@adecore/ui 0.61.0 → 0.62.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.
@@ -0,0 +1,1075 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { useRender } from '@base-ui/react/use-render';
3
+ import clsx from 'clsx';
4
+ import { ArrowDown, ArrowUp, ChevronsUpDown } from 'lucide-react';
5
+ import { Children, createContext, useContext, useId } from 'react';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { Icon } from "../Icon.js";
8
+ import { ScrollArea } from "../ScrollArea.js";
9
+ import { Skeleton } from "../Skeleton.js";
10
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
+ const BREAKPOINTS = ['sm', 'md', 'lg', 'xl', '2xl'];
12
+ /* A narrower query comes later in the CSS, so it wins over a wider one. */
13
+ const TEMPLATE_BELOW = {
14
+ sm: '@max-sm:grid-cols-(--table-columns-sm)',
15
+ md: '@max-md:grid-cols-(--table-columns-md)',
16
+ lg: '@max-lg:grid-cols-(--table-columns-lg)',
17
+ xl: '@max-xl:grid-cols-(--table-columns-xl)',
18
+ '2xl': '@max-2xl:grid-cols-(--table-columns-2xl)'
19
+ };
20
+ const HIDDEN_BELOW = {
21
+ sm: '@max-sm:hidden',
22
+ md: '@max-md:hidden',
23
+ lg: '@max-lg:hidden',
24
+ xl: '@max-xl:hidden',
25
+ '2xl': '@max-2xl:hidden'
26
+ };
27
+ const ROW_HEIGHT = {
28
+ regular: 'min-h-10',
29
+ compact: 'min-h-8'
30
+ };
31
+ const CELL_PADDING = {
32
+ regular: 'py-2',
33
+ compact: 'py-1'
34
+ };
35
+ const TEXT_SIZE = {
36
+ regular: 'text-sm',
37
+ compact: 'text-xs'
38
+ };
39
+ const ARIA_SORT = {
40
+ none: 'none',
41
+ asc: 'ascending',
42
+ desc: 'descending'
43
+ };
44
+ const SKELETON_WIDTHS = ['w-3/4', 'w-1/2', 'w-2/3'];
45
+ /* Every row is a subgrid of the table, so its cells line up with the columns and it still has a box to tint and focus. */
46
+ const ROW = 'col-span-full grid grid-cols-subgrid items-center px-4.5';
47
+ /* A click that lands on one of these inside a row is the control's, not the row's. */
48
+ const CONTROLS = 'a[href], button, input, select, textarea, label, [contenteditable="true"], [role="button"], [role="checkbox"], [role="switch"], [role="menuitem"], [role="option"]';
49
+ const TableContext = createContext({
50
+ columns: [],
51
+ density: 'regular',
52
+ scrolls: false
53
+ });
54
+ const ColumnIndexContext = createContext(-1);
55
+ const templateOf = columns => columns.map(column => column.width).join(' ');
56
+ /* Below a breakpoint every column that hides at it or at a wider one is gone. */
57
+ const visibleBelow = (columns, breakpoint) => columns.filter(column => column.hideBelow === undefined || BREAKPOINTS.indexOf(column.hideBelow) < BREAKPOINTS.indexOf(breakpoint));
58
+ /* A cell knows its column by its place in the row, so cells are the row's direct children. */
59
+ const indexed = children => Children.map(children, (child, index) => /*#__PURE__*/_jsx(ColumnIndexContext, {
60
+ value: index,
61
+ children: child
62
+ }));
63
+ const columnClass = column => clsx('flex min-w-0 items-center gap-2', column?.align === 'end' && 'justify-end text-end tabular-nums', column?.hideBelow && HIDDEN_BELOW[column.hideBelow]);
64
+ function useColumn() {
65
+ const {
66
+ columns
67
+ } = useContext(TableContext);
68
+ return columns[useContext(ColumnIndexContext)];
69
+ }
70
+ /* A grid rather than a `<table>`, so a cell holds any control and a column can leave on a narrow table. */
71
+ export function TableRoot(t0) {
72
+ const $ = _c(36);
73
+ let children;
74
+ let className;
75
+ let columns;
76
+ let label;
77
+ let maxHeight;
78
+ let props;
79
+ let t1;
80
+ let t2;
81
+ if ($[0] !== t0) {
82
+ ({
83
+ label,
84
+ columns,
85
+ density: t1,
86
+ framed: t2,
87
+ maxHeight,
88
+ className,
89
+ children,
90
+ ...props
91
+ } = t0);
92
+ $[0] = t0;
93
+ $[1] = children;
94
+ $[2] = className;
95
+ $[3] = columns;
96
+ $[4] = label;
97
+ $[5] = maxHeight;
98
+ $[6] = props;
99
+ $[7] = t1;
100
+ $[8] = t2;
101
+ } else {
102
+ children = $[1];
103
+ className = $[2];
104
+ columns = $[3];
105
+ label = $[4];
106
+ maxHeight = $[5];
107
+ props = $[6];
108
+ t1 = $[7];
109
+ t2 = $[8];
110
+ }
111
+ const density = t1 === undefined ? "regular" : t1;
112
+ const framed = t2 === undefined ? false : t2;
113
+ const scrolls = maxHeight !== undefined;
114
+ let t3;
115
+ let tracks;
116
+ if ($[9] !== columns || $[10] !== density) {
117
+ let t4;
118
+ if ($[13] !== columns) {
119
+ t4 = breakpoint => columns.some(column => column.hideBelow === breakpoint);
120
+ $[13] = columns;
121
+ $[14] = t4;
122
+ } else {
123
+ t4 = $[14];
124
+ }
125
+ const used = BREAKPOINTS.filter(t4);
126
+ tracks = {
127
+ "--table-columns": templateOf(columns)
128
+ };
129
+ for (const breakpoint_0 of used) {
130
+ tracks[`--table-columns-${breakpoint_0}`] = templateOf(visibleBelow(columns, breakpoint_0));
131
+ }
132
+ t3 = clsx("ade-table-grid grid grid-cols-(--table-columns) gap-x-3", used.map(_temp), TEXT_SIZE[density]);
133
+ $[9] = columns;
134
+ $[10] = density;
135
+ $[11] = t3;
136
+ $[12] = tracks;
137
+ } else {
138
+ t3 = $[11];
139
+ tracks = $[12];
140
+ }
141
+ const grid = t3;
142
+ let t4;
143
+ if ($[15] !== columns || $[16] !== density || $[17] !== scrolls) {
144
+ t4 = {
145
+ columns,
146
+ density,
147
+ scrolls
148
+ };
149
+ $[15] = columns;
150
+ $[16] = density;
151
+ $[17] = scrolls;
152
+ $[18] = t4;
153
+ } else {
154
+ t4 = $[18];
155
+ }
156
+ const t5 = framed && "overflow-clip rounded-lg border border-border bg-surface";
157
+ let t6;
158
+ if ($[19] !== className || $[20] !== t5) {
159
+ t6 = clsx("@container min-w-0 text-text", t5, className);
160
+ $[19] = className;
161
+ $[20] = t5;
162
+ $[21] = t6;
163
+ } else {
164
+ t6 = $[21];
165
+ }
166
+ let t7;
167
+ if ($[22] !== children || $[23] !== grid || $[24] !== maxHeight || $[25] !== scrolls || $[26] !== tracks) {
168
+ t7 = scrolls ? /*#__PURE__*/_jsx(ScrollArea, {
169
+ viewportClassName: grid,
170
+ style: {
171
+ ...tracks,
172
+ maxHeight
173
+ },
174
+ children: children
175
+ }) : /*#__PURE__*/_jsx("div", {
176
+ className: grid,
177
+ style: tracks,
178
+ children: children
179
+ });
180
+ $[22] = children;
181
+ $[23] = grid;
182
+ $[24] = maxHeight;
183
+ $[25] = scrolls;
184
+ $[26] = tracks;
185
+ $[27] = t7;
186
+ } else {
187
+ t7 = $[27];
188
+ }
189
+ let t8;
190
+ if ($[28] !== label || $[29] !== props || $[30] !== t6 || $[31] !== t7) {
191
+ t8 = /*#__PURE__*/_jsx("div", {
192
+ role: "table",
193
+ "aria-label": label,
194
+ ...props,
195
+ className: t6,
196
+ children: t7
197
+ });
198
+ $[28] = label;
199
+ $[29] = props;
200
+ $[30] = t6;
201
+ $[31] = t7;
202
+ $[32] = t8;
203
+ } else {
204
+ t8 = $[32];
205
+ }
206
+ let t9;
207
+ if ($[33] !== t4 || $[34] !== t8) {
208
+ t9 = /*#__PURE__*/_jsx(TableContext, {
209
+ value: t4,
210
+ children: t8
211
+ });
212
+ $[33] = t4;
213
+ $[34] = t8;
214
+ $[35] = t9;
215
+ } else {
216
+ t9 = $[35];
217
+ }
218
+ return t9;
219
+ }
220
+ /* The row of column headers. It stays at the top while the body scrolls, on the surface color. */
221
+ function _temp(breakpoint_1) {
222
+ return TEMPLATE_BELOW[breakpoint_1];
223
+ }
224
+ export function TableHead(t0) {
225
+ const $ = _c(24);
226
+ let children;
227
+ let className;
228
+ let props;
229
+ let ref;
230
+ let render;
231
+ if ($[0] !== t0) {
232
+ ({
233
+ render,
234
+ className,
235
+ ref,
236
+ children,
237
+ ...props
238
+ } = t0);
239
+ $[0] = t0;
240
+ $[1] = children;
241
+ $[2] = className;
242
+ $[3] = props;
243
+ $[4] = ref;
244
+ $[5] = render;
245
+ } else {
246
+ children = $[1];
247
+ className = $[2];
248
+ props = $[3];
249
+ ref = $[4];
250
+ render = $[5];
251
+ }
252
+ const {
253
+ density,
254
+ scrolls
255
+ } = useContext(TableContext);
256
+ const t1 = scrolls && "sticky top-0 z-1 bg-surface";
257
+ let t2;
258
+ if ($[6] !== className || $[7] !== t1) {
259
+ t2 = clsx("ade-table-head col-span-full grid grid-cols-subgrid border-b border-border", t1, className);
260
+ $[6] = className;
261
+ $[7] = t1;
262
+ $[8] = t2;
263
+ } else {
264
+ t2 = $[8];
265
+ }
266
+ const t3 = density === "compact" ? "min-h-7" : "min-h-8";
267
+ let t4;
268
+ if ($[9] !== t3) {
269
+ t4 = clsx(ROW, t3, "text-2xs font-medium text-text-muted");
270
+ $[9] = t3;
271
+ $[10] = t4;
272
+ } else {
273
+ t4 = $[10];
274
+ }
275
+ let t5;
276
+ if ($[11] !== children) {
277
+ t5 = indexed(children);
278
+ $[11] = children;
279
+ $[12] = t5;
280
+ } else {
281
+ t5 = $[12];
282
+ }
283
+ let t6;
284
+ if ($[13] !== t4 || $[14] !== t5) {
285
+ t6 = /*#__PURE__*/_jsx("div", {
286
+ role: "row",
287
+ className: t4,
288
+ children: t5
289
+ });
290
+ $[13] = t4;
291
+ $[14] = t5;
292
+ $[15] = t6;
293
+ } else {
294
+ t6 = $[15];
295
+ }
296
+ let t7;
297
+ if ($[16] !== props || $[17] !== t2 || $[18] !== t6) {
298
+ t7 = {
299
+ role: "rowgroup",
300
+ ...props,
301
+ className: t2,
302
+ children: t6
303
+ };
304
+ $[16] = props;
305
+ $[17] = t2;
306
+ $[18] = t6;
307
+ $[19] = t7;
308
+ } else {
309
+ t7 = $[19];
310
+ }
311
+ let t8;
312
+ if ($[20] !== ref || $[21] !== render || $[22] !== t7) {
313
+ t8 = {
314
+ render,
315
+ ref,
316
+ defaultTagName: "div",
317
+ props: t7
318
+ };
319
+ $[20] = ref;
320
+ $[21] = render;
321
+ $[22] = t7;
322
+ $[23] = t8;
323
+ } else {
324
+ t8 = $[23];
325
+ }
326
+ return useRender(t8);
327
+ }
328
+ export function TableColumn(t0) {
329
+ const $ = _c(26);
330
+ let children;
331
+ let className;
332
+ let onSort;
333
+ let props;
334
+ let ref;
335
+ let render;
336
+ let sort;
337
+ if ($[0] !== t0) {
338
+ ({
339
+ sort,
340
+ onSort,
341
+ render,
342
+ className,
343
+ ref,
344
+ children,
345
+ ...props
346
+ } = t0);
347
+ $[0] = t0;
348
+ $[1] = children;
349
+ $[2] = className;
350
+ $[3] = onSort;
351
+ $[4] = props;
352
+ $[5] = ref;
353
+ $[6] = render;
354
+ $[7] = sort;
355
+ } else {
356
+ children = $[1];
357
+ className = $[2];
358
+ onSort = $[3];
359
+ props = $[4];
360
+ ref = $[5];
361
+ render = $[6];
362
+ sort = $[7];
363
+ }
364
+ const column = useColumn();
365
+ let t1;
366
+ if ($[8] !== children) {
367
+ t1 = /*#__PURE__*/_jsx("span", {
368
+ className: "truncate",
369
+ children: children
370
+ });
371
+ $[8] = children;
372
+ $[9] = t1;
373
+ } else {
374
+ t1 = $[9];
375
+ }
376
+ const label = t1;
377
+ const t2 = sort === undefined ? undefined : ARIA_SORT[sort];
378
+ let t3;
379
+ if ($[10] !== className || $[11] !== column) {
380
+ t3 = clsx(columnClass(column), "py-1.5", className);
381
+ $[10] = className;
382
+ $[11] = column;
383
+ $[12] = t3;
384
+ } else {
385
+ t3 = $[12];
386
+ }
387
+ let t4;
388
+ if ($[13] !== label || $[14] !== onSort || $[15] !== sort) {
389
+ t4 = sort === undefined ? label : /*#__PURE__*/_jsxs("button", {
390
+ type: "button",
391
+ className: "-mx-1 inline-flex min-w-0 items-center gap-1 rounded-sm px-1 hover:text-text",
392
+ onClick: () => onSort?.(sort === "asc" ? "desc" : "asc"),
393
+ children: [label, /*#__PURE__*/_jsx(Icon, {
394
+ icon: sort === "asc" ? ArrowUp : sort === "desc" ? ArrowDown : ChevronsUpDown,
395
+ size: 12,
396
+ className: clsx("shrink-0", sort === "none" && "text-text-faint")
397
+ })]
398
+ });
399
+ $[13] = label;
400
+ $[14] = onSort;
401
+ $[15] = sort;
402
+ $[16] = t4;
403
+ } else {
404
+ t4 = $[16];
405
+ }
406
+ let t5;
407
+ if ($[17] !== props || $[18] !== t2 || $[19] !== t3 || $[20] !== t4) {
408
+ t5 = {
409
+ role: "columnheader",
410
+ "aria-sort": t2,
411
+ ...props,
412
+ className: t3,
413
+ children: t4
414
+ };
415
+ $[17] = props;
416
+ $[18] = t2;
417
+ $[19] = t3;
418
+ $[20] = t4;
419
+ $[21] = t5;
420
+ } else {
421
+ t5 = $[21];
422
+ }
423
+ let t6;
424
+ if ($[22] !== ref || $[23] !== render || $[24] !== t5) {
425
+ t6 = {
426
+ render,
427
+ ref,
428
+ defaultTagName: "div",
429
+ props: t5
430
+ };
431
+ $[22] = ref;
432
+ $[23] = render;
433
+ $[24] = t5;
434
+ $[25] = t6;
435
+ } else {
436
+ t6 = $[25];
437
+ }
438
+ return useRender(t6);
439
+ }
440
+ const fromControl = event => {
441
+ const row = event.currentTarget;
442
+ const target = event.target;
443
+ // React bubbles a click out of a portal, such as a menu opened from a cell, into the row.
444
+ if (!(target instanceof Element) || !row.contains(target)) {
445
+ return true;
446
+ }
447
+ const control = target.closest(CONTROLS);
448
+ return control !== null && control !== row && row.contains(control);
449
+ };
450
+ /* With `onClick` the row is a tab stop that Enter and Space press, unless `focusable` is false, and a click on a control inside it stays the control's. */
451
+ export function TableRow(t0) {
452
+ const $ = _c(37);
453
+ let children;
454
+ let className;
455
+ let onClick;
456
+ let onKeyDown;
457
+ let props;
458
+ let ref;
459
+ let render;
460
+ let t1;
461
+ let t2;
462
+ let t3;
463
+ if ($[0] !== t0) {
464
+ ({
465
+ selected: t1,
466
+ muted: t2,
467
+ focusable: t3,
468
+ onClick,
469
+ onKeyDown,
470
+ render,
471
+ className,
472
+ ref,
473
+ children,
474
+ ...props
475
+ } = t0);
476
+ $[0] = t0;
477
+ $[1] = children;
478
+ $[2] = className;
479
+ $[3] = onClick;
480
+ $[4] = onKeyDown;
481
+ $[5] = props;
482
+ $[6] = ref;
483
+ $[7] = render;
484
+ $[8] = t1;
485
+ $[9] = t2;
486
+ $[10] = t3;
487
+ } else {
488
+ children = $[1];
489
+ className = $[2];
490
+ onClick = $[3];
491
+ onKeyDown = $[4];
492
+ props = $[5];
493
+ ref = $[6];
494
+ render = $[7];
495
+ t1 = $[8];
496
+ t2 = $[9];
497
+ t3 = $[10];
498
+ }
499
+ const selected = t1 === undefined ? false : t1;
500
+ const muted = t2 === undefined ? false : t2;
501
+ const focusable = t3 === undefined ? true : t3;
502
+ const {
503
+ density
504
+ } = useContext(TableContext);
505
+ const clickable = onClick !== undefined;
506
+ const pressable = clickable && focusable;
507
+ const t4 = pressable ? 0 : undefined;
508
+ const t5 = selected ? "" : undefined;
509
+ const t6 = ROW_HEIGHT[density];
510
+ const t7 = selected ? "bg-accent-soft" : clickable && "hover:bg-surface-hover";
511
+ const t8 = pressable && "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent-on-surface";
512
+ const t9 = muted && "text-text-muted";
513
+ let t10;
514
+ if ($[11] !== className || $[12] !== t6 || $[13] !== t7 || $[14] !== t8 || $[15] !== t9) {
515
+ t10 = clsx("ade-table-line", ROW, t6, t7, t8, t9, className);
516
+ $[11] = className;
517
+ $[12] = t6;
518
+ $[13] = t7;
519
+ $[14] = t8;
520
+ $[15] = t9;
521
+ $[16] = t10;
522
+ } else {
523
+ t10 = $[16];
524
+ }
525
+ let t11;
526
+ if ($[17] !== clickable || $[18] !== onClick) {
527
+ t11 = clickable ? event => {
528
+ if (!fromControl(event)) {
529
+ onClick(event);
530
+ }
531
+ } : undefined;
532
+ $[17] = clickable;
533
+ $[18] = onClick;
534
+ $[19] = t11;
535
+ } else {
536
+ t11 = $[19];
537
+ }
538
+ let t12;
539
+ if ($[20] !== onKeyDown || $[21] !== pressable) {
540
+ t12 = event_0 => {
541
+ onKeyDown?.(event_0);
542
+ if (!pressable || event_0.defaultPrevented || event_0.target !== event_0.currentTarget || event_0.key !== "Enter" && event_0.key !== " ") {
543
+ return;
544
+ }
545
+ event_0.preventDefault();
546
+ event_0.currentTarget.click();
547
+ };
548
+ $[20] = onKeyDown;
549
+ $[21] = pressable;
550
+ $[22] = t12;
551
+ } else {
552
+ t12 = $[22];
553
+ }
554
+ let t13;
555
+ if ($[23] !== children) {
556
+ t13 = indexed(children);
557
+ $[23] = children;
558
+ $[24] = t13;
559
+ } else {
560
+ t13 = $[24];
561
+ }
562
+ let t14;
563
+ if ($[25] !== props || $[26] !== t10 || $[27] !== t11 || $[28] !== t12 || $[29] !== t13 || $[30] !== t4 || $[31] !== t5) {
564
+ t14 = {
565
+ role: "row",
566
+ tabIndex: t4,
567
+ ...props,
568
+ "data-selected": t5,
569
+ className: t10,
570
+ onClick: t11,
571
+ onKeyDown: t12,
572
+ children: t13
573
+ };
574
+ $[25] = props;
575
+ $[26] = t10;
576
+ $[27] = t11;
577
+ $[28] = t12;
578
+ $[29] = t13;
579
+ $[30] = t4;
580
+ $[31] = t5;
581
+ $[32] = t14;
582
+ } else {
583
+ t14 = $[32];
584
+ }
585
+ let t15;
586
+ if ($[33] !== ref || $[34] !== render || $[35] !== t14) {
587
+ t15 = {
588
+ render,
589
+ ref,
590
+ defaultTagName: "div",
591
+ props: t14
592
+ };
593
+ $[33] = ref;
594
+ $[34] = render;
595
+ $[35] = t14;
596
+ $[36] = t15;
597
+ } else {
598
+ t15 = $[36];
599
+ }
600
+ return useRender(t15);
601
+ }
602
+ const isText = children => typeof children === 'string' || typeof children === 'number' || Array.isArray(children) && children.every(child => typeof child === 'string' || typeof child === 'number');
603
+ /* Takes its column's alignment and hiding. Any content may sit inside: a pill, a switch, a checkbox, an input or a menu button. */
604
+ export function TableCell(t0) {
605
+ const $ = _c(25);
606
+ let children;
607
+ let className;
608
+ let props;
609
+ let ref;
610
+ let render;
611
+ let t1;
612
+ let t2;
613
+ if ($[0] !== t0) {
614
+ ({
615
+ truncate: t1,
616
+ mono: t2,
617
+ render,
618
+ className,
619
+ ref,
620
+ children,
621
+ ...props
622
+ } = t0);
623
+ $[0] = t0;
624
+ $[1] = children;
625
+ $[2] = className;
626
+ $[3] = props;
627
+ $[4] = ref;
628
+ $[5] = render;
629
+ $[6] = t1;
630
+ $[7] = t2;
631
+ } else {
632
+ children = $[1];
633
+ className = $[2];
634
+ props = $[3];
635
+ ref = $[4];
636
+ render = $[5];
637
+ t1 = $[6];
638
+ t2 = $[7];
639
+ }
640
+ const truncate = t1 === undefined ? true : t1;
641
+ const mono = t2 === undefined ? false : t2;
642
+ const column = useColumn();
643
+ const {
644
+ density
645
+ } = useContext(TableContext);
646
+ let t3;
647
+ if ($[8] !== className || $[9] !== column || $[10] !== density || $[11] !== mono || $[12] !== truncate) {
648
+ t3 = clsx(columnClass(column), CELL_PADDING[density], !truncate && "flex-wrap", mono && "font-mono text-code text-text-muted", className);
649
+ $[8] = className;
650
+ $[9] = column;
651
+ $[10] = density;
652
+ $[11] = mono;
653
+ $[12] = truncate;
654
+ $[13] = t3;
655
+ } else {
656
+ t3 = $[13];
657
+ }
658
+ let t4;
659
+ if ($[14] !== children || $[15] !== truncate) {
660
+ t4 = isText(children) ? /*#__PURE__*/_jsx("span", {
661
+ className: truncate ? "min-w-0 truncate" : "min-w-0 break-words",
662
+ children: children
663
+ }) : children;
664
+ $[14] = children;
665
+ $[15] = truncate;
666
+ $[16] = t4;
667
+ } else {
668
+ t4 = $[16];
669
+ }
670
+ let t5;
671
+ if ($[17] !== props || $[18] !== t3 || $[19] !== t4) {
672
+ t5 = {
673
+ role: "cell",
674
+ ...props,
675
+ className: t3,
676
+ children: t4
677
+ };
678
+ $[17] = props;
679
+ $[18] = t3;
680
+ $[19] = t4;
681
+ $[20] = t5;
682
+ } else {
683
+ t5 = $[20];
684
+ }
685
+ let t6;
686
+ if ($[21] !== ref || $[22] !== render || $[23] !== t5) {
687
+ t6 = {
688
+ render,
689
+ ref,
690
+ defaultTagName: "div",
691
+ props: t5
692
+ };
693
+ $[21] = ref;
694
+ $[22] = render;
695
+ $[23] = t5;
696
+ $[24] = t6;
697
+ } else {
698
+ t6 = $[24];
699
+ }
700
+ return useRender(t6);
701
+ }
702
+ export function TableGroup(t0) {
703
+ const $ = _c(25);
704
+ let children;
705
+ let className;
706
+ let label;
707
+ let props;
708
+ let ref;
709
+ let render;
710
+ if ($[0] !== t0) {
711
+ ({
712
+ label,
713
+ render,
714
+ className,
715
+ ref,
716
+ children,
717
+ ...props
718
+ } = t0);
719
+ $[0] = t0;
720
+ $[1] = children;
721
+ $[2] = className;
722
+ $[3] = label;
723
+ $[4] = props;
724
+ $[5] = ref;
725
+ $[6] = render;
726
+ } else {
727
+ children = $[1];
728
+ className = $[2];
729
+ label = $[3];
730
+ props = $[4];
731
+ ref = $[5];
732
+ render = $[6];
733
+ }
734
+ const {
735
+ columns
736
+ } = useContext(TableContext);
737
+ const id = useId();
738
+ let t1;
739
+ if ($[7] !== className) {
740
+ t1 = clsx("col-span-full grid grid-cols-subgrid", className);
741
+ $[7] = className;
742
+ $[8] = t1;
743
+ } else {
744
+ t1 = $[8];
745
+ }
746
+ let t2;
747
+ if ($[9] !== columns.length || $[10] !== id || $[11] !== label) {
748
+ t2 = /*#__PURE__*/_jsx("div", {
749
+ role: "row",
750
+ className: "ade-table-line col-span-full grid min-h-8 grid-cols-subgrid items-end px-4.5 pt-3 pb-1 text-2xs text-text-faint",
751
+ children: /*#__PURE__*/_jsx("div", {
752
+ role: "cell",
753
+ id: id,
754
+ "aria-colspan": columns.length,
755
+ className: "col-span-full min-w-0 truncate",
756
+ children: label
757
+ })
758
+ });
759
+ $[9] = columns.length;
760
+ $[10] = id;
761
+ $[11] = label;
762
+ $[12] = t2;
763
+ } else {
764
+ t2 = $[12];
765
+ }
766
+ let t3;
767
+ if ($[13] !== children || $[14] !== t2) {
768
+ t3 = /*#__PURE__*/_jsxs(_Fragment, {
769
+ children: [t2, children]
770
+ });
771
+ $[13] = children;
772
+ $[14] = t2;
773
+ $[15] = t3;
774
+ } else {
775
+ t3 = $[15];
776
+ }
777
+ let t4;
778
+ if ($[16] !== id || $[17] !== props || $[18] !== t1 || $[19] !== t3) {
779
+ t4 = {
780
+ role: "rowgroup",
781
+ "aria-labelledby": id,
782
+ ...props,
783
+ className: t1,
784
+ children: t3
785
+ };
786
+ $[16] = id;
787
+ $[17] = props;
788
+ $[18] = t1;
789
+ $[19] = t3;
790
+ $[20] = t4;
791
+ } else {
792
+ t4 = $[20];
793
+ }
794
+ let t5;
795
+ if ($[21] !== ref || $[22] !== render || $[23] !== t4) {
796
+ t5 = {
797
+ render,
798
+ ref,
799
+ defaultTagName: "div",
800
+ props: t4
801
+ };
802
+ $[21] = ref;
803
+ $[22] = render;
804
+ $[23] = t4;
805
+ $[24] = t5;
806
+ } else {
807
+ t5 = $[24];
808
+ }
809
+ return useRender(t5);
810
+ }
811
+ /* The totals under the body, behind a stronger line. Its cells follow the columns like a row's. */
812
+ export function TableFoot(t0) {
813
+ const $ = _c(23);
814
+ let children;
815
+ let className;
816
+ let props;
817
+ let ref;
818
+ let render;
819
+ if ($[0] !== t0) {
820
+ ({
821
+ render,
822
+ className,
823
+ ref,
824
+ children,
825
+ ...props
826
+ } = t0);
827
+ $[0] = t0;
828
+ $[1] = children;
829
+ $[2] = className;
830
+ $[3] = props;
831
+ $[4] = ref;
832
+ $[5] = render;
833
+ } else {
834
+ children = $[1];
835
+ className = $[2];
836
+ props = $[3];
837
+ ref = $[4];
838
+ render = $[5];
839
+ }
840
+ const {
841
+ density
842
+ } = useContext(TableContext);
843
+ let t1;
844
+ if ($[6] !== className) {
845
+ t1 = clsx("col-span-full grid grid-cols-subgrid border-t border-border font-medium", className);
846
+ $[6] = className;
847
+ $[7] = t1;
848
+ } else {
849
+ t1 = $[7];
850
+ }
851
+ const t2 = ROW_HEIGHT[density];
852
+ let t3;
853
+ if ($[8] !== t2) {
854
+ t3 = clsx(ROW, t2);
855
+ $[8] = t2;
856
+ $[9] = t3;
857
+ } else {
858
+ t3 = $[9];
859
+ }
860
+ let t4;
861
+ if ($[10] !== children) {
862
+ t4 = indexed(children);
863
+ $[10] = children;
864
+ $[11] = t4;
865
+ } else {
866
+ t4 = $[11];
867
+ }
868
+ let t5;
869
+ if ($[12] !== t3 || $[13] !== t4) {
870
+ t5 = /*#__PURE__*/_jsx("div", {
871
+ role: "row",
872
+ className: t3,
873
+ children: t4
874
+ });
875
+ $[12] = t3;
876
+ $[13] = t4;
877
+ $[14] = t5;
878
+ } else {
879
+ t5 = $[14];
880
+ }
881
+ let t6;
882
+ if ($[15] !== props || $[16] !== t1 || $[17] !== t5) {
883
+ t6 = {
884
+ role: "rowgroup",
885
+ ...props,
886
+ className: t1,
887
+ children: t5
888
+ };
889
+ $[15] = props;
890
+ $[16] = t1;
891
+ $[17] = t5;
892
+ $[18] = t6;
893
+ } else {
894
+ t6 = $[18];
895
+ }
896
+ let t7;
897
+ if ($[19] !== ref || $[20] !== render || $[21] !== t6) {
898
+ t7 = {
899
+ render,
900
+ ref,
901
+ defaultTagName: "div",
902
+ props: t6
903
+ };
904
+ $[19] = ref;
905
+ $[20] = render;
906
+ $[21] = t6;
907
+ $[22] = t7;
908
+ } else {
909
+ t7 = $[22];
910
+ }
911
+ return useRender(t7);
912
+ }
913
+ /* The one row of a table without rows, its message across every column. */
914
+ export function TableEmpty(t0) {
915
+ const $ = _c(19);
916
+ let children;
917
+ let className;
918
+ let props;
919
+ let ref;
920
+ let render;
921
+ if ($[0] !== t0) {
922
+ ({
923
+ render,
924
+ className,
925
+ ref,
926
+ children,
927
+ ...props
928
+ } = t0);
929
+ $[0] = t0;
930
+ $[1] = children;
931
+ $[2] = className;
932
+ $[3] = props;
933
+ $[4] = ref;
934
+ $[5] = render;
935
+ } else {
936
+ children = $[1];
937
+ className = $[2];
938
+ props = $[3];
939
+ ref = $[4];
940
+ render = $[5];
941
+ }
942
+ const {
943
+ columns
944
+ } = useContext(TableContext);
945
+ let t1;
946
+ if ($[6] !== className) {
947
+ t1 = clsx("ade-table-line", ROW, className);
948
+ $[6] = className;
949
+ $[7] = t1;
950
+ } else {
951
+ t1 = $[7];
952
+ }
953
+ let t2;
954
+ if ($[8] !== children || $[9] !== columns.length) {
955
+ t2 = /*#__PURE__*/_jsx("div", {
956
+ role: "cell",
957
+ "aria-colspan": columns.length,
958
+ className: "col-span-full min-w-0 py-6 text-center break-words text-text-muted",
959
+ children: children
960
+ });
961
+ $[8] = children;
962
+ $[9] = columns.length;
963
+ $[10] = t2;
964
+ } else {
965
+ t2 = $[10];
966
+ }
967
+ let t3;
968
+ if ($[11] !== props || $[12] !== t1 || $[13] !== t2) {
969
+ t3 = {
970
+ role: "row",
971
+ ...props,
972
+ className: t1,
973
+ children: t2
974
+ };
975
+ $[11] = props;
976
+ $[12] = t1;
977
+ $[13] = t2;
978
+ $[14] = t3;
979
+ } else {
980
+ t3 = $[14];
981
+ }
982
+ let t4;
983
+ if ($[15] !== ref || $[16] !== render || $[17] !== t3) {
984
+ t4 = {
985
+ render,
986
+ ref,
987
+ defaultTagName: "div",
988
+ props: t3
989
+ };
990
+ $[15] = ref;
991
+ $[16] = render;
992
+ $[17] = t3;
993
+ $[18] = t4;
994
+ } else {
995
+ t4 = $[18];
996
+ }
997
+ return useRender(t4);
998
+ }
999
+ /* Rows of bars under the columns; a screen reader hears that the table is loading instead. */
1000
+ export function TableLoading(t0) {
1001
+ const $ = _c(14);
1002
+ const {
1003
+ rows: t1,
1004
+ className,
1005
+ ref
1006
+ } = t0;
1007
+ const rows = t1 === undefined ? 3 : t1;
1008
+ const {
1009
+ t
1010
+ } = useTranslation("ui");
1011
+ const {
1012
+ columns
1013
+ } = useContext(TableContext);
1014
+ let t2;
1015
+ if ($[0] !== t) {
1016
+ t2 = t("table.loading");
1017
+ $[0] = t;
1018
+ $[1] = t2;
1019
+ } else {
1020
+ t2 = $[1];
1021
+ }
1022
+ let t3;
1023
+ if ($[2] !== className) {
1024
+ t3 = clsx("col-span-full grid grid-cols-subgrid", className);
1025
+ $[2] = className;
1026
+ $[3] = t3;
1027
+ } else {
1028
+ t3 = $[3];
1029
+ }
1030
+ let t4;
1031
+ if ($[4] !== columns || $[5] !== rows) {
1032
+ let t5;
1033
+ if ($[7] !== columns) {
1034
+ t5 = (_, row) => /*#__PURE__*/_jsx(TableRow, {
1035
+ "aria-hidden": true,
1036
+ children: Array.from(columns, (__0, index) => /*#__PURE__*/_jsx(TableCell, {
1037
+ children: /*#__PURE__*/_jsx(Skeleton, {
1038
+ className: SKELETON_WIDTHS[(row + index) % SKELETON_WIDTHS.length]
1039
+ })
1040
+ }, index))
1041
+ }, row);
1042
+ $[7] = columns;
1043
+ $[8] = t5;
1044
+ } else {
1045
+ t5 = $[8];
1046
+ }
1047
+ t4 = Array.from({
1048
+ length: rows
1049
+ }, t5);
1050
+ $[4] = columns;
1051
+ $[5] = rows;
1052
+ $[6] = t4;
1053
+ } else {
1054
+ t4 = $[6];
1055
+ }
1056
+ let t5;
1057
+ if ($[9] !== ref || $[10] !== t2 || $[11] !== t3 || $[12] !== t4) {
1058
+ t5 = /*#__PURE__*/_jsx("div", {
1059
+ ref: ref,
1060
+ role: "rowgroup",
1061
+ "aria-busy": true,
1062
+ "aria-label": t2,
1063
+ className: t3,
1064
+ children: t4
1065
+ });
1066
+ $[9] = ref;
1067
+ $[10] = t2;
1068
+ $[11] = t3;
1069
+ $[12] = t4;
1070
+ $[13] = t5;
1071
+ } else {
1072
+ t5 = $[13];
1073
+ }
1074
+ return t5;
1075
+ }