@macrostrat/data-sheet 3.0.4 → 4.0.0-dev1
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 +20 -1
- package/dist/actions/builtin.cjs +56 -0
- package/dist/actions/builtin.cjs.map +1 -0
- package/dist/actions/builtin.d.ts +15 -0
- package/dist/actions/builtin.js +56 -0
- package/dist/actions/builtin.js.map +1 -0
- package/dist/actions/clipboard.cjs +250 -0
- package/dist/actions/clipboard.cjs.map +1 -0
- package/dist/actions/clipboard.d.ts +42 -0
- package/dist/actions/clipboard.js +250 -0
- package/dist/actions/clipboard.js.map +1 -0
- package/dist/actions/filters.cjs +123 -0
- package/dist/actions/filters.cjs.map +1 -0
- package/dist/actions/filters.d.ts +6 -0
- package/dist/actions/filters.js +123 -0
- package/dist/actions/filters.js.map +1 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/selection.cjs +194 -0
- package/dist/actions/selection.cjs.map +1 -0
- package/dist/actions/selection.d.ts +40 -0
- package/dist/actions/selection.js +192 -0
- package/dist/actions/selection.js.map +1 -0
- package/dist/actions/toolbar.cjs +171 -0
- package/dist/actions/toolbar.cjs.map +1 -0
- package/dist/actions/toolbar.d.ts +10 -0
- package/dist/actions/toolbar.js +171 -0
- package/dist/actions/toolbar.js.map +1 -0
- package/dist/actions/toolbar.module.sass.cjs +22 -0
- package/dist/actions/toolbar.module.sass.cjs.map +1 -0
- package/dist/actions/toolbar.module.sass.js +20 -0
- package/dist/actions/toolbar.module.sass.js.map +1 -0
- package/dist/actions/types.d.ts +143 -0
- package/dist/cell-renderer.cjs +165 -0
- package/dist/cell-renderer.cjs.map +1 -0
- package/dist/cell-renderer.d.ts +3 -0
- package/dist/cell-renderer.js +165 -0
- package/dist/cell-renderer.js.map +1 -0
- package/dist/components/actions.module.sass.cjs +3 -3
- package/dist/components/actions.module.sass.js +2 -2
- package/dist/components/colors.cjs +20 -16
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.d.ts +4 -3
- package/dist/components/colors.js +20 -16
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +4 -3
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +4 -3
- package/dist/components/editor-popup.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/main.module.sass.cjs +12 -12
- package/dist/components/main.module.sass.js +11 -11
- package/dist/components/text-areas.cjs +23 -18
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.d.ts +8 -4
- package/dist/components/text-areas.js +20 -13
- package/dist/components/text-areas.js.map +1 -1
- package/dist/components/view-info.cjs +18 -0
- package/dist/components/view-info.cjs.map +1 -0
- package/dist/components/view-info.d.ts +1 -0
- package/dist/components/view-info.js +18 -0
- package/dist/components/view-info.js.map +1 -0
- package/dist/core.cjs +201 -300
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +18 -10
- package/dist/core.js +204 -299
- package/dist/core.js.map +1 -1
- package/dist/data-sheet.css +190 -52
- package/dist/index.cjs +47 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +48 -9
- package/dist/index.js.map +1 -1
- package/dist/main.module.sass.cjs +15 -14
- package/dist/main.module.sass.cjs.map +1 -1
- package/dist/main.module.sass.js +14 -13
- package/dist/main.module.sass.js.map +1 -1
- package/dist/notifications.cjs +19 -0
- package/dist/notifications.cjs.map +1 -0
- package/dist/notifications.d.ts +9 -0
- package/dist/notifications.js +19 -0
- package/dist/notifications.js.map +1 -0
- package/dist/postgrest-table/data-loaders.cjs +181 -104
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -28
- package/dist/postgrest-table/data-loaders.js +181 -104
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +205 -79
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +14 -17
- package/dist/postgrest-table/index.js +186 -58
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/postgrest-table/lazy-loader-table.cjs +18 -17
- package/dist/postgrest-table/lazy-loader-table.cjs.map +1 -1
- package/dist/postgrest-table/lazy-loader-table.d.ts +1 -1
- package/dist/postgrest-table/lazy-loader-table.js +17 -14
- package/dist/postgrest-table/lazy-loader-table.js.map +1 -1
- package/dist/postgrest-table/loading-utils.cjs +16 -0
- package/dist/postgrest-table/loading-utils.cjs.map +1 -0
- package/dist/postgrest-table/loading-utils.d.ts +13 -0
- package/dist/postgrest-table/loading-utils.js +16 -0
- package/dist/postgrest-table/loading-utils.js.map +1 -0
- package/dist/postgrest-table/main.module.sass.cjs +18 -13
- package/dist/postgrest-table/main.module.sass.cjs.map +1 -1
- package/dist/postgrest-table/main.module.sass.js +18 -13
- package/dist/postgrest-table/main.module.sass.js.map +1 -1
- package/dist/provider.cjs +96 -344
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.js +96 -343
- package/dist/provider.js.map +1 -1
- package/dist/renderers/column-header-cell-postgrest.cjs +216 -0
- package/dist/renderers/column-header-cell-postgrest.cjs.map +1 -0
- package/dist/renderers/column-header-cell-postgrest.d.ts +13 -0
- package/dist/renderers/column-header-cell-postgrest.js +216 -0
- package/dist/renderers/column-header-cell-postgrest.js.map +1 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.cjs +23 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.cjs.map +1 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.js +22 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +103 -0
- package/dist/renderers/column-header-cell.cjs.map +1 -0
- package/dist/renderers/column-header-cell.d.ts +30 -0
- package/dist/renderers/column-header-cell.js +101 -0
- package/dist/renderers/column-header-cell.js.map +1 -0
- package/dist/renderers/index.d.ts +2 -0
- package/dist/table-updates/data-parameter.d.ts +14 -0
- package/dist/table-updates/filter.d.ts +16 -0
- package/dist/table-updates/index.d.ts +19 -0
- package/dist/types.cjs +9 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/column-spec.cjs +9 -1
- package/dist/utils/column-spec.cjs.map +1 -1
- package/dist/utils/column-spec.d.ts +21 -0
- package/dist/utils/column-spec.js +9 -1
- package/dist/utils/column-spec.js.map +1 -1
- package/dist/utils/key-handling.cjs +161 -47
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +3 -3
- package/dist/utils/key-handling.js +161 -47
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/zustand-store.cjs +485 -0
- package/dist/zustand-store.cjs.map +1 -0
- package/dist/zustand-store.d.ts +6 -0
- package/dist/zustand-store.js +483 -0
- package/dist/zustand-store.js.map +1 -0
- package/package.json +6 -5
- package/src/actions/builtin.ts +65 -0
- package/src/actions/clipboard.ts +350 -0
- package/src/actions/filters.ts +150 -0
- package/src/actions/index.ts +6 -0
- package/src/actions/selection.ts +271 -0
- package/src/actions/toolbar.module.sass +30 -0
- package/src/actions/toolbar.ts +212 -0
- package/src/actions/types.ts +159 -0
- package/src/cell-renderer.ts +221 -0
- package/src/components/colors.ts +22 -19
- package/src/components/editor-popup.ts +3 -2
- package/src/components/index.ts +1 -0
- package/src/components/main.module.sass +1 -0
- package/src/components/text-areas.ts +34 -19
- package/src/components/view-info.ts +17 -0
- package/src/core.ts +273 -360
- package/src/index.ts +4 -0
- package/src/main.module.sass +14 -2
- package/src/notifications.ts +22 -0
- package/src/postgrest-table/data-loaders.ts +300 -201
- package/src/postgrest-table/index.ts +260 -86
- package/src/postgrest-table/lazy-loader-table.ts +18 -17
- package/src/postgrest-table/loading-utils.ts +49 -0
- package/src/postgrest-table/main.module.sass +16 -0
- package/src/provider.ts +110 -487
- package/src/renderers/column-header-cell-postgrest.module.sass +71 -0
- package/src/renderers/column-header-cell-postgrest.ts +282 -0
- package/src/renderers/column-header-cell.ts +388 -0
- package/src/renderers/index.ts +2 -0
- package/src/table-updates/data-parameter.ts +44 -0
- package/src/table-updates/filter.ts +124 -0
- package/src/table-updates/index.ts +239 -0
- package/src/types.ts +121 -0
- package/src/utils/column-spec.ts +47 -0
- package/src/utils/key-handling.ts +201 -66
- package/src/zustand-store.ts +582 -0
- package/dist/provider.d.ts +0 -69
package/dist/index.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataSheet, DataSheetDensity, ScrollToRowControl, getRowsToDelete } from "./core.js";
|
|
2
2
|
import { ExpandedLithologies, IntervalCell, LongTextViewer, PostgRESTTableView, SearchAction, lithologyRenderer, notifyOnError, wrapWithErrorHandling } from "./postgrest-table/index.js";
|
|
3
|
-
import { DataSheetProvider,
|
|
3
|
+
import { DataSheetProvider, DataSheetProviderInner, columnSpecAtom, ctx, storeAPIAtom, storeAtom, tableActionsAtom, tableDataAtom, useSelector, useStoreAPI } from "./provider.js";
|
|
4
4
|
import { range } from "./utils/index.js";
|
|
5
|
+
import { TableElementStatus } from "./types.js";
|
|
5
6
|
import { Cell } from "@blueprintjs/table";
|
|
7
|
+
import { ActionsToolbar, runActionWrapper } from "./actions/toolbar.js";
|
|
6
8
|
import { ColorCell, ColorPicker, colorSwatchRenderer } from "./components/colors.js";
|
|
7
9
|
import { DataSheetAction, DataSheetActionsRow } from "./components/actions.js";
|
|
8
10
|
import { EditableTextArea } from "./components/text-areas.js";
|
|
9
11
|
import { EditorPopup } from "./components/editor-popup.js";
|
|
12
|
+
import { FilterBar } from "./actions/filters.js";
|
|
13
|
+
import { InfoBar } from "./components/view-info.js";
|
|
14
|
+
import { PasteShape, clipboardActions, copyAction, cutAction, pasteAction, serializeSelectionToTSV } from "./actions/clipboard.js";
|
|
10
15
|
import { TestLazyLoaderTableView } from "./postgrest-table/lazy-loader-table.js";
|
|
11
|
-
import {
|
|
16
|
+
import { addRowAction, defaultTableActions, deleteRowsAction, resetChangesAction } from "./actions/builtin.js";
|
|
17
|
+
import { applyColumnFilters, standardizeFilter, usePostgRESTLazyLoader, useScrollHandler, useTestLazyLoader, viewInfoAtom } from "./postgrest-table/data-loaders.js";
|
|
18
|
+
import { buildActionContext, collectAllFilters, computeFilteredRowIndices, computeTransformedRowIndices, getApplicableActions, getSelectedColumnKeys, getSelectedRowIndices, getSelectionCardinality, mergeColumnActions } from "./actions/selection.js";
|
|
19
|
+
import { editorKeyHandlerAtom, multiLineTextKeyHandler, tableHotkeysAtom } from "./utils/key-handling.js";
|
|
12
20
|
import { generateColumnSpec, generateDefaultColumnSpec } from "./utils/column-spec.js";
|
|
13
|
-
import { usePostgRESTLazyLoader, useTestLazyLoader } from "./postgrest-table/data-loaders.js";
|
|
14
21
|
export {
|
|
15
|
-
|
|
22
|
+
ActionsToolbar,
|
|
16
23
|
Cell,
|
|
17
24
|
ColorCell,
|
|
18
25
|
ColorPicker,
|
|
@@ -21,31 +28,63 @@ export {
|
|
|
21
28
|
DataSheetActionsRow,
|
|
22
29
|
DataSheetDensity,
|
|
23
30
|
DataSheetProvider,
|
|
31
|
+
DataSheetProviderInner,
|
|
24
32
|
EditableTextArea,
|
|
25
33
|
EditorPopup,
|
|
26
34
|
ExpandedLithologies,
|
|
35
|
+
FilterBar,
|
|
36
|
+
InfoBar,
|
|
27
37
|
IntervalCell,
|
|
28
38
|
LongTextViewer,
|
|
39
|
+
PasteShape,
|
|
29
40
|
PostgRESTTableView,
|
|
30
41
|
ScrollToRowControl,
|
|
31
42
|
SearchAction,
|
|
43
|
+
TableElementStatus,
|
|
32
44
|
TestLazyLoaderTableView,
|
|
45
|
+
addRowAction,
|
|
46
|
+
applyColumnFilters,
|
|
47
|
+
buildActionContext,
|
|
48
|
+
clipboardActions,
|
|
49
|
+
collectAllFilters,
|
|
33
50
|
colorSwatchRenderer,
|
|
34
|
-
|
|
51
|
+
columnSpecAtom,
|
|
52
|
+
computeFilteredRowIndices,
|
|
53
|
+
computeTransformedRowIndices,
|
|
54
|
+
copyAction,
|
|
55
|
+
ctx,
|
|
56
|
+
cutAction,
|
|
57
|
+
defaultTableActions,
|
|
58
|
+
deleteRowsAction,
|
|
59
|
+
editorKeyHandlerAtom,
|
|
35
60
|
generateColumnSpec,
|
|
36
61
|
generateDefaultColumnSpec,
|
|
62
|
+
getApplicableActions,
|
|
37
63
|
getRowsToDelete,
|
|
64
|
+
getSelectedColumnKeys,
|
|
65
|
+
getSelectedRowIndices,
|
|
66
|
+
getSelectionCardinality,
|
|
38
67
|
lithologyRenderer,
|
|
68
|
+
mergeColumnActions,
|
|
39
69
|
multiLineTextKeyHandler,
|
|
40
70
|
notifyOnError,
|
|
71
|
+
pasteAction,
|
|
41
72
|
range,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
73
|
+
resetChangesAction,
|
|
74
|
+
runActionWrapper,
|
|
75
|
+
serializeSelectionToTSV,
|
|
76
|
+
standardizeFilter,
|
|
77
|
+
storeAPIAtom,
|
|
78
|
+
storeAtom,
|
|
79
|
+
tableActionsAtom,
|
|
80
|
+
tableDataAtom,
|
|
81
|
+
tableHotkeysAtom,
|
|
45
82
|
usePostgRESTLazyLoader,
|
|
83
|
+
useScrollHandler,
|
|
46
84
|
useSelector,
|
|
47
85
|
useStoreAPI,
|
|
48
86
|
useTestLazyLoader,
|
|
87
|
+
viewInfoAtom,
|
|
49
88
|
wrapWithErrorHandling
|
|
50
89
|
};
|
|
51
90
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
3
|
+
const h$1 = require("@macrostrat/hyper");
|
|
4
4
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
-
const
|
|
6
|
-
const spacer = "
|
|
5
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
6
|
+
const spacer = "_spacer_11hm8_103";
|
|
7
7
|
const styles = {
|
|
8
|
-
"data-sheet-container": "_data-sheet-
|
|
9
|
-
"data-sheet-holder": "_data-sheet-
|
|
10
|
-
"data-sheet": "_data-
|
|
11
|
-
"input-cell": "_input-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
8
|
+
"data-sheet-container": "_data-sheet-container_11hm8_1",
|
|
9
|
+
"data-sheet-holder": "_data-sheet-holder_11hm8_1",
|
|
10
|
+
"data-sheet": "_data-sheet_11hm8_1",
|
|
11
|
+
"input-cell": "_input-cell_11hm8_41",
|
|
12
|
+
"value-viewer-cell": "_value-viewer-cell_11hm8_58",
|
|
13
|
+
"editor-cell": "_editor-cell_11hm8_66",
|
|
14
|
+
"hidden-input": "_hidden-input_11hm8_74",
|
|
15
|
+
"data-editor-anchor": "_data-editor-anchor_11hm8_80",
|
|
16
|
+
"corner-drag-handle": "_corner-drag-handle_11hm8_87",
|
|
17
|
+
"data-sheet-toolbar": "_data-sheet-toolbar_11hm8_97",
|
|
17
18
|
spacer,
|
|
18
|
-
"table-control": "_table-
|
|
19
|
+
"table-control": "_table-control_11hm8_107"
|
|
19
20
|
};
|
|
20
|
-
let h =
|
|
21
|
+
let h = h__default.default.styled(styles);
|
|
21
22
|
Object.assign(h, styles);
|
|
22
23
|
exports.default = h;
|
|
23
24
|
exports.spacer = spacer;
|
|
@@ -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,19 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
const spacer = "
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
2
|
+
const spacer = "_spacer_11hm8_103";
|
|
3
3
|
const styles = {
|
|
4
|
-
"data-sheet-container": "_data-sheet-
|
|
5
|
-
"data-sheet-holder": "_data-sheet-
|
|
6
|
-
"data-sheet": "_data-
|
|
7
|
-
"input-cell": "_input-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
4
|
+
"data-sheet-container": "_data-sheet-container_11hm8_1",
|
|
5
|
+
"data-sheet-holder": "_data-sheet-holder_11hm8_1",
|
|
6
|
+
"data-sheet": "_data-sheet_11hm8_1",
|
|
7
|
+
"input-cell": "_input-cell_11hm8_41",
|
|
8
|
+
"value-viewer-cell": "_value-viewer-cell_11hm8_58",
|
|
9
|
+
"editor-cell": "_editor-cell_11hm8_66",
|
|
10
|
+
"hidden-input": "_hidden-input_11hm8_74",
|
|
11
|
+
"data-editor-anchor": "_data-editor-anchor_11hm8_80",
|
|
12
|
+
"corner-drag-handle": "_corner-drag-handle_11hm8_87",
|
|
13
|
+
"data-sheet-toolbar": "_data-sheet-toolbar_11hm8_97",
|
|
13
14
|
spacer,
|
|
14
|
-
"table-control": "_table-
|
|
15
|
+
"table-control": "_table-control_11hm8_107"
|
|
15
16
|
};
|
|
16
|
-
let h =
|
|
17
|
+
let h = h$1.styled(styles);
|
|
17
18
|
Object.assign(h, styles);
|
|
18
19
|
export {
|
|
19
20
|
h as default,
|
|
@@ -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":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const core = require("@blueprintjs/core");
|
|
4
|
+
const jotai = require("jotai");
|
|
5
|
+
const provider = require("./provider.cjs");
|
|
6
|
+
const react = require("react");
|
|
7
|
+
const toasterAtom = jotai.atom(null);
|
|
8
|
+
function useToaster(toaster) {
|
|
9
|
+
const [toasterRef, setToasterRef] = provider.ctx.use(toasterAtom);
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
{
|
|
12
|
+
core.OverlayToaster.create().then((t) => setToasterRef(t));
|
|
13
|
+
}
|
|
14
|
+
}, [toaster]);
|
|
15
|
+
return toasterRef;
|
|
16
|
+
}
|
|
17
|
+
exports.toasterAtom = toasterAtom;
|
|
18
|
+
exports.useToaster = useToaster;
|
|
19
|
+
//# sourceMappingURL=notifications.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.cjs","sources":["../src/notifications.ts"],"sourcesContent":["import { OverlayToaster } from \"@blueprintjs/core\";\nimport { atom, useAtom } from \"jotai\";\nimport { ctx } from \"./provider\";\nimport { useEffect } from \"react\";\n\n/** Toaster access\n * Atom that stores a reference to a global or contextual toaster used by the\n * data sheet.\n * */\nexport const toasterAtom = atom(null);\n\nexport function useToaster(toaster?: OverlayToaster): OverlayToaster {\n const [toasterRef, setToasterRef] = ctx.use(toasterAtom);\n useEffect(() => {\n if (toaster != null) {\n setToasterRef(toaster);\n } else {\n OverlayToaster.create().then((t) => setToasterRef(t));\n }\n }, [toaster]);\n return toasterRef;\n}\n"],"names":["atom","ctx","useEffect","OverlayToaster"],"mappings":";;;;;;AASO,MAAM,cAAcA,MAAAA,KAAK,IAAI;AAE7B,SAAS,WAAW,SAA0C;AACnE,QAAM,CAAC,YAAY,aAAa,IAAIC,SAAAA,IAAI,IAAI,WAAW;AACvDC,QAAAA,UAAU,MAAM;AAGP;AACLC,WAAAA,eAAe,SAAS,KAAK,CAAC,MAAM,cAAc,CAAC,CAAC;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACZ,SAAO;AACT;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OverlayToaster } from '@blueprintjs/core';
|
|
2
|
+
/** Toaster access
|
|
3
|
+
* Atom that stores a reference to a global or contextual toaster used by the
|
|
4
|
+
* data sheet.
|
|
5
|
+
* */
|
|
6
|
+
export declare const toasterAtom: import('jotai').PrimitiveAtom<null> & {
|
|
7
|
+
init: null;
|
|
8
|
+
};
|
|
9
|
+
export declare function useToaster(toaster?: OverlayToaster): OverlayToaster;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OverlayToaster } from "@blueprintjs/core";
|
|
2
|
+
import { atom } from "jotai";
|
|
3
|
+
import { ctx } from "./provider.js";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
const toasterAtom = atom(null);
|
|
6
|
+
function useToaster(toaster) {
|
|
7
|
+
const [toasterRef, setToasterRef] = ctx.use(toasterAtom);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
{
|
|
10
|
+
OverlayToaster.create().then((t) => setToasterRef(t));
|
|
11
|
+
}
|
|
12
|
+
}, [toaster]);
|
|
13
|
+
return toasterRef;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
toasterAtom,
|
|
17
|
+
useToaster
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sources":["../src/notifications.ts"],"sourcesContent":["import { OverlayToaster } from \"@blueprintjs/core\";\nimport { atom, useAtom } from \"jotai\";\nimport { ctx } from \"./provider\";\nimport { useEffect } from \"react\";\n\n/** Toaster access\n * Atom that stores a reference to a global or contextual toaster used by the\n * data sheet.\n * */\nexport const toasterAtom = atom(null);\n\nexport function useToaster(toaster?: OverlayToaster): OverlayToaster {\n const [toasterRef, setToasterRef] = ctx.use(toasterAtom);\n useEffect(() => {\n if (toaster != null) {\n setToasterRef(toaster);\n } else {\n OverlayToaster.create().then((t) => setToasterRef(t));\n }\n }, [toaster]);\n return toasterRef;\n}\n"],"names":[],"mappings":";;;;AASO,MAAM,cAAc,KAAK,IAAI;AAE7B,SAAS,WAAW,SAA0C;AACnE,QAAM,CAAC,YAAY,aAAa,IAAI,IAAI,IAAI,WAAW;AACvD,YAAU,MAAM;AAGP;AACL,qBAAe,SAAS,KAAK,CAAC,MAAM,cAAc,CAAC,CAAC;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACZ,SAAO;AACT;"}
|
|
@@ -5,18 +5,28 @@ const underscore = require("underscore");
|
|
|
5
5
|
const react = require("react");
|
|
6
6
|
const update = require("immutability-helper");
|
|
7
7
|
const postgrestJs = require("@supabase/postgrest-js");
|
|
8
|
+
const loadingUtils = require("./loading-utils.cjs");
|
|
9
|
+
const provider = require("../provider.cjs");
|
|
10
|
+
const jotai = require("jotai");
|
|
8
11
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
12
|
const update__default = /* @__PURE__ */ _interopDefault(update);
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
function standardizeFilter(columnFilter) {
|
|
14
|
+
return {
|
|
15
|
+
type: "filter",
|
|
16
|
+
apply(req) {
|
|
17
|
+
return applyColumnFilters(req, [columnFilter]);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function applyColumnFilters(req, filters) {
|
|
22
|
+
for (const cf of filters) {
|
|
23
|
+
if (cf.value === "" || cf.value == null) continue;
|
|
24
|
+
const val = cf.operator === "like" || cf.operator === "ilike" ? `*${cf.value}*` : cf.value;
|
|
25
|
+
req = req.filter(cf.key, cf.operator, val);
|
|
15
26
|
}
|
|
16
|
-
return
|
|
27
|
+
return req;
|
|
17
28
|
}
|
|
18
29
|
function lazyLoadingReducer(state, action) {
|
|
19
|
-
console.log(action);
|
|
20
30
|
switch (action.type) {
|
|
21
31
|
case "start-loading":
|
|
22
32
|
return {
|
|
@@ -24,11 +34,6 @@ function lazyLoadingReducer(state, action) {
|
|
|
24
34
|
loading: true,
|
|
25
35
|
initialized: true
|
|
26
36
|
};
|
|
27
|
-
case "set-visible":
|
|
28
|
-
return {
|
|
29
|
-
...state,
|
|
30
|
-
visibleRegion: action.region
|
|
31
|
-
};
|
|
32
37
|
case "update-data":
|
|
33
38
|
return {
|
|
34
39
|
...state,
|
|
@@ -36,23 +41,32 @@ function lazyLoadingReducer(state, action) {
|
|
|
36
41
|
data: update__default.default(state.data, action.changes)
|
|
37
42
|
};
|
|
38
43
|
case "loaded":
|
|
39
|
-
let data = adjustArraySize(state.data, action.totalSize);
|
|
44
|
+
let data = loadingUtils.adjustArraySize(state.data, action.totalSize);
|
|
45
|
+
const newData = action.data ?? [];
|
|
46
|
+
const offset = action.offset ?? 0;
|
|
40
47
|
data = [
|
|
41
|
-
...data.slice(0,
|
|
42
|
-
...
|
|
43
|
-
...data.slice(
|
|
48
|
+
...data.slice(0, offset),
|
|
49
|
+
...newData,
|
|
50
|
+
...data.slice(offset + newData.length)
|
|
44
51
|
];
|
|
45
52
|
return {
|
|
46
53
|
...state,
|
|
47
54
|
data,
|
|
48
55
|
loading: false
|
|
49
56
|
};
|
|
57
|
+
case "start-reload":
|
|
58
|
+
return {
|
|
59
|
+
...state,
|
|
60
|
+
data: new Array(state.data.length).fill(null),
|
|
61
|
+
loading: true,
|
|
62
|
+
initialized: false
|
|
63
|
+
};
|
|
50
64
|
case "reset":
|
|
51
65
|
return {
|
|
66
|
+
visibleRegion: defaultVisibleRegion,
|
|
52
67
|
data: [],
|
|
53
68
|
loading: false,
|
|
54
69
|
error: null,
|
|
55
|
-
visibleRegion: { rowIndexStart: 0, rowIndexEnd: 0 },
|
|
56
70
|
initialized: false
|
|
57
71
|
};
|
|
58
72
|
case "error":
|
|
@@ -66,9 +80,8 @@ function lazyLoadingReducer(state, action) {
|
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
function buildQuery(client, config) {
|
|
69
|
-
const { columns = "*", count } = config;
|
|
83
|
+
const { columns = "*", count, lastLoadedRowIndex } = config;
|
|
70
84
|
const opts = { count };
|
|
71
|
-
console.log("config", config);
|
|
72
85
|
let cols;
|
|
73
86
|
if (Array.isArray(columns)) {
|
|
74
87
|
cols = columns.join(", ");
|
|
@@ -76,52 +89,140 @@ function buildQuery(client, config) {
|
|
|
76
89
|
cols = columns ?? "*";
|
|
77
90
|
}
|
|
78
91
|
let query = client.select(cols, opts);
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
const filters = config.filters ?? [];
|
|
93
|
+
for (const filter of filters) {
|
|
94
|
+
query = filter.apply(query);
|
|
81
95
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
const orderClauses = buildPostgrestOrderClauses(
|
|
97
|
+
config.order ?? [],
|
|
98
|
+
config.identityKey
|
|
99
|
+
);
|
|
100
|
+
let hasOrdering = false;
|
|
101
|
+
for (const clause of orderClauses) {
|
|
102
|
+
query = query.order(clause.key, clause);
|
|
103
|
+
if (config.lastLoadedRow != null) {
|
|
104
|
+
const op = clause.ascending ?? true ? "gt" : "lt";
|
|
105
|
+
const value = config.lastLoadedRow[clause.key];
|
|
106
|
+
query = query[op](clause.key, value);
|
|
89
107
|
}
|
|
108
|
+
hasOrdering = true;
|
|
109
|
+
}
|
|
110
|
+
let offset = null;
|
|
111
|
+
if (!hasOrdering && lastLoadedRowIndex > 0) {
|
|
112
|
+
offset = lastLoadedRowIndex + 1;
|
|
90
113
|
}
|
|
91
114
|
if (config.limit != null) {
|
|
92
|
-
if (
|
|
93
|
-
query = query.range(
|
|
94
|
-
console.log(`Random seek from ${
|
|
115
|
+
if (offset != null) {
|
|
116
|
+
query = query.range(offset, offset + config.limit - 1);
|
|
117
|
+
console.log(`Random seek from ${offset}, this will be slow`);
|
|
95
118
|
} else {
|
|
96
119
|
query = query.limit(config.limit);
|
|
97
120
|
}
|
|
98
121
|
}
|
|
122
|
+
console.log("query", query.url.search);
|
|
99
123
|
return query;
|
|
100
124
|
}
|
|
101
|
-
|
|
102
|
-
|
|
125
|
+
const defaultVisibleRegion = {
|
|
126
|
+
rowIndexStart: 0,
|
|
127
|
+
rowIndexEnd: 0
|
|
128
|
+
};
|
|
129
|
+
const visibleRegionAtom = jotai.atom(defaultVisibleRegion);
|
|
130
|
+
const lazyLoaderCoreStateAtom = jotai.atom({
|
|
131
|
+
loading: false,
|
|
132
|
+
error: null,
|
|
133
|
+
initialized: false
|
|
134
|
+
});
|
|
135
|
+
const viewInfoAtom = jotai.atom((get) => {
|
|
136
|
+
const state = get(lazyLoaderStateAtom);
|
|
137
|
+
return {
|
|
138
|
+
visibleRegion: state.visibleRegion,
|
|
139
|
+
loading: state.loading,
|
|
140
|
+
error: state.error,
|
|
141
|
+
totalCount: state.data.length
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
const lazyLoaderStateAtom = jotai.atom(
|
|
145
|
+
(get) => {
|
|
146
|
+
const core = get(lazyLoaderCoreStateAtom);
|
|
147
|
+
const data = get(provider.tableDataAtom);
|
|
148
|
+
const visibleRegion = get(visibleRegionAtom);
|
|
149
|
+
return {
|
|
150
|
+
...core,
|
|
151
|
+
data,
|
|
152
|
+
visibleRegion
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
(get, set, update2) => {
|
|
156
|
+
if (typeof update2 === "function") {
|
|
157
|
+
update2 = update2(get(lazyLoaderStateAtom));
|
|
158
|
+
}
|
|
159
|
+
const { visibleRegion, data, ...rest } = update2;
|
|
160
|
+
if (visibleRegion != null) {
|
|
161
|
+
set(visibleRegionAtom, visibleRegion);
|
|
162
|
+
}
|
|
163
|
+
if (data != null && data.length > 0) {
|
|
164
|
+
set(provider.tableDataAtom, data);
|
|
165
|
+
}
|
|
166
|
+
if (Object.keys(rest).length > 1) {
|
|
167
|
+
set(lazyLoaderCoreStateAtom, (v) => ({ ...v, ...rest }));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
function useLazyLoaderReducer() {
|
|
172
|
+
const [state, setState] = provider.ctx.use(lazyLoaderStateAtom);
|
|
173
|
+
const dispatch = react.useCallback(
|
|
174
|
+
(action) => setState((prev) => lazyLoadingReducer(prev, action)),
|
|
175
|
+
[setState]
|
|
176
|
+
);
|
|
177
|
+
return [state, dispatch];
|
|
178
|
+
}
|
|
179
|
+
function buildPostgrestOrderClauses(sorts, identityOrder) {
|
|
180
|
+
const identitySort = typeof identityOrder == "string" ? { key: identityOrder, ascending: true } : identityOrder;
|
|
181
|
+
const identityKey = identitySort.key;
|
|
182
|
+
const clauses = sorts.map((sort) => {
|
|
183
|
+
return {
|
|
184
|
+
key: sort.key,
|
|
185
|
+
ascending: sort.ascending,
|
|
186
|
+
nullsFirst: "nullsFirst" in sort ? sort.nullsFirst : false
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
const hasIdentityClause = clauses.some((d) => d.key === identityKey);
|
|
190
|
+
if (hasIdentityClause) {
|
|
191
|
+
clauses.sort((a, b) => {
|
|
192
|
+
if (a.key === identityKey) return 1;
|
|
193
|
+
if (b.key === identityKey) return -1;
|
|
194
|
+
return 0;
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
clauses.push(identitySort);
|
|
198
|
+
}
|
|
199
|
+
return clauses;
|
|
200
|
+
}
|
|
201
|
+
function _loadMorePostgRESTData(client, config, state, dispatch) {
|
|
202
|
+
let rowIndex = indexOfFirstNullInRegion(state.data, state.visibleRegion);
|
|
103
203
|
if (state.loading || rowIndex == null) {
|
|
104
204
|
if (state.initialized) {
|
|
105
205
|
return;
|
|
106
206
|
}
|
|
207
|
+
rowIndex = rowIndex ?? 0;
|
|
208
|
+
}
|
|
209
|
+
const lastLoadedRowIndex = rowIndex - 1;
|
|
210
|
+
let lastLoadedRow = null;
|
|
211
|
+
if (lastLoadedRowIndex >= 0) {
|
|
212
|
+
lastLoadedRow = state.data[lastLoadedRowIndex];
|
|
107
213
|
}
|
|
108
214
|
const { chunkSize = 100, ...rest } = config;
|
|
109
|
-
|
|
215
|
+
config.order?.key ?? "id";
|
|
110
216
|
let cfg = {
|
|
111
217
|
...rest,
|
|
112
218
|
limit: chunkSize,
|
|
113
|
-
|
|
219
|
+
lastLoadedRow,
|
|
220
|
+
lastLoadedRowIndex
|
|
114
221
|
};
|
|
115
222
|
const isInitialQuery = !state.initialized;
|
|
116
223
|
if (isInitialQuery) {
|
|
117
224
|
cfg.count = "exact";
|
|
118
225
|
}
|
|
119
|
-
if (!isInitialQuery) {
|
|
120
|
-
cfg.after = state.data[rowIndex - 1]?.[sortKey];
|
|
121
|
-
if (cfg.after == null) {
|
|
122
|
-
cfg.offset = rowIndex;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
226
|
dispatch({ type: "start-loading" });
|
|
126
227
|
const query = buildQuery(client, cfg);
|
|
127
228
|
query.then((res) => {
|
|
@@ -135,48 +236,49 @@ function _loadMoreData(client, config, state, dispatch) {
|
|
|
135
236
|
});
|
|
136
237
|
});
|
|
137
238
|
}
|
|
138
|
-
const
|
|
139
|
-
function
|
|
140
|
-
const initialState = {
|
|
141
|
-
data: [],
|
|
142
|
-
loading: false,
|
|
143
|
-
error: null,
|
|
144
|
-
visibleRegion: { rowIndexStart: 0, rowIndexEnd: 0 },
|
|
145
|
-
initialized: false
|
|
146
|
-
};
|
|
147
|
-
const client = react.useMemo(() => {
|
|
148
|
-
return new postgrestJs.PostgrestClient(endpoint).from(table);
|
|
149
|
-
}, [endpoint, table]);
|
|
150
|
-
const [state, dispatch] = react.useReducer(lazyLoadingReducer, initialState);
|
|
151
|
-
const { data, loading } = state;
|
|
152
|
-
uiComponents.useAsyncEffect(async () => {
|
|
153
|
-
loadMoreData(client, config, state, dispatch);
|
|
154
|
-
}, [
|
|
155
|
-
data,
|
|
156
|
-
state.visibleRegion.rowIndexStart,
|
|
157
|
-
state.visibleRegion.rowIndexEnd
|
|
158
|
-
]);
|
|
239
|
+
const loadMorePostgRESTData = underscore.debounce(_loadMorePostgRESTData, 100);
|
|
240
|
+
function useScrollHandler() {
|
|
159
241
|
const ref = react.useRef(null);
|
|
160
|
-
const
|
|
242
|
+
const setVisibleRegion = provider.ctx.useSet(visibleRegionAtom);
|
|
243
|
+
return react.useCallback(
|
|
161
244
|
underscore.debounce((visibleCells) => {
|
|
162
245
|
if (visibleCells.rowIndexEnd == ref.current?.rowIndexEnd && visibleCells.rowIndexStart == ref.current?.rowIndexStart) {
|
|
163
246
|
return;
|
|
164
247
|
}
|
|
165
248
|
console.log("Visible cells changed", visibleCells);
|
|
166
|
-
|
|
167
|
-
type: "set-visible",
|
|
168
|
-
region: visibleCells
|
|
169
|
-
});
|
|
249
|
+
setVisibleRegion(visibleCells);
|
|
170
250
|
ref.current = visibleCells;
|
|
171
251
|
}, 500),
|
|
172
|
-
[
|
|
252
|
+
[setVisibleRegion]
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
function usePostgRESTLazyLoader(endpoint, table, config = {}) {
|
|
256
|
+
const getClient = react.useCallback(() => {
|
|
257
|
+
return new postgrestJs.PostgrestClient(endpoint).from(table);
|
|
258
|
+
}, [endpoint, table]);
|
|
259
|
+
const [state, dispatch] = useLazyLoaderReducer();
|
|
260
|
+
const { data, loading } = state;
|
|
261
|
+
const sortFilterKey = react.useMemo(
|
|
262
|
+
() => JSON.stringify({
|
|
263
|
+
s: config.order,
|
|
264
|
+
v: config.filters,
|
|
265
|
+
i: config.identityKey
|
|
266
|
+
}),
|
|
267
|
+
[config.order, config.filters, config.identityKey]
|
|
173
268
|
);
|
|
269
|
+
const visibleRegion = provider.ctx.useValue(visibleRegionAtom);
|
|
270
|
+
react.useEffect(() => {
|
|
271
|
+
dispatch({ type: "reset" });
|
|
272
|
+
}, [sortFilterKey]);
|
|
273
|
+
uiComponents.useAsyncEffect(async () => {
|
|
274
|
+
const client = getClient();
|
|
275
|
+
loadMorePostgRESTData(client, config, state, dispatch);
|
|
276
|
+
}, [data, visibleRegion, sortFilterKey]);
|
|
174
277
|
return {
|
|
175
278
|
data,
|
|
176
279
|
loading,
|
|
177
|
-
onScroll,
|
|
178
280
|
dispatch,
|
|
179
|
-
|
|
281
|
+
getClient
|
|
180
282
|
};
|
|
181
283
|
}
|
|
182
284
|
function indexOfFirstNullInRegion(data, region) {
|
|
@@ -188,41 +290,15 @@ function indexOfFirstNullInRegion(data, region) {
|
|
|
188
290
|
return null;
|
|
189
291
|
}
|
|
190
292
|
function useTestLazyLoader(config = {}) {
|
|
191
|
-
const
|
|
192
|
-
data: [],
|
|
193
|
-
loading: false,
|
|
194
|
-
error: null,
|
|
195
|
-
visibleRegion: { rowIndexStart: 0, rowIndexEnd: 0 },
|
|
196
|
-
initialized: false
|
|
197
|
-
};
|
|
198
|
-
const [state, dispatch] = react.useReducer(lazyLoadingReducer, initialState);
|
|
293
|
+
const [state, dispatch] = useLazyLoaderReducer();
|
|
199
294
|
const { data, loading } = state;
|
|
295
|
+
const visibleRegion = provider.ctx.useValue(visibleRegionAtom);
|
|
200
296
|
uiComponents.useAsyncEffect(async () => {
|
|
201
297
|
testDataLoader(config, state, dispatch);
|
|
202
|
-
}, [
|
|
203
|
-
data,
|
|
204
|
-
state.visibleRegion.rowIndexStart,
|
|
205
|
-
state.visibleRegion.rowIndexEnd
|
|
206
|
-
]);
|
|
207
|
-
const ref = react.useRef(null);
|
|
208
|
-
const onScroll = react.useCallback(
|
|
209
|
-
underscore.debounce((visibleCells) => {
|
|
210
|
-
if (visibleCells.rowIndexEnd == ref.current?.rowIndexEnd && visibleCells.rowIndexStart == ref.current?.rowIndexStart) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
console.log("Visible cells changed", visibleCells);
|
|
214
|
-
dispatch({
|
|
215
|
-
type: "set-visible",
|
|
216
|
-
region: visibleCells
|
|
217
|
-
});
|
|
218
|
-
ref.current = visibleCells;
|
|
219
|
-
}, 500),
|
|
220
|
-
[dispatch]
|
|
221
|
-
);
|
|
298
|
+
}, [data, visibleRegion]);
|
|
222
299
|
return {
|
|
223
300
|
data,
|
|
224
301
|
loading,
|
|
225
|
-
onScroll,
|
|
226
302
|
dispatch
|
|
227
303
|
};
|
|
228
304
|
}
|
|
@@ -274,15 +350,12 @@ const testQueryFunc = async (cfg) => {
|
|
|
274
350
|
let count = cfg.limit;
|
|
275
351
|
const totalCount = 5e4;
|
|
276
352
|
count = Math.min(count, totalCount - offset);
|
|
277
|
-
await sleep(100);
|
|
353
|
+
await loadingUtils.sleep(100);
|
|
278
354
|
return {
|
|
279
355
|
data: buildSyntheticData(offset, count),
|
|
280
356
|
count: cfg.count != null ? 5e4 : void 0
|
|
281
357
|
};
|
|
282
358
|
};
|
|
283
|
-
async function sleep(ms) {
|
|
284
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
285
|
-
}
|
|
286
359
|
function buildSyntheticData(offset, count) {
|
|
287
360
|
console.log(
|
|
288
361
|
`Getting data at indices between ${offset} and ${offset + count}`
|
|
@@ -291,10 +364,14 @@ function buildSyntheticData(offset, count) {
|
|
|
291
364
|
const id = i + 1;
|
|
292
365
|
return {
|
|
293
366
|
id,
|
|
294
|
-
name: `
|
|
367
|
+
name: `row ${id} has some long text content`
|
|
295
368
|
};
|
|
296
369
|
});
|
|
297
370
|
}
|
|
371
|
+
exports.applyColumnFilters = applyColumnFilters;
|
|
372
|
+
exports.standardizeFilter = standardizeFilter;
|
|
298
373
|
exports.usePostgRESTLazyLoader = usePostgRESTLazyLoader;
|
|
374
|
+
exports.useScrollHandler = useScrollHandler;
|
|
299
375
|
exports.useTestLazyLoader = useTestLazyLoader;
|
|
376
|
+
exports.viewInfoAtom = viewInfoAtom;
|
|
300
377
|
//# sourceMappingURL=data-loaders.cjs.map
|