@macrostrat/data-sheet 3.0.1 → 3.0.3
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 +17 -0
- package/dist/components/actions.js +2 -2
- package/dist/components/actions.js.map +1 -1
- package/dist/components/actions.module.sass.cjs +7 -2
- package/dist/components/actions.module.sass.cjs.map +1 -1
- package/dist/components/actions.module.sass.js +5 -2
- package/dist/components/actions.module.sass.js.map +1 -1
- package/dist/components/colors.cjs +1 -41
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.d.ts +2 -17
- package/dist/components/colors.js +5 -45
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.js +2 -2
- package/dist/components/editor-popup.js.map +1 -1
- package/dist/components/main.module.sass.cjs +15 -11
- package/dist/components/main.module.sass.cjs.map +1 -1
- package/dist/components/main.module.sass.js +13 -11
- package/dist/components/main.module.sass.js.map +1 -1
- package/dist/components/text-areas.js +2 -2
- package/dist/components/text-areas.js.map +1 -1
- package/dist/core.js +2 -2
- package/dist/core.js.map +1 -1
- package/dist/data-sheet.css +10 -14
- package/dist/main.module.sass.cjs +6 -1
- package/dist/main.module.sass.cjs.map +1 -1
- package/dist/main.module.sass.js +4 -1
- package/dist/main.module.sass.js.map +1 -1
- package/dist/postgrest-table/index.js +2 -2
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/postgrest-table/main.module.sass.cjs +6 -1
- package/dist/postgrest-table/main.module.sass.cjs.map +1 -1
- package/dist/postgrest-table/main.module.sass.js +4 -1
- package/dist/postgrest-table/main.module.sass.js.map +1 -1
- package/package.json +17 -14
- package/src/components/colors.ts +4 -54
- package/src/components/main.module.sass +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.0.3] - 2026-04-04 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/data-sheet-v3.0.2...@macrostrat/data-sheet-v3.0.3)
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated [BlueprintJS](https://blueprintjs.com) dependencies to latest `6.x.x`
|
|
8
|
+
series
|
|
9
|
+
[fa23ec06](https://github.com/UW-Macrostrat/web-components/commit/fa23ec06a42fefa638f1b95bdb68473f2fc9615b)
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
[fa23ec06](https://github.com/UW-Macrostrat/web-components/commit/fa23ec06a42fefa638f1b95bdb68473f2fc9615b)
|
|
12
|
+
- @macrostrat/data-components@1.1.4
|
|
13
|
+
- @macrostrat/ui-components@5.0.6
|
|
14
|
+
|
|
3
15
|
All notable changes to this project will be documented in this file. The format
|
|
4
16
|
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
|
|
5
17
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
18
|
|
|
19
|
+
## [3.0.2] - 2026-01-29
|
|
20
|
+
|
|
21
|
+
- Change layout of `package.json` and remove `@uiw/react-color` dependency in
|
|
22
|
+
favor of `@macrostrat/ui-components` color picker
|
|
23
|
+
|
|
7
24
|
## [3.0.1] - 2026-01-28
|
|
8
25
|
|
|
9
26
|
Update handling of `@uiw/react-color` dependency
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import hyper from "@macrostrat/hyper";
|
|
2
|
-
import
|
|
3
|
-
const h = hyper.styled(
|
|
2
|
+
import h$1 from "./actions.module.sass.js";
|
|
3
|
+
const h = hyper.styled(h$1);
|
|
4
4
|
function DataSheetActionsRow(props) {
|
|
5
5
|
return h("div.table-actions", props.children);
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sources":["../../src/components/actions.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport style from \"./actions.module.sass\";\nconst h = hyper.styled(style);\n\nexport function DataSheetActionsRow(props) {\n return h(\"div.table-actions\", props.children);\n}\n\nexport function DataSheetAction(props) {\n return h(\"div.table-action\", props.children);\n}\n"],"names":[],"mappings":";;AAEA,MAAM,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"actions.js","sources":["../../src/components/actions.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport style from \"./actions.module.sass\";\nconst h = hyper.styled(style);\n\nexport function DataSheetActionsRow(props) {\n return h(\"div.table-actions\", props.children);\n}\n\nexport function DataSheetAction(props) {\n return h(\"div.table-action\", props.children);\n}\n"],"names":["style"],"mappings":";;AAEA,MAAM,IAAI,MAAM,OAAOA,GAAK;AAErB,SAAS,oBAAoB,OAAO;AACzC,SAAO,EAAE,qBAAqB,MAAM,QAAQ;AAC9C;AAEO,SAAS,gBAAgB,OAAO;AACrC,SAAO,EAAE,oBAAoB,MAAM,QAAQ;AAC7C;"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const hyper = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
5
|
+
const styles = {
|
|
3
6
|
"table-actions": "_table-actions_1xz9a_1",
|
|
4
7
|
"table-action": "_table-action_1xz9a_1"
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
let h = hyper__default.default.styled(styles);
|
|
10
|
+
Object.assign(h, styles);
|
|
11
|
+
module.exports = h;
|
|
7
12
|
//# sourceMappingURL=actions.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import hyper from "@macrostrat/hyper";
|
|
2
|
+
const styles = {
|
|
2
3
|
"table-actions": "_table-actions_1xz9a_1",
|
|
3
4
|
"table-action": "_table-action_1xz9a_1"
|
|
4
5
|
};
|
|
6
|
+
let h = hyper.styled(styles);
|
|
7
|
+
Object.assign(h, styles);
|
|
5
8
|
export {
|
|
6
|
-
|
|
9
|
+
h as default
|
|
7
10
|
};
|
|
8
11
|
//# sourceMappingURL=actions.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -5,13 +5,12 @@ const uiComponents = require("@macrostrat/ui-components");
|
|
|
5
5
|
const hyper = require("@macrostrat/hyper");
|
|
6
6
|
const main_module = require("./main.module.sass.cjs");
|
|
7
7
|
const colorUtils = require("@macrostrat/color-utils");
|
|
8
|
-
const react = require("react");
|
|
9
8
|
const underscore = require("underscore");
|
|
10
|
-
const reactColor = require("@uiw/react-color");
|
|
11
9
|
const classNames = require("classnames");
|
|
12
10
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
13
11
|
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
14
12
|
const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
|
|
13
|
+
const ColorPicker = uiComponents.ColorPicker2;
|
|
15
14
|
const h = hyper__default.default.styled(main_module.default);
|
|
16
15
|
function ColorCell({
|
|
17
16
|
value,
|
|
@@ -60,45 +59,6 @@ function colorSwatchRenderer(value) {
|
|
|
60
59
|
]);
|
|
61
60
|
}
|
|
62
61
|
const colorCombo = underscore.memoize(colorUtils.getLuminanceAdjustedColorScheme);
|
|
63
|
-
function ColorPicker({
|
|
64
|
-
value,
|
|
65
|
-
onChange,
|
|
66
|
-
editable = true,
|
|
67
|
-
type = "css"
|
|
68
|
-
/* CSS */
|
|
69
|
-
}) {
|
|
70
|
-
const ref = react.useRef(null);
|
|
71
|
-
react.useEffect(() => {
|
|
72
|
-
if (ref.current == null) return;
|
|
73
|
-
ref.current.focus();
|
|
74
|
-
}, []);
|
|
75
|
-
const color = react.useMemo(() => {
|
|
76
|
-
try {
|
|
77
|
-
return colorUtils.asChromaColor(value).hex();
|
|
78
|
-
} catch {
|
|
79
|
-
return "#aaaaaa";
|
|
80
|
-
}
|
|
81
|
-
}, [value]);
|
|
82
|
-
return h(
|
|
83
|
-
"div.color-picker-container",
|
|
84
|
-
{
|
|
85
|
-
onKeyDown(evt) {
|
|
86
|
-
if (evt.key === "Escape") {
|
|
87
|
-
evt.preventDefault();
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
ref,
|
|
91
|
-
tabIndex: 0
|
|
92
|
-
},
|
|
93
|
-
h(reactColor.Sketch, {
|
|
94
|
-
color,
|
|
95
|
-
disableAlpha: true,
|
|
96
|
-
onChange(color2) {
|
|
97
|
-
onChange(colorUtils.asChromaColor(color2.hexa)[type]());
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
62
|
exports.ColorCell = ColorCell;
|
|
103
63
|
exports.ColorPicker = ColorPicker;
|
|
104
64
|
exports.colorSwatchRenderer = colorSwatchRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.cjs","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"colors.cjs","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { getLuminanceAdjustedColorScheme } from \"@macrostrat/color-utils\";\nimport { memoize } from \"underscore\";\nimport classNames from \"classnames\";\nimport { ColorPicker2 } from \"@macrostrat/ui-components\";\n\nexport const ColorPicker = ColorPicker2;\n\nconst h = hyper.styled(styles);\n\nexport function ColorCell({\n value,\n children,\n style,\n intent,\n adjustLuminance = true,\n className,\n ...rest\n}) {\n const darkMode = useInDarkMode();\n\n const _className = classNames(className, \"color-cell\");\n\n let mainColor = \"var(--text-color)\";\n let backgroundColor = value;\n\n if (adjustLuminance) {\n // If adjustLuminance is true, get the color scheme based on the value\n let colors = colorCombo(value, darkMode, 0.05);\n if (colors != null) {\n mainColor = colors.mainColor;\n backgroundColor = colors.backgroundColor;\n }\n }\n\n if (intent != null) {\n // If an intent is specified, override the main color\n mainColor = undefined;\n }\n\n return h(\n Cell,\n {\n intent,\n className: _className,\n ...rest,\n style: {\n color: mainColor,\n backgroundColor,\n ...style,\n },\n },\n children,\n );\n}\n\nexport function colorSwatchRenderer(value) {\n return h(\"span.color-swatch-container\", [\n h(\"span.color-swatch\", {\n style: { backgroundColor: value },\n }),\n h(\"span.color-name\", value),\n ]);\n}\n\nconst colorCombo = memoize(getLuminanceAdjustedColorScheme);\n"],"names":["ColorPicker2","hyper","styles","useInDarkMode","classNames","Cell","memoize","getLuminanceAdjustedColorScheme"],"mappings":";;;;;;;;;;;;AASO,MAAM,cAAcA,aAAAA;AAE3B,MAAM,IAAIC,eAAAA,QAAM,OAAOC,mBAAM;AAEtB,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,WAAWC,aAAAA,cAAA;AAEjB,QAAM,aAAaC,oBAAAA,QAAW,WAAW,YAAY;AAErD,MAAI,YAAY;AAChB,MAAI,kBAAkB;AAEtB,MAAI,iBAAiB;AAEnB,QAAI,SAAS,WAAW,OAAO,UAAU,IAAI;AAC7C,QAAI,UAAU,MAAM;AAClB,kBAAY,OAAO;AACnB,wBAAkB,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,UAAU,MAAM;AAElB,gBAAY;AAAA,EACd;AAEA,SAAO;AAAA,IACLC,MAAAA;AAAAA,IACA;AAAA,MACE;AAAA,MACA,WAAW;AAAA,MACX,GAAG;AAAA,MACH,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,IACL;AAAA,IAEF;AAAA,EAAA;AAEJ;AAEO,SAAS,oBAAoB,OAAO;AACzC,SAAO,EAAE,+BAA+B;AAAA,IACtC,EAAE,qBAAqB;AAAA,MACrB,OAAO,EAAE,iBAAiB,MAAA;AAAA,IAAM,CACjC;AAAA,IACD,EAAE,mBAAmB,KAAK;AAAA,EAAA,CAC3B;AACH;AAEA,MAAM,aAAaC,WAAAA,QAAQC,0CAA+B;;;;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ColorPicker2 } from '@macrostrat/ui-components';
|
|
2
|
+
export declare const ColorPicker: typeof ColorPicker2;
|
|
1
3
|
export declare function ColorCell({ value, children, style, intent, adjustLuminance, className, ...rest }: {
|
|
2
4
|
[x: string]: any;
|
|
3
5
|
value: any;
|
|
@@ -8,20 +10,3 @@ export declare function ColorCell({ value, children, style, intent, adjustLumina
|
|
|
8
10
|
className: any;
|
|
9
11
|
}): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
10
12
|
export declare function colorSwatchRenderer(value: any): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
|
|
11
|
-
declare enum ColorConversionType {
|
|
12
|
-
HEX = "hex",
|
|
13
|
-
RGB = "rgb",
|
|
14
|
-
HSL = "hsl",
|
|
15
|
-
CSS = "css"
|
|
16
|
-
}
|
|
17
|
-
export declare function ColorPicker({ value, onChange, editable, type, }: {
|
|
18
|
-
value: any;
|
|
19
|
-
onChange: any;
|
|
20
|
-
editable?: boolean;
|
|
21
|
-
type?: ColorConversionType;
|
|
22
|
-
}): import('react').DOMElement<{
|
|
23
|
-
onKeyDown(evt: import('react').KeyboardEvent<any>): void;
|
|
24
|
-
ref: import('react').MutableRefObject<any>;
|
|
25
|
-
tabIndex: number;
|
|
26
|
-
}, any>;
|
|
27
|
-
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Cell } from "@blueprintjs/table";
|
|
2
|
-
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
2
|
+
import { ColorPicker2, useInDarkMode } from "@macrostrat/ui-components";
|
|
3
3
|
import hyper from "@macrostrat/hyper";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { useRef, useEffect, useMemo } from "react";
|
|
4
|
+
import h$1 from "./main.module.sass.js";
|
|
5
|
+
import { getLuminanceAdjustedColorScheme } from "@macrostrat/color-utils";
|
|
7
6
|
import { memoize } from "underscore";
|
|
8
|
-
import { Sketch } from "@uiw/react-color";
|
|
9
7
|
import classNames from "classnames";
|
|
10
|
-
const
|
|
8
|
+
const ColorPicker = ColorPicker2;
|
|
9
|
+
const h = hyper.styled(h$1);
|
|
11
10
|
function ColorCell({
|
|
12
11
|
value,
|
|
13
12
|
children,
|
|
@@ -55,45 +54,6 @@ function colorSwatchRenderer(value) {
|
|
|
55
54
|
]);
|
|
56
55
|
}
|
|
57
56
|
const colorCombo = memoize(getLuminanceAdjustedColorScheme);
|
|
58
|
-
function ColorPicker({
|
|
59
|
-
value,
|
|
60
|
-
onChange,
|
|
61
|
-
editable = true,
|
|
62
|
-
type = "css"
|
|
63
|
-
/* CSS */
|
|
64
|
-
}) {
|
|
65
|
-
const ref = useRef(null);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (ref.current == null) return;
|
|
68
|
-
ref.current.focus();
|
|
69
|
-
}, []);
|
|
70
|
-
const color = useMemo(() => {
|
|
71
|
-
try {
|
|
72
|
-
return asChromaColor(value).hex();
|
|
73
|
-
} catch {
|
|
74
|
-
return "#aaaaaa";
|
|
75
|
-
}
|
|
76
|
-
}, [value]);
|
|
77
|
-
return h(
|
|
78
|
-
"div.color-picker-container",
|
|
79
|
-
{
|
|
80
|
-
onKeyDown(evt) {
|
|
81
|
-
if (evt.key === "Escape") {
|
|
82
|
-
evt.preventDefault();
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
ref,
|
|
86
|
-
tabIndex: 0
|
|
87
|
-
},
|
|
88
|
-
h(Sketch, {
|
|
89
|
-
color,
|
|
90
|
-
disableAlpha: true,
|
|
91
|
-
onChange(color2) {
|
|
92
|
-
onChange(asChromaColor(color2.hexa)[type]());
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
57
|
export {
|
|
98
58
|
ColorCell,
|
|
99
59
|
ColorPicker,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"colors.js","sources":["../../src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { getLuminanceAdjustedColorScheme } from \"@macrostrat/color-utils\";\nimport { memoize } from \"underscore\";\nimport classNames from \"classnames\";\nimport { ColorPicker2 } from \"@macrostrat/ui-components\";\n\nexport const ColorPicker = ColorPicker2;\n\nconst h = hyper.styled(styles);\n\nexport function ColorCell({\n value,\n children,\n style,\n intent,\n adjustLuminance = true,\n className,\n ...rest\n}) {\n const darkMode = useInDarkMode();\n\n const _className = classNames(className, \"color-cell\");\n\n let mainColor = \"var(--text-color)\";\n let backgroundColor = value;\n\n if (adjustLuminance) {\n // If adjustLuminance is true, get the color scheme based on the value\n let colors = colorCombo(value, darkMode, 0.05);\n if (colors != null) {\n mainColor = colors.mainColor;\n backgroundColor = colors.backgroundColor;\n }\n }\n\n if (intent != null) {\n // If an intent is specified, override the main color\n mainColor = undefined;\n }\n\n return h(\n Cell,\n {\n intent,\n className: _className,\n ...rest,\n style: {\n color: mainColor,\n backgroundColor,\n ...style,\n },\n },\n children,\n );\n}\n\nexport function colorSwatchRenderer(value) {\n return h(\"span.color-swatch-container\", [\n h(\"span.color-swatch\", {\n style: { backgroundColor: value },\n }),\n h(\"span.color-name\", value),\n ]);\n}\n\nconst colorCombo = memoize(getLuminanceAdjustedColorScheme);\n"],"names":["styles"],"mappings":";;;;;;;AASO,MAAM,cAAc;AAE3B,MAAM,IAAI,MAAM,OAAOA,GAAM;AAEtB,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,WAAW,cAAA;AAEjB,QAAM,aAAa,WAAW,WAAW,YAAY;AAErD,MAAI,YAAY;AAChB,MAAI,kBAAkB;AAEtB,MAAI,iBAAiB;AAEnB,QAAI,SAAS,WAAW,OAAO,UAAU,IAAI;AAC7C,QAAI,UAAU,MAAM;AAClB,kBAAY,OAAO;AACnB,wBAAkB,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,UAAU,MAAM;AAElB,gBAAY;AAAA,EACd;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA,WAAW;AAAA,MACX,GAAG;AAAA,MACH,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,GAAG;AAAA,MAAA;AAAA,IACL;AAAA,IAEF;AAAA,EAAA;AAEJ;AAEO,SAAS,oBAAoB,OAAO;AACzC,SAAO,EAAE,+BAA+B;AAAA,IACtC,EAAE,qBAAqB;AAAA,MACrB,OAAO,EAAE,iBAAiB,MAAA;AAAA,IAAM,CACjC;AAAA,IACD,EAAE,mBAAmB,KAAK;AAAA,EAAA,CAC3B;AACH;AAEA,MAAM,aAAa,QAAQ,+BAA+B;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import hyper from "@macrostrat/hyper";
|
|
2
2
|
import { ErrorBoundary } from "@macrostrat/ui-components";
|
|
3
3
|
import { Popover } from "@blueprintjs/core";
|
|
4
|
-
import
|
|
4
|
+
import h$1 from "./main.module.sass.js";
|
|
5
5
|
import { useState, useRef } from "react";
|
|
6
6
|
import { useSelector } from "../provider.js";
|
|
7
|
-
const h = hyper.styled(
|
|
7
|
+
const h = hyper.styled(h$1);
|
|
8
8
|
function EditorPopup(props) {
|
|
9
9
|
const {
|
|
10
10
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-popup.js","sources":["../../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 placement = \"right-start\",\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.bp6-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 placement,\n interactionKind: \"hover-target\",\n isOpen,\n // Portal must be used to avoid issues with the editor being clipped to the bounds of the cell\n usePortal: true,\n },\n h(\n \"span.editor-popup-target.bp6-table-cell\",\n {\n className: targetClassName,\n onClick: () => setIsOpen(!isOpen),\n ref,\n },\n // If the editor is open, show the inline editor, otherwise show the value viewer\n isOpen ? valueViewer : (inlineEditor ?? valueViewer),\n ),\n );\n}\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"editor-popup.js","sources":["../../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 placement = \"right-start\",\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.bp6-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 placement,\n interactionKind: \"hover-target\",\n isOpen,\n // Portal must be used to avoid issues with the editor being clipped to the bounds of the cell\n usePortal: true,\n },\n h(\n \"span.editor-popup-target.bp6-table-cell\",\n {\n className: targetClassName,\n onClick: () => setIsOpen(!isOpen),\n ref,\n },\n // If the editor is open, show the inline editor, otherwise show the value viewer\n isOpen ? valueViewer : (inlineEditor ?? valueViewer),\n ),\n );\n}\n"],"names":["styles"],"mappings":";;;;;;AAOA,MAAM,IAAI,MAAM,OAAOA,GAAM;AAEtB,SAAS,YAAY,OAAO;AACjC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA,IACR;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,SAAS;AAC9C,QAAM,aAAa,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,MAAM,OAAO,IAAI;AAEvB,QAAM,eAAe,EAAE;AAAA,IACrB,EAAE,oCAAoC,WAAW;AAAA,IACjD,EAAE,uBAAuB;AAAA,MACvB,OAAO;AAAA,MACP,WAAW;AAAA,MACX,WAAW;AAAA,IAAA,CACZ;AAAA,EAAA,CACF;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,SAAS;AAAA,QACP;AAAA,QACA;AAAA,UACE,YAAY,KAAK;AACf,gBAAI,YAAY,yBAAA;AAAA,UAClB;AAAA,UACA,UAAU,KAAK;AACb,gBAAI,IAAI,QAAQ,UAAU;AACxB,kBAAI,QAAQ;AACV,0BAAU,KAAK;AAAA,cACjB;AACA,kBAAI,gBAAA;AACJ,kBAAI,eAAA;AACJ;AAAA,YACF;AAAA,UAEF;AAAA,QAAA;AAAA,QAEF,EAAE,eAAe,MAAM,QAAQ;AAAA,MAAA;AAAA,MAEjC,cAAc;AAAA,MACd,WAAW;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,QAAQ,EAAE,SAAS,MAAM,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAA,EAAE;AAAA,MAAE;AAAA,MAEvD;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA;AAAA,MAEA,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,MACE;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,QAChC;AAAA,MAAA;AAAA;AAAA,MAGF,SAAS,cAAe,gBAAgB;AAAA,IAAA;AAAA,EAC1C;AAEJ;"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
3
|
+
const hyper = require("@macrostrat/hyper");
|
|
4
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
+
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
6
|
+
const tools = "_tools_utey8_23";
|
|
4
7
|
const styles = {
|
|
5
|
-
"interaction-barrier": "_interaction-
|
|
6
|
-
"editor-popup-target": "_editor-popup-
|
|
7
|
-
"editable-text-area": "_editable-text-
|
|
8
|
+
"interaction-barrier": "_interaction-barrier_utey8_1",
|
|
9
|
+
"editor-popup-target": "_editor-popup-target_utey8_5",
|
|
10
|
+
"editable-text-area": "_editable-text-area_utey8_14",
|
|
8
11
|
tools,
|
|
9
|
-
"hidden-editor": "_hidden-
|
|
10
|
-
"editor-value": "_editor-
|
|
11
|
-
"color-
|
|
12
|
-
"color-swatch": "_color-
|
|
13
|
-
"color-
|
|
14
|
-
"color-name": "_color-name_1gc88_65"
|
|
12
|
+
"hidden-editor": "_hidden-editor_utey8_30",
|
|
13
|
+
"editor-value": "_editor-value_utey8_34",
|
|
14
|
+
"color-swatch": "_color-swatch_utey8_42",
|
|
15
|
+
"color-swatch-container": "_color-swatch-container_utey8_49",
|
|
16
|
+
"color-name": "_color-name_utey8_61"
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
let h = hyper__default.default.styled(styles);
|
|
19
|
+
Object.assign(h, styles);
|
|
20
|
+
exports.default = h;
|
|
17
21
|
exports.tools = tools;
|
|
18
22
|
//# sourceMappingURL=main.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import hyper from "@macrostrat/hyper";
|
|
2
|
+
const tools = "_tools_utey8_23";
|
|
2
3
|
const styles = {
|
|
3
|
-
"interaction-barrier": "_interaction-
|
|
4
|
-
"editor-popup-target": "_editor-popup-
|
|
5
|
-
"editable-text-area": "_editable-text-
|
|
4
|
+
"interaction-barrier": "_interaction-barrier_utey8_1",
|
|
5
|
+
"editor-popup-target": "_editor-popup-target_utey8_5",
|
|
6
|
+
"editable-text-area": "_editable-text-area_utey8_14",
|
|
6
7
|
tools,
|
|
7
|
-
"hidden-editor": "_hidden-
|
|
8
|
-
"editor-value": "_editor-
|
|
9
|
-
"color-
|
|
10
|
-
"color-swatch": "_color-
|
|
11
|
-
"color-
|
|
12
|
-
"color-name": "_color-name_1gc88_65"
|
|
8
|
+
"hidden-editor": "_hidden-editor_utey8_30",
|
|
9
|
+
"editor-value": "_editor-value_utey8_34",
|
|
10
|
+
"color-swatch": "_color-swatch_utey8_42",
|
|
11
|
+
"color-swatch-container": "_color-swatch-container_utey8_49",
|
|
12
|
+
"color-name": "_color-name_utey8_61"
|
|
13
13
|
};
|
|
14
|
+
let h = hyper.styled(styles);
|
|
15
|
+
Object.assign(h, styles);
|
|
14
16
|
export {
|
|
15
|
-
|
|
17
|
+
h as default,
|
|
16
18
|
tools
|
|
17
19
|
};
|
|
18
20
|
//# sourceMappingURL=main.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import hyper from "@macrostrat/hyper";
|
|
2
|
-
import
|
|
2
|
+
import h$1 from "./main.module.sass.js";
|
|
3
3
|
import { Button } from "@blueprintjs/core";
|
|
4
4
|
import { useRef, useEffect } from "react";
|
|
5
5
|
import { multiLineTextKeyHandler } from "../utils/key-handling.js";
|
|
6
|
-
const h = hyper.styled(
|
|
6
|
+
const h = hyper.styled(h$1);
|
|
7
7
|
function EditableTextArea({ value, onChange }) {
|
|
8
8
|
const ref = useRef(null);
|
|
9
9
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-areas.js","sources":["../../src/components/text-areas.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useEffect, useRef } from \"react\";\nimport { multiLineTextKeyHandler } from \"../utils\";\n\nconst h = hyper.styled(styles);\n\nexport function EditableTextArea({ value, onChange }) {\n const ref = useRef(null);\n\n useEffect(() => {\n if (ref.current == null) return;\n ref.current.focus();\n // Get the current value\n const val = ref.current.value;\n // Move the cursor to the end of the text\n ref.current.setSelectionRange(val.length, val.length);\n }, []);\n\n return h(\"div.editable-text-area\", [\n h(\"textarea.bp6-input\", {\n ref,\n value: value ?? \"\",\n onChange: (evt) => onChange(evt.target.value),\n onKeyDown: multiLineTextKeyHandler,\n }),\n h(\"div.tools\", [\n h(Button, {\n icon: \"key-enter\",\n minimal: true,\n small: true,\n onClick() {\n // Get cursor position\n let _value = value ?? \"\";\n\n const cursorPos = ref.current.selectionStart ?? _value.length;\n // Insert a newline at the cursor position\n onChange(_value.slice(0, cursorPos) + \"\\n\" + _value.slice(cursorPos));\n // Re-focus the textarea\n ref.current.focus();\n // Move the cursor to the end of the line\n ref.current.setSelectionRange(cursorPos + 1, cursorPos + 1);\n },\n }),\n ]),\n ]);\n}\n"],"names":[],"mappings":";;;;;AAMA,MAAM,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"text-areas.js","sources":["../../src/components/text-areas.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useEffect, useRef } from \"react\";\nimport { multiLineTextKeyHandler } from \"../utils\";\n\nconst h = hyper.styled(styles);\n\nexport function EditableTextArea({ value, onChange }) {\n const ref = useRef(null);\n\n useEffect(() => {\n if (ref.current == null) return;\n ref.current.focus();\n // Get the current value\n const val = ref.current.value;\n // Move the cursor to the end of the text\n ref.current.setSelectionRange(val.length, val.length);\n }, []);\n\n return h(\"div.editable-text-area\", [\n h(\"textarea.bp6-input\", {\n ref,\n value: value ?? \"\",\n onChange: (evt) => onChange(evt.target.value),\n onKeyDown: multiLineTextKeyHandler,\n }),\n h(\"div.tools\", [\n h(Button, {\n icon: \"key-enter\",\n minimal: true,\n small: true,\n onClick() {\n // Get cursor position\n let _value = value ?? \"\";\n\n const cursorPos = ref.current.selectionStart ?? _value.length;\n // Insert a newline at the cursor position\n onChange(_value.slice(0, cursorPos) + \"\\n\" + _value.slice(cursorPos));\n // Re-focus the textarea\n ref.current.focus();\n // Move the cursor to the end of the line\n ref.current.setSelectionRange(cursorPos + 1, cursorPos + 1);\n },\n }),\n ]),\n ]);\n}\n"],"names":["styles"],"mappings":";;;;;AAMA,MAAM,IAAI,MAAM,OAAOA,GAAM;AAEtB,SAAS,iBAAiB,EAAE,OAAO,YAAY;AACpD,QAAM,MAAM,OAAO,IAAI;AAEvB,YAAU,MAAM;AACd,QAAI,IAAI,WAAW,KAAM;AACzB,QAAI,QAAQ,MAAA;AAEZ,UAAM,MAAM,IAAI,QAAQ;AAExB,QAAI,QAAQ,kBAAkB,IAAI,QAAQ,IAAI,MAAM;AAAA,EACtD,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,0BAA0B;AAAA,IACjC,EAAE,sBAAsB;AAAA,MACtB;AAAA,MACA,OAAO,SAAS;AAAA,MAChB,UAAU,CAAC,QAAQ,SAAS,IAAI,OAAO,KAAK;AAAA,MAC5C,WAAW;AAAA,IAAA,CACZ;AAAA,IACD,EAAE,aAAa;AAAA,MACb,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAER,cAAI,SAAS,SAAS;AAEtB,gBAAM,YAAY,IAAI,QAAQ,kBAAkB,OAAO;AAEvD,mBAAS,OAAO,MAAM,GAAG,SAAS,IAAI,OAAO,OAAO,MAAM,SAAS,CAAC;AAEpE,cAAI,QAAQ,MAAA;AAEZ,cAAI,QAAQ,kBAAkB,YAAY,GAAG,YAAY,CAAC;AAAA,QAC5D;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AACH;"}
|
package/dist/core.js
CHANGED
|
@@ -5,11 +5,11 @@ import { Cell as Cell2 } from "@blueprintjs/table";
|
|
|
5
5
|
import hyper from "@macrostrat/hyper";
|
|
6
6
|
import update from "immutability-helper";
|
|
7
7
|
import { useState, useMemo, useCallback, useEffect } from "react";
|
|
8
|
-
import
|
|
8
|
+
import h$1 from "./main.module.sass.js";
|
|
9
9
|
import { DataSheetProvider, useSelector, useStoreAPI, singleFocusedCell } from "./provider.js";
|
|
10
10
|
import { DataSheetAction } from "./components/actions.js";
|
|
11
11
|
import { EditorPopup } from "./components/editor-popup.js";
|
|
12
|
-
const h = hyper.styled(
|
|
12
|
+
const h = hyper.styled(h$1);
|
|
13
13
|
var DataSheetDensity = /* @__PURE__ */ ((DataSheetDensity2) => {
|
|
14
14
|
DataSheetDensity2["HIGH"] = "high";
|
|
15
15
|
DataSheetDensity2["MEDIUM"] = "medium";
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../src/core.ts"],"sourcesContent":["import {\n Button,\n ButtonGroup,\n HotkeysProvider,\n InputGroup,\n Intent,\n} from \"@blueprintjs/core\";\nimport { Cell, Column, Region, RowHeaderCell, Table } 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 Table,\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 let _dataEditor = null;\n let className = null;\n\n if (col.dataEditor != null) {\n _dataEditor = h(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n editable,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n }),\n ],\n );\n }\n\n if (!editable) {\n // Most cells are not focused and don't need to be editable.\n // This will be the rendering logic for almost all cells\n\n if (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n },\n cellContents,\n );\n // Could probably put the hidden input elsewhere,\n }\n\n /* The remaining logic covers cells that are focused and editable */\n\n const onChange = (e) => {\n if (!editable) return;\n if (value === e.target.value) return;\n onCellEdited(rowIndex, col.key, e.target.value);\n };\n\n const isSingleCellSelection = singleFocusedCell(state.selection) != null;\n\n let _inlineEditor: ReactNode = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (\n typeof _renderedValue === \"string\" ||\n typeof _renderedValue === \"number\" ||\n _renderedValue == null\n ) {\n _value = _renderedValue;\n }\n _inlineEditor = h(\"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 if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle, {\n 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":["DataSheetDensity","updatedData","style","value"],"mappings":";;;;;;;;;;;AAyBA,MAAM,IAAI,MAAM,OAAO,MAAM;AAOtB,IAAK,qCAAAA,sBAAL;AACLA,oBAAA,MAAA,IAAO;AACPA,oBAAA,QAAA,IAAS;AACTA,oBAAA,KAAA,IAAM;AAHI,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAsBL,SAAS,UAAa,OAA0B;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,yBAAyB;AAAA,IACzB,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,IACrB,GAAG;AAAA,EAAA,IACD;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,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AgB,WAAW;AACzC,MAAI,aAAuB,CAAA;AAC3B,aAAW,OAAO,WAAW;AAE3B,QAAI,IAAI,QAAQ,KAAM;AACtB,QAAI,IAAI,QAAQ,KAAM;AACtB,UAAM,CAAC,YAAY,QAAQ,IAAI,IAAI;AACnC,aAAS,IAAI,YAAY,KAAK,UAAU,KAAK;AAC3C,iBAAW,KAAK,CAAC;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;"}
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../src/core.ts"],"sourcesContent":["import {\n Button,\n ButtonGroup,\n HotkeysProvider,\n InputGroup,\n Intent,\n} from \"@blueprintjs/core\";\nimport { Cell, Column, Region, RowHeaderCell, Table } 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 Table,\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 let _dataEditor = null;\n let className = null;\n\n if (col.dataEditor != null) {\n _dataEditor = h(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n editable,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n }),\n ],\n );\n }\n\n if (!editable) {\n // Most cells are not focused and don't need to be editable.\n // This will be the rendering logic for almost all cells\n\n if (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n },\n cellContents,\n );\n // Could probably put the hidden input elsewhere,\n }\n\n /* The remaining logic covers cells that are focused and editable */\n\n const onChange = (e) => {\n if (!editable) return;\n if (value === e.target.value) return;\n onCellEdited(rowIndex, col.key, e.target.value);\n };\n\n const isSingleCellSelection = singleFocusedCell(state.selection) != null;\n\n let _inlineEditor: ReactNode = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (\n typeof _renderedValue === \"string\" ||\n typeof _renderedValue === \"number\" ||\n _renderedValue == null\n ) {\n _value = _renderedValue;\n }\n _inlineEditor = h(\"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 if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle, {\n 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":["styles","DataSheetDensity","updatedData","style","value"],"mappings":";;;;;;;;;;;AAyBA,MAAM,IAAI,MAAM,OAAOA,GAAM;AAOtB,IAAK,qCAAAC,sBAAL;AACLA,oBAAA,MAAA,IAAO;AACPA,oBAAA,QAAA,IAAS;AACTA,oBAAA,KAAA,IAAM;AAHI,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAsBL,SAAS,UAAa,OAA0B;AACrD,QAAM;AAAA,IACJ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AAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,EAAA;AAEJ;AAEO,SAAS,SAAS,EAAE,UAAU,OAAO,GAAG,QAAQ;AACrD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;AAIO,SAAS,gBAAgB,WAAW;AACzC,MAAI,aAAuB,CAAA;AAC3B,aAAW,OAAO,WAAW;AAE3B,QAAI,IAAI,QAAQ,KAAM;AACtB,QAAI,IAAI,QAAQ,KAAM;AACtB,UAAM,CAAC,YAAY,QAAQ,IAAI,IAAI;AACnC,aAAS,IAAI,YAAY,KAAK,UAAU,KAAK;AAC3C,iBAAW,KAAK,CAAC;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;"}
|
package/dist/data-sheet.css
CHANGED
|
@@ -1204,11 +1204,11 @@
|
|
|
1204
1204
|
._table-actions_1xz9a_1 {
|
|
1205
1205
|
margin-bottom: 0.5em;
|
|
1206
1206
|
gap: 1em;
|
|
1207
|
-
}._interaction-
|
|
1207
|
+
}._interaction-barrier_utey8_1 {
|
|
1208
1208
|
pointer-events: all;
|
|
1209
1209
|
}
|
|
1210
1210
|
|
|
1211
|
-
._editor-popup-
|
|
1211
|
+
._editor-popup-target_utey8_5 {
|
|
1212
1212
|
position: absolute;
|
|
1213
1213
|
display: block;
|
|
1214
1214
|
top: 0;
|
|
@@ -1217,27 +1217,27 @@
|
|
|
1217
1217
|
height: 100%;
|
|
1218
1218
|
}
|
|
1219
1219
|
|
|
1220
|
-
._editable-text-
|
|
1220
|
+
._editable-text-area_utey8_14 {
|
|
1221
1221
|
position: relative;
|
|
1222
1222
|
}
|
|
1223
|
-
._editable-text-
|
|
1223
|
+
._editable-text-area_utey8_14 textarea {
|
|
1224
1224
|
min-width: var(--data-editor-width, 15em);
|
|
1225
1225
|
min-height: var(--data-editor-height, 10em);
|
|
1226
1226
|
font-family: inherit;
|
|
1227
1227
|
font-size: inherit;
|
|
1228
1228
|
}
|
|
1229
|
-
._editable-text-
|
|
1229
|
+
._editable-text-area_utey8_14 ._tools_utey8_23 {
|
|
1230
1230
|
position: absolute;
|
|
1231
1231
|
top: 0.2em;
|
|
1232
1232
|
right: 0.2em;
|
|
1233
1233
|
transform: scale(0.8);
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
|
-
._hidden-
|
|
1236
|
+
._hidden-editor_utey8_30 {
|
|
1237
1237
|
opacity: 0;
|
|
1238
1238
|
}
|
|
1239
1239
|
|
|
1240
|
-
._editor-
|
|
1240
|
+
._editor-value_utey8_34 {
|
|
1241
1241
|
position: absolute;
|
|
1242
1242
|
top: 0;
|
|
1243
1243
|
left: 0;
|
|
@@ -1245,18 +1245,14 @@
|
|
|
1245
1245
|
height: 100%;
|
|
1246
1246
|
}
|
|
1247
1247
|
|
|
1248
|
-
._color-
|
|
1249
|
-
--sketch-background: var(--secondary-background) !important;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
._color-swatch_1gc88_46 {
|
|
1248
|
+
._color-swatch_utey8_42 {
|
|
1253
1249
|
width: 18px;
|
|
1254
1250
|
height: 18px;
|
|
1255
1251
|
display: inline-block;
|
|
1256
1252
|
margin-right: 0.5em;
|
|
1257
1253
|
}
|
|
1258
1254
|
|
|
1259
|
-
._color-swatch-
|
|
1255
|
+
._color-swatch-container_utey8_49 {
|
|
1260
1256
|
position: absolute;
|
|
1261
1257
|
top: 0;
|
|
1262
1258
|
left: 0;
|
|
@@ -1268,7 +1264,7 @@
|
|
|
1268
1264
|
gap: 0.3em;
|
|
1269
1265
|
}
|
|
1270
1266
|
|
|
1271
|
-
._color-
|
|
1267
|
+
._color-name_utey8_61 {
|
|
1272
1268
|
position: relative;
|
|
1273
1269
|
flex-grow: 1;
|
|
1274
1270
|
display: block;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const hyper = require("@macrostrat/hyper");
|
|
4
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
+
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
3
6
|
const spacer = "_spacer_tr5j5_94";
|
|
4
7
|
const styles = {
|
|
5
8
|
"data-sheet-container": "_data-sheet-container_tr5j5_1",
|
|
@@ -14,6 +17,8 @@ const styles = {
|
|
|
14
17
|
spacer,
|
|
15
18
|
"table-control": "_table-control_tr5j5_98"
|
|
16
19
|
};
|
|
17
|
-
|
|
20
|
+
let h = hyper__default.default.styled(styles);
|
|
21
|
+
Object.assign(h, styles);
|
|
22
|
+
exports.default = h;
|
|
18
23
|
exports.spacer = spacer;
|
|
19
24
|
//# sourceMappingURL=main.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.module.sass.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import hyper from "@macrostrat/hyper";
|
|
1
2
|
const spacer = "_spacer_tr5j5_94";
|
|
2
3
|
const styles = {
|
|
3
4
|
"data-sheet-container": "_data-sheet-container_tr5j5_1",
|
|
@@ -12,8 +13,10 @@ const styles = {
|
|
|
12
13
|
spacer,
|
|
13
14
|
"table-control": "_table-control_tr5j5_98"
|
|
14
15
|
};
|
|
16
|
+
let h = hyper.styled(styles);
|
|
17
|
+
Object.assign(h, styles);
|
|
15
18
|
export {
|
|
16
|
-
|
|
19
|
+
h as default,
|
|
17
20
|
spacer
|
|
18
21
|
};
|
|
19
22
|
//# sourceMappingURL=main.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { HotkeysProvider, InputGroup, Spinner } from "@blueprintjs/core";
|
|
2
2
|
import hyper from "@macrostrat/hyper";
|
|
3
|
-
import
|
|
3
|
+
import h$1 from "./main.module.sass.js";
|
|
4
4
|
import { DataSheet, getRowsToDelete } from "../core.js";
|
|
5
5
|
import { LithologyTag, Tag, TagSize } from "@macrostrat/data-components";
|
|
6
6
|
import { usePostgRESTLazyLoader } from "./data-loaders.js";
|
|
7
7
|
import { useState, useCallback } from "react";
|
|
8
8
|
import { ErrorBoundary, ToasterContext, useToaster, useAPIResult } from "@macrostrat/ui-components";
|
|
9
9
|
import { ColorCell } from "../components/colors.js";
|
|
10
|
-
const h = hyper.styled(
|
|
10
|
+
const h = hyper.styled(h$1);
|
|
11
11
|
function PostgRESTTableView(props) {
|
|
12
12
|
return h(
|
|
13
13
|
ErrorBoundary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/postgrest-table/index.ts"],"sourcesContent":["import { HotkeysProvider, OverlayToaster } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { DataSheet, getRowsToDelete } from \"../core\"; //getRowsToDelete\nimport { LithologyTag, Tag, TagSize } from \"@macrostrat/data-components\";\nimport { PostgrestOrder, usePostgRESTLazyLoader } from \"./data-loaders\";\nimport { Spinner, InputGroup } from \"@blueprintjs/core\";\n\nexport * from \"./data-loaders\";\nimport { useCallback, useState, useRef } from \"react\";\nimport {\n ErrorBoundary,\n ToasterContext,\n useAPIResult,\n useToaster,\n} from \"@macrostrat/ui-components\";\nimport { Spec } from \"immutability-helper\";\nimport { DataSheetProviderProps } from \"../provider\";\nimport { PostgrestFilterBuilder } from \"@supabase/postgrest-js\";\nimport type {\n GenericFunction,\n GenericTable,\n GenericView,\n} from \"@supabase/postgrest-js/dist/cjs/index\";\nimport { ColorCell } from \"../components\";\n\nconst h = hyper.styled(styles);\n\nexport type GenericSchema = {\n Tables: Record<string, GenericTable>;\n Views: Record<string, GenericView>;\n Functions: Record<string, GenericFunction>;\n};\n\ninterface PostgRESTTableViewProps<\n T extends object,\n> extends DataSheetProviderProps<T> {\n endpoint: string;\n table: string;\n columnOptions?: any;\n order?: PostgrestOrder<T>;\n columns?: string;\n editable?: boolean;\n identityKey?: string;\n enableFullTableSearch?: boolean;\n dataSheetActions?: any;\n filter(\n query: PostgrestFilterBuilder<T, any, any>,\n ): PostgrestFilterBuilder<T, any, any>;\n}\n\nexport function PostgRESTTableView<T>(props: PostgRESTTableViewProps<T>) {\n return h(\n ErrorBoundary,\n h(HotkeysProvider, h(ToasterContext, h(_PostgRESTTableView, props))),\n );\n}\n\nconst successResponses = [200, 201];\n\nfunction _PostgRESTTableView<T>({\n endpoint,\n table,\n columnOptions,\n order,\n columns,\n editable = false,\n filter = undefined,\n enableFullTableSearch = false,\n dataSheetActions,\n identityKey = \"id\",\n ...rest\n}: PostgRESTTableViewProps<T>) {\n const [input, setInput] = useState(\"\");\n\n if (enableFullTableSearch) {\n const columnList = columns ?? getColumnList(endpoint, table);\n\n filter = (query) => {\n const urlParams = new URLSearchParams(query.url.search);\n urlParams.delete(\"or\");\n query.url.search = urlParams.toString() ? `?${urlParams.toString()}` : \"\";\n\n if (input.length > 2 && enableFullTableSearch) {\n const conditions = columnList?.map((col) => `${col}.ilike.*${input}*`);\n\n return query.or(conditions.join(\",\"));\n }\n\n return query;\n };\n }\n\n const { data, onScroll, dispatch, client } = usePostgRESTLazyLoader(\n endpoint,\n table,\n {\n order: order ?? { key: identityKey, ascending: true },\n columns,\n filter,\n },\n );\n\n const toaster = useToaster();\n\n const finishResponse = useCallback(\n (promisedResult, changes) => {\n wrapWithErrorHandling(toaster, promisedResult).then((res) => {\n if (res == null) {\n throw new Error(\"Could not complete action\");\n } else {\n // Merge new data with old data\n console.log(\"Updating data\", changes);\n dispatch({ type: \"update-data\", changes });\n }\n });\n },\n [dispatch, toaster],\n );\n\n if (data == null) {\n return h(Spinner);\n }\n\n return h(\"div.data-sheet-outer\", [\n h(DataSheet, {\n ...rest,\n dataSheetActions: enableFullTableSearch\n ? h(SearchAction, { input, setInput, dispatch })\n : dataSheetActions,\n data,\n columnSpecOptions: columnOptions ?? {},\n editable,\n onVisibleCellsChange: onScroll,\n onDeleteRows(selection) {\n if (!editable) return;\n\n const rowIndices = getRowsToDelete(selection);\n\n const ids = rowIndices.map((i) => data[i][identityKey]);\n\n dispatch({ type: \"start-loading\" });\n\n let query = client.delete().in(identityKey, ids);\n\n query = filter?.(query) ?? query;\n\n finishResponse(query, { $delete: Array.from(rowIndices.keys()) });\n },\n onSaveData(updates, data) {\n if (!editable) return;\n\n // Augment updates with primary key\n\n let changes: Spec<any[]> = {};\n let updateRows: any[] = [];\n for (let [key, update] of Object.entries(updates)) {\n const value = { ...data[key], ...update };\n updateRows.push(value);\n changes[key] = { $set: value };\n }\n\n dispatch({ type: \"start-loading\" });\n\n // Save data\n let query = client.upsert(updateRows, { defaultToNull: false });\n\n query = filter?.(query) ?? query;\n\n finishResponse(query, changes);\n },\n }),\n ]);\n}\n\nexport function notifyOnError(toaster: OverlayToaster, error: any) {\n console.error(error);\n const { message, status, code, details } = error;\n\n let errorDetails = null;\n\n if (details != null) {\n if (typeof details === \"string\") {\n errorDetails = h(\"p.error-details\", details);\n } else {\n errorDetails = h(\"div.error-details\", [\n h(\"h4\", \"Error details\"),\n h(\"pre\", JSON.stringify(details, null, 2)),\n ]);\n }\n }\n\n toaster.show({\n message: h([\n h.if(status != null)([h(\"code.bp6-code\", status), \" \"]),\n h.if(code != null)([h(\"code.bp6-code\", code), \" \"]),\n message ?? \"An error occurred\",\n errorDetails,\n ]),\n intent: \"danger\",\n });\n}\n\ninterface PromiseResult {\n error?: Error;\n}\n\nexport async function wrapWithErrorHandling<T extends PromiseResult>(\n toaster: OverlayToaster,\n fnPromise: Promise<T>,\n): Promise<T | null> {\n try {\n const p = await fnPromise;\n if (p.error != null) {\n // Rethrow error\n throw p.error;\n }\n return p;\n } catch (err) {\n notifyOnError(toaster, err);\n return null;\n }\n}\n\nexport function LongTextViewer({ value, onChange }) {\n return h(\"div.long-text\", value);\n}\n\nexport function IntervalCell({ value, children, ...rest }) {\n return h(ColorCell, { value: value?.color, ...rest }, value?.name);\n}\n\nexport function lithologyRenderer(value) {\n return h(\n \"span.tag-cell-content.liths\",\n value?.map((d) => h(LithologyTag, { data: d, key: d.id })),\n );\n}\n\nexport function ExpandedLithologies({ value, onChange }) {\n if (value == null) return h(\"div.basis-panel\", \"No lithologies\");\n return h(\"div.basis-panel\", [\n h(\"table\", [\n h(\"thead\", h(\"tr\", [h(\"th\", \"Lithology\"), h(\"th\", \"Source\")])),\n h(\n \"tbody\",\n value.map((d) => {\n return h(\"tr\", { key: d.id }, [\n h(\"td\", h(LithologyTag, { data: d })),\n h(\n \"td.basis-col\",\n d.basis_col?.map((d) => {\n return h(Tag, {\n size: TagSize.Small,\n key: d,\n name: h([h(\"span.tag-header\", \"Column\"), \" \", h(\"code\", d)]),\n });\n }),\n ),\n ]);\n }),\n ),\n ]),\n ]);\n}\n\nexport function SearchAction({ input, setInput, dispatch }) {\n return h(InputGroup, {\n type: \"search\",\n placeholder: \"Search table...\",\n value: input,\n onChange(event) {\n const search = event.target.value;\n if (search.length > 2 || (input.length === 3 && search.length < 3)) {\n dispatch({ type: \"reset\" });\n }\n setInput(search.toLowerCase());\n },\n });\n}\n\nfunction getColumnList(endpoint: string, table: string) {\n const url = `${endpoint}/${table}?select=*&limit=1`;\n const res = useAPIResult(url);\n\n if (!res || !Array.isArray(res) || res.length === 0) return [];\n\n const sampleRow = res[0];\n\n return Object.entries(sampleRow)\n .filter(([_, value]) => {\n return typeof value === \"string\";\n })\n .map(([key])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AS;AAAA,MAC5B;AACA,eAAS,OAAO,aAAa;AAAA,IAC/B;AAAA,EAAA,CACD;AACH;AAEA,SAAS,cAAc,UAAkB,OAAe;AACtD,QAAM,MAAM,GAAG,QAAQ,IAAI,KAAK;AAChC,QAAM,MAAM,aAAa,GAAG;AAE5B,MAAI,CAAC,OAAO,CAAC,MAAM,QAAQ,GAAG,KAAK,IAAI,WAAW,EAAG,QAAO,CAAA;AAE5D,QAAM,YAAY,IAAI,CAAC;AAEvB,SAAO,OAAO,QAAQ,SAAS,EAC5B,OAAO,CAAC,CAAC,GAAG,KAAK,MAAM;AACtB,WAAO,OAAO,UAAU;AAAA,EAC1B,CAAC,EACA,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG;AACvB;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/postgrest-table/index.ts"],"sourcesContent":["import { HotkeysProvider, OverlayToaster } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { DataSheet, getRowsToDelete } from \"../core\"; //getRowsToDelete\nimport { LithologyTag, Tag, TagSize } from \"@macrostrat/data-components\";\nimport { PostgrestOrder, usePostgRESTLazyLoader } from \"./data-loaders\";\nimport { Spinner, InputGroup } from \"@blueprintjs/core\";\n\nexport * from \"./data-loaders\";\nimport { useCallback, useState, useRef } from \"react\";\nimport {\n ErrorBoundary,\n ToasterContext,\n useAPIResult,\n useToaster,\n} from \"@macrostrat/ui-components\";\nimport { Spec } from \"immutability-helper\";\nimport { DataSheetProviderProps } from \"../provider\";\nimport { PostgrestFilterBuilder } from \"@supabase/postgrest-js\";\nimport type {\n GenericFunction,\n GenericTable,\n GenericView,\n} from \"@supabase/postgrest-js/dist/cjs/index\";\nimport { ColorCell } from \"../components\";\n\nconst h = hyper.styled(styles);\n\nexport type GenericSchema = {\n Tables: Record<string, GenericTable>;\n Views: Record<string, GenericView>;\n Functions: Record<string, GenericFunction>;\n};\n\ninterface PostgRESTTableViewProps<\n T extends object,\n> extends DataSheetProviderProps<T> {\n endpoint: string;\n table: string;\n columnOptions?: any;\n order?: PostgrestOrder<T>;\n columns?: string;\n editable?: boolean;\n identityKey?: string;\n enableFullTableSearch?: boolean;\n dataSheetActions?: any;\n filter(\n query: PostgrestFilterBuilder<T, any, any>,\n ): PostgrestFilterBuilder<T, any, any>;\n}\n\nexport function PostgRESTTableView<T>(props: PostgRESTTableViewProps<T>) {\n return h(\n ErrorBoundary,\n h(HotkeysProvider, h(ToasterContext, h(_PostgRESTTableView, props))),\n );\n}\n\nconst successResponses = [200, 201];\n\nfunction _PostgRESTTableView<T>({\n endpoint,\n table,\n columnOptions,\n order,\n columns,\n editable = false,\n filter = undefined,\n enableFullTableSearch = false,\n dataSheetActions,\n identityKey = \"id\",\n ...rest\n}: PostgRESTTableViewProps<T>) {\n const [input, setInput] = useState(\"\");\n\n if (enableFullTableSearch) {\n const columnList = columns ?? getColumnList(endpoint, table);\n\n filter = (query) => {\n const urlParams = new URLSearchParams(query.url.search);\n urlParams.delete(\"or\");\n query.url.search = urlParams.toString() ? `?${urlParams.toString()}` : \"\";\n\n if (input.length > 2 && enableFullTableSearch) {\n const conditions = columnList?.map((col) => `${col}.ilike.*${input}*`);\n\n return query.or(conditions.join(\",\"));\n }\n\n return query;\n };\n }\n\n const { data, onScroll, dispatch, client } = usePostgRESTLazyLoader(\n endpoint,\n table,\n {\n order: order ?? { key: identityKey, ascending: true },\n columns,\n filter,\n },\n );\n\n const toaster = useToaster();\n\n const finishResponse = useCallback(\n (promisedResult, changes) => {\n wrapWithErrorHandling(toaster, promisedResult).then((res) => {\n if (res == null) {\n throw new Error(\"Could not complete action\");\n } else {\n // Merge new data with old data\n console.log(\"Updating data\", changes);\n dispatch({ type: \"update-data\", changes });\n }\n });\n },\n [dispatch, toaster],\n );\n\n if (data == null) {\n return h(Spinner);\n }\n\n return h(\"div.data-sheet-outer\", [\n h(DataSheet, {\n ...rest,\n dataSheetActions: enableFullTableSearch\n ? h(SearchAction, { input, setInput, dispatch })\n : dataSheetActions,\n data,\n columnSpecOptions: columnOptions ?? {},\n editable,\n onVisibleCellsChange: onScroll,\n onDeleteRows(selection) {\n if (!editable) return;\n\n const rowIndices = getRowsToDelete(selection);\n\n const ids = rowIndices.map((i) => data[i][identityKey]);\n\n dispatch({ type: \"start-loading\" });\n\n let query = client.delete().in(identityKey, ids);\n\n query = filter?.(query) ?? query;\n\n finishResponse(query, { $delete: Array.from(rowIndices.keys()) });\n },\n onSaveData(updates, data) {\n if (!editable) return;\n\n // Augment updates with primary key\n\n let changes: Spec<any[]> = {};\n let updateRows: any[] = [];\n for (let [key, update] of Object.entries(updates)) {\n const value = { ...data[key], ...update };\n updateRows.push(value);\n changes[key] = { $set: value };\n }\n\n dispatch({ type: \"start-loading\" });\n\n // Save data\n let query = client.upsert(updateRows, { defaultToNull: false });\n\n query = filter?.(query) ?? query;\n\n finishResponse(query, changes);\n },\n }),\n ]);\n}\n\nexport function notifyOnError(toaster: OverlayToaster, error: any) {\n console.error(error);\n const { message, status, code, details } = error;\n\n let errorDetails = null;\n\n if (details != null) {\n if (typeof details === \"string\") {\n errorDetails = h(\"p.error-details\", details);\n } else {\n errorDetails = h(\"div.error-details\", [\n h(\"h4\", \"Error details\"),\n h(\"pre\", JSON.stringify(details, null, 2)),\n ]);\n }\n }\n\n toaster.show({\n message: h([\n h.if(status != null)([h(\"code.bp6-code\", status), \" \"]),\n h.if(code != null)([h(\"code.bp6-code\", code), \" \"]),\n message ?? \"An error occurred\",\n errorDetails,\n ]),\n intent: \"danger\",\n });\n}\n\ninterface PromiseResult {\n error?: Error;\n}\n\nexport async function wrapWithErrorHandling<T extends PromiseResult>(\n toaster: OverlayToaster,\n fnPromise: Promise<T>,\n): Promise<T | null> {\n try {\n const p = await fnPromise;\n if (p.error != null) {\n // Rethrow error\n throw p.error;\n }\n return p;\n } catch (err) {\n notifyOnError(toaster, err);\n return null;\n }\n}\n\nexport function LongTextViewer({ value, onChange }) {\n return h(\"div.long-text\", value);\n}\n\nexport function IntervalCell({ value, children, ...rest }) {\n return h(ColorCell, { value: value?.color, ...rest }, value?.name);\n}\n\nexport function lithologyRenderer(value) {\n return h(\n \"span.tag-cell-content.liths\",\n value?.map((d) => h(LithologyTag, { data: d, key: d.id })),\n );\n}\n\nexport function ExpandedLithologies({ value, onChange }) {\n if (value == null) return h(\"div.basis-panel\", \"No lithologies\");\n return h(\"div.basis-panel\", [\n h(\"table\", [\n h(\"thead\", h(\"tr\", [h(\"th\", \"Lithology\"), h(\"th\", \"Source\")])),\n h(\n \"tbody\",\n value.map((d) => {\n return h(\"tr\", { key: d.id }, [\n h(\"td\", h(LithologyTag, { data: d })),\n h(\n \"td.basis-col\",\n d.basis_col?.map((d) => {\n return h(Tag, {\n size: TagSize.Small,\n key: d,\n name: h([h(\"span.tag-header\", \"Column\"), \" \", h(\"code\", d)]),\n });\n }),\n ),\n ]);\n }),\n ),\n ]),\n ]);\n}\n\nexport function SearchAction({ input, setInput, dispatch }) {\n return h(InputGroup, {\n type: \"search\",\n placeholder: \"Search table...\",\n value: input,\n onChange(event) {\n const search = event.target.value;\n if (search.length > 2 || (input.length === 3 && search.length < 3)) {\n dispatch({ type: \"reset\" });\n }\n setInput(search.toLowerCase());\n },\n });\n}\n\nfunction getColumnList(endpoint: string, table: string) {\n const url = `${endpoint}/${table}?select=*&limit=1`;\n const res = useAPIResult(url);\n\n if (!res || !Array.isArray(res) || res.length === 0) return [];\n\n const sampleRow = res[0];\n\n return Object.entries(sampleRow)\n .filter(([_, value]) => {\n return typeof value === \"string\";\n })\n .map(([key]) => key);\n}\n"],"names":["styles","data","d"],"mappings":";;;;;;;;;AA0BA,MAAM,IAAI,MAAM,OAAOA,GAAM;AAyBtB,SAAS,mBAAsB,OAAmC;AACvE,SAAO;AAAA,IACL;AAAA,IACA,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,KAAK,CAAC,CAAC;AAAA,EAAA;AAEvE;AAIA,SAAS,oBAAuB;AAAA,EA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AG,QAAO,CAAA;AAE5D,QAAM,YAAY,IAAI,CAAC;AAEvB,SAAO,OAAO,QAAQ,SAAS,EAC5B,OAAO,CAAC,CAAC,GAAG,KAAK,MAAM;AACtB,WAAO,OAAO,UAAU;AAAA,EAC1B,CAAC,EACA,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG;AACvB;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const hyper = require("@macrostrat/hyper");
|
|
4
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
+
const hyper__default = /* @__PURE__ */ _interopDefault(hyper);
|
|
3
6
|
const lithology = "_lithology_12ust_1";
|
|
4
7
|
const description = "_description_12ust_34";
|
|
5
8
|
const liths = "_liths_12ust_49";
|
|
@@ -15,7 +18,9 @@ const styles = {
|
|
|
15
18
|
"data-sheet-outer": "_data-sheet-outer_12ust_53",
|
|
16
19
|
"tag-cell-content": "_tag-cell-content_12ust_60"
|
|
17
20
|
};
|
|
18
|
-
|
|
21
|
+
let h = hyper__default.default.styled(styles);
|
|
22
|
+
Object.assign(h, styles);
|
|
23
|
+
exports.default = h;
|
|
19
24
|
exports.description = description;
|
|
20
25
|
exports.lithology = lithology;
|
|
21
26
|
exports.liths = liths;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import hyper from "@macrostrat/hyper";
|
|
1
2
|
const lithology = "_lithology_12ust_1";
|
|
2
3
|
const description = "_description_12ust_34";
|
|
3
4
|
const liths = "_liths_12ust_49";
|
|
@@ -13,8 +14,10 @@ const styles = {
|
|
|
13
14
|
"data-sheet-outer": "_data-sheet-outer_12ust_53",
|
|
14
15
|
"tag-cell-content": "_tag-cell-content_12ust_60"
|
|
15
16
|
};
|
|
17
|
+
let h = hyper.styled(styles);
|
|
18
|
+
Object.assign(h, styles);
|
|
16
19
|
export {
|
|
17
|
-
|
|
20
|
+
h as default,
|
|
18
21
|
description,
|
|
19
22
|
lithology,
|
|
20
23
|
liths
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/data-sheet",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Scalable data sheet with optional editing capabilities",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"author": "Daven Quinn",
|
|
12
|
-
"type": "module",
|
|
13
12
|
"source": "src/index.ts",
|
|
14
|
-
"main": "dist/index.
|
|
13
|
+
"main": "dist/index.cjs",
|
|
14
|
+
"module": "dist/index.js",
|
|
15
15
|
"node": "dist/index.cjs",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
17
|
"style": "dist/data-sheet.css",
|
|
@@ -25,9 +25,14 @@
|
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"source": "./src/index.ts",
|
|
28
|
-
"import":
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
|
+
},
|
|
31
36
|
"style": "./dist/data-sheet.css"
|
|
32
37
|
},
|
|
33
38
|
"./package.json": "./package.json",
|
|
@@ -41,16 +46,14 @@
|
|
|
41
46
|
"react": "^18.0.0||^19.0.0"
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
44
|
-
"@blueprintjs/core": "^6.
|
|
45
|
-
"@blueprintjs/table": "^6.0.
|
|
46
|
-
"@macrostrat/color-utils": "^1.2.
|
|
47
|
-
"@macrostrat/data-components": "^1.
|
|
49
|
+
"@blueprintjs/core": "^6.11.3",
|
|
50
|
+
"@blueprintjs/table": "^6.0.23",
|
|
51
|
+
"@macrostrat/color-utils": "^1.2.1",
|
|
52
|
+
"@macrostrat/data-components": "^1.1.4",
|
|
48
53
|
"@macrostrat/hyper": "^3.0.6",
|
|
49
|
-
"@macrostrat/ui-components": "^5.0.
|
|
54
|
+
"@macrostrat/ui-components": "^5.0.6",
|
|
50
55
|
"@supabase/postgrest-js": "^1.17.7",
|
|
51
56
|
"@types/underscore": "^1.13.0",
|
|
52
|
-
"@uiw/react-color": "^2.9.2",
|
|
53
|
-
"chroma-js": "^3.2.0",
|
|
54
57
|
"classnames": "^2.5.1",
|
|
55
58
|
"immutability-helper": "^3.1.1",
|
|
56
59
|
"underscore": "^1.13.7",
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
"zustand-computed": "^2.1.0"
|
|
59
62
|
},
|
|
60
63
|
"devDependencies": {
|
|
61
|
-
"@macrostrat/web-components-bundler": "1.0.
|
|
64
|
+
"@macrostrat/web-components-bundler": "1.0.1"
|
|
62
65
|
},
|
|
63
66
|
"publishConfig": {
|
|
64
67
|
"access": "public"
|
package/src/components/colors.ts
CHANGED
|
@@ -2,14 +2,12 @@ import { Cell } from "@blueprintjs/table";
|
|
|
2
2
|
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
3
3
|
import hyper from "@macrostrat/hyper";
|
|
4
4
|
import styles from "./main.module.sass";
|
|
5
|
-
import {
|
|
6
|
-
asChromaColor,
|
|
7
|
-
getLuminanceAdjustedColorScheme,
|
|
8
|
-
} from "@macrostrat/color-utils";
|
|
9
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { getLuminanceAdjustedColorScheme } from "@macrostrat/color-utils";
|
|
10
6
|
import { memoize } from "underscore";
|
|
11
|
-
import { Sketch } from "@uiw/react-color";
|
|
12
7
|
import classNames from "classnames";
|
|
8
|
+
import { ColorPicker2 } from "@macrostrat/ui-components";
|
|
9
|
+
|
|
10
|
+
export const ColorPicker = ColorPicker2;
|
|
13
11
|
|
|
14
12
|
const h = hyper.styled(styles);
|
|
15
13
|
|
|
@@ -69,51 +67,3 @@ export function colorSwatchRenderer(value) {
|
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
const colorCombo = memoize(getLuminanceAdjustedColorScheme);
|
|
72
|
-
|
|
73
|
-
enum ColorConversionType {
|
|
74
|
-
HEX = "hex",
|
|
75
|
-
RGB = "rgb",
|
|
76
|
-
HSL = "hsl",
|
|
77
|
-
CSS = "css",
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function ColorPicker({
|
|
81
|
-
value,
|
|
82
|
-
onChange,
|
|
83
|
-
editable = true,
|
|
84
|
-
type = ColorConversionType.CSS,
|
|
85
|
-
}) {
|
|
86
|
-
const ref = useRef(null);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (ref.current == null) return;
|
|
89
|
-
ref.current.focus();
|
|
90
|
-
}, []);
|
|
91
|
-
|
|
92
|
-
const color = useMemo(() => {
|
|
93
|
-
try {
|
|
94
|
-
return asChromaColor(value).hex();
|
|
95
|
-
} catch {
|
|
96
|
-
return "#aaaaaa";
|
|
97
|
-
}
|
|
98
|
-
}, [value]);
|
|
99
|
-
|
|
100
|
-
return h(
|
|
101
|
-
"div.color-picker-container",
|
|
102
|
-
{
|
|
103
|
-
onKeyDown(evt) {
|
|
104
|
-
if (evt.key === "Escape") {
|
|
105
|
-
evt.preventDefault();
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
ref,
|
|
109
|
-
tabIndex: 0,
|
|
110
|
-
},
|
|
111
|
-
h(Sketch, {
|
|
112
|
-
color,
|
|
113
|
-
disableAlpha: true,
|
|
114
|
-
onChange(color) {
|
|
115
|
-
onChange(asChromaColor(color.hexa)[type]());
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
118
|
-
);
|
|
119
|
-
}
|