Skip to content

Schema query area and light filtering ​

VTableQuery generates query controls from fields or columns. Place it above a table or use it on its own. useTableQuery manages the draft, parameter transforms, submission and reset; its complete options, state and methods are listed in the useTableQuery API.

ModeHow to use itInteraction
QueryFilterDefault, or layout-type="QueryFilter"Query form with a Search button and Enter submission
LightFilterlayout-type="LightFilter"Filter chips show selected values and open popups

QueryFilter ​

Register the host UI library's Form and FormItem with the control factory, and QueryFilter uses them by default. Set form-mode="builtin" to use VTable's form and labels while keeping the registered host controls. The built-in form is also the fallback when no host form is registered.

The native form defaults to query-layout="inline". Items use their own widths and wrap when space runs out. The collapsed layout reserves room for the search, reset and expand actions. Expanding shows all fields, and toggling the layout keeps their values.

Native inline forms keep the host form items' horizontal spacing. Antdv inline items have no bottom margin, so VTable adds a gap between wrapped rows using the host's --ant-margin, or 16px when unavailable. Element Plus items already have a bottom margin, so the container adds no vertical gap by default. Use searchGutter: [horizontal, vertical] or --vtg-query-row-gap to set the container's extra row gap explicitly; this adds to any host form-item bottom margin.

To align fields across rows, set query-layout="grid" on a native form. It then shares the built-in form's 24-unit grid, including span and search.colSize. The separate layout prop controls label placement and accepts horizontal, inline and vertical.

In native mode, formProps configures the host form, while search.formItemProps on a column or formItemProps on an explicit field configures its form item. For example, with Ant Design Vue or Antdv Next, use :form-props="{ colon: false }" to hide the label colons or search: { formItemProps: { tooltip: 'Supports partial matches' } } for a single label. fieldProps still controls input width, placeholders and other control props.

vue
<!-- Registering Form and FormItem enables native inline rendering by default. -->
<VTableQuery :query="query" :columns="columns" :controls="controls" />

<!-- Align native form items on a 24-unit grid with 8 units per ordinary field. -->
<VTableQuery :query="query" :columns="columns" :controls="controls" query-layout="grid" :span="8" />

<!-- Keep host input controls and switch back to VTable's built-in form. -->
<VTableQuery :query="query" :columns="columns" :controls="controls" form-mode="builtin" />
Edit in Playground

Toggle Narrow container to see the same schema fit a smaller area. Expand the form to edit the two-column date range and inspect the submitted parameters.

Query area widthDefault columnsDefault label placement
Below 513px1Above
513px to 700px2Above
701px to 1351px3Beside
1352px and up4Beside

The grid has 24 units. span sets the number of units per column and accepts a breakpoint map such as { xs: 24, md: 12, xl: 8 }. A field's colSize sets how many columns it occupies and defaults to 1. For example, with span: 8, a field with search: { colSize: 2 } occupies 16 units. Fields with a larger order appear first. Ties retain their original order.

The grid's default collapsed layout reserves a column for the actions, then fits the fields in order and shows at least the first visible field. defaultColsNumber can lower the first-row limit. defaultFormItemsNumber takes precedence and can show more than one row while collapsed; both count options apply only to the grid. Native inline packing measures item widths to determine its first-row capacity. Use defaultCollapsed to change the initial state, v-model:collapsed to control it, or :collapse-render="false" to hide the toggle.

LightFilter ​

Click a primary filter chip to open its popup. Single selects and date / dateRange controls submit on selection. Text, number and time-bearing controls (time / dateTime / dateTimeRange) wait for confirmation in the filter popup footer. Multiple selects submit individual changes and stay open for further choices, including both Ant Design Vue multiple / tags modes. The clear button on a chip submits immediately.

Fields marked secondary: true appear under More filters. Set collapse to group every field in one popup. Edits in the group are submitted together on confirmation. Closing the popup discards pending edits. The footer's clear button clears the group and submits. Customize these actions with footerRender or set the popup mount point with getPopupContainer.

Edit in Playground

Registering controls from your existing UI library ​

Pass the host components your application has already installed to the adapter factory; the library does not import another UI library. Both factories register all 11 built-in control keys listed below.

ts
import { Button, DatePicker, Form, Input, InputNumber, Select, TimePicker } from 'ant-design-vue'
import { createAntdvTableControls, type TableControls } from '@vtable-guild/vtable-guild'

const controls: TableControls = createAntdvTableControls({
  Form,
  FormItem: Form.Item,
  Button,
  Input,
  Select,
  InputNumber,
  DatePicker,
  RangePicker: DatePicker.RangePicker,
  TimePicker,
})

With Antdv Next, import Form, FormItem and Button directly from antdv-next. For Element Plus, pass ElForm, ElFormItem and ElButton as Form, FormItem and Button to createElementPlusTableControls, alongside controls such as Input: ElInput, Select: ElSelect and Option: ElOption. textarea uses Input.TextArea (Ant Design Vue) or ElInput with type="textarea" (Element Plus); when the Input you pass has no static TextArea, pass TextArea to the factory as well. Dates use strings by default through the host valueFormat, which the application can adjust with fieldProps.valueFormat. Query and editing can share the same registry, but each has its own field rules and value transforms.

Query control valueType ​

TableQueryField.valueType selects a control from the controls registry and defaults to text. Both adapter factories register the 11 built-in keys below. See TableControlValueType for the field type and TableBuiltinControlValueType for the built-in keys.

