ivt 0.3.3 → 0.3.4
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/index.mjs +19 -1
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/alert/index.mjs +43 -1
- package/dist/alert/index.mjs.map +1 -1
- package/dist/alert-dialog/index.mjs +260 -1
- package/dist/alert-dialog/index.mjs.map +1 -1
- package/dist/avatar/index.mjs +164 -1
- package/dist/avatar/index.mjs.map +1 -1
- package/dist/badge/index.mjs +6 -1
- package/dist/badge/index.mjs.map +1 -1
- package/dist/base/index.mjs +760 -1
- package/dist/base/index.mjs.map +1 -1
- package/dist/button/index.mjs +6 -1
- package/dist/button/index.mjs.map +1 -1
- package/dist/calendar/index.mjs +11 -1
- package/dist/calendar/index.mjs.map +1 -1
- package/dist/card/index.mjs +55 -1
- package/dist/card/index.mjs.map +1 -1
- package/dist/chart/index.mjs +17042 -1
- package/dist/chart/index.mjs.map +1 -1
- package/dist/checkbox/index.mjs +223 -1
- package/dist/checkbox/index.mjs.map +1 -1
- package/dist/chunks/_commonjsHelpers-DqEvkrE1.mjs +6 -0
- package/dist/chunks/_commonjsHelpers-DqEvkrE1.mjs.map +1 -0
- package/dist/chunks/accordion-BMP2PSSC.mjs +455 -0
- package/dist/chunks/{accordion-CdshDFZC.mjs.map → accordion-BMP2PSSC.mjs.map} +1 -1
- package/dist/chunks/badge-DxuZhgBF.mjs +57 -0
- package/dist/chunks/{badge-BYqshEmA.mjs.map → badge-DxuZhgBF.mjs.map} +1 -1
- package/dist/chunks/bundle-mjs-tFg__FnT.mjs +4491 -0
- package/dist/chunks/{bundle-mjs-9BXytT_r.mjs.map → bundle-mjs-tFg__FnT.mjs.map} +1 -1
- package/dist/chunks/button-CX0htulo.mjs +47 -0
- package/dist/chunks/{button-DrFZXJ7z.mjs.map → button-CX0htulo.mjs.map} +1 -1
- package/dist/chunks/calendar-B4IV5RyM.mjs +7106 -0
- package/dist/chunks/calendar-B4IV5RyM.mjs.map +1 -0
- package/dist/chunks/check-B7209s3e.mjs +15 -0
- package/dist/chunks/{check-CimnOyD7.mjs.map → check-B7209s3e.mjs.map} +1 -1
- package/dist/chunks/chevron-down-D84DRJBv.mjs +15 -0
- package/dist/chunks/{chevron-down-D3fvbjxE.mjs.map → chevron-down-D84DRJBv.mjs.map} +1 -1
- package/dist/chunks/chevron-left-DtL1t1DJ.mjs +15 -0
- package/dist/chunks/{chevron-left-CrN7DlXg.mjs.map → chevron-left-DtL1t1DJ.mjs.map} +1 -1
- package/dist/chunks/chevron-right-Cdxg1JSQ.mjs +15 -0
- package/dist/chunks/{chevron-right-BMSCuDGK.mjs.map → chevron-right-Cdxg1JSQ.mjs.map} +1 -1
- package/dist/chunks/chevrons-up-down-DtBUG1i8.mjs +22 -0
- package/dist/chunks/{chevrons-up-down-DBgvRkZm.mjs.map → chevrons-up-down-DtBUG1i8.mjs.map} +1 -1
- package/dist/chunks/circle-BLWMZ9yp.mjs +17 -0
- package/dist/chunks/{circle-CGqt18Bd.mjs.map → circle-BLWMZ9yp.mjs.map} +1 -1
- package/dist/chunks/command-C8cVzg-x.mjs +611 -0
- package/dist/chunks/command-C8cVzg-x.mjs.map +1 -0
- package/dist/chunks/createLucideIcon-Ba0IWqsz.mjs +60 -0
- package/dist/chunks/{createLucideIcon-L-tld2uc.mjs.map → createLucideIcon-Ba0IWqsz.mjs.map} +1 -1
- package/dist/chunks/dialog-D9vbxUuQ.mjs +80 -0
- package/dist/chunks/{dialog-36eqHzT3.mjs.map → dialog-D9vbxUuQ.mjs.map} +1 -1
- package/dist/chunks/hover-card-idvDPXrI.mjs +274 -0
- package/dist/chunks/{hover-card-Cnd58du6.mjs.map → hover-card-idvDPXrI.mjs.map} +1 -1
- package/dist/chunks/index-6JUj2Tld.mjs +18 -0
- package/dist/chunks/{index-CRxQlsb9.mjs.map → index-6JUj2Tld.mjs.map} +1 -1
- package/dist/chunks/index-B0IElWB4.mjs +51 -0
- package/dist/chunks/{index-vmPXTidH.mjs.map → index-B0IElWB4.mjs.map} +1 -1
- package/dist/chunks/index-B4VRyyD1.mjs +40 -0
- package/dist/chunks/index-B4VRyyD1.mjs.map +1 -0
- package/dist/chunks/index-BE-_q4IW.mjs +266 -0
- package/dist/chunks/index-BE-_q4IW.mjs.map +1 -0
- package/dist/chunks/index-BNxaLFA6.mjs +216 -0
- package/dist/chunks/{index-LvOFIVGz.mjs.map → index-BNxaLFA6.mjs.map} +1 -1
- package/dist/chunks/index-BZUrHhU8.mjs +7 -0
- package/dist/chunks/{index-CLtWFQL5.mjs.map → index-BZUrHhU8.mjs.map} +1 -1
- package/dist/chunks/index-B_FsTtnF.mjs +110 -0
- package/dist/chunks/{index-CCcl327A.mjs.map → index-B_FsTtnF.mjs.map} +1 -1
- package/dist/chunks/index-CAg47KJ6.mjs +13 -0
- package/dist/chunks/{index-CXszXOf_.mjs.map → index-CAg47KJ6.mjs.map} +1 -1
- package/dist/chunks/index-CXuEm8w1.mjs +12 -0
- package/dist/chunks/{index-CU_y1XAz.mjs.map → index-CXuEm8w1.mjs.map} +1 -1
- package/dist/chunks/index-C_jFwfR_.mjs +77 -0
- package/dist/chunks/{index-CybgQKpz.mjs.map → index-C_jFwfR_.mjs.map} +1 -1
- package/dist/chunks/index-CglX-DNW.mjs +21 -0
- package/dist/chunks/index-CglX-DNW.mjs.map +1 -0
- package/dist/chunks/index-CyMuypYR.mjs +324 -0
- package/dist/chunks/{index-DUNcuWJE.mjs.map → index-CyMuypYR.mjs.map} +1 -1
- package/dist/chunks/index-D0S6rRRE.mjs +50 -0
- package/dist/chunks/{index-w9bxia3O.mjs.map → index-D0S6rRRE.mjs.map} +1 -1
- package/dist/chunks/index-D23BhVQG.mjs +859 -0
- package/dist/chunks/{index-DZHMFdr0.mjs.map → index-D23BhVQG.mjs.map} +1 -1
- package/dist/chunks/index-D2wfJaZh.mjs +145 -0
- package/dist/chunks/index-D2wfJaZh.mjs.map +1 -0
- package/dist/chunks/index-DNvm9MP3.mjs +34 -0
- package/dist/chunks/{index-D2sZp5OP.mjs.map → index-DNvm9MP3.mjs.map} +1 -1
- package/dist/chunks/index-Dm4_czlz.mjs +12 -0
- package/dist/chunks/index-Dm4_czlz.mjs.map +1 -0
- package/dist/chunks/index-PaJVyocC.mjs +151 -0
- package/dist/chunks/index-PaJVyocC.mjs.map +1 -0
- package/dist/chunks/index-kr6_v_F8.mjs +2370 -0
- package/dist/chunks/index-kr6_v_F8.mjs.map +1 -0
- package/dist/chunks/index-sz_BcBbA.mjs +1210 -0
- package/dist/chunks/index-sz_BcBbA.mjs.map +1 -0
- package/dist/chunks/input-DK1slFF1.mjs +14 -0
- package/dist/chunks/{input-85UFztMJ.mjs.map → input-DK1slFF1.mjs.map} +1 -1
- package/dist/chunks/label-D7ONQdHc.mjs +32 -0
- package/dist/chunks/{label-CICFzZIt.mjs.map → label-D7ONQdHc.mjs.map} +1 -1
- package/dist/chunks/pagination-BM_IQ6Qk.mjs +106 -0
- package/dist/chunks/{pagination-CReDQes6.mjs.map → pagination-BM_IQ6Qk.mjs.map} +1 -1
- package/dist/chunks/popover-D3F326FR.mjs +308 -0
- package/dist/chunks/{popover-Cn2ZTvKd.mjs.map → popover-D3F326FR.mjs.map} +1 -1
- package/dist/chunks/progress-BCl5yD5Q.mjs +99 -0
- package/dist/chunks/{progress-CSxQH6-f.mjs.map → progress-BCl5yD5Q.mjs.map} +1 -1
- package/dist/chunks/scroll-area-DB3eUx8V.mjs +791 -0
- package/dist/chunks/scroll-area-DB3eUx8V.mjs.map +1 -0
- package/dist/chunks/select-Cw81y8pT.mjs +104 -0
- package/dist/chunks/{select-BR6_N_Yo.mjs.map → select-Cw81y8pT.mjs.map} +1 -1
- package/dist/chunks/separator-2k1C7RSn.mjs +48 -0
- package/dist/chunks/{separator-BB6-E9Z1.mjs.map → separator-2k1C7RSn.mjs.map} +1 -1
- package/dist/chunks/skeleton-qx8-vr62.mjs +13 -0
- package/dist/chunks/{skeleton-XPWWiaac.mjs.map → skeleton-qx8-vr62.mjs.map} +1 -1
- package/dist/chunks/sortable-D8ayoe_b.mjs +4221 -0
- package/dist/chunks/sortable-D8ayoe_b.mjs.map +1 -0
- package/dist/chunks/table-BDNUhtz-.mjs +62 -0
- package/dist/chunks/{table-LQIHzPHi.mjs.map → table-BDNUhtz-.mjs.map} +1 -1
- package/dist/chunks/toggle-CE2ycSdL.mjs +65 -0
- package/dist/chunks/{toggle-Co72WXGd.mjs.map → toggle-CE2ycSdL.mjs.map} +1 -1
- package/dist/chunks/tooltip-DLD0ycR4.mjs +596 -0
- package/dist/chunks/{tooltip-qX2HjdJP.mjs.map → tooltip-DLD0ycR4.mjs.map} +1 -1
- package/dist/chunks/tslib.es6-BgHLrbno.mjs +61 -0
- package/dist/chunks/{tslib.es6-cMGqxriw.mjs.map → tslib.es6-BgHLrbno.mjs.map} +1 -1
- package/dist/chunks/utils-BUelq9Ro.mjs +42 -0
- package/dist/chunks/utils-BUelq9Ro.mjs.map +1 -0
- package/dist/chunks/x-Bjz0Vo6R.mjs +22 -0
- package/dist/chunks/{x-BNLl0E-E.mjs.map → x-Bjz0Vo6R.mjs.map} +1 -1
- package/dist/combobox/index.mjs +65 -1
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/command/index.mjs +23 -1
- package/dist/command/index.mjs.map +1 -1
- package/dist/data-table/index.mjs +673 -1
- package/dist/data-table/index.mjs.map +1 -1
- package/dist/dialog/index.mjs +22 -1
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/dropdown-menu/index.mjs +438 -1
- package/dist/dropdown-menu/index.mjs.map +1 -1
- package/dist/dropzone/index.mjs +7839 -1
- package/dist/dropzone/index.mjs.map +1 -1
- package/dist/form/index.mjs +649 -1
- package/dist/form/index.mjs.map +1 -1
- package/dist/hover-card/index.mjs +18 -1
- package/dist/hover-card/index.mjs.map +1 -1
- package/dist/icon/index.mjs +317 -1
- package/dist/icon/index.mjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/input/index.mjs +4 -1
- package/dist/input/index.mjs.map +1 -1
- package/dist/ivt.css +1 -1
- package/dist/label/index.mjs +8 -1
- package/dist/label/index.mjs.map +1 -1
- package/dist/menubar/index.mjs +583 -1
- package/dist/menubar/index.mjs.map +1 -1
- package/dist/multi-select/index.mjs +297 -1
- package/dist/multi-select/index.mjs.map +1 -1
- package/dist/pagination/index.mjs +10 -1
- package/dist/pagination/index.mjs.map +1 -1
- package/dist/popover/index.mjs +21 -1
- package/dist/popover/index.mjs.map +1 -1
- package/dist/progress/index.mjs +9 -1
- package/dist/progress/index.mjs.map +1 -1
- package/dist/radio-group/index.mjs +267 -1
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/scroll-area/index.mjs +15 -1
- package/dist/scroll-area/index.mjs.map +1 -1
- package/dist/select/index.mjs +8 -1
- package/dist/select/index.mjs.map +1 -1
- package/dist/separator/index.mjs +8 -1
- package/dist/separator/index.mjs.map +1 -1
- package/dist/sheet/index.mjs +96 -1
- package/dist/sheet/index.mjs.map +1 -1
- package/dist/skeleton/index.mjs +4 -1
- package/dist/skeleton/index.mjs.map +1 -1
- package/dist/sonner/index.mjs +1140 -1
- package/dist/sonner/index.mjs.map +1 -1
- package/dist/sortable/index.mjs +8 -1
- package/dist/sortable/index.mjs.map +1 -1
- package/dist/table/index.mjs +4 -1
- package/dist/table/index.mjs.map +1 -1
- package/dist/tabs/index.mjs +193 -1
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/textarea/index.mjs +13 -1
- package/dist/textarea/index.mjs.map +1 -1
- package/dist/toast/index.mjs +705 -1
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toggle/index.mjs +12 -1
- package/dist/toggle/index.mjs.map +1 -1
- package/dist/toggle-group/index.mjs +219 -1
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/tooltip/index.mjs +20 -1
- package/dist/tooltip/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs +0 -2
- package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs.map +0 -1
- package/dist/chunks/accordion-CdshDFZC.mjs +0 -2
- package/dist/chunks/badge-BYqshEmA.mjs +0 -2
- package/dist/chunks/bundle-mjs-9BXytT_r.mjs +0 -2
- package/dist/chunks/button-DrFZXJ7z.mjs +0 -2
- package/dist/chunks/calendar-BY6t8wdJ.mjs +0 -2
- package/dist/chunks/calendar-BY6t8wdJ.mjs.map +0 -1
- package/dist/chunks/check-CimnOyD7.mjs +0 -2
- package/dist/chunks/chevron-down-D3fvbjxE.mjs +0 -2
- package/dist/chunks/chevron-left-CrN7DlXg.mjs +0 -2
- package/dist/chunks/chevron-right-BMSCuDGK.mjs +0 -2
- package/dist/chunks/chevrons-up-down-DBgvRkZm.mjs +0 -2
- package/dist/chunks/circle-CGqt18Bd.mjs +0 -2
- package/dist/chunks/command-C6ON-ciq.mjs +0 -2
- package/dist/chunks/command-C6ON-ciq.mjs.map +0 -1
- package/dist/chunks/createLucideIcon-L-tld2uc.mjs +0 -2
- package/dist/chunks/dialog-36eqHzT3.mjs +0 -2
- package/dist/chunks/hover-card-Cnd58du6.mjs +0 -2
- package/dist/chunks/index-B4QsDzeM.mjs +0 -2
- package/dist/chunks/index-B4QsDzeM.mjs.map +0 -1
- package/dist/chunks/index-BdpYc58_.mjs +0 -2
- package/dist/chunks/index-BdpYc58_.mjs.map +0 -1
- package/dist/chunks/index-CCcl327A.mjs +0 -2
- package/dist/chunks/index-CLtWFQL5.mjs +0 -2
- package/dist/chunks/index-COvW87ew.mjs +0 -2
- package/dist/chunks/index-COvW87ew.mjs.map +0 -1
- package/dist/chunks/index-CRxQlsb9.mjs +0 -2
- package/dist/chunks/index-CU_y1XAz.mjs +0 -2
- package/dist/chunks/index-CXszXOf_.mjs +0 -2
- package/dist/chunks/index-CdJCOoFA.mjs +0 -2
- package/dist/chunks/index-CdJCOoFA.mjs.map +0 -1
- package/dist/chunks/index-Cpq7N5Ej.mjs +0 -2
- package/dist/chunks/index-Cpq7N5Ej.mjs.map +0 -1
- package/dist/chunks/index-CybgQKpz.mjs +0 -2
- package/dist/chunks/index-D2sZp5OP.mjs +0 -2
- package/dist/chunks/index-DOyt-JEx.mjs +0 -2
- package/dist/chunks/index-DOyt-JEx.mjs.map +0 -1
- package/dist/chunks/index-DUNcuWJE.mjs +0 -2
- package/dist/chunks/index-DZHMFdr0.mjs +0 -2
- package/dist/chunks/index-LvOFIVGz.mjs +0 -2
- package/dist/chunks/index-lvPXnk5F.mjs +0 -2
- package/dist/chunks/index-lvPXnk5F.mjs.map +0 -1
- package/dist/chunks/index-vmPXTidH.mjs +0 -2
- package/dist/chunks/index-w9bxia3O.mjs +0 -2
- package/dist/chunks/index-xew3kygQ.mjs +0 -2
- package/dist/chunks/index-xew3kygQ.mjs.map +0 -1
- package/dist/chunks/input-85UFztMJ.mjs +0 -2
- package/dist/chunks/label-CICFzZIt.mjs +0 -2
- package/dist/chunks/pagination-CReDQes6.mjs +0 -2
- package/dist/chunks/popover-Cn2ZTvKd.mjs +0 -2
- package/dist/chunks/progress-CSxQH6-f.mjs +0 -2
- package/dist/chunks/scroll-area-CvCz7cL_.mjs +0 -2
- package/dist/chunks/scroll-area-CvCz7cL_.mjs.map +0 -1
- package/dist/chunks/select-BR6_N_Yo.mjs +0 -2
- package/dist/chunks/separator-BB6-E9Z1.mjs +0 -2
- package/dist/chunks/skeleton-XPWWiaac.mjs +0 -2
- package/dist/chunks/sortable-CqPFGn8Q.mjs +0 -2
- package/dist/chunks/sortable-CqPFGn8Q.mjs.map +0 -1
- package/dist/chunks/table-LQIHzPHi.mjs +0 -2
- package/dist/chunks/toggle-Co72WXGd.mjs +0 -2
- package/dist/chunks/tooltip-qX2HjdJP.mjs +0 -2
- package/dist/chunks/tslib.es6-cMGqxriw.mjs +0 -2
- package/dist/chunks/utils-BctauAA9.mjs +0 -2
- package/dist/chunks/utils-BctauAA9.mjs.map +0 -1
- package/dist/chunks/x-BNLl0E-E.mjs +0 -2
package/dist/toast/index.mjs
CHANGED
@@ -1,2 +1,706 @@
|
|
1
|
-
import{c as e}from"../chunks/utils-BctauAA9.mjs";import*as t from"react";import r from"react";import*as o from"react-dom";import{c as n}from"../chunks/index-CdJCOoFA.mjs";import{u as s}from"../chunks/index-COvW87ew.mjs";import{createCollection as a}from"@radix-ui/react-collection";import{c as i}from"../chunks/index-CCcl327A.mjs";import{B as c,R as d,P as u}from"../chunks/index-xew3kygQ.mjs";import{P as l}from"../chunks/index-BdpYc58_.mjs";import{P as p,d as m}from"../chunks/index-w9bxia3O.mjs";import{u as f}from"../chunks/index-CXszXOf_.mjs";import{u as v}from"../chunks/index-CybgQKpz.mjs";import{u as w}from"../chunks/index-CLtWFQL5.mjs";import{V as h}from"../chunks/index-D2sZp5OP.mjs";import{jsx as x,jsxs as y,Fragment as g}from"react/jsx-runtime";import{cva as E}from"class-variance-authority";import{X as T}from"../chunks/x-BNLl0E-E.mjs";import"../chunks/bundle-mjs-9BXytT_r.mjs";import"@radix-ui/react-slot";import"../chunks/createLucideIcon-L-tld2uc.mjs";var b="ToastProvider",[C,P,R]=a("Toast"),[N,k]=i("Toast",[R]),[D,L]=N(b),S=e=>{const{__scopeToast:r,label:o="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:a=50,children:i}=e,[c,d]=t.useState(null),[u,l]=t.useState(0),p=t.useRef(!1),m=t.useRef(!1);return o.trim(),x(C.Provider,{scope:r,children:x(D,{scope:r,label:o,duration:n,swipeDirection:s,swipeThreshold:a,toastCount:u,viewport:c,onViewportChange:d,onToastAdd:t.useCallback(()=>l(e=>e+1),[]),onToastRemove:t.useCallback(()=>l(e=>e-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};S.displayName=b;var _="ToastViewport",F=["F8"],j="toast.viewportPause",A="toast.viewportResume",I=t.forwardRef((e,r)=>{const{__scopeToast:o,hotkey:n=F,label:a="Notifications ({hotkey})",...i}=e,d=L(_,o),u=P(o),l=t.useRef(null),m=t.useRef(null),f=t.useRef(null),v=t.useRef(null),w=s(r,v,d.onViewportChange),h=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=d.toastCount>0;t.useEffect(()=>{const e=e=>{0!==n.length&&n.every(t=>e[t]||e.code===t)&&v.current?.focus()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n]),t.useEffect(()=>{const e=l.current,t=v.current;if(g&&e&&t){const r=()=>{if(!d.isClosePausedRef.current){const e=new CustomEvent(j);t.dispatchEvent(e),d.isClosePausedRef.current=!0}},o=()=>{if(d.isClosePausedRef.current){const e=new CustomEvent(A);t.dispatchEvent(e),d.isClosePausedRef.current=!1}},n=t=>{!e.contains(t.relatedTarget)&&o()},s=()=>{e.contains(document.activeElement)||o()};return e.addEventListener("focusin",r),e.addEventListener("focusout",n),e.addEventListener("pointermove",r),e.addEventListener("pointerleave",s),window.addEventListener("blur",r),window.addEventListener("focus",o),()=>{e.removeEventListener("focusin",r),e.removeEventListener("focusout",n),e.removeEventListener("pointermove",r),e.removeEventListener("pointerleave",s),window.removeEventListener("blur",r),window.removeEventListener("focus",o)}}},[g,d.isClosePausedRef]);const E=t.useCallback(({tabbingDirection:e})=>{const t=u().map(t=>{const r=t.ref.current,o=[r,...ee(r)];return"forwards"===e?o:o.reverse()});return("forwards"===e?t.reverse():t).flat()},[u]);return t.useEffect(()=>{const e=v.current;if(e){const t=t=>{const r=t.altKey||t.ctrlKey||t.metaKey;if("Tab"===t.key&&!r){const r=document.activeElement,o=t.shiftKey;if(t.target===e&&o)return void m.current?.focus();const n=E({tabbingDirection:o?"backwards":"forwards"}),s=n.findIndex(e=>e===r);te(n.slice(s+1))?t.preventDefault():o?m.current?.focus():f.current?.focus()}};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}},[u,E]),y(c,{ref:l,role:"region","aria-label":a.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:g?void 0:"none"},children:[g&&x(K,{ref:m,onFocusFromOutsideViewport:()=>{te(E({tabbingDirection:"forwards"}))}}),x(C.Slot,{scope:o,children:x(p.ol,{tabIndex:-1,...i,ref:w})}),g&&x(K,{ref:f,onFocusFromOutsideViewport:()=>{te(E({tabbingDirection:"backwards"}))}})]})});I.displayName=_;var M="ToastFocusProxy",K=t.forwardRef((e,t)=>{const{__scopeToast:r,onFocusFromOutsideViewport:o,...n}=e,s=L(M,r);return x(h,{"aria-hidden":!0,tabIndex:0,...n,ref:t,style:{position:"fixed"},onFocus:e=>{const t=e.relatedTarget;!s.viewport?.contains(t)&&o()}})});K.displayName=M;var O="Toast",V=t.forwardRef((e,t)=>{const{forceMount:r,open:o,defaultOpen:s,onOpenChange:a,...i}=e,[c,d]=v({prop:o,defaultProp:s??!0,onChange:a,caller:O});return x(l,{present:r||c,children:x(U,{open:c,...i,ref:t,onClose:()=>d(!1),onPause:f(e.onPause),onResume:f(e.onResume),onSwipeStart:n(e.onSwipeStart,e=>{e.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:n(e.onSwipeMove,e=>{const{x:t,y:r}=e.detail.delta;e.currentTarget.setAttribute("data-swipe","move"),e.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${t}px`),e.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${r}px`)}),onSwipeCancel:n(e.onSwipeCancel,e=>{e.currentTarget.setAttribute("data-swipe","cancel"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),e.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),e.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:n(e.onSwipeEnd,e=>{const{x:t,y:r}=e.detail.delta;e.currentTarget.setAttribute("data-swipe","end"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),e.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${t}px`),e.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${r}px`),d(!1)})})})});V.displayName=O;var[$,H]=N(O,{onClose(){}}),U=t.forwardRef((e,r)=>{const{__scopeToast:a,type:i="foreground",duration:c,open:u,onClose:l,onEscapeKeyDown:m,onPause:v,onResume:w,onSwipeStart:h,onSwipeMove:E,onSwipeCancel:T,onSwipeEnd:b,...P}=e,R=L(O,a),[N,k]=t.useState(null),D=s(r,e=>k(e)),S=t.useRef(null),_=t.useRef(null),F=c||R.duration,I=t.useRef(0),M=t.useRef(F),K=t.useRef(0),{onToastAdd:V,onToastRemove:H}=R,U=f(()=>{const e=N?.contains(document.activeElement);e&&R.viewport?.focus(),l()}),q=t.useCallback(e=>{e&&e!==1/0&&(window.clearTimeout(K.current),I.current=(new Date).getTime(),K.current=window.setTimeout(U,e))},[U]);t.useEffect(()=>{const e=R.viewport;if(e){const t=()=>{q(M.current),w?.()},r=()=>{const e=(new Date).getTime()-I.current;M.current=M.current-e,window.clearTimeout(K.current),v?.()};return e.addEventListener(j,r),e.addEventListener(A,t),()=>{e.removeEventListener(j,r),e.removeEventListener(A,t)}}},[R.viewport,F,v,w,q]),t.useEffect(()=>{u&&!R.isClosePausedRef.current&&q(F)},[u,F,R.isClosePausedRef,q]),t.useEffect(()=>(V(),()=>H()),[V,H]);const B=t.useMemo(()=>N?J(N):null,[N]);return R.viewport?y(g,{children:[B&&x(X,{__scopeToast:a,role:"status","aria-live":"foreground"===i?"assertive":"polite","aria-atomic":!0,children:B}),x($,{scope:a,onClose:U,children:o.createPortal(x(C.ItemSlot,{scope:a,children:x(d,{asChild:!0,onEscapeKeyDown:n(m,()=>{R.isFocusedToastEscapeKeyDownRef.current||U(),R.isFocusedToastEscapeKeyDownRef.current=!1}),children:x(p.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":u?"open":"closed","data-swipe-direction":R.swipeDirection,...P,ref:D,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:n(e.onKeyDown,e=>{"Escape"===e.key&&(m?.(e.nativeEvent),e.nativeEvent.defaultPrevented||(R.isFocusedToastEscapeKeyDownRef.current=!0,U()))}),onPointerDown:n(e.onPointerDown,e=>{0===e.button&&(S.current={x:e.clientX,y:e.clientY})}),onPointerMove:n(e.onPointerMove,e=>{if(!S.current)return;const t=e.clientX-S.current.x,r=e.clientY-S.current.y,o=Boolean(_.current),n=["left","right"].includes(R.swipeDirection),s=["left","up"].includes(R.swipeDirection)?Math.min:Math.max,a=n?s(0,t):0,i=n?0:s(0,r),c="touch"===e.pointerType?10:2,d={x:a,y:i},u={originalEvent:e,delta:d};o?(_.current=d,Q("toast.swipeMove",E,u,{discrete:!1})):Z(d,R.swipeDirection,c)?(_.current=d,Q("toast.swipeStart",h,u,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(r)>c)&&(S.current=null)}),onPointerUp:n(e.onPointerUp,e=>{const t=_.current,r=e.target;if(r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),_.current=null,S.current=null,t){const r=e.currentTarget,o={originalEvent:e,delta:t};Z(t,R.swipeDirection,R.swipeThreshold)?Q("toast.swipeEnd",b,o,{discrete:!0}):Q("toast.swipeCancel",T,o,{discrete:!0}),r.addEventListener("click",e=>e.preventDefault(),{once:!0})}})})})}),R.viewport)})]}):null}),X=e=>{const{__scopeToast:r,children:o,...n}=e,s=L(O,r),[a,i]=t.useState(!1),[c,d]=t.useState(!1);return function(e=()=>{}){const t=f(e);w(()=>{let e=0,r=0;return e=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(r)}},[t])}(()=>i(!0)),t.useEffect(()=>{const e=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(e)},[]),c?null:x(u,{asChild:!0,children:x(h,{...n,children:a&&y(g,{children:[s.label," ",o]})})})},q=t.forwardRef((e,t)=>{const{__scopeToast:r,...o}=e;return x(p.div,{...o,ref:t})});q.displayName="ToastTitle";var B=t.forwardRef((e,t)=>{const{__scopeToast:r,...o}=e;return x(p.div,{...o,ref:t})});B.displayName="ToastDescription";var W=t.forwardRef((e,t)=>{const{altText:r,...o}=e;return r.trim()?x(G,{altText:r,asChild:!0,children:x(z,{...o,ref:t})}):null});W.displayName="ToastAction";var Y="ToastClose",z=t.forwardRef((e,t)=>{const{__scopeToast:r,...o}=e,s=H(Y,r);return x(G,{asChild:!0,children:x(p.button,{type:"button",...o,ref:t,onClick:n(e.onClick,s.onClose)})})});z.displayName=Y;var G=t.forwardRef((e,t)=>{const{__scopeToast:r,altText:o,...n}=e;return x(p.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":o||void 0,...n,ref:t})});function J(e){const t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),function(e){return e.nodeType===e.ELEMENT_NODE}(e)){const r=e.ariaHidden||e.hidden||"none"===e.style.display,o=""===e.dataset.radixToastAnnounceExclude;if(!r)if(o){const r=e.dataset.radixToastAnnounceAlt;r&&t.push(r)}else t.push(...J(e))}}),t}function Q(e,t,r,{discrete:o}){const n=r.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?m(n,s):n.dispatchEvent(s)}var Z=(e,t,r=0)=>{const o=Math.abs(e.x),n=Math.abs(e.y),s=o>n;return"left"===t||"right"===t?s&&o>r:!s&&n>r};function ee(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function te(e){const t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}var re=I,oe=V,ne=q,se=B,ae=W,ie=z;const ce=S,de=({className:t,...o})=>r.createElement(re,{"data-slot":"toast-viewport",className:e("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]",t),...o}),ue=E("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 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-foreground bg-destructive-foreground text-destructive border-destructive"}},defaultVariants:{variant:"default"}}),le=({className:t,variant:o,...n})=>r.createElement(oe,{"data-slot":"toast-root",className:e(ue({variant:o}),t),...n}),pe=({className:t,...o})=>r.createElement(ae,{"data-slot":"toast-action",className:e("ring-offset-background 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-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none disabled:opacity-50",t),...o}),me=({className:t,...o})=>r.createElement(ie,{"data-slot":"toast-close",className:e("text-foreground/50 hover:text-foreground absolute top-2 right-2 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-2 focus:outline-none group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...o},r.createElement(T,{className:"h-4 w-4"})),fe=({className:t,...o})=>r.createElement(ne,{"data-slot":"toast-title",className:e("text-sm font-semibold",t),...o}),ve=({className:t,...o})=>r.createElement(se,{"data-slot":"toast-description",className:e("text-sm opacity-90",t),...o});export{le as Toast,pe as ToastAction,me as ToastClose,ve as ToastDescription,ce as ToastProvider,fe as ToastTitle,de as ToastViewport};
|
1
|
+
import { c as cn } from '../chunks/utils-BUelq9Ro.mjs';
|
2
|
+
import * as React from 'react';
|
3
|
+
import React__default from 'react';
|
4
|
+
import * as ReactDOM from 'react-dom';
|
5
|
+
import { c as composeEventHandlers } from '../chunks/index-Dm4_czlz.mjs';
|
6
|
+
import { u as useComposedRefs } from '../chunks/index-B4VRyyD1.mjs';
|
7
|
+
import { createCollection } from '@radix-ui/react-collection';
|
8
|
+
import { c as createContextScope } from '../chunks/index-B_FsTtnF.mjs';
|
9
|
+
import { B as Branch, R as Root, P as Portal } from '../chunks/index-BE-_q4IW.mjs';
|
10
|
+
import { P as Presence } from '../chunks/index-D2wfJaZh.mjs';
|
11
|
+
import { P as Primitive, d as dispatchDiscreteCustomEvent } from '../chunks/index-D0S6rRRE.mjs';
|
12
|
+
import { u as useCallbackRef } from '../chunks/index-CAg47KJ6.mjs';
|
13
|
+
import { u as useControllableState } from '../chunks/index-C_jFwfR_.mjs';
|
14
|
+
import { u as useLayoutEffect2 } from '../chunks/index-BZUrHhU8.mjs';
|
15
|
+
import { V as VisuallyHidden } from '../chunks/index-DNvm9MP3.mjs';
|
16
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
17
|
+
import { cva } from 'class-variance-authority';
|
18
|
+
import { X } from '../chunks/x-Bjz0Vo6R.mjs';
|
19
|
+
import '../chunks/bundle-mjs-tFg__FnT.mjs';
|
20
|
+
import '@radix-ui/react-slot';
|
21
|
+
import '../chunks/createLucideIcon-Ba0IWqsz.mjs';
|
22
|
+
|
23
|
+
var PROVIDER_NAME = "ToastProvider";
|
24
|
+
var [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
25
|
+
var [createToastContext, createToastScope] = createContextScope("Toast", [
|
26
|
+
createCollectionScope
|
27
|
+
]);
|
28
|
+
var [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME);
|
29
|
+
var ToastProvider$1 = (props)=>{
|
30
|
+
const { __scopeToast, label = "Notification", duration = 5e3, swipeDirection = "right", swipeThreshold = 50, children } = props;
|
31
|
+
const [viewport, setViewport] = React.useState(null);
|
32
|
+
const [toastCount, setToastCount] = React.useState(0);
|
33
|
+
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
34
|
+
const isClosePausedRef = React.useRef(false);
|
35
|
+
if (!label.trim()) {
|
36
|
+
console.error(`Invalid prop \`label\` supplied to \`${PROVIDER_NAME}\`. Expected non-empty \`string\`.`);
|
37
|
+
}
|
38
|
+
return /* @__PURE__ */ jsx(Collection.Provider, {
|
39
|
+
scope: __scopeToast,
|
40
|
+
children: /* @__PURE__ */ jsx(ToastProviderProvider, {
|
41
|
+
scope: __scopeToast,
|
42
|
+
label,
|
43
|
+
duration,
|
44
|
+
swipeDirection,
|
45
|
+
swipeThreshold,
|
46
|
+
toastCount,
|
47
|
+
viewport,
|
48
|
+
onViewportChange: setViewport,
|
49
|
+
onToastAdd: React.useCallback(()=>setToastCount((prevCount)=>prevCount + 1), []),
|
50
|
+
onToastRemove: React.useCallback(()=>setToastCount((prevCount)=>prevCount - 1), []),
|
51
|
+
isFocusedToastEscapeKeyDownRef,
|
52
|
+
isClosePausedRef,
|
53
|
+
children
|
54
|
+
})
|
55
|
+
});
|
56
|
+
};
|
57
|
+
ToastProvider$1.displayName = PROVIDER_NAME;
|
58
|
+
var VIEWPORT_NAME = "ToastViewport";
|
59
|
+
var VIEWPORT_DEFAULT_HOTKEY = [
|
60
|
+
"F8"
|
61
|
+
];
|
62
|
+
var VIEWPORT_PAUSE = "toast.viewportPause";
|
63
|
+
var VIEWPORT_RESUME = "toast.viewportResume";
|
64
|
+
var ToastViewport$1 = React.forwardRef((props, forwardedRef)=>{
|
65
|
+
const { __scopeToast, hotkey = VIEWPORT_DEFAULT_HOTKEY, label = "Notifications ({hotkey})", ...viewportProps } = props;
|
66
|
+
const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);
|
67
|
+
const getItems = useCollection(__scopeToast);
|
68
|
+
const wrapperRef = React.useRef(null);
|
69
|
+
const headFocusProxyRef = React.useRef(null);
|
70
|
+
const tailFocusProxyRef = React.useRef(null);
|
71
|
+
const ref = React.useRef(null);
|
72
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
|
73
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
74
|
+
const hasToasts = context.toastCount > 0;
|
75
|
+
React.useEffect(()=>{
|
76
|
+
const handleKeyDown = (event)=>{
|
77
|
+
const isHotkeyPressed = hotkey.length !== 0 && hotkey.every((key)=>event[key] || event.code === key);
|
78
|
+
if (isHotkeyPressed) ref.current?.focus();
|
79
|
+
};
|
80
|
+
document.addEventListener("keydown", handleKeyDown);
|
81
|
+
return ()=>document.removeEventListener("keydown", handleKeyDown);
|
82
|
+
}, [
|
83
|
+
hotkey
|
84
|
+
]);
|
85
|
+
React.useEffect(()=>{
|
86
|
+
const wrapper = wrapperRef.current;
|
87
|
+
const viewport = ref.current;
|
88
|
+
if (hasToasts && wrapper && viewport) {
|
89
|
+
const handlePause = ()=>{
|
90
|
+
if (!context.isClosePausedRef.current) {
|
91
|
+
const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
92
|
+
viewport.dispatchEvent(pauseEvent);
|
93
|
+
context.isClosePausedRef.current = true;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
const handleResume = ()=>{
|
97
|
+
if (context.isClosePausedRef.current) {
|
98
|
+
const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
99
|
+
viewport.dispatchEvent(resumeEvent);
|
100
|
+
context.isClosePausedRef.current = false;
|
101
|
+
}
|
102
|
+
};
|
103
|
+
const handleFocusOutResume = (event)=>{
|
104
|
+
const isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
|
105
|
+
if (isFocusMovingOutside) handleResume();
|
106
|
+
};
|
107
|
+
const handlePointerLeaveResume = ()=>{
|
108
|
+
const isFocusInside = wrapper.contains(document.activeElement);
|
109
|
+
if (!isFocusInside) handleResume();
|
110
|
+
};
|
111
|
+
wrapper.addEventListener("focusin", handlePause);
|
112
|
+
wrapper.addEventListener("focusout", handleFocusOutResume);
|
113
|
+
wrapper.addEventListener("pointermove", handlePause);
|
114
|
+
wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
|
115
|
+
window.addEventListener("blur", handlePause);
|
116
|
+
window.addEventListener("focus", handleResume);
|
117
|
+
return ()=>{
|
118
|
+
wrapper.removeEventListener("focusin", handlePause);
|
119
|
+
wrapper.removeEventListener("focusout", handleFocusOutResume);
|
120
|
+
wrapper.removeEventListener("pointermove", handlePause);
|
121
|
+
wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
|
122
|
+
window.removeEventListener("blur", handlePause);
|
123
|
+
window.removeEventListener("focus", handleResume);
|
124
|
+
};
|
125
|
+
}
|
126
|
+
}, [
|
127
|
+
hasToasts,
|
128
|
+
context.isClosePausedRef
|
129
|
+
]);
|
130
|
+
const getSortedTabbableCandidates = React.useCallback(({ tabbingDirection })=>{
|
131
|
+
const toastItems = getItems();
|
132
|
+
const tabbableCandidates = toastItems.map((toastItem)=>{
|
133
|
+
const toastNode = toastItem.ref.current;
|
134
|
+
const toastTabbableCandidates = [
|
135
|
+
toastNode,
|
136
|
+
...getTabbableCandidates(toastNode)
|
137
|
+
];
|
138
|
+
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
139
|
+
});
|
140
|
+
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
141
|
+
}, [
|
142
|
+
getItems
|
143
|
+
]);
|
144
|
+
React.useEffect(()=>{
|
145
|
+
const viewport = ref.current;
|
146
|
+
if (viewport) {
|
147
|
+
const handleKeyDown = (event)=>{
|
148
|
+
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
149
|
+
const isTabKey = event.key === "Tab" && !isMetaKey;
|
150
|
+
if (isTabKey) {
|
151
|
+
const focusedElement = document.activeElement;
|
152
|
+
const isTabbingBackwards = event.shiftKey;
|
153
|
+
const targetIsViewport = event.target === viewport;
|
154
|
+
if (targetIsViewport && isTabbingBackwards) {
|
155
|
+
headFocusProxyRef.current?.focus();
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
const tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
|
159
|
+
const sortedCandidates = getSortedTabbableCandidates({
|
160
|
+
tabbingDirection
|
161
|
+
});
|
162
|
+
const index = sortedCandidates.findIndex((candidate)=>candidate === focusedElement);
|
163
|
+
if (focusFirst(sortedCandidates.slice(index + 1))) {
|
164
|
+
event.preventDefault();
|
165
|
+
} else {
|
166
|
+
isTabbingBackwards ? headFocusProxyRef.current?.focus() : tailFocusProxyRef.current?.focus();
|
167
|
+
}
|
168
|
+
}
|
169
|
+
};
|
170
|
+
viewport.addEventListener("keydown", handleKeyDown);
|
171
|
+
return ()=>viewport.removeEventListener("keydown", handleKeyDown);
|
172
|
+
}
|
173
|
+
}, [
|
174
|
+
getItems,
|
175
|
+
getSortedTabbableCandidates
|
176
|
+
]);
|
177
|
+
return /* @__PURE__ */ jsxs(Branch, {
|
178
|
+
ref: wrapperRef,
|
179
|
+
role: "region",
|
180
|
+
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
181
|
+
tabIndex: -1,
|
182
|
+
style: {
|
183
|
+
pointerEvents: hasToasts ? void 0 : "none"
|
184
|
+
},
|
185
|
+
children: [
|
186
|
+
hasToasts && /* @__PURE__ */ jsx(FocusProxy, {
|
187
|
+
ref: headFocusProxyRef,
|
188
|
+
onFocusFromOutsideViewport: ()=>{
|
189
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
190
|
+
tabbingDirection: "forwards"
|
191
|
+
});
|
192
|
+
focusFirst(tabbableCandidates);
|
193
|
+
}
|
194
|
+
}),
|
195
|
+
/* @__PURE__ */ jsx(Collection.Slot, {
|
196
|
+
scope: __scopeToast,
|
197
|
+
children: /* @__PURE__ */ jsx(Primitive.ol, {
|
198
|
+
tabIndex: -1,
|
199
|
+
...viewportProps,
|
200
|
+
ref: composedRefs
|
201
|
+
})
|
202
|
+
}),
|
203
|
+
hasToasts && /* @__PURE__ */ jsx(FocusProxy, {
|
204
|
+
ref: tailFocusProxyRef,
|
205
|
+
onFocusFromOutsideViewport: ()=>{
|
206
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
207
|
+
tabbingDirection: "backwards"
|
208
|
+
});
|
209
|
+
focusFirst(tabbableCandidates);
|
210
|
+
}
|
211
|
+
})
|
212
|
+
]
|
213
|
+
});
|
214
|
+
});
|
215
|
+
ToastViewport$1.displayName = VIEWPORT_NAME;
|
216
|
+
var FOCUS_PROXY_NAME = "ToastFocusProxy";
|
217
|
+
var FocusProxy = React.forwardRef((props, forwardedRef)=>{
|
218
|
+
const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;
|
219
|
+
const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);
|
220
|
+
return /* @__PURE__ */ jsx(VisuallyHidden, {
|
221
|
+
tabIndex: 0,
|
222
|
+
...proxyProps,
|
223
|
+
ref: forwardedRef,
|
224
|
+
style: {
|
225
|
+
position: "fixed"
|
226
|
+
},
|
227
|
+
onFocus: (event)=>{
|
228
|
+
const prevFocusedElement = event.relatedTarget;
|
229
|
+
const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement);
|
230
|
+
if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();
|
231
|
+
}
|
232
|
+
});
|
233
|
+
});
|
234
|
+
FocusProxy.displayName = FOCUS_PROXY_NAME;
|
235
|
+
var TOAST_NAME = "Toast";
|
236
|
+
var TOAST_SWIPE_START = "toast.swipeStart";
|
237
|
+
var TOAST_SWIPE_MOVE = "toast.swipeMove";
|
238
|
+
var TOAST_SWIPE_CANCEL = "toast.swipeCancel";
|
239
|
+
var TOAST_SWIPE_END = "toast.swipeEnd";
|
240
|
+
var Toast$1 = React.forwardRef((props, forwardedRef)=>{
|
241
|
+
const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props;
|
242
|
+
const [open, setOpen] = useControllableState({
|
243
|
+
prop: openProp,
|
244
|
+
defaultProp: defaultOpen ?? true,
|
245
|
+
onChange: onOpenChange,
|
246
|
+
caller: TOAST_NAME
|
247
|
+
});
|
248
|
+
return /* @__PURE__ */ jsx(Presence, {
|
249
|
+
present: forceMount || open,
|
250
|
+
children: /* @__PURE__ */ jsx(ToastImpl, {
|
251
|
+
open,
|
252
|
+
...toastProps,
|
253
|
+
ref: forwardedRef,
|
254
|
+
onClose: ()=>setOpen(false),
|
255
|
+
onPause: useCallbackRef(props.onPause),
|
256
|
+
onResume: useCallbackRef(props.onResume),
|
257
|
+
onSwipeStart: composeEventHandlers(props.onSwipeStart, (event)=>{
|
258
|
+
event.currentTarget.setAttribute("data-swipe", "start");
|
259
|
+
}),
|
260
|
+
onSwipeMove: composeEventHandlers(props.onSwipeMove, (event)=>{
|
261
|
+
const { x, y } = event.detail.delta;
|
262
|
+
event.currentTarget.setAttribute("data-swipe", "move");
|
263
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${x}px`);
|
264
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${y}px`);
|
265
|
+
}),
|
266
|
+
onSwipeCancel: composeEventHandlers(props.onSwipeCancel, (event)=>{
|
267
|
+
event.currentTarget.setAttribute("data-swipe", "cancel");
|
268
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x");
|
269
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y");
|
270
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-end-x");
|
271
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
272
|
+
}),
|
273
|
+
onSwipeEnd: composeEventHandlers(props.onSwipeEnd, (event)=>{
|
274
|
+
const { x, y } = event.detail.delta;
|
275
|
+
event.currentTarget.setAttribute("data-swipe", "end");
|
276
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x");
|
277
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y");
|
278
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${x}px`);
|
279
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${y}px`);
|
280
|
+
setOpen(false);
|
281
|
+
})
|
282
|
+
})
|
283
|
+
});
|
284
|
+
});
|
285
|
+
Toast$1.displayName = TOAST_NAME;
|
286
|
+
var [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {
|
287
|
+
onClose () {}
|
288
|
+
});
|
289
|
+
var ToastImpl = React.forwardRef((props, forwardedRef)=>{
|
290
|
+
const { __scopeToast, type = "foreground", duration: durationProp, open, onClose, onEscapeKeyDown, onPause, onResume, onSwipeStart, onSwipeMove, onSwipeCancel, onSwipeEnd, ...toastProps } = props;
|
291
|
+
const context = useToastProviderContext(TOAST_NAME, __scopeToast);
|
292
|
+
const [node, setNode] = React.useState(null);
|
293
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2)=>setNode(node2));
|
294
|
+
const pointerStartRef = React.useRef(null);
|
295
|
+
const swipeDeltaRef = React.useRef(null);
|
296
|
+
const duration = durationProp || context.duration;
|
297
|
+
const closeTimerStartTimeRef = React.useRef(0);
|
298
|
+
const closeTimerRemainingTimeRef = React.useRef(duration);
|
299
|
+
const closeTimerRef = React.useRef(0);
|
300
|
+
const { onToastAdd, onToastRemove } = context;
|
301
|
+
const handleClose = useCallbackRef(()=>{
|
302
|
+
const isFocusInToast = node?.contains(document.activeElement);
|
303
|
+
if (isFocusInToast) context.viewport?.focus();
|
304
|
+
onClose();
|
305
|
+
});
|
306
|
+
const startTimer = React.useCallback((duration2)=>{
|
307
|
+
if (!duration2 || duration2 === Infinity) return;
|
308
|
+
window.clearTimeout(closeTimerRef.current);
|
309
|
+
closeTimerStartTimeRef.current = /* @__PURE__ */ new Date().getTime();
|
310
|
+
closeTimerRef.current = window.setTimeout(handleClose, duration2);
|
311
|
+
}, [
|
312
|
+
handleClose
|
313
|
+
]);
|
314
|
+
React.useEffect(()=>{
|
315
|
+
const viewport = context.viewport;
|
316
|
+
if (viewport) {
|
317
|
+
const handleResume = ()=>{
|
318
|
+
startTimer(closeTimerRemainingTimeRef.current);
|
319
|
+
onResume?.();
|
320
|
+
};
|
321
|
+
const handlePause = ()=>{
|
322
|
+
const elapsedTime = /* @__PURE__ */ new Date().getTime() - closeTimerStartTimeRef.current;
|
323
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;
|
324
|
+
window.clearTimeout(closeTimerRef.current);
|
325
|
+
onPause?.();
|
326
|
+
};
|
327
|
+
viewport.addEventListener(VIEWPORT_PAUSE, handlePause);
|
328
|
+
viewport.addEventListener(VIEWPORT_RESUME, handleResume);
|
329
|
+
return ()=>{
|
330
|
+
viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);
|
331
|
+
viewport.removeEventListener(VIEWPORT_RESUME, handleResume);
|
332
|
+
};
|
333
|
+
}
|
334
|
+
}, [
|
335
|
+
context.viewport,
|
336
|
+
duration,
|
337
|
+
onPause,
|
338
|
+
onResume,
|
339
|
+
startTimer
|
340
|
+
]);
|
341
|
+
React.useEffect(()=>{
|
342
|
+
if (open && !context.isClosePausedRef.current) startTimer(duration);
|
343
|
+
}, [
|
344
|
+
open,
|
345
|
+
duration,
|
346
|
+
context.isClosePausedRef,
|
347
|
+
startTimer
|
348
|
+
]);
|
349
|
+
React.useEffect(()=>{
|
350
|
+
onToastAdd();
|
351
|
+
return ()=>onToastRemove();
|
352
|
+
}, [
|
353
|
+
onToastAdd,
|
354
|
+
onToastRemove
|
355
|
+
]);
|
356
|
+
const announceTextContent = React.useMemo(()=>{
|
357
|
+
return node ? getAnnounceTextContent(node) : null;
|
358
|
+
}, [
|
359
|
+
node
|
360
|
+
]);
|
361
|
+
if (!context.viewport) return null;
|
362
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
363
|
+
children: [
|
364
|
+
announceTextContent && /* @__PURE__ */ jsx(ToastAnnounce, {
|
365
|
+
__scopeToast,
|
366
|
+
role: "status",
|
367
|
+
"aria-live": type === "foreground" ? "assertive" : "polite",
|
368
|
+
children: announceTextContent
|
369
|
+
}),
|
370
|
+
/* @__PURE__ */ jsx(ToastInteractiveProvider, {
|
371
|
+
scope: __scopeToast,
|
372
|
+
onClose: handleClose,
|
373
|
+
children: ReactDOM.createPortal(/* @__PURE__ */ jsx(Collection.ItemSlot, {
|
374
|
+
scope: __scopeToast,
|
375
|
+
children: /* @__PURE__ */ jsx(Root, {
|
376
|
+
asChild: true,
|
377
|
+
onEscapeKeyDown: composeEventHandlers(onEscapeKeyDown, ()=>{
|
378
|
+
if (!context.isFocusedToastEscapeKeyDownRef.current) handleClose();
|
379
|
+
context.isFocusedToastEscapeKeyDownRef.current = false;
|
380
|
+
}),
|
381
|
+
children: /* @__PURE__ */ jsx(Primitive.li, {
|
382
|
+
tabIndex: 0,
|
383
|
+
"data-state": open ? "open" : "closed",
|
384
|
+
"data-swipe-direction": context.swipeDirection,
|
385
|
+
...toastProps,
|
386
|
+
ref: composedRefs,
|
387
|
+
style: {
|
388
|
+
userSelect: "none",
|
389
|
+
touchAction: "none",
|
390
|
+
...props.style
|
391
|
+
},
|
392
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event)=>{
|
393
|
+
if (event.key !== "Escape") return;
|
394
|
+
onEscapeKeyDown?.(event.nativeEvent);
|
395
|
+
if (!event.nativeEvent.defaultPrevented) {
|
396
|
+
context.isFocusedToastEscapeKeyDownRef.current = true;
|
397
|
+
handleClose();
|
398
|
+
}
|
399
|
+
}),
|
400
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event)=>{
|
401
|
+
if (event.button !== 0) return;
|
402
|
+
pointerStartRef.current = {
|
403
|
+
x: event.clientX,
|
404
|
+
y: event.clientY
|
405
|
+
};
|
406
|
+
}),
|
407
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event)=>{
|
408
|
+
if (!pointerStartRef.current) return;
|
409
|
+
const x = event.clientX - pointerStartRef.current.x;
|
410
|
+
const y = event.clientY - pointerStartRef.current.y;
|
411
|
+
const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);
|
412
|
+
const isHorizontalSwipe = [
|
413
|
+
"left",
|
414
|
+
"right"
|
415
|
+
].includes(context.swipeDirection);
|
416
|
+
const clamp = [
|
417
|
+
"left",
|
418
|
+
"up"
|
419
|
+
].includes(context.swipeDirection) ? Math.min : Math.max;
|
420
|
+
const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;
|
421
|
+
const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;
|
422
|
+
const moveStartBuffer = event.pointerType === "touch" ? 10 : 2;
|
423
|
+
const delta = {
|
424
|
+
x: clampedX,
|
425
|
+
y: clampedY
|
426
|
+
};
|
427
|
+
const eventDetail = {
|
428
|
+
originalEvent: event,
|
429
|
+
delta
|
430
|
+
};
|
431
|
+
if (hasSwipeMoveStarted) {
|
432
|
+
swipeDeltaRef.current = delta;
|
433
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {
|
434
|
+
discrete: false
|
435
|
+
});
|
436
|
+
} else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {
|
437
|
+
swipeDeltaRef.current = delta;
|
438
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {
|
439
|
+
discrete: false
|
440
|
+
});
|
441
|
+
event.target.setPointerCapture(event.pointerId);
|
442
|
+
} else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {
|
443
|
+
pointerStartRef.current = null;
|
444
|
+
}
|
445
|
+
}),
|
446
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event)=>{
|
447
|
+
const delta = swipeDeltaRef.current;
|
448
|
+
const target = event.target;
|
449
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
450
|
+
target.releasePointerCapture(event.pointerId);
|
451
|
+
}
|
452
|
+
swipeDeltaRef.current = null;
|
453
|
+
pointerStartRef.current = null;
|
454
|
+
if (delta) {
|
455
|
+
const toast = event.currentTarget;
|
456
|
+
const eventDetail = {
|
457
|
+
originalEvent: event,
|
458
|
+
delta
|
459
|
+
};
|
460
|
+
if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {
|
461
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {
|
462
|
+
discrete: true
|
463
|
+
});
|
464
|
+
} else {
|
465
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_CANCEL, onSwipeCancel, eventDetail, {
|
466
|
+
discrete: true
|
467
|
+
});
|
468
|
+
}
|
469
|
+
toast.addEventListener("click", (event2)=>event2.preventDefault(), {
|
470
|
+
once: true
|
471
|
+
});
|
472
|
+
}
|
473
|
+
})
|
474
|
+
})
|
475
|
+
})
|
476
|
+
}), context.viewport)
|
477
|
+
})
|
478
|
+
]
|
479
|
+
});
|
480
|
+
});
|
481
|
+
var ToastAnnounce = (props)=>{
|
482
|
+
const { __scopeToast, children, ...announceProps } = props;
|
483
|
+
const context = useToastProviderContext(TOAST_NAME, __scopeToast);
|
484
|
+
const [renderAnnounceText, setRenderAnnounceText] = React.useState(false);
|
485
|
+
const [isAnnounced, setIsAnnounced] = React.useState(false);
|
486
|
+
useNextFrame(()=>setRenderAnnounceText(true));
|
487
|
+
React.useEffect(()=>{
|
488
|
+
const timer = window.setTimeout(()=>setIsAnnounced(true), 1e3);
|
489
|
+
return ()=>window.clearTimeout(timer);
|
490
|
+
}, []);
|
491
|
+
return isAnnounced ? null : /* @__PURE__ */ jsx(Portal, {
|
492
|
+
asChild: true,
|
493
|
+
children: /* @__PURE__ */ jsx(VisuallyHidden, {
|
494
|
+
...announceProps,
|
495
|
+
children: renderAnnounceText && /* @__PURE__ */ jsxs(Fragment, {
|
496
|
+
children: [
|
497
|
+
context.label,
|
498
|
+
" ",
|
499
|
+
children
|
500
|
+
]
|
501
|
+
})
|
502
|
+
})
|
503
|
+
});
|
504
|
+
};
|
505
|
+
var TITLE_NAME = "ToastTitle";
|
506
|
+
var ToastTitle$1 = React.forwardRef((props, forwardedRef)=>{
|
507
|
+
const { __scopeToast, ...titleProps } = props;
|
508
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
509
|
+
...titleProps,
|
510
|
+
ref: forwardedRef
|
511
|
+
});
|
512
|
+
});
|
513
|
+
ToastTitle$1.displayName = TITLE_NAME;
|
514
|
+
var DESCRIPTION_NAME = "ToastDescription";
|
515
|
+
var ToastDescription$1 = React.forwardRef((props, forwardedRef)=>{
|
516
|
+
const { __scopeToast, ...descriptionProps } = props;
|
517
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
518
|
+
...descriptionProps,
|
519
|
+
ref: forwardedRef
|
520
|
+
});
|
521
|
+
});
|
522
|
+
ToastDescription$1.displayName = DESCRIPTION_NAME;
|
523
|
+
var ACTION_NAME = "ToastAction";
|
524
|
+
var ToastAction$1 = React.forwardRef((props, forwardedRef)=>{
|
525
|
+
const { altText, ...actionProps } = props;
|
526
|
+
if (!altText.trim()) {
|
527
|
+
console.error(`Invalid prop \`altText\` supplied to \`${ACTION_NAME}\`. Expected non-empty \`string\`.`);
|
528
|
+
return null;
|
529
|
+
}
|
530
|
+
return /* @__PURE__ */ jsx(ToastAnnounceExclude, {
|
531
|
+
altText,
|
532
|
+
asChild: true,
|
533
|
+
children: /* @__PURE__ */ jsx(ToastClose$1, {
|
534
|
+
...actionProps,
|
535
|
+
ref: forwardedRef
|
536
|
+
})
|
537
|
+
});
|
538
|
+
});
|
539
|
+
ToastAction$1.displayName = ACTION_NAME;
|
540
|
+
var CLOSE_NAME = "ToastClose";
|
541
|
+
var ToastClose$1 = React.forwardRef((props, forwardedRef)=>{
|
542
|
+
const { __scopeToast, ...closeProps } = props;
|
543
|
+
const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);
|
544
|
+
return /* @__PURE__ */ jsx(ToastAnnounceExclude, {
|
545
|
+
asChild: true,
|
546
|
+
children: /* @__PURE__ */ jsx(Primitive.button, {
|
547
|
+
type: "button",
|
548
|
+
...closeProps,
|
549
|
+
ref: forwardedRef,
|
550
|
+
onClick: composeEventHandlers(props.onClick, interactiveContext.onClose)
|
551
|
+
})
|
552
|
+
});
|
553
|
+
});
|
554
|
+
ToastClose$1.displayName = CLOSE_NAME;
|
555
|
+
var ToastAnnounceExclude = React.forwardRef((props, forwardedRef)=>{
|
556
|
+
const { __scopeToast, altText, ...announceExcludeProps } = props;
|
557
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
558
|
+
"data-radix-toast-announce-exclude": "",
|
559
|
+
"data-radix-toast-announce-alt": altText || void 0,
|
560
|
+
...announceExcludeProps,
|
561
|
+
ref: forwardedRef
|
562
|
+
});
|
563
|
+
});
|
564
|
+
function getAnnounceTextContent(container) {
|
565
|
+
const textContent = [];
|
566
|
+
const childNodes = Array.from(container.childNodes);
|
567
|
+
childNodes.forEach((node)=>{
|
568
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent) textContent.push(node.textContent);
|
569
|
+
if (isHTMLElement(node)) {
|
570
|
+
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none";
|
571
|
+
const isExcluded = node.dataset.radixToastAnnounceExclude === "";
|
572
|
+
if (!isHidden) {
|
573
|
+
if (isExcluded) {
|
574
|
+
const altText = node.dataset.radixToastAnnounceAlt;
|
575
|
+
if (altText) textContent.push(altText);
|
576
|
+
} else {
|
577
|
+
textContent.push(...getAnnounceTextContent(node));
|
578
|
+
}
|
579
|
+
}
|
580
|
+
}
|
581
|
+
});
|
582
|
+
return textContent;
|
583
|
+
}
|
584
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
585
|
+
const currentTarget = detail.originalEvent.currentTarget;
|
586
|
+
const event = new CustomEvent(name, {
|
587
|
+
bubbles: true,
|
588
|
+
cancelable: true,
|
589
|
+
detail
|
590
|
+
});
|
591
|
+
if (handler) currentTarget.addEventListener(name, handler, {
|
592
|
+
once: true
|
593
|
+
});
|
594
|
+
if (discrete) {
|
595
|
+
dispatchDiscreteCustomEvent(currentTarget, event);
|
596
|
+
} else {
|
597
|
+
currentTarget.dispatchEvent(event);
|
598
|
+
}
|
599
|
+
}
|
600
|
+
var isDeltaInDirection = (delta, direction, threshold = 0)=>{
|
601
|
+
const deltaX = Math.abs(delta.x);
|
602
|
+
const deltaY = Math.abs(delta.y);
|
603
|
+
const isDeltaX = deltaX > deltaY;
|
604
|
+
if (direction === "left" || direction === "right") {
|
605
|
+
return isDeltaX && deltaX > threshold;
|
606
|
+
} else {
|
607
|
+
return !isDeltaX && deltaY > threshold;
|
608
|
+
}
|
609
|
+
};
|
610
|
+
function useNextFrame(callback = ()=>{}) {
|
611
|
+
const fn = useCallbackRef(callback);
|
612
|
+
useLayoutEffect2(()=>{
|
613
|
+
let raf1 = 0;
|
614
|
+
let raf2 = 0;
|
615
|
+
raf1 = window.requestAnimationFrame(()=>raf2 = window.requestAnimationFrame(fn));
|
616
|
+
return ()=>{
|
617
|
+
window.cancelAnimationFrame(raf1);
|
618
|
+
window.cancelAnimationFrame(raf2);
|
619
|
+
};
|
620
|
+
}, [
|
621
|
+
fn
|
622
|
+
]);
|
623
|
+
}
|
624
|
+
function isHTMLElement(node) {
|
625
|
+
return node.nodeType === node.ELEMENT_NODE;
|
626
|
+
}
|
627
|
+
function getTabbableCandidates(container) {
|
628
|
+
const nodes = [];
|
629
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
630
|
+
acceptNode: (node)=>{
|
631
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
632
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
633
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
634
|
+
}
|
635
|
+
});
|
636
|
+
while(walker.nextNode())nodes.push(walker.currentNode);
|
637
|
+
return nodes;
|
638
|
+
}
|
639
|
+
function focusFirst(candidates) {
|
640
|
+
const previouslyFocusedElement = document.activeElement;
|
641
|
+
return candidates.some((candidate)=>{
|
642
|
+
if (candidate === previouslyFocusedElement) return true;
|
643
|
+
candidate.focus();
|
644
|
+
return document.activeElement !== previouslyFocusedElement;
|
645
|
+
});
|
646
|
+
}
|
647
|
+
var Provider = ToastProvider$1;
|
648
|
+
var Viewport = ToastViewport$1;
|
649
|
+
var Root2 = Toast$1;
|
650
|
+
var Title = ToastTitle$1;
|
651
|
+
var Description = ToastDescription$1;
|
652
|
+
var Action = ToastAction$1;
|
653
|
+
var Close = ToastClose$1;
|
654
|
+
|
655
|
+
const ToastProvider = Provider;
|
656
|
+
const ToastViewport = ({ className, ...props })=>/*#__PURE__*/ React__default.createElement(Viewport, {
|
657
|
+
"data-slot": "toast-viewport",
|
658
|
+
className: 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]", className),
|
659
|
+
...props
|
660
|
+
});
|
661
|
+
const toastVariants = cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 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", {
|
662
|
+
variants: {
|
663
|
+
variant: {
|
664
|
+
default: "border bg-background text-foreground",
|
665
|
+
destructive: "destructive group border-destructive-foreground bg-destructive-foreground text-destructive border-destructive"
|
666
|
+
}
|
667
|
+
},
|
668
|
+
defaultVariants: {
|
669
|
+
variant: "default"
|
670
|
+
}
|
671
|
+
});
|
672
|
+
const Toast = ({ className, variant, ...props })=>{
|
673
|
+
return /*#__PURE__*/ React__default.createElement(Root2, {
|
674
|
+
"data-slot": "toast-root",
|
675
|
+
className: cn(toastVariants({
|
676
|
+
variant
|
677
|
+
}), className),
|
678
|
+
...props
|
679
|
+
});
|
680
|
+
};
|
681
|
+
const ToastAction = ({ className, ...props })=>/*#__PURE__*/ React__default.createElement(Action, {
|
682
|
+
"data-slot": "toast-action",
|
683
|
+
className: cn("ring-offset-background 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-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none disabled:opacity-50", className),
|
684
|
+
...props
|
685
|
+
});
|
686
|
+
const ToastClose = ({ className, ...props })=>/*#__PURE__*/ React__default.createElement(Close, {
|
687
|
+
"data-slot": "toast-close",
|
688
|
+
className: cn("text-foreground/50 hover:text-foreground absolute top-2 right-2 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-2 focus:outline-none group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600", className),
|
689
|
+
"toast-close": "",
|
690
|
+
...props
|
691
|
+
}, /*#__PURE__*/ React__default.createElement(X, {
|
692
|
+
className: "h-4 w-4"
|
693
|
+
}));
|
694
|
+
const ToastTitle = ({ className, ...props })=>/*#__PURE__*/ React__default.createElement(Title, {
|
695
|
+
"data-slot": "toast-title",
|
696
|
+
className: cn("text-sm font-semibold", className),
|
697
|
+
...props
|
698
|
+
});
|
699
|
+
const ToastDescription = ({ className, ...props })=>/*#__PURE__*/ React__default.createElement(Description, {
|
700
|
+
"data-slot": "toast-description",
|
701
|
+
className: cn("text-sm opacity-90", className),
|
702
|
+
...props
|
703
|
+
});
|
704
|
+
|
705
|
+
export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport };
|
2
706
|
//# sourceMappingURL=index.mjs.map
|