@zag-js/toast 0.0.0-dev-20220406144843
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/toast-group.connect.d.ts +25 -0
- package/dist/toast-group.machine.d.ts +2 -0
- package/dist/toast.connect.d.ts +18 -0
- package/dist/toast.dom.d.ts +11 -0
- package/dist/toast.machine.d.ts +2 -0
- package/dist/toast.types.d.ts +148 -0
- package/dist/toast.utils.d.ts +6 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @zag-js/toast
|
|
2
|
+
|
|
3
|
+
Core logic for the toast widget implemented as a state machine
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
yarn add @zag-js/toast
|
|
9
|
+
# or
|
|
10
|
+
npm i @zag-js/toast
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Contribution
|
|
14
|
+
|
|
15
|
+
Yes please! See the [contributing guidelines](https://github.com/chakra-ui/ui-machines/blob/main/CONTRIBUTING.md) for
|
|
16
|
+
details.
|
|
17
|
+
|
|
18
|
+
## Licence
|
|
19
|
+
|
|
20
|
+
This project is licensed under the terms of the
|
|
21
|
+
[MIT license](https://github.com/chakra-ui/ui-machines/blob/main/LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { groupConnect } from "./toast-group.connect";
|
|
2
|
+
import { createToastMachine as createMachine } from "./toast.machine";
|
|
3
|
+
export { connect } from "./toast.connect";
|
|
4
|
+
export type { GroupMachineContext, MachineContext, MachineState, Placement, Service, Type } from "./toast.types";
|
|
5
|
+
export { createMachine };
|
|
6
|
+
export declare const group: {
|
|
7
|
+
connect: typeof groupConnect;
|
|
8
|
+
machine: import("@zag-js/core").Machine<import("./toast.types").GroupMachineContext, import("@zag-js/core").StateMachine.StateSchema, import("@zag-js/core").StateMachine.AnyEventObject>;
|
|
9
|
+
};
|
|
10
|
+
export declare function api(): import("./toast.types").Toaster;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var E=Object.defineProperty,K=Object.defineProperties,W=Object.getOwnPropertyDescriptor,$=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var C=(t,e,n)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,f=(t,e)=>{for(var n in e||(e={}))T.call(e,n)&&C(t,n,e[n]);if(w)for(var n of w(e))I.call(e,n)&&C(t,n,e[n]);return t},g=(t,e)=>K(t,$(e)),X=t=>E(t,"__esModule",{value:!0});var O=(t,e)=>{var n={};for(var r in t)T.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&w)for(var r of w(t))e.indexOf(r)<0&&I.call(t,r)&&(n[r]=t[r]);return n};var Z=(t,e)=>{for(var n in e)E(t,n,{get:e[n],enumerable:!0})},J=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y(e))!T.call(t,o)&&(n||o!=="default")&&E(t,o,{get:()=>e[o],enumerable:!(r=W(e,o))||r.enumerable});return t};var Q=(t=>(e,n)=>t&&t.get(e)||(n=J(X({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var ft={};Z(ft,{api:()=>pt,connect:()=>q,createMachine:()=>P,group:()=>dt});var A=(t,...e)=>{let n=typeof t=="function"?t(...e):t;return n!=null?n:void 0};var gt=(()=>{let t=0;return()=>(t++,t.toString(36))})();var D=()=>typeof window!="undefined";function _(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}var V=require("@zag-js/core");function tt(t){return{button:t,label:t,input:t,output:t,element:t}}var S=tt(t=>t);var d={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getGroupId:t=>`toast-group--${t}`,getContainerId:t=>`toast--${t.id}`,getTitleId:t=>`toast-title--${t.id}`,getCloseButtonId:t=>`toast-close-button--${t.id}`,getPortalId:t=>`toast-portal--${t.uid}`,getPortalEl:t=>d.getDoc(t).getElementById(d.getPortalId(t)),createPortalEl:t=>{let e=d.getPortalEl(t);if(e)return e;let n=d.getDoc(t).createElement("toast-portal");return n.id=d.getPortalId(t),n}};function R(t){let e={};for(let n of t){let r=n.state.context.placement;e[r]||(e[r]=[]),e[r].push(n)}return e}var et={info:5e3,error:5e3,success:2e3,loading:1/0,custom:5e3};function M(t,e){return t!=null?t:et[e]}function U(t,e){let n=t.offsets,r=typeof n=="string"?{left:n,right:n,bottom:n,top:n}:n,o=t.dir==="rtl",a=e.replace("-start",o?"-right":"-left").replace("-end",o?"-left":"-right"),l=a.includes("right"),m=a.includes("left"),c={position:"fixed",pointerEvents:t.count>0?void 0:"none",display:"flex",flexDirection:"column","--toast-gutter":t.gutter,zIndex:t.zIndex},i="center";if(l&&(i="flex-end"),m&&(i="flex-start"),c.alignItems=i,a.includes("top")){let s=r.top;c.top=`calc(env(safe-area-inset-top, 0px) + ${s})`}if(a.includes("bottom")){let s=r.bottom;c.bottom=`calc(env(safe-area-inset-bottom, 0px) + ${s})`}if(!a.includes("left")){let s=r.right;c.right=`calc(env(safe-area-inset-right, 0px) + ${s})`}if(!a.includes("right")){let s=r.left;c.left=`calc(env(safe-area-inset-left, 0px) + ${s})`}return c}var L={};function B(t,e,n=S){let r={count:t.context.count,toasts:t.context.toasts,toastsByPlacement:R(t.context.toasts),isVisible(o){return t.context.toasts.length?!!t.context.toasts.find(a=>a.id==o):!1},create(o){let a="toast-"+Math.random().toString(36).substring(2,9),l=o.id?o.id:a;if(!r.isVisible(l))return e({type:"ADD_TOAST",toast:g(f({},o),{id:l})}),l},upsert(o){let{id:a}=o;return(a?r.isVisible(a):!1)&&a!=null?r.update(a,o):r.create(o)},dismiss(o){o==null?e("DISMISS_ALL"):r.isVisible(o)&&e({type:"DISMISS_TOAST",id:o})},remove(o){o==null?e("REMOVE_ALL"):r.isVisible(o)&&e({type:"REMOVE_TOAST",id:o})},dismissByPlacement(o){let a=r.toastsByPlacement[o];a&&a.forEach(l=>r.dismiss(l.id))},update(o,a){if(!!r.isVisible(o))return e({type:"UPDATE_TOAST",id:o,toast:a}),o},loading(o){return o.type="loading",r.upsert(o)},success(o){return o.type="success",r.upsert(o)},error(o){return o.type="error",r.upsert(o)},promise(o,a,l={}){let m=r.loading(g(f(f({},l),l==null?void 0:l.loading),{type:"loading",title:a.loading}));return o.then(c=>{let i=A(a.loading,c);r.success(g(f(f({},l),l==null?void 0:l.success),{id:m,title:i}))}).catch(c=>{let i=A(a.error,c);r.error(g(f(f({},l),l==null?void 0:l.error),{id:m,title:i}))}),o},pause(o){o==null?e("PAUSE_ALL"):r.isVisible(o)&&e({type:"PAUSE_TOAST",id:o})},resume(o){o==null?e("RESUME_ALL"):r.isVisible(o)&&e({type:"RESUME_TOAST",id:o})},getGroupProps(o){let{placement:a,label:l="Notifications"}=o;return n.element({tabIndex:-1,"aria-label":l,id:d.getGroupId(a),"data-placement":a,"aria-live":"polite",role:"region",style:U(t.context,a)})},createPortal(){let o=d.getDoc(t.context),a=d.getPortalEl(t.context);if(a)return a;let l=d.createPortalEl(t.context);return o.body.appendChild(l),l},subscribe(o){return(0,V.subscribe)(t.context.toasts,()=>o(t.context.toasts))}};return t.matches("unknown")||Object.assign(L,r),r}var b=require("@zag-js/core");var N=t=>t?"":void 0;var nt=t=>t,ot=()=>{};var Lt=(()=>{let t=0;return()=>(t++,t.toString(36))})();var y=new Map,v=new Map;function rt(t,e,n,r){var o;if(!t)return ot;let a=JSON.stringify({type:e,options:r}),l=y.get(t);if(y.has(t))(l==null?void 0:l.has(a))?(o=l==null?void 0:l.get(a))==null||o.add(n):l==null||l.set(a,new Set([n]));else{let c=new Map([[a,new Set([n])]]);y.set(t,c)}function m(c){var i,s;function u(p){var h;let k=y.get(c);(h=k==null?void 0:k.get(a))==null||h.forEach(H=>H(p))}if(!(v==null?void 0:v.has(c))){v.set(c,new Map([[a,u]])),c.addEventListener(e,u,r);return}((i=v==null?void 0:v.get(c))==null?void 0:i.has(a))||((s=v.get(c))==null||s.set(a,u),c.addEventListener(e,u,r))}return m(t),function(){var c,i,s,u;if(!y.has(t))return;let p=y.get(t);if((c=p==null?void 0:p.get(a))==null||c.delete(n),((i=p==null?void 0:p.get(a))==null?void 0:i.size)===0){let h=(s=v.get(t))==null?void 0:s.get(a);t.removeEventListener(e,h,r),p==null||p.delete(a),(u=v.get(t))==null||u.delete(a),(p==null?void 0:p.size)===0&&(y.delete(t),v.delete(t))}}}var z=t=>Object.prototype.toString.call(t).slice(8,-1),it=t=>z(t)==="Object"&&"current"in t,at=t=>z(t)==="Function"?t():t;function st(t,e,n,r){let o=it(t)?t.current:at(t);return rt(o,e,n,r)}var F=2147483647;var kt=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function G(t,e){let n=nt(t);return st(n,"visibilitychange",()=>{let r=n.hidden||n.msHidden||n.webkitHidden;e(!!r)})}var x=require("@zag-js/core");var{not:lt,and:ct,or:ut}=x.guards;function P(t={}){let c=t,{type:e="info",duration:n,id:r="toast",placement:o="bottom",removeDelay:a=500}=c,l=O(c,["type","duration","id","placement","removeDelay"]),m=M(n,e);return(0,x.createMachine)({id:r,entry:"invokeOnOpen",initial:e==="loading"?"persist":"active",context:f({id:r,type:e,remaining:m,duration:m,removeDelay:a,createdAt:Date.now(),placement:o},l),on:{UPDATE:[{guard:ct("hasTypeChanged","isChangingToLoading"),target:"persist",actions:["setContext","invokeOnUpdate"]},{guard:ut("hasDurationChanged","hasTypeChanged"),target:"active:temp",actions:["setContext","invokeOnUpdate"]},{actions:["setContext","invokeOnUpdate"]}]},states:{"active:temp":{tags:["visible","updating"],after:{0:"active"}},persist:{tags:["visible","paused"],activities:"trackDocumentVisibility",on:{RESUME:{guard:lt("isLoadingType"),target:"active",actions:["setCreatedAt"]},DISMISS:"dismissing"}},active:{tags:["visible"],activities:"trackDocumentVisibility",after:{VISIBLE_DURATION:"dismissing"},on:{DISMISS:"dismissing",PAUSE:{target:"persist",actions:"setRemainingDuration"}}},dismissing:{entry:"invokeOnClosing",after:{REMOVE_DELAY:{target:"inactive",actions:"notifyParentToRemove"}}},inactive:{entry:"invokeOnClose",type:"final"}}},{activities:{trackDocumentVisibility(i,s,{send:u}){if(!!i.pauseOnPageIdle)return G(d.getDoc(i),function(p){u(p?"PAUSE":"RESUME")})}},guards:{isChangingToLoading:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.type)==="loading"},isLoadingType:i=>i.type==="loading",hasTypeChanged:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.type)!==i.type},hasDurationChanged:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.duration)!==i.duration}},delays:{VISIBLE_DURATION:i=>i.remaining,REMOVE_DELAY:i=>i.removeDelay},actions:{setRemainingDuration(i){i.remaining-=Date.now()-i.createdAt},setCreatedAt(i){i.createdAt=Date.now()},notifyParentToRemove(i,s,{self:u}){u.sendParent({type:"REMOVE_TOAST",id:u.id})},invokeOnClosing(i){var s;(s=i.onClosing)==null||s.call(i)},invokeOnClose(i){var s;(s=i.onClose)==null||s.call(i)},invokeOnOpen(i){var s;(s=i.onOpen)==null||s.call(i)},invokeOnUpdate(i){var s;(s=i.onUpdate)==null||s.call(i)},setContext(i,s){let{duration:u,type:p}=s.toast,h=M(u,p);Object.assign(i,g(f({},s.toast),{duration:h,remaining:h}))}}})}var j=(0,b.createMachine)({id:"toaster",initial:"active",context:{dir:"ltr",max:Number.MAX_SAFE_INTEGER,uid:"",toasts:[],gutter:"1rem",zIndex:F,pauseOnPageIdle:!1,pauseOnInteraction:!0,offsets:{left:"0px",right:"0px",top:"0px",bottom:"0px"}},computed:{count:t=>t.toasts.length},on:{SETUP:{actions:(t,e)=>{t.uid=e.id,e.doc&&(t.doc=(0,b.ref)(e.doc))}},PAUSE_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("PAUSE",e.id)}},PAUSE_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("PAUSE"))}},RESUME_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("RESUME",e.id)}},RESUME_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("RESUME"))}},ADD_TOAST:{guard:t=>t.toasts.length<t.max,actions:(t,e,{self:n})=>{var l;let r=g(f({},e.toast),{pauseOnPageIdle:t.pauseOnPageIdle,pauseOnInteraction:t.pauseOnInteraction,dir:t.dir,doc:(0,b.ref)((l=t.doc)!=null?l:document)}),o=P(r),a=n.spawn(o);t.toasts.push(a)}},UPDATE_TOAST:{actions:(t,e,{self:n})=>{n.sendChild({type:"UPDATE",toast:e.toast},e.id)}},DISMISS_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("DISMISS",e.id)}},DISMISS_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("DISMISS"))}},REMOVE_TOAST:{actions:(t,e,{self:n})=>{n.stopChild(e.id);let r=t.toasts.findIndex(o=>o.id===e.id);t.toasts.splice(r,1)}},REMOVE_ALL:{actions:(t,e,{self:n})=>{for(t.toasts.forEach(r=>n.stopChild(r.id));t.toasts.length;)t.toasts.pop()}}}});function q(t,e,n=S){let r=t.hasTag("visible"),o=t.hasTag("paused"),a=t.hasTag("updating"),l=t.context.dir==="rtl",m=t.context.type,c=t.context.pauseOnInteraction,i=t.context.placement;return{type:t.context.type,title:t.context.title,placement:i,isVisible:r,isPaused:o,pause(){e("PAUSE")},resume(){e("RESUME")},dismiss(){e("DISMISS")},rootProps:n.element({"data-part":"root",dir:t.context.dir,id:d.getContainerId(t.context),"data-open":N(r),"data-type":t.context.type,"data-placement":i,role:"status","aria-atomic":"true",tabIndex:0,style:{position:"relative",pointerEvents:"auto",margin:"calc(var(--toast-gutter) / 2)","--remove-delay":`${t.context.removeDelay}ms`,"--duration":`${t.context.duration}ms`},onKeyDown(s){s.key=="Escape"&&(e("DISMISS"),s.preventDefault(),s.stopPropagation())},onFocus(){c&&e("PAUSE")},onBlur(){c&&e("RESUME")},onPointerEnter(){c&&e("PAUSE")},onPointerLeave(){c&&e("RESUME")}}),progressbarProps:n.element({"data-part":"progressbar","data-type":t.context.type,style:{opacity:r?1:0,transformOrigin:l?"right":"left",animationName:a||m==="loading"?"none":void 0,animationPlayState:o?"paused":"running",animationDuration:`${t.context.duration}ms`,animationFillMode:a?void 0:"forwards"}}),titleProps:n.element({"data-part":"title",id:d.getTitleId(t.context)}),closeButtonProps:n.button({id:d.getCloseButtonId(t.context),"data-part":"close-button",type:"button","aria-label":"Dismiss notification",onClick(){e("DISMISS")}}),render(){var s,u;return(u=(s=t.context).render)==null?void 0:u.call(s,{id:t.context.id,type:t.context.type,duration:t.context.duration,title:t.context.title,placement:t.context.placement,description:t.context.description,dismiss(){e("DISMISS")}})}}}var dt={connect:B,machine:j};function pt(){if(!D())_("toast.api() is only available in the browser");else return L}module.exports=Q(ft);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../../../utilities/core/src/array.ts", "../../../utilities/core/src/functions.ts", "../../../utilities/core/src/guard.ts", "../../../utilities/core/src/warning.ts", "../src/toast-group.connect.ts", "../../../types/src/prop-types.ts", "../../../types/src/controls.ts", "../src/toast.dom.ts", "../src/toast.utils.ts", "../src/toast-group.machine.ts", "../../../utilities/dom/src/attrs.ts", "../../../utilities/dom/src/computed-style.ts", "../../../utilities/dom/src/next-tick.ts", "../../../utilities/dom/src/auto-resize.ts", "../../../utilities/core/src/array.ts", "../../../utilities/core/src/functions.ts", "../../../utilities/core/src/guard.ts", "../../../utilities/core/src/warning.ts", "../../../utilities/dom/src/event-bus.ts", "../../../utilities/dom/src/listener.ts", "../../../utilities/dom/src/body-pointer-event.ts", "../../../utilities/dom/src/body-scroll-lock.ts", "../../../utilities/dom/src/query.ts", "../../../utilities/dom/src/scrollable.ts", "../../../utilities/dom/src/constants.ts", "../../../utilities/dom/src/dispatch-event.ts", "../../../utilities/dom/src/focus-event.ts", "../../../utilities/dom/src/focusable.ts", "../../../utilities/dom/src/keyboard-event.ts", "../../../utilities/dom/src/visually-hidden.ts", "../../../utilities/dom/src/live-region.ts", "../../../utilities/dom/src/mutation-observer.ts", "../../../utilities/dom/src/nodelist.ts", "../../../utilities/dom/src/text-selection.ts", "../../../utilities/dom/src/pointer-event.ts", "../../../utilities/dom/src/pointerlock.ts", "../../../utilities/dom/src/rect-observer.ts", "../../../utilities/dom/src/visibility-event.ts", "../../../utilities/dom/src/wait.ts", "../src/toast.machine.ts", "../src/toast.connect.ts"],
|
|
4
|
+
"sourcesContent": ["import { isDom, warn } from \"@zag-js/utils\"\nimport { groupConnect, toaster } from \"./toast-group.connect\"\nimport { groupMachine } from \"./toast-group.machine\"\nimport { createToastMachine as createMachine } from \"./toast.machine\"\n\nexport { connect } from \"./toast.connect\"\nexport type { GroupMachineContext, MachineContext, MachineState, Placement, Service, Type } from \"./toast.types\"\nexport { createMachine }\n\nexport const group = {\n connect: groupConnect,\n machine: groupMachine,\n}\n\nexport function api() {\n if (!isDom()) {\n warn(\"toast.api() is only available in the browser\")\n } else {\n return toaster\n }\n}\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: MouseEvent | PointerEvent | KeyboardEvent) =>\n v.ctrlKey || v.altKey || v.metaKey || v.shiftKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { StateMachine as S, subscribe } from \"@zag-js/core\"\nimport { normalizeProp, PropTypes, ReactPropTypes } from \"@zag-js/types\"\nimport { runIfFn } from \"@zag-js/utils\"\nimport { dom } from \"./toast.dom\"\nimport {\n Toaster,\n GroupProps,\n GroupMachineContext,\n Options,\n Placement,\n PromiseMessages,\n PromiseOptions,\n} from \"./toast.types\"\nimport { getGroupPlacementStyle, getToastsByPlacement } from \"./toast.utils\"\n\nexport let toaster: Toaster = {} as any\n\nexport function groupConnect<T extends PropTypes = ReactPropTypes>(\n state: S.State<GroupMachineContext>,\n send: (event: S.Event<S.AnyEventObject>) => void,\n normalize = normalizeProp,\n) {\n const group = {\n count: state.context.count,\n toasts: state.context.toasts,\n toastsByPlacement: getToastsByPlacement(state.context.toasts),\n\n isVisible(id: string) {\n if (!state.context.toasts.length) return false\n return !!state.context.toasts.find((toast) => toast.id == id)\n },\n\n create(options: Options) {\n const uid = \"toast-\" + Math.random().toString(36).substring(2, 9)\n const id = options.id ? options.id : uid\n\n if (group.isVisible(id)) return\n send({ type: \"ADD_TOAST\", toast: { ...options, id } })\n\n return id\n },\n\n upsert(options: Options) {\n const { id } = options\n const isVisible = id ? group.isVisible(id) : false\n if (isVisible && id != null) {\n return group.update(id, options)\n } else {\n return group.create(options)\n }\n },\n\n dismiss(id?: string) {\n if (id == null) {\n send(\"DISMISS_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"DISMISS_TOAST\", id })\n }\n },\n\n remove(id?: string) {\n if (id == null) {\n send(\"REMOVE_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"REMOVE_TOAST\", id })\n }\n },\n\n dismissByPlacement(placement: Placement) {\n const toasts = group.toastsByPlacement[placement]\n if (toasts) {\n toasts.forEach((toast) => group.dismiss(toast.id))\n }\n },\n\n update(id: string, options: Options) {\n if (!group.isVisible(id)) return\n send({ type: \"UPDATE_TOAST\", id, toast: options })\n return id\n },\n\n loading(options: Options) {\n options.type = \"loading\"\n return group.upsert(options)\n },\n\n success(options: Options) {\n options.type = \"success\"\n return group.upsert(options)\n },\n\n error(options: Options) {\n options.type = \"error\"\n return group.upsert(options)\n },\n\n promise<T>(promise: Promise<T>, msgs: PromiseMessages, opts: PromiseOptions = {}) {\n const id = group.loading({ ...opts, ...opts?.loading, type: \"loading\", title: msgs.loading })\n\n promise\n .then((response) => {\n const message = runIfFn(msgs.loading, response)\n group.success({ ...opts, ...opts?.success, id, title: message })\n })\n .catch((error) => {\n const message = runIfFn(msgs.error, error)\n group.error({ ...opts, ...opts?.error, id, title: message })\n })\n\n return promise\n },\n\n pause(id?: string) {\n if (id == null) {\n send(\"PAUSE_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"PAUSE_TOAST\", id })\n }\n },\n\n resume(id?: string) {\n if (id == null) {\n send(\"RESUME_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"RESUME_TOAST\", id })\n }\n },\n\n getGroupProps(options: GroupProps) {\n const { placement, label = \"Notifications\" } = options\n return normalize.element<T>({\n tabIndex: -1,\n \"aria-label\": label,\n id: dom.getGroupId(placement),\n \"data-placement\": placement,\n \"aria-live\": \"polite\",\n role: \"region\",\n style: getGroupPlacementStyle(state.context, placement),\n })\n },\n\n createPortal() {\n const doc = dom.getDoc(state.context)\n const exist = dom.getPortalEl(state.context)\n if (exist) return exist\n const portal = dom.createPortalEl(state.context)\n doc.body.appendChild(portal)\n return portal\n },\n\n subscribe(fn: (toasts: GroupMachineContext[\"toasts\"]) => void) {\n return subscribe(state.context.toasts, () => fn(state.context.toasts))\n },\n }\n\n if (!state.matches(\"unknown\")) {\n Object.assign(toaster, group)\n }\n\n return group\n}\n", "import type * as React from \"react\"\n\ntype Dict<T = any> = Record<string, T>\n\ntype Booleanish = boolean | \"true\" | \"false\"\n\ntype Omit<T, K extends keyof T> = { [P in Exclude<keyof T, K>]?: T[P] }\n\ntype WithStyle<T extends { style?: any }> = Omit<T, \"style\"> & {\n style?: T[\"style\"] & {\n [prop: string]: string | number | undefined\n }\n}\n\ntype DataAttr = {\n \"data-uid\"?: string\n \"data-name\"?: string\n \"data-ownedby\"?: string\n \"data-selected\"?: Booleanish\n \"data-expanded\"?: Booleanish\n \"data-highlighted\"?: Booleanish\n \"data-readonly\"?: Booleanish\n \"data-invalid\"?: Booleanish\n \"data-hover\"?: Booleanish\n \"data-active\"?: Booleanish\n \"data-focus\"?: Booleanish\n \"data-disabled\"?: Booleanish\n \"data-type\"?: string\n \"data-value\"?: string | number\n \"data-valuetext\"?: string\n \"data-open\"?: Booleanish\n \"data-placement\"?: string\n \"data-orientation\"?: \"horizontal\" | \"vertical\"\n \"data-label\"?: string\n \"data-checked\"?: Booleanish\n \"data-pressed\"?: Booleanish\n \"data-state\"?: string | null\n \"data-half\"?: Booleanish\n \"data-count\"?: number\n \"data-controls\"?: string\n \"data-part\"?: string\n \"data-index\"?: number\n \"data-complete\"?: Booleanish\n \"data-empty\"?: Booleanish\n \"data-placeholder-shown\"?: Booleanish\n}\n\ntype JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>\ntype JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>\ntype JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>\ntype JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>\ntype JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>\n\nexport type PropTypes = Record<\"button\" | \"label\" | \"input\" | \"output\" | \"element\", Dict>\n\nexport type ReactPropTypes = {\n button: JSXButtonAttributes\n label: JSXLabelAttributes\n input: JSXInputAttributes\n output: JSXOutputAttributes\n element: JSXElementAttributes\n}\n\nexport type NormalizeProps = {\n button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T[\"button\"]\n label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T[\"label\"]\n input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T[\"input\"]\n output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T[\"output\"]\n element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T[\"element\"]\n}\n\nexport function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps {\n return { button: fn, label: fn, input: fn, output: fn, element: fn }\n}\n\nexport const normalizeProp = createNormalizer((v) => v)\n", "export type ControlProp =\n | { type: \"boolean\"; label?: string; defaultValue: boolean }\n | { type: \"string\"; label?: string; defaultValue: string; placeholder?: string }\n | { type: \"select\"; options: readonly string[]; defaultValue: string; label?: string }\n | { type: \"multiselect\"; options: readonly string[]; defaultValue: string[]; label?: string }\n | { type: \"number\"; label?: string; defaultValue: number; min?: number; max?: number }\n\nexport type ControlRecord = Record<string, ControlProp>\n\nexport type ControlValue<T extends ControlRecord> = {\n [K in keyof T]: T[K] extends { type: \"boolean\" }\n ? boolean\n : T[K] extends { type: \"string\" }\n ? string\n : T[K] extends { type: \"select\" }\n ? T[K][\"options\"][number]\n : T[K] extends { type: \"multiselect\" }\n ? T[K][\"options\"][number][]\n : T[K] extends { type: \"number\" }\n ? number\n : never\n}\n\nexport function defineControls<T extends ControlRecord>(config: T) {\n return config\n}\n", "import { GroupMachineContext as GroupCtx, MachineContext as Ctx, Placement } from \"./toast.types\"\n\nexport const dom = {\n getDoc: (ctx: Ctx | GroupCtx) => ctx.doc ?? document,\n\n getGroupId: (placement: Placement) => `toast-group--${placement}`,\n getContainerId: (ctx: Ctx) => `toast--${ctx.id}`,\n getTitleId: (ctx: Ctx) => `toast-title--${ctx.id}`,\n getCloseButtonId: (ctx: Ctx) => `toast-close-button--${ctx.id}`,\n\n getPortalId: (ctx: GroupCtx) => `toast-portal--${ctx.uid}`,\n getPortalEl: (ctx: GroupCtx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),\n\n createPortalEl: (ctx: GroupCtx) => {\n const existing = dom.getPortalEl(ctx)\n if (existing) return existing\n const portal = dom.getDoc(ctx).createElement(\"toast-portal\")\n portal.id = dom.getPortalId(ctx)\n return portal\n },\n}\n", "import { Style } from \"@zag-js/types\"\nimport { GroupMachineContext, MachineContext, Placement, Service, Type } from \"./toast.types\"\n\nexport function getToastsByPlacement(toasts: Service[]) {\n const result: Partial<Record<Placement, Service[]>> = {}\n\n for (const toast of toasts) {\n const placement = toast.state.context.placement!\n result[placement] ||= []\n result[placement]!.push(toast)\n }\n\n return result\n}\n\nexport const defaultTimeouts: Record<Type, number> = {\n info: 5000,\n error: 5000,\n success: 2000,\n loading: Infinity,\n custom: 5000,\n}\n\nexport function getToastDuration(duration: number | undefined, type: MachineContext[\"type\"]) {\n return duration ?? defaultTimeouts[type]\n}\n\nexport function getGroupPlacementStyle(ctx: GroupMachineContext, placement: Placement): Style {\n const offset = ctx.offsets\n const __offset = typeof offset === \"string\" ? { left: offset, right: offset, bottom: offset, top: offset } : offset\n\n const rtl = ctx.dir === \"rtl\"\n const __placement = placement.replace(\"-start\", rtl ? \"-right\" : \"-left\").replace(\"-end\", rtl ? \"-left\" : \"-right\")\n\n const isRighty = __placement.includes(\"right\")\n const isLefty = __placement.includes(\"left\")\n\n const styles: Style = {\n position: \"fixed\",\n pointerEvents: ctx.count > 0 ? undefined : \"none\",\n display: \"flex\",\n flexDirection: \"column\",\n \"--toast-gutter\": ctx.gutter,\n zIndex: ctx.zIndex,\n }\n\n let alignItems: Style[\"alignItems\"] = \"center\"\n if (isRighty) alignItems = \"flex-end\"\n if (isLefty) alignItems = \"flex-start\"\n\n styles.alignItems = alignItems\n\n if (__placement.includes(\"top\")) {\n const offset = __offset.top\n styles.top = `calc(env(safe-area-inset-top, 0px) + ${offset})`\n }\n\n if (__placement.includes(\"bottom\")) {\n const offset = __offset.bottom\n styles.bottom = `calc(env(safe-area-inset-bottom, 0px) + ${offset})`\n }\n\n if (!__placement.includes(\"left\")) {\n const offset = __offset.right\n styles.right = `calc(env(safe-area-inset-right, 0px) + ${offset})`\n }\n\n if (!__placement.includes(\"right\")) {\n const offset = __offset.left\n styles.left = `calc(env(safe-area-inset-left, 0px) + ${offset})`\n }\n\n return styles\n}\n", "import { createMachine, ref } from \"@zag-js/core\"\nimport { MAX_Z_INDEX } from \"@zag-js/dom-utils\"\nimport { createToastMachine } from \"./toast.machine\"\nimport { GroupMachineContext } from \"./toast.types\"\n\nexport const groupMachine = createMachine<GroupMachineContext>({\n id: \"toaster\",\n initial: \"active\",\n context: {\n dir: \"ltr\",\n max: Number.MAX_SAFE_INTEGER,\n uid: \"\",\n toasts: [],\n gutter: \"1rem\",\n zIndex: MAX_Z_INDEX,\n pauseOnPageIdle: false,\n pauseOnInteraction: true,\n offsets: { left: \"0px\", right: \"0px\", top: \"0px\", bottom: \"0px\" },\n },\n\n computed: {\n count: (ctx) => ctx.toasts.length,\n },\n\n on: {\n SETUP: {\n actions: (ctx, evt) => {\n ctx.uid = evt.id\n if (evt.doc) ctx.doc = ref(evt.doc)\n },\n },\n\n PAUSE_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild(\"PAUSE\", evt.id)\n },\n },\n\n PAUSE_ALL: {\n actions: (ctx) => {\n ctx.toasts.forEach((toast) => toast.send(\"PAUSE\"))\n },\n },\n\n RESUME_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild(\"RESUME\", evt.id)\n },\n },\n\n RESUME_ALL: {\n actions: (ctx) => {\n ctx.toasts.forEach((toast) => toast.send(\"RESUME\"))\n },\n },\n\n ADD_TOAST: {\n guard: (ctx) => ctx.toasts.length < ctx.max,\n actions: (ctx, evt, { self }) => {\n const options = {\n ...evt.toast,\n pauseOnPageIdle: ctx.pauseOnPageIdle,\n pauseOnInteraction: ctx.pauseOnInteraction,\n dir: ctx.dir,\n doc: ref(ctx.doc ?? document),\n }\n const toast = createToastMachine(options)\n const actor = self.spawn(toast)\n ctx.toasts.push(actor)\n },\n },\n\n UPDATE_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild({ type: \"UPDATE\", toast: evt.toast }, evt.id)\n },\n },\n\n DISMISS_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild(\"DISMISS\", evt.id)\n },\n },\n\n DISMISS_ALL: {\n actions: (ctx) => {\n ctx.toasts.forEach((toast) => toast.send(\"DISMISS\"))\n },\n },\n\n REMOVE_TOAST: {\n actions: (ctx, evt, { self }) => {\n self.stopChild(evt.id)\n const index = ctx.toasts.findIndex((toast) => toast.id === evt.id)\n ctx.toasts.splice(index, 1)\n },\n },\n\n REMOVE_ALL: {\n actions: (ctx, _evt, { self }) => {\n ctx.toasts.forEach((toast) => self.stopChild(toast.id))\n while (ctx.toasts.length) ctx.toasts.pop()\n },\n },\n },\n})\n", "type Booleanish = boolean | \"true\" | \"false\"\n\nexport const dataAttr = (guard: boolean | undefined) => {\n return (guard ? \"\" : undefined) as Booleanish\n}\n\nexport const ariaAttr = (guard: boolean | undefined) => {\n return guard ? true : undefined\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n if (!el) return {} as Styles\n let style: Styles | undefined = styleCache.get(el)\n if (!style) {\n const win = el?.ownerDocument.defaultView ?? window\n style = win.getComputedStyle(el) as Styles\n styleCache.set(el, style)\n }\n return style\n}\n\nexport function copyVisualStyles(fromEl: HTMLElement | null, toEl: HTMLElement) {\n if (!fromEl) return\n const el = getComputedStyle(fromEl)\n // prettier-ignore\n const cssText = 'box-sizing:' + el.boxSizing +\n ';border-left:' + el.borderLeftWidth + ' solid red' +\n ';border-right:' + el.borderRightWidth + ' solid red' +\n ';font-family:' + el.fontFamily +\n ';font-feature-settings:' + el.fontFeatureSettings +\n ';font-kerning:' + el.fontKerning +\n ';font-size:' + el.fontSize +\n ';font-stretch:' + el.fontStretch +\n ';font-style:' + el.fontStyle +\n ';font-variant:' + el.fontVariant +\n ';font-variant-caps:' + el.fontVariantCaps +\n ';font-variant-ligatures:' + el.fontVariantLigatures +\n ';font-variant-numeric:' + el.fontVariantNumeric +\n ';font-weight:' + el.fontWeight +\n ';letter-spacing:' + el.letterSpacing +\n ';margin-left:' + el.marginLeft +\n ';margin-right:' + el.marginRight +\n ';padding-left:' + el.paddingLeft +\n ';padding-right:' + el.paddingRight +\n ';text-indent:' + el.textIndent +\n ';text-transform:' + el.textTransform\n\n toEl.style.cssText += cssText\n}\n", "export function nextTick(fn: VoidFunction) {\n const set = new Set<VoidFunction>()\n function raf(fn: VoidFunction) {\n const id = globalThis.requestAnimationFrame(fn)\n set.add(() => globalThis.cancelAnimationFrame(id))\n }\n raf(() => raf(fn))\n return function cleanup() {\n set.forEach(function (fn) {\n fn()\n })\n }\n}\n\nexport function raf(fn: VoidFunction) {\n const id = globalThis.requestAnimationFrame(fn)\n return function cleanup() {\n globalThis.cancelAnimationFrame(id)\n }\n}\n\nexport function forceReflow() {\n return document.body.offsetHeight\n}\n", "import { copyVisualStyles } from \"./computed-style\"\nimport { raf } from \"./next-tick\"\n\nfunction createGhostElement(doc: Document) {\n var el = doc.createElement(\"div\")\n el.id = \"ghost\"\n el.style.cssText =\n \"display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;\"\n doc.body.appendChild(el)\n return el\n}\n\nexport function autoResizeInput(input: HTMLInputElement | null) {\n if (!input) return\n const doc = input.ownerDocument ?? document\n const ghost = createGhostElement(doc)\n\n copyVisualStyles(input, ghost)\n\n function resize() {\n raf(() => {\n ghost.innerHTML = input!.value\n const rect = getComputedStyle(ghost)\n input?.style.setProperty(\"width\", rect.width)\n })\n }\n\n resize()\n\n input?.addEventListener(\"input\", resize)\n input?.addEventListener(\"change\", resize)\n\n return () => {\n doc.body.removeChild(ghost)\n input?.removeEventListener(\"input\", resize)\n input?.removeEventListener(\"change\", resize)\n }\n}\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: MouseEvent | PointerEvent | KeyboardEvent) =>\n v.ctrlKey || v.altKey || v.metaKey || v.shiftKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { noop } from \"@zag-js/utils\"\n\ntype El = HTMLElement | Document | VisualViewport | Window\ntype Handler = (event: Event) => void\ntype Group = Map<string, Set<Handler>>\ntype Option = boolean | AddEventListenerOptions\n\nconst listenerElements: Map<El, Group> = new Map()\nconst listenerCache: Map<El, Map<string, Handler>> = new Map()\n\n/**\n * The global event bus for managing event listeners attached to DOM elements.\n *\n * It's goal is to ensure that only one listener is attached to a DOM element for a given event,\n * regardless of the number of times `addEventListener` is called.\n */\n\nexport function globalEventBus(node: El | null, type: string, handler: Handler, options?: Option) {\n if (!node) return noop\n\n // unique identifier for the event listener\n const hash = JSON.stringify({ type, options })\n\n // Subscribe pattern\n\n const group = listenerElements.get(node)\n\n if (!listenerElements.has(node)) {\n // create group of listeners per hash\n const group: Group = new Map([[hash, new Set([handler])]])\n listenerElements.set(node, group)\n } else if (group?.has(hash)) {\n group?.get(hash)?.add(handler)\n } else {\n group?.set(hash, new Set([handler]))\n }\n\n // add the event listener to the node or register it in the cache\n function attach(node: El) {\n // Publish pattern\n function listener(event: Event) {\n const group = listenerElements.get(node)\n group?.get(hash)?.forEach((fn) => fn(event))\n }\n\n if (!listenerCache?.has(node)) {\n listenerCache.set(node, new Map([[hash, listener]]))\n node.addEventListener(type, listener, options)\n return\n }\n\n if (!listenerCache?.get(node)?.has(hash)) {\n listenerCache.get(node)?.set(hash, listener)\n node.addEventListener(type, listener, options)\n }\n }\n\n attach(node)\n\n return function remove() {\n if (!listenerElements.has(node)) return\n\n const group = listenerElements.get(node)\n group?.get(hash)?.delete(handler)\n\n if (group?.get(hash)?.size === 0) {\n const listener = listenerCache.get(node)?.get(hash)!\n node.removeEventListener(type, listener, options)\n group?.delete(hash)\n listenerCache.get(node)?.delete(hash)\n\n if (group?.size === 0) {\n listenerElements.delete(node)\n listenerCache.delete(node)\n }\n }\n }\n}\n", "import { globalEventBus } from \"./event-bus\"\nimport {\n AnyPointerEvent,\n DOMEventTarget,\n EventMap,\n PointerEventInfo,\n PointerNameMap,\n RefTarget,\n} from \"./listener.types\"\n\nconst t = (v: any) => Object.prototype.toString.call(v).slice(8, -1)\nconst isRef = (v: any): v is RefTarget => t(v) === \"Object\" && \"current\" in v\nconst runIfFn = (fn: any): HTMLElement | null => (t(fn) === \"Function\" ? fn() : fn)\nconst isTouchEvent = (v: Event): v is TouchEvent => t(v) === \"Object\" && !!(v as TouchEvent).touches\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function extractInfo<T extends AnyPointerEvent = AnyPointerEvent>(event: T, type: \"page\" | \"client\" = \"page\") {\n const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event\n return {\n point: {\n x: point[`${type}X`],\n y: point[`${type}Y`],\n },\n }\n}\n\nexport function addDomEvent<K extends keyof EventMap>(\n target: DOMEventTarget,\n event: K,\n listener: (event: EventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n) {\n const node = isRef(target) ? target.current : runIfFn(target)\n return globalEventBus(node, event, listener as any, options)\n}\n\nexport function addPointerEvent<K extends keyof EventMap>(\n target: DOMEventTarget,\n event: K,\n listener: (event: EventMap[K], info: PointerEventInfo) => void,\n options?: boolean | AddEventListenerOptions,\n) {\n const type = getEventName(event) ?? event\n return addDomEvent(target, type, wrapHandler(listener, event === \"pointerdown\"), options)\n}\n\nfunction wrapHandler<E extends EventMap[keyof EventMap]>(\n fn: (event: E, info: PointerEventInfo) => void,\n filter = false,\n) {\n const listener: EventListener = (event: any) => {\n fn(event, extractInfo(event))\n }\n return filter ? filterPrimaryPointer(listener) : listener\n}\n\nfunction filterPrimaryPointer(fn: EventListener): EventListener {\n return (event: Event) => {\n const win = ((event as UIEvent).view ?? window) as typeof window\n const isMouseEvent = event instanceof win.MouseEvent\n const isPrimary = !isMouseEvent || (isMouseEvent && (event as MouseEvent).button === 0)\n if (isPrimary) fn(event)\n }\n}\n\nexport function extractClientInfo(event: AnyPointerEvent) {\n return extractInfo(event, \"client\")\n}\n\nconst supportsPointerEvent = () => typeof window !== \"undefined\" && window.onpointerdown === null\nconst supportsTouchEvent = () => typeof window !== \"undefined\" && window.ontouchstart === null\nconst supportsMouseEvent = () => typeof window !== \"undefined\" && window.onmousedown === null\n\nconst mouseEventNames: PointerNameMap = {\n pointerdown: \"mousedown\",\n pointermove: \"mousemove\",\n pointerup: \"mouseup\",\n pointercancel: \"mousecancel\",\n pointerover: \"mouseover\",\n pointerout: \"mouseout\",\n pointerenter: \"mouseenter\",\n pointerleave: \"mouseleave\",\n}\n\nconst touchEventNames: PointerNameMap = {\n pointerdown: \"touchstart\",\n pointermove: \"touchmove\",\n pointerup: \"touchend\",\n pointercancel: \"touchcancel\",\n}\n\nexport function getEventName(evt: keyof EventMap): keyof EventMap {\n if (supportsPointerEvent()) return evt\n if (supportsTouchEvent()) return touchEventNames[evt]\n if (supportsMouseEvent()) return mouseEventNames[evt]\n return evt\n}\n", "import { isLeftClick, pipe } from \"@zag-js/utils\"\nimport { addDomEvent } from \"./listener\"\nimport { nextTick } from \"./next-tick\"\n\nlet changeCount = 0\nlet originalBodyPointerEvents: string\n\ntype PointerEventOptions = {\n disabled: boolean\n document?: Document\n}\n\nexport function preventBodyPointerEvents(el: HTMLElement | null, opts: Partial<PointerEventOptions> = {}) {\n const { disabled = false, document: docProp } = opts\n const doc: Document = docProp || document\n\n let isTouchOrPenPressed = false\n let isLeftClickPressed = false\n\n function listen() {\n const onPointerDown = (event: PointerEvent) => {\n const isMouse = event.pointerType === \"mouse\"\n isTouchOrPenPressed = !isMouse\n isLeftClickPressed = isMouse && isLeftClick(event)\n }\n\n const onPointerUp = () => {\n isTouchOrPenPressed = false\n isLeftClickPressed = false\n }\n\n // prettier-ignore\n return pipe(\n addDomEvent(doc, \"pointerdown\", onPointerDown),\n addDomEvent(doc,\"pointerup\", onPointerUp)\n )\n }\n\n function reset() {\n changeCount--\n if (changeCount === 0) {\n doc.body.style.pointerEvents = originalBodyPointerEvents\n }\n if (el) {\n el.style.pointerEvents = \"\"\n }\n }\n\n function apply() {\n if (disabled) return\n\n if (changeCount === 0) {\n originalBodyPointerEvents = doc.body.style.pointerEvents\n }\n\n doc.body.style.pointerEvents = \"none\"\n if (el) {\n el.style.pointerEvents = \"auto\"\n }\n\n changeCount++\n\n return function () {\n if (isTouchOrPenPressed) {\n addDomEvent(doc, \"click\", reset, { once: true })\n } else if (isLeftClickPressed) {\n addDomEvent(doc, \"pointerup\", reset, { once: true })\n } else {\n reset()\n }\n }\n }\n\n const cleanups: Array<VoidFunction | undefined> = []\n cleanups.push(apply())\n nextTick(() => {\n cleanups.push(listen())\n })\n\n return function () {\n cleanups.forEach((cleanup) => cleanup?.())\n }\n}\n", "import { isDom, isIos, noop, pipe } from \"@zag-js/utils\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { addDomEvent } from \"./listener\"\nimport { getScrollParent } from \"./scrollable\"\n\ninterface PreventScrollOptions {\n disabled?: boolean\n allowPinchZoom?: boolean\n document?: Document\n}\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\"checkbox\", \"radio\", \"range\", \"color\", \"file\", \"image\", \"button\", \"submit\", \"reset\"])\n\nexport function preventBodyScroll(opts?: PreventScrollOptions) {\n const { document: docProp, disabled = false, allowPinchZoom } = opts ?? {}\n\n const doc = docProp ?? document\n const win = doc?.defaultView ?? window\n\n const viewport = isDom() ? win.visualViewport : null\n const docEl = doc.documentElement\n\n function preventScrollStandard() {\n const fn = pipe(\n setStyle(docEl, \"paddingRight\", `${win.innerWidth - docEl.clientWidth}px`),\n setStyle(docEl, \"overflow\", \"hidden\"),\n )\n return () => fn?.()\n }\n\n function preventScrollMobileSafari() {\n let scrollable: HTMLElement | undefined\n let lastY = 0\n\n let onTouchStart = (e: TouchEvent) => {\n scrollable = getScrollParent(e.target as HTMLElement)\n\n if (scrollable === docEl && scrollable === doc.body) {\n return\n }\n lastY = e.changedTouches[0].pageY\n }\n\n let onTouchMove = (e: TouchEvent) => {\n if (e.touches.length === 2 && allowPinchZoom) return\n\n if (!scrollable || scrollable === docEl || scrollable === doc.body) {\n e.preventDefault()\n return\n }\n\n let y = e.changedTouches[0].pageY\n let scrollTop = scrollable.scrollTop\n let bottom = scrollable.scrollHeight - scrollable.clientHeight\n\n if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n e.preventDefault()\n }\n\n lastY = y\n }\n\n let onTouchEnd = (e: TouchEvent) => {\n let target = e.target as HTMLElement\n if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {\n e.preventDefault()\n target.style.transform = \"translateY(-2000px)\"\n target.focus()\n win.requestAnimationFrame(() => {\n target.style.transform = \"\"\n })\n }\n }\n\n let onFocus = (e: FocusEvent) => {\n let target = e.target as HTMLElement\n if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {\n target.style.transform = \"translateY(-2000px)\"\n win.requestAnimationFrame(() => {\n target.style.transform = \"\"\n if (!viewport) return\n\n if (viewport.height < win.innerHeight) {\n win.requestAnimationFrame(function () {\n scrollIntoView(target, { scrollMode: \"if-needed\" })\n })\n } else {\n const onResize = () => {\n scrollIntoView(target, { scrollMode: \"if-needed\" })\n }\n addDomEvent(viewport, \"resize\", onResize, { once: true })\n }\n })\n }\n }\n\n let onWindowScroll = () => {\n win.scrollTo(0, 0)\n }\n\n let scrollX = win.scrollX\n let scrollY = win.scrollY\n let restoreStyles = pipe(\n setStyle(docEl, \"paddingRight\", `${win.innerWidth - docEl.clientWidth}px`),\n setStyle(docEl, \"overflow\", \"hidden\"),\n setStyle(doc.body, \"marginTop\", `-${scrollY}px`),\n )\n\n win.scrollTo(0, 0)\n\n let removeEvents = pipe(\n addDomEvent(doc, \"touchstart\", onTouchStart, { passive: false, capture: true }),\n addDomEvent(doc, \"touchmove\", onTouchMove, { passive: false, capture: true }),\n addDomEvent(doc, \"touchend\", onTouchEnd, { passive: false, capture: true }),\n addDomEvent(doc, \"focus\", onFocus, true),\n addDomEvent(win, \"scroll\", onWindowScroll),\n )\n\n return () => {\n restoreStyles()\n removeEvents()\n win.scrollTo(scrollX, scrollY)\n }\n }\n\n if (disabled) return noop\n return isIos() ? preventScrollMobileSafari() : preventScrollStandard()\n}\n\nfunction setStyle(el: HTMLElement, key: string, value: string) {\n let cur = el.style[key]\n el.style[key] = value\n return () => {\n el.style[key] = cur\n }\n}\n\n// Backup lib: https://github.com/hanai/html-body-scroll-lock\n", "export function getOwnerDocument(el: HTMLElement | Window) {\n if (isWindow(el)) return el.document\n return el?.ownerDocument ?? document\n}\n\nexport function getOwnerWindow(el: HTMLElement) {\n return el?.ownerDocument.defaultView ?? window\n}\n\nexport function getDocumentElement(el: HTMLElement | Window): HTMLElement {\n return getOwnerDocument(el).documentElement\n}\n\nexport function getNodeName(node: HTMLElement | Window): string {\n return isWindow(node) ? \"\" : node ? node.localName || \"\" : \"\"\n}\n\nexport function getEventWindow(event: UIEvent) {\n if (event.view) return event.view\n let target = event.currentTarget\n if (target != null) return getOwnerWindow(target as HTMLElement)\n return window\n}\n\nexport function getParent(el: HTMLElement): HTMLElement {\n const doc = getOwnerDocument(el)\n if (getNodeName(el) === \"html\") return el\n return el.assignedSlot || el.parentElement || doc.documentElement\n}\n\ntype Node = HTMLElement | EventTarget | null\n\nexport function contains(parent: Node | undefined, child: Node) {\n if (!parent) return false\n return parent === child || (isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child))\n}\n\nexport function isHTMLElement(v: any): v is HTMLElement {\n return typeof v === \"object\" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === \"string\"\n}\n\nexport function isWindow(value: any): value is Window {\n return value?.toString() === \"[object Window]\"\n}\n\nexport const isDisabled = (el: HTMLElement | null): boolean => {\n return el?.getAttribute(\"disabled\") != null || !!el?.getAttribute(\"aria-disabled\") === true\n}\n\nexport function getNativeEvent<E>(\n event: E,\n): React.ChangeEvent<any> extends E ? InputEvent : E extends React.SyntheticEvent<any, infer T> ? T : never {\n return (event as any).nativeEvent ?? event\n}\n", "import { getComputedStyle } from \"./computed-style\"\nimport { getNodeName, getOwnerDocument, getOwnerWindow, getParent, isHTMLElement, isWindow } from \"./query\"\n\nexport function isScrollParent(el: HTMLElement): boolean {\n const { overflow, overflowX, overflowY } = getComputedStyle(el)\n return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX)\n}\n\nexport function getScrollParent(el: HTMLElement): HTMLElement {\n if ([\"html\", \"body\", \"#document\"].includes(getNodeName(el))) {\n return getOwnerDocument(el).body\n }\n\n if (isHTMLElement(el) && isScrollParent(el)) {\n return el\n }\n\n return getScrollParent(getParent(el))\n}\n\ntype Target = Array<VisualViewport | Window | HTMLElement>\n\nexport function getScrollParents(el: HTMLElement, list: Target = []): Target {\n const scrollParent = getScrollParent(el)\n const isBody = scrollParent === getOwnerDocument(el).body\n const win = getOwnerWindow(scrollParent)\n\n const target = isBody\n ? ([win] as Target).concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : [])\n : scrollParent\n\n const parents = list.concat(target)\n if (isBody) return parents\n\n return parents.concat(getScrollParents(getParent(<HTMLElement>target)))\n}\n\nexport function getScrollOffset(el: HTMLElement) {\n if (isWindow(el)) {\n return { scrollLeft: el.scrollX, scrollTop: el.scrollY }\n }\n\n return { scrollLeft: el.scrollLeft, scrollTop: el.scrollTop }\n}\n", "export const MAX_Z_INDEX = 2147483647\n", "import { getOwnerWindow } from \"./query\"\n\nfunction descriptor(el: HTMLElement, type: \"input\" | \"textarea\" = \"input\") {\n const win = getOwnerWindow(el)\n const _type = type === \"input\" ? \"HTMLInputElement\" : \"HTMLTextAreaElement\"\n const proto = win[_type].prototype\n return Object.getOwnPropertyDescriptor(proto, \"value\") ?? {}\n}\n\nexport function dispatchEvent(el: HTMLElement, name: string, options: CustomEventInit) {\n const win = getOwnerWindow(el)\n const evt = new win.CustomEvent(name, options)\n el.dispatchEvent(evt)\n return evt\n}\n\nexport function dispatchInputEvent(el: HTMLElement, value: string | number) {\n const win = getOwnerWindow(el)\n if (!(el instanceof win.HTMLInputElement)) return\n\n el.type = \"text\"\n el.hidden = true\n\n descriptor(el).set?.call(el, value)\n\n const evt = new win.Event(\"input\", { bubbles: true })\n el.dispatchEvent(evt)\n\n el.type = \"hidden\"\n el.hidden = false\n}\n\nexport function onElementValueChange(el: HTMLInputElement, fn?: (value: string) => void) {\n if (!fn) return\n\n const { get, set } = descriptor(el)\n\n let run = true\n\n Object.defineProperty(el, \"value\", {\n get() {\n return get?.call(this)\n },\n set(value: string) {\n if (run) fn(value)\n return set?.call(this, value)\n },\n })\n\n return function () {\n run = false\n }\n}\n", "/**\n * Determine if the blur event within an element is valid\n */\nexport function validateBlur(event: Event, opts: Options) {\n const exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude]\n const relatedTarget = (event.relatedTarget ?? opts.fallback) as HTMLElement\n return exclude.every((el) => !el?.contains(relatedTarget))\n}\n\ntype MaybeArray<T> = T | T[]\n\ntype Options = {\n exclude: MaybeArray<HTMLElement | null>\n fallback?: HTMLElement | null\n}\n\ntype Event = Pick<FocusEvent, \"relatedTarget\">\n", "import { getComputedStyle } from \"./computed-style\"\nimport { isDisabled, isHTMLElement } from \"./query\"\n\nexport const focusableSelector = /*#__PURE__*/ [\n \"input:not([disabled]):not([type=hidden])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"embed\",\n \"iframe\",\n \"object\",\n \"a[href]\",\n \"area[href]\",\n \"[tabindex]\",\n \"audio[controls]\",\n \"video[controls]\",\n \"*[tabindex]:not([aria-disabled])\",\n \"[contenteditable]:not([contenteditable=false])\",\n \"details > summary:first-of-type\",\n].join(\",\")\n\nexport function isHidden(el: HTMLElement | null, until?: HTMLElement) {\n const style = getComputedStyle(el)\n if (!el || style.getPropertyValue(\"visibility\") === \"hidden\") return true\n while (el) {\n if (until != null && el === until) return false\n if (style.getPropertyValue(\"display\") === \"none\") return true\n el = el.parentElement\n }\n return false\n}\n\n/**\n * Returns the focusable elements within the element\n */\nexport const getFocusables = (el: HTMLElement | Document | null, includeContainer = false) => {\n if (!el) return []\n let els = Array.from(el.querySelectorAll<HTMLElement>(focusableSelector))\n if (includeContainer && isHTMLElement(el)) {\n els.unshift(el)\n }\n return els.filter((el) => isFocusable(el) && !isHidden(el))\n}\n\n/**\n * Whether this element is focusable\n */\nexport const isFocusable = (el: HTMLElement | null) => {\n if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) return false\n return el?.matches(focusableSelector)\n}\n\n/**\n * Returns the tabbable elements within the element\n */\nexport const getTabbables = (el: HTMLElement | Document, includeContainer = false) => {\n return getFocusables(el, includeContainer).filter(isTabbable)\n}\n\n/**\n * Whether this element is tabbable\n */\nexport const isTabbable = (el: HTMLElement | null) => {\n return isFocusable(el) && !isDisabled(el) && !isHidden(el)\n}\n", "import type { KeyboardEvent } from \"react\"\n\ntype EventKey =\n | \"ArrowDown\"\n | \"ArrowUp\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"Space\"\n | \"Enter\"\n | \"Comma\"\n | \"Escape\"\n | \"Backspace\"\n | \"Delete\"\n | \"Home\"\n | \"End\"\n | \"Tab\"\n | \"PageUp\"\n | \"PageDown\"\n | (string & {})\n\nexport type EventKeyMap = Partial<Record<EventKey, (event: React.KeyboardEvent) => void>>\n\nconst rtlKeyMap = {\n ArrowLeft: \"ArrowRight\",\n ArrowRight: \"ArrowLeft\",\n Home: \"End\",\n End: \"Home\",\n}\n\nconst sameKeyMap = {\n Up: \"ArrowUp\",\n Down: \"ArrowDown\",\n Esc: \"Escape\",\n \" \": \"Space\",\n \",\": \"Comma\",\n Left: \"ArrowLeft\",\n Right: \"ArrowRight\",\n}\n\ntype EventKeyOptions = {\n dir?: \"ltr\" | \"rtl\"\n orientation?: \"horizontal\" | \"vertical\"\n}\n\n/**\n * Determine the event key based on text direction.\n */\nexport function getEventKey(event: KeyboardEvent, options: EventKeyOptions = {}) {\n const { dir = \"ltr\", orientation = \"horizontal\" } = options\n\n let { key } = event\n key = sameKeyMap[key] ?? key // normalize key\n\n const isRtl = dir === \"rtl\" && orientation === \"horizontal\"\n\n if (isRtl && key in rtlKeyMap) {\n key = rtlKeyMap[key]\n }\n\n return key\n}\n\nconst PAGE_KEYS = new Set([\"PageUp\", \"PageDown\"])\nconst ARROW_KEYS = new Set([\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"])\n\n/**\n * Determine the step factor for keyboard events\n */\nexport function getEventStep(event: KeyboardEvent) {\n if (event.ctrlKey || event.metaKey) {\n return 0.1\n } else {\n const isPageKey = PAGE_KEYS.has(event.key)\n const isSkipKey = isPageKey || (event.shiftKey && ARROW_KEYS.has(event.key))\n return isSkipKey ? 10 : 1\n }\n}\n", "export const visuallyHiddenStyle = {\n border: \"0\",\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0\",\n position: \"absolute\",\n width: \"1px\",\n whiteSpace: \"nowrap\",\n wordWrap: \"normal\",\n} as const\n\nexport function setVisuallyHidden(el: HTMLElement) {\n Object.assign(el.style, visuallyHiddenStyle)\n}\n", "import { setVisuallyHidden } from \"./visually-hidden\"\n\nexport type LiveRegionOptions = {\n level: \"polite\" | \"assertive\"\n doc?: Document\n root?: HTMLElement | null\n delay?: number\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n const { level = \"polite\", doc: ownerDocument, root, delay: rootDelay = 0 } = opts\n\n const doc = ownerDocument ?? document\n const win = doc.defaultView ?? window\n\n const parent = root ?? doc.body\n\n function announce(msg: string, delay?: number) {\n const oldRegion = doc.getElementById(\"__live-region__\")\n\n // remove old region\n if (!!oldRegion) {\n parent.removeChild(oldRegion)\n }\n\n // Did an override level get set?\n delay = delay ?? rootDelay\n\n // create fresh region\n const region = doc.createElement(\"span\")\n region.id = \"__live-region__\"\n\n // Determine redundant role\n var role = level !== \"assertive\" ? \"status\" : \"alert\"\n\n // add role and attributes\n region.setAttribute(\"aria-live\", level)\n region.setAttribute(\"role\", role)\n\n // hide live region\n setVisuallyHidden(region)\n\n parent.appendChild(region)\n\n // populate region to trigger it\n win.setTimeout(() => {\n region!.textContent = msg\n }, delay)\n }\n\n function destroy() {\n const oldRegion = doc.getElementById(\"__live-region__\")\n if (oldRegion) {\n parent.removeChild(oldRegion)\n }\n }\n\n return { announce, destroy }\n}\n", "import { noop } from \"@zag-js/utils\"\n\ntype Callback = (v: MutationRecord) => void\n\nexport function observeAttributes(node: Element | null, attributes: string | string[], fn: Callback) {\n if (!node) return noop\n const attrs = Array.isArray(attributes) ? attributes : [attributes]\n const win = node.ownerDocument.defaultView || window\n const obs = new win.MutationObserver((changes) => {\n for (const change of changes) {\n if (change.type === \"attributes\" && change.attributeName && attrs.includes(change.attributeName)) {\n fn(change)\n }\n }\n })\n\n obs.observe(node, { attributes: true, attributeFilter: attrs })\n\n return () => obs.disconnect()\n}\n\nexport function observeChildren(node: Element | null, fn: Callback, subtree = false) {\n if (!node) return noop\n const win = node.ownerDocument.defaultView || window\n const obs = new win.MutationObserver((changes) => {\n for (const change of changes) {\n if (change.type === \"childList\") {\n fn(change)\n }\n }\n })\n\n obs.observe(node, { childList: true, subtree })\n\n return () => obs.disconnect()\n}\n", "type Root = Document | Element | null | undefined\n\nexport function queryAll<T extends HTMLElement = HTMLElement>(root: Root, selector: string) {\n return Array.from(root?.querySelectorAll<T>(selector) ?? [])\n}\n\nexport function query<T extends HTMLElement = HTMLElement>(root: Root, selector: string) {\n return root?.querySelector<T>(selector)\n}\n\nexport function itemById<T extends HTMLElement>(v: T[], id: string) {\n return v.find((node) => node.id === id)\n}\n\nexport function indexOfId<T extends HTMLElement>(v: T[], id: string) {\n const item = itemById(v, id)\n return item ? v.indexOf(item) : -1\n}\n\nexport function nextById<T extends HTMLElement>(v: T[], id: string, loop = true) {\n let idx = indexOfId(v, id)\n idx = loop ? (idx + 1) % v.length : Math.min(idx + 1, v.length - 1)\n return v[idx]\n}\n\nexport function prevById<T extends HTMLElement>(v: T[], id: string, loop = true) {\n let idx = indexOfId(v, id)\n if (idx === -1) return loop ? v[v.length - 1] : null\n idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1)\n return v[idx]\n}\n\nexport function findByText<T extends HTMLElement>(v: T[], text: string, currentId?: string | null) {\n const filtered = v.filter((item) => {\n const str = item.dataset.valuetext ?? item.textContent\n return !!str?.toLowerCase().startsWith(text.toLowerCase())\n })\n return currentId ? nextById(filtered, currentId) : null\n}\n\nexport function sortByTreeOrder<T extends HTMLElement>(v: T[]) {\n return v.sort((a, b) => (a.compareDocumentPosition(b) & 2 ? 1 : -1))\n}\n", "// Credits: https://github.com/adobe/react-spectrum/blob/e81cfec20056338c7987c513826dc45df32f3db4/packages/%40react-aria/interactions/src/textSelection.ts\nimport { isIos } from \"@zag-js/utils\"\nimport { nextTick } from \"./next-tick\"\n\ntype State = \"default\" | \"disabled\" | \"restoring\"\n\nlet state: State = \"default\"\nlet savedUserSelect = \"\"\nlet modifiedElementMap = new WeakMap<HTMLElement, string>()\n\nexport function disableTextSelection({ target, doc }: { target?: HTMLElement; doc?: Document } = {}) {\n const _document = doc ?? document\n\n if (isIos()) {\n if (state === \"default\") {\n savedUserSelect = _document.documentElement.style.webkitUserSelect\n _document.documentElement.style.webkitUserSelect = \"none\"\n }\n\n state = \"disabled\"\n } else if (target) {\n modifiedElementMap.set(target, target.style.userSelect)\n target.style.userSelect = \"none\"\n }\n\n return () => restoreTextSelection({ target, doc: _document })\n}\n\nexport function restoreTextSelection({ target, doc }: { target?: HTMLElement; doc?: Document } = {}) {\n const _document = doc ?? document\n\n if (isIos()) {\n if (state !== \"disabled\") return\n state = \"restoring\"\n\n setTimeout(() => {\n nextTick(() => {\n if (state === \"restoring\") {\n if (_document.documentElement.style.webkitUserSelect === \"none\") {\n _document.documentElement.style.webkitUserSelect = savedUserSelect || \"\"\n }\n\n savedUserSelect = \"\"\n state = \"default\"\n }\n })\n }, 300)\n } else {\n if (target && modifiedElementMap.has(target)) {\n let targetOldUserSelect = modifiedElementMap.get(target)\n\n if (target.style.userSelect === \"none\") {\n target.style.userSelect = targetOldUserSelect ?? \"\"\n }\n\n if (target.getAttribute(\"style\") === \"\") {\n target.removeAttribute(\"style\")\n }\n modifiedElementMap.delete(target)\n }\n }\n}\n", "import { isLeftClick, isMouseEvent, pipe } from \"@zag-js/utils\"\nimport { addDomEvent, addPointerEvent } from \"./listener\"\nimport type { AnyPointerEvent, EventListenerWithPointInfo as Listener, PointerEventInfo } from \"./listener.types\"\nimport { disableTextSelection } from \"./text-selection\"\n\nexport function trackPointerDown(doc: Document, onPointerDown: (el: HTMLElement) => void) {\n const win = doc.defaultView ?? window\n const fn = (event: PointerEvent) => {\n if (event.target instanceof win.HTMLElement) {\n onPointerDown(event.target)\n }\n }\n return addDomEvent(doc, \"pointerdown\", fn)\n}\n\ntype TrackPointerMoveOptions = {\n ctx: { doc?: Document; threshold?: number }\n onPointerUp: VoidFunction\n onPointerMove: (info: PointerEventInfo, event: AnyPointerEvent) => void\n}\n\nexport function trackPointerMove(opts: TrackPointerMoveOptions) {\n const { onPointerMove, onPointerUp, ctx } = opts\n const { doc = document, threshold = 5 } = ctx\n\n const handlePointerMove: Listener = (event, info) => {\n const { point: p } = info\n const distance = Math.sqrt(p.x ** 2 + p.y ** 2)\n if (distance < threshold) return\n\n // Because Safari doesn't trigger mouseup events when it's above a `<select>`\n if (isMouseEvent(event) && isLeftClick(event)) {\n onPointerUp()\n return\n }\n\n onPointerMove(info, event)\n }\n\n return pipe(\n addPointerEvent(doc, \"pointermove\", handlePointerMove, false),\n addPointerEvent(doc, \"pointerup\", onPointerUp, false),\n addPointerEvent(doc, \"pointercancel\", onPointerUp, false),\n addPointerEvent(doc, \"contextmenu\", onPointerUp, false),\n disableTextSelection({ doc }),\n )\n}\n", "type PointerLockHandlers = {\n onPointerLock?: VoidFunction\n onPointerUnlock?: VoidFunction\n}\n\nexport function addPointerlockChangeListener(doc: Document, fn: VoidFunction) {\n doc.addEventListener(\"webkitpointerlockchange\", fn, false)\n doc.addEventListener(\"mozpointerlockchange\", fn, false)\n doc.addEventListener(\"pointerlockchange\", fn, false)\n return function cleaup() {\n doc.removeEventListener(\"mozpointerlockchange\", fn, false)\n doc.removeEventListener(\"pointerlockchange\", fn, false)\n }\n}\n\nexport function addPointerlockErrorListener(doc: Document, fn: (e: Event) => void) {\n doc.addEventListener(\"webkitpointerlockerror\", fn, false)\n doc.addEventListener(\"mozpointerlockerror\", fn, false)\n doc.addEventListener(\"pointerlockerror\", fn, false)\n return function cleanup() {\n doc.removeEventListener(\"webkitpointerlockerror\", fn, false)\n doc.removeEventListener(\"mozpointerlockerror\", fn, false)\n doc.removeEventListener(\"pointerlockerror\", fn, false)\n }\n}\n\nfunction getPointerlockFunc(el: HTMLElement) {\n return el.requestPointerLock || (el as any).mozRequestPointerLock || (el as any).webkitRequestPointerLock\n}\n\nfunction getRemovePointerlockFunc(doc: Document) {\n return doc.exitPointerLock || (doc as any).mozExitPointerLock || (doc as any).webkitExitPointerLock\n}\n\nexport function getPointerlockElement(doc: Document) {\n return doc.pointerLockElement || (doc as any).mozPointerLockElement || (doc as any).webkitPointerLockElement\n}\n\nexport function requestPointerLock(doc: Document, handlers: PointerLockHandlers = {}) {\n const { onPointerLock, onPointerUnlock } = handlers\n const body = doc.body\n\n function isSupported() {\n return \"pointerLockElement\" in doc || \"mozPointerLockElement\" in doc || \"webkitPointerLockElement\" in doc\n }\n\n function hasLockElement() {\n return !!doc.pointerLockElement\n }\n\n function onPointerChange() {\n if (hasLockElement()) onPointerLock?.()\n else onPointerUnlock?.()\n }\n\n function onPointerError(event: Event) {\n const isLocked = hasLockElement()\n if (isLocked) onPointerUnlock?.()\n console.error(\"PointerLock error occured:\", event)\n exit()\n }\n\n function exit() {\n doc.exitPointerLock = getRemovePointerlockFunc(doc)\n doc.exitPointerLock()\n }\n\n const cleanups: Set<Function> = new Set()\n\n function addEventListeners() {\n cleanups.add(addPointerlockChangeListener(doc, onPointerChange))\n cleanups.add(addPointerlockErrorListener(doc, onPointerError))\n }\n\n function dispose() {\n if (!isSupported()) return\n cleanups.forEach((fn) => fn())\n cleanups.clear()\n exit()\n }\n\n function setup() {\n if (!isSupported()) return\n body.requestPointerLock = getPointerlockFunc(body)\n body.requestPointerLock()\n addEventListeners()\n }\n\n setup()\n return dispose\n}\n", "// Credit goes to the radix-ui team for this utility:\n// https://github.com/radix-ui/primitives/blob/main/packages/core/rect/src/observeElementRect.ts\n\ntype Fn = (rect: DOMRect) => void\ntype ObservedData = { rect: DOMRect; callbacks: Fn[] }\nexport type Measurable = { getBoundingClientRect(): DOMRect }\n\nconst observedElements: Map<Measurable, ObservedData> = new Map()\n\nexport function observeElementRect(el: Measurable, fn: Fn) {\n const data = observedElements.get(el)\n\n if (!data) {\n observedElements.set(el, { rect: {} as DOMRect, callbacks: [fn] })\n\n if (observedElements.size === 1) {\n rafId = requestAnimationFrame(runLoop)\n }\n } else {\n data.callbacks.push(fn)\n fn(el.getBoundingClientRect())\n }\n\n return function unobserve() {\n const data = observedElements.get(el)\n if (!data) return\n\n const index = data.callbacks.indexOf(fn)\n if (index > -1) {\n data.callbacks.splice(index, 1)\n }\n\n if (data.callbacks.length === 0) {\n observedElements.delete(el)\n\n if (observedElements.size === 0) {\n cancelAnimationFrame(rafId)\n }\n }\n }\n}\n\nlet rafId: number\n\nfunction runLoop() {\n const changedRectsData: Array<ObservedData> = []\n\n observedElements.forEach((data, element) => {\n const newRect = element.getBoundingClientRect()\n\n if (!isEqual(data.rect, newRect)) {\n data.rect = newRect\n changedRectsData.push(data)\n }\n })\n\n changedRectsData.forEach((data) => {\n data.callbacks.forEach((callback) => callback(data.rect))\n })\n\n rafId = requestAnimationFrame(runLoop)\n}\n\nfunction isEqual(rect1: DOMRect, rect2: DOMRect) {\n return (\n rect1.width === rect2.width &&\n rect1.height === rect2.height &&\n rect1.top === rect2.top &&\n rect1.right === rect2.right &&\n rect1.bottom === rect2.bottom &&\n rect1.left === rect2.left\n )\n}\n", "import { cast } from \"@zag-js/utils\"\nimport { addDomEvent } from \"./listener\"\n\nexport function trackDocumentVisibility(_doc: Document, callback: (hidden: boolean) => void) {\n const doc = cast(_doc) as Document & { msHidden?: boolean; webkitHidden?: boolean }\n return addDomEvent(doc, \"visibilitychange\", () => {\n const hidden = doc.hidden || doc.msHidden || doc.webkitHidden\n callback(!!hidden)\n })\n}\n", "export function waitUntil(predicate: () => boolean) {\n if (predicate()) return Promise.resolve(true)\n return new Promise((resolve) => {\n const id = globalThis.setInterval(function () {\n if (predicate()) {\n globalThis.clearInterval(id)\n resolve(true)\n }\n }, 0)\n })\n}\n\nexport function waitForEvent(el: HTMLElement, eventName: string) {\n return new Promise<void>((resolve) => {\n function done(event: Event) {\n if (event.target === el) {\n el.removeEventListener(eventName, done)\n resolve()\n }\n }\n\n el.addEventListener(eventName, done)\n })\n}\n", "import { createMachine, guards } from \"@zag-js/core\"\nimport { trackDocumentVisibility } from \"@zag-js/dom-utils\"\nimport { dom } from \"./toast.dom\"\nimport { MachineContext, MachineState, Options } from \"./toast.types\"\nimport { getToastDuration } from \"./toast.utils\"\n\nconst { not, and, or } = guards\n\nexport function createToastMachine(options: Options = {}) {\n const { type = \"info\", duration, id = \"toast\", placement = \"bottom\", removeDelay = 500, ...rest } = options\n const __duration = getToastDuration(duration, type)\n\n return createMachine<MachineContext, MachineState>(\n {\n id,\n entry: \"invokeOnOpen\",\n initial: type === \"loading\" ? \"persist\" : \"active\",\n context: {\n id,\n type,\n remaining: __duration,\n duration: __duration,\n removeDelay,\n createdAt: Date.now(),\n placement,\n ...rest,\n },\n\n on: {\n UPDATE: [\n {\n guard: and(\"hasTypeChanged\", \"isChangingToLoading\"),\n target: \"persist\",\n actions: [\"setContext\", \"invokeOnUpdate\"],\n },\n {\n guard: or(\"hasDurationChanged\", \"hasTypeChanged\"),\n target: \"active:temp\",\n actions: [\"setContext\", \"invokeOnUpdate\"],\n },\n {\n actions: [\"setContext\", \"invokeOnUpdate\"],\n },\n ],\n },\n\n states: {\n \"active:temp\": {\n tags: [\"visible\", \"updating\"],\n after: {\n 0: \"active\",\n },\n },\n\n persist: {\n tags: [\"visible\", \"paused\"],\n activities: \"trackDocumentVisibility\",\n on: {\n RESUME: {\n guard: not(\"isLoadingType\"),\n target: \"active\",\n actions: [\"setCreatedAt\"],\n },\n DISMISS: \"dismissing\",\n },\n },\n\n active: {\n tags: [\"visible\"],\n activities: \"trackDocumentVisibility\",\n after: {\n VISIBLE_DURATION: \"dismissing\",\n },\n on: {\n DISMISS: \"dismissing\",\n PAUSE: {\n target: \"persist\",\n actions: \"setRemainingDuration\",\n },\n },\n },\n\n dismissing: {\n entry: \"invokeOnClosing\",\n after: {\n REMOVE_DELAY: {\n target: \"inactive\",\n actions: \"notifyParentToRemove\",\n },\n },\n },\n\n inactive: {\n entry: \"invokeOnClose\",\n type: \"final\",\n },\n },\n },\n {\n activities: {\n trackDocumentVisibility(ctx, _evt, { send }) {\n if (!ctx.pauseOnPageIdle) return\n return trackDocumentVisibility(dom.getDoc(ctx), function (hidden) {\n send(hidden ? \"PAUSE\" : \"RESUME\")\n })\n },\n },\n\n guards: {\n isChangingToLoading: (_, evt) => evt.toast?.type === \"loading\",\n isLoadingType: (ctx) => ctx.type === \"loading\",\n hasTypeChanged: (ctx, evt) => evt.toast?.type !== ctx.type,\n hasDurationChanged: (ctx, evt) => evt.toast?.duration !== ctx.duration,\n },\n\n delays: {\n VISIBLE_DURATION: (ctx) => ctx.remaining,\n REMOVE_DELAY: (ctx) => ctx.removeDelay,\n },\n\n actions: {\n setRemainingDuration(ctx) {\n ctx.remaining -= Date.now() - ctx.createdAt\n },\n setCreatedAt(ctx) {\n ctx.createdAt = Date.now()\n },\n notifyParentToRemove(_ctx, _evt, { self }) {\n self.sendParent({ type: \"REMOVE_TOAST\", id: self.id })\n },\n invokeOnClosing(ctx) {\n ctx.onClosing?.()\n },\n invokeOnClose(ctx) {\n ctx.onClose?.()\n },\n invokeOnOpen(ctx) {\n ctx.onOpen?.()\n },\n invokeOnUpdate(ctx) {\n ctx.onUpdate?.()\n },\n setContext(ctx, evt) {\n const { duration, type } = evt.toast\n const time = getToastDuration(duration, type)\n Object.assign(ctx, { ...evt.toast, duration: time, remaining: time })\n },\n },\n },\n )\n}\n", "import { StateMachine as S } from \"@zag-js/core\"\nimport { dataAttr } from \"@zag-js/dom-utils\"\nimport { normalizeProp, PropTypes, ReactPropTypes } from \"@zag-js/types\"\nimport { dom } from \"./toast.dom\"\nimport { MachineContext, MachineState } from \"./toast.types\"\n\nexport function connect<T extends PropTypes = ReactPropTypes>(\n state: S.State<MachineContext, MachineState>,\n send: (event: S.Event<S.AnyEventObject>) => void,\n normalize = normalizeProp,\n) {\n const isVisible = state.hasTag(\"visible\")\n const isPaused = state.hasTag(\"paused\")\n const isUpdating = state.hasTag(\"updating\")\n\n const isRtl = state.context.dir === \"rtl\"\n const type = state.context.type\n\n const pauseOnInteraction = state.context.pauseOnInteraction\n const placement = state.context.placement\n\n return {\n type: state.context.type,\n title: state.context.title,\n placement,\n isVisible,\n isPaused,\n pause() {\n send(\"PAUSE\")\n },\n resume() {\n send(\"RESUME\")\n },\n dismiss() {\n send(\"DISMISS\")\n },\n\n rootProps: normalize.element<T>({\n \"data-part\": \"root\",\n dir: state.context.dir,\n id: dom.getContainerId(state.context),\n \"data-open\": dataAttr(isVisible),\n \"data-type\": state.context.type,\n \"data-placement\": placement,\n role: \"status\",\n \"aria-atomic\": \"true\",\n tabIndex: 0,\n style: {\n position: \"relative\",\n pointerEvents: \"auto\",\n margin: \"calc(var(--toast-gutter) / 2)\",\n \"--remove-delay\": `${state.context.removeDelay}ms`,\n \"--duration\": `${state.context.duration}ms`,\n },\n onKeyDown(event) {\n if (event.key == \"Escape\") {\n send(\"DISMISS\")\n event.preventDefault()\n event.stopPropagation()\n }\n },\n onFocus() {\n if (pauseOnInteraction) {\n send(\"PAUSE\")\n }\n },\n onBlur() {\n if (pauseOnInteraction) {\n send(\"RESUME\")\n }\n },\n onPointerEnter() {\n if (pauseOnInteraction) {\n send(\"PAUSE\")\n }\n },\n onPointerLeave() {\n if (pauseOnInteraction) {\n send(\"RESUME\")\n }\n },\n }),\n\n progressbarProps: normalize.element<T>({\n \"data-part\": \"progressbar\",\n \"data-type\": state.context.type,\n style: {\n opacity: isVisible ? 1 : 0,\n transformOrigin: isRtl ? \"right\" : \"left\",\n animationName: isUpdating || type === \"loading\" ? \"none\" : undefined,\n animationPlayState: isPaused ? \"paused\" : \"running\",\n animationDuration: `${state.context.duration}ms`,\n animationFillMode: isUpdating ? undefined : \"forwards\",\n },\n }),\n\n titleProps: normalize.element<T>({\n \"data-part\": \"title\",\n id: dom.getTitleId(state.context),\n }),\n\n closeButtonProps: normalize.button<T>({\n id: dom.getCloseButtonId(state.context),\n \"data-part\": \"close-button\",\n type: \"button\",\n \"aria-label\": \"Dismiss notification\",\n onClick() {\n send(\"DISMISS\")\n },\n }),\n\n render() {\n return state.context.render?.({\n id: state.context.id,\n type: state.context.type,\n duration: state.context.duration,\n title: state.context.title,\n placement: state.context.placement,\n description: state.context.description,\n dismiss() {\n send(\"DISMISS\")\n },\n })\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "ugCAAA,4EEAO,GAAM,GAAU,CACrB,KACG,IAC+E,CAClF,GAAM,GAAM,MAAO,IAAM,WAAa,EAAE,GAAG,GAAK,EAChD,MAAO,IAAA,KAAA,EAAO,QALT,GAyBM,IAAsB,KAAM,CACvC,GAAI,GAAK,EACT,MAAO,IACL,KACO,EAAG,SAAS,SC7BvB,GAIa,GAAQ,IAAS,MAAO,SAAW,YCFzC,cAAiB,EAAgB,CACtC,GAAM,GAAI,EAAE,SAAW,EAAI,EAAE,GAAK,EAAE,GAC9B,EAAI,EAAE,SAAW,EAAI,EAAE,GAAK,GCJpC,MAA6C,wBCuEtC,YAA0B,EAA2C,CAC1E,MAAO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EAAY,EAAI,EACzB,gBAAiB,EAAQ,QAAU,OACnC,cAAe,GAAc,IAAS,UAAY,OAAS,OAC3D,mBAAoB,EAAW,SAAW,UAC1C,kBAAmB,GAAG,EAAM,QAAQ,aACpC,kBAAmB,EAAa,OAAY,cAIhD,WAAY,EAAU,QAAW,CAC/B,YAAa,QACb,GAAI,EAAI,WAAW,EAAM,WAG3B,iBAAkB,EAAU,OAAU,CACpC,GAAI,EAAI,iBAAiB,EAAM,SAC/B,YAAa,eACb,KAAM,SACN,aAAc,uBACd,SAAU,CACR,EAAK,cAIT,QAAS,CA/Gb,QAgHM,MAAO,QAAM,SAAQ,SAAd,qBAAuB,CAC5B,GAAI,EAAM,QAAQ,GAClB,KAAM,EAAM,QAAQ,KACpB,SAAU,EAAM,QAAQ,SACxB,MAAO,EAAM,QAAQ,MACrB,UAAW,EAAM,QAAQ,UACzB,YAAa,EAAM,QAAQ,YAC3B,SAAU,CACR,EAAK,gBzC/GR,GAAM,IAAQ,CACnB,QAAS,EACT,QAAS,GAGJ,aAAe,CACpB,GAAI,CAAC,IACH,EAAK,oDAEL,OAAO",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var G=Object.defineProperty,j=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var L=(t,e,n)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,f=(t,e)=>{for(var n in e||(e={}))A.call(e,n)&&L(t,n,e[n]);if(b)for(var n of b(e))M.call(e,n)&&L(t,n,e[n]);return t},g=(t,e)=>j(t,q(e));var k=(t,e)=>{var n={};for(var r in t)A.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&b)for(var r of b(t))e.indexOf(r)<0&&M.call(t,r)&&(n[r]=t[r]);return n};var w=(t,...e)=>{let n=typeof t=="function"?t(...e):t;return n!=null?n:void 0};var lt=(()=>{let t=0;return()=>(t++,t.toString(36))})();var I=()=>typeof window!="undefined";function C(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}import{subscribe as W}from"@zag-js/core";function H(t){return{button:t,label:t,input:t,output:t,element:t}}var E=H(t=>t);var d={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getGroupId:t=>`toast-group--${t}`,getContainerId:t=>`toast--${t.id}`,getTitleId:t=>`toast-title--${t.id}`,getCloseButtonId:t=>`toast-close-button--${t.id}`,getPortalId:t=>`toast-portal--${t.uid}`,getPortalEl:t=>d.getDoc(t).getElementById(d.getPortalId(t)),createPortalEl:t=>{let e=d.getPortalEl(t);if(e)return e;let n=d.getDoc(t).createElement("toast-portal");return n.id=d.getPortalId(t),n}};function O(t){let e={};for(let n of t){let r=n.state.context.placement;e[r]||(e[r]=[]),e[r].push(n)}return e}var K={info:5e3,error:5e3,success:2e3,loading:1/0,custom:5e3};function S(t,e){return t!=null?t:K[e]}function D(t,e){let n=t.offsets,r=typeof n=="string"?{left:n,right:n,bottom:n,top:n}:n,o=t.dir==="rtl",a=e.replace("-start",o?"-right":"-left").replace("-end",o?"-left":"-right"),l=a.includes("right"),m=a.includes("left"),c={position:"fixed",pointerEvents:t.count>0?void 0:"none",display:"flex",flexDirection:"column","--toast-gutter":t.gutter,zIndex:t.zIndex},i="center";if(l&&(i="flex-end"),m&&(i="flex-start"),c.alignItems=i,a.includes("top")){let s=r.top;c.top=`calc(env(safe-area-inset-top, 0px) + ${s})`}if(a.includes("bottom")){let s=r.bottom;c.bottom=`calc(env(safe-area-inset-bottom, 0px) + ${s})`}if(!a.includes("left")){let s=r.right;c.right=`calc(env(safe-area-inset-right, 0px) + ${s})`}if(!a.includes("right")){let s=r.left;c.left=`calc(env(safe-area-inset-left, 0px) + ${s})`}return c}var x={};function _(t,e,n=E){let r={count:t.context.count,toasts:t.context.toasts,toastsByPlacement:O(t.context.toasts),isVisible(o){return t.context.toasts.length?!!t.context.toasts.find(a=>a.id==o):!1},create(o){let a="toast-"+Math.random().toString(36).substring(2,9),l=o.id?o.id:a;if(!r.isVisible(l))return e({type:"ADD_TOAST",toast:g(f({},o),{id:l})}),l},upsert(o){let{id:a}=o;return(a?r.isVisible(a):!1)&&a!=null?r.update(a,o):r.create(o)},dismiss(o){o==null?e("DISMISS_ALL"):r.isVisible(o)&&e({type:"DISMISS_TOAST",id:o})},remove(o){o==null?e("REMOVE_ALL"):r.isVisible(o)&&e({type:"REMOVE_TOAST",id:o})},dismissByPlacement(o){let a=r.toastsByPlacement[o];a&&a.forEach(l=>r.dismiss(l.id))},update(o,a){if(!!r.isVisible(o))return e({type:"UPDATE_TOAST",id:o,toast:a}),o},loading(o){return o.type="loading",r.upsert(o)},success(o){return o.type="success",r.upsert(o)},error(o){return o.type="error",r.upsert(o)},promise(o,a,l={}){let m=r.loading(g(f(f({},l),l==null?void 0:l.loading),{type:"loading",title:a.loading}));return o.then(c=>{let i=w(a.loading,c);r.success(g(f(f({},l),l==null?void 0:l.success),{id:m,title:i}))}).catch(c=>{let i=w(a.error,c);r.error(g(f(f({},l),l==null?void 0:l.error),{id:m,title:i}))}),o},pause(o){o==null?e("PAUSE_ALL"):r.isVisible(o)&&e({type:"PAUSE_TOAST",id:o})},resume(o){o==null?e("RESUME_ALL"):r.isVisible(o)&&e({type:"RESUME_TOAST",id:o})},getGroupProps(o){let{placement:a,label:l="Notifications"}=o;return n.element({tabIndex:-1,"aria-label":l,id:d.getGroupId(a),"data-placement":a,"aria-live":"polite",role:"region",style:D(t.context,a)})},createPortal(){let o=d.getDoc(t.context),a=d.getPortalEl(t.context);if(a)return a;let l=d.createPortalEl(t.context);return o.body.appendChild(l),l},subscribe(o){return W(t.context.toasts,()=>o(t.context.toasts))}};return t.matches("unknown")||Object.assign(x,r),r}import{createMachine as it,ref as N}from"@zag-js/core";var R=t=>t?"":void 0;var $=t=>t,Y=()=>{};var St=(()=>{let t=0;return()=>(t++,t.toString(36))})();var y=new Map,v=new Map;function X(t,e,n,r){var o;if(!t)return Y;let a=JSON.stringify({type:e,options:r}),l=y.get(t);if(y.has(t))(l==null?void 0:l.has(a))?(o=l==null?void 0:l.get(a))==null||o.add(n):l==null||l.set(a,new Set([n]));else{let c=new Map([[a,new Set([n])]]);y.set(t,c)}function m(c){var i,s;function u(p){var h;let T=y.get(c);(h=T==null?void 0:T.get(a))==null||h.forEach(F=>F(p))}if(!(v==null?void 0:v.has(c))){v.set(c,new Map([[a,u]])),c.addEventListener(e,u,r);return}((i=v==null?void 0:v.get(c))==null?void 0:i.has(a))||((s=v.get(c))==null||s.set(a,u),c.addEventListener(e,u,r))}return m(t),function(){var c,i,s,u;if(!y.has(t))return;let p=y.get(t);if((c=p==null?void 0:p.get(a))==null||c.delete(n),((i=p==null?void 0:p.get(a))==null?void 0:i.size)===0){let h=(s=v.get(t))==null?void 0:s.get(a);t.removeEventListener(e,h,r),p==null||p.delete(a),(u=v.get(t))==null||u.delete(a),(p==null?void 0:p.size)===0&&(y.delete(t),v.delete(t))}}}var U=t=>Object.prototype.toString.call(t).slice(8,-1),Z=t=>U(t)==="Object"&&"current"in t,J=t=>U(t)==="Function"?t():t;function Q(t,e,n,r){let o=Z(t)?t.current:J(t);return X(o,e,n,r)}var V=2147483647;var xt=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function B(t,e){let n=$(t);return Q(n,"visibilitychange",()=>{let r=n.hidden||n.msHidden||n.webkitHidden;e(!!r)})}import{createMachine as tt,guards as et}from"@zag-js/core";var{not:nt,and:ot,or:rt}=et;function P(t={}){let c=t,{type:e="info",duration:n,id:r="toast",placement:o="bottom",removeDelay:a=500}=c,l=k(c,["type","duration","id","placement","removeDelay"]),m=S(n,e);return tt({id:r,entry:"invokeOnOpen",initial:e==="loading"?"persist":"active",context:f({id:r,type:e,remaining:m,duration:m,removeDelay:a,createdAt:Date.now(),placement:o},l),on:{UPDATE:[{guard:ot("hasTypeChanged","isChangingToLoading"),target:"persist",actions:["setContext","invokeOnUpdate"]},{guard:rt("hasDurationChanged","hasTypeChanged"),target:"active:temp",actions:["setContext","invokeOnUpdate"]},{actions:["setContext","invokeOnUpdate"]}]},states:{"active:temp":{tags:["visible","updating"],after:{0:"active"}},persist:{tags:["visible","paused"],activities:"trackDocumentVisibility",on:{RESUME:{guard:nt("isLoadingType"),target:"active",actions:["setCreatedAt"]},DISMISS:"dismissing"}},active:{tags:["visible"],activities:"trackDocumentVisibility",after:{VISIBLE_DURATION:"dismissing"},on:{DISMISS:"dismissing",PAUSE:{target:"persist",actions:"setRemainingDuration"}}},dismissing:{entry:"invokeOnClosing",after:{REMOVE_DELAY:{target:"inactive",actions:"notifyParentToRemove"}}},inactive:{entry:"invokeOnClose",type:"final"}}},{activities:{trackDocumentVisibility(i,s,{send:u}){if(!!i.pauseOnPageIdle)return B(d.getDoc(i),function(p){u(p?"PAUSE":"RESUME")})}},guards:{isChangingToLoading:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.type)==="loading"},isLoadingType:i=>i.type==="loading",hasTypeChanged:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.type)!==i.type},hasDurationChanged:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.duration)!==i.duration}},delays:{VISIBLE_DURATION:i=>i.remaining,REMOVE_DELAY:i=>i.removeDelay},actions:{setRemainingDuration(i){i.remaining-=Date.now()-i.createdAt},setCreatedAt(i){i.createdAt=Date.now()},notifyParentToRemove(i,s,{self:u}){u.sendParent({type:"REMOVE_TOAST",id:u.id})},invokeOnClosing(i){var s;(s=i.onClosing)==null||s.call(i)},invokeOnClose(i){var s;(s=i.onClose)==null||s.call(i)},invokeOnOpen(i){var s;(s=i.onOpen)==null||s.call(i)},invokeOnUpdate(i){var s;(s=i.onUpdate)==null||s.call(i)},setContext(i,s){let{duration:u,type:p}=s.toast,h=S(u,p);Object.assign(i,g(f({},s.toast),{duration:h,remaining:h}))}}})}var z=it({id:"toaster",initial:"active",context:{dir:"ltr",max:Number.MAX_SAFE_INTEGER,uid:"",toasts:[],gutter:"1rem",zIndex:V,pauseOnPageIdle:!1,pauseOnInteraction:!0,offsets:{left:"0px",right:"0px",top:"0px",bottom:"0px"}},computed:{count:t=>t.toasts.length},on:{SETUP:{actions:(t,e)=>{t.uid=e.id,e.doc&&(t.doc=N(e.doc))}},PAUSE_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("PAUSE",e.id)}},PAUSE_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("PAUSE"))}},RESUME_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("RESUME",e.id)}},RESUME_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("RESUME"))}},ADD_TOAST:{guard:t=>t.toasts.length<t.max,actions:(t,e,{self:n})=>{var l;let r=g(f({},e.toast),{pauseOnPageIdle:t.pauseOnPageIdle,pauseOnInteraction:t.pauseOnInteraction,dir:t.dir,doc:N((l=t.doc)!=null?l:document)}),o=P(r),a=n.spawn(o);t.toasts.push(a)}},UPDATE_TOAST:{actions:(t,e,{self:n})=>{n.sendChild({type:"UPDATE",toast:e.toast},e.id)}},DISMISS_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("DISMISS",e.id)}},DISMISS_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("DISMISS"))}},REMOVE_TOAST:{actions:(t,e,{self:n})=>{n.stopChild(e.id);let r=t.toasts.findIndex(o=>o.id===e.id);t.toasts.splice(r,1)}},REMOVE_ALL:{actions:(t,e,{self:n})=>{for(t.toasts.forEach(r=>n.stopChild(r.id));t.toasts.length;)t.toasts.pop()}}}});function at(t,e,n=E){let r=t.hasTag("visible"),o=t.hasTag("paused"),a=t.hasTag("updating"),l=t.context.dir==="rtl",m=t.context.type,c=t.context.pauseOnInteraction,i=t.context.placement;return{type:t.context.type,title:t.context.title,placement:i,isVisible:r,isPaused:o,pause(){e("PAUSE")},resume(){e("RESUME")},dismiss(){e("DISMISS")},rootProps:n.element({"data-part":"root",dir:t.context.dir,id:d.getContainerId(t.context),"data-open":R(r),"data-type":t.context.type,"data-placement":i,role:"status","aria-atomic":"true",tabIndex:0,style:{position:"relative",pointerEvents:"auto",margin:"calc(var(--toast-gutter) / 2)","--remove-delay":`${t.context.removeDelay}ms`,"--duration":`${t.context.duration}ms`},onKeyDown(s){s.key=="Escape"&&(e("DISMISS"),s.preventDefault(),s.stopPropagation())},onFocus(){c&&e("PAUSE")},onBlur(){c&&e("RESUME")},onPointerEnter(){c&&e("PAUSE")},onPointerLeave(){c&&e("RESUME")}}),progressbarProps:n.element({"data-part":"progressbar","data-type":t.context.type,style:{opacity:r?1:0,transformOrigin:l?"right":"left",animationName:a||m==="loading"?"none":void 0,animationPlayState:o?"paused":"running",animationDuration:`${t.context.duration}ms`,animationFillMode:a?void 0:"forwards"}}),titleProps:n.element({"data-part":"title",id:d.getTitleId(t.context)}),closeButtonProps:n.button({id:d.getCloseButtonId(t.context),"data-part":"close-button",type:"button","aria-label":"Dismiss notification",onClick(){e("DISMISS")}}),render(){var s,u;return(u=(s=t.context).render)==null?void 0:u.call(s,{id:t.context.id,type:t.context.type,duration:t.context.duration,title:t.context.title,placement:t.context.placement,description:t.context.description,dismiss(){e("DISMISS")}})}}}var qt={connect:_,machine:z};function Ht(){if(!I())C("toast.api() is only available in the browser");else return x}export{Ht as api,at as connect,P as createMachine,qt as group};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../utilities/core/src/array.ts", "../../../utilities/core/src/functions.ts", "../../../utilities/core/src/guard.ts", "../../../utilities/core/src/warning.ts", "../src/toast-group.connect.ts", "../../../types/src/prop-types.ts", "../../../types/src/controls.ts", "../src/toast.dom.ts", "../src/toast.utils.ts", "../src/toast-group.machine.ts", "../../../utilities/dom/src/attrs.ts", "../../../utilities/dom/src/computed-style.ts", "../../../utilities/dom/src/next-tick.ts", "../../../utilities/dom/src/auto-resize.ts", "../../../utilities/core/src/array.ts", "../../../utilities/core/src/functions.ts", "../../../utilities/core/src/guard.ts", "../../../utilities/core/src/warning.ts", "../../../utilities/dom/src/event-bus.ts", "../../../utilities/dom/src/listener.ts", "../../../utilities/dom/src/body-pointer-event.ts", "../../../utilities/dom/src/body-scroll-lock.ts", "../../../utilities/dom/src/query.ts", "../../../utilities/dom/src/scrollable.ts", "../../../utilities/dom/src/constants.ts", "../../../utilities/dom/src/dispatch-event.ts", "../../../utilities/dom/src/focus-event.ts", "../../../utilities/dom/src/focusable.ts", "../../../utilities/dom/src/keyboard-event.ts", "../../../utilities/dom/src/visually-hidden.ts", "../../../utilities/dom/src/live-region.ts", "../../../utilities/dom/src/mutation-observer.ts", "../../../utilities/dom/src/nodelist.ts", "../../../utilities/dom/src/text-selection.ts", "../../../utilities/dom/src/pointer-event.ts", "../../../utilities/dom/src/pointerlock.ts", "../../../utilities/dom/src/rect-observer.ts", "../../../utilities/dom/src/visibility-event.ts", "../../../utilities/dom/src/wait.ts", "../src/toast.machine.ts", "../src/toast.connect.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: MouseEvent | PointerEvent | KeyboardEvent) =>\n v.ctrlKey || v.altKey || v.metaKey || v.shiftKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { StateMachine as S, subscribe } from \"@zag-js/core\"\nimport { normalizeProp, PropTypes, ReactPropTypes } from \"@zag-js/types\"\nimport { runIfFn } from \"@zag-js/utils\"\nimport { dom } from \"./toast.dom\"\nimport {\n Toaster,\n GroupProps,\n GroupMachineContext,\n Options,\n Placement,\n PromiseMessages,\n PromiseOptions,\n} from \"./toast.types\"\nimport { getGroupPlacementStyle, getToastsByPlacement } from \"./toast.utils\"\n\nexport let toaster: Toaster = {} as any\n\nexport function groupConnect<T extends PropTypes = ReactPropTypes>(\n state: S.State<GroupMachineContext>,\n send: (event: S.Event<S.AnyEventObject>) => void,\n normalize = normalizeProp,\n) {\n const group = {\n count: state.context.count,\n toasts: state.context.toasts,\n toastsByPlacement: getToastsByPlacement(state.context.toasts),\n\n isVisible(id: string) {\n if (!state.context.toasts.length) return false\n return !!state.context.toasts.find((toast) => toast.id == id)\n },\n\n create(options: Options) {\n const uid = \"toast-\" + Math.random().toString(36).substring(2, 9)\n const id = options.id ? options.id : uid\n\n if (group.isVisible(id)) return\n send({ type: \"ADD_TOAST\", toast: { ...options, id } })\n\n return id\n },\n\n upsert(options: Options) {\n const { id } = options\n const isVisible = id ? group.isVisible(id) : false\n if (isVisible && id != null) {\n return group.update(id, options)\n } else {\n return group.create(options)\n }\n },\n\n dismiss(id?: string) {\n if (id == null) {\n send(\"DISMISS_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"DISMISS_TOAST\", id })\n }\n },\n\n remove(id?: string) {\n if (id == null) {\n send(\"REMOVE_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"REMOVE_TOAST\", id })\n }\n },\n\n dismissByPlacement(placement: Placement) {\n const toasts = group.toastsByPlacement[placement]\n if (toasts) {\n toasts.forEach((toast) => group.dismiss(toast.id))\n }\n },\n\n update(id: string, options: Options) {\n if (!group.isVisible(id)) return\n send({ type: \"UPDATE_TOAST\", id, toast: options })\n return id\n },\n\n loading(options: Options) {\n options.type = \"loading\"\n return group.upsert(options)\n },\n\n success(options: Options) {\n options.type = \"success\"\n return group.upsert(options)\n },\n\n error(options: Options) {\n options.type = \"error\"\n return group.upsert(options)\n },\n\n promise<T>(promise: Promise<T>, msgs: PromiseMessages, opts: PromiseOptions = {}) {\n const id = group.loading({ ...opts, ...opts?.loading, type: \"loading\", title: msgs.loading })\n\n promise\n .then((response) => {\n const message = runIfFn(msgs.loading, response)\n group.success({ ...opts, ...opts?.success, id, title: message })\n })\n .catch((error) => {\n const message = runIfFn(msgs.error, error)\n group.error({ ...opts, ...opts?.error, id, title: message })\n })\n\n return promise\n },\n\n pause(id?: string) {\n if (id == null) {\n send(\"PAUSE_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"PAUSE_TOAST\", id })\n }\n },\n\n resume(id?: string) {\n if (id == null) {\n send(\"RESUME_ALL\")\n } else if (group.isVisible(id)) {\n send({ type: \"RESUME_TOAST\", id })\n }\n },\n\n getGroupProps(options: GroupProps) {\n const { placement, label = \"Notifications\" } = options\n return normalize.element<T>({\n tabIndex: -1,\n \"aria-label\": label,\n id: dom.getGroupId(placement),\n \"data-placement\": placement,\n \"aria-live\": \"polite\",\n role: \"region\",\n style: getGroupPlacementStyle(state.context, placement),\n })\n },\n\n createPortal() {\n const doc = dom.getDoc(state.context)\n const exist = dom.getPortalEl(state.context)\n if (exist) return exist\n const portal = dom.createPortalEl(state.context)\n doc.body.appendChild(portal)\n return portal\n },\n\n subscribe(fn: (toasts: GroupMachineContext[\"toasts\"]) => void) {\n return subscribe(state.context.toasts, () => fn(state.context.toasts))\n },\n }\n\n if (!state.matches(\"unknown\")) {\n Object.assign(toaster, group)\n }\n\n return group\n}\n", "import type * as React from \"react\"\n\ntype Dict<T = any> = Record<string, T>\n\ntype Booleanish = boolean | \"true\" | \"false\"\n\ntype Omit<T, K extends keyof T> = { [P in Exclude<keyof T, K>]?: T[P] }\n\ntype WithStyle<T extends { style?: any }> = Omit<T, \"style\"> & {\n style?: T[\"style\"] & {\n [prop: string]: string | number | undefined\n }\n}\n\ntype DataAttr = {\n \"data-uid\"?: string\n \"data-name\"?: string\n \"data-ownedby\"?: string\n \"data-selected\"?: Booleanish\n \"data-expanded\"?: Booleanish\n \"data-highlighted\"?: Booleanish\n \"data-readonly\"?: Booleanish\n \"data-invalid\"?: Booleanish\n \"data-hover\"?: Booleanish\n \"data-active\"?: Booleanish\n \"data-focus\"?: Booleanish\n \"data-disabled\"?: Booleanish\n \"data-type\"?: string\n \"data-value\"?: string | number\n \"data-valuetext\"?: string\n \"data-open\"?: Booleanish\n \"data-placement\"?: string\n \"data-orientation\"?: \"horizontal\" | \"vertical\"\n \"data-label\"?: string\n \"data-checked\"?: Booleanish\n \"data-pressed\"?: Booleanish\n \"data-state\"?: string | null\n \"data-half\"?: Booleanish\n \"data-count\"?: number\n \"data-controls\"?: string\n \"data-part\"?: string\n \"data-index\"?: number\n \"data-complete\"?: Booleanish\n \"data-empty\"?: Booleanish\n \"data-placeholder-shown\"?: Booleanish\n}\n\ntype JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>\ntype JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>\ntype JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>\ntype JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>\ntype JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>\n\nexport type PropTypes = Record<\"button\" | \"label\" | \"input\" | \"output\" | \"element\", Dict>\n\nexport type ReactPropTypes = {\n button: JSXButtonAttributes\n label: JSXLabelAttributes\n input: JSXInputAttributes\n output: JSXOutputAttributes\n element: JSXElementAttributes\n}\n\nexport type NormalizeProps = {\n button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T[\"button\"]\n label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T[\"label\"]\n input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T[\"input\"]\n output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T[\"output\"]\n element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T[\"element\"]\n}\n\nexport function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps {\n return { button: fn, label: fn, input: fn, output: fn, element: fn }\n}\n\nexport const normalizeProp = createNormalizer((v) => v)\n", "export type ControlProp =\n | { type: \"boolean\"; label?: string; defaultValue: boolean }\n | { type: \"string\"; label?: string; defaultValue: string; placeholder?: string }\n | { type: \"select\"; options: readonly string[]; defaultValue: string; label?: string }\n | { type: \"multiselect\"; options: readonly string[]; defaultValue: string[]; label?: string }\n | { type: \"number\"; label?: string; defaultValue: number; min?: number; max?: number }\n\nexport type ControlRecord = Record<string, ControlProp>\n\nexport type ControlValue<T extends ControlRecord> = {\n [K in keyof T]: T[K] extends { type: \"boolean\" }\n ? boolean\n : T[K] extends { type: \"string\" }\n ? string\n : T[K] extends { type: \"select\" }\n ? T[K][\"options\"][number]\n : T[K] extends { type: \"multiselect\" }\n ? T[K][\"options\"][number][]\n : T[K] extends { type: \"number\" }\n ? number\n : never\n}\n\nexport function defineControls<T extends ControlRecord>(config: T) {\n return config\n}\n", "import { GroupMachineContext as GroupCtx, MachineContext as Ctx, Placement } from \"./toast.types\"\n\nexport const dom = {\n getDoc: (ctx: Ctx | GroupCtx) => ctx.doc ?? document,\n\n getGroupId: (placement: Placement) => `toast-group--${placement}`,\n getContainerId: (ctx: Ctx) => `toast--${ctx.id}`,\n getTitleId: (ctx: Ctx) => `toast-title--${ctx.id}`,\n getCloseButtonId: (ctx: Ctx) => `toast-close-button--${ctx.id}`,\n\n getPortalId: (ctx: GroupCtx) => `toast-portal--${ctx.uid}`,\n getPortalEl: (ctx: GroupCtx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),\n\n createPortalEl: (ctx: GroupCtx) => {\n const existing = dom.getPortalEl(ctx)\n if (existing) return existing\n const portal = dom.getDoc(ctx).createElement(\"toast-portal\")\n portal.id = dom.getPortalId(ctx)\n return portal\n },\n}\n", "import { Style } from \"@zag-js/types\"\nimport { GroupMachineContext, MachineContext, Placement, Service, Type } from \"./toast.types\"\n\nexport function getToastsByPlacement(toasts: Service[]) {\n const result: Partial<Record<Placement, Service[]>> = {}\n\n for (const toast of toasts) {\n const placement = toast.state.context.placement!\n result[placement] ||= []\n result[placement]!.push(toast)\n }\n\n return result\n}\n\nexport const defaultTimeouts: Record<Type, number> = {\n info: 5000,\n error: 5000,\n success: 2000,\n loading: Infinity,\n custom: 5000,\n}\n\nexport function getToastDuration(duration: number | undefined, type: MachineContext[\"type\"]) {\n return duration ?? defaultTimeouts[type]\n}\n\nexport function getGroupPlacementStyle(ctx: GroupMachineContext, placement: Placement): Style {\n const offset = ctx.offsets\n const __offset = typeof offset === \"string\" ? { left: offset, right: offset, bottom: offset, top: offset } : offset\n\n const rtl = ctx.dir === \"rtl\"\n const __placement = placement.replace(\"-start\", rtl ? \"-right\" : \"-left\").replace(\"-end\", rtl ? \"-left\" : \"-right\")\n\n const isRighty = __placement.includes(\"right\")\n const isLefty = __placement.includes(\"left\")\n\n const styles: Style = {\n position: \"fixed\",\n pointerEvents: ctx.count > 0 ? undefined : \"none\",\n display: \"flex\",\n flexDirection: \"column\",\n \"--toast-gutter\": ctx.gutter,\n zIndex: ctx.zIndex,\n }\n\n let alignItems: Style[\"alignItems\"] = \"center\"\n if (isRighty) alignItems = \"flex-end\"\n if (isLefty) alignItems = \"flex-start\"\n\n styles.alignItems = alignItems\n\n if (__placement.includes(\"top\")) {\n const offset = __offset.top\n styles.top = `calc(env(safe-area-inset-top, 0px) + ${offset})`\n }\n\n if (__placement.includes(\"bottom\")) {\n const offset = __offset.bottom\n styles.bottom = `calc(env(safe-area-inset-bottom, 0px) + ${offset})`\n }\n\n if (!__placement.includes(\"left\")) {\n const offset = __offset.right\n styles.right = `calc(env(safe-area-inset-right, 0px) + ${offset})`\n }\n\n if (!__placement.includes(\"right\")) {\n const offset = __offset.left\n styles.left = `calc(env(safe-area-inset-left, 0px) + ${offset})`\n }\n\n return styles\n}\n", "import { createMachine, ref } from \"@zag-js/core\"\nimport { MAX_Z_INDEX } from \"@zag-js/dom-utils\"\nimport { createToastMachine } from \"./toast.machine\"\nimport { GroupMachineContext } from \"./toast.types\"\n\nexport const groupMachine = createMachine<GroupMachineContext>({\n id: \"toaster\",\n initial: \"active\",\n context: {\n dir: \"ltr\",\n max: Number.MAX_SAFE_INTEGER,\n uid: \"\",\n toasts: [],\n gutter: \"1rem\",\n zIndex: MAX_Z_INDEX,\n pauseOnPageIdle: false,\n pauseOnInteraction: true,\n offsets: { left: \"0px\", right: \"0px\", top: \"0px\", bottom: \"0px\" },\n },\n\n computed: {\n count: (ctx) => ctx.toasts.length,\n },\n\n on: {\n SETUP: {\n actions: (ctx, evt) => {\n ctx.uid = evt.id\n if (evt.doc) ctx.doc = ref(evt.doc)\n },\n },\n\n PAUSE_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild(\"PAUSE\", evt.id)\n },\n },\n\n PAUSE_ALL: {\n actions: (ctx) => {\n ctx.toasts.forEach((toast) => toast.send(\"PAUSE\"))\n },\n },\n\n RESUME_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild(\"RESUME\", evt.id)\n },\n },\n\n RESUME_ALL: {\n actions: (ctx) => {\n ctx.toasts.forEach((toast) => toast.send(\"RESUME\"))\n },\n },\n\n ADD_TOAST: {\n guard: (ctx) => ctx.toasts.length < ctx.max,\n actions: (ctx, evt, { self }) => {\n const options = {\n ...evt.toast,\n pauseOnPageIdle: ctx.pauseOnPageIdle,\n pauseOnInteraction: ctx.pauseOnInteraction,\n dir: ctx.dir,\n doc: ref(ctx.doc ?? document),\n }\n const toast = createToastMachine(options)\n const actor = self.spawn(toast)\n ctx.toasts.push(actor)\n },\n },\n\n UPDATE_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild({ type: \"UPDATE\", toast: evt.toast }, evt.id)\n },\n },\n\n DISMISS_TOAST: {\n actions: (_ctx, evt, { self }) => {\n self.sendChild(\"DISMISS\", evt.id)\n },\n },\n\n DISMISS_ALL: {\n actions: (ctx) => {\n ctx.toasts.forEach((toast) => toast.send(\"DISMISS\"))\n },\n },\n\n REMOVE_TOAST: {\n actions: (ctx, evt, { self }) => {\n self.stopChild(evt.id)\n const index = ctx.toasts.findIndex((toast) => toast.id === evt.id)\n ctx.toasts.splice(index, 1)\n },\n },\n\n REMOVE_ALL: {\n actions: (ctx, _evt, { self }) => {\n ctx.toasts.forEach((toast) => self.stopChild(toast.id))\n while (ctx.toasts.length) ctx.toasts.pop()\n },\n },\n },\n})\n", "type Booleanish = boolean | \"true\" | \"false\"\n\nexport const dataAttr = (guard: boolean | undefined) => {\n return (guard ? \"\" : undefined) as Booleanish\n}\n\nexport const ariaAttr = (guard: boolean | undefined) => {\n return guard ? true : undefined\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n if (!el) return {} as Styles\n let style: Styles | undefined = styleCache.get(el)\n if (!style) {\n const win = el?.ownerDocument.defaultView ?? window\n style = win.getComputedStyle(el) as Styles\n styleCache.set(el, style)\n }\n return style\n}\n\nexport function copyVisualStyles(fromEl: HTMLElement | null, toEl: HTMLElement) {\n if (!fromEl) return\n const el = getComputedStyle(fromEl)\n // prettier-ignore\n const cssText = 'box-sizing:' + el.boxSizing +\n ';border-left:' + el.borderLeftWidth + ' solid red' +\n ';border-right:' + el.borderRightWidth + ' solid red' +\n ';font-family:' + el.fontFamily +\n ';font-feature-settings:' + el.fontFeatureSettings +\n ';font-kerning:' + el.fontKerning +\n ';font-size:' + el.fontSize +\n ';font-stretch:' + el.fontStretch +\n ';font-style:' + el.fontStyle +\n ';font-variant:' + el.fontVariant +\n ';font-variant-caps:' + el.fontVariantCaps +\n ';font-variant-ligatures:' + el.fontVariantLigatures +\n ';font-variant-numeric:' + el.fontVariantNumeric +\n ';font-weight:' + el.fontWeight +\n ';letter-spacing:' + el.letterSpacing +\n ';margin-left:' + el.marginLeft +\n ';margin-right:' + el.marginRight +\n ';padding-left:' + el.paddingLeft +\n ';padding-right:' + el.paddingRight +\n ';text-indent:' + el.textIndent +\n ';text-transform:' + el.textTransform\n\n toEl.style.cssText += cssText\n}\n", "export function nextTick(fn: VoidFunction) {\n const set = new Set<VoidFunction>()\n function raf(fn: VoidFunction) {\n const id = globalThis.requestAnimationFrame(fn)\n set.add(() => globalThis.cancelAnimationFrame(id))\n }\n raf(() => raf(fn))\n return function cleanup() {\n set.forEach(function (fn) {\n fn()\n })\n }\n}\n\nexport function raf(fn: VoidFunction) {\n const id = globalThis.requestAnimationFrame(fn)\n return function cleanup() {\n globalThis.cancelAnimationFrame(id)\n }\n}\n\nexport function forceReflow() {\n return document.body.offsetHeight\n}\n", "import { copyVisualStyles } from \"./computed-style\"\nimport { raf } from \"./next-tick\"\n\nfunction createGhostElement(doc: Document) {\n var el = doc.createElement(\"div\")\n el.id = \"ghost\"\n el.style.cssText =\n \"display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;\"\n doc.body.appendChild(el)\n return el\n}\n\nexport function autoResizeInput(input: HTMLInputElement | null) {\n if (!input) return\n const doc = input.ownerDocument ?? document\n const ghost = createGhostElement(doc)\n\n copyVisualStyles(input, ghost)\n\n function resize() {\n raf(() => {\n ghost.innerHTML = input!.value\n const rect = getComputedStyle(ghost)\n input?.style.setProperty(\"width\", rect.width)\n })\n }\n\n resize()\n\n input?.addEventListener(\"input\", resize)\n input?.addEventListener(\"change\", resize)\n\n return () => {\n doc.body.removeChild(ghost)\n input?.removeEventListener(\"input\", resize)\n input?.removeEventListener(\"change\", resize)\n }\n}\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: MouseEvent | PointerEvent | KeyboardEvent) =>\n v.ctrlKey || v.altKey || v.metaKey || v.shiftKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { noop } from \"@zag-js/utils\"\n\ntype El = HTMLElement | Document | VisualViewport | Window\ntype Handler = (event: Event) => void\ntype Group = Map<string, Set<Handler>>\ntype Option = boolean | AddEventListenerOptions\n\nconst listenerElements: Map<El, Group> = new Map()\nconst listenerCache: Map<El, Map<string, Handler>> = new Map()\n\n/**\n * The global event bus for managing event listeners attached to DOM elements.\n *\n * It's goal is to ensure that only one listener is attached to a DOM element for a given event,\n * regardless of the number of times `addEventListener` is called.\n */\n\nexport function globalEventBus(node: El | null, type: string, handler: Handler, options?: Option) {\n if (!node) return noop\n\n // unique identifier for the event listener\n const hash = JSON.stringify({ type, options })\n\n // Subscribe pattern\n\n const group = listenerElements.get(node)\n\n if (!listenerElements.has(node)) {\n // create group of listeners per hash\n const group: Group = new Map([[hash, new Set([handler])]])\n listenerElements.set(node, group)\n } else if (group?.has(hash)) {\n group?.get(hash)?.add(handler)\n } else {\n group?.set(hash, new Set([handler]))\n }\n\n // add the event listener to the node or register it in the cache\n function attach(node: El) {\n // Publish pattern\n function listener(event: Event) {\n const group = listenerElements.get(node)\n group?.get(hash)?.forEach((fn) => fn(event))\n }\n\n if (!listenerCache?.has(node)) {\n listenerCache.set(node, new Map([[hash, listener]]))\n node.addEventListener(type, listener, options)\n return\n }\n\n if (!listenerCache?.get(node)?.has(hash)) {\n listenerCache.get(node)?.set(hash, listener)\n node.addEventListener(type, listener, options)\n }\n }\n\n attach(node)\n\n return function remove() {\n if (!listenerElements.has(node)) return\n\n const group = listenerElements.get(node)\n group?.get(hash)?.delete(handler)\n\n if (group?.get(hash)?.size === 0) {\n const listener = listenerCache.get(node)?.get(hash)!\n node.removeEventListener(type, listener, options)\n group?.delete(hash)\n listenerCache.get(node)?.delete(hash)\n\n if (group?.size === 0) {\n listenerElements.delete(node)\n listenerCache.delete(node)\n }\n }\n }\n}\n", "import { globalEventBus } from \"./event-bus\"\nimport {\n AnyPointerEvent,\n DOMEventTarget,\n EventMap,\n PointerEventInfo,\n PointerNameMap,\n RefTarget,\n} from \"./listener.types\"\n\nconst t = (v: any) => Object.prototype.toString.call(v).slice(8, -1)\nconst isRef = (v: any): v is RefTarget => t(v) === \"Object\" && \"current\" in v\nconst runIfFn = (fn: any): HTMLElement | null => (t(fn) === \"Function\" ? fn() : fn)\nconst isTouchEvent = (v: Event): v is TouchEvent => t(v) === \"Object\" && !!(v as TouchEvent).touches\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function extractInfo<T extends AnyPointerEvent = AnyPointerEvent>(event: T, type: \"page\" | \"client\" = \"page\") {\n const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event\n return {\n point: {\n x: point[`${type}X`],\n y: point[`${type}Y`],\n },\n }\n}\n\nexport function addDomEvent<K extends keyof EventMap>(\n target: DOMEventTarget,\n event: K,\n listener: (event: EventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n) {\n const node = isRef(target) ? target.current : runIfFn(target)\n return globalEventBus(node, event, listener as any, options)\n}\n\nexport function addPointerEvent<K extends keyof EventMap>(\n target: DOMEventTarget,\n event: K,\n listener: (event: EventMap[K], info: PointerEventInfo) => void,\n options?: boolean | AddEventListenerOptions,\n) {\n const type = getEventName(event) ?? event\n return addDomEvent(target, type, wrapHandler(listener, event === \"pointerdown\"), options)\n}\n\nfunction wrapHandler<E extends EventMap[keyof EventMap]>(\n fn: (event: E, info: PointerEventInfo) => void,\n filter = false,\n) {\n const listener: EventListener = (event: any) => {\n fn(event, extractInfo(event))\n }\n return filter ? filterPrimaryPointer(listener) : listener\n}\n\nfunction filterPrimaryPointer(fn: EventListener): EventListener {\n return (event: Event) => {\n const win = ((event as UIEvent).view ?? window) as typeof window\n const isMouseEvent = event instanceof win.MouseEvent\n const isPrimary = !isMouseEvent || (isMouseEvent && (event as MouseEvent).button === 0)\n if (isPrimary) fn(event)\n }\n}\n\nexport function extractClientInfo(event: AnyPointerEvent) {\n return extractInfo(event, \"client\")\n}\n\nconst supportsPointerEvent = () => typeof window !== \"undefined\" && window.onpointerdown === null\nconst supportsTouchEvent = () => typeof window !== \"undefined\" && window.ontouchstart === null\nconst supportsMouseEvent = () => typeof window !== \"undefined\" && window.onmousedown === null\n\nconst mouseEventNames: PointerNameMap = {\n pointerdown: \"mousedown\",\n pointermove: \"mousemove\",\n pointerup: \"mouseup\",\n pointercancel: \"mousecancel\",\n pointerover: \"mouseover\",\n pointerout: \"mouseout\",\n pointerenter: \"mouseenter\",\n pointerleave: \"mouseleave\",\n}\n\nconst touchEventNames: PointerNameMap = {\n pointerdown: \"touchstart\",\n pointermove: \"touchmove\",\n pointerup: \"touchend\",\n pointercancel: \"touchcancel\",\n}\n\nexport function getEventName(evt: keyof EventMap): keyof EventMap {\n if (supportsPointerEvent()) return evt\n if (supportsTouchEvent()) return touchEventNames[evt]\n if (supportsMouseEvent()) return mouseEventNames[evt]\n return evt\n}\n", "import { isLeftClick, pipe } from \"@zag-js/utils\"\nimport { addDomEvent } from \"./listener\"\nimport { nextTick } from \"./next-tick\"\n\nlet changeCount = 0\nlet originalBodyPointerEvents: string\n\ntype PointerEventOptions = {\n disabled: boolean\n document?: Document\n}\n\nexport function preventBodyPointerEvents(el: HTMLElement | null, opts: Partial<PointerEventOptions> = {}) {\n const { disabled = false, document: docProp } = opts\n const doc: Document = docProp || document\n\n let isTouchOrPenPressed = false\n let isLeftClickPressed = false\n\n function listen() {\n const onPointerDown = (event: PointerEvent) => {\n const isMouse = event.pointerType === \"mouse\"\n isTouchOrPenPressed = !isMouse\n isLeftClickPressed = isMouse && isLeftClick(event)\n }\n\n const onPointerUp = () => {\n isTouchOrPenPressed = false\n isLeftClickPressed = false\n }\n\n // prettier-ignore\n return pipe(\n addDomEvent(doc, \"pointerdown\", onPointerDown),\n addDomEvent(doc,\"pointerup\", onPointerUp)\n )\n }\n\n function reset() {\n changeCount--\n if (changeCount === 0) {\n doc.body.style.pointerEvents = originalBodyPointerEvents\n }\n if (el) {\n el.style.pointerEvents = \"\"\n }\n }\n\n function apply() {\n if (disabled) return\n\n if (changeCount === 0) {\n originalBodyPointerEvents = doc.body.style.pointerEvents\n }\n\n doc.body.style.pointerEvents = \"none\"\n if (el) {\n el.style.pointerEvents = \"auto\"\n }\n\n changeCount++\n\n return function () {\n if (isTouchOrPenPressed) {\n addDomEvent(doc, \"click\", reset, { once: true })\n } else if (isLeftClickPressed) {\n addDomEvent(doc, \"pointerup\", reset, { once: true })\n } else {\n reset()\n }\n }\n }\n\n const cleanups: Array<VoidFunction | undefined> = []\n cleanups.push(apply())\n nextTick(() => {\n cleanups.push(listen())\n })\n\n return function () {\n cleanups.forEach((cleanup) => cleanup?.())\n }\n}\n", "import { isDom, isIos, noop, pipe } from \"@zag-js/utils\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { addDomEvent } from \"./listener\"\nimport { getScrollParent } from \"./scrollable\"\n\ninterface PreventScrollOptions {\n disabled?: boolean\n allowPinchZoom?: boolean\n document?: Document\n}\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\"checkbox\", \"radio\", \"range\", \"color\", \"file\", \"image\", \"button\", \"submit\", \"reset\"])\n\nexport function preventBodyScroll(opts?: PreventScrollOptions) {\n const { document: docProp, disabled = false, allowPinchZoom } = opts ?? {}\n\n const doc = docProp ?? document\n const win = doc?.defaultView ?? window\n\n const viewport = isDom() ? win.visualViewport : null\n const docEl = doc.documentElement\n\n function preventScrollStandard() {\n const fn = pipe(\n setStyle(docEl, \"paddingRight\", `${win.innerWidth - docEl.clientWidth}px`),\n setStyle(docEl, \"overflow\", \"hidden\"),\n )\n return () => fn?.()\n }\n\n function preventScrollMobileSafari() {\n let scrollable: HTMLElement | undefined\n let lastY = 0\n\n let onTouchStart = (e: TouchEvent) => {\n scrollable = getScrollParent(e.target as HTMLElement)\n\n if (scrollable === docEl && scrollable === doc.body) {\n return\n }\n lastY = e.changedTouches[0].pageY\n }\n\n let onTouchMove = (e: TouchEvent) => {\n if (e.touches.length === 2 && allowPinchZoom) return\n\n if (!scrollable || scrollable === docEl || scrollable === doc.body) {\n e.preventDefault()\n return\n }\n\n let y = e.changedTouches[0].pageY\n let scrollTop = scrollable.scrollTop\n let bottom = scrollable.scrollHeight - scrollable.clientHeight\n\n if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n e.preventDefault()\n }\n\n lastY = y\n }\n\n let onTouchEnd = (e: TouchEvent) => {\n let target = e.target as HTMLElement\n if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {\n e.preventDefault()\n target.style.transform = \"translateY(-2000px)\"\n target.focus()\n win.requestAnimationFrame(() => {\n target.style.transform = \"\"\n })\n }\n }\n\n let onFocus = (e: FocusEvent) => {\n let target = e.target as HTMLElement\n if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {\n target.style.transform = \"translateY(-2000px)\"\n win.requestAnimationFrame(() => {\n target.style.transform = \"\"\n if (!viewport) return\n\n if (viewport.height < win.innerHeight) {\n win.requestAnimationFrame(function () {\n scrollIntoView(target, { scrollMode: \"if-needed\" })\n })\n } else {\n const onResize = () => {\n scrollIntoView(target, { scrollMode: \"if-needed\" })\n }\n addDomEvent(viewport, \"resize\", onResize, { once: true })\n }\n })\n }\n }\n\n let onWindowScroll = () => {\n win.scrollTo(0, 0)\n }\n\n let scrollX = win.scrollX\n let scrollY = win.scrollY\n let restoreStyles = pipe(\n setStyle(docEl, \"paddingRight\", `${win.innerWidth - docEl.clientWidth}px`),\n setStyle(docEl, \"overflow\", \"hidden\"),\n setStyle(doc.body, \"marginTop\", `-${scrollY}px`),\n )\n\n win.scrollTo(0, 0)\n\n let removeEvents = pipe(\n addDomEvent(doc, \"touchstart\", onTouchStart, { passive: false, capture: true }),\n addDomEvent(doc, \"touchmove\", onTouchMove, { passive: false, capture: true }),\n addDomEvent(doc, \"touchend\", onTouchEnd, { passive: false, capture: true }),\n addDomEvent(doc, \"focus\", onFocus, true),\n addDomEvent(win, \"scroll\", onWindowScroll),\n )\n\n return () => {\n restoreStyles()\n removeEvents()\n win.scrollTo(scrollX, scrollY)\n }\n }\n\n if (disabled) return noop\n return isIos() ? preventScrollMobileSafari() : preventScrollStandard()\n}\n\nfunction setStyle(el: HTMLElement, key: string, value: string) {\n let cur = el.style[key]\n el.style[key] = value\n return () => {\n el.style[key] = cur\n }\n}\n\n// Backup lib: https://github.com/hanai/html-body-scroll-lock\n", "export function getOwnerDocument(el: HTMLElement | Window) {\n if (isWindow(el)) return el.document\n return el?.ownerDocument ?? document\n}\n\nexport function getOwnerWindow(el: HTMLElement) {\n return el?.ownerDocument.defaultView ?? window\n}\n\nexport function getDocumentElement(el: HTMLElement | Window): HTMLElement {\n return getOwnerDocument(el).documentElement\n}\n\nexport function getNodeName(node: HTMLElement | Window): string {\n return isWindow(node) ? \"\" : node ? node.localName || \"\" : \"\"\n}\n\nexport function getEventWindow(event: UIEvent) {\n if (event.view) return event.view\n let target = event.currentTarget\n if (target != null) return getOwnerWindow(target as HTMLElement)\n return window\n}\n\nexport function getParent(el: HTMLElement): HTMLElement {\n const doc = getOwnerDocument(el)\n if (getNodeName(el) === \"html\") return el\n return el.assignedSlot || el.parentElement || doc.documentElement\n}\n\ntype Node = HTMLElement | EventTarget | null\n\nexport function contains(parent: Node | undefined, child: Node) {\n if (!parent) return false\n return parent === child || (isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child))\n}\n\nexport function isHTMLElement(v: any): v is HTMLElement {\n return typeof v === \"object\" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === \"string\"\n}\n\nexport function isWindow(value: any): value is Window {\n return value?.toString() === \"[object Window]\"\n}\n\nexport const isDisabled = (el: HTMLElement | null): boolean => {\n return el?.getAttribute(\"disabled\") != null || !!el?.getAttribute(\"aria-disabled\") === true\n}\n\nexport function getNativeEvent<E>(\n event: E,\n): React.ChangeEvent<any> extends E ? InputEvent : E extends React.SyntheticEvent<any, infer T> ? T : never {\n return (event as any).nativeEvent ?? event\n}\n", "import { getComputedStyle } from \"./computed-style\"\nimport { getNodeName, getOwnerDocument, getOwnerWindow, getParent, isHTMLElement, isWindow } from \"./query\"\n\nexport function isScrollParent(el: HTMLElement): boolean {\n const { overflow, overflowX, overflowY } = getComputedStyle(el)\n return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX)\n}\n\nexport function getScrollParent(el: HTMLElement): HTMLElement {\n if ([\"html\", \"body\", \"#document\"].includes(getNodeName(el))) {\n return getOwnerDocument(el).body\n }\n\n if (isHTMLElement(el) && isScrollParent(el)) {\n return el\n }\n\n return getScrollParent(getParent(el))\n}\n\ntype Target = Array<VisualViewport | Window | HTMLElement>\n\nexport function getScrollParents(el: HTMLElement, list: Target = []): Target {\n const scrollParent = getScrollParent(el)\n const isBody = scrollParent === getOwnerDocument(el).body\n const win = getOwnerWindow(scrollParent)\n\n const target = isBody\n ? ([win] as Target).concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : [])\n : scrollParent\n\n const parents = list.concat(target)\n if (isBody) return parents\n\n return parents.concat(getScrollParents(getParent(<HTMLElement>target)))\n}\n\nexport function getScrollOffset(el: HTMLElement) {\n if (isWindow(el)) {\n return { scrollLeft: el.scrollX, scrollTop: el.scrollY }\n }\n\n return { scrollLeft: el.scrollLeft, scrollTop: el.scrollTop }\n}\n", "export const MAX_Z_INDEX = 2147483647\n", "import { getOwnerWindow } from \"./query\"\n\nfunction descriptor(el: HTMLElement, type: \"input\" | \"textarea\" = \"input\") {\n const win = getOwnerWindow(el)\n const _type = type === \"input\" ? \"HTMLInputElement\" : \"HTMLTextAreaElement\"\n const proto = win[_type].prototype\n return Object.getOwnPropertyDescriptor(proto, \"value\") ?? {}\n}\n\nexport function dispatchEvent(el: HTMLElement, name: string, options: CustomEventInit) {\n const win = getOwnerWindow(el)\n const evt = new win.CustomEvent(name, options)\n el.dispatchEvent(evt)\n return evt\n}\n\nexport function dispatchInputEvent(el: HTMLElement, value: string | number) {\n const win = getOwnerWindow(el)\n if (!(el instanceof win.HTMLInputElement)) return\n\n el.type = \"text\"\n el.hidden = true\n\n descriptor(el).set?.call(el, value)\n\n const evt = new win.Event(\"input\", { bubbles: true })\n el.dispatchEvent(evt)\n\n el.type = \"hidden\"\n el.hidden = false\n}\n\nexport function onElementValueChange(el: HTMLInputElement, fn?: (value: string) => void) {\n if (!fn) return\n\n const { get, set } = descriptor(el)\n\n let run = true\n\n Object.defineProperty(el, \"value\", {\n get() {\n return get?.call(this)\n },\n set(value: string) {\n if (run) fn(value)\n return set?.call(this, value)\n },\n })\n\n return function () {\n run = false\n }\n}\n", "/**\n * Determine if the blur event within an element is valid\n */\nexport function validateBlur(event: Event, opts: Options) {\n const exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude]\n const relatedTarget = (event.relatedTarget ?? opts.fallback) as HTMLElement\n return exclude.every((el) => !el?.contains(relatedTarget))\n}\n\ntype MaybeArray<T> = T | T[]\n\ntype Options = {\n exclude: MaybeArray<HTMLElement | null>\n fallback?: HTMLElement | null\n}\n\ntype Event = Pick<FocusEvent, \"relatedTarget\">\n", "import { getComputedStyle } from \"./computed-style\"\nimport { isDisabled, isHTMLElement } from \"./query\"\n\nexport const focusableSelector = /*#__PURE__*/ [\n \"input:not([disabled]):not([type=hidden])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"embed\",\n \"iframe\",\n \"object\",\n \"a[href]\",\n \"area[href]\",\n \"[tabindex]\",\n \"audio[controls]\",\n \"video[controls]\",\n \"*[tabindex]:not([aria-disabled])\",\n \"[contenteditable]:not([contenteditable=false])\",\n \"details > summary:first-of-type\",\n].join(\",\")\n\nexport function isHidden(el: HTMLElement | null, until?: HTMLElement) {\n const style = getComputedStyle(el)\n if (!el || style.getPropertyValue(\"visibility\") === \"hidden\") return true\n while (el) {\n if (until != null && el === until) return false\n if (style.getPropertyValue(\"display\") === \"none\") return true\n el = el.parentElement\n }\n return false\n}\n\n/**\n * Returns the focusable elements within the element\n */\nexport const getFocusables = (el: HTMLElement | Document | null, includeContainer = false) => {\n if (!el) return []\n let els = Array.from(el.querySelectorAll<HTMLElement>(focusableSelector))\n if (includeContainer && isHTMLElement(el)) {\n els.unshift(el)\n }\n return els.filter((el) => isFocusable(el) && !isHidden(el))\n}\n\n/**\n * Whether this element is focusable\n */\nexport const isFocusable = (el: HTMLElement | null) => {\n if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) return false\n return el?.matches(focusableSelector)\n}\n\n/**\n * Returns the tabbable elements within the element\n */\nexport const getTabbables = (el: HTMLElement | Document, includeContainer = false) => {\n return getFocusables(el, includeContainer).filter(isTabbable)\n}\n\n/**\n * Whether this element is tabbable\n */\nexport const isTabbable = (el: HTMLElement | null) => {\n return isFocusable(el) && !isDisabled(el) && !isHidden(el)\n}\n", "import type { KeyboardEvent } from \"react\"\n\ntype EventKey =\n | \"ArrowDown\"\n | \"ArrowUp\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"Space\"\n | \"Enter\"\n | \"Comma\"\n | \"Escape\"\n | \"Backspace\"\n | \"Delete\"\n | \"Home\"\n | \"End\"\n | \"Tab\"\n | \"PageUp\"\n | \"PageDown\"\n | (string & {})\n\nexport type EventKeyMap = Partial<Record<EventKey, (event: React.KeyboardEvent) => void>>\n\nconst rtlKeyMap = {\n ArrowLeft: \"ArrowRight\",\n ArrowRight: \"ArrowLeft\",\n Home: \"End\",\n End: \"Home\",\n}\n\nconst sameKeyMap = {\n Up: \"ArrowUp\",\n Down: \"ArrowDown\",\n Esc: \"Escape\",\n \" \": \"Space\",\n \",\": \"Comma\",\n Left: \"ArrowLeft\",\n Right: \"ArrowRight\",\n}\n\ntype EventKeyOptions = {\n dir?: \"ltr\" | \"rtl\"\n orientation?: \"horizontal\" | \"vertical\"\n}\n\n/**\n * Determine the event key based on text direction.\n */\nexport function getEventKey(event: KeyboardEvent, options: EventKeyOptions = {}) {\n const { dir = \"ltr\", orientation = \"horizontal\" } = options\n\n let { key } = event\n key = sameKeyMap[key] ?? key // normalize key\n\n const isRtl = dir === \"rtl\" && orientation === \"horizontal\"\n\n if (isRtl && key in rtlKeyMap) {\n key = rtlKeyMap[key]\n }\n\n return key\n}\n\nconst PAGE_KEYS = new Set([\"PageUp\", \"PageDown\"])\nconst ARROW_KEYS = new Set([\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"])\n\n/**\n * Determine the step factor for keyboard events\n */\nexport function getEventStep(event: KeyboardEvent) {\n if (event.ctrlKey || event.metaKey) {\n return 0.1\n } else {\n const isPageKey = PAGE_KEYS.has(event.key)\n const isSkipKey = isPageKey || (event.shiftKey && ARROW_KEYS.has(event.key))\n return isSkipKey ? 10 : 1\n }\n}\n", "export const visuallyHiddenStyle = {\n border: \"0\",\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0\",\n position: \"absolute\",\n width: \"1px\",\n whiteSpace: \"nowrap\",\n wordWrap: \"normal\",\n} as const\n\nexport function setVisuallyHidden(el: HTMLElement) {\n Object.assign(el.style, visuallyHiddenStyle)\n}\n", "import { setVisuallyHidden } from \"./visually-hidden\"\n\nexport type LiveRegionOptions = {\n level: \"polite\" | \"assertive\"\n doc?: Document\n root?: HTMLElement | null\n delay?: number\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n const { level = \"polite\", doc: ownerDocument, root, delay: rootDelay = 0 } = opts\n\n const doc = ownerDocument ?? document\n const win = doc.defaultView ?? window\n\n const parent = root ?? doc.body\n\n function announce(msg: string, delay?: number) {\n const oldRegion = doc.getElementById(\"__live-region__\")\n\n // remove old region\n if (!!oldRegion) {\n parent.removeChild(oldRegion)\n }\n\n // Did an override level get set?\n delay = delay ?? rootDelay\n\n // create fresh region\n const region = doc.createElement(\"span\")\n region.id = \"__live-region__\"\n\n // Determine redundant role\n var role = level !== \"assertive\" ? \"status\" : \"alert\"\n\n // add role and attributes\n region.setAttribute(\"aria-live\", level)\n region.setAttribute(\"role\", role)\n\n // hide live region\n setVisuallyHidden(region)\n\n parent.appendChild(region)\n\n // populate region to trigger it\n win.setTimeout(() => {\n region!.textContent = msg\n }, delay)\n }\n\n function destroy() {\n const oldRegion = doc.getElementById(\"__live-region__\")\n if (oldRegion) {\n parent.removeChild(oldRegion)\n }\n }\n\n return { announce, destroy }\n}\n", "import { noop } from \"@zag-js/utils\"\n\ntype Callback = (v: MutationRecord) => void\n\nexport function observeAttributes(node: Element | null, attributes: string | string[], fn: Callback) {\n if (!node) return noop\n const attrs = Array.isArray(attributes) ? attributes : [attributes]\n const win = node.ownerDocument.defaultView || window\n const obs = new win.MutationObserver((changes) => {\n for (const change of changes) {\n if (change.type === \"attributes\" && change.attributeName && attrs.includes(change.attributeName)) {\n fn(change)\n }\n }\n })\n\n obs.observe(node, { attributes: true, attributeFilter: attrs })\n\n return () => obs.disconnect()\n}\n\nexport function observeChildren(node: Element | null, fn: Callback, subtree = false) {\n if (!node) return noop\n const win = node.ownerDocument.defaultView || window\n const obs = new win.MutationObserver((changes) => {\n for (const change of changes) {\n if (change.type === \"childList\") {\n fn(change)\n }\n }\n })\n\n obs.observe(node, { childList: true, subtree })\n\n return () => obs.disconnect()\n}\n", "type Root = Document | Element | null | undefined\n\nexport function queryAll<T extends HTMLElement = HTMLElement>(root: Root, selector: string) {\n return Array.from(root?.querySelectorAll<T>(selector) ?? [])\n}\n\nexport function query<T extends HTMLElement = HTMLElement>(root: Root, selector: string) {\n return root?.querySelector<T>(selector)\n}\n\nexport function itemById<T extends HTMLElement>(v: T[], id: string) {\n return v.find((node) => node.id === id)\n}\n\nexport function indexOfId<T extends HTMLElement>(v: T[], id: string) {\n const item = itemById(v, id)\n return item ? v.indexOf(item) : -1\n}\n\nexport function nextById<T extends HTMLElement>(v: T[], id: string, loop = true) {\n let idx = indexOfId(v, id)\n idx = loop ? (idx + 1) % v.length : Math.min(idx + 1, v.length - 1)\n return v[idx]\n}\n\nexport function prevById<T extends HTMLElement>(v: T[], id: string, loop = true) {\n let idx = indexOfId(v, id)\n if (idx === -1) return loop ? v[v.length - 1] : null\n idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1)\n return v[idx]\n}\n\nexport function findByText<T extends HTMLElement>(v: T[], text: string, currentId?: string | null) {\n const filtered = v.filter((item) => {\n const str = item.dataset.valuetext ?? item.textContent\n return !!str?.toLowerCase().startsWith(text.toLowerCase())\n })\n return currentId ? nextById(filtered, currentId) : null\n}\n\nexport function sortByTreeOrder<T extends HTMLElement>(v: T[]) {\n return v.sort((a, b) => (a.compareDocumentPosition(b) & 2 ? 1 : -1))\n}\n", "// Credits: https://github.com/adobe/react-spectrum/blob/e81cfec20056338c7987c513826dc45df32f3db4/packages/%40react-aria/interactions/src/textSelection.ts\nimport { isIos } from \"@zag-js/utils\"\nimport { nextTick } from \"./next-tick\"\n\ntype State = \"default\" | \"disabled\" | \"restoring\"\n\nlet state: State = \"default\"\nlet savedUserSelect = \"\"\nlet modifiedElementMap = new WeakMap<HTMLElement, string>()\n\nexport function disableTextSelection({ target, doc }: { target?: HTMLElement; doc?: Document } = {}) {\n const _document = doc ?? document\n\n if (isIos()) {\n if (state === \"default\") {\n savedUserSelect = _document.documentElement.style.webkitUserSelect\n _document.documentElement.style.webkitUserSelect = \"none\"\n }\n\n state = \"disabled\"\n } else if (target) {\n modifiedElementMap.set(target, target.style.userSelect)\n target.style.userSelect = \"none\"\n }\n\n return () => restoreTextSelection({ target, doc: _document })\n}\n\nexport function restoreTextSelection({ target, doc }: { target?: HTMLElement; doc?: Document } = {}) {\n const _document = doc ?? document\n\n if (isIos()) {\n if (state !== \"disabled\") return\n state = \"restoring\"\n\n setTimeout(() => {\n nextTick(() => {\n if (state === \"restoring\") {\n if (_document.documentElement.style.webkitUserSelect === \"none\") {\n _document.documentElement.style.webkitUserSelect = savedUserSelect || \"\"\n }\n\n savedUserSelect = \"\"\n state = \"default\"\n }\n })\n }, 300)\n } else {\n if (target && modifiedElementMap.has(target)) {\n let targetOldUserSelect = modifiedElementMap.get(target)\n\n if (target.style.userSelect === \"none\") {\n target.style.userSelect = targetOldUserSelect ?? \"\"\n }\n\n if (target.getAttribute(\"style\") === \"\") {\n target.removeAttribute(\"style\")\n }\n modifiedElementMap.delete(target)\n }\n }\n}\n", "import { isLeftClick, isMouseEvent, pipe } from \"@zag-js/utils\"\nimport { addDomEvent, addPointerEvent } from \"./listener\"\nimport type { AnyPointerEvent, EventListenerWithPointInfo as Listener, PointerEventInfo } from \"./listener.types\"\nimport { disableTextSelection } from \"./text-selection\"\n\nexport function trackPointerDown(doc: Document, onPointerDown: (el: HTMLElement) => void) {\n const win = doc.defaultView ?? window\n const fn = (event: PointerEvent) => {\n if (event.target instanceof win.HTMLElement) {\n onPointerDown(event.target)\n }\n }\n return addDomEvent(doc, \"pointerdown\", fn)\n}\n\ntype TrackPointerMoveOptions = {\n ctx: { doc?: Document; threshold?: number }\n onPointerUp: VoidFunction\n onPointerMove: (info: PointerEventInfo, event: AnyPointerEvent) => void\n}\n\nexport function trackPointerMove(opts: TrackPointerMoveOptions) {\n const { onPointerMove, onPointerUp, ctx } = opts\n const { doc = document, threshold = 5 } = ctx\n\n const handlePointerMove: Listener = (event, info) => {\n const { point: p } = info\n const distance = Math.sqrt(p.x ** 2 + p.y ** 2)\n if (distance < threshold) return\n\n // Because Safari doesn't trigger mouseup events when it's above a `<select>`\n if (isMouseEvent(event) && isLeftClick(event)) {\n onPointerUp()\n return\n }\n\n onPointerMove(info, event)\n }\n\n return pipe(\n addPointerEvent(doc, \"pointermove\", handlePointerMove, false),\n addPointerEvent(doc, \"pointerup\", onPointerUp, false),\n addPointerEvent(doc, \"pointercancel\", onPointerUp, false),\n addPointerEvent(doc, \"contextmenu\", onPointerUp, false),\n disableTextSelection({ doc }),\n )\n}\n", "type PointerLockHandlers = {\n onPointerLock?: VoidFunction\n onPointerUnlock?: VoidFunction\n}\n\nexport function addPointerlockChangeListener(doc: Document, fn: VoidFunction) {\n doc.addEventListener(\"webkitpointerlockchange\", fn, false)\n doc.addEventListener(\"mozpointerlockchange\", fn, false)\n doc.addEventListener(\"pointerlockchange\", fn, false)\n return function cleaup() {\n doc.removeEventListener(\"mozpointerlockchange\", fn, false)\n doc.removeEventListener(\"pointerlockchange\", fn, false)\n }\n}\n\nexport function addPointerlockErrorListener(doc: Document, fn: (e: Event) => void) {\n doc.addEventListener(\"webkitpointerlockerror\", fn, false)\n doc.addEventListener(\"mozpointerlockerror\", fn, false)\n doc.addEventListener(\"pointerlockerror\", fn, false)\n return function cleanup() {\n doc.removeEventListener(\"webkitpointerlockerror\", fn, false)\n doc.removeEventListener(\"mozpointerlockerror\", fn, false)\n doc.removeEventListener(\"pointerlockerror\", fn, false)\n }\n}\n\nfunction getPointerlockFunc(el: HTMLElement) {\n return el.requestPointerLock || (el as any).mozRequestPointerLock || (el as any).webkitRequestPointerLock\n}\n\nfunction getRemovePointerlockFunc(doc: Document) {\n return doc.exitPointerLock || (doc as any).mozExitPointerLock || (doc as any).webkitExitPointerLock\n}\n\nexport function getPointerlockElement(doc: Document) {\n return doc.pointerLockElement || (doc as any).mozPointerLockElement || (doc as any).webkitPointerLockElement\n}\n\nexport function requestPointerLock(doc: Document, handlers: PointerLockHandlers = {}) {\n const { onPointerLock, onPointerUnlock } = handlers\n const body = doc.body\n\n function isSupported() {\n return \"pointerLockElement\" in doc || \"mozPointerLockElement\" in doc || \"webkitPointerLockElement\" in doc\n }\n\n function hasLockElement() {\n return !!doc.pointerLockElement\n }\n\n function onPointerChange() {\n if (hasLockElement()) onPointerLock?.()\n else onPointerUnlock?.()\n }\n\n function onPointerError(event: Event) {\n const isLocked = hasLockElement()\n if (isLocked) onPointerUnlock?.()\n console.error(\"PointerLock error occured:\", event)\n exit()\n }\n\n function exit() {\n doc.exitPointerLock = getRemovePointerlockFunc(doc)\n doc.exitPointerLock()\n }\n\n const cleanups: Set<Function> = new Set()\n\n function addEventListeners() {\n cleanups.add(addPointerlockChangeListener(doc, onPointerChange))\n cleanups.add(addPointerlockErrorListener(doc, onPointerError))\n }\n\n function dispose() {\n if (!isSupported()) return\n cleanups.forEach((fn) => fn())\n cleanups.clear()\n exit()\n }\n\n function setup() {\n if (!isSupported()) return\n body.requestPointerLock = getPointerlockFunc(body)\n body.requestPointerLock()\n addEventListeners()\n }\n\n setup()\n return dispose\n}\n", "// Credit goes to the radix-ui team for this utility:\n// https://github.com/radix-ui/primitives/blob/main/packages/core/rect/src/observeElementRect.ts\n\ntype Fn = (rect: DOMRect) => void\ntype ObservedData = { rect: DOMRect; callbacks: Fn[] }\nexport type Measurable = { getBoundingClientRect(): DOMRect }\n\nconst observedElements: Map<Measurable, ObservedData> = new Map()\n\nexport function observeElementRect(el: Measurable, fn: Fn) {\n const data = observedElements.get(el)\n\n if (!data) {\n observedElements.set(el, { rect: {} as DOMRect, callbacks: [fn] })\n\n if (observedElements.size === 1) {\n rafId = requestAnimationFrame(runLoop)\n }\n } else {\n data.callbacks.push(fn)\n fn(el.getBoundingClientRect())\n }\n\n return function unobserve() {\n const data = observedElements.get(el)\n if (!data) return\n\n const index = data.callbacks.indexOf(fn)\n if (index > -1) {\n data.callbacks.splice(index, 1)\n }\n\n if (data.callbacks.length === 0) {\n observedElements.delete(el)\n\n if (observedElements.size === 0) {\n cancelAnimationFrame(rafId)\n }\n }\n }\n}\n\nlet rafId: number\n\nfunction runLoop() {\n const changedRectsData: Array<ObservedData> = []\n\n observedElements.forEach((data, element) => {\n const newRect = element.getBoundingClientRect()\n\n if (!isEqual(data.rect, newRect)) {\n data.rect = newRect\n changedRectsData.push(data)\n }\n })\n\n changedRectsData.forEach((data) => {\n data.callbacks.forEach((callback) => callback(data.rect))\n })\n\n rafId = requestAnimationFrame(runLoop)\n}\n\nfunction isEqual(rect1: DOMRect, rect2: DOMRect) {\n return (\n rect1.width === rect2.width &&\n rect1.height === rect2.height &&\n rect1.top === rect2.top &&\n rect1.right === rect2.right &&\n rect1.bottom === rect2.bottom &&\n rect1.left === rect2.left\n )\n}\n", "import { cast } from \"@zag-js/utils\"\nimport { addDomEvent } from \"./listener\"\n\nexport function trackDocumentVisibility(_doc: Document, callback: (hidden: boolean) => void) {\n const doc = cast(_doc) as Document & { msHidden?: boolean; webkitHidden?: boolean }\n return addDomEvent(doc, \"visibilitychange\", () => {\n const hidden = doc.hidden || doc.msHidden || doc.webkitHidden\n callback(!!hidden)\n })\n}\n", "export function waitUntil(predicate: () => boolean) {\n if (predicate()) return Promise.resolve(true)\n return new Promise((resolve) => {\n const id = globalThis.setInterval(function () {\n if (predicate()) {\n globalThis.clearInterval(id)\n resolve(true)\n }\n }, 0)\n })\n}\n\nexport function waitForEvent(el: HTMLElement, eventName: string) {\n return new Promise<void>((resolve) => {\n function done(event: Event) {\n if (event.target === el) {\n el.removeEventListener(eventName, done)\n resolve()\n }\n }\n\n el.addEventListener(eventName, done)\n })\n}\n", "import { createMachine, guards } from \"@zag-js/core\"\nimport { trackDocumentVisibility } from \"@zag-js/dom-utils\"\nimport { dom } from \"./toast.dom\"\nimport { MachineContext, MachineState, Options } from \"./toast.types\"\nimport { getToastDuration } from \"./toast.utils\"\n\nconst { not, and, or } = guards\n\nexport function createToastMachine(options: Options = {}) {\n const { type = \"info\", duration, id = \"toast\", placement = \"bottom\", removeDelay = 500, ...rest } = options\n const __duration = getToastDuration(duration, type)\n\n return createMachine<MachineContext, MachineState>(\n {\n id,\n entry: \"invokeOnOpen\",\n initial: type === \"loading\" ? \"persist\" : \"active\",\n context: {\n id,\n type,\n remaining: __duration,\n duration: __duration,\n removeDelay,\n createdAt: Date.now(),\n placement,\n ...rest,\n },\n\n on: {\n UPDATE: [\n {\n guard: and(\"hasTypeChanged\", \"isChangingToLoading\"),\n target: \"persist\",\n actions: [\"setContext\", \"invokeOnUpdate\"],\n },\n {\n guard: or(\"hasDurationChanged\", \"hasTypeChanged\"),\n target: \"active:temp\",\n actions: [\"setContext\", \"invokeOnUpdate\"],\n },\n {\n actions: [\"setContext\", \"invokeOnUpdate\"],\n },\n ],\n },\n\n states: {\n \"active:temp\": {\n tags: [\"visible\", \"updating\"],\n after: {\n 0: \"active\",\n },\n },\n\n persist: {\n tags: [\"visible\", \"paused\"],\n activities: \"trackDocumentVisibility\",\n on: {\n RESUME: {\n guard: not(\"isLoadingType\"),\n target: \"active\",\n actions: [\"setCreatedAt\"],\n },\n DISMISS: \"dismissing\",\n },\n },\n\n active: {\n tags: [\"visible\"],\n activities: \"trackDocumentVisibility\",\n after: {\n VISIBLE_DURATION: \"dismissing\",\n },\n on: {\n DISMISS: \"dismissing\",\n PAUSE: {\n target: \"persist\",\n actions: \"setRemainingDuration\",\n },\n },\n },\n\n dismissing: {\n entry: \"invokeOnClosing\",\n after: {\n REMOVE_DELAY: {\n target: \"inactive\",\n actions: \"notifyParentToRemove\",\n },\n },\n },\n\n inactive: {\n entry: \"invokeOnClose\",\n type: \"final\",\n },\n },\n },\n {\n activities: {\n trackDocumentVisibility(ctx, _evt, { send }) {\n if (!ctx.pauseOnPageIdle) return\n return trackDocumentVisibility(dom.getDoc(ctx), function (hidden) {\n send(hidden ? \"PAUSE\" : \"RESUME\")\n })\n },\n },\n\n guards: {\n isChangingToLoading: (_, evt) => evt.toast?.type === \"loading\",\n isLoadingType: (ctx) => ctx.type === \"loading\",\n hasTypeChanged: (ctx, evt) => evt.toast?.type !== ctx.type,\n hasDurationChanged: (ctx, evt) => evt.toast?.duration !== ctx.duration,\n },\n\n delays: {\n VISIBLE_DURATION: (ctx) => ctx.remaining,\n REMOVE_DELAY: (ctx) => ctx.removeDelay,\n },\n\n actions: {\n setRemainingDuration(ctx) {\n ctx.remaining -= Date.now() - ctx.createdAt\n },\n setCreatedAt(ctx) {\n ctx.createdAt = Date.now()\n },\n notifyParentToRemove(_ctx, _evt, { self }) {\n self.sendParent({ type: \"REMOVE_TOAST\", id: self.id })\n },\n invokeOnClosing(ctx) {\n ctx.onClosing?.()\n },\n invokeOnClose(ctx) {\n ctx.onClose?.()\n },\n invokeOnOpen(ctx) {\n ctx.onOpen?.()\n },\n invokeOnUpdate(ctx) {\n ctx.onUpdate?.()\n },\n setContext(ctx, evt) {\n const { duration, type } = evt.toast\n const time = getToastDuration(duration, type)\n Object.assign(ctx, { ...evt.toast, duration: time, remaining: time })\n },\n },\n },\n )\n}\n", "import { StateMachine as S } from \"@zag-js/core\"\nimport { dataAttr } from \"@zag-js/dom-utils\"\nimport { normalizeProp, PropTypes, ReactPropTypes } from \"@zag-js/types\"\nimport { dom } from \"./toast.dom\"\nimport { MachineContext, MachineState } from \"./toast.types\"\n\nexport function connect<T extends PropTypes = ReactPropTypes>(\n state: S.State<MachineContext, MachineState>,\n send: (event: S.Event<S.AnyEventObject>) => void,\n normalize = normalizeProp,\n) {\n const isVisible = state.hasTag(\"visible\")\n const isPaused = state.hasTag(\"paused\")\n const isUpdating = state.hasTag(\"updating\")\n\n const isRtl = state.context.dir === \"rtl\"\n const type = state.context.type\n\n const pauseOnInteraction = state.context.pauseOnInteraction\n const placement = state.context.placement\n\n return {\n type: state.context.type,\n title: state.context.title,\n placement,\n isVisible,\n isPaused,\n pause() {\n send(\"PAUSE\")\n },\n resume() {\n send(\"RESUME\")\n },\n dismiss() {\n send(\"DISMISS\")\n },\n\n rootProps: normalize.element<T>({\n \"data-part\": \"root\",\n dir: state.context.dir,\n id: dom.getContainerId(state.context),\n \"data-open\": dataAttr(isVisible),\n \"data-type\": state.context.type,\n \"data-placement\": placement,\n role: \"status\",\n \"aria-atomic\": \"true\",\n tabIndex: 0,\n style: {\n position: \"relative\",\n pointerEvents: \"auto\",\n margin: \"calc(var(--toast-gutter) / 2)\",\n \"--remove-delay\": `${state.context.removeDelay}ms`,\n \"--duration\": `${state.context.duration}ms`,\n },\n onKeyDown(event) {\n if (event.key == \"Escape\") {\n send(\"DISMISS\")\n event.preventDefault()\n event.stopPropagation()\n }\n },\n onFocus() {\n if (pauseOnInteraction) {\n send(\"PAUSE\")\n }\n },\n onBlur() {\n if (pauseOnInteraction) {\n send(\"RESUME\")\n }\n },\n onPointerEnter() {\n if (pauseOnInteraction) {\n send(\"PAUSE\")\n }\n },\n onPointerLeave() {\n if (pauseOnInteraction) {\n send(\"RESUME\")\n }\n },\n }),\n\n progressbarProps: normalize.element<T>({\n \"data-part\": \"progressbar\",\n \"data-type\": state.context.type,\n style: {\n opacity: isVisible ? 1 : 0,\n transformOrigin: isRtl ? \"right\" : \"left\",\n animationName: isUpdating || type === \"loading\" ? \"none\" : undefined,\n animationPlayState: isPaused ? \"paused\" : \"running\",\n animationDuration: `${state.context.duration}ms`,\n animationFillMode: isUpdating ? undefined : \"forwards\",\n },\n }),\n\n titleProps: normalize.element<T>({\n \"data-part\": \"title\",\n id: dom.getTitleId(state.context),\n }),\n\n closeButtonProps: normalize.button<T>({\n id: dom.getCloseButtonId(state.context),\n \"data-part\": \"close-button\",\n type: \"button\",\n \"aria-label\": \"Dismiss notification\",\n onClick() {\n send(\"DISMISS\")\n },\n }),\n\n render() {\n return state.context.render?.({\n id: state.context.id,\n type: state.context.type,\n duration: state.context.duration,\n title: state.context.title,\n placement: state.context.placement,\n description: state.context.description,\n dismiss() {\n send(\"DISMISS\")\n },\n })\n },\n }\n}\n", "import { isDom, warn } from \"@zag-js/utils\"\nimport { groupConnect, toaster } from \"./toast-group.connect\"\nimport { groupMachine } from \"./toast-group.machine\"\nimport { createToastMachine as createMachine } from \"./toast.machine\"\n\nexport { connect } from \"./toast.connect\"\nexport type { GroupMachineContext, MachineContext, MachineState, Placement, Service, Type } from \"./toast.types\"\nexport { createMachine }\n\nexport const group = {\n connect: groupConnect,\n machine: groupMachine,\n}\n\nexport function api() {\n if (!isDom()) {\n warn(\"toast.api() is only available in the browser\")\n } else {\n return toaster\n }\n}\n"],
|
|
5
|
+
"mappings": "+kBCAO,GAAM,GAAU,CACrB,KACG,IAC+E,CAClF,GAAM,GAAM,MAAO,IAAM,WAAa,EAAE,GAAG,GAAK,EAChD,MAAO,IAAA,KAAA,EAAO,QALT,GAyBM,IAAsB,KAAM,CACvC,GAAI,GAAK,EACT,MAAO,IACL,KACO,EAAG,SAAS,SC7BvB,GAIa,GAAQ,IAAS,MAAO,SAAW,YCFzC,cAAiB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AAK,UAGT,gBAAiB,CACf,AAAI,GACF,EAAK,aAKX,iBAAkB,EAAU,QAAW,CACrC,YAAa,cACb,YAAa,EAAM,QAAQ,KAC3B,MAAO,CACL,QAAS,EAAY,EAAI,EACzB,gBAAiB,EAAQ,QAAU,OACnC,cAAe,GAAc,IAAS,UAAY,OAAS,OAC3D,mBAAoB,EAAW,SAAW,UAC1C,kBAAmB,GAAG,EAAM,QAAQ,aACpC,kBAAmB,EAAa,OAAY,cAIhD,WAAY,EAAU,QAAW,CAC/B,YAAa,QACb,GAAI,EAAI,WAAW,EAAM,WAG3B,iBAAkB,EAAU,OAAU,CACpC,GAAI,EAAI,iBAAiB,EAAM,SAC/B,YAAa,eACb,KAAM,SACN,aAAc,uBACd,SAAU,CACR,EAAK,cAIT,QAAS,CA/Gb,QAgHM,MAAO,QAAM,SAAQ,SAAd,qBAAuB,CAC5B,GAAI,EAAM,QAAQ,GAClB,KAAM,EAAM,QAAQ,KACpB,SAAU,EAAM,QAAQ,SACxB,MAAO,EAAM,QAAQ,MACrB,UAAW,EAAM,QAAQ,UACzB,YAAa,EAAM,QAAQ,YAC3B,SAAU,CACR,EAAK,gBC/GR,GAAM,IAAQ,CACnB,QAAS,EACT,QAAS,GAGJ,aAAe,CACpB,GAAI,CAAC,IACH,EAAK,oDAEL,OAAO",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StateMachine as S } from "@zag-js/core";
|
|
2
|
+
import { PropTypes, ReactPropTypes } from "@zag-js/types";
|
|
3
|
+
import { Toaster, GroupProps, GroupMachineContext, Options, Placement, PromiseMessages, PromiseOptions } from "./toast.types";
|
|
4
|
+
export declare let toaster: Toaster;
|
|
5
|
+
export declare function groupConnect<T extends PropTypes = ReactPropTypes>(state: S.State<GroupMachineContext>, send: (event: S.Event<S.AnyEventObject>) => void, normalize?: import("@zag-js/types").NormalizeProps): {
|
|
6
|
+
count: number;
|
|
7
|
+
toasts: import("./toast.types").Service[];
|
|
8
|
+
toastsByPlacement: Partial<Record<Placement, import("./toast.types").Service[]>>;
|
|
9
|
+
isVisible(id: string): boolean;
|
|
10
|
+
create(options: Options): string;
|
|
11
|
+
upsert(options: Options): string;
|
|
12
|
+
dismiss(id?: string): void;
|
|
13
|
+
remove(id?: string): void;
|
|
14
|
+
dismissByPlacement(placement: Placement): void;
|
|
15
|
+
update(id: string, options: Options): string;
|
|
16
|
+
loading(options: Options): string;
|
|
17
|
+
success(options: Options): string;
|
|
18
|
+
error(options: Options): string;
|
|
19
|
+
promise<T_1>(promise: Promise<T_1>, msgs: PromiseMessages, opts?: PromiseOptions): Promise<T_1>;
|
|
20
|
+
pause(id?: string): void;
|
|
21
|
+
resume(id?: string): void;
|
|
22
|
+
getGroupProps(options: GroupProps): T["element"];
|
|
23
|
+
createPortal(): HTMLElement;
|
|
24
|
+
subscribe(fn: (toasts: GroupMachineContext["toasts"]) => void): () => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StateMachine as S } from "@zag-js/core";
|
|
2
|
+
import { PropTypes, ReactPropTypes } from "@zag-js/types";
|
|
3
|
+
import { MachineContext, MachineState } from "./toast.types";
|
|
4
|
+
export declare function connect<T extends PropTypes = ReactPropTypes>(state: S.State<MachineContext, MachineState>, send: (event: S.Event<S.AnyEventObject>) => void, normalize?: import("@zag-js/types").NormalizeProps): {
|
|
5
|
+
type: import("./toast.types").Type;
|
|
6
|
+
title: string;
|
|
7
|
+
placement: import("./toast.types").Placement;
|
|
8
|
+
isVisible: boolean;
|
|
9
|
+
isPaused: boolean;
|
|
10
|
+
pause(): void;
|
|
11
|
+
resume(): void;
|
|
12
|
+
dismiss(): void;
|
|
13
|
+
rootProps: T["element"];
|
|
14
|
+
progressbarProps: T["element"];
|
|
15
|
+
titleProps: T["element"];
|
|
16
|
+
closeButtonProps: T["button"];
|
|
17
|
+
render(): any;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GroupMachineContext as GroupCtx, MachineContext as Ctx, Placement } from "./toast.types";
|
|
2
|
+
export declare const dom: {
|
|
3
|
+
getDoc: (ctx: Ctx | GroupCtx) => Document;
|
|
4
|
+
getGroupId: (placement: Placement) => string;
|
|
5
|
+
getContainerId: (ctx: Ctx) => string;
|
|
6
|
+
getTitleId: (ctx: Ctx) => string;
|
|
7
|
+
getCloseButtonId: (ctx: Ctx) => string;
|
|
8
|
+
getPortalId: (ctx: GroupCtx) => string;
|
|
9
|
+
getPortalEl: (ctx: GroupCtx) => HTMLElement;
|
|
10
|
+
createPortalEl: (ctx: GroupCtx) => HTMLElement;
|
|
11
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Machine } from "@zag-js/core";
|
|
2
|
+
import { Context, Direction } from "@zag-js/types";
|
|
3
|
+
export declare type Type = "success" | "error" | "loading" | "info" | "custom";
|
|
4
|
+
export declare type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
|
|
5
|
+
declare type SharedContext = {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to pause toast when the user leaves the browser tab
|
|
8
|
+
*/
|
|
9
|
+
pauseOnPageIdle?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to pause the toast when interacted with
|
|
12
|
+
*/
|
|
13
|
+
pauseOnInteraction?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare type RenderOptions = Omit<ToastOptions, "render"> & {
|
|
16
|
+
dismiss(): void;
|
|
17
|
+
};
|
|
18
|
+
declare type ToastOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* The unique id of the toast
|
|
21
|
+
*/
|
|
22
|
+
id: string;
|
|
23
|
+
/**
|
|
24
|
+
* The type of the toast
|
|
25
|
+
*/
|
|
26
|
+
type: Type;
|
|
27
|
+
/**
|
|
28
|
+
* The placement of the toast
|
|
29
|
+
*/
|
|
30
|
+
placement: Placement;
|
|
31
|
+
/**
|
|
32
|
+
* The message of the toast
|
|
33
|
+
*/
|
|
34
|
+
title?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The description of the toast
|
|
37
|
+
*/
|
|
38
|
+
description?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The duration the toast will be visible
|
|
41
|
+
*/
|
|
42
|
+
duration: number;
|
|
43
|
+
/**
|
|
44
|
+
* Custom function to render the toast element.
|
|
45
|
+
*/
|
|
46
|
+
render?: (options: RenderOptions) => any;
|
|
47
|
+
};
|
|
48
|
+
export declare type MachineContext = SharedContext & ToastOptions & {
|
|
49
|
+
/**
|
|
50
|
+
* The unique id of the toast
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
/**
|
|
54
|
+
* @internal The owner document of the toast
|
|
55
|
+
*/
|
|
56
|
+
doc?: Document;
|
|
57
|
+
/**
|
|
58
|
+
* The document's text/writing direction.
|
|
59
|
+
*/
|
|
60
|
+
dir?: Direction;
|
|
61
|
+
/**
|
|
62
|
+
* The duration for the toast to kept alive before it is removed.
|
|
63
|
+
* Useful for exit transitions.
|
|
64
|
+
*/
|
|
65
|
+
removeDelay: number;
|
|
66
|
+
/**
|
|
67
|
+
* The time the toast was created
|
|
68
|
+
*/
|
|
69
|
+
createdAt: number;
|
|
70
|
+
/**
|
|
71
|
+
* The time left before the toast is removed
|
|
72
|
+
*/
|
|
73
|
+
remaining: number;
|
|
74
|
+
/**
|
|
75
|
+
* Function called when the toast has been closed and removed
|
|
76
|
+
*/
|
|
77
|
+
onClose?: VoidFunction;
|
|
78
|
+
/**
|
|
79
|
+
* Function called when the toast is leaving
|
|
80
|
+
*/
|
|
81
|
+
onClosing?: VoidFunction;
|
|
82
|
+
/**
|
|
83
|
+
* Function called when the toast is shown
|
|
84
|
+
*/
|
|
85
|
+
onOpen?: VoidFunction;
|
|
86
|
+
/**
|
|
87
|
+
* Function called when the toast is updated
|
|
88
|
+
*/
|
|
89
|
+
onUpdate?: VoidFunction;
|
|
90
|
+
};
|
|
91
|
+
export declare type Options = Partial<Omit<MachineContext, "progress">>;
|
|
92
|
+
export declare type MachineState = {
|
|
93
|
+
value: "active" | "active:temp" | "dismissing" | "inactive" | "persist";
|
|
94
|
+
tags: "visible" | "paused" | "updating";
|
|
95
|
+
};
|
|
96
|
+
export declare type Service = Machine<MachineContext, MachineState>;
|
|
97
|
+
export declare type GroupMachineContext = SharedContext & Context<{
|
|
98
|
+
/**
|
|
99
|
+
* @internal The child toast machines (spawned by the toast group)
|
|
100
|
+
*/
|
|
101
|
+
toasts: Service[];
|
|
102
|
+
/**
|
|
103
|
+
* @internal The total number of toasts in the group
|
|
104
|
+
*/
|
|
105
|
+
readonly count: number;
|
|
106
|
+
/**
|
|
107
|
+
* The gutter or spacing between toasts
|
|
108
|
+
*/
|
|
109
|
+
gutter: string;
|
|
110
|
+
/**
|
|
111
|
+
* The z-index applied to each toast group
|
|
112
|
+
*/
|
|
113
|
+
zIndex: number;
|
|
114
|
+
/**
|
|
115
|
+
* The maximum number of toasts that can be shown at once
|
|
116
|
+
*/
|
|
117
|
+
max: number;
|
|
118
|
+
/**
|
|
119
|
+
* The offset from the safe environment edge of the viewport
|
|
120
|
+
*/
|
|
121
|
+
offsets: string | Record<"left" | "right" | "bottom" | "top", string>;
|
|
122
|
+
}>;
|
|
123
|
+
declare type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
|
|
124
|
+
export declare type PromiseMessages<Value = any> = {
|
|
125
|
+
loading: Value;
|
|
126
|
+
success: MaybeFunction<Value, Options>;
|
|
127
|
+
error: MaybeFunction<Value, Options>;
|
|
128
|
+
};
|
|
129
|
+
export declare type PromiseOptions = Options & {
|
|
130
|
+
[key in "success" | "loading" | "error"]?: Options;
|
|
131
|
+
};
|
|
132
|
+
export declare type GroupProps = {
|
|
133
|
+
placement: Placement;
|
|
134
|
+
label?: string;
|
|
135
|
+
};
|
|
136
|
+
export declare type Toaster = {
|
|
137
|
+
count: number;
|
|
138
|
+
isVisible(id: string): boolean;
|
|
139
|
+
upsert(options: Options): string | undefined;
|
|
140
|
+
create(options: Options): string | undefined;
|
|
141
|
+
success(options: Options): string | undefined;
|
|
142
|
+
error(options: Options): string | undefined;
|
|
143
|
+
loading(options: Options): string | undefined;
|
|
144
|
+
dismiss(id?: string | undefined): void;
|
|
145
|
+
remove(id?: string | undefined): void;
|
|
146
|
+
promise<T>(promise: Promise<T>, msgs: PromiseMessages, opts?: PromiseOptions): Promise<T>;
|
|
147
|
+
};
|
|
148
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Style } from "@zag-js/types";
|
|
2
|
+
import { GroupMachineContext, MachineContext, Placement, Service, Type } from "./toast.types";
|
|
3
|
+
export declare function getToastsByPlacement(toasts: Service[]): Partial<Record<Placement, Service[]>>;
|
|
4
|
+
export declare const defaultTimeouts: Record<Type, number>;
|
|
5
|
+
export declare function getToastDuration(duration: number | undefined, type: MachineContext["type"]): number;
|
|
6
|
+
export declare function getGroupPlacementStyle(ctx: GroupMachineContext, placement: Placement): Style;
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zag-js/toast",
|
|
3
|
+
"version": "0.0.0-dev-20220406144843",
|
|
4
|
+
"description": "Core logic for the toast widget implemented as a state machine",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"js",
|
|
7
|
+
"machine",
|
|
8
|
+
"xstate",
|
|
9
|
+
"statechart",
|
|
10
|
+
"component",
|
|
11
|
+
"chakra-ui",
|
|
12
|
+
"toast"
|
|
13
|
+
],
|
|
14
|
+
"author": "Segun Adebayo <sage@adebayosegun.com>",
|
|
15
|
+
"homepage": "https://github.com/chakra-ui/ui-machines#readme",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"module": "dist/index.mjs",
|
|
20
|
+
"repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/toast",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/chakra-ui/ui-machines/issues"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@zag-js/core": "^0.0.0-dev-20220406144843",
|
|
33
|
+
"@zag-js/dom-utils": "^0.0.0-dev-20220406144843",
|
|
34
|
+
"@zag-js/types": "^0.0.0-dev-20220406144843",
|
|
35
|
+
"@zag-js/utils": "^0.0.0-dev-20220406144843"
|
|
36
|
+
}
|
|
37
|
+
}
|