@macrostrat/data-sheet 4.4.0 → 4.5.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 (57) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/components/indicators/unified-filters.cjs +30 -10
  3. package/dist/components/indicators/unified-filters.cjs.map +1 -1
  4. package/dist/components/indicators/unified-filters.js +30 -10
  5. package/dist/components/indicators/unified-filters.js.map +1 -1
  6. package/dist/data-panel.cjs +3 -1
  7. package/dist/data-panel.cjs.map +1 -1
  8. package/dist/data-panel.d.ts +1 -1
  9. package/dist/data-panel.js +3 -1
  10. package/dist/data-panel.js.map +1 -1
  11. package/dist/data-panel.module.sass.cjs +25 -25
  12. package/dist/data-panel.module.sass.js +25 -25
  13. package/dist/data-sheet.cjs +3 -1
  14. package/dist/data-sheet.cjs.map +1 -1
  15. package/dist/data-sheet.css +37 -38
  16. package/dist/data-sheet.d.ts +1 -1
  17. package/dist/data-sheet.js +3 -1
  18. package/dist/data-sheet.js.map +1 -1
  19. package/dist/index.cjs +4 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.js +5 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/postgrest-table/data-loaders.cjs +67 -2
  24. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  25. package/dist/postgrest-table/data-loaders.d.ts +8 -1
  26. package/dist/postgrest-table/data-loaders.js +67 -2
  27. package/dist/postgrest-table/data-loaders.js.map +1 -1
  28. package/dist/provider/core.cjs +23 -2
  29. package/dist/provider/core.cjs.map +1 -1
  30. package/dist/provider/core.d.ts +2 -2
  31. package/dist/provider/core.js +23 -2
  32. package/dist/provider/core.js.map +1 -1
  33. package/dist/provider/distinct-values.cjs +65 -0
  34. package/dist/provider/distinct-values.cjs.map +1 -0
  35. package/dist/provider/distinct-values.d.ts +21 -0
  36. package/dist/provider/distinct-values.js +65 -0
  37. package/dist/provider/distinct-values.js.map +1 -0
  38. package/dist/provider/index.d.ts +1 -0
  39. package/dist/provider/table-data.cjs +21 -0
  40. package/dist/provider/table-data.cjs.map +1 -1
  41. package/dist/provider/table-data.d.ts +22 -0
  42. package/dist/provider/table-data.js +21 -0
  43. package/dist/provider/table-data.js.map +1 -1
  44. package/dist/types.cjs.map +1 -1
  45. package/dist/types.d.ts +27 -4
  46. package/dist/types.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/components/indicators/unified-filters.ts +40 -10
  49. package/src/data-panel.module.sass +2 -3
  50. package/src/data-panel.ts +3 -1
  51. package/src/data-sheet.ts +3 -1
  52. package/src/postgrest-table/data-loaders.ts +106 -3
  53. package/src/provider/core.ts +36 -3
  54. package/src/provider/distinct-values.ts +127 -0
  55. package/src/provider/index.ts +1 -0
  56. package/src/provider/table-data.ts +51 -0
  57. package/src/types.ts +33 -4
@@ -1 +1 @@
1
- {"version":3,"file":"data-panel.js","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}\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 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[] = [];\n data.forEach((row, i) => {\n if (row == null) return;\n const selected = enableSelection && selectedIndices.has(i);\n cards.push(\n 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\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 if (loadPending) {\n const pending = Math.min(Math.max(data.length - loadedCount, 0), 24);\n for (let i = 0; i < pending; i++) {\n cards.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\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 });\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 return h(\n \"div.data-panel\",\n { className: classNames(className, \"toolbar-style-\" + toolbarStyle) },\n [\n h(\"div.data-panel-main\", [\n loaderNode,\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 h(\n \"div.data-panel-body\",\n {\n onScroll,\n className: classNames({ \"is-scrolled\": scrolled }),\n },\n h(\"div.data-panel-body-content\", [\n emptyState ?? h(ScrollBody, cards),\n _contentFooter,\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. */\nfunction DefaultScrollBody({ children }: { children: ReactNode }) {\n return h(\"div.data-panel-list\", children);\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) {\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"],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ACxD;AAAA,IAAA;AAEF,QAAI,kBAAkB,IAAI,mBAAmB;AAC7C,QAAI,CAAC,iBAAiB;AAKpB,UAAI,CAAC,wBAAwB,CAAC,KAAK,SAAU;AAC7C,UAAI,qBAAqB,IAAI;AAC7B,wBAAkB,IAAI,mBAAmB;AACzC,UAAI,CAAC,gBAAiB;AAAA,IACxB;AACA,UAAM,YAAY,IAAI,gBAAgB;AACtC,UAAM,YAAY,IAAI,aAAa;AACnC,UAAM,MAAM;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAEF,QAAI,eAAe,GAAG;AAAA,EACxB;AACF;AAEA,MAAM,yBAAyB,KAAK,CAAC,QAAQ;AAC3C,QAAM,MAAM,IAAI,aAAa;AAC7B,SAAO,IAAI,IAAI,sBAAsB,GAAG,CAAC;AAC3C,CAAC;AAUM,SAAS,SAAkB,OAAsB;AAEtD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,WAAW,WAAW,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,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,MAEL,EAAE,WAAW,KAAK;AAAA,IAAA;AAAA,EAEtB;AACF;"}
1
+ {"version":3,"file":"data-panel.js","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}\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[] = [];\n data.forEach((row, i) => {\n if (row == null) return;\n const selected = enableSelection && selectedIndices.has(i);\n cards.push(\n 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\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 if (loadPending) {\n const pending = Math.min(Math.max(data.length - loadedCount, 0), 24);\n for (let i = 0; i < pending; i++) {\n cards.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\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 return h(\n \"div.data-panel\",\n { className: classNames(className, \"toolbar-style-\" + toolbarStyle) },\n [\n h(\"div.data-panel-main\", [\n loaderNode,\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 h(\n \"div.data-panel-body\",\n {\n onScroll,\n className: classNames({ \"is-scrolled\": scrolled }),\n },\n h(\"div.data-panel-body-content\", [\n emptyState ?? h(ScrollBody, cards),\n _contentFooter,\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. */\nfunction DefaultScrollBody({ children }: { children: ReactNode }) {\n return h(\"div.data-panel-list\", children);\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"],"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;AAyFL,SAAS,UAAa,OAA0B;AACrD,QAAM,CAAC,eAAe,aAAa,IAAI,uBAAuB;AAAA,IAC5D,GAAG;AAAA,IACH,UAAU,qBAAqB;AAAA,EAAA,CAChC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,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;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ChB,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,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,MAEL,EAAE,WAAW,KAAK;AAAA,IAAA;AAAA,EAEtB;AACF;"}
@@ -3,36 +3,36 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const h$1 = require("@macrostrat/hyper");
4
4
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
5
5
  const h__default = /* @__PURE__ */ _interopDefault(h$1);
