@macrostrat/data-sheet 4.1.0 → 4.2.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 +40 -0
- package/dist/actions/builtin.cjs +1 -1
- package/dist/actions/builtin.cjs.map +1 -1
- package/dist/actions/builtin.d.ts +0 -2
- package/dist/actions/builtin.js +1 -1
- package/dist/actions/builtin.js.map +1 -1
- package/dist/actions/clipboard.cjs +1 -1
- package/dist/actions/clipboard.cjs.map +1 -1
- package/dist/actions/clipboard.d.ts +3 -2
- package/dist/actions/clipboard.js +1 -1
- package/dist/actions/clipboard.js.map +1 -1
- package/dist/actions/column-controls.cjs +7 -184
- package/dist/actions/column-controls.cjs.map +1 -1
- package/dist/actions/column-controls.d.ts +1 -1
- package/dist/actions/column-controls.js +5 -182
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -50
- package/dist/actions/column-filter.cjs.map +1 -1
- package/dist/actions/column-filter.d.ts +6 -4
- package/dist/actions/column-filter.js +25 -51
- package/dist/actions/column-filter.js.map +1 -1
- package/dist/actions/context.cjs +147 -0
- package/dist/actions/context.cjs.map +1 -0
- package/dist/actions/context.d.ts +93 -0
- package/dist/actions/context.js +145 -0
- package/dist/actions/context.js.map +1 -0
- package/dist/actions/edit-actions.cjs.map +1 -1
- package/dist/actions/edit-actions.d.ts +3 -1
- package/dist/actions/edit-actions.js.map +1 -1
- package/dist/actions/index.d.ts +2 -3
- package/dist/actions/selection.cjs +70 -115
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +22 -12
- package/dist/actions/selection.js +71 -114
- package/dist/actions/selection.js.map +1 -1
- package/dist/actions/{table-controls.cjs → table-actions.cjs} +7 -24
- package/dist/actions/table-actions.cjs.map +1 -0
- package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
- package/dist/actions/{table-controls.js → table-actions.js} +2 -19
- package/dist/actions/table-actions.js.map +1 -0
- package/dist/actions/types.d.ts +11 -89
- package/dist/components/cell-detail.cjs +6 -6
- package/dist/components/cell-detail.cjs.map +1 -1
- package/dist/components/cell-detail.js +1 -1
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +7 -7
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/indicators/filter-and-sort.cjs +378 -0
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.d.ts +59 -0
- package/dist/components/indicators/filter-and-sort.js +376 -0
- package/dist/components/indicators/filter-and-sort.js.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
- package/dist/components/indicators/index.d.ts +4 -0
- package/dist/components/indicators/selection.cjs +113 -0
- package/dist/components/indicators/selection.cjs.map +1 -0
- package/dist/components/indicators/selection.d.ts +3 -0
- package/dist/components/indicators/selection.js +111 -0
- package/dist/components/indicators/selection.js.map +1 -0
- package/dist/components/indicators/selection.module.sass.cjs +19 -0
- package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
- package/dist/components/indicators/selection.module.sass.js +17 -0
- package/dist/components/indicators/selection.module.sass.js.map +1 -0
- package/dist/components/indicators/unified-filters.cjs +130 -0
- package/dist/components/indicators/unified-filters.cjs.map +1 -0
- package/dist/components/indicators/unified-filters.d.ts +10 -0
- package/dist/components/indicators/unified-filters.js +130 -0
- package/dist/components/indicators/unified-filters.js.map +1 -0
- package/dist/components/indicators/view-info.cjs +59 -0
- package/dist/components/indicators/view-info.cjs.map +1 -0
- package/dist/components/{view-info.d.ts → indicators/view-info.d.ts} +1 -0
- package/dist/components/{view-info.js → indicators/view-info.js} +17 -13
- package/dist/components/indicators/view-info.js.map +1 -0
- package/dist/components/text-areas.cjs +5 -5
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.js +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +185 -0
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
- package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
- package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +36 -97
- package/dist/components/toolbars/actions-toolbar.js.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
- package/dist/components/toolbars/active-filters.cjs +120 -0
- package/dist/components/toolbars/active-filters.cjs.map +1 -0
- package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
- package/dist/components/toolbars/active-filters.js +120 -0
- package/dist/components/toolbars/active-filters.js.map +1 -0
- package/dist/components/toolbars/index.d.ts +2 -0
- package/dist/data-panel.cjs +291 -0
- package/dist/data-panel.cjs.map +1 -0
- package/dist/data-panel.d.ts +110 -0
- package/dist/data-panel.js +289 -0
- package/dist/data-panel.js.map +1 -0
- package/dist/data-panel.module.sass.cjs +40 -0
- package/dist/data-panel.module.sass.cjs.map +1 -0
- package/dist/data-panel.module.sass.js +38 -0
- package/dist/data-panel.module.sass.js.map +1 -0
- package/dist/{core.cjs → data-sheet.cjs} +123 -181
- package/dist/data-sheet.cjs.map +1 -0
- package/dist/data-sheet.css +241 -13
- package/dist/data-sheet.d.ts +16 -0
- package/dist/{core.js → data-sheet.js} +92 -150
- package/dist/data-sheet.js.map +1 -0
- package/dist/data-view.cjs +47 -0
- package/dist/data-view.cjs.map +1 -0
- package/dist/data-view.d.ts +15 -0
- package/dist/data-view.js +45 -0
- package/dist/data-view.js.map +1 -0
- package/dist/filters/operators.cjs +21 -4
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +5 -4
- package/dist/filters/operators.js +21 -4
- package/dist/filters/operators.js.map +1 -1
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +76 -17
- package/dist/index.js.map +1 -1
- package/dist/notifications.cjs +4 -4
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.js +1 -1
- package/dist/postgrest-table/data-loaders.cjs +129 -103
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -82
- package/dist/postgrest-table/data-loaders.js +110 -84
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +18 -17
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +4 -3
- package/dist/postgrest-table/index.js +9 -8
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/{utils → provider}/column-spec.cjs +23 -9
- package/dist/provider/column-spec.cjs.map +1 -0
- package/dist/{utils → provider}/column-spec.d.ts +77 -2
- package/dist/{utils → provider}/column-spec.js +24 -10
- package/dist/provider/column-spec.js.map +1 -0
- package/dist/provider/core.cjs +382 -0
- package/dist/provider/core.cjs.map +1 -0
- package/dist/provider/core.d.ts +74 -0
- package/dist/provider/core.js +380 -0
- package/dist/provider/core.js.map +1 -0
- package/dist/provider/index.d.ts +7 -0
- package/dist/provider/interactions.cjs +128 -0
- package/dist/provider/interactions.cjs.map +1 -0
- package/dist/provider/interactions.d.ts +39 -0
- package/dist/provider/interactions.js +128 -0
- package/dist/provider/interactions.js.map +1 -0
- package/dist/provider/selection.cjs +29 -0
- package/dist/provider/selection.cjs.map +1 -0
- package/dist/provider/selection.d.ts +9 -0
- package/dist/provider/selection.js +29 -0
- package/dist/provider/selection.js.map +1 -0
- package/dist/provider/table-data.cjs +92 -0
- package/dist/provider/table-data.cjs.map +1 -0
- package/dist/provider/table-data.d.ts +81 -0
- package/dist/provider/table-data.js +92 -0
- package/dist/provider/table-data.js.map +1 -0
- package/dist/provider/types.cjs +22 -0
- package/dist/provider/types.cjs.map +1 -0
- package/dist/provider/types.d.ts +256 -0
- package/dist/provider/types.js +22 -0
- package/dist/provider/types.js.map +1 -0
- package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +37 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +22 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +68 -35
- package/dist/renderers/cell-renderer.cjs.map +1 -0
- package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
- package/dist/{cell-renderer.js → renderers/cell-renderer.js} +66 -33
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +40 -17
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +2 -2
- package/dist/renderers/column-header-cell.js +40 -17
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/renderers/index.d.ts +1 -0
- package/dist/types.cjs +7 -19
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +123 -226
- package/dist/types.js +7 -19
- package/dist/types.js.map +1 -1
- package/dist/utils/atoms.cjs +24 -0
- package/dist/utils/atoms.cjs.map +1 -0
- package/dist/utils/atoms.d.ts +4 -0
- package/dist/utils/atoms.js +24 -0
- package/dist/utils/atoms.js.map +1 -0
- package/dist/utils/debug-overlay.cjs.map +1 -1
- package/dist/utils/debug-overlay.js.map +1 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/key-handling.cjs +140 -139
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +4 -2
- package/dist/utils/key-handling.js +136 -135
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/utils/validation.cjs +6 -1
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +6 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +4 -3
- package/src/actions/builtin.ts +1 -4
- package/src/actions/clipboard.ts +4 -3
- package/src/actions/column-controls.ts +12 -228
- package/src/actions/column-filter.ts +28 -63
- package/src/actions/context.ts +299 -0
- package/src/actions/edit-actions.ts +3 -1
- package/src/actions/index.ts +2 -3
- package/src/actions/selection.ts +109 -156
- package/src/actions/{table-controls.ts → table-actions.ts} +0 -20
- package/src/actions/types.ts +17 -101
- package/src/components/colors.ts +1 -1
- package/src/components/index.ts +2 -1
- package/src/components/indicators/filter-and-sort.module.sass +13 -0
- package/src/components/indicators/filter-and-sort.ts +478 -0
- package/src/components/indicators/index.ts +4 -0
- package/src/components/indicators/selection.module.sass +22 -0
- package/src/components/indicators/selection.ts +141 -0
- package/src/components/indicators/unified-filters.ts +161 -0
- package/src/components/{view-info.ts → indicators/view-info.ts} +16 -27
- package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
- package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +53 -126
- package/src/components/toolbars/active-filters.ts +150 -0
- package/src/components/toolbars/index.ts +2 -0
- package/src/data-panel.module.sass +185 -0
- package/src/data-panel.ts +556 -0
- package/src/{core.ts → data-sheet.ts} +144 -306
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +38 -6
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +250 -181
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +34 -15
- package/src/provider/core.ts +585 -0
- package/src/provider/index.ts +7 -0
- package/src/provider/interactions.ts +161 -0
- package/src/provider/selection.ts +31 -0
- package/src/provider/table-data.ts +178 -0
- package/src/provider/types.ts +273 -0
- package/src/{zustand-store.ts → provider/zustand-store.ts} +36 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +146 -58
- package/src/renderers/column-header-cell.ts +51 -17
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +143 -236
- package/src/utils/atoms.ts +28 -0
- package/src/utils/debug-overlay.ts +1 -1
- package/src/utils/index.ts +2 -8
- package/src/utils/key-handling.ts +170 -164
- package/src/utils/validation.ts +7 -2
- package/dist/actions/filters.cjs +0 -139
- package/dist/actions/filters.cjs.map +0 -1
- package/dist/actions/filters.js +0 -139
- package/dist/actions/filters.js.map +0 -1
- package/dist/actions/table-controls.cjs.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -246
- package/dist/actions/toolbar.cjs.map +0 -1
- package/dist/actions/toolbar.js.map +0 -1
- package/dist/actions/toolbar.module.sass.cjs +0 -27
- package/dist/actions/toolbar.module.sass.cjs.map +0 -1
- package/dist/actions/toolbar.module.sass.js +0 -25
- package/dist/actions/toolbar.module.sass.js.map +0 -1
- package/dist/cell-renderer.cjs.map +0 -1
- package/dist/cell-renderer.js.map +0 -1
- package/dist/components/view-info.cjs +0 -55
- package/dist/components/view-info.cjs.map +0 -1
- package/dist/components/view-info.js.map +0 -1
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -113
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -191
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -25
- package/dist/provider.js +0 -189
- package/dist/provider.js.map +0 -1
- package/dist/table-updates/data-parameter.d.ts +0 -14
- package/dist/table-updates/filter.d.ts +0 -16
- package/dist/table-updates/index.d.ts +0 -19
- package/dist/utils/column-spec.cjs.map +0 -1
- package/dist/utils/column-spec.js.map +0 -1
- package/dist/utils/index.cjs +0 -9
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/zustand-store.cjs.map +0 -1
- package/dist/zustand-store.js.map +0 -1
- package/src/actions/filters.ts +0 -176
- package/src/components/actions.module.sass +0 -8
- package/src/provider.ts +0 -250
- package/src/table-updates/data-parameter.ts +0 -44
- package/src/table-updates/filter.ts +0 -124
- package/src/table-updates/index.ts +0 -239
- /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,67 +1,98 @@
|
|
|
1
|
-
import { DataSheet,
|
|
1
|
+
import { DataSheet, DataSheetRenderer } from "./data-sheet.js";
|
|
2
|
+
import { DataCard, DataPanel, DataPanelRenderer, DataPanelToolbarStyle, createDataCard } from "./data-panel.js";
|
|
3
|
+
import { DataView } from "./data-view.js";
|
|
2
4
|
import { ExpandedLithologies, IntervalCell, LongTextViewer, PostgRESTTableView, SearchAction, fullTextSearchAction, lithologyRenderer, notifyOnError, wrapWithErrorHandling } from "./postgrest-table/index.js";
|
|
3
|
-
import { DataSheetProvider, DataSheetProviderInner, columnSpecAtom, ctx, storeAPIAtom, storeAtom, tableActionsAtom, tableDataAtom, useSelector, useStoreAPI } from "./provider.js";
|
|
4
|
-
import { range } from "./utils/index.js";
|
|
5
|
-
import { DEFAULT_ROW_STATUS_STYLES, DS_ROW_ID, TableElementStatus } from "./types.js";
|
|
6
5
|
import { DEFAULT_FILTER_OPERATORS, OPERATOR_LABELS, getOperatorsForColumn, testFilterOperator } from "./filters/operators.js";
|
|
6
|
+
import { DataSheetDensity } from "./types.js";
|
|
7
7
|
import { Cell } from "@blueprintjs/table";
|
|
8
8
|
import { ALL_CARDINALITIES, createSaveAction, hasPendingChanges } from "./actions/edit-actions.js";
|
|
9
|
-
import { ActionsToolbar
|
|
9
|
+
import { ActionsToolbar } from "./components/toolbars/actions-toolbar.js";
|
|
10
|
+
import { ActiveFiltersList } from "./components/toolbars/active-filters.js";
|
|
10
11
|
import { CellDetailModal } from "./components/cell-detail.js";
|
|
11
12
|
import { CellRendererDebugOverlay } from "./utils/debug-overlay.js";
|
|
12
13
|
import { ColorCell, ColorPicker, colorSwatchRenderer } from "./components/colors.js";
|
|
14
|
+
import { ColumnFilterControl, ColumnFilterForm, ColumnFilterMenu, ColumnFilterMenuItem, ColumnSortIndicator, ColumnSortMenu, FilterIndicator, MenuDropdown, resolveColumnFilter } from "./components/indicators/filter-and-sort.js";
|
|
15
|
+
import { DEFAULT_ROW_STATUS_STYLES, DS_ROW_ID, TableElementStatus } from "./provider/types.js";
|
|
16
|
+
import { DataSheetProvider, DataSheetProviderInner, capitalize, columnSpecAtom, ctx, dataProviderAtom, itemLabelAtom, pluralize, splitDataProviderProps, storeAPIAtom, storeAtom, tableActionsAtom, tableDataAtom, tableNameAtom, useItemCount, useResolvedProvider, useSelector, useStoreAPI } from "./provider/core.js";
|
|
17
|
+
import { DataViewRendererType, SelectionInteractionStyle, dragValueHandlerAtom, enableDragValueAtom, interactionOptionsAtom, interactionOptionsKeys, resolveInteractionOptions } from "./provider/interactions.js";
|
|
13
18
|
import { EditableTextArea } from "./components/text-areas.js";
|
|
14
19
|
import { EditorPopup } from "./components/editor-popup.js";
|
|
15
|
-
import {
|
|
16
|
-
import { LoadProgressIndicator } from "./components/view-info.js";
|
|
20
|
+
import { LoadProgressIndicator, LoadProgressLabel } from "./components/indicators/view-info.js";
|
|
17
21
|
import { PasteShape, clipboardActions, copyAction, cutAction, pasteAction, serializeSelectionToTSV } from "./actions/clipboard.js";
|
|
22
|
+
import { SelectionIndicator } from "./components/indicators/selection.js";
|
|
18
23
|
import { addRowAction, defaultTableActions, deleteRowsAction, resetChangesAction } from "./actions/builtin.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
24
|
+
import { anchorRefAtom, selectionAtom } from "./provider/selection.js";
|
|
25
|
+
import { applyColumnFilters, autoLoadPagesAtom, chunkPageAtom, createPostgRESTFetchChunk, createPostgRESTProvider, resumeBaselineAtom, standardizeFilter, tableFooterAtom, useDataLoader, useLoadControls, useScrollHandler, viewInfoAtom } from "./postgrest-table/data-loaders.js";
|
|
26
|
+
import { buildActionContext, runActionWrapper } from "./actions/context.js";
|
|
27
|
+
import { buildDataViewSelection, computeFilteredRowIndices, computeSelectionShape, getApplicableActions, getSelectedColumnKeys, getSelectedRowIndices, getSelectionCardinality, mergeColumnActions, range, rowIndicesToRegions } from "./actions/selection.js";
|
|
28
|
+
import { buildMultiOperatorColumnFilter, columnFilterId, enhanceColumnFilter } from "./actions/column-filter.js";
|
|
22
29
|
import { collectValidationErrors, validateCell } from "./utils/validation.js";
|
|
23
30
|
import { columnControlActions, columnFilterAction, columnSortAction, isColumnFilterable } from "./actions/column-controls.js";
|
|
24
|
-
import {
|
|
31
|
+
import { compareRowsBySorts, createLocalProvider, dataRefreshTokenAtom, persistViaProvider } from "./provider/table-data.js";
|
|
32
|
+
import { createZustandStore, singleFocusedCell, topLeftCell, updateSelection } from "./provider/zustand-store.js";
|
|
25
33
|
import { editorKeyHandlerAtom, multiLineTextKeyHandler, tableHotkeysAtom } from "./utils/key-handling.js";
|
|
26
|
-
import { generateColumnSpec, generateDefaultColumnSpec } from "./
|
|
34
|
+
import { generateColumnSpec, generateDefaultColumnSpec, postprocessColumnSpec } from "./provider/column-spec.js";
|
|
35
|
+
import { passThroughGet, passThroughSet, splitProps } from "./utils/atoms.js";
|
|
36
|
+
import { scrollToRowAction } from "./actions/table-actions.js";
|
|
37
|
+
import { useDataPanelControls } from "./components/indicators/unified-filters.js";
|
|
27
38
|
export {
|
|
28
39
|
ALL_CARDINALITIES,
|
|
29
40
|
ActionsToolbar,
|
|
41
|
+
ActiveFiltersList,
|
|
30
42
|
Cell,
|
|
31
43
|
CellDetailModal,
|
|
32
44
|
CellRendererDebugOverlay,
|
|
33
45
|
ColorCell,
|
|
34
46
|
ColorPicker,
|
|
47
|
+
ColumnFilterControl,
|
|
48
|
+
ColumnFilterForm,
|
|
49
|
+
ColumnFilterMenu,
|
|
50
|
+
ColumnFilterMenuItem,
|
|
51
|
+
ColumnSortIndicator,
|
|
52
|
+
ColumnSortMenu,
|
|
35
53
|
DEFAULT_FILTER_OPERATORS,
|
|
36
54
|
DEFAULT_ROW_STATUS_STYLES,
|
|
37
55
|
DS_ROW_ID,
|
|
56
|
+
DataCard,
|
|
57
|
+
DataPanel,
|
|
58
|
+
DataPanelRenderer,
|
|
59
|
+
DataPanelToolbarStyle,
|
|
38
60
|
DataSheet,
|
|
39
61
|
DataSheetDensity,
|
|
40
62
|
DataSheetProvider,
|
|
41
63
|
DataSheetProviderInner,
|
|
64
|
+
DataSheetRenderer,
|
|
65
|
+
DataView,
|
|
66
|
+
DataViewRendererType,
|
|
42
67
|
EditableTextArea,
|
|
43
68
|
EditorPopup,
|
|
44
69
|
ExpandedLithologies,
|
|
45
|
-
|
|
70
|
+
FilterIndicator,
|
|
46
71
|
IntervalCell,
|
|
47
72
|
LoadProgressIndicator,
|
|
73
|
+
LoadProgressLabel,
|
|
48
74
|
LongTextViewer,
|
|
75
|
+
MenuDropdown,
|
|
49
76
|
OPERATOR_LABELS,
|
|
50
77
|
PasteShape,
|
|
51
78
|
PostgRESTTableView,
|
|
52
79
|
SearchAction,
|
|
80
|
+
SelectionIndicator,
|
|
81
|
+
SelectionInteractionStyle,
|
|
53
82
|
TableElementStatus,
|
|
54
83
|
addRowAction,
|
|
84
|
+
anchorRefAtom,
|
|
55
85
|
applyColumnFilters,
|
|
86
|
+
autoLoadPagesAtom,
|
|
56
87
|
buildActionContext,
|
|
88
|
+
buildDataViewSelection,
|
|
89
|
+
buildMultiOperatorColumnFilter,
|
|
90
|
+
capitalize,
|
|
57
91
|
chunkPageAtom,
|
|
58
|
-
clearSelectionAction,
|
|
59
92
|
clipboardActions,
|
|
60
|
-
collectAllFilters,
|
|
61
93
|
collectValidationErrors,
|
|
62
94
|
colorSwatchRenderer,
|
|
63
95
|
columnControlActions,
|
|
64
|
-
columnFilter,
|
|
65
96
|
columnFilterAction,
|
|
66
97
|
columnFilterId,
|
|
67
98
|
columnSortAction,
|
|
@@ -70,37 +101,58 @@ export {
|
|
|
70
101
|
computeFilteredRowIndices,
|
|
71
102
|
computeSelectionShape,
|
|
72
103
|
copyAction,
|
|
104
|
+
createDataCard,
|
|
73
105
|
createLocalProvider,
|
|
74
106
|
createPostgRESTFetchChunk,
|
|
75
107
|
createPostgRESTProvider,
|
|
76
108
|
createSaveAction,
|
|
109
|
+
createZustandStore,
|
|
77
110
|
ctx,
|
|
78
111
|
cutAction,
|
|
112
|
+
dataProviderAtom,
|
|
79
113
|
dataRefreshTokenAtom,
|
|
80
114
|
defaultTableActions,
|
|
81
115
|
deleteRowsAction,
|
|
116
|
+
dragValueHandlerAtom,
|
|
82
117
|
editorKeyHandlerAtom,
|
|
118
|
+
enableDragValueAtom,
|
|
119
|
+
enhanceColumnFilter,
|
|
83
120
|
fullTextSearchAction,
|
|
84
121
|
generateColumnSpec,
|
|
85
122
|
generateDefaultColumnSpec,
|
|
86
123
|
getApplicableActions,
|
|
87
124
|
getOperatorsForColumn,
|
|
88
|
-
getRowsToDelete,
|
|
89
125
|
getSelectedColumnKeys,
|
|
90
126
|
getSelectedRowIndices,
|
|
91
127
|
getSelectionCardinality,
|
|
92
128
|
hasPendingChanges,
|
|
129
|
+
interactionOptionsAtom,
|
|
130
|
+
interactionOptionsKeys,
|
|
93
131
|
isColumnFilterable,
|
|
132
|
+
itemLabelAtom,
|
|
94
133
|
lithologyRenderer,
|
|
95
134
|
mergeColumnActions,
|
|
96
135
|
multiLineTextKeyHandler,
|
|
97
136
|
notifyOnError,
|
|
137
|
+
passThroughGet,
|
|
138
|
+
passThroughSet,
|
|
98
139
|
pasteAction,
|
|
140
|
+
persistViaProvider,
|
|
141
|
+
pluralize,
|
|
142
|
+
postprocessColumnSpec,
|
|
99
143
|
range,
|
|
100
144
|
resetChangesAction,
|
|
145
|
+
resolveColumnFilter,
|
|
146
|
+
resolveInteractionOptions,
|
|
147
|
+
resumeBaselineAtom,
|
|
148
|
+
rowIndicesToRegions,
|
|
101
149
|
runActionWrapper,
|
|
102
150
|
scrollToRowAction,
|
|
151
|
+
selectionAtom,
|
|
103
152
|
serializeSelectionToTSV,
|
|
153
|
+
singleFocusedCell,
|
|
154
|
+
splitDataProviderProps,
|
|
155
|
+
splitProps,
|
|
104
156
|
standardizeFilter,
|
|
105
157
|
storeAPIAtom,
|
|
106
158
|
storeAtom,
|
|
@@ -108,8 +160,15 @@ export {
|
|
|
108
160
|
tableDataAtom,
|
|
109
161
|
tableFooterAtom,
|
|
110
162
|
tableHotkeysAtom,
|
|
163
|
+
tableNameAtom,
|
|
111
164
|
testFilterOperator,
|
|
165
|
+
topLeftCell,
|
|
166
|
+
updateSelection,
|
|
112
167
|
useDataLoader,
|
|
168
|
+
useDataPanelControls,
|
|
169
|
+
useItemCount,
|
|
170
|
+
useLoadControls,
|
|
171
|
+
useResolvedProvider,
|
|
113
172
|
useScrollHandler,
|
|
114
173
|
useSelector,
|
|
115
174
|
useStoreAPI,
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/notifications.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const core = require("@blueprintjs/core");
|
|
3
|
+
const core$1 = require("@blueprintjs/core");
|
|
4
4
|
const jotai = require("jotai");
|
|
5
|
-
const provider = require("./provider.cjs");
|
|
6
5
|
const react = require("react");
|
|
6
|
+
const core = require("./provider/core.cjs");
|
|
7
7
|
const toasterAtom = jotai.atom(null);
|
|
8
8
|
function useToaster(toaster) {
|
|
9
|
-
const [toasterRef, setToasterRef] =
|
|
9
|
+
const [toasterRef, setToasterRef] = core.ctx.use(toasterAtom);
|
|
10
10
|
react.useEffect(() => {
|
|
11
11
|
{
|
|
12
|
-
core.OverlayToaster.create().then((t) => setToasterRef(t));
|
|
12
|
+
core$1.OverlayToaster.create().then((t) => setToasterRef(t));
|
|
13
13
|
}
|
|
14
14
|
}, [toaster]);
|
|
15
15
|
return toasterRef;
|
|
@@ -1 +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,
|
|
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,KAAAA,IAAI,IAAI,WAAW;AACvDC,QAAAA,UAAU,MAAM;AAGP;AACLC,aAAAA,eAAe,SAAS,KAAK,CAAC,MAAM,cAAc,CAAC,CAAC;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACZ,SAAO;AACT;;;"}
|
package/dist/notifications.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OverlayToaster } from "@blueprintjs/core";
|
|
2
2
|
import { atom } from "jotai";
|
|
3
|
-
import { ctx } from "./provider.js";
|
|
4
3
|
import { useEffect } from "react";
|
|
4
|
+
import { ctx } from "./provider/core.js";
|
|
5
5
|
const toasterAtom = atom(null);
|
|
6
6
|
function useToaster(toaster) {
|
|
7
7
|
const [toasterRef, setToasterRef] = ctx.use(toasterAtom);
|
|
@@ -6,8 +6,9 @@ const react = require("react");
|
|
|
6
6
|
const update = require("immutability-helper");
|
|
7
7
|
const postgrestJs = require("@supabase/postgrest-js");
|
|
8
8
|
const loadingUtils = require("./loading-utils.cjs");
|
|
9
|
-
const provider = require("../provider.cjs");
|
|
10
9
|
const jotai = require("jotai");
|
|
10
|
+
const core = require("../provider/core.cjs");
|
|
11
|
+
const tableData = require("../provider/table-data.cjs");
|
|
11
12
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
12
13
|
const update__default = /* @__PURE__ */ _interopDefault(update);
|
|
13
14
|
function standardizeFilter(columnFilter) {
|
|
@@ -21,11 +22,22 @@ function standardizeFilter(columnFilter) {
|
|
|
21
22
|
function applyColumnFilters(req, filters) {
|
|
22
23
|
for (const cf of filters) {
|
|
23
24
|
if (cf.value === "" || cf.value == null) continue;
|
|
25
|
+
if (cf.operator === "cs") {
|
|
26
|
+
req = req.contains(cf.key, splitFilterList(cf.value));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (cf.operator === "ov") {
|
|
30
|
+
req = req.overlaps(cf.key, splitFilterList(cf.value));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
24
33
|
const val = cf.operator === "like" || cf.operator === "ilike" ? `*${cf.value}*` : cf.value;
|
|
25
34
|
req = req.filter(cf.key, cf.operator, val);
|
|
26
35
|
}
|
|
27
36
|
return req;
|
|
28
37
|
}
|
|
38
|
+
function splitFilterList(value) {
|
|
39
|
+
return String(value).split(",").map((s) => s.trim()).filter((s) => s !== "");
|
|
40
|
+
}
|
|
29
41
|
function lazyLoadingReducer(state, action) {
|
|
30
42
|
switch (action.type) {
|
|
31
43
|
case "start-loading":
|
|
@@ -61,17 +73,10 @@ function lazyLoadingReducer(state, action) {
|
|
|
61
73
|
fetchMode: action.fetchMode,
|
|
62
74
|
pageSize: action.pageSize
|
|
63
75
|
};
|
|
64
|
-
case "start-reload":
|
|
65
|
-
return {
|
|
66
|
-
...state,
|
|
67
|
-
data: new Array(state.data.length).fill(null),
|
|
68
|
-
loading: true,
|
|
69
|
-
initialized: false
|
|
70
|
-
};
|
|
71
76
|
case "reset":
|
|
72
77
|
return {
|
|
73
78
|
visibleRegion: defaultVisibleRegion,
|
|
74
|
-
data:
|
|
79
|
+
data: new Array(Math.max(state.pageSize, 0)).fill(null),
|
|
75
80
|
loading: false,
|
|
76
81
|
error: null,
|
|
77
82
|
initialized: false,
|
|
@@ -89,6 +94,31 @@ function lazyLoadingReducer(state, action) {
|
|
|
89
94
|
return state;
|
|
90
95
|
}
|
|
91
96
|
}
|
|
97
|
+
function formatKeysetValue(v) {
|
|
98
|
+
const s = String(v);
|
|
99
|
+
if (s === "" || /[,.:()"\\ ]/.test(s)) {
|
|
100
|
+
return `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
101
|
+
}
|
|
102
|
+
return s;
|
|
103
|
+
}
|
|
104
|
+
function keysetEq(key, v) {
|
|
105
|
+
return v == null ? `${key}.is.null` : `${key}.eq.${formatKeysetValue(v)}`;
|
|
106
|
+
}
|
|
107
|
+
function buildKeysetPredicate(clauses, lastRow) {
|
|
108
|
+
const terms = [];
|
|
109
|
+
for (let i = 0; i < clauses.length; i++) {
|
|
110
|
+
const v = lastRow[clauses[i].key];
|
|
111
|
+
if (v == null) continue;
|
|
112
|
+
const conds = [];
|
|
113
|
+
for (let j = 0; j < i; j++) {
|
|
114
|
+
conds.push(keysetEq(clauses[j].key, lastRow[clauses[j].key]));
|
|
115
|
+
}
|
|
116
|
+
const op = clauses[i].ascending ?? true ? "gt" : "lt";
|
|
117
|
+
conds.push(`${clauses[i].key}.${op}.${formatKeysetValue(v)}`);
|
|
118
|
+
terms.push(conds.length === 1 ? conds[0] : `and(${conds.join(",")})`);
|
|
119
|
+
}
|
|
120
|
+
return terms.length > 0 ? terms.join(",") : null;
|
|
121
|
+
}
|
|
92
122
|
function buildQuery(client, config) {
|
|
93
123
|
const { columns = "*", count, lastLoadedRowIndex } = config;
|
|
94
124
|
const opts = { count };
|
|
@@ -105,18 +135,17 @@ function buildQuery(client, config) {
|
|
|
105
135
|
}
|
|
106
136
|
const orderClauses = buildPostgrestOrderClauses(
|
|
107
137
|
config.order ?? [],
|
|
108
|
-
config.identityKey
|
|
138
|
+
config.identityOrder ?? config.identityKey
|
|
109
139
|
);
|
|
110
140
|
let hasOrdering = false;
|
|
111
141
|
for (const clause of orderClauses) {
|
|
112
142
|
query = query.order(clause.key, clause);
|
|
113
|
-
if (config.lastLoadedRow != null) {
|
|
114
|
-
const op = clause.ascending ?? true ? "gt" : "lt";
|
|
115
|
-
const value = config.lastLoadedRow[clause.key];
|
|
116
|
-
query = query[op](clause.key, value);
|
|
117
|
-
}
|
|
118
143
|
hasOrdering = true;
|
|
119
144
|
}
|
|
145
|
+
if (config.lastLoadedRow != null && hasOrdering) {
|
|
146
|
+
const pred = buildKeysetPredicate(orderClauses, config.lastLoadedRow);
|
|
147
|
+
if (pred != null) query = query.or(pred);
|
|
148
|
+
}
|
|
120
149
|
let offset = null;
|
|
121
150
|
if (!hasOrdering && lastLoadedRowIndex > 0) {
|
|
122
151
|
offset = lastLoadedRowIndex + 1;
|
|
@@ -129,7 +158,6 @@ function buildQuery(client, config) {
|
|
|
129
158
|
query = query.limit(config.limit);
|
|
130
159
|
}
|
|
131
160
|
}
|
|
132
|
-
console.log("query", query.url.search);
|
|
133
161
|
return query;
|
|
134
162
|
}
|
|
135
163
|
const defaultVisibleRegion = {
|
|
@@ -146,28 +174,65 @@ const lazyLoaderCoreStateAtom = jotai.atom({
|
|
|
146
174
|
pageSize: 100
|
|
147
175
|
});
|
|
148
176
|
const chunkPageAtom = jotai.atom(0);
|
|
149
|
-
const dataRefreshTokenAtom = jotai.atom(0);
|
|
150
177
|
const tableFooterAtom = jotai.atom((get) => {
|
|
151
|
-
const core = get(lazyLoaderCoreStateAtom);
|
|
152
|
-
const data = get(
|
|
178
|
+
const core$1 = get(lazyLoaderCoreStateAtom);
|
|
179
|
+
const data = get(core.tableDataAtom) ?? [];
|
|
153
180
|
let loaded = 0;
|
|
154
181
|
let hasGaps = false;
|
|
155
182
|
for (const row of data) {
|
|
156
183
|
if (row != null) loaded++;
|
|
157
184
|
else hasGaps = true;
|
|
158
185
|
}
|
|
159
|
-
const total = core.totalCount ?? (hasGaps ? null : data.length);
|
|
160
|
-
const totalPages = core.totalCount != null ? Math.ceil(core.totalCount / core.pageSize) : null;
|
|
186
|
+
const total = core$1.totalCount ?? (hasGaps ? null : data.length);
|
|
187
|
+
const totalPages = core$1.totalCount != null ? Math.ceil(core$1.totalCount / core$1.pageSize) : null;
|
|
161
188
|
return {
|
|
162
|
-
mode: core.fetchMode,
|
|
189
|
+
mode: core$1.fetchMode,
|
|
163
190
|
loaded,
|
|
164
191
|
total,
|
|
165
|
-
loading: core.loading,
|
|
192
|
+
loading: core$1.loading,
|
|
166
193
|
page: get(chunkPageAtom),
|
|
167
|
-
pageSize: core.pageSize,
|
|
194
|
+
pageSize: core$1.pageSize,
|
|
168
195
|
totalPages
|
|
169
196
|
};
|
|
170
197
|
});
|
|
198
|
+
const autoLoadPagesAtom = jotai.atom(null);
|
|
199
|
+
const resumeBaselineAtom = jotai.atom(0);
|
|
200
|
+
function useLoadControls() {
|
|
201
|
+
const footer = core.ctx.useValue(tableFooterAtom);
|
|
202
|
+
const data = core.ctx.useValue(core.tableDataAtom) ?? [];
|
|
203
|
+
const { isLocalProvider } = core.ctx.useValue(core.dataProviderAtom);
|
|
204
|
+
const resumeBaseline = core.ctx.useValue(resumeBaselineAtom);
|
|
205
|
+
const autoLoadPages = core.ctx.useValue(autoLoadPagesAtom);
|
|
206
|
+
const setResumeBaseline = core.ctx.useSet(resumeBaselineAtom);
|
|
207
|
+
const setVisibleRegion = core.ctx.useSet(visibleRegionAtom);
|
|
208
|
+
let loadedCount = 0;
|
|
209
|
+
for (const row of data) if (row != null) loadedCount++;
|
|
210
|
+
const pageSize = footer.pageSize || 100;
|
|
211
|
+
const dataLength = data.length;
|
|
212
|
+
const hasMore = !isLocalProvider && loadedCount < dataLength;
|
|
213
|
+
const paused = autoLoadPages != null && loadedCount - resumeBaseline >= autoLoadPages * pageSize;
|
|
214
|
+
const canLoadMore = hasMore && !footer.loading && !paused;
|
|
215
|
+
const advance = react.useCallback(() => {
|
|
216
|
+
setVisibleRegion({
|
|
217
|
+
rowIndexStart: 0,
|
|
218
|
+
rowIndexEnd: Math.min(loadedCount + pageSize, dataLength)
|
|
219
|
+
});
|
|
220
|
+
}, [setVisibleRegion, loadedCount, pageSize, dataLength]);
|
|
221
|
+
const loadMore = react.useCallback(() => {
|
|
222
|
+
setResumeBaseline(loadedCount);
|
|
223
|
+
advance();
|
|
224
|
+
}, [setResumeBaseline, loadedCount, advance]);
|
|
225
|
+
return {
|
|
226
|
+
loadMore,
|
|
227
|
+
loading: footer.loading,
|
|
228
|
+
hasMore,
|
|
229
|
+
loaded: footer.loaded,
|
|
230
|
+
total: footer.total,
|
|
231
|
+
paused,
|
|
232
|
+
canLoadMore,
|
|
233
|
+
advance
|
|
234
|
+
};
|
|
235
|
+
}
|
|
171
236
|
const viewInfoAtom = jotai.atom((get) => {
|
|
172
237
|
const state = get(lazyLoaderStateAtom);
|
|
173
238
|
return {
|
|
@@ -179,11 +244,11 @@ const viewInfoAtom = jotai.atom((get) => {
|
|
|
179
244
|
});
|
|
180
245
|
const lazyLoaderStateAtom = jotai.atom(
|
|
181
246
|
(get) => {
|
|
182
|
-
const core = get(lazyLoaderCoreStateAtom);
|
|
183
|
-
const data = get(
|
|
247
|
+
const core$1 = get(lazyLoaderCoreStateAtom);
|
|
248
|
+
const data = get(core.tableDataAtom);
|
|
184
249
|
const visibleRegion = get(visibleRegionAtom);
|
|
185
250
|
return {
|
|
186
|
-
...core,
|
|
251
|
+
...core$1,
|
|
187
252
|
data,
|
|
188
253
|
visibleRegion
|
|
189
254
|
};
|
|
@@ -197,7 +262,7 @@ const lazyLoaderStateAtom = jotai.atom(
|
|
|
197
262
|
set(visibleRegionAtom, visibleRegion);
|
|
198
263
|
}
|
|
199
264
|
if (data != null) {
|
|
200
|
-
set(
|
|
265
|
+
set(core.tableDataAtom, data);
|
|
201
266
|
}
|
|
202
267
|
if (Object.keys(rest).length > 1) {
|
|
203
268
|
set(lazyLoaderCoreStateAtom, (v) => ({ ...v, ...rest }));
|
|
@@ -205,7 +270,7 @@ const lazyLoaderStateAtom = jotai.atom(
|
|
|
205
270
|
}
|
|
206
271
|
);
|
|
207
272
|
function useLazyLoaderReducer() {
|
|
208
|
-
const [state, setState] =
|
|
273
|
+
const [state, setState] = core.ctx.use(lazyLoaderStateAtom);
|
|
209
274
|
const dispatch = react.useCallback(
|
|
210
275
|
(action) => setState((prev) => lazyLoadingReducer(prev, action)),
|
|
211
276
|
[setState]
|
|
@@ -215,28 +280,33 @@ function useLazyLoaderReducer() {
|
|
|
215
280
|
function buildPostgrestOrderClauses(sorts, identityOrder) {
|
|
216
281
|
const identitySort = typeof identityOrder == "string" ? { key: identityOrder, ascending: true } : identityOrder;
|
|
217
282
|
const identityKey = identitySort.key;
|
|
218
|
-
const
|
|
219
|
-
|
|
283
|
+
const seen = /* @__PURE__ */ new Set();
|
|
284
|
+
const clauses = [];
|
|
285
|
+
for (const sort of sorts) {
|
|
286
|
+
if (seen.has(sort.key)) continue;
|
|
287
|
+
seen.add(sort.key);
|
|
288
|
+
clauses.push({
|
|
220
289
|
key: sort.key,
|
|
221
290
|
ascending: sort.ascending,
|
|
222
291
|
nullsFirst: "nullsFirst" in sort ? sort.nullsFirst : false
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
const hasIdentityClause = clauses.some((d) => d.key === identityKey);
|
|
226
|
-
if (hasIdentityClause) {
|
|
227
|
-
clauses.sort((a, b) => {
|
|
228
|
-
if (a.key === identityKey) return 1;
|
|
229
|
-
if (b.key === identityKey) return -1;
|
|
230
|
-
return 0;
|
|
231
292
|
});
|
|
293
|
+
}
|
|
294
|
+
if (seen.has(identityKey)) {
|
|
295
|
+
const idx = clauses.findIndex((c) => c.key === identityKey);
|
|
296
|
+
const [idClause] = clauses.splice(idx, 1);
|
|
297
|
+
clauses.push(idClause);
|
|
232
298
|
} else {
|
|
233
|
-
clauses.push(
|
|
299
|
+
clauses.push({
|
|
300
|
+
key: identitySort.key,
|
|
301
|
+
ascending: identitySort.ascending ?? true,
|
|
302
|
+
nullsFirst: identitySort.nullsFirst ?? false
|
|
303
|
+
});
|
|
234
304
|
}
|
|
235
305
|
return clauses;
|
|
236
306
|
}
|
|
237
307
|
function useScrollHandler() {
|
|
238
308
|
const ref = react.useRef(null);
|
|
239
|
-
const setVisibleRegion =
|
|
309
|
+
const setVisibleRegion = core.ctx.useSet(visibleRegionAtom);
|
|
240
310
|
return react.useCallback(
|
|
241
311
|
underscore.debounce((visibleCells) => {
|
|
242
312
|
if (visibleCells.rowIndexEnd == ref.current?.rowIndexEnd && visibleCells.rowIndexStart == ref.current?.rowIndexStart) {
|
|
@@ -248,65 +318,16 @@ function useScrollHandler() {
|
|
|
248
318
|
[setVisibleRegion]
|
|
249
319
|
);
|
|
250
320
|
}
|
|
251
|
-
function createLocalProvider(data, options = {}) {
|
|
252
|
-
const identity = options.identity ?? defaultLocalIdentity;
|
|
253
|
-
return {
|
|
254
|
-
identity,
|
|
255
|
-
async fetchData({ offset, limit, sorts, filters }) {
|
|
256
|
-
let rows = data;
|
|
257
|
-
if (filters != null && filters.length > 0) {
|
|
258
|
-
rows = rows.filter(
|
|
259
|
-
(row) => filters.every(
|
|
260
|
-
(f) => f.predicate != null ? f.predicate(row, f.state) : true
|
|
261
|
-
)
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
if (sorts != null && sorts.length > 0) {
|
|
265
|
-
rows = [...rows].sort(compareRowsBySorts(sorts));
|
|
266
|
-
}
|
|
267
|
-
return {
|
|
268
|
-
rows: rows.slice(offset, offset + limit),
|
|
269
|
-
totalCount: rows.length
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
const _syntheticRowIds = /* @__PURE__ */ new WeakMap();
|
|
275
|
-
let _syntheticRowCounter = 0;
|
|
276
|
-
function defaultLocalIdentity(row) {
|
|
277
|
-
if (row == null) return void 0;
|
|
278
|
-
if (row.id != null) return row.id;
|
|
279
|
-
if (typeof row !== "object") return row;
|
|
280
|
-
let id = _syntheticRowIds.get(row);
|
|
281
|
-
if (id == null) {
|
|
282
|
-
id = `__row_${_syntheticRowCounter++}`;
|
|
283
|
-
_syntheticRowIds.set(row, id);
|
|
284
|
-
}
|
|
285
|
-
return id;
|
|
286
|
-
}
|
|
287
|
-
function compareRowsBySorts(sorts) {
|
|
288
|
-
return (a, b) => {
|
|
289
|
-
for (const sort of sorts) {
|
|
290
|
-
const av = a?.[sort.key];
|
|
291
|
-
const bv = b?.[sort.key];
|
|
292
|
-
if (av == null && bv == null) continue;
|
|
293
|
-
if (av == null) return sort.ascending ? -1 : 1;
|
|
294
|
-
if (bv == null) return sort.ascending ? 1 : -1;
|
|
295
|
-
const cmp = av < bv ? -1 : av > bv ? 1 : 0;
|
|
296
|
-
if (cmp !== 0) return sort.ascending ? cmp : -cmp;
|
|
297
|
-
}
|
|
298
|
-
return 0;
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
321
|
function useDataLoader(fetchChunk, options = {}) {
|
|
302
322
|
const { pageSize = 100, fetchMode = "scroll" } = options;
|
|
303
323
|
const [state, dispatch] = useLazyLoaderReducer();
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
324
|
+
const { isLocalProvider, provider } = core.ctx.useValue(core.dataProviderAtom);
|
|
325
|
+
const visibleRegion = core.ctx.useValue(visibleRegionAtom);
|
|
326
|
+
const page = core.ctx.useValue(chunkPageAtom);
|
|
327
|
+
const setPage = core.ctx.useSet(chunkPageAtom);
|
|
328
|
+
const refreshToken = core.ctx.useValue(tableData.dataRefreshTokenAtom);
|
|
329
|
+
const columnSorts = core.useSelector((s) => s.columnSorts);
|
|
330
|
+
const activeFilters = core.useSelector((s) => s.activeFilters);
|
|
310
331
|
const abortRef = react.useRef(null);
|
|
311
332
|
const loadedRef = react.useRef({
|
|
312
333
|
page: -1,
|
|
@@ -407,8 +428,8 @@ function createPostgRESTFetchChunk(config) {
|
|
|
407
428
|
return async ({ limit, signal, sorts, filters, cursor }) => {
|
|
408
429
|
const client = new postgrestJs.PostgrestClient(config.endpoint).from(config.table);
|
|
409
430
|
const order = [
|
|
410
|
-
...
|
|
411
|
-
...
|
|
431
|
+
...sorts.map((s) => ({ key: s.key, ascending: s.ascending })),
|
|
432
|
+
...config.baseOrder ?? []
|
|
412
433
|
];
|
|
413
434
|
const pgFilters = [];
|
|
414
435
|
if (config.baseFilter != null) {
|
|
@@ -425,6 +446,10 @@ function createPostgRESTFetchChunk(config) {
|
|
|
425
446
|
count: cursor == null ? "exact" : void 0,
|
|
426
447
|
limit,
|
|
427
448
|
identityKey: config.identityKey,
|
|
449
|
+
identityOrder: {
|
|
450
|
+
key: config.identityKey,
|
|
451
|
+
ascending: config.identityAscending ?? true
|
|
452
|
+
},
|
|
428
453
|
order,
|
|
429
454
|
filters: pgFilters,
|
|
430
455
|
lastLoadedRow: cursor?.row ?? null,
|
|
@@ -464,7 +489,8 @@ function standardColumnFilter(f) {
|
|
|
464
489
|
return null;
|
|
465
490
|
}
|
|
466
491
|
function indexOfFirstNullInRegion(data, region) {
|
|
467
|
-
|
|
492
|
+
const end = Math.min(region.rowIndexEnd, data.length);
|
|
493
|
+
for (let i = region.rowIndexStart; i < end; i++) {
|
|
468
494
|
if (data[i] == null) {
|
|
469
495
|
return i;
|
|
470
496
|
}
|
|
@@ -472,15 +498,15 @@ function indexOfFirstNullInRegion(data, region) {
|
|
|
472
498
|
return null;
|
|
473
499
|
}
|
|
474
500
|
exports.applyColumnFilters = applyColumnFilters;
|
|
501
|
+
exports.autoLoadPagesAtom = autoLoadPagesAtom;
|
|
475
502
|
exports.chunkPageAtom = chunkPageAtom;
|
|
476
|
-
exports.compareRowsBySorts = compareRowsBySorts;
|
|
477
|
-
exports.createLocalProvider = createLocalProvider;
|
|
478
503
|
exports.createPostgRESTFetchChunk = createPostgRESTFetchChunk;
|
|
479
504
|
exports.createPostgRESTProvider = createPostgRESTProvider;
|
|
480
|
-
exports.
|
|
505
|
+
exports.resumeBaselineAtom = resumeBaselineAtom;
|
|
481
506
|
exports.standardizeFilter = standardizeFilter;
|
|
482
507
|
exports.tableFooterAtom = tableFooterAtom;
|
|
483
508
|
exports.useDataLoader = useDataLoader;
|
|
509
|
+
exports.useLoadControls = useLoadControls;
|
|
484
510
|
exports.useScrollHandler = useScrollHandler;
|
|
485
511
|
exports.viewInfoAtom = viewInfoAtom;
|
|
486
512
|
//# sourceMappingURL=data-loaders.cjs.map
|