@frontile/collections 0.17.0-beta.24 → 0.17.0-beta.25

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 (76) hide show
  1. package/declarations/components/table/index.d.ts +9 -0
  2. package/declarations/components/table/table-body.d.ts +250 -0
  3. package/declarations/components/table/table-cell.d.ts +243 -0
  4. package/declarations/components/table/table-column.d.ts +234 -0
  5. package/declarations/components/table/table-footer.d.ts +242 -0
  6. package/declarations/components/table/table-header.d.ts +241 -0
  7. package/declarations/components/table/table-row.d.ts +249 -0
  8. package/declarations/components/table/table.d.ts +331 -0
  9. package/declarations/components/table/types.d.ts +15 -0
  10. package/declarations/components/table/utils.d.ts +10 -0
  11. package/declarations/components/table.d.ts +2 -0
  12. package/dist/table-92ff_YNO.js +277 -0
  13. package/dist/table-92ff_YNO.js.map +1 -0
  14. package/dist/table-9AY4L0Gb.js +197 -0
  15. package/dist/table-9AY4L0Gb.js.map +1 -0
  16. package/dist/table-9lHVhRR5.js +241 -0
  17. package/dist/table-9lHVhRR5.js.map +1 -0
  18. package/dist/table-BIkLOscH.js +269 -0
  19. package/dist/table-BIkLOscH.js.map +1 -0
  20. package/dist/table-BPp_OXkX.js +206 -0
  21. package/dist/table-BPp_OXkX.js.map +1 -0
  22. package/dist/table-BQBLUGgl.js +208 -0
  23. package/dist/table-BQBLUGgl.js.map +1 -0
  24. package/dist/table-BUboQojw.js +267 -0
  25. package/dist/table-BUboQojw.js.map +1 -0
  26. package/dist/table-BUrvD0CN.js +324 -0
  27. package/dist/table-BUrvD0CN.js.map +1 -0
  28. package/dist/table-B_z4aWPh.js +276 -0
  29. package/dist/table-B_z4aWPh.js.map +1 -0
  30. package/dist/table-Bi_i2GOl.js +279 -0
  31. package/dist/table-Bi_i2GOl.js.map +1 -0
  32. package/dist/table-BkWhyzMo.js +214 -0
  33. package/dist/table-BkWhyzMo.js.map +1 -0
  34. package/dist/table-Bp_EqrlK.js +309 -0
  35. package/dist/table-Bp_EqrlK.js.map +1 -0
  36. package/dist/table-Bq1HGB9C.js +240 -0
  37. package/dist/table-Bq1HGB9C.js.map +1 -0
  38. package/dist/table-C-_mQMW_.js +141 -0
  39. package/dist/table-C-_mQMW_.js.map +1 -0
  40. package/dist/table-CaBDs-LD.js +269 -0
  41. package/dist/table-CaBDs-LD.js.map +1 -0
  42. package/dist/table-CcbmieDl.js +329 -0
  43. package/dist/table-CcbmieDl.js.map +1 -0
  44. package/dist/table-CdLut7xT.js +172 -0
  45. package/dist/table-CdLut7xT.js.map +1 -0
  46. package/dist/table-Cs_Xm3-T.js +144 -0
  47. package/dist/table-Cs_Xm3-T.js.map +1 -0
  48. package/dist/table-CwxlKxz0.js +185 -0
  49. package/dist/table-CwxlKxz0.js.map +1 -0
  50. package/dist/table-D1jyvvdd.js +242 -0
  51. package/dist/table-D1jyvvdd.js.map +1 -0
  52. package/dist/table-D7QCvl0_.js +269 -0
  53. package/dist/table-D7QCvl0_.js.map +1 -0
  54. package/dist/table-DApb61os.js +185 -0
  55. package/dist/table-DApb61os.js.map +1 -0
  56. package/dist/table-DFIwJpJO.js +144 -0
  57. package/dist/table-DFIwJpJO.js.map +1 -0
  58. package/dist/table-DIZvtyjH.js +185 -0
  59. package/dist/table-DIZvtyjH.js.map +1 -0
  60. package/dist/table-DYOLmjfk.js +325 -0
  61. package/dist/table-DYOLmjfk.js.map +1 -0
  62. package/dist/table-Da60U9eH.js +269 -0
  63. package/dist/table-Da60U9eH.js.map +1 -0
  64. package/dist/table-Dcyk7CLS.js +144 -0
  65. package/dist/table-Dcyk7CLS.js.map +1 -0
  66. package/dist/table-DzNT9tDs.js +280 -0
  67. package/dist/table-DzNT9tDs.js.map +1 -0
  68. package/dist/table-EDCy6SCT.js +214 -0
  69. package/dist/table-EDCy6SCT.js.map +1 -0
  70. package/dist/table-GRGxN-x5.js +309 -0
  71. package/dist/table-GRGxN-x5.js.map +1 -0
  72. package/dist/table-Lk0tmBng.js +309 -0
  73. package/dist/table-Lk0tmBng.js.map +1 -0
  74. package/dist/table-k5i2kvUD.js +324 -0
  75. package/dist/table-k5i2kvUD.js.map +1 -0
  76. package/package.json +6 -6
