Skip to content

GhostQueryBuilder reference ​

Package: @ghostvue/vue. Status: experimental (stability policy).

Headless editor for a saved, grouped filter: a tree of conditions and nested AND/OR groups with NOT on a whole group, built from GhostSelect, GhostRadioGroup, GhostCheckbox, GhostInput, GhostNumberInput and GhostDatePicker. Edits change only the draft; Apply validates it and emits a frozen, JSON-serializable expression with an increasing revision, and an invalid draft keeps the last applied expression. Restored filters keep unknown or retired fields in place with an explanation until the user repairs or removes them. Ships choice, yes/no, date, text and number value editors that offer only the operators of their field type, with "From" and "To" controls for ranges, and the `value` slot for app-supplied editors. `0` and `false` are ordinary values, and a cleared input removes the value.

Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.

All component references

Props ​

NameTypeDefaultRequiredDescription
applyDefaultbooleanfalseNoWhen the default expression has no blocking issue, it is also the initial applied expression at revision `1`. No `apply` event is emitted.
createId((kind: 'group' | 'rule') => string)—NoMints ids for nodes the user adds. Never called during setup, so a random or counter id is SSR-safe. A returned duplicate is a development error and is replaced.
defaultExpressionunknown—NoInitial draft, read once at setup through `validateQueryExpression`. Malformed input starts an empty draft and warns in development.
disabledbooleanfalseNoDisables every control. Programmatic `restore`, `reset`, `clear` and `apply` still work.
fieldsFields—YesConsumer-owned schema. Reactive: a change revalidates the draft and never changes the applied expression.
maxDepthnumber3NoNesting levels the user can create, counting the root as 1.
messagesPartial<GhostQueryBuilderMessages>—NoReactive overrides for every component-owned string. Omitted entries use the English defaults.
readonlybooleanfalseNoRenders the draft as static text with no form controls and no add or remove actions. `disabled` takes precedence.

Emits ​

NamePayloadDescription
applyGhostQueryApplyEvent<Fields>After every successful Apply, including a programmatic one, a restore with `apply: true` and an Apply of an unchanged draft. The expression is a fresh, frozen, deep copy; `revision` increases by one each time. A failed Apply emits nothing.

Models ​

None declared.

Slots ​

NameDescription
actionsRenders after the root group, typically Apply, Reset and the app's Save button.
emptyRenders inside an empty root group, before its Add condition button.
valueReplaces the value editor of every rule that has a usable field and an operator that takes a value.

Slot props: actions ​

None declared.

Slot props: empty ​

None declared.

Slot props: value ​

None declared.

Exposed members ​

NameTypeDescription
applied{ readonly version: 1; readonly root: { readonly kind: 'group'; readonly id: string; readonly combinator: 'and' | 'or'; readonly not: boolean; readonly children: readonly (any | GhostQueryDeepReadonly<import('./ghost-query-builder').GhostQueryRuleForField<Fields[number]>>)[]; }; } | nullLast applied expression, or `null` before the first Apply.
appliedIssuesreadonly GhostQueryIssue[]Issues found when `applied` is revalidated against the current `fields`.
apply(options?: { focus?: boolean; }) => GhostQueryApplyResult<Fields>Validates the draft. Success replaces the applied expression and emits `apply`. Failure keeps it, shows every issue and, unless `focus: false`, focuses the first invalid control.
clear() => voidReplaces the draft with an empty root group, keeping the root id. Does not apply.
dirtyboolean`true` when the draft differs from `applied` (or from an empty root when nothing is applied).
draft{ readonly version: 1; readonly root: { readonly kind: 'group'; readonly id: string; readonly combinator: 'and' | 'or'; readonly not: boolean; readonly children: readonly ({ readonly kind: 'rule'; readonly id: string; readonly field: string | null; readonly operator: string | null; readonly value?: string | number | boolean | readonly string[] | { readonly start: string; readonly end: string; } | { readonly min: number; readonly max: number; } | { readonly start: string | null; readonly end: string | null; } | { readonly min: number | null; readonly max: number | null; } | { readonly kind: 'stored'; readonly raw: unknown; }; } | any)[]; }; }Current draft. Read-only; edit through the UI or `restore`.
issuesreadonly GhostQueryIssue[]Current blocking issues of the draft, in document order, whether or not they are displayed yet.
reset() => voidReplaces the draft with the applied expression, else the last restored or default input, else an empty root.
restore(input: unknown, options?: { apply?: boolean; }) => GhostQueryRestoreResultReplaces the draft with a parsed expression. With `apply: true` it then applies without moving focus. Malformed input changes nothing.
revisionnumberRevision of `applied`; `0` before the first Apply.

