@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.d.cts CHANGED
@@ -57,6 +57,7 @@ interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElem
57
57
  asContainer?: boolean;
58
58
  noWrap?: boolean;
59
59
  noHoverOverlay?: boolean;
60
+ gradient?: boolean;
60
61
  }
61
62
  declare const Button: React__default.ForwardRefExoticComponent<ButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
62
63
 
@@ -342,11 +343,14 @@ interface ModalProps {
342
343
  title?: string;
343
344
  description?: string;
344
345
  className?: string;
346
+ contentClassName?: string;
345
347
  overlayClassName?: string;
346
348
  showCloseButton?: boolean;
347
349
  closeOnOverlayClick?: boolean;
348
350
  closeOnEsc?: boolean;
349
351
  size?: "sm" | "md" | "lg" | "xl" | "full";
352
+ noPadding?: boolean;
353
+ fullWidth?: boolean;
350
354
  }
351
355
  declare const Modal: React$1.FC<ModalProps>;
352
356
 
@@ -827,6 +831,8 @@ interface ComboboxProps {
827
831
  label?: string;
828
832
  required?: boolean;
829
833
  fontBold?: boolean;
834
+ loading?: boolean;
835
+ loadingText?: string;
830
836
  }
831
837
  declare const Combobox: React$1.FC<ComboboxProps>;
832
838
 
@@ -846,11 +852,14 @@ interface MultiComboboxProps {
846
852
  showClear?: boolean;
847
853
  className?: string;
848
854
  disabled?: boolean;
849
- size?: 'sm' | 'md' | 'lg';
855
+ size?: "sm" | "md" | "lg";
850
856
  label?: string;
851
857
  title?: string;
852
858
  required?: boolean;
853
859
  displayFormat?: (option: MultiComboboxOption) => string;
860
+ loading?: boolean;
861
+ loadingText?: string;
862
+ emptyText?: string;
854
863
  }
855
864
  declare const MultiCombobox: React$1.FC<MultiComboboxProps>;
856
865
 
package/dist/index.d.ts CHANGED
@@ -57,6 +57,7 @@ interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElem
57
57
  asContainer?: boolean;
58
58
  noWrap?: boolean;
59
59
  noHoverOverlay?: boolean;
60
+ gradient?: boolean;
60
61
  }
61
62
  declare const Button: React__default.ForwardRefExoticComponent<ButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
62
63
 
@@ -342,11 +343,14 @@ interface ModalProps {
342
343
  title?: string;
343
344
  description?: string;
344
345
  className?: string;
346
+ contentClassName?: string;
345
347
  overlayClassName?: string;
346
348
  showCloseButton?: boolean;
347
349
  closeOnOverlayClick?: boolean;
348
350
  closeOnEsc?: boolean;
349
351
  size?: "sm" | "md" | "lg" | "xl" | "full";
352
+ noPadding?: boolean;
353
+ fullWidth?: boolean;
350
354
  }
351
355
  declare const Modal: React$1.FC<ModalProps>;
352
356
 
@@ -827,6 +831,8 @@ interface ComboboxProps {
827
831
  label?: string;
828
832
  required?: boolean;
829
833
  fontBold?: boolean;
834
+ loading?: boolean;
835
+ loadingText?: string;
830
836
  }
831
837
  declare const Combobox: React$1.FC<ComboboxProps>;
832
838
 
@@ -846,11 +852,14 @@ interface MultiComboboxProps {
846
852
  showClear?: boolean;
847
853
  className?: string;
848
854
  disabled?: boolean;
849
- size?: 'sm' | 'md' | 'lg';
855
+ size?: "sm" | "md" | "lg";
850
856
  label?: string;
851
857
  title?: string;
852
858
  required?: boolean;
853
859
  displayFormat?: (option: MultiComboboxOption) => string;
860
+ loading?: boolean;
861
+ loadingText?: string;
862
+ emptyText?: string;
854
863
  }
855
864
  declare const MultiCombobox: React$1.FC<MultiComboboxProps>;
856
865
 
