@macrostrat/data-sheet 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +70 -31
  2. package/dist/actions/selection.cjs +5 -1
  3. package/dist/actions/selection.cjs.map +1 -1
  4. package/dist/actions/selection.d.ts +7 -1
  5. package/dist/actions/selection.js +5 -1
  6. package/dist/actions/selection.js.map +1 -1
  7. package/dist/components/editor-actions.cjs +1 -1
  8. package/dist/components/editor-actions.cjs.map +1 -1
  9. package/dist/components/editor-actions.js +2 -2
  10. package/dist/components/editor-actions.js.map +1 -1
  11. package/dist/components/indicators/unified-filters.cjs +3 -0
  12. package/dist/components/indicators/unified-filters.cjs.map +1 -1
  13. package/dist/components/indicators/unified-filters.js +3 -0
  14. package/dist/components/indicators/unified-filters.js.map +1 -1
  15. package/dist/components/toolbars/actions-toolbar.cjs +5 -2
  16. package/dist/components/toolbars/actions-toolbar.cjs.map +1 -1
  17. package/dist/components/toolbars/actions-toolbar.js +6 -3
  18. package/dist/components/toolbars/actions-toolbar.js.map +1 -1
  19. package/dist/data-sheet.cjs +4 -0
  20. package/dist/data-sheet.cjs.map +1 -1
  21. package/dist/data-sheet.css +38 -22
  22. package/dist/data-sheet.js +4 -0
  23. package/dist/data-sheet.js.map +1 -1
  24. package/dist/index.cjs +15 -14
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +2 -1
  27. package/dist/main.module.sass.cjs +14 -14
  28. package/dist/main.module.sass.js +14 -14
  29. package/dist/provider/column-spec.cjs.map +1 -1
  30. package/dist/provider/column-spec.d.ts +8 -0
  31. package/dist/provider/column-spec.js.map +1 -1
  32. package/dist/provider/types.cjs.map +1 -1
  33. package/dist/provider/types.d.ts +11 -0
  34. package/dist/provider/types.js.map +1 -1
  35. package/dist/provider/zustand-store.cjs +40 -24
  36. package/dist/provider/zustand-store.cjs.map +1 -1
  37. package/dist/provider/zustand-store.js +40 -24
  38. package/dist/provider/zustand-store.js.map +1 -1
  39. package/dist/renderers/cell-renderer.cjs +9 -2
  40. package/dist/renderers/cell-renderer.cjs.map +1 -1
  41. package/dist/renderers/cell-renderer.js +9 -2
  42. package/dist/renderers/cell-renderer.js.map +1 -1
  43. package/dist/utils/key-handling.cjs +6 -5
  44. package/dist/utils/key-handling.cjs.map +1 -1
  45. package/dist/utils/key-handling.js +2 -1
  46. package/dist/utils/key-handling.js.map +1 -1
  47. package/package.json +2 -2
  48. package/src/actions/selection.ts +11 -2
  49. package/src/components/editor-actions.ts +5 -2
  50. package/src/components/indicators/unified-filters.ts +3 -0
  51. package/src/components/toolbars/actions-toolbar.ts +10 -4
  52. package/src/data-sheet.ts +6 -0
  53. package/src/main.module.sass +14 -0
  54. package/src/provider/column-spec.ts +8 -0
  55. package/src/provider/types.ts +15 -1
  56. package/src/provider/zustand-store.ts +58 -28
  57. package/src/renderers/cell-renderer.ts +12 -0
  58. package/src/utils/key-handling.ts +2 -1
