@gears-frontx/ui-kit 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/data-grid.DYrZEU-F.css +1 -0
- package/dist/chunks/debounce.js +17 -0
- package/dist/chunks/debounce.js.map +1 -0
- package/dist/chunks/empty.Cfg5lE0n.css +1 -0
- package/dist/chunks/filters.DcFdZpNG.css +1 -0
- package/dist/chunks/hooked.js +52 -0
- package/dist/chunks/hooked.js.map +1 -0
- package/dist/chunks/messages.js +18 -3
- package/dist/chunks/messages.js.map +1 -1
- package/dist/chunks/pagination.DPVITj_D.css +1 -0
- package/dist/components/data-grid/components/filter-chip.d.ts +21 -0
- package/dist/components/data-grid/components/filter-chip.d.ts.map +1 -0
- package/dist/components/data-grid/components/filter-control-area.d.ts +9 -0
- package/dist/components/data-grid/components/filter-control-area.d.ts.map +1 -0
- package/dist/components/data-grid/components/filter-options-search-input.d.ts +11 -0
- package/dist/components/data-grid/components/filter-options-search-input.d.ts.map +1 -0
- package/dist/components/data-grid/components/filter-popover-content.d.ts +8 -0
- package/dist/components/data-grid/components/filter-popover-content.d.ts.map +1 -0
- package/dist/components/data-grid/components/filter-reset-button.d.ts +8 -0
- package/dist/components/data-grid/components/filter-reset-button.d.ts.map +1 -0
- package/dist/components/data-grid/components/filter-scrollable-wrapper.d.ts +8 -0
- package/dist/components/data-grid/components/filter-scrollable-wrapper.d.ts.map +1 -0
- package/dist/components/data-grid/messages.d.ts +15 -0
- package/dist/components/data-grid/messages.d.ts.map +1 -1
- package/dist/components/data-grid/plugins/filters/components/adaptive-popover.d.ts +20 -0
- package/dist/components/data-grid/plugins/filters/components/adaptive-popover.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/all-filters-button.d.ts +3 -0
- package/dist/components/data-grid/plugins/filters/components/all-filters-button.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/all-filters-dialog.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/components/all-filters-dialog.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/dialog-filter-item.d.ts +9 -0
- package/dist/components/data-grid/plugins/filters/components/dialog-filter-item.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/filter-label.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/components/filter-label.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/filter-popover.d.ts +9 -0
- package/dist/components/data-grid/plugins/filters/components/filter-popover.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/filter-single.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/components/filter-single.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/components/filters-bar.d.ts +3 -0
- package/dist/components/data-grid/plugins/filters/components/filters-bar.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/checkbox-group-dialog-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/checkbox-group-dialog-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/checkbox-group-list.d.ts +12 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/checkbox-group-list.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/checkbox-group-quick-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/checkbox-group-quick-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/filter-checkbox-group.d.ts +20 -0
- package/dist/components/data-grid/plugins/filters/entities/checkbox-group/filter-checkbox-group.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-calendar.d.ts +17 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-calendar.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-dialog-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-dialog-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-quick-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-quick-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-selection.d.ts +16 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-selection.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-value.d.ts +19 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/date-range-value.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/filter-date-range.d.ts +16 -0
- package/dist/components/data-grid/plugins/filters/entities/date-range/filter-date-range.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/entities.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/entities.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/search/filter-search.d.ts +10 -0
- package/dist/components/data-grid/plugins/filters/entities/search/filter-search.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/search/search-quick-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/search/search-quick-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/filter-tag-group.d.ts +14 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/filter-tag-group.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/tag-group-dialog-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/tag-group-dialog-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/tag-group-list.d.ts +11 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/tag-group-list.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/tag-group-quick-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/tag-group/tag-group-quick-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/toggle/filter-toggle.d.ts +10 -0
- package/dist/components/data-grid/plugins/filters/entities/toggle/filter-toggle.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/toggle/toggle-quick-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/toggle/toggle-quick-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/filter-tree.d.ts +20 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/filter-tree.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/resolve-filter-tree-value.d.ts +8 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/resolve-filter-tree-value.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-dialog-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-dialog-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-list.d.ts +12 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-list.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-quick-filter.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-quick-filter.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-radio-select-plugin.d.ts +13 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/tree-radio-select-plugin.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/use-tree-search.d.ts +8 -0
- package/dist/components/data-grid/plugins/filters/entities/tree/use-tree-search.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/filters-plugin.d.ts +3 -0
- package/dist/components/data-grid/plugins/filters/filters-plugin.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/filters-types.d.ts +141 -0
- package/dist/components/data-grid/plugins/filters/filters-types.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/public.d.ts +11 -0
- package/dist/components/data-grid/plugins/filters/public.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/services/read-option-values.d.ts +7 -0
- package/dist/components/data-grid/plugins/filters/services/read-option-values.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/services/use-async-filter-search.d.ts +20 -0
- package/dist/components/data-grid/plugins/filters/services/use-async-filter-search.d.ts.map +1 -0
- package/dist/components/data-grid/plugins/filters/services/use-filter-search.d.ts +12 -0
- package/dist/components/data-grid/plugins/filters/services/use-filter-search.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-actions.d.ts +7 -0
- package/dist/components/data-grid/tree/components/tree-actions.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-content.d.ts +3 -0
- package/dist/components/data-grid/tree/components/tree-content.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-layout-slot.d.ts +9 -0
- package/dist/components/data-grid/tree/components/tree-layout-slot.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-left-slot.d.ts +7 -0
- package/dist/components/data-grid/tree/components/tree-left-slot.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-list-item.d.ts +10 -0
- package/dist/components/data-grid/tree/components/tree-list-item.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-main.d.ts +3 -0
- package/dist/components/data-grid/tree/components/tree-main.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-node-content.d.ts +7 -0
- package/dist/components/data-grid/tree/components/tree-node-content.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-node-directory-item.d.ts +7 -0
- package/dist/components/data-grid/tree/components/tree-node-directory-item.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-node-leaf.d.ts +7 -0
- package/dist/components/data-grid/tree/components/tree-node-leaf.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-nodes.d.ts +7 -0
- package/dist/components/data-grid/tree/components/tree-nodes.d.ts.map +1 -0
- package/dist/components/data-grid/tree/components/tree-placeholder.d.ts +6 -0
- package/dist/components/data-grid/tree/components/tree-placeholder.d.ts.map +1 -0
- package/dist/components/data-grid/tree/create-tree.d.ts +5 -0
- package/dist/components/data-grid/tree/create-tree.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/core/tree-context.d.ts +21 -0
- package/dist/components/data-grid/tree/services/core/tree-context.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/focus/focus-service.d.ts +5 -0
- package/dist/components/data-grid/tree/services/focus/focus-service.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/focus/focus-types.d.ts +25 -0
- package/dist/components/data-grid/tree/services/focus/focus-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/focus/navigation-helpers.d.ts +27 -0
- package/dist/components/data-grid/tree/services/focus/navigation-helpers.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/hooked/hooked-types.d.ts +8 -0
- package/dist/components/data-grid/tree/services/hooked/hooked-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/hooked/hooked.d.ts +3 -0
- package/dist/components/data-grid/tree/services/hooked/hooked.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/internal/internal-helpers.d.ts +2 -0
- package/dist/components/data-grid/tree/services/internal/internal-helpers.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/layout/layout-service.d.ts +5 -0
- package/dist/components/data-grid/tree/services/layout/layout-service.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/layout/layout-types.d.ts +124 -0
- package/dist/components/data-grid/tree/services/layout/layout-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/plugins/plugins-helpers.d.ts +50 -0
- package/dist/components/data-grid/tree/services/plugins/plugins-helpers.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/plugins/plugins-service.d.ts +5 -0
- package/dist/components/data-grid/tree/services/plugins/plugins-service.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/plugins/plugins-types.d.ts +43 -0
- package/dist/components/data-grid/tree/services/plugins/plugins-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/settings/settings-service.d.ts +5 -0
- package/dist/components/data-grid/tree/services/settings/settings-service.d.ts.map +1 -0
- package/dist/components/data-grid/tree/services/settings/settings-types.d.ts +73 -0
- package/dist/components/data-grid/tree/services/settings/settings-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree/tree-types.d.ts +44 -0
- package/dist/components/data-grid/tree/tree-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree/tree.d.ts +4 -0
- package/dist/components/data-grid/tree/tree.d.ts.map +1 -0
- package/dist/components/data-grid/tree-structure/tree-structure-types.d.ts +89 -0
- package/dist/components/data-grid/tree-structure/tree-structure-types.d.ts.map +1 -0
- package/dist/components/data-grid/tree-structure/tree-structure.d.ts +19 -0
- package/dist/components/data-grid/tree-structure/tree-structure.d.ts.map +1 -0
- package/dist/components/data-grid/utils/components-stack.d.ts +12 -0
- package/dist/components/data-grid/utils/components-stack.d.ts.map +1 -0
- package/dist/components/data-grid/utils/use-is-tablet-up.d.ts +3 -0
- package/dist/components/data-grid/utils/use-is-tablet-up.d.ts.map +1 -0
- package/dist/data-grid/filters.d.ts +1 -0
- package/dist/data-grid/filters.js +1633 -0
- package/dist/data-grid/filters.js.map +1 -0
- package/dist/data-grid/pagination.js +41 -40
- package/dist/data-grid/pagination.js.map +1 -1
- package/dist/data-grid/text-search.js +55 -67
- package/dist/data-grid/text-search.js.map +1 -1
- package/dist/data-grid.js +578 -618
- package/dist/data-grid.js.map +1 -1
- package/dist/docs/data-grid.md +170 -4
- package/dist/empty.js +34 -34
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +392 -382
- package/dist/index.js.map +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/dist/chunks/data-grid.DIkpRRaf.css +0 -1
- package/dist/chunks/empty.DWqLrSfF.css +0 -1
- package/dist/chunks/pagination.BAAl9D_S.css +0 -1
package/dist/docs/data-grid.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
A server-driven data grid: a `DataGrid` that renders rows through the kit's
|
|
4
4
|
`Table`, a `load(ctx)` callback that fetches them, a slot-based layout around
|
|
5
|
-
the table, and plugins that add behavior (paging, search, sorting, a
|
|
6
|
-
empty state) by registering into those slots and hooking the load. Each concern
|
|
5
|
+
the table, and plugins that add behavior (paging, search, sorting, filters, a
|
|
6
|
+
custom empty state) by registering into those slots and hooking the load. Each concern
|
|
7
7
|
(load, layout, table, storage, persistence) is a service with its own store, and
|
|
8
8
|
a plugin reaches all of them through one context object.
|
|
9
9
|
|
|
10
|
-
Built-in plugins: pagination, text search, order and empty state, each
|
|
11
|
-
entry (see below).
|
|
10
|
+
Built-in plugins: pagination, text search, order, filters and empty state, each
|
|
11
|
+
its own entry (see below).
|
|
12
12
|
|
|
13
13
|
## When to use
|
|
14
14
|
|
|
@@ -35,6 +35,7 @@ code or CSS:
|
|
|
35
35
|
| `@gears-frontx/ui-kit/data-grid/pagination` | `DataGridPaginationPlugin` |
|
|
36
36
|
| `@gears-frontx/ui-kit/data-grid/text-search` | `DataGridTextSearchPlugin` |
|
|
37
37
|
| `@gears-frontx/ui-kit/data-grid/order` | `DataGridOrderPlugin`, `createDataGridOrderOption` |
|
|
38
|
+
| `@gears-frontx/ui-kit/data-grid/filters` | `DataGridFiltersPlugin`, the entity factories `filterSearch`, `filterToggle`, `filterCheckboxGroup`, `filterTagGroup`, `filterTree` and `filterDateRange`, `createDataGridTreeStructure` and `useDataGridTreeStructure` (the tree `filterTree` takes), and the types |
|
|
38
39
|
| `@gears-frontx/ui-kit/data-grid/empty-state` | `DataGridEmptyStatePlugin` |
|
|
39
40
|
|
|
40
41
|
The package root re-exports all of them, so
|
|
@@ -295,6 +296,11 @@ them with `registerSlot(name, { id, component, order? })`:
|
|
|
295
296
|
| `bottom` | The footer (pagination); hidden while the grid has no records |
|
|
296
297
|
| `empty` | Replaces the built-in empty state |
|
|
297
298
|
|
|
299
|
+
The toolbar fits itself to the grid's width. What `top-start` holds flows onto
|
|
300
|
+
further lines when it is too wide for one, and `top-end` goes on to a line of its
|
|
301
|
+
own, at its end, when it would not fit beside `top-start` on a single line. A
|
|
302
|
+
toolbar that fits on one line has everything centred on it.
|
|
303
|
+
|
|
298
304
|
With two or more `main` views (for example the table and a cards view) the grid
|
|
299
305
|
adds a view switch to `top-end` by itself. Read or set the active view with
|
|
300
306
|
`useDataGridActiveView()` and `DATA_GRID_VIEW`:
|
|
@@ -394,6 +400,143 @@ again.
|
|
|
394
400
|
The plugin compares `options` and `excludedColumns` by content, so an inline
|
|
395
401
|
array does not count as a change.
|
|
396
402
|
|
|
403
|
+
### `DataGridFiltersPlugin`
|
|
404
|
+
|
|
405
|
+
A bar of quick filters in `top-start`, and an "All filters" panel that edits the
|
|
406
|
+
same filters in one go. Each active filter reaches your `load` as
|
|
407
|
+
`filters[filterKey] = { value }`.
|
|
408
|
+
|
|
409
|
+
```tsx
|
|
410
|
+
import {
|
|
411
|
+
DataGridFiltersPlugin,
|
|
412
|
+
filterCheckboxGroup,
|
|
413
|
+
filterDateRange,
|
|
414
|
+
filterToggle,
|
|
415
|
+
} from '@gears-frontx/ui-kit/data-grid/filters';
|
|
416
|
+
|
|
417
|
+
const ENTITIES = [
|
|
418
|
+
filterToggle({ id: 'only_active', label: 'Only active' }),
|
|
419
|
+
filterCheckboxGroup({
|
|
420
|
+
id: 'role',
|
|
421
|
+
label: 'Role',
|
|
422
|
+
options: [
|
|
423
|
+
{ label: 'Admin', value: 'admin' },
|
|
424
|
+
{ label: 'Member', value: 'member' },
|
|
425
|
+
],
|
|
426
|
+
}),
|
|
427
|
+
filterDateRange({ id: 'created_at', label: 'Created' }),
|
|
428
|
+
];
|
|
429
|
+
|
|
430
|
+
async function loadUsers({ filters }: DataGridLoadContext) {
|
|
431
|
+
const roles = filters?.role?.value; // ['admin'], when the Role filter holds a choice
|
|
432
|
+
const range = filters?.created_at?.value; // { from?: '2026-03-01', to?: '2026-03-31' }
|
|
433
|
+
// ...
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
<DataGrid name="users" load={loadUsers} columns={columns}>
|
|
437
|
+
<DataGridFiltersPlugin entities={ENTITIES} />
|
|
438
|
+
</DataGrid>;
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
| Prop | Type | Default |
|
|
442
|
+
|------|------|---------|
|
|
443
|
+
| `entities` | `DataGridFilterEntity[]` | required; keep the array referentially stable (module scope, or `useMemo`) |
|
|
444
|
+
| `isAllFiltersOptionVisible` | `boolean` | `true`; the "All filters" chip is drawn when this is on and at least one entity has a panel section |
|
|
445
|
+
|
|
446
|
+
**Entities.** Each factory returns one filter. They share `id`, `filterKey`
|
|
447
|
+
(defaults to `id`: the key your `load` reads) and `label`. With no `label`, the
|
|
448
|
+
chip is named after the column whose id equals `id`; an entity with neither a
|
|
449
|
+
label nor a matching column throws when it renders. `popover` (`{ minInlineSize,
|
|
450
|
+
maxInlineSize? }`, in px) sizes the popover of a filter that has one.
|
|
451
|
+
|
|
452
|
+
| Factory | Value in `load` | Quick filter | Panel section |
|
|
453
|
+
|---------|-----------------|--------------|---------------|
|
|
454
|
+
| `filterSearch({ id })` | `{ value: string }` | A text box in a popover, applied 1 s after typing stops | no |
|
|
455
|
+
| `filterToggle({ id })` | `{ value: true }` | A chip that switches the filter on and off | no |
|
|
456
|
+
| `filterCheckboxGroup({ id, options, search?, searchDebounce? })` | `{ value: (string \| number)[] }` | A popover of checkboxes | yes |
|
|
457
|
+
| `filterTagGroup({ id, options, mode?, search? })` | `{ value: (string \| number)[] }` | A popover of selectable tags; `mode: 'radio'` allows one | yes |
|
|
458
|
+
| `filterTree({ id, tree, treeLabel, filterValue?, search? })` | `{ value: string \| number }` | A popover with a tree of radios | yes |
|
|
459
|
+
| `filterDateRange({ id, modelDateFormat? })` | `{ value: { from?: string, to?: string } }` | A popover with a range calendar | yes |
|
|
460
|
+
|
|
461
|
+
An option is `{ label, value, component? }`; `component` draws the option in
|
|
462
|
+
place of its label. The search box of a checkbox group and a tree shows above 5
|
|
463
|
+
options (5 nodes), and of a tag group above 10; `search` forces it on or off.
|
|
464
|
+
`filterCheckboxGroup` takes a function for `options` when the list is too long
|
|
465
|
+
to load up front: it is called with the trimmed search term, once when the list
|
|
466
|
+
opens (with an empty string) and again `searchDebounce` ms (default 300) after
|
|
467
|
+
each change of the term, and only the latest answer is shown. A failure shows "No
|
|
468
|
+
options found".
|
|
469
|
+
|
|
470
|
+
**Quick filters** apply at once: each change updates the value, stores it and
|
|
471
|
+
reloads from page 1. A chip shows a count when its value is a list, a dot when it
|
|
472
|
+
holds any other value, and its popover has a Reset button.
|
|
473
|
+
|
|
474
|
+
**The "All filters" panel** opens a sheet (from the side from 720 px wide, from the
|
|
475
|
+
bottom edge below it) with a section for each entity that has one. Its choices
|
|
476
|
+
are a draft: nothing loads until **Apply**, which commits all of them at once.
|
|
477
|
+
Leaving the panel without Apply (its close button, Escape, a click outside)
|
|
478
|
+
discards the draft, and the next opening starts from what is applied. The count tag in a section's
|
|
479
|
+
header clears that section of the draft. The chip's count is the number of active
|
|
480
|
+
filters that have a section.
|
|
481
|
+
|
|
482
|
+
The same width decides how a quick filter opens: as a popover beside its chip,
|
|
483
|
+
or as a panel from the bottom edge.
|
|
484
|
+
|
|
485
|
+
**Active values.** A filter is active unless its value is `undefined`, `null`,
|
|
486
|
+
`''` or an empty array, so `false` and `0` are values like any other. Inactive
|
|
487
|
+
filters are left out of the load context. (The grid's own `hasActiveFilters`,
|
|
488
|
+
which the empty state reads, agrees except for one value: it treats `0` as
|
|
489
|
+
inactive.)
|
|
490
|
+
|
|
491
|
+
**Persistence.** All filters are stored under one key, `dataGrid:${name}:filters`,
|
|
492
|
+
as `{ [filterKey]: { value } }`. A refresh that resets filters clears them. The
|
|
493
|
+
stored value can be edited by the user, so what the controls show is guarded: a
|
|
494
|
+
checkbox group or a tag group reads a stored value that is not a list as no
|
|
495
|
+
selection, and a date range reads a bound that is not a date in `modelDateFormat`
|
|
496
|
+
as unset. The guards change only what the controls show. Every stored value,
|
|
497
|
+
whatever its shape, still reaches `load` as long as it is stored (a list filter's
|
|
498
|
+
wrongly shaped value, a date range's, a value for a filter that is no longer in
|
|
499
|
+
`entities`), so read `filters` defensively there (check `Array.isArray` before
|
|
500
|
+
using a list).
|
|
501
|
+
|
|
502
|
+
**`filterDateRange`.** The bounds are strings in `modelDateFormat`, which takes
|
|
503
|
+
[date-fns format tokens](https://date-fns.org/docs/format) and defaults to
|
|
504
|
+
`'yyyy-MM-dd'`: `'dd.MM.yyyy'`, not `'DD.MM.YYYY'`. Either bound may be missing
|
|
505
|
+
(`{ from }` means "from then on"). The first click on a day starts a range, the
|
|
506
|
+
second ends it (in either order), and a click after that starts a new one.
|
|
507
|
+
|
|
508
|
+
**`filterTree`.** `tree` is a tree structure, made in the same entry:
|
|
509
|
+
|
|
510
|
+
```tsx
|
|
511
|
+
import { filterTree, useDataGridTreeStructure } from '@gears-frontx/ui-kit/data-grid/filters';
|
|
512
|
+
|
|
513
|
+
const tree = useDataGridTreeStructure({
|
|
514
|
+
items: departments,
|
|
515
|
+
itemKey: 'id', // the default; a function is allowed
|
|
516
|
+
parentKey: 'parent_id', // the default; or `childrenKey` for nested items
|
|
517
|
+
isLeaf: (department) => !department.has_children, // without it every node can be expanded
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
filterTree({ id: 'department', tree, treeLabel: 'name', filterValue: 'code' });
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
`createDataGridTreeStructure` makes the same thing outside a component; either
|
|
524
|
+
returns a structure you can fill later with `tree.setItems(items)` or reshape with
|
|
525
|
+
`tree.move(...)` (which throws for a move under the node itself or one of its
|
|
526
|
+
descendants), and an open filter follows. `treeLabel` is a property name or a
|
|
527
|
+
function returning the node's text; search matches on it, keeps the matching
|
|
528
|
+
nodes, the path down to each one and the nodes under it, and starts 300 ms after
|
|
529
|
+
typing stops. By default `load` receives the id of the chosen node; `filterValue`
|
|
530
|
+
(a property name or a function of the item) sends something else, such as a
|
|
531
|
+
code, while the id is what is stored. A tree keeps its items' `id` property as
|
|
532
|
+
their key: use the default `itemKey`.
|
|
533
|
+
|
|
534
|
+
The plugin's API (`getPlugin<DataGridFiltersPluginApi>('filters')`) offers
|
|
535
|
+
`useState(filterKey)`, `setState`, `removeState`, `useDraftState`,
|
|
536
|
+
`setDraftState`, `applyDraftState`, `resetDraftState`, `useActiveCount(filterKeys)`,
|
|
537
|
+
`isFilterValueActive` and `useFilterEntities`, for a custom filter or a control
|
|
538
|
+
of your own.
|
|
539
|
+
|
|
397
540
|
### `DataGridEmptyStatePlugin`
|
|
398
541
|
|
|
399
542
|
Renders your component in place of the built-in empty state, whenever the grid has
|
|
@@ -544,6 +687,17 @@ columns' minimum content widths.
|
|
|
544
687
|
- `aria-busy` is set on the content region while a loader is on screen.
|
|
545
688
|
- The order popover's items are menu items without a menu popup, so they take
|
|
546
689
|
focus and Enter and Space, but arrow keys do not move between them.
|
|
690
|
+
- A filter chip is a native `button`; the toggle chip does not say whether it is on
|
|
691
|
+
(no `aria-pressed`), only by its look. The text box of a `filterSearch` filter has
|
|
692
|
+
no placeholder and no accessible name, and the search box inside a list filter
|
|
693
|
+
has a placeholder ("Search...") and no accessible name. A tag is a label over a
|
|
694
|
+
native checkbox or radio, so the input carries the state.
|
|
695
|
+
- In a tree filter each row holds a radio and the tree moves its own focus: Arrow
|
|
696
|
+
keys move between rows, Right and Left open and close a directory, Home and End
|
|
697
|
+
go to the ends, and Enter toggles a directory. A node is chosen with the mouse,
|
|
698
|
+
or by Tab to its radio and Space.
|
|
699
|
+
- The "All filters" panel is a dialog; it is left with its close button (named
|
|
700
|
+
"Close dialog"), Escape or a click outside.
|
|
547
701
|
- Strings are English and live in one module; the kit has no i18n layer yet.
|
|
548
702
|
|
|
549
703
|
## Known limitations
|
|
@@ -575,6 +729,18 @@ columns' minimum content widths.
|
|
|
575
729
|
it also drops `history.state` and the `#hash` when it writes the URL, and it does
|
|
576
730
|
not work during server rendering.
|
|
577
731
|
- A new `columns` array identity resets user pins and visibility.
|
|
732
|
+
- A filter's quick popover is not kept in step with what resets it from outside:
|
|
733
|
+
a tree filter's radio stays checked after its Reset button until the popover is
|
|
734
|
+
opened again, although the filter is cleared.
|
|
735
|
+
- `filterTree` reads each item's `id` property for its search and its radios. With
|
|
736
|
+
an `itemKey` other than `id` every radio shows as checked, a click selects
|
|
737
|
+
nothing, and a search hides every node.
|
|
738
|
+
- In a tree filter with a search, the arrow keys also step onto the rows the search
|
|
739
|
+
hides. Once the focus is on a hidden row, no row shown is a tab stop, so the
|
|
740
|
+
arrow keys are lost until that row is shown again or another row is clicked;
|
|
741
|
+
each row's radio can still be reached with Tab.
|
|
742
|
+
- A key in `filters` that no entity owns any more, and any stored value of the
|
|
743
|
+
wrong shape (see Persistence), still reach `load`.
|
|
578
744
|
- There is no plugin unregister.
|
|
579
745
|
|
|
580
746
|
## Anti-patterns
|
package/dist/empty.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
3
3
|
import { mergeProps as r } from "@base-ui/react/merge-props";
|
|
4
|
-
import { useRender as
|
|
5
|
-
import { cx as i, cva as
|
|
6
|
-
import './chunks/empty.
|
|
7
|
-
empty:
|
|
4
|
+
import { useRender as p } from "@base-ui/react/use-render";
|
|
5
|
+
import { cx as i, cva as o } from "class-variance-authority";
|
|
6
|
+
import './chunks/empty.Cfg5lE0n.css';const s = "_empty_nanxk_7", c = "_emptyHeader_nanxk_31", y = "_emptyMedia_nanxk_39", _ = "_variantDefault_nanxk_52", l = "_variantIcon_nanxk_56", d = "_emptyTitle_nanxk_82", u = "_emptyDescription_nanxk_99", f = "_emptyDetail_nanxk_125", v = "_emptyActions_nanxk_154", x = "_emptyContent_nanxk_151", D = "_renderedTitle_nanxk_187", n = {
|
|
7
|
+
empty: s,
|
|
8
8
|
emptyHeader: c,
|
|
9
|
-
emptyMedia:
|
|
10
|
-
variantDefault:
|
|
11
|
-
variantIcon:
|
|
9
|
+
emptyMedia: y,
|
|
10
|
+
variantDefault: _,
|
|
11
|
+
variantIcon: l,
|
|
12
12
|
emptyTitle: d,
|
|
13
13
|
emptyDescription: u,
|
|
14
14
|
emptyDetail: f,
|
|
15
15
|
emptyActions: v,
|
|
16
|
-
emptyContent:
|
|
17
|
-
renderedTitle:
|
|
16
|
+
emptyContent: x,
|
|
17
|
+
renderedTitle: D
|
|
18
18
|
};
|
|
19
|
-
function
|
|
20
|
-
return /* @__PURE__ */
|
|
19
|
+
function A({ className: e, ...t }) {
|
|
20
|
+
return /* @__PURE__ */ a("div", { className: i(n.empty, e), ...t });
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return /* @__PURE__ */
|
|
22
|
+
function C({ className: e, ...t }) {
|
|
23
|
+
return /* @__PURE__ */ a("div", { className: i(n.emptyHeader, e), ...t });
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const k = o(n.emptyMedia, {
|
|
26
26
|
variants: {
|
|
27
27
|
variant: {
|
|
28
28
|
default: n.variantDefault,
|
|
@@ -33,39 +33,39 @@ const N = m(n.emptyMedia, {
|
|
|
33
33
|
variant: "default"
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
function
|
|
37
|
-
return /* @__PURE__ */
|
|
36
|
+
function H({ className: e, variant: t, ...m }) {
|
|
37
|
+
return /* @__PURE__ */ a("div", { className: k({ variant: t, className: e }), ...m });
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function I({ className: e, render: t, ...m }) {
|
|
40
|
+
return p({
|
|
41
41
|
defaultTagName: "div",
|
|
42
42
|
render: t,
|
|
43
43
|
props: r(
|
|
44
44
|
{ className: i(n.emptyTitle, t && n.renderedTitle, e) },
|
|
45
|
-
|
|
45
|
+
m
|
|
46
46
|
)
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
function g({ className: e, ...t }) {
|
|
50
|
+
return /* @__PURE__ */ a("div", { className: i(n.emptyDescription, e), ...t });
|
|
51
|
+
}
|
|
49
52
|
function V({ className: e, ...t }) {
|
|
50
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ a("div", { className: i(n.emptyContent, e), ...t });
|
|
51
54
|
}
|
|
52
55
|
function j({ className: e, ...t }) {
|
|
53
|
-
return /* @__PURE__ */
|
|
56
|
+
return /* @__PURE__ */ a("div", { className: i(n.emptyDetail, e), ...t });
|
|
54
57
|
}
|
|
55
58
|
function P({ className: e, ...t }) {
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
}
|
|
58
|
-
function R({ className: e, ...t }) {
|
|
59
|
-
return /* @__PURE__ */ p("div", { className: i(n.emptyActions, e), ...t });
|
|
59
|
+
return /* @__PURE__ */ a("div", { className: i(n.emptyActions, e), ...t });
|
|
60
60
|
}
|
|
61
61
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
A as Empty,
|
|
63
|
+
P as EmptyActions,
|
|
64
|
+
V as EmptyContent,
|
|
65
|
+
g as EmptyDescription,
|
|
66
|
+
j as EmptyDetail,
|
|
67
|
+
C as EmptyHeader,
|
|
68
|
+
H as EmptyMedia,
|
|
69
|
+
I as EmptyTitle
|
|
70
70
|
};
|
|
71
71
|
//# sourceMappingURL=empty.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export * from './components/combobox/public.js';
|
|
|
48
48
|
export * from './components/command/public.js';
|
|
49
49
|
export * from './components/context-menu/public.js';
|
|
50
50
|
export * from './components/data-grid/plugins/empty-state/public.js';
|
|
51
|
+
export * from './components/data-grid/plugins/filters/public.js';
|
|
51
52
|
export * from './components/data-grid/plugins/order/public.js';
|
|
52
53
|
export * from './components/data-grid/plugins/pagination/public.js';
|
|
53
54
|
export * from './components/data-grid/plugins/text-search/public.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1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