@gv-tech/ui-web 2.10.0 → 2.12.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/dist/accordion.cjs.js +1 -0
- package/dist/accordion.d.ts +18 -0
- package/dist/accordion.es.js +259 -0
- package/dist/alert-dialog.cjs.js +7 -0
- package/dist/alert-dialog.d.ts +43 -0
- package/dist/alert-dialog.es.js +171 -0
- package/dist/alert.cjs.js +1 -0
- package/dist/alert.d.ts +18 -0
- package/dist/alert.es.js +32 -0
- package/dist/aspect-ratio.cjs.js +1 -0
- package/dist/aspect-ratio.d.ts +10 -0
- package/dist/aspect-ratio.es.js +43 -0
- package/dist/avatar.cjs.js +1 -0
- package/dist/avatar.d.ts +15 -0
- package/dist/avatar.es.js +205 -0
- package/dist/badge.cjs.js +1 -0
- package/dist/badge.d.ts +16 -0
- package/dist/badge.es.js +26 -0
- package/dist/breadcrumb.cjs.js +1 -0
- package/dist/breadcrumb.d.ts +35 -0
- package/dist/breadcrumb.es.js +69 -0
- package/dist/button.cjs.js +1 -0
- package/dist/button.d.ts +17 -0
- package/dist/button.es.js +40 -0
- package/dist/calendar.cjs.js +1 -0
- package/dist/calendar.d.ts +29 -0
- package/dist/calendar.es.js +2976 -0
- package/dist/card.cjs.js +1 -0
- package/dist/card.d.ts +19 -0
- package/dist/card.es.js +33 -0
- package/dist/carousel.cjs.js +1 -0
- package/dist/carousel.d.ts +50 -0
- package/dist/carousel.es.js +1403 -0
- package/dist/chart.cjs.js +16 -0
- package/dist/chart.d.ts +60 -0
- package/dist/chart.es.js +4402 -0
- package/dist/checkbox.cjs.js +1 -0
- package/dist/checkbox.d.ts +10 -0
- package/dist/checkbox.es.js +258 -0
- package/dist/collapsible.cjs.js +1 -0
- package/dist/collapsible.d.ts +20 -0
- package/dist/collapsible.es.js +7 -0
- package/dist/command.cjs.js +1 -0
- package/dist/command.d.ts +115 -0
- package/dist/command.es.js +396 -0
- package/dist/context-menu.cjs.js +1 -0
- package/dist/context-menu.d.ts +80 -0
- package/dist/context-menu.es.js +328 -0
- package/dist/dialog.cjs.js +1 -0
- package/dist/dialog.d.ts +31 -0
- package/dist/dialog.es.js +66 -0
- package/dist/drawer.cjs.js +3 -0
- package/dist/drawer.d.ts +65 -0
- package/dist/drawer.es.js +1085 -0
- package/dist/dropdown-menu.cjs.js +1 -0
- package/dist/dropdown-menu.d.ts +80 -0
- package/dist/dropdown-menu.es.js +316 -0
- package/dist/form.cjs.js +1 -0
- package/dist/form.d.ts +53 -0
- package/dist/form.es.js +355 -0
- package/dist/hover-card.cjs.js +1 -0
- package/dist/hover-card.d.ts +19 -0
- package/dist/hover-card.es.js +188 -0
- package/dist/index-0ioNhtNM.mjs +10 -0
- package/dist/index-3j-XAIXT.mjs +55 -0
- package/dist/index-B2XtpfGY.js +1 -0
- package/dist/index-B39Lzq0v.js +1 -0
- package/dist/index-B7n6fy75.js +1 -0
- package/dist/index-B8dxbSWX.js +41 -0
- package/dist/index-BGIK9FQF.js +1 -0
- package/dist/index-BZPx6jYI.mjs +8 -0
- package/dist/index-BoNjHhm4.js +1 -0
- package/dist/index-BtZvtDmp.js +1 -0
- package/dist/index-Bv7qrYW6.mjs +180 -0
- package/dist/index-ByiPJW53.js +5 -0
- package/dist/index-C0dlIQIi.js +1 -0
- package/dist/index-C1qb0595.mjs +27 -0
- package/dist/index-C7HEunrh.mjs +15 -0
- package/dist/index-C8ni3LLa.js +1 -0
- package/dist/index-CCKe-Mpx.mjs +6 -0
- package/dist/index-CD6_IrA-.mjs +10 -0
- package/dist/index-CRyCZJLa.mjs +677 -0
- package/dist/index-CVx1AgNG.mjs +615 -0
- package/dist/index-Ce5TOFAK.js +1 -0
- package/dist/index-CeSLNJ60.mjs +32 -0
- package/dist/index-CefEQe_4.js +1 -0
- package/dist/index-Cj5hzyBi.js +1 -0
- package/dist/index-Cjj_rUPu.js +1 -0
- package/dist/index-Cl3G0jzM.js +1 -0
- package/dist/index-CsjrqSSN.js +1 -0
- package/dist/index-CwfE56Ep.mjs +1545 -0
- package/dist/index-CwyAfCwY.js +1 -0
- package/dist/index-CzY-WZXL.js +1 -0
- package/dist/index-D2HnlO3y.js +1 -0
- package/dist/index-DAWHN3cH.mjs +85 -0
- package/dist/index-DFdF7K7v.mjs +50 -0
- package/dist/index-DIsg7zU7.js +1 -0
- package/dist/index-DKN_vhyX.mjs +32 -0
- package/dist/index-DLcqcWxM.mjs +29 -0
- package/dist/index-DSxf1gN6.mjs +118 -0
- package/dist/index-DYxWvftI.js +1 -0
- package/dist/index-DaILh3TV.mjs +32 -0
- package/dist/index-Dfzl8TxY.mjs +136 -0
- package/dist/index-Dko2XdTk.js +1 -0
- package/dist/index-DlY82G31.mjs +245 -0
- package/dist/index-DnFcfnA9.mjs +13 -0
- package/dist/index-IZ2gq03c.mjs +68 -0
- package/dist/index-K9FzbxYw.mjs +93 -0
- package/dist/index-Le8p9oP4.mjs +60 -0
- package/dist/index-MQ0c3ZX_.js +1 -0
- package/dist/index-_XxjJPRD.js +1 -0
- package/dist/index-_wdrnYim.js +1 -0
- package/dist/index-jv3B4mTd.js +1 -0
- package/dist/index-kaM0u2Q1.js +1 -0
- package/dist/index-p6xVFRb4.mjs +52 -0
- package/dist/index-rKs9bXHr.mjs +6 -0
- package/dist/index-vuPgkS0V.mjs +70 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +1288 -0
- package/dist/index.es.js +289 -0
- package/dist/input.cjs.js +1 -0
- package/dist/input.d.ts +9 -0
- package/dist/input.es.js +19 -0
- package/dist/jsx-runtime-nZSsnGb7.js +6 -0
- package/dist/jsx-runtime-tc70JA_2.mjs +264 -0
- package/dist/label.cjs.js +1 -0
- package/dist/label.d.ts +11 -0
- package/dist/label.es.js +22 -0
- package/dist/menubar.cjs.js +1 -0
- package/dist/menubar.d.ts +79 -0
- package/dist/menubar.es.js +473 -0
- package/dist/navigation-menu.cjs.js +1 -0
- package/dist/navigation-menu.d.ts +47 -0
- package/dist/navigation-menu.es.js +673 -0
- package/dist/pagination.cjs.js +1 -0
- package/dist/pagination.d.ts +68 -0
- package/dist/pagination.es.js +68 -0
- package/dist/popover.cjs.js +1 -0
- package/dist/popover.d.ts +24 -0
- package/dist/popover.es.js +242 -0
- package/dist/progress.cjs.js +6 -0
- package/dist/progress.d.ts +9 -0
- package/dist/progress.es.js +99 -0
- package/dist/radio-group.cjs.js +1 -0
- package/dist/radio-group.d.ts +16 -0
- package/dist/radio-group.es.js +253 -0
- package/dist/resizable.cjs.js +1 -0
- package/dist/resizable.d.ts +22 -0
- package/dist/resizable.es.js +1990 -0
- package/dist/scroll-area.cjs.js +1 -0
- package/dist/scroll-area.d.ts +14 -0
- package/dist/scroll-area.es.js +546 -0
- package/dist/search.cjs.js +1 -0
- package/dist/search.d.ts +15 -0
- package/dist/search.es.js +51 -0
- package/dist/select.cjs.js +1 -0
- package/dist/select.d.ts +54 -0
- package/dist/select.es.js +908 -0
- package/dist/separator.cjs.js +1 -0
- package/dist/separator.d.ts +9 -0
- package/dist/separator.es.js +35 -0
- package/dist/sheet.cjs.js +1 -0
- package/dist/sheet.d.ts +68 -0
- package/dist/sheet.es.js +66 -0
- package/dist/skeleton.cjs.js +1 -0
- package/dist/skeleton.d.ts +9 -0
- package/dist/skeleton.es.js +8 -0
- package/dist/slider.cjs.js +1 -0
- package/dist/slider.d.ts +9 -0
- package/dist/slider.es.js +442 -0
- package/dist/sonner.cjs.js +1 -0
- package/dist/sonner.d.ts +10 -0
- package/dist/sonner.es.js +764 -0
- package/dist/switch.cjs.js +1 -0
- package/dist/switch.d.ts +9 -0
- package/dist/switch.es.js +149 -0
- package/dist/table.cjs.js +1 -0
- package/dist/table.d.ts +43 -0
- package/dist/table.es.js +57 -0
- package/dist/tabs.cjs.js +1 -0
- package/dist/tabs.d.ts +24 -0
- package/dist/tabs.es.js +195 -0
- package/dist/text.cjs.js +1 -0
- package/dist/text.d.ts +17 -0
- package/dist/text.es.js +42 -0
- package/dist/textarea.cjs.js +1 -0
- package/dist/textarea.d.ts +9 -0
- package/dist/textarea.es.js +18 -0
- package/dist/theme-provider.cjs.js +1 -0
- package/dist/theme-provider.d.ts +9 -0
- package/dist/theme-provider.es.js +8 -0
- package/dist/theme-toggle.cjs.js +1 -0
- package/dist/theme-toggle.d.ts +8 -0
- package/dist/theme-toggle.es.js +78 -0
- package/dist/toast.cjs.js +1 -0
- package/dist/toast.d.ts +26 -0
- package/dist/toast.es.js +494 -0
- package/dist/toaster-CIpfms4W.js +1 -0
- package/dist/toaster-jBYXAPRk.mjs +118 -0
- package/dist/toaster.cjs.js +1 -0
- package/dist/toaster.d.ts +6 -0
- package/dist/toaster.es.js +6 -0
- package/dist/toggle-group.cjs.js +1 -0
- package/dist/toggle-group.d.ts +18 -0
- package/dist/toggle-group.es.js +170 -0
- package/dist/toggle.cjs.js +1 -0
- package/dist/toggle.d.ts +14 -0
- package/dist/toggle.es.js +14 -0
- package/dist/tooltip.cjs.js +1 -0
- package/dist/tooltip.d.ts +25 -0
- package/dist/tooltip.es.js +342 -0
- package/dist/utils-B6yFEsav.mjs +8 -0
- package/dist/utils-IjLH3w2e.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { j as e } from "./jsx-runtime-tc70JA_2.mjs";
|
|
2
|
+
import { Sun as x, Moon as j, SunMoon as g } from "lucide-react";
|
|
3
|
+
import { Button as p } from "./button.es.js";
|
|
4
|
+
import { DropdownMenu as w, DropdownMenuTrigger as v, DropdownMenuContent as N, DropdownMenuItem as i } from "./dropdown-menu.es.js";
|
|
5
|
+
import { theme as u } from "@gv-tech/design-tokens";
|
|
6
|
+
import { z as y } from "./index-DAWHN3cH.mjs";
|
|
7
|
+
import { c as r } from "./utils-B6yFEsav.mjs";
|
|
8
|
+
function C() {
|
|
9
|
+
const t = y(), { resolvedTheme: n } = t, s = n === "dark" ? u.dark : u.light;
|
|
10
|
+
return {
|
|
11
|
+
...t,
|
|
12
|
+
tokens: s
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function F({ variant: t = "binary", onThemeChange: n, customTheme: s, className: l }) {
|
|
16
|
+
const { theme: f, setTheme: k, resolvedTheme: T } = C(), c = s ?? f, m = (s || T) === "dark", a = c === "system", o = (d) => {
|
|
17
|
+
n ? n(d) : k(d);
|
|
18
|
+
}, h = () => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
19
|
+
/* @__PURE__ */ e.jsx(
|
|
20
|
+
x,
|
|
21
|
+
{
|
|
22
|
+
className: r(
|
|
23
|
+
"h-[1.2rem] w-[1.2rem] transition-all",
|
|
24
|
+
!a && !m ? "scale-100 rotate-0" : "scale-0 -rotate-90"
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ e.jsx(
|
|
29
|
+
j,
|
|
30
|
+
{
|
|
31
|
+
className: r(
|
|
32
|
+
"absolute h-[1.2rem] w-[1.2rem] transition-all",
|
|
33
|
+
!a && m ? "scale-100 rotate-0" : "scale-0 rotate-90"
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ e.jsx(
|
|
38
|
+
g,
|
|
39
|
+
{
|
|
40
|
+
className: r(
|
|
41
|
+
"absolute h-[1.2rem] w-[1.2rem] transition-all",
|
|
42
|
+
a ? "scale-100 rotate-0" : "scale-0 rotate-90"
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Toggle theme" })
|
|
47
|
+
] });
|
|
48
|
+
return t === "ternary" ? /* @__PURE__ */ e.jsxs(w, { children: [
|
|
49
|
+
/* @__PURE__ */ e.jsx(v, { asChild: !0, children: /* @__PURE__ */ e.jsx(p, { variant: "ghost", size: "icon", className: r("relative h-9 w-9", l), children: /* @__PURE__ */ e.jsx(h, {}) }) }),
|
|
50
|
+
/* @__PURE__ */ e.jsxs(N, { align: "end", children: [
|
|
51
|
+
/* @__PURE__ */ e.jsxs(i, { onClick: () => o("light"), children: [
|
|
52
|
+
/* @__PURE__ */ e.jsx(x, { className: "mr-2 h-4 w-4" }),
|
|
53
|
+
/* @__PURE__ */ e.jsx("span", { children: "Light" })
|
|
54
|
+
] }),
|
|
55
|
+
/* @__PURE__ */ e.jsxs(i, { onClick: () => o("dark"), children: [
|
|
56
|
+
/* @__PURE__ */ e.jsx(j, { className: "mr-2 h-4 w-4" }),
|
|
57
|
+
/* @__PURE__ */ e.jsx("span", { children: "Dark" })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ e.jsxs(i, { onClick: () => o("system"), children: [
|
|
60
|
+
/* @__PURE__ */ e.jsx(g, { className: "mr-2 h-4 w-4" }),
|
|
61
|
+
/* @__PURE__ */ e.jsx("span", { children: "System" })
|
|
62
|
+
] })
|
|
63
|
+
] })
|
|
64
|
+
] }) : /* @__PURE__ */ e.jsx(
|
|
65
|
+
p,
|
|
66
|
+
{
|
|
67
|
+
variant: "ghost",
|
|
68
|
+
size: "icon",
|
|
69
|
+
className: r("relative h-9 w-9", l),
|
|
70
|
+
onClick: () => o(c === "dark" ? "light" : "dark"),
|
|
71
|
+
"aria-label": "Toggle theme",
|
|
72
|
+
children: /* @__PURE__ */ e.jsx(h, {})
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
F as ThemeToggle
|
|
78
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-nZSsnGb7.js"),Ae=require("react"),Ie=require("react-dom"),x=require("./index-BtZvtDmp.js"),te=require("./index-_XxjJPRD.js"),Fe=require("./index-BGIK9FQF.js"),Oe=require("./index-D2HnlO3y.js"),se=require("./index-BoNjHhm4.js"),Le=require("./index-CwyAfCwY.js"),Me=require("./index-B2XtpfGY.js"),K=require("./index-CzY-WZXL.js"),ke=require("./index-Ce5TOFAK.js"),Ve=require("./index-MQ0c3ZX_.js"),oe=require("./index-Cl3G0jzM.js"),$e=require("class-variance-authority"),He=require("lucide-react"),S=require("./utils-IjLH3w2e.js");function re(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const r=re(Ae),Ke=re(Ie);var z="ToastProvider",[G,qe,We]=Fe.createCollection("Toast"),[ne]=Oe.createContextScope("Toast",[We]),[Xe,q]=ne(z),ae=e=>{const{__scopeToast:t,label:s="Notification",duration:o=5e3,swipeDirection:u="right",swipeThreshold:l=50,children:p}=e,[v,E]=r.useState(null),[c,b]=r.useState(0),T=r.useRef(!1),_=r.useRef(!1);return s.trim()||console.error(`Invalid prop \`label\` supplied to \`${z}\`. Expected non-empty \`string\`.`),n.jsxRuntimeExports.jsx(G.Provider,{scope:t,children:n.jsxRuntimeExports.jsx(Xe,{scope:t,label:s,duration:o,swipeDirection:u,swipeThreshold:l,toastCount:c,viewport:v,onViewportChange:E,onToastAdd:r.useCallback(()=>b(C=>C+1),[]),onToastRemove:r.useCallback(()=>b(C=>C-1),[]),isFocusedToastEscapeKeyDownRef:T,isClosePausedRef:_,children:p})})};ae.displayName=z;var ie="ToastViewport",Ue=["F8"],U="toast.viewportPause",Y="toast.viewportResume",ce=r.forwardRef((e,t)=>{const{__scopeToast:s,hotkey:o=Ue,label:u="Notifications ({hotkey})",...l}=e,p=q(ie,s),v=qe(s),E=r.useRef(null),c=r.useRef(null),b=r.useRef(null),T=r.useRef(null),_=te.useComposedRefs(t,T,p.onViewportChange),C=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=p.toastCount>0;r.useEffect(()=>{const i=y=>{o.length!==0&&o.every(m=>y[m]||y.code===m)&&T.current?.focus()};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[o]),r.useEffect(()=>{const i=E.current,y=T.current;if(j&&i&&y){const f=()=>{if(!p.isClosePausedRef.current){const w=new CustomEvent(U);y.dispatchEvent(w),p.isClosePausedRef.current=!0}},m=()=>{if(p.isClosePausedRef.current){const w=new CustomEvent(Y);y.dispatchEvent(w),p.isClosePausedRef.current=!1}},R=w=>{!i.contains(w.relatedTarget)&&m()},g=()=>{i.contains(document.activeElement)||m()};return i.addEventListener("focusin",f),i.addEventListener("focusout",R),i.addEventListener("pointermove",f),i.addEventListener("pointerleave",g),window.addEventListener("blur",f),window.addEventListener("focus",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",R),i.removeEventListener("pointermove",f),i.removeEventListener("pointerleave",g),window.removeEventListener("blur",f),window.removeEventListener("focus",m)}}},[j,p.isClosePausedRef]);const d=r.useCallback(({tabbingDirection:i})=>{const f=v().map(m=>{const R=m.ref.current,g=[R,...nt(R)];return i==="forwards"?g:g.reverse()});return(i==="forwards"?f.reverse():f).flat()},[v]);return r.useEffect(()=>{const i=T.current;if(i){const y=f=>{const m=f.altKey||f.ctrlKey||f.metaKey;if(f.key==="Tab"&&!m){const g=document.activeElement,w=f.shiftKey;if(f.target===i&&w){c.current?.focus();return}const A=d({tabbingDirection:w?"backwards":"forwards"}),M=A.findIndex(N=>N===g);X(A.slice(M+1))?f.preventDefault():w?c.current?.focus():b.current?.focus()}};return i.addEventListener("keydown",y),()=>i.removeEventListener("keydown",y)}},[v,d]),n.jsxRuntimeExports.jsxs(se.Branch,{ref:E,role:"region","aria-label":u.replace("{hotkey}",C),tabIndex:-1,style:{pointerEvents:j?void 0:"none"},children:[j&&n.jsxRuntimeExports.jsx(B,{ref:c,onFocusFromOutsideViewport:()=>{const i=d({tabbingDirection:"forwards"});X(i)}}),n.jsxRuntimeExports.jsx(G.Slot,{scope:s,children:n.jsxRuntimeExports.jsx(x.Primitive.ol,{tabIndex:-1,...l,ref:_})}),j&&n.jsxRuntimeExports.jsx(B,{ref:b,onFocusFromOutsideViewport:()=>{const i=d({tabbingDirection:"backwards"});X(i)}})]})});ce.displayName=ie;var ue="ToastFocusProxy",B=r.forwardRef((e,t)=>{const{__scopeToast:s,onFocusFromOutsideViewport:o,...u}=e,l=q(ue,s);return n.jsxRuntimeExports.jsx(oe.VisuallyHidden,{tabIndex:0,...u,ref:t,style:{position:"fixed"},onFocus:p=>{const v=p.relatedTarget;!l.viewport?.contains(v)&&o()}})});B.displayName=ue;var O="Toast",Ye="toast.swipeStart",Be="toast.swipeMove",ze="toast.swipeCancel",Ge="toast.swipeEnd",de=r.forwardRef((e,t)=>{const{forceMount:s,open:o,defaultOpen:u,onOpenChange:l,...p}=e,[v,E]=ke.useControllableState({prop:o,defaultProp:u??!0,onChange:l,caller:O});return n.jsxRuntimeExports.jsx(Me.Presence,{present:s||v,children:n.jsxRuntimeExports.jsx(Ze,{open:v,...p,ref:t,onClose:()=>E(!1),onPause:K.useCallbackRef(e.onPause),onResume:K.useCallbackRef(e.onResume),onSwipeStart:x.composeEventHandlers(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:x.composeEventHandlers(e.onSwipeMove,c=>{const{x:b,y:T}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${b}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${T}px`)}),onSwipeCancel:x.composeEventHandlers(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:x.composeEventHandlers(e.onSwipeEnd,c=>{const{x:b,y:T}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${b}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${T}px`),E(!1)})})})});de.displayName=O;var[Je,Qe]=ne(O,{onClose(){}}),Ze=r.forwardRef((e,t)=>{const{__scopeToast:s,type:o="foreground",duration:u,open:l,onClose:p,onEscapeKeyDown:v,onPause:E,onResume:c,onSwipeStart:b,onSwipeMove:T,onSwipeCancel:_,onSwipeEnd:C,...j}=e,d=q(O,s),[i,y]=r.useState(null),f=te.useComposedRefs(t,a=>y(a)),m=r.useRef(null),R=r.useRef(null),g=u||d.duration,w=r.useRef(0),D=r.useRef(g),L=r.useRef(0),{onToastAdd:A,onToastRemove:M}=d,N=K.useCallbackRef(()=>{i?.contains(document.activeElement)&&d.viewport?.focus(),p()}),k=r.useCallback(a=>{!a||a===1/0||(window.clearTimeout(L.current),w.current=new Date().getTime(),L.current=window.setTimeout(N,a))},[N]);r.useEffect(()=>{const a=d.viewport;if(a){const h=()=>{k(D.current),c?.()},P=()=>{const I=new Date().getTime()-w.current;D.current=D.current-I,window.clearTimeout(L.current),E?.()};return a.addEventListener(U,P),a.addEventListener(Y,h),()=>{a.removeEventListener(U,P),a.removeEventListener(Y,h)}}},[d.viewport,g,E,c,k]),r.useEffect(()=>{l&&!d.isClosePausedRef.current&&k(g)},[l,g,d.isClosePausedRef,k]),r.useEffect(()=>(A(),()=>M()),[A,M]);const Q=r.useMemo(()=>i?Ee(i):null,[i]);return d.viewport?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[Q&&n.jsxRuntimeExports.jsx(et,{__scopeToast:s,role:"status","aria-live":o==="foreground"?"assertive":"polite",children:Q}),n.jsxRuntimeExports.jsx(Je,{scope:s,onClose:N,children:Ke.createPortal(n.jsxRuntimeExports.jsx(G.ItemSlot,{scope:s,children:n.jsxRuntimeExports.jsx(se.Root,{asChild:!0,onEscapeKeyDown:x.composeEventHandlers(v,()=>{d.isFocusedToastEscapeKeyDownRef.current||N(),d.isFocusedToastEscapeKeyDownRef.current=!1}),children:n.jsxRuntimeExports.jsx(x.Primitive.li,{tabIndex:0,"data-state":l?"open":"closed","data-swipe-direction":d.swipeDirection,...j,ref:f,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:x.composeEventHandlers(e.onKeyDown,a=>{a.key==="Escape"&&(v?.(a.nativeEvent),a.nativeEvent.defaultPrevented||(d.isFocusedToastEscapeKeyDownRef.current=!0,N()))}),onPointerDown:x.composeEventHandlers(e.onPointerDown,a=>{a.button===0&&(m.current={x:a.clientX,y:a.clientY})}),onPointerMove:x.composeEventHandlers(e.onPointerMove,a=>{if(!m.current)return;const h=a.clientX-m.current.x,P=a.clientY-m.current.y,I=!!R.current,F=["left","right"].includes(d.swipeDirection),V=["left","up"].includes(d.swipeDirection)?Math.min:Math.max,_e=F?V(0,h):0,De=F?0:V(0,P),W=a.pointerType==="touch"?10:2,$={x:_e,y:De},Z={originalEvent:a,delta:$};I?(R.current=$,H(Be,T,Z,{discrete:!1})):ee($,d.swipeDirection,W)?(R.current=$,H(Ye,b,Z,{discrete:!1}),a.target.setPointerCapture(a.pointerId)):(Math.abs(h)>W||Math.abs(P)>W)&&(m.current=null)}),onPointerUp:x.composeEventHandlers(e.onPointerUp,a=>{const h=R.current,P=a.target;if(P.hasPointerCapture(a.pointerId)&&P.releasePointerCapture(a.pointerId),R.current=null,m.current=null,h){const I=a.currentTarget,F={originalEvent:a,delta:h};ee(h,d.swipeDirection,d.swipeThreshold)?H(Ge,C,F,{discrete:!0}):H(ze,_,F,{discrete:!0}),I.addEventListener("click",V=>V.preventDefault(),{once:!0})}})})})}),d.viewport)})]}):null}),et=e=>{const{__scopeToast:t,children:s,...o}=e,u=q(O,t),[l,p]=r.useState(!1),[v,E]=r.useState(!1);return ot(()=>p(!0)),r.useEffect(()=>{const c=window.setTimeout(()=>E(!0),1e3);return()=>window.clearTimeout(c)},[]),v?null:n.jsxRuntimeExports.jsx(Le.Portal,{asChild:!0,children:n.jsxRuntimeExports.jsx(oe.VisuallyHidden,{...o,children:l&&n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[u.label," ",s]})})})},tt="ToastTitle",le=r.forwardRef((e,t)=>{const{__scopeToast:s,...o}=e;return n.jsxRuntimeExports.jsx(x.Primitive.div,{...o,ref:t})});le.displayName=tt;var st="ToastDescription",pe=r.forwardRef((e,t)=>{const{__scopeToast:s,...o}=e;return n.jsxRuntimeExports.jsx(x.Primitive.div,{...o,ref:t})});pe.displayName=st;var fe="ToastAction",me=r.forwardRef((e,t)=>{const{altText:s,...o}=e;return s.trim()?n.jsxRuntimeExports.jsx(ve,{altText:s,asChild:!0,children:n.jsxRuntimeExports.jsx(J,{...o,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${fe}\`. Expected non-empty \`string\`.`),null)});me.displayName=fe;var xe="ToastClose",J=r.forwardRef((e,t)=>{const{__scopeToast:s,...o}=e,u=Qe(xe,s);return n.jsxRuntimeExports.jsx(ve,{asChild:!0,children:n.jsxRuntimeExports.jsx(x.Primitive.button,{type:"button",...o,ref:t,onClick:x.composeEventHandlers(e.onClick,u.onClose)})})});J.displayName=xe;var ve=r.forwardRef((e,t)=>{const{__scopeToast:s,altText:o,...u}=e;return n.jsxRuntimeExports.jsx(x.Primitive.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":o||void 0,...u,ref:t})});function Ee(e){const t=[];return Array.from(e.childNodes).forEach(o=>{if(o.nodeType===o.TEXT_NODE&&o.textContent&&t.push(o.textContent),rt(o)){const u=o.ariaHidden||o.hidden||o.style.display==="none",l=o.dataset.radixToastAnnounceExclude==="";if(!u)if(l){const p=o.dataset.radixToastAnnounceAlt;p&&t.push(p)}else t.push(...Ee(o))}}),t}function H(e,t,s,{discrete:o}){const u=s.originalEvent.currentTarget,l=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:s});t&&u.addEventListener(e,t,{once:!0}),o?x.dispatchDiscreteCustomEvent(u,l):u.dispatchEvent(l)}var ee=(e,t,s=0)=>{const o=Math.abs(e.x),u=Math.abs(e.y),l=o>u;return t==="left"||t==="right"?l&&o>s:!l&&u>s};function ot(e=()=>{}){const t=K.useCallbackRef(e);Ve.useLayoutEffect2(()=>{let s=0,o=0;return s=window.requestAnimationFrame(()=>o=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(o)}},[t])}function rt(e){return e.nodeType===e.ELEMENT_NODE}function nt(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const u=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||u?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)t.push(s.currentNode);return t}function X(e){const t=document.activeElement;return e.some(s=>s===t?!0:(s.focus(),document.activeElement!==t))}var at=ae,we=ce,Te=de,ye=le,Re=pe,ge=me,be=J;const it=at,he=r.forwardRef(({className:e,...t},s)=>n.jsxRuntimeExports.jsx(we,{ref:s,className:S.cn("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:top-auto sm:right-0 sm:bottom-0 sm:flex-col md:max-w-[420px]",e),...t}));he.displayName=we.displayName;const ct=$e.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Pe=r.forwardRef(({className:e,variant:t,...s},o)=>n.jsxRuntimeExports.jsx(Te,{ref:o,className:S.cn(ct({variant:t}),e),...s}));Pe.displayName=Te.displayName;const Ce=r.forwardRef(({className:e,...t},s)=>n.jsxRuntimeExports.jsx(ge,{ref:s,className:S.cn("hover:bg-secondary focus:ring-ring group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors focus:ring-1 focus:outline-none disabled:pointer-events-none disabled:opacity-50",e),...t}));Ce.displayName=ge.displayName;const je=r.forwardRef(({className:e,...t},s)=>n.jsxRuntimeExports.jsx(be,{ref:s,className:S.cn("text-foreground/50 hover:text-foreground absolute top-1 right-1 rounded-md p-1 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:ring-1 focus:outline-none group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:n.jsxRuntimeExports.jsx(He.X,{className:"h-4 w-4"})}));je.displayName=be.displayName;const Ne=r.forwardRef(({className:e,...t},s)=>n.jsxRuntimeExports.jsx(ye,{ref:s,className:S.cn("text-sm font-semibold [&+div]:text-xs",e),...t}));Ne.displayName=ye.displayName;const Se=r.forwardRef(({className:e,...t},s)=>n.jsxRuntimeExports.jsx(Re,{ref:s,className:S.cn("text-sm opacity-90",e),...t}));Se.displayName=Re.displayName;exports.Toast=Pe;exports.ToastAction=Ce;exports.ToastClose=je;exports.ToastDescription=Se;exports.ToastProvider=it;exports.ToastTitle=Ne;exports.ToastViewport=he;
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClassProp } from 'class-variance-authority/types';
|
|
2
|
+
import * as React_2 from 'react';
|
|
3
|
+
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
4
|
+
import { VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
export declare const Toast: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastProps & React_2.RefAttributes<HTMLLIElement>, "ref"> & VariantProps<(props?: ({
|
|
7
|
+
variant?: "default" | "destructive" | null | undefined;
|
|
8
|
+
} & ClassProp) | undefined) => string> & React_2.RefAttributes<HTMLLIElement>>;
|
|
9
|
+
|
|
10
|
+
export declare const ToastAction: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastActionProps & React_2.RefAttributes<HTMLButtonElement>, "ref"> & React_2.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
|
|
12
|
+
export declare type ToastActionElement = React_2.ReactElement<typeof ToastAction>;
|
|
13
|
+
|
|
14
|
+
export declare const ToastClose: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastCloseProps & React_2.RefAttributes<HTMLButtonElement>, "ref"> & React_2.RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
|
|
16
|
+
export declare const ToastDescription: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastDescriptionProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
|
|
18
|
+
export declare type ToastProps = React_2.ComponentPropsWithoutRef<typeof Toast>;
|
|
19
|
+
|
|
20
|
+
export declare const ToastProvider: React_2.FC<ToastPrimitives.ToastProviderProps>;
|
|
21
|
+
|
|
22
|
+
export declare const ToastTitle: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastTitleProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
|
|
24
|
+
export declare const ToastViewport: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastViewportProps & React_2.RefAttributes<HTMLOListElement>, "ref"> & React_2.RefAttributes<HTMLOListElement>>;
|
|
25
|
+
|
|
26
|
+
export { }
|
package/dist/toast.es.js
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { j as n } from "./jsx-runtime-tc70JA_2.mjs";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import * as Re from "react-dom";
|
|
4
|
+
import { P as I, c as P, d as Ce } from "./index-K9FzbxYw.mjs";
|
|
5
|
+
import { u as oe } from "./index-DLcqcWxM.mjs";
|
|
6
|
+
import { c as Ne } from "./index-DFdF7K7v.mjs";
|
|
7
|
+
import { c as Se } from "./index-IZ2gq03c.mjs";
|
|
8
|
+
import { B as Ie, R as Ae } from "./index-Dfzl8TxY.mjs";
|
|
9
|
+
import { P as Fe } from "./index-C7HEunrh.mjs";
|
|
10
|
+
import { P as De } from "./index-vuPgkS0V.mjs";
|
|
11
|
+
import { u as W } from "./index-0ioNhtNM.mjs";
|
|
12
|
+
import { u as _e } from "./index-p6xVFRb4.mjs";
|
|
13
|
+
import { u as je } from "./index-CCKe-Mpx.mjs";
|
|
14
|
+
import { a as re } from "./index-DKN_vhyX.mjs";
|
|
15
|
+
import { cva as Le } from "class-variance-authority";
|
|
16
|
+
import { X as Me } from "lucide-react";
|
|
17
|
+
import { c as A } from "./utils-B6yFEsav.mjs";
|
|
18
|
+
var G = "ToastProvider", [J, Oe, ke] = Ne("Toast"), [se] = Se("Toast", [ke]), [Ve, X] = se(G), ne = (e) => {
|
|
19
|
+
const {
|
|
20
|
+
__scopeToast: t,
|
|
21
|
+
label: o = "Notification",
|
|
22
|
+
duration: r = 5e3,
|
|
23
|
+
swipeDirection: u = "right",
|
|
24
|
+
swipeThreshold: l = 50,
|
|
25
|
+
children: p
|
|
26
|
+
} = e, [v, w] = s.useState(null), [c, h] = s.useState(0), x = s.useRef(!1), F = s.useRef(!1);
|
|
27
|
+
return o.trim() || console.error(
|
|
28
|
+
`Invalid prop \`label\` supplied to \`${G}\`. Expected non-empty \`string\`.`
|
|
29
|
+
), /* @__PURE__ */ n.jsx(J.Provider, { scope: t, children: /* @__PURE__ */ n.jsx(
|
|
30
|
+
Ve,
|
|
31
|
+
{
|
|
32
|
+
scope: t,
|
|
33
|
+
label: o,
|
|
34
|
+
duration: r,
|
|
35
|
+
swipeDirection: u,
|
|
36
|
+
swipeThreshold: l,
|
|
37
|
+
toastCount: c,
|
|
38
|
+
viewport: v,
|
|
39
|
+
onViewportChange: w,
|
|
40
|
+
onToastAdd: s.useCallback(() => h((C) => C + 1), []),
|
|
41
|
+
onToastRemove: s.useCallback(() => h((C) => C - 1), []),
|
|
42
|
+
isFocusedToastEscapeKeyDownRef: x,
|
|
43
|
+
isClosePausedRef: F,
|
|
44
|
+
children: p
|
|
45
|
+
}
|
|
46
|
+
) });
|
|
47
|
+
};
|
|
48
|
+
ne.displayName = G;
|
|
49
|
+
var ae = "ToastViewport", Ke = ["F8"], B = "toast.viewportPause", q = "toast.viewportResume", ie = s.forwardRef(
|
|
50
|
+
(e, t) => {
|
|
51
|
+
const {
|
|
52
|
+
__scopeToast: o,
|
|
53
|
+
hotkey: r = Ke,
|
|
54
|
+
label: u = "Notifications ({hotkey})",
|
|
55
|
+
...l
|
|
56
|
+
} = e, p = X(ae, o), v = Oe(o), w = s.useRef(null), c = s.useRef(null), h = s.useRef(null), x = s.useRef(null), F = oe(t, x, p.onViewportChange), C = r.join("+").replace(/Key/g, "").replace(/Digit/g, ""), N = p.toastCount > 0;
|
|
57
|
+
s.useEffect(() => {
|
|
58
|
+
const i = (E) => {
|
|
59
|
+
r.length !== 0 && r.every((m) => E[m] || E.code === m) && x.current?.focus();
|
|
60
|
+
};
|
|
61
|
+
return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
|
|
62
|
+
}, [r]), s.useEffect(() => {
|
|
63
|
+
const i = w.current, E = x.current;
|
|
64
|
+
if (N && i && E) {
|
|
65
|
+
const f = () => {
|
|
66
|
+
if (!p.isClosePausedRef.current) {
|
|
67
|
+
const T = new CustomEvent(B);
|
|
68
|
+
E.dispatchEvent(T), p.isClosePausedRef.current = !0;
|
|
69
|
+
}
|
|
70
|
+
}, m = () => {
|
|
71
|
+
if (p.isClosePausedRef.current) {
|
|
72
|
+
const T = new CustomEvent(q);
|
|
73
|
+
E.dispatchEvent(T), p.isClosePausedRef.current = !1;
|
|
74
|
+
}
|
|
75
|
+
}, y = (T) => {
|
|
76
|
+
!i.contains(T.relatedTarget) && m();
|
|
77
|
+
}, g = () => {
|
|
78
|
+
i.contains(document.activeElement) || m();
|
|
79
|
+
};
|
|
80
|
+
return i.addEventListener("focusin", f), i.addEventListener("focusout", y), i.addEventListener("pointermove", f), i.addEventListener("pointerleave", g), window.addEventListener("blur", f), window.addEventListener("focus", m), () => {
|
|
81
|
+
i.removeEventListener("focusin", f), i.removeEventListener("focusout", y), i.removeEventListener("pointermove", f), i.removeEventListener("pointerleave", g), window.removeEventListener("blur", f), window.removeEventListener("focus", m);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}, [N, p.isClosePausedRef]);
|
|
85
|
+
const d = s.useCallback(
|
|
86
|
+
({ tabbingDirection: i }) => {
|
|
87
|
+
const f = v().map((m) => {
|
|
88
|
+
const y = m.ref.current, g = [y, ...Ze(y)];
|
|
89
|
+
return i === "forwards" ? g : g.reverse();
|
|
90
|
+
});
|
|
91
|
+
return (i === "forwards" ? f.reverse() : f).flat();
|
|
92
|
+
},
|
|
93
|
+
[v]
|
|
94
|
+
);
|
|
95
|
+
return s.useEffect(() => {
|
|
96
|
+
const i = x.current;
|
|
97
|
+
if (i) {
|
|
98
|
+
const E = (f) => {
|
|
99
|
+
const m = f.altKey || f.ctrlKey || f.metaKey;
|
|
100
|
+
if (f.key === "Tab" && !m) {
|
|
101
|
+
const g = document.activeElement, T = f.shiftKey;
|
|
102
|
+
if (f.target === i && T) {
|
|
103
|
+
c.current?.focus();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const _ = d({ tabbingDirection: T ? "backwards" : "forwards" }), k = _.findIndex((S) => S === g);
|
|
107
|
+
Y(_.slice(k + 1)) ? f.preventDefault() : T ? c.current?.focus() : h.current?.focus();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return i.addEventListener("keydown", E), () => i.removeEventListener("keydown", E);
|
|
111
|
+
}
|
|
112
|
+
}, [v, d]), /* @__PURE__ */ n.jsxs(
|
|
113
|
+
Ie,
|
|
114
|
+
{
|
|
115
|
+
ref: w,
|
|
116
|
+
role: "region",
|
|
117
|
+
"aria-label": u.replace("{hotkey}", C),
|
|
118
|
+
tabIndex: -1,
|
|
119
|
+
style: { pointerEvents: N ? void 0 : "none" },
|
|
120
|
+
children: [
|
|
121
|
+
N && /* @__PURE__ */ n.jsx(
|
|
122
|
+
z,
|
|
123
|
+
{
|
|
124
|
+
ref: c,
|
|
125
|
+
onFocusFromOutsideViewport: () => {
|
|
126
|
+
const i = d({
|
|
127
|
+
tabbingDirection: "forwards"
|
|
128
|
+
});
|
|
129
|
+
Y(i);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ n.jsx(J.Slot, { scope: o, children: /* @__PURE__ */ n.jsx(I.ol, { tabIndex: -1, ...l, ref: F }) }),
|
|
134
|
+
N && /* @__PURE__ */ n.jsx(
|
|
135
|
+
z,
|
|
136
|
+
{
|
|
137
|
+
ref: h,
|
|
138
|
+
onFocusFromOutsideViewport: () => {
|
|
139
|
+
const i = d({
|
|
140
|
+
tabbingDirection: "backwards"
|
|
141
|
+
});
|
|
142
|
+
Y(i);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
ie.displayName = ae;
|
|
152
|
+
var ce = "ToastFocusProxy", z = s.forwardRef(
|
|
153
|
+
(e, t) => {
|
|
154
|
+
const { __scopeToast: o, onFocusFromOutsideViewport: r, ...u } = e, l = X(ce, o);
|
|
155
|
+
return /* @__PURE__ */ n.jsx(
|
|
156
|
+
re,
|
|
157
|
+
{
|
|
158
|
+
tabIndex: 0,
|
|
159
|
+
...u,
|
|
160
|
+
ref: t,
|
|
161
|
+
style: { position: "fixed" },
|
|
162
|
+
onFocus: (p) => {
|
|
163
|
+
const v = p.relatedTarget;
|
|
164
|
+
!l.viewport?.contains(v) && r();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
z.displayName = ce;
|
|
171
|
+
var M = "Toast", $e = "toast.swipeStart", He = "toast.swipeMove", We = "toast.swipeCancel", Xe = "toast.swipeEnd", ue = s.forwardRef(
|
|
172
|
+
(e, t) => {
|
|
173
|
+
const { forceMount: o, open: r, defaultOpen: u, onOpenChange: l, ...p } = e, [v, w] = _e({
|
|
174
|
+
prop: r,
|
|
175
|
+
defaultProp: u ?? !0,
|
|
176
|
+
onChange: l,
|
|
177
|
+
caller: M
|
|
178
|
+
});
|
|
179
|
+
return /* @__PURE__ */ n.jsx(De, { present: o || v, children: /* @__PURE__ */ n.jsx(
|
|
180
|
+
Be,
|
|
181
|
+
{
|
|
182
|
+
open: v,
|
|
183
|
+
...p,
|
|
184
|
+
ref: t,
|
|
185
|
+
onClose: () => w(!1),
|
|
186
|
+
onPause: W(e.onPause),
|
|
187
|
+
onResume: W(e.onResume),
|
|
188
|
+
onSwipeStart: P(e.onSwipeStart, (c) => {
|
|
189
|
+
c.currentTarget.setAttribute("data-swipe", "start");
|
|
190
|
+
}),
|
|
191
|
+
onSwipeMove: P(e.onSwipeMove, (c) => {
|
|
192
|
+
const { x: h, y: x } = c.detail.delta;
|
|
193
|
+
c.currentTarget.setAttribute("data-swipe", "move"), c.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${h}px`), c.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${x}px`);
|
|
194
|
+
}),
|
|
195
|
+
onSwipeCancel: P(e.onSwipeCancel, (c) => {
|
|
196
|
+
c.currentTarget.setAttribute("data-swipe", "cancel"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
|
197
|
+
}),
|
|
198
|
+
onSwipeEnd: P(e.onSwipeEnd, (c) => {
|
|
199
|
+
const { x: h, y: x } = c.detail.delta;
|
|
200
|
+
c.currentTarget.setAttribute("data-swipe", "end"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), c.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${h}px`), c.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${x}px`), w(!1);
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
) });
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
ue.displayName = M;
|
|
207
|
+
var [Ue, Ye] = se(M, {
|
|
208
|
+
onClose() {
|
|
209
|
+
}
|
|
210
|
+
}), Be = s.forwardRef(
|
|
211
|
+
(e, t) => {
|
|
212
|
+
const {
|
|
213
|
+
__scopeToast: o,
|
|
214
|
+
type: r = "foreground",
|
|
215
|
+
duration: u,
|
|
216
|
+
open: l,
|
|
217
|
+
onClose: p,
|
|
218
|
+
onEscapeKeyDown: v,
|
|
219
|
+
onPause: w,
|
|
220
|
+
onResume: c,
|
|
221
|
+
onSwipeStart: h,
|
|
222
|
+
onSwipeMove: x,
|
|
223
|
+
onSwipeCancel: F,
|
|
224
|
+
onSwipeEnd: C,
|
|
225
|
+
...N
|
|
226
|
+
} = e, d = X(M, o), [i, E] = s.useState(null), f = oe(t, (a) => E(a)), m = s.useRef(null), y = s.useRef(null), g = u || d.duration, T = s.useRef(0), D = s.useRef(g), O = s.useRef(0), { onToastAdd: _, onToastRemove: k } = d, S = W(() => {
|
|
227
|
+
i?.contains(document.activeElement) && d.viewport?.focus(), p();
|
|
228
|
+
}), V = s.useCallback(
|
|
229
|
+
(a) => {
|
|
230
|
+
!a || a === 1 / 0 || (window.clearTimeout(O.current), T.current = (/* @__PURE__ */ new Date()).getTime(), O.current = window.setTimeout(S, a));
|
|
231
|
+
},
|
|
232
|
+
[S]
|
|
233
|
+
);
|
|
234
|
+
s.useEffect(() => {
|
|
235
|
+
const a = d.viewport;
|
|
236
|
+
if (a) {
|
|
237
|
+
const b = () => {
|
|
238
|
+
V(D.current), c?.();
|
|
239
|
+
}, R = () => {
|
|
240
|
+
const j = (/* @__PURE__ */ new Date()).getTime() - T.current;
|
|
241
|
+
D.current = D.current - j, window.clearTimeout(O.current), w?.();
|
|
242
|
+
};
|
|
243
|
+
return a.addEventListener(B, R), a.addEventListener(q, b), () => {
|
|
244
|
+
a.removeEventListener(B, R), a.removeEventListener(q, b);
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}, [d.viewport, g, w, c, V]), s.useEffect(() => {
|
|
248
|
+
l && !d.isClosePausedRef.current && V(g);
|
|
249
|
+
}, [l, g, d.isClosePausedRef, V]), s.useEffect(() => (_(), () => k()), [_, k]);
|
|
250
|
+
const Z = s.useMemo(() => i ? we(i) : null, [i]);
|
|
251
|
+
return d.viewport ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
252
|
+
Z && /* @__PURE__ */ n.jsx(
|
|
253
|
+
qe,
|
|
254
|
+
{
|
|
255
|
+
__scopeToast: o,
|
|
256
|
+
role: "status",
|
|
257
|
+
"aria-live": r === "foreground" ? "assertive" : "polite",
|
|
258
|
+
children: Z
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ n.jsx(Ue, { scope: o, onClose: S, children: Re.createPortal(
|
|
262
|
+
/* @__PURE__ */ n.jsx(J.ItemSlot, { scope: o, children: /* @__PURE__ */ n.jsx(
|
|
263
|
+
Ae,
|
|
264
|
+
{
|
|
265
|
+
asChild: !0,
|
|
266
|
+
onEscapeKeyDown: P(v, () => {
|
|
267
|
+
d.isFocusedToastEscapeKeyDownRef.current || S(), d.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
268
|
+
}),
|
|
269
|
+
children: /* @__PURE__ */ n.jsx(
|
|
270
|
+
I.li,
|
|
271
|
+
{
|
|
272
|
+
tabIndex: 0,
|
|
273
|
+
"data-state": l ? "open" : "closed",
|
|
274
|
+
"data-swipe-direction": d.swipeDirection,
|
|
275
|
+
...N,
|
|
276
|
+
ref: f,
|
|
277
|
+
style: { userSelect: "none", touchAction: "none", ...e.style },
|
|
278
|
+
onKeyDown: P(e.onKeyDown, (a) => {
|
|
279
|
+
a.key === "Escape" && (v?.(a.nativeEvent), a.nativeEvent.defaultPrevented || (d.isFocusedToastEscapeKeyDownRef.current = !0, S()));
|
|
280
|
+
}),
|
|
281
|
+
onPointerDown: P(e.onPointerDown, (a) => {
|
|
282
|
+
a.button === 0 && (m.current = { x: a.clientX, y: a.clientY });
|
|
283
|
+
}),
|
|
284
|
+
onPointerMove: P(e.onPointerMove, (a) => {
|
|
285
|
+
if (!m.current) return;
|
|
286
|
+
const b = a.clientX - m.current.x, R = a.clientY - m.current.y, j = !!y.current, L = ["left", "right"].includes(d.swipeDirection), K = ["left", "up"].includes(d.swipeDirection) ? Math.min : Math.max, Pe = L ? K(0, b) : 0, be = L ? 0 : K(0, R), U = a.pointerType === "touch" ? 10 : 2, $ = { x: Pe, y: be }, ee = { originalEvent: a, delta: $ };
|
|
287
|
+
j ? (y.current = $, H(He, x, ee, {
|
|
288
|
+
discrete: !1
|
|
289
|
+
})) : te($, d.swipeDirection, U) ? (y.current = $, H($e, h, ee, {
|
|
290
|
+
discrete: !1
|
|
291
|
+
}), a.target.setPointerCapture(a.pointerId)) : (Math.abs(b) > U || Math.abs(R) > U) && (m.current = null);
|
|
292
|
+
}),
|
|
293
|
+
onPointerUp: P(e.onPointerUp, (a) => {
|
|
294
|
+
const b = y.current, R = a.target;
|
|
295
|
+
if (R.hasPointerCapture(a.pointerId) && R.releasePointerCapture(a.pointerId), y.current = null, m.current = null, b) {
|
|
296
|
+
const j = a.currentTarget, L = { originalEvent: a, delta: b };
|
|
297
|
+
te(b, d.swipeDirection, d.swipeThreshold) ? H(Xe, C, L, {
|
|
298
|
+
discrete: !0
|
|
299
|
+
}) : H(
|
|
300
|
+
We,
|
|
301
|
+
F,
|
|
302
|
+
L,
|
|
303
|
+
{
|
|
304
|
+
discrete: !0
|
|
305
|
+
}
|
|
306
|
+
), j.addEventListener("click", (K) => K.preventDefault(), {
|
|
307
|
+
once: !0
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
) }),
|
|
315
|
+
d.viewport
|
|
316
|
+
) })
|
|
317
|
+
] }) : null;
|
|
318
|
+
}
|
|
319
|
+
), qe = (e) => {
|
|
320
|
+
const { __scopeToast: t, children: o, ...r } = e, u = X(M, t), [l, p] = s.useState(!1), [v, w] = s.useState(!1);
|
|
321
|
+
return Je(() => p(!0)), s.useEffect(() => {
|
|
322
|
+
const c = window.setTimeout(() => w(!0), 1e3);
|
|
323
|
+
return () => window.clearTimeout(c);
|
|
324
|
+
}, []), v ? null : /* @__PURE__ */ n.jsx(Fe, { asChild: !0, children: /* @__PURE__ */ n.jsx(re, { ...r, children: l && /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
325
|
+
u.label,
|
|
326
|
+
" ",
|
|
327
|
+
o
|
|
328
|
+
] }) }) });
|
|
329
|
+
}, ze = "ToastTitle", de = s.forwardRef(
|
|
330
|
+
(e, t) => {
|
|
331
|
+
const { __scopeToast: o, ...r } = e;
|
|
332
|
+
return /* @__PURE__ */ n.jsx(I.div, { ...r, ref: t });
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
de.displayName = ze;
|
|
336
|
+
var Ge = "ToastDescription", le = s.forwardRef(
|
|
337
|
+
(e, t) => {
|
|
338
|
+
const { __scopeToast: o, ...r } = e;
|
|
339
|
+
return /* @__PURE__ */ n.jsx(I.div, { ...r, ref: t });
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
le.displayName = Ge;
|
|
343
|
+
var pe = "ToastAction", fe = s.forwardRef(
|
|
344
|
+
(e, t) => {
|
|
345
|
+
const { altText: o, ...r } = e;
|
|
346
|
+
return o.trim() ? /* @__PURE__ */ n.jsx(ve, { altText: o, asChild: !0, children: /* @__PURE__ */ n.jsx(Q, { ...r, ref: t }) }) : (console.error(
|
|
347
|
+
`Invalid prop \`altText\` supplied to \`${pe}\`. Expected non-empty \`string\`.`
|
|
348
|
+
), null);
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
fe.displayName = pe;
|
|
352
|
+
var me = "ToastClose", Q = s.forwardRef(
|
|
353
|
+
(e, t) => {
|
|
354
|
+
const { __scopeToast: o, ...r } = e, u = Ye(me, o);
|
|
355
|
+
return /* @__PURE__ */ n.jsx(ve, { asChild: !0, children: /* @__PURE__ */ n.jsx(
|
|
356
|
+
I.button,
|
|
357
|
+
{
|
|
358
|
+
type: "button",
|
|
359
|
+
...r,
|
|
360
|
+
ref: t,
|
|
361
|
+
onClick: P(e.onClick, u.onClose)
|
|
362
|
+
}
|
|
363
|
+
) });
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
Q.displayName = me;
|
|
367
|
+
var ve = s.forwardRef((e, t) => {
|
|
368
|
+
const { __scopeToast: o, altText: r, ...u } = e;
|
|
369
|
+
return /* @__PURE__ */ n.jsx(
|
|
370
|
+
I.div,
|
|
371
|
+
{
|
|
372
|
+
"data-radix-toast-announce-exclude": "",
|
|
373
|
+
"data-radix-toast-announce-alt": r || void 0,
|
|
374
|
+
...u,
|
|
375
|
+
ref: t
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
});
|
|
379
|
+
function we(e) {
|
|
380
|
+
const t = [];
|
|
381
|
+
return Array.from(e.childNodes).forEach((r) => {
|
|
382
|
+
if (r.nodeType === r.TEXT_NODE && r.textContent && t.push(r.textContent), Qe(r)) {
|
|
383
|
+
const u = r.ariaHidden || r.hidden || r.style.display === "none", l = r.dataset.radixToastAnnounceExclude === "";
|
|
384
|
+
if (!u)
|
|
385
|
+
if (l) {
|
|
386
|
+
const p = r.dataset.radixToastAnnounceAlt;
|
|
387
|
+
p && t.push(p);
|
|
388
|
+
} else
|
|
389
|
+
t.push(...we(r));
|
|
390
|
+
}
|
|
391
|
+
}), t;
|
|
392
|
+
}
|
|
393
|
+
function H(e, t, o, { discrete: r }) {
|
|
394
|
+
const u = o.originalEvent.currentTarget, l = new CustomEvent(e, { bubbles: !0, cancelable: !0, detail: o });
|
|
395
|
+
t && u.addEventListener(e, t, { once: !0 }), r ? Ce(u, l) : u.dispatchEvent(l);
|
|
396
|
+
}
|
|
397
|
+
var te = (e, t, o = 0) => {
|
|
398
|
+
const r = Math.abs(e.x), u = Math.abs(e.y), l = r > u;
|
|
399
|
+
return t === "left" || t === "right" ? l && r > o : !l && u > o;
|
|
400
|
+
};
|
|
401
|
+
function Je(e = () => {
|
|
402
|
+
}) {
|
|
403
|
+
const t = W(e);
|
|
404
|
+
je(() => {
|
|
405
|
+
let o = 0, r = 0;
|
|
406
|
+
return o = window.requestAnimationFrame(() => r = window.requestAnimationFrame(t)), () => {
|
|
407
|
+
window.cancelAnimationFrame(o), window.cancelAnimationFrame(r);
|
|
408
|
+
};
|
|
409
|
+
}, [t]);
|
|
410
|
+
}
|
|
411
|
+
function Qe(e) {
|
|
412
|
+
return e.nodeType === e.ELEMENT_NODE;
|
|
413
|
+
}
|
|
414
|
+
function Ze(e) {
|
|
415
|
+
const t = [], o = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
|
|
416
|
+
acceptNode: (r) => {
|
|
417
|
+
const u = r.tagName === "INPUT" && r.type === "hidden";
|
|
418
|
+
return r.disabled || r.hidden || u ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
for (; o.nextNode(); ) t.push(o.currentNode);
|
|
422
|
+
return t;
|
|
423
|
+
}
|
|
424
|
+
function Y(e) {
|
|
425
|
+
const t = document.activeElement;
|
|
426
|
+
return e.some((o) => o === t ? !0 : (o.focus(), document.activeElement !== t));
|
|
427
|
+
}
|
|
428
|
+
var et = ne, Te = ie, xe = ue, Ee = de, ye = le, ge = fe, he = Q;
|
|
429
|
+
const Pt = et, tt = s.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ n.jsx(
|
|
430
|
+
Te,
|
|
431
|
+
{
|
|
432
|
+
ref: o,
|
|
433
|
+
className: A(
|
|
434
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:top-auto sm:right-0 sm:bottom-0 sm:flex-col md:max-w-[420px]",
|
|
435
|
+
e
|
|
436
|
+
),
|
|
437
|
+
...t
|
|
438
|
+
}
|
|
439
|
+
));
|
|
440
|
+
tt.displayName = Te.displayName;
|
|
441
|
+
const ot = Le(
|
|
442
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
443
|
+
{
|
|
444
|
+
variants: {
|
|
445
|
+
variant: {
|
|
446
|
+
default: "border bg-background text-foreground",
|
|
447
|
+
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
defaultVariants: {
|
|
451
|
+
variant: "default"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
), rt = s.forwardRef(({ className: e, variant: t, ...o }, r) => /* @__PURE__ */ n.jsx(xe, { ref: r, className: A(ot({ variant: t }), e), ...o }));
|
|
455
|
+
rt.displayName = xe.displayName;
|
|
456
|
+
const st = s.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ n.jsx(
|
|
457
|
+
ge,
|
|
458
|
+
{
|
|
459
|
+
ref: o,
|
|
460
|
+
className: A(
|
|
461
|
+
"hover:bg-secondary focus:ring-ring group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors focus:ring-1 focus:outline-none disabled:pointer-events-none disabled:opacity-50",
|
|
462
|
+
e
|
|
463
|
+
),
|
|
464
|
+
...t
|
|
465
|
+
}
|
|
466
|
+
));
|
|
467
|
+
st.displayName = ge.displayName;
|
|
468
|
+
const nt = s.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ n.jsx(
|
|
469
|
+
he,
|
|
470
|
+
{
|
|
471
|
+
ref: o,
|
|
472
|
+
className: A(
|
|
473
|
+
"text-foreground/50 hover:text-foreground absolute top-1 right-1 rounded-md p-1 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:ring-1 focus:outline-none group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
474
|
+
e
|
|
475
|
+
),
|
|
476
|
+
"toast-close": "",
|
|
477
|
+
...t,
|
|
478
|
+
children: /* @__PURE__ */ n.jsx(Me, { className: "h-4 w-4" })
|
|
479
|
+
}
|
|
480
|
+
));
|
|
481
|
+
nt.displayName = he.displayName;
|
|
482
|
+
const at = s.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ n.jsx(Ee, { ref: o, className: A("text-sm font-semibold [&+div]:text-xs", e), ...t }));
|
|
483
|
+
at.displayName = Ee.displayName;
|
|
484
|
+
const it = s.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ n.jsx(ye, { ref: o, className: A("text-sm opacity-90", e), ...t }));
|
|
485
|
+
it.displayName = ye.displayName;
|
|
486
|
+
export {
|
|
487
|
+
rt as Toast,
|
|
488
|
+
st as ToastAction,
|
|
489
|
+
nt as ToastClose,
|
|
490
|
+
it as ToastDescription,
|
|
491
|
+
Pt as ToastProvider,
|
|
492
|
+
at as ToastTitle,
|
|
493
|
+
tt as ToastViewport
|
|
494
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("./jsx-runtime-nZSsnGb7.js"),m=require("react"),T=require("./toast.cjs.js");function _(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const d=_(m),x=1,D=1e6,u={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"};let S=0;function j(){return S=(S+1)%Number.MAX_SAFE_INTEGER,S.toString()}const p=new Map,O=t=>{if(p.has(t))return;const s=setTimeout(()=>{p.delete(t),i({type:"REMOVE_TOAST",toastId:t})},D);p.set(t,s)},R=(t,s)=>{switch(s.type){case u.ADD_TOAST:return{...t,toasts:[s.toast,...t.toasts].slice(0,x)};case u.UPDATE_TOAST:return{...t,toasts:t.toasts.map(e=>e.id===s.toast.id?{...e,...s.toast}:e)};case u.DISMISS_TOAST:{const{toastId:e}=s;return e?O(e):t.toasts.forEach(o=>{O(o.id)}),{...t,toasts:t.toasts.map(o=>o.id===e||e===void 0?{...o,open:!1}:o)}}case u.REMOVE_TOAST:return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(e=>e.id!==s.toastId)}}},a=[];let c={toasts:[]};function i(t){c=R(c,t),a.forEach(s=>{s(c)})}function A({...t}){const s=j(),e=r=>i({type:"UPDATE_TOAST",toast:{...r,id:s}}),o=()=>i({type:"DISMISS_TOAST",toastId:s});return i({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:r=>{r||o()}}}),{id:s,dismiss:o,update:e}}function E(){const[t,s]=d.useState(c);return d.useEffect(()=>(a.push(s),()=>{const e=a.indexOf(s);e>-1&&a.splice(e,1)}),[t]),{...t,toast:A,dismiss:e=>i({type:"DISMISS_TOAST",toastId:e})}}function I({...t}){const{toasts:s}=E();return n.jsxRuntimeExports.jsxs(T.ToastProvider,{...t,children:[s.map(function({id:e,title:o,description:r,action:f,...l}){return n.jsxRuntimeExports.jsxs(T.Toast,{...l,children:[n.jsxRuntimeExports.jsxs("div",{className:"grid gap-1",children:[o&&n.jsxRuntimeExports.jsx(T.ToastTitle,{children:o}),r&&n.jsxRuntimeExports.jsx(T.ToastDescription,{children:r})]}),f,n.jsxRuntimeExports.jsx(T.ToastClose,{})]},e)}),n.jsxRuntimeExports.jsx(T.ToastViewport,{})]})}exports.Toaster=I;exports.toast=A;exports.useToast=E;
|