@macrostrat/data-sheet 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/esm/data-sheet.410c5122.js.map +1 -1
- package/dist/esm/{data-sheet.b4098761.js → data-sheet.45e8d3b0.js} +2 -2
- package/dist/esm/data-sheet.45e8d3b0.js.map +1 -0
- package/dist/esm/{data-sheet.e09e2546.js → data-sheet.a0d5d18d.js} +7 -6
- package/dist/esm/data-sheet.a0d5d18d.js.map +1 -0
- package/dist/esm/data-sheet.ae6daf58.js +14 -0
- package/dist/esm/data-sheet.ae6daf58.js.map +1 -0
- package/dist/esm/{data-sheet.2521a9d7.js → data-sheet.ce24dcf9.js} +4 -4
- package/dist/esm/data-sheet.ce24dcf9.js.map +1 -0
- package/dist/esm/index.d.ts +14 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/node/data-sheet.4a8fd8a7.js +2 -0
- package/dist/node/data-sheet.4a8fd8a7.js.map +1 -0
- package/dist/node/data-sheet.bb45401c.js +2 -0
- package/dist/node/data-sheet.bb45401c.js.map +1 -0
- package/dist/node/data-sheet.bfbba3fc.js +2 -0
- package/dist/node/data-sheet.bfbba3fc.js.map +1 -0
- package/dist/node/{data-sheet.22cde343.js → data-sheet.d40ac2ae.js} +2 -2
- package/dist/node/data-sheet.d40ac2ae.js.map +1 -0
- package/dist/node/{data-sheet.52753d1d.js → data-sheet.f3404ed5.js} +2 -2
- package/dist/node/{data-sheet.52753d1d.js.map → data-sheet.f3404ed5.js.map} +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +4 -4
- package/src/core.ts +2 -2
- package/src/index.ts +1 -0
- package/src/postgrest-table/index.ts +19 -15
- package/src/provider.ts +6 -27
- package/src/utils/column-spec.ts +25 -1
- package/src/utils/index.ts +1 -1
- package/dist/esm/data-sheet.0adfe599.js +0 -14
- package/dist/esm/data-sheet.0adfe599.js.map +0 -1
- package/dist/esm/data-sheet.2521a9d7.js.map +0 -1
- package/dist/esm/data-sheet.b4098761.js.map +0 -1
- package/dist/esm/data-sheet.e09e2546.js.map +0 -1
- package/dist/node/data-sheet.22cde343.js.map +0 -1
- package/dist/node/data-sheet.50d0742f.js +0 -2
- package/dist/node/data-sheet.50d0742f.js.map +0 -1
- package/dist/node/data-sheet.7bbad640.js +0 -2
- package/dist/node/data-sheet.7bbad640.js.map +0 -1
- package/dist/node/data-sheet.820e5bc3.js +0 -2
- package/dist/node/data-sheet.820e5bc3.js.map +0 -1
- package/src/__archive/base.ts +0 -55
- package/src/__archive/components/column-utils.ts +0 -126
- package/src/__archive/components/index.ts +0 -115
- package/src/__archive/components/toolbar.ts +0 -79
- package/src/__archive/editors/index.ts +0 -78
- package/src/__archive/editors/styles.module.scss +0 -10
- package/src/__archive/enhancers.ts +0 -36
- package/src/__archive/index.ts +0 -8
- package/src/__archive/main.ts +0 -180
- package/src/__archive/provider.ts +0 -179
- package/src/__archive/styles.module.scss +0 -56
- package/src/__archive/test-sheet/attitude-sheet.old.styl +0 -53
- package/src/__archive/test-sheet/attitude-sheet.scss +0 -60
- package/src/__archive/test-sheet/index.ts +0 -210
- package/src/__archive/virtualized.ts +0 -82
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,2C,A,O,2C,A,O,2C,A,Q,mB,C,C,e,C,C,U,C,C,U,C,C,c,C,K,mB,A,Q,U,C,C,iB,C,C,U,C,C,Q,C,K,oB,A,O,sC,A,Q,M,mB,A,Q,M,qB,A,Q,W,C,C,e,C,C,a,C,C,Y,C,K,O,C,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,ICsCY,E,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,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A,EAAA,WAAU,AAAV,EAAY,AAAC,GAAU,EAAM,WAAW,EAE5D,OAAO,EAAE,EAAA,eAAc,CAAG,CACxB,EAAE,EAAY,CACZ,KAAM,SACN,YAAa,aACb,MAAA,EACA,cAAc,CAAK,EACjB,EAAS,EACX,CACF,GACA,EACE,EACA,CACE,KAAM,cACN,UAEE,EAAY,AADA,SAAS,GACH,EACpB,CACF,EACA,iBAEH,CACH,CAEA,SAAS,IAEP,OAAO,EACL,EACA,CACE,KAAM,OACN,QALW,AAAA,CAAA,EAAA,EAAA,WAAU,AAAV,EAAY,AAAC,GAAU,EAAM,MAAM,CAMhD,EACA,UAEJ,CAEO,SAAS,EAAS,CAAA,SAAE,CAAQ,CAAA,MAAE,CAAK,CAAE,GAAG,EAAM,EACnD,OAAO,EACL,EACA,CACE,YAAa,CAAA,EACb,GAAG,CAAI,AACT,EACA,EAEJ,CAIO,SAAS,EAAgB,CAAS,EACvC,IAAI,EAAuB,EAAE,CAC7B,IAAK,IAAM,KAAO,EAAW,CAE3B,GAAgB,MAAZ,EAAI,IAAI,EACR,AAAY,MAAZ,EAAI,IAAI,CADU,SAEtB,GAAM,CAAC,EAAY,EAAS,CAAG,EAAI,IAAI,CACvC,IAAK,IAAI,EAAI,EAAY,GAAK,EAAU,IACtC,EAAW,IAAI,CAAC,EAEpB,CACA,OAAO,CACT,Q,K,gB,C,K,S,C,K,e,C,K,Q,C,K,kB,C,K,I","sources":["<anon>","packages/data-sheet/src/core.ts"],"sourcesContent":["import \"./data-sheet.86550c41.js\";\nimport \"./data-sheet.f0223f39.js\";\nimport \"./data-sheet.52753d1d.js\";\nimport {HotkeysProvider as $oH60h$HotkeysProvider, ButtonGroup as $oH60h$ButtonGroup, Button as $oH60h$Button, Intent as $oH60h$Intent, InputGroup as $oH60h$InputGroup} from \"@blueprintjs/core\";\nimport {Table2 as $oH60h$Table2, RowHeaderCell as $oH60h$RowHeaderCell, Column as $oH60h$Column, Cell as $963b78d65282413b$import$5573889ca4ff9ca2$f6f0c3fe4ec306ea} from \"@blueprintjs/table\";\nimport \"@blueprintjs/table/lib/css/table.css\";\nimport $oH60h$macrostrathyper from \"@macrostrat/hyper\";\nimport $oH60h$immutabilityhelper from \"immutability-helper\";\nimport {useMemo as $oH60h$useMemo, useCallback as $oH60h$useCallback, useEffect as $oH60h$useEffect, useState as $oH60h$useState} from \"react\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\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;\nvar $963b78d65282413b$exports = {};\n\n$parcel$export($963b78d65282413b$exports, \"DataSheetDensity\", () => $963b78d65282413b$export$b556effaa3ad7d4a);\n$parcel$export($963b78d65282413b$exports, \"DataSheet\", () => $963b78d65282413b$export$dea56b0125f0282d);\n$parcel$export($963b78d65282413b$exports, \"getRowsToDelete\", () => $963b78d65282413b$export$222fa1b971ddc36);\n$parcel$export($963b78d65282413b$exports, \"BaseCell\", () => $963b78d65282413b$export$41ad0bbfa4755cac);\n$parcel$export($963b78d65282413b$exports, \"ScrollToRowControl\", () => $963b78d65282413b$export$e7db3202e96fc463);\n$parcel$export($963b78d65282413b$exports, \"Cell\", () => $963b78d65282413b$import$5573889ca4ff9ca2$f6f0c3fe4ec306ea);\n\n\n\n\n\n\n\nvar $gZfn5 = parcelRequire(\"gZfn5\");\n\nvar $kwt8s = parcelRequire(\"kwt8s\");\n\nvar $kib2Q = parcelRequire(\"kib2Q\");\nconst $963b78d65282413b$var$h = (0, $oH60h$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($kwt8s))));\nvar $963b78d65282413b$export$b556effaa3ad7d4a = /*#__PURE__*/ function(DataSheetDensity) {\n DataSheetDensity[\"HIGH\"] = \"high\";\n DataSheetDensity[\"MEDIUM\"] = \"medium\";\n DataSheetDensity[\"LOW\"] = \"low\";\n return DataSheetDensity;\n}({});\nfunction $963b78d65282413b$export$dea56b0125f0282d(props) {\n const { data: data, columnSpec: columnSpec, columnSpecOptions: columnSpecOptions, editable: editable = true, enableColumnReordering: enableColumnReordering = false, enableFocusedCell: enableFocusedCell = false, ...rest } = props;\n return $963b78d65282413b$var$h((0, $oH60h$HotkeysProvider), $963b78d65282413b$var$h((0, $kib2Q.DataSheetProvider), {\n data: data,\n columnSpec: columnSpec,\n columnSpecOptions: columnSpecOptions,\n enableColumnReordering: enableColumnReordering,\n editable: editable,\n ...rest\n }, $963b78d65282413b$var$h($963b78d65282413b$var$_DataSheet, {\n ...rest,\n editable: editable,\n enableColumnReordering: enableColumnReordering,\n enableFocusedCell: enableFocusedCell\n })));\n}\nfunction $963b78d65282413b$var$_DataSheet({ onVisibleCellsChange: onVisibleCellsChange, enableColumnReordering: enableColumnReordering, onSaveData: onSaveData, onUpdateData: onUpdateData, onDeleteRows: onDeleteRows, verbose: verbose = false, dataSheetActions: dataSheetActions = null, enableFocusedCell: enableFocusedCell, autoFocusEditor: autoFocusEditor = true, density: density = \"high\" }) {\n /**\n * @param data: The data to be displayed in the table\n * @param columnSpec: The specification for all columns in the table. If not provided, the column spec will be generated from the data.\n * @param columnSpecOptions: Options for generating a column spec from data\n */ // For now, we only consider a single cell \"focused\" when we have one cell selected.\n // Multi-cell selections have a different set of \"bulk\" actions.\n const selection = (0, $kib2Q.useSelector)((state)=>state.selection);\n const data = (0, $kib2Q.useSelector)((state)=>state.data);\n const editable = (0, $kib2Q.useSelector)((state)=>state.editable);\n const deletedRows = (0, $kib2Q.useSelector)((state)=>state.deletedRows);\n const focusedCell = (0, $kib2Q.useSelector)((state)=>state.focusedCell);\n const ref = (0, $kib2Q.useSelector)((state)=>state.tableRef);\n const columnSpec = (0, $kib2Q.useSelector)((state)=>state.columnSpec);\n // A sparse array to hold updates\n // TODO: create a \"changeset\" concept to facilitate undo/redo\n const updatedData = (0, $kib2Q.useSelector)((state)=>state.updatedData);\n const setUpdatedData = (0, $kib2Q.useSelector)((state)=>state.setUpdatedData);\n const onSelection = (0, $kib2Q.useSelector)((state)=>state.onSelection);\n const storeAPI = (0, $kib2Q.useStoreAPI)();\n const _onSaveData = (0, $oH60h$useMemo)(()=>{\n if (onSaveData == null) return null;\n return ()=>{\n onSaveData(updatedData, data);\n setUpdatedData([]);\n };\n }, [\n updatedData,\n data,\n onSaveData\n ]);\n const setVisibleCells = (0, $kib2Q.useSelector)((state)=>state.setVisibleCells);\n const _onVisibleCellsChange = (0, $oH60h$useCallback)((visibleCells)=>{\n setVisibleCells(visibleCells);\n onVisibleCellsChange?.(visibleCells);\n }, [\n onVisibleCellsChange,\n setVisibleCells\n ]);\n const onAddRow = (0, $oH60h$useCallback)(()=>{\n setUpdatedData((updatedData)=>{\n const ix = Math.max(updatedData.length, data.length);\n const addRowSpec = {\n [ix]: {\n $set: {}\n }\n };\n const newUpdatedData = (0, $oH60h$immutabilityhelper)(updatedData, addRowSpec);\n return newUpdatedData;\n });\n }, [\n setUpdatedData\n ]);\n const deleteSelectedRows = (0, $kib2Q.useSelector)((state)=>state.deleteSelectedRows);\n const _onDeleteRows = (0, $oH60h$useCallback)(()=>{\n deleteSelectedRows();\n onDeleteRows?.(selection);\n }, [\n onDeleteRows,\n selection,\n deleteSelectedRows\n ]);\n (0, $oH60h$useEffect)(()=>{\n if (!verbose) return;\n console.log(\"Updated data\", updatedData);\n }, [\n updatedData\n ]);\n (0, $oH60h$useEffect)(()=>{\n onUpdateData?.(updatedData, data);\n }, [\n onUpdateData,\n data,\n updatedData\n ]);\n (0, $oH60h$useEffect)(()=>{\n if (!verbose) return;\n console.log(\"Selection\", selection);\n }, [\n selection\n ]);\n if (data == null) return null;\n const nDeletionCandidates = $963b78d65282413b$export$222fa1b971ddc36(selection).length;\n const numRows = Math.max(updatedData.length, data.length);\n let className = `${density}-density`;\n let rowHeight = 20;\n let defaultColumnWidth = 150;\n let style = {\n \"--data-sheet-row-height\": \"20px\",\n \"--data-sheet-font-size\": \"12px\"\n };\n if (density === \"medium\") {\n rowHeight = 24;\n style = {\n \"--data-sheet-row-height\": \"24px\",\n \"--data-sheet-font-size\": \"14px\"\n };\n } else if (density === \"low\") {\n rowHeight = 30;\n style = {\n \"--data-sheet-row-height\": \"30px\",\n \"--data-sheet-font-size\": \"18px\"\n };\n }\n return $963b78d65282413b$var$h(\"div.data-sheet-container\", {\n className: className,\n style: style\n }, [\n $963b78d65282413b$var$h.if(editable)($963b78d65282413b$var$DataSheetEditToolbar, {\n onSaveData: _onSaveData,\n onAddRow: onAddRow,\n onDeleteRows: nDeletionCandidates > 0 ? _onDeleteRows : null\n }),\n dataSheetActions,\n $963b78d65282413b$var$h(\"div.data-sheet-holder\", {\n onKeyDown (e) {\n // General key event\n if (e.key === \"Escape\") {\n // Clear selection on Escape\n storeAPI.getState().setSelection([]);\n e.preventDefault();\n }\n // Clear selection on Backspace or Delete\n if (e.key === \"Backspace\" || e.key === \"Delete\") {\n // Clear selection on Backspace or Delete\n storeAPI.getState().clearSelection();\n e.preventDefault();\n }\n // Handle arrow keys for navigation\n if (e.key.startsWith(\"Arrow\")) {\n // Handle arrow key navigation\n const direction = e.key.replace(\"Arrow\", \"\").toLowerCase();\n const state = storeAPI.getState();\n state.moveFocusedCell(direction);\n // Prevent default scrolling behavior\n e.preventDefault();\n }\n }\n }, [\n $963b78d65282413b$var$h((0, $oH60h$Table2), {\n ref: ref,\n numRows: numRows,\n className: \"data-sheet\",\n enableFocusedCell: enableFocusedCell,\n enableColumnReordering: enableColumnReordering,\n focusedCell: //onColumnsReordered,\n focusedCell,\n selectedRegions: selection,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths: columnSpec.map((col)=>col.width ?? defaultColumnWidth),\n onSelection: onSelection,\n // The cell renderer is memoized internally based on these data dependencies\n cellRendererDependencies: [\n data,\n selection,\n updatedData,\n focusedCell,\n deletedRows\n ],\n onVisibleCellsChange: _onVisibleCellsChange,\n rowHeaderCellRenderer: (rowIndex)=>{\n let style = null;\n let intent = undefined;\n if (deletedRows.has(rowIndex)) style = {\n opacity: 0.5,\n textDecoration: \"line-through\"\n };\n return $963b78d65282413b$var$h((0, $oH60h$RowHeaderCell), {\n index: rowIndex,\n name: `${rowIndex + 1}`,\n style: style\n });\n }\n }, columnSpec.map((col, colIndex)=>{\n return $963b78d65282413b$var$h((0, $oH60h$Column), {\n name: col.name,\n cellRenderer: (rowIndex)=>{\n const state = storeAPI.getState();\n return $963b78d65282413b$var$basicCellRenderer(rowIndex, colIndex, col, state, autoFocusEditor);\n }\n });\n }))\n ])\n ]);\n}\nfunction $963b78d65282413b$var$basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEditor = true) {\n const data = state.data;\n const updatedData = state.updatedData;\n const isDeleted = state.deletedRows.has(rowIndex);\n const row = data[rowIndex] ?? updatedData[rowIndex];\n const loading = row == null;\n const col = columnSpec;\n const focusedCell = state.focusedCell;\n const _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n const clearSelection = state.clearSelection;\n const value = updatedData[rowIndex]?.[col.key] ?? data[rowIndex]?.[col.key];\n const _renderedValue = col.valueRenderer?.(value) ?? value;\n let cellContents = _renderedValue;\n const editable = (col.editable ?? state.editable) && !isDeleted;\n let style = col.style ?? {};\n if (isDeleted) style = {\n ...style,\n opacity: 0.5,\n textDecoration: \"line-through\"\n };\n const focused = focusedCell?.col === colIndex && focusedCell?.row === rowIndex;\n // Top left cell of a ranged selection\n const topLeft = _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;\n if (!editable && state.editable) // If the cell is not editable but the sheet is editable, we want to differentiate\n // between editable and non-editable cells.\n style.color = \"var(--secondary-color)\";\n const edited = updatedData[rowIndex]?.[col.key] != null;\n let intent = edited ? \"success\" : undefined;\n if (isDeleted) intent = \"danger\";\n const _Cell = col.cellComponent ?? $963b78d65282413b$export$41ad0bbfa4755cac;\n let inlineEditor = editable ? col.inlineEditor ?? true : false;\n if (!topLeft) // This should be the case for every cell except the focused one\n return $963b78d65282413b$var$h(_Cell, {\n intent: intent,\n loading: loading,\n value: value,\n style: style,\n isDeleted: isDeleted\n }, cellContents);\n // The rest is for the top-left cell of a selection or the focused cell\n if (!editable) {\n // Most cells are not focused and don't need to be editable.\n // This will be the rendering logic for almost all cells\n if (col.dataEditor != null) cellContents = $963b78d65282413b$var$h((0, $gZfn5.EditorPopup), {\n autoFocus: autoFocusEditor,\n content: $963b78d65282413b$var$h(col.dataEditor, {\n value: value\n }),\n valueViewer: _renderedValue\n });\n return $963b78d65282413b$var$h(_Cell, {\n intent: intent,\n value: value,\n style: style\n }, [\n $963b78d65282413b$var$h.if(!focused)(\"input.hidden-input\", {\n autoFocus: true,\n onKeyDown (e) {\n if (e.key == \"Backspace\" || e.key == \"Delete\") clearSelection();\n e.preventDefault();\n }\n }),\n cellContents\n ]);\n // Could probably put the hidden input elsewhere,\n }\n /* The remaining logic covers cells that are focused and editable */ const onChange = (e)=>{\n if (!editable) return;\n if (value === e.target.value) return;\n onCellEdited(rowIndex, col.key, e.target.value);\n };\n let _inlineEditor = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (typeof _renderedValue === \"string\" || typeof _renderedValue === \"number\" || _renderedValue == null) _value = _renderedValue;\n _inlineEditor = $963b78d65282413b$var$h(\"input.main-editor\", {\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange: onChange,\n onKeyDown (e) {\n console.log(\"Key down in inline editor\", e.key);\n if (e.key == \"Enter\") e.target.blur();\n if (e.key == \"Escape\") {\n e.target.blur();\n e.preventDefault();\n return;\n }\n const shouldPropagate = (0, $gZfn5.handleSpecialKeys)(e, e.target);\n if (!shouldPropagate) e.stopPropagation();\n else e.target.blur();\n }\n });\n } else // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor;\n let className = null;\n if (col.dataEditor != null) {\n className = \"editor-cell\";\n cellContents = $963b78d65282413b$var$h([\n $963b78d65282413b$var$h((0, $gZfn5.EditorPopup), {\n autoFocus: autoFocusEditor,\n content: $963b78d65282413b$var$h(col.dataEditor, {\n value: value,\n onChange (value) {\n if (!editable) return;\n onCellEdited(rowIndex, col.key, value);\n }\n }),\n valueViewer: _renderedValue\n })\n ]);\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n }\n const isSingleCellSelection = (0, $kib2Q.singleFocusedCell)(state.selection) != null;\n // Hidden html input\n return $963b78d65282413b$var$h(_Cell, {\n intent: intent,\n value: value,\n className: className,\n style: style\n }, [\n cellContents,\n $963b78d65282413b$var$h.if(editable && isSingleCellSelection)($963b78d65282413b$var$DragHandle, {\n focusedCell: focusedCell\n })\n ]);\n}\nfunction $963b78d65282413b$var$DragHandle({ focusedCell: focusedCell }) {\n // TODO: we might want to drag multiple columns in some cases\n // This should be on the last cell of a selection\n const onDragValue = (0, $kib2Q.useSelector)((state)=>state.onDragValue);\n return $963b78d65282413b$var$h(\"div.corner-drag-handle\", {\n onMouseDown (e) {\n onDragValue(focusedCell);\n e.preventDefault();\n }\n });\n}\nfunction $963b78d65282413b$var$DataSheetEditToolbar({ onSaveData: onSaveData, onDeleteRows: onDeleteRows }) {\n const selection = (0, $kib2Q.useSelector)((state)=>state.selection);\n const resetChanges = (0, $kib2Q.useSelector)((state)=>state.resetChanges);\n const hasUpdates = (0, $kib2Q.useSelector)((state)=>state.hasUpdates);\n return $963b78d65282413b$var$h(\"div.data-sheet-toolbar\", [\n $963b78d65282413b$var$h((0, $oH60h$ButtonGroup), {\n minimal: true\n }, [\n $963b78d65282413b$var$h($963b78d65282413b$var$AddRowButton),\n $963b78d65282413b$var$h((0, $oH60h$Button), {\n intent: (0, $oH60h$Intent).DANGER,\n disabled: onDeleteRows == null,\n onClick () {\n onDeleteRows?.();\n }\n }, \"Delete\")\n ]),\n $963b78d65282413b$var$h(\"div.spacer\"),\n $963b78d65282413b$var$h((0, $oH60h$ButtonGroup), [\n $963b78d65282413b$var$h((0, $oH60h$Button), {\n intent: (0, $oH60h$Intent).WARNING,\n disabled: !hasUpdates,\n onClick: resetChanges\n }, \"Reset\"),\n $963b78d65282413b$var$h.if(onSaveData != null)((0, $oH60h$Button), {\n intent: (0, $oH60h$Intent).SUCCESS,\n icon: \"floppy-disk\",\n disabled: !hasUpdates,\n onClick: onSaveData\n }, \"Save\")\n ])\n ]);\n}\nfunction $963b78d65282413b$export$e7db3202e96fc463() {\n const [value, setValue] = (0, $oH60h$useState)(\"\");\n const scrollToRow = (0, $kib2Q.useSelector)((state)=>state.scrollToRow);\n return $963b78d65282413b$var$h((0, $gZfn5.DataSheetAction), [\n $963b78d65282413b$var$h((0, $oH60h$InputGroup), {\n type: \"number\",\n placeholder: \"Row number\",\n value: value,\n onValueChange (value) {\n setValue(value);\n }\n }),\n $963b78d65282413b$var$h((0, $oH60h$Button), {\n icon: \"arrow-right\",\n onClick () {\n const row = parseInt(value);\n scrollToRow(row - 1);\n }\n }, \"Scroll to row\")\n ]);\n}\nfunction $963b78d65282413b$var$AddRowButton() {\n const addRow = (0, $kib2Q.useSelector)((state)=>state.addRow);\n return $963b78d65282413b$var$h((0, $oH60h$Button), {\n icon: \"plus\",\n onClick: addRow\n }, \"Add row\");\n}\nfunction $963b78d65282413b$export$41ad0bbfa4755cac({ children: children, value: value, ...rest }) {\n return $963b78d65282413b$var$h((0, $963b78d65282413b$import$5573889ca4ff9ca2$f6f0c3fe4ec306ea), {\n interactive: true,\n ...rest\n }, children);\n}\nfunction $963b78d65282413b$export$222fa1b971ddc36(selection) {\n let rowIndices = [];\n for (const sel of selection){\n // This isn't a full-row selection\n if (sel.cols != null) continue;\n if (sel.rows == null) continue;\n const [startIndex, endIndex] = sel.rows;\n for(let i = startIndex; i <= endIndex; i++)rowIndices.push(i);\n }\n return rowIndices;\n}\n\n\nexport {$963b78d65282413b$export$b556effaa3ad7d4a as DataSheetDensity, $963b78d65282413b$export$dea56b0125f0282d as DataSheet, $963b78d65282413b$export$222fa1b971ddc36 as getRowsToDelete, $963b78d65282413b$export$41ad0bbfa4755cac as BaseCell, $963b78d65282413b$export$e7db3202e96fc463 as ScrollToRowControl, $963b78d65282413b$import$5573889ca4ff9ca2$f6f0c3fe4ec306ea as Cell};\n//# sourceMappingURL=data-sheet.820e5bc3.js.map\n","import {\n Button,\n ButtonGroup,\n HotkeysProvider,\n InputGroup,\n Intent,\n} from \"@blueprintjs/core\";\nimport {\n Cell,\n Column,\n Region,\n RowHeaderCell,\n Table2,\n} from \"@blueprintjs/table\";\nimport \"@blueprintjs/table/lib/css/table.css\";\nimport hyper from \"@macrostrat/hyper\";\nimport update from \"immutability-helper\";\nimport { ReactNode, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { EditorPopup, handleSpecialKeys, DataSheetAction } from \"./components\";\nimport styles from \"./main.module.sass\";\nimport {\n ColumnSpec,\n DataSheetProvider,\n DataSheetProviderProps,\n DataSheetStore,\n singleFocusedCell,\n useSelector,\n useStoreAPI,\n VisibleCells,\n} from \"./provider\";\n\nconst h = hyper.styled(styles);\n\n// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args\n\n// TODO: add a \"copy to selection\" tool (the little square in the bottom right corner of a cell)\n// This should copy the value of a cell (or a set of cells in the same row) downwards.\n\nexport enum DataSheetDensity {\n HIGH = \"high\",\n MEDIUM = \"medium\",\n LOW = \"low\",\n}\n\ninterface DataSheetInternalProps<T> {\n onVisibleCellsChange?: (visibleCells: VisibleCells) => void;\n onSaveData?: (updatedData: any[], data: T[]) => void;\n onUpdateData?: (updatedData: any[], data: T[]) => void;\n onDeleteRows?: (selection: Region[]) => void;\n verbose?: boolean;\n enableColumnReordering?: boolean;\n enableFocusedCell?: boolean;\n dataSheetActions?: ReactNode | null;\n editable?: boolean;\n autoFocusEditor?: boolean;\n density?: DataSheetDensity;\n}\n\ntype DataSheetProps<T> = DataSheetProviderProps<T> & DataSheetInternalProps<T>;\n\nexport function DataSheet<T>(props: DataSheetProps<T>) {\n const {\n data,\n columnSpec,\n columnSpecOptions,\n editable = true,\n enableColumnReordering = false,\n enableFocusedCell = false,\n ...rest\n } = props;\n\n return h(\n HotkeysProvider,\n h(\n DataSheetProvider<T>,\n {\n data,\n columnSpec,\n columnSpecOptions: columnSpecOptions,\n enableColumnReordering,\n editable,\n ...rest,\n },\n h(_DataSheet, {\n ...rest,\n editable,\n enableColumnReordering,\n enableFocusedCell,\n }),\n ),\n );\n}\n\nfunction _DataSheet<T>({\n onVisibleCellsChange,\n enableColumnReordering,\n onSaveData,\n onUpdateData,\n onDeleteRows,\n verbose = false,\n dataSheetActions = null,\n enableFocusedCell,\n autoFocusEditor = true,\n density = DataSheetDensity.HIGH,\n}: DataSheetInternalProps<T>) {\n /**\n * @param data: The data to be displayed in the table\n * @param columnSpec: The specification for all columns in the table. If not provided, the column spec will be generated from the data.\n * @param columnSpecOptions: Options for generating a column spec from data\n */\n\n // For now, we only consider a single cell \"focused\" when we have one cell selected.\n // Multi-cell selections have a different set of \"bulk\" actions.\n const selection = useSelector<T>((state) => state.selection);\n\n const data = useSelector((state) => state.data);\n const editable = useSelector((state) => state.editable);\n\n const deletedRows = useSelector((state) => state.deletedRows);\n\n const focusedCell = useSelector((state) => state.focusedCell);\n\n const ref = useSelector((state) => state.tableRef);\n\n const columnSpec = useSelector((state) => state.columnSpec);\n\n // A sparse array to hold updates\n // TODO: create a \"changeset\" concept to facilitate undo/redo\n const updatedData = useSelector((state) => state.updatedData);\n const setUpdatedData = useSelector((state) => state.setUpdatedData);\n\n const onSelection = useSelector((state) => state.onSelection);\n\n const storeAPI = useStoreAPI<T>();\n\n const _onSaveData = useMemo(() => {\n if (onSaveData == null) return null;\n return () => {\n onSaveData(updatedData, data);\n setUpdatedData([]);\n };\n }, [updatedData, data, onSaveData]);\n\n const setVisibleCells = useSelector((state) => state.setVisibleCells);\n\n const _onVisibleCellsChange = useCallback(\n (visibleCells: VisibleCells) => {\n setVisibleCells(visibleCells);\n onVisibleCellsChange?.(visibleCells);\n },\n [onVisibleCellsChange, setVisibleCells],\n );\n\n const onAddRow = useCallback(() => {\n setUpdatedData((updatedData: any[]): any[] => {\n const ix = Math.max(updatedData.length, data.length);\n const addRowSpec = { [ix]: { $set: {} } };\n const newUpdatedData = update(updatedData, addRowSpec);\n return newUpdatedData;\n });\n }, [setUpdatedData]);\n\n const deleteSelectedRows = useSelector((state) => state.deleteSelectedRows);\n const _onDeleteRows = useCallback(() => {\n deleteSelectedRows();\n onDeleteRows?.(selection);\n }, [onDeleteRows, selection, deleteSelectedRows]);\n\n useEffect(() => {\n if (!verbose) return;\n console.log(\"Updated data\", updatedData);\n }, [updatedData]);\n\n useEffect(() => {\n onUpdateData?.(updatedData, data);\n }, [onUpdateData, data, updatedData]);\n\n useEffect(() => {\n if (!verbose) return;\n console.log(\"Selection\", selection);\n }, [selection]);\n\n if (data == null) return null;\n\n const nDeletionCandidates = getRowsToDelete(selection).length;\n\n const numRows = Math.max(updatedData.length, data.length);\n\n let className = `${density}-density`;\n\n let rowHeight = 20;\n let defaultColumnWidth = 150;\n let style = {\n \"--data-sheet-row-height\": \"20px\",\n \"--data-sheet-font-size\": \"12px\",\n };\n if (density === DataSheetDensity.MEDIUM) {\n rowHeight = 24;\n style = {\n \"--data-sheet-row-height\": \"24px\",\n \"--data-sheet-font-size\": \"14px\",\n };\n } else if (density === DataSheetDensity.LOW) {\n rowHeight = 30;\n style = {\n \"--data-sheet-row-height\": \"30px\",\n \"--data-sheet-font-size\": \"18px\",\n };\n }\n\n return h(\"div.data-sheet-container\", { className, style }, [\n h.if(editable)(DataSheetEditToolbar, {\n onSaveData: _onSaveData,\n onAddRow,\n onDeleteRows: nDeletionCandidates > 0 ? _onDeleteRows : null,\n }),\n dataSheetActions,\n h(\n \"div.data-sheet-holder\",\n {\n onKeyDown(e) {\n // General key event\n if (e.key === \"Escape\") {\n // Clear selection on Escape\n storeAPI.getState().setSelection([]);\n e.preventDefault();\n }\n // Clear selection on Backspace or Delete\n if (e.key === \"Backspace\" || e.key === \"Delete\") {\n // Clear selection on Backspace or Delete\n storeAPI.getState().clearSelection();\n e.preventDefault();\n }\n // Handle arrow keys for navigation\n if (e.key.startsWith(\"Arrow\")) {\n // Handle arrow key navigation\n const direction = e.key.replace(\"Arrow\", \"\").toLowerCase();\n const state = storeAPI.getState();\n state.moveFocusedCell(direction);\n // Prevent default scrolling behavior\n e.preventDefault();\n }\n },\n },\n [\n h(\n Table2,\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n enableColumnReordering,\n //onColumnsReordered,\n focusedCell,\n selectedRegions: selection,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths: columnSpec.map(\n (col) => col.width ?? defaultColumnWidth,\n ),\n onSelection,\n // The cell renderer is memoized internally based on these data dependencies\n cellRendererDependencies: [\n data,\n selection,\n updatedData,\n focusedCell,\n deletedRows,\n ],\n onVisibleCellsChange: _onVisibleCellsChange,\n rowHeaderCellRenderer: (rowIndex) => {\n let style = null;\n let intent = undefined;\n if (deletedRows.has(rowIndex)) {\n style = {\n opacity: 0.5,\n textDecoration: \"line-through\",\n };\n }\n return h(RowHeaderCell, {\n index: rowIndex,\n name: `${rowIndex + 1}`,\n style,\n });\n },\n },\n columnSpec.map((col, colIndex) => {\n return h(Column, {\n name: col.name,\n cellRenderer: (rowIndex) => {\n const state = storeAPI.getState();\n return basicCellRenderer<T>(\n rowIndex,\n colIndex,\n col,\n state,\n autoFocusEditor,\n );\n },\n });\n }),\n ),\n ],\n ),\n ]);\n}\n\nfunction basicCellRenderer<T>(\n rowIndex: number,\n colIndex: number,\n columnSpec: ColumnSpec,\n state: DataSheetStore<T>,\n autoFocusEditor = true,\n): any {\n const data = state.data;\n const updatedData = state.updatedData;\n\n const isDeleted = state.deletedRows.has(rowIndex);\n\n const row = data[rowIndex] ?? updatedData[rowIndex];\n const loading = row == null;\n const col = columnSpec;\n\n const focusedCell = state.focusedCell;\n const _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n const clearSelection = state.clearSelection;\n\n const value = updatedData[rowIndex]?.[col.key] ?? data[rowIndex]?.[col.key];\n const _renderedValue = col.valueRenderer?.(value) ?? value;\n let cellContents: ReactNode = _renderedValue;\n const editable = (col.editable ?? state.editable) && !isDeleted;\n\n let style = col.style ?? {};\n if (isDeleted) {\n style = {\n ...style,\n opacity: 0.5,\n textDecoration: \"line-through\",\n };\n }\n\n const focused =\n focusedCell?.col === colIndex && focusedCell?.row === rowIndex;\n // Top left cell of a ranged selection\n const topLeft =\n _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;\n\n if (!editable && state.editable) {\n // If the cell is not editable but the sheet is editable, we want to differentiate\n // between editable and non-editable cells.\n style.color = \"var(--secondary-color)\";\n }\n\n const edited = updatedData[rowIndex]?.[col.key] != null;\n let intent = edited ? \"success\" : undefined;\n if (isDeleted) {\n intent = \"danger\";\n }\n\n const _Cell = col.cellComponent ?? BaseCell;\n\n let inlineEditor = editable ? (col.inlineEditor ?? true) : false;\n\n if (!topLeft) {\n // This should be the case for every cell except the focused one\n return h(\n _Cell,\n {\n intent,\n loading,\n value,\n style,\n isDeleted,\n },\n cellContents,\n );\n }\n\n // The rest is for the top-left cell of a selection or the focused cell\n\n if (!editable) {\n // Most cells are not focused and don't need to be editable.\n // This will be the rendering logic for almost all cells\n\n if (col.dataEditor != null) {\n cellContents = h(EditorPopup, {\n autoFocus: autoFocusEditor,\n content: h(col.dataEditor, {\n value,\n }),\n valueViewer: _renderedValue,\n });\n }\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n },\n [\n h.if(!focused)(\"input.hidden-input\", {\n autoFocus: true,\n onKeyDown(e) {\n if (e.key == \"Backspace\" || e.key == \"Delete\") {\n clearSelection();\n }\n e.preventDefault();\n },\n }),\n cellContents,\n ],\n );\n // Could probably put the hidden input elsewhere,\n }\n\n /* The remaining logic covers cells that are focused and editable */\n\n const onChange = (e) => {\n if (!editable) return;\n if (value === e.target.value) return;\n onCellEdited(rowIndex, col.key, e.target.value);\n };\n\n let _inlineEditor: ReactNode = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (\n typeof _renderedValue === \"string\" ||\n typeof _renderedValue === \"number\" ||\n _renderedValue == null\n ) {\n _value = _renderedValue;\n }\n _inlineEditor = h(\"input.main-editor\", {\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange,\n onKeyDown(e) {\n console.log(\"Key down in inline editor\", e.key);\n if (e.key == \"Enter\") {\n e.target.blur();\n }\n\n if (e.key == \"Escape\") {\n e.target.blur();\n e.preventDefault();\n return;\n }\n\n const shouldPropagate = handleSpecialKeys(e, e.target);\n if (!shouldPropagate) {\n e.stopPropagation();\n } else {\n e.target.blur();\n //e.target.parentNode.dispatchEvent(new KeyboardEvent(\"keydown\", e));\n }\n },\n });\n } else {\n // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor as ReactNode;\n }\n\n let className = null;\n\n if (col.dataEditor != null) {\n className = \"editor-cell\";\n cellContents = h([\n h(EditorPopup, {\n autoFocus: autoFocusEditor,\n content: h(col.dataEditor, {\n value,\n onChange(value) {\n if (!editable) return;\n onCellEdited(rowIndex, col.key, value);\n },\n }),\n valueViewer: _renderedValue,\n }),\n ]);\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n }\n\n const isSingleCellSelection = singleFocusedCell(state.selection) != null;\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle, {\n focusedCell,\n }),\n ],\n );\n}\n\nfunction DragHandle({ focusedCell }) {\n // TODO: we might want to drag multiple columns in some cases\n // This should be on the last cell of a selection\n const onDragValue = useSelector((state) => state.onDragValue);\n\n return h(\"div.corner-drag-handle\", {\n onMouseDown(e) {\n onDragValue(focusedCell);\n e.preventDefault();\n },\n });\n}\n\nfunction DataSheetEditToolbar({ onSaveData, onDeleteRows }) {\n const selection = useSelector((state) => state.selection);\n const resetChanges = useSelector((state) => state.resetChanges);\n const hasUpdates = useSelector((state) => state.hasUpdates);\n\n return h(\"div.data-sheet-toolbar\", [\n h(ButtonGroup, { minimal: true }, [\n h(AddRowButton),\n h(\n Button,\n {\n intent: Intent.DANGER,\n disabled: onDeleteRows == null,\n onClick() {\n onDeleteRows?.();\n },\n },\n \"Delete\",\n ),\n ]),\n h(\"div.spacer\"),\n h(ButtonGroup, [\n h(\n Button,\n {\n intent: Intent.WARNING,\n disabled: !hasUpdates,\n onClick: resetChanges,\n },\n \"Reset\",\n ),\n h.if(onSaveData != null)(\n Button,\n {\n intent: Intent.SUCCESS,\n icon: \"floppy-disk\",\n disabled: !hasUpdates,\n onClick: onSaveData,\n },\n \"Save\",\n ),\n ]),\n ]);\n}\n\nexport function ScrollToRowControl() {\n const [value, setValue] = useState(\"\");\n const scrollToRow = useSelector((state) => state.scrollToRow);\n\n return h(DataSheetAction, [\n h(InputGroup, {\n type: \"number\",\n placeholder: \"Row number\",\n value,\n onValueChange(value) {\n setValue(value);\n },\n }),\n h(\n Button,\n {\n icon: \"arrow-right\",\n onClick() {\n const row = parseInt(value);\n scrollToRow(row - 1);\n },\n },\n \"Scroll to row\",\n ),\n ]);\n}\n\nfunction AddRowButton() {\n const addRow = useSelector((state) => state.addRow);\n return h(\n Button,\n {\n icon: \"plus\",\n onClick: addRow,\n },\n \"Add row\",\n );\n}\n\nexport function BaseCell({ children, value, ...rest }) {\n return h(\n Cell,\n {\n interactive: true,\n ...rest,\n },\n children,\n );\n}\n\nexport { Cell };\n\nexport function getRowsToDelete(selection) {\n let rowIndices: number[] = [];\n for (const sel of selection) {\n // This isn't a full-row selection\n if (sel.cols != null) continue;\n if (sel.rows == null) continue;\n const [startIndex, endIndex] = sel.rows;\n for (let i = startIndex; i <= endIndex; i++) {\n rowIndices.push(i);\n }\n }\n return rowIndices;\n}\n"],"names":["HotkeysProvider","$oH60h$HotkeysProvider","ButtonGroup","$oH60h$ButtonGroup","Button","$oH60h$Button","Intent","$oH60h$Intent","InputGroup","$oH60h$InputGroup","Table2","$oH60h$Table2","RowHeaderCell","$oH60h$RowHeaderCell","Column","$oH60h$Column","Cell","$963b78d65282413b$import$5573889ca4ff9ca2$f6f0c3fe4ec306ea","$oH60h$macrostrathyper","$oH60h$immutabilityhelper","useMemo","$oH60h$useMemo","useCallback","$oH60h$useCallback","useEffect","$oH60h$useEffect","useState","$oH60h$useState","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","DataSheetDensity","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$963b78d65282413b$exports","$963b78d65282413b$export$b556effaa3ad7d4a","$963b78d65282413b$export$dea56b0125f0282d","$963b78d65282413b$export$222fa1b971ddc36","$963b78d65282413b$export$41ad0bbfa4755cac","$963b78d65282413b$export$e7db3202e96fc463","$gZfn5","$kwt8s","$kib2Q","$963b78d65282413b$var$h","styled","a","__esModule","default","props","data","columnSpec","columnSpecOptions","editable","enableColumnReordering","enableFocusedCell","rest","DataSheetProvider","$963b78d65282413b$var$_DataSheet","onVisibleCellsChange","onSaveData","onUpdateData","onDeleteRows","verbose","dataSheetActions","autoFocusEditor","density","selection","useSelector","state","deletedRows","focusedCell","ref","tableRef","updatedData","setUpdatedData","onSelection","storeAPI","useStoreAPI","_onSaveData","setVisibleCells","_onVisibleCellsChange","visibleCells","onAddRow","ix","Math","max","length","$set","deleteSelectedRows","_onDeleteRows","console","log","nDeletionCandidates","numRows","className","rowHeight","style","if","$963b78d65282413b$var$DataSheetEditToolbar","onKeyDown","key","getState","setSelection","preventDefault","clearSelection","startsWith","direction","replace","toLowerCase","moveFocusedCell","selectedRegions","defaultRowHeight","minRowHeight","columnWidths","map","col","width","cellRendererDependencies","rowHeaderCellRenderer","rowIndex","has","opacity","textDecoration","index","name","colIndex","cellRenderer","$963b78d65282413b$var$basicCellRenderer","isDeleted","row","_topLeftCell","topLeftCell","onCellEdited","value","_renderedValue","valueRenderer","cellContents","focused","topLeft","color","intent","edited","undefined","_Cell","cellComponent","inlineEditor","loading","dataEditor","EditorPopup","autoFocus","content","valueViewer","_inlineEditor","_value","onChange","target","blur","handleSpecialKeys","stopPropagation","isSingleCellSelection","singleFocusedCell","$963b78d65282413b$var$DragHandle","onDragValue","onMouseDown","resetChanges","hasUpdates","minimal","$963b78d65282413b$var$AddRowButton","DANGER","disabled","onClick","WARNING","SUCCESS","icon","setValue","scrollToRow","DataSheetAction","type","placeholder","onValueChange","parseInt","addRow","children","interactive","rowIndices","sel","cols","rows","startIndex","endIndex","i","push","DataSheet","getRowsToDelete","BaseCell","ScrollToRowControl"],"version":3,"file":"data-sheet.820e5bc3.js.map","sourceRoot":"../../../../"}
|
package/src/__archive/base.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import ReactDataSheet from "react-datasheet";
|
|
2
|
-
import "react-datasheet/lib/react-datasheet.css";
|
|
3
|
-
import h from "@macrostrat/hyper";
|
|
4
|
-
import { forwardRef } from "react";
|
|
5
|
-
import { useDataSheet } from "./provider";
|
|
6
|
-
import { Row, Sheet } from "./components";
|
|
7
|
-
import React from "react";
|
|
8
|
-
|
|
9
|
-
interface GridElement extends ReactDataSheet.Cell<GridElement, number> {
|
|
10
|
-
value: number | null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface SheetContainerProps<T = any>
|
|
14
|
-
extends ReactDataSheet.DataSheetProps<T> {
|
|
15
|
-
height?: number;
|
|
16
|
-
width?: number;
|
|
17
|
-
children?: React.ReactNode;
|
|
18
|
-
className?: string;
|
|
19
|
-
scrollable?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const BaseSheet = forwardRef((props: SheetContainerProps, ref) => {
|
|
23
|
-
const {
|
|
24
|
-
scrollable = true,
|
|
25
|
-
height,
|
|
26
|
-
width,
|
|
27
|
-
children,
|
|
28
|
-
className,
|
|
29
|
-
...rest
|
|
30
|
-
} = props;
|
|
31
|
-
|
|
32
|
-
const { dispatch } = useDataSheet();
|
|
33
|
-
|
|
34
|
-
return h(
|
|
35
|
-
"div.data-sheet-container",
|
|
36
|
-
{ style: { height, width }, className, ref },
|
|
37
|
-
[
|
|
38
|
-
h("div.ui", { style: { height, width } }, [
|
|
39
|
-
h(ReactDataSheet, {
|
|
40
|
-
width,
|
|
41
|
-
height,
|
|
42
|
-
sheetRenderer: Sheet,
|
|
43
|
-
rowRenderer: Row,
|
|
44
|
-
onSelect(sel) {
|
|
45
|
-
dispatch({ type: "set-selection", value: sel });
|
|
46
|
-
},
|
|
47
|
-
...rest,
|
|
48
|
-
}),
|
|
49
|
-
]),
|
|
50
|
-
children,
|
|
51
|
-
],
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export { GridElement };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { sum } from "d3-array";
|
|
2
|
-
import { useDataSheet } from "../provider";
|
|
3
|
-
import { useDrop, DropTargetMonitor } from "react-dnd";
|
|
4
|
-
|
|
5
|
-
interface ColumnData {
|
|
6
|
-
name: string;
|
|
7
|
-
key: string;
|
|
8
|
-
width?: number;
|
|
9
|
-
idealWidth?: number;
|
|
10
|
-
editable?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ColumnWidthInfo {
|
|
14
|
-
key: string;
|
|
15
|
-
offset: number;
|
|
16
|
-
width: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type DragItem = {
|
|
20
|
-
type: "column";
|
|
21
|
-
id: string;
|
|
22
|
-
index: number;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/* Column width functionality */
|
|
26
|
-
function apportionWidths(
|
|
27
|
-
columns: ColumnData[],
|
|
28
|
-
desiredWidths: { [key: string]: number },
|
|
29
|
-
containerWidth: number,
|
|
30
|
-
): ColumnData[] {
|
|
31
|
-
if (columns == null || desiredWidths == null || containerWidth == null)
|
|
32
|
-
return columns;
|
|
33
|
-
|
|
34
|
-
const totalSize = sum(Object.values(desiredWidths));
|
|
35
|
-
|
|
36
|
-
//console.log(maxContentWidth);
|
|
37
|
-
|
|
38
|
-
return columns.map((col) => {
|
|
39
|
-
return {
|
|
40
|
-
...col,
|
|
41
|
-
width: (desiredWidths[col.key] / totalSize) * (containerWidth - 50),
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function useColumnDropTarget(ref, index) {
|
|
47
|
-
const { dispatch } = useDataSheet();
|
|
48
|
-
return useDrop({
|
|
49
|
-
accept: "column",
|
|
50
|
-
hover(item: DragItem, monitor: DropTargetMonitor) {
|
|
51
|
-
if (!ref.current) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const dragIndex = item.index;
|
|
55
|
-
const hoverIndex = index;
|
|
56
|
-
|
|
57
|
-
// Don't replace items with themselves
|
|
58
|
-
if (dragIndex === hoverIndex) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Determine rectangle on screen
|
|
63
|
-
const hoverBoundingRect = ref.current?.getBoundingClientRect();
|
|
64
|
-
|
|
65
|
-
// Get horizontal middle
|
|
66
|
-
const hoverMiddleX =
|
|
67
|
-
(hoverBoundingRect.right - hoverBoundingRect.left) / 2;
|
|
68
|
-
|
|
69
|
-
// Determine mouse position
|
|
70
|
-
const clientOffset = monitor.getClientOffset();
|
|
71
|
-
|
|
72
|
-
// Get pixels to the left
|
|
73
|
-
const hoverClientX = clientOffset.x - hoverBoundingRect.left;
|
|
74
|
-
|
|
75
|
-
// Only perform the move when the mouse has crossed half of the items height
|
|
76
|
-
// When dragging downwards, only move when the cursor is below 50%
|
|
77
|
-
// When dragging upwards, only move when the cursor is above 50%
|
|
78
|
-
// Dragging downwards
|
|
79
|
-
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Dragging upwards
|
|
84
|
-
if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Time to actually perform the action
|
|
89
|
-
dispatch({ type: "move-column", dragIndex, hoverIndex });
|
|
90
|
-
//moveCard(dragIndex, hoverIndex);
|
|
91
|
-
|
|
92
|
-
// Note: we're mutating the monitor item here!
|
|
93
|
-
// Generally it's better to avoid mutations,
|
|
94
|
-
// but it's good here for the sake of performance
|
|
95
|
-
// to avoid expensive index searches.
|
|
96
|
-
item.index = hoverIndex;
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function useColumnWidths(): ColumnWidthInfo[] {
|
|
102
|
-
const { columns, columnWidths, containerWidth } = useDataSheet();
|
|
103
|
-
|
|
104
|
-
let widthArray = [];
|
|
105
|
-
let offset = 50; // for index, we should probably not hard-code this...
|
|
106
|
-
for (const [i, col] of columns.entries()) {
|
|
107
|
-
let width =
|
|
108
|
-
columnWidths[col.name] ??
|
|
109
|
-
col.width ??
|
|
110
|
-
(containerWidth - 50) / columns.length;
|
|
111
|
-
if (i == columns.length - 1) {
|
|
112
|
-
// special case for last column to fill container
|
|
113
|
-
width = containerWidth - offset;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
widthArray.push({
|
|
117
|
-
key: col.name,
|
|
118
|
-
offset: offset,
|
|
119
|
-
width,
|
|
120
|
-
});
|
|
121
|
-
offset += width;
|
|
122
|
-
}
|
|
123
|
-
return widthArray;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export { ColumnData, apportionWidths, useColumnWidths, useColumnDropTarget };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { useRef, memo } from "react";
|
|
2
|
-
import { hyperStyled } from "@macrostrat/hyper";
|
|
3
|
-
import { ColumnInfo, useDataSheet } from "../provider";
|
|
4
|
-
import { useColumnDropTarget, useColumnWidths } from "./column-utils";
|
|
5
|
-
import { useDrag } from "react-dnd";
|
|
6
|
-
import Draggable from "react-draggable";
|
|
7
|
-
import styles from "../styles.module.scss";
|
|
8
|
-
|
|
9
|
-
const h = hyperStyled(styles);
|
|
10
|
-
|
|
11
|
-
function Row({ row, children, className }) {
|
|
12
|
-
const { rowHeight, rowOffset } = useDataSheet();
|
|
13
|
-
const style = { height: rowHeight };
|
|
14
|
-
return h("tr", { style, className }, [
|
|
15
|
-
h("td.index-cell.cell.read-only.index", row + rowOffset + 1),
|
|
16
|
-
children,
|
|
17
|
-
]);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function Columns() {
|
|
21
|
-
const columns = useColumnWidths();
|
|
22
|
-
return h("colgroup", [
|
|
23
|
-
h("col.index-column", { key: "index", style: { width: 50 } }),
|
|
24
|
-
columns.map(({ width, key }) => {
|
|
25
|
-
return h("col", {
|
|
26
|
-
key,
|
|
27
|
-
style: { width },
|
|
28
|
-
});
|
|
29
|
-
}),
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function ColumnResizeHandles() {
|
|
34
|
-
const { dispatch } = useDataSheet();
|
|
35
|
-
const columnWidths = useColumnWidths();
|
|
36
|
-
return h(
|
|
37
|
-
"td.column-resizers",
|
|
38
|
-
columnWidths.map((d, i) => {
|
|
39
|
-
if (i == columnWidths.length - 1) return null;
|
|
40
|
-
return h(
|
|
41
|
-
Draggable,
|
|
42
|
-
{
|
|
43
|
-
axis: "x",
|
|
44
|
-
position: { x: d.offset + d.width, y: 0 },
|
|
45
|
-
onStop(event, { x }) {
|
|
46
|
-
dispatch({
|
|
47
|
-
type: "update-column-width",
|
|
48
|
-
key: d.key,
|
|
49
|
-
value: x - d.offset,
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
h("span.cell-drag-handle", {
|
|
54
|
-
onMouseDown(e) {
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
e.stopPropagation();
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
}),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function HeaderCell({ col, index }: { col: ColumnInfo; index: number }) {
|
|
65
|
-
const ref = useRef();
|
|
66
|
-
|
|
67
|
-
const [, drop] = useColumnDropTarget(ref, index);
|
|
68
|
-
|
|
69
|
-
const [{ isDragging }, drag] = useDrag({
|
|
70
|
-
item: { id: col.name, index },
|
|
71
|
-
type: "column",
|
|
72
|
-
collect: (monitor: any) => ({
|
|
73
|
-
isDragging: monitor.isDragging(),
|
|
74
|
-
}),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const opacity = isDragging ? 0 : 1;
|
|
78
|
-
|
|
79
|
-
drag(drop(ref));
|
|
80
|
-
return h(
|
|
81
|
-
"td.cell.header.read-only.header-cell",
|
|
82
|
-
{ style: { opacity }, key: col.name },
|
|
83
|
-
[h("div.cell-content", { ref }, col.name)],
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function Header_({ width }) {
|
|
88
|
-
const style = { width };
|
|
89
|
-
const { columns } = useDataSheet();
|
|
90
|
-
|
|
91
|
-
return h("thead", { style }, [
|
|
92
|
-
h("tr.header", { style }, [
|
|
93
|
-
h("td.index-column.cell.read-only", ""),
|
|
94
|
-
columns.map((col, index) => {
|
|
95
|
-
return h(HeaderCell, { key: col.name, col, index });
|
|
96
|
-
}),
|
|
97
|
-
h(ColumnResizeHandles),
|
|
98
|
-
]),
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const Header = memo(Header_);
|
|
103
|
-
|
|
104
|
-
function Sheet({ className, children }) {
|
|
105
|
-
const { containerWidth: width } = useDataSheet();
|
|
106
|
-
return h("table", { className, style: { width } }, [
|
|
107
|
-
h(Columns),
|
|
108
|
-
h(Header, { width }),
|
|
109
|
-
h("tbody", children),
|
|
110
|
-
]);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export * from "./column-utils";
|
|
114
|
-
export * from "./toolbar";
|
|
115
|
-
export { Sheet, Row };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import h from "@macrostrat/hyper";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Dialog, Classes, Button, ButtonGroup } from "@blueprintjs/core";
|
|
4
|
-
import { SaveButton, CancelButton } from "@macrostrat/ui-components";
|
|
5
|
-
|
|
6
|
-
function SubmitDialog({
|
|
7
|
-
onClick,
|
|
8
|
-
content,
|
|
9
|
-
className = null,
|
|
10
|
-
disabled,
|
|
11
|
-
...rest
|
|
12
|
-
}) {
|
|
13
|
-
const [open, setOpen] = useState(false);
|
|
14
|
-
return h("div", null, [
|
|
15
|
-
h(
|
|
16
|
-
SaveButton,
|
|
17
|
-
{
|
|
18
|
-
disabled: disabled,
|
|
19
|
-
...rest,
|
|
20
|
-
onClick: () => setOpen(true),
|
|
21
|
-
},
|
|
22
|
-
"Save Changes",
|
|
23
|
-
),
|
|
24
|
-
h(Dialog, { isOpen: open }, [
|
|
25
|
-
h("div", { className: Classes.DIALOG_HEADER }, h("h3", null, "WARNING")),
|
|
26
|
-
h("div", { className: Classes.DIALOG_BODY }, h("p", null, content)),
|
|
27
|
-
h("div", { className: Classes.DIALOG_FOOTER }, [
|
|
28
|
-
h(
|
|
29
|
-
SaveButton,
|
|
30
|
-
{
|
|
31
|
-
className: "save-btn",
|
|
32
|
-
small: true,
|
|
33
|
-
onClick: () => {
|
|
34
|
-
onClick();
|
|
35
|
-
setOpen(false);
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
"Save changes",
|
|
39
|
-
),
|
|
40
|
-
h(
|
|
41
|
-
CancelButton,
|
|
42
|
-
{
|
|
43
|
-
small: true,
|
|
44
|
-
onClick: () => setOpen(false),
|
|
45
|
-
},
|
|
46
|
-
"Cancel",
|
|
47
|
-
),
|
|
48
|
-
]),
|
|
49
|
-
]),
|
|
50
|
-
]);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function SheetToolbar(props) {
|
|
54
|
-
const { onSubmit, onUndo, hasChanges, children } = props;
|
|
55
|
-
const buttonProps = { disabled: !hasChanges, small: true };
|
|
56
|
-
var constant =
|
|
57
|
-
"Are you sure you want to save your edits? All changes will be final. If you do not want to submit, click Cancel.";
|
|
58
|
-
return h("div.sheet-header", [
|
|
59
|
-
h("h3.sheet-title", "Sample metadata"),
|
|
60
|
-
h(ButtonGroup, { className: "sheet-actions" }, [
|
|
61
|
-
h(SubmitDialog, {
|
|
62
|
-
className: "save-btn",
|
|
63
|
-
onClick: onSubmit,
|
|
64
|
-
content: constant,
|
|
65
|
-
...buttonProps,
|
|
66
|
-
}),
|
|
67
|
-
h(
|
|
68
|
-
Button,
|
|
69
|
-
{
|
|
70
|
-
onClick: onUndo,
|
|
71
|
-
...buttonProps,
|
|
72
|
-
},
|
|
73
|
-
"Reset changes",
|
|
74
|
-
),
|
|
75
|
-
]),
|
|
76
|
-
h("div.spacer"),
|
|
77
|
-
children,
|
|
78
|
-
]);
|
|
79
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import h from "@macrostrat/hyper";
|
|
2
|
-
import { ErrorBoundary, useInDarkMode } from "@macrostrat/ui-components";
|
|
3
|
-
import { ChromePicker } from "react-color";
|
|
4
|
-
import { Popover } from "@blueprintjs/core";
|
|
5
|
-
import chroma from "chroma-js";
|
|
6
|
-
import "./styles.module.scss";
|
|
7
|
-
|
|
8
|
-
export function BasePopupEditor(props) {
|
|
9
|
-
const { children, valueRenderer, value, ...rest } = props;
|
|
10
|
-
|
|
11
|
-
return h(
|
|
12
|
-
Popover,
|
|
13
|
-
{
|
|
14
|
-
content: h(
|
|
15
|
-
"div.interaction-barrier",
|
|
16
|
-
{
|
|
17
|
-
onMouseDown(evt) {
|
|
18
|
-
//evt.nativeEvent.stopImmediatePropagation();
|
|
19
|
-
},
|
|
20
|
-
onKeyDown(evt) {
|
|
21
|
-
console.log(evt);
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
h(ErrorBoundary, null, children),
|
|
25
|
-
),
|
|
26
|
-
enforceFocus: false,
|
|
27
|
-
autoFocus: false,
|
|
28
|
-
minimal: true,
|
|
29
|
-
modifiers: {
|
|
30
|
-
//offset: { enabled: true, options: { offset: [0, 8] } },
|
|
31
|
-
},
|
|
32
|
-
interactionKind: "hover-target",
|
|
33
|
-
isOpen: true,
|
|
34
|
-
onClose(evt) {
|
|
35
|
-
props.onKeyDown(evt);
|
|
36
|
-
},
|
|
37
|
-
usePortal: false,
|
|
38
|
-
},
|
|
39
|
-
children,
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function ColorPicker({ value, onChange }) {
|
|
44
|
-
const darkMode = useInDarkMode();
|
|
45
|
-
const background = darkMode ? "#383e47;" : "#ffffff";
|
|
46
|
-
let color = "#aaaaaa";
|
|
47
|
-
try {
|
|
48
|
-
color = chroma(value).hex();
|
|
49
|
-
} catch {}
|
|
50
|
-
return h(ChromePicker, {
|
|
51
|
-
disableAlpha: true,
|
|
52
|
-
color,
|
|
53
|
-
styles: {
|
|
54
|
-
default: {
|
|
55
|
-
picker: {
|
|
56
|
-
background,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
onChange(color, evt) {
|
|
61
|
-
let c = "";
|
|
62
|
-
try {
|
|
63
|
-
c = chroma(color.hex);
|
|
64
|
-
} finally {
|
|
65
|
-
onChange(c);
|
|
66
|
-
evt.stopPropagation();
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
onKeyDown(evt) {
|
|
70
|
-
console.log(evt);
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function ColorEditor(props) {
|
|
76
|
-
const { value, onChange, ...rest } = props;
|
|
77
|
-
return h(BasePopupEditor, rest, h(ColorPicker, { value, onChange }));
|
|
78
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import ReactDataSheet from "react-datasheet";
|
|
2
|
-
//import classNames from "classnames";
|
|
3
|
-
interface GridElement extends ReactDataSheet.Cell<GridElement, number> {
|
|
4
|
-
value: number | null;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type SheetContent = GridElement[][];
|
|
8
|
-
|
|
9
|
-
export interface Field<Key> {
|
|
10
|
-
name: string;
|
|
11
|
-
key: Key;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
isValid?(k: any): boolean;
|
|
14
|
-
transform?(k: any): any;
|
|
15
|
-
valueViewer?: (k: any) => any;
|
|
16
|
-
dataEditor?: ReactDataSheet.DataEditor<ReactDataSheet.Cell<any, any>>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getFieldData<K>(field: Field<K>): Field<K> {
|
|
20
|
-
const {
|
|
21
|
-
transform = (d) => parseFloat(d),
|
|
22
|
-
isValid = (d) => !isNaN(d),
|
|
23
|
-
required = true,
|
|
24
|
-
...rest
|
|
25
|
-
} = field;
|
|
26
|
-
return { ...rest, transform, isValid, required };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function enhanceData(row: GridElement[], fields): any[] {
|
|
30
|
-
if (row == null) return [];
|
|
31
|
-
return row.map((cellData, i) => {
|
|
32
|
-
const { dataEditor, valueViewer, key } = getFieldData(fields[i]);
|
|
33
|
-
|
|
34
|
-
return { dataEditor, valueViewer, ...cellData };
|
|
35
|
-
});
|
|
36
|
-
}
|