@seekalfred/primitives 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -4
- package/dist/alert/alert.d.ts +2 -2
- package/dist/alert/alert.js +1 -1
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +14 -0
- package/dist/alert-dialog/alert-dialog.js +52 -27
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/announcement-bar/announcement-bar.d.ts +15 -4
- package/dist/announcement-bar/announcement-bar.js +31 -6
- package/dist/announcement-bar/announcement-bar.js.map +1 -1
- package/dist/avatar/avatar.d.ts +7 -0
- package/dist/avatar/avatar.js +33 -12
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/badge/badge.d.ts +16 -1
- package/dist/badge/badge.js +12 -5
- package/dist/badge/badge.js.map +1 -1
- package/dist/bar-chart/bar-chart-series.d.ts +75 -0
- package/dist/bar-chart/bar-chart-series.js +401 -0
- package/dist/bar-chart/bar-chart-series.js.map +1 -0
- package/dist/bar-chart/bar-chart.d.ts +25 -1
- package/dist/bar-chart/bar-chart.js +26 -1
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -1
- package/dist/button/button.d.ts +24 -2
- package/dist/button/button.js +62 -13
- package/dist/button/button.js.map +1 -1
- package/dist/card/card.js +1 -1
- package/dist/card/card.js.map +1 -1
- package/dist/checkbox/checkbox.d.ts +25 -1
- package/dist/checkbox/checkbox.js +103 -28
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/checkbox/index.d.ts +2 -2
- package/dist/checkbox/index.js +2 -2
- package/dist/chip-group/chip-group.d.ts +11 -0
- package/dist/chip-group/chip-group.js +50 -34
- package/dist/chip-group/chip-group.js.map +1 -1
- package/dist/chip-group/index.d.ts +2 -2
- package/dist/code-block/code-block.d.ts +45 -0
- package/dist/code-block/code-block.js +74 -0
- package/dist/code-block/code-block.js.map +1 -0
- package/dist/code-block/index.d.ts +2 -0
- package/dist/code-block/index.js +2 -0
- package/dist/command-palette/command-palette.d.ts +128 -0
- package/dist/command-palette/command-palette.js +371 -0
- package/dist/command-palette/command-palette.js.map +1 -0
- package/dist/command-palette/index.d.ts +2 -0
- package/dist/command-palette/index.js +2 -0
- package/dist/copy-button/copy-button.d.ts +19 -3
- package/dist/copy-button/copy-button.js +7 -4
- package/dist/copy-button/copy-button.js.map +1 -1
- package/dist/dialog/dialog.js +1 -1
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/empty-state/empty-state.d.ts +17 -0
- package/dist/empty-state/empty-state.js +9 -7
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/file-drop-zone/file-drop-zone.d.ts +29 -3
- package/dist/file-drop-zone/file-drop-zone.js +26 -8
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/gauge/gauge.d.ts +18 -1
- package/dist/gauge/gauge.js +35 -21
- package/dist/gauge/gauge.js.map +1 -1
- package/dist/gauge/index.d.ts +2 -2
- package/dist/index.d.ts +14 -9
- package/dist/index.js +14 -10
- package/dist/info-tooltip/index.d.ts +2 -0
- package/dist/info-tooltip/index.js +2 -0
- package/dist/info-tooltip/info-tooltip.d.ts +35 -0
- package/dist/info-tooltip/info-tooltip.js +49 -0
- package/dist/info-tooltip/info-tooltip.js.map +1 -0
- package/dist/input/input.d.ts +7 -0
- package/dist/input/input.js +4 -2
- package/dist/input/input.js.map +1 -1
- package/dist/lib/field-shell.js +2 -6
- package/dist/lib/field-shell.js.map +1 -1
- package/dist/lib/required-marker.js +20 -0
- package/dist/lib/required-marker.js.map +1 -0
- package/dist/lib/selection-control.js +32 -1
- package/dist/lib/selection-control.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -2
- package/dist/line-chart/line-chart.d.ts +106 -3
- package/dist/line-chart/line-chart.js +185 -46
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/mention-input/mention-input.js +1 -1
- package/dist/money-input/index.d.ts +2 -2
- package/dist/money-input/money-input.d.ts +14 -0
- package/dist/money-input/money-input.js +17 -7
- package/dist/money-input/money-input.js.map +1 -1
- package/dist/morph-select/morph-select.d.ts +8 -1
- package/dist/morph-select/morph-select.js +8 -5
- package/dist/morph-select/morph-select.js.map +1 -1
- package/dist/multi-select/multi-select.d.ts +31 -0
- package/dist/multi-select/multi-select.js +123 -6
- package/dist/multi-select/multi-select.js.map +1 -1
- package/dist/number-field/number-field.js +1 -1
- package/dist/password-field/password-field.js +1 -1
- package/dist/password-strength/password-strength.js +1 -1
- package/dist/phone-input/phone-input.js +1 -1
- package/dist/popover/popover.js +1 -1
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/index.d.ts +2 -2
- package/dist/progress/index.js +2 -2
- package/dist/progress/progress.d.ts +53 -2
- package/dist/progress/progress.js +146 -36
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/radio-group.d.ts +12 -3
- package/dist/radio-group/radio-group.js +62 -52
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/scroll-area/scroll-area.d.ts +1 -1
- package/dist/scrub-input/scrub-input.d.ts +11 -1
- package/dist/scrub-input/scrub-input.js +22 -10
- package/dist/scrub-input/scrub-input.js.map +1 -1
- package/dist/search-field/search-field.js +1 -1
- package/dist/select/select.d.ts +10 -1
- package/dist/select/select.js +4 -3
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/shortcut-recorder/shortcut-recorder.js +1 -1
- package/dist/sparkline/sparkline.d.ts +27 -2
- package/dist/sparkline/sparkline.js +115 -18
- package/dist/sparkline/sparkline.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +32 -1
- package/dist/stat-card/stat-card.js +52 -9
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +211 -3
- package/dist/table/table.js +473 -93
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.d.ts +4 -2
- package/dist/tabs/tabs.js +7 -5
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/tag-input.js +1 -1
- package/dist/text-shimmer/text-shimmer.d.ts +18 -2
- package/dist/text-shimmer/text-shimmer.js +5 -2
- package/dist/text-shimmer/text-shimmer.js.map +1 -1
- package/dist/textarea/textarea.d.ts +7 -0
- package/dist/textarea/textarea.js +4 -2
- package/dist/textarea/textarea.js.map +1 -1
- package/dist/toast/toast.d.ts +2 -2
- package/dist/toggle-button/index.d.ts +2 -0
- package/dist/toggle-button/index.js +2 -0
- package/dist/toggle-button/toggle-button.d.ts +93 -0
- package/dist/toggle-button/toggle-button.js +199 -0
- package/dist/toggle-button/toggle-button.js.map +1 -0
- package/package.json +19 -3
package/dist/table/table.js
CHANGED
|
@@ -6,8 +6,8 @@ import { useFlip } from "../lib/flip.js";
|
|
|
6
6
|
import { Checkbox as Checkbox$1 } from "../checkbox/checkbox.js";
|
|
7
7
|
import { Select as Select$1, SelectItem } from "../select/select.js";
|
|
8
8
|
import { cva } from "class-variance-authority";
|
|
9
|
-
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
-
import { Cell, Column, Row, Table, TableBody, TableFooter, TableHeader } from "react-aria-components";
|
|
9
|
+
import { Fragment, forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { Button, Cell, Column, Row, Table, TableBody, TableFooter, TableHeader } from "react-aria-components";
|
|
11
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { flushSync } from "react-dom";
|
|
13
13
|
//#region src/table/table.tsx
|
|
@@ -110,6 +110,34 @@ const CHEVRON_COLUMN_ID = "__table_row_action";
|
|
|
110
110
|
const CHEVRON_CELL = "w-10 px-0 text-center";
|
|
111
111
|
/** Reserved id for the checkbox column of a selectable table. */
|
|
112
112
|
const SELECT_COLUMN_ID = "__table_row_select";
|
|
113
|
+
/** Prefix of a detail row's id in the grid, so it cannot collide with a real row's. */
|
|
114
|
+
const DETAIL_ROW_PREFIX = "__table_row_detail:";
|
|
115
|
+
/** Only `data-*` gets through `getRowProps`: the rest belongs to the library or to `onRowAction`. */
|
|
116
|
+
function rowAttributes(attributes) {
|
|
117
|
+
if (!attributes) return void 0;
|
|
118
|
+
const kept = {};
|
|
119
|
+
for (const [name, value] of Object.entries(attributes)) if (name.startsWith("data-")) kept[name] = value;
|
|
120
|
+
return kept;
|
|
121
|
+
}
|
|
122
|
+
/** Whether `renderExpandedRow` had anything to show. */
|
|
123
|
+
const hasContent = (content) => content !== null && content !== void 0 && content !== false;
|
|
124
|
+
/**
|
|
125
|
+
* A header add-on's wrapper in the grid, where the header CELL is the sort
|
|
126
|
+
* control. A press or Enter/Space on the add-on is not a request to sort, so
|
|
127
|
+
* those stop here; focus, hover and every other key (the arrows that walk the
|
|
128
|
+
* grid) pass.
|
|
129
|
+
*/
|
|
130
|
+
const stopSort = {
|
|
131
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
132
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
133
|
+
onClick: (e) => e.stopPropagation(),
|
|
134
|
+
onKeyDown: (e) => {
|
|
135
|
+
if (e.key === "Enter" || e.key === " ") e.stopPropagation();
|
|
136
|
+
},
|
|
137
|
+
onKeyUp: (e) => {
|
|
138
|
+
if (e.key === "Enter" || e.key === " ") e.stopPropagation();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
113
141
|
/** The checkbox column is as wide as its box needs, with the table's usual inset on its leading side. */
|
|
114
142
|
const SELECT_CELL = "w-11 px-0 ps-(--density-row-pad-x)";
|
|
115
143
|
/** The horizontal scroll container. The table owns it; 5 of 6 consumers built one by hand. */
|
|
@@ -118,7 +146,13 @@ const tableVariants = cva([
|
|
|
118
146
|
"w-full border-collapse box-border",
|
|
119
147
|
"font-sans text-base leading-(--leading-normal)",
|
|
120
148
|
"bg-surface text-foreground"
|
|
121
|
-
]
|
|
149
|
+
], {
|
|
150
|
+
variants: { density: {
|
|
151
|
+
default: "",
|
|
152
|
+
compact: "text-sm"
|
|
153
|
+
} },
|
|
154
|
+
defaultVariants: { density: "default" }
|
|
155
|
+
});
|
|
122
156
|
/**
|
|
123
157
|
* The header is near-white, not a grey band.
|
|
124
158
|
*
|
|
@@ -173,6 +207,8 @@ const tableColumnVariants = cva([
|
|
|
173
207
|
"px-(--density-row-pad-x) py-(--density-row-pad-y)",
|
|
174
208
|
"box-border align-middle text-sm font-semibold select-none",
|
|
175
209
|
"data-[sorted]:bg-foreground/3 data-[sorted]:text-foreground",
|
|
210
|
+
"data-[highlighted]:bg-primary-subtle data-[highlighted]:text-foreground",
|
|
211
|
+
"data-[highlighted]:data-[sorted]:bg-primary-subtle",
|
|
176
212
|
...FOCUS_RING,
|
|
177
213
|
"data-[allows-sorting]:cursor-pointer"
|
|
178
214
|
], {
|
|
@@ -182,16 +218,79 @@ const tableColumnVariants = cva([
|
|
|
182
218
|
center: "text-center",
|
|
183
219
|
end: "text-end"
|
|
184
220
|
},
|
|
221
|
+
density: {
|
|
222
|
+
default: "",
|
|
223
|
+
compact: "py-2"
|
|
224
|
+
},
|
|
225
|
+
hidden: {
|
|
226
|
+
true: "group/column py-0 data-[focus-visible]:py-(--density-row-pad-y)",
|
|
227
|
+
false: ""
|
|
228
|
+
},
|
|
185
229
|
headerType: {
|
|
186
230
|
sentence: "text-sm leading-none",
|
|
187
231
|
caps: "text-xs uppercase tracking-wide leading-none"
|
|
188
232
|
}
|
|
189
233
|
},
|
|
234
|
+
compoundVariants: [{
|
|
235
|
+
density: "compact",
|
|
236
|
+
hidden: true,
|
|
237
|
+
class: "data-[focus-visible]:py-2"
|
|
238
|
+
}],
|
|
190
239
|
defaultVariants: {
|
|
191
240
|
align: "start",
|
|
192
|
-
headerType: "sentence"
|
|
241
|
+
headerType: "sentence",
|
|
242
|
+
density: "default",
|
|
243
|
+
hidden: false
|
|
193
244
|
}
|
|
194
245
|
});
|
|
246
|
+
/**
|
|
247
|
+
* The disclosure button that opens a row's sub-rows (`getSubRows`).
|
|
248
|
+
*
|
|
249
|
+
* A real button in the first cell, named by that cell's own content and
|
|
250
|
+
* carrying `aria-expanded`, so a reader hears "Meta, button, collapsed"
|
|
251
|
+
* without the library inventing copy. 24px square: the WCAG 2.2 target-size
|
|
252
|
+
* floor (2.5.8), and the step each level of sub-rows is indented by, so a
|
|
253
|
+
* child's text lines up one button-width in from its parent's. The chevron
|
|
254
|
+
* turns a quarter when the row opens; with reduced motion it simply flips.
|
|
255
|
+
*/
|
|
256
|
+
const tableExpandButtonVariants = cva([
|
|
257
|
+
"inline-flex size-6 shrink-0 items-center justify-center rounded-sm cursor-pointer",
|
|
258
|
+
"text-muted-foreground data-[hovered]:bg-muted data-[hovered]:text-foreground",
|
|
259
|
+
"[&_svg]:motion-safe:transition-transform [&_svg]:motion-safe:duration-(--duration-snappy) [&_svg]:motion-safe:ease-snappy",
|
|
260
|
+
"data-[expanded]:[&_svg]:rotate-90 rtl:data-[expanded]:[&_svg]:-rotate-90",
|
|
261
|
+
...FOCUS_RING
|
|
262
|
+
]);
|
|
263
|
+
/**
|
|
264
|
+
* A group header row (`isGroupRow`): one cell spanning the row, naming the rows
|
|
265
|
+
* under it ("Mobile" / "Desktop"). The header band's fill and label type, so it
|
|
266
|
+
* reads as a heading of the rows that follow rather than as one of them.
|
|
267
|
+
*/
|
|
268
|
+
const tableGroupRowVariants = cva(["bg-header-fill hover:bg-header-fill", "[&>td]:text-sm [&>td]:font-semibold [&>td]:text-muted-foreground"]);
|
|
269
|
+
/**
|
|
270
|
+
* A detail row (`renderExpandedRow`): one cell spanning the row, under the row it
|
|
271
|
+
* belongs to. Not interactive, so it takes no hover, focus or selection fill and
|
|
272
|
+
* no rule of its own: it reads as part of the row above, and the next row's rule
|
|
273
|
+
* closes it.
|
|
274
|
+
*/
|
|
275
|
+
const tableDetailRowVariants = cva(["box-border bg-muted"]);
|
|
276
|
+
/** The cell of a detail row. The table's own inset, so the content is not flush against the edge. */
|
|
277
|
+
const tableDetailCellVariants = cva(["px-(--density-row-pad-x) py-(--density-row-pad-y)", "box-border align-top"]);
|
|
278
|
+
/**
|
|
279
|
+
* The sort control of a column header in a plain table (`keyboardModel="table"`).
|
|
280
|
+
*
|
|
281
|
+
* In the grid the header cell is the control; in a plain table a cell cannot
|
|
282
|
+
* take focus, so the label sits in a real button that Tab reaches. It wears
|
|
283
|
+
* the header's own type and colour, and is at least 24px tall so a compact
|
|
284
|
+
* header still clears the WCAG 2.2 target size (2.5.8).
|
|
285
|
+
*/
|
|
286
|
+
const tableSortButtonVariants = cva([
|
|
287
|
+
"inline-flex min-h-6 items-center cursor-pointer",
|
|
288
|
+
"bg-transparent p-0 border-0 font-[inherit] text-[length:inherit] leading-[inherit] text-inherit",
|
|
289
|
+
"outline-none focus-visible:outline-solid",
|
|
290
|
+
"focus-visible:outline-(length:--focus-ring-width)",
|
|
291
|
+
"focus-visible:outline-offset-(--focus-ring-offset)",
|
|
292
|
+
"focus-visible:outline-(--color-ring)"
|
|
293
|
+
]);
|
|
195
294
|
const tableRowVariants = cva([
|
|
196
295
|
"group/row box-border bg-surface",
|
|
197
296
|
"motion-safe:transition-colors motion-safe:duration-(--duration-fast) motion-safe:ease-standard",
|
|
@@ -219,6 +318,7 @@ const tableCellVariants = cva([
|
|
|
219
318
|
"px-(--density-row-pad-x) py-(--density-row-pad-y)",
|
|
220
319
|
"box-border align-middle wrap-anywhere",
|
|
221
320
|
"data-[sorted]:bg-foreground/3",
|
|
321
|
+
"data-[highlighted]:bg-primary-subtle data-[highlighted]:data-[sorted]:bg-primary-subtle",
|
|
222
322
|
...FOCUS_RING
|
|
223
323
|
], {
|
|
224
324
|
variants: {
|
|
@@ -230,11 +330,16 @@ const tableCellVariants = cva([
|
|
|
230
330
|
numeric: {
|
|
231
331
|
true: "tabular-nums whitespace-nowrap",
|
|
232
332
|
false: ""
|
|
333
|
+
},
|
|
334
|
+
density: {
|
|
335
|
+
default: "",
|
|
336
|
+
compact: "py-2"
|
|
233
337
|
}
|
|
234
338
|
},
|
|
235
339
|
defaultVariants: {
|
|
236
340
|
align: "start",
|
|
237
|
-
numeric: false
|
|
341
|
+
numeric: false,
|
|
342
|
+
density: "default"
|
|
238
343
|
}
|
|
239
344
|
});
|
|
240
345
|
/**
|
|
@@ -375,6 +480,20 @@ function RowChevronGlyph() {
|
|
|
375
480
|
})
|
|
376
481
|
});
|
|
377
482
|
}
|
|
483
|
+
function ExpandChevronGlyph() {
|
|
484
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
485
|
+
"data-slot": "table-row-expand-chevron",
|
|
486
|
+
"aria-hidden": "true",
|
|
487
|
+
viewBox: "0 0 16 16",
|
|
488
|
+
fill: "none",
|
|
489
|
+
stroke: "currentColor",
|
|
490
|
+
strokeWidth: "1.5",
|
|
491
|
+
strokeLinecap: "round",
|
|
492
|
+
strokeLinejoin: "round",
|
|
493
|
+
className: "size-(--icon-sm) rtl:-scale-x-100",
|
|
494
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 3 5 5-5 5" })
|
|
495
|
+
});
|
|
496
|
+
}
|
|
378
497
|
function SortCaretGlyph({ direction }) {
|
|
379
498
|
return /* @__PURE__ */ jsxs("svg", {
|
|
380
499
|
"data-slot": "table-sort-caret",
|
|
@@ -456,9 +575,10 @@ function createColumns() {
|
|
|
456
575
|
/**
|
|
457
576
|
* A data table.
|
|
458
577
|
*
|
|
459
|
-
* Maturity: **beta**.
|
|
460
|
-
*
|
|
461
|
-
*
|
|
578
|
+
* Maturity: **beta**. Filtering is deliberately absent -- it had one consumer
|
|
579
|
+
* or none across the six legacy tables, and it belongs to DataGrid. Rows can
|
|
580
|
+
* open onto sub-rows (`getSubRows`) and head a group (`isGroupRow`), which the
|
|
581
|
+
* product's usage and page-speed reports needed. Sorting glides: when a sort reorders the
|
|
462
582
|
* rows, each slides to its new place instead of jumping (the lib/flip helper).
|
|
463
583
|
* Selection is opt-in with `selectionMode="multiple"`.
|
|
464
584
|
*
|
|
@@ -496,17 +616,20 @@ function compareKeys(a, b) {
|
|
|
496
616
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
497
617
|
return String(a).localeCompare(String(b));
|
|
498
618
|
}
|
|
499
|
-
|
|
619
|
+
/** `level` in the order `sort` asks for; unchanged when there is none or its column is gone. */
|
|
620
|
+
function sortRows(level, columns, sort) {
|
|
621
|
+
if (!sort) return level;
|
|
622
|
+
const sorted = columns.find((column) => column.id === sort.column);
|
|
623
|
+
if (!sorted) return level;
|
|
624
|
+
const direction = sort.direction === "descending" ? -1 : 1;
|
|
625
|
+
return [...level].sort((a, b) => direction * compareKeys(sortKey(sorted, a), sortKey(sorted, b)));
|
|
626
|
+
}
|
|
627
|
+
const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant, sortDescriptor, defaultSortDescriptor, onSortChange, onRowAction, isRowHighlighted, rowClassName, selectionMode, selectedKeys, defaultSelectedKeys, onSelectionChange, selectionLabels, frame, headerType, headerFill, striped, totalRow, empty, minWidth, stickyFirstColumn, pageSize, pageSizeOptions, onPageSizeChange, pageLabels, getSubRows, renderExpandedRow, getRowProps, expandedKeys, defaultExpandedKeys, onExpandedChange, isGroupRow, density, headerHidden, keyboardModel, className, ...props }, ref) {
|
|
500
628
|
const isControlled = sortDescriptor !== void 0;
|
|
501
629
|
const [uncontrolledSort, setUncontrolledSort] = useState(defaultSortDescriptor);
|
|
502
630
|
const activeSort = isControlled ? sortDescriptor : uncontrolledSort;
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
const sorted = columns.find((column) => column.id === activeSort.column);
|
|
506
|
-
if (!sorted) return data;
|
|
507
|
-
const direction = activeSort.direction === "descending" ? -1 : 1;
|
|
508
|
-
return [...data].sort((a, b) => direction * compareKeys(sortKey(sorted, a), sortKey(sorted, b)));
|
|
509
|
-
}, [
|
|
631
|
+
const sortLevel = (level) => isControlled ? level : sortRows(level, columns, activeSort);
|
|
632
|
+
const rows = useMemo(() => isControlled ? data : sortRows(data, columns, activeSort), [
|
|
510
633
|
data,
|
|
511
634
|
columns,
|
|
512
635
|
activeSort,
|
|
@@ -526,15 +649,69 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
526
649
|
perPage: pageLabels?.perPage ?? ((size) => `${size} per page`),
|
|
527
650
|
rowsPerPage: pageLabels?.rowsPerPage ?? "Rows per page"
|
|
528
651
|
};
|
|
529
|
-
const
|
|
530
|
-
const
|
|
652
|
+
const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpandedKeys ?? []));
|
|
653
|
+
const expanded = expandedKeys === void 0 ? uncontrolledExpanded : new Set(expandedKeys);
|
|
654
|
+
const toggleExpanded = (key) => {
|
|
655
|
+
const next = new Set(expanded);
|
|
656
|
+
if (next.has(key)) next.delete(key);
|
|
657
|
+
else next.add(key);
|
|
658
|
+
if (expandedKeys === void 0) setUncontrolledExpanded(next);
|
|
659
|
+
onExpandedChange?.(next);
|
|
660
|
+
};
|
|
661
|
+
const expandable = getSubRows !== void 0;
|
|
662
|
+
const { rowsByKey, subRowsByRow } = useMemo(() => {
|
|
663
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
664
|
+
const subRows = /* @__PURE__ */ new Map();
|
|
665
|
+
const index = (level) => {
|
|
666
|
+
for (const row of level) {
|
|
667
|
+
byKey.set(getRowId(row), row);
|
|
668
|
+
const children = getSubRows?.(row) ?? [];
|
|
669
|
+
subRows.set(row, children);
|
|
670
|
+
index(children);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
index(data);
|
|
674
|
+
return {
|
|
675
|
+
rowsByKey: byKey,
|
|
676
|
+
subRowsByRow: subRows
|
|
677
|
+
};
|
|
678
|
+
}, [
|
|
679
|
+
data,
|
|
680
|
+
getSubRows,
|
|
681
|
+
getRowId
|
|
682
|
+
]);
|
|
683
|
+
const subRowsOf = (row) => subRowsByRow.get(row) ?? [];
|
|
684
|
+
const shownRows = [];
|
|
685
|
+
const walk = (level, depth) => {
|
|
686
|
+
for (const [index, row] of level.entries()) {
|
|
687
|
+
const subRows = subRowsOf(row);
|
|
688
|
+
const key = getRowId(row);
|
|
689
|
+
const isExpanded = subRows.length > 0 && expanded.has(key);
|
|
690
|
+
const detail = renderExpandedRow && expanded.has(key) ? renderExpandedRow(row) : void 0;
|
|
691
|
+
shownRows.push({
|
|
692
|
+
row,
|
|
693
|
+
depth,
|
|
694
|
+
index,
|
|
695
|
+
hasSubRows: subRows.length > 0,
|
|
696
|
+
isExpanded,
|
|
697
|
+
detail: hasContent(detail) ? detail : void 0
|
|
698
|
+
});
|
|
699
|
+
if (isExpanded) walk(sortLevel(subRows), depth + 1);
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
walk(visibleRows, 0);
|
|
703
|
+
const idBase = useId();
|
|
704
|
+
const detailRowKeys = shownRows.filter((shown) => shown.detail !== void 0).map((shown) => `${DETAIL_ROW_PREFIX}${String(getRowId(shown.row))}`);
|
|
705
|
+
const plain = keyboardModel === "table";
|
|
706
|
+
const selectable = selectionMode === "multiple" && !plain;
|
|
707
|
+
const rowAction = plain ? void 0 : onRowAction;
|
|
531
708
|
const [uncontrolledSelection, setUncontrolledSelection] = useState(defaultSelectedKeys ?? /* @__PURE__ */ new Set());
|
|
532
709
|
const selection = selectedKeys ?? uncontrolledSelection;
|
|
533
710
|
const commitSelection = (keys) => {
|
|
534
711
|
if (selectedKeys === void 0) setUncontrolledSelection(keys);
|
|
535
712
|
onSelectionChange?.(keys);
|
|
536
713
|
};
|
|
537
|
-
const selectedCount = selection === "all" ?
|
|
714
|
+
const selectedCount = selection === "all" ? shownRows.length : [...selection].filter((key) => rowsByKey.has(key)).length;
|
|
538
715
|
const selectLabels = {
|
|
539
716
|
item: selectionLabels?.item ?? {
|
|
540
717
|
one: "row",
|
|
@@ -574,6 +751,101 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
574
751
|
part,
|
|
575
752
|
striped: part === "body" && !!striped
|
|
576
753
|
});
|
|
754
|
+
const headerPart = headerFill === "none" ? "bare" : "header";
|
|
755
|
+
const alignOf = (column) => column.align ?? (column.numeric ? "end" : void 0);
|
|
756
|
+
const stickyFirst = (column, part) => [stickyFirstColumn && column === columns[0] && stickyCell(part), stickyFirstColumn && selectable && column === columns[0] && "start-11"];
|
|
757
|
+
const columnClass = (column) => cnAll(tableColumnVariants({
|
|
758
|
+
align: alignOf(column),
|
|
759
|
+
headerType,
|
|
760
|
+
density,
|
|
761
|
+
hidden: headerHidden
|
|
762
|
+
}), stickyFirst(column, headerPart));
|
|
763
|
+
const cellClass = (column, part) => cnAll(tableCellVariants({
|
|
764
|
+
align: alignOf(column),
|
|
765
|
+
numeric: column.numeric,
|
|
766
|
+
density
|
|
767
|
+
}), stickyFirst(column, part));
|
|
768
|
+
const rowClass = (row, isGroup) => cn(cnAll(tableRowVariants({
|
|
769
|
+
variant,
|
|
770
|
+
striped
|
|
771
|
+
}), isGroup && tableGroupRowVariants(), rowAction && !isGroup && "cursor-pointer", headerHidden && "first:border-t-0"), rowClassName?.(row));
|
|
772
|
+
const isSortable = (column) => !headerHidden && !!column.sortable;
|
|
773
|
+
const headerLabel = (column) => {
|
|
774
|
+
const label = /* @__PURE__ */ jsxs(Fragment$1, { children: [column.header, isSortable(column) ? /* @__PURE__ */ jsx(SortCaretGlyph, { direction: activeSort?.column === column.id ? activeSort.direction : "none" }) : null] });
|
|
775
|
+
return headerHidden ? /* @__PURE__ */ jsx("span", {
|
|
776
|
+
"data-slot": "table-column-label",
|
|
777
|
+
className: "sr-only group-data-[focus-visible]/column:not-sr-only",
|
|
778
|
+
children: label
|
|
779
|
+
}) : label;
|
|
780
|
+
};
|
|
781
|
+
const headerAddon = (column, grid) => column.headerAddon && !headerHidden ? /* @__PURE__ */ jsx("span", {
|
|
782
|
+
"data-slot": "table-column-addon",
|
|
783
|
+
className: "ms-1 inline-flex items-center align-middle",
|
|
784
|
+
...grid ? stopSort : void 0,
|
|
785
|
+
children: column.headerAddon
|
|
786
|
+
}) : null;
|
|
787
|
+
const changeSort = (descriptor) => {
|
|
788
|
+
if (!isControlled) setUncontrolledSort(descriptor);
|
|
789
|
+
setPage(1);
|
|
790
|
+
onSortChange?.(descriptor);
|
|
791
|
+
};
|
|
792
|
+
const cellContent = (column, row, index) => {
|
|
793
|
+
const value = column.accessor(row);
|
|
794
|
+
if (!column.cell) return renderValue(column, value, row);
|
|
795
|
+
const key = getRowId(row);
|
|
796
|
+
return column.cell({
|
|
797
|
+
value,
|
|
798
|
+
row,
|
|
799
|
+
index,
|
|
800
|
+
isExpanded: expanded.has(key),
|
|
801
|
+
toggleExpanded: () => toggleExpanded(key)
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
const cellsOf = (row, isGroup) => {
|
|
805
|
+
if (isGroup) return columns.slice(0, 1).map((column) => ({
|
|
806
|
+
column,
|
|
807
|
+
span: 1
|
|
808
|
+
}));
|
|
809
|
+
const cells = [];
|
|
810
|
+
for (let at = 0; at < columns.length;) {
|
|
811
|
+
const column = columns[at];
|
|
812
|
+
const asked = Math.floor(column.colSpan?.(row) ?? 1);
|
|
813
|
+
const span = stickyFirstColumn && at === 0 ? 1 : Number.isNaN(asked) ? 1 : Math.max(1, Math.min(asked, columns.length - at));
|
|
814
|
+
cells.push({
|
|
815
|
+
column,
|
|
816
|
+
span
|
|
817
|
+
});
|
|
818
|
+
at += span;
|
|
819
|
+
}
|
|
820
|
+
return cells;
|
|
821
|
+
};
|
|
822
|
+
const indentClass = (column) => expandable && column === columns[0] && "ps-[calc(var(--density-row-pad-x)+var(--table-row-depth)*--spacing(7))]";
|
|
823
|
+
const depthStyle = (column, depth) => expandable && column === columns[0] ? { "--table-row-depth": depth } : void 0;
|
|
824
|
+
const firstCellContent = (column, content, { row, hasSubRows, isExpanded }, labelId) => expandable && column === columns[0] ? /* @__PURE__ */ jsxs("span", {
|
|
825
|
+
className: "flex items-center gap-1",
|
|
826
|
+
children: [hasSubRows ? /* @__PURE__ */ jsx(Button, {
|
|
827
|
+
"data-slot": "table-row-expand",
|
|
828
|
+
"aria-expanded": isExpanded,
|
|
829
|
+
"aria-labelledby": labelId,
|
|
830
|
+
className: cnAll(tableExpandButtonVariants()),
|
|
831
|
+
onPress: () => toggleExpanded(getRowId(row)),
|
|
832
|
+
children: /* @__PURE__ */ jsx(ExpandChevronGlyph, {})
|
|
833
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
834
|
+
"aria-hidden": "true",
|
|
835
|
+
className: "size-6 shrink-0"
|
|
836
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
837
|
+
id: labelId,
|
|
838
|
+
"data-slot": "table-row-label",
|
|
839
|
+
className: "min-w-0",
|
|
840
|
+
children: content
|
|
841
|
+
})]
|
|
842
|
+
}) : content;
|
|
843
|
+
const columnStyle = (column) => column.width === void 0 ? void 0 : { width: column.width };
|
|
844
|
+
const emptyState = empty === void 0 ? void 0 : /* @__PURE__ */ jsx("div", {
|
|
845
|
+
"data-slot": "table-empty",
|
|
846
|
+
className: cnAll(tableEmptyVariants()),
|
|
847
|
+
children: empty
|
|
848
|
+
});
|
|
577
849
|
return /* @__PURE__ */ jsxs("div", {
|
|
578
850
|
"data-slot": "table-card",
|
|
579
851
|
"data-overflow-start": edges.start || void 0,
|
|
@@ -585,24 +857,118 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
585
857
|
ref: scrollRef,
|
|
586
858
|
"data-slot": "table-scroll",
|
|
587
859
|
className: cnAll(tableScrollVariants()),
|
|
588
|
-
children: /* @__PURE__ */ jsxs(
|
|
860
|
+
children: plain ? /* @__PURE__ */ jsxs("table", {
|
|
861
|
+
ref,
|
|
862
|
+
...props,
|
|
863
|
+
"data-slot": "table",
|
|
864
|
+
"data-keyboard-model": "table",
|
|
865
|
+
className: cn(tableVariants({ density }), className),
|
|
866
|
+
style: tableStyle,
|
|
867
|
+
children: [
|
|
868
|
+
/* @__PURE__ */ jsx("thead", {
|
|
869
|
+
"data-slot": "table-header",
|
|
870
|
+
className: cnAll(tableHeaderVariants({ headerFill })),
|
|
871
|
+
children: /* @__PURE__ */ jsx("tr", { children: columns.map((column) => {
|
|
872
|
+
const sorted = activeSort?.column === column.id ? activeSort.direction : void 0;
|
|
873
|
+
return /* @__PURE__ */ jsxs("th", {
|
|
874
|
+
scope: "col",
|
|
875
|
+
"data-slot": "table-column",
|
|
876
|
+
"data-sorted": sortedColumn === column.id || void 0,
|
|
877
|
+
"data-highlighted": column.highlighted || void 0,
|
|
878
|
+
"aria-sort": isSortable(column) ? sorted ?? "none" : void 0,
|
|
879
|
+
className: columnClass(column),
|
|
880
|
+
style: columnStyle(column),
|
|
881
|
+
children: [isSortable(column) ? /* @__PURE__ */ jsx("button", {
|
|
882
|
+
type: "button",
|
|
883
|
+
"data-slot": "table-sort-button",
|
|
884
|
+
className: cnAll(tableSortButtonVariants()),
|
|
885
|
+
onClick: () => changeSort({
|
|
886
|
+
column: column.id,
|
|
887
|
+
direction: sorted === "ascending" ? "descending" : "ascending"
|
|
888
|
+
}),
|
|
889
|
+
children: headerLabel(column)
|
|
890
|
+
}) : headerLabel(column), headerAddon(column, false)]
|
|
891
|
+
}, column.id);
|
|
892
|
+
}) })
|
|
893
|
+
}),
|
|
894
|
+
/* @__PURE__ */ jsx("tbody", {
|
|
895
|
+
"data-slot": "table-body",
|
|
896
|
+
children: shownRows.length === 0 && emptyState ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
897
|
+
colSpan: columns.length,
|
|
898
|
+
children: emptyState
|
|
899
|
+
}) }) : shownRows.map((shown, position) => {
|
|
900
|
+
const { row, depth, index } = shown;
|
|
901
|
+
const key = getRowId(row);
|
|
902
|
+
const isGroup = isGroupRow?.(row) ?? false;
|
|
903
|
+
const cells = cellsOf(row, isGroup);
|
|
904
|
+
const labelId = `${idBase}-row-${String(position)}`;
|
|
905
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
|
|
906
|
+
...rowAttributes(getRowProps?.(row)),
|
|
907
|
+
"data-slot": "table-row",
|
|
908
|
+
"data-flip": String(key),
|
|
909
|
+
"data-highlighted": isRowHighlighted?.(row) || void 0,
|
|
910
|
+
"data-depth": expandable ? depth : void 0,
|
|
911
|
+
"data-open": shown.isExpanded || void 0,
|
|
912
|
+
"data-group": isGroup || void 0,
|
|
913
|
+
className: rowClass(row, isGroup),
|
|
914
|
+
children: cells.map(({ column, span }) => {
|
|
915
|
+
const content = firstCellContent(column, cellContent(column, row, index), shown, labelId);
|
|
916
|
+
const cellProps = {
|
|
917
|
+
"data-slot": "table-cell",
|
|
918
|
+
"data-sorted": sortedColumn === column.id || void 0,
|
|
919
|
+
"data-highlighted": column.highlighted || void 0,
|
|
920
|
+
colSpan: isGroup ? columns.length : span > 1 ? span : void 0,
|
|
921
|
+
style: depthStyle(column, depth)
|
|
922
|
+
};
|
|
923
|
+
return column === columns[0] ? /* @__PURE__ */ jsx("th", {
|
|
924
|
+
scope: "row",
|
|
925
|
+
...cellProps,
|
|
926
|
+
className: cnAll(cellClass(column, "body"), indentClass(column), "font-normal"),
|
|
927
|
+
children: content
|
|
928
|
+
}, column.id) : /* @__PURE__ */ jsx("td", {
|
|
929
|
+
...cellProps,
|
|
930
|
+
className: cellClass(column, "body"),
|
|
931
|
+
children: content
|
|
932
|
+
}, column.id);
|
|
933
|
+
})
|
|
934
|
+
}), shown.detail === void 0 ? null : /* @__PURE__ */ jsx("tr", {
|
|
935
|
+
"data-slot": "table-detail-row",
|
|
936
|
+
"data-flip": `${String(key)}:detail`,
|
|
937
|
+
className: cnAll(tableDetailRowVariants()),
|
|
938
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
939
|
+
"data-slot": "table-detail-cell",
|
|
940
|
+
colSpan: columns.length,
|
|
941
|
+
className: cnAll(tableDetailCellVariants()),
|
|
942
|
+
children: shown.detail
|
|
943
|
+
})
|
|
944
|
+
})] }, String(key));
|
|
945
|
+
})
|
|
946
|
+
}),
|
|
947
|
+
totalRow ? /* @__PURE__ */ jsx("tfoot", {
|
|
948
|
+
"data-slot": "table-footer",
|
|
949
|
+
className: cnAll(tableFooterVariants()),
|
|
950
|
+
children: /* @__PURE__ */ jsx("tr", { children: columns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
951
|
+
"data-slot": "table-cell",
|
|
952
|
+
className: cellClass(column, "bare"),
|
|
953
|
+
children: totalRow(column)
|
|
954
|
+
}, column.id)) })
|
|
955
|
+
}) : null
|
|
956
|
+
]
|
|
957
|
+
}) : /* @__PURE__ */ jsxs(Table, {
|
|
589
958
|
ref,
|
|
590
959
|
...props,
|
|
591
960
|
"data-slot": "table",
|
|
592
|
-
className: cn(tableVariants(), className),
|
|
961
|
+
className: cn(tableVariants({ density }), className),
|
|
593
962
|
style: tableStyle,
|
|
594
963
|
selectionMode: selectable ? "multiple" : void 0,
|
|
595
964
|
selectedKeys: selectable ? selection : void 0,
|
|
596
965
|
onSelectionChange: selectable ? commitSelection : void 0,
|
|
597
966
|
sortDescriptor: activeSort,
|
|
598
|
-
onSortChange:
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
onSortChange?.(descriptor);
|
|
602
|
-
},
|
|
603
|
-
onRowAction: onRowAction ? (key) => {
|
|
967
|
+
onSortChange: changeSort,
|
|
968
|
+
disabledKeys: detailRowKeys.length > 0 ? detailRowKeys : void 0,
|
|
969
|
+
onRowAction: rowAction ? (key) => {
|
|
604
970
|
const row = rowsByKey.get(key);
|
|
605
|
-
if (row !== void 0)
|
|
971
|
+
if (row !== void 0 && !isGroupRow?.(row)) rowAction(row);
|
|
606
972
|
} : void 0,
|
|
607
973
|
children: [
|
|
608
974
|
/* @__PURE__ */ jsxs(TableHeader, {
|
|
@@ -612,81 +978,98 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
612
978
|
selectable ? /* @__PURE__ */ jsx(Column, {
|
|
613
979
|
id: SELECT_COLUMN_ID,
|
|
614
980
|
"data-slot": "table-column",
|
|
615
|
-
className: cnAll(tableColumnVariants({
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
981
|
+
className: cnAll(tableColumnVariants({
|
|
982
|
+
headerType,
|
|
983
|
+
density,
|
|
984
|
+
hidden: headerHidden
|
|
985
|
+
}), SELECT_CELL, stickyFirstColumn && stickyCell(headerPart), stickyFirstColumn && "border-e-0"),
|
|
986
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
987
|
+
className: headerHidden ? "sr-only group-data-[focus-visible]/column:not-sr-only" : void 0,
|
|
988
|
+
children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
989
|
+
slot: "selection",
|
|
990
|
+
"aria-label": selectionLabels?.selectAll
|
|
991
|
+
})
|
|
619
992
|
})
|
|
620
993
|
}) : null,
|
|
621
994
|
columns.map((column) => /* @__PURE__ */ jsxs(Column, {
|
|
622
995
|
id: column.id,
|
|
623
996
|
isRowHeader: column === columns[0],
|
|
624
|
-
allowsSorting: column
|
|
997
|
+
allowsSorting: isSortable(column),
|
|
625
998
|
"data-slot": "table-column",
|
|
626
999
|
"data-sorted": sortedColumn === column.id || void 0,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
style: column.width === void 0 ? void 0 : { width: column.width },
|
|
632
|
-
children: [column.header, column.sortable ? /* @__PURE__ */ jsx(SortCaretGlyph, { direction: activeSort?.column === column.id ? activeSort.direction : "none" }) : null]
|
|
1000
|
+
"data-highlighted": column.highlighted || void 0,
|
|
1001
|
+
className: columnClass(column),
|
|
1002
|
+
style: columnStyle(column),
|
|
1003
|
+
children: [headerLabel(column), headerAddon(column, true)]
|
|
633
1004
|
}, column.id)),
|
|
634
|
-
|
|
1005
|
+
rowAction ? /* @__PURE__ */ jsx(Column, {
|
|
635
1006
|
id: CHEVRON_COLUMN_ID,
|
|
636
1007
|
"data-slot": "table-column",
|
|
637
|
-
className: cnAll(tableColumnVariants({
|
|
1008
|
+
className: cnAll(tableColumnVariants({
|
|
1009
|
+
headerType,
|
|
1010
|
+
density,
|
|
1011
|
+
hidden: headerHidden
|
|
1012
|
+
}), CHEVRON_CELL),
|
|
638
1013
|
children: ""
|
|
639
1014
|
}) : null
|
|
640
1015
|
]
|
|
641
1016
|
}),
|
|
642
1017
|
/* @__PURE__ */ jsx(TableBody, {
|
|
643
1018
|
"data-slot": "table-body",
|
|
644
|
-
renderEmptyState:
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
slot: "
|
|
664
|
-
"
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
1019
|
+
renderEmptyState: emptyState === void 0 ? void 0 : () => emptyState,
|
|
1020
|
+
children: shownRows.map((shown, position) => {
|
|
1021
|
+
const { row, depth, index } = shown;
|
|
1022
|
+
const key = getRowId(row);
|
|
1023
|
+
const isGroup = isGroupRow?.(row) ?? false;
|
|
1024
|
+
const cells = cellsOf(row, isGroup);
|
|
1025
|
+
const labelId = `${idBase}-row-${String(position)}`;
|
|
1026
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Row, {
|
|
1027
|
+
...rowAttributes(getRowProps?.(row)),
|
|
1028
|
+
id: key,
|
|
1029
|
+
"data-slot": "table-row",
|
|
1030
|
+
"data-flip": String(key),
|
|
1031
|
+
"data-highlighted": isRowHighlighted?.(row) || void 0,
|
|
1032
|
+
"data-depth": expandable ? depth : void 0,
|
|
1033
|
+
"data-open": shown.isExpanded || void 0,
|
|
1034
|
+
"data-group": isGroup || void 0,
|
|
1035
|
+
className: rowClass(row, isGroup),
|
|
1036
|
+
children: [
|
|
1037
|
+
selectable ? /* @__PURE__ */ jsx(Cell, {
|
|
1038
|
+
"data-slot": "table-cell",
|
|
1039
|
+
className: cnAll(tableCellVariants({ density }), SELECT_CELL, stickyFirstColumn && stickyCell("body"), stickyFirstColumn && "border-e-0"),
|
|
1040
|
+
children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
1041
|
+
slot: "selection",
|
|
1042
|
+
"aria-label": selectionLabels?.selectRow
|
|
1043
|
+
})
|
|
1044
|
+
}) : null,
|
|
1045
|
+
cells.map(({ column, span }) => /* @__PURE__ */ jsx(Cell, {
|
|
670
1046
|
"data-slot": "table-cell",
|
|
671
1047
|
"data-sorted": sortedColumn === column.id || void 0,
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
children: column
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
1048
|
+
"data-highlighted": column.highlighted || void 0,
|
|
1049
|
+
colSpan: isGroup ? columns.length + (rowAction ? 1 : 0) : span > 1 ? span : void 0,
|
|
1050
|
+
className: cnAll(cellClass(column, "body"), indentClass(column)),
|
|
1051
|
+
style: depthStyle(column, depth),
|
|
1052
|
+
children: firstCellContent(column, cellContent(column, row, index), shown, labelId)
|
|
1053
|
+
}, column.id)),
|
|
1054
|
+
rowAction && !isGroup ? /* @__PURE__ */ jsx(Cell, {
|
|
1055
|
+
"data-slot": "table-cell",
|
|
1056
|
+
className: cnAll(tableCellVariants({ density }), CHEVRON_CELL),
|
|
1057
|
+
children: /* @__PURE__ */ jsx(RowChevronGlyph, {})
|
|
1058
|
+
}) : null
|
|
1059
|
+
]
|
|
1060
|
+
}), shown.detail === void 0 ? null : /* @__PURE__ */ jsx(Row, {
|
|
1061
|
+
id: `${DETAIL_ROW_PREFIX}${String(key)}`,
|
|
1062
|
+
"data-slot": "table-detail-row",
|
|
1063
|
+
"data-flip": `${String(key)}:detail`,
|
|
1064
|
+
className: cnAll(tableDetailRowVariants()),
|
|
1065
|
+
children: /* @__PURE__ */ jsx(Cell, {
|
|
1066
|
+
"data-slot": "table-detail-cell",
|
|
1067
|
+
colSpan: columns.length + (selectable ? 1 : 0) + (rowAction ? 1 : 0),
|
|
1068
|
+
className: cnAll(tableDetailCellVariants()),
|
|
1069
|
+
children: shown.detail
|
|
1070
|
+
})
|
|
1071
|
+
})] }, String(key));
|
|
1072
|
+
})
|
|
690
1073
|
}),
|
|
691
1074
|
totalRow ? /* @__PURE__ */ jsx(TableFooter, {
|
|
692
1075
|
"data-slot": "table-footer",
|
|
@@ -696,20 +1079,17 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
696
1079
|
children: [
|
|
697
1080
|
selectable ? /* @__PURE__ */ jsx(Cell, {
|
|
698
1081
|
"data-slot": "table-cell",
|
|
699
|
-
className: cnAll(tableCellVariants(), SELECT_CELL, stickyFirstColumn && stickyCell("bare"), stickyFirstColumn && "border-e-0"),
|
|
1082
|
+
className: cnAll(tableCellVariants({ density }), SELECT_CELL, stickyFirstColumn && stickyCell("bare"), stickyFirstColumn && "border-e-0"),
|
|
700
1083
|
children: ""
|
|
701
1084
|
}) : null,
|
|
702
1085
|
columns.map((col) => /* @__PURE__ */ jsx(Cell, {
|
|
703
1086
|
"data-slot": "table-cell",
|
|
704
|
-
className:
|
|
705
|
-
align: col.align ?? (col.numeric ? "end" : void 0),
|
|
706
|
-
numeric: col.numeric
|
|
707
|
-
}), stickyFirstColumn && col === columns[0] && stickyCell("bare"), stickyFirstColumn && selectable && col === columns[0] && "start-11"),
|
|
1087
|
+
className: cellClass(col, "bare"),
|
|
708
1088
|
children: totalRow(col)
|
|
709
1089
|
}, col.id)),
|
|
710
|
-
|
|
1090
|
+
rowAction ? /* @__PURE__ */ jsx(Cell, {
|
|
711
1091
|
"data-slot": "table-cell",
|
|
712
|
-
className: cnAll(tableCellVariants(), CHEVRON_CELL),
|
|
1092
|
+
className: cnAll(tableCellVariants({ density }), CHEVRON_CELL),
|
|
713
1093
|
children: ""
|
|
714
1094
|
}) : null
|
|
715
1095
|
]
|
|
@@ -785,6 +1165,6 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
785
1165
|
});
|
|
786
1166
|
});
|
|
787
1167
|
//#endregion
|
|
788
|
-
export { Table$1 as Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableEmptyVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableStickyCellVariants, tableVariants };
|
|
1168
|
+
export { Table$1 as Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableDetailCellVariants, tableDetailRowVariants, tableEmptyVariants, tableExpandButtonVariants, tableFooterVariants, tableGroupRowVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableSortButtonVariants, tableStickyCellVariants, tableVariants };
|
|
789
1169
|
|
|
790
1170
|
//# sourceMappingURL=table.js.map
|