@macrostrat/data-sheet 4.1.1 → 4.2.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 +34 -0
- package/dist/actions/builtin.cjs +1 -1
- package/dist/actions/builtin.cjs.map +1 -1
- package/dist/actions/builtin.d.ts +0 -2
- package/dist/actions/builtin.js +1 -1
- package/dist/actions/builtin.js.map +1 -1
- package/dist/actions/clipboard.cjs +1 -1
- package/dist/actions/clipboard.cjs.map +1 -1
- package/dist/actions/clipboard.d.ts +3 -2
- package/dist/actions/clipboard.js +1 -1
- package/dist/actions/clipboard.js.map +1 -1
- package/dist/actions/column-controls.cjs +7 -196
- package/dist/actions/column-controls.cjs.map +1 -1
- package/dist/actions/column-controls.d.ts +1 -1
- package/dist/actions/column-controls.js +5 -194
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -73
- package/dist/actions/column-filter.cjs.map +1 -1
- package/dist/actions/column-filter.d.ts +6 -4
- package/dist/actions/column-filter.js +25 -74
- package/dist/actions/column-filter.js.map +1 -1
- package/dist/actions/context.cjs +147 -0
- package/dist/actions/context.cjs.map +1 -0
- package/dist/actions/context.d.ts +93 -0
- package/dist/actions/context.js +145 -0
- package/dist/actions/context.js.map +1 -0
- package/dist/actions/edit-actions.cjs.map +1 -1
- package/dist/actions/edit-actions.d.ts +3 -1
- package/dist/actions/edit-actions.js.map +1 -1
- package/dist/actions/index.d.ts +2 -3
- package/dist/actions/selection.cjs +70 -115
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +22 -12
- package/dist/actions/selection.js +71 -114
- package/dist/actions/selection.js.map +1 -1
- package/dist/actions/table-actions.cjs +41 -0
- package/dist/actions/table-actions.cjs.map +1 -0
- package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
- package/dist/actions/{table-controls.js → table-actions.js} +2 -23
- package/dist/actions/table-actions.js.map +1 -0
- package/dist/actions/types.d.ts +11 -89
- package/dist/components/cell-detail.cjs +6 -6
- package/dist/components/cell-detail.cjs.map +1 -1
- package/dist/components/cell-detail.js +1 -1
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +7 -7
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/indicators/filter-and-sort.cjs +378 -0
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.d.ts +59 -0
- package/dist/components/indicators/filter-and-sort.js +376 -0
- package/dist/components/indicators/filter-and-sort.js.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
- package/dist/components/indicators/index.d.ts +4 -0
- package/dist/components/indicators/selection.cjs +113 -0
- package/dist/components/indicators/selection.cjs.map +1 -0
- package/dist/components/indicators/selection.d.ts +3 -0
- package/dist/components/indicators/selection.js +111 -0
- package/dist/components/indicators/selection.js.map +1 -0
- package/dist/components/indicators/selection.module.sass.cjs +19 -0
- package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
- package/dist/components/indicators/selection.module.sass.js +17 -0
- package/dist/components/indicators/selection.module.sass.js.map +1 -0
- package/dist/components/indicators/unified-filters.cjs +130 -0
- package/dist/components/indicators/unified-filters.cjs.map +1 -0
- package/dist/components/indicators/unified-filters.d.ts +10 -0
- package/dist/components/indicators/unified-filters.js +130 -0
- package/dist/components/indicators/unified-filters.js.map +1 -0
- package/dist/components/indicators/view-info.cjs +59 -0
- package/dist/components/indicators/view-info.cjs.map +1 -0
- package/dist/components/{view-info.d.ts → indicators/view-info.d.ts} +1 -0
- package/dist/components/{view-info.js → indicators/view-info.js} +17 -13
- package/dist/components/indicators/view-info.js.map +1 -0
- package/dist/components/text-areas.cjs +5 -5
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.js +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +185 -0
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
- package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
- package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +37 -112
- package/dist/components/toolbars/actions-toolbar.js.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
- package/dist/components/toolbars/active-filters.cjs +120 -0
- package/dist/components/toolbars/active-filters.cjs.map +1 -0
- package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
- package/dist/components/toolbars/active-filters.js +120 -0
- package/dist/components/toolbars/active-filters.js.map +1 -0
- package/dist/components/toolbars/index.d.ts +2 -0
- package/dist/data-panel.cjs +291 -0
- package/dist/data-panel.cjs.map +1 -0
- package/dist/data-panel.d.ts +110 -0
- package/dist/data-panel.js +289 -0
- package/dist/data-panel.js.map +1 -0
- package/dist/data-panel.module.sass.cjs +40 -0
- package/dist/data-panel.module.sass.cjs.map +1 -0
- package/dist/data-panel.module.sass.js +38 -0
- package/dist/data-panel.module.sass.js.map +1 -0
- package/dist/{core.cjs → data-sheet.cjs} +123 -190
- package/dist/data-sheet.cjs.map +1 -0
- package/dist/data-sheet.css +241 -13
- package/dist/data-sheet.d.ts +16 -0
- package/dist/{core.js → data-sheet.js} +92 -159
- package/dist/data-sheet.js.map +1 -0
- package/dist/data-view.cjs +47 -0
- package/dist/data-view.cjs.map +1 -0
- package/dist/data-view.d.ts +15 -0
- package/dist/data-view.js +45 -0
- package/dist/data-view.js.map +1 -0
- package/dist/filters/operators.cjs +19 -2
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +4 -3
- package/dist/filters/operators.js +19 -2
- package/dist/filters/operators.js.map +1 -1
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +76 -17
- package/dist/index.js.map +1 -1
- package/dist/notifications.cjs +4 -4
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.js +1 -1
- package/dist/postgrest-table/data-loaders.cjs +128 -95
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -82
- package/dist/postgrest-table/data-loaders.js +109 -76
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +18 -17
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +4 -3
- package/dist/postgrest-table/index.js +9 -8
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/{utils → provider}/column-spec.cjs +23 -9
- package/dist/provider/column-spec.cjs.map +1 -0
- package/dist/{utils → provider}/column-spec.d.ts +73 -2
- package/dist/{utils → provider}/column-spec.js +24 -10
- package/dist/provider/column-spec.js.map +1 -0
- package/dist/provider/core.cjs +382 -0
- package/dist/provider/core.cjs.map +1 -0
- package/dist/provider/core.d.ts +74 -0
- package/dist/provider/core.js +380 -0
- package/dist/provider/core.js.map +1 -0
- package/dist/provider/index.d.ts +7 -0
- package/dist/provider/interactions.cjs +128 -0
- package/dist/provider/interactions.cjs.map +1 -0
- package/dist/provider/interactions.d.ts +39 -0
- package/dist/provider/interactions.js +128 -0
- package/dist/provider/interactions.js.map +1 -0
- package/dist/provider/selection.cjs +29 -0
- package/dist/provider/selection.cjs.map +1 -0
- package/dist/provider/selection.d.ts +9 -0
- package/dist/provider/selection.js +29 -0
- package/dist/provider/selection.js.map +1 -0
- package/dist/provider/table-data.cjs +92 -0
- package/dist/provider/table-data.cjs.map +1 -0
- package/dist/provider/table-data.d.ts +81 -0
- package/dist/provider/table-data.js +92 -0
- package/dist/provider/table-data.js.map +1 -0
- package/dist/provider/types.cjs +22 -0
- package/dist/provider/types.cjs.map +1 -0
- package/dist/provider/types.d.ts +256 -0
- package/dist/provider/types.js +22 -0
- package/dist/provider/types.js.map +1 -0
- package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +36 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +21 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +67 -34
- package/dist/renderers/cell-renderer.cjs.map +1 -0
- package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
- package/dist/{cell-renderer.js → renderers/cell-renderer.js} +65 -32
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +21 -13
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +3 -2
- package/dist/renderers/column-header-cell.js +20 -12
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/renderers/index.d.ts +1 -0
- package/dist/types.cjs +7 -19
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +117 -229
- package/dist/types.js +7 -19
- package/dist/types.js.map +1 -1
- package/dist/utils/atoms.cjs +24 -0
- package/dist/utils/atoms.cjs.map +1 -0
- package/dist/utils/atoms.d.ts +4 -0
- package/dist/utils/atoms.js +24 -0
- package/dist/utils/atoms.js.map +1 -0
- package/dist/utils/debug-overlay.cjs.map +1 -1
- package/dist/utils/debug-overlay.js.map +1 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/key-handling.cjs +140 -139
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +4 -2
- package/dist/utils/key-handling.js +136 -135
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/utils/validation.cjs +6 -1
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +6 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +4 -3
- package/src/actions/builtin.ts +1 -4
- package/src/actions/clipboard.ts +4 -3
- package/src/actions/column-controls.ts +12 -245
- package/src/actions/column-filter.ts +28 -92
- package/src/actions/context.ts +299 -0
- package/src/actions/edit-actions.ts +3 -1
- package/src/actions/index.ts +2 -3
- package/src/actions/selection.ts +109 -156
- package/src/actions/{table-controls.ts → table-actions.ts} +0 -24
- package/src/actions/types.ts +17 -101
- package/src/components/colors.ts +1 -1
- package/src/components/index.ts +2 -1
- package/src/components/indicators/filter-and-sort.module.sass +13 -0
- package/src/components/indicators/filter-and-sort.ts +478 -0
- package/src/components/indicators/index.ts +4 -0
- package/src/components/indicators/selection.module.sass +22 -0
- package/src/components/indicators/selection.ts +141 -0
- package/src/components/indicators/unified-filters.ts +161 -0
- package/src/components/{view-info.ts → indicators/view-info.ts} +16 -27
- package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
- package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +49 -150
- package/src/components/toolbars/active-filters.ts +150 -0
- package/src/components/toolbars/index.ts +2 -0
- package/src/data-panel.module.sass +185 -0
- package/src/data-panel.ts +556 -0
- package/src/{core.ts → data-sheet.ts} +145 -330
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +33 -3
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +244 -171
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +30 -15
- package/src/provider/core.ts +585 -0
- package/src/provider/index.ts +7 -0
- package/src/provider/interactions.ts +161 -0
- package/src/provider/selection.ts +31 -0
- package/src/provider/table-data.ts +178 -0
- package/src/provider/types.ts +273 -0
- package/src/{zustand-store.ts → provider/zustand-store.ts} +35 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +140 -57
- package/src/renderers/column-header-cell.ts +21 -14
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +137 -239
- package/src/utils/atoms.ts +28 -0
- package/src/utils/debug-overlay.ts +1 -1
- package/src/utils/index.ts +2 -8
- package/src/utils/key-handling.ts +170 -164
- package/src/utils/validation.ts +7 -2
- package/dist/actions/filters.cjs +0 -139
- package/dist/actions/filters.cjs.map +0 -1
- package/dist/actions/filters.js +0 -139
- package/dist/actions/filters.js.map +0 -1
- package/dist/actions/table-controls.cjs +0 -62
- package/dist/actions/table-controls.cjs.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -260
- package/dist/actions/toolbar.cjs.map +0 -1
- package/dist/actions/toolbar.js.map +0 -1
- package/dist/actions/toolbar.module.sass.cjs +0 -27
- package/dist/actions/toolbar.module.sass.cjs.map +0 -1
- package/dist/actions/toolbar.module.sass.js +0 -25
- package/dist/actions/toolbar.module.sass.js.map +0 -1
- package/dist/cell-renderer.cjs.map +0 -1
- package/dist/cell-renderer.js.map +0 -1
- package/dist/components/view-info.cjs +0 -55
- package/dist/components/view-info.cjs.map +0 -1
- package/dist/components/view-info.js.map +0 -1
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -117
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -197
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -26
- package/dist/provider.js +0 -195
- package/dist/provider.js.map +0 -1
- package/dist/table-updates/data-parameter.d.ts +0 -14
- package/dist/table-updates/filter.d.ts +0 -16
- package/dist/table-updates/index.d.ts +0 -19
- package/dist/utils/column-spec.cjs.map +0 -1
- package/dist/utils/column-spec.js.map +0 -1
- package/dist/utils/index.cjs +0 -9
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/zustand-store.cjs.map +0 -1
- package/dist/zustand-store.js.map +0 -1
- package/src/actions/filters.ts +0 -176
- package/src/components/actions.module.sass +0 -8
- package/src/provider.ts +0 -267
- package/src/table-updates/data-parameter.ts +0 -44
- package/src/table-updates/filter.ts +0 -124
- package/src/table-updates/index.ts +0 -239
- /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
columnSpecAtom,
|
|
3
|
+
ctx,
|
|
4
|
+
interactionOptionsAtom,
|
|
5
|
+
itemLabelAtom,
|
|
6
|
+
pluralize,
|
|
7
|
+
selectionAtom,
|
|
8
|
+
tableNameAtom,
|
|
9
|
+
} from "../../provider";
|
|
10
|
+
import { atom } from "jotai";
|
|
11
|
+
import { computeSelectionShape, getSelectedColumnKeys } from "../../actions";
|
|
12
|
+
import { RegionCardinality } from "@blueprintjs/table";
|
|
13
|
+
import classNames from "classnames";
|
|
14
|
+
import h from "./selection.module.sass";
|
|
15
|
+
import { Tag } from "@blueprintjs/core";
|
|
16
|
+
|
|
17
|
+
/** A short title describing the current selection (its shape), shown as the
|
|
18
|
+
* toolbar's leading label — no icon. */
|
|
19
|
+
const selectionTitleAtom = atom<string | null>((get) => {
|
|
20
|
+
const sel = get(selectionAtom);
|
|
21
|
+
if (sel == null || sel.length === 0) return null;
|
|
22
|
+
const sh = computeSelectionShape(sel);
|
|
23
|
+
const itemName = get(itemLabelAtom);
|
|
24
|
+
|
|
25
|
+
switch (sh.cardinality) {
|
|
26
|
+
case RegionCardinality.FULL_COLUMNS: {
|
|
27
|
+
if (sh.columns == 1) {
|
|
28
|
+
const columnSpec = get(columnSpecAtom);
|
|
29
|
+
const columnKey = getSelectedColumnKeys(sel, columnSpec)[0];
|
|
30
|
+
const col = columnSpec.find((c) => c.key === columnKey);
|
|
31
|
+
return col?.name ?? "1 column";
|
|
32
|
+
}
|
|
33
|
+
return itemCount(sh.columns, "column");
|
|
34
|
+
}
|
|
35
|
+
case RegionCardinality.FULL_ROWS:
|
|
36
|
+
return itemCount(sh.rows, itemName);
|
|
37
|
+
case RegionCardinality.CELLS:
|
|
38
|
+
if (sh.columns == 1 || sh.rows == 1) {
|
|
39
|
+
const nCells = Math.max(sh.columns, sh.rows);
|
|
40
|
+
return itemCount(nCells, "cell");
|
|
41
|
+
}
|
|
42
|
+
return `${sh.columns}×${sh.rows} cells`;
|
|
43
|
+
case RegionCardinality.FULL_TABLE:
|
|
44
|
+
return null;
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function itemCount(n: number, itemType: string) {
|
|
51
|
+
return `${n} ` + pluralize(itemType, n);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const toggleModalSelectionAtom = atom(null, (get, set) => {
|
|
55
|
+
const interactionState = get(interactionOptionsAtom);
|
|
56
|
+
if (interactionState.enableModalSelection) {
|
|
57
|
+
const enableSelection = !interactionState.enableSelection;
|
|
58
|
+
|
|
59
|
+
if (!enableSelection) {
|
|
60
|
+
set(clearableSelectionAtom);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
set(interactionOptionsAtom, {
|
|
64
|
+
...interactionState,
|
|
65
|
+
enableSelection,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const clearableSelectionAtom = atom(
|
|
70
|
+
(get) => get(selectionAtom),
|
|
71
|
+
(get, set) => {
|
|
72
|
+
set(selectionAtom, []);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export function SelectionIndicator({ minimal = true }: { minimal?: boolean }) {
|
|
77
|
+
/** An indicator that shows the table's current selection shape, and optionally modal selection status */
|
|
78
|
+
// The leading title doubles as the clear-selection affordance: with an active
|
|
79
|
+
// selection it renders as a dismissible tag (its ✕ clears the selection),
|
|
80
|
+
// which ties "clear" to the selection it acts on and frees toolbar space.
|
|
81
|
+
// With no selection it's a plain label (table name).
|
|
82
|
+
// Both states render as a `large` `Tag` so the title keeps a constant font
|
|
83
|
+
// and height; only the selected one has a filled background + a ✕ (which
|
|
84
|
+
// clears the selection). The unselected label is a transparent, non-removable
|
|
85
|
+
// tag — visually a plain title, but the same box.
|
|
86
|
+
|
|
87
|
+
const [selection, clearSelection] = ctx.use(clearableSelectionAtom);
|
|
88
|
+
const interactionState = ctx.useValue(interactionOptionsAtom);
|
|
89
|
+
const tableName = ctx.useValue(tableNameAtom);
|
|
90
|
+
|
|
91
|
+
const toggleModalSelection = ctx.useSet(toggleModalSelectionAtom);
|
|
92
|
+
const { enableModalSelection, enableSelection } = interactionState;
|
|
93
|
+
|
|
94
|
+
const hasSelection = selection != null && selection.length > 0;
|
|
95
|
+
|
|
96
|
+
let selectionName: string | null = ctx.useValue(selectionTitleAtom);
|
|
97
|
+
|
|
98
|
+
let _name = tableName;
|
|
99
|
+
if (hasSelection) {
|
|
100
|
+
_name = selectionName ?? tableName;
|
|
101
|
+
} else if (enableModalSelection) {
|
|
102
|
+
_name = "Select";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const isClearable = hasSelection || (enableModalSelection && enableSelection);
|
|
106
|
+
|
|
107
|
+
if (minimal && !(hasSelection || enableModalSelection)) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let onClick = null;
|
|
112
|
+
let icon: string | null = null;
|
|
113
|
+
let enterSelectionButton: React.ReactNode = null;
|
|
114
|
+
if (enableModalSelection) {
|
|
115
|
+
onClick = toggleModalSelection;
|
|
116
|
+
if (!isClearable) {
|
|
117
|
+
icon = "more";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const className = classNames("selection-indicator-tag", {
|
|
122
|
+
enabled: isClearable,
|
|
123
|
+
interactive: onClick != null || hasSelection,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return h("div.selection-indicator", [
|
|
127
|
+
h(
|
|
128
|
+
Tag,
|
|
129
|
+
{
|
|
130
|
+
minimal: true,
|
|
131
|
+
large: true,
|
|
132
|
+
onClick,
|
|
133
|
+
rightIcon: icon,
|
|
134
|
+
intent: isClearable ? "primary" : undefined,
|
|
135
|
+
className,
|
|
136
|
+
onRemove: isClearable ? clearSelection : undefined,
|
|
137
|
+
},
|
|
138
|
+
[_name, enterSelectionButton],
|
|
139
|
+
),
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ALL_CARDINALITIES,
|
|
3
|
+
isColumnFilterable,
|
|
4
|
+
TableAction,
|
|
5
|
+
} from "../../actions";
|
|
6
|
+
import { ctx, storeAtom, useSelector } from "../../provider";
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import h from "../../data-panel.module.sass";
|
|
9
|
+
import { Menu, Tag } from "@blueprintjs/core";
|
|
10
|
+
import {
|
|
11
|
+
ColumnFilterMenuItem,
|
|
12
|
+
ColumnSortMenu,
|
|
13
|
+
MenuDropdown,
|
|
14
|
+
resolveColumnFilter,
|
|
15
|
+
} from "./filter-and-sort.ts";
|
|
16
|
+
import { atom } from "jotai";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Stand-in for the column-header dropdown the card list lacks: "Filter" and
|
|
20
|
+
* "Sort" menus listing the column-declared `filterable` / `sortable` fields.
|
|
21
|
+
* Each field reuses the *exact* data-sheet controls — `ColumnSortMenu`
|
|
22
|
+
* (Ascending/Descending submenu) and `ColumnFilterMenuItem` (the operator form
|
|
23
|
+
* in a submenu) — so sort/filter behave identically to the sheet and flow
|
|
24
|
+
* through the same store + provider seam (the server applies them).
|
|
25
|
+
*/
|
|
26
|
+
export function useDataPanelControls(): TableAction[] {
|
|
27
|
+
const filterAction = useUnifiedFilterAction();
|
|
28
|
+
|
|
29
|
+
const actions: TableAction[] = [];
|
|
30
|
+
if (filterAction != null) {
|
|
31
|
+
actions.push(filterAction);
|
|
32
|
+
}
|
|
33
|
+
const sortAction = useSortAction();
|
|
34
|
+
if (sortAction != null) {
|
|
35
|
+
actions.push(sortAction);
|
|
36
|
+
}
|
|
37
|
+
return actions;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function useDisplayIntent(atom) {
|
|
41
|
+
const [hasActive, clearActive] = ctx.use(atom);
|
|
42
|
+
const intent = hasActive ? "primary" : "none";
|
|
43
|
+
|
|
44
|
+
let rightIcon: "caret-down" | undefined = "caret-down";
|
|
45
|
+
let onRemove: any = undefined;
|
|
46
|
+
if (hasActive) {
|
|
47
|
+
rightIcon = undefined;
|
|
48
|
+
onRemove = (evt) => {
|
|
49
|
+
clearActive();
|
|
50
|
+
evt.stopPropagation();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { intent, rightIcon, onRemove, hasActive };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function useUnifiedFilterAction(): TableAction | null {
|
|
58
|
+
const columnSpec = useSelector((s) => s.columnSpec);
|
|
59
|
+
const filterableCols = useMemo(
|
|
60
|
+
() => columnSpec.filter((c) => isColumnFilterable(c)),
|
|
61
|
+
[columnSpec],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const rest = useDisplayIntent(hasActiveFiltersAtom);
|
|
65
|
+
|
|
66
|
+
if (filterableCols.length === 0) return null;
|
|
67
|
+
|
|
68
|
+
const filterMenu = h(
|
|
69
|
+
Menu,
|
|
70
|
+
filterableCols.map((col) =>
|
|
71
|
+
h(ColumnFilterMenuItem, {
|
|
72
|
+
key: col.key,
|
|
73
|
+
filter: resolveColumnFilter(col),
|
|
74
|
+
label: col.name,
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const filterIndicator = h(
|
|
80
|
+
Tag,
|
|
81
|
+
{
|
|
82
|
+
minimal: true,
|
|
83
|
+
large: true,
|
|
84
|
+
icon: "filter",
|
|
85
|
+
...rest,
|
|
86
|
+
},
|
|
87
|
+
"Filter",
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
id: "filter",
|
|
92
|
+
name: "Filter",
|
|
93
|
+
icon: "filter",
|
|
94
|
+
description: "Add a filter to the data panel.",
|
|
95
|
+
targets: ALL_CARDINALITIES,
|
|
96
|
+
render: (ctx) =>
|
|
97
|
+
h(
|
|
98
|
+
MenuDropdown,
|
|
99
|
+
{
|
|
100
|
+
content: filterMenu,
|
|
101
|
+
placement: "bottom-start",
|
|
102
|
+
},
|
|
103
|
+
[filterIndicator],
|
|
104
|
+
),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function useSortAction(): TableAction | null {
|
|
109
|
+
const columnSpec = useSelector((s) => s.columnSpec);
|
|
110
|
+
|
|
111
|
+
const rest = useDisplayIntent(hasActiveSortsAtom);
|
|
112
|
+
|
|
113
|
+
const sortableCols = useMemo(
|
|
114
|
+
() => columnSpec.filter((c) => c.sortable),
|
|
115
|
+
[columnSpec],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
if (sortableCols.length == 0) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const sortMenu = h(
|
|
122
|
+
Menu,
|
|
123
|
+
sortableCols.map((col) =>
|
|
124
|
+
h(ColumnSortMenu, { key: col.key, columnKey: col.key, text: col.name }),
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
id: "sort",
|
|
130
|
+
name: "Sort",
|
|
131
|
+
icon: "sort",
|
|
132
|
+
description: "Add a sort to the data panel.",
|
|
133
|
+
targets: ALL_CARDINALITIES,
|
|
134
|
+
render: (ctx) =>
|
|
135
|
+
h(MenuDropdown, { content: sortMenu }, [
|
|
136
|
+
h(
|
|
137
|
+
Tag,
|
|
138
|
+
{
|
|
139
|
+
minimal: true,
|
|
140
|
+
large: true,
|
|
141
|
+
icon: "sort",
|
|
142
|
+
...rest,
|
|
143
|
+
},
|
|
144
|
+
"Sort",
|
|
145
|
+
),
|
|
146
|
+
]),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const hasActiveFiltersAtom = atom(
|
|
151
|
+
(get) => get(storeAtom)?.activeFilters.size ?? 0 > 0,
|
|
152
|
+
(get, set) => {
|
|
153
|
+
set(storeAtom, (s) => ({ ...s, activeFilters: new Map([]) }));
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
const hasActiveSortsAtom = atom(
|
|
157
|
+
(get) => get(storeAtom)?.columnSorts.length ?? 0 > 0,
|
|
158
|
+
(get, set) => {
|
|
159
|
+
set(storeAtom, (s) => ({ ...s, columnSorts: [] }));
|
|
160
|
+
},
|
|
161
|
+
);
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import h from "
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
viewInfoAtom,
|
|
5
|
-
tableFooterAtom,
|
|
6
|
-
chunkPageAtom,
|
|
7
|
-
} from "../postgrest-table";
|
|
8
|
-
import { ctx } from "../provider.ts";
|
|
1
|
+
import h from "../../postgrest-table/main.module.sass";
|
|
2
|
+
import { tableFooterAtom, chunkPageAtom } from "../../postgrest-table";
|
|
3
|
+
import { ctx, useItemCount } from "../../provider";
|
|
9
4
|
import { Button, ButtonGroup, Icon, Spinner } from "@blueprintjs/core";
|
|
10
5
|
|
|
11
|
-
function VisibleRegionControl() {
|
|
12
|
-
const viewInfo: ViewInfo = ctx.useValue(viewInfoAtom);
|
|
13
|
-
|
|
14
|
-
return h("p", [
|
|
15
|
-
`Rows ${viewInfo.visibleRegion.rowIndexStart}–${viewInfo.visibleRegion.rowIndexEnd}`,
|
|
16
|
-
" of ",
|
|
17
|
-
h("span.total-count", viewInfo.totalCount),
|
|
18
|
-
]);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
6
|
/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In
|
|
22
7
|
* scroll mode: rows loaded, "of total" when known, and a status icon (spinner
|
|
23
8
|
* loading / check complete / dots incomplete). In paged mode: prev/next page
|
|
@@ -31,19 +16,23 @@ export function LoadProgressIndicator() {
|
|
|
31
16
|
if (loading) {
|
|
32
17
|
status = h(Spinner, { size: 12 });
|
|
33
18
|
} else if (total != null && loaded >= total) {
|
|
34
|
-
status = h(Icon, { icon: "tick
|
|
19
|
+
status = h(Icon, { icon: "tick", size: 12 });
|
|
35
20
|
} else {
|
|
36
21
|
status = h(Icon, { icon: "more", size: 12 });
|
|
37
22
|
}
|
|
38
23
|
|
|
39
|
-
return h("div.load-progress", [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
return h("div.load-progress", [h(LoadProgressLabel), status]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function LoadProgressLabel() {
|
|
28
|
+
const { loaded, total } = ctx.useValue(tableFooterAtom);
|
|
29
|
+
const expectedCount = total ?? loaded;
|
|
30
|
+
let countText = useItemCount(expectedCount);
|
|
31
|
+
if (expectedCount === 0) return countText;
|
|
32
|
+
if (total != null && loaded <= total) {
|
|
33
|
+
countText = `${loaded} of ${countText}`;
|
|
34
|
+
}
|
|
35
|
+
return h("span.load-progress-label", countText);
|
|
47
36
|
}
|
|
48
37
|
|
|
49
38
|
/** Prev/next pager for paged fetch mode. */
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
flex-direction: row
|
|
4
4
|
gap: 8px
|
|
5
5
|
align-items: center
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
background-color: var(--panel-secondary-background-color)
|
|
6
|
+
padding: 0.2em var(--data-panel-content-padding)
|
|
7
|
+
min-height: var(--panel-header-height, 40px)
|
|
9
8
|
|
|
10
9
|
// Leading label naming the current selection shape (no icon) — reads as the
|
|
11
10
|
// toolbar's title.
|
|
@@ -14,6 +13,12 @@
|
|
|
14
13
|
white-space: nowrap
|
|
15
14
|
min-width: 100px
|
|
16
15
|
|
|
16
|
+
.toolbar-group
|
|
17
|
+
display: flex
|
|
18
|
+
flex-direction: row
|
|
19
|
+
gap: 4px
|
|
20
|
+
align-items: center
|
|
21
|
+
|
|
17
22
|
.spacer
|
|
18
23
|
flex-grow: 1
|
|
19
24
|
|
|
@@ -35,16 +40,24 @@
|
|
|
35
40
|
flex-direction: row
|
|
36
41
|
flex-wrap: wrap
|
|
37
42
|
gap: 4px
|
|
38
|
-
margin-bottom: 4px
|
|
39
43
|
align-items: center
|
|
40
44
|
justify-content: flex-start
|
|
45
|
+
height: var(--filter-bar-height, 24px)
|
|
46
|
+
.description
|
|
47
|
+
margin: 0
|
|
48
|
+
color: var(--secondary-color)
|
|
49
|
+
font-size: 0.9em
|
|
41
50
|
|
|
42
51
|
&>.group
|
|
43
52
|
display: flex
|
|
44
53
|
flex-direction: row
|
|
45
54
|
gap: 4px
|
|
46
55
|
|
|
56
|
+
.filter-tag
|
|
57
|
+
display: flex
|
|
58
|
+
|
|
47
59
|
// The current filter window shown after the filter name on its tag
|
|
48
60
|
.filter-window
|
|
49
61
|
opacity: 0.8
|
|
50
62
|
font-variant-numeric: tabular-nums
|
|
63
|
+
|