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.
| Mode | How to use it | Interaction |
|---|---|---|
| QueryFilter | Default, or layout-type="QueryFilter" | Query form with a Search button and Enter submission |
| LightFilter | layout-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.
<!-- 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" />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 width | Default columns | Default label placement |
|---|---|---|
| Below 513px | 1 | Above |
| 513px to 700px | 2 | Above |
| 701px to 1351px | 3 | Beside |
| 1352px and up | 4 | Beside |
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.
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.
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.
| valueType | Control | Value format and common configuration |
|---|---|---|
text | Text input | Text; host props such as placeholder / maxlength. |
textarea | Multi-line text input | Text 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. |
select | Select | Single value or array; field options / dictionary supplies options. |
enum | Alias of select | Identical to select. |
digit | Number input | Number; configure the host with min / max / step / precision. |
money | Number input | Same host as digit; configure money formatting and precision explicitly. |
date | Date picker | A YYYY-MM-DD string. |
dateTime | Date-time picker | A YYYY-MM-DD HH:mm:ss string. |
dateRange | Date range picker | An array of two YYYY-MM-DD strings. |
dateTimeRange | Date-time range picker | An array of two YYYY-MM-DD HH:mm:ss strings. |
time | Time picker | An 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.
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:
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
| Configuration | Registry | Purpose |
|---|---|---|
TableQueryField.valueType / column search.valueType | controls | Selects a query input using TableControlValueType |
Column editor.valueType | controls | Selects an editing input with the same control types |
Column valueType | renderers | Selects 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.
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: truekeeps 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 individualfieldTransforms.- Expanding or collapsing QueryFilter changes the display only. LightFilter
secondaryfields still participate in the query while the popup is closed. - QueryFilter reset restores
defaultValuesand clears host validation feedback in native mode. It then runs the customvalidatecallback and callsonResetonce, falling back toonSubmitifonResetwas 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.
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.
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)
}<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 point | Flow |
|---|---|
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.
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.
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
| Prop | Type | Default | Description |
|---|---|---|---|
query | UseTableQueryReturn<TValues, TParams> | Required | Query draft, parameter transforms and submission protocol. |
rootTag | 'form' | 'div' | 'form' | Use div inside a host form. |
fields | readonly TableQueryField<TValues>[] | - | Explicit field configuration, taking precedence over columns. |
columns | readonly TableQueryColumn<TRecord, TValues>[] | - | Derive query fields from column configuration. |
controls | TableControls | Required | Registry of host UI controls. |
layoutType | 'QueryFilter' | 'LightFilter' | 'QueryFilter' | Query mode. |
formMode | 'native' | 'builtin' | Automatic | Use the registered host Form and FormItem when available; otherwise use the built-in form. |
queryLayout | 'inline' | 'grid' | inline for native mode | Field arrangement for native QueryFilter. The built-in form always uses the grid. |
formProps | Record<string, unknown> | - | Props passed to the native Form. VTable owns the draft and the query and reset flow. |
layout | 'horizontal' | 'inline' | 'vertical' | Responsive | QueryFilter label layout. Native inline packing defaults to inline. |
span | TableQueryProps['span'] | Responsive | Units per column in grid layout. Accepts a breakpoint map. |
defaultColsNumber | number | - | Grid columns kept while collapsed, capped by first-row capacity. |
defaultFormItemsNumber | number | - | Controls the grid field limit across collapsed rows and takes precedence over defaultColsNumber. |
defaultCollapsed | boolean | query.collapsed | Initial QueryFilter collapse state, collapsed by default. |
collapsed | boolean | - | Controlled state. Supports v-model:collapsed. |
onCollapse | (collapsed: boolean) => void | - | Called on expand or collapse. |
collapseRender | TableQueryProps['collapseRender'] | - | Customize the expand toggle label or hide it with false. |
optionRender | TableQueryProps['optionRender'] | - | Customize the QueryFilter actions. |
searchText | string | Localized | Search button text. |
resetText | string | Localized | Reset button text. |
labelWidth | number | 'auto' | 80 in built-in mode | QueryFilter label width in pixels. Native mode uses the host default when omitted. |
searchGutter | number | [number, number] | 24 in grid; see native inline defaults | Extra 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. |
split | boolean | false | Show separators between rows in a vertical QueryFilter. |
preserve | boolean | true | Include hidden and collapsed QueryFilter fields in request parameters. |
showHiddenNum | boolean | false | Show the number of collapsed fields on the toggle. |
submitter | false | TableQuerySubmitter | - | Configure the search and reset buttons or their renderer. |
submitterColSpanProps | TableQueryProps['submitterColSpanProps'] | - | Set the QueryFilter action area's grid span and offset. |
collapse | boolean | false | Group every LightFilter field into one popup. |
collapseLabel | VNodeChild | Localized | Label for the combined LightFilter trigger. |
footerRender | TableQueryProps['footerRender'] | - | Customize the LightFilter group popup's footer. |
getPopupContainer | (anchor: HTMLElement) => HTMLElement | string | - | Set the LightFilter popup mount point. |
disabled | boolean | false | Disable query controls and actions. |
validate | TableQueryProps<TValues, TParams>['validate'] | - | Validate before submit or reset. Returning false or throwing blocks the operation. |
errors | Readonly<Partial<Record<keyof TValues & string, string>>> | - | External error messages keyed by field name. |
locale | Partial<TableQueryLocale> | - | Override button and status text for this instance. |
ui | Partial<Record<QuerySlots, string>> | - | Override query theme slot classes for this instance. |
class | string | - | Add a class to the query root. |
TableQueryField
| Field | Type | Default | Description |
|---|---|---|---|
name | keyof TValues & string | Required | Field name in the draft. May be omitted when fields are derived from column definitions; defaults to the column's dataIndex. |
label | VNodeChild | - | Field label. |
valueType | TableControlValueType | 'text' | Selects a built-in or custom control from controls; unknown names fall back to text. See TableBuiltinControlValueType for all built-in keys. |
order | number | 0 | Fields with larger values come first. |
colSize | number | 1 | Number of columns occupied in the QueryFilter grid. |
secondary | boolean | false | Place the field in the LightFilter group popup. |
hidden | boolean | ((context: TableQueryFieldContext<TValues>) => boolean) | false | Hide the field and use preserve to control its inclusion in the request. |
disabled | boolean | ((context: TableQueryFieldContext<TValues>) => boolean) | false | Keeps the control and disables updates. |
readonly | boolean | ((context: TableQueryFieldContext<TValues>) => boolean) | false | Displays the control as read-only. |
formItemProps | TableQueryField<TValues>['formItemProps'] | - | Props such as tooltip or rules passed to the native FormItem. Can be computed from the field context. |
fieldProps | TableQueryField<TValues>['fieldProps'] | - | Props passed to the host control, or a function computing them from the field context. |
options | MaybeRefOrGetter<readonly TableDictionaryOption[]> | - | Explicit options; take precedence over the dictionary result. |
dictionary | TableDictionaryBinding | - | Provides dictionary options, loading state and search. |
VTableQuery Slots
| Slot | Payload type | Description |
|---|---|---|
field | TableQueryFieldSlotProps<TValues> | Receives field, values, control and layoutType; supports control updates and dictionary search. |
actions | TableQueryActionSlotProps | Receives the search, reset and collapse actions, along with the submitting and collapsed states. |
VTableQuery Events
| Event | Payload | Description |
|---|---|---|
submitted | (success: boolean) => void | Emitted 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) => void | Emitted 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) => void | The 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.
| Method | Type | Description |
|---|---|---|
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 | () => void | Cancels 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 config | Slot | Description |
|---|---|---|
theme.query | root | Schema query area root container. |
theme.query | fields | QueryFilter grid or LightFilter chip container. |
theme.query | field | Layout of a single query field. |
theme.query | label | Field label. |
theme.query | control | Host control container. |
theme.query | error | Single-field error. |
theme.query | actions | Query, reset and collapse action area. |
theme.query | feedback | Overall error feedback for the query area. |
theme.query | collapse | Entry point for expanding or collapsing fields. |
Preset defaults
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',
},
},
},
})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
| Variable | Purpose | antdv | element-plus |
|---|---|---|---|
--vtg-cell-error | Field error status color; also used for query and editing validation text | #ff4d4f | #f56c6c |
--vtg-query-padding | Padding of the regular query area | undeclared, falls back to 24px | undeclared, falls back to 24px |
--vtg-query-light-padding | Padding of the lightweight query area | undeclared, falls back to 16px | undeclared, falls back to 16px |
--vtg-query-column-gap | Horizontal gap between fields | undeclared, falls back to 24px | undeclared, falls back to 24px |
--vtg-query-row-gap | Vertical gap between fields | undeclared, falls back to 24px | undeclared, falls back to 24px |
--vtg-query-label-width | Field label width | undeclared, falls back to 80px | undeclared, falls back to 80px |
--vtg-query-label-gap | Gap between the field label and the control | undeclared, falls back to 12px | undeclared, falls back to 12px |
--vtg-query-control-height | Alignment height of labels and the action area | undeclared, falls back to 32px | undeclared, falls back to 32px |
--vtg-query-vertical-label-gap | Gap between the label and control in a vertical form | undeclared, falls back to 4px | undeclared, falls back to 4px |
--vtg-query-split-color | Row separator color in a vertical form | undeclared, falls back to var(--vtg-table-border-color) | undeclared, falls back to var(--vtg-table-border-color) |
--vtg-query-light-control-width | Width of regular controls in a LightFilter popup | undeclared, falls back to 200px | undeclared, falls back to 200px |
--vtg-query-light-range-width | Width of date range controls in a LightFilter popup | undeclared, falls back to 320px | undeclared, falls back to 320px |
--vtg-query-light-gap | Gap between filter chips | undeclared, falls back to 8px | undeclared, falls back to 8px |
--vtg-query-light-border | Filter chip border color | undeclared, falls back to transparent | undeclared, falls back to transparent |
--vtg-query-light-radius | Filter chip radius | undeclared, falls back to var(--vtg-btn-border-radius) | undeclared, falls back to var(--vtg-btn-border-radius) |
--vtg-query-light-bg | Filter chip background | undeclared, falls back to transparent | undeclared, falls back to transparent |
--vtg-query-light-hover-border | Hovered filter chip border color | undeclared, falls back to var(--color-primary) | undeclared, falls back to var(--color-primary) |
--vtg-query-light-hover-bg | Hovered filter chip background | undeclared, falls back to var(--color-text-hover-bg) | undeclared, falls back to var(--color-text-hover-bg) |
--vtg-query-light-active-bg | Active filter chip background | undeclared, falls back to var(--vtg-table-row-selected-bg) | undeclared, falls back to var(--vtg-table-row-selected-bg) |
--vtg-query-light-active-color | Active filter chip text color | undeclared, falls back to var(--color-primary) | undeclared, falls back to var(--color-primary) |
--vtg-query-light-height | Minimum filter chip height | undeclared, falls back to var(--vtg-query-control-height, 32px) | undeclared, falls back to var(--vtg-query-control-height, 32px) |
--vtg-query-light-trigger-padding | Horizontal filter button padding | undeclared, falls back to 8px | undeclared, falls back to 8px |
--vtg-query-light-summary-width | Maximum filter summary width | undeclared, falls back to 244px | undeclared, falls back to 244px |
--vtg-query-light-icon-gap | Gap between filter text and icon | undeclared, falls back to 6px | undeclared, falls back to 6px |
--vtg-query-light-icon-size | Filter icon font size | undeclared, falls back to 10px | undeclared, falls back to 10px |
--vtg-query-light-collapse-icon-size | Icon size of the combined filter trigger | undeclared, falls back to 14px | undeclared, falls back to 14px |
--vtg-query-light-popup-padding | Filter popup padding | undeclared, falls back to 12px | undeclared, falls back to 12px |
--vtg-query-light-popup-gap | Filter popup fields and actions spacing | undeclared, falls back to 12px | undeclared, falls back to 12px |
--vtg-query-light-label-gap | Gap between label and control in a filter popup | undeclared, falls back to 4px | undeclared, falls back to 4px |
--vtg-query-action-gap | Gap between action buttons | undeclared, falls back to 8px | undeclared, falls back to 8px |
--vtg-query-radius | Query area container radius | undeclared, falls back to 6px | undeclared, falls back to 4px |
--vtg-query-error-font-size | Font size of query area error text | undeclared, falls back to 12px | undeclared, 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
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
}