valueTypeControlValue format and common configuration
textText inputText; host props such as placeholder / maxlength.
textareaMulti-line text inputText that may contain line breaks. In an editable table Enter breaks the line and Ctrl / ⌘ + Enter commits; in the stable layout the box fills its cell.
selectSelectSingle value or array; field options / dictionary supplies options.
enumAlias of selectIdentical to select.
digitNumber inputNumber; configure the host with min / max / step / precision.
moneyNumber inputSame host as digit; configure money formatting and precision explicitly.
dateDate pickerA YYYY-MM-DD string.
dateTimeDate-time pickerA YYYY-MM-DD HH:mm:ss string.
dateRangeDate range pickerAn array of two YYYY-MM-DD strings.
dateTimeRangeDate-time range pickerAn array of two YYYY-MM-DD HH:mm:ss strings.
timeTime pickerAn HH:mm:ss string.

enum uses the same control as select. money uses a number input and does not add a currency symbol, thousands separators or two decimal places automatically. select / enum use the field's options or dictionary and preserve string, number and boolean identities on update. Clearing a single select normalizes the host's empty value to undefined. Multiple-select arrays are decoded item by item, so clearing to [] preserves the empty array. If the host instead returns a non-array empty value, it is normalized to undefined.

Ant Design Vue range controls require RangePicker and time controls require TimePicker in the factory input. Element Plus selects require Option: ElOption. Cleared date and time values follow the host control; normalize them with fieldTransforms when your API requires a different value. Explicitly setting fieldProps.valueFormat: undefined uses the host's native date values instead of the formatted strings listed above.

Common configuration ​

fieldProps is passed directly to the host control and uses that UI library's prop names. For example, Ant Design Vue enables multiple selection with mode: 'multiple', while Element Plus uses multiple: true.

ts
import type { TableQueryField } from '@vtable-guild/vtable-guild'

interface SearchValues {
  username: string
  status?: number
  amount?: number
  createdAt?: [string, string]
}

const fields: TableQueryField<SearchValues>[] = [
  {
    name: 'username',
    label: 'Username',
    valueType: 'text',
    fieldProps: { placeholder: 'Enter a username', style: { width: '200px' } },
  },
  {
    name: 'status',
    label: 'Status',
    valueType: 'select',
    options: [
      { value: 1, label: 'Enabled' },
      { value: 0, label: 'Disabled' },
    ],
    fieldProps: { style: { width: '120px' } },
  },
  { name: 'amount', label: 'Amount', valueType: 'money', fieldProps: { min: 0, precision: 2 } },
  {
    name: 'createdAt',
    label: 'Created',
    valueType: 'dateRange',
    fieldProps: { valueFormat: 'YYYY-MM-DD' },
  },
]

Custom registration and spelling errors ​

TableControlValueType provides built-in key suggestions while accepting custom strings. Each custom name must match a registry key. Factory registries are read-only, so create a new registry with object spread:

ts
import { h } from 'vue'
import UserPicker from './UserPicker.vue'
import type { TableControls, TableQueryField } from '@vtable-guild/vtable-guild'

// controls is the built-in registry above. This UserPicker uses the modelValue protocol.
const businessControls = {
  ...controls,
  userPicker: (context) =>
    h(UserPicker, {
      ...context.fieldProps,
      id: context.id,
      modelValue: context.value,
      disabled: context.disabled || context.readonly,
      'onUpdate:modelValue': context.onChange,
    }),
} satisfies TableControls

const ownerFields: TableQueryField<{ owner?: string }>[] = [
  { name: 'owner', label: 'Owner', valueType: 'userPicker' },
]

Pass businessControls as the controls prop of VTableQuery. Call context.onChange(value) to update the current draft. A custom LightFilter control can set renderer.lightFilter.formatValue(context) to render its selected-value summary. Standalone popups wait for confirmation by default. Use submitOnChange to submit immediately and closeOnChange to control whether the popup closes after submission. Use context.lightFilter?.getPopupContainer to mount any nested control menus inside the filter popup.

An unregistered name, such as sleect instead of select, falls back to controls.text. If text is also missing, there is no default control to render. The component does not automatically register a control or raise a validation error for a spelling mistake. The open TableControlValueType also accepts arbitrary strings; use satisfies TableBuiltinControlValueType when a configuration must accept built-in keys only.

Difference from cell display types ​

ConfigurationRegistryPurpose
TableQueryField.valueType / column search.valueTypecontrolsSelects a query input using TableControlValueType
Column editor.valueTypecontrolsSelects an editing input with the same control types
Column valueTyperenderersSelects a cell display, such as formatted money, dates or tags

The money display type formats an amount, and the money query control uses a number input. deriveTableQueryFields uses select for columns with a nonempty valueEnum, digit for digit / money columns, the same key for date and time types, and text for other types. Set search.valueType to override the result. For example, a column can display date and query with dateRange.

Explicit schema and column derivation ​

A schema field's name maps to a top-level key of the query draft. valueType selects the control and fieldProps configures the host props; fieldProps / hidden / disabled / readonly can be callbacks that read the whole draft. Inside a LightFilter popup, these callbacks include pending edits so dependent fields appear or disappear immediately. Confirmation submits the edits together; dismissal discards them.

ts
import {
  useTableQuery,
  deriveTableQueryFields,
  type TableQueryColumn,
} from '@vtable-guild/vtable-guild'

interface Values {
  name: string
  range?: [string, string]
  status?: number
}
const query = useTableQuery<Values>({ defaultValues: { name: '' }, onSubmit: request.submit })

