eidos-ui 1.2.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 (35) 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-6XB3QTHO.cjs → chunk-2ZENLZEQ.cjs} +55 -51
  4. package/dist/chunk-2ZENLZEQ.cjs.map +1 -0
  5. package/dist/{chunk-6DBCT5MK.js → chunk-AJZTVCST.js} +1 -1
  6. package/dist/chunk-AJZTVCST.js.map +1 -0
  7. package/dist/{chunk-P2ZHWFK4.js → chunk-MH2CD2QT.js} +29 -25
  8. package/dist/chunk-MH2CD2QT.js.map +1 -0
  9. package/dist/{chunk-NUK4NT5Q.cjs → chunk-QONDJ5VM.cjs} +11 -11
  10. package/dist/chunk-QONDJ5VM.cjs.map +1 -0
  11. package/dist/{chunk-2KO5ZCZC.js → chunk-VSFKM7FE.js} +2 -2
  12. package/dist/chunk-VSFKM7FE.js.map +1 -0
  13. package/dist/{chunk-TKLWQWMT.cjs → chunk-XVSODE4K.cjs} +1 -1
  14. package/dist/chunk-XVSODE4K.cjs.map +1 -0
  15. package/dist/data-grid/index.cjs +3 -3
  16. package/dist/data-grid/index.d.cts +123 -51
  17. package/dist/data-grid/index.d.ts +123 -51
  18. package/dist/data-grid/index.js +2 -2
  19. package/dist/index.cjs +4 -4
  20. package/dist/index.d.cts +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +3 -3
  23. package/dist/table/index.cjs +3 -3
  24. package/dist/table/index.d.cts +5 -5
  25. package/dist/table/index.d.ts +5 -5
  26. package/dist/table/index.js +2 -2
  27. package/package.json +1 -1
  28. package/dist/Table.types-Bv9l7qxd.d.ts +0 -103
  29. package/dist/Table.types-DQ0ReOLj.d.cts +0 -103
  30. package/dist/chunk-2KO5ZCZC.js.map +0 -1
  31. package/dist/chunk-6DBCT5MK.js.map +0 -1
  32. package/dist/chunk-6XB3QTHO.cjs.map +0 -1
  33. package/dist/chunk-NUK4NT5Q.cjs.map +0 -1
  34. package/dist/chunk-P2ZHWFK4.js.map +0 -1
  35. package/dist/chunk-TKLWQWMT.cjs.map +0 -1