6
- const sentinel = "_sentinel_s95k2_84";
7
- const spacer = "_spacer_s95k2_106";
8
- const selected = "_selected_s95k2_125";
9
- const selectable = "_selectable_s95k2_134";
6
+ const sentinel = "_sentinel_lybzx_84";
7
+ const spacer = "_spacer_lybzx_106";
8
+ const selected = "_selected_lybzx_125";
9
+ const selectable = "_selectable_lybzx_134";
10
10
  const styles = {
11
- "data-panel": "_data-panel_s95k2_5",
12
- "data-panel-main": "_data-panel-main_s95k2_19",
13
- "data-panel-sidebar-container": "_data-panel-sidebar-container_s95k2_25",
14
- "data-panel-body": "_data-panel-body_s95k2_34",
15
- "content-footer-holder": "_content-footer-holder_s95k2_54",
16
- "data-panel-item-container": "_data-panel-item-container_s95k2_62",
17
- "is-skeleton": "_is-skeleton_s95k2_62",
18
- "data-panel-skeleton": "_data-panel-skeleton_s95k2_66",
19
- "data-panel-list": "_data-panel-list_s95k2_72",
20
- "data-panel-item": "_data-panel-item_s95k2_62",
11
+ "data-panel": "_data-panel_lybzx_5",
12
+ "data-panel-main": "_data-panel-main_lybzx_19",
13
+ "data-panel-sidebar-container": "_data-panel-sidebar-container_lybzx_25",
14
+ "data-panel-body": "_data-panel-body_lybzx_34",
15
+ "content-footer-holder": "_content-footer-holder_lybzx_54",
16
+ "data-panel-item-container": "_data-panel-item-container_lybzx_62",
17
+ "is-skeleton": "_is-skeleton_lybzx_62",
18
+ "data-panel-skeleton": "_data-panel-skeleton_lybzx_66",
19
+ "data-panel-list": "_data-panel-list_lybzx_72",
20
+ "data-panel-item": "_data-panel-item_lybzx_62",
21
21
  sentinel,
22
- "data-panel-toolbar-content": "_data-panel-toolbar-content_s95k2_94",
23
- "data-panel-footer": "_data-panel-footer_s95k2_98",
24
- "data-panel-footer-content": "_data-panel-footer-content_s95k2_102",
22
+ "data-panel-toolbar-content": "_data-panel-toolbar-content_lybzx_94",
23
+ "data-panel-footer": "_data-panel-footer_lybzx_98",
24
+ "data-panel-footer-content": "_data-panel-footer-content_lybzx_102",
25
25
  spacer,
26
- "data-panel-status-bar": "_data-panel-status-bar_s95k2_110",
27
- "data-card": "_data-card_s95k2_116",
26
+ "data-panel-status-bar": "_data-panel-status-bar_lybzx_110",
27
+ "data-card": "_data-card_lybzx_116",
28
28
  selected,
29
29
  selectable,
30
- "toolbar-style-bordered": "_toolbar-style-bordered_s95k2_139",
31
- "data-panel-toolbar": "_data-panel-toolbar_s95k2_94",
32
- "toolbar-style-floating": "_toolbar-style-floating_s95k2_148",
33
- "toolbar-style-fade": "_toolbar-style-fade_s95k2_190",
34
- "is-scrolled": "_is-scrolled_s95k2_190",
35
- "collapsed-controls": "_collapsed-controls_s95k2_194"
30
+ "toolbar-style-bordered": "_toolbar-style-bordered_lybzx_139",
31
+ "data-panel-toolbar": "_data-panel-toolbar_lybzx_94",
32
+ "toolbar-style-floating": "_toolbar-style-floating_lybzx_148",
33
+ "toolbar-style-fade": "_toolbar-style-fade_lybzx_189",
34
+ "is-scrolled": "_is-scrolled_lybzx_189",
35
+ "collapsed-controls": "_collapsed-controls_lybzx_193"
36
36
  };
37
37
  let h = h__default.default.styled(styles);
38
38
  Object.assign(h, styles);
@@ -1,34 +1,34 @@
1
1
  import h$1 from "@macrostrat/hyper";
2
- const sentinel = "_sentinel_s95k2_84";
3
- const spacer = "_spacer_s95k2_106";
4
- const selected = "_selected_s95k2_125";
5
- const selectable = "_selectable_s95k2_134";
2
+ const sentinel = "_sentinel_lybzx_84";
3
+ const spacer = "_spacer_lybzx_106";
4
+ const selected = "_selected_lybzx_125";
5
+ const selectable = "_selectable_lybzx_134";
6
6
  const styles = {
7
- "data-panel": "_data-panel_s95k2_5",
8
- "data-panel-main": "_data-panel-main_s95k2_19",
9
- "data-panel-sidebar-container": "_data-panel-sidebar-container_s95k2_25",
10
- "data-panel-body": "_data-panel-body_s95k2_34",
11
- "content-footer-holder": "_content-footer-holder_s95k2_54",
12
- "data-panel-item-container": "_data-panel-item-container_s95k2_62",
13
- "is-skeleton": "_is-skeleton_s95k2_62",
14
- "data-panel-skeleton": "_data-panel-skeleton_s95k2_66",
15
- "data-panel-list": "_data-panel-list_s95k2_72",
16
- "data-panel-item": "_data-panel-item_s95k2_62",
7
+ "data-panel": "_data-panel_lybzx_5",
8
+ "data-panel-main": "_data-panel-main_lybzx_19",
9
+ "data-panel-sidebar-container": "_data-panel-sidebar-container_lybzx_25",
10
+ "data-panel-body": "_data-panel-body_lybzx_34",
11
+ "content-footer-holder": "_content-footer-holder_lybzx_54",
12
+ "data-panel-item-container": "_data-panel-item-container_lybzx_62",
13
+ "is-skeleton": "_is-skeleton_lybzx_62",
14
+ "data-panel-skeleton": "_data-panel-skeleton_lybzx_66",
15
+ "data-panel-list": "_data-panel-list_lybzx_72",
16
+ "data-panel-item": "_data-panel-item_lybzx_62",
17
17
  sentinel,
18
- "data-panel-toolbar-content": "_data-panel-toolbar-content_s95k2_94",
19
- "data-panel-footer": "_data-panel-footer_s95k2_98",
20
- "data-panel-footer-content": "_data-panel-footer-content_s95k2_102",
18
+ "data-panel-toolbar-content": "_data-panel-toolbar-content_lybzx_94",
19
+ "data-panel-footer": "_data-panel-footer_lybzx_98",
20
+ "data-panel-footer-content": "_data-panel-footer-content_lybzx_102",
21
21
  spacer,
22
- "data-panel-status-bar": "_data-panel-status-bar_s95k2_110",
23
- "data-card": "_data-card_s95k2_116",
22
+ "data-panel-status-bar": "_data-panel-status-bar_lybzx_110",
23
+ "data-card": "_data-card_lybzx_116",
24
24
  selected,
25
25
  selectable,
26
- "toolbar-style-bordered": "_toolbar-style-bordered_s95k2_139",
27
- "data-panel-toolbar": "_data-panel-toolbar_s95k2_94",
28
- "toolbar-style-floating": "_toolbar-style-floating_s95k2_148",
29
- "toolbar-style-fade": "_toolbar-style-fade_s95k2_190",
30
- "is-scrolled": "_is-scrolled_s95k2_190",
31
- "collapsed-controls": "_collapsed-controls_s95k2_194"
26
+ "toolbar-style-bordered": "_toolbar-style-bordered_lybzx_139",
27
+ "data-panel-toolbar": "_data-panel-toolbar_lybzx_94",
28
+ "toolbar-style-floating": "_toolbar-style-floating_lybzx_148",
29
+ "toolbar-style-fade": "_toolbar-style-fade_lybzx_189",
30
+ "is-scrolled": "_is-scrolled_lybzx_189",
31
+ "collapsed-controls": "_collapsed-controls_lybzx_193"
32
32
  };
33
33
  let h = h$1.styled(styles);
34
34
  Object.assign(h, styles);
