@macrostrat/data-sheet 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/esm/{data-sheet.e09ffc66.js → data-sheet.2521a9d7.js} +4 -6
  3. package/dist/esm/data-sheet.2521a9d7.js.map +1 -0
  4. package/dist/esm/data-sheet.410c5122.js.map +1 -1
  5. package/dist/esm/{data-sheet.2773da15.js → data-sheet.aa2b4902.js} +18 -6
  6. package/dist/esm/data-sheet.aa2b4902.js.map +1 -0
  7. package/dist/esm/data-sheet.b4098761.js.map +1 -1
  8. package/dist/esm/{data-sheet.e37b4bd3.js → data-sheet.ce2a3218.js} +4 -2
  9. package/dist/esm/data-sheet.ce2a3218.js.map +1 -0
  10. package/dist/esm/{data-sheet.00171fc5.js → data-sheet.e09e2546.js} +63 -15
  11. package/dist/esm/data-sheet.e09e2546.js.map +1 -0
  12. package/dist/esm/index.d.ts +66 -20
  13. package/dist/esm/index.d.ts.map +1 -1
  14. package/dist/esm/index.js +7 -3
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/node/data-sheet.22cde343.js +2 -0
  17. package/dist/node/data-sheet.22cde343.js.map +1 -0
  18. package/dist/node/data-sheet.52753d1d.js +2 -0
  19. package/dist/node/data-sheet.52753d1d.js.map +1 -0
  20. package/dist/node/data-sheet.7bbad640.js.map +1 -1
  21. package/dist/node/data-sheet.820e5bc3.js +2 -0
  22. package/dist/node/data-sheet.820e5bc3.js.map +1 -0
  23. package/dist/node/data-sheet.846d5f8f.js +2 -0
  24. package/dist/node/data-sheet.846d5f8f.js.map +1 -0
  25. package/dist/node/data-sheet.86550c41.js +2 -0
  26. package/dist/node/data-sheet.86550c41.js.map +1 -0
  27. package/dist/node/data-sheet.cbbc8d31.js +2 -0
  28. package/dist/node/data-sheet.cbbc8d31.js.map +1 -0
  29. package/dist/node/index.js +1 -1
  30. package/dist/node/index.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/components/index.ts +1 -0
  33. package/src/core.ts +2 -7
  34. package/src/index.ts +2 -0
  35. package/src/postgrest-table/data-loaders.ts +27 -8
  36. package/src/postgrest-table/index.ts +72 -12
  37. package/src/provider.ts +4 -2
  38. package/src/utils/column-spec.ts +3 -1
  39. package/dist/esm/data-sheet.00171fc5.js.map +0 -1
  40. package/dist/esm/data-sheet.2773da15.js.map +0 -1
  41. package/dist/esm/data-sheet.e09ffc66.js.map +0 -1
  42. package/dist/esm/data-sheet.e37b4bd3.js.map +0 -1
  43. package/dist/node/data-sheet.0f66147e.js +0 -2
  44. package/dist/node/data-sheet.0f66147e.js.map +0 -1
  45. package/dist/node/data-sheet.47e3f95c.js +0 -2
  46. package/dist/node/data-sheet.47e3f95c.js.map +0 -1
  47. package/dist/node/data-sheet.599efaa9.js +0 -2
  48. package/dist/node/data-sheet.599efaa9.js.map +0 -1
  49. package/dist/node/data-sheet.95445483.js +0 -2
  50. package/dist/node/data-sheet.95445483.js.map +0 -1
  51. package/dist/node/data-sheet.c3eefdc9.js +0 -2
  52. package/dist/node/data-sheet.c3eefdc9.js.map +0 -1
  53. package/dist/node/data-sheet.e6e07d4a.js +0 -2
  54. package/dist/node/data-sheet.e6e07d4a.js.map +0 -1
