@evinvest/uikit 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -132,9 +132,19 @@ measuring needs host-only `web-sys`). Known gaps:
132
132
  - **calendar:** single month, single-date selection (no range/multi-month, no
133
133
  locale/dropdown features). Rust does manual date math; TS uses the built-in
134
134
  `Date`.
135
- - **sonner:** TS exposes a global `toast()` backed by a module store with
136
- auto-dismiss; Rust uses a `ToasterProvider` + `use_toaster()` hook and omits
137
- auto-dismiss (dismiss via the close button or `.dismiss(id)`).
135
+ - **sonner:** both ports stack toasts Sonner-style — a collapsed pile (front
136
+ three peeking, scaled by depth) that spreads into a list on hover / keyboard
137
+ focus, via the shared `data-stack` CSS in `tokens.css`. The enter is a CSS
138
+ keyframe (plays on insertion), the exit slides out on `data-state="closed"` and
139
+ unmounts on `transitionend` (no host timer). React measures each toast's height
140
+ for exact expanded spacing; Dioxus can't (layout measuring needs host-only
141
+ `web-sys`), so it assumes a constant height — collapsed pile exact, expanded
142
+ list uniform. Both **auto-dismiss** (default 4000ms) and **pause while the stack
143
+ is hovered/focused**, and support **persistent** toasts; React does it with a
144
+ `setTimeout` (`duration: Infinity` to persist), Dioxus with a host-timer-free
145
+ CSS "life" animation whose `animationend` closes the toast (`use_toaster().show(
146
+ msg, variant, None)` to persist). Swipe-to-dismiss (horizontal drag, past 45px
147
+ or a fast flick) is TS-only pointer physics.
138
148
  - **form:** react-hook-form is dropped — these are presentational + ARIA-id
139
149
  wiring; consumers own validation/state. Rust `FormControl` can't inject ids
140
150
  onto an arbitrary child (no `Slot`), so the consumer wires them.