@@ -14,9 +14,11 @@ function createZustandStore(set, get) {
14
14
  columnSpec: [],
15
15
  deferColumnSpec: false,
16
16
  defaultColumnWidth: 150,
17
+ rowHeight: 20,
17
18
  editable: false,
18
19
  selection: [],
19
20
  fillValueBaseCell: null,
21
+ fillBaseData: null,
20
22
  focusedCell: null,
21
23
  topLeftCell: null,
22
24
  initialized: false,
@@ -122,10 +124,12 @@ function createZustandStore(set, get) {
122
124
  deleteSelectedRows() {
123
125
  if (!get().canDeleteRows) return;
124
126
  let deletedIndices = [];
127
+ let deletedRows = [];
125
128
  set((state) => {
126
- const { selection, deletedRows } = state;
129
+ const { selection } = state;
127
130
  const rowIndices = getRowIndices(selection);
128
131
  deletedIndices = rowIndices;
132
+ deletedRows = rowIndices.map((i) => state.data[i]);
129
133
  const { addedRows } = state;
130
134
  const rowsNewlyDeleted = new Set(rowIndices);
131
135
  const rowsToRemoveFromDataArrays = new Set(
@@ -163,7 +167,11 @@ function createZustandStore(set, get) {
163
167
  };
164
168
  });
165
169
  if (deletedIndices.length > 0) {
166
- get().onEdit?.({ type: "deleteRows", rowIndices: deletedIndices });
170
+ get().onEdit?.({
171
+ type: "deleteRows",
172
+ rowIndices: deletedIndices,
173
+ rows: deletedRows
174
+ });
167
175
  }
168
176
  },
169
177
  resetChanges(regions) {
@@ -180,10 +188,20 @@ function createZustandStore(set, get) {
180
188
  });
181
189
  },
182
190
  onDragValue(event) {
183
- set((state) => {
184
- return { fillValueBaseCell: state.focusedCell };
185
- });
186
191
  event.preventDefault();
192
+ const { focusedCell, updatedData } = get();
193
+ if (focusedCell == null) return;
194
+ set({ fillValueBaseCell: focusedCell, fillBaseData: updatedData });
195
+ window.addEventListener("mouseup", () => get().finishFill(), {
196
+ once: true
197
+ });
198
+ },
199
+ finishFill() {
200
+ const state = get();
201
+ if (state.fillValueBaseCell == null) return;
202
+ const { cells } = fillSelection(state, state.selection);
203
+ set({ fillValueBaseCell: null, fillBaseData: null });
204
+ if (cells.length > 0) get().onEdit?.({ type: "setCells", cells });
187
205
  },
188
206
  onCellEdited(rowIndex, columnName, value) {
189
207
  const targetColumn = get().columnSpec.find((c) => c.key === columnName);
@@ -272,7 +290,7 @@ function createZustandStore(set, get) {
272
290
  }
273
291
  let spec = updateSelection(selection);
274
292
  if (state.fillValueBaseCell != null) {
275
- spec.updatedData = fillValues(state, selection);
293
+ spec.updatedData = fillSelection(state, selection).updatedData;
276
294
  }
277
295
  spec.autoActivateArmed = true;
278
296
  spec.lastNavDirection = null;
@@ -399,9 +417,6 @@ function updateSelection(selection) {
399
417
  focusedCell,
400
418
  topLeftCell: topLeftCell(selection)
401
419
  };
402
- if (focusedCell != null) {
403
- spec.fillValueBaseCell = null;
404
- }
405
420
  return spec;
406
421
  }
407
422
  function getLastRowIndex(regions) {
@@ -458,30 +473,31 @@ function singleFocusedCell(sel) {
458
473
  if (sel?.length !== 1) return null;
459
474
  return topLeftCell(sel, true);
460
475
  }
461
- function fillValues(state, selection) {
462
- const { updatedData, columnSpec, editable, fillValueBaseCell, data } = state;
463
- let regions = selection.map((region) => {
464
- const { cols, rows } = region;
465
- const [col2] = cols ?? [];
466
- return { cols: [col2, col2], rows };
467
- });
468
- if (!editable || fillValueBaseCell == null) return updatedData;
476
+ function fillSelection(state, selection) {
477
+ const { columnSpec, editable, fillValueBaseCell, data } = state;
478
+ const baseData = state.fillBaseData ?? state.updatedData;
479
+ const noFill = { updatedData: state.updatedData, cells: [] };
480
+ if (!editable || fillValueBaseCell == null) return noFill;
469
481
  const { col, row: baseVisibleRow } = fillValueBaseCell;
470
- if (!isColumnWritable(columnSpec[col], editable)) return updatedData;
482
+ if (!isColumnWritable(columnSpec[col], editable)) return noFill;
471
483
  const baseRow = toDataRowIndex(state, baseVisibleRow);
472
484
  const key = columnSpec[col].key;
473
- const value = updatedData[baseRow]?.[key] ?? data[baseRow]?.[key];
485
+ const value = baseData[baseRow]?.[key] ?? data[baseRow]?.[key];
474
486
  const spec = {};
475
- for (const region of regions) {
476
- const { rows } = region;
477
- for (const visibleRow of range(rows ?? [])) {
487
+ const cells = [];
488
+ for (const region of selection) {
489
+ for (const visibleRow of range(region.rows ?? [])) {
478
490
  const row = toDataRowIndex(state, visibleRow);
491
+ if (row === baseRow) continue;
479
492
  if (state.rowStatus[row] === TableElementStatus.DELETED) continue;
480
- let op = updatedData[row] == null ? "$set" : "$merge";
493
+ const current = baseData[row]?.[key] ?? data[row]?.[key];
494
+ if (valuesAreEquivalent(value, current)) continue;
495
+ let op = baseData[row] == null ? "$set" : "$merge";
481
496
  spec[row] = { [op]: { [key]: value } };
497
+ cells.push({ rowIndex: row, column: key, value, row: data[row] });
482
498
  }
483
499
  }
484
- return update(updatedData, spec);
500
+ return { updatedData: update(baseData, spec), cells };
485
501
  }
486
502
  function visibleRowCount(state) {
487
503
  const { filteredRowIndices, updatedData, data } = state;
@@ -1 +1 @@
1
- {"version":3,"file":"zustand-store.js","sources":["../../src/provider/zustand-store.ts"],"sourcesContent":["import {\n DataSheetState,\n DataSheetStore,\n DataSheetStoreMain,\n DEFAULT_ROW_STATUS_STYLES,\n DS_ROW_ID,\n StateUpdater,\n TableElementStatus,\n} from \"./types.ts\";\nimport {\n type FocusedCellCoordinates,\n type Region,\n RegionCardinality,\n} from \"@blueprintjs/table\";\nimport update, { Spec } from \"immutability-helper\";\nimport {\n getSelectedColumnKeys,\n getSelectedRowIndices,\n getSelectionCardinality,\n range,\n} from \"../actions\";\nimport { isColumnWritable } from \"./column-spec.ts\";\n\n/** Monotonic counter for synthetic ids on in-table-added rows. */\nlet _addedRowCounter = 0;\n\nexport function createZustandStore<T>(set, get): DataSheetStoreMain<T> {\n return {\n /** All the data in the table */\n data: [],\n updatedData: [],\n rowStatus: [],\n rowStatusStyles: DEFAULT_ROW_STATUS_STYLES,\n columnSpec: [],\n deferColumnSpec: false,\n defaultColumnWidth: 150,\n editable: false,\n selection: [],\n fillValueBaseCell: null,\n focusedCell: null,\n topLeftCell: null,\n initialized: false,\n tableRef: null,\n // This is a placeholder\n enableColumnReordering: false,\n activeFilters: new Map<string, { filter: any; state: any }>(),\n columnSorts: [],\n clipboardProxy: null,\n filteredRowIndices: null,\n cellInteraction: \"auto\",\n autoActivateArmed: true,\n lastNavDirection: null,\n tableElement: null,\n cellSurfaceOpen: false,\n identity: (row: any) => row?.id,\n pendingOverlayById: new Map(),\n controlledOverlay: false,\n canDeleteRows: true,\n setSelection(selection: Region[]) {\n set(updateSelection(selection));\n },\n columnWidthsIndex: new Map<string, number>(),\n suppressAutoActivate() {\n set({ autoActivateArmed: false });\n },\n armAutoActivate() {\n set({ autoActivateArmed: true });\n },\n openCellSurface() {\n set({ cellSurfaceOpen: true });\n },\n closeCellSurface(opts?: { suppress?: boolean }) {\n const suppress = opts?.suppress ?? true;\n set((state) => ({\n cellSurfaceOpen: false,\n // Escape (suppress) drops auto mode into navigation mode so surfaces\n // stop auto-opening until the next click. A click-dismiss doesn't.\n autoActivateArmed:\n suppress && state.cellInteraction === \"auto\"\n ? false\n : state.autoActivateArmed,\n }));\n },\n moveFocusedCell(direction: \"up\" | \"down\" | \"left\" | \"right\") {\n set((state) => {\n const { topLeftCell } = state;\n if (topLeftCell == null) return {};\n let { col, row } = topLeftCell;\n switch (direction) {\n case \"up\":\n row = Math.max(0, row - 1);\n break;\n case \"down\":\n row = Math.min(\n row + 1,\n Math.max(state.data.length, state.updatedData.length) - 1,\n );\n break;\n case \"left\":\n col = Math.max(0, col - 1);\n break;\n case \"right\":\n col = Math.min(col + 1, state.columnSpec.length - 1);\n break;\n }\n const region: Region = { cols: [col, col], rows: [row, row] };\n // Record the travel direction (so the next editor places its cursor on\n // the side we're moving toward) and open the new cell's surface only\n // when auto-activation is armed.\n return {\n ...updateSelection([region]),\n lastNavDirection: direction,\n cellSurfaceOpen:\n state.cellInteraction === \"auto\" && state.autoActivateArmed,\n };\n });\n },\n addRow(row: Partial<T> = {} as T) {\n /** Add a new row. If there is a selection, use the last row index to determine\n * where to insert the new row. Otherwise, append to the end of the data. */\n let newIndex = -1;\n set((state) => {\n const { updatedData, data, selection, rowStatus } = state;\n\n const lastRowIndex =\n getLastRowIndex(selection) ??\n Math.max(data.length, updatedData.length) - 1;\n // Use $set at a specific index to correctly extend the sparse array.\n // $splice fails when the target index exceeds the array length.\n newIndex = lastRowIndex + 1;\n\n // Stamp a stable synthetic id so the added row survives a provider\n // re-fetch (it has no provider row to match on). Its values live in the\n // overlay (`updatedData`), which the loader-boundary remap re-appends.\n const newRow = {\n ...(row as any),\n [DS_ROW_ID]: `__added_${_addedRowCounter++}`,\n } as T;\n\n return {\n updatedData: insertItemAtIndex(updatedData, newIndex, newRow),\n data: insertItemAtIndex(data, newIndex, newRow),\n rowStatus: insertItemAtIndex(\n rowStatus,\n newIndex,\n TableElementStatus.ADDED,\n ),\n };\n });\n get().onEdit?.({ type: \"addRow\", rowIndex: newIndex, value: row });\n },\n setUpdatedData(data: StateUpdater<T>) {\n if (Array.isArray(data)) {\n set({ updatedData: data });\n } else {\n set((state) => {\n return { updatedData: data(state.updatedData) };\n });\n }\n },\n deleteSelectedRows() {\n // Deletion is a provider capability: if the active data provider can't\n // delete (no `deleteRows`), the whole affordance is disabled.\n if (!get().canDeleteRows) return;\n // Remove selected rows from the data and updatedData arrays\n let deletedIndices: number[] = [];\n set((state) => {\n const { selection, deletedRows } = state;\n const rowIndices = getRowIndices(selection);\n deletedIndices = rowIndices;\n\n // Delete rows from both updatedData and data\n\n // If rows are in addedRows, we just delete them outright from the data and updatedData arrays\n const { addedRows } = state;\n\n const rowsNewlyDeleted = new Set(rowIndices);\n\n // We outright remove rows that have not been added to the data array\n const rowsToRemoveFromDataArrays = new Set(\n rowIndices.filter(\n (d) => state.rowStatus[d] == TableElementStatus.ADDED,\n ),\n );\n // ...otherwise we set them to 'deleted'\n const rowsToMarkAsDeleted = rowsNewlyDeleted.difference(\n rowsToRemoveFromDataArrays,\n );\n\n let data = state.data;\n let updatedData = state.updatedData;\n let rowStatus = state.rowStatus;\n if (rowsToMarkAsDeleted.size > 0) {\n let spec: Spec<TableElementStatus[]> = {};\n for (const ix of rowsToMarkAsDeleted) {\n spec[ix] = { $set: TableElementStatus.DELETED };\n }\n rowStatus = update(rowStatus, spec);\n }\n\n if (rowsToRemoveFromDataArrays.size > 0) {\n const filterFunc = (_, i) => !rowsToRemoveFromDataArrays.has(i);\n data = data.filter(filterFunc);\n updatedData = updatedData.filter(filterFunc);\n rowStatus = rowStatus.filter(filterFunc);\n }\n\n // Remove selected rows and reset selection\n return {\n selection: [],\n data,\n updatedData,\n rowStatus,\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n };\n });\n if (deletedIndices.length > 0) {\n get().onEdit?.({ type: \"deleteRows\", rowIndices: deletedIndices });\n }\n },\n resetChanges(regions?: Region[]) {\n // Reset the updated data to the initial data\n set((state) => resetChangesForSelection(state, regions ?? []));\n get().onEdit?.({ type: \"resetChanges\" });\n },\n onColumnWidthChanged(columnIx: number, newWidth: number) {\n set((state) => {\n const { columnSpec, columnWidthsIndex } = state;\n const colKey = columnSpec[columnIx].key;\n const newColumnWidths = new Map(columnWidthsIndex);\n newColumnWidths.set(colKey, newWidth);\n return { columnWidthsIndex: newColumnWidths };\n });\n },\n onDragValue(event: MouseEvent) {\n set((state) => {\n return { fillValueBaseCell: state.focusedCell };\n });\n event.preventDefault();\n },\n onCellEdited(rowIndex: number, columnName: string, value: any) {\n // The column decides whether it takes writes (see `isColumnWritable`):\n // a locked or derived column is refused here as well as in the cell\n // renderer, so a programmatic caller — the row editor, say — can't\n // write what the grid wouldn't let you type.\n const targetColumn = get().columnSpec.find((c) => c.key === columnName);\n if (!isColumnWritable(targetColumn, get().editable)) return;\n set((state) => {\n const { editable, updatedData, data } = state;\n if (!editable) return {};\n let rowSpec: any;\n\n // Check to see if the new value is meaningfully different from the old\n // one. Empty string and null/undefined are treated as equivalent, so\n // focusing (and blurring) an empty cell doesn't record a phantom edit.\n const oldValue = data[rowIndex]?.[columnName];\n if (!valuesAreEquivalent(value, oldValue)) {\n const rowOp = updatedData[rowIndex] != null ? \"$merge\" : \"$set\";\n rowSpec = { [rowOp]: { [columnName]: value } };\n } else if (updatedData[rowIndex] != null) {\n // No change — drop any prior override for this cell.\n rowSpec = { $unset: [columnName] };\n } else {\n // No change and no prior override: nothing to do. (`$unset` on an\n // absent row would throw in immutability-helper.)\n return {};\n }\n const spec: Spec<T[]> = { [rowIndex]: rowSpec };\n return { updatedData: update(updatedData, spec) };\n });\n if (get().editable) {\n get().onEdit?.({\n type: \"setCells\",\n cells: [\n { rowIndex, column: columnName, value, row: get().data[rowIndex] },\n ],\n });\n }\n },\n clearSelection() {\n const edits: {\n rowIndex: number;\n column: string;\n value: any;\n row?: any;\n }[] = [];\n set((state) => {\n // Delete all selected cells\n const { selection, updatedData, columnSpec, data } = state;\n const numVisible = visibleRowCount(state);\n let spec = {};\n for (const region of selection) {\n const { cols, rows } = region;\n const rowRange = range(rows ?? [0, numVisible - 1]);\n const colRange = range(cols ?? [0, columnSpec.length - 1]);\n for (const visibleRow of rowRange) {\n // Selection indices are visible positions; map to the data row.\n const row = toDataRowIndex(state, visibleRow);\n // Don't clear row if it has been deleted\n const rowIsDeleted =\n state.rowStatus[row] === TableElementStatus.DELETED;\n if (rowIsDeleted) continue;\n let vals = {};\n for (const col of colRange) {\n // A locked or derived column is never cleared\n if (!isColumnWritable(columnSpec[col], state.editable)) continue;\n const key = columnSpec[col].key;\n const currentValue = updatedData[row]?.[key] ?? data[row]?.[key];\n if (currentValue != null && currentValue !== \"\") {\n vals[key] = \"\";\n edits.push({\n rowIndex: row,\n column: key,\n value: \"\",\n row: data[row],\n });\n }\n }\n if (Object.keys(vals).length === 0) continue;\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: vals };\n }\n }\n return {\n updatedData: update(updatedData, spec),\n };\n });\n if (edits.length > 0) {\n get().onEdit?.({ type: \"setCells\", cells: edits });\n }\n },\n onSelection(selection: Region[]) {\n set((state) => {\n const isSameAsPrevSelection = selectionEquals(\n selection,\n state.selection,\n );\n if (\n isSameAsPrevSelection &&\n singleFocusedCell(selection) == null // Only if we're in a multi-cell selection mode\n ) {\n // If the selection is the same as the current selection, remove the selection.\n // In practice this only happens for whole-row and whole-column selections\n return {\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n cellSurfaceOpen: false,\n };\n }\n\n let spec = updateSelection(selection);\n if (state.fillValueBaseCell != null) {\n spec.updatedData = fillValues(state, selection);\n }\n // A click (user selection) re-arms auto-activation and clears the\n // travel direction so the editor opens with a default cursor.\n spec.autoActivateArmed = true;\n spec.lastNavDirection = null;\n // Only open when the selection actually MOVES to a (single) cell.\n // A click on the already-selected cell leaves open-state to the\n // target's click toggle — this avoids racing the selection event\n // (which fires on mousedown, possibly more than once) and is what\n // makes both re-focus-to-open and click-to-close reliable.\n // In \"second-click\" mode a new selection only selects; the click on\n // the already-selected cell opens it.\n if (!selectionEquals(selection, state.selection)) {\n spec.cellSurfaceOpen =\n state.cellInteraction !== \"second-click\" &&\n singleFocusedCell(selection) != null;\n }\n return spec;\n });\n },\n onSelectionEdited(value: any) {\n // Apply the same value to all selected cells\n const edits: {\n rowIndex: number;\n column: string;\n value: any;\n row?: any;\n }[] = [];\n set((state) => {\n const { selection, updatedData, columnSpec, editable } = state;\n if (!editable) return {};\n const numVisible = visibleRowCount(state);\n let spec = {};\n for (const region of selection) {\n const { cols, rows } = region;\n const rowRange = range(rows ?? [0, numVisible - 1]);\n const colRange = range(cols ?? [0, columnSpec.length - 1]);\n for (const visibleRow of rowRange) {\n // Selection indices are visible positions; map to the data row.\n const row = toDataRowIndex(state, visibleRow);\n // A deleted row takes no edits\n if (state.rowStatus[row] === TableElementStatus.DELETED) continue;\n let vals = {};\n for (const col of colRange) {\n // Only the columns that take writes — a selection spanning a\n // locked or derived column writes around it\n if (!isColumnWritable(columnSpec[col], editable)) continue;\n const key = columnSpec[col].key;\n vals[key] = value;\n edits.push({\n rowIndex: row,\n column: key,\n value,\n row: state.data[row],\n });\n }\n if (Object.keys(vals).length === 0) continue;\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: vals };\n }\n }\n return {\n updatedData: update(updatedData, spec),\n };\n });\n if (edits.length > 0) {\n get().onEdit?.({ type: \"setCells\", cells: edits });\n }\n },\n onColumnsReordered(oldIndex: number, newIndex: number, length: number) {\n set((state) => {\n if (!state.enableColumnReordering) return {};\n const { columnSpec } = state;\n const newSpec = [...columnSpec];\n const removed = newSpec.splice(oldIndex, length);\n newSpec.splice(newIndex, 0, ...removed);\n return { columnSpec: newSpec };\n });\n },\n scrollToRow(rowIndex: number) {\n const tableRef = get().tableRef;\n if (tableRef.current == null) return;\n tableRef.current.scrollToRegion({\n rows: [rowIndex, rowIndex],\n });\n },\n // Sort/filter state changes flow to the data provider (via the loader,\n // which reads `activeFilters`/`columnSorts` and re-fetches). The library no\n // longer computes a client-side `filteredRowIndices` view — `data` arrives\n // already ordered from the provider (in memory for a local source).\n setFilter(filterId: string, filter: any, filterState: any) {\n set((state) => {\n const newFilters = new Map<string, { filter: any; state: any }>(\n state.activeFilters,\n );\n newFilters.set(filterId, { filter, state: filterState });\n return { activeFilters: newFilters, ...dropRowSelection(state) };\n });\n },\n removeFilter(filterId: string) {\n set((state) => {\n const newFilters = new Map<string, { filter: any; state: any }>(\n state.activeFilters,\n );\n newFilters.delete(filterId);\n return { activeFilters: newFilters, ...dropRowSelection(state) };\n });\n },\n clearFilters() {\n set((state) => ({\n activeFilters: new Map<string, { filter: any; state: any }>(),\n ...dropRowSelection(state),\n }));\n },\n setColumnSort(key: string, ascending: boolean | null) {\n set((state) => {\n let newSorts;\n if (ascending == null) {\n newSorts = state.columnSorts.filter((s) => s.key !== key);\n } else {\n const without = state.columnSorts.filter((s) => s.key !== key);\n newSorts = [...without, { key, ascending }];\n }\n return { columnSorts: newSorts, ...dropRowSelection(state) };\n });\n },\n clearColumnSorts() {\n set((state) => ({ columnSorts: [], ...dropRowSelection(state) }));\n },\n setClipboardProxy(proxy) {\n set({ clipboardProxy: proxy });\n },\n };\n}\n\n/**\n * Drop the parts of a selection that are addressed by **row index**, because a\n * filter or sort change re-orders and re-filters the rows underneath them —\n * \"rows 3–5\" then means different records, and a set-action would silently act\n * on the wrong ones. Column selections are index-stable under a view change, so\n * they survive (and must: the sheet's sort/filter controls are themselves\n * column-scoped, and are invoked *from* that selection).\n */\nfunction dropRowSelection<T>(\n state: DataSheetState<T>,\n): Partial<DataSheetState<T>> {\n const selection = state.selection ?? [];\n const kept = selection.filter((region) => region.rows == null);\n if (kept.length === selection.length) return {};\n return { selection: kept, focusedCell: null, topLeftCell: null };\n}\n\nexport function updateSelection<T>(selection: Region[]) {\n const focusedCell = singleFocusedCell(selection);\n let spec: Partial<DataSheetState<T>> = {\n selection,\n focusedCell,\n topLeftCell: topLeftCell(selection),\n };\n if (focusedCell != null) {\n spec.fillValueBaseCell = null;\n }\n return spec;\n}\n\nfunction getLastRowIndex(regions: Region[]): number | null {\n /** Get the last row index from a selection of regions */\n if (regions == null || regions.length === 0) return null;\n let lastRow = -1;\n for (const region of regions) {\n const { rows } = region;\n if (rows == null || rows.length !== 2) continue;\n lastRow = Math.max(lastRow, rows[1]);\n }\n if (lastRow < 0) {\n /** If no valid rows are found, return null */\n return null;\n }\n return lastRow;\n}\n\nfunction getRowIndices(regions: Region[]): number[] {\n /** Get the row indices from a selection of regions */\n if (regions == null || regions.length === 0) return [];\n const rowIndices = new Set<number>();\n for (const region of regions) {\n const { rows } = region;\n if (rows == null || rows.length !== 2) continue;\n for (let i = rows[0]; i <= rows[1]; i++) {\n rowIndices.add(i);\n }\n }\n return Array.from(rowIndices).sort((a, b) => a - b);\n}\n\nexport function topLeftCell(\n regions: Region[],\n requireSolitaryCell: boolean = false,\n): FocusedCellCoordinates | null {\n /** Top left cell of a ranged selection */\n if (regions == null) return null;\n const [region] = regions;\n if (region == null) return null;\n const { cols, rows } = region;\n if (cols == null || rows == null) return null;\n if (requireSolitaryCell && (cols[0] !== cols[1] || rows[0] !== rows[1]))\n return null;\n return { col: cols[0], row: rows[0], focusSelectionIndex: 0 };\n}\n\nfunction selectionEquals(a: Region[], b: Region[]): boolean {\n /** Check if two selections are equal */\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const regionA = a[i];\n const regionB = b[i];\n\n const colsA = regionA.cols ?? [];\n const colsB = regionB.cols ?? [];\n\n const rowsA = regionA.rows ?? [];\n const rowsB = regionB.rows ?? [];\n\n if (\n colsA.length !== colsB.length ||\n rowsA.length !== rowsB.length ||\n colsA[0] !== colsB[0] ||\n colsA[1] !== colsB[1] ||\n rowsA[0] !== rowsB[0] ||\n rowsA[1] !== rowsB[1]\n ) {\n return false;\n }\n }\n return true;\n}\n\nexport function singleFocusedCell(\n sel: Region[],\n): FocusedCellCoordinates | null {\n /** Derive a single focused cell from a selected region, if possible */\n if (sel?.length !== 1) return null;\n return topLeftCell(sel, true);\n}\n\nfunction fillValues<T>(state: DataSheetStore<T>, selection: Region[]) {\n const { updatedData, columnSpec, editable, fillValueBaseCell, data } = state;\n\n // Prepare regions by unnesting columns\n let regions = selection.map((region) => {\n const { cols, rows } = region;\n // Get the first column (maybe should be the last)\n const [col] = cols ?? [];\n return { cols: [col, col], rows };\n });\n\n // Fill values downwards\n if (!editable || fillValueBaseCell == null) return updatedData;\n const { col, row: baseVisibleRow } = fillValueBaseCell;\n // Dragging from a locked or derived column fills nothing\n if (!isColumnWritable(columnSpec[col], editable)) return updatedData;\n // The base cell and target rows are visible positions; map to data rows.\n const baseRow = toDataRowIndex(state, baseVisibleRow);\n const key = columnSpec[col].key;\n const value = updatedData[baseRow]?.[key] ?? data[baseRow]?.[key];\n const spec = {};\n for (const region of regions) {\n const { rows } = region;\n for (const visibleRow of range(rows ?? [])) {\n const row = toDataRowIndex(state, visibleRow);\n if (state.rowStatus[row] === TableElementStatus.DELETED) continue;\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: { [key]: value } };\n }\n }\n return update(updatedData, spec);\n}\n\n/** Number of rows currently visible (post-filter/sort), or the full data\n * length when no view transform is active. Uses the max of `data` and\n * `updatedData` lengths because `updatedData` is sparse — keying off it alone\n * would stop a whole-column edit at the last already-edited row. */\nfunction visibleRowCount<T>(state: DataSheetStore<T>): number {\n const { filteredRowIndices, updatedData, data } = state;\n return filteredRowIndices != null\n ? filteredRowIndices.length\n : Math.max(data.length, updatedData.length);\n}\n\n/** Map a visible (post-filter/sort) row position to its underlying data\n * index. Edit methods receive selection indices in visible space, so they\n * must translate before writing to `updatedData`/`data`. */\nfunction toDataRowIndex<T>(\n state: DataSheetStore<T>,\n visibleRow: number,\n): number {\n const { filteredRowIndices } = state;\n if (filteredRowIndices == null) return visibleRow;\n return filteredRowIndices[visibleRow] ?? visibleRow;\n}\n\n/** Whether two cell values are equivalent for edit-tracking. Empty string and\n * null/undefined are equivalent (so clearing an empty cell is a no-op), and\n * non-blank values are compared by string form so a text editor's `\"42\"`\n * matches a numeric base `42` (otherwise the cell reads as edited when its\n * value didn't actually change). */\nfunction valuesAreEquivalent(a: any, b: any): boolean {\n if (a === b) return true;\n const aBlank = a == null || a === \"\";\n const bBlank = b == null || b === \"\";\n if (aBlank || bBlank) return aBlank && bBlank;\n // Structured values (an interval position, a list of lithologies) compare\n // by content: as strings, every object is \"[object Object]\", so any edit\n // to one — or to a list that keeps its length — read as no change\n if (typeof a === \"object\" || typeof b === \"object\") {\n return JSON.stringify(a) === JSON.stringify(b);\n }\n return String(a) === String(b);\n}\n\nfunction resetChangesForSelection<T>(\n state: DataSheetStore<T>,\n selection: Region[],\n): Partial<DataSheetStore<T>> {\n const emptySelection = {\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n };\n\n const { data } = state;\n const cardinality =\n getSelectionCardinality(selection ?? []) ?? RegionCardinality.FULL_TABLE;\n\n const rowStatus = [...state.rowStatus];\n const updatedData = [...state.updatedData];\n const addedRows = new Set<number>();\n\n // Global reset\n switch (cardinality) {\n case RegionCardinality.FULL_TABLE:\n for (let i = 0; i < rowStatus.length; i++) {\n if (rowStatus[i] === TableElementStatus.ADDED) {\n addedRows.add(i);\n }\n }\n\n return {\n updatedData: [],\n rowStatus: [],\n data: data.filter((_, i) => !addedRows.has(i)),\n ...emptySelection,\n };\n case RegionCardinality.FULL_COLUMNS:\n case RegionCardinality.CELLS:\n /** Columns or cells. Note, these only work the same because we don't\n * allow column deletion, only unsetting all values.\n */\n const columnKeys = getSelectedColumnKeys(selection, state.columnSpec);\n const spec: Spec<Record<string, any>[]> = {};\n const rowIndices =\n cardinality == RegionCardinality.FULL_COLUMNS\n ? Array.from({ length: updatedData.length }, (_, i) => i)\n : getSelectedRowIndices(selection);\n for (const row of rowIndices) {\n if (updatedData[row] == null) continue;\n spec[row] = { $unset: columnKeys };\n }\n // TODO: if we allow column addition/deletion, this will require more adjustment\n return {\n updatedData: update(updatedData, spec as any),\n ...emptySelection,\n };\n case RegionCardinality.FULL_ROWS:\n for (const row of getSelectedRowIndices(selection)) {\n updatedData[row] = undefined;\n if (state.rowStatus[row] === TableElementStatus.DELETED) {\n rowStatus[row] = undefined;\n } else if (state.rowStatus[row] === TableElementStatus.ADDED) {\n addedRows.add(row);\n }\n }\n\n const removeCandidateRows = (arr: any[]) => {\n return arr.filter((d, i) => !addedRows.has(i));\n };\n\n return {\n updatedData: removeCandidateRows(updatedData),\n data: removeCandidateRows(state.data),\n rowStatus: removeCandidateRows(rowStatus),\n ...emptySelection,\n };\n }\n}\n\nfunction insertItemAtIndex<T>(arr: T[], index: number, item: T) {\n if (arr.length < index) {\n const newArr = [...arr];\n newArr.length = index;\n newArr[index] = item;\n return newArr;\n }\n\n return [...arr.slice(0, index), item, ...arr.slice(index)];\n}\n"],"names":["topLeftCell","col"],"mappings":";;;;;AAwBA,IAAI,mBAAmB;AAEhB,SAAS,mBAAsB,KAAK,KAA4B;AACrE,SAAO;AAAA;AAAA,IAEL,MAAM,CAAA;AAAA,IACN,aAAa,CAAA;AAAA,IACb,WAAW,CAAA;AAAA,IACX,iBAAiB;AAAA,IACjB,YAAY,CAAA;AAAA,IACZ,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,IACpB,UAAU;AAAA,IACV,WAAW,CAAA;AAAA,IACX,mBAAmB;AAAA,IACnB,aAAa;AAAA,IACb,aAAa;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA;AAAA,IAEV,wBAAwB;AAAA,IACxB,mCAAmB,IAAA;AAAA,IACnB,aAAa,CAAA;AAAA,IACb,gBAAgB;AAAA,IAChB,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,UAAU,CAAC,QAAa,KAAK;AAAA,IAC7B,wCAAwB,IAAA;AAAA,IACxB,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,aAAa,WAAqB;AAChC,UAAI,gBAAgB,SAAS,CAAC;AAAA,IAChC;AAA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AAC,QAAe;AAC1C,eAAO,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;AAAA,MAC/C;AAEA,aAAO;AAAA,QACL,aAAa,oBAAoB,WAAW;AAAA,QAC5C,MAAM,oBAAoB,MAAM,IAAI;AAAA,QACpC,WAAW,oBAAoB,SAAS;AAAA,QACxC,GAAG;AAAA,MAAA;AAAA,EACL;AAEN;AAEA,SAAS,kBAAqB,KAAU,OAAe,MAAS;AAC9D,MAAI,IAAI,SAAS,OAAO;AACtB,UAAM,SAAS,CAAC,GAAG,GAAG;AACtB,WAAO,SAAS;AAChB,WAAO,KAAK,IAAI;AAChB,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,GAAG,IAAI,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,MAAM,KAAK,CAAC;AAC3D;"}
1
+ {"version":3,"file":"zustand-store.js","sources":["../../src/provider/zustand-store.ts"],"sourcesContent":["import {\n CellEdit,\n DataSheetState,\n DataSheetStore,\n DataSheetStoreMain,\n DEFAULT_ROW_STATUS_STYLES,\n DS_ROW_ID,\n StateUpdater,\n TableElementStatus,\n} from \"./types.ts\";\nimport {\n type FocusedCellCoordinates,\n type Region,\n RegionCardinality,\n} from \"@blueprintjs/table\";\nimport update, { Spec } from \"immutability-helper\";\nimport {\n getSelectedColumnKeys,\n getSelectedRowIndices,\n getSelectionCardinality,\n range,\n} from \"../actions\";\nimport { isColumnWritable } from \"./column-spec.ts\";\n\n/** Monotonic counter for synthetic ids on in-table-added rows. */\nlet _addedRowCounter = 0;\n\nexport function createZustandStore<T>(set, get): DataSheetStoreMain<T> {\n return {\n /** All the data in the table */\n data: [],\n updatedData: [],\n rowStatus: [],\n rowStatusStyles: DEFAULT_ROW_STATUS_STYLES,\n columnSpec: [],\n deferColumnSpec: false,\n defaultColumnWidth: 150,\n rowHeight: 20,\n editable: false,\n selection: [],\n fillValueBaseCell: null,\n fillBaseData: null,\n focusedCell: null,\n topLeftCell: null,\n initialized: false,\n tableRef: null,\n // This is a placeholder\n enableColumnReordering: false,\n activeFilters: new Map<string, { filter: any; state: any }>(),\n columnSorts: [],\n clipboardProxy: null,\n filteredRowIndices: null,\n cellInteraction: \"auto\",\n autoActivateArmed: true,\n lastNavDirection: null,\n tableElement: null,\n cellSurfaceOpen: false,\n identity: (row: any) => row?.id,\n pendingOverlayById: new Map(),\n controlledOverlay: false,\n canDeleteRows: true,\n setSelection(selection: Region[]) {\n set(updateSelection(selection));\n },\n columnWidthsIndex: new Map<string, number>(),\n suppressAutoActivate() {\n set({ autoActivateArmed: false });\n },\n armAutoActivate() {\n set({ autoActivateArmed: true });\n },\n openCellSurface() {\n set({ cellSurfaceOpen: true });\n },\n closeCellSurface(opts?: { suppress?: boolean }) {\n const suppress = opts?.suppress ?? true;\n set((state) => ({\n cellSurfaceOpen: false,\n // Escape (suppress) drops auto mode into navigation mode so surfaces\n // stop auto-opening until the next click. A click-dismiss doesn't.\n autoActivateArmed:\n suppress && state.cellInteraction === \"auto\"\n ? false\n : state.autoActivateArmed,\n }));\n },\n moveFocusedCell(direction: \"up\" | \"down\" | \"left\" | \"right\") {\n set((state) => {\n const { topLeftCell } = state;\n if (topLeftCell == null) return {};\n let { col, row } = topLeftCell;\n switch (direction) {\n case \"up\":\n row = Math.max(0, row - 1);\n break;\n case \"down\":\n row = Math.min(\n row + 1,\n Math.max(state.data.length, state.updatedData.length) - 1,\n );\n break;\n case \"left\":\n col = Math.max(0, col - 1);\n break;\n case \"right\":\n col = Math.min(col + 1, state.columnSpec.length - 1);\n break;\n }\n const region: Region = { cols: [col, col], rows: [row, row] };\n // Record the travel direction (so the next editor places its cursor on\n // the side we're moving toward) and open the new cell's surface only\n // when auto-activation is armed.\n return {\n ...updateSelection([region]),\n lastNavDirection: direction,\n cellSurfaceOpen:\n state.cellInteraction === \"auto\" && state.autoActivateArmed,\n };\n });\n },\n addRow(row: Partial<T> = {} as T) {\n /** Add a new row. If there is a selection, use the last row index to determine\n * where to insert the new row. Otherwise, append to the end of the data. */\n let newIndex = -1;\n set((state) => {\n const { updatedData, data, selection, rowStatus } = state;\n\n const lastRowIndex =\n getLastRowIndex(selection) ??\n Math.max(data.length, updatedData.length) - 1;\n // Use $set at a specific index to correctly extend the sparse array.\n // $splice fails when the target index exceeds the array length.\n newIndex = lastRowIndex + 1;\n\n // Stamp a stable synthetic id so the added row survives a provider\n // re-fetch (it has no provider row to match on). Its values live in the\n // overlay (`updatedData`), which the loader-boundary remap re-appends.\n const newRow = {\n ...(row as any),\n [DS_ROW_ID]: `__added_${_addedRowCounter++}`,\n } as T;\n\n return {\n updatedData: insertItemAtIndex(updatedData, newIndex, newRow),\n data: insertItemAtIndex(data, newIndex, newRow),\n rowStatus: insertItemAtIndex(\n rowStatus,\n newIndex,\n TableElementStatus.ADDED,\n ),\n };\n });\n get().onEdit?.({ type: \"addRow\", rowIndex: newIndex, value: row });\n },\n setUpdatedData(data: StateUpdater<T>) {\n if (Array.isArray(data)) {\n set({ updatedData: data });\n } else {\n set((state) => {\n return { updatedData: data(state.updatedData) };\n });\n }\n },\n deleteSelectedRows() {\n // Deletion is a provider capability: if the active data provider can't\n // delete (no `deleteRows`), the whole affordance is disabled.\n if (!get().canDeleteRows) return;\n // Remove selected rows from the data and updatedData arrays\n let deletedIndices: number[] = [];\n let deletedRows: T[] = [];\n set((state) => {\n const { selection } = state;\n const rowIndices = getRowIndices(selection);\n deletedIndices = rowIndices;\n deletedRows = rowIndices.map((i) => state.data[i]);\n\n // Delete rows from both updatedData and data\n\n // If rows are in addedRows, we just delete them outright from the data and updatedData arrays\n const { addedRows } = state;\n\n const rowsNewlyDeleted = new Set(rowIndices);\n\n // We outright remove rows that have not been added to the data array\n const rowsToRemoveFromDataArrays = new Set(\n rowIndices.filter(\n (d) => state.rowStatus[d] == TableElementStatus.ADDED,\n ),\n );\n // ...otherwise we set them to 'deleted'\n const rowsToMarkAsDeleted = rowsNewlyDeleted.difference(\n rowsToRemoveFromDataArrays,\n );\n\n let data = state.data;\n let updatedData = state.updatedData;\n let rowStatus = state.rowStatus;\n if (rowsToMarkAsDeleted.size > 0) {\n let spec: Spec<TableElementStatus[]> = {};\n for (const ix of rowsToMarkAsDeleted) {\n spec[ix] = { $set: TableElementStatus.DELETED };\n }\n rowStatus = update(rowStatus, spec);\n }\n\n if (rowsToRemoveFromDataArrays.size > 0) {\n const filterFunc = (_, i) => !rowsToRemoveFromDataArrays.has(i);\n data = data.filter(filterFunc);\n updatedData = updatedData.filter(filterFunc);\n rowStatus = rowStatus.filter(filterFunc);\n }\n\n // Remove selected rows and reset selection\n return {\n selection: [],\n data,\n updatedData,\n rowStatus,\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n };\n });\n if (deletedIndices.length > 0) {\n get().onEdit?.({\n type: \"deleteRows\",\n rowIndices: deletedIndices,\n rows: deletedRows,\n });\n }\n },\n resetChanges(regions?: Region[]) {\n // Reset the updated data to the initial data\n set((state) => resetChangesForSelection(state, regions ?? []));\n get().onEdit?.({ type: \"resetChanges\" });\n },\n onColumnWidthChanged(columnIx: number, newWidth: number) {\n set((state) => {\n const { columnSpec, columnWidthsIndex } = state;\n const colKey = columnSpec[columnIx].key;\n const newColumnWidths = new Map(columnWidthsIndex);\n newColumnWidths.set(colKey, newWidth);\n return { columnWidthsIndex: newColumnWidths };\n });\n },\n onDragValue(event: MouseEvent) {\n event.preventDefault();\n const { focusedCell, updatedData } = get();\n if (focusedCell == null) return;\n // The fill is drawn from the overlay as it stood when the drag began, so\n // shrinking the drag takes back the rows it leaves.\n set({ fillValueBaseCell: focusedCell, fillBaseData: updatedData });\n // A fill belongs to its drag alone, and the drag ends when the button is\n // released, wherever that is. Left armed, the anchor would fill every\n // later selection that isn't a single cell — a row picked by its header,\n // say — with the anchor's value.\n window.addEventListener(\"mouseup\", () => get().finishFill(), {\n once: true,\n });\n },\n finishFill() {\n const state = get();\n if (state.fillValueBaseCell == null) return;\n const { cells } = fillSelection(state, state.selection);\n set({ fillValueBaseCell: null, fillBaseData: null });\n // Reported like any other write, so a consumer that holds the edits\n // (a controlled overlay) records the fill rather than having it drawn\n // once and then overwritten.\n if (cells.length > 0) get().onEdit?.({ type: \"setCells\", cells });\n },\n onCellEdited(rowIndex: number, columnName: string, value: any) {\n // The column decides whether it takes writes (see `isColumnWritable`):\n // a locked or derived column is refused here as well as in the cell\n // renderer, so a programmatic caller — the row editor, say — can't\n // write what the grid wouldn't let you type.\n const targetColumn = get().columnSpec.find((c) => c.key === columnName);\n if (!isColumnWritable(targetColumn, get().editable)) return;\n set((state) => {\n const { editable, updatedData, data } = state;\n if (!editable) return {};\n let rowSpec: any;\n\n // Check to see if the new value is meaningfully different from the old\n // one. Empty string and null/undefined are treated as equivalent, so\n // focusing (and blurring) an empty cell doesn't record a phantom edit.\n const oldValue = data[rowIndex]?.[columnName];\n if (!valuesAreEquivalent(value, oldValue)) {\n const rowOp = updatedData[rowIndex] != null ? \"$merge\" : \"$set\";\n rowSpec = { [rowOp]: { [columnName]: value } };\n } else if (updatedData[rowIndex] != null) {\n // No change — drop any prior override for this cell.\n rowSpec = { $unset: [columnName] };\n } else {\n // No change and no prior override: nothing to do. (`$unset` on an\n // absent row would throw in immutability-helper.)\n return {};\n }\n const spec: Spec<T[]> = { [rowIndex]: rowSpec };\n return { updatedData: update(updatedData, spec) };\n });\n if (get().editable) {\n get().onEdit?.({\n type: \"setCells\",\n cells: [\n { rowIndex, column: columnName, value, row: get().data[rowIndex] },\n ],\n });\n }\n },\n clearSelection() {\n const edits: {\n rowIndex: number;\n column: string;\n value: any;\n row?: any;\n }[] = [];\n set((state) => {\n // Delete all selected cells\n const { selection, updatedData, columnSpec, data } = state;\n const numVisible = visibleRowCount(state);\n let spec = {};\n for (const region of selection) {\n const { cols, rows } = region;\n const rowRange = range(rows ?? [0, numVisible - 1]);\n const colRange = range(cols ?? [0, columnSpec.length - 1]);\n for (const visibleRow of rowRange) {\n // Selection indices are visible positions; map to the data row.\n const row = toDataRowIndex(state, visibleRow);\n // Don't clear row if it has been deleted\n const rowIsDeleted =\n state.rowStatus[row] === TableElementStatus.DELETED;\n if (rowIsDeleted) continue;\n let vals = {};\n for (const col of colRange) {\n // A locked or derived column is never cleared\n if (!isColumnWritable(columnSpec[col], state.editable)) continue;\n const key = columnSpec[col].key;\n const currentValue = updatedData[row]?.[key] ?? data[row]?.[key];\n if (currentValue != null && currentValue !== \"\") {\n vals[key] = \"\";\n edits.push({\n rowIndex: row,\n column: key,\n value: \"\",\n row: data[row],\n });\n }\n }\n if (Object.keys(vals).length === 0) continue;\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: vals };\n }\n }\n return {\n updatedData: update(updatedData, spec),\n };\n });\n if (edits.length > 0) {\n get().onEdit?.({ type: \"setCells\", cells: edits });\n }\n },\n onSelection(selection: Region[]) {\n set((state) => {\n const isSameAsPrevSelection = selectionEquals(\n selection,\n state.selection,\n );\n if (\n isSameAsPrevSelection &&\n singleFocusedCell(selection) == null // Only if we're in a multi-cell selection mode\n ) {\n // If the selection is the same as the current selection, remove the selection.\n // In practice this only happens for whole-row and whole-column selections\n return {\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n cellSurfaceOpen: false,\n };\n }\n\n let spec = updateSelection(selection);\n if (state.fillValueBaseCell != null) {\n spec.updatedData = fillSelection(state, selection).updatedData;\n }\n // A click (user selection) re-arms auto-activation and clears the\n // travel direction so the editor opens with a default cursor.\n spec.autoActivateArmed = true;\n spec.lastNavDirection = null;\n // Only open when the selection actually MOVES to a (single) cell.\n // A click on the already-selected cell leaves open-state to the\n // target's click toggle — this avoids racing the selection event\n // (which fires on mousedown, possibly more than once) and is what\n // makes both re-focus-to-open and click-to-close reliable.\n // In \"second-click\" mode a new selection only selects; the click on\n // the already-selected cell opens it.\n if (!selectionEquals(selection, state.selection)) {\n spec.cellSurfaceOpen =\n state.cellInteraction !== \"second-click\" &&\n singleFocusedCell(selection) != null;\n }\n return spec;\n });\n },\n onSelectionEdited(value: any) {\n // Apply the same value to all selected cells\n const edits: {\n rowIndex: number;\n column: string;\n value: any;\n row?: any;\n }[] = [];\n set((state) => {\n const { selection, updatedData, columnSpec, editable } = state;\n if (!editable) return {};\n const numVisible = visibleRowCount(state);\n let spec = {};\n for (const region of selection) {\n const { cols, rows } = region;\n const rowRange = range(rows ?? [0, numVisible - 1]);\n const colRange = range(cols ?? [0, columnSpec.length - 1]);\n for (const visibleRow of rowRange) {\n // Selection indices are visible positions; map to the data row.\n const row = toDataRowIndex(state, visibleRow);\n // A deleted row takes no edits\n if (state.rowStatus[row] === TableElementStatus.DELETED) continue;\n let vals = {};\n for (const col of colRange) {\n // Only the columns that take writes — a selection spanning a\n // locked or derived column writes around it\n if (!isColumnWritable(columnSpec[col], editable)) continue;\n const key = columnSpec[col].key;\n vals[key] = value;\n edits.push({\n rowIndex: row,\n column: key,\n value,\n row: state.data[row],\n });\n }\n if (Object.keys(vals).length === 0) continue;\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: vals };\n }\n }\n return {\n updatedData: update(updatedData, spec),\n };\n });\n if (edits.length > 0) {\n get().onEdit?.({ type: \"setCells\", cells: edits });\n }\n },\n onColumnsReordered(oldIndex: number, newIndex: number, length: number) {\n set((state) => {\n if (!state.enableColumnReordering) return {};\n const { columnSpec } = state;\n const newSpec = [...columnSpec];\n const removed = newSpec.splice(oldIndex, length);\n newSpec.splice(newIndex, 0, ...removed);\n return { columnSpec: newSpec };\n });\n },\n scrollToRow(rowIndex: number) {\n const tableRef = get().tableRef;\n if (tableRef.current == null) return;\n tableRef.current.scrollToRegion({\n rows: [rowIndex, rowIndex],\n });\n },\n // Sort/filter state changes flow to the data provider (via the loader,\n // which reads `activeFilters`/`columnSorts` and re-fetches). The library no\n // longer computes a client-side `filteredRowIndices` view — `data` arrives\n // already ordered from the provider (in memory for a local source).\n setFilter(filterId: string, filter: any, filterState: any) {\n set((state) => {\n const newFilters = new Map<string, { filter: any; state: any }>(\n state.activeFilters,\n );\n newFilters.set(filterId, { filter, state: filterState });\n return { activeFilters: newFilters, ...dropRowSelection(state) };\n });\n },\n removeFilter(filterId: string) {\n set((state) => {\n const newFilters = new Map<string, { filter: any; state: any }>(\n state.activeFilters,\n );\n newFilters.delete(filterId);\n return { activeFilters: newFilters, ...dropRowSelection(state) };\n });\n },\n clearFilters() {\n set((state) => ({\n activeFilters: new Map<string, { filter: any; state: any }>(),\n ...dropRowSelection(state),\n }));\n },\n setColumnSort(key: string, ascending: boolean | null) {\n set((state) => {\n let newSorts;\n if (ascending == null) {\n newSorts = state.columnSorts.filter((s) => s.key !== key);\n } else {\n const without = state.columnSorts.filter((s) => s.key !== key);\n newSorts = [...without, { key, ascending }];\n }\n return { columnSorts: newSorts, ...dropRowSelection(state) };\n });\n },\n clearColumnSorts() {\n set((state) => ({ columnSorts: [], ...dropRowSelection(state) }));\n },\n setClipboardProxy(proxy) {\n set({ clipboardProxy: proxy });\n },\n };\n}\n\n/**\n * Drop the parts of a selection that are addressed by **row index**, because a\n * filter or sort change re-orders and re-filters the rows underneath them —\n * \"rows 3–5\" then means different records, and a set-action would silently act\n * on the wrong ones. Column selections are index-stable under a view change, so\n * they survive (and must: the sheet's sort/filter controls are themselves\n * column-scoped, and are invoked *from* that selection).\n */\nfunction dropRowSelection<T>(\n state: DataSheetState<T>,\n): Partial<DataSheetState<T>> {\n const selection = state.selection ?? [];\n const kept = selection.filter((region) => region.rows == null);\n if (kept.length === selection.length) return {};\n return { selection: kept, focusedCell: null, topLeftCell: null };\n}\n\nexport function updateSelection<T>(selection: Region[]) {\n const focusedCell = singleFocusedCell(selection);\n let spec: Partial<DataSheetState<T>> = {\n selection,\n focusedCell,\n topLeftCell: topLeftCell(selection),\n };\n return spec;\n}\n\nfunction getLastRowIndex(regions: Region[]): number | null {\n /** Get the last row index from a selection of regions */\n if (regions == null || regions.length === 0) return null;\n let lastRow = -1;\n for (const region of regions) {\n const { rows } = region;\n if (rows == null || rows.length !== 2) continue;\n lastRow = Math.max(lastRow, rows[1]);\n }\n if (lastRow < 0) {\n /** If no valid rows are found, return null */\n return null;\n }\n return lastRow;\n}\n\nfunction getRowIndices(regions: Region[]): number[] {\n /** Get the row indices from a selection of regions */\n if (regions == null || regions.length === 0) return [];\n const rowIndices = new Set<number>();\n for (const region of regions) {\n const { rows } = region;\n if (rows == null || rows.length !== 2) continue;\n for (let i = rows[0]; i <= rows[1]; i++) {\n rowIndices.add(i);\n }\n }\n return Array.from(rowIndices).sort((a, b) => a - b);\n}\n\nexport function topLeftCell(\n regions: Region[],\n requireSolitaryCell: boolean = false,\n): FocusedCellCoordinates | null {\n /** Top left cell of a ranged selection */\n if (regions == null) return null;\n const [region] = regions;\n if (region == null) return null;\n const { cols, rows } = region;\n if (cols == null || rows == null) return null;\n if (requireSolitaryCell && (cols[0] !== cols[1] || rows[0] !== rows[1]))\n return null;\n return { col: cols[0], row: rows[0], focusSelectionIndex: 0 };\n}\n\nfunction selectionEquals(a: Region[], b: Region[]): boolean {\n /** Check if two selections are equal */\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const regionA = a[i];\n const regionB = b[i];\n\n const colsA = regionA.cols ?? [];\n const colsB = regionB.cols ?? [];\n\n const rowsA = regionA.rows ?? [];\n const rowsB = regionB.rows ?? [];\n\n if (\n colsA.length !== colsB.length ||\n rowsA.length !== rowsB.length ||\n colsA[0] !== colsB[0] ||\n colsA[1] !== colsB[1] ||\n rowsA[0] !== rowsB[0] ||\n rowsA[1] !== rowsB[1]\n ) {\n return false;\n }\n }\n return true;\n}\n\nexport function singleFocusedCell(\n sel: Region[],\n): FocusedCellCoordinates | null {\n /** Derive a single focused cell from a selected region, if possible */\n if (sel?.length !== 1) return null;\n return topLeftCell(sel, true);\n}\n\n/** A fill-drag over `selection`: the anchor cell's value written down the\n * anchor's column in every selected row. Drawn from the overlay as it stood\n * when the drag began (`fillBaseData`), so the result is the fill alone, and\n * returned with the cells it changed. */\nfunction fillSelection<T>(\n state: DataSheetStore<T>,\n selection: Region[],\n): { updatedData: T[]; cells: CellEdit[] } {\n const { columnSpec, editable, fillValueBaseCell, data } = state;\n const baseData = state.fillBaseData ?? state.updatedData;\n const noFill = { updatedData: state.updatedData, cells: [] };\n\n if (!editable || fillValueBaseCell == null) return noFill;\n const { col, row: baseVisibleRow } = fillValueBaseCell;\n // Dragging from a locked or derived column fills nothing\n if (!isColumnWritable(columnSpec[col], editable)) return noFill;\n // The base cell and target rows are visible positions; map to data rows.\n const baseRow = toDataRowIndex(state, baseVisibleRow);\n const key = columnSpec[col].key;\n const value = baseData[baseRow]?.[key] ?? data[baseRow]?.[key];\n\n const spec = {};\n const cells: CellEdit[] = [];\n for (const region of selection) {\n for (const visibleRow of range(region.rows ?? [])) {\n const row = toDataRowIndex(state, visibleRow);\n if (row === baseRow) continue;\n if (state.rowStatus[row] === TableElementStatus.DELETED) continue;\n const current = baseData[row]?.[key] ?? data[row]?.[key];\n if (valuesAreEquivalent(value, current)) continue;\n let op = baseData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: { [key]: value } };\n cells.push({ rowIndex: row, column: key, value, row: data[row] });\n }\n }\n return { updatedData: update(baseData, spec), cells };\n}\n\n/** Number of rows currently visible (post-filter/sort), or the full data\n * length when no view transform is active. Uses the max of `data` and\n * `updatedData` lengths because `updatedData` is sparse — keying off it alone\n * would stop a whole-column edit at the last already-edited row. */\nfunction visibleRowCount<T>(state: DataSheetStore<T>): number {\n const { filteredRowIndices, updatedData, data } = state;\n return filteredRowIndices != null\n ? filteredRowIndices.length\n : Math.max(data.length, updatedData.length);\n}\n\n/** Map a visible (post-filter/sort) row position to its underlying data\n * index. Edit methods receive selection indices in visible space, so they\n * must translate before writing to `updatedData`/`data`. */\nfunction toDataRowIndex<T>(\n state: DataSheetStore<T>,\n visibleRow: number,\n): number {\n const { filteredRowIndices } = state;\n if (filteredRowIndices == null) return visibleRow;\n return filteredRowIndices[visibleRow] ?? visibleRow;\n}\n\n/** Whether two cell values are equivalent for edit-tracking. Empty string and\n * null/undefined are equivalent (so clearing an empty cell is a no-op), and\n * non-blank values are compared by string form so a text editor's `\"42\"`\n * matches a numeric base `42` (otherwise the cell reads as edited when its\n * value didn't actually change). */\nfunction valuesAreEquivalent(a: any, b: any): boolean {\n if (a === b) return true;\n const aBlank = a == null || a === \"\";\n const bBlank = b == null || b === \"\";\n if (aBlank || bBlank) return aBlank && bBlank;\n // Structured values (an interval position, a list of lithologies) compare\n // by content: as strings, every object is \"[object Object]\", so any edit\n // to one — or to a list that keeps its length — read as no change\n if (typeof a === \"object\" || typeof b === \"object\") {\n return JSON.stringify(a) === JSON.stringify(b);\n }\n return String(a) === String(b);\n}\n\nfunction resetChangesForSelection<T>(\n state: DataSheetStore<T>,\n selection: Region[],\n): Partial<DataSheetStore<T>> {\n const emptySelection = {\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n };\n\n const { data } = state;\n const cardinality =\n getSelectionCardinality(selection ?? []) ?? RegionCardinality.FULL_TABLE;\n\n const rowStatus = [...state.rowStatus];\n const updatedData = [...state.updatedData];\n const addedRows = new Set<number>();\n\n // Global reset\n switch (cardinality) {\n case RegionCardinality.FULL_TABLE:\n for (let i = 0; i < rowStatus.length; i++) {\n if (rowStatus[i] === TableElementStatus.ADDED) {\n addedRows.add(i);\n }\n }\n\n return {\n updatedData: [],\n rowStatus: [],\n data: data.filter((_, i) => !addedRows.has(i)),\n ...emptySelection,\n };\n case RegionCardinality.FULL_COLUMNS:\n case RegionCardinality.CELLS:\n /** Columns or cells. Note, these only work the same because we don't\n * allow column deletion, only unsetting all values.\n */\n const columnKeys = getSelectedColumnKeys(selection, state.columnSpec);\n const spec: Spec<Record<string, any>[]> = {};\n const rowIndices =\n cardinality == RegionCardinality.FULL_COLUMNS\n ? Array.from({ length: updatedData.length }, (_, i) => i)\n : getSelectedRowIndices(selection);\n for (const row of rowIndices) {\n if (updatedData[row] == null) continue;\n spec[row] = { $unset: columnKeys };\n }\n // TODO: if we allow column addition/deletion, this will require more adjustment\n return {\n updatedData: update(updatedData, spec as any),\n ...emptySelection,\n };\n case RegionCardinality.FULL_ROWS:\n for (const row of getSelectedRowIndices(selection)) {\n updatedData[row] = undefined;\n if (state.rowStatus[row] === TableElementStatus.DELETED) {\n rowStatus[row] = undefined;\n } else if (state.rowStatus[row] === TableElementStatus.ADDED) {\n addedRows.add(row);\n }\n }\n\n const removeCandidateRows = (arr: any[]) => {\n return arr.filter((d, i) => !addedRows.has(i));\n };\n\n return {\n updatedData: removeCandidateRows(updatedData),\n data: removeCandidateRows(state.data),\n rowStatus: removeCandidateRows(rowStatus),\n ...emptySelection,\n };\n }\n}\n\nfunction insertItemAtIndex<T>(arr: T[], index: number, item: T) {\n if (arr.length < index) {\n const newArr = [...arr];\n newArr.length = index;\n newArr[index] = item;\n return newArr;\n }\n\n return [...arr.slice(0, index), item, ...arr.slice(index)];\n}\n"],"names":["topLeftCell"],"mappings":";;;;;AAyBA,IAAI,mBAAmB;AAEhB,SAAS,mBAAsB,KAAK,KAA4B;AACrE,SAAO;AAAA;AAAA,IAEL,MAAM,CAAA;AAAA,IACN,aAAa,CAAA;AAAA,IACb,WAAW,CAAA;AAAA,IACX,iBAAiB;AAAA,IACjB,YAAY,CAAA;AAAA,IACZ,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,IACpB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW,CAAA;AAAA,IACX,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,aAAa;AAAA,IACb,aAAa;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA;AAAA,IAEV,wBAAwB;AAAA,IACxB,mCAAmB,IAAA;AAAA,IACnB,aAAa,CAAA;AAAA,IACb,gBAAgB;AAAA,IAChB,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,UAAU,CAAC,QAA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AAK,CAAC;AAC3D;"}
@@ -22,7 +22,7 @@ function validationEqual(a, b) {
22
22
  function cellContentsEqual(a, b) {
23
23
  const x = a.cellContext;
24
24
  const y = b.cellContext;
25
- return x.column === y.column && x.value === y.value && x.row === y.row && x.rowIndex === y.rowIndex && x.colIndex === y.colIndex && x.isEdited === y.isEdited && x.isDeleted === y.isDeleted && x.status === y.status && validationEqual(x.validation, y.validation);
25
+ return x.column === y.column && x.value === y.value && x.row === y.row && x.rowIndex === y.rowIndex && x.colIndex === y.colIndex && x.isEdited === y.isEdited && x.isDeleted === y.isDeleted && x.status === y.status && x.width === y.width && x.height === y.height && validationEqual(x.validation, y.validation);
26
26
  }
27
27
  const CellContent = react.memo(function CellContent2({
28
28
  cellContext
@@ -69,7 +69,11 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
69
69
  isEdited: edited,
70
70
  isDeleted,
71
71
  status: statusVal,
72
- validation: validation$1
72
+ validation: validation$1,
73
+ // The size the table gives the cell (resized columns included), so a
74
+ // renderer that fits itself to it needn't measure
75
+ width: state.columnWidthsIndex?.get(col.key) ?? col.width ?? state.defaultColumnWidth,
76
+ height: state.rowHeight
73
77
  };
74
78
  const style = statusStyle?.cellStyle != null ? { ...col.style, ...statusStyle.cellStyle } : col.style;
75
79
  const detailPresentation = col.cellDetail != null ? col.detailPresentation ?? "popover" : null;
@@ -100,6 +104,9 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
100
104
  let inlineEditor = editable ? inlineEditorSpec ?? true : false;
101
105
  const makeDetailCtx = (editableFlag) => ({
102
106
  ...cellContext,
107
+ // A popover isn't laid out in the cell
108
+ width: void 0,
109
+ height: void 0,
103
110
  surface: "cell",
104
111
  editable: editableFlag,
105
112
  onChange(v) {
@@ -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 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 };\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 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,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,E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
+ {"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"],"mapp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B;AAC1D,UAAM,MAAM,UAAU,IAAK,GAAG,OAAO,UAAU;AAC/C,OAAG,kBAAkB,KAAK,GAAG;AAAA,EAE/B,GAAG,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;;"}
@@ -18,7 +18,7 @@ function validationEqual(a, b) {
18
18
  function cellContentsEqual(a, b) {
19
19
  const x = a.cellContext;
20
20
  const y = b.cellContext;
21
- return x.column === y.column && x.value === y.value && x.row === y.row && x.rowIndex === y.rowIndex && x.colIndex === y.colIndex && x.isEdited === y.isEdited && x.isDeleted === y.isDeleted && x.status === y.status && validationEqual(x.validation, y.validation);
21
+ return x.column === y.column && x.value === y.value && x.row === y.row && x.rowIndex === y.rowIndex && x.colIndex === y.colIndex && x.isEdited === y.isEdited && x.isDeleted === y.isDeleted && x.status === y.status && x.width === y.width && x.height === y.height && validationEqual(x.validation, y.validation);
22
22
  }
23
23
  const CellContent = memo(function CellContent2({
24
24
  cellContext
@@ -65,7 +65,11 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
65
65
  isEdited: edited,
66
66
  isDeleted,
67
67
  status: statusVal,
68
- validation
68
+ validation,
69
+ // The size the table gives the cell (resized columns included), so a
70
+ // renderer that fits itself to it needn't measure
71
+ width: state.columnWidthsIndex?.get(col.key) ?? col.width ?? state.defaultColumnWidth,
72
+ height: state.rowHeight
69
73
  };
70
74
  const style = statusStyle?.cellStyle != null ? { ...col.style, ...statusStyle.cellStyle } : col.style;
71
75
  const detailPresentation = col.cellDetail != null ? col.detailPresentation ?? "popover" : null;
@@ -96,6 +100,9 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, filteredRowInd
96
100
  let inlineEditor = editable ? inlineEditorSpec ?? true : false;
97
101
  const makeDetailCtx = (editableFlag) => ({
98
102
  ...cellContext,
103
+ // A popover isn't laid out in the cell
104
+ width: void 0,
105
+ height: void 0,
99
106
  surface: "cell",
100
107
  editable: editableFlag,
101
108
  onChange(v) {