@macrostrat/data-sheet 4.7.0 → 4.9.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 +47 -0
- package/README.md +60 -19
- package/dist/actions/context.cjs +10 -1
- package/dist/actions/context.cjs.map +1 -1
- package/dist/actions/context.js +10 -1
- package/dist/actions/context.js.map +1 -1
- package/dist/actions/types.d.ts +4 -0
- package/dist/components/data-editor.cjs +527 -0
- package/dist/components/data-editor.cjs.map +1 -0
- package/dist/components/data-editor.d.ts +142 -0
- package/dist/components/data-editor.js +524 -0
- package/dist/components/data-editor.js.map +1 -0
- package/dist/components/editor-actions.cjs +167 -0
- package/dist/components/editor-actions.cjs.map +1 -0
- package/dist/components/editor-actions.d.ts +37 -0
- package/dist/components/editor-actions.js +165 -0
- package/dist/components/editor-actions.js.map +1 -0
- package/dist/components/editor-popup.cjs +11 -1
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +11 -1
- package/dist/components/editor-popup.js.map +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/indicators/selection.cjs +10 -4
- package/dist/components/indicators/selection.cjs.map +1 -1
- package/dist/components/indicators/selection.js +10 -4
- package/dist/components/indicators/selection.js.map +1 -1
- package/dist/components/row-editor.cjs +351 -0
- package/dist/components/row-editor.cjs.map +1 -0
- package/dist/components/row-editor.d.ts +181 -0
- package/dist/components/row-editor.js +349 -0
- package/dist/components/row-editor.js.map +1 -0
- package/dist/components/row-editor.module.sass.cjs +51 -0
- package/dist/components/row-editor.module.sass.cjs.map +1 -0
- package/dist/components/row-editor.module.sass.js +49 -0
- package/dist/components/row-editor.module.sass.js.map +1 -0
- package/dist/components/toolbars/actions-toolbar.cjs +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -1
- package/dist/components/toolbars/actions-toolbar.js +1 -1
- package/dist/components/toolbars/actions-toolbar.js.map +1 -1
- package/dist/data-panel.cjs +36 -0
- package/dist/data-panel.cjs.map +1 -1
- package/dist/data-panel.d.ts +3 -2
- package/dist/data-panel.js +37 -1
- package/dist/data-panel.js.map +1 -1
- package/dist/data-panel.module.sass.cjs +28 -26
- package/dist/data-panel.module.sass.cjs.map +1 -1
- package/dist/data-panel.module.sass.js +28 -26
- package/dist/data-panel.module.sass.js.map +1 -1
- package/dist/data-sheet.css +267 -56
- package/dist/data-sheet.d.ts +2 -1
- package/dist/data-view.d.ts +1 -0
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/dist/main.module.sass.cjs +14 -13
- package/dist/main.module.sass.cjs.map +1 -1
- package/dist/main.module.sass.js +14 -13
- package/dist/main.module.sass.js.map +1 -1
- package/dist/postgrest-table/data-loaders.cjs +8 -1
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.js +9 -2
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/provider/column-spec.cjs +8 -1
- package/dist/provider/column-spec.cjs.map +1 -1
- package/dist/provider/column-spec.d.ts +105 -1
- package/dist/provider/column-spec.js +8 -1
- package/dist/provider/column-spec.js.map +1 -1
- package/dist/provider/core.cjs +32 -7
- package/dist/provider/core.cjs.map +1 -1
- package/dist/provider/core.d.ts +5 -1
- package/dist/provider/core.js +32 -7
- package/dist/provider/core.js.map +1 -1
- package/dist/provider/loader-state.cjs +11 -3
- package/dist/provider/loader-state.cjs.map +1 -1
- package/dist/provider/loader-state.d.ts +8 -1
- package/dist/provider/loader-state.js +12 -4
- package/dist/provider/loader-state.js.map +1 -1
- package/dist/provider/table-data.cjs +10 -1
- package/dist/provider/table-data.cjs.map +1 -1
- package/dist/provider/table-data.d.ts +10 -0
- package/dist/provider/table-data.js +11 -2
- package/dist/provider/table-data.js.map +1 -1
- package/dist/provider/types.cjs.map +1 -1
- package/dist/provider/types.d.ts +4 -1
- package/dist/provider/types.js.map +1 -1
- package/dist/provider/zustand-store.cjs +26 -13
- package/dist/provider/zustand-store.cjs.map +1 -1
- package/dist/provider/zustand-store.js +14 -1
- package/dist/provider/zustand-store.js.map +1 -1
- package/dist/renderers/cell-renderer.cjs +15 -4
- package/dist/renderers/cell-renderer.cjs.map +1 -1
- package/dist/renderers/cell-renderer.js +13 -4
- package/dist/renderers/cell-renderer.js.map +1 -1
- package/dist/renderers/column-header-cell.cjs +12 -1
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.js +11 -1
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +30 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/actions/context.ts +13 -2
- package/src/actions/types.ts +5 -0
- package/src/components/data-editor.ts +741 -0
- package/src/components/editor-actions.ts +228 -0
- package/src/components/editor-popup.ts +16 -3
- package/src/components/index.ts +3 -0
- package/src/components/indicators/selection.ts +12 -4
- package/src/components/row-editor.module.sass +161 -0
- package/src/components/row-editor.ts +620 -0
- package/src/components/toolbars/actions-toolbar.ts +3 -2
- package/src/data-panel.module.sass +25 -0
- package/src/data-panel.ts +50 -1
- package/src/main.module.sass +19 -0
- package/src/postgrest-table/data-loaders.ts +13 -0
- package/src/provider/column-spec.ts +94 -16
- package/src/provider/core.ts +41 -9
- package/src/provider/loader-state.ts +15 -2
- package/src/provider/table-data.ts +23 -1
- package/src/provider/types.ts +4 -1
- package/src/provider/zustand-store.ts +30 -1
- package/src/renderers/cell-renderer.ts +18 -3
- package/src/renderers/column-header-cell.ts +10 -0
- package/src/types.ts +31 -1
|
@@ -13,6 +13,7 @@ import { singleFocusedCell } from "../provider";
|
|
|
13
13
|
import { Cell } from "@blueprintjs/table";
|
|
14
14
|
import { ctx, dragValueHandlerAtom, useSelector } from "../provider";
|
|
15
15
|
import { Intent } from "@blueprintjs/core";
|
|
16
|
+
import classNames from "classnames";
|
|
16
17
|
|
|
17
18
|
/** Two validations are equivalent if they convey the same thing — so a fresh
|
|
18
19
|
* `validateCell` result object doesn't force a re-render when nothing changed. */
|
|
@@ -111,7 +112,10 @@ export function basicCellRenderer<T>(
|
|
|
111
112
|
? null
|
|
112
113
|
: validateCell(col, value, row, dataRowIndex);
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
// A derived column is never writable, whatever `editable` says — see
|
|
116
|
+
// `isColumnWritable`, which every write path in the store applies too.
|
|
117
|
+
const editable =
|
|
118
|
+
(col.editable ?? state.editable) && !isDeleted && !col.derived;
|
|
115
119
|
const tableIsEditable = state.editable;
|
|
116
120
|
|
|
117
121
|
// topLeftCell stores visible row indices, so compare with the visible rowIndex
|
|
@@ -160,6 +164,10 @@ export function basicCellRenderer<T>(
|
|
|
160
164
|
const detailPresentation =
|
|
161
165
|
col.cellDetail != null ? (col.detailPresentation ?? "popover") : null;
|
|
162
166
|
|
|
167
|
+
// Derived values are drawn dimmed, so a reader can tell a record from a
|
|
168
|
+
// restatement of one. Applied on every path below.
|
|
169
|
+
const derivedClass = col.derived ? "derived-cell" : undefined;
|
|
170
|
+
|
|
163
171
|
// Fast path — any non-focused cell whose *unfocused* appearance is just the
|
|
164
172
|
// value viewer (a plain Blueprint `Cell`). That's everything except a custom
|
|
165
173
|
// `cellComponent` (its own markup on every cell) and an *inline* `cellDetail`
|
|
@@ -179,6 +187,7 @@ export function basicCellRenderer<T>(
|
|
|
179
187
|
loading,
|
|
180
188
|
//value,
|
|
181
189
|
style,
|
|
190
|
+
className: derivedClass,
|
|
182
191
|
interactive: false,
|
|
183
192
|
//disabled: tableIsEditable && !editable,
|
|
184
193
|
},
|
|
@@ -216,6 +225,7 @@ export function basicCellRenderer<T>(
|
|
|
216
225
|
// Build the detail context for the unified `cellDetail` surface.
|
|
217
226
|
const makeDetailCtx = (editableFlag: boolean): CellDetailContext<T> => ({
|
|
218
227
|
...cellContext,
|
|
228
|
+
surface: "cell",
|
|
219
229
|
editable: editableFlag,
|
|
220
230
|
onChange(v: any) {
|
|
221
231
|
if (editableFlag) onCellEdited(dataRowIndex, col.key, v);
|
|
@@ -255,6 +265,7 @@ export function basicCellRenderer<T>(
|
|
|
255
265
|
loading,
|
|
256
266
|
value,
|
|
257
267
|
style,
|
|
268
|
+
className: derivedClass,
|
|
258
269
|
disabled: tableIsEditable && !editable,
|
|
259
270
|
interactive: false,
|
|
260
271
|
...cellComponentProps,
|
|
@@ -308,7 +319,11 @@ export function basicCellRenderer<T>(
|
|
|
308
319
|
}
|
|
309
320
|
|
|
310
321
|
// Default: popover (same open/close machinery as editors and panels).
|
|
311
|
-
const panel = h(
|
|
322
|
+
const panel = h(
|
|
323
|
+
EditorPopup,
|
|
324
|
+
{ valueViewer: _renderedValue, placement: col.detailPlacement },
|
|
325
|
+
content,
|
|
326
|
+
);
|
|
312
327
|
return h(
|
|
313
328
|
_Cell,
|
|
314
329
|
{
|
|
@@ -385,7 +400,7 @@ export function basicCellRenderer<T>(
|
|
|
385
400
|
if (_dataEditor != null) {
|
|
386
401
|
cellContents = _dataEditor;
|
|
387
402
|
}
|
|
388
|
-
const className = "value-viewer-cell";
|
|
403
|
+
const className = classNames("value-viewer-cell", derivedClass);
|
|
389
404
|
|
|
390
405
|
return h(
|
|
391
406
|
_Cell,
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
} from "../postgrest-table";
|
|
17
17
|
import { buildActionContext } from "../actions";
|
|
18
18
|
import { useMemo } from "react";
|
|
19
|
+
import classNames from "classnames";
|
|
19
20
|
|
|
20
21
|
export interface ColumnActionsConfig {
|
|
21
22
|
activeSort?: ColumnSortEntry | null;
|
|
@@ -107,9 +108,18 @@ function ColumnHeaderName({ col, hasSortActive, hasFilterActive, activeSort }) {
|
|
|
107
108
|
textOverflow: "ellipsis",
|
|
108
109
|
whiteSpace: "nowrap",
|
|
109
110
|
},
|
|
111
|
+
className: classNames({ "derived-column-name": col.derived }),
|
|
110
112
|
},
|
|
111
113
|
col.name,
|
|
112
114
|
),
|
|
115
|
+
// A derived column says so in its header: the values below are computed
|
|
116
|
+
// and won't take an edit.
|
|
117
|
+
h.if(col.derived === true)(Icon, {
|
|
118
|
+
icon: "function",
|
|
119
|
+
size: 12,
|
|
120
|
+
title: "Derived — computed from other values, not editable",
|
|
121
|
+
style: { marginLeft: "4px", flexShrink: 0, opacity: 0.6 },
|
|
122
|
+
}),
|
|
113
123
|
h.if(hasSortActive || hasFilterActive)(
|
|
114
124
|
"span",
|
|
115
125
|
{
|
package/src/types.ts
CHANGED
|
@@ -39,6 +39,14 @@ export interface FetchDataOptions<T = any> {
|
|
|
39
39
|
* Pass `totalCount` when it's known — the array is pre-sized to it, so the
|
|
40
40
|
* scrollbar and the counter are right from the first paint. */
|
|
41
41
|
initialData?: T[] | InitialDataChunk<T>;
|
|
42
|
+
/** Identity of the row the view starts after — the keyset cursor of a view
|
|
43
|
+
* that begins mid-list, as reached through a page link (`?after=<id>`). It is
|
|
44
|
+
* passed to the provider as `after` on every chunk of the view it was created
|
|
45
|
+
* for, and dropped on the first view change (sorts, filters, a refresh), since
|
|
46
|
+
* it only describes that view. Read from the URL when the page loads; the
|
|
47
|
+
* client never writes it back while scrolling. Pair it with an `initialData`
|
|
48
|
+
* seed of the rows after it for a complete server render. */
|
|
49
|
+
startAfter?: string | number | null;
|
|
42
50
|
/** Debounce (ms) applied to view-state → refetch, so rapid changes (typing a
|
|
43
51
|
* text filter) collapse into one fetch once the view settles. The input stays
|
|
44
52
|
* instant; only the fetch waits. `0` (default) keeps immediate refetching. */
|
|
@@ -88,8 +96,26 @@ export interface DataViewCoreProps<T> extends InteractionOptions {
|
|
|
88
96
|
initialSorts?: ColumnSort[];
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
/** Links that make a paged view reachable without JavaScript. */
|
|
100
|
+
export interface PageLinks<T = any> {
|
|
101
|
+
/** The href of the view that starts after `row` (`?after=<id>`). Rendered as
|
|
102
|
+
* a visually hidden `rel="next"` link after the loaded rows, so a crawler
|
|
103
|
+
* following the server-rendered HTML reaches every page of the list while
|
|
104
|
+
* readers keep the infinite scroll. */
|
|
105
|
+
after: (row: T) => string;
|
|
106
|
+
/** The href of the view's first page. Shown as a "Return to top" link at the
|
|
107
|
+
* head of the content while the view starts mid-list (`startAfter`). */
|
|
108
|
+
top?: string;
|
|
109
|
+
/** Label for that link (default "Return to top"). */
|
|
110
|
+
topLabel?: ReactNode;
|
|
111
|
+
}
|
|
112
|
+
|
|
91
113
|
export interface DataViewSharedProps<T = any>
|
|
92
114
|
extends FetchDataOptions<T>, DataViewCoreProps<T> {
|
|
115
|
+
/** Crawlable page links (see `PageLinks`). Neither link is written to the
|
|
116
|
+
* browser's URL as the list is scrolled — deep pages are for crawlers and
|
|
117
|
+
* for whoever follows such a link, not a state the page keeps. */
|
|
118
|
+
pageLinks?: PageLinks<T>;
|
|
93
119
|
/** Configurable table actions shown in a selection-aware toolbar.
|
|
94
120
|
* When provided, the actions toolbar renders alongside the existing
|
|
95
121
|
* edit toolbar. Actions are filtered by the current selection cardinality. */
|
|
@@ -117,8 +143,12 @@ export enum DataSheetDensity {
|
|
|
117
143
|
* until the next click.
|
|
118
144
|
* - `"manual"` (default when `autoFocusEditor` is `false`): the surface stays
|
|
119
145
|
* closed until the cell is clicked; arrow keys always navigate the table.
|
|
146
|
+
* - `"second-click"`: a click selects a cell and nothing more; a second click
|
|
147
|
+
* on it (or Enter / F2) opens its surface. For a sheet whose selection
|
|
148
|
+
* already feeds an editor of its own — a row editor beside the grid — so
|
|
149
|
+
* selecting doesn't also open a popover over the cells.
|
|
120
150
|
*/
|
|
121
|
-
export type CellInteraction = "auto" | "manual";
|
|
151
|
+
export type CellInteraction = "auto" | "manual" | "second-click";
|
|
122
152
|
|
|
123
153
|
export interface DataSheetRendererProps<T = any>
|
|
124
154
|
extends TableProps, DataViewSharedProps<T> {
|