@trinityui/design-system 2.10.5 → 2.10.7
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 +93 -0
- package/dist/charts.js +3302 -3306
- package/dist/components/DataTable/rowUpdateUtils.d.ts +45 -0
- package/dist/components/DataTable/rowUpdateUtils.d.ts.map +1 -0
- package/dist/data-table2.js +29914 -18965
- package/dist/index.js +29879 -29517
- package/dist/trinity.css +1 -1
- package/package.json +44 -43
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Pure helpers for the DataTable cell-editing update flow.
|
|
3
|
+
* @module components/DataTable/rowUpdateUtils
|
|
4
|
+
*
|
|
5
|
+
* AG Grid mutates the row object in place before firing `cellValueChanged`,
|
|
6
|
+
* so `event.data` already contains the NEW value. To give `onRowUpdate`
|
|
7
|
+
* consumers a usable `oldRow`, the previous row must be reconstructed from
|
|
8
|
+
* the event's `colDef.field` and `oldValue`.
|
|
9
|
+
*
|
|
10
|
+
* Extracted as a pure helper because AG Grid cell editing is impractical to
|
|
11
|
+
* simulate in jsdom; this logic is unit-tested directly instead.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Minimal shape of an AG Grid `CellValueChangedEvent` needed to build the
|
|
15
|
+
* `onRowUpdate` arguments. Structurally compatible with the real event type.
|
|
16
|
+
*/
|
|
17
|
+
export interface CellValueChangeLike<R> {
|
|
18
|
+
/** The row data, already mutated in place with the new cell value. */
|
|
19
|
+
data: R;
|
|
20
|
+
/** The cell value before the edit. */
|
|
21
|
+
oldValue?: unknown;
|
|
22
|
+
/** Column definition of the edited cell. */
|
|
23
|
+
colDef?: {
|
|
24
|
+
field?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Arguments for the `onRowUpdate` callback. */
|
|
28
|
+
export interface RowUpdateArgs<R> {
|
|
29
|
+
/** Fresh copy of the row containing the new value. */
|
|
30
|
+
newRow: R;
|
|
31
|
+
/** Fresh copy of the row with the edited field restored to its previous value. */
|
|
32
|
+
oldRow: R;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds distinct `newRow`/`oldRow` objects for `onRowUpdate` from a
|
|
36
|
+
* cell-value-changed event.
|
|
37
|
+
*
|
|
38
|
+
* - `newRow` is a fresh shallow copy of the (already mutated) row.
|
|
39
|
+
* - `oldRow` is a fresh copy with the edited field reset to `event.oldValue`.
|
|
40
|
+
* - If `colDef.field` is missing, the old value cannot be restored, so
|
|
41
|
+
* `oldRow` falls back to a plain copy of the row; both objects are still
|
|
42
|
+
* distinct from each other and from `event.data`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildRowUpdateArgs<R extends object>(event: CellValueChangeLike<R>): RowUpdateArgs<R>;
|
|
45
|
+
//# sourceMappingURL=rowUpdateUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowUpdateUtils.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/rowUpdateUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,sEAAsE;IACtE,IAAI,EAAE,CAAC,CAAC;IACR,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B;AAED,gDAAgD;AAChD,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,sDAAsD;IACtD,MAAM,EAAE,CAAC,CAAC;IACV,kFAAkF;IAClF,MAAM,EAAE,CAAC,CAAC;CACX;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAQpG"}
|