const columns: TableQueryColumn<Values>[] = [
  { dataIndex: 'name', title: 'Name', visible: false, search: { order: 1 } },
  {
    dataIndex: 'range',
    title: 'Date',
    valueType: 'date',
    search: { valueType: 'dateRange', order: 2 },
  },
  {
    dataIndex: 'status',
    title: 'Status',
    valueEnum: new Map([[1, 'In progress']]),
    search: { order: 3 },
  },
]
const fields = deriveTableQueryFields(columns)

Pass columns directly to VTableQuery, or pass fields to supply an explicit schema. search: false and hideInSearch: true exclude a column. search.hidden controls visibility and search.order controls order. The table's visible / responsive options control column display. You can also use the helper's second argument to override the config by name, or pass false to exclude a field. A nested array dataIndex does not infer the query param automatically and needs an explicit search.name; grouped columns are expanded recursively, and only the first field with a given name is kept.

valueEnum derives select options automatically only from string labels, and preserves the string, number and boolean identity of Map keys; numeric, boolean and VNode labels are not converted automatically, so use explicit options or the field slot instead.

Hidden fields, collapsed fields and reset ​

  • The default preserve: true keeps hidden fields and collapsed QueryFilter fields in the submitted parameters.
  • :preserve="false" omits those fields from the request and retains the values in the draft. Omitted fields skip their individual fieldTransforms.
  • Expanding or collapsing QueryFilter changes the display only. LightFilter secondary fields still participate in the query while the popup is closed.
  • QueryFilter reset restores defaultValues and clears host validation feedback in native mode. It then runs the custom validate callback and calls onReset once, falling back to onSubmit if onReset was omitted.

Host validation runs before the query ​

Native mode automatically validates the host form when the search button, Enter or the component's submit() method runs. Failed validation blocks the request and the host FormItem displays its feedback. Define form-wide rules in formProps.rules or field-specific rules in search.formItemProps.rules. By default, validation includes non-hidden fields, including collapsed fields; with preserve: false, it includes only currently displayed fields. Reset restores defaults and clears validation feedback without requiring those defaults to pass host rules.

ts
const columns: TableQueryColumn<Values>[] = [
  {
    dataIndex: 'name',
    title: 'Name',
    search: {
      formItemProps: {
        tooltip: 'Supports partial matches',
        rules: [{ required: true, message: 'Enter a name' }],
      },
      fieldProps: { placeholder: 'Enter a name', allowClear: true },
    },
  },
]

When validate(values, { fields, action, signal }) returns false or throws, the request is blocked. values is a snapshot and fields contains the fields that are not hidden; repeated calls while the same action is pending share the result. An input change or the component unmounting invalidates the old validation, so a stale result never submits a newer draft.

In native mode, host validation runs before this callback. If your application already wraps the query area in its own Form, use the built-in integration shown below.

ts
import type { TableQueryFieldSlotProps } from '@vtable-guild/vtable-guild'

const FieldControl = ({ field, control }: TableQueryFieldSlotProps<Values>) => {
  const valueType = field.valueType ?? 'text'
  const render = Object.hasOwn(controls, valueType) ? controls[valueType] : controls.text
  return render?.(control)
}
vue
<a-form ref="form" :model="query.draft.value" :rules="queryRules">
  <VTableQuery
    form-mode="builtin"
    root-tag="div"
    :query="query"
    :fields="fields"
    :controls="controls"
    :validate="() => form.validate().then(() => true)"
  >
    <template #field="{ field, control }">
      <a-form-item :name="field.name">
        <FieldControl :field="field" :control="control" :values="query.draft.value" />
      </a-form-item>
    </template>
  </VTableQuery>
</a-form>

When your own host Form wraps the query area, use built-in mode with rootTag="div" to avoid nesting forms. errors accepts error text indexed by field name; when the host FormItem already shows the errors, it can take care of the feedback. Query rules and editing rules are provided separately, and query fields do not inherit required from editing automatically. The concrete rules, cross-field relations and validation messages are still provided by the host form or the application's validate.

Query state and requests ​

Connect requests through useTableQuery({ onSubmit, onReset }). With useTableRequest, pass request.submit and request.reset respectively. To update several fields together, edit query.draft.value and then call the component instance's submit() once.

Component methods and query state methods ​

When using VTableQuery validation and field visibility rules, call the component ref from both page buttons and application code.

Entry pointFlow
queryForm.value?.submit()Uses current field visibility and preserve to determine which fields to omit, then runs host form validation and custom validate. Calls query.submit() when validation passes.
queryForm.value?.reset()Restores the default draft, then captures which fields to omit using their visibility at that point and preserve. Clears host validation messages and runs custom validate. Calls query.reset() when validation passes.
query.submit() / query.reset()Runs the useTableQuery parameter transforms and the onSubmit or onReset callback. When calling these methods directly, the application handles validation and can specify fields to omit with omitFields.

With preserve: false, expanding a QueryFilter while async validation is pending still leaves the previously collapsed fields out of that request. Repeated calls to the same pending component method share a result. The component emits submitted or reset when the query state method finishes and the operation is still current.

Use TableQueryInstance to access the component methods below. Leave the keyword empty and click "Search from a page button": the component returns false, and the submission callback and component event counts stay unchanged. Enter a non-empty keyword and search again to invoke the callback and emit submitted once each. preserve: false omits the hidden internal field from the params. Reset restores the empty keyword, and custom validate prevents submission again.

Edit in Playground