Parts and data attributes ​

AttributeValueDescription
data-partrootThe element with role="group" named by the consumer's aria-label or aria-labelledby. Consumer class, style and attributes land here.
data-partgroupEvery group, the root group included. Nested groups have role="group" named by their group-name heading.
data-partgroup-headerHeader of a group: its name, the Match radio group, the NOT checkbox and Remove group.
data-partgroup-nameVisible heading that names a nested group, such as "Group 2: Any condition (OR)".
data-partcombinatorThe Match label and its All/Any GhostRadioGroup; in read-only mode, the root's combinator text.
data-partnotThe label wrapping the NOT GhostCheckbox; in read-only mode, the root's NOT text.
data-partchildrenThe <ul> of a group's conditions and nested groups. Each item is an <li>.
data-partconnectorVisible AND/OR text between the items of a group, aria-hidden because the group name states it.
data-partruleA condition: role="group" named "Condition N", holding the field, operator and value parts and its remove button.
data-partfieldWrapper of a condition's Field GhostSelect, its label and its issue; static text in read-only mode. Its popup, and the Operator popup, are portaled to <body> and carry the class ghost-query-builder-listbox.
data-partoperatorWrapper of a condition's Operator GhostSelect, or the operator as static text for an unavailable field or in read-only mode.
data-partvalueWrapper of a condition's value editor (the `value` slot or the built-in editor), its label and its issue; static text in read-only mode or for an unavailable field. A range editor holds a role="group" named by the Value label with "From" and "To" labels and controls. Date popups are portaled to <body> and carry the class ghost-query-builder-calendar; choice popups carry ghost-query-builder-listbox.
data-partvalue-textText of a retained value the built-in editor cannot show in its control, such as a restored unparseable date or a value kept across an operator change. It is part of the control's description and disappears once an edit replaces the value.
data-partlabelVisible Field, Operator and Value label of a condition's control, and the From and To labels of a range editor, referenced by the control's aria-labelledby.
data-partremoveNative button that removes a condition or a nested group. Its name includes the position and a summary.
data-partadd-ruleNative button that appends a condition to a group and focuses its Field control.
data-partadd-groupNative button that appends a group with one condition. Absent at maxDepth.
data-partissueText of a shown issue, rendered next to its control and referenced by that control's aria-describedby.
data-partemptyDefault content inside an empty root group (messages.emptyRoot), replaced by the `empty` slot.
data-partstatusVisually hidden polite status region that announces additions, removals, Apply results and restore results. It starts empty.
data-combinatorand, orOn groups: the group's combinator.
data-negatedpresentPresent on groups with NOT turned on.
data-depth1, 2, 3On groups and rules: nesting level, counting the root group as 1. Restored filters can be deeper than maxDepth.
data-invalidpresentPresent on rules and groups that have a shown issue.
data-retiredpresentPresent on a rule whose stored field is unknown, retired, duplicated or set up incorrectly.
data-disabledpresentPresent on the root while disabled.
data-readonlypresentPresent on the root while read-only (and not disabled).

CSS variables ​

None declared.

Accessibility ​

Role: group. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/.

Required ARIA attributes: aria-label, aria-labelledby.

Keyboard ​

