@macrostrat/data-sheet 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +19 -0
  3. package/dist/actions.5740e8e2.js +21 -0
  4. package/dist/actions.5740e8e2.js.map +1 -0
  5. package/dist/actions.module.6ec06797.css +11 -0
  6. package/dist/actions.module.6ec06797.css.map +1 -0
  7. package/dist/actions.module.ea96403b.js +16 -0
  8. package/dist/actions.module.ea96403b.js.map +1 -0
  9. package/dist/cell-renderers.de70f471.js +31 -0
  10. package/dist/cell-renderers.de70f471.js.map +1 -0
  11. package/dist/colors.41c3ed7a.js +83 -0
  12. package/dist/colors.41c3ed7a.js.map +1 -0
  13. package/dist/column-spec.4710da93.js +70 -0
  14. package/dist/column-spec.4710da93.js.map +1 -0
  15. package/dist/components.c3ad66e9.js +11 -0
  16. package/dist/components.c3ad66e9.js.map +1 -0
  17. package/dist/core.d8d80480.js +356 -0
  18. package/dist/core.d8d80480.js.map +1 -0
  19. package/dist/data-loaders.5302dedd.js +196 -0
  20. package/dist/data-loaders.5302dedd.js.map +1 -0
  21. package/dist/editor-popup.9259608f.js +68 -0
  22. package/dist/editor-popup.9259608f.js.map +1 -0
  23. package/dist/index.d.ts +202 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +9 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/main.module.846377cd.css +35 -0
  28. package/dist/main.module.846377cd.css.map +1 -0
  29. package/dist/main.module.914caa19.css +91 -0
  30. package/dist/main.module.914caa19.css.map +1 -0
  31. package/dist/main.module.93f91ad4.js +25 -0
  32. package/dist/main.module.93f91ad4.js.map +1 -0
  33. package/dist/main.module.dc8f6293.css +62 -0
  34. package/dist/main.module.dc8f6293.css.map +1 -0
  35. package/dist/main.module.de002429.js +43 -0
  36. package/dist/main.module.de002429.js.map +1 -0
  37. package/dist/main.module.ff717a08.js +37 -0
  38. package/dist/main.module.ff717a08.js.map +1 -0
  39. package/dist/postgrest-table.15ded3c1.js +173 -0
  40. package/dist/postgrest-table.15ded3c1.js.map +1 -0
  41. package/dist/provider.67e982b8.js +232 -0
  42. package/dist/provider.67e982b8.js.map +1 -0
  43. package/dist/text-areas.079e8b15.js +78 -0
  44. package/dist/text-areas.079e8b15.js.map +1 -0
  45. package/dist/utils.a37ed786.js +14 -0
  46. package/dist/utils.a37ed786.js.map +1 -0
  47. package/package.json +50 -0
  48. package/src/__archive/base.ts +55 -0
  49. package/src/__archive/components/column-utils.ts +126 -0
  50. package/src/__archive/components/index.ts +115 -0
  51. package/src/__archive/components/toolbar.ts +79 -0
  52. package/src/__archive/editors/index.ts +78 -0
  53. package/src/__archive/editors/styles.module.scss +10 -0
  54. package/src/__archive/enhancers.ts +36 -0
  55. package/src/__archive/index.ts +8 -0
  56. package/src/__archive/main.ts +180 -0
  57. package/src/__archive/provider.ts +179 -0
  58. package/src/__archive/styles.module.scss +56 -0
  59. package/src/__archive/test-sheet/attitude-sheet.old.styl +53 -0
  60. package/src/__archive/test-sheet/attitude-sheet.scss +60 -0
  61. package/src/__archive/test-sheet/index.ts +210 -0
  62. package/src/__archive/virtualized.ts +82 -0
  63. package/src/components/actions.module.sass +8 -0
  64. package/src/components/actions.ts +11 -0
  65. package/src/components/colors.ts +90 -0
  66. package/src/components/editor-popup.ts +69 -0
  67. package/src/components/index.ts +3 -0
  68. package/src/components/main.module.sass +35 -0
  69. package/src/components/text-areas.ts +88 -0
  70. package/src/core.ts +481 -0
  71. package/src/index.ts +2 -0
  72. package/src/main.module.sass +77 -0
  73. package/src/postgrest-table/cell-renderers.ts +24 -0
  74. package/src/postgrest-table/data-loaders.ts +287 -0
  75. package/src/postgrest-table/index.ts +172 -0
  76. package/src/postgrest-table/main.module.sass +52 -0
  77. package/src/provider.ts +282 -0
  78. package/src/utils/column-spec.ts +97 -0
  79. package/src/utils/index.ts +7 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [2.0.0] - 2025-02-14