The component instance's submit() and reset() return Promise<boolean>. Failed component validation returns false directly and emits no submitted / reset event. These events are emitted after the query state method finishes while the operation remains current; their payload reports transform and callback success. Read network results from the request manager's state. cancel() cancels a pending component operation and retains the draft for further editing; requests already sent by the application are cancelled through useTableRequest or the application request manager.

Dictionaries, dependencies and application controls ​

A field's dictionary takes the return value of useTableDictionary; the component wires up options, loading, error and search, and fills in the labels of selected values from valueEnum. Several query fields or table displays can share one dictionary instance.

ts
const teams = useTableDictionary({
  dictionary: teamDictionary,
  params: () => ({ region: query.draft.value.region }),
  selectedOptions: selectedTeamLabels,
  debounceTime: 200,
})
const fields = [{ name: 'team', label: 'Team', valueType: 'select', dictionary: teams }]

A dependency change refreshes the candidate options and does not clear the application's selection automatically. When downstream conditions need to be cleared, the application modifies the draft explicitly; existing values should not be cleared out of nowhere, even when the options have not loaded yet. An explicit options config takes precedence over the dictionary's candidate options. controls is a table-level, read-only registry; add a key to register an application control. The field slot receives { field, values, control, layoutType }; calling control.onChange(value) enters the same update / debounce protocol, and control.onSearch(keyword) connects to the dictionary search.

The actions slot receives { submit, reset, submitting, collapsed, toggleCollapsed, showCollapseButton }. Set type="button" on custom native buttons so that they do not trigger the form's default submit.

API ​

See the useTableQuery API for the composable's complete options and return value. This page covers the VTableQuery component; before calling it from application code, read Component methods and query state methods.

VTableQuery Props ​

PropTypeDefaultDescription
queryUseTableQueryReturn<TValues, TParams>RequiredQuery draft, parameter transforms and submission protocol.
rootTag'form' | 'div''form'Use div inside a host form.
fieldsreadonly TableQueryField<TValues>[]-Explicit field configuration, taking precedence over columns.
columnsreadonly TableQueryColumn<TRecord, TValues>[]-Derive query fields from column configuration.
controlsTableControlsRequiredRegistry of host UI controls.
layoutType'QueryFilter' | 'LightFilter''QueryFilter'Query mode.
formMode'native' | 'builtin'AutomaticUse the registered host Form and FormItem when available; otherwise use the built-in form.
queryLayout'inline' | 'grid'inline for native modeField arrangement for native QueryFilter. The built-in form always uses the grid.
formPropsRecord<string, unknown>-Props passed to the native Form. VTable owns the draft and the query and reset flow.
layout'horizontal' | 'inline' | 'vertical'ResponsiveQueryFilter label layout. Native inline packing defaults to inline.
spanTableQueryProps['span']ResponsiveUnits per column in grid layout. Accepts a breakpoint map.
defaultColsNumbernumber-Grid columns kept while collapsed, capped by first-row capacity.
defaultFormItemsNumbernumber-Controls the grid field limit across collapsed rows and takes precedence over defaultColsNumber.
defaultCollapsedbooleanquery.collapsedInitial QueryFilter collapse state, collapsed by default.
collapsedboolean-Controlled state. Supports v-model:collapsed.
onCollapse(collapsed: boolean) => void-Called on expand or collapse.
collapseRenderTableQueryProps['collapseRender']-Customize the expand toggle label or hide it with false.
optionRenderTableQueryProps['optionRender']-Customize the QueryFilter actions.
searchTextstringLocalizedSearch button text.
resetTextstringLocalizedReset button text.
labelWidthnumber | 'auto'80 in built-in modeQueryFilter label width in pixels. Native mode uses the host default when omitted.
searchGutternumber | [number, number]24 in grid; see native inline defaultsExtra container gap or [horizontal, vertical], in pixels. Native inline defaults to the host margin (16px fallback) vertically for Antdv and 0 for Element Plus, retaining host form-item bottom margins.
splitbooleanfalseShow separators between rows in a vertical QueryFilter.
preservebooleantrueInclude hidden and collapsed QueryFilter fields in request parameters.
showHiddenNumbooleanfalseShow the number of collapsed fields on the toggle.
submitterfalse | TableQuerySubmitter-Configure the search and reset buttons or their renderer.
submitterColSpanPropsTableQueryProps['submitterColSpanProps']-Set the QueryFilter action area's grid span and offset.
collapsebooleanfalseGroup every LightFilter field into one popup.
collapseLabelVNodeChildLocalizedLabel for the combined LightFilter trigger.
footerRenderTableQueryProps['footerRender']-Customize the LightFilter group popup's footer.
getPopupContainer(anchor: HTMLElement) => HTMLElement | string-Set the LightFilter popup mount point.
disabledbooleanfalseDisable query controls and actions.
validateTableQueryProps<TValues, TParams>['validate']-Validate before submit or reset. Returning false or throwing blocks the operation.
errorsReadonly<Partial<Record<keyof TValues & string, string>>>-External error messages keyed by field name.
localePartial<TableQueryLocale>-Override button and status text for this instance.
uiPartial<Record<QuerySlots, string>>-Override query theme slot classes for this instance.
classstring-Add a class to the query root.

TableQueryField ​

