# Filters

Filter bar for lists and tables. The app declares the filterable `fields` (text, number, date, options, yes/no or its own input; columns, joins, relations and custom queries are declared on the field), and the user adds the conditions one at a time: "Add filter" lists the fields (with a search when they are many), then a card asks for the operator of that field and the value. Each condition becomes a pill "field · operator · value": click it to edit, its × removes it. The "Filters" button shows how many conditions are active and opens a panel with every condition in rows ("Where … and …"), where `allowOr` lets the user switch to OR and `maxDepth` allows nested groups. `pinned` fields are always in the bar, and `presets` are chips that add ready-made conditions. Changes apply as soon as a condition is complete (after `applyDelay`); with `confirm` the card and the panel have Cancel and Apply. On screens up to 1024px wide the panel opens in a bottom sheet (`mobileDrawer`); when the bar is narrower than 640px (a phone, a side column) it is compact: the pills and "Clear" stay on one row that scrolls sideways, "Add filter" lives only in the panel or the sheet opened by "Filters", and next to a `prependSnippet` (for example a search) "Filters" shows only its icon and the count (`data-compact`). The conditions live in `value`, a plain JSON tree (see `createFilters`), and `onchange` receives it with the `FilterBuilder` of the query, built by `filtersToBuilder`. Every text can be translated with `labels`.

```ts
import { Filters } from '@likable-hair/svelte';
```

Category: composed. Source: `src/lib/components/composed/search/Filters.svelte`.

## Examples

### Add filters one at a time

"Add filter" lists the fields, then the card asks for the operator and the value; each condition becomes a pill (click to edit, × to remove). The "Filters" button opens every condition in rows. Below, the query that `onchange` receives (`builder.toJson()`).

```svelte
<script lang="ts">
	import { Filters, createFilters, filterCondition, type FilterBuilder } from '@likable-hair/svelte';
	import { fields } from './fields.js';

	let value = $state(
		createFilters([
			filterCondition('service', 'in', [{ value: 3, label: 'Balayage' }]),
			filterCondition('amount', 'gte', 50)
		])
	);
	let query = $state<FilterBuilder>();
</script>

<div class="example">
	<Filters {fields} bind:value onchange={(change) => (query = change.builder)} />
	<pre>{JSON.stringify(query?.toJson() ?? 'Change a filter to see the query', null, 2)}</pre>
</div>

<style>
	.example {
		display: grid;
		gap: 16px;
	}

	pre {
		max-height: 220px;
		margin: 0;
		overflow: auto;
		padding: 12px;
		border-radius: var(--global-radius-md);
		background: var(--global-color-surface-2);
		color: var(--global-color-text-2);
		font-size: 11.5px;
	}
</style>
```

### AND, OR and nested groups

`allowOr` lets the user switch the conditions to OR (on the second row), `maxDepth` allows groups: every filter is a box with "Add nested filter", which turns it into a group (OR under AND when `allowOr` is on) or adds a row to it, and the root has one "Add filter". Turn them on only when the backend applies OR groups correctly.

```svelte
<script lang="ts">
	import { Filters, createFilters, filterCondition, filterGroup } from '@likable-hair/svelte';
	import { fields } from './fields.js';

	let value = $state(
		createFilters([
			filterCondition('date', 'period', 'thisMonth'),
			filterGroup('or', [
				filterCondition('status', 'in', [{ value: 'waiting', label: 'Waiting' }]),
				filterCondition('paid', 'isFalse')
			])
		])
	);
</script>

<Filters {fields} bind:value allowOr maxDepth={1} />
```

### Pinned fields, presets and actions

`pinned` keeps a field in the bar even without a condition; `presets` are chips that add ready-made conditions; `actionsSnippet` puts the page actions on the right. A `hidden` field with a `locked` condition is a fixed constraint the user does not see.

```svelte
<script lang="ts">
	import { mdiPlus } from '@mdi/js';
	import { Button, Filters, createFilters, filterCondition, type FilterField, type FilterPreset } from '@likable-hair/svelte';
	import { fields as base } from './fields.js';

	const fields: FilterField[] = [
		...base.map((field) => (field.name === 'status' ? { ...field, pinned: true } : field)),
		{ name: 'tenant', label: 'Salon', type: 'number', column: 'appointments.salonId', hidden: true }
	];

	const presets: FilterPreset[] = [
		{ id: 'today', label: 'Today', count: 18, conditions: [{ field: 'date', operator: 'period', value: 'today' }] },
		{ id: 'week', label: 'This week', count: 94, conditions: [{ field: 'date', operator: 'period', value: 'thisWeek' }] },
		{ id: 'unpaid', label: 'Not paid', count: 7, conditions: [{ field: 'paid', operator: 'isFalse' }] }
	];

	let value = $state(createFilters([filterCondition('tenant', 'eq', 12, { locked: true })]));
</script>

<Filters {fields} {presets} bind:value>
	{#snippet actionsSnippet()}
		<Button size="sm" icon={mdiPlus}>New appointment</Button>
	{/snippet}
</Filters>
```

### Confirm before applying, in Italian

With `confirm` the card and the panel work on a draft with Cancel and Apply, as in v4. `locale="it"` is enough for Italian: it picks every text of the library (operators, periods, placeholders, the lists and the calendar included) and the format of dates and numbers; `labels` changes only the texts you pass. The field labels are the app's own.

```svelte
<script lang="ts">
	import { Filters, createFilters } from '@likable-hair/svelte';
	import { italianFields } from './fields.js';

	let value = $state(createFilters());
</script>

<Filters fields={italianFields} bind:value confirm locale="it" />
```

### Playground: every field, operator and option

One field for each type and option (several columns and words, suggestions, case sensitivity, units and scale, column comparisons, date only, date and time, periods and relative dates, options from a list, a search, countries, toggles, a Postgres array, a relation through a subquery, JSONB keys, nullable and computed yes/no, a hidden constraint), with OR and nested groups (pick how deep with `maxDepth`, 2 by default), presets, saved filters (kept in this browser) and a pinned field. Below: the query of `filtersToBuilder`, the URL parameter of `filtersToParam` and every operator of every type.

