@macrostrat/data-sheet 4.7.0 → 4.9.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 (125) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +60 -19
  3. package/dist/actions/context.cjs +10 -1
  4. package/dist/actions/context.cjs.map +1 -1
  5. package/dist/actions/context.js +10 -1
  6. package/dist/actions/context.js.map +1 -1
  7. package/dist/actions/types.d.ts +4 -0
  8. package/dist/components/data-editor.cjs +527 -0
  9. package/dist/components/data-editor.cjs.map +1 -0
  10. package/dist/components/data-editor.d.ts +142 -0
  11. package/dist/components/data-editor.js +524 -0
  12. package/dist/components/data-editor.js.map +1 -0
  13. package/dist/components/editor-actions.cjs +167 -0
  14. package/dist/components/editor-actions.cjs.map +1 -0
  15. package/dist/components/editor-actions.d.ts +37 -0
  16. package/dist/components/editor-actions.js +165 -0
  17. package/dist/components/editor-actions.js.map +1 -0
  18. package/dist/components/editor-popup.cjs +11 -1
  19. package/dist/components/editor-popup.cjs.map +1 -1
  20. package/dist/components/editor-popup.js +11 -1
  21. package/dist/components/editor-popup.js.map +1 -1
  22. package/dist/components/index.d.ts +3 -0
  23. package/dist/components/indicators/selection.cjs +10 -4
  24. package/dist/components/indicators/selection.cjs.map +1 -1
  25. package/dist/components/indicators/selection.js +10 -4
  26. package/dist/components/indicators/selection.js.map +1 -1
  27. package/dist/components/row-editor.cjs +351 -0
  28. package/dist/components/row-editor.cjs.map +1 -0
  29. package/dist/components/row-editor.d.ts +181 -0
  30. package/dist/components/row-editor.js +349 -0
  31. package/dist/components/row-editor.js.map +1 -0
  32. package/dist/components/row-editor.module.sass.cjs +51 -0
  33. package/dist/components/row-editor.module.sass.cjs.map +1 -0
  34. package/dist/components/row-editor.module.sass.js +49 -0
  35. package/dist/components/row-editor.module.sass.js.map +1 -0
  36. package/dist/components/toolbars/actions-toolbar.cjs +1 -1
  37. package/dist/components/toolbars/actions-toolbar.cjs.map +1 -1
  38. package/dist/components/toolbars/actions-toolbar.js +1 -1
  39. package/dist/components/toolbars/actions-toolbar.js.map +1 -1
  40. package/dist/data-panel.cjs +36 -0
  41. package/dist/data-panel.cjs.map +1 -1
  42. package/dist/data-panel.d.ts +3 -2
  43. package/dist/data-panel.js +37 -1
  44. package/dist/data-panel.js.map +1 -1
  45. package/dist/data-panel.module.sass.cjs +28 -26
  46. package/dist/data-panel.module.sass.cjs.map +1 -1
  47. package/dist/data-panel.module.sass.js +28 -26
  48. package/dist/data-panel.module.sass.js.map +1 -1
  49. package/dist/data-sheet.css +267 -56
  50. package/dist/data-sheet.d.ts +2 -1
  51. package/dist/data-view.d.ts +1 -0
  52. package/dist/index.cjs +28 -0
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.js +31 -3
  55. package/dist/index.js.map +1 -1
  56. package/dist/main.module.sass.cjs +14 -13
  57. package/dist/main.module.sass.cjs.map +1 -1
  58. package/dist/main.module.sass.js +14 -13
  59. package/dist/main.module.sass.js.map +1 -1
  60. package/dist/postgrest-table/data-loaders.cjs +8 -1
  61. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  62. package/dist/postgrest-table/data-loaders.js +9 -2
  63. package/dist/postgrest-table/data-loaders.js.map +1 -1
  64. package/dist/provider/column-spec.cjs +8 -1
  65. package/dist/provider/column-spec.cjs.map +1 -1
  66. package/dist/provider/column-spec.d.ts +105 -1
  67. package/dist/provider/column-spec.js +8 -1
  68. package/dist/provider/column-spec.js.map +1 -1
  69. package/dist/provider/core.cjs +32 -7
  70. package/dist/provider/core.cjs.map +1 -1
  71. package/dist/provider/core.d.ts +5 -1
  72. package/dist/provider/core.js +32 -7
  73. package/dist/provider/core.js.map +1 -1
  74. package/dist/provider/loader-state.cjs +11 -3
  75. package/dist/provider/loader-state.cjs.map +1 -1
  76. package/dist/provider/loader-state.d.ts +8 -1
  77. package/dist/provider/loader-state.js +12 -4
  78. package/dist/provider/loader-state.js.map +1 -1
  79. package/dist/provider/table-data.cjs +10 -1
  80. package/dist/provider/table-data.cjs.map +1 -1
  81. package/dist/provider/table-data.d.ts +10 -0
  82. package/dist/provider/table-data.js +11 -2
  83. package/dist/provider/table-data.js.map +1 -1
  84. package/dist/provider/types.cjs.map +1 -1
  85. package/dist/provider/types.d.ts +4 -1
  86. package/dist/provider/types.js.map +1 -1
  87. package/dist/provider/zustand-store.cjs +26 -13
  88. package/dist/provider/zustand-store.cjs.map +1 -1
  89. package/dist/provider/zustand-store.js +14 -1
  90. package/dist/provider/zustand-store.js.map +1 -1
  91. package/dist/renderers/cell-renderer.cjs +15 -4
  92. package/dist/renderers/cell-renderer.cjs.map +1 -1
  93. package/dist/renderers/cell-renderer.js +13 -4
  94. package/dist/renderers/cell-renderer.js.map +1 -1
  95. package/dist/renderers/column-header-cell.cjs +12 -1
  96. package/dist/renderers/column-header-cell.cjs.map +1 -1
  97. package/dist/renderers/column-header-cell.js +11 -1
  98. package/dist/renderers/column-header-cell.js.map +1 -1
  99. package/dist/types.cjs.map +1 -1
  100. package/dist/types.d.ts +30 -1
  101. package/dist/types.js.map +1 -1
  102. package/package.json +2 -2
  103. package/src/actions/context.ts +13 -2
  104. package/src/actions/types.ts +5 -0
  105. package/src/components/data-editor.ts +741 -0
  106. package/src/components/editor-actions.ts +228 -0
  107. package/src/components/editor-popup.ts +16 -3
  108. package/src/components/index.ts +3 -0
  109. package/src/components/indicators/selection.ts +12 -4
  110. package/src/components/row-editor.module.sass +161 -0
  111. package/src/components/row-editor.ts +620 -0
  112. package/src/components/toolbars/actions-toolbar.ts +3 -2
  113. package/src/data-panel.module.sass +25 -0
  114. package/src/data-panel.ts +50 -1
  115. package/src/main.module.sass +19 -0
  116. package/src/postgrest-table/data-loaders.ts +13 -0
  117. package/src/provider/column-spec.ts +94 -16
  118. package/src/provider/core.ts +41 -9
  119. package/src/provider/loader-state.ts +15 -2
  120. package/src/provider/table-data.ts +23 -1
  121. package/src/provider/types.ts +4 -1
  122. package/src/provider/zustand-store.ts +30 -1
  123. package/src/renderers/cell-renderer.ts +18 -3
  124. package/src/renderers/column-header-cell.ts +10 -0
  125. package/src/types.ts +31 -1
@@ -0,0 +1,49 @@
1
+ import h$1 from "@macrostrat/hyper";
2
+ const panel = "_panel_kma62_39";
3
+ const edited = "_edited_kma62_87";
4
+ const derived = "_derived_kma62_90";
5
+ const inline = "_inline_kma62_98";
6
+ const empty = "_empty_kma62_139";
7
+ const selected = "_selected_kma62_151";
8
+ const styles = {
9
+ "row-editor": "_row-editor_kma62_1",
10
+ "field-actions": "_field-actions_kma62_8",
11
+ "editor-action-form": "_editor-action-form_kma62_19",
12
+ "data-editor-footer": "_data-editor-footer_kma62_27",
13
+ "data-editor-footer-spacer": "_data-editor-footer-spacer_kma62_35",
14
+ panel,
15
+ "row-editor-body": "_row-editor-body_kma62_44",
16
+ "row-editor-title-bar": "_row-editor-title-bar_kma62_65",
17
+ "row-editor-fields": "_row-editor-fields_kma62_74",
18
+ "row-editor-field": "_row-editor-field_kma62_74",
19
+ edited,
20
+ "field-name": "_field-name_kma62_87",
21
+ derived,
22
+ "field-value": "_field-value_kma62_90",
23
+ "read-only": "_read-only_kma62_94",
24
+ inline,
25
+ "field-label": "_field-label_kma62_102",
26
+ "field-marker": "_field-marker_kma62_115",
27
+ "required-marker": "_required-marker_kma62_122",
28
+ "reset-field": "_reset-field_kma62_126",
29
+ empty,
30
+ "field-surface": "_field-surface_kma62_143",
31
+ "cell-detail": "_cell-detail_kma62_143",
32
+ "row-editor-non-ideal": "_row-editor-non-ideal_kma62_147",
33
+ selected,
34
+ "mixed-values": "_mixed-values_kma62_163",
35
+ "selection-summary": "_selection-summary_kma62_168",
36
+ "row-editor-field-target": "_row-editor-field-target_kma62_174"
37
+ };
38
+ let h = h$1.styled(styles);
39
+ Object.assign(h, styles);
40
+ export {
41
+ h as default,
42
+ derived,
43
+ edited,
44
+ empty,
45
+ inline,
46
+ panel,
47
+ selected
48
+ };
49
+ //# sourceMappingURL=row-editor.module.sass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row-editor.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -47,7 +47,7 @@ function ActionsToolbar({
47
47
  if (!toolbarIsShown && children == null) {
48
48
  return null;
49
49
  }
50
- const isGlobal = (a) => (a.targets.includes(table.RegionCardinality.FULL_TABLE) || a.targets.includes("none")) && a.requiresEditable;
50
+ const isGlobal = (a) => a.placement === "end" || (a.targets.includes(table.RegionCardinality.FULL_TABLE) || a.targets.includes("none")) && a.requiresEditable;
51
51
  const contextual = shownActions.filter((a) => !isGlobal(a));
52
52
  const globalActions = shownActions.filter(isGlobal);
