@macrostrat/data-sheet 4.0.0-dev2 → 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.
Files changed (212) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +44 -0
  3. package/dist/actions/builtin.cjs +36 -5
  4. package/dist/actions/builtin.cjs.map +1 -1
  5. package/dist/actions/builtin.d.ts +3 -2
  6. package/dist/actions/builtin.js +36 -5
  7. package/dist/actions/builtin.js.map +1 -1
  8. package/dist/actions/column-controls.cjs +149 -0
  9. package/dist/actions/column-controls.cjs.map +1 -0
  10. package/dist/actions/column-controls.d.ts +11 -0
  11. package/dist/actions/column-controls.js +147 -0
  12. package/dist/actions/column-controls.js.map +1 -0
  13. package/dist/actions/column-filter.cjs +68 -0
  14. package/dist/actions/column-filter.cjs.map +1 -0
  15. package/dist/actions/column-filter.d.ts +11 -0
  16. package/dist/actions/column-filter.js +66 -0
  17. package/dist/actions/column-filter.js.map +1 -0
  18. package/dist/actions/edit-actions.cjs +42 -0
  19. package/dist/actions/edit-actions.cjs.map +1 -0
  20. package/dist/actions/edit-actions.d.ts +14 -0
  21. package/dist/actions/edit-actions.js +42 -0
  22. package/dist/actions/edit-actions.js.map +1 -0
  23. package/dist/actions/filters.cjs +39 -23
  24. package/dist/actions/filters.cjs.map +1 -1
  25. package/dist/actions/filters.d.ts +6 -3
  26. package/dist/actions/filters.js +41 -25
  27. package/dist/actions/filters.js.map +1 -1
  28. package/dist/actions/index.d.ts +4 -0
  29. package/dist/actions/selection.cjs +39 -30
  30. package/dist/actions/selection.cjs.map +1 -1
  31. package/dist/actions/selection.d.ts +3 -7
  32. package/dist/actions/selection.js +39 -30
  33. package/dist/actions/selection.js.map +1 -1
  34. package/dist/actions/table-controls.cjs +41 -0
  35. package/dist/actions/table-controls.cjs.map +1 -0
  36. package/dist/actions/table-controls.d.ts +4 -0
  37. package/dist/actions/table-controls.js +39 -0
  38. package/dist/actions/table-controls.js.map +1 -0
  39. package/dist/actions/toolbar.cjs +69 -10
  40. package/dist/actions/toolbar.cjs.map +1 -1
  41. package/dist/actions/toolbar.d.ts +9 -6
  42. package/dist/actions/toolbar.js +69 -10
  43. package/dist/actions/toolbar.js.map +1 -1
  44. package/dist/actions/toolbar.module.sass.cjs +12 -7
  45. package/dist/actions/toolbar.module.sass.cjs.map +1 -1
  46. package/dist/actions/toolbar.module.sass.js +12 -7
  47. package/dist/actions/toolbar.module.sass.js.map +1 -1
  48. package/dist/actions/types.d.ts +49 -4
  49. package/dist/cell-renderer.cjs +150 -14
  50. package/dist/cell-renderer.cjs.map +1 -1
  51. package/dist/cell-renderer.d.ts +1 -1
  52. package/dist/cell-renderer.js +151 -15
  53. package/dist/cell-renderer.js.map +1 -1
  54. package/dist/components/cell-detail.cjs +24 -0
  55. package/dist/components/cell-detail.cjs.map +1 -0
  56. package/dist/components/cell-detail.d.ts +12 -0
  57. package/dist/components/cell-detail.js +24 -0
  58. package/dist/components/cell-detail.js.map +1 -0
  59. package/dist/components/editor-popup.cjs +28 -24
  60. package/dist/components/editor-popup.cjs.map +1 -1
  61. package/dist/components/editor-popup.js +29 -25
  62. package/dist/components/editor-popup.js.map +1 -1
  63. package/dist/components/index.d.ts +2 -2
  64. package/dist/components/text-areas.cjs +51 -7
  65. package/dist/components/text-areas.cjs.map +1 -1
  66. package/dist/components/text-areas.d.ts +4 -1
  67. package/dist/components/text-areas.js +51 -7
  68. package/dist/components/text-areas.js.map +1 -1
  69. package/dist/components/view-info.cjs +46 -9
  70. package/dist/components/view-info.cjs.map +1 -1
  71. package/dist/components/view-info.d.ts +5 -1
  72. package/dist/components/view-info.js +47 -10
  73. package/dist/components/view-info.js.map +1 -1
  74. package/dist/core.cjs +167 -73
  75. package/dist/core.cjs.map +1 -1
  76. package/dist/core.d.ts +53 -6
  77. package/dist/core.js +169 -75
  78. package/dist/core.js.map +1 -1
  79. package/dist/data-sheet.css +72 -123
  80. package/dist/filters/operators.cjs +91 -0
  81. package/dist/filters/operators.cjs.map +1 -0
  82. package/dist/filters/operators.d.ts +17 -0
  83. package/dist/filters/operators.js +91 -0
  84. package/dist/filters/operators.js.map +1 -0
  85. package/dist/index.cjs +38 -10
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.js +44 -16
  89. package/dist/index.js.map +1 -1
  90. package/dist/main.module.sass.cjs +13 -12
  91. package/dist/main.module.sass.cjs.map +1 -1
  92. package/dist/main.module.sass.js +13 -12
  93. package/dist/main.module.sass.js.map +1 -1
  94. package/dist/postgrest-table/data-loaders.cjs +255 -146
  95. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  96. package/dist/postgrest-table/data-loaders.d.ts +144 -46
  97. package/dist/postgrest-table/data-loaders.js +259 -150
  98. package/dist/postgrest-table/data-loaders.js.map +1 -1
  99. package/dist/postgrest-table/index.cjs +58 -169
  100. package/dist/postgrest-table/index.cjs.map +1 -1
  101. package/dist/postgrest-table/index.d.ts +5 -2
  102. package/dist/postgrest-table/index.js +63 -174
  103. package/dist/postgrest-table/index.js.map +1 -1
  104. package/dist/postgrest-table/loading-utils.cjs +0 -4
  105. package/dist/postgrest-table/loading-utils.cjs.map +1 -1
  106. package/dist/postgrest-table/loading-utils.js +1 -5
  107. package/dist/postgrest-table/loading-utils.js.map +1 -1
  108. package/dist/postgrest-table/main.module.sass.cjs +14 -13
  109. package/dist/postgrest-table/main.module.sass.cjs.map +1 -1
  110. package/dist/postgrest-table/main.module.sass.js +14 -13
  111. package/dist/postgrest-table/main.module.sass.js.map +1 -1
  112. package/dist/provider.cjs +68 -11
  113. package/dist/provider.cjs.map +1 -1
  114. package/dist/provider.d.ts +25 -0
  115. package/dist/provider.js +68 -11
  116. package/dist/provider.js.map +1 -1
  117. package/dist/renderers/column-header-cell.cjs +95 -75
  118. package/dist/renderers/column-header-cell.cjs.map +1 -1
  119. package/dist/renderers/column-header-cell.d.ts +3 -18
  120. package/dist/renderers/column-header-cell.js +98 -78
  121. package/dist/renderers/column-header-cell.js.map +1 -1
  122. package/dist/renderers/index.d.ts +0 -1
  123. package/dist/types.cjs +2 -0
  124. package/dist/types.cjs.map +1 -1
  125. package/dist/types.d.ts +84 -1
  126. package/dist/types.js +2 -0
  127. package/dist/types.js.map +1 -1
  128. package/dist/utils/column-spec.cjs.map +1 -1
  129. package/dist/utils/column-spec.d.ts +101 -1
  130. package/dist/utils/column-spec.js.map +1 -1
  131. package/dist/utils/debug-overlay.cjs +24 -0
  132. package/dist/utils/debug-overlay.cjs.map +1 -0
  133. package/dist/utils/debug-overlay.d.ts +4 -0
  134. package/dist/utils/debug-overlay.js +24 -0
  135. package/dist/utils/debug-overlay.js.map +1 -0
  136. package/dist/utils/index.cjs.map +1 -1
  137. package/dist/utils/index.d.ts +2 -0
  138. package/dist/utils/index.js.map +1 -1
  139. package/dist/utils/key-handling.cjs +52 -6
  140. package/dist/utils/key-handling.cjs.map +1 -1
  141. package/dist/utils/key-handling.js +52 -6
  142. package/dist/utils/key-handling.js.map +1 -1
  143. package/dist/utils/validation.cjs +41 -0
  144. package/dist/utils/validation.cjs.map +1 -0
  145. package/dist/utils/validation.d.ts +26 -0
  146. package/dist/utils/validation.js +41 -0
  147. package/dist/utils/validation.js.map +1 -0
  148. package/dist/zustand-store.cjs +119 -61
  149. package/dist/zustand-store.cjs.map +1 -1
  150. package/dist/zustand-store.js +121 -63
  151. package/dist/zustand-store.js.map +1 -1
  152. package/package.json +6 -6
  153. package/src/actions/builtin.ts +62 -7
  154. package/src/actions/column-controls.ts +185 -0
  155. package/src/actions/column-filter.ts +104 -0
  156. package/src/actions/edit-actions.ts +67 -0
  157. package/src/actions/filters.ts +54 -28
  158. package/src/actions/index.ts +4 -0
  159. package/src/actions/selection.ts +59 -52
  160. package/src/actions/table-controls.ts +46 -0
  161. package/src/actions/toolbar.module.sass +22 -2
  162. package/src/actions/toolbar.ts +113 -16
  163. package/src/actions/types.ts +49 -4
  164. package/src/cell-renderer.ts +211 -16
  165. package/src/components/cell-detail.ts +30 -0
  166. package/src/components/editor-popup.ts +39 -25
  167. package/src/components/index.ts +2 -2
  168. package/src/components/text-areas.ts +80 -16
  169. package/src/components/view-info.ts +63 -4
  170. package/src/core.ts +321 -103
  171. package/src/filters/operators.ts +127 -0
  172. package/src/index.ts +2 -0
  173. package/src/main.module.sass +6 -0
  174. package/src/postgrest-table/data-loaders.ts +459 -209
  175. package/src/postgrest-table/index.ts +81 -254
  176. package/src/postgrest-table/main.module.sass +11 -0
  177. package/src/provider.ts +109 -12
  178. package/src/renderers/column-header-cell.ts +60 -272
  179. package/src/renderers/index.ts +0 -1
  180. package/src/types.ts +76 -2
  181. package/src/utils/column-spec.ts +112 -1
  182. package/src/utils/debug-overlay.ts +22 -0
  183. package/src/utils/index.ts +2 -0
  184. package/src/utils/key-handling.ts +70 -6
  185. package/src/utils/validation.ts +72 -0
  186. package/src/zustand-store.ts +167 -60
  187. package/dist/components/actions.cjs +0 -12
  188. package/dist/components/actions.cjs.map +0 -1
  189. package/dist/components/actions.d.ts +0 -2
  190. package/dist/components/actions.js +0 -12
  191. package/dist/components/actions.js.map +0 -1
  192. package/dist/components/actions.module.sass.cjs +0 -12
  193. package/dist/components/actions.module.sass.cjs.map +0 -1
  194. package/dist/components/actions.module.sass.js +0 -11
  195. package/dist/components/actions.module.sass.js.map +0 -1
  196. package/dist/postgrest-table/lazy-loader-table.cjs +0 -27
  197. package/dist/postgrest-table/lazy-loader-table.cjs.map +0 -1
  198. package/dist/postgrest-table/lazy-loader-table.d.ts +0 -3
  199. package/dist/postgrest-table/lazy-loader-table.js +0 -27
  200. package/dist/postgrest-table/lazy-loader-table.js.map +0 -1
  201. package/dist/renderers/column-header-cell-postgrest.cjs +0 -216
  202. package/dist/renderers/column-header-cell-postgrest.cjs.map +0 -1
  203. package/dist/renderers/column-header-cell-postgrest.d.ts +0 -13
  204. package/dist/renderers/column-header-cell-postgrest.js +0 -216
  205. package/dist/renderers/column-header-cell-postgrest.js.map +0 -1
  206. package/dist/renderers/column-header-cell-postgrest.module.sass.cjs +0 -23
  207. package/dist/renderers/column-header-cell-postgrest.module.sass.cjs.map +0 -1
  208. package/dist/renderers/column-header-cell-postgrest.module.sass.js +0 -22
  209. package/dist/renderers/column-header-cell-postgrest.module.sass.js.map +0 -1
  210. package/src/components/actions.ts +0 -9
  211. package/src/postgrest-table/lazy-loader-table.ts +0 -25
  212. 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 { useRef, useState } from "react";
