Skip to content
Likable Aurora @likable-hair/svelte 5

FilterEditor

Card that edits one filter condition: the field name with its icon, the operators of the field (side by side when they are up to four, otherwise a select) and the input of the value, which depends on the operator (text, number with unit, range, date, date range, period, last N days, options from a list, a search or countries, yes/no, or the app's input). Every change calls onchange; with confirm it shows Cancel and Apply instead, and Enter applies. Filters shows it under a pill or after "Add filter"; it can also be used alone, for example in a page of settings.

import { FilterEditor } from '@likable-hair/svelte';

src/lib/components/composed/search/FilterEditor.svelte · Markdown for LLMs

Edit one condition

The card on its own: the operators of the field side by side (up to four), then the input of the value. Every change calls onchange; here the condition is shown below as JSON, the shape stored in the Filters tree.

Amount
€
{"operator":"gte","value":50}
Code
<script lang="ts">
	import { mdiCashMultiple } from '@mdi/js';
	import { FilterEditor, filterCondition, type FilterField } from '@likable-hair/svelte';

	const field: FilterField = {
		name: 'amount',
		label: 'Amount',
		icon: mdiCashMultiple,
		type: 'number',
		unit: '€',
		operators: ['gte', 'lte', 'eq', 'between']
	};

	let condition = $state(filterCondition('amount', 'gte', 50));
</script>

<div class="example">
	<div class="card">
		<FilterEditor {field} bind:condition />
	</div>
	<pre>{JSON.stringify({ operator: condition.operator, value: condition.value })}</pre>
</div>

<style>
	.example {
		display: grid;
		justify-items: start;
		gap: 12px;
	}

	.card {
		border: var(--global-border-width) solid var(--global-color-border-strong);
		border-radius: var(--global-radius-xl);
		background: var(--global-color-surface-pop);
		box-shadow: var(--global-shadow-lg);
	}

	pre {
		margin: 0;
		color: var(--global-color-text-2);
		font-size: 12px;
	}
</style>

Cancel and Apply

With confirm changes stay in the card until Apply (or Enter); Apply is disabled while the value is incomplete. removable adds Remove for a condition that is already applied, onclose a close button.

Service
Balayage

Nothing applied yet

Code
<script lang="ts">
	import { mdiContentCut } from '@mdi/js';
	import { FilterEditor, filterCondition, type FilterField, type FilterCondition } from '@likable-hair/svelte';

	const field: FilterField = {
		name: 'service',
		label: 'Service',
		icon: mdiContentCut,
		type: 'select',
		items: [
			{ value: 1, label: 'Cut' },
			{ value: 2, label: 'Color' },
			{ value: 3, label: 'Balayage' },
			{ value: 4, label: 'Blow-dry' }
		]
	};

	let condition = $state(filterCondition('service', 'in', [{ value: 3, label: 'Balayage' }]));
	let applied = $state<FilterCondition>();
	let message = $state('Nothing applied yet');

	function describe(item: FilterCondition) {
		const items = (item.value as { label: string }[] | undefined) ?? [];
		return `${item.operator === 'in' ? 'is' : 'is not'} ${items.map((entry) => entry.label).join(', ')}`;
	}
</script>

<div class="example">
	<div class="card">
		<FilterEditor
			{field}
			bind:condition
			confirm
			removable={!!applied}
			onapply={(next) => {
				applied = next;
				message = `Applied: ${field.label} ${describe(next)}`;
			}}
			oncancel={() => {
				condition = applied ?? filterCondition('service', 'in');
				message = 'Cancelled';
			}}
			onremove={() => {
				applied = undefined;
				condition = filterCondition('service', 'in');
				message = 'Removed';
			}}
			onclose={() => (message = 'Closed')}
		/>
	</div>
	<p>{message}</p>
</div>

<style>
	.example {
		display: grid;
		justify-items: start;
		gap: 12px;
	}

	.card {
		border: var(--global-border-width) solid var(--global-color-border-strong);
		border-radius: var(--global-radius-xl);
		background: var(--global-color-surface-pop);
		box-shadow: var(--global-shadow-lg);
	}

	p {
		margin: 0;
		color: var(--global-color-text-2);
		font-size: 13px;
	}
</style>

Props

NameTypeDefaultDescription
field requiredFilterFieldThe field of the condition.
condition bindable requiredFilterConditionThe condition being edited. A new one is a condition with the field's default operator and no value.
confirm booleanfalseShows Cancel and Apply: changes reach onapply only when the user applies. Without it every change calls onchange.
operatorSet 'basic' | 'standard' | 'all''standard'Operators offered when the field has no operators: basic, standard (default) or all.
typeOperators Partial<Record<'string' | 'number' | 'date' | 'select' | 'bool' | 'custom', string[]>>Own operator list per field type, instead of operatorSet.
removable booleanfalseShows a Remove button (for a condition already in the filters).
labels FilterLabelsInputTexts to change (see FilterLabels), on top of those of locale.
locale stringBCP 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.
autofocus booleanfalseMoves the focus to the value input when the card appears.
class stringExtra classes on the card.

Snippets

NameParametersDescription
inputSnippet{ field: FilterField; operator: string; value: unknown; setValue: (value: unknown) => void }Input of the value for custom fields and for operators with input: 'custom'. Call setValue with the new value.

Events

NameTypeDescription
onchange(condition: FilterCondition) => voidCalled at every change of operator or value (without confirm).
onapply(condition: FilterCondition) => voidCalled by Apply and by Enter, with the edited condition (with confirm), or by Enter alone.
oncancel() => voidCalled by Cancel.
onremove() => voidCalled by Remove.
onclose() => voidShows a close button in the header and calls this when it is clicked.

Types

Exported by the package: import type { FilterField, FilterCondition, FilterLabelsInput, StringFilterField, NumberFilterField, DateFilterField, SelectFilterField, BoolFilterField, CustomFilterField, FilterConditionValue, FilterLabels, FilterPeriod, FilterTimeUnit, 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

FilterCondition

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

interface FilterCondition

NameTypeDescription
id requiredstringIdentity inside the tree, made by the helpers. Not shown anywhere.
field requiredstringname of the field.
operator requiredstringName of the operator, one of the field's.
value FilterConditionValueValue for the operator.
locked booleanThe user sees the condition but cannot change or remove it.
preset stringid of the preset that added the condition: the preset chip is on while its conditions are in the tree.

FilterLabelsInput

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

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

NameTypeDescription
operators Partial<Record<string, string>>
periods Partial<Record<FilterPeriod, string>>
units Partial<Record<FilterTimeUnit, string>>

StringFilterField

A text field.

interface StringFilterField extends FieldBase

NameTypeDescription
name requiredstringIdentity of the field, stored in the conditions.
label requiredstringName shown to the user.
icon stringSVG path of an icon shown in the list, the card and the pill.
category stringGroups the fields in the list of "Add filter".
description stringSecondary text in the list of fields.
column stringColumn 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 stringOperator of a new condition. Defaults to the first one.
pinned booleanAlways shown as a pill in the bar, even without a condition.
hidden booleanNever shown: its conditions (usually locked) only reach the query.
defaultValue FilterConditionValueValue of a new condition on this field (the card and the panel start with it).
isComplete (condition: FilterCondition) => booleanDecides 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) => voidReplaces the whole query of a condition on this field.
whenAbsent (builder: FilterBuilder) => voidQuery added when the field has no condition at all (for example "hide archived" until the user asks for them).
format (condition: FilterCondition) => stringReplaces the text of the value in the pill.
negativesIncludeEmpty booleanNegative 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 booleanSplits 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 booleanTells 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 stringColumn compared with the value of a picked suggestion. Defaults to column.
blankIsEmpty booleanWith empty / notEmpty, an empty string counts as empty too. Default true.
placeholder stringPlaceholder of the input.

NumberFilterField

A number field.

interface NumberFilterField extends FieldBase

NameTypeDescription
name requiredstringIdentity of the field, stored in the conditions.
label requiredstringName shown to the user.
icon stringSVG path of an icon shown in the list, the card and the pill.
category stringGroups the fields in the list of "Add filter".
description stringSecondary text in the list of fields.
column stringColumn 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 stringOperator of a new condition. Defaults to the first one.
pinned booleanAlways shown as a pill in the bar, even without a condition.
hidden booleanNever shown: its conditions (usually locked) only reach the query.
defaultValue FilterConditionValueValue of a new condition on this field (the card and the panel start with it).
isComplete (condition: FilterCondition) => booleanDecides 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) => voidReplaces the whole query of a condition on this field.
whenAbsent (builder: FilterBuilder) => voidQuery added when the field has no condition at all (for example "hide archived" until the user asks for them).
format (condition: FilterCondition) => stringReplaces the text of the value in the pill.
negativesIncludeEmpty booleanNegative 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 stringText after the value (€, kg).
scale numberMultiplies the typed value before the query (for example 1000 to type tons of a column in kilograms).
step numberstep 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

