@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/types.d.ts
CHANGED
|
@@ -1,235 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ascending: boolean;
|
|
1
|
+
import { EditEvent, FetchData, InteractionOptions, RowHeaderRenderContext, RowStatusStyles, TableDataProvider, TableElementStatus, VisibleCells, ColumnSpec, ColumnSpecOptions } from './provider';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { TableAction, TableActionContext, TableFilter } from './actions';
|
|
4
|
+
import { Region, TableProps } from '@blueprintjs/table';
|
|
5
|
+
export type FetchMode = "scroll" | "paged";
|
|
6
|
+
export interface FetchDataOptions {
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
fetchMode?: FetchMode;
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
export
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} | {
|
|
24
|
-
type: "deleteRows";
|
|
25
|
-
rowIndices: number[];
|
|
26
|
-
} | {
|
|
27
|
-
type: "restoreRows";
|
|
28
|
-
rowIndices: number[];
|
|
29
|
-
} | {
|
|
30
|
-
type: "addRow";
|
|
31
|
-
rowIndex: number;
|
|
32
|
-
value: Partial<T>;
|
|
33
|
-
} | {
|
|
34
|
-
type: "resetChanges";
|
|
35
|
-
};
|
|
36
|
-
export interface DataSheetCoreProps<T> {
|
|
37
|
-
data: T[];
|
|
38
|
-
columnSpec?: ColumnSpec[];
|
|
39
|
-
editable?: boolean;
|
|
10
|
+
/** Props shared between the wrapper components and the provider */
|
|
11
|
+
export interface DataViewCoreProps<T> extends InteractionOptions {
|
|
12
|
+
/** In-memory rows. Internally wrapped in a local `TableDataProvider` and
|
|
13
|
+
* driven through the same loader as any other source. */
|
|
14
|
+
data?: T[];
|
|
15
|
+
/** Column definitions. Either a static array, or a function derived from the
|
|
16
|
+
* loaded rows — invoked once the first rows arrive (and re-invoked when the
|
|
17
|
+
* function's identity changes), so a data-shaped spec needs no separate fetch
|
|
18
|
+
* of sample data. Omit entirely to auto-generate a plain spec via
|
|
19
|
+
* `columnSpecOptions`. */
|
|
20
|
+
columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);
|
|
21
|
+
columnSpecOptions?: ColumnSpecOptions<T>;
|
|
40
22
|
enableColumnReordering?: boolean;
|
|
41
23
|
defaultColumnWidth?: number;
|
|
24
|
+
fetchData?: FetchData<T>;
|
|
25
|
+
/** A data provider instantiated separately and passed in — bundles the read
|
|
26
|
+
* side (`fetchData` + `identity`) and, optionally, the persistence side
|
|
27
|
+
* (`saveRows` / `deleteRows` / `insertRow`) that drives the Save action. An
|
|
28
|
+
* explicit alternative to the loose `data` / `fetchData` / `identity` props;
|
|
29
|
+
* takes precedence when given. */
|
|
30
|
+
provider?: TableDataProvider<T>;
|
|
31
|
+
/** Row identity for the edit overlay — stable across a provider re-sort (a
|
|
32
|
+
* data provider supplies its own; defaults to `(row) => row?.id`). Lets edits
|
|
33
|
+
* survive a re-ordered re-fetch. */
|
|
34
|
+
identity?: (row: T) => string | number | null | undefined;
|
|
35
|
+
/** Shown as the toolbar's leading label when nothing is selected. */
|
|
36
|
+
name?: string;
|
|
37
|
+
itemLabel?: string;
|
|
38
|
+
/** Bump to force a re-fetch from scratch (e.g. after an immediate edit that
|
|
39
|
+
* mutated rows through the provider). */
|
|
40
|
+
refreshToken?: number | string;
|
|
42
41
|
}
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
export interface DataViewSharedProps<T = any> extends FetchDataOptions, DataViewCoreProps<T> {
|
|
43
|
+
/** Configurable table actions shown in a selection-aware toolbar.
|
|
44
|
+
* When provided, the actions toolbar renders alongside the existing
|
|
45
|
+
* edit toolbar. Actions are filtered by the current selection cardinality. */
|
|
46
|
+
actions?: TableAction<T>[];
|
|
47
|
+
/** Available column/table filters shown in a filter bar.
|
|
48
|
+
* Filters can also be defined per-column via `ColumnSpec.filters`. */
|
|
49
|
+
filters?: TableFilter<T>[];
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export type RowStatusValue = TableElementStatus | (string & {});
|
|
52
|
-
/** Presentation for a row status: applied to the row's cells and its header
|
|
53
|
-
* cell. Keyed by status value in `rowStatusStyles`. The library ships a
|
|
54
|
-
* default for `"deleted"` (dimmed + struck through, danger intent); consumers
|
|
55
|
-
* merge in styles for their own statuses (and may override the defaults). */
|
|
56
|
-
export interface RowStatusStyle {
|
|
57
|
-
/** Style merged onto each cell in a row with this status. */
|
|
58
|
-
cellStyle?: import('react').CSSProperties;
|
|
59
|
-
/** Style applied to the row's header cell. */
|
|
60
|
-
headerStyle?: import('react').CSSProperties;
|
|
61
|
-
/** Blueprint intent applied to the row's cells (precedence: validation >
|
|
62
|
-
* this > edited-green). */
|
|
63
|
-
intent?: import('@blueprintjs/core').Intent;
|
|
51
|
+
export declare enum DataSheetDensity {
|
|
52
|
+
HIGH = "high",
|
|
53
|
+
MEDIUM = "medium",
|
|
54
|
+
LOW = "low"
|
|
64
55
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/** The default label (`"${rowIndex + 1}"`). */
|
|
85
|
-
defaultLabel: string;
|
|
86
|
-
}
|
|
87
|
-
/** Property key holding a stable synthetic id on rows added in-table. Added
|
|
88
|
-
* rows aren't in the data provider, so they need their own identity to survive
|
|
89
|
-
* a provider re-fetch; it's carried on the row and preserved through edits. */
|
|
90
|
-
export declare const DS_ROW_ID = "__dsRowId";
|
|
91
|
-
/** Proxy stored during a copy operation, enabling backend-mediated paste
|
|
92
|
-
* for lazy-loaded tables where not all data is available locally. */
|
|
93
|
-
export interface ClipboardProxy {
|
|
94
|
-
cardinality: RegionCardinality;
|
|
95
|
-
/** Source row indices (for row/cell copies) */
|
|
96
|
-
rowIndices?: number[];
|
|
97
|
-
/** Source column keys (for column/cell copies) */
|
|
98
|
-
columnKeys?: string[];
|
|
99
|
-
/** The plain text written to the clipboard, used to verify the proxy
|
|
100
|
-
* is still valid on paste (i.e., clipboard hasn't been overwritten). */
|
|
101
|
-
text: string;
|
|
102
|
-
}
|
|
103
|
-
export interface DataSheetState<T> {
|
|
104
|
-
selection: Region[];
|
|
105
|
-
columnSpec: ColumnSpec[];
|
|
106
|
-
fillValueBaseCell: FocusedCellCoordinates | null;
|
|
107
|
-
focusedCell: FocusedCellCoordinates | null;
|
|
108
|
-
topLeftCell: FocusedCellCoordinates | null;
|
|
109
|
-
/**
|
|
110
|
-
* Set of row indices that have been added to the table,
|
|
111
|
-
* but not yet committed to the underlying data array.
|
|
112
|
-
*
|
|
113
|
-
* This is used to track which rows should be reverted when
|
|
114
|
-
* a "reset" action is performed.
|
|
115
|
-
*/
|
|
116
|
-
rowStatus: RowStatusValue[];
|
|
117
|
-
/** Presentation per row-status value (merged: defaults + the
|
|
118
|
-
* `rowStatusStyles` prop). Read by the cell renderer and row-header renderer
|
|
119
|
-
* to style rows by status. */
|
|
120
|
-
rowStatusStyles: RowStatusStyles;
|
|
121
|
-
updatedData: T[];
|
|
122
|
-
initialized: boolean;
|
|
123
|
-
columnWidthsIndex: Map<string, number>;
|
|
124
|
-
/** Active column/table filters. Keys are filter IDs, values carry the
|
|
125
|
-
* filter definition and its current configuration state. */
|
|
126
|
-
activeFilters: Map<string, {
|
|
127
|
-
filter: any;
|
|
128
|
-
state: any;
|
|
129
|
-
}>;
|
|
130
|
-
/** Clipboard proxy from the last copy operation */
|
|
131
|
-
clipboardProxy: ClipboardProxy | null;
|
|
132
|
-
/** Visible row indices when filters are active. `null` means show all rows. */
|
|
133
|
-
filteredRowIndices: number[] | null;
|
|
134
|
-
/** Active column sort entries for client-side sorting. */
|
|
135
|
-
columnSorts: ColumnSort[];
|
|
136
|
-
/** Whether selecting a cell automatically activates its surface (opens an
|
|
137
|
-
* editor/detail panel and, for editors, focuses it). `"manual"` opens only
|
|
138
|
-
* on click. */
|
|
139
|
-
cellInteraction: "auto" | "manual";
|
|
140
|
-
/** Runtime override of `cellInteraction`: while `false`, auto-activation is
|
|
141
|
-
* suppressed (set by pressing Escape, re-armed by clicking a cell) so the
|
|
142
|
-
* keyboard prioritizes navigation. */
|
|
143
|
-
autoActivateArmed: boolean;
|
|
144
|
-
/** Direction of the last keyboard navigation, used to place an editor's
|
|
145
|
-
* cursor on the side the user is travelling toward. `null` after a click. */
|
|
146
|
-
lastNavDirection: NavDirection | null;
|
|
147
|
-
/** The table's focusable holder element; editors return focus here when the
|
|
148
|
-
* cursor leaves them so arrow-key navigation resumes. */
|
|
149
|
-
tableElement: HTMLElement | null;
|
|
150
|
-
/** Whether the focused cell's surface (editor or detail panel) is open.
|
|
151
|
-
* Owned by the store — not per-popover — so navigation, clicks, and the
|
|
152
|
-
* Escape handler all agree on it. */
|
|
153
|
-
cellSurfaceOpen: boolean;
|
|
154
|
-
/** Optional observer called for every user edit as a structured
|
|
155
|
-
* `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a
|
|
156
|
-
* consumer capture edits as revertible operations. */
|
|
56
|
+
/**
|
|
57
|
+
* How selecting a cell activates its surface (an editor, or a read-only detail
|
|
58
|
+
* panel):
|
|
59
|
+
* - `"auto"` (default when `autoFocusEditor` is `true`): open the surface on
|
|
60
|
+
* selection and, for editors, focus it. Editors relinquish focus at their
|
|
61
|
+
* edges — arrow past the start/end of a text cell, or press Escape, and focus
|
|
62
|
+
* returns to the table — so the keyboard stays operable without the mouse.
|
|
63
|
+
* Pressing Escape drops into navigation mode (surfaces stop auto-opening)
|
|
64
|
+
* until the next click.
|
|
65
|
+
* - `"manual"` (default when `autoFocusEditor` is `false`): the surface stays
|
|
66
|
+
* closed until the cell is clicked; arrow keys always navigate the table.
|
|
67
|
+
*/
|
|
68
|
+
export type CellInteraction = "auto" | "manual";
|
|
69
|
+
export interface DataSheetRendererProps<T = any> extends TableProps, DataViewSharedProps<T> {
|
|
70
|
+
onVisibleCellsChange?: (visibleCells: VisibleCells) => void;
|
|
71
|
+
onUpdateData?: (updatedData: any[], data: T[]) => void;
|
|
72
|
+
/** Observer called for every user edit as a structured `EditEvent`
|
|
73
|
+
* (Workstream A). Additive: the built-in `updatedData` overlay still
|
|
74
|
+
* applies. */
|
|
157
75
|
onEdit?: (event: EditEvent<T>) => void;
|
|
158
|
-
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
clearFilters(): void;
|
|
212
|
-
/** Set or clear a column sort. Pass `null` for ascending to clear. */
|
|
213
|
-
setColumnSort(key: string, ascending: boolean | null): void;
|
|
214
|
-
/** Remove all active column sorts */
|
|
215
|
-
clearColumnSorts(): void;
|
|
216
|
-
/** Store a clipboard proxy for potential backend-mediated paste */
|
|
217
|
-
setClipboardProxy(proxy: ClipboardProxy | null): void;
|
|
218
|
-
initialize(props: Partial<DataSheetStoreMain<T>>): void;
|
|
219
|
-
onSelection(selection: Region[]): void;
|
|
220
|
-
scrollToRow(rowIndex: number): void;
|
|
221
|
-
tableRef: React.MutableRefObject<Table2>;
|
|
222
|
-
columnWidthsIndex: Map<string, number>;
|
|
76
|
+
/** Controlled edited-cell overlay (Workstream A). When provided, it is
|
|
77
|
+
* synced into the store as the source of truth for edited values — pair with
|
|
78
|
+
* `onEdit` to own edit state externally (e.g. an ops model). Optimistic
|
|
79
|
+
* in-table edits are superseded by the next value you pass back. */
|
|
80
|
+
updatedData?: T[];
|
|
81
|
+
/** Controlled row-status overlay (edited / added / deleted), the companion
|
|
82
|
+
* to `updatedData`. */
|
|
83
|
+
rowStatus?: TableElementStatus[];
|
|
84
|
+
/** Derive the controlled edit overlay from the loaded rows, *inside* the
|
|
85
|
+
* sheet. For provider-backed tables whose overlay is a function of the loaded
|
|
86
|
+
* data plus external edit state (e.g. an ops stack): the library owns the
|
|
87
|
+
* rows, so it calls this with them and uses the result as the controlled
|
|
88
|
+
* overlay, re-deriving when the rows — or this function's identity (close it
|
|
89
|
+
* over your edit state) — change. Supersedes `updatedData`/`rowStatus`. */
|
|
90
|
+
deriveOverlay?: (rows: T[]) => {
|
|
91
|
+
updatedData: T[];
|
|
92
|
+
rowStatus: TableElementStatus[];
|
|
93
|
+
};
|
|
94
|
+
/** Persistence handler for the built-in Save action. When provided, a Save
|
|
95
|
+
* control is added to the toolbar (always visible, disabled when there are
|
|
96
|
+
* no pending changes). */
|
|
97
|
+
onSave?: (ctx: TableActionContext<T>) => void | Promise<void>;
|
|
98
|
+
onDeleteRows?: (selection: Region[]) => void;
|
|
99
|
+
verbose?: boolean;
|
|
100
|
+
enableColumnReordering?: boolean;
|
|
101
|
+
enableClipboard?: boolean;
|
|
102
|
+
enableFocusedCell?: boolean;
|
|
103
|
+
/** @deprecated Prefer `cellInteraction`. `true` maps to `"auto"`,
|
|
104
|
+
* `false` to `"manual"`. */
|
|
105
|
+
autoFocusEditor?: boolean;
|
|
106
|
+
/** How selecting a cell activates its surface (editor or detail panel).
|
|
107
|
+
* Defaults from `autoFocusEditor` for backward compatibility. */
|
|
108
|
+
cellInteraction?: CellInteraction;
|
|
109
|
+
density?: DataSheetDensity;
|
|
110
|
+
/** Optional custom column header cell renderer, called for each column.
|
|
111
|
+
* Receives the ColumnSpec and column index; should return a React element
|
|
112
|
+
* (typically a Blueprint ColumnHeaderCell). */
|
|
113
|
+
columnHeaderCellRenderer?: (col: any, colIndex: number) => ReactNode;
|
|
114
|
+
/** Arbitrary nodes for the bottom status bar (left group), rendered beside
|
|
115
|
+
* the active sort/filter tags — the home for view-state controls (show/hide
|
|
116
|
+
* omitted rows/columns, a group-by indicator, etc.). */
|
|
117
|
+
statusBar?: ReactNode;
|
|
118
|
+
/** Presentation per row-status value, merged over the built-in defaults
|
|
119
|
+
* (which style `"deleted"`). Supply styles for consumer-defined statuses
|
|
120
|
+
* (e.g. `"omitted"`) and/or override the defaults. Each entry may set the
|
|
121
|
+
* cells' style/intent and the row header's style. */
|
|
122
|
+
rowStatusStyles?: RowStatusStyles;
|
|
123
|
+
/** Render the content of a row's header cell (the left gutter). Receives the
|
|
124
|
+
* row, its status, and the default 1-based label; return a node to use, or a
|
|
125
|
+
* nullish value to keep the default. For group-key labels, omit indicators,
|
|
126
|
+
* etc. Header-cell *styling* still comes from `rowStatusStyles`. */
|
|
127
|
+
rowHeaderRenderer?: (ctx: RowHeaderRenderContext<T>) => ReactNode;
|
|
128
|
+
minRowHeight: number;
|
|
223
129
|
defaultColumnWidth: number;
|
|
130
|
+
debug: boolean;
|
|
224
131
|
}
|
|
225
|
-
export type
|
|
226
|
-
children: React.ReactNode;
|
|
227
|
-
columnSpecOptions?: ColumnSpecOptions<T>;
|
|
228
|
-
toaster?: OverlayToaster;
|
|
229
|
-
};
|
|
230
|
-
export interface VisibleCells {
|
|
231
|
-
rowIndexStart: number;
|
|
232
|
-
rowIndexEnd: number;
|
|
233
|
-
}
|
|
234
|
-
export type DataSheetStore<T> = DataSheetStoreMain<T>;
|
|
235
|
-
export {};
|
|
132
|
+
export type DataSheetProps<T> = DataViewCoreProps<T> & DataSheetRendererProps<T>;
|
package/dist/types.js
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
"deleted"
|
|
9
|
-
/* DELETED */
|
|
10
|
-
]: {
|
|
11
|
-
cellStyle: { opacity: 0.5, textDecoration: "line-through" },
|
|
12
|
-
headerStyle: { opacity: 0.5, textDecoration: "line-through" },
|
|
13
|
-
intent: "danger"
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const DS_ROW_ID = "__dsRowId";
|
|
1
|
+
var DataSheetDensity = /* @__PURE__ */ ((DataSheetDensity2) => {
|
|
2
|
+
DataSheetDensity2["HIGH"] = "high";
|
|
3
|
+
DataSheetDensity2["MEDIUM"] = "medium";
|
|
4
|
+
DataSheetDensity2["LOW"] = "low";
|
|
5
|
+
return DataSheetDensity2;
|
|
6
|
+
})(DataSheetDensity || {});
|
|
17
7
|
export {
|
|
18
|
-
|
|
19
|
-
DS_ROW_ID,
|
|
20
|
-
TableElementStatus
|
|
8
|
+
DataSheetDensity
|
|
21
9
|
};
|
|
22
10
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n FocusedCellCoordinates,\n Region,\n RegionCardinality,\n Table2,\n} from \"@blueprintjs/table\";\nimport { ColumnSpec, ColumnSpecOptions } from \"./utils\";\nimport { OverlayToaster } from \"@blueprintjs/core\";\nimport type { CellEdit } from \"./actions\";\n\n/** A single column sort entry for client-side sorting.\n * Defined here (rather than in actions/types) to avoid circular imports. */\nexport interface ColumnSort {\n key: string;\n ascending: boolean;\n}\n\n/** Direction of keyboard navigation between cells. */\nexport type NavDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/**\n * A structured, revertible description of a user edit. Emitted via the\n * `onEdit` hook so a consumer can capture edits as operations (and, with the\n * controlled-overlay API, own the edited state) instead of diffing\n * `updatedData`. This is the write half of the data-sheet's read/write\n * contract — the mirror of how data flows in.\n */\nexport type EditEvent<T = any> =\n | { type: \"setCells\"; cells: CellEdit[] }\n | { type: \"deleteRows\"; rowIndices: number[] }\n | { type: \"restoreRows\"; rowIndices: number[] }\n | { type: \"addRow\"; rowIndex: number; value: Partial<T> }\n | { type: \"resetChanges\" };\n\nexport interface DataSheetCoreProps<T> {\n data: T[];\n columnSpec?: ColumnSpec[];\n editable?: boolean;\n enableColumnReordering?: boolean;\n defaultColumnWidth?: number;\n}\n\nexport enum TableElementStatus {\n DELETED = \"deleted\",\n ADDED = \"added\",\n}\n\n/** A row's status value. The built-in `TableElementStatus` members\n * (`\"deleted\"` / `\"added\"`) plus any consumer-defined status string (e.g.\n * `\"omitted\"`). The `(string & {})` keeps autocomplete for the enum members\n * while still accepting arbitrary strings. */\nexport type RowStatusValue = TableElementStatus | (string & {});\n\n/** Presentation for a row status: applied to the row's cells and its header\n * cell. Keyed by status value in `rowStatusStyles`. The library ships a\n * default for `\"deleted\"` (dimmed + struck through, danger intent); consumers\n * merge in styles for their own statuses (and may override the defaults). */\nexport interface RowStatusStyle {\n /** Style merged onto each cell in a row with this status. */\n cellStyle?: import(\"react\").CSSProperties;\n /** Style applied to the row's header cell. */\n headerStyle?: import(\"react\").CSSProperties;\n /** Blueprint intent applied to the row's cells (precedence: validation >\n * this > edited-green). */\n intent?: import(\"@blueprintjs/core\").Intent;\n}\n\nexport type RowStatusStyles = Record<string, RowStatusStyle>;\n\n/** Built-in row-status presentation. Consumers' `rowStatusStyles` are merged\n * over this, so `\"deleted\"` keeps its look unless explicitly overridden. */\nexport const DEFAULT_ROW_STATUS_STYLES: RowStatusStyles = {\n [TableElementStatus.DELETED]: {\n cellStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n headerStyle: { opacity: 0.5, textDecoration: \"line-through\" },\n intent: \"danger\",\n },\n};\n\n/** Context passed to a custom `rowHeaderRenderer`, so it can label and style\n * the row header from the row's data and status (group-key labels, an\n * omit indicator, etc.). Return a node to use as the header's name, or a\n * nullish value to fall back to the default (1-based row number). */\nexport interface RowHeaderRenderContext<T = any> {\n /** Data-row index (stable under sort/filter). */\n rowIndex: number;\n /** Visible (display) row index. */\n visibleIndex: number;\n /** The row's data (base, overlaid with edits if present). */\n row: T | undefined;\n /** The row's status, if any. */\n status: RowStatusValue | undefined;\n /** Convenience: `status === TableElementStatus.DELETED`. */\n isDeleted: boolean;\n /** The default label (`\"${rowIndex + 1}\"`). */\n defaultLabel: string;\n}\n\n/** Property key holding a stable synthetic id on rows added in-table. Added\n * rows aren't in the data provider, so they need their own identity to survive\n * a provider re-fetch; it's carried on the row and preserved through edits. */\nexport const DS_ROW_ID = \"__dsRowId\";\n\n/** Proxy stored during a copy operation, enabling backend-mediated paste\n * for lazy-loaded tables where not all data is available locally. */\nexport interface ClipboardProxy {\n cardinality: RegionCardinality;\n /** Source row indices (for row/cell copies) */\n rowIndices?: number[];\n /** Source column keys (for column/cell copies) */\n columnKeys?: string[];\n /** The plain text written to the clipboard, used to verify the proxy\n * is still valid on paste (i.e., clipboard hasn't been overwritten). */\n text: string;\n}\n\nexport interface DataSheetState<T> {\n selection: Region[];\n columnSpec: ColumnSpec[];\n fillValueBaseCell: FocusedCellCoordinates | null;\n focusedCell: FocusedCellCoordinates | null;\n topLeftCell: FocusedCellCoordinates | null;\n /**\n * Set of row indices that have been added to the table,\n * but not yet committed to the underlying data array.\n *\n * This is used to track which rows should be reverted when\n * a \"reset\" action is performed.\n */\n rowStatus: RowStatusValue[];\n /** Presentation per row-status value (merged: defaults + the\n * `rowStatusStyles` prop). Read by the cell renderer and row-header renderer\n * to style rows by status. */\n rowStatusStyles: RowStatusStyles;\n // Sparse data structure for updated data\n updatedData: T[];\n initialized: boolean;\n columnWidthsIndex: Map<string, number>;\n /** Active column/table filters. Keys are filter IDs, values carry the\n * filter definition and its current configuration state. */\n activeFilters: Map<string, { filter: any; state: any }>;\n /** Clipboard proxy from the last copy operation */\n clipboardProxy: ClipboardProxy | null;\n /** Visible row indices when filters are active. `null` means show all rows. */\n filteredRowIndices: number[] | null;\n /** Active column sort entries for client-side sorting. */\n columnSorts: ColumnSort[];\n /** Whether selecting a cell automatically activates its surface (opens an\n * editor/detail panel and, for editors, focuses it). `\"manual\"` opens only\n * on click. */\n cellInteraction: \"auto\" | \"manual\";\n /** Runtime override of `cellInteraction`: while `false`, auto-activation is\n * suppressed (set by pressing Escape, re-armed by clicking a cell) so the\n * keyboard prioritizes navigation. */\n autoActivateArmed: boolean;\n /** Direction of the last keyboard navigation, used to place an editor's\n * cursor on the side the user is travelling toward. `null` after a click. */\n lastNavDirection: NavDirection | null;\n /** The table's focusable holder element; editors return focus here when the\n * cursor leaves them so arrow-key navigation resumes. */\n tableElement: HTMLElement | null;\n /** Whether the focused cell's surface (editor or detail panel) is open.\n * Owned by the store — not per-popover — so navigation, clicks, and the\n * Escape handler all agree on it. */\n cellSurfaceOpen: boolean;\n /** Optional observer called for every user edit as a structured\n * `EditEvent`, in addition to the built-in `updatedData` overlay. Lets a\n * consumer capture edits as revertible operations. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Row identity for the edit overlay — stable across a provider re-sort,\n * unlike an array index. Defaults to `(row) => row?.id`; a data provider\n * supplies its own (e.g. a PostgREST identity key). Used to re-attach edits\n * when the loader replaces `data` with a re-ordered window. */\n identity: (row: any) => string | number | null | undefined;\n /** Edits/statuses held by identity for rows not currently loaded (server\n * sources), re-attached when their row next arrives. */\n pendingOverlayById: Map<\n string | number,\n { edit?: any; status?: TableElementStatus }\n >;\n /** True when the consumer controls the `updatedData`/`rowStatus` overlay; the\n * loader-boundary identity remap is skipped (the consumer owns it). */\n controlledOverlay: boolean;\n /** Whether row deletion is available. Set from the data provider: an explicit\n * `provider` without `deleteRows` disables deletion entirely (the delete\n * affordance greys out and the delete key is a no-op). Defaults to `true`. */\n canDeleteRows: boolean;\n}\n\ntype DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;\nexport type StateUpdater<T> = T[] | ((state: T[]) => T[]);\n\nexport interface DataSheetStoreMain<T> extends DataSheetVals<T> {\n setSelection(selection: Region[]): void;\n onDragValue(event: MouseEvent): void;\n setUpdatedData(data: StateUpdater<T>): void;\n onCellEdited(rowIndex: number, columnName: string, value: any): void;\n onSelectionEdited(value: any): void;\n onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;\n onColumnWidthChanged(columnIndex: number, newWidth: number): void;\n moveFocusedCell(direction: NavDirection): void;\n /** Suppress auto-activation until the next click (Escape enters nav mode). */\n suppressAutoActivate(): void;\n /** Re-arm auto-activation (a click re-enables auto-focus). */\n armAutoActivate(): void;\n /** Open the focused cell's surface (editor or detail panel). */\n openCellSurface(): void;\n /** Close the focused cell's surface. When `suppress` is true (the default,\n * as for Escape), auto mode also enters navigation mode (auto-activation is\n * suppressed until the next click). A click-dismiss passes `suppress: false`\n * so it just closes without changing the global mode. */\n closeCellSurface(opts?: { suppress?: boolean }): void;\n deleteSelectedRows(): void;\n clearSelection(): void;\n resetChanges(): void;\n addRow(): void;\n /** Activate or update a column/table filter.\n * Filter is any object satisfying `TableFilter` from the actions module. */\n setFilter(filterId: string, filter: any, filterState: any): void;\n /** Remove a filter by ID */\n removeFilter(filterId: string): void;\n /** Remove all active filters */\n clearFilters(): void;\n /** Set or clear a column sort. Pass `null` for ascending to clear. */\n setColumnSort(key: string, ascending: boolean | null): void;\n /** Remove all active column sorts */\n clearColumnSorts(): void;\n /** Store a clipboard proxy for potential backend-mediated paste */\n setClipboardProxy(proxy: ClipboardProxy | null): void;\n initialize(props: Partial<DataSheetStoreMain<T>>): void;\n onSelection(selection: Region[]): void;\n // Internal method used for infinite scrolling\n scrollToRow(rowIndex: number): void;\n tableRef: React.MutableRefObject<Table2>;\n columnWidthsIndex: Map<string, number>;\n defaultColumnWidth: number;\n}\n\nexport type DataSheetProviderProps<T> = DataSheetCoreProps<T> & {\n children: React.ReactNode;\n columnSpecOptions?: ColumnSpecOptions<T>;\n toaster?: OverlayToaster;\n};\n\nexport interface VisibleCells {\n rowIndexStart: number;\n rowIndexEnd: number;\n}\n\nexport type DataSheetStore<T> = DataSheetStoreMain<T>;\n"],"names":["TableElementStatus"],"mappings":"AA0CO,IAAK,uCAAAA,wBAAL;AACLA,sBAAA,SAAA,IAAU;AACVA,sBAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AA6BL,MAAM,4BAA6C;AAAA,EACxD;AAAA,IAAC;AAAA;AAAA,KAA6B;AAAA,IAC5B,WAAW,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC3C,aAAa,EAAE,SAAS,KAAK,gBAAgB,eAAA;AAAA,IAC7C,QAAQ;AAAA,EAAA;AAEZ;AAwBO,MAAM,YAAY;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import {\n EditEvent,\n FetchData,\n InteractionOptions,\n RowHeaderRenderContext,\n RowStatusStyles,\n TableDataProvider,\n TableElementStatus,\n VisibleCells,\n} from \"./provider\";\nimport type { ColumnSpec, ColumnSpecOptions } from \"./provider\";\nimport { ReactNode } from \"react\";\nimport { TableAction, TableActionContext, TableFilter } from \"./actions\";\nimport { Region, TableProps } from \"@blueprintjs/table\";\n\nexport type FetchMode = \"scroll\" | \"paged\";\n\nexport interface FetchDataOptions {\n pageSize?: number;\n fetchMode?: FetchMode;\n}\n\n/** Props shared between the wrapper components and the provider */\nexport interface DataViewCoreProps<T> extends InteractionOptions {\n /** In-memory rows. Internally wrapped in a local `TableDataProvider` and\n * driven through the same loader as any other source. */\n data?: T[];\n /** Column definitions. Either a static array, or a function derived from the\n * loaded rows — invoked once the first rows arrive (and re-invoked when the\n * function's identity changes), so a data-shaped spec needs no separate fetch\n * of sample data. Omit entirely to auto-generate a plain spec via\n * `columnSpecOptions`. */\n columnSpec?: ColumnSpec[] | ((rows: T[]) => ColumnSpec[]);\n columnSpecOptions?: ColumnSpecOptions<T>;\n enableColumnReordering?: boolean;\n defaultColumnWidth?: number;\n // function to fetch a chunk of data (the read side of a data provider)\n fetchData?: FetchData<T>;\n /** A data provider instantiated separately and passed in — bundles the read\n * side (`fetchData` + `identity`) and, optionally, the persistence side\n * (`saveRows` / `deleteRows` / `insertRow`) that drives the Save action. An\n * explicit alternative to the loose `data` / `fetchData` / `identity` props;\n * takes precedence when given. */\n provider?: TableDataProvider<T>;\n /** Row identity for the edit overlay — stable across a provider re-sort (a\n * data provider supplies its own; defaults to `(row) => row?.id`). Lets edits\n * survive a re-ordered re-fetch. */\n identity?: (row: T) => string | number | null | undefined;\n /** Shown as the toolbar's leading label when nothing is selected. */\n name?: string;\n // itemLabel (e.g., \"row\", \"item\")\n itemLabel?: string;\n /** Bump to force a re-fetch from scratch (e.g. after an immediate edit that\n * mutated rows through the provider). */\n refreshToken?: number | string;\n}\n\nexport interface DataViewSharedProps<T = any>\n extends FetchDataOptions, DataViewCoreProps<T> {\n /** Configurable table actions shown in a selection-aware toolbar.\n * When provided, the actions toolbar renders alongside the existing\n * edit toolbar. Actions are filtered by the current selection cardinality. */\n actions?: TableAction<T>[];\n /** Available column/table filters shown in a filter bar.\n * Filters can also be defined per-column via `ColumnSpec.filters`. */\n filters?: TableFilter<T>[];\n //enableSelection?: boolean;\n}\n\nexport enum DataSheetDensity {\n HIGH = \"high\",\n MEDIUM = \"medium\",\n LOW = \"low\",\n}\n\n/**\n * How selecting a cell activates its surface (an editor, or a read-only detail\n * panel):\n * - `\"auto\"` (default when `autoFocusEditor` is `true`): open the surface on\n * selection and, for editors, focus it. Editors relinquish focus at their\n * edges — arrow past the start/end of a text cell, or press Escape, and focus\n * returns to the table — so the keyboard stays operable without the mouse.\n * Pressing Escape drops into navigation mode (surfaces stop auto-opening)\n * until the next click.\n * - `\"manual\"` (default when `autoFocusEditor` is `false`): the surface stays\n * closed until the cell is clicked; arrow keys always navigate the table.\n */\nexport type CellInteraction = \"auto\" | \"manual\";\n\nexport interface DataSheetRendererProps<T = any>\n extends TableProps, DataViewSharedProps<T> {\n onVisibleCellsChange?: (visibleCells: VisibleCells) => void;\n onUpdateData?: (updatedData: any[], data: T[]) => void;\n /** Observer called for every user edit as a structured `EditEvent`\n * (Workstream A). Additive: the built-in `updatedData` overlay still\n * applies. */\n onEdit?: (event: EditEvent<T>) => void;\n /** Controlled edited-cell overlay (Workstream A). When provided, it is\n * synced into the store as the source of truth for edited values — pair with\n * `onEdit` to own edit state externally (e.g. an ops model). Optimistic\n * in-table edits are superseded by the next value you pass back. */\n updatedData?: T[];\n /** Controlled row-status overlay (edited / added / deleted), the companion\n * to `updatedData`. */\n rowStatus?: TableElementStatus[];\n\n /** Derive the controlled edit overlay from the loaded rows, *inside* the\n * sheet. For provider-backed tables whose overlay is a function of the loaded\n * data plus external edit state (e.g. an ops stack): the library owns the\n * rows, so it calls this with them and uses the result as the controlled\n * overlay, re-deriving when the rows — or this function's identity (close it\n * over your edit state) — change. Supersedes `updatedData`/`rowStatus`. */\n deriveOverlay?: (rows: T[]) => {\n updatedData: T[];\n rowStatus: TableElementStatus[];\n };\n /** Persistence handler for the built-in Save action. When provided, a Save\n * control is added to the toolbar (always visible, disabled when there are\n * no pending changes). */\n onSave?: (ctx: TableActionContext<T>) => void | Promise<void>;\n onDeleteRows?: (selection: Region[]) => void;\n verbose?: boolean;\n enableColumnReordering?: boolean;\n enableClipboard?: boolean;\n enableFocusedCell?: boolean;\n /** @deprecated Prefer `cellInteraction`. `true` maps to `\"auto\"`,\n * `false` to `\"manual\"`. */\n autoFocusEditor?: boolean;\n /** How selecting a cell activates its surface (editor or detail panel).\n * Defaults from `autoFocusEditor` for backward compatibility. */\n cellInteraction?: CellInteraction;\n density?: DataSheetDensity;\n /** Optional custom column header cell renderer, called for each column.\n * Receives the ColumnSpec and column index; should return a React element\n * (typically a Blueprint ColumnHeaderCell). */\n columnHeaderCellRenderer?: (col: any, colIndex: number) => ReactNode;\n /** Arbitrary nodes for the bottom status bar (left group), rendered beside\n * the active sort/filter tags — the home for view-state controls (show/hide\n * omitted rows/columns, a group-by indicator, etc.). */\n statusBar?: ReactNode;\n /** Presentation per row-status value, merged over the built-in defaults\n * (which style `\"deleted\"`). Supply styles for consumer-defined statuses\n * (e.g. `\"omitted\"`) and/or override the defaults. Each entry may set the\n * cells' style/intent and the row header's style. */\n rowStatusStyles?: RowStatusStyles;\n /** Render the content of a row's header cell (the left gutter). Receives the\n * row, its status, and the default 1-based label; return a node to use, or a\n * nullish value to keep the default. For group-key labels, omit indicators,\n * etc. Header-cell *styling* still comes from `rowStatusStyles`. */\n rowHeaderRenderer?: (ctx: RowHeaderRenderContext<T>) => ReactNode;\n minRowHeight: number;\n defaultColumnWidth: number;\n debug: boolean;\n}\n\nexport type DataSheetProps<T> = DataViewCoreProps<T> &\n DataSheetRendererProps<T>;\n"],"names":["DataSheetDensity"],"mappings":"AAqEO,IAAK,qCAAAA,sBAAL;AACLA,oBAAA,MAAA,IAAO;AACPA,oBAAA,QAAA,IAAS;AACTA,oBAAA,KAAA,IAAM;AAHI,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function passThroughSet(atom) {
|
|
4
|
+
return (get, set, ...args) => set(atom, ...args);
|
|
5
|
+
}
|
|
6
|
+
function passThroughGet(atom) {
|
|
7
|
+
return (get) => get(atom);
|
|
8
|
+
}
|
|
9
|
+
function splitProps(input, keys) {
|
|
10
|
+
const requestedProps = {};
|
|
11
|
+
const otherProps = {};
|
|
12
|
+
for (const key in input) {
|
|
13
|
+
if (keys.has(key)) {
|
|
14
|
+
requestedProps[key] = input[key];
|
|
15
|
+
} else {
|
|
16
|
+
otherProps[key] = input[key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return [requestedProps, otherProps];
|
|
20
|
+
}
|
|
21
|
+
exports.passThroughGet = passThroughGet;
|
|
22
|
+
exports.passThroughSet = passThroughSet;
|
|
23
|
+
exports.splitProps = splitProps;
|
|
24
|
+
//# sourceMappingURL=atoms.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atoms.cjs","sources":["../../src/utils/atoms.ts"],"sourcesContent":["import type { Getter, Setter, Atom, WritableAtom } from \"jotai\";\n\nexport function passThroughSet<V, Args extends unknown[], Result>(\n atom: WritableAtom<V, Args, Result>,\n) {\n return (get: Getter, set: Setter, ...args: Args): Result =>\n set(atom, ...args);\n}\n\nexport function passThroughGet<T>(atom: Atom<T>) {\n return (get: Getter) => get(atom);\n}\n\nexport function splitProps<T, R extends Partial<T>>(\n input: T,\n keys: Set<keyof R>,\n): [R, Omit<T, keyof R>] {\n const requestedProps: Partial<T> = {};\n const otherProps: Partial<T> = {};\n for (const key in input) {\n if (keys.has(key as keyof R)) {\n requestedProps[key] = input[key];\n } else {\n otherProps[key] = input[key];\n }\n }\n return [requestedProps as R, otherProps as Omit<T, keyof R>];\n}\n"],"names":[],"mappings":";;AAEO,SAAS,eACd,MACA;AACA,SAAO,CAAC,KAAa,QAAgB,SACnC,IAAI,MAAM,GAAG,IAAI;AACrB;AAEO,SAAS,eAAkB,MAAe;AAC/C,SAAO,CAAC,QAAgB,IAAI,IAAI;AAClC;AAEO,SAAS,WACd,OACA,MACuB;AACvB,QAAM,iBAA6B,CAAA;AACnC,QAAM,aAAyB,CAAA;AAC/B,aAAW,OAAO,OAAO;AACvB,QAAI,KAAK,IAAI,GAAc,GAAG;AAC5B,qBAAe,GAAG,IAAI,MAAM,GAAG;AAAA,IACjC,OAAO;AACL,iBAAW,GAAG,IAAI,MAAM,GAAG;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,CAAC,gBAAqB,UAA8B;AAC7D;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Getter, Setter, Atom, WritableAtom } from 'jotai';
|
|
2
|
+
export declare function passThroughSet<V, Args extends unknown[], Result>(atom: WritableAtom<V, Args, Result>): (get: Getter, set: Setter, ...args: Args) => Result;
|
|
3
|
+
export declare function passThroughGet<T>(atom: Atom<T>): (get: Getter) => T;
|
|
4
|
+
export declare function splitProps<T, R extends Partial<T>>(input: T, keys: Set<keyof R>): [R, Omit<T, keyof R>];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function passThroughSet(atom) {
|
|
2
|
+
return (get, set, ...args) => set(atom, ...args);
|
|
3
|
+
}
|
|
4
|
+
function passThroughGet(atom) {
|
|
5
|
+
return (get) => get(atom);
|
|
6
|
+
}
|
|
7
|
+
function splitProps(input, keys) {
|
|
8
|
+
const requestedProps = {};
|
|
9
|
+
const otherProps = {};
|
|
10
|
+
for (const key in input) {
|
|
11
|
+
if (keys.has(key)) {
|
|
12
|
+
requestedProps[key] = input[key];
|
|
13
|
+
} else {
|
|
14
|
+
otherProps[key] = input[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return [requestedProps, otherProps];
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
passThroughGet,
|
|
21
|
+
passThroughSet,
|
|
22
|
+
splitProps
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=atoms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atoms.js","sources":["../../src/utils/atoms.ts"],"sourcesContent":["import type { Getter, Setter, Atom, WritableAtom } from \"jotai\";\n\nexport function passThroughSet<V, Args extends unknown[], Result>(\n atom: WritableAtom<V, Args, Result>,\n) {\n return (get: Getter, set: Setter, ...args: Args): Result =>\n set(atom, ...args);\n}\n\nexport function passThroughGet<T>(atom: Atom<T>) {\n return (get: Getter) => get(atom);\n}\n\nexport function splitProps<T, R extends Partial<T>>(\n input: T,\n keys: Set<keyof R>,\n): [R, Omit<T, keyof R>] {\n const requestedProps: Partial<T> = {};\n const otherProps: Partial<T> = {};\n for (const key in input) {\n if (keys.has(key as keyof R)) {\n requestedProps[key] = input[key];\n } else {\n otherProps[key] = input[key];\n }\n }\n return [requestedProps as R, otherProps as Omit<T, keyof R>];\n}\n"],"names":[],"mappings":"AAEO,SAAS,eACd,MACA;AACA,SAAO,CAAC,KAAa,QAAgB,SACnC,IAAI,MAAM,GAAG,IAAI;AACrB;AAEO,SAAS,eAAkB,MAAe;AAC/C,SAAO,CAAC,QAAgB,IAAI,IAAI;AAClC;AAEO,SAAS,WACd,OACA,MACuB;AACvB,QAAM,iBAA6B,CAAA;AACnC,QAAM,aAAyB,CAAA;AAC/B,aAAW,OAAO,OAAO;AACvB,QAAI,KAAK,IAAI,GAAc,GAAG;AAC5B,qBAAe,GAAG,IAAI,MAAM,GAAG;AAAA,IACjC,OAAO;AACL,iBAAW,GAAG,IAAI,MAAM,GAAG;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,CAAC,gBAAqB,UAA8B;AAC7D;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-overlay.cjs","sources":["../../src/utils/debug-overlay.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport function CellRendererDebugOverlay({ cellRendererDependencies, names }) {\n /** Debug overlay for cell renderer dependencies */\n const lastRenderDependencies = useRef<any[]>(cellRendererDependencies);\n useEffect(() => {\n let changeDepNames = [];\n for (const [i, dep] of cellRendererDependencies.entries()) {\n if (dep !== lastRenderDependencies.current[i]) {\n changeDepNames.push(names[i]);\n }\n }\n if (changeDepNames.length > 0) {\n console.log(\n \"Cell renderer dependencies changed:\",\n changeDepNames.join(\", \"),\n );\n }\n lastRenderDependencies.current = cellRendererDependencies;\n }, cellRendererDependencies);\n return null;\n}\n"],"names":["useRef","useEffect"],"mappings":";;;AAEO,SAAS,yBAAyB,EAAE,0BAA0B,SAAS;AAE5E,QAAM,yBAAyBA,MAAAA,OAAc,wBAAwB;AACrEC,QAAAA,UAAU,MAAM;AACd,QAAI,
|
|
1
|
+
{"version":3,"file":"debug-overlay.cjs","sources":["../../src/utils/debug-overlay.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport function CellRendererDebugOverlay({ cellRendererDependencies, names }) {\n /** Debug overlay for cell renderer dependencies */\n const lastRenderDependencies = useRef<any[]>(cellRendererDependencies);\n useEffect(() => {\n let changeDepNames: any[] = [];\n for (const [i, dep] of cellRendererDependencies.entries()) {\n if (dep !== lastRenderDependencies.current[i]) {\n changeDepNames.push(names[i]);\n }\n }\n if (changeDepNames.length > 0) {\n console.log(\n \"Cell renderer dependencies changed:\",\n changeDepNames.join(\", \"),\n );\n }\n lastRenderDependencies.current = cellRendererDependencies;\n }, cellRendererDependencies);\n return null;\n}\n"],"names":["useRef","useEffect"],"mappings":";;;AAEO,SAAS,yBAAyB,EAAE,0BAA0B,SAAS;AAE5E,QAAM,yBAAyBA,MAAAA,OAAc,wBAAwB;AACrEC,QAAAA,UAAU,MAAM;AACd,QAAI,iBAAwB,CAAA;AAC5B,eAAW,CAAC,GAAG,GAAG,KAAK,yBAAyB,WAAW;AACzD,UAAI,QAAQ,uBAAuB,QAAQ,CAAC,GAAG;AAC7C,uBAAe,KAAK,MAAM,CAAC,CAAC;AAAA,MAC9B;AAAA,IACF;AACA,QAAI,eAAe,SAAS,GAAG;AAC7B,cAAQ;AAAA,QACN;AAAA,QACA,eAAe,KAAK,IAAI;AAAA,MAAA;AAAA,IAE5B;AACA,2BAAuB,UAAU;AAAA,EACnC,GAAG,wBAAwB;AAC3B,SAAO;AACT;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-overlay.js","sources":["../../src/utils/debug-overlay.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport function CellRendererDebugOverlay({ cellRendererDependencies, names }) {\n /** Debug overlay for cell renderer dependencies */\n const lastRenderDependencies = useRef<any[]>(cellRendererDependencies);\n useEffect(() => {\n let changeDepNames = [];\n for (const [i, dep] of cellRendererDependencies.entries()) {\n if (dep !== lastRenderDependencies.current[i]) {\n changeDepNames.push(names[i]);\n }\n }\n if (changeDepNames.length > 0) {\n console.log(\n \"Cell renderer dependencies changed:\",\n changeDepNames.join(\", \"),\n );\n }\n lastRenderDependencies.current = cellRendererDependencies;\n }, cellRendererDependencies);\n return null;\n}\n"],"names":[],"mappings":";AAEO,SAAS,yBAAyB,EAAE,0BAA0B,SAAS;AAE5E,QAAM,yBAAyB,OAAc,wBAAwB;AACrE,YAAU,MAAM;AACd,QAAI,
|
|
1
|
+
{"version":3,"file":"debug-overlay.js","sources":["../../src/utils/debug-overlay.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport function CellRendererDebugOverlay({ cellRendererDependencies, names }) {\n /** Debug overlay for cell renderer dependencies */\n const lastRenderDependencies = useRef<any[]>(cellRendererDependencies);\n useEffect(() => {\n let changeDepNames: any[] = [];\n for (const [i, dep] of cellRendererDependencies.entries()) {\n if (dep !== lastRenderDependencies.current[i]) {\n changeDepNames.push(names[i]);\n }\n }\n if (changeDepNames.length > 0) {\n console.log(\n \"Cell renderer dependencies changed:\",\n changeDepNames.join(\", \"),\n );\n }\n lastRenderDependencies.current = cellRendererDependencies;\n }, cellRendererDependencies);\n return null;\n}\n"],"names":[],"mappings":";AAEO,SAAS,yBAAyB,EAAE,0BAA0B,SAAS;AAE5E,QAAM,yBAAyB,OAAc,wBAAwB;AACrE,YAAU,MAAM;AACd,QAAI,iBAAwB,CAAA;AAC5B,eAAW,CAAC,GAAG,GAAG,KAAK,yBAAyB,WAAW;AACzD,UAAI,QAAQ,uBAAuB,QAAQ,CAAC,GAAG;AAC7C,uBAAe,KAAK,MAAM,CAAC,CAAC;AAAA,MAC9B;AAAA,IACF;AACA,QAAI,eAAe,SAAS,GAAG;AAC7B,cAAQ;AAAA,QACN;AAAA,QACA,eAAe,KAAK,IAAI;AAAA,MAAA;AAAA,IAE5B;AACA,2BAAuB,UAAU;AAAA,EACnC,GAAG,wBAAwB;AAC3B,SAAO;AACT;"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export * from './column-spec';
|
|
2
1
|
export * from './key-handling';
|
|
3
2
|
export * from './validation';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export * from './debug-overlay.ts';
|
|
4
|
+
export * from './atoms.ts';
|