```svelte
<script lang="ts">
	import {
		mdiAccountOutline,
		mdiBarcode,
		mdiCalendarClock,
		mdiCalendarOutline,
		mdiCashMultiple,
		mdiCheckCircleOutline,
		mdiContentCut,
		mdiEarth,
		mdiPackageVariant,
		mdiPalette,
		mdiStar,
		mdiTagOutline,
		mdiWeight
	} from '@mdi/js';
	import {
		DEFAULT_FILTER_LABELS,
		FILTER_OPERATORS,
		Filters,
		Select,
		createFilters,
		filterCondition,
		filterGroup,
		filtersToBuilder,
		filtersToParam,
		type FilterField,
		type FilterItem,
		type FilterPreset
	} from '@likable-hair/svelte';

	const staff: FilterItem[] = [
		{ value: 1, label: 'Giulia Marini' },
		{ value: 2, label: 'Luca Rossi' },
		{ value: 3, label: 'Sara Bianchi' },
		{ value: 4, label: 'Marta Neri' }
	];
	const products: FilterItem[] = [
		{ value: 'P-100', label: 'P-100 Nourishing shampoo' },
		{ value: 'P-140', label: 'P-140 Keratin mask' },
		{ value: 'P-220', label: 'P-220 Argan oil' }
	];

	const wait = (signal: AbortSignal) =>
		new Promise<void>((resolve, reject) => {
			const timer = setTimeout(resolve, 300);
			signal.addEventListener('abort', () => {
				clearTimeout(timer);
				reject(signal.reason);
			});
		});

	const fields: FilterField[] = [
		{
			name: 'client',
			label: 'Client',
			icon: mdiAccountOutline,
			type: 'string',
			columns: ['clients.firstName', 'clients.lastName'],
			words: true,
			category: 'Text'
		},
		{
			name: 'product',
			label: 'Product',
			icon: mdiBarcode,
			type: 'string',
			column: 'products.name',
			suggestColumn: 'products.code',
			suggest: async ({ searchText, signal }) => {
				await wait(signal);
				return products.filter((item) => String(item.label).toLowerCase().includes(searchText.toLowerCase()));
			},
			category: 'Text'
		},
		{
			name: 'code',
			label: 'Code (case sensitive)',
			type: 'string',
			column: 'appointments.code',
			caseSensitive: true,
			category: 'Text'
		},
		{
			name: 'amount',
			label: 'Amount',
			icon: mdiCashMultiple,
			type: 'number',
			unit: '€',
			column: 'appointments.amount',
			compareWith: [{ column: 'appointments.deposit', label: 'Deposit' }],
			category: 'Numbers'
		},
		{
			name: 'weight',
			label: 'Weight',
			icon: mdiWeight,
			type: 'number',
			unit: 't',
			scale: 1000,
			column: 'goods.weightKg',
			category: 'Numbers'
		},
		{
			name: 'date',
			label: 'Date',
			icon: mdiCalendarOutline,
			type: 'date',
			column: 'appointments.startsAt',
			category: 'Dates'
		},
		{
			name: 'due',
			label: 'Due day (date only)',
			icon: mdiCalendarOutline,
			type: 'date',
			dateOnly: true,
			column: 'invoices.dueDate',
			category: 'Dates'
		},
		{
			name: 'delivered',
			label: 'Delivered at (date and time)',
			icon: mdiCalendarClock,
			type: 'date',
			withTime: true,
			column: 'orders.deliveredAt',
			compareWith: [{ column: 'orders.promisedAt', label: 'Promised at' }],
			category: 'Dates'
		},
		{
			name: 'service',
			label: 'Service',
			icon: mdiContentCut,
			type: 'select',
			column: 'appointments.serviceId',
			items: [
				{ value: 1, label: 'Cut' },
				{ value: 2, label: 'Color' },
				{ value: 3, label: 'Balayage' },
				{ value: 'care', label: 'Any treatment', values: [4, 5, 6] }
			],
			category: 'Options'
		},
		{
			name: 'status',
			label: 'Status',
			icon: mdiCheckCircleOutline,
			type: 'select',
			view: 'toggle',
			pinned: true,
			column: 'appointments.status',
			items: [
				{ value: 'confirmed', label: 'Confirmed' },
				{ value: 'waiting', label: 'Waiting' },
				{ value: 'cancelled', label: 'Cancelled' }
			],
			category: 'Options'
		},
		{
			name: 'staff',
			label: 'Staff (search)',
			icon: mdiAccountOutline,
			type: 'select',
			column: 'appointments.staffId',
			shortcuts: [{ value: 1, label: 'Me' }],
			searcher: async ({ searchText, signal }) => {
				await wait(signal);
				return staff.filter((item) => String(item.label).toLowerCase().includes(searchText.toLowerCase()));
			},
			category: 'Options'
		},
		{
			name: 'country',
			label: 'Country',
			icon: mdiEarth,
			type: 'select',
			view: 'countries',
			column: 'clients.country',
			category: 'Options'
		},
		{
			name: 'labels',
			label: 'Labels (Postgres array)',
			icon: mdiTagOutline,
			type: 'select',
			array: true,
			column: 'clients.labels',
			items: [
				{ value: 'vip', label: 'VIP' },
				{ value: 'allergic', label: 'Allergic' },
				{ value: 'new', label: 'New' }
			],
			category: 'Options'
		},
		{
			name: 'tags',
			label: 'Tags (relation)',
			icon: mdiTagOutline,
			type: 'select',
			column: 'tagId',
			through: { key: 'clients.id', from: 'client_tags', select: 'clientId' },
			items: [
				{ value: 1, label: 'Student' },
				{ value: 2, label: 'Bride' },
				{ value: 3, label: 'Partner' }
			],
			category: 'Options'
		},
		{
			name: 'color',
			label: 'Favourite color (JSONB)',
			icon: mdiPalette,
			type: 'select',
			json: { column: 'clients.customFields', key: 'color' },
			items: [
				{ value: 'red', label: 'Red' },
				{ value: 'blonde', label: 'Blonde' },
				{ value: 'brown', label: 'Brown' }
			],
			category: 'JSON'
		},
		{
			name: 'visits',
			label: 'Visits (JSONB number)',
			type: 'number',
			json: { column: 'clients.customFields', key: 'stats.visits', cast: 'numeric' },
			category: 'JSON'
		},
		{ name: 'paid', label: 'Paid', icon: mdiCashMultiple, type: 'bool', column: 'appointments.paid', category: 'Yes / no' },
		{
			name: 'vip',
			label: 'VIP (nullable)',
			icon: mdiStar,
			type: 'bool',
			nullable: true,
			column: 'clients.vip',
			category: 'Yes / no'
		},
		{
			name: 'lowStock',
			label: 'Low stock',
			icon: mdiPackageVariant,
			type: 'bool',
			trueLabel: 'Below minimum',
			falseLabel: 'Enough',
			whenTrue: (builder) => builder.whereColumn('products.quantity', '<', 'products.minQuantity'),
			whenFalse: (builder) => builder.whereColumn('products.quantity', '>=', 'products.minQuantity'),
			category: 'Yes / no'
		},
		{
			name: 'archived',
			label: 'Show archived',
			type: 'bool',
			operators: ['isTrue'],
			whenTrue: () => {},
			whenAbsent: (builder) => builder.where('clients.archived', '=', false),
			category: 'Yes / no'
		},
		{ name: 'salon', label: 'Salon', type: 'number', column: 'appointments.salonId', hidden: true }
	];

	const presets: FilterPreset[] = [
		{ id: 'today', label: 'Today', count: 18, conditions: [{ field: 'date', operator: 'period', value: 'today' }] },
		{ id: 'week', label: 'This week', count: 94, conditions: [{ field: 'date', operator: 'period', value: 'thisWeek' }] },
		{ id: 'unpaid', label: 'Not paid', count: 7, conditions: [{ field: 'paid', operator: 'isFalse' }] }
	];

	const now = new Date(2026, 8, 24, 10);
	let maxDepth = $state(2);

	let value = $state(
		createFilters([
			filterCondition('salon', 'eq', 12, { locked: true }),
			filterCondition('client', 'contains', 'mario rossi'),
			filterCondition('amount', 'between', { from: 50, to: 200 }),
			filterGroup('or', [
				filterCondition('date', 'inLast', { amount: 2, unit: 'weeks' }),
				filterCondition('labels', 'all', [
					{ value: 'vip', label: 'VIP' },
					{ value: 'new', label: 'New' }
				])
			])
		])
	);
	let query = $derived(JSON.stringify(filtersToBuilder(value, fields, { now }).toJson(), null, 2));
	let param = $derived(filtersToParam(value));
	let types = Object.entries(FILTER_OPERATORS);
</script>

<div class="example">
	<div class="depth">
		<Select
			label="maxDepth"
			items={[0, 1, 2, 3].map((depth) => ({ value: depth, label: String(depth) }))}
			bind:value={maxDepth}
		/>
	</div>
	<Filters {fields} bind:value {presets} allowOr {maxDepth} operatorSet="all" savedKey="aurora-docs-playground" />
	<details open>
		<summary>Query (<code>filtersToBuilder(value, fields).toJson()</code>)</summary>
		<pre>{query}</pre>
	</details>
	<details>
		<summary>URL parameter (<code>filtersToParam(value)</code>)</summary>
		<pre>{param}</pre>
	</details>
	<details>
		<summary>Every operator of every type</summary>
		<table>
			<thead><tr><th>Type</th><th>Operator</th><th>Label</th><th>Input</th></tr></thead>
			<tbody>
				{#each types as [type, list] (type)}
					{#each list as operator (operator.name)}
						<tr>
							<td>{type}</td>
							<td><code>{operator.name}</code></td>
							<td>{DEFAULT_FILTER_LABELS.operators[operator.name] ?? ''}</td>
							<td>{operator.input}</td>
						</tr>
					{/each}
				{/each}
			</tbody>
		</table>
	</details>
</div>

<style>
	.example {
		display: grid;
		gap: 14px;
	}

	.depth {
		width: 120px;
	}

	details {
		border: var(--global-border-width) solid var(--global-color-border);
		border-radius: var(--global-radius-md);
		padding: 8px 12px;
		background: var(--global-color-surface);
	}

	summary {
		color: var(--global-color-text-2);
		font-size: 13px;
		cursor: pointer;
	}

	pre {
		max-height: 260px;
		margin: 10px 0 0;
		overflow: auto;
		color: var(--global-color-text-2);
		font-size: 11.5px;
		white-space: pre-wrap;
		word-break: break-all;
	}

	table {
		width: 100%;
		margin-top: 10px;
		border-collapse: collapse;
		font-size: 12.5px;
	}

	th,
	td {
		padding: 4px 8px;
		border-bottom: var(--global-border-width) solid var(--global-color-border);
		text-align: start;
	}

	th {
		color: var(--global-color-text-3);
		font-weight: 600;
	}
</style>
```

