@macrostrat/data-sheet 4.2.0 → 4.3.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 +95 -0
- package/dist/actions/types.d.ts +10 -0
- package/dist/components/indicators/filter-and-sort.cjs +47 -6
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -1
- package/dist/components/indicators/filter-and-sort.d.ts +28 -6
- package/dist/components/indicators/filter-and-sort.js +48 -7
- package/dist/components/indicators/filter-and-sort.js.map +1 -1
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +5 -3
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -1
- package/dist/components/indicators/filter-and-sort.module.sass.js +5 -3
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -1
- package/dist/components/indicators/unified-filters.cjs +36 -22
- package/dist/components/indicators/unified-filters.cjs.map +1 -1
- package/dist/components/indicators/unified-filters.d.ts +10 -8
- package/dist/components/indicators/unified-filters.js +37 -23
- package/dist/components/indicators/unified-filters.js.map +1 -1
- package/dist/components/indicators/view-info.cjs +11 -5
- package/dist/components/indicators/view-info.cjs.map +1 -1
- package/dist/components/indicators/view-info.d.ts +6 -1
- package/dist/components/indicators/view-info.js +12 -6
- package/dist/components/indicators/view-info.js.map +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +7 -1
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -1
- package/dist/components/toolbars/actions-toolbar.js +7 -1
- package/dist/components/toolbars/actions-toolbar.js.map +1 -1
- package/dist/data-panel.cjs +53 -8
- package/dist/data-panel.cjs.map +1 -1
- package/dist/data-panel.d.ts +1 -1
- package/dist/data-panel.js +54 -9
- package/dist/data-panel.js.map +1 -1
- package/dist/data-panel.module.sass.cjs +24 -21
- package/dist/data-panel.module.sass.cjs.map +1 -1
- package/dist/data-panel.module.sass.js +24 -21
- package/dist/data-panel.module.sass.js.map +1 -1
- package/dist/data-sheet.cjs +9 -2
- package/dist/data-sheet.cjs.map +1 -1
- package/dist/data-sheet.css +56 -35
- package/dist/data-sheet.d.ts +1 -1
- package/dist/data-sheet.js +9 -2
- package/dist/data-sheet.js.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -1
- package/dist/postgrest-table/data-loaders.cjs +20 -3
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +10 -0
- package/dist/postgrest-table/data-loaders.js +21 -4
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/provider/core.cjs +27 -56
- package/dist/provider/core.cjs.map +1 -1
- package/dist/provider/core.d.ts +7 -9
- package/dist/provider/core.js +19 -48
- package/dist/provider/core.js.map +1 -1
- package/dist/provider/interactions.d.ts +1 -1
- package/dist/provider/selection.d.ts +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.js.map +1 -1
- package/package.json +6 -7
- package/src/actions/types.ts +11 -0
- package/src/components/indicators/filter-and-sort.module.sass +7 -0
- package/src/components/indicators/filter-and-sort.ts +71 -11
- package/src/components/indicators/unified-filters.ts +66 -29
- package/src/components/indicators/view-info.ts +15 -5
- package/src/components/toolbars/actions-toolbar.ts +10 -1
- package/src/data-panel.module.sass +18 -1
- package/src/data-panel.ts +67 -8
- package/src/data-sheet.ts +18 -2
- package/src/postgrest-table/data-loaders.ts +40 -4
- package/src/provider/core.ts +29 -53
- package/src/types.ts +4 -0
package/src/provider/core.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import h from "@macrostrat/hyper";
|
|
3
|
-
import { createStore, StoreApi, useStore } from "zustand";
|
|
4
3
|
import { Table } from "@blueprintjs/table";
|
|
5
4
|
import {
|
|
6
5
|
type ColumnSpec,
|
|
@@ -8,7 +7,15 @@ import {
|
|
|
8
7
|
postprocessColumnSpec,
|
|
9
8
|
} from "./column-spec.ts";
|
|
10
9
|
import { splitProps } from "../utils";
|
|
11
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
createScopedStore,
|
|
12
|
+
zustandAPIAtom,
|
|
13
|
+
zustandStoreAtom,
|
|
14
|
+
atom,
|
|
15
|
+
ZustandStoreProvider,
|
|
16
|
+
useZustandSelector,
|
|
17
|
+
useZustandStoreAPI,
|
|
18
|
+
} from "@macrostrat/scoped-store";
|
|
12
19
|
import {
|
|
13
20
|
DataSheetProviderProps,
|
|
14
21
|
DataSheetState,
|
|
@@ -17,10 +24,8 @@ import {
|
|
|
17
24
|
TableElementStatus,
|
|
18
25
|
} from "./types.ts";
|
|
19
26
|
import { createZustandStore } from "./zustand-store.ts";
|
|
20
|
-
import { atomWithStore } from "jotai-zustand";
|
|
21
27
|
import { toasterAtom } from "../notifications.ts";
|
|
22
28
|
import { TableAction } from "../actions";
|
|
23
|
-
import { atom } from "jotai";
|
|
24
29
|
import {
|
|
25
30
|
createLocalProvider,
|
|
26
31
|
dataRefreshTokenAtom,
|
|
@@ -42,33 +47,10 @@ import { DataPanelProps } from "../data-panel.ts";
|
|
|
42
47
|
/** Create a Jotai scoped store */
|
|
43
48
|
export const ctx = createScopedStore();
|
|
44
49
|
|
|
45
|
-
export const storeAPIAtom =
|
|
46
|
-
|
|
47
|
-
const storeWrapperAtom = atom((get) => {
|
|
48
|
-
const _storeAPIAtom = get(storeAPIAtom);
|
|
49
|
-
if (_storeAPIAtom == null) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
return atomWithStore(_storeAPIAtom);
|
|
53
|
-
});
|
|
50
|
+
export const storeAPIAtom = zustandAPIAtom;
|
|
54
51
|
|
|
55
52
|
/** This is the basis for all other atoms that manipulate the store. */
|
|
56
|
-
export const storeAtom =
|
|
57
|
-
(get) => {
|
|
58
|
-
const storeWrapper = get(storeWrapperAtom);
|
|
59
|
-
if (storeWrapper == null) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
return get(storeWrapper);
|
|
63
|
-
},
|
|
64
|
-
(get, set, action: SetStateAction<any>) => {
|
|
65
|
-
const storeWrapper = get(storeWrapperAtom);
|
|
66
|
-
if (storeWrapper == null) {
|
|
67
|
-
throw new Error("Missing DataSheetProvider");
|
|
68
|
-
}
|
|
69
|
-
return set(storeWrapper, action);
|
|
70
|
-
},
|
|
71
|
-
);
|
|
53
|
+
export const storeAtom = zustandStoreAtom;
|
|
72
54
|
|
|
73
55
|
/** Stable empty spec so a function `columnSpec` yields a constant init value
|
|
74
56
|
* (see `DataSheetProviderInner`). */
|
|
@@ -77,7 +59,7 @@ const EMPTY_SPEC: ColumnSpec[] = [];
|
|
|
77
59
|
const initializeStoreAtom = atom(
|
|
78
60
|
null,
|
|
79
61
|
(get, set, payload: Partial<DataSheetStore<any>>) => {
|
|
80
|
-
set(
|
|
62
|
+
set(zustandStoreAtom, (state) => {
|
|
81
63
|
return {
|
|
82
64
|
...state,
|
|
83
65
|
...payload,
|
|
@@ -172,16 +154,13 @@ export function useResolvedProvider<T>(props: {
|
|
|
172
154
|
|
|
173
155
|
function DataSheetStoreWrapper<T>(props: DataSheetProviderProps<T>) {
|
|
174
156
|
const { toaster, ...rest } = props;
|
|
175
|
-
const [store] = useState(() => {
|
|
176
|
-
return createStore<DataSheetStore<T>>(createZustandStore);
|
|
177
|
-
});
|
|
178
157
|
return h(
|
|
179
|
-
|
|
158
|
+
ZustandStoreProvider,
|
|
180
159
|
{
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
160
|
+
ctx,
|
|
161
|
+
initializeStore: createZustandStore,
|
|
162
|
+
atoms: [[toasterAtom, toaster]],
|
|
163
|
+
debugName: "DataSheetProvider",
|
|
185
164
|
},
|
|
186
165
|
h(DataSheetProviderInner, rest),
|
|
187
166
|
);
|
|
@@ -209,9 +188,7 @@ const dataProviderKeys = new Set([
|
|
|
209
188
|
]);
|
|
210
189
|
|
|
211
190
|
type AnyDataSheetProps<T> =
|
|
212
|
-
|
|
|
213
|
-
| DataPanelProps<T>
|
|
214
|
-
| DataSheetProps<T>;
|
|
191
|
+
DataViewProps<T> | DataPanelProps<T> | DataSheetProps<T>;
|
|
215
192
|
|
|
216
193
|
export function splitDataProviderProps<T>(props: AnyDataSheetProps<T>) {
|
|
217
194
|
/** Split provided props based on provider's needs */
|
|
@@ -295,9 +272,13 @@ export function DataSheetProviderInner<T>(
|
|
|
295
272
|
useEffect(() => {
|
|
296
273
|
initializeStore({
|
|
297
274
|
columnSpec: postprocessColumnSpec(baseSpec),
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
|
|
275
|
+
// Suppress the loader's first-chunk auto-generation whenever the consumer
|
|
276
|
+
// provided a spec at all — a function (derived later in `_DataSheet`) OR
|
|
277
|
+
// an explicit array, *including an empty one*. An empty array means "no
|
|
278
|
+
// facet columns" (e.g. a browse panel whose only control is a sheet-level
|
|
279
|
+
// search), not "please generate from the data". Auto-gen runs only when
|
|
280
|
+
// no `columnSpec` was passed.
|
|
281
|
+
deferColumnSpec: columnSpec != null,
|
|
301
282
|
editable: interactionOptions.enableEditing,
|
|
302
283
|
enableColumnReordering,
|
|
303
284
|
data,
|
|
@@ -398,19 +379,14 @@ export function DataSheetProviderInner<T>(
|
|
|
398
379
|
return children;
|
|
399
380
|
}
|
|
400
381
|
|
|
401
|
-
export function useStoreAPI<T>()
|
|
402
|
-
|
|
403
|
-
if (!store) {
|
|
404
|
-
throw new Error("Missing DataSheetProvider");
|
|
405
|
-
}
|
|
406
|
-
return store;
|
|
382
|
+
export function useStoreAPI<T>() {
|
|
383
|
+
return useZustandStoreAPI<DataSheetStore<T>>(ctx);
|
|
407
384
|
}
|
|
408
385
|
|
|
409
386
|
export function useSelector<T = any, A = any>(
|
|
410
387
|
selector: (state: DataSheetStore<T>) => A,
|
|
411
388
|
): A {
|
|
412
|
-
|
|
413
|
-
return useStore(store, selector);
|
|
389
|
+
return useZustandSelector<T, A>(ctx, selector);
|
|
414
390
|
}
|
|
415
391
|
/** Atoms for efficient sub-selection of state */
|
|
416
392
|
|
package/src/types.ts
CHANGED
|
@@ -18,6 +18,10 @@ export type FetchMode = "scroll" | "paged";
|
|
|
18
18
|
export interface FetchDataOptions {
|
|
19
19
|
pageSize?: number;
|
|
20
20
|
fetchMode?: FetchMode;
|
|
21
|
+
/** Debounce (ms) applied to view-state → refetch, so rapid changes (typing a
|
|
22
|
+
* text filter) collapse into one fetch once the view settles. The input stays
|
|
23
|
+
* instant; only the fetch waits. `0` (default) keeps immediate refetching. */
|
|
24
|
+
filterDebounce?: number;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/** Props shared between the wrapper components and the provider */
|