@jielga/tmdatagrid 2.0.0-beta.1 → 2.0.0-beta.3
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/dist/index.d.ts +192 -46
- package/dist/index.js +2147 -1687
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/skills/appearance/SKILL.md +1 -1
- package/skills/cell-selection/SKILL.md +1 -1
- package/skills/columns/SKILL.md +2 -2
- package/skills/data/SKILL.md +1 -1
- package/skills/editing/SKILL.md +95 -218
- package/skills/editing/references/common-mistakes.md +179 -0
- package/skills/editing/references/editing-api.md +48 -15
- package/skills/editing/references/editors-and-validation.md +5 -2
- package/skills/filtering/SKILL.md +1 -1
- package/skills/getting-started/SKILL.md +1 -1
- package/skills/grouping/SKILL.md +1 -1
- package/skills/options/SKILL.md +2 -2
- package/skills/rows/SKILL.md +1 -1
- package/skills/rows/references/rows-api.md +1 -1
- package/skills/server-side/SKILL.md +1 -1
- package/skills/testing/SKILL.md +3 -2
- package/src/tmdatagrid/components/TMDataGrid.module.css +7 -0
- package/src/tmdatagrid/components/TMDataGridCellEditor.tsx +25 -10
- package/src/tmdatagrid/components/TMDataGridEditActions.tsx +96 -25
- package/src/tmdatagrid/components/TMDataGridEditColumn.tsx +242 -86
- package/src/tmdatagrid/components/TMDataGridEntryRows.tsx +176 -77
- package/src/tmdatagrid/components/TMDataGridTable.module.css +47 -3
- package/src/tmdatagrid/components/TMDataGridTable.tsx +44 -4
- package/src/tmdatagrid/components/icons.ts +1 -0
- package/src/tmdatagrid/core/capabilities.ts +10 -0
- package/src/tmdatagrid/core/draftCellContext.ts +68 -0
- package/src/tmdatagrid/core/editEngine.ts +465 -65
- package/src/tmdatagrid/core/labels.ts +21 -2
- package/src/tmdatagrid/core/labelsSv.ts +6 -0
- package/src/tmdatagrid/index.ts +4 -1
- package/src/tmdatagrid/useTMDataGrid.tsx +67 -27
package/dist/index.d.ts
CHANGED
|
@@ -15,24 +15,41 @@ declare function TMDataGridColumnsPanel(): import("react").JSX.Element;
|
|
|
15
15
|
//#region .types-tmp/components/TMDataGridEditActions.d.ts
|
|
16
16
|
/** What the edit chrome is showing. */
|
|
17
17
|
type TMDataGridEditActionsState = {
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Rows in the draft store, which is what Save sends: committed edits,
|
|
20
|
+
* committed entry rows and deletion marks.
|
|
21
|
+
*/
|
|
22
|
+
draftCount: number;
|
|
23
|
+
/**
|
|
24
|
+
* Rows still open - edited or entered but not committed, so not part of
|
|
25
|
+
* the save. They stay open across a save.
|
|
26
|
+
*/
|
|
27
|
+
openCount: number;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Was "everything uncommitted", which Save no longer sends.
|
|
30
|
+
* Reads as `draftCount + openCount`; use whichever you meant.
|
|
31
|
+
*/
|
|
19
32
|
pendingCount: number;
|
|
20
33
|
/** Whether a submit is in flight. */
|
|
21
34
|
isSubmitting: boolean;
|
|
22
35
|
};
|
|
23
36
|
/** What the edit chrome can do. */
|
|
24
37
|
type TMDataGridEditActionsActions = {
|
|
25
|
-
/**
|
|
38
|
+
/** Saves the draft store. Open rows are left alone. */
|
|
26
39
|
save: () => Promise<boolean>;
|
|
27
|
-
/**
|
|
40
|
+
/** Submits every open row, committing the ones that validate. */
|
|
41
|
+
commitAll: () => Promise<boolean>;
|
|
42
|
+
/** Drops everything - open form state and the draft store alike. */
|
|
28
43
|
discard: () => void;
|
|
29
44
|
};
|
|
30
45
|
/** The pre-bound pieces of the built-in edit chrome. */
|
|
31
46
|
type TMDataGridEditActionsControls = {
|
|
32
|
-
/** Save, with the
|
|
47
|
+
/** Save, with the draft count, disabled while the draft store is empty. */
|
|
33
48
|
Save: () => ReactNode;
|
|
34
49
|
/** Discard, disabled while nothing is pending. */
|
|
35
50
|
Discard: () => ReactNode;
|
|
51
|
+
/** The "N rows still being edited" note, or nothing while there are none. */
|
|
52
|
+
OpenRowsNote: () => ReactNode;
|
|
36
53
|
};
|
|
37
54
|
/** What {@link TMDataGridEditActionsProps.renderActions} is handed. */
|
|
38
55
|
type TMDataGridEditActionsSlotArgs = {
|
|
@@ -48,7 +65,8 @@ type TMDataGridEditActionsProps = {
|
|
|
48
65
|
* <TMDataGrid.EditActions
|
|
49
66
|
* renderActions={({ state, Controls }) => (
|
|
50
67
|
* <Group>
|
|
51
|
-
* {state.
|
|
68
|
+
* {state.draftCount > 0 && <Badge>{state.draftCount}</Badge>}
|
|
69
|
+
* <Controls.OpenRowsNote />
|
|
52
70
|
* <Controls.Save />
|
|
53
71
|
* <Controls.Discard />
|
|
54
72
|
* </Group>
|
|
@@ -59,11 +77,11 @@ type TMDataGridEditActionsProps = {
|
|
|
59
77
|
renderActions?: (args: TMDataGridEditActionsSlotArgs) => ReactNode;
|
|
60
78
|
};
|
|
61
79
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* nothing while editing is off.
|
|
80
|
+
* Draft mode's toolbar chrome: Save with the draft-store count, Discard, and
|
|
81
|
+
* a note counting rows still open. Save sends the draft store and leaves open
|
|
82
|
+
* rows alone, so it greys out while nothing is committed however much is
|
|
83
|
+
* being typed - the note is what makes those rows visible. Works under any
|
|
84
|
+
* `editing.mode` and renders nothing while editing is off.
|
|
67
85
|
*
|
|
68
86
|
* ```tsx
|
|
69
87
|
* <TMDataGrid.Toolbar>
|
|
@@ -262,7 +280,7 @@ declare function tmDataGridFilterFn<TFeatures extends TableFeatures, TData exten
|
|
|
262
280
|
* How commits happen - one axis, each mode a thin policy over the same
|
|
263
281
|
* engine. See `editMode` on `UseTMDataGridOptions`.
|
|
264
282
|
*/
|
|
265
|
-
type TMDataGridEditMode = "cell" | "cellConfirm" | "row" | "
|
|
283
|
+
type TMDataGridEditMode = "cell" | "cellConfirm" | "row" | "draft";
|
|
266
284
|
/**
|
|
267
285
|
* One editing row's live form. TanStack Form's `FormApi`, not a wrapper: the
|
|
268
286
|
* engine is a form library, and everything mid-edit - values, dirty state,
|
|
@@ -344,6 +362,12 @@ type TMDataGridEditRowProjection = {
|
|
|
344
362
|
/** A row-level error - a pathless `.refine()`, or a rejected commit. */
|
|
345
363
|
hasRowError: boolean;
|
|
346
364
|
isSubmitting: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* The row as drafted - the form's `state.values`. Reference-stable while no
|
|
367
|
+
* value changes, so a cell may subscribe to it and repaint only when its
|
|
368
|
+
* row's draft actually moves.
|
|
369
|
+
*/
|
|
370
|
+
values: TMDataGridRowData;
|
|
347
371
|
};
|
|
348
372
|
/**
|
|
349
373
|
* The grid-facing index of everything mid-edit. A projection synced from the
|
|
@@ -362,16 +386,34 @@ type TMDataGridEditState = {
|
|
|
362
386
|
columnId: string | null;
|
|
363
387
|
} | null;
|
|
364
388
|
/**
|
|
365
|
-
* Rows with a live form
|
|
366
|
-
*
|
|
389
|
+
* Rows with a live form, committed or not - every row the grid is holding
|
|
390
|
+
* work for. A row is *open* (undecided form state) when it is in here and
|
|
391
|
+
* not in {@link committedRowIds}.
|
|
367
392
|
*/
|
|
368
393
|
openRowIds: ReadonlyArray<string>;
|
|
369
394
|
rows: Record<string, TMDataGridEditRowProjection>;
|
|
370
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* The draft store's edit slice: existing rows whose form passed its submit
|
|
397
|
+
* and is parked, waiting for `saveDrafts`. A subset of `openRowIds` - the
|
|
398
|
+
* values stay in the row's form, this records which side of the line the
|
|
399
|
+
* row is on. `begin` on one of these takes it back out, into form state.
|
|
400
|
+
*
|
|
401
|
+
* Only draft mode parks; the immediate modes send a commit straight to the
|
|
402
|
+
* consumer and drop the form, so there this stays empty.
|
|
403
|
+
*/
|
|
404
|
+
committedRowIds: ReadonlyArray<string>;
|
|
405
|
+
/**
|
|
406
|
+
* Rows being created, not yet in `data`. `committed` is the draft store's
|
|
407
|
+
* add slice: the entry row passed its submit and renders as a value row
|
|
408
|
+
* until `begin` re-opens it. Under the immediate modes a commit adds
|
|
409
|
+
* through `onRowAdd` and the entry is dropped, so there it never turns
|
|
410
|
+
* `true`.
|
|
411
|
+
*/
|
|
371
412
|
newRows: ReadonlyArray<{
|
|
372
413
|
tempId: string;
|
|
414
|
+
committed: boolean;
|
|
373
415
|
}>;
|
|
374
|
-
/**
|
|
416
|
+
/** The draft store's delete slice: rows marked deleted under draft mode. */
|
|
375
417
|
deletedRowIds: ReadonlyArray<string>;
|
|
376
418
|
};
|
|
377
419
|
type ErasedRow = Row<TMDataGridFeatures, TMDataGridRowData>;
|
|
@@ -492,15 +534,24 @@ type TMDataGridRowDeleteArgs<TData extends RowData> = {
|
|
|
492
534
|
rowId: string;
|
|
493
535
|
row: Row<TMDataGridFeatures, TData>;
|
|
494
536
|
};
|
|
495
|
-
/**
|
|
496
|
-
|
|
497
|
-
|
|
537
|
+
/**
|
|
538
|
+
* The draft store, flushed - what `saveDrafts` hands `onSaveDrafts`. Every
|
|
539
|
+
* committed change at once, so a server can apply it as one transaction.
|
|
540
|
+
* Rows still open (undecided form state) are not in here and stay open.
|
|
541
|
+
*/
|
|
542
|
+
type TMDataGridSaveDraftsArgs<TData extends RowData> = {
|
|
543
|
+
/** Every committed edit to an existing row. */
|
|
498
544
|
rows: Array<TMDataGridEditCommitArgs<TData>>;
|
|
499
|
-
/** Every
|
|
545
|
+
/** Every committed new row from the entry block. */
|
|
500
546
|
added: Array<TMDataGridRowAddArgs<TData>>;
|
|
501
|
-
/** Ids marked deleted while the
|
|
547
|
+
/** Ids marked deleted while the drafts accumulated. */
|
|
502
548
|
deleted: Array<string>;
|
|
503
549
|
};
|
|
550
|
+
/**
|
|
551
|
+
* @deprecated Renamed to {@link TMDataGridSaveDraftsArgs} - the payload is
|
|
552
|
+
* the draft store being saved, not a commit. Removed in a later beta.
|
|
553
|
+
*/
|
|
554
|
+
type TMDataGridEditCommitDraftsArgs<TData extends RowData> = TMDataGridSaveDraftsArgs<TData>;
|
|
504
555
|
/**
|
|
505
556
|
* The data path a column edits, or `null` for a column that has none.
|
|
506
557
|
*
|
|
@@ -522,6 +573,24 @@ declare function getEditFieldName(column: {
|
|
|
522
573
|
}): string | null;
|
|
523
574
|
/** What Delete writes into a cell - the type's honest empty value. */
|
|
524
575
|
declare function clearedValueForType(type: TMDataGridColumnType): unknown;
|
|
576
|
+
/** `edit.addRows` options. */
|
|
577
|
+
type TMDataGridAddRowsOptions = {
|
|
578
|
+
/**
|
|
579
|
+
* Submit each row as it is added instead of leaving it open. Defaults to
|
|
580
|
+
* `false` - the rows open as editable entry rows, as `addRow` does.
|
|
581
|
+
*/
|
|
582
|
+
commit?: boolean;
|
|
583
|
+
};
|
|
584
|
+
/** What `edit.addRows` reports back. Every added row is in exactly one list. */
|
|
585
|
+
type TMDataGridAddRowsResult = {
|
|
586
|
+
/** Temp ids that committed - parked as drafts, or added outright. */
|
|
587
|
+
committed: Array<string>;
|
|
588
|
+
/**
|
|
589
|
+
* Temp ids still open in the entry block: everything, when `commit` was
|
|
590
|
+
* not asked for; the rows that failed validation, when it was.
|
|
591
|
+
*/
|
|
592
|
+
open: Array<string>;
|
|
593
|
+
};
|
|
525
594
|
/**
|
|
526
595
|
* The engine plus its store - `api.edit`.
|
|
527
596
|
*
|
|
@@ -529,7 +598,7 @@ declare function clearedValueForType(type: TMDataGridColumnType): unknown;
|
|
|
529
598
|
* editors write through, so a consumer can render it in a drawer or a detail
|
|
530
599
|
* panel and share values, dirty state and errors with the cells.
|
|
531
600
|
*/
|
|
532
|
-
type TMDataGridEditApi = {
|
|
601
|
+
type TMDataGridEditApi<TData extends RowData = TMDataGridRowData> = {
|
|
533
602
|
/** The projection store - subscribe with `useSelector(edit.store, …)`. */
|
|
534
603
|
store: Store<TMDataGridEditState>;
|
|
535
604
|
/** Current snapshot, for reads outside React. */
|
|
@@ -565,22 +634,56 @@ type TMDataGridEditApi = {
|
|
|
565
634
|
* `"cellConfirm"`, where the dirty cell keeps waiting for its ✓.
|
|
566
635
|
*/
|
|
567
636
|
deactivate: () => void;
|
|
568
|
-
/** Drops every draft. */
|
|
637
|
+
/** Drops every draft - open form state and the draft store alike. */
|
|
569
638
|
cancelAll: () => void;
|
|
570
|
-
/**
|
|
639
|
+
/**
|
|
640
|
+
* Submits every open row, as if each had been OK'd: a row that validates
|
|
641
|
+
* commits (into the draft store under draft mode, straight to the consumer
|
|
642
|
+
* under the immediate modes), a row that fails stays open with its errors.
|
|
643
|
+
* `true` when every row committed. Sends nothing to the consumer by itself
|
|
644
|
+
* under draft mode - that is `saveDrafts`.
|
|
645
|
+
*/
|
|
646
|
+
commitAll: () => Promise<boolean>;
|
|
647
|
+
/**
|
|
648
|
+
* Flushes the draft store: every committed edit, added row and deletion
|
|
649
|
+
* mark reaches the consumer, through `onSaveDrafts` in one call when it is
|
|
650
|
+
* set, or row by row through `onCommit` / `onRowAdd` / `onRowDelete`.
|
|
651
|
+
*
|
|
652
|
+
* Rows still open are left alone - they keep their form state and stay
|
|
653
|
+
* open. `true` when everything landed; a rejected save keeps every draft.
|
|
654
|
+
*/
|
|
655
|
+
saveDrafts: () => Promise<boolean>;
|
|
656
|
+
/**
|
|
657
|
+
* @deprecated Split into {@link commitAll} and {@link saveDrafts}, which is
|
|
658
|
+
* exactly what this now does. Removed in a later beta.
|
|
659
|
+
*/
|
|
571
660
|
submitAll: () => Promise<boolean>;
|
|
572
661
|
/** Writes the type's empty value into a cell and commits it - Delete. */
|
|
573
662
|
clearCell: (rowId: string, columnId: string) => Promise<boolean>;
|
|
574
663
|
/**
|
|
575
664
|
* Opens a new entry row (the sticky block under the header) seeded from
|
|
576
|
-
* `newRowDefaults`.
|
|
577
|
-
*
|
|
578
|
-
*
|
|
665
|
+
* `newRowDefaults`. `values` overrides that seed key by key, so
|
|
666
|
+
* `addRow()` opens a blank row and `addRow({ status: "draft" })` opens one
|
|
667
|
+
* that starts filled in. Returns its temporary id - a form with no backing
|
|
668
|
+
* row yet. Committing it calls `onRowAdd` (immediate modes) or joins
|
|
669
|
+
* `submitAll`'s `added` (draft).
|
|
579
670
|
*/
|
|
580
|
-
addRow: () => string;
|
|
671
|
+
addRow: (values?: Partial<TData>) => string;
|
|
672
|
+
/**
|
|
673
|
+
* Opens entry rows for a list of records at once - one state write for the
|
|
674
|
+
* batch, where a loop over `addRow` is one per row. Each row is seeded over
|
|
675
|
+
* `newRowDefaults` exactly as `addRow` does.
|
|
676
|
+
*
|
|
677
|
+
* `commit: true` submits each row as it lands, which is what an import
|
|
678
|
+
* wants: rows that validate commit (parked in the draft store under draft
|
|
679
|
+
* mode, added through `onRowAdd` under the immediate modes - once per row),
|
|
680
|
+
* and rows that fail stay open in the entry block carrying their errors,
|
|
681
|
+
* for the user to fix. The result says which went which way.
|
|
682
|
+
*/
|
|
683
|
+
addRows: (rows: ReadonlyArray<Partial<TData>>, options?: TMDataGridAddRowsOptions) => Promise<TMDataGridAddRowsResult>;
|
|
581
684
|
/**
|
|
582
685
|
* Deletes a row: `onRowDelete` straight away under the immediate modes;
|
|
583
|
-
* under
|
|
686
|
+
* under draft it toggles the id in `deletedRowIds` - the row renders
|
|
584
687
|
* struck through until `submitAll` reports it. On an uncommitted entry
|
|
585
688
|
* row it just discards the entry.
|
|
586
689
|
*/
|
|
@@ -691,18 +794,31 @@ type TMDataGridLabels = {
|
|
|
691
794
|
cancelRowEdit: string;
|
|
692
795
|
/** Save tooltip when field errors block the row, with no row message. */
|
|
693
796
|
editRowErrors: string;
|
|
694
|
-
/** `EditActions`' Save, with the
|
|
797
|
+
/** `EditActions`' Save, with the count of rows in the draft store. */
|
|
695
798
|
saveAllEdits: (rows: number) => string;
|
|
696
799
|
/** `EditActions`' Discard. */
|
|
697
800
|
discardAllEdits: string;
|
|
801
|
+
/**
|
|
802
|
+
* `EditActions`' note about rows still open - edited but not committed, so
|
|
803
|
+
* not part of the save. Shown only while there are any.
|
|
804
|
+
*/
|
|
805
|
+
editRowsStillOpen: (rows: number) => string;
|
|
698
806
|
/** The entry row's ✓ - commit the add. */
|
|
699
807
|
confirmNewRow: string;
|
|
700
808
|
/** The entry row's ✕ - drop the entry. */
|
|
701
809
|
discardNewRow: string;
|
|
702
810
|
/** The lane's trash can. */
|
|
703
811
|
deleteRow: string;
|
|
704
|
-
/** The lane's undo on a row marked deleted (
|
|
812
|
+
/** The lane's undo on a row marked deleted (draft). */
|
|
705
813
|
restoreRow: string;
|
|
814
|
+
/** The lane's undo on a row with a dirty draft (draft) - drops it. */
|
|
815
|
+
revertRow: string;
|
|
816
|
+
/** The lane's state icon on a confirmed entry row (draft). */
|
|
817
|
+
rowStateNew: string;
|
|
818
|
+
/** The lane's state icon on a row with a dirty draft (draft). */
|
|
819
|
+
rowStateEdited: string;
|
|
820
|
+
/** The lane's state icon on a row marked deleted (draft). */
|
|
821
|
+
rowStateDeleted: string;
|
|
706
822
|
cellCount: (count: number) => string;
|
|
707
823
|
copy: string;
|
|
708
824
|
exportCsv: string;
|
|
@@ -987,6 +1103,13 @@ type TMDataGridFeatureFlags = {
|
|
|
987
1103
|
editing: boolean;
|
|
988
1104
|
/** The commit policy, or `null` while editing is off. */
|
|
989
1105
|
editMode: TMDataGridEditMode | null;
|
|
1106
|
+
/**
|
|
1107
|
+
* Whether a confirmed entry row stays pinned in the sticky entry block
|
|
1108
|
+
* until Save all - `editing.newRowsSticky`, draft mode only. Off by
|
|
1109
|
+
* default: a confirmed row joins the scrolling flow instead, so entering
|
|
1110
|
+
* many rows cannot fill the viewport with sticky chrome.
|
|
1111
|
+
*/
|
|
1112
|
+
editNewRowsSticky: boolean;
|
|
990
1113
|
/** The generated row-number gutter - `enableRowNumbers`. Off by default. */
|
|
991
1114
|
rowNumbers: boolean;
|
|
992
1115
|
/**
|
|
@@ -1517,7 +1640,7 @@ type TMDataGridApi<TData extends RowData> = {
|
|
|
1517
1640
|
* out the same TanStack Form the inline editors write through, so a drawer
|
|
1518
1641
|
* or detail panel can share a row's draft. Inert until `editing` is set.
|
|
1519
1642
|
*/
|
|
1520
|
-
edit: TMDataGridEditApi
|
|
1643
|
+
edit: TMDataGridEditApi<TData>;
|
|
1521
1644
|
/** Table-level feature switches, re-read from options on every render. */
|
|
1522
1645
|
features: TMDataGridFeatureFlags;
|
|
1523
1646
|
/** Every string the chrome renders, `labels` merged over the English defaults. */
|
|
@@ -1597,17 +1720,18 @@ type TMDataGridEditingCallbacks<TData extends RowData> = {
|
|
|
1597
1720
|
/**
|
|
1598
1721
|
* Seed values for `edit.addRow()` - the entry row's starting point. A
|
|
1599
1722
|
* function is called per added row (fresh timestamps, empty arrays).
|
|
1723
|
+
* `edit.addRow(values)` overrides this key by key for that one row.
|
|
1600
1724
|
*/
|
|
1601
1725
|
newRowDefaults?: TData | (() => TData);
|
|
1602
1726
|
/**
|
|
1603
1727
|
* Called when an entry row commits: `Enter` or the lane's ✓ under the
|
|
1604
|
-
* immediate modes, `submitAll` under
|
|
1728
|
+
* immediate modes, `submitAll` under draft. Create the record and let it
|
|
1605
1729
|
* arrive back through `data`; the engine's `tempId` never leaves the grid.
|
|
1606
1730
|
*/
|
|
1607
1731
|
onRowAdd?: (args: TMDataGridRowAddArgs<TData>) => void | Promise<void>;
|
|
1608
1732
|
/**
|
|
1609
1733
|
* Called by `edit.deleteRow` under the immediate modes - confirmation, if
|
|
1610
|
-
* any, belongs in here. Under
|
|
1734
|
+
* any, belongs in here. Under draft, deletions accumulate in
|
|
1611
1735
|
* `edit.state.deletedRowIds` instead and are reported by `submitAll`.
|
|
1612
1736
|
* Setting this also puts the trash can in the edit lane.
|
|
1613
1737
|
*/
|
|
@@ -1623,12 +1747,12 @@ type TMDataGridEditingCallbacks<TData extends RowData> = {
|
|
|
1623
1747
|
* | `"cell"` | Enter, Tab, blur - Sheets | Escape |
|
|
1624
1748
|
* | `"cellConfirm"` | ✓ or Enter only; blur keeps the draft | ✕ or Escape |
|
|
1625
1749
|
* | `"row"` | Save in the edit lane, or Ctrl+Enter | Cancel, or Escape |
|
|
1626
|
-
* | `"
|
|
1750
|
+
* | `"draft"` | `edit.commit(rowId)` into the draft store, `edit.saveDrafts()` out | `edit.cancelAll()` |
|
|
1627
1751
|
*
|
|
1628
1752
|
* Setting `editing` makes `getRowId` required - drafts are keyed by row id,
|
|
1629
1753
|
* and the index fallback would name a different record after any sort - and
|
|
1630
|
-
* `
|
|
1631
|
-
*
|
|
1754
|
+
* `onSaveDrafts` exists only under `mode: "draft"`, the one mode with a draft
|
|
1755
|
+
* store to save.
|
|
1632
1756
|
*
|
|
1633
1757
|
* The object may be written inline: the callbacks are read through a ref
|
|
1634
1758
|
* every render, so its identity does not matter.
|
|
@@ -1640,18 +1764,40 @@ type TMDataGridEditingCallbacks<TData extends RowData> = {
|
|
|
1640
1764
|
* override the rest.
|
|
1641
1765
|
*/
|
|
1642
1766
|
type TMDataGridEditingOptions<TData extends RowData> = TMDataGridEditingCallbacks<TData> & ({
|
|
1643
|
-
mode: "
|
|
1767
|
+
mode: "draft";
|
|
1768
|
+
/**
|
|
1769
|
+
* Draft mode's save: called once by `edit.saveDrafts()` with the
|
|
1770
|
+
* whole draft store - committed edits, added rows and deletion
|
|
1771
|
+
* marks - so a server can apply it as one transaction. Without it,
|
|
1772
|
+
* `saveDrafts` falls back to the per-row
|
|
1773
|
+
* {@link TMDataGridEditingCallbacks.onCommit} loop.
|
|
1774
|
+
*
|
|
1775
|
+
* Rows still open are not in the payload and stay open; a rejection
|
|
1776
|
+
* keeps every draft.
|
|
1777
|
+
*/
|
|
1778
|
+
onSaveDrafts?: (args: TMDataGridSaveDraftsArgs<TData>) => void | Promise<void>;
|
|
1779
|
+
/**
|
|
1780
|
+
* @deprecated Renamed to {@link onSaveDrafts} - it fires when the
|
|
1781
|
+
* draft store is saved, not when a row commits into it. Still
|
|
1782
|
+
* honoured; removed in a later beta.
|
|
1783
|
+
*/
|
|
1784
|
+
onCommitDrafts?: (args: TMDataGridSaveDraftsArgs<TData>) => void | Promise<void>;
|
|
1644
1785
|
/**
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1786
|
+
* Keep committed entry rows pinned in the sticky entry block until
|
|
1787
|
+
* the draft store is saved. Off by default: a committed row joins
|
|
1788
|
+
* the scrolling flow above the body rows instead - the block a row
|
|
1789
|
+
* is *typed* into is always sticky, but committed rows scroll, so
|
|
1790
|
+
* committing many cannot fill the viewport with sticky chrome.
|
|
1649
1791
|
*/
|
|
1650
|
-
|
|
1792
|
+
newRowsSticky?: boolean;
|
|
1651
1793
|
} | {
|
|
1652
|
-
mode: Exclude<TMDataGridEditMode, "
|
|
1653
|
-
/** Only `"
|
|
1654
|
-
|
|
1794
|
+
mode: Exclude<TMDataGridEditMode, "draft">;
|
|
1795
|
+
/** Only `"draft"` has a draft store to save - see the other branch. */
|
|
1796
|
+
onSaveDrafts?: never;
|
|
1797
|
+
/** @deprecated See {@link onSaveDrafts}. */
|
|
1798
|
+
onCommitDrafts?: never;
|
|
1799
|
+
/** Committed entry rows exist only under `"draft"` - see there. */
|
|
1800
|
+
newRowsSticky?: never;
|
|
1655
1801
|
});
|
|
1656
1802
|
type UseTMDataGridOptions<TData extends RowData> = Omit<TableOptions<TMDataGridFeatures, TData>, "features"> & ({
|
|
1657
1803
|
editing?: undefined;
|
|
@@ -3069,4 +3215,4 @@ declare function getSelectableRowIds<TData extends RowData>(row: Row<TMDataGridF
|
|
|
3069
3215
|
*/
|
|
3070
3216
|
declare function resolveRowSelectionClick<TData extends RowData>({ rows, rowId, anchorRowId, modifiers, selection, canReplaceSelection }: ResolveRowSelectionClickArgs<TData>): ResolvedRowSelection;
|
|
3071
3217
|
//#endregion
|
|
3072
|
-
export { type BuildCellMatrixArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_CELL_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, type ResolveCellMoveArgs, type ResolveRangeBoundsArgs, type ResolveRowSelectionClickArgs, type ResolvedRowSelection, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, TMDataGrid, type TMDataGridAggregationName, type TMDataGridApi, TMDataGridBooleanEditor, type TMDataGridCapabilities, type TMDataGridCellCoords, type TMDataGridCellEventArgs, type TMDataGridCellExportOptions, type TMDataGridCellMatrix, type TMDataGridCellNav, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilterOptions, type TMDataGridColumnLayout, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnType, type TMDataGridContextValue, type TMDataGridDataSlice, TMDataGridDateEditor, type TMDataGridDetailsArgs, type TMDataGridDetailsRenderer, type TMDataGridDropSide, TMDataGridEditActions, type TMDataGridEditActionsActions, type TMDataGridEditActionsControls, type TMDataGridEditActionsProps, type TMDataGridEditActionsSlotArgs, type TMDataGridEditActionsState, type TMDataGridEditApi, type TMDataGridEditChange, type TMDataGridEditCommitArgs, type
|
|
3218
|
+
export { type BuildCellMatrixArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_CELL_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, type ResolveCellMoveArgs, type ResolveRangeBoundsArgs, type ResolveRowSelectionClickArgs, type ResolvedRowSelection, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, TMDataGrid, type TMDataGridAddRowsOptions, type TMDataGridAddRowsResult, type TMDataGridAggregationName, type TMDataGridApi, TMDataGridBooleanEditor, type TMDataGridCapabilities, type TMDataGridCellCoords, type TMDataGridCellEventArgs, type TMDataGridCellExportOptions, type TMDataGridCellMatrix, type TMDataGridCellNav, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilterOptions, type TMDataGridColumnLayout, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnType, type TMDataGridContextValue, type TMDataGridDataSlice, TMDataGridDateEditor, type TMDataGridDetailsArgs, type TMDataGridDetailsRenderer, type TMDataGridDropSide, TMDataGridEditActions, type TMDataGridEditActionsActions, type TMDataGridEditActionsControls, type TMDataGridEditActionsProps, type TMDataGridEditActionsSlotArgs, type TMDataGridEditActionsState, type TMDataGridEditApi, type TMDataGridEditChange, type TMDataGridEditCommitArgs, type TMDataGridEditCommitDraftsArgs, type TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterOperator, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFooterProps, type TMDataGridLabels, type TMDataGridLabelsOverride, TMDataGridMultiSelectEditor, TMDataGridNumberEditor, type TMDataGridOption, type TMDataGridOptionsArgs, type TMDataGridOptionsSource, type TMDataGridPaginationActions, type TMDataGridPaginationApi, type TMDataGridPaginationControls, type TMDataGridPaginationSlotArgs, type TMDataGridPaginationState, type TMDataGridPersistKey, type TMDataGridPersistence, type TMDataGridProps, type TMDataGridQuickSearchMode, type TMDataGridRangeBounds, type TMDataGridRowAddArgs, type TMDataGridRowClickModifiers, type TMDataGridRowContextMenuArgs, type TMDataGridRowContextMenuRenderer, type TMDataGridRowData, type TMDataGridRowDeleteArgs, type TMDataGridRowEditForm, type TMDataGridRowStyle, type TMDataGridRowValidators, type TMDataGridSaveDraftsArgs, type TMDataGridScrollAlign, type TMDataGridScrollToRowArgs, TMDataGridSearch, type TMDataGridSearchProps, TMDataGridSelectEditor, type TMDataGridSelectionMode, type TMDataGridSettingsSlice, type TMDataGridSize, type TMDataGridStorageMode, TMDataGridStringEditor, type TMDataGridTable, type TMDataGridTableMeta, type TMDataGridTableProps, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type UseTMDataGridOptions, aggregateColumn, areAllRowsExpanded, autosizeColumn, boundsCellCount, boundsEdges, buildCellMatrix, buildGridCellMatrix, clearedValueForType, createTMDataGridColumnHelper, downloadTextFile, emptyValueForOperator, exportGridToCsv, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnFilterControl, getColumnLabel, getColumnRegion, getColumnType, getDefaultOperator, getDisplayedRows, getEditFieldName, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, isColumnEditableForRow, isColumnReorderable, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, isSameCell, isWithinBounds, keepGeneratedColumnsOutermost, measureColumnContentWidth, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveCellMove, resolveColumnOptions, resolveExpandAll, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFeatures, toClipboardText, toExcelCsv, useCellControlTabIndex, useTMDataGrid, useTMDataGridContext, writeClipboardText };
|