@underverse-ui/underverse 0.2.5 → 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 +134 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +138 -53
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -343,11 +343,14 @@ interface ModalProps {
|
|
|
343
343
|
title?: string;
|
|
344
344
|
description?: string;
|
|
345
345
|
className?: string;
|
|
346
|
+
contentClassName?: string;
|
|
346
347
|
overlayClassName?: string;
|
|
347
348
|
showCloseButton?: boolean;
|
|
348
349
|
closeOnOverlayClick?: boolean;
|
|
349
350
|
closeOnEsc?: boolean;
|
|
350
351
|
size?: "sm" | "md" | "lg" | "xl" | "full";
|
|
352
|
+
noPadding?: boolean;
|
|
353
|
+
fullWidth?: boolean;
|
|
351
354
|
}
|
|
352
355
|
declare const Modal: React$1.FC<ModalProps>;
|
|
353
356
|
|
|
@@ -828,6 +831,8 @@ interface ComboboxProps {
|
|
|
828
831
|
label?: string;
|
|
829
832
|
required?: boolean;
|
|
830
833
|
fontBold?: boolean;
|
|
834
|
+
loading?: boolean;
|
|
835
|
+
loadingText?: string;
|
|
831
836
|
}
|
|
832
837
|
declare const Combobox: React$1.FC<ComboboxProps>;
|
|
833
838
|
|
|
@@ -847,11 +852,14 @@ interface MultiComboboxProps {
|
|
|
847
852
|
showClear?: boolean;
|
|
848
853
|
className?: string;
|
|
849
854
|
disabled?: boolean;
|
|
850
|
-
size?:
|
|
855
|
+
size?: "sm" | "md" | "lg";
|
|
851
856
|
label?: string;
|
|
852
857
|
title?: string;
|
|
853
858
|
required?: boolean;
|
|
854
859
|
displayFormat?: (option: MultiComboboxOption) => string;
|
|
860
|
+
loading?: boolean;
|
|
861
|
+
loadingText?: string;
|
|
862
|
+
emptyText?: string;
|
|
855
863
|
}
|
|
856
864
|
declare const MultiCombobox: React$1.FC<MultiComboboxProps>;
|
|
857
865
|
|
package/dist/index.d.ts
CHANGED
|
@@ -343,11 +343,14 @@ interface ModalProps {
|
|
|
343
343
|
title?: string;
|
|
344
344
|
description?: string;
|
|
345
345
|
className?: string;
|
|
346
|
+
contentClassName?: string;
|
|
346
347
|
overlayClassName?: string;
|
|
347
348
|
showCloseButton?: boolean;
|
|
348
349
|
closeOnOverlayClick?: boolean;
|
|
349
350
|
closeOnEsc?: boolean;
|
|
350
351
|
size?: "sm" | "md" | "lg" | "xl" | "full";
|
|
352
|
+
noPadding?: boolean;
|
|
353
|
+
fullWidth?: boolean;
|
|
351
354
|
}
|
|
352
355
|
declare const Modal: React$1.FC<ModalProps>;
|
|
353
356
|
|
|
@@ -828,6 +831,8 @@ interface ComboboxProps {
|
|
|
828
831
|
label?: string;
|
|
829
832
|
required?: boolean;
|
|
830
833
|
fontBold?: boolean;
|
|
834
|
+
loading?: boolean;
|
|
835
|
+
loadingText?: string;
|
|
831
836
|
}
|
|
832
837
|
declare const Combobox: React$1.FC<ComboboxProps>;
|
|
833
838
|
|
|
@@ -847,11 +852,14 @@ interface MultiComboboxProps {
|
|
|
847
852
|
showClear?: boolean;
|
|
848
853
|
className?: string;
|
|
849
854
|
disabled?: boolean;
|
|
850
|
-
size?:
|
|
855
|
+
size?: "sm" | "md" | "lg";
|
|
851
856
|
label?: string;
|
|
852
857
|
title?: string;
|
|
853
858
|
required?: boolean;
|
|
854
859
|
displayFormat?: (option: MultiComboboxOption) => string;
|
|
860
|
+
loading?: boolean;
|
|
861
|
+
loadingText?: string;
|
|
862
|
+
emptyText?: string;
|
|
855
863
|
}
|
|
856
864
|
declare const MultiCombobox: React$1.FC<MultiComboboxProps>;
|
|
857
865
|
|
package/dist/index.js
CHANGED
|
@@ -2107,7 +2107,7 @@ var sizeStyles3 = {
|
|
|
2107
2107
|
md: "max-w-md",
|
|
2108
2108
|
lg: "max-w-lg",
|
|
2109
2109
|
xl: "max-w-xl",
|
|
2110
|
-
full: "max-w-full
|
|
2110
|
+
full: "max-w-full"
|
|
2111
2111
|
};
|
|
2112
2112
|
var Modal = ({
|
|
2113
2113
|
isOpen,
|
|
@@ -2116,11 +2116,14 @@ var Modal = ({
|
|
|
2116
2116
|
title,
|
|
2117
2117
|
description,
|
|
2118
2118
|
className,
|
|
2119
|
+
contentClassName,
|
|
2119
2120
|
overlayClassName,
|
|
2120
2121
|
showCloseButton = true,
|
|
2121
2122
|
closeOnOverlayClick = true,
|
|
2122
2123
|
closeOnEsc = true,
|
|
2123
|
-
size = "md"
|
|
2124
|
+
size = "md",
|
|
2125
|
+
noPadding = false,
|
|
2126
|
+
fullWidth = false
|
|
2124
2127
|
}) => {
|
|
2125
2128
|
const [isMounted, setIsMounted] = React9.useState(false);
|
|
2126
2129
|
const [isVisible, setIsVisible] = React9.useState(false);
|
|
@@ -2188,7 +2191,8 @@ var Modal = ({
|
|
|
2188
2191
|
className: cn(
|
|
2189
2192
|
"relative w-full rounded-lg bg-card text-card-foreground shadow-xl",
|
|
2190
2193
|
"transition-all duration-200 ease-out",
|
|
2191
|
-
sizeStyles3[size],
|
|
2194
|
+
fullWidth ? "max-w-full" : sizeStyles3[size],
|
|
2195
|
+
fullWidth && "mx-0",
|
|
2192
2196
|
className
|
|
2193
2197
|
),
|
|
2194
2198
|
style: {
|
|
@@ -2217,7 +2221,7 @@ var Modal = ({
|
|
|
2217
2221
|
}
|
|
2218
2222
|
)
|
|
2219
2223
|
] }),
|
|
2220
|
-
/* @__PURE__ */ jsx13("div", { className: "p-6", children })
|
|
2224
|
+
/* @__PURE__ */ jsx13("div", { className: cn("p-6", noPadding && "p-0", contentClassName), children })
|
|
2221
2225
|
]
|
|
2222
2226
|
}
|
|
2223
2227
|
)
|
|
@@ -3846,7 +3850,7 @@ import { ChevronLeft, ChevronRight as ChevronRight2, MoreHorizontal as MoreHoriz
|
|
|
3846
3850
|
import * as React18 from "react";
|
|
3847
3851
|
import { useId as useId2 } from "react";
|
|
3848
3852
|
import { createPortal as createPortal6 } from "react-dom";
|
|
3849
|
-
import { ChevronDown, Search as Search2, Check as Check3, X as X7 } from "lucide-react";
|
|
3853
|
+
import { ChevronDown, Search as Search2, SearchX, Check as Check3, X as X7, Loader2 as Loader22 } from "lucide-react";
|
|
3850
3854
|
import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3851
3855
|
var getOptionLabel = (option) => {
|
|
3852
3856
|
return typeof option === "string" ? option : option.label;
|
|
@@ -3872,7 +3876,9 @@ var Combobox = ({
|
|
|
3872
3876
|
usePortal = true,
|
|
3873
3877
|
label,
|
|
3874
3878
|
required,
|
|
3875
|
-
fontBold = false
|
|
3879
|
+
fontBold = false,
|
|
3880
|
+
loading: loading2 = false,
|
|
3881
|
+
loadingText = "Loading..."
|
|
3876
3882
|
}) => {
|
|
3877
3883
|
const [open, setOpen] = React18.useState(false);
|
|
3878
3884
|
const [query, setQuery] = React18.useState("");
|
|
@@ -3890,6 +3896,7 @@ var Combobox = ({
|
|
|
3890
3896
|
);
|
|
3891
3897
|
const [dropdownPosition, setDropdownPosition] = React18.useState(null);
|
|
3892
3898
|
const triggerRef = React18.useRef(null);
|
|
3899
|
+
const dropdownRef = React18.useRef(null);
|
|
3893
3900
|
const calculatePosition = React18.useCallback(() => {
|
|
3894
3901
|
if (!triggerRef.current) return null;
|
|
3895
3902
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
@@ -3918,11 +3925,10 @@ var Combobox = ({
|
|
|
3918
3925
|
if (!open) return;
|
|
3919
3926
|
const handleClickOutside = (event) => {
|
|
3920
3927
|
const target = event.target;
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
}
|
|
3928
|
+
const triggerEl = triggerRef.current;
|
|
3929
|
+
const dropdownEl = dropdownRef.current;
|
|
3930
|
+
if (triggerEl && !triggerEl.contains(target) && dropdownEl && !dropdownEl.contains(target)) {
|
|
3931
|
+
setOpen(false);
|
|
3926
3932
|
}
|
|
3927
3933
|
};
|
|
3928
3934
|
const handleEscape = (event) => {
|
|
@@ -3966,6 +3972,7 @@ var Combobox = ({
|
|
|
3966
3972
|
"div",
|
|
3967
3973
|
{
|
|
3968
3974
|
"data-combobox-dropdown": true,
|
|
3975
|
+
ref: dropdownRef,
|
|
3969
3976
|
style: {
|
|
3970
3977
|
position: "absolute",
|
|
3971
3978
|
top: dropdownPosition?.top || 0,
|
|
@@ -4023,7 +4030,10 @@ var Combobox = ({
|
|
|
4023
4030
|
}
|
|
4024
4031
|
)
|
|
4025
4032
|
] }),
|
|
4026
|
-
/* @__PURE__ */ jsx24("div", { className: "max-h-64 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ jsx24("ul", { className: "p-1 space-y-1", children:
|
|
4033
|
+
/* @__PURE__ */ jsx24("div", { className: "max-h-64 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ jsx24("ul", { className: "p-1 space-y-1", children: loading2 ? /* @__PURE__ */ jsx24("li", { className: "px-3 py-8 text-center", children: /* @__PURE__ */ jsxs21("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
4034
|
+
/* @__PURE__ */ jsx24(Loader22, { className: "h-6 w-6 animate-spin text-primary" }),
|
|
4035
|
+
/* @__PURE__ */ jsx24("span", { className: "text-sm text-muted-foreground", children: loadingText || "Loading..." })
|
|
4036
|
+
] }) }) : filteredOptions.length > 0 ? filteredOptions.map((item, index) => {
|
|
4027
4037
|
const itemValue = getOptionValue(item);
|
|
4028
4038
|
const itemLabel = getOptionLabel(item);
|
|
4029
4039
|
const isSelected = itemValue === value;
|
|
@@ -4057,9 +4067,18 @@ var Combobox = ({
|
|
|
4057
4067
|
},
|
|
4058
4068
|
`${itemValue}-${index}`
|
|
4059
4069
|
);
|
|
4060
|
-
}) : /* @__PURE__ */ jsx24("li", { className: "px-3 py-8 text-center text-muted-foreground text-sm", children: /* @__PURE__ */ jsxs21("div", { className: "flex flex-col items-center gap-2", children: [
|
|
4061
|
-
/* @__PURE__ */ jsx24(
|
|
4062
|
-
/* @__PURE__ */ jsx24("span", { children: emptyText })
|
|
4070
|
+
}) : /* @__PURE__ */ jsx24("li", { className: "px-3 py-8 text-center text-muted-foreground text-sm", children: /* @__PURE__ */ jsxs21("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
4071
|
+
/* @__PURE__ */ jsx24(SearchX, { className: "h-8 w-8 opacity-40 text-muted-foreground" }),
|
|
4072
|
+
/* @__PURE__ */ jsx24("span", { className: "text-sm", children: emptyText }),
|
|
4073
|
+
query && /* @__PURE__ */ jsx24(
|
|
4074
|
+
"button",
|
|
4075
|
+
{
|
|
4076
|
+
type: "button",
|
|
4077
|
+
onClick: () => setQuery(""),
|
|
4078
|
+
className: "text-xs text-primary hover:underline",
|
|
4079
|
+
children: "Clear search"
|
|
4080
|
+
}
|
|
4081
|
+
)
|
|
4063
4082
|
] }) }) }) })
|
|
4064
4083
|
] })
|
|
4065
4084
|
}
|
|
@@ -4135,7 +4154,15 @@ var Combobox = ({
|
|
|
4135
4154
|
children: /* @__PURE__ */ jsx24(X7, { className: "h-3 w-3" })
|
|
4136
4155
|
}
|
|
4137
4156
|
),
|
|
4138
|
-
/* @__PURE__ */ jsx24(
|
|
4157
|
+
/* @__PURE__ */ jsx24(
|
|
4158
|
+
ChevronDown,
|
|
4159
|
+
{
|
|
4160
|
+
className: cn(
|
|
4161
|
+
"h-4 w-4 text-muted-foreground transition-all duration-200",
|
|
4162
|
+
open && "rotate-180 scale-110 text-primary"
|
|
4163
|
+
)
|
|
4164
|
+
}
|
|
4165
|
+
)
|
|
4139
4166
|
] })
|
|
4140
4167
|
]
|
|
4141
4168
|
}
|
|
@@ -6044,7 +6071,7 @@ function Calendar2({
|
|
|
6044
6071
|
import * as React24 from "react";
|
|
6045
6072
|
import { useId as useId4 } from "react";
|
|
6046
6073
|
import { createPortal as createPortal8 } from "react-dom";
|
|
6047
|
-
import { ChevronDown as ChevronDown2, Search as Search3, Check as Check5 } from "lucide-react";
|
|
6074
|
+
import { ChevronDown as ChevronDown2, Search as Search3, Check as Check5, SearchX as SearchX2, Loader2 as Loader23 } from "lucide-react";
|
|
6048
6075
|
import { jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6049
6076
|
var MultiCombobox = ({
|
|
6050
6077
|
id,
|
|
@@ -6062,7 +6089,10 @@ var MultiCombobox = ({
|
|
|
6062
6089
|
label,
|
|
6063
6090
|
title,
|
|
6064
6091
|
required,
|
|
6065
|
-
displayFormat = (option) => option.label
|
|
6092
|
+
displayFormat = (option) => option.label,
|
|
6093
|
+
loading: loading2 = false,
|
|
6094
|
+
loadingText = "Loading...",
|
|
6095
|
+
emptyText = "No results found"
|
|
6066
6096
|
}) => {
|
|
6067
6097
|
const [query, setQuery] = React24.useState("");
|
|
6068
6098
|
const [open, setOpen] = React24.useState(false);
|
|
@@ -6071,6 +6101,7 @@ var MultiCombobox = ({
|
|
|
6071
6101
|
const listRef = React24.useRef([]);
|
|
6072
6102
|
const [dropdownPosition, setDropdownPosition] = React24.useState(null);
|
|
6073
6103
|
const triggerRef = React24.useRef(null);
|
|
6104
|
+
const dropdownRef = React24.useRef(null);
|
|
6074
6105
|
useShadCNAnimations();
|
|
6075
6106
|
const calculatePosition = React24.useCallback(() => {
|
|
6076
6107
|
if (!triggerRef.current) return null;
|
|
@@ -6100,11 +6131,10 @@ var MultiCombobox = ({
|
|
|
6100
6131
|
if (!open) return;
|
|
6101
6132
|
const handleClickOutside = (event) => {
|
|
6102
6133
|
const target = event.target;
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
}
|
|
6134
|
+
const triggerEl = triggerRef.current;
|
|
6135
|
+
const dropdownEl = dropdownRef.current;
|
|
6136
|
+
if (triggerEl && !triggerEl.contains(target) && dropdownEl && !dropdownEl.contains(target)) {
|
|
6137
|
+
setOpen(false);
|
|
6108
6138
|
}
|
|
6109
6139
|
};
|
|
6110
6140
|
const handleEscape = (event) => {
|
|
@@ -6273,7 +6303,12 @@ var MultiCombobox = ({
|
|
|
6273
6303
|
value.length,
|
|
6274
6304
|
" selected"
|
|
6275
6305
|
] }) : /* @__PURE__ */ jsx31("span", { className: "text-muted-foreground", children: placeholder || "Select..." }) }),
|
|
6276
|
-
/* @__PURE__ */ jsx31(
|
|
6306
|
+
/* @__PURE__ */ jsx31(
|
|
6307
|
+
ChevronDown2,
|
|
6308
|
+
{
|
|
6309
|
+
className: cn("opacity-50 transition-all duration-200", sizeStyles8[size].icon, open && "rotate-180 scale-110 text-primary opacity-100")
|
|
6310
|
+
}
|
|
6311
|
+
)
|
|
6277
6312
|
]
|
|
6278
6313
|
}
|
|
6279
6314
|
),
|
|
@@ -6281,6 +6316,7 @@ var MultiCombobox = ({
|
|
|
6281
6316
|
/* @__PURE__ */ jsx31(
|
|
6282
6317
|
"div",
|
|
6283
6318
|
{
|
|
6319
|
+
ref: dropdownRef,
|
|
6284
6320
|
"data-dropdown": "multicombobox",
|
|
6285
6321
|
style: {
|
|
6286
6322
|
position: "absolute",
|
|
@@ -6298,10 +6334,7 @@ var MultiCombobox = ({
|
|
|
6298
6334
|
children: /* @__PURE__ */ jsxs26(
|
|
6299
6335
|
"div",
|
|
6300
6336
|
{
|
|
6301
|
-
className: cn(
|
|
6302
|
-
"rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
6303
|
-
"backdrop-blur-sm bg-popover/95 border-border/60"
|
|
6304
|
-
),
|
|
6337
|
+
className: cn("rounded-md border bg-popover text-popover-foreground shadow-md", "backdrop-blur-sm bg-popover/95 border-border/60"),
|
|
6305
6338
|
children: [
|
|
6306
6339
|
showClear && value.length > 0 && /* @__PURE__ */ jsx31("div", { className: "px-3 py-2 border-b border-border/60 flex justify-end", children: /* @__PURE__ */ jsx31(
|
|
6307
6340
|
"button",
|
|
@@ -6333,7 +6366,10 @@ var MultiCombobox = ({
|
|
|
6333
6366
|
}
|
|
6334
6367
|
)
|
|
6335
6368
|
] }),
|
|
6336
|
-
/* @__PURE__ */ jsx31("ul", { className: cn("max-h-60 overflow-y-auto p-1", size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"), children:
|
|
6369
|
+
/* @__PURE__ */ jsx31("ul", { className: cn("max-h-60 overflow-y-auto p-1", size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"), children: loading2 ? /* @__PURE__ */ jsx31("li", { className: "px-3 py-8 text-center", children: /* @__PURE__ */ jsxs26("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
6370
|
+
/* @__PURE__ */ jsx31(Loader23, { className: "h-6 w-6 animate-spin text-primary" }),
|
|
6371
|
+
/* @__PURE__ */ jsx31("span", { className: "text-muted-foreground", children: loadingText })
|
|
6372
|
+
] }) }) : filtered.length ? filtered.map((item, index) => {
|
|
6337
6373
|
const isSelected = value.includes(item.value);
|
|
6338
6374
|
const isDisabled = disabledOptions.includes(item.value);
|
|
6339
6375
|
return /* @__PURE__ */ jsxs26(
|
|
@@ -6365,7 +6401,20 @@ var MultiCombobox = ({
|
|
|
6365
6401
|
},
|
|
6366
6402
|
item.value
|
|
6367
6403
|
);
|
|
6368
|
-
}) : /* @__PURE__ */ jsx31(
|
|
6404
|
+
}) : /* @__PURE__ */ jsx31(
|
|
6405
|
+
"li",
|
|
6406
|
+
{
|
|
6407
|
+
className: cn(
|
|
6408
|
+
"px-3 py-8 text-center text-muted-foreground",
|
|
6409
|
+
size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"
|
|
6410
|
+
),
|
|
6411
|
+
children: /* @__PURE__ */ jsxs26("div", { className: "flex flex-col items-center gap-2 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
6412
|
+
/* @__PURE__ */ jsx31(SearchX2, { className: "h-8 w-8 opacity-40 text-muted-foreground" }),
|
|
6413
|
+
/* @__PURE__ */ jsx31("span", { children: emptyText }),
|
|
6414
|
+
query && /* @__PURE__ */ jsx31("button", { type: "button", onClick: () => setQuery(""), className: "text-xs text-primary hover:underline", children: "Clear search" })
|
|
6415
|
+
] })
|
|
6416
|
+
}
|
|
6417
|
+
) })
|
|
6369
6418
|
]
|
|
6370
6419
|
}
|
|
6371
6420
|
)
|
|
@@ -7393,7 +7442,7 @@ function CategoryTreeSelect({ categories, value, onChange, placeholder = "Ch\u1E
|
|
|
7393
7442
|
|
|
7394
7443
|
// ../../components/ui/ImageUpload.tsx
|
|
7395
7444
|
import { useState as useState25, useRef as useRef10, useCallback as useCallback9 } from "react";
|
|
7396
|
-
import { Upload, X as X9, Image as ImageIcon, Loader2 as
|
|
7445
|
+
import { Upload, X as X9, Image as ImageIcon, Loader2 as Loader24, Check as Check7 } from "lucide-react";
|
|
7397
7446
|
import { useTranslations as useTranslations6 } from "next-intl";
|
|
7398
7447
|
import { jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
7399
7448
|
function ImageUpload({
|
|
@@ -7532,7 +7581,7 @@ function ImageUpload({
|
|
|
7532
7581
|
onDrop: handleDrop,
|
|
7533
7582
|
children: [
|
|
7534
7583
|
uploading && /* @__PURE__ */ jsx36("div", { className: "absolute inset-0 bg-background/80 flex items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-3", children: [
|
|
7535
|
-
/* @__PURE__ */ jsx36(
|
|
7584
|
+
/* @__PURE__ */ jsx36(Loader24, { className: "w-6 h-6 animate-spin text-primary" }),
|
|
7536
7585
|
/* @__PURE__ */ jsx36("span", { className: "text-sm font-medium", children: "Uploading..." })
|
|
7537
7586
|
] }) }),
|
|
7538
7587
|
/* @__PURE__ */ jsxs31("div", { className: "space-y-4", children: [
|
|
@@ -10035,11 +10084,44 @@ function DataTable({
|
|
|
10035
10084
|
col.key
|
|
10036
10085
|
)) });
|
|
10037
10086
|
const isServerMode = Boolean(onQueryChange);
|
|
10087
|
+
const processedData = React37.useMemo(() => {
|
|
10088
|
+
if (isServerMode) return data;
|
|
10089
|
+
let result = [...data];
|
|
10090
|
+
if (Object.keys(filters).length > 0) {
|
|
10091
|
+
result = result.filter((row) => {
|
|
10092
|
+
return Object.entries(filters).every(([key, value]) => {
|
|
10093
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
10094
|
+
const col = columns.find((c) => c.key === key);
|
|
10095
|
+
const rowValue = col?.dataIndex ? row[col.dataIndex] : row[key];
|
|
10096
|
+
if (col?.filter?.type === "date" && value instanceof Date) {
|
|
10097
|
+
return new Date(rowValue).toDateString() === value.toDateString();
|
|
10098
|
+
}
|
|
10099
|
+
return String(rowValue ?? "").toLowerCase().includes(String(value).toLowerCase());
|
|
10100
|
+
});
|
|
10101
|
+
});
|
|
10102
|
+
}
|
|
10103
|
+
if (sort) {
|
|
10104
|
+
result.sort((a, b) => {
|
|
10105
|
+
const col = columns.find((c) => c.key === sort.key);
|
|
10106
|
+
const aValue = col?.dataIndex ? a[col.dataIndex] : a[sort.key];
|
|
10107
|
+
const bValue = col?.dataIndex ? b[col.dataIndex] : b[sort.key];
|
|
10108
|
+
if (aValue === bValue) return 0;
|
|
10109
|
+
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
10110
|
+
return sort.order === "asc" ? aValue - bValue : bValue - aValue;
|
|
10111
|
+
}
|
|
10112
|
+
const compare = String(aValue).localeCompare(String(bValue));
|
|
10113
|
+
return sort.order === "asc" ? compare : -compare;
|
|
10114
|
+
});
|
|
10115
|
+
}
|
|
10116
|
+
return result;
|
|
10117
|
+
}, [data, isServerMode, filters, sort, columns]);
|
|
10118
|
+
const totalItems = isServerMode ? total : processedData.length;
|
|
10038
10119
|
const displayedData = isServerMode ? data : React37.useMemo(() => {
|
|
10039
10120
|
const start = (curPage - 1) * curPageSize;
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10121
|
+
if (start >= processedData.length && curPage > 1) {
|
|
10122
|
+
}
|
|
10123
|
+
return processedData.slice(start, start + curPageSize);
|
|
10124
|
+
}, [processedData, curPage, curPageSize]);
|
|
10043
10125
|
return /* @__PURE__ */ jsxs41("div", { className: cn("space-y-2", className), children: [
|
|
10044
10126
|
/* @__PURE__ */ jsxs41("div", { className: "flex items-center justify-between gap-4 mb-1", children: [
|
|
10045
10127
|
/* @__PURE__ */ jsx47("div", { className: "text-sm text-muted-foreground", children: caption }),
|
|
@@ -10111,24 +10193,27 @@ function DataTable({
|
|
|
10111
10193
|
)
|
|
10112
10194
|
] }),
|
|
10113
10195
|
/* @__PURE__ */ jsx47("span", { className: "text-sm", children: "Loading..." })
|
|
10114
|
-
] }) }) }) : !displayedData || displayedData.length === 0 ? /* @__PURE__ */ jsx47(TableRow, { children: /* @__PURE__ */ jsx47(TableCell, { colSpan: visibleColumns.length, className: "text-center py-6 text-muted-foreground", children: "No data" }) }) : displayedData.map((row, idx) =>
|
|
10115
|
-
const
|
|
10116
|
-
return /* @__PURE__ */ jsx47(
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10196
|
+
] }) }) }) : !displayedData || displayedData.length === 0 ? /* @__PURE__ */ jsx47(TableRow, { children: /* @__PURE__ */ jsx47(TableCell, { colSpan: visibleColumns.length, className: "text-center py-6 text-muted-foreground", children: "No data" }) }) : displayedData.map((row, idx) => {
|
|
10197
|
+
const isLastRow = idx === displayedData.length - 1;
|
|
10198
|
+
return /* @__PURE__ */ jsx47(TableRow, { className: cn(densityRowClass, striped && idx % 2 === 0 && "bg-muted/30"), children: visibleColumns.map((col, colIdx) => {
|
|
10199
|
+
const value = col.dataIndex ? row[col.dataIndex] : void 0;
|
|
10200
|
+
return /* @__PURE__ */ jsx47(
|
|
10201
|
+
TableCell,
|
|
10202
|
+
{
|
|
10203
|
+
className: cn(
|
|
10204
|
+
cellPadding,
|
|
10205
|
+
col.align === "right" && "text-right",
|
|
10206
|
+
col.align === "center" && "text-center",
|
|
10207
|
+
columnDividers && colIdx > 0 && "border-l border-border/60",
|
|
10208
|
+
isLastRow && col === visibleColumns[0] && "rounded-bl-md",
|
|
10209
|
+
isLastRow && col === visibleColumns[visibleColumns.length - 1] && "rounded-br-md"
|
|
10210
|
+
),
|
|
10211
|
+
children: col.render ? col.render(value, row, idx) : String(value ?? "")
|
|
10212
|
+
},
|
|
10213
|
+
col.key
|
|
10214
|
+
);
|
|
10215
|
+
}) }, getRowKey(row, idx));
|
|
10216
|
+
}) })
|
|
10132
10217
|
]
|
|
10133
10218
|
}
|
|
10134
10219
|
) }),
|