FieldTypeDefaultDescription
namekeyof TValues & stringRequiredField name in the draft. May be omitted when fields are derived from column definitions; defaults to the column's dataIndex.
labelVNodeChild-Field label.
valueTypeTableControlValueType'text'Selects a built-in or custom control from controls; unknown names fall back to text. See TableBuiltinControlValueType for all built-in keys.
ordernumber0Fields with larger values come first.
colSizenumber1Number of columns occupied in the QueryFilter grid.
secondarybooleanfalsePlace the field in the LightFilter group popup.
hiddenboolean | ((context: TableQueryFieldContext<TValues>) => boolean)falseHide the field and use preserve to control its inclusion in the request.
disabledboolean | ((context: TableQueryFieldContext<TValues>) => boolean)falseKeeps the control and disables updates.
readonlyboolean | ((context: TableQueryFieldContext<TValues>) => boolean)falseDisplays the control as read-only.
formItemPropsTableQueryField<TValues>['formItemProps']-Props such as tooltip or rules passed to the native FormItem. Can be computed from the field context.
fieldPropsTableQueryField<TValues>['fieldProps']-Props passed to the host control, or a function computing them from the field context.
optionsMaybeRefOrGetter<readonly TableDictionaryOption[]>-Explicit options; take precedence over the dictionary result.
dictionaryTableDictionaryBinding-Provides dictionary options, loading state and search.

VTableQuery Slots ​

SlotPayload typeDescription
fieldTableQueryFieldSlotProps<TValues>Receives field, values, control and layoutType; supports control updates and dictionary search.
actionsTableQueryActionSlotPropsReceives the search, reset and collapse actions, along with the submitting and collapsed states.

VTableQuery Events ​

EventPayloadDescription
submitted(success: boolean) => voidEmitted after the component finishes calling query.submit() while the operation remains current. The payload reports query transform and callback success. Operations stopped before that call, including failed component validation, disabling, cancellation or disposal, emit no event. Read network results from the request manager.
reset(success: boolean) => voidEmitted after the component finishes calling query.reset() while the operation remains current. The payload reports query transform and reset callback success. Operations stopped earlier, such as failed component validation, emit no event.
update:collapsed(collapsed: boolean) => voidThe state after a component expand or collapse action. Use with v-model:collapsed.

VTableQuery instance methods ​

Call these methods through ref<TableQueryInstance>(); see Component methods and query state methods for the full example.

MethodTypeDescription
submit() => Promise<boolean>Captures which fields to omit for the current draft under preserve before running host form validation and custom validate. On success, calls query.submit() with those omissions. Returns true when transforms and the callback succeed. Returns false for validation failure, disabling, cancellation, obsolete work, or failed transforms or callbacks.
reset() => Promise<boolean>Restores the default draft, then captures which fields to omit under preserve using their visibility at that point. Clears host validation messages, runs custom validate and, on success, calls query.reset() with those omissions. Returns true when transforms and the reset callback succeed. Returns false for failed or obsolete work.
cancel() => voidCancels a pending component operation so its method resolves to false, retaining the draft for further editing. Requests already sent by the application are cancelled through useTableRequest or the application request manager.

Theming and layout ​

In the built-in grid, labelWidth sets the label width. It defaults to 80px and also accepts 'auto'. The grid's searchGutter accepts a horizontal gap or [horizontal, vertical], with 24px as the default gap. Set fieldProps.style.width to size a host control within its field.

Override query area classes with the instance's ui or global theme.query.slots. The selected preset supplies the query area and popup styles, and the host UI library styles its own inputs.

QueryFilter animates its height when expanding or collapsing, with a default duration of 180ms. Adjust the duration and easing with --vtg-query-motion-duration and --vtg-query-motion-easing; set the duration to 0s to disable the animation. The component also respects the system's reduced-motion preference.

ui slots ​

Theme configSlotDescription
theme.queryrootSchema query area root container.
theme.queryfieldsQueryFilter grid or LightFilter chip container.
theme.queryfieldLayout of a single query field.
theme.querylabelField label.
theme.querycontrolHost control container.
theme.queryerrorSingle-field error.
theme.queryactionsQuery, reset and collapse action area.
theme.queryfeedbackOverall error feedback for the query area.
theme.querycollapseEntry point for expanding or collapsing fields.

Preset defaults ​

ts
createVTableGuild({
  theme: {
    query: {
      slots: {
        root: 'min-w-0 rounded-[var(--vtg-query-radius,6px)] bg-[color:var(--color-surface)] p-[var(--vtg-query-padding,24px)] font-[family-name:var(--font-family-base)] text-[length:var(--vtg-table-font-size)] text-[color:var(--color-on-surface)]',
        fields: '',
        field: 'flex min-w-0 items-start gap-[var(--vtg-query-label-gap,12px)]',
        label: 'flex h-[var(--vtg-query-control-height,32px)] shrink-0 items-center',
        control: 'min-w-0',
        error: 'mt-1 text-[color:var(--vtg-cell-error)] text-[length:var(--vtg-query-error-font-size,12px)]',
        actions: 'flex min-h-[var(--vtg-query-control-height,32px)] max-w-full flex-wrap items-center gap-[var(--vtg-query-action-gap,8px)]',
        feedback: 'w-full text-[color:var(--vtg-cell-error)]',
        collapse: 'inline-flex items-center gap-1',
      },
      variants: {
        layoutType: {
          QueryFilter: {
            control: 'flex-1',
            actions: 'justify-end',
          },
          LightFilter: {
            root: 'p-[var(--vtg-query-light-padding,16px)]',
          },
        },
      },
      defaultVariants: {
        layoutType: 'QueryFilter',
      },
    },
  },
})
ts
createVTableGuild({
  themePreset: 'element-plus',
  theme: {
    query: {
      slots: {
        root: 'min-w-0 rounded-[var(--vtg-query-radius,6px)] bg-[color:var(--color-surface)] p-[var(--vtg-query-padding,24px)] font-[family-name:var(--font-family-base)] text-[length:var(--vtg-table-font-size)] text-[color:var(--color-on-surface)] rounded-[var(--vtg-query-radius,4px)]',
        fields: '',
        field: 'flex min-w-0 items-start gap-[var(--vtg-query-label-gap,12px)]',
        label: 'flex h-[var(--vtg-query-control-height,32px)] shrink-0 items-center',
        control: 'min-w-0',
        error: 'mt-1 text-[color:var(--vtg-cell-error)] text-[length:var(--vtg-query-error-font-size,12px)]',
        actions: 'flex min-h-[var(--vtg-query-control-height,32px)] max-w-full flex-wrap items-center gap-[var(--vtg-query-action-gap,8px)]',
        feedback: 'w-full text-[color:var(--vtg-cell-error)]',
        collapse: 'inline-flex items-center gap-1',
      },
      variants: {
        layoutType: {
          QueryFilter: {
            control: 'flex-1',
            actions: 'justify-end',
          },
          LightFilter: {
            root: 'p-[var(--vtg-query-light-padding,16px)]',
          },
        },
      },
      defaultVariants: {
        layoutType: 'QueryFilter',
      },
    },
  },
})

