@macrostrat/data-sheet 4.0.0-dev3 → 4.0.1
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 +56 -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 +51 -32
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +3 -7
- package/dist/actions/selection.js +51 -32
- 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 +73 -54
- 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,30 @@
|
|
|
1
|
+
import { Dialog } from "@blueprintjs/core";
|
|
2
|
+
import h from "./main.module.sass";
|
|
3
|
+
import { useSelector } from "../provider";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Modal presentation for a cell's `cellDetail` surface. Subscribes to the
|
|
7
|
+
* store's `cellSurfaceOpen` so the dialog opens/closes reactively (Escape,
|
|
8
|
+
* the close button, and outside-click all route through `closeCellSurface`).
|
|
9
|
+
* Rendering the dialog from a plain render snapshot would leave it unable to
|
|
10
|
+
* close, since the cell renderer isn't re-invoked on every store change.
|
|
11
|
+
*/
|
|
12
|
+
export function CellDetailModal({ title, valueViewer, children }) {
|
|
13
|
+
const isOpen = useSelector((s) => s.cellSurfaceOpen);
|
|
14
|
+
const closeCellSurface = useSelector((s) => s.closeCellSurface);
|
|
15
|
+
const tableElement = useSelector((s) => s.tableElement);
|
|
16
|
+
|
|
17
|
+
const onClose = () => {
|
|
18
|
+
closeCellSurface?.();
|
|
19
|
+
tableElement?.focus?.();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return h([
|
|
23
|
+
valueViewer,
|
|
24
|
+
h(
|
|
25
|
+
Dialog,
|
|
26
|
+
{ isOpen, onClose, title, canEscapeKeyClose: true, canOutsideClickClose: true },
|
|
27
|
+
h("div.bp6-dialog-body", children),
|
|
28
|
+
),
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
import { ErrorBoundary } from "@macrostrat/ui-components";
|
|
2
2
|
import { PopoverNext } from "@blueprintjs/core";
|
|
3
3
|
import h from "./main.module.sass";
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback, useRef } from "react";
|
|
5
5
|
import { useSelector } from "../provider";
|
|
6
6
|
|
|
7
7
|
export function EditorPopup(props) {
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
targetClassName,
|
|
11
|
-
autoFocus,
|
|
12
|
-
valueViewer,
|
|
13
|
-
placement = "right-start",
|
|
14
|
-
} = props;
|
|
8
|
+
const { children, targetClassName, valueViewer, placement = "right-start" } =
|
|
9
|
+
props;
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
// Open state is owned by the store (not local), so navigation, clicks, and
|
|
12
|
+
// the Escape handler all agree on whether the focused cell's surface is
|
|
13
|
+
// open. We never render a focus-stealing element, so keyboard focus stays on
|
|
14
|
+
// the Blueprint table until an editor takes it — that's what keeps arrow-key
|
|
15
|
+
// navigation working (cf. the Color column and read-only detail panels).
|
|
16
|
+
const isOpen = useSelector((s) => s.cellSurfaceOpen);
|
|
17
|
+
const tableElement = useSelector((s) => s.tableElement);
|
|
18
|
+
const openCellSurface = useSelector((s) => s.openCellSurface);
|
|
19
|
+
const closeCellSurface = useSelector((s) => s.closeCellSurface);
|
|
18
20
|
|
|
19
21
|
const ref = useRef(null);
|
|
22
|
+
// Whether the surface was open at mousedown. `onSelection` doesn't change
|
|
23
|
+
// open-state for a click on the already-selected cell, so this reflects the
|
|
24
|
+
// true pre-click state and the click toggles cleanly (no flash).
|
|
25
|
+
const wasOpenRef = useRef(false);
|
|
20
26
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const close = useCallback(
|
|
28
|
+
(suppress: boolean) => {
|
|
29
|
+
closeCellSurface?.({ suppress });
|
|
30
|
+
// Return focus to the table so arrow keys navigate again.
|
|
31
|
+
tableElement?.focus();
|
|
32
|
+
},
|
|
33
|
+
[closeCellSurface, tableElement],
|
|
34
|
+
);
|
|
29
35
|
|
|
30
36
|
return h(
|
|
31
37
|
PopoverNext,
|
|
@@ -38,9 +44,7 @@ export function EditorPopup(props) {
|
|
|
38
44
|
},
|
|
39
45
|
onKeyDown(evt) {
|
|
40
46
|
if (evt.key === "Escape") {
|
|
41
|
-
|
|
42
|
-
setIsOpen(false);
|
|
43
|
-
}
|
|
47
|
+
close(true);
|
|
44
48
|
evt.stopPropagation();
|
|
45
49
|
evt.preventDefault();
|
|
46
50
|
return;
|
|
@@ -59,7 +63,9 @@ export function EditorPopup(props) {
|
|
|
59
63
|
// offset: { enabled: true, options: { offset: [0, 8] } },
|
|
60
64
|
// },
|
|
61
65
|
placement,
|
|
62
|
-
|
|
66
|
+
// Fully controlled via `isOpen`; use click (not hover) so hovering the
|
|
67
|
+
// target can't momentarily preview/dismiss the popover.
|
|
68
|
+
interactionKind: "click",
|
|
63
69
|
isOpen,
|
|
64
70
|
// Portal must be used to avoid issues with the editor being clipped to the bounds of the cell
|
|
65
71
|
//usePortal: true,
|
|
@@ -68,11 +74,19 @@ export function EditorPopup(props) {
|
|
|
68
74
|
"span.editor-popup-target",
|
|
69
75
|
{
|
|
70
76
|
className: targetClassName,
|
|
71
|
-
|
|
77
|
+
onMouseDown: () => {
|
|
78
|
+
wasOpenRef.current = isOpen;
|
|
79
|
+
},
|
|
80
|
+
// Toggle on click of the already-selected cell: clicking an open cell
|
|
81
|
+
// dismisses it (without entering nav mode); clicking a closed one
|
|
82
|
+
// reopens it. New-cell clicks are opened by `onSelection` instead.
|
|
83
|
+
onClick: () => {
|
|
84
|
+
if (wasOpenRef.current) close(false);
|
|
85
|
+
else openCellSurface?.();
|
|
86
|
+
},
|
|
72
87
|
ref,
|
|
73
88
|
},
|
|
74
|
-
|
|
75
|
-
isOpen ? valueViewer : (inlineEditor ?? valueViewer),
|
|
89
|
+
valueViewer,
|
|
76
90
|
),
|
|
77
91
|
);
|
|
78
92
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import h from "./main.module.sass";
|
|
2
2
|
import { Button } from "@blueprintjs/core";
|
|
3
|
-
import { useEffect, useRef
|
|
4
|
-
import {
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { useSelector } from "../provider";
|
|
5
5
|
|
|
6
6
|
export type DataEditorProps = {
|
|
7
7
|
value: string;
|
|
@@ -9,6 +9,9 @@ export type DataEditorProps = {
|
|
|
9
9
|
onChange: (value: string) => void;
|
|
10
10
|
isEdited?: boolean;
|
|
11
11
|
resetValue?: () => void;
|
|
12
|
+
/** Focus the textarea on mount. Defaults to `true`. The data sheet sets
|
|
13
|
+
* this from the table's `cellInteraction` mode. */
|
|
14
|
+
autoFocus?: boolean;
|
|
12
15
|
};
|
|
13
16
|
|
|
14
17
|
export function EditableTextArea({
|
|
@@ -16,35 +19,96 @@ export function EditableTextArea({
|
|
|
16
19
|
onChange,
|
|
17
20
|
isEdited,
|
|
18
21
|
resetValue,
|
|
22
|
+
autoFocus = true,
|
|
19
23
|
}: DataEditorProps) {
|
|
20
|
-
const ref = useRef(null);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
// useEffect(() => {
|
|
25
|
-
// setValue(value);
|
|
26
|
-
// }, [value]);
|
|
24
|
+
const ref = useRef<HTMLTextAreaElement>(null);
|
|
25
|
+
const tableElement = useSelector((s) => s.tableElement);
|
|
26
|
+
const navDirection = useSelector((s) => s.lastNavDirection);
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
|
+
if (!autoFocus) return;
|
|
29
30
|
if (ref.current == null) return;
|
|
30
31
|
ref.current.focus();
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ref.current.
|
|
35
|
-
|
|
32
|
+
// Place the cursor on the side we're travelling toward, so one more arrow
|
|
33
|
+
// in the same direction leaves the cell.
|
|
34
|
+
const atStart = navDirection === "up" || navDirection === "left";
|
|
35
|
+
const pos = atStart ? 0 : (ref.current.value?.length ?? 0);
|
|
36
|
+
ref.current.setSelectionRange(pos, pos);
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
|
+
}, [autoFocus]);
|
|
39
|
+
|
|
40
|
+
// Hand keyboard focus (and the in-flight key) back to the table so the
|
|
41
|
+
// arrow key that left the editor navigates in a single press.
|
|
42
|
+
function handOffToTable(evt) {
|
|
43
|
+
evt.preventDefault();
|
|
44
|
+
ref.current?.blur();
|
|
45
|
+
if (tableElement != null) {
|
|
46
|
+
tableElement.focus();
|
|
47
|
+
tableElement.dispatchEvent(
|
|
48
|
+
new KeyboardEvent("keydown", {
|
|
49
|
+
key: evt.key,
|
|
50
|
+
code: evt.code,
|
|
51
|
+
bubbles: true,
|
|
52
|
+
cancelable: true,
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onKeyDown(evt) {
|
|
59
|
+
const el = ref.current;
|
|
60
|
+
if (evt.key === "Enter") {
|
|
61
|
+
// Newline stays within the textarea.
|
|
62
|
+
evt.stopPropagation();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (evt.key === "Escape") {
|
|
66
|
+
// Let it bubble to EditorPopup, which closes and refocuses the table.
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const collapsed = el != null && el.selectionStart === el.selectionEnd;
|
|
71
|
+
|
|
72
|
+
// Copy/paste with no text selected: hand off so the table can act on the
|
|
73
|
+
// whole cell/row.
|
|
74
|
+
if (
|
|
75
|
+
collapsed &&
|
|
76
|
+
(evt.key === "c" || evt.key === "v" || evt.key === "x") &&
|
|
77
|
+
(evt.ctrlKey || evt.metaKey)
|
|
78
|
+
) {
|
|
79
|
+
handOffToTable(evt);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Only leave the editor when the cursor is at the text boundary in the
|
|
84
|
+
// direction of travel — otherwise the arrow moves within the text.
|
|
85
|
+
if (el != null && collapsed) {
|
|
86
|
+
const atStart = el.selectionStart === 0;
|
|
87
|
+
const atEnd = el.selectionStart === el.value.length;
|
|
88
|
+
const leaving =
|
|
89
|
+
((evt.key === "ArrowUp" || evt.key === "ArrowLeft") && atStart) ||
|
|
90
|
+
((evt.key === "ArrowDown" || evt.key === "ArrowRight") && atEnd);
|
|
91
|
+
if (leaving) {
|
|
92
|
+
handOffToTable(evt);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Keep every other key inside the textarea; stop it from bubbling (through
|
|
98
|
+
// the portal's React tree) to the table's hotkey handler.
|
|
99
|
+
evt.stopPropagation();
|
|
100
|
+
}
|
|
36
101
|
|
|
37
102
|
return h("div.editable-text-area", [
|
|
38
103
|
h("textarea.bp6-input", {
|
|
39
104
|
ref,
|
|
40
105
|
defaultValue: value ?? "",
|
|
41
|
-
//onChange: (evt) => setValue(evt.target.value),
|
|
42
106
|
onBlur: (evt) => {
|
|
43
107
|
if (evt.target.value !== value) {
|
|
44
108
|
onChange(evt.target.value);
|
|
45
109
|
}
|
|
46
110
|
},
|
|
47
|
-
onKeyDown
|
|
111
|
+
onKeyDown,
|
|
48
112
|
}),
|
|
49
113
|
h("div.tools", [
|
|
50
114
|
// Tool to reset the value to the default
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import h from "../postgrest-table/main.module.sass";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ViewInfo,
|
|
4
|
+
viewInfoAtom,
|
|
5
|
+
tableFooterAtom,
|
|
6
|
+
chunkPageAtom,
|
|
7
|
+
} from "../postgrest-table";
|
|
3
8
|
import { ctx } from "../provider.ts";
|
|
9
|
+
import { Button, ButtonGroup, Icon, Spinner } from "@blueprintjs/core";
|
|
4
10
|
|
|
5
|
-
function
|
|
11
|
+
function VisibleRegionControl() {
|
|
6
12
|
const viewInfo: ViewInfo = ctx.useValue(viewInfoAtom);
|
|
7
13
|
|
|
8
14
|
return h("p", [
|
|
@@ -12,6 +18,59 @@ function ViewInfoControl() {
|
|
|
12
18
|
]);
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In
|
|
22
|
+
* scroll mode: rows loaded, "of total" when known, and a status icon (spinner
|
|
23
|
+
* loading / check complete / dots incomplete). In paged mode: prev/next page
|
|
24
|
+
* controls with "Page X of Y". */
|
|
25
|
+
export function LoadProgressIndicator() {
|
|
26
|
+
const footer = ctx.useValue(tableFooterAtom);
|
|
27
|
+
if (footer.mode === "paged") return h(PageControl);
|
|
28
|
+
|
|
29
|
+
const { loaded, total, loading } = footer;
|
|
30
|
+
let status: any;
|
|
31
|
+
if (loading) {
|
|
32
|
+
status = h(Spinner, { size: 12 });
|
|
33
|
+
} else if (total != null && loaded >= total) {
|
|
34
|
+
status = h(Icon, { icon: "tick-circle", intent: "success", size: 12 });
|
|
35
|
+
} else {
|
|
36
|
+
status = h(Icon, { icon: "more", size: 12 });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return h("div.load-progress", [
|
|
40
|
+
h("span.load-progress-label", [
|
|
41
|
+
`${loaded}`,
|
|
42
|
+
total != null ? ` of ${total}` : "",
|
|
43
|
+
" rows",
|
|
44
|
+
]),
|
|
45
|
+
status,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Prev/next pager for paged fetch mode. */
|
|
50
|
+
function PageControl() {
|
|
51
|
+
const { page, totalPages, loading } = ctx.useValue(tableFooterAtom);
|
|
52
|
+
const setPage = ctx.useSet(chunkPageAtom);
|
|
53
|
+
const atEnd = totalPages != null && page >= totalPages - 1;
|
|
54
|
+
|
|
55
|
+
return h("div.load-progress", [
|
|
56
|
+
loading ? h(Spinner, { size: 12 }) : null,
|
|
57
|
+
h("span.load-progress-label", [
|
|
58
|
+
`Page ${page + 1}`,
|
|
59
|
+
totalPages != null ? ` of ${totalPages}` : "",
|
|
60
|
+
]),
|
|
61
|
+
h(ButtonGroup, { minimal: true }, [
|
|
62
|
+
h(Button, {
|
|
63
|
+
icon: "chevron-left",
|
|
64
|
+
small: true,
|
|
65
|
+
disabled: page <= 0 || loading,
|
|
66
|
+
onClick: () => setPage(Math.max(0, page - 1)),
|
|
67
|
+
}),
|
|
68
|
+
h(Button, {
|
|
69
|
+
icon: "chevron-right",
|
|
70
|
+
small: true,
|
|
71
|
+
disabled: atEnd || loading,
|
|
72
|
+
onClick: () => setPage(page + 1),
|
|
73
|
+
}),
|
|
74
|
+
]),
|
|
75
|
+
]);
|
|
17
76
|
}
|