@underverse-ui/underverse 0.2.4 → 0.2.7
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/index.cjs +142 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +146 -60
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -226,10 +226,12 @@ var Button = (0, import_react.forwardRef)(
|
|
|
226
226
|
asContainer = false,
|
|
227
227
|
noWrap = true,
|
|
228
228
|
noHoverOverlay = false,
|
|
229
|
+
gradient = false,
|
|
229
230
|
...rest
|
|
230
231
|
}, ref) => {
|
|
231
232
|
const baseStyles = asContainer ? "relative inline-flex justify-center rounded-md font-medium transition-colors duration-150 ease-soft outline-none focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:translate-y-px" : "relative inline-flex items-center justify-center gap-2 rounded-md font-medium overflow-hidden transition-colors duration-150 ease-soft outline-none focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:translate-y-px";
|
|
232
|
-
const
|
|
233
|
+
const finalVariant = gradient ? "gradient" : variant;
|
|
234
|
+
const variantStyle = VARIANT_STYLES_BTN[finalVariant] || VARIANT_STYLES_BTN.default;
|
|
233
235
|
const sizeStyle = SIZE_STYLES_BTN[size] || SIZE_STYLES_BTN.md;
|
|
234
236
|
const SpinnerIcon = Spinner ?? import_lucide_react.Activity;
|
|
235
237
|
const [locked, setLocked] = (0, import_react.useState)(false);
|
|
@@ -287,7 +289,7 @@ var Button = (0, import_react.forwardRef)(
|
|
|
287
289
|
"aria-label": rest["aria-label"] || title,
|
|
288
290
|
...rest,
|
|
289
291
|
children: [
|
|
290
|
-
!noHoverOverlay && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "absolute inset-0 bg-gradient-to-r from-primary-foreground/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-200" }),
|
|
292
|
+
!noHoverOverlay && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "absolute inset-0 bg-gradient-to-r from-primary-foreground/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-200 dark:hidden" }),
|
|
291
293
|
loading2 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
292
294
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpinnerIcon, { className: "w-4 h-4 animate-spin" }),
|
|
293
295
|
loadingText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ml-2", "aria-live": "polite", children: loadingText }),
|
|
@@ -2260,7 +2262,7 @@ var sizeStyles3 = {
|
|
|
2260
2262
|
md: "max-w-md",
|
|
2261
2263
|
lg: "max-w-lg",
|
|
2262
2264
|
xl: "max-w-xl",
|
|
2263
|
-
full: "max-w-full
|
|
2265
|
+
full: "max-w-full"
|
|
2264
2266
|
};
|
|
2265
2267
|
var Modal = ({
|
|
2266
2268
|
isOpen,
|
|
@@ -2269,11 +2271,14 @@ var Modal = ({
|
|
|
2269
2271
|
title,
|
|
2270
2272
|
description,
|
|
2271
2273
|
className,
|
|
2274
|
+
contentClassName,
|
|
2272
2275
|
overlayClassName,
|
|
2273
2276
|
showCloseButton = true,
|
|
2274
2277
|
closeOnOverlayClick = true,
|
|
2275
2278
|
closeOnEsc = true,
|
|
2276
|
-
size = "md"
|
|
2279
|
+
size = "md",
|
|
2280
|
+
noPadding = false,
|
|
2281
|
+
fullWidth = false
|
|
2277
2282
|
}) => {
|
|
2278
2283
|
const [isMounted, setIsMounted] = React9.useState(false);
|
|
2279
2284
|
const [isVisible, setIsVisible] = React9.useState(false);
|
|
@@ -2341,7 +2346,8 @@ var Modal = ({
|
|
|
2341
2346
|
className: cn(
|
|
2342
2347
|
"relative w-full rounded-lg bg-card text-card-foreground shadow-xl",
|
|
2343
2348
|
"transition-all duration-200 ease-out",
|
|
2344
|
-
sizeStyles3[size],
|
|
2349
|
+
fullWidth ? "max-w-full" : sizeStyles3[size],
|
|
2350
|
+
fullWidth && "mx-0",
|
|
2345
2351
|
className
|
|
2346
2352
|
),
|
|
2347
2353
|
style: {
|
|
@@ -2370,7 +2376,7 @@ var Modal = ({
|
|
|
2370
2376
|
}
|
|
2371
2377
|
)
|
|
2372
2378
|
] }),
|
|
2373
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "p-6", children })
|
|
2379
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: cn("p-6", noPadding && "p-0", contentClassName), children })
|
|
2374
2380
|
]
|
|
2375
2381
|
}
|
|
2376
2382
|
)
|
|
@@ -4025,7 +4031,9 @@ var Combobox = ({
|
|
|
4025
4031
|
usePortal = true,
|
|
4026
4032
|
label,
|
|
4027
4033
|
required,
|
|
4028
|
-
fontBold = false
|
|
4034
|
+
fontBold = false,
|
|
4035
|
+
loading: loading2 = false,
|
|
4036
|
+
loadingText = "Loading..."
|
|
4029
4037
|
}) => {
|
|
4030
4038
|
const [open, setOpen] = React18.useState(false);
|
|
4031
4039
|
const [query, setQuery] = React18.useState("");
|
|
@@ -4043,6 +4051,7 @@ var Combobox = ({
|
|
|
4043
4051
|
);
|
|
4044
4052
|
const [dropdownPosition, setDropdownPosition] = React18.useState(null);
|
|
4045
4053
|
const triggerRef = React18.useRef(null);
|
|
4054
|
+
const dropdownRef = React18.useRef(null);
|
|
4046
4055
|
const calculatePosition = React18.useCallback(() => {
|
|
4047
4056
|
if (!triggerRef.current) return null;
|
|
4048
4057
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
@@ -4071,11 +4080,10 @@ var Combobox = ({
|
|
|
4071
4080
|
if (!open) return;
|
|
4072
4081
|
const handleClickOutside = (event) => {
|
|
4073
4082
|
const target = event.target;
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
}
|
|
4083
|
+
const triggerEl = triggerRef.current;
|
|
4084
|
+
const dropdownEl = dropdownRef.current;
|
|
4085
|
+
if (triggerEl && !triggerEl.contains(target) && dropdownEl && !dropdownEl.contains(target)) {
|
|
4086
|
+
setOpen(false);
|
|
4079
4087
|
}
|
|
4080
4088
|
};
|
|
4081
4089
|
const handleEscape = (event) => {
|
|
@@ -4119,6 +4127,7 @@ var Combobox = ({
|
|
|
4119
4127
|
"div",
|
|
4120
4128
|
{
|
|
4121
4129
|
"data-combobox-dropdown": true,
|
|
4130
|
+
ref: dropdownRef,
|
|
4122
4131
|
style: {
|
|
4123
4132
|
position: "absolute",
|
|
4124
4133
|
top: dropdownPosition?.top || 0,
|
|
@@ -4176,7 +4185,10 @@ var Combobox = ({
|
|
|
4176
4185
|
}
|
|
4177
4186
|
)
|
|
4178
4187
|
] }),
|
|
4179
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "max-h-64 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("ul", { className: "p-1 space-y-1", children:
|
|
4188
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "max-h-64 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("ul", { className: "p-1 space-y-1", children: loading2 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { className: "px-3 py-8 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
4189
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react12.Loader2, { className: "h-6 w-6 animate-spin text-primary" }),
|
|
4190
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-sm text-muted-foreground", children: loadingText || "Loading..." })
|
|
4191
|
+
] }) }) : filteredOptions.length > 0 ? filteredOptions.map((item, index) => {
|
|
4180
4192
|
const itemValue = getOptionValue(item);
|
|
4181
4193
|
const itemLabel = getOptionLabel(item);
|
|
4182
4194
|
const isSelected = itemValue === value;
|
|
@@ -4210,9 +4222,18 @@ var Combobox = ({
|
|
|
4210
4222
|
},
|
|
4211
4223
|
`${itemValue}-${index}`
|
|
4212
4224
|
);
|
|
4213
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { className: "px-3 py-8 text-center text-muted-foreground text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col items-center gap-2", children: [
|
|
4214
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react12.
|
|
4215
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: emptyText })
|
|
4225
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { className: "px-3 py-8 text-center text-muted-foreground text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
4226
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react12.SearchX, { className: "h-8 w-8 opacity-40 text-muted-foreground" }),
|
|
4227
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-sm", children: emptyText }),
|
|
4228
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4229
|
+
"button",
|
|
4230
|
+
{
|
|
4231
|
+
type: "button",
|
|
4232
|
+
onClick: () => setQuery(""),
|
|
4233
|
+
className: "text-xs text-primary hover:underline",
|
|
4234
|
+
children: "Clear search"
|
|
4235
|
+
}
|
|
4236
|
+
)
|
|
4216
4237
|
] }) }) }) })
|
|
4217
4238
|
] })
|
|
4218
4239
|
}
|
|
@@ -4288,7 +4309,15 @@ var Combobox = ({
|
|
|
4288
4309
|
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react12.X, { className: "h-3 w-3" })
|
|
4289
4310
|
}
|
|
4290
4311
|
),
|
|
4291
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4312
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4313
|
+
import_lucide_react12.ChevronDown,
|
|
4314
|
+
{
|
|
4315
|
+
className: cn(
|
|
4316
|
+
"h-4 w-4 text-muted-foreground transition-all duration-200",
|
|
4317
|
+
open && "rotate-180 scale-110 text-primary"
|
|
4318
|
+
)
|
|
4319
|
+
}
|
|
4320
|
+
)
|
|
4292
4321
|
] })
|
|
4293
4322
|
]
|
|
4294
4323
|
}
|
|
@@ -4964,10 +4993,9 @@ var DatePicker = ({
|
|
|
4964
4993
|
},
|
|
4965
4994
|
className: cn(
|
|
4966
4995
|
size === "sm" ? "w-7 h-7 text-[12px]" : "w-8 h-8 text-sm",
|
|
4967
|
-
"datepicker-day rounded-md
|
|
4968
|
-
"focus:bg-accent focus:text-accent-foreground focus:outline-none",
|
|
4996
|
+
"datepicker-day rounded-md focus:outline-none",
|
|
4969
4997
|
"transition-colors",
|
|
4970
|
-
isSelected
|
|
4998
|
+
isSelected ? "bg-primary text-primary-foreground hover:bg-primary/90 focus:bg-primary focus:text-primary-foreground" : "hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
|
4971
4999
|
isToday2 && !isSelected && "bg-accent text-accent-foreground font-semibold"
|
|
4972
5000
|
),
|
|
4973
5001
|
children: day
|
|
@@ -6118,7 +6146,7 @@ function Calendar2({
|
|
|
6118
6146
|
disabled && "opacity-40 cursor-not-allowed",
|
|
6119
6147
|
isToday2 && !selectedDay && "ring-1 ring-primary/50",
|
|
6120
6148
|
selectedDay && "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
6121
|
-
!selectedDay && "hover:bg-accent"
|
|
6149
|
+
!selectedDay && "hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
|
|
6122
6150
|
),
|
|
6123
6151
|
title: d.toDateString(),
|
|
6124
6152
|
children: [
|
|
@@ -6179,7 +6207,7 @@ function Calendar2({
|
|
|
6179
6207
|
disabled && "opacity-40 cursor-not-allowed",
|
|
6180
6208
|
isToday2 && !selectedDay && "ring-1 ring-primary/50",
|
|
6181
6209
|
selectedDay && "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
6182
|
-
!selectedDay && "hover:bg-accent"
|
|
6210
|
+
!selectedDay && "hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
|
|
6183
6211
|
),
|
|
6184
6212
|
title: d.toDateString(),
|
|
6185
6213
|
children: [
|
|
@@ -6216,7 +6244,10 @@ var MultiCombobox = ({
|
|
|
6216
6244
|
label,
|
|
6217
6245
|
title,
|
|
6218
6246
|
required,
|
|
6219
|
-
displayFormat = (option) => option.label
|
|
6247
|
+
displayFormat = (option) => option.label,
|
|
6248
|
+
loading: loading2 = false,
|
|
6249
|
+
loadingText = "Loading...",
|
|
6250
|
+
emptyText = "No results found"
|
|
6220
6251
|
}) => {
|
|
6221
6252
|
const [query, setQuery] = React24.useState("");
|
|
6222
6253
|
const [open, setOpen] = React24.useState(false);
|
|
@@ -6225,6 +6256,7 @@ var MultiCombobox = ({
|
|
|
6225
6256
|
const listRef = React24.useRef([]);
|
|
6226
6257
|
const [dropdownPosition, setDropdownPosition] = React24.useState(null);
|
|
6227
6258
|
const triggerRef = React24.useRef(null);
|
|
6259
|
+
const dropdownRef = React24.useRef(null);
|
|
6228
6260
|
useShadCNAnimations();
|
|
6229
6261
|
const calculatePosition = React24.useCallback(() => {
|
|
6230
6262
|
if (!triggerRef.current) return null;
|
|
@@ -6254,11 +6286,10 @@ var MultiCombobox = ({
|
|
|
6254
6286
|
if (!open) return;
|
|
6255
6287
|
const handleClickOutside = (event) => {
|
|
6256
6288
|
const target = event.target;
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
}
|
|
6289
|
+
const triggerEl = triggerRef.current;
|
|
6290
|
+
const dropdownEl = dropdownRef.current;
|
|
6291
|
+
if (triggerEl && !triggerEl.contains(target) && dropdownEl && !dropdownEl.contains(target)) {
|
|
6292
|
+
setOpen(false);
|
|
6262
6293
|
}
|
|
6263
6294
|
};
|
|
6264
6295
|
const handleEscape = (event) => {
|
|
@@ -6427,7 +6458,12 @@ var MultiCombobox = ({
|
|
|
6427
6458
|
value.length,
|
|
6428
6459
|
" selected"
|
|
6429
6460
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "text-muted-foreground", children: placeholder || "Select..." }) }),
|
|
6430
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6461
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6462
|
+
import_lucide_react17.ChevronDown,
|
|
6463
|
+
{
|
|
6464
|
+
className: cn("opacity-50 transition-all duration-200", sizeStyles8[size].icon, open && "rotate-180 scale-110 text-primary opacity-100")
|
|
6465
|
+
}
|
|
6466
|
+
)
|
|
6431
6467
|
]
|
|
6432
6468
|
}
|
|
6433
6469
|
),
|
|
@@ -6435,6 +6471,7 @@ var MultiCombobox = ({
|
|
|
6435
6471
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6436
6472
|
"div",
|
|
6437
6473
|
{
|
|
6474
|
+
ref: dropdownRef,
|
|
6438
6475
|
"data-dropdown": "multicombobox",
|
|
6439
6476
|
style: {
|
|
6440
6477
|
position: "absolute",
|
|
@@ -6452,10 +6489,7 @@ var MultiCombobox = ({
|
|
|
6452
6489
|
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
6453
6490
|
"div",
|
|
6454
6491
|
{
|
|
6455
|
-
className: cn(
|
|
6456
|
-
"rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
6457
|
-
"backdrop-blur-sm bg-popover/95 border-border/60"
|
|
6458
|
-
),
|
|
6492
|
+
className: cn("rounded-md border bg-popover text-popover-foreground shadow-md", "backdrop-blur-sm bg-popover/95 border-border/60"),
|
|
6459
6493
|
children: [
|
|
6460
6494
|
showClear && value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "px-3 py-2 border-b border-border/60 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6461
6495
|
"button",
|
|
@@ -6487,7 +6521,10 @@ var MultiCombobox = ({
|
|
|
6487
6521
|
}
|
|
6488
6522
|
)
|
|
6489
6523
|
] }),
|
|
6490
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("ul", { className: cn("max-h-60 overflow-y-auto p-1", size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"), children:
|
|
6524
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("ul", { className: cn("max-h-60 overflow-y-auto p-1", size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"), children: loading2 ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("li", { className: "px-3 py-8 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
6525
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react17.Loader2, { className: "h-6 w-6 animate-spin text-primary" }),
|
|
6526
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "text-muted-foreground", children: loadingText })
|
|
6527
|
+
] }) }) : filtered.length ? filtered.map((item, index) => {
|
|
6491
6528
|
const isSelected = value.includes(item.value);
|
|
6492
6529
|
const isDisabled = disabledOptions.includes(item.value);
|
|
6493
6530
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
@@ -6519,7 +6556,20 @@ var MultiCombobox = ({
|
|
|
6519
6556
|
},
|
|
6520
6557
|
item.value
|
|
6521
6558
|
);
|
|
6522
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6559
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6560
|
+
"li",
|
|
6561
|
+
{
|
|
6562
|
+
className: cn(
|
|
6563
|
+
"px-3 py-8 text-center text-muted-foreground",
|
|
6564
|
+
size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"
|
|
6565
|
+
),
|
|
6566
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
6567
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react17.SearchX, { className: "h-8 w-8 opacity-40 text-muted-foreground" }),
|
|
6568
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: emptyText }),
|
|
6569
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", onClick: () => setQuery(""), className: "text-xs text-primary hover:underline", children: "Clear search" })
|
|
6570
|
+
] })
|
|
6571
|
+
}
|
|
6572
|
+
) })
|
|
6523
6573
|
]
|
|
6524
6574
|
}
|
|
6525
6575
|
)
|
|
@@ -10189,11 +10239,44 @@ function DataTable({
|
|
|
10189
10239
|
col.key
|
|
10190
10240
|
)) });
|
|
10191
10241
|
const isServerMode = Boolean(onQueryChange);
|
|
10242
|
+
const processedData = import_react23.default.useMemo(() => {
|
|
10243
|
+
if (isServerMode) return data;
|
|
10244
|
+
let result = [...data];
|
|
10245
|
+
if (Object.keys(filters).length > 0) {
|
|
10246
|
+
result = result.filter((row) => {
|
|
10247
|
+
return Object.entries(filters).every(([key, value]) => {
|
|
10248
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
10249
|
+
const col = columns.find((c) => c.key === key);
|
|
10250
|
+
const rowValue = col?.dataIndex ? row[col.dataIndex] : row[key];
|
|
10251
|
+
if (col?.filter?.type === "date" && value instanceof Date) {
|
|
10252
|
+
return new Date(rowValue).toDateString() === value.toDateString();
|
|
10253
|
+
}
|
|
10254
|
+
return String(rowValue ?? "").toLowerCase().includes(String(value).toLowerCase());
|
|
10255
|
+
});
|
|
10256
|
+
});
|
|
10257
|
+
}
|
|
10258
|
+
if (sort) {
|
|
10259
|
+
result.sort((a, b) => {
|
|
10260
|
+
const col = columns.find((c) => c.key === sort.key);
|
|
10261
|
+
const aValue = col?.dataIndex ? a[col.dataIndex] : a[sort.key];
|
|
10262
|
+
const bValue = col?.dataIndex ? b[col.dataIndex] : b[sort.key];
|
|
10263
|
+
if (aValue === bValue) return 0;
|
|
10264
|
+
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
10265
|
+
return sort.order === "asc" ? aValue - bValue : bValue - aValue;
|
|
10266
|
+
}
|
|
10267
|
+
const compare = String(aValue).localeCompare(String(bValue));
|
|
10268
|
+
return sort.order === "asc" ? compare : -compare;
|
|
10269
|
+
});
|
|
10270
|
+
}
|
|
10271
|
+
return result;
|
|
10272
|
+
}, [data, isServerMode, filters, sort, columns]);
|
|
10273
|
+
const totalItems = isServerMode ? total : processedData.length;
|
|
10192
10274
|
const displayedData = isServerMode ? data : import_react23.default.useMemo(() => {
|
|
10193
10275
|
const start = (curPage - 1) * curPageSize;
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10276
|
+
if (start >= processedData.length && curPage > 1) {
|
|
10277
|
+
}
|
|
10278
|
+
return processedData.slice(start, start + curPageSize);
|
|
10279
|
+
}, [processedData, curPage, curPageSize]);
|
|
10197
10280
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: cn("space-y-2", className), children: [
|
|
10198
10281
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between gap-4 mb-1", children: [
|
|
10199
10282
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "text-sm text-muted-foreground", children: caption }),
|
|
@@ -10265,24 +10348,27 @@ function DataTable({
|
|
|
10265
10348
|
)
|
|
10266
10349
|
] }),
|
|
10267
10350
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-sm", children: "Loading..." })
|
|
10268
|
-
] }) }) }) : !displayedData || displayedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableCell, { colSpan: visibleColumns.length, className: "text-center py-6 text-muted-foreground", children: "No data" }) }) : displayedData.map((row, idx) =>
|
|
10269
|
-
const
|
|
10270
|
-
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10351
|
+
] }) }) }) : !displayedData || displayedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableCell, { colSpan: visibleColumns.length, className: "text-center py-6 text-muted-foreground", children: "No data" }) }) : displayedData.map((row, idx) => {
|
|
10352
|
+
const isLastRow = idx === displayedData.length - 1;
|
|
10353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableRow, { className: cn(densityRowClass, striped && idx % 2 === 0 && "bg-muted/30"), children: visibleColumns.map((col, colIdx) => {
|
|
10354
|
+
const value = col.dataIndex ? row[col.dataIndex] : void 0;
|
|
10355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10356
|
+
TableCell,
|
|
10357
|
+
{
|
|
10358
|
+
className: cn(
|
|
10359
|
+
cellPadding,
|
|
10360
|
+
col.align === "right" && "text-right",
|
|
10361
|
+
col.align === "center" && "text-center",
|
|
10362
|
+
columnDividers && colIdx > 0 && "border-l border-border/60",
|
|
10363
|
+
isLastRow && col === visibleColumns[0] && "rounded-bl-md",
|
|
10364
|
+
isLastRow && col === visibleColumns[visibleColumns.length - 1] && "rounded-br-md"
|
|
10365
|
+
),
|
|
10366
|
+
children: col.render ? col.render(value, row, idx) : String(value ?? "")
|
|
10367
|
+
},
|
|
10368
|
+
col.key
|
|
10369
|
+
);
|
|
10370
|
+
}) }, getRowKey(row, idx));
|
|
10371
|
+
}) })
|
|
10286
10372
|
]
|
|
10287
10373
|
}
|
|
10288
10374
|
) }),
|