View as Markdown

API reference: @salmonui/query-builder

QueryBuilderApiinterface

import type { QueryBuilderApi } from '@salmonui/query-builder';
interface QueryBuilderApi {
    getValue(): QueryGroup;
    setValue(value: QueryGroup): void;
    getValidValue(): QueryGroup;
    getNode(id: string): QueryNode | null;
    addRules(rules: readonly QueryRule[], groupId?: string): string[];
    addGroups(groups: readonly QueryGroup[], groupId?: string): string[];
    remove(ids: string | readonly string[]): void;
    clone(id: string, options?: {
        readonly parentId?: string;
        readonly index?: number;
    }): string | null;
    lock(id: string, locked?: boolean): void;
    validate(): boolean;
    reset(): void;
    focus(): void;
}
QueryBuilderApi members (12)
NameSignatureDescription
getValuegetValue(): QueryGroup;
setValuesetValue(value: QueryGroup): void;
getValidValuegetValidValue(): QueryGroup;

The value without incomplete rules and empty groups.

getNodegetNode(id: string): QueryNode | null;
addRulesaddRules(rules: readonly QueryRule[], groupId?: string): string[];

Appends rules to the group groupId (default: the root); returns their ids.

addGroupsaddGroups(groups: readonly QueryGroup[], groupId?: string): string[];
removeremove(ids: string | readonly string[]): void;
cloneclone(id: string, options?: { readonly parentId?: string; readonly index?: number; }): string | null;

Copies a node next to itself (or into parentId at index); returns the copy's id.

locklock(id: string, locked?: boolean): void;
validatevalidate(): boolean;

Validates every rule, shows inline errors and returns whether the value is valid.

resetreset(): void;

Back to defaultValue (uncontrolled) or proposes it (controlled).

focusfocus(): void;

Moves focus to the first control.