@@ -1 +0,0 @@
1
- {"mappings":"A,M,2C,A,Q,iB,C,C,U,C,C,Y,C,C,a,C,C,c,C,K,O,A,Q,M,mB,A,Q,e,C,C,Y,C,K,S,A,Q,kB,C,K,kB,A,Q,M,qB,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E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CAAM,EAAG,EACxD,CAEO,SAAS,IACd,IAAM,EAAQ,AAAA,EAAW,GACzB,GAAI,CAAC,EACH,MAAM,AAAI,MAAM,6BAElB,OAAO,CACT,CAEO,SAAS,EACd,CAAkE,EAGlE,OAAO,AAAA,EADO,IACS,EACzB,CAEA,SAAS,EAAmB,CAAmB,EAC7C,IAAM,EAAc,EAAkB,GAClC,EAAmC,CACrC,UAAA,EACA,YAAA,EACA,YAAa,EAAY,EAC3B,EAIA,OAHI,AAAe,MAAf,GACF,CAAA,EAAK,iBAAiB,CAAG,IAD3B,EAGO,CACT,CAgCO,SAAS,EACd,CAAiB,CACjB,EAA+B,CAAA,CAAK,EAGpC,GAAI,AAAW,MAAX,EAAiB,OAAO,KAC5B,GAAM,CAAC,EAAO,CAAG,EACjB,GAAI,AAAU,MAAV,EAAgB,OAAO,KAC3B,GAAM,CAAA,KAAE,CAAI,CAAA,KAAE,CAAI,CAAE,CAAG,SACvB,AAAY,MAAR,GAAgB,AAAQ,MAAR,GAChB,GAAwB,CAAA,CAAI,CAAC,EAAE,GAAK,CAAI,CAAC,EAAE,EAAI,CAAI,CAAC,EAAE,GAAK,CAAI,CAAC,EAAC,AAAD,EAD3B,KAGlC,CAAE,IAAK,CAAI,CAAC,EAAE,CAAE,IAAK,CAAI,CAAC,EAAE,CAAE,oBAAqB,CAAE,CAC9D,CA6BO,SAAS,EACd,CAAa,SAGb,AAAI,GAAK,SAAW,EAAU,KACvB,EAAY,EAAK,CAAA,EAC1B,Q,K,iB,C,K,iB,C,K,W,C,K,W,C,K,W","sources":["<anon>","packages/data-sheet/src/provider.ts"],"sourcesContent":["import \"./data-sheet.50d0742f.js\";\nimport {createContext as $lNLp4$createContext, useRef as $lNLp4$useRef, useState as $lNLp4$useState, useEffect as $lNLp4$useEffect, useContext as $lNLp4$useContext} from \"react\";\nimport $lNLp4$macrostrathyper from \"@macrostrat/hyper\";\nimport {createStore as $lNLp4$createStore, useStore as $lNLp4$useStore} from \"zustand\";\nimport {createComputed as $lNLp4$createComputed} from \"zustand-computed\";\nimport $lNLp4$immutabilityhelper from \"immutability-helper\";\n\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\n\n\n\n\nvar $50UEa = parcelRequire(\"50UEa\");\n\nconst $7e5384423bc0f425$var$DataSheetContext = (0, $lNLp4$createContext)(null);\nconst $7e5384423bc0f425$var$computed = (0, $lNLp4$createComputed)((state)=>({\n hasUpdates: state.updatedData.length > 0 || state.deletedRows.size > 0\n }));\nfunction $7e5384423bc0f425$export$135c527978291360({ children: children, data: data, columnSpec: columnSpec, columnSpecOptions: columnSpecOptions, editable: editable, enableColumnReordering: enableColumnReordering }) {\n const visibleCellsRef = (0, $lNLp4$useRef)({\n rowIndexStart: 0,\n rowIndexEnd: 0\n });\n const tableRef = (0, $lNLp4$useRef)(null);\n const [store] = (0, $lNLp4$useState)(()=>{\n return (0, $lNLp4$createStore)($7e5384423bc0f425$var$computed((set)=>{\n return {\n data: data,\n columnSpec: columnSpec ?? (0, $50UEa.generateColumnSpec)(data, columnSpecOptions),\n editable: editable,\n deletedRows: new Set(),\n selection: [],\n fillValueBaseCell: null,\n updatedData: [],\n focusedCell: null,\n topLeftCell: null,\n initialized: false,\n tableRef: tableRef,\n // This is a placeholder\n enableColumnReordering: false,\n setSelection (selection) {\n set($7e5384423bc0f425$var$updateSelection(selection));\n },\n moveFocusedCell (direction) {\n set((state)=>{\n const { topLeftCell: topLeftCell } = state;\n if (topLeftCell == null) return {};\n let { col: col, row: row } = topLeftCell;\n switch(direction){\n case \"up\":\n row = Math.max(0, row - 1);\n break;\n case \"down\":\n row = Math.min(row + 1, Math.max(state.data.length, state.updatedData.length) - 1);\n break;\n case \"left\":\n col = Math.max(0, col - 1);\n break;\n case \"right\":\n col = Math.min(col + 1, state.columnSpec.length - 1);\n break;\n }\n const region = {\n cols: [\n col,\n col\n ],\n rows: [\n row,\n row\n ]\n };\n return $7e5384423bc0f425$var$updateSelection([\n region\n ]);\n });\n },\n addRow (row = {}) {\n /** Add a new row. If there is a selection, use the last row index to determine\n * where to insert the new row. Otherwise, append to the end of the data. */ set((state)=>{\n const { updatedData: updatedData, data: data, selection: selection } = state;\n const lastRowIndex = $7e5384423bc0f425$var$getLastRowIndex(selection) ?? Math.max(data.length, updatedData.length) - 1;\n // If there is a selection, insert the new row after the last selected row\n const spec = {\n $splice: [\n [\n lastRowIndex + 1,\n 0,\n row\n ]\n ]\n };\n console.log(spec);\n return {\n updatedData: (0, $lNLp4$immutabilityhelper)(updatedData, spec)\n };\n });\n },\n setUpdatedData (data) {\n if (Array.isArray(data)) set({\n updatedData: data\n });\n else set((state)=>{\n return {\n updatedData: data(state.updatedData)\n };\n });\n },\n deleteSelectedRows () {\n // Remove selected rows from the data and updatedData arrays\n set((state)=>{\n const { selection: selection, deletedRows: deletedRows } = state;\n const rowIndices = $7e5384423bc0f425$var$getRowIndices(selection);\n // Delete rows from both updatedData and data\n const newDeletedRows = new Set(deletedRows);\n for (const rowIndex of rowIndices)newDeletedRows.add(rowIndex);\n // Remove selected rows and reset selection\n return {\n deletedRows: newDeletedRows,\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null\n };\n });\n },\n resetChanges () {\n // Reset the updated data to the initial data\n set((state)=>({\n updatedData: [],\n deletedRows: new Set(),\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null\n }));\n },\n setVisibleCells (visibleCells) {\n // Visible cells are used for infinite scrolling\n // Right now we don't store this in the state\n visibleCellsRef.current = visibleCells;\n },\n onDragValue (cell) {\n set({\n fillValueBaseCell: cell\n });\n },\n onCellEdited (rowIndex, columnName, value) {\n set((state)=>{\n const { editable: editable, updatedData: updatedData, data: data } = state;\n if (!editable) return {};\n let rowSpec;\n // Check to see if the new value is the same as the old one\n if (value !== data[rowIndex]?.[columnName]) {\n const rowOp = updatedData[rowIndex] != null ? \"$merge\" : \"$set\";\n rowSpec = {\n [rowOp]: {\n [columnName]: value\n }\n };\n } else rowSpec = {\n $unset: [\n columnName\n ]\n };\n const spec = {\n [rowIndex]: rowSpec\n };\n return {\n updatedData: (0, $lNLp4$immutabilityhelper)(updatedData, spec)\n };\n });\n },\n initialize (props) {\n set({\n ...props,\n initialized: true\n });\n },\n clearSelection () {\n set((state)=>{\n // Delete all selected cells\n const { selection: selection, updatedData: updatedData, columnSpec: columnSpec, data: data } = state;\n let spec = {};\n for (const region of selection){\n const { cols: cols, rows: rows } = region;\n const rowRange = (0, $50UEa.range)(rows ?? [\n 0,\n updatedData.length - 1\n ]);\n const colRange = (0, $50UEa.range)(cols ?? [\n 0,\n columnSpec.length - 1\n ]);\n for (const row of rowRange){\n let vals = {};\n for (const col of colRange){\n const key = columnSpec[col].key;\n const currentValue = updatedData[row]?.[key] ?? data[row]?.[key];\n if (currentValue != null && currentValue !== \"\") vals[key] = \"\";\n }\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = {\n [op]: vals\n };\n }\n }\n return {\n updatedData: (0, $lNLp4$immutabilityhelper)(updatedData, spec)\n };\n });\n },\n onSelection (selection) {\n set((state)=>{\n if ($7e5384423bc0f425$var$selectionEquals(selection, state.selection) && $7e5384423bc0f425$export$de0bb697976d7dcb(selection) == null // Only if we're in a multi-cell selection mode\n ) // If the selection is the same as the current selection, remove the selection.\n // In practice this only happens for whole-row and whole-column selections\n return {\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null\n };\n let spec = $7e5384423bc0f425$var$updateSelection(selection);\n if (state.fillValueBaseCell != null) spec.updatedData = $7e5384423bc0f425$var$fillValues(state, selection);\n return spec;\n });\n },\n onColumnsReordered (oldIndex, newIndex, length) {\n set((state)=>{\n if (!state.enableColumnReordering) return {};\n const { columnSpec: columnSpec } = state;\n const newSpec = [\n ...columnSpec\n ];\n const removed = newSpec.splice(oldIndex, length);\n newSpec.splice(newIndex, 0, ...removed);\n return {\n columnSpec: newSpec\n };\n });\n },\n scrollToRow (rowIndex) {\n if (tableRef.current == null) return;\n tableRef.current.scrollToRegion({\n rows: [\n rowIndex,\n rowIndex\n ]\n });\n }\n };\n }));\n });\n // Not sure how required this initialization is\n (0, $lNLp4$useEffect)(()=>{\n const { initialize: initialize } = store.getState();\n initialize({\n data: data,\n columnSpec: columnSpec ?? (0, $50UEa.generateColumnSpec)(data, columnSpecOptions),\n editable: editable,\n enableColumnReordering: enableColumnReordering\n });\n }, [\n data,\n editable,\n columnSpec,\n columnSpecOptions,\n enableColumnReordering\n ]);\n return (0, $lNLp4$macrostrathyper)($7e5384423bc0f425$var$DataSheetContext.Provider, {\n value: store\n }, children);\n}\nfunction $7e5384423bc0f425$export$54fc6f5c8f914926() {\n const store = (0, $lNLp4$useContext)($7e5384423bc0f425$var$DataSheetContext);\n if (!store) throw new Error(\"Missing DataSheetProvider\");\n return store;\n}\nfunction $7e5384423bc0f425$export$2105062e25df4afe(selector) {\n const store = $7e5384423bc0f425$export$54fc6f5c8f914926();\n return (0, $lNLp4$useStore)(store, selector);\n}\nfunction $7e5384423bc0f425$var$updateSelection(selection) {\n const focusedCell = $7e5384423bc0f425$export$de0bb697976d7dcb(selection);\n let spec = {\n selection: selection,\n focusedCell: focusedCell,\n topLeftCell: $7e5384423bc0f425$export$88b0ba8661dc41b4(selection)\n };\n if (focusedCell != null) spec.fillValueBaseCell = null;\n return spec;\n}\nfunction $7e5384423bc0f425$var$getLastRowIndex(regions) {\n /** Get the last row index from a selection of regions */ if (regions == null || regions.length === 0) return null;\n let lastRow = -1;\n for (const region of regions){\n const { rows: rows } = region;\n if (rows == null || rows.length !== 2) continue;\n lastRow = Math.max(lastRow, rows[1]);\n }\n if (lastRow < 0) /** If no valid rows are found, return null */ return null;\n return lastRow;\n}\nfunction $7e5384423bc0f425$var$getRowIndices(regions) {\n /** Get the row indices from a selection of regions */ if (regions == null || regions.length === 0) return [];\n const rowIndices = new Set();\n for (const region of regions){\n const { rows: rows } = region;\n if (rows == null || rows.length !== 2) continue;\n for(let i = rows[0]; i <= rows[1]; i++)rowIndices.add(i);\n }\n return Array.from(rowIndices).sort((a, b)=>a - b);\n}\nfunction $7e5384423bc0f425$export$88b0ba8661dc41b4(regions, requireSolitaryCell = false) {\n /** Top left cell of a ranged selection */ if (regions == null) return null;\n const [region] = regions;\n if (region == null) return null;\n const { cols: cols, rows: rows } = region;\n if (cols == null || rows == null) return null;\n if (requireSolitaryCell && (cols[0] !== cols[1] || rows[0] !== rows[1])) return null;\n return {\n col: cols[0],\n row: rows[0],\n focusSelectionIndex: 0\n };\n}\nfunction $7e5384423bc0f425$var$selectionEquals(a, b) {\n /** Check if two selections are equal */ if (a.length !== b.length) return false;\n for(let i = 0; i < a.length; i++){\n const regionA = a[i];\n const regionB = b[i];\n const colsA = regionA.cols ?? [];\n const colsB = regionB.cols ?? [];\n const rowsA = regionA.rows ?? [];\n const rowsB = regionB.rows ?? [];\n if (colsA.length !== colsB.length || rowsA.length !== rowsB.length || colsA[0] !== colsB[0] || colsA[1] !== colsB[1] || rowsA[0] !== rowsB[0] || rowsA[1] !== rowsB[1]) return false;\n }\n return true;\n}\nfunction $7e5384423bc0f425$export$de0bb697976d7dcb(sel) {\n /** Derive a single focused cell from a selected region, if possible */ if (sel?.length !== 1) return null;\n return $7e5384423bc0f425$export$88b0ba8661dc41b4(sel, true);\n}\nfunction $7e5384423bc0f425$var$fillValues(state, selection) {\n const { updatedData: updatedData, columnSpec: columnSpec, editable: editable, fillValueBaseCell: fillValueBaseCell, data: data } = state;\n // Prepare regions by unnesting columns\n let regions = selection.map((region)=>{\n const { cols: cols, rows: rows } = region;\n // Get the first column (maybe should be the last)\n const [col] = cols;\n return {\n cols: [\n col,\n col\n ],\n rows: rows\n };\n });\n // Fill values downwards\n if (!editable || fillValueBaseCell == null) return updatedData;\n const { col: col, row: row } = fillValueBaseCell;\n const key = columnSpec[col].key;\n const value = updatedData[row]?.[key] ?? data[row][key];\n const spec = {};\n for (const region of regions){\n const { cols: cols, rows: rows } = region;\n for (const row of (0, $50UEa.range)(rows)){\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = {\n [op]: {\n [key]: value\n }\n };\n }\n }\n return (0, $lNLp4$immutabilityhelper)(updatedData, spec);\n}\n\n\nexport {$7e5384423bc0f425$export$135c527978291360 as DataSheetProvider, $7e5384423bc0f425$export$de0bb697976d7dcb as singleFocusedCell, $7e5384423bc0f425$export$54fc6f5c8f914926 as useStoreAPI, $7e5384423bc0f425$export$2105062e25df4afe as useSelector, $7e5384423bc0f425$export$88b0ba8661dc41b4 as topLeftCell};\n//# sourceMappingURL=data-sheet.e6e07d4a.js.map\n","import { createContext, useContext, useEffect, useRef, useState } from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { createStore, StoreApi, useStore } from \"zustand\";\nimport { createComputed } from \"zustand-computed\";\nimport type {\n FocusedCellCoordinates,\n Region,\n Table2,\n} from \"@blueprintjs/table\";\nimport { generateColumnSpec } from \"./utils\";\nimport update, { Spec } from \"immutability-helper\";\nimport { range } from \"./utils\";\nimport React from \"react\";\n\nexport interface ColumnSpec {\n name: string;\n key: string;\n required?: boolean;\n isValid?: (d: any) => boolean;\n transformValue?: (d: any) => any;\n valueRenderer?: (d: any) => string | React.ReactNode;\n dataEditor?: any;\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}\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 interface DataSheetCoreProps<T> {\n data: T[];\n columnSpec?: ColumnSpec[];\n editable?: boolean;\n enableColumnReordering?: boolean;\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 deletedRows: Set<number>;\n // Sparse data structure for updated data\n updatedData: T[];\n initialized: boolean;\n}\n\nexport interface DataSheetComputedStore {\n hasUpdates: boolean;\n}\n\ntype DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;\n\nexport interface DataSheetStore<T> extends DataSheetVals<T> {\n setSelection(selection: Region[]): void;\n onDragValue(cell: FocusedCellCoordinates | null): void;\n setUpdatedData(data: T[]): void;\n onCellEdited(rowIndex: number, columnName: string, value: any): void;\n onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;\n moveFocusedCell(direction: \"up\" | \"down\" | \"left\" | \"right\"): void;\n deleteSelectedRows(): void;\n clearSelection(): void;\n resetChanges(): void;\n addRow(): void;\n initialize(props: DataSheetCoreProps<T>): void;\n onSelection(selection: Region[]): void;\n // Internal method used for infinite scrolling\n setVisibleCells(visibleCells: VisibleCells): void;\n scrollToRow(rowIndex: number): void;\n tableRef: React.MutableRefObject<Table2>;\n}\n\nexport type DataSheetProviderProps<T> = DataSheetCoreProps<T> & {\n children: React.ReactNode;\n columnSpecOptions?: ColumnSpecOptions<T>;\n};\n\nconst DataSheetContext = createContext<StoreApi<DataSheetStore<any>>>(null);\n\nexport interface VisibleCells {\n rowIndexStart: number;\n rowIndexEnd: number;\n}\n\nconst computed = createComputed(\n (state: DataSheetStore<any>): DataSheetComputedStore => ({\n hasUpdates: state.updatedData.length > 0 || state.deletedRows.size > 0,\n }),\n) as any;\n\nexport function DataSheetProvider<T>({\n children,\n data,\n columnSpec,\n columnSpecOptions,\n editable,\n enableColumnReordering,\n}: DataSheetProviderProps<T>) {\n const visibleCellsRef = useRef<VisibleCells>({\n rowIndexStart: 0,\n rowIndexEnd: 0,\n });\n\n const tableRef = useRef<Table2>(null);\n\n const [store] = useState(() => {\n return createStore<DataSheetStore<T>>(\n computed((set): DataSheetStore<T> => {\n return {\n data,\n columnSpec: columnSpec ?? generateColumnSpec(data, columnSpecOptions),\n editable,\n deletedRows: new Set<number>(),\n selection: [],\n fillValueBaseCell: null,\n updatedData: [],\n focusedCell: null,\n topLeftCell: null,\n initialized: false,\n tableRef,\n // This is a placeholder\n enableColumnReordering: false,\n setSelection(selection: Region[]) {\n set(updateSelection(selection));\n },\n moveFocusedCell(direction: \"up\" | \"down\" | \"left\" | \"right\") {\n set((state) => {\n const { topLeftCell } = state;\n if (topLeftCell == null) return {};\n let { col, row } = topLeftCell;\n switch (direction) {\n case \"up\":\n row = Math.max(0, row - 1);\n break;\n case \"down\":\n row = Math.min(\n row + 1,\n Math.max(state.data.length, state.updatedData.length) - 1,\n );\n break;\n case \"left\":\n col = Math.max(0, col - 1);\n break;\n case \"right\":\n col = Math.min(col + 1, state.columnSpec.length - 1);\n break;\n }\n const region: Region = { cols: [col, col], rows: [row, row] };\n return updateSelection([region]);\n });\n },\n addRow(row: Partial<T> = {} as T) {\n /** Add a new row. If there is a selection, use the last row index to determine\n * where to insert the new row. Otherwise, append to the end of the data. */\n set((state) => {\n const { updatedData, data, selection } = state;\n const lastRowIndex =\n getLastRowIndex(selection) ??\n Math.max(data.length, updatedData.length) - 1;\n // If there is a selection, insert the new row after the last selected row\n const spec: Spec<any> = {\n $splice: [[lastRowIndex + 1, 0, row]],\n };\n console.log(spec);\n\n return {\n updatedData: update(updatedData, spec),\n };\n });\n },\n setUpdatedData(data: T[] | ((state: T[]) => T[])) {\n if (Array.isArray(data)) {\n set({ updatedData: data });\n } else {\n set((state) => {\n return { updatedData: data(state.updatedData) };\n });\n }\n },\n deleteSelectedRows() {\n // Remove selected rows from the data and updatedData arrays\n set((state) => {\n const { selection, deletedRows } = state;\n const rowIndices = getRowIndices(selection);\n\n // Delete rows from both updatedData and data\n const newDeletedRows = new Set(deletedRows);\n for (const rowIndex of rowIndices) {\n newDeletedRows.add(rowIndex);\n }\n\n // Remove selected rows and reset selection\n return {\n deletedRows: newDeletedRows,\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n };\n });\n },\n resetChanges() {\n // Reset the updated data to the initial data\n set((state) => ({\n updatedData: [],\n deletedRows: new Set<number>(),\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n }));\n },\n setVisibleCells(visibleCells: VisibleCells) {\n // Visible cells are used for infinite scrolling\n // Right now we don't store this in the state\n visibleCellsRef.current = visibleCells;\n },\n onDragValue(cell: FocusedCellCoordinates | null) {\n set({ fillValueBaseCell: cell });\n },\n onCellEdited(rowIndex: number, columnName: string, value: any) {\n set((state) => {\n const { editable, updatedData, data } = state;\n if (!editable) return {};\n let rowSpec: any;\n // Check to see if the new value is the same as the old one\n if (value !== data[rowIndex]?.[columnName]) {\n const rowOp = updatedData[rowIndex] != null ? \"$merge\" : \"$set\";\n rowSpec = { [rowOp]: { [columnName]: value } };\n } else {\n rowSpec = { $unset: [columnName] };\n }\n const spec: Spec<T[]> = { [rowIndex]: rowSpec };\n return { updatedData: update(updatedData, spec) };\n });\n },\n initialize(props: DataSheetCoreProps<T>) {\n set({ ...props, initialized: true });\n },\n clearSelection() {\n set((state) => {\n // Delete all selected cells\n const { selection, updatedData, columnSpec, data } = state;\n let spec = {};\n for (const region of selection) {\n const { cols, rows } = region;\n const rowRange = range(rows ?? [0, updatedData.length - 1]);\n const colRange = range(cols ?? [0, columnSpec.length - 1]);\n for (const row of rowRange) {\n let vals = {};\n for (const col of colRange) {\n const key = columnSpec[col].key;\n const currentValue =\n updatedData[row]?.[key] ?? data[row]?.[key];\n if (currentValue != null && currentValue !== \"\") {\n vals[key] = \"\";\n }\n }\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: vals };\n }\n }\n return {\n updatedData: update(updatedData, spec),\n };\n });\n },\n onSelection(selection: Region[]) {\n set((state) => {\n if (\n selectionEquals(selection, state.selection) &&\n singleFocusedCell(selection) == null // Only if we're in a multi-cell selection mode\n ) {\n // If the selection is the same as the current selection, remove the selection.\n // In practice this only happens for whole-row and whole-column selections\n return {\n selection: [],\n focusedCell: null,\n topLeftCell: null,\n fillValueBaseCell: null,\n };\n }\n\n let spec = updateSelection(selection);\n if (state.fillValueBaseCell != null) {\n spec.updatedData = fillValues(state, selection);\n }\n return spec;\n });\n },\n onColumnsReordered(\n oldIndex: number,\n newIndex: number,\n length: number,\n ) {\n set((state) => {\n if (!state.enableColumnReordering) return {};\n const { columnSpec } = state;\n const newSpec = [...columnSpec];\n const removed = newSpec.splice(oldIndex, length);\n newSpec.splice(newIndex, 0, ...removed);\n return { columnSpec: newSpec };\n });\n },\n scrollToRow(rowIndex: number) {\n if (tableRef.current == null) return;\n tableRef.current.scrollToRegion({\n rows: [rowIndex, rowIndex],\n });\n },\n };\n }),\n );\n });\n\n // Not sure how required this initialization is\n useEffect(() => {\n const { initialize } = store.getState();\n initialize({\n data,\n columnSpec: columnSpec ?? generateColumnSpec(data, columnSpecOptions),\n editable,\n enableColumnReordering,\n });\n }, [data, editable, columnSpec, columnSpecOptions, enableColumnReordering]);\n\n return h(DataSheetContext.Provider, { value: store }, children);\n}\n\nexport function useStoreAPI<T>(): StoreApi<DataSheetStore<T>> {\n const store = useContext(DataSheetContext);\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> & DataSheetComputedStore) => A,\n): A {\n const store = useStoreAPI<T>();\n return useStore(store, selector);\n}\n\nfunction updateSelection<T>(selection: Region[]) {\n const focusedCell = singleFocusedCell(selection);\n let spec: Partial<DataSheetState<T>> = {\n selection,\n focusedCell,\n topLeftCell: topLeftCell(selection),\n };\n if (focusedCell != null) {\n spec.fillValueBaseCell = null;\n }\n return spec;\n}\n\nfunction getLastRowIndex(regions: Region[]): number | null {\n /** Get the last row index from a selection of regions */\n if (regions == null || regions.length === 0) return null;\n let lastRow = -1;\n for (const region of regions) {\n const { rows } = region;\n if (rows == null || rows.length !== 2) continue;\n lastRow = Math.max(lastRow, rows[1]);\n }\n if (lastRow < 0) {\n /** If no valid rows are found, return null */\n return null;\n }\n return lastRow;\n}\n\nfunction getRowIndices(regions: Region[]): number[] {\n /** Get the row indices from a selection of regions */\n if (regions == null || regions.length === 0) return [];\n const rowIndices = new Set<number>();\n for (const region of regions) {\n const { rows } = region;\n if (rows == null || rows.length !== 2) continue;\n for (let i = rows[0]; i <= rows[1]; i++) {\n rowIndices.add(i);\n }\n }\n return Array.from(rowIndices).sort((a, b) => a - b);\n}\n\nexport function topLeftCell(\n regions: Region[],\n requireSolitaryCell: boolean = false,\n): FocusedCellCoordinates | null {\n /** Top left cell of a ranged selection */\n if (regions == null) return null;\n const [region] = regions;\n if (region == null) return null;\n const { cols, rows } = region;\n if (cols == null || rows == null) return null;\n if (requireSolitaryCell && (cols[0] !== cols[1] || rows[0] !== rows[1]))\n return null;\n return { col: cols[0], row: rows[0], focusSelectionIndex: 0 };\n}\n\nfunction selectionEquals(a: Region[], b: Region[]): boolean {\n /** Check if two selections are equal */\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const regionA = a[i];\n const regionB = b[i];\n\n const colsA = regionA.cols ?? [];\n const colsB = regionB.cols ?? [];\n\n const rowsA = regionA.rows ?? [];\n const rowsB = regionB.rows ?? [];\n\n if (\n colsA.length !== colsB.length ||\n rowsA.length !== rowsB.length ||\n colsA[0] !== colsB[0] ||\n colsA[1] !== colsB[1] ||\n rowsA[0] !== rowsB[0] ||\n rowsA[1] !== rowsB[1]\n ) {\n return false;\n }\n }\n return true;\n}\n\nexport function singleFocusedCell(\n sel: Region[],\n): FocusedCellCoordinates | null {\n /** Derive a single focused cell from a selected region, if possible */\n if (sel?.length !== 1) return null;\n return topLeftCell(sel, true);\n}\n\nfunction fillValues<T>(state: DataSheetStore<T>, selection: Region[]) {\n const { updatedData, columnSpec, editable, fillValueBaseCell, data } = state;\n\n // Prepare regions by unnesting columns\n let regions = selection.map((region) => {\n const { cols, rows } = region;\n // Get the first column (maybe should be the last)\n const [col] = cols;\n return { cols: [col, col], rows };\n });\n\n // Fill values downwards\n if (!editable || fillValueBaseCell == null) return updatedData;\n const { col, row } = fillValueBaseCell;\n const key = columnSpec[col].key;\n const value = updatedData[row]?.[key] ?? data[row][key];\n const spec = {};\n for (const region of regions) {\n const { cols, rows } = region;\n for (const row of range(rows)) {\n let op = updatedData[row] == null ? \"$set\" : \"$merge\";\n spec[row] = { [op]: { [key]: value } };\n }\n }\n return update(updatedData, spec);\n}\n"],"names":["createContext","$lNLp4$createContext","useRef","$lNLp4$useRef","useState","$lNLp4$useState","useEffect","$lNLp4$useEffect","useContext","$lNLp4$useContext","$lNLp4$macrostrathyper","createStore","$lNLp4$createStore","useStore","$lNLp4$useStore","createComputed","$lNLp4$createComputed","$lNLp4$immutabilityhelper","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$50UEa","$7e5384423bc0f425$var$DataSheetContext","$7e5384423bc0f425$var$computed","state","hasUpdates","updatedData","length","deletedRows","size","$7e5384423bc0f425$export$135c527978291360","children","data","columnSpec","columnSpecOptions","editable","enableColumnReordering","visibleCellsRef","rowIndexStart","rowIndexEnd","tableRef","store","set","generateColumnSpec","Set","selection","fillValueBaseCell","focusedCell","topLeftCell","initialized","setSelection","$7e5384423bc0f425$var$updateSelection","moveFocusedCell","direction","col","row","Math","max","min","cols","rows","addRow","spec","$splice","lastRowIndex","$7e5384423bc0f425$var$getLastRowIndex","regions","lastRow","region","console","log","setUpdatedData","Array","isArray","deleteSelectedRows","rowIndices","$7e5384423bc0f425$var$getRowIndices","i","add","from","sort","a","b","newDeletedRows","rowIndex","resetChanges","setVisibleCells","visibleCells","current","onDragValue","cell","onCellEdited","columnName","value","rowSpec","$unset","initialize","props","clearSelection","rowRange","range","colRange","vals","key","currentValue","op","onSelection","$7e5384423bc0f425$var$selectionEquals","regionA","regionB","colsA","colsB","rowsA","rowsB","$7e5384423bc0f425$export$de0bb697976d7dcb","$7e5384423bc0f425$var$fillValues","map","onColumnsReordered","oldIndex","newIndex","newSpec","removed","splice","scrollToRow","scrollToRegion","getState","Provider","$7e5384423bc0f425$export$54fc6f5c8f914926","$7e5384423bc0f425$export$2105062e25df4afe","selector","$7e5384423bc0f425$export$88b0ba8661dc41b4","requireSolitaryCell","focusSelectionIndex","sel","DataSheetProvider","singleFocusedCell","useStoreAPI","useSelector"],"version":3,"file":"data-sheet.e6e07d4a.js.map","sourceRoot":"../../../../"}