@macrostrat/data-sheet 4.11.2 → 4.11.3

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.
@@ -77,7 +77,11 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
77
77
  };
78
78
  const style = statusStyle?.cellStyle != null ? { ...col.style, ...statusStyle.cellStyle } : col.style;
79
79
  const detailPresentation = col.cellDetail != null ? col.detailPresentation ?? "popover" : null;
80
- const derivedClass = col.derived ? "derived-cell" : void 0;
80
+ const locked = tableIsEditable && col.editable === false && !col.derived;
81
+ const valueClass = classNames__default.default({
82
+ "derived-cell": col.derived,
83
+ "readonly-cell": locked
84
+ });
81
85
  const usesCustomCell = col.cellComponent != null || detailPresentation === "inline";
82
86
  if (!topLeft && !usesCustomCell) {
83
87
  return main_module.default(
@@ -87,7 +91,7 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
87
91
  loading,
88
92
  //value,
89
93
  style,
90
- className: derivedClass,
94
+ className: valueClass,
91
95
  interactive: false
92
96
  //disabled: tableIsEditable && !editable,
93
97
  },
@@ -142,7 +146,7 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
142
146
  loading,
143
147
  value,
144
148
  style,
145
- className: derivedClass,
149
+ className: valueClass,
146
150
  disabled: tableIsEditable && !editable,
147
151
  interactive: false,
148
152
  ...cellComponentProps
@@ -252,7 +256,7 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
252
256
  if (_dataEditor != null) {
253
257
  cellContents = _dataEditor;
254
258
  }
255
- const className2 = classNames__default.default("value-viewer-cell", derivedClass);
259
+ const className2 = classNames__default.default("value-viewer-cell", valueClass);
256
260
  return main_module.default(
257
261
  _Cell,
258
262
  {
@@ -1 +1 @@
1
- {"version":3,"file":"cell-renderer.cjs","sources":["../../src/renderers/cell-renderer.ts"],"sourcesContent":["import type {\n ColumnSpec,\n CellRenderContext,\n CellDetailContext,\n DataSheetStore,\n} from \"../provider\";\nimport { TableElementStatus } from \"../provider\";\nimport { editorKeyHandlerAtom, validateCell } from \"../utils\";\nimport h from \"../main.module.sass\";\nimport { memo, ReactNode, useEffect, useRef, useState } from \"react\";\nimport { EditorPopup, CellDetailModal } from \"../components\";\nimport { singleFocusedCell } from \"../provider\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, dragValueHandlerAtom, useSelector } from \"../provider\";\nimport { Intent } from \"@blueprintjs/core\";\nimport classNames from \"classnames\";\n\n/** Two validations are equivalent if they convey the same thing — so a fresh\n * `validateCell` result object doesn't force a re-render when nothing changed. */\nfunction validationEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (a == null || b == null) return a == b;\n return a.severity === b.severity && a.message === b.message;\n}\n\n/** Memoize on the *fields* of `cellContext` (not its identity — it's rebuilt\n * fresh each render), so an unchanged cell skips re-rendering. */\nfunction cellContentsEqual(\n a: { cellContext: CellRenderContext },\n b: { cellContext: CellRenderContext },\n): boolean {\n const x = a.cellContext;\n const y = b.cellContext;\n return (\n x.column === y.column &&\n x.value === y.value &&\n x.row === y.row &&\n x.rowIndex === y.rowIndex &&\n x.colIndex === y.colIndex &&\n x.isEdited === y.isEdited &&\n x.isDeleted === y.isDeleted &&\n x.status === y.status &&\n x.width === y.width &&\n x.height === y.height &&\n validationEqual(x.validation, y.validation)\n );\n}\n\n/** The rendered *content* of a read-only cell — the value renderer's output —\n * memoized on the cell's own inputs. It is placed as the CHILD of a real\n * Blueprint `Cell` (never a wrapper: Blueprint clones the returned `Cell` to\n * position/size it, so the renderer must return a `Cell` directly). This lets a\n * re-render from unrelated state — the focused cell moving, or a\n * scroll-triggered data load that swaps the `data`/overlay arrays — reposition\n * the lightweight `Cell` without re-running this (possibly heavy) value\n * renderer; only cells whose own value/status changed re-render. */\nconst CellContent = memo(function CellContent({\n cellContext,\n}: {\n cellContext: CellRenderContext;\n}) {\n const { value, column } = cellContext;\n if (value == null || value === \"\") return null;\n return column.valueRenderer?.(value, cellContext) ?? value;\n}, cellContentsEqual);\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 =\n 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\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\n ? null\n : validateCell(col, value, row, dataRowIndex);\n\n // A derived column is never writable, whatever `editable` says — see\n // `isColumnWritable`, which every write path in the store applies too.\n const editable =\n (col.editable ?? state.editable) && !isDeleted && !col.derived;\n const tableIsEditable = state.editable;\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 // 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: Intent | 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 // One context object, assembled once and threaded through every path (fast,\n // slow, focused). `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 // The size the table gives the cell (resized columns included), so a\n // renderer that fits itself to it needn't measure\n width:\n state.columnWidthsIndex?.get(col.key) ??\n col.width ??\n state.defaultColumnWidth,\n height: state.rowHeight,\n };\n\n // Only allocate a new style object when a row-status style must be layered on\n // (deleted → dimmed/struck-through; consumer statuses supply their own\n // `cellStyle`). The common case passes the column's own `style` straight\n // through — no per-cell clone, and a stable identity that diffs cheaply.\n // (Nothing downstream mutates `style`.)\n const style =\n statusStyle?.cellStyle != null\n ? { ...col.style, ...statusStyle.cellStyle }\n : col.style;\n\n const detailPresentation =\n col.cellDetail != null ? (col.detailPresentation ?? \"popover\") : null;\n\n // Derived values are drawn dimmed, so a reader can tell a record from a\n // restatement of one. Applied on every path below.\n const derivedClass = col.derived ? \"derived-cell\" : undefined;\n\n // Fast path — any non-focused cell whose *unfocused* appearance is just the\n // value viewer (a plain Blueprint `Cell`). That's everything except a custom\n // `cellComponent` (its own markup on every cell) and an *inline* `cellDetail`\n // (a persistent in-cell surface). A `cellDetail` popover/modal or a\n // `detailRenderer` only surfaces on the focused cell, so unfocused they show\n // the value viewer too — and take the fast path. Return a real `Cell`\n // (Blueprint clones it to position/size it) whose CHILD is the memoized\n // content, so unrelated re-renders (focus moving, a data load that swaps the\n // arrays) reposition the cheap `Cell` without re-running the value renderer.\n const usesCustomCell =\n col.cellComponent != null || detailPresentation === \"inline\";\n if (!topLeft && !usesCustomCell) {\n return h(\n Cell,\n {\n intent,\n loading,\n //value,\n style,\n className: derivedClass,\n interactive: false,\n //disabled: tableIsEditable && !editable,\n },\n h(CellContent, { cellContext }),\n );\n }\n\n const isEmpty = value == null || value === \"\";\n\n const _renderedValue: any = isEmpty\n ? null\n : (col.valueRenderer?.(value, cellContext) ?? value);\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 = 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 // A popover isn't laid out in the cell\n width: undefined,\n height: undefined,\n surface: \"cell\",\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\n if (!topLeft) {\n // Non-focused cell that took the slow path — a custom `cellComponent`, or a\n // `cellDetail` / `detailRenderer` surface. An inline surface is a persistent\n // in-cell renderer (read-only here); others show the value viewer. (The\n // plain default-`Cell` case is handled by the memoized fast path above.)\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 className: derivedClass,\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(\n EditorPopup,\n { valueViewer: _renderedValue, placement: col.detailPlacement },\n content,\n );\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: any = _renderedValue;\n\n let _dataEditor: ReactNode = null;\n let className: string | null = 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 = classNames(\"value-viewer-cell\", derivedClass);\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: any = 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)(CornerDragHandle),\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 CornerDragHandle() {\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 onDragValue = ctx.useValue(dragValueHandlerAtom);\n if (onDragValue == null) return null;\n\n return h(\"div.corner-drag-handle\", {\n onMouseDown: onDragValue,\n });\n}\n"],"names":["memo","CellContent","TableElementStatus","validation","validateCell","h","Cell","CellDetailModal","EditorPopup","value","className","classNames","singleFocusedCell","ctx","editorKeyHandlerAtom","useSelector","useRef","useState","useEffect","dragValueHandlerAtom"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAS,gBAAgB,GAAQ,GAAiB;AAChD,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,KAAK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CAAC,WAAW,CAAC;AAChB,SAAOb,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,mBAAmB;AAG1B,QAAM,cAAcQ,KAAAA,IAAI,SAASM,iCAAoB;AACrD,MAAI,eAAe,KAAM,QAAO;AAEhC,SAAOd,YAAAA,QAAE,0BAA0B;AAAA,IACjC,aAAa;AAAA,EAAA,CACd;AACH;;"}
1
+ {"version":3,"file":"cell-renderer.cjs","sources":["../../src/renderers/cell-renderer.ts"],"sourcesContent":["import type {\n ColumnSpec,\n CellRenderContext,\n CellDetailContext,\n DataSheetStore,\n} from \"../provider\";\nimport { TableElementStatus } from \"../provider\";\nimport { editorKeyHandlerAtom, validateCell } from \"../utils\";\nimport h from \"../main.module.sass\";\nimport { memo, ReactNode, useEffect, useRef, useState } from \"react\";\nimport { EditorPopup, CellDetailModal } from \"../components\";\nimport { singleFocusedCell } from \"../provider\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, dragValueHandlerAtom, useSelector } from \"../provider\";\nimport { Intent } from \"@blueprintjs/core\";\nimport classNames from \"classnames\";\n\n/** Two validations are equivalent if they convey the same thing — so a fresh\n * `validateCell` result object doesn't force a re-render when nothing changed. */\nfunction validationEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (a == null || b == null) return a == b;\n return a.severity === b.severity && a.message === b.message;\n}\n\n/** Memoize on the *fields* of `cellContext` (not its identity — it's rebuilt\n * fresh each render), so an unchanged cell skips re-rendering. */\nfunction cellContentsEqual(\n a: { cellContext: CellRenderContext },\n b: { cellContext: CellRenderContext },\n): boolean {\n const x = a.cellContext;\n const y = b.cellContext;\n return (\n x.column === y.column &&\n x.value === y.value &&\n x.row === y.row &&\n x.rowIndex === y.rowIndex &&\n x.colIndex === y.colIndex &&\n x.isEdited === y.isEdited &&\n x.isDeleted === y.isDeleted &&\n x.status === y.status &&\n x.width === y.width &&\n x.height === y.height &&\n validationEqual(x.validation, y.validation)\n );\n}\n\n/** The rendered *content* of a read-only cell — the value renderer's output —\n * memoized on the cell's own inputs. It is placed as the CHILD of a real\n * Blueprint `Cell` (never a wrapper: Blueprint clones the returned `Cell` to\n * position/size it, so the renderer must return a `Cell` directly). This lets a\n * re-render from unrelated state — the focused cell moving, or a\n * scroll-triggered data load that swaps the `data`/overlay arrays — reposition\n * the lightweight `Cell` without re-running this (possibly heavy) value\n * renderer; only cells whose own value/status changed re-render. */\nconst CellContent = memo(function CellContent({\n cellContext,\n}: {\n cellContext: CellRenderContext;\n}) {\n const { value, column } = cellContext;\n if (value == null || value === \"\") return null;\n return column.valueRenderer?.(value, cellContext) ?? value;\n}, cellContentsEqual);\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 =\n 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\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\n ? null\n : validateCell(col, value, row, dataRowIndex);\n\n // A derived column is never writable, whatever `editable` says — see\n // `isColumnWritable`, which every write path in the store applies too.\n const editable =\n (col.editable ?? state.editable) && !isDeleted && !col.derived;\n const tableIsEditable = state.editable;\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 // 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: Intent | 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 // One context object, assembled once and threaded through every path (fast,\n // slow, focused). `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 // The size the table gives the cell (resized columns included), so a\n // renderer that fits itself to it needn't measure\n width:\n state.columnWidthsIndex?.get(col.key) ??\n col.width ??\n state.defaultColumnWidth,\n height: state.rowHeight,\n };\n\n // Only allocate a new style object when a row-status style must be layered on\n // (deleted → dimmed/struck-through; consumer statuses supply their own\n // `cellStyle`). The common case passes the column's own `style` straight\n // through — no per-cell clone, and a stable identity that diffs cheaply.\n // (Nothing downstream mutates `style`.)\n const style =\n statusStyle?.cellStyle != null\n ? { ...col.style, ...statusStyle.cellStyle }\n : col.style;\n\n const detailPresentation =\n col.cellDetail != null ? (col.detailPresentation ?? \"popover\") : null;\n\n // Derived values are drawn dimmed, so a reader can tell a record from a\n // restatement of one. Locked columns in an editable sheet are dimmed too.\n // Applied on every path below.\n const locked = tableIsEditable && col.editable === false && !col.derived;\n const valueClass = classNames({\n \"derived-cell\": col.derived,\n \"readonly-cell\": locked,\n });\n\n // Fast path — any non-focused cell whose *unfocused* appearance is just the\n // value viewer (a plain Blueprint `Cell`). That's everything except a custom\n // `cellComponent` (its own markup on every cell) and an *inline* `cellDetail`\n // (a persistent in-cell surface). A `cellDetail` popover/modal or a\n // `detailRenderer` only surfaces on the focused cell, so unfocused they show\n // the value viewer too — and take the fast path. Return a real `Cell`\n // (Blueprint clones it to position/size it) whose CHILD is the memoized\n // content, so unrelated re-renders (focus moving, a data load that swaps the\n // arrays) reposition the cheap `Cell` without re-running the value renderer.\n const usesCustomCell =\n col.cellComponent != null || detailPresentation === \"inline\";\n if (!topLeft && !usesCustomCell) {\n return h(\n Cell,\n {\n intent,\n loading,\n //value,\n style,\n className: valueClass,\n interactive: false,\n //disabled: tableIsEditable && !editable,\n },\n h(CellContent, { cellContext }),\n );\n }\n\n const isEmpty = value == null || value === \"\";\n\n const _renderedValue: any = isEmpty\n ? null\n : (col.valueRenderer?.(value, cellContext) ?? value);\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 = 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 // A popover isn't laid out in the cell\n width: undefined,\n height: undefined,\n surface: \"cell\",\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\n if (!topLeft) {\n // Non-focused cell that took the slow path — a custom `cellComponent`, or a\n // `cellDetail` / `detailRenderer` surface. An inline surface is a persistent\n // in-cell renderer (read-only here); others show the value viewer. (The\n // plain default-`Cell` case is handled by the memoized fast path above.)\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 className: valueClass,\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(\n EditorPopup,\n { valueViewer: _renderedValue, placement: col.detailPlacement },\n content,\n );\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: any = _renderedValue;\n\n let _dataEditor: ReactNode = null;\n let className: string | null = 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 = classNames(\"value-viewer-cell\", valueClass);\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: any = 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)(CornerDragHandle),\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 CornerDragHandle() {\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 onDragValue = ctx.useValue(dragValueHandlerAtom);\n if (onDragValue == null) return null;\n\n return h(\"div.corner-drag-handle\", {\n onMouseDown: onDragValue,\n });\n}\n"],"names":["memo","CellContent","TableElementStatus","validation","validateCell","classNames","h","Cell","CellDetailModal","EditorPopup","value","className","singleFocusedCell","ctx","editorKeyHandlerAtom","useSelector","useRef","useState","useEffect","dragValueHandlerAtom"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAS,gBAAgB,GAAQ,GAAiB;AAChD,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,KAAK,QAAQ,KAAK,aAAa,KAAK;AACxC,SAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE;AACtD;AAIA,SAAS,kBACP,GACA,GACS;AACT,QAAM,IAAI,EAAE;AACZ,QAAM,IAAI,EAAE;AACZ,SACE,EAAE,WAAW,EAAE,UACf,EAAE,UAAU,EAAE,SACd,EAAE,QAAQ,EAAE,OACZ,EAAE,aAAa,EAAE,YACjB,EAAE,aAAa,EAAE,YACjB,EAAE,aAAa,EAAE,YACjB,EAAE,cAAc,EAAE,aAClB,EAAE,WAAW,EAAE,UACf,EAAE,UAAU,EAAE,SACd,EAAE,WAAW,EAAE,UACf,gBAAgB,EAAE,YAAY,EAAE,UAAU;AAE9C;AAUA,MAAM,cAAcA,MAAAA,KAAK,SAASC,aAAY;AAAA,EAC5C;AACF,GAEG;AACD,QAAM,EAAE,OAAO,OAAA,IAAW;AAC1B,MAAI,SAAS,QAAQ,UAAU,GAAI,QAAO;AAC1C,SAAO,OAAO,gBAAgB,OAAO,WAAW,KAAK;AACvD,GAAG,i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AAAA;AAAA,IAAA;AAAA,EAE1D;AAEJ;AAEA,SAAS,YAAY,OAAO;AAC1B,QAAM,EAAE,OAAO,UAAU,GAAG,SAAS;AACrC,QAAM,YAAYO,KAAAA,IAAI,SAASC,gCAAoB;AACnD,QAAM,eAAeC,KAAAA,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAC1D,QAAM,cAAcA,KAAAA,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,SAAOZ,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,mBAAmB;AAG1B,QAAM,cAAcO,KAAAA,IAAI,SAASM,iCAAoB;AACrD,MAAI,eAAe,KAAM,QAAO;AAEhC,SAAOb,YAAAA,QAAE,0BAA0B;AAAA,IACjC,aAAa;AAAA,EAAA,CACd;AACH;;"}
@@ -73,7 +73,11 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
73
73
  };
74
74
  const style = statusStyle?.cellStyle != null ? { ...col.style, ...statusStyle.cellStyle } : col.style;
75
75
  const detailPresentation = col.cellDetail != null ? col.detailPresentation ?? "popover" : null;
76
- const derivedClass = col.derived ? "derived-cell" : void 0;
76
+ const locked = tableIsEditable && col.editable === false && !col.derived;
77
+ const valueClass = classNames({
78
+ "derived-cell": col.derived,
79
+ "readonly-cell": locked
80
+ });
77
81
  const usesCustomCell = col.cellComponent != null || detailPresentation === "inline";
78
82
  if (!topLeft && !usesCustomCell) {
79
83
  return h(
@@ -83,7 +87,7 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
83
87
  loading,
84
88
  //value,
85
89
  style,
86
- className: derivedClass,
90
+ className: valueClass,
87
91
  interactive: false
88
92
  //disabled: tableIsEditable && !editable,
89
93
  },
@@ -138,7 +142,7 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
138
142
  loading,
139
143
  value,
140
144
  style,
141
- className: derivedClass,
145
+ className: valueClass,
142
146
  disabled: tableIsEditable && !editable,
143
147
  interactive: false,
144
148
  ...cellComponentProps
@@ -248,7 +252,7 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
248
252
  if (_dataEditor != null) {
249
253
  cellContents = _dataEditor;
250
254
  }
251
- const className2 = classNames("value-viewer-cell", derivedClass);
255
+ const className2 = classNames("value-viewer-cell", valueClass);
252
256
  return h(
253
257
  _Cell,
254
258
  {
@@ -1 +1 @@
1
- {"version":3,"file":"cell-renderer.js","sources":["../../src/renderers/cell-renderer.ts"],"sourcesContent":["import type {\n ColumnSpec,\n CellRenderContext,\n CellDetailContext,\n DataSheetStore,\n} from \"../provider\";\nimport { TableElementStatus } from \"../provider\";\nimport { editorKeyHandlerAtom, validateCell } from \"../utils\";\nimport h from \"../main.module.sass\";\nimport { memo, ReactNode, useEffect, useRef, useState } from \"react\";\nimport { EditorPopup, CellDetailModal } from \"../components\";\nimport { singleFocusedCell } from \"../provider\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, dragValueHandlerAtom, useSelector } from \"../provider\";\nimport { Intent } from \"@blueprintjs/core\";\nimport classNames from \"classnames\";\n\n/** Two validations are equivalent if they convey the same thing — so a fresh\n * `validateCell` result object doesn't force a re-render when nothing changed. */\nfunction validationEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (a == null || b == null) return a == b;\n return a.severity === b.severity && a.message === b.message;\n}\n\n/** Memoize on the *fields* of `cellContext` (not its identity — it's rebuilt\n * fresh each render), so an unchanged cell skips re-rendering. */\nfunction cellContentsEqual(\n a: { cellContext: CellRenderContext },\n b: { cellContext: CellRenderContext },\n): boolean {\n const x = a.cellContext;\n const y = b.cellContext;\n return (\n x.column === y.column &&\n x.value === y.value &&\n x.row === y.row &&\n x.rowIndex === y.rowIndex &&\n x.colIndex === y.colIndex &&\n x.isEdited === y.isEdited &&\n x.isDeleted === y.isDeleted &&\n x.status === y.status &&\n x.width === y.width &&\n x.height === y.height &&\n validationEqual(x.validation, y.validation)\n );\n}\n\n/** The rendered *content* of a read-only cell — the value renderer's output —\n * memoized on the cell's own inputs. It is placed as the CHILD of a real\n * Blueprint `Cell` (never a wrapper: Blueprint clones the returned `Cell` to\n * position/size it, so the renderer must return a `Cell` directly). This lets a\n * re-render from unrelated state — the focused cell moving, or a\n * scroll-triggered data load that swaps the `data`/overlay arrays — reposition\n * the lightweight `Cell` without re-running this (possibly heavy) value\n * renderer; only cells whose own value/status changed re-render. */\nconst CellContent = memo(function CellContent({\n cellContext,\n}: {\n cellContext: CellRenderContext;\n}) {\n const { value, column } = cellContext;\n if (value == null || value === \"\") return null;\n return column.valueRenderer?.(value, cellContext) ?? value;\n}, cellContentsEqual);\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 =\n 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\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\n ? null\n : validateCell(col, value, row, dataRowIndex);\n\n // A derived column is never writable, whatever `editable` says — see\n // `isColumnWritable`, which every write path in the store applies too.\n const editable =\n (col.editable ?? state.editable) && !isDeleted && !col.derived;\n const tableIsEditable = state.editable;\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 // 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: Intent | 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 // One context object, assembled once and threaded through every path (fast,\n // slow, focused). `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 // The size the table gives the cell (resized columns included), so a\n // renderer that fits itself to it needn't measure\n width:\n state.columnWidthsIndex?.get(col.key) ??\n col.width ??\n state.defaultColumnWidth,\n height: state.rowHeight,\n };\n\n // Only allocate a new style object when a row-status style must be layered on\n // (deleted → dimmed/struck-through; consumer statuses supply their own\n // `cellStyle`). The common case passes the column's own `style` straight\n // through — no per-cell clone, and a stable identity that diffs cheaply.\n // (Nothing downstream mutates `style`.)\n const style =\n statusStyle?.cellStyle != null\n ? { ...col.style, ...statusStyle.cellStyle }\n : col.style;\n\n const detailPresentation =\n col.cellDetail != null ? (col.detailPresentation ?? \"popover\") : null;\n\n // Derived values are drawn dimmed, so a reader can tell a record from a\n // restatement of one. Applied on every path below.\n const derivedClass = col.derived ? \"derived-cell\" : undefined;\n\n // Fast path — any non-focused cell whose *unfocused* appearance is just the\n // value viewer (a plain Blueprint `Cell`). That's everything except a custom\n // `cellComponent` (its own markup on every cell) and an *inline* `cellDetail`\n // (a persistent in-cell surface). A `cellDetail` popover/modal or a\n // `detailRenderer` only surfaces on the focused cell, so unfocused they show\n // the value viewer too — and take the fast path. Return a real `Cell`\n // (Blueprint clones it to position/size it) whose CHILD is the memoized\n // content, so unrelated re-renders (focus moving, a data load that swaps the\n // arrays) reposition the cheap `Cell` without re-running the value renderer.\n const usesCustomCell =\n col.cellComponent != null || detailPresentation === \"inline\";\n if (!topLeft && !usesCustomCell) {\n return h(\n Cell,\n {\n intent,\n loading,\n //value,\n style,\n className: derivedClass,\n interactive: false,\n //disabled: tableIsEditable && !editable,\n },\n h(CellContent, { cellContext }),\n );\n }\n\n const isEmpty = value == null || value === \"\";\n\n const _renderedValue: any = isEmpty\n ? null\n : (col.valueRenderer?.(value, cellContext) ?? value);\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 = 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 // A popover isn't laid out in the cell\n width: undefined,\n height: undefined,\n surface: \"cell\",\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\n if (!topLeft) {\n // Non-focused cell that took the slow path — a custom `cellComponent`, or a\n // `cellDetail` / `detailRenderer` surface. An inline surface is a persistent\n // in-cell renderer (read-only here); others show the value viewer. (The\n // plain default-`Cell` case is handled by the memoized fast path above.)\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 className: derivedClass,\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(\n EditorPopup,\n { valueViewer: _renderedValue, placement: col.detailPlacement },\n content,\n );\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: any = _renderedValue;\n\n let _dataEditor: ReactNode = null;\n let className: string | null = 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 = classNames(\"value-viewer-cell\", derivedClass);\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: any = 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)(CornerDragHandle),\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 CornerDragHandle() {\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 onDragValue = ctx.useValue(dragValueHandlerAtom);\n if (onDragValue == null) return null;\n\n return h(\"div.corner-drag-handle\", {\n onMouseDown: onDragValue,\n });\n}\n"],"names":["CellContent","value","className"],"mappings":";;;;;;;;;;;;AAmBA,SAAS,gBAAgB,GAAQ,GAAiB;AAChD,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,KAAK,QAAQ,KAAK,aAAa,KAAK;AACxC,SAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE;AACtD;AAIA,SAAS,kBACP,GACA,GACS;AACT,QAAM,IAAI,EAAE;AACZ,QAAM,IAAI,EAAE;AACZ,SACE,EAAE,WAAW,EAAE,UACf,EAAE,UAAU,EAAE,SACd,EAAE,QAAQ,EAAE,OACZ,EAAE,aAAa,EAAE,YACjB,EAAE,aAAa,EAAE,YACjB,EAAE,aAAa,EAAE,YACjB,EAAE,cAAc,EAAE,aAClB,EAAE,WAAW,EAAE,UACf,EAAE,UAAU,EAAE,SACd,EAAE,WAAW,EAAE,UACf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ACnD,QAAM,eAAe,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAC1D,QAAM,cAAc,YAAY,CAAC,MAAM,EAAE,eAAe;AACxD,QAAM,WAAW,OAAyB,IAAI;AAC9C,QAAM,CAAC,QAAQ,QAAQ,IAAI,SAAS,KAAK;AACzC,YAAU,MAAM;AACd,aAAS,KAAK;AAAA,EAChB,GAAG,CAAC,KAAK,CAAC;AACV,YAAU,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,SAAO,EAAE,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,mBAAmB;AAG1B,QAAM,cAAc,IAAI,SAAS,oBAAoB;AACrD,MAAI,eAAe,KAAM,QAAO;AAEhC,SAAO,EAAE,0BAA0B;AAAA,IACjC,aAAa;AAAA,EAAA,CACd;AACH;"}
1
+ {"version":3,"file":"cell-renderer.js","sources":["../../src/renderers/cell-renderer.ts"],"sourcesContent":["import type {\n ColumnSpec,\n CellRenderContext,\n CellDetailContext,\n DataSheetStore,\n} from \"../provider\";\nimport { TableElementStatus } from \"../provider\";\nimport { editorKeyHandlerAtom, validateCell } from \"../utils\";\nimport h from \"../main.module.sass\";\nimport { memo, ReactNode, useEffect, useRef, useState } from \"react\";\nimport { EditorPopup, CellDetailModal } from \"../components\";\nimport { singleFocusedCell } from \"../provider\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, dragValueHandlerAtom, useSelector } from \"../provider\";\nimport { Intent } from \"@blueprintjs/core\";\nimport classNames from \"classnames\";\n\n/** Two validations are equivalent if they convey the same thing — so a fresh\n * `validateCell` result object doesn't force a re-render when nothing changed. */\nfunction validationEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (a == null || b == null) return a == b;\n return a.severity === b.severity && a.message === b.message;\n}\n\n/** Memoize on the *fields* of `cellContext` (not its identity — it's rebuilt\n * fresh each render), so an unchanged cell skips re-rendering. */\nfunction cellContentsEqual(\n a: { cellContext: CellRenderContext },\n b: { cellContext: CellRenderContext },\n): boolean {\n const x = a.cellContext;\n const y = b.cellContext;\n return (\n x.column === y.column &&\n x.value === y.value &&\n x.row === y.row &&\n x.rowIndex === y.rowIndex &&\n x.colIndex === y.colIndex &&\n x.isEdited === y.isEdited &&\n x.isDeleted === y.isDeleted &&\n x.status === y.status &&\n x.width === y.width &&\n x.height === y.height &&\n validationEqual(x.validation, y.validation)\n );\n}\n\n/** The rendered *content* of a read-only cell — the value renderer's output —\n * memoized on the cell's own inputs. It is placed as the CHILD of a real\n * Blueprint `Cell` (never a wrapper: Blueprint clones the returned `Cell` to\n * position/size it, so the renderer must return a `Cell` directly). This lets a\n * re-render from unrelated state — the focused cell moving, or a\n * scroll-triggered data load that swaps the `data`/overlay arrays — reposition\n * the lightweight `Cell` without re-running this (possibly heavy) value\n * renderer; only cells whose own value/status changed re-render. */\nconst CellContent = memo(function CellContent({\n cellContext,\n}: {\n cellContext: CellRenderContext;\n}) {\n const { value, column } = cellContext;\n if (value == null || value === \"\") return null;\n return column.valueRenderer?.(value, cellContext) ?? value;\n}, cellContentsEqual);\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 =\n 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\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\n ? null\n : validateCell(col, value, row, dataRowIndex);\n\n // A derived column is never writable, whatever `editable` says — see\n // `isColumnWritable`, which every write path in the store applies too.\n const editable =\n (col.editable ?? state.editable) && !isDeleted && !col.derived;\n const tableIsEditable = state.editable;\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 // 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: Intent | 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 // One context object, assembled once and threaded through every path (fast,\n // slow, focused). `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 // The size the table gives the cell (resized columns included), so a\n // renderer that fits itself to it needn't measure\n width:\n state.columnWidthsIndex?.get(col.key) ??\n col.width ??\n state.defaultColumnWidth,\n height: state.rowHeight,\n };\n\n // Only allocate a new style object when a row-status style must be layered on\n // (deleted → dimmed/struck-through; consumer statuses supply their own\n // `cellStyle`). The common case passes the column's own `style` straight\n // through — no per-cell clone, and a stable identity that diffs cheaply.\n // (Nothing downstream mutates `style`.)\n const style =\n statusStyle?.cellStyle != null\n ? { ...col.style, ...statusStyle.cellStyle }\n : col.style;\n\n const detailPresentation =\n col.cellDetail != null ? (col.detailPresentation ?? \"popover\") : null;\n\n // Derived values are drawn dimmed, so a reader can tell a record from a\n // restatement of one. Locked columns in an editable sheet are dimmed too.\n // Applied on every path below.\n const locked = tableIsEditable && col.editable === false && !col.derived;\n const valueClass = classNames({\n \"derived-cell\": col.derived,\n \"readonly-cell\": locked,\n });\n\n // Fast path — any non-focused cell whose *unfocused* appearance is just the\n // value viewer (a plain Blueprint `Cell`). That's everything except a custom\n // `cellComponent` (its own markup on every cell) and an *inline* `cellDetail`\n // (a persistent in-cell surface). A `cellDetail` popover/modal or a\n // `detailRenderer` only surfaces on the focused cell, so unfocused they show\n // the value viewer too — and take the fast path. Return a real `Cell`\n // (Blueprint clones it to position/size it) whose CHILD is the memoized\n // content, so unrelated re-renders (focus moving, a data load that swaps the\n // arrays) reposition the cheap `Cell` without re-running the value renderer.\n const usesCustomCell =\n col.cellComponent != null || detailPresentation === \"inline\";\n if (!topLeft && !usesCustomCell) {\n return h(\n Cell,\n {\n intent,\n loading,\n //value,\n style,\n className: valueClass,\n interactive: false,\n //disabled: tableIsEditable && !editable,\n },\n h(CellContent, { cellContext }),\n );\n }\n\n const isEmpty = value == null || value === \"\";\n\n const _renderedValue: any = isEmpty\n ? null\n : (col.valueRenderer?.(value, cellContext) ?? value);\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 = 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 // A popover isn't laid out in the cell\n width: undefined,\n height: undefined,\n surface: \"cell\",\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\n if (!topLeft) {\n // Non-focused cell that took the slow path — a custom `cellComponent`, or a\n // `cellDetail` / `detailRenderer` surface. An inline surface is a persistent\n // in-cell renderer (read-only here); others show the value viewer. (The\n // plain default-`Cell` case is handled by the memoized fast path above.)\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 className: valueClass,\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(\n EditorPopup,\n { valueViewer: _renderedValue, placement: col.detailPlacement },\n content,\n );\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: any = _renderedValue;\n\n let _dataEditor: ReactNode = null;\n let className: string | null = 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 = classNames(\"value-viewer-cell\", valueClass);\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: any = 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)(CornerDragHandle),\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 CornerDragHandle() {\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 onDragValue = ctx.useValue(dragValueHandlerAtom);\n if (onDragValue == null) return null;\n\n return h(\"div.corner-drag-handle\", {\n onMouseDown: onDragValue,\n });\n}\n"],"names":["CellContent","value","className"],"mappings":";;;;;;;;;;;;AAmBA,SAAS,gBAAgB,GAAQ,GAAiB;AAChD,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,KAAK,QAAQ,KAAK,aAAa,KAAK;AACxC,SAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE;AACtD;AAIA,SAAS,kBACP,GACA,GACS;AACT,QAAM,IAAI,EAAE;AACZ,QAAM,IAAI,EAAE;AACZ,SACE,EAAE,WAAW,EAAE,UACf,EAAE,UAAU,EAAE,SACd,EAAE,QAAQ,EAAE,OACZ,EAAE,aAAa,EAAE,YACjB,EAAE,aAAa,EAAE,YACjB,EAAE,aAAa,EAAE,YACjB,EA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AAAA,MACA,EAAE,GAAG,YAAY,qBAAqB,EAAE,gBAAgB;AAAA;AAAA,IAAA;AAAA,EAE1D;AAEJ;AAEA,SAAS,YAAY,OAAO;AAC1B,QAAM,EAAE,OAAO,UAAU,GAAG,SAAS;AACrC,QAAM,YAAY,IAAI,SAAS,oBAAoB;AACnD,QAAM,eAAe,YAAY,CAAC,MAAM,EAAE,gBAAgB;AAC1D,QAAM,cAAc,YAAY,CAAC,MAAM,EAAE,eAAe;AACxD,QAAM,WAAW,OAAyB,IAAI;AAC9C,QAAM,CAAC,QAAQ,QAAQ,IAAI,SAAS,KAAK;AACzC,YAAU,MAAM;AACd,aAAS,KAAK;AAAA,EAChB,GAAG,CAAC,KAAK,CAAC;AACV,YAAU,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,SAAO,EAAE,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,mBAAmB;AAG1B,QAAM,cAAc,IAAI,SAAS,oBAAoB;AACrD,MAAI,eAAe,KAAM,QAAO;AAEhC,SAAO,EAAE,0BAA0B;AAAA,IACjC,aAAa;AAAA,EAAA,CACd;AACH;"}
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const h = require("@macrostrat/hyper");
4
4
  const table = require("@blueprintjs/table");
5
- const core = require("@blueprintjs/core");
5
+ const core$1 = require("@blueprintjs/core");
6
6
  const react = require("react");
7
7
  const classNames = require("classnames");
8
- const core$1 = require("../provider/core.cjs");
8
+ const core = require("../provider/core.cjs");
9
9
  const context = require("../actions/context.cjs");
10
10
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
11
11
  const h__default = /* @__PURE__ */ _interopDefault(h);
@@ -51,6 +51,8 @@ function renderColumnHeaderCell({
51
51
  });
52
52
  }
53
53
  function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
54
+ const tableEditable = core.useSelector((s) => s.editable);
55
+ const locked = tableEditable && col.editable === false && !col.derived;
54
56
  return h__default.default(
55
57
  "div",
56
58
  {
@@ -73,12 +75,18 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
73
75
  ),
74
76
  // A derived column says so in its header: the values below are computed
75
77
  // and won't take an edit.
76
- h__default.default.if(col.derived === true)(core.Icon, {
78
+ h__default.default.if(col.derived === true)(core$1.Icon, {
77
79
  icon: "function",
78
80
  size: 12,
79
81
  title: "Derived — computed from other values, not editable",
80
82
  style: { marginLeft: "4px", flexShrink: 0, opacity: 0.6 }
81
83
  }),
84
+ h__default.default.if(locked)(core$1.Icon, {
85
+ icon: "lock",
86
+ size: 12,
87
+ title: "Not editable",
88
+ style: { marginLeft: "4px", flexShrink: 0, opacity: 0.6 }
89
+ }),
82
90
  h__default.default.if(hasSortActive || hasFilterActive)(
83
91
  "span",
84
92
  {
@@ -91,12 +99,12 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
91
99
  }
92
100
  },
93
101
  [
94
- h__default.default.if(hasSortActive)(core.Icon, {
102
+ h__default.default.if(hasSortActive)(core$1.Icon, {
95
103
  icon: activeSort?.ascending ? "sort-asc" : "sort-desc",
96
104
  size: 12,
97
105
  style: { color: "var(--intent-primary, #2965cc)" }
98
106
  }),
99
- h__default.default.if(hasFilterActive)(core.Icon, {
107
+ h__default.default.if(hasFilterActive)(core$1.Icon, {
100
108
  icon: "filter",
101
109
  size: 12,
102
110
  style: { color: "var(--intent-primary, #2965cc)" }
@@ -107,8 +115,8 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
107
115
  );
108
116
  }
109
117
  function ColumnHeaderControls({ colIndex }) {
110
- const actions = core$1.ctx.useValue(core$1.tableActionsAtom);
111
- const store = core$1.ctx.useStore();
118
+ const actions = core.ctx.useValue(core.tableActionsAtom);
119
+ const store = core.ctx.useStore();
112
120
  const actionCtx = react.useMemo(() => {
113
121
  return context.buildActionContext(store.get, store.set, {
114
122
  singleColumn: colIndex
@@ -126,7 +134,7 @@ function ColumnHeaderControls({ colIndex }) {
126
134
  { key: a.id ?? i },
127
135
  a.render(actionCtx)
128
136
  );
129
- return h__default.default(core.MenuItem, {
137
+ return h__default.default(core$1.MenuItem, {
130
138
  key: a.id ?? i,
131
139
  icon: a.icon,
132
140
  intent: a.intent,
@@ -135,9 +143,9 @@ function ColumnHeaderControls({ colIndex }) {
135
143
  });
136
144
  }).filter(Boolean);
137
145
  if (items.length === 0) {
138
- return h__default.default(core.Menu, [h__default.default(core.MenuItem, { text: "No options", disabled: true })]);
146
+ return h__default.default(core$1.Menu, [h__default.default(core$1.MenuItem, { text: "No options", disabled: true })]);
139
147
  }
140
- return h__default.default(core.Menu, { className: "column-header-controls" }, items);
148
+ return h__default.default(core$1.Menu, { className: "column-header-controls" }, items);
141
149
  }
142
150
  exports.renderColumnHeaderCell = renderColumnHeaderCell;
143
151
  //# sourceMappingURL=column-header-cell.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"column-header-cell.cjs","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport { ctx, tableActionsAtom, type ColumnSpec } from \"../provider\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\nimport { buildActionContext } from \"../actions\";\nimport { useMemo } from \"react\";\nimport classNames from \"classnames\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n // A column may be pinned against drag-reordering via `reorderable: false`.\n const enableColumnReordering = col.reorderable !== false;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive: false,\n hasFilterActive: false,\n activeSort: null,\n }) as any,\n });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive,\n hasFilterActive,\n activeSort,\n }) as any,\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. The column key is\n * exposed as `data-column-key` so consumers can target a specific header from\n * CSS (e.g. to tint a column) without a bespoke styling prop. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n return h(\n \"div\",\n {\n \"data-column-key\": col.key,\n style: { display: \"flex\", alignItems: \"center\", width: \"100%\" },\n },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n className: classNames({ \"derived-column-name\": col.derived }),\n },\n col.name,\n ),\n // A derived column says so in its header: the values below are computed\n // and won't take an edit.\n h.if(col.derived === true)(Icon, {\n icon: \"function\",\n size: 12,\n title: \"Derived — computed from other values, not editable\",\n style: { marginLeft: \"4px\", flexShrink: 0, opacity: 0.6 },\n }),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const actions = ctx.useValue(tableActionsAtom);\n const store = ctx.useStore();\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = useMemo(() => {\n return buildActionContext(store.get, store.set, {\n singleColumn: colIndex,\n });\n }, [actions, colIndex, store]);\n\n // Only actions *limited* to column scope belong in a column's dropdown —\n // sort/filter and column-specific actions. Global actions (Save / Reset /\n // Clear-selection, marked by a FULL_TABLE or \"none\" target) are confusing\n // here, so they're excluded even though they nominally apply to columns too.\n const isGlobal = (a: (typeof actions)[number]) =>\n a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any);\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n !isGlobal(a) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\n \"li.column-header-control\",\n { key: a.id ?? i },\n a.render(actionCtx),\n );\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":["h","ColumnHeaderCell","classNames","Icon","ctx","tableActionsAtom","useMemo","buildActionContext","RegionCardinality","MenuItem","Menu"],"mappings":";;;;;;;;;;;;AAoCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,aAAa,IAAI,aAAa;AACpC,QAAM,eACJ,IAAI,eAAe,QACnB,OAAO,IAAI,eAAe,YACzB,MAAM,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,SAAS;AACtD,QAAM,mBACJ,MAAM,QAAS,IAAY,OAAO,KAAM,IAAY,QAAQ,SAAS;AAGvE,QAAM,yBAAyB,IAAI,gBAAgB;AAEnD,MAAI,CAAC,cAAc,C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kB,KAAM,QAAO,EAAE,eAAe,SAAS;AAC/D,QAAI,EAAE,UAAU;AACd,aAAOR,WAAAA;AAAAA,QACL;AAAA,QACA,EAAE,KAAK,EAAE,MAAM,EAAA;AAAA,QACf,EAAE,OAAO,SAAS;AAAA,MAAA;AAEtB,WAAOA,WAAAA,QAAES,KAAAA,UAAU;AAAA,MACjB,KAAK,EAAE,MAAM;AAAA,MACb,MAAM,EAAE;AAAA,MACR,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,SAAS,MAAM,EAAE,MAAM,SAAS;AAAA,IAAA,CACjC;AAAA,EACH,CAAC,EACA,OAAO,OAAO;AAEjB,MAAI,MAAM,WAAW,GAAG;AACtB,WAAOT,mBAAEU,KAAAA,MAAM,CAACV,WAAAA,QAAES,KAAAA,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAOT,WAAAA,QAAEU,KAAAA,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;;"}
1
+ {"version":3,"file":"column-header-cell.cjs","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport {\n ctx,\n tableActionsAtom,\n useSelector,\n type ColumnSpec,\n} from \"../provider\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\nimport { buildActionContext } from \"../actions\";\nimport { useMemo } from \"react\";\nimport classNames from \"classnames\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n // A column may be pinned against drag-reordering via `reorderable: false`.\n const enableColumnReordering = col.reorderable !== false;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive: false,\n hasFilterActive: false,\n activeSort: null,\n }) as any,\n });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive,\n hasFilterActive,\n activeSort,\n }) as any,\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. The column key is\n * exposed as `data-column-key` so consumers can target a specific header from\n * CSS (e.g. to tint a column) without a bespoke styling prop. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n // Only meaningful when the rest of the sheet takes edits.\n const tableEditable = useSelector((s) => s.editable);\n const locked = tableEditable && col.editable === false && !col.derived;\n return h(\n \"div\",\n {\n \"data-column-key\": col.key,\n style: { display: \"flex\", alignItems: \"center\", width: \"100%\" },\n },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n className: classNames({ \"derived-column-name\": col.derived }),\n },\n col.name,\n ),\n // A derived column says so in its header: the values below are computed\n // and won't take an edit.\n h.if(col.derived === true)(Icon, {\n icon: \"function\",\n size: 12,\n title: \"Derived — computed from other values, not editable\",\n style: { marginLeft: \"4px\", flexShrink: 0, opacity: 0.6 },\n }),\n h.if(locked)(Icon, {\n icon: \"lock\",\n size: 12,\n title: \"Not editable\",\n style: { marginLeft: \"4px\", flexShrink: 0, opacity: 0.6 },\n }),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const actions = ctx.useValue(tableActionsAtom);\n const store = ctx.useStore();\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = useMemo(() => {\n return buildActionContext(store.get, store.set, {\n singleColumn: colIndex,\n });\n }, [actions, colIndex, store]);\n\n // Only actions *limited* to column scope belong in a column's dropdown —\n // sort/filter and column-specific actions. Global actions (Save / Reset /\n // Clear-selection, marked by a FULL_TABLE or \"none\" target) are confusing\n // here, so they're excluded even though they nominally apply to columns too.\n const isGlobal = (a: (typeof actions)[number]) =>\n a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any);\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n !isGlobal(a) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\n \"li.column-header-control\",\n { key: a.id ?? i },\n a.render(actionCtx),\n );\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":["h","ColumnHeaderCell","useSelector","classNames","Icon","ctx","tableActionsAtom","useMemo","buildActionContext","RegionCardinality","MenuItem","Menu"],"mappings":";;;;;;;;;;;;AAyCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,aAAa,IAAI,aAAa;AACpC,QAAM,eACJ,IAAI,eAAe,QACnB,OAAO,IAAI,eAAe,YACzB,MAAM,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,SAAS;AACtD,QAAM,mBACJ,MAAM,QAAS,IAAY,OAAO,KAAM,IAAY,QAAQ,SAAS;AAGvE,QAAM,yBAAyB,IAAI,gBAAgB;AAEnD,MAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,kBAAkB;AACrD,WAAOA,WAAAA,QAAEC,MAAAA,kBAA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S,MAAa;AAClC,QAAM,WAAW,QAAQ;AAAA,IACvB,CAAC,MACC,EAAE,QAAQ,SAASA,MAAAA,kBAAkB,YAAY,KACjD,CAAC,SAAS,CAAC,MACV,EAAE,YAAY,SAAS,KAAK;AAAA,EAAA;AAOjC,QAAM,QAAQ,SACX,IAAI,CAAC,GAAG,MAAM;AACb,QAAI,EAAE,kBAAkB,KAAM,QAAO,EAAE,eAAe,SAAS;AAC/D,QAAI,EAAE,UAAU;AACd,aAAOT,WAAAA;AAAAA,QACL;AAAA,QACA,EAAE,KAAK,EAAE,MAAM,EAAA;AAAA,QACf,EAAE,OAAO,SAAS;AAAA,MAAA;AAEtB,WAAOA,WAAAA,QAAEU,OAAAA,UAAU;AAAA,MACjB,KAAK,EAAE,MAAM;AAAA,MACb,MAAM,EAAE;AAAA,MACR,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,SAAS,MAAM,EAAE,MAAM,SAAS;AAAA,IAAA,CACjC;AAAA,EACH,CAAC,EACA,OAAO,OAAO;AAEjB,MAAI,MAAM,WAAW,GAAG;AACtB,WAAOV,mBAAEW,OAAAA,MAAM,CAACX,WAAAA,QAAEU,OAAAA,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAOV,WAAAA,QAAEW,OAAAA,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;;"}
@@ -3,7 +3,7 @@ import { ColumnHeaderCell, RegionCardinality } from "@blueprintjs/table";
3
3
  import { Icon, MenuItem, Menu } from "@blueprintjs/core";
4
4
  import { useMemo } from "react";
5
5
  import classNames from "classnames";
6
- import { ctx, tableActionsAtom } from "../provider/core.js";
6
+ import { useSelector, ctx, tableActionsAtom } from "../provider/core.js";
7
7
  import { buildActionContext } from "../actions/context.js";
8
8
  function renderColumnHeaderCell({
9
9
  col,
@@ -46,6 +46,8 @@ function renderColumnHeaderCell({
46
46
  });
47
47
  }
48
48
  function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
49
+ const tableEditable = useSelector((s) => s.editable);
50
+ const locked = tableEditable && col.editable === false && !col.derived;
49
51
  return h(
50
52
  "div",
51
53
  {
@@ -74,6 +76,12 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
74
76
  title: "Derived — computed from other values, not editable",
75
77
  style: { marginLeft: "4px", flexShrink: 0, opacity: 0.6 }
76
78
  }),
79
+ h.if(locked)(Icon, {
80
+ icon: "lock",
81
+ size: 12,
82
+ title: "Not editable",
83
+ style: { marginLeft: "4px", flexShrink: 0, opacity: 0.6 }
84
+ }),
77
85
  h.if(hasSortActive || hasFilterActive)(
78
86
  "span",
79
87
  {
@@ -1 +1 @@
1
- {"version":3,"file":"column-header-cell.js","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport { ctx, tableActionsAtom, type ColumnSpec } from \"../provider\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\nimport { buildActionContext } from \"../actions\";\nimport { useMemo } from \"react\";\nimport classNames from \"classnames\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n // A column may be pinned against drag-reordering via `reorderable: false`.\n const enableColumnReordering = col.reorderable !== false;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive: false,\n hasFilterActive: false,\n activeSort: null,\n }) as any,\n });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive,\n hasFilterActive,\n activeSort,\n }) as any,\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. The column key is\n * exposed as `data-column-key` so consumers can target a specific header from\n * CSS (e.g. to tint a column) without a bespoke styling prop. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n return h(\n \"div\",\n {\n \"data-column-key\": col.key,\n style: { display: \"flex\", alignItems: \"center\", width: \"100%\" },\n },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n className: classNames({ \"derived-column-name\": col.derived }),\n },\n col.name,\n ),\n // A derived column says so in its header: the values below are computed\n // and won't take an edit.\n h.if(col.derived === true)(Icon, {\n icon: \"function\",\n size: 12,\n title: \"Derived — computed from other values, not editable\",\n style: { marginLeft: \"4px\", flexShrink: 0, opacity: 0.6 },\n }),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const actions = ctx.useValue(tableActionsAtom);\n const store = ctx.useStore();\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = useMemo(() => {\n return buildActionContext(store.get, store.set, {\n singleColumn: colIndex,\n });\n }, [actions, colIndex, store]);\n\n // Only actions *limited* to column scope belong in a column's dropdown —\n // sort/filter and column-specific actions. Global actions (Save / Reset /\n // Clear-selection, marked by a FULL_TABLE or \"none\" target) are confusing\n // here, so they're excluded even though they nominally apply to columns too.\n const isGlobal = (a: (typeof actions)[number]) =>\n a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any);\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n !isGlobal(a) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\n \"li.column-header-control\",\n { key: a.id ?? i },\n a.render(actionCtx),\n );\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":[],"mappings":";;;;;;;AAoCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,aAAa,IAAI,aAAa;AACpC,QAAM,eACJ,IAAI,eAAe,QACnB,OAAO,IAAI,eAAe,YACzB,MAAM,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,SAAS;AACtD,QAAM,mBACJ,MAAM,QAAS,IAAY,OAAO,KAAM,IAAY,QAAQ,SAAS;AAGvE,QAAM,yBAAyB,IAAI,gBAAgB;AAEnD,MAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,kBAAkB;AACrD,WAAO,EAAE,kBAAkB;AAAA,MACzB,MAAM,IAAI;AAAA,MACV;AAAA,MACA,cAAc,MACZ,EAAE,kBAAkB;AAAA,QAClB;AAAA,QACA,eAAe;AAAA,QACf,iBAAiB;AAAA,QACjB,YAAY;AAAA,MAAA,CACb;AAAA,IAAA,CACJ;AAAA,EACH;AAIA,QAAM,kBAAkB,gBAAgB;AACxC,QAAM,gBAAgB,cAAc;AAEpC,SAAO,EAAE,kBAAkB;AAAA,IACzB,MAAM,IAAI;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAIA,4BAA4B;AAAA,IAC5B,cAAc,MACZ,EAAE,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACH,cAAc,MAAM,EAAE,sBAAsB,EAAE,UAAU;AAAA,EAAA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AgB;AAC7C,QAAM,QAAQ,IAAI,SAAA;AAGlB,QAAM,YAAY,QAAQ,MAAM;AAC9B,WAAO,mBAAmB,MAAM,KAAK,MAAM,KAAK;AAAA,MAC9C,cAAc;AAAA,IAAA,CACf;AAAA,EACH,GAAG,CAAC,SAAS,UAAU,KAAK,CAAC;AAM7B,QAAM,WAAW,CAAC,MAChB,EAAE,QAAQ,SAAS,kBAAkB,UAAU,KAC/C,EAAE,QAAQ,SAAS,MAAa;AAClC,QAAM,WAAW,QAAQ;AAAA,IACvB,CAAC,MACC,EAAE,QAAQ,SAAS,kBAAkB,YAAY,KACjD,CAAC,SAAS,CAAC,MACV,EAAE,YAAY,SAAS,KAAK;AAAA,EAAA;AAOjC,QAAM,QAAQ,SACX,IAAI,CAAC,GAAG,MAAM;AACb,QAAI,EAAE,kBAAkB,KAAM,QAAO,EAAE,eAAe,SAAS;AAC/D,QAAI,EAAE,UAAU;AACd,aAAO;AAAA,QACL;AAAA,QACA,EAAE,KAAK,EAAE,MAAM,EAAA;AAAA,QACf,EAAE,OAAO,SAAS;AAAA,MAAA;AAEtB,WAAO,EAAE,UAAU;AAAA,MACjB,KAAK,EAAE,MAAM;AAAA,MACb,MAAM,EAAE;AAAA,MACR,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,SAAS,MAAM,EAAE,MAAM,SAAS;AAAA,IAAA,CACjC;AAAA,EACH,CAAC,EACA,OAAO,OAAO;AAEjB,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAO,EAAE,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;"}
1
+ {"version":3,"file":"column-header-cell.js","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport {\n ctx,\n tableActionsAtom,\n useSelector,\n type ColumnSpec,\n} from \"../provider\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\nimport { buildActionContext } from \"../actions\";\nimport { useMemo } from \"react\";\nimport classNames from \"classnames\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n // A column may be pinned against drag-reordering via `reorderable: false`.\n const enableColumnReordering = col.reorderable !== false;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive: false,\n hasFilterActive: false,\n activeSort: null,\n }) as any,\n });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive,\n hasFilterActive,\n activeSort,\n }) as any,\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. The column key is\n * exposed as `data-column-key` so consumers can target a specific header from\n * CSS (e.g. to tint a column) without a bespoke styling prop. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n // Only meaningful when the rest of the sheet takes edits.\n const tableEditable = useSelector((s) => s.editable);\n const locked = tableEditable && col.editable === false && !col.derived;\n return h(\n \"div\",\n {\n \"data-column-key\": col.key,\n style: { display: \"flex\", alignItems: \"center\", width: \"100%\" },\n },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n className: classNames({ \"derived-column-name\": col.derived }),\n },\n col.name,\n ),\n // A derived column says so in its header: the values below are computed\n // and won't take an edit.\n h.if(col.derived === true)(Icon, {\n icon: \"function\",\n size: 12,\n title: \"Derived — computed from other values, not editable\",\n style: { marginLeft: \"4px\", flexShrink: 0, opacity: 0.6 },\n }),\n h.if(locked)(Icon, {\n icon: \"lock\",\n size: 12,\n title: \"Not editable\",\n style: { marginLeft: \"4px\", flexShrink: 0, opacity: 0.6 },\n }),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const actions = ctx.useValue(tableActionsAtom);\n const store = ctx.useStore();\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = useMemo(() => {\n return buildActionContext(store.get, store.set, {\n singleColumn: colIndex,\n });\n }, [actions, colIndex, store]);\n\n // Only actions *limited* to column scope belong in a column's dropdown —\n // sort/filter and column-specific actions. Global actions (Save / Reset /\n // Clear-selection, marked by a FULL_TABLE or \"none\" target) are confusing\n // here, so they're excluded even though they nominally apply to columns too.\n const isGlobal = (a: (typeof actions)[number]) =>\n a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any);\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n !isGlobal(a) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\n \"li.column-header-control\",\n { key: a.id ?? i },\n a.render(actionCtx),\n );\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":[],"mappings":";;;;;;;AAyCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA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AAK;AAAA,MAC9C,cAAc;AAAA,IAAA,CACf;AAAA,EACH,GAAG,CAAC,SAAS,UAAU,KAAK,CAAC;AAM7B,QAAM,WAAW,CAAC,MAChB,EAAE,QAAQ,SAAS,kBAAkB,UAAU,KAC/C,EAAE,QAAQ,SAAS,MAAa;AAClC,QAAM,WAAW,QAAQ;AAAA,IACvB,CAAC,MACC,EAAE,QAAQ,SAAS,kBAAkB,YAAY,KACjD,CAAC,SAAS,CAAC,MACV,EAAE,YAAY,SAAS,KAAK;AAAA,EAAA;AAOjC,QAAM,QAAQ,SACX,IAAI,CAAC,GAAG,MAAM;AACb,QAAI,EAAE,kBAAkB,KAAM,QAAO,EAAE,eAAe,SAAS;AAC/D,QAAI,EAAE,UAAU;AACd,aAAO;AAAA,QACL;AAAA,QACA,EAAE,KAAK,EAAE,MAAM,EAAA;AAAA,QACf,EAAE,OAAO,SAAS;AAAA,MAAA;AAEtB,WAAO,EAAE,UAAU;AAAA,MACjB,KAAK,EAAE,MAAM;AAAA,MACb,MAAM,EAAE;AAAA,MACR,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,SAAS,MAAM,EAAE,MAAM,SAAS;AAAA,IAAA,CACjC;AAAA,EACH,CAAC,EACA,OAAO,OAAO;AAEjB,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAO,EAAE,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;"}
@@ -3,9 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jotai = require("jotai");
4
4
  const selection = require("../actions/selection.cjs");
5
5
  const notifications = require("../notifications.cjs");
6
- const core = require("../provider/core.cjs");
7
6
  const context = require("../actions/context.cjs");
8
7
  const zustandStore = require("../provider/zustand-store.cjs");
8
+ const core = require("../provider/core.cjs");
9
9
  const isEditableAtom = jotai.atom((get) => {
10
10
  const store = get(core.storeAtom);
11
11
  return store?.editable ?? false;
@@ -17,11 +17,10 @@ jotai.atom((get) => {
17
17
  });
18
18
  const tableHotkeysAtom = jotai.atom(
19
19
  null,
20
- (get, set) => {
20
+ (get, set, tableActions) => {
21
21
  const store = get(core.storeAPIAtom);
22
22
  const toaster = get(notifications.toasterAtom);
23
23
  const editable = get(isEditableAtom);
24
- const tableActions = get(core.tableActionsAtom);
25
24
  if (store == null) return [];
26
25
  const keyHandler = (actionRunner) => {
27
26
  return (e) => {