package/dist/index.js CHANGED
@@ -71,10 +71,12 @@ var Button = forwardRef(
71
71
  asContainer = false,
72
72
  noWrap = true,
73
73
  noHoverOverlay = false,
74
+ gradient = false,
74
75
  ...rest
75
76
  }, ref) => {
76
77
  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";
77
- const variantStyle = VARIANT_STYLES_BTN[variant] || VARIANT_STYLES_BTN.default;
78
+ const finalVariant = gradient ? "gradient" : variant;
79
+ const variantStyle = VARIANT_STYLES_BTN[finalVariant] || VARIANT_STYLES_BTN.default;
78
80
  const sizeStyle = SIZE_STYLES_BTN[size] || SIZE_STYLES_BTN.md;
79
81
  const SpinnerIcon = Spinner ?? Activity;
80
82
  const [locked, setLocked] = useState(false);
@@ -132,7 +134,7 @@ var Button = forwardRef(
132
134
  "aria-label": rest["aria-label"] || title,
133
135
  ...rest,
134
136
  children: [
135
- !noHoverOverlay && /* @__PURE__ */ 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" }),
137
+ !noHoverOverlay && /* @__PURE__ */ 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" }),
136
138
  loading2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
137
139
  /* @__PURE__ */ jsx(SpinnerIcon, { className: "w-4 h-4 animate-spin" }),
138
140
  loadingText && /* @__PURE__ */ jsx("span", { className: "ml-2", "aria-live": "polite", children: loadingText }),
@@ -2105,7 +2107,7 @@ var sizeStyles3 = {
2105
2107
  md: "max-w-md",
2106
2108
  lg: "max-w-lg",
2107
2109
  xl: "max-w-xl",
2108
- full: "max-w-full mx-4"
2110
+ full: "max-w-full"
2109
2111
  };
2110
2112
  var Modal = ({
2111
2113
  isOpen,
@@ -2114,11 +2116,14 @@ var Modal = ({
2114
2116
  title,
2115
2117
  description,
2116
2118
  className,
2119
+ contentClassName,
2117
2120
  overlayClassName,
2118
2121
  showCloseButton = true,
2119
2122
  closeOnOverlayClick = true,
2120
2123
  closeOnEsc = true,
2121
- size = "md"
2124
+ size = "md",
2125
+ noPadding = false,
2126
+ fullWidth = false
2122
2127
  }) => {
2123
2128
  const [isMounted, setIsMounted] = React9.useState(false);
2124
2129
  const [isVisible, setIsVisible] = React9.useState(false);
@@ -2186,7 +2191,8 @@ var Modal = ({
2186
2191
  className: cn(
2187
2192
  "relative w-full rounded-lg bg-card text-card-foreground shadow-xl",
2188
2193
  "transition-all duration-200 ease-out",
2189
- sizeStyles3[size],
2194
+ fullWidth ? "max-w-full" : sizeStyles3[size],
2195
+ fullWidth && "mx-0",
2190
2196
  className
2191
2197
  ),
2192
2198
  style: {
@@ -2215,7 +2221,7 @@ var Modal = ({
2215
2221
  }
2216
2222
  )
2217
2223
  ] }),
2218
- /* @__PURE__ */ jsx13("div", { className: "p-6", children })
2224
+ /* @__PURE__ */ jsx13("div", { className: cn("p-6", noPadding && "p-0", contentClassName), children })
2219
2225
  ]
2220
2226
  }
2221
2227
  )
@@ -3844,7 +3850,7 @@ import { ChevronLeft, ChevronRight as ChevronRight2, MoreHorizontal as MoreHoriz
3844
3850
  import * as React18 from "react";
3845
3851
  import { useId as useId2 } from "react";
3846
3852
  import { createPortal as createPortal6 } from "react-dom";
3847
- 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";
3848
3854
  import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
3849
3855
  var getOptionLabel = (option) => {
3850
3856
  return typeof option === "string" ? option : option.label;
@@ -3870,7 +3876,9 @@ var Combobox = ({
3870
3876
  usePortal = true,
3871
3877
  label,
3872
3878
  required,
3873
- fontBold = false
3879
+ fontBold = false,
3880
+ loading: loading2 = false,
3881
+ loadingText = "Loading..."
3874
3882
  }) => {
3875
3883
  const [open, setOpen] = React18.useState(false);
3876
3884
  const [query, setQuery] = React18.useState("");
@@ -3888,6 +3896,7 @@ var Combobox = ({
3888
3896
  );
3889
3897
  const [dropdownPosition, setDropdownPosition] = React18.useState(null);
3890
3898
  const triggerRef = React18.useRef(null);
3899
+ const dropdownRef = React18.useRef(null);
3891
3900
  const calculatePosition = React18.useCallback(() => {
3892
3901
  if (!triggerRef.current) return null;
3893
3902
  const rect = triggerRef.current.getBoundingClientRect();
@@ -3916,11 +3925,10 @@ var Combobox = ({
3916
3925
  if (!open) return;
3917
3926
  const handleClickOutside = (event) => {
3918
3927
  const target = event.target;
3919
- if (triggerRef.current && !triggerRef.current.contains(target)) {
3920
- const dropdown = document.querySelector("[data-combobox-dropdown]");
3921
- if (dropdown && !dropdown.contains(target)) {
3922
- setOpen(false);
3923
- }
3928
+ const triggerEl = triggerRef.current;
3929
+ const dropdownEl = dropdownRef.current;
3930
+ if (triggerEl && !triggerEl.contains(target) && dropdownEl && !dropdownEl.contains(target)) {
3931
+ setOpen(false);
3924
3932
  }
3925
3933
  };
3926
3934
  const handleEscape = (event) => {
@@ -3964,6 +3972,7 @@ var Combobox = ({
3964
3972
  "div",
3965
3973
  {
3966
3974
  "data-combobox-dropdown": true,
3975
+ ref: dropdownRef,
3967
3976
  style: {
3968
3977
  position: "absolute",
3969
3978
  top: dropdownPosition?.top || 0,
@@ -4021,7 +4030,10 @@ var Combobox = ({
4021
4030
  }
4022
4031
  )
4023
4032
  ] }),
4024
- /* @__PURE__ */ jsx24("div", { className: "max-h-64 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ jsx24("ul", { className: "p-1 space-y-1", children: filteredOptions.length > 0 ? filteredOptions.map((item, index) => {
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) => {
4025
4037
  const itemValue = getOptionValue(item);
4026
4038
  const itemLabel = getOptionLabel(item);
4027
4039
  const isSelected = itemValue === value;
@@ -4055,9 +4067,18 @@ var Combobox = ({
4055
4067
  },
4056
4068
  `${itemValue}-${index}`
4057
4069
  );
4058
- }) : /* @__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: [
4059
- /* @__PURE__ */ jsx24(Search2, { className: "h-6 w-6 opacity-50" }),
4060
- /* @__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
+ )
4061
4082
  ] }) }) }) })
4062
4083
  ] })
4063
4084
  }
@@ -4133,7 +4154,15 @@ var Combobox = ({
4133
4154
  children: /* @__PURE__ */ jsx24(X7, { className: "h-3 w-3" })
4134
4155
  }
4135
4156
  ),
4136
- /* @__PURE__ */ jsx24(ChevronDown, { className: cn("h-4 w-4 text-muted-foreground transition-transform duration-200", open && "rotate-180") })
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
+ )
4137
4166
  ] })
4138
4167
  ]
4139
4168
  }
@@ -4809,10 +4838,9 @@ var DatePicker = ({
4809
4838
  },
4810
4839
  className: cn(
4811
4840
  size === "sm" ? "w-7 h-7 text-[12px]" : "w-8 h-8 text-sm",
4812
- "datepicker-day rounded-md hover:bg-accent hover:text-accent-foreground",
4813
- "focus:bg-accent focus:text-accent-foreground focus:outline-none",
4841
+ "datepicker-day rounded-md focus:outline-none",
4814
4842
  "transition-colors",
4815
- isSelected && "bg-primary text-primary-foreground hover:bg-primary/90",
4843
+ 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",
4816
4844
  isToday2 && !isSelected && "bg-accent text-accent-foreground font-semibold"
4817
4845
  ),
4818
4846
  children: day
@@ -5963,7 +5991,7 @@ function Calendar2({
5963
5991
  disabled && "opacity-40 cursor-not-allowed",
5964
5992
  isToday2 && !selectedDay && "ring-1 ring-primary/50",
5965
5993
  selectedDay && "bg-primary text-primary-foreground hover:bg-primary/90",
5966
- !selectedDay && "hover:bg-accent"
5994
+ !selectedDay && "hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
5967
5995
  ),
5968
5996
  title: d.toDateString(),
5969
5997
  children: [
@@ -6024,7 +6052,7 @@ function Calendar2({
6024
6052
  disabled && "opacity-40 cursor-not-allowed",
6025
6053
  isToday2 && !selectedDay && "ring-1 ring-primary/50",
6026
6054
  selectedDay && "bg-primary text-primary-foreground hover:bg-primary/90",
6027
- !selectedDay && "hover:bg-accent"
6055
+ !selectedDay && "hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
6028
6056
  ),
6029
6057
  title: d.toDateString(),
6030
6058
  children: [
@@ -6043,7 +6071,7 @@ function Calendar2({
6043
6071
  import * as React24 from "react";
6044
6072
  import { useId as useId4 } from "react";
6045
6073
  import { createPortal as createPortal8 } from "react-dom";
6046
- 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";
6047
6075
  import { jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
6048
6076
  var MultiCombobox = ({
6049
6077
  id,
@@ -6061,7 +6089,10 @@ var MultiCombobox = ({
6061
6089
  label,
6062
6090
  title,
6063
6091
  required,
6064
- displayFormat = (option) => option.label
6092
+ displayFormat = (option) => option.label,
6093
+ loading: loading2 = false,
6094
+ loadingText = "Loading...",
6095
+ emptyText = "No results found"
6065
6096
  }) => {
6066
6097
  const [query, setQuery] = React24.useState("");
6067
6098
  const [open, setOpen] = React24.useState(false);
@@ -6070,6 +6101,7 @@ var MultiCombobox = ({
6070
6101
  const listRef = React24.useRef([]);
6071
6102
  const [dropdownPosition, setDropdownPosition] = React24.useState(null);
6072
6103
  const triggerRef = React24.useRef(null);
6104
+ const dropdownRef = React24.useRef(null);
6073
6105
  useShadCNAnimations();
6074
6106
  const calculatePosition = React24.useCallback(() => {
6075
6107
  if (!triggerRef.current) return null;
@@ -6099,11 +6131,10 @@ var MultiCombobox = ({
6099
6131
  if (!open) return;
6100
6132
  const handleClickOutside = (event) => {
6101
6133
  const target = event.target;
6102
- if (triggerRef.current && !triggerRef.current.contains(target)) {
6103
- const dropdown = document.querySelector('[data-dropdown="multicombobox"]');
6104
- if (dropdown && !dropdown.contains(target)) {
6105
- setOpen(false);
6106
- }
6134
+ const triggerEl = triggerRef.current;
6135
+ const dropdownEl = dropdownRef.current;
6136
+ if (triggerEl && !triggerEl.contains(target) && dropdownEl && !dropdownEl.contains(target)) {
6137
+ setOpen(false);
6107
6138
  }
6108
6139
  };
6109
6140
  const handleEscape = (event) => {
@@ -6272,7 +6303,12 @@ var MultiCombobox = ({
6272
6303
  value.length,
6273
6304
  " selected"
6274
6305
  ] }) : /* @__PURE__ */ jsx31("span", { className: "text-muted-foreground", children: placeholder || "Select..." }) }),
6275
- /* @__PURE__ */ jsx31(ChevronDown2, { className: cn("opacity-50 transition-transform", sizeStyles8[size].icon, open && "rotate-180") })
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
+ )
6276
6312
  ]
6277
6313
  }
6278
6314
  ),
@@ -6280,6 +6316,7 @@ var MultiCombobox = ({
6280
6316
  /* @__PURE__ */ jsx31(
6281
6317
  "div",
6282
6318
  {
6319
+ ref: dropdownRef,
6283
6320
  "data-dropdown": "multicombobox",
6284
6321
  style: {
6285
6322
  position: "absolute",
@@ -6297,10 +6334,7 @@ var MultiCombobox = ({
6297
6334
  children: /* @__PURE__ */ jsxs26(
6298
6335
  "div",
6299
6336
  {
6300
- className: cn(
6301
- "rounded-md border bg-popover text-popover-foreground shadow-md",
6302
- "backdrop-blur-sm bg-popover/95 border-border/60"
6303
- ),
6337
+ className: cn("rounded-md border bg-popover text-popover-foreground shadow-md", "backdrop-blur-sm bg-popover/95 border-border/60"),
6304
6338
  children: [
6305
6339
  showClear && value.length > 0 && /* @__PURE__ */ jsx31("div", { className: "px-3 py-2 border-b border-border/60 flex justify-end", children: /* @__PURE__ */ jsx31(
6306
6340
  "button",
@@ -6332,7 +6366,10 @@ var MultiCombobox = ({
6332
6366
  }
6333
6367
  )
6334
6368
  ] }),
6335
- /* @__PURE__ */ jsx31("ul", { className: cn("max-h-60 overflow-y-auto p-1", size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"), children: filtered.length ? filtered.map((item, index) => {
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) => {
6336
6373
  const isSelected = value.includes(item.value);
6337
6374
  const isDisabled = disabledOptions.includes(item.value);
6338
6375
  return /* @__PURE__ */ jsxs26(
@@ -6364,7 +6401,20 @@ var MultiCombobox = ({
6364
6401
  },
6365
6402
  item.value
6366
6403
  );
6367
- }) : /* @__PURE__ */ jsx31("li", { className: cn("px-3 py-2 text-muted-foreground", size === "lg" ? "text-base" : size === "sm" ? "text-xs" : "text-sm"), children: "No result." }) })
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
+ ) })
6368
6418
  ]
6369
6419
  }
6370
6420
  )
@@ -7392,7 +7442,7 @@ function CategoryTreeSelect({ categories, value, onChange, placeholder = "Ch\u1E
7392
7442
 
7393
7443
  // ../../components/ui/ImageUpload.tsx
7394
7444
  import { useState as useState25, useRef as useRef10, useCallback as useCallback9 } from "react";
7395
- import { Upload, X as X9, Image as ImageIcon, Loader2 as Loader22, Check as Check7 } from "lucide-react";
7445
+ import { Upload, X as X9, Image as ImageIcon, Loader2 as Loader24, Check as Check7 } from "lucide-react";
7396
7446
  import { useTranslations as useTranslations6 } from "next-intl";
7397
7447
  import { jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
7398
7448
  function ImageUpload({
@@ -7531,7 +7581,7 @@ function ImageUpload({
7531
7581
  onDrop: handleDrop,
7532
7582
  children: [
7533
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: [
7534
- /* @__PURE__ */ jsx36(Loader22, { className: "w-6 h-6 animate-spin text-primary" }),
7584
+ /* @__PURE__ */ jsx36(Loader24, { className: "w-6 h-6 animate-spin text-primary" }),
7535
7585
  /* @__PURE__ */ jsx36("span", { className: "text-sm font-medium", children: "Uploading..." })
7536
7586
  ] }) }),
7537
7587
  /* @__PURE__ */ jsxs31("div", { className: "space-y-4", children: [
@@ -10034,11 +10084,44 @@ function DataTable({
10034
10084
  col.key
10035
10085
  )) });
10036
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;
10037
10119
  const displayedData = isServerMode ? data : React37.useMemo(() => {
10038
10120
  const start = (curPage - 1) * curPageSize;
10039
- return data.slice(start, start + curPageSize);
10040
- }, [data, curPage, curPageSize]);
10041
- const totalItems = isServerMode ? total : data.length;
10121
+ if (start >= processedData.length && curPage > 1) {
10122
+ }
10123
+ return processedData.slice(start, start + curPageSize);
10124
+ }, [processedData, curPage, curPageSize]);
10042
10125
  return /* @__PURE__ */ jsxs41("div", { className: cn("space-y-2", className), children: [
10043
10126
  /* @__PURE__ */ jsxs41("div", { className: "flex items-center justify-between gap-4 mb-1", children: [
10044
10127
  /* @__PURE__ */ jsx47("div", { className: "text-sm text-muted-foreground", children: caption }),
@@ -10110,24 +10193,27 @@ function DataTable({
10110
10193
  )
10111
10194
  ] }),
10112
10195
  /* @__PURE__ */ jsx47("span", { className: "text-sm", children: "Loading..." })
10113
- ] }) }) }) : !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) => /* @__PURE__ */ jsx47(TableRow, { className: cn(densityRowClass, striped && idx % 2 === 0 && "bg-muted/30"), children: visibleColumns.map((col, colIdx) => {
10114
- const value = col.dataIndex ? row[col.dataIndex] : void 0;
10115
- return /* @__PURE__ */ jsx47(
10116
- TableCell,
10117
- {
10118
- className: cn(
10119
- cellPadding,
10120
- col.align === "right" && "text-right",
10121
- col.align === "center" && "text-center",
10122
- columnDividers && colIdx > 0 && "border-l border-border/60",
10123
- idx === data.length - 1 && col === visibleColumns[0] && "rounded-bl-md",
10124
- idx === data.length - 1 && col === visibleColumns[visibleColumns.length - 1] && "rounded-br-md"
10125
- ),
10126
- children: col.render ? col.render(value, row, idx) : String(value ?? "")
10127
- },
10128
- col.key
10129
- );
10130
- }) }, getRowKey(row, idx))) })
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
+ }) })
10131
10217
  ]
10132
10218
  }
10133
10219
  ) }),