@macrostrat/data-sheet 4.0.0-dev3 → 4.0.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 +51 -0
- package/README.md +44 -0
- package/dist/actions/builtin.cjs +36 -5
- package/dist/actions/builtin.cjs.map +1 -1
- package/dist/actions/builtin.d.ts +3 -2
- package/dist/actions/builtin.js +36 -5
- package/dist/actions/builtin.js.map +1 -1
- package/dist/actions/column-controls.cjs +149 -0
- package/dist/actions/column-controls.cjs.map +1 -0
- package/dist/actions/column-controls.d.ts +11 -0
- package/dist/actions/column-controls.js +147 -0
- package/dist/actions/column-controls.js.map +1 -0
- package/dist/actions/column-filter.cjs +68 -0
- package/dist/actions/column-filter.cjs.map +1 -0
- package/dist/actions/column-filter.d.ts +11 -0
- package/dist/actions/column-filter.js +66 -0
- package/dist/actions/column-filter.js.map +1 -0
- package/dist/actions/edit-actions.cjs +42 -0
- package/dist/actions/edit-actions.cjs.map +1 -0
- package/dist/actions/edit-actions.d.ts +14 -0
- package/dist/actions/edit-actions.js +42 -0
- package/dist/actions/edit-actions.js.map +1 -0
- package/dist/actions/filters.cjs +39 -23
- package/dist/actions/filters.cjs.map +1 -1
- package/dist/actions/filters.d.ts +6 -3
- package/dist/actions/filters.js +41 -25
- package/dist/actions/filters.js.map +1 -1
- package/dist/actions/index.d.ts +4 -0
- package/dist/actions/selection.cjs +39 -30
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +3 -7
- package/dist/actions/selection.js +39 -30
- package/dist/actions/selection.js.map +1 -1
- package/dist/actions/table-controls.cjs +41 -0
- package/dist/actions/table-controls.cjs.map +1 -0
- package/dist/actions/table-controls.d.ts +4 -0
- package/dist/actions/table-controls.js +39 -0
- package/dist/actions/table-controls.js.map +1 -0
- package/dist/actions/toolbar.cjs +69 -10
- package/dist/actions/toolbar.cjs.map +1 -1
- package/dist/actions/toolbar.d.ts +9 -6
- package/dist/actions/toolbar.js +69 -10
- package/dist/actions/toolbar.js.map +1 -1
- package/dist/actions/toolbar.module.sass.cjs +12 -7
- package/dist/actions/toolbar.module.sass.cjs.map +1 -1
- package/dist/actions/toolbar.module.sass.js +12 -7
- package/dist/actions/toolbar.module.sass.js.map +1 -1
- package/dist/actions/types.d.ts +49 -4
- package/dist/cell-renderer.cjs +150 -14
- package/dist/cell-renderer.cjs.map +1 -1
- package/dist/cell-renderer.d.ts +1 -1
- package/dist/cell-renderer.js +151 -15
- package/dist/cell-renderer.js.map +1 -1
- package/dist/components/cell-detail.cjs +24 -0
- package/dist/components/cell-detail.cjs.map +1 -0
- package/dist/components/cell-detail.d.ts +12 -0
- package/dist/components/cell-detail.js +24 -0
- package/dist/components/cell-detail.js.map +1 -0
- package/dist/components/editor-popup.cjs +28 -24
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +29 -25
- package/dist/components/editor-popup.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/text-areas.cjs +51 -7
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.d.ts +4 -1
- package/dist/components/text-areas.js +51 -7
- package/dist/components/text-areas.js.map +1 -1
- package/dist/components/view-info.cjs +46 -9
- package/dist/components/view-info.cjs.map +1 -1
- package/dist/components/view-info.d.ts +5 -1
- package/dist/components/view-info.js +47 -10
- package/dist/components/view-info.js.map +1 -1
- package/dist/core.cjs +167 -73
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +53 -6
- package/dist/core.js +169 -75
- package/dist/core.js.map +1 -1
- package/dist/data-sheet.css +72 -123
- package/dist/filters/operators.cjs +91 -0
- package/dist/filters/operators.cjs.map +1 -0
- package/dist/filters/operators.d.ts +17 -0
- package/dist/filters/operators.js +91 -0
- package/dist/filters/operators.js.map +1 -0
- package/dist/index.cjs +38 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +44 -16
- package/dist/index.js.map +1 -1
- package/dist/main.module.sass.cjs +13 -12
- package/dist/main.module.sass.cjs.map +1 -1
- package/dist/main.module.sass.js +13 -12
- package/dist/main.module.sass.js.map +1 -1
- package/dist/postgrest-table/data-loaders.cjs +255 -146
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +144 -46
- package/dist/postgrest-table/data-loaders.js +259 -150
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +58 -169
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +5 -2
- package/dist/postgrest-table/index.js +63 -174
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/postgrest-table/loading-utils.cjs +0 -4
- package/dist/postgrest-table/loading-utils.cjs.map +1 -1
- package/dist/postgrest-table/loading-utils.js +1 -5
- package/dist/postgrest-table/loading-utils.js.map +1 -1
- package/dist/postgrest-table/main.module.sass.cjs +14 -13
- package/dist/postgrest-table/main.module.sass.cjs.map +1 -1
- package/dist/postgrest-table/main.module.sass.js +14 -13
- package/dist/postgrest-table/main.module.sass.js.map +1 -1
- package/dist/provider.cjs +68 -11
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.ts +25 -0
- package/dist/provider.js +68 -11
- package/dist/provider.js.map +1 -1
- package/dist/renderers/column-header-cell.cjs +95 -75
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +3 -18
- package/dist/renderers/column-header-cell.js +98 -78
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/renderers/index.d.ts +0 -1
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +84 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/column-spec.cjs.map +1 -1
- package/dist/utils/column-spec.d.ts +101 -1
- package/dist/utils/column-spec.js.map +1 -1
- package/dist/utils/debug-overlay.cjs +24 -0
- package/dist/utils/debug-overlay.cjs.map +1 -0
- package/dist/utils/debug-overlay.d.ts +4 -0
- package/dist/utils/debug-overlay.js +24 -0
- package/dist/utils/debug-overlay.js.map +1 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/key-handling.cjs +52 -6
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.js +52 -6
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/utils/validation.cjs +41 -0
- package/dist/utils/validation.cjs.map +1 -0
- package/dist/utils/validation.d.ts +26 -0
- package/dist/utils/validation.js +41 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/zustand-store.cjs +119 -61
- package/dist/zustand-store.cjs.map +1 -1
- package/dist/zustand-store.js +121 -63
- package/dist/zustand-store.js.map +1 -1
- package/package.json +3 -3
- package/src/actions/builtin.ts +62 -7
- package/src/actions/column-controls.ts +185 -0
- package/src/actions/column-filter.ts +104 -0
- package/src/actions/edit-actions.ts +67 -0
- package/src/actions/filters.ts +54 -28
- package/src/actions/index.ts +4 -0
- package/src/actions/selection.ts +59 -52
- package/src/actions/table-controls.ts +46 -0
- package/src/actions/toolbar.module.sass +22 -2
- package/src/actions/toolbar.ts +113 -16
- package/src/actions/types.ts +49 -4
- package/src/cell-renderer.ts +211 -16
- package/src/components/cell-detail.ts +30 -0
- package/src/components/editor-popup.ts +39 -25
- package/src/components/index.ts +2 -2
- package/src/components/text-areas.ts +80 -16
- package/src/components/view-info.ts +63 -4
- package/src/core.ts +321 -103
- package/src/filters/operators.ts +127 -0
- package/src/index.ts +2 -0
- package/src/main.module.sass +6 -0
- package/src/postgrest-table/data-loaders.ts +459 -209
- package/src/postgrest-table/index.ts +81 -254
- package/src/postgrest-table/main.module.sass +11 -0
- package/src/provider.ts +109 -12
- package/src/renderers/column-header-cell.ts +60 -272
- package/src/renderers/index.ts +0 -1
- package/src/types.ts +76 -2
- package/src/utils/column-spec.ts +112 -1
- package/src/utils/debug-overlay.ts +22 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/key-handling.ts +70 -6
- package/src/utils/validation.ts +72 -0
- package/src/zustand-store.ts +167 -60
- package/dist/components/actions.cjs +0 -12
- package/dist/components/actions.cjs.map +0 -1
- package/dist/components/actions.d.ts +0 -2
- package/dist/components/actions.js +0 -12
- package/dist/components/actions.js.map +0 -1
- package/dist/components/actions.module.sass.cjs +0 -12
- package/dist/components/actions.module.sass.cjs.map +0 -1
- package/dist/components/actions.module.sass.js +0 -11
- package/dist/components/actions.module.sass.js.map +0 -1
- package/dist/postgrest-table/lazy-loader-table.cjs +0 -27
- package/dist/postgrest-table/lazy-loader-table.cjs.map +0 -1
- package/dist/postgrest-table/lazy-loader-table.d.ts +0 -3
- package/dist/postgrest-table/lazy-loader-table.js +0 -27
- package/dist/postgrest-table/lazy-loader-table.js.map +0 -1
- package/dist/renderers/column-header-cell-postgrest.cjs +0 -216
- package/dist/renderers/column-header-cell-postgrest.cjs.map +0 -1
- package/dist/renderers/column-header-cell-postgrest.d.ts +0 -13
- package/dist/renderers/column-header-cell-postgrest.js +0 -216
- package/dist/renderers/column-header-cell-postgrest.js.map +0 -1
- package/dist/renderers/column-header-cell-postgrest.module.sass.cjs +0 -23
- package/dist/renderers/column-header-cell-postgrest.module.sass.cjs.map +0 -1
- package/dist/renderers/column-header-cell-postgrest.module.sass.js +0 -22
- package/dist/renderers/column-header-cell-postgrest.module.sass.js.map +0 -1
- package/src/components/actions.ts +0 -9
- package/src/postgrest-table/lazy-loader-table.ts +0 -25
- package/src/renderers/column-header-cell-postgrest.ts +0 -282
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal presentation for a cell's `cellDetail` surface. Subscribes to the
|
|
3
|
+
* store's `cellSurfaceOpen` so the dialog opens/closes reactively (Escape,
|
|
4
|
+
* the close button, and outside-click all route through `closeCellSurface`).
|
|
5
|
+
* Rendering the dialog from a plain render snapshot would leave it unable to
|
|
6
|
+
* close, since the cell renderer isn't re-invoked on every store change.
|
|
7
|
+
*/
|
|
8
|
+
export declare function CellDetailModal({ title, valueViewer, children }: {
|
|
9
|
+
title: any;
|
|
10
|
+
valueViewer: any;
|
|
11
|
+
children: any;
|
|
12
|
+
}): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Dialog } from "@blueprintjs/core";
|
|
2
|
+
import h from "./main.module.sass.js";
|
|
3
|
+
import { useSelector } from "../provider.js";
|
|
4
|
+
function CellDetailModal({ title, valueViewer, children }) {
|
|
5
|
+
const isOpen = useSelector((s) => s.cellSurfaceOpen);
|
|
6
|
+
const closeCellSurface = useSelector((s) => s.closeCellSurface);
|
|
7
|
+
const tableElement = useSelector((s) => s.tableElement);
|
|
8
|
+
const onClose = () => {
|
|
9
|
+
closeCellSurface?.();
|
|
10
|
+
tableElement?.focus?.();
|
|
11
|
+
};
|
|
12
|
+
return h([
|
|
13
|
+
valueViewer,
|
|
14
|
+
h(
|
|
15
|
+
Dialog,
|
|
16
|
+
{ isOpen, onClose, title, canEscapeKeyClose: true, canOutsideClickClose: true },
|
|
17
|
+
h("div.bp6-dialog-body", children)
|
|
18
|
+
)
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
CellDetailModal
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=cell-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-detail.js","sources":["../../src/components/cell-detail.ts"],"sourcesContent":["import { Dialog } from \"@blueprintjs/core\";\nimport h from \"./main.module.sass\";\nimport { useSelector } from \"../provider\";\n\n/**\n * Modal presentation for a cell's `cellDetail` surface. Subscribes to the\n * store's `cellSurfaceOpen` so the dialog opens/closes reactively (Escape,\n * the close button, and outside-click all route through `closeCellSurface`).\n * Rendering the dialog from a plain render snapshot would leave it unable to\n * close, since the cell renderer isn't re-invoked on every store change.\n */\nexport function CellDetailModal({ title, valueViewer, children }) {\n const isOpen = useSelector((s) => s.cellSurfaceOpen);\n const closeCellSurface = useSelector((s) => s.closeCellSurface);\n const tableElement = useSelector((s) => s.tableElement);\n\n const onClose = () => {\n closeCellSurface?.();\n tableElement?.focus?.();\n };\n\n return h([\n valueViewer,\n h(\n Dialog,\n { isOpen, onClose, title, canEscapeKeyClose: true, canOutsideClickClose: true },\n h(\"div.bp6-dialog-body\", children),\n ),\n ]);\n}\n"],"names":[],"mappings":";;;AAWO,SAAS,gBAAgB,EAAE,OAAO,aAAa,YAAY;AAChE,QAAM,SAAS,YAAY,CAAC,MAAM,EAAE,eAAe;AACnD,QAAM,mBAAmB,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAC9D,QAAM,eAAe,YAAY,CAAC,MAAM,EAAE,YAAY;AAEtD,QAAM,UAAU,MAAM;AACpB,uBAAA;AACA,kBAAc,QAAA;AAAA,EAChB;AAEA,SAAO,EAAE;AAAA,IACP;AAAA,IACA;AAAA,MACE;AAAA,MACA,EAAE,QAAQ,SAAS,OAAO,mBAAmB,MAAM,sBAAsB,KAAA;AAAA,MACzE,EAAE,uBAAuB,QAAQ;AAAA,IAAA;AAAA,EACnC,CACD;AACH;"}
|
|
@@ -6,24 +6,20 @@ const main_module = require("./main.module.sass.cjs");
|
|
|
6
6
|
const react = require("react");
|
|
7
7
|
const provider = require("../provider.cjs");
|
|
8
8
|
function EditorPopup(props) {
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
placement = "right-start"
|
|
15
|
-
} = props;
|
|
16
|
-
const [isOpen, setIsOpen] = react.useState(autoFocus);
|
|
17
|
-
const keyHandler = provider.useSelector((state) => state.keyHandler);
|
|
9
|
+
const { children, targetClassName, valueViewer, placement = "right-start" } = props;
|
|
10
|
+
const isOpen = provider.useSelector((s) => s.cellSurfaceOpen);
|
|
11
|
+
const tableElement = provider.useSelector((s) => s.tableElement);
|
|
12
|
+
const openCellSurface = provider.useSelector((s) => s.openCellSurface);
|
|
13
|
+
const closeCellSurface = provider.useSelector((s) => s.closeCellSurface);
|
|
18
14
|
const ref = react.useRef(null);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const wasOpenRef = react.useRef(false);
|
|
16
|
+
const close = react.useCallback(
|
|
17
|
+
(suppress) => {
|
|
18
|
+
closeCellSurface?.({ suppress });
|
|
19
|
+
tableElement?.focus();
|
|
20
|
+
},
|
|
21
|
+
[closeCellSurface, tableElement]
|
|
22
|
+
);
|
|
27
23
|
return main_module.default(
|
|
28
24
|
core.PopoverNext,
|
|
29
25
|
{
|
|
@@ -35,9 +31,7 @@ function EditorPopup(props) {
|
|
|
35
31
|
},
|
|
36
32
|
onKeyDown(evt) {
|
|
37
33
|
if (evt.key === "Escape") {
|
|
38
|
-
|
|
39
|
-
setIsOpen(false);
|
|
40
|
-
}
|
|
34
|
+
close(true);
|
|
41
35
|
evt.stopPropagation();
|
|
42
36
|
evt.preventDefault();
|
|
43
37
|
return;
|
|
@@ -55,7 +49,9 @@ function EditorPopup(props) {
|
|
|
55
49
|
// offset: { enabled: true, options: { offset: [0, 8] } },
|
|
56
50
|
// },
|
|
57
51
|
placement,
|
|
58
|
-
|
|
52
|
+
// Fully controlled via `isOpen`; use click (not hover) so hovering the
|
|
53
|
+
// target can't momentarily preview/dismiss the popover.
|
|
54
|
+
interactionKind: "click",
|
|
59
55
|
isOpen
|
|
60
56
|
// Portal must be used to avoid issues with the editor being clipped to the bounds of the cell
|
|
61
57
|
//usePortal: true,
|
|
@@ -64,11 +60,19 @@ function EditorPopup(props) {
|
|
|
64
60
|
"span.editor-popup-target",
|
|
65
61
|
{
|
|
66
62
|
className: targetClassName,
|
|
67
|
-
|
|
63
|
+
onMouseDown: () => {
|
|
64
|
+
wasOpenRef.current = isOpen;
|
|
65
|
+
},
|
|
66
|
+
// Toggle on click of the already-selected cell: clicking an open cell
|
|
67
|
+
// dismisses it (without entering nav mode); clicking a closed one
|
|
68
|
+
// reopens it. New-cell clicks are opened by `onSelection` instead.
|
|
69
|
+
onClick: () => {
|
|
70
|
+
if (wasOpenRef.current) close(false);
|
|
71
|
+
else openCellSurface?.();
|
|
72
|
+
},
|
|
68
73
|
ref
|
|
69
74
|
},
|
|
70
|
-
|
|
71
|
-
isOpen ? valueViewer : inlineEditor ?? valueViewer
|
|
75
|
+
valueViewer
|
|
72
76
|
)
|
|
73
77
|
);
|
|
74
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-popup.cjs","sources":["../../src/components/editor-popup.ts"],"sourcesContent":["import { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PopoverNext } from \"@blueprintjs/core\";\nimport h from \"./main.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"editor-popup.cjs","sources":["../../src/components/editor-popup.ts"],"sourcesContent":["import { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PopoverNext } from \"@blueprintjs/core\";\nimport h from \"./main.module.sass\";\nimport { useCallback, useRef } from \"react\";\nimport { useSelector } from \"../provider\";\n\nexport function EditorPopup(props) {\n const { children, targetClassName, valueViewer, placement = \"right-start\" } =\n props;\n\n // Open state is owned by the store (not local), so navigation, clicks, and\n // the Escape handler all agree on whether the focused cell's surface is\n // open. We never render a focus-stealing element, so keyboard focus stays on\n // the Blueprint table until an editor takes it — that's what keeps arrow-key\n // navigation working (cf. the Color column and read-only detail panels).\n const isOpen = useSelector((s) => s.cellSurfaceOpen);\n const tableElement = useSelector((s) => s.tableElement);\n const openCellSurface = useSelector((s) => s.openCellSurface);\n const closeCellSurface = useSelector((s) => s.closeCellSurface);\n\n const ref = useRef(null);\n // Whether the surface was open at mousedown. `onSelection` doesn't change\n // open-state for a click on the already-selected cell, so this reflects the\n // true pre-click state and the click toggles cleanly (no flash).\n const wasOpenRef = useRef(false);\n\n const close = useCallback(\n (suppress: boolean) => {\n closeCellSurface?.({ suppress });\n // Return focus to the table so arrow keys navigate again.\n tableElement?.focus();\n },\n [closeCellSurface, tableElement],\n );\n\n return h(\n PopoverNext,\n {\n content: h(\n \"div.interaction-barrier\",\n {\n onMouseDown(evt) {\n evt.nativeEvent.stopImmediatePropagation();\n },\n onKeyDown(evt) {\n if (evt.key === \"Escape\") {\n close(true);\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n // Climb over the interaction barrier to propagate the key event to the table\n },\n },\n h(ErrorBoundary, null, children),\n ),\n enforceFocus: false,\n autoFocus: false,\n animation: \"minimal\",\n //arrow: false,\n lazy: true,\n // modifiers: {\n // offset: { enabled: true, options: { offset: [0, 8] } },\n // },\n placement,\n // Fully controlled via `isOpen`; use click (not hover) so hovering the\n // target can't momentarily preview/dismiss the popover.\n interactionKind: \"click\",\n isOpen,\n // Portal must be used to avoid issues with the editor being clipped to the bounds of the cell\n //usePortal: true,\n },\n h(\n \"span.editor-popup-target\",\n {\n className: targetClassName,\n onMouseDown: () => {\n wasOpenRef.current = isOpen;\n },\n // Toggle on click of the already-selected cell: clicking an open cell\n // dismisses it (without entering nav mode); clicking a closed one\n // reopens it. New-cell clicks are opened by `onSelection` instead.\n onClick: () => {\n if (wasOpenRef.current) close(false);\n else openCellSurface?.();\n },\n ref,\n },\n valueViewer,\n ),\n );\n}\n"],"names":["useSelector","useRef","useCallback","h","PopoverNext","ErrorBoundary"],"mappings":";;;;;;;AAMO,SAAS,YAAY,OAAO;AACjC,QAAM,EAAE,UAAU,iBAAiB,aAAa,YAAY,kBAC1D;AAOF,QAAM,SAASA,SAAAA,YAAY,CAAC,MAAM,EAAE,eAAe;AACnD,QAAM,eAAeA,SAAAA,YAAY,CAAC,MAAM,EAAE,YAAY;AACtD,QAAM,kBAAkBA,SAAAA,YAAY,CAAC,MAAM,EAAE,eAAe;AAC5D,QAAM,mBAAmBA,SAAAA,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAE9D,QAAM,MAAMC,MAAAA,OAAO,IAAI;AAIvB,QAAM,aAAaA,MAAAA,OAAO,KAAK;AAE/B,QAAM,QAAQC,MAAAA;AAAAA,IACZ,CAAC,aAAsB;AACrB,yBAAmB,EAAE,UAAU;AAE/B,oBAAc,MAAA;AAAA,IAChB;AAAA,IACA,CAAC,kBAAkB,YAAY;AAAA,EAAA;AAGjC,SAAOC,YAAAA;AAAAA,IACLC,KAAAA;AAAAA,IACA;AAAA,MACE,SAASD,YAAAA;AAAAA,QACP;AAAA,QACA;AAAA,UACE,YAAY,KAAK;AACf,gBAAI,YAAY,yBAAA;AAAA,UAClB;AAAA,UACA,UAAU,KAAK;AACb,gBAAI,IAAI,QAAQ,UAAU;AACxB,oBAAM,IAAI;AACV,kBAAI,gBAAA;AACJ,kBAAI,eAAA;AACJ;AAAA,YACF;AAAA,UAEF;AAAA,QAAA;AAAA,QAEFA,oBAAEE,aAAAA,eAAe,MAAM,QAAQ;AAAA,MAAA;AAAA,MAEjC,cAAc;AAAA,MACd,WAAW;AAAA,MACX,WAAW;AAAA;AAAA,MAEX,MAAM;AAAA;AAAA;AAAA;AAAA,MAIN;AAAA;AAAA;AAAA,MAGA,iBAAiB;AAAA,MACjB;AAAA;AAAA;AAAA,IAAA;AAAA,IAIFF,YAAAA;AAAAA,MACE;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,aAAa,MAAM;AACjB,qBAAW,UAAU;AAAA,QACvB;AAAA;AAAA;AAAA;AAAA,QAIA,SAAS,MAAM;AACb,cAAI,WAAW,QAAS,OAAM,KAAK;AAAA,cAC9B,mBAAA;AAAA,QACP;AAAA,QACA;AAAA,MAAA;AAAA,MAEF;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { ErrorBoundary } from "@macrostrat/ui-components";
|
|
2
2
|
import { PopoverNext } from "@blueprintjs/core";
|
|
3
3
|
import h from "./main.module.sass.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useRef, useCallback } from "react";
|
|
5
5
|
import { useSelector } from "../provider.js";
|
|
6
6
|
function EditorPopup(props) {
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
placement = "right-start"
|
|
13
|
-
} = props;
|
|
14
|
-
const [isOpen, setIsOpen] = useState(autoFocus);
|
|
15
|
-
const keyHandler = useSelector((state) => state.keyHandler);
|
|
7
|
+
const { children, targetClassName, valueViewer, placement = "right-start" } = props;
|
|
8
|
+
const isOpen = useSelector((s) => s.cellSurfaceOpen);
|
|
9
|
+
const tableElement = useSelector((s) => s.tableElement);
|
|
10
|
+
const openCellSurface = useSelector((s) => s.openCellSurface);
|
|
11
|
+
const closeCellSurface = useSelector((s) => s.closeCellSurface);
|
|
16
12
|
const ref = useRef(null);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const wasOpenRef = useRef(false);
|
|
14
|
+
const close = useCallback(
|
|
15
|
+
(suppress) => {
|
|
16
|
+
closeCellSurface?.({ suppress });
|
|
17
|
+
tableElement?.focus();
|
|
18
|
+
},
|
|
19
|
+
[closeCellSurface, tableElement]
|
|
20
|
+
);
|
|
25
21
|
return h(
|
|
26
22
|
PopoverNext,
|
|
27
23
|
{
|
|
@@ -33,9 +29,7 @@ function EditorPopup(props) {
|
|
|
33
29
|
},
|
|
34
30
|
onKeyDown(evt) {
|
|
35
31
|
if (evt.key === "Escape") {
|
|
36
|
-
|
|
37
|
-
setIsOpen(false);
|
|
38
|
-
}
|
|
32
|
+
close(true);
|
|
39
33
|
evt.stopPropagation();
|
|
40
34
|
evt.preventDefault();
|
|
41
35
|
return;
|
|
@@ -53,7 +47,9 @@ function EditorPopup(props) {
|
|
|
53
47
|
// offset: { enabled: true, options: { offset: [0, 8] } },
|
|
54
48
|
// },
|
|
55
49
|
placement,
|
|
56
|
-
|
|
50
|
+
// Fully controlled via `isOpen`; use click (not hover) so hovering the
|
|
51
|
+
// target can't momentarily preview/dismiss the popover.
|
|
52
|
+
interactionKind: "click",
|
|
57
53
|
isOpen
|
|
58
54
|
// Portal must be used to avoid issues with the editor being clipped to the bounds of the cell
|
|
59
55
|
//usePortal: true,
|
|
@@ -62,11 +58,19 @@ function EditorPopup(props) {
|
|
|
62
58
|
"span.editor-popup-target",
|
|
63
59
|
{
|
|
64
60
|
className: targetClassName,
|
|
65
|
-
|
|
61
|
+
onMouseDown: () => {
|
|
62
|
+
wasOpenRef.current = isOpen;
|
|
63
|
+
},
|
|
64
|
+
// Toggle on click of the already-selected cell: clicking an open cell
|
|
65
|
+
// dismisses it (without entering nav mode); clicking a closed one
|
|
66
|
+
// reopens it. New-cell clicks are opened by `onSelection` instead.
|
|
67
|
+
onClick: () => {
|
|
68
|
+
if (wasOpenRef.current) close(false);
|
|
69
|
+
else openCellSurface?.();
|
|
70
|
+
},
|
|
66
71
|
ref
|
|
67
72
|
},
|
|
68
|
-
|
|
69
|
-
isOpen ? valueViewer : inlineEditor ?? valueViewer
|
|
73
|
+
valueViewer
|
|
70
74
|
)
|
|
71
75
|
);
|
|
72
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-popup.js","sources":["../../src/components/editor-popup.ts"],"sourcesContent":["import { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PopoverNext } from \"@blueprintjs/core\";\nimport h from \"./main.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"editor-popup.js","sources":["../../src/components/editor-popup.ts"],"sourcesContent":["import { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PopoverNext } from \"@blueprintjs/core\";\nimport h from \"./main.module.sass\";\nimport { useCallback, useRef } from \"react\";\nimport { useSelector } from \"../provider\";\n\nexport function EditorPopup(props) {\n const { children, targetClassName, valueViewer, placement = \"right-start\" } =\n props;\n\n // Open state is owned by the store (not local), so navigation, clicks, and\n // the Escape handler all agree on whether the focused cell's surface is\n // open. We never render a focus-stealing element, so keyboard focus stays on\n // the Blueprint table until an editor takes it — that's what keeps arrow-key\n // navigation working (cf. the Color column and read-only detail panels).\n const isOpen = useSelector((s) => s.cellSurfaceOpen);\n const tableElement = useSelector((s) => s.tableElement);\n const openCellSurface = useSelector((s) => s.openCellSurface);\n const closeCellSurface = useSelector((s) => s.closeCellSurface);\n\n const ref = useRef(null);\n // Whether the surface was open at mousedown. `onSelection` doesn't change\n // open-state for a click on the already-selected cell, so this reflects the\n // true pre-click state and the click toggles cleanly (no flash).\n const wasOpenRef = useRef(false);\n\n const close = useCallback(\n (suppress: boolean) => {\n closeCellSurface?.({ suppress });\n // Return focus to the table so arrow keys navigate again.\n tableElement?.focus();\n },\n [closeCellSurface, tableElement],\n );\n\n return h(\n PopoverNext,\n {\n content: h(\n \"div.interaction-barrier\",\n {\n onMouseDown(evt) {\n evt.nativeEvent.stopImmediatePropagation();\n },\n onKeyDown(evt) {\n if (evt.key === \"Escape\") {\n close(true);\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n // Climb over the interaction barrier to propagate the key event to the table\n },\n },\n h(ErrorBoundary, null, children),\n ),\n enforceFocus: false,\n autoFocus: false,\n animation: \"minimal\",\n //arrow: false,\n lazy: true,\n // modifiers: {\n // offset: { enabled: true, options: { offset: [0, 8] } },\n // },\n placement,\n // Fully controlled via `isOpen`; use click (not hover) so hovering the\n // target can't momentarily preview/dismiss the popover.\n interactionKind: \"click\",\n isOpen,\n // Portal must be used to avoid issues with the editor being clipped to the bounds of the cell\n //usePortal: true,\n },\n h(\n \"span.editor-popup-target\",\n {\n className: targetClassName,\n onMouseDown: () => {\n wasOpenRef.current = isOpen;\n },\n // Toggle on click of the already-selected cell: clicking an open cell\n // dismisses it (without entering nav mode); clicking a closed one\n // reopens it. New-cell clicks are opened by `onSelection` instead.\n onClick: () => {\n if (wasOpenRef.current) close(false);\n else openCellSurface?.();\n },\n ref,\n },\n valueViewer,\n ),\n );\n}\n"],"names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A,QACA;AAAA,MAAA;AAAA,MAEF;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -3,31 +3,75 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const main_module = require("./main.module.sass.cjs");
|
|
4
4
|
const core = require("@blueprintjs/core");
|
|
5
5
|
const react = require("react");
|
|
6
|
-
const
|
|
6
|
+
const provider = require("../provider.cjs");
|
|
7
7
|
function EditableTextArea({
|
|
8
8
|
value,
|
|
9
9
|
onChange,
|
|
10
10
|
isEdited,
|
|
11
|
-
resetValue
|
|
11
|
+
resetValue,
|
|
12
|
+
autoFocus = true
|
|
12
13
|
}) {
|
|
13
14
|
const ref = react.useRef(null);
|
|
15
|
+
const tableElement = provider.useSelector((s) => s.tableElement);
|
|
16
|
+
const navDirection = provider.useSelector((s) => s.lastNavDirection);
|
|
14
17
|
react.useEffect(() => {
|
|
18
|
+
if (!autoFocus) return;
|
|
15
19
|
if (ref.current == null) return;
|
|
16
20
|
ref.current.focus();
|
|
17
|
-
const
|
|
18
|
-
ref.current.
|
|
19
|
-
|
|
21
|
+
const atStart = navDirection === "up" || navDirection === "left";
|
|
22
|
+
const pos = atStart ? 0 : ref.current.value?.length ?? 0;
|
|
23
|
+
ref.current.setSelectionRange(pos, pos);
|
|
24
|
+
}, [autoFocus]);
|
|
25
|
+
function handOffToTable(evt) {
|
|
26
|
+
evt.preventDefault();
|
|
27
|
+
ref.current?.blur();
|
|
28
|
+
if (tableElement != null) {
|
|
29
|
+
tableElement.focus();
|
|
30
|
+
tableElement.dispatchEvent(
|
|
31
|
+
new KeyboardEvent("keydown", {
|
|
32
|
+
key: evt.key,
|
|
33
|
+
code: evt.code,
|
|
34
|
+
bubbles: true,
|
|
35
|
+
cancelable: true
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function onKeyDown(evt) {
|
|
41
|
+
const el = ref.current;
|
|
42
|
+
if (evt.key === "Enter") {
|
|
43
|
+
evt.stopPropagation();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (evt.key === "Escape") {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const collapsed = el != null && el.selectionStart === el.selectionEnd;
|
|
50
|
+
if (collapsed && (evt.key === "c" || evt.key === "v" || evt.key === "x") && (evt.ctrlKey || evt.metaKey)) {
|
|
51
|
+
handOffToTable(evt);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (el != null && collapsed) {
|
|
55
|
+
const atStart = el.selectionStart === 0;
|
|
56
|
+
const atEnd = el.selectionStart === el.value.length;
|
|
57
|
+
const leaving = (evt.key === "ArrowUp" || evt.key === "ArrowLeft") && atStart || (evt.key === "ArrowDown" || evt.key === "ArrowRight") && atEnd;
|
|
58
|
+
if (leaving) {
|
|
59
|
+
handOffToTable(evt);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
evt.stopPropagation();
|
|
64
|
+
}
|
|
20
65
|
return main_module.default("div.editable-text-area", [
|
|
21
66
|
main_module.default("textarea.bp6-input", {
|
|
22
67
|
ref,
|
|
23
68
|
defaultValue: value ?? "",
|
|
24
|
-
//onChange: (evt) => setValue(evt.target.value),
|
|
25
69
|
onBlur: (evt) => {
|
|
26
70
|
if (evt.target.value !== value) {
|
|
27
71
|
onChange(evt.target.value);
|
|
28
72
|
}
|
|
29
73
|
},
|
|
30
|
-
onKeyDown
|
|
74
|
+
onKeyDown
|
|
31
75
|
}),
|
|
32
76
|
main_module.default("div.tools", [
|
|
33
77
|
// Tool to reset the value to the default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-areas.cjs","sources":["../../src/components/text-areas.ts"],"sourcesContent":["import h from \"./main.module.sass\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useEffect, useRef
|
|
1
|
+
{"version":3,"file":"text-areas.cjs","sources":["../../src/components/text-areas.ts"],"sourcesContent":["import h from \"./main.module.sass\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useEffect, useRef } from \"react\";\nimport { useSelector } from \"../provider\";\n\nexport type DataEditorProps = {\n value: string;\n editable: boolean;\n onChange: (value: string) => void;\n isEdited?: boolean;\n resetValue?: () => void;\n /** Focus the textarea on mount. Defaults to `true`. The data sheet sets\n * this from the table's `cellInteraction` mode. */\n autoFocus?: boolean;\n};\n\nexport function EditableTextArea({\n value,\n onChange,\n isEdited,\n resetValue,\n autoFocus = true,\n}: DataEditorProps) {\n const ref = useRef<HTMLTextAreaElement>(null);\n const tableElement = useSelector((s) => s.tableElement);\n const navDirection = useSelector((s) => s.lastNavDirection);\n\n useEffect(() => {\n if (!autoFocus) return;\n if (ref.current == null) return;\n ref.current.focus();\n // Place the cursor on the side we're travelling toward, so one more arrow\n // in the same direction leaves the cell.\n const atStart = navDirection === \"up\" || navDirection === \"left\";\n const pos = atStart ? 0 : (ref.current.value?.length ?? 0);\n ref.current.setSelectionRange(pos, pos);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [autoFocus]);\n\n // Hand keyboard focus (and the in-flight key) back to the table so the\n // arrow key that left the editor navigates in a single press.\n function handOffToTable(evt) {\n evt.preventDefault();\n ref.current?.blur();\n if (tableElement != null) {\n tableElement.focus();\n tableElement.dispatchEvent(\n new KeyboardEvent(\"keydown\", {\n key: evt.key,\n code: evt.code,\n bubbles: true,\n cancelable: true,\n }),\n );\n }\n }\n\n function onKeyDown(evt) {\n const el = ref.current;\n if (evt.key === \"Enter\") {\n // Newline stays within the textarea.\n evt.stopPropagation();\n return;\n }\n if (evt.key === \"Escape\") {\n // Let it bubble to EditorPopup, which closes and refocuses the table.\n return;\n }\n\n const collapsed = el != null && el.selectionStart === el.selectionEnd;\n\n // Copy/paste with no text selected: hand off so the table can act on the\n // whole cell/row.\n if (\n collapsed &&\n (evt.key === \"c\" || evt.key === \"v\" || evt.key === \"x\") &&\n (evt.ctrlKey || evt.metaKey)\n ) {\n handOffToTable(evt);\n return;\n }\n\n // Only leave the editor when the cursor is at the text boundary in the\n // direction of travel — otherwise the arrow moves within the text.\n if (el != null && collapsed) {\n const atStart = el.selectionStart === 0;\n const atEnd = el.selectionStart === el.value.length;\n const leaving =\n ((evt.key === \"ArrowUp\" || evt.key === \"ArrowLeft\") && atStart) ||\n ((evt.key === \"ArrowDown\" || evt.key === \"ArrowRight\") && atEnd);\n if (leaving) {\n handOffToTable(evt);\n return;\n }\n }\n\n // Keep every other key inside the textarea; stop it from bubbling (through\n // the portal's React tree) to the table's hotkey handler.\n evt.stopPropagation();\n }\n\n return h(\"div.editable-text-area\", [\n h(\"textarea.bp6-input\", {\n ref,\n defaultValue: value ?? \"\",\n onBlur: (evt) => {\n if (evt.target.value !== value) {\n onChange(evt.target.value);\n }\n },\n onKeyDown,\n }),\n h(\"div.tools\", [\n // Tool to reset the value to the default\n h(Button, {\n icon: \"undo\",\n minimal: true,\n small: true,\n intent: isEdited ? \"success\" : \"none\",\n disabled: !isEdited,\n onClick(evt) {\n resetValue?.();\n },\n }),\n ]),\n ]);\n}\n"],"names":["useRef","useSelector","useEffect","h","Button"],"mappings":";;;;;;AAgBO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAAoB;AAClB,QAAM,MAAMA,MAAAA,OAA4B,IAAI;AAC5C,QAAM,eAAeC,SAAAA,YAAY,CAAC,MAAM,EAAE,YAAY;AACtD,QAAM,eAAeA,SAAAA,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAE1DC,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,UAAW;AAChB,QAAI,IAAI,WAAW,KAAM;AACzB,QAAI,QAAQ,MAAA;AAGZ,UAAM,UAAU,iBAAiB,QAAQ,iBAAiB;AAC1D,UAAM,MAAM,UAAU,IAAK,IAAI,QAAQ,OAAO,UAAU;AACxD,QAAI,QAAQ,kBAAkB,KAAK,GAAG;AAAA,EAExC,GAAG,CAAC,SAAS,CAAC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;AAAA;AAAA,MAEbA,YAAAA,QAAEC,KAAAA,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ,WAAW,YAAY;AAAA,QAC/B,UAAU,CAAC;AAAA,QACX,QAAQ,KAAK;AACX,uBAAA;AAAA,QACF;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;;"}
|
|
@@ -4,5 +4,8 @@ export type DataEditorProps = {
|
|
|
4
4
|
onChange: (value: string) => void;
|
|
5
5
|
isEdited?: boolean;
|
|
6
6
|
resetValue?: () => void;
|
|
7
|
+
/** Focus the textarea on mount. Defaults to `true`. The data sheet sets
|
|
8
|
+
* this from the table's `cellInteraction` mode. */
|
|
9
|
+
autoFocus?: boolean;
|
|
7
10
|
};
|
|
8
|
-
export declare function EditableTextArea({ value, onChange, isEdited, resetValue, }: DataEditorProps): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
|
|
11
|
+
export declare function EditableTextArea({ value, onChange, isEdited, resetValue, autoFocus, }: DataEditorProps): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
|
|
@@ -1,31 +1,75 @@
|
|
|
1
1
|
import h from "./main.module.sass.js";
|
|
2
2
|
import { Button } from "@blueprintjs/core";
|
|
3
3
|
import { useRef, useEffect } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useSelector } from "../provider.js";
|
|
5
5
|
function EditableTextArea({
|
|
6
6
|
value,
|
|
7
7
|
onChange,
|
|
8
8
|
isEdited,
|
|
9
|
-
resetValue
|
|
9
|
+
resetValue,
|
|
10
|
+
autoFocus = true
|
|
10
11
|
}) {
|
|
11
12
|
const ref = useRef(null);
|
|
13
|
+
const tableElement = useSelector((s) => s.tableElement);
|
|
14
|
+
const navDirection = useSelector((s) => s.lastNavDirection);
|
|
12
15
|
useEffect(() => {
|
|
16
|
+
if (!autoFocus) return;
|
|
13
17
|
if (ref.current == null) return;
|
|
14
18
|
ref.current.focus();
|
|
15
|
-
const
|
|
16
|
-
ref.current.
|
|
17
|
-
|
|
19
|
+
const atStart = navDirection === "up" || navDirection === "left";
|
|
20
|
+
const pos = atStart ? 0 : ref.current.value?.length ?? 0;
|
|
21
|
+
ref.current.setSelectionRange(pos, pos);
|
|
22
|
+
}, [autoFocus]);
|
|
23
|
+
function handOffToTable(evt) {
|
|
24
|
+
evt.preventDefault();
|
|
25
|
+
ref.current?.blur();
|
|
26
|
+
if (tableElement != null) {
|
|
27
|
+
tableElement.focus();
|
|
28
|
+
tableElement.dispatchEvent(
|
|
29
|
+
new KeyboardEvent("keydown", {
|
|
30
|
+
key: evt.key,
|
|
31
|
+
code: evt.code,
|
|
32
|
+
bubbles: true,
|
|
33
|
+
cancelable: true
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function onKeyDown(evt) {
|
|
39
|
+
const el = ref.current;
|
|
40
|
+
if (evt.key === "Enter") {
|
|
41
|
+
evt.stopPropagation();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (evt.key === "Escape") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const collapsed = el != null && el.selectionStart === el.selectionEnd;
|
|
48
|
+
if (collapsed && (evt.key === "c" || evt.key === "v" || evt.key === "x") && (evt.ctrlKey || evt.metaKey)) {
|
|
49
|
+
handOffToTable(evt);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (el != null && collapsed) {
|
|
53
|
+
const atStart = el.selectionStart === 0;
|
|
54
|
+
const atEnd = el.selectionStart === el.value.length;
|
|
55
|
+
const leaving = (evt.key === "ArrowUp" || evt.key === "ArrowLeft") && atStart || (evt.key === "ArrowDown" || evt.key === "ArrowRight") && atEnd;
|
|
56
|
+
if (leaving) {
|
|
57
|
+
handOffToTable(evt);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
evt.stopPropagation();
|
|
62
|
+
}
|
|
18
63
|
return h("div.editable-text-area", [
|
|
19
64
|
h("textarea.bp6-input", {
|
|
20
65
|
ref,
|
|
21
66
|
defaultValue: value ?? "",
|
|
22
|
-
//onChange: (evt) => setValue(evt.target.value),
|
|
23
67
|
onBlur: (evt) => {
|
|
24
68
|
if (evt.target.value !== value) {
|
|
25
69
|
onChange(evt.target.value);
|
|
26
70
|
}
|
|
27
71
|
},
|
|
28
|
-
onKeyDown
|
|
72
|
+
onKeyDown
|
|
29
73
|
}),
|
|
30
74
|
h("div.tools", [
|
|
31
75
|
// Tool to reset the value to the default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-areas.js","sources":["../../src/components/text-areas.ts"],"sourcesContent":["import h from \"./main.module.sass\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useEffect, useRef
|
|
1
|
+
{"version":3,"file":"text-areas.js","sources":["../../src/components/text-areas.ts"],"sourcesContent":["import h from \"./main.module.sass\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useEffect, useRef } from \"react\";\nimport { useSelector } from \"../provider\";\n\nexport type DataEditorProps = {\n value: string;\n editable: boolean;\n onChange: (value: string) => void;\n isEdited?: boolean;\n resetValue?: () => void;\n /** Focus the textarea on mount. Defaults to `true`. The data sheet sets\n * this from the table's `cellInteraction` mode. */\n autoFocus?: boolean;\n};\n\nexport function EditableTextArea({\n value,\n onChange,\n isEdited,\n resetValue,\n autoFocus = true,\n}: DataEditorProps) {\n const ref = useRef<HTMLTextAreaElement>(null);\n const tableElement = useSelector((s) => s.tableElement);\n const navDirection = useSelector((s) => s.lastNavDirection);\n\n useEffect(() => {\n if (!autoFocus) return;\n if (ref.current == null) return;\n ref.current.focus();\n // Place the cursor on the side we're travelling toward, so one more arrow\n // in the same direction leaves the cell.\n const atStart = navDirection === \"up\" || navDirection === \"left\";\n const pos = atStart ? 0 : (ref.current.value?.length ?? 0);\n ref.current.setSelectionRange(pos, pos);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [autoFocus]);\n\n // Hand keyboard focus (and the in-flight key) back to the table so the\n // arrow key that left the editor navigates in a single press.\n function handOffToTable(evt) {\n evt.preventDefault();\n ref.current?.blur();\n if (tableElement != null) {\n tableElement.focus();\n tableElement.dispatchEvent(\n new KeyboardEvent(\"keydown\", {\n key: evt.key,\n code: evt.code,\n bubbles: true,\n cancelable: true,\n }),\n );\n }\n }\n\n function onKeyDown(evt) {\n const el = ref.current;\n if (evt.key === \"Enter\") {\n // Newline stays within the textarea.\n evt.stopPropagation();\n return;\n }\n if (evt.key === \"Escape\") {\n // Let it bubble to EditorPopup, which closes and refocuses the table.\n return;\n }\n\n const collapsed = el != null && el.selectionStart === el.selectionEnd;\n\n // Copy/paste with no text selected: hand off so the table can act on the\n // whole cell/row.\n if (\n collapsed &&\n (evt.key === \"c\" || evt.key === \"v\" || evt.key === \"x\") &&\n (evt.ctrlKey || evt.metaKey)\n ) {\n handOffToTable(evt);\n return;\n }\n\n // Only leave the editor when the cursor is at the text boundary in the\n // direction of travel — otherwise the arrow moves within the text.\n if (el != null && collapsed) {\n const atStart = el.selectionStart === 0;\n const atEnd = el.selectionStart === el.value.length;\n const leaving =\n ((evt.key === \"ArrowUp\" || evt.key === \"ArrowLeft\") && atStart) ||\n ((evt.key === \"ArrowDown\" || evt.key === \"ArrowRight\") && atEnd);\n if (leaving) {\n handOffToTable(evt);\n return;\n }\n }\n\n // Keep every other key inside the textarea; stop it from bubbling (through\n // the portal's React tree) to the table's hotkey handler.\n evt.stopPropagation();\n }\n\n return h(\"div.editable-text-area\", [\n h(\"textarea.bp6-input\", {\n ref,\n defaultValue: value ?? \"\",\n onBlur: (evt) => {\n if (evt.target.value !== value) {\n onChange(evt.target.value);\n }\n },\n onKeyDown,\n }),\n h(\"div.tools\", [\n // Tool to reset the value to the default\n h(Button, {\n icon: \"undo\",\n minimal: true,\n small: true,\n intent: isEdited ? \"success\" : \"none\",\n disabled: !isEdited,\n onClick(evt) {\n resetValue?.();\n },\n }),\n ]),\n ]);\n}\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AAQ,GAAG,mBAAmB,GAAG,MAAM;AAC7C,YAAM,WACF,IAAI,QAAQ,aAAa,IAAI,QAAQ,gBAAgB,YACrD,IAAI,QAAQ,eAAe,IAAI,QAAQ,iBAAiB;AAC5D,UAAI,SAAS;AACX,uBAAe,GAAG;AAClB;AAAA,MACF;AAAA,IACF;AAIA,QAAI,gBAAA;AAAA,EACN;AAEA,SAAO,EAAE,0BAA0B;AAAA,IACjC,EAAE,sBAAsB;AAAA,MACtB;AAAA,MACA,cAAc,SAAS;AAAA,MACvB,QAAQ,CAAC,QAAQ;AACf,YAAI,IAAI,OAAO,UAAU,OAAO;AAC9B,mBAAS,IAAI,OAAO,KAAK;AAAA,QAC3B;AAAA,MACF;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACD,EAAE,aAAa;AAAA;AAAA,MAEb,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ,WAAW,YAAY;AAAA,QAC/B,UAAU,CAAC;AAAA,QACX,QAAQ,KAAK;AACX,uBAAA;AAAA,QACF;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;"}
|
|
@@ -2,17 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const main_module = require("../postgrest-table/main.module.sass.cjs");
|
|
4
4
|
const provider = require("../provider.cjs");
|
|
5
|
+
const core = require("@blueprintjs/core");
|
|
5
6
|
const dataLoaders = require("../postgrest-table/data-loaders.cjs");
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
return main_module.default(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function LoadProgressIndicator() {
|
|
8
|
+
const footer = provider.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.Spinner, { size: 12 });
|
|
14
|
+
} else if (total != null && loaded >= total) {
|
|
15
|
+
status = main_module.default(core.Icon, { icon: "tick-circle", intent: "success", size: 12 });
|
|
16
|
+
} else {
|
|
17
|
+
status = main_module.default(core.Icon, { icon: "more", size: 12 });
|
|
18
|
+
}
|
|
19
|
+
return main_module.default("div.load-progress", [
|
|
20
|
+
main_module.default("span.load-progress-label", [
|
|
21
|
+
`${loaded}`,
|
|
22
|
+
total != null ? ` of ${total}` : "",
|
|
23
|
+
" rows"
|
|
24
|
+
]),
|
|
25
|
+
status
|
|
12
26
|
]);
|
|
13
27
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
28
|
+
function PageControl() {
|
|
29
|
+
const { page, totalPages, loading } = provider.ctx.useValue(dataLoaders.tableFooterAtom);
|
|
30
|
+
const setPage = provider.ctx.useSet(dataLoaders.chunkPageAtom);
|
|
31
|
+
const atEnd = totalPages != null && page >= totalPages - 1;
|
|
32
|
+
return main_module.default("div.load-progress", [
|
|
33
|
+
loading ? main_module.default(core.Spinner, { size: 12 }) : null,
|
|
34
|
+
main_module.default("span.load-progress-label", [
|
|
35
|
+
`Page ${page + 1}`,
|
|
36
|
+
totalPages != null ? ` of ${totalPages}` : ""
|
|
37
|
+
]),
|
|
38
|
+
main_module.default(core.ButtonGroup, { minimal: true }, [
|
|
39
|
+
main_module.default(core.Button, {
|
|
40
|
+
icon: "chevron-left",
|
|
41
|
+
small: true,
|
|
42
|
+
disabled: page <= 0 || loading,
|
|
43
|
+
onClick: () => setPage(Math.max(0, page - 1))
|
|
44
|
+
}),
|
|
45
|
+
main_module.default(core.Button, {
|
|
46
|
+
icon: "chevron-right",
|
|
47
|
+
small: true,
|
|
48
|
+
disabled: atEnd || loading,
|
|
49
|
+
onClick: () => setPage(page + 1)
|
|
50
|
+
})
|
|
51
|
+
])
|
|
52
|
+
]);
|
|
16
53
|
}
|
|
17
|
-
exports.
|
|
54
|
+
exports.LoadProgressIndicator = LoadProgressIndicator;
|
|
18
55
|
//# sourceMappingURL=view-info.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-info.cjs","sources":["../../src/components/view-info.ts"],"sourcesContent":["import h from \"../postgrest-table/main.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"view-info.cjs","sources":["../../src/components/view-info.ts"],"sourcesContent":["import h from \"../postgrest-table/main.module.sass\";\nimport {\n ViewInfo,\n viewInfoAtom,\n tableFooterAtom,\n chunkPageAtom,\n} from \"../postgrest-table\";\nimport { ctx } from \"../provider.ts\";\nimport { Button, ButtonGroup, Icon, Spinner } from \"@blueprintjs/core\";\n\nfunction VisibleRegionControl() {\n const viewInfo: ViewInfo = ctx.useValue(viewInfoAtom);\n\n return h(\"p\", [\n `Rows ${viewInfo.visibleRegion.rowIndexStart}–${viewInfo.visibleRegion.rowIndexEnd}`,\n \" of \",\n h(\"span.total-count\", viewInfo.totalCount),\n ]);\n}\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-circle\", intent: \"success\", size: 12 });\n } else {\n status = h(Icon, { icon: \"more\", size: 12 });\n }\n\n return h(\"div.load-progress\", [\n h(\"span.load-progress-label\", [\n `${loaded}`,\n total != null ? ` of ${total}` : \"\",\n \" rows\",\n ]),\n status,\n ]);\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","chunkPageAtom","ButtonGroup","Button"],"mappings":";;;;;;AAwBO,SAAS,wBAAwB;AACtC,QAAM,SAASA,SAAAA,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,KAAAA,SAAS,EAAE,MAAM,IAAI;AAAA,EAClC,WAAW,SAAS,QAAQ,UAAU,OAAO;AAC3C,aAASD,YAAAA,QAAEE,KAAAA,MAAM,EAAE,MAAM,eAAe,QAAQ,WAAW,MAAM,IAAI;AAAA,EACvE,OAAO;AACL,aAASF,YAAAA,QAAEE,WAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C;AAEA,SAAOF,YAAAA,QAAE,qBAAqB;AAAA,IAC5BA,YAAAA,QAAE,4BAA4B;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT,SAAS,OAAO,OAAO,KAAK,KAAK;AAAA,MACjC;AAAA,IAAA,CACD;AAAA,IACD;AAAA,EAAA,CACD;AACH;AAGA,SAAS,cAAc;AACrB,QAAM,EAAE,MAAM,YAAY,YAAYF,SAAAA,IAAI,SAASC,2BAAe;AAClE,QAAM,UAAUD,SAAAA,IAAI,OAAOK,yBAAa;AACxC,QAAM,QAAQ,cAAc,QAAQ,QAAQ,aAAa;AAEzD,SAAOH,YAAAA,QAAE,qBAAqB;AAAA,IAC5B,UAAUA,YAAAA,QAAEC,KAAAA,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,QAAEI,KAAAA,aAAa,EAAE,SAAS,QAAQ;AAAA,MAChCJ,YAAAA,QAAEK,KAAAA,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,MACDL,YAAAA,QAAEK,KAAAA,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 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In
|
|
2
|
+
* scroll mode: rows loaded, "of total" when known, and a status icon (spinner
|
|
3
|
+
* loading / check complete / dots incomplete). In paged mode: prev/next page
|
|
4
|
+
* controls with "Page X of Y". */
|
|
5
|
+
export declare function LoadProgressIndicator(): import('react').DOMElement<import('react').DOMAttributes<Element>, Element> | import('react').FunctionComponentElement<{}>;
|