Calm motion: animations on this site only fade, with no movement
QueryBuilder
Filter rules in nested "all" and "any" groups
Builds a filter that has more than one condition, for example "studio is A-1 Pictures, and the show has 12 episodes or aired after 2015". Use it for saved views, segments, and reports. For one search box, use an input. For filters on the columns of a table, use the filters of the data table.
Basic
{"match":"all","rules":[{"field":"studio","op":"eq","value":"a1"},{"match":"any","rules":[{"field":"episodes","op":"gte","value":"12"},{"field":"aired","op":"gt","value":"2015-01-01"}]}]}fieldslists what people can filter by:{ name, label, type, options }. The type istext(default),number,date, orselect, and it sets the operators and the value control.v-modelis plain data:{ match: "all" | "any", rules }. A rule is{ field, op, value }, and a rule can also be a group. The component does not filter anything. Turn the data into your query on the server, for example with Ecto'sdynamic/2.- The operators are
eq,neq,contains,starts,lt,lte,gt,gte,empty, andnotEmpty. A date field showsltandgtas "is before" and "is after".emptyandnotEmptytake no value. - The value is the text of its control, also for a number or a date (
"12","2015-01-01"). Convert it where you build the query. - When a rule changes to a field that does not have its operator, the operator goes to the field's first one, and the value clears.
maxDepthsets how deep groups can go (default 2: groups in the top group, and no deeper). A group inside a group has a line on its start edge.- After a remove, focus goes to the "Add rule" button of the same group, so the keyboard stays in place.
- Change the words with
labelsor a label pack: the buttons, the names of the controls, and each operator.
Usage
ts
import { BlessQueryBuilder, type BlessQueryField, type BlessQueryGroup } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
fields* | BlessQueryField[] | — | what people can filter by |
maxDepth | number | 2 | how deep groups can go; 1 allows no groups inside the top one |
disabled | boolean | — | |
labels | Partial<{ group: string; match: string; all: string; any: string; field: string; op: string; value: string; addRule: string; addGroup: string; remove: string; removeGroup: string; eq: string; neq: string; contains: string; starts: string; lt: string; lte: string; gt: string; gte: string; empty: string; notEmpty: string; before: string; onOrBefore: string; after: string; onOrAfter: string; }> | — | |
modelValue | BlessQueryGroup | { match: "all", rules: [] } | the rules as plain data; turn it into your query on the server |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: BlessQueryGroup] |