@macrostrat/data-sheet 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/actions/column-controls.cjs +17 -5
  3. package/dist/actions/column-controls.cjs.map +1 -1
  4. package/dist/actions/column-controls.js +18 -6
  5. package/dist/actions/column-controls.js.map +1 -1
  6. package/dist/actions/column-filter.cjs +48 -25
  7. package/dist/actions/column-filter.cjs.map +1 -1
  8. package/dist/actions/column-filter.js +50 -27
  9. package/dist/actions/column-filter.js.map +1 -1
  10. package/dist/actions/table-controls.cjs +4 -0
  11. package/dist/actions/table-controls.cjs.map +1 -1
  12. package/dist/actions/table-controls.js +4 -0
  13. package/dist/actions/table-controls.js.map +1 -1
  14. package/dist/actions/toolbar.cjs +19 -5
  15. package/dist/actions/toolbar.cjs.map +1 -1
  16. package/dist/actions/toolbar.js +20 -6
  17. package/dist/actions/toolbar.js.map +1 -1
  18. package/dist/cell-renderer.cjs +1 -1
  19. package/dist/cell-renderer.cjs.map +1 -1
  20. package/dist/cell-renderer.js +1 -1
  21. package/dist/cell-renderer.js.map +1 -1
  22. package/dist/core.cjs +11 -2
  23. package/dist/core.cjs.map +1 -1
  24. package/dist/core.d.ts +4 -0
  25. package/dist/core.js +11 -2
  26. package/dist/core.js.map +1 -1
  27. package/dist/filters/operators.cjs +2 -2
  28. package/dist/filters/operators.cjs.map +1 -1
  29. package/dist/filters/operators.d.ts +1 -1
  30. package/dist/filters/operators.js +2 -2
  31. package/dist/filters/operators.js.map +1 -1
  32. package/dist/postgrest-table/data-loaders.cjs +1 -8
  33. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  34. package/dist/postgrest-table/data-loaders.js +1 -8
  35. package/dist/postgrest-table/data-loaders.js.map +1 -1
  36. package/dist/provider.cjs +9 -3
  37. package/dist/provider.cjs.map +1 -1
  38. package/dist/provider.d.ts +2 -1
  39. package/dist/provider.js +9 -3
  40. package/dist/provider.js.map +1 -1
  41. package/dist/renderers/column-header-cell.cjs +19 -4
  42. package/dist/renderers/column-header-cell.cjs.map +1 -1
  43. package/dist/renderers/column-header-cell.d.ts +1 -2
  44. package/dist/renderers/column-header-cell.js +20 -5
  45. package/dist/renderers/column-header-cell.js.map +1 -1
  46. package/dist/types.cjs.map +1 -1
  47. package/dist/types.d.ts +10 -1
  48. package/dist/types.js.map +1 -1
  49. package/dist/utils/column-spec.cjs.map +1 -1
  50. package/dist/utils/column-spec.d.ts +4 -0
  51. package/dist/utils/column-spec.js.map +1 -1
  52. package/dist/zustand-store.cjs +1 -0
  53. package/dist/zustand-store.cjs.map +1 -1
  54. package/dist/zustand-store.js +1 -0
  55. package/dist/zustand-store.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/actions/column-controls.ts +24 -7
  58. package/src/actions/column-filter.ts +59 -30
  59. package/src/actions/table-controls.ts +4 -0
  60. package/src/actions/toolbar.ts +39 -11
  61. package/src/cell-renderer.ts +6 -1
  62. package/src/core.ts +26 -3
  63. package/src/filters/operators.ts +5 -3
  64. package/src/postgrest-table/data-loaders.ts +6 -10
  65. package/src/provider.ts +22 -5
  66. package/src/renderers/column-header-cell.ts +31 -4
  67. package/src/types.ts +10 -1
  68. package/src/utils/column-spec.ts +4 -0
  69. package/src/zustand-store.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sources":["../src/provider.ts"],"sourcesContent":["import { SetStateAction, useEffect, useRef, useState } from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { createStore, StoreApi, useStore } from \"zustand\";\nimport type { Table } from \"@blueprintjs/table\";\nimport { generateColumnSpec } from \"./utils\";\nimport { createScopedStore } from \"@macrostrat/data-components\";\nimport {\n DataSheetProviderProps,\n DataSheetState,\n DataSheetStore,\n DS_ROW_ID,\n TableElementStatus,\n} from \"./types.ts\";\nimport { createZustandStore } from \"./zustand-store.ts\";\nimport { atomWithStore } from \"jotai-zustand\";\nimport { toasterAtom } from \"./notifications.ts\";\nimport { TableAction } from \"./actions\";\nimport { atom } from \"jotai\";\n\n/** Create a Jotai scoped store */\nexport const ctx = createScopedStore();\n\nexport const storeAPIAtom = atom<StoreApi<DataSheetStore<any>>>();\n\nconst storeWrapperAtom = atom((get) => {\n const _storeAPIAtom = get(storeAPIAtom);\n if (_storeAPIAtom == null) {\n return undefined;\n }\n return atomWithStore(_storeAPIAtom);\n});\n\n/** This is the basis for all other atoms that manipulate the store. */\nexport const storeAtom = atom(\n (get) => {\n const storeWrapper = get(storeWrapperAtom);\n if (storeWrapper == null) {\n return undefined;\n }\n return get(storeWrapper);\n },\n (get, set, action: SetStateAction<T>) => {\n const storeWrapper = get(storeWrapperAtom);\n if (storeWrapper == null) {\n throw new Error(\"Missing DataSheetProvider\");\n }\n return set(storeWrapper, action);\n },\n);\n\nconst initializeStoreAtom = atom(\n null,\n (get, set, payload: Partial<DataSheetStore<T>>) => {\n set(storeAtom, (state) => {\n return {\n ...state,\n ...payload,\n };\n });\n },\n);\n\nexport const tableActionsAtom = atom<TableAction[]>([]);\n\nexport function DataSheetProvider<T>(props: DataSheetProviderProps<T>) {\n const { toaster, ...rest } = props;\n const [store] = useState(() => {\n return createStore<DataSheetStore<T>>(createZustandStore);\n });\n return h(\n ctx.Provider,\n {\n atoms: [\n [storeAPIAtom, store],\n [toasterAtom, toaster],\n ],\n },\n h(DataSheetProviderInner, rest),\n );\n}\n\nexport function DataSheetProviderInner<T>({\n children,\n data,\n columnSpec,\n columnSpecOptions,\n editable,\n enableColumnReordering,\n defaultColumnWidth = 150,\n}: DataSheetProviderProps<T>) {\n const tableRef = useRef<Table>(null);\n\n const initializeStore = ctx.useSet(initializeStoreAtom);\n\n // Not sure how required this initialization is\n useEffect(() => {\n initializeStore({\n columnSpec: columnSpec ?? generateColumnSpec(data, columnSpecOptions),\n editable,\n enableColumnReordering,\n data,\n defaultColumnWidth,\n tableRef,\n });\n }, [data, editable, columnSpec, columnSpecOptions, enableColumnReordering]);\n\n return children;\n}\n\nexport function useStoreAPI<T>(): StoreApi<DataSheetStore<T>> {\n const store = ctx.useValue(storeAPIAtom);\n if (!store) {\n throw new Error(\"Missing DataSheetProvider\");\n }\n return store;\n}\n\nexport function useSelector<T = any, A = any>(\n selector: (state: DataSheetStore<T> & DataSheetComputedVals) => A,\n): A {\n const store = useStoreAPI<T>();\n return useStore(store, selector);\n}\n/** Atoms for efficient sub-selection of state */\n\nexport const columnSpecAtom = atom((get) => get(storeAtom)?.columnSpec ?? []);\n\nexport const tableDataAtom = atom(\n (get) => {\n return get(storeAtom)?.data ?? [];\n },\n (get, set, newData: any[]) => {\n set(storeAtom, (state: DataSheetState<any>): DataSheetState<any> => {\n let next: DataSheetState<any> = { ...state, data: newData };\n if (\n state.data.length == 0 &&\n newData.length > 0 &&\n state.columnSpec.length == 0\n ) {\n // We haven't yet generated the column spec, and we need to do so.\n next.columnSpec = generateColumnSpec(newData, state.columnSpecOptions);\n }\n\n // Re-attach the edit overlay by identity. The loader replaces `data` with\n // re-ordered windows on sort/filter, so an index-keyed overlay would\n // smear; keying by identity keeps edits (and deletes) on their rows, holds\n // edits for not-yet-loaded rows, and re-appends locally-added rows (which\n // aren't in the provider's data) after it. Skipped when the consumer\n // controls the overlay (they own reconciliation).\n if (!state.controlledOverlay) {\n const remap = remapOverlayByIdentity(state, newData);\n next.data = remap.data;\n next.updatedData = remap.updatedData;\n next.rowStatus = remap.rowStatus;\n next.pendingOverlayById = remap.pending;\n }\n\n return next;\n });\n },\n);\n\ntype OverlayEntry = { edit?: any; status?: any };\n\n/** Row identity used by the overlay: an in-table-added row's synthetic id\n * (stable across its edits), else the provider/consumer `identity`. */\nfunction overlayIdentity(\n state: DataSheetState<any>,\n row: any,\n): string | number | null | undefined {\n if (row == null) return undefined;\n const added = row[DS_ROW_ID];\n if (added != null) return added;\n return state.identity(row);\n}\n\n/** Re-project the (index-keyed) edit overlay from the old `data` order onto a\n * new one, matching rows by identity. Edits/statuses whose row is absent from\n * `newData` are held in `pending` and re-applied when the row loads; rows added\n * in-table (status `ADDED`) are re-appended after the provider data (they have\n * no provider row). Starts from the prior pending set so edits survive multiple\n * re-sorts. Returns the reconstructed data (provider rows + re-appended added\n * rows) alongside the re-aligned overlay. */\nfunction remapOverlayByIdentity(\n state: DataSheetState<any>,\n newData: any[],\n): {\n data: any[];\n updatedData: any[];\n rowStatus: any[];\n pending: Map<string | number, OverlayEntry>;\n} {\n const { data: oldData, updatedData, rowStatus } = state;\n\n // Collect current overlay entries by identity, seeded with prior pending.\n const byId = new Map<string | number, OverlayEntry>(state.pendingOverlayById);\n const n = Math.max(\n oldData.length,\n updatedData?.length ?? 0,\n rowStatus?.length ?? 0,\n );\n for (let i = 0; i < n; i++) {\n const row = oldData[i];\n if (row == null) continue;\n const id = overlayIdentity(state, row);\n if (id == null) continue;\n const edit = updatedData?.[i];\n const status = rowStatus?.[i];\n if (edit != null || status != null) byId.set(id, { edit, status });\n }\n\n // Project onto the new data order.\n const resultData = newData.slice();\n const nextUpdated: any[] = [];\n const nextStatus: any[] = [];\n const attached = new Set<string | number>();\n for (let j = 0; j < resultData.length; j++) {\n const row = resultData[j];\n if (row == null) continue;\n const id = overlayIdentity(state, row);\n if (id == null) continue;\n const entry = byId.get(id);\n if (entry == null) continue;\n if (entry.edit != null) nextUpdated[j] = entry.edit;\n if (entry.status != null) nextStatus[j] = entry.status;\n attached.add(id);\n }\n\n // Re-append in-table-added rows (not present in the provider data), then hold\n // anything still unattached (rows not currently loaded) as pending.\n const pending = new Map<string | number, OverlayEntry>();\n for (const [id, entry] of byId) {\n if (attached.has(id)) continue;\n if (entry.status === TableElementStatus.ADDED) {\n const idx = resultData.length;\n resultData.push(entry.edit ?? {});\n nextUpdated[idx] = entry.edit;\n nextStatus[idx] = entry.status;\n } else {\n pending.set(id, entry);\n }\n }\n\n return {\n data: resultData,\n updatedData: nextUpdated,\n rowStatus: nextStatus,\n pending,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AA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,QAAI,SAAS,IAAI,EAAE,EAAG;AACtB,QAAI,MAAM,WAAW,mBAAmB,OAAO;AAC7C,YAAM,MAAM,WAAW;AACvB,iBAAW,KAAK,MAAM,QAAQ,CAAA,CAAE;AAChC,kBAAY,GAAG,IAAI,MAAM;AACzB,iBAAW,GAAG,IAAI,MAAM;AAAA,IAC1B,OAAO;AACL,cAAQ,IAAI,IAAI,KAAK;AAAA,IACvB;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,WAAW;AAAA,IACX;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"provider.js","sources":["../src/provider.ts"],"sourcesContent":["import { SetStateAction, useEffect, useRef, useState } from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { createStore, StoreApi, useStore } from \"zustand\";\nimport type { Table } from \"@blueprintjs/table\";\nimport { generateColumnSpec, type ColumnSpec } from \"./utils\";\nimport { createScopedStore } from \"@macrostrat/data-components\";\nimport {\n DataSheetProviderProps,\n DataSheetState,\n DataSheetStore,\n DS_ROW_ID,\n TableElementStatus,\n} from \"./types.ts\";\nimport { createZustandStore } from \"./zustand-store.ts\";\nimport { atomWithStore } from \"jotai-zustand\";\nimport { toasterAtom } from \"./notifications.ts\";\nimport { TableAction } from \"./actions\";\nimport { atom } from \"jotai\";\n\n/** Create a Jotai scoped store */\nexport const ctx = createScopedStore();\n\nexport const storeAPIAtom = atom<StoreApi<DataSheetStore<any>>>();\n\nconst storeWrapperAtom = atom((get) => {\n const _storeAPIAtom = get(storeAPIAtom);\n if (_storeAPIAtom == null) {\n return undefined;\n }\n return atomWithStore(_storeAPIAtom);\n});\n\n/** This is the basis for all other atoms that manipulate the store. */\nexport const storeAtom = atom(\n (get) => {\n const storeWrapper = get(storeWrapperAtom);\n if (storeWrapper == null) {\n return undefined;\n }\n return get(storeWrapper);\n },\n (get, set, action: SetStateAction<T>) => {\n const storeWrapper = get(storeWrapperAtom);\n if (storeWrapper == null) {\n throw new Error(\"Missing DataSheetProvider\");\n }\n return set(storeWrapper, action);\n },\n);\n\n/** Stable empty spec so a function `columnSpec` yields a constant init value\n * (see `DataSheetProviderInner`). */\nconst EMPTY_SPEC: ColumnSpec[] = [];\n\nconst initializeStoreAtom = atom(\n null,\n (get, set, payload: Partial<DataSheetStore<T>>) => {\n set(storeAtom, (state) => {\n return {\n ...state,\n ...payload,\n };\n });\n },\n);\n\nexport const tableActionsAtom = atom<TableAction[]>([]);\n\nexport function DataSheetProvider<T>(props: DataSheetProviderProps<T>) {\n const { toaster, ...rest } = props;\n const [store] = useState(() => {\n return createStore<DataSheetStore<T>>(createZustandStore);\n });\n return h(\n ctx.Provider,\n {\n atoms: [\n [storeAPIAtom, store],\n [toasterAtom, toaster],\n ],\n },\n h(DataSheetProviderInner, rest),\n );\n}\n\nexport function DataSheetProviderInner<T>({\n children,\n data,\n columnSpec,\n columnSpecOptions,\n editable,\n enableColumnReordering,\n defaultColumnWidth = 150,\n}: DataSheetProviderProps<T>) {\n const tableRef = useRef<Table>(null);\n\n const initializeStore = ctx.useSet(initializeStoreAtom);\n\n // A function `columnSpec` is derived from the loaded rows later (in\n // `_DataSheet`), not here — start it empty. Crucially it's kept OUT of the\n // init effect's deps: re-running init also resets `data`, so re-initializing\n // when the function's identity changes (e.g. a consumer hiding a column)\n // would wipe the loaded rows. `staticSpec` is a stable value in that case.\n const isFnSpec = typeof columnSpec === \"function\";\n const staticSpec = isFnSpec ? EMPTY_SPEC : columnSpec;\n\n // Not sure how required this initialization is\n useEffect(() => {\n initializeStore({\n columnSpec: staticSpec ?? generateColumnSpec(data, columnSpecOptions),\n // A function spec is derived from the loaded rows in `_DataSheet`; tell\n // the loader not to auto-generate a plain spec from the first chunk.\n deferColumnSpec: isFnSpec,\n editable,\n enableColumnReordering,\n data,\n defaultColumnWidth,\n tableRef,\n });\n }, [data, editable, staticSpec, isFnSpec, columnSpecOptions, enableColumnReordering]);\n\n return children;\n}\n\nexport function useStoreAPI<T>(): StoreApi<DataSheetStore<T>> {\n const store = ctx.useValue(storeAPIAtom);\n if (!store) {\n throw new Error(\"Missing DataSheetProvider\");\n }\n return store;\n}\n\nexport function useSelector<T = any, A = any>(\n selector: (state: DataSheetStore<T> & DataSheetComputedVals) => A,\n): A {\n const store = useStoreAPI<T>();\n return useStore(store, selector);\n}\n/** Atoms for efficient sub-selection of state */\n\nexport const columnSpecAtom = atom((get) => get(storeAtom)?.columnSpec ?? []);\n\nexport const tableDataAtom = atom(\n (get) => {\n return get(storeAtom)?.data ?? [];\n },\n (get, set, newData: any[]) => {\n set(storeAtom, (state: DataSheetState<any>): DataSheetState<any> => {\n let next: DataSheetState<any> = { ...state, data: newData };\n if (\n state.data.length == 0 &&\n newData.length > 0 &&\n state.columnSpec.length == 0 &&\n !state.deferColumnSpec\n ) {\n // No spec yet and none deferred to a function — auto-generate a plain\n // spec from the first chunk. (A function spec is derived separately.)\n next.columnSpec = generateColumnSpec(newData, state.columnSpecOptions);\n }\n\n // Re-attach the edit overlay by identity. The loader replaces `data` with\n // re-ordered windows on sort/filter, so an index-keyed overlay would\n // smear; keying by identity keeps edits (and deletes) on their rows, holds\n // edits for not-yet-loaded rows, and re-appends locally-added rows (which\n // aren't in the provider's data) after it. Skipped when the consumer\n // controls the overlay (they own reconciliation).\n if (!state.controlledOverlay) {\n const remap = remapOverlayByIdentity(state, newData);\n next.data = remap.data;\n next.updatedData = remap.updatedData;\n next.rowStatus = remap.rowStatus;\n next.pendingOverlayById = remap.pending;\n }\n\n return next;\n });\n },\n);\n\ntype OverlayEntry = { edit?: any; status?: any };\n\n/** Row identity used by the overlay: an in-table-added row's synthetic id\n * (stable across its edits), else the provider/consumer `identity`. */\nfunction overlayIdentity(\n state: DataSheetState<any>,\n row: any,\n): string | number | null | undefined {\n if (row == null) return undefined;\n const added = row[DS_ROW_ID];\n if (added != null) return added;\n return state.identity(row);\n}\n\n/** Re-project the (index-keyed) edit overlay from the old `data` order onto a\n * new one, matching rows by identity. Edits/statuses whose row is absent from\n * `newData` are held in `pending` and re-applied when the row loads; rows added\n * in-table (status `ADDED`) are re-appended after the provider data (they have\n * no provider row). Starts from the prior pending set so edits survive multiple\n * re-sorts. Returns the reconstructed data (provider rows + re-appended added\n * rows) alongside the re-aligned overlay. */\nfunction remapOverlayByIdentity(\n state: DataSheetState<any>,\n newData: any[],\n): {\n data: any[];\n updatedData: any[];\n rowStatus: any[];\n pending: Map<string | number, OverlayEntry>;\n} {\n const { data: oldData, updatedData, rowStatus } = state;\n\n // Collect current overlay entries by identity, seeded with prior pending.\n const byId = new Map<string | number, OverlayEntry>(state.pendingOverlayById);\n const n = Math.max(\n oldData.length,\n updatedData?.length ?? 0,\n rowStatus?.length ?? 0,\n );\n for (let i = 0; i < n; i++) {\n const row = oldData[i];\n if (row == null) continue;\n const id = overlayIdentity(state, row);\n if (id == null) continue;\n const edit = updatedData?.[i];\n const status = rowStatus?.[i];\n if (edit != null || status != null) byId.set(id, { edit, status });\n }\n\n // Project onto the new data order.\n const resultData = newData.slice();\n const nextUpdated: any[] = [];\n const nextStatus: any[] = [];\n const attached = new Set<string | number>();\n for (let j = 0; j < resultData.length; j++) {\n const row = resultData[j];\n if (row == null) continue;\n const id = overlayIdentity(state, row);\n if (id == null) continue;\n const entry = byId.get(id);\n if (entry == null) continue;\n if (entry.edit != null) nextUpdated[j] = entry.edit;\n if (entry.status != null) nextStatus[j] = entry.status;\n attached.add(id);\n }\n\n // Re-append in-table-added rows (not present in the provider data), then hold\n // anything still unattached (rows not currently loaded) as pending.\n const pending = new Map<string | number, OverlayEntry>();\n for (const [id, entry] of byId) {\n if (attached.has(id)) continue;\n if (entry.status === TableElementStatus.ADDED) {\n const idx = resultData.length;\n resultData.push(entry.edit ?? {});\n nextUpdated[idx] = entry.edit;\n nextStatus[idx] = entry.status;\n } else {\n pending.set(id, entry);\n }\n }\n\n return {\n data: resultData,\n updatedData: nextUpdated,\n rowStatus: nextStatus,\n pending,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;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M,UAAU,KAAM,YAAW,CAAC,IAAI,MAAM;AAChD,aAAS,IAAI,EAAE;AAAA,EACjB;AAIA,QAAM,8BAAc,IAAA;AACpB,aAAW,CAAC,IAAI,KAAK,KAAK,MAAM;AAC9B,QAAI,SAAS,IAAI,EAAE,EAAG;AACtB,QAAI,MAAM,WAAW,mBAAmB,OAAO;AAC7C,YAAM,MAAM,WAAW;AACvB,iBAAW,KAAK,MAAM,QAAQ,CAAA,CAAE;AAChC,kBAAY,GAAG,IAAI,MAAM;AACzB,iBAAW,GAAG,IAAI,MAAM;AAAA,IAC1B,OAAO;AACL,cAAQ,IAAI,IAAI,KAAK;AAAA,IACvB;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,WAAW;AAAA,IACX;AAAA,EAAA;AAEJ;"}
