eidos-ui 1.1.0 → 2.0.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.
Files changed (38) hide show
  1. package/dist/Table.types-Cl5gR8r9.d.cts +183 -0
  2. package/dist/Table.types-jhPb7JNU.d.ts +183 -0
  3. package/dist/{chunk-A5JVDHML.cjs → chunk-2ZENLZEQ.cjs} +59 -52
  4. package/dist/chunk-2ZENLZEQ.cjs.map +1 -0
  5. package/dist/{chunk-IZBJW37N.js → chunk-AJZTVCST.js} +9 -6
  6. package/dist/chunk-AJZTVCST.js.map +1 -0
  7. package/dist/{chunk-A5LHCAQY.js → chunk-MH2CD2QT.js} +33 -26
  8. package/dist/chunk-MH2CD2QT.js.map +1 -0
  9. package/dist/{chunk-IC2M4N7R.cjs → chunk-QONDJ5VM.cjs} +11 -11
  10. package/dist/chunk-QONDJ5VM.cjs.map +1 -0
  11. package/dist/{chunk-NFIK3KMT.js → chunk-VSFKM7FE.js} +2 -2
  12. package/dist/chunk-VSFKM7FE.js.map +1 -0
  13. package/dist/{chunk-PA4IT2XQ.cjs → chunk-XVSODE4K.cjs} +9 -6
  14. package/dist/chunk-XVSODE4K.cjs.map +1 -0
  15. package/dist/data-grid/index.cjs +4 -3
  16. package/dist/data-grid/index.cjs.map +1 -1
  17. package/dist/data-grid/index.d.cts +129 -48
  18. package/dist/data-grid/index.d.ts +129 -48
  19. package/dist/data-grid/index.js +3 -2
  20. package/dist/index.cjs +4 -4
  21. package/dist/index.css +42 -30
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +3 -3
  25. package/dist/table/index.cjs +4 -3
  26. package/dist/table/index.cjs.map +1 -1
  27. package/dist/table/index.d.cts +5 -5
  28. package/dist/table/index.d.ts +5 -5
  29. package/dist/table/index.js +3 -2
  30. package/package.json +1 -1
  31. package/dist/Table.types-Bv9l7qxd.d.ts +0 -103
  32. package/dist/Table.types-DQ0ReOLj.d.cts +0 -103
  33. package/dist/chunk-A5JVDHML.cjs.map +0 -1
  34. package/dist/chunk-A5LHCAQY.js.map +0 -1
  35. package/dist/chunk-IC2M4N7R.cjs.map +0 -1
  36. package/dist/chunk-IZBJW37N.js.map +0 -1
  37. package/dist/chunk-NFIK3KMT.js.map +0 -1
  38. package/dist/chunk-PA4IT2XQ.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkA5JVDHMLcjs = require('../chunk-A5JVDHML.cjs');
4
- require('../chunk-PA4IT2XQ.cjs');
3
+ var _chunk2ZENLZEQcjs = require('../chunk-2ZENLZEQ.cjs');
4
+ require('../chunk-XVSODE4K.cjs');
5
5
  require('../chunk-TROYIUDH.cjs');
6
6
  require('../chunk-EQEV7GPT.cjs');
7
7
  require('../chunk-ISABZ2VX.cjs');
@@ -18,6 +18,7 @@ require('../chunk-G5IGADJI.cjs');
18
18
  require('../chunk-FMPXSF3H.cjs');
19
19
  require('../chunk-FRUOA2QU.cjs');
20
20
  require('../chunk-KVIL4EP4.cjs');
21
+ require('../chunk-3ETWFS2N.cjs');
21
22
  require('../chunk-EACNRR3C.cjs');
22
23
  require('../chunk-A7Z2QAFZ.cjs');
23
24
  require('../chunk-I6UOIS4J.cjs');
@@ -26,5 +27,5 @@ require('../chunk-Z5U4NJTW.cjs');
26
27
  require('../chunk-DZUJEN5N.cjs');
27
28
 
28
29
 
29
- exports.DataGrid = _chunkA5JVDHMLcjs.DataGrid;
30
+ exports.DataGrid = _chunk2ZENLZEQcjs.DataGrid;
30
31
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/data-grid/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,8CAAC","file":"/home/runner/work/eidos-ui/eidos-ui/dist/data-grid/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/data-grid/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,8CAAC","file":"/home/runner/work/eidos-ui/eidos-ui/dist/data-grid/index.cjs"}
@@ -1,16 +1,18 @@
1
1
  import React__default from 'react';
2
2
  import { I as IconType } from '../renderIcon-C2lEMMzb.cjs';
3
+ import { R as RowKey, e as TableFilters, B as BulkAction } from '../Table.types-Cl5gR8r9.cjs';
4
+ export { a as BulkActionButton, b as BulkActionSplitButton, c as BulkActionSplitOption } from '../Table.types-Cl5gR8r9.cjs';
3
5
  import { C as ComboboxOption } from '../Combobox.types-B7ozlnA9.cjs';
4
6
  import { b as MenuItemType } from '../Menu.types-DwcuCZM7.cjs';
5
7
  import { S as SelectOption } from '../Select.types-CAkT2ACt.cjs';
6
8
  import { b as SegmentedOption, S as SegmentedControlColorProps } from '../SegmentedControl.types-Dm4SnwCK.cjs';
7
- import { d as TableFilters, B as BulkAction } from '../Table.types-DQ0ReOLj.cjs';
8
- export { a as BulkActionButton, b as BulkActionSplitButton, c as BulkActionSplitOption } from '../Table.types-DQ0ReOLj.cjs';
9
+ import '../Button.types-DZRCVqyN.cjs';
9
10
  import '../sizes-DM6Rrrgq.cjs';
