@yuhuanowo/yunui 0.2.15 → 0.2.16

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.
@@ -1,8 +1,10 @@
1
1
  "use client";
2
- import { cn, useAnchoredPosition } from './chunk-LLNTUA5K.js';
3
- import { useYunUI } from './chunk-U2LNRVMI.js';
2
+ import { cn, useAnchoredPosition } from './chunk-AV5TGEJS.js';
3
+ import { useYunUI } from './chunk-3RT24MSH.js';
4
4
  import * as React7 from 'react';
5
- import { forwardRef, useState, useEffect, useRef, useCallback, useId } from 'react';
5
+ import { forwardRef, useRef, useCallback, useEffect, useState, useId } from 'react';
6
+ import { createPortal } from 'react-dom';
7
+ import { Minus, Check, ChevronDown, ChevronLeft, ChevronRight, Loader2, AlertCircle, EyeOff, Eye, Plus, Search, X, ChevronUp, CheckCircle2, CheckCircle, Info, RefreshCw, Trash2, AlertTriangle } from 'lucide-react';
6
8
  import * as DialogPrimitive from '@radix-ui/react-dialog';
7
9
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
8
10
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
@@ -11,15 +13,10 @@ import * as SliderPrimitive from '@radix-ui/react-slider';
11
13
  import * as ProgressPrimitive from '@radix-ui/react-progress';
12
14
  import * as TabsPrimitive from '@radix-ui/react-tabs';
13
15
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
14
- import { motion, AnimatePresence, useSpring, useTransform } from 'framer-motion';
15
- import { Minus, Check, ChevronDown, ChevronLeft, ChevronRight, Loader2, AlertCircle, EyeOff, Eye, Plus, Search, X, CheckCircle2, CheckCircle, Info, RefreshCw, Trash2, ArrowRight, AlertTriangle } from 'lucide-react';
16
- import { createPortal } from 'react-dom';
16
+ import { motion, AnimatePresence } from 'framer-motion';
17
17
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
18
18
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
19
19
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
20
- import * as Primitive from '@radix-ui/react-collapsible';
21
- import * as PopoverPrimitive from '@radix-ui/react-popover';
22
- import { Toaster as Toaster$1, toast as toast$1 } from 'sonner';
23
20
 
24
21
  function useEscapeKey(onEscape, enabled = true) {
25
22
  const onEscapeRef = useRef(onEscape);
@@ -152,163 +149,6 @@ var SIZE_CLASSES = {
152
149
  var ANIMATION_DURATION = 150;
153
150
  var DEFAULT_MAX_HEIGHT = "85vh";
154
151
  var closeIdCounter = 0;
155
- function Modal({
156
- isOpen,
157
- onClose,
158
- title,
159
- subtitle,
160
- children,
161
- footer,
162
- size = "lg",
163
- className,
164
- showCloseButton = true,
165
- isClosing: externalIsClosing,
166
- setIsClosing: externalSetIsClosing,
167
- showUnsavedBadge = false,
168
- maxHeight = DEFAULT_MAX_HEIGHT,
169
- onBackdropClick
170
- }) {
171
- const t = useYunUI().useT("components.modal");
172
- const modalRef = useRef(null);
173
- const timeoutRef = useRef(null);
174
- const closeIdRef = useRef(0);
175
- const [internalIsClosing, setInternalIsClosing] = useState(false);
176
- const [mounted, setMounted] = useState(false);
177
- const isClosing = externalIsClosing ?? internalIsClosing;
178
- useEffect(() => {
179
- setMounted(true);
180
- return () => setMounted(false);
181
- }, []);
182
- useEffect(() => {
183
- return () => {
184
- if (timeoutRef.current) {
185
- clearTimeout(timeoutRef.current);
186
- timeoutRef.current = null;
187
- }
188
- };
189
- }, []);
190
- const isClosingRef = useRef(isClosing);
191
- isClosingRef.current = isClosing;
192
- const onCloseRef = useRef(onClose);
193
- onCloseRef.current = onClose;
194
- const externalSetIsClosingRef = useRef(externalSetIsClosing);
195
- externalSetIsClosingRef.current = externalSetIsClosing;
196
- const handleClose = useCallback(() => {
197
- if (isClosingRef.current) return;
198
- if (timeoutRef.current) {
199
- clearTimeout(timeoutRef.current);
200
- timeoutRef.current = null;
201
- }
202
- const currentCloseId = ++closeIdCounter;
203
- closeIdRef.current = currentCloseId;
204
- const executeClose = () => {
205
- if (closeIdRef.current === currentCloseId) {
206
- onCloseRef.current();
207
- if (externalSetIsClosingRef.current) {
208
- externalSetIsClosingRef.current(false);
209
- } else {
210
- setInternalIsClosing(false);
211
- }
212
- timeoutRef.current = null;
213
- }
214
- };
215
- if (externalSetIsClosingRef.current) {
216
- externalSetIsClosingRef.current(true);
217
- timeoutRef.current = setTimeout(executeClose, ANIMATION_DURATION);
218
- } else {
219
- setInternalIsClosing(true);
220
- timeoutRef.current = setTimeout(executeClose, ANIMATION_DURATION);
221
- }
222
- }, []);
223
- useEscapeKey(handleClose, isOpen);
224
- useBodyScrollLock(isOpen);
225
- useFocusTrap(modalRef, isOpen);
226
- useEffect(() => {
227
- if (isOpen && internalIsClosing) {
228
- setInternalIsClosing(false);
229
- }
230
- }, [isOpen, internalIsClosing]);
231
- const handleBackdropClick = useCallback((e) => {
232
- if (e.target === e.currentTarget) {
233
- if (onBackdropClick) {
234
- onBackdropClick();
235
- } else {
236
- handleClose();
237
- }
238
- }
239
- }, [onBackdropClick, handleClose]);
240
- if (!isOpen || !mounted) return null;
241
- const sizeClass = SIZE_CLASSES[size] ?? SIZE_CLASSES.lg;
242
- const modalContent = /* @__PURE__ */ jsxs(
243
- "div",
244
- {
245
- className: cn(
246
- "fixed inset-0 flex items-center justify-center p-4 transition-opacity",
247
- isClosing ? "opacity-0 pointer-events-none" : "opacity-100"
248
- ),
249
- style: { zIndex: Z_INDEX.MODAL },
250
- onClick: handleBackdropClick,
251
- role: "dialog",
252
- "aria-modal": "true",
253
- "aria-labelledby": "modal-title",
254
- children: [
255
- /* @__PURE__ */ jsx(
256
- "div",
257
- {
258
- className: cn(
259
- "absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity",
260
- isClosing ? "opacity-0" : "opacity-100"
261
- ),
262
- onClick: handleClose,
263
- "aria-hidden": "true"
264
- }
265
- ),
266
- /* @__PURE__ */ jsxs(
267
- "div",
268
- {
269
- ref: modalRef,
270
- className: cn(
271
- // Glassy surface (not the solid .card) to match Sheet/Dialog/navbar.
272
- "relative w-full rounded-2xl border border-border bg-background/95 backdrop-blur-xl shadow-2xl flex flex-col transition-all",
273
- sizeClass,
274
- isClosing ? "scale-95 opacity-0" : "scale-100 opacity-100",
275
- className
276
- ),
277
- style: { maxHeight },
278
- onClick: (e) => e.stopPropagation(),
279
- tabIndex: -1,
280
- children: [
281
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b border-border shrink-0", children: [
282
- /* @__PURE__ */ jsxs("div", { className: "space-y-1 min-w-0", children: [
283
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
284
- /* @__PURE__ */ jsx("h2", { id: "modal-title", className: "text-lg font-semibold truncate", children: title }),
285
- showUnsavedBadge && /* @__PURE__ */ jsx("span", { className: "badge-warning shrink-0", children: t("unsaved") })
286
- ] }),
287
- subtitle && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground truncate", children: subtitle })
288
- ] }),
289
- showCloseButton && /* @__PURE__ */ jsx(
290
- Button,
291
- {
292
- variant: "ghost",
293
- size: "sm",
294
- onClick: handleClose,
295
- className: "p-2 shrink-0",
296
- "aria-label": t("close"),
297
- children: /* @__PURE__ */ jsx(X, { size: 20 })
298
- }
299
- )
300
- ] }),
301
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-6", children }),
302
- footer && /* @__PURE__ */ jsx("div", { className: "p-4 border-t border-border bg-muted/20 shrink-0", children: footer })
303
- ]
304
- }
305
- )
306
- ]
307
- }
308
- );
309
- return createPortal(modalContent, document.body);
310
- }
311
- var closeIdCounter2 = 0;
312
152
  var variantConfig = {
313
153
  danger: {
314
154
  iconBg: "bg-error-soft",
@@ -384,7 +224,7 @@ function ConfirmModal({
384
224
  clearTimeout(timeoutRef.current);
385
225
  timeoutRef.current = null;
386
226
  }
387
- const currentCloseId = ++closeIdCounter2;
227
+ const currentCloseId = ++closeIdCounter;
388
228
  closeIdRef.current = currentCloseId;
389
229
  setIsClosing(true);
390
230
  timeoutRef.current = setTimeout(() => {
@@ -592,7 +432,7 @@ function Sheet({ open, onClose, children, title, mobileOnly = false }) {
592
432
  }
593
433
  )
594
434
  ] }),
595
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children })
435
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto px-5 py-4", children })
596
436
  ]