8
+
9
+ - New version of the `@macrostrat/data-sheet` library based on `@blueprintjs/table` and `@blueprintjs/core`
10
+ - Full-featured and customizable virtualized data sheet
11
+ - Preliminary support for windowed loading and [PostgREST](https://postgrest.org) data fetching
12
+ - Standardized approach to tooltips, context menus, and other controls
13
+
14
+ ## [1.0.0] - 2021 to 2024
15
+
16
+ - Initial release of the `@macrostrat/data-sheet` library based on `react-datasheet`
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Data sheet
2
+
3
+ A new data sheet component for Macrostrat based on the BlueprintJS table component.
4
+ This will eventually replace the existing data sheet component.
5
+
6
+ ## PostgREST table
7
+
8
+ A goal of this module is to create a generic table that can be bootstrapped on top of PostgreSQL routes, with support for filtering, sorting, and pagination.
9
+ This will be supported by the [PostgREST](https://postgrest.org/) API, which provides generic API tooling over PostgreSQL tables and views.
10
+
11
+ The design of this conceptually follows the [Supabase Grid](https://github.com/supabase/grid) component, which has been deprecated as a standalone module.
12
+ The current version of the Supabase Grid is available in the [Supabase Studio app](https://github.com/supabase/supabase/tree/master/apps/studio/components/grid),
13
+ but is in my opinion a bit tightly coupled to the Supabase ecosystem now. Still, it can be used, at minimum, as a design reference.
14
+
15
+ ## Changes from Data Sheet v1
16
+
17
+ - The new data sheet will be based on BlueprintJS, a more mature and feature-rich table component library.
18
+ - In particular, the BlueprintJS table natively supports virtualization, which is
19
+ important for performance when rendering large tables.
@@ -0,0 +1,21 @@
1
+ import "./actions.module.6ec06797.css";
2
+ import $akuc1$actionsmoduleea96403bjs from "./actions.module.ea96403b.js";
3
+ import $akuc1$macrostrathyper from "@macrostrat/hyper";
4
+
5
+
6
+ function $parcel$interopDefault(a) {
7
+ return a && a.__esModule ? a.default : a;
8
+ }
9
+
10
+
11
+ const $a36e736abd533bdf$var$h = (0, $akuc1$macrostrathyper).styled((0, ($parcel$interopDefault($akuc1$actionsmoduleea96403bjs))));
12
+ function $a36e736abd533bdf$export$b215fe4466d8f847(props) {
13
+ return $a36e736abd533bdf$var$h("div.table-actions", props.children);
14
+ }
15
+ function $a36e736abd533bdf$export$c2c7070a9fc246e1(props) {
16
+ return $a36e736abd533bdf$var$h("div.table-action", props.children);
17
+ }
18
+
19
+
20
+ export {$a36e736abd533bdf$export$b215fe4466d8f847 as DataSheetActionsRow, $a36e736abd533bdf$export$c2c7070a9fc246e1 as DataSheetAction};
21
+ //# sourceMappingURL=actions.5740e8e2.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAEA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,yEAAI;AAEpB,SAAS,0CAAoB,KAAK;IACvC,OAAO,wBAAE,qBAAqB,MAAM,QAAQ;AAC9C;AAEO,SAAS,0CAAgB,KAAK;IACnC,OAAO,wBAAE,oBAAoB,MAAM,QAAQ;AAC7C","sources":["packages/data-sheet/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":[],"version":3,"file":"actions.5740e8e2.js.map"}
@@ -0,0 +1,11 @@
1
+ .mo-ulq_table-actions, .mo-ulq_table-action {
2
+ flex-direction: row;
3
+ gap: .5em;
4
+ display: flex;
5
+ }
6
+
7
+ .mo-ulq_table-actions {
8
+ gap: 1em;
9
+ margin-bottom: .5em;
10
+ }
11
+ /*# sourceMappingURL=actions.module.6ec06797.css.map */
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;AAKA","sources":["packages/data-sheet/src/components/actions.module.sass"],"sourcesContent":[".table-actions, .table-action\n display: flex\n flex-direction: row\n gap: 0.5em\n\n.table-actions\n margin-bottom: 0.5em\n gap: 1em\n"],"names":[],"version":3,"file":"actions.module.6ec06797.css.map"}
@@ -0,0 +1,16 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+ var $2c100a5db8320baf$exports = {};
6
+
7
+ $parcel$export($2c100a5db8320baf$exports, "table-action", () => $2c100a5db8320baf$export$d6d0049d3b1f338e, (v) => $2c100a5db8320baf$export$d6d0049d3b1f338e = v);
8
+ $parcel$export($2c100a5db8320baf$exports, "table-actions", () => $2c100a5db8320baf$export$204e8b69eae0e749, (v) => $2c100a5db8320baf$export$204e8b69eae0e749 = v);
9
+ var $2c100a5db8320baf$export$d6d0049d3b1f338e;
10
+ var $2c100a5db8320baf$export$204e8b69eae0e749;
11
+ $2c100a5db8320baf$export$d6d0049d3b1f338e = `mo-ulq_table-action`;
12
+ $2c100a5db8320baf$export$204e8b69eae0e749 = `mo-ulq_table-actions`;
13
+
14
+
15
+ export {$2c100a5db8320baf$exports as default};
16
+ //# sourceMappingURL=actions.module.ea96403b.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA,IAAA;AACA,IAAA;AADA,4CAAiC,CAAC,mBAAmB,CAAC;AACtD,4CAAkC,CAAC,oBAAoB,CAAC","sources":["packages/data-sheet/src/components/actions.module.sass"],"sourcesContent":[".table-actions, .table-action\n display: flex\n flex-direction: row\n gap: 0.5em\n\n.table-actions\n margin-bottom: 0.5em\n gap: 1em\n"],"names":[],"version":3,"file":"actions.module.ea96403b.js.map"}
@@ -0,0 +1,31 @@
1
+ import {useInDarkMode as $lIlPt$useInDarkMode} from "@macrostrat/ui-components";
2
+ import $lIlPt$macrostrathyper from "@macrostrat/hyper";
3
+ import {Tag as $lIlPt$Tag} from "@blueprintjs/core";
4
+ import {asChromaColor as $lIlPt$asChromaColor} from "@macrostrat/color-utils";
5
+ import $lIlPt$classnames from "classnames";
6
+
7
+
8
+
9
+
10
+
11
+
12
+ function $753d4a0c461d4588$export$17064b7382e320b2({ data: data, className: className = null }) {
13
+ const darkMode = (0, $lIlPt$useInDarkMode)();
14
+ const luminance = darkMode ? 0.9 : 0.4;
15
+ const color = (0, $lIlPt$asChromaColor)(data.color);
16
+ return (0, $lIlPt$macrostrathyper)((0, $lIlPt$Tag), {
17
+ key: data.id,
18
+ className: (0, $lIlPt$classnames)("lithology-tag", className),
19
+ minimal: true,
20
+ style: {
21
+ color: color?.luminance(luminance).hex(),
22
+ backgroundColor: color?.luminance(1 - luminance).hex()
23
+ }
24
+ }, (0, $lIlPt$macrostrathyper)("span.contents", [
25
+ (0, $lIlPt$macrostrathyper)("span.name", data.name)
26
+ ]));
27
+ }
28
+
29
+
30
+ export {$753d4a0c461d4588$export$17064b7382e320b2 as LithologyTag};
31
+ //# sourceMappingURL=cell-renderers.de70f471.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAMO,SAAS,0CAAa,QAAE,IAAI,aAAE,YAAY,MAAM;IACrD,MAAM,WAAW,CAAA,GAAA,oBAAY;IAC7B,MAAM,YAAY,WAAW,MAAM;IACnC,MAAM,QAAQ,CAAA,GAAA,oBAAY,EAAE,KAAK,KAAK;IACtC,OAAO,CAAA,GAAA,sBAAA,EACL,CAAA,GAAA,UAAE,GACF;QACE,KAAK,KAAK,EAAE;QACZ,WAAW,CAAA,GAAA,iBAAS,EAAE,iBAAiB;QACvC,SAAS;QACT,OAAO;YACL,OAAO,OAAO,UAAU,WAAW;YACnC,iBAAiB,OAAO,UAAU,IAAI,WAAW;QACnD;IACF,GACA,CAAA,GAAA,sBAAA,EAAE,iBAAiB;QAAC,CAAA,GAAA,sBAAA,EAAE,aAAa,KAAK,IAAI;KAAE;AAElD","sources":["packages/data-sheet/src/postgrest-table/cell-renderers.ts"],"sourcesContent":["import { useInDarkMode } from \"@macrostrat/ui-components\";\nimport h from \"@macrostrat/hyper\";\nimport { Tag } from \"@blueprintjs/core\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport classNames from \"classnames\";\n\nexport function LithologyTag({ data, className = null }) {\n const darkMode = useInDarkMode();\n const luminance = darkMode ? 0.9 : 0.4;\n const color = asChromaColor(data.color);\n return h(\n Tag,\n {\n key: data.id,\n className: classNames(\"lithology-tag\", className),\n minimal: true,\n style: {\n color: color?.luminance(luminance).hex(),\n backgroundColor: color?.luminance(1 - luminance).hex(),\n },\n },\n h(\"span.contents\", [h(\"span.name\", data.name)])\n );\n}\n"],"names":[],"version":3,"file":"cell-renderers.de70f471.js.map"}
@@ -0,0 +1,83 @@
1
+ import $3umSq$mainmodule93f91ad4js from "./main.module.93f91ad4.js";
2
+ import "./main.module.846377cd.css";
3
+ import {Cell as $3umSq$Cell} from "@blueprintjs/table";
4
+ import {useInDarkMode as $3umSq$useInDarkMode} from "@macrostrat/ui-components";
5
+ import $3umSq$macrostrathyper from "@macrostrat/hyper";
6
+ import {asChromaColor as $3umSq$asChromaColor} from "@macrostrat/color-utils";
7
+ import {HexColorPicker as $3umSq$HexColorPicker} from "react-colorful";
8
+ import {useRef as $3umSq$useRef, useEffect as $3umSq$useEffect} from "react";
9
+ import {memoize as $3umSq$memoize} from "underscore";
10
+
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ const $423bf54b4879ebeb$var$h = (0, $3umSq$macrostrathyper).styled((0, ($parcel$interopDefault($3umSq$mainmodule93f91ad4js))));
24
+ function $423bf54b4879ebeb$export$24aecfe8a925020d({ value: value, children: children, style: style, intent: intent, ...rest }) {
25
+ const darkMode = (0, $3umSq$useInDarkMode)();
26
+ return $423bf54b4879ebeb$var$h((0, $3umSq$Cell), {
27
+ ...rest,
28
+ style: {
29
+ ...style,
30
+ ...$423bf54b4879ebeb$var$colorCombo(value, darkMode)
31
+ }
32
+ }, children);
33
+ }
34
+ const $423bf54b4879ebeb$var$colorCombo = (0, $3umSq$memoize)((color, darkMode)=>$423bf54b4879ebeb$export$ba6491245befce5c(color, {
35
+ darkMode: darkMode
36
+ }));
37
+ function $423bf54b4879ebeb$export$ba6491245befce5c(color, { luminance: luminance = null, backgroundAlpha: backgroundAlpha = 0.2, darkMode: darkMode = false } = {}) {
38
+ const brighten = luminance ?? darkMode ? 0.5 : 0.1;
39
+ // Check if is a chroma color
40
+ color = (0, $3umSq$asChromaColor)(color);
41
+ if (color == null) return {};
42
+ return {
43
+ color: color?.luminance?.(brighten).css(),
44
+ backgroundColor: color?.alpha?.(backgroundAlpha).css()
45
+ };
46
+ }
47
+ var $423bf54b4879ebeb$var$ColorConversionType = /*#__PURE__*/ function(ColorConversionType) {
48
+ ColorConversionType["HEX"] = "hex";
49
+ ColorConversionType["RGB"] = "rgb";
50
+ ColorConversionType["HSL"] = "hsl";
51
+ ColorConversionType["CSS"] = "css";
52
+ return ColorConversionType;
53
+ }($423bf54b4879ebeb$var$ColorConversionType || {});
54
+ function $423bf54b4879ebeb$export$9feb1bc2e5f1ccb3({ value: value, onChange: onChange, type: type = "css" }) {
55
+ const ref = (0, $3umSq$useRef)(null);
56
+ (0, $3umSq$useEffect)(()=>{
57
+ if (ref.current == null) return;
58
+ ref.current.focus();
59
+ }, []);
60
+ let color;
61
+ try {
62
+ color = (0, $3umSq$asChromaColor)(value).hex();
63
+ } catch {
64
+ color = "#aaaaaa";
65
+ }
66
+ return $423bf54b4879ebeb$var$h("div.color-picker-container", {
67
+ onKeyDown (evt) {
68
+ console.log(evt);
69
+ if (evt.key === "Escape") evt.preventDefault();
70
+ },
71
+ ref: ref,
72
+ tabIndex: 0
73
+ }, $423bf54b4879ebeb$var$h((0, $3umSq$HexColorPicker), {
74
+ color: color,
75
+ onChange (color) {
76
+ onChange((0, $3umSq$asChromaColor)(color)[type]());
77
+ }
78
+ }));
79
+ }
80
+
81
+
82
+ export {$423bf54b4879ebeb$export$24aecfe8a925020d as ColorCell, $423bf54b4879ebeb$export$ba6491245befce5c as pleasantCombination, $423bf54b4879ebeb$export$9feb1bc2e5f1ccb3 as ColorPicker};
83
+ //# sourceMappingURL=colors.41c3ed7a.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,sEAAK;AAErB,SAAS,0CAAU,SAAE,KAAK,YAAE,QAAQ,SAAE,KAAK,UAAE,MAAM,EAAE,GAAG,MAAM;IACnE,MAAM,WAAW,CAAA,GAAA,oBAAY;IAE7B,OAAO,wBACL,CAAA,GAAA,WAAG,GACH;QACE,GAAG,IAAI;QACP,OAAO;YACL,GAAG,KAAK;YACR,GAAG,iCAAW,OAAO,SAAS;QAChC;IACF,GACA;AAEJ;AAEA,MAAM,mCAAa,CAAA,GAAA,cAAM,EAAE,CAAC,OAAO,WACjC,0CAAoB,OAAO;kBAAE;IAAS;AAGjC,SAAS,0CACd,KAAK,EACL,aAAE,YAAY,uBAAM,kBAAkB,eAAK,WAAW,OAAO,GAAG,CAAC,CAAC;IAElE,MAAM,WAAW,aAAa,WAAW,MAAM;IAE/C,6BAA6B;IAC7B,QAAQ,CAAA,GAAA,oBAAY,EAAE;IACtB,IAAI,SAAS,MAAM,OAAO,CAAC;IAC3B,OAAO;QACL,OAAO,OAAO,YAAY,UAAU;QACpC,iBAAiB,OAAO,QAAQ,iBAAiB;IACnD;AACF;AAEA,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 { asChromaColor } from \"@macrostrat/color-utils\";\nimport { HexColorPicker } from \"react-colorful\";\nimport { useEffect, useRef } from \"react\";\nimport { memoize } from \"underscore\";\n\nconst h = hyper.styled(styles);\n\nexport function ColorCell({ value, children, style, intent, ...rest }) {\n const darkMode = useInDarkMode();\n\n return h(\n Cell,\n {\n ...rest,\n style: {\n ...style,\n ...colorCombo(value, darkMode),\n },\n },\n children\n );\n}\n\nconst colorCombo = memoize((color, darkMode) =>\n pleasantCombination(color, { darkMode })\n);\n\nexport function pleasantCombination(\n color,\n { luminance = null, backgroundAlpha = 0.2, darkMode = false } = {}\n) {\n const brighten = luminance ?? darkMode ? 0.5 : 0.1;\n\n // Check if is a chroma color\n color = asChromaColor(color);\n if (color == null) return {};\n return {\n color: color?.luminance?.(brighten).css(),\n backgroundColor: color?.alpha?.(backgroundAlpha).css(),\n };\n}\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":"colors.41c3ed7a.js.map"}
@@ -0,0 +1,70 @@
1
+ const $afa6527b61074fe8$var$defaultRenderers = {
2
+ string: (d)=>d,
3
+ number: (d)=>d?.toFixed(2),
4
+ boolean: (d)=>d ? "T" : "F",
5
+ object: (d)=>JSON.stringify(d),
6
+ integer: (d)=>d?.toFixed(0),
7
+ array: (d)=>d?.join(", ")
8
+ };
9
+ function $afa6527b61074fe8$export$90c86365d1c277aa(data) {
10
+ /** Build a default column spec from a dataset based on the first n rows */ if (data == null) return [];
11
+ // Get the keys
12
+ const keys = new Set();
13
+ const types = new Map();
14
+ for (const row of data){
15
+ if (row == null) continue;
16
+ for (const key of Object.keys(row)){
17
+ const val = row[key];
18
+ keys.add(key);
19
+ if (val == null) continue;
20
+ let type = typeof val;
21
+ // Special 'type' for integers
22
+ if (Number.isInteger(val)) type = "integer";
23
+ // Special 'type' for arrays of simple values
24
+ if (Array.isArray(val) && val.every((d)=>typeof d === "string" || typeof d === "number")) type = "array";
25
+ if (types.has(key)) {
26
+ if (types.get(key) !== type) {
27
+ if (type === "number" && types.get(key) === "integer") types.set(key, "number");
28
+ if (type === "object" && types.get(key) === "array") types.set(key, "object");
29
+ types.set(key, "string");
30
+ }
31
+ } else types.set(key, type);
32
+ }
33
+ }
34
+ // Build a column spec
35
+ const spec = [];
36
+ for (const key of keys)spec.push({
37
+ name: key,
38
+ key: key,
39
+ valueRenderer: $afa6527b61074fe8$var$defaultRenderers[types.get(key)]
40
+ });
41
+ return spec;
42
+ }
43
+ function $afa6527b61074fe8$export$30457629971d2e1f(data, options) {
44
+ /** Generate a column spec from a dataset */ const { overrides: overrides = {}, nRows: nRows = 10, omitColumns: omitColumns, includeColumns: includeColumns } = options;
45
+ if (data == null) return [];
46
+ const _nRows = Math.min(nRows, data.length);
47
+ let columnSpec = $afa6527b61074fe8$export$90c86365d1c277aa(data.slice(0, _nRows));
48
+ let filteredSpec = columnSpec.filter((col)=>{
49
+ if (omitColumns != null && omitColumns.includes(col.key)) return false;
50
+ if (includeColumns != null && !includeColumns.includes(col.key)) return false;
51
+ return true;
52
+ });
53
+ // Apply overrides
54
+ return filteredSpec.map((col)=>{
55
+ let ovr = overrides[col.key];
56
+ if (ovr == null) return col;
57
+ if (typeof ovr === "string") return {
58
+ ...col,
59
+ name: ovr
60
+ };
61
+ return {
62
+ ...col,
63
+ ...ovr
64
+ };
65
+ });
66
+ }
67
+
68
+
69
+ export {$afa6527b61074fe8$export$90c86365d1c277aa as generateDefaultColumnSpec, $afa6527b61074fe8$export$30457629971d2e1f as generateColumnSpec};
70
+ //# sourceMappingURL=column-spec.4710da93.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA,MAAM,yCAAmB;IACvB,QAAQ,CAAC,IAAM;IACf,QAAQ,CAAC,IAAM,GAAG,QAAQ;IAC1B,SAAS,CAAC,IAAO,IAAI,MAAM;IAC3B,QAAQ,CAAC,IAAM,KAAK,SAAS,CAAC;IAC9B,SAAS,CAAC,IAAM,GAAG,QAAQ;IAC3B,OAAO,CAAC,IAAM,GAAG,KAAK;AACxB;AAEO,SAAS,0CAA6B,IAAc;IACzD,yEAAyE,GACzE,IAAI,QAAQ,MAAM,OAAO,EAAE;IAC3B,eAAe;IACf,MAAM,OAAO,IAAI;IACjB,MAAM,QAAQ,IAAI;IAClB,KAAK,MAAM,OAAO,KAAM;QACtB,IAAI,OAAO,MAAM;QACjB,KAAK,MAAM,OAAO,OAAO,IAAI,CAAC,KAAM;YAClC,MAAM,MAAM,GAAG,CAAC,IAAI;YACpB,KAAK,GAAG,CAAC;YAET,IAAI,OAAO,MAAM;YACjB,IAAI,OAAe,OAAO;YAC1B,8BAA8B;YAC9B,IAAI,OAAO,SAAS,CAAC,MACnB,OAAO;YAGT,6CAA6C;YAC7C,IACE,MAAM,OAAO,CAAC,QACd,IAAI,KAAK,CAAC,CAAC,IAAM,OAAO,MAAM,YAAY,OAAO,MAAM,WAEvD,OAAO;YAGT,IAAI,MAAM,GAAG,CAAC,MACZ;gBAAA,IAAI,MAAM,GAAG,CAAC,SAAS,MAAM;oBAC3B,IAAI,SAAS,YAAY,MAAM,GAAG,CAAC,SAAS,WAC1C,MAAM,GAAG,CAAC,KAAK;oBAEjB,IAAI,SAAS,YAAY,MAAM,GAAG,CAAC,SAAS,SAC1C,MAAM,GAAG,CAAC,KAAK;oBAGjB,MAAM,GAAG,CAAC,KAAK;gBACjB;YAAA,OAEA,MAAM,GAAG,CAAC,KAAK;QAEnB;IACF;IAEA,sBAAsB;IACtB,MAAM,OAAO,EAAE;IACf,KAAK,MAAM,OAAO,KAChB,KAAK,IAAI,CAAC;QACR,MAAM;aACN;QACA,eAAe,sCAAgB,CAAC,MAAM,GAAG,CAAC,KAAK;IACjD;IAEF,OAAO;AACT;AAEO,SAAS,0CACd,IAAS,EACT,OAA0B;IAE1B,0CAA0C,GAC1C,MAAM,aAAE,YAAY,CAAC,UAAG,QAAQ,iBAAI,WAAW,kBAAE,cAAc,EAAE,GAAG;IAEpE,IAAI,QAAQ,MAAM,OAAO,EAAE;IAE3B,MAAM,SAAS,KAAK,GAAG,CAAC,OAAO,KAAK,MAAM;IAE1C,IAAI,aAAa,0CAA0B,KAAK,KAAK,CAAC,GAAG;IACzD,IAAI,eAAe,WAAW,MAAM,CAAC,CAAC;QACpC,IAAI,eAAe,QAAQ,YAAY,QAAQ,CAAC,IAAI,GAAG,GACrD,OAAO;QAET,IAAI,kBAAkB,QAAQ,CAAC,eAAe,QAAQ,CAAC,IAAI,GAAG,GAC5D,OAAO;QAET,OAAO;IACT;IAEA,kBAAkB;IAClB,OAAO,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,MAAM,SAAS,CAAC,IAAI,GAAG,CAAC;QAC5B,IAAI,OAAO,MAAM,OAAO;QACxB,IAAI,OAAO,QAAQ,UACjB,OAAO;YAAE,GAAG,GAAG;YAAE,MAAM;QAAI;QAE7B,OAAO;YAAE,GAAG,GAAG;YAAE,GAAG,GAAG;QAAC;IAC1B;AACF","sources":["packages/data-sheet/src/utils/column-spec.ts"],"sourcesContent":["const defaultRenderers = {\n string: (d) => d,\n number: (d) => d?.toFixed(2),\n boolean: (d) => (d ? \"T\" : \"F\"),\n object: (d) => JSON.stringify(d),\n integer: (d) => d?.toFixed(0),\n array: (d) => d?.join(\", \"),\n};\n\nexport function generateDefaultColumnSpec<T>(data: Array<T>): ColumnSpec[] {\n /** Build a default column spec from a dataset based on the first n rows */\n if (data == null) return [];\n // Get the keys\n const keys = new Set();\n const types = new Map();\n for (const row of data) {\n if (row == null) continue;\n for (const key of Object.keys(row)) {\n const val = row[key];\n keys.add(key);\n\n if (val == null) continue;\n let type: string = typeof val;\n // Special 'type' for integers\n if (Number.isInteger(val)) {\n type = \"integer\";\n }\n\n // Special 'type' for arrays of simple values\n if (\n Array.isArray(val) &&\n val.every((d) => typeof d === \"string\" || typeof d === \"number\")\n ) {\n type = \"array\";\n }\n\n if (types.has(key)) {\n if (types.get(key) !== type) {\n if (type === \"number\" && types.get(key) === \"integer\") {\n types.set(key, \"number\");\n }\n if (type === \"object\" && types.get(key) === \"array\") {\n types.set(key, \"object\");\n }\n\n types.set(key, \"string\");\n }\n } else {\n types.set(key, type);\n }\n }\n }\n\n // Build a column spec\n const spec = [];\n for (const key of keys) {\n spec.push({\n name: key,\n key,\n valueRenderer: defaultRenderers[types.get(key)],\n });\n }\n return spec;\n}\n\nexport function generateColumnSpec<T>(\n data: T[],\n options: ColumnSpecOptions\n): ColumnSpec[] {\n /** Generate a column spec from a dataset */\n const { overrides = {}, nRows = 10, omitColumns, includeColumns } = options;\n\n if (data == null) return [];\n\n const _nRows = Math.min(nRows, data.length);\n\n let columnSpec = generateDefaultColumnSpec(data.slice(0, _nRows));\n let filteredSpec = columnSpec.filter((col) => {\n if (omitColumns != null && omitColumns.includes(col.key)) {\n return false;\n }\n if (includeColumns != null && !includeColumns.includes(col.key)) {\n return false;\n }\n return true;\n });\n\n // Apply overrides\n return filteredSpec.map((col) => {\n let ovr = overrides[col.key];\n if (ovr == null) return col;\n if (typeof ovr === \"string\") {\n return { ...col, name: ovr };\n }\n return { ...col, ...ovr };\n });\n}\n"],"names":[],"version":3,"file":"column-spec.4710da93.js.map"}
@@ -0,0 +1,11 @@
1
+ import {EditorPopup as $88e63ff6e4eea209$export$2a7e60c8443c1751} from "./editor-popup.9259608f.js";
2
+ import {ColorCell as $423bf54b4879ebeb$export$24aecfe8a925020d, pleasantCombination as $423bf54b4879ebeb$export$ba6491245befce5c, ColorPicker as $423bf54b4879ebeb$export$9feb1bc2e5f1ccb3} from "./colors.41c3ed7a.js";
3
+ import {EditableTextArea as $0aa421c11d2af971$export$b8e68c321a6269f1, handleSpecialKeys as $0aa421c11d2af971$export$52c8c5a1aad17e2a} from "./text-areas.079e8b15.js";
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export {$88e63ff6e4eea209$export$2a7e60c8443c1751 as EditorPopup, $423bf54b4879ebeb$export$24aecfe8a925020d as ColorCell, $423bf54b4879ebeb$export$ba6491245befce5c as pleasantCombination, $423bf54b4879ebeb$export$9feb1bc2e5f1ccb3 as ColorPicker, $0aa421c11d2af971$export$b8e68c321a6269f1 as EditableTextArea, $0aa421c11d2af971$export$52c8c5a1aad17e2a as handleSpecialKeys};
11
+ //# sourceMappingURL=components.c3ad66e9.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"","sources":["packages/data-sheet/src/components/index.ts"],"sourcesContent":["export * from \"./editor-popup\";\nexport * from \"./colors\";\nexport * from \"./text-areas\";\n"],"names":[],"version":3,"file":"components.c3ad66e9.js.map"}