@macrostrat/data-sheet 4.1.0 → 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 +40 -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 -184
- 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 -182
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -50
- 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 -51
- 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-controls.cjs → table-actions.cjs} +7 -24
- 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 -19
- 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} +36 -97
- 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 -181
- 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 -150
- 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 +21 -4
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +5 -4
- package/dist/filters/operators.js +21 -4
- 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 +129 -103
- 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 +110 -84
- 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 +77 -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} +37 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +22 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +68 -35
- 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} +66 -33
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +40 -17
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +2 -2
- package/dist/renderers/column-header-cell.js +40 -17
- 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 +123 -226
- 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 -228
- package/src/actions/column-filter.ts +28 -63
- 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 -20
- 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} +53 -126
- 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} +144 -306
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +38 -6
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +250 -181
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +34 -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} +36 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +146 -58
- package/src/renderers/column-header-cell.ts +51 -17
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +143 -236
- 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.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -246
- 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 -113
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -191
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -25
- package/dist/provider.js +0 -189
- 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 -250
- 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,111 @@
|
|
|
1
|
+
import { atom } from "jotai";
|
|
2
|
+
import { RegionCardinality } from "@blueprintjs/table";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import h from "./selection.module.sass.js";
|
|
5
|
+
import { Tag } from "@blueprintjs/core";
|
|
6
|
+
import { interactionOptionsAtom } from "../../provider/interactions.js";
|
|
7
|
+
import { ctx, tableNameAtom, itemLabelAtom, columnSpecAtom, pluralize } from "../../provider/core.js";
|
|
8
|
+
import { selectionAtom } from "../../provider/selection.js";
|
|
9
|
+
import { computeSelectionShape, getSelectedColumnKeys } from "../../actions/selection.js";
|
|
10
|
+
const selectionTitleAtom = atom((get) => {
|
|
11
|
+
const sel = get(selectionAtom);
|
|
12
|
+
if (sel == null || sel.length === 0) return null;
|
|
13
|
+
const sh = computeSelectionShape(sel);
|
|
14
|
+
const itemName = get(itemLabelAtom);
|
|
15
|
+
switch (sh.cardinality) {
|
|
16
|
+
case RegionCardinality.FULL_COLUMNS: {
|
|
17
|
+
if (sh.columns == 1) {
|
|
18
|
+
const columnSpec = get(columnSpecAtom);
|
|
19
|
+
const columnKey = getSelectedColumnKeys(sel, columnSpec)[0];
|
|
20
|
+
const col = columnSpec.find((c) => c.key === columnKey);
|
|
21
|
+
return col?.name ?? "1 column";
|
|
22
|
+
}
|
|
23
|
+
return itemCount(sh.columns, "column");
|
|
24
|
+
}
|
|
25
|
+
case RegionCardinality.FULL_ROWS:
|
|
26
|
+
return itemCount(sh.rows, itemName);
|
|
27
|
+
case RegionCardinality.CELLS:
|
|
28
|
+
if (sh.columns == 1 || sh.rows == 1) {
|
|
29
|
+
const nCells = Math.max(sh.columns, sh.rows);
|
|
30
|
+
return itemCount(nCells, "cell");
|
|
31
|
+
}
|
|
32
|
+
return `${sh.columns}×${sh.rows} cells`;
|
|
33
|
+
case RegionCardinality.FULL_TABLE:
|
|
34
|
+
return null;
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function itemCount(n, itemType) {
|
|
40
|
+
return `${n} ` + pluralize(itemType, n);
|
|
41
|
+
}
|
|
42
|
+
const toggleModalSelectionAtom = atom(null, (get, set) => {
|
|
43
|
+
const interactionState = get(interactionOptionsAtom);
|
|
44
|
+
if (interactionState.enableModalSelection) {
|
|
45
|
+
const enableSelection = !interactionState.enableSelection;
|
|
46
|
+
if (!enableSelection) {
|
|
47
|
+
set(clearableSelectionAtom);
|
|
48
|
+
}
|
|
49
|
+
set(interactionOptionsAtom, {
|
|
50
|
+
...interactionState,
|
|
51
|
+
enableSelection
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const clearableSelectionAtom = atom(
|
|
56
|
+
(get) => get(selectionAtom),
|
|
57
|
+
(get, set) => {
|
|
58
|
+
set(selectionAtom, []);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
function SelectionIndicator({ minimal = true }) {
|
|
62
|
+
const [selection, clearSelection] = ctx.use(clearableSelectionAtom);
|
|
63
|
+
const interactionState = ctx.useValue(interactionOptionsAtom);
|
|
64
|
+
const tableName = ctx.useValue(tableNameAtom);
|
|
65
|
+
const toggleModalSelection = ctx.useSet(toggleModalSelectionAtom);
|
|
66
|
+
const { enableModalSelection, enableSelection } = interactionState;
|
|
67
|
+
const hasSelection = selection != null && selection.length > 0;
|
|
68
|
+
let selectionName = ctx.useValue(selectionTitleAtom);
|
|
69
|
+
let _name = tableName;
|
|
70
|
+
if (hasSelection) {
|
|
71
|
+
_name = selectionName ?? tableName;
|
|
72
|
+
} else if (enableModalSelection) {
|
|
73
|
+
_name = "Select";
|
|
74
|
+
}
|
|
75
|
+
const isClearable = hasSelection || enableModalSelection && enableSelection;
|
|
76
|
+
if (minimal && !(hasSelection || enableModalSelection)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
let onClick = null;
|
|
80
|
+
let icon = null;
|
|
81
|
+
let enterSelectionButton = null;
|
|
82
|
+
if (enableModalSelection) {
|
|
83
|
+
onClick = toggleModalSelection;
|
|
84
|
+
if (!isClearable) {
|
|
85
|
+
icon = "more";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const className = classNames("selection-indicator-tag", {
|
|
89
|
+
enabled: isClearable,
|
|
90
|
+
interactive: onClick != null || hasSelection
|
|
91
|
+
});
|
|
92
|
+
return h("div.selection-indicator", [
|
|
93
|
+
h(
|
|
94
|
+
Tag,
|
|
95
|
+
{
|
|
96
|
+
minimal: true,
|
|
97
|
+
large: true,
|
|
98
|
+
onClick,
|
|
99
|
+
rightIcon: icon,
|
|
100
|
+
intent: isClearable ? "primary" : void 0,
|
|
101
|
+
className,
|
|
102
|
+
onRemove: isClearable ? clearSelection : void 0
|
|
103
|
+
},
|
|
104
|
+
[_name, enterSelectionButton]
|
|
105
|
+
)
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
SelectionIndicator
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sources":["../../../src/components/indicators/selection.ts"],"sourcesContent":["import {\n columnSpecAtom,\n ctx,\n interactionOptionsAtom,\n itemLabelAtom,\n pluralize,\n selectionAtom,\n tableNameAtom,\n} from \"../../provider\";\nimport { atom } from \"jotai\";\nimport { computeSelectionShape, getSelectedColumnKeys } from \"../../actions\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport classNames from \"classnames\";\nimport h from \"./selection.module.sass\";\nimport { Tag } from \"@blueprintjs/core\";\n\n/** A short title describing the current selection (its shape), shown as the\n * toolbar's leading label — no icon. */\nconst selectionTitleAtom = atom<string | null>((get) => {\n const sel = get(selectionAtom);\n if (sel == null || sel.length === 0) return null;\n const sh = computeSelectionShape(sel);\n const itemName = get(itemLabelAtom);\n\n switch (sh.cardinality) {\n case RegionCardinality.FULL_COLUMNS: {\n if (sh.columns == 1) {\n const columnSpec = get(columnSpecAtom);\n const columnKey = getSelectedColumnKeys(sel, columnSpec)[0];\n const col = columnSpec.find((c) => c.key === columnKey);\n return col?.name ?? \"1 column\";\n }\n return itemCount(sh.columns, \"column\");\n }\n case RegionCardinality.FULL_ROWS:\n return itemCount(sh.rows, itemName);\n case RegionCardinality.CELLS:\n if (sh.columns == 1 || sh.rows == 1) {\n const nCells = Math.max(sh.columns, sh.rows);\n return itemCount(nCells, \"cell\");\n }\n return `${sh.columns}×${sh.rows} cells`;\n case RegionCardinality.FULL_TABLE:\n return null;\n default:\n return null;\n }\n});\n\nfunction itemCount(n: number, itemType: string) {\n return `${n} ` + pluralize(itemType, n);\n}\n\nconst toggleModalSelectionAtom = atom(null, (get, set) => {\n const interactionState = get(interactionOptionsAtom);\n if (interactionState.enableModalSelection) {\n const enableSelection = !interactionState.enableSelection;\n\n if (!enableSelection) {\n set(clearableSelectionAtom);\n }\n\n set(interactionOptionsAtom, {\n ...interactionState,\n enableSelection,\n });\n }\n});\nconst clearableSelectionAtom = atom(\n (get) => get(selectionAtom),\n (get, set) => {\n set(selectionAtom, []);\n },\n);\n\nexport function SelectionIndicator({ minimal = true }: { minimal?: boolean }) {\n /** An indicator that shows the table's current selection shape, and optionally modal selection status */\n // The leading title doubles as the clear-selection affordance: with an active\n // selection it renders as a dismissible tag (its ✕ clears the selection),\n // which ties \"clear\" to the selection it acts on and frees toolbar space.\n // With no selection it's a plain label (table name).\n // Both states render as a `large` `Tag` so the title keeps a constant font\n // and height; only the selected one has a filled background + a ✕ (which\n // clears the selection). The unselected label is a transparent, non-removable\n // tag — visually a plain title, but the same box.\n\n const [selection, clearSelection] = ctx.use(clearableSelectionAtom);\n const interactionState = ctx.useValue(interactionOptionsAtom);\n const tableName = ctx.useValue(tableNameAtom);\n\n const toggleModalSelection = ctx.useSet(toggleModalSelectionAtom);\n const { enableModalSelection, enableSelection } = interactionState;\n\n const hasSelection = selection != null && selection.length > 0;\n\n let selectionName: string | null = ctx.useValue(selectionTitleAtom);\n\n let _name = tableName;\n if (hasSelection) {\n _name = selectionName ?? tableName;\n } else if (enableModalSelection) {\n _name = \"Select\";\n }\n\n const isClearable = hasSelection || (enableModalSelection && enableSelection);\n\n if (minimal && !(hasSelection || enableModalSelection)) {\n return null;\n }\n\n let onClick = null;\n let icon: string | null = null;\n let enterSelectionButton: React.ReactNode = null;\n if (enableModalSelection) {\n onClick = toggleModalSelection;\n if (!isClearable) {\n icon = \"more\";\n }\n }\n\n const className = classNames(\"selection-indicator-tag\", {\n enabled: isClearable,\n interactive: onClick != null || hasSelection,\n });\n\n return h(\"div.selection-indicator\", [\n h(\n Tag,\n {\n minimal: true,\n large: true,\n onClick,\n rightIcon: icon,\n intent: isClearable ? \"primary\" : undefined,\n className,\n onRemove: isClearable ? clearSelection : undefined,\n },\n [_name, enterSelectionButton],\n ),\n ]);\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const h$1 = require("@macrostrat/hyper");
|
|
4
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
6
|
+
const enabled = "_enabled_1648m_13";
|
|
7
|
+
const interactive = "_interactive_1648m_16";
|
|
8
|
+
const styles = {
|
|
9
|
+
"selection-indicator": "_selection-indicator_1648m_1",
|
|
10
|
+
"selection-indicator-tag": "_selection-indicator-tag_1648m_5",
|
|
11
|
+
enabled,
|
|
12
|
+
interactive
|
|
13
|
+
};
|
|
14
|
+
let h = h__default.default.styled(styles);
|
|
15
|
+
Object.assign(h, styles);
|
|
16
|
+
exports.default = h;
|
|
17
|
+
exports.enabled = enabled;
|
|
18
|
+
exports.interactive = interactive;
|
|
19
|
+
//# sourceMappingURL=selection.module.sass.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
2
|
+
const enabled = "_enabled_1648m_13";
|
|
3
|
+
const interactive = "_interactive_1648m_16";
|
|
4
|
+
const styles = {
|
|
5
|
+
"selection-indicator": "_selection-indicator_1648m_1",
|
|
6
|
+
"selection-indicator-tag": "_selection-indicator-tag_1648m_5",
|
|
7
|
+
enabled,
|
|
8
|
+
interactive
|
|
9
|
+
};
|
|
10
|
+
let h = h$1.styled(styles);
|
|
11
|
+
Object.assign(h, styles);
|
|
12
|
+
export {
|
|
13
|
+
h as default,
|
|
14
|
+
enabled,
|
|
15
|
+
interactive
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=selection.module.sass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const dataPanel_module = require("../../data-panel.module.sass.cjs");
|
|
5
|
+
const core$1 = require("@blueprintjs/core");
|
|
6
|
+
const filterAndSort = require("./filter-and-sort.cjs");
|
|
7
|
+
const jotai = require("jotai");
|
|
8
|
+
const columnControls = require("../../actions/column-controls.cjs");
|
|
9
|
+
const core = require("../../provider/core.cjs");
|
|
10
|
+
const editActions = require("../../actions/edit-actions.cjs");
|
|
11
|
+
function useDataPanelControls() {
|
|
12
|
+
const filterAction = useUnifiedFilterAction();
|
|
13
|
+
const actions = [];
|
|
14
|
+
if (filterAction != null) {
|
|
15
|
+
actions.push(filterAction);
|
|
16
|
+
}
|
|
17
|
+
const sortAction = useSortAction();
|
|
18
|
+
if (sortAction != null) {
|
|
19
|
+
actions.push(sortAction);
|
|
20
|
+
}
|
|
21
|
+
return actions;
|
|
22
|
+
}
|
|
23
|
+
function useDisplayIntent(atom2) {
|
|
24
|
+
const [hasActive, clearActive] = core.ctx.use(atom2);
|
|
25
|
+
const intent = hasActive ? "primary" : "none";
|
|
26
|
+
let rightIcon = "caret-down";
|
|
27
|
+
let onRemove = void 0;
|
|
28
|
+
if (hasActive) {
|
|
29
|
+
rightIcon = void 0;
|
|
30
|
+
onRemove = (evt) => {
|
|
31
|
+
clearActive();
|
|
32
|
+
evt.stopPropagation();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return { intent, rightIcon, onRemove, hasActive };
|
|
36
|
+
}
|
|
37
|
+
function useUnifiedFilterAction() {
|
|
38
|
+
const columnSpec = core.useSelector((s) => s.columnSpec);
|
|
39
|
+
const filterableCols = react.useMemo(
|
|
40
|
+
() => columnSpec.filter((c) => columnControls.isColumnFilterable(c)),
|
|
41
|
+
[columnSpec]
|
|
42
|
+
);
|
|
43
|
+
const rest = useDisplayIntent(hasActiveFiltersAtom);
|
|
44
|
+
if (filterableCols.length === 0) return null;
|
|
45
|
+
const filterMenu = dataPanel_module.default(
|
|
46
|
+
core$1.Menu,
|
|
47
|
+
filterableCols.map(
|
|
48
|
+
(col) => dataPanel_module.default(filterAndSort.ColumnFilterMenuItem, {
|
|
49
|
+
key: col.key,
|
|
50
|
+
filter: filterAndSort.resolveColumnFilter(col),
|
|
51
|
+
label: col.name
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
const filterIndicator = dataPanel_module.default(
|
|
56
|
+
core$1.Tag,
|
|
57
|
+
{
|
|
58
|
+
minimal: true,
|
|
59
|
+
large: true,
|
|
60
|
+
icon: "filter",
|
|
61
|
+
...rest
|
|
62
|
+
},
|
|
63
|
+
"Filter"
|
|
64
|
+
);
|
|
65
|
+
return {
|
|
66
|
+
id: "filter",
|
|
67
|
+
name: "Filter",
|
|
68
|
+
icon: "filter",
|
|
69
|
+
description: "Add a filter to the data panel.",
|
|
70
|
+
targets: editActions.ALL_CARDINALITIES,
|
|
71
|
+
render: (ctx2) => dataPanel_module.default(
|
|
72
|
+
filterAndSort.MenuDropdown,
|
|
73
|
+
{
|
|
74
|
+
content: filterMenu,
|
|
75
|
+
placement: "bottom-start"
|
|
76
|
+
},
|
|
77
|
+
[filterIndicator]
|
|
78
|
+
)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function useSortAction() {
|
|
82
|
+
const columnSpec = core.useSelector((s) => s.columnSpec);
|
|
83
|
+
const rest = useDisplayIntent(hasActiveSortsAtom);
|
|
84
|
+
const sortableCols = react.useMemo(
|
|
85
|
+
() => columnSpec.filter((c) => c.sortable),
|
|
86
|
+
[columnSpec]
|
|
87
|
+
);
|
|
88
|
+
if (sortableCols.length == 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const sortMenu = dataPanel_module.default(
|
|
92
|
+
core$1.Menu,
|
|
93
|
+
sortableCols.map(
|
|
94
|
+
(col) => dataPanel_module.default(filterAndSort.ColumnSortMenu, { key: col.key, columnKey: col.key, text: col.name })
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
return {
|
|
98
|
+
id: "sort",
|
|
99
|
+
name: "Sort",
|
|
100
|
+
icon: "sort",
|
|
101
|
+
description: "Add a sort to the data panel.",
|
|
102
|
+
targets: editActions.ALL_CARDINALITIES,
|
|
103
|
+
render: (ctx2) => dataPanel_module.default(filterAndSort.MenuDropdown, { content: sortMenu }, [
|
|
104
|
+
dataPanel_module.default(
|
|
105
|
+
core$1.Tag,
|
|
106
|
+
{
|
|
107
|
+
minimal: true,
|
|
108
|
+
large: true,
|
|
109
|
+
icon: "sort",
|
|
110
|
+
...rest
|
|
111
|
+
},
|
|
112
|
+
"Sort"
|
|
113
|
+
)
|
|
114
|
+
])
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const hasActiveFiltersAtom = jotai.atom(
|
|
118
|
+
(get) => get(core.storeAtom)?.activeFilters.size ?? 0 > 0,
|
|
119
|
+
(get, set) => {
|
|
120
|
+
set(core.storeAtom, (s) => ({ ...s, activeFilters: /* @__PURE__ */ new Map([]) }));
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
const hasActiveSortsAtom = jotai.atom(
|
|
124
|
+
(get) => get(core.storeAtom)?.columnSorts.length ?? 0 > 0,
|
|
125
|
+
(get, set) => {
|
|
126
|
+
set(core.storeAtom, (s) => ({ ...s, columnSorts: [] }));
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
exports.useDataPanelControls = useDataPanelControls;
|
|
130
|
+
//# sourceMappingURL=unified-filters.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-filters.cjs","sources":["../../../src/components/indicators/unified-filters.ts"],"sourcesContent":["import {\n ALL_CARDINALITIES,\n isColumnFilterable,\n TableAction,\n} from \"../../actions\";\nimport { ctx, storeAtom, useSelector } from \"../../provider\";\nimport { useMemo } from \"react\";\nimport h from \"../../data-panel.module.sass\";\nimport { Menu, Tag } from \"@blueprintjs/core\";\nimport {\n ColumnFilterMenuItem,\n ColumnSortMenu,\n MenuDropdown,\n resolveColumnFilter,\n} from \"./filter-and-sort.ts\";\nimport { atom } from \"jotai\";\n\n/**\n * Stand-in for the column-header dropdown the card list lacks: \"Filter\" and\n * \"Sort\" menus listing the column-declared `filterable` / `sortable` fields.\n * Each field reuses the *exact* data-sheet controls — `ColumnSortMenu`\n * (Ascending/Descending submenu) and `ColumnFilterMenuItem` (the operator form\n * in a submenu) — so sort/filter behave identically to the sheet and flow\n * through the same store + provider seam (the server applies them).\n */\nexport function useDataPanelControls(): TableAction[] {\n const filterAction = useUnifiedFilterAction();\n\n const actions: TableAction[] = [];\n if (filterAction != null) {\n actions.push(filterAction);\n }\n const sortAction = useSortAction();\n if (sortAction != null) {\n actions.push(sortAction);\n }\n return actions;\n}\n\nfunction useDisplayIntent(atom) {\n const [hasActive, clearActive] = ctx.use(atom);\n const intent = hasActive ? \"primary\" : \"none\";\n\n let rightIcon: \"caret-down\" | undefined = \"caret-down\";\n let onRemove: any = undefined;\n if (hasActive) {\n rightIcon = undefined;\n onRemove = (evt) => {\n clearActive();\n evt.stopPropagation();\n };\n }\n\n return { intent, rightIcon, onRemove, hasActive };\n}\n\nfunction useUnifiedFilterAction(): TableAction | null {\n const columnSpec = useSelector((s) => s.columnSpec);\n const filterableCols = useMemo(\n () => columnSpec.filter((c) => isColumnFilterable(c)),\n [columnSpec],\n );\n\n const rest = useDisplayIntent(hasActiveFiltersAtom);\n\n if (filterableCols.length === 0) return null;\n\n const filterMenu = h(\n Menu,\n filterableCols.map((col) =>\n h(ColumnFilterMenuItem, {\n key: col.key,\n filter: resolveColumnFilter(col),\n label: col.name,\n }),\n ),\n );\n\n const filterIndicator = h(\n Tag,\n {\n minimal: true,\n large: true,\n icon: \"filter\",\n ...rest,\n },\n \"Filter\",\n );\n\n return {\n id: \"filter\",\n name: \"Filter\",\n icon: \"filter\",\n description: \"Add a filter to the data panel.\",\n targets: ALL_CARDINALITIES,\n render: (ctx) =>\n h(\n MenuDropdown,\n {\n content: filterMenu,\n placement: \"bottom-start\",\n },\n [filterIndicator],\n ),\n };\n}\n\nfunction useSortAction(): TableAction | null {\n const columnSpec = useSelector((s) => s.columnSpec);\n\n const rest = useDisplayIntent(hasActiveSortsAtom);\n\n const sortableCols = useMemo(\n () => columnSpec.filter((c) => c.sortable),\n [columnSpec],\n );\n\n if (sortableCols.length == 0) {\n return null;\n }\n const sortMenu = h(\n Menu,\n sortableCols.map((col) =>\n h(ColumnSortMenu, { key: col.key, columnKey: col.key, text: col.name }),\n ),\n );\n\n return {\n id: \"sort\",\n name: \"Sort\",\n icon: \"sort\",\n description: \"Add a sort to the data panel.\",\n targets: ALL_CARDINALITIES,\n render: (ctx) =>\n h(MenuDropdown, { content: sortMenu }, [\n h(\n Tag,\n {\n minimal: true,\n large: true,\n icon: \"sort\",\n ...rest,\n },\n \"Sort\",\n ),\n ]),\n };\n}\n\nconst hasActiveFiltersAtom = atom(\n (get) => get(storeAtom)?.activeFilters.size ?? 0 > 0,\n (get, set) => {\n set(storeAtom, (s) => ({ ...s, activeFilters: new Map([]) }));\n },\n);\nconst hasActiveSortsAtom = atom(\n (get) => get(storeAtom)?.columnSorts.length ?? 0 > 0,\n (get, set) => {\n set(storeAtom, (s) => ({ ...s, columnSorts: [] }));\n },\n);\n"],"names":["atom","ctx","useSelector","useMemo","isColumnFilterable","h","Menu","ColumnFilterMenuItem","resolveColumnFilter","Tag","ALL_CARDINALITIES","MenuDropdown","ColumnSortMenu","storeAtom"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TableAction } from '../../actions';
|
|
2
|
+
/**
|
|
3
|
+
* Stand-in for the column-header dropdown the card list lacks: "Filter" and
|
|
4
|
+
* "Sort" menus listing the column-declared `filterable` / `sortable` fields.
|
|
5
|
+
* Each field reuses the *exact* data-sheet controls — `ColumnSortMenu`
|
|
6
|
+
* (Ascending/Descending submenu) and `ColumnFilterMenuItem` (the operator form
|
|
7
|
+
* in a submenu) — so sort/filter behave identically to the sheet and flow
|
|
8
|
+
* through the same store + provider seam (the server applies them).
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDataPanelControls(): TableAction[];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import h from "../../data-panel.module.sass.js";
|
|
3
|
+
import { Menu, Tag } from "@blueprintjs/core";
|
|
4
|
+
import { ColumnFilterMenuItem, resolveColumnFilter, MenuDropdown, ColumnSortMenu } from "./filter-and-sort.js";
|
|
5
|
+
import { atom } from "jotai";
|
|
6
|
+
import { isColumnFilterable } from "../../actions/column-controls.js";
|
|
7
|
+
import { useSelector, ctx, storeAtom } from "../../provider/core.js";
|
|
8
|
+
import { ALL_CARDINALITIES } from "../../actions/edit-actions.js";
|
|
9
|
+
function useDataPanelControls() {
|
|
10
|
+
const filterAction = useUnifiedFilterAction();
|
|
11
|
+
const actions = [];
|
|
12
|
+
if (filterAction != null) {
|
|
13
|
+
actions.push(filterAction);
|
|
14
|
+
}
|
|
15
|
+
const sortAction = useSortAction();
|
|
16
|
+
if (sortAction != null) {
|
|
17
|
+
actions.push(sortAction);
|
|
18
|
+
}
|
|
19
|
+
return actions;
|
|
20
|
+
}
|
|
21
|
+
function useDisplayIntent(atom2) {
|
|
22
|
+
const [hasActive, clearActive] = ctx.use(atom2);
|
|
23
|
+
const intent = hasActive ? "primary" : "none";
|
|
24
|
+
let rightIcon = "caret-down";
|
|
25
|
+
let onRemove = void 0;
|
|
26
|
+
if (hasActive) {
|
|
27
|
+
rightIcon = void 0;
|
|
28
|
+
onRemove = (evt) => {
|
|
29
|
+
clearActive();
|
|
30
|
+
evt.stopPropagation();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { intent, rightIcon, onRemove, hasActive };
|
|
34
|
+
}
|
|
35
|
+
function useUnifiedFilterAction() {
|
|
36
|
+
const columnSpec = useSelector((s) => s.columnSpec);
|
|
37
|
+
const filterableCols = useMemo(
|
|
38
|
+
() => columnSpec.filter((c) => isColumnFilterable(c)),
|
|
39
|
+
[columnSpec]
|
|
40
|
+
);
|
|
41
|
+
const rest = useDisplayIntent(hasActiveFiltersAtom);
|
|
42
|
+
if (filterableCols.length === 0) return null;
|
|
43
|
+
const filterMenu = h(
|
|
44
|
+
Menu,
|
|
45
|
+
filterableCols.map(
|
|
46
|
+
(col) => h(ColumnFilterMenuItem, {
|
|
47
|
+
key: col.key,
|
|
48
|
+
filter: resolveColumnFilter(col),
|
|
49
|
+
label: col.name
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
const filterIndicator = h(
|
|
54
|
+
Tag,
|
|
55
|
+
{
|
|
56
|
+
minimal: true,
|
|
57
|
+
large: true,
|
|
58
|
+
icon: "filter",
|
|
59
|
+
...rest
|
|
60
|
+
},
|
|
61
|
+
"Filter"
|
|
62
|
+
);
|
|
63
|
+
return {
|
|
64
|
+
id: "filter",
|
|
65
|
+
name: "Filter",
|
|
66
|
+
icon: "filter",
|
|
67
|
+
description: "Add a filter to the data panel.",
|
|
68
|
+
targets: ALL_CARDINALITIES,
|
|
69
|
+
render: (ctx2) => h(
|
|
70
|
+
MenuDropdown,
|
|
71
|
+
{
|
|
72
|
+
content: filterMenu,
|
|
73
|
+
placement: "bottom-start"
|
|
74
|
+
},
|
|
75
|
+
[filterIndicator]
|
|
76
|
+
)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function useSortAction() {
|
|
80
|
+
const columnSpec = useSelector((s) => s.columnSpec);
|
|
81
|
+
const rest = useDisplayIntent(hasActiveSortsAtom);
|
|
82
|
+
const sortableCols = useMemo(
|
|
83
|
+
() => columnSpec.filter((c) => c.sortable),
|
|
84
|
+
[columnSpec]
|
|
85
|
+
);
|
|
86
|
+
if (sortableCols.length == 0) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const sortMenu = h(
|
|
90
|
+
Menu,
|
|
91
|
+
sortableCols.map(
|
|
92
|
+
(col) => h(ColumnSortMenu, { key: col.key, columnKey: col.key, text: col.name })
|
|
93
|
+
)
|
|
94
|
+
);
|
|
95
|
+
return {
|
|
96
|
+
id: "sort",
|
|
97
|
+
name: "Sort",
|
|
98
|
+
icon: "sort",
|
|
99
|
+
description: "Add a sort to the data panel.",
|
|
100
|
+
targets: ALL_CARDINALITIES,
|
|
101
|
+
render: (ctx2) => h(MenuDropdown, { content: sortMenu }, [
|
|
102
|
+
h(
|
|
103
|
+
Tag,
|
|
104
|
+
{
|
|
105
|
+
minimal: true,
|
|
106
|
+
large: true,
|
|
107
|
+
icon: "sort",
|
|
108
|
+
...rest
|
|
109
|
+
},
|
|
110
|
+
"Sort"
|
|
111
|
+
)
|
|
112
|
+
])
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const hasActiveFiltersAtom = atom(
|
|
116
|
+
(get) => get(storeAtom)?.activeFilters.size ?? 0 > 0,
|
|
117
|
+
(get, set) => {
|
|
118
|
+
set(storeAtom, (s) => ({ ...s, activeFilters: /* @__PURE__ */ new Map([]) }));
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
const hasActiveSortsAtom = atom(
|
|
122
|
+
(get) => get(storeAtom)?.columnSorts.length ?? 0 > 0,
|
|
123
|
+
(get, set) => {
|
|
124
|
+
set(storeAtom, (s) => ({ ...s, columnSorts: [] }));
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
export {
|
|
128
|
+
useDataPanelControls
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=unified-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-filters.js","sources":["../../../src/components/indicators/unified-filters.ts"],"sourcesContent":["import {\n ALL_CARDINALITIES,\n isColumnFilterable,\n TableAction,\n} from \"../../actions\";\nimport { ctx, storeAtom, useSelector } from \"../../provider\";\nimport { useMemo } from \"react\";\nimport h from \"../../data-panel.module.sass\";\nimport { Menu, Tag } from \"@blueprintjs/core\";\nimport {\n ColumnFilterMenuItem,\n ColumnSortMenu,\n MenuDropdown,\n resolveColumnFilter,\n} from \"./filter-and-sort.ts\";\nimport { atom } from \"jotai\";\n\n/**\n * Stand-in for the column-header dropdown the card list lacks: \"Filter\" and\n * \"Sort\" menus listing the column-declared `filterable` / `sortable` fields.\n * Each field reuses the *exact* data-sheet controls — `ColumnSortMenu`\n * (Ascending/Descending submenu) and `ColumnFilterMenuItem` (the operator form\n * in a submenu) — so sort/filter behave identically to the sheet and flow\n * through the same store + provider seam (the server applies them).\n */\nexport function useDataPanelControls(): TableAction[] {\n const filterAction = useUnifiedFilterAction();\n\n const actions: TableAction[] = [];\n if (filterAction != null) {\n actions.push(filterAction);\n }\n const sortAction = useSortAction();\n if (sortAction != null) {\n actions.push(sortAction);\n }\n return actions;\n}\n\nfunction useDisplayIntent(atom) {\n const [hasActive, clearActive] = ctx.use(atom);\n const intent = hasActive ? \"primary\" : \"none\";\n\n let rightIcon: \"caret-down\" | undefined = \"caret-down\";\n let onRemove: any = undefined;\n if (hasActive) {\n rightIcon = undefined;\n onRemove = (evt) => {\n clearActive();\n evt.stopPropagation();\n };\n }\n\n return { intent, rightIcon, onRemove, hasActive };\n}\n\nfunction useUnifiedFilterAction(): TableAction | null {\n const columnSpec = useSelector((s) => s.columnSpec);\n const filterableCols = useMemo(\n () => columnSpec.filter((c) => isColumnFilterable(c)),\n [columnSpec],\n );\n\n const rest = useDisplayIntent(hasActiveFiltersAtom);\n\n if (filterableCols.length === 0) return null;\n\n const filterMenu = h(\n Menu,\n filterableCols.map((col) =>\n h(ColumnFilterMenuItem, {\n key: col.key,\n filter: resolveColumnFilter(col),\n label: col.name,\n }),\n ),\n );\n\n const filterIndicator = h(\n Tag,\n {\n minimal: true,\n large: true,\n icon: \"filter\",\n ...rest,\n },\n \"Filter\",\n );\n\n return {\n id: \"filter\",\n name: \"Filter\",\n icon: \"filter\",\n description: \"Add a filter to the data panel.\",\n targets: ALL_CARDINALITIES,\n render: (ctx) =>\n h(\n MenuDropdown,\n {\n content: filterMenu,\n placement: \"bottom-start\",\n },\n [filterIndicator],\n ),\n };\n}\n\nfunction useSortAction(): TableAction | null {\n const columnSpec = useSelector((s) => s.columnSpec);\n\n const rest = useDisplayIntent(hasActiveSortsAtom);\n\n const sortableCols = useMemo(\n () => columnSpec.filter((c) => c.sortable),\n [columnSpec],\n );\n\n if (sortableCols.length == 0) {\n return null;\n }\n const sortMenu = h(\n Menu,\n sortableCols.map((col) =>\n h(ColumnSortMenu, { key: col.key, columnKey: col.key, text: col.name }),\n ),\n );\n\n return {\n id: \"sort\",\n name: \"Sort\",\n icon: \"sort\",\n description: \"Add a sort to the data panel.\",\n targets: ALL_CARDINALITIES,\n render: (ctx) =>\n h(MenuDropdown, { content: sortMenu }, [\n h(\n Tag,\n {\n minimal: true,\n large: true,\n icon: \"sort\",\n ...rest,\n },\n \"Sort\",\n ),\n ]),\n };\n}\n\nconst hasActiveFiltersAtom = atom(\n (get) => get(storeAtom)?.activeFilters.size ?? 0 > 0,\n (get, set) => {\n set(storeAtom, (s) => ({ ...s, activeFilters: new Map([]) }));\n },\n);\nconst hasActiveSortsAtom = atom(\n (get) => get(storeAtom)?.columnSorts.length ?? 0 > 0,\n (get, set) => {\n set(storeAtom, (s) => ({ ...s, columnSorts: [] }));\n },\n);\n"],"names":["atom","ctx"],"mappings":"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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const main_module = require("../../postgrest-table/main.module.sass.cjs");
|
|
4
|
+
const core$1 = require("@blueprintjs/core");
|
|
5
|
+
const dataLoaders = require("../../postgrest-table/data-loaders.cjs");
|
|
6
|
+
const core = require("../../provider/core.cjs");
|
|
7
|
+
function LoadProgressIndicator() {
|
|
8
|
+
const footer = core.ctx.useValue(dataLoaders.tableFooterAtom);
|
|
9
|
+
if (footer.mode === "paged") return main_module.default(PageControl);
|
|
10
|
+
const { loaded, total, loading } = footer;
|
|
11
|
+
let status;
|
|
12
|
+
if (loading) {
|
|
13
|
+
status = main_module.default(core$1.Spinner, { size: 12 });
|
|
14
|
+
} else if (total != null && loaded >= total) {
|
|
15
|
+
status = main_module.default(core$1.Icon, { icon: "tick", size: 12 });
|
|
16
|
+
} else {
|
|
17
|
+
status = main_module.default(core$1.Icon, { icon: "more", size: 12 });
|
|
18
|
+
}
|
|
19
|
+
return main_module.default("div.load-progress", [main_module.default(LoadProgressLabel), status]);
|
|
20
|
+
}
|
|
21
|
+
function LoadProgressLabel() {
|
|
22
|
+
const { loaded, total } = core.ctx.useValue(dataLoaders.tableFooterAtom);
|
|
23
|
+
const expectedCount = total ?? loaded;
|
|
24
|
+
let countText = core.useItemCount(expectedCount);
|
|
25
|
+
if (expectedCount === 0) return countText;
|
|
26
|
+
if (total != null && loaded <= total) {
|
|
27
|
+
countText = `${loaded} of ${countText}`;
|
|
28
|
+
}
|
|
29
|
+
return main_module.default("span.load-progress-label", countText);
|
|
30
|
+
}
|
|
31
|
+
function PageControl() {
|
|
32
|
+
const { page, totalPages, loading } = core.ctx.useValue(dataLoaders.tableFooterAtom);
|
|
33
|
+
const setPage = core.ctx.useSet(dataLoaders.chunkPageAtom);
|
|
34
|
+
const atEnd = totalPages != null && page >= totalPages - 1;
|
|
35
|
+
return main_module.default("div.load-progress", [
|
|
36
|
+
loading ? main_module.default(core$1.Spinner, { size: 12 }) : null,
|
|
37
|
+
main_module.default("span.load-progress-label", [
|
|
38
|
+
`Page ${page + 1}`,
|
|
39
|
+
totalPages != null ? ` of ${totalPages}` : ""
|
|
40
|
+
]),
|
|
41
|
+
main_module.default(core$1.ButtonGroup, { minimal: true }, [
|
|
42
|
+
main_module.default(core$1.Button, {
|
|
43
|
+
icon: "chevron-left",
|
|
44
|
+
small: true,
|
|
45
|
+
disabled: page <= 0 || loading,
|
|
46
|
+
onClick: () => setPage(Math.max(0, page - 1))
|
|
47
|
+
}),
|
|
48
|
+
main_module.default(core$1.Button, {
|
|
49
|
+
icon: "chevron-right",
|
|
50
|
+
small: true,
|
|
51
|
+
disabled: atEnd || loading,
|
|
52
|
+
onClick: () => setPage(page + 1)
|
|
53
|
+
})
|
|
54
|
+
])
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
exports.LoadProgressIndicator = LoadProgressIndicator;
|
|
58
|
+
exports.LoadProgressLabel = LoadProgressLabel;
|
|
59
|
+
//# sourceMappingURL=view-info.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-info.cjs","sources":["../../../src/components/indicators/view-info.ts"],"sourcesContent":["import h from \"../../postgrest-table/main.module.sass\";\nimport { tableFooterAtom, chunkPageAtom } from \"../../postgrest-table\";\nimport { ctx, useItemCount } from \"../../provider\";\nimport { Button, ButtonGroup, Icon, Spinner } from \"@blueprintjs/core\";\n\n/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In\n * scroll mode: rows loaded, \"of total\" when known, and a status icon (spinner\n * loading / check complete / dots incomplete). In paged mode: prev/next page\n * controls with \"Page X of Y\". */\nexport function LoadProgressIndicator() {\n const footer = ctx.useValue(tableFooterAtom);\n if (footer.mode === \"paged\") return h(PageControl);\n\n const { loaded, total, loading } = footer;\n let status: any;\n if (loading) {\n status = h(Spinner, { size: 12 });\n } else if (total != null && loaded >= total) {\n status = h(Icon, { icon: \"tick\", size: 12 });\n } else {\n status = h(Icon, { icon: \"more\", size: 12 });\n }\n\n return h(\"div.load-progress\", [h(LoadProgressLabel), status]);\n}\n\nexport function LoadProgressLabel() {\n const { loaded, total } = ctx.useValue(tableFooterAtom);\n const expectedCount = total ?? loaded;\n let countText = useItemCount(expectedCount);\n if (expectedCount === 0) return countText;\n if (total != null && loaded <= total) {\n countText = `${loaded} of ${countText}`;\n }\n return h(\"span.load-progress-label\", countText);\n}\n\n/** Prev/next pager for paged fetch mode. */\nfunction PageControl() {\n const { page, totalPages, loading } = ctx.useValue(tableFooterAtom);\n const setPage = ctx.useSet(chunkPageAtom);\n const atEnd = totalPages != null && page >= totalPages - 1;\n\n return h(\"div.load-progress\", [\n loading ? h(Spinner, { size: 12 }) : null,\n h(\"span.load-progress-label\", [\n `Page ${page + 1}`,\n totalPages != null ? ` of ${totalPages}` : \"\",\n ]),\n h(ButtonGroup, { minimal: true }, [\n h(Button, {\n icon: \"chevron-left\",\n small: true,\n disabled: page <= 0 || loading,\n onClick: () => setPage(Math.max(0, page - 1)),\n }),\n h(Button, {\n icon: \"chevron-right\",\n small: true,\n disabled: atEnd || loading,\n onClick: () => setPage(page + 1),\n }),\n ]),\n ]);\n}\n"],"names":["ctx","tableFooterAtom","h","Spinner","Icon","useItemCount","chunkPageAtom","ButtonGroup","Button"],"mappings":";;;;;;AASO,SAAS,wBAAwB;AACtC,QAAM,SAASA,KAAAA,IAAI,SAASC,2BAAe;AAC3C,MAAI,OAAO,SAAS,QAAS,QAAOC,YAAAA,QAAE,WAAW;AAEjD,QAAM,EAAE,QAAQ,OAAO,QAAA,IAAY;AACnC,MAAI;AACJ,MAAI,SAAS;AACX,aAASA,YAAAA,QAAEC,OAAAA,SAAS,EAAE,MAAM,IAAI;AAAA,EAClC,WAAW,SAAS,QAAQ,UAAU,OAAO;AAC3C,aAASD,YAAAA,QAAEE,aAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C,OAAO;AACL,aAASF,YAAAA,QAAEE,aAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C;AAEA,SAAOF,YAAAA,QAAE,qBAAqB,CAACA,YAAAA,QAAE,iBAAiB,GAAG,MAAM,CAAC;AAC9D;AAEO,SAAS,oBAAoB;AAClC,QAAM,EAAE,QAAQ,MAAA,IAAUF,KAAAA,IAAI,SAASC,YAAAA,eAAe;AACtD,QAAM,gBAAgB,SAAS;AAC/B,MAAI,YAAYI,KAAAA,aAAa,aAAa;AAC1C,MAAI,kBAAkB,EAAG,QAAO;AAChC,MAAI,SAAS,QAAQ,UAAU,OAAO;AACpC,gBAAY,GAAG,MAAM,OAAO,SAAS;AAAA,EACvC;AACA,SAAOH,YAAAA,QAAE,4BAA4B,SAAS;AAChD;AAGA,SAAS,cAAc;AACrB,QAAM,EAAE,MAAM,YAAY,YAAYF,KAAAA,IAAI,SAASC,2BAAe;AAClE,QAAM,UAAUD,KAAAA,IAAI,OAAOM,yBAAa;AACxC,QAAM,QAAQ,cAAc,QAAQ,QAAQ,aAAa;AAEzD,SAAOJ,YAAAA,QAAE,qBAAqB;AAAA,IAC5B,UAAUA,YAAAA,QAAEC,OAAAA,SAAS,EAAE,MAAM,GAAA,CAAI,IAAI;AAAA,IACrCD,YAAAA,QAAE,4BAA4B;AAAA,MAC5B,QAAQ,OAAO,CAAC;AAAA,MAChB,cAAc,OAAO,OAAO,UAAU,KAAK;AAAA,IAAA,CAC5C;AAAA,IACDA,YAAAA,QAAEK,OAAAA,aAAa,EAAE,SAAS,QAAQ;AAAA,MAChCL,YAAAA,QAAEM,OAAAA,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,QAAQ,KAAK;AAAA,QACvB,SAAS,MAAM,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC;AAAA,MAAA,CAC7C;AAAA,MACDN,YAAAA,QAAEM,OAAAA,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,SAAS;AAAA,QACnB,SAAS,MAAM,QAAQ,OAAO,CAAC;AAAA,MAAA,CAChC;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;;;"}
|
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
* loading / check complete / dots incomplete). In paged mode: prev/next page
|
|
4
4
|
* controls with "Page X of Y". */
|
|
5
5
|
export declare function LoadProgressIndicator(): import('react').DOMElement<import('react').DOMAttributes<Element>, Element> | import('react').FunctionComponentElement<{}>;
|
|
6
|
+
export declare function LoadProgressLabel(): string | import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import h from "
|
|
2
|
-
import { ctx } from "../provider.js";
|
|
1
|
+
import h from "../../postgrest-table/main.module.sass.js";
|
|
3
2
|
import { Spinner, Icon, ButtonGroup, Button } from "@blueprintjs/core";
|
|
4
|
-
import { tableFooterAtom, chunkPageAtom } from "
|
|
3
|
+
import { tableFooterAtom, chunkPageAtom } from "../../postgrest-table/data-loaders.js";
|
|
4
|
+
import { ctx, useItemCount } from "../../provider/core.js";
|
|
5
5
|
function LoadProgressIndicator() {
|
|
6
6
|
const footer = ctx.useValue(tableFooterAtom);
|
|
7
7
|
if (footer.mode === "paged") return h(PageControl);
|
|
@@ -10,18 +10,21 @@ function LoadProgressIndicator() {
|
|
|
10
10
|
if (loading) {
|
|
11
11
|
status = h(Spinner, { size: 12 });
|
|
12
12
|
} else if (total != null && loaded >= total) {
|
|
13
|
-
status = h(Icon, { icon: "tick
|
|
13
|
+
status = h(Icon, { icon: "tick", size: 12 });
|
|
14
14
|
} else {
|
|
15
15
|
status = h(Icon, { icon: "more", size: 12 });
|
|
16
16
|
}
|
|
17
|
-
return h("div.load-progress", [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
return h("div.load-progress", [h(LoadProgressLabel), status]);
|
|
18
|
+
}
|
|
19
|
+
function LoadProgressLabel() {
|
|
20
|
+
const { loaded, total } = ctx.useValue(tableFooterAtom);
|
|
21
|
+
const expectedCount = total ?? loaded;
|
|
22
|
+
let countText = useItemCount(expectedCount);
|
|
23
|
+
if (expectedCount === 0) return countText;
|
|
24
|
+
if (total != null && loaded <= total) {
|
|
25
|
+
countText = `${loaded} of ${countText}`;
|
|
26
|
+
}
|
|
27
|
+
return h("span.load-progress-label", countText);
|
|
25
28
|
}
|
|
26
29
|
function PageControl() {
|
|
27
30
|
const { page, totalPages, loading } = ctx.useValue(tableFooterAtom);
|
|
@@ -50,6 +53,7 @@ function PageControl() {
|
|
|
50
53
|
]);
|
|
51
54
|
}
|
|
52
55
|
export {
|
|
53
|
-
LoadProgressIndicator
|
|
56
|
+
LoadProgressIndicator,
|
|
57
|
+
LoadProgressLabel
|
|
54
58
|
};
|
|
55
59
|
//# sourceMappingURL=view-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-info.js","sources":["../../../src/components/indicators/view-info.ts"],"sourcesContent":["import h from \"../../postgrest-table/main.module.sass\";\nimport { tableFooterAtom, chunkPageAtom } from \"../../postgrest-table\";\nimport { ctx, useItemCount } from \"../../provider\";\nimport { Button, ButtonGroup, Icon, Spinner } from \"@blueprintjs/core\";\n\n/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In\n * scroll mode: rows loaded, \"of total\" when known, and a status icon (spinner\n * loading / check complete / dots incomplete). In paged mode: prev/next page\n * controls with \"Page X of Y\". */\nexport function LoadProgressIndicator() {\n const footer = ctx.useValue(tableFooterAtom);\n if (footer.mode === \"paged\") return h(PageControl);\n\n const { loaded, total, loading } = footer;\n let status: any;\n if (loading) {\n status = h(Spinner, { size: 12 });\n } else if (total != null && loaded >= total) {\n status = h(Icon, { icon: \"tick\", size: 12 });\n } else {\n status = h(Icon, { icon: \"more\", size: 12 });\n }\n\n return h(\"div.load-progress\", [h(LoadProgressLabel), status]);\n}\n\nexport function LoadProgressLabel() {\n const { loaded, total } = ctx.useValue(tableFooterAtom);\n const expectedCount = total ?? loaded;\n let countText = useItemCount(expectedCount);\n if (expectedCount === 0) return countText;\n if (total != null && loaded <= total) {\n countText = `${loaded} of ${countText}`;\n }\n return h(\"span.load-progress-label\", countText);\n}\n\n/** Prev/next pager for paged fetch mode. */\nfunction PageControl() {\n const { page, totalPages, loading } = ctx.useValue(tableFooterAtom);\n const setPage = ctx.useSet(chunkPageAtom);\n const atEnd = totalPages != null && page >= totalPages - 1;\n\n return h(\"div.load-progress\", [\n loading ? h(Spinner, { size: 12 }) : null,\n h(\"span.load-progress-label\", [\n `Page ${page + 1}`,\n totalPages != null ? ` of ${totalPages}` : \"\",\n ]),\n h(ButtonGroup, { minimal: true }, [\n h(Button, {\n icon: \"chevron-left\",\n small: true,\n disabled: page <= 0 || loading,\n onClick: () => setPage(Math.max(0, page - 1)),\n }),\n h(Button, {\n icon: \"chevron-right\",\n small: true,\n disabled: atEnd || loading,\n onClick: () => setPage(page + 1),\n }),\n ]),\n ]);\n}\n"],"names":[],"mappings":";;;;AASO,SAAS,wBAAwB;AACtC,QAAM,SAAS,IAAI,SAAS,eAAe;AAC3C,MAAI,OAAO,SAAS,QAAS,QAAO,EAAE,WAAW;AAEjD,QAAM,EAAE,QAAQ,OAAO,QAAA,IAAY;AACnC,MAAI;AACJ,MAAI,SAAS;AACX,aAAS,EAAE,SAAS,EAAE,MAAM,IAAI;AAAA,EAClC,WAAW,SAAS,QAAQ,UAAU,OAAO;AAC3C,aAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C,OAAO;AACL,aAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C;AAEA,SAAO,EAAE,qBAAqB,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC9D;AAEO,SAAS,oBAAoB;AAClC,QAAM,EAAE,QAAQ,MAAA,IAAU,IAAI,SAAS,eAAe;AACtD,QAAM,gBAAgB,SAAS;AAC/B,MAAI,YAAY,aAAa,aAAa;AAC1C,MAAI,kBAAkB,EAAG,QAAO;AAChC,MAAI,SAAS,QAAQ,UAAU,OAAO;AACpC,gBAAY,GAAG,MAAM,OAAO,SAAS;AAAA,EACvC;AACA,SAAO,EAAE,4BAA4B,SAAS;AAChD;AAGA,SAAS,cAAc;AACrB,QAAM,EAAE,MAAM,YAAY,YAAY,IAAI,SAAS,eAAe;AAClE,QAAM,UAAU,IAAI,OAAO,aAAa;AACxC,QAAM,QAAQ,cAAc,QAAQ,QAAQ,aAAa;AAEzD,SAAO,EAAE,qBAAqB;AAAA,IAC5B,UAAU,EAAE,SAAS,EAAE,MAAM,GAAA,CAAI,IAAI;AAAA,IACrC,EAAE,4BAA4B;AAAA,MAC5B,QAAQ,OAAO,CAAC;AAAA,MAChB,cAAc,OAAO,OAAO,UAAU,KAAK;AAAA,IAAA,CAC5C;AAAA,IACD,EAAE,aAAa,EAAE,SAAS,QAAQ;AAAA,MAChC,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,QAAQ,KAAK;AAAA,QACvB,SAAS,MAAM,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC;AAAA,MAAA,CAC7C;AAAA,MACD,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,SAAS;AAAA,QACnB,SAAS,MAAM,QAAQ,OAAO,CAAC;AAAA,MAAA,CAChC;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const main_module = require("./main.module.sass.cjs");
|
|
4
|
-
const core = require("@blueprintjs/core");
|
|
4
|
+
const core$1 = require("@blueprintjs/core");
|
|
5
5
|
const react = require("react");
|
|
6
|
-
const
|
|
6
|
+
const core = require("../provider/core.cjs");
|
|
7
7
|
function EditableTextArea({
|
|
8
8
|
value,
|
|
9
9
|
onChange,
|
|
@@ -12,8 +12,8 @@ function EditableTextArea({
|
|
|
12
12
|
autoFocus = true
|
|
13
13
|
}) {
|
|
14
14
|
const ref = react.useRef(null);
|
|
15
|
-
const tableElement =
|
|
16
|
-
const navDirection =
|
|
15
|
+
const tableElement = core.useSelector((s) => s.tableElement);
|
|
16
|
+
const navDirection = core.useSelector((s) => s.lastNavDirection);
|
|
17
17
|
react.useEffect(() => {
|
|
18
18
|
if (!autoFocus) return;
|
|
19
19
|
if (ref.current == null) return;
|
|
@@ -75,7 +75,7 @@ function EditableTextArea({
|
|
|
75
75
|
}),
|
|
76
76
|
main_module.default("div.tools", [
|
|
77
77
|
// Tool to reset the value to the default
|
|
78
|
-
main_module.default(core.Button, {
|
|
78
|
+
main_module.default(core$1.Button, {
|
|
79
79
|
icon: "undo",
|
|
80
80
|
minimal: true,
|
|
81
81
|
small: true,
|