@macrostrat/data-sheet 4.2.1 → 4.4.0
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/CHANGELOG.md +134 -0
- package/dist/actions/types.d.ts +10 -0
- package/dist/components/indicators/filter-and-sort.cjs +61 -9
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -1
- package/dist/components/indicators/filter-and-sort.d.ts +49 -7
- package/dist/components/indicators/filter-and-sort.js +62 -10
- package/dist/components/indicators/filter-and-sort.js.map +1 -1
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +7 -3
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -1
- package/dist/components/indicators/filter-and-sort.module.sass.js +7 -3
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -1
- package/dist/components/indicators/selection.cjs +7 -12
- package/dist/components/indicators/selection.cjs.map +1 -1
- package/dist/components/indicators/selection.d.ts +5 -0
- package/dist/components/indicators/selection.js +9 -14
- package/dist/components/indicators/selection.js.map +1 -1
- package/dist/components/indicators/unified-filters.cjs +135 -22
- package/dist/components/indicators/unified-filters.cjs.map +1 -1
- package/dist/components/indicators/unified-filters.d.ts +17 -8
- package/dist/components/indicators/unified-filters.js +137 -24
- package/dist/components/indicators/unified-filters.js.map +1 -1
- package/dist/components/indicators/view-info.cjs +6 -0
- package/dist/components/indicators/view-info.cjs.map +1 -1
- package/dist/components/indicators/view-info.d.ts +2 -2
- package/dist/components/indicators/view-info.js +7 -1
- package/dist/components/indicators/view-info.js.map +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +7 -1
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -1
- package/dist/components/toolbars/actions-toolbar.js +7 -1
- package/dist/components/toolbars/actions-toolbar.js.map +1 -1
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +12 -12
- package/dist/components/toolbars/actions-toolbar.module.sass.js +12 -12
- package/dist/data-panel.cjs +62 -9
- package/dist/data-panel.cjs.map +1 -1
- package/dist/data-panel.d.ts +14 -2
- package/dist/data-panel.js +64 -11
- package/dist/data-panel.js.map +1 -1
- package/dist/data-panel.module.sass.cjs +25 -21
- package/dist/data-panel.module.sass.cjs.map +1 -1
- package/dist/data-panel.module.sass.js +25 -21
- package/dist/data-panel.module.sass.js.map +1 -1
- package/dist/data-sheet.cjs +3 -1
- package/dist/data-sheet.cjs.map +1 -1
- package/dist/data-sheet.css +75 -50
- package/dist/data-sheet.d.ts +1 -1
- package/dist/data-sheet.js +3 -1
- package/dist/data-sheet.js.map +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -3
- package/dist/postgrest-table/data-loaders.cjs +20 -3
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +10 -0
- package/dist/postgrest-table/data-loaders.js +21 -4
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/provider/core.cjs +27 -56
- package/dist/provider/core.cjs.map +1 -1
- package/dist/provider/core.d.ts +7 -9
- package/dist/provider/core.js +19 -48
- package/dist/provider/core.js.map +1 -1
- package/dist/provider/interactions.cjs +14 -0
- package/dist/provider/interactions.cjs.map +1 -1
- package/dist/provider/interactions.d.ts +20 -1
- package/dist/provider/interactions.js +15 -1
- package/dist/provider/interactions.js.map +1 -1
- package/dist/provider/selection.cjs +2 -2
- package/dist/provider/selection.cjs.map +1 -1
- package/dist/provider/selection.d.ts +1 -1
- package/dist/provider/selection.js +3 -3
- package/dist/provider/selection.js.map +1 -1
- package/dist/provider/zustand-store.cjs +13 -6
- package/dist/provider/zustand-store.cjs.map +1 -1
- package/dist/provider/zustand-store.js +13 -6
- package/dist/provider/zustand-store.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.js.map +1 -1
- package/package.json +5 -6
- package/src/actions/types.ts +11 -0
- package/src/components/indicators/filter-and-sort.module.sass +7 -0
- package/src/components/indicators/filter-and-sort.ts +102 -13
- package/src/components/indicators/selection.ts +10 -15
- package/src/components/indicators/unified-filters.ts +215 -32
- package/src/components/indicators/view-info.ts +10 -0
- package/src/components/toolbars/actions-toolbar.module.sass +1 -1
- package/src/components/toolbars/actions-toolbar.ts +10 -1
- package/src/data-panel.module.sass +26 -4
- package/src/data-panel.ts +92 -9
- package/src/data-sheet.ts +2 -0
- package/src/postgrest-table/data-loaders.ts +40 -4
- package/src/provider/core.ts +29 -53
- package/src/provider/interactions.ts +31 -0
- package/src/provider/selection.ts +3 -3
- package/src/provider/zustand-store.ts +23 -5
- package/src/types.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,139 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.4.0] - 2026-08-26 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v4.3.0...@macrostrat/data-sheet-v4.4.0)
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- View-control placement, modal-selection fixes, and cmd-click selection
|
|
8
|
+
(`DataPanel`):
|
|
9
|
+
|
|
10
|
+
- **`viewControls: "inline" | "popover"`** — where the built-in view controls
|
|
11
|
+
(inline filters, the Filter menu, the Sort menu) sit in the toolbar.
|
|
12
|
+
`popover` collapses all of them behind one button, for a narrow or
|
|
13
|
+
deliberately chrome-light toolbar. Same controls, same store seam; only
|
|
14
|
+
placement changes — the `TableFilter.presentation` idea applied to the
|
|
15
|
+
toolbar as a whole.
|
|
16
|
+
- **The view controls get out of the way while selecting.** On a
|
|
17
|
+
modal-selection view, entering select mode replaces them with a single
|
|
18
|
+
**Filter** control that _leaves_ select mode, handing the toolbar to the
|
|
19
|
+
selection and its set-actions. Filtering and selecting no longer compete for
|
|
20
|
+
the toolbar — or for each other's correctness (below).
|
|
21
|
+
- **A view change drops row selections.** `setFilter` / `removeFilter` /
|
|
22
|
+
`clearFilters` / `setColumnSort` / `clearColumnSorts` now clear the
|
|
23
|
+
row-addressed parts of the selection: rows are selected _by index_, so a
|
|
24
|
+
re-filter or re-sort leaves "rows 3–5" pointing at different records, and a
|
|
25
|
+
set-action would silently act on the wrong ones. Column selections survive
|
|
26
|
+
(they're index-stable, and the sheet's own sort/filter controls are invoked
|
|
27
|
+
from a column selection).
|
|
28
|
+
- **Cmd/ctrl-click enters select mode** on a modal-selection `DataPanel` and
|
|
29
|
+
selects the clicked row — the familiar list idiom, so a bulk action no
|
|
30
|
+
longer requires finding the Select control first.
|
|
31
|
+
- **Modal selection state is no longer clobberable.** It lived in
|
|
32
|
+
`interactionOptionsAtom`, which the provider re-syncs from props on every
|
|
33
|
+
render (`resolveInteractionOptions` builds a fresh object each time), so any
|
|
34
|
+
provider re-render reset select mode. It now has its own atom
|
|
35
|
+
(`selectionModeActiveAtom`), read through the new `enableSelectionAtom` —
|
|
36
|
+
which is what every selection path should consult from now on.
|
|
37
|
+
- **`MenuDropdown` no longer traps focus, and passes its props through.** It
|
|
38
|
+
hard-coded `enforceFocus: true` and silently dropped extra props (a caller's
|
|
39
|
+
`placement` never applied). The focus trap is what made a filter submenu
|
|
40
|
+
feel unstable: a control whose own typeahead renders in a separate portal
|
|
41
|
+
had focus yanked back out of it.
|
|
42
|
+
- **New `MenuFormItem`** — a titled block inside a menu holding an arbitrary
|
|
43
|
+
form (rather than a submenu), exported so a custom control panel can use the
|
|
44
|
+
idiom `MenuInlineFilterItem` is built on.
|
|
45
|
+
- **`DataPanelToolbarStyle.FLOATING`** — the `"floating"` toolbar style was
|
|
46
|
+
implemented in the stylesheet (and used by consumers) but missing from the
|
|
47
|
+
enum.
|
|
48
|
+
- New story `Data sheet/Data panel/View controls`, with `viewControls`,
|
|
49
|
+
`toolbarStyle`, and `enableSelection` as arg controls — the three are
|
|
50
|
+
coupled (how much toolbar there is decides whether inline controls fit, and
|
|
51
|
+
modal selection is what makes them step aside), so the story is a matrix to
|
|
52
|
+
try rather than one arrangement per story.
|
|
53
|
+
|
|
54
|
+
## [4.3.0] - 2026-07-27 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v4.2.1...@macrostrat/data-sheet-v4.3.0)
|
|
55
|
+
|
|
56
|
+
### Minor Changes
|
|
57
|
+
|
|
58
|
+
- Create a `@macrostrat/scoped-store` library:
|
|
59
|
+
[f1bb8214](https://github.com/UW-Macrostrat/web-components/commit/f1bb8214b97668a4c4107d1d6faceb648f91f2b4)
|
|
60
|
+
- Move Jotai scope and enhancements to a separate package (formerly part of
|
|
61
|
+
`@macrostrat/data-components`).
|
|
62
|
+
- Add extensions for Zustand coordination (`ZustandStoreProvider`,
|
|
63
|
+
`useZustandSelector`, `useZustandStoreAPI`).
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Graceful degradation on load errors. A failed `fetchData` (e.g. the whole
|
|
68
|
+
PostgREST route returning 401) was caught but never surfaced — the panel sat
|
|
69
|
+
blank. Now the load error flows through `tableFooterAtom` /
|
|
70
|
+
`useLoadControls().error`; `LoadProgressIndicator` shows a compact error chip,
|
|
71
|
+
and `DataPanel` shows a "Couldn't load data" `NonIdealState` (and a "No
|
|
72
|
+
results" state for a genuinely empty result) instead of a perpetual spinner or
|
|
73
|
+
an empty list.
|
|
74
|
+
[20a49359](https://github.com/UW-Macrostrat/web-components/commit/20a493594c3813c14462dd997f5f58c7ed89f102)
|
|
75
|
+
- Smoother windowed loading (workstream H):
|
|
76
|
+
[83dbc89f](https://github.com/UW-Macrostrat/web-components/commit/83dbc89f269ee462ffd3419268844cc76a1f2653)
|
|
77
|
+
|
|
78
|
+
- **`filterDebounce`** (ms) on `DataSheet` / `DataPanel` — debounces the
|
|
79
|
+
view-state → refetch, so typing in a text filter no longer resets and
|
|
80
|
+
refetches on every keystroke. The input (and store) stay instant; only the
|
|
81
|
+
fetch waits for the view to settle. Scroll paging is unaffected. Default `0`
|
|
82
|
+
keeps immediate refetching.
|
|
83
|
+
- **`DataPanel` skeleton rows** — the panel used to _skip_ the loader's `null`
|
|
84
|
+
placeholder rows, so a view change flashed the list blank while the sheet
|
|
85
|
+
showed skeletons. It now renders bounded shimmer cards where the loading
|
|
86
|
+
page's rows will land (on a view change and on the next scroll page), so the
|
|
87
|
+
body height stays stable — no blank flash, no footer pinging up into the
|
|
88
|
+
scroll flow. The end region also holds a constant min-height.
|
|
89
|
+
- **No empty-state flash** — `useLoadControls()` now exposes `initialized`;
|
|
90
|
+
the "No results" state shows only after a fetch settles empty, not during
|
|
91
|
+
the reset→fetch gap.
|
|
92
|
+
|
|
93
|
+
- Toolbar + filter presentation:
|
|
94
|
+
[20a49359](https://github.com/UW-Macrostrat/web-components/commit/20a493594c3813c14462dd997f5f58c7ed89f102)
|
|
95
|
+
|
|
96
|
+
- **`TableFilter.presentation`** (`"menu"` | `"menu-inline"` | `"inline"`) —
|
|
97
|
+
progressive enhancement over the same `filterForm`, choosing where a filter
|
|
98
|
+
surfaces without changing its state/wiring:
|
|
99
|
+
- `"menu"` (default): a menu item whose submenu holds the form (today's
|
|
100
|
+
behavior).
|
|
101
|
+
- `"menu-inline"`: the form renders directly in the Filter menu (no submenu)
|
|
102
|
+
— for compact controls like a segmented picker.
|
|
103
|
+
- `"inline"`: the form renders as an always-visible toolbar control (no
|
|
104
|
+
menu) — for a common always-on control like a text search.
|
|
105
|
+
- **`DataPanel` now surfaces the table-level `filters` prop** (previously
|
|
106
|
+
dropped), splitting them by `presentation` — inline filters become
|
|
107
|
+
always-visible toolbar controls, the rest join the "Filter" menu.
|
|
108
|
+
Column-declared filters are unchanged (default `"menu"`).
|
|
109
|
+
- New exports: **`InlineFilterControl`** (renders any filter's `filterForm`
|
|
110
|
+
inline, wired to the shared filter state) and **`MenuInlineFilterItem`**
|
|
111
|
+
(renders a filter's form directly in a menu).
|
|
112
|
+
- Action buttons (`RunActionButton` + the details-form trigger) render
|
|
113
|
+
`minimal` + `small`, matching the toolbar's other controls; and
|
|
114
|
+
`ActionsToolbar` renders when given custom `children` even with no
|
|
115
|
+
displayable actions.
|
|
116
|
+
- **`DataPanel` title** is now `compact`: it renders only when modal selection
|
|
117
|
+
is toggle-able (or a selection is active), since the title doubles as the
|
|
118
|
+
modal-selection control — no bare label when selection is off.
|
|
119
|
+
- **Flat sort menu** — `ColumnSortMenu` is a single item (no
|
|
120
|
+
Ascending/Descending submenu): direction shows as an icon, an active sort
|
|
121
|
+
reads through the `primary` intent, clicking toggles the direction, and a
|
|
122
|
+
right-aligned ✕ clears it.
|
|
123
|
+
- **Explicit empty `columnSpec` is respected** — an explicitly-passed spec
|
|
124
|
+
(function or array, _including `[]`_) now suppresses the loader's
|
|
125
|
+
first-chunk auto-generation. `columnSpec: []` means "no facet columns" (e.g.
|
|
126
|
+
a browse panel whose only control is a sheet-level filter), not "generate
|
|
127
|
+
from the data". Auto-gen still runs when no `columnSpec` is passed.
|
|
128
|
+
|
|
129
|
+
- Updated dependencies
|
|
130
|
+
[f1bb8214](https://github.com/UW-Macrostrat/web-components/commit/f1bb8214b97668a4c4107d1d6faceb648f91f2b4)
|
|
131
|
+
- Updated dependencies
|
|
132
|
+
[155a855c](https://github.com/UW-Macrostrat/web-components/commit/155a855c2bf99d6f218735616724ab6f5a362590)
|
|
133
|
+
- @macrostrat/scoped-store@1.0.0
|
|
134
|
+
- @macrostrat/data-components@1.3.0
|
|
135
|
+
- @macrostrat/ui-components@5.1.0
|
|
136
|
+
|
|
3
137
|
## [4.2.1] - 2026-07-21 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v4.2.0...@macrostrat/data-sheet-v4.2.1)
|
|
4
138
|
|
|
5
139
|
### Patch Changes
|
package/dist/actions/types.d.ts
CHANGED
|
@@ -37,7 +37,17 @@ export interface TableFilter<T = any, S = any> {
|
|
|
37
37
|
/** Row predicate: return `true` if the row should be visible.
|
|
38
38
|
* Receives the merged row (updatedData overlaid on data). */
|
|
39
39
|
predicate(row: T, state: S): boolean;
|
|
40
|
+
/** How this filter surfaces in the UI — progressive enhancement over the
|
|
41
|
+
* same `filterForm`:
|
|
42
|
+
* - `"menu"` (default): a menu item whose submenu holds the form.
|
|
43
|
+
* - `"menu-inline"`: the form renders directly in the filter menu (no
|
|
44
|
+
* submenu) — good for a compact control like a segmented picker.
|
|
45
|
+
* - `"inline"`: the form renders as an always-visible toolbar control (no
|
|
46
|
+
* menu) — good for a common, always-on control like a text search.
|
|
47
|
+
* The state/wiring is identical in every case; only placement changes. */
|
|
48
|
+
presentation?: FilterPresentation;
|
|
40
49
|
}
|
|
50
|
+
export type FilterPresentation = "menu" | "menu-inline" | "inline";
|
|
41
51
|
export interface ColumnFilter<T = any, S = any> extends Omit<TableFilter<T, S>, "columnKey"> {
|
|
42
52
|
columnKey: string;
|
|
43
53
|
}
|
|
@@ -17,6 +17,12 @@ function resolveColumnFilter(col) {
|
|
|
17
17
|
if (rich != null) return { ...rich, columnKey: rich.columnKey ?? col.key };
|
|
18
18
|
return columnFilter.buildMultiOperatorColumnFilter(col);
|
|
19
19
|
}
|
|
20
|
+
function InlineFilterControl({ filter }) {
|
|
21
|
+
const [state, setState] = useFilterAtom(filter);
|
|
22
|
+
const Form = filter.filterForm;
|
|
23
|
+
if (Form == null) return null;
|
|
24
|
+
return filterAndSort_module.default(Form, { state: state ?? filter.defaultState, setState });
|
|
25
|
+
}
|
|
20
26
|
function ColumnFilterControl({ col }) {
|
|
21
27
|
const filter = react.useMemo(() => resolveColumnFilter(col), [col]);
|
|
22
28
|
return filterAndSort_module.default(FilterIndicator, {
|
|
@@ -63,19 +69,29 @@ function FilterIndicator({
|
|
|
63
69
|
)
|
|
64
70
|
);
|
|
65
71
|
}
|
|
66
|
-
function MenuDropdown({ children, content,
|
|
72
|
+
function MenuDropdown({ children, content, ...props }) {
|
|
67
73
|
return filterAndSort_module.default(
|
|
68
74
|
core.PopoverNext,
|
|
69
75
|
{
|
|
70
76
|
content,
|
|
71
77
|
placement: "bottom-start",
|
|
72
|
-
enforceFocus:
|
|
78
|
+
enforceFocus: false,
|
|
73
79
|
autoFocus: false,
|
|
74
|
-
arrow: false
|
|
80
|
+
arrow: false,
|
|
81
|
+
...props
|
|
75
82
|
},
|
|
76
83
|
children
|
|
77
84
|
);
|
|
78
85
|
}
|
|
86
|
+
function MenuFormItem({
|
|
87
|
+
title,
|
|
88
|
+
children
|
|
89
|
+
}) {
|
|
90
|
+
return filterAndSort_module.default("li.menu-form-item", [
|
|
91
|
+
filterAndSort_module.default.if(title != null)(core.MenuDivider, { title }),
|
|
92
|
+
filterAndSort_module.default("div.menu-form-body", children)
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
79
95
|
function buildFilterTagLabel(filter, valueText, {
|
|
80
96
|
minimal,
|
|
81
97
|
showSubject,
|
|
@@ -131,6 +147,18 @@ function ColumnFilterMenuItem({
|
|
|
131
147
|
filterForm
|
|
132
148
|
);
|
|
133
149
|
}
|
|
150
|
+
function MenuInlineFilterItem({
|
|
151
|
+
filter,
|
|
152
|
+
label
|
|
153
|
+
}) {
|
|
154
|
+
const { filterForm, valueText } = useFilterProps(filter);
|
|
155
|
+
return filterAndSort_module.default("li.menu-inline-filter", [
|
|
156
|
+
filterAndSort_module.default(core.MenuDivider, { title: label ?? filter.name }),
|
|
157
|
+
filterAndSort_module.default("div.menu-inline-filter-body", { "data-filter-value": valueText }, [
|
|
158
|
+
filterForm
|
|
159
|
+
])
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
134
162
|
function useFilterProps(filter) {
|
|
135
163
|
const [state, setState] = useFilterAtom(filter);
|
|
136
164
|
const onRemove = react.useCallback(
|
|
@@ -307,15 +335,36 @@ function ColumnSortIndicator({
|
|
|
307
335
|
}
|
|
308
336
|
function ColumnSortMenu({
|
|
309
337
|
columnKey,
|
|
338
|
+
text,
|
|
310
339
|
defaultLabel
|
|
311
340
|
}) {
|
|
312
341
|
const [sort, setSort] = useSortAtom(columnKey);
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
342
|
+
const isActive = sort != null;
|
|
343
|
+
const icon = sort == null ? "sort" : sort.ascending ? "sort-asc" : "sort-desc";
|
|
344
|
+
const name = text ?? defaultLabel ?? columnKey;
|
|
345
|
+
let clearButton = void 0;
|
|
346
|
+
if (isActive) {
|
|
347
|
+
clearButton = filterAndSort_module.default(core.Button, {
|
|
348
|
+
icon: "cross",
|
|
349
|
+
minimal: true,
|
|
350
|
+
small: true,
|
|
351
|
+
onClick: (e) => {
|
|
352
|
+
e.stopPropagation();
|
|
353
|
+
setSort(null);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return filterAndSort_module.default(core.MenuItem, {
|
|
358
|
+
icon,
|
|
359
|
+
text: name,
|
|
360
|
+
intent: isActive ? "primary" : void 0,
|
|
361
|
+
active: isActive,
|
|
362
|
+
labelElement: clearButton,
|
|
363
|
+
shouldDismissPopover: false,
|
|
364
|
+
// Toggle direction; `setSort` never receives the current direction (so its
|
|
365
|
+
// click-same-to-clear path doesn't fire) — clearing is the ✕'s job.
|
|
366
|
+
onClick: () => setSort(sort == null ? true : !sort.ascending)
|
|
367
|
+
});
|
|
319
368
|
}
|
|
320
369
|
const setFilterAtom = jotai.atom(null, (get, set, filter, next) => {
|
|
321
370
|
const store = get(core$1.storeAtom);
|
|
@@ -373,6 +422,9 @@ exports.ColumnFilterMenuItem = ColumnFilterMenuItem;
|
|
|
373
422
|
exports.ColumnSortIndicator = ColumnSortIndicator;
|
|
374
423
|
exports.ColumnSortMenu = ColumnSortMenu;
|
|
375
424
|
exports.FilterIndicator = FilterIndicator;
|
|
425
|
+
exports.InlineFilterControl = InlineFilterControl;
|
|
376
426
|
exports.MenuDropdown = MenuDropdown;
|
|
427
|
+
exports.MenuFormItem = MenuFormItem;
|
|
428
|
+
exports.MenuInlineFilterItem = MenuInlineFilterItem;
|
|
377
429
|
exports.resolveColumnFilter = resolveColumnFilter;
|
|
378
430
|
//# sourceMappingURL=filter-and-sort.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-and-sort.cjs","sources":["../../../src/components/indicators/filter-and-sort.ts"],"sourcesContent":["import type { ColumnSpec } from \"../../provider\";\nimport { ReactNode, useCallback, useMemo, useState } from \"react\";\nimport {\n buildMultiOperatorColumnFilter,\n ColumnFilterState,\n type TableFilter,\n} from \"../../actions\";\nimport { ColumnSort, ctx, storeAtom } from \"../../provider\";\nimport {\n Button,\n HTMLSelect,\n InputGroup,\n Menu,\n MenuItem,\n PopoverNext,\n Tag,\n} from \"@blueprintjs/core\";\nimport { FilterOperator, OPERATOR_LABELS } from \"../../filters/operators\";\nimport classNames from \"classnames\";\nimport { atom } from \"jotai\";\nimport h from \"./filter-and-sort.module.sass\";\n\n/** The filter for a column: its own rich `TableFilter` (from\n * `col.filters`) when present — so the header matches the top bar and the rich\n * filter is prioritized — else the built-in operator `columnFilter`. */\nexport function resolveColumnFilter(col: ColumnSpec): TableFilter {\n const rich = (col.filters as TableFilter[] | undefined)?.find(\n (f) => (f.columnKey ?? col.key) === col.key,\n );\n if (rich != null) return { ...rich, columnKey: rich.columnKey ?? col.key };\n return buildMultiOperatorColumnFilter(col);\n}\n\n/** Shows an active column filter in the top menu */\nexport function ColumnFilterControl({ col }: { col: ColumnSpec }) {\n // Same `TableFilter` the FilterBar and any provider consume, so the header,\n // the bar, and the query stay in sync (rich filter prioritized).\n const filter = useMemo(() => resolveColumnFilter(col), [col]);\n return h(FilterIndicator, {\n filter,\n large: true,\n minimal: true,\n showSubject: false,\n });\n}\n\nexport function FilterIndicator({\n filter,\n large,\n minimal = false,\n showSubject = true,\n}: {\n filter: TableFilter;\n state: any;\n large?: boolean;\n minimal?: boolean;\n showSubject: boolean;\n}) {\n const props = useFilterProps(filter);\n\n const { valueText, filterForm, icon, intent, isActive, onRemove } = props;\n\n let rightIcon: string | undefined = \"caret-down\";\n if (isActive) {\n rightIcon = undefined;\n }\n\n const label = buildFilterTagLabel(filter, valueText, {\n minimal,\n showSubject,\n isActive,\n });\n\n return h(\n MenuDropdown,\n {\n content: filterForm,\n },\n h(\n Tag,\n {\n minimal: true,\n large,\n icon,\n rightIcon,\n intent,\n onRemove,\n className: classNames(\"filter-tag\", { active: isActive }),\n },\n h(\"span.filter-label\", label),\n ),\n );\n}\n\nexport function MenuDropdown({ children, content, isOpen, ...props }: any) {\n return h(\n PopoverNext,\n {\n content,\n placement: \"bottom-start\",\n enforceFocus: true,\n autoFocus: false,\n arrow: false,\n },\n children,\n );\n}\n\nfunction buildFilterTagLabel(\n filter: TableFilter,\n valueText: ReactNode | null,\n {\n minimal,\n showSubject,\n isActive,\n }: { minimal: boolean; showSubject: boolean; isActive: boolean },\n): ReactNode {\n let name = filter.name;\n if (!showSubject) {\n name = \"Filter\";\n }\n\n let _showColumnKey = showSubject ?? !minimal;\n let columnKeyEl: ReactNode = null;\n const subj = filter.subject ?? filter.columnKey;\n if (_showColumnKey && subj != null) {\n columnKeyEl = h([h(\"span.subject\", subj), h(\"span.sep\", \" \")]);\n }\n\n const showOperator = (!minimal || !isActive) && name != subj;\n let operatorEl: ReactNode = null;\n if (showOperator) {\n operatorEl = h([h(\"span.operator\", name), h(\"span.sep\", \": \")]);\n }\n\n let filterWindow: ReactNode = null;\n if (valueText != null && valueText != \"\") {\n filterWindow = h(\"span.filter-value\", valueText);\n }\n\n return h([columnKeyEl, operatorEl, filterWindow]);\n}\n\n/** Every filter applicable to a column: its rich `col.filters` (there may be\n * several) plus the built-in operator `columnFilter` when the column is\n * `filterable` and no rich filter already targets it. The menu lists all of\n * them; the toolbar's `render` collapses to `resolveColumnFilter` (a single\n * control). */\nfunction applicableColumnFilters(col: ColumnSpec): TableFilter[] {\n const result: TableFilter[] = [];\n const rich = (col.filters as TableFilter[] | undefined) ?? [];\n for (const f of rich) {\n result.push({ ...f, columnKey: f.columnKey ?? col.key });\n }\n const hasOwnColumnFilter = result.some((r) => r.columnKey === col.key);\n if (\n (col.filterable === true || typeof col.filterable === \"object\") &&\n !hasOwnColumnFilter\n ) {\n result.push(buildMultiOperatorColumnFilter(col));\n }\n return result;\n}\n\n/** One filter, as a menu item whose submenu carries its edit form. Active\n * filters get a warning intent and show their `describeState` summary. The\n * displayed `label` may differ from `filter.name` (e.g. the built-in operator\n * filter reads \"Filter\" in a column's own menu, where the column is implicit). */\nexport function ColumnFilterMenuItem({\n filter,\n label,\n}: {\n filter: TableFilter;\n label: string;\n}) {\n const { filterForm, icon, intent, valueText } = useFilterProps(filter);\n return h(\n MenuItem,\n {\n icon,\n text: label,\n label: valueText,\n intent,\n shouldDismissPopover: false,\n },\n filterForm,\n );\n}\n\nfunction useFilterProps(filter: TableFilter) {\n const [state, setState] = useFilterAtom(filter);\n\n const onRemove = useCallback(\n (event) => {\n setState(null);\n event.stopPropagation();\n },\n [setState],\n );\n\n const isActive = state != null;\n let summary: ReactNode = null;\n let label: ReactNode = filter.name ?? \"Filter\";\n if (isActive) {\n summary = filter.describeState?.(state);\n label = summary ?? filter.name;\n if (summary == \"\") summary = null;\n if (summary != null) {\n label = h([filter.name, h(\"span.filter-window\", [\": \", summary])]);\n }\n }\n\n let filterForm: ReactNode = null;\n if (filter.filterForm != null) {\n filterForm = h(\n \"div.filter-form-container\",\n h(filter.filterForm, {\n state: state ?? filter.defaultState,\n setState,\n }),\n );\n }\n\n return {\n filterForm,\n label,\n icon: filter.icon ?? \"filter\",\n intent: isActive ? \"primary\" : \"none\",\n isActive,\n nameText: filter.name,\n valueText: summary,\n onRemove: isActive ? onRemove : undefined,\n };\n}\n\n/** Menu-native filter: one item per applicable filter, each opening its form\n * in a submenu. */\nexport function ColumnFilterMenu({ col }: { col: ColumnSpec }) {\n const filters = useMemo(() => applicableColumnFilters(col), [col]);\n return h(\n filters.map((f) =>\n h(ColumnFilterMenuItem, {\n key: f.id,\n filter: f,\n // The generic operator filter is just \"Filter\" in its own column's\n // menu; rich (user-provided) filters keep their descriptive names.\n label: f.columnKey === col.key ? \"Filter\" : f.name,\n }),\n ),\n );\n}\n\nexport function ColumnFilterForm({\n operators,\n state,\n setState,\n}: {\n operators: FilterOperator[];\n state: ColumnFilterState;\n setState: (s: ColumnFilterState) => void;\n}) {\n // Operator and value are held locally, seeded once from the incoming state.\n // The operator must be local: committing it with an empty value clears the\n // filter (so the store round-trips back to the default state), which would\n // otherwise snap the dropdown back to the default — the operator wouldn't\n // \"stick\" until a value was typed. The value commits (triggering a server\n // re-fetch) on blur / Enter, not on every keystroke.\n const [op, setOp] = useState<FilterOperator>(state?.operator ?? operators[0]);\n const [val, setVal] = useState<string>(state?.value ?? \"\");\n\n const commit = (nextOp: FilterOperator, nextVal: string) =>\n setState({ operator: nextOp, value: nextVal });\n\n const clear = () => {\n setVal(\"\");\n commit(op, \"\");\n };\n\n return h(\"div.column-filter-form\", [\n // Compact header: title + operator on one row (with a clear ✕ when set),\n // value on the next — space-efficient and full-width for the value.\n h(\"div\", { style: { display: \"flex\", alignItems: \"center\", gap: \"6px\" } }, [\n h(\"span\", { style: { fontWeight: 600 } }, \"Filter\"),\n h(HTMLSelect, {\n small: true,\n value: op,\n options: operators.map((o) => ({\n value: o,\n label: OPERATOR_LABELS[o] ?? o,\n })),\n onChange: (e) => {\n const nextOp = e.currentTarget.value as FilterOperator;\n setOp(nextOp);\n commit(nextOp, val);\n },\n }),\n h(\"div\", { style: { flex: 1 } }),\n h.if(val !== \"\")(Button, {\n small: true,\n minimal: true,\n icon: \"cross\",\n \"aria-label\": \"Clear filter\",\n onClick: clear,\n }),\n ]),\n h(InputGroup, {\n small: true,\n fill: true,\n value: val,\n placeholder: \"value\",\n autoFocus: true,\n onChange: (e) => setVal(e.target.value),\n onBlur: () => commit(op, val),\n onKeyDown: (e) => {\n if (e.key === \"Enter\") commit(op, val);\n },\n }),\n ]);\n}\n\nfunction ColumnSortActions({ sort, setSort }) {\n return h([\n h(MenuItem, {\n key: \"asc\",\n text: \"Ascending\",\n icon: \"sort-asc\",\n active: sort?.ascending === true,\n onClick: () => setSort(true),\n shouldDismissPopover: false,\n }),\n h(MenuItem, {\n key: \"desc\",\n text: \"Descending\",\n icon: \"sort-desc\",\n active: sort?.ascending === false,\n onClick: () => setSort(false),\n shouldDismissPopover: false,\n }),\n ]);\n}\n\nfunction displayParamsForSort(sort: ColumnSort | undefined) {\n const icon =\n sort == null ? \"sort\" : sort.ascending ? \"sort-asc\" : \"sort-desc\";\n const label =\n sort == null ? null : sort.ascending ? \"Ascending\" : \"Descending\";\n\n let intent = \"none\";\n if (sort != null) {\n intent = \"primary\";\n }\n\n return { icon, label, intent };\n}\n\nexport function ColumnSortIndicator({\n columnKey,\n showColumnKey,\n small,\n large,\n}: {\n showColumnKey: string;\n columnKey: string;\n small?: boolean;\n large?: boolean;\n}) {\n const [sort, setSort] = useSortAtom(columnKey);\n const { icon, label, intent } = displayParamsForSort(sort);\n\n const columnLabel = showColumnKey ? `${columnKey}: ` : \"\";\n let onRemove: any = undefined;\n let rightIcon: string | undefined = \"caret-down\";\n if (sort != null) {\n rightIcon = undefined;\n onRemove = () => setSort(null);\n }\n\n let valLabel = label;\n valLabel ??= showColumnKey ? columnKey : \"Sort\";\n\n return h(\n MenuDropdown,\n {\n content: h(Menu, h(ColumnSortActions, { sort, setSort })),\n },\n h(\n Tag,\n {\n small,\n large,\n minimal: true,\n icon,\n rightIcon,\n intent,\n onRemove,\n },\n h([columnLabel, valLabel]),\n ),\n );\n}\n\n/** Menu-native sort: a \"Sort\" item whose submenu holds Ascending / Descending.\n * Clicking the *active* direction again clears the sort (toggle off) — there's\n * no explicit \"Clear\" item, since the active-filter/sort tag in the status bar\n * already offers direct removal. `text` overrides the parent item's label (the\n * `DataPanel` uses the column name, so its Sort menu lists one item per field). */\nexport function ColumnSortMenu({\n columnKey,\n defaultLabel,\n}: {\n columnKey: string;\n text?: string;\n defaultLabel?: string;\n}) {\n const [sort, setSort] = useSortAtom(columnKey);\n const { icon, label, intent } = displayParamsForSort(sort);\n return h(\n MenuItem,\n { icon, text: label ?? defaultLabel ?? columnKey, intent },\n h(ColumnSortActions, { sort, setSort }),\n );\n}\n\nconst setFilterAtom = atom(null, (get, set, filter: TableFilter, next: any) => {\n const store = get(storeAtom);\n if (store == null) return;\n if (next == null || next.value === \"\") {\n store.removeFilter(filter.id);\n } else {\n store.setFilter(filter.id, filter, next);\n }\n});\n\nfunction useFilterAtom(filter: TableFilter) {\n const filterStateAtom = useMemo(\n () =>\n atom(\n (get) => {\n const store = get(storeAtom);\n return store?.activeFilters.get(filter.id)?.state;\n },\n (get, set, next: any) => {\n set(setFilterAtom, filter, next);\n },\n ),\n [filter.id],\n );\n return ctx.use(filterStateAtom);\n}\n\nfunction useSortAtom(columnKey) {\n const sortAtom = useMemo(\n () =>\n atom(\n (get) => {\n return get(storeAtom)?.columnSorts.find((x) => x.key === columnKey);\n },\n (get, set, ascending: boolean | null) => {\n const store = get(storeAtom);\n if (store == null) return;\n const currentVal = store.columnSorts.find(\n (x) => x.key === columnKey,\n )?.ascending;\n let nextVal = ascending;\n if (currentVal != null) {\n if (currentVal == nextVal) {\n // Unset\n nextVal = null;\n }\n }\n\n store.setColumnSort(columnKey, nextVal);\n },\n ),\n [columnKey],\n );\n return ctx.use(sortAtom);\n}\n"],"names":["buildMultiOperatorColumnFilter","useMemo","h","Tag","classNames","PopoverNext","MenuItem","useCallback","operators","useState","HTMLSelect","OPERATOR_LABELS","Button","InputGroup","Menu","atom","storeAtom","ctx"],"mappings":";;;;;;;;;;;;AAyBO,SAAS,oBAAoB,KAA8B;AAChE,QAAM,OAAQ,IAAI,SAAuC;AAAA,IACvD,CAAC,OAAO,EAAE,aAAa,IAAI,SAAS,IAAI;AAAA,EAAA;AAE1C,MAAI,QAAQ,KAAM,QAAO,EAAE,GAAG,MAAM,WAAW,KAAK,aAAa,IAAI,IAAA;AACrE,SAAOA,aAAAA,+BAA+B,GAAG;AAC3C;AAGO,SAAS,oBAAoB,EAAE,OAA4B;AAGhE,QAAM,SAASC,MAAAA,QAAQ,MAAM,oBAAoB,GAAG,GAAG,CAAC,GAAG,CAAC;AAC5D,S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L,UAAM,UAAU,OAAO,IAAI,QAAQ,IAAI;AAAA,EACzC;AACF,CAAC;AAED,SAAS,cAAc,QAAqB;AAC1C,QAAM,kBAAkBf,MAAAA;AAAAA,IACtB,MACEc,MAAAA;AAAAA,MACE,CAAC,QAAQ;AACP,cAAM,QAAQ,IAAIC,gBAAS;AAC3B,eAAO,OAAO,cAAc,IAAI,OAAO,EAAE,GAAG;AAAA,MAC9C;AAAA,MACA,CAAC,KAAK,KAAK,SAAc;AACvB,YAAI,eAAe,QAAQ,IAAI;AAAA,MACjC;AAAA,IAAA;AAAA,IAEJ,CAAC,OAAO,EAAE;AAAA,EAAA;AAEZ,SAAOC,OAAAA,IAAI,IAAI,eAAe;AAChC;AAEA,SAAS,YAAY,WAAW;AAC9B,QAAM,WAAWhB,MAAAA;AAAAA,IACf,MACEc,MAAAA;AAAAA,MACE,CAAC,QAAQ;AACP,eAAO,IAAIC,gBAAS,GAAG,YAAY,KAAK,CAAC,MAAM,EAAE,QAAQ,SAAS;AAAA,MACpE;AAAA,MACA,CAAC,KAAK,KAAK,cAA8B;AACvC,cAAM,QAAQ,IAAIA,gBAAS;AAC3B,YAAI,SAAS,KAAM;AACnB,cAAM,aAAa,MAAM,YAAY;AAAA,UACnC,CAAC,MAAM,EAAE,QAAQ;AAAA,QAAA,GAChB;AACH,YAAI,UAAU;AACd,YAAI,cAAc,MAAM;AACtB,cAAI,cAAc,SAAS;AAEzB,sBAAU;AAAA,UACZ;AAAA,QACF;AAEA,cAAM,cAAc,WAAW,OAAO;AAAA,MACxC;AAAA,IAAA;AAAA,IAEJ,CAAC,SAAS;AAAA,EAAA;AAEZ,SAAOC,OAAAA,IAAI,IAAI,QAAQ;AACzB;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"filter-and-sort.cjs","sources":["../../../src/components/indicators/filter-and-sort.ts"],"sourcesContent":["import type { ColumnSpec } from \"../../provider\";\nimport { ReactNode, useCallback, useMemo, useState } from \"react\";\nimport {\n buildMultiOperatorColumnFilter,\n ColumnFilterState,\n type TableFilter,\n} from \"../../actions\";\nimport { ColumnSort, ctx, storeAtom } from \"../../provider\";\nimport {\n Button,\n HTMLSelect,\n InputGroup,\n Menu,\n MenuDivider,\n MenuItem,\n PopoverNext,\n Tag,\n} from \"@blueprintjs/core\";\nimport { FilterOperator, OPERATOR_LABELS } from \"../../filters/operators\";\nimport classNames from \"classnames\";\nimport { atom } from \"jotai\";\nimport h from \"./filter-and-sort.module.sass\";\n\n/** The filter for a column: its own rich `TableFilter` (from\n * `col.filters`) when present — so the header matches the top bar and the rich\n * filter is prioritized — else the built-in operator `columnFilter`. */\nexport function resolveColumnFilter(col: ColumnSpec): TableFilter {\n const rich = (col.filters as TableFilter[] | undefined)?.find(\n (f) => (f.columnKey ?? col.key) === col.key,\n );\n if (rich != null) return { ...rich, columnKey: rich.columnKey ?? col.key };\n return buildMultiOperatorColumnFilter(col);\n}\n\n/**\n * Render a filter's `filterForm` as an always-visible inline control — rather\n * than behind a menu dropdown — wired to the shared filter state. Lets any\n * `TableFilter` (e.g. an open text search spanning several columns) live\n * directly in a toolbar while still flowing through the standard filter model:\n * store `activeFilters` → the provider's `translateFilter`, identical to the\n * menu-driven controls. The form clears the filter when its state goes empty\n * (`state.value === \"\"`), matching the rest of the filter UI.\n */\nexport function InlineFilterControl({ filter }: { filter: TableFilter }) {\n const [state, setState] = useFilterAtom(filter);\n const Form = filter.filterForm;\n if (Form == null) return null;\n return h(Form, { state: state ?? filter.defaultState, setState });\n}\n\n/** Shows an active column filter in the top menu */\nexport function ColumnFilterControl({ col }: { col: ColumnSpec }) {\n // Same `TableFilter` the FilterBar and any provider consume, so the header,\n // the bar, and the query stay in sync (rich filter prioritized).\n const filter = useMemo(() => resolveColumnFilter(col), [col]);\n return h(FilterIndicator, {\n filter,\n large: true,\n minimal: true,\n showSubject: false,\n });\n}\n\nexport function FilterIndicator({\n filter,\n large,\n minimal = false,\n showSubject = true,\n}: {\n filter: TableFilter;\n state: any;\n large?: boolean;\n minimal?: boolean;\n showSubject: boolean;\n}) {\n const props = useFilterProps(filter);\n\n const { valueText, filterForm, icon, intent, isActive, onRemove } = props;\n\n let rightIcon: string | undefined = \"caret-down\";\n if (isActive) {\n rightIcon = undefined;\n }\n\n const label = buildFilterTagLabel(filter, valueText, {\n minimal,\n showSubject,\n isActive,\n });\n\n return h(\n MenuDropdown,\n {\n content: filterForm,\n },\n h(\n Tag,\n {\n minimal: true,\n large,\n icon,\n rightIcon,\n intent,\n onRemove,\n className: classNames(\"filter-tag\", { active: isActive }),\n },\n h(\"span.filter-label\", label),\n ),\n );\n}\n\n/**\n * A dropdown for a panel of controls (not just menu items).\n *\n * Deliberately **not** focus-trapping. These panels hold real form controls,\n * and a control whose own typeahead renders in a separate portal (a\n * `MultiSelect`, a date picker) has focus yanked back out of it by an enclosing\n * trap — which is what makes a nested filter submenu feel unstable. Caller\n * props are passed through (`placement`, `isOpen`, …).\n */\nexport function MenuDropdown({ children, content, ...props }: any) {\n return h(\n PopoverNext,\n {\n content,\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n arrow: false,\n ...props,\n },\n children,\n );\n}\n\n/**\n * A titled block *inside* a menu holding an arbitrary form, rather than a menu\n * item that opens a submenu — one click away instead of two, with no nested\n * popover to lose focus to. The building block behind `MenuInlineFilterItem`,\n * exported so a custom control panel can use the same idiom.\n */\nexport function MenuFormItem({\n title,\n children,\n}: {\n title?: ReactNode;\n children: ReactNode;\n}) {\n return h(\"li.menu-form-item\", [\n h.if(title != null)(MenuDivider, { title }),\n h(\"div.menu-form-body\", children),\n ]);\n}\n\nfunction buildFilterTagLabel(\n filter: TableFilter,\n valueText: ReactNode | null,\n {\n minimal,\n showSubject,\n isActive,\n }: { minimal: boolean; showSubject: boolean; isActive: boolean },\n): ReactNode {\n let name = filter.name;\n if (!showSubject) {\n name = \"Filter\";\n }\n\n let _showColumnKey = showSubject ?? !minimal;\n let columnKeyEl: ReactNode = null;\n const subj = filter.subject ?? filter.columnKey;\n if (_showColumnKey && subj != null) {\n columnKeyEl = h([h(\"span.subject\", subj), h(\"span.sep\", \" \")]);\n }\n\n const showOperator = (!minimal || !isActive) && name != subj;\n let operatorEl: ReactNode = null;\n if (showOperator) {\n operatorEl = h([h(\"span.operator\", name), h(\"span.sep\", \": \")]);\n }\n\n let filterWindow: ReactNode = null;\n if (valueText != null && valueText != \"\") {\n filterWindow = h(\"span.filter-value\", valueText);\n }\n\n return h([columnKeyEl, operatorEl, filterWindow]);\n}\n\n/** Every filter applicable to a column: its rich `col.filters` (there may be\n * several) plus the built-in operator `columnFilter` when the column is\n * `filterable` and no rich filter already targets it. The menu lists all of\n * them; the toolbar's `render` collapses to `resolveColumnFilter` (a single\n * control). */\nfunction applicableColumnFilters(col: ColumnSpec): TableFilter[] {\n const result: TableFilter[] = [];\n const rich = (col.filters as TableFilter[] | undefined) ?? [];\n for (const f of rich) {\n result.push({ ...f, columnKey: f.columnKey ?? col.key });\n }\n const hasOwnColumnFilter = result.some((r) => r.columnKey === col.key);\n if (\n (col.filterable === true || typeof col.filterable === \"object\") &&\n !hasOwnColumnFilter\n ) {\n result.push(buildMultiOperatorColumnFilter(col));\n }\n return result;\n}\n\n/** One filter, as a menu item whose submenu carries its edit form. Active\n * filters get a warning intent and show their `describeState` summary. The\n * displayed `label` may differ from `filter.name` (e.g. the built-in operator\n * filter reads \"Filter\" in a column's own menu, where the column is implicit). */\nexport function ColumnFilterMenuItem({\n filter,\n label,\n}: {\n filter: TableFilter;\n label: string;\n}) {\n const { filterForm, icon, intent, valueText } = useFilterProps(filter);\n return h(\n MenuItem,\n {\n icon,\n text: label,\n label: valueText,\n intent,\n shouldDismissPopover: false,\n },\n filterForm,\n );\n}\n\n/** A filter rendered *inside* a menu but without a submenu — its name as a\n * section header, its form directly below. For `presentation: \"menu-inline\"`\n * (e.g. a compact segmented control that doesn't warrant a submenu hop). */\nexport function MenuInlineFilterItem({\n filter,\n label,\n}: {\n filter: TableFilter;\n label?: string;\n}) {\n const { filterForm, valueText } = useFilterProps(filter);\n return h(\"li.menu-inline-filter\", [\n h(MenuDivider, { title: label ?? filter.name }),\n h(\"div.menu-inline-filter-body\", { \"data-filter-value\": valueText }, [\n filterForm,\n ]),\n ]);\n}\n\nfunction useFilterProps(filter: TableFilter) {\n const [state, setState] = useFilterAtom(filter);\n\n const onRemove = useCallback(\n (event) => {\n setState(null);\n event.stopPropagation();\n },\n [setState],\n );\n\n const isActive = state != null;\n let summary: ReactNode = null;\n let label: ReactNode = filter.name ?? \"Filter\";\n if (isActive) {\n summary = filter.describeState?.(state);\n label = summary ?? filter.name;\n if (summary == \"\") summary = null;\n if (summary != null) {\n label = h([filter.name, h(\"span.filter-window\", [\": \", summary])]);\n }\n }\n\n let filterForm: ReactNode = null;\n if (filter.filterForm != null) {\n filterForm = h(\n \"div.filter-form-container\",\n h(filter.filterForm, {\n state: state ?? filter.defaultState,\n setState,\n }),\n );\n }\n\n return {\n filterForm,\n label,\n icon: filter.icon ?? \"filter\",\n intent: isActive ? \"primary\" : \"none\",\n isActive,\n nameText: filter.name,\n valueText: summary,\n onRemove: isActive ? onRemove : undefined,\n };\n}\n\n/** Menu-native filter: one item per applicable filter, each opening its form\n * in a submenu. */\nexport function ColumnFilterMenu({ col }: { col: ColumnSpec }) {\n const filters = useMemo(() => applicableColumnFilters(col), [col]);\n return h(\n filters.map((f) =>\n h(ColumnFilterMenuItem, {\n key: f.id,\n filter: f,\n // The generic operator filter is just \"Filter\" in its own column's\n // menu; rich (user-provided) filters keep their descriptive names.\n label: f.columnKey === col.key ? \"Filter\" : f.name,\n }),\n ),\n );\n}\n\nexport function ColumnFilterForm({\n operators,\n state,\n setState,\n}: {\n operators: FilterOperator[];\n state: ColumnFilterState;\n setState: (s: ColumnFilterState) => void;\n}) {\n // Operator and value are held locally, seeded once from the incoming state.\n // The operator must be local: committing it with an empty value clears the\n // filter (so the store round-trips back to the default state), which would\n // otherwise snap the dropdown back to the default — the operator wouldn't\n // \"stick\" until a value was typed. The value commits (triggering a server\n // re-fetch) on blur / Enter, not on every keystroke.\n const [op, setOp] = useState<FilterOperator>(state?.operator ?? operators[0]);\n const [val, setVal] = useState<string>(state?.value ?? \"\");\n\n const commit = (nextOp: FilterOperator, nextVal: string) =>\n setState({ operator: nextOp, value: nextVal });\n\n const clear = () => {\n setVal(\"\");\n commit(op, \"\");\n };\n\n return h(\"div.column-filter-form\", [\n // Compact header: title + operator on one row (with a clear ✕ when set),\n // value on the next — space-efficient and full-width for the value.\n h(\"div\", { style: { display: \"flex\", alignItems: \"center\", gap: \"6px\" } }, [\n h(\"span\", { style: { fontWeight: 600 } }, \"Filter\"),\n h(HTMLSelect, {\n small: true,\n value: op,\n options: operators.map((o) => ({\n value: o,\n label: OPERATOR_LABELS[o] ?? o,\n })),\n onChange: (e) => {\n const nextOp = e.currentTarget.value as FilterOperator;\n setOp(nextOp);\n commit(nextOp, val);\n },\n }),\n h(\"div\", { style: { flex: 1 } }),\n h.if(val !== \"\")(Button, {\n small: true,\n minimal: true,\n icon: \"cross\",\n \"aria-label\": \"Clear filter\",\n onClick: clear,\n }),\n ]),\n h(InputGroup, {\n small: true,\n fill: true,\n value: val,\n placeholder: \"value\",\n autoFocus: true,\n onChange: (e) => setVal(e.target.value),\n onBlur: () => commit(op, val),\n onKeyDown: (e) => {\n if (e.key === \"Enter\") commit(op, val);\n },\n }),\n ]);\n}\n\nfunction ColumnSortActions({ sort, setSort }) {\n return h([\n h(MenuItem, {\n key: \"asc\",\n text: \"Ascending\",\n icon: \"sort-asc\",\n active: sort?.ascending === true,\n onClick: () => setSort(true),\n shouldDismissPopover: false,\n }),\n h(MenuItem, {\n key: \"desc\",\n text: \"Descending\",\n icon: \"sort-desc\",\n active: sort?.ascending === false,\n onClick: () => setSort(false),\n shouldDismissPopover: false,\n }),\n ]);\n}\n\nfunction displayParamsForSort(sort: ColumnSort | undefined) {\n const icon =\n sort == null ? \"sort\" : sort.ascending ? \"sort-asc\" : \"sort-desc\";\n const label =\n sort == null ? null : sort.ascending ? \"Ascending\" : \"Descending\";\n\n let intent = \"none\";\n if (sort != null) {\n intent = \"primary\";\n }\n\n return { icon, label, intent };\n}\n\nexport function ColumnSortIndicator({\n columnKey,\n showColumnKey,\n small,\n large,\n}: {\n showColumnKey: string;\n columnKey: string;\n small?: boolean;\n large?: boolean;\n}) {\n const [sort, setSort] = useSortAtom(columnKey);\n const { icon, label, intent } = displayParamsForSort(sort);\n\n const columnLabel = showColumnKey ? `${columnKey}: ` : \"\";\n let onRemove: any = undefined;\n let rightIcon: string | undefined = \"caret-down\";\n if (sort != null) {\n rightIcon = undefined;\n onRemove = () => setSort(null);\n }\n\n let valLabel = label;\n valLabel ??= showColumnKey ? columnKey : \"Sort\";\n\n return h(\n MenuDropdown,\n {\n content: h(Menu, h(ColumnSortActions, { sort, setSort })),\n },\n h(\n Tag,\n {\n small,\n large,\n minimal: true,\n icon,\n rightIcon,\n intent,\n onRemove,\n },\n h([columnLabel, valLabel]),\n ),\n );\n}\n\n/** Menu-native sort as a **single, flat** item — no submenu. The item shows the\n * field name with a direction icon (↑/↓); an active sort reads through the\n * `primary` intent, and clicking the item toggles the direction (unsorted →\n * ascending → descending → …). A right-aligned ✕ clears it. `text` is the\n * field's display label (the `DataPanel` lists one item per sortable field). */\nexport function ColumnSortMenu({\n columnKey,\n text,\n defaultLabel,\n}: {\n columnKey: string;\n text?: string;\n defaultLabel?: string;\n}) {\n const [sort, setSort] = useSortAtom(columnKey);\n const isActive = sort != null;\n const icon =\n sort == null ? \"sort\" : sort.ascending ? \"sort-asc\" : \"sort-desc\";\n const name = text ?? defaultLabel ?? columnKey;\n\n let clearButton: ReactNode = undefined;\n if (isActive) {\n clearButton = h(Button, {\n icon: \"cross\",\n minimal: true,\n small: true,\n onClick: (e: any) => {\n e.stopPropagation();\n setSort(null);\n },\n });\n }\n\n return h(MenuItem, {\n icon,\n text: name,\n intent: isActive ? \"primary\" : undefined,\n active: isActive,\n labelElement: clearButton,\n shouldDismissPopover: false,\n // Toggle direction; `setSort` never receives the current direction (so its\n // click-same-to-clear path doesn't fire) — clearing is the ✕'s job.\n onClick: () => setSort(sort == null ? true : !sort.ascending),\n });\n}\n\nconst setFilterAtom = atom(null, (get, set, filter: TableFilter, next: any) => {\n const store = get(storeAtom);\n if (store == null) return;\n if (next == null || next.value === \"\") {\n store.removeFilter(filter.id);\n } else {\n store.setFilter(filter.id, filter, next);\n }\n});\n\nfunction useFilterAtom(filter: TableFilter) {\n const filterStateAtom = useMemo(\n () =>\n atom(\n (get) => {\n const store = get(storeAtom);\n return store?.activeFilters.get(filter.id)?.state;\n },\n (get, set, next: any) => {\n set(setFilterAtom, filter, next);\n },\n ),\n [filter.id],\n );\n return ctx.use(filterStateAtom);\n}\n\nfunction useSortAtom(columnKey) {\n const sortAtom = useMemo(\n () =>\n atom(\n (get) => {\n return get(storeAtom)?.columnSorts.find((x) => x.key === columnKey);\n },\n (get, set, ascending: boolean | null) => {\n const store = get(storeAtom);\n if (store == null) return;\n const currentVal = store.columnSorts.find(\n (x) => x.key === columnKey,\n )?.ascending;\n let nextVal = ascending;\n if (currentVal != null) {\n if (currentVal == nextVal) {\n // Unset\n nextVal = null;\n }\n }\n\n store.setColumnSort(columnKey, nextVal);\n },\n ),\n [columnKey],\n );\n return ctx.use(sortAtom);\n}\n"],"names":["buildMultiOperatorColumnFilter","h","useMemo","Tag","classNames","PopoverNext","MenuDivider","MenuItem","useCallback","operators","useState","HTMLSelect","OPERATOR_LABELS","Button","InputGroup","Menu","atom","storeAtom","ctx"],"mappings":";;;;;;;;;;;;AA0BO,SAAS,oBAAoB,KAA8B;AAChE,QAAM,OAAQ,IAAI,SAAuC;AAAA,IACvD,CAAC,OAAO,EAAE,aAAa,IAAI,SAAS,IAAI;AAAA,EAAA;AAE1C,MAAI,QAAQ,KAAM,QAAO,EAAE,GAAG,MAAM,WAAW,KAAK,aAAa,IAAI,IAAA;AACrE,SAAOA,aAAAA,+BAA+B,GAAG;AAC3C;AAWO,SAAS,oBAAoB,EAAE,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E;AAAA,EAC9B,OAAO;AACL,UAAM,UAAU,OAAO,IAAI,QAAQ,IAAI;AAAA,EACzC;AACF,CAAC;AAED,SAAS,cAAc,QAAqB;AAC1C,QAAM,kBAAkBf,MAAAA;AAAAA,IACtB,MACEc,MAAAA;AAAAA,MACE,CAAC,QAAQ;AACP,cAAM,QAAQ,IAAIC,gBAAS;AAC3B,eAAO,OAAO,cAAc,IAAI,OAAO,EAAE,GAAG;AAAA,MAC9C;AAAA,MACA,CAAC,KAAK,KAAK,SAAc;AACvB,YAAI,eAAe,QAAQ,IAAI;AAAA,MACjC;AAAA,IAAA;AAAA,IAEJ,CAAC,OAAO,EAAE;AAAA,EAAA;AAEZ,SAAOC,OAAAA,IAAI,IAAI,eAAe;AAChC;AAEA,SAAS,YAAY,WAAW;AAC9B,QAAM,WAAWhB,MAAAA;AAAAA,IACf,MACEc,MAAAA;AAAAA,MACE,CAAC,QAAQ;AACP,eAAO,IAAIC,gBAAS,GAAG,YAAY,KAAK,CAAC,MAAM,EAAE,QAAQ,SAAS;AAAA,MACpE;AAAA,MACA,CAAC,KAAK,KAAK,cAA8B;AACvC,cAAM,QAAQ,IAAIA,gBAAS;AAC3B,YAAI,SAAS,KAAM;AACnB,cAAM,aAAa,MAAM,YAAY;AAAA,UACnC,CAAC,MAAM,EAAE,QAAQ;AAAA,QAAA,GAChB;AACH,YAAI,UAAU;AACd,YAAI,cAAc,MAAM;AACtB,cAAI,cAAc,SAAS;AAEzB,sBAAU;AAAA,UACZ;AAAA,QACF;AAEA,cAAM,cAAc,WAAW,OAAO;AAAA,MACxC;AAAA,IAAA;AAAA,IAEJ,CAAC,SAAS;AAAA,EAAA;AAEZ,SAAOC,OAAAA,IAAI,IAAI,QAAQ;AACzB;;;;;;;;;;;;;"}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import { ColumnSpec } from '../../provider';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { ColumnFilterState, TableFilter } from '../../actions';
|
|
3
4
|
import { FilterOperator } from '../../filters/operators';
|
|
4
5
|
/** The filter for a column: its own rich `TableFilter` (from
|
|
5
6
|
* `col.filters`) when present — so the header matches the top bar and the rich
|
|
6
7
|
* filter is prioritized — else the built-in operator `columnFilter`. */
|
|
7
8
|
export declare function resolveColumnFilter(col: ColumnSpec): TableFilter;
|
|
9
|
+
/**
|
|
10
|
+
* Render a filter's `filterForm` as an always-visible inline control — rather
|
|
11
|
+
* than behind a menu dropdown — wired to the shared filter state. Lets any
|
|
12
|
+
* `TableFilter` (e.g. an open text search spanning several columns) live
|
|
13
|
+
* directly in a toolbar while still flowing through the standard filter model:
|
|
14
|
+
* store `activeFilters` → the provider's `translateFilter`, identical to the
|
|
15
|
+
* menu-driven controls. The form clears the filter when its state goes empty
|
|
16
|
+
* (`state.value === ""`), matching the rest of the filter UI.
|
|
17
|
+
*/
|
|
18
|
+
export declare function InlineFilterControl({ filter }: {
|
|
19
|
+
filter: TableFilter;
|
|
20
|
+
}): import('react').ReactElement<{
|
|
21
|
+
state: any;
|
|
22
|
+
setState(state: any): void;
|
|
23
|
+
}, string | import('react').JSXElementConstructor<any>> | null;
|
|
8
24
|
/** Shows an active column filter in the top menu */
|
|
9
25
|
export declare function ColumnFilterControl({ col }: {
|
|
10
26
|
col: ColumnSpec;
|
|
@@ -22,7 +38,26 @@ export declare function FilterIndicator({ filter, large, minimal, showSubject, }
|
|
|
22
38
|
minimal?: boolean;
|
|
23
39
|
showSubject: boolean;
|
|
24
40
|
}): import('react').FunctionComponentElement<any>;
|
|
25
|
-
|
|
41
|
+
/**
|
|
42
|
+
* A dropdown for a panel of controls (not just menu items).
|
|
43
|
+
*
|
|
44
|
+
* Deliberately **not** focus-trapping. These panels hold real form controls,
|
|
45
|
+
* and a control whose own typeahead renders in a separate portal (a
|
|
46
|
+
* `MultiSelect`, a date picker) has focus yanked back out of it by an enclosing
|
|
47
|
+
* trap — which is what makes a nested filter submenu feel unstable. Caller
|
|
48
|
+
* props are passed through (`placement`, `isOpen`, …).
|
|
49
|
+
*/
|
|
50
|
+
export declare function MenuDropdown({ children, content, ...props }: any): import('react').FunctionComponentElement<import('@blueprintjs/core').PopoverNextProps<import('@blueprintjs/core').DefaultPopoverTargetHTMLProps> & import('react').RefAttributes<import('@blueprintjs/core').PopoverNextRef>>;
|
|
51
|
+
/**
|
|
52
|
+
* A titled block *inside* a menu holding an arbitrary form, rather than a menu
|
|
53
|
+
* item that opens a submenu — one click away instead of two, with no nested
|
|
54
|
+
* popover to lose focus to. The building block behind `MenuInlineFilterItem`,
|
|
55
|
+
* exported so a custom control panel can use the same idiom.
|
|
56
|
+
*/
|
|
57
|
+
export declare function MenuFormItem({ title, children, }: {
|
|
58
|
+
title?: ReactNode;
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
}): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
|
|
26
61
|
/** One filter, as a menu item whose submenu carries its edit form. Active
|
|
27
62
|
* filters get a warning intent and show their `describeState` summary. The
|
|
28
63
|
* displayed `label` may differ from `filter.name` (e.g. the built-in operator
|
|
@@ -31,6 +66,13 @@ export declare function ColumnFilterMenuItem({ filter, label, }: {
|
|
|
31
66
|
filter: TableFilter;
|
|
32
67
|
label: string;
|
|
33
68
|
}): import('react').FunctionComponentElement<import('@blueprintjs/core').MenuItemProps>;
|
|
69
|
+
/** A filter rendered *inside* a menu but without a submenu — its name as a
|
|
70
|
+
* section header, its form directly below. For `presentation: "menu-inline"`
|
|
71
|
+
* (e.g. a compact segmented control that doesn't warrant a submenu hop). */
|
|
72
|
+
export declare function MenuInlineFilterItem({ filter, label, }: {
|
|
73
|
+
filter: TableFilter;
|
|
74
|
+
label?: string;
|
|
75
|
+
}): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
|
|
34
76
|
/** Menu-native filter: one item per applicable filter, each opening its form
|
|
35
77
|
* in a submenu. */
|
|
36
78
|
export declare function ColumnFilterMenu({ col }: {
|
|
@@ -47,12 +89,12 @@ export declare function ColumnSortIndicator({ columnKey, showColumnKey, small, l
|
|
|
47
89
|
small?: boolean;
|
|
48
90
|
large?: boolean;
|
|
49
91
|
}): import('react').FunctionComponentElement<any>;
|
|
50
|
-
/** Menu-native sort
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
export declare function ColumnSortMenu({ columnKey, defaultLabel, }: {
|
|
92
|
+
/** Menu-native sort as a **single, flat** item — no submenu. The item shows the
|
|
93
|
+
* field name with a direction icon (↑/↓); an active sort reads through the
|
|
94
|
+
* `primary` intent, and clicking the item toggles the direction (unsorted →
|
|
95
|
+
* ascending → descending → …). A right-aligned ✕ clears it. `text` is the
|
|
96
|
+
* field's display label (the `DataPanel` lists one item per sortable field). */
|
|
97
|
+
export declare function ColumnSortMenu({ columnKey, text, defaultLabel, }: {
|
|
56
98
|
columnKey: string;
|
|
57
99
|
text?: string;
|
|
58
100
|
defaultLabel?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo, useState, useCallback } from "react";
|
|
2
|
-
import { HTMLSelect, Button, InputGroup, MenuItem, Menu, Tag, PopoverNext } from "@blueprintjs/core";
|
|
2
|
+
import { HTMLSelect, Button, InputGroup, MenuItem, Menu, Tag, PopoverNext, MenuDivider } from "@blueprintjs/core";
|
|
3
3
|
import { OPERATOR_LABELS } from "../../filters/operators.js";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
import { atom } from "jotai";
|
|
@@ -13,6 +13,12 @@ function resolveColumnFilter(col) {
|
|
|
13
13
|
if (rich != null) return { ...rich, columnKey: rich.columnKey ?? col.key };
|
|
14
14
|
return buildMultiOperatorColumnFilter(col);
|
|
15
15
|
}
|
|
16
|
+
function InlineFilterControl({ filter }) {
|
|
17
|
+
const [state, setState] = useFilterAtom(filter);
|
|
18
|
+
const Form = filter.filterForm;
|
|
19
|
+
if (Form == null) return null;
|
|
20
|
+
return h(Form, { state: state ?? filter.defaultState, setState });
|
|
21
|
+
}
|
|
16
22
|
function ColumnFilterControl({ col }) {
|
|
17
23
|
const filter = useMemo(() => resolveColumnFilter(col), [col]);
|
|
18
24
|
return h(FilterIndicator, {
|
|
@@ -59,19 +65,29 @@ function FilterIndicator({
|
|
|
59
65
|
)
|
|
60
66
|
);
|
|
61
67
|
}
|
|
62
|
-
function MenuDropdown({ children, content,
|
|
68
|
+
function MenuDropdown({ children, content, ...props }) {
|
|
63
69
|
return h(
|
|
64
70
|
PopoverNext,
|
|
65
71
|
{
|
|
66
72
|
content,
|
|
67
73
|
placement: "bottom-start",
|
|
68
|
-
enforceFocus:
|
|
74
|
+
enforceFocus: false,
|
|
69
75
|
autoFocus: false,
|
|
70
|
-
arrow: false
|
|
76
|
+
arrow: false,
|
|
77
|
+
...props
|
|
71
78
|
},
|
|
72
79
|
children
|
|
73
80
|
);
|
|
74
81
|
}
|
|
82
|
+
function MenuFormItem({
|
|
83
|
+
title,
|
|
84
|
+
children
|
|
85
|
+
}) {
|
|
86
|
+
return h("li.menu-form-item", [
|
|
87
|
+
h.if(title != null)(MenuDivider, { title }),
|
|
88
|
+
h("div.menu-form-body", children)
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
75
91
|
function buildFilterTagLabel(filter, valueText, {
|
|
76
92
|
minimal,
|
|
77
93
|
showSubject,
|
|
@@ -127,6 +143,18 @@ function ColumnFilterMenuItem({
|
|
|
127
143
|
filterForm
|
|
128
144
|
);
|
|
129
145
|
}
|
|
146
|
+
function MenuInlineFilterItem({
|
|
147
|
+
filter,
|
|
148
|
+
label
|
|
149
|
+
}) {
|
|
150
|
+
const { filterForm, valueText } = useFilterProps(filter);
|
|
151
|
+
return h("li.menu-inline-filter", [
|
|
152
|
+
h(MenuDivider, { title: label ?? filter.name }),
|
|
153
|
+
h("div.menu-inline-filter-body", { "data-filter-value": valueText }, [
|
|
154
|
+
filterForm
|
|
155
|
+
])
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
130
158
|
function useFilterProps(filter) {
|
|
131
159
|
const [state, setState] = useFilterAtom(filter);
|
|
132
160
|
const onRemove = useCallback(
|
|
@@ -303,15 +331,36 @@ function ColumnSortIndicator({
|
|
|
303
331
|
}
|
|
304
332
|
function ColumnSortMenu({
|
|
305
333
|
columnKey,
|
|
334
|
+
text,
|
|
306
335
|
defaultLabel
|
|
307
336
|
}) {
|
|
308
337
|
const [sort, setSort] = useSortAtom(columnKey);
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
338
|
+
const isActive = sort != null;
|
|
339
|
+
const icon = sort == null ? "sort" : sort.ascending ? "sort-asc" : "sort-desc";
|
|
340
|
+
const name = text ?? defaultLabel ?? columnKey;
|
|
341
|
+
let clearButton = void 0;
|
|
342
|
+
if (isActive) {
|
|
343
|
+
clearButton = h(Button, {
|
|
344
|
+
icon: "cross",
|
|
345
|
+
minimal: true,
|
|
346
|
+
small: true,
|
|
347
|
+
onClick: (e) => {
|
|
348
|
+
e.stopPropagation();
|
|
349
|
+
setSort(null);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return h(MenuItem, {
|
|
354
|
+
icon,
|
|
355
|
+
text: name,
|
|
356
|
+
intent: isActive ? "primary" : void 0,
|
|
357
|
+
active: isActive,
|
|
358
|
+
labelElement: clearButton,
|
|
359
|
+
shouldDismissPopover: false,
|
|
360
|
+
// Toggle direction; `setSort` never receives the current direction (so its
|
|
361
|
+
// click-same-to-clear path doesn't fire) — clearing is the ✕'s job.
|
|
362
|
+
onClick: () => setSort(sort == null ? true : !sort.ascending)
|
|
363
|
+
});
|
|
315
364
|
}
|
|
316
365
|
const setFilterAtom = atom(null, (get, set, filter, next) => {
|
|
317
366
|
const store = get(storeAtom);
|
|
@@ -370,7 +419,10 @@ export {
|
|
|
370
419
|
ColumnSortIndicator,
|
|
371
420
|
ColumnSortMenu,
|
|
372
421
|
FilterIndicator,
|
|
422
|
+
InlineFilterControl,
|
|
373
423
|
MenuDropdown,
|
|
424
|
+
MenuFormItem,
|
|
425
|
+
MenuInlineFilterItem,
|
|
374
426
|
resolveColumnFilter
|
|
375
427
|
};
|
|
376
428
|
//# sourceMappingURL=filter-and-sort.js.map
|