CSS variables ​

VariablePurposeantdvelement-plus
--vtg-cell-errorField error status color; also used for query and editing validation text#ff4d4f#f56c6c
--vtg-query-paddingPadding of the regular query areaundeclared, falls back to 24pxundeclared, falls back to 24px
--vtg-query-light-paddingPadding of the lightweight query areaundeclared, falls back to 16pxundeclared, falls back to 16px
--vtg-query-column-gapHorizontal gap between fieldsundeclared, falls back to 24pxundeclared, falls back to 24px
--vtg-query-row-gapVertical gap between fieldsundeclared, falls back to 24pxundeclared, falls back to 24px
--vtg-query-label-widthField label widthundeclared, falls back to 80pxundeclared, falls back to 80px
--vtg-query-label-gapGap between the field label and the controlundeclared, falls back to 12pxundeclared, falls back to 12px
--vtg-query-control-heightAlignment height of labels and the action areaundeclared, falls back to 32pxundeclared, falls back to 32px
--vtg-query-vertical-label-gapGap between the label and control in a vertical formundeclared, falls back to 4pxundeclared, falls back to 4px
--vtg-query-split-colorRow separator color in a vertical formundeclared, falls back to var(--vtg-table-border-color)undeclared, falls back to var(--vtg-table-border-color)
--vtg-query-light-control-widthWidth of regular controls in a LightFilter popupundeclared, falls back to 200pxundeclared, falls back to 200px
--vtg-query-light-range-widthWidth of date range controls in a LightFilter popupundeclared, falls back to 320pxundeclared, falls back to 320px
--vtg-query-light-gapGap between filter chipsundeclared, falls back to 8pxundeclared, falls back to 8px
--vtg-query-light-borderFilter chip border colorundeclared, falls back to transparentundeclared, falls back to transparent
--vtg-query-light-radiusFilter chip radiusundeclared, falls back to var(--vtg-btn-border-radius)undeclared, falls back to var(--vtg-btn-border-radius)
--vtg-query-light-bgFilter chip backgroundundeclared, falls back to transparentundeclared, falls back to transparent
--vtg-query-light-hover-borderHovered filter chip border colorundeclared, falls back to var(--color-primary)undeclared, falls back to var(--color-primary)
--vtg-query-light-hover-bgHovered filter chip backgroundundeclared, falls back to var(--color-text-hover-bg)undeclared, falls back to var(--color-text-hover-bg)
--vtg-query-light-active-bgActive filter chip backgroundundeclared, falls back to var(--vtg-table-row-selected-bg)undeclared, falls back to var(--vtg-table-row-selected-bg)
--vtg-query-light-active-colorActive filter chip text colorundeclared, falls back to var(--color-primary)undeclared, falls back to var(--color-primary)
--vtg-query-light-heightMinimum filter chip heightundeclared, falls back to var(--vtg-query-control-height, 32px)undeclared, falls back to var(--vtg-query-control-height, 32px)
--vtg-query-light-trigger-paddingHorizontal filter button paddingundeclared, falls back to 8pxundeclared, falls back to 8px
--vtg-query-light-summary-widthMaximum filter summary widthundeclared, falls back to 244pxundeclared, falls back to 244px
--vtg-query-light-icon-gapGap between filter text and iconundeclared, falls back to 6pxundeclared, falls back to 6px
--vtg-query-light-icon-sizeFilter icon font sizeundeclared, falls back to 10pxundeclared, falls back to 10px
--vtg-query-light-collapse-icon-sizeIcon size of the combined filter triggerundeclared, falls back to 14pxundeclared, falls back to 14px
--vtg-query-light-popup-paddingFilter popup paddingundeclared, falls back to 12pxundeclared, falls back to 12px
--vtg-query-light-popup-gapFilter popup fields and actions spacingundeclared, falls back to 12pxundeclared, falls back to 12px
--vtg-query-light-label-gapGap between label and control in a filter popupundeclared, falls back to 4pxundeclared, falls back to 4px
--vtg-query-action-gapGap between action buttonsundeclared, falls back to 8pxundeclared, falls back to 8px
--vtg-query-radiusQuery area container radiusundeclared, falls back to 6pxundeclared, falls back to 4px
--vtg-query-error-font-sizeFont size of query area error textundeclared, falls back to 12pxundeclared, falls back to 12px

