twico-ui 1.14.0 → 1.15.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/dist/index.d.cts CHANGED
@@ -1742,11 +1742,51 @@ declare function CurrencyField(props: CurrencyFieldProps): React.JSX.Element;
1742
1742
  *
1743
1743
  * @startingPoint section="Data display" subtitle="MUI-style sortable/filterable/pinnable data table" viewport="900x460"
1744
1744
  */
1745
+ /** Op counts returned to `DatatableDiff.onClassified` (and shown in the toolbar summary). */
1746
+ interface DiffSummary {
1747
+ added: number;
1748
+ removed: number;
1749
+ modified: number;
1750
+ moved: number;
1751
+ unchanged: number;
1752
+ }
1753
+
1754
+ /** Diff payload for `Datatable`'s `diff` mode (#239). */
1755
+ interface DatatableDiff<T = any> {
1756
+ /** "before" rows (version A). */
1757
+ from: T[];
1758
+ /** "after" rows (version B). The table's own `rows` is ignored when `diff` is set. */
1759
+ to: T[];
1760
+ /** Stable business key to pair A↔B. Falls back to the table's `rowKey`, then `row.id`. */
1761
+ rowKey?: (row: T) => React.Key;
1762
+ /** Hide unchanged rows (initial state of the built-in toggle). @default true */
1763
+ onlyChanged?: boolean;
1764
+ /** Render the "only changed" toggle in the toolbar. @default true */
1765
+ showToggle?: boolean;
1766
+ /** Render the +added ~modified −removed (+ ⇅ moved) summary badges in the toolbar. @default true */
1767
+ showSummary?: boolean;
1768
+ /** Classify same-value, re-positioned rows as "moved" (LIS-minimal). @default true */
1769
+ moveDetection?: boolean;
1770
+ /** Global equality override; falls back to a column's `compare`, then `===`, then a JSON compare. */
1771
+ compare?: (a: any, b: any, field: string) => boolean;
1772
+ /** Label for the only-changed toggle. @default "Only changed" */
1773
+ toggleLabel?: React.ReactNode;
1774
+ /** Called after classification with the op counts (e.g. to drive an external summary). */
1775
+ onClassified?: (summary: DiffSummary) => void;
1776
+ }
1777
+
1745
1778
  interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivElement>, "rows"> {
1746
1779
  /** Column definitions. */
1747
1780
  columns: DatatableColumn<T>[];
1748
- /** Row objects. In server mode, only the current page's rows. */
1749
- rows: T[];
1781
+ /** Row objects. In server mode, only the current page's rows. Optional (and ignored) when `diff` is set. */
1782
+ rows?: T[];
1783
+ /** Turn the grid into a two-dataset **diff** (#239). When set, the table pairs `diff.from`↔`diff.to`
1784
+ * on a business key, classifies each row added/removed/modified/moved/unchanged, and renders modified
1785
+ * cells as `before → after` — all through this same engine, so density, resize, pin, reorder, sort,
1786
+ * filter, quick-search, grouping, export, virtualization, and pagination apply. A leading "Change"
1787
+ * op-badge column is prepended, and a summary + only-changed toggle appear in the toolbar. `rows`,
1788
+ * `serverMode`, `editMode`, `onRowUpdate`, and `onRowsChange` are ignored in diff mode. */
1789
+ diff?: DatatableDiff<T>;
1750
1790
  /** Show shimmering skeleton rows instead of data. @default false */
1751
1791
  loading?: boolean;
1752
1792
  /** Returns a stable key per row. @default (r,i) => r.id ?? i */
@@ -1762,6 +1802,14 @@ interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivEleme
1762
1802
  /** Restrict the toolbar quick-search to these column `field`s (client mode); defaults to every
1763
1803
  * visible column. Mirrors `runDatatableQuery`'s `options.searchFields`. */
1764
1804
  searchFields?: string[];
1805
+ /** Render the built-in toolbar quick-search box. Set `false` to externalize search — supply your
1806
+ * own input wired to `quickFilter`/`onQuickFilterChange` (mirrors CardGrid). @default true */
1807
+ searchable?: boolean;
1808
+ /** Controlled quick-search string; pair with `onQuickFilterChange` to drive search from outside
1809
+ * (the value still flows into client filtering and the `onServerChange` query). */
1810
+ quickFilter?: string;
1811
+ /** Fires with the new quick-search string as the user types (and when a host sets it). */
1812
+ onQuickFilterChange?: (value: string) => void;
1765
1813
  /**
1766
1814
  * Actions shown in the toolbar when one or more rows are selected (requires
1767
1815
  * `checkboxSelection`). Each handler receives the selected keys, the resolved
@@ -1982,6 +2030,13 @@ interface DatatableColumn<T = any> {
1982
2030
  editable?: boolean;
1983
2031
  /** Editor type. "select" (or any column with `valueOptions`) renders a dropdown; else a text/number input by column type. */
1984
2032
  editType?: "text" | "number" | "select";
2033
+ /** Full escape hatch for the inline cell editor — render your own control (a searchable / creatable /
2034
+ * async `Combobox`, a `MasterCombobox`, …) for a value backed by a large, extensible vocabulary.
2035
+ * Providing it makes the column editable (unless `editable: false`) and takes precedence over the
2036
+ * built-in select/text editor. Call `commit(nextValue)` to save (fires `onRowUpdate`/`onRowsChange`)
2037
+ * or `cancel()` to discard. Twico overlay dropdowns (portaled as `.twc-pop`) are exempt from the
2038
+ * cell's outside-click auto-cancel, so a Combobox popover works inside the cell. */
2039
+ renderEditCell?: (args: { value: any; row: T; field: string; commit: (nextValue: any) => void; cancel: () => void }) => React.ReactNode;
1985
2040
  /** Hide the column header ⋮ menu. @default false */
1986
2041
  disableColumnMenu?: boolean;
1987
2042
  /** Start with this column's cell text wrapped onto multiple lines (the row grows down) instead of
@@ -1998,6 +2053,9 @@ interface DatatableColumn<T = any> {
1998
2053
  valueFormatter?: (value: any, row: T) => React.ReactNode;
1999
2054
  /** Fully custom cell renderer (badges, avatars, etc.). */
2000
2055
  renderCell?: (value: any, row: T) => React.ReactNode;
2056
+ /** Diff-mode (#239) per-column equality override — return true when the two values are equal.
2057
+ * Precedence: column.compare → diff.compare → valueGetter/=== → JSON compare. */
2058
+ compare?: (a: any, b: any) => boolean;
2001
2059
  /** For type:"actions" — returns the row's action items. */
2002
2060
  getActions?: (row: T) => DatatableRowAction<T>[];
2003
2061
  }
