@macrostrat/data-sheet 3.0.3 → 3.1.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.
- package/CHANGELOG.md +29 -0
- package/dist/cell-renderer.cjs +162 -0
- package/dist/cell-renderer.cjs.map +1 -0
- package/dist/cell-renderer.d.ts +8 -0
- package/dist/cell-renderer.js +162 -0
- package/dist/cell-renderer.js.map +1 -0
- package/dist/components/actions.cjs +2 -6
- package/dist/components/actions.cjs.map +1 -1
- package/dist/components/actions.js +1 -3
- package/dist/components/actions.js.map +1 -1
- package/dist/components/colors.cjs +4 -7
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.js +1 -3
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +15 -19
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.d.ts +1 -1
- package/dist/components/editor-popup.js +10 -12
- package/dist/components/editor-popup.js.map +1 -1
- package/dist/core.cjs +67 -207
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +4 -9
- package/dist/core.js +48 -185
- package/dist/core.js.map +1 -1
- package/dist/data-sheet.css +9 -9
- package/dist/index.cjs +16 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/postgrest-table/data-loaders.cjs +109 -0
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +6 -0
- package/dist/postgrest-table/data-loaders.js +111 -2
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +1 -0
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +2 -1
- package/dist/postgrest-table/index.js +2 -0
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/postgrest-table/lazy-loader-table.cjs +26 -0
- package/dist/postgrest-table/lazy-loader-table.cjs.map +1 -0
- package/dist/postgrest-table/lazy-loader-table.d.ts +3 -0
- package/dist/postgrest-table/lazy-loader-table.js +24 -0
- package/dist/postgrest-table/lazy-loader-table.js.map +1 -0
- package/dist/provider.cjs +59 -336
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.ts +11 -65
- package/dist/provider.js +58 -336
- package/dist/provider.js.map +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/utils/column-spec.cjs +6 -1
- package/dist/utils/column-spec.cjs.map +1 -1
- package/dist/utils/column-spec.js +6 -1
- package/dist/utils/column-spec.js.map +1 -1
- package/dist/utils/key-handling.cjs +26 -1
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +3 -2
- package/dist/utils/key-handling.js +27 -2
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/zustand-store.cjs +320 -0
- package/dist/zustand-store.cjs.map +1 -0
- package/dist/zustand-store.d.ts +6 -0
- package/dist/zustand-store.js +318 -0
- package/dist/zustand-store.js.map +1 -0
- package/package.json +7 -6
- package/src/cell-renderer.ts +217 -0
- package/src/components/actions.ts +1 -3
- package/src/components/colors.ts +1 -4
- package/src/components/editor-popup.ts +9 -12
- package/src/core.ts +82 -254
- package/src/index.ts +3 -0
- package/src/postgrest-table/data-loaders.ts +151 -1
- package/src/postgrest-table/index.ts +2 -1
- package/src/postgrest-table/lazy-loader-table.ts +24 -0
- package/src/provider.ts +66 -483
- package/src/types.ts +66 -0
- package/src/utils/column-spec.ts +6 -1
- package/src/utils/key-handling.ts +31 -5
- package/src/zustand-store.ts +377 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.1.0] - 2026-04-10 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v3.0.4...@macrostrat/data-sheet-v3.1.0)
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- New state model using Jotai scoped atoms to manage data sheet state
|
|
8
|
+
[b5119a4b](https://github.com/UW-Macrostrat/web-components/commit/b5119a4b7775286461ae67dff9f04000068810d3)
|
|
9
|
+
Removed `zustand-computed` dependency Improved lazy-loading examples
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
[b5119a4b](https://github.com/UW-Macrostrat/web-components/commit/b5119a4b7775286461ae67dff9f04000068810d3)
|
|
15
|
+
- @macrostrat/data-components@1.1.6
|
|
16
|
+
|
|
17
|
+
## [3.0.4] - 2026-04-05 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v3.0.3...@macrostrat/data-sheet-v3.0.4)
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- General performance improvements for rendering and infinite scrolling
|
|
22
|
+
- Use `PopoverNext` instead of popover
|
|
23
|
+
[4bd24d9f](https://github.com/UW-Macrostrat/web-components/commit/4bd24d9f65dacfdbbede3613921182858ec1e3d1)
|
|
24
|
+
- Re-enable column reordering
|
|
25
|
+
- Updated `@macrostrat/hyper` dependency
|
|
26
|
+
[6e9a6654](https://github.com/UW-Macrostrat/web-components/commit/6e9a665456460b31c30316a2a13d41abed94c43a)
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
[6e9a6654](https://github.com/UW-Macrostrat/web-components/commit/6e9a665456460b31c30316a2a13d41abed94c43a)
|
|
29
|
+
- @macrostrat/data-components@1.1.5
|
|
30
|
+
- @macrostrat/ui-components@5.0.7
|
|
31
|
+
|
|
3
32
|
## [3.0.3] - 2026-04-04 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v3.0.2...@macrostrat/data-sheet-v3.0.3)
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const main_module = require("./main.module.sass.cjs");
|
|
4
|
+
const zustandStore = require("./zustand-store.cjs");
|
|
5
|
+
const table = require("@blueprintjs/table");
|
|
6
|
+
const provider = require("./provider.cjs");
|
|
7
|
+
const editorPopup = require("./components/editor-popup.cjs");
|
|
8
|
+
const keyHandling = require("./utils/key-handling.cjs");
|
|
9
|
+
function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEditor = true) {
|
|
10
|
+
const data = state.data;
|
|
11
|
+
const updatedData = state.updatedData;
|
|
12
|
+
const isDeleted = state.deletedRows.has(rowIndex);
|
|
13
|
+
const row = data[rowIndex] ?? updatedData[rowIndex];
|
|
14
|
+
const loading = row == null;
|
|
15
|
+
const col = columnSpec;
|
|
16
|
+
const _topLeftCell = state.topLeftCell;
|
|
17
|
+
const onCellEdited = state.onCellEdited;
|
|
18
|
+
const value = updatedData[rowIndex]?.[col.key] ?? data[rowIndex]?.[col.key];
|
|
19
|
+
const _renderedValue = col.valueRenderer?.(value) ?? value;
|
|
20
|
+
let style = col.style ?? {};
|
|
21
|
+
if (isDeleted) {
|
|
22
|
+
style = {
|
|
23
|
+
...style,
|
|
24
|
+
opacity: 0.5,
|
|
25
|
+
textDecoration: "line-through"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const editable = (col.editable ?? state.editable) && !isDeleted;
|
|
29
|
+
const topLeft = _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;
|
|
30
|
+
if (!editable && state.editable) {
|
|
31
|
+
style.color = "var(--secondary-color)";
|
|
32
|
+
}
|
|
33
|
+
const edited = updatedData[rowIndex]?.[col.key] != null;
|
|
34
|
+
let intent = edited ? "success" : void 0;
|
|
35
|
+
if (isDeleted) {
|
|
36
|
+
intent = "danger";
|
|
37
|
+
}
|
|
38
|
+
const _Cell = col.cellComponent ?? BaseCell;
|
|
39
|
+
let inlineEditor = editable ? col.inlineEditor ?? true : false;
|
|
40
|
+
if (!topLeft) {
|
|
41
|
+
return main_module.default(
|
|
42
|
+
_Cell,
|
|
43
|
+
{
|
|
44
|
+
intent,
|
|
45
|
+
loading,
|
|
46
|
+
value,
|
|
47
|
+
style,
|
|
48
|
+
isDeleted
|
|
49
|
+
},
|
|
50
|
+
_renderedValue
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
let hiddenInput = main_module.default(EditorInput, {
|
|
54
|
+
className: "hidden-input",
|
|
55
|
+
autoFocus: true
|
|
56
|
+
});
|
|
57
|
+
let cellContents = _renderedValue;
|
|
58
|
+
let _dataEditor = null;
|
|
59
|
+
let className = null;
|
|
60
|
+
if (col.dataEditor != null) {
|
|
61
|
+
_dataEditor = main_module.default(
|
|
62
|
+
editorPopup.EditorPopup,
|
|
63
|
+
{
|
|
64
|
+
autoFocus: autoFocusEditor,
|
|
65
|
+
valueViewer: _renderedValue
|
|
66
|
+
},
|
|
67
|
+
[
|
|
68
|
+
main_module.default(col.dataEditor, {
|
|
69
|
+
value,
|
|
70
|
+
editable,
|
|
71
|
+
onChange(value2) {
|
|
72
|
+
if (!editable) return;
|
|
73
|
+
state.onSelectionEdited(value2);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (!editable) {
|
|
80
|
+
if (_dataEditor != null) {
|
|
81
|
+
cellContents = _dataEditor;
|
|
82
|
+
}
|
|
83
|
+
return main_module.default(
|
|
84
|
+
_Cell,
|
|
85
|
+
{
|
|
86
|
+
intent,
|
|
87
|
+
value,
|
|
88
|
+
style
|
|
89
|
+
},
|
|
90
|
+
cellContents
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const onChange = (e) => {
|
|
94
|
+
if (!editable) return;
|
|
95
|
+
if (value === e.target.value) return;
|
|
96
|
+
onCellEdited(rowIndex, col.key, e.target.value);
|
|
97
|
+
};
|
|
98
|
+
const isSingleCellSelection = zustandStore.singleFocusedCell(state.selection) != null;
|
|
99
|
+
let _inlineEditor = null;
|
|
100
|
+
if (typeof inlineEditor == "boolean") {
|
|
101
|
+
let _value = value;
|
|
102
|
+
if (typeof _renderedValue === "string" || typeof _renderedValue === "number" || _renderedValue == null) {
|
|
103
|
+
_value = _renderedValue;
|
|
104
|
+
}
|
|
105
|
+
_inlineEditor = main_module.default(EditorInput, {
|
|
106
|
+
className: "main-editor",
|
|
107
|
+
value: _value ?? "",
|
|
108
|
+
autoFocus: autoFocusEditor,
|
|
109
|
+
onChange
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
_inlineEditor = inlineEditor;
|
|
113
|
+
}
|
|
114
|
+
if (_dataEditor != null) {
|
|
115
|
+
className = "editor-cell";
|
|
116
|
+
cellContents = _dataEditor;
|
|
117
|
+
hiddenInput = null;
|
|
118
|
+
} else if (_inlineEditor != null) {
|
|
119
|
+
cellContents = _inlineEditor;
|
|
120
|
+
className = "input-cell";
|
|
121
|
+
hiddenInput = null;
|
|
122
|
+
}
|
|
123
|
+
return main_module.default(
|
|
124
|
+
_Cell,
|
|
125
|
+
{
|
|
126
|
+
intent,
|
|
127
|
+
value,
|
|
128
|
+
className,
|
|
129
|
+
style
|
|
130
|
+
//truncated: false,
|
|
131
|
+
},
|
|
132
|
+
[
|
|
133
|
+
cellContents,
|
|
134
|
+
main_module.default.if(editable && isSingleCellSelection)(DragHandle),
|
|
135
|
+
hiddenInput
|
|
136
|
+
]
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
function EditorInput(props) {
|
|
140
|
+
const onKeyDown = provider.useAtomValue(keyHandling.editorKeyHandlerAtom);
|
|
141
|
+
return main_module.default("input", {
|
|
142
|
+
onKeyDown,
|
|
143
|
+
...props
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function DragHandle() {
|
|
147
|
+
const onMouseDown = provider.useSelector((state) => state.onDragValue);
|
|
148
|
+
return main_module.default("div.corner-drag-handle", { onMouseDown });
|
|
149
|
+
}
|
|
150
|
+
function BaseCell({ children, value, ...rest }) {
|
|
151
|
+
return main_module.default(
|
|
152
|
+
table.Cell,
|
|
153
|
+
{
|
|
154
|
+
interactive: true,
|
|
155
|
+
...rest
|
|
156
|
+
},
|
|
157
|
+
children
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
exports.BaseCell = BaseCell;
|
|
161
|
+
exports.basicCellRenderer = basicCellRenderer;
|
|
162
|
+
//# sourceMappingURL=cell-renderer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-renderer.cjs","sources":["../src/cell-renderer.ts"],"sourcesContent":["import { ColumnSpec, editorKeyHandlerAtom } from \"./utils\";\nimport { DataSheetStore } from \"./types.ts\";\nimport h from \"./main.module.sass\";\nimport { ReactNode } from \"react\";\nimport { EditorPopup } from \"./components\";\nimport { singleFocusedCell } from \"./zustand-store.ts\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { useAtomValue, useSelector } from \"./provider.ts\";\n\nexport function 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 _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n\n const value = updatedData[rowIndex]?.[col.key] ?? data[rowIndex]?.[col.key];\n const _renderedValue = col.valueRenderer?.(value) ?? value;\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\n const editable = (col.editable ?? state.editable) && !isDeleted;\n\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 _renderedValue,\n );\n }\n\n // The rest is for the top-left cell of a selection or the focused cell\n\n // Hidden input to capture key events\n let hiddenInput = h(EditorInput, {\n className: \"hidden-input\",\n autoFocus: true,\n });\n\n let cellContents: ReactNode = _renderedValue;\n\n let _dataEditor = null;\n let className = null;\n\n if (col.dataEditor != null) {\n _dataEditor = h(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n editable,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n }),\n ],\n );\n }\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 (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n },\n cellContents,\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 const isSingleCellSelection = singleFocusedCell(state.selection) != null;\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(EditorInput, {\n className: \"main-editor\",\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange,\n });\n } else {\n // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor as ReactNode;\n }\n\n if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle),\n hiddenInput,\n ],\n );\n}\n\nfunction EditorInput(props) {\n const onKeyDown = useAtomValue(editorKeyHandlerAtom);\n return h(\"input\", {\n onKeyDown,\n ...props,\n });\n}\n\nfunction DragHandle() {\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 onMouseDown = useSelector((state) => state.onDragValue);\n return h(\"div.corner-drag-handle\", { onMouseDown });\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"],"names":["h","EditorPopup","value","singleFocusedCell","useAtomValue","editorKeyHandlerAtom","useSelector","Cell"],"mappings":";;;;;;;;AASO,SAAS,kBACd,UACA,UACA,YACA,OACA,kBAAkB,MACb;AACL,QAAM,OAAO,MAAM;AACnB,QAAM,cAAc,MAAM;AAE1B,QAAM,YAAY,MAAM,YAAY,IAAI,QAAQ;AAEhD,QAAM,MAAM,KAAK,QAAQ,KAAK,YAAY,QAAQ;AAClD,QAAM,UAAU,OAAO;AACvB,QAAM,MAAM;AAEZ,QAAM,eAAe,MAAM;AAC3B,QAAM,eAAe,MAAM;AAE3B,QAAM,QAAQ,YAAY,QAAQ,IAAI,IAAI,GAAG,KAAK,KAAK,QAAQ,IAAI,IAAI,GAAG;AAC1E,QAAM,iBAAiB,IAAI,gBAAgB,KAAK,KAAK;AAErD,MAAI,QAAQ,IAAI,SAAS,CAAA;AACzB,MAAI,WAAW;AACb,YAAQ;AAAA,MACN,GAAG;AAAA,MACH,SAAS;AAAA,MACT,gBAAgB;AAAA,IAAA;AAAA,EAEp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,QAAQ;AACrD,SAAOA,YAAAA;AAAAA,IACLO,MAAAA;AAAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnSpec } from './utils';
|
|
2
|
+
import { DataSheetStore } from './types.ts';
|
|
3
|
+
export declare function basicCellRenderer<T>(rowIndex: number, colIndex: number, columnSpec: ColumnSpec, state: DataSheetStore<T>, autoFocusEditor?: boolean): any;
|
|
4
|
+
export declare function BaseCell({ children, value, ...rest }: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
children: any;
|
|
7
|
+
value: any;
|
|
8
|
+
}): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import h from "./main.module.sass.js";
|
|
2
|
+
import { singleFocusedCell } from "./zustand-store.js";
|
|
3
|
+
import { Cell } from "@blueprintjs/table";
|
|
4
|
+
import { useAtomValue, useSelector } from "./provider.js";
|
|
5
|
+
import { EditorPopup } from "./components/editor-popup.js";
|
|
6
|
+
import { editorKeyHandlerAtom } from "./utils/key-handling.js";
|
|
7
|
+
function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEditor = true) {
|
|
8
|
+
const data = state.data;
|
|
9
|
+
const updatedData = state.updatedData;
|
|
10
|
+
const isDeleted = state.deletedRows.has(rowIndex);
|
|
11
|
+
const row = data[rowIndex] ?? updatedData[rowIndex];
|
|
12
|
+
const loading = row == null;
|
|
13
|
+
const col = columnSpec;
|
|
14
|
+
const _topLeftCell = state.topLeftCell;
|
|
15
|
+
const onCellEdited = state.onCellEdited;
|
|
16
|
+
const value = updatedData[rowIndex]?.[col.key] ?? data[rowIndex]?.[col.key];
|
|
17
|
+
const _renderedValue = col.valueRenderer?.(value) ?? value;
|
|
18
|
+
let style = col.style ?? {};
|
|
19
|
+
if (isDeleted) {
|
|
20
|
+
style = {
|
|
21
|
+
...style,
|
|
22
|
+
opacity: 0.5,
|
|
23
|
+
textDecoration: "line-through"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const editable = (col.editable ?? state.editable) && !isDeleted;
|
|
27
|
+
const topLeft = _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;
|
|
28
|
+
if (!editable && state.editable) {
|
|
29
|
+
style.color = "var(--secondary-color)";
|
|
30
|
+
}
|
|
31
|
+
const edited = updatedData[rowIndex]?.[col.key] != null;
|
|
32
|
+
let intent = edited ? "success" : void 0;
|
|
33
|
+
if (isDeleted) {
|
|
34
|
+
intent = "danger";
|
|
35
|
+
}
|
|
36
|
+
const _Cell = col.cellComponent ?? BaseCell;
|
|
37
|
+
let inlineEditor = editable ? col.inlineEditor ?? true : false;
|
|
38
|
+
if (!topLeft) {
|
|
39
|
+
return h(
|
|
40
|
+
_Cell,
|
|
41
|
+
{
|
|
42
|
+
intent,
|
|
43
|
+
loading,
|
|
44
|
+
value,
|
|
45
|
+
style,
|
|
46
|
+
isDeleted
|
|
47
|
+
},
|
|
48
|
+
_renderedValue
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
let hiddenInput = h(EditorInput, {
|
|
52
|
+
className: "hidden-input",
|
|
53
|
+
autoFocus: true
|
|
54
|
+
});
|
|
55
|
+
let cellContents = _renderedValue;
|
|
56
|
+
let _dataEditor = null;
|
|
57
|
+
let className = null;
|
|
58
|
+
if (col.dataEditor != null) {
|
|
59
|
+
_dataEditor = h(
|
|
60
|
+
EditorPopup,
|
|
61
|
+
{
|
|
62
|
+
autoFocus: autoFocusEditor,
|
|
63
|
+
valueViewer: _renderedValue
|
|
64
|
+
},
|
|
65
|
+
[
|
|
66
|
+
h(col.dataEditor, {
|
|
67
|
+
value,
|
|
68
|
+
editable,
|
|
69
|
+
onChange(value2) {
|
|
70
|
+
if (!editable) return;
|
|
71
|
+
state.onSelectionEdited(value2);
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (!editable) {
|
|
78
|
+
if (_dataEditor != null) {
|
|
79
|
+
cellContents = _dataEditor;
|
|
80
|
+
}
|
|
81
|
+
return h(
|
|
82
|
+
_Cell,
|
|
83
|
+
{
|
|
84
|
+
intent,
|
|
85
|
+
value,
|
|
86
|
+
style
|
|
87
|
+
},
|
|
88
|
+
cellContents
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const onChange = (e) => {
|
|
92
|
+
if (!editable) return;
|
|
93
|
+
if (value === e.target.value) return;
|
|
94
|
+
onCellEdited(rowIndex, col.key, e.target.value);
|
|
95
|
+
};
|
|
96
|
+
const isSingleCellSelection = singleFocusedCell(state.selection) != null;
|
|
97
|
+
let _inlineEditor = null;
|
|
98
|
+
if (typeof inlineEditor == "boolean") {
|
|
99
|
+
let _value = value;
|
|
100
|
+
if (typeof _renderedValue === "string" || typeof _renderedValue === "number" || _renderedValue == null) {
|
|
101
|
+
_value = _renderedValue;
|
|
102
|
+
}
|
|
103
|
+
_inlineEditor = h(EditorInput, {
|
|
104
|
+
className: "main-editor",
|
|
105
|
+
value: _value ?? "",
|
|
106
|
+
autoFocus: autoFocusEditor,
|
|
107
|
+
onChange
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
_inlineEditor = inlineEditor;
|
|
111
|
+
}
|
|
112
|
+
if (_dataEditor != null) {
|
|
113
|
+
className = "editor-cell";
|
|
114
|
+
cellContents = _dataEditor;
|
|
115
|
+
hiddenInput = null;
|
|
116
|
+
} else if (_inlineEditor != null) {
|
|
117
|
+
cellContents = _inlineEditor;
|
|
118
|
+
className = "input-cell";
|
|
119
|
+
hiddenInput = null;
|
|
120
|
+
}
|
|
121
|
+
return h(
|
|
122
|
+
_Cell,
|
|
123
|
+
{
|
|
124
|
+
intent,
|
|
125
|
+
value,
|
|
126
|
+
className,
|
|
127
|
+
style
|
|
128
|
+
//truncated: false,
|
|
129
|
+
},
|
|
130
|
+
[
|
|
131
|
+
cellContents,
|
|
132
|
+
h.if(editable && isSingleCellSelection)(DragHandle),
|
|
133
|
+
hiddenInput
|
|
134
|
+
]
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function EditorInput(props) {
|
|
138
|
+
const onKeyDown = useAtomValue(editorKeyHandlerAtom);
|
|
139
|
+
return h("input", {
|
|
140
|
+
onKeyDown,
|
|
141
|
+
...props
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function DragHandle() {
|
|
145
|
+
const onMouseDown = useSelector((state) => state.onDragValue);
|
|
146
|
+
return h("div.corner-drag-handle", { onMouseDown });
|
|
147
|
+
}
|
|
148
|
+
function BaseCell({ children, value, ...rest }) {
|
|
149
|
+
return h(
|
|
150
|
+
Cell,
|
|
151
|
+
{
|
|
152
|
+
interactive: true,
|
|
153
|
+
...rest
|
|
154
|
+
},
|
|
155
|
+
children
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
BaseCell,
|
|
160
|
+
basicCellRenderer
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=cell-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-renderer.js","sources":["../src/cell-renderer.ts"],"sourcesContent":["import { ColumnSpec, editorKeyHandlerAtom } from \"./utils\";\nimport { DataSheetStore } from \"./types.ts\";\nimport h from \"./main.module.sass\";\nimport { ReactNode } from \"react\";\nimport { EditorPopup } from \"./components\";\nimport { singleFocusedCell } from \"./zustand-store.ts\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { useAtomValue, useSelector } from \"./provider.ts\";\n\nexport function 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 _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n\n const value = updatedData[rowIndex]?.[col.key] ?? data[rowIndex]?.[col.key];\n const _renderedValue = col.valueRenderer?.(value) ?? value;\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\n const editable = (col.editable ?? state.editable) && !isDeleted;\n\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 _renderedValue,\n );\n }\n\n // The rest is for the top-left cell of a selection or the focused cell\n\n // Hidden input to capture key events\n let hiddenInput = h(EditorInput, {\n className: \"hidden-input\",\n autoFocus: true,\n });\n\n let cellContents: ReactNode = _renderedValue;\n\n let _dataEditor = null;\n let className = null;\n\n if (col.dataEditor != null) {\n _dataEditor = h(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n editable,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n }),\n ],\n );\n }\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 (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n },\n cellContents,\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 const isSingleCellSelection = singleFocusedCell(state.selection) != null;\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(EditorInput, {\n className: \"main-editor\",\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange,\n });\n } else {\n // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor as ReactNode;\n }\n\n if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle),\n hiddenInput,\n ],\n );\n}\n\nfunction EditorInput(props) {\n const onKeyDown = useAtomValue(editorKeyHandlerAtom);\n return h(\"input\", {\n onKeyDown,\n ...props,\n });\n}\n\nfunction DragHandle() {\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 onMouseDown = useSelector((state) => state.onDragValue);\n return h(\"div.corner-drag-handle\", { onMouseDown });\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"],"names":["value"],"mappings":";;;;;;AASO,SAAS,kBACd,UACA,UACA,YACA,OACA,kBAAkB,MACb;AACL,QAAM,OAAO,MAAM;AACnB,QAAM,cAAc,MAAM;AAE1B,QAAM,YAAY,MAAM,YAAY,IAAI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AAAA,IAAA;AAAA,EACF;AAEJ;AAEA,SAAS,YAAY,OAAO;AAC1B,QAAM,YAAY,aAAa,oBAAoB;AACnD,SAAO,EAAE,SAAS;AAAA,IAChB;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;AAEA,SAAS,aAAa;AAGpB,QAAM,cAAc,YAAY,CAAC,UAAU,MAAM,WAAW;AAC5D,SAAO,EAAE,0BAA0B,EAAE,aAAa;AACpD;AAEO,SAAS,SAAS,EAAE,UAAU,OAAO,GAAG,QAAQ;AACrD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const hyper = require("@macrostrat/hyper");
|
|
4
3
|
const actions_module = require("./actions.module.sass.cjs");
|
|
5
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
6
|
-
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
7
|
-
const h = hyper__default.default.styled(actions_module);
|
|
8
4
|
function DataSheetActionsRow(props) {
|
|
9
|
-
return
|
|
5
|
+
return actions_module("div.table-actions", props.children);
|
|
10
6
|
}
|
|
11
7
|
function DataSheetAction(props) {
|
|
12
|
-
return
|
|
8
|
+
return actions_module("div.table-action", props.children);
|
|
13
9
|
}
|
|
14
10
|
exports.DataSheetAction = DataSheetAction;
|
|
15
11
|
exports.DataSheetActionsRow = DataSheetActionsRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.cjs","sources":["../../src/components/actions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"actions.cjs","sources":["../../src/components/actions.ts"],"sourcesContent":["import h from \"./actions.module.sass\";\n\nexport function DataSheetActionsRow(props) {\n return h(\"div.table-actions\", props.children);\n}\n\nexport function DataSheetAction(props) {\n return h(\"div.table-action\", props.children);\n}\n"],"names":["h"],"mappings":";;;AAEO,SAAS,oBAAoB,OAAO;AACzC,SAAOA,eAAE,qBAAqB,MAAM,QAAQ;AAC9C;AAEO,SAAS,gBAAgB,OAAO;AACrC,SAAOA,eAAE,oBAAoB,MAAM,QAAQ;AAC7C;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sources":["../../src/components/actions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"actions.js","sources":["../../src/components/actions.ts"],"sourcesContent":["import h from \"./actions.module.sass\";\n\nexport function DataSheetActionsRow(props) {\n return h(\"div.table-actions\", props.children);\n}\n\nexport function DataSheetAction(props) {\n return h(\"div.table-action\", props.children);\n}\n"],"names":[],"mappings":";AAEO,SAAS,oBAAoB,OAAO;AACzC,SAAO,EAAE,qBAAqB,MAAM,QAAQ;AAC9C;AAEO,SAAS,gBAAgB,OAAO;AACrC,SAAO,EAAE,oBAAoB,MAAM,QAAQ;AAC7C;"}
|
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const table = require("@blueprintjs/table");
|
|
4
4
|
const uiComponents = require("@macrostrat/ui-components");
|
|
5
|
-
const hyper = require("@macrostrat/hyper");
|
|
6
5
|
const main_module = require("./main.module.sass.cjs");
|
|
7
6
|
const colorUtils = require("@macrostrat/color-utils");
|
|
8
7
|
const underscore = require("underscore");
|
|
9
8
|
const classNames = require("classnames");
|
|
10
9
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
11
|
-
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
12
10
|
const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
|
|
13
11
|
const ColorPicker = uiComponents.ColorPicker2;
|
|
14
|
-
const h = hyper__default.default.styled(main_module.default);
|
|
15
12
|
function ColorCell({
|
|
16
13
|
value,
|
|
17
14
|
children,
|
|
@@ -35,7 +32,7 @@ function ColorCell({
|
|
|
35
32
|
if (intent != null) {
|
|
36
33
|
mainColor = void 0;
|
|
37
34
|
}
|
|
38
|
-
return
|
|
35
|
+
return main_module.default(
|
|
39
36
|
table.Cell,
|
|
40
37
|
{
|
|
41
38
|
intent,
|
|
@@ -51,11 +48,11 @@ function ColorCell({
|
|
|
51
48
|
);
|
|
52
49
|
}
|
|
53
50
|
function colorSwatchRenderer(value) {
|
|
54
|
-
return
|
|
55
|
-
|
|
51
|
+
return main_module.default("span.color-swatch-container", [
|
|
52
|
+
main_module.default("span.color-swatch", {
|
|
56
53
|
style: { backgroundColor: value }
|
|
57
54
|
}),
|
|
58
|
-
|
|
55
|
+
main_module.default("span.color-name", value)
|
|
59
56
|
]);
|
|
60
57
|
}
|
|
61
58
|
const colorCombo = underscore.memoize(colorUtils.getLuminanceAdjustedColorScheme);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.cjs","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport
|
|
1
|
+
{"version":3,"file":"colors.cjs","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport h from \"./main.module.sass\";\nimport { getLuminanceAdjustedColorScheme } from \"@macrostrat/color-utils\";\nimport { memoize } from \"underscore\";\nimport classNames from \"classnames\";\nimport { ColorPicker2 } from \"@macrostrat/ui-components\";\n\nexport const ColorPicker = ColorPicker2;\n\nexport function ColorCell({\n value,\n children,\n style,\n intent,\n adjustLuminance = true,\n className,\n ...rest\n}) {\n const darkMode = useInDarkMode();\n\n const _className = classNames(className, \"color-cell\");\n\n let mainColor = \"var(--text-color)\";\n let backgroundColor = value;\n\n if (adjustLuminance) {\n // If adjustLuminance is true, get the color scheme based on the value\n let colors = colorCombo(value, darkMode, 0.05);\n if (colors != null) {\n mainColor = colors.mainColor;\n backgroundColor = colors.backgroundColor;\n }\n }\n\n if (intent != null) {\n // If an intent is specified, override the main color\n mainColor = undefined;\n }\n\n return h(\n Cell,\n {\n intent,\n className: _className,\n ...rest,\n style: {\n color: mainColor,\n backgroundColor,\n ...style,\n },\n },\n children,\n );\n}\n\nexport function colorSwatchRenderer(value) {\n return h(\"span.color-swatch-container\", [\n h(\"span.color-swatch\", {\n style: { backgroundColor: value },\n }),\n h(\"span.color-name\", value),\n ]);\n}\n\nconst colorCombo = memoize(getLuminanceAdjustedColorScheme);\n"],"names":["ColorPicker2","useInDarkMode","classNames","h","Cell","memoize","getLuminanceAdjustedColorScheme"],"mappings":";;;;;;;;;;AAQO,MAAM,cAAcA,aAAAA;AAEpB,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,WAAWC,aAAAA,cAAA;AAEjB,QAAM,aAAaC,oBAAAA,QAAW,WAAW,YAAY;AAErD,MAAI,YAAY;AAChB,MAAI,kBAAkB;AAEtB,MAAI,iBAAiB;AAEnB,QAAI,SAAS,WAAW,OAAO,UAAU,IAAI;AAC7C,QAAI,UAAU,MAAM;AAClB,kBAAY,OAAO;AACnB,wBAAkB,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,UAAU,MAAM;AAElB,gBAAY;AAAA,EACd;AAEA,SAAOC,YAAAA;AAAAA,IACLC,MAAAA;AAAAA,IACA;AAAA,MACE;AAAA,MACA,WAAW;AAAA,MACX,GAAG;AAAA,MACH,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,IACL;AAAA,IAEF;AAAA,EAAA;AAEJ;AAEO,SAAS,oBAAoB,OAAO;AACzC,SAAOD,YAAAA,QAAE,+BAA+B;AAAA,IACtCA,YAAAA,QAAE,qBAAqB;AAAA,MACrB,OAAO,EAAE,iBAAiB,MAAA;AAAA,IAAM,CACjC;AAAA,IACDA,YAAAA,QAAE,mBAAmB,KAAK;AAAA,EAAA,CAC3B;AACH;AAEA,MAAM,aAAaE,WAAAA,QAAQC,0CAA+B;;;;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Cell } from "@blueprintjs/table";
|
|
2
2
|
import { ColorPicker2, useInDarkMode } from "@macrostrat/ui-components";
|
|
3
|
-
import
|
|
4
|
-
import h$1 from "./main.module.sass.js";
|
|
3
|
+
import h from "./main.module.sass.js";
|
|
5
4
|
import { getLuminanceAdjustedColorScheme } from "@macrostrat/color-utils";
|
|
6
5
|
import { memoize } from "underscore";
|
|
7
6
|
import classNames from "classnames";
|
|
8
7
|
const ColorPicker = ColorPicker2;
|
|
9
|
-
const h = hyper.styled(h$1);
|
|
10
8
|
function ColorCell({
|
|
11
9
|
value,
|
|
12
10
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport
|
|
1
|
+
{"version":3,"file":"colors.js","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport h from \"./main.module.sass\";\nimport { getLuminanceAdjustedColorScheme } from \"@macrostrat/color-utils\";\nimport { memoize } from \"underscore\";\nimport classNames from \"classnames\";\nimport { ColorPicker2 } from \"@macrostrat/ui-components\";\n\nexport const ColorPicker = ColorPicker2;\n\nexport function ColorCell({\n value,\n children,\n style,\n intent,\n adjustLuminance = true,\n className,\n ...rest\n}) {\n const darkMode = useInDarkMode();\n\n const _className = classNames(className, \"color-cell\");\n\n let mainColor = \"var(--text-color)\";\n let backgroundColor = value;\n\n if (adjustLuminance) {\n // If adjustLuminance is true, get the color scheme based on the value\n let colors = colorCombo(value, darkMode, 0.05);\n if (colors != null) {\n mainColor = colors.mainColor;\n backgroundColor = colors.backgroundColor;\n }\n }\n\n if (intent != null) {\n // If an intent is specified, override the main color\n mainColor = undefined;\n }\n\n return h(\n Cell,\n {\n intent,\n className: _className,\n ...rest,\n style: {\n color: mainColor,\n backgroundColor,\n ...style,\n },\n },\n children,\n );\n}\n\nexport function colorSwatchRenderer(value) {\n return h(\"span.color-swatch-container\", [\n h(\"span.color-swatch\", {\n style: { backgroundColor: value },\n }),\n h(\"span.color-name\", value),\n ]);\n}\n\nconst colorCombo = memoize(getLuminanceAdjustedColorScheme);\n"],"names":[],"mappings":";;;;;;AAQO,MAAM,cAAc;AAEpB,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,WAAW,cAAA;AAEjB,QAAM,aAAa,WAAW,WAAW,YAAY;AAErD,MAAI,YAAY;AAChB,MAAI,kBAAkB;AAEtB,MAAI,iBAAiB;AAEnB,QAAI,SAAS,WAAW,OAAO,UAAU,IAAI;AAC7C,QAAI,UAAU,MAAM;AAClB,kBAAY,OAAO;AACnB,wBAAkB,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,UAAU,MAAM;AAElB,gBAAY;AAAA,EACd;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA,WAAW;AAAA,MACX,GAAG;AAAA,MACH,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,IACL;AAAA,IAEF;AAAA,EAAA;AAEJ;AAEO,SAAS,oBAAoB,OAAO;AACzC,SAAO,EAAE,+BAA+B;AAAA,IACtC,EAAE,qBAAqB;AAAA,MACrB,OAAO,EAAE,iBAAiB,MAAA;AAAA,IAAM,CACjC;AAAA,IACD,EAAE,mBAAmB,KAAK;AAAA,EAAA,CAC3B;AACH;AAEA,MAAM,aAAa,QAAQ,+BAA+B;"}
|
|
@@ -1,38 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const hyper = require("@macrostrat/hyper");
|
|
4
3
|
const uiComponents = require("@macrostrat/ui-components");
|
|
5
4
|
const core = require("@blueprintjs/core");
|
|
6
5
|
const main_module = require("./main.module.sass.cjs");
|
|
7
6
|
const react = require("react");
|
|
8
7
|
const provider = require("../provider.cjs");
|
|
9
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
-
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
11
|
-
const h = hyper__default.default.styled(main_module.default);
|
|
12
8
|
function EditorPopup(props) {
|
|
13
9
|
const {
|
|
14
10
|
children,
|
|
15
11
|
targetClassName,
|
|
16
12
|
autoFocus,
|
|
17
13
|
valueViewer,
|
|
18
|
-
placement = "right-start"
|
|
19
|
-
minimal = true
|
|
14
|
+
placement = "right-start"
|
|
20
15
|
} = props;
|
|
21
16
|
const [isOpen, setIsOpen] = react.useState(autoFocus);
|
|
22
17
|
const keyHandler = provider.useSelector((state) => state.keyHandler);
|
|
23
18
|
const ref = react.useRef(null);
|
|
24
|
-
const inlineEditor =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const inlineEditor = main_module.default([
|
|
20
|
+
main_module.default("span.editor-value.bp6-table-cell", valueViewer),
|
|
21
|
+
main_module.default("input.hidden-editor", {
|
|
22
|
+
defaultValue: "",
|
|
28
23
|
autoFocus: true,
|
|
29
24
|
onKeyDown: keyHandler
|
|
30
25
|
})
|
|
31
26
|
]);
|
|
32
|
-
return
|
|
33
|
-
core.
|
|
27
|
+
return main_module.default(
|
|
28
|
+
core.PopoverNext,
|
|
34
29
|
{
|
|
35
|
-
content:
|
|
30
|
+
content: main_module.default(
|
|
36
31
|
"div.interaction-barrier",
|
|
37
32
|
{
|
|
38
33
|
onMouseDown(evt) {
|
|
@@ -49,21 +44,22 @@ function EditorPopup(props) {
|
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
46
|
},
|
|
52
|
-
|
|
47
|
+
main_module.default(uiComponents.ErrorBoundary, null, children)
|
|
53
48
|
),
|
|
54
49
|
enforceFocus: false,
|
|
55
50
|
autoFocus: false,
|
|
56
|
-
minimal,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
51
|
+
animation: "minimal",
|
|
52
|
+
lazy: true,
|
|
53
|
+
// modifiers: {
|
|
54
|
+
// offset: { enabled: true, options: { offset: [0, 8] } },
|
|
55
|
+
// },
|
|
60
56
|
placement,
|
|
61
57
|
interactionKind: "hover-target",
|
|
62
58
|
isOpen,
|
|
63
59
|
// Portal must be used to avoid issues with the editor being clipped to the bounds of the cell
|
|
64
60
|
usePortal: true
|
|
65
61
|
},
|
|
66
|
-
|
|
62
|
+
main_module.default(
|
|
67
63
|
"span.editor-popup-target.bp6-table-cell",
|
|
68
64
|
{
|
|
69
65
|
className: targetClassName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-popup.cjs","sources":["../../src/components/editor-popup.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"editor-popup.cjs","sources":["../../src/components/editor-popup.ts"],"sourcesContent":["import { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PopoverNext } from \"@blueprintjs/core\";\nimport h from \"./main.module.sass\";\nimport { useRef, useState } from \"react\";\nimport { useSelector } from \"../provider\";\n\nexport function EditorPopup(props) {\n const {\n children,\n targetClassName,\n autoFocus,\n valueViewer,\n placement = \"right-start\",\n } = props;\n\n const [isOpen, setIsOpen] = useState(autoFocus);\n const keyHandler = useSelector((state) => state.keyHandler);\n\n const ref = useRef(null);\n\n const inlineEditor = h([\n h(\"span.editor-value.bp6-table-cell\", valueViewer),\n h(\"input.hidden-editor\", {\n defaultValue: \"\",\n autoFocus: true,\n onKeyDown: keyHandler,\n }),\n ]);\n\n return h(\n PopoverNext,\n {\n content: h(\n \"div.interaction-barrier\",\n {\n onMouseDown(evt) {\n evt.nativeEvent.stopImmediatePropagation();\n },\n onKeyDown(evt) {\n if (evt.key === \"Escape\") {\n if (isOpen) {\n setIsOpen(false);\n }\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n // Climb over the interaction barrier to propagate the key event to the table\n },\n },\n h(ErrorBoundary, null, children),\n ),\n enforceFocus: false,\n autoFocus: false,\n animation: \"minimal\",\n lazy: true,\n // modifiers: {\n // offset: { enabled: true, options: { offset: [0, 8] } },\n // },\n placement,\n interactionKind: \"hover-target\",\n isOpen,\n // Portal must be used to avoid issues with the editor being clipped to the bounds of the cell\n usePortal: true,\n },\n h(\n \"span.editor-popup-target.bp6-table-cell\",\n {\n className: targetClassName,\n onClick: () => setIsOpen(!isOpen),\n ref,\n },\n // If the editor is open, show the inline editor, otherwise show the value viewer\n isOpen ? valueViewer : (inlineEditor ?? valueViewer),\n ),\n );\n}\n"],"names":["useState","useSelector","useRef","h","PopoverNext","ErrorBoundary"],"mappings":";;;;;;;AAMO,SAAS,YAAY,OAAO;AACjC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,EAAA,IACV;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA,SAAS,SAAS;AAC9C,QAAM,aAAaC,SAAAA,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,MAAMC,MAAAA,OAAO,IAAI;AAEvB,QAAM,eAAeC,YAAAA,QAAE;AAAA,IACrBA,YAAAA,QAAE,oCAAoC,WAAW;AAAA,IACjDA,YAAAA,QAAE,uBAAuB;AAAA,MACvB,cAAc;AAAA,MACd,WAAW;AAAA,MACX,WAAW;AAAA,IAAA,CACZ;AAAA,EAAA,CACF;AAED,SAAOA,YAAAA;AAAAA,IACLC,KAAAA;AAAAA,IACA;AAAA,MACE,SAASD,YAAAA;AAAAA,QACP;AAAA,QACA;AAAA,UACE,YAAY,KAAK;AACf,gBAAI,YAAY,yBAAA;AAAA,UAClB;AAAA,UACA,UAAU,KAAK;AACb,gBAAI,IAAI,QAAQ,UAAU;AACxB,kBAAI,QAAQ;AACV,0BAAU,KAAK;AAAA,cACjB;AACA,kBAAI,gBAAA;AACJ,kBAAI,eAAA;AACJ;AAAA,YACF;AAAA,UAEF;AAAA,QAAA;AAAA,QAEFA,oBAAEE,aAAAA,eAAe,MAAM,QAAQ;AAAA,MAAA;AAAA,MAEjC,cAAc;AAAA,MACd,WAAW;AAAA,MACX,WAAW;AAAA,MACX,MAAM;AAAA;AAAA;AAAA;AAAA,MAIN;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA;AAAA,MAEA,WAAW;AAAA,IAAA;AAAA,IAEbF,YAAAA;AAAAA,MACE;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,QAChC;AAAA,MAAA;AAAA;AAAA,MAGF,SAAS,cAAe,gBAAgB;AAAA,IAAA;AAAA,EAC1C;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function EditorPopup(props: any): import('react').
|
|
1
|
+
export declare function EditorPopup(props: any): import('react').FunctionComponentElement<import('@blueprintjs/core').PopoverNextProps<import('@blueprintjs/core').DefaultPopoverTargetHTMLProps> & import('react').RefAttributes<import('@blueprintjs/core').PopoverNextRef>>;
|