4
+ import { useCallback, useRef } from "react";
5
5
  import { useSelector } from "../provider";
6
6
 
7
7
  export function EditorPopup(props) {
8
- const {
9
- children,
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
- const [isOpen, setIsOpen] = useState(autoFocus);
17
- const keyHandler = useSelector((state) => state.keyHandler);
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 inlineEditor = h([
22
- h("span.editor-value.bp6-table-cell", valueViewer),
23
- h("input.hidden-editor", {
24
- defaultValue: "",
25
- autoFocus: true,
26
- onKeyDown: keyHandler,
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
- if (isOpen) {
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
- interactionKind: "hover-target",
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
- onClick: () => setIsOpen(!isOpen),
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
- // If the editor is open, show the inline editor, otherwise show the value viewer
75
- isOpen ? valueViewer : (inlineEditor ?? valueViewer),
89
+ valueViewer,
76
90
  ),
77
91
  );
78
92
  }
@@ -1,5 +1,5 @@
1
1
  export * from "./editor-popup";
2
+ export * from "./cell-detail";
2
3
  export * from "./colors";
3
4
  export * from "./text-areas";
4
- export * from "./actions";
5
- export { InfoBar } from "./view-info.ts";
5
+ export { LoadProgressIndicator } from "./view-info.ts";
@@ -1,7 +1,7 @@
1
1
  import h from "./main.module.sass";
2
2
  import { Button } from "@blueprintjs/core";
3
- import { useEffect, useRef, useState } from "react";
4
- import { multiLineTextKeyHandler } from "../utils";
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
- // const [_value, setValue] = useState(value);
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
- // Get the current value
32
- const val = ref.current.value;
33
- // Move the cursor to the end of the text
34
- ref.current.setSelectionRange(val.length, val.length);
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: multiLineTextKeyHandler,
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 { ViewInfo, viewInfoAtom } from "../postgrest-table";
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 ViewInfoControl() {
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
- export function InfoBar() {
16
- return h("div.info-bar", [h(ViewInfoControl)]);
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
  }