A full ProForm, ModalForm, DrawerForm or CRUD page engine is outside the scope of this adapter layer.

Type Declarations ​

View type declarations
ts
export { VTableQuery } from '@vtable-guild/vtable-guild'

export declare function deriveTableQueryFields<
  TValues extends object,
  TRecord extends object = TValues,
>(
  columns: readonly TableQueryColumn<TRecord, TValues>[],
  overrides?: Partial<Record<keyof TValues & string, false | Partial<TableQueryField<TValues>>>>,
): TableQueryField<TValues>[]

export interface TableQueryFieldContext<TValues extends object> {
  values: Readonly<TValues>
  field: TableQueryField<TValues>
}

/** Query metadata is independent from table visibility, ordering and readonly field formatting. */
export interface TableQueryField<TValues extends object = Record<string, unknown>> {
  name: keyof TValues & string
  label?: VNodeChild
  /** Select a registered host control; missing or unregistered keys fall back to text. */
  valueType?: TableControlValueType
  /** Larger values appear first, independently of table column order. */
  order?: number
  /** QueryFilter grid units; one unit occupies the configured span. Ignored by inline packing. */
  colSize?: number
  /** LightFilter fields collected inside More filters. */
  secondary?: boolean
  hidden?: boolean | ((context: TableQueryFieldContext<TValues>) => boolean)
  disabled?: boolean | ((context: TableQueryFieldContext<TValues>) => boolean)
  readonly?: boolean | ((context: TableQueryFieldContext<TValues>) => boolean)
  /** Props passed to the registered host FormItem in native mode. */
  formItemProps?:
    | Record<string, unknown>
    | ((context: TableQueryFieldContext<TValues>) => Record<string, unknown>)
  fieldProps?:
    | Record<string, unknown>
    | ((context: TableQueryFieldContext<TValues>) => Record<string, unknown>)
  options?: MaybeRefOrGetter<readonly TableDictionaryOption[]>
  dictionary?: TableDictionaryBinding
}

export type TableQueryColumn<TRecord extends object, TValues extends object = TRecord> =
  | (ColumnType<TRecord> & {
      search?: false | (Omit<TableQueryField<TValues>, 'name'> & { name?: keyof TValues & string })
      hideInSearch?: boolean
    })
  | (Omit<ColumnGroupType<TRecord>, 'children'> & {
      children: TableQueryColumn<TRecord, TValues>[]
      search?: false
      hideInSearch?: boolean
    })
  | ColumnSentinel

export interface TableQueryLocale {
  label: string
  submit: string
  reset: string
  expand: string
  collapse: string
  more: string
  confirm: string
  clear: string
  validationFailed: string
}

export interface TableQueryValidationContext<TValues extends object> {
  fields: readonly TableQueryField<TValues>[]
  action: 'submit' | 'reset'
  signal: AbortSignal
}

export interface TableQueryProps<
  TValues extends object = Record<string, unknown>,
  TParams extends object = TValues,
  TRecord extends object = TValues,
> {
  query: UseTableQueryReturn<TValues, TParams>
  /** Use div when an existing host Form wraps this query area, avoiding nested forms. */
  rootTag?: 'form' | 'div'
  /** Explicit fields take precedence over columns. */
  fields?: readonly TableQueryField<TValues>[]
  columns?: readonly TableQueryColumn<TRecord, TValues>[]
  controls: TableControls
  layoutType?: 'QueryFilter' | 'LightFilter'
  /** Defaults to the registered host Form/FormItem, or built-in rendering if unavailable. */
  formMode?: 'native' | 'builtin'
  /** Native QueryFilter defaults to inline packing. Built-in QueryFilter always uses the grid. */
  queryLayout?: 'inline' | 'grid'
  /** Props passed to the registered host Form. VTable owns the model and submit/reset flow. */
  formProps?: Record<string, unknown>
  layout?: 'horizontal' | 'inline' | 'vertical'
  span?: number | Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>>
  /** Grid layout: maximum controls in the collapsed row, limited by its grid capacity. */
  defaultColsNumber?: number
  /** Grid layout: overrides defaultColsNumber and permits multiple collapsed rows. */
  defaultFormItemsNumber?: number
  defaultCollapsed?: boolean
  collapsed?: boolean
  onCollapse?: (collapsed: boolean) => void
  collapseRender?: boolean | ((collapsed: boolean) => VNodeChild)
  optionRender?:
    | boolean
    | ((context: TableQueryActionSlotProps, buttons: VNodeChild[]) => VNodeChild)
  searchText?: string
  resetText?: string
  labelWidth?: number | 'auto'
  searchGutter?: number | [number, number]
  split?: boolean
  /** Keep hidden fields registered and include their values in submissions. Defaults to true. */
  preserve?: boolean
  showHiddenNum?: boolean
  submitter?: false | TableQuerySubmitter
  submitterColSpanProps?: { span: number; offset?: number; class?: string; style?: CSSProperties }
  /** LightFilter: collect every field in the filter popup. */
  collapse?: boolean
  collapseLabel?: VNodeChild
  footerRender?: false | ((context: TableQueryFooterContext<TValues>) => VNodeChild)
  getPopupContainer?: (anchor: HTMLElement) => HTMLElement | string
  disabled?: boolean
  /** Connect a host form's validate here. false or an exception prevents query submission. */
  validate?: (
    values: Readonly<TValues>,
    context: TableQueryValidationContext<TValues>,
  ) => boolean | void | Promise<boolean | void>
  errors?: Readonly<Partial<Record<keyof TValues & string, string>>>
  locale?: Partial<TableQueryLocale>
  ui?: Partial<Record<QuerySlots, string>>
  class?: string
}