NameTypeDescription
name requiredstringIdentity of the field, stored in the conditions.
label requiredstringName shown to the user.
icon stringSVG path of an icon shown in the list, the card and the pill.
category stringGroups the fields in the list of "Add filter".
description stringSecondary text in the list of fields.
column stringColumn 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 stringOperator of a new condition. Defaults to the first one.
pinned booleanAlways shown as a pill in the bar, even without a condition.
hidden booleanNever shown: its conditions (usually locked) only reach the query.
defaultValue FilterConditionValueValue of a new condition on this field (the card and the panel start with it).
isComplete (condition: FilterCondition) => booleanDecides 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) => voidReplaces the whole query of a condition on this field.
whenAbsent (builder: FilterBuilder) => voidQuery added when the field has no condition at all (for example "hide archived" until the user asks for them).
format (condition: FilterCondition) => stringReplaces the text of the value in the pill.
negativesIncludeEmpty booleanNegative 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 booleanThe 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 booleanThe 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

NameTypeDescription
name requiredstringIdentity of the field, stored in the conditions.
label requiredstringName shown to the user.
icon stringSVG path of an icon shown in the list, the card and the pill.
category stringGroups the fields in the list of "Add filter".
description stringSecondary text in the list of fields.
column stringColumn 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 stringOperator of a new condition. Defaults to the first one.
pinned booleanAlways shown as a pill in the bar, even without a condition.
hidden booleanNever shown: its conditions (usually locked) only reach the query.
defaultValue FilterConditionValueValue of a new condition on this field (the card and the panel start with it).
isComplete (condition: FilterCondition) => booleanDecides 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) => voidReplaces the whole query of a condition on this field.
whenAbsent (builder: FilterBuilder) => voidQuery added when the field has no condition at all (for example "hide archived" until the user asks for them).
format (condition: FilterCondition) => stringReplaces the text of the value in the pill.
negativesIncludeEmpty booleanNegative 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 stringLocale of the country names with view: 'countries'.
placeholder stringPlaceholder of the input.
array booleanThe 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

