@macrostrat/data-sheet 2.2.3 → 2.2.4
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 +5 -0
- package/dist/esm/{data-sheet.9b593da4.js → data-sheet.2e11f097.js} +4 -4
- package/dist/esm/{data-sheet.9b593da4.js.map → data-sheet.2e11f097.js.map} +1 -1
- package/dist/esm/data-sheet.37e35216.js.map +1 -1
- package/dist/esm/{data-sheet.ba9a1241.js → data-sheet.403b9693.js} +20 -22
- package/dist/esm/data-sheet.403b9693.js.map +1 -0
- package/dist/esm/{data-sheet.96446cae.js → data-sheet.40866550.js} +2 -2
- package/dist/esm/{data-sheet.96446cae.js.map → data-sheet.40866550.js.map} +1 -1
- package/dist/esm/{data-sheet.6021b6c9.js → data-sheet.53ee5bf7.js} +25 -15
- package/dist/esm/data-sheet.53ee5bf7.js.map +1 -0
- package/dist/esm/{data-sheet.00353511.js → data-sheet.560943e5.js} +3 -3
- package/dist/esm/{data-sheet.00353511.js.map → data-sheet.560943e5.js.map} +1 -1
- package/dist/esm/{data-sheet.6776e250.js → data-sheet.9a4e4e01.js} +4 -3
- package/dist/esm/data-sheet.9a4e4e01.js.map +1 -0
- package/dist/esm/{data-sheet.91223ec6.css → data-sheet.a7230b2f.css} +3 -3
- package/dist/esm/data-sheet.a7230b2f.css.map +1 -0
- package/dist/esm/data-sheet.c9b6b6f2.js.map +1 -1
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/node/data-sheet.3c728e09.js +2 -0
- package/dist/node/data-sheet.3c728e09.js.map +1 -0
- package/dist/node/{data-sheet.c350336f.js → data-sheet.474755ec.js} +2 -2
- package/dist/node/{data-sheet.c350336f.js.map → data-sheet.474755ec.js.map} +1 -1
- package/dist/node/data-sheet.afb25a47.js +2 -0
- package/dist/node/data-sheet.afb25a47.js.map +1 -0
- package/dist/node/{data-sheet.2f64274d.css → data-sheet.c90cb14b.css} +2 -2
- package/dist/node/data-sheet.c90cb14b.css.map +1 -0
- package/dist/node/data-sheet.dffdda71.js.map +1 -1
- package/dist/node/data-sheet.e472411d.js +2 -0
- package/dist/node/data-sheet.e472411d.js.map +1 -0
- package/dist/node/{data-sheet.2a613259.js → data-sheet.ef0c95f4.js} +2 -2
- package/dist/node/{data-sheet.2a613259.js.map → data-sheet.ef0c95f4.js.map} +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +5 -6
- package/src/components/colors.ts +25 -12
- package/src/components/editor-popup.ts +2 -0
- package/src/components/main.module.sass +3 -7
- package/src/core.ts +27 -30
- package/src/provider.ts +1 -0
- package/dist/esm/data-sheet.6021b6c9.js.map +0 -1
- package/dist/esm/data-sheet.6776e250.js.map +0 -1
- package/dist/esm/data-sheet.91223ec6.css.map +0 -1
- package/dist/esm/data-sheet.ba9a1241.js.map +0 -1
- package/dist/node/data-sheet.171105c1.js +0 -2
- package/dist/node/data-sheet.171105c1.js.map +0 -1
- package/dist/node/data-sheet.2f64274d.css.map +0 -1
- package/dist/node/data-sheet.6a663031.js +0 -2
- package/dist/node/data-sheet.6a663031.js.map +0 -1
- package/dist/node/data-sheet.809cdb29.js +0 -2
- package/dist/node/data-sheet.809cdb29.js.map +0 -1
package/src/components/colors.ts
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
asChromaColor,
|
|
7
7
|
getLuminanceAdjustedColorScheme,
|
|
8
8
|
} from "@macrostrat/color-utils";
|
|
9
|
-
import {
|
|
10
|
-
import { useEffect, useRef } from "react";
|
|
9
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
11
10
|
import { memoize } from "underscore";
|
|
12
|
-
import
|
|
11
|
+
import Sketch from "@uiw/react-color-sketch";
|
|
12
|
+
import classNames from "classnames";
|
|
13
13
|
|
|
14
14
|
const h = hyper.styled(styles);
|
|
15
15
|
|
|
@@ -19,10 +19,13 @@ export function ColorCell({
|
|
|
19
19
|
style,
|
|
20
20
|
intent,
|
|
21
21
|
adjustLuminance = true,
|
|
22
|
+
className,
|
|
22
23
|
...rest
|
|
23
24
|
}) {
|
|
24
25
|
const darkMode = useInDarkMode();
|
|
25
26
|
|
|
27
|
+
const _className = classNames(className, "color-cell");
|
|
28
|
+
|
|
26
29
|
let mainColor = "var(--text-color)";
|
|
27
30
|
let backgroundColor = value;
|
|
28
31
|
|
|
@@ -35,9 +38,16 @@ export function ColorCell({
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
if (intent != null) {
|
|
42
|
+
// If an intent is specified, override the main color
|
|
43
|
+
mainColor = undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
return h(
|
|
39
47
|
Cell,
|
|
40
48
|
{
|
|
49
|
+
intent,
|
|
50
|
+
className: _className,
|
|
41
51
|
...rest,
|
|
42
52
|
style: {
|
|
43
53
|
color: mainColor,
|
|
@@ -70,6 +80,7 @@ enum ColorConversionType {
|
|
|
70
80
|
export function ColorPicker({
|
|
71
81
|
value,
|
|
72
82
|
onChange,
|
|
83
|
+
editable = true,
|
|
73
84
|
type = ColorConversionType.CSS,
|
|
74
85
|
}) {
|
|
75
86
|
const ref = useRef(null);
|
|
@@ -78,17 +89,18 @@ export function ColorPicker({
|
|
|
78
89
|
ref.current.focus();
|
|
79
90
|
}, []);
|
|
80
91
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
const color = useMemo(() => {
|
|
93
|
+
try {
|
|
94
|
+
return asChromaColor(value).hex();
|
|
95
|
+
} catch {
|
|
96
|
+
return "#aaaaaa";
|
|
97
|
+
}
|
|
98
|
+
}, [value]);
|
|
99
|
+
|
|
87
100
|
return h(
|
|
88
101
|
"div.color-picker-container",
|
|
89
102
|
{
|
|
90
103
|
onKeyDown(evt) {
|
|
91
|
-
console.log(evt);
|
|
92
104
|
if (evt.key === "Escape") {
|
|
93
105
|
evt.preventDefault();
|
|
94
106
|
}
|
|
@@ -96,10 +108,11 @@ export function ColorPicker({
|
|
|
96
108
|
ref,
|
|
97
109
|
tabIndex: 0,
|
|
98
110
|
},
|
|
99
|
-
h(
|
|
111
|
+
h(Sketch, {
|
|
100
112
|
color,
|
|
113
|
+
disableAlpha: true,
|
|
101
114
|
onChange(color) {
|
|
102
|
-
onChange(asChromaColor(color)[type]());
|
|
115
|
+
onChange(asChromaColor(color.hexa)[type]());
|
|
103
116
|
},
|
|
104
117
|
}),
|
|
105
118
|
);
|
|
@@ -13,6 +13,7 @@ export function EditorPopup(props) {
|
|
|
13
13
|
targetClassName,
|
|
14
14
|
autoFocus,
|
|
15
15
|
valueViewer,
|
|
16
|
+
placement = "right-start",
|
|
16
17
|
minimal = true,
|
|
17
18
|
} = props;
|
|
18
19
|
|
|
@@ -59,6 +60,7 @@ export function EditorPopup(props) {
|
|
|
59
60
|
modifiers: {
|
|
60
61
|
offset: { enabled: true, options: { offset: [0, 8] } },
|
|
61
62
|
},
|
|
63
|
+
placement,
|
|
62
64
|
interactionKind: "hover-target",
|
|
63
65
|
isOpen,
|
|
64
66
|
// Portal must be used to avoid issues with the editor being clipped to the bounds of the cell
|
|
@@ -37,13 +37,8 @@
|
|
|
37
37
|
|
|
38
38
|
// Color picker
|
|
39
39
|
.color-picker-container
|
|
40
|
-
:global
|
|
41
|
-
|
|
42
|
-
border-radius: 0
|
|
43
|
-
|
|
44
|
-
.react-colorful__hue
|
|
45
|
-
border-radius: 0
|
|
46
|
-
|
|
40
|
+
:global .w-color-sketch
|
|
41
|
+
--sketch-background: var(--secondary-background) !important
|
|
47
42
|
|
|
48
43
|
.color-swatch
|
|
49
44
|
width: 18px
|
|
@@ -66,3 +61,4 @@
|
|
|
66
61
|
position: relative
|
|
67
62
|
flex-grow: 1
|
|
68
63
|
display: block
|
|
64
|
+
|
package/src/core.ts
CHANGED
|
@@ -385,23 +385,35 @@ function basicCellRenderer<T>(
|
|
|
385
385
|
|
|
386
386
|
let cellContents: ReactNode = _renderedValue;
|
|
387
387
|
|
|
388
|
+
let _dataEditor = null;
|
|
389
|
+
let className = null;
|
|
390
|
+
|
|
391
|
+
if (col.dataEditor != null) {
|
|
392
|
+
_dataEditor = h(
|
|
393
|
+
EditorPopup,
|
|
394
|
+
{
|
|
395
|
+
autoFocus: autoFocusEditor,
|
|
396
|
+
valueViewer: _renderedValue,
|
|
397
|
+
},
|
|
398
|
+
[
|
|
399
|
+
h(col.dataEditor, {
|
|
400
|
+
value,
|
|
401
|
+
editable,
|
|
402
|
+
onChange(value) {
|
|
403
|
+
if (!editable) return;
|
|
404
|
+
state.onSelectionEdited(value);
|
|
405
|
+
},
|
|
406
|
+
}),
|
|
407
|
+
],
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
388
411
|
if (!editable) {
|
|
389
412
|
// Most cells are not focused and don't need to be editable.
|
|
390
413
|
// This will be the rendering logic for almost all cells
|
|
391
414
|
|
|
392
|
-
if (
|
|
393
|
-
cellContents =
|
|
394
|
-
EditorPopup,
|
|
395
|
-
{
|
|
396
|
-
autoFocus: autoFocusEditor,
|
|
397
|
-
valueViewer: _renderedValue,
|
|
398
|
-
},
|
|
399
|
-
[
|
|
400
|
-
h(col.dataEditor, {
|
|
401
|
-
value,
|
|
402
|
-
}),
|
|
403
|
-
],
|
|
404
|
-
);
|
|
415
|
+
if (_dataEditor != null) {
|
|
416
|
+
cellContents = _dataEditor;
|
|
405
417
|
}
|
|
406
418
|
|
|
407
419
|
return h(
|
|
@@ -447,24 +459,9 @@ function basicCellRenderer<T>(
|
|
|
447
459
|
_inlineEditor = inlineEditor as ReactNode;
|
|
448
460
|
}
|
|
449
461
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
if (col.dataEditor != null) {
|
|
462
|
+
if (_dataEditor != null) {
|
|
453
463
|
className = "editor-cell";
|
|
454
|
-
cellContents =
|
|
455
|
-
EditorPopup,
|
|
456
|
-
{
|
|
457
|
-
autoFocus: autoFocusEditor,
|
|
458
|
-
valueViewer: _renderedValue,
|
|
459
|
-
},
|
|
460
|
-
h(col.dataEditor, {
|
|
461
|
-
value,
|
|
462
|
-
onChange(value) {
|
|
463
|
-
if (!editable) return;
|
|
464
|
-
state.onSelectionEdited(value);
|
|
465
|
-
},
|
|
466
|
-
}),
|
|
467
|
-
);
|
|
464
|
+
cellContents = _dataEditor;
|
|
468
465
|
hiddenInput = null;
|
|
469
466
|
} else if (_inlineEditor != null) {
|
|
470
467
|
cellContents = _inlineEditor;
|
package/src/provider.ts
CHANGED
|
@@ -260,6 +260,7 @@ export function DataSheetProvider<T>({
|
|
|
260
260
|
const { editable, updatedData, data } = state;
|
|
261
261
|
if (!editable) return {};
|
|
262
262
|
let rowSpec: any;
|
|
263
|
+
|
|
263
264
|
// Check to see if the new value is the same as the old one
|
|
264
265
|
if (value !== data[rowIndex]?.[columnName]) {
|
|
265
266
|
const rowOp = updatedData[rowIndex] != null ? "$merge" : "$set";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,qEAAK;AAErB,SAAS,0CAAU,SACxB,KAAK,YACL,QAAQ,SACR,KAAK,UACL,MAAM,mBACN,kBAAkB,MAClB,GAAG,MACJ;IACC,MAAM,WAAW,CAAA,GAAA,oBAAY;IAE7B,IAAI,YAAY;IAChB,IAAI,kBAAkB;IAEtB,IAAI,iBAAiB;QACnB,sEAAsE;QACtE,IAAI,SAAS,iCAAW,OAAO,UAAU;QACzC,IAAI,UAAU,MAAM;YAClB,YAAY,OAAO,SAAS;YAC5B,kBAAkB,OAAO,eAAe;QAC1C;IACF;IAEA,OAAO,wBACL,CAAA,GAAA,WAAG,GACH;QACE,GAAG,IAAI;QACP,OAAO;YACL,OAAO;6BACP;YACA,GAAG,KAAK;QACV;IACF,GACA;AAEJ;AAEO,SAAS,0CAAoB,KAAK;IACvC,OAAO,wBAAE,+BAA+B;QACtC,wBAAE,qBAAqB;YACrB,OAAO;gBAAE,iBAAiB;YAAM;QAClC;QACA,wBAAE,mBAAmB;KACtB;AACH;AAEA,MAAM,mCAAa,CAAA,GAAA,cAAM,EAAE,CAAA,GAAA,sCAA8B;AAEzD,IAAA,AAAK,mEAAA;;;;;WAAA;EAAA;AAOE,SAAS,0CAAY,SAC1B,KAAK,YACL,QAAQ,QACR,cACD;IACC,MAAM,MAAM,CAAA,GAAA,aAAK,EAAE;IACnB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,MAAM;QACzB,IAAI,OAAO,CAAC,KAAK;IACnB,GAAG,EAAE;IAEL,IAAI;IACJ,IAAI;QACF,QAAQ,CAAA,GAAA,oBAAY,EAAE,OAAO,GAAG;IAClC,EAAE,OAAM;QACN,QAAQ;IACV;IACA,OAAO,wBACL,8BACA;QACE,WAAU,GAAG;YACX,QAAQ,GAAG,CAAC;YACZ,IAAI,IAAI,GAAG,KAAK,UACd,IAAI,cAAc;QAEtB;aACA;QACA,UAAU;IACZ,GACA,wBAAE,CAAA,GAAA,qBAAa,GAAG;eAChB;QACA,UAAS,KAAK;YACZ,SAAS,CAAA,GAAA,oBAAY,EAAE,MAAM,CAAC,KAAK;QACrC;IACF;AAEJ","sources":["packages/data-sheet/src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport {\n asChromaColor,\n getLuminanceAdjustedColorScheme,\n} from \"@macrostrat/color-utils\";\nimport { HexColorPicker } from \"react-colorful\";\nimport { useEffect, useRef } from \"react\";\nimport { memoize } from \"underscore\";\nimport main from \"../../../../.storybook/main\";\n\nconst h = hyper.styled(styles);\n\nexport function ColorCell({\n value,\n children,\n style,\n intent,\n adjustLuminance = true,\n ...rest\n}) {\n const darkMode = useInDarkMode();\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 return h(\n Cell,\n {\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\nenum ColorConversionType {\n HEX = \"hex\",\n RGB = \"rgb\",\n HSL = \"hsl\",\n CSS = \"css\",\n}\n\nexport function ColorPicker({\n value,\n onChange,\n type = ColorConversionType.CSS,\n}) {\n const ref = useRef(null);\n useEffect(() => {\n if (ref.current == null) return;\n ref.current.focus();\n }, []);\n\n let color: any;\n try {\n color = asChromaColor(value).hex();\n } catch {\n color = \"#aaaaaa\";\n }\n return h(\n \"div.color-picker-container\",\n {\n onKeyDown(evt) {\n console.log(evt);\n if (evt.key === \"Escape\") {\n evt.preventDefault();\n }\n },\n ref,\n tabIndex: 0,\n },\n h(HexColorPicker, {\n color,\n onChange(color) {\n onChange(asChromaColor(color)[type]());\n },\n }),\n );\n}\n"],"names":[],"version":3,"file":"data-sheet.6021b6c9.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAOA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,qEAAK;AAErB,SAAS,0CAAY,KAAK;IAC/B,MAAM,YACJ,QAAQ,mBACR,eAAe,aACf,SAAS,eACT,WAAW,WACX,UAAU,MACX,GAAG;IAEJ,MAAM,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAE;IACrC,MAAM,aAAa,CAAA,GAAA,yCAAU,EAAE,CAAC,QAAU,MAAM,UAAU;IAE1D,MAAM,MAAM,CAAA,GAAA,aAAK,EAAE;IAEnB,MAAM,eAAe,wBAAE;QACrB,wBAAE,oCAAoC;QACtC,wBAAE,uBAAuB;YACvB,OAAO;YACP,WAAW;YACX,WAAW;QACb;KACD;IAED,OAAO,wBACL,CAAA,GAAA,cAAM,GACN;QACE,SAAS,wBACP,2BACA;YACE,aAAY,GAAG;gBACb,IAAI,WAAW,CAAC,wBAAwB;YAC1C;YACA,WAAU,GAAG;gBACX,IAAI,IAAI,GAAG,KAAK,UAAU;oBACxB,IAAI,QACF,UAAU;oBAEZ,IAAI,eAAe;oBACnB,IAAI,cAAc;oBAClB;gBACF;YACA,6EAA6E;YAC/E;QACF,GACA,wBAAE,CAAA,GAAA,oBAAY,GAAG,MAAM;QAEzB,cAAc;QACd,WAAW;iBACX;QACA,WAAW;YACT,QAAQ;gBAAE,SAAS;gBAAM,SAAS;oBAAE,QAAQ;wBAAC;wBAAG;qBAAE;gBAAC;YAAE;QACvD;QACA,iBAAiB;gBACjB;QACA,8FAA8F;QAC9F,WAAW;IACb,GACA,wBACE,2CACA;QACE,WAAW;QACX,SAAS,IAAM,UAAU,CAAC;aAC1B;IACF,GACA,iFAAiF;IACjF,SAAS,cAAe,gBAAgB;AAG9C","sources":["packages/data-sheet/src/components/editor-popup.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { Popover } from \"@blueprintjs/core\";\nimport styles from \"./main.module.sass\";\nimport { useRef, useState } from \"react\";\nimport { useSelector } from \"../provider\";\n\nconst h = hyper.styled(styles);\n\nexport function EditorPopup(props) {\n const {\n children,\n targetClassName,\n autoFocus,\n valueViewer,\n minimal = true,\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.bp5-table-cell\", valueViewer),\n h(\"input.hidden-editor\", {\n value: \"\",\n autoFocus: true,\n onKeyDown: keyHandler,\n }),\n ]);\n\n return h(\n Popover,\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 minimal,\n modifiers: {\n offset: { enabled: true, options: { offset: [0, 8] } },\n },\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.bp5-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":[],"version":3,"file":"data-sheet.6776e250.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;AAGA;;;;;;;;;AAQA;;;;AAII;;;;;;;AAOA;;;;;;;;;;;AASF;;;;;;;;;;;;AAmBA;;;;;;;AAMA;;;;;;;;;AAWA","sources":["packages/data-sheet/src/components/main.module.sass"],"sourcesContent":[".interaction-barrier\n pointer-events: all\n\n.editor-popup-target\n position: absolute\n display: block\n top: 0\n left: 0\n width: 100%\n height: 100%\n\n.editable-text-area\n position: relative\n\n textarea\n min-width: var(--data-editor-width, 15em)\n min-height: var(--data-editor-height, 10em)\n font-family: inherit\n font-size: inherit\n\n .tools\n position: absolute\n top: 0.2em\n right: 0.2em\n transform: scale(0.8)\n\n.hidden-editor\n opacity: 0\n\n.editor-value\n position: absolute\n top: 0\n left: 0\n width: 100%\n height: 100%\n\n\n// Color picker\n.color-picker-container\n :global\n .react-colorful__saturation\n border-radius: 0\n\n .react-colorful__hue\n border-radius: 0\n\n\n.color-swatch\n width: 18px\n height: 18px\n display: inline-block\n margin-right: 0.5em\n\n.color-swatch-container\n position: absolute\n top: 0\n left: 0\n right: 0\n bottom: 0\n display: flex\n flex-direction: row\n align-items: center\n gap: 0.3em\n\n.color-name\n position: relative\n flex-grow: 1\n display: block\n"],"names":[],"version":3,"file":"data-sheet.91223ec6.css.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,qEAAK;AAOrB,IAAA,AAAK,mEAAA;;;;WAAA;;AAsBL,SAAS,0CAAa,KAAwB;IACnD,MAAM,QACJ,IAAI,cACJ,UAAU,qBACV,iBAAiB,YACjB,WAAW,8BACX,yBAAyB,0BACzB,oBAAoB,2BACpB,qBAAqB,KACrB,GAAG,MACJ,GAAG;IAEJ,OAAO,wBACL,CAAA,GAAA,sBAAc,GACd,wBACE,CAAA,GAAA,yCAAgB,GAChB;cACE;oBACA;QACA,mBAAmB;gCACnB;4BACA;kBACA;QACA,GAAG,IAAI;IACT,GACA,wBAAE,kCAAY;QACZ,GAAG,IAAI;kBACP;gCACA;2BACA;IACF;AAGN;AAEA,SAAS,iCAAc,wBACrB,oBAAoB,0BACpB,sBAAsB,cACtB,UAAU,gBACV,YAAY,gBACZ,YAAY,WACZ,UAAU,yBACV,mBAAmB,yBACnB,iBAAiB,mBACjB,kBAAkB,eAClB,kBAC0B;IAC1B;;;;GAIC,GAED,oFAAoF;IACpF,gEAAgE;IAChE,MAAM,kBAAkB,CAAA,GAAA,yCAAU,EAAK,CAAC,QAAU,MAAM,SAAS;IAEjE,MAAM,OAAO,CAAA,GAAA,yCAAU,EAAE,CAAC,QAAU,MAAM,IAAI;IAC9C,MAAM,WAAW,CAAA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AA,sBAAc,GAAG;QACxB,wBAAE,CAAA,GAAA,iBAAS,GAAG;YACZ,MAAM;YACN,aAAa;mBACb;YACA,eAAc,KAAK;gBACjB,SAAS;YACX;QACF;QACA,wBACE,CAAA,GAAA,aAAK,GACL;YACE,MAAM;YACN;gBACE,MAAM,MAAM,SAAS;gBACrB,YAAY,MAAM;YACpB;QACF,GACA;KAEH;AACH;AAEA,SAAS;IACP,MAAM,SAAS,CAAA,GAAA,yCAAU,EAAE,CAAC,QAAU,MAAM,MAAM;IAClD,OAAO,wBACL,CAAA,GAAA,aAAK,GACL;QACE,MAAM;QACN,SAAS;IACX,GACA;AAEJ;AAEO,SAAS,0CAAS,YAAE,QAAQ,SAAE,KAAK,EAAE,GAAG,MAAM;IACnD,OAAO,wBACL,CAAA,GAAA,0DAAG,GACH;QACE,aAAa;QACb,GAAG,IAAI;IACT,GACA;AAEJ;AAIO,SAAS,yCAAgB,SAAS;IACvC,IAAI,aAAuB,EAAE;IAC7B,KAAK,MAAM,OAAO,UAAW;QAC3B,kCAAkC;QAClC,IAAI,IAAI,IAAI,IAAI,MAAM;QACtB,IAAI,IAAI,IAAI,IAAI,MAAM;QACtB,MAAM,CAAC,YAAY,SAAS,GAAG,IAAI,IAAI;QACvC,IAAK,IAAI,IAAI,YAAY,KAAK,UAAU,IACtC,WAAW,IAAI,CAAC;IAEpB;IACA,OAAO;AACT","sources":["packages/data-sheet/src/core.ts"],"sourcesContent":["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, DataSheetAction } from \"./components\";\nimport styles from \"./main.module.sass\";\nimport {\n DataSheetProvider,\n DataSheetProviderProps,\n DataSheetStore,\n singleFocusedCell,\n useSelector,\n useStoreAPI,\n VisibleCells,\n} from \"./provider\";\nimport { ColumnSpec } from \"./utils\";\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 defaultColumnWidth = 150,\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 defaultColumnWidth,\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 selectedRegions = 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?.(selectedRegions);\n }, [onDeleteRows, selectedRegions, 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(\"Selected regions\", selectedRegions);\n }, [selectedRegions]);\n\n const nDeletionCandidates = useMemo(\n () => getRowsToDelete(selectedRegions).length,\n [selectedRegions],\n );\n\n const columnWidths = useSelector((state) => state.columnWidths);\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 const children = useMemo(\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 [columnSpec, storeAPI, autoFocusEditor],\n );\n\n const onColumnWidthChanged = useSelector(\n (state) => state.onColumnWidthChanged,\n );\n\n const rowHeaderCellRenderer = useCallback(\n (rowIndex: number) => {\n let style = null;\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 [deletedRows],\n );\n\n const onKeyDown = useSelector((state) => state.tableKeyHandler);\n\n if (data == null) return null;\n\n return h(\"div.data-sheet-container\", { className, style }, [\n h.if(editable)(DataSheetEditToolbar, {\n onSaveData: _onSaveData,\n onDeleteRows: nDeletionCandidates > 0 ? _onDeleteRows : null,\n }),\n dataSheetActions,\n h(\n \"div.data-sheet-holder\",\n { onKeyDown },\n h(\n // @ts-expect-error\n Table2,\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n enableColumnReordering,\n //onColumnsReordered,\n focusedCell,\n selectedRegions,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths,\n onColumnWidthChanged,\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,\n },\n children,\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\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(\"input.hidden-input\", {\n autoFocus: true,\n onKeyDown: state.editorKeyHandler,\n });\n\n let cellContents: ReactNode = _renderedValue;\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(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n }),\n ],\n );\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(\"input.main-editor\", {\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange,\n onKeyDown: state.editorKeyHandler,\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 EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n h(col.dataEditor, {\n value,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n }),\n );\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 focusedCell,\n }),\n hiddenInput,\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":[],"version":3,"file":"data-sheet.ba9a1241.js.map"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./data-sheet.3680e59d.js";import{Cell as e}from"@blueprintjs/table";import{useInDarkMode as r}from"@macrostrat/ui-components";import o from"@macrostrat/hyper";import{getLuminanceAdjustedColorScheme as t,asChromaColor as a}from"@macrostrat/color-utils";import{HexColorPicker as l}from"react-colorful";import{useRef as n,useEffect as c}from"react";import{memoize as s}from"underscore";function i(e,r,o,t){Object.defineProperty(e,r,{get:o,set:t,enumerable:!0,configurable:!0})}var u,f=globalThis,p={},m={},d=f.parcelRequirea149;null==d&&((d=function(e){if(e in p)return p[e].exports;if(e in m){var r=m[e];delete m[e];var o={id:e,exports:{}};return p[e]=o,r.call(o.exports,o,o.exports),o.exports}var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}).register=function(e,r){m[e]=r},f.parcelRequirea149=d),d.register;var b={};i(b,"ColorCell",()=>x),i(b,"colorSwatchRenderer",()=>g),i(b,"ColorPicker",()=>k);var C=d("9wR9f");let h=o.styled(C&&C.__esModule?C.default:C);function x({value:o,children:t,style:a,intent:l,adjustLuminance:n=!0,...c}){let s=r(),i="var(--text-color)",u=o;if(n){let e=v(o,s,.05);null!=e&&(i=e.mainColor,u=e.backgroundColor)}return h(e,{...c,style:{color:i,backgroundColor:u,...a}},t)}function g(e){return h("span.color-swatch-container",[h("span.color-swatch",{style:{backgroundColor:e}}),h("span.color-name",e)])}let v=s(t);var y=((u=y||{}).HEX="hex",u.RGB="rgb",u.HSL="hsl",u.CSS="css",u);function k({value:e,onChange:r,type:o="css"}){let t,s=n(null);c(()=>{null!=s.current&&s.current.focus()},[]);try{t=a(e).hex()}catch{t="#aaaaaa"}return h("div.color-picker-container",{onKeyDown(e){console.log(e),"Escape"===e.key&&e.preventDefault()},ref:s,tabIndex:0},h(l,{color:t,onChange(e){r(a(e)[o]())}}))}export{x as ColorCell,g as colorSwatchRenderer,k as ColorPicker};
|
|
2
|
-
//# sourceMappingURL=data-sheet.171105c1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,2C,A,Q,Q,C,K,oB,A,Q,iB,C,K,2B,A,Q,M,mB,A,Q,mC,C,C,iB,C,K,yB,A,Q,kB,C,K,gB,A,Q,U,C,C,a,C,K,O,A,Q,W,C,K,Y,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,IC8DK,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,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,Y,I,G,E,E,sB,I,G,E,E,c,I,G,I,E,E,SAjDL,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAU,CAAA,MACxB,CAAK,CAAA,SACL,CAAQ,CAAA,MACR,CAAK,CAAA,OACL,CAAM,CAAA,gBACN,EAAkB,CAAA,CAAA,CAClB,GAAG,EACJ,EACC,IAAM,EAAW,AAAA,IAEb,EAAY,oBACZ,EAAkB,EAEtB,GAAI,EAAiB,CAEnB,IAAI,EAAS,EAAW,EAAO,EAAU,IAC3B,OAAV,IACF,EAAY,EAAO,SAAS,CAC5B,EAAkB,EAAO,eAAe,CAE5C,CAEA,OAAO,EACL,EACA,CACE,GAAG,CAAI,CACP,MAAO,CACL,MAAO,EACP,gBAAA,EACA,GAAG,CAAK,AACV,CACF,EACA,EAEJ,CAEO,SAAS,EAAoB,CAAK,EACvC,OAAO,EAAE,8BAA+B,CACtC,EAAE,oBAAqB,CACrB,MAAO,CAAE,gBAAiB,CAAM,CAClC,GACA,EAAE,kBAAmB,GACtB,CACH,CAEA,IAAM,EAAa,AAAA,EAAQ,GAE3B,IAAK,G,CAAA,EAAA,GAAA,CAAA,G,G,C,M,E,G,C,M,E,G,C,M,E,G,C,MAAA,GAOE,SAAS,EAAY,CAAA,MAC1B,CAAK,CAAA,SACL,CAAQ,CAAA,KACR,EAAA,KAAA,CACD,EACC,IAMI,EANE,EAAM,AAAA,EAAO,MACnB,AAAA,EAAU,KACW,MAAf,EAAI,OAAO,EACf,EAAI,OAAO,CAAC,KAAK,EACnB,EAAG,EAAE,EAGL,GAAI,CACF,EAAQ,AAAA,EAAc,GAAO,GAAG,EAClC,CAAE,KAAM,CACN,EAAQ,SACV,CACA,OAAO,EACL,6BACA,CACE,UAAU,CAAG,EACX,QAAQ,GAAG,CAAC,GACR,AAAY,WAAZ,EAAI,GAAG,EACT,EAAI,cAAc,EAEtB,EACA,IAAA,EACA,SAAU,CACZ,EACA,EAAE,EAAgB,CAChB,MAAA,EACA,SAAS,CAAK,EACZ,EAAS,AAAA,EAAc,EAAM,CAAC,EAAK,GACrC,CACF,GAEJ,Q,K,S,C,K,mB,C,K,W","sources":["<anon>","packages/data-sheet/src/components/colors.ts"],"sourcesContent":["import \"./data-sheet.3680e59d.js\";\nimport {Cell as $h9Up1$Cell} from \"@blueprintjs/table\";\nimport {useInDarkMode as $h9Up1$useInDarkMode} from \"@macrostrat/ui-components\";\nimport $h9Up1$macrostrathyper from \"@macrostrat/hyper\";\nimport {getLuminanceAdjustedColorScheme as $h9Up1$getLuminanceAdjustedColorScheme, asChromaColor as $h9Up1$asChromaColor} from \"@macrostrat/color-utils\";\nimport {HexColorPicker as $h9Up1$HexColorPicker} from \"react-colorful\";\nimport {useRef as $h9Up1$useRef, useEffect as $h9Up1$useEffect} from \"react\";\nimport {memoize as $h9Up1$memoize} from \"underscore\";\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 $827916362b958415$exports = {};\n\n$parcel$export($827916362b958415$exports, \"ColorCell\", () => $827916362b958415$export$24aecfe8a925020d);\n$parcel$export($827916362b958415$exports, \"colorSwatchRenderer\", () => $827916362b958415$export$e5f546a5ba915f1c);\n$parcel$export($827916362b958415$exports, \"ColorPicker\", () => $827916362b958415$export$9feb1bc2e5f1ccb3);\n\n\n\n\nvar $9wR9f = parcelRequire(\"9wR9f\");\n\n\n\n\nconst $827916362b958415$var$h = (0, $h9Up1$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wR9f))));\nfunction $827916362b958415$export$24aecfe8a925020d({ value: value, children: children, style: style, intent: intent, adjustLuminance: adjustLuminance = true, ...rest }) {\n const darkMode = (0, $h9Up1$useInDarkMode)();\n let mainColor = \"var(--text-color)\";\n let backgroundColor = value;\n if (adjustLuminance) {\n // If adjustLuminance is true, get the color scheme based on the value\n let colors = $827916362b958415$var$colorCombo(value, darkMode, 0.05);\n if (colors != null) {\n mainColor = colors.mainColor;\n backgroundColor = colors.backgroundColor;\n }\n }\n return $827916362b958415$var$h((0, $h9Up1$Cell), {\n ...rest,\n style: {\n color: mainColor,\n backgroundColor: backgroundColor,\n ...style\n }\n }, children);\n}\nfunction $827916362b958415$export$e5f546a5ba915f1c(value) {\n return $827916362b958415$var$h(\"span.color-swatch-container\", [\n $827916362b958415$var$h(\"span.color-swatch\", {\n style: {\n backgroundColor: value\n }\n }),\n $827916362b958415$var$h(\"span.color-name\", value)\n ]);\n}\nconst $827916362b958415$var$colorCombo = (0, $h9Up1$memoize)((0, $h9Up1$getLuminanceAdjustedColorScheme));\nvar $827916362b958415$var$ColorConversionType = /*#__PURE__*/ function(ColorConversionType) {\n ColorConversionType[\"HEX\"] = \"hex\";\n ColorConversionType[\"RGB\"] = \"rgb\";\n ColorConversionType[\"HSL\"] = \"hsl\";\n ColorConversionType[\"CSS\"] = \"css\";\n return ColorConversionType;\n}($827916362b958415$var$ColorConversionType || {});\nfunction $827916362b958415$export$9feb1bc2e5f1ccb3({ value: value, onChange: onChange, type: type = \"css\" }) {\n const ref = (0, $h9Up1$useRef)(null);\n (0, $h9Up1$useEffect)(()=>{\n if (ref.current == null) return;\n ref.current.focus();\n }, []);\n let color;\n try {\n color = (0, $h9Up1$asChromaColor)(value).hex();\n } catch {\n color = \"#aaaaaa\";\n }\n return $827916362b958415$var$h(\"div.color-picker-container\", {\n onKeyDown (evt) {\n console.log(evt);\n if (evt.key === \"Escape\") evt.preventDefault();\n },\n ref: ref,\n tabIndex: 0\n }, $827916362b958415$var$h((0, $h9Up1$HexColorPicker), {\n color: color,\n onChange (color) {\n onChange((0, $h9Up1$asChromaColor)(color)[type]());\n }\n }));\n}\n\n\nexport {$827916362b958415$export$24aecfe8a925020d as ColorCell, $827916362b958415$export$e5f546a5ba915f1c as colorSwatchRenderer, $827916362b958415$export$9feb1bc2e5f1ccb3 as ColorPicker};\n//# sourceMappingURL=data-sheet.171105c1.js.map\n","import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport {\n asChromaColor,\n getLuminanceAdjustedColorScheme,\n} from \"@macrostrat/color-utils\";\nimport { HexColorPicker } from \"react-colorful\";\nimport { useEffect, useRef } from \"react\";\nimport { memoize } from \"underscore\";\nimport main from \"../../../../.storybook/main\";\n\nconst h = hyper.styled(styles);\n\nexport function ColorCell({\n value,\n children,\n style,\n intent,\n adjustLuminance = true,\n ...rest\n}) {\n const darkMode = useInDarkMode();\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 return h(\n Cell,\n {\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\nenum ColorConversionType {\n HEX = \"hex\",\n RGB = \"rgb\",\n HSL = \"hsl\",\n CSS = \"css\",\n}\n\nexport function ColorPicker({\n value,\n onChange,\n type = ColorConversionType.CSS,\n}) {\n const ref = useRef(null);\n useEffect(() => {\n if (ref.current == null) return;\n ref.current.focus();\n }, []);\n\n let color: any;\n try {\n color = asChromaColor(value).hex();\n } catch {\n color = \"#aaaaaa\";\n }\n return h(\n \"div.color-picker-container\",\n {\n onKeyDown(evt) {\n console.log(evt);\n if (evt.key === \"Escape\") {\n evt.preventDefault();\n }\n },\n ref,\n tabIndex: 0,\n },\n h(HexColorPicker, {\n color,\n onChange(color) {\n onChange(asChromaColor(color)[type]());\n },\n }),\n );\n}\n"],"names":["Cell","$h9Up1$Cell","useInDarkMode","$h9Up1$useInDarkMode","$h9Up1$macrostrathyper","getLuminanceAdjustedColorScheme","$h9Up1$getLuminanceAdjustedColorScheme","asChromaColor","$h9Up1$asChromaColor","HexColorPicker","$h9Up1$HexColorPicker","useRef","$h9Up1$useRef","useEffect","$h9Up1$useEffect","memoize","$h9Up1$memoize","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","ColorConversionType","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$827916362b958415$exports","$827916362b958415$export$24aecfe8a925020d","$827916362b958415$export$e5f546a5ba915f1c","$827916362b958415$export$9feb1bc2e5f1ccb3","$9wR9f","$827916362b958415$var$h","styled","a","__esModule","default","value","children","style","intent","adjustLuminance","rest","darkMode","mainColor","backgroundColor","colors","$827916362b958415$var$colorCombo","color","$827916362b958415$var$ColorConversionType","onChange","type","ref","current","focus","hex","onKeyDown","evt","console","log","key","preventDefault","tabIndex","ColorCell","colorSwatchRenderer","ColorPicker"],"version":3,"file":"data-sheet.171105c1.js.map","sourceRoot":"../../../../"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"ACAA,+CAGA,gGAQA,6CAII,4JAOA,mG,gCASF,2E,+HAmBA,mFAMA,qHAWA","sources":["data-sheet.2f64274d.css","packages/data-sheet/src/components/main.module.sass"],"sourcesContent":[".interaction-barrier_c65904 {\n pointer-events: all;\n}\n\n.editor-popup-target_c65904 {\n width: 100%;\n height: 100%;\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n.editable-text-area_c65904 {\n position: relative;\n}\n\n.editable-text-area_c65904 textarea {\n min-width: var(--data-editor-width, 15em);\n min-height: var(--data-editor-height, 10em);\n font-family: inherit;\n font-size: inherit;\n}\n\n.editable-text-area_c65904 .tools_c65904 {\n position: absolute;\n top: .2em;\n right: .2em;\n transform: scale(.8);\n}\n\n.hidden-editor_c65904 {\n opacity: 0;\n}\n\n.editor-value_c65904 {\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n.color-picker-container_c65904 .react-colorful__saturation, .color-picker-container_c65904 .react-colorful__hue {\n border-radius: 0;\n}\n\n.color-swatch_c65904 {\n width: 18px;\n height: 18px;\n margin-right: .5em;\n display: inline-block;\n}\n\n.color-swatch-container_c65904 {\n flex-direction: row;\n align-items: center;\n gap: .3em;\n display: flex;\n position: absolute;\n inset: 0;\n}\n\n.color-name_c65904 {\n flex-grow: 1;\n display: block;\n position: relative;\n}\n/*# sourceMappingURL=data-sheet.2f64274d.css.map */\n",".interaction-barrier\n pointer-events: all\n\n.editor-popup-target\n position: absolute\n display: block\n top: 0\n left: 0\n width: 100%\n height: 100%\n\n.editable-text-area\n position: relative\n\n textarea\n min-width: var(--data-editor-width, 15em)\n min-height: var(--data-editor-height, 10em)\n font-family: inherit\n font-size: inherit\n\n .tools\n position: absolute\n top: 0.2em\n right: 0.2em\n transform: scale(0.8)\n\n.hidden-editor\n opacity: 0\n\n.editor-value\n position: absolute\n top: 0\n left: 0\n width: 100%\n height: 100%\n\n\n// Color picker\n.color-picker-container\n :global\n .react-colorful__saturation\n border-radius: 0\n\n .react-colorful__hue\n border-radius: 0\n\n\n.color-swatch\n width: 18px\n height: 18px\n display: inline-block\n margin-right: 0.5em\n\n.color-swatch-container\n position: absolute\n top: 0\n left: 0\n right: 0\n bottom: 0\n display: flex\n flex-direction: row\n align-items: center\n gap: 0.3em\n\n.color-name\n position: relative\n flex-grow: 1\n display: block\n"],"names":[],"version":3,"file":"data-sheet.2f64274d.css.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./data-sheet.c350336f.js";import"./data-sheet.f0223f39.js";import"./data-sheet.dffdda71.js";import{HotkeysProvider as e,ButtonGroup as t,Button as l,Intent as o,InputGroup as a}from"@blueprintjs/core";import{Column as n,RowHeaderCell as r,Table2 as s,Cell as i}from"@blueprintjs/table";import"@blueprintjs/table/lib/css/table.css";import u from"@macrostrat/hyper";import d from"immutability-helper";import{useMemo as c,useCallback as p,useEffect as f,useState as h}from"react";function b(e,t,l,o){Object.defineProperty(e,t,{get:l,set:o,enumerable:!0,configurable:!0})}var m,S=globalThis,C={},g={},w=S.parcelRequirea149;null==w&&((w=function(e){if(e in C)return C[e].exports;if(e in g){var t=g[e];delete g[e];var l={id:e,exports:{}};return C[e]=l,t.call(l.exports,l,l.exports),l.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,t){g[e]=t},S.parcelRequirea149=w),w.register;var v={};b(v,"DataSheetDensity",()=>$),b(v,"DataSheet",()=>E),b(v,"getRowsToDelete",()=>N),b(v,"BaseCell",()=>M),b(v,"ScrollToRowControl",()=>_),b(v,"Cell",()=>i);var R=w("gZfn5"),D=w("kwt8s"),y=w("kib2Q");let x=u.styled(D&&D.__esModule?D.default:D);var $=((m={}).HIGH="high",m.MEDIUM="medium",m.LOW="low",m);function E(t){let{data:l,columnSpec:o,columnSpecOptions:a,editable:n=!0,enableColumnReordering:r=!1,enableFocusedCell:s=!1,defaultColumnWidth:i=150,...u}=t;return x(e,x(y.DataSheetProvider,{data:l,columnSpec:o,columnSpecOptions:a,enableColumnReordering:r,defaultColumnWidth:i,editable:n,...u},x(H,{...u,editable:n,enableColumnReordering:r,enableFocusedCell:s})))}function H({onVisibleCellsChange:e,enableColumnReordering:t,onSaveData:l,onUpdateData:o,onDeleteRows:a,verbose:i=!1,dataSheetActions:u=null,enableFocusedCell:h,autoFocusEditor:b=!0,density:m="high"}){let S=(0,y.useSelector)(e=>e.selection),C=(0,y.useSelector)(e=>e.data),g=(0,y.useSelector)(e=>e.editable),w=(0,y.useSelector)(e=>e.deletedRows),v=(0,y.useSelector)(e=>e.focusedCell),D=(0,y.useSelector)(e=>e.tableRef),$=(0,y.useSelector)(e=>e.columnSpec),E=(0,y.useSelector)(e=>e.updatedData),H=(0,y.useSelector)(e=>e.setUpdatedData),_=(0,y.useSelector)(e=>e.onSelection),A=(0,y.useStoreAPI)(),T=c(()=>null==l?null:()=>{l(E,C),H([])},[E,C,l]),U=(0,y.useSelector)(e=>e.setVisibleCells),W=p(t=>{U(t),e?.(t)},[e,U]);p(()=>{H(e=>{let t=Math.max(e.length,C.length);return d(e,{[t]:{$set:{}}})})},[H]);let j=(0,y.useSelector)(e=>e.deleteSelectedRows),I=p(()=>{j(),a?.(S)},[a,S,j]);f(()=>{i&&console.log("Updated data",E)},[E]),f(()=>{o?.(E,C)},[o,C,E]),f(()=>{i&&console.log("Selected regions",S)},[S]);let O=c(()=>N(S).length,[S]),V=(0,y.useSelector)(e=>e.columnWidths),K=Math.max(E.length,C.length),P=`${m}-density`,G=20,B={"--data-sheet-row-height":"20px","--data-sheet-font-size":"12px"};"medium"===m?(G=24,B={"--data-sheet-row-height":"24px","--data-sheet-font-size":"14px"}):"low"===m&&(G=30,B={"--data-sheet-row-height":"30px","--data-sheet-font-size":"18px"});let z=c(()=>$.map((e,t)=>x(n,{name:e.name,cellRenderer:l=>(function(e,t,l,o,a=!0){let n=o.data,r=o.updatedData,s=o.deletedRows.has(e),i=n[e]??r[e],u=o.focusedCell,d=o.topLeftCell,c=o.onCellEdited;o.clearSelection;let p=r[e]?.[l.key]??n[e]?.[l.key],f=l.valueRenderer?.(p)??p,h=l.style??{};s&&(h={...h,opacity:.5,textDecoration:"line-through"}),u?.col===t&&u?.row;let b=(l.editable??o.editable)&&!s,m=d?.col===t&&d?.row===e;!b&&o.editable&&(h.color="var(--secondary-color)");let S=r[e]?.[l.key]!=null?"success":void 0;s&&(S="danger");let C=l.cellComponent??M,g=!!b&&(l.inlineEditor??!0);if(!m)return x(C,{intent:S,loading:null==i,value:p,style:h,isDeleted:s},f);let w=x("input.hidden-input",{autoFocus:!0,onKeyDown:o.editorKeyHandler}),v=f;if(!b)return null!=l.dataEditor&&(v=x(R.EditorPopup,{autoFocus:a,valueViewer:f},[x(l.dataEditor,{value:p})])),x(C,{intent:S,value:p,style:h},v);let D=null!=(0,y.singleFocusedCell)(o.selection),$=null;if("boolean"==typeof g){let t=p;("string"==typeof f||"number"==typeof f||null==f)&&(t=f),$=x("input.main-editor",{value:t??"",autoFocus:a,onChange:t=>{b&&p!==t.target.value&&c(e,l.key,t.target.value)},onKeyDown:o.editorKeyHandler})}else $=g;let E=null;return null!=l.dataEditor?(E="editor-cell",v=x(R.EditorPopup,{autoFocus:a,valueViewer:f},x(l.dataEditor,{value:p,onChange(e){b&&o.onSelectionEdited(e)}})),w=null):null!=$&&(v=$,E="input-cell",w=null),x(C,{intent:S,value:p,className:E,style:h},[v,x.if(b&&D)(k,{focusedCell:u}),w])})(l,t,e,A.getState(),b)})),[$,A,b]),L=(0,y.useSelector)(e=>e.onColumnWidthChanged),q=p(e=>{let t=null;return w.has(e)&&(t={opacity:.5,textDecoration:"line-through"}),x(r,{index:e,name:`${e+1}`,style:t})},[w]),Q=(0,y.useSelector)(e=>e.tableKeyHandler);return null==C?null:x("div.data-sheet-container",{className:P,style:B},[x.if(g)(F,{onSaveData:T,onDeleteRows:O>0?I:null}),u,x("div.data-sheet-holder",{onKeyDown:Q},x(s,{ref:D,numRows:K,className:"data-sheet",enableFocusedCell:h,enableColumnReordering:t,focusedCell:v,selectedRegions:S,defaultRowHeight:G,minRowHeight:G,columnWidths:V,onColumnWidthChanged:L,onSelection:_,cellRendererDependencies:[C,E,v,w],onVisibleCellsChange:W,rowHeaderCellRenderer:q},z))])}function k({focusedCell:e}){let t=(0,y.useSelector)(e=>e.onDragValue);return x("div.corner-drag-handle",{onMouseDown(l){t(e),l.preventDefault()}})}function F({onSaveData:e,onDeleteRows:a}){(0,y.useSelector)(e=>e.selection);let n=(0,y.useSelector)(e=>e.resetChanges),r=(0,y.useSelector)(e=>e.hasUpdates);return x("div.data-sheet-toolbar",[x(t,{minimal:!0},[x(A),x(l,{intent:o.DANGER,disabled:null==a,onClick(){a?.()}},"Delete")]),x("div.spacer"),x(t,[x(l,{intent:o.WARNING,disabled:!r,onClick:n},"Reset"),x.if(null!=e)(l,{intent:o.SUCCESS,icon:"floppy-disk",disabled:!r,onClick:e},"Save")])])}function _(){let[e,t]=h(""),o=(0,y.useSelector)(e=>e.scrollToRow);return x(R.DataSheetAction,[x(a,{type:"number",placeholder:"Row number",value:e,onValueChange(e){t(e)}}),x(l,{icon:"arrow-right",onClick(){o(parseInt(e)-1)}},"Scroll to row")])}function A(){return x(l,{icon:"plus",onClick:(0,y.useSelector)(e=>e.addRow)},"Add row")}function M({children:e,value:t,...l}){return x(i,{interactive:!0,...l},e)}function N(e){let t=[];for(let l of e){if(null!=l.cols||null==l.rows)continue;let[e,o]=l.rows;for(let l=e;l<=o;l++)t.push(l)}return t}export{$ as DataSheetDensity,E as DataSheet,N as getRowsToDelete,M as BaseCell,_ as ScrollToRowControl,i as Cell};
|
|
2
|
-
//# sourceMappingURL=data-sheet.6a663031.js.map
|
|
@@ -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,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I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,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.c350336f.js\";\nimport \"./data-sheet.f0223f39.js\";\nimport \"./data-sheet.dffdda71.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 {Column as $oH60h$Column, RowHeaderCell as $oH60h$RowHeaderCell, Table2 as $oH60h$Table2, 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, defaultColumnWidth: defaultColumnWidth = 150, ...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 defaultColumnWidth: defaultColumnWidth,\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 selectedRegions = (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?.(selectedRegions);\n }, [\n onDeleteRows,\n selectedRegions,\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(\"Selected regions\", selectedRegions);\n }, [\n selectedRegions\n ]);\n const nDeletionCandidates = (0, $oH60h$useMemo)(()=>$963b78d65282413b$export$222fa1b971ddc36(selectedRegions).length, [\n selectedRegions\n ]);\n const columnWidths = (0, $kib2Q.useSelector)((state)=>state.columnWidths);\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 const children = (0, $oH60h$useMemo)(()=>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 columnSpec,\n storeAPI,\n autoFocusEditor\n ]);\n const onColumnWidthChanged = (0, $kib2Q.useSelector)((state)=>state.onColumnWidthChanged);\n const rowHeaderCellRenderer = (0, $oH60h$useCallback)((rowIndex)=>{\n let style = null;\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 deletedRows\n ]);\n const onKeyDown = (0, $kib2Q.useSelector)((state)=>state.tableKeyHandler);\n if (data == null) return null;\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 onDeleteRows: nDeletionCandidates > 0 ? _onDeleteRows : null\n }),\n dataSheetActions,\n $963b78d65282413b$var$h(\"div.data-sheet-holder\", {\n onKeyDown: onKeyDown\n }, $963b78d65282413b$var$h(// @ts-expect-error\n (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: selectedRegions,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths: columnWidths,\n onColumnWidthChanged: onColumnWidthChanged,\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: rowHeaderCellRenderer\n }, children))\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 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 const editable = (col.editable ?? state.editable) && !isDeleted;\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 }, _renderedValue);\n // The rest is for the top-left cell of a selection or the focused cell\n // Hidden input to capture key events\n let hiddenInput = $963b78d65282413b$var$h(\"input.hidden-input\", {\n autoFocus: true,\n onKeyDown: state.editorKeyHandler\n });\n let cellContents = _renderedValue;\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 valueViewer: _renderedValue\n }, [\n $963b78d65282413b$var$h(col.dataEditor, {\n value: value\n })\n ]);\n return $963b78d65282413b$var$h(_Cell, {\n intent: intent,\n value: value,\n style: style\n }, cellContents);\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 const isSingleCellSelection = (0, $kib2Q.singleFocusedCell)(state.selection) != null;\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: state.editorKeyHandler\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((0, $gZfn5.EditorPopup), {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue\n }, $963b78d65282413b$var$h(col.dataEditor, {\n value: value,\n onChange (value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n }\n }));\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\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 hiddenInput\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.6a663031.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, DataSheetAction } from \"./components\";\nimport styles from \"./main.module.sass\";\nimport {\n DataSheetProvider,\n DataSheetProviderProps,\n DataSheetStore,\n singleFocusedCell,\n useSelector,\n useStoreAPI,\n VisibleCells,\n} from \"./provider\";\nimport { ColumnSpec } from \"./utils\";\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 defaultColumnWidth = 150,\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 defaultColumnWidth,\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 selectedRegions = 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?.(selectedRegions);\n }, [onDeleteRows, selectedRegions, 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(\"Selected regions\", selectedRegions);\n }, [selectedRegions]);\n\n const nDeletionCandidates = useMemo(\n () => getRowsToDelete(selectedRegions).length,\n [selectedRegions],\n );\n\n const columnWidths = useSelector((state) => state.columnWidths);\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 const children = useMemo(\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 [columnSpec, storeAPI, autoFocusEditor],\n );\n\n const onColumnWidthChanged = useSelector(\n (state) => state.onColumnWidthChanged,\n );\n\n const rowHeaderCellRenderer = useCallback(\n (rowIndex: number) => {\n let style = null;\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 [deletedRows],\n );\n\n const onKeyDown = useSelector((state) => state.tableKeyHandler);\n\n if (data == null) return null;\n\n return h(\"div.data-sheet-container\", { className, style }, [\n h.if(editable)(DataSheetEditToolbar, {\n onSaveData: _onSaveData,\n onDeleteRows: nDeletionCandidates > 0 ? _onDeleteRows : null,\n }),\n dataSheetActions,\n h(\n \"div.data-sheet-holder\",\n { onKeyDown },\n h(\n // @ts-expect-error\n Table2,\n {\n ref,\n numRows,\n className: \"data-sheet\",\n enableFocusedCell,\n enableColumnReordering,\n //onColumnsReordered,\n focusedCell,\n selectedRegions,\n defaultRowHeight: rowHeight,\n minRowHeight: rowHeight,\n columnWidths,\n onColumnWidthChanged,\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,\n },\n children,\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\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(\"input.hidden-input\", {\n autoFocus: true,\n onKeyDown: state.editorKeyHandler,\n });\n\n let cellContents: ReactNode = _renderedValue;\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(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n }),\n ],\n );\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(\"input.main-editor\", {\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange,\n onKeyDown: state.editorKeyHandler,\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 EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n h(col.dataEditor, {\n value,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n }),\n );\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 focusedCell,\n }),\n hiddenInput,\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","Column","$oH60h$Column","RowHeaderCell","$oH60h$RowHeaderCell","Table2","$oH60h$Table2","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","defaultColumnWidth","rest","DataSheetProvider","$963b78d65282413b$var$_DataSheet","onVisibleCellsChange","onSaveData","onUpdateData","onDeleteRows","verbose","dataSheetActions","autoFocusEditor","density","selectedRegions","useSelector","state","selection","deletedRows","focusedCell","ref","tableRef","updatedData","setUpdatedData","onSelection","storeAPI","useStoreAPI","_onSaveData","setVisibleCells","_onVisibleCellsChange","visibleCells","ix","Math","max","length","$set","deleteSelectedRows","_onDeleteRows","console","log","nDeletionCandidates","columnWidths","numRows","className","rowHeight","style","children","map","col","colIndex","name","cellRenderer","rowIndex","$963b78d65282413b$var$basicCellRenderer","isDeleted","has","row","_topLeftCell","topLeftCell","onCellEdited","clearSelection","value","key","_renderedValue","valueRenderer","opacity","textDecoration","topLeft","color","intent","edited","undefined","_Cell","cellComponent","inlineEditor","loading","hiddenInput","autoFocus","onKeyDown","editorKeyHandler","cellContents","dataEditor","EditorPopup","valueViewer","isSingleCellSelection","singleFocusedCell","_inlineEditor","_value","onChange","target","onSelectionEdited","if","$963b78d65282413b$var$DragHandle","getState","onColumnWidthChanged","rowHeaderCellRenderer","index","tableKeyHandler","$963b78d65282413b$var$DataSheetEditToolbar","defaultRowHeight","minRowHeight","cellRendererDependencies","onDragValue","onMouseDown","preventDefault","resetChanges","hasUpdates","minimal","$963b78d65282413b$var$AddRowButton","DANGER","disabled","onClick","WARNING","SUCCESS","icon","setValue","scrollToRow","DataSheetAction","type","placeholder","onValueChange","parseInt","addRow","interactive","rowIndices","sel","cols","rows","startIndex","endIndex","i","push","DataSheet","getRowsToDelete","BaseCell","ScrollToRowControl"],"version":3,"file":"data-sheet.6a663031.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./data-sheet.3680e59d.js";import"./data-sheet.dffdda71.js";import e from"@macrostrat/hyper";import{ErrorBoundary as r}from"@macrostrat/ui-components";import{Popover as t}from"@blueprintjs/core";import{useState as o,useRef as a}from"react";var i=globalThis,n={},s={},l=i.parcelRequirea149;null==l&&((l=function(e){if(e in n)return n[e].exports;if(e in s){var r=s[e];delete s[e];var t={id:e,exports:{}};return n[e]=t,r.call(t.exports,t,t.exports),t.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,r){s[e]=r},i.parcelRequirea149=l),l.register,Object.defineProperty({},"EditorPopup",{get:()=>d,set:void 0,enumerable:!0,configurable:!0});var p=l("9wR9f"),u=l("kib2Q");let c=e.styled(p&&p.__esModule?p.default:p);function d(e){let{children:i,targetClassName:n,autoFocus:s,valueViewer:l,minimal:p=!0}=e,[d,f]=o(s),m=(0,u.useSelector)(e=>e.keyHandler),v=a(null),b=c([c("span.editor-value.bp5-table-cell",l),c("input.hidden-editor",{value:"",autoFocus:!0,onKeyDown:m})]);return c(t,{content:c("div.interaction-barrier",{onMouseDown(e){e.nativeEvent.stopImmediatePropagation()},onKeyDown(e){if("Escape"===e.key){d&&f(!1),e.stopPropagation(),e.preventDefault();return}}},c(r,null,i)),enforceFocus:!1,autoFocus:!1,minimal:p,modifiers:{offset:{enabled:!0,options:{offset:[0,8]}}},interactionKind:"hover-target",isOpen:d,usePortal:!0},c("span.editor-popup-target.bp5-table-cell",{className:n,onClick:()=>f(!d),ref:v},d?l:b??l))}export{d as EditorPopup};
|
|
2
|
-
//# sourceMappingURL=data-sheet.809cdb29.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,2C,A,O,2C,A,Q,M,mB,A,Q,iB,C,K,2B,A,Q,W,C,K,mB,A,Q,Y,C,C,U,C,K,O,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,O,c,C,C,E,c,C,I,I,E,I,K,E,W,C,E,a,C,C,G,I,E,E,S,E,E,SCOA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAY,CAAK,EAC/B,GAAM,CAAA,SACJ,CAAQ,CAAA,gBACR,CAAe,CAAA,UACf,CAAS,CAAA,YACT,CAAW,CAAA,QACX,EAAU,CAAA,CAAA,CACX,CAAG,EAEE,CAAC,EAAQ,EAAU,CAAG,AAAA,EAAS,GAC/B,EAAa,AAAA,CAAA,EAAA,EAAA,WAAU,AAAV,EAAY,AAAC,GAAU,EAAM,UAAU,EAEpD,EAAM,AAAA,EAAO,MAEb,EAAe,EAAE,CACrB,EAAE,mCAAoC,GACtC,EAAE,sBAAuB,CACvB,MAAO,GACP,UAAW,CAAA,EACX,UAAW,CACb,GACD,EAED,OAAO,EACL,EACA,CACE,QAAS,EACP,0BACA,CACE,YAAY,CAAG,EACb,EAAI,WAAW,CAAC,wBAAwB,EAC1C,EACA,UAAU,CAAG,EACX,GAAI,AAAY,WAAZ,EAAI,GAAG,CAAe,CACpB,GACF,EAAU,CAAA,GAEZ,EAAI,eAAe,GACnB,EAAI,cAAc,GAClB,MACF,CAEF,CACF,EACA,EAAE,EAAe,KAAM,IAEzB,aAAc,CAAA,EACd,UAAW,CAAA,EACX,QAAA,EACA,UAAW,CACT,OAAQ,CAAE,QAAS,CAAA,EAAM,QAAS,CAAE,OAAQ,CAAC,EAAG,EAAE,AAAC,CAAE,CACvD,EACA,gBAAiB,eACjB,OAAA,EAEA,UAAW,CAAA,CACb,EACA,EACE,0CACA,CACE,UAAW,EACX,QAAS,IAAM,EAAU,CAAC,GAC1B,IAAA,CACF,EAEA,EAAS,EAAe,GAAgB,GAG9C,Q,K,W","sources":["<anon>","packages/data-sheet/src/components/editor-popup.ts"],"sourcesContent":["import \"./data-sheet.3680e59d.js\";\nimport \"./data-sheet.dffdda71.js\";\nimport $46X05$macrostrathyper from \"@macrostrat/hyper\";\nimport {ErrorBoundary as $46X05$ErrorBoundary} from \"@macrostrat/ui-components\";\nimport {Popover as $46X05$Popover} from \"@blueprintjs/core\";\nimport {useState as $46X05$useState, useRef as $46X05$useRef} 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 $36eead336b938625$exports = {};\n\n$parcel$export($36eead336b938625$exports, \"EditorPopup\", () => $36eead336b938625$export$2a7e60c8443c1751);\n\n\n\n\nvar $9wR9f = parcelRequire(\"9wR9f\");\n\n\nvar $kib2Q = parcelRequire(\"kib2Q\");\nconst $36eead336b938625$var$h = (0, $46X05$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wR9f))));\nfunction $36eead336b938625$export$2a7e60c8443c1751(props) {\n const { children: children, targetClassName: targetClassName, autoFocus: autoFocus, valueViewer: valueViewer, minimal: minimal = true } = props;\n const [isOpen, setIsOpen] = (0, $46X05$useState)(autoFocus);\n const keyHandler = (0, $kib2Q.useSelector)((state)=>state.keyHandler);\n const ref = (0, $46X05$useRef)(null);\n const inlineEditor = $36eead336b938625$var$h([\n $36eead336b938625$var$h(\"span.editor-value.bp5-table-cell\", valueViewer),\n $36eead336b938625$var$h(\"input.hidden-editor\", {\n value: \"\",\n autoFocus: true,\n onKeyDown: keyHandler\n })\n ]);\n return $36eead336b938625$var$h((0, $46X05$Popover), {\n content: $36eead336b938625$var$h(\"div.interaction-barrier\", {\n onMouseDown (evt) {\n evt.nativeEvent.stopImmediatePropagation();\n },\n onKeyDown (evt) {\n if (evt.key === \"Escape\") {\n if (isOpen) setIsOpen(false);\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 }, $36eead336b938625$var$h((0, $46X05$ErrorBoundary), null, children)),\n enforceFocus: false,\n autoFocus: false,\n minimal: minimal,\n modifiers: {\n offset: {\n enabled: true,\n options: {\n offset: [\n 0,\n 8\n ]\n }\n }\n },\n interactionKind: \"hover-target\",\n isOpen: isOpen,\n // Portal must be used to avoid issues with the editor being clipped to the bounds of the cell\n usePortal: true\n }, $36eead336b938625$var$h(\"span.editor-popup-target.bp5-table-cell\", {\n className: targetClassName,\n onClick: ()=>setIsOpen(!isOpen),\n ref: ref\n }, // If the editor is open, show the inline editor, otherwise show the value viewer\n isOpen ? valueViewer : inlineEditor ?? valueViewer));\n}\n\n\nexport {$36eead336b938625$export$2a7e60c8443c1751 as EditorPopup};\n//# sourceMappingURL=data-sheet.809cdb29.js.map\n","import hyper from \"@macrostrat/hyper\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { Popover } from \"@blueprintjs/core\";\nimport styles from \"./main.module.sass\";\nimport { useRef, useState } from \"react\";\nimport { useSelector } from \"../provider\";\n\nconst h = hyper.styled(styles);\n\nexport function EditorPopup(props) {\n const {\n children,\n targetClassName,\n autoFocus,\n valueViewer,\n minimal = true,\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.bp5-table-cell\", valueViewer),\n h(\"input.hidden-editor\", {\n value: \"\",\n autoFocus: true,\n onKeyDown: keyHandler,\n }),\n ]);\n\n return h(\n Popover,\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 minimal,\n modifiers: {\n offset: { enabled: true, options: { offset: [0, 8] } },\n },\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.bp5-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":["$46X05$macrostrathyper","ErrorBoundary","$46X05$ErrorBoundary","Popover","$46X05$Popover","useState","$46X05$useState","useRef","$46X05$useRef","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","Object","defineProperty","get","$36eead336b938625$export$2a7e60c8443c1751","set","s","enumerable","configurable","$9wR9f","$kib2Q","$36eead336b938625$var$h","styled","a","__esModule","default","props","children","targetClassName","autoFocus","valueViewer","minimal","isOpen","setIsOpen","keyHandler","useSelector","state","ref","inlineEditor","value","onKeyDown","content","onMouseDown","evt","nativeEvent","stopImmediatePropagation","key","stopPropagation","preventDefault","enforceFocus","modifiers","offset","enabled","options","interactionKind","usePortal","className","onClick","EditorPopup"],"version":3,"file":"data-sheet.809cdb29.js.map","sourceRoot":"../../../../"}
|