package/dist/index.d.ts CHANGED
@@ -1742,11 +1742,51 @@ declare function CurrencyField(props: CurrencyFieldProps): React.JSX.Element;
1742
1742
  *
1743
1743
  * @startingPoint section="Data display" subtitle="MUI-style sortable/filterable/pinnable data table" viewport="900x460"
1744
1744
  */
1745
+ /** Op counts returned to `DatatableDiff.onClassified` (and shown in the toolbar summary). */
1746
+ interface DiffSummary {
1747
+ added: number;
1748
+ removed: number;
1749
+ modified: number;
1750
+ moved: number;
1751
+ unchanged: number;
1752
+ }
1753
+
1754
+ /** Diff payload for `Datatable`'s `diff` mode (#239). */
1755
+ interface DatatableDiff<T = any> {
1756
+ /** "before" rows (version A). */
1757
+ from: T[];
1758
+ /** "after" rows (version B). The table's own `rows` is ignored when `diff` is set. */
1759
+ to: T[];
1760
+ /** Stable business key to pair A↔B. Falls back to the table's `rowKey`, then `row.id`. */
1761
+ rowKey?: (row: T) => React.Key;
1762
+ /** Hide unchanged rows (initial state of the built-in toggle). @default true */
1763
+ onlyChanged?: boolean;
1764
+ /** Render the "only changed" toggle in the toolbar. @default true */
1765
+ showToggle?: boolean;
1766
+ /** Render the +added ~modified −removed (+ ⇅ moved) summary badges in the toolbar. @default true */
1767
+ showSummary?: boolean;
1768
+ /** Classify same-value, re-positioned rows as "moved" (LIS-minimal). @default true */
1769
+ moveDetection?: boolean;
1770
+ /** Global equality override; falls back to a column's `compare`, then `===`, then a JSON compare. */
1771
+ compare?: (a: any, b: any, field: string) => boolean;
1772
+ /** Label for the only-changed toggle. @default "Only changed" */
1773
+ toggleLabel?: React.ReactNode;
1774
+ /** Called after classification with the op counts (e.g. to drive an external summary). */
1775
+ onClassified?: (summary: DiffSummary) => void;
1776
+ }
1777
+
1745
1778
  interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivElement>, "rows"> {
1746
1779
  /** Column definitions. */
1747
1780
  columns: DatatableColumn<T>[];
1748
- /** Row objects. In server mode, only the current page's rows. */
1749
- rows: T[];
1781
+ /** Row objects. In server mode, only the current page's rows. Optional (and ignored) when `diff` is set. */
1782
+ rows?: T[];
1783
+ /** Turn the grid into a two-dataset **diff** (#239). When set, the table pairs `diff.from`↔`diff.to`
1784
+ * on a business key, classifies each row added/removed/modified/moved/unchanged, and renders modified
1785
+ * cells as `before → after` — all through this same engine, so density, resize, pin, reorder, sort,
1786
+ * filter, quick-search, grouping, export, virtualization, and pagination apply. A leading "Change"
1787
+ * op-badge column is prepended, and a summary + only-changed toggle appear in the toolbar. `rows`,
1788
+ * `serverMode`, `editMode`, `onRowUpdate`, and `onRowsChange` are ignored in diff mode. */
1789
+ diff?: DatatableDiff<T>;
1750
1790
  /** Show shimmering skeleton rows instead of data. @default false */
1751
1791
  loading?: boolean;
1752
1792
  /** Returns a stable key per row. @default (r,i) => r.id ?? i */
@@ -1762,6 +1802,14 @@ interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivEleme
1762
1802
  /** Restrict the toolbar quick-search to these column `field`s (client mode); defaults to every
1763
1803
  * visible column. Mirrors `runDatatableQuery`'s `options.searchFields`. */
1764
1804
  searchFields?: string[];
1805
+ /** Render the built-in toolbar quick-search box. Set `false` to externalize search — supply your
1806
+ * own input wired to `quickFilter`/`onQuickFilterChange` (mirrors CardGrid). @default true */
1807
+ searchable?: boolean;
1808
+ /** Controlled quick-search string; pair with `onQuickFilterChange` to drive search from outside
1809
+ * (the value still flows into client filtering and the `onServerChange` query). */
1810
+ quickFilter?: string;
1811
+ /** Fires with the new quick-search string as the user types (and when a host sets it). */
1812
+ onQuickFilterChange?: (value: string) => void;
1765
1813
  /**
1766
1814
  * Actions shown in the toolbar when one or more rows are selected (requires
1767
1815
  * `checkboxSelection`). Each handler receives the selected keys, the resolved
@@ -1982,6 +2030,13 @@ interface DatatableColumn<T = any> {
1982
2030
  editable?: boolean;
1983
2031
  /** Editor type. "select" (or any column with `valueOptions`) renders a dropdown; else a text/number input by column type. */
1984
2032
  editType?: "text" | "number" | "select";
2033
+ /** Full escape hatch for the inline cell editor — render your own control (a searchable / creatable /
2034
+ * async `Combobox`, a `MasterCombobox`, …) for a value backed by a large, extensible vocabulary.
2035
+ * Providing it makes the column editable (unless `editable: false`) and takes precedence over the
2036
+ * built-in select/text editor. Call `commit(nextValue)` to save (fires `onRowUpdate`/`onRowsChange`)
2037
+ * or `cancel()` to discard. Twico overlay dropdowns (portaled as `.twc-pop`) are exempt from the
2038
+ * cell's outside-click auto-cancel, so a Combobox popover works inside the cell. */
2039
+ renderEditCell?: (args: { value: any; row: T; field: string; commit: (nextValue: any) => void; cancel: () => void }) => React.ReactNode;
1985
2040
  /** Hide the column header ⋮ menu. @default false */
1986
2041
  disableColumnMenu?: boolean;
1987
2042
  /** Start with this column's cell text wrapped onto multiple lines (the row grows down) instead of
@@ -1998,6 +2053,9 @@ interface DatatableColumn<T = any> {
1998
2053
  valueFormatter?: (value: any, row: T) => React.ReactNode;
1999
2054
  /** Fully custom cell renderer (badges, avatars, etc.). */
2000
2055
  renderCell?: (value: any, row: T) => React.ReactNode;
2056
+ /** Diff-mode (#239) per-column equality override — return true when the two values are equal.
2057
+ * Precedence: column.compare → diff.compare → valueGetter/=== → JSON compare. */
2058
+ compare?: (a: any, b: any) => boolean;
2001
2059
  /** For type:"actions" — returns the row's action items. */
2002
2060
  getActions?: (row: T) => DatatableRowAction<T>[];
2003
2061
  }