597
437
  },
598
438
  "sheet-panel"
@@ -1442,7 +1282,7 @@ var Input = React7.forwardRef(
1442
1282
  "aria-invalid": error ? true : void 0,
1443
1283
  "aria-describedby": describedByIds,
1444
1284
  className: cn(
1445
- "w-full h-10 px-4 bg-background border rounded-xl text-sm outline-none transition-colors",
1285
+ "w-full h-10 px-4 bg-background border border-border rounded-xl text-sm outline-none transition-colors",
1446
1286
  "placeholder:text-muted-foreground",
1447
1287
  "focus:border-ring focus:ring-2 focus:ring-ring/20",
1448
1288
  "disabled:opacity-50 disabled:cursor-not-allowed",
@@ -1476,7 +1316,7 @@ var Textarea = React7.forwardRef(
1476
1316
  "aria-invalid": error ? true : void 0,
1477
1317
  "aria-describedby": describedByIds,
1478
1318
  className: cn(
1479
- "w-full px-4 py-3 bg-background border rounded-xl text-sm outline-none transition-colors resize-none",
1319
+ "w-full px-4 py-3 bg-background border border-border rounded-xl text-sm outline-none transition-colors resize-none",
1480
1320
  "placeholder:text-muted-foreground",
1481
1321
  "focus:border-ring focus:ring-2 focus:ring-ring/20",
1482
1322
  "disabled:opacity-50 disabled:cursor-not-allowed",
@@ -1506,7 +1346,7 @@ var PasswordInput = React7.forwardRef(
1506
1346
  "div",
1507
1347
  {
1508
1348
  className: cn(
1509
- "flex items-center h-10 rounded-xl border bg-background transition-colors",
1349
+ "flex items-center h-10 rounded-xl border border-border bg-background transition-colors",
1510
1350
  "focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20",
1511
1351
  error ? "border-(--error) focus:border-(--error)" : "border-border",
1512
1352
  disabled && "opacity-50",
@@ -1567,7 +1407,7 @@ var NumberInput = React7.forwardRef(
1567
1407
  "div",
1568
1408
  {
1569
1409
  className: cn(
1570
- "relative flex items-stretch rounded-xl border bg-background transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20",
1410
+ "relative flex items-stretch rounded-xl border border-border bg-background transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20",
1571
1411
  error ? "border-(--error) focus:border-(--error)" : "border-border",
1572
1412
  disabled && "opacity-50",
1573
1413
  className
@@ -1723,13 +1563,27 @@ var Card = React7.forwardRef(
1723
1563
  }
1724
1564
  );
1725
1565
  Card.displayName = "Card";
1566
+ var CardHeader = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props }));
1567
+ CardHeader.displayName = "CardHeader";
1568
+ var CardTitle = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: cn("text-lg font-semibold leading-none tracking-tight", className), ...props }));
1569
+ CardTitle.displayName = "CardTitle";
1570
+ var CardDescription = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
1571
+ CardDescription.displayName = "CardDescription";
1572
+ var CardContent = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
1573
+ CardContent.displayName = "CardContent";
1574
+ var CardFooter = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex items-center p-6 pt-0", className), ...props }));
1575
+ CardFooter.displayName = "CardFooter";
1726
1576
  function Badge({ className, variant = "default", ...props }) {
1727
1577
  const variants = {
1728
1578
  default: "bg-muted text-foreground/80",
1729
1579
  success: "bg-success-soft text-success",
1730
1580
  warning: "bg-warning-soft text-warning",
1731
1581
  error: "bg-error-soft text-error",
1732
- info: "bg-info-soft text-info"
1582
+ info: "bg-info-soft text-info",
1583
+ // Structural (shadcn-compatible) variants:
1584
+ secondary: "bg-secondary text-secondary-foreground",
1585
+ outline: "border border-border text-foreground",
1586
+ destructive: "bg-error-soft text-error"
1733
1587
  };
1734
1588
  return /* @__PURE__ */ jsx(
1735
1589
  "span",
@@ -1743,7 +1597,7 @@ function Badge({ className, variant = "default", ...props }) {
1743
1597
  }
1744
1598
  );
1745
1599
  }
1746
- function Separator2({
1600
+ function Separator3({
1747
1601
  className,
1748
1602
  orientation = "horizontal",
1749
1603
  decorative = false,
@@ -1768,13 +1622,15 @@ function Alert({ className, variant = "info", title, icon, children, ...props })
1768
1622
  info: "bg-info-soft text-info border-info-soft",
1769
1623
  success: "bg-success-soft text-success border-success-soft",
1770
1624
  warning: "bg-warning-soft text-warning border-warning-soft",
1771
- error: "bg-error-soft text-error border-error-soft"
1625
+ error: "bg-error-soft text-error border-error-soft",
1626
+ accent: "bg-accent-soft text-accent border-accent-soft"
1772
1627
  };
1773
1628
  const defaultIcon = {
1774
1629
  info: /* @__PURE__ */ jsx(Info, { className: "h-4 w-4" }),
1775
1630
  success: /* @__PURE__ */ jsx(CheckCircle2, { className: "h-4 w-4" }),
1776
1631
  warning: /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
1777
- error: /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" })
1632
+ error: /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
1633
+ accent: /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" })
1778
1634
  };
1779
1635
  const resolvedIcon = icon === void 0 ? defaultIcon[variant] : icon;
1780
1636
  const role = variant === "error" || variant === "warning" ? "alert" : "status";
@@ -1782,7 +1638,7 @@ function Alert({ className, variant = "info", title, icon, children, ...props })
1782
1638
  "div",
1783
1639
  {
1784
1640
  role,
1785
- className: cn("flex gap-3 rounded-xl border p-3 text-sm", styles[variant], className),
1641
+ className: cn("flex gap-3 rounded-xl border border-border p-3 text-sm", styles[variant], className),
1786
1642
  ...props,
1787
1643
  children: [
1788
1644
  resolvedIcon && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mt-0.5 shrink-0", children: resolvedIcon }),
@@ -1885,7 +1741,7 @@ function Steps({ steps, current = 0, className, ...props }) {
1885
1741
  {
1886
1742
  "aria-hidden": "true",
1887
1743
  className: cn(
1888
- "flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-xs font-medium",
1744
+ "flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-border text-xs font-medium",
1889
1745
  state === "done" && "border-transparent bg-primary text-primary-foreground",
1890
1746
  state === "active" && "border-primary text-primary",
1891
1747
  state === "upcoming" && "border-border text-muted-foreground"
@@ -2050,14 +1906,52 @@ var SelectItem = React7.forwardRef(({ className, children, ...props }, ref) => /
2050
1906
  }
2051
1907
  ));
2052
1908
  SelectItem.displayName = SelectPrimitive.Item.displayName;
1909
+ var SelectLabel = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1910
+ SelectPrimitive.Label,
1911
+ {
1912
+ ref,
1913
+ className: cn("px-2 py-1.5 text-xs font-medium text-muted-foreground", className),
1914
+ ...props
1915
+ }
1916
+ ));
1917
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
1918
+ var SelectSeparator = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1919
+ SelectPrimitive.Separator,
1920
+ {
1921
+ ref,
1922
+ className: cn("-mx-1 my-1 h-px bg-border", className),
1923
+ ...props
1924
+ }
1925
+ ));
1926
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
1927
+ var SelectScrollUpButton = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1928
+ SelectPrimitive.ScrollUpButton,
1929
+ {
1930
+ ref,
1931
+ className: cn("flex cursor-default items-center justify-center py-1", className),
1932
+ ...props,
1933
+ children: /* @__PURE__ */ jsx(ChevronUp, { className: "h-4 w-4" })
1934
+ }
1935
+ ));
1936
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
1937
+ var SelectScrollDownButton = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1938
+ SelectPrimitive.ScrollDownButton,
1939
+ {
1940
+ ref,
1941
+ className: cn("flex cursor-default items-center justify-center py-1", className),
1942
+ ...props,
1943
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" })
1944
+ }
1945
+ ));
1946
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
2053
1947
  var Slider = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(
2054
1948
  SliderPrimitive.Root,
2055
1949
  {
2056
1950
  ref,
2057
- className: cn("relative flex w-full touch-none select-none items-center", className),
1951
+ className: cn("relative flex w-full touch-none select-none items-center px-2.5", className),
2058
1952
  ...props,
2059
1953
  children: [
2060
- /* @__PURE__ */ jsx(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-muted", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: "absolute h-full bg-foreground yunui-accent-bg" }) }),
1954
+ /* @__PURE__ */ jsx(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-border", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: "absolute h-full bg-foreground yunui-accent-bg" }) }),
2061
1955
  /* @__PURE__ */ jsx(
2062
1956
  SliderPrimitive.Thumb,
2063
1957
  {
@@ -2090,7 +1984,10 @@ var TabsList = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__
2090
1984
  {
2091
1985
  ref,
2092
1986
  className: cn(
2093
- "inline-flex h-11 items-center justify-center rounded-xl bg-muted p-1 flex-nowrap overflow-x-auto overflow-y-hidden overscroll-x-contain",
1987
+ // max-w-full: inline-flex sizes to content, so without it a long tab
1988
+ // strip grows past its parent and drags the page sideways on narrow
1989
+ // screens instead of engaging its own overflow-x-auto.
1990
+ "inline-flex h-11 max-w-full items-center justify-center rounded-xl bg-muted p-1 flex-nowrap overflow-x-auto overflow-y-hidden overscroll-x-contain",
2094
1991
  className
2095
1992
  ),
2096
1993
  ...props
@@ -2102,7 +1999,7 @@ var TabsTrigger = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE
2102
1999
  {
2103
2000
  ref,
2104
2001
  className: cn(
2105
- "inline-flex items-center justify-center whitespace-nowrap rounded-lg px-4 py-2 text-sm font-medium transition-all",
2002
+ "inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-lg px-4 py-2 text-sm font-medium transition-all",
2106
2003
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2107
2004
  "disabled:pointer-events-none disabled:opacity-50",
2108
2005
  "data-[state=active]:bg-card data-[state=active]:shadow-sm",
@@ -2277,7 +2174,7 @@ var IconButton = React7.forwardRef(
2277
2174
  }
2278
2175
  );
2279
2176
  IconButton.displayName = "IconButton";
2280
- function Label2({ className, ...props }) {
2177
+ function Label3({ className, ...props }) {
2281
2178
  return /* @__PURE__ */ jsx(
2282
2179
  "label",
2283
2180
  {
@@ -2420,678 +2317,164 @@ var DropdownMenuShortcut = ({
2420
2317
  );
2421
2318
  };
2422
2319
  DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
2423
- function CustomSelect({
2424
- options,
2425
- value,
2426
- onChange,
2427
- placeholder,
2428
- searchable = false,
2429
- className = "",
2430
- disabled = false
2320
+ var closeIdCounter2 = 0;
2321
+ function Modal({
2322
+ isOpen,
2323
+ onClose,
2324
+ title,
2325
+ subtitle,
2326
+ children,
2327
+ footer,
2328
+ size = "lg",
2329
+ className,
2330
+ showCloseButton = true,
2331
+ isClosing: externalIsClosing,
2332
+ setIsClosing: externalSetIsClosing,
2333
+ showUnsavedBadge = false,
2334
+ maxHeight = DEFAULT_MAX_HEIGHT,
2335
+ onBackdropClick
2431
2336
  }) {
2432
- const t = useYunUI().useT("common.select");
2433
- const resolvedPlaceholder = placeholder || t("placeholder");
2434
- const [isOpen, setIsOpen] = useState(false);
2435
- const [searchQuery, setSearchQuery] = useState("");
2436
- const [highlighted, setHighlighted] = useState(-1);
2437
- const containerRef = useRef(null);
2438
- const inputRef = useRef(null);
2439
- const triggerRef = useRef(null);
2440
- const listRef = useRef(null);
2441
- const panelRef = useRef(null);
2442
- const { shift, maxHeight } = useAnchoredPosition(isOpen, panelRef);
2443
- const baseId = useId();
2444
- const listboxId = `${baseId}-listbox`;
2445
- const optionId = (i) => `${baseId}-opt-${i}`;
2446
- const selectedOption = options.find((o) => o.value === value);
2447
- const filteredOptions = searchQuery ? options.filter(
2448
- (o) => o.label.toLowerCase().includes(searchQuery.toLowerCase()) || o.value.toLowerCase().includes(searchQuery.toLowerCase())
2449
- ) : options;
2337
+ const t = useYunUI().useT("components.modal");
2338
+ const modalRef = useRef(null);
2339
+ const timeoutRef = useRef(null);
2340
+ const closeIdRef = useRef(0);
2341
+ const [internalIsClosing, setInternalIsClosing] = useState(false);
2342
+ const [mounted, setMounted] = useState(false);
2343
+ const isClosing = externalIsClosing ?? internalIsClosing;
2450
2344
  useEffect(() => {
2451
- const handleClickOutside = (e) => {
2452
- if (containerRef.current && !containerRef.current.contains(e.target)) {
2453
- setIsOpen(false);
2454
- setSearchQuery("");
2345
+ setMounted(true);
2346
+ return () => setMounted(false);
2347
+ }, []);
2348
+ useEffect(() => {
2349
+ return () => {
2350
+ if (timeoutRef.current) {
2351
+ clearTimeout(timeoutRef.current);
2352
+ timeoutRef.current = null;
2455
2353
  }
2456
2354
  };
2457
- document.addEventListener("mousedown", handleClickOutside);
2458
- return () => document.removeEventListener("mousedown", handleClickOutside);
2459
2355
  }, []);
2460
- useEffect(() => {
2461
- if (!isOpen) return;
2462
- if (searchable && inputRef.current) inputRef.current.focus();
2463
- else triggerRef.current?.focus();
2464
- }, [isOpen, searchable]);
2465
- useEffect(() => {
2466
- if (isOpen) {
2467
- const sel = filteredOptions.findIndex((o) => o.value === value);
2468
- setHighlighted(sel >= 0 ? sel : 0);
2469
- } else {
2470
- setHighlighted(-1);
2356
+ const isClosingRef = useRef(isClosing);
2357
+ isClosingRef.current = isClosing;
2358
+ const onCloseRef = useRef(onClose);
2359
+ onCloseRef.current = onClose;
2360
+ const externalSetIsClosingRef = useRef(externalSetIsClosing);
2361
+ externalSetIsClosingRef.current = externalSetIsClosing;
2362
+ const handleClose = useCallback(() => {
2363
+ if (isClosingRef.current) return;
2364
+ if (timeoutRef.current) {
2365
+ clearTimeout(timeoutRef.current);
2366
+ timeoutRef.current = null;
2471
2367
  }
2472
- }, [isOpen]);
2473
- useEffect(() => {
2474
- if (highlighted >= filteredOptions.length) setHighlighted(filteredOptions.length - 1);
2475
- }, [filteredOptions.length, highlighted]);
2476
- useEffect(() => {
2477
- if (!isOpen || highlighted < 0 || !listRef.current) return;
2478
- listRef.current.querySelector(`#${CSS.escape(optionId(highlighted))}`)?.scrollIntoView({ block: "nearest" });
2479
- }, [highlighted, isOpen]);
2480
- const open = () => !disabled && setIsOpen(true);
2481
- const close = () => {
2482
- setIsOpen(false);
2483
- setSearchQuery("");
2484
- triggerRef.current?.focus();
2485
- };
2486
- const handleSelect = (optionValue) => {
2487
- onChange(optionValue);
2488
- setIsOpen(false);
2489
- setSearchQuery("");
2490
- triggerRef.current?.focus();
2491
- };
2492
- const handleKeyDown = (e) => {
2493
- if (disabled) return;
2494
- switch (e.key) {
2495
- case "ArrowDown":
2496
- e.preventDefault();
2497
- if (!isOpen) return open();
2498
- setHighlighted((h) => Math.min(h + 1, filteredOptions.length - 1));
2499
- break;
2500
- case "ArrowUp":
2501
- e.preventDefault();
2502
- if (!isOpen) return open();
2503
- setHighlighted((h) => Math.max(h - 1, 0));
2504
- break;
2505
- case "Home":
2506
- if (isOpen) {
2507
- e.preventDefault();
2508
- setHighlighted(0);
2509
- }
2510
- break;
2511
- case "End":
2512
- if (isOpen) {
2513
- e.preventDefault();
2514
- setHighlighted(filteredOptions.length - 1);
2515
- }
2516
- break;
2517
- case "Enter":
2518
- if (isOpen && filteredOptions[highlighted]) {
2519
- e.preventDefault();
2520
- handleSelect(filteredOptions[highlighted].value);
2521
- } else if (!isOpen) {
2522
- e.preventDefault();
2523
- open();
2524
- }
2525
- break;
2526
- case " ":
2527
- if (!isOpen && !searchable) {
2528
- e.preventDefault();
2529
- open();
2530
- }
2531
- break;
2532
- case "Escape":
2533
- if (isOpen) {
2534
- e.preventDefault();
2535
- close();
2368
+ const currentCloseId = ++closeIdCounter2;
2369
+ closeIdRef.current = currentCloseId;
2370
+ const executeClose = () => {
2371
+ if (closeIdRef.current === currentCloseId) {
2372
+ onCloseRef.current();
2373
+ if (externalSetIsClosingRef.current) {
2374
+ externalSetIsClosingRef.current(false);
2375
+ } else {
2376
+ setInternalIsClosing(false);
2536
2377
  }
2537
- break;
2538
- case "Tab":
2539
- if (isOpen) setIsOpen(false);
2540
- break;
2541
- }
2542
- };
2543
- return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `relative ${className}`, onKeyDown: handleKeyDown, children: [
2544
- /* @__PURE__ */ jsxs(
2545
- "button",
2546
- {
2547
- ref: triggerRef,
2548
- type: "button",
2549
- onClick: () => !disabled && setIsOpen(!isOpen),
2550
- disabled,
2551
- "aria-haspopup": "listbox",
2552
- "aria-expanded": isOpen,
2553
- "aria-controls": isOpen ? listboxId : void 0,
2554
- "aria-activedescendant": isOpen && !searchable && highlighted >= 0 ? optionId(highlighted) : void 0,
2555
- className: `
2556
- w-full flex items-center justify-between gap-2 px-3 py-2
2557
- rounded-xl border border-(--border-default) bg-(--bg-elevated)
2558
- hover:border-(--border-strong) hover:bg-(--bg-hover)
2559
- transition-all duration-200 text-sm
2560
- ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
2561
- ${isOpen ? "border-primary ring-2 ring-primary/20" : ""}
2562
- `,
2563
- children: [
2564
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
2565
- selectedOption?.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: selectedOption.icon }),
2566
- /* @__PURE__ */ jsx("span", { className: `truncate ${!selectedOption ? "text-muted-foreground" : ""}`, children: selectedOption ? selectedOption.label : resolvedPlaceholder })
2567
- ] }),
2568
- /* @__PURE__ */ jsx(
2569
- ChevronDown,
2570
- {
2571
- size: 16,
2572
- className: `shrink-0 text-muted-foreground transition-transform ${isOpen ? "rotate-180" : ""}`
2573
- }
2574
- )
2575
- ]
2576
- }
2577
- ),
2578
- isOpen && /* @__PURE__ */ jsxs(
2579
- "div",
2580
- {
2581
- ref: panelRef,
2582
- style: { marginLeft: shift, maxHeight },
2583
- className: "\n absolute z-50 w-full mt-2\n rounded-2xl border border-border\n bg-background/60 backdrop-blur-2xl text-popover-foreground\n shadow-lg shadow-black/5\n max-h-64 overflow-hidden flex flex-col\n animate-in fade-in-0 zoom-in-95 duration-200\n ",
2584
- children: [
2585
- searchable && /* @__PURE__ */ jsx("div", { className: "px-2.5 pb-2 pt-1.5 border-b border-(--border-subtle)", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
2586
- /* @__PURE__ */ jsx(Search, { size: 14, className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }),
2587
- /* @__PURE__ */ jsx(
2588
- "input",
2589
- {
2590
- ref: inputRef,
2591
- type: "text",
2592
- role: "combobox",
2593
- "aria-expanded": isOpen,
2594
- "aria-controls": listboxId,
2595
- "aria-activedescendant": highlighted >= 0 ? optionId(highlighted) : void 0,
2596
- "aria-autocomplete": "list",
2597
- value: searchQuery,
2598
- onChange: (e) => setSearchQuery(e.target.value),
2599
- placeholder: t("search"),
2600
- "aria-label": t("search"),
2601
- className: "w-full pl-9 pr-8 py-1.5 text-sm rounded-lg\n bg-(--bg-muted) border border-transparent\n focus:border-primary focus:outline-none focus:bg-(--bg-elevated) transition-colors"
2602
- }
2603
- ),
2604
- searchQuery && /* @__PURE__ */ jsx(
2605
- "button",
2606
- {
2607
- type: "button",
2608
- onClick: () => setSearchQuery(""),
2609
- "aria-label": t("clearSearch"),
2610
- className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded-md hover:bg-(--bg-hover)",
2611
- title: t("clearSearch"),
2612
- children: /* @__PURE__ */ jsx(X, { size: 12 })
2613
- }
2614
- )
2615
- ] }) }),
2616
- /* @__PURE__ */ jsx(
2617
- "div",
2618
- {
2619
- ref: listRef,
2620
- role: "listbox",
2621
- id: listboxId,
2622
- className: "flex-1 min-h-0 max-h-52 overflow-y-auto overscroll-contain p-1",
2623
- children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground text-center whitespace-nowrap", children: t("noOptions") }) : filteredOptions.map((option, i) => {
2624
- const isSelected = option.value === value;
2625
- const isHigh = i === highlighted;
2626
- return /* @__PURE__ */ jsxs(
2627
- "button",
2628
- {
2629
- id: optionId(i),
2630
- type: "button",
2631
- role: "option",
2632
- "aria-selected": isSelected,
2633
- "data-highlighted": isHigh ? "" : void 0,
2634
- onClick: () => handleSelect(option.value),
2635
- onMouseEnter: () => setHighlighted(i),
2636
- className: `dropdown-item w-full text-left outline-none ${isSelected ? "active" : ""}`,
2637
- children: [
2638
- option.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 w-5 h-5 flex items-center justify-center", children: option.icon }),
2639
- /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
2640
- /* @__PURE__ */ jsx("div", { className: "truncate", children: option.label }),
2641
- option.description && /* @__PURE__ */ jsx("div", { className: "text-xs font-normal text-muted-foreground truncate", children: option.description })
2642
- ] })
2643
- ]
2644
- },
2645
- option.value
2646
- );
2647
- })
2648
- }
2649
- )
2650
- ]
2378
+ timeoutRef.current = null;
2651
2379
  }
2652
- )
2653
- ] });
2654
- }
2655
- function SegmentedSelect({
2656
- options,
2657
- value,
2658
- onChange,
2659
- className,
2660
- disabled = false
2661
- }) {
2662
- return /* @__PURE__ */ jsx("div", { className: cn("flex gap-1 flex-wrap", className), children: options.map((opt) => {
2663
- const Icon2 = opt.icon;
2664
- return /* @__PURE__ */ jsxs(
2665
- "button",
2666
- {
2667
- type: "button",
2668
- onClick: () => !disabled && onChange(opt.value),
2669
- disabled,
2670
- "aria-pressed": value === opt.value,
2671
- title: opt.desc,
2672
- className: cn(
2673
- "inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-medium border rounded-lg whitespace-nowrap transition-all duration-150 ease cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
2674
- value === opt.value ? "text-foreground border-(--border-strong) bg-accent-subtle hover:bg-accent-muted hover:shadow-xs" : "text-muted-foreground border-(--border-default) bg-muted/50 hover:text-foreground hover:border-(--border-strong) hover:bg-muted",
2675
- disabled && "opacity-50 cursor-not-allowed pointer-events-none"
2676
- ),
2677
- children: [
2678
- Icon2 && /* @__PURE__ */ jsx(Icon2, { size: 14 }),
2679
- opt.label
2680
- ]
2681
- },
2682
- String(opt.value)
2683
- );
2684
- }) });
2685
- }
2686
- function NavTabs({ tabs, activeKey, onChange, className = "", ariaLabel }) {
2687
- const { Link } = useYunUI();
2688
- return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("nav", { className: "flex items-center gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain", "aria-label": ariaLabel, children: tabs.map((tab) => {
2689
- const active = tab.key === activeKey;
2690
- const cls = `nav-tab ${active ? "active" : ""}`;
2691
- return tab.href ? /* @__PURE__ */ jsx(Link, { href: tab.href, className: cls, "aria-current": active ? "page" : void 0, children: tab.label }, tab.key) : /* @__PURE__ */ jsx(
2692
- "button",
2693
- {
2694
- type: "button",
2695
- onClick: () => onChange?.(tab.key),
2696
- className: cls,
2697
- "aria-current": active ? "true" : void 0,
2698
- children: tab.label
2699
- },
2700
- tab.key
2701
- );
2702
- }) }) });
2703
- }
2704
- function ShinyButton({
2705
- children,
2706
- className,
2707
- href,
2708
- onClick
2709
- }) {
2710
- const { Link } = useYunUI();
2711
- const ButtonContent = /* @__PURE__ */ jsxs(
2712
- "div",
2713
- {
2714
- className: cn(
2715
- "group relative flex items-center justify-center gap-2 overflow-hidden rounded-xl bg-(--text-primary) px-8 py-3 font-semibold text-background transition-all hover:ring-2 hover:ring-(--accent) hover:ring-offset-2 hover:ring-offset-background",
2716
- className
2717
- ),
2718
- children: [
2719
- /* @__PURE__ */ jsxs("span", { className: "relative z-10 flex items-center gap-2", children: [
2720
- children,
2721
- /* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4 transition-transform group-hover:translate-x-1" })
2722
- ] }),
2723
- /* @__PURE__ */ jsx("div", { className: "absolute inset-0 -z-10 block animate-shimmer bg-linear-to-r from-transparent via-(--text-primary)/10 to-transparent bg-size-[200%_100%]" })
2724
- ]
2380
+ };
2381
+ if (externalSetIsClosingRef.current) {
2382
+ externalSetIsClosingRef.current(true);
2383
+ timeoutRef.current = setTimeout(executeClose, ANIMATION_DURATION);
2384
+ } else {
2385
+ setInternalIsClosing(true);
2386
+ timeoutRef.current = setTimeout(executeClose, ANIMATION_DURATION);
2725
2387
  }
2726
- );
2727
- const focusCls = "rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-(--accent) focus-visible:ring-offset-2 focus-visible:ring-offset-background";
2728
- if (href) {
2729
- return /* @__PURE__ */ jsx(Link, { href, onClick, className: focusCls, children: ButtonContent });
2730
- }
2731
- return /* @__PURE__ */ jsx("button", { type: "button", onClick, className: focusCls, children: ButtonContent });
2732
- }
2733
- function Marquee({
2734
- className,
2735
- reverse,
2736
- pauseOnHover = false,
2737
- children,
2738
- vertical = false,
2739
- repeat = 4,
2740
- ...props
2741
- }) {
2742
- return /* @__PURE__ */ jsx(
2743
- "div",
2744
- {
2745
- ...props,
2746
- className: cn(
2747
- "group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] gap-(--gap)",
2748
- {
2749
- "flex-row": !vertical,
2750
- "flex-col": vertical
2751
- },
2752
- className
2753
- ),
2754
- children: Array(repeat).fill(0).map((_, i) => /* @__PURE__ */ jsx(
2755
- "div",
2756
- {
2757
- className: cn("flex shrink-0 justify-around gap-(--gap)", {
2758
- "animate-marquee flex-row": !vertical,
2759
- "animate-marquee-vertical flex-col": vertical,
2760
- "group-hover:[animation-play-state:paused]": pauseOnHover,
2761
- "[animation-direction:reverse]": reverse
2762
- }),
2763
- children
2764
- },
2765
- i
2766
- ))
2388
+ }, []);
2389
+ useEscapeKey(handleClose, isOpen);
2390
+ useBodyScrollLock(isOpen);
2391
+ useFocusTrap(modalRef, isOpen);
2392
+ useEffect(() => {
2393
+ if (isOpen && internalIsClosing) {
2394
+ setInternalIsClosing(false);
2767
2395
  }
2768
- );
2769
- }
2770
- var BentoGrid = ({
2771
- className,
2772
- children
2773
- }) => {
2774
- return /* @__PURE__ */ jsx(
2775
- "div",
2776
- {
2777
- className: cn(
2778
- "grid grid-cols-1 md:grid-cols-3 gap-6 max-w-7xl mx-auto",
2779
- className
2780
- ),
2781
- children
2396
+ }, [isOpen, internalIsClosing]);
2397
+ const handleBackdropClick = useCallback((e) => {
2398
+ if (e.target === e.currentTarget) {
2399
+ if (onBackdropClick) {
2400
+ onBackdropClick();
2401
+ } else {
2402
+ handleClose();
2403
+ }
2782
2404
  }
2783
- );
2784
- };
2785
- var BentoCard = ({
2786
- className,
2787
- title,
2788
- description,
2789
- header,
2790
- icon
2791
- }) => {
2792
- return /* @__PURE__ */ jsxs(
2405
+ }, [onBackdropClick, handleClose]);
2406
+ if (!isOpen || !mounted) return null;
2407
+ const sizeClass = SIZE_CLASSES[size] ?? SIZE_CLASSES.lg;
2408
+ const modalContent = /* @__PURE__ */ jsxs(
2793
2409
  "div",
2794
2410
  {
2795
2411
  className: cn(
2796
- "row-span-1 glass-card p-6 flex flex-col justify-between space-y-4 group/bento overflow-hidden",
2797
- className
2412
+ "fixed inset-0 flex items-center justify-center p-4 transition-opacity",
2413
+ isClosing ? "opacity-0 pointer-events-none" : "opacity-100"
2798
2414
  ),
2415
+ style: { zIndex: Z_INDEX.MODAL },
2416
+ onClick: handleBackdropClick,
2417
+ role: "dialog",
2418
+ "aria-modal": "true",
2419
+ "aria-labelledby": "modal-title",
2799
2420
  children: [
2800
- header,
2801
- /* @__PURE__ */ jsxs("div", { className: "group-hover/bento:translate-x-2 transition duration-200", children: [
2802
- /* @__PURE__ */ jsx("div", { className: "mb-2 text-[var(--text-primary)]", children: icon }),
2803
- /* @__PURE__ */ jsx("div", { className: "font-semibold text-[var(--text-primary)] text-lg mb-2 mt-2", children: title }),
2804
- /* @__PURE__ */ jsx("div", { className: "font-normal text-[var(--text-secondary)] text-sm leading-relaxed", children: description })
2805
- ] })
2806
- ]
2807
- }
2808
- );
2809
- };
2810
- var Collapsible = Primitive.Root;
2811
- var CollapsibleTrigger2 = Primitive.CollapsibleTrigger;
2812
- var CollapsibleContent2 = forwardRef(({ children, ...props }, ref) => {
2813
- const [mounted, setMounted] = useState(false);
2814
- useEffect(() => {
2815
- setMounted(true);
2816
- }, []);
2817
- return /* @__PURE__ */ jsx(
2818
- Primitive.CollapsibleContent,
2819
- {
2820
- ref,
2821
- ...props,
2822
- className: cn(
2823
- "overflow-hidden",
2824
- mounted && "data-[state=closed]:animate-fd-collapsible-up data-[state=open]:animate-fd-collapsible-down",
2825
- props.className
2826
- ),
2827
- children
2828
- }
2829
- );
2830
- });
2831
- CollapsibleContent2.displayName = Primitive.CollapsibleContent.displayName;
2832
- var Popover = PopoverPrimitive.Root;
2833
- var PopoverTrigger = PopoverPrimitive.Trigger;
2834
- var PopoverContent = React7.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
2835
- PopoverPrimitive.Content,
2836
- {
2837
- ref,
2838
- align,
2839
- sideOffset,
2840
- side: "bottom",
2841
- className: cn(
2842
- "z-50 origin-(--radix-popover-content-transform-origin) overflow-y-auto max-h-(--radix-popover-content-available-height) min-w-[240px] max-w-[98vw] rounded-2xl border border-border bg-background/60 backdrop-blur-2xl p-2 text-sm text-popover-foreground shadow-lg shadow-black/5 focus-visible:outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
2843
- className
2844
- ),
2845
- ...props
2846
- }
2847
- ) }));
2848
- PopoverContent.displayName = PopoverPrimitive.Content.displayName;
2849
- var PopoverClose2 = PopoverPrimitive.PopoverClose;
2850
- var sizeClasses = {
2851
- sm: {
2852
- track: "w-8 h-4",
2853
- thumb: "w-2.5 h-2.5",
2854
- thumbTranslate: "translate-x-3.5"
2855
- },
2856
- md: {
2857
- track: "w-11 h-6",
2858
- thumb: "w-4 h-4",
2859
- thumbTranslate: "translate-x-5"
2860
- }
2861
- };
2862
- var variantClasses = {
2863
- default: {
2864
- checkedTrack: "border-primary bg-primary/10",
2865
- uncheckedTrack: "border-(--border-strong) bg-muted",
2866
- checkedThumb: "bg-primary",
2867
- uncheckedThumb: "bg-(--border-strong)"
2868
- },
2869
- success: {
2870
- checkedTrack: "border-(--success) bg-success-soft",
2871
- uncheckedTrack: "border-(--border-strong) bg-muted",
2872
- checkedThumb: "bg-(--success)",
2873
- uncheckedThumb: "bg-(--border-strong)"
2874
- },
2875
- warning: {
2876
- checkedTrack: "border-(--warning) bg-warning-soft",
2877
- uncheckedTrack: "border-(--border-strong) bg-muted",
2878
- checkedThumb: "bg-(--warning)",
2879
- uncheckedThumb: "bg-(--border-strong)"
2880
- },
2881
- danger: {
2882
- checkedTrack: "border-(--error) bg-error-soft",
2883
- uncheckedTrack: "border-(--border-strong) bg-muted",
2884
- checkedThumb: "bg-(--error)",
2885
- uncheckedThumb: "bg-(--border-strong)"
2886
- }
2887
- };
2888
- var Switch = forwardRef(
2889
- ({ checked, onCheckedChange, disabled = false, size = "sm", variant = "default", className = "", id }, ref) => {
2890
- const sizeClass = sizeClasses[size];
2891
- const variantClass = variantClasses[variant];
2892
- return /* @__PURE__ */ jsx(
2893
- "button",
2894
- {
2895
- ref,
2896
- type: "button",
2897
- role: "switch",
2898
- "aria-checked": checked,
2899
- id,
2900
- onClick: () => !disabled && onCheckedChange(!checked),
2901
- disabled,
2902
- className: `
2903
- ${sizeClass.track} rounded-full border-2 flex items-center px-0.5
2904
- transition-all duration-200 ease-in-out
2905
- outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background
2906
- ${checked ? variantClass.checkedTrack : variantClass.uncheckedTrack}
2907
- ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
2908
- ${className}
2909
- `,
2910
- children: /* @__PURE__ */ jsx(
2911
- "span",
2421
+ /* @__PURE__ */ jsx(
2422
+ "div",
2912
2423
  {
2913
- className: `
2914
- ${sizeClass.thumb} rounded-full transition-all duration-200 ease-in-out
2915
- ${checked ? variantClass.checkedThumb + " " + sizeClass.thumbTranslate : variantClass.uncheckedThumb + " translate-x-0"}
2916
- shadow-sm
2917
- `
2424
+ className: cn(
2425
+ "absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity",
2426
+ isClosing ? "opacity-0" : "opacity-100"
2427
+ ),
2428
+ onClick: handleClose,
2429
+ "aria-hidden": "true"
2430
+ }
2431
+ ),
2432
+ /* @__PURE__ */ jsxs(
2433
+ "div",
2434
+ {
2435
+ ref: modalRef,
2436
+ className: cn(
2437
+ // Glassy surface (not the solid .card) to match Sheet/Dialog/navbar.
2438
+ "relative w-full rounded-2xl border border-border bg-background/95 backdrop-blur-xl shadow-2xl flex flex-col transition-all",
2439
+ sizeClass,
2440
+ isClosing ? "scale-95 opacity-0" : "scale-100 opacity-100",
2441
+ className
2442
+ ),
2443
+ style: { maxHeight },
2444
+ onClick: (e) => e.stopPropagation(),
2445
+ tabIndex: -1,
2446
+ children: [
2447
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b border-border shrink-0", children: [
2448
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1 min-w-0", children: [
2449
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2450
+ /* @__PURE__ */ jsx("h2", { id: "modal-title", className: "text-lg font-semibold truncate", children: title }),
2451
+ showUnsavedBadge && /* @__PURE__ */ jsx("span", { className: "badge-warning shrink-0", children: t("unsaved") })
2452
+ ] }),
2453
+ subtitle && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground truncate", children: subtitle })
2454
+ ] }),
2455
+ showCloseButton && /* @__PURE__ */ jsx(
2456
+ Button,
2457
+ {
2458
+ variant: "ghost",
2459
+ size: "sm",
2460
+ onClick: handleClose,
2461
+ className: "p-2 shrink-0",
2462
+ "aria-label": t("close"),
2463
+ children: /* @__PURE__ */ jsx(X, { size: 20 })
2464
+ }
2465
+ )
2466
+ ] }),
2467
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-6", children }),
2468
+ footer && /* @__PURE__ */ jsx("div", { className: "p-4 border-t border-border bg-muted/20 shrink-0", children: footer })
2469
+ ]
2918
2470
  }
2919
2471
  )
2920
- }
2921
- );
2922
- }
2923
- );
2924
- Switch.displayName = "Switch";
2925
- function AnimatedNumber({ value, suffix = "", decimals = 0 }) {
2926
- const animatedValue = useSpring(0, { stiffness: 50, damping: 15 });
2927
- const displayValue = useTransform(animatedValue, (latest) => {
2928
- const numStr = decimals > 0 ? latest.toFixed(decimals) : Math.round(latest).toString();
2929
- return Number(numStr).toString() + suffix;
2930
- });
2931
- useEffect(() => {
2932
- animatedValue.set(value);
2933
- }, [animatedValue, value]);
2934
- return /* @__PURE__ */ jsx(motion.span, { children: displayValue });
2935
- }
2936
- function Toaster() {
2937
- return /* @__PURE__ */ jsx(
2938
- Toaster$1,
2939
- {
2940
- position: "bottom-right",
2941
- toastOptions: {
2942
- classNames: {
2943
- toast: "bg-card border border-border rounded-xl shadow-lg p-4",
2944
- title: "text-sm font-medium",
2945
- description: "text-xs text-muted-foreground",
2946
- actionButton: "bg-foreground text-background text-xs px-3 py-1.5 rounded-lg",
2947
- cancelButton: "text-muted-foreground text-xs px-3 py-1.5 rounded-lg hover:bg-muted"
2948
- }
2949
- }
2472
+ ]
2950
2473
  }
2951
2474
  );