NameTypeDescription
name requiredstringIdentity of the field, stored in the conditions.
label requiredstringName shown to the user.
icon stringSVG path of an icon shown in the list, the card and the pill.
category stringGroups the fields in the list of "Add filter".
description stringSecondary text in the list of fields.
column stringColumn 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 stringOperator of a new condition. Defaults to the first one.
pinned booleanAlways shown as a pill in the bar, even without a condition.
hidden booleanNever shown: its conditions (usually locked) only reach the query.
defaultValue FilterConditionValueValue of a new condition on this field (the card and the panel start with it).
isComplete (condition: FilterCondition) => booleanDecides 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) => voidReplaces the whole query of a condition on this field.
whenAbsent (builder: FilterBuilder) => voidQuery added when the field has no condition at all (for example "hide archived" until the user asks for them).
format (condition: FilterCondition) => stringReplaces the text of the value in the pill.
negativesIncludeEmpty booleanNegative 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 stringText of isTrue in the pill and the card. Default Yes.
falseLabel stringText of isFalse. Default No.
whenTrue (builder: FilterBuilder) => voidQuery of isTrue, when it is not column = true (for example whereColumn('quantity', '<', 'minQuantity')).
whenFalse (builder: FilterBuilder) => voidQuery of isFalse, when it is not column = false.
nullable booleanThe column can be null: adds empty and notEmpty.

