@humain/ui 2.1.63 → 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 +7 -339
- 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 +79 -78
- 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 +58 -57
- 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/index190.js
CHANGED
|
@@ -1,799 +1,212 @@
|
|
|
1
1
|
import { cn } from "./index2.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
import { Button } from "./index5.js";
|
|
3
|
+
import { Badge } from "./index14.js";
|
|
4
|
+
import { Progress } from "./index17.js";
|
|
5
|
+
import { Rating } from "./index18.js";
|
|
6
|
+
import { SparklineChart } from "./index23.js";
|
|
7
|
+
import { Switch } from "./index42.js";
|
|
8
|
+
import { Avatar } from "./index70.js";
|
|
9
|
+
import { dataTableTouchTargetClassName } from "./index189.js";
|
|
10
|
+
import { ArrowDown, ArrowUp, MoreHorizontal } from "lucide-react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
//#region src/components/organisms/content/DataTable/DataTableCell.tsx
|
|
13
|
+
var textToneClassName = {
|
|
14
|
+
foreground: "text-foreground",
|
|
15
|
+
secondary: "text-secondary-foreground",
|
|
16
|
+
muted: "text-muted-foreground",
|
|
17
|
+
success: "text-success",
|
|
18
|
+
warning: "text-warning",
|
|
19
|
+
destructive: "text-destructive"
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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");
|
|
130
|
-
}
|
|
131
|
-
function getResponsiveColumnPriority(priority) {
|
|
132
|
-
switch (priority) {
|
|
133
|
-
case "always":
|
|
134
|
-
case "desktop":
|
|
135
|
-
case "mobile": return priority;
|
|
136
|
-
default: return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function getResponsiveColumnHideBelow(hideBelow) {
|
|
140
|
-
switch (hideBelow) {
|
|
141
|
-
case "sm":
|
|
142
|
-
case "md":
|
|
143
|
-
case "lg": return hideBelow;
|
|
144
|
-
default: return;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
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];
|
|
154
|
-
}
|
|
155
|
-
function withResponsiveSlotVariant(slot, className) {
|
|
156
|
-
if (slot === "base") return className;
|
|
157
|
-
return className.split(" ").map((token) => `@${slot}:${token}`).join(" ");
|
|
158
|
-
}
|
|
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);
|
|
171
|
-
}
|
|
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);
|
|
181
|
-
}
|
|
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;
|
|
191
|
-
}
|
|
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
|
-
}));
|
|
204
|
-
}
|
|
205
|
-
function getHeaderCellWidth(size) {
|
|
206
|
-
if (size === 150) return;
|
|
207
|
-
return size;
|
|
208
|
-
}
|
|
209
|
-
function getAriaSort(sortState) {
|
|
210
|
-
if (sortState === "asc") return "ascending";
|
|
211
|
-
if (sortState === "desc") return "descending";
|
|
21
|
+
function getSentiment(value) {
|
|
22
|
+
if (value > 0) return "positive";
|
|
23
|
+
if (value < 0) return "negative";
|
|
24
|
+
return "neutral";
|
|
25
|
+
}
|
|
26
|
+
function formatTrendValue(value) {
|
|
27
|
+
const absoluteValue = Math.abs(value);
|
|
28
|
+
return `${Number.isInteger(absoluteValue) ? absoluteValue : absoluteValue.toFixed(1)}%`;
|
|
29
|
+
}
|
|
30
|
+
function getActionButtonSize({ children, icon, iconOnly, size }) {
|
|
31
|
+
if (size) return size;
|
|
32
|
+
return iconOnly ?? (icon && !children) ? "icon-sm" : "sm";
|
|
33
|
+
}
|
|
34
|
+
function DataTableCellRoot({ className, ...props }) {
|
|
35
|
+
return /* @__PURE__ */ jsx("div", {
|
|
36
|
+
"data-slot": "data-table-cell-content",
|
|
37
|
+
className: cn("flex min-w-0 items-center gap-3", className),
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
212
40
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
41
|
+
DataTableCellRoot.displayName = "DataTableCell";
|
|
42
|
+
function DataTableTextCell({ className, primary, children, supportingText, lead = true, tone = lead ? "foreground" : "secondary", supportingTone = "muted", primaryClassName, supportingClassName, ...props }) {
|
|
43
|
+
const primaryContent = primary ?? children;
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
45
|
+
"data-slot": "data-table-cell-text",
|
|
46
|
+
className: cn("flex min-w-0 flex-col", className),
|
|
47
|
+
...props,
|
|
48
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: cn("truncate text-sm", lead ? "font-medium" : "font-regular", textToneClassName[tone], primaryClassName),
|
|
50
|
+
children: primaryContent
|
|
51
|
+
}), supportingText ? /* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: cn("truncate text-sm font-light", textToneClassName[supportingTone], supportingClassName),
|
|
53
|
+
children: supportingText
|
|
54
|
+
}) : null]
|
|
55
|
+
});
|
|
219
56
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
57
|
+
DataTableTextCell.displayName = "DataTableCell.Text";
|
|
58
|
+
function DataTableAvatarCell({ className, name, supportingText, src, alt = "", fallback, avatar, avatarSize = "lg", avatarShape = "circle", lead = true, ...props }) {
|
|
59
|
+
return /* @__PURE__ */ jsxs(DataTableCellRoot, {
|
|
60
|
+
className,
|
|
61
|
+
...props,
|
|
62
|
+
children: [avatar ?? /* @__PURE__ */ jsx(Avatar, {
|
|
63
|
+
src,
|
|
64
|
+
alt,
|
|
65
|
+
fallback: fallback ?? (typeof name === "string" ? name : void 0),
|
|
66
|
+
size: avatarSize,
|
|
67
|
+
shape: avatarShape
|
|
68
|
+
}), /* @__PURE__ */ jsx(DataTableTextCell, {
|
|
69
|
+
className: "min-w-0",
|
|
70
|
+
primary: name,
|
|
71
|
+
supportingText,
|
|
72
|
+
lead
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
229
75
|
}
|
|
230
|
-
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}),
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
};
|
|
76
|
+
DataTableAvatarCell.displayName = "DataTableCell.Avatar";
|
|
77
|
+
function DataTableBadgesCell({ className, items, max = items.length, overflowLabel = (count) => `+${count}`, size = "sm", color = "secondary", variant = "soft", shape = "rounded", ...props }) {
|
|
78
|
+
const visibleCount = Math.max(0, Math.min(items.length, max));
|
|
79
|
+
const visibleItems = items.slice(0, visibleCount);
|
|
80
|
+
const overflowCount = items.length - visibleItems.length;
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
82
|
+
"data-slot": "data-table-cell-badges",
|
|
83
|
+
className: cn("flex min-w-0 flex-wrap items-center gap-1", className),
|
|
84
|
+
...props,
|
|
85
|
+
children: [visibleItems.map((item, index) => /* @__PURE__ */ jsx(Badge, {
|
|
86
|
+
color: item.color ?? color,
|
|
87
|
+
variant: item.variant ?? variant,
|
|
88
|
+
shape: item.shape ?? shape,
|
|
89
|
+
size,
|
|
90
|
+
className: item.className,
|
|
91
|
+
children: item.label
|
|
92
|
+
}, `${String(item.label)}-${index}`)), overflowCount > 0 ? /* @__PURE__ */ jsx(Badge, {
|
|
93
|
+
color: "secondary",
|
|
94
|
+
variant: "soft",
|
|
95
|
+
shape,
|
|
96
|
+
size,
|
|
97
|
+
children: overflowLabel(overflowCount)
|
|
98
|
+
}) : null]
|
|
99
|
+
});
|
|
255
100
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
101
|
+
DataTableBadgesCell.displayName = "DataTableCell.Badges";
|
|
102
|
+
function DataTableProgressCell({ className, value, max = 100, label, supportingText, progressClassName, ...props }) {
|
|
103
|
+
const percentage = Math.min(100, Math.max(0, value / (Number.isFinite(max) && max > 0 ? max : 100) * 100));
|
|
104
|
+
const visibleLabel = label ?? `${Math.round(percentage)}%`;
|
|
105
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
106
|
+
"data-slot": "data-table-cell-progress",
|
|
107
|
+
className: cn("flex min-w-40 items-center gap-3", className),
|
|
108
|
+
...props,
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "w-10 shrink-0 text-sm text-secondary-foreground",
|
|
112
|
+
children: visibleLabel
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ jsx(Progress, {
|
|
115
|
+
value: percentage,
|
|
116
|
+
className: cn("min-w-24 flex-1", progressClassName)
|
|
117
|
+
}),
|
|
118
|
+
supportingText ? /* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "shrink-0 text-sm text-foreground",
|
|
120
|
+
children: supportingText
|
|
121
|
+
}) : null
|
|
122
|
+
]
|
|
266
123
|
});
|
|
267
124
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const
|
|
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
|
-
}
|
|
125
|
+
DataTableProgressCell.displayName = "DataTableCell.Progress";
|
|
126
|
+
function DataTableTrendCell({ className, value, sentiment = getSentiment(value), showIcon = true, formatValue = formatTrendValue, ...props }) {
|
|
127
|
+
const Icon = sentiment === "positive" ? ArrowUp : sentiment === "negative" ? ArrowDown : null;
|
|
282
128
|
return /* @__PURE__ */ jsxs("span", {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
className:
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
]
|
|
295
|
-
})]
|
|
296
|
-
}), /* @__PURE__ */ jsx(HeaderTooltip, { content: tooltipContent })]
|
|
129
|
+
"data-slot": "data-table-cell-trend",
|
|
130
|
+
className: cn("inline-flex items-center gap-1 text-sm font-medium", sentiment === "positive" ? "text-success" : sentiment === "negative" ? "text-destructive" : "text-secondary-foreground", className),
|
|
131
|
+
...props,
|
|
132
|
+
children: [showIcon && Icon ? /* @__PURE__ */ jsx(Icon, {
|
|
133
|
+
className: "size-3",
|
|
134
|
+
"aria-hidden": "true"
|
|
135
|
+
}) : null, formatValue(value)]
|
|
297
136
|
});
|
|
298
137
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
|
138
|
+
DataTableTrendCell.displayName = "DataTableCell.Trend";
|
|
139
|
+
function DataTableSparklineCell({ className, data, color = "primary", width = 108, height = 24, ...props }) {
|
|
140
|
+
return /* @__PURE__ */ jsx("div", {
|
|
141
|
+
"data-slot": "data-table-cell-sparkline",
|
|
142
|
+
className: cn("flex items-center", className),
|
|
143
|
+
...props,
|
|
144
|
+
children: /* @__PURE__ */ jsx(SparklineChart, {
|
|
145
|
+
data,
|
|
146
|
+
color,
|
|
147
|
+
width,
|
|
148
|
+
height
|
|
149
|
+
})
|
|
412
150
|
});
|
|
413
|
-
return {
|
|
414
|
-
table,
|
|
415
|
-
totalPages: table.getPageCount(),
|
|
416
|
-
currentPage: pagination.pageIndex + 1,
|
|
417
|
-
showPagination: enablePagination && paginationMode !== "none" && table.getPageCount() > 1
|
|
418
|
-
};
|
|
419
151
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
data,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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
|
|
152
|
+
DataTableSparklineCell.displayName = "DataTableCell.Sparkline";
|
|
153
|
+
function DataTableRatingCell({ className, size = "md", ...props }) {
|
|
154
|
+
return /* @__PURE__ */ jsx(Rating, {
|
|
155
|
+
"data-slot": "data-table-cell-rating",
|
|
156
|
+
className,
|
|
157
|
+
size,
|
|
158
|
+
...props
|
|
463
159
|
});
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|
|
160
|
+
}
|
|
161
|
+
DataTableRatingCell.displayName = "DataTableCell.Rating";
|
|
162
|
+
function DataTableSwitchCell(props) {
|
|
163
|
+
return /* @__PURE__ */ jsx(Switch, {
|
|
164
|
+
"data-slot": "data-table-cell-switch",
|
|
165
|
+
size: "sm",
|
|
166
|
+
...props
|
|
483
167
|
});
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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
|
|
168
|
+
}
|
|
169
|
+
DataTableSwitchCell.displayName = "DataTableCell.Switch";
|
|
170
|
+
function DataTableActionsCell({ className, actions, ...props }) {
|
|
171
|
+
return /* @__PURE__ */ jsx("div", {
|
|
172
|
+
"data-slot": "data-table-cell-actions",
|
|
173
|
+
className: cn("flex items-center justify-end gap-1", className),
|
|
174
|
+
...props,
|
|
175
|
+
children: actions.map((action) => {
|
|
176
|
+
const iconOnly = action.iconOnly ?? !action.children;
|
|
177
|
+
const size = getActionButtonSize({
|
|
178
|
+
children: action.children,
|
|
179
|
+
icon: action.icon,
|
|
180
|
+
iconOnly,
|
|
181
|
+
size: action.size
|
|
629
182
|
});
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
children: /* @__PURE__ */ jsx(
|
|
639
|
-
|
|
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
|
-
]
|
|
183
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
184
|
+
appearance: action.appearance ?? "ghost",
|
|
185
|
+
variant: action.variant ?? "secondary",
|
|
186
|
+
size,
|
|
187
|
+
iconOnly,
|
|
188
|
+
"aria-label": action.label,
|
|
189
|
+
onClick: action.onClick,
|
|
190
|
+
className: cn(dataTableTouchTargetClassName, action.className),
|
|
191
|
+
children: action.icon ?? action.children ?? /* @__PURE__ */ jsx(MoreHorizontal, {})
|
|
192
|
+
}, action.label);
|
|
752
193
|
})
|
|
753
194
|
});
|
|
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]
|
|
793
|
-
});
|
|
794
195
|
}
|
|
795
|
-
|
|
196
|
+
DataTableActionsCell.displayName = "DataTableCell.Actions";
|
|
197
|
+
var DataTableCell = Object.assign(DataTableCellRoot, {
|
|
198
|
+
Root: DataTableCellRoot,
|
|
199
|
+
Text: DataTableTextCell,
|
|
200
|
+
Avatar: DataTableAvatarCell,
|
|
201
|
+
Badges: DataTableBadgesCell,
|
|
202
|
+
Progress: DataTableProgressCell,
|
|
203
|
+
Trend: DataTableTrendCell,
|
|
204
|
+
Sparkline: DataTableSparklineCell,
|
|
205
|
+
Rating: DataTableRatingCell,
|
|
206
|
+
Switch: DataTableSwitchCell,
|
|
207
|
+
Actions: DataTableActionsCell
|
|
208
|
+
});
|
|
796
209
|
//#endregion
|
|
797
|
-
export {
|
|
210
|
+
export { DataTableActionsCell, DataTableAvatarCell, DataTableBadgesCell, DataTableCell, DataTableCellRoot, DataTableProgressCell, DataTableRatingCell, DataTableSparklineCell, DataTableSwitchCell, DataTableTextCell, DataTableTrendCell };
|
|
798
211
|
|
|
799
212
|
//# sourceMappingURL=index190.js.map
|