@@ -0,0 +1,331 @@
1
+ import Component from '@glimmer/component';
2
+ import { useStyles } from '@frontile/theme';
3
+ import { TableHeader } from './table-header';
4
+ import { TableBody } from './table-body';
5
+ import { TableFooter } from './table-footer';
6
+ import { TableColumn } from './table-column';
7
+ import { TableRow } from './table-row';
8
+ import { TableCell } from './table-cell';
9
+ import type { ColumnDefinition, TableVariants, TableSlots, SlotsToClasses, ClassValue } from './types';
10
+ import type { ContentValue, WithBoundArgs } from '@glint/template';
11
+ interface TableSignature<T> {
12
+ Args: {
13
+ /** Array of column definitions for automatic table generation */
14
+ columns?: ColumnDefinition<T>[];
15
+ /** Array of data items to display in the table */
16
+ items?: T[];
17
+ /** Custom CSS classes for different table elements (wrapper, table, th, td, etc.) */
18
+ classes?: SlotsToClasses<TableSlots>;
19
+ /** Size variant for table cells and headers. @defaultValue 'md' */
20
+ size?: TableVariants['size'];
21
+ /** Table layout algorithm - 'auto' sizes columns by content, 'fixed' uses first row for sizing. @defaultValue 'auto' */
22
+ layout?: TableVariants['layout'];
23
+ /** Enable striped rows (alternating background colors) */
24
+ isStriped?: TableVariants['striped'];
25
+ /** Content to display when no data items are provided */
26
+ emptyContent?: ContentValue;
27
+ /** Enable scrolling for the table container */
28
+ isScrollable?: boolean;
29
+ /** Array of item keys that should be sticky during vertical scrolling */
30
+ stickyKeys?: string[];
31
+ /** Make the table header sticky during vertical scrolling */
32
+ isStickyHeader?: boolean;
33
+ /** Array of column definitions for automatic footer generation */
34
+ footerColumns?: ColumnDefinition<T>[];
35
+ /** Make the table footer sticky during vertical scrolling */
36
+ isStickyFooter?: boolean;
37
+ };
38
+ Element: HTMLTableElement;
39
+ Blocks: {
40
+ default: [
41
+ {
42
+ Column: WithBoundArgs<typeof TableColumn<T>, 'styleFns'>;
43
+ Header: WithBoundArgs<typeof TableHeader<T>, 'columns' | 'styleFns'>;
44
+ Body: WithBoundArgs<typeof TableBody<T>, 'columns' | 'items' | 'styleFns'>;
45
+ Footer: WithBoundArgs<typeof TableFooter<T>, 'columns' | 'styleFns'>;
46
+ Row: WithBoundArgs<typeof TableRow<T>, 'columns' | 'styleFns' | 'stickyKeys' | 'isStickyHeader'>;
47
+ Cell: WithBoundArgs<typeof TableCell<T>, 'styleFns'>;
48
+ }
49
+ ];
50
+ };
51
+ }
52
+ declare class Table<T = unknown> extends Component<TableSignature<T>> {
53
+ TableBody: {
54
+ new (owner: import("@ember/-internals/owner").default, args: {
55
+ columns?: ColumnDefinition<T>[] | undefined;
56
+ items?: T[] | undefined;
57
+ class?: string;
58
+ styleFns?: ReturnType<ReturnType<typeof useStyles>["table"]>;
59
+ classes?: SlotsToClasses<TableSlots>;
60
+ }): TableBody<T>;
61
+ };
62
+ TableFooter: {
63
+ new (owner: import("@ember/-internals/owner").default, args: {
64
+ columns?: ColumnDefinition<T>[] | undefined;
65
+ class?: string;
66
+ isSticky?: boolean;
67
+ styleFns?: ReturnType<ReturnType<typeof useStyles>["table"]>;
68
+ classes?: SlotsToClasses<TableSlots>;
69
+ }): TableFooter<T>;
70
+ };
71
+ TableRow: {
72
+ new (owner: import("@ember/-internals/owner").default, args: {
73
+ item?: T | undefined;
74
+ columns?: ColumnDefinition<T>[] | undefined;
75
+ class?: string;
76
+ isSticky?: boolean;
77
+ stickyKeys?: string[];
78
+ isStickyHeader?: boolean;
79
+ styleFns?: ReturnType<ReturnType<typeof useStyles>["table"]>;
80
+ classes?: SlotsToClasses<TableSlots>;
81
+ }): TableRow<T>;
82
+ };
83
+ TableCell: {
84
+ new (owner: import("@ember/-internals/owner").default, args: {
85
+ item?: T | undefined;
86
+ column?: ColumnDefinition<T> | undefined;
87
+ class?: string;
88
+ isSticky?: boolean;
89
+ stickyPosition?: "left" | "right";
90
+ isInStickyRow?: boolean;
91
+ styleFns?: ReturnType<ReturnType<typeof useStyles>["table"]>;
92
+ classes?: SlotsToClasses<TableSlots>;
93
+ }): TableCell<T>;
94
+ };
95
+ TableColumn: {
96
+ new (owner: import("@ember/-internals/owner").default, args: {
97
+ column?: ColumnDefinition<T> | undefined;
98
+ class?: string;
99
+ isSticky?: boolean;
100
+ stickyPosition?: "left" | "right";
101
+ styleFns?: ReturnType<ReturnType<typeof useStyles>["table"]>;
102
+ }): TableColumn<T>;
103
+ };
104
+ TableHeader: {
105
+ new (owner: import("@ember/-internals/owner").default, args: {
106
+ columns?: ColumnDefinition<T>[] | undefined;
107
+ class?: string;
108
+ isSticky?: boolean;
109
+ styleFns?: ReturnType<ReturnType<typeof useStyles>["table"]>;
110
+ classes?: SlotsToClasses<TableSlots>;
111
+ }): TableHeader<T>;
112
+ };
113
+ get styles(): {
114
+ base: (slotProps?: ({
115
+ size?: "sm" | "md" | "lg" | undefined;
116
+ layout?: "fixed" | "auto" | undefined;
117
+ striped?: boolean | undefined;
118
+ isSticky?: boolean | undefined;
119
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
120
+ isScrollable?: boolean | undefined;
121
+ hasStickyHeader?: boolean | undefined;
122
+ isInStickyRow?: boolean | undefined;
123
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
124
+ wrapper: (slotProps?: ({
125
+ size?: "sm" | "md" | "lg" | undefined;
126
+ layout?: "fixed" | "auto" | undefined;
127
+ striped?: boolean | undefined;
128
+ isSticky?: boolean | undefined;
129
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
130
+ isScrollable?: boolean | undefined;
131
+ hasStickyHeader?: boolean | undefined;
132
+ isInStickyRow?: boolean | undefined;
133
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
134
+ table: (slotProps?: ({
135
+ size?: "sm" | "md" | "lg" | undefined;
136
+ layout?: "fixed" | "auto" | undefined;
137
+ striped?: boolean | undefined;
138
+ isSticky?: boolean | undefined;
139
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
140
+ isScrollable?: boolean | undefined;
141
+ hasStickyHeader?: boolean | undefined;
142
+ isInStickyRow?: boolean | undefined;
143
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
144
+ thead: (slotProps?: ({
145
+ size?: "sm" | "md" | "lg" | undefined;
146
+ layout?: "fixed" | "auto" | undefined;
147
+ striped?: boolean | undefined;
148
+ isSticky?: boolean | undefined;
149
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
150
+ isScrollable?: boolean | undefined;
151
+ hasStickyHeader?: boolean | undefined;
152
+ isInStickyRow?: boolean | undefined;
153
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
154
+ tbody: (slotProps?: ({
155
+ size?: "sm" | "md" | "lg" | undefined;
156
+ layout?: "fixed" | "auto" | undefined;
157
+ striped?: boolean | undefined;
158
+ isSticky?: boolean | undefined;
159
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
160
+ isScrollable?: boolean | undefined;
161
+ hasStickyHeader?: boolean | undefined;
162
+ isInStickyRow?: boolean | undefined;
163
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
164
+ tfoot: (slotProps?: ({
165
+ size?: "sm" | "md" | "lg" | undefined;
166
+ layout?: "fixed" | "auto" | undefined;
167
+ striped?: boolean | undefined;
168
+ isSticky?: boolean | undefined;
169
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
170
+ isScrollable?: boolean | undefined;
171
+ hasStickyHeader?: boolean | undefined;
172
+ isInStickyRow?: boolean | undefined;
173
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
174
+ tr: (slotProps?: ({
175
+ size?: "sm" | "md" | "lg" | undefined;
176
+ layout?: "fixed" | "auto" | undefined;
177
+ striped?: boolean | undefined;
178
+ isSticky?: boolean | undefined;
179
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
180
+ isScrollable?: boolean | undefined;
181
+ hasStickyHeader?: boolean | undefined;
182
+ isInStickyRow?: boolean | undefined;
183
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
184
+ th: (slotProps?: ({
185
+ size?: "sm" | "md" | "lg" | undefined;
186
+ layout?: "fixed" | "auto" | undefined;
187
+ striped?: boolean | undefined;
188
+ isSticky?: boolean | undefined;
189
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
190
+ isScrollable?: boolean | undefined;
191
+ hasStickyHeader?: boolean | undefined;
192
+ isInStickyRow?: boolean | undefined;
193
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
194
+ td: (slotProps?: ({
195
+ size?: "sm" | "md" | "lg" | undefined;
196
+ layout?: "fixed" | "auto" | undefined;
197
+ striped?: boolean | undefined;
198
+ isSticky?: boolean | undefined;
199
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
200
+ isScrollable?: boolean | undefined;
201
+ hasStickyHeader?: boolean | undefined;
202
+ isInStickyRow?: boolean | undefined;
203
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
204
+ emptyCell: (slotProps?: ({
205
+ size?: "sm" | "md" | "lg" | undefined;
206
+ layout?: "fixed" | "auto" | undefined;
207
+ striped?: boolean | undefined;
208
+ isSticky?: boolean | undefined;
209
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
210
+ isScrollable?: boolean | undefined;
211
+ hasStickyHeader?: boolean | undefined;
212
+ isInStickyRow?: boolean | undefined;
213
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
214
+ } & {
215
+ base: (slotProps?: ({
216
+ size?: "sm" | "md" | "lg" | undefined;
217
+ layout?: "fixed" | "auto" | undefined;
218
+ striped?: boolean | undefined;
219
+ isSticky?: boolean | undefined;
220
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
221
+ isScrollable?: boolean | undefined;
222
+ hasStickyHeader?: boolean | undefined;
223
+ isInStickyRow?: boolean | undefined;
224
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
225
+ wrapper: (slotProps?: ({
226
+ size?: "sm" | "md" | "lg" | undefined;
227
+ layout?: "fixed" | "auto" | undefined;
228
+ striped?: boolean | undefined;
229
+ isSticky?: boolean | undefined;
230
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
231
+ isScrollable?: boolean | undefined;
232
+ hasStickyHeader?: boolean | undefined;
233
+ isInStickyRow?: boolean | undefined;
234
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
235
+ table: (slotProps?: ({
236
+ size?: "sm" | "md" | "lg" | undefined;
237
+ layout?: "fixed" | "auto" | undefined;
238
+ striped?: boolean | undefined;
239
+ isSticky?: boolean | undefined;
240
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
241
+ isScrollable?: boolean | undefined;
242
+ hasStickyHeader?: boolean | undefined;
243
+ isInStickyRow?: boolean | undefined;
244
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
245
+ thead: (slotProps?: ({
246
+ size?: "sm" | "md" | "lg" | undefined;
247
+ layout?: "fixed" | "auto" | undefined;
248
+ striped?: boolean | undefined;
249
+ isSticky?: boolean | undefined;
250
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
251
+ isScrollable?: boolean | undefined;
252
+ hasStickyHeader?: boolean | undefined;
253
+ isInStickyRow?: boolean | undefined;
254
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
255
+ tbody: (slotProps?: ({
256
+ size?: "sm" | "md" | "lg" | undefined;
257
+ layout?: "fixed" | "auto" | undefined;
258
+ striped?: boolean | undefined;
259
+ isSticky?: boolean | undefined;
260
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
261
+ isScrollable?: boolean | undefined;
262
+ hasStickyHeader?: boolean | undefined;
263
+ isInStickyRow?: boolean | undefined;
264
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
265
+ tfoot: (slotProps?: ({
266
+ size?: "sm" | "md" | "lg" | undefined;
267
+ layout?: "fixed" | "auto" | undefined;
268
+ striped?: boolean | undefined;
269
+ isSticky?: boolean | undefined;
270
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
271
+ isScrollable?: boolean | undefined;
272
+ hasStickyHeader?: boolean | undefined;
273
+ isInStickyRow?: boolean | undefined;
274
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
275
+ tr: (slotProps?: ({
276
+ size?: "sm" | "md" | "lg" | undefined;
277
+ layout?: "fixed" | "auto" | undefined;
278
+ striped?: boolean | undefined;
279
+ isSticky?: boolean | undefined;
280
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
281
+ isScrollable?: boolean | undefined;
282
+ hasStickyHeader?: boolean | undefined;
283
+ isInStickyRow?: boolean | undefined;
284
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
285
+ th: (slotProps?: ({
286
+ size?: "sm" | "md" | "lg" | undefined;
287
+ layout?: "fixed" | "auto" | undefined;
288
+ striped?: boolean | undefined;
289
+ isSticky?: boolean | undefined;
290
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
291
+ isScrollable?: boolean | undefined;
292
+ hasStickyHeader?: boolean | undefined;
293
+ isInStickyRow?: boolean | undefined;
294
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
295
+ td: (slotProps?: ({
296
+ size?: "sm" | "md" | "lg" | undefined;
297
+ layout?: "fixed" | "auto" | undefined;
298
+ striped?: boolean | undefined;
299
+ isSticky?: boolean | undefined;
300
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
301
+ isScrollable?: boolean | undefined;
302
+ hasStickyHeader?: boolean | undefined;
303
+ isInStickyRow?: boolean | undefined;
304
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
305
+ emptyCell: (slotProps?: ({
306
+ size?: "sm" | "md" | "lg" | undefined;
307
+ layout?: "fixed" | "auto" | undefined;
308
+ striped?: boolean | undefined;
309
+ isSticky?: boolean | undefined;
310
+ stickyPosition?: "top" | "right" | "bottom" | "left" | undefined;
311
+ isScrollable?: boolean | undefined;
312
+ hasStickyHeader?: boolean | undefined;
313
+ isInStickyRow?: boolean | undefined;
314
+ } & import("tailwind-variants").ClassProp<ClassValue>) | undefined) => string;
315
+ } & {};
316
+ get wrapperClassNames(): string;
317
+ calculateHeaderHeight: import("ember-modifier").FunctionBasedModifier<{
318
+ Args: {
319
+ Positional: unknown[];
320
+ Named: import("ember-modifier/-private/signature").EmptyObject;
321
+ };
322
+ Element: HTMLDivElement;
323
+ }>;
324
+ get tableClassNames(): string;
325
+ get columns(): ColumnDefinition<T>[];
326
+ get footerColumns(): ColumnDefinition<T>[];
327
+ get items(): T[];
328
+ getValue: (item: T, column: ColumnDefinition<T>) => ContentValue;
329
+ }
330
+ export { Table, type TableSignature };
331
+ export default Table;
@@ -0,0 +1,15 @@
1
+ import type { ContentValue } from '@glint/template';
2
+ import type { TableVariants, TableSlots, SlotsToClasses, ClassValue } from '@frontile/theme';
3
+ export interface ColumnDefinition<T = unknown> {
4
+ /** The property key to extract data from items, or a unique identifier for the column */
5
+ key: string;
6
+ /** Display label for the column header */
7
+ label: string;
8
+ /** Optional function to transform or compute column values from the data item */
9
+ accessorFn?: (item: T) => ContentValue;
10
+ /** Whether this column should be sticky during horizontal scrolling */
11
+ isSticky?: boolean;
12
+ /** Position where the sticky column should stick. @default 'left' */
13
+ stickyPosition?: 'left' | 'right';
14
+ }
15
+ export type { TableVariants, TableSlots, SlotsToClasses, ClassValue };
@@ -0,0 +1,10 @@
1
+ import type { ContentValue } from '@glint/template';
2
+ import type { ColumnDefinition } from './types';
3
+ /**
4
+ * Safely extracts a value from an object using either a custom accessorFn or direct property access
5
+ */
6
+ export declare function getSafeValue<T>(obj: T, column: ColumnDefinition<T>): ContentValue;
7
+ /**
8
+ * Safely extracts a value from an object by key and ensures it's safe for template rendering
9
+ */
10
+ export declare function getSafeValueByKey(obj: unknown, key: string): ContentValue;
@@ -0,0 +1,2 @@
1
+ export * from './table/index';
2
+ export { default } from './table/index';
@@ -0,0 +1,277 @@
1
+ import Component from '@glimmer/component';
2
+ import { hash } from '@ember/helper';
3
+ import { useStyles } from '@frontile/theme';
4
+ import { modifier } from 'ember-modifier';
5
+ import { precompileTemplate } from '@ember/template-compilation';
6
+ import { setComponentTemplate } from '@ember/component';
7
+ import { k as keyAndLabelForItem } from './listManager-D4_vozfz.js';
8
+
9
+ /**
10
+ * Safely extracts a value from an object using either a custom accessorFn or direct property access
11
+ */
12
+ function getSafeValue(obj, column) {
13
+ // Use custom accessor function if provided
14
+ if (column.accessorFn) {
15
+ return column.accessorFn(obj);
16
+ }
17
+
18
+ // Fallback to direct property access
19
+ return getSafeValueByKey(obj, column.key);
20
+ }
21
+
22
+ /**
23
+ * Safely extracts a value from an object by key and ensures it's safe for template rendering
24
+ */
25
+ function getSafeValueByKey(obj, key) {
26
+ if (!obj || typeof obj !== 'object') {
27
+ return undefined;
28
+ }
29
+ const value = obj[key];
30
+
31
+ // Return the value if it's already a safe template type
32
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value === null || value === undefined) {
33
+ return value;
34
+ }
35
+
36
+ // For other types, convert to string representation
37
+ if (typeof value === 'object' && value !== null) {
38
+ // Handle arrays
39
+ if (Array.isArray(value)) {
40
+ return value.join(', ');
41
+ }
42
+ // Handle objects with toString method
43
+ return value.toString();
44
+ }
45
+
46
+ // Fallback - convert to string
47
+ return String(value);
48
+ }
49
+
50
+ class TableColumn extends Component {
51
+ get isFrozen() {
52
+ return this.args.isFrozen ?? this.args.column?.isFrozen ?? false;
53
+ }
54
+ get frozenPosition() {
55
+ return this.args.frozenPosition ?? this.args.column?.frozenPosition ?? 'left';
56
+ }
57
+ get classNames() {
58
+ const {
59
+ table
60
+ } = useStyles();
61
+ const options = {
62
+ isFrozen: this.isFrozen,
63
+ frozenPosition: this.isFrozen ? this.frozenPosition : undefined,
64
+ class: this.args.class
65
+ };
66
+ return this.args.thStyles?.(options) || table().th(options);
67
+ }
68
+ static {
69
+ setComponentTemplate(precompileTemplate("\n <th class={{this.classNames}} data-test-id=\"table-column\" data-component=\"table-column\" data-key={{@column.key}} ...attributes>\n {{yield}}\n </th>\n ", {
70
+ strictMode: true
71
+ }), this);
72
+ }
73
+ }
74
+
75
+ class TableHeader extends Component {
76
+ get styles() {
77
+ const {
78
+ table
79
+ } = useStyles();
80
+ return table();
81
+ }
82
+ get classNames() {
83
+ const options = {
84
+ isFrozen: this.args.isFrozen,
85
+ frozenPosition: this.args.isFrozen ? 'top' : undefined,
86
+ class: this.args.class
87
+ };
88
+ return this.args.theadStyles?.(options) || this.styles.thead(options);
89
+ }
90
+ get rowClassNames() {
91
+ return this.args.trStyles?.() || this.styles.tr();
92
+ }
93
+ static {
94
+ setComponentTemplate(precompileTemplate("\n <thead class={{this.classNames}} data-test-id=\"table-header\" data-component=\"table-header\" ...attributes>\n <tr class={{this.rowClassNames}}>\n {{#if (has-block \"default\")}}\n {{yield (hash Column=TableColumn) to=\"default\"}}\n {{else}}\n {{#each @columns as |column|}}\n <TableColumn @column={{column}}>\n {{column.label}}\n </TableColumn>\n {{/each}}\n {{/if}}\n </tr>\n </thead>\n ", {
95
+ strictMode: true,
96
+ scope: () => ({
97
+ hash,
98
+ TableColumn
99
+ })
100
+ }), this);
101
+ }
102
+ }
103
+
104
+ class TableCell extends Component {
105
+ get isFrozen() {
106
+ return this.args.isFrozen ?? this.args.column?.isFrozen ?? false;
107
+ }
108
+ get frozenPosition() {
109
+ return this.args.frozenPosition ?? this.args.column?.frozenPosition ?? 'left';
110
+ }
111
+ get classNames() {
112
+ const {
113
+ table
114
+ } = useStyles();
115
+ const options = {
116
+ isFrozen: this.isFrozen,
117
+ frozenPosition: this.isFrozen ? this.frozenPosition : undefined,
118
+ isInFrozenRow: this.args.isInFrozenRow || false,
119
+ class: this.args.class
120
+ };
121
+ return this.args.tdStyles?.(options) || table().td(options);
122
+ }
123
+ static {
124
+ setComponentTemplate(precompileTemplate("\n <td class={{this.classNames}} data-test-id=\"table-cell\" data-component=\"table-cell\" data-column={{@column.key}} ...attributes>\n {{yield}}\n </td>\n ", {
125
+ strictMode: true
126
+ }), this);
127
+ }
128
+ }
129
+
130
+ class TableRow extends Component {
131
+ get isFrozen() {
132
+ if (this.args.isFrozen) return true;
133
+ if (this.args.frozenKeys && this.args.item) {
134
+ const {
135
+ key
136
+ } = keyAndLabelForItem(this.args.item);
137
+ return this.args.frozenKeys.includes(key);
138
+ }
139
+ return false;
140
+ }
141
+ get classNames() {
142
+ const {
143
+ table
144
+ } = useStyles();
145
+ const options = {
146
+ isFrozen: this.isFrozen,
147
+ frozenPosition: this.isFrozen ? 'top' : undefined,
148
+ hasFrozenHeader: this.args.isFrozenHeader || false,
149
+ class: this.args.class
150
+ };
151
+ return this.args.trStyles?.(options) || table().tr(options);
152
+ }
153
+ get rowKey() {
154
+ if (this.args.item) {
155
+ const {
156
+ key
157
+ } = keyAndLabelForItem(this.args.item);
158
+ return key;
159
+ }
160
+ return '';
161
+ }
162
+ getValue = (item, column) => getSafeValue(item, column);
163
+ static {
164
+ setComponentTemplate(precompileTemplate("\n <tr class={{this.classNames}} data-test-id=\"table-row\" data-component=\"table-row\" data-key={{this.rowKey}} ...attributes>\n {{#if (has-block \"default\")}}\n {{yield (hash Cell=TableCell) to=\"default\"}}\n {{else}}\n {{#each @columns as |column|}}\n {{#if @item}}\n {{#let (this.getValue @item column) as |value|}}\n <TableCell @item={{@item}} @column={{column}} @value={{value}} @isInFrozenRow={{this.isFrozen}} @tdStyles={{@tdStyles}}>\n {{value}}\n </TableCell>\n {{/let}}\n {{/if}}\n {{/each}}\n {{/if}}\n </tr>\n ", {
165
+ strictMode: true,
166
+ scope: () => ({
167
+ hash,
168
+ TableCell
169
+ })
170
+ }), this);
171
+ }
172
+ }
173
+
174
+ class TableBody extends Component {
175
+ get classNames() {
176
+ const {
177
+ table
178
+ } = useStyles();
179
+ return this.args.tbodyStyles?.({
180
+ class: this.args.class
181
+ }) || table().tbody({
182
+ class: this.args.class
183
+ });
184
+ }
185
+ getValue = (item, column) => getSafeValue(item, column);
186
+ static {
187
+ setComponentTemplate(precompileTemplate("\n <tbody class={{this.classNames}} data-test-id=\"table-body\" data-component=\"table-body\" ...attributes>\n {{#if (has-block \"default\")}}\n {{yield (hash Row=TableRow Cell=TableCell) to=\"default\"}}\n {{else}}\n {{#each @items as |item|}}\n {{#if (has-block \"row\")}}\n {{yield (hash item=item Row=TableRow Cell=TableCell) to=\"row\"}}\n {{else}}\n <TableRow @item={{item}} @columns={{@columns}} @trStyles={{@trStyles}} @tdStyles={{@tdStyles}}>\n {{#each @columns as |column|}}\n {{#let (this.getValue item column) as |value|}}\n <TableCell @item={{item}} @column={{column}} @value={{value}} @tdStyles={{@tdStyles}}>\n {{value}}\n </TableCell>\n {{/let}}\n {{/each}}\n </TableRow>\n {{/if}}\n {{/each}}\n {{/if}}\n </tbody>\n ", {
188
+ strictMode: true,
189
+ scope: () => ({
190
+ hash,
191
+ TableRow,
192
+ TableCell
193
+ })
194
+ }), this);
195
+ }
196
+ }
197
+
198
+ class Table extends Component {
199
+ // Needed to make glint happy with generic components
200
+ TableBody = TableBody;
201
+ TableRow = TableRow;
202
+ get styles() {
203
+ const {
204
+ table
205
+ } = useStyles();
206
+ return table({
207
+ size: this.args.size,
208
+ layout: this.args.layout,
209
+ striped: this.args.striped,
210
+ isScrollable: this.args.scrollable || false,
211
+ hasFrozenHeader: this.args.isFrozenHeader || false,
212
+ class: this.args.classes?.base
213
+ });
214
+ }
215
+ get wrapperClassNames() {
216
+ return this.styles.wrapper({
217
+ class: this.args.classes?.wrapper
218
+ });
219
+ }
220
+ updateMaxDimensions = modifier(el => {
221
+ if (this.args.maxHeight) {
222
+ el.style.setProperty('--table-max-height', this.args.maxHeight);
223
+ }
224
+ if (this.args.maxWidth) {
225
+ el.style.setProperty('--table-max-width', this.args.maxWidth);
226
+ }
227
+ });
228
+ calculateHeaderHeight = modifier(el => {
229
+ if (this.args.isFrozenHeader) {
230
+ const updateHeight = () => {
231
+ const thead = el.querySelector('thead');
232
+ if (thead) {
233
+ const headerHeight = Math.round(thead.offsetHeight);
234
+ el.style.setProperty('--table-header-height', `${headerHeight}px`);
235
+ }
236
+ };
237
+ requestAnimationFrame(updateHeight);
238
+ // Update on resize
239
+ let observer;
240
+ observer = new ResizeObserver(updateHeight);
241
+ observer.observe(el);
242
+ return () => {
243
+ if (observer) {
244
+ observer.disconnect();
245
+ }
246
+ };
247
+ }
248
+ });
249
+ get tableClassNames() {
250
+ return this.styles.table({
251
+ class: this.args.classes?.table
252
+ });
253
+ }
254
+ get columns() {
255
+ return this.args.columns || [];
256
+ }
257
+ get items() {
258
+ return this.args.items || [];
259
+ }
260
+ getValue = (item, column) => getSafeValue(item, column);
261
+ static {
262
+ setComponentTemplate(precompileTemplate("\n <div class={{this.wrapperClassNames}} {{this.updateMaxDimensions}} {{this.calculateHeaderHeight}} data-component=\"table-wrapper\">\n <table class={{this.tableClassNames}} data-test-id=\"table\" data-component=\"table\" ...attributes>\n {{#if (has-block \"default\")}}\n {{yield (hash Column=(component TableColumn thStyles=this.styles.th) Header=(component TableHeader columns=this.columns theadStyles=this.styles.thead trStyles=this.styles.tr) Body=(component this.TableBody columns=this.columns items=this.items tbodyStyles=this.styles.tbody trStyles=this.styles.tr thStyles=this.styles.th tdStyles=this.styles.td) Row=(component this.TableRow columns=this.columns frozenKeys=@frozenKeys isFrozenHeader=@isFrozenHeader trStyles=this.styles.tr tdStyles=this.styles.td) Cell=(component TableCell tdStyles=this.styles.td)) to=\"default\"}}\n {{else}}\n <TableHeader @columns={{this.columns}} @isFrozen={{@isFrozenHeader}} @theadStyles={{this.styles.thead}} @trStyles={{this.styles.tr}}>\n {{#each this.columns as |column|}}\n <TableColumn @column={{column}} @thStyles={{this.styles.th}}>\n {{column.label}}\n </TableColumn>\n {{/each}}\n </TableHeader>\n\n <TableBody @columns={{this.columns}} @items={{this.items}} @tbodyStyles={{this.styles.tbody}} @trStyles={{this.styles.tr}} @thStyles={{this.styles.th}} @tdStyles={{this.styles.td}}>\n\n {{#each this.items as |item|}}\n <TableRow @item={{item}} @columns={{this.columns}} @frozenKeys={{@frozenKeys}} @isFrozenHeader={{@isFrozenHeader}} @trStyles={{this.styles.tr}} @tdStyles={{this.styles.td}}>\n {{#each this.columns as |column|}}\n {{#let (this.getValue item column) as |value|}}\n <TableCell @item={{item}} @column={{column}} @value={{value}} @tdStyles={{this.styles.td}}>\n {{value}}\n </TableCell>\n {{/let}}\n {{/each}}\n </TableRow>\n {{else}}\n {{#if @emptyContent}}\n <TableRow @trStyles={{this.styles.tr}} data-test-id=\"table-empty-row\">\n <TableCell colspan={{this.columns.length}} @tdStyles={{this.styles.td}} @class={{(this.styles.emptyCell)}} data-test-id=\"table-empty-cell\">\n {{@emptyContent}}\n </TableCell>\n </TableRow>\n {{/if}}\n {{/each}}\n </TableBody>\n {{/if}}\n </table>\n </div>\n ", {
263
+ strictMode: true,
264
+ scope: () => ({
265
+ hash,
266
+ TableColumn,
267
+ TableHeader,
268
+ TableCell,
269
+ TableBody,
270
+ TableRow
271
+ })
272
+ }), this);
273
+ }
274
+ }
275
+
276
+ export { Table as T, TableHeader as a, TableBody as b, TableColumn as c, TableRow as d, TableCell as e };
277
+ //# sourceMappingURL=table-92ff_YNO.js.map