@platned/ui 0.10.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -98
- package/dist/blocks-charts.cjs +459 -0
- package/dist/blocks-charts.cjs.map +1 -0
- package/dist/blocks-charts.d.cts +64 -0
- package/dist/blocks-charts.d.ts +64 -0
- package/dist/blocks-charts.js +440 -0
- package/dist/blocks-charts.js.map +1 -0
- package/dist/blocks.cjs +8007 -0
- package/dist/blocks.cjs.map +1 -0
- package/dist/blocks.d.cts +3082 -0
- package/dist/blocks.d.ts +3082 -0
- package/dist/blocks.js +8223 -0
- package/dist/blocks.js.map +1 -0
- package/dist/chart.cjs +226 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.ts +66 -0
- package/dist/chart.js +183 -0
- package/dist/chart.js.map +1 -0
- package/dist/chunk-2L5XAYNK.js +11 -0
- package/dist/chunk-2L5XAYNK.js.map +1 -0
- package/dist/chunk-327NSKZW.js +3176 -0
- package/dist/chunk-327NSKZW.js.map +1 -0
- package/dist/chunk-GJJWRZ4B.js +200 -0
- package/dist/chunk-GJJWRZ4B.js.map +1 -0
- package/dist/chunk-WGCAQEZ4.js +178 -0
- package/dist/chunk-WGCAQEZ4.js.map +1 -0
- package/dist/code-block-BgEiLXpO.d.ts +111 -0
- package/dist/code-block-highlight.cjs +489 -0
- package/dist/code-block-highlight.cjs.map +1 -0
- package/dist/code-block-highlight.d.ts +28 -0
- package/dist/code-block-highlight.js +120 -0
- package/dist/code-block-highlight.js.map +1 -0
- package/dist/data-table-Dec6t8NO.d.ts +729 -0
- package/dist/data-table.cjs +3506 -2219
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +1396 -246
- package/dist/data-table.js.map +1 -1
- package/dist/index.cjs +8934 -11994
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2524 -5312
- package/dist/index.js +4678 -9574
- package/dist/index.js.map +1 -1
- package/dist/map.cjs +432 -0
- package/dist/map.cjs.map +1 -0
- package/dist/map.d.cts +294 -0
- package/dist/map.d.ts +294 -0
- package/dist/map.js +422 -0
- package/dist/map.js.map +1 -0
- package/dist/theme.css +1897 -0
- package/package.json +65 -24
- package/dist/chunk-OVIRTNT4.js +0 -2787
- package/dist/chunk-OVIRTNT4.js.map +0 -1
- package/dist/data-table-JX-vnL0F.d.ts +0 -464
- package/dist/sidebar.cjs +0 -108
- package/dist/sidebar.cjs.map +0 -1
- package/dist/sidebar.d.cts +0 -257
- package/dist/sidebar.d.ts +0 -257
- package/dist/sidebar.js +0 -70
- package/dist/sidebar.js.map +0 -1
- package/dist/styles.css +0 -1
- package/dist/tokens.css +0 -1
- package/tailwind-preset.cjs +0 -446
package/dist/data-table.js
CHANGED
|
@@ -1,27 +1,59 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
Badge,
|
|
3
3
|
Checkbox,
|
|
4
|
+
Command,
|
|
5
|
+
CommandEmpty,
|
|
6
|
+
CommandGroup,
|
|
7
|
+
CommandInput,
|
|
8
|
+
CommandItem,
|
|
9
|
+
CommandList,
|
|
10
|
+
CommandSeparator,
|
|
11
|
+
CommandShortcut,
|
|
4
12
|
DropdownMenu,
|
|
5
13
|
DropdownMenuCheckboxItem,
|
|
6
14
|
DropdownMenuContent,
|
|
15
|
+
DropdownMenuItem,
|
|
7
16
|
DropdownMenuLabel,
|
|
17
|
+
DropdownMenuSeparator,
|
|
8
18
|
DropdownMenuTrigger,
|
|
9
|
-
|
|
10
|
-
FOCUS_RING,
|
|
19
|
+
Empty,
|
|
11
20
|
FOCUS_RING_INSET,
|
|
12
|
-
|
|
21
|
+
Input,
|
|
22
|
+
Popover,
|
|
23
|
+
PopoverContent,
|
|
24
|
+
PopoverTrigger,
|
|
13
25
|
SCROLLBAR_CLASSES,
|
|
14
|
-
|
|
26
|
+
Select,
|
|
27
|
+
Separator,
|
|
15
28
|
Skeleton,
|
|
16
29
|
TableCellBadge,
|
|
17
30
|
TableCellLeadText,
|
|
18
31
|
TableCellProgress,
|
|
19
32
|
TableCellText,
|
|
20
33
|
TableRow,
|
|
21
|
-
|
|
34
|
+
Tabs,
|
|
35
|
+
TabsList,
|
|
36
|
+
TabsTrigger,
|
|
37
|
+
ToggleGroup,
|
|
38
|
+
ToggleGroupItem,
|
|
39
|
+
Value,
|
|
22
40
|
devWarn,
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
fillTemplate,
|
|
42
|
+
formatValue,
|
|
43
|
+
getValueAt,
|
|
44
|
+
humanize,
|
|
45
|
+
isNumericType,
|
|
46
|
+
toDate,
|
|
47
|
+
useElementWidth,
|
|
48
|
+
useFormat,
|
|
49
|
+
valueLabel
|
|
50
|
+
} from "./chunk-327NSKZW.js";
|
|
51
|
+
import {
|
|
52
|
+
Button
|
|
53
|
+
} from "./chunk-WGCAQEZ4.js";
|
|
54
|
+
import {
|
|
55
|
+
cn
|
|
56
|
+
} from "./chunk-2L5XAYNK.js";
|
|
25
57
|
|
|
26
58
|
// src/components/lists/data-table.tsx
|
|
27
59
|
import {
|
|
@@ -31,17 +63,23 @@ import {
|
|
|
31
63
|
useLayoutEffect,
|
|
32
64
|
useMemo,
|
|
33
65
|
useRef,
|
|
34
|
-
useState
|
|
66
|
+
useState,
|
|
67
|
+
Fragment as Fragment4
|
|
35
68
|
} from "react";
|
|
36
69
|
import clsx from "clsx";
|
|
37
70
|
import {
|
|
38
71
|
flexRender,
|
|
39
72
|
getCoreRowModel,
|
|
73
|
+
getExpandedRowModel,
|
|
74
|
+
getFacetedRowModel,
|
|
75
|
+
getFacetedUniqueValues,
|
|
76
|
+
getGroupedRowModel,
|
|
40
77
|
getFilteredRowModel,
|
|
41
78
|
getPaginationRowModel,
|
|
42
79
|
getSortedRowModel,
|
|
43
80
|
useReactTable
|
|
44
81
|
} from "@tanstack/react-table";
|
|
82
|
+
import { ChevronRightIcon as ChevronRightIcon3, CircleAlertIcon, XIcon as XIcon2 } from "lucide-react";
|
|
45
83
|
|
|
46
84
|
// src/components/lists/data-table-layout.ts
|
|
47
85
|
var DEFAULT_CARD_BREAKPOINT_PX = 560;
|
|
@@ -72,8 +110,21 @@ function cardSlots(columns) {
|
|
|
72
110
|
}
|
|
73
111
|
|
|
74
112
|
// src/components/lists/data-table-parts.tsx
|
|
75
|
-
import {
|
|
76
|
-
|
|
113
|
+
import {
|
|
114
|
+
ArrowDownIcon,
|
|
115
|
+
ArrowUpIcon,
|
|
116
|
+
ChevronLeftIcon,
|
|
117
|
+
ChevronRightIcon,
|
|
118
|
+
ChevronsLeftIcon,
|
|
119
|
+
ChevronsRightIcon,
|
|
120
|
+
ChevronsUpDownIcon,
|
|
121
|
+
EyeOffIcon,
|
|
122
|
+
PinIcon,
|
|
123
|
+
PinOffIcon,
|
|
124
|
+
Settings2Icon,
|
|
125
|
+
XIcon
|
|
126
|
+
} from "lucide-react";
|
|
127
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
77
128
|
var SELECT_COLUMN_ID = "select";
|
|
78
129
|
function columnLabel(column) {
|
|
79
130
|
const meta = column.columnDef.meta;
|
|
@@ -83,42 +134,72 @@ function columnLabel(column) {
|
|
|
83
134
|
}
|
|
84
135
|
function DataTableColumnHeader({
|
|
85
136
|
column,
|
|
137
|
+
table,
|
|
86
138
|
title,
|
|
87
139
|
className
|
|
88
140
|
}) {
|
|
89
141
|
const text = title ?? columnLabel(column);
|
|
90
142
|
const hidden = column.columnDef.meta?.hideHeader;
|
|
91
|
-
|
|
92
|
-
|
|
143
|
+
const pinning = table?.options.meta?.pinning;
|
|
144
|
+
const multiSort = Boolean(table?.options.meta?.multiSort);
|
|
145
|
+
if (!column.getCanSort() && !pinning) {
|
|
146
|
+
return /* @__PURE__ */ jsx("div", { className: cn(hidden && "sr-only", className), children: text });
|
|
93
147
|
}
|
|
148
|
+
const sortable = column.getCanSort();
|
|
94
149
|
const sorted = column.getIsSorted();
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
className:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
150
|
+
const pinned = pinning?.get(column.id);
|
|
151
|
+
const sorts = (table?.getState().sorting ?? []).filter((sort) => !sort.id.startsWith("__"));
|
|
152
|
+
const position = sorts.findIndex((sort) => sort.id === column.id);
|
|
153
|
+
const sortIndex = sorted && sorts.length > 1 && position >= 0 ? position + 1 : void 0;
|
|
154
|
+
return /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-2", className), children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
155
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "-ms-3 h-8 data-[state=open]:bg-accent", children: [
|
|
156
|
+
/* @__PURE__ */ jsx("span", { className: cn(hidden && "sr-only"), children: text }),
|
|
157
|
+
pinned && /* @__PURE__ */ jsx(PinIcon, { "aria-hidden": true, className: "size-3 text-muted-foreground" }),
|
|
158
|
+
sorted === "desc" ? /* @__PURE__ */ jsx(ArrowDownIcon, {}) : sorted === "asc" ? /* @__PURE__ */ jsx(ArrowUpIcon, {}) : sortable ? /* @__PURE__ */ jsx(ChevronsUpDownIcon, {}) : null,
|
|
159
|
+
sortIndex && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground tabular-nums", children: [
|
|
160
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: ", sort " }),
|
|
161
|
+
sortIndex
|
|
162
|
+
] })
|
|
163
|
+
] }) }),
|
|
164
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", children: [
|
|
165
|
+
sortable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
166
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: (event) => column.toggleSorting(false, multiSort || event.shiftKey), children: [
|
|
167
|
+
/* @__PURE__ */ jsx(ArrowUpIcon, {}),
|
|
168
|
+
"Asc"
|
|
169
|
+
] }),
|
|
170
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: (event) => column.toggleSorting(true, multiSort || event.shiftKey), children: [
|
|
171
|
+
/* @__PURE__ */ jsx(ArrowDownIcon, {}),
|
|
172
|
+
"Desc"
|
|
173
|
+
] }),
|
|
174
|
+
multiSort && sorted && /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => column.clearSorting(), children: [
|
|
175
|
+
/* @__PURE__ */ jsx(XIcon, {}),
|
|
176
|
+
"Clear sort"
|
|
177
|
+
] })
|
|
178
|
+
] }),
|
|
179
|
+
pinning && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
180
|
+
sortable && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
181
|
+
pinned !== "start" && /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => pinning.set(column.id, "start"), children: [
|
|
182
|
+
/* @__PURE__ */ jsx(PinIcon, {}),
|
|
183
|
+
"Pin to start"
|
|
184
|
+
] }),
|
|
185
|
+
pinned !== "end" && /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => pinning.set(column.id, "end"), children: [
|
|
186
|
+
/* @__PURE__ */ jsx(PinIcon, {}),
|
|
187
|
+
"Pin to end"
|
|
188
|
+
] }),
|
|
189
|
+
pinned && /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => pinning.set(column.id, false), children: [
|
|
190
|
+
/* @__PURE__ */ jsx(PinOffIcon, {}),
|
|
191
|
+
"Unpin"
|
|
192
|
+
] })
|
|
193
|
+
] }),
|
|
194
|
+
column.getCanHide() && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
195
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
196
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => column.toggleVisibility(false), children: [
|
|
197
|
+
/* @__PURE__ */ jsx(EyeOffIcon, {}),
|
|
198
|
+
"Hide"
|
|
199
|
+
] })
|
|
200
|
+
] })
|
|
201
|
+
] })
|
|
202
|
+
] }) });
|
|
122
203
|
}
|
|
123
204
|
function createSelectColumn(options = {}) {
|
|
124
205
|
const { getRowLabel, selectAllLabel = "Select all rows on this page" } = options;
|
|
@@ -128,8 +209,7 @@ function createSelectColumn(options = {}) {
|
|
|
128
209
|
Checkbox,
|
|
129
210
|
{
|
|
130
211
|
"aria-label": selectAllLabel,
|
|
131
|
-
checked: table.getIsAllPageRowsSelected(),
|
|
132
|
-
indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(),
|
|
212
|
+
checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && "indeterminate",
|
|
133
213
|
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked)
|
|
134
214
|
}
|
|
135
215
|
),
|
|
@@ -148,18 +228,24 @@ function createSelectColumn(options = {}) {
|
|
|
148
228
|
meta: { width: "48px", interactive: true, mobile: "hidden", label: "Select" }
|
|
149
229
|
};
|
|
150
230
|
}
|
|
151
|
-
function DataTableViewOptions({ table, label = "
|
|
152
|
-
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
231
|
+
function DataTableViewOptions({ table, label = "View" }) {
|
|
232
|
+
const columns = table.getAllLeafColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide());
|
|
153
233
|
if (columns.length === 0) return null;
|
|
154
234
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
155
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
235
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "ms-auto hidden h-8 lg:flex", children: [
|
|
236
|
+
/* @__PURE__ */ jsx(Settings2Icon, {}),
|
|
237
|
+
label
|
|
238
|
+
] }) }),
|
|
239
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[150px]", children: [
|
|
240
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
241
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
158
242
|
columns.map((column) => /* @__PURE__ */ jsx(
|
|
159
243
|
DropdownMenuCheckboxItem,
|
|
160
244
|
{
|
|
245
|
+
className: "capitalize",
|
|
161
246
|
checked: column.getIsVisible(),
|
|
162
247
|
onCheckedChange: (visible) => column.toggleVisibility(visible),
|
|
248
|
+
onSelect: (event) => event.preventDefault(),
|
|
163
249
|
children: columnLabel(column)
|
|
164
250
|
},
|
|
165
251
|
column.id
|
|
@@ -169,48 +255,601 @@ function DataTableViewOptions({ table, label = "Columns" }) {
|
|
|
169
255
|
}
|
|
170
256
|
function DataTablePagination({
|
|
171
257
|
table,
|
|
172
|
-
pageSizeOptions = [10, 20, 50],
|
|
258
|
+
pageSizeOptions = [10, 20, 25, 30, 40, 50],
|
|
173
259
|
summary
|
|
174
260
|
}) {
|
|
175
261
|
const { pageIndex, pageSize } = table.getState().pagination;
|
|
176
|
-
|
|
177
|
-
|
|
262
|
+
const selectable = Boolean(table.options.enableRowSelection);
|
|
263
|
+
const pageCount = Math.max(table.getPageCount(), 1);
|
|
264
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "data-table-pagination", className: "flex items-center justify-between px-2", children: [
|
|
265
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-muted-foreground", children: summary ?? (selectable ? `${table.getFilteredSelectedRowModel().rows.length} of ${table.getFilteredRowModel().rows.length} row(s) selected.` : null) }),
|
|
266
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6 lg:gap-8", children: [
|
|
267
|
+
pageSizeOptions.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
268
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Rows per page" }),
|
|
269
|
+
/* @__PURE__ */ jsx(
|
|
270
|
+
Select,
|
|
271
|
+
{
|
|
272
|
+
"aria-label": "Rows per page",
|
|
273
|
+
value: `${pageSize}`,
|
|
274
|
+
onValueChange: (value) => table.setPageSize(Number(value)),
|
|
275
|
+
options: pageSizeOptions.map((size) => ({ value: `${size}`, label: `${size}` })),
|
|
276
|
+
className: "h-8 w-[70px]"
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
|
|
281
|
+
"Page ",
|
|
282
|
+
pageIndex + 1,
|
|
283
|
+
" of ",
|
|
284
|
+
pageCount
|
|
285
|
+
] }),
|
|
286
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
287
|
+
/* @__PURE__ */ jsxs(
|
|
288
|
+
Button,
|
|
289
|
+
{
|
|
290
|
+
variant: "outline",
|
|
291
|
+
size: "icon",
|
|
292
|
+
className: "hidden size-8 lg:flex",
|
|
293
|
+
onClick: () => table.setPageIndex(0),
|
|
294
|
+
disabled: !table.getCanPreviousPage(),
|
|
295
|
+
children: [
|
|
296
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Go to first page" }),
|
|
297
|
+
/* @__PURE__ */ jsx(ChevronsLeftIcon, { className: "rtl:rotate-180" })
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ jsxs(
|
|
302
|
+
Button,
|
|
303
|
+
{
|
|
304
|
+
variant: "outline",
|
|
305
|
+
size: "icon",
|
|
306
|
+
className: "size-8",
|
|
307
|
+
onClick: () => table.previousPage(),
|
|
308
|
+
disabled: !table.getCanPreviousPage(),
|
|
309
|
+
children: [
|
|
310
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Go to previous page" }),
|
|
311
|
+
/* @__PURE__ */ jsx(ChevronLeftIcon, { className: "rtl:rotate-180" })
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
),
|
|
315
|
+
/* @__PURE__ */ jsxs(
|
|
316
|
+
Button,
|
|
317
|
+
{
|
|
318
|
+
variant: "outline",
|
|
319
|
+
size: "icon",
|
|
320
|
+
className: "size-8",
|
|
321
|
+
onClick: () => table.nextPage(),
|
|
322
|
+
disabled: !table.getCanNextPage(),
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Go to next page" }),
|
|
325
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "rtl:rotate-180" })
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsxs(
|
|
330
|
+
Button,
|
|
331
|
+
{
|
|
332
|
+
variant: "outline",
|
|
333
|
+
size: "icon",
|
|
334
|
+
className: "hidden size-8 lg:flex",
|
|
335
|
+
onClick: () => table.setPageIndex(table.getPageCount() - 1),
|
|
336
|
+
disabled: !table.getCanNextPage(),
|
|
337
|
+
children: [
|
|
338
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Go to last page" }),
|
|
339
|
+
/* @__PURE__ */ jsx(ChevronsRightIcon, { className: "rtl:rotate-180" })
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
] })
|
|
344
|
+
] })
|
|
345
|
+
] });
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/components/lists/data-table-fields.tsx
|
|
349
|
+
import { CheckIcon, MoreHorizontalIcon, PlusCircleIcon } from "lucide-react";
|
|
350
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
351
|
+
var ROW_ACTIONS_COLUMN_ID = "actions";
|
|
352
|
+
function isFieldColumn(column) {
|
|
353
|
+
return typeof column === "object" && column !== null && "key" in column && typeof column.key === "string";
|
|
354
|
+
}
|
|
355
|
+
function filterValues(value) {
|
|
356
|
+
if (value == null || value === "") return [];
|
|
357
|
+
return Array.isArray(value) ? value.map(String) : [String(value)];
|
|
358
|
+
}
|
|
359
|
+
var includesSome = (row, columnId, selected) => {
|
|
360
|
+
if (!selected?.length) return true;
|
|
361
|
+
return filterValues(row.getValue(columnId)).some((value) => selected.includes(value));
|
|
362
|
+
};
|
|
363
|
+
function sortKey(field, value) {
|
|
364
|
+
if (value == null || value === "") return null;
|
|
365
|
+
switch (field.type) {
|
|
366
|
+
case "number":
|
|
367
|
+
case "currency":
|
|
368
|
+
case "percent": {
|
|
369
|
+
const n = Number(value);
|
|
370
|
+
return Number.isFinite(n) ? n : null;
|
|
371
|
+
}
|
|
372
|
+
case "date":
|
|
373
|
+
case "datetime":
|
|
374
|
+
case "relative":
|
|
375
|
+
return toDate(value)?.getTime() ?? null;
|
|
376
|
+
case "boolean":
|
|
377
|
+
return value ? 1 : 0;
|
|
378
|
+
case "status":
|
|
379
|
+
return valueLabel(value, field.type === "status" ? field.labels : void 0).toLowerCase();
|
|
380
|
+
default:
|
|
381
|
+
return String(value).toLowerCase();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function sortingFnFor(field) {
|
|
385
|
+
return (a, b, columnId) => {
|
|
386
|
+
const x = sortKey(field, a.getValue(columnId));
|
|
387
|
+
const y = sortKey(field, b.getValue(columnId));
|
|
388
|
+
if (x === null || y === null) return x === y ? 0 : x === null ? 1 : -1;
|
|
389
|
+
if (typeof x === "number" && typeof y === "number") return x - y;
|
|
390
|
+
return String(x).localeCompare(String(y), void 0, { numeric: true });
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function describeFor(field) {
|
|
394
|
+
return (value) => {
|
|
395
|
+
if (field.type === "status")
|
|
396
|
+
return { label: valueLabel(value, field.labels), color: field.colors?.[value] ?? "gray" };
|
|
397
|
+
if (field.type === "boolean")
|
|
398
|
+
return { label: value === "true" ? field.trueLabel ?? "Yes" : field.falseLabel ?? "No" };
|
|
399
|
+
if (field.type === "badge") return { label: field.labels?.[value] ?? value };
|
|
400
|
+
return { label: value };
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function fieldToColumn(field, format = {}) {
|
|
404
|
+
const label = field.label ?? humanize(field.key.split(".").pop() ?? field.key);
|
|
405
|
+
const sortable = field.sortable ?? field.type !== "badge";
|
|
406
|
+
const filter = field.filter ? {
|
|
407
|
+
title: typeof field.filter === "object" && field.filter.title || label,
|
|
408
|
+
options: typeof field.filter === "object" ? field.filter.options : void 0,
|
|
409
|
+
variant: typeof field.filter === "object" && field.filter.variant || "menu",
|
|
410
|
+
allLabel: typeof field.filter === "object" && field.filter.allLabel || "All",
|
|
411
|
+
describe: describeFor(field)
|
|
412
|
+
} : void 0;
|
|
413
|
+
const mobile = field.mobile ?? (field.type === "avatar" ? "title" : field.type === "status" ? "status" : void 0);
|
|
414
|
+
return {
|
|
415
|
+
id: field.id ?? field.key,
|
|
416
|
+
// Empty values read as undefined, so `sortUndefined: 'last'` keeps them last in both directions.
|
|
417
|
+
accessorFn: (row) => {
|
|
418
|
+
const value = getValueAt(row, field.key);
|
|
419
|
+
return value === null || value === "" ? void 0 : value;
|
|
420
|
+
},
|
|
421
|
+
header: ({ column, table }) => /* @__PURE__ */ jsx2(DataTableColumnHeader, { column, table, title: label }),
|
|
422
|
+
cell: ({ row }) => /* @__PURE__ */ jsx2(Value, { row: row.original, field }),
|
|
423
|
+
enableSorting: sortable,
|
|
424
|
+
enableHiding: field.hideable ?? true,
|
|
425
|
+
sortingFn: sortingFnFor(field),
|
|
426
|
+
sortUndefined: "last",
|
|
427
|
+
filterFn: includesSome,
|
|
428
|
+
// A badge column's facets are its single values, not the lists.
|
|
429
|
+
getUniqueValues: (row) => filterValues(getValueAt(row, field.key)),
|
|
430
|
+
meta: {
|
|
431
|
+
label,
|
|
432
|
+
width: field.width,
|
|
433
|
+
grow: field.grow,
|
|
434
|
+
align: field.align ?? (isNumericType(field.type) ? "end" : void 0),
|
|
435
|
+
sticky: field.sticky,
|
|
436
|
+
mobile,
|
|
437
|
+
// A cell with its own link or copy button keeps presses from activating the row.
|
|
438
|
+
interactive: field.type === "email" || field.type === "link" || field.type === "phone" || void 0,
|
|
439
|
+
filter,
|
|
440
|
+
searchText: (value) => formatValue(value, field, format)
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function createGlobalSearch(textById) {
|
|
445
|
+
return (row, columnId, query) => {
|
|
446
|
+
const needle = String(query ?? "").trim().toLowerCase();
|
|
447
|
+
if (!needle) return true;
|
|
448
|
+
const value = row.getValue(columnId);
|
|
449
|
+
const toText = textById.get(columnId);
|
|
450
|
+
const text = toText ? toText(value) : value == null ? "" : Array.isArray(value) ? value.join(" ") : String(value);
|
|
451
|
+
return text.toLowerCase().includes(needle);
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function RowActionsMenu({
|
|
455
|
+
row,
|
|
456
|
+
actions,
|
|
457
|
+
rowLabel,
|
|
458
|
+
renderLink
|
|
459
|
+
}) {
|
|
460
|
+
const visible = actions.filter((action) => !action.hidden?.(row));
|
|
461
|
+
if (visible.length === 0) return null;
|
|
462
|
+
return /* @__PURE__ */ jsxs2(DropdownMenu, { children: [
|
|
463
|
+
/* @__PURE__ */ jsx2(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "ghost", size: "icon", className: "size-8 data-[state=open]:bg-muted", children: [
|
|
464
|
+
/* @__PURE__ */ jsx2(MoreHorizontalIcon, {}),
|
|
465
|
+
/* @__PURE__ */ jsx2("span", { className: "sr-only", children: rowLabel ? `Actions for ${rowLabel}` : "Open menu" })
|
|
466
|
+
] }) }),
|
|
467
|
+
/* @__PURE__ */ jsx2(DropdownMenuContent, { align: "end", className: "w-[160px]", children: visible.map((action, index) => /* @__PURE__ */ jsx2(
|
|
468
|
+
RowAction,
|
|
469
|
+
{
|
|
470
|
+
action,
|
|
471
|
+
row,
|
|
472
|
+
renderLink,
|
|
473
|
+
first: index === 0
|
|
474
|
+
},
|
|
475
|
+
`${action.label}-${index}`
|
|
476
|
+
)) })
|
|
477
|
+
] });
|
|
478
|
+
}
|
|
479
|
+
function RowAction({
|
|
480
|
+
action,
|
|
481
|
+
row,
|
|
482
|
+
renderLink,
|
|
483
|
+
first
|
|
484
|
+
}) {
|
|
485
|
+
const content = /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
486
|
+
action.icon,
|
|
487
|
+
action.label
|
|
488
|
+
] });
|
|
489
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
490
|
+
action.separator && !first && /* @__PURE__ */ jsx2(DropdownMenuSeparator, {}),
|
|
491
|
+
action.href ? /* @__PURE__ */ jsx2(
|
|
492
|
+
DropdownMenuItem,
|
|
493
|
+
{
|
|
494
|
+
asChild: true,
|
|
495
|
+
variant: action.destructive ? "destructive" : "default",
|
|
496
|
+
disabled: action.disabled?.(row),
|
|
497
|
+
onSelect: () => action.onSelect?.(row),
|
|
498
|
+
children: renderLink({ href: fillTemplate(action.href, row), children: content }, row)
|
|
499
|
+
}
|
|
500
|
+
) : /* @__PURE__ */ jsx2(
|
|
501
|
+
DropdownMenuItem,
|
|
502
|
+
{
|
|
503
|
+
variant: action.destructive ? "destructive" : "default",
|
|
504
|
+
disabled: action.disabled?.(row),
|
|
505
|
+
onSelect: () => action.onSelect?.(row),
|
|
506
|
+
children: content
|
|
507
|
+
}
|
|
508
|
+
)
|
|
509
|
+
] });
|
|
510
|
+
}
|
|
511
|
+
function rowActionsColumn(actions, options) {
|
|
512
|
+
return {
|
|
513
|
+
id: ROW_ACTIONS_COLUMN_ID,
|
|
514
|
+
header: "Actions",
|
|
515
|
+
enableSorting: false,
|
|
516
|
+
enableHiding: false,
|
|
517
|
+
cell: ({ row }) => /* @__PURE__ */ jsx2(
|
|
518
|
+
RowActionsMenu,
|
|
519
|
+
{
|
|
520
|
+
row: row.original,
|
|
521
|
+
actions,
|
|
522
|
+
rowLabel: options.getRowLabel?.(row.original),
|
|
523
|
+
renderLink: options.renderLink
|
|
524
|
+
}
|
|
525
|
+
),
|
|
526
|
+
meta: {
|
|
527
|
+
label: "Actions",
|
|
528
|
+
hideHeader: true,
|
|
529
|
+
interactive: true,
|
|
530
|
+
mobile: "actions",
|
|
531
|
+
align: "end",
|
|
532
|
+
width: "56px",
|
|
533
|
+
sticky: "end"
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
var DOT = {
|
|
538
|
+
gray: "bg-badge-dot-gray",
|
|
539
|
+
red: "bg-badge-dot-red",
|
|
540
|
+
orange: "bg-badge-dot-orange",
|
|
541
|
+
yellow: "bg-badge-dot-yellow",
|
|
542
|
+
lime: "bg-badge-dot-lime",
|
|
543
|
+
green: "bg-badge-dot-green",
|
|
544
|
+
teal: "bg-badge-dot-teal",
|
|
545
|
+
blue: "bg-badge-dot-blue",
|
|
546
|
+
pink: "bg-badge-dot-pink",
|
|
547
|
+
slate: "bg-badge-dot-slate",
|
|
548
|
+
violet: "bg-badge-dot-violet"
|
|
549
|
+
};
|
|
550
|
+
function facets(column) {
|
|
551
|
+
const meta = column.columnDef.meta?.filter;
|
|
552
|
+
const counts = /* @__PURE__ */ new Map();
|
|
553
|
+
for (const row of column.getFacetedRowModel().rows) {
|
|
554
|
+
if (row.getIsGrouped()) continue;
|
|
555
|
+
for (const value of filterValues(row.getValue(column.id))) counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
556
|
+
}
|
|
557
|
+
const values = meta?.options ?? [...counts.keys()].sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
558
|
+
const items = values.map((value) => ({
|
|
559
|
+
value,
|
|
560
|
+
...meta?.describe(value) ?? { label: value },
|
|
561
|
+
icon: void 0
|
|
562
|
+
}));
|
|
563
|
+
const total = column.getFacetedRowModel().rows.filter((row) => !row.getIsGrouped()).length;
|
|
564
|
+
return { counts, items, total };
|
|
565
|
+
}
|
|
566
|
+
function singleValue(column) {
|
|
567
|
+
const value = column.getFilterValue()?.[0];
|
|
568
|
+
return {
|
|
569
|
+
value: value ?? "",
|
|
570
|
+
set: (next) => column.setFilterValue(next ? [next] : void 0)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function DataTableButtonFilter({ column, title }) {
|
|
574
|
+
const meta = column.columnDef.meta?.filter;
|
|
575
|
+
const { items } = facets(column);
|
|
576
|
+
const { value, set } = singleValue(column);
|
|
577
|
+
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
578
|
+
return /* @__PURE__ */ jsxs2(
|
|
579
|
+
ToggleGroup,
|
|
178
580
|
{
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
581
|
+
type: "single",
|
|
582
|
+
variant: "outline",
|
|
583
|
+
size: "sm",
|
|
584
|
+
spacing: 0,
|
|
585
|
+
"aria-label": heading,
|
|
586
|
+
value: value || "__all",
|
|
587
|
+
onValueChange: (next) => set(next === "__all" || !next ? "" : next),
|
|
588
|
+
children: [
|
|
589
|
+
/* @__PURE__ */ jsx2(ToggleGroupItem, { value: "__all", children: meta?.allLabel ?? "All" }),
|
|
590
|
+
items.map((item) => /* @__PURE__ */ jsxs2(ToggleGroupItem, { value: item.value, children: [
|
|
591
|
+
item.color && /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: cn("size-2 rounded-full", DOT[item.color]) }),
|
|
592
|
+
item.label
|
|
593
|
+
] }, item.value))
|
|
594
|
+
]
|
|
187
595
|
}
|
|
188
596
|
);
|
|
189
597
|
}
|
|
598
|
+
function DataTableTabsFilter({ column, title }) {
|
|
599
|
+
const meta = column.columnDef.meta?.filter;
|
|
600
|
+
const { counts, items, total } = facets(column);
|
|
601
|
+
const { value, set } = singleValue(column);
|
|
602
|
+
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
603
|
+
const count = (n) => /* @__PURE__ */ jsx2(Badge, { variant: "secondary", className: "ms-1 h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: n ?? 0 });
|
|
604
|
+
return /* @__PURE__ */ jsx2(Tabs, { value: value || "__all", onValueChange: (next) => set(next === "__all" ? "" : next), children: /* @__PURE__ */ jsxs2(TabsList, { "aria-label": heading, children: [
|
|
605
|
+
/* @__PURE__ */ jsxs2(TabsTrigger, { value: "__all", children: [
|
|
606
|
+
meta?.allLabel ?? "All",
|
|
607
|
+
count(total)
|
|
608
|
+
] }),
|
|
609
|
+
items.map((item) => /* @__PURE__ */ jsxs2(TabsTrigger, { value: item.value, children: [
|
|
610
|
+
item.label,
|
|
611
|
+
count(counts.get(item.value))
|
|
612
|
+
] }, item.value))
|
|
613
|
+
] }) });
|
|
614
|
+
}
|
|
615
|
+
function DataTableFacetedFilter({ column, title, options }) {
|
|
616
|
+
const meta = column.columnDef.meta?.filter;
|
|
617
|
+
const { counts, items: facetItems } = facets(column);
|
|
618
|
+
const items = options ?? facetItems;
|
|
619
|
+
const selected = new Set(column.getFilterValue() ?? []);
|
|
620
|
+
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
621
|
+
const toggle = (value) => {
|
|
622
|
+
const next = new Set(selected);
|
|
623
|
+
if (next.has(value)) next.delete(value);
|
|
624
|
+
else next.add(value);
|
|
625
|
+
column.setFilterValue(next.size ? [...next] : void 0);
|
|
626
|
+
};
|
|
627
|
+
return /* @__PURE__ */ jsxs2(Popover, { children: [
|
|
628
|
+
/* @__PURE__ */ jsx2(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", children: [
|
|
629
|
+
/* @__PURE__ */ jsx2(PlusCircleIcon, {}),
|
|
630
|
+
heading,
|
|
631
|
+
selected.size > 0 && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
632
|
+
/* @__PURE__ */ jsx2(Separator, { orientation: "vertical", className: "mx-2 h-4" }),
|
|
633
|
+
/* @__PURE__ */ jsx2(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal lg:hidden", children: selected.size }),
|
|
634
|
+
/* @__PURE__ */ jsx2("div", { className: "hidden gap-1 lg:flex", children: selected.size > 2 ? /* @__PURE__ */ jsxs2(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal", children: [
|
|
635
|
+
selected.size,
|
|
636
|
+
" selected"
|
|
637
|
+
] }) : items.filter((item) => selected.has(item.value)).map((item) => /* @__PURE__ */ jsx2(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal", children: item.label }, item.value)) })
|
|
638
|
+
] })
|
|
639
|
+
] }) }),
|
|
640
|
+
/* @__PURE__ */ jsx2(PopoverContent, { className: "w-[200px] p-0", align: "start", children: /* @__PURE__ */ jsxs2(Command, { children: [
|
|
641
|
+
/* @__PURE__ */ jsx2(CommandInput, { placeholder: heading, "aria-label": heading }),
|
|
642
|
+
/* @__PURE__ */ jsxs2(CommandList, { children: [
|
|
643
|
+
/* @__PURE__ */ jsx2(CommandEmpty, { children: "No results found." }),
|
|
644
|
+
/* @__PURE__ */ jsx2(CommandGroup, { children: items.map((item) => {
|
|
645
|
+
const isSelected = selected.has(item.value);
|
|
646
|
+
return /* @__PURE__ */ jsxs2(
|
|
647
|
+
CommandItem,
|
|
648
|
+
{
|
|
649
|
+
value: item.label,
|
|
650
|
+
keywords: [item.value],
|
|
651
|
+
"aria-checked": isSelected,
|
|
652
|
+
onSelect: () => toggle(item.value),
|
|
653
|
+
children: [
|
|
654
|
+
/* @__PURE__ */ jsx2(
|
|
655
|
+
"div",
|
|
656
|
+
{
|
|
657
|
+
className: cn(
|
|
658
|
+
"flex size-4 items-center justify-center rounded-[4px] border",
|
|
659
|
+
isSelected ? "border-primary bg-primary text-primary-foreground" : "border-input [&_svg]:invisible"
|
|
660
|
+
),
|
|
661
|
+
children: /* @__PURE__ */ jsx2(CheckIcon, { className: "size-3.5 text-primary-foreground" })
|
|
662
|
+
}
|
|
663
|
+
),
|
|
664
|
+
item.color && /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: cn("size-2 rounded-full", DOT[item.color]) }),
|
|
665
|
+
item.icon,
|
|
666
|
+
/* @__PURE__ */ jsx2("span", { children: item.label }),
|
|
667
|
+
counts.get(item.value) ? (
|
|
668
|
+
// A shortcut slot, so it takes the item's end (and the item's own check hides).
|
|
669
|
+
/* @__PURE__ */ jsx2(CommandShortcut, { className: "font-mono tracking-normal", children: counts.get(item.value) })
|
|
670
|
+
) : null
|
|
671
|
+
]
|
|
672
|
+
},
|
|
673
|
+
item.value
|
|
674
|
+
);
|
|
675
|
+
}) }),
|
|
676
|
+
selected.size > 0 && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
677
|
+
/* @__PURE__ */ jsx2(CommandSeparator, {}),
|
|
678
|
+
/* @__PURE__ */ jsx2(CommandGroup, { children: /* @__PURE__ */ jsx2(CommandItem, { onSelect: () => column.setFilterValue(void 0), className: "justify-center text-center", children: "Clear filters" }) })
|
|
679
|
+
] })
|
|
680
|
+
] })
|
|
681
|
+
] }) })
|
|
682
|
+
] });
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// src/components/lists/data-table-features.tsx
|
|
686
|
+
import { createContext, useContext } from "react";
|
|
687
|
+
import { ChevronRightIcon as ChevronRightIcon2, GripVerticalIcon } from "lucide-react";
|
|
688
|
+
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
689
|
+
var EXPAND_COLUMN_ID = "expand";
|
|
690
|
+
var DRAG_COLUMN_ID = "drag";
|
|
691
|
+
var GROUP_COLUMN_ID = "__group";
|
|
692
|
+
function DetailFields({ row, fields }) {
|
|
693
|
+
return /* @__PURE__ */ jsx3("dl", { className: "grid gap-x-6 gap-y-3 sm:grid-cols-2 lg:grid-cols-3", children: fields.map((field) => /* @__PURE__ */ jsxs3("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
694
|
+
/* @__PURE__ */ jsx3("dt", { className: "text-xs text-muted-foreground", children: field.label ?? humanize(field.key.split(".").pop() ?? field.key) }),
|
|
695
|
+
/* @__PURE__ */ jsx3("dd", { className: "min-w-0 text-sm", children: /* @__PURE__ */ jsx3(Value, { row, field }) })
|
|
696
|
+
] }, field.key)) });
|
|
697
|
+
}
|
|
698
|
+
function expandColumn() {
|
|
699
|
+
return {
|
|
700
|
+
id: EXPAND_COLUMN_ID,
|
|
701
|
+
header: "Details",
|
|
702
|
+
enableSorting: false,
|
|
703
|
+
enableHiding: false,
|
|
704
|
+
enableGlobalFilter: false,
|
|
705
|
+
cell: ({ row, table }) => {
|
|
706
|
+
const expansion = table.options.meta?.expansion;
|
|
707
|
+
if (!expansion) return null;
|
|
708
|
+
const open = expansion.isOpen(row.id);
|
|
709
|
+
return /* @__PURE__ */ jsx3(
|
|
710
|
+
Button,
|
|
711
|
+
{
|
|
712
|
+
variant: "ghost",
|
|
713
|
+
size: "icon-sm",
|
|
714
|
+
"aria-expanded": open,
|
|
715
|
+
"aria-controls": open ? detailId(row.id) : void 0,
|
|
716
|
+
"aria-label": `Details for ${expansion.label(row.original)}`,
|
|
717
|
+
onClick: () => expansion.toggle(row.id),
|
|
718
|
+
children: /* @__PURE__ */ jsx3(ChevronRightIcon2, { className: cn("transition-transform", open && "rotate-90") })
|
|
719
|
+
}
|
|
720
|
+
);
|
|
721
|
+
},
|
|
722
|
+
meta: { width: "44px", interactive: true, hideHeader: true, mobile: "hidden", label: "Details" }
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
var detailId = (rowId) => `data-table-detail-${rowId.replace(/[^\w-]/g, "_")}`;
|
|
726
|
+
var RowDragContext = createContext(null);
|
|
727
|
+
function DragHandle() {
|
|
728
|
+
const drag = useContext(RowDragContext);
|
|
729
|
+
if (!drag) return null;
|
|
730
|
+
return /* @__PURE__ */ jsx3(
|
|
731
|
+
Button,
|
|
732
|
+
{
|
|
733
|
+
ref: drag.setActivatorNodeRef,
|
|
734
|
+
variant: "ghost",
|
|
735
|
+
size: "icon-sm",
|
|
736
|
+
disabled: drag.disabled,
|
|
737
|
+
"aria-label": drag.label,
|
|
738
|
+
title: drag.disabled ? "Clear the sort, filters and grouping to reorder" : void 0,
|
|
739
|
+
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
740
|
+
onClick: (event) => event.stopPropagation(),
|
|
741
|
+
...drag.attributes,
|
|
742
|
+
...drag.listeners,
|
|
743
|
+
children: /* @__PURE__ */ jsx3(GripVerticalIcon, {})
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
function dragColumn() {
|
|
748
|
+
return {
|
|
749
|
+
id: DRAG_COLUMN_ID,
|
|
750
|
+
header: "Reorder",
|
|
751
|
+
enableSorting: false,
|
|
752
|
+
enableHiding: false,
|
|
753
|
+
enableGlobalFilter: false,
|
|
754
|
+
cell: () => /* @__PURE__ */ jsx3(DragHandle, {}),
|
|
755
|
+
// Not `interactive`: that guard stops key events, which would also stop the drag sensor's
|
|
756
|
+
// window listener. The handle stops its own clicks instead.
|
|
757
|
+
meta: { width: "44px", hideHeader: true, mobile: "hidden", label: "Reorder" }
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
function groupKey(value, by = "value", timeZone) {
|
|
761
|
+
if (by === "value") return value == null ? "" : Array.isArray(value) ? value.join(", ") : String(value);
|
|
762
|
+
const date = toDate(value);
|
|
763
|
+
if (!date) return "";
|
|
764
|
+
const iso = new Intl.DateTimeFormat("en-CA", { timeZone, year: "numeric", month: "2-digit", day: "2-digit" }).format(
|
|
765
|
+
date
|
|
766
|
+
);
|
|
767
|
+
return by === "day" ? iso : by === "month" ? iso.slice(0, 7) : iso.slice(0, 4);
|
|
768
|
+
}
|
|
769
|
+
function GroupLabel({
|
|
770
|
+
groupingValue,
|
|
771
|
+
by = "value",
|
|
772
|
+
format,
|
|
773
|
+
options
|
|
774
|
+
}) {
|
|
775
|
+
if (groupingValue === "") return /* @__PURE__ */ jsx3("span", { className: "text-muted-foreground", children: "None" });
|
|
776
|
+
if (by === "value") return /* @__PURE__ */ jsx3(Value, { value: groupingValue, ...format ?? {} });
|
|
777
|
+
const [y, m = "01", d = "01"] = groupingValue.split("-");
|
|
778
|
+
const date = new Date(Date.UTC(Number(y), Number(m) - 1, Number(d), 12));
|
|
779
|
+
if (by === "year") return /* @__PURE__ */ jsx3(Fragment3, { children: y });
|
|
780
|
+
if (by === "month")
|
|
781
|
+
return /* @__PURE__ */ jsx3(Fragment3, { children: new Intl.DateTimeFormat(options.locale, { month: "long", year: "numeric", timeZone: "UTC" }).format(date) });
|
|
782
|
+
const today = groupKey(options.now === void 0 ? /* @__PURE__ */ new Date() : new Date(options.now), "day", options.timeZone);
|
|
783
|
+
const yesterday = groupKey(
|
|
784
|
+
(options.now === void 0 ? Date.now() : new Date(options.now).getTime()) - 24 * 3600 * 1e3,
|
|
785
|
+
"day",
|
|
786
|
+
options.timeZone
|
|
787
|
+
);
|
|
788
|
+
const words = new Intl.DateTimeFormat(options.locale, {
|
|
789
|
+
weekday: "long",
|
|
790
|
+
day: "numeric",
|
|
791
|
+
month: "long",
|
|
792
|
+
year: "numeric",
|
|
793
|
+
timeZone: "UTC"
|
|
794
|
+
}).format(date);
|
|
795
|
+
if (groupingValue === today) return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
796
|
+
"Today \xB7 ",
|
|
797
|
+
words
|
|
798
|
+
] });
|
|
799
|
+
if (groupingValue === yesterday) return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
800
|
+
"Yesterday \xB7 ",
|
|
801
|
+
words
|
|
802
|
+
] });
|
|
803
|
+
return /* @__PURE__ */ jsx3(Fragment3, { children: words });
|
|
804
|
+
}
|
|
805
|
+
function groupSummary(row, summary, formatOf, options) {
|
|
806
|
+
const leaves = row.getLeafRows().filter((leaf) => !leaf.getIsGrouped());
|
|
807
|
+
return summary.map(({ key, fn = "sum", label }) => {
|
|
808
|
+
if (fn === "count") return { key, text: String(leaves.length), label };
|
|
809
|
+
const numbers = leaves.map((leaf) => Number(getValueAt(leaf.original, key))).filter(Number.isFinite);
|
|
810
|
+
const total = fn === "min" ? Math.min(...numbers) : fn === "max" ? Math.max(...numbers) : numbers.reduce((sum, n) => sum + n, 0) / (fn === "avg" ? numbers.length || 1 : 1);
|
|
811
|
+
const format = formatOf(key) ?? { type: "number" };
|
|
812
|
+
return { key, text: numbers.length ? formatValue(total, format, options) : "\u2014", label };
|
|
813
|
+
});
|
|
814
|
+
}
|
|
190
815
|
|
|
191
816
|
// src/components/lists/data-table.tsx
|
|
192
|
-
import {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
817
|
+
import {
|
|
818
|
+
DndContext,
|
|
819
|
+
KeyboardSensor,
|
|
820
|
+
PointerSensor,
|
|
821
|
+
closestCenter,
|
|
822
|
+
useSensor,
|
|
823
|
+
useSensors
|
|
824
|
+
} from "@dnd-kit/core";
|
|
825
|
+
import {
|
|
826
|
+
SortableContext,
|
|
827
|
+
arrayMove,
|
|
828
|
+
sortableKeyboardCoordinates,
|
|
829
|
+
useSortable,
|
|
830
|
+
verticalListSortingStrategy
|
|
831
|
+
} from "@dnd-kit/sortable";
|
|
832
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
833
|
+
import { Fragment as Fragment5, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
834
|
+
var ROW_TONE = "data-[tone=muted]:bg-muted data-[tone=brand]:bg-accent data-[tone=positive]:bg-success/10 data-[tone=warning]:bg-warning/10 data-[tone=danger]:bg-destructive/10 data-[dimmed]:opacity-60 data-[state=selected]:bg-muted";
|
|
835
|
+
var D = {
|
|
836
|
+
headerCell: "h-10 px-2 align-middle",
|
|
837
|
+
headerText: "text-foreground font-medium whitespace-nowrap",
|
|
838
|
+
bodyCell: "p-2 whitespace-nowrap"
|
|
204
839
|
};
|
|
205
840
|
var VERTICAL = {
|
|
206
841
|
center: "align-middle",
|
|
207
842
|
top: "align-top"
|
|
208
843
|
};
|
|
209
844
|
var TEXT_ALIGN = {
|
|
210
|
-
start: "text-
|
|
845
|
+
start: "text-start",
|
|
211
846
|
center: "text-center",
|
|
212
|
-
end: "text-
|
|
847
|
+
end: "text-end"
|
|
213
848
|
};
|
|
849
|
+
var GROUPING_ON = ["__group"];
|
|
850
|
+
var GROUPING_OFF = [];
|
|
851
|
+
var NO_ROWS = [];
|
|
852
|
+
var UTILITY_COLUMNS = ["drag", "select", "expand"];
|
|
214
853
|
var ROW_LINK_ATTR = "data-row-link";
|
|
215
854
|
function resolve(updater, previous) {
|
|
216
855
|
return typeof updater === "function" ? updater(previous) : updater;
|
|
@@ -236,7 +875,7 @@ function useTableState(controlled, initial, onChange) {
|
|
|
236
875
|
function CellInteractionGuard({ children }) {
|
|
237
876
|
return (
|
|
238
877
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
239
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ jsx4(
|
|
240
879
|
"div",
|
|
241
880
|
{
|
|
242
881
|
className: "contents",
|
|
@@ -248,7 +887,7 @@ function CellInteractionGuard({ children }) {
|
|
|
248
887
|
)
|
|
249
888
|
);
|
|
250
889
|
}
|
|
251
|
-
var HEADER_PADDING_PX =
|
|
890
|
+
var HEADER_PADDING_PX = 16;
|
|
252
891
|
function useHeaderWidths(padding, deps) {
|
|
253
892
|
const nodes = useRef(/* @__PURE__ */ new Map());
|
|
254
893
|
const [widths, setWidths] = useState({});
|
|
@@ -310,7 +949,7 @@ function useScrollEdges() {
|
|
|
310
949
|
}
|
|
311
950
|
var serverSortedValue = () => void 0;
|
|
312
951
|
function defaultRowLink({ children, ...props }) {
|
|
313
|
-
return /* @__PURE__ */
|
|
952
|
+
return /* @__PURE__ */ jsx4("a", { ...props, children });
|
|
314
953
|
}
|
|
315
954
|
function DataTable({
|
|
316
955
|
columns,
|
|
@@ -327,7 +966,17 @@ function DataTable({
|
|
|
327
966
|
onSelectionChange,
|
|
328
967
|
getRowLabel,
|
|
329
968
|
onRowClick,
|
|
330
|
-
getRowHref,
|
|
969
|
+
getRowHref: getRowHrefProp,
|
|
970
|
+
rowHref,
|
|
971
|
+
rowActions,
|
|
972
|
+
defaultSort,
|
|
973
|
+
multiSort = false,
|
|
974
|
+
expand,
|
|
975
|
+
groupBy,
|
|
976
|
+
columnPinning = false,
|
|
977
|
+
resizable = false,
|
|
978
|
+
reorderable = false,
|
|
979
|
+
onDataChange,
|
|
331
980
|
renderRowLink = defaultRowLink,
|
|
332
981
|
getRowTone,
|
|
333
982
|
getRowDimmed,
|
|
@@ -335,10 +984,9 @@ function DataTable({
|
|
|
335
984
|
loadingRows = 5,
|
|
336
985
|
error,
|
|
337
986
|
onRetry,
|
|
338
|
-
empty = "No results
|
|
987
|
+
empty = "No results.",
|
|
339
988
|
toolbar,
|
|
340
989
|
footer,
|
|
341
|
-
density = "default",
|
|
342
990
|
align = "center",
|
|
343
991
|
responsive = true,
|
|
344
992
|
maxHeight,
|
|
@@ -360,7 +1008,29 @@ function DataTable({
|
|
|
360
1008
|
if (manual.pagination && manual.rowCount === void 0) {
|
|
361
1009
|
devWarn("DataTable `manual.pagination` needs `manual.rowCount` to know how many pages there are.");
|
|
362
1010
|
}
|
|
363
|
-
const [sorting, setSorting] = useTableState(
|
|
1011
|
+
const [sorting, setSorting] = useTableState(
|
|
1012
|
+
state.sorting,
|
|
1013
|
+
(Array.isArray(defaultSort) ? defaultSort : defaultSort ? [defaultSort] : []).map((sort) => ({
|
|
1014
|
+
id: sort.key,
|
|
1015
|
+
desc: Boolean(sort.desc)
|
|
1016
|
+
})),
|
|
1017
|
+
onSortingChange
|
|
1018
|
+
);
|
|
1019
|
+
const [ownOrder, setOwnOrder] = useState(null);
|
|
1020
|
+
useEffect(() => setOwnOrder(null), [data]);
|
|
1021
|
+
const tableData = ownOrder ?? data;
|
|
1022
|
+
const moveRow = (from, to) => {
|
|
1023
|
+
const next = arrayMove(tableData, from, to);
|
|
1024
|
+
if (onDataChange) onDataChange(next);
|
|
1025
|
+
else setOwnOrder(next);
|
|
1026
|
+
};
|
|
1027
|
+
const group = typeof groupBy === "string" ? { key: groupBy } : groupBy;
|
|
1028
|
+
const [groupsExpanded, setGroupsExpanded] = useState(group?.defaultCollapsed ? {} : true);
|
|
1029
|
+
const [openRows, setOpenRows] = useState(() => new Set(expand?.defaultExpanded ?? []));
|
|
1030
|
+
const [pinOverrides, setPinOverrides] = useState({});
|
|
1031
|
+
const [widthOverrides, setWidthOverrides] = useState({});
|
|
1032
|
+
const getRowHref = getRowHrefProp ?? (rowHref ? (row) => fillTemplate(rowHref, row) : void 0);
|
|
1033
|
+
const format = useFormat();
|
|
364
1034
|
const [globalFilter, setGlobalFilter] = useTableState(state.globalFilter, "", onGlobalFilterChange);
|
|
365
1035
|
const [columnFilters, setColumnFilters] = useTableState(state.columnFilters, [], onColumnFiltersChange);
|
|
366
1036
|
const [pagination, setPagination] = useTableState(
|
|
@@ -374,21 +1044,152 @@ function DataTable({
|
|
|
374
1044
|
onColumnVisibilityChange
|
|
375
1045
|
);
|
|
376
1046
|
const [rowSelection, setRowSelection] = useTableState(state.rowSelection, {}, onRowSelectionChange);
|
|
1047
|
+
const hasExpand = Boolean(expand);
|
|
377
1048
|
const allColumns = useMemo(() => {
|
|
378
|
-
let cols = columns
|
|
1049
|
+
let cols = columns.map(
|
|
1050
|
+
(column) => isFieldColumn(column) ? fieldToColumn(column, format) : column
|
|
1051
|
+
);
|
|
1052
|
+
if (expand) cols = [expandColumn(), ...cols];
|
|
1053
|
+
if (group) {
|
|
1054
|
+
cols = [
|
|
1055
|
+
...cols,
|
|
1056
|
+
{
|
|
1057
|
+
id: GROUP_COLUMN_ID,
|
|
1058
|
+
accessorFn: (row) => groupKey(getValueAt(row, group.key), group.by, format.timeZone),
|
|
1059
|
+
header: "Group",
|
|
1060
|
+
cell: () => null,
|
|
1061
|
+
enableHiding: false,
|
|
1062
|
+
enableGlobalFilter: false,
|
|
1063
|
+
meta: { mobile: "hidden", label: "Group" }
|
|
1064
|
+
}
|
|
1065
|
+
];
|
|
1066
|
+
}
|
|
1067
|
+
if (rowActions?.length) {
|
|
1068
|
+
cols = [
|
|
1069
|
+
...cols,
|
|
1070
|
+
rowActionsColumn(rowActions, {
|
|
1071
|
+
getRowLabel,
|
|
1072
|
+
renderLink: ({ href, children }, row) => renderRowLink({ href, className: "", children, [ROW_LINK_ATTR]: "" }, row)
|
|
1073
|
+
})
|
|
1074
|
+
];
|
|
1075
|
+
}
|
|
379
1076
|
if (manual.sorting) {
|
|
380
1077
|
cols = cols.map(
|
|
381
1078
|
(column) => column.enableSorting === true && !("accessorFn" in column) && !("accessorKey" in column) ? { ...column, accessorFn: serverSortedValue } : column
|
|
382
1079
|
);
|
|
383
1080
|
}
|
|
384
|
-
if (
|
|
385
|
-
|
|
386
|
-
|
|
1081
|
+
if (enableRowSelection && !cols.some((column) => column.id === SELECT_COLUMN_ID)) {
|
|
1082
|
+
cols = [createSelectColumn({ getRowLabel: getRowLabel && ((row) => `Select ${getRowLabel(row)}`) }), ...cols];
|
|
1083
|
+
}
|
|
1084
|
+
if (reorderable) cols = [dragColumn(), ...cols];
|
|
1085
|
+
return cols;
|
|
1086
|
+
}, [
|
|
1087
|
+
columns,
|
|
1088
|
+
enableRowSelection,
|
|
1089
|
+
getRowLabel,
|
|
1090
|
+
manual.sorting,
|
|
1091
|
+
format,
|
|
1092
|
+
rowActions,
|
|
1093
|
+
renderRowLink,
|
|
1094
|
+
hasExpand,
|
|
1095
|
+
group?.key,
|
|
1096
|
+
group?.by,
|
|
1097
|
+
reorderable
|
|
1098
|
+
]);
|
|
1099
|
+
const fieldsByKey = useMemo(() => {
|
|
1100
|
+
const map = /* @__PURE__ */ new Map();
|
|
1101
|
+
for (const column of columns) if (isFieldColumn(column)) map.set(column.key, column);
|
|
1102
|
+
return map;
|
|
1103
|
+
}, [columns]);
|
|
1104
|
+
const formatOf = (key) => {
|
|
1105
|
+
const field = fieldsByKey.get(key);
|
|
1106
|
+
if (!field) return void 0;
|
|
1107
|
+
const { key: _key, label: _label, ...rest } = field;
|
|
1108
|
+
return rest;
|
|
1109
|
+
};
|
|
1110
|
+
const metaPin = (id) => allColumns.find((column) => column.id === id)?.meta?.sticky;
|
|
1111
|
+
const pinOf = (id) => {
|
|
1112
|
+
const override = pinOverrides[id];
|
|
1113
|
+
return override === "none" ? void 0 : override ?? metaPin(id);
|
|
1114
|
+
};
|
|
1115
|
+
const columnIds = allColumns.map((column) => column.id ?? "");
|
|
1116
|
+
const isUtility = (id) => UTILITY_COLUMNS.includes(id);
|
|
1117
|
+
const orderKey = [
|
|
1118
|
+
...UTILITY_COLUMNS.filter((id) => columnIds.includes(id)),
|
|
1119
|
+
...columnIds.filter((id) => !isUtility(id) && pinOf(id) === "start"),
|
|
1120
|
+
...columnIds.filter((id) => !isUtility(id) && !pinOf(id)),
|
|
1121
|
+
...columnIds.filter((id) => !isUtility(id) && pinOf(id) === "end")
|
|
1122
|
+
].join("\0");
|
|
1123
|
+
const columnOrder = useMemo(() => orderKey.split("\0"), [orderKey]);
|
|
1124
|
+
const anyStartPin = columnIds.some((id) => !isUtility(id) && pinOf(id) === "start");
|
|
1125
|
+
const effectivePin = (id) => isUtility(id) ? anyStartPin ? "start" : void 0 : pinOf(id);
|
|
1126
|
+
const grouped = Boolean(group);
|
|
1127
|
+
const groupDesc = group?.order === "desc";
|
|
1128
|
+
const effectiveSorting = useMemo(
|
|
1129
|
+
() => grouped ? [{ id: GROUP_COLUMN_ID, desc: groupDesc }, ...sorting.filter((sort) => sort.id !== GROUP_COLUMN_ID)] : sorting,
|
|
1130
|
+
[grouped, groupDesc, sorting]
|
|
1131
|
+
);
|
|
1132
|
+
const effectiveVisibility = useMemo(
|
|
1133
|
+
() => grouped ? { ...columnVisibility, [GROUP_COLUMN_ID]: false } : columnVisibility,
|
|
1134
|
+
[grouped, columnVisibility]
|
|
1135
|
+
);
|
|
1136
|
+
const expansion = expand ? {
|
|
1137
|
+
isOpen: (id) => openRows.has(id),
|
|
1138
|
+
toggle: (id) => setOpenRows((current) => {
|
|
1139
|
+
const next = new Set(expand.single ? [] : current);
|
|
1140
|
+
if (current.has(id)) next.delete(id);
|
|
1141
|
+
else next.add(id);
|
|
1142
|
+
return next;
|
|
1143
|
+
}),
|
|
1144
|
+
label: (row) => getRowLabel?.(row) ?? "row",
|
|
1145
|
+
render: (row) => expand.render ? expand.render(row) : expand.table ? /* @__PURE__ */ jsx4(
|
|
1146
|
+
DataTable,
|
|
1147
|
+
{
|
|
1148
|
+
label: expand.table.label ?? "Details",
|
|
1149
|
+
data: getValueAt(row, expand.table.key) ?? NO_ROWS,
|
|
1150
|
+
columns: expand.table.columns,
|
|
1151
|
+
pagination: false,
|
|
1152
|
+
className: "bg-background"
|
|
1153
|
+
}
|
|
1154
|
+
) : expand.fields ? /* @__PURE__ */ jsx4(DetailFields, { row, fields: expand.fields }) : null
|
|
1155
|
+
} : void 0;
|
|
1156
|
+
const searchTextById = useMemo(() => {
|
|
1157
|
+
const map = /* @__PURE__ */ new Map();
|
|
1158
|
+
for (const column of allColumns) {
|
|
1159
|
+
const text = column.meta?.searchText;
|
|
1160
|
+
if (text && column.id) map.set(column.id, text);
|
|
1161
|
+
}
|
|
1162
|
+
return map;
|
|
1163
|
+
}, [allColumns]);
|
|
1164
|
+
const hasFilters = allColumns.some((column) => column.meta?.filter);
|
|
387
1165
|
const table = useReactTable({
|
|
388
|
-
data,
|
|
1166
|
+
data: tableData,
|
|
389
1167
|
columns: allColumns,
|
|
390
1168
|
getRowId,
|
|
391
|
-
state: {
|
|
1169
|
+
state: {
|
|
1170
|
+
sorting: effectiveSorting,
|
|
1171
|
+
globalFilter,
|
|
1172
|
+
columnFilters,
|
|
1173
|
+
pagination,
|
|
1174
|
+
columnVisibility: effectiveVisibility,
|
|
1175
|
+
rowSelection,
|
|
1176
|
+
columnOrder,
|
|
1177
|
+
grouping: grouped ? GROUPING_ON : GROUPING_OFF,
|
|
1178
|
+
expanded: groupsExpanded
|
|
1179
|
+
},
|
|
1180
|
+
onExpandedChange: setGroupsExpanded,
|
|
1181
|
+
getGroupedRowModel: group ? getGroupedRowModel() : void 0,
|
|
1182
|
+
getExpandedRowModel: group ? getExpandedRowModel() : void 0,
|
|
1183
|
+
groupedColumnMode: false,
|
|
1184
|
+
autoResetExpanded: false,
|
|
1185
|
+
meta: {
|
|
1186
|
+
pinning: columnPinning ? {
|
|
1187
|
+
get: pinOf,
|
|
1188
|
+
set: (id, side) => setPinOverrides((current) => ({ ...current, [id]: side || "none" }))
|
|
1189
|
+
} : void 0,
|
|
1190
|
+
multiSort,
|
|
1191
|
+
expansion
|
|
1192
|
+
},
|
|
392
1193
|
onSortingChange: setSorting,
|
|
393
1194
|
onGlobalFilterChange: setGlobalFilter,
|
|
394
1195
|
onColumnFiltersChange: setColumnFilters,
|
|
@@ -400,6 +1201,16 @@ function DataTable({
|
|
|
400
1201
|
getSortedRowModel: manual.sorting ? void 0 : getSortedRowModel(),
|
|
401
1202
|
getFilteredRowModel: manual.filtering ? void 0 : getFilteredRowModel(),
|
|
402
1203
|
getPaginationRowModel: paginated && !manual.pagination ? getPaginationRowModel() : void 0,
|
|
1204
|
+
getFacetedRowModel: hasFilters ? getFacetedRowModel() : void 0,
|
|
1205
|
+
getFacetedUniqueValues: hasFilters ? getFacetedUniqueValues() : void 0,
|
|
1206
|
+
globalFilterFn: searchTextById.size ? createGlobalSearch(searchTextById) : "auto",
|
|
1207
|
+
// TanStack searches only columns whose first value is a string or number. JSON columns are
|
|
1208
|
+
// searched by their shown text, so lists (tags), dates and nested values are searchable too.
|
|
1209
|
+
getColumnCanGlobalFilter: (column) => {
|
|
1210
|
+
if (column.columnDef.meta?.searchText) return true;
|
|
1211
|
+
const value = tableData.length ? column.accessorFn?.(tableData[0], 0) : void 0;
|
|
1212
|
+
return typeof value === "string" || typeof value === "number";
|
|
1213
|
+
},
|
|
403
1214
|
manualSorting: manual.sorting,
|
|
404
1215
|
manualFiltering: manual.filtering,
|
|
405
1216
|
manualPagination: !paginated || manual.pagination,
|
|
@@ -435,25 +1246,28 @@ function DataTable({
|
|
|
435
1246
|
const filtering = Boolean(globalFilter) || columnFilters.length > 0;
|
|
436
1247
|
const rows = table.getRowModel().rows;
|
|
437
1248
|
const isEmpty = !loading && !error && rows.length === 0;
|
|
438
|
-
const placeholder = error ? /* @__PURE__ */
|
|
439
|
-
|
|
1249
|
+
const placeholder = error ? /* @__PURE__ */ jsx4(
|
|
1250
|
+
Empty,
|
|
440
1251
|
{
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1252
|
+
role: "alert",
|
|
1253
|
+
icon: /* @__PURE__ */ jsx4(CircleAlertIcon, {}),
|
|
1254
|
+
title: typeof error === "string" ? error : "Something went wrong loading this data.",
|
|
1255
|
+
className: "mx-auto max-w-[520px]",
|
|
1256
|
+
children: onRetry ? /* @__PURE__ */ jsx4(Button, { variant: "outline", size: "xs", onClick: onRetry, children: "Retry" }) : void 0
|
|
446
1257
|
}
|
|
447
|
-
) : isEmpty ?
|
|
1258
|
+
) : isEmpty ? empty : null;
|
|
448
1259
|
const resultCount = manual.filtering ? table.getRowCount() : table.getFilteredRowModel().rows.length;
|
|
449
|
-
const
|
|
1260
|
+
const filterColumns = table.getAllLeafColumns().filter((column) => column.columnDef.meta?.filter);
|
|
1261
|
+
const tabsFilters = filterColumns.filter((column) => column.columnDef.meta?.filter?.variant === "tabs");
|
|
1262
|
+
const isToolbarFilter = (id) => filterColumns.some((c) => c.id === id && c.columnDef.meta?.filter?.variant !== "tabs");
|
|
1263
|
+
const showToolbar = Boolean(search || toolbar || showColumnMenu || filterColumns.length > tabsFilters.length);
|
|
1264
|
+
const reorderActive = reorderable && sorting.length === 0 && !filtering && !group;
|
|
450
1265
|
const showPager = paginated && !error && table.getRowCount() > 0;
|
|
451
1266
|
const view = {
|
|
452
1267
|
table,
|
|
453
1268
|
label,
|
|
454
1269
|
caption,
|
|
455
1270
|
captionId,
|
|
456
|
-
density,
|
|
457
1271
|
align,
|
|
458
1272
|
loading,
|
|
459
1273
|
loadingRows,
|
|
@@ -464,34 +1278,75 @@ function DataTable({
|
|
|
464
1278
|
getRowTone,
|
|
465
1279
|
getRowDimmed,
|
|
466
1280
|
getRowLabel,
|
|
467
|
-
maxHeight
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
1281
|
+
maxHeight,
|
|
1282
|
+
expansion,
|
|
1283
|
+
pinOf: effectivePin,
|
|
1284
|
+
resizable,
|
|
1285
|
+
widthOverrides,
|
|
1286
|
+
setWidth: (id, width) => setWidthOverrides((current) => {
|
|
1287
|
+
const next = { ...current };
|
|
1288
|
+
if (width === void 0) delete next[id];
|
|
1289
|
+
else next[id] = width;
|
|
1290
|
+
return next;
|
|
1291
|
+
}),
|
|
1292
|
+
reorder: reorderable ? { active: reorderActive, move: moveRow } : void 0,
|
|
1293
|
+
group: group ? {
|
|
1294
|
+
label: (row) => /* @__PURE__ */ jsx4(
|
|
1295
|
+
GroupLabel,
|
|
473
1296
|
{
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
onChange: (event) => setSearchValue(event.target.value),
|
|
479
|
-
onClear: () => setSearchValue(""),
|
|
480
|
-
className: "w-full max-w-[280px]"
|
|
1297
|
+
groupingValue: String(row.groupingValue ?? ""),
|
|
1298
|
+
by: group.by,
|
|
1299
|
+
format: group.by && group.by !== "value" ? void 0 : formatOf(group.key),
|
|
1300
|
+
options: format
|
|
481
1301
|
}
|
|
482
1302
|
),
|
|
483
|
-
|
|
484
|
-
|
|
1303
|
+
summary: (row) => groupSummary(row, group.summary ?? [], formatOf, format)
|
|
1304
|
+
} : void 0
|
|
1305
|
+
};
|
|
1306
|
+
return /* @__PURE__ */ jsxs4("div", { "data-slot": "data-table", className: cn("relative flex flex-col gap-4", className), children: [
|
|
1307
|
+
tabsFilters.length > 0 && /* @__PURE__ */ jsx4("div", { className: cn("flex flex-wrap items-center gap-2", !bordered && "px-4 pt-3"), children: tabsFilters.map((column) => /* @__PURE__ */ jsx4(DataTableTabsFilter, { column }, column.id)) }),
|
|
1308
|
+
showToolbar && /* @__PURE__ */ jsxs4("div", { className: cn("flex items-center justify-between gap-2", !bordered && "px-4 pt-3"), children: [
|
|
1309
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-wrap items-center gap-2", children: [
|
|
1310
|
+
search && /* @__PURE__ */ jsx4(
|
|
1311
|
+
Input,
|
|
1312
|
+
{
|
|
1313
|
+
type: "search",
|
|
1314
|
+
"aria-label": search.label ?? "Filter",
|
|
1315
|
+
placeholder: search.placeholder ?? "Filter...",
|
|
1316
|
+
value: searchValue,
|
|
1317
|
+
onChange: (event) => setSearchValue(event.target.value),
|
|
1318
|
+
className: "h-8 w-[150px] lg:w-[250px]"
|
|
1319
|
+
}
|
|
1320
|
+
),
|
|
1321
|
+
filterColumns.map(
|
|
1322
|
+
(column) => column.columnDef.meta?.filter?.variant === "buttons" ? /* @__PURE__ */ jsx4(DataTableButtonFilter, { column }, column.id) : column.columnDef.meta?.filter?.variant === "tabs" ? null : /* @__PURE__ */ jsx4(DataTableFacetedFilter, { column }, column.id)
|
|
1323
|
+
),
|
|
1324
|
+
columnFilters.some((f) => isToolbarFilter(f.id)) && /* @__PURE__ */ jsxs4(
|
|
1325
|
+
Button,
|
|
1326
|
+
{
|
|
1327
|
+
variant: "ghost",
|
|
1328
|
+
size: "sm",
|
|
1329
|
+
onClick: () => table.setColumnFilters((current) => current.filter((f) => !isToolbarFilter(f.id))),
|
|
1330
|
+
children: [
|
|
1331
|
+
"Reset",
|
|
1332
|
+
/* @__PURE__ */ jsx4(XIcon2, {})
|
|
1333
|
+
]
|
|
1334
|
+
}
|
|
1335
|
+
),
|
|
1336
|
+
toolbar
|
|
1337
|
+
] }),
|
|
1338
|
+
showColumnMenu && /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx4(DataTableViewOptions, { table }) })
|
|
485
1339
|
] }),
|
|
486
|
-
/* @__PURE__ */
|
|
487
|
-
/* @__PURE__ */
|
|
488
|
-
mode === "cards" && caption && /* @__PURE__ */
|
|
489
|
-
mode === "cards" ? maxHeight ? /* @__PURE__ */
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
1340
|
+
/* @__PURE__ */ jsx4("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
|
|
1341
|
+
/* @__PURE__ */ jsxs4("div", { ref: wrapRef, className: cn("overflow-hidden bg-background", bordered && "rounded-md border"), children: [
|
|
1342
|
+
mode === "cards" && caption && /* @__PURE__ */ jsx4("div", { id: captionId, className: "px-4 pt-3 text-left text-sm text-muted-foreground", children: caption }),
|
|
1343
|
+
mode === "cards" ? maxHeight ? /* @__PURE__ */ jsx4(CardScroll, { label, maxHeight, children: /* @__PURE__ */ jsx4(CardList, { ...view }) }) : /* @__PURE__ */ jsx4(CardList, { ...view }) : /* @__PURE__ */ jsx4(TableView, { ...view }),
|
|
1344
|
+
footer && /* @__PURE__ */ jsx4("div", { className: "border-t p-2", children: footer })
|
|
1345
|
+
] }),
|
|
1346
|
+
showPager && /* @__PURE__ */ jsx4("div", { className: cn(!bordered && "px-2 pb-3"), children: /* @__PURE__ */ jsx4(DataTablePagination, { table, pageSizeOptions }) })
|
|
493
1347
|
] });
|
|
494
1348
|
}
|
|
1349
|
+
var verticalOnly = ({ transform }) => ({ ...transform, x: 0 });
|
|
495
1350
|
function titleColumnId(columns) {
|
|
496
1351
|
const content = columns.filter((column) => column.id !== SELECT_COLUMN_ID);
|
|
497
1352
|
return (content.find((column) => column.columnDef.meta?.mobile === "title") ?? content[0])?.id;
|
|
@@ -500,7 +1355,6 @@ function TableView({
|
|
|
500
1355
|
table,
|
|
501
1356
|
label,
|
|
502
1357
|
caption,
|
|
503
|
-
density,
|
|
504
1358
|
align,
|
|
505
1359
|
loading,
|
|
506
1360
|
loadingRows,
|
|
@@ -510,40 +1364,63 @@ function TableView({
|
|
|
510
1364
|
renderRowLink,
|
|
511
1365
|
getRowTone,
|
|
512
1366
|
getRowDimmed,
|
|
513
|
-
|
|
1367
|
+
getRowLabel,
|
|
1368
|
+
maxHeight,
|
|
1369
|
+
expansion,
|
|
1370
|
+
pinOf,
|
|
1371
|
+
resizable,
|
|
1372
|
+
widthOverrides,
|
|
1373
|
+
setWidth,
|
|
1374
|
+
reorder,
|
|
1375
|
+
group
|
|
514
1376
|
}) {
|
|
515
|
-
const d =
|
|
1377
|
+
const d = D;
|
|
516
1378
|
const columns = table.getVisibleLeafColumns();
|
|
1379
|
+
const sensors = useSensors(
|
|
1380
|
+
useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),
|
|
1381
|
+
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
|
|
1382
|
+
);
|
|
517
1383
|
const scroll = useScrollEdges();
|
|
518
|
-
const headers = useHeaderWidths(HEADER_PADDING_PX
|
|
519
|
-
const columnPx = (column) => Math.max(widthToPx(column.columnDef.meta?.width), headers.widths[column.id] ?? 0);
|
|
1384
|
+
const headers = useHeaderWidths(HEADER_PADDING_PX, columns.map((column) => column.id).join());
|
|
1385
|
+
const columnPx = (column) => widthOverrides[column.id] ?? Math.max(widthToPx(column.columnDef.meta?.width), headers.widths[column.id] ?? 0);
|
|
520
1386
|
const minWidth = columns.reduce((sum, column) => sum + columnPx(column), 0);
|
|
521
1387
|
const showPlaceholder = loading || placeholder !== null;
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
1388
|
+
const offsets = usePinOffsets(
|
|
1389
|
+
[
|
|
1390
|
+
columns.map((column) => `${column.id}:${pinOf(column.id) ?? ""}`).join(),
|
|
1391
|
+
JSON.stringify(widthOverrides),
|
|
1392
|
+
Object.values(headers.widths).join(),
|
|
1393
|
+
scroll.overflowing
|
|
1394
|
+
].join("|")
|
|
1395
|
+
);
|
|
1396
|
+
const pinned = (id) => scroll.overflowing ? pinOf(id) : void 0;
|
|
1397
|
+
const startIds = columns.filter((column) => pinned(column.id) === "start").map((column) => column.id);
|
|
1398
|
+
const endIds = columns.filter((column) => pinned(column.id) === "end").map((column) => column.id);
|
|
1399
|
+
const hasSticky = startIds.length + endIds.length > 0;
|
|
527
1400
|
const titleId = titleColumnId(columns);
|
|
528
1401
|
const rowAction = getRowHref ? "link" : onRowClick ? "click" : null;
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
1402
|
+
const stickyProps = (id, header) => {
|
|
1403
|
+
const side = pinned(id);
|
|
1404
|
+
if (!side) return { className: "" };
|
|
1405
|
+
return {
|
|
1406
|
+
className: clsx(
|
|
1407
|
+
"sticky z-raised",
|
|
1408
|
+
// A hairline where content slides under the pinned columns, once it has scrolled.
|
|
1409
|
+
side === "start" && id === startIds[startIds.length - 1] && !scroll.atStart && "shadow-[inset_-1px_0_0_var(--border)]",
|
|
1410
|
+
side === "end" && id === endIds[0] && !scroll.atEnd && "shadow-[inset_1px_0_0_var(--border)]",
|
|
1411
|
+
header ? "bg-background" : ["bg-background", rowAction && "group-hover:bg-muted"]
|
|
1412
|
+
),
|
|
1413
|
+
style: side === "start" ? { insetInlineStart: offsets.start[id] ?? 0 } : { insetInlineEnd: offsets.end[id] ?? 0 }
|
|
1414
|
+
};
|
|
1415
|
+
};
|
|
1416
|
+
const stickyStart = startIds[0];
|
|
1417
|
+
const stickyEnd = endIds[0];
|
|
541
1418
|
const scrolls = scroll.overflowing || Boolean(maxHeight) && scroll.overflowingY;
|
|
542
1419
|
const direction = scroll.overflowing && maxHeight && scroll.overflowingY ? "scrolls" : scroll.overflowing ? "scrolls horizontally" : "scrolls vertically";
|
|
543
1420
|
const regionLabel = `${label ?? "Table"} (${direction})`;
|
|
544
|
-
const pinnedHeader = maxHeight ? clsx("sticky top-0 z-sticky bg-
|
|
545
|
-
return /* @__PURE__ */
|
|
546
|
-
/* @__PURE__ */
|
|
1421
|
+
const pinnedHeader = maxHeight ? clsx("sticky top-0 z-sticky bg-background", !scroll.atTop && "shadow-[inset_0_-1px_0_var(--border)]") : void 0;
|
|
1422
|
+
return /* @__PURE__ */ jsxs4("div", { className: "relative", children: [
|
|
1423
|
+
/* @__PURE__ */ jsx4(
|
|
547
1424
|
"div",
|
|
548
1425
|
{
|
|
549
1426
|
ref: scroll.ref,
|
|
@@ -555,105 +1432,164 @@ function TableView({
|
|
|
555
1432
|
),
|
|
556
1433
|
style: maxHeight ? { maxHeight } : void 0,
|
|
557
1434
|
...scrolls ? { role: "region", tabIndex: 0, "aria-label": regionLabel } : {},
|
|
558
|
-
children: /* @__PURE__ */
|
|
559
|
-
|
|
1435
|
+
children: /* @__PURE__ */ jsx4(
|
|
1436
|
+
DndWrapper,
|
|
560
1437
|
{
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
1438
|
+
enabled: Boolean(reorder),
|
|
1439
|
+
sensors,
|
|
1440
|
+
ids: table.getRowModel().rows.map((row) => row.id),
|
|
1441
|
+
onDragEnd: (event) => {
|
|
1442
|
+
const rows = table.getRowModel().rows;
|
|
1443
|
+
const from = rows.find((row) => row.id === event.active.id)?.index;
|
|
1444
|
+
const to = rows.find((row) => row.id === event.over?.id)?.index;
|
|
1445
|
+
if (from !== void 0 && to !== void 0 && from !== to) reorder?.move(from, to);
|
|
1446
|
+
},
|
|
1447
|
+
children: /* @__PURE__ */ jsxs4(
|
|
1448
|
+
"table",
|
|
1449
|
+
{
|
|
1450
|
+
className: "w-full table-fixed border-collapse caption-bottom text-sm text-start",
|
|
1451
|
+
style: showPlaceholder ? void 0 : { minWidth },
|
|
1452
|
+
"aria-busy": loading || void 0,
|
|
1453
|
+
children: [
|
|
1454
|
+
caption ? /* @__PURE__ */ jsx4("caption", { className: "text-muted-foreground py-4 text-sm", children: caption }) : label && /* @__PURE__ */ jsx4("caption", { className: "sr-only", children: label }),
|
|
1455
|
+
/* @__PURE__ */ jsx4("colgroup", { children: columns.map((column) => {
|
|
1456
|
+
const meta = column.columnDef.meta;
|
|
1457
|
+
const floor = headers.widths[column.id] ?? 0;
|
|
1458
|
+
return /* @__PURE__ */ jsx4(
|
|
1459
|
+
"col",
|
|
1460
|
+
{
|
|
1461
|
+
style: widthOverrides[column.id] !== void 0 ? { width: widthOverrides[column.id] } : meta?.grow || !meta?.width ? void 0 : { width: floor > widthToPx(meta.width) ? floor : meta.width }
|
|
1462
|
+
},
|
|
1463
|
+
column.id
|
|
1464
|
+
);
|
|
1465
|
+
}) }),
|
|
1466
|
+
/* @__PURE__ */ jsx4("thead", { children: table.getHeaderGroups().map((group2) => /* @__PURE__ */ jsx4("tr", { className: "border-b", children: group2.headers.map((header) => {
|
|
1467
|
+
const meta = header.column.columnDef.meta;
|
|
1468
|
+
const sortable = header.column.getCanSort();
|
|
1469
|
+
const sorted = header.column.getIsSorted();
|
|
1470
|
+
const definition = header.column.columnDef.header;
|
|
1471
|
+
const sticky = stickyProps(header.column.id, true);
|
|
1472
|
+
const canResize = resizable && !UTILITY_COLUMNS.includes(header.column.id) && !meta?.hideHeader;
|
|
1473
|
+
return /* @__PURE__ */ jsxs4(
|
|
1474
|
+
"th",
|
|
1475
|
+
{
|
|
1476
|
+
ref: offsets.register(header.column.id),
|
|
1477
|
+
scope: "col",
|
|
1478
|
+
colSpan: header.colSpan,
|
|
1479
|
+
style: sticky.style,
|
|
1480
|
+
"aria-sort": sortable ? sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : "none" : void 0,
|
|
1481
|
+
className: cn(
|
|
1482
|
+
d.headerCell,
|
|
1483
|
+
d.headerText,
|
|
1484
|
+
TEXT_ALIGN[meta?.align ?? "start"],
|
|
1485
|
+
!meta?.interactive && "overflow-hidden",
|
|
1486
|
+
canResize && "relative",
|
|
1487
|
+
sticky.className,
|
|
1488
|
+
pinnedHeader,
|
|
1489
|
+
meta?.headerClassName
|
|
1490
|
+
),
|
|
1491
|
+
children: [
|
|
1492
|
+
header.isPlaceholder ? null : typeof definition === "string" || definition === void 0 ? /* @__PURE__ */ jsx4("span", { ref: meta?.hideHeader ? void 0 : headers.register(header.column.id), className: "inline-block", children: /* @__PURE__ */ jsx4(DataTableColumnHeader, { column: header.column, table }) }) : flexRender(definition, header.getContext()),
|
|
1493
|
+
canResize && /* @__PURE__ */ jsx4(
|
|
1494
|
+
ResizeHandle,
|
|
1495
|
+
{
|
|
1496
|
+
label: columnLabel(header.column),
|
|
1497
|
+
floor: headers.widths[header.column.id] ?? 48,
|
|
1498
|
+
width: () => offsets.width(header.column.id),
|
|
1499
|
+
onResize: (width) => setWidth(header.column.id, width)
|
|
1500
|
+
}
|
|
1501
|
+
)
|
|
1502
|
+
]
|
|
1503
|
+
},
|
|
1504
|
+
header.id
|
|
1505
|
+
);
|
|
1506
|
+
}) }, group2.id)) }),
|
|
1507
|
+
/* @__PURE__ */ jsx4("tbody", { className: "[&_tr:last-child]:border-0", children: loading && !placeholder ? Array.from({ length: loadingRows }, (_, index) => /* @__PURE__ */ jsx4("tr", { className: "border-b", children: columns.map((column) => /* @__PURE__ */ jsx4("td", { className: clsx(d.bodyCell, "align-middle"), children: /* @__PURE__ */ jsx4(Skeleton, { className: column.columnDef.meta?.grow ? "h-4 w-[70%]" : "h-4 w-[55%]" }) }, column.id)) }, `skeleton-${index}`)) : placeholder ? /* @__PURE__ */ jsx4("tr", { children: /* @__PURE__ */ jsx4("td", { colSpan: columns.length, className: "h-24 px-2 text-center", children: placeholder }) }) : table.getRowModel().rows.map((row) => {
|
|
1508
|
+
if (row.getIsGrouped() && group) {
|
|
1509
|
+
return /* @__PURE__ */ jsx4(GroupRow, { row, span: columns.length, group }, row.id);
|
|
1510
|
+
}
|
|
1511
|
+
const props = {
|
|
1512
|
+
row,
|
|
1513
|
+
align,
|
|
1514
|
+
titleId,
|
|
1515
|
+
rowAction,
|
|
1516
|
+
hasSticky,
|
|
1517
|
+
stickyProps,
|
|
1518
|
+
onRowClick,
|
|
1519
|
+
getRowHref,
|
|
1520
|
+
renderRowLink,
|
|
1521
|
+
getRowTone,
|
|
1522
|
+
getRowDimmed
|
|
1523
|
+
};
|
|
1524
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
1525
|
+
reorder ? /* @__PURE__ */ jsx4(
|
|
1526
|
+
SortableBodyRow,
|
|
1527
|
+
{
|
|
1528
|
+
...props,
|
|
1529
|
+
disabled: !reorder.active,
|
|
1530
|
+
label: `Reorder ${getRowLabel?.(row.original) ?? "row"}`
|
|
1531
|
+
}
|
|
1532
|
+
) : /* @__PURE__ */ jsx4(BodyRow, { ...props }),
|
|
1533
|
+
expansion?.isOpen(row.id) && /* @__PURE__ */ jsx4("tr", { "data-slot": "data-table-detail", className: "border-b bg-muted/30", children: /* @__PURE__ */ jsx4("td", { colSpan: columns.length, className: "p-0", children: /* @__PURE__ */ jsx4(
|
|
1534
|
+
"div",
|
|
1535
|
+
{
|
|
1536
|
+
id: detailId(row.id),
|
|
1537
|
+
role: "region",
|
|
1538
|
+
"aria-label": `Details for ${expansion.label(row.original)}`,
|
|
1539
|
+
className: "p-4",
|
|
1540
|
+
children: expansion.render(row.original)
|
|
1541
|
+
}
|
|
1542
|
+
) }) })
|
|
1543
|
+
] }, row.id);
|
|
1544
|
+
}) })
|
|
1545
|
+
]
|
|
1546
|
+
}
|
|
1547
|
+
)
|
|
621
1548
|
}
|
|
622
1549
|
)
|
|
623
1550
|
}
|
|
624
1551
|
),
|
|
625
|
-
scroll.overflowing && !scroll.atStart && !stickyStart && /* @__PURE__ */
|
|
626
|
-
scroll.overflowing && !scroll.atEnd && !stickyEnd && /* @__PURE__ */
|
|
1552
|
+
scroll.overflowing && !scroll.atStart && !stickyStart && /* @__PURE__ */ jsx4("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0 left-0 w-6 bg-gradient-to-r from-muted to-transparent" }),
|
|
1553
|
+
scroll.overflowing && !scroll.atEnd && !stickyEnd && /* @__PURE__ */ jsx4("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0 right-0 w-6 bg-gradient-to-l from-muted to-transparent" })
|
|
627
1554
|
] });
|
|
628
1555
|
}
|
|
629
1556
|
function BodyRow({
|
|
630
1557
|
row,
|
|
631
|
-
density,
|
|
632
1558
|
align,
|
|
633
1559
|
titleId,
|
|
634
1560
|
rowAction,
|
|
635
1561
|
hasSticky,
|
|
636
|
-
|
|
1562
|
+
stickyProps,
|
|
637
1563
|
onRowClick,
|
|
638
1564
|
getRowHref,
|
|
639
1565
|
renderRowLink,
|
|
640
1566
|
getRowTone,
|
|
641
|
-
getRowDimmed
|
|
1567
|
+
getRowDimmed,
|
|
1568
|
+
sortable
|
|
642
1569
|
}) {
|
|
643
|
-
const d =
|
|
1570
|
+
const d = D;
|
|
644
1571
|
const href = getRowHref?.(row.original);
|
|
645
|
-
return /* @__PURE__ */
|
|
1572
|
+
return /* @__PURE__ */ jsx4(
|
|
646
1573
|
TableRow,
|
|
647
1574
|
{
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
1575
|
+
ref: sortable?.ref,
|
|
1576
|
+
style: sortable?.style,
|
|
1577
|
+
"data-dragging": sortable?.dragging || void 0,
|
|
1578
|
+
"aria-selected": row.getIsSelected() || void 0,
|
|
1579
|
+
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
1580
|
+
"data-tone": (() => {
|
|
1581
|
+
const tone = getRowTone?.(row.original);
|
|
1582
|
+
return tone && tone !== "default" ? tone : void 0;
|
|
1583
|
+
})(),
|
|
1584
|
+
"data-dimmed": getRowDimmed?.(row.original) || void 0,
|
|
651
1585
|
className: cn(
|
|
652
1586
|
"group",
|
|
653
|
-
|
|
1587
|
+
ROW_TONE,
|
|
1588
|
+
"data-[dragging]:relative data-[dragging]:z-overlay data-[dragging]:bg-background data-[dragging]:shadow-lg",
|
|
1589
|
+
rowAction && ["cursor-pointer", hasSticky && "hover:bg-muted"],
|
|
654
1590
|
// outline, not ring: `ring-*` is box-shadow, which browsers do not paint on a <tr>
|
|
655
1591
|
// under border-collapse.
|
|
656
|
-
rowAction === "click" && "outline-none focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-
|
|
1592
|
+
rowAction === "click" && "outline-none focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
|
657
1593
|
),
|
|
658
1594
|
tabIndex: rowAction === "click" ? 0 : void 0,
|
|
659
1595
|
onClick: rowAction === "link" ? (event) => {
|
|
@@ -667,11 +1603,12 @@ function BodyRow({
|
|
|
667
1603
|
onRowClick(row.original);
|
|
668
1604
|
}
|
|
669
1605
|
} : void 0,
|
|
670
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */
|
|
1606
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx4(
|
|
671
1607
|
BodyCell,
|
|
672
1608
|
{
|
|
673
1609
|
cell,
|
|
674
|
-
className: cn(d.bodyCell, VERTICAL[align],
|
|
1610
|
+
className: cn(d.bodyCell, VERTICAL[align], stickyProps(cell.column.id, false).className),
|
|
1611
|
+
style: stickyProps(cell.column.id, false).style,
|
|
675
1612
|
link: href && cell.column.id === titleId ? href : void 0,
|
|
676
1613
|
renderRowLink
|
|
677
1614
|
},
|
|
@@ -683,6 +1620,7 @@ function BodyRow({
|
|
|
683
1620
|
function BodyCell({
|
|
684
1621
|
cell,
|
|
685
1622
|
className,
|
|
1623
|
+
style,
|
|
686
1624
|
link,
|
|
687
1625
|
renderRowLink
|
|
688
1626
|
}) {
|
|
@@ -696,9 +1634,10 @@ function BodyCell({
|
|
|
696
1634
|
children: content
|
|
697
1635
|
}, cell.row.original);
|
|
698
1636
|
}
|
|
699
|
-
return /* @__PURE__ */
|
|
1637
|
+
return /* @__PURE__ */ jsx4(
|
|
700
1638
|
"td",
|
|
701
1639
|
{
|
|
1640
|
+
style,
|
|
702
1641
|
className: cn(
|
|
703
1642
|
className,
|
|
704
1643
|
TEXT_ALIGN[meta?.align ?? "start"],
|
|
@@ -707,13 +1646,180 @@ function BodyCell({
|
|
|
707
1646
|
!meta?.interactive && "overflow-hidden",
|
|
708
1647
|
meta?.cellClassName
|
|
709
1648
|
),
|
|
710
|
-
children: meta?.interactive ? /* @__PURE__ */
|
|
1649
|
+
children: meta?.interactive ? /* @__PURE__ */ jsx4(CellInteractionGuard, { children: content }) : content
|
|
1650
|
+
}
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
function SortableBodyRow(props) {
|
|
1654
|
+
const { disabled, label, ...rowProps } = props;
|
|
1655
|
+
const sortable = useSortable({ id: props.row.id, disabled });
|
|
1656
|
+
return /* @__PURE__ */ jsx4(
|
|
1657
|
+
RowDragContext.Provider,
|
|
1658
|
+
{
|
|
1659
|
+
value: {
|
|
1660
|
+
attributes: sortable.attributes,
|
|
1661
|
+
listeners: sortable.listeners,
|
|
1662
|
+
setActivatorNodeRef: sortable.setActivatorNodeRef,
|
|
1663
|
+
disabled,
|
|
1664
|
+
label
|
|
1665
|
+
},
|
|
1666
|
+
children: /* @__PURE__ */ jsx4(
|
|
1667
|
+
BodyRow,
|
|
1668
|
+
{
|
|
1669
|
+
...rowProps,
|
|
1670
|
+
sortable: {
|
|
1671
|
+
ref: sortable.setNodeRef,
|
|
1672
|
+
style: { transform: CSS.Translate.toString(sortable.transform), transition: sortable.transition },
|
|
1673
|
+
dragging: sortable.isDragging
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
)
|
|
1677
|
+
}
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
function DndWrapper({
|
|
1681
|
+
enabled,
|
|
1682
|
+
sensors,
|
|
1683
|
+
ids,
|
|
1684
|
+
onDragEnd,
|
|
1685
|
+
children
|
|
1686
|
+
}) {
|
|
1687
|
+
if (!enabled) return /* @__PURE__ */ jsx4(Fragment5, { children });
|
|
1688
|
+
return /* @__PURE__ */ jsx4(DndContext, { sensors, collisionDetection: closestCenter, modifiers: [verticalOnly], onDragEnd, children: /* @__PURE__ */ jsx4(SortableContext, { items: ids, strategy: verticalListSortingStrategy, children }) });
|
|
1689
|
+
}
|
|
1690
|
+
function GroupRow({
|
|
1691
|
+
row,
|
|
1692
|
+
span,
|
|
1693
|
+
group
|
|
1694
|
+
}) {
|
|
1695
|
+
const open = row.getIsExpanded();
|
|
1696
|
+
const count = row.getLeafRows().filter((leaf) => !leaf.getIsGrouped()).length;
|
|
1697
|
+
const summary = group.summary(row);
|
|
1698
|
+
return /* @__PURE__ */ jsx4("tr", { "data-slot": "data-table-group", className: "border-b bg-muted/50", children: /* @__PURE__ */ jsx4("td", { colSpan: span, className: "p-0", children: /* @__PURE__ */ jsxs4(
|
|
1699
|
+
"button",
|
|
1700
|
+
{
|
|
1701
|
+
type: "button",
|
|
1702
|
+
"aria-expanded": open,
|
|
1703
|
+
onClick: row.getToggleExpandedHandler(),
|
|
1704
|
+
className: cn("flex h-10 w-full items-center gap-2 px-2 text-start text-sm font-medium", FOCUS_RING_INSET),
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ jsx4(ChevronRightIcon3, { "aria-hidden": true, className: cn("size-4 shrink-0 transition-transform", open && "rotate-90") }),
|
|
1707
|
+
/* @__PURE__ */ jsx4("span", { className: "min-w-0 truncate", children: group.label(row) }),
|
|
1708
|
+
/* @__PURE__ */ jsxs4(Badge, { variant: "secondary", className: "h-5 rounded-full px-1.5 font-normal tabular-nums", children: [
|
|
1709
|
+
count,
|
|
1710
|
+
/* @__PURE__ */ jsxs4("span", { className: "sr-only", children: [
|
|
1711
|
+
" ",
|
|
1712
|
+
count === 1 ? "row" : "rows"
|
|
1713
|
+
] })
|
|
1714
|
+
] }),
|
|
1715
|
+
summary.length > 0 && /* @__PURE__ */ jsx4("span", { className: "ms-auto flex items-center gap-3 text-xs font-normal text-muted-foreground tabular-nums", children: summary.map((item) => /* @__PURE__ */ jsxs4("span", { children: [
|
|
1716
|
+
item.label && /* @__PURE__ */ jsxs4("span", { children: [
|
|
1717
|
+
item.label,
|
|
1718
|
+
" "
|
|
1719
|
+
] }),
|
|
1720
|
+
/* @__PURE__ */ jsx4("span", { className: "font-medium text-foreground", children: item.text })
|
|
1721
|
+
] }, item.key)) })
|
|
1722
|
+
]
|
|
1723
|
+
}
|
|
1724
|
+
) }) });
|
|
1725
|
+
}
|
|
1726
|
+
function usePinOffsets(key) {
|
|
1727
|
+
const nodes = useRef(/* @__PURE__ */ new Map());
|
|
1728
|
+
const [offsets, setOffsets] = useState({
|
|
1729
|
+
start: {},
|
|
1730
|
+
end: {}
|
|
1731
|
+
});
|
|
1732
|
+
useLayoutEffect(() => {
|
|
1733
|
+
const cells = [...nodes.current.entries()].filter(([, node]) => node.isConnected);
|
|
1734
|
+
cells.sort(([, a], [, b]) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
1735
|
+
const start = {};
|
|
1736
|
+
const end = {};
|
|
1737
|
+
let acc = 0;
|
|
1738
|
+
for (const [id, node] of cells) {
|
|
1739
|
+
start[id] = acc;
|
|
1740
|
+
acc += node.offsetWidth;
|
|
1741
|
+
}
|
|
1742
|
+
acc = 0;
|
|
1743
|
+
for (const [id, node] of [...cells].reverse()) {
|
|
1744
|
+
end[id] = acc;
|
|
1745
|
+
acc += node.offsetWidth;
|
|
711
1746
|
}
|
|
1747
|
+
setOffsets(
|
|
1748
|
+
(current) => JSON.stringify(current) === JSON.stringify({ start, end }) ? current : { start, end }
|
|
1749
|
+
);
|
|
1750
|
+
}, [key]);
|
|
1751
|
+
const register = useCallback(
|
|
1752
|
+
(id) => (node) => {
|
|
1753
|
+
if (node) nodes.current.set(id, node);
|
|
1754
|
+
else nodes.current.delete(id);
|
|
1755
|
+
},
|
|
1756
|
+
[]
|
|
1757
|
+
);
|
|
1758
|
+
const width = (id) => nodes.current.get(id)?.offsetWidth ?? 0;
|
|
1759
|
+
return { ...offsets, register, width };
|
|
1760
|
+
}
|
|
1761
|
+
function ResizeHandle({
|
|
1762
|
+
label,
|
|
1763
|
+
floor,
|
|
1764
|
+
width,
|
|
1765
|
+
onResize
|
|
1766
|
+
}) {
|
|
1767
|
+
const [now, setNow] = useState();
|
|
1768
|
+
const set = (next) => {
|
|
1769
|
+
const clamped = next === void 0 ? void 0 : Math.max(floor, Math.round(next));
|
|
1770
|
+
setNow(clamped);
|
|
1771
|
+
onResize(clamped);
|
|
1772
|
+
};
|
|
1773
|
+
return (
|
|
1774
|
+
// A focusable separator is a widget (ARIA "window splitter"): keyboard and pointer resize it.
|
|
1775
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
1776
|
+
/* @__PURE__ */ jsx4(
|
|
1777
|
+
"div",
|
|
1778
|
+
{
|
|
1779
|
+
role: "separator",
|
|
1780
|
+
"aria-orientation": "vertical",
|
|
1781
|
+
"aria-label": `Resize ${label}`,
|
|
1782
|
+
"aria-valuenow": now ?? width(),
|
|
1783
|
+
"aria-valuemin": floor,
|
|
1784
|
+
tabIndex: 0,
|
|
1785
|
+
onPointerDown: (event) => {
|
|
1786
|
+
event.preventDefault();
|
|
1787
|
+
const startX = event.clientX;
|
|
1788
|
+
const startWidth = width();
|
|
1789
|
+
const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
|
|
1790
|
+
const target = event.currentTarget;
|
|
1791
|
+
target.setPointerCapture?.(event.pointerId);
|
|
1792
|
+
const move = (e) => set(startWidth + (rtl ? startX - e.clientX : e.clientX - startX));
|
|
1793
|
+
const up = () => {
|
|
1794
|
+
target.removeEventListener("pointermove", move);
|
|
1795
|
+
target.removeEventListener("pointerup", up);
|
|
1796
|
+
};
|
|
1797
|
+
target.addEventListener("pointermove", move);
|
|
1798
|
+
target.addEventListener("pointerup", up);
|
|
1799
|
+
},
|
|
1800
|
+
onDoubleClick: () => set(void 0),
|
|
1801
|
+
onKeyDown: (event) => {
|
|
1802
|
+
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
1803
|
+
event.preventDefault();
|
|
1804
|
+
const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
|
|
1805
|
+
const grow = event.key === "ArrowRight" !== rtl;
|
|
1806
|
+
set(width() + (grow ? 16 : -16));
|
|
1807
|
+
} else if (event.key === "Home") {
|
|
1808
|
+
event.preventDefault();
|
|
1809
|
+
set(void 0);
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1812
|
+
className: cn(
|
|
1813
|
+
"absolute inset-y-0 end-0 z-raised w-2 translate-x-1/2 cursor-col-resize touch-none select-none rtl:-translate-x-1/2",
|
|
1814
|
+
"after:absolute after:inset-y-2 after:start-1/2 after:w-px after:bg-border hover:after:bg-ring focus-visible:outline-none focus-visible:after:w-0.5 focus-visible:after:bg-ring"
|
|
1815
|
+
)
|
|
1816
|
+
}
|
|
1817
|
+
)
|
|
712
1818
|
);
|
|
713
1819
|
}
|
|
714
1820
|
function CardScroll({ label, maxHeight, children }) {
|
|
715
1821
|
const scroll = useScrollEdges();
|
|
716
|
-
return /* @__PURE__ */
|
|
1822
|
+
return /* @__PURE__ */ jsx4(
|
|
717
1823
|
"div",
|
|
718
1824
|
{
|
|
719
1825
|
ref: scroll.ref,
|
|
@@ -738,14 +1844,16 @@ function CardList({
|
|
|
738
1844
|
renderRowLink,
|
|
739
1845
|
getRowTone,
|
|
740
1846
|
getRowDimmed,
|
|
741
|
-
getRowLabel
|
|
1847
|
+
getRowLabel,
|
|
1848
|
+
expansion,
|
|
1849
|
+
group
|
|
742
1850
|
}) {
|
|
743
|
-
if (placeholder) return /* @__PURE__ */
|
|
1851
|
+
if (placeholder) return /* @__PURE__ */ jsx4("div", { className: "px-4", children: placeholder });
|
|
744
1852
|
if (loading) {
|
|
745
|
-
return /* @__PURE__ */
|
|
746
|
-
/* @__PURE__ */
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
1853
|
+
return /* @__PURE__ */ jsx4("ul", { "aria-label": label, "aria-labelledby": !label && caption ? captionId : void 0, "aria-busy": "true", className: "divide-y divide-border", children: Array.from({ length: loadingRows }, (_, index) => /* @__PURE__ */ jsxs4("li", { className: "flex flex-col gap-3 p-4", children: [
|
|
1854
|
+
/* @__PURE__ */ jsx4(Skeleton, { className: "h-4 w-2/3" }),
|
|
1855
|
+
/* @__PURE__ */ jsx4(Skeleton, { className: "h-4 w-1/2" }),
|
|
1856
|
+
/* @__PURE__ */ jsx4(Skeleton, { className: "h-4 w-5/6" })
|
|
749
1857
|
] }, index)) });
|
|
750
1858
|
}
|
|
751
1859
|
const columns = table.getVisibleLeafColumns();
|
|
@@ -756,18 +1864,36 @@ function CardList({
|
|
|
756
1864
|
const trigger = clsx(
|
|
757
1865
|
"block w-full min-w-0 text-left focus-visible:outline-none",
|
|
758
1866
|
"after:absolute after:inset-0 after:content-['']",
|
|
759
|
-
"focus-visible:after:ring-
|
|
1867
|
+
"focus-visible:after:ring-[3px] focus-visible:after:ring-inset focus-visible:after:ring-ring/50"
|
|
760
1868
|
);
|
|
761
1869
|
return (
|
|
762
1870
|
// Card mode un-truncates: on touch there is no hover tooltip, so a clipped value would be
|
|
763
1871
|
// unreadable. `.truncate` cell renderers wrap here instead.
|
|
764
|
-
/* @__PURE__ */
|
|
1872
|
+
/* @__PURE__ */ jsx4(
|
|
765
1873
|
"ul",
|
|
766
1874
|
{
|
|
767
1875
|
"aria-label": label,
|
|
768
1876
|
"aria-labelledby": !label && caption ? captionId : void 0,
|
|
769
|
-
className: "divide-y divide-
|
|
1877
|
+
className: "divide-y divide-border [&_.truncate]:whitespace-normal [&_.truncate]:[overflow-wrap:anywhere]",
|
|
770
1878
|
children: table.getRowModel().rows.map((row) => {
|
|
1879
|
+
if (row.getIsGrouped() && group) {
|
|
1880
|
+
const open = row.getIsExpanded();
|
|
1881
|
+
const count = row.getLeafRows().filter((leaf) => !leaf.getIsGrouped()).length;
|
|
1882
|
+
return /* @__PURE__ */ jsx4("li", { "data-slot": "data-table-group", className: "bg-muted/50", children: /* @__PURE__ */ jsxs4(
|
|
1883
|
+
"button",
|
|
1884
|
+
{
|
|
1885
|
+
type: "button",
|
|
1886
|
+
"aria-expanded": open,
|
|
1887
|
+
onClick: row.getToggleExpandedHandler(),
|
|
1888
|
+
className: cn("flex w-full items-center gap-2 px-4 py-2.5 text-start text-sm font-medium", FOCUS_RING_INSET),
|
|
1889
|
+
children: [
|
|
1890
|
+
/* @__PURE__ */ jsx4(ChevronRightIcon3, { "aria-hidden": true, className: cn("size-4 shrink-0 transition-transform", open && "rotate-90") }),
|
|
1891
|
+
/* @__PURE__ */ jsx4("span", { className: "min-w-0 flex-1", children: group.label(row) }),
|
|
1892
|
+
/* @__PURE__ */ jsx4(Badge, { variant: "secondary", className: "h-5 rounded-full px-1.5 font-normal tabular-nums", children: count })
|
|
1893
|
+
]
|
|
1894
|
+
}
|
|
1895
|
+
) }, row.id);
|
|
1896
|
+
}
|
|
771
1897
|
const cells = new Map(row.getVisibleCells().map((cell) => [cell.column.id, cell]));
|
|
772
1898
|
const render = (id) => {
|
|
773
1899
|
const cell = id ? cells.get(id) : void 0;
|
|
@@ -776,7 +1902,7 @@ function CardList({
|
|
|
776
1902
|
const href = getRowHref?.(row.original);
|
|
777
1903
|
const titleContent = render(slots.title?.id);
|
|
778
1904
|
const tone = getRowTone?.(row.original);
|
|
779
|
-
return /* @__PURE__ */
|
|
1905
|
+
return /* @__PURE__ */ jsxs4(
|
|
780
1906
|
"li",
|
|
781
1907
|
{
|
|
782
1908
|
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
@@ -784,16 +1910,16 @@ function CardList({
|
|
|
784
1910
|
"data-dimmed": getRowDimmed?.(row.original) || void 0,
|
|
785
1911
|
className: cn(
|
|
786
1912
|
"relative flex flex-col gap-3 p-4 transition-colors",
|
|
787
|
-
(href || onRowClick) && "hover:bg-
|
|
788
|
-
"data-[tone=muted]:bg-
|
|
789
|
-
"data-[tone=positive]:bg-
|
|
790
|
-
"data-[tone=danger]:bg-
|
|
791
|
-
"data-[state=selected]:bg-
|
|
1913
|
+
(href || onRowClick) && "hover:bg-muted/50",
|
|
1914
|
+
"data-[tone=muted]:bg-muted data-[tone=brand]:bg-accent",
|
|
1915
|
+
"data-[tone=positive]:bg-success/10 data-[tone=warning]:bg-warning/10",
|
|
1916
|
+
"data-[tone=danger]:bg-destructive/10 data-[dimmed]:opacity-60",
|
|
1917
|
+
"data-[state=selected]:bg-accent"
|
|
792
1918
|
),
|
|
793
1919
|
children: [
|
|
794
|
-
/* @__PURE__ */
|
|
795
|
-
selectable && /* @__PURE__ */
|
|
796
|
-
/* @__PURE__ */
|
|
1920
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-start gap-3", children: [
|
|
1921
|
+
selectable && /* @__PURE__ */ jsx4("div", { className: "relative z-raised shrink-0 pt-0.5", children: render(SELECT_COLUMN_ID) }),
|
|
1922
|
+
/* @__PURE__ */ jsx4("div", { className: "min-w-0 flex-1", children: href ? renderRowLink({ href, [ROW_LINK_ATTR]: "", className: trigger, children: titleContent }, row.original) : onRowClick ? /* @__PURE__ */ jsx4(
|
|
797
1923
|
"button",
|
|
798
1924
|
{
|
|
799
1925
|
type: "button",
|
|
@@ -805,13 +1931,31 @@ function CardList({
|
|
|
805
1931
|
) : titleContent }),
|
|
806
1932
|
slots.status && // A status pill is `nowrap`, so a long label would spill off the card. Let it
|
|
807
1933
|
// wrap inside the cap instead.
|
|
808
|
-
/* @__PURE__ */
|
|
809
|
-
slots.actions && /* @__PURE__ */
|
|
1934
|
+
/* @__PURE__ */ jsx4("div", { className: "flex max-w-[45%] shrink-0 justify-end [&_.whitespace-nowrap]:whitespace-normal", children: render(slots.status.id) }),
|
|
1935
|
+
slots.actions && /* @__PURE__ */ jsx4("div", { className: "relative z-raised shrink-0", children: /* @__PURE__ */ jsx4(CellInteractionGuard, { children: render(slots.actions.id) }) })
|
|
810
1936
|
] }),
|
|
811
|
-
slots.fields.length > 0 && /* @__PURE__ */
|
|
812
|
-
/* @__PURE__ */
|
|
813
|
-
/* @__PURE__ */
|
|
814
|
-
] }, id)) })
|
|
1937
|
+
slots.fields.length > 0 && /* @__PURE__ */ jsx4("dl", { className: "grid grid-cols-[repeat(auto-fit,minmax(min(100%,8.5rem),1fr))] gap-x-4 gap-y-2.5", children: slots.fields.map(({ id, column }) => /* @__PURE__ */ jsxs4("div", { className: clsx("min-w-0", column.columnDef.meta?.interactive && "relative z-raised"), children: [
|
|
1938
|
+
/* @__PURE__ */ jsx4("dt", { className: "text-xs text-muted-foreground", children: columnLabel(column) }),
|
|
1939
|
+
/* @__PURE__ */ jsx4("dd", { className: "mt-0.5 min-w-0 text-xs text-foreground", children: column.columnDef.meta?.interactive ? /* @__PURE__ */ jsx4(CellInteractionGuard, { children: render(id) }) : render(id) })
|
|
1940
|
+
] }, id)) }),
|
|
1941
|
+
expansion && /* @__PURE__ */ jsxs4("div", { className: "relative z-raised flex flex-col gap-3", children: [
|
|
1942
|
+
/* @__PURE__ */ jsxs4(
|
|
1943
|
+
Button,
|
|
1944
|
+
{
|
|
1945
|
+
variant: "ghost",
|
|
1946
|
+
size: "xs",
|
|
1947
|
+
className: "-ms-2 self-start",
|
|
1948
|
+
"aria-expanded": expansion.isOpen(row.id),
|
|
1949
|
+
"aria-controls": expansion.isOpen(row.id) ? detailId(row.id) : void 0,
|
|
1950
|
+
onClick: () => expansion.toggle(row.id),
|
|
1951
|
+
children: [
|
|
1952
|
+
/* @__PURE__ */ jsx4(ChevronRightIcon3, { className: cn("transition-transform", expansion.isOpen(row.id) && "rotate-90") }),
|
|
1953
|
+
"Details"
|
|
1954
|
+
]
|
|
1955
|
+
}
|
|
1956
|
+
),
|
|
1957
|
+
expansion.isOpen(row.id) && /* @__PURE__ */ jsx4("div", { id: detailId(row.id), role: "region", "aria-label": `Details for ${expansion.label(row.original)}`, children: expansion.render(row.original) })
|
|
1958
|
+
] })
|
|
815
1959
|
]
|
|
816
1960
|
},
|
|
817
1961
|
row.id
|
|
@@ -826,15 +1970,21 @@ function CardList({
|
|
|
826
1970
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
827
1971
|
export {
|
|
828
1972
|
DataTable,
|
|
1973
|
+
DataTableButtonFilter,
|
|
829
1974
|
DataTableColumnHeader,
|
|
1975
|
+
DataTableFacetedFilter,
|
|
830
1976
|
DataTablePagination,
|
|
1977
|
+
DataTableTabsFilter,
|
|
831
1978
|
DataTableViewOptions,
|
|
1979
|
+
ROW_ACTIONS_COLUMN_ID,
|
|
832
1980
|
SELECT_COLUMN_ID,
|
|
833
1981
|
TableCellBadge,
|
|
834
1982
|
TableCellLeadText,
|
|
835
1983
|
TableCellProgress,
|
|
836
1984
|
TableCellText,
|
|
837
1985
|
createColumnHelper,
|
|
838
|
-
createSelectColumn
|
|
1986
|
+
createSelectColumn,
|
|
1987
|
+
fieldToColumn,
|
|
1988
|
+
isFieldColumn
|
|
839
1989
|
};
|
|
840
1990
|
//# sourceMappingURL=data-table.js.map
|