@@ -16,13 +16,24 @@ function renderColumnHeaderCell({
16
16
  const isSortable = col.sortable === true;
17
17
  const isFilterable = col.filterable === true || typeof col.filterable === "object" || Array.isArray(col.filters) && col.filters.length > 0;
18
18
  const hasCustomActions = Array.isArray(col.actions) && col.actions.length > 0;
19
+ const enableColumnReordering = col.reorderable !== false;
19
20
  if (!isSortable && !isFilterable && !hasCustomActions) {
20
- return h__default.default(table.ColumnHeaderCell, { name: col.name });
21
+ return h__default.default(table.ColumnHeaderCell, {
22
+ name: col.name,
23
+ enableColumnReordering,
24
+ nameRenderer: () => h__default.default(ColumnHeaderName, {
25
+ col,
26
+ hasSortActive: false,
27
+ hasFilterActive: false,
28
+ activeSort: null
29
+ })
30
+ });
21
31
  }
22
32
  const hasFilterActive = activeFilter != null;
23
33
  const hasSortActive = activeSort != null;
24
34
  return h__default.default(table.ColumnHeaderCell, {
25
35
  name: col.name,
36
+ enableColumnReordering,
26
37
  // Persistent interaction bar so the menu caret is always clickable — the
27
38
  // hover-triggered caret was blocked by the selection overlay when the
28
39
  // column was selected.
@@ -34,7 +45,10 @@ function renderColumnHeaderCell({
34
45
  function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
35
46
  return h__default.default(
36
47
  "div",
37
- { style: { display: "flex", alignItems: "center", width: "100%" } },
48
+ {
49
+ "data-column-key": col.key,
50
+ style: { display: "flex", alignItems: "center", width: "100%" }
51
+ },
38
52
  [
39
53
  h__default.default(
40
54
  "span",
@@ -68,7 +82,7 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
68
82
  h__default.default.if(hasFilterActive)(core.Icon, {
69
83
  icon: "filter",
70
84
  size: 12,
71
- style: { color: "var(--intent-warning, #d99e0b)" }
85
+ style: { color: "var(--intent-primary, #2965cc)" }
72
86
  })
73
87
  ]
74
88
  )
@@ -85,8 +99,9 @@ function ColumnHeaderControls({ colIndex }) {
85
99
  },
86
100
  storeAPI.setState
87
101
  );
102
+ const isGlobal = (a) => a.targets.includes(table.RegionCardinality.FULL_TABLE) || a.targets.includes("none");
88
103
  const controls = actions.filter(
89
- (a) => a.targets.includes(table.RegionCardinality.FULL_COLUMNS) && (a.appliesTo?.(actionCtx) ?? true)
104
+ (a) => a.targets.includes(table.RegionCardinality.FULL_COLUMNS) && !isGlobal(a) && (a.appliesTo?.(actionCtx) ?? true)
90
105
  );
91
106
  const items = controls.map((a, i) => {
92
107
  if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);
@@ -1 +1 @@
1
- {"version":3,"file":"column-header-cell.cjs","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport { ctx, tableActionsAtom, useStoreAPI } from \"../provider\";\nimport { buildActionContext } from \"../actions/selection\";\nimport type { ColumnSpec } from \"../utils/column-spec\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, { name: col.name });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, { col, hasSortActive, hasFilterActive, activeSort }),\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n return h(\n \"div\",\n { style: { display: \"flex\", alignItems: \"center\", width: \"100%\" } },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n },\n col.name,\n ),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-warning, #d99e0b)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const storeAPI = useStoreAPI();\n const actions = ctx.useValue(tableActionsAtom);\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = buildActionContext(\n {\n ...storeAPI.getState(),\n selection: [{ cols: [colIndex, colIndex], rows: undefined }],\n } as any,\n storeAPI.setState,\n );\n\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\"li.column-header-control\", { key: a.id ?? i }, a.render(actionCtx));\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":["h","ColumnHeaderC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M,EAAE;AAAA,MACR,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,SAAS,MAAM,EAAE,MAAM,SAAS;AAAA,IAAA,CACjC;AAAA,EACH,CAAC,EACA,OAAO,OAAO;AAEjB,MAAI,MAAM,WAAW,GAAG;AACtB,WAAOR,mBAAES,KAAAA,MAAM,CAACT,WAAAA,QAAEQ,KAAAA,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAOR,WAAAA,QAAES,KAAAA,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;;"}
1
+ {"version":3,"file":"column-header-cell.cjs","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport { ctx, tableActionsAtom, useStoreAPI } from \"../provider\";\nimport { buildActionContext } from \"../actions/selection\";\nimport type { ColumnSpec } from \"../utils/column-spec\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n // A column may be pinned against drag-reordering via `reorderable: false`.\n const enableColumnReordering = col.reorderable !== false;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive: false,\n hasFilterActive: false,\n activeSort: null,\n }),\n });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, { col, hasSortActive, hasFilterActive, activeSort }),\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. The column key is\n * exposed as `data-column-key` so consumers can target a specific header from\n * CSS (e.g. to tint a column) without a bespoke styling prop. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n return h(\n \"div\",\n {\n \"data-column-key\": col.key,\n style: { display: \"flex\", alignItems: \"center\", width: \"100%\" },\n },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n },\n col.name,\n ),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const storeAPI = useStoreAPI();\n const actions = ctx.useValue(tableActionsAtom);\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = buildActionContext(\n {\n ...storeAPI.getState(),\n selection: [{ cols: [colIndex, colIndex], rows: undefined }],\n } as any,\n storeAPI.setState,\n );\n\n // Only actions *limited* to column scope belong in a column's dropdown —\n // sort/filter and column-specific actions. Global actions (Save / Reset /\n // Clear-selection, marked by a FULL_TABLE or \"none\" target) are confusing\n // here, so they're excluded even though they nominally apply to columns too.\n const isGlobal = (a: (typeof actions)[number]) =>\n a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any);\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n !isGlobal(a) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\"li.column-header-control\", { key: a.id ?? i }, a.render(actionCtx));\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":["h","ColumnHeaderCell","Icon","useStoreAPI","ctx","tableActionsAtom","buildActionContext","RegionCardinality","MenuItem","Menu"],"mappings":";;;;;;;;;AAmCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,aAAa,IAAI,aAAa;AACpC,QAAM,eACJ,IAAI,eAAe,QACnB,OAAO,IAAI,eAAe,YACzB,MAAM,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,SAAS;AACtD,QAAM,mBACJ,MAAM,QAAS,IAAY,OAAO,KAAM,IAAY,QAAQ,SAAS;AAGvE,QAAM,yBAAyB,IAAI,gBAAgB;AAEnD,MAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,kBAAkB;AACrD,WAAOA,WAAAA,QAAEC,MAAAA,kBAAkB;AAAA,MACzB,MAAM,IAAI;AAAA,MACV;AAAA,MACA,cAAc,MACZD,WAAAA,QAAE,kBAAkB;AAAA,QAClB;AAAA,QACA,eAAe;AAAA,QACf,iBAAiB;AAAA,QACjB,YAAY;AAAA,MAAA,CACb;AAAA,IAAA,CACJ;AAAA,EACH;AAIA,QAAM,kBAAkB,gBAAgB;AACxC,QAAM,gBAAgB,cAAc;AAEpC,SAAOA,WAAAA,QAAEC,MAAAA,kBAAkB;AAAA,IACzB,MAAM,IAAI;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAIA,4BAA4B;AAAA,IAC5B,cAAc,MACZD,WAAAA,QAAE,kBAAkB,EAAE,KAAK,eAAe,iBAAiB,YAAY;AAAA,IACzE,cAAc,MAAMA,WAAAA,QAAE,sBAAsB,EAAE,UAAU;AAAA,EAAA,CACzD;AACH;AAKA,SAAS,iBAAiB,EAAE,KAAK,eAAe,iBAAiB,cAAc;AAC7E,SAAOA,WAAAA;AAAAA,IACL;AAAA,IACA;AAAA,MACE,mBAAmB,IAAI;AAAA,MACvB,OA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;AAAA,IACvB,CAAC,MACC,EAAE,QAAQ,SAASA,MAAAA,kBAAkB,YAAY,KACjD,CAAC,SAAS,CAAC,MACV,EAAE,YAAY,SAAS,KAAK;AAAA,EAAA;AAOjC,QAAM,QAAQ,SACX,IAAI,CAAC,GAAG,MAAM;AACb,QAAI,EAAE,kBAAkB,KAAM,QAAO,EAAE,eAAe,SAAS;AAC/D,QAAI,EAAE,UAAU;AACd,aAAOP,mBAAE,4BAA4B,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,SAAS,CAAC;AAC9E,WAAOA,WAAAA,QAAEQ,KAAAA,UAAU;AAAA,MACjB,KAAK,EAAE,MAAM;AAAA,MACb,MAAM,EAAE;AAAA,MACR,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,SAAS,MAAM,EAAE,MAAM,SAAS;AAAA,IAAA,CACjC;AAAA,EACH,CAAC,EACA,OAAO,OAAO;AAEjB,MAAI,MAAM,WAAW,GAAG;AACtB,WAAOR,mBAAES,KAAAA,MAAM,CAACT,WAAAA,QAAEQ,KAAAA,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAOR,WAAAA,QAAES,KAAAA,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;;"}
@@ -1,4 +1,3 @@
1
- import { ColumnHeaderCell } from '@blueprintjs/table';
2
1
  import { ColumnSpec } from '../utils/column-spec';
3
2
  import { PostgrestColumnFilter, ColumnSortEntry } from '../postgrest-table';
4
3
  export interface ColumnActionsConfig {
@@ -12,4 +11,4 @@ export interface ColumnHeaderRendererProps extends ColumnActionsConfig {
12
11
  /** Column header cell whose dropdown renders the `FULL_COLUMNS` controls
13
12
  * (sort/filter + any custom column actions) from the shared action registry,
14
13
  * scoped to this column. */
15
- export declare function renderColumnHeaderCell({ col, colIndex, activeSort, activeFilter, }: ColumnHeaderRendererProps): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | import('react').ComponentElement<import('@blueprintjs/table').ColumnHeaderCellProps, ColumnHeaderCell>;
14
+ export declare function renderColumnHeaderCell({ col, colIndex, activeSort, activeFilter, }: ColumnHeaderRendererProps): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
@@ -1,6 +1,6 @@
1
1
  import h from "@macrostrat/hyper";
2
2
  import { ColumnHeaderCell, RegionCardinality } from "@blueprintjs/table";
3
- import { MenuItem, Menu, Icon } from "@blueprintjs/core";
3
+ import { Icon, MenuItem, Menu } from "@blueprintjs/core";
4
4
  import { useStoreAPI, ctx, tableActionsAtom } from "../provider.js";
5
5
  import { buildActionContext } from "../actions/selection.js";
6
6
  function renderColumnHeaderCell({
@@ -12,13 +12,24 @@ function renderColumnHeaderCell({
12
12
  const isSortable = col.sortable === true;
13
13
  const isFilterable = col.filterable === true || typeof col.filterable === "object" || Array.isArray(col.filters) && col.filters.length > 0;
14
14
  const hasCustomActions = Array.isArray(col.actions) && col.actions.length > 0;
15
+ const enableColumnReordering = col.reorderable !== false;
15
16
  if (!isSortable && !isFilterable && !hasCustomActions) {
16
- return h(ColumnHeaderCell, { name: col.name });
17
+ return h(ColumnHeaderCell, {
18
+ name: col.name,
19
+ enableColumnReordering,
20
+ nameRenderer: () => h(ColumnHeaderName, {
21
+ col,
22
+ hasSortActive: false,
23
+ hasFilterActive: false,
24
+ activeSort: null
25
+ })
26
+ });
17
27
  }
18
28
  const hasFilterActive = activeFilter != null;
19
29
  const hasSortActive = activeSort != null;
20
30
  return h(ColumnHeaderCell, {
21
31
  name: col.name,
32
+ enableColumnReordering,
22
33
  // Persistent interaction bar so the menu caret is always clickable — the
23
34
  // hover-triggered caret was blocked by the selection overlay when the
24
35
  // column was selected.
@@ -30,7 +41,10 @@ function renderColumnHeaderCell({
30
41
  function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
31
42
  return h(
32
43
  "div",
33
- { style: { display: "flex", alignItems: "center", width: "100%" } },
44
+ {
45
+ "data-column-key": col.key,
46
+ style: { display: "flex", alignItems: "center", width: "100%" }
47
+ },
34
48
  [
35
49
  h(
36
50
  "span",
@@ -64,7 +78,7 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
64
78
  h.if(hasFilterActive)(Icon, {
65
79
  icon: "filter",
66
80
  size: 12,
67
- style: { color: "var(--intent-warning, #d99e0b)" }
81
+ style: { color: "var(--intent-primary, #2965cc)" }
68
82
  })
69
83
  ]
70
84
  )
@@ -81,8 +95,9 @@ function ColumnHeaderControls({ colIndex }) {
81
95
  },
82
96
  storeAPI.setState
83
97
  );
98
+ const isGlobal = (a) => a.targets.includes(RegionCardinality.FULL_TABLE) || a.targets.includes("none");
84
99
  const controls = actions.filter(
85
- (a) => a.targets.includes(RegionCardinality.FULL_COLUMNS) && (a.appliesTo?.(actionCtx) ?? true)
100
+ (a) => a.targets.includes(RegionCardinality.FULL_COLUMNS) && !isGlobal(a) && (a.appliesTo?.(actionCtx) ?? true)
86
101
  );
87
102
  const items = controls.map((a, i) => {
88
103
  if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);
@@ -1 +1 @@
1
- {"version":3,"file":"column-header-cell.js","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport { ctx, tableActionsAtom, useStoreAPI } from \"../provider\";\nimport { buildActionContext } from \"../actions/selection\";\nimport type { ColumnSpec } from \"../utils/column-spec\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, { name: col.name });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, { col, hasSortActive, hasFilterActive, activeSort }),\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n return h(\n \"div\",\n { style: { display: \"flex\", alignItems: \"center\", width: \"100%\" } },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n },\n col.name,\n ),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-warning, #d99e0b)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const storeAPI = useStoreAPI();\n const actions = ctx.useValue(tableActionsAtom);\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = buildActionContext(\n {\n ...storeAPI.getState(),\n selection: [{ cols: [colIndex, colIndex], rows: undefined }],\n } as any,\n storeAPI.setState,\n );\n\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\"li.column-header-control\", { key: a.id ?? i }, a.render(actionCtx));\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":[],"mappings":";;;;;AAmCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,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E,WAAW,yBAAA,GAA4B,KAAK;AAC/D;"}
1
+ {"version":3,"file":"column-header-cell.js","sources":["../../src/renderers/column-header-cell.ts"],"sourcesContent":["/**\n * Column header with client-side sort and filter controls.\n *\n * Mirrors the PostgREST column header UX but operates on in-memory data.\n * Sort state is stored in the DataSheet zustand store; filtering uses the\n * existing `setFilter` / `removeFilter` mechanism with auto-generated\n * predicate filters for simple text search.\n */\nimport h from \"@macrostrat/hyper\";\nimport { ColumnHeaderCell, RegionCardinality } from \"@blueprintjs/table\";\nimport { Icon, Menu, MenuItem } from \"@blueprintjs/core\";\nimport { ctx, tableActionsAtom, useStoreAPI } from \"../provider\";\nimport { buildActionContext } from \"../actions/selection\";\nimport type { ColumnSpec } from \"../utils/column-spec\";\nimport type {\n PostgrestColumnFilter,\n ColumnSortEntry,\n} from \"../postgrest-table\";\n\nexport interface ColumnActionsConfig {\n activeSort?: ColumnSortEntry | null;\n activeFilter?: PostgrestColumnFilter | null;\n}\n\nexport interface ColumnHeaderRendererProps extends ColumnActionsConfig {\n col: ColumnSpec;\n colIndex: number;\n //actions: ColumnHeaderActions;\n}\n\n// ---- Column header cell ----\n\n/** Column header cell whose dropdown renders the `FULL_COLUMNS` controls\n * (sort/filter + any custom column actions) from the shared action registry,\n * scoped to this column. */\nexport function renderColumnHeaderCell({\n col,\n colIndex,\n activeSort,\n activeFilter,\n}: ColumnHeaderRendererProps) {\n const isSortable = col.sortable === true;\n const isFilterable =\n col.filterable === true ||\n typeof col.filterable === \"object\" ||\n (Array.isArray(col.filters) && col.filters.length > 0);\n const hasCustomActions =\n Array.isArray((col as any).actions) && (col as any).actions.length > 0;\n\n // A column may be pinned against drag-reordering via `reorderable: false`.\n const enableColumnReordering = col.reorderable !== false;\n\n if (!isSortable && !isFilterable && !hasCustomActions) {\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n nameRenderer: () =>\n h(ColumnHeaderName, {\n col,\n hasSortActive: false,\n hasFilterActive: false,\n activeSort: null,\n }),\n });\n }\n\n // `activeFilter` is the active store entry targeting this column (any filter\n // type), or null — so the indicator lights for rich and operator filters.\n const hasFilterActive = activeFilter != null;\n const hasSortActive = activeSort != null;\n\n return h(ColumnHeaderCell, {\n name: col.name,\n enableColumnReordering,\n // Persistent interaction bar so the menu caret is always clickable — the\n // hover-triggered caret was blocked by the selection overlay when the\n // column was selected.\n enableColumnInteractionBar: true,\n nameRenderer: () =>\n h(ColumnHeaderName, { col, hasSortActive, hasFilterActive, activeSort }),\n menuRenderer: () => h(ColumnHeaderControls, { colIndex }),\n });\n}\n\n/** Column name with active sort/filter indicator icons. The column key is\n * exposed as `data-column-key` so consumers can target a specific header from\n * CSS (e.g. to tint a column) without a bespoke styling prop. */\nfunction ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {\n return h(\n \"div\",\n {\n \"data-column-key\": col.key,\n style: { display: \"flex\", alignItems: \"center\", width: \"100%\" },\n },\n [\n h(\n \"span\",\n {\n style: {\n flex: 1,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n },\n col.name,\n ),\n h.if(hasSortActive || hasFilterActive)(\n \"span\",\n {\n style: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"2px\",\n marginLeft: \"4px\",\n flexShrink: 0,\n },\n },\n [\n h.if(hasSortActive)(Icon, {\n icon: activeSort?.ascending ? \"sort-asc\" : \"sort-desc\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n h.if(hasFilterActive)(Icon, {\n icon: \"filter\",\n size: 12,\n style: { color: \"var(--intent-primary, #2965cc)\" },\n }),\n ],\n ),\n ],\n );\n}\n\n/** Dropdown content: the `FULL_COLUMNS` controls for this column, sourced from\n * the shared action registry and scoped to the column via a synthetic\n * single-column selection context — so the header and toolbar render the same\n * sort/filter (and custom column) controls. */\nfunction ColumnHeaderControls({ colIndex }: { colIndex: number }) {\n const storeAPI = useStoreAPI();\n const actions = ctx.useValue(tableActionsAtom);\n\n // Scope the action context to this column (as if it were the selection).\n const actionCtx = buildActionContext(\n {\n ...storeAPI.getState(),\n selection: [{ cols: [colIndex, colIndex], rows: undefined }],\n } as any,\n storeAPI.setState,\n );\n\n // Only actions *limited* to column scope belong in a column's dropdown —\n // sort/filter and column-specific actions. Global actions (Save / Reset /\n // Clear-selection, marked by a FULL_TABLE or \"none\" target) are confusing\n // here, so they're excluded even though they nominally apply to columns too.\n const isGlobal = (a: (typeof actions)[number]) =>\n a.targets.includes(RegionCardinality.FULL_TABLE) ||\n a.targets.includes(\"none\" as any);\n const controls = actions.filter(\n (a) =>\n a.targets.includes(RegionCardinality.FULL_COLUMNS) &&\n !isGlobal(a) &&\n (a.appliesTo?.(actionCtx) ?? true),\n );\n\n // Prefer menu-native rendering (`renderMenuItem`) — sort/filter render as\n // items with submenus, so the whole dropdown is one Blueprint `Menu`. A\n // control that only has `render` (a live toolbar control) is embedded as-is;\n // a plain `run` action becomes a clickable item.\n const items = controls\n .map((a, i) => {\n if (a.renderMenuItem != null) return a.renderMenuItem(actionCtx);\n if (a.render != null)\n return h(\"li.column-header-control\", { key: a.id ?? i }, a.render(actionCtx));\n return h(MenuItem, {\n key: a.id ?? i,\n icon: a.icon,\n intent: a.intent,\n text: a.name,\n onClick: () => a.run?.(actionCtx),\n });\n })\n .filter(Boolean);\n\n if (items.length === 0) {\n return h(Menu, [h(MenuItem, { text: \"No options\", disabled: true })]);\n }\n\n return h(Menu, { className: \"column-header-controls\" }, items);\n}\n"],"names":[],"mappings":";;;;;AAmCO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,aAAa,IAAI,aAAa;AACpC,QAAM,eACJ,IAAI,eAAe,QACnB,OAAO,IAAI,eAAe,YACzB,MAAM,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,SAAS;AACtD,QAAM,mBACJ,MAAM,QAAS,IAAY,OAAO,KAAM,IAAY,QAAQ,SAAS;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MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,cAAc,UAAU,KAAA,CAAM,CAAC,CAAC;AAAA,EACtE;AAEA,SAAO,EAAE,MAAM,EAAE,WAAW,yBAAA,GAA4B,KAAK;AAC/D;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../src/types.ts"],"sourcesContent":["import type {\n FocusedCellCoordinates,\n Region,\n RegionCardinality,\n Table2,\n} from \"@blueprintjs/table\";\nimport { ColumnSpec, ColumnSpecOptions } from \"./utils\";\nimport { OverlayToaster } from \"@blueprintjs/core\";\nimport type { CellEdit } from \"./actions\";\n\n/** A single column sort entry for client-side sorting.\n * Defined here (rather than in actions/types) to avoid circular imports. */\nexport interface ColumnSort {\n key: string;\n ascending: boolean;\n}\n\n/** Direction of keyboard navigation between cells. */\nexport type NavDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/**\n * A structured, revertible description of a user edit. Emitted via the\n * `onEdit` hook so a consumer can capture edits as operations (and, with the\n * controlled-overlay API, own the edited state) instead of diffing\n * `updatedData`. This is the write half of the data-sheet's read/write\n * contract — the mirror of how data flows in.\n */\nexport type EditEvent<T = any> =\n | { type: \"setCells\"; cells: CellEdit[] }\n | { type: \"deleteRows\"; rowIndices: number[] }\n | { type: \"restoreRows\"; rowIndices: number[] }\n | { type: \"addRow\"; rowIndex: number; value: Partial<T> }\n | { type: \"resetChanges\" };\n\nexport interface DataSheetCoreProps<T> {\n data: T[];\n columnSpec?: ColumnSpec[];\n editable?: boolean;\n enableColumnReordering?: boolean;\n defaultColumnWidth?: number;\n}\n\nexport enum TableElementStatus {\n DELETED = \"deleted\",\n ADDED = \"added\",\n}\n\n/** A row's status value. The built-in `TableElementStatus` members\n * (`\"deleted\"` / `\"added\"`) plus any consumer-defined status string (e.g.\n * `\"omitted\"`). The `(string & {})` keeps autocomplete for the enum members\n * while still accepting arbitrary strings. */\nexport type RowStatusValue = TableElementStatus | (string & {});\n\n/** Presentation for a row status: applied to the row's cells and its header\n * cell. Keyed by status value in `rowStatusStyles`. The library ships a\n * default for `\"deleted\"` (dimmed + struck through, danger intent); consumers\n * merge in styles for their own statuses (and may override the defaults). */\nexport interface RowStatusStyle {\n /** Style merged onto each cell in a row with this status. */\n cellStyle?: import(\"react\").CSSProperties;\n /** Style applied to the row's header cell. */\n headerStyle?: import(\"react\").CSSProperties;\n /** Blueprint intent applied to the row's cells (precedence: validation >\n * this > edited-green). */\n intent?: import(\"@blueprintjs/core\").Intent;\n}\n\nexport type RowStatusStyles = Record<string, RowStatusStyle>;\n\n/** Built-in row-status presentation. Consumers' `rowStatusStyles` are merged\n * over this, so `\"deleted\"` keeps its look unless explicitly overridden. */\nexport const DEFAULT_ROW_STATUS_STYLES: RowStatusStyles = {\n [TableElementStatus.DELETED]: {\n cellStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n headerStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n intent: \"danger\",\n },\n};\n\n/** Context passed to a custom `rowHeaderRenderer`, so it can label and style\n * the row header from the row's data and status (group-key labels, an\n * omit indicator, etc.). Return a node to use as the header's name, or a\n * nullish value to fall back to the default (1-based row number). */\nexport interface RowHeaderRenderContext<T = any> {\n /** Data-row index (stable under sort/filter). */\n rowIndex: number;\n /** Visible (display) row index. */\n visibleIndex: number;\n /** The row's data (base, overlaid with edits if present). */\n row: T | undefined;\n /** The row's status, if any. */\n status: RowStatusValue | undefined;\n /** Convenience: `status === TableElementStatus.DELETED`. */\n isDeleted: boolean;\n /** The default label (`\"${rowIndex + 1}\"`). */\n defaultLabel: string;\n}\n\n/** Property key holding a stable synthetic id on rows added in-table. Added\n * rows aren't in the data provider, so they need their own identity to survive\n * a provider re-fetch; it's carried on the row and preserved through edits. */\nexport const DS_ROW_ID = \"__dsRowId\";\n\n/** Proxy stored during a copy operation, enabling backend-mediated paste\n * for lazy-loaded tables where not all data is available locally. */\nexport interface ClipboardProxy {\n cardinality: RegionCardinality;\n /** Source row indices (for row/cell copies) */\n rowIndices?: number[];\n /** Source column keys (for column/cell copies) */\n columnKeys?: string[];\n /** The plain text written to the clipboard, used to verify the proxy\n * is still valid on paste (i.e., clipboard hasn't been overwritten). */\n text: string;\n}\n\nexport interface DataSheetState<T> {\n selection: Region[];\n columnSpec: ColumnSpec[];\n fillValueBaseCell: FocusedCellCoordinates | null;\n focusedCell: FocusedCellCoordinates | null;\n topLeftCell: FocusedCellCoordinates | null;\n /**\n * Set of row indices that have been added to the table,\n * but not yet committed to the underlying data array.\n *\n * This is used to track which rows should be reverted when\n * a \"reset\" action is performed.\n */\n rowStatus: RowStatusValue[];\n /** Presentation per row-status value (merged: defaults + the\n * `rowStatusStyles` prop). Read by the cell renderer and row-header renderer\n * to style rows by status. */\n rowStatusStyles: RowStatusStyles;\n // Sparse data structure for updated data\n updatedData: T[];\n initialized: boolean;\n columnWidthsIndex: Map<string, number>;\n /** Active column/table filters. Keys are filter IDs, values carry the\n * filter definition and its current configuration state. */\n activeFilters: Map<string, { filter: any; state: any }>;\n /** Clipboard proxy from the last copy operation */\n clipboardProxy: ClipboardProxy | null;\n /** Visible row indices when filters are active. `null` means show all rows. */\n filteredRowIndices: number[] | null;\n /** Active column sort entries for client-side sorting. */\n columnSorts: ColumnSort[];\n /** Whether selecting a cell automatically activates its surface (opens an\n * editor/detail panel and, for editors, focuses it). `\"manual\"` opens only\n * on click. */\n cellInteraction: \"auto\" | \"manual\";\n /** Runtime override of `cellInteraction`: while `false`, auto-activation is\n * suppressed (set by pressing Escape, re-armed by clicking a cell) so the\n * keyboard prioritizes navigation. */\n autoActivateArmed: boolean;\n /** Direction of the last keyboard navigation, used to place an editor's\n * cursor on the side the user is travelling toward. `null` after a click. */\n lastNavDirection: NavDirection | null;\n /** The table's focusable holder element; editors return focus here when the\n * cursor leaves them so arrow-key navigation resumes. */\n tableElement: HTMLElement | null;\n /** Whether the focused cell's surface (editor or detail panel) is open.\n * Owned by the store — not per-popover — so navigation, clicks, and the\n * Escape handler all agree on it. */\n cellSurfaceOpen: boolean;\n /** Optional observer called for every user edit as a structured\n * `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a\n * consumer capture edits as revertible operations. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Row identity for the edit overlay — stable across a provider re-sort,\n * unlike an array index. Defaults to `(row) => row?.id`; a data provider\n * supplies its own (e.g. a PostgREST identity key). Used to re-attach edits\n * when the loader replaces `data` with a re-ordered window. */\n identity: (row: any) => string | number | null | undefined;\n /** Edits/statuses held by identity for rows not currently loaded (server\n * sources), re-attached when their row next arrives. */\n pendingOverlayById: Map<\n string | number,\n { edit?: any; status?: TableElementStatus }\n >;\n /** True when the consumer controls the `updatedData`/`rowStatus` overlay; the\n * loader-boundary identity remap is skipped (the consumer owns it). */\n controlledOverlay: boolean;\n /** Whether row deletion is available. Set from the data provider: an explicit\n * `provider` without `deleteRows` disables deletion entirely (the delete\n * affordance greys out and the delete key is a no-op). Defaults to `true`. */\n canDeleteRows: boolean;\n}\n\ntype DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;\nexport type StateUpdater<T> = T[] | ((state: T[]) => T[]);\n\nexport interface DataSheetStoreMain<T> extends DataSheetVals<T> {\n setSelection(selection: Region[]): void;\n onDragValue(event: MouseEvent): void;\n setUpdatedData(data: StateUpdater<T>): void;\n onCellEdited(rowIndex: number, columnName: string, value: any): void;\n onSelectionEdited(value: any): void;\n onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;\n onColumnWidthChanged(columnIndex: number, newWidth: number): void;\n moveFocusedCell(direction: NavDirection): void;\n /** Suppress auto-activation until the next click (Escape enters nav mode). */\n suppressAutoActivate(): void;\n /** Re-arm auto-activation (a click re-enables auto-focus). */\n armAutoActivate(): void;\n /** Open the focused cell's surface (editor or detail panel). */\n openCellSurface(): void;\n /** Close the focused cell's surface. When `suppress` is true (the default,\n * as for Escape), auto mode also enters navigation mode (auto-activation is\n * suppressed until the next click). A click-dismiss passes `suppress: false`\n * so it just closes without changing the global mode. */\n closeCellSurface(opts?: { suppress?: boolean }): void;\n deleteSelectedRows(): void;\n clearSelection(): void;\n resetChanges(): void;\n addRow(): void;\n /** Activate or update a column/table filter.\n * Filter is any object satisfying `TableFilter` from the actions module. */\n setFilter(filterId: string, filter: any, filterState: any): void;\n /** Remove a filter by ID */\n removeFilter(filterId: string): void;\n /** Remove all active filters */\n clearFilters(): void;\n /** Set or clear a column sort. Pass `null` for ascending to clear. */\n setColumnSort(key: string, ascending: boolean | null): void;\n /** Remove all active column sorts */\n clearColumnSorts(): void;\n /** Store a clipboard proxy for potential backend-mediated paste */\n setClipboardProxy(proxy: ClipboardProxy | null): void;\n initialize(props: Partial<DataSheetStoreMain<T>>): void;\n onSelection(selection: Region[]): void;\n // Internal method used for infinite scrolling\n scrollToRow(rowIndex: number): void;\n tableRef: React.MutableRefObject<Table2>;\n columnWidthsIndex: Map<string, number>;\n defaultColumnWidth: number;\n}\n\nexport type DataSheetProviderProps<T> = DataSheetCoreProps<T> & {\n children: React.ReactNode;\n columnSpecOptions?: ColumnSpecOptions<T>;\n toaster?: OverlayToaster;\n};\n\nexport interface VisibleCells {\n rowIndexStart: number;\n rowIndexEnd: number;\n}\n\nexport type DataSheetStore<T> = DataSheetStoreMain<T>;\n"],"names":["TableElementStatus"],"mappings":";;AA0CO,IAAK,uCAAAA,wBAAL;AACLA,sBAAA,SAAA,IAAU;AACVA,sBAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AA6BL,MAAM,4BAA6C;AAAA,EACxD;AAAA,IAAC;AAAA;AAAA,KAA6B;AAAA,IAC5B,WAAW,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC3C,aAAa,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC7C,QAAQ;AAAA,EAAA;AAEZ;AAwBO,MAAM,YAAY;;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../src/types.ts"],"sourcesContent":["import type {\n FocusedCellCoordinates,\n Region,\n RegionCardinality,\n Table2,\n} from \"@blueprintjs/table\";\nimport { ColumnSpec, ColumnSpecOptions } from \"./utils\";\nimport { OverlayToaster } from \"@blueprintjs/core\";\nimport type { CellEdit } from \"./actions\";\n\n/** A single column sort entry for client-side sorting.\n * Defined here (rather than in actions/types) to avoid circular imports. */\nexport interface ColumnSort {\n key: string;\n ascending: boolean;\n}\n\n/** Direction of keyboard navigation between cells. */\nexport type NavDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/**\n * A structured, revertible description of a user edit. Emitted via the\n * `onEdit` hook so a consumer can capture edits as operations (and, with the\n * controlled-overlay API, own the edited state) instead of diffing\n * `updatedData`. This is the write half of the data-sheet's read/write\n * contract — the mirror of how data flows in.\n */\nexport type EditEvent<T = any> =\n | { type: \"setCells\"; cells: CellEdit[] }\n | { type: \"deleteRows\"; rowIndices: number[] }\n | { type: \"restoreRows\"; rowIndices: number[] }\n | { type: \"addRow\"; rowIndex: number; value: Partial<T> }\n | { type: \"resetChanges\" };\n\nexport interface DataSheetCoreProps<T> {\n data: T[];\n /** Column definitions. Either a static array, or a function derived from the\n * loaded rows — invoked once the first rows arrive (and re-invoked when the\n * function's identity changes), so a data-shaped spec needs no separate fetch\n * of sample data. Omit entirely to auto-generate a plain spec via\n * `columnSpecOptions`. */\n columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);\n editable?: boolean;\n enableColumnReordering?: boolean;\n defaultColumnWidth?: number;\n}\n\nexport enum TableElementStatus {\n DELETED = \"deleted\",\n ADDED = \"added\",\n}\n\n/** A row's status value. The built-in `TableElementStatus` members\n * (`\"deleted\"` / `\"added\"`) plus any consumer-defined status string (e.g.\n * `\"omitted\"`). The `(string & {})` keeps autocomplete for the enum members\n * while still accepting arbitrary strings. */\nexport type RowStatusValue = TableElementStatus | (string & {});\n\n/** Presentation for a row status: applied to the row's cells and its header\n * cell. Keyed by status value in `rowStatusStyles`. The library ships a\n * default for `\"deleted\"` (dimmed + struck through, danger intent); consumers\n * merge in styles for their own statuses (and may override the defaults). */\nexport interface RowStatusStyle {\n /** Style merged onto each cell in a row with this status. */\n cellStyle?: import(\"react\").CSSProperties;\n /** Style applied to the row's header cell. */\n headerStyle?: import(\"react\").CSSProperties;\n /** Blueprint intent applied to the row's cells (precedence: validation >\n * this > edited-green). */\n intent?: import(\"@blueprintjs/core\").Intent;\n}\n\nexport type RowStatusStyles = Record<string, RowStatusStyle>;\n\n/** Built-in row-status presentation. Consumers' `rowStatusStyles` are merged\n * over this, so `\"deleted\"` keeps its look unless explicitly overridden. */\nexport const DEFAULT_ROW_STATUS_STYLES: RowStatusStyles = {\n [TableElementStatus.DELETED]: {\n cellStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n headerStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n intent: \"danger\",\n },\n};\n\n/** Context passed to a custom `rowHeaderRenderer`, so it can label and style\n * the row header from the row's data and status (group-key labels, an\n * omit indicator, etc.). Return a node to use as the header's name, or a\n * nullish value to fall back to the default (1-based row number). */\nexport interface RowHeaderRenderContext<T = any> {\n /** Data-row index (stable under sort/filter). */\n rowIndex: number;\n /** Visible (display) row index. */\n visibleIndex: number;\n /** The row's data (base, overlaid with edits if present). */\n row: T | undefined;\n /** The row's status, if any. */\n status: RowStatusValue | undefined;\n /** Convenience: `status === TableElementStatus.DELETED`. */\n isDeleted: boolean;\n /** The default label (`\"${rowIndex + 1}\"`). */\n defaultLabel: string;\n}\n\n/** Property key holding a stable synthetic id on rows added in-table. Added\n * rows aren't in the data provider, so they need their own identity to survive\n * a provider re-fetch; it's carried on the row and preserved through edits. */\nexport const DS_ROW_ID = \"__dsRowId\";\n\n/** Proxy stored during a copy operation, enabling backend-mediated paste\n * for lazy-loaded tables where not all data is available locally. */\nexport interface ClipboardProxy {\n cardinality: RegionCardinality;\n /** Source row indices (for row/cell copies) */\n rowIndices?: number[];\n /** Source column keys (for column/cell copies) */\n columnKeys?: string[];\n /** The plain text written to the clipboard, used to verify the proxy\n * is still valid on paste (i.e., clipboard hasn't been overwritten). */\n text: string;\n}\n\nexport interface DataSheetState<T> {\n selection: Region[];\n columnSpec: ColumnSpec[];\n /** When `true`, the loader's first-chunk auto-generation of `columnSpec` is\n * suppressed — a function `columnSpec` derives it from the loaded rows\n * instead (in `_DataSheet`). Set at init from the prop's shape. */\n deferColumnSpec: boolean;\n fillValueBaseCell: FocusedCellCoordinates | null;\n focusedCell: FocusedCellCoordinates | null;\n topLeftCell: FocusedCellCoordinates | null;\n /**\n * Set of row indices that have been added to the table,\n * but not yet committed to the underlying data array.\n *\n * This is used to track which rows should be reverted when\n * a \"reset\" action is performed.\n */\n rowStatus: RowStatusValue[];\n /** Presentation per row-status value (merged: defaults + the\n * `rowStatusStyles` prop). Read by the cell renderer and row-header renderer\n * to style rows by status. */\n rowStatusStyles: RowStatusStyles;\n // Sparse data structure for updated data\n updatedData: T[];\n initialized: boolean;\n columnWidthsIndex: Map<string, number>;\n /** Active column/table filters. Keys are filter IDs, values carry the\n * filter definition and its current configuration state. */\n activeFilters: Map<string, { filter: any; state: any }>;\n /** Clipboard proxy from the last copy operation */\n clipboardProxy: ClipboardProxy | null;\n /** Visible row indices when filters are active. `null` means show all rows. */\n filteredRowIndices: number[] | null;\n /** Active column sort entries for client-side sorting. */\n columnSorts: ColumnSort[];\n /** Whether selecting a cell automatically activates its surface (opens an\n * editor/detail panel and, for editors, focuses it). `\"manual\"` opens only\n * on click. */\n cellInteraction: \"auto\" | \"manual\";\n /** Runtime override of `cellInteraction`: while `false`, auto-activation is\n * suppressed (set by pressing Escape, re-armed by clicking a cell) so the\n * keyboard prioritizes navigation. */\n autoActivateArmed: boolean;\n /** Direction of the last keyboard navigation, used to place an editor's\n * cursor on the side the user is travelling toward. `null` after a click. */\n lastNavDirection: NavDirection | null;\n /** The table's focusable holder element; editors return focus here when the\n * cursor leaves them so arrow-key navigation resumes. */\n tableElement: HTMLElement | null;\n /** Whether the focused cell's surface (editor or detail panel) is open.\n * Owned by the store — not per-popover — so navigation, clicks, and the\n * Escape handler all agree on it. */\n cellSurfaceOpen: boolean;\n /** Optional observer called for every user edit as a structured\n * `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a\n * consumer capture edits as revertible operations. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Row identity for the edit overlay — stable across a provider re-sort,\n * unlike an array index. Defaults to `(row) => row?.id`; a data provider\n * supplies its own (e.g. a PostgREST identity key). Used to re-attach edits\n * when the loader replaces `data` with a re-ordered window. */\n identity: (row: any) => string | number | null | undefined;\n /** Edits/statuses held by identity for rows not currently loaded (server\n * sources), re-attached when their row next arrives. */\n pendingOverlayById: Map<\n string | number,\n { edit?: any; status?: TableElementStatus }\n >;\n /** True when the consumer controls the `updatedData`/`rowStatus` overlay; the\n * loader-boundary identity remap is skipped (the consumer owns it). */\n controlledOverlay: boolean;\n /** Whether row deletion is available. Set from the data provider: an explicit\n * `provider` without `deleteRows` disables deletion entirely (the delete\n * affordance greys out and the delete key is a no-op). Defaults to `true`. */\n canDeleteRows: boolean;\n}\n\ntype DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;\nexport type StateUpdater<T> = T[] | ((state: T[]) => T[]);\n\nexport interface DataSheetStoreMain<T> extends DataSheetVals<T> {\n setSelection(selection: Region[]): void;\n onDragValue(event: MouseEvent): void;\n setUpdatedData(data: StateUpdater<T>): void;\n onCellEdited(rowIndex: number, columnName: string, value: any): void;\n onSelectionEdited(value: any): void;\n onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;\n onColumnWidthChanged(columnIndex: number, newWidth: number): void;\n moveFocusedCell(direction: NavDirection): void;\n /** Suppress auto-activation until the next click (Escape enters nav mode). */\n suppressAutoActivate(): void;\n /** Re-arm auto-activation (a click re-enables auto-focus). */\n armAutoActivate(): void;\n /** Open the focused cell's surface (editor or detail panel). */\n openCellSurface(): void;\n /** Close the focused cell's surface. When `suppress` is true (the default,\n * as for Escape), auto mode also enters navigation mode (auto-activation is\n * suppressed until the next click). A click-dismiss passes `suppress: false`\n * so it just closes without changing the global mode. */\n closeCellSurface(opts?: { suppress?: boolean }): void;\n deleteSelectedRows(): void;\n clearSelection(): void;\n resetChanges(): void;\n addRow(): void;\n /** Activate or update a column/table filter.\n * Filter is any object satisfying `TableFilter` from the actions module. */\n setFilter(filterId: string, filter: any, filterState: any): void;\n /** Remove a filter by ID */\n removeFilter(filterId: string): void;\n /** Remove all active filters */\n clearFilters(): void;\n /** Set or clear a column sort. Pass `null` for ascending to clear. */\n setColumnSort(key: string, ascending: boolean | null): void;\n /** Remove all active column sorts */\n clearColumnSorts(): void;\n /** Store a clipboard proxy for potential backend-mediated paste */\n setClipboardProxy(proxy: ClipboardProxy | null): void;\n initialize(props: Partial<DataSheetStoreMain<T>>): void;\n onSelection(selection: Region[]): void;\n // Internal method used for infinite scrolling\n scrollToRow(rowIndex: number): void;\n tableRef: React.MutableRefObject<Table2>;\n columnWidthsIndex: Map<string, number>;\n defaultColumnWidth: number;\n}\n\nexport type DataSheetProviderProps<T> = DataSheetCoreProps<T> & {\n children: React.ReactNode;\n columnSpecOptions?: ColumnSpecOptions<T>;\n toaster?: OverlayToaster;\n};\n\nexport interface VisibleCells {\n rowIndexStart: number;\n rowIndexEnd: number;\n}\n\nexport type DataSheetStore<T> = DataSheetStoreMain<T>;\n"],"names":["TableElementStatus"],"mappings":";;AA+CO,IAAK,uCAAAA,wBAAL;AACLA,sBAAA,SAAA,IAAU;AACVA,sBAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AA6BL,MAAM,4BAA6C;AAAA,EACxD;AAAA,IAAC;AAAA;AAAA,KAA6B;AAAA,IAC5B,WAAW,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC3C,aAAa,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC7C,QAAQ;AAAA,EAAA;AAEZ;AAwBO,MAAM,YAAY;;;;"}
package/dist/types.d.ts CHANGED
@@ -35,7 +35,12 @@ export type EditEvent<T = any> = {
35
35
  };
36
36
  export interface DataSheetCoreProps<T> {
37
37
  data: T[];
38
- columnSpec?: ColumnSpec[];
38
+ /** Column definitions. Either a static array, or a function derived from the
39
+ * loaded rows — invoked once the first rows arrive (and re-invoked when the
40
+ * function's identity changes), so a data-shaped spec needs no separate fetch
41
+ * of sample data. Omit entirely to auto-generate a plain spec via
42
+ * `columnSpecOptions`. */
43
+ columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);
39
44
  editable?: boolean;
40
45
  enableColumnReordering?: boolean;
41
46
  defaultColumnWidth?: number;
@@ -103,6 +108,10 @@ export interface ClipboardProxy {
103
108
  export interface DataSheetState<T> {
104
109
  selection: Region[];
105
110
  columnSpec: ColumnSpec[];
111
+ /** When `true`, the loader's first-chunk auto-generation of `columnSpec` is
112
+ * suppressed — a function `columnSpec` derives it from the loaded rows
113
+ * instead (in `_DataSheet`). Set at init from the prop's shape. */
114
+ deferColumnSpec: boolean;
106
115
  fillValueBaseCell: FocusedCellCoordinates | null;
107
116
  focusedCell: FocusedCellCoordinates | null;
108
117
  topLeftCell: FocusedCellCoordinates | null;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n FocusedCellCoordinates,\n Region,\n RegionCardinality,\n Table2,\n} from \"@blueprintjs/table\";\nimport { ColumnSpec, ColumnSpecOptions } from \"./utils\";\nimport { OverlayToaster } from \"@blueprintjs/core\";\nimport type { CellEdit } from \"./actions\";\n\n/** A single column sort entry for client-side sorting.\n * Defined here (rather than in actions/types) to avoid circular imports. */\nexport interface ColumnSort {\n key: string;\n ascending: boolean;\n}\n\n/** Direction of keyboard navigation between cells. */\nexport type NavDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/**\n * A structured, revertible description of a user edit. Emitted via the\n * `onEdit` hook so a consumer can capture edits as operations (and, with the\n * controlled-overlay API, own the edited state) instead of diffing\n * `updatedData`. This is the write half of the data-sheet's read/write\n * contract — the mirror of how data flows in.\n */\nexport type EditEvent<T = any> =\n | { type: \"setCells\"; cells: CellEdit[] }\n | { type: \"deleteRows\"; rowIndices: number[] }\n | { type: \"restoreRows\"; rowIndices: number[] }\n | { type: \"addRow\"; rowIndex: number; value: Partial<T> }\n | { type: \"resetChanges\" };\n\nexport interface DataSheetCoreProps<T> {\n data: T[];\n columnSpec?: ColumnSpec[];\n editable?: boolean;\n enableColumnReordering?: boolean;\n defaultColumnWidth?: number;\n}\n\nexport enum TableElementStatus {\n DELETED = \"deleted\",\n ADDED = \"added\",\n}\n\n/** A row's status value. The built-in `TableElementStatus` members\n * (`\"deleted\"` / `\"added\"`) plus any consumer-defined status string (e.g.\n * `\"omitted\"`). The `(string & {})` keeps autocomplete for the enum members\n * while still accepting arbitrary strings. */\nexport type RowStatusValue = TableElementStatus | (string & {});\n\n/** Presentation for a row status: applied to the row's cells and its header\n * cell. Keyed by status value in `rowStatusStyles`. The library ships a\n * default for `\"deleted\"` (dimmed + struck through, danger intent); consumers\n * merge in styles for their own statuses (and may override the defaults). */\nexport interface RowStatusStyle {\n /** Style merged onto each cell in a row with this status. */\n cellStyle?: import(\"react\").CSSProperties;\n /** Style applied to the row's header cell. */\n headerStyle?: import(\"react\").CSSProperties;\n /** Blueprint intent applied to the row's cells (precedence: validation >\n * this > edited-green). */\n intent?: import(\"@blueprintjs/core\").Intent;\n}\n\nexport type RowStatusStyles = Record<string, RowStatusStyle>;\n\n/** Built-in row-status presentation. Consumers' `rowStatusStyles` are merged\n * over this, so `\"deleted\"` keeps its look unless explicitly overridden. */\nexport const DEFAULT_ROW_STATUS_STYLES: RowStatusStyles = {\n [TableElementStatus.DELETED]: {\n cellStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n headerStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n intent: \"danger\",\n },\n};\n\n/** Context passed to a custom `rowHeaderRenderer`, so it can label and style\n * the row header from the row's data and status (group-key labels, an\n * omit indicator, etc.). Return a node to use as the header's name, or a\n * nullish value to fall back to the default (1-based row number). */\nexport interface RowHeaderRenderContext<T = any> {\n /** Data-row index (stable under sort/filter). */\n rowIndex: number;\n /** Visible (display) row index. */\n visibleIndex: number;\n /** The row's data (base, overlaid with edits if present). */\n row: T | undefined;\n /** The row's status, if any. */\n status: RowStatusValue | undefined;\n /** Convenience: `status === TableElementStatus.DELETED`. */\n isDeleted: boolean;\n /** The default label (`\"${rowIndex + 1}\"`). */\n defaultLabel: string;\n}\n\n/** Property key holding a stable synthetic id on rows added in-table. Added\n * rows aren't in the data provider, so they need their own identity to survive\n * a provider re-fetch; it's carried on the row and preserved through edits. */\nexport const DS_ROW_ID = \"__dsRowId\";\n\n/** Proxy stored during a copy operation, enabling backend-mediated paste\n * for lazy-loaded tables where not all data is available locally. */\nexport interface ClipboardProxy {\n cardinality: RegionCardinality;\n /** Source row indices (for row/cell copies) */\n rowIndices?: number[];\n /** Source column keys (for column/cell copies) */\n columnKeys?: string[];\n /** The plain text written to the clipboard, used to verify the proxy\n * is still valid on paste (i.e., clipboard hasn't been overwritten). */\n text: string;\n}\n\nexport interface DataSheetState<T> {\n selection: Region[];\n columnSpec: ColumnSpec[];\n fillValueBaseCell: FocusedCellCoordinates | null;\n focusedCell: FocusedCellCoordinates | null;\n topLeftCell: FocusedCellCoordinates | null;\n /**\n * Set of row indices that have been added to the table,\n * but not yet committed to the underlying data array.\n *\n * This is used to track which rows should be reverted when\n * a \"reset\" action is performed.\n */\n rowStatus: RowStatusValue[];\n /** Presentation per row-status value (merged: defaults + the\n * `rowStatusStyles` prop). Read by the cell renderer and row-header renderer\n * to style rows by status. */\n rowStatusStyles: RowStatusStyles;\n // Sparse data structure for updated data\n updatedData: T[];\n initialized: boolean;\n columnWidthsIndex: Map<string, number>;\n /** Active column/table filters. Keys are filter IDs, values carry the\n * filter definition and its current configuration state. */\n activeFilters: Map<string, { filter: any; state: any }>;\n /** Clipboard proxy from the last copy operation */\n clipboardProxy: ClipboardProxy | null;\n /** Visible row indices when filters are active. `null` means show all rows. */\n filteredRowIndices: number[] | null;\n /** Active column sort entries for client-side sorting. */\n columnSorts: ColumnSort[];\n /** Whether selecting a cell automatically activates its surface (opens an\n * editor/detail panel and, for editors, focuses it). `\"manual\"` opens only\n * on click. */\n cellInteraction: \"auto\" | \"manual\";\n /** Runtime override of `cellInteraction`: while `false`, auto-activation is\n * suppressed (set by pressing Escape, re-armed by clicking a cell) so the\n * keyboard prioritizes navigation. */\n autoActivateArmed: boolean;\n /** Direction of the last keyboard navigation, used to place an editor's\n * cursor on the side the user is travelling toward. `null` after a click. */\n lastNavDirection: NavDirection | null;\n /** The table's focusable holder element; editors return focus here when the\n * cursor leaves them so arrow-key navigation resumes. */\n tableElement: HTMLElement | null;\n /** Whether the focused cell's surface (editor or detail panel) is open.\n * Owned by the store — not per-popover — so navigation, clicks, and the\n * Escape handler all agree on it. */\n cellSurfaceOpen: boolean;\n /** Optional observer called for every user edit as a structured\n * `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a\n * consumer capture edits as revertible operations. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Row identity for the edit overlay — stable across a provider re-sort,\n * unlike an array index. Defaults to `(row) => row?.id`; a data provider\n * supplies its own (e.g. a PostgREST identity key). Used to re-attach edits\n * when the loader replaces `data` with a re-ordered window. */\n identity: (row: any) => string | number | null | undefined;\n /** Edits/statuses held by identity for rows not currently loaded (server\n * sources), re-attached when their row next arrives. */\n pendingOverlayById: Map<\n string | number,\n { edit?: any; status?: TableElementStatus }\n >;\n /** True when the consumer controls the `updatedData`/`rowStatus` overlay; the\n * loader-boundary identity remap is skipped (the consumer owns it). */\n controlledOverlay: boolean;\n /** Whether row deletion is available. Set from the data provider: an explicit\n * `provider` without `deleteRows` disables deletion entirely (the delete\n * affordance greys out and the delete key is a no-op). Defaults to `true`. */\n canDeleteRows: boolean;\n}\n\ntype DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;\nexport type StateUpdater<T> = T[] | ((state: T[]) => T[]);\n\nexport interface DataSheetStoreMain<T> extends DataSheetVals<T> {\n setSelection(selection: Region[]): void;\n onDragValue(event: MouseEvent): void;\n setUpdatedData(data: StateUpdater<T>): void;\n onCellEdited(rowIndex: number, columnName: string, value: any): void;\n onSelectionEdited(value: any): void;\n onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;\n onColumnWidthChanged(columnIndex: number, newWidth: number): void;\n moveFocusedCell(direction: NavDirection): void;\n /** Suppress auto-activation until the next click (Escape enters nav mode). */\n suppressAutoActivate(): void;\n /** Re-arm auto-activation (a click re-enables auto-focus). */\n armAutoActivate(): void;\n /** Open the focused cell's surface (editor or detail panel). */\n openCellSurface(): void;\n /** Close the focused cell's surface. When `suppress` is true (the default,\n * as for Escape), auto mode also enters navigation mode (auto-activation is\n * suppressed until the next click). A click-dismiss passes `suppress: false`\n * so it just closes without changing the global mode. */\n closeCellSurface(opts?: { suppress?: boolean }): void;\n deleteSelectedRows(): void;\n clearSelection(): void;\n resetChanges(): void;\n addRow(): void;\n /** Activate or update a column/table filter.\n * Filter is any object satisfying `TableFilter` from the actions module. */\n setFilter(filterId: string, filter: any, filterState: any): void;\n /** Remove a filter by ID */\n removeFilter(filterId: string): void;\n /** Remove all active filters */\n clearFilters(): void;\n /** Set or clear a column sort. Pass `null` for ascending to clear. */\n setColumnSort(key: string, ascending: boolean | null): void;\n /** Remove all active column sorts */\n clearColumnSorts(): void;\n /** Store a clipboard proxy for potential backend-mediated paste */\n setClipboardProxy(proxy: ClipboardProxy | null): void;\n initialize(props: Partial<DataSheetStoreMain<T>>): void;\n onSelection(selection: Region[]): void;\n // Internal method used for infinite scrolling\n scrollToRow(rowIndex: number): void;\n tableRef: React.MutableRefObject<Table2>;\n columnWidthsIndex: Map<string, number>;\n defaultColumnWidth: number;\n}\n\nexport type DataSheetProviderProps<T> = DataSheetCoreProps<T> & {\n children: React.ReactNode;\n columnSpecOptions?: ColumnSpecOptions<T>;\n toaster?: OverlayToaster;\n};\n\nexport interface VisibleCells {\n rowIndexStart: number;\n rowIndexEnd: number;\n}\n\nexport type DataSheetStore<T> = DataSheetStoreMain<T>;\n"],"names":["TableElementStatus"],"mappings":"AA0CO,IAAK,uCAAAA,wBAAL;AACLA,sBAAA,SAAA,IAAU;AACVA,sBAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AA6BL,MAAM,4BAA6C;AAAA,EACxD;AAAA,IAAC;AAAA;AAAA,KAA6B;AAAA,IAC5B,WAAW,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC3C,aAAa,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC7C,QAAQ;AAAA,EAAA;AAEZ;AAwBO,MAAM,YAAY;"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n FocusedCellCoordinates,\n Region,\n RegionCardinality,\n Table2,\n} from \"@blueprintjs/table\";\nimport { ColumnSpec, ColumnSpecOptions } from \"./utils\";\nimport { OverlayToaster } from \"@blueprintjs/core\";\nimport type { CellEdit } from \"./actions\";\n\n/** A single column sort entry for client-side sorting.\n * Defined here (rather than in actions/types) to avoid circular imports. */\nexport interface ColumnSort {\n key: string;\n ascending: boolean;\n}\n\n/** Direction of keyboard navigation between cells. */\nexport type NavDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/**\n * A structured, revertible description of a user edit. Emitted via the\n * `onEdit` hook so a consumer can capture edits as operations (and, with the\n * controlled-overlay API, own the edited state) instead of diffing\n * `updatedData`. This is the write half of the data-sheet's read/write\n * contract — the mirror of how data flows in.\n */\nexport type EditEvent<T = any> =\n | { type: \"setCells\"; cells: CellEdit[] }\n | { type: \"deleteRows\"; rowIndices: number[] }\n | { type: \"restoreRows\"; rowIndices: number[] }\n | { type: \"addRow\"; rowIndex: number; value: Partial<T> }\n | { type: \"resetChanges\" };\n\nexport interface DataSheetCoreProps<T> {\n data: T[];\n /** Column definitions. Either a static array, or a function derived from the\n * loaded rows — invoked once the first rows arrive (and re-invoked when the\n * function's identity changes), so a data-shaped spec needs no separate fetch\n * of sample data. Omit entirely to auto-generate a plain spec via\n * `columnSpecOptions`. */\n columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);\n editable?: boolean;\n enableColumnReordering?: boolean;\n defaultColumnWidth?: number;\n}\n\nexport enum TableElementStatus {\n DELETED = \"deleted\",\n ADDED = \"added\",\n}\n\n/** A row's status value. The built-in `TableElementStatus` members\n * (`\"deleted\"` / `\"added\"`) plus any consumer-defined status string (e.g.\n * `\"omitted\"`). The `(string & {})` keeps autocomplete for the enum members\n * while still accepting arbitrary strings. */\nexport type RowStatusValue = TableElementStatus | (string & {});\n\n/** Presentation for a row status: applied to the row's cells and its header\n * cell. Keyed by status value in `rowStatusStyles`. The library ships a\n * default for `\"deleted\"` (dimmed + struck through, danger intent); consumers\n * merge in styles for their own statuses (and may override the defaults). */\nexport interface RowStatusStyle {\n /** Style merged onto each cell in a row with this status. */\n cellStyle?: import(\"react\").CSSProperties;\n /** Style applied to the row's header cell. */\n headerStyle?: import(\"react\").CSSProperties;\n /** Blueprint intent applied to the row's cells (precedence: validation >\n * this > edited-green). */\n intent?: import(\"@blueprintjs/core\").Intent;\n}\n\nexport type RowStatusStyles = Record<string, RowStatusStyle>;\n\n/** Built-in row-status presentation. Consumers' `rowStatusStyles` are merged\n * over this, so `\"deleted\"` keeps its look unless explicitly overridden. */\nexport const DEFAULT_ROW_STATUS_STYLES: RowStatusStyles = {\n [TableElementStatus.DELETED]: {\n cellStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n headerStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n intent: \"danger\",\n },\n};\n\n/** Context passed to a custom `rowHeaderRenderer`, so it can label and style\n * the row header from the row's data and status (group-key labels, an\n * omit indicator, etc.). Return a node to use as the header's name, or a\n * nullish value to fall back to the default (1-based row number). */\nexport interface RowHeaderRenderContext<T = any> {\n /** Data-row index (stable under sort/filter). */\n rowIndex: number;\n /** Visible (display) row index. */\n visibleIndex: number;\n /** The row's data (base, overlaid with edits if present). */\n row: T | undefined;\n /** The row's status, if any. */\n status: RowStatusValue | undefined;\n /** Convenience: `status === TableElementStatus.DELETED`. */\n isDeleted: boolean;\n /** The default label (`\"${rowIndex + 1}\"`). */\n defaultLabel: string;\n}\n\n/** Property key holding a stable synthetic id on rows added in-table. Added\n * rows aren't in the data provider, so they need their own identity to survive\n * a provider re-fetch; it's carried on the row and preserved through edits. */\nexport const DS_ROW_ID = \"__dsRowId\";\n\n/** Proxy stored during a copy operation, enabling backend-mediated paste\n * for lazy-loaded tables where not all data is available locally. */\nexport interface ClipboardProxy {\n cardinality: RegionCardinality;\n /** Source row indices (for row/cell copies) */\n rowIndices?: number[];\n /** Source column keys (for column/cell copies) */\n columnKeys?: string[];\n /** The plain text written to the clipboard, used to verify the proxy\n * is still valid on paste (i.e., clipboard hasn't been overwritten). */\n text: string;\n}\n\nexport interface DataSheetState<T> {\n selection: Region[];\n columnSpec: ColumnSpec[];\n /** When `true`, the loader's first-chunk auto-generation of `columnSpec` is\n * suppressed — a function `columnSpec` derives it from the loaded rows\n * instead (in `_DataSheet`). Set at init from the prop's shape. */\n deferColumnSpec: boolean;\n fillValueBaseCell: FocusedCellCoordinates | null;\n focusedCell: FocusedCellCoordinates | null;\n topLeftCell: FocusedCellCoordinates | null;\n /**\n * Set of row indices that have been added to the table,\n * but not yet committed to the underlying data array.\n *\n * This is used to track which rows should be reverted when\n * a \"reset\" action is performed.\n */\n rowStatus: RowStatusValue[];\n /** Presentation per row-status value (merged: defaults + the\n * `rowStatusStyles` prop). Read by the cell renderer and row-header renderer\n * to style rows by status. */\n rowStatusStyles: RowStatusStyles;\n // Sparse data structure for updated data\n updatedData: T[];\n initialized: boolean;\n columnWidthsIndex: Map<string, number>;\n /** Active column/table filters. Keys are filter IDs, values carry the\n * filter definition and its current configuration state. */\n activeFilters: Map<string, { filter: any; state: any }>;\n /** Clipboard proxy from the last copy operation */\n clipboardProxy: ClipboardProxy | null;\n /** Visible row indices when filters are active. `null` means show all rows. */\n filteredRowIndices: number[] | null;\n /** Active column sort entries for client-side sorting. */\n columnSorts: ColumnSort[];\n /** Whether selecting a cell automatically activates its surface (opens an\n * editor/detail panel and, for editors, focuses it). `\"manual\"` opens only\n * on click. */\n cellInteraction: \"auto\" | \"manual\";\n /** Runtime override of `cellInteraction`: while `false`, auto-activation is\n * suppressed (set by pressing Escape, re-armed by clicking a cell) so the\n * keyboard prioritizes navigation. */\n autoActivateArmed: boolean;\n /** Direction of the last keyboard navigation, used to place an editor's\n * cursor on the side the user is travelling toward. `null` after a click. */\n lastNavDirection: NavDirection | null;\n /** The table's focusable holder element; editors return focus here when the\n * cursor leaves them so arrow-key navigation resumes. */\n tableElement: HTMLElement | null;\n /** Whether the focused cell's surface (editor or detail panel) is open.\n * Owned by the store — not per-popover — so navigation, clicks, and the\n * Escape handler all agree on it. */\n cellSurfaceOpen: boolean;\n /** Optional observer called for every user edit as a structured\n * `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a\n * consumer capture edits as revertible operations. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Row identity for the edit overlay — stable across a provider re-sort,\n * unlike an array index. Defaults to `(row) => row?.id`; a data provider\n * supplies its own (e.g. a PostgREST identity key). Used to re-attach edits\n * when the loader replaces `data` with a re-ordered window. */\n identity: (row: any) => string | number | null | undefined;\n /** Edits/statuses held by identity for rows not currently loaded (server\n * sources), re-attached when their row next arrives. */\n pendingOverlayById: Map<\n string | number,\n { edit?: any; status?: TableElementStatus }\n >;\n /** True when the consumer controls the `updatedData`/`rowStatus` overlay; the\n * loader-boundary identity remap is skipped (the consumer owns it). */\n controlledOverlay: boolean;\n /** Whether row deletion is available. Set from the data provider: an explicit\n * `provider` without `deleteRows` disables deletion entirely (the delete\n * affordance greys out and the delete key is a no-op). Defaults to `true`. */\n canDeleteRows: boolean;\n}\n\ntype DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;\nexport type StateUpdater<T> = T[] | ((state: T[]) => T[]);\n\nexport interface DataSheetStoreMain<T> extends DataSheetVals<T> {\n setSelection(selection: Region[]): void;\n onDragValue(event: MouseEvent): void;\n setUpdatedData(data: StateUpdater<T>): void;\n onCellEdited(rowIndex: number, columnName: string, value: any): void;\n onSelectionEdited(value: any): void;\n onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;\n onColumnWidthChanged(columnIndex: number, newWidth: number): void;\n moveFocusedCell(direction: NavDirection): void;\n /** Suppress auto-activation until the next click (Escape enters nav mode). */\n suppressAutoActivate(): void;\n /** Re-arm auto-activation (a click re-enables auto-focus). */\n armAutoActivate(): void;\n /** Open the focused cell's surface (editor or detail panel). */\n openCellSurface(): void;\n /** Close the focused cell's surface. When `suppress` is true (the default,\n * as for Escape), auto mode also enters navigation mode (auto-activation is\n * suppressed until the next click). A click-dismiss passes `suppress: false`\n * so it just closes without changing the global mode. */\n closeCellSurface(opts?: { suppress?: boolean }): void;\n deleteSelectedRows(): void;\n clearSelection(): void;\n resetChanges(): void;\n addRow(): void;\n /** Activate or update a column/table filter.\n * Filter is any object satisfying `TableFilter` from the actions module. */\n setFilter(filterId: string, filter: any, filterState: any): void;\n /** Remove a filter by ID */\n removeFilter(filterId: string): void;\n /** Remove all active filters */\n clearFilters(): void;\n /** Set or clear a column sort. Pass `null` for ascending to clear. */\n setColumnSort(key: string, ascending: boolean | null): void;\n /** Remove all active column sorts */\n clearColumnSorts(): void;\n /** Store a clipboard proxy for potential backend-mediated paste */\n setClipboardProxy(proxy: ClipboardProxy | null): void;\n initialize(props: Partial<DataSheetStoreMain<T>>): void;\n onSelection(selection: Region[]): void;\n // Internal method used for infinite scrolling\n scrollToRow(rowIndex: number): void;\n tableRef: React.MutableRefObject<Table2>;\n columnWidthsIndex: Map<string, number>;\n defaultColumnWidth: number;\n}\n\nexport type DataSheetProviderProps<T> = DataSheetCoreProps<T> & {\n children: React.ReactNode;\n columnSpecOptions?: ColumnSpecOptions<T>;\n toaster?: OverlayToaster;\n};\n\nexport interface VisibleCells {\n rowIndexStart: number;\n rowIndexEnd: number;\n}\n\nexport type DataSheetStore<T> = DataSheetStoreMain<T>;\n"],"names":["TableElementStatus"],"mappings":"AA+CO,IAAK,uCAAAA,wBAAL;AACLA,sBAAA,SAAA,IAAU;AACVA,sBAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AA6BL,MAAM,4BAA6C;AAAA,EACxD;AAAA,IAAC;AAAA;AAAA,KAA6B;AAAA,IAC5B,WAAW,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC3C,aAAa,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC7C,QAAQ;AAAA,EAAA;AAEZ;AAwBO,MAAM,YAAY;"}
@@ -1 +1 @@
1
- {"version":3,"file":"column-spec.cjs","sources":["../../src/utils/column-spec.ts"],"sourcesContent":["import React from \"react\";\n\nconst defaultRenderers = {\n string: (d) => d,\n number: (d) => d?.toFixed(2),\n boolean: (d) => (d ? \"T\" : \"F\"),\n object: (d) => JSON.stringify(d),\n integer: (d) => d?.toFixed(0),\n array: (d) => d?.join(\", \"),\n};\n\ninterface ColumnSpecGenerateOptions {\n calculateWidths?: boolean;\n defaultWidth?: number;\n getWidthForValue?: (value: any) => number;\n}\n\nconst defaultWidthForValue = (val) => String(val).length * 8;\n\n/** Inferred data type of a column, used to select appropriate\n * sort/filter operators. */\nexport type ColumnDataType =\n | \"text\"\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\";\n\n/** Severity of a cell validation result. `warning` is soft (flagged, doesn't\n * block saving); `error` is hard (blocks saving). */\nexport type ValidationSeverity = \"warning\" | \"error\";\n\n/** The result of validating a cell. `null` means valid. */\nexport interface CellValidation {\n severity: ValidationSeverity;\n message?: string;\n}\n\n/**\n * Context handed to per-cell renderers (`valueRenderer`, and — as the\n * `cellContext` prop — a custom `cellComponent`). It lets a renderer draw\n * based on the row/column position and the cell's edit status, and, combined\n * with the editing API, write edits back for a specific cell.\n *\n * `rowIndex` is the underlying **data-row index** (the value edit methods\n * expect), so it stays stable when a sort or filter reorders the view.\n */\nexport interface CellRenderContext<T = any> {\n /** The cell's current value (the edited value if present, else the base). */\n value: any;\n /** Underlying data-row index — stable under sort/filter. */\n rowIndex: number;\n /** Column index within the active column spec. */\n colIndex: number;\n /** The full column spec for this cell's column. */\n column: ColumnSpec;\n /** The full row object backing this cell (may be undefined while loading). */\n row: T | undefined;\n /** Whether this cell has an uncommitted edit. */\n isEdited: boolean;\n /** Whether this cell's row is marked for deletion. */\n isDeleted: boolean;\n /** The row's status value (`RowStatusValue`) — `\"deleted\"` / `\"added\"` or a\n * consumer-defined status (e.g. `\"omitted\"`), or `undefined` for a normal\n * row. Lets a renderer style by arbitrary status, not just deletion. */\n status: string | undefined;\n /** Validation result for this cell, or `null` when valid. Orthogonal to the\n * edit status — a cell can be both edited and invalid. */\n validation: CellValidation | null;\n}\n\n/**\n * The editor configuration for a cell. Mirrors the static `dataEditor` /\n * `inlineEditor` column fields so a per-cell resolver (`editorForCell`) can\n * override either one for an individual cell.\n */\nexport interface CellEditors {\n dataEditor?: any;\n inlineEditor?: boolean | React.ComponentType<any> | string | null;\n}\n\n/**\n * Context for a cell's detail surface (`cellDetail`). Extends the render\n * context with the edit affordances and controls a surface needs, so one\n * component can act as an editor (when `editable`) or a read-only viewer\n * (otherwise). This is the write side of the read/write contract, per-cell.\n */\nexport interface CellDetailContext<T = any> extends CellRenderContext<T> {\n /** Whether this cell is editable (column × table × not-deleted). */\n editable: boolean;\n /** Commit a new value for this cell. */\n onChange: (value: any) => void;\n /** Reset this cell (and selection) to its base value. */\n resetValue: () => void;\n /** Close the surface and return focus to the table. */\n close: () => void;\n}\n\n/** How a cell's detail surface is presented. Orthogonal to what it renders. */\nexport type DetailPresentation = \"popover\" | \"modal\" | \"inline\";\n\nexport interface ColumnSpec {\n name: string;\n key: string;\n /** When true, an empty value is an error (sugar over `validate`). */\n required?: boolean;\n /** Validate a cell's value. Return a `{ severity, message }` for a\n * warning/error, or `null` when valid. Runs after the `required` check.\n * `warning` flags the cell but allows saving; `error` blocks saving. */\n validate?: (\n value: any,\n row: any,\n ctx: { rowIndex: number },\n ) => CellValidation | null;\n /** @deprecated Prefer `validate`, which carries severity + a message.\n * A falsy result maps to an `error`. */\n isValid?: (d: any) => boolean;\n transformValue?: (d: any) => any;\n valueRenderer?: (\n d: any,\n ctx?: CellRenderContext,\n ) => string | React.ReactNode;\n headerRenderer?: (d: any) => string | React.ReactNode;\n dataEditor?: any;\n /**\n * Choose the editor for an individual cell from its render context,\n * overriding the static `dataEditor` / `inlineEditor` for that cell. Return\n * `undefined` (or omit a key) to fall back to the static configuration —\n * e.g. show a textarea only for cells whose value is long. A returned key is\n * respected even when its value is `false`/`null` (i.e. \"no editor here\").\n */\n editorForCell?: (ctx: CellRenderContext) => CellEditors | undefined;\n /**\n * Render a read-only detail panel for a cell. When set, selecting the cell\n * opens a popover with this content (following the table's `cellInteraction`\n * mode). The panel never takes keyboard focus, so arrow keys keep navigating\n * the table; Escape closes it. Mutually distinct from `dataEditor` — use this\n * for non-editable surfaces (previews, summaries, links).\n *\n * @deprecated Prefer `cellDetail`, which unifies editor and viewer.\n */\n detailRenderer?: (ctx: CellRenderContext) => React.ReactNode;\n /**\n * The unified cell surface (Workstream A): one renderer that acts as an\n * editor when `ctx.editable` and a read-only viewer otherwise, superseding\n * `dataEditor` / `detailRenderer` / `editorForCell`. Presentation is chosen\n * separately via `detailPresentation` (popover / modal / inline), so the\n * same component works in any container.\n */\n cellDetail?: (ctx: CellDetailContext) => React.ReactNode;\n /** How `cellDetail` is presented. Defaults to `\"popover\"`. */\n detailPresentation?: DetailPresentation;\n cellComponent?: any;\n category?: string;\n editable?: boolean;\n inlineEditor?: boolean | React.ComponentType<any> | string | null;\n style?: React.CSSProperties;\n width?: number;\n /** Column-specific table actions (TableAction[]). These appear in the\n * actions toolbar when this column is part of the current selection. */\n actions?: any[];\n /** Column-specific table filters (TableFilter[]). These appear in the\n * filter bar and apply to this column's values. */\n filters?: any[];\n /** Whether this column supports server-side sorting. */\n sortable?: boolean;\n /** Whether this column supports server-side filtering.\n * Set to `true` for default operators, or provide a config object\n * with a custom set of operators. */\n filterable?: boolean | { operators?: string[] };\n /** Inferred data type, used to select context-appropriate filter\n * operators when `filterable` is `true` without explicit operators. */\n dataType?: ColumnDataType;\n}\n\nexport interface ColumnSpecOptions<T> {\n overrides: Record<string, Partial<ColumnSpec> | string>;\n data?: T[]; // Data to use for type inference\n nRows?: number; // Number of rows to use for type inference\n omitColumns?: string[]; // Columns to omit. Takes precedence over includeColumns.\n includeColumns?: string[]; // Columns to include.\n}\n\nexport function generateDefaultColumnSpec<T>(\n data: Array<T>,\n options: ColumnSpecGenerateOptions = {},\n): ColumnSpec[] {\n /** Build a default column spec from a dataset based on the first n rows */\n if (data == null) return [];\n // Get the keys\n\n const {\n defaultWidth = 150,\n calculateWidths = true,\n getWidthForValue = defaultWidthForValue,\n } = options;\n\n const keys = new Set<string>();\n const types = new Map();\n\n const columnWidths = new Map<string, number>();\n\n for (const row of data) {\n if (row == null) continue;\n for (const key of Object.keys(row)) {\n const val = row[key];\n keys.add(key);\n\n if (val == null) continue;\n\n if (calculateWidths) {\n let width = getWidthForValue(val);\n if (width != null && width >= 0) {\n columnWidths.set(key, Math.max(width, columnWidths.get(key) ?? 0));\n }\n }\n\n let type: string = typeof val;\n // Special 'type' for integers\n if (Number.isInteger(val)) {\n type = \"integer\";\n }\n\n // Special 'type' for arrays of simple values\n if (\n Array.isArray(val) &&\n val.every((d) => typeof d === \"string\" || typeof d === \"number\")\n ) {\n type = \"array\";\n }\n\n // Check if it is strictly a string, if so, we can explicitly mark it as text\n if (type === \"string\") {\n type = \"text\";\n }\n\n if (types.has(key)) {\n if (types.get(key) !== type) {\n if (type === \"number\" && types.get(key) === \"integer\") {\n types.set(key, \"number\");\n }\n if (type === \"object\" && types.get(key) === \"array\") {\n types.set(key, \"object\");\n }\n\n types.set(key, \"string\");\n }\n } else {\n types.set(key, type);\n }\n }\n }\n\n // Build a column spec\n const spec = [];\n for (const key of keys) {\n let width = null;\n if (calculateWidths) {\n // If we are calculating widths, use the value lengths\n width = Math.min(\n Math.max(defaultWidth / 2, columnWidths.get(key) ?? defaultWidth),\n defaultWidth * 1.5,\n );\n }\n\n const dataType = (types.get(key) ?? \"string\") as ColumnDataType;\n\n // Auto-infer sortable/filterable based on data type.\n // Scalar types (string, number, integer, boolean) get sort/filter;\n // complex types (object, array) do not.\n const isScalar =\n dataType === \"text\" ||\n dataType === \"string\" ||\n dataType === \"number\" ||\n dataType === \"integer\" ||\n dataType === \"boolean\";\n\n spec.push({\n name: key,\n key,\n valueRenderer: defaultRenderers[types.get(key)],\n width,\n dataType,\n sortable: isScalar,\n filterable: isScalar,\n });\n }\n return spec;\n}\n\nexport function generateColumnSpec<T>(\n data: T[],\n options: ColumnSpecOptions<T>,\n): ColumnSpec[] {\n /** Generate a column spec from a dataset */\n const {\n overrides = {},\n nRows = 10,\n omitColumns,\n includeColumns,\n } = options ?? {};\n\n if (data == null) return [];\n\n const _nRows = Math.min(nRows, data.length);\n\n let columnSpec = generateDefaultColumnSpec(data.slice(0, _nRows));\n let filteredSpec = columnSpec.filter((col) => {\n if (omitColumns != null && omitColumns.includes(col.key)) {\n return false;\n }\n if (includeColumns != null && !includeColumns.includes(col.key)) {\n return false;\n }\n return true;\n });\n\n // Apply overrides\n return filteredSpec.map((col) => {\n let ovr = overrides[col.key];\n if (ovr == null) return col;\n if (typeof ovr === \"string\") {\n return { ...col, name: ovr };\n }\n return { ...col, ...ovr };\n });\n}\n"],"names":[],"mappings":";;AAEA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC,MAAM;AAAA,EACf,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC;AAAA,EAC3B,SAAS,CAAC,MAAO,IAAI,MAAM;AAAA,EAC3B,QAAQ,CAAC,MAAM,KA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AO;AAAA,EACT,CAAC;AAGD,SAAO,aAAa,IAAI,CAAC,QAAQ;AAC/B,QAAI,MAAM,UAAU,IAAI,GAAG;AAC3B,QAAI,OAAO,KAAM,QAAO;AACxB,QAAI,OAAO,QAAQ,UAAU;AAC3B,aAAO,EAAE,GAAG,KAAK,MAAM,IAAA;AAAA,IACzB;AACA,WAAO,EAAE,GAAG,KAAK,GAAG,IAAA;AAAA,EACtB,CAAC;AACH;;;"}
1
+ {"version":3,"file":"column-spec.cjs","sources":["../../src/utils/column-spec.ts"],"sourcesContent":["import React from \"react\";\n\nconst defaultRenderers = {\n string: (d) => d,\n number: (d) => d?.toFixed(2),\n boolean: (d) => (d ? \"T\" : \"F\"),\n object: (d) => JSON.stringify(d),\n integer: (d) => d?.toFixed(0),\n array: (d) => d?.join(\", \"),\n};\n\ninterface ColumnSpecGenerateOptions {\n calculateWidths?: boolean;\n defaultWidth?: number;\n getWidthForValue?: (value: any) => number;\n}\n\nconst defaultWidthForValue = (val) => String(val).length * 8;\n\n/** Inferred data type of a column, used to select appropriate\n * sort/filter operators. */\nexport type ColumnDataType =\n | \"text\"\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\";\n\n/** Severity of a cell validation result. `warning` is soft (flagged, doesn't\n * block saving); `error` is hard (blocks saving). */\nexport type ValidationSeverity = \"warning\" | \"error\";\n\n/** The result of validating a cell. `null` means valid. */\nexport interface CellValidation {\n severity: ValidationSeverity;\n message?: string;\n}\n\n/**\n * Context handed to per-cell renderers (`valueRenderer`, and — as the\n * `cellContext` prop — a custom `cellComponent`). It lets a renderer draw\n * based on the row/column position and the cell's edit status, and, combined\n * with the editing API, write edits back for a specific cell.\n *\n * `rowIndex` is the underlying **data-row index** (the value edit methods\n * expect), so it stays stable when a sort or filter reorders the view.\n */\nexport interface CellRenderContext<T = any> {\n /** The cell's current value (the edited value if present, else the base). */\n value: any;\n /** Underlying data-row index — stable under sort/filter. */\n rowIndex: number;\n /** Column index within the active column spec. */\n colIndex: number;\n /** The full column spec for this cell's column. */\n column: ColumnSpec;\n /** The full row object backing this cell (may be undefined while loading). */\n row: T | undefined;\n /** Whether this cell has an uncommitted edit. */\n isEdited: boolean;\n /** Whether this cell's row is marked for deletion. */\n isDeleted: boolean;\n /** The row's status value (`RowStatusValue`) — `\"deleted\"` / `\"added\"` or a\n * consumer-defined status (e.g. `\"omitted\"`), or `undefined` for a normal\n * row. Lets a renderer style by arbitrary status, not just deletion. */\n status: string | undefined;\n /** Validation result for this cell, or `null` when valid. Orthogonal to the\n * edit status — a cell can be both edited and invalid. */\n validation: CellValidation | null;\n}\n\n/**\n * The editor configuration for a cell. Mirrors the static `dataEditor` /\n * `inlineEditor` column fields so a per-cell resolver (`editorForCell`) can\n * override either one for an individual cell.\n */\nexport interface CellEditors {\n dataEditor?: any;\n inlineEditor?: boolean | React.ComponentType<any> | string | null;\n}\n\n/**\n * Context for a cell's detail surface (`cellDetail`). Extends the render\n * context with the edit affordances and controls a surface needs, so one\n * component can act as an editor (when `editable`) or a read-only viewer\n * (otherwise). This is the write side of the read/write contract, per-cell.\n */\nexport interface CellDetailContext<T = any> extends CellRenderContext<T> {\n /** Whether this cell is editable (column × table × not-deleted). */\n editable: boolean;\n /** Commit a new value for this cell. */\n onChange: (value: any) => void;\n /** Reset this cell (and selection) to its base value. */\n resetValue: () => void;\n /** Close the surface and return focus to the table. */\n close: () => void;\n}\n\n/** How a cell's detail surface is presented. Orthogonal to what it renders. */\nexport type DetailPresentation = \"popover\" | \"modal\" | \"inline\";\n\nexport interface ColumnSpec {\n name: string;\n key: string;\n /** When true, an empty value is an error (sugar over `validate`). */\n required?: boolean;\n /** Validate a cell's value. Return a `{ severity, message }` for a\n * warning/error, or `null` when valid. Runs after the `required` check.\n * `warning` flags the cell but allows saving; `error` blocks saving. */\n validate?: (\n value: any,\n row: any,\n ctx: { rowIndex: number },\n ) => CellValidation | null;\n /** @deprecated Prefer `validate`, which carries severity + a message.\n * A falsy result maps to an `error`. */\n isValid?: (d: any) => boolean;\n transformValue?: (d: any) => any;\n valueRenderer?: (\n d: any,\n ctx?: CellRenderContext,\n ) => string | React.ReactNode;\n headerRenderer?: (d: any) => string | React.ReactNode;\n dataEditor?: any;\n /**\n * Choose the editor for an individual cell from its render context,\n * overriding the static `dataEditor` / `inlineEditor` for that cell. Return\n * `undefined` (or omit a key) to fall back to the static configuration —\n * e.g. show a textarea only for cells whose value is long. A returned key is\n * respected even when its value is `false`/`null` (i.e. \"no editor here\").\n */\n editorForCell?: (ctx: CellRenderContext) => CellEditors | undefined;\n /**\n * Render a read-only detail panel for a cell. When set, selecting the cell\n * opens a popover with this content (following the table's `cellInteraction`\n * mode). The panel never takes keyboard focus, so arrow keys keep navigating\n * the table; Escape closes it. Mutually distinct from `dataEditor` — use this\n * for non-editable surfaces (previews, summaries, links).\n *\n * @deprecated Prefer `cellDetail`, which unifies editor and viewer.\n */\n detailRenderer?: (ctx: CellRenderContext) => React.ReactNode;\n /**\n * The unified cell surface (Workstream A): one renderer that acts as an\n * editor when `ctx.editable` and a read-only viewer otherwise, superseding\n * `dataEditor` / `detailRenderer` / `editorForCell`. Presentation is chosen\n * separately via `detailPresentation` (popover / modal / inline), so the\n * same component works in any container.\n */\n cellDetail?: (ctx: CellDetailContext) => React.ReactNode;\n /** How `cellDetail` is presented. Defaults to `\"popover\"`. */\n detailPresentation?: DetailPresentation;\n cellComponent?: any;\n category?: string;\n editable?: boolean;\n inlineEditor?: boolean | React.ComponentType<any> | string | null;\n style?: React.CSSProperties;\n width?: number;\n /** Column-specific table actions (TableAction[]). These appear in the\n * actions toolbar when this column is part of the current selection. */\n actions?: any[];\n /** Column-specific table filters (TableFilter[]). These appear in the\n * filter bar and apply to this column's values. */\n filters?: any[];\n /** Whether this column supports server-side sorting. */\n sortable?: boolean;\n /** Whether this column supports server-side filtering.\n * Set to `true` for default operators, or provide a config object\n * with a custom set of operators. */\n filterable?: boolean | { operators?: string[] };\n /** Inferred data type, used to select context-appropriate filter\n * operators when `filterable` is `true` without explicit operators. */\n dataType?: ColumnDataType;\n /** Whether this column may be drag-reordered. Defaults to `true`; set\n * `false` to pin a fixed/system column in place. Applied by the default\n * header renderer (requires table-level `enableColumnReordering`). */\n reorderable?: boolean;\n}\n\nexport interface ColumnSpecOptions<T> {\n overrides: Record<string, Partial<ColumnSpec> | string>;\n data?: T[]; // Data to use for type inference\n nRows?: number; // Number of rows to use for type inference\n omitColumns?: string[]; // Columns to omit. Takes precedence over includeColumns.\n includeColumns?: string[]; // Columns to include.\n}\n\nexport function generateDefaultColumnSpec<T>(\n data: Array<T>,\n options: ColumnSpecGenerateOptions = {},\n): ColumnSpec[] {\n /** Build a default column spec from a dataset based on the first n rows */\n if (data == null) return [];\n // Get the keys\n\n const {\n defaultWidth = 150,\n calculateWidths = true,\n getWidthForValue = defaultWidthForValue,\n } = options;\n\n const keys = new Set<string>();\n const types = new Map();\n\n const columnWidths = new Map<string, number>();\n\n for (const row of data) {\n if (row == null) continue;\n for (const key of Object.keys(row)) {\n const val = row[key];\n keys.add(key);\n\n if (val == null) continue;\n\n if (calculateWidths) {\n let width = getWidthForValue(val);\n if (width != null && width >= 0) {\n columnWidths.set(key, Math.max(width, columnWidths.get(key) ?? 0));\n }\n }\n\n let type: string = typeof val;\n // Special 'type' for integers\n if (Number.isInteger(val)) {\n type = \"integer\";\n }\n\n // Special 'type' for arrays of simple values\n if (\n Array.isArray(val) &&\n val.every((d) => typeof d === \"string\" || typeof d === \"number\")\n ) {\n type = \"array\";\n }\n\n // Check if it is strictly a string, if so, we can explicitly mark it as text\n if (type === \"string\") {\n type = \"text\";\n }\n\n if (types.has(key)) {\n if (types.get(key) !== type) {\n if (type === \"number\" && types.get(key) === \"integer\") {\n types.set(key, \"number\");\n }\n if (type === \"object\" && types.get(key) === \"array\") {\n types.set(key, \"object\");\n }\n\n types.set(key, \"string\");\n }\n } else {\n types.set(key, type);\n }\n }\n }\n\n // Build a column spec\n const spec = [];\n for (const key of keys) {\n let width = null;\n if (calculateWidths) {\n // If we are calculating widths, use the value lengths\n width = Math.min(\n Math.max(defaultWidth / 2, columnWidths.get(key) ?? defaultWidth),\n defaultWidth * 1.5,\n );\n }\n\n const dataType = (types.get(key) ?? \"string\") as ColumnDataType;\n\n // Auto-infer sortable/filterable based on data type.\n // Scalar types (string, number, integer, boolean) get sort/filter;\n // complex types (object, array) do not.\n const isScalar =\n dataType === \"text\" ||\n dataType === \"string\" ||\n dataType === \"number\" ||\n dataType === \"integer\" ||\n dataType === \"boolean\";\n\n spec.push({\n name: key,\n key,\n valueRenderer: defaultRenderers[types.get(key)],\n width,\n dataType,\n sortable: isScalar,\n filterable: isScalar,\n });\n }\n return spec;\n}\n\nexport function generateColumnSpec<T>(\n data: T[],\n options: ColumnSpecOptions<T>,\n): ColumnSpec[] {\n /** Generate a column spec from a dataset */\n const {\n overrides = {},\n nRows = 10,\n omitColumns,\n includeColumns,\n } = options ?? {};\n\n if (data == null) return [];\n\n const _nRows = Math.min(nRows, data.length);\n\n let columnSpec = generateDefaultColumnSpec(data.slice(0, _nRows));\n let filteredSpec = columnSpec.filter((col) => {\n if (omitColumns != null && omitColumns.includes(col.key)) {\n return false;\n }\n if (includeColumns != null && !includeColumns.includes(col.key)) {\n return false;\n }\n return true;\n });\n\n // Apply overrides\n return filteredSpec.map((col) => {\n let ovr = overrides[col.key];\n if (ovr == null) return col;\n if (typeof ovr === \"string\") {\n return { ...col, name: ovr };\n }\n return { ...col, ...ovr };\n });\n}\n"],"names":[],"mappings":";;AAEA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC,MAAM;AAAA,EACf,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC;AAAA,EAC3B,SAAS,CAAC,MAAO,IAAI,MAAM;AAAA,EAC3B,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC;AAAA,EAC/B,SAAS,CAAC,MAAM,GAAG,QAAQ,CAAC;AAAA,EAC5B,OAAO,CAAC,MAAM,GAAG,KAAK,IAAI;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AAM,QAAO;AACxB,QAAI,OAAO,QAAQ,UAAU;AAC3B,aAAO,EAAE,GAAG,KAAK,MAAM,IAAA;AAAA,IACzB;AACA,WAAO,EAAE,GAAG,KAAK,GAAG,IAAA;AAAA,EACtB,CAAC;AACH;;;"}
@@ -143,6 +143,10 @@ export interface ColumnSpec {
143
143
  /** Inferred data type, used to select context-appropriate filter
144
144
  * operators when `filterable` is `true` without explicit operators. */
145
145
  dataType?: ColumnDataType;
146
+ /** Whether this column may be drag-reordered. Defaults to `true`; set
147
+ * `false` to pin a fixed/system column in place. Applied by the default
148
+ * header renderer (requires table-level `enableColumnReordering`). */
149
+ reorderable?: boolean;
146
150
  }
147
151
  export interface ColumnSpecOptions<T> {
148
152
  overrides: Record<string, Partial<ColumnSpec> | string>;