package/dist/index.d.ts CHANGED
@@ -1119,9 +1119,21 @@ interface CalendarProps {
1119
1119
  declare function Calendar({ selected, onSelect, month, defaultMonth, onMonthChange, today, className, }: CalendarProps): React.JSX.Element;
1120
1120
 
1121
1121
  type ToastVariant = "default" | "success" | "error" | "info" | "warning";
1122
+ /**
1123
+ * Lifecycle phase of a toast. It is added `"open"` (plays the enter keyframe);
1124
+ * {@link ToastFn.dismiss} flips it to `"closing"` (plays the exit keyframe) and
1125
+ * the live node is dropped once the exit `animationend` fires. Mirrors Rust's
1126
+ * `ToastState` enum and the `data-state` the shared `tokens.css` keys on.
1127
+ */
1128
+ type ToastState = "open" | "closing";
1122
1129
  type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
1123
1130
  interface ToastOptions {
1124
1131
  description?: React.ReactNode;
1132
+ /**
1133
+ * Auto-dismiss delay in ms (default 4000). Pass `Infinity` for a **persistent**
1134
+ * toast that never times out — it stays until the close button, a swipe, or
1135
+ * `toast.dismiss(id)` removes it. Hovering the stack also pauses the countdown.
1136
+ */
1125
1137
  duration?: number;
1126
1138
  variant?: ToastVariant;
1127
1139
  }
@@ -1131,6 +1143,7 @@ interface Toast {
1131
1143
  description?: React.ReactNode;
1132
1144
  duration: number;
1133
1145
  variant: ToastVariant;
1146
+ state: ToastState;
1134
1147
  }
1135
1148
  interface ToastFn {
1136
1149
  (message: React.ReactNode, opts?: ToastOptions): number;
@@ -1151,9 +1164,16 @@ interface ToasterProps extends React.ComponentProps<"ol"> {
1151
1164
  }
1152
1165
  /**
1153
1166
  * Renders the live toast stack from the module store. Fixed-positioned per
1154
- * `position` (default `bottom-right`); each toast auto-dismisses after its
1155
- * `duration` (default 4000ms) via `setTimeout`. Single dark palette — no theme
1156
- * switching (the upstream `next-themes` dependency is dropped).
1167
+ * `position` (default `bottom-right`).
1168
+ *
1169
+ * Stacking mirrors Sonner: toasts pile up collapsed (the front three peeking,
1170
+ * each scaled + lifted by depth and clamped to the front toast's height) and
1171
+ * spread into a list on hover / keyboard focus — driven by the measured
1172
+ * `--front-height`/`--offset` vars and the `data-stack` CSS in `tokens.css`.
1173
+ * Each toast auto-dismisses after its `duration` (default 4000ms) via the same
1174
+ * animated `dismiss` as the close button (`data-state="closed"` → slide out →
1175
+ * unmount on `transitionend`), and is swipe-to-dismiss (horizontal drag, TS-only
1176
+ * pointer physics). Single dark palette — no theme switching.
1157
1177
  */
1158
1178
  declare function Toaster({ position, className, ...props }: ToasterProps): React.JSX.Element;
1159
1179
 
@@ -1186,4 +1206,4 @@ interface ResizableHandleProps extends React.ComponentProps<"div"> {
1186
1206
  }
1187
1207
  declare function ResizableHandle({ className, index, withHandle, children, ...props }: ResizableHandleProps): React.JSX.Element;
1188
1208
 
1189
- export { Accordion, AccordionContent, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, type AlertDialogOverlayProps, type AlertDialogProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, type AlertProps, AlertTitle, type AlertVariant, type Align, AspectRatio, type AspectRatioProps, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, type BadgeVariant, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, type ButtonGroupOrientation, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, type ButtonGroupTextProps, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantsOptions, Calendar, type CalendarProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type CarouselProps, type ChartConfig, ChartContainer, type ChartItem, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, type CollapsibleProps, CollapsibleTrigger, Command, CommandDialog, type CommandDialogProps, CommandEmpty, CommandGroup, type CommandGroupProps, CommandInput, CommandItem, type CommandItemProps, CommandList, type CommandProps, CommandSeparator, CommandShortcut, Container, type ContainerProps, ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, ContextMenuGroup, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, DialogTitle, DialogTrigger, type DialogTriggerProps, Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, DropdownMenu, DropdownMenuCheckboxItem, type DropdownMenuCheckboxItemProps, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuGroup, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuLabel, type DropdownMenuLabelProps, DropdownMenuPortal, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, type DropdownMenuSubProps, DropdownMenuSubTrigger, type DropdownMenuSubTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyMediaProps, type EmptyMediaVariant, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldOrientation, FieldSeparator, FieldSet, FieldTitle, type FloatingResult, Form, FormControl, FormDescription, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, type HoverCardContentProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, Input, InputGroup, InputGroupAddon, type InputGroupAddonAlign, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, type InputGroupButtonSize, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, type InputOTPProps, InputOTPSeparator, InputOTPSlot, type InputOTPSlotProps, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, type ItemMediaProps, type ItemMediaVariant, type ItemProps, ItemSeparator, type ItemSize, ItemTitle, type ItemVariant, Kbd, KbdGroup, Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, type MenubarMenuProps, MenubarRadioGroup, type MenubarRadioGroupProps, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, type MenubarSubProps, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, type PortalProps, Progress, type ProgressProps, RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, type ResizableDirection, ResizableHandle, type ResizableHandleProps, ResizablePanel, ResizablePanelGroup, type ResizablePanelGroupProps, type ResizablePanelProps, ScrollArea, ScrollBar, type ScrollBarProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, type SelectItemProps, SelectLabel, type SelectProps, SelectSeparator, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, Sheet, SheetClose, type SheetCloseProps, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, type SheetOverlayProps, type SheetProps, SheetTitle, SheetTrigger, type SheetTriggerProps, type Side, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, type SidebarMenuButtonVariant, SidebarMenuItem, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, type SliderProps, Slot, type SlotProps, Spinner, Switch, type SwitchProps, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsProps, TabsTrigger, type TabsTriggerProps, Textarea, type Toast, type ToastFn, type ToastOptions, type ToastPosition, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, type ToggleSize, type ToggleVariant, type ToggleVariantsOptions, Tooltip, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, buttonVariants, cn, mergeRefs, navigationMenuTriggerStyle, toast, toggleVariants, useControllableState, useDismissableLayer, useFloating, useFocusScope, usePresence, useRovingFocus, useSidebar };
1209
+ export { Accordion, AccordionContent, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, type AlertDialogOverlayProps, type AlertDialogProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, type AlertProps, AlertTitle, type AlertVariant, type Align, AspectRatio, type AspectRatioProps, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, type BadgeVariant, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, type ButtonGroupOrientation, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, type ButtonGroupTextProps, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantsOptions, Calendar, type CalendarProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type CarouselProps, type ChartConfig, ChartContainer, type ChartItem, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, type CollapsibleProps, CollapsibleTrigger, Command, CommandDialog, type CommandDialogProps, CommandEmpty, CommandGroup, type CommandGroupProps, CommandInput, CommandItem, type CommandItemProps, CommandList, type CommandProps, CommandSeparator, CommandShortcut, Container, type ContainerProps, ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, ContextMenuGroup, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, DialogTitle, DialogTrigger, type DialogTriggerProps, Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, DropdownMenu, DropdownMenuCheckboxItem, type DropdownMenuCheckboxItemProps, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuGroup, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuLabel, type DropdownMenuLabelProps, DropdownMenuPortal, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, type DropdownMenuSubProps, DropdownMenuSubTrigger, type DropdownMenuSubTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyMediaProps, type EmptyMediaVariant, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldOrientation, FieldSeparator, FieldSet, FieldTitle, type FloatingResult, Form, FormControl, FormDescription, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, type HoverCardContentProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, Input, InputGroup, InputGroupAddon, type InputGroupAddonAlign, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, type InputGroupButtonSize, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, type InputOTPProps, InputOTPSeparator, InputOTPSlot, type InputOTPSlotProps, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, type ItemMediaProps, type ItemMediaVariant, type ItemProps, ItemSeparator, type ItemSize, ItemTitle, type ItemVariant, Kbd, KbdGroup, Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, type MenubarMenuProps, MenubarRadioGroup, type MenubarRadioGroupProps, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, type MenubarSubProps, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, type PortalProps, Progress, type ProgressProps, RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, type ResizableDirection, ResizableHandle, type ResizableHandleProps, ResizablePanel, ResizablePanelGroup, type ResizablePanelGroupProps, type ResizablePanelProps, ScrollArea, ScrollBar, type ScrollBarProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, type SelectItemProps, SelectLabel, type SelectProps, SelectSeparator, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, Sheet, SheetClose, type SheetCloseProps, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, type SheetOverlayProps, type SheetProps, SheetTitle, SheetTrigger, type SheetTriggerProps, type Side, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, type SidebarMenuButtonVariant, SidebarMenuItem, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, type SliderProps, Slot, type SlotProps, Spinner, Switch, type SwitchProps, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsProps, TabsTrigger, type TabsTriggerProps, Textarea, type Toast, type ToastFn, type ToastOptions, type ToastPosition, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, type ToggleSize, type ToggleVariant, type ToggleVariantsOptions, Tooltip, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, buttonVariants, cn, mergeRefs, navigationMenuTriggerStyle, toast, toggleVariants, useControllableState, useDismissableLayer, useFloating, useFocusScope, usePresence, useRovingFocus, useSidebar };
package/dist/index.js CHANGED
@@ -6032,6 +6032,9 @@ function Calendar({
6032
6032
  import * as React61 from "react";
6033
6033
  import { jsx as jsx52, jsxs as jsxs22 } from "react/jsx-runtime";
6034
6034
  var DEFAULT_DURATION = 4e3;
6035
+ var SWIPE_THRESHOLD = 45;
6036
+ var SWIPE_VELOCITY = 0.11;
6037
+ var SWIPE_FLING_MS = 200;
6035
6038
  var store = /* @__PURE__ */ (() => {
6036
6039
  let toasts = [];
6037
6040
  let id = 0;
@@ -6045,13 +6048,20 @@ var store = /* @__PURE__ */ (() => {
6045
6048
  message,
6046
6049
  description: opts.description,
6047
6050
  duration: opts.duration ?? DEFAULT_DURATION,
6048
- variant: opts.variant ?? "default"
6051
+ variant: opts.variant ?? "default",
6052
+ state: "open"
6049
6053
  };
6050
6054
  toasts = [...toasts, next];
6051
6055
  emit();
6052
6056
  return next.id;
6053
6057
  };
6054
6058
  const dismiss = (toastId) => {
6059
+ toasts = toasts.map(
6060
+ (t) => t.id === toastId ? { ...t, state: "closing" } : t
6061
+ );
6062
+ emit();
6063
+ };
6064
+ const remove = (toastId) => {
6055
6065
  toasts = toasts.filter((t) => t.id !== toastId);
6056
6066
  emit();
6057
6067
  };
@@ -6062,7 +6072,7 @@ var store = /* @__PURE__ */ (() => {
6062
6072
  listeners.delete(listener);
6063
6073
  };
6064
6074
  };
6065
- return { add, dismiss, subscribe };
6075
+ return { add, dismiss, remove, subscribe };
6066
6076
  })();
6067
6077
  var toast = Object.assign(
6068
6078
  (message, opts) => store.add(message, opts),
@@ -6082,28 +6092,141 @@ var toastVariantClasses = {
6082
6092
  warning: "bg-popover text-popover-foreground border-border"
6083
6093
  };
6084
6094
  var positionClasses = {
6085
- "top-left": "top-0 left-0 items-start",
6086
- "top-center": "top-0 left-1/2 -translate-x-1/2 items-center",
6087
- "top-right": "top-0 right-0 items-end",
6088
- "bottom-left": "bottom-0 left-0 items-start",
6089
- "bottom-center": "bottom-0 left-1/2 -translate-x-1/2 items-center",
6090
- "bottom-right": "bottom-0 right-0 items-end"
6095
+ "top-left": "top-4 left-4",
6096
+ "top-center": "top-4 left-1/2 -translate-x-1/2",
6097
+ "top-right": "top-4 right-4",
6098
+ "bottom-left": "bottom-4 left-4",
6099
+ "bottom-center": "bottom-4 left-1/2 -translate-x-1/2",
6100
+ "bottom-right": "bottom-4 right-4"
6091
6101
  };
6092
- function ToastItem({ toast: t }) {
6102
+ var VISIBLE_TOASTS = 3;
6103
+ var GAP = 14;
6104
+ function ToastItem({
6105
+ toast: t,
6106
+ index,
6107
+ total,
6108
+ offset,
6109
+ paused,
6110
+ reportHeight,
6111
+ removeHeight
6112
+ }) {
6113
+ const ref = React61.useRef(null);
6114
+ const [height, setHeight] = React61.useState(0);
6115
+ const remainingRef = React61.useRef(t.duration);
6116
+ const startedRef = React61.useRef(0);
6117
+ const flingRef = React61.useRef(
6118
+ void 0
6119
+ );
6120
+ const dragRef = React61.useRef(
6121
+ null
6122
+ );
6123
+ React61.useLayoutEffect(() => {
6124
+ const el = ref.current;
6125
+ if (!el) return;
6126
+ el.style.height = "auto";
6127
+ const h = el.getBoundingClientRect().height;
6128
+ el.style.height = "";
6129
+ if (h) {
6130
+ setHeight(h);
6131
+ reportHeight(t.id, h);
6132
+ }
6133
+ }, [t.id, t.message, t.description, reportHeight]);
6134
+ React61.useEffect(() => () => removeHeight(t.id), [t.id, removeHeight]);
6093
6135
  React61.useEffect(() => {
6094
- if (t.duration === Infinity) return;
6095
- const timer = setTimeout(() => store.dismiss(t.id), t.duration);
6096
- return () => clearTimeout(timer);
6097
- }, [t.id, t.duration]);
6136
+ if (t.duration === Infinity || t.state === "closing" || paused) return;
6137
+ startedRef.current = Date.now();
6138
+ const id = setTimeout(() => store.dismiss(t.id), remainingRef.current);
6139
+ return () => {
6140
+ clearTimeout(id);
6141
+ remainingRef.current = Math.max(
6142
+ 0,
6143
+ remainingRef.current - (Date.now() - startedRef.current)
6144
+ );
6145
+ };
6146
+ }, [paused, t.id, t.duration, t.state]);
6147
+ React61.useEffect(
6148
+ () => () => {
6149
+ if (flingRef.current) clearTimeout(flingRef.current);
6150
+ },
6151
+ []
6152
+ );
6153
+ const onTransitionEnd = (e) => {
6154
+ if (t.state === "closing" && e.propertyName === "transform") {
6155
+ store.remove(t.id);
6156
+ }
6157
+ };
6158
+ const onPointerDown = (e) => {
6159
+ const el = ref.current;
6160
+ if (!el || e.button > 0 || t.state === "closing") return;
6161
+ if (e.target.closest('[data-slot="toast-close"]')) return;
6162
+ dragRef.current = { x: e.clientX, time: e.timeStamp, dx: 0 };
6163
+ el.setAttribute("data-swiping", "true");
6164
+ try {
6165
+ el.setPointerCapture?.(e.pointerId);
6166
+ } catch {
6167
+ }
6168
+ };
6169
+ const onPointerMove = (e) => {
6170
+ const drag = dragRef.current;
6171
+ const el = ref.current;
6172
+ if (!drag || !el) return;
6173
+ const dx = e.clientX - drag.x;
6174
+ drag.dx = dx;
6175
+ const dist = el.offsetWidth || 256;
6176
+ el.style.setProperty("--swipe-x", `${dx}px`);
6177
+ el.style.opacity = `${Math.max(0, 1 - Math.abs(dx) / dist)}`;
6178
+ };
6179
+ const onPointerEnd = (e) => {
6180
+ const drag = dragRef.current;
6181
+ const el = ref.current;
6182
+ if (!drag || !el) return;
6183
+ dragRef.current = null;
6184
+ el.removeAttribute("data-swiping");
6185
+ const dt = e.timeStamp - drag.time;
6186
+ const velocity = dt > 0 ? Math.abs(drag.dx) / dt : 0;
6187
+ if (drag.dx !== 0 && (Math.abs(drag.dx) >= SWIPE_THRESHOLD || velocity > SWIPE_VELOCITY)) {
6188
+ el.style.setProperty("--swipe-x", `${drag.dx > 0 ? 150 : -150}%`);
6189
+ el.style.opacity = "0";
6190
+ const remove = () => store.remove(t.id);
6191
+ el.addEventListener("transitionend", remove, { once: true });
6192
+ flingRef.current = setTimeout(remove, SWIPE_FLING_MS + 50);
6193
+ } else {
6194
+ el.style.setProperty("--swipe-x", "0px");
6195
+ el.style.opacity = "1";
6196
+ el.addEventListener(
6197
+ "transitionend",
6198
+ () => {
6199
+ el.style.removeProperty("--swipe-x");
6200
+ el.style.opacity = "";
6201
+ },
6202
+ { once: true }
6203
+ );
6204
+ }
6205
+ };
6098
6206
  return /* @__PURE__ */ jsxs22(
6099
6207
  "li",
6100
6208
  {
6209
+ ref,
6101
6210
  role: "status",
6102
6211
  "aria-live": "polite",
6103
6212
  "data-slot": "toast",
6104
6213
  "data-variant": t.variant,
6214
+ "data-state": t.state === "closing" ? "closed" : "open",
6215
+ "data-front": index === 0,
6216
+ "data-visible": index < VISIBLE_TOASTS,
6217
+ onTransitionEnd,
6218
+ onPointerDown,
6219
+ onPointerMove,
6220
+ onPointerUp: onPointerEnd,
6221
+ onPointerCancel: onPointerEnd,
6222
+ style: {
6223
+ "--index": index,
6224
+ "--z-index": total - index,
6225
+ "--offset": `${offset}px`,
6226
+ "--initial-height": `${height}px`
6227
+ },
6105
6228
  className: cn(
6106
- "pointer-events-auto flex w-full items-start gap-3 rounded-md border p-4 text-sm shadow-lg",
6229
+ "pointer-events-auto flex w-full touch-pan-y items-start gap-3 rounded-md border p-4 text-sm shadow-lg select-none",
6107
6230
  toastVariantClasses[t.variant]
6108
6231
  ),
6109
6232
  children: [
@@ -6147,19 +6270,75 @@ function Toaster({
6147
6270
  ...props
6148
6271
  }) {
6149
6272
  const [toasts, setToasts] = React61.useState([]);
6273
+ const [heights, setHeights] = React61.useState(/* @__PURE__ */ new Map());
6274
+ const [paused, setPaused] = React61.useState(false);
6150
6275
  React61.useEffect(() => store.subscribe(setToasts), []);
6276
+ const onEnter = () => setPaused(true);
6277
+ const onLeave = (e) => {
6278
+ if (!e.currentTarget.contains(e.relatedTarget)) {
6279
+ setPaused(false);
6280
+ }
6281
+ };
6282
+ const reportHeight = React61.useCallback((id, h) => {
6283
+ setHeights((prev) => {
6284
+ if (prev.get(id) === h) return prev;
6285
+ const next = new Map(prev);
6286
+ next.set(id, h);
6287
+ return next;
6288
+ });
6289
+ }, []);
6290
+ const removeHeight = React61.useCallback((id) => {
6291
+ setHeights((prev) => {
6292
+ if (!prev.has(id)) return prev;
6293
+ const next = new Map(prev);
6294
+ next.delete(id);
6295
+ return next;
6296
+ });
6297
+ }, []);
6298
+ const yPosition = position.startsWith("top") ? "top" : "bottom";
6299
+ const ordered = [...toasts].reverse();
6300
+ const known = [...heights.values()];
6301
+ const frontHeight = ordered[0] ? heights.get(ordered[0].id) ?? (known.length ? Math.max(...known) : 0) : 0;
6302
+ let sum = 0;
6303
+ const offsets = ordered.map((t, i) => {
6304
+ const o = sum + i * GAP;
6305
+ sum += heights.get(t.id) ?? 0;
6306
+ return o;
6307
+ });
6151
6308
  return /* @__PURE__ */ jsx52(
6152
6309
  "ol",
6153
6310
  {
6154
6311
  "data-slot": "toaster",
6155
6312
  "data-position": position,
6313
+ "data-y-position": yPosition,
6314
+ "data-stack": "",
6315
+ style: {
6316
+ "--front-height": `${frontHeight}px`,
6317
+ "--gap": `${GAP}px`
6318
+ },
6156
6319
  className: cn(
6157
- "pointer-events-none fixed z-100 flex w-[calc(100%-2rem)] max-w-sm flex-col gap-2 p-4",
6320
+ "pointer-events-none fixed z-100 w-[calc(100%-2rem)] max-w-sm",
6158
6321
  positionClasses[position],
6159
6322
  className
6160
6323
  ),
6161
6324
  ...props,
6162
- children: toasts.map((t) => /* @__PURE__ */ jsx52(ToastItem, { toast: t }, t.id))
6325
+ onPointerOver: onEnter,
6326
+ onPointerOut: onLeave,
6327
+ onFocus: onEnter,
6328
+ onBlur: onLeave,
6329
+ children: ordered.map((t, i) => /* @__PURE__ */ jsx52(
6330
+ ToastItem,
6331
+ {
6332
+ toast: t,
6333
+ index: i,
6334
+ total: ordered.length,
6335
+ offset: offsets[i],
6336
+ paused,
6337
+ reportHeight,
6338
+ removeHeight
6339
+ },
6340
+ t.id
6341
+ ))
6163
6342
  }
6164
6343
  );
6165
6344
  }