@humain/ui 2.1.62 → 2.1.65
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/dist/components/organisms/ai/AIToolCall/AIToolCall.d.ts +9 -3
- package/dist/components/organisms/ai/AIToolRun/index.d.ts +1 -1
- package/dist/components/organisms/ai/AIToolRun/validation.d.ts +24 -3
- package/dist/components/organisms/ai/_shared/format-ai-duration.d.ts +1 -0
- package/dist/components/organisms/ai/_shared/workflow-step-renderer.d.ts +1 -0
- package/dist/index.js +52 -52
- package/dist/index151.js +1 -1
- package/dist/index174.js +10 -333
- package/dist/index174.js.map +1 -1
- package/dist/index175.js +310 -137
- package/dist/index175.js.map +1 -1
- package/dist/index176.js +148 -174
- package/dist/index176.js.map +1 -1
- package/dist/index177.js +186 -78
- package/dist/index177.js.map +1 -1
- package/dist/index178.js +74 -124
- package/dist/index178.js.map +1 -1
- package/dist/index179.js +133 -1
- package/dist/index179.js.map +1 -0
- package/dist/index180.js +2 -201
- package/dist/index181.js +201 -0
- package/dist/{index180.js.map → index181.js.map} +1 -1
- package/dist/index183.js +130 -166
- package/dist/index183.js.map +1 -1
- package/dist/index184.js +195 -983
- package/dist/index184.js.map +1 -1
- package/dist/index185.js +1069 -369
- package/dist/index185.js.map +1 -1
- package/dist/index186.js +395 -197
- package/dist/index186.js.map +1 -1
- package/dist/index187.js +198 -243
- package/dist/index187.js.map +1 -1
- package/dist/index188.js +263 -3
- package/dist/index188.js.map +1 -1
- package/dist/index189.js +3 -209
- package/dist/index189.js.map +1 -1
- package/dist/index190.js +190 -777
- package/dist/index190.js.map +1 -1
- package/dist/index191.js +771 -252
- package/dist/index191.js.map +1 -1
- package/dist/index192.js +250 -65
- package/dist/index192.js.map +1 -1
- package/dist/index193.js +72 -523
- package/dist/index193.js.map +1 -1
- package/dist/index194.js +537 -144
- package/dist/index194.js.map +1 -1
- package/dist/index195.js +139 -720
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +707 -167
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +175 -151
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +152 -487
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +472 -225
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +236 -260
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +265 -215
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +207 -307
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +302 -135
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +140 -271
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +263 -253
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +244 -137
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +100 -238
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +278 -74
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +56 -97
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +142 -47
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +38 -84
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +72 -252
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +274 -26
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +29 -94
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +98 -25
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +20 -565
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +564 -17
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +20 -23
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +20 -95
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +92 -88
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +97 -29
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +24 -470
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +446 -196
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +199 -729
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +750 -61
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +58 -181
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +175 -259
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +246 -172
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +195 -32
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +12 -40
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +23 -26
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +45 -22
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +27 -48
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +52 -26
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +40 -225
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +217 -39
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +50 -0
- package/dist/index237.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/wc/AIToolCall.js +218 -0
- package/dist/wc/AIToolCall.js.map +1 -0
- package/dist/wc/hf-ai-tool-call.js +34 -219
- package/dist/wc/hf-ai-tool-call.js.map +1 -1
- package/dist/wc/hf-ai-tool-run.js +673 -576
- package/dist/wc/hf-ai-tool-run.js.map +1 -1
- package/dist/wc/workflow-step-renderer.js +94 -86
- package/dist/wc/workflow-step-renderer.js.map +1 -1
- package/dist/wc-react/AIToolCall.js +218 -0
- package/dist/wc-react/AIToolCall.js.map +1 -0
- package/dist/wc-react/hf-ai-tool-call.js +32 -217
- package/dist/wc-react/hf-ai-tool-call.js.map +1 -1
- package/dist/wc-react/hf-ai-tool-run.js +698 -601
- package/dist/wc-react/hf-ai-tool-run.js.map +1 -1
- package/dist/wc-react/workflow-step-renderer.js +76 -68
- package/dist/wc-react/workflow-step-renderer.js.map +1 -1
- package/package.json +1 -1
- package/skills/humain-ui/SKILL.md +1 -1
- package/skills/humain-ui-wc/SKILL.md +1 -1
- package/skills/humain-ui-wc.skill +0 -0
- package/skills/humain-ui.skill +0 -0
- package/dist/index182.js +0 -143
- package/dist/index182.js.map +0 -1
- package/dist/wc/wrench.js +0 -10
- package/dist/wc/wrench.js.map +0 -1
- package/dist/wc-react/wrench.js +0 -10
- package/dist/wc-react/wrench.js.map +0 -1
package/dist/index191.js
CHANGED
|
@@ -1,280 +1,799 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import { cn } from "./index2.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import { Pagination } from "./index135.js";
|
|
3
|
+
import { Checkbox } from "./index161.js";
|
|
4
|
+
import { Table as TableNamespace, TableBody, TableCell, TableHead, TableHeader, TableRow } from "./index178.js";
|
|
5
|
+
import { Tooltip as TooltipCompound } from "./index188.js";
|
|
6
|
+
import { dataTableTouchTargetClassName } from "./index189.js";
|
|
7
|
+
import { DataTableActionsCell, DataTableAvatarCell, DataTableBadgesCell, DataTableCell, DataTableCellRoot, DataTableProgressCell, DataTableRatingCell, DataTableSparklineCell, DataTableSwitchCell, DataTableTextCell, DataTableTrendCell } from "./index190.js";
|
|
8
|
+
import { cva } from "class-variance-authority";
|
|
9
|
+
import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown, CircleHelp } from "lucide-react";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { flexRender, getCoreRowModel, getExpandedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
13
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
14
|
+
//#region src/components/organisms/content/DataTable/DataTable.tsx
|
|
15
|
+
var responsiveColumnBreakpointClasses = {
|
|
16
|
+
sm: "@sm:table-cell",
|
|
17
|
+
md: "@md:table-cell",
|
|
18
|
+
lg: "@lg:table-cell"
|
|
19
|
+
};
|
|
20
|
+
var responsiveColumnVisibilitySlots = [
|
|
21
|
+
"base",
|
|
22
|
+
"sm",
|
|
23
|
+
"md",
|
|
24
|
+
"lg"
|
|
25
|
+
];
|
|
26
|
+
var responsiveColumnVisibilityRanks = {
|
|
27
|
+
base: 0,
|
|
28
|
+
sm: 1,
|
|
29
|
+
md: 2,
|
|
30
|
+
lg: 3
|
|
31
|
+
};
|
|
32
|
+
var dataTableVariants = cva("w-full", {
|
|
33
|
+
variants: {
|
|
34
|
+
/** Visual style for row separation */
|
|
35
|
+
dividers: {
|
|
36
|
+
/** Border line between rows */
|
|
37
|
+
line: "",
|
|
38
|
+
/** Alternating row background fills */
|
|
39
|
+
alternating: ""
|
|
40
|
+
},
|
|
41
|
+
/** Table density */
|
|
42
|
+
density: {
|
|
43
|
+
default: "",
|
|
44
|
+
compact: ""
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
dividers: "line",
|
|
49
|
+
density: "default"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var dataTableContainerVariants = cva("bg-card", {
|
|
53
|
+
variants: {
|
|
54
|
+
/** Border radius configuration */
|
|
55
|
+
rounded: {
|
|
56
|
+
/** Rounded on all corners (default) */
|
|
57
|
+
all: "rounded-xl",
|
|
58
|
+
/** No rounding on any corner */
|
|
59
|
+
none: "rounded-none",
|
|
60
|
+
/** Only top corners rounded */
|
|
61
|
+
top: "rounded-t-xl rounded-b-none",
|
|
62
|
+
/** Only bottom corners rounded (for embedding in cards with headers) */
|
|
63
|
+
bottom: "rounded-t-none rounded-b-xl"
|
|
64
|
+
},
|
|
65
|
+
/** Whether to show the outer border */
|
|
66
|
+
bordered: {
|
|
67
|
+
true: "border border-border shadow-xs",
|
|
68
|
+
false: ""
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
rounded: "all",
|
|
73
|
+
bordered: true
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
var dataTableRowVariants = cva("transition-colors duration-150 ease-out motion-reduce:transition-none", {
|
|
77
|
+
variants: {
|
|
78
|
+
dividers: {
|
|
79
|
+
line: "border-b border-border-subtle",
|
|
80
|
+
alternating: "border-0"
|
|
81
|
+
},
|
|
82
|
+
density: {
|
|
83
|
+
default: "",
|
|
84
|
+
compact: ""
|
|
85
|
+
},
|
|
86
|
+
isEven: {
|
|
87
|
+
true: "",
|
|
88
|
+
false: ""
|
|
89
|
+
},
|
|
90
|
+
isSelected: {
|
|
91
|
+
true: "bg-muted dark:bg-accent shadow-[inset_3px_0_0_0_var(--color-primary)] rtl:shadow-[inset_-3px_0_0_0_var(--color-primary)]",
|
|
92
|
+
false: ""
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
compoundVariants: [{
|
|
96
|
+
dividers: "alternating",
|
|
97
|
+
isEven: true,
|
|
98
|
+
isSelected: false,
|
|
99
|
+
className: "bg-muted"
|
|
100
|
+
}, {
|
|
101
|
+
dividers: "alternating",
|
|
102
|
+
isEven: false,
|
|
103
|
+
isSelected: false,
|
|
104
|
+
className: "bg-background dark:bg-card"
|
|
105
|
+
}],
|
|
106
|
+
defaultVariants: {
|
|
107
|
+
dividers: "line",
|
|
108
|
+
density: "default",
|
|
109
|
+
isEven: false,
|
|
110
|
+
isSelected: false
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
var dataTableCellVariants = cva("align-middle", {
|
|
114
|
+
variants: { density: {
|
|
115
|
+
default: "h-[72px] ps-4 pe-4 py-3 @md:ps-6 @md:pe-6 @md:py-3",
|
|
116
|
+
compact: "h-14 ps-4 pe-4 py-2"
|
|
117
|
+
} },
|
|
118
|
+
defaultVariants: { density: "default" }
|
|
119
|
+
});
|
|
120
|
+
var dataTableHeaderCellVariants = cva("text-sm font-medium text-muted-foreground", {
|
|
121
|
+
variants: { density: {
|
|
122
|
+
default: "h-11 ps-6 pe-6 py-3",
|
|
123
|
+
compact: "h-11 ps-4 pe-4 py-2"
|
|
124
|
+
} },
|
|
125
|
+
defaultVariants: { density: "default" }
|
|
126
|
+
});
|
|
127
|
+
function getStickyCellClass({ stickyFirstColumn, stickyLastColumn, isFirstColumn, isLastColumn, isSelected }) {
|
|
128
|
+
if (!(stickyFirstColumn && isFirstColumn || stickyLastColumn && isLastColumn)) return;
|
|
129
|
+
return cn("sticky z-20", stickyFirstColumn && isFirstColumn && "start-0", stickyLastColumn && isLastColumn && "end-0", isSelected ? "bg-muted dark:bg-accent" : "bg-background dark:bg-card");
|
|
13
130
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
131
|
+
function getResponsiveColumnPriority(priority) {
|
|
132
|
+
switch (priority) {
|
|
133
|
+
case "always":
|
|
134
|
+
case "desktop":
|
|
135
|
+
case "mobile": return priority;
|
|
136
|
+
default: return;
|
|
137
|
+
}
|
|
20
138
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
139
|
+
function getResponsiveColumnHideBelow(hideBelow) {
|
|
140
|
+
switch (hideBelow) {
|
|
141
|
+
case "sm":
|
|
142
|
+
case "md":
|
|
143
|
+
case "lg": return hideBelow;
|
|
144
|
+
default: return;
|
|
145
|
+
}
|
|
27
146
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
147
|
+
function isColumnVisibleInResponsiveSlot(responsive, enabled, slot) {
|
|
148
|
+
if (!enabled || !responsive) return true;
|
|
149
|
+
const priority = getResponsiveColumnPriority(responsive.priority);
|
|
150
|
+
if (priority === "always") return true;
|
|
151
|
+
if (priority === "mobile") return slot === "base" || slot === "sm";
|
|
152
|
+
const hideBelow = getResponsiveColumnHideBelow(responsive.hideBelow) ?? "md";
|
|
153
|
+
return responsiveColumnVisibilityRanks[slot] >= responsiveColumnVisibilityRanks[hideBelow];
|
|
34
154
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
"data-slot": "dropdown-menu-sub",
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
155
|
+
function withResponsiveSlotVariant(slot, className) {
|
|
156
|
+
if (slot === "base") return className;
|
|
157
|
+
return className.split(" ").map((token) => `@${slot}:${token}`).join(" ");
|
|
41
158
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
159
|
+
function getResponsiveStickyStateClass({ backgroundClass, side, slots, zIndexClass }) {
|
|
160
|
+
if (!slots.length) return;
|
|
161
|
+
const stickySlots = new Set(slots);
|
|
162
|
+
const classes = [];
|
|
163
|
+
let wasSticky = false;
|
|
164
|
+
for (const slot of responsiveColumnVisibilitySlots) {
|
|
165
|
+
const isSticky = stickySlots.has(slot);
|
|
166
|
+
if (isSticky && !wasSticky) classes.push(withResponsiveSlotVariant(slot, cn("sticky", zIndexClass, `${side}-0`, backgroundClass)));
|
|
167
|
+
else if (!isSticky && wasSticky) classes.push(withResponsiveSlotVariant(slot, "static z-auto start-auto end-auto"));
|
|
168
|
+
wasSticky = isSticky;
|
|
169
|
+
}
|
|
170
|
+
return cn(classes);
|
|
51
171
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
172
|
+
function addResponsiveStickySlot(slotMap, item, getId, slot, slotKey) {
|
|
173
|
+
if (!item) return;
|
|
174
|
+
const itemId = getId(item);
|
|
175
|
+
const itemSlots = slotMap.get(itemId) ?? {
|
|
176
|
+
firstSlots: [],
|
|
177
|
+
lastSlots: []
|
|
178
|
+
};
|
|
179
|
+
itemSlots[slotKey].push(slot);
|
|
180
|
+
slotMap.set(itemId, itemSlots);
|
|
58
181
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
children: /* @__PURE__ */ jsx(Menu$1.RadioItemIndicator, {
|
|
69
|
-
className: "animate-in zoom-in-75 duration-150 motion-reduce:animate-none",
|
|
70
|
-
children: /* @__PURE__ */ jsx(Check, {})
|
|
71
|
-
})
|
|
72
|
-
}), children]
|
|
73
|
-
});
|
|
182
|
+
function getResponsiveStickySlotsById({ enabled, getId, getResponsive, items, stickyFirstColumn, stickyLastColumn }) {
|
|
183
|
+
const slotMap = /* @__PURE__ */ new Map();
|
|
184
|
+
if (!enabled || !(stickyFirstColumn || stickyLastColumn)) return slotMap;
|
|
185
|
+
for (const slot of responsiveColumnVisibilitySlots) {
|
|
186
|
+
const visibleItems = items.filter((item) => isColumnVisibleInResponsiveSlot(getResponsive(item), enabled, slot));
|
|
187
|
+
if (stickyFirstColumn) addResponsiveStickySlot(slotMap, visibleItems[0], getId, slot, "firstSlots");
|
|
188
|
+
if (stickyLastColumn) addResponsiveStickySlot(slotMap, visibleItems.at(-1), getId, slot, "lastSlots");
|
|
189
|
+
}
|
|
190
|
+
return slotMap;
|
|
74
191
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
children: /* @__PURE__ */ jsx(Check, {})
|
|
88
|
-
})
|
|
89
|
-
}), children]
|
|
90
|
-
});
|
|
192
|
+
function getResponsiveStickyClass({ backgroundClass, firstSlots, lastSlots, zIndexClass = "z-20" }) {
|
|
193
|
+
return cn(getResponsiveStickyStateClass({
|
|
194
|
+
backgroundClass,
|
|
195
|
+
side: "start",
|
|
196
|
+
slots: firstSlots,
|
|
197
|
+
zIndexClass
|
|
198
|
+
}), getResponsiveStickyStateClass({
|
|
199
|
+
backgroundClass,
|
|
200
|
+
side: "end",
|
|
201
|
+
slots: lastSlots,
|
|
202
|
+
zIndexClass
|
|
203
|
+
}));
|
|
91
204
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return
|
|
95
|
-
"data-slot": "dropdown-menu-shortcut",
|
|
96
|
-
className: cn("text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ms-auto text-xs tracking-widest", className),
|
|
97
|
-
...props
|
|
98
|
-
});
|
|
205
|
+
function getHeaderCellWidth(size) {
|
|
206
|
+
if (size === 150) return;
|
|
207
|
+
return size;
|
|
99
208
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
sm: "w-48",
|
|
104
|
-
md: "w-56",
|
|
105
|
-
lg: "w-64"
|
|
106
|
-
};
|
|
107
|
-
function DropdownMenuPopup({ align = "start", alignOffset = 0, side = "bottom", sideOffset = 4, width = "auto", className, ...props }) {
|
|
108
|
-
return /* @__PURE__ */ jsx(Menu$1.Portal, { children: /* @__PURE__ */ jsx(Menu$1.Positioner, {
|
|
109
|
-
className: "isolate z-50 outline-none",
|
|
110
|
-
align,
|
|
111
|
-
alignOffset,
|
|
112
|
-
side,
|
|
113
|
-
sideOffset,
|
|
114
|
-
children: /* @__PURE__ */ jsx(Menu$1.Popup, {
|
|
115
|
-
"data-slot": "dropdown-menu-popup",
|
|
116
|
-
className: cn("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", "border border-border bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-sm z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", "duration-200 motion-reduce:animate-none", popupWidthClasses[width], className),
|
|
117
|
-
...props
|
|
118
|
-
})
|
|
119
|
-
}) });
|
|
209
|
+
function getAriaSort(sortState) {
|
|
210
|
+
if (sortState === "asc") return "ascending";
|
|
211
|
+
if (sortState === "desc") return "descending";
|
|
120
212
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
213
|
+
function getResponsiveColumnClass(responsive, enabled) {
|
|
214
|
+
if (!enabled || !responsive) return;
|
|
215
|
+
const priority = getResponsiveColumnPriority(responsive.priority);
|
|
216
|
+
if (priority === "always") return;
|
|
217
|
+
if (priority === "mobile") return "@md:hidden";
|
|
218
|
+
return `hidden ${responsiveColumnBreakpointClasses[getResponsiveColumnHideBelow(responsive.hideBelow) ?? "md"]}`;
|
|
219
|
+
}
|
|
220
|
+
function getVirtualRowStyle(start, headerOffset) {
|
|
221
|
+
return {
|
|
222
|
+
display: "table",
|
|
223
|
+
position: "absolute",
|
|
224
|
+
top: 0,
|
|
225
|
+
insetInlineStart: 0,
|
|
226
|
+
width: "100%",
|
|
227
|
+
transform: `translateY(${start + headerOffset}px)`
|
|
228
|
+
};
|
|
132
229
|
}
|
|
133
|
-
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
230
|
+
var selectionCheckboxClassName = "translate-y-[2px] before:-inset-[14px] before:rounded-md";
|
|
231
|
+
function createSelectColumn() {
|
|
232
|
+
return {
|
|
233
|
+
id: "select",
|
|
234
|
+
header: ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
235
|
+
checked: table.getIsAllPageRowsSelected(),
|
|
236
|
+
indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(),
|
|
237
|
+
onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value),
|
|
238
|
+
"aria-label": "Select all",
|
|
239
|
+
className: selectionCheckboxClassName
|
|
240
|
+
}),
|
|
241
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
242
|
+
checked: row.getIsSelected(),
|
|
243
|
+
onCheckedChange: (value) => row.toggleSelected(!!value),
|
|
244
|
+
"aria-label": "Select row",
|
|
245
|
+
className: selectionCheckboxClassName
|
|
246
|
+
}),
|
|
247
|
+
enableSorting: false,
|
|
248
|
+
enableHiding: false,
|
|
249
|
+
size: 64,
|
|
250
|
+
meta: {
|
|
251
|
+
headerClassName: "w-16 min-w-16",
|
|
252
|
+
cellClassName: "w-16 min-w-16"
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function HeaderTooltip({ content }) {
|
|
257
|
+
if (!content) return null;
|
|
258
|
+
return /* @__PURE__ */ jsx(TooltipCompound, {
|
|
259
|
+
trigger: /* @__PURE__ */ jsx("button", {
|
|
260
|
+
type: "button",
|
|
261
|
+
className: cn(dataTableTouchTargetClassName, "rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"),
|
|
262
|
+
"aria-label": "Column information",
|
|
263
|
+
children: /* @__PURE__ */ jsx(CircleHelp, { className: "size-3.5 shrink-0" })
|
|
264
|
+
}),
|
|
265
|
+
content
|
|
140
266
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
267
|
+
}
|
|
268
|
+
function SortableHeader({ children, column, className }) {
|
|
269
|
+
const sorted = column.getIsSorted();
|
|
270
|
+
const canSort = column.getCanSort();
|
|
271
|
+
const tooltipContent = column.columnDef?.meta?.headerTooltip;
|
|
272
|
+
if (!canSort) {
|
|
273
|
+
if (!tooltipContent) return /* @__PURE__ */ jsx("span", {
|
|
274
|
+
className,
|
|
275
|
+
children
|
|
276
|
+
});
|
|
277
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
278
|
+
className: cn("inline-flex items-center gap-1", className),
|
|
279
|
+
children: [/* @__PURE__ */ jsx("span", { children }), /* @__PURE__ */ jsx(HeaderTooltip, { content: tooltipContent })]
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
283
|
+
className: cn("inline-flex items-center gap-1", className),
|
|
284
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
285
|
+
type: "button",
|
|
286
|
+
onClick: () => column.toggleSorting(sorted === "asc"),
|
|
287
|
+
className: cn(dataTableTouchTargetClassName, "flex items-center gap-1 text-start hover:text-foreground transition-colors duration-150 ease-out motion-reduce:transition-none -ms-1 ps-1 -me-1 pe-1 -my-0.5 py-0.5 rounded focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none active:scale-[0.97] motion-reduce:active:scale-100"),
|
|
288
|
+
children: [children, /* @__PURE__ */ jsxs("span", {
|
|
289
|
+
className: "relative size-4",
|
|
290
|
+
children: [
|
|
291
|
+
/* @__PURE__ */ jsx(ArrowUp, { className: cn("absolute inset-0 size-4 text-text-quaternary transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none", sorted === "asc" ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-1") }),
|
|
292
|
+
/* @__PURE__ */ jsx(ArrowDown, { className: cn("absolute inset-0 size-4 text-text-quaternary transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none", sorted === "desc" ? "opacity-100 translate-y-0" : "opacity-0 translate-y-1") }),
|
|
293
|
+
/* @__PURE__ */ jsx(ChevronsUpDown, { className: cn("absolute inset-0 size-4 transition-opacity duration-200 ease-out motion-reduce:transition-none", sorted ? "opacity-0" : "opacity-100 text-muted-foreground") })
|
|
294
|
+
]
|
|
156
295
|
})]
|
|
157
|
-
})
|
|
296
|
+
}), /* @__PURE__ */ jsx(HeaderTooltip, { content: tooltipContent })]
|
|
158
297
|
});
|
|
159
298
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
* Enhanced DropdownMenuLabel
|
|
163
|
-
*/
|
|
164
|
-
function DropdownMenuLabel({ className, inset, ...props }) {
|
|
165
|
-
return /* @__PURE__ */ jsx(Menu$1.GroupLabel, {
|
|
166
|
-
"data-slot": "dropdown-menu-label",
|
|
167
|
-
"data-inset": inset,
|
|
168
|
-
className: cn("px-4 py-2 text-xs font-medium text-text-quaternary uppercase tracking-wider", "data-[inset]:ps-8", className),
|
|
169
|
-
...props
|
|
170
|
-
});
|
|
299
|
+
function DataTableGroupHeader({ row, visibleColumnCount, customHeader }) {
|
|
300
|
+
return /* @__PURE__ */ jsx(Fragment, { children: customHeader(row, visibleColumnCount) });
|
|
171
301
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const isDestructive = destructive || variant === "destructive";
|
|
175
|
-
return /* @__PURE__ */ jsxs(Menu$1.Item, {
|
|
176
|
-
"data-slot": "dropdown-menu-item",
|
|
177
|
-
"data-inset": inset,
|
|
178
|
-
"data-variant": isDestructive ? "destructive" : variant,
|
|
179
|
-
className: cn("group/dropdown-menu-item relative flex items-center gap-2 mx-1.5 px-2.5 py-2 rounded-md cursor-pointer outline-none", "text-sm font-semibold text-secondary-foreground", "focus:bg-muted focus:text-secondary-foreground", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "data-[inset]:ps-8", "[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", "transition-[color,background-color,transform] duration-150 active:scale-[0.99]", isDestructive && "text-destructive focus:text-destructive focus:bg-destructive/10", className),
|
|
180
|
-
render,
|
|
181
|
-
...props,
|
|
182
|
-
children: [
|
|
183
|
-
icon && /* @__PURE__ */ jsx("span", {
|
|
184
|
-
className: cn("size-4 shrink-0 transition-colors duration-150", isDestructive ? "text-destructive" : "text-text-quaternary group-focus/dropdown-menu-item:text-secondary-foreground"),
|
|
185
|
-
children: icon
|
|
186
|
-
}),
|
|
187
|
-
/* @__PURE__ */ jsx("span", {
|
|
188
|
-
className: "flex-1",
|
|
189
|
-
children
|
|
190
|
-
}),
|
|
191
|
-
shortcut && /* @__PURE__ */ jsx(DropdownMenuShortcutBadge, {
|
|
192
|
-
className: "transition-colors duration-150 group-focus/dropdown-menu-item:bg-primary/10 group-focus/dropdown-menu-item:text-primary",
|
|
193
|
-
children: shortcut
|
|
194
|
-
})
|
|
195
|
-
]
|
|
196
|
-
});
|
|
302
|
+
function DataTableControls({ table, customControls }) {
|
|
303
|
+
return /* @__PURE__ */ jsx(Fragment, { children: customControls(table) });
|
|
197
304
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
305
|
+
function useDataTable({ columns, data, enableRowSelection = false, enableMultiRowSelection = true, rowSelection: controlledRowSelection, onRowSelectionChange, initialRowSelection = {}, showSelectAll = true, enableSorting = true, sortingMode = "client", sorting: controlledSorting, onSortingChange, initialSorting = [], enablePagination = false, paginationMode = "client", pagination: controlledPagination, onPaginationChange, pageCount: controlledPageCount, rowCount, pageSize = 10, initialPageIndex = 0, enableColumnFilters = false, filteringMode = "client", columnFilters: controlledColumnFilters, onColumnFiltersChange, initialColumnFilters = [], enableColumnVisibility = false, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, initialColumnVisibility = {}, enableGrouping = false, groupingMode = "client", grouping: controlledGrouping, onGroupingChange, initialGrouping = [], groupedColumnMode = false, expanded: controlledExpanded, onExpandedChange, initialExpanded = {}, getRowId, getSubRows }) {
|
|
306
|
+
const defaultPaginationState = React.useMemo(() => ({
|
|
307
|
+
pageIndex: initialPageIndex,
|
|
308
|
+
pageSize
|
|
309
|
+
}), [initialPageIndex, pageSize]);
|
|
310
|
+
const [internalRowSelection, setInternalRowSelection] = React.useState(initialRowSelection);
|
|
311
|
+
const [internalSorting, setInternalSorting] = React.useState(initialSorting);
|
|
312
|
+
const [internalColumnFilters, setInternalColumnFilters] = React.useState(initialColumnFilters);
|
|
313
|
+
const [internalColumnVisibility, setInternalColumnVisibility] = React.useState(initialColumnVisibility);
|
|
314
|
+
const [internalPagination, setInternalPagination] = React.useState(defaultPaginationState);
|
|
315
|
+
const [internalGrouping, setInternalGrouping] = React.useState(initialGrouping);
|
|
316
|
+
const [internalExpanded, setInternalExpanded] = React.useState(initialExpanded);
|
|
317
|
+
const rowSelection = controlledRowSelection ?? internalRowSelection;
|
|
318
|
+
const sorting = controlledSorting ?? internalSorting;
|
|
319
|
+
const columnFilters = controlledColumnFilters ?? internalColumnFilters;
|
|
320
|
+
const columnVisibility = controlledColumnVisibility ?? internalColumnVisibility;
|
|
321
|
+
const pagination = controlledPagination ?? internalPagination;
|
|
322
|
+
const grouping = controlledGrouping ?? internalGrouping;
|
|
323
|
+
const expanded = controlledExpanded ?? internalExpanded;
|
|
324
|
+
const handleRowSelectionChange = React.useCallback((updater) => {
|
|
325
|
+
if (controlledRowSelection === void 0) setInternalRowSelection(updater);
|
|
326
|
+
onRowSelectionChange?.(updater);
|
|
327
|
+
}, [controlledRowSelection, onRowSelectionChange]);
|
|
328
|
+
const handleSortingChange = React.useCallback((updater) => {
|
|
329
|
+
if (controlledSorting === void 0) setInternalSorting(updater);
|
|
330
|
+
onSortingChange?.(updater);
|
|
331
|
+
}, [controlledSorting, onSortingChange]);
|
|
332
|
+
const handleColumnFiltersChange = React.useCallback((updater) => {
|
|
333
|
+
if (controlledColumnFilters === void 0) setInternalColumnFilters(updater);
|
|
334
|
+
onColumnFiltersChange?.(updater);
|
|
335
|
+
}, [controlledColumnFilters, onColumnFiltersChange]);
|
|
336
|
+
const handleColumnVisibilityChange = React.useCallback((updater) => {
|
|
337
|
+
if (controlledColumnVisibility === void 0) setInternalColumnVisibility(updater);
|
|
338
|
+
onColumnVisibilityChange?.(updater);
|
|
339
|
+
}, [controlledColumnVisibility, onColumnVisibilityChange]);
|
|
340
|
+
const handlePaginationChange = React.useCallback((updater) => {
|
|
341
|
+
if (controlledPagination === void 0) setInternalPagination(updater);
|
|
342
|
+
onPaginationChange?.(updater);
|
|
343
|
+
}, [controlledPagination, onPaginationChange]);
|
|
344
|
+
const handleGroupingChange = React.useCallback((updater) => {
|
|
345
|
+
if (controlledGrouping === void 0) setInternalGrouping(updater);
|
|
346
|
+
onGroupingChange?.(updater);
|
|
347
|
+
}, [controlledGrouping, onGroupingChange]);
|
|
348
|
+
const handleExpandedChange = React.useCallback((updater) => {
|
|
349
|
+
if (controlledExpanded === void 0) setInternalExpanded(updater);
|
|
350
|
+
onExpandedChange?.(updater);
|
|
351
|
+
}, [controlledExpanded, onExpandedChange]);
|
|
352
|
+
const tableColumns = React.useMemo(() => {
|
|
353
|
+
if (enableRowSelection && showSelectAll) return [createSelectColumn(), ...columns];
|
|
354
|
+
return columns;
|
|
355
|
+
}, [
|
|
356
|
+
columns,
|
|
357
|
+
enableRowSelection,
|
|
358
|
+
showSelectAll
|
|
359
|
+
]);
|
|
360
|
+
const manualPagination = paginationMode === "server";
|
|
361
|
+
const manualSorting = sortingMode === "server";
|
|
362
|
+
const manualFiltering = filteringMode === "server";
|
|
363
|
+
const manualGrouping = groupingMode === "server";
|
|
364
|
+
const pageCount = React.useMemo(() => {
|
|
365
|
+
if (controlledPageCount !== void 0) return controlledPageCount;
|
|
366
|
+
if (rowCount !== void 0 && pagination.pageSize > 0) return Math.ceil(rowCount / pagination.pageSize);
|
|
367
|
+
}, [
|
|
368
|
+
controlledPageCount,
|
|
369
|
+
rowCount,
|
|
370
|
+
pagination.pageSize
|
|
371
|
+
]);
|
|
372
|
+
const table = useReactTable({
|
|
373
|
+
data,
|
|
374
|
+
columns: tableColumns,
|
|
375
|
+
state: {
|
|
376
|
+
rowSelection,
|
|
377
|
+
sorting,
|
|
378
|
+
columnFilters,
|
|
379
|
+
columnVisibility,
|
|
380
|
+
pagination,
|
|
381
|
+
grouping,
|
|
382
|
+
expanded
|
|
383
|
+
},
|
|
384
|
+
enableRowSelection,
|
|
385
|
+
enableMultiRowSelection,
|
|
386
|
+
onRowSelectionChange: handleRowSelectionChange,
|
|
387
|
+
enableSorting,
|
|
388
|
+
manualSorting,
|
|
389
|
+
onSortingChange: handleSortingChange,
|
|
390
|
+
manualPagination,
|
|
391
|
+
pageCount,
|
|
392
|
+
onPaginationChange: handlePaginationChange,
|
|
393
|
+
enableColumnFilters,
|
|
394
|
+
manualFiltering,
|
|
395
|
+
onColumnFiltersChange: handleColumnFiltersChange,
|
|
396
|
+
enableHiding: enableColumnVisibility,
|
|
397
|
+
onColumnVisibilityChange: handleColumnVisibilityChange,
|
|
398
|
+
enableGrouping,
|
|
399
|
+
manualGrouping,
|
|
400
|
+
groupedColumnMode: groupedColumnMode || void 0,
|
|
401
|
+
onGroupingChange: handleGroupingChange,
|
|
402
|
+
onExpandedChange: handleExpandedChange,
|
|
403
|
+
paginateExpandedRows: false,
|
|
404
|
+
getSubRows: groupingMode === "server" ? getSubRows : void 0,
|
|
405
|
+
getCoreRowModel: getCoreRowModel(),
|
|
406
|
+
getSortedRowModel: enableSorting && sortingMode === "client" ? getSortedRowModel() : void 0,
|
|
407
|
+
getFilteredRowModel: enableColumnFilters && filteringMode === "client" ? getFilteredRowModel() : void 0,
|
|
408
|
+
getPaginationRowModel: enablePagination && paginationMode === "client" ? getPaginationRowModel() : void 0,
|
|
409
|
+
getGroupedRowModel: enableGrouping && groupingMode === "client" ? getGroupedRowModel() : void 0,
|
|
410
|
+
getExpandedRowModel: enableGrouping ? getExpandedRowModel() : void 0,
|
|
411
|
+
getRowId
|
|
207
412
|
});
|
|
413
|
+
return {
|
|
414
|
+
table,
|
|
415
|
+
totalPages: table.getPageCount(),
|
|
416
|
+
currentPage: pagination.pageIndex + 1,
|
|
417
|
+
showPagination: enablePagination && paginationMode !== "none" && table.getPageCount() > 1
|
|
418
|
+
};
|
|
208
419
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
420
|
+
function DataTable({ columns, data, children, enableRowSelection = false, enableMultiRowSelection = true, rowSelection: controlledRowSelection, onRowSelectionChange, initialRowSelection = {}, enableSorting = true, sortingMode = "client", sorting: controlledSorting, onSortingChange, initialSorting = [], enablePagination = false, paginationMode = "client", pagination: controlledPagination, onPaginationChange, pageCount: controlledPageCount, rowCount, pageSize = 10, initialPageIndex = 0, enableColumnFilters = false, filteringMode = "client", columnFilters: controlledColumnFilters, onColumnFiltersChange, initialColumnFilters = [], enableColumnVisibility = false, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, initialColumnVisibility = {}, enableGrouping = false, groupingMode = "client", grouping: controlledGrouping, onGroupingChange, initialGrouping = [], groupedColumnMode = false, expanded: controlledExpanded, onExpandedChange, initialExpanded = {}, getSubRows, paginationType = "page-default", paginationShape = "square", paginationSize = "md", paginationShowPageNumbers = true, paginationLabel, getRowId, onRowClick, emptyState, className, caption, dividers = "line", density = "default", showSelectAll = true, responsiveColumns = false, renderControls, classNames, renderBody, renderRow, renderGroupHeader, maxHeight, stickyHeader = false, stickyFirstColumn = false, stickyLastColumn = false, loading: isLoading = false, loadingState, error, errorState, i18n, virtualization, showSelectionCount = false, rounded = "all", bordered = true }) {
|
|
421
|
+
const { table, totalPages, currentPage, showPagination } = useDataTable({
|
|
422
|
+
columns,
|
|
423
|
+
data,
|
|
424
|
+
enableRowSelection,
|
|
425
|
+
enableMultiRowSelection,
|
|
426
|
+
rowSelection: controlledRowSelection,
|
|
427
|
+
onRowSelectionChange,
|
|
428
|
+
initialRowSelection,
|
|
429
|
+
showSelectAll,
|
|
430
|
+
enableSorting,
|
|
431
|
+
sortingMode,
|
|
432
|
+
sorting: controlledSorting,
|
|
433
|
+
onSortingChange,
|
|
434
|
+
initialSorting,
|
|
435
|
+
enablePagination,
|
|
436
|
+
paginationMode,
|
|
437
|
+
pagination: controlledPagination,
|
|
438
|
+
onPaginationChange,
|
|
439
|
+
pageCount: controlledPageCount,
|
|
440
|
+
rowCount,
|
|
441
|
+
pageSize,
|
|
442
|
+
initialPageIndex,
|
|
443
|
+
enableColumnFilters,
|
|
444
|
+
filteringMode,
|
|
445
|
+
columnFilters: controlledColumnFilters,
|
|
446
|
+
onColumnFiltersChange,
|
|
447
|
+
initialColumnFilters,
|
|
448
|
+
enableColumnVisibility,
|
|
449
|
+
columnVisibility: controlledColumnVisibility,
|
|
450
|
+
onColumnVisibilityChange,
|
|
451
|
+
initialColumnVisibility,
|
|
452
|
+
enableGrouping,
|
|
453
|
+
groupingMode,
|
|
454
|
+
grouping: controlledGrouping,
|
|
455
|
+
onGroupingChange,
|
|
456
|
+
initialGrouping,
|
|
457
|
+
groupedColumnMode,
|
|
458
|
+
expanded: controlledExpanded,
|
|
459
|
+
onExpandedChange,
|
|
460
|
+
initialExpanded,
|
|
461
|
+
getSubRows,
|
|
462
|
+
getRowId
|
|
219
463
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
464
|
+
const tableContainerRef = React.useRef(null);
|
|
465
|
+
const rows = table.getRowModel().rows;
|
|
466
|
+
const isVirtualizationEnabled = virtualization?.enabled ?? false;
|
|
467
|
+
const headerOffset = stickyHeader && isVirtualizationEnabled ? 40 : 0;
|
|
468
|
+
const isGroupRow = React.useCallback((row) => {
|
|
469
|
+
if (row.getIsGrouped()) return true;
|
|
470
|
+
if (groupingMode === "server" && row.subRows.length > 0) return true;
|
|
471
|
+
return false;
|
|
472
|
+
}, [groupingMode]);
|
|
473
|
+
const rowVirtualizer = useVirtualizer({
|
|
474
|
+
enabled: isVirtualizationEnabled,
|
|
475
|
+
count: isVirtualizationEnabled ? rows.length : 0,
|
|
476
|
+
getScrollElement: () => tableContainerRef.current,
|
|
477
|
+
estimateSize: (index) => {
|
|
478
|
+
const row = rows[index];
|
|
479
|
+
if (row && isGroupRow(row)) return virtualization?.estimatedGroupHeaderHeight ?? 48;
|
|
480
|
+
return virtualization?.estimatedRowHeight ?? 50;
|
|
481
|
+
},
|
|
482
|
+
overscan: virtualization?.overscan ?? 5
|
|
232
483
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
484
|
+
const handleRowKeyDown = React.useCallback((row, e) => {
|
|
485
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
486
|
+
e.preventDefault();
|
|
487
|
+
onRowClick?.(row);
|
|
488
|
+
}
|
|
489
|
+
}, [onRowClick]);
|
|
490
|
+
const renderCellContent = React.useCallback((cell, row) => {
|
|
491
|
+
const isGroupedCell = cell.getIsGrouped();
|
|
492
|
+
const isAggregatedCell = cell.getIsAggregated();
|
|
493
|
+
const isPlaceholderCell = cell.getIsPlaceholder();
|
|
494
|
+
if (isGroupedCell) {
|
|
495
|
+
const actionLabel = row.getIsExpanded() ? "Collapse" : "Expand";
|
|
496
|
+
const groupLabel = String(cell.getValue() ?? "");
|
|
497
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
498
|
+
type: "button",
|
|
499
|
+
onClick: row.getToggleExpandedHandler(),
|
|
500
|
+
className: "flex items-center gap-1.5 text-start font-medium group/expand rounded -ms-1 ps-1 -me-1 pe-1 -my-0.5 py-0.5 hover:text-foreground transition-colors duration-150 ease-out motion-reduce:transition-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none active:scale-[0.98] motion-reduce:active:scale-100",
|
|
501
|
+
"aria-label": `${actionLabel} ${groupLabel} group`,
|
|
502
|
+
"aria-expanded": row.getIsExpanded(),
|
|
503
|
+
children: [
|
|
504
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: cn("h-4 w-4 flex-shrink-0 transition-transform duration-200 ease-out motion-reduce:transition-none", row.getIsExpanded() && "rotate-90") }),
|
|
505
|
+
/* @__PURE__ */ jsx("span", { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }),
|
|
506
|
+
/* @__PURE__ */ jsxs("span", {
|
|
507
|
+
className: "text-text-quaternary tabular-nums",
|
|
508
|
+
children: [
|
|
509
|
+
"(",
|
|
510
|
+
row.subRows.length,
|
|
511
|
+
")"
|
|
512
|
+
]
|
|
513
|
+
})
|
|
514
|
+
]
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
if (isAggregatedCell) return flexRender(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext());
|
|
518
|
+
if (isPlaceholderCell) return null;
|
|
519
|
+
return flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
520
|
+
}, []);
|
|
521
|
+
const hasChildren = React.Children.count(children) > 0;
|
|
522
|
+
const hasFooter = showPagination || showSelectionCount;
|
|
523
|
+
const shouldRenderComposite = hasChildren || hasFooter;
|
|
524
|
+
const selectedRowCount = table.getFilteredSelectedRowModel().rows.length;
|
|
525
|
+
const filteredRowCount = table.getFilteredRowModel().rows.length;
|
|
526
|
+
const selectionTotalRowCount = rowCount ?? filteredRowCount;
|
|
527
|
+
const footerLabel = showSelectionCount ? i18n?.selectionCount?.(selectedRowCount, selectionTotalRowCount) ?? `${selectedRowCount} of ${selectionTotalRowCount} Row(s) Selected.` : null;
|
|
528
|
+
let statusContent;
|
|
529
|
+
if (isLoading) statusContent = loadingState || i18n?.loading || "Loading...";
|
|
530
|
+
else if (error) statusContent = errorState || error.message;
|
|
531
|
+
else statusContent = emptyState || i18n?.noResults || "No results.";
|
|
532
|
+
const statusAriaLive = isLoading || error ? "polite" : void 0;
|
|
533
|
+
function renderVirtualizedBody() {
|
|
534
|
+
return /* @__PURE__ */ jsx(TableBody, {
|
|
535
|
+
style: {
|
|
536
|
+
display: "block",
|
|
537
|
+
position: "relative",
|
|
538
|
+
height: `${rowVirtualizer.getTotalSize() + headerOffset}px`
|
|
539
|
+
},
|
|
540
|
+
children: rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
541
|
+
const row = rows[virtualRow.index];
|
|
542
|
+
const rowIsGroup = isGroupRow(row);
|
|
543
|
+
const visibleCells = row.getVisibleCells();
|
|
544
|
+
const visibleColumnCount = visibleCells.length;
|
|
545
|
+
const responsiveStickySlotsById = getResponsiveStickySlotsById({
|
|
546
|
+
enabled: responsiveColumns,
|
|
547
|
+
getId: (item) => item.column.id,
|
|
548
|
+
getResponsive: (item) => item.column.columnDef.meta?.responsive,
|
|
549
|
+
items: visibleCells,
|
|
550
|
+
stickyFirstColumn,
|
|
551
|
+
stickyLastColumn
|
|
552
|
+
});
|
|
553
|
+
if (rowIsGroup && renderGroupHeader) return /* @__PURE__ */ jsx(TableRow, {
|
|
554
|
+
"data-state": row.getIsSelected() && "selected",
|
|
555
|
+
ref: (node) => rowVirtualizer.measureElement(node),
|
|
556
|
+
"data-index": virtualRow.index,
|
|
557
|
+
className: cn(dataTableRowVariants({
|
|
558
|
+
dividers,
|
|
559
|
+
density,
|
|
560
|
+
isEven: virtualRow.index % 2 === 1,
|
|
561
|
+
isSelected: row.getIsSelected()
|
|
562
|
+
}), "bg-muted", classNames?.row),
|
|
563
|
+
style: getVirtualRowStyle(virtualRow.start, headerOffset),
|
|
564
|
+
children: /* @__PURE__ */ jsx(DataTableGroupHeader, {
|
|
565
|
+
row,
|
|
566
|
+
visibleColumnCount,
|
|
567
|
+
customHeader: renderGroupHeader
|
|
568
|
+
})
|
|
569
|
+
}, row.id);
|
|
570
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
571
|
+
"data-state": row.getIsSelected() && "selected",
|
|
572
|
+
"aria-selected": row.getIsSelected() ? "true" : void 0,
|
|
573
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
574
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
575
|
+
onKeyDown: onRowClick ? (e) => handleRowKeyDown(row, e) : void 0,
|
|
576
|
+
ref: (node) => rowVirtualizer.measureElement(node),
|
|
577
|
+
"data-index": virtualRow.index,
|
|
578
|
+
className: cn(dataTableRowVariants({
|
|
579
|
+
dividers,
|
|
580
|
+
density,
|
|
581
|
+
isEven: virtualRow.index % 2 === 1,
|
|
582
|
+
isSelected: row.getIsSelected()
|
|
583
|
+
}), rowIsGroup && "bg-muted", onRowClick && "cursor-pointer hover:bg-muted focus-visible:bg-muted focus-visible:outline-none active:bg-accent/50 motion-reduce:active:bg-muted", classNames?.row),
|
|
584
|
+
style: getVirtualRowStyle(virtualRow.start, headerOffset),
|
|
585
|
+
children: visibleCells.map((cell, cellIndex) => {
|
|
586
|
+
const isFirstColumn = cellIndex === 0;
|
|
587
|
+
const isLastColumn = cellIndex === visibleColumnCount - 1;
|
|
588
|
+
const responsiveStickySlots = responsiveStickySlotsById.get(cell.column.id);
|
|
589
|
+
const stickyClass = responsiveColumns ? getResponsiveStickyClass({
|
|
590
|
+
backgroundClass: row.getIsSelected() ? "bg-muted dark:bg-accent" : "bg-background dark:bg-card",
|
|
591
|
+
firstSlots: responsiveStickySlots?.firstSlots ?? [],
|
|
592
|
+
lastSlots: responsiveStickySlots?.lastSlots ?? []
|
|
593
|
+
}) : getStickyCellClass({
|
|
594
|
+
stickyFirstColumn,
|
|
595
|
+
stickyLastColumn,
|
|
596
|
+
isFirstColumn,
|
|
597
|
+
isLastColumn,
|
|
598
|
+
isSelected: row.getIsSelected()
|
|
599
|
+
});
|
|
600
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
601
|
+
className: cn(dataTableCellVariants({ density }), classNames?.cell, cell.column.columnDef.meta?.cellClassName, getResponsiveColumnClass(cell.column.columnDef.meta?.responsive, responsiveColumns), stickyClass),
|
|
602
|
+
children: rowIsGroup ? renderCellContent(cell, row) : flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
603
|
+
}, cell.id);
|
|
604
|
+
})
|
|
605
|
+
}, row.id);
|
|
606
|
+
})
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
function renderStandardBody() {
|
|
610
|
+
let bodyContent;
|
|
611
|
+
if (!rows.length) bodyContent = /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
|
|
612
|
+
colSpan: table.getAllColumns().length,
|
|
613
|
+
className: cn(dataTableCellVariants({ density }), "h-24 text-center text-muted-foreground"),
|
|
614
|
+
"aria-live": statusAriaLive,
|
|
615
|
+
children: statusContent
|
|
616
|
+
}) });
|
|
617
|
+
else if (renderRow) bodyContent = rows.map((row) => renderRow(row));
|
|
618
|
+
else bodyContent = rows.map((row, index) => {
|
|
619
|
+
const rowIsGroup = isGroupRow(row);
|
|
620
|
+
const visibleCells = row.getVisibleCells();
|
|
621
|
+
const visibleColumnCount = visibleCells.length;
|
|
622
|
+
const responsiveStickySlotsById = getResponsiveStickySlotsById({
|
|
623
|
+
enabled: responsiveColumns,
|
|
624
|
+
getId: (item) => item.column.id,
|
|
625
|
+
getResponsive: (item) => item.column.columnDef.meta?.responsive,
|
|
626
|
+
items: visibleCells,
|
|
627
|
+
stickyFirstColumn,
|
|
628
|
+
stickyLastColumn
|
|
629
|
+
});
|
|
630
|
+
if (rowIsGroup && renderGroupHeader) return /* @__PURE__ */ jsx(TableRow, {
|
|
631
|
+
"data-state": row.getIsSelected() && "selected",
|
|
632
|
+
className: cn(dataTableRowVariants({
|
|
633
|
+
dividers,
|
|
634
|
+
density,
|
|
635
|
+
isEven: index % 2 === 1,
|
|
636
|
+
isSelected: row.getIsSelected()
|
|
637
|
+
}), "bg-muted", classNames?.row),
|
|
638
|
+
children: /* @__PURE__ */ jsx(DataTableGroupHeader, {
|
|
639
|
+
row,
|
|
640
|
+
visibleColumnCount,
|
|
641
|
+
customHeader: renderGroupHeader
|
|
642
|
+
})
|
|
643
|
+
}, row.id);
|
|
644
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
645
|
+
"data-state": row.getIsSelected() && "selected",
|
|
646
|
+
"aria-selected": row.getIsSelected() ? "true" : void 0,
|
|
647
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
648
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
649
|
+
onKeyDown: onRowClick ? (e) => handleRowKeyDown(row, e) : void 0,
|
|
650
|
+
className: cn(dataTableRowVariants({
|
|
651
|
+
dividers,
|
|
652
|
+
density,
|
|
653
|
+
isEven: index % 2 === 1,
|
|
654
|
+
isSelected: row.getIsSelected()
|
|
655
|
+
}), rowIsGroup && "bg-muted", onRowClick && "cursor-pointer hover:bg-muted focus-visible:bg-muted focus-visible:outline-none active:bg-accent/50 motion-reduce:active:bg-muted", classNames?.row),
|
|
656
|
+
children: visibleCells.map((cell, cellIndex) => {
|
|
657
|
+
const isFirstColumn = cellIndex === 0;
|
|
658
|
+
const isLastColumn = cellIndex === visibleColumnCount - 1;
|
|
659
|
+
const responsiveStickySlots = responsiveStickySlotsById.get(cell.column.id);
|
|
660
|
+
const stickyClass = responsiveColumns ? getResponsiveStickyClass({
|
|
661
|
+
backgroundClass: row.getIsSelected() ? "bg-muted dark:bg-accent" : "bg-background dark:bg-card",
|
|
662
|
+
firstSlots: responsiveStickySlots?.firstSlots ?? [],
|
|
663
|
+
lastSlots: responsiveStickySlots?.lastSlots ?? []
|
|
664
|
+
}) : getStickyCellClass({
|
|
665
|
+
stickyFirstColumn,
|
|
666
|
+
stickyLastColumn,
|
|
667
|
+
isFirstColumn,
|
|
668
|
+
isLastColumn,
|
|
669
|
+
isSelected: row.getIsSelected()
|
|
670
|
+
});
|
|
671
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
672
|
+
className: cn(dataTableCellVariants({ density }), classNames?.cell, cell.column.columnDef.meta?.cellClassName, getResponsiveColumnClass(cell.column.columnDef.meta?.responsive, responsiveColumns), stickyClass),
|
|
673
|
+
children: rowIsGroup ? renderCellContent(cell, row) : flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
674
|
+
}, cell.id);
|
|
675
|
+
})
|
|
676
|
+
}, row.id);
|
|
677
|
+
});
|
|
678
|
+
return /* @__PURE__ */ jsx(TableBody, { children: bodyContent });
|
|
679
|
+
}
|
|
680
|
+
let tableBody;
|
|
681
|
+
if (renderBody) tableBody = renderBody(table);
|
|
682
|
+
else if (isVirtualizationEnabled && rows.length > 0) tableBody = renderVirtualizedBody();
|
|
683
|
+
else tableBody = renderStandardBody();
|
|
684
|
+
const tableContainer = /* @__PURE__ */ jsx("div", {
|
|
685
|
+
ref: tableContainerRef,
|
|
686
|
+
className: cn(dataTableContainerVariants({
|
|
687
|
+
rounded: shouldRenderComposite ? "none" : rounded,
|
|
688
|
+
bordered: shouldRenderComposite ? false : bordered
|
|
689
|
+
}), maxHeight ? "overflow-auto" : "overflow-x-auto"),
|
|
690
|
+
style: maxHeight ? { maxHeight } : void 0,
|
|
691
|
+
children: /* @__PURE__ */ jsxs(TableNamespace, {
|
|
692
|
+
disableOverflow: !!(maxHeight || stickyHeader || stickyFirstColumn || stickyLastColumn),
|
|
693
|
+
className: cn(dataTableVariants({
|
|
694
|
+
dividers,
|
|
695
|
+
density
|
|
696
|
+
}), classNames?.table),
|
|
697
|
+
children: [
|
|
698
|
+
caption && /* @__PURE__ */ jsx("caption", {
|
|
699
|
+
className: "sr-only",
|
|
700
|
+
children: caption
|
|
701
|
+
}),
|
|
702
|
+
/* @__PURE__ */ jsx(TableHeader, {
|
|
703
|
+
className: cn(stickyHeader && "sticky top-0 z-10"),
|
|
704
|
+
children: table.getHeaderGroups().map((headerGroup) => {
|
|
705
|
+
const responsiveStickySlotsById = getResponsiveStickySlotsById({
|
|
706
|
+
enabled: responsiveColumns,
|
|
707
|
+
getId: (item) => item.column.id,
|
|
708
|
+
getResponsive: (item) => item.column.columnDef.meta?.responsive,
|
|
709
|
+
items: headerGroup.headers,
|
|
710
|
+
stickyFirstColumn,
|
|
711
|
+
stickyLastColumn
|
|
712
|
+
});
|
|
713
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
714
|
+
className: cn("border-b border-border bg-muted hover:bg-muted", classNames?.headerRow),
|
|
715
|
+
children: headerGroup.headers.map((header, headerIndex) => {
|
|
716
|
+
const isFirstColumn = headerIndex === 0;
|
|
717
|
+
const isLastColumn = headerIndex === headerGroup.headers.length - 1;
|
|
718
|
+
const isSticky = stickyFirstColumn && isFirstColumn || stickyLastColumn && isLastColumn;
|
|
719
|
+
const responsiveStickySlots = responsiveStickySlotsById.get(header.column.id);
|
|
720
|
+
const responsiveHeaderStickyClass = responsiveColumns ? getResponsiveStickyClass({
|
|
721
|
+
backgroundClass: "bg-muted",
|
|
722
|
+
firstSlots: responsiveStickySlots?.firstSlots ?? [],
|
|
723
|
+
lastSlots: responsiveStickySlots?.lastSlots ?? [],
|
|
724
|
+
zIndexClass: stickyHeader ? "z-30" : "z-20"
|
|
725
|
+
}) : void 0;
|
|
726
|
+
const ariaSort = getAriaSort(header.column.getIsSorted());
|
|
727
|
+
const headerDefinition = header.column.columnDef.header;
|
|
728
|
+
const isTextHeader = typeof headerDefinition === "string";
|
|
729
|
+
let headerContent = null;
|
|
730
|
+
if (!header.isPlaceholder && isTextHeader) headerContent = /* @__PURE__ */ jsx(SortableHeader, {
|
|
731
|
+
column: header.column,
|
|
732
|
+
children: headerDefinition
|
|
733
|
+
});
|
|
734
|
+
else if (!header.isPlaceholder) headerContent = flexRender(headerDefinition, header.getContext());
|
|
735
|
+
return /* @__PURE__ */ jsx(TableHead, {
|
|
736
|
+
scope: "col",
|
|
737
|
+
style: { width: getHeaderCellWidth(header.getSize()) },
|
|
738
|
+
className: cn(dataTableHeaderCellVariants({ density }), "text-start", classNames?.headerCell, header.column.columnDef.meta?.headerClassName, getResponsiveColumnClass(header.column.columnDef.meta?.responsive, responsiveColumns), responsiveColumns ? responsiveHeaderStickyClass : [
|
|
739
|
+
stickyFirstColumn && isFirstColumn && "sticky start-0 z-20 bg-muted",
|
|
740
|
+
stickyLastColumn && isLastColumn && "sticky end-0 z-20 bg-muted",
|
|
741
|
+
stickyHeader && isSticky && "z-30"
|
|
742
|
+
]),
|
|
743
|
+
"aria-sort": ariaSort,
|
|
744
|
+
children: headerContent
|
|
745
|
+
}, header.id);
|
|
746
|
+
})
|
|
747
|
+
}, headerGroup.id);
|
|
748
|
+
})
|
|
749
|
+
}),
|
|
750
|
+
tableBody
|
|
751
|
+
]
|
|
752
|
+
})
|
|
753
|
+
});
|
|
754
|
+
const tableFooter = hasFooter ? /* @__PURE__ */ jsxs("div", {
|
|
755
|
+
"data-slot": "data-table-footer",
|
|
756
|
+
className: cn("flex min-h-[68px] items-center gap-4 border-t border-border-subtle px-6 py-0", footerLabel ? "justify-between" : "justify-end"),
|
|
757
|
+
children: [footerLabel && /* @__PURE__ */ jsx("span", {
|
|
758
|
+
className: "text-sm text-muted-foreground",
|
|
759
|
+
children: footerLabel
|
|
760
|
+
}), showPagination && /* @__PURE__ */ jsx(Pagination, {
|
|
761
|
+
type: paginationType,
|
|
762
|
+
shape: paginationShape,
|
|
763
|
+
size: paginationSize,
|
|
764
|
+
currentPage,
|
|
765
|
+
totalPages,
|
|
766
|
+
onPageChange: (page) => table.setPageIndex(page - 1),
|
|
767
|
+
showPageNumbers: paginationShowPageNumbers,
|
|
768
|
+
"aria-label": paginationLabel,
|
|
769
|
+
className: footerLabel ? "w-auto justify-end" : void 0
|
|
770
|
+
})]
|
|
771
|
+
}) : null;
|
|
772
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
773
|
+
"data-slot": "data-table",
|
|
774
|
+
className: cn("@container", className),
|
|
775
|
+
children: [renderControls && /* @__PURE__ */ jsx("div", {
|
|
776
|
+
className: "mb-4",
|
|
777
|
+
children: /* @__PURE__ */ jsx(DataTableControls, {
|
|
778
|
+
table,
|
|
779
|
+
customControls: renderControls
|
|
780
|
+
})
|
|
781
|
+
}), shouldRenderComposite ? /* @__PURE__ */ jsxs("div", {
|
|
782
|
+
"data-slot": "data-table-composite",
|
|
783
|
+
className: cn(dataTableContainerVariants({
|
|
784
|
+
rounded,
|
|
785
|
+
bordered
|
|
786
|
+
}), "overflow-hidden"),
|
|
787
|
+
children: [
|
|
788
|
+
children,
|
|
789
|
+
tableContainer,
|
|
790
|
+
tableFooter
|
|
791
|
+
]
|
|
792
|
+
}) : tableContainer]
|
|
253
793
|
});
|
|
254
794
|
}
|
|
255
|
-
|
|
256
|
-
var DropdownMenu = Object.assign(DropdownMenuRoot, {
|
|
257
|
-
Root: DropdownMenuRoot,
|
|
258
|
-
Portal: DropdownMenuPortal,
|
|
259
|
-
Trigger: DropdownMenuTrigger,
|
|
260
|
-
Popup: DropdownMenuPopup,
|
|
261
|
-
Group: DropdownMenuGroup,
|
|
262
|
-
Label: DropdownMenuLabel,
|
|
263
|
-
Item: DropdownMenuItem,
|
|
264
|
-
CheckboxItem: DropdownMenuCheckboxItem,
|
|
265
|
-
RadioGroup: DropdownMenuRadioGroup,
|
|
266
|
-
RadioItem: DropdownMenuRadioItem,
|
|
267
|
-
Separator: DropdownMenuSeparator,
|
|
268
|
-
Shortcut: DropdownMenuShortcut,
|
|
269
|
-
ShortcutBadge: DropdownMenuShortcutBadge,
|
|
270
|
-
Sub: DropdownMenuSub,
|
|
271
|
-
SubTrigger: DropdownMenuSubTrigger,
|
|
272
|
-
SubPopup: DropdownMenuSubPopup,
|
|
273
|
-
Header: DropdownMenuHeader,
|
|
274
|
-
Items: DropdownMenuItems,
|
|
275
|
-
Simple: SimpleDropdownMenu
|
|
276
|
-
});
|
|
795
|
+
DataTable.displayName = "DataTable";
|
|
277
796
|
//#endregion
|
|
278
|
-
export {
|
|
797
|
+
export { DataTable, DataTableActionsCell, DataTableAvatarCell, DataTableBadgesCell, DataTableCell, DataTableCellRoot, DataTableProgressCell, DataTableRatingCell, DataTableSparklineCell, DataTableSwitchCell, DataTableTextCell, DataTableTrendCell, SortableHeader, createSelectColumn, dataTableCellVariants, dataTableContainerVariants, dataTableHeaderCellVariants, dataTableRowVariants, dataTableVariants, useDataTable };
|
|
279
798
|
|
|
280
799
|
//# sourceMappingURL=index191.js.map
|