@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/src/types.ts
CHANGED
|
@@ -1,250 +1,157 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import {
|
|
2
|
+
EditEvent,
|
|
3
|
+
FetchData,
|
|
4
|
+
InteractionOptions,
|
|
5
|
+
RowHeaderRenderContext,
|
|
6
|
+
RowStatusStyles,
|
|
7
|
+
TableDataProvider,
|
|
8
|
+
TableElementStatus,
|
|
9
|
+
VisibleCells,
|
|
10
|
+
} from "./provider";
|
|
11
|
+
import type { ColumnSpec, ColumnSpecOptions } from "./provider";
|
|
12
|
+
import { ReactNode } from "react";
|
|
13
|
+
import { TableAction, TableActionContext, TableFilter } from "./actions";
|
|
14
|
+
import { Region, TableProps } from "@blueprintjs/table";
|
|
15
|
+
|
|
16
|
+
export type FetchMode = "scroll" | "paged";
|
|
17
|
+
|
|
18
|
+
export interface FetchDataOptions {
|
|
19
|
+
pageSize?: number;
|
|
20
|
+
fetchMode?: FetchMode;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
/**
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| { type: "deleteRows"; rowIndices: number[] }
|
|
31
|
-
| { type: "restoreRows"; rowIndices: number[] }
|
|
32
|
-
| { type: "addRow"; rowIndex: number; value: Partial<T> }
|
|
33
|
-
| { type: "resetChanges" };
|
|
34
|
-
|
|
35
|
-
export interface DataSheetCoreProps<T> {
|
|
36
|
-
data: T[];
|
|
37
|
-
columnSpec?: ColumnSpec[];
|
|
38
|
-
editable?: boolean;
|
|
23
|
+
/** Props shared between the wrapper components and the provider */
|
|
24
|
+
export interface DataViewCoreProps<T> extends InteractionOptions {
|
|
25
|
+
/** In-memory rows. Internally wrapped in a local `TableDataProvider` and
|
|
26
|
+
* driven through the same loader as any other source. */
|
|
27
|
+
data?: T[];
|
|
28
|
+
/** Column definitions. Either a static array, or a function derived from the
|
|
29
|
+
* loaded rows — invoked once the first rows arrive (and re-invoked when the
|
|
30
|
+
* function's identity changes), so a data-shaped spec needs no separate fetch
|
|
31
|
+
* of sample data. Omit entirely to auto-generate a plain spec via
|
|
32
|
+
* `columnSpecOptions`. */
|
|
33
|
+
columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);
|
|
34
|
+
columnSpecOptions?: ColumnSpecOptions<T>;
|
|
39
35
|
enableColumnReordering?: boolean;
|
|
40
36
|
defaultColumnWidth?: number;
|
|
37
|
+
// function to fetch a chunk of data (the read side of a data provider)
|
|
38
|
+
fetchData?: FetchData<T>;
|
|
39
|
+
/** A data provider instantiated separately and passed in — bundles the read
|
|
40
|
+
* side (`fetchData` + `identity`) and, optionally, the persistence side
|
|
41
|
+
* (`saveRows` / `deleteRows` / `insertRow`) that drives the Save action. An
|
|
42
|
+
* explicit alternative to the loose `data` / `fetchData` / `identity` props;
|
|
43
|
+
* takes precedence when given. */
|
|
44
|
+
provider?: TableDataProvider<T>;
|
|
45
|
+
/** Row identity for the edit overlay — stable across a provider re-sort (a
|
|
46
|
+
* data provider supplies its own; defaults to `(row) => row?.id`). Lets edits
|
|
47
|
+
* survive a re-ordered re-fetch. */
|
|
48
|
+
identity?: (row: T) => string | number | null | undefined;
|
|
49
|
+
/** Shown as the toolbar's leading label when nothing is selected. */
|
|
50
|
+
name?: string;
|
|
51
|
+
// itemLabel (e.g., "row", "item")
|
|
52
|
+
itemLabel?: string;
|
|
53
|
+
/** Bump to force a re-fetch from scratch (e.g. after an immediate edit that
|
|
54
|
+
* mutated rows through the provider). */
|
|
55
|
+
refreshToken?: number | string;
|
|
41
56
|
}
|
|
42
57
|
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** Presentation for a row status: applied to the row's cells and its header
|
|
55
|
-
* cell. Keyed by status value in `rowStatusStyles`. The library ships a
|
|
56
|
-
* default for `"deleted"` (dimmed + struck through, danger intent); consumers
|
|
57
|
-
* merge in styles for their own statuses (and may override the defaults). */
|
|
58
|
-
export interface RowStatusStyle {
|
|
59
|
-
/** Style merged onto each cell in a row with this status. */
|
|
60
|
-
cellStyle?: import("react").CSSProperties;
|
|
61
|
-
/** Style applied to the row's header cell. */
|
|
62
|
-
headerStyle?: import("react").CSSProperties;
|
|
63
|
-
/** Blueprint intent applied to the row's cells (precedence: validation >
|
|
64
|
-
* this > edited-green). */
|
|
65
|
-
intent?: import("@blueprintjs/core").Intent;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type RowStatusStyles = Record<string, RowStatusStyle>;
|
|
69
|
-
|
|
70
|
-
/** Built-in row-status presentation. Consumers' `rowStatusStyles` are merged
|
|
71
|
-
* over this, so `"deleted"` keeps its look unless explicitly overridden. */
|
|
72
|
-
export const DEFAULT_ROW_STATUS_STYLES: RowStatusStyles = {
|
|
73
|
-
[TableElementStatus.DELETED]: {
|
|
74
|
-
cellStyle: { opacity: 0.5, textDecoration: "line-through" },
|
|
75
|
-
headerStyle: { opacity: 0.5, textDecoration: "line-through" },
|
|
76
|
-
intent: "danger",
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/** Context passed to a custom `rowHeaderRenderer`, so it can label and style
|
|
81
|
-
* the row header from the row's data and status (group-key labels, an
|
|
82
|
-
* omit indicator, etc.). Return a node to use as the header's name, or a
|
|
83
|
-
* nullish value to fall back to the default (1-based row number). */
|
|
84
|
-
export interface RowHeaderRenderContext<T = any> {
|
|
85
|
-
/** Data-row index (stable under sort/filter). */
|
|
86
|
-
rowIndex: number;
|
|
87
|
-
/** Visible (display) row index. */
|
|
88
|
-
visibleIndex: number;
|
|
89
|
-
/** The row's data (base, overlaid with edits if present). */
|
|
90
|
-
row: T | undefined;
|
|
91
|
-
/** The row's status, if any. */
|
|
92
|
-
status: RowStatusValue | undefined;
|
|
93
|
-
/** Convenience: `status === TableElementStatus.DELETED`. */
|
|
94
|
-
isDeleted: boolean;
|
|
95
|
-
/** The default label (`"${rowIndex + 1}"`). */
|
|
96
|
-
defaultLabel: string;
|
|
58
|
+
export interface DataViewSharedProps<T = any>
|
|
59
|
+
extends FetchDataOptions, DataViewCoreProps<T> {
|
|
60
|
+
/** Configurable table actions shown in a selection-aware toolbar.
|
|
61
|
+
* When provided, the actions toolbar renders alongside the existing
|
|
62
|
+
* edit toolbar. Actions are filtered by the current selection cardinality. */
|
|
63
|
+
actions?: TableAction<T>[];
|
|
64
|
+
/** Available column/table filters shown in a filter bar.
|
|
65
|
+
* Filters can also be defined per-column via `ColumnSpec.filters`. */
|
|
66
|
+
filters?: TableFilter<T>[];
|
|
67
|
+
//enableSelection?: boolean;
|
|
97
68
|
}
|
|
98
69
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/** Proxy stored during a copy operation, enabling backend-mediated paste
|
|
105
|
-
* for lazy-loaded tables where not all data is available locally. */
|
|
106
|
-
export interface ClipboardProxy {
|
|
107
|
-
cardinality: RegionCardinality;
|
|
108
|
-
/** Source row indices (for row/cell copies) */
|
|
109
|
-
rowIndices?: number[];
|
|
110
|
-
/** Source column keys (for column/cell copies) */
|
|
111
|
-
columnKeys?: string[];
|
|
112
|
-
/** The plain text written to the clipboard, used to verify the proxy
|
|
113
|
-
* is still valid on paste (i.e., clipboard hasn't been overwritten). */
|
|
114
|
-
text: string;
|
|
70
|
+
export enum DataSheetDensity {
|
|
71
|
+
HIGH = "high",
|
|
72
|
+
MEDIUM = "medium",
|
|
73
|
+
LOW = "low",
|
|
115
74
|
}
|
|
116
75
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
columnWidthsIndex: Map<string, number>;
|
|
139
|
-
/** Active column/table filters. Keys are filter IDs, values carry the
|
|
140
|
-
* filter definition and its current configuration state. */
|
|
141
|
-
activeFilters: Map<string, { filter: any; state: any }>;
|
|
142
|
-
/** Clipboard proxy from the last copy operation */
|
|
143
|
-
clipboardProxy: ClipboardProxy | null;
|
|
144
|
-
/** Visible row indices when filters are active. `null` means show all rows. */
|
|
145
|
-
filteredRowIndices: number[] | null;
|
|
146
|
-
/** Active column sort entries for client-side sorting. */
|
|
147
|
-
columnSorts: ColumnSort[];
|
|
148
|
-
/** Whether selecting a cell automatically activates its surface (opens an
|
|
149
|
-
* editor/detail panel and, for editors, focuses it). `"manual"` opens only
|
|
150
|
-
* on click. */
|
|
151
|
-
cellInteraction: "auto" | "manual";
|
|
152
|
-
/** Runtime override of `cellInteraction`: while `false`, auto-activation is
|
|
153
|
-
* suppressed (set by pressing Escape, re-armed by clicking a cell) so the
|
|
154
|
-
* keyboard prioritizes navigation. */
|
|
155
|
-
autoActivateArmed: boolean;
|
|
156
|
-
/** Direction of the last keyboard navigation, used to place an editor's
|
|
157
|
-
* cursor on the side the user is travelling toward. `null` after a click. */
|
|
158
|
-
lastNavDirection: NavDirection | null;
|
|
159
|
-
/** The table's focusable holder element; editors return focus here when the
|
|
160
|
-
* cursor leaves them so arrow-key navigation resumes. */
|
|
161
|
-
tableElement: HTMLElement | null;
|
|
162
|
-
/** Whether the focused cell's surface (editor or detail panel) is open.
|
|
163
|
-
* Owned by the store — not per-popover — so navigation, clicks, and the
|
|
164
|
-
* Escape handler all agree on it. */
|
|
165
|
-
cellSurfaceOpen: boolean;
|
|
166
|
-
/** Optional observer called for every user edit as a structured
|
|
167
|
-
* `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a
|
|
168
|
-
* consumer capture edits as revertible operations. */
|
|
76
|
+
/**
|
|
77
|
+
* How selecting a cell activates its surface (an editor, or a read-only detail
|
|
78
|
+
* panel):
|
|
79
|
+
* - `"auto"` (default when `autoFocusEditor` is `true`): open the surface on
|
|
80
|
+
* selection and, for editors, focus it. Editors relinquish focus at their
|
|
81
|
+
* edges — arrow past the start/end of a text cell, or press Escape, and focus
|
|
82
|
+
* returns to the table — so the keyboard stays operable without the mouse.
|
|
83
|
+
* Pressing Escape drops into navigation mode (surfaces stop auto-opening)
|
|
84
|
+
* until the next click.
|
|
85
|
+
* - `"manual"` (default when `autoFocusEditor` is `false`): the surface stays
|
|
86
|
+
* closed until the cell is clicked; arrow keys always navigate the table.
|
|
87
|
+
*/
|
|
88
|
+
export type CellInteraction = "auto" | "manual";
|
|
89
|
+
|
|
90
|
+
export interface DataSheetRendererProps<T = any>
|
|
91
|
+
extends TableProps, DataViewSharedProps<T> {
|
|
92
|
+
onVisibleCellsChange?: (visibleCells: VisibleCells) => void;
|
|
93
|
+
onUpdateData?: (updatedData: any[], data: T[]) => void;
|
|
94
|
+
/** Observer called for every user edit as a structured `EditEvent`
|
|
95
|
+
* (Workstream A). Additive: the built-in `updatedData` overlay still
|
|
96
|
+
* applies. */
|
|
169
97
|
onEdit?: (event: EditEvent<T>) => void;
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
*
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/** Set or clear a column sort. Pass `null` for ascending to clear. */
|
|
225
|
-
setColumnSort(key: string, ascending: boolean | null): void;
|
|
226
|
-
/** Remove all active column sorts */
|
|
227
|
-
clearColumnSorts(): void;
|
|
228
|
-
/** Store a clipboard proxy for potential backend-mediated paste */
|
|
229
|
-
setClipboardProxy(proxy: ClipboardProxy | null): void;
|
|
230
|
-
initialize(props: Partial<DataSheetStoreMain<T>>): void;
|
|
231
|
-
onSelection(selection: Region[]): void;
|
|
232
|
-
// Internal method used for infinite scrolling
|
|
233
|
-
scrollToRow(rowIndex: number): void;
|
|
234
|
-
tableRef: React.MutableRefObject<Table2>;
|
|
235
|
-
columnWidthsIndex: Map<string, number>;
|
|
98
|
+
/** Controlled edited-cell overlay (Workstream A). When provided, it is
|
|
99
|
+
* synced into the store as the source of truth for edited values — pair with
|
|
100
|
+
* `onEdit` to own edit state externally (e.g. an ops model). Optimistic
|
|
101
|
+
* in-table edits are superseded by the next value you pass back. */
|
|
102
|
+
updatedData?: T[];
|
|
103
|
+
/** Controlled row-status overlay (edited / added / deleted), the companion
|
|
104
|
+
* to `updatedData`. */
|
|
105
|
+
rowStatus?: TableElementStatus[];
|
|
106
|
+
|
|
107
|
+
/** Derive the controlled edit overlay from the loaded rows, *inside* the
|
|
108
|
+
* sheet. For provider-backed tables whose overlay is a function of the loaded
|
|
109
|
+
* data plus external edit state (e.g. an ops stack): the library owns the
|
|
110
|
+
* rows, so it calls this with them and uses the result as the controlled
|
|
111
|
+
* overlay, re-deriving when the rows — or this function's identity (close it
|
|
112
|
+
* over your edit state) — change. Supersedes `updatedData`/`rowStatus`. */
|
|
113
|
+
deriveOverlay?: (rows: T[]) => {
|
|
114
|
+
updatedData: T[];
|
|
115
|
+
rowStatus: TableElementStatus[];
|
|
116
|
+
};
|
|
117
|
+
/** Persistence handler for the built-in Save action. When provided, a Save
|
|
118
|
+
* control is added to the toolbar (always visible, disabled when there are
|
|
119
|
+
* no pending changes). */
|
|
120
|
+
onSave?: (ctx: TableActionContext<T>) => void | Promise<void>;
|
|
121
|
+
onDeleteRows?: (selection: Region[]) => void;
|
|
122
|
+
verbose?: boolean;
|
|
123
|
+
enableColumnReordering?: boolean;
|
|
124
|
+
enableClipboard?: boolean;
|
|
125
|
+
enableFocusedCell?: boolean;
|
|
126
|
+
/** @deprecated Prefer `cellInteraction`. `true` maps to `"auto"`,
|
|
127
|
+
* `false` to `"manual"`. */
|
|
128
|
+
autoFocusEditor?: boolean;
|
|
129
|
+
/** How selecting a cell activates its surface (editor or detail panel).
|
|
130
|
+
* Defaults from `autoFocusEditor` for backward compatibility. */
|
|
131
|
+
cellInteraction?: CellInteraction;
|
|
132
|
+
density?: DataSheetDensity;
|
|
133
|
+
/** Optional custom column header cell renderer, called for each column.
|
|
134
|
+
* Receives the ColumnSpec and column index; should return a React element
|
|
135
|
+
* (typically a Blueprint ColumnHeaderCell). */
|
|
136
|
+
columnHeaderCellRenderer?: (col: any, colIndex: number) => ReactNode;
|
|
137
|
+
/** Arbitrary nodes for the bottom status bar (left group), rendered beside
|
|
138
|
+
* the active sort/filter tags — the home for view-state controls (show/hide
|
|
139
|
+
* omitted rows/columns, a group-by indicator, etc.). */
|
|
140
|
+
statusBar?: ReactNode;
|
|
141
|
+
/** Presentation per row-status value, merged over the built-in defaults
|
|
142
|
+
* (which style `"deleted"`). Supply styles for consumer-defined statuses
|
|
143
|
+
* (e.g. `"omitted"`) and/or override the defaults. Each entry may set the
|
|
144
|
+
* cells' style/intent and the row header's style. */
|
|
145
|
+
rowStatusStyles?: RowStatusStyles;
|
|
146
|
+
/** Render the content of a row's header cell (the left gutter). Receives the
|
|
147
|
+
* row, its status, and the default 1-based label; return a node to use, or a
|
|
148
|
+
* nullish value to keep the default. For group-key labels, omit indicators,
|
|
149
|
+
* etc. Header-cell *styling* still comes from `rowStatusStyles`. */
|
|
150
|
+
rowHeaderRenderer?: (ctx: RowHeaderRenderContext<T>) => ReactNode;
|
|
151
|
+
minRowHeight: number;
|
|
236
152
|
defaultColumnWidth: number;
|
|
153
|
+
debug: boolean;
|
|
237
154
|
}
|
|
238
155
|
|
|
239
|
-
export type
|
|
240
|
-
|
|
241
|
-
columnSpecOptions?: ColumnSpecOptions<T>;
|
|
242
|
-
toaster?: OverlayToaster;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export interface VisibleCells {
|
|
246
|
-
rowIndexStart: number;
|
|
247
|
-
rowIndexEnd: number;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export type DataSheetStore<T> = DataSheetStoreMain<T>;
|
|
156
|
+
export type DataSheetProps<T> = DataViewCoreProps<T> &
|
|
157
|
+
DataSheetRendererProps<T>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Getter, Setter, Atom, WritableAtom } from "jotai";
|
|
2
|
+
|
|
3
|
+
export function passThroughSet<V, Args extends unknown[], Result>(
|
|
4
|
+
atom: WritableAtom<V, Args, Result>,
|
|
5
|
+
) {
|
|
6
|
+
return (get: Getter, set: Setter, ...args: Args): Result =>
|
|
7
|
+
set(atom, ...args);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function passThroughGet<T>(atom: Atom<T>) {
|
|
11
|
+
return (get: Getter) => get(atom);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function splitProps<T, R extends Partial<T>>(
|
|
15
|
+
input: T,
|
|
16
|
+
keys: Set<keyof R>,
|
|
17
|
+
): [R, Omit<T, keyof R>] {
|
|
18
|
+
const requestedProps: Partial<T> = {};
|
|
19
|
+
const otherProps: Partial<T> = {};
|
|
20
|
+
for (const key in input) {
|
|
21
|
+
if (keys.has(key as keyof R)) {
|
|
22
|
+
requestedProps[key] = input[key];
|
|
23
|
+
} else {
|
|
24
|
+
otherProps[key] = input[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return [requestedProps as R, otherProps as Omit<T, keyof R>];
|
|
28
|
+
}
|
|
@@ -4,7 +4,7 @@ export function CellRendererDebugOverlay({ cellRendererDependencies, names }) {
|
|
|
4
4
|
/** Debug overlay for cell renderer dependencies */
|
|
5
5
|
const lastRenderDependencies = useRef<any[]>(cellRendererDependencies);
|
|
6
6
|
useEffect(() => {
|
|
7
|
-
let changeDepNames = [];
|
|
7
|
+
let changeDepNames: any[] = [];
|
|
8
8
|
for (const [i, dep] of cellRendererDependencies.entries()) {
|
|
9
9
|
if (dep !== lastRenderDependencies.current[i]) {
|
|
10
10
|
changeDepNames.push(names[i]);
|
package/src/utils/index.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export * from "./column-spec";
|
|
2
1
|
export * from "./key-handling";
|
|
3
2
|
export * from "./validation";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export function range(arr: number[]) {
|
|
7
|
-
if (arr.length != 2) throw new Error("Range must have two elements");
|
|
8
|
-
const [start, end] = arr;
|
|
9
|
-
return Array.from({ length: end - start + 1 }, (_, i) => i + start);
|
|
10
|
-
}
|
|
3
|
+
export * from "./debug-overlay.ts";
|
|
4
|
+
export * from "./atoms.ts";
|