@@ -0,0 +1,183 @@
1
+ import { ReactNode } from 'react';
2
+ import { I as IconType } from './renderIcon-C2lEMMzb.cjs';
3
+ import { B as ButtonColorProps, b as ButtonVariantProps } from './Button.types-DZRCVqyN.cjs';
4
+
5
+ /**
6
+ * A field name of a row-data type, as a string-literal union.
7
+ *
8
+ * Shared by every data component that addresses row fields by name
9
+ * (`Table`, `DataGrid`) so the same concept is typed one way everywhere -
10
+ * `TableColumn.key`, `DataGridColumn.key`, `rowKey`, sort keys, and the
11
+ * filter/quick-filter schemas.
12
+ *
13
+ * Degrades to `string` for the untyped default (`Record<string, unknown>`),
14
+ * which is what keeps callers who never specify `T` compiling unchanged.
15
+ *
16
+ * `Extract<keyof T, string>` rather than `keyof T`: keys are compared against
17
+ * and rendered as strings throughout (`data-col-key`, React keys, filter
18
+ * state objects), so numeric and symbol keys are excluded deliberately.
19
+ *
20
+ * ## Why this only works when `T` has no index signature
21
+ *
22
+ * An index signature widens `keyof T` to `string`, at which point this
23
+ * resolves to `string` and every key-narrowing and per-key value type built
24
+ * on it silently degrades to the old, unchecked behaviour. That is exactly
25
+ * what `T extends Record<string, unknown>` used to force on consumers:
26
+ * TypeScript only grants *implicit* index signatures to object type aliases,
27
+ * so anyone modelling rows with an `interface` had to write
28
+ * `interface Row extends Record<string, unknown>` to satisfy it - and thereby
29
+ * opted out of all of this without knowing.
30
+ *
31
+ * Both components now constrain `T extends object` instead, so a plain
32
+ * interface is accepted and keeps its literal keys. Don't tighten that
33
+ * constraint back to `Record<string, unknown>`: it would not fail loudly, it
34
+ * would just quietly stop checking.
35
+ */
36
+ type RowKey<T> = Extract<keyof T, string>;
37
+
38
+ /** A secondary action inside a `type: 'split-button'` bulk action's dropdown. */
39
+ interface BulkActionSplitOption<T> {
40
+ id: string;
41
+ label: string;
42
+ icon?: IconType;
43
+ disabled?: boolean;
44
+ /** Receives the full array of currently selected row objects. */
45
+ onClick: (selectedRows: T[]) => void;
46
+ }
47
+ interface BulkActionCommon<T> {
48
+ /** Only needs to be unique within this `bulkActions` array. */
49
+ id: string;
50
+ color?: ButtonColorProps;
51
+ disabled?: boolean | ((selectedRows: T[]) => boolean);
52
+ /** Primary action - fired on click for `'button'`, or on the primary (left) segment for `'split-button'`. */
53
+ onClick: (selectedRows: T[]) => void;
54
+ }
55
+ interface BulkActionButton<T> extends BulkActionCommon<T> {
56
+ /** @default 'button' */
57
+ type?: 'button';
58
+ /** Omit to render an icon-only button - `icon` becomes the sole icon in that case. */
59
+ label?: string;
60
+ icon?: IconType;
61
+ posIcon?: IconType;
62
+ variant?: ButtonVariantProps;
63
+ }
64
+ interface BulkActionSplitButton<T> extends BulkActionCommon<T> {
65
+ type: 'split-button';
66
+ /** Required - SplitButton always renders a primary label. */
67
+ label: string;
68
+ icon?: IconType;
69
+ /** SplitButton has no `text` variant. */
70
+ variant?: Exclude<ButtonVariantProps, 'text'>;
71
+ /** Secondary actions shown in the split-button's dropdown. */
72
+ options: BulkActionSplitOption<T>[];
73
+ }
74
+ type BulkAction<T> = BulkActionButton<T> | BulkActionSplitButton<T>;
75
+ /** Members shared by every column variant, field-addressing or not. */
76
+ interface TableColumnCommon {
77
+ label: string;
78
+ sortable?: boolean;
79
+ filterable?: boolean;
80
+ filterType?: 'text' | 'select' | 'date' | 'boolean';
81
+ filterOptions?: {
82
+ id: string;
83
+ value: string;
84
+ label: string;
85
+ }[];
86
+ dateFilterMode?: 'single' | 'multiple' | 'range';
87
+ width?: string;
88
+ align?: 'left' | 'center' | 'right';
89
+ /** Enables position:sticky on this column */
90
+ pin?: 'left' | 'right';
91
+ }
92
+ /**
93
+ * A column bound to the row field named by `key`, which is what lets `render`
94
+ * receive `T[K]` rather than `unknown`.
95
+ *
96
+ * Not used directly - `TableColumn` distributes this over `keyof T` so each
97
+ * entry correlates its own `key` with its own value type.
98
+ */
99
+ interface TableValueColumn<T extends object, K extends RowKey<T>> extends TableColumnCommon {
100
+ key: K;
101
+ /** @default 'data' */
102
+ type?: 'data';
103
+ render?: (value: T[K], item: T) => ReactNode;
104
+ }
105
+ /**
106
+ * A column that renders from the whole row rather than one field - an icon or
107
+ * action cell, or a computed/composite value. `key` is free-form here because
108
+ * nothing reads `row[key]`: it's only an identity for React keys, sorting and
109
+ * `data-col-key`.
110
+ *
111
+ * `'icon'` and `'action'` carry their existing cell styling; `'custom'` styles
112
+ * like a normal data cell but takes a free-form key, which is the home for a
113
+ * derived column (previously expressible only by pointing `key` at a field
114
+ * that didn't exist).
115
+ */
116
+ interface TableCustomColumn<T extends object> extends TableColumnCommon {
117
+ /** Free-form - must only be unique within `columns`. */
118
+ key: string;
119
+ type: 'icon' | 'action' | 'custom';
120
+ /** `value` is always `undefined`; render from `item`. */
121
+ render?: (value: undefined, item: T) => ReactNode;
122
+ }
123
+ /**
124
+ * One column definition. A union of two variants, discriminated on `type`:
125
+ *
126
+ * - **value column** (default, `type` omitted or `'data'`) - `key` must be a
127
+ * field of `T`, and `render` receives that field's type instead of `unknown`.
128
+ * - **`type: 'icon' | 'action' | 'custom'`** - renders from the whole row;
129
+ * `key` is free-form.
130
+ *
131
+ * With the untyped default `T`, `RowKey<T>` is `string` and `T[K]` is
132
+ * `unknown`, which is byte-identical to the pre-2.0 behaviour.
133
+ *
134
+ * Replaces `key: keyof T | string`, which looked constrained but wasn't:
135
+ * `keyof T` is assignable to `string`, so that union collapsed to plain
136
+ * `string` and checked nothing.
137
+ */
138
+ type TableColumn<T extends object = Record<string, unknown>> = {
139
+ [K in RowKey<T>]: TableValueColumn<T, K>;
140
+ }[RowKey<T>] | TableCustomColumn<T>;
141
+ type FilterValue = string | string[] | boolean | {
142
+ start: string | null;
143
+ end: string | null;
144
+ } | undefined;
145
+ interface TableFilters {
146
+ [key: string]: FilterValue;
147
+ }
148
+ interface TableProps<T extends object = Record<string, unknown>> {
149
+ data: T[];
150
+ columns: TableColumn<T>[];
151
+ loading?: boolean;
152
+ emptyMessage?: string;
153
+ onRowClick?: (item: T) => void;
154
+ className?: string;
155
+ showFooter?: boolean;
156
+ totalItems?: number;
157
+ showPagination?: boolean;
158
+ pageSize?: number;
159
+ pageSizeOptions?: number[];
160
+ onSortChange?: (sortBy: RowKey<T>, sortDirection: 'asc' | 'desc') => void;
161
+ currentSort?: {
162
+ key: RowKey<T>;
163
+ direction: 'asc' | 'desc';
164
+ };
165
+ filters?: TableFilters;
166
+ onFiltersChange?: (filters: TableFilters) => void;
167
+ defaultFilters?: TableFilters;
168
+ showFilters?: boolean;
169
+ selectable?: boolean;
170
+ rowKey?: RowKey<T>;
171
+ selectedRows?: string[];
172
+ defaultSelectedRows?: string[];
173
+ onSelectionChange?: (selectedKeys: string[], selectedRows: T[]) => void;
174
+ bulkActions?: BulkAction<T>[];
175
+ density?: 'compact' | 'comfortable' | 'spacious';
176
+ showColumnVisibility?: boolean;
177
+ showExport?: boolean;
178
+ showDensity?: boolean;
179
+ draggableColumns?: boolean;
180
+ onColumnReorder?: (newColumns: TableColumn<T>[]) => void;
181
+ }
182
+
183
+ export type { BulkAction as B, FilterValue as F, RowKey as R, TableColumn as T, BulkActionButton as a, BulkActionSplitButton as b, BulkActionSplitOption as c, TableCustomColumn as d, TableFilters as e, TableProps as f, TableValueColumn as g };
@@ -0,0 +1,183 @@
1
+ import { ReactNode } from 'react';
2
+ import { I as IconType } from './renderIcon-C2lEMMzb.js';
3
+ import { B as ButtonColorProps, b as ButtonVariantProps } from './Button.types-BH0CPyPx.js';
4
+
5
+ /**
6
+ * A field name of a row-data type, as a string-literal union.
7
+ *
8
+ * Shared by every data component that addresses row fields by name
9
+ * (`Table`, `DataGrid`) so the same concept is typed one way everywhere -
10
+ * `TableColumn.key`, `DataGridColumn.key`, `rowKey`, sort keys, and the
11
+ * filter/quick-filter schemas.
12
+ *
13
+ * Degrades to `string` for the untyped default (`Record<string, unknown>`),
14
+ * which is what keeps callers who never specify `T` compiling unchanged.
15
+ *
16
+ * `Extract<keyof T, string>` rather than `keyof T`: keys are compared against
17
+ * and rendered as strings throughout (`data-col-key`, React keys, filter
18
+ * state objects), so numeric and symbol keys are excluded deliberately.
19
+ *
20
+ * ## Why this only works when `T` has no index signature
21
+ *
22
+ * An index signature widens `keyof T` to `string`, at which point this
23
+ * resolves to `string` and every key-narrowing and per-key value type built
24
+ * on it silently degrades to the old, unchecked behaviour. That is exactly
25
+ * what `T extends Record<string, unknown>` used to force on consumers:
26
+ * TypeScript only grants *implicit* index signatures to object type aliases,
27
+ * so anyone modelling rows with an `interface` had to write
28
+ * `interface Row extends Record<string, unknown>` to satisfy it - and thereby
29
+ * opted out of all of this without knowing.
30
+ *
31
+ * Both components now constrain `T extends object` instead, so a plain
32
+ * interface is accepted and keeps its literal keys. Don't tighten that
33
+ * constraint back to `Record<string, unknown>`: it would not fail loudly, it
34
+ * would just quietly stop checking.
35
+ */
36
+ type RowKey<T> = Extract<keyof T, string>;
37
+
38
+ /** A secondary action inside a `type: 'split-button'` bulk action's dropdown. */
39
+ interface BulkActionSplitOption<T> {
40
+ id: string;
41
+ label: string;
42
+ icon?: IconType;
43
+ disabled?: boolean;
44
+ /** Receives the full array of currently selected row objects. */
45
+ onClick: (selectedRows: T[]) => void;
46
+ }
47
+ interface BulkActionCommon<T> {
48
+ /** Only needs to be unique within this `bulkActions` array. */
49
+ id: string;
50
+ color?: ButtonColorProps;
51
+ disabled?: boolean | ((selectedRows: T[]) => boolean);
52
+ /** Primary action - fired on click for `'button'`, or on the primary (left) segment for `'split-button'`. */
53
+ onClick: (selectedRows: T[]) => void;
54
+ }
55
+ interface BulkActionButton<T> extends BulkActionCommon<T> {
56
+ /** @default 'button' */
57
+ type?: 'button';
58
+ /** Omit to render an icon-only button - `icon` becomes the sole icon in that case. */
59
+ label?: string;
60
+ icon?: IconType;
61
+ posIcon?: IconType;
62
+ variant?: ButtonVariantProps;
63
+ }
64
+ interface BulkActionSplitButton<T> extends BulkActionCommon<T> {
65
+ type: 'split-button';
66
+ /** Required - SplitButton always renders a primary label. */
67
+ label: string;
68
+ icon?: IconType;
69
+ /** SplitButton has no `text` variant. */
70
+ variant?: Exclude<ButtonVariantProps, 'text'>;
71
+ /** Secondary actions shown in the split-button's dropdown. */
72
+ options: BulkActionSplitOption<T>[];
73
+ }
74
+ type BulkAction<T> = BulkActionButton<T> | BulkActionSplitButton<T>;
75
+ /** Members shared by every column variant, field-addressing or not. */
76
+ interface TableColumnCommon {
77
+ label: string;
78
+ sortable?: boolean;
79
+ filterable?: boolean;
80
+ filterType?: 'text' | 'select' | 'date' | 'boolean';
81
+ filterOptions?: {
82
+ id: string;
83
+ value: string;
84
+ label: string;
85
+ }[];
86
+ dateFilterMode?: 'single' | 'multiple' | 'range';
87
+ width?: string;
88
+ align?: 'left' | 'center' | 'right';
89
+ /** Enables position:sticky on this column */
90
+ pin?: 'left' | 'right';
91
+ }
92
+ /**
93
+ * A column bound to the row field named by `key`, which is what lets `render`
94
+ * receive `T[K]` rather than `unknown`.
95
+ *
96
+ * Not used directly - `TableColumn` distributes this over `keyof T` so each
97
+ * entry correlates its own `key` with its own value type.
98
+ */
99
+ interface TableValueColumn<T extends object, K extends RowKey<T>> extends TableColumnCommon {
100
+ key: K;
101
+ /** @default 'data' */
102
+ type?: 'data';
103
+ render?: (value: T[K], item: T) => ReactNode;
104
+ }
105
+ /**
106
+ * A column that renders from the whole row rather than one field - an icon or
107
+ * action cell, or a computed/composite value. `key` is free-form here because
108
+ * nothing reads `row[key]`: it's only an identity for React keys, sorting and
109
+ * `data-col-key`.
110
+ *
111
+ * `'icon'` and `'action'` carry their existing cell styling; `'custom'` styles
112
+ * like a normal data cell but takes a free-form key, which is the home for a
113
+ * derived column (previously expressible only by pointing `key` at a field
114
+ * that didn't exist).
115
+ */
116
+ interface TableCustomColumn<T extends object> extends TableColumnCommon {
117
+ /** Free-form - must only be unique within `columns`. */
118
+ key: string;
119
+ type: 'icon' | 'action' | 'custom';
120
+ /** `value` is always `undefined`; render from `item`. */
121
+ render?: (value: undefined, item: T) => ReactNode;
122
+ }
123
+ /**
124
+ * One column definition. A union of two variants, discriminated on `type`:
125
+ *
126
+ * - **value column** (default, `type` omitted or `'data'`) - `key` must be a
127
+ * field of `T`, and `render` receives that field's type instead of `unknown`.
128
+ * - **`type: 'icon' | 'action' | 'custom'`** - renders from the whole row;
129
+ * `key` is free-form.
130
+ *
131
+ * With the untyped default `T`, `RowKey<T>` is `string` and `T[K]` is
132
+ * `unknown`, which is byte-identical to the pre-2.0 behaviour.
133
+ *
134
+ * Replaces `key: keyof T | string`, which looked constrained but wasn't:
135
+ * `keyof T` is assignable to `string`, so that union collapsed to plain
136
+ * `string` and checked nothing.
137
+ */
138
+ type TableColumn<T extends object = Record<string, unknown>> = {
139
+ [K in RowKey<T>]: TableValueColumn<T, K>;
140
+ }[RowKey<T>] | TableCustomColumn<T>;
141
+ type FilterValue = string | string[] | boolean | {
142
+ start: string | null;
143
+ end: string | null;
144
+ } | undefined;
145
+ interface TableFilters {
146
+ [key: string]: FilterValue;
147
+ }
148
+ interface TableProps<T extends object = Record<string, unknown>> {
149
+ data: T[];
150
+ columns: TableColumn<T>[];
151
+ loading?: boolean;
152
+ emptyMessage?: string;
153
+ onRowClick?: (item: T) => void;
154
+ className?: string;
155
+ showFooter?: boolean;
156
+ totalItems?: number;
157
+ showPagination?: boolean;
158
+ pageSize?: number;
159
+ pageSizeOptions?: number[];
160
+ onSortChange?: (sortBy: RowKey<T>, sortDirection: 'asc' | 'desc') => void;
161
+ currentSort?: {
162
+ key: RowKey<T>;
163
+ direction: 'asc' | 'desc';
164
+ };
165
+ filters?: TableFilters;
166
+ onFiltersChange?: (filters: TableFilters) => void;
167
+ defaultFilters?: TableFilters;
168
+ showFilters?: boolean;
169
+ selectable?: boolean;
170
+ rowKey?: RowKey<T>;
171
+ selectedRows?: string[];
172
+ defaultSelectedRows?: string[];
173
+ onSelectionChange?: (selectedKeys: string[], selectedRows: T[]) => void;
174
+ bulkActions?: BulkAction<T>[];
175
+ density?: 'compact' | 'comfortable' | 'spacious';
176
+ showColumnVisibility?: boolean;
177
+ showExport?: boolean;
178
+ showDensity?: boolean;
179
+ draggableColumns?: boolean;
180
+ onColumnReorder?: (newColumns: TableColumn<T>[]) => void;
181
+ }
182
+
183
+ export type { BulkAction as B, FilterValue as F, RowKey as R, TableColumn as T, BulkActionButton as a, BulkActionSplitButton as b, BulkActionSplitOption as c, TableCustomColumn as d, TableFilters as e, TableProps as f, TableValueColumn as g };