@@ -55,6 +55,7 @@ function DataSheetRenderer({
55
55
  pageSize,
56
56
  fetchMode,
57
57
  filterDebounce,
58
+ initialData,
58
59
  onVisibleCellsChange,
59
60
  onUpdateData,
60
61
  onEdit,
@@ -336,7 +337,8 @@ function DataSheetRenderer({
336
337
  fetchData: activeProvider.fetchData,
337
338
  pageSize: isLocalProvider ? Math.max(localCount, 1) : pageSize,
338
339
  fetchMode: isLocalProvider ? void 0 : fetchMode,
339
- filterDebounce
340
+ filterDebounce,
341
+ initialData
340
342
  });
341
343
  }
342
344
  const showFilterBar = filters != null && filters.length > 0 || hasSortableOrFilterable;
@@ -1 +1 @@
1
- {"version":3,"file":"data-sheet.cjs","sources":["../src/data-sheet.ts"],"sourcesContent":["import { useHotkeys } from \"@blueprintjs/core\";\nimport {\n Column,\n RegionCardinality,\n RowHeaderCell,\n Table,\n} from \"@blueprintjs/table\";\nimport \"@blueprintjs/table/lib/css/table.css\";\nimport {\n CSSProperties,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n LoadProgressIndicator,\n ActionsToolbar,\n ActiveFiltersList,\n} from \"./components\";\nimport { basicCellRenderer, renderColumnHeaderCell } from \"./renderers\";\nimport h from \"./main.module.sass\";\nimport {\n columnSpecAtom,\n ctx,\n dataProviderAtom,\n dataRefreshTokenAtom,\n DataSheetProvider,\n DataViewRendererType,\n DEFAULT_ROW_STATUS_STYLES,\n FetchData,\n persistViaProvider,\n RowStatusStyles,\n splitDataProviderProps,\n storeAtom,\n tableActionsAtom,\n TableElementStatus,\n useSelector,\n useStoreAPI,\n VisibleCells,\n} from \"./provider\";\nimport { atom } from \"jotai\";\nimport { CellRendererDebugOverlay, tableHotkeysAtom } from \"./utils\";\nimport {\n clipboardActions,\n columnControlActions,\n createSaveAction,\n resetChangesAction,\n TableAction,\n TableActionContext,\n} from \"./actions\";\nimport {\n tableFooterAtom,\n useDataLoader,\n useScrollHandler,\n} from \"./postgrest-table\";\nimport {\n CellInteraction,\n DataSheetDensity,\n DataSheetProps,\n DataSheetRendererProps,\n FetchDataOptions,\n} from \"./types.ts\";\nimport { ErrorCallout } from \"@macrostrat/ui-components\";\n\n// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args\n\n// TODO: add a \"copy to selection\" tool (the little square in the bottom right corner of a cell)\n// This should copy the value of a cell (or a set of cells in the same row) downwards.\n\n/** Approximate column-header + scrollbar allowance, used to size the table to\n * its content in paged mode. */\nconst COLUMN_HEADER_HEIGHT = 34;\n\nexport function DataSheet<T>(props: DataSheetProps<T>) {\n const {\n data,\n columnSpec,\n columnSpecOptions,\n editable = true,\n enableColumnReordering = false,\n enableFocusedCell = false,\n defaultColumnWidth = 150,\n children,\n name,\n ...rest\n } = props;\n\n const [providerProps, rendererProps] = splitDataProviderProps<T>({\n ...props,\n viewType: DataViewRendererType.TABLE,\n });\n return h(\n DataSheetProvider<T>,\n providerProps,\n h(DataSheetRenderer<any>, rendererProps),\n );\n}\n\nconst verboseAtom = atom(false);\n\n/** The table (cell-grid) renderer. Assumes it is rendered inside a\n * `DataSheetProvider` (the `DataSheet` wrapper, or `DataView`). Exported so a\n * shared-store `DataView` can mount it directly alongside `_DataPanel`. */\nexport function DataSheetRenderer<T>({\n fetchData,\n provider,\n pageSize,\n fetchMode,\n filterDebounce,\n onVisibleCellsChange,\n onUpdateData,\n onEdit,\n onSave,\n updatedData: updatedDataProp,\n rowStatus: rowStatusProp,\n // Identity/canDeleteRows sync (was here) is now handled by the provider\n // (`DataSheetProviderInner`); still destructured so `identity`/`refreshToken`\n // don't leak into `...rest` (spread onto the Blueprint `Table` below).\n identity: _identity,\n deriveOverlay,\n refreshToken: _refreshToken,\n onDeleteRows,\n name,\n verbose = false,\n debug = false,\n enableFocusedCell,\n autoFocusEditor = true,\n cellInteraction,\n enableClipboard = true,\n density = DataSheetDensity.HIGH,\n selectionModes,\n actions,\n filters,\n columnHeaderCellRenderer,\n statusBar,\n rowStatusStyles,\n rowHeaderRenderer,\n children,\n ...tableProps\n}: DataSheetRendererProps<T>) {\n /**\n * @param data: The data to be displayed in the table\n * @param columnSpec: The specification for all columns in the table. If not provided, the column spec will be generated from the data.\n * @param columnSpecOptions: Options for generating a column spec from data\n */\n\n ctx.useSync(verboseAtom, verbose);\n\n const editable = useSelector((state) => state.editable);\n\n // The active data source is resolved in the wrapper (`DataSheet`) and held in\n // the provider layer; read it here rather than resolving per render.\n const {\n provider: activeProvider,\n isLocalProvider,\n localCount,\n } = ctx.useValue(dataProviderAtom);\n\n // When an explicit provider owns persistence, its methods drive the built-in\n // Save (batch: edits→saveRows, added→insertRow, deleted→deleteRows), then a\n // refresh. Otherwise the loose `onSave` handler is used.\n const bumpRefresh = ctx.useSet(dataRefreshTokenAtom);\n const providerSave = useMemo(() => {\n const p = provider;\n if (\n p == null ||\n (p.saveRows == null && p.deleteRows == null && p.insertRow == null)\n ) {\n return null;\n }\n return async (actionCtx: TableActionContext<T>) => {\n await persistViaProvider(p, actionCtx);\n bumpRefresh((v) => v + 1);\n };\n }, [provider, bumpRefresh]);\n const saveHandler = onSave ?? providerSave;\n\n // Sync table actions to atom. Consumer actions come first (they override a\n // built-in by reusing its id); the built-in column controls (sort/filter)\n // fill in the rest — so both the toolbar and the header dropdown source from\n // one registry. Built-ins self-gate (single sortable/filterable column).\n const _actions: TableAction[] = useMemo(() => {\n const _actions: TableAction[] = [];\n const add = (list: TableAction[]) => {\n for (const a of list) {\n if (!_actions.some((x) => x.id === a.id)) _actions.push(a);\n }\n };\n if (actions != null) add(actions);\n add(columnControlActions);\n if (enableClipboard) add(clipboardActions);\n // Save/reset last — they're the most significant actions — and present for\n // every cardinality (editable), so the toolbar stays mounted regardless of\n // selection.\n if (editable) {\n if (saveHandler != null) add([createSaveAction(saveHandler)]);\n add([resetChangesAction]);\n }\n return _actions;\n }, [actions, enableClipboard, editable, saveHandler]);\n\n /*** TODO: generalize this, probably shouldn't need 'set' */\n ctx.useSync(tableActionsAtom, _actions);\n const getHotkeys = ctx.useSet(tableHotkeysAtom);\n\n // This is quite hacky!\n const hotkeysConfig = useMemo(() => {\n return getHotkeys();\n }, [_actions]);\n\n const { handleKeyDown, handleKeyUp } = useHotkeys(hotkeysConfig);\n\n // For now, we only consider a single cell \"focused\" when we have one cell selected.\n // Multi-cell selections have a different set of \"bulk\" actions.\n const selectedRegions = useSelector<T>((state) => state.selection ?? []);\n\n const data = useSelector((state) => state.data);\n\n const rowStatus = useSelector((state) => state.rowStatus);\n\n const focusedCell = useSelector((state) => state.focusedCell);\n\n const ref = useSelector((state) => state.tableRef);\n\n const columnSpec = useSelector((state) => state.columnSpec);\n\n // A sparse array to hold updates\n // TODO: create a \"changeset\" concept to facilitate undo/redo\n const updatedData = useSelector((state) => state.updatedData);\n\n const onSelection = useSelector((state) => state.onSelection);\n\n const storeAPI = useStoreAPI<T>();\n\n const onScroll = useScrollHandler();\n const _onVisibleCellsChange = useCallback(\n (visibleCells: VisibleCells) => {\n onScroll(visibleCells);\n onVisibleCellsChange?.(visibleCells);\n },\n [onVisibleCellsChange, onScroll],\n );\n\n useEffect(() => {\n if (!verbose) return;\n console.log(\"Updated data\", updatedData);\n }, [updatedData]);\n\n useEffect(() => {\n onUpdateData?.(updatedData, data);\n }, [onUpdateData, data, updatedData]);\n\n useEffect(() => {\n if (!verbose) return;\n console.log(\"Selected regions\", selectedRegions);\n }, [selectedRegions]);\n\n const tableElementRef = useRef<HTMLElement>(null);\n useEffect(() => {\n // Return the focus to the table\n tableElementRef.current?.focus();\n }, [focusedCell]);\n\n const columnWidths = ctx.useValue(columnWidthsAtom);\n\n // When filters are active, only show matching rows\n const filteredRowIndices = useSelector((state) => state.filteredRowIndices);\n const totalRows = Math.max(updatedData.length, data.length);\n const numRows =\n filteredRowIndices != null ? filteredRowIndices.length : totalRows;\n\n let className = `${density}-density`;\n\n const { rowHeight, style } = styleParamsForDensity(density);\n\n // In paged mode the row count is small and fixed, so let the table size to\n // its content (header + rows) instead of filling the viewport.\n const footerInfo = ctx.useValue(tableFooterAtom);\n let holderStyle: CSSProperties | undefined = undefined;\n if (footerInfo.mode === \"paged\") {\n holderStyle = {\n flex: \"0 0 auto\" as const,\n height: numRows * rowHeight + COLUMN_HEADER_HEIGHT,\n };\n }\n\n const onColumnsReordered = useSelector((state) => state.onColumnsReordered);\n // Whether table-level column drag-reordering is enabled. Held in the store\n // (set from the `enableColumnReordering` prop by the provider); it must reach\n // the Blueprint `Table` — the `onColumnsReordered` handler alone doesn't turn\n // on the drag affordance.\n const enableColumnReordering = useSelector(\n (state) => state.enableColumnReordering,\n );\n\n // Auto-detect if any columns have sortable/filterable set.\n // If so and no explicit columnHeaderCellRenderer was provided,\n // use the built-in client-side sort/filter header.\n const hasSortableOrFilterable = useMemo(\n () =>\n columnSpec.some(\n (col) =>\n col.sortable ||\n col.filterable ||\n (Array.isArray(col.filters) && col.filters.length > 0),\n ),\n [columnSpec],\n );\n\n const columnSorts = useSelector((state) => state.columnSorts);\n const activeFilters = useSelector((state) => state.activeFilters);\n\n // Cell activation mode, defaulting from the legacy `autoFocusEditor` boolean\n // so existing consumers are unaffected. Synced into the store so the cell\n // renderer, editors, and key handlers all read it consistently.\n const cellInteractionMode: CellInteraction =\n cellInteraction ?? (autoFocusEditor ? \"auto\" : \"manual\");\n\n const storeState = storeAPI;\n useEffect(() => {\n storeState.setState({ cellInteraction: cellInteractionMode });\n }, [storeState, cellInteractionMode]);\n\n useEffect(() => {\n // Give the store a handle to the focusable holder so editors can return\n // keyboard focus to the table when the cursor leaves them.\n storeState.setState({ tableElement: tableElementRef.current });\n }, [storeState]);\n\n useEffect(() => {\n storeState.setState({ onEdit });\n }, [storeState, onEdit]);\n\n useEffect(() => {\n // Controlled overlay: mirror the caller's edited state into the store as\n // the source of truth. Optimistic in-table edits are superseded on the\n // next render when the caller passes an updated value back. When the caller\n // controls it, the loader-boundary identity remap steps aside.\n const controlled =\n updatedDataProp !== undefined ||\n rowStatusProp !== undefined ||\n deriveOverlay != null;\n const patch: Record<string, unknown> = { controlledOverlay: controlled };\n if (updatedDataProp !== undefined) patch.updatedData = updatedDataProp;\n if (rowStatusProp !== undefined) patch.rowStatus = rowStatusProp;\n storeState.setState(patch);\n }, [storeState, updatedDataProp, rowStatusProp, deriveOverlay]);\n\n // Derived controlled overlay: the library owns the loaded rows, so it runs\n // the consumer's `deriveOverlay(rows)` here and pushes the result. Re-derives\n // when the rows load/change or the function's identity changes (close it over\n // your external edit state). The `controlledOverlay` flag above suppresses the\n // loader-boundary identity remap so this derivation is authoritative.\n useEffect(() => {\n if (deriveOverlay == null) return;\n const overlay = deriveOverlay(data);\n storeState.setState({\n updatedData: overlay.updatedData,\n rowStatus: overlay.rowStatus,\n });\n }, [deriveOverlay, data, storeState]);\n\n // Function `columnSpec` derivation is hoisted to the provider\n // (`DataSheetProviderInner`), shared by both renderers.\n\n // Identity and canDeleteRows sync are hoisted to the provider\n // (`DataSheetProviderInner`), shared with `_DataPanel` — both depend only on\n // the resolved data provider, not any sheet-specific state.\n\n // Merge consumer `rowStatusStyles` over the built-in defaults and hand the\n // result to the store, where the cell renderer and row-header renderer read\n // it. Merged (not replaced) so overriding one status doesn't drop the rest.\n const mergedRowStatusStyles = useMemo<RowStatusStyles>(\n () => ({ ...DEFAULT_ROW_STATUS_STYLES, ...rowStatusStyles }),\n [rowStatusStyles],\n );\n useEffect(() => {\n storeState.setState({ rowStatusStyles: mergedRowStatusStyles });\n }, [storeState, mergedRowStatusStyles]);\n\n const realizedColumns = useMemo(() => {\n return columnSpec.map((col, colIndex) => {\n let fn =\n col.headerRenderer ??\n columnHeaderCellRenderer ??\n renderColumnHeaderCell;\n let activeSort: any = null;\n let activeFilter: any = null;\n if (col.sortable) {\n activeSort = columnSorts?.find((s) => s.key === col.key);\n }\n // The active filter for this column is whichever active filter targets\n // it (a rich `col.filters` filter or the generic operator filter) — match\n // by columnKey rather than a fixed id.\n for (const entry of activeFilters?.values() ?? []) {\n if ((entry as any)?.filter?.columnKey === col.key) {\n activeFilter = entry;\n break;\n }\n }\n\n const _columnHeaderCellRenderer: any = (colIndex) => {\n return fn(\n {\n col,\n colIndex,\n activeSort,\n activeFilter,\n },\n colIndex,\n );\n };\n\n return h(Column, {\n id: col.key,\n name: col.name,\n columnHeaderCellRenderer: _columnHeaderCellRenderer as any,\n cellRenderer: (rowIndex) => {\n const state = storeAPI.getState();\n return basicCellRenderer<T>(\n rowIndex,\n colIndex,\n col,\n state,\n filteredRowIndices,\n );\n },\n });\n });\n }, [\n columnSpec,\n columnSorts,\n activeFilters,\n storeAPI,\n filteredRowIndices,\n columnHeaderCellRenderer,\n ]);\n\n const onColumnWidthChanged = useSelector(\n (state) => state.onColumnWidthChanged,\n );\n\n const rowHeaderCellRenderer = useCallback(\n (rowIndex: number) => {\n let dataRowIndex = rowIndex;\n if (filteredRowIndices != null) {\n dataRowIndex = filteredRowIndices[rowIndex] ?? rowIndex;\n }\n const statusVal = rowStatus[dataRowIndex];\n let style: CSSProperties | undefined;\n if (statusVal != null) {\n style = mergedRowStatusStyles[statusVal]?.headerStyle;\n }\n\n const defaultLabel = `${dataRowIndex + 1}`;\n // A custom renderer supplies the header's *name* content (a group-key\n // label, an omit indicator, …); a nullish return keeps the default\n // 1-based label. Either way the node is wrapped in a `RowHeaderCell` so\n // status styling and the row index are always applied — the renderer is\n // not responsible for producing the whole cell.\n let name: ReactNode = defaultLabel;\n if (rowHeaderRenderer != null) {\n const custom = rowHeaderRenderer({\n rowIndex: dataRowIndex,\n visibleIndex: rowIndex,\n row: data[dataRowIndex] ?? updatedData[dataRowIndex],\n status: statusVal,\n isDeleted: statusVal === TableElementStatus.DELETED,\n defaultLabel,\n });\n if (custom != null) name = custom;\n }\n\n return h(RowHeaderCell, {\n enableRowReordering: false,\n index: rowIndex,\n name,\n style,\n });\n },\n [\n rowStatus,\n filteredRowIndices,\n mergedRowStatusStyles,\n rowHeaderRenderer,\n data,\n updatedData,\n ],\n );\n\n // Done with hooks!\n /** Guard for unacceptable state combinations:\n * editable = true requires selectionModes to include cells, else the user cannot select a cell to edit.\n * TODO: make this an impossible state to enter.\n */\n if (\n editable &&\n selectionModes &&\n !selectionModes.includes(RegionCardinality.CELLS)\n ) {\n return h(ErrorCallout, {\n title: \"Invalid selection mode\",\n description: \"Editable sheet requires cell selection\",\n });\n }\n\n // TODO: hoist this\n let _selectionModes = selectionModes;\n if (\n editable &&\n _selectionModes != null &&\n !_selectionModes.includes(RegionCardinality.CELLS)\n ) {\n _selectionModes = [..._selectionModes, RegionCardinality.CELLS];\n // Ensure selection mode includes \"cells\"\n }\n\n const cellRendererDependencies = [\n data,\n updatedData,\n focusedCell,\n rowStatus,\n filteredRowIndices,\n ];\n\n // Drive the table from the active provider's `fetchData`. A local (in-memory)\n // provider loads the whole array at once; a remote one uses the `pageSize` /\n // `fetchMode` props and shows load progress.\n let _showLoadProgress: boolean = false;\n let dataLoader: ReactNode = null;\n if (activeProvider != null) {\n _showLoadProgress = !isLocalProvider;\n // A local (in-memory) source loads all its rows in one page; its count\n // rides on the resolved provider (`localCount`), so `_DataSheet` no longer\n // takes a `data` prop — live rows come only from the store.\n dataLoader = h(_DataLoaderManager, {\n key: \"__data_loader\",\n fetchData: activeProvider.fetchData,\n pageSize: isLocalProvider ? Math.max(localCount, 1) : pageSize,\n fetchMode: isLocalProvider ? undefined : fetchMode,\n filterDebounce,\n });\n }\n const showFilterBar =\n (filters != null && filters.length > 0) || hasSortableOrFilterable;\n\n let filterStatus: ReactNode = null;\n if (showFilterBar) {\n filterStatus = h(ActiveFiltersList, { filters: filters ?? [] });\n }\n\n return h(\"div.data-sheet-container\", { className, style }, [\n // The actions/tools toolbar (selection-modal). Table-scoped controls like\n // scroll-to-row / full-text search live here as ordinary actions.\n h(ActionsToolbar, { actions: _actions }),\n dataLoader,\n children,\n h(\n \"div.data-sheet-holder\",\n {\n tabIndex: 0,\n onKeyDown: handleKeyDown,\n onKeyUp: handleKeyUp,\n ref: tableElementRef,\n style: holderStyle,\n },\n h(\n Table as any, // Some sort of hyperscript type error\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n enableColumnReordering,\n onColumnsReordered,\n focusedCell,\n selectedRegions,\n defaultRowHeight: rowHeight,\n columnWidths,\n onColumnWidthChanged,\n onSelection,\n /** TODO: we could enable this if we had a use-case */\n enableRowReordering: false,\n enableRowResizing: false,\n // The cell renderer is memoized internally based on these data dependencies\n cellRendererDependencies,\n onVisibleCellsChange: _onVisibleCellsChange,\n rowHeaderCellRenderer,\n selectionModes: _selectionModes,\n ...tableProps,\n getCellClipboardData: null,\n },\n realizedColumns,\n ),\n ),\n h(\"div.status-bar\", [\n filterStatus,\n statusBar,\n h(\"div.spacer\"),\n h.if(_showLoadProgress)(LoadProgressIndicator),\n ]),\n h.if(debug)(CellRendererDebugOverlay, {\n cellRendererDependencies,\n names: [\n \"data\",\n \"updatedData\",\n \"focusedCell\",\n \"rowStatus\",\n \"filteredRowIndices\",\n ],\n }),\n ]);\n}\n\nconst EMPTY_MAP = new Map<string, number>();\n\nconst columnWidthsIndexAtom = atom(\n (get) => get(storeAtom)?.columnWidthsIndex ?? EMPTY_MAP,\n);\nconst defaultColumnWidthAtom = atom(\n (get) => get(storeAtom)?.defaultColumnWidth ?? 150,\n);\n\nconst columnWidthsAtom = atom((get) => {\n const ix = get(columnWidthsIndexAtom);\n return get(columnSpecAtom).map(\n (col) => ix.get(col.key) ?? col.width ?? get(defaultColumnWidthAtom),\n );\n});\n\nfunction styleParamsForDensity(density: DataSheetDensity): {\n rowHeight: number;\n style: Record<string, string>;\n} {\n switch (density) {\n case DataSheetDensity.MEDIUM:\n return {\n rowHeight: 24,\n style: {\n \"--data-sheet-row-height\": \"24px\",\n \"--data-sheet-font-size\": \"14px\",\n },\n };\n case DataSheetDensity.LOW:\n return {\n rowHeight: 30,\n style: {\n \"--data-sheet-row-height\": \"30px\",\n \"--data-sheet-font-size\": \"18px\",\n },\n };\n case DataSheetDensity.HIGH:\n default:\n return {\n rowHeight: 20,\n style: {\n \"--data-sheet-row-height\": \"20px\",\n \"--data-sheet-font-size\": \"12px\",\n },\n };\n }\n}\n\n/** Convenience component: runs `useChunkLoader` from inside a `DataSheet`.\n * Render as a child of `DataSheet` (it renders nothing itself). */\nfunction _DataLoaderManager<T = any>({\n fetchData,\n ...rest\n}: {\n fetchData: FetchData<T>;\n} & FetchDataOptions) {\n useDataLoader(fetchData, rest);\n return null;\n}\n"],"names":["splitDataProviderProps","DataViewRendererType","h","DataSheetProvider","atom","DataSheetDensity","ctx","useSelector","dataProviderAtom","dataRefreshTokenAtom","useMemo","persistViaProvider","_actions","columnControlActions","clipboardActions","createSaveAction","resetChangesAction","tableActionsAtom","tableHotkeysAtom","useHotkeys","useStoreAPI","useScrollHandler","useCallback","useEffect","useRef","tableFooterAtom","activeFilters","DEFAULT_ROW_STATUS_STYLES","renderColumnHeaderCell","colIndex","Column","basicCellRenderer","style","name","TableElementStatus","RowHeaderCell","RegionCardinality","ErrorCallout","ActiveFiltersList","ActionsToolbar","Table","LoadProgressIndicator","CellRendererDebugOverlay","storeAtom","columnSpecAtom","useDataLoader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAM,uBAAuB;AAEtB,SAAS,UAAa,OAA0B;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,yBAAyB;AAAA,IACzB,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,CAAC,eAAe,aAAa,IAAIA,4BAA0B;AAAA,IAC/D,GAAG;AAAA,IACH,UAAUC,aAAAA,qBAAqB;AAAA,EAAA,CAChC;AACD,SAAOC,YAAAA;AAAAA,IACLC,KAAAA;AAAAA,IACA;AAAA,IACAD,YAAAA,QAAE,mBAAwB,aAAa;AAAA,EAAA;AAE3C;AAEA,MAAM,cAAcE,MAAAA,KAAK,KAAK;AAKvB,SAAS,kBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,WAAW;AAAA;AAAA;AAAA;AAAA,EAIX,UAAU;AAAA,EACV;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA,kBAAkB;AAAA,EAClB,UAAUC,QAAAA,iBAAiB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA8B;AAO5BC,WAAI,QAAQ,aAAa,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BAAsB;AACjD;AAEA,MAAM,mBAAmBvC,MAAAA,KAAK,CAAC,QAAQ;AACrC,QAAM,KAAK,IAAI,qBAAqB;AACpC,SAAO,IAAIwC,KAAAA,cAAc,EAAE;AAAA,IACzB,CAAC,QAAQ,GAAG,IAAI,IAAI,GAAG,KAAK,IAAI,SAAS,IAAI,sBAAsB;AAAA,EAAA;AAEvE,CAAC;AAED,SAAS,sBAAsB,SAG7B;AACA,UAAQ,SAAA;AAAA,IACN,KAAKvC,QAAAA,iBAAiB;AACpB,aAAO;AAAA,QACL,WAAW;AAAA,QACX,OAAO;AAAA,UACL,2BAA2B;AAAA,UAC3B,0BAA0B;AAAA,QAAA;AAAA,MAC5B;AAAA,IAEJ,KAAKA,QAAAA,iBAAiB;AACpB,aAAO;AAAA,QACL,WAAW;AAAA,QACX,OAAO;AAAA,UACL,2BAA2B;AAAA,UAC3B,0BAA0B;AAAA,QAAA;AAAA,MAC5B;AAAA,IAEJ,KAAKA,QAAAA,iBAAiB;AAAA,IACtB;AACE,aAAO;AAAA,QACL,WAAW;AAAA,QACX,OAAO;AAAA,UACL,2BAA2B;AAAA,UAC3B,0BAA0B;AAAA,QAAA;AAAA,MAC5B;AAAA,EACF;AAEN;AAIA,SAAS,mBAA4B;AAAA,EACnC;AAAA,EACA,GAAG;AACL,GAEsB;AACpBwC,cAAAA,cAAc,WAAW,IAAI;AAC7B,SAAO;AACT;;;"}
1
+ {"version":3,"file":"data-sheet.cjs","sources":["../src/data-sheet.ts"],"sourcesContent":["import { useHotkeys } from \"@blueprintjs/core\";\nimport {\n Column,\n RegionCardinality,\n RowHeaderCell,\n Table,\n} from \"@blueprintjs/table\";\nimport \"@blueprintjs/table/lib/css/table.css\";\nimport {\n CSSProperties,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n LoadProgressIndicator,\n ActionsToolbar,\n ActiveFiltersList,\n} from \"./components\";\nimport { basicCellRenderer, renderColumnHeaderCell } from \"./renderers\";\nimport h from \"./main.module.sass\";\nimport {\n columnSpecAtom,\n ctx,\n dataProviderAtom,\n dataRefreshTokenAtom,\n DataSheetProvider,\n DataViewRendererType,\n DEFAULT_ROW_STATUS_STYLES,\n FetchData,\n persistViaProvider,\n RowStatusStyles,\n splitDataProviderProps,\n storeAtom,\n tableActionsAtom,\n TableElementStatus,\n useSelector,\n useStoreAPI,\n VisibleCells,\n} from \"./provider\";\nimport { atom } from \"jotai\";\nimport { CellRendererDebugOverlay, tableHotkeysAtom } from \"./utils\";\nimport {\n clipboardActions,\n columnControlActions,\n createSaveAction,\n resetChangesAction,\n TableAction,\n TableActionContext,\n} from \"./actions\";\nimport {\n tableFooterAtom,\n useDataLoader,\n useScrollHandler,\n} from \"./postgrest-table\";\nimport {\n CellInteraction,\n DataSheetDensity,\n DataSheetProps,\n DataSheetRendererProps,\n FetchDataOptions,\n} from \"./types.ts\";\nimport { ErrorCallout } from \"@macrostrat/ui-components\";\n\n// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args\n\n// TODO: add a \"copy to selection\" tool (the little square in the bottom right corner of a cell)\n// This should copy the value of a cell (or a set of cells in the same row) downwards.\n\n/** Approximate column-header + scrollbar allowance, used to size the table to\n * its content in paged mode. */\nconst COLUMN_HEADER_HEIGHT = 34;\n\nexport function DataSheet<T>(props: DataSheetProps<T>) {\n const {\n data,\n columnSpec,\n columnSpecOptions,\n editable = true,\n enableColumnReordering = false,\n enableFocusedCell = false,\n defaultColumnWidth = 150,\n children,\n name,\n ...rest\n } = props;\n\n const [providerProps, rendererProps] = splitDataProviderProps<T>({\n ...props,\n viewType: DataViewRendererType.TABLE,\n });\n return h(\n DataSheetProvider<T>,\n providerProps,\n h(DataSheetRenderer<any>, rendererProps),\n );\n}\n\nconst verboseAtom = atom(false);\n\n/** The table (cell-grid) renderer. Assumes it is rendered inside a\n * `DataSheetProvider` (the `DataSheet` wrapper, or `DataView`). Exported so a\n * shared-store `DataView` can mount it directly alongside `_DataPanel`. */\nexport function DataSheetRenderer<T>({\n fetchData,\n provider,\n pageSize,\n fetchMode,\n filterDebounce,\n initialData,\n onVisibleCellsChange,\n onUpdateData,\n onEdit,\n onSave,\n updatedData: updatedDataProp,\n rowStatus: rowStatusProp,\n // Identity/canDeleteRows sync (was here) is now handled by the provider\n // (`DataSheetProviderInner`); still destructured so `identity`/`refreshToken`\n // don't leak into `...rest` (spread onto the Blueprint `Table` below).\n identity: _identity,\n deriveOverlay,\n refreshToken: _refreshToken,\n onDeleteRows,\n name,\n verbose = false,\n debug = false,\n enableFocusedCell,\n autoFocusEditor = true,\n cellInteraction,\n enableClipboard = true,\n density = DataSheetDensity.HIGH,\n selectionModes,\n actions,\n filters,\n columnHeaderCellRenderer,\n statusBar,\n rowStatusStyles,\n rowHeaderRenderer,\n children,\n ...tableProps\n}: DataSheetRendererProps<T>) {\n /**\n * @param data: The data to be displayed in the table\n * @param columnSpec: The specification for all columns in the table. If not provided, the column spec will be generated from the data.\n * @param columnSpecOptions: Options for generating a column spec from data\n */\n\n ctx.useSync(verboseAtom, verbose);\n\n const editable = useSelector((state) => state.editable);\n\n // The active data source is resolved in the wrapper (`DataSheet`) and held in\n // the provider layer; read it here rather than resolving per render.\n const {\n provider: activeProvider,\n isLocalProvider,\n localCount,\n } = ctx.useValue(dataProviderAtom);\n\n // When an explicit provider owns persistence, its methods drive the built-in\n // Save (batch: edits→saveRows, added→insertRow, deleted→deleteRows), then a\n // refresh. Otherwise the loose `onSave` handler is used.\n const bumpRefresh = ctx.useSet(dataRefreshTokenAtom);\n const providerSave = useMemo(() => {\n const p = provider;\n if (\n p == null ||\n (p.saveRows == null && p.deleteRows == null && p.insertRow == null)\n ) {\n return null;\n }\n return async (actionCtx: TableActionContext<T>) => {\n await persistViaProvider(p, actionCtx);\n bumpRefresh((v) => v + 1);\n };\n }, [provider, bumpRefresh]);\n const saveHandler = onSave ?? providerSave;\n\n // Sync table actions to atom. Consumer actions come first (they override a\n // built-in by reusing its id); the built-in column controls (sort/filter)\n // fill in the rest — so both the toolbar and the header dropdown source from\n // one registry. Built-ins self-gate (single sortable/filterable column).\n const _actions: TableAction[] = useMemo(() => {\n const _actions: TableAction[] = [];\n const add = (list: TableAction[]) => {\n for (const a of list) {\n if (!_actions.some((x) => x.id === a.id)) _actions.push(a);\n }\n };\n if (actions != null) add(actions);\n add(columnControlActions);\n if (enableClipboard) add(clipboardActions);\n // Save/reset last — they're the most significant actions — and present for\n // every cardinality (editable), so the toolbar stays mounted regardless of\n // selection.\n if (editable) {\n if (saveHandler != null) add([createSaveAction(saveHandler)]);\n add([resetChangesAction]);\n }\n return _actions;\n }, [actions, enableClipboard, editable, saveHandler]);\n\n /*** TODO: generalize this, probably shouldn't need 'set' */\n ctx.useSync(tableActionsAtom, _actions);\n const getHotkeys = ctx.useSet(tableHotkeysAtom);\n\n // This is quite hacky!\n const hotkeysConfig = useMemo(() => {\n return getHotkeys();\n }, [_actions]);\n\n const { handleKeyDown, handleKeyUp } = useHotkeys(hotkeysConfig);\n\n // For now, we only consider a single cell \"focused\" when we have one cell selected.\n // Multi-cell selections have a different set of \"bulk\" actions.\n const selectedRegions = useSelector<T>((state) => state.selection ?? []);\n\n const data = useSelector((state) => state.data);\n\n const rowStatus = useSelector((state) => state.rowStatus);\n\n const focusedCell = useSelector((state) => state.focusedCell);\n\n const ref = useSelector((state) => state.tableRef);\n\n const columnSpec = useSelector((state) => state.columnSpec);\n\n // A sparse array to hold updates\n // TODO: create a \"changeset\" concept to facilitate undo/redo\n const updatedData = useSelector((state) => state.updatedData);\n\n const onSelection = useSelector((state) => state.onSelection);\n\n const storeAPI = useStoreAPI<T>();\n\n const onScroll = useScrollHandler();\n const _onVisibleCellsChange = useCallback(\n (visibleCells: VisibleCells) => {\n onScroll(visibleCells);\n onVisibleCellsChange?.(visibleCells);\n },\n [onVisibleCellsChange, onScroll],\n );\n\n useEffect(() => {\n if (!verbose) return;\n console.log(\"Updated data\", updatedData);\n }, [updatedData]);\n\n useEffect(() => {\n onUpdateData?.(updatedData, data);\n }, [onUpdateData, data, updatedData]);\n\n useEffect(() => {\n if (!verbose) return;\n console.log(\"Selected regions\", selectedRegions);\n }, [selectedRegions]);\n\n const tableElementRef = useRef<HTMLElement>(null);\n useEffect(() => {\n // Return the focus to the table\n tableElementRef.current?.focus();\n }, [focusedCell]);\n\n const columnWidths = ctx.useValue(columnWidthsAtom);\n\n // When filters are active, only show matching rows\n const filteredRowIndices = useSelector((state) => state.filteredRowIndices);\n const totalRows = Math.max(updatedData.length, data.length);\n const numRows =\n filteredRowIndices != null ? filteredRowIndices.length : totalRows;\n\n let className = `${density}-density`;\n\n const { rowHeight, style } = styleParamsForDensity(density);\n\n // In paged mode the row count is small and fixed, so let the table size to\n // its content (header + rows) instead of filling the viewport.\n const footerInfo = ctx.useValue(tableFooterAtom);\n let holderStyle: CSSProperties | undefined = undefined;\n if (footerInfo.mode === \"paged\") {\n holderStyle = {\n flex: \"0 0 auto\" as const,\n height: numRows * rowHeight + COLUMN_HEADER_HEIGHT,\n };\n }\n\n const onColumnsReordered = useSelector((state) => state.onColumnsReordered);\n // Whether table-level column drag-reordering is enabled. Held in the store\n // (set from the `enableColumnReordering` prop by the provider); it must reach\n // the Blueprint `Table` — the `onColumnsReordered` handler alone doesn't turn\n // on the drag affordance.\n const enableColumnReordering = useSelector(\n (state) => state.enableColumnReordering,\n );\n\n // Auto-detect if any columns have sortable/filterable set.\n // If so and no explicit columnHeaderCellRenderer was provided,\n // use the built-in client-side sort/filter header.\n const hasSortableOrFilterable = useMemo(\n () =>\n columnSpec.some(\n (col) =>\n col.sortable ||\n col.filterable ||\n (Array.isArray(col.filters) && col.filters.length > 0),\n ),\n [columnSpec],\n );\n\n const columnSorts = useSelector((state) => state.columnSorts);\n const activeFilters = useSelector((state) => state.activeFilters);\n\n // Cell activation mode, defaulting from the legacy `autoFocusEditor` boolean\n // so existing consumers are unaffected. Synced into the store so the cell\n // renderer, editors, and key handlers all read it consistently.\n const cellInteractionMode: CellInteraction =\n cellInteraction ?? (autoFocusEditor ? \"auto\" : \"manual\");\n\n const storeState = storeAPI;\n useEffect(() => {\n storeState.setState({ cellInteraction: cellInteractionMode });\n }, [storeState, cellInteractionMode]);\n\n useEffect(() => {\n // Give the store a handle to the focusable holder so editors can return\n // keyboard focus to the table when the cursor leaves them.\n storeState.setState({ tableElement: tableElementRef.current });\n }, [storeState]);\n\n useEffect(() => {\n storeState.setState({ onEdit });\n }, [storeState, onEdit]);\n\n useEffect(() => {\n // Controlled overlay: mirror the caller's edited state into the store as\n // the source of truth. Optimistic in-table edits are superseded on the\n // next render when the caller passes an updated value back. When the caller\n // controls it, the loader-boundary identity remap steps aside.\n const controlled =\n updatedDataProp !== undefined ||\n rowStatusProp !== undefined ||\n deriveOverlay != null;\n const patch: Record<string, unknown> = { controlledOverlay: controlled };\n if (updatedDataProp !== undefined) patch.updatedData = updatedDataProp;\n if (rowStatusProp !== undefined) patch.rowStatus = rowStatusProp;\n storeState.setState(patch);\n }, [storeState, updatedDataProp, rowStatusProp, deriveOverlay]);\n\n // Derived controlled overlay: the library owns the loaded rows, so it runs\n // the consumer's `deriveOverlay(rows)` here and pushes the result. Re-derives\n // when the rows load/change or the function's identity changes (close it over\n // your external edit state). The `controlledOverlay` flag above suppresses the\n // loader-boundary identity remap so this derivation is authoritative.\n useEffect(() => {\n if (deriveOverlay == null) return;\n const overlay = deriveOverlay(data);\n storeState.setState({\n updatedData: overlay.updatedData,\n rowStatus: overlay.rowStatus,\n });\n }, [deriveOverlay, data, storeState]);\n\n // Function `columnSpec` derivation is hoisted to the provider\n // (`DataSheetProviderInner`), shared by both renderers.\n\n // Identity and canDeleteRows sync are hoisted to the provider\n // (`DataSheetProviderInner`), shared with `_DataPanel` — both depend only on\n // the resolved data provider, not any sheet-specific state.\n\n // Merge consumer `rowStatusStyles` over the built-in defaults and hand the\n // result to the store, where the cell renderer and row-header renderer read\n // it. Merged (not replaced) so overriding one status doesn't drop the rest.\n const mergedRowStatusStyles = useMemo<RowStatusStyles>(\n () => ({ ...DEFAULT_ROW_STATUS_STYLES, ...rowStatusStyles }),\n [rowStatusStyles],\n );\n useEffect(() => {\n storeState.setState({ rowStatusStyles: mergedRowStatusStyles });\n }, [storeState, mergedRowStatusStyles]);\n\n const realizedColumns = useMemo(() => {\n return columnSpec.map((col, colIndex) => {\n let fn =\n col.headerRenderer ??\n columnHeaderCellRenderer ??\n renderColumnHeaderCell;\n let activeSort: any = null;\n let activeFilter: any = null;\n if (col.sortable) {\n activeSort = columnSorts?.find((s) => s.key === col.key);\n }\n // The active filter for this column is whichever active filter targets\n // it (a rich `col.filters` filter or the generic operator filter) — match\n // by columnKey rather than a fixed id.\n for (const entry of activeFilters?.values() ?? []) {\n if ((entry as any)?.filter?.columnKey === col.key) {\n activeFilter = entry;\n break;\n }\n }\n\n const _columnHeaderCellRenderer: any = (colIndex) => {\n return fn(\n {\n col,\n colIndex,\n activeSort,\n activeFilter,\n },\n colIndex,\n );\n };\n\n return h(Column, {\n id: col.key,\n name: col.name,\n columnHeaderCellRenderer: _columnHeaderCellRenderer as any,\n cellRenderer: (rowIndex) => {\n const state = storeAPI.getState();\n return basicCellRenderer<T>(\n rowIndex,\n colIndex,\n col,\n state,\n filteredRowIndices,\n );\n },\n });\n });\n }, [\n columnSpec,\n columnSorts,\n activeFilters,\n storeAPI,\n filteredRowIndices,\n columnHeaderCellRenderer,\n ]);\n\n const onColumnWidthChanged = useSelector(\n (state) => state.onColumnWidthChanged,\n );\n\n const rowHeaderCellRenderer = useCallback(\n (rowIndex: number) => {\n let dataRowIndex = rowIndex;\n if (filteredRowIndices != null) {\n dataRowIndex = filteredRowIndices[rowIndex] ?? rowIndex;\n }\n const statusVal = rowStatus[dataRowIndex];\n let style: CSSProperties | undefined;\n if (statusVal != null) {\n style = mergedRowStatusStyles[statusVal]?.headerStyle;\n }\n\n const defaultLabel = `${dataRowIndex + 1}`;\n // A custom renderer supplies the header's *name* content (a group-key\n // label, an omit indicator, …); a nullish return keeps the default\n // 1-based label. Either way the node is wrapped in a `RowHeaderCell` so\n // status styling and the row index are always applied — the renderer is\n // not responsible for producing the whole cell.\n let name: ReactNode = defaultLabel;\n if (rowHeaderRenderer != null) {\n const custom = rowHeaderRenderer({\n rowIndex: dataRowIndex,\n visibleIndex: rowIndex,\n row: data[dataRowIndex] ?? updatedData[dataRowIndex],\n status: statusVal,\n isDeleted: statusVal === TableElementStatus.DELETED,\n defaultLabel,\n });\n if (custom != null) name = custom;\n }\n\n return h(RowHeaderCell, {\n enableRowReordering: false,\n index: rowIndex,\n name,\n style,\n });\n },\n [\n rowStatus,\n filteredRowIndices,\n mergedRowStatusStyles,\n rowHeaderRenderer,\n data,\n updatedData,\n ],\n );\n\n // Done with hooks!\n /** Guard for unacceptable state combinations:\n * editable = true requires selectionModes to include cells, else the user cannot select a cell to edit.\n * TODO: make this an impossible state to enter.\n */\n if (\n editable &&\n selectionModes &&\n !selectionModes.includes(RegionCardinality.CELLS)\n ) {\n return h(ErrorCallout, {\n title: \"Invalid selection mode\",\n description: \"Editable sheet requires cell selection\",\n });\n }\n\n // TODO: hoist this\n let _selectionModes = selectionModes;\n if (\n editable &&\n _selectionModes != null &&\n !_selectionModes.includes(RegionCardinality.CELLS)\n ) {\n _selectionModes = [..._selectionModes, RegionCardinality.CELLS];\n // Ensure selection mode includes \"cells\"\n }\n\n const cellRendererDependencies = [\n data,\n updatedData,\n focusedCell,\n rowStatus,\n filteredRowIndices,\n ];\n\n // Drive the table from the active provider's `fetchData`. A local (in-memory)\n // provider loads the whole array at once; a remote one uses the `pageSize` /\n // `fetchMode` props and shows load progress.\n let _showLoadProgress: boolean = false;\n let dataLoader: ReactNode = null;\n if (activeProvider != null) {\n _showLoadProgress = !isLocalProvider;\n // A local (in-memory) source loads all its rows in one page; its count\n // rides on the resolved provider (`localCount`), so `_DataSheet` no longer\n // takes a `data` prop — live rows come only from the store.\n dataLoader = h(_DataLoaderManager, {\n key: \"__data_loader\",\n fetchData: activeProvider.fetchData,\n pageSize: isLocalProvider ? Math.max(localCount, 1) : pageSize,\n fetchMode: isLocalProvider ? undefined : fetchMode,\n filterDebounce,\n initialData,\n });\n }\n const showFilterBar =\n (filters != null && filters.length > 0) || hasSortableOrFilterable;\n\n let filterStatus: ReactNode = null;\n if (showFilterBar) {\n filterStatus = h(ActiveFiltersList, { filters: filters ?? [] });\n }\n\n return h(\"div.data-sheet-container\", { className, style }, [\n // The actions/tools toolbar (selection-modal). Table-scoped controls like\n // scroll-to-row / full-text search live here as ordinary actions.\n h(ActionsToolbar, { actions: _actions }),\n dataLoader,\n children,\n h(\n \"div.data-sheet-holder\",\n {\n tabIndex: 0,\n onKeyDown: handleKeyDown,\n onKeyUp: handleKeyUp,\n ref: tableElementRef,\n style: holderStyle,\n },\n h(\n Table as any, // Some sort of hyperscript type error\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n enableColumnReordering,\n onColumnsReordered,\n focusedCell,\n selectedRegions,\n defaultRowHeight: rowHeight,\n columnWidths,\n onColumnWidthChanged,\n onSelection,\n /** TODO: we could enable this if we had a use-case */\n enableRowReordering: false,\n enableRowResizing: false,\n // The cell renderer is memoized internally based on these data dependencies\n cellRendererDependencies,\n onVisibleCellsChange: _onVisibleCellsChange,\n rowHeaderCellRenderer,\n selectionModes: _selectionModes,\n ...tableProps,\n getCellClipboardData: null,\n },\n realizedColumns,\n ),\n ),\n h(\"div.status-bar\", [\n filterStatus,\n statusBar,\n h(\"div.spacer\"),\n h.if(_showLoadProgress)(LoadProgressIndicator),\n ]),\n h.if(debug)(CellRendererDebugOverlay, {\n cellRendererDependencies,\n names: [\n \"data\",\n \"updatedData\",\n \"focusedCell\",\n \"rowStatus\",\n \"filteredRowIndices\",\n ],\n }),\n ]);\n}\n\nconst EMPTY_MAP = new Map<string, number>();\n\nconst columnWidthsIndexAtom = atom(\n (get) => get(storeAtom)?.columnWidthsIndex ?? EMPTY_MAP,\n);\nconst defaultColumnWidthAtom = atom(\n (get) => get(storeAtom)?.defaultColumnWidth ?? 150,\n);\n\nconst columnWidthsAtom = atom((get) => {\n const ix = get(columnWidthsIndexAtom);\n return get(columnSpecAtom).map(\n (col) => ix.get(col.key) ?? col.width ?? get(defaultColumnWidthAtom),\n );\n});\n\nfunction styleParamsForDensity(density: DataSheetDensity): {\n rowHeight: number;\n style: Record<string, string>;\n} {\n switch (density) {\n case DataSheetDensity.MEDIUM:\n return {\n rowHeight: 24,\n style: {\n \"--data-sheet-row-height\": \"24px\",\n \"--data-sheet-font-size\": \"14px\",\n },\n };\n case DataSheetDensity.LOW:\n return {\n rowHeight: 30,\n style: {\n \"--data-sheet-row-height\": \"30px\",\n \"--data-sheet-font-size\": \"18px\",\n },\n };\n case DataSheetDensity.HIGH:\n default:\n return {\n rowHeight: 20,\n style: {\n \"--data-sheet-row-height\": \"20px\",\n \"--data-sheet-font-size\": \"12px\",\n },\n };\n }\n}\n\n/** Convenience component: runs `useChunkLoader` from inside a `DataSheet`.\n * Render as a child of `DataSheet` (it renders nothing itself). */\nfunction _DataLoaderManager<T = any>({\n fetchData,\n ...rest\n}: {\n fetchData: FetchData<T>;\n} & FetchDataOptions<any>) {\n useDataLoader(fetchData, rest);\n return null;\n}\n"],"names":["splitDataProviderProps","DataViewRendererType","h","DataSheetProvider","atom","DataSheetDensity","ctx","useSelector","dataProviderAtom","dataRefreshTokenAtom","useMemo","persistViaProvider","_actions","columnControlActions","clipboardActions","createSaveAction","resetChangesAction","tableActionsAtom","tableHotkeysAtom","useHotkeys","useStoreAPI","useScrollHandler","useCallback","useEffect","useRef","tableFooterAtom","activeFilters","DEFAULT_ROW_STATUS_STYLES","renderColumnHeaderCell","colIndex","Column","basicCellRenderer","style","name","TableElementStatus","RowHeaderCell","RegionCardinality","ErrorCallout","ActiveFiltersList","ActionsToolbar","Table","LoadProgressIndicator","CellRendererDebugOverlay","storeAtom","columnSpecAtom","useDataLoader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAM,uBAAuB;AAEtB,SAAS,UAAa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