### Fewer operators for simple apps

`operatorSet` decides how many operators the fields offer: `basic` (the essential ones), `standard` (default) or `all`. `typeOperators` sets an own list for a type, and a field's `operators` wins over both (a list, or a set name). With one operator the card shows no choice at all.

```svelte
<script lang="ts">
	import { Filters, createFilters } from '@likable-hair/svelte';
	import { fields } from './fields.js';

	let value = $state(createFilters());
</script>

<Filters
	{fields}
	bind:value
	operatorSet="basic"
	typeOperators={{ date: ['is', 'period'] }}
/>
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `fields` (required) | `FilterField[]` |  | The fields the user can filter. |
| `value` (bindable) | `FilterGroup` |  | The conditions: a tree of groups and conditions (see `createFilters`). Without it the component keeps its own; to clear them from the app pass `createFilters()`. |
| `allowOr` | `boolean` | `false` | Lets the user combine the conditions with OR instead of AND. Turn it on only when the backend applies OR groups correctly. |
| `maxDepth` | `number` | `0` | How deep groups can be nested in the panel: `0` means no groups. With GET requests most backends read one level. |
| `confirm` | `boolean` | `false` | The card and the panel work on a draft, with Cancel and Apply. Without it every complete change applies. |
| `applyDelay` | `number` | `300` | Milliseconds between the last change and `onchange` (without `confirm`). |
| `operatorSet` | `'basic' \| 'standard' \| 'all'` | `'standard'` | Operators the fields without `operators` offer: `basic` (the essential ones), `standard` (default) or `all`. |
| `typeOperators` | `Partial<Record<'string' \| 'number' \| 'date' \| 'select' \| 'bool' \| 'custom', string[]>>` |  | Own operator list per field type for the fields without `operators`, instead of `operatorSet` (for example `{ date: ['is', 'between', 'period'] }`). |
| `presets` | `FilterPreset[]` | `[]` | Ready-made sets of conditions, shown as chips under the bar. |
| `savable` | `boolean` | `false` | Shows "Saved filters": the user saves the current filters under a name and applies them later. On with `saved` or `savedKey` too. |
| `saved` (bindable) | `SavedFilter[]` |  | The saved filters. Bind it (or use `onsavedchange`) to keep them in the backend. |
| `savedKey` | `string` |  | Keeps the saved filters in the browser (`localStorage`) under this key. |
| `builder` | `FilterBuilder` |  | Query the filters are added to in `onchange` (for example with the search and the sorting). |
| `locale` | `string` |  | BCP 47 locale: the language of every text (`it` and `en` are built in, others fall back to English) and the format of dates and numbers. Defaults to the one set with `setDefaultLocale`, else `en`. |
| `weekStart` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6` | `1` | First day of the week for the periods `thisWeek`, `lastWeek` and `nextWeek`. Default 1 (Monday). |
| `negativesIncludeEmpty` | `boolean` | `true` | Negative operators ("is not", "does not contain", ≠, "is none of", "not between") also keep the rows where the field is empty, which SQL leaves out. On by default; it sends `null` modifiers, so pass `false` for backends that do not know them (variants E and E'). A field's `negativesIncludeEmpty` wins. |
| `labels` | `FilterLabelsInput` |  | Texts to change (see `FilterLabels`), on top of those of `locale`: pass only what differs, or every text for a language the library does not have. |
| `showPills` | `boolean` | `true` | Shows a pill for each condition in the bar. |
| `mobileDrawer` | `boolean` | `true` | On screens up to 1024px wide, every editor opens in a bottom sheet with all the conditions. |
| `class` | `{ container?: string; bar?: string; pill?: string; panel?: string }` | `{}` | Extra classes for each part. |

## Snippets

| Name | Parameters | Description |
| --- | --- | --- |
| `prependSnippet` |  | Content at the start of the bar (for example a search field). |
| `appendSnippet` |  | Content after the filter buttons. |
| `actionsSnippet` |  | Content at the end of the bar, pushed to the right (for example "New" or "Export"). |
| `pillSnippet` | `{ condition: FilterCondition; field: FilterField; operator: string; value: string }` | Replaces the text of a pill (field, operator and value). The pill keeps its buttons. |
| `inputSnippet` | `{ field: FilterField; operator: string; value: unknown; setValue: (value: unknown) => void }` | Input of the value for `custom` fields and operators with `input: 'custom'`. Call `setValue` with the new value. |

## Events

| Name | Type | Description |
| --- | --- | --- |
| `onchange` | `(change: { value: FilterGroup; builder: FilterBuilder }) => void` | Called when the query changes: the tree (complete conditions only) and the `FilterBuilder` built from it. |
| `onremove` | `(change: { conditions: FilterCondition[] }) => void` | Called when the user removes complete conditions (× of a pill, Remove, Clear, a row of the panel, a preset turned off), for example to reset state of the app. |
| `onsavedchange` | `(saved: SavedFilter[]) => void` | Called when the user saves or deletes saved filters, with the new list. |
| `onopen` | `(event: { view: 'fields' \| 'editor' \| 'panel'; field?: FilterField }) => void` | Called when the list of fields, a card or the panel opens, for example to load the options of a field. |

## Types

Exported by the package: `import type { FilterField, FilterGroup, FilterPreset, SavedFilter, FilterLabelsInput, FilterCondition, StringFilterField, NumberFilterField, DateFilterField, SelectFilterField, BoolFilterField, CustomFilterField, FilterLogic, FilterNode, FilterLabels, FilterPeriod, FilterTimeUnit, FilterConditionValue, FilterJoin, FilterThrough, FilterOperatorDefinition, FilterOperatorSet, FilterItem, FilterInput, Item } from '@likable-hair/svelte';`

### FilterField

A filterable field: what the app declares for each column the user can filter.

`type FilterField = StringFilterField \| NumberFilterField \| DateFilterField \| SelectFilterField \| BoolFilterField \| CustomFilterField`

### FilterGroup

A group of conditions and groups, combined with `logic`. The root of the tree is a group.

`interface FilterGroup`

| Name | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Identity inside the tree, made by the helpers. |
| `logic` (required) | `FilterLogic` | `and`: every item must hold; `or`: at least one. |
| `items` (required) | `FilterNode[]` | Conditions and nested groups. |
| `locked` | `boolean` | The user cannot change or remove the group. |

### FilterPreset

A ready-made set of conditions shown as a chip that the user turns on and off ("Today · 18").

`interface FilterPreset`

| Name | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Identity of the preset, stored in the conditions it adds. |
| `label` (required) | `string` | Text of the chip. |
| `icon` | `string` | SVG path of an icon in the chip. |
| `count` | `number \| string` | Number shown after the label (for example the matching rows). |
| `conditions` (required) | `Omit<FilterCondition, 'id' \| 'preset'>[]` | Conditions added when the chip is turned on. |

### SavedFilter

A set of filters saved by the user under a name (see `Filters` `savable`).

`interface SavedFilter`

| Name | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Identity of the saved filters. |
| `name` (required) | `string` | Name chosen by the user. |
| `value` (required) | `FilterGroup` | The saved tree. |

### FilterLabelsInput

Texts to change: any of `FilterLabels`, with `operators`, `periods` and `units` partial too.

`type FilterLabelsInput = Partial<Omit<FilterLabels, 'operators' \| 'periods' \| 'units'>> & { … }`

| Name | Type | Description |
| --- | --- | --- |
| `operators` | `Partial<Record<string, string>>` |  |
| `periods` | `Partial<Record<FilterPeriod, string>>` |  |
| `units` | `Partial<Record<FilterTimeUnit, string>>` |  |

### FilterCondition

A condition of the tree: a field, an operator and a value.

`interface FilterCondition`

| Name | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Identity inside the tree, made by the helpers. Not shown anywhere. |
| `field` (required) | `string` | `name` of the field. |
| `operator` (required) | `string` | Name of the operator, one of the field's. |
| `value` | `FilterConditionValue` | Value for the operator. |
| `locked` | `boolean` | The user sees the condition but cannot change or remove it. |
| `preset` | `string` | `id` of the preset that added the condition: the preset chip is on while its conditions are in the tree. |

### StringFilterField

A text field.

`interface StringFilterField extends FieldBase`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Identity of the field, stored in the conditions. |
| `label` (required) | `string` | Name shown to the user. |
| `icon` | `string` | SVG path of an icon shown in the list, the card and the pill. |
| `category` | `string` | Groups the fields in the list of "Add filter". |
| `description` | `string` | Secondary text in the list of fields. |
| `column` | `string` | Column of the query. Defaults to `name`. |
| `joins` | `FilterJoin[]` | Joins added to the query when the field has a condition. |
| `through` | `FilterThrough \| FilterThrough[]` | The condition is checked in a subquery on a related table (`column` is a column of the last hop). Several hops nest. |
| `operators` | `FilterOperatorSet \| (string \| FilterOperatorDefinition)[]` | Operators offered, in this order: names of the built-in ones of the type, definitions of new ones, or a whole set (`basic`, `standard`, `all`). Defaults to the set chosen on `Filters` (`standard`). |
| `defaultOperator` | `string` | Operator of a new condition. Defaults to the first one. |
| `pinned` | `boolean` | Always shown as a pill in the bar, even without a condition. |
| `hidden` | `boolean` | Never shown: its conditions (usually `locked`) only reach the query. |
| `defaultValue` | `FilterConditionValue` | Value of a new condition on this field (the card and the panel start with it). |
| `isComplete` | `(condition: FilterCondition) => boolean` | Decides when a condition on this field is complete (it reaches the query and gets a pill). Defaults to a check on the value for the operator. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Replaces the whole query of a condition on this field. |
| `whenAbsent` | `(builder: FilterBuilder) => void` | Query added when the field has no condition at all (for example "hide archived" until the user asks for them). |
| `format` | `(condition: FilterCondition) => string` | Replaces the text of the value in the pill. |
| `negativesIncludeEmpty` | `boolean` | Negative operators (`isNot`, `notContains`, `ne`, `notIn`, `noneOf`, `notBetween`) also keep the rows where the column is empty: "surname is not Rossi" shows the clients without a surname too. On by default (option of `Filters` / `filtersToBuilder`); this one wins. Needs a backend that knows `null` modifiers: pass `false` for backends E and E'. |
| `json` | `{ column: string; key: string; cast?: 'text' \| 'numeric' \| 'date' \| 'timestamp' \| 'boolean' }` | The value lives in a key of a JSONB column (`customFields.color`): equalities use `whereJsonSuperset`; with `cast` every operator works through a parametrized `whereRaw` (accepted only by backends that allow raw conditions). |
| `type` (required) | `'string'` |  |
| `columns` | `string[]` | Several columns: a condition holds when any of them matches (`contains`), or when none does (`isNot`, `notContains`). |
| `words` | `boolean` | Splits the text into words, for names split over `columns`: `contains` wants every word in some column; `is` wants every word as a whole word of some column, ignoring case unless `caseSensitive` ("mario rossi" finds Mario Rossi, Rossi Mario and Maria Grazia De Rossi with "maria rossi", not Mariolina Rossini); `notContains` and `isNot` are their exact opposites (some word is missing). The other operators compare the whole text. |
| `caseSensitive` | `boolean` | Tells upper and lower case apart. Without it every text operator ignores case: `contains` with `ilike`, `is`, `isNot`, `anyOf`, `noneOf`, `startsWith` and `endsWith` with a Postgres regex (`~*`). With it the equalities use `=`, `<>` and `in`, as in v4, which can use the column's index. |
| `suggest` | `(params: { searchText: string; signal: AbortSignal }) => Promise<FilterItem[]>` | Suggestions while typing, for the `match` operator: picking one filters on its exact value (on `suggestColumn`), keeping the typed text filters with `contains`. |
| `suggestColumn` | `string` | Column compared with the value of a picked suggestion. Defaults to `column`. |
| `blankIsEmpty` | `boolean` | With `empty` / `notEmpty`, an empty string counts as empty too. Default `true`. |
| `placeholder` | `string` | Placeholder of the input. |

### NumberFilterField

A number field.

`interface NumberFilterField extends FieldBase`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Identity of the field, stored in the conditions. |
| `label` (required) | `string` | Name shown to the user. |
| `icon` | `string` | SVG path of an icon shown in the list, the card and the pill. |
| `category` | `string` | Groups the fields in the list of "Add filter". |
| `description` | `string` | Secondary text in the list of fields. |
| `column` | `string` | Column of the query. Defaults to `name`. |
| `joins` | `FilterJoin[]` | Joins added to the query when the field has a condition. |
| `through` | `FilterThrough \| FilterThrough[]` | The condition is checked in a subquery on a related table (`column` is a column of the last hop). Several hops nest. |
| `operators` | `FilterOperatorSet \| (string \| FilterOperatorDefinition)[]` | Operators offered, in this order: names of the built-in ones of the type, definitions of new ones, or a whole set (`basic`, `standard`, `all`). Defaults to the set chosen on `Filters` (`standard`). |
| `defaultOperator` | `string` | Operator of a new condition. Defaults to the first one. |
| `pinned` | `boolean` | Always shown as a pill in the bar, even without a condition. |
| `hidden` | `boolean` | Never shown: its conditions (usually `locked`) only reach the query. |
| `defaultValue` | `FilterConditionValue` | Value of a new condition on this field (the card and the panel start with it). |
| `isComplete` | `(condition: FilterCondition) => boolean` | Decides when a condition on this field is complete (it reaches the query and gets a pill). Defaults to a check on the value for the operator. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Replaces the whole query of a condition on this field. |
| `whenAbsent` | `(builder: FilterBuilder) => void` | Query added when the field has no condition at all (for example "hide archived" until the user asks for them). |
| `format` | `(condition: FilterCondition) => string` | Replaces the text of the value in the pill. |
| `negativesIncludeEmpty` | `boolean` | Negative operators (`isNot`, `notContains`, `ne`, `notIn`, `noneOf`, `notBetween`) also keep the rows where the column is empty: "surname is not Rossi" shows the clients without a surname too. On by default (option of `Filters` / `filtersToBuilder`); this one wins. Needs a backend that knows `null` modifiers: pass `false` for backends E and E'. |
| `json` | `{ column: string; key: string; cast?: 'text' \| 'numeric' \| 'date' \| 'timestamp' \| 'boolean' }` | The value lives in a key of a JSONB column (`customFields.color`): equalities use `whereJsonSuperset`; with `cast` every operator works through a parametrized `whereRaw` (accepted only by backends that allow raw conditions). |
| `type` (required) | `'number'` |  |
| `unit` | `string` | Text after the value (`€`, `kg`). |
| `scale` | `number` | Multiplies the typed value before the query (for example `1000` to type tons of a column in kilograms). |
| `step` | `number` | `step` of the input. |
| `compareWith` | `{ column: string; label: string }[]` | Other columns the value can be compared with (`quantity < minimum quantity`): adds the column operators. |

### DateFilterField

A date field.

`interface DateFilterField extends FieldBase`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Identity of the field, stored in the conditions. |
| `label` (required) | `string` | Name shown to the user. |
| `icon` | `string` | SVG path of an icon shown in the list, the card and the pill. |
| `category` | `string` | Groups the fields in the list of "Add filter". |
| `description` | `string` | Secondary text in the list of fields. |
| `column` | `string` | Column of the query. Defaults to `name`. |
| `joins` | `FilterJoin[]` | Joins added to the query when the field has a condition. |
| `through` | `FilterThrough \| FilterThrough[]` | The condition is checked in a subquery on a related table (`column` is a column of the last hop). Several hops nest. |
| `operators` | `FilterOperatorSet \| (string \| FilterOperatorDefinition)[]` | Operators offered, in this order: names of the built-in ones of the type, definitions of new ones, or a whole set (`basic`, `standard`, `all`). Defaults to the set chosen on `Filters` (`standard`). |
| `defaultOperator` | `string` | Operator of a new condition. Defaults to the first one. |
| `pinned` | `boolean` | Always shown as a pill in the bar, even without a condition. |
| `hidden` | `boolean` | Never shown: its conditions (usually `locked`) only reach the query. |
| `defaultValue` | `FilterConditionValue` | Value of a new condition on this field (the card and the panel start with it). |
| `isComplete` | `(condition: FilterCondition) => boolean` | Decides when a condition on this field is complete (it reaches the query and gets a pill). Defaults to a check on the value for the operator. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Replaces the whole query of a condition on this field. |
| `whenAbsent` | `(builder: FilterBuilder) => void` | Query added when the field has no condition at all (for example "hide archived" until the user asks for them). |
| `format` | `(condition: FilterCondition) => string` | Replaces the text of the value in the pill. |
| `negativesIncludeEmpty` | `boolean` | Negative operators (`isNot`, `notContains`, `ne`, `notIn`, `noneOf`, `notBetween`) also keep the rows where the column is empty: "surname is not Rossi" shows the clients without a surname too. On by default (option of `Filters` / `filtersToBuilder`); this one wins. Needs a backend that knows `null` modifiers: pass `false` for backends E and E'. |
| `json` | `{ column: string; key: string; cast?: 'text' \| 'numeric' \| 'date' \| 'timestamp' \| 'boolean' }` | The value lives in a key of a JSONB column (`customFields.color`): equalities use `whereJsonSuperset`; with `cast` every operator works through a parametrized `whereRaw` (accepted only by backends that allow raw conditions). |
| `type` (required) | `'date'` |  |
| `dateOnly` | `boolean` | The column is a `date` (no time): the query compares `yyyy-MM-dd` strings. Otherwise it compares timestamps from the start to the end of the local days. |
| `periods` | `FilterPeriod[]` | Periods offered by the `period` operator, in this order. |
| `withTime` | `boolean` | The value has a time too: `before`, `after`, `between` and the relative operators compare instants (`yyyy-MM-ddTHH:mm`), and minutes and hours become available. |
| `compareWith` | `{ column: string; label: string }[]` | Other columns the value can be compared with (`deliveredAt after promisedAt`): adds the column operators. |

### SelectFilterField

A field whose value is chosen among options.

`interface SelectFilterField extends FieldBase`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Identity of the field, stored in the conditions. |
| `label` (required) | `string` | Name shown to the user. |
| `icon` | `string` | SVG path of an icon shown in the list, the card and the pill. |
| `category` | `string` | Groups the fields in the list of "Add filter". |
| `description` | `string` | Secondary text in the list of fields. |
| `column` | `string` | Column of the query. Defaults to `name`. |
| `joins` | `FilterJoin[]` | Joins added to the query when the field has a condition. |
| `through` | `FilterThrough \| FilterThrough[]` | The condition is checked in a subquery on a related table (`column` is a column of the last hop). Several hops nest. |
| `operators` | `FilterOperatorSet \| (string \| FilterOperatorDefinition)[]` | Operators offered, in this order: names of the built-in ones of the type, definitions of new ones, or a whole set (`basic`, `standard`, `all`). Defaults to the set chosen on `Filters` (`standard`). |
| `defaultOperator` | `string` | Operator of a new condition. Defaults to the first one. |
| `pinned` | `boolean` | Always shown as a pill in the bar, even without a condition. |
| `hidden` | `boolean` | Never shown: its conditions (usually `locked`) only reach the query. |
| `defaultValue` | `FilterConditionValue` | Value of a new condition on this field (the card and the panel start with it). |
| `isComplete` | `(condition: FilterCondition) => boolean` | Decides when a condition on this field is complete (it reaches the query and gets a pill). Defaults to a check on the value for the operator. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Replaces the whole query of a condition on this field. |
| `whenAbsent` | `(builder: FilterBuilder) => void` | Query added when the field has no condition at all (for example "hide archived" until the user asks for them). |
| `format` | `(condition: FilterCondition) => string` | Replaces the text of the value in the pill. |
| `negativesIncludeEmpty` | `boolean` | Negative operators (`isNot`, `notContains`, `ne`, `notIn`, `noneOf`, `notBetween`) also keep the rows where the column is empty: "surname is not Rossi" shows the clients without a surname too. On by default (option of `Filters` / `filtersToBuilder`); this one wins. Needs a backend that knows `null` modifiers: pass `false` for backends E and E'. |
| `json` | `{ column: string; key: string; cast?: 'text' \| 'numeric' \| 'date' \| 'timestamp' \| 'boolean' }` | The value lives in a key of a JSONB column (`customFields.color`): equalities use `whereJsonSuperset`; with `cast` every operator works through a parametrized `whereRaw` (accepted only by backends that allow raw conditions). |
| `type` (required) | `'select'` |  |
| `items` | `FilterItem[]` | The options, when they are known. |
| `searcher` | `(params: { searchText: string; signal: AbortSignal }) => Promise<FilterItem[]>` | Loads the options matching the typed text (from an API), instead of `items`. |
| `view` | `'autocomplete' \| 'toggle' \| 'countries'` | How the options are picked: an autocomplete (default), toggle buttons (few options), or countries with flags. |
| `shortcuts` | `FilterItem[]` | Options added at the top of the list, such as "Me" for the current user. |
| `locale` | `string` | Locale of the country names with `view: 'countries'`. |
| `placeholder` | `string` | Placeholder of the input. |
| `array` | `boolean` | The column (or the JSON key, with `json`) holds a list of values: `in` = has any of (`&&`), `notIn` = has none of, `all` = has all of (`@>`), `empty` = null or `{}`. |

### BoolFilterField

A yes/no field.

`interface BoolFilterField extends FieldBase`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Identity of the field, stored in the conditions. |
| `label` (required) | `string` | Name shown to the user. |
| `icon` | `string` | SVG path of an icon shown in the list, the card and the pill. |
| `category` | `string` | Groups the fields in the list of "Add filter". |
| `description` | `string` | Secondary text in the list of fields. |
| `column` | `string` | Column of the query. Defaults to `name`. |
| `joins` | `FilterJoin[]` | Joins added to the query when the field has a condition. |
| `through` | `FilterThrough \| FilterThrough[]` | The condition is checked in a subquery on a related table (`column` is a column of the last hop). Several hops nest. |
| `operators` | `FilterOperatorSet \| (string \| FilterOperatorDefinition)[]` | Operators offered, in this order: names of the built-in ones of the type, definitions of new ones, or a whole set (`basic`, `standard`, `all`). Defaults to the set chosen on `Filters` (`standard`). |
| `defaultOperator` | `string` | Operator of a new condition. Defaults to the first one. |
| `pinned` | `boolean` | Always shown as a pill in the bar, even without a condition. |
| `hidden` | `boolean` | Never shown: its conditions (usually `locked`) only reach the query. |
| `defaultValue` | `FilterConditionValue` | Value of a new condition on this field (the card and the panel start with it). |
| `isComplete` | `(condition: FilterCondition) => boolean` | Decides when a condition on this field is complete (it reaches the query and gets a pill). Defaults to a check on the value for the operator. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Replaces the whole query of a condition on this field. |
| `whenAbsent` | `(builder: FilterBuilder) => void` | Query added when the field has no condition at all (for example "hide archived" until the user asks for them). |
| `format` | `(condition: FilterCondition) => string` | Replaces the text of the value in the pill. |
| `negativesIncludeEmpty` | `boolean` | Negative operators (`isNot`, `notContains`, `ne`, `notIn`, `noneOf`, `notBetween`) also keep the rows where the column is empty: "surname is not Rossi" shows the clients without a surname too. On by default (option of `Filters` / `filtersToBuilder`); this one wins. Needs a backend that knows `null` modifiers: pass `false` for backends E and E'. |
| `json` | `{ column: string; key: string; cast?: 'text' \| 'numeric' \| 'date' \| 'timestamp' \| 'boolean' }` | The value lives in a key of a JSONB column (`customFields.color`): equalities use `whereJsonSuperset`; with `cast` every operator works through a parametrized `whereRaw` (accepted only by backends that allow raw conditions). |
| `type` (required) | `'bool'` |  |
| `trueLabel` | `string` | Text of `isTrue` in the pill and the card. Default `Yes`. |
| `falseLabel` | `string` | Text of `isFalse`. Default `No`. |
| `whenTrue` | `(builder: FilterBuilder) => void` | Query of `isTrue`, when it is not `column = true` (for example `whereColumn('quantity', '<', 'minQuantity')`). |
| `whenFalse` | `(builder: FilterBuilder) => void` | Query of `isFalse`, when it is not `column = false`. |
| `nullable` | `boolean` | The column can be null: adds `empty` and `notEmpty`. |

### CustomFilterField

A field with an input of the app.

`interface CustomFilterField extends FieldBase`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Identity of the field, stored in the conditions. |
| `label` (required) | `string` | Name shown to the user. |
| `icon` | `string` | SVG path of an icon shown in the list, the card and the pill. |
| `category` | `string` | Groups the fields in the list of "Add filter". |
| `description` | `string` | Secondary text in the list of fields. |
| `column` | `string` | Column of the query. Defaults to `name`. |
| `joins` | `FilterJoin[]` | Joins added to the query when the field has a condition. |
| `through` | `FilterThrough \| FilterThrough[]` | The condition is checked in a subquery on a related table (`column` is a column of the last hop). Several hops nest. |
| `operators` | `FilterOperatorSet \| (string \| FilterOperatorDefinition)[]` | Operators offered, in this order: names of the built-in ones of the type, definitions of new ones, or a whole set (`basic`, `standard`, `all`). Defaults to the set chosen on `Filters` (`standard`). |
| `defaultOperator` | `string` | Operator of a new condition. Defaults to the first one. |
| `pinned` | `boolean` | Always shown as a pill in the bar, even without a condition. |
| `hidden` | `boolean` | Never shown: its conditions (usually `locked`) only reach the query. |
| `defaultValue` | `FilterConditionValue` | Value of a new condition on this field (the card and the panel start with it). |
| `isComplete` | `(condition: FilterCondition) => boolean` | Decides when a condition on this field is complete (it reaches the query and gets a pill). Defaults to a check on the value for the operator. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Replaces the whole query of a condition on this field. |
| `whenAbsent` | `(builder: FilterBuilder) => void` | Query added when the field has no condition at all (for example "hide archived" until the user asks for them). |
| `format` | `(condition: FilterCondition) => string` | Replaces the text of the value in the pill. |
| `negativesIncludeEmpty` | `boolean` | Negative operators (`isNot`, `notContains`, `ne`, `notIn`, `noneOf`, `notBetween`) also keep the rows where the column is empty: "surname is not Rossi" shows the clients without a surname too. On by default (option of `Filters` / `filtersToBuilder`); this one wins. Needs a backend that knows `null` modifiers: pass `false` for backends E and E'. |
| `json` | `{ column: string; key: string; cast?: 'text' \| 'numeric' \| 'date' \| 'timestamp' \| 'boolean' }` | The value lives in a key of a JSONB column (`customFields.color`): equalities use `whereJsonSuperset`; with `cast` every operator works through a parametrized `whereRaw` (accepted only by backends that allow raw conditions). |
| `type` (required) | `'custom'` |  |

### FilterLogic

How the conditions of a group are combined.

`type FilterLogic = 'and' \| 'or'`

### FilterNode

A condition or a group.

`type FilterNode = FilterCondition \| FilterGroup`

### FilterLabels

Every text of the filters, to translate them. Pass the ones to change: the others keep the English default.

`interface FilterLabels`

| Name | Type | Description |
| --- | --- | --- |
| `filters` (required) | `string` |  |
| `addFilter` (required) | `string` |  |
| `addNestedFilter` (required) | `string` |  |
| `clear` (required) | `string` |  |
| `clearAll` (required) | `string` |  |
| `clearGroup` (required) | `string` |  |
| `where` (required) | `string` |  |
| `and` (required) | `string` |  |
| `or` (required) | `string` |  |
| `searchFields` (required) | `string` |  |
| `noFields` (required) | `string` |  |
| `field` (required) | `string` |  |
| `operator` (required) | `string` |  |
| `value` (required) | `string` |  |
| `apply` (required) | `string` |  |
| `cancel` (required) | `string` |  |
| `remove` (required) | `string` |  |
| `close` (required) | `string` |  |
| `showResults` (required) | `string` |  |
| `editFilter` (required) | `string` |  |
| `removeFilter` (required) | `string` |  |
| `from` (required) | `string` |  |
| `to` (required) | `string` |  |
| `days` (required) | `string` |  |
| `yes` (required) | `string` |  |
| `no` (required) | `string` |  |
| `more` (required) | `string` |  |
| `conditions` (required) | `string` |  |
| `anyOf` (required) | `string` |  |
| `allOf` (required) | `string` |  |
| `addValue` (required) | `string` |  |
| `choose` (required) | `string` |  |
| `search` (required) | `string` |  |
| `amount` (required) | `string` |  |
| `showLess` (required) | `string` |  |
| `loading` (required) | `string` | Text of the list while options load. |
| `noResults` (required) | `string` | Text of the list when no option matches. |
| `searchError` (required) | `string` | Text of the list when a search fails. |
| `typeMore` (required) | `string` | Text of the list before a search starts; `{count}` is the number of characters. |
| `invalidDate` (required) | `string` | Error of a date field with a date that does not exist. |
| `chooseDate` (required) | `string` | Accessible name of the calendar button of a date field. |
| `previousMonth` (required) | `string` |  |
| `nextMonth` (required) | `string` |  |
| `previousYear` (required) | `string` |  |
| `nextYear` (required) | `string` |  |
| `dateLetters` (required) | `string` | Letters of day, month and year in the format hint of date fields: `dmy` shows `dd/mm/yyyy`, `gma` shows `gg/mm/aaaa`. |
| `invalidDateTime` (required) | `string` | Error of a date and time field with a date or a time that does not exist. |
| `chooseDateTime` (required) | `string` | Accessible name of the calendar button of a date and time field. |
| `hours` (required) | `string` | Accessible name of the hours column of a date and time field. |
| `minutes` (required) | `string` | Accessible name of the minutes column of a date and time field. |
| `amPm` (required) | `string` | Accessible name of the AM/PM column of a date and time field on a 12-hour clock. |
| `compareWith` (required) | `string` |  |
| `savedFilters` (required) | `string` |  |
| `saveFilters` (required) | `string` |  |
| `saveAs` (required) | `string` |  |
| `save` (required) | `string` |  |
| `deleteSaved` (required) | `string` |  |
| `noSaved` (required) | `string` |  |
| `unit` (required) | `string` |  |
| `units` (required) | `Record<FilterTimeUnit, string>` |  |
| `operators` (required) | `Record<string, string>` |  |
| `periods` (required) | `Record<FilterPeriod, string>` |  |

### FilterPeriod

A period relative to today, for the date operator `period`.

`type FilterPeriod = 'today' \| 'yesterday' \| 'tomorrow' \| 'thisWeek' \| 'lastWeek' \| 'nextWeek' \| 'thisMonth' \| 'lastMonth' \| 'nextMonth' \| 'thisQuarter' \| 'lastQuarter' \| 'nextQuarter' \| 'thisYear' \| 'lastYear' \| 'nextYear' \| 'monthToDate' \| 'quarterToDate' \| 'yearToDate'`

### FilterTimeUnit

Unit of a relative date (`inLast`, `inNext`, `olderThan`, `laterThan`). Minutes and hours need `withTime`.

`type FilterTimeUnit = 'minutes' \| 'hours' \| 'days' \| 'weeks' \| 'months' \| 'years'`

### FilterConditionValue

Value of a condition. Its shape depends on the operator (see `FilterInput`). Dates are `yyyy-MM-dd` strings, so the whole tree is plain JSON.

`type FilterConditionValue = string \| number \| boolean \| { from?: number \| string; to?: number \| string } \| FilterItem[] \| FilterPeriod \| unknown`

### FilterJoin

A join the field needs, added once per query however many conditions use it.

`interface FilterJoin`

| Name | Type | Description |
| --- | --- | --- |
| `table` (required) | `string` | Table, with an alias if needed (`suppliers as primary_supplier`). |
| `on` (required) | `[string, string] \| [string, string, string]` | `[from, to]` (equality) or `[from, operator, to]`. |
| `kind` | `'left' \| 'inner'` | Default `left`, so the join itself filters nothing. |

### FilterThrough

A hop of a relation reached through a subquery: `key IN (SELECT select FROM from WHERE ...)`.

`interface FilterThrough`

| Name | Type | Description |
| --- | --- | --- |
| `key` (required) | `string` | Column of the outer query compared with the subquery (`users.id`). |
| `from` (required) | `string` | Table of the subquery (`user_residences`). |
| `select` (required) | `string` | Column selected by the subquery (`userId`). |
| `joins` | `FilterJoin[]` | Joins inside the subquery. |
| `where` | `(builder: FilterBuilder) => void` | Fixed conditions inside the subquery. |

### FilterOperatorDefinition

An operator defined by the app for one field.

`interface FilterOperatorDefinition`

| Name | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Name stored in the conditions. |
| `label` (required) | `string` | Text between the field and the value (`is`, `≥`, `has tag`). |
| `input` (required) | `FilterInput` | Input shown for the value. `custom` uses the field's `inputSnippet`. |
| `apply` | `(builder: FilterBuilder, condition: FilterCondition) => void` | Adds the query for a condition with this operator. Without it the field's `apply` is used. |

### FilterOperatorSet

How many operators the fields offer: `basic` the essential ones, `standard` the common ones (default), `all` every built-in one.

`type FilterOperatorSet = 'basic' \| 'standard' \| 'all'`

### FilterItem

An option of a select field: an `Item`, optionally standing for several values in the query.

`type FilterItem<Data = unknown> = Item<Data> & { … }`

| Name | Type | Description |
| --- | --- | --- |
| `values` | `(string \| number)[]` | Values the option stands for in the query (for example "In progress" = four statuses). Defaults to `[value]`. |

### FilterInput

Kind of value an operator asks for, which decides the input shown to the user.

`type FilterInput = 'none' \| 'text' \| 'texts' \| 'number' \| 'numbers' \| 'numberRange' \| 'date' \| 'dateRange' \| 'datetime' \| 'datetimeRange' \| 'days' \| 'relative' \| 'period' \| 'items' \| 'column' \| 'suggest' \| 'custom'`

### Item

An option of a picker (Autocomplete, Select, ...).

`type Item<Data = unknown> = { … }`

| Name | Type | Description |
| --- | --- | --- |
| `value` (required) | `string \| number` | Identity of the option: two items are the same option when their `value`s are equal (`===`). |
| `label` | `string \| number` | Text shown and searched. Defaults to `value`. |
| `icon` | `string` | SVG path of an icon shown before the label, for example from `@mdi/js`. |
| `data` | `Data` | Any extra data, available in snippets and callbacks. |

## CSS variables

For a single instance, pass them as style props: `<Filters --filters-count-color="tomato">`. The `--filters-default-*` defaults apply to the whole app: override them in `:root` or in a theme.

| Per-instance variable | Default |
| --- | --- |
| `--filters-gap` | `--filters-default-gap`: `8px` |
| `--filters-width` | `100%` |
| `--filters-count-background` | `--filters-default-count-background`: `var(--global-color-primary-soft)` |
| `--filters-count-color` | `--filters-default-count-color`: `var(--global-color-primary)` |
| `--filters-field-list-width` | `260px` |
| `--filters-field-list-max-height` | `320px` |
| `--filters-group-padding` | `--filters-default-group-padding`: `14px` |
| `--filters-group-border-color` | `--filters-default-group-border-color`: `var(--global-color-border)` |
| `--filters-group-border-radius` | `--filters-default-group-border-radius`: `var(--global-radius-md)` |
| `--filters-group-background` | `--filters-default-group-background`: `var(--global-color-surface-3)` |
| `--filters-group-alt-background` | `--filters-default-group-alt-background`: `var(--global-color-surface-pop)` |
| `--filters-pill-height` | `--filters-default-pill-height`: `30px` |
| `--filters-pill-border-color` | `--filters-default-pill-border-color`: `var(--global-color-border-strong)` |
| `--filters-pill-border-radius` | `--filters-default-pill-border-radius`: `var(--global-radius-md)` |
| `--filters-pill-background` | `--filters-default-pill-background`: `var(--global-color-surface-solid)` |
| `--filters-pill-box-shadow` | `--filters-default-pill-box-shadow`: `var(--global-shadow-sm)` |
| `--filters-pill-font-size` | `--filters-default-pill-font-size`: `13px` |
| `--filters-pill-key-color` | `--filters-default-pill-key-color`: `var(--global-color-text-3)` |
| `--filters-pill-divider-color` | `--filters-default-pill-divider-color`: `var(--global-color-border)` |
| `--filters-pill-operator-color` | `--filters-default-pill-operator-color`: `var(--global-color-primary)` |
| `--filters-pill-value-max-width` | `220px` |
| `--filters-pill-value-color` | `--filters-default-pill-value-color`: `var(--global-color-text)` |
| `--filters-pill-remove-hover-background` | `--filters-default-pill-remove-hover-background`: `var(--global-color-error-soft)` |
| `--filters-pill-remove-hover-color` | `--filters-default-pill-remove-hover-color`: `var(--global-color-error)` |
| `--filters-add-hover-color` | `--filters-default-add-hover-color`: `var(--global-color-primary)` |
| `--filters-add-border-color` | `--filters-default-add-border-color`: `var(--global-color-border-strong)` |
| `--filters-add-color` | `--filters-default-add-color`: `var(--global-color-text-2)` |
| `--filters-connective-color` | `--filters-default-connective-color`: `var(--global-color-text-3)` |
| `--filters-panel-width` | `--filters-default-panel-width`: `880px` |
| `--filters-panel-padding` | `--filters-default-panel-padding`: `16px` |
