@macrostrat/data-sheet 4.1.1 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/actions/builtin.cjs +1 -1
- package/dist/actions/builtin.cjs.map +1 -1
- package/dist/actions/builtin.d.ts +0 -2
- package/dist/actions/builtin.js +1 -1
- package/dist/actions/builtin.js.map +1 -1
- package/dist/actions/clipboard.cjs +1 -1
- package/dist/actions/clipboard.cjs.map +1 -1
- package/dist/actions/clipboard.d.ts +3 -2
- package/dist/actions/clipboard.js +1 -1
- package/dist/actions/clipboard.js.map +1 -1
- package/dist/actions/column-controls.cjs +7 -196
- package/dist/actions/column-controls.cjs.map +1 -1
- package/dist/actions/column-controls.d.ts +1 -1
- package/dist/actions/column-controls.js +5 -194
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -73
- package/dist/actions/column-filter.cjs.map +1 -1
- package/dist/actions/column-filter.d.ts +6 -4
- package/dist/actions/column-filter.js +25 -74
- package/dist/actions/column-filter.js.map +1 -1
- package/dist/actions/context.cjs +147 -0
- package/dist/actions/context.cjs.map +1 -0
- package/dist/actions/context.d.ts +93 -0
- package/dist/actions/context.js +145 -0
- package/dist/actions/context.js.map +1 -0
- package/dist/actions/edit-actions.cjs.map +1 -1
- package/dist/actions/edit-actions.d.ts +3 -1
- package/dist/actions/edit-actions.js.map +1 -1
- package/dist/actions/index.d.ts +2 -3
- package/dist/actions/selection.cjs +70 -115
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +22 -12
- package/dist/actions/selection.js +71 -114
- package/dist/actions/selection.js.map +1 -1
- package/dist/actions/table-actions.cjs +41 -0
- package/dist/actions/table-actions.cjs.map +1 -0
- package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
- package/dist/actions/{table-controls.js → table-actions.js} +2 -23
- package/dist/actions/table-actions.js.map +1 -0
- package/dist/actions/types.d.ts +11 -89
- package/dist/components/cell-detail.cjs +6 -6
- package/dist/components/cell-detail.cjs.map +1 -1
- package/dist/components/cell-detail.js +1 -1
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +7 -7
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/indicators/filter-and-sort.cjs +378 -0
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.d.ts +59 -0
- package/dist/components/indicators/filter-and-sort.js +376 -0
- package/dist/components/indicators/filter-and-sort.js.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
- package/dist/components/indicators/index.d.ts +4 -0
- package/dist/components/indicators/selection.cjs +113 -0
- package/dist/components/indicators/selection.cjs.map +1 -0
- package/dist/components/indicators/selection.d.ts +3 -0
- package/dist/components/indicators/selection.js +111 -0
- package/dist/components/indicators/selection.js.map +1 -0
- package/dist/components/indicators/selection.module.sass.cjs +19 -0
- package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
- package/dist/components/indicators/selection.module.sass.js +17 -0
- package/dist/components/indicators/selection.module.sass.js.map +1 -0
- package/dist/components/indicators/unified-filters.cjs +130 -0
- package/dist/components/indicators/unified-filters.cjs.map +1 -0
- package/dist/components/indicators/unified-filters.d.ts +10 -0
- package/dist/components/indicators/unified-filters.js +130 -0
- package/dist/components/indicators/unified-filters.js.map +1 -0
- package/dist/components/indicators/view-info.cjs +59 -0
- package/dist/components/indicators/view-info.cjs.map +1 -0
- package/dist/components/indicators/view-info.d.ts +11 -0
- package/dist/components/{view-info.js → indicators/view-info.js} +20 -16
- package/dist/components/indicators/view-info.js.map +1 -0
- package/dist/components/text-areas.cjs +5 -5
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.js +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +185 -0
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
- package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
- package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +37 -112
- package/dist/components/toolbars/actions-toolbar.js.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
- package/dist/components/toolbars/active-filters.cjs +120 -0
- package/dist/components/toolbars/active-filters.cjs.map +1 -0
- package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
- package/dist/components/toolbars/active-filters.js +120 -0
- package/dist/components/toolbars/active-filters.js.map +1 -0
- package/dist/components/toolbars/index.d.ts +2 -0
- package/dist/data-panel.cjs +291 -0
- package/dist/data-panel.cjs.map +1 -0
- package/dist/data-panel.d.ts +110 -0
- package/dist/data-panel.js +289 -0
- package/dist/data-panel.js.map +1 -0
- package/dist/data-panel.module.sass.cjs +40 -0
- package/dist/data-panel.module.sass.cjs.map +1 -0
- package/dist/data-panel.module.sass.js +38 -0
- package/dist/data-panel.module.sass.js.map +1 -0
- package/dist/{core.cjs → data-sheet.cjs} +126 -188
- package/dist/data-sheet.cjs.map +1 -0
- package/dist/data-sheet.css +241 -13
- package/dist/data-sheet.d.ts +16 -0
- package/dist/{core.js → data-sheet.js} +95 -157
- package/dist/data-sheet.js.map +1 -0
- package/dist/data-view.cjs +47 -0
- package/dist/data-view.cjs.map +1 -0
- package/dist/data-view.d.ts +15 -0
- package/dist/data-view.js +45 -0
- package/dist/data-view.js.map +1 -0
- package/dist/filters/operators.cjs +19 -2
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +4 -3
- package/dist/filters/operators.js +19 -2
- package/dist/filters/operators.js.map +1 -1
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +76 -17
- package/dist/index.js.map +1 -1
- package/dist/notifications.cjs +4 -4
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.js +1 -1
- package/dist/postgrest-table/data-loaders.cjs +128 -95
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -82
- package/dist/postgrest-table/data-loaders.js +109 -76
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +18 -17
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +4 -3
- package/dist/postgrest-table/index.js +9 -8
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/{utils → provider}/column-spec.cjs +23 -9
- package/dist/provider/column-spec.cjs.map +1 -0
- package/dist/{utils → provider}/column-spec.d.ts +73 -2
- package/dist/{utils → provider}/column-spec.js +24 -10
- package/dist/provider/column-spec.js.map +1 -0
- package/dist/provider/core.cjs +382 -0
- package/dist/provider/core.cjs.map +1 -0
- package/dist/provider/core.d.ts +74 -0
- package/dist/provider/core.js +380 -0
- package/dist/provider/core.js.map +1 -0
- package/dist/provider/index.d.ts +7 -0
- package/dist/provider/interactions.cjs +128 -0
- package/dist/provider/interactions.cjs.map +1 -0
- package/dist/provider/interactions.d.ts +39 -0
- package/dist/provider/interactions.js +128 -0
- package/dist/provider/interactions.js.map +1 -0
- package/dist/provider/selection.cjs +29 -0
- package/dist/provider/selection.cjs.map +1 -0
- package/dist/provider/selection.d.ts +9 -0
- package/dist/provider/selection.js +29 -0
- package/dist/provider/selection.js.map +1 -0
- package/dist/provider/table-data.cjs +92 -0
- package/dist/provider/table-data.cjs.map +1 -0
- package/dist/provider/table-data.d.ts +81 -0
- package/dist/provider/table-data.js +92 -0
- package/dist/provider/table-data.js.map +1 -0
- package/dist/provider/types.cjs +22 -0
- package/dist/provider/types.cjs.map +1 -0
- package/dist/provider/types.d.ts +256 -0
- package/dist/provider/types.js +22 -0
- package/dist/provider/types.js.map +1 -0
- package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +36 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +21 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +67 -34
- package/dist/renderers/cell-renderer.cjs.map +1 -0
- package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
- package/dist/{cell-renderer.js → renderers/cell-renderer.js} +65 -32
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +21 -13
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +3 -2
- package/dist/renderers/column-header-cell.js +20 -12
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/renderers/index.d.ts +1 -0
- package/dist/types.cjs +7 -19
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +117 -229
- package/dist/types.js +7 -19
- package/dist/types.js.map +1 -1
- package/dist/utils/atoms.cjs +24 -0
- package/dist/utils/atoms.cjs.map +1 -0
- package/dist/utils/atoms.d.ts +4 -0
- package/dist/utils/atoms.js +24 -0
- package/dist/utils/atoms.js.map +1 -0
- package/dist/utils/debug-overlay.cjs.map +1 -1
- package/dist/utils/debug-overlay.js.map +1 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/key-handling.cjs +140 -139
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +4 -2
- package/dist/utils/key-handling.js +136 -135
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/utils/validation.cjs +6 -1
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +6 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +4 -3
- package/src/actions/builtin.ts +1 -4
- package/src/actions/clipboard.ts +4 -3
- package/src/actions/column-controls.ts +12 -245
- package/src/actions/column-filter.ts +28 -92
- package/src/actions/context.ts +299 -0
- package/src/actions/edit-actions.ts +3 -1
- package/src/actions/index.ts +2 -3
- package/src/actions/selection.ts +109 -156
- package/src/actions/{table-controls.ts → table-actions.ts} +0 -24
- package/src/actions/types.ts +17 -101
- package/src/components/colors.ts +1 -1
- package/src/components/index.ts +2 -1
- package/src/components/indicators/filter-and-sort.module.sass +13 -0
- package/src/components/indicators/filter-and-sort.ts +478 -0
- package/src/components/indicators/index.ts +4 -0
- package/src/components/indicators/selection.module.sass +22 -0
- package/src/components/indicators/selection.ts +141 -0
- package/src/components/indicators/unified-filters.ts +161 -0
- package/src/components/{view-info.ts → indicators/view-info.ts} +19 -30
- package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
- package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +49 -150
- package/src/components/toolbars/active-filters.ts +150 -0
- package/src/components/toolbars/index.ts +2 -0
- package/src/data-panel.module.sass +185 -0
- package/src/data-panel.ts +556 -0
- package/src/{core.ts → data-sheet.ts} +156 -327
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +33 -3
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +244 -171
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +30 -15
- package/src/provider/core.ts +585 -0
- package/src/provider/index.ts +7 -0
- package/src/provider/interactions.ts +161 -0
- package/src/provider/selection.ts +31 -0
- package/src/provider/table-data.ts +178 -0
- package/src/provider/types.ts +273 -0
- package/src/{zustand-store.ts → provider/zustand-store.ts} +35 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +140 -57
- package/src/renderers/column-header-cell.ts +21 -14
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +137 -239
- package/src/utils/atoms.ts +28 -0
- package/src/utils/debug-overlay.ts +1 -1
- package/src/utils/index.ts +2 -8
- package/src/utils/key-handling.ts +170 -164
- package/src/utils/validation.ts +7 -2
- package/dist/actions/filters.cjs +0 -139
- package/dist/actions/filters.cjs.map +0 -1
- package/dist/actions/filters.js +0 -139
- package/dist/actions/filters.js.map +0 -1
- package/dist/actions/table-controls.cjs +0 -62
- package/dist/actions/table-controls.cjs.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -260
- package/dist/actions/toolbar.cjs.map +0 -1
- package/dist/actions/toolbar.js.map +0 -1
- package/dist/actions/toolbar.module.sass.cjs +0 -27
- package/dist/actions/toolbar.module.sass.cjs.map +0 -1
- package/dist/actions/toolbar.module.sass.js +0 -25
- package/dist/actions/toolbar.module.sass.js.map +0 -1
- package/dist/cell-renderer.cjs.map +0 -1
- package/dist/cell-renderer.js.map +0 -1
- package/dist/components/view-info.cjs +0 -55
- package/dist/components/view-info.cjs.map +0 -1
- package/dist/components/view-info.d.ts +0 -5
- package/dist/components/view-info.js.map +0 -1
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -117
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -197
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -26
- package/dist/provider.js +0 -195
- package/dist/provider.js.map +0 -1
- package/dist/table-updates/data-parameter.d.ts +0 -14
- package/dist/table-updates/filter.d.ts +0 -16
- package/dist/table-updates/index.d.ts +0 -19
- package/dist/utils/column-spec.cjs.map +0 -1
- package/dist/utils/column-spec.js.map +0 -1
- package/dist/utils/index.cjs +0 -9
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/zustand-store.cjs.map +0 -1
- package/dist/zustand-store.js.map +0 -1
- package/src/actions/filters.ts +0 -176
- package/src/components/actions.module.sass +0 -8
- package/src/provider.ts +0 -267
- package/src/table-updates/data-parameter.ts +0 -44
- package/src/table-updates/filter.ts +0 -124
- package/src/table-updates/index.ts +0 -239
- /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cell-renderer.cjs","sources":["../src/cell-renderer.ts"],"sourcesContent":["import {\n ColumnSpec,\n CellRenderContext,\n CellDetailContext,\n editorKeyHandlerAtom,\n validateCell,\n} from \"./utils\";\nimport { DataSheetStore, TableElementStatus } from \"./types.ts\";\nimport h from \"./main.module.sass\";\nimport { ReactNode, useEffect, useRef, useState } from \"react\";\nimport { EditorPopup, CellDetailModal } from \"./components\";\nimport { singleFocusedCell } from \"./zustand-store.ts\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, useSelector } from \"./provider.ts\";\n\nexport function basicCellRenderer<T>(\n rowIndex: number,\n colIndex: number,\n columnSpec: ColumnSpec,\n state: DataSheetStore<T>,\n filteredRowIndices?: number[] | null,\n): any {\n // Auto-activation is on when the mode is \"auto\" and it hasn't been suppressed\n // (Escape enters navigation mode until the next click).\n // Whether the inline editor grabs focus. It follows the store-owned surface\n // open state, so it focuses on selection in auto mode and on click in manual\n // mode, and not at all in navigation mode. The popover surfaces read the\n // same state directly.\n const focusOnOpen = state.cellSurfaceOpen;\n // When filters are active, `rowIndex` is the visible row position.\n // Map it to the actual data index for data access.\n const dataRowIndex =\n filteredRowIndices != null\n ? (filteredRowIndices[rowIndex] ?? rowIndex)\n : rowIndex;\n\n const data = state.data;\n const updatedData = state.updatedData;\n\n const statusVal = state.rowStatus[dataRowIndex];\n const isDeleted = statusVal == TableElementStatus.DELETED;\n // Presentation for this row's status (deleted, or a consumer-defined status\n // like \"omitted\"), from the merged `rowStatusStyles`.\n const statusStyle = statusVal != null ? state.rowStatusStyles?.[statusVal] : undefined;\n\n const row = data[dataRowIndex] ?? updatedData[dataRowIndex];\n const loading = row == null;\n const col = columnSpec;\n\n const _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n\n const value: T | undefined =\n updatedData[dataRowIndex]?.[col.key] ?? data[dataRowIndex]?.[col.key];\n const isEmpty = value == null || value === \"\";\n\n const edited =\n updatedData[dataRowIndex]?.[col.key] != null ||\n state.rowStatus[dataRowIndex] === TableElementStatus.ADDED;\n\n // Validate the cell (skipped for deleted rows). Orthogonal to edit status.\n const validation = isDeleted ? null : validateCell(col, value, row, dataRowIndex);\n\n // Context passed to custom renderers so they can render based on the\n // row/column position and cell status (and, with the editing API, write\n // edits back). `rowIndex` is the data-row index, stable under sort/filter.\n const cellContext: CellRenderContext<T> = {\n value,\n rowIndex: dataRowIndex,\n colIndex,\n column: col,\n row,\n isEdited: edited,\n isDeleted,\n status: statusVal,\n validation,\n };\n\n const _renderedValue = isEmpty\n ? null\n : (col.valueRenderer?.(value, cellContext) ?? value);\n\n // Clone so we never mutate the caller's column-spec style object, then layer\n // the row-status presentation (deleted → dimmed/struck-through by default;\n // consumer statuses supply their own `cellStyle`).\n let style = { ...(col.style ?? {}) };\n\n if (statusStyle?.cellStyle != null) {\n style = { ...style, ...statusStyle.cellStyle };\n }\n\n const editable = (col.editable ?? state.editable) && !isDeleted;\n\n // topLeftCell stores visible row indices, so compare with the visible rowIndex\n const topLeft =\n _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;\n\n const tableIsEditable = state.editable;\n\n // Intent precedence: error > warning > row-status intent > edited. Validation\n // state overrides the edited-green so an edited-but-invalid cell reads as\n // invalid. A row's status intent (e.g. deleted → danger) outranks the\n // edited-green so status reads through even on an edited row.\n let intent: string | undefined;\n if (validation?.severity === \"error\") {\n intent = \"danger\";\n } else if (validation?.severity === \"warning\") {\n intent = \"warning\";\n } else if (statusStyle?.intent != null) {\n intent = statusStyle.intent;\n } else if (edited) {\n intent = \"success\";\n }\n\n const _Cell = col.cellComponent ?? Cell;\n\n // Only forward the render context to a custom cell component; the default\n // Blueprint Cell would spread unknown props onto the DOM.\n const cellComponentProps =\n col.cellComponent != null ? { cellContext } : {};\n\n // Allow a column to pick the editor per-cell (e.g. textarea only when the\n // value is long). A returned key overrides the static column field even\n // when its value is false/null, so use `in` rather than nullish-coalesce.\n const perCellEditors = col.editorForCell?.(cellContext);\n const dataEditorSpec =\n perCellEditors != null && \"dataEditor\" in perCellEditors\n ? perCellEditors.dataEditor\n : col.dataEditor;\n const inlineEditorSpec =\n perCellEditors != null && \"inlineEditor\" in perCellEditors\n ? perCellEditors.inlineEditor\n : col.inlineEditor;\n\n let inlineEditor = editable ? (inlineEditorSpec ?? true) : false;\n\n // Build the detail context for the unified `cellDetail` surface.\n const makeDetailCtx = (editableFlag: boolean): CellDetailContext<T> => ({\n ...cellContext,\n editable: editableFlag,\n onChange(v: any) {\n if (editableFlag) onCellEdited(dataRowIndex, col.key, v);\n },\n resetValue() {\n state.resetChanges();\n },\n close() {\n state.closeCellSurface();\n state.tableElement?.focus?.();\n },\n });\n const detailPresentation =\n col.cellDetail != null ? (col.detailPresentation ?? \"popover\") : null;\n\n if (!topLeft) {\n // An inline surface is a persistent in-cell renderer, so it draws on every\n // cell (read-only when not the focused/editing cell).\n if (detailPresentation === \"inline\") {\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: \"value-viewer-cell\",\n interactive: false,\n ...cellComponentProps,\n },\n col.cellDetail!(makeDetailCtx(false)),\n );\n }\n return h(\n _Cell,\n {\n intent,\n loading,\n value,\n style,\n disabled: tableIsEditable && !editable,\n interactive: false,\n ...cellComponentProps,\n },\n _renderedValue,\n );\n }\n\n // The rest is for the top-left cell of a selection or the focused cell\n\n // Unified cell surface: one renderer that acts as editor (when editable) or\n // viewer (otherwise), presented as a popover / modal / inline. Supersedes\n // dataEditor / detailRenderer / editorForCell.\n if (col.cellDetail != null) {\n const content = col.cellDetail(makeDetailCtx(editable));\n\n if (detailPresentation === \"inline\") {\n // Persistent in-cell surface (editable on the focused cell). No popover.\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: editable ? \"input-cell\" : \"value-viewer-cell\",\n interactive: editable,\n ...cellComponentProps,\n },\n content,\n );\n }\n\n if (detailPresentation === \"modal\") {\n // CellDetailModal subscribes to the store so the dialog closes reactively.\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: \"value-viewer-cell\",\n interactive: false,\n ...cellComponentProps,\n },\n h(\n CellDetailModal,\n { title: col.name, valueViewer: _renderedValue },\n content,\n ),\n );\n }\n\n // Default: popover (same open/close machinery as editors and panels).\n const panel = h(EditorPopup, { valueViewer: _renderedValue }, content);\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: \"editor-cell\",\n interactive: editable,\n ...cellComponentProps,\n },\n panel,\n );\n }\n\n // Read-only detail panel: a surface that opens on selection (auto) or click,\n // shows arbitrary content, and never takes keyboard focus — so arrow keys\n // keep navigating the table. Uses the same open/close machinery as editors.\n if (col.detailRenderer != null) {\n const panel = h(\n EditorPopup,\n { valueViewer: _renderedValue },\n col.detailRenderer(cellContext),\n );\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n // Use the editor-cell popover layout so the target fills the cell\n // without the double-padding offset of `value-viewer-cell`.\n className: \"editor-cell\",\n interactive: false,\n ...cellComponentProps,\n },\n panel,\n );\n }\n\n let cellContents: ReactNode = _renderedValue;\n\n let _dataEditor = null;\n let className = null;\n\n if (dataEditorSpec != null) {\n _dataEditor = h(\n EditorPopup,\n {\n valueViewer: _renderedValue,\n },\n [\n h(dataEditorSpec, {\n value,\n editable,\n isEdited: edited,\n onChange(value) {\n if (!editable) return;\n // Commit to THIS cell — not the live selection. The editor can\n // commit (e.g. on blur) after the selection has moved to another\n // cell or a whole column; `onSelectionEdited` would then write the\n // value to the wrong target (emptying it). `onCellEdited` addresses\n // the editor's own data cell.\n state.onCellEdited(dataRowIndex, col.key, value);\n },\n resetValue() {\n state.resetChanges();\n },\n }),\n ],\n );\n }\n\n if (!editable) {\n if (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n const className = \"value-viewer-cell\";\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className,\n interactive: false,\n ...cellComponentProps,\n },\n cellContents,\n );\n }\n\n /* The remaining logic covers cells that are focused and editable */\n\n const onChange = (e) => {\n if (!editable) return;\n if (_renderedValue === e.target.value) return;\n // Use dataRowIndex for the actual data mutation\n onCellEdited(dataRowIndex, col.key, e.target.value);\n };\n\n const isSingleCellSelection = singleFocusedCell(state.selection) != null;\n\n let _inlineEditor: ReactNode = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (\n typeof _renderedValue === \"string\" ||\n typeof _renderedValue === \"number\" ||\n _renderedValue == null\n ) {\n _value = _renderedValue;\n }\n _inlineEditor = h(EditorInput, {\n className: \"main-editor\",\n value: _value ?? \"\",\n autoFocus: focusOnOpen,\n onChange,\n });\n } else {\n // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor as ReactNode;\n }\n\n let hiddenInput: React.ReactNode = h(EditorInput, {\n className: \"hidden-input\",\n autoFocus: true,\n });\n\n if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n interactive: true,\n ...cellComponentProps,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle),\n //hiddenInput,\n ],\n );\n}\n\nfunction EditorInput(props) {\n const { value, onChange, ...rest } = props;\n const onKeyDown = ctx.useValue(editorKeyHandlerAtom);\n const navDirection = useSelector((s) => s.lastNavDirection);\n const surfaceOpen = useSelector((s) => s.cellSurfaceOpen);\n const inputRef = useRef<HTMLInputElement>(null);\n const [_value, setValue] = useState(value);\n useEffect(() => {\n setValue(value);\n }, [value]);\n useEffect(() => {\n // Focus when the cell's surface is open (on mount, and when reopened via\n // click/F2 while already mounted), placing the cursor on the side we're\n // travelling toward so another arrow in that direction leaves the cell.\n const el = inputRef.current;\n if (el == null || !surfaceOpen) return;\n el.focus();\n const atStart = navDirection === \"up\" || navDirection === \"left\";\n const pos = atStart ? 0 : (el.value?.length ?? 0);\n el.setSelectionRange(pos, pos);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [surfaceOpen]);\n return h(\"input\", {\n ref: inputRef,\n onKeyDown,\n onBlur: onChange,\n value: _value ?? value,\n onChange: (e) => setValue(e.target.value),\n ...rest,\n });\n}\n\nfunction DragHandle() {\n // TODO: we might want to drag multiple columns in some cases\n // This should be on the last cell of a selection\n const onMouseDown = useSelector((state) => state.onDragValue);\n return h(\"div.corner-drag-handle\", { onMouseDown });\n}\n"],"names":["TableElementStatus","validation","validateCell","Cell","h","CellDetailModal","EditorPopup","value","className","singleFocusedCell","ctx","editorKeyHandlerAtom","useSelector","useRef","useState","useEffect"],"mappings":";;;;;;;;;;;;AAeO,SAAS,kBACd,UACA,UACA,YACA,OACA,oBACK;AAOL,QAAM,cAAc,MAAM;AAG1B,QAAM,eACJ,sBAAsB,OACjB,mBAAmB,QAAQ,KAAK,WACjC;AAEN,QAAM,OAAO,MAAM;AACnB,QAAM,cAAc,MAAM;AAE1B,QAAM,YAAY,MAAM,UAAU,YAAY;AAC9C,QAAM,YAAY,aAAaA,MAAAA,mBAAmB;AAGlD,QAAM,cAAc,aAAa,OAAO,MAAM,kBAAkB,SAAS,IAAI;AAE7E,QAAM,MAAM,KAAK,YAAY,KAAK,YAAY,YAAY;AAC1D,QAAM,UAAU,OAAO;AACvB,QAAM,MAAM;AAEZ,QAAM,eAAe,MAAM;AAC3B,QAAM,eAAe,MAAM;AAE3B,QAAM,QACJ,YAAY,YAAY,IAAI,IAAI,GAAG,KAAK,KAAK,YAAY,IAAI,IAAI,GAAG;AACtE,QAAM,UAAU,SAAS,QAAQ,UAAU;AAE3C,QAAM,SACJ,YAAY,YAAY,IAAI,IAAI,GAAG,KAAK,QACxC,MAAM,UAAU,YAAY,MAAMA,MAAAA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AI,SAASC,gCAAoB;AACnD,QAAM,eAAeC,SAAAA,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAC1D,QAAM,cAAcA,SAAAA,YAAY,CAAC,MAAM,EAAE,eAAe;AACxD,QAAM,WAAWC,MAAAA,OAAyB,IAAI;AAC9C,QAAM,CAAC,QAAQ,QAAQ,IAAIC,MAAAA,SAAS,KAAK;AACzCC,QAAAA,UAAU,MAAM;AACd,aAAS,KAAK;AAAA,EAChB,GAAG,CAAC,KAAK,CAAC;AACVA,QAAAA,UAAU,MAAM;AAId,UAAM,KAAK,SAAS;AACpB,QAAI,MAAM,QAAQ,CAAC,YAAa;AAChC,OAAG,MAAA;AACH,UAAM,UAAU,iBAAiB,QAAQ,iBAAiB;AAC1D,UAAM,MAAM,UAAU,IAAK,GAAG,OAAO,UAAU;AAC/C,OAAG,kBAAkB,KAAK,GAAG;AAAA,EAE/B,GAAG,CAAC,WAAW,CAAC;AAChB,SAAOX,YAAAA,QAAE,SAAS;AAAA,IAChB,KAAK;AAAA,IACL;AAAA,IACA,QAAQ;AAAA,IACR,OAAO,UAAU;AAAA,IACjB,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAK;AAAA,IACxC,GAAG;AAAA,EAAA,CACJ;AACH;AAEA,SAAS,aAAa;AAGpB,QAAM,cAAcQ,SAAAA,YAAY,CAAC,UAAU,MAAM,WAAW;AAC5D,SAAOR,oBAAE,0BAA0B,EAAE,aAAa;AACpD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cell-renderer.js","sources":["../src/cell-renderer.ts"],"sourcesContent":["import {\n ColumnSpec,\n CellRenderContext,\n CellDetailContext,\n editorKeyHandlerAtom,\n validateCell,\n} from \"./utils\";\nimport { DataSheetStore, TableElementStatus } from \"./types.ts\";\nimport h from \"./main.module.sass\";\nimport { ReactNode, useEffect, useRef, useState } from \"react\";\nimport { EditorPopup, CellDetailModal } from \"./components\";\nimport { singleFocusedCell } from \"./zustand-store.ts\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, useSelector } from \"./provider.ts\";\n\nexport function basicCellRenderer<T>(\n rowIndex: number,\n colIndex: number,\n columnSpec: ColumnSpec,\n state: DataSheetStore<T>,\n filteredRowIndices?: number[] | null,\n): any {\n // Auto-activation is on when the mode is \"auto\" and it hasn't been suppressed\n // (Escape enters navigation mode until the next click).\n // Whether the inline editor grabs focus. It follows the store-owned surface\n // open state, so it focuses on selection in auto mode and on click in manual\n // mode, and not at all in navigation mode. The popover surfaces read the\n // same state directly.\n const focusOnOpen = state.cellSurfaceOpen;\n // When filters are active, `rowIndex` is the visible row position.\n // Map it to the actual data index for data access.\n const dataRowIndex =\n filteredRowIndices != null\n ? (filteredRowIndices[rowIndex] ?? rowIndex)\n : rowIndex;\n\n const data = state.data;\n const updatedData = state.updatedData;\n\n const statusVal = state.rowStatus[dataRowIndex];\n const isDeleted = statusVal == TableElementStatus.DELETED;\n // Presentation for this row's status (deleted, or a consumer-defined status\n // like \"omitted\"), from the merged `rowStatusStyles`.\n const statusStyle = statusVal != null ? state.rowStatusStyles?.[statusVal] : undefined;\n\n const row = data[dataRowIndex] ?? updatedData[dataRowIndex];\n const loading = row == null;\n const col = columnSpec;\n\n const _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n\n const value: T | undefined =\n updatedData[dataRowIndex]?.[col.key] ?? data[dataRowIndex]?.[col.key];\n const isEmpty = value == null || value === \"\";\n\n const edited =\n updatedData[dataRowIndex]?.[col.key] != null ||\n state.rowStatus[dataRowIndex] === TableElementStatus.ADDED;\n\n // Validate the cell (skipped for deleted rows). Orthogonal to edit status.\n const validation = isDeleted ? null : validateCell(col, value, row, dataRowIndex);\n\n // Context passed to custom renderers so they can render based on the\n // row/column position and cell status (and, with the editing API, write\n // edits back). `rowIndex` is the data-row index, stable under sort/filter.\n const cellContext: CellRenderContext<T> = {\n value,\n rowIndex: dataRowIndex,\n colIndex,\n column: col,\n row,\n isEdited: edited,\n isDeleted,\n status: statusVal,\n validation,\n };\n\n const _renderedValue = isEmpty\n ? null\n : (col.valueRenderer?.(value, cellContext) ?? value);\n\n // Clone so we never mutate the caller's column-spec style object, then layer\n // the row-status presentation (deleted → dimmed/struck-through by default;\n // consumer statuses supply their own `cellStyle`).\n let style = { ...(col.style ?? {}) };\n\n if (statusStyle?.cellStyle != null) {\n style = { ...style, ...statusStyle.cellStyle };\n }\n\n const editable = (col.editable ?? state.editable) && !isDeleted;\n\n // topLeftCell stores visible row indices, so compare with the visible rowIndex\n const topLeft =\n _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;\n\n const tableIsEditable = state.editable;\n\n // Intent precedence: error > warning > row-status intent > edited. Validation\n // state overrides the edited-green so an edited-but-invalid cell reads as\n // invalid. A row's status intent (e.g. deleted → danger) outranks the\n // edited-green so status reads through even on an edited row.\n let intent: string | undefined;\n if (validation?.severity === \"error\") {\n intent = \"danger\";\n } else if (validation?.severity === \"warning\") {\n intent = \"warning\";\n } else if (statusStyle?.intent != null) {\n intent = statusStyle.intent;\n } else if (edited) {\n intent = \"success\";\n }\n\n const _Cell = col.cellComponent ?? Cell;\n\n // Only forward the render context to a custom cell component; the default\n // Blueprint Cell would spread unknown props onto the DOM.\n const cellComponentProps =\n col.cellComponent != null ? { cellContext } : {};\n\n // Allow a column to pick the editor per-cell (e.g. textarea only when the\n // value is long). A returned key overrides the static column field even\n // when its value is false/null, so use `in` rather than nullish-coalesce.\n const perCellEditors = col.editorForCell?.(cellContext);\n const dataEditorSpec =\n perCellEditors != null && \"dataEditor\" in perCellEditors\n ? perCellEditors.dataEditor\n : col.dataEditor;\n const inlineEditorSpec =\n perCellEditors != null && \"inlineEditor\" in perCellEditors\n ? perCellEditors.inlineEditor\n : col.inlineEditor;\n\n let inlineEditor = editable ? (inlineEditorSpec ?? true) : false;\n\n // Build the detail context for the unified `cellDetail` surface.\n const makeDetailCtx = (editableFlag: boolean): CellDetailContext<T> => ({\n ...cellContext,\n editable: editableFlag,\n onChange(v: any) {\n if (editableFlag) onCellEdited(dataRowIndex, col.key, v);\n },\n resetValue() {\n state.resetChanges();\n },\n close() {\n state.closeCellSurface();\n state.tableElement?.focus?.();\n },\n });\n const detailPresentation =\n col.cellDetail != null ? (col.detailPresentation ?? \"popover\") : null;\n\n if (!topLeft) {\n // An inline surface is a persistent in-cell renderer, so it draws on every\n // cell (read-only when not the focused/editing cell).\n if (detailPresentation === \"inline\") {\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: \"value-viewer-cell\",\n interactive: false,\n ...cellComponentProps,\n },\n col.cellDetail!(makeDetailCtx(false)),\n );\n }\n return h(\n _Cell,\n {\n intent,\n loading,\n value,\n style,\n disabled: tableIsEditable && !editable,\n interactive: false,\n ...cellComponentProps,\n },\n _renderedValue,\n );\n }\n\n // The rest is for the top-left cell of a selection or the focused cell\n\n // Unified cell surface: one renderer that acts as editor (when editable) or\n // viewer (otherwise), presented as a popover / modal / inline. Supersedes\n // dataEditor / detailRenderer / editorForCell.\n if (col.cellDetail != null) {\n const content = col.cellDetail(makeDetailCtx(editable));\n\n if (detailPresentation === \"inline\") {\n // Persistent in-cell surface (editable on the focused cell). No popover.\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: editable ? \"input-cell\" : \"value-viewer-cell\",\n interactive: editable,\n ...cellComponentProps,\n },\n content,\n );\n }\n\n if (detailPresentation === \"modal\") {\n // CellDetailModal subscribes to the store so the dialog closes reactively.\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: \"value-viewer-cell\",\n interactive: false,\n ...cellComponentProps,\n },\n h(\n CellDetailModal,\n { title: col.name, valueViewer: _renderedValue },\n content,\n ),\n );\n }\n\n // Default: popover (same open/close machinery as editors and panels).\n const panel = h(EditorPopup, { valueViewer: _renderedValue }, content);\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className: \"editor-cell\",\n interactive: editable,\n ...cellComponentProps,\n },\n panel,\n );\n }\n\n // Read-only detail panel: a surface that opens on selection (auto) or click,\n // shows arbitrary content, and never takes keyboard focus — so arrow keys\n // keep navigating the table. Uses the same open/close machinery as editors.\n if (col.detailRenderer != null) {\n const panel = h(\n EditorPopup,\n { valueViewer: _renderedValue },\n col.detailRenderer(cellContext),\n );\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n // Use the editor-cell popover layout so the target fills the cell\n // without the double-padding offset of `value-viewer-cell`.\n className: \"editor-cell\",\n interactive: false,\n ...cellComponentProps,\n },\n panel,\n );\n }\n\n let cellContents: ReactNode = _renderedValue;\n\n let _dataEditor = null;\n let className = null;\n\n if (dataEditorSpec != null) {\n _dataEditor = h(\n EditorPopup,\n {\n valueViewer: _renderedValue,\n },\n [\n h(dataEditorSpec, {\n value,\n editable,\n isEdited: edited,\n onChange(value) {\n if (!editable) return;\n // Commit to THIS cell — not the live selection. The editor can\n // commit (e.g. on blur) after the selection has moved to another\n // cell or a whole column; `onSelectionEdited` would then write the\n // value to the wrong target (emptying it). `onCellEdited` addresses\n // the editor's own data cell.\n state.onCellEdited(dataRowIndex, col.key, value);\n },\n resetValue() {\n state.resetChanges();\n },\n }),\n ],\n );\n }\n\n if (!editable) {\n if (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n const className = \"value-viewer-cell\";\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className,\n interactive: false,\n ...cellComponentProps,\n },\n cellContents,\n );\n }\n\n /* The remaining logic covers cells that are focused and editable */\n\n const onChange = (e) => {\n if (!editable) return;\n if (_renderedValue === e.target.value) return;\n // Use dataRowIndex for the actual data mutation\n onCellEdited(dataRowIndex, col.key, e.target.value);\n };\n\n const isSingleCellSelection = singleFocusedCell(state.selection) != null;\n\n let _inlineEditor: ReactNode = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (\n typeof _renderedValue === \"string\" ||\n typeof _renderedValue === \"number\" ||\n _renderedValue == null\n ) {\n _value = _renderedValue;\n }\n _inlineEditor = h(EditorInput, {\n className: \"main-editor\",\n value: _value ?? \"\",\n autoFocus: focusOnOpen,\n onChange,\n });\n } else {\n // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor as ReactNode;\n }\n\n let hiddenInput: React.ReactNode = h(EditorInput, {\n className: \"hidden-input\",\n autoFocus: true,\n });\n\n if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n interactive: true,\n ...cellComponentProps,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle),\n //hiddenInput,\n ],\n );\n}\n\nfunction EditorInput(props) {\n const { value, onChange, ...rest } = props;\n const onKeyDown = ctx.useValue(editorKeyHandlerAtom);\n const navDirection = useSelector((s) => s.lastNavDirection);\n const surfaceOpen = useSelector((s) => s.cellSurfaceOpen);\n const inputRef = useRef<HTMLInputElement>(null);\n const [_value, setValue] = useState(value);\n useEffect(() => {\n setValue(value);\n }, [value]);\n useEffect(() => {\n // Focus when the cell's surface is open (on mount, and when reopened via\n // click/F2 while already mounted), placing the cursor on the side we're\n // travelling toward so another arrow in that direction leaves the cell.\n const el = inputRef.current;\n if (el == null || !surfaceOpen) return;\n el.focus();\n const atStart = navDirection === \"up\" || navDirection === \"left\";\n const pos = atStart ? 0 : (el.value?.length ?? 0);\n el.setSelectionRange(pos, pos);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [surfaceOpen]);\n return h(\"input\", {\n ref: inputRef,\n onKeyDown,\n onBlur: onChange,\n value: _value ?? value,\n onChange: (e) => setValue(e.target.value),\n ...rest,\n });\n}\n\nfunction DragHandle() {\n // TODO: we might want to drag multiple columns in some cases\n // This should be on the last cell of a selection\n const onMouseDown = useSelector((state) => state.onDragValue);\n return h(\"div.corner-drag-handle\", { onMouseDown });\n}\n"],"names":["value","className"],"mappings":";;;;;;;;;;AAeO,S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B,EAAE,aAAa;AACpD;"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const main_module = require("../postgrest-table/main.module.sass.cjs");
|
|
4
|
-
const provider = require("../provider.cjs");
|
|
5
|
-
const core = require("@blueprintjs/core");
|
|
6
|
-
const dataLoaders = require("../postgrest-table/data-loaders.cjs");
|
|
7
|
-
function LoadProgressIndicator() {
|
|
8
|
-
const footer = provider.ctx.useValue(dataLoaders.tableFooterAtom);
|
|
9
|
-
if (footer.mode === "paged") return main_module.default(PageControl);
|
|
10
|
-
const { loaded, total, loading } = footer;
|
|
11
|
-
let status;
|
|
12
|
-
if (loading) {
|
|
13
|
-
status = main_module.default(core.Spinner, { size: 12 });
|
|
14
|
-
} else if (total != null && loaded >= total) {
|
|
15
|
-
status = main_module.default(core.Icon, { icon: "tick-circle", intent: "success", size: 12 });
|
|
16
|
-
} else {
|
|
17
|
-
status = main_module.default(core.Icon, { icon: "more", size: 12 });
|
|
18
|
-
}
|
|
19
|
-
return main_module.default("div.load-progress", [
|
|
20
|
-
main_module.default("span.load-progress-label", [
|
|
21
|
-
`${loaded}`,
|
|
22
|
-
total != null ? ` of ${total}` : "",
|
|
23
|
-
" rows"
|
|
24
|
-
]),
|
|
25
|
-
status
|
|
26
|
-
]);
|
|
27
|
-
}
|
|
28
|
-
function PageControl() {
|
|
29
|
-
const { page, totalPages, loading } = provider.ctx.useValue(dataLoaders.tableFooterAtom);
|
|
30
|
-
const setPage = provider.ctx.useSet(dataLoaders.chunkPageAtom);
|
|
31
|
-
const atEnd = totalPages != null && page >= totalPages - 1;
|
|
32
|
-
return main_module.default("div.load-progress", [
|
|
33
|
-
loading ? main_module.default(core.Spinner, { size: 12 }) : null,
|
|
34
|
-
main_module.default("span.load-progress-label", [
|
|
35
|
-
`Page ${page + 1}`,
|
|
36
|
-
totalPages != null ? ` of ${totalPages}` : ""
|
|
37
|
-
]),
|
|
38
|
-
main_module.default(core.ButtonGroup, { minimal: true }, [
|
|
39
|
-
main_module.default(core.Button, {
|
|
40
|
-
icon: "chevron-left",
|
|
41
|
-
small: true,
|
|
42
|
-
disabled: page <= 0 || loading,
|
|
43
|
-
onClick: () => setPage(Math.max(0, page - 1))
|
|
44
|
-
}),
|
|
45
|
-
main_module.default(core.Button, {
|
|
46
|
-
icon: "chevron-right",
|
|
47
|
-
small: true,
|
|
48
|
-
disabled: atEnd || loading,
|
|
49
|
-
onClick: () => setPage(page + 1)
|
|
50
|
-
})
|
|
51
|
-
])
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
exports.LoadProgressIndicator = LoadProgressIndicator;
|
|
55
|
-
//# sourceMappingURL=view-info.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-info.cjs","sources":["../../src/components/view-info.ts"],"sourcesContent":["import h from \"../postgrest-table/main.module.sass\";\nimport {\n ViewInfo,\n viewInfoAtom,\n tableFooterAtom,\n chunkPageAtom,\n} from \"../postgrest-table\";\nimport { ctx } from \"../provider.ts\";\nimport { Button, ButtonGroup, Icon, Spinner } from \"@blueprintjs/core\";\n\nfunction VisibleRegionControl() {\n const viewInfo: ViewInfo = ctx.useValue(viewInfoAtom);\n\n return h(\"p\", [\n `Rows ${viewInfo.visibleRegion.rowIndexStart}–${viewInfo.visibleRegion.rowIndexEnd}`,\n \" of \",\n h(\"span.total-count\", viewInfo.totalCount),\n ]);\n}\n\n/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In\n * scroll mode: rows loaded, \"of total\" when known, and a status icon (spinner\n * loading / check complete / dots incomplete). In paged mode: prev/next page\n * controls with \"Page X of Y\". */\nexport function LoadProgressIndicator() {\n const footer = ctx.useValue(tableFooterAtom);\n if (footer.mode === \"paged\") return h(PageControl);\n\n const { loaded, total, loading } = footer;\n let status: any;\n if (loading) {\n status = h(Spinner, { size: 12 });\n } else if (total != null && loaded >= total) {\n status = h(Icon, { icon: \"tick-circle\", intent: \"success\", size: 12 });\n } else {\n status = h(Icon, { icon: \"more\", size: 12 });\n }\n\n return h(\"div.load-progress\", [\n h(\"span.load-progress-label\", [\n `${loaded}`,\n total != null ? ` of ${total}` : \"\",\n \" rows\",\n ]),\n status,\n ]);\n}\n\n/** Prev/next pager for paged fetch mode. */\nfunction PageControl() {\n const { page, totalPages, loading } = ctx.useValue(tableFooterAtom);\n const setPage = ctx.useSet(chunkPageAtom);\n const atEnd = totalPages != null && page >= totalPages - 1;\n\n return h(\"div.load-progress\", [\n loading ? h(Spinner, { size: 12 }) : null,\n h(\"span.load-progress-label\", [\n `Page ${page + 1}`,\n totalPages != null ? ` of ${totalPages}` : \"\",\n ]),\n h(ButtonGroup, { minimal: true }, [\n h(Button, {\n icon: \"chevron-left\",\n small: true,\n disabled: page <= 0 || loading,\n onClick: () => setPage(Math.max(0, page - 1)),\n }),\n h(Button, {\n icon: \"chevron-right\",\n small: true,\n disabled: atEnd || loading,\n onClick: () => setPage(page + 1),\n }),\n ]),\n ]);\n}\n"],"names":["ctx","tableFooterAtom","h","Spinner","Icon","chunkPageAtom","ButtonGroup","Button"],"mappings":";;;;;;AAwBO,SAAS,wBAAwB;AACtC,QAAM,SAASA,SAAAA,IAAI,SAASC,2BAAe;AAC3C,MAAI,OAAO,SAAS,QAAS,QAAOC,YAAAA,QAAE,WAAW;AAEjD,QAAM,EAAE,QAAQ,OAAO,QAAA,IAAY;AACnC,MAAI;AACJ,MAAI,SAAS;AACX,aAASA,YAAAA,QAAEC,KAAAA,SAAS,EAAE,MAAM,IAAI;AAAA,EAClC,WAAW,SAAS,QAAQ,UAAU,OAAO;AAC3C,aAASD,YAAAA,QAAEE,KAAAA,MAAM,EAAE,MAAM,eAAe,QAAQ,WAAW,MAAM,IAAI;AAAA,EACvE,OAAO;AACL,aAASF,YAAAA,QAAEE,WAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C;AAEA,SAAOF,YAAAA,QAAE,qBAAqB;AAAA,IAC5BA,YAAAA,QAAE,4BAA4B;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT,SAAS,OAAO,OAAO,KAAK,KAAK;AAAA,MACjC;AAAA,IAAA,CACD;AAAA,IACD;AAAA,EAAA,CACD;AACH;AAGA,SAAS,cAAc;AACrB,QAAM,EAAE,MAAM,YAAY,YAAYF,SAAAA,IAAI,SAASC,2BAAe;AAClE,QAAM,UAAUD,SAAAA,IAAI,OAAOK,yBAAa;AACxC,QAAM,QAAQ,cAAc,QAAQ,QAAQ,aAAa;AAEzD,SAAOH,YAAAA,QAAE,qBAAqB;AAAA,IAC5B,UAAUA,YAAAA,QAAEC,KAAAA,SAAS,EAAE,MAAM,GAAA,CAAI,IAAI;AAAA,IACrCD,YAAAA,QAAE,4BAA4B;AAAA,MAC5B,QAAQ,OAAO,CAAC;AAAA,MAChB,cAAc,OAAO,OAAO,UAAU,KAAK;AAAA,IAAA,CAC5C;AAAA,IACDA,YAAAA,QAAEI,KAAAA,aAAa,EAAE,SAAS,QAAQ;AAAA,MAChCJ,YAAAA,QAAEK,KAAAA,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,QAAQ,KAAK;AAAA,QACvB,SAAS,MAAM,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC;AAAA,MAAA,CAC7C;AAAA,MACDL,YAAAA,QAAEK,KAAAA,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,SAAS;AAAA,QACnB,SAAS,MAAM,QAAQ,OAAO,CAAC;AAAA,MAAA,CAChC;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In
|
|
2
|
-
* scroll mode: rows loaded, "of total" when known, and a status icon (spinner
|
|
3
|
-
* loading / check complete / dots incomplete). In paged mode: prev/next page
|
|
4
|
-
* controls with "Page X of Y". */
|
|
5
|
-
export declare function LoadProgressIndicator(): import('react').DOMElement<import('react').DOMAttributes<Element>, Element> | import('react').FunctionComponentElement<{}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-info.js","sources":["../../src/components/view-info.ts"],"sourcesContent":["import h from \"../postgrest-table/main.module.sass\";\nimport {\n ViewInfo,\n viewInfoAtom,\n tableFooterAtom,\n chunkPageAtom,\n} from \"../postgrest-table\";\nimport { ctx } from \"../provider.ts\";\nimport { Button, ButtonGroup, Icon, Spinner } from \"@blueprintjs/core\";\n\nfunction VisibleRegionControl() {\n const viewInfo: ViewInfo = ctx.useValue(viewInfoAtom);\n\n return h(\"p\", [\n `Rows ${viewInfo.visibleRegion.rowIndexStart}–${viewInfo.visibleRegion.rowIndexEnd}`,\n \" of \",\n h(\"span.total-count\", viewInfo.totalCount),\n ]);\n}\n\n/** A minimal bottom-of-table footer reflecting the `useChunkLoader` source. In\n * scroll mode: rows loaded, \"of total\" when known, and a status icon (spinner\n * loading / check complete / dots incomplete). In paged mode: prev/next page\n * controls with \"Page X of Y\". */\nexport function LoadProgressIndicator() {\n const footer = ctx.useValue(tableFooterAtom);\n if (footer.mode === \"paged\") return h(PageControl);\n\n const { loaded, total, loading } = footer;\n let status: any;\n if (loading) {\n status = h(Spinner, { size: 12 });\n } else if (total != null && loaded >= total) {\n status = h(Icon, { icon: \"tick-circle\", intent: \"success\", size: 12 });\n } else {\n status = h(Icon, { icon: \"more\", size: 12 });\n }\n\n return h(\"div.load-progress\", [\n h(\"span.load-progress-label\", [\n `${loaded}`,\n total != null ? ` of ${total}` : \"\",\n \" rows\",\n ]),\n status,\n ]);\n}\n\n/** Prev/next pager for paged fetch mode. */\nfunction PageControl() {\n const { page, totalPages, loading } = ctx.useValue(tableFooterAtom);\n const setPage = ctx.useSet(chunkPageAtom);\n const atEnd = totalPages != null && page >= totalPages - 1;\n\n return h(\"div.load-progress\", [\n loading ? h(Spinner, { size: 12 }) : null,\n h(\"span.load-progress-label\", [\n `Page ${page + 1}`,\n totalPages != null ? ` of ${totalPages}` : \"\",\n ]),\n h(ButtonGroup, { minimal: true }, [\n h(Button, {\n icon: \"chevron-left\",\n small: true,\n disabled: page <= 0 || loading,\n onClick: () => setPage(Math.max(0, page - 1)),\n }),\n h(Button, {\n icon: \"chevron-right\",\n small: true,\n disabled: atEnd || loading,\n onClick: () => setPage(page + 1),\n }),\n ]),\n ]);\n}\n"],"names":[],"mappings":";;;;AAwBO,SAAS,wBAAwB;AACtC,QAAM,SAAS,IAAI,SAAS,eAAe;AAC3C,MAAI,OAAO,SAAS,QAAS,QAAO,EAAE,WAAW;AAEjD,QAAM,EAAE,QAAQ,OAAO,QAAA,IAAY;AACnC,MAAI;AACJ,MAAI,SAAS;AACX,aAAS,EAAE,SAAS,EAAE,MAAM,IAAI;AAAA,EAClC,WAAW,SAAS,QAAQ,UAAU,OAAO;AAC3C,aAAS,EAAE,MAAM,EAAE,MAAM,eAAe,QAAQ,WAAW,MAAM,IAAI;AAAA,EACvE,OAAO;AACL,aAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,MAAM,IAAI;AAAA,EAC7C;AAEA,SAAO,EAAE,qBAAqB;AAAA,IAC5B,EAAE,4BAA4B;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT,SAAS,OAAO,OAAO,KAAK,KAAK;AAAA,MACjC;AAAA,IAAA,CACD;AAAA,IACD;AAAA,EAAA,CACD;AACH;AAGA,SAAS,cAAc;AACrB,QAAM,EAAE,MAAM,YAAY,YAAY,IAAI,SAAS,eAAe;AAClE,QAAM,UAAU,IAAI,OAAO,aAAa;AACxC,QAAM,QAAQ,cAAc,QAAQ,QAAQ,aAAa;AAEzD,SAAO,EAAE,qBAAqB;AAAA,IAC5B,UAAU,EAAE,SAAS,EAAE,MAAM,GAAA,CAAI,IAAI;AAAA,IACrC,EAAE,4BAA4B;AAAA,MAC5B,QAAQ,OAAO,CAAC;AAAA,MAChB,cAAc,OAAO,OAAO,UAAU,KAAK;AAAA,IAAA,CAC5C;AAAA,IACD,EAAE,aAAa,EAAE,SAAS,QAAQ;AAAA,MAChC,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,QAAQ,KAAK;AAAA,QACvB,SAAS,MAAM,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC;AAAA,MAAA,CAC7C;AAAA,MACD,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,SAAS;AAAA,QACnB,SAAS,MAAM,QAAQ,OAAO,CAAC;AAAA,MAAA,CAChC;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;"}
|
package/dist/core.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.cjs","sources":["../src/core.ts"],"sourcesContent":["import { useHotkeys } from \"@blueprintjs/core\";\nimport {\n Column,\n Region,\n RegionCardinality,\n RowHeaderCell,\n Table,\n TableProps,\n} from \"@blueprintjs/table\";\nimport \"@blueprintjs/table/lib/css/table.css\";\nimport { ReactNode, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { LoadProgressIndicator } from \"./components\";\nimport { renderColumnHeaderCell } from \"./renderers\";\nimport h from \"./main.module.sass\";\nimport {\n columnSpecAtom,\n ctx,\n DataSheetProvider,\n storeAtom,\n tableActionsAtom,\n useSelector,\n useStoreAPI,\n} from \"./provider\";\nimport { atom } from \"jotai\";\nimport {\n DataSheetProviderProps,\n DEFAULT_ROW_STATUS_STYLES,\n EditEvent,\n RowHeaderRenderContext,\n RowStatusStyles,\n TableElementStatus,\n VisibleCells,\n} from \"./types.ts\";\nimport { basicCellRenderer } from \"./cell-renderer.ts\";\nimport {\n CellRendererDebugOverlay,\n tableHotkeysAtom,\n type ColumnSpec,\n} from \"./utils\";\nimport {\n ActionsToolbar,\n clipboardActions,\n columnControlActions,\n createSaveAction,\n FilterBar,\n resetChangesAction,\n TableAction,\n TableActionContext,\n TableFilter,\n} from \"./actions\";\nimport {\n createLocalProvider,\n dataRefreshTokenAtom,\n FetchData,\n FetchDataOptions,\n tableFooterAtom,\n TableDataProvider,\n useScrollHandler,\n useDataLoader,\n} from \"./postgrest-table\";\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\nexport enum DataSheetDensity {\n HIGH = \"high\",\n MEDIUM = \"medium\",\n LOW = \"low\",\n}\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\n/**\n * How selecting a cell activates its surface (an editor, or a read-only detail\n * panel):\n * - `\"auto\"` (default when `autoFocusEditor` is `true`): open the surface on\n * selection and, for editors, focus it. Editors relinquish focus at their\n * edges — arrow past the start/end of a text cell, or press Escape, and focus\n * returns to the table — so the keyboard stays operable without the mouse.\n * Pressing Escape drops into navigation mode (surfaces stop auto-opening)\n * until the next click.\n * - `\"manual\"` (default when `autoFocusEditor` is `false`): the surface stays\n * closed until the cell is clicked; arrow keys always navigate the table.\n */\nexport type CellInteraction = \"auto\" | \"manual\";\n\ninterface DataSheetInternalProps<T> extends TableProps, FetchDataOptions {\n /** In-memory rows. Internally wrapped in a local `TableDataProvider` and\n * driven through the same loader as any other source. */\n data?: T[];\n /** Passed through from the public props so a function form can be derived\n * from the loaded rows here (a static array is handled by the provider). */\n columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);\n // function to fetch a chunk of data (the read side of a data provider)\n fetchData?: FetchData<T>;\n /** A data provider instantiated separately and passed in — bundles the read\n * side (`fetchData` + `identity`) and, optionally, the persistence side\n * (`saveRows` / `deleteRows` / `insertRow`) that drives the Save action. An\n * explicit alternative to the loose `data` / `fetchData` / `identity` props;\n * takes precedence when given. */\n provider?: TableDataProvider<T>;\n // An optional table name that will be used in toolbars if given\n name?: string;\n onVisibleCellsChange?: (visibleCells: VisibleCells) => void;\n onUpdateData?: (updatedData: any[], data: T[]) => void;\n /** Observer called for every user edit as a structured `EditEvent`\n * (Workstream A). Additive: the built-in `updatedData` overlay still\n * applies. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Controlled edited-cell overlay (Workstream A). When provided, it is\n * synced into the store as the source of truth for edited values — pair with\n * `onEdit` to own edit state externally (e.g. an ops model). Optimistic\n * in-table edits are superseded by the next value you pass back. */\n updatedData?: T[];\n /** Controlled row-status overlay (edited / added / deleted), the companion\n * to `updatedData`. */\n rowStatus?: TableElementStatus[];\n /** Row identity for the edit overlay — stable across a provider re-sort (a\n * data provider supplies its own; defaults to `(row) => row?.id`). Lets edits\n * survive a re-ordered re-fetch. */\n identity?: (row: T) => string | number | null | undefined;\n /** Derive the controlled edit overlay from the loaded rows, *inside* the\n * sheet. For provider-backed tables whose overlay is a function of the loaded\n * data plus external edit state (e.g. an ops stack): the library owns the\n * rows, so it calls this with them and uses the result as the controlled\n * overlay, re-deriving when the rows — or this function's identity (close it\n * over your edit state) — change. Supersedes `updatedData`/`rowStatus`. */\n deriveOverlay?: (rows: T[]) => {\n updatedData: T[];\n rowStatus: TableElementStatus[];\n };\n /** Bump to force the data provider to re-fetch from scratch (e.g. after a\n * save/delete that invalidated the loaded rows). */\n refreshToken?: number | string;\n /** Persistence handler for the built-in Save action. When provided, a Save\n * control is added to the toolbar (always visible, disabled when there are\n * no pending changes). */\n onSave?: (ctx: TableActionContext<T>) => void | Promise<void>;\n onDeleteRows?: (selection: Region[]) => void;\n verbose?: boolean;\n enableColumnReordering?: boolean;\n enableClipboard?: boolean;\n enableFocusedCell?: boolean;\n editable?: boolean;\n /** @deprecated Prefer `cellInteraction`. `true` maps to `\"auto\"`,\n * `false` to `\"manual\"`. */\n autoFocusEditor?: boolean;\n /** How selecting a cell activates its surface (editor or detail panel).\n * Defaults from `autoFocusEditor` for backward compatibility. */\n cellInteraction?: CellInteraction;\n density?: DataSheetDensity;\n /** Configurable table actions shown in a selection-aware toolbar.\n * When provided, the actions toolbar renders alongside the existing\n * edit toolbar. Actions are filtered by the current selection cardinality. */\n actions?: TableAction<T>[];\n /** Available column/table filters shown in a filter bar.\n * Filters can also be defined per-column via `ColumnSpec.filters`. */\n filters?: TableFilter<T>[];\n /** Optional custom column header cell renderer, called for each column.\n * Receives the ColumnSpec and column index; should return a React element\n * (typically a Blueprint ColumnHeaderCell). */\n columnHeaderCellRenderer?: (col: any, colIndex: number) => ReactNode;\n /** Arbitrary nodes for the bottom status bar (left group), rendered beside\n * the active sort/filter tags — the home for view-state controls (show/hide\n * omitted rows/columns, a group-by indicator, etc.). */\n statusBar?: ReactNode;\n /** Presentation per row-status value, merged over the built-in defaults\n * (which style `\"deleted\"`). Supply styles for consumer-defined statuses\n * (e.g. `\"omitted\"`) and/or override the defaults. Each entry may set the\n * cells' style/intent and the row header's style. */\n rowStatusStyles?: RowStatusStyles;\n /** Render the content of a row's header cell (the left gutter). Receives the\n * row, its status, and the default 1-based label; return a node to use, or a\n * nullish value to keep the default. For group-key labels, omit indicators,\n * etc. Header-cell *styling* still comes from `rowStatusStyles`. */\n rowHeaderRenderer?: (ctx: RowHeaderRenderContext<T>) => ReactNode;\n}\n\ntype DataSheetProps<T> = DataSheetProviderProps<T> & DataSheetInternalProps<T>;\n\nconst emptyData: any[] = [];\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 ...rest\n } = props;\n\n return h(\n DataSheetProvider<T>,\n {\n data: data ?? emptyData,\n columnSpec,\n columnSpecOptions,\n enableColumnReordering,\n defaultColumnWidth,\n editable,\n ...rest,\n },\n h(_DataSheet<any>, {\n ...rest,\n data: data ?? emptyData,\n columnSpec,\n children,\n editable,\n enableColumnReordering,\n enableFocusedCell,\n }),\n );\n}\n\n/** Persist all pending changes through a data provider: added rows via\n * `insertRow`, edited rows via `saveRows`, deleted rows via `deleteRows`\n * (addressed by `provider.identity`). Used by the built-in Save action when an\n * explicit provider owns persistence. */\nasync function persistViaProvider<T>(\n provider: TableDataProvider<T>,\n ctx: TableActionContext<T>,\n): Promise<void> {\n const base = (ctx.data ?? []) as any[];\n const updates = (ctx.updatedData ?? []) as any[];\n const status = (ctx.rowStatus ?? []) as any[];\n const n = Math.max(base.length, updates.length, status.length);\n const toSave: T[] = [];\n const toInsert: T[] = [];\n const toDelete: Array<string | number> = [];\n for (let i = 0; i < n; i++) {\n if (status[i] === TableElementStatus.DELETED) {\n const id = provider.identity(base[i]);\n if (id != null) toDelete.push(id);\n continue;\n }\n const upd = updates[i];\n const hasEdit =\n upd != null && typeof upd === \"object\" && Object.keys(upd).length > 0;\n if (status[i] === TableElementStatus.ADDED) {\n toInsert.push({ ...base[i], ...upd } as T);\n } else if (hasEdit) {\n toSave.push({ ...base[i], ...upd } as T);\n }\n }\n if (toDelete.length > 0 && provider.deleteRows != null) {\n await provider.deleteRows(toDelete);\n }\n for (const row of toInsert) {\n if (provider.insertRow != null) await provider.insertRow(row);\n }\n if (toSave.length > 0 && provider.saveRows != null) {\n await provider.saveRows(toSave);\n }\n}\n\nfunction _DataSheet<T>({\n data: sourceData,\n fetchData,\n provider,\n pageSize,\n fetchMode,\n onVisibleCellsChange,\n onUpdateData,\n onEdit,\n onSave,\n updatedData: updatedDataProp,\n rowStatus: rowStatusProp,\n identity,\n deriveOverlay,\n refreshToken,\n onDeleteRows,\n name,\n verbose = false,\n enableFocusedCell,\n autoFocusEditor = true,\n cellInteraction,\n enableClipboard = true,\n density = DataSheetDensity.HIGH,\n selectionModes,\n actions,\n filters,\n columnHeaderCellRenderer,\n columnSpec: columnSpecProp,\n statusBar,\n rowStatusStyles,\n rowHeaderRenderer,\n children,\n ...rest\n}: DataSheetInternalProps<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 // Turn on debug features\n const debugMode = false;\n\n const editable = useSelector((state) => state.editable);\n\n // Resolve the active data provider: an explicit `provider` prop wins; else a\n // loose `fetchData` (+ identity) is wrapped as one; else in-memory `data`\n // becomes a local provider. Local and remote thus share one path, and the\n // provider is an explicit contract rather than a set of scattered props.\n const isLocalProvider = provider == null && fetchData == null;\n const activeProvider = useMemo<TableDataProvider<any> | null>(() => {\n if (provider != null) return provider;\n if (fetchData != null) {\n return { fetchData, identity: identity ?? ((r: any) => r?.id) };\n }\n if (sourceData != null && sourceData.length > 0) {\n return createLocalProvider(\n sourceData,\n identity != null ? { identity } : undefined,\n );\n }\n return null;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [provider, fetchData, sourceData, identity]);\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 ctx.useSync(tableActionsAtom, _actions);\n\n const hotkeysConfig = ctx.useValue(tableHotkeysAtom);\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 const holderStyle =\n footerInfo.mode === \"paged\"\n ? {\n flex: \"0 0 auto\" as const,\n height: numRows * rowHeight + COLUMN_HEADER_HEIGHT,\n }\n : undefined;\n\n const onColumnsReordered = useSelector((state) => state.onColumnsReordered);\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 const loadedData = useSelector((state) => state.data);\n useEffect(() => {\n if (deriveOverlay == null) return;\n const overlay = deriveOverlay(loadedData);\n storeState.setState({\n updatedData: overlay.updatedData,\n rowStatus: overlay.rowStatus,\n });\n }, [deriveOverlay, loadedData, storeState]);\n\n // Function `columnSpec`: derive the spec from the loaded rows (no separate\n // fetch of sample data). Derive once the first rows arrive, and re-derive\n // when the function's identity changes (a consumer memoizes it over its\n // own view state — hidden columns, order, overrides). Not re-run as more\n // rows page in (guarded by the function identity), so it never clobbers\n // in-store column state on scroll.\n const derivedSpecFor = useRef<unknown>(null);\n useEffect(() => {\n if (typeof columnSpecProp !== \"function\") return;\n if (derivedSpecFor.current === columnSpecProp) return;\n const rows = loadedData.filter((r) => r != null);\n if (rows.length === 0) return;\n derivedSpecFor.current = columnSpecProp;\n storeState.setState({ columnSpec: columnSpecProp(rows) });\n }, [columnSpecProp, loadedData, storeState]);\n\n // Imperative re-fetch: bump `refreshToken` to reload the provider (e.g. after\n // a save). Skips the initial mount (the loader does its own first fetch).\n const bumpRefreshFromToken = ctx.useSet(dataRefreshTokenAtom);\n const firstRefreshToken = useRef(true);\n useEffect(() => {\n if (firstRefreshToken.current) {\n firstRefreshToken.current = false;\n return;\n }\n bumpRefreshFromToken((v) => v + 1);\n }, [refreshToken, bumpRefreshFromToken]);\n\n // The active provider supplies the row identity for the edit overlay.\n useEffect(() => {\n const id = activeProvider?.identity ?? identity;\n if (id != null) storeState.setState({ identity: id });\n }, [storeState, activeProvider, identity]);\n\n // Row deletion is a provider capability: an explicit `provider` without\n // `deleteRows` disables deletion entirely. (Local / loose sources keep the\n // local delete overlay.)\n useEffect(() => {\n const canDeleteRows = provider == null || provider.deleteRows != null;\n storeState.setState({ canDeleteRows });\n }, [storeState, provider]);\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.headerCellRenderer ??\n columnHeaderCellRenderer ??\n renderColumnHeaderCell;\n let activeSort = null;\n let activeFilter = 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 = (colIndex) => {\n return fn({\n col,\n colIndex,\n activeSort,\n activeFilter,\n });\n };\n\n return h(Column, {\n id: col.key,\n name: col.name,\n columnHeaderCellRenderer: _columnHeaderCellRenderer,\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 const dataRowIndex =\n filteredRowIndices != null\n ? (filteredRowIndices[rowIndex] ?? rowIndex)\n : rowIndex;\n const statusVal = rowStatus[dataRowIndex];\n const style =\n (statusVal != null\n ? mergedRowStatusStyles[statusVal]?.headerStyle\n : null) ?? null;\n\n const defaultLabel = `${dataRowIndex + 1}`;\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 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 dataLoader = h(_DataLoaderManager, {\n key: \"__data_loader\",\n fetchData: activeProvider.fetchData,\n pageSize: isLocalProvider\n ? Math.max(sourceData?.length ?? 1, 1)\n : pageSize,\n fetchMode: isLocalProvider ? undefined : fetchMode,\n });\n }\n const showFilterBar =\n (filters != null && filters.length > 0) || hasSortableOrFilterable;\n\n let filterStatus: ReactNode = null;\n if (showFilterBar) {\n filterStatus = h(FilterBar, { 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, tableName: name }),\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,\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n onColumnsReordered,\n focusedCell,\n selectedRegions,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths,\n onColumnWidthChanged,\n onSelection,\n /** TODO: we could enable this, but we need a use-case first... */\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 ...rest,\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(debugMode)(CellRendererDebugOverlay, {\n cellRendererDependencies,\n names: [\n \"data\",\n \"updatedData\",\n \"focusedCell\",\n \"rowStatus\",\n \"filteredRowIndices\",\n ],\n }),\n ]);\n}\n\nconst columnWidthsIndexAtom = atom((get) => get(storeAtom).columnWidthsIndex);\nconst defaultColumnWidthAtom = atom((get) => get(storeAtom).defaultColumnWidth);\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 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\nexport function getRowsToDelete(selection) {\n let rowIndices: number[] = [];\n for (const sel of selection) {\n // This isn't a full-row selection\n if (sel.cols != null) continue;\n if (sel.rows == null) continue;\n const [startIndex, endIndex] = sel.rows;\n for (let i = startIndex; i <= endIndex; i++) {\n rowIndices.push(i);\n }\n }\n return rowIndices;\n}\n"],"names":["DataSheetDensity","h","DataSheetProvider","provider","ctx","TableElementStatus","filters","useSelector","useMemo","createLocalProvider","dataRefreshTokenAtom","_actions","columnControlActions","clipboardActions","createSaveAction","resetChangesAction","tableActionsAtom","tableHotkeysAtom","useHotkeys","useStoreAPI","useScrollHandler","useCallback","useEffect","useRef","tableFooterAtom","DEFAULT_ROW_STATUS_STYLES","renderColumnHeaderCell","colIndex","Column","basicCellRenderer","style","name","RowHeaderCell","RegionCardinality","FilterBar","ActionsToolbar","Table","LoadProgressIndicator","CellRendererDebugOverlay","atom","storeAtom","columnSpecAtom","useDataLoader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkEO,IAAK,qCAAAA,sBAAL;AACLA,oBAAA,MAAA,IAAO;AACPA,oBAAA,QAAA,IAAS;AACTA,oBAAA,KAAA,IAAM;AAHI,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAQZ,MAAM,uBAAuB;AA8G7B,MAAM,YAAmB,CAAA;AAElB,SAAS,UAAa,OAA0B;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,yBAAyB;AAAA,IACzB,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AAQ,KAAM;AACtB,UAAM,CAAC,YAAY,QAAQ,IAAI,IAAI;AACnC,aAAS,IAAI,YAAY,KAAK,UAAU,KAAK;AAC3C,iBAAW,KAAK,CAAC;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;;;;"}
|
package/dist/core.d.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { Region, TableProps } from '@blueprintjs/table';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { DataSheetProviderProps, EditEvent, RowHeaderRenderContext, RowStatusStyles, TableElementStatus, VisibleCells } from './types.ts';
|
|
4
|
-
import { ColumnSpec } from './utils';
|
|
5
|
-
import { TableAction, TableActionContext, TableFilter } from './actions';
|
|
6
|
-
import { FetchData, FetchDataOptions, TableDataProvider } from './postgrest-table';
|
|
7
|
-
export declare enum DataSheetDensity {
|
|
8
|
-
HIGH = "high",
|
|
9
|
-
MEDIUM = "medium",
|
|
10
|
-
LOW = "low"
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* How selecting a cell activates its surface (an editor, or a read-only detail
|
|
14
|
-
* panel):
|
|
15
|
-
* - `"auto"` (default when `autoFocusEditor` is `true`): open the surface on
|
|
16
|
-
* selection and, for editors, focus it. Editors relinquish focus at their
|
|
17
|
-
* edges — arrow past the start/end of a text cell, or press Escape, and focus
|
|
18
|
-
* returns to the table — so the keyboard stays operable without the mouse.
|
|
19
|
-
* Pressing Escape drops into navigation mode (surfaces stop auto-opening)
|
|
20
|
-
* until the next click.
|
|
21
|
-
* - `"manual"` (default when `autoFocusEditor` is `false`): the surface stays
|
|
22
|
-
* closed until the cell is clicked; arrow keys always navigate the table.
|
|
23
|
-
*/
|
|
24
|
-
export type CellInteraction = "auto" | "manual";
|
|
25
|
-
interface DataSheetInternalProps<T> extends TableProps, FetchDataOptions {
|
|
26
|
-
/** In-memory rows. Internally wrapped in a local `TableDataProvider` and
|
|
27
|
-
* driven through the same loader as any other source. */
|
|
28
|
-
data?: T[];
|
|
29
|
-
/** Passed through from the public props so a function form can be derived
|
|
30
|
-
* from the loaded rows here (a static array is handled by the provider). */
|
|
31
|
-
columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);
|
|
32
|
-
fetchData?: FetchData<T>;
|
|
33
|
-
/** A data provider instantiated separately and passed in — bundles the read
|
|
34
|
-
* side (`fetchData` + `identity`) and, optionally, the persistence side
|
|
35
|
-
* (`saveRows` / `deleteRows` / `insertRow`) that drives the Save action. An
|
|
36
|
-
* explicit alternative to the loose `data` / `fetchData` / `identity` props;
|
|
37
|
-
* takes precedence when given. */
|
|
38
|
-
provider?: TableDataProvider<T>;
|
|
39
|
-
name?: string;
|
|
40
|
-
onVisibleCellsChange?: (visibleCells: VisibleCells) => void;
|
|
41
|
-
onUpdateData?: (updatedData: any[], data: T[]) => void;
|
|
42
|
-
/** Observer called for every user edit as a structured `EditEvent`
|
|
43
|
-
* (Workstream A). Additive: the built-in `updatedData` overlay still
|
|
44
|
-
* applies. */
|
|
45
|
-
onEdit?: (event: EditEvent<T>) => void;
|
|
46
|
-
/** Controlled edited-cell overlay (Workstream A). When provided, it is
|
|
47
|
-
* synced into the store as the source of truth for edited values — pair with
|
|
48
|
-
* `onEdit` to own edit state externally (e.g. an ops model). Optimistic
|
|
49
|
-
* in-table edits are superseded by the next value you pass back. */
|
|
50
|
-
updatedData?: T[];
|
|
51
|
-
/** Controlled row-status overlay (edited / added / deleted), the companion
|
|
52
|
-
* to `updatedData`. */
|
|
53
|
-
rowStatus?: TableElementStatus[];
|
|
54
|
-
/** Row identity for the edit overlay — stable across a provider re-sort (a
|
|
55
|
-
* data provider supplies its own; defaults to `(row) => row?.id`). Lets edits
|
|
56
|
-
* survive a re-ordered re-fetch. */
|
|
57
|
-
identity?: (row: T) => string | number | null | undefined;
|
|
58
|
-
/** Derive the controlled edit overlay from the loaded rows, *inside* the
|
|
59
|
-
* sheet. For provider-backed tables whose overlay is a function of the loaded
|
|
60
|
-
* data plus external edit state (e.g. an ops stack): the library owns the
|
|
61
|
-
* rows, so it calls this with them and uses the result as the controlled
|
|
62
|
-
* overlay, re-deriving when the rows — or this function's identity (close it
|
|
63
|
-
* over your edit state) — change. Supersedes `updatedData`/`rowStatus`. */
|
|
64
|
-
deriveOverlay?: (rows: T[]) => {
|
|
65
|
-
updatedData: T[];
|
|
66
|
-
rowStatus: TableElementStatus[];
|
|
67
|
-
};
|
|
68
|
-
/** Bump to force the data provider to re-fetch from scratch (e.g. after a
|
|
69
|
-
* save/delete that invalidated the loaded rows). */
|
|
70
|
-
refreshToken?: number | string;
|
|
71
|
-
/** Persistence handler for the built-in Save action. When provided, a Save
|
|
72
|
-
* control is added to the toolbar (always visible, disabled when there are
|
|
73
|
-
* no pending changes). */
|
|
74
|
-
onSave?: (ctx: TableActionContext<T>) => void | Promise<void>;
|
|
75
|
-
onDeleteRows?: (selection: Region[]) => void;
|
|
76
|
-
verbose?: boolean;
|
|
77
|
-
enableColumnReordering?: boolean;
|
|
78
|
-
enableClipboard?: boolean;
|
|
79
|
-
enableFocusedCell?: boolean;
|
|
80
|
-
editable?: boolean;
|
|
81
|
-
/** @deprecated Prefer `cellInteraction`. `true` maps to `"auto"`,
|
|
82
|
-
* `false` to `"manual"`. */
|
|
83
|
-
autoFocusEditor?: boolean;
|
|
84
|
-
/** How selecting a cell activates its surface (editor or detail panel).
|
|
85
|
-
* Defaults from `autoFocusEditor` for backward compatibility. */
|
|
86
|
-
cellInteraction?: CellInteraction;
|
|
87
|
-
density?: DataSheetDensity;
|
|
88
|
-
/** Configurable table actions shown in a selection-aware toolbar.
|
|
89
|
-
* When provided, the actions toolbar renders alongside the existing
|
|
90
|
-
* edit toolbar. Actions are filtered by the current selection cardinality. */
|
|
91
|
-
actions?: TableAction<T>[];
|
|
92
|
-
/** Available column/table filters shown in a filter bar.
|
|
93
|
-
* Filters can also be defined per-column via `ColumnSpec.filters`. */
|
|
94
|
-
filters?: TableFilter<T>[];
|
|
95
|
-
/** Optional custom column header cell renderer, called for each column.
|
|
96
|
-
* Receives the ColumnSpec and column index; should return a React element
|
|
97
|
-
* (typically a Blueprint ColumnHeaderCell). */
|
|
98
|
-
columnHeaderCellRenderer?: (col: any, colIndex: number) => ReactNode;
|
|
99
|
-
/** Arbitrary nodes for the bottom status bar (left group), rendered beside
|
|
100
|
-
* the active sort/filter tags — the home for view-state controls (show/hide
|
|
101
|
-
* omitted rows/columns, a group-by indicator, etc.). */
|
|
102
|
-
statusBar?: ReactNode;
|
|
103
|
-
/** Presentation per row-status value, merged over the built-in defaults
|
|
104
|
-
* (which style `"deleted"`). Supply styles for consumer-defined statuses
|
|
105
|
-
* (e.g. `"omitted"`) and/or override the defaults. Each entry may set the
|
|
106
|
-
* cells' style/intent and the row header's style. */
|
|
107
|
-
rowStatusStyles?: RowStatusStyles;
|
|
108
|
-
/** Render the content of a row's header cell (the left gutter). Receives the
|
|
109
|
-
* row, its status, and the default 1-based label; return a node to use, or a
|
|
110
|
-
* nullish value to keep the default. For group-key labels, omit indicators,
|
|
111
|
-
* etc. Header-cell *styling* still comes from `rowStatusStyles`. */
|
|
112
|
-
rowHeaderRenderer?: (ctx: RowHeaderRenderContext<T>) => ReactNode;
|
|
113
|
-
}
|
|
114
|
-
type DataSheetProps<T> = DataSheetProviderProps<T> & DataSheetInternalProps<T>;
|
|
115
|
-
export declare function DataSheet<T>(props: DataSheetProps<T>): import('react').FunctionComponentElement<DataSheetProviderProps<T>>;
|
|
116
|
-
export declare function getRowsToDelete(selection: any): number[];
|
|
117
|
-
export {};
|
package/dist/core.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../src/core.ts"],"sourcesContent":["import { useHotkeys } from \"@blueprintjs/core\";\nimport {\n Column,\n Region,\n RegionCardinality,\n RowHeaderCell,\n Table,\n TableProps,\n} from \"@blueprintjs/table\";\nimport \"@blueprintjs/table/lib/css/table.css\";\nimport { ReactNode, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { LoadProgressIndicator } from \"./components\";\nimport { renderColumnHeaderCell } from \"./renderers\";\nimport h from \"./main.module.sass\";\nimport {\n columnSpecAtom,\n ctx,\n DataSheetProvider,\n storeAtom,\n tableActionsAtom,\n useSelector,\n useStoreAPI,\n} from \"./provider\";\nimport { atom } from \"jotai\";\nimport {\n DataSheetProviderProps,\n DEFAULT_ROW_STATUS_STYLES,\n EditEvent,\n RowHeaderRenderContext,\n RowStatusStyles,\n TableElementStatus,\n VisibleCells,\n} from \"./types.ts\";\nimport { basicCellRenderer } from \"./cell-renderer.ts\";\nimport {\n CellRendererDebugOverlay,\n tableHotkeysAtom,\n type ColumnSpec,\n} from \"./utils\";\nimport {\n ActionsToolbar,\n clipboardActions,\n columnControlActions,\n createSaveAction,\n FilterBar,\n resetChangesAction,\n TableAction,\n TableActionContext,\n TableFilter,\n} from \"./actions\";\nimport {\n createLocalProvider,\n dataRefreshTokenAtom,\n FetchData,\n FetchDataOptions,\n tableFooterAtom,\n TableDataProvider,\n useScrollHandler,\n useDataLoader,\n} from \"./postgrest-table\";\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\nexport enum DataSheetDensity {\n HIGH = \"high\",\n MEDIUM = \"medium\",\n LOW = \"low\",\n}\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\n/**\n * How selecting a cell activates its surface (an editor, or a read-only detail\n * panel):\n * - `\"auto\"` (default when `autoFocusEditor` is `true`): open the surface on\n * selection and, for editors, focus it. Editors relinquish focus at their\n * edges — arrow past the start/end of a text cell, or press Escape, and focus\n * returns to the table — so the keyboard stays operable without the mouse.\n * Pressing Escape drops into navigation mode (surfaces stop auto-opening)\n * until the next click.\n * - `\"manual\"` (default when `autoFocusEditor` is `false`): the surface stays\n * closed until the cell is clicked; arrow keys always navigate the table.\n */\nexport type CellInteraction = \"auto\" | \"manual\";\n\ninterface DataSheetInternalProps<T> extends TableProps, FetchDataOptions {\n /** In-memory rows. Internally wrapped in a local `TableDataProvider` and\n * driven through the same loader as any other source. */\n data?: T[];\n /** Passed through from the public props so a function form can be derived\n * from the loaded rows here (a static array is handled by the provider). */\n columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);\n // function to fetch a chunk of data (the read side of a data provider)\n fetchData?: FetchData<T>;\n /** A data provider instantiated separately and passed in — bundles the read\n * side (`fetchData` + `identity`) and, optionally, the persistence side\n * (`saveRows` / `deleteRows` / `insertRow`) that drives the Save action. An\n * explicit alternative to the loose `data` / `fetchData` / `identity` props;\n * takes precedence when given. */\n provider?: TableDataProvider<T>;\n // An optional table name that will be used in toolbars if given\n name?: string;\n onVisibleCellsChange?: (visibleCells: VisibleCells) => void;\n onUpdateData?: (updatedData: any[], data: T[]) => void;\n /** Observer called for every user edit as a structured `EditEvent`\n * (Workstream A). Additive: the built-in `updatedData` overlay still\n * applies. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Controlled edited-cell overlay (Workstream A). When provided, it is\n * synced into the store as the source of truth for edited values — pair with\n * `onEdit` to own edit state externally (e.g. an ops model). Optimistic\n * in-table edits are superseded by the next value you pass back. */\n updatedData?: T[];\n /** Controlled row-status overlay (edited / added / deleted), the companion\n * to `updatedData`. */\n rowStatus?: TableElementStatus[];\n /** Row identity for the edit overlay — stable across a provider re-sort (a\n * data provider supplies its own; defaults to `(row) => row?.id`). Lets edits\n * survive a re-ordered re-fetch. */\n identity?: (row: T) => string | number | null | undefined;\n /** Derive the controlled edit overlay from the loaded rows, *inside* the\n * sheet. For provider-backed tables whose overlay is a function of the loaded\n * data plus external edit state (e.g. an ops stack): the library owns the\n * rows, so it calls this with them and uses the result as the controlled\n * overlay, re-deriving when the rows — or this function's identity (close it\n * over your edit state) — change. Supersedes `updatedData`/`rowStatus`. */\n deriveOverlay?: (rows: T[]) => {\n updatedData: T[];\n rowStatus: TableElementStatus[];\n };\n /** Bump to force the data provider to re-fetch from scratch (e.g. after a\n * save/delete that invalidated the loaded rows). */\n refreshToken?: number | string;\n /** Persistence handler for the built-in Save action. When provided, a Save\n * control is added to the toolbar (always visible, disabled when there are\n * no pending changes). */\n onSave?: (ctx: TableActionContext<T>) => void | Promise<void>;\n onDeleteRows?: (selection: Region[]) => void;\n verbose?: boolean;\n enableColumnReordering?: boolean;\n enableClipboard?: boolean;\n enableFocusedCell?: boolean;\n editable?: boolean;\n /** @deprecated Prefer `cellInteraction`. `true` maps to `\"auto\"`,\n * `false` to `\"manual\"`. */\n autoFocusEditor?: boolean;\n /** How selecting a cell activates its surface (editor or detail panel).\n * Defaults from `autoFocusEditor` for backward compatibility. */\n cellInteraction?: CellInteraction;\n density?: DataSheetDensity;\n /** Configurable table actions shown in a selection-aware toolbar.\n * When provided, the actions toolbar renders alongside the existing\n * edit toolbar. Actions are filtered by the current selection cardinality. */\n actions?: TableAction<T>[];\n /** Available column/table filters shown in a filter bar.\n * Filters can also be defined per-column via `ColumnSpec.filters`. */\n filters?: TableFilter<T>[];\n /** Optional custom column header cell renderer, called for each column.\n * Receives the ColumnSpec and column index; should return a React element\n * (typically a Blueprint ColumnHeaderCell). */\n columnHeaderCellRenderer?: (col: any, colIndex: number) => ReactNode;\n /** Arbitrary nodes for the bottom status bar (left group), rendered beside\n * the active sort/filter tags — the home for view-state controls (show/hide\n * omitted rows/columns, a group-by indicator, etc.). */\n statusBar?: ReactNode;\n /** Presentation per row-status value, merged over the built-in defaults\n * (which style `\"deleted\"`). Supply styles for consumer-defined statuses\n * (e.g. `\"omitted\"`) and/or override the defaults. Each entry may set the\n * cells' style/intent and the row header's style. */\n rowStatusStyles?: RowStatusStyles;\n /** Render the content of a row's header cell (the left gutter). Receives the\n * row, its status, and the default 1-based label; return a node to use, or a\n * nullish value to keep the default. For group-key labels, omit indicators,\n * etc. Header-cell *styling* still comes from `rowStatusStyles`. */\n rowHeaderRenderer?: (ctx: RowHeaderRenderContext<T>) => ReactNode;\n}\n\ntype DataSheetProps<T> = DataSheetProviderProps<T> & DataSheetInternalProps<T>;\n\nconst emptyData: any[] = [];\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 ...rest\n } = props;\n\n return h(\n DataSheetProvider<T>,\n {\n data: data ?? emptyData,\n columnSpec,\n columnSpecOptions,\n enableColumnReordering,\n defaultColumnWidth,\n editable,\n ...rest,\n },\n h(_DataSheet<any>, {\n ...rest,\n data: data ?? emptyData,\n columnSpec,\n children,\n editable,\n enableColumnReordering,\n enableFocusedCell,\n }),\n );\n}\n\n/** Persist all pending changes through a data provider: added rows via\n * `insertRow`, edited rows via `saveRows`, deleted rows via `deleteRows`\n * (addressed by `provider.identity`). Used by the built-in Save action when an\n * explicit provider owns persistence. */\nasync function persistViaProvider<T>(\n provider: TableDataProvider<T>,\n ctx: TableActionContext<T>,\n): Promise<void> {\n const base = (ctx.data ?? []) as any[];\n const updates = (ctx.updatedData ?? []) as any[];\n const status = (ctx.rowStatus ?? []) as any[];\n const n = Math.max(base.length, updates.length, status.length);\n const toSave: T[] = [];\n const toInsert: T[] = [];\n const toDelete: Array<string | number> = [];\n for (let i = 0; i < n; i++) {\n if (status[i] === TableElementStatus.DELETED) {\n const id = provider.identity(base[i]);\n if (id != null) toDelete.push(id);\n continue;\n }\n const upd = updates[i];\n const hasEdit =\n upd != null && typeof upd === \"object\" && Object.keys(upd).length > 0;\n if (status[i] === TableElementStatus.ADDED) {\n toInsert.push({ ...base[i], ...upd } as T);\n } else if (hasEdit) {\n toSave.push({ ...base[i], ...upd } as T);\n }\n }\n if (toDelete.length > 0 && provider.deleteRows != null) {\n await provider.deleteRows(toDelete);\n }\n for (const row of toInsert) {\n if (provider.insertRow != null) await provider.insertRow(row);\n }\n if (toSave.length > 0 && provider.saveRows != null) {\n await provider.saveRows(toSave);\n }\n}\n\nfunction _DataSheet<T>({\n data: sourceData,\n fetchData,\n provider,\n pageSize,\n fetchMode,\n onVisibleCellsChange,\n onUpdateData,\n onEdit,\n onSave,\n updatedData: updatedDataProp,\n rowStatus: rowStatusProp,\n identity,\n deriveOverlay,\n refreshToken,\n onDeleteRows,\n name,\n verbose = false,\n enableFocusedCell,\n autoFocusEditor = true,\n cellInteraction,\n enableClipboard = true,\n density = DataSheetDensity.HIGH,\n selectionModes,\n actions,\n filters,\n columnHeaderCellRenderer,\n columnSpec: columnSpecProp,\n statusBar,\n rowStatusStyles,\n rowHeaderRenderer,\n children,\n ...rest\n}: DataSheetInternalProps<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 // Turn on debug features\n const debugMode = false;\n\n const editable = useSelector((state) => state.editable);\n\n // Resolve the active data provider: an explicit `provider` prop wins; else a\n // loose `fetchData` (+ identity) is wrapped as one; else in-memory `data`\n // becomes a local provider. Local and remote thus share one path, and the\n // provider is an explicit contract rather than a set of scattered props.\n const isLocalProvider = provider == null && fetchData == null;\n const activeProvider = useMemo<TableDataProvider<any> | null>(() => {\n if (provider != null) return provider;\n if (fetchData != null) {\n return { fetchData, identity: identity ?? ((r: any) => r?.id) };\n }\n if (sourceData != null && sourceData.length > 0) {\n return createLocalProvider(\n sourceData,\n identity != null ? { identity } : undefined,\n );\n }\n return null;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [provider, fetchData, sourceData, identity]);\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 ctx.useSync(tableActionsAtom, _actions);\n\n const hotkeysConfig = ctx.useValue(tableHotkeysAtom);\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 const holderStyle =\n footerInfo.mode === \"paged\"\n ? {\n flex: \"0 0 auto\" as const,\n height: numRows * rowHeight + COLUMN_HEADER_HEIGHT,\n }\n : undefined;\n\n const onColumnsReordered = useSelector((state) => state.onColumnsReordered);\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 const loadedData = useSelector((state) => state.data);\n useEffect(() => {\n if (deriveOverlay == null) return;\n const overlay = deriveOverlay(loadedData);\n storeState.setState({\n updatedData: overlay.updatedData,\n rowStatus: overlay.rowStatus,\n });\n }, [deriveOverlay, loadedData, storeState]);\n\n // Function `columnSpec`: derive the spec from the loaded rows (no separate\n // fetch of sample data). Derive once the first rows arrive, and re-derive\n // when the function's identity changes (a consumer memoizes it over its\n // own view state — hidden columns, order, overrides). Not re-run as more\n // rows page in (guarded by the function identity), so it never clobbers\n // in-store column state on scroll.\n const derivedSpecFor = useRef<unknown>(null);\n useEffect(() => {\n if (typeof columnSpecProp !== \"function\") return;\n if (derivedSpecFor.current === columnSpecProp) return;\n const rows = loadedData.filter((r) => r != null);\n if (rows.length === 0) return;\n derivedSpecFor.current = columnSpecProp;\n storeState.setState({ columnSpec: columnSpecProp(rows) });\n }, [columnSpecProp, loadedData, storeState]);\n\n // Imperative re-fetch: bump `refreshToken` to reload the provider (e.g. after\n // a save). Skips the initial mount (the loader does its own first fetch).\n const bumpRefreshFromToken = ctx.useSet(dataRefreshTokenAtom);\n const firstRefreshToken = useRef(true);\n useEffect(() => {\n if (firstRefreshToken.current) {\n firstRefreshToken.current = false;\n return;\n }\n bumpRefreshFromToken((v) => v + 1);\n }, [refreshToken, bumpRefreshFromToken]);\n\n // The active provider supplies the row identity for the edit overlay.\n useEffect(() => {\n const id = activeProvider?.identity ?? identity;\n if (id != null) storeState.setState({ identity: id });\n }, [storeState, activeProvider, identity]);\n\n // Row deletion is a provider capability: an explicit `provider` without\n // `deleteRows` disables deletion entirely. (Local / loose sources keep the\n // local delete overlay.)\n useEffect(() => {\n const canDeleteRows = provider == null || provider.deleteRows != null;\n storeState.setState({ canDeleteRows });\n }, [storeState, provider]);\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.headerCellRenderer ??\n columnHeaderCellRenderer ??\n renderColumnHeaderCell;\n let activeSort = null;\n let activeFilter = 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 = (colIndex) => {\n return fn({\n col,\n colIndex,\n activeSort,\n activeFilter,\n });\n };\n\n return h(Column, {\n id: col.key,\n name: col.name,\n columnHeaderCellRenderer: _columnHeaderCellRenderer,\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 const dataRowIndex =\n filteredRowIndices != null\n ? (filteredRowIndices[rowIndex] ?? rowIndex)\n : rowIndex;\n const statusVal = rowStatus[dataRowIndex];\n const style =\n (statusVal != null\n ? mergedRowStatusStyles[statusVal]?.headerStyle\n : null) ?? null;\n\n const defaultLabel = `${dataRowIndex + 1}`;\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 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 dataLoader = h(_DataLoaderManager, {\n key: \"__data_loader\",\n fetchData: activeProvider.fetchData,\n pageSize: isLocalProvider\n ? Math.max(sourceData?.length ?? 1, 1)\n : pageSize,\n fetchMode: isLocalProvider ? undefined : fetchMode,\n });\n }\n const showFilterBar =\n (filters != null && filters.length > 0) || hasSortableOrFilterable;\n\n let filterStatus: ReactNode = null;\n if (showFilterBar) {\n filterStatus = h(FilterBar, { 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, tableName: name }),\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,\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n onColumnsReordered,\n focusedCell,\n selectedRegions,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths,\n onColumnWidthChanged,\n onSelection,\n /** TODO: we could enable this, but we need a use-case first... */\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 ...rest,\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(debugMode)(CellRendererDebugOverlay, {\n cellRendererDependencies,\n names: [\n \"data\",\n \"updatedData\",\n \"focusedCell\",\n \"rowStatus\",\n \"filteredRowIndices\",\n ],\n }),\n ]);\n}\n\nconst columnWidthsIndexAtom = atom((get) => get(storeAtom).columnWidthsIndex);\nconst defaultColumnWidthAtom = atom((get) => get(storeAtom).defaultColumnWidth);\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 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\nexport function getRowsToDelete(selection) {\n let rowIndices: number[] = [];\n for (const sel of selection) {\n // This isn't a full-row selection\n if (sel.cols != null) continue;\n if (sel.rows == null) continue;\n const [startIndex, endIndex] = sel.rows;\n for (let i = startIndex; i <= endIndex; i++) {\n rowIndices.push(i);\n }\n }\n return rowIndices;\n}\n"],"names":["DataSheetDensity","ctx","_actions","colIndex","style","name"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkEO,IAAK,qCAAAA,sBAAL;AACLA,oBAAA,MAAA,IAAO;AACPA,oBAAA,QAAA,IAAS;AACTA,oBAAA,KAAA,IAAM;AAHI,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAQZ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