2952
- }
2953
- var toast = {
2954
- success: (message, description) => {
2955
- toast$1.success(message, {
2956
- description,
2957
- icon: /* @__PURE__ */ jsx(CheckCircle2, { className: "w-5 h-5 text-success" })
2958
- });
2959
- },
2960
- error: (message, description) => {
2961
- toast$1.error(message, {
2962
- description,
2963
- icon: /* @__PURE__ */ jsx(AlertCircle, { className: "w-5 h-5 text-error" })
2964
- });
2965
- },
2966
- info: (message, description) => {
2967
- toast$1.info(message, {
2968
- description,
2969
- icon: /* @__PURE__ */ jsx(Info, { className: "w-5 h-5 text-info" })
2970
- });
2971
- },
2972
- warning: (message, description) => {
2973
- toast$1.warning(message, {
2974
- description,
2975
- icon: /* @__PURE__ */ jsx(AlertTriangle, { className: "w-5 h-5 text-warning" })
2976
- });
2977
- },
2978
- loading: (message) => {
2979
- return toast$1.loading(message, {
2980
- icon: /* @__PURE__ */ jsx(Loader2, { className: "w-5 h-5 animate-spin" })
2981
- });
2982
- },
2983
- dismiss: (id) => {
2984
- toast$1.dismiss(id);
2985
- },
2986
- promise: (promise, messages) => {
2987
- return toast$1.promise(promise, {
2988
- loading: messages.loading,
2989
- success: messages.success,
2990
- error: messages.error
2991
- });
2992
- }
2993
- };
2994
- var YUNUI_PALETTES = [
2995
- "gray",
2996
- "sand",
2997
- "slate",
2998
- "mint",
2999
- "rose",
3000
- "dusk",
3001
- "red",
3002
- "orange",
3003
- "amber",
3004
- "yellow",
3005
- "lime",
3006
- "moss",
3007
- "green",
3008
- "emerald",
3009
- "teal",
3010
- "aqua",
3011
- "cyan",
3012
- "blue",
3013
- "indigo",
3014
- "violet",
3015
- "plum",
3016
- "magenta",
3017
- "fuchsia",
3018
- "pink"
3019
- ];
3020
- var YUNUI_THEME_PRESETS = {
3021
- aurora: { label: "Aurora", brand: "blue", accent: "violet", neutral: "slate" },
3022
- sunset: { label: "Sunset", brand: "orange", accent: "pink", neutral: "sand" },
3023
- forest: { label: "Forest", brand: "green", accent: "lime", neutral: "gray" },
3024
- ocean: { label: "Ocean", brand: "cyan", accent: "teal", neutral: "slate" },
3025
- grape: { label: "Grape", brand: "violet", accent: "magenta", neutral: "dusk" },
3026
- ember: { label: "Ember", brand: "red", accent: "amber", neutral: "sand" },
3027
- lagoon: { label: "Lagoon", brand: "teal", accent: "emerald", neutral: "mint" },
3028
- blossom: { label: "Blossom", brand: "pink", accent: "fuchsia", neutral: "rose" },
3029
- royal: { label: "Royal", brand: "indigo", accent: "blue", neutral: "slate" },
3030
- citrus: { label: "Citrus", brand: "lime", accent: "yellow", neutral: "sand" },
3031
- orchid: { label: "Orchid", brand: "plum", accent: "violet", neutral: "dusk" },
3032
- mono: { label: "Mono", brand: "gray", accent: "gray", neutral: "gray" }
3033
- };
3034
- var ATTR = {
3035
- brand: "data-brand",
3036
- accent: "data-accent",
3037
- neutral: "data-neutral",
3038
- solid: "data-solid",
3039
- surface: "data-surface",
3040
- theme: "data-theme",
3041
- accentSource: "data-accent-source"
3042
- };
3043
- function resolveTarget(el) {
3044
- if (el) return el;
3045
- return typeof document !== "undefined" ? document.documentElement : null;
3046
- }
3047
- function applyTheme(theme, el) {
3048
- const target = resolveTarget(el);
3049
- if (!target) return;
3050
- for (const key of Object.keys(theme)) {
3051
- const value = theme[key];
3052
- const attr = ATTR[key];
3053
- if (!attr) continue;
3054
- if (value == null) target.removeAttribute(attr);
3055
- else target.setAttribute(attr, value);
3056
- }
3057
- }
3058
- function readTheme(el) {
3059
- const target = resolveTarget(el);
3060
- const out = {};
3061
- if (!target) return out;
3062
- for (const key of Object.keys(ATTR)) {
3063
- const v = target.getAttribute(ATTR[key]);
3064
- if (v != null) out[key] = v;
3065
- }
3066
- return out;
3067
- }
3068
- var STORAGE_KEY = "yunui-theme";
3069
- function useYunUITheme(defaults = {}) {
3070
- const [theme, setTheme] = React7.useState(defaults);
3071
- React7.useEffect(() => {
3072
- let stored = {};
3073
- try {
3074
- stored = JSON.parse(localStorage.getItem(STORAGE_KEY) || "{}");
3075
- } catch {
3076
- }
3077
- const merged = { ...defaults, ...stored };
3078
- setTheme(merged);
3079
- applyTheme(merged);
3080
- }, []);
3081
- const update = React7.useCallback((patch) => {
3082
- setTheme((prev) => {
3083
- const next = { ...prev, ...patch };
3084
- applyTheme(next);
3085
- try {
3086
- localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
3087
- } catch {
3088
- }
3089
- return next;
3090
- });
3091
- }, []);
3092
- return [theme, update];
2475
+ return createPortal(modalContent, document.body);
3093
2476
  }
