ivt 0.1.8 → 0.1.9
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 +1 -1
- package/dist/alert/index.mjs +1 -1
- package/dist/alert-dialog/index.mjs +1 -1
- package/dist/avatar/index.mjs +1 -1
- package/dist/badge/index.mjs +1 -1
- package/dist/base/index.mjs +1 -1
- package/dist/button/index.mjs +1 -1
- package/dist/calendar/index.mjs +1 -1
- package/dist/card/index.mjs +1 -1
- package/dist/checkbox/index.mjs +1 -1
- package/dist/chunks/{accordion-LstSopx4.mjs → accordion-BZ27divW.mjs} +2 -2
- package/dist/chunks/{accordion-LstSopx4.mjs.map → accordion-BZ27divW.mjs.map} +1 -1
- package/dist/chunks/{badge-BpvI4lxd.mjs → badge-DReiecuz.mjs} +2 -2
- package/dist/chunks/{badge-BpvI4lxd.mjs.map → badge-DReiecuz.mjs.map} +1 -1
- package/dist/chunks/{bundle-mjs-BVqH9Xiz.mjs → bundle-mjs-DdsKEIOo.mjs} +1 -1
- package/dist/chunks/{bundle-mjs-BVqH9Xiz.mjs.map → bundle-mjs-DdsKEIOo.mjs.map} +1 -1
- package/dist/chunks/{button-bpYD_OCh.mjs → button-BiUJlCbP.mjs} +2 -2
- package/dist/chunks/{button-bpYD_OCh.mjs.map → button-BiUJlCbP.mjs.map} +1 -1
- package/dist/chunks/{calendar-B7NC5f3S.mjs → calendar-CGpAU3KL.mjs} +2 -2
- package/dist/chunks/{calendar-B7NC5f3S.mjs.map → calendar-CGpAU3KL.mjs.map} +1 -1
- package/dist/chunks/check-DcO6cfxw.mjs +2 -0
- package/dist/chunks/{check-C1S8oGnA.mjs.map → check-DcO6cfxw.mjs.map} +1 -1
- package/dist/chunks/chevron-down-DAXj2M4s.mjs +2 -0
- package/dist/chunks/{chevron-down-LNM8QSJt.mjs.map → chevron-down-DAXj2M4s.mjs.map} +1 -1
- package/dist/chunks/chevron-left-BlTUbzCL.mjs +2 -0
- package/dist/chunks/{chevron-left-DGTU0tN0.mjs.map → chevron-left-BlTUbzCL.mjs.map} +1 -1
- package/dist/chunks/chevron-right-IKI4gwaE.mjs +2 -0
- package/dist/chunks/{chevron-right-BZ-GCzPm.mjs.map → chevron-right-IKI4gwaE.mjs.map} +1 -1
- package/dist/chunks/{command-BrYRDhVo.mjs → command-U0Je4z4o.mjs} +2 -2
- package/dist/chunks/{command-BrYRDhVo.mjs.map → command-U0Je4z4o.mjs.map} +1 -1
- package/dist/chunks/{createLucideIcon-JNrPx34C.mjs → createLucideIcon-BSkMD9sy.mjs} +1 -1
- package/dist/chunks/{createLucideIcon-JNrPx34C.mjs.map → createLucideIcon-BSkMD9sy.mjs.map} +1 -1
- package/dist/chunks/{dialog-qeEDGLRF.mjs → dialog-dzuVKbgu.mjs} +2 -2
- package/dist/chunks/{dialog-qeEDGLRF.mjs.map → dialog-dzuVKbgu.mjs.map} +1 -1
- package/dist/chunks/{hover-card-Ch_WNrXf.mjs → hover-card-BkSVghU4.mjs} +2 -2
- package/dist/chunks/{hover-card-Ch_WNrXf.mjs.map → hover-card-BkSVghU4.mjs.map} +1 -1
- package/dist/chunks/{index-BSTiUDx6.mjs → index-BXKQJZ6z.mjs} +1 -1
- package/dist/chunks/{index-BSTiUDx6.mjs.map → index-BXKQJZ6z.mjs.map} +1 -1
- package/dist/chunks/{index-Jch-kFOs.mjs → index-BclYsZHn.mjs} +2 -2
- package/dist/chunks/{index-Jch-kFOs.mjs.map → index-BclYsZHn.mjs.map} +1 -1
- package/dist/chunks/{index-9Wr-AbGf.mjs → index-BgU_7G37.mjs} +2 -2
- package/dist/chunks/{index-9Wr-AbGf.mjs.map → index-BgU_7G37.mjs.map} +1 -1
- package/dist/chunks/{index-vjATIVlG.mjs → index-Bj6b6xW8.mjs} +1 -1
- package/dist/chunks/{index-vjATIVlG.mjs.map → index-Bj6b6xW8.mjs.map} +1 -1
- package/dist/chunks/{index-C_f5Fx2v.mjs → index-C99OdH8-.mjs} +1 -1
- package/dist/chunks/{index-C_f5Fx2v.mjs.map → index-C99OdH8-.mjs.map} +1 -1
- package/dist/chunks/{index-Dw-nLa3V.mjs → index-CD0qf5ak.mjs} +2 -2
- package/dist/chunks/{index-Dw-nLa3V.mjs.map → index-CD0qf5ak.mjs.map} +1 -1
- package/dist/chunks/{index-CJdBH2dA.mjs → index-CDzNhFWE.mjs} +2 -2
- package/dist/chunks/{index-CJdBH2dA.mjs.map → index-CDzNhFWE.mjs.map} +1 -1
- package/dist/chunks/{index-qIY9XpbL.mjs → index-CJw5YZXp.mjs} +2 -2
- package/dist/chunks/{index-qIY9XpbL.mjs.map → index-CJw5YZXp.mjs.map} +1 -1
- package/dist/chunks/{index-Ga0tRLIX.mjs → index-DHTHqgm4.mjs} +2 -2
- package/dist/chunks/{index-Ga0tRLIX.mjs.map → index-DHTHqgm4.mjs.map} +1 -1
- package/dist/chunks/{index-B7JXO_ZL.mjs → index-DKvOtb2R.mjs} +2 -2
- package/dist/chunks/{index-B7JXO_ZL.mjs.map → index-DKvOtb2R.mjs.map} +1 -1
- package/dist/chunks/{index-BWIrjh6G.mjs → index-DN2GfLYB.mjs} +2 -2
- package/dist/chunks/{index-BWIrjh6G.mjs.map → index-DN2GfLYB.mjs.map} +1 -1
- package/dist/chunks/{index-D1v3PdP0.mjs → index-DX37fts-.mjs} +2 -2
- package/dist/chunks/{index-D1v3PdP0.mjs.map → index-DX37fts-.mjs.map} +1 -1
- package/dist/chunks/{index-BF_rlJfV.mjs → index-DwSoQWco.mjs} +1 -1
- package/dist/chunks/{index-BF_rlJfV.mjs.map → index-DwSoQWco.mjs.map} +1 -1
- package/dist/chunks/{index-cC12OKKn.mjs → index-X2oEHtiP.mjs} +1 -1
- package/dist/chunks/{index-cC12OKKn.mjs.map → index-X2oEHtiP.mjs.map} +1 -1
- package/dist/chunks/{index-BVxX50NR.mjs → index-w5meZsTe.mjs} +2 -2
- package/dist/chunks/{index-BVxX50NR.mjs.map → index-w5meZsTe.mjs.map} +1 -1
- package/dist/chunks/{input-WGTUuQwx.mjs → input-BjHvd9_1.mjs} +2 -2
- package/dist/chunks/{input-WGTUuQwx.mjs.map → input-BjHvd9_1.mjs.map} +1 -1
- package/dist/chunks/{label-C9fmItRi.mjs → label-BwzNNKzX.mjs} +2 -2
- package/dist/chunks/{label-C9fmItRi.mjs.map → label-BwzNNKzX.mjs.map} +1 -1
- package/dist/chunks/{pagination-CwfzF6ZA.mjs → pagination-DRsm0449.mjs} +2 -2
- package/dist/chunks/{pagination-CwfzF6ZA.mjs.map → pagination-DRsm0449.mjs.map} +1 -1
- package/dist/chunks/{popover-DWUH3762.mjs → popover-C1cJBw3j.mjs} +2 -2
- package/dist/chunks/{popover-DWUH3762.mjs.map → popover-C1cJBw3j.mjs.map} +1 -1
- package/dist/chunks/{progress-4uCJqswH.mjs → progress-2xiymnoq.mjs} +2 -2
- package/dist/chunks/{progress-4uCJqswH.mjs.map → progress-2xiymnoq.mjs.map} +1 -1
- package/dist/chunks/{scroll-area-k2fAfAN1.mjs → scroll-area-v3WLDhPc.mjs} +2 -2
- package/dist/chunks/{scroll-area-k2fAfAN1.mjs.map → scroll-area-v3WLDhPc.mjs.map} +1 -1
- package/dist/chunks/{select-DScrQSU7.mjs → select-BZFFkHf0.mjs} +2 -2
- package/dist/chunks/{select-DScrQSU7.mjs.map → select-BZFFkHf0.mjs.map} +1 -1
- package/dist/chunks/{skeleton-BOGCHPea.mjs → skeleton-COXF8Nl_.mjs} +2 -2
- package/dist/chunks/{skeleton-BOGCHPea.mjs.map → skeleton-COXF8Nl_.mjs.map} +1 -1
- package/dist/chunks/{sortable-gbvqGC-N.mjs → sortable-CqFeH7tf.mjs} +2 -2
- package/dist/chunks/{sortable-gbvqGC-N.mjs.map → sortable-CqFeH7tf.mjs.map} +1 -1
- package/dist/chunks/{table-B3Ju2kvw.mjs → table-BkDUCjpn.mjs} +2 -2
- package/dist/chunks/{table-B3Ju2kvw.mjs.map → table-BkDUCjpn.mjs.map} +1 -1
- package/dist/chunks/{tslib.es6-DNj8ZlM2.mjs → tslib.es6-B8aZ0Vi5.mjs} +1 -1
- package/dist/chunks/{tslib.es6-DNj8ZlM2.mjs.map → tslib.es6-B8aZ0Vi5.mjs.map} +1 -1
- package/dist/chunks/{utils-Bv9f_FMv.mjs → utils-B4HRExF_.mjs} +2 -2
- package/dist/chunks/{utils-Bv9f_FMv.mjs.map → utils-B4HRExF_.mjs.map} +1 -1
- package/dist/chunks/x-rWMGj99P.mjs +2 -0
- package/dist/chunks/{x-CyVCd2U8.mjs.map → x-rWMGj99P.mjs.map} +1 -1
- package/dist/command/index.mjs +1 -1
- package/dist/data-table/index.mjs +1 -1
- package/dist/data-table/index.mjs.map +1 -1
- package/dist/dialog/index.mjs +1 -1
- package/dist/dropdown-menu/index.mjs +1 -1
- package/dist/dropzone/index.mjs +1 -1
- package/dist/form/index.mjs +1 -1
- package/dist/hover-card/index.mjs +1 -1
- package/dist/icon/index.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/input/index.mjs +1 -1
- package/dist/label/index.mjs +1 -1
- package/dist/pagination/index.mjs +1 -1
- package/dist/popover/index.mjs +1 -1
- package/dist/progress/index.mjs +1 -1
- package/dist/scroll-area/index.mjs +1 -1
- package/dist/select/index.mjs +1 -1
- package/dist/separator/index.mjs +1 -1
- package/dist/sheet/index.mjs +1 -1
- package/dist/skeleton/index.mjs +1 -1
- package/dist/sortable/index.mjs +1 -1
- package/dist/table/index.mjs +1 -1
- package/dist/tabs/index.mjs +1 -1
- package/dist/toast/index.mjs +1 -1
- package/dist/tooltip/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunks/check-C1S8oGnA.mjs +0 -2
- package/dist/chunks/chevron-down-LNM8QSJt.mjs +0 -2
- package/dist/chunks/chevron-left-DGTU0tN0.mjs +0 -2
- package/dist/chunks/chevron-right-BZ-GCzPm.mjs +0 -2
- package/dist/chunks/x-CyVCd2U8.mjs +0 -2
package/dist/toast/index.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{c as e}from"../chunks/utils-Bv9f_FMv.mjs";import*as t from"react";import r from"react";import*as o from"react-dom";import{u as n,P as s,c as a}from"../chunks/index-9Wr-AbGf.mjs";import{createCollection as i}from"@radix-ui/react-collection";import{c}from"../chunks/index-BSTiUDx6.mjs";import{B as d,R as u,P as l}from"../chunks/index-D1v3PdP0.mjs";import{P as p,d as m}from"../chunks/index-vjATIVlG.mjs";import{u as f}from"../chunks/index-BF_rlJfV.mjs";import{u as v}from"../chunks/index-qIY9XpbL.mjs";import{u as w}from"../chunks/index-C_f5Fx2v.mjs";import{V as h}from"../chunks/index-BVxX50NR.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-CyVCd2U8.mjs";import"../chunks/bundle-mjs-BVqH9Xiz.mjs";import"@radix-ui/react-slot";import"../chunks/createLucideIcon-JNrPx34C.mjs";var b="ToastProvider",[C,P,R]=i("Toast"),[N,k]=c("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:s=F,label:a="Notifications ({hotkey})",...i}=e,c=L(_,o),u=P(o),l=t.useRef(null),m=t.useRef(null),f=t.useRef(null),v=t.useRef(null),w=n(r,v,c.onViewportChange),h=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=c.toastCount>0;t.useEffect((()=>{const e=e=>{0!==s.length&&s.every((t=>e[t]||e.code===t))&&v.current?.focus()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[s]),t.useEffect((()=>{const e=l.current,t=v.current;if(g&&e&&t){const r=()=>{if(!c.isClosePausedRef.current){const e=new CustomEvent(j);t.dispatchEvent(e),c.isClosePausedRef.current=!0}},o=()=>{if(c.isClosePausedRef.current){const e=new CustomEvent(A);t.dispatchEvent(e),c.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,c.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(d,{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:n,onOpenChange:i,...c}=e,[d,u]=v({prop:o,defaultProp:n??!0,onChange:i,caller:O});return x(s,{present:r||d,children:x(X,{open:d,...c,ref:t,onClose:()=>u(!1),onPause:f(e.onPause),onResume:f(e.onResume),onSwipeStart:a(e.onSwipeStart,(e=>{e.currentTarget.setAttribute("data-swipe","start")})),onSwipeMove:a(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:a(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:a(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`),u(!1)}))})})}));V.displayName=O;var[$,U]=N(O,{onClose(){}}),X=t.forwardRef(((e,r)=>{const{__scopeToast:s,type:i="foreground",duration:c,open:d,onClose:l,onEscapeKeyDown:m,onPause:v,onResume:w,onSwipeStart:h,onSwipeMove:E,onSwipeCancel:T,onSwipeEnd:b,...P}=e,R=L(O,s),[N,k]=t.useState(null),D=n(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:U}=R,X=f((()=>{const e=N?.contains(document.activeElement);e&&R.viewport?.focus(),l()})),B=t.useCallback((e=>{e&&e!==1/0&&(window.clearTimeout(K.current),I.current=(new Date).getTime(),K.current=window.setTimeout(X,e))}),[X]);t.useEffect((()=>{const e=R.viewport;if(e){const t=()=>{B(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,B]),t.useEffect((()=>{d&&!R.isClosePausedRef.current&&B(F)}),[d,F,R.isClosePausedRef,B]),t.useEffect((()=>(V(),()=>U())),[V,U]);const H=t.useMemo((()=>N?J(N):null),[N]);return R.viewport?y(g,{children:[H&&x(q,{__scopeToast:s,role:"status","aria-live":"foreground"===i?"assertive":"polite","aria-atomic":!0,children:H}),x($,{scope:s,onClose:X,children:o.createPortal(x(C.ItemSlot,{scope:s,children:x(u,{asChild:!0,onEscapeKeyDown:a(m,(()=>{R.isFocusedToastEscapeKeyDownRef.current||X(),R.isFocusedToastEscapeKeyDownRef.current=!1})),children:x(p.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":d?"open":"closed","data-swipe-direction":R.swipeDirection,...P,ref:D,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:a(e.onKeyDown,(e=>{"Escape"===e.key&&(m?.(e.nativeEvent),e.nativeEvent.defaultPrevented||(R.isFocusedToastEscapeKeyDownRef.current=!0,X()))})),onPointerDown:a(e.onPointerDown,(e=>{0===e.button&&(S.current={x:e.clientX,y:e.clientY})})),onPointerMove:a(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:a(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})),q=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(l,{asChild:!0,children:x(h,{...n,children:a&&y(g,{children:[s.label," ",o]})})})},B=t.forwardRef(((e,t)=>{const{__scopeToast:r,...o}=e;return x(p.div,{...o,ref:t})}));B.displayName="ToastTitle";var H=t.forwardRef(((e,t)=>{const{__scopeToast:r,...o}=e;return x(p.div,{...o,ref:t})}));H.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,n=U(Y,r);return x(G,{asChild:!0,children:x(p.button,{type:"button",...o,ref:t,onClick:a(e.onClick,n.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=B,se=H,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 e}from"../chunks/utils-B4HRExF_.mjs";import*as t from"react";import r from"react";import*as o from"react-dom";import{u as n,P as s,c as a}from"../chunks/index-BgU_7G37.mjs";import{createCollection as i}from"@radix-ui/react-collection";import{c}from"../chunks/index-BXKQJZ6z.mjs";import{B as d,R as u,P as l}from"../chunks/index-DX37fts-.mjs";import{P as p,d as m}from"../chunks/index-Bj6b6xW8.mjs";import{u as f}from"../chunks/index-DwSoQWco.mjs";import{u as v}from"../chunks/index-CJw5YZXp.mjs";import{u as w}from"../chunks/index-C99OdH8-.mjs";import{V as h}from"../chunks/index-w5meZsTe.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-rWMGj99P.mjs";import"../chunks/bundle-mjs-DdsKEIOo.mjs";import"@radix-ui/react-slot";import"../chunks/createLucideIcon-BSkMD9sy.mjs";var b="ToastProvider",[C,P,R]=i("Toast"),[N,k]=c("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:s=F,label:a="Notifications ({hotkey})",...i}=e,c=L(_,o),u=P(o),l=t.useRef(null),m=t.useRef(null),f=t.useRef(null),v=t.useRef(null),w=n(r,v,c.onViewportChange),h=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=c.toastCount>0;t.useEffect((()=>{const e=e=>{0!==s.length&&s.every((t=>e[t]||e.code===t))&&v.current?.focus()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[s]),t.useEffect((()=>{const e=l.current,t=v.current;if(g&&e&&t){const r=()=>{if(!c.isClosePausedRef.current){const e=new CustomEvent(j);t.dispatchEvent(e),c.isClosePausedRef.current=!0}},o=()=>{if(c.isClosePausedRef.current){const e=new CustomEvent(A);t.dispatchEvent(e),c.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,c.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(d,{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:n,onOpenChange:i,...c}=e,[d,u]=v({prop:o,defaultProp:n??!0,onChange:i,caller:O});return x(s,{present:r||d,children:x(X,{open:d,...c,ref:t,onClose:()=>u(!1),onPause:f(e.onPause),onResume:f(e.onResume),onSwipeStart:a(e.onSwipeStart,(e=>{e.currentTarget.setAttribute("data-swipe","start")})),onSwipeMove:a(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:a(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:a(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`),u(!1)}))})})}));V.displayName=O;var[$,U]=N(O,{onClose(){}}),X=t.forwardRef(((e,r)=>{const{__scopeToast:s,type:i="foreground",duration:c,open:d,onClose:l,onEscapeKeyDown:m,onPause:v,onResume:w,onSwipeStart:h,onSwipeMove:E,onSwipeCancel:T,onSwipeEnd:b,...P}=e,R=L(O,s),[N,k]=t.useState(null),D=n(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:U}=R,X=f((()=>{const e=N?.contains(document.activeElement);e&&R.viewport?.focus(),l()})),B=t.useCallback((e=>{e&&e!==1/0&&(window.clearTimeout(K.current),I.current=(new Date).getTime(),K.current=window.setTimeout(X,e))}),[X]);t.useEffect((()=>{const e=R.viewport;if(e){const t=()=>{B(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,B]),t.useEffect((()=>{d&&!R.isClosePausedRef.current&&B(F)}),[d,F,R.isClosePausedRef,B]),t.useEffect((()=>(V(),()=>U())),[V,U]);const H=t.useMemo((()=>N?J(N):null),[N]);return R.viewport?y(g,{children:[H&&x(q,{__scopeToast:s,role:"status","aria-live":"foreground"===i?"assertive":"polite","aria-atomic":!0,children:H}),x($,{scope:s,onClose:X,children:o.createPortal(x(C.ItemSlot,{scope:s,children:x(u,{asChild:!0,onEscapeKeyDown:a(m,(()=>{R.isFocusedToastEscapeKeyDownRef.current||X(),R.isFocusedToastEscapeKeyDownRef.current=!1})),children:x(p.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":d?"open":"closed","data-swipe-direction":R.swipeDirection,...P,ref:D,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:a(e.onKeyDown,(e=>{"Escape"===e.key&&(m?.(e.nativeEvent),e.nativeEvent.defaultPrevented||(R.isFocusedToastEscapeKeyDownRef.current=!0,X()))})),onPointerDown:a(e.onPointerDown,(e=>{0===e.button&&(S.current={x:e.clientX,y:e.clientY})})),onPointerMove:a(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:a(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})),q=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(l,{asChild:!0,children:x(h,{...n,children:a&&y(g,{children:[s.label," ",o]})})})},B=t.forwardRef(((e,t)=>{const{__scopeToast:r,...o}=e;return x(p.div,{...o,ref:t})}));B.displayName="ToastTitle";var H=t.forwardRef(((e,t)=>{const{__scopeToast:r,...o}=e;return x(p.div,{...o,ref:t})}));H.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,n=U(Y,r);return x(G,{asChild:!0,children:x(p.button,{type:"button",...o,ref:t,onClick:a(e.onClick,n.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=B,se=H,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};
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/tooltip/index.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{c as e}from"../chunks/utils-
|
1
|
+
import{c as e}from"../chunks/utils-B4HRExF_.mjs";import*as t from"react";import n from"react";import{u as o,c as r,P as i}from"../chunks/index-BgU_7G37.mjs";import{c as a}from"../chunks/index-BXKQJZ6z.mjs";import{P as s,D as c}from"../chunks/index-DX37fts-.mjs";import{u as l}from"../chunks/index-BclYsZHn.mjs";import{c as u,R as d,A as p,C as f,a as m}from"../chunks/index-DN2GfLYB.mjs";import{P as h}from"../chunks/index-Bj6b6xW8.mjs";import{createSlottable as g}from"@radix-ui/react-slot";import{u as x}from"../chunks/index-CJw5YZXp.mjs";import{R as y}from"../chunks/index-w5meZsTe.mjs";import{jsx as v,jsxs as b}from"react/jsx-runtime";import"../chunks/bundle-mjs-DdsKEIOo.mjs";import"../chunks/index-C99OdH8-.mjs";import"../chunks/index-DwSoQWco.mjs";import"react-dom";import"../chunks/index-DHTHqgm4.mjs";var[w,C]=a("Tooltip",[u]),T=u(),E="TooltipProvider",k=700,R="tooltip.open",[_,D]=w(E),P=e=>{const{__scopeTooltip:n,delayDuration:o=k,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,s=t.useRef(!0),c=t.useRef(!1),l=t.useRef(0);return t.useEffect((()=>{const e=l.current;return()=>window.clearTimeout(e)}),[]),v(_,{scope:n,isOpenDelayedRef:s,delayDuration:o,onOpen:t.useCallback((()=>{window.clearTimeout(l.current),s.current=!1}),[]),onClose:t.useCallback((()=>{window.clearTimeout(l.current),l.current=window.setTimeout((()=>s.current=!0),r)}),[r]),isPointerInTransitRef:c,onPointerInTransitChange:t.useCallback((e=>{c.current=e}),[]),disableHoverableContent:i,children:a})};P.displayName=E;var L="Tooltip",[j,O]=w(L),M=e=>{const{__scopeTooltip:n,children:o,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:s,delayDuration:c}=e,u=D(L,e.__scopeTooltip),p=T(n),[f,m]=t.useState(null),h=l(),g=t.useRef(0),y=s??u.disableHoverableContent,b=c??u.delayDuration,w=t.useRef(!1),[C,E]=x({prop:r,defaultProp:i??!1,onChange:e=>{e?(u.onOpen(),document.dispatchEvent(new CustomEvent(R))):u.onClose(),a?.(e)},caller:L}),k=t.useMemo((()=>C?w.current?"delayed-open":"instant-open":"closed"),[C]),_=t.useCallback((()=>{window.clearTimeout(g.current),g.current=0,w.current=!1,E(!0)}),[E]),P=t.useCallback((()=>{window.clearTimeout(g.current),g.current=0,E(!1)}),[E]),O=t.useCallback((()=>{window.clearTimeout(g.current),g.current=window.setTimeout((()=>{w.current=!0,E(!0),g.current=0}),b)}),[b,E]);return t.useEffect((()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)}),[]),v(d,{...p,children:v(j,{scope:n,contentId:h,open:C,stateAttribute:k,trigger:f,onTriggerChange:m,onTriggerEnter:t.useCallback((()=>{u.isOpenDelayedRef.current?O():_()}),[u.isOpenDelayedRef,O,_]),onTriggerLeave:t.useCallback((()=>{y?P():(window.clearTimeout(g.current),g.current=0)}),[P,y]),onOpen:_,onClose:P,disableHoverableContent:y,children:o})})};M.displayName=L;var I="TooltipTrigger",N=t.forwardRef(((e,n)=>{const{__scopeTooltip:i,...a}=e,s=O(I,i),c=D(I,i),l=T(i),u=t.useRef(null),d=o(n,u,s.onTriggerChange),f=t.useRef(!1),m=t.useRef(!1),g=t.useCallback((()=>f.current=!1),[]);return t.useEffect((()=>()=>document.removeEventListener("pointerup",g)),[g]),v(p,{asChild:!0,...l,children:v(h.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...a,ref:d,onPointerMove:r(e.onPointerMove,(e=>{"touch"!==e.pointerType&&(m.current||c.isPointerInTransitRef.current||(s.onTriggerEnter(),m.current=!0))})),onPointerLeave:r(e.onPointerLeave,(()=>{s.onTriggerLeave(),m.current=!1})),onPointerDown:r(e.onPointerDown,(()=>{s.open&&s.onClose(),f.current=!0,document.addEventListener("pointerup",g,{once:!0})})),onFocus:r(e.onFocus,(()=>{f.current||s.onOpen()})),onBlur:r(e.onBlur,s.onClose),onClick:r(e.onClick,s.onClose)})})}));N.displayName=I;var H="TooltipPortal",[A,B]=w(H,{forceMount:void 0}),F=e=>{const{__scopeTooltip:t,forceMount:n,children:o,container:r}=e,a=O(H,t);return v(A,{scope:t,forceMount:n,children:v(i,{present:n||a.open,children:v(s,{asChild:!0,container:r,children:o})})})};F.displayName=H;var z="TooltipContent",K=t.forwardRef(((e,t)=>{const n=B(z,e.__scopeTooltip),{forceMount:o=n.forceMount,side:r="top",...a}=e,s=O(z,e.__scopeTooltip);return v(i,{present:o||s.open,children:s.disableHoverableContent?v(G,{side:r,...a,ref:t}):v(S,{side:r,...a,ref:t})})})),S=t.forwardRef(((e,n)=>{const r=O(z,e.__scopeTooltip),i=D(z,e.__scopeTooltip),a=t.useRef(null),s=o(n,a),[c,l]=t.useState(null),{trigger:u,onClose:d}=r,p=a.current,{onPointerInTransitChange:f}=i,m=t.useCallback((()=>{l(null),f(!1)}),[f]),h=t.useCallback(((e,t)=>{const n=e.currentTarget,o={x:e.clientX,y:e.clientY},r=function(e,t,n=5){const o=[];switch(t){case"top":o.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":o.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":o.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":o.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return o}(o,function(e,t){const n=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,o,r,i)){case i:return"left";case r:return"right";case n:return"top";case o:return"bottom";default:throw new Error("unreachable")}}(o,n.getBoundingClientRect())),i=function(e){const t=e.slice();return t.sort(((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0)),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const o=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(o.y-n.y)>=(e.y-n.y)*(o.x-n.x)))break;t.pop()}t.push(o)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const o=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(o.y-t.y)>=(e.y-t.y)*(o.x-t.x)))break;n.pop()}n.push(o)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...r,...function(e){const{top:t,right:n,bottom:o,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:o},{x:r,y:o}]}(t.getBoundingClientRect())]);l(i),f(!0)}),[f]);return t.useEffect((()=>()=>m()),[m]),t.useEffect((()=>{if(u&&p){const e=e=>h(e,p),t=e=>h(e,u);return u.addEventListener("pointerleave",e),p.addEventListener("pointerleave",t),()=>{u.removeEventListener("pointerleave",e),p.removeEventListener("pointerleave",t)}}}),[u,p,h,m]),t.useEffect((()=>{if(c){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},o=u?.contains(t)||p?.contains(t),r=!function(e,t){const{x:n,y:o}=e;let r=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){const a=t[e],s=t[i],c=a.x,l=a.y,u=s.x,d=s.y;l>o!=d>o&&n<(u-c)*(o-l)/(d-l)+c&&(r=!r)}return r}(n,c);o?m():r&&(m(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}}),[u,p,c,d,m]),v(G,{...e,ref:s})})),[X,Y]=w(L,{isInside:!1}),q=g("TooltipContent"),G=t.forwardRef(((e,n)=>{const{__scopeTooltip:o,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:s,...l}=e,u=O(z,o),d=T(o),{onClose:p}=u;return t.useEffect((()=>(document.addEventListener(R,p),()=>document.removeEventListener(R,p))),[p]),t.useEffect((()=>{if(u.trigger){const e=e=>{const t=e.target;t?.contains(u.trigger)&&p()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}}),[u.trigger,p]),v(c,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:b(f,{"data-state":u.stateAttribute,...d,...l,ref:n,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[v(q,{children:r}),v(X,{scope:o,isInside:!0,children:v(y,{id:u.contentId,role:"tooltip",children:i||r})})]})})}));K.displayName=z;var J="TooltipArrow";t.forwardRef(((e,t)=>{const{__scopeTooltip:n,...o}=e,r=T(n);return Y(J,n).isInside?null:v(m,{...r,...o,ref:t})})).displayName=J;var Q=P,U=M,V=N,W=F,Z=K;function $({delayDuration:e=700,...t}){return n.createElement(Q,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ee({...e}){return n.createElement($,null,n.createElement(U,{"data-slot":"tooltip",...e}))}function te({...e}){return n.createElement(V,{"data-slot":"tooltip-trigger",...e})}function ne({className:t,sideOffset:o=0,children:r,...i}){return n.createElement(W,null,n.createElement(Z,{"data-slot":"tooltip-content",sideOffset:o,className:e("bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md px-3 py-1.5 text-sm shadow-md drop-shadow",t),...i},r))}export{ee as Tooltip,ne as TooltipContent,$ as TooltipProvider,te as TooltipTrigger};
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED