@macrostrat/data-sheet 2.2.4 → 3.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.
- package/CHANGELOG.md +8 -0
- package/dist/components/actions.cjs +14 -0
- package/dist/components/actions.cjs.map +1 -0
- package/dist/components/actions.d.ts +2 -0
- package/dist/components/actions.js +14 -0
- package/dist/components/actions.js.map +1 -0
- package/dist/components/actions.module.sass.cjs +8 -0
- package/dist/components/actions.module.sass.cjs.map +1 -0
- package/dist/components/actions.module.sass.js +8 -0
- package/dist/components/actions.module.sass.js.map +1 -0
- package/dist/components/colors.cjs +102 -0
- package/dist/components/colors.cjs.map +1 -0
- package/dist/components/colors.d.ts +27 -0
- package/dist/components/colors.js +102 -0
- package/dist/components/colors.js.map +1 -0
- package/dist/components/editor-popup.cjs +77 -0
- package/dist/components/editor-popup.cjs.map +1 -0
- package/dist/components/editor-popup.d.ts +1 -0
- package/dist/components/editor-popup.js +77 -0
- package/dist/components/editor-popup.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/main.module.sass.cjs +18 -0
- package/dist/components/main.module.sass.cjs.map +1 -0
- package/dist/components/main.module.sass.js +18 -0
- package/dist/components/main.module.sass.js.map +1 -0
- package/dist/components/text-areas.cjs +41 -0
- package/dist/components/text-areas.cjs.map +1 -0
- package/dist/components/text-areas.d.ts +4 -0
- package/dist/components/text-areas.js +41 -0
- package/dist/components/text-areas.js.map +1 -0
- package/dist/core.cjs +477 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.ts +31 -0
- package/dist/core.js +475 -0
- package/dist/core.js.map +1 -0
- package/dist/data-sheet.css +1336 -0
- package/dist/index.cjs +51 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/main.module.sass.cjs +19 -0
- package/dist/main.module.sass.cjs.map +1 -0
- package/dist/main.module.sass.js +19 -0
- package/dist/main.module.sass.js.map +1 -0
- package/dist/postgrest-table/data-loaders.cjs +189 -0
- package/dist/postgrest-table/data-loaders.cjs.map +1 -0
- package/dist/postgrest-table/data-loaders.d.ts +55 -0
- package/dist/postgrest-table/data-loaders.js +189 -0
- package/dist/postgrest-table/data-loaders.js.map +1 -0
- package/dist/postgrest-table/index.cjs +212 -0
- package/dist/postgrest-table/index.cjs.map +1 -0
- package/dist/postgrest-table/index.d.ts +56 -0
- package/dist/postgrest-table/index.js +212 -0
- package/dist/postgrest-table/index.js.map +1 -0
- package/dist/postgrest-table/main.module.sass.cjs +22 -0
- package/dist/postgrest-table/main.module.sass.cjs.map +1 -0
- package/dist/postgrest-table/main.module.sass.js +22 -0
- package/dist/postgrest-table/main.module.sass.js.map +1 -0
- package/dist/provider.cjs +376 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.ts +69 -0
- package/dist/provider.js +376 -0
- package/dist/provider.js.map +1 -0
- package/dist/utils/column-spec.cjs +99 -0
- package/dist/utils/column-spec.cjs.map +1 -0
- package/dist/utils/column-spec.d.ts +31 -0
- package/dist/utils/column-spec.js +99 -0
- package/dist/utils/column-spec.js.map +1 -0
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/key-handling.cjs +85 -0
- package/dist/utils/key-handling.cjs.map +1 -0
- package/dist/utils/key-handling.d.ts +5 -0
- package/dist/utils/key-handling.js +85 -0
- package/dist/utils/key-handling.js.map +1 -0
- package/package.json +43 -37
- package/src/components/editor-popup.ts +2 -2
- package/src/components/text-areas.ts +1 -1
- package/src/core.ts +2 -8
- package/src/main.module.sass +7 -7
- package/src/postgrest-table/index.ts +6 -6
- package/src/postgrest-table/main.module.sass +1 -1
- package/src/provider.ts +1 -1
- package/dist/esm/data-sheet.186dcac8.js +0 -86
- package/dist/esm/data-sheet.186dcac8.js.map +0 -1
- package/dist/esm/data-sheet.2e11f097.js +0 -13
- package/dist/esm/data-sheet.2e11f097.js.map +0 -1
- package/dist/esm/data-sheet.37e35216.js +0 -40
- package/dist/esm/data-sheet.37e35216.js.map +0 -1
- package/dist/esm/data-sheet.403b9693.js +0 -429
- package/dist/esm/data-sheet.403b9693.js.map +0 -1
- package/dist/esm/data-sheet.40866550.js +0 -58
- package/dist/esm/data-sheet.40866550.js.map +0 -1
- package/dist/esm/data-sheet.410c5122.js +0 -83
- package/dist/esm/data-sheet.410c5122.js.map +0 -1
- package/dist/esm/data-sheet.48635112.js +0 -40
- package/dist/esm/data-sheet.48635112.js.map +0 -1
- package/dist/esm/data-sheet.53ee5bf7.js +0 -102
- package/dist/esm/data-sheet.53ee5bf7.js.map +0 -1
- package/dist/esm/data-sheet.54cfa8e8.js +0 -16
- package/dist/esm/data-sheet.54cfa8e8.js.map +0 -1
- package/dist/esm/data-sheet.560943e5.js +0 -237
- package/dist/esm/data-sheet.560943e5.js.map +0 -1
- package/dist/esm/data-sheet.706f955d.css +0 -11
- package/dist/esm/data-sheet.706f955d.css.map +0 -1
- package/dist/esm/data-sheet.8dbfccef.js +0 -16
- package/dist/esm/data-sheet.8dbfccef.js.map +0 -1
- package/dist/esm/data-sheet.9a4e4e01.js +0 -77
- package/dist/esm/data-sheet.9a4e4e01.js.map +0 -1
- package/dist/esm/data-sheet.a3eb6088.js +0 -21
- package/dist/esm/data-sheet.a3eb6088.js.map +0 -1
- package/dist/esm/data-sheet.a7230b2f.css +0 -69
- package/dist/esm/data-sheet.a7230b2f.css.map +0 -1
- package/dist/esm/data-sheet.b3ccc91b.css +0 -65
- package/dist/esm/data-sheet.b3ccc91b.css.map +0 -1
- package/dist/esm/data-sheet.c9b6b6f2.js +0 -439
- package/dist/esm/data-sheet.c9b6b6f2.js.map +0 -1
- package/dist/esm/data-sheet.d2160988.js +0 -218
- package/dist/esm/data-sheet.d2160988.js.map +0 -1
- package/dist/esm/data-sheet.d570ef95.js +0 -43
- package/dist/esm/data-sheet.d570ef95.js.map +0 -1
- package/dist/esm/data-sheet.ef63e366.css +0 -110
- package/dist/esm/data-sheet.ef63e366.css.map +0 -1
- package/dist/esm/index.d.ts +0 -292
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -15
- package/dist/esm/index.js.map +0 -1
- package/dist/node/data-sheet.28641e23.css +0 -2
- package/dist/node/data-sheet.28641e23.css.map +0 -1
- package/dist/node/data-sheet.2cac1a8c.js +0 -2
- package/dist/node/data-sheet.2cac1a8c.js.map +0 -1
- package/dist/node/data-sheet.3680e59d.js +0 -2
- package/dist/node/data-sheet.3680e59d.js.map +0 -1
- package/dist/node/data-sheet.3c728e09.js +0 -2
- package/dist/node/data-sheet.3c728e09.js.map +0 -1
- package/dist/node/data-sheet.474755ec.js +0 -2
- package/dist/node/data-sheet.474755ec.js.map +0 -1
- package/dist/node/data-sheet.648db7af.js +0 -2
- package/dist/node/data-sheet.648db7af.js.map +0 -1
- package/dist/node/data-sheet.7b95fbc1.css +0 -2
- package/dist/node/data-sheet.7b95fbc1.css.map +0 -1
- package/dist/node/data-sheet.945becc3.js +0 -2
- package/dist/node/data-sheet.945becc3.js.map +0 -1
- package/dist/node/data-sheet.97ac1b50.js +0 -2
- package/dist/node/data-sheet.97ac1b50.js.map +0 -1
- package/dist/node/data-sheet.ae543670.js +0 -2
- package/dist/node/data-sheet.ae543670.js.map +0 -1
- package/dist/node/data-sheet.afb25a47.js +0 -2
- package/dist/node/data-sheet.afb25a47.js.map +0 -1
- package/dist/node/data-sheet.bb45401c.js +0 -2
- package/dist/node/data-sheet.bb45401c.js.map +0 -1
- package/dist/node/data-sheet.c90cb14b.css +0 -2
- package/dist/node/data-sheet.c90cb14b.css.map +0 -1
- package/dist/node/data-sheet.cbbc8d31.js +0 -2
- package/dist/node/data-sheet.cbbc8d31.js.map +0 -1
- package/dist/node/data-sheet.d971095a.js +0 -2
- package/dist/node/data-sheet.d971095a.js.map +0 -1
- package/dist/node/data-sheet.dffdda71.js +0 -2
- package/dist/node/data-sheet.dffdda71.js.map +0 -1
- package/dist/node/data-sheet.e472411d.js +0 -2
- package/dist/node/data-sheet.e472411d.js.map +0 -1
- package/dist/node/data-sheet.ef0c95f4.js +0 -2
- package/dist/node/data-sheet.ef0c95f4.js.map +0 -1
- package/dist/node/data-sheet.f0223f39.js +0 -2
- package/dist/node/data-sheet.f0223f39.js.map +0 -1
- package/dist/node/data-sheet.ffaf8ac7.css +0 -2
- package/dist/node/data-sheet.ffaf8ac7.css.map +0 -1
- package/dist/node/index.js +0 -2
- package/dist/node/index.js.map +0 -1
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import $eBkqD$datasheet37e35216js from "./data-sheet.37e35216.js";
|
|
2
|
-
import "./data-sheet.a7230b2f.css";
|
|
3
|
-
import {multiLineTextKeyHandler as $eBkqD$multiLineTextKeyHandler} from "./data-sheet.8dbfccef.js";
|
|
4
|
-
import $eBkqD$macrostrathyper from "@macrostrat/hyper";
|
|
5
|
-
import {Button as $eBkqD$Button} from "@blueprintjs/core";
|
|
6
|
-
import {useRef as $eBkqD$useRef, useEffect as $eBkqD$useEffect} from "react";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function $parcel$interopDefault(a) {
|
|
10
|
-
return a && a.__esModule ? a.default : a;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const $0aa421c11d2af971$var$h = (0, $eBkqD$macrostrathyper).styled((0, ($parcel$interopDefault($eBkqD$datasheet37e35216js))));
|
|
18
|
-
function $0aa421c11d2af971$export$b8e68c321a6269f1({ value: value, onChange: onChange }) {
|
|
19
|
-
const ref = (0, $eBkqD$useRef)(null);
|
|
20
|
-
(0, $eBkqD$useEffect)(()=>{
|
|
21
|
-
if (ref.current == null) return;
|
|
22
|
-
ref.current.focus();
|
|
23
|
-
// Get the current value
|
|
24
|
-
const val = ref.current.value;
|
|
25
|
-
// Move the cursor to the end of the text
|
|
26
|
-
ref.current.setSelectionRange(val.length, val.length);
|
|
27
|
-
}, []);
|
|
28
|
-
return $0aa421c11d2af971$var$h("div.editable-text-area", [
|
|
29
|
-
$0aa421c11d2af971$var$h("textarea.bp5-input", {
|
|
30
|
-
ref: ref,
|
|
31
|
-
value: value ?? "",
|
|
32
|
-
onChange: (evt)=>onChange(evt.target.value),
|
|
33
|
-
onKeyDown: (0, $eBkqD$multiLineTextKeyHandler)
|
|
34
|
-
}),
|
|
35
|
-
$0aa421c11d2af971$var$h("div.tools", [
|
|
36
|
-
$0aa421c11d2af971$var$h((0, $eBkqD$Button), {
|
|
37
|
-
icon: "key-enter",
|
|
38
|
-
minimal: true,
|
|
39
|
-
small: true,
|
|
40
|
-
onClick () {
|
|
41
|
-
// Get cursor position
|
|
42
|
-
let _value = value ?? "";
|
|
43
|
-
const cursorPos = ref.current.selectionStart ?? _value.length;
|
|
44
|
-
// Insert a newline at the cursor position
|
|
45
|
-
onChange(_value.slice(0, cursorPos) + "\n" + _value.slice(cursorPos));
|
|
46
|
-
// Re-focus the textarea
|
|
47
|
-
ref.current.focus();
|
|
48
|
-
// Move the cursor to the end of the line
|
|
49
|
-
ref.current.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
])
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export {$0aa421c11d2af971$export$b8e68c321a6269f1 as EditableTextArea};
|
|
58
|
-
//# sourceMappingURL=data-sheet.40866550.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAMA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,qEAAK;AAErB,SAAS,0CAAiB,SAAE,KAAK,YAAE,QAAQ,EAAE;IAClD,MAAM,MAAM,CAAA,GAAA,aAAK,EAAE;IAEnB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,MAAM;QACzB,IAAI,OAAO,CAAC,KAAK;QACjB,wBAAwB;QACxB,MAAM,MAAM,IAAI,OAAO,CAAC,KAAK;QAC7B,yCAAyC;QACzC,IAAI,OAAO,CAAC,iBAAiB,CAAC,IAAI,MAAM,EAAE,IAAI,MAAM;IACtD,GAAG,EAAE;IAEL,OAAO,wBAAE,0BAA0B;QACjC,wBAAE,sBAAsB;iBACtB;YACA,OAAO,SAAS;YAChB,UAAU,CAAC,MAAQ,SAAS,IAAI,MAAM,CAAC,KAAK;YAC5C,WAAW,CAAA,GAAA,8BAAsB;QACnC;QACA,wBAAE,aAAa;YACb,wBAAE,CAAA,GAAA,aAAK,GAAG;gBACR,MAAM;gBACN,SAAS;gBACT,OAAO;gBACP;oBACE,sBAAsB;oBACtB,IAAI,SAAS,SAAS;oBAEtB,MAAM,YAAY,IAAI,OAAO,CAAC,cAAc,IAAI,OAAO,MAAM;oBAC7D,0CAA0C;oBAC1C,SAAS,OAAO,KAAK,CAAC,GAAG,aAAa,OAAO,OAAO,KAAK,CAAC;oBAC1D,wBAAwB;oBACxB,IAAI,OAAO,CAAC,KAAK;oBACjB,yCAAyC;oBACzC,IAAI,OAAO,CAAC,iBAAiB,CAAC,YAAY,GAAG,YAAY;gBAC3D;YACF;SACD;KACF;AACH","sources":["packages/data-sheet/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.bp5-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":[],"version":3,"file":"data-sheet.40866550.js.map"}
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
const $afa6527b61074fe8$var$defaultWidthForValue = (val)=>String(val).length * 8;
|
|
10
|
-
function $afa6527b61074fe8$export$90c86365d1c277aa(data, options = {}) {
|
|
11
|
-
/** Build a default column spec from a dataset based on the first n rows */ if (data == null) return [];
|
|
12
|
-
// Get the keys
|
|
13
|
-
const { defaultWidth: defaultWidth = 150, calculateWidths: calculateWidths = true, getWidthForValue: getWidthForValue = $afa6527b61074fe8$var$defaultWidthForValue } = options;
|
|
14
|
-
const keys = new Set();
|
|
15
|
-
const types = new Map();
|
|
16
|
-
const columnWidths = new Map();
|
|
17
|
-
for (const row of data){
|
|
18
|
-
if (row == null) continue;
|
|
19
|
-
for (const key of Object.keys(row)){
|
|
20
|
-
const val = row[key];
|
|
21
|
-
keys.add(key);
|
|
22
|
-
if (val == null) continue;
|
|
23
|
-
if (calculateWidths) {
|
|
24
|
-
let width = getWidthForValue(val);
|
|
25
|
-
if (width != null && width >= 0) columnWidths.set(key, Math.max(width, columnWidths.get(key) ?? 0));
|
|
26
|
-
}
|
|
27
|
-
let type = typeof val;
|
|
28
|
-
// Special 'type' for integers
|
|
29
|
-
if (Number.isInteger(val)) type = "integer";
|
|
30
|
-
// Special 'type' for arrays of simple values
|
|
31
|
-
if (Array.isArray(val) && val.every((d)=>typeof d === "string" || typeof d === "number")) type = "array";
|
|
32
|
-
if (types.has(key)) {
|
|
33
|
-
if (types.get(key) !== type) {
|
|
34
|
-
if (type === "number" && types.get(key) === "integer") types.set(key, "number");
|
|
35
|
-
if (type === "object" && types.get(key) === "array") types.set(key, "object");
|
|
36
|
-
types.set(key, "string");
|
|
37
|
-
}
|
|
38
|
-
} else types.set(key, type);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Build a column spec
|
|
42
|
-
const spec = [];
|
|
43
|
-
for (const key of keys){
|
|
44
|
-
let width = null;
|
|
45
|
-
if (calculateWidths) // If we are calculating widths, use the value lengths
|
|
46
|
-
width = Math.min(Math.max(defaultWidth / 2, columnWidths.get(key) ?? defaultWidth), defaultWidth * 1.5);
|
|
47
|
-
spec.push({
|
|
48
|
-
name: key,
|
|
49
|
-
key: key,
|
|
50
|
-
valueRenderer: $afa6527b61074fe8$var$defaultRenderers[types.get(key)],
|
|
51
|
-
width: width
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return spec;
|
|
55
|
-
}
|
|
56
|
-
function $afa6527b61074fe8$export$30457629971d2e1f(data, options) {
|
|
57
|
-
/** Generate a column spec from a dataset */ const { overrides: overrides = {}, nRows: nRows = 10, omitColumns: omitColumns, includeColumns: includeColumns } = options;
|
|
58
|
-
if (data == null) return [];
|
|
59
|
-
const _nRows = Math.min(nRows, data.length);
|
|
60
|
-
let columnSpec = $afa6527b61074fe8$export$90c86365d1c277aa(data.slice(0, _nRows));
|
|
61
|
-
let filteredSpec = columnSpec.filter((col)=>{
|
|
62
|
-
if (omitColumns != null && omitColumns.includes(col.key)) return false;
|
|
63
|
-
if (includeColumns != null && !includeColumns.includes(col.key)) return false;
|
|
64
|
-
return true;
|
|
65
|
-
});
|
|
66
|
-
// Apply overrides
|
|
67
|
-
return filteredSpec.map((col)=>{
|
|
68
|
-
let ovr = overrides[col.key];
|
|
69
|
-
if (ovr == null) return col;
|
|
70
|
-
if (typeof ovr === "string") return {
|
|
71
|
-
...col,
|
|
72
|
-
name: ovr
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
...col,
|
|
76
|
-
...ovr
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export {$afa6527b61074fe8$export$90c86365d1c277aa as generateDefaultColumnSpec, $afa6527b61074fe8$export$30457629971d2e1f as generateColumnSpec};
|
|
83
|
-
//# sourceMappingURL=data-sheet.410c5122.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAEA,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;AAQA,MAAM,6CAAuB,CAAC,MAAQ,OAAO,KAAK,MAAM,GAAG;AA0BpD,SAAS,0CACd,IAAc,EACd,UAAqC,CAAC,CAAC;IAEvC,yEAAyE,GACzE,IAAI,QAAQ,MAAM,OAAO,EAAE;IAC3B,eAAe;IAEf,MAAM,gBACJ,eAAe,sBACf,kBAAkB,wBAClB,mBAAmB,4CACpB,GAAG;IAEJ,MAAM,OAAO,IAAI;IACjB,MAAM,QAAQ,IAAI;IAElB,MAAM,eAAe,IAAI;IAEzB,KAAK,MAAM,OAAO,KAAM;QACtB,IAAI,OAAO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,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":["import React from \"react\";\n\nconst 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\ninterface ColumnSpecGenerateOptions {\n calculateWidths?: boolean;\n defaultWidth?: number;\n getWidthForValue?: (value: any) => number;\n}\n\nconst defaultWidthForValue = (val) => String(val).length * 8;\n\nexport interface ColumnSpec {\n name: string;\n key: string;\n required?: boolean;\n isValid?: (d: any) => boolean;\n transformValue?: (d: any) => any;\n valueRenderer?: (d: any) => string | React.ReactNode;\n dataEditor?: any;\n cellComponent?: any;\n category?: string;\n editable?: boolean;\n inlineEditor?: boolean | React.ComponentType<any> | string | null;\n style?: React.CSSProperties;\n width?: number;\n}\n\nexport interface ColumnSpecOptions<T> {\n overrides: Record<string, Partial<ColumnSpec> | string>;\n data?: T[]; // Data to use for type inference\n nRows?: number; // Number of rows to use for type inference\n omitColumns?: string[]; // Columns to omit. Takes precedence over includeColumns.\n includeColumns?: string[]; // Columns to include.\n}\n\nexport function generateDefaultColumnSpec<T>(\n data: Array<T>,\n options: ColumnSpecGenerateOptions = {},\n): 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\n const {\n defaultWidth = 150,\n calculateWidths = true,\n getWidthForValue = defaultWidthForValue,\n } = options;\n\n const keys = new Set<string>();\n const types = new Map();\n\n const columnWidths = new Map<string, number>();\n\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\n if (calculateWidths) {\n let width = getWidthForValue(val);\n if (width != null && width >= 0) {\n columnWidths.set(key, Math.max(width, columnWidths.get(key) ?? 0));\n }\n }\n\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 let width = null;\n if (calculateWidths) {\n // If we are calculating widths, use the value lengths\n width = Math.min(\n Math.max(defaultWidth / 2, columnWidths.get(key) ?? defaultWidth),\n defaultWidth * 1.5,\n );\n }\n\n spec.push({\n name: key,\n key,\n valueRenderer: defaultRenderers[types.get(key)],\n width,\n });\n }\n return spec;\n}\n\nexport function generateColumnSpec<T>(\n data: T[],\n options: ColumnSpecOptions<T>,\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":"data-sheet.410c5122.js.map"}
|
|
@@ -1,40 +0,0 @@
|
|
|
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 $4829e0f8e57759e3$exports = {};
|
|
6
|
-
|
|
7
|
-
$parcel$export($4829e0f8e57759e3$exports, "basis-col", () => $4829e0f8e57759e3$export$1ed47493f461348b, (v) => $4829e0f8e57759e3$export$1ed47493f461348b = v);
|
|
8
|
-
$parcel$export($4829e0f8e57759e3$exports, "basis-panel", () => $4829e0f8e57759e3$export$c7bc816036885da1, (v) => $4829e0f8e57759e3$export$c7bc816036885da1 = v);
|
|
9
|
-
$parcel$export($4829e0f8e57759e3$exports, "data-sheet-outer", () => $4829e0f8e57759e3$export$a41cc5b8098038de, (v) => $4829e0f8e57759e3$export$a41cc5b8098038de = v);
|
|
10
|
-
$parcel$export($4829e0f8e57759e3$exports, "description", () => $4829e0f8e57759e3$export$6d59db4903f20f7d, (v) => $4829e0f8e57759e3$export$6d59db4903f20f7d = v);
|
|
11
|
-
$parcel$export($4829e0f8e57759e3$exports, "inline-lithology", () => $4829e0f8e57759e3$export$1ec8789066e3d6bc, (v) => $4829e0f8e57759e3$export$1ec8789066e3d6bc = v);
|
|
12
|
-
$parcel$export($4829e0f8e57759e3$exports, "lithology", () => $4829e0f8e57759e3$export$5c23751bce3f0807, (v) => $4829e0f8e57759e3$export$5c23751bce3f0807 = v);
|
|
13
|
-
$parcel$export($4829e0f8e57759e3$exports, "liths", () => $4829e0f8e57759e3$export$edffc8ad17c72de6, (v) => $4829e0f8e57759e3$export$edffc8ad17c72de6 = v);
|
|
14
|
-
$parcel$export($4829e0f8e57759e3$exports, "long-text", () => $4829e0f8e57759e3$export$617db6d5463a006, (v) => $4829e0f8e57759e3$export$617db6d5463a006 = v);
|
|
15
|
-
$parcel$export($4829e0f8e57759e3$exports, "tag-cell-content", () => $4829e0f8e57759e3$export$f83be3fbc2592c17, (v) => $4829e0f8e57759e3$export$f83be3fbc2592c17 = v);
|
|
16
|
-
$parcel$export($4829e0f8e57759e3$exports, "tag-header", () => $4829e0f8e57759e3$export$3a7d1f90484c84e1, (v) => $4829e0f8e57759e3$export$3a7d1f90484c84e1 = v);
|
|
17
|
-
var $4829e0f8e57759e3$export$1ed47493f461348b;
|
|
18
|
-
var $4829e0f8e57759e3$export$c7bc816036885da1;
|
|
19
|
-
var $4829e0f8e57759e3$export$a41cc5b8098038de;
|
|
20
|
-
var $4829e0f8e57759e3$export$6d59db4903f20f7d;
|
|
21
|
-
var $4829e0f8e57759e3$export$1ec8789066e3d6bc;
|
|
22
|
-
var $4829e0f8e57759e3$export$5c23751bce3f0807;
|
|
23
|
-
var $4829e0f8e57759e3$export$edffc8ad17c72de6;
|
|
24
|
-
var $4829e0f8e57759e3$export$617db6d5463a006;
|
|
25
|
-
var $4829e0f8e57759e3$export$f83be3fbc2592c17;
|
|
26
|
-
var $4829e0f8e57759e3$export$3a7d1f90484c84e1;
|
|
27
|
-
$4829e0f8e57759e3$export$1ed47493f461348b = `h0RamW_basis-col`;
|
|
28
|
-
$4829e0f8e57759e3$export$c7bc816036885da1 = `h0RamW_basis-panel`;
|
|
29
|
-
$4829e0f8e57759e3$export$a41cc5b8098038de = `h0RamW_data-sheet-outer`;
|
|
30
|
-
$4829e0f8e57759e3$export$6d59db4903f20f7d = `h0RamW_description`;
|
|
31
|
-
$4829e0f8e57759e3$export$1ec8789066e3d6bc = `h0RamW_inline-lithology`;
|
|
32
|
-
$4829e0f8e57759e3$export$5c23751bce3f0807 = `h0RamW_lithology`;
|
|
33
|
-
$4829e0f8e57759e3$export$edffc8ad17c72de6 = `h0RamW_liths`;
|
|
34
|
-
$4829e0f8e57759e3$export$617db6d5463a006 = `h0RamW_long-text`;
|
|
35
|
-
$4829e0f8e57759e3$export$f83be3fbc2592c17 = `h0RamW_tag-cell-content`;
|
|
36
|
-
$4829e0f8e57759e3$export$3a7d1f90484c84e1 = `h0RamW_tag-header`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export {$4829e0f8e57759e3$exports as default};
|
|
40
|
-
//# sourceMappingURL=data-sheet.48635112.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AATA,4CAA8B,CAAC,gBAAgB,CAAC;AAChD,4CAAgC,CAAC,kBAAkB,CAAC;AACpD,4CAAqC,CAAC,uBAAuB,CAAC;AAC9D,4CAAgC,CAAC,kBAAkB,CAAC;AACpD,4CAAqC,CAAC,uBAAuB,CAAC;AAC9D,4CAA8B,CAAC,gBAAgB,CAAC;AAChD,4CAA0B,CAAC,YAAY,CAAC;AACxC,2CAA8B,CAAC,gBAAgB,CAAC;AAChD,4CAAqC,CAAC,uBAAuB,CAAC;AAC9D,4CAA+B,CAAC,iBAAiB,CAAC","sources":["packages/data-sheet/src/postgrest-table/main.module.sass"],"sourcesContent":[".lithology\n font-weight: bold\n display: inline-block\n padding: 0 0.5em\n border-radius: 0.5em\n\n.inline-lithology .lithology\n line-height: 1em\n\n.basis-panel\n :global(.bp5-tag)\n margin: 0 0.5em 0.5em 0\n\n td\n vertical-align: top\n\n th\n text-align: left\n font-weight: 400\n font-size: 0.9em\n font-style: italic\n color: var(--secondary-color)\n\n.basis-panel, .long-text\n max-width: 20em\n padding: 8px\n max-height: 30em\n overflow-y: scroll\n pointer-events: all\n\n.description\n font-style: italic\n\n\n.tag-header\n font-weight: bold\n text-transform: small-caps\n font-size: 0.8em\n color: var(--secondary-color)\n\n.basis-col\n max-width: 15em\n\n.liths>*\n margin-right: 0.5em\n\n.data-sheet-outer\n position: relative\n flex: 1\n display: flex\n min-height: 0\n\n.tag-cell-content\n line-height: 1\n"],"names":[],"version":3,"file":"data-sheet.48635112.js.map"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import $iaGQ1$datasheet37e35216js from "./data-sheet.37e35216.js";
|
|
2
|
-
import "./data-sheet.a7230b2f.css";
|
|
3
|
-
import {Cell as $iaGQ1$Cell} from "@blueprintjs/table";
|
|
4
|
-
import {useInDarkMode as $iaGQ1$useInDarkMode} from "@macrostrat/ui-components";
|
|
5
|
-
import $iaGQ1$macrostrathyper from "@macrostrat/hyper";
|
|
6
|
-
import {getLuminanceAdjustedColorScheme as $iaGQ1$getLuminanceAdjustedColorScheme, asChromaColor as $iaGQ1$asChromaColor} from "@macrostrat/color-utils";
|
|
7
|
-
import {useRef as $iaGQ1$useRef, useEffect as $iaGQ1$useEffect, useMemo as $iaGQ1$useMemo} from "react";
|
|
8
|
-
import {memoize as $iaGQ1$memoize} from "underscore";
|
|
9
|
-
import $iaGQ1$uiwreactcolorsketch from "@uiw/react-color-sketch";
|
|
10
|
-
import $iaGQ1$classnames from "classnames";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function $parcel$interopDefault(a) {
|
|
14
|
-
return a && a.__esModule ? a.default : a;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const $423bf54b4879ebeb$var$h = (0, $iaGQ1$macrostrathyper).styled((0, ($parcel$interopDefault($iaGQ1$datasheet37e35216js))));
|
|
26
|
-
function $423bf54b4879ebeb$export$24aecfe8a925020d({ value: value, children: children, style: style, intent: intent, adjustLuminance: adjustLuminance = true, className: className, ...rest }) {
|
|
27
|
-
const darkMode = (0, $iaGQ1$useInDarkMode)();
|
|
28
|
-
const _className = (0, $iaGQ1$classnames)(className, "color-cell");
|
|
29
|
-
let mainColor = "var(--text-color)";
|
|
30
|
-
let backgroundColor = value;
|
|
31
|
-
if (adjustLuminance) {
|
|
32
|
-
// If adjustLuminance is true, get the color scheme based on the value
|
|
33
|
-
let colors = $423bf54b4879ebeb$var$colorCombo(value, darkMode, 0.05);
|
|
34
|
-
if (colors != null) {
|
|
35
|
-
mainColor = colors.mainColor;
|
|
36
|
-
backgroundColor = colors.backgroundColor;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (intent != null) // If an intent is specified, override the main color
|
|
40
|
-
mainColor = undefined;
|
|
41
|
-
return $423bf54b4879ebeb$var$h((0, $iaGQ1$Cell), {
|
|
42
|
-
intent: intent,
|
|
43
|
-
className: _className,
|
|
44
|
-
...rest,
|
|
45
|
-
style: {
|
|
46
|
-
color: mainColor,
|
|
47
|
-
backgroundColor: backgroundColor,
|
|
48
|
-
...style
|
|
49
|
-
}
|
|
50
|
-
}, children);
|
|
51
|
-
}
|
|
52
|
-
function $423bf54b4879ebeb$export$e5f546a5ba915f1c(value) {
|
|
53
|
-
return $423bf54b4879ebeb$var$h("span.color-swatch-container", [
|
|
54
|
-
$423bf54b4879ebeb$var$h("span.color-swatch", {
|
|
55
|
-
style: {
|
|
56
|
-
backgroundColor: value
|
|
57
|
-
}
|
|
58
|
-
}),
|
|
59
|
-
$423bf54b4879ebeb$var$h("span.color-name", value)
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
const $423bf54b4879ebeb$var$colorCombo = (0, $iaGQ1$memoize)((0, $iaGQ1$getLuminanceAdjustedColorScheme));
|
|
63
|
-
var $423bf54b4879ebeb$var$ColorConversionType = /*#__PURE__*/ function(ColorConversionType) {
|
|
64
|
-
ColorConversionType["HEX"] = "hex";
|
|
65
|
-
ColorConversionType["RGB"] = "rgb";
|
|
66
|
-
ColorConversionType["HSL"] = "hsl";
|
|
67
|
-
ColorConversionType["CSS"] = "css";
|
|
68
|
-
return ColorConversionType;
|
|
69
|
-
}($423bf54b4879ebeb$var$ColorConversionType || {});
|
|
70
|
-
function $423bf54b4879ebeb$export$9feb1bc2e5f1ccb3({ value: value, onChange: onChange, editable: editable = true, type: type = "css" }) {
|
|
71
|
-
const ref = (0, $iaGQ1$useRef)(null);
|
|
72
|
-
(0, $iaGQ1$useEffect)(()=>{
|
|
73
|
-
if (ref.current == null) return;
|
|
74
|
-
ref.current.focus();
|
|
75
|
-
}, []);
|
|
76
|
-
const color = (0, $iaGQ1$useMemo)(()=>{
|
|
77
|
-
try {
|
|
78
|
-
return (0, $iaGQ1$asChromaColor)(value).hex();
|
|
79
|
-
} catch {
|
|
80
|
-
return "#aaaaaa";
|
|
81
|
-
}
|
|
82
|
-
}, [
|
|
83
|
-
value
|
|
84
|
-
]);
|
|
85
|
-
return $423bf54b4879ebeb$var$h("div.color-picker-container", {
|
|
86
|
-
onKeyDown (evt) {
|
|
87
|
-
if (evt.key === "Escape") evt.preventDefault();
|
|
88
|
-
},
|
|
89
|
-
ref: ref,
|
|
90
|
-
tabIndex: 0
|
|
91
|
-
}, $423bf54b4879ebeb$var$h((0, $iaGQ1$uiwreactcolorsketch), {
|
|
92
|
-
color: color,
|
|
93
|
-
disableAlpha: true,
|
|
94
|
-
onChange (color) {
|
|
95
|
-
onChange((0, $iaGQ1$asChromaColor)(color.hexa)[type]());
|
|
96
|
-
}
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export {$423bf54b4879ebeb$export$24aecfe8a925020d as ColorCell, $423bf54b4879ebeb$export$e5f546a5ba915f1c as colorSwatchRenderer, $423bf54b4879ebeb$export$9feb1bc2e5f1ccb3 as ColorPicker};
|
|
102
|
-
//# sourceMappingURL=data-sheet.53ee5bf7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,qEAAK;AAErB,SAAS,0CAAU,SACxB,KAAK,YACL,QAAQ,SACR,KAAK,UACL,MAAM,mBACN,kBAAkB,iBAClB,SAAS,EACT,GAAG,MACJ;IACC,MAAM,WAAW,CAAA,GAAA,oBAAY;IAE7B,MAAM,aAAa,CAAA,GAAA,iBAAS,EAAE,WAAW;IAEzC,IAAI,YAAY;IAChB,IAAI,kBAAkB;IAEtB,IAAI,iBAAiB;QACnB,sEAAsE;QACtE,IAAI,SAAS,iCAAW,OAAO,UAAU;QACzC,IAAI,UAAU,MAAM;YAClB,YAAY,OAAO,SAAS;YAC5B,kBAAkB,OAAO,eAAe;QAC1C;IACF;IAEA,IAAI,UAAU,MACZ,qDAAqD;IACrD,YAAY;IAGd,OAAO,wBACL,CAAA,GAAA,WAAG,GACH;gBACE;QACA,WAAW;QACX,GAAG,IAAI;QACP,OAAO;YACL,OAAO;6BACP;YACA,GAAG,KAAK;QACV;IACF,GACA;AAEJ;AAEO,SAAS,0CAAoB,KAAK;IACvC,OAAO,wBAAE,+BAA+B;QACtC,wBAAE,qBAAqB;YACrB,OAAO;gBAAE,iBAAiB;YAAM;QAClC;QACA,wBAAE,mBAAmB;KACtB;AACH;AAEA,MAAM,mCAAa,CAAA,GAAA,cAAM,EAAE,CAAA,GAAA,sCAA8B;AAEzD,IAAA,AAAK,mEAAA;;;;;WAAA;EAAA;AAOE,SAAS,0CAAY,SAC1B,KAAK,YACL,QAAQ,YACR,WAAW,YACX,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,MAAM,QAAQ,CAAA,GAAA,cAAM,EAAE;QACpB,IAAI;YACF,OAAO,CAAA,GAAA,oBAAY,EAAE,OAAO,GAAG;QACjC,EAAE,OAAM;YACN,OAAO;QACT;IACF,GAAG;QAAC;KAAM;IAEV,OAAO,wBACL,8BACA;QACE,WAAU,GAAG;YACX,IAAI,IAAI,GAAG,KAAK,UACd,IAAI,cAAc;QAEtB;aACA;QACA,UAAU;IACZ,GACA,wBAAE,CAAA,GAAA,0BAAK,GAAG;eACR;QACA,cAAc;QACd,UAAS,KAAK;YACZ,SAAS,CAAA,GAAA,oBAAY,EAAE,MAAM,IAAI,CAAC,CAAC,KAAK;QAC1C;IACF;AAEJ","sources":["packages/data-sheet/src/components/colors.ts"],"sourcesContent":["import { Cell } from \"@blueprintjs/table\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport {\n asChromaColor,\n getLuminanceAdjustedColorScheme,\n} from \"@macrostrat/color-utils\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { memoize } from \"underscore\";\nimport Sketch from \"@uiw/react-color-sketch\";\nimport classNames from \"classnames\";\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\nenum ColorConversionType {\n HEX = \"hex\",\n RGB = \"rgb\",\n HSL = \"hsl\",\n CSS = \"css\",\n}\n\nexport function ColorPicker({\n value,\n onChange,\n editable = true,\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 const color = useMemo(() => {\n try {\n return asChromaColor(value).hex();\n } catch {\n return \"#aaaaaa\";\n }\n }, [value]);\n\n return h(\n \"div.color-picker-container\",\n {\n onKeyDown(evt) {\n if (evt.key === \"Escape\") {\n evt.preventDefault();\n }\n },\n ref,\n tabIndex: 0,\n },\n h(Sketch, {\n color,\n disableAlpha: true,\n onChange(color) {\n onChange(asChromaColor(color.hexa)[type]());\n },\n }),\n );\n}\n"],"names":[],"version":3,"file":"data-sheet.53ee5bf7.js.map"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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=data-sheet.54cfa8e8.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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":"data-sheet.54cfa8e8.js.map"}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import "./data-sheet.b3ccc91b.css";
|
|
2
|
-
import $52ytf$datasheet48635112js from "./data-sheet.48635112.js";
|
|
3
|
-
import {DataSheet as $8bdde5bf56f8afde$export$dea56b0125f0282d, getRowsToDelete as $8bdde5bf56f8afde$export$222fa1b971ddc36} from "./data-sheet.403b9693.js";
|
|
4
|
-
import {usePostgRESTLazyLoader as $4c00def725e3d600$export$4dffb9bb65ef8b2} from "./data-sheet.d2160988.js";
|
|
5
|
-
import {ColorCell as $52ytf$ColorCell} from "./data-sheet.2e11f097.js";
|
|
6
|
-
import {HotkeysProvider as $52ytf$HotkeysProvider, Spinner as $52ytf$Spinner, InputGroup as $52ytf$InputGroup} from "@blueprintjs/core";
|
|
7
|
-
import $52ytf$macrostrathyper from "@macrostrat/hyper";
|
|
8
|
-
import {LithologyTag as $52ytf$LithologyTag, Tag as $52ytf$Tag, TagSize as $52ytf$TagSize} from "@macrostrat/data-components";
|
|
9
|
-
import {useState as $52ytf$useState, useCallback as $52ytf$useCallback} from "react";
|
|
10
|
-
import {ErrorBoundary as $52ytf$ErrorBoundary, ToasterContext as $52ytf$ToasterContext, useToaster as $52ytf$useToaster, useAPIResult as $52ytf$useAPIResult} from "@macrostrat/ui-components";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function $parcel$interopDefault(a) {
|
|
14
|
-
return a && a.__esModule ? a.default : a;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const $ea3fc6a8962e0e3d$var$h = (0, $52ytf$macrostrathyper).styled((0, ($parcel$interopDefault($52ytf$datasheet48635112js))));
|
|
26
|
-
function $ea3fc6a8962e0e3d$export$34ce2a614f5dd320(props) {
|
|
27
|
-
return $ea3fc6a8962e0e3d$var$h((0, $52ytf$ErrorBoundary), $ea3fc6a8962e0e3d$var$h((0, $52ytf$HotkeysProvider), $ea3fc6a8962e0e3d$var$h((0, $52ytf$ToasterContext), $ea3fc6a8962e0e3d$var$h($ea3fc6a8962e0e3d$var$_PostgRESTTableView, props))));
|
|
28
|
-
}
|
|
29
|
-
const $ea3fc6a8962e0e3d$var$successResponses = [
|
|
30
|
-
200,
|
|
31
|
-
201
|
|
32
|
-
];
|
|
33
|
-
function $ea3fc6a8962e0e3d$var$_PostgRESTTableView({ endpoint: endpoint, table: table, columnOptions: columnOptions, order: order, columns: columns, editable: editable = false, filter: filter, enableFullTableSearch: enableFullTableSearch = false, dataSheetActions: dataSheetActions, identityKey: identityKey = "id", ...rest }) {
|
|
34
|
-
const [input, setInput] = (0, $52ytf$useState)("");
|
|
35
|
-
if (enableFullTableSearch) {
|
|
36
|
-
const columnList = columns ?? $ea3fc6a8962e0e3d$var$getColumnList(endpoint, table);
|
|
37
|
-
filter = (query)=>{
|
|
38
|
-
const urlParams = new URLSearchParams(query.url.search);
|
|
39
|
-
urlParams.delete("or");
|
|
40
|
-
query.url.search = urlParams.toString() ? `?${urlParams.toString()}` : "";
|
|
41
|
-
if (input.length > 2 && enableFullTableSearch) {
|
|
42
|
-
const conditions = columnList?.map((col)=>`${col}.ilike.*${input}*`);
|
|
43
|
-
return query.or(conditions.join(","));
|
|
44
|
-
}
|
|
45
|
-
return query;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const { data: data, onScroll: onScroll, dispatch: dispatch, client: client } = (0, $4c00def725e3d600$export$4dffb9bb65ef8b2)(endpoint, table, {
|
|
49
|
-
order: order ?? {
|
|
50
|
-
key: identityKey,
|
|
51
|
-
ascending: true
|
|
52
|
-
},
|
|
53
|
-
columns: columns,
|
|
54
|
-
filter: filter
|
|
55
|
-
});
|
|
56
|
-
const toaster = (0, $52ytf$useToaster)();
|
|
57
|
-
const finishResponse = (0, $52ytf$useCallback)((promisedResult, changes)=>{
|
|
58
|
-
$ea3fc6a8962e0e3d$export$2022c252b5885348(toaster, promisedResult).then((res)=>{
|
|
59
|
-
if (res == null) throw new Error("Could not complete action");
|
|
60
|
-
else {
|
|
61
|
-
// Merge new data with old data
|
|
62
|
-
console.log("Updating data", changes);
|
|
63
|
-
dispatch({
|
|
64
|
-
type: "update-data",
|
|
65
|
-
changes: changes
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}, [
|
|
70
|
-
dispatch,
|
|
71
|
-
toaster
|
|
72
|
-
]);
|
|
73
|
-
if (data == null) return $ea3fc6a8962e0e3d$var$h((0, $52ytf$Spinner));
|
|
74
|
-
return $ea3fc6a8962e0e3d$var$h("div.data-sheet-outer", [
|
|
75
|
-
$ea3fc6a8962e0e3d$var$h((0, $8bdde5bf56f8afde$export$dea56b0125f0282d), {
|
|
76
|
-
...rest,
|
|
77
|
-
dataSheetActions: enableFullTableSearch ? $ea3fc6a8962e0e3d$var$h($ea3fc6a8962e0e3d$export$a346ab8a0cc01d91, {
|
|
78
|
-
input: input,
|
|
79
|
-
setInput: setInput,
|
|
80
|
-
dispatch: dispatch
|
|
81
|
-
}) : dataSheetActions,
|
|
82
|
-
data: data,
|
|
83
|
-
columnSpecOptions: columnOptions ?? {},
|
|
84
|
-
editable: editable,
|
|
85
|
-
onVisibleCellsChange: onScroll,
|
|
86
|
-
onDeleteRows (selection) {
|
|
87
|
-
if (!editable) return;
|
|
88
|
-
const rowIndices = (0, $8bdde5bf56f8afde$export$222fa1b971ddc36)(selection);
|
|
89
|
-
const ids = rowIndices.map((i)=>data[i][identityKey]);
|
|
90
|
-
dispatch({
|
|
91
|
-
type: "start-loading"
|
|
92
|
-
});
|
|
93
|
-
let query = client.delete().in(identityKey, ids);
|
|
94
|
-
query = filter?.(query) ?? query;
|
|
95
|
-
finishResponse(query, {
|
|
96
|
-
$delete: Array.from(rowIndices.keys())
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
onSaveData (updates, data) {
|
|
100
|
-
if (!editable) return;
|
|
101
|
-
// Augment updates with primary key
|
|
102
|
-
let changes = {};
|
|
103
|
-
let updateRows = [];
|
|
104
|
-
for (let [key, update] of Object.entries(updates)){
|
|
105
|
-
const value = {
|
|
106
|
-
...data[key],
|
|
107
|
-
...update
|
|
108
|
-
};
|
|
109
|
-
updateRows.push(value);
|
|
110
|
-
changes[key] = {
|
|
111
|
-
$set: value
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
dispatch({
|
|
115
|
-
type: "start-loading"
|
|
116
|
-
});
|
|
117
|
-
// Save data
|
|
118
|
-
let query = client.upsert(updateRows, {
|
|
119
|
-
defaultToNull: false
|
|
120
|
-
});
|
|
121
|
-
query = filter?.(query) ?? query;
|
|
122
|
-
finishResponse(query, changes);
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
]);
|
|
126
|
-
}
|
|
127
|
-
function $ea3fc6a8962e0e3d$export$48a1a02e95eff0a2(toaster, error) {
|
|
128
|
-
console.error(error);
|
|
129
|
-
const { message: message, status: status, code: code, details: details } = error;
|
|
130
|
-
let errorDetails = null;
|
|
131
|
-
if (details != null) {
|
|
132
|
-
if (typeof details === "string") errorDetails = $ea3fc6a8962e0e3d$var$h("p.error-details", details);
|
|
133
|
-
else errorDetails = $ea3fc6a8962e0e3d$var$h("div.error-details", [
|
|
134
|
-
$ea3fc6a8962e0e3d$var$h("h4", "Error details"),
|
|
135
|
-
$ea3fc6a8962e0e3d$var$h("pre", JSON.stringify(details, null, 2))
|
|
136
|
-
]);
|
|
137
|
-
}
|
|
138
|
-
toaster.show({
|
|
139
|
-
message: $ea3fc6a8962e0e3d$var$h([
|
|
140
|
-
$ea3fc6a8962e0e3d$var$h.if(status != null)([
|
|
141
|
-
$ea3fc6a8962e0e3d$var$h("code.bp5-code", status),
|
|
142
|
-
" "
|
|
143
|
-
]),
|
|
144
|
-
$ea3fc6a8962e0e3d$var$h.if(code != null)([
|
|
145
|
-
$ea3fc6a8962e0e3d$var$h("code.bp5-code", code),
|
|
146
|
-
" "
|
|
147
|
-
]),
|
|
148
|
-
message ?? "An error occurred",
|
|
149
|
-
errorDetails
|
|
150
|
-
]),
|
|
151
|
-
intent: "danger"
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
async function $ea3fc6a8962e0e3d$export$2022c252b5885348(toaster, fnPromise) {
|
|
155
|
-
try {
|
|
156
|
-
const p = await fnPromise;
|
|
157
|
-
if (p.error != null) // Rethrow error
|
|
158
|
-
throw p.error;
|
|
159
|
-
return p;
|
|
160
|
-
} catch (err) {
|
|
161
|
-
$ea3fc6a8962e0e3d$export$48a1a02e95eff0a2(toaster, err);
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function $ea3fc6a8962e0e3d$export$85a23c82145eafdb({ value: value, onChange: onChange }) {
|
|
166
|
-
return $ea3fc6a8962e0e3d$var$h("div.long-text", value);
|
|
167
|
-
}
|
|
168
|
-
function $ea3fc6a8962e0e3d$export$8d4d3113a9b124d2({ value: value, children: children, ...rest }) {
|
|
169
|
-
return $ea3fc6a8962e0e3d$var$h((0, $52ytf$ColorCell), {
|
|
170
|
-
value: value?.color,
|
|
171
|
-
...rest
|
|
172
|
-
}, value?.name);
|
|
173
|
-
}
|
|
174
|
-
function $ea3fc6a8962e0e3d$export$2ad73a796d2d3eb(value) {
|
|
175
|
-
return $ea3fc6a8962e0e3d$var$h("span.tag-cell-content.liths", value?.map((d)=>$ea3fc6a8962e0e3d$var$h((0, $52ytf$LithologyTag), {
|
|
176
|
-
data: d,
|
|
177
|
-
key: d.id
|
|
178
|
-
})));
|
|
179
|
-
}
|
|
180
|
-
function $ea3fc6a8962e0e3d$export$5da000845ac52c4f({ value: value, onChange: onChange }) {
|
|
181
|
-
if (value == null) return $ea3fc6a8962e0e3d$var$h("div.basis-panel", "No lithologies");
|
|
182
|
-
return $ea3fc6a8962e0e3d$var$h("div.basis-panel", [
|
|
183
|
-
$ea3fc6a8962e0e3d$var$h("table", [
|
|
184
|
-
$ea3fc6a8962e0e3d$var$h("thead", $ea3fc6a8962e0e3d$var$h("tr", [
|
|
185
|
-
$ea3fc6a8962e0e3d$var$h("th", "Lithology"),
|
|
186
|
-
$ea3fc6a8962e0e3d$var$h("th", "Source")
|
|
187
|
-
])),
|
|
188
|
-
$ea3fc6a8962e0e3d$var$h("tbody", value.map((d)=>{
|
|
189
|
-
return $ea3fc6a8962e0e3d$var$h("tr", {
|
|
190
|
-
key: d.id
|
|
191
|
-
}, [
|
|
192
|
-
$ea3fc6a8962e0e3d$var$h("td", $ea3fc6a8962e0e3d$var$h((0, $52ytf$LithologyTag), {
|
|
193
|
-
data: d
|
|
194
|
-
})),
|
|
195
|
-
$ea3fc6a8962e0e3d$var$h("td.basis-col", d.basis_col?.map((d)=>{
|
|
196
|
-
return $ea3fc6a8962e0e3d$var$h((0, $52ytf$Tag), {
|
|
197
|
-
size: (0, $52ytf$TagSize).Small,
|
|
198
|
-
key: d,
|
|
199
|
-
name: $ea3fc6a8962e0e3d$var$h([
|
|
200
|
-
$ea3fc6a8962e0e3d$var$h("span.tag-header", "Column"),
|
|
201
|
-
" ",
|
|
202
|
-
$ea3fc6a8962e0e3d$var$h("code", d)
|
|
203
|
-
])
|
|
204
|
-
});
|
|
205
|
-
}))
|
|
206
|
-
]);
|
|
207
|
-
}))
|
|
208
|
-
])
|
|
209
|
-
]);
|
|
210
|
-
}
|
|
211
|
-
function $ea3fc6a8962e0e3d$export$a346ab8a0cc01d91({ input: input, setInput: setInput, dispatch: dispatch }) {
|
|
212
|
-
return $ea3fc6a8962e0e3d$var$h((0, $52ytf$InputGroup), {
|
|
213
|
-
type: "search",
|
|
214
|
-
placeholder: "Search table...",
|
|
215
|
-
value: input,
|
|
216
|
-
onChange (event) {
|
|
217
|
-
const search = event.target.value;
|
|
218
|
-
if (search.length > 2 || input.length === 3 && search.length < 3) dispatch({
|
|
219
|
-
type: "reset"
|
|
220
|
-
});
|
|
221
|
-
setInput(search.toLowerCase());
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
function $ea3fc6a8962e0e3d$var$getColumnList(endpoint, table) {
|
|
226
|
-
const url = `${endpoint}/${table}?select=*&limit=1`;
|
|
227
|
-
const res = (0, $52ytf$useAPIResult)(url);
|
|
228
|
-
if (!res || !Array.isArray(res) || res.length === 0) return [];
|
|
229
|
-
const sampleRow = res[0];
|
|
230
|
-
return Object.entries(sampleRow).filter(([_, value])=>{
|
|
231
|
-
return typeof value === "string";
|
|
232
|
-
}).map(([key])=>key);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
export {$ea3fc6a8962e0e3d$export$34ce2a614f5dd320 as PostgRESTTableView, $ea3fc6a8962e0e3d$export$2022c252b5885348 as wrapWithErrorHandling, $ea3fc6a8962e0e3d$export$a346ab8a0cc01d91 as SearchAction, $ea3fc6a8962e0e3d$export$48a1a02e95eff0a2 as notifyOnError, $ea3fc6a8962e0e3d$export$85a23c82145eafdb as LongTextViewer, $ea3fc6a8962e0e3d$export$8d4d3113a9b124d2 as IntervalCell, $ea3fc6a8962e0e3d$export$2ad73a796d2d3eb as lithologyRenderer, $ea3fc6a8962e0e3d$export$5da000845ac52c4f as ExpandedLithologies, $4c00def725e3d600$export$4dffb9bb65ef8b2 as usePostgRESTLazyLoader};
|
|
237
|
-
//# sourceMappingURL=data-sheet.560943e5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,qEAAK;AAyBrB,SAAS,0CAAsB,KAAiC;IACrE,OAAO,wBACL,CAAA,GAAA,oBAAY,GACZ,wBAAE,CAAA,GAAA,sBAAc,GAAG,wBAAE,CAAA,GAAA,qBAAa,GAAG,wBAAE,2CAAqB;AAEhE;AAEA,MAAM,yCAAmB;IAAC;IAAK;CAAI;AAEnC,SAAS,0CAAuB,YAC9B,QAAQ,SACR,KAAK,iBACL,aAAa,SACb,KAAK,WACL,OAAO,YACP,WAAW,eACX,MAAM,yBACN,wBAAwB,yBACxB,gBAAgB,eAChB,cAAc,MACd,GAAG,MACwB;IAC3B,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAE;IAEnC,IAAI,uBAAuB;QACzB,MAAM,aAAa,WAAW,oCAAc,UAAU;QAEtD,SAAS,CAAC;YACR,MAAM,YAAY,IAAI,gBAAgB,MAAM,GAAG,CAAC,MAAM;YACtD,UAAU,MAAM,CAAC;YACjB,MAAM,GAAG,CAAC,MAAM,GAAG,UAAU,QAAQ,KAAK,CAAC,CAAC,EAAE,UAAU,QAAQ,IAAI,GAAG;YAEvE,IAAI,MAAM,MAAM,GAAG,KAAK,uBAAuB;gBAC7C,MAAM,aAAa,YAAY,IAAI,CAAC,MAAQ,GAAG,IAAI,QAAQ,EAAE,MAAM,CAAC,CAAC;gBAErE,OAAO,MAAM,EAAE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S,GAAG;QACnB,MAAM;QACN,aAAa;QACb,OAAO;QACP,UAAS,KAAK;YACZ,MAAM,SAAS,MAAM,MAAM,CAAC,KAAK;YACjC,IAAI,OAAO,MAAM,GAAG,KAAM,MAAM,MAAM,KAAK,KAAK,OAAO,MAAM,GAAG,GAC9D,SAAS;gBAAE,MAAM;YAAQ;YAE3B,SAAS,OAAO,WAAW;QAC7B;IACF;AACF;AAEA,SAAS,oCAAc,QAAgB,EAAE,KAAa;IACpD,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,MAAM,iBAAiB,CAAC;IACnD,MAAM,MAAM,CAAA,GAAA,mBAAW,EAAE;IAEzB,IAAI,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,QAAQ,IAAI,MAAM,KAAK,GAAG,OAAO,EAAE;IAE9D,MAAM,YAAY,GAAG,CAAC,EAAE;IAExB,OAAO,OAAO,OAAO,CAAC,WACnB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM;QACjB,OAAO,OAAO,UAAU;IAC1B,GACC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAK;AACpB","sources":["packages/data-sheet/src/postgrest-table/index.ts"],"sourcesContent":["import { Toaster, HotkeysProvider } 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/types\";\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: Toaster, 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.bp5-code\", status), \" \"]),\n h.if(code != null)([h(\"code.bp5-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: Toaster,\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":[],"version":3,"file":"data-sheet.560943e5.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
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":"data-sheet.706f955d.css.map"}
|