3094
2477
 
3095
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AnimatedNumber, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Column, Combobox, ConfirmModal, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, Grid, IconButton, InlineCode, InlineStatus, Input, Kbd, Label2 as Label, Marquee, Modal, MotionDiv, MotionSpan, NavTabs, NumberInput, PageLoader, Pagination, PasswordInput, Popover, PopoverClose2 as PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SearchInput, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, ShinyButton, Skeleton, Slider, Spinner, Stack, StatusIndicator, Steps, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, YUNUI_PALETTES, YUNUI_THEME_PRESETS, applyTheme, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme };
3096
- //# sourceMappingURL=chunk-6MZN3GOP.js.map
3097
- //# sourceMappingURL=chunk-6MZN3GOP.js.map
2478
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Column, Combobox, ConfirmModal, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, Grid, IconButton, InlineCode, InlineStatus, Input, Kbd, Label3 as Label, Modal, MotionDiv, MotionSpan, NumberInput, PageLoader, Pagination, PasswordInput, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Sheet, Skeleton, Slider, Spinner, Stack, StatusIndicator, Steps, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, fadeIn, staggerContainer, staggerItem, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior };
2479
+ //# sourceMappingURL=chunk-5TOGZTAO.js.map
2480
+ //# sourceMappingURL=chunk-5TOGZTAO.js.map