@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
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
HTMLSelect,
|
|
12
12
|
InputGroup,
|
|
13
13
|
Menu,
|
|
14
|
+
MenuDivider,
|
|
14
15
|
MenuItem,
|
|
15
16
|
PopoverNext,
|
|
16
17
|
Tag,
|
|
@@ -31,6 +32,22 @@ export function resolveColumnFilter(col: ColumnSpec): TableFilter {
|
|
|
31
32
|
return buildMultiOperatorColumnFilter(col);
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Render a filter's `filterForm` as an always-visible inline control — rather
|
|
37
|
+
* than behind a menu dropdown — wired to the shared filter state. Lets any
|
|
38
|
+
* `TableFilter` (e.g. an open text search spanning several columns) live
|
|
39
|
+
* directly in a toolbar while still flowing through the standard filter model:
|
|
40
|
+
* store `activeFilters` → the provider's `translateFilter`, identical to the
|
|
41
|
+
* menu-driven controls. The form clears the filter when its state goes empty
|
|
42
|
+
* (`state.value === ""`), matching the rest of the filter UI.
|
|
43
|
+
*/
|
|
44
|
+
export function InlineFilterControl({ filter }: { filter: TableFilter }) {
|
|
45
|
+
const [state, setState] = useFilterAtom(filter);
|
|
46
|
+
const Form = filter.filterForm;
|
|
47
|
+
if (Form == null) return null;
|
|
48
|
+
return h(Form, { state: state ?? filter.defaultState, setState });
|
|
49
|
+
}
|
|
50
|
+
|
|
34
51
|
/** Shows an active column filter in the top menu */
|
|
35
52
|
export function ColumnFilterControl({ col }: { col: ColumnSpec }) {
|
|
36
53
|
// Same `TableFilter` the FilterBar and any provider consume, so the header,
|
|
@@ -92,20 +109,49 @@ export function FilterIndicator({
|
|
|
92
109
|
);
|
|
93
110
|
}
|
|
94
111
|
|
|
95
|
-
|
|
112
|
+
/**
|
|
113
|
+
* A dropdown for a panel of controls (not just menu items).
|
|
114
|
+
*
|
|
115
|
+
* Deliberately **not** focus-trapping. These panels hold real form controls,
|
|
116
|
+
* and a control whose own typeahead renders in a separate portal (a
|
|
117
|
+
* `MultiSelect`, a date picker) has focus yanked back out of it by an enclosing
|
|
118
|
+
* trap — which is what makes a nested filter submenu feel unstable. Caller
|
|
119
|
+
* props are passed through (`placement`, `isOpen`, …).
|
|
120
|
+
*/
|
|
121
|
+
export function MenuDropdown({ children, content, ...props }: any) {
|
|
96
122
|
return h(
|
|
97
123
|
PopoverNext,
|
|
98
124
|
{
|
|
99
125
|
content,
|
|
100
126
|
placement: "bottom-start",
|
|
101
|
-
enforceFocus:
|
|
127
|
+
enforceFocus: false,
|
|
102
128
|
autoFocus: false,
|
|
103
129
|
arrow: false,
|
|
130
|
+
...props,
|
|
104
131
|
},
|
|
105
132
|
children,
|
|
106
133
|
);
|
|
107
134
|
}
|
|
108
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A titled block *inside* a menu holding an arbitrary form, rather than a menu
|
|
138
|
+
* item that opens a submenu — one click away instead of two, with no nested
|
|
139
|
+
* popover to lose focus to. The building block behind `MenuInlineFilterItem`,
|
|
140
|
+
* exported so a custom control panel can use the same idiom.
|
|
141
|
+
*/
|
|
142
|
+
export function MenuFormItem({
|
|
143
|
+
title,
|
|
144
|
+
children,
|
|
145
|
+
}: {
|
|
146
|
+
title?: ReactNode;
|
|
147
|
+
children: ReactNode;
|
|
148
|
+
}) {
|
|
149
|
+
return h("li.menu-form-item", [
|
|
150
|
+
h.if(title != null)(MenuDivider, { title }),
|
|
151
|
+
h("div.menu-form-body", children),
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
|
|
109
155
|
function buildFilterTagLabel(
|
|
110
156
|
filter: TableFilter,
|
|
111
157
|
valueText: ReactNode | null,
|
|
@@ -187,6 +233,25 @@ export function ColumnFilterMenuItem({
|
|
|
187
233
|
);
|
|
188
234
|
}
|
|
189
235
|
|
|
236
|
+
/** A filter rendered *inside* a menu but without a submenu — its name as a
|
|
237
|
+
* section header, its form directly below. For `presentation: "menu-inline"`
|
|
238
|
+
* (e.g. a compact segmented control that doesn't warrant a submenu hop). */
|
|
239
|
+
export function MenuInlineFilterItem({
|
|
240
|
+
filter,
|
|
241
|
+
label,
|
|
242
|
+
}: {
|
|
243
|
+
filter: TableFilter;
|
|
244
|
+
label?: string;
|
|
245
|
+
}) {
|
|
246
|
+
const { filterForm, valueText } = useFilterProps(filter);
|
|
247
|
+
return h("li.menu-inline-filter", [
|
|
248
|
+
h(MenuDivider, { title: label ?? filter.name }),
|
|
249
|
+
h("div.menu-inline-filter-body", { "data-filter-value": valueText }, [
|
|
250
|
+
filterForm,
|
|
251
|
+
]),
|
|
252
|
+
]);
|
|
253
|
+
}
|
|
254
|
+
|
|
190
255
|
function useFilterProps(filter: TableFilter) {
|
|
191
256
|
const [state, setState] = useFilterAtom(filter);
|
|
192
257
|
|
|
@@ -399,13 +464,14 @@ export function ColumnSortIndicator({
|
|
|
399
464
|
);
|
|
400
465
|
}
|
|
401
466
|
|
|
402
|
-
/** Menu-native sort
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
467
|
+
/** Menu-native sort as a **single, flat** item — no submenu. The item shows the
|
|
468
|
+
* field name with a direction icon (↑/↓); an active sort reads through the
|
|
469
|
+
* `primary` intent, and clicking the item toggles the direction (unsorted →
|
|
470
|
+
* ascending → descending → …). A right-aligned ✕ clears it. `text` is the
|
|
471
|
+
* field's display label (the `DataPanel` lists one item per sortable field). */
|
|
407
472
|
export function ColumnSortMenu({
|
|
408
473
|
columnKey,
|
|
474
|
+
text,
|
|
409
475
|
defaultLabel,
|
|
410
476
|
}: {
|
|
411
477
|
columnKey: string;
|
|
@@ -413,12 +479,35 @@ export function ColumnSortMenu({
|
|
|
413
479
|
defaultLabel?: string;
|
|
414
480
|
}) {
|
|
415
481
|
const [sort, setSort] = useSortAtom(columnKey);
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
482
|
+
const isActive = sort != null;
|
|
483
|
+
const icon =
|
|
484
|
+
sort == null ? "sort" : sort.ascending ? "sort-asc" : "sort-desc";
|
|
485
|
+
const name = text ?? defaultLabel ?? columnKey;
|
|
486
|
+
|
|
487
|
+
let clearButton: ReactNode = undefined;
|
|
488
|
+
if (isActive) {
|
|
489
|
+
clearButton = h(Button, {
|
|
490
|
+
icon: "cross",
|
|
491
|
+
minimal: true,
|
|
492
|
+
small: true,
|
|
493
|
+
onClick: (e: any) => {
|
|
494
|
+
e.stopPropagation();
|
|
495
|
+
setSort(null);
|
|
496
|
+
},
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return h(MenuItem, {
|
|
501
|
+
icon,
|
|
502
|
+
text: name,
|
|
503
|
+
intent: isActive ? "primary" : undefined,
|
|
504
|
+
active: isActive,
|
|
505
|
+
labelElement: clearButton,
|
|
506
|
+
shouldDismissPopover: false,
|
|
507
|
+
// Toggle direction; `setSort` never receives the current direction (so its
|
|
508
|
+
// click-same-to-clear path doesn't fire) — clearing is the ✕'s job.
|
|
509
|
+
onClick: () => setSort(sort == null ? true : !sort.ascending),
|
|
510
|
+
});
|
|
422
511
|
}
|
|
423
512
|
|
|
424
513
|
const setFilterAtom = atom(null, (get, set, filter: TableFilter, next: any) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
columnSpecAtom,
|
|
3
3
|
ctx,
|
|
4
|
+
enableSelectionAtom,
|
|
4
5
|
interactionOptionsAtom,
|
|
5
6
|
itemLabelAtom,
|
|
6
7
|
pluralize,
|
|
@@ -51,20 +52,13 @@ function itemCount(n: number, itemType: string) {
|
|
|
51
52
|
return `${n} ` + pluralize(itemType, n);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
set(interactionOptionsAtom, {
|
|
64
|
-
...interactionState,
|
|
65
|
-
enableSelection,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
55
|
+
/** Enter/leave select mode. Leaving clears the selection — it has to happen
|
|
56
|
+
* *before* selection is switched off, since the selection write is gated on it. */
|
|
57
|
+
export const toggleModalSelectionAtom = atom(null, (get, set) => {
|
|
58
|
+
if (!get(interactionOptionsAtom).enableModalSelection) return;
|
|
59
|
+
const next = !get(enableSelectionAtom);
|
|
60
|
+
if (!next) set(clearableSelectionAtom);
|
|
61
|
+
set(enableSelectionAtom, next);
|
|
68
62
|
});
|
|
69
63
|
const clearableSelectionAtom = atom(
|
|
70
64
|
(get) => get(selectionAtom),
|
|
@@ -89,7 +83,8 @@ export function SelectionIndicator({ minimal = true }: { minimal?: boolean }) {
|
|
|
89
83
|
const tableName = ctx.useValue(tableNameAtom);
|
|
90
84
|
|
|
91
85
|
const toggleModalSelection = ctx.useSet(toggleModalSelectionAtom);
|
|
92
|
-
const { enableModalSelection
|
|
86
|
+
const { enableModalSelection } = interactionState;
|
|
87
|
+
const enableSelection = ctx.useValue(enableSelectionAtom);
|
|
93
88
|
|
|
94
89
|
const hasSelection = selection != null && selection.length > 0;
|
|
95
90
|
|
|
@@ -2,41 +2,229 @@ import {
|
|
|
2
2
|
ALL_CARDINALITIES,
|
|
3
3
|
isColumnFilterable,
|
|
4
4
|
TableAction,
|
|
5
|
+
TableFilter,
|
|
5
6
|
} from "../../actions";
|
|
6
|
-
import {
|
|
7
|
-
|
|
7
|
+
import {
|
|
8
|
+
ctx,
|
|
9
|
+
enableSelectionAtom,
|
|
10
|
+
interactionOptionsAtom,
|
|
11
|
+
storeAtom,
|
|
12
|
+
useSelector,
|
|
13
|
+
} from "../../provider";
|
|
14
|
+
import { type ReactNode, useMemo } from "react";
|
|
8
15
|
import h from "../../data-panel.module.sass";
|
|
9
|
-
import { Menu, Tag } from "@blueprintjs/core";
|
|
16
|
+
import { Button, Menu, MenuDivider, Tag } from "@blueprintjs/core";
|
|
10
17
|
import {
|
|
11
18
|
ColumnFilterMenuItem,
|
|
12
19
|
ColumnSortMenu,
|
|
20
|
+
InlineFilterControl,
|
|
13
21
|
MenuDropdown,
|
|
22
|
+
MenuFormItem,
|
|
23
|
+
MenuInlineFilterItem,
|
|
14
24
|
resolveColumnFilter,
|
|
15
25
|
} from "./filter-and-sort.ts";
|
|
26
|
+
import { toggleModalSelectionAtom } from "./selection.ts";
|
|
16
27
|
import { atom } from "jotai";
|
|
17
28
|
|
|
29
|
+
/** How the built-in view controls (inline filters, Filter menu, Sort menu) are
|
|
30
|
+
* placed in the toolbar:
|
|
31
|
+
* - `"inline"` (default): each control sits in the toolbar.
|
|
32
|
+
* - `"popover"`: all of them collapse behind a single button — for a narrow or
|
|
33
|
+
* deliberately chrome-light toolbar.
|
|
34
|
+
* In both cases the controls, state, and provider seam are identical. */
|
|
35
|
+
export type ViewControlsPresentation = "inline" | "popover";
|
|
36
|
+
|
|
37
|
+
/** A filter to surface, plus the label to show for it. */
|
|
38
|
+
interface FilterEntry {
|
|
39
|
+
filter: TableFilter;
|
|
40
|
+
label: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
18
43
|
/**
|
|
19
|
-
* Stand-in for the column-header dropdown the card list lacks
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
44
|
+
* Stand-in for the column-header dropdown the card list lacks. Surfaces every
|
|
45
|
+
* available filter (column-declared `filterable` + any table-level `filters`)
|
|
46
|
+
* and sort, honoring each filter's `presentation`:
|
|
47
|
+
* - `"inline"` → an always-visible toolbar control (its `filterForm` directly),
|
|
48
|
+
* - `"menu"` (default) → a "Filter" menu item that opens the form in a submenu,
|
|
49
|
+
* - `"menu-inline"` → the form rendered directly in the "Filter" menu.
|
|
50
|
+
* Every case reuses the *same* controls and store/provider seam — only
|
|
51
|
+
* placement changes. Sort still comes from the column-declared `sortable` set.
|
|
25
52
|
*/
|
|
26
|
-
export function useDataPanelControls(
|
|
27
|
-
|
|
53
|
+
export function useDataPanelControls(
|
|
54
|
+
tableFilters: TableFilter[] = [],
|
|
55
|
+
presentation: ViewControlsPresentation = "inline",
|
|
56
|
+
): TableAction[] {
|
|
57
|
+
const columnSpec = useSelector((s) => s.columnSpec);
|
|
28
58
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
59
|
+
// All filters, table-level first, then column-derived (each with a label).
|
|
60
|
+
const entries = useMemo<FilterEntry[]>(() => {
|
|
61
|
+
const fromColumns = columnSpec
|
|
62
|
+
.filter((c) => isColumnFilterable(c))
|
|
63
|
+
.map((c) => ({ filter: resolveColumnFilter(c), label: c.name }));
|
|
64
|
+
const fromTable = tableFilters.map((f) => ({ filter: f, label: f.name }));
|
|
65
|
+
return [...fromTable, ...fromColumns];
|
|
66
|
+
}, [columnSpec, tableFilters]);
|
|
67
|
+
|
|
68
|
+
const inlineEntries = entries.filter(
|
|
69
|
+
(e) => presentationOf(e.filter) === "inline",
|
|
70
|
+
);
|
|
71
|
+
const menuEntries = entries.filter(
|
|
72
|
+
(e) => presentationOf(e.filter) !== "inline",
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Hooks first (stable order), then assemble.
|
|
76
|
+
const filterMenuAction = useFilterMenuAction(menuEntries);
|
|
33
77
|
const sortAction = useSortAction();
|
|
34
|
-
|
|
35
|
-
|
|
78
|
+
const collapsedAction = useCollapsedControlsAction(entries);
|
|
79
|
+
const exitSelectionAction = useExitSelectionAction();
|
|
80
|
+
|
|
81
|
+
// While a modal view is *selecting*, the toolbar belongs to the selection and
|
|
82
|
+
// its set-actions. Changing the view would also invalidate the selection
|
|
83
|
+
// (rows are addressed by index — see `dropRowSelection`), so rather than
|
|
84
|
+
// competing for space, the view controls collapse to a single affordance that
|
|
85
|
+
// **leaves select mode** and hands the toolbar back.
|
|
86
|
+
if (exitSelectionAction != null) return [exitSelectionAction];
|
|
87
|
+
|
|
88
|
+
// One button holding every control, for a toolbar with no room for them (or a
|
|
89
|
+
// deliberately chrome-light layout).
|
|
90
|
+
if (presentation === "popover" && collapsedAction != null) {
|
|
91
|
+
return [collapsedAction];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const actions: TableAction[] = [];
|
|
95
|
+
// Inline filters: one always-visible toolbar control each.
|
|
96
|
+
for (const { filter } of inlineEntries) {
|
|
97
|
+
actions.push({
|
|
98
|
+
id: `filter:${filter.id}`,
|
|
99
|
+
name: filter.name,
|
|
100
|
+
icon: filter.icon,
|
|
101
|
+
targets: ALL_CARDINALITIES,
|
|
102
|
+
render: () => h(InlineFilterControl, { filter }),
|
|
103
|
+
});
|
|
36
104
|
}
|
|
105
|
+
if (filterMenuAction != null) actions.push(filterMenuAction);
|
|
106
|
+
if (sortAction != null) actions.push(sortAction);
|
|
37
107
|
return actions;
|
|
38
108
|
}
|
|
39
109
|
|
|
110
|
+
/**
|
|
111
|
+
* The whole view-control set behind one button: inline filters as titled
|
|
112
|
+
* sections, then the filters, then the sorts. Same controls, same store seam —
|
|
113
|
+
* only placement changes (the `presentation` idea from `TableFilter`, applied to
|
|
114
|
+
* the toolbar as a whole).
|
|
115
|
+
*/
|
|
116
|
+
function useCollapsedControlsAction(
|
|
117
|
+
entries: FilterEntry[],
|
|
118
|
+
): TableAction | null {
|
|
119
|
+
const columnSpec = useSelector((s) => s.columnSpec);
|
|
120
|
+
const hasActiveFilters = ctx.useValue(hasActiveFiltersAtom);
|
|
121
|
+
const hasActiveSorts = ctx.useValue(hasActiveSortsAtom);
|
|
122
|
+
|
|
123
|
+
const sortableCols = useMemo(
|
|
124
|
+
() => columnSpec.filter((c) => c.sortable),
|
|
125
|
+
[columnSpec],
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
if (entries.length === 0 && sortableCols.length === 0) return null;
|
|
129
|
+
|
|
130
|
+
const inlineEntries = entries.filter(
|
|
131
|
+
(e) => presentationOf(e.filter) === "inline",
|
|
132
|
+
);
|
|
133
|
+
const menuEntries = entries.filter(
|
|
134
|
+
(e) => presentationOf(e.filter) !== "inline",
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const items: ReactNode[] = [];
|
|
138
|
+
for (const { filter, label } of inlineEntries) {
|
|
139
|
+
items.push(
|
|
140
|
+
h(MenuFormItem, { key: filter.id, title: label }, [
|
|
141
|
+
h(InlineFilterControl, { filter }),
|
|
142
|
+
]),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (menuEntries.length > 0) {
|
|
146
|
+
items.push(h(MenuDivider, { key: "filter-divider", title: "Filter" }));
|
|
147
|
+
for (const { filter, label } of menuEntries) {
|
|
148
|
+
if (presentationOf(filter) === "menu-inline") {
|
|
149
|
+
items.push(h(MenuInlineFilterItem, { key: filter.id, filter, label }));
|
|
150
|
+
} else {
|
|
151
|
+
items.push(h(ColumnFilterMenuItem, { key: filter.id, filter, label }));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (sortableCols.length > 0) {
|
|
156
|
+
items.push(h(MenuDivider, { key: "sort-divider", title: "Sort" }));
|
|
157
|
+
for (const col of sortableCols) {
|
|
158
|
+
items.push(
|
|
159
|
+
h(ColumnSortMenu, { key: col.key, columnKey: col.key, text: col.name }),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
let intent: "primary" | "none" = "none";
|
|
165
|
+
if (hasActiveFilters || hasActiveSorts) intent = "primary";
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
id: "view-controls",
|
|
169
|
+
name: "View",
|
|
170
|
+
icon: "filter-list",
|
|
171
|
+
description: "Search, filter and sort.",
|
|
172
|
+
targets: ALL_CARDINALITIES,
|
|
173
|
+
requiresEditable: false,
|
|
174
|
+
render: () =>
|
|
175
|
+
h(
|
|
176
|
+
MenuDropdown,
|
|
177
|
+
{ content: h(Menu, { className: "collapsed-controls" }, items) },
|
|
178
|
+
[
|
|
179
|
+
h(Button, {
|
|
180
|
+
minimal: true,
|
|
181
|
+
small: true,
|
|
182
|
+
icon: "filter-list",
|
|
183
|
+
intent,
|
|
184
|
+
title: "Search, filter and sort",
|
|
185
|
+
}),
|
|
186
|
+
],
|
|
187
|
+
),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** While selecting on a modal view: one control that leaves select mode (and so
|
|
192
|
+
* restores the view controls). Labelled for where it takes you, not what it
|
|
193
|
+
* does to the selection. */
|
|
194
|
+
function useExitSelectionAction(): TableAction | null {
|
|
195
|
+
const { enableModalSelection } = ctx.useValue(interactionOptionsAtom);
|
|
196
|
+
const selecting = ctx.useValue(enableSelectionAtom);
|
|
197
|
+
const toggleSelectMode = ctx.useSet(toggleModalSelectionAtom);
|
|
198
|
+
|
|
199
|
+
if (!enableModalSelection || !selecting) return null;
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
id: "exit-selection",
|
|
203
|
+
name: "Filter",
|
|
204
|
+
icon: "filter",
|
|
205
|
+
description: "Leave select mode to filter and sort.",
|
|
206
|
+
targets: ALL_CARDINALITIES,
|
|
207
|
+
requiresEditable: false,
|
|
208
|
+
render: () =>
|
|
209
|
+
h(
|
|
210
|
+
Tag,
|
|
211
|
+
{
|
|
212
|
+
minimal: true,
|
|
213
|
+
large: true,
|
|
214
|
+
interactive: true,
|
|
215
|
+
icon: "filter",
|
|
216
|
+
title: "Filter and sort (leaves select mode)",
|
|
217
|
+
onClick: () => toggleSelectMode(),
|
|
218
|
+
},
|
|
219
|
+
"Filter",
|
|
220
|
+
),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function presentationOf(filter: TableFilter): string {
|
|
225
|
+
return filter.presentation ?? "menu";
|
|
226
|
+
}
|
|
227
|
+
|
|
40
228
|
function useDisplayIntent(atom) {
|
|
41
229
|
const [hasActive, clearActive] = ctx.use(atom);
|
|
42
230
|
const intent = hasActive ? "primary" : "none";
|
|
@@ -54,26 +242,21 @@ function useDisplayIntent(atom) {
|
|
|
54
242
|
return { intent, rightIcon, onRemove, hasActive };
|
|
55
243
|
}
|
|
56
244
|
|
|
57
|
-
function
|
|
58
|
-
const columnSpec = useSelector((s) => s.columnSpec);
|
|
59
|
-
const filterableCols = useMemo(
|
|
60
|
-
() => columnSpec.filter((c) => isColumnFilterable(c)),
|
|
61
|
-
[columnSpec],
|
|
62
|
-
);
|
|
63
|
-
|
|
245
|
+
function useFilterMenuAction(entries: FilterEntry[]): TableAction | null {
|
|
64
246
|
const rest = useDisplayIntent(hasActiveFiltersAtom);
|
|
65
247
|
|
|
66
|
-
if (
|
|
248
|
+
if (entries.length === 0) return null;
|
|
67
249
|
|
|
68
250
|
const filterMenu = h(
|
|
69
251
|
Menu,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
252
|
+
entries.map(({ filter, label }) => {
|
|
253
|
+
// A `menu-inline` filter renders its form directly in the menu (no
|
|
254
|
+
// submenu); the default `menu` presentation uses the submenu item.
|
|
255
|
+
if (presentationOf(filter) === "menu-inline") {
|
|
256
|
+
return h(MenuInlineFilterItem, { key: filter.id, filter, label });
|
|
257
|
+
}
|
|
258
|
+
return h(ColumnFilterMenuItem, { key: filter.id, filter, label });
|
|
259
|
+
}),
|
|
77
260
|
);
|
|
78
261
|
|
|
79
262
|
const filterIndicator = h(
|
|
@@ -9,6 +9,16 @@ import { Button, ButtonGroup, Icon, Spinner } from "@blueprintjs/core";
|
|
|
9
9
|
* controls with "Page X of Y". */
|
|
10
10
|
export function LoadProgressIndicator({ iconSize: size = 12, className }) {
|
|
11
11
|
const footer = ctx.useValue(tableFooterAtom);
|
|
12
|
+
|
|
13
|
+
// A load error takes precedence over the normal progress display in every
|
|
14
|
+
// mode — a compact, non-crashing signal that the source failed.
|
|
15
|
+
if (footer.error != null) {
|
|
16
|
+
return h("div.load-progress.load-error", { className }, [
|
|
17
|
+
h(Icon, { icon: "error", size, intent: "danger" }),
|
|
18
|
+
h("span.load-progress-label", footer.error.message ?? "Failed to load"),
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
if (footer.mode === "paged") return h(PageControl);
|
|
13
23
|
|
|
14
24
|
const { loaded, total, loading } = footer;
|
|
@@ -79,7 +79,10 @@ export function ActionsToolbar<T>({
|
|
|
79
79
|
[actions, columnSpec],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
// Render whenever there are displayable actions OR the consumer supplied
|
|
83
|
+
// custom toolbar chrome (`children`) — a facet-less panel (e.g. a card list
|
|
84
|
+
// with only a search box) still needs its toolbar slot to appear.
|
|
85
|
+
if (!toolbarIsShown && children == null) {
|
|
83
86
|
return null;
|
|
84
87
|
}
|
|
85
88
|
|
|
@@ -165,6 +168,10 @@ function RunActionButton<T>({ action }: { action: TableAction<T> }) {
|
|
|
165
168
|
return h(
|
|
166
169
|
Button,
|
|
167
170
|
{
|
|
171
|
+
// Minimal + small to match the toolbar's other controls (scroll-to-row,
|
|
172
|
+
// sort/filter tags) — the compact, minimal house style.
|
|
173
|
+
minimal: true,
|
|
174
|
+
small: true,
|
|
168
175
|
icon: action.icon,
|
|
169
176
|
intent: action.intent,
|
|
170
177
|
disabled: isDisabled,
|
|
@@ -230,6 +237,8 @@ function ActionButtonWithForm<T, S>({
|
|
|
230
237
|
h(
|
|
231
238
|
Button,
|
|
232
239
|
{
|
|
240
|
+
minimal: true,
|
|
241
|
+
small: true,
|
|
233
242
|
icon: action.icon,
|
|
234
243
|
intent: action.intent,
|
|
235
244
|
disabled: isDisabled,
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
:root
|
|
5
5
|
--data-panel-content-padding: 0px
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
.data-panel
|
|
9
8
|
display: flex
|
|
10
9
|
flex: 1 1 auto
|
|
@@ -14,7 +13,9 @@
|
|
|
14
13
|
min-width: 0
|
|
15
14
|
--data-panel-content-padding: 12px
|
|
16
15
|
--data-panel-item-gap: 8px
|
|
17
|
-
|
|
16
|
+
// Fallback to percentage
|
|
17
|
+
--data-panel-content-width: 100cqw
|
|
18
|
+
|
|
18
19
|
--data-panel-selected-color: #2d72d2
|
|
19
20
|
--data-panel-selected-background: rgba(45, 114, 210, 0.1)
|
|
20
21
|
|
|
@@ -53,9 +54,26 @@
|
|
|
53
54
|
min-width: 0
|
|
54
55
|
|
|
55
56
|
// The inline end-of-scroll region (default spinner sentinel, or an inline
|
|
56
|
-
// footer). Sits in the scroll flow, so it's seen only at the bottom.
|
|
57
|
+
// footer). Sits in the scroll flow, so it's seen only at the bottom. A constant
|
|
58
|
+
// min-height keeps its content (spinner / "Load more" / end note) swapping in
|
|
59
|
+
// place instead of the footer pinging up into the list as pages append.
|
|
57
60
|
.content-footer-holder
|
|
58
61
|
flex: 0 0 auto
|
|
62
|
+
min-height: 44px
|
|
63
|
+
display: flex
|
|
64
|
+
align-items: center
|
|
65
|
+
justify-content: center
|
|
66
|
+
|
|
67
|
+
// Skeleton placeholder shown where a loading page's rows will land — sized like
|
|
68
|
+
// a card so the body height stays stable (no blank flash, no footer ping). The
|
|
69
|
+
// shimmer comes from Blueprint's `.bp6-skeleton`.
|
|
70
|
+
.data-panel-item-container.is-skeleton
|
|
71
|
+
pointer-events: none
|
|
72
|
+
|
|
73
|
+
.data-panel-skeleton
|
|
74
|
+
width: 100%
|
|
75
|
+
min-height: 3.25em
|
|
76
|
+
border-radius: 4px
|
|
59
77
|
|
|
60
78
|
// Default layout body — a vertical list of cards. A custom `scrollBody`
|
|
61
79
|
// replaces this element (e.g. with a CSS grid) but keeps the same scroll
|
|
@@ -156,7 +174,7 @@
|
|
|
156
174
|
|
|
157
175
|
.data-panel-toolbar
|
|
158
176
|
left: 50%
|
|
159
|
-
transform: translateX(calc((var(--data-panel-content-width,
|
|
177
|
+
transform: translateX(calc((var(--data-panel-content-width, 100cqw) / -2) + var(--data-panel-content-padding) - 4px))
|
|
160
178
|
top: var(--data-panel-content-padding, 12px)
|
|
161
179
|
background-color: var(--panel-secondary-background-color)
|
|
162
180
|
box-shadow: 0 0 0 1px var(--panel-rule-color)
|
|
@@ -183,3 +201,7 @@
|
|
|
183
201
|
.data-panel-body.is-scrolled
|
|
184
202
|
mask-image: linear-gradient(to bottom, transparent 0, var(--background-color) 20px)
|
|
185
203
|
|
|
204
|
+
|
|
205
|
+
// Every view control behind one button (`viewControls: "popover"`).
|
|
206
|
+
.collapsed-controls
|
|
207
|
+
max-width: 360px
|