53
53
  return actionsToolbar_module.default("div.actions-toolbar", { className }, [
@@ -1 +1 @@
1
- {"version":3,"file":"actions-toolbar.cjs","sources":["../../../src/components/toolbars/actions-toolbar.ts"],"sourcesContent":["import { Button, ButtonGroup, PopoverNext } from \"@blueprintjs/core\";\nimport { type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport h from \"./actions-toolbar.module.sass\";\nimport { ctx, selectionAtom, useSelector } from \"../../provider\";\nimport {\n getApplicableActions,\n getSelectionCardinality,\n mergeColumnActions,\n buildActionContext,\n TableActionContext,\n runActionWrapper,\n type TableAction,\n} from \"../../actions\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport { useToaster } from \"../../notifications.ts\";\nimport type { ColumnSpec } from \"../../provider\";\nimport { SelectionIndicator } from \"../index.ts\";\n\n/** Toolbar that renders the actions/controls applicable to the current\n * selection cardinality (modal by selection) and edit mode. Actions with a\n * `render` show their live control; others show a button (with an optional\n * `detailsForm` popover). Column-specific actions from `ColumnSpec.actions`\n * are merged when their columns are selected. A capsule on the left shows the\n * current selection polarity. */\nexport function ActionsToolbar<T>({\n actions: _actions,\n children,\n className,\n compact = false,\n}: {\n actions: TableAction<T>[];\n tableName?: string;\n children: ReactNode;\n className?: string;\n compact: boolean;\n}) {\n const selection = ctx.useValue(selectionAtom);\n const editable = useSelector((state) => state.editable);\n const columnSpec = useSelector((state) => state.columnSpec);\n\n const actionIDs = new Set(_actions.map((a) => a.id));\n const actions = useMemo(() => _actions, [actionIDs]);\n\n const cardinality = useMemo(\n () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,\n [selection],\n );\n\n // Merge global actions with column-specific actions from the selection\n const allActions = useMemo(\n () => mergeColumnActions(actions, columnSpec, selection),\n [actions, columnSpec, selection],\n );\n\n const applicableActions = useMemo(\n () => getApplicableActions(allActions, cardinality, editable),\n [allActions, cardinality, editable],\n );\n\n const store = ctx.useStore();\n // Context for `render`-style controls (they subscribe to the store\n // themselves; this resolves the selected column/rows).\n const actionContext = useMemo(() => {\n return buildActionContext(store.get, store.set);\n }, [allActions]);\n\n // The toolbar is for actions that AREN'T keyboard-accessible: any action\n // with a `hotkey` (copy/cut/paste, etc.) is reachable from the keyboard and\n // is omitted here (it still works via its shortcut). Then refine by selection\n // shape beyond cardinality (e.g. single column only).\n const shownActions = applicableActions.filter(\n (action: TableAction<T, any>) =>\n action.hotkey == null &&\n (action.appliesTo?.(actionContext as any) ?? true),\n );\n\n const toolbarIsShown = useMemo(\n () => hasAnyDisplayableActions(actions, columnSpec),\n [actions, columnSpec],\n );\n\n // Render whenever there are displayable actions OR the consumer supplied\n // custom toolbar chrome (`children`) — a facet-less panel (e.g. a card list\n // with only a search box) still needs its toolbar slot to appear.\n if (!toolbarIsShown && children == null) {\n return null;\n }\n\n // Order left→right by generality: actions that require editing\n // are \"global\" and sit after a spacer on the right (Save /\n // Reset); everything else is contextual and stays on the left. So the left\n // edge tracks the selection and the right edge is constant.\n const isGlobal = (a: TableAction<T>) =>\n (a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any)) &&\n a.requiresEditable;\n const contextual = shownActions.filter((a) => !isGlobal(a));\n // Order the built-in global actions least→most impactful, left→right: reset\n // changes, then save. Any other global actions keep their natural order to\n // the left of these (stable sort, rank 0).\n\n const globalActions = shownActions.filter(isGlobal);\n\n return h(\"div.actions-toolbar\", { className }, [\n h(SelectionIndicator, { minimal: compact }),\n h(\n \"div.toolbar-group.contextual\",\n contextual.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n children,\n h(\"div.toolbar-spacer\", { style: { flex: 1 } }),\n h(\n ButtonGroup,\n { minimal: true },\n globalActions.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n ]);\n}\n\nfunction isActionDisabled(action: TableAction, state: any): boolean {\n if (typeof action.disabled === \"boolean\") return action.disabled;\n if (typeof action.disabled === \"function\") {\n return action.disabled(state);\n }\n return false;\n}\n\n/** Dispatcher: a live control (`action.render`) or a run/detailsForm button.\n * Kept hook-free so the two paths don't share a hook order. */\nfunction ActionButton<T>({\n action,\n ctx,\n}: {\n action: TableAction<T>;\n ctx: TableActionContext<T>;\n}) {\n if (action.render != null) {\n return action.render(ctx) as any;\n }\n return h(RunActionButton, { action });\n}\n\n/** A run/detailsForm action rendered as a button. */\nfunction RunActionButton<T>({ action }: { action: TableAction<T> }) {\n const store = ctx.useStore();\n const toaster = useToaster();\n\n // Reactive disabled check — re-renders when relevant state changes\n const isDisabled = useSelector((state) => {\n return isActionDisabled(action, state);\n });\n\n const runAction = useCallback(\n (configState?: any) => {\n runActionWrapper(action, store.get, store.set, toaster, configState);\n },\n [action, toaster],\n );\n\n if (action.detailsForm != null) {\n return h(ActionButtonWithForm, { action, runAction, isDisabled });\n }\n\n return h(\n Button,\n {\n // Minimal + small to match the toolbar's other controls (scroll-to-row,\n // sort/filter tags) — the compact, minimal house style.\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick() {\n runAction();\n },\n },\n action.name,\n );\n}\n\n/** Action button that opens a popover for pre-run configuration. */\nfunction ActionButtonWithForm<T, S>({\n action,\n runAction,\n isDisabled,\n}: {\n action: TableAction<T, S>;\n runAction: (configState?: S) => void;\n isDisabled: boolean;\n}) {\n const [configState, setConfigState] = useState<S>(\n action.defaultState ?? (null as S),\n );\n const [isOpen, setIsOpen] = useState(false);\n\n let ready = true;\n if (action.isReady != null) {\n ready = action.isReady(configState);\n }\n\n return h(\n PopoverNext,\n {\n isOpen,\n onClose: () => setIsOpen(false),\n content: h(\"div.action-popover-content\", [\n h.if(action.description != null)(\"p.description\", action.description),\n h(action.detailsForm as any, {\n state: configState,\n setState: setConfigState,\n }),\n h(\n Button,\n {\n className: \"run-button\",\n intent: action.intent ?? \"primary\",\n icon: \"play\",\n disabled: !ready,\n fill: true,\n onClick() {\n runAction(configState);\n setIsOpen(false);\n },\n },\n \"Run\",\n ),\n ]),\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n },\n h(\n Button,\n {\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick: () => setIsOpen(!isOpen),\n },\n action.name,\n ),\n );\n}\n\nfunction hasAnyDisplayableActions(\n actions: TableAction[],\n columnSpec: ColumnSpec[],\n) {\n /** Check whether there are any actions that can be displayed in the toolbar.\n * for the entire table. This is used to determine whether the toolbar should\n * be rendered. If any actions are available, the toolbar is rendered in ALL\n * selection modes to avoid flickering\n */\n const allActions = [\n ...actions,\n ...columnSpec.flatMap((c) => c.actions ?? []),\n ];\n\n if (allActions.length === 0) {\n return false;\n }\n // Check whether any action doesn't have hotkey and is not disabled\n return allActions.some(\n (action) => action.hotkey == null && !isActionDisabled(action, {}),\n );\n}\n"],"names":["selection","ctx","selectionAtom","useSelector","useMemo","getSelectionCardinality","RegionCardinality","mergeColumnActions","getApplicableActions","buildActionContext","h","SelectionIndicator","ButtonGroup","useToaster","useCallback","runActionWrapper","Button","useState","PopoverNext"],"mappings":";;;;;;;;;;;;AAwBO,SAAS,eAAkB;AAAA,EAChC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAMG;AACD,QAAMA,cAAYC,KAAAA,IAAI,SAASC,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AAA,YACN,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,UAAU;AACR,wBAAU,WAAW;AACrB,wBAAU,KAAK;AAAA,YACjB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA;AAAA,MACF,CACD;AAAA,MACD,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAW;AAAA,IAAA;AAAA,IAEbN,sBAAAA;AAAAA,MACEM,OAAAA;AAAAA,MACA;AAAA,QACE,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf,UAAU;AAAA,QACV,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,MAAA;AAAA,MAElC,OAAO;AAAA,IAAA;AAAA,EACT;AAEJ;AAEA,SAAS,yBACP,SACA,YACA;AAMA,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,GAAG,WAAW,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA,CAAE;AAAA,EAAA;AAG9C,MAAI,WAAW,WAAW,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,SAAO,WAAW;AAAA,IAChB,CAAC,WAAW,OAAO,UAAU,QAAQ,CAAC,iBAAiB,QAAQ,CAAA,CAAE;AAAA,EAAA;AAErE;;"}
1
+ {"version":3,"file":"actions-toolbar.cjs","sources":["../../../src/components/toolbars/actions-toolbar.ts"],"sourcesContent":["import { Button, ButtonGroup, PopoverNext } from \"@blueprintjs/core\";\nimport { type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport h from \"./actions-toolbar.module.sass\";\nimport { ctx, selectionAtom, useSelector } from \"../../provider\";\nimport {\n getApplicableActions,\n getSelectionCardinality,\n mergeColumnActions,\n buildActionContext,\n TableActionContext,\n runActionWrapper,\n type TableAction,\n} from \"../../actions\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport { useToaster } from \"../../notifications.ts\";\nimport type { ColumnSpec } from \"../../provider\";\nimport { SelectionIndicator } from \"../index.ts\";\n\n/** Toolbar that renders the actions/controls applicable to the current\n * selection cardinality (modal by selection) and edit mode. Actions with a\n * `render` show their live control; others show a button (with an optional\n * `detailsForm` popover). Column-specific actions from `ColumnSpec.actions`\n * are merged when their columns are selected. A capsule on the left shows the\n * current selection polarity. */\nexport function ActionsToolbar<T>({\n actions: _actions,\n children,\n className,\n compact = false,\n}: {\n actions: TableAction<T>[];\n tableName?: string;\n children: ReactNode;\n className?: string;\n compact: boolean;\n}) {\n const selection = ctx.useValue(selectionAtom);\n const editable = useSelector((state) => state.editable);\n const columnSpec = useSelector((state) => state.columnSpec);\n\n const actionIDs = new Set(_actions.map((a) => a.id));\n const actions = useMemo(() => _actions, [actionIDs]);\n\n const cardinality = useMemo(\n () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,\n [selection],\n );\n\n // Merge global actions with column-specific actions from the selection\n const allActions = useMemo(\n () => mergeColumnActions(actions, columnSpec, selection),\n [actions, columnSpec, selection],\n );\n\n const applicableActions = useMemo(\n () => getApplicableActions(allActions, cardinality, editable),\n [allActions, cardinality, editable],\n );\n\n const store = ctx.useStore();\n // Context for `render`-style controls (they subscribe to the store\n // themselves; this resolves the selected column/rows).\n const actionContext = useMemo(() => {\n return buildActionContext(store.get, store.set);\n }, [allActions]);\n\n // The toolbar is for actions that AREN'T keyboard-accessible: any action\n // with a `hotkey` (copy/cut/paste, etc.) is reachable from the keyboard and\n // is omitted here (it still works via its shortcut). Then refine by selection\n // shape beyond cardinality (e.g. single column only).\n const shownActions = applicableActions.filter(\n (action: TableAction<T, any>) =>\n action.hotkey == null &&\n (action.appliesTo?.(actionContext as any) ?? true),\n );\n\n const toolbarIsShown = useMemo(\n () => hasAnyDisplayableActions(actions, columnSpec),\n [actions, columnSpec],\n );\n\n // Render whenever there are displayable actions OR the consumer supplied\n // custom toolbar chrome (`children`) — a facet-less panel (e.g. a card list\n // with only a search box) still needs its toolbar slot to appear.\n if (!toolbarIsShown && children == null) {\n return null;\n }\n\n // Order left→right by generality: actions that require editing\n // are \"global\" and sit after a spacer on the right (Save /\n // Reset); everything else is contextual and stays on the left. So the left\n // edge tracks the selection and the right edge is constant.\n const isGlobal = (a: TableAction<T>) =>\n a.placement === \"end\" ||\n ((a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any)) &&\n a.requiresEditable);\n const contextual = shownActions.filter((a) => !isGlobal(a));\n // Order the built-in global actions least→most impactful, left→right: reset\n // changes, then save. Any other global actions keep their natural order to\n // the left of these (stable sort, rank 0).\n\n const globalActions = shownActions.filter(isGlobal);\n\n return h(\"div.actions-toolbar\", { className }, [\n h(SelectionIndicator, { minimal: compact }),\n h(\n \"div.toolbar-group.contextual\",\n contextual.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n children,\n h(\"div.toolbar-spacer\", { style: { flex: 1 } }),\n h(\n ButtonGroup,\n { minimal: true },\n globalActions.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n ]);\n}\n\nfunction isActionDisabled(action: TableAction, state: any): boolean {\n if (typeof action.disabled === \"boolean\") return action.disabled;\n if (typeof action.disabled === \"function\") {\n return action.disabled(state);\n }\n return false;\n}\n\n/** Dispatcher: a live control (`action.render`) or a run/detailsForm button.\n * Kept hook-free so the two paths don't share a hook order. */\nfunction ActionButton<T>({\n action,\n ctx,\n}: {\n action: TableAction<T>;\n ctx: TableActionContext<T>;\n}) {\n if (action.render != null) {\n return action.render(ctx) as any;\n }\n return h(RunActionButton, { action });\n}\n\n/** A run/detailsForm action rendered as a button. */\nfunction RunActionButton<T>({ action }: { action: TableAction<T> }) {\n const store = ctx.useStore();\n const toaster = useToaster();\n\n // Reactive disabled check — re-renders when relevant state changes\n const isDisabled = useSelector((state) => {\n return isActionDisabled(action, state);\n });\n\n const runAction = useCallback(\n (configState?: any) => {\n runActionWrapper(action, store.get, store.set, toaster, configState);\n },\n [action, toaster],\n );\n\n if (action.detailsForm != null) {\n return h(ActionButtonWithForm, { action, runAction, isDisabled });\n }\n\n return h(\n Button,\n {\n // Minimal + small to match the toolbar's other controls (scroll-to-row,\n // sort/filter tags) — the compact, minimal house style.\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick() {\n runAction();\n },\n },\n action.name,\n );\n}\n\n/** Action button that opens a popover for pre-run configuration. */\nfunction ActionButtonWithForm<T, S>({\n action,\n runAction,\n isDisabled,\n}: {\n action: TableAction<T, S>;\n runAction: (configState?: S) => void;\n isDisabled: boolean;\n}) {\n const [configState, setConfigState] = useState<S>(\n action.defaultState ?? (null as S),\n );\n const [isOpen, setIsOpen] = useState(false);\n\n let ready = true;\n if (action.isReady != null) {\n ready = action.isReady(configState);\n }\n\n return h(\n PopoverNext,\n {\n isOpen,\n onClose: () => setIsOpen(false),\n content: h(\"div.action-popover-content\", [\n h.if(action.description != null)(\"p.description\", action.description),\n h(action.detailsForm as any, {\n state: configState,\n setState: setConfigState,\n }),\n h(\n Button,\n {\n className: \"run-button\",\n intent: action.intent ?? \"primary\",\n icon: \"play\",\n disabled: !ready,\n fill: true,\n onClick() {\n runAction(configState);\n setIsOpen(false);\n },\n },\n \"Run\",\n ),\n ]),\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n },\n h(\n Button,\n {\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick: () => setIsOpen(!isOpen),\n },\n action.name,\n ),\n );\n}\n\nfunction hasAnyDisplayableActions(\n actions: TableAction[],\n columnSpec: ColumnSpec[],\n) {\n /** Check whether there are any actions that can be displayed in the toolbar.\n * for the entire table. This is used to determine whether the toolbar should\n * be rendered. If any actions are available, the toolbar is rendered in ALL\n * selection modes to avoid flickering\n */\n const allActions = [\n ...actions,\n ...columnSpec.flatMap((c) => c.actions ?? []),\n ];\n\n if (allActions.length === 0) {\n return false;\n }\n // Check whether any action doesn't have hotkey and is not disabled\n return allActions.some(\n (action) => action.hotkey == null && !isActionDisabled(action, {}),\n );\n}\n"],"names":["selection","ctx","selectionAtom","useSelector","useMemo","getSelectionCardinality","RegionCardinality","mergeColumnActions","getApplicableActions","buildActionContext","h","SelectionIndicator","ButtonGroup","useToaster","useCallback","runActionWrapper","Button","useState","PopoverNext"],"mappings":";;;;;;;;;;;;AAwBO,SAAS,eAAkB;AAAA,EAChC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAMG;AACD,QAAMA,cAAYC,KAAAA,IAAI,SAASC,uBAAa;AAC5C,QAAM,WAAWC,KAAAA,YAAY,CAAC,UAAU,MAAM,QAAQ;AACtD,QAAM,aAAaA,KAAAA,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,YAAY,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AACnD,QAAM,UAAUC,MAAAA,QAAQ,MAAM,UAAU,CAAC,SAAS,CAAC;AAEnD,QAAM,cAAcA,MAAAA;AAAAA,IAClB,MAAMC,oCAAwBL,WAAS,KAAKM,MAAAA,kBAAkB;AAAA,IAC9D,CAACN,WAAS;AAAA,EAAA;AAIZ,QAAM,aAAaI,MAAAA;AAAAA,IACjB,MAAMG,+BAAmB,SAAS,YAAYP,WAAS;AAAA,IACvD,CAAC,SAAS,YAAYA,WAAS;AAAA,EAAA;AAGjC,QAAM,oBAAoBI,MAAAA;AAAAA,IACxB,MAAMI,iCAAqB,YAAY,aAAa,QAAQ;AAAA,IAC5D,CAAC,YAAY,aAAa,QAAQ;AAAA,EAAA;AAGpC,QAAM,QAAQP,KAAAA,IAAI,SAAA;AAGlB,QAAM,gBAAgBG,MAAAA,QAAQ,MAAM;AAClC,WAAOK,QAAAA,mBAAmB,MAAM,KAAK,MAAM,GAAG;AAAA,EAChD,GAAG,CAAC,UAAU,CAAC;AAMf,QAAM,eAAe,kBAAkB;AAAA,IACrC,CAAC,WACC,OAAO,UAAU,SAChB,OAAO,YAAY,aAAoB,KAAK;AAAA,EAAA;AAG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AA,MAC9B,SAASR,sBAAAA,QAAE,8BAA8B;AAAA,QACvCA,8BAAE,GAAG,OAAO,eAAe,IAAI,EAAE,iBAAiB,OAAO,WAAW;AAAA,QACpEA,sBAAAA,QAAE,OAAO,aAAoB;AAAA,UAC3B,OAAO;AAAA,UACP,UAAU;AAAA,QAAA,CACX;AAAA,QACDA,sBAAAA;AAAAA,UACEM,OAAAA;AAAAA,UACA;AAAA,YACE,WAAW;AAAA,YACX,QAAQ,OAAO,UAAU;AAAA,YACzB,MAAM;AAAA,YACN,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,UAAU;AACR,wBAAU,WAAW;AACrB,wBAAU,KAAK;AAAA,YACjB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA;AAAA,MACF,CACD;AAAA,MACD,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAW;AAAA,IAAA;AAAA,IAEbN,sBAAAA;AAAAA,MACEM,OAAAA;AAAAA,MACA;AAAA,QACE,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf,UAAU;AAAA,QACV,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,MAAA;AAAA,MAElC,OAAO;AAAA,IAAA;AAAA,EACT;AAEJ;AAEA,SAAS,yBACP,SACA,YACA;AAMA,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,GAAG,WAAW,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA,CAAE;AAAA,EAAA;AAG9C,MAAI,WAAW,WAAW,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,SAAO,WAAW;AAAA,IAChB,CAAC,WAAW,OAAO,UAAU,QAAQ,CAAC,iBAAiB,QAAQ,CAAA,CAAE;AAAA,EAAA;AAErE;;"}
@@ -45,7 +45,7 @@ function ActionsToolbar({
45
45
  if (!toolbarIsShown && children == null) {
46
46
  return null;
47
47
  }
48
- const isGlobal = (a) => (a.targets.includes(RegionCardinality.FULL_TABLE) || a.targets.includes("none")) && a.requiresEditable;
48
+ const isGlobal = (a) => a.placement === "end" || (a.targets.includes(RegionCardinality.FULL_TABLE) || a.targets.includes("none")) && a.requiresEditable;
49
49
  const contextual = shownActions.filter((a) => !isGlobal(a));
50
50
  const globalActions = shownActions.filter(isGlobal);
51
51
  return h("div.actions-toolbar", { className }, [
@@ -1 +1 @@
1
- {"version":3,"file":"actions-toolbar.js","sources":["../../../src/components/toolbars/actions-toolbar.ts"],"sourcesContent":["import { Button, ButtonGroup, PopoverNext } from \"@blueprintjs/core\";\nimport { type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport h from \"./actions-toolbar.module.sass\";\nimport { ctx, selectionAtom, useSelector } from \"../../provider\";\nimport {\n getApplicableActions,\n getSelectionCardinality,\n mergeColumnActions,\n buildActionContext,\n TableActionContext,\n runActionWrapper,\n type TableAction,\n} from \"../../actions\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport { useToaster } from \"../../notifications.ts\";\nimport type { ColumnSpec } from \"../../provider\";\nimport { SelectionIndicator } from \"../index.ts\";\n\n/** Toolbar that renders the actions/controls applicable to the current\n * selection cardinality (modal by selection) and edit mode. Actions with a\n * `render` show their live control; others show a button (with an optional\n * `detailsForm` popover). Column-specific actions from `ColumnSpec.actions`\n * are merged when their columns are selected. A capsule on the left shows the\n * current selection polarity. */\nexport function ActionsToolbar<T>({\n actions: _actions,\n children,\n className,\n compact = false,\n}: {\n actions: TableAction<T>[];\n tableName?: string;\n children: ReactNode;\n className?: string;\n compact: boolean;\n}) {\n const selection = ctx.useValue(selectionAtom);\n const editable = useSelector((state) => state.editable);\n const columnSpec = useSelector((state) => state.columnSpec);\n\n const actionIDs = new Set(_actions.map((a) => a.id));\n const actions = useMemo(() => _actions, [actionIDs]);\n\n const cardinality = useMemo(\n () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,\n [selection],\n );\n\n // Merge global actions with column-specific actions from the selection\n const allActions = useMemo(\n () => mergeColumnActions(actions, columnSpec, selection),\n [actions, columnSpec, selection],\n );\n\n const applicableActions = useMemo(\n () => getApplicableActions(allActions, cardinality, editable),\n [allActions, cardinality, editable],\n );\n\n const store = ctx.useStore();\n // Context for `render`-style controls (they subscribe to the store\n // themselves; this resolves the selected column/rows).\n const actionContext = useMemo(() => {\n return buildActionContext(store.get, store.set);\n }, [allActions]);\n\n // The toolbar is for actions that AREN'T keyboard-accessible: any action\n // with a `hotkey` (copy/cut/paste, etc.) is reachable from the keyboard and\n // is omitted here (it still works via its shortcut). Then refine by selection\n // shape beyond cardinality (e.g. single column only).\n const shownActions = applicableActions.filter(\n (action: TableAction<T, any>) =>\n action.hotkey == null &&\n (action.appliesTo?.(actionContext as any) ?? true),\n );\n\n const toolbarIsShown = useMemo(\n () => hasAnyDisplayableActions(actions, columnSpec),\n [actions, columnSpec],\n );\n\n // Render whenever there are displayable actions OR the consumer supplied\n // custom toolbar chrome (`children`) — a facet-less panel (e.g. a card list\n // with only a search box) still needs its toolbar slot to appear.\n if (!toolbarIsShown && children == null) {\n return null;\n }\n\n // Order left→right by generality: actions that require editing\n // are \"global\" and sit after a spacer on the right (Save /\n // Reset); everything else is contextual and stays on the left. So the left\n // edge tracks the selection and the right edge is constant.\n const isGlobal = (a: TableAction<T>) =>\n (a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any)) &&\n a.requiresEditable;\n const contextual = shownActions.filter((a) => !isGlobal(a));\n // Order the built-in global actions least→most impactful, left→right: reset\n // changes, then save. Any other global actions keep their natural order to\n // the left of these (stable sort, rank 0).\n\n const globalActions = shownActions.filter(isGlobal);\n\n return h(\"div.actions-toolbar\", { className }, [\n h(SelectionIndicator, { minimal: compact }),\n h(\n \"div.toolbar-group.contextual\",\n contextual.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n children,\n h(\"div.toolbar-spacer\", { style: { flex: 1 } }),\n h(\n ButtonGroup,\n { minimal: true },\n globalActions.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n ]);\n}\n\nfunction isActionDisabled(action: TableAction, state: any): boolean {\n if (typeof action.disabled === \"boolean\") return action.disabled;\n if (typeof action.disabled === \"function\") {\n return action.disabled(state);\n }\n return false;\n}\n\n/** Dispatcher: a live control (`action.render`) or a run/detailsForm button.\n * Kept hook-free so the two paths don't share a hook order. */\nfunction ActionButton<T>({\n action,\n ctx,\n}: {\n action: TableAction<T>;\n ctx: TableActionContext<T>;\n}) {\n if (action.render != null) {\n return action.render(ctx) as any;\n }\n return h(RunActionButton, { action });\n}\n\n/** A run/detailsForm action rendered as a button. */\nfunction RunActionButton<T>({ action }: { action: TableAction<T> }) {\n const store = ctx.useStore();\n const toaster = useToaster();\n\n // Reactive disabled check — re-renders when relevant state changes\n const isDisabled = useSelector((state) => {\n return isActionDisabled(action, state);\n });\n\n const runAction = useCallback(\n (configState?: any) => {\n runActionWrapper(action, store.get, store.set, toaster, configState);\n },\n [action, toaster],\n );\n\n if (action.detailsForm != null) {\n return h(ActionButtonWithForm, { action, runAction, isDisabled });\n }\n\n return h(\n Button,\n {\n // Minimal + small to match the toolbar's other controls (scroll-to-row,\n // sort/filter tags) — the compact, minimal house style.\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick() {\n runAction();\n },\n },\n action.name,\n );\n}\n\n/** Action button that opens a popover for pre-run configuration. */\nfunction ActionButtonWithForm<T, S>({\n action,\n runAction,\n isDisabled,\n}: {\n action: TableAction<T, S>;\n runAction: (configState?: S) => void;\n isDisabled: boolean;\n}) {\n const [configState, setConfigState] = useState<S>(\n action.defaultState ?? (null as S),\n );\n const [isOpen, setIsOpen] = useState(false);\n\n let ready = true;\n if (action.isReady != null) {\n ready = action.isReady(configState);\n }\n\n return h(\n PopoverNext,\n {\n isOpen,\n onClose: () => setIsOpen(false),\n content: h(\"div.action-popover-content\", [\n h.if(action.description != null)(\"p.description\", action.description),\n h(action.detailsForm as any, {\n state: configState,\n setState: setConfigState,\n }),\n h(\n Button,\n {\n className: \"run-button\",\n intent: action.intent ?? \"primary\",\n icon: \"play\",\n disabled: !ready,\n fill: true,\n onClick() {\n runAction(configState);\n setIsOpen(false);\n },\n },\n \"Run\",\n ),\n ]),\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n },\n h(\n Button,\n {\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick: () => setIsOpen(!isOpen),\n },\n action.name,\n ),\n );\n}\n\nfunction hasAnyDisplayableActions(\n actions: TableAction[],\n columnSpec: ColumnSpec[],\n) {\n /** Check whether there are any actions that can be displayed in the toolbar.\n * for the entire table. This is used to determine whether the toolbar should\n * be rendered. If any actions are available, the toolbar is rendered in ALL\n * selection modes to avoid flickering\n */\n const allActions = [\n ...actions,\n ...columnSpec.flatMap((c) => c.actions ?? []),\n ];\n\n if (allActions.length === 0) {\n return false;\n }\n // Check whether any action doesn't have hotkey and is not disabled\n return allActions.some(\n (action) => action.hotkey == null && !isActionDisabled(action, {}),\n );\n}\n"],"names":["ctx"],"mappings":";;;;;;;;;;AAwBO,SAAS,eAAkB;AAAA,EAChC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAMG;AACD,QAAM,YAAY,IAAI,SAAS,aAAa;AAC5C,QAAM,WAAW,YAAY,CAAC,UAAU,MAAM,QAAQ;AACtD,QAAM,aAAa,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,YAAY,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AACnD,QAAM,UAAU,QAAQ,MAAM,UAAU,CAAC,SAAS,CAAC;AAEnD,QAAM,cAAc;AAAA,IAClB,MAAM,wBAAwB,SAAS,KAAK,kBAAkB;AAAA,IAC9D,CAAC,SAAS;AAAA,EAAA;AAIZ,QAAM,aAAa;AAAA,IACjB,MAAM,mBAAmB,SAAS,YAAY,SAAS;AAAA,I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A,CAAE;AAAA,EAAA;AAErE;"}
1
+ {"version":3,"file":"actions-toolbar.js","sources":["../../../src/components/toolbars/actions-toolbar.ts"],"sourcesContent":["import { Button, ButtonGroup, PopoverNext } from \"@blueprintjs/core\";\nimport { type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport h from \"./actions-toolbar.module.sass\";\nimport { ctx, selectionAtom, useSelector } from \"../../provider\";\nimport {\n getApplicableActions,\n getSelectionCardinality,\n mergeColumnActions,\n buildActionContext,\n TableActionContext,\n runActionWrapper,\n type TableAction,\n} from \"../../actions\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport { useToaster } from \"../../notifications.ts\";\nimport type { ColumnSpec } from \"../../provider\";\nimport { SelectionIndicator } from \"../index.ts\";\n\n/** Toolbar that renders the actions/controls applicable to the current\n * selection cardinality (modal by selection) and edit mode. Actions with a\n * `render` show their live control; others show a button (with an optional\n * `detailsForm` popover). Column-specific actions from `ColumnSpec.actions`\n * are merged when their columns are selected. A capsule on the left shows the\n * current selection polarity. */\nexport function ActionsToolbar<T>({\n actions: _actions,\n children,\n className,\n compact = false,\n}: {\n actions: TableAction<T>[];\n tableName?: string;\n children: ReactNode;\n className?: string;\n compact: boolean;\n}) {\n const selection = ctx.useValue(selectionAtom);\n const editable = useSelector((state) => state.editable);\n const columnSpec = useSelector((state) => state.columnSpec);\n\n const actionIDs = new Set(_actions.map((a) => a.id));\n const actions = useMemo(() => _actions, [actionIDs]);\n\n const cardinality = useMemo(\n () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,\n [selection],\n );\n\n // Merge global actions with column-specific actions from the selection\n const allActions = useMemo(\n () => mergeColumnActions(actions, columnSpec, selection),\n [actions, columnSpec, selection],\n );\n\n const applicableActions = useMemo(\n () => getApplicableActions(allActions, cardinality, editable),\n [allActions, cardinality, editable],\n );\n\n const store = ctx.useStore();\n // Context for `render`-style controls (they subscribe to the store\n // themselves; this resolves the selected column/rows).\n const actionContext = useMemo(() => {\n return buildActionContext(store.get, store.set);\n }, [allActions]);\n\n // The toolbar is for actions that AREN'T keyboard-accessible: any action\n // with a `hotkey` (copy/cut/paste, etc.) is reachable from the keyboard and\n // is omitted here (it still works via its shortcut). Then refine by selection\n // shape beyond cardinality (e.g. single column only).\n const shownActions = applicableActions.filter(\n (action: TableAction<T, any>) =>\n action.hotkey == null &&\n (action.appliesTo?.(actionContext as any) ?? true),\n );\n\n const toolbarIsShown = useMemo(\n () => hasAnyDisplayableActions(actions, columnSpec),\n [actions, columnSpec],\n );\n\n // Render whenever there are displayable actions OR the consumer supplied\n // custom toolbar chrome (`children`) — a facet-less panel (e.g. a card list\n // with only a search box) still needs its toolbar slot to appear.\n if (!toolbarIsShown && children == null) {\n return null;\n }\n\n // Order left→right by generality: actions that require editing\n // are \"global\" and sit after a spacer on the right (Save /\n // Reset); everything else is contextual and stays on the left. So the left\n // edge tracks the selection and the right edge is constant.\n const isGlobal = (a: TableAction<T>) =>\n a.placement === \"end\" ||\n ((a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any)) &&\n a.requiresEditable);\n const contextual = shownActions.filter((a) => !isGlobal(a));\n // Order the built-in global actions least→most impactful, left→right: reset\n // changes, then save. Any other global actions keep their natural order to\n // the left of these (stable sort, rank 0).\n\n const globalActions = shownActions.filter(isGlobal);\n\n return h(\"div.actions-toolbar\", { className }, [\n h(SelectionIndicator, { minimal: compact }),\n h(\n \"div.toolbar-group.contextual\",\n contextual.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n children,\n h(\"div.toolbar-spacer\", { style: { flex: 1 } }),\n h(\n ButtonGroup,\n { minimal: true },\n globalActions.map((action) =>\n h(ActionButton, { key: action.id, action, ctx: actionContext }),\n ),\n ),\n ]);\n}\n\nfunction isActionDisabled(action: TableAction, state: any): boolean {\n if (typeof action.disabled === \"boolean\") return action.disabled;\n if (typeof action.disabled === \"function\") {\n return action.disabled(state);\n }\n return false;\n}\n\n/** Dispatcher: a live control (`action.render`) or a run/detailsForm button.\n * Kept hook-free so the two paths don't share a hook order. */\nfunction ActionButton<T>({\n action,\n ctx,\n}: {\n action: TableAction<T>;\n ctx: TableActionContext<T>;\n}) {\n if (action.render != null) {\n return action.render(ctx) as any;\n }\n return h(RunActionButton, { action });\n}\n\n/** A run/detailsForm action rendered as a button. */\nfunction RunActionButton<T>({ action }: { action: TableAction<T> }) {\n const store = ctx.useStore();\n const toaster = useToaster();\n\n // Reactive disabled check — re-renders when relevant state changes\n const isDisabled = useSelector((state) => {\n return isActionDisabled(action, state);\n });\n\n const runAction = useCallback(\n (configState?: any) => {\n runActionWrapper(action, store.get, store.set, toaster, configState);\n },\n [action, toaster],\n );\n\n if (action.detailsForm != null) {\n return h(ActionButtonWithForm, { action, runAction, isDisabled });\n }\n\n return h(\n Button,\n {\n // Minimal + small to match the toolbar's other controls (scroll-to-row,\n // sort/filter tags) — the compact, minimal house style.\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick() {\n runAction();\n },\n },\n action.name,\n );\n}\n\n/** Action button that opens a popover for pre-run configuration. */\nfunction ActionButtonWithForm<T, S>({\n action,\n runAction,\n isDisabled,\n}: {\n action: TableAction<T, S>;\n runAction: (configState?: S) => void;\n isDisabled: boolean;\n}) {\n const [configState, setConfigState] = useState<S>(\n action.defaultState ?? (null as S),\n );\n const [isOpen, setIsOpen] = useState(false);\n\n let ready = true;\n if (action.isReady != null) {\n ready = action.isReady(configState);\n }\n\n return h(\n PopoverNext,\n {\n isOpen,\n onClose: () => setIsOpen(false),\n content: h(\"div.action-popover-content\", [\n h.if(action.description != null)(\"p.description\", action.description),\n h(action.detailsForm as any, {\n state: configState,\n setState: setConfigState,\n }),\n h(\n Button,\n {\n className: \"run-button\",\n intent: action.intent ?? \"primary\",\n icon: \"play\",\n disabled: !ready,\n fill: true,\n onClick() {\n runAction(configState);\n setIsOpen(false);\n },\n },\n \"Run\",\n ),\n ]),\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n },\n h(\n Button,\n {\n minimal: true,\n small: true,\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick: () => setIsOpen(!isOpen),\n },\n action.name,\n ),\n );\n}\n\nfunction hasAnyDisplayableActions(\n actions: TableAction[],\n columnSpec: ColumnSpec[],\n) {\n /** Check whether there are any actions that can be displayed in the toolbar.\n * for the entire table. This is used to determine whether the toolbar should\n * be rendered. If any actions are available, the toolbar is rendered in ALL\n * selection modes to avoid flickering\n */\n const allActions = [\n ...actions,\n ...columnSpec.flatMap((c) => c.actions ?? []),\n ];\n\n if (allActions.length === 0) {\n return false;\n }\n // Check whether any action doesn't have hotkey and is not disabled\n return allActions.some(\n (action) => action.hotkey == null && !isActionDisabled(action, {}),\n );\n}\n"],"names":["ctx"],"mappings":";;;;;;;;;;AAwBO,SAAS,eAAkB;AAAA,EAChC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAMG;AACD,QAAM,YAAY,IAAI,SAAS,aAAa;AAC5C,QAAM,WAAW,YAAY,CAAC,UAAU,MAAM,QAAQ;AACtD,QAAM,aAAa,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,YAAY,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AACnD,QAAM,UAAU,QAAQ,MAAM,UAAU,CAAC,SAAS,CAAC;AAEnD,QAAM,cAAc;AAAA,IAClB,MAAM,wBAAwB,SAAS,KAAK,kBAAkB;AAAA,IAC9D,CAAC,SAAS;AAAA,EAAA;AAIZ,QAAM,aAAa;AAAA,IACjB,MAAM,mBAAmB,SAAS,YAAY,SAAS;AAAA,IACvD,CAAC,SAAS,YAAY,SAAS;AAAA,EAAA;AAGjC,QAAM,oBAAoB;AAAA,IACxB,MAAM,qBAAqB,YAAY,aAAa,QAAQ;AAAA,IAC5D,CAAC,YAAY,aAAa,QAAQ;AAAA,EAAA;AAGpC,QAAM,QAAQ,IAAI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AAA,MACE;AAAA,MACA,SAAS,MAAM,UAAU,KAAK;AAAA,MAC9B,SAAS,EAAE,8BAA8B;AAAA,QACvC,EAAE,GAAG,OAAO,eAAe,IAAI,EAAE,iBAAiB,OAAO,WAAW;AAAA,QACpE,EAAE,OAAO,aAAoB;AAAA,UAC3B,OAAO;AAAA,UACP,UAAU;AAAA,QAAA,CACX;AAAA,QACD;AAAA,UACE;AAAA,UACA;AAAA,YACE,WAAW;AAAA,YACX,QAAQ,OAAO,UAAU;AAAA,YACzB,MAAM;AAAA,YACN,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,UAAU;AACR,wBAAU,WAAW;AACrB,wBAAU,KAAK;AAAA,YACjB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA;AAAA,MACF,CACD;AAAA,MACD,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,MACE;AAAA,MACA;AAAA,QACE,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf,UAAU;AAAA,QACV,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,MAAA;AAAA,MAElC,OAAO;AAAA,IAAA;AAAA,EACT;AAEJ;AAEA,SAAS,yBACP,SACA,YACA;AAMA,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,GAAG,WAAW,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA,CAAE;AAAA,EAAA;AAG9C,MAAI,WAAW,WAAW,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,SAAO,WAAW;AAAA,IAChB,CAAC,WAAW,OAAO,UAAU,QAAQ,CAAC,iBAAiB,QAAQ,CAAA,CAAE;AAAA,EAAA;AAErE;"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const dataPanel_module = require("./data-panel.module.sass.cjs");
4
4
  const react = require("react");
5
5
  const core$1 = require("@blueprintjs/core");
6
+ const loaderState = require("./provider/loader-state.cjs");
6
7
  const classNames = require("classnames");
7
8
  const jotai = require("jotai");
8
9
  const dataLoaders = require("./postgrest-table/data-loaders.cjs");
@@ -50,6 +51,7 @@ function DataPanelRenderer({
50
51
  contentFooter,
51
52
  autoLoadPages,
52
53
  scrollBody,
54
+ pageLinks,
53
55
  className,
54
56
  toolbarStyle = "bordered",
55
57
  viewControls = "inline",
@@ -176,6 +178,38 @@ function DataPanelRenderer({
176
178
  { ref: sentinelRef },
177
179
  contentFooter ?? defaultFooter
178
180
  );
181
+ const startAfter = core.ctx.useValue(loaderState.startAfterAtom);
182
+ const lastLoadedRow = react.useMemo(() => {
183
+ for (let i = data.length - 1; i >= 0; i--) {
184
+ if (data[i] != null) return data[i];
185
+ }
186
+ return null;
187
+ }, [data]);
188
+ const moreToCome = total == null || loadedCount < total;
189
+ let nextPageLink = null;
190
+ if (pageLinks != null && lastLoadedRow != null && moreToCome) {
191
+ nextPageLink = dataPanel_module.default(
192
+ "a.crawl-next-link",
193
+ {
194
+ href: pageLinks.after(lastLoadedRow),
195
+ rel: "next",
196
+ tabIndex: -1,
197
+ "aria-hidden": true
198
+ },
199
+ "Next page"
200
+ );
201
+ }
202
+ let viewStartNotice = null;
203
+ if (startAfter != null && pageLinks?.top != null) {
204
+ viewStartNotice = dataPanel_module.default("div.view-start-notice", [
205
+ dataPanel_module.default("span.view-start-text", `Continued after #${startAfter}`),
206
+ dataPanel_module.default(
207
+ core$1.AnchorButton,
208
+ { href: pageLinks.top, minimal: true, small: true, icon: "arrow-up" },
209
+ pageLinks.topLabel ?? "Return to top"
210
+ )
211
+ ]);
212
+ }
179
213
  let footer = null;
180
214
  let _statusBarContent = statusBar ?? dataPanel_module.default(DataPanelStatusBar);
181
215
  if (showStatusBar) {
@@ -218,7 +252,9 @@ function DataPanelRenderer({
218
252
  },
219
253
  [
220
254
  dataPanel_module.default("div.data-panel-body-content", [
255
+ viewStartNotice,
221
256
  emptyState ?? dataPanel_module.default(ScrollBody, { placeholders }, cards),
257
+ nextPageLink,
222
258
  _contentFooter
223
259
  ])
224
260
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"data-panel.cjs","sources":["../src/data-panel.ts"],"sourcesContent":["/**\n * DataPanel — a card/list renderer over the same headless core as `DataSheet`.\n *\n * The two components differ in only two dimensions: the **view** (cards vs. the\n * Blueprint cell grid) and **edit granularity** (immediate per-item vs. a\n * batched pending-ops stack). Everything else — provider-driven windowed\n * loading, `{sorts, filters}` view state, the selection set, and set-based\n * actions — is the shared substrate, reused here unchanged:\n *\n * - `DataSheetProvider` supplies the jotai+zustand store.\n * - `useDataLoader(provider.fetchData)` drives windowed loading and threads the\n * active store sorts/filters through so a server provider applies them.\n * - `ActionsToolbar` + `FilterBar` render selection-aware actions and the\n * active sort/filter tags — they read the store, not the table.\n *\n * The only list-specific pieces are: rows rendered as cards via a consumer\n * `itemComponent`; selection expressed as `FULL_ROWS` regions (so the existing\n * row-targeted `TableAction`s apply); an infinite-scroll sentinel that advances\n * the loader's visible region; and `FacetControls`, which stands in for the\n * column-header dropdown the list doesn't have (a menu to add a column filter /\n * sort from the column-declared `filterable` / `sortable` capabilities).\n *\n * See [[Data list editors]] in the Macrostrat workbench for the design.\n */\nimport h from \"./data-panel.module.sass\";\nimport {\n ComponentType,\n CSSProperties,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n UIEvent as ReactUIEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Classes, Icon, NonIdealState, Spinner } from \"@blueprintjs/core\";\nimport {\n anchorRefAtom,\n ctx,\n dataProviderAtom,\n DataSheetProvider,\n DataViewRendererType,\n FetchData,\n enableSelectionAtom,\n interactionOptionsAtom,\n selectionAtom,\n splitDataProviderProps,\n useSelector,\n} from \"./provider\";\nimport {\n buildDataViewSelection,\n getSelectedRowIndices,\n rowIndicesToRegions,\n TableAction,\n} from \"./actions\";\nimport {\n autoLoadPagesAtom,\n useDataLoader,\n useLoadControls,\n} from \"./postgrest-table\";\nimport classNames from \"classnames\";\nimport {\n ActionsToolbar,\n LoadProgressIndicator,\n useDataPanelControls,\n type ViewControlsPresentation,\n} from \"./components\";\nimport { DataViewSharedProps, FetchDataOptions } from \"./types\";\nimport { atom } from \"jotai\";\nimport { passThroughSet } from \"./utils\";\n\nexport enum DataPanelToolbarStyle {\n BORDERED = \"bordered\",\n FADE = \"fade\",\n MINIMAL = \"minimal\",\n /** Toolbar (and footer) sized to their contents and lifted over the scroll\n * body, rather than occupying a full-width band. Pairs with\n * `viewControls: \"popover\"`, since inline controls cost real space here. */\n FLOATING = \"floating\",\n}\n\n/** Props for a custom scroll-body layout component. It receives the\n * already-rendered, selection-wrapped item cards and lays them out however it\n * likes (a grid, sections, sticky headers, its own windowing). The panel owns\n * the surrounding scroll container and the loading sentinel; the scroll body\n * only arranges the items. */\nexport interface ScrollBodyProps {\n /** The rendered item cards (each wrapped for selection styling). */\n children: ReactNode;\n /** Loading skeletons for the page currently being fetched, if any. Kept\n * separate from `children` because they are transient stand-ins, not items:\n * a layout that assigns a lasting position per item (e.g. the masonry body)\n * must not hand one to a placeholder. Render them after the items; a body\n * that ignores them simply shows no loading state. */\n placeholders?: ReactNode;\n}\n\n/** Props handed to a consumer's card renderer for one row. */\nexport interface ItemComponentProps<T = any> {\n /** The row's data. */\n data: T;\n /** Underlying data-row index (stable within a loaded window). */\n index: number;\n /** Whether this row is in the current selection. */\n selected: boolean;\n /** Whether the row can be selected */\n selectable: boolean;\n /** Select this row. Pass the click's `MouseEvent` (or `React.MouseEvent`) to\n * honor shift / cmd / ctrl automatically — the usual wiring is\n * `onClick: onSelect`. Or pass an explicit `SelectModifiers` object; no\n * argument means a plain (replace) select. */\n onSelect: (arg?: SelectModifiers | ReactMouseEvent) => void;\n}\n\nexport interface DataPanelProps<T = any> extends DataViewSharedProps<T> {\n /** Renders one row as a card. */\n itemComponent: ComponentType<ItemComponentProps<T>>;\n /** Arbitrary nodes for the bottom status row (beside the loaded/total\n * counter). Pass `false` to drop the status row entirely — e.g. when the\n * counter is folded into an inline footer instead. */\n statusBar?: ReactNode | false;\n /** Custom header controls, replacing the default `FacetControls` +\n * `FilterBar`. Rendered inside the provider, so it can drive sort/filter via\n * the exported building blocks (`FacetControls`, `FilterBar`) and the store\n * hooks (`useStoreAPI` / `useSelector`). The selection `ActionsToolbar` still\n * renders above it. Omit for the sane default. */\n toolbar?: ReactNode;\n /** A filter/detail sidebar beside the scroll body (its own scroll). Rendered\n * inside the provider, so a custom filter panel drives sort/filter through\n * the store hooks — the alternative placement to the top `toolbar`. */\n sidebar?: ReactNode;\n /** Footer content. Rendered inside the provider, so it reads live load state\n * from the store via `useLoadControls()` (loadMore / loading / hasMore /\n * loaded / total / paused) rather than a passed-down contract — a footer, a\n * status line, or a \"Load more\" button all just call the hook. */\n contentFooter?: ReactNode;\n /** Auto-load this many pages per burst, then pause: a paused panel stops\n * fetching on scroll until `useLoadControls().loadMore()` starts the next\n * burst (e.g. a footer \"Load more\" button). Omit for unbounded auto-scroll. */\n // TODO: we may deprecate this for opt-in scrolling\n autoLoadPages?: number;\n /** Custom layout for the item cards — the seam for anything other than a\n * vertical list (a CSS grid for several per row, grouped sections, sticky\n * sub-headers, a windowed renderer). Receives the rendered cards as\n * `children`; the panel still owns the scroll container and the loading\n * sentinel, so paging and selection keep working. Defaults to a vertical\n * flex list. */\n scrollBody?: ComponentType<ScrollBodyProps>;\n className?: string;\n toolbarStyle?: DataPanelToolbarStyle | string;\n /** Where the built-in view controls (inline filters, Filter menu, Sort menu)\n * sit in the toolbar: `\"inline\"` (default) places each in the toolbar;\n * `\"popover\"` collapses all of them behind a single button — for a narrow or\n * deliberately chrome-light toolbar. Same controls and state either way.\n * Ignored while a modal view is selecting: the toolbar then carries a single\n * control that leaves select mode. */\n viewControls?: ViewControlsPresentation;\n /** Arbitrary children rendered inside the provider, after the panel. */\n children?: ReactNode;\n}\n\n/**\n * Resolve the data source (shared with `DataSheet` / `DataView` via\n * `useResolvedProvider`), wrap in the shared provider, and render the inner\n * panel.\n */\nexport function DataPanel<T>(props: DataPanelProps<T>) {\n const [providerProps, rendererProps] = splitDataProviderProps({\n ...props,\n viewType: DataViewRendererType.CARDS,\n });\n return h(\n DataSheetProvider<T>,\n providerProps,\n h(DataPanelRenderer<any>, rendererProps),\n );\n}\n\n/** Selection modifier keys, following the familiar list idiom. */\nexport interface SelectModifiers {\n /** cmd/ctrl — toggle this row in/out of the selection (or extend a range). */\n additive?: boolean;\n /** shift — select the range from the anchor (last plain/cmd click) to here. */\n range?: boolean;\n}\n\n/** The card-list renderer. Assumes it is rendered inside a `DataSheetProvider`\n * (the `DataPanel` wrapper, or `DataView`). Exported so a shared-store\n * `DataView` can mount it directly alongside `_DataSheet`. */\nexport function DataPanelRenderer<T>({\n itemComponent,\n actions = [],\n filters = [],\n pageSize = 50,\n filterDebounce,\n initialData,\n name,\n // Bottom bar\n statusBar,\n toolbar,\n sidebar,\n // Footer within content flow\n contentFooter,\n autoLoadPages,\n scrollBody,\n className,\n toolbarStyle = DataPanelToolbarStyle.BORDERED,\n viewControls = \"inline\",\n children,\n}: Omit<DataPanelProps<T>, \"provider\" | \"fetchData\" | \"data\" | \"identity\">) {\n const {\n provider: activeProvider,\n isLocalProvider,\n localCount,\n } = ctx.useValue(dataProviderAtom);\n\n // The loader is mounted as a child component (below), NOT called as a hook\n // here, and only once `activeProvider` resolves. This mirrors `_DataSheet`:\n // `dataProviderAtom` is synced by a parent effect that fires *after* this\n // component's effects, so a hook call here would capture the placeholder\n // provider on first render and — since `fetchData` isn't one of its effect\n // deps — never re-fetch with the real one. A child that mounts with the real\n // `fetchData` already in hand sidesteps that entirely.\n // A local (in-memory) source loads all of its rows in one page; its count\n // rides on the resolved provider, so the renderer no longer takes a `data`\n // prop (the store is the single source of live rows).\n const loaderPageSize = isLocalProvider ? Math.max(localCount, 1) : pageSize;\n\n const data = useSelector((s) => s.data);\n\n // Load state + pause/resume live in the store, read via `useLoadControls`\n // (also available to the caller's `footer` via the same hook). The panel's\n // `autoLoadPages` prop is the store's configuration input.\n ctx.useSync(autoLoadPagesAtom, autoLoadPages ?? null);\n const {\n loading,\n initialized,\n error,\n hasMore,\n loaded,\n total,\n paused,\n canLoadMore,\n advance,\n } = useLoadControls();\n\n // Track whether the body is scrolled off the top, to gate the top fade.\n // `setState` with an unchanged value is a no-op, so this only re-renders on\n // the at-top ↔ scrolled transition.\n const [scrolled, setScrolled] = useState(false);\n const onScroll = useCallback((e: ReactUIEvent<HTMLDivElement>) => {\n setScrolled(e.currentTarget.scrollTop > 4);\n }, []);\n\n const enableSelection = ctx.useValue(enableSelectionAtom);\n const selectedIndices = ctx.useValue(selectedRowIndicesAtom);\n const select = ctx.useSet(updateSelectionAtom);\n\n const loadedCount = useMemo(() => {\n let n = 0;\n for (const r of data) if (r != null) n++;\n return n;\n }, [data]);\n\n // Refresh-token, rowEditing, and load controls (loadMore / pause) are all\n // store-managed (see `useLoadControls`), shared with `_DataSheet` — so both\n // renderers, and any footer, drive loading off one source.\n\n // Infinite scroll. A naive \"load a page when the bottom sentinel is visible\"\n // over-fetches: when a page's rows commit, this component re-renders\n // (loadedCount changed) *before* the IntersectionObserver has re-evaluated\n // the sentinel's new position, so a stale \"still visible\" fires a second\n // load. `useBottomSentinel` re-observes the sentinel whenever the pass-through\n // deps change, so every trigger reflects the *current* post-layout\n // visibility — it loads one page, and only loads another if the sentinel is\n // genuinely still on screen. `advance` (from the store) moves the loader one\n // page without resuming a paused auto-load.\n const sentinelRef = useBottomSentinel(canLoadMore ? advance : null, [\n loadedCount,\n canLoadMore,\n ]);\n\n const cards: ReactNode[] = data\n .filter((d) => d != null)\n .map((row: ReactNode, i) => {\n const selected = enableSelection && selectedIndices.has(i);\n return h(\n \"div.data-panel-item-container\",\n { key: `item-${i}`, className: classNames({ selected }) },\n h(itemComponent, {\n data: row,\n index: i,\n selected,\n selectable: enableSelection,\n onSelect: (arg?: SelectModifiers | ReactMouseEvent) =>\n select(i, modifiersOf(arg)),\n }),\n );\n });\n\n // Body-level empty/error state: when nothing has loaded, show a clear message\n // instead of a blank list — an errored source (e.g. a 401 on the whole route)\n // degrades gracefully, and a genuinely empty result reads as \"no results\"\n // rather than a perpetual spinner.\n // A load is pending whenever a fetch is in flight OR the view was just reset\n // and hasn't fetched yet (`!initialized`) — the window that would otherwise\n // flash \"No results\" before the request starts.\n const loadPending = (loading || !initialized) && error == null;\n\n let emptyState: ReactNode = null;\n if (cards.length === 0) {\n if (error != null) {\n emptyState = h(NonIdealState, {\n icon: \"error\",\n title: \"Couldn't load data\",\n description: error.message ?? \"The data source returned an error.\",\n });\n } else if (initialized && !loading) {\n // Only after a fetch settled with no rows — not during the reset gap.\n emptyState = h(NonIdealState, {\n icon: \"search\",\n title: \"No results\",\n });\n }\n }\n\n // Skeleton placeholders for the page being fetched — on a view change (the\n // reset pre-sizes to a page of `null` slots) or the next scroll page — so the\n // body shows shimmer where rows will land instead of a blank flash or a\n // footer pinging up into the gap. Bounded to a viewport's worth of cards.\n const placeholderCards: ReactNode[] = [];\n if (loadPending) {\n const pending = Math.min(Math.max(data.length - loadedCount, 0), 24);\n for (let i = 0; i < pending; i++) {\n placeholderCards.push(\n h(\n \"div.data-panel-item-container.is-skeleton\",\n { key: `skeleton-${i}`, \"aria-hidden\": true },\n h(\"div.data-panel-skeleton\", { className: Classes.SKELETON }),\n ),\n );\n }\n }\n let placeholders: ReactNode = null;\n if (placeholderCards.length > 0) {\n placeholders = placeholderCards;\n }\n\n // The default spinner sentinel (below-placement): hidden while paused so the\n // pinned footer's \"Load more\" takes over.\n const shouldLoadNextPage = (hasMore || loading) && !paused && error == null;\n\n // Mount the loader only once the provider resolves (see `PanelLoader`). Built\n // as a real conditional — `h.if(...)` evaluates its arguments eagerly, so\n // `activeProvider.fetchData` can't be referenced inside it while null.\n let loaderNode: ReactNode = null;\n if (activeProvider != null) {\n loaderNode = h(PanelLoader, {\n fetchData: activeProvider.fetchData,\n pageSize: loaderPageSize,\n fetchMode: isLocalProvider ? undefined : \"scroll\",\n filterDebounce,\n initialData,\n });\n }\n\n const coreActions = useDataPanelControls(filters, viewControls);\n\n // Merge consumer actions with the synthesized Filter/Sort controls, deduped\n // by id — consumer actions come first, so passing an action with id `filter`\n // or `sort` *replaces* the built-in one (a hybrid set keeps the others).\n // Mirrors the sheet's action registry contract (see `data-sheet.ts`).\n const _actions = useMemo(() => {\n const merged: TableAction[] = [];\n const add = (list: TableAction[]) => {\n for (const a of list) {\n if (!merged.some((x) => x.id === a.id)) merged.push(a);\n }\n };\n add(actions);\n add(coreActions);\n return merged;\n }, [actions, coreActions]);\n\n const ScrollBody = scrollBody ?? DefaultScrollBody;\n\n // The panel owns the scroll container + the loading sentinel; the (custom or\n // default) scroll body only lays out the cards. So a grid / grouped / windowed\n // body composes without reimplementing paging or selection. The end-of-scroll\n // region is either the default spinner sentinel or the caller's inline\n // footer — both carry the sentinel ref that drives auto-load.\n // The top fade is gated on being scrolled (via `.is-scrolled`), so the first\n // item isn't clipped at rest.\n\n const showStatusBar = statusBar !== false;\n\n let defaultFooter: ReactNode = null;\n if (shouldLoadNextPage) {\n defaultFooter = h(\"div.sentinel\", [h(Spinner, { size: 16 }), \"Loading...\"]);\n } else if (!showStatusBar) {\n defaultFooter = h(\"div.sentinel\", [\n h(Icon, { size: 16, icon: \"tick\" }),\n \"Loaded\",\n ]);\n }\n\n const _contentFooter = h(\n \"div.content-footer-holder\",\n { ref: sentinelRef },\n contentFooter ?? defaultFooter,\n );\n\n // Body + optional filter/detail sidebar share a horizontal row so each\n // scrolls independently.\n\n // Bottom status row (counter + extras). `statusBar === false` drops it — e.g.\n // when an inline footer carries the counter itself.\n let footer: ReactNode = null;\n let _statusBarContent = statusBar ?? h(DataPanelStatusBar);\n if (showStatusBar) {\n footer = h(\n \"div.data-panel-footer\",\n h(\"div.data-panel-footer-content\", [_statusBarContent]),\n );\n }\n\n const _toolbar = h(\n \"div.data-panel-top-area\",\n h(\n \"div.data-panel-toolbar\",\n h(\n ActionsToolbar,\n {\n actions: _actions,\n tableName: name,\n className: \"data-panel-toolbar-content\",\n // In the panel the title doubles as the modal-selection control,\n // so only render it when modal selection is toggle-able (or a\n // selection is active) — not as a bare label otherwise.\n compact: true,\n },\n toolbar,\n ),\n ),\n );\n\n return h(\n \"div.data-panel\",\n { className: classNames(className, \"toolbar-style-\" + toolbarStyle) },\n [\n h(\"div.data-panel-main\", [\n loaderNode,\n _toolbar,\n h(\n \"div.data-panel-body\",\n {\n onScroll,\n className: classNames({ \"is-scrolled\": scrolled }),\n },\n [\n h(\"div.data-panel-body-content\", [\n emptyState ?? h(ScrollBody, { placeholders }, cards),\n _contentFooter,\n ]),\n ],\n ),\n footer,\n ]),\n h.if(sidebar != null)(\"div.data-panel-sidebar-container\", sidebar),\n children,\n ],\n );\n}\n\nfunction DataPanelStatusBar({ children }) {\n /** Default status bar for the Data Panel */\n return h(\"div.data-panel-status-bar\", [children, h(LoadProgressIndicator)]);\n}\n\n/** Default scroll-body layout: a vertical flex list of cards, with any loading\n * placeholders appended in the same flow. */\nfunction DefaultScrollBody({ children, placeholders }: ScrollBodyProps) {\n return h(\"div.data-panel-list\", [children, placeholders]);\n}\n\n/** Runs the shared windowed loader from inside the panel (renders nothing).\n * Mounted only once the real provider is resolved, so `useDataLoader` captures\n * the real `fetchData` from the start (see `_DataPanel`). */\nfunction PanelLoader<T = any>({\n fetchData,\n ...options\n}: { fetchData: FetchData<T> } & FetchDataOptions<T>) {\n useDataLoader(fetchData, options);\n return null;\n}\n\n/** Resolve the selection modifiers from either a click event (reads shift /\n * cmd / ctrl) or an explicit modifier object; no argument ⇒ a plain select. */\nfunction modifiersOf(arg?: SelectModifiers | ReactMouseEvent): SelectModifiers {\n if (arg == null) return {};\n if (\"shiftKey\" in arg) {\n return { additive: arg.metaKey || arg.ctrlKey, range: arg.shiftKey };\n }\n return arg;\n}\n\n/**\n * Bottom-sentinel infinite-scroll hook (no `react-intersection-observer`\n * dependency). Calls `onVisible` when the observed element is on screen, and —\n * crucially — **re-observes on every `deps` change** so the callback reflects\n * the *current* post-layout visibility rather than the pre-load render.\n *\n * This is what avoids the double-load: a plain observer whose visibility is\n * mirrored into React state lags a render behind the DOM, so a load-driven\n * re-render fires a second `onVisible` before the observer catches up. By\n * re-arming after each load (`deps = [loadedCount, canLoadMore]`), the observer\n * emits a fresh callback for the settled layout: it fires again only if the\n * sentinel is *still* visible (viewport not yet filled), so it loads exactly\n * one page per bottom-reach and self-fills an underfull viewport without\n * overshooting. Pass `onVisible = null` to disarm (loading / no more data).\n */\nfunction useBottomSentinel<E extends HTMLElement>(\n onVisible: (() => void) | null,\n deps: unknown[],\n): (el: E | null) => void {\n const elRef = useRef<E | null>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const cbRef = useRef(onVisible);\n cbRef.current = onVisible;\n\n const setRef = useCallback((el: E | null) => {\n elRef.current = el;\n observerRef.current?.disconnect();\n observerRef.current = null;\n if (el == null) return;\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) cbRef.current?.();\n },\n { rootMargin: \"300px\" },\n );\n observer.observe(el);\n observerRef.current = observer;\n }, []);\n\n // Re-arm after each load so the observer re-checks the settled layout.\n useEffect(() => {\n const el = elRef.current;\n const observer = observerRef.current;\n if (el == null || observer == null) return;\n observer.disconnect();\n observer.observe(el);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n useEffect(() => () => observerRef.current?.disconnect(), []);\n return setRef;\n}\n\nconst rowSelectionAtom = atom((get) => {\n /** Coerce selection to full rows, for use with data panel instead of data sheet. */\n const selection = get(selectionAtom);\n if (selection.some((r) => r.cols != null)) {\n // A card list has no cells or columns. When the selection carries columns —\n // inherited from a shared store the sheet also drives (a `DataView` toggle) —\n // coerce it to the full rows it covers, so the toolbar shows row-scoped\n // actions rather than column/cell ones for a column that isn't visible here.\n // Column-only selections (no rows) collapse to nothing.\n return rowIndicesToRegions(new Set(getSelectedRowIndices(selection)));\n } else {\n return selection;\n }\n}, passThroughSet(selectionAtom));\n\nconst updateSelectionAtom = atom(\n null,\n (get, set, index: number, mods: SelectModifiers) => {\n /** Update selection from a row index and modifiers. */\n const { enableMultipleSelection, enableModalSelection } = get(\n interactionOptionsAtom,\n );\n let enableSelection = get(enableSelectionAtom);\n if (!enableSelection) {\n // Cmd/ctrl-click *enters* select mode on a modal view and selects the\n // row, the familiar list idiom — so a bulk action doesn't require finding\n // the Select control first. The flag is read back below rather than\n // trusted from this scope: the write goes through the store synchronously.\n if (!enableModalSelection || !mods.additive) return;\n set(enableSelectionAtom, true);\n enableSelection = get(enableSelectionAtom);\n if (!enableSelection) return;\n }\n const selection = get(rowSelectionAtom);\n const anchorRef = get(anchorRefAtom);\n const res = buildDataViewSelection(\n index,\n mods,\n selection,\n anchorRef,\n enableMultipleSelection,\n );\n set(selectionAtom, res);\n },\n);\n\nconst selectedRowIndicesAtom = atom((get) => {\n const sel = get(selectionAtom);\n return new Set(getSelectedRowIndices(sel));\n});\n\ntype ItemSelectionKeys = \"onSelect\" | \"selected\" | \"selectable\";\n\ntype DataCardProps = {\n children: ReactNode;\n className: string;\n style?: CSSProperties;\n} & Pick<ItemComponentProps, ItemSelectionKeys>;\n\nexport function DataCard<T = any>(props: DataCardProps) {\n /** A basic card that implements the data panel's selection behavior. */\n return h(\n \"div.data-card.data-panel-item\",\n {\n className: classNames(props.className, {\n selected: props.selected,\n selectable: props.selectable,\n }),\n onClick: props.onSelect,\n style: props.style,\n },\n props.children,\n );\n}\n\ntype DataCardInnerComponent<T> = (\n props: ItemComponentProps<T>,\n) => React.ReactNode;\n\nexport function createDataCard<T>(\n component: DataCardInnerComponent<T>,\n extraProps = {},\n) {\n return (props: ItemComponentProps<T>) => {\n const { selected, selectable, onSelect } = props;\n return h(\n DataCard,\n {\n selected,\n selectable,\n onSelect,\n ...extraProps,\n },\n h(component, props),\n );\n };\n}\n"],"names":["DataPanelToolbarStyle","splitDataProviderProps","DataViewRendererType","h","DataSheetProvider","ctx","dataProviderAtom","useSelector","autoLoadPagesAtom","useLoadControls","useState","useCallback","enableSelectionAtom","useMemo","classNames","NonIdealState","Classes","useDataPanelControls","Spinner","Icon","ActionsToolbar","LoadProgressIndicator","useDataLoader","useRef","useEffect","atom","selection","selectionAtom","rowIndicesToRegions","getSelectedRowIndices","passThroughSet","interactionOptionsAtom","anchorRefAtom","buildDataViewSelection"],"mappings":";;;;;;;;;;;;;;;;;;AAyEO,IAAK,0CAAAA,2BAAL;AACLA,yBAAA,UAAA,IAAW;AACXA,yBAAA,MAAA,IAAO;AACPA,yBAAA,SAAA,IAAU;AAIVA,yBAAA,UAAA,IAAW;AAPD,SAAAA;AAAA,GAAA,yBAAA,CAAA,CAAA;AA+FL,SAAS,UAAa,OAA0B;AACrD,QAAM,CAAC,eAAe,aAAa,IAAIC,4BAAuB;AAAA,IAC5D,GAAG;AAAA,IACH,UAAUC,aAAAA,qBAAqB;AAAA,EAAA,CAChC;AACD,SAAOC,iBAAAA;AAAAA,IACLC,KAAAA;AAAAA,IACA;AAAA,IACAD,iBAAAA,QAAE,mBAAwB,aAAa;AAAA,EAAA;AAE3C;AAaO,SAAS,kBAAqB;AAAA,EACnC;AAAA,EACA,UAAU,CAAA;AAAA,EACV,UAAU,CAAA;AAAA,EACV,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,eAAe;AAAA,EACf;AACF,GAA4E;AAC1E,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,EAAA,IACEE,KAAAA,IAAI,SAASC,qBAAgB;AAYjC,QAAM,iBAAiB,kBAAkB,KAAK,IAAI,YAAY,CAAC,IAAI;AAEnE,QAAM,OAAOC,KAAAA,YAAY,CAAC,MAAM,EAAE,IAAI;AAKtCF,OAAAA,IAAI,QAAQG,+BAAmB,iBAAiB,IAAI;AACpD,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AAAA,IACxB;AACA,UAAMc,cAAY,IAAI,gBAAgB;AACtC,UAAM,YAAY,IAAIM,uBAAa;AACnC,UAAM,MAAMC,YAAAA;AAAAA,MACV;AAAA,MACA;AAAA,MACAP;AAAAA,MACA;AAAA,MACA;AAAA,IAAA;AAEF,QAAIC,UAAAA,eAAe,GAAG;AAAA,EACxB;AACF;AAEA,MAAM,yBAAyBF,MAAAA,KAAK,CAAC,QAAQ;AAC3C,QAAM,MAAM,IAAIE,uBAAa;AAC7B,SAAO,IAAI,IAAIE,kCAAsB,GAAG,CAAC;AAC3C,CAAC;AAUM,SAAS,SAAkB,OAAsB;AAEtD,SAAO1B,iBAAAA;AAAAA,IACL;AAAA,IACA;AAAA,MACE,WAAWW,oBAAAA,QAAW,MAAM,WAAW;AAAA,QACrC,UAAU,MAAM;AAAA,QAChB,YAAY,MAAM;AAAA,MAAA,CACnB;AAAA,MACD,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,IAAA;AAAA,IAEf,MAAM;AAAA,EAAA;AAEV;AAMO,SAAS,eACd,WACA,aAAa,IACb;AACA,SAAO,CAAC,UAAiC;AACvC,UAAM,EAAE,UAAU,YAAY,SAAA,IAAa;AAC3C,WAAOX,iBAAAA;AAAAA,MACL;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,MAELA,iBAAAA,QAAE,WAAW,KAAK;AAAA,IAAA;AAAA,EAEtB;AACF;;;;;;"}
1
+ {"version":3,"file":"data-panel.cjs","sources":["../src/data-panel.ts"],"sourcesContent":["/**\n * DataPanel — a card/list renderer over the same headless core as `DataSheet`.\n *\n * The two components differ in only two dimensions: the **view** (cards vs. the\n * Blueprint cell grid) and **edit granularity** (immediate per-item vs. a\n * batched pending-ops stack). Everything else — provider-driven windowed\n * loading, `{sorts, filters}` view state, the selection set, and set-based\n * actions — is the shared substrate, reused here unchanged:\n *\n * - `DataSheetProvider` supplies the jotai+zustand store.\n * - `useDataLoader(provider.fetchData)` drives windowed loading and threads the\n * active store sorts/filters through so a server provider applies them.\n * - `ActionsToolbar` + `FilterBar` render selection-aware actions and the\n * active sort/filter tags — they read the store, not the table.\n *\n * The only list-specific pieces are: rows rendered as cards via a consumer\n * `itemComponent`; selection expressed as `FULL_ROWS` regions (so the existing\n * row-targeted `TableAction`s apply); an infinite-scroll sentinel that advances\n * the loader's visible region; and `FacetControls`, which stands in for the\n * column-header dropdown the list doesn't have (a menu to add a column filter /\n * sort from the column-declared `filterable` / `sortable` capabilities).\n *\n * See [[Data list editors]] in the Macrostrat workbench for the design.\n */\nimport h from \"./data-panel.module.sass\";\nimport {\n ComponentType,\n CSSProperties,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n UIEvent as ReactUIEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n AnchorButton,\n Classes,\n Icon,\n NonIdealState,\n Spinner,\n} from \"@blueprintjs/core\";\nimport { startAfterAtom } from \"./provider/loader-state.ts\";\nimport {\n anchorRefAtom,\n ctx,\n dataProviderAtom,\n DataSheetProvider,\n DataViewRendererType,\n FetchData,\n enableSelectionAtom,\n interactionOptionsAtom,\n selectionAtom,\n splitDataProviderProps,\n useSelector,\n} from \"./provider\";\nimport {\n buildDataViewSelection,\n getSelectedRowIndices,\n rowIndicesToRegions,\n TableAction,\n} from \"./actions\";\nimport {\n autoLoadPagesAtom,\n useDataLoader,\n useLoadControls,\n} from \"./postgrest-table\";\nimport classNames from \"classnames\";\nimport {\n ActionsToolbar,\n LoadProgressIndicator,\n useDataPanelControls,\n type ViewControlsPresentation,\n} from \"./components\";\nimport { DataViewSharedProps, FetchDataOptions } from \"./types\";\nimport { atom } from \"jotai\";\nimport { passThroughSet } from \"./utils\";\n\nexport enum DataPanelToolbarStyle {\n BORDERED = \"bordered\",\n FADE = \"fade\",\n MINIMAL = \"minimal\",\n /** Toolbar (and footer) sized to their contents and lifted over the scroll\n * body, rather than occupying a full-width band. Pairs with\n * `viewControls: \"popover\"`, since inline controls cost real space here. */\n FLOATING = \"floating\",\n}\n\n/** Props for a custom scroll-body layout component. It receives the\n * already-rendered, selection-wrapped item cards and lays them out however it\n * likes (a grid, sections, sticky headers, its own windowing). The panel owns\n * the surrounding scroll container and the loading sentinel; the scroll body\n * only arranges the items. */\nexport interface ScrollBodyProps {\n /** The rendered item cards (each wrapped for selection styling). */\n children: ReactNode;\n /** Loading skeletons for the page currently being fetched, if any. Kept\n * separate from `children` because they are transient stand-ins, not items:\n * a layout that assigns a lasting position per item (e.g. the masonry body)\n * must not hand one to a placeholder. Render them after the items; a body\n * that ignores them simply shows no loading state. */\n placeholders?: ReactNode;\n}\n\n/** Props handed to a consumer's card renderer for one row. */\nexport interface ItemComponentProps<T = any> {\n /** The row's data. */\n data: T;\n /** Underlying data-row index (stable within a loaded window). */\n index: number;\n /** Whether this row is in the current selection. */\n selected: boolean;\n /** Whether the row can be selected */\n selectable: boolean;\n /** Select this row. Pass the click's `MouseEvent` (or `React.MouseEvent`) to\n * honor shift / cmd / ctrl automatically — the usual wiring is\n * `onClick: onSelect`. Or pass an explicit `SelectModifiers` object; no\n * argument means a plain (replace) select. */\n onSelect: (arg?: SelectModifiers | ReactMouseEvent) => void;\n}\n\nexport interface DataPanelProps<T = any> extends DataViewSharedProps<T> {\n /** Renders one row as a card. */\n itemComponent: ComponentType<ItemComponentProps<T>>;\n /** Arbitrary nodes for the bottom status row (beside the loaded/total\n * counter). Pass `false` to drop the status row entirely — e.g. when the\n * counter is folded into an inline footer instead. */\n statusBar?: ReactNode | false;\n /** Custom header controls, replacing the default `FacetControls` +\n * `FilterBar`. Rendered inside the provider, so it can drive sort/filter via\n * the exported building blocks (`FacetControls`, `FilterBar`) and the store\n * hooks (`useStoreAPI` / `useSelector`). The selection `ActionsToolbar` still\n * renders above it. Omit for the sane default. */\n toolbar?: ReactNode;\n /** A filter/detail sidebar beside the scroll body (its own scroll). Rendered\n * inside the provider, so a custom filter panel drives sort/filter through\n * the store hooks — the alternative placement to the top `toolbar`. */\n sidebar?: ReactNode;\n /** Footer content. Rendered inside the provider, so it reads live load state\n * from the store via `useLoadControls()` (loadMore / loading / hasMore /\n * loaded / total / paused) rather than a passed-down contract — a footer, a\n * status line, or a \"Load more\" button all just call the hook. */\n contentFooter?: ReactNode;\n /** Auto-load this many pages per burst, then pause: a paused panel stops\n * fetching on scroll until `useLoadControls().loadMore()` starts the next\n * burst (e.g. a footer \"Load more\" button). Omit for unbounded auto-scroll. */\n // TODO: we may deprecate this for opt-in scrolling\n autoLoadPages?: number;\n /** Custom layout for the item cards — the seam for anything other than a\n * vertical list (a CSS grid for several per row, grouped sections, sticky\n * sub-headers, a windowed renderer). Receives the rendered cards as\n * `children`; the panel still owns the scroll container and the loading\n * sentinel, so paging and selection keep working. Defaults to a vertical\n * flex list. */\n scrollBody?: ComponentType<ScrollBodyProps>;\n className?: string;\n toolbarStyle?: DataPanelToolbarStyle | string;\n /** Where the built-in view controls (inline filters, Filter menu, Sort menu)\n * sit in the toolbar: `\"inline\"` (default) places each in the toolbar;\n * `\"popover\"` collapses all of them behind a single button — for a narrow or\n * deliberately chrome-light toolbar. Same controls and state either way.\n * Ignored while a modal view is selecting: the toolbar then carries a single\n * control that leaves select mode. */\n viewControls?: ViewControlsPresentation;\n /** Arbitrary children rendered inside the provider, after the panel. */\n children?: ReactNode;\n}\n\n/**\n * Resolve the data source (shared with `DataSheet` / `DataView` via\n * `useResolvedProvider`), wrap in the shared provider, and render the inner\n * panel.\n */\nexport function DataPanel<T>(props: DataPanelProps<T>) {\n const [providerProps, rendererProps] = splitDataProviderProps({\n ...props,\n viewType: DataViewRendererType.CARDS,\n });\n return h(\n DataSheetProvider<T>,\n providerProps,\n h(DataPanelRenderer<any>, rendererProps),\n );\n}\n\n/** Selection modifier keys, following the familiar list idiom. */\nexport interface SelectModifiers {\n /** cmd/ctrl — toggle this row in/out of the selection (or extend a range). */\n additive?: boolean;\n /** shift — select the range from the anchor (last plain/cmd click) to here. */\n range?: boolean;\n}\n\n/** The card-list renderer. Assumes it is rendered inside a `DataSheetProvider`\n * (the `DataPanel` wrapper, or `DataView`). Exported so a shared-store\n * `DataView` can mount it directly alongside `_DataSheet`. */\nexport function DataPanelRenderer<T>({\n itemComponent,\n actions = [],\n filters = [],\n pageSize = 50,\n filterDebounce,\n initialData,\n name,\n // Bottom bar\n statusBar,\n toolbar,\n sidebar,\n // Footer within content flow\n contentFooter,\n autoLoadPages,\n scrollBody,\n pageLinks,\n className,\n toolbarStyle = DataPanelToolbarStyle.BORDERED,\n viewControls = \"inline\",\n children,\n}: Omit<DataPanelProps<T>, \"provider\" | \"fetchData\" | \"data\" | \"identity\">) {\n const {\n provider: activeProvider,\n isLocalProvider,\n localCount,\n } = ctx.useValue(dataProviderAtom);\n\n // The loader is mounted as a child component (below), NOT called as a hook\n // here, and only once `activeProvider` resolves. This mirrors `_DataSheet`:\n // `dataProviderAtom` is synced by a parent effect that fires *after* this\n // component's effects, so a hook call here would capture the placeholder\n // provider on first render and — since `fetchData` isn't one of its effect\n // deps — never re-fetch with the real one. A child that mounts with the real\n // `fetchData` already in hand sidesteps that entirely.\n // A local (in-memory) source loads all of its rows in one page; its count\n // rides on the resolved provider, so the renderer no longer takes a `data`\n // prop (the store is the single source of live rows).\n const loaderPageSize = isLocalProvider ? Math.max(localCount, 1) : pageSize;\n\n const data = useSelector((s) => s.data);\n\n // Load state + pause/resume live in the store, read via `useLoadControls`\n // (also available to the caller's `footer` via the same hook). The panel's\n // `autoLoadPages` prop is the store's configuration input.\n ctx.useSync(autoLoadPagesAtom, autoLoadPages ?? null);\n const {\n loading,\n initialized,\n error,\n hasMore,\n loaded,\n total,\n paused,\n canLoadMore,\n advance,\n } = useLoadControls();\n\n // Track whether the body is scrolled off the top, to gate the top fade.\n // `setState` with an unchanged value is a no-op, so this only re-renders on\n // the at-top ↔ scrolled transition.\n const [scrolled, setScrolled] = useState(false);\n const onScroll = useCallback((e: ReactUIEvent<HTMLDivElement>) => {\n setScrolled(e.currentTarget.scrollTop > 4);\n }, []);\n\n const enableSelection = ctx.useValue(enableSelectionAtom);\n const selectedIndices = ctx.useValue(selectedRowIndicesAtom);\n const select = ctx.useSet(updateSelectionAtom);\n\n const loadedCount = useMemo(() => {\n let n = 0;\n for (const r of data) if (r != null) n++;\n return n;\n }, [data]);\n\n // Refresh-token, rowEditing, and load controls (loadMore / pause) are all\n // store-managed (see `useLoadControls`), shared with `_DataSheet` — so both\n // renderers, and any footer, drive loading off one source.\n\n // Infinite scroll. A naive \"load a page when the bottom sentinel is visible\"\n // over-fetches: when a page's rows commit, this component re-renders\n // (loadedCount changed) *before* the IntersectionObserver has re-evaluated\n // the sentinel's new position, so a stale \"still visible\" fires a second\n // load. `useBottomSentinel` re-observes the sentinel whenever the pass-through\n // deps change, so every trigger reflects the *current* post-layout\n // visibility — it loads one page, and only loads another if the sentinel is\n // genuinely still on screen. `advance` (from the store) moves the loader one\n // page without resuming a paused auto-load.\n const sentinelRef = useBottomSentinel(canLoadMore ? advance : null, [\n loadedCount,\n canLoadMore,\n ]);\n\n const cards: ReactNode[] = data\n .filter((d) => d != null)\n .map((row: ReactNode, i) => {\n const selected = enableSelection && selectedIndices.has(i);\n return h(\n \"div.data-panel-item-container\",\n { key: `item-${i}`, className: classNames({ selected }) },\n h(itemComponent, {\n data: row,\n index: i,\n selected,\n selectable: enableSelection,\n onSelect: (arg?: SelectModifiers | ReactMouseEvent) =>\n select(i, modifiersOf(arg)),\n }),\n );\n });\n\n // Body-level empty/error state: when nothing has loaded, show a clear message\n // instead of a blank list — an errored source (e.g. a 401 on the whole route)\n // degrades gracefully, and a genuinely empty result reads as \"no results\"\n // rather than a perpetual spinner.\n // A load is pending whenever a fetch is in flight OR the view was just reset\n // and hasn't fetched yet (`!initialized`) — the window that would otherwise\n // flash \"No results\" before the request starts.\n const loadPending = (loading || !initialized) && error == null;\n\n let emptyState: ReactNode = null;\n if (cards.length === 0) {\n if (error != null) {\n emptyState = h(NonIdealState, {\n icon: \"error\",\n title: \"Couldn't load data\",\n description: error.message ?? \"The data source returned an error.\",\n });\n } else if (initialized && !loading) {\n // Only after a fetch settled with no rows — not during the reset gap.\n emptyState = h(NonIdealState, {\n icon: \"search\",\n title: \"No results\",\n });\n }\n }\n\n // Skeleton placeholders for the page being fetched — on a view change (the\n // reset pre-sizes to a page of `null` slots) or the next scroll page — so the\n // body shows shimmer where rows will land instead of a blank flash or a\n // footer pinging up into the gap. Bounded to a viewport's worth of cards.\n const placeholderCards: ReactNode[] = [];\n if (loadPending) {\n const pending = Math.min(Math.max(data.length - loadedCount, 0), 24);\n for (let i = 0; i < pending; i++) {\n placeholderCards.push(\n h(\n \"div.data-panel-item-container.is-skeleton\",\n { key: `skeleton-${i}`, \"aria-hidden\": true },\n h(\"div.data-panel-skeleton\", { className: Classes.SKELETON }),\n ),\n );\n }\n }\n let placeholders: ReactNode = null;\n if (placeholderCards.length > 0) {\n placeholders = placeholderCards;\n }\n\n // The default spinner sentinel (below-placement): hidden while paused so the\n // pinned footer's \"Load more\" takes over.\n const shouldLoadNextPage = (hasMore || loading) && !paused && error == null;\n\n // Mount the loader only once the provider resolves (see `PanelLoader`). Built\n // as a real conditional — `h.if(...)` evaluates its arguments eagerly, so\n // `activeProvider.fetchData` can't be referenced inside it while null.\n let loaderNode: ReactNode = null;\n if (activeProvider != null) {\n loaderNode = h(PanelLoader, {\n fetchData: activeProvider.fetchData,\n pageSize: loaderPageSize,\n fetchMode: isLocalProvider ? undefined : \"scroll\",\n filterDebounce,\n initialData,\n });\n }\n\n const coreActions = useDataPanelControls(filters, viewControls);\n\n // Merge consumer actions with the synthesized Filter/Sort controls, deduped\n // by id — consumer actions come first, so passing an action with id `filter`\n // or `sort` *replaces* the built-in one (a hybrid set keeps the others).\n // Mirrors the sheet's action registry contract (see `data-sheet.ts`).\n const _actions = useMemo(() => {\n const merged: TableAction[] = [];\n const add = (list: TableAction[]) => {\n for (const a of list) {\n if (!merged.some((x) => x.id === a.id)) merged.push(a);\n }\n };\n add(actions);\n add(coreActions);\n return merged;\n }, [actions, coreActions]);\n\n const ScrollBody = scrollBody ?? DefaultScrollBody;\n\n // The panel owns the scroll container + the loading sentinel; the (custom or\n // default) scroll body only lays out the cards. So a grid / grouped / windowed\n // body composes without reimplementing paging or selection. The end-of-scroll\n // region is either the default spinner sentinel or the caller's inline\n // footer — both carry the sentinel ref that drives auto-load.\n // The top fade is gated on being scrolled (via `.is-scrolled`), so the first\n // item isn't clipped at rest.\n\n const showStatusBar = statusBar !== false;\n\n let defaultFooter: ReactNode = null;\n if (shouldLoadNextPage) {\n defaultFooter = h(\"div.sentinel\", [h(Spinner, { size: 16 }), \"Loading...\"]);\n } else if (!showStatusBar) {\n defaultFooter = h(\"div.sentinel\", [\n h(Icon, { size: 16, icon: \"tick\" }),\n \"Loaded\",\n ]);\n }\n\n const _contentFooter = h(\n \"div.content-footer-holder\",\n { ref: sentinelRef },\n contentFooter ?? defaultFooter,\n );\n\n // Crawlable paging (see `PageLinks`). Both are plain links, so they work in\n // the server-rendered HTML with no script: the next-page link is visually\n // hidden after the loaded rows and points past the last loaded row; the\n // \"Return to top\" notice heads the content while the view starts mid-list.\n const startAfter = ctx.useValue(startAfterAtom);\n const lastLoadedRow = useMemo(() => {\n for (let i = data.length - 1; i >= 0; i--) {\n if (data[i] != null) return data[i];\n }\n return null;\n }, [data]);\n // Gated on the counts rather than `hasMore`, which reads the resolved\n // provider — synced after mount, so absent in a server render.\n const moreToCome = total == null || loadedCount < total;\n let nextPageLink: ReactNode = null;\n if (pageLinks != null && lastLoadedRow != null && moreToCome) {\n nextPageLink = h(\n \"a.crawl-next-link\",\n {\n href: pageLinks.after(lastLoadedRow),\n rel: \"next\",\n tabIndex: -1,\n \"aria-hidden\": true,\n },\n \"Next page\",\n );\n }\n let viewStartNotice: ReactNode = null;\n if (startAfter != null && pageLinks?.top != null) {\n viewStartNotice = h(\"div.view-start-notice\", [\n h(\"span.view-start-text\", `Continued after #${startAfter}`),\n h(\n AnchorButton,\n { href: pageLinks.top, minimal: true, small: true, icon: \"arrow-up\" },\n pageLinks.topLabel ?? \"Return to top\",\n ),\n ]);\n }\n\n // Body + optional filter/detail sidebar share a horizontal row so each\n // scrolls independently.\n\n // Bottom status row (counter + extras). `statusBar === false` drops it — e.g.\n // when an inline footer carries the counter itself.\n let footer: ReactNode = null;\n let _statusBarContent = statusBar ?? h(DataPanelStatusBar);\n if (showStatusBar) {\n footer = h(\n \"div.data-panel-footer\",\n h(\"div.data-panel-footer-content\", [_statusBarContent]),\n );\n }\n\n const _toolbar = h(\n \"div.data-panel-top-area\",\n h(\n \"div.data-panel-toolbar\",\n h(\n ActionsToolbar,\n {\n actions: _actions,\n tableName: name,\n className: \"data-panel-toolbar-content\",\n // In the panel the title doubles as the modal-selection control,\n // so only render it when modal selection is toggle-able (or a\n // selection is active) — not as a bare label otherwise.\n compact: true,\n },\n toolbar,\n ),\n ),\n );\n\n return h(\n \"div.data-panel\",\n { className: classNames(className, \"toolbar-style-\" + toolbarStyle) },\n [\n h(\"div.data-panel-main\", [\n loaderNode,\n _toolbar,\n h(\n \"div.data-panel-body\",\n {\n onScroll,\n className: classNames({ \"is-scrolled\": scrolled }),\n },\n [\n h(\"div.data-panel-body-content\", [\n viewStartNotice,\n emptyState ?? h(ScrollBody, { placeholders }, cards),\n nextPageLink,\n _contentFooter,\n ]),\n ],\n ),\n footer,\n ]),\n h.if(sidebar != null)(\"div.data-panel-sidebar-container\", sidebar),\n children,\n ],\n );\n}\n\nfunction DataPanelStatusBar({ children }) {\n /** Default status bar for the Data Panel */\n return h(\"div.data-panel-status-bar\", [children, h(LoadProgressIndicator)]);\n}\n\n/** Default scroll-body layout: a vertical flex list of cards, with any loading\n * placeholders appended in the same flow. */\nfunction DefaultScrollBody({ children, placeholders }: ScrollBodyProps) {\n return h(\"div.data-panel-list\", [children, placeholders]);\n}\n\n/** Runs the shared windowed loader from inside the panel (renders nothing).\n * Mounted only once the real provider is resolved, so `useDataLoader` captures\n * the real `fetchData` from the start (see `_DataPanel`). */\nfunction PanelLoader<T = any>({\n fetchData,\n ...options\n}: { fetchData: FetchData<T> } & FetchDataOptions<T>) {\n useDataLoader(fetchData, options);\n return null;\n}\n\n/** Resolve the selection modifiers from either a click event (reads shift /\n * cmd / ctrl) or an explicit modifier object; no argument ⇒ a plain select. */\nfunction modifiersOf(arg?: SelectModifiers | ReactMouseEvent): SelectModifiers {\n if (arg == null) return {};\n if (\"shiftKey\" in arg) {\n return { additive: arg.metaKey || arg.ctrlKey, range: arg.shiftKey };\n }\n return arg;\n}\n\n/**\n * Bottom-sentinel infinite-scroll hook (no `react-intersection-observer`\n * dependency). Calls `onVisible` when the observed element is on screen, and —\n * crucially — **re-observes on every `deps` change** so the callback reflects\n * the *current* post-layout visibility rather than the pre-load render.\n *\n * This is what avoids the double-load: a plain observer whose visibility is\n * mirrored into React state lags a render behind the DOM, so a load-driven\n * re-render fires a second `onVisible` before the observer catches up. By\n * re-arming after each load (`deps = [loadedCount, canLoadMore]`), the observer\n * emits a fresh callback for the settled layout: it fires again only if the\n * sentinel is *still* visible (viewport not yet filled), so it loads exactly\n * one page per bottom-reach and self-fills an underfull viewport without\n * overshooting. Pass `onVisible = null` to disarm (loading / no more data).\n */\nfunction useBottomSentinel<E extends HTMLElement>(\n onVisible: (() => void) | null,\n deps: unknown[],\n): (el: E | null) => void {\n const elRef = useRef<E | null>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const cbRef = useRef(onVisible);\n cbRef.current = onVisible;\n\n const setRef = useCallback((el: E | null) => {\n elRef.current = el;\n observerRef.current?.disconnect();\n observerRef.current = null;\n if (el == null) return;\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) cbRef.current?.();\n },\n { rootMargin: \"300px\" },\n );\n observer.observe(el);\n observerRef.current = observer;\n }, []);\n\n // Re-arm after each load so the observer re-checks the settled layout.\n useEffect(() => {\n const el = elRef.current;\n const observer = observerRef.current;\n if (el == null || observer == null) return;\n observer.disconnect();\n observer.observe(el);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n useEffect(() => () => observerRef.current?.disconnect(), []);\n return setRef;\n}\n\nconst rowSelectionAtom = atom((get) => {\n /** Coerce selection to full rows, for use with data panel instead of data sheet. */\n const selection = get(selectionAtom);\n if (selection.some((r) => r.cols != null)) {\n // A card list has no cells or columns. When the selection carries columns —\n // inherited from a shared store the sheet also drives (a `DataView` toggle) —\n // coerce it to the full rows it covers, so the toolbar shows row-scoped\n // actions rather than column/cell ones for a column that isn't visible here.\n // Column-only selections (no rows) collapse to nothing.\n return rowIndicesToRegions(new Set(getSelectedRowIndices(selection)));\n } else {\n return selection;\n }\n}, passThroughSet(selectionAtom));\n\nconst updateSelectionAtom = atom(\n null,\n (get, set, index: number, mods: SelectModifiers) => {\n /** Update selection from a row index and modifiers. */\n const { enableMultipleSelection, enableModalSelection } = get(\n interactionOptionsAtom,\n );\n let enableSelection = get(enableSelectionAtom);\n if (!enableSelection) {\n // Cmd/ctrl-click *enters* select mode on a modal view and selects the\n // row, the familiar list idiom — so a bulk action doesn't require finding\n // the Select control first. The flag is read back below rather than\n // trusted from this scope: the write goes through the store synchronously.\n if (!enableModalSelection || !mods.additive) return;\n set(enableSelectionAtom, true);\n enableSelection = get(enableSelectionAtom);\n if (!enableSelection) return;\n }\n const selection = get(rowSelectionAtom);\n const anchorRef = get(anchorRefAtom);\n const res = buildDataViewSelection(\n index,\n mods,\n selection,\n anchorRef,\n enableMultipleSelection,\n );\n set(selectionAtom, res);\n },\n);\n\nconst selectedRowIndicesAtom = atom((get) => {\n const sel = get(selectionAtom);\n return new Set(getSelectedRowIndices(sel));\n});\n\ntype ItemSelectionKeys = \"onSelect\" | \"selected\" | \"selectable\";\n\ntype DataCardProps = {\n children: ReactNode;\n className: string;\n style?: CSSProperties;\n} & Pick<ItemComponentProps, ItemSelectionKeys>;\n\nexport function DataCard<T = any>(props: DataCardProps) {\n /** A basic card that implements the data panel's selection behavior. */\n return h(\n \"div.data-card.data-panel-item\",\n {\n className: classNames(props.className, {\n selected: props.selected,\n selectable: props.selectable,\n }),\n onClick: props.onSelect,\n style: props.style,\n },\n props.children,\n );\n}\n\ntype DataCardInnerComponent<T> = (\n props: ItemComponentProps<T>,\n) => React.ReactNode;\n\nexport function createDataCard<T>(\n component: DataCardInnerComponent<T>,\n extraProps = {},\n) {\n return (props: ItemComponentProps<T>) => {\n const { selected, selectable, onSelect } = props;\n return h(\n DataCard,\n {\n selected,\n selectable,\n onSelect,\n ...extraProps,\n },\n h(component, props),\n );\n };\n}\n"],"names":["DataPanelToolbarStyle","splitDataProviderProps","DataViewRendererType","h","DataSheetProvider","ctx","dataProviderAtom","useSelector","autoLoadPagesAtom","useLoadControls","useState","useCallback","enableSelectionAtom","useMemo","classNames","NonIdealState","Classes","useDataPanelControls","Spinner","Icon","startAfterAtom","AnchorButton","ActionsToolbar","LoadProgressIndicator","useDataLoader","useRef","useEffect","atom","selection","selectionAtom","rowIndicesToRegions","getSelectedRowIndices","passThroughSet","interactionOptionsAtom","anchorRefAtom","buildDataViewSelection"],"mappings":";;;;;;;;;;;;;;;;;;;AAgFO,IAAK,0CAAAA,2BAAL;AACLA,yBAAA,UAAA,IAAW;AACXA,yBAAA,MAAA,IAAO;AACPA,yBAAA,SAAA,IAAU;AAIVA,yBAAA,UAAA,IAAW;AAPD,SAAAA;AAAA,GAAA,yBAAA,CAAA,CAAA;AA+FL,SAAS,UAAa,OAA0B;AACrD,QAAM,CAAC,eAAe,aAAa,IAAIC,4BAAuB;AAAA,IAC5D,GAAG;AAAA,IACH,UAAUC,aAAAA,qBAAqB;AAAA,EAAA,CAChC;AACD,SAAOC,iBAAAA;AAAAA,IACLC,KAAAA;AAAAA,IACA;AAAA,IACAD,iBAAAA,QAAE,mBAAwB,aAAa;AAAA,EAAA;AAE3C;AAaO,SAAS,kBAAqB;AAAA,EACnC;AAAA,EACA,UAAU,CAAA;AAAA,EACV,UAAU,CAAA;AAAA,EACV,WAAW;AA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B,UAAI,CAAC,wBAAwB,CAAC,KAAK,SAAU;AAC7C,UAAIA,aAAAA,qBAAqB,IAAI;AAC7B,wBAAkB,IAAIA,gCAAmB;AACzC,UAAI,CAAC,gBAAiB;AAAA,IACxB;AACA,UAAMgB,cAAY,IAAI,gBAAgB;AACtC,UAAM,YAAY,IAAIM,uBAAa;AACnC,UAAM,MAAMC,YAAAA;AAAAA,MACV;AAAA,MACA;AAAA,MACAP;AAAAA,MACA;AAAA,MACA;AAAA,IAAA;AAEF,QAAIC,UAAAA,eAAe,GAAG;AAAA,EACxB;AACF;AAEA,MAAM,yBAAyBF,MAAAA,KAAK,CAAC,QAAQ;AAC3C,QAAM,MAAM,IAAIE,uBAAa;AAC7B,SAAO,IAAI,IAAIE,kCAAsB,GAAG,CAAC;AAC3C,CAAC;AAUM,SAAS,SAAkB,OAAsB;AAEtD,SAAO5B,iBAAAA;AAAAA,IACL;AAAA,IACA;AAAA,MACE,WAAWW,oBAAAA,QAAW,MAAM,WAAW;AAAA,QACrC,UAAU,MAAM;AAAA,QAChB,YAAY,MAAM;AAAA,MAAA,CACnB;AAAA,MACD,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,IAAA;AAAA,IAEf,MAAM;AAAA,EAAA;AAEV;AAMO,SAAS,eACd,WACA,aAAa,IACb;AACA,SAAO,CAAC,UAAiC;AACvC,UAAM,EAAE,UAAU,YAAY,SAAA,IAAa;AAC3C,WAAOX,iBAAAA;AAAAA,MACL;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,MAELA,iBAAAA,QAAE,WAAW,KAAK;AAAA,IAAA;AAAA,EAEtB;AACF;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { ComponentType, CSSProperties, MouseEvent as ReactMouseEvent, ReactNode } from 'react';
2
2
  import { DataViewRendererType } from './provider';
3
3
  import { ViewControlsPresentation } from './components';
4
- import { DataViewSharedProps } from './types';
4
+ import { DataViewSharedProps, FetchDataOptions } from './types';
5
5
  export declare enum DataPanelToolbarStyle {
6
6
  BORDERED = "bordered",
7
7
  FADE = "fade",
@@ -95,6 +95,7 @@ export interface DataPanelProps<T = any> extends DataViewSharedProps<T> {
95
95
  export declare function DataPanel<T>(props: DataPanelProps<T>): import('react').FunctionComponentElement<import('./types').DataViewCoreProps<T> & {
96
96
  toaster?: import('@blueprintjs/core').OverlayToaster;
97
97
  initialData?: import('./types').InitialDataChunk<T> | T[] | undefined;
98
+ startAfter?: FetchDataOptions<T_1>["startAfter"];
98
99
  viewType?: DataViewRendererType;
99
100
  children?: React.ReactNode;
100
101
  } & {
@@ -110,7 +111,7 @@ export interface SelectModifiers {
110
111
  /** The card-list renderer. Assumes it is rendered inside a `DataSheetProvider`
111
112
  * (the `DataPanel` wrapper, or `DataView`). Exported so a shared-store
112
113
  * `DataView` can mount it directly alongside `_DataSheet`. */
113
- export declare function DataPanelRenderer<T>({ itemComponent, actions, filters, pageSize, filterDebounce, initialData, name, statusBar, toolbar, sidebar, contentFooter, autoLoadPages, scrollBody, className, toolbarStyle, viewControls, children, }: Omit<DataPanelProps<T>, "provider" | "fetchData" | "data" | "identity">): import('react').ReactElement<{
114
+ export declare function DataPanelRenderer<T>({ itemComponent, actions, filters, pageSize, filterDebounce, initialData, name, statusBar, toolbar, sidebar, contentFooter, autoLoadPages, scrollBody, pageLinks, className, toolbarStyle, viewControls, children, }: Omit<DataPanelProps<T>, "provider" | "fetchData" | "data" | "identity">): import('react').ReactElement<{
114
115
  className: string;
115
116
  }, string | import('react').JSXElementConstructor<any>>;
116
117
  type ItemSelectionKeys = "onSelect" | "selected" | "selectable";
@@ -1,6 +1,7 @@
1
1
  import h from "./data-panel.module.sass.js";
2
2
  import { useState, useCallback, useMemo, useRef, useEffect } from "react";
3
- import { NonIdealState, Classes, Spinner, Icon } from "@blueprintjs/core";
3
+ import { NonIdealState, Classes, Spinner, Icon, AnchorButton } from "@blueprintjs/core";
4
+ import { startAfterAtom } from "./provider/loader-state.js";
4
5
  import classNames from "classnames";
5
6
  import { atom } from "jotai";
6
7
  import { autoLoadPagesAtom, useLoadControls, useDataLoader } from "./postgrest-table/data-loaders.js";
@@ -46,6 +47,7 @@ function DataPanelRenderer({
46
47
  contentFooter,
47
48
  autoLoadPages,
48
49
  scrollBody,
50
+ pageLinks,
49
51
  className,
50
52
  toolbarStyle = "bordered",
51
53
  viewControls = "inline",
@@ -172,6 +174,38 @@ function DataPanelRenderer({
172
174
  { ref: sentinelRef },
173
175
  contentFooter ?? defaultFooter
174
176
  );
177
+ const startAfter = ctx.useValue(startAfterAtom);
178
+ const lastLoadedRow = useMemo(() => {
179
+ for (let i = data.length - 1; i >= 0; i--) {
180
+ if (data[i] != null) return data[i];
181
+ }
182
+ return null;
183
+ }, [data]);
184
+ const moreToCome = total == null || loadedCount < total;
185
+ let nextPageLink = null;
186
+ if (pageLinks != null && lastLoadedRow != null && moreToCome) {
187
+ nextPageLink = h(
188
+ "a.crawl-next-link",
189
+ {
190
+ href: pageLinks.after(lastLoadedRow),
191
+ rel: "next",
192
+ tabIndex: -1,
193
+ "aria-hidden": true
194
+ },
195
+ "Next page"
196
+ );
197
+ }
198
+ let viewStartNotice = null;
199
+ if (startAfter != null && pageLinks?.top != null) {
200
+ viewStartNotice = h("div.view-start-notice", [
201
+ h("span.view-start-text", `Continued after #${startAfter}`),
202
+ h(
203
+ AnchorButton,
204
+ { href: pageLinks.top, minimal: true, small: true, icon: "arrow-up" },
205
+ pageLinks.topLabel ?? "Return to top"
206
+ )
207
+ ]);
208
+ }
175
209
  let footer = null;
176
210
  let _statusBarContent = statusBar ?? h(DataPanelStatusBar);
177
211
  if (showStatusBar) {
@@ -214,7 +248,9 @@ function DataPanelRenderer({
214
248
  },
215
249
  [
216
250
  h("div.data-panel-body-content", [
251
+ viewStartNotice,
217
252
  emptyState ?? h(ScrollBody, { placeholders }, cards),
253
+ nextPageLink,
218
254
  _contentFooter
219
255
  ])
220
256
  ]