KeyActionAutomated browser test
TabMoves through the builder in document order: each group header (Match, NOT, Remove group), its conditions (Field, Operator, Value or From and To, Remove condition), then Add condition and Add group. Every control is its own Tab stop; there is no roving tabindex.GhostQueryBuilder @component:GhostQueryBuilder › Tab and Shift+Tab move through every control in document order (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › read-only renders text with no Tab stops; right-to-left keeps the keyboard contract; narrow widths do not overflow (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › number value: arrows step, Enter applies, a half range focuses its To input (@ghostvue/vue)
Shift+TabMoves backward through the same order.GhostQueryBuilder @component:GhostQueryBuilder › Tab and Shift+Tab move through every control in document order (@ghostvue/vue)
ArrowRightOn the Match radio group or a yes/no value, selects the other option (GhostRadioGroup contract); the group name and connectors update. In a text, number or date value, moves the caret.GhostQueryBuilder @component:GhostQueryBuilder › Match arrows and NOT Space update the group name and connectors (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › read-only renders text with no Tab stops; right-to-left keeps the keyboard contract; narrow widths do not overflow (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › yes/no value: no selection until picked, arrows select, a failed Apply focuses the group (@ghostvue/vue)
ArrowLeftOn the Match radio group or a yes/no value, selects the other option. In a text, number or date value, moves the caret.GhostQueryBuilder @component:GhostQueryBuilder › Match arrows and NOT Space update the group name and connectors (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › read-only renders text with no Tab stops; right-to-left keeps the keyboard contract; narrow widths do not overflow (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › yes/no value: no selection until picked, arrows select, a failed Apply focuses the group (@ghostvue/vue)
ArrowDownOn a Field, Operator or choice value control, opens its list (GhostSelect contract); in the open list, moves to the next option. In a number value, steps down (GhostNumberInput).GhostQueryBuilder @component:GhostQueryBuilder › Field and Operator selects: arrows open and move, Enter picks, Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › Enter applies through the form; a failed Apply focuses the first invalid control and is announced (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › choice value: Select keys pick one or many active options; Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › number value: arrows step, Enter applies, a half range focuses its To input (@ghostvue/vue)
ArrowUpOn a Field, Operator or choice value control, opens its list at the end; in the open list, moves to the previous option. In a number value, steps up (GhostNumberInput).GhostQueryBuilder @component:GhostQueryBuilder › Field and Operator selects: arrows open and move, Enter picks, Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › number value: arrows step, Enter applies, a half range focuses its To input (@ghostvue/vue)
SpaceOn the NOT checkbox, toggles NOT for the whole group (disabled while the group is empty). In an open multiple choice list, toggles the active option and keeps the list open. On Add or Remove buttons, activates them.GhostQueryBuilder @component:GhostQueryBuilder › Match arrows and NOT Space update the group name and connectors (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › Enter and Space on Add actions append and focus the new Field control (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › choice value: Select keys pick one or many active options; Escape closes only the popup (@ghostvue/vue)
EnterOn Add condition or Add group, appends and focuses the new condition's Field control. On a Remove button, removes the item and recovers focus. In an open choice list, picks the active option. In a date value, commits typed text (GhostDatePicker); on its calendar button, opens the calendar dialog. In a text or number value inside a <form>, performs native implicit submission; the builder binds no Enter of its own.GhostQueryBuilder @component:GhostQueryBuilder › Field and Operator selects: arrows open and move, Enter picks, Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › Enter and Space on Add actions append and focus the new Field control (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › Enter on Remove recovers focus after the first, middle and last conditions and groups (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › Enter applies through the form; a failed Apply focuses the first invalid control and is announced (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › choice value: Select keys pick one or many active options; Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › number value: arrows step, Enter applies, a half range focuses its To input (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › date value: Enter commits typed dates, an incomplete range keeps the applied filter and focuses To (@ghostvue/vue)
EscapeIn an open Field, Operator or choice list, or an open date calendar, closes only the popup and returns focus to its control. The builder binds no Escape of its own.GhostQueryBuilder @component:GhostQueryBuilder › Field and Operator selects: arrows open and move, Enter picks, Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › choice value: Select keys pick one or many active options; Escape closes only the popup (@ghostvue/vue)
GhostQueryBuilder @component:GhostQueryBuilder › date value: Enter commits typed dates, an incomplete range keeps the applied filter and focuses To (@ghostvue/vue)

Verification ​

Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.

CategoryStatusEvidence
Automated keyboardPassedEvery declared key maps to a Chromium browser test that CI runs and requires to pass on every commit.
Manual interactionNot reviewedNo review recorded.
Assistive technologyNot reviewedNo review recorded.

Examples ​

query-builder/custom-editor ​

Example source

Custom value editor Headless

A `value` slot editor for the Assignee field proposes typed values and reports half-typed text as pending, which blocks Apply; other fields keep the built-in editor.

Assignment filter

Match
  • Field
    Operator
    Value

Nothing applied yet.

query-builder/issue-triage ​

Example source

Triage issues with saved filters Headless

Apply `Open AND (High priority OR Overdue)` to five sample issues, save the applied filter separately, and reopen it with the same matching IDs. A saved filter with a retired Severity rule blocks Apply until it is repaired, the Assignee field uses a custom person picker, and a slower, older search never replaces newer results.

Issue filter

Match
  • Field
    Operator
    Value
  • Group 2: Any condition (OR)
    Match
    • Field
      Operator
      Value
    • Field
      Operator
      Value

Saved filters

  • Urgent open issues
  • Open, hide archived and unassigned
  • Last quarter triage

Matching issues

query-builder/text-filter ​

Example source

Filter by text fields Headless

Build `Title contains "crash" AND (Assignee is missing OR Reporter equals "ana")` with the keyboard, apply it, and see the applied expression and revision. An empty text value blocks Apply and focus moves to it.

Issue filter

Match
  • Field
    Operator
    Value
  • Group 2: Any condition (OR)
    Match
    • Field
      Operator
    • Field
      Operator
      Value

Applied filter (revision 0)

Nothing applied yet.