@jielga/tmdatagrid 2.0.0-beta.17 → 2.0.0-beta.18
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 +35 -23
- package/dist/index.js +1336 -1276
- package/dist/index.js.map +1 -1
- package/docs/editing.md +25 -21
- package/docs/editors.md +10 -8
- package/docs/summary-row.md +1 -1
- package/docs/testing.md +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 +1 -1
- package/skills/data/SKILL.md +1 -1
- package/skills/editing/SKILL.md +22 -19
- package/skills/editing/references/editing-api.md +12 -12
- package/skills/editing/references/editors-and-validation.md +8 -7
- 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 +1 -1
- package/skills/rows/SKILL.md +1 -1
- package/skills/server-side/SKILL.md +1 -1
- package/skills/testing/SKILL.md +1 -1
- package/src/components/TMDataGridEntryRows.tsx +12 -5
- package/src/core/editEngine.ts +502 -248
- package/src/useTMDataGrid.tsx +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -188,8 +188,9 @@ type TMDataGridTableValidateArgs<TData extends RowData = TMDataGridRowData> = {
|
|
|
188
188
|
/**
|
|
189
189
|
* `editing.tableValidators` - rules that need the other rows: no duplicate
|
|
190
190
|
* keys, no overlapping ranges, allocations summing to a total. Run at every
|
|
191
|
-
* commit, after the row's own validators, and again per
|
|
192
|
-
* `saveDrafts
|
|
191
|
+
* commit, after the row's own validators, and again per committed row during
|
|
192
|
+
* `saveDrafts`, the only rules that run there - a committed row a later edit
|
|
193
|
+
* invalidated is reopened with the error and the save resolves `false`.
|
|
193
194
|
*
|
|
194
195
|
* Return nothing to pass, a message, or Form's `{ form, fields }` shape;
|
|
195
196
|
* pathed issues land on the committing row's cells, pathless ones on the row.
|
|
@@ -265,20 +266,22 @@ type TMDataGridEditState = {
|
|
|
265
266
|
columnId: string | null;
|
|
266
267
|
} | null;
|
|
267
268
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
269
|
+
* Every row the grid is holding work for: open rows, whose form is still
|
|
270
|
+
* undecided, and committed rows, whose values wait in the draft store. In
|
|
271
|
+
* the order the rows first entered; a reopen keeps a row's place. A row is
|
|
272
|
+
* *open* when it is in here and not in {@link committedRowIds}, or, for an
|
|
273
|
+
* entry row, not flagged `committed` in {@link newRows}.
|
|
271
274
|
*/
|
|
272
275
|
openRowIds: ReadonlyArray<string>;
|
|
273
276
|
rows: Record<string, TMDataGridEditRowProjection>;
|
|
274
277
|
/**
|
|
275
|
-
* The draft store's edit slice: existing rows
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
278
|
+
* The draft store's edit slice: existing rows that passed their commit and
|
|
279
|
+
* wait for `saveDrafts`. A committed row is data, not a form: its values
|
|
280
|
+
* are in {@link committedValues}, and `begin` on one of these builds a
|
|
281
|
+
* fresh form from them and takes the row back out.
|
|
279
282
|
*
|
|
280
|
-
* Only `editing.draft`
|
|
281
|
-
*
|
|
283
|
+
* Only `editing.draft` commits into the store. Without it a commit goes
|
|
284
|
+
* straight to the consumer, so this stays empty.
|
|
282
285
|
*/
|
|
283
286
|
committedRowIds: ReadonlyArray<string>;
|
|
284
287
|
/**
|
|
@@ -294,8 +297,9 @@ type TMDataGridEditState = {
|
|
|
294
297
|
/**
|
|
295
298
|
* Rows being created, not yet in `data`. `committed` is the draft store's
|
|
296
299
|
* add slice: the entry row passed its submit and renders as a value row
|
|
297
|
-
* until `begin` re-opens it. Without
|
|
298
|
-
* `onRowAdd` and the entry is
|
|
300
|
+
* from {@link committedValues} until `begin` re-opens it. Without
|
|
301
|
+
* `editing.draft` a commit adds through `onRowAdd` and the entry is
|
|
302
|
+
* dropped, so it never turns `true`.
|
|
299
303
|
*/
|
|
300
304
|
newRows: ReadonlyArray<{
|
|
301
305
|
tempId: string;
|
|
@@ -520,22 +524,28 @@ type TMDataGridEditRowSnapshot<TData extends RowData = TMDataGridRowData> = {
|
|
|
520
524
|
/**
|
|
521
525
|
* The engine plus its store - `api.edit`.
|
|
522
526
|
*
|
|
523
|
-
* "One row, one form": `getForm` hands out the same
|
|
524
|
-
* editors write through, so a consumer can render it in
|
|
525
|
-
* panel and share values, dirty state and errors with
|
|
527
|
+
* "One row, one form" while a row is open: `getForm` hands out the same
|
|
528
|
+
* `FormApi` the inline editors write through, so a consumer can render it in
|
|
529
|
+
* a drawer or a detail panel and share values, dirty state and errors with
|
|
530
|
+
* the cells. A committed row has no form - it is data in the draft store -
|
|
531
|
+
* so `getForm` returns `undefined` for it until `begin` reopens it.
|
|
526
532
|
*/
|
|
527
533
|
type TMDataGridEditApi<TData extends RowData = TMDataGridRowData> = {
|
|
528
534
|
/** The projection store - subscribe with `useSelector(edit.store, …)`. */
|
|
529
535
|
store: Store<TMDataGridEditState>;
|
|
530
536
|
/** Current snapshot, for reads outside React. */
|
|
531
537
|
readonly state: TMDataGridEditState;
|
|
532
|
-
/**
|
|
538
|
+
/**
|
|
539
|
+
* rowId → the open row's live form, the source of truth for everything
|
|
540
|
+
* mid-edit. `undefined` for a row that is not open, a committed row
|
|
541
|
+
* included; `begin` reopens one.
|
|
542
|
+
*/
|
|
533
543
|
getForm: (rowId: string) => TMDataGridRowEditForm | undefined;
|
|
534
544
|
/**
|
|
535
|
-
* The row as shown: its draft values where
|
|
536
|
-
*
|
|
537
|
-
* such row exists. A deletion mark does not
|
|
538
|
-
* `state.deletedRowIds` for that.
|
|
545
|
+
* The row as shown: its draft values where the grid holds any - an open
|
|
546
|
+
* form's, or the committed values in the draft store - else what `data`
|
|
547
|
+
* says. `undefined` when no such row exists. A deletion mark does not
|
|
548
|
+
* change the answer; check `state.deletedRowIds` for that.
|
|
539
549
|
*/
|
|
540
550
|
getRowValues: (rowId: string) => TData | undefined;
|
|
541
551
|
/**
|
|
@@ -2123,8 +2133,10 @@ type TMDataGridApi<TData extends RowData> = {
|
|
|
2123
2133
|
/**
|
|
2124
2134
|
* The edit engine - open forms, dirty/error projections, and the verbs
|
|
2125
2135
|
* (`begin`, `commit`, `cancel`, `submitAll`). `edit.getForm(rowId)` hands
|
|
2126
|
-
* out the same TanStack Form the inline editors write through
|
|
2127
|
-
* or detail panel can share a row's draft
|
|
2136
|
+
* out the same TanStack Form the inline editors write through while a row
|
|
2137
|
+
* is open, so a drawer or detail panel can share a row's draft; a
|
|
2138
|
+
* committed row has no form until `begin` reopens it. Inert until
|
|
2139
|
+
* `editing` is set.
|
|
2128
2140
|
*/
|
|
2129
2141
|
edit: TMDataGridEditApi<TData>;
|
|
2130
2142
|
/** Table-level feature switches, re-read from options on every render. */
|