CustomFilterField

A field with an input of the app.

interface CustomFilterField extends FieldBase

NameTypeDescription
name requiredstringIdentity of the field, stored in the conditions.
label requiredstringName shown to the user.
icon stringSVG path of an icon shown in the list, the card and the pill.
category stringGroups the fields in the list of "Add filter".
description stringSecondary text in the list of fields.
column stringColumn 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 stringOperator of a new condition. Defaults to the first one.
pinned booleanAlways shown as a pill in the bar, even without a condition.
hidden booleanNever shown: its conditions (usually locked) only reach the query.
defaultValue FilterConditionValueValue of a new condition on this field (the card and the panel start with it).
isComplete (condition: FilterCondition) => booleanDecides 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) => voidReplaces the whole query of a condition on this field.
whenAbsent (builder: FilterBuilder) => voidQuery added when the field has no condition at all (for example "hide archived" until the user asks for them).
format (condition: FilterCondition) => stringReplaces the text of the value in the pill.
negativesIncludeEmpty booleanNegative 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'

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

FilterLabels

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

interface FilterLabels

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

FilterJoin

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

interface FilterJoin

NameTypeDescription
table requiredstringTable, 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

NameTypeDescription
key requiredstringColumn of the outer query compared with the subquery (users.id).
from requiredstringTable of the subquery (user_residences).
select requiredstringColumn selected by the subquery (userId).
joins FilterJoin[]Joins inside the subquery.
where (builder: FilterBuilder) => voidFixed conditions inside the subquery.

FilterOperatorDefinition

An operator defined by the app for one field.

interface FilterOperatorDefinition

NameTypeDescription
name requiredstringName stored in the conditions.
label requiredstringText between the field and the value (is, ≥, has tag).
input requiredFilterInputInput shown for the value. custom uses the field's inputSnippet.
apply (builder: FilterBuilder, condition: FilterCondition) => voidAdds 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> & { … }

NameTypeDescription
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> = { … }

NameTypeDescription
value requiredstring | numberIdentity of the option: two items are the same option when their values are equal (===).
label string | numberText shown and searched. Defaults to value.
icon stringSVG path of an icon shown before the label, for example from @mdi/js.
data DataAny extra data, available in snippets and callbacks.

CSS variables

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

Per-instance variableDefault
--filter-editor-gap
--filter-editor-default-gap 12px
--filter-editor-width
--filter-editor-default-width 320px
--filter-editor-padding
--filter-editor-default-padding 12px
--filter-editor-color
--filter-editor-default-color var(--global-color-text)
--filter-editor-title-font-size
--filter-editor-default-title-font-size 14px
--filter-editor-title-font-weight
--filter-editor-default-title-font-weight 600
--filter-editor-icon-color
--filter-editor-default-icon-color var(--global-color-primary)
--filter-editor-operators-border-radius
--filter-editor-default-operators-border-radius var(--global-radius-md)
--filter-editor-operators-background
--filter-editor-default-operators-background var(--global-color-surface-2)
--filter-editor-operator-color
--filter-editor-default-operator-color var(--global-color-text-2)
--filter-editor-operator-selected-background
--filter-editor-default-operator-selected-background var(--global-color-surface-pop)
--filter-editor-operator-selected-color
--filter-editor-default-operator-selected-color var(--global-color-primary)
--filter-editor-operator-selected-border-color
--filter-editor-default-operator-selected-border-color var(--global-color-border-strong)