10
11
  import '../Input.types-DFZNyJGF.cjs';
11
- import '../Button.types-DZRCVqyN.cjs';
12
12
 
13
- type DataGridCellType = 'text' | 'number' | 'select' | 'checkbox' | 'date' | 'readonly' | 'actions';
13
+ type DataGridCellType = 'text' | 'number' | 'select' | 'checkbox' | 'date' | 'readonly' | 'custom' | 'actions';
14
+ /** Cell types that address a row field, i.e. everything but the two escape hatches. */
15
+ type DataGridValueCellType = Exclude<DataGridCellType, 'custom' | 'actions'>;
14
16
  interface DataGridSelectOption {
15
17
  value: string;
16
18
  label: string;
@@ -22,9 +24,15 @@ interface DataGridSelectOption {
22
24
  * field (including ones you don't display), without hunting through column
23
25
  * definitions to find which ones set a filter flag.
24
26
  */
25
- interface DataGridFilterField {
26
- /** Row data key this filter reads/writes. Does not need to match a `columns` entry. */
27
- key: string;
27
+ interface DataGridFilterField<T extends object = Record<string, unknown>> {
28
+ /**
29
+ * Row data key this filter reads/writes. Does not need to match a `columns`
30
+ * entry - the decoupling from `columns` is intact, so filtering an
31
+ * undisplayed field still works. It does have to be a real field of `T`,
32
+ * because the filter evaluates `row[key]`: a name that isn't on the row
33
+ * type used to compile fine and then silently match nothing.
34
+ */
35
+ key: RowKey<T>;
28
36
  label: string;
29
37
  /** Filter UI type. @default 'text' */
30
38
  filterType?: 'text' | 'select' | 'date' | 'boolean';
@@ -40,9 +48,12 @@ interface DataGridFilterField {
40
48
  type DataGridQuickFilterSelectOption = Omit<SelectOption, 'id'>;
41
49
  type DataGridQuickFilterComboboxOption = Omit<ComboboxOption, 'id'>;
42
50
  type DataGridQuickFilterSegmentedOption = SegmentedOption;
43
- interface DataGridQuickFilterBase {
44
- /** Row data key this filter reads/writes. Does not need to match a `columns` entry. */
45
- key: string;
51
+ interface DataGridQuickFilterBase<T extends object = Record<string, unknown>> {
52
+ /**
53
+ * Row data key this filter reads/writes. Does not need to match a `columns`
54
+ * entry, but must be a real field of `T` - the filter evaluates `row[key]`.
55
+ */
56
+ key: RowKey<T>;
46
57
  /**
47
58
  * Short label for the control. The toolbar has no room for a visible field
48
59
  * label, so this is used as the control's placeholder and its accessible
@@ -63,7 +74,7 @@ interface DataGridQuickFilterBase {
63
74
  */
64
75
  defaultValue?: string | string[];
65
76
  }
66
- interface DataGridQuickFilterSelect extends DataGridQuickFilterBase {
77
+ interface DataGridQuickFilterSelect<T extends object = Record<string, unknown>> extends DataGridQuickFilterBase<T> {
67
78
  type: 'select';
68
79
  options: DataGridQuickFilterSelectOption[];
69
80
  /** Select several values at once - writes a `string[]` filter value. @default false */
@@ -73,7 +84,7 @@ interface DataGridQuickFilterSelect extends DataGridQuickFilterBase {
73
84
  /** Defaults to `label`. */
74
85
  placeholder?: string;
75
86
  }
76
- interface DataGridQuickFilterCombobox extends DataGridQuickFilterBase {
87
+ interface DataGridQuickFilterCombobox<T extends object = Record<string, unknown>> extends DataGridQuickFilterBase<T> {
77
88
  type: 'combobox';
78
89
  /** Optional so options can be supplied asynchronously via `onSearch`. */
79
90
  options?: DataGridQuickFilterComboboxOption[];
@@ -87,7 +98,7 @@ interface DataGridQuickFilterCombobox extends DataGridQuickFilterBase {
87
98
  loading?: boolean;
88
99
  loadingText?: string;
89
100
  }
90
- interface DataGridQuickFilterSegmented extends DataGridQuickFilterBase {
101
+ interface DataGridQuickFilterSegmented<T extends object = Record<string, unknown>> extends DataGridQuickFilterBase<T> {
91
102
  type: 'segmented';
92
103
  /**
93
104
  * Rendered after the reset segment, which the grid always prepends - a
@@ -104,7 +115,7 @@ interface DataGridQuickFilterSegmented extends DataGridQuickFilterBase {
104
115
  * `DataGridProps.quickFilters`. Discriminated on `type`, so each control only
105
116
  * accepts the props that actually apply to it.
106
117
  */
107
- type DataGridQuickFilter = DataGridQuickFilterSelect | DataGridQuickFilterCombobox | DataGridQuickFilterSegmented;
118
+ type DataGridQuickFilter<T extends object = Record<string, unknown>> = DataGridQuickFilterSelect<T> | DataGridQuickFilterCombobox<T> | DataGridQuickFilterSegmented<T>;
108
119
  /** A single entry in a `type: 'actions'` column's menu - see `DataGridColumn.actions`. */
109
120
  interface DataGridRowAction<T = Record<string, unknown>> {
110
121
  /** Defaults to `label` if omitted - only needs to be unique within this column's `actions`. */
@@ -118,14 +129,49 @@ interface DataGridRowAction<T = Record<string, unknown>> {
118
129
  /** Renders a separator directly above this item. */
119
130
  divider?: boolean;
120
131
  }
121
- interface DataGridColumn<T = Record<string, unknown>> {
122
- /** Matches the key in the data row object. Unused when `type: 'actions'`, but still required - any placeholder string works. */
123
- key: string;
132
+ /** Members every column variant shares, whether or not it addresses a row field. */
133
+ interface DataGridColumnCommon {
124
134
  header: string;
125
- /** @default 'text' */
126
- type?: DataGridCellType;
127
135
  width?: number | string;
128
136
  minWidth?: number | string;
137
+ /** Enable click-to-sort on this column */
138
+ sortable?: boolean;
139
+ /**
140
+ * Horizontal alignment of this column's header and cell content - same
141
+ * values as `TableColumn.align`. Applies in table mode only: card view
142
+ * renders each field as a label above its value, where aligning the value
143
+ * away from its own label reads as a misalignment rather than a choice.
144
+ * Typically `'right'` for numeric columns.
145
+ * @default 'left'
146
+ */
147
+ align?: 'left' | 'center' | 'right';
148
+ /** Lock this column to the left or right edge on horizontal scroll */
149
+ pin?: 'left' | 'right';
150
+ /**
151
+ * Render this column's value as the card's title instead of a label:value
152
+ * field row. Only the first column with `cardHeader` set is used - if
153
+ * several are marked, the rest are silently ignored.
154
+ */
155
+ cardHeader?: boolean;
156
+ /**
157
+ * Render this column's value as the card's subtitle, directly under the
158
+ * `cardHeader` value. Only the first column with `cardSubheader` set is
159
+ * used. Has no effect without a `cardHeader` column also being set.
160
+ */
161
+ cardSubheader?: boolean;
162
+ }
163
+ /**
164
+ * A column bound to the row field named by `key`, which is what makes `value`
165
+ * knowable: every callback below receives `T[K]` rather than `unknown`.
166
+ *
167
+ * Not used directly - `DataGridColumn` distributes this over `keyof T` so each
168
+ * entry in a `columns` array correlates its own `key` with its own value type.
169
+ */
170
+ interface DataGridValueColumn<T extends object, K extends RowKey<T>> extends DataGridColumnCommon {
171
+ /** Matches the key in the data row object. */
172
+ key: K;
173
+ /** @default 'text' */
174
+ type?: DataGridValueCellType;
129
175
  /** @default true */
130
176
  editable?: boolean;
131
177
  /** Show error if cell is left empty */
@@ -133,13 +179,41 @@ interface DataGridColumn<T = Record<string, unknown>> {
133
179
  /** For type='select' */
134
180
  options?: DataGridSelectOption[];
135
181
  /** Return an error string or `true` if valid */
136
- validate?: (value: unknown) => string | true;
137
- renderCell?: (value: unknown, row: T, rowIndex: number) => React__default.ReactNode;
138
- renderEditor?: (value: unknown, onChange: (v: unknown) => void, row: T) => React__default.ReactNode;
139
- /** Enable click-to-sort on this column */
140
- sortable?: boolean;
141
- /** Lock this column to the left or right edge on horizontal scroll */
142
- pin?: 'left' | 'right';
182
+ validate?: (value: T[K]) => string | true;
183
+ renderCell?: (value: T[K], row: T, rowIndex: number) => React__default.ReactNode;
184
+ renderEditor?: (value: T[K], onChange: (v: T[K]) => void, row: T) => React__default.ReactNode;
185
+ }
186
+ /**
187
+ * A column that renders from the whole row rather than one field - a computed
188
+ * or composite value (`${row.first} ${row.last}`), a link, a status derived
189
+ * from several fields. `key` is free-form here because nothing reads
190
+ * `row[key]`: it's only an identity for React keys, sorting and `data-col-key`.
191
+ *
192
+ * This is the home for what used to be expressible by pointing `key` at a
193
+ * field that didn't exist. Not editable - there is no single field to write
194
+ * back to - so `editable`, `required`, `validate` and `renderEditor` are all
195
+ * absent by design.
196
+ */
197
+ interface DataGridCustomColumn<T extends object> extends DataGridColumnCommon {
198
+ /** Free-form - must only be unique within `columns`. */
199
+ key: string;
200
+ type: 'custom';
201
+ /**
202
+ * Required: a custom column has no field to fall back to rendering.
203
+ * `value` is always `undefined` and exists only to keep the parameter list
204
+ * aligned with `DataGridValueColumn.renderCell`, so `(_, row) => ...` reads
205
+ * the same on both.
206
+ */
207
+ renderCell: (value: undefined, row: T, rowIndex: number) => React__default.ReactNode;
208
+ }
209
+ /**
210
+ * The row-actions column. Addresses no field, so it needs no `key` at all -
211
+ * previously this had to carry a required placeholder string that nothing read.
212
+ */
213
+ interface DataGridActionsColumn<T extends object> extends DataGridColumnCommon {
214
+ /** Optional, and unused - only ever an identity for React keys. */
215
+ key?: string;
216
+ type: 'actions';
143
217
  /**
144
218
  * The menu items shown for this row. Required for the column to render
145
219
  * anything - a `type: 'actions'` column with no `actions` renders nothing.
@@ -160,24 +234,31 @@ interface DataGridColumn<T = Record<string, unknown>> {
160
234
  * ignored.
161
235
  */
162
236
  renderActions?: (row: T, index: number) => MenuItemType[];
163
- /**
164
- * Render this column's value as the card's title instead of a label:value
165
- * field row. Only the first column with `cardHeader` set is used - if
166
- * several are marked, the rest are silently ignored.
167
- */
168
- cardHeader?: boolean;
169
- /**
170
- * Render this column's value as the card's subtitle, directly under the
171
- * `cardHeader` value. Only the first column with `cardSubheader` set is
172
- * used. Has no effect without a `cardHeader` column also being set.
173
- */
174
- cardSubheader?: boolean;
175
237
  }
176
- interface DataGridProps<T extends Record<string, unknown> = Record<string, unknown>> {
238
+ /**
239
+ * One column definition. A union of three variants, discriminated on `type`:
240
+ *
241
+ * - **value column** (default, `type` omitted or a cell type) - `key` must be a
242
+ * field of `T`, and `renderCell`/`renderEditor`/`validate` receive that
243
+ * field's type instead of `unknown`.
244
+ * - **`type: 'custom'`** - renders from the whole row; `key` is free-form.
245
+ * - **`type: 'actions'`** - the row-actions menu; `key` is optional.
246
+ *
247
+ * The value variant is produced by distributing over `RowKey<T>`, which is
248
+ * what correlates `key` with the value type. Note this keeps a single public
249
+ * type parameter, so no consumer signature changes.
250
+ *
251
+ * With the untyped default `T`, `RowKey<T>` is `string` and `T[K]` is
252
+ * `unknown`, which is byte-identical to the pre-2.0 behaviour.
253
+ */
254
+ type DataGridColumn<T extends object = Record<string, unknown>> = {
255
+ [K in RowKey<T>]: DataGridValueColumn<T, K>;
256
+ }[RowKey<T>] | DataGridCustomColumn<T> | DataGridActionsColumn<T>;
257
+ interface DataGridProps<T extends object = Record<string, unknown>> {
177
258
  columns: DataGridColumn<T>[];
178
259
  data: T[];
179
260
  /** Field name used as React key. @default 'id' */
180
- rowKey?: string;
261
+ rowKey?: RowKey<T>;
181
262
  /** Called after each cell commit with the full updated dataset */
182
263
  onChange?: (data: T[]) => void;
183
264
  /** Returns a blank row object; if omitted, no Add-row button is shown */
@@ -197,11 +278,11 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
197
278
  onRowReorder?: (newData: T[]) => void;
198
279
  /** Controlled sort state. When provided, component is in server-side sort mode. */
199
280
  currentSort?: {
200
- key: string;
281
+ key: RowKey<T>;
201
282
  direction: 'asc' | 'desc';
202
283
  };
203
284
  /** Server-side sort callback. When omitted, sorting is handled client-side. */
204
- onSortChange?: (key: string, direction: 'asc' | 'desc') => void;
285
+ onSortChange?: (key: RowKey<T>, direction: 'asc' | 'desc') => void;
205
286
  /** Show the filter button in the toolbar. */
206
287
  showFilters?: boolean;
207
288
  /**
@@ -210,7 +291,7 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
210
291
  * (including ones that aren't rendered as a column at all), rather than
211
292
  * columns each carrying their own filter flag.
212
293
  */
213
- filterConfig?: DataGridFilterField[];
294
+ filterConfig?: DataGridFilterField<T>[];
214
295
  /** Controlled filter state (the current values, keyed by `filterConfig[].key`). When provided with onFiltersChange → server-side mode. */
215
296
  filters?: TableFilters;
216
297
  /** Filter change callback. When omitted, filtering is handled client-side. */
@@ -230,7 +311,7 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
230
311
  * Hidden while rows are selected - the selection count and bulk actions
231
312
  * occupy the same toolbar zone.
232
313
  */
233
- quickFilters?: DataGridQuickFilter[];
314
+ quickFilters?: DataGridQuickFilter<T>[];
234
315
  showPagination?: boolean;
235
316
  /** @default 10 */
236
317
  pageSize?: number;
@@ -303,14 +384,14 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
303
384
  */
304
385
  cardMinWidth?: number;
305
386
  }
306
- type EditingCell = {
387
+ type EditingCell<T extends object = Record<string, unknown>> = {
307
388
  rowIndex: number;
308
- colKey: string;
389
+ colKey: RowKey<T>;
309
390
  } | null;
310
391
 
311
- declare function DataGridInner<T extends Record<string, unknown>>({ columns, data, rowKey, onChange, onRowAdd, editable, loading, emptyText, className, stickyHeader, maxHeight, showRowNumbers, draggableRows, onRowReorder, currentSort, onSortChange, showFilters, filterConfig, filters, onFiltersChange, quickFilters, showPagination, pageSize, pageSizeOptions, totalRows: totalRowsProp, onPageChange, selectable, selectedRows: controlledSelectedRows, defaultSelectedRows, onSelectionChange, bulkActions, expandable, renderExpandedContent, isRowExpandable, expandMultiple, expandedRows: controlledExpandedRows, defaultExpandedRows, onExpandedRowsChange, density, showDensity, hasCardView, cardViewBreakpoint, cardMinWidth, }: DataGridProps<T>): React__default.ReactElement;
392
+ declare function DataGridInner<T extends object>({ columns: columnsProp, data, rowKey, onChange, onRowAdd, editable, loading, emptyText, className, stickyHeader, maxHeight, showRowNumbers, draggableRows, onRowReorder, currentSort, onSortChange, showFilters, filterConfig, filters, onFiltersChange, quickFilters, showPagination, pageSize, pageSizeOptions, totalRows: totalRowsProp, onPageChange, selectable, selectedRows: controlledSelectedRows, defaultSelectedRows, onSelectionChange, bulkActions, expandable, renderExpandedContent, isRowExpandable, expandMultiple, expandedRows: controlledExpandedRows, defaultExpandedRows, onExpandedRowsChange, density, showDensity, hasCardView, cardViewBreakpoint, cardMinWidth, }: DataGridProps<T>): React__default.ReactElement;
312
393
  declare const DataGrid: typeof DataGridInner & {
313
394
  displayName: string;
314
395
  };
315
396
 
316
- export { BulkAction, DataGrid, type DataGridCellType, type DataGridColumn, type DataGridFilterField, type DataGridProps, type DataGridQuickFilter, type DataGridQuickFilterCombobox, type DataGridQuickFilterComboboxOption, type DataGridQuickFilterSegmented, type DataGridQuickFilterSegmentedOption, type DataGridQuickFilterSelect, type DataGridQuickFilterSelectOption, type DataGridRowAction, type DataGridSelectOption, type EditingCell };
397
+ export { BulkAction, DataGrid, type DataGridActionsColumn, type DataGridCellType, type DataGridColumn, type DataGridCustomColumn, type DataGridFilterField, type DataGridProps, type DataGridQuickFilter, type DataGridQuickFilterCombobox, type DataGridQuickFilterComboboxOption, type DataGridQuickFilterSegmented, type DataGridQuickFilterSegmentedOption, type DataGridQuickFilterSelect, type DataGridQuickFilterSelectOption, type DataGridRowAction, type DataGridSelectOption, type DataGridValueCellType, type DataGridValueColumn, type EditingCell };
@@ -1,16 +1,18 @@
1
1
  import React__default from 'react';
2
2
  import { I as IconType } from '../renderIcon-C2lEMMzb.js';
3
+ import { R as RowKey, e as TableFilters, B as BulkAction } from '../Table.types-jhPb7JNU.js';
4
+ export { a as BulkActionButton, b as BulkActionSplitButton, c as BulkActionSplitOption } from '../Table.types-jhPb7JNU.js';
3
5
  import { C as ComboboxOption } from '../Combobox.types-DkigkEh2.js';
4
6
  import { b as MenuItemType } from '../Menu.types-DNIpjSAK.js';
5
7
  import { S as SelectOption } from '../Select.types-B4kDpkGB.js';
6
8
  import { b as SegmentedOption, S as SegmentedControlColorProps } from '../SegmentedControl.types-CK8EiShd.js';
7
- import { d as TableFilters, B as BulkAction } from '../Table.types-Bv9l7qxd.js';
8
- export { a as BulkActionButton, b as BulkActionSplitButton, c as BulkActionSplitOption } from '../Table.types-Bv9l7qxd.js';
9
+ import '../Button.types-BH0CPyPx.js';
9
10
  import '../sizes-DM6Rrrgq.js';
10
11
  import '../Input.types-XrJTI0JC.js';
11
- import '../Button.types-BH0CPyPx.js';
12
12
 
13
- type DataGridCellType = 'text' | 'number' | 'select' | 'checkbox' | 'date' | 'readonly' | 'actions';
13
+ type DataGridCellType = 'text' | 'number' | 'select' | 'checkbox' | 'date' | 'readonly' | 'custom' | 'actions';
14
+ /** Cell types that address a row field, i.e. everything but the two escape hatches. */
15
+ type DataGridValueCellType = Exclude<DataGridCellType, 'custom' | 'actions'>;
14
16
  interface DataGridSelectOption {
15
17
  value: string;
16
18
  label: string;
@@ -22,9 +24,15 @@ interface DataGridSelectOption {
22
24
  * field (including ones you don't display), without hunting through column
23
25
  * definitions to find which ones set a filter flag.
24
26
  */
25
- interface DataGridFilterField {
26
- /** Row data key this filter reads/writes. Does not need to match a `columns` entry. */
27
- key: string;
27
+ interface DataGridFilterField<T extends object = Record<string, unknown>> {
28
+ /**
29
+ * Row data key this filter reads/writes. Does not need to match a `columns`
30
+ * entry - the decoupling from `columns` is intact, so filtering an
31
+ * undisplayed field still works. It does have to be a real field of `T`,
32
+ * because the filter evaluates `row[key]`: a name that isn't on the row
33
+ * type used to compile fine and then silently match nothing.
34
+ */
35
+ key: RowKey<T>;
28
36
  label: string;
29
37
  /** Filter UI type. @default 'text' */
30
38
  filterType?: 'text' | 'select' | 'date' | 'boolean';
@@ -40,9 +48,12 @@ interface DataGridFilterField {
40
48
  type DataGridQuickFilterSelectOption = Omit<SelectOption, 'id'>;
41
49
  type DataGridQuickFilterComboboxOption = Omit<ComboboxOption, 'id'>;
42
50
  type DataGridQuickFilterSegmentedOption = SegmentedOption;
43
- interface DataGridQuickFilterBase {
44
- /** Row data key this filter reads/writes. Does not need to match a `columns` entry. */
45
- key: string;
51
+ interface DataGridQuickFilterBase<T extends object = Record<string, unknown>> {
52
+ /**
53
+ * Row data key this filter reads/writes. Does not need to match a `columns`
54
+ * entry, but must be a real field of `T` - the filter evaluates `row[key]`.
55
+ */
56
+ key: RowKey<T>;
46
57
  /**
47
58
  * Short label for the control. The toolbar has no room for a visible field
48
59
  * label, so this is used as the control's placeholder and its accessible
@@ -63,7 +74,7 @@ interface DataGridQuickFilterBase {
63
74
  */
64
75
  defaultValue?: string | string[];
65
76
  }
66
- interface DataGridQuickFilterSelect extends DataGridQuickFilterBase {
77
+ interface DataGridQuickFilterSelect<T extends object = Record<string, unknown>> extends DataGridQuickFilterBase<T> {
67
78
  type: 'select';
68
79
  options: DataGridQuickFilterSelectOption[];
69
80
  /** Select several values at once - writes a `string[]` filter value. @default false */
@@ -73,7 +84,7 @@ interface DataGridQuickFilterSelect extends DataGridQuickFilterBase {
73
84
  /** Defaults to `label`. */
74
85
  placeholder?: string;
75
86
  }
76
- interface DataGridQuickFilterCombobox extends DataGridQuickFilterBase {
87
+ interface DataGridQuickFilterCombobox<T extends object = Record<string, unknown>> extends DataGridQuickFilterBase<T> {
77
88
  type: 'combobox';
78
89
  /** Optional so options can be supplied asynchronously via `onSearch`. */
79
90
  options?: DataGridQuickFilterComboboxOption[];
@@ -87,7 +98,7 @@ interface DataGridQuickFilterCombobox extends DataGridQuickFilterBase {
87
98
  loading?: boolean;
88
99
  loadingText?: string;
89
100
  }
90
- interface DataGridQuickFilterSegmented extends DataGridQuickFilterBase {
101
+ interface DataGridQuickFilterSegmented<T extends object = Record<string, unknown>> extends DataGridQuickFilterBase<T> {
91
102
  type: 'segmented';
92
103
  /**
93
104
  * Rendered after the reset segment, which the grid always prepends - a
@@ -104,7 +115,7 @@ interface DataGridQuickFilterSegmented extends DataGridQuickFilterBase {
104
115
  * `DataGridProps.quickFilters`. Discriminated on `type`, so each control only
105
116
  * accepts the props that actually apply to it.
106
117
  */
107
- type DataGridQuickFilter = DataGridQuickFilterSelect | DataGridQuickFilterCombobox | DataGridQuickFilterSegmented;
118
+ type DataGridQuickFilter<T extends object = Record<string, unknown>> = DataGridQuickFilterSelect<T> | DataGridQuickFilterCombobox<T> | DataGridQuickFilterSegmented<T>;
108
119
  /** A single entry in a `type: 'actions'` column's menu - see `DataGridColumn.actions`. */
109
120
  interface DataGridRowAction<T = Record<string, unknown>> {
110
121
  /** Defaults to `label` if omitted - only needs to be unique within this column's `actions`. */
@@ -118,14 +129,49 @@ interface DataGridRowAction<T = Record<string, unknown>> {
118
129
  /** Renders a separator directly above this item. */
119
130
  divider?: boolean;
120
131
  }
121
- interface DataGridColumn<T = Record<string, unknown>> {
122
- /** Matches the key in the data row object. Unused when `type: 'actions'`, but still required - any placeholder string works. */
123
- key: string;
132
+ /** Members every column variant shares, whether or not it addresses a row field. */
133
+ interface DataGridColumnCommon {
124
134
  header: string;
125
- /** @default 'text' */
126
- type?: DataGridCellType;
127
135
  width?: number | string;
128
136
  minWidth?: number | string;
137
+ /** Enable click-to-sort on this column */
138
+ sortable?: boolean;
139
+ /**
140
+ * Horizontal alignment of this column's header and cell content - same
141
+ * values as `TableColumn.align`. Applies in table mode only: card view
142
+ * renders each field as a label above its value, where aligning the value
143
+ * away from its own label reads as a misalignment rather than a choice.
144
+ * Typically `'right'` for numeric columns.
145
+ * @default 'left'
146
+ */
147
+ align?: 'left' | 'center' | 'right';
148
+ /** Lock this column to the left or right edge on horizontal scroll */
149
+ pin?: 'left' | 'right';
150
+ /**
151
+ * Render this column's value as the card's title instead of a label:value
152
+ * field row. Only the first column with `cardHeader` set is used - if
153
+ * several are marked, the rest are silently ignored.
154
+ */
155
+ cardHeader?: boolean;
156
+ /**
157
+ * Render this column's value as the card's subtitle, directly under the
158
+ * `cardHeader` value. Only the first column with `cardSubheader` set is
159
+ * used. Has no effect without a `cardHeader` column also being set.
160
+ */
161
+ cardSubheader?: boolean;
162
+ }
163
+ /**
164
+ * A column bound to the row field named by `key`, which is what makes `value`
165
+ * knowable: every callback below receives `T[K]` rather than `unknown`.
166
+ *
167
+ * Not used directly - `DataGridColumn` distributes this over `keyof T` so each
168
+ * entry in a `columns` array correlates its own `key` with its own value type.
169
+ */
170
+ interface DataGridValueColumn<T extends object, K extends RowKey<T>> extends DataGridColumnCommon {
171
+ /** Matches the key in the data row object. */
172
+ key: K;
173
+ /** @default 'text' */
174
+ type?: DataGridValueCellType;
129
175
  /** @default true */
130
176
  editable?: boolean;
131
177
  /** Show error if cell is left empty */
@@ -133,13 +179,41 @@ interface DataGridColumn<T = Record<string, unknown>> {
133
179
  /** For type='select' */
134
180
  options?: DataGridSelectOption[];
135
181
  /** Return an error string or `true` if valid */
136
- validate?: (value: unknown) => string | true;
137
- renderCell?: (value: unknown, row: T, rowIndex: number) => React__default.ReactNode;
138
- renderEditor?: (value: unknown, onChange: (v: unknown) => void, row: T) => React__default.ReactNode;
139
- /** Enable click-to-sort on this column */
140
- sortable?: boolean;
141
- /** Lock this column to the left or right edge on horizontal scroll */
142
- pin?: 'left' | 'right';
182
+ validate?: (value: T[K]) => string | true;
183
+ renderCell?: (value: T[K], row: T, rowIndex: number) => React__default.ReactNode;
184
+ renderEditor?: (value: T[K], onChange: (v: T[K]) => void, row: T) => React__default.ReactNode;
185
+ }
186
+ /**
187
+ * A column that renders from the whole row rather than one field - a computed
188
+ * or composite value (`${row.first} ${row.last}`), a link, a status derived
189
+ * from several fields. `key` is free-form here because nothing reads
190
+ * `row[key]`: it's only an identity for React keys, sorting and `data-col-key`.
191
+ *
192
+ * This is the home for what used to be expressible by pointing `key` at a
193
+ * field that didn't exist. Not editable - there is no single field to write
194
+ * back to - so `editable`, `required`, `validate` and `renderEditor` are all
195
+ * absent by design.
196
+ */
197
+ interface DataGridCustomColumn<T extends object> extends DataGridColumnCommon {
198
+ /** Free-form - must only be unique within `columns`. */
199
+ key: string;
200
+ type: 'custom';
201
+ /**
202
+ * Required: a custom column has no field to fall back to rendering.
203
+ * `value` is always `undefined` and exists only to keep the parameter list
204
+ * aligned with `DataGridValueColumn.renderCell`, so `(_, row) => ...` reads
205
+ * the same on both.
206
+ */
207
+ renderCell: (value: undefined, row: T, rowIndex: number) => React__default.ReactNode;
208
+ }
209
+ /**
210
+ * The row-actions column. Addresses no field, so it needs no `key` at all -
211
+ * previously this had to carry a required placeholder string that nothing read.
212
+ */
213
+ interface DataGridActionsColumn<T extends object> extends DataGridColumnCommon {
214
+ /** Optional, and unused - only ever an identity for React keys. */
215
+ key?: string;
216
+ type: 'actions';
143
217
  /**
144
218
  * The menu items shown for this row. Required for the column to render
145
219
  * anything - a `type: 'actions'` column with no `actions` renders nothing.
@@ -160,24 +234,31 @@ interface DataGridColumn<T = Record<string, unknown>> {
160
234
  * ignored.
161
235
  */
162
236
  renderActions?: (row: T, index: number) => MenuItemType[];
163
- /**
164
- * Render this column's value as the card's title instead of a label:value
165
- * field row. Only the first column with `cardHeader` set is used - if
166
- * several are marked, the rest are silently ignored.
167
- */
168
- cardHeader?: boolean;
169
- /**
170
- * Render this column's value as the card's subtitle, directly under the
171
- * `cardHeader` value. Only the first column with `cardSubheader` set is
172
- * used. Has no effect without a `cardHeader` column also being set.
173
- */
174
- cardSubheader?: boolean;
175
237
  }
176
- interface DataGridProps<T extends Record<string, unknown> = Record<string, unknown>> {
238
+ /**
239
+ * One column definition. A union of three variants, discriminated on `type`:
240
+ *
241
+ * - **value column** (default, `type` omitted or a cell type) - `key` must be a
242
+ * field of `T`, and `renderCell`/`renderEditor`/`validate` receive that
243
+ * field's type instead of `unknown`.
244
+ * - **`type: 'custom'`** - renders from the whole row; `key` is free-form.
245
+ * - **`type: 'actions'`** - the row-actions menu; `key` is optional.
246
+ *
247
+ * The value variant is produced by distributing over `RowKey<T>`, which is
248
+ * what correlates `key` with the value type. Note this keeps a single public
249
+ * type parameter, so no consumer signature changes.
250
+ *
251
+ * With the untyped default `T`, `RowKey<T>` is `string` and `T[K]` is
252
+ * `unknown`, which is byte-identical to the pre-2.0 behaviour.
253
+ */
254
+ type DataGridColumn<T extends object = Record<string, unknown>> = {
255
+ [K in RowKey<T>]: DataGridValueColumn<T, K>;
256
+ }[RowKey<T>] | DataGridCustomColumn<T> | DataGridActionsColumn<T>;
257
+ interface DataGridProps<T extends object = Record<string, unknown>> {
177
258
  columns: DataGridColumn<T>[];
178
259
  data: T[];
179
260
  /** Field name used as React key. @default 'id' */
180
- rowKey?: string;
261
+ rowKey?: RowKey<T>;
181
262
  /** Called after each cell commit with the full updated dataset */
182
263
  onChange?: (data: T[]) => void;
183
264
  /** Returns a blank row object; if omitted, no Add-row button is shown */
@@ -197,11 +278,11 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
197
278
  onRowReorder?: (newData: T[]) => void;
198
279
  /** Controlled sort state. When provided, component is in server-side sort mode. */
199
280
  currentSort?: {
200
- key: string;
281
+ key: RowKey<T>;
201
282
  direction: 'asc' | 'desc';
202
283
  };
203
284
  /** Server-side sort callback. When omitted, sorting is handled client-side. */
204
- onSortChange?: (key: string, direction: 'asc' | 'desc') => void;
285
+ onSortChange?: (key: RowKey<T>, direction: 'asc' | 'desc') => void;
205
286
  /** Show the filter button in the toolbar. */
206
287
  showFilters?: boolean;
207
288
  /**
@@ -210,7 +291,7 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
210
291
  * (including ones that aren't rendered as a column at all), rather than
211
292
  * columns each carrying their own filter flag.
212
293
  */
213
- filterConfig?: DataGridFilterField[];
294
+ filterConfig?: DataGridFilterField<T>[];
214
295
  /** Controlled filter state (the current values, keyed by `filterConfig[].key`). When provided with onFiltersChange → server-side mode. */
215
296
  filters?: TableFilters;
216
297
  /** Filter change callback. When omitted, filtering is handled client-side. */
@@ -230,7 +311,7 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
230
311
  * Hidden while rows are selected - the selection count and bulk actions
231
312
  * occupy the same toolbar zone.
232
313
  */
233
- quickFilters?: DataGridQuickFilter[];
314
+ quickFilters?: DataGridQuickFilter<T>[];
234
315
  showPagination?: boolean;
235
316
  /** @default 10 */
236
317
  pageSize?: number;
@@ -303,14 +384,14 @@ interface DataGridProps<T extends Record<string, unknown> = Record<string, unkno
303
384
  */
304
385
  cardMinWidth?: number;
305
386
  }
306
- type EditingCell = {
387
+ type EditingCell<T extends object = Record<string, unknown>> = {
307
388
  rowIndex: number;
308
- colKey: string;
389
+ colKey: RowKey<T>;
309
390
  } | null;
310
391
 
311
- declare function DataGridInner<T extends Record<string, unknown>>({ columns, data, rowKey, onChange, onRowAdd, editable, loading, emptyText, className, stickyHeader, maxHeight, showRowNumbers, draggableRows, onRowReorder, currentSort, onSortChange, showFilters, filterConfig, filters, onFiltersChange, quickFilters, showPagination, pageSize, pageSizeOptions, totalRows: totalRowsProp, onPageChange, selectable, selectedRows: controlledSelectedRows, defaultSelectedRows, onSelectionChange, bulkActions, expandable, renderExpandedContent, isRowExpandable, expandMultiple, expandedRows: controlledExpandedRows, defaultExpandedRows, onExpandedRowsChange, density, showDensity, hasCardView, cardViewBreakpoint, cardMinWidth, }: DataGridProps<T>): React__default.ReactElement;
392
+ declare function DataGridInner<T extends object>({ columns: columnsProp, data, rowKey, onChange, onRowAdd, editable, loading, emptyText, className, stickyHeader, maxHeight, showRowNumbers, draggableRows, onRowReorder, currentSort, onSortChange, showFilters, filterConfig, filters, onFiltersChange, quickFilters, showPagination, pageSize, pageSizeOptions, totalRows: totalRowsProp, onPageChange, selectable, selectedRows: controlledSelectedRows, defaultSelectedRows, onSelectionChange, bulkActions, expandable, renderExpandedContent, isRowExpandable, expandMultiple, expandedRows: controlledExpandedRows, defaultExpandedRows, onExpandedRowsChange, density, showDensity, hasCardView, cardViewBreakpoint, cardMinWidth, }: DataGridProps<T>): React__default.ReactElement;
312
393
  declare const DataGrid: typeof DataGridInner & {
313
394
  displayName: string;
314
395
  };
315
396
 
316
- export { BulkAction, DataGrid, type DataGridCellType, type DataGridColumn, type DataGridFilterField, type DataGridProps, type DataGridQuickFilter, type DataGridQuickFilterCombobox, type DataGridQuickFilterComboboxOption, type DataGridQuickFilterSegmented, type DataGridQuickFilterSegmentedOption, type DataGridQuickFilterSelect, type DataGridQuickFilterSelectOption, type DataGridRowAction, type DataGridSelectOption, type EditingCell };
397
+ export { BulkAction, DataGrid, type DataGridActionsColumn, type DataGridCellType, type DataGridColumn, type DataGridCustomColumn, type DataGridFilterField, type DataGridProps, type DataGridQuickFilter, type DataGridQuickFilterCombobox, type DataGridQuickFilterComboboxOption, type DataGridQuickFilterSegmented, type DataGridQuickFilterSegmentedOption, type DataGridQuickFilterSelect, type DataGridQuickFilterSelectOption, type DataGridRowAction, type DataGridSelectOption, type DataGridValueCellType, type DataGridValueColumn, type EditingCell };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DataGrid
3
- } from "../chunk-A5LHCAQY.js";
4
- import "../chunk-IZBJW37N.js";
3
+ } from "../chunk-MH2CD2QT.js";
4
+ import "../chunk-AJZTVCST.js";
5
5
  import "../chunk-6ZAT5CGB.js";
6
6
  import "../chunk-3LHQUOGP.js";
7
7
  import "../chunk-56B6RLOE.js";
@@ -18,6 +18,7 @@ import "../chunk-WE5FTQGD.js";
18
18
  import "../chunk-JMD3P4CY.js";
19
19
  import "../chunk-4BKTBV2I.js";
20
20
  import "../chunk-LYH3EKKQ.js";
21
+ import "../chunk-3SKI6FXB.js";
21
22
  import "../chunk-N5JDL4VE.js";
22
23
  import "../chunk-WIE7HDIM.js";
23
24
  import "../chunk-66R54X6R.js";