export interface TableQuerySubmitter {
  searchConfig?: { submitText?: string; resetText?: string }
  submitButtonProps?: false | Record<string, unknown>
  resetButtonProps?: false | Record<string, unknown>
  render?: false | ((context: TableQueryActionSlotProps, buttons: VNodeChild[]) => VNodeChild)
}

export interface TableQueryFooterContext<TValues extends object = Record<string, unknown>> {
  values: Readonly<TValues>
  fields: readonly TableQueryField<TValues>[]
  confirm: () => Promise<boolean>
  clear: () => Promise<boolean>
  submitting: boolean
}

export interface TableQueryFieldSlotProps<TValues extends object = Record<string, unknown>> {
  field: TableQueryField<TValues>
  values: Readonly<TValues>
  control: TableControlContext
  layoutType: 'QueryFilter' | 'LightFilter'
}

export interface TableQueryActionSlotProps {
  submit: () => Promise<boolean>
  reset: () => Promise<boolean>
  submitting: boolean
  collapsed: boolean
  toggleCollapsed: () => void
  showCollapseButton: boolean
}

export interface TableQuerySlots<TValues extends object = Record<string, unknown>> {
  field?: (props: TableQueryFieldSlotProps<TValues>) => VNodeChild
  actions?: (props: TableQueryActionSlotProps) => VNodeChild
}

export interface TableQueryInstance {
  submit: () => Promise<boolean>
  reset: () => Promise<boolean>
  /** Cancel pending host validation, retaining form values. */
  cancel: () => void
}

import { TABLE_QUERY_FORM_ADAPTER } from '@vtable-guild/vtable-guild'

/** Shared by schema query fields and editable cells; host libraries remain optional. */
export interface TableControlContext {
  value: unknown
  onChange: (value: unknown) => void
  onSearch?: (keyword: string) => void
  fieldProps: Record<string, unknown>
  options: readonly TableDictionaryOption[]
  disabled: boolean
  readonly: boolean
  loading: boolean
  error?: string
  id?: string
  name?: string
  mode: 'query' | 'edit'
  /** Present when the renderer is used inside a LightFilter popup. */
  lightFilter?: {
    grouped: boolean
    getPopupContainer: () => HTMLElement
  }
  /** Present when the renderer is mounted for click-triggered cell editing. */
  cellEdit?: TableControlCellEditBridge
}

export type TableControlCellCommitMode = 'blur' | 'change' | 'popup-close'

export type TableControlCellCommitReason = TableControlCellCommitMode | 'explicit'

export interface TableControlCellEditOptions {
  /** Select how cell editing commits for this control; may depend on fieldProps (e.g. single vs multiple Select). */
  commitOn?:
    | TableControlCellCommitMode
    | ((context: TableControlContext) => TableControlCellCommitMode)
  /** Open the host popup automatically when entering cell edit mode. */
  autoOpen?: boolean | ((context: TableControlContext) => boolean)
}

export interface TableControlCellEditBridge {
  /** True for the initial focus of an editor whose control requests an open popup. */
  autoOpen?: boolean
  /** The host has requested a close and may still publish a value as focus leaves. */
  closingPopup?: boolean
  commit: (reason?: TableControlCellCommitReason) => void
  cancel: () => void
  /** Track host popup open state so popup Esc / internal focus transfers do not prematurely commit or cancel. */
  setPopupOpen: (open: boolean) => void
}

export interface TableControlLightFilterOptions {
  /** Selected value summary in the filter trigger. */
  formatValue?: (context: TableControlContext) => VNodeChild
  /** Submit changes immediately for standalone fields. Grouped edits always require confirmation. */
  submitOnChange?: boolean
  /** Defaults to true for standalone fields that submit immediately. */
  closeOnChange?: boolean | ((context: TableControlContext) => boolean)
}

export type TableControlRenderer = ((context: TableControlContext) => VNodeChild) & {
  lightFilter?: TableControlLightFilterOptions
  cellEdit?: TableControlCellEditOptions
  /**
   * Stretch the control over the full height of its cell in the 'stable' edit layout.
   * For multi-line controls: a cell whose text wraps is then edited in a box of the same size.
   */
  fill?: boolean
}

/** Optional form renderer metadata on a controls registry. */
export { TABLE_QUERY_FORM_ADAPTER } from '@vtable-guild/vtable-guild'

export interface TableQueryFormAdapter {
  kind: 'antdv' | 'element-plus'
  Form: Component
  FormItem: Component
  Button?: Component
}

export type TableControls = Readonly<
  Record<string, TableControlRenderer> & { [TABLE_QUERY_FORM_ADAPTER]?: TableQueryFormAdapter }
>

/** Pass components already installed by the host application. No UI library is imported here. */
export interface TableControlComponents {
  Input: Component
  /** Multi-line input. Ant Design Vue defaults to Input.TextArea; Element Plus uses Input with type="textarea". */
  TextArea?: Component
  Select: Component
  InputNumber: Component
  DatePicker: Component
  RangePicker?: Component
  TimePicker?: Component
  /** Element Plus ElOption; unused by the Ant Design Vue adapter. */
  Option?: Component
  /** Provide both Form and FormItem to enable native query form rendering. */
  Form?: Component
  FormItem?: Component
  /** Use the host button for native query form actions. */
  Button?: Component
}