@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 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 parked row during
192
- * `saveDrafts` - so a draft invalidated by a later edit blocks the save.
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
- * Rows with a live form, committed or not - every row the grid is holding
269
- * work for. A row is *open* (undecided form state) when it is in here and
270
- * not in {@link committedRowIds}.
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 whose form passed its submit
276
- * and is parked, waiting for `saveDrafts`. A subset of `openRowIds` - the
277
- * values stay in the row's form, this records which side of the line the
278
- * row is on. `begin` on one of these takes it back out, into form state.
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` parks. Without it a commit goes straight to the
281
- * consumer and the form is dropped, so this stays empty.
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 `editing.draft` a commit adds through
298
- * `onRowAdd` and the entry is dropped, so it never turns `true`.
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 `FormApi` the inline
524
- * editors write through, so a consumer can render it in a drawer or a detail
525
- * panel and share values, dirty state and errors with the cells.
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
- /** rowId → live form. The source of truth for everything mid-edit. */
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 a form holds one - open or
536
- * parked in the draft store - else what `data` says. `undefined` when no
537
- * such row exists. A deletion mark does not change the answer; check
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, so a drawer
2127
- * or detail panel can share a row's draft. Inert until `editing` is set.
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. */