@inertiaui/modal-react 1.0.0-beta-1 → 1.0.0-beta-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/inertiaui-modal.js +509 -496
- package/dist/inertiaui-modal.umd.cjs +5 -5
- package/package.json +2 -2
- package/src/ModalRoot.jsx +25 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(M,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core","react-dom"],o):(M=typeof globalThis<"u"?globalThis:M||self,o(M.InertiaUIModal={},M.React,M.jsxRuntime,M.Axios,M.react,M.core,M.ReactDOM))})(this,function(M,o,S,Ce,ie,Pr,Tr){"use strict";var Kl=Object.defineProperty;var Yl=(M,o,S)=>o in M?Kl(M,o,{enumerable:!0,configurable:!0,writable:!0,value:S}):M[o]=S;var V=(M,o,S)=>Yl(M,typeof o!="symbol"?o+"":o,S);function kr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const pe=kr(o),he={type:"modal",navigate:!1,modal:{closeButton:!0,closeExplicitly:!1,maxWidth:"2xl",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white rounded",position:"center"},slideover:{closeButton:!0,closeExplicitly:!1,maxWidth:"md",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white min-h-screen",position:"right"}};class Fr{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(he))}put(t,r){if(typeof t=="object"){this.config={type:t.type??he.type,navigate:t.navigate??he.navigate,modal:{...he.modal,...t.modal??{}},slideover:{...he.slideover,...t.slideover??{}}};return}const n=t.split(".");let l=this.config;for(let i=0;i<n.length-1;i++)l=l[n[i]]=l[n[i]]||{};l[n[n.length-1]]=r}get(t){if(typeof t>"u")return this.config;const r=t.split(".");let n=this.config;for(const l of r){if(n[l]===void 0)return null;n=n[l]}return n}}const Pe=new Fr,Lr=()=>Pe.reset(),Ar=(e,t)=>Pe.put(e,t),Te=e=>Pe.get(e),se=(e,t)=>Pe.get(e?`slideover.${t}`:`modal.${t}`);function Ir(e,t){return e=typeof e=="string"?new URL(e,window.location.origin):e,t=typeof t=="string"?new URL(t,window.location.origin):t,`${e.origin}${e.pathname}`==`${t.origin}${t.pathname}`}function Qe(e="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}${crypto.randomUUID()}`:`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function ue(e){return typeof e=="string"?e.toLowerCase():e}function Nr(e,t,r=!1){return r&&(t=t.map(ue)),Array.isArray(e)?e.filter(n=>!t.includes(r?ue(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?ue(l):l)||(n[l]=e[l]),n),{})}function Dr(e,t,r=!1){return r&&(t=t.map(ue)),Array.isArray(e)?e.filter(n=>t.includes(r?ue(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?ue(l):l)&&(n[l]=e[l]),n),{})}function jr(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,r)=>(r in e&&e[r]!==null&&(t[r]=e[r]),t),{})}function ve(e){return e?(e=e.replace(/_/g,"-"),e=e.replace(/-+/g,"-"),/[A-Z]/.test(e)?(e=e.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(t,r)=>r.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const ke=o.createContext(null);ke.displayName="ModalStackContext";let Ot=null,Mt=null,ae=null,Fe={},Re=[],de={};const Ct=({children:e})=>{const[t,r]=o.useState([]),[n,l]=o.useState({}),i=v=>{r(c=>{const f=v([...c]),g=y=>{var p;return f.length<2?!0:((p=f.map(x=>({id:x.id,shouldRender:x.shouldRender})).reverse().find(x=>x.shouldRender))==null?void 0:p.id)===y};return f.forEach((y,p)=>{f[p].onTopOfStack=g(y.id),f[p].getParentModal=()=>p<1?null:f.slice(0,p).reverse().find(x=>x.isOpen),f[p].getChildModal=()=>p===f.length-1?null:f.slice(p+1).find(x=>x.isOpen)}),f})};o.useEffect(()=>{Re=t},[t]);class a{constructor(c,f,g,y,p){V(this,"show",()=>{i(c=>c.map(f=>(f.id===this.id&&!f.isOpen&&(f.isOpen=!0,f.shouldRender=!0),f)))});V(this,"setOpen",c=>{c?this.show():this.close()});V(this,"close",()=>{i(c=>{let f=!1;const g=c.map(y=>{var p;return y.id===this.id&&y.isOpen&&(Object.keys(y.listeners).forEach(x=>{y.off(x)}),y.isOpen=!1,(p=y.onCloseCallback)==null||p.call(y),f=!0),y});return f?g:c})});V(this,"afterLeave",()=>{this.isOpen||i(c=>{const f=c.map(g=>{var y;return g.id===this.id&&!g.isOpen&&(g.shouldRender=!1,(y=g.afterLeaveCallback)==null||y.call(g),g.afterLeaveCallback=null),g});return this.index===0?[]:f})});V(this,"on",(c,f)=>{c=ve(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(f)});V(this,"off",(c,f)=>{var g;c=ve(c),f?this.listeners[c]=((g=this.listeners[c])==null?void 0:g.filter(y=>y!==f))??[]:delete this.listeners[c]});V(this,"emit",(c,...f)=>{var g;(g=this.listeners[ve(c)])==null||g.forEach(y=>y(...f))});V(this,"registerEventListenersFromProps",c=>{const f=[];return Object.keys(c).filter(g=>g.startsWith("on")).forEach(g=>{const y=ve(g).replace(/^on-/,"");this.on(y,c[g]),f.push(()=>this.off(y,c[g]))}),()=>f.forEach(g=>g())});V(this,"reload",(c={})=>{var p,x;let f=Object.keys(this.response.props);if(c.only&&(f=c.only),c.except&&(f=Nr(f,c.except)),!((p=this.response)!=null&&p.url))return;const g=(c.method??"get").toLowerCase(),y=c.data??{};(x=c.onStart)==null||x.call(c),Ce({url:this.response.url,method:g,data:g==="get"?{}:y,params:g==="get"?y:{},headers:{...c.headers??{},Accept:"text/html, application/xhtml+xml","X-Inertia":!0,"X-Inertia-Partial-Component":this.response.component,"X-Inertia-Version":this.response.version,"X-Inertia-Partial-Data":f.join(","),"X-InertiaUI-Modal":Qe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":ae}}).then(O=>{var F;this.updateProps(O.data.props),(F=c.onSuccess)==null||F.call(c,O)}).catch(O=>{var F;(F=c.onError)==null||F.call(c,O)}).finally(()=>{var O;(O=c.onFinish)==null||O.call(c)})});V(this,"updateProps",c=>{Object.assign(this.props,c),i(f=>f)});if(this.id=f.id??Qe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=f.props,this.response=f,this.config=g??{},this.onCloseCallback=y,this.afterLeaveCallback=p,de[this.id]){this.config={...this.config,...de[this.id].config??{}};const x=de[this.id].onClose,O=de[this.id].onAfterLeave;x&&(this.onCloseCallback=y?()=>{y(),x()}:x),O&&(this.afterLeaveCallback=p?()=>{p(),O()}:O),delete de[this.id]}this.index=-1,this.getParentModal=()=>null,this.getChildModal=()=>null,this.onTopOfStack=!0}static generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`inertiaui_modal_${crypto.randomUUID()}`:`inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}}const u=(v,c={},f=null,g=null)=>Mt(v.component).then(y=>d(y,v,c,f,g)),s=v=>{var f,g;const c=(g=(f=v.response)==null?void 0:f.meta)==null?void 0:g.deferredProps;c&&Object.keys(c).forEach(y=>{v.reload({only:c[y]})})},d=(v,c,f,g,y)=>{const p=new a(v,c,f,g,y);return p.index=t.length,i(x=>[...x,p]),s(p),p.show(),p};function h(v,c,f,g){if(!n[v])throw new Error(`The local modal "${v}" has not been registered.`);const y=d(null,{},c,f,g);return y.name=v,n[v].callback(y),y}const b=(v,c={})=>E(v,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??Te("navigate")).then(f=>{const g=c.listeners??{};return Object.keys(g).forEach(y=>{const p=ve(y);f.on(p,g[y])}),f}),E=(v,c,f={},g={},y={},p=null,x=null,O="brackets",F=!1)=>{const U=Qe();return new Promise((k,D)=>{if(v.startsWith("#")){k(h(v.substring(1),y,p,x));return}const[H,A]=Pr.mergeDataIntoQueryString(c,v||"",f,O);let T=F&&t.length===0;if(t.length===0&&(ae=typeof window<"u"?window.location.href:""),g={...g,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":Ot,"X-InertiaUI-Modal":U,"X-InertiaUI-Modal-Use-Router":T?1:0,"X-InertiaUI-Modal-Base-Url":ae},T)return Fe={},de[U]={config:y,onClose:p,onAfterLeave:x},ie.router.visit(H,{method:c,data:A,headers:g,preserveScroll:!0,preserveState:!0,onError:D,onBefore:()=>{Fe[U]=k}});Ce({url:H,method:c,data:A,headers:g}).then(I=>k(u(I.data,y,p,x))).catch(I=>{D(I)})})},$={stack:t,localModals:n,push:d,pushFromResponseData:u,length:()=>Re.length,closeAll:()=>{Re.reverse().forEach(v=>v.close())},reset:()=>i(()=>[]),visit:E,visitModal:b,registerLocalModal:(v,c)=>{l(f=>({...f,[v]:{name:v,callback:c}}))},removeLocalModal:v=>{l(c=>{const f={...c};return delete f[v],f})},onModalOnBase:v=>{const c=Fe[v.id];c&&(c(v),delete Fe[v.id])}};return S.jsx(ke.Provider,{value:$,children:e})},ge=()=>{const e=o.useContext(ke);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},Pt=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],Tt=e=>{e.initialPage&&(Ot=e.initialPage.version),e.resolveComponent&&(Mt=e.resolveComponent)},_r=(e,t)=>{Tt(t);const r=({Component:n,props:l,key:i})=>{const a=()=>{const u=o.createElement(n,{key:i,...l});return typeof n.layout=="function"?n.layout(u):Array.isArray(n.layout)?n.layout.concat(u).reverse().reduce((d,h)=>o.createElement(h,l,d)):u};return S.jsxs(S.Fragment,{children:[a(),S.jsx(kt,{})]})};return S.jsx(Ct,{children:S.jsx(e,{...t,children:r})})},kt=({children:e})=>{var s,d;const t=o.useContext(ke),r=ie.usePage();let n=!1,l=!1,i=!!((s=r.props)!=null&&s._inertiaui_modal);o.useEffect(()=>ie.router.on("start",()=>n=!0),[]),o.useEffect(()=>ie.router.on("finish",()=>n=!1),[]),o.useEffect(()=>ie.router.on("navigate",function(h){const b=h.detail.page.props._inertiaui_modal;if(!b){l&&t.closeAll(),ae=null,i=!1;return}l=b,ae=b.baseUrl,t.pushFromResponseData(b,{},()=>{if(!b.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==b.baseUrl&&ie.router.visit(b.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(t.onModalOnBase)}),[]);const a=h=>{var b;return h.headers["X-InertiaUI-Modal-Base-Url"]=ae??(i?(b=r.props._inertiaui_modal)==null?void 0:b.baseUrl:null),h};o.useEffect(()=>(Ce.interceptors.request.use(a),()=>Ce.interceptors.request.eject(a)),[]);const u=o.useRef();return o.useEffect(()=>{var E,w;const h=(E=r.props)==null?void 0:E._inertiaui_modal,b=u.current;u.current=h,h&&b&&h.component===b.component&&Ir(h.url,b.url)&&((w=t.stack[0])==null||w.updateProps(h.props??{}))},[(d=r.props)==null?void 0:d._inertiaui_modal]),S.jsxs(S.Fragment,{children:[e,t.stack.length>0&&S.jsx(Ft,{index:0})]})},et=o.createContext(null);et.displayName="ModalIndexContext";const tt=()=>{const e=o.useContext(et);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},Ft=({index:e})=>{const{stack:t}=ge(),r=o.useMemo(()=>t[e],[t,e]);return(r==null?void 0:r.component)&&S.jsx(et.Provider,{value:e,children:S.jsx(r.component,{...r.props,onModalEvent:(...n)=>r.emit(...n)})})};function rt(){return ge().stack[tt()]??null}const Lt=({children:e,data:t,fallback:r})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop to be a string or array of strings");const[n,l]=o.useState(!1),i=Array.isArray(t)?t:[t],a=rt().props;return o.useEffect(()=>{l(i.every(u=>a[u]!==void 0))},[a,i]),n?e:r};Lt.displayName="InertiaModalDeferred";const nt=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,...a},u)=>{const s=tt(),{stack:d,registerLocalModal:h,removeLocalModal:b}=ge(),[E,w]=o.useState(null),m=o.useMemo(()=>e?E:d[s],[e,E,s,d]),$=o.useMemo(()=>{var p;return(p=d.find(x=>x.shouldRender&&x.index>(m==null?void 0:m.index)))==null?void 0:p.index},[s,d]),v=o.useMemo(()=>(m==null?void 0:m.config.slideover)??a.slideover??Te("type")==="slideover",[a.slideover]),c=o.useMemo(()=>({slideover:v,closeButton:a.closeButton??se(v,"closeButton"),closeExplicitly:a.closeExplicitly??se(v,"closeExplicitly"),maxWidth:a.maxWidth??se(v,"maxWidth"),paddingClasses:a.paddingClasses??se(v,"paddingClasses"),panelClasses:a.panelClasses??se(v,"panelClasses"),position:a.position??se(v,"position"),...m==null?void 0:m.config}),[a,m==null?void 0:m.config]);o.useEffect(()=>{if(e){let p=null;return h(e,x=>{p=x.registerEventListenersFromProps(a),w(x)}),()=>{p==null||p(),p=null,b(e)}}return m.registerEventListenersFromProps(a)},[e]);const f=o.useRef(m);o.useEffect(()=>{f.current=m},[m]),o.useEffect(()=>{m!==null&&(m.isOpen?i==null||i():l==null||l())},[m==null?void 0:m.isOpen]);const[g,y]=o.useState(!1);return o.useEffect(()=>{g&&m!==null&&m.isOpen&&(m.onTopOfStack?r==null||r():n==null||n()),y(!0)},[m==null?void 0:m.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var p;return(p=f.current)==null?void 0:p.afterLeave()},close:()=>{var p;return(p=f.current)==null?void 0:p.close()},emit:(...p)=>{var x;return(x=f.current)==null?void 0:x.emit(...p)},getChildModal:()=>{var p;return(p=f.current)==null?void 0:p.getChildModal()},getParentModal:()=>{var p;return(p=f.current)==null?void 0:p.getParentModal()},reload:(...p)=>{var x;return(x=f.current)==null?void 0:x.reload(...p)},setOpen:()=>{var p;return(p=f.current)==null?void 0:p.setOpen()},get id(){var p;return(p=f.current)==null?void 0:p.id},get index(){var p;return(p=f.current)==null?void 0:p.index},get isOpen(){var p;return(p=f.current)==null?void 0:p.isOpen},get config(){var p;return(p=f.current)==null?void 0:p.config},get modalContext(){return f.current},get onTopOfStack(){var p;return(p=f.current)==null?void 0:p.onTopOfStack},get shouldRender(){var p;return(p=f.current)==null?void 0:p.shouldRender}}),[m]),(m==null?void 0:m.shouldRender)&&S.jsxs(S.Fragment,{children:[typeof t=="function"?t({afterLeave:m.afterLeave,close:m.close,config:c,emit:m.emit,getChildModal:m.getChildModal,getParentModal:m.getParentModal,id:m.id,index:m.index,isOpen:m.isOpen,modalContext:m,onTopOfStack:m.onTopOfStack,reload:m.reload,setOpen:m.setOpen,shouldRender:m.shouldRender}):t,$&&S.jsx(Ft,{index:$})]})});nt.displayName="HeadlessModal";function At(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(r=At(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Le(){for(var e,t,r=0,n="",l=arguments.length;r<l;r++)(e=arguments[r])&&(t=At(e))&&(n&&(n+=" "),n+=t);return n}var Wr=Object.defineProperty,Ur=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lt=(e,t,r)=>(Ur(e,typeof t!="symbol"?t+"":t,r),r);let Hr=class{constructor(){lt(this,"current",this.detect()),lt(this,"handoffState","pending"),lt(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},ee=new Hr;function Ae(e){var t,r;return ee.isServer?null:e?"ownerDocument"in e?e.ownerDocument:"current"in e?(r=(t=e.current)==null?void 0:t.ownerDocument)!=null?r:document:null:document}function Ie(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function X(){let e=[],t={addEventListener(r,n,l,i){return r.addEventListener(n,l,i),t.add(()=>r.removeEventListener(n,l,i))},requestAnimationFrame(...r){let n=requestAnimationFrame(...r);return t.add(()=>cancelAnimationFrame(n))},nextFrame(...r){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...r))},setTimeout(...r){let n=setTimeout(...r);return t.add(()=>clearTimeout(n))},microTask(...r){let n={current:!0};return Ie(()=>{n.current&&r[0]()}),t.add(()=>{n.current=!1})},style(r,n,l){let i=r.style.getPropertyValue(n);return Object.assign(r.style,{[n]:l}),this.add(()=>{Object.assign(r.style,{[n]:i})})},group(r){let n=X();return r(n),this.add(()=>n.dispose())},add(r){return e.includes(r)||e.push(r),()=>{let n=e.indexOf(r);if(n>=0)for(let l of e.splice(n,1))l()}},dispose(){for(let r of e.splice(0))r()}};return t}function ot(){let[e]=o.useState(X);return o.useEffect(()=>()=>e.dispose(),[e]),e}let L=(e,t)=>{ee.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function te(e){let t=o.useRef(e);return L(()=>{t.current=e},[e]),t}let P=function(e){let t=te(e);return o.useCallback((...r)=>t.current(...r),[t])},Vr=o.createContext(void 0);function Br(){return o.useContext(Vr)}function it(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function z(e,t,...r){if(e in t){let l=t[e];return typeof l=="function"?l(...r):l}let n=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(l=>`"${l}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,z),n}var Ne=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Ne||{}),Y=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Y||{});function j(){let e=Xr();return o.useCallback(t=>qr({mergeRefs:e,...t}),[e])}function qr({ourProps:e,theirProps:t,slot:r,defaultTag:n,features:l,visible:i=!0,name:a,mergeRefs:u}){u=u??zr;let s=It(t,e);if(i)return De(s,r,n,a,u);let d=l??0;if(d&2){let{static:h=!1,...b}=s;if(h)return De(b,r,n,a,u)}if(d&1){let{unmount:h=!0,...b}=s;return z(h?0:1,{0(){return null},1(){return De({...b,hidden:!0,style:{display:"none"}},r,n,a,u)}})}return De(s,r,n,a,u)}function De(e,t={},r,n,l){let{as:i=r,children:a,refName:u="ref",...s}=st(e,["unmount","static"]),d=e.ref!==void 0?{[u]:e.ref}:{},h=typeof a=="function"?a(t):a;"className"in s&&s.className&&typeof s.className=="function"&&(s.className=s.className(t)),s["aria-labelledby"]&&s["aria-labelledby"]===s.id&&(s["aria-labelledby"]=void 0);let b={};if(t){let E=!1,w=[];for(let[m,$]of Object.entries(t))typeof $=="boolean"&&(E=!0),$===!0&&w.push(m.replace(/([A-Z])/g,v=>`-${v.toLowerCase()}`));if(E){b["data-headlessui-state"]=w.join(" ");for(let m of w)b[`data-${m}`]=""}}if(i===o.Fragment&&(Object.keys(re(s)).length>0||Object.keys(re(b)).length>0))if(!o.isValidElement(h)||Array.isArray(h)&&h.length>1){if(Object.keys(re(s)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${n} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(re(s)).concat(Object.keys(re(b))).map(E=>` - ${E}`).join(`
|
|
1
|
+
(function(M,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core","react-dom"],o):(M=typeof globalThis<"u"?globalThis:M||self,o(M.InertiaUIModal={},M.React,M.jsxRuntime,M.Axios,M.react,M.core,M.ReactDOM))})(this,function(M,o,O,Te,ue,Pr,Tr){"use strict";var Kl=Object.defineProperty;var Yl=(M,o,O)=>o in M?Kl(M,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):M[o]=O;var B=(M,o,O)=>Yl(M,typeof o!="symbol"?o+"":o,O);function kr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ve=kr(o),ge={type:"modal",navigate:!1,modal:{closeButton:!0,closeExplicitly:!1,maxWidth:"2xl",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white rounded",position:"center"},slideover:{closeButton:!0,closeExplicitly:!1,maxWidth:"md",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white min-h-screen",position:"right"}};class Fr{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(ge))}put(t,r){if(typeof t=="object"){this.config={type:t.type??ge.type,navigate:t.navigate??ge.navigate,modal:{...ge.modal,...t.modal??{}},slideover:{...ge.slideover,...t.slideover??{}}};return}const n=t.split(".");let l=this.config;for(let i=0;i<n.length-1;i++)l=l[n[i]]=l[n[i]]||{};l[n[n.length-1]]=r}get(t){if(typeof t>"u")return this.config;const r=t.split(".");let n=this.config;for(const l of r){if(n[l]===void 0)return null;n=n[l]}return n}}const ke=new Fr,Lr=()=>ke.reset(),Ar=(e,t)=>ke.put(e,t),Fe=e=>ke.get(e),ae=(e,t)=>ke.get(e?`slideover.${t}`:`modal.${t}`);function Ir(e,t){return e=typeof e=="string"?new URL(e,window.location.origin):e,t=typeof t=="string"?new URL(t,window.location.origin):t,`${e.origin}${e.pathname}`==`${t.origin}${t.pathname}`}function Re(e="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}${crypto.randomUUID()}`:`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function de(e){return typeof e=="string"?e.toLowerCase():e}function Nr(e,t,r=!1){return r&&(t=t.map(de)),Array.isArray(e)?e.filter(n=>!t.includes(r?de(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?de(l):l)||(n[l]=e[l]),n),{})}function Dr(e,t,r=!1){return r&&(t=t.map(de)),Array.isArray(e)?e.filter(n=>t.includes(r?de(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?de(l):l)&&(n[l]=e[l]),n),{})}function jr(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,r)=>(r in e&&e[r]!==null&&(t[r]=e[r]),t),{})}function we(e){return e?(e=e.replace(/_/g,"-"),e=e.replace(/-+/g,"-"),/[A-Z]/.test(e)?(e=e.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(t,r)=>r.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const Le=o.createContext(null);Le.displayName="ModalStackContext";let St=null,Mt=null,ce=null,Ae={},et=[],fe={};const Ct=({children:e})=>{const[t,r]=o.useState([]),[n,l]=o.useState({}),i=v=>{r(c=>{const f=v([...c]),g=y=>{var p;return f.length<2?!0:((p=f.map(x=>({id:x.id,shouldRender:x.shouldRender})).reverse().find(x=>x.shouldRender))==null?void 0:p.id)===y};return f.forEach((y,p)=>{f[p].onTopOfStack=g(y.id),f[p].getParentModal=()=>p<1?null:f.slice(0,p).reverse().find(x=>x.isOpen),f[p].getChildModal=()=>p===f.length-1?null:f.slice(p+1).find(x=>x.isOpen)}),f})};o.useEffect(()=>{et=t},[t]);class a{constructor(c,f,g,y,p){B(this,"show",()=>{i(c=>c.map(f=>(f.id===this.id&&!f.isOpen&&(f.isOpen=!0,f.shouldRender=!0),f)))});B(this,"setOpen",c=>{c?this.show():this.close()});B(this,"close",()=>{i(c=>{let f=!1;const g=c.map(y=>{var p;return y.id===this.id&&y.isOpen&&(Object.keys(y.listeners).forEach(x=>{y.off(x)}),y.isOpen=!1,(p=y.onCloseCallback)==null||p.call(y),f=!0),y});return f?g:c})});B(this,"afterLeave",()=>{this.isOpen||i(c=>{const f=c.map(g=>{var y;return g.id===this.id&&!g.isOpen&&(g.shouldRender=!1,(y=g.afterLeaveCallback)==null||y.call(g),g.afterLeaveCallback=null),g});return this.index===0?[]:f})});B(this,"on",(c,f)=>{c=we(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(f)});B(this,"off",(c,f)=>{var g;c=we(c),f?this.listeners[c]=((g=this.listeners[c])==null?void 0:g.filter(y=>y!==f))??[]:delete this.listeners[c]});B(this,"emit",(c,...f)=>{var g;(g=this.listeners[we(c)])==null||g.forEach(y=>y(...f))});B(this,"registerEventListenersFromProps",c=>{const f=[];return Object.keys(c).filter(g=>g.startsWith("on")).forEach(g=>{const y=we(g).replace(/^on-/,"");this.on(y,c[g]),f.push(()=>this.off(y,c[g]))}),()=>f.forEach(g=>g())});B(this,"reload",(c={})=>{var p,x;let f=Object.keys(this.response.props);if(c.only&&(f=c.only),c.except&&(f=Nr(f,c.except)),!((p=this.response)!=null&&p.url))return;const g=(c.method??"get").toLowerCase(),y=c.data??{};(x=c.onStart)==null||x.call(c),Te({url:this.response.url,method:g,data:g==="get"?{}:y,params:g==="get"?y:{},headers:{...c.headers??{},Accept:"text/html, application/xhtml+xml","X-Inertia":!0,"X-Inertia-Partial-Component":this.response.component,"X-Inertia-Version":this.response.version,"X-Inertia-Partial-Data":f.join(","),"X-InertiaUI-Modal":Re(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":ce}}).then(S=>{var L;this.updateProps(S.data.props),(L=c.onSuccess)==null||L.call(c,S)}).catch(S=>{var L;(L=c.onError)==null||L.call(c,S)}).finally(()=>{var S;(S=c.onFinish)==null||S.call(c)})});B(this,"updateProps",c=>{Object.assign(this.props,c),i(f=>f)});if(this.id=f.id??Re(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=f.props,this.response=f,this.config=g??{},this.onCloseCallback=y,this.afterLeaveCallback=p,fe[this.id]){this.config={...this.config,...fe[this.id].config??{}};const x=fe[this.id].onClose,S=fe[this.id].onAfterLeave;x&&(this.onCloseCallback=y?()=>{y(),x()}:x),S&&(this.afterLeaveCallback=p?()=>{p(),S()}:S),delete fe[this.id]}this.index=-1,this.getParentModal=()=>null,this.getChildModal=()=>null,this.onTopOfStack=!0}static generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`inertiaui_modal_${crypto.randomUUID()}`:`inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}}const u=(v,c={},f=null,g=null)=>Mt(v.component).then(y=>d(y,v,c,f,g)),s=v=>{var f,g;const c=(g=(f=v.response)==null?void 0:f.meta)==null?void 0:g.deferredProps;c&&Object.keys(c).forEach(y=>{v.reload({only:c[y]})})},d=(v,c,f,g,y)=>{const p=new a(v,c,f,g,y);return p.index=t.length,i(x=>[...x,p]),s(p),p.show(),p};function h(v,c,f,g){if(!n[v])throw new Error(`The local modal "${v}" has not been registered.`);const y=d(null,{},c,f,g);return y.name=v,n[v].callback(y),y}const b=(v,c={})=>E(v,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??Fe("navigate"),c.onStart,c.onSuccess,c.onError).then(f=>{const g=c.listeners??{};return Object.keys(g).forEach(y=>{const p=we(y);f.on(p,g[y])}),f}),E=(v,c,f={},g={},y={},p=null,x=null,S="brackets",L=!1,j=null,k=null,A=null)=>{const H=Re();return new Promise((I,T)=>{if(v.startsWith("#")){I(h(v.substring(1),y,p,x));return}const[_,pe]=Pr.mergeDataIntoQueryString(c,v||"",f,S);let se=L&&t.length===0;if(t.length===0&&(ce=typeof window<"u"?window.location.href:""),g={...g,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":St,"X-InertiaUI-Modal":H,"X-InertiaUI-Modal-Use-Router":se?1:0,"X-InertiaUI-Modal-Base-Url":ce},se)return Ae={},fe[H]={config:y,onClose:p,onAfterLeave:x},ue.router.visit(_,{method:c,data:pe,headers:g,preserveScroll:!0,preserveState:!0,onError(...F){A==null||A(...F),T(...F)},onStart(...F){j==null||j(...F)},onSuccess(...F){k==null||k(...F)},onBefore:()=>{Ae[H]=I}});j==null||j(),Te({url:_,method:c,data:pe,headers:g}).then(F=>{k==null||k(F),I(u(F.data,y,p,x))}).catch((...F)=>{A==null||A(...F),T(...F)})})},$={stack:t,localModals:n,push:d,pushFromResponseData:u,length:()=>et.length,closeAll:()=>{et.reverse().forEach(v=>v.close())},reset:()=>i(()=>[]),visit:E,visitModal:b,registerLocalModal:(v,c)=>{l(f=>({...f,[v]:{name:v,callback:c}}))},removeLocalModal:v=>{l(c=>{const f={...c};return delete f[v],f})},onModalOnBase:v=>{const c=Ae[v.id];c&&(c(v),delete Ae[v.id])}};return O.jsx(Le.Provider,{value:$,children:e})},be=()=>{const e=o.useContext(Le);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},Pt=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],Tt=e=>{e.initialPage&&(St=e.initialPage.version),e.resolveComponent&&(Mt=e.resolveComponent)},_r=(e,t)=>{Tt(t);const r=({Component:n,props:l,key:i})=>{const a=()=>{const u=o.createElement(n,{key:i,...l});return typeof n.layout=="function"?n.layout(u):Array.isArray(n.layout)?n.layout.concat(u).reverse().reduce((d,h)=>o.createElement(h,l,d)):u};return O.jsxs(O.Fragment,{children:[a(),O.jsx(kt,{})]})};return O.jsx(Ct,{children:O.jsx(e,{...t,children:r})})},kt=({children:e})=>{var s,d;const t=o.useContext(Le),r=ue.usePage();let n=!1,l=!1,i=!!((s=r.props)!=null&&s._inertiaui_modal);o.useEffect(()=>ue.router.on("start",()=>n=!0),[]),o.useEffect(()=>ue.router.on("finish",()=>n=!1),[]),o.useEffect(()=>ue.router.on("navigate",function(h){const b=h.detail.page.props._inertiaui_modal;if(!b){l&&t.closeAll(),ce=null,i=!1;return}l=b,ce=b.baseUrl,t.pushFromResponseData(b,{},()=>{if(!b.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==b.baseUrl&&ue.router.visit(b.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(t.onModalOnBase)}),[]);const a=h=>{var b;return h.headers["X-InertiaUI-Modal-Base-Url"]=ce??(i?(b=r.props._inertiaui_modal)==null?void 0:b.baseUrl:null),h};o.useEffect(()=>(Te.interceptors.request.use(a),()=>Te.interceptors.request.eject(a)),[]);const u=o.useRef();return o.useEffect(()=>{var E,w;const h=(E=r.props)==null?void 0:E._inertiaui_modal,b=u.current;u.current=h,h&&b&&h.component===b.component&&Ir(h.url,b.url)&&((w=t.stack[0])==null||w.updateProps(h.props??{}))},[(d=r.props)==null?void 0:d._inertiaui_modal]),O.jsxs(O.Fragment,{children:[e,t.stack.length>0&&O.jsx(Ft,{index:0})]})},tt=o.createContext(null);tt.displayName="ModalIndexContext";const rt=()=>{const e=o.useContext(tt);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},Ft=({index:e})=>{const{stack:t}=be(),r=o.useMemo(()=>t[e],[t,e]);return(r==null?void 0:r.component)&&O.jsx(tt.Provider,{value:e,children:O.jsx(r.component,{...r.props,onModalEvent:(...n)=>r.emit(...n)})})};function nt(){return be().stack[rt()]??null}const Lt=({children:e,data:t,fallback:r})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop to be a string or array of strings");const[n,l]=o.useState(!1),i=Array.isArray(t)?t:[t],a=nt().props;return o.useEffect(()=>{l(i.every(u=>a[u]!==void 0))},[a,i]),n?e:r};Lt.displayName="InertiaModalDeferred";const lt=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,...a},u)=>{const s=rt(),{stack:d,registerLocalModal:h,removeLocalModal:b}=be(),[E,w]=o.useState(null),m=o.useMemo(()=>e?E:d[s],[e,E,s,d]),$=o.useMemo(()=>{var p;return(p=d.find(x=>x.shouldRender&&x.index>(m==null?void 0:m.index)))==null?void 0:p.index},[s,d]),v=o.useMemo(()=>(m==null?void 0:m.config.slideover)??a.slideover??Fe("type")==="slideover",[a.slideover]),c=o.useMemo(()=>({slideover:v,closeButton:a.closeButton??ae(v,"closeButton"),closeExplicitly:a.closeExplicitly??ae(v,"closeExplicitly"),maxWidth:a.maxWidth??ae(v,"maxWidth"),paddingClasses:a.paddingClasses??ae(v,"paddingClasses"),panelClasses:a.panelClasses??ae(v,"panelClasses"),position:a.position??ae(v,"position"),...m==null?void 0:m.config}),[a,m==null?void 0:m.config]);o.useEffect(()=>{if(e){let p=null;return h(e,x=>{p=x.registerEventListenersFromProps(a),w(x)}),()=>{p==null||p(),p=null,b(e)}}return m.registerEventListenersFromProps(a)},[e]);const f=o.useRef(m);o.useEffect(()=>{f.current=m},[m]),o.useEffect(()=>{m!==null&&(m.isOpen?i==null||i():l==null||l())},[m==null?void 0:m.isOpen]);const[g,y]=o.useState(!1);return o.useEffect(()=>{g&&m!==null&&m.isOpen&&(m.onTopOfStack?r==null||r():n==null||n()),y(!0)},[m==null?void 0:m.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var p;return(p=f.current)==null?void 0:p.afterLeave()},close:()=>{var p;return(p=f.current)==null?void 0:p.close()},emit:(...p)=>{var x;return(x=f.current)==null?void 0:x.emit(...p)},getChildModal:()=>{var p;return(p=f.current)==null?void 0:p.getChildModal()},getParentModal:()=>{var p;return(p=f.current)==null?void 0:p.getParentModal()},reload:(...p)=>{var x;return(x=f.current)==null?void 0:x.reload(...p)},setOpen:()=>{var p;return(p=f.current)==null?void 0:p.setOpen()},get id(){var p;return(p=f.current)==null?void 0:p.id},get index(){var p;return(p=f.current)==null?void 0:p.index},get isOpen(){var p;return(p=f.current)==null?void 0:p.isOpen},get config(){var p;return(p=f.current)==null?void 0:p.config},get modalContext(){return f.current},get onTopOfStack(){var p;return(p=f.current)==null?void 0:p.onTopOfStack},get shouldRender(){var p;return(p=f.current)==null?void 0:p.shouldRender}}),[m]),(m==null?void 0:m.shouldRender)&&O.jsxs(O.Fragment,{children:[typeof t=="function"?t({afterLeave:m.afterLeave,close:m.close,config:c,emit:m.emit,getChildModal:m.getChildModal,getParentModal:m.getParentModal,id:m.id,index:m.index,isOpen:m.isOpen,modalContext:m,onTopOfStack:m.onTopOfStack,reload:m.reload,setOpen:m.setOpen,shouldRender:m.shouldRender}):t,$&&O.jsx(Ft,{index:$})]})});lt.displayName="HeadlessModal";function At(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(r=At(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Ie(){for(var e,t,r=0,n="",l=arguments.length;r<l;r++)(e=arguments[r])&&(t=At(e))&&(n&&(n+=" "),n+=t);return n}var Wr=Object.defineProperty,Ur=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ot=(e,t,r)=>(Ur(e,typeof t!="symbol"?t+"":t,r),r);let Hr=class{constructor(){ot(this,"current",this.detect()),ot(this,"handoffState","pending"),ot(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},te=new Hr;function Ne(e){var t,r;return te.isServer?null:e?"ownerDocument"in e?e.ownerDocument:"current"in e?(r=(t=e.current)==null?void 0:t.ownerDocument)!=null?r:document:null:document}function De(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function z(){let e=[],t={addEventListener(r,n,l,i){return r.addEventListener(n,l,i),t.add(()=>r.removeEventListener(n,l,i))},requestAnimationFrame(...r){let n=requestAnimationFrame(...r);return t.add(()=>cancelAnimationFrame(n))},nextFrame(...r){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...r))},setTimeout(...r){let n=setTimeout(...r);return t.add(()=>clearTimeout(n))},microTask(...r){let n={current:!0};return De(()=>{n.current&&r[0]()}),t.add(()=>{n.current=!1})},style(r,n,l){let i=r.style.getPropertyValue(n);return Object.assign(r.style,{[n]:l}),this.add(()=>{Object.assign(r.style,{[n]:i})})},group(r){let n=z();return r(n),this.add(()=>n.dispose())},add(r){return e.includes(r)||e.push(r),()=>{let n=e.indexOf(r);if(n>=0)for(let l of e.splice(n,1))l()}},dispose(){for(let r of e.splice(0))r()}};return t}function it(){let[e]=o.useState(z);return o.useEffect(()=>()=>e.dispose(),[e]),e}let N=(e,t)=>{te.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function re(e){let t=o.useRef(e);return N(()=>{t.current=e},[e]),t}let P=function(e){let t=re(e);return o.useCallback((...r)=>t.current(...r),[t])},Vr=o.createContext(void 0);function Br(){return o.useContext(Vr)}function st(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function G(e,t,...r){if(e in t){let l=t[e];return typeof l=="function"?l(...r):l}let n=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(l=>`"${l}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,G),n}var je=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(je||{}),Z=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Z||{});function W(){let e=Xr();return o.useCallback(t=>qr({mergeRefs:e,...t}),[e])}function qr({ourProps:e,theirProps:t,slot:r,defaultTag:n,features:l,visible:i=!0,name:a,mergeRefs:u}){u=u??zr;let s=It(t,e);if(i)return _e(s,r,n,a,u);let d=l??0;if(d&2){let{static:h=!1,...b}=s;if(h)return _e(b,r,n,a,u)}if(d&1){let{unmount:h=!0,...b}=s;return G(h?0:1,{0(){return null},1(){return _e({...b,hidden:!0,style:{display:"none"}},r,n,a,u)}})}return _e(s,r,n,a,u)}function _e(e,t={},r,n,l){let{as:i=r,children:a,refName:u="ref",...s}=ut(e,["unmount","static"]),d=e.ref!==void 0?{[u]:e.ref}:{},h=typeof a=="function"?a(t):a;"className"in s&&s.className&&typeof s.className=="function"&&(s.className=s.className(t)),s["aria-labelledby"]&&s["aria-labelledby"]===s.id&&(s["aria-labelledby"]=void 0);let b={};if(t){let E=!1,w=[];for(let[m,$]of Object.entries(t))typeof $=="boolean"&&(E=!0),$===!0&&w.push(m.replace(/([A-Z])/g,v=>`-${v.toLowerCase()}`));if(E){b["data-headlessui-state"]=w.join(" ");for(let m of w)b[`data-${m}`]=""}}if(i===o.Fragment&&(Object.keys(ne(s)).length>0||Object.keys(ne(b)).length>0))if(!o.isValidElement(h)||Array.isArray(h)&&h.length>1){if(Object.keys(ne(s)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${n} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(ne(s)).concat(Object.keys(ne(b))).map(E=>` - ${E}`).join(`
|
|
2
2
|
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(E=>` - ${E}`).join(`
|
|
3
3
|
`)].join(`
|
|
4
|
-
`))}else{let E=h.props,w=E==null?void 0:E.className,m=typeof w=="function"?(...c)=>
|
|
4
|
+
`))}else{let E=h.props,w=E==null?void 0:E.className,m=typeof w=="function"?(...c)=>st(w(...c),s.className):st(w,s.className),$=m?{className:m}:{},v=It(h.props,ne(ut(s,["ref"])));for(let c in b)c in v&&delete b[c];return o.cloneElement(h,Object.assign({},v,b,d,{ref:l(Gr(h),d.ref)},$))}return o.createElement(i,Object.assign({},ut(s,["ref"]),i!==o.Fragment&&d,i!==o.Fragment&&b),h)}function Xr(){let e=o.useRef([]),t=o.useCallback(r=>{for(let n of e.current)n!=null&&(typeof n=="function"?n(r):n.current=r)},[]);return(...r)=>{if(!r.every(n=>n==null))return e.current=r,t}}function zr(...e){return e.every(t=>t==null)?void 0:t=>{for(let r of e)r!=null&&(typeof r=="function"?r(t):r.current=t)}}function It(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},r={};for(let n of e)for(let l in n)l.startsWith("on")&&typeof n[l]=="function"?(r[l]!=null||(r[l]=[]),r[l].push(n[l])):t[l]=n[l];if(t.disabled||t["aria-disabled"])for(let n in r)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(n)&&(r[n]=[l=>{var i;return(i=l==null?void 0:l.preventDefault)==null?void 0:i.call(l)}]);for(let n in r)Object.assign(t,{[n](l,...i){let a=r[n];for(let u of a){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;u(l,...i)}}});return t}function D(e){var t;return Object.assign(o.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function ne(e){let t=Object.assign({},e);for(let r in t)t[r]===void 0&&delete t[r];return t}function ut(e,t=[]){let r=Object.assign({},e);for(let n of t)n in r&&delete r[n];return r}function Gr(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let Kr="span";var We=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(We||{});function Yr(e,t){var r;let{features:n=1,...l}=e,i={ref:t,"aria-hidden":(n&2)===2?!0:(r=l["aria-hidden"])!=null?r:void 0,hidden:(n&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(n&4)===4&&(n&2)!==2&&{display:"none"}}};return W()({ourProps:i,theirProps:l,slot:{},defaultTag:Kr,name:"Hidden"})}let at=D(Yr);function Nt(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function J(e){return Nt(e)&&"tagName"in e}function le(e){return J(e)&&"accessKey"in e}function Q(e){return J(e)&&"tabIndex"in e}function Zr(e){return J(e)&&"style"in e}function Jr(e){return le(e)&&e.nodeName==="IFRAME"}function Qr(e){return le(e)&&e.nodeName==="INPUT"}let Dt=Symbol();function Rr(e,t=!0){return Object.assign(e,{[Dt]:t})}function q(...e){let t=o.useRef(e);o.useEffect(()=>{t.current=e},[e]);let r=P(n=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(n):l.current=n)});return e.every(n=>n==null||(n==null?void 0:n[Dt]))?void 0:r}let dt=o.createContext(null);dt.displayName="DescriptionContext";function jt(){let e=o.useContext(dt);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,jt),t}return e}function en(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(r){let n=P(i=>(t(a=>[...a,i]),()=>t(a=>{let u=a.slice(),s=u.indexOf(i);return s!==-1&&u.splice(s,1),u}))),l=o.useMemo(()=>({register:n,slot:r.slot,name:r.name,props:r.props,value:r.value}),[n,r.slot,r.name,r.props,r.value]);return o.createElement(dt.Provider,{value:l},r.children)},[t])]}let tn="p";function rn(e,t){let r=o.useId(),n=Br(),{id:l=`headlessui-description-${r}`,...i}=e,a=jt(),u=q(t);N(()=>a.register(l),[l,a.register]);let s=n||!1,d=o.useMemo(()=>({...a.slot,disabled:s}),[a.slot,s]),h={ref:u,...a.props,id:l};return W()({ourProps:h,theirProps:i,slot:d,defaultTag:tn,name:a.name||"Description"})}let nn=D(rn),ln=Object.assign(nn,{});var _t=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(_t||{});let on=o.createContext(()=>{});function sn({value:e,children:t}){return o.createElement(on.Provider,{value:e},t)}let Wt=class extends Map{constructor(t){super(),this.factory=t}get(t){let r=super.get(t);return r===void 0&&(r=this.factory(t),this.set(t,r)),r}};var un=Object.defineProperty,an=(e,t,r)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dn=(e,t,r)=>(an(e,t+"",r),r),Ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},U=(e,t,r)=>(Ut(e,t,"read from private field"),r?r.call(e):t.get(e)),ct=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ht=(e,t,r,n)=>(Ut(e,t,"write to private field"),t.set(e,r),r),X,ye,Ee;let cn=class{constructor(t){ct(this,X,{}),ct(this,ye,new Wt(()=>new Set)),ct(this,Ee,new Set),dn(this,"disposables",z()),Ht(this,X,t)}dispose(){this.disposables.dispose()}get state(){return U(this,X)}subscribe(t,r){let n={selector:t,callback:r,current:t(U(this,X))};return U(this,Ee).add(n),this.disposables.add(()=>{U(this,Ee).delete(n)})}on(t,r){return U(this,ye).get(t).add(r),this.disposables.add(()=>{U(this,ye).get(t).delete(r)})}send(t){let r=this.reduce(U(this,X),t);if(r!==U(this,X)){Ht(this,X,r);for(let n of U(this,Ee)){let l=n.selector(U(this,X));Vt(n.current,l)||(n.current=l,n.callback(l))}for(let n of U(this,ye).get(t.type))n(U(this,X),t)}}};X=new WeakMap,ye=new WeakMap,Ee=new WeakMap;function Vt(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null?!1:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:ft(e[Symbol.iterator](),t[Symbol.iterator]()):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?e.size!==t.size?!1:ft(e.entries(),t.entries()):Bt(e)&&Bt(t)?ft(Object.entries(e)[Symbol.iterator](),Object.entries(t)[Symbol.iterator]()):!1}function ft(e,t){do{let r=e.next(),n=t.next();if(r.done&&n.done)return!0;if(r.done||n.done||!Object.is(r.value,n.value))return!1}while(!0)}function Bt(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}var fn=Object.defineProperty,mn=(e,t,r)=>t in e?fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qt=(e,t,r)=>(mn(e,typeof t!="symbol"?t+"":t,r),r),pn=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(pn||{});let hn={0(e,t){let r=t.id,n=e.stack,l=e.stack.indexOf(r);if(l!==-1){let i=e.stack.slice();return i.splice(l,1),i.push(r),n=i,{...e,stack:n}}return{...e,stack:[...e.stack,r]}},1(e,t){let r=t.id,n=e.stack.indexOf(r);if(n===-1)return e;let l=e.stack.slice();return l.splice(n,1),{...e,stack:l}}},vn=class Cr extends cn{constructor(){super(...arguments),qt(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})}),qt(this,"selectors",{isTop:(t,r)=>t.stack[t.stack.length-1]===r,inStack:(t,r)=>t.stack.includes(r)})}static new(){return new Cr({stack:[]})}reduce(t,r){return G(r.type,hn,t,r)}};const Xt=new Wt(()=>vn.new());var Ue={exports:{}},mt={};/**
|
|
5
5
|
* @license React
|
|
6
6
|
* use-sync-external-store-with-selector.production.js
|
|
7
7
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/var zt;function gn(){if(zt)return
|
|
12
|
+
*/var zt;function gn(){if(zt)return mt;zt=1;var e=o;function t(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,l=e.useRef,i=e.useEffect,a=e.useMemo,u=e.useDebugValue;return mt.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var S=b(p);return E!==void 0&&E(x,S)?(f=p,x):(f=p,g=S)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},mt}var pt={};/**
|
|
13
13
|
* @license React
|
|
14
14
|
* use-sync-external-store-with-selector.development.js
|
|
15
15
|
*
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
*
|
|
18
18
|
* This source code is licensed under the MIT license found in the
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/var Gt;function wn(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&function(){function e(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=o,r=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,l=t.useRef,i=t.useEffect,a=t.useMemo,u=t.useDebugValue;mt.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var O=b(p);return E!==void 0&&E(x,O)?(f=p,x):(f=p,g=O)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),mt}var Kt;function bn(){return Kt||(Kt=1,process.env.NODE_ENV==="production"?_e.exports=gn():_e.exports=wn()),_e.exports}var yn=bn();function Yt(e,t,r=Vt){return yn.useSyncExternalStoreWithSelector(P(n=>e.subscribe(En,n)),P(()=>e.state),P(()=>e.state),P(t),r)}function En(e){return e}function ye(e,t){let r=o.useId(),n=Xt.get(t),[l,i]=Yt(n,o.useCallback(a=>[n.selectors.isTop(a,r),n.selectors.inStack(a,r)],[n,r]));return L(()=>{if(e)return n.actions.push(r),()=>n.actions.pop(r)},[n,e,r]),e?i?l:!0:!1}let pt=new Map,Ee=new Map;function Zt(e){var t;let r=(t=Ee.get(e))!=null?t:0;return Ee.set(e,r+1),r!==0?()=>Jt(e):(pt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Jt(e))}function Jt(e){var t;let r=(t=Ee.get(e))!=null?t:1;if(r===1?Ee.delete(e):Ee.set(e,r-1),r!==1)return;let n=pt.get(e);n&&(n["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert,pt.delete(e))}function xn(e,{allowed:t,disallowed:r}={}){let n=ye(e,"inert-others");L(()=>{var l,i;if(!n)return;let a=X();for(let s of(l=r==null?void 0:r())!=null?l:[])s&&a.add(Zt(s));let u=(i=t==null?void 0:t())!=null?i:[];for(let s of u){if(!s)continue;let d=Ae(s);if(!d)continue;let h=s.parentElement;for(;h&&h!==d.body;){for(let b of h.children)u.some(E=>b.contains(E))||a.add(Zt(b));h=h.parentElement}}return a.dispose},[n,t,r])}function $n(e,t,r){let n=te(l=>{let i=l.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&r()});o.useEffect(()=>{if(!e)return;let l=t===null?null:ne(t)?t:t.current;if(!l)return;let i=X();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}return()=>i.dispose()},[t,n,e])}let We=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),Sn=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var G=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(G||{}),ht=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(ht||{}),On=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(On||{});function Mn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(We)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}function Cn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Sn)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}var Qt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Qt||{});function Pn(e,t=0){var r;return e===((r=Ae(e))==null?void 0:r.body)?!1:z(t,{0(){return e.matches(We)},1(){let n=e;for(;n!==null;){if(n.matches(We))return!0;n=n.parentElement}return!1}})}var Tn=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Tn||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function K(e){e==null||e.focus({preventScroll:!0})}let kn=["textarea","input"].join(",");function Fn(e){var t,r;return(r=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,kn))!=null?r:!1}function Ln(e,t=r=>r){return e.slice().sort((r,n)=>{let l=t(r),i=t(n);if(l===null||i===null)return 0;let a=l.compareDocumentPosition(i);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function xe(e,t,{sorted:r=!0,relativeTo:n=null,skipElements:l=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?r?Ln(e):e:t&64?Cn(e):Mn(e);l.length>0&&a.length>1&&(a=a.filter(w=>!l.some(m=>m!=null&&"current"in m?(m==null?void 0:m.current)===w:m===w))),n=n??i.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,a.indexOf(n))-1;if(t&4)return Math.max(0,a.indexOf(n))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=t&32?{preventScroll:!0}:{},h=0,b=a.length,E;do{if(h>=b||h+b<=0)return 0;let w=s+h;if(t&16)w=(w+b)%b;else{if(w<0)return 3;if(w>=b)return 1}E=a[w],E==null||E.focus(d),h+=u}while(E!==i.activeElement);return t&6&&Fn(E)&&E.select(),2}function Rt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function An(){return/Android/gi.test(window.navigator.userAgent)}function er(){return Rt()||An()}function Ue(e,t,r,n){let l=te(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return document.addEventListener(t,i,n),()=>document.removeEventListener(t,i,n)},[e,t,n])}function tr(e,t,r,n){let l=te(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return window.addEventListener(t,i,n),()=>window.removeEventListener(t,i,n)},[e,t,n])}const rr=30;function In(e,t,r){let n=te(r),l=o.useCallback(function(u,s){if(u.defaultPrevented)return;let d=s(u);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let h=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of h)if(b!==null&&(b.contains(d)||u.composed&&u.composedPath().includes(b)))return;return!Pn(d,Qt.Loose)&&d.tabIndex!==-1&&u.preventDefault(),n.current(u,d)},[n,t]),i=o.useRef(null);Ue(e,"pointerdown",u=>{var s,d;er()||(i.current=((d=(s=u.composedPath)==null?void 0:s.call(u))==null?void 0:d[0])||u.target)},!0),Ue(e,"pointerup",u=>{if(er()||!i.current)return;let s=i.current;return i.current=null,l(u,()=>s)},!0);let a=o.useRef({x:0,y:0});Ue(e,"touchstart",u=>{a.current.x=u.touches[0].clientX,a.current.y=u.touches[0].clientY},!0),Ue(e,"touchend",u=>{let s={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(s.x-a.current.x)>=rr||Math.abs(s.y-a.current.y)>=rr))return l(u,()=>J(u.target)?u.target:null)},!0),tr(e,"blur",u=>l(u,()=>Jr(window.document.activeElement)?window.document.activeElement:null),!0)}function He(...e){return o.useMemo(()=>Ae(...e),[...e])}function nr(e,t,r,n){let l=te(r);o.useEffect(()=>{e=e??window;function i(a){l.current(a)}return e.addEventListener(t,i,n),()=>e.removeEventListener(t,i,n)},[e,t,n])}function Nn(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Dn(e,t){let r=e(),n=new Set;return{getSnapshot(){return r},subscribe(l){return n.add(l),()=>n.delete(l)},dispatch(l,...i){let a=t[l].call(r,...i);a&&(r=a,n.forEach(u=>u()))}}}function jn(){let e;return{before({doc:t}){var r;let n=t.documentElement,l=(r=t.defaultView)!=null?r:window;e=Math.max(0,l.innerWidth-n.clientWidth)},after({doc:t,d:r}){let n=t.documentElement,l=Math.max(0,n.clientWidth-n.offsetWidth),i=Math.max(0,e-l);r.style(n,"paddingRight",`${i}px`)}}}function _n(){return Rt()?{before({doc:e,d:t,meta:r}){function n(l){return r.containers.flatMap(i=>i()).some(i=>i.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=X();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let i=(l=window.scrollY)!=null?l:window.pageYOffset,a=null;t.addEventListener(e,"click",u=>{if(J(u.target))try{let s=u.target.closest("a");if(!s)return;let{hash:d}=new URL(s.href),h=e.querySelector(d);J(h)&&!n(h)&&(a=h)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(J(u.target)&&Zr(u.target))if(n(u.target)){let s=u.target;for(;s.parentElement&&n(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(J(u.target)){if(Qr(u.target))return;if(n(u.target)){let s=u.target;for(;s.parentElement&&s.dataset.headlessuiPortal!==""&&!(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);)s=s.parentElement;s.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let s=(u=window.scrollY)!=null?u:window.pageYOffset;i!==s&&window.scrollTo(0,i),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function Wn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Un(e){let t={};for(let r of e)Object.assign(t,r(t));return t}let le=Dn(()=>new Map,{PUSH(e,t){var r;let n=(r=this.get(e))!=null?r:{doc:e,count:0,d:X(),meta:new Set};return n.count++,n.meta.add(t),this.set(e,n),this},POP(e,t){let r=this.get(e);return r&&(r.count--,r.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:r}){let n={doc:e,d:t,meta:Un(r)},l=[_n(),jn(),Wn()];l.forEach(({before:i})=>i==null?void 0:i(n)),l.forEach(({after:i})=>i==null?void 0:i(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});le.subscribe(()=>{let e=le.getSnapshot(),t=new Map;for(let[r]of e)t.set(r,r.documentElement.style.overflow);for(let r of e.values()){let n=t.get(r.doc)==="hidden",l=r.count!==0;(l&&!n||!l&&n)&&le.dispatch(r.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",r),r.count===0&&le.dispatch("TEARDOWN",r)}});function Hn(e,t,r=()=>({containers:[]})){let n=Nn(le),l=t?n.get(t):void 0,i=l?l.count>0:!1;return L(()=>{if(!(!t||!e))return le.dispatch("PUSH",t,r),()=>le.dispatch("POP",t,r)},[e,t]),i}function Vn(e,t,r=()=>[document.body]){let n=ye(e,"scroll-lock");Hn(n,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],r]}})}function Bn(e=0){let[t,r]=o.useState(e),n=o.useCallback(s=>r(s),[t]),l=o.useCallback(s=>r(d=>d|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),a=o.useCallback(s=>r(d=>d&~s),[r]),u=o.useCallback(s=>r(d=>d^s),[r]);return{flags:t,setFlag:n,addFlag:l,hasFlag:i,removeFlag:a,toggleFlag:u}}var lr,or;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((lr=process==null?void 0:process.env)==null?void 0:lr.NODE_ENV)==="test"&&typeof((or=Element==null?void 0:Element.prototype)==null?void 0:or.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
|
|
21
|
-
`)),[]});var qn=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(qn||{});function Xn(e){let t={};for(let r in e)e[r]===!0&&(t[`data-${r}`]="");return t}function zn(e,t,r,n){let[l,i]=o.useState(r),{hasFlag:a,addFlag:u,removeFlag:s}=Bn(e&&l?3:0),d=o.useRef(!1),h=o.useRef(!1),b=ot();return L(()=>{var E;if(e){if(r&&i(!0),!t){r&&u(3);return}return(E=n==null?void 0:n.start)==null||E.call(n,r),Gn(t,{inFlight:d,prepare(){h.current?h.current=!1:h.current=d.current,d.current=!0,!h.current&&(r?(u(3),s(4)):(u(4),s(2)))},run(){h.current?r?(s(3),u(4)):(s(4),u(3)):r?s(1):u(1)},done(){var w;h.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(d.current=!1,s(7),r||i(!1),(w=n==null?void 0:n.end)==null||w.call(n,r))}})}},[e,r,t,b]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[r,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function Gn(e,{prepare:t,run:r,done:n,inFlight:l}){let i=X();return Yn(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{r(),i.requestAnimationFrame(()=>{i.add(Kn(e,n))})}),i.dispose}function Kn(e,t){var r,n;let l=X();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let a=(n=(r=e.getAnimations)==null?void 0:r.call(e).filter(u=>u instanceof CSSTransition))!=null?n:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{i||t()}),l.dispose)}function Yn(e,{inFlight:t,prepare:r}){if(t!=null&&t.current){r();return}let n=e.style.transition;e.style.transition="none",r(),e.offsetHeight,e.style.transition=n}function vt(e,t){let r=o.useRef([]),n=P(e);o.useEffect(()=>{let l=[...r.current];for(let[i,a]of t.entries())if(r.current[i]!==a){let u=n(t,l);return r.current=t,u}},[n,...t])}let Ve=o.createContext(null);Ve.displayName="OpenClosedContext";var W=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(W||{});function Be(){return o.useContext(Ve)}function Zn({value:e,children:t}){return o.createElement(Ve.Provider,{value:e},t)}function Jn({children:e}){return o.createElement(Ve.Provider,{value:null},e)}function Qn(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Q=[];Qn(()=>{function e(t){if(!J(t.target)||t.target===document.body||Q[0]===t.target)return;let r=t.target;r=r.closest(We),Q.unshift(r??t.target),Q=Q.filter(n=>n!=null&&n.isConnected),Q.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function ir(e){let t=P(e),r=o.useRef(!1);o.useEffect(()=>(r.current=!1,()=>{r.current=!0,Ie(()=>{r.current&&t()})}),[t])}function Rn(){let e=typeof document>"u";return"useSyncExternalStore"in pe?(t=>t.useSyncExternalStore)(pe)(()=>()=>{},()=>!1,()=>!e):!1}function $e(){let e=Rn(),[t,r]=pe.useState(ee.isHandoffComplete);return t&&ee.isHandoffComplete===!1&&r(!1),pe.useEffect(()=>{t!==!0&&r(!0)},[t]),pe.useEffect(()=>ee.handoff(),[]),e?!1:t}let sr=o.createContext(!1);function el(){return o.useContext(sr)}function ur(e){return o.createElement(sr.Provider,{value:e.force},e.children)}function tl(e){let t=el(),r=o.useContext(dr),[n,l]=o.useState(()=>{var i;if(!t&&r!==null)return(i=r.current)!=null?i:null;if(ee.isServer)return null;let a=e==null?void 0:e.getElementById("headlessui-portal-root");if(a)return a;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return o.useEffect(()=>{n!==null&&(e!=null&&e.body.contains(n)||e==null||e.body.appendChild(n))},[n,e]),o.useEffect(()=>{t||r!==null&&l(r.current)},[r,l,t]),n}let ar=o.Fragment,rl=N(function(e,t){let{ownerDocument:r=null,...n}=e,l=o.useRef(null),i=B(Rr(w=>{l.current=w}),t),a=He(l),u=r??a,s=tl(u),[d]=o.useState(()=>{var w;return ee.isServer?null:(w=u==null?void 0:u.createElement("div"))!=null?w:null}),h=o.useContext(gt),b=$e();L(()=>{!s||!d||s.contains(d)||(d.setAttribute("data-headlessui-portal",""),s.appendChild(d))},[s,d]),L(()=>{if(d&&h)return h.register(d)},[h,d]),ir(()=>{var w;!s||!d||(Nt(d)&&s.contains(d)&&s.removeChild(d),s.childNodes.length<=0&&((w=s.parentElement)==null||w.removeChild(s)))});let E=j();return b?!s||!d?null:Tr.createPortal(E({ourProps:{ref:i},theirProps:n,slot:{},defaultTag:ar,name:"Portal"}),d):null});function nl(e,t){let r=B(t),{enabled:n=!0,ownerDocument:l,...i}=e,a=j();return n?o.createElement(rl,{...i,ownerDocument:l,ref:r}):a({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:ar,name:"Portal"})}let ll=o.Fragment,dr=o.createContext(null);function ol(e,t){let{target:r,...n}=e,l={ref:B(t)},i=j();return o.createElement(dr.Provider,{value:r},i({ourProps:l,theirProps:n,defaultTag:ll,name:"Popover.Group"}))}let gt=o.createContext(null);function il(){let e=o.useContext(gt),t=o.useRef([]),r=P(i=>(t.current.push(i),e&&e.register(i),()=>n(i))),n=P(i=>{let a=t.current.indexOf(i);a!==-1&&t.current.splice(a,1),e&&e.unregister(i)}),l=o.useMemo(()=>({register:r,unregister:n,portals:t}),[r,n,t]);return[t,o.useMemo(()=>function({children:i}){return o.createElement(gt.Provider,{value:l},i)},[l])]}let sl=N(nl),cr=N(ol),ul=Object.assign(sl,{Group:cr});function al(e,t=typeof document<"u"?document.defaultView:null,r){let n=ye(e,"escape");nr(t,"keydown",l=>{n&&(l.defaultPrevented||l.key===_t.Escape&&r(l))})}function dl(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[r,n]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return L(()=>{if(!t)return;function l(i){n(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),r}function cl({defaultContainers:e=[],portals:t,mainTreeNode:r}={}){let n=He(r),l=P(()=>{var i,a;let u=[];for(let s of e)s!==null&&(Z(s)?u.push(s):"current"in s&&Z(s.current)&&u.push(s.current));if(t!=null&&t.current)for(let s of t.current)u.push(s);for(let s of(i=n==null?void 0:n.querySelectorAll("html > *, body > *"))!=null?i:[])s!==document.body&&s!==document.head&&Z(s)&&s.id!=="headlessui-portal-root"&&(r&&(s.contains(r)||s.contains((a=r==null?void 0:r.getRootNode())==null?void 0:a.host))||u.some(d=>s.contains(d))||u.push(s));return u});return{resolveContainers:l,contains:P(i=>l().some(a=>a.contains(i)))}}let fr=o.createContext(null);function mr({children:e,node:t}){let[r,n]=o.useState(null),l=pr(t??r);return o.createElement(fr.Provider,{value:l},e,l===null&&o.createElement(ut,{features:je.Hidden,ref:i=>{var a,u;if(i){for(let s of(u=(a=Ae(i))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(s!==document.body&&s!==document.head&&Z(s)&&s!=null&&s.contains(i)){n(s);break}}}}))}function pr(e=null){var t;return(t=o.useContext(fr))!=null?t:e}function wt(){let e=o.useRef(!1);return L(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Se=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Se||{});function fl(){let e=o.useRef(0);return tr(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function hr(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let r of e.current)Z(r.current)&&t.add(r.current);return t}let ml="div";var oe=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(oe||{});function pl(e,t){let r=o.useRef(null),n=B(r,t),{initialFocus:l,initialFocusFallback:i,containers:a,features:u=15,...s}=e;$e()||(u=0);let d=He(r);wl(u,{ownerDocument:d});let h=bl(u,{ownerDocument:d,container:r,initialFocus:l,initialFocusFallback:i});yl(u,{ownerDocument:d,container:r,containers:a,previousActiveElement:h});let b=fl(),E=P(f=>{if(!ne(r.current))return;let g=r.current;(y=>y())(()=>{z(b.current,{[Se.Forwards]:()=>{xe(g,G.First,{skipElements:[f.relatedTarget,i]})},[Se.Backwards]:()=>{xe(g,G.Last,{skipElements:[f.relatedTarget,i]})}})})}),w=ye(!!(u&2),"focus-trap#tab-lock"),m=ot(),$=o.useRef(!1),v={ref:n,onKeyDown(f){f.key=="Tab"&&($.current=!0,m.requestAnimationFrame(()=>{$.current=!1}))},onBlur(f){if(!(u&4))return;let g=hr(a);ne(r.current)&&g.add(r.current);let y=f.relatedTarget;J(y)&&y.dataset.headlessuiFocusGuard!=="true"&&(vr(g,y)||($.current?xe(r.current,z(b.current,{[Se.Forwards]:()=>G.Next,[Se.Backwards]:()=>G.Previous})|G.WrapAround,{relativeTo:f.target}):J(f.target)&&K(f.target)))}},c=j();return o.createElement(o.Fragment,null,w&&o.createElement(ut,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:je.Focusable}),c({ourProps:v,theirProps:s,defaultTag:ml,name:"FocusTrap"}),w&&o.createElement(ut,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:je.Focusable}))}let hl=N(pl),vl=Object.assign(hl,{features:oe});function gl(e=!0){let t=o.useRef(Q.slice());return vt(([r],[n])=>{n===!0&&r===!1&&Ie(()=>{t.current.splice(0)}),n===!1&&r===!0&&(t.current=Q.slice())},[e,Q,t]),P(()=>{var r;return(r=t.current.find(n=>n!=null&&n.isConnected))!=null?r:null})}function wl(e,{ownerDocument:t}){let r=!!(e&8),n=gl(r);vt(()=>{r||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&K(n())},[r]),ir(()=>{r&&K(n())})}function bl(e,{ownerDocument:t,container:r,initialFocus:n,initialFocusFallback:l}){let i=o.useRef(null),a=ye(!!(e&1),"focus-trap#initial-focus"),u=wt();return vt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&K(l.current);return}let s=r.current;s&&Ie(()=>{if(!u.current)return;let d=t==null?void 0:t.activeElement;if(n!=null&&n.current){if((n==null?void 0:n.current)===d){i.current=d;return}}else if(s.contains(d)){i.current=d;return}if(n!=null&&n.current)K(n.current);else{if(e&16){if(xe(s,G.First|G.AutoFocus)!==ht.Error)return}else if(xe(s,G.First)!==ht.Error)return;if(l!=null&&l.current&&(K(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=t==null?void 0:t.activeElement})},[l,a,e]),i}function yl(e,{ownerDocument:t,container:r,containers:n,previousActiveElement:l}){let i=wt(),a=!!(e&4);nr(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!i.current)return;let s=hr(n);ne(r.current)&&s.add(r.current);let d=l.current;if(!d)return;let h=u.target;ne(h)?vr(s,h)?(l.current=h,K(h)):(u.preventDefault(),u.stopPropagation(),K(d)):K(l.current)},!0)}function vr(e,t){for(let r of e)if(r.contains(t))return!0;return!1}function gr(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:br)!==o.Fragment||o.Children.count(e.children)===1}let qe=o.createContext(null);qe.displayName="TransitionContext";var El=(e=>(e.Visible="visible",e.Hidden="hidden",e))(El||{});function xl(){let e=o.useContext(qe);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function $l(){let e=o.useContext(Xe);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Xe=o.createContext(null);Xe.displayName="NestingContext";function ze(e){return"children"in e?ze(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function wr(e,t){let r=te(e),n=o.useRef([]),l=wt(),i=ot(),a=P((w,m=Y.Hidden)=>{let $=n.current.findIndex(({el:v})=>v===w);$!==-1&&(z(m,{[Y.Unmount](){n.current.splice($,1)},[Y.Hidden](){n.current[$].state="hidden"}}),i.microTask(()=>{var v;!ze(n)&&l.current&&((v=r.current)==null||v.call(r))}))}),u=P(w=>{let m=n.current.find(({el:$})=>$===w);return m?m.state!=="visible"&&(m.state="visible"):n.current.push({el:w,state:"visible"}),()=>a(w,Y.Unmount)}),s=o.useRef([]),d=o.useRef(Promise.resolve()),h=o.useRef({enter:[],leave:[]}),b=P((w,m,$)=>{s.current.splice(0),t&&(t.chains.current[m]=t.chains.current[m].filter(([v])=>v!==w)),t==null||t.chains.current[m].push([w,new Promise(v=>{s.current.push(v)})]),t==null||t.chains.current[m].push([w,new Promise(v=>{Promise.all(h.current[m].map(([c,f])=>f)).then(()=>v())})]),m==="enter"?d.current=d.current.then(()=>t==null?void 0:t.wait.current).then(()=>$(m)):$(m)}),E=P((w,m,$)=>{Promise.all(h.current[m].splice(0).map(([v,c])=>c)).then(()=>{var v;(v=s.current.shift())==null||v()}).then(()=>$(m))});return o.useMemo(()=>({children:n,register:u,unregister:a,onStart:b,onStop:E,wait:d,chains:h}),[u,a,n,b,E,h,d])}let br=o.Fragment,yr=Ne.RenderStrategy;function Sl(e,t){var r,n;let{transition:l=!0,beforeEnter:i,afterEnter:a,beforeLeave:u,afterLeave:s,enter:d,enterFrom:h,enterTo:b,entered:E,leave:w,leaveFrom:m,leaveTo:$,...v}=e,[c,f]=o.useState(null),g=o.useRef(null),y=gr(e),p=B(...y?[g,t,f]:t===null?[]:[t]),x=(r=v.unmount)==null||r?Y.Unmount:Y.Hidden,{show:O,appear:F,initial:U}=xl(),[k,D]=o.useState(O?"visible":"hidden"),H=$l(),{register:A,unregister:T}=H;L(()=>A(g),[A,g]),L(()=>{if(x===Y.Hidden&&g.current){if(O&&k!=="visible"){D("visible");return}return z(k,{hidden:()=>T(g),visible:()=>A(g)})}},[k,g,A,T,O,x]);let I=$e();L(()=>{if(y&&I&&k==="visible"&&g.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[g,k,I,y]);let xt=U&&!F,Ke=F&&O&&U,fe=o.useRef(!1),me=wr(()=>{fe.current||(D("hidden"),T(g))},H),Ye=P(St=>{fe.current=!0;let Je=St?"enter":"leave";me.onStart(g,Je,Me=>{Me==="enter"?i==null||i():Me==="leave"&&(u==null||u())})}),R=P(St=>{let Je=St?"enter":"leave";fe.current=!1,me.onStop(g,Je,Me=>{Me==="enter"?a==null||a():Me==="leave"&&(s==null||s())}),Je==="leave"&&!ze(me)&&(D("hidden"),T(g))});o.useEffect(()=>{y&&l||(Ye(O),R(O))},[O,y,l]);let $t=!(!l||!y||!I||xt),[,C]=zn($t,c,O,{start:Ye,end:R}),Ze=re({ref:p,className:((n=it(v.className,Ke&&d,Ke&&h,C.enter&&d,C.enter&&C.closed&&h,C.enter&&!C.closed&&b,C.leave&&w,C.leave&&!C.closed&&m,C.leave&&C.closed&&$,!C.transition&&O&&E))==null?void 0:n.trim())||void 0,...Xn(C)}),Oe=0;k==="visible"&&(Oe|=W.Open),k==="hidden"&&(Oe|=W.Closed),O&&k==="hidden"&&(Oe|=W.Opening),!O&&k==="visible"&&(Oe|=W.Closing);let Gl=j();return o.createElement(Xe.Provider,{value:me},o.createElement(Zn,{value:Oe},Gl({ourProps:Ze,theirProps:v,defaultTag:br,features:yr,visible:k==="visible",name:"Transition.Child"})))}function Ol(e,t){let{show:r,appear:n=!1,unmount:l=!0,...i}=e,a=o.useRef(null),u=gr(e),s=B(...u?[a,t]:t===null?[]:[t]);$e();let d=Be();if(r===void 0&&d!==null&&(r=(d&W.Open)===W.Open),r===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,b]=o.useState(r?"visible":"hidden"),E=wr(()=>{r||b("hidden")}),[w,m]=o.useState(!0),$=o.useRef([r]);L(()=>{w!==!1&&$.current[$.current.length-1]!==r&&($.current.push(r),m(!1))},[$,r]);let v=o.useMemo(()=>({show:r,appear:n,initial:w}),[r,n,w]);L(()=>{r?b("visible"):!ze(E)&&a.current!==null&&b("hidden")},[r,E]);let c={unmount:l},f=P(()=>{var p;w&&m(!1),(p=e.beforeEnter)==null||p.call(e)}),g=P(()=>{var p;w&&m(!1),(p=e.beforeLeave)==null||p.call(e)}),y=j();return o.createElement(Xe.Provider,{value:E},o.createElement(qe.Provider,{value:v},y({ourProps:{...c,as:o.Fragment,children:o.createElement(Er,{ref:s,...c,...i,beforeEnter:f,beforeLeave:g})},theirProps:{},defaultTag:o.Fragment,features:yr,visible:h==="visible",name:"Transition"})))}function Ml(e,t){let r=o.useContext(qe)!==null,n=Be()!==null;return o.createElement(o.Fragment,null,!r&&n?o.createElement(bt,{ref:t,...e}):o.createElement(Er,{ref:t,...e}))}let bt=N(Ol),Er=N(Sl),ce=N(Ml),xr=Object.assign(bt,{Child:ce,Root:bt});var Cl=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Cl||{}),Pl=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Pl||{});let Tl={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},yt=o.createContext(null);yt.displayName="DialogContext";function Ge(e){let t=o.useContext(yt);if(t===null){let r=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Ge),r}return t}function kl(e,t){return z(t.type,Tl,e,t)}let $r=N(function(e,t){let r=o.useId(),{id:n=`headlessui-dialog-${r}`,open:l,onClose:i,initialFocus:a,role:u="dialog",autoFocus:s=!0,__demoMode:d=!1,unmount:h=!1,...b}=e,E=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(E.current||(E.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let w=Be();l===void 0&&w!==null&&(l=(w&W.Open)===W.Open);let m=o.useRef(null),$=B(m,t),v=He(m),c=l?0:1,[f,g]=o.useReducer(kl,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=P(()=>i(!1)),p=P(C=>g({type:0,id:C})),x=$e()?c===0:!1,[O,F]=il(),U={get current(){var C;return(C=f.panelRef.current)!=null?C:m.current}},k=pr(),{resolveContainers:D}=cl({mainTreeNode:k,portals:O,defaultContainers:[U]}),H=w!==null?(w&W.Closing)===W.Closing:!1;xn(d||H?!1:x,{allowed:P(()=>{var C,Ze;return[(Ze=(C=m.current)==null?void 0:C.closest("[data-headlessui-portal]"))!=null?Ze:null]}),disallowed:P(()=>{var C;return[(C=k==null?void 0:k.closest("body > *:not(#headlessui-portal-root)"))!=null?C:null]})});let A=Xt.get(null);L(()=>{if(x)return A.actions.push(n),()=>A.actions.pop(n)},[A,n,x]);let T=Yt(A,o.useCallback(C=>A.selectors.isTop(C,n),[A,n]));In(T,D,C=>{C.preventDefault(),y()}),al(T,v==null?void 0:v.defaultView,C=>{C.preventDefault(),C.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Vn(d||H?!1:x,v,D),$n(x,m,y);let[I,xt]=en(),Ke=o.useMemo(()=>[{dialogState:c,close:y,setTitleId:p,unmount:h},f],[c,f,y,p,h]),fe=o.useMemo(()=>({open:c===0}),[c]),me={ref:$,id:n,role:u,tabIndex:-1,"aria-modal":d?void 0:c===0?!0:void 0,"aria-labelledby":f.titleId,"aria-describedby":I,unmount:h},Ye=!dl(),R=oe.None;x&&!d&&(R|=oe.RestoreFocus,R|=oe.TabLock,s&&(R|=oe.AutoFocus),Ye&&(R|=oe.InitialFocus));let $t=j();return o.createElement(Jn,null,o.createElement(ur,{force:!0},o.createElement(ul,null,o.createElement(yt.Provider,{value:Ke},o.createElement(cr,{target:m},o.createElement(ur,{force:!1},o.createElement(xt,{slot:fe},o.createElement(F,null,o.createElement(vl,{initialFocus:a,initialFocusFallback:m,containers:D,features:R},o.createElement(sn,{value:y},$t({ourProps:me,theirProps:b,slot:fe,defaultTag:Fl,features:Ll,visible:c===0,name:"Dialog"})))))))))))}),Fl="div",Ll=Ne.RenderStrategy|Ne.Static;function Al(e,t){let{transition:r=!1,open:n,...l}=e,i=Be(),a=e.hasOwnProperty("open")||i!==null,u=e.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(n!==void 0||r)&&!l.static?o.createElement(mr,null,o.createElement(xr,{show:n,transition:r,unmount:l.unmount},o.createElement($r,{ref:t,...l}))):o.createElement(mr,null,o.createElement($r,{ref:t,open:n,...l}))}let Il="div";function Nl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-panel-${r}`,transition:l=!1,...i}=e,[{dialogState:a,unmount:u},s]=Ge("Dialog.Panel"),d=B(t,s.panelRef),h=o.useMemo(()=>({open:a===0}),[a]),b=P(v=>{v.stopPropagation()}),E={ref:d,id:n,onClick:b},w=l?ce:o.Fragment,m=l?{unmount:u}:{},$=j();return o.createElement(w,{...m},$({ourProps:E,theirProps:i,slot:h,defaultTag:Il,name:"Dialog.Panel"}))}let Dl="div";function jl(e,t){let{transition:r=!1,...n}=e,[{dialogState:l,unmount:i}]=Ge("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},s=r?ce:o.Fragment,d=r?{unmount:i}:{},h=j();return o.createElement(s,{...d},h({ourProps:u,theirProps:n,slot:a,defaultTag:Dl,name:"Dialog.Backdrop"}))}let _l="h2";function Wl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-title-${r}`,...l}=e,[{dialogState:i,setTitleId:a}]=Ge("Dialog.Title"),u=B(t);o.useEffect(()=>(a(n),()=>a(null)),[n,a]);let s=o.useMemo(()=>({open:i===0}),[i]),d={ref:u,id:n};return j()({ourProps:d,theirProps:l,slot:s,defaultTag:_l,name:"Dialog.Title"})}let Ul=N(Al),Et=N(Nl);N(jl);let Hl=N(Wl),Vl=Object.assign(Ul,{Panel:Et,Title:Hl,Description:ln});function Sr({onClick:e}){return S.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[S.jsx("span",{className:"sr-only",children:"Close"}),S.jsx("svg",{className:"size-6",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor","aria-hidden":"true",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const Bl=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return S.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:S.jsx("div",{className:Le("im-modal-positioner flex min-h-full justify-center",{"items-start":t.position==="top","items-center":t.position==="center","items-end":t.position==="bottom"}),children:S.jsx(ce,{as:"div",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Le("im-modal-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:S.jsxs(Et,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&S.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:S.jsx(Sr,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},ql=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return S.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:S.jsx("div",{className:Le("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(t==null?void 0:t.position)==="left","justify-end rtl:justify-start":(t==null?void 0:t.position)==="right"}),children:S.jsx(ce,{as:"div",enterFrom:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Le("im-slideover-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:S.jsxs(Et,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&S.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:S.jsx(Sr,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},Or=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,onAfterLeave:a=null,...u},s)=>{const d=b=>typeof t=="function"?t(b):t,h=o.useRef(null);return o.useImperativeHandle(s,()=>h.current,[h]),S.jsx(nt,{ref:h,name:e,onFocus:r,onBlur:n,onClose:l,onSuccess:i,...u,children:({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:O,shouldRender:F})=>S.jsx(xr,{appear:!0,show:g??!1,afterLeave:a,children:S.jsxs(Vl,{as:"div",className:"im-dialog relative z-20",onClose:()=>w.closeExplicitly?null:E(),"data-inertiaui-modal-id":c,"data-inertiaui-modal-index":f,children:[f===0?S.jsx(ce,{enter:"transition transform ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition transform ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:p?S.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):S.jsx("div",{})}):null,f>0&&p?S.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,w.slideover?S.jsx(ql,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:O,shouldRender:F})}):S.jsx(Bl,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:O,shouldRender:F})})]})})})});Or.displayName="Modal";const Xl=({href:e,method:t="get",data:r={},as:n="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:s=null,onError:d=null,onFocus:h=null,onStart:b=null,onSuccess:E=null,navigate:w=null,children:m,...$})=>{const[v,c]=o.useState(!1),[f,g]=o.useState(null),{stack:y,visit:p}=ge(),x=o.useMemo(()=>w??Te("navigate"),[w]),O={},F={};Object.keys($).forEach(T=>{Pt.includes(T)||(T.startsWith("on")&&typeof $[T]=="function"?T.toLowerCase()in window?O[T]=$[T]:F[T]=$[T]:O[T]=$[T])});const[U,k]=o.useState(!1);o.useEffect(()=>{f&&(f.onTopOfStack&&U?h==null||h():!f.onTopOfStack&&!U&&(u==null||u()),k(!f.onTopOfStack))},[y]);const D=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{g(null),a==null||a()},[a]),A=o.useCallback(T=>{T==null||T.preventDefault(),!v&&(e.startsWith("#")||(c(!0),b==null||b()),p(e,t,r,l,jr(Dr($,Pt)),()=>D(y.length),H,i,x).then(I=>{g(I),I.registerEventListenersFromProps(F),E==null||E()}).catch(I=>{console.error(I),d==null||d(I)}).finally(()=>c(!1)))},[e,t,r,l,i,$,D,H]);return S.jsx(n,{...O,href:e,onClick:A,children:typeof m=="function"?m({loading:v}):m})},Mr=({children:e,data:t,params:r,buffer:n,as:l,always:i,fallback:a})=>{i=i??!1,l=l??"div",a=a??null;const[u,s]=o.useState(!1),d=o.useRef(!1),h=o.useRef(!1),b=o.useRef(null),E=rt(),w=o.useCallback(()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!r)throw new Error("You must provide either a `data` or `params` prop.");return r},[r,t]);return o.useEffect(()=>{if(!b.current)return;const m=new IntersectionObserver($=>{if(!$[0].isIntersecting||(!i&&d.current&&m.disconnect(),h.current))return;d.current=!0,h.current=!0;const v=w();E.reload({...v,onStart:c=>{var f;h.current=!0,(f=v.onStart)==null||f.call(v,c)},onFinish:c=>{var f;s(!0),h.current=!1,(f=v.onFinish)==null||f.call(v,c),i||m.disconnect()}})},{rootMargin:`${n||0}px`});return m.observe(b.current),()=>{m.disconnect()}},[b,w,n]),i||!u?o.createElement(l,{props:null,ref:b},u?e:a):u?e:null};Mr.displayName="InertiaWhenVisible";const zl=e=>t=>(t.default.layout=r=>o.createElement(e,{},r),t);M.Deferred=Lt,M.HeadlessModal=nt,M.Modal=Or,M.ModalLink=Xl,M.ModalRoot=kt,M.ModalStackProvider=Ct,M.WhenVisible=Mr,M.getConfig=Te,M.initFromPageProps=Tt,M.putConfig=Ar,M.renderApp=_r,M.resetConfig=Lr,M.setPageLayout=zl,M.useModal=rt,M.useModalIndex=tt,M.useModalStack=ge,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
20
|
+
*/var Gt;function wn(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&function(){function e(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=o,r=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,l=t.useRef,i=t.useEffect,a=t.useMemo,u=t.useDebugValue;pt.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var S=b(p);return E!==void 0&&E(x,S)?(f=p,x):(f=p,g=S)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),pt}var Kt;function bn(){return Kt||(Kt=1,process.env.NODE_ENV==="production"?Ue.exports=gn():Ue.exports=wn()),Ue.exports}var yn=bn();function Yt(e,t,r=Vt){return yn.useSyncExternalStoreWithSelector(P(n=>e.subscribe(En,n)),P(()=>e.state),P(()=>e.state),P(t),r)}function En(e){return e}function xe(e,t){let r=o.useId(),n=Xt.get(t),[l,i]=Yt(n,o.useCallback(a=>[n.selectors.isTop(a,r),n.selectors.inStack(a,r)],[n,r]));return N(()=>{if(e)return n.actions.push(r),()=>n.actions.pop(r)},[n,e,r]),e?i?l:!0:!1}let ht=new Map,$e=new Map;function Zt(e){var t;let r=(t=$e.get(e))!=null?t:0;return $e.set(e,r+1),r!==0?()=>Jt(e):(ht.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Jt(e))}function Jt(e){var t;let r=(t=$e.get(e))!=null?t:1;if(r===1?$e.delete(e):$e.set(e,r-1),r!==1)return;let n=ht.get(e);n&&(n["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert,ht.delete(e))}function xn(e,{allowed:t,disallowed:r}={}){let n=xe(e,"inert-others");N(()=>{var l,i;if(!n)return;let a=z();for(let s of(l=r==null?void 0:r())!=null?l:[])s&&a.add(Zt(s));let u=(i=t==null?void 0:t())!=null?i:[];for(let s of u){if(!s)continue;let d=Ne(s);if(!d)continue;let h=s.parentElement;for(;h&&h!==d.body;){for(let b of h.children)u.some(E=>b.contains(E))||a.add(Zt(b));h=h.parentElement}}return a.dispose},[n,t,r])}function $n(e,t,r){let n=re(l=>{let i=l.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&r()});o.useEffect(()=>{if(!e)return;let l=t===null?null:le(t)?t:t.current;if(!l)return;let i=z();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}return()=>i.dispose()},[t,n,e])}let He=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),On=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var K=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(K||{}),vt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(vt||{}),Sn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(Sn||{});function Mn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(He)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}function Cn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(On)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}var Qt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Qt||{});function Pn(e,t=0){var r;return e===((r=Ne(e))==null?void 0:r.body)?!1:G(t,{0(){return e.matches(He)},1(){let n=e;for(;n!==null;){if(n.matches(He))return!0;n=n.parentElement}return!1}})}var Tn=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Tn||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function Y(e){e==null||e.focus({preventScroll:!0})}let kn=["textarea","input"].join(",");function Fn(e){var t,r;return(r=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,kn))!=null?r:!1}function Ln(e,t=r=>r){return e.slice().sort((r,n)=>{let l=t(r),i=t(n);if(l===null||i===null)return 0;let a=l.compareDocumentPosition(i);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function Oe(e,t,{sorted:r=!0,relativeTo:n=null,skipElements:l=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?r?Ln(e):e:t&64?Cn(e):Mn(e);l.length>0&&a.length>1&&(a=a.filter(w=>!l.some(m=>m!=null&&"current"in m?(m==null?void 0:m.current)===w:m===w))),n=n??i.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,a.indexOf(n))-1;if(t&4)return Math.max(0,a.indexOf(n))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=t&32?{preventScroll:!0}:{},h=0,b=a.length,E;do{if(h>=b||h+b<=0)return 0;let w=s+h;if(t&16)w=(w+b)%b;else{if(w<0)return 3;if(w>=b)return 1}E=a[w],E==null||E.focus(d),h+=u}while(E!==i.activeElement);return t&6&&Fn(E)&&E.select(),2}function Rt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function An(){return/Android/gi.test(window.navigator.userAgent)}function er(){return Rt()||An()}function Ve(e,t,r,n){let l=re(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return document.addEventListener(t,i,n),()=>document.removeEventListener(t,i,n)},[e,t,n])}function tr(e,t,r,n){let l=re(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return window.addEventListener(t,i,n),()=>window.removeEventListener(t,i,n)},[e,t,n])}const rr=30;function In(e,t,r){let n=re(r),l=o.useCallback(function(u,s){if(u.defaultPrevented)return;let d=s(u);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let h=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of h)if(b!==null&&(b.contains(d)||u.composed&&u.composedPath().includes(b)))return;return!Pn(d,Qt.Loose)&&d.tabIndex!==-1&&u.preventDefault(),n.current(u,d)},[n,t]),i=o.useRef(null);Ve(e,"pointerdown",u=>{var s,d;er()||(i.current=((d=(s=u.composedPath)==null?void 0:s.call(u))==null?void 0:d[0])||u.target)},!0),Ve(e,"pointerup",u=>{if(er()||!i.current)return;let s=i.current;return i.current=null,l(u,()=>s)},!0);let a=o.useRef({x:0,y:0});Ve(e,"touchstart",u=>{a.current.x=u.touches[0].clientX,a.current.y=u.touches[0].clientY},!0),Ve(e,"touchend",u=>{let s={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(s.x-a.current.x)>=rr||Math.abs(s.y-a.current.y)>=rr))return l(u,()=>Q(u.target)?u.target:null)},!0),tr(e,"blur",u=>l(u,()=>Jr(window.document.activeElement)?window.document.activeElement:null),!0)}function Be(...e){return o.useMemo(()=>Ne(...e),[...e])}function nr(e,t,r,n){let l=re(r);o.useEffect(()=>{e=e??window;function i(a){l.current(a)}return e.addEventListener(t,i,n),()=>e.removeEventListener(t,i,n)},[e,t,n])}function Nn(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Dn(e,t){let r=e(),n=new Set;return{getSnapshot(){return r},subscribe(l){return n.add(l),()=>n.delete(l)},dispatch(l,...i){let a=t[l].call(r,...i);a&&(r=a,n.forEach(u=>u()))}}}function jn(){let e;return{before({doc:t}){var r;let n=t.documentElement,l=(r=t.defaultView)!=null?r:window;e=Math.max(0,l.innerWidth-n.clientWidth)},after({doc:t,d:r}){let n=t.documentElement,l=Math.max(0,n.clientWidth-n.offsetWidth),i=Math.max(0,e-l);r.style(n,"paddingRight",`${i}px`)}}}function _n(){return Rt()?{before({doc:e,d:t,meta:r}){function n(l){return r.containers.flatMap(i=>i()).some(i=>i.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=z();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let i=(l=window.scrollY)!=null?l:window.pageYOffset,a=null;t.addEventListener(e,"click",u=>{if(Q(u.target))try{let s=u.target.closest("a");if(!s)return;let{hash:d}=new URL(s.href),h=e.querySelector(d);Q(h)&&!n(h)&&(a=h)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(Q(u.target)&&Zr(u.target))if(n(u.target)){let s=u.target;for(;s.parentElement&&n(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(Q(u.target)){if(Qr(u.target))return;if(n(u.target)){let s=u.target;for(;s.parentElement&&s.dataset.headlessuiPortal!==""&&!(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);)s=s.parentElement;s.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let s=(u=window.scrollY)!=null?u:window.pageYOffset;i!==s&&window.scrollTo(0,i),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function Wn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Un(e){let t={};for(let r of e)Object.assign(t,r(t));return t}let oe=Dn(()=>new Map,{PUSH(e,t){var r;let n=(r=this.get(e))!=null?r:{doc:e,count:0,d:z(),meta:new Set};return n.count++,n.meta.add(t),this.set(e,n),this},POP(e,t){let r=this.get(e);return r&&(r.count--,r.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:r}){let n={doc:e,d:t,meta:Un(r)},l=[_n(),jn(),Wn()];l.forEach(({before:i})=>i==null?void 0:i(n)),l.forEach(({after:i})=>i==null?void 0:i(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});oe.subscribe(()=>{let e=oe.getSnapshot(),t=new Map;for(let[r]of e)t.set(r,r.documentElement.style.overflow);for(let r of e.values()){let n=t.get(r.doc)==="hidden",l=r.count!==0;(l&&!n||!l&&n)&&oe.dispatch(r.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",r),r.count===0&&oe.dispatch("TEARDOWN",r)}});function Hn(e,t,r=()=>({containers:[]})){let n=Nn(oe),l=t?n.get(t):void 0,i=l?l.count>0:!1;return N(()=>{if(!(!t||!e))return oe.dispatch("PUSH",t,r),()=>oe.dispatch("POP",t,r)},[e,t]),i}function Vn(e,t,r=()=>[document.body]){let n=xe(e,"scroll-lock");Hn(n,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],r]}})}function Bn(e=0){let[t,r]=o.useState(e),n=o.useCallback(s=>r(s),[t]),l=o.useCallback(s=>r(d=>d|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),a=o.useCallback(s=>r(d=>d&~s),[r]),u=o.useCallback(s=>r(d=>d^s),[r]);return{flags:t,setFlag:n,addFlag:l,hasFlag:i,removeFlag:a,toggleFlag:u}}var lr,or;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((lr=process==null?void 0:process.env)==null?void 0:lr.NODE_ENV)==="test"&&typeof((or=Element==null?void 0:Element.prototype)==null?void 0:or.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
|
|
21
|
+
`)),[]});var qn=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(qn||{});function Xn(e){let t={};for(let r in e)e[r]===!0&&(t[`data-${r}`]="");return t}function zn(e,t,r,n){let[l,i]=o.useState(r),{hasFlag:a,addFlag:u,removeFlag:s}=Bn(e&&l?3:0),d=o.useRef(!1),h=o.useRef(!1),b=it();return N(()=>{var E;if(e){if(r&&i(!0),!t){r&&u(3);return}return(E=n==null?void 0:n.start)==null||E.call(n,r),Gn(t,{inFlight:d,prepare(){h.current?h.current=!1:h.current=d.current,d.current=!0,!h.current&&(r?(u(3),s(4)):(u(4),s(2)))},run(){h.current?r?(s(3),u(4)):(s(4),u(3)):r?s(1):u(1)},done(){var w;h.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(d.current=!1,s(7),r||i(!1),(w=n==null?void 0:n.end)==null||w.call(n,r))}})}},[e,r,t,b]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[r,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function Gn(e,{prepare:t,run:r,done:n,inFlight:l}){let i=z();return Yn(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{r(),i.requestAnimationFrame(()=>{i.add(Kn(e,n))})}),i.dispose}function Kn(e,t){var r,n;let l=z();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let a=(n=(r=e.getAnimations)==null?void 0:r.call(e).filter(u=>u instanceof CSSTransition))!=null?n:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{i||t()}),l.dispose)}function Yn(e,{inFlight:t,prepare:r}){if(t!=null&&t.current){r();return}let n=e.style.transition;e.style.transition="none",r(),e.offsetHeight,e.style.transition=n}function gt(e,t){let r=o.useRef([]),n=P(e);o.useEffect(()=>{let l=[...r.current];for(let[i,a]of t.entries())if(r.current[i]!==a){let u=n(t,l);return r.current=t,u}},[n,...t])}let qe=o.createContext(null);qe.displayName="OpenClosedContext";var V=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(V||{});function Xe(){return o.useContext(qe)}function Zn({value:e,children:t}){return o.createElement(qe.Provider,{value:e},t)}function Jn({children:e}){return o.createElement(qe.Provider,{value:null},e)}function Qn(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let R=[];Qn(()=>{function e(t){if(!Q(t.target)||t.target===document.body||R[0]===t.target)return;let r=t.target;r=r.closest(He),R.unshift(r??t.target),R=R.filter(n=>n!=null&&n.isConnected),R.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function ir(e){let t=P(e),r=o.useRef(!1);o.useEffect(()=>(r.current=!1,()=>{r.current=!0,De(()=>{r.current&&t()})}),[t])}function Rn(){let e=typeof document>"u";return"useSyncExternalStore"in ve?(t=>t.useSyncExternalStore)(ve)(()=>()=>{},()=>!1,()=>!e):!1}function Se(){let e=Rn(),[t,r]=ve.useState(te.isHandoffComplete);return t&&te.isHandoffComplete===!1&&r(!1),ve.useEffect(()=>{t!==!0&&r(!0)},[t]),ve.useEffect(()=>te.handoff(),[]),e?!1:t}let sr=o.createContext(!1);function el(){return o.useContext(sr)}function ur(e){return o.createElement(sr.Provider,{value:e.force},e.children)}function tl(e){let t=el(),r=o.useContext(dr),[n,l]=o.useState(()=>{var i;if(!t&&r!==null)return(i=r.current)!=null?i:null;if(te.isServer)return null;let a=e==null?void 0:e.getElementById("headlessui-portal-root");if(a)return a;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return o.useEffect(()=>{n!==null&&(e!=null&&e.body.contains(n)||e==null||e.body.appendChild(n))},[n,e]),o.useEffect(()=>{t||r!==null&&l(r.current)},[r,l,t]),n}let ar=o.Fragment,rl=D(function(e,t){let{ownerDocument:r=null,...n}=e,l=o.useRef(null),i=q(Rr(w=>{l.current=w}),t),a=Be(l),u=r??a,s=tl(u),[d]=o.useState(()=>{var w;return te.isServer?null:(w=u==null?void 0:u.createElement("div"))!=null?w:null}),h=o.useContext(wt),b=Se();N(()=>{!s||!d||s.contains(d)||(d.setAttribute("data-headlessui-portal",""),s.appendChild(d))},[s,d]),N(()=>{if(d&&h)return h.register(d)},[h,d]),ir(()=>{var w;!s||!d||(Nt(d)&&s.contains(d)&&s.removeChild(d),s.childNodes.length<=0&&((w=s.parentElement)==null||w.removeChild(s)))});let E=W();return b?!s||!d?null:Tr.createPortal(E({ourProps:{ref:i},theirProps:n,slot:{},defaultTag:ar,name:"Portal"}),d):null});function nl(e,t){let r=q(t),{enabled:n=!0,ownerDocument:l,...i}=e,a=W();return n?o.createElement(rl,{...i,ownerDocument:l,ref:r}):a({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:ar,name:"Portal"})}let ll=o.Fragment,dr=o.createContext(null);function ol(e,t){let{target:r,...n}=e,l={ref:q(t)},i=W();return o.createElement(dr.Provider,{value:r},i({ourProps:l,theirProps:n,defaultTag:ll,name:"Popover.Group"}))}let wt=o.createContext(null);function il(){let e=o.useContext(wt),t=o.useRef([]),r=P(i=>(t.current.push(i),e&&e.register(i),()=>n(i))),n=P(i=>{let a=t.current.indexOf(i);a!==-1&&t.current.splice(a,1),e&&e.unregister(i)}),l=o.useMemo(()=>({register:r,unregister:n,portals:t}),[r,n,t]);return[t,o.useMemo(()=>function({children:i}){return o.createElement(wt.Provider,{value:l},i)},[l])]}let sl=D(nl),cr=D(ol),ul=Object.assign(sl,{Group:cr});function al(e,t=typeof document<"u"?document.defaultView:null,r){let n=xe(e,"escape");nr(t,"keydown",l=>{n&&(l.defaultPrevented||l.key===_t.Escape&&r(l))})}function dl(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[r,n]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return N(()=>{if(!t)return;function l(i){n(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),r}function cl({defaultContainers:e=[],portals:t,mainTreeNode:r}={}){let n=Be(r),l=P(()=>{var i,a;let u=[];for(let s of e)s!==null&&(J(s)?u.push(s):"current"in s&&J(s.current)&&u.push(s.current));if(t!=null&&t.current)for(let s of t.current)u.push(s);for(let s of(i=n==null?void 0:n.querySelectorAll("html > *, body > *"))!=null?i:[])s!==document.body&&s!==document.head&&J(s)&&s.id!=="headlessui-portal-root"&&(r&&(s.contains(r)||s.contains((a=r==null?void 0:r.getRootNode())==null?void 0:a.host))||u.some(d=>s.contains(d))||u.push(s));return u});return{resolveContainers:l,contains:P(i=>l().some(a=>a.contains(i)))}}let fr=o.createContext(null);function mr({children:e,node:t}){let[r,n]=o.useState(null),l=pr(t??r);return o.createElement(fr.Provider,{value:l},e,l===null&&o.createElement(at,{features:We.Hidden,ref:i=>{var a,u;if(i){for(let s of(u=(a=Ne(i))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(s!==document.body&&s!==document.head&&J(s)&&s!=null&&s.contains(i)){n(s);break}}}}))}function pr(e=null){var t;return(t=o.useContext(fr))!=null?t:e}function bt(){let e=o.useRef(!1);return N(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Me=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Me||{});function fl(){let e=o.useRef(0);return tr(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function hr(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let r of e.current)J(r.current)&&t.add(r.current);return t}let ml="div";var ie=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(ie||{});function pl(e,t){let r=o.useRef(null),n=q(r,t),{initialFocus:l,initialFocusFallback:i,containers:a,features:u=15,...s}=e;Se()||(u=0);let d=Be(r);wl(u,{ownerDocument:d});let h=bl(u,{ownerDocument:d,container:r,initialFocus:l,initialFocusFallback:i});yl(u,{ownerDocument:d,container:r,containers:a,previousActiveElement:h});let b=fl(),E=P(f=>{if(!le(r.current))return;let g=r.current;(y=>y())(()=>{G(b.current,{[Me.Forwards]:()=>{Oe(g,K.First,{skipElements:[f.relatedTarget,i]})},[Me.Backwards]:()=>{Oe(g,K.Last,{skipElements:[f.relatedTarget,i]})}})})}),w=xe(!!(u&2),"focus-trap#tab-lock"),m=it(),$=o.useRef(!1),v={ref:n,onKeyDown(f){f.key=="Tab"&&($.current=!0,m.requestAnimationFrame(()=>{$.current=!1}))},onBlur(f){if(!(u&4))return;let g=hr(a);le(r.current)&&g.add(r.current);let y=f.relatedTarget;Q(y)&&y.dataset.headlessuiFocusGuard!=="true"&&(vr(g,y)||($.current?Oe(r.current,G(b.current,{[Me.Forwards]:()=>K.Next,[Me.Backwards]:()=>K.Previous})|K.WrapAround,{relativeTo:f.target}):Q(f.target)&&Y(f.target)))}},c=W();return o.createElement(o.Fragment,null,w&&o.createElement(at,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:We.Focusable}),c({ourProps:v,theirProps:s,defaultTag:ml,name:"FocusTrap"}),w&&o.createElement(at,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:We.Focusable}))}let hl=D(pl),vl=Object.assign(hl,{features:ie});function gl(e=!0){let t=o.useRef(R.slice());return gt(([r],[n])=>{n===!0&&r===!1&&De(()=>{t.current.splice(0)}),n===!1&&r===!0&&(t.current=R.slice())},[e,R,t]),P(()=>{var r;return(r=t.current.find(n=>n!=null&&n.isConnected))!=null?r:null})}function wl(e,{ownerDocument:t}){let r=!!(e&8),n=gl(r);gt(()=>{r||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(n())},[r]),ir(()=>{r&&Y(n())})}function bl(e,{ownerDocument:t,container:r,initialFocus:n,initialFocusFallback:l}){let i=o.useRef(null),a=xe(!!(e&1),"focus-trap#initial-focus"),u=bt();return gt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&Y(l.current);return}let s=r.current;s&&De(()=>{if(!u.current)return;let d=t==null?void 0:t.activeElement;if(n!=null&&n.current){if((n==null?void 0:n.current)===d){i.current=d;return}}else if(s.contains(d)){i.current=d;return}if(n!=null&&n.current)Y(n.current);else{if(e&16){if(Oe(s,K.First|K.AutoFocus)!==vt.Error)return}else if(Oe(s,K.First)!==vt.Error)return;if(l!=null&&l.current&&(Y(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=t==null?void 0:t.activeElement})},[l,a,e]),i}function yl(e,{ownerDocument:t,container:r,containers:n,previousActiveElement:l}){let i=bt(),a=!!(e&4);nr(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!i.current)return;let s=hr(n);le(r.current)&&s.add(r.current);let d=l.current;if(!d)return;let h=u.target;le(h)?vr(s,h)?(l.current=h,Y(h)):(u.preventDefault(),u.stopPropagation(),Y(d)):Y(l.current)},!0)}function vr(e,t){for(let r of e)if(r.contains(t))return!0;return!1}function gr(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:br)!==o.Fragment||o.Children.count(e.children)===1}let ze=o.createContext(null);ze.displayName="TransitionContext";var El=(e=>(e.Visible="visible",e.Hidden="hidden",e))(El||{});function xl(){let e=o.useContext(ze);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function $l(){let e=o.useContext(Ge);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Ge=o.createContext(null);Ge.displayName="NestingContext";function Ke(e){return"children"in e?Ke(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function wr(e,t){let r=re(e),n=o.useRef([]),l=bt(),i=it(),a=P((w,m=Z.Hidden)=>{let $=n.current.findIndex(({el:v})=>v===w);$!==-1&&(G(m,{[Z.Unmount](){n.current.splice($,1)},[Z.Hidden](){n.current[$].state="hidden"}}),i.microTask(()=>{var v;!Ke(n)&&l.current&&((v=r.current)==null||v.call(r))}))}),u=P(w=>{let m=n.current.find(({el:$})=>$===w);return m?m.state!=="visible"&&(m.state="visible"):n.current.push({el:w,state:"visible"}),()=>a(w,Z.Unmount)}),s=o.useRef([]),d=o.useRef(Promise.resolve()),h=o.useRef({enter:[],leave:[]}),b=P((w,m,$)=>{s.current.splice(0),t&&(t.chains.current[m]=t.chains.current[m].filter(([v])=>v!==w)),t==null||t.chains.current[m].push([w,new Promise(v=>{s.current.push(v)})]),t==null||t.chains.current[m].push([w,new Promise(v=>{Promise.all(h.current[m].map(([c,f])=>f)).then(()=>v())})]),m==="enter"?d.current=d.current.then(()=>t==null?void 0:t.wait.current).then(()=>$(m)):$(m)}),E=P((w,m,$)=>{Promise.all(h.current[m].splice(0).map(([v,c])=>c)).then(()=>{var v;(v=s.current.shift())==null||v()}).then(()=>$(m))});return o.useMemo(()=>({children:n,register:u,unregister:a,onStart:b,onStop:E,wait:d,chains:h}),[u,a,n,b,E,h,d])}let br=o.Fragment,yr=je.RenderStrategy;function Ol(e,t){var r,n;let{transition:l=!0,beforeEnter:i,afterEnter:a,beforeLeave:u,afterLeave:s,enter:d,enterFrom:h,enterTo:b,entered:E,leave:w,leaveFrom:m,leaveTo:$,...v}=e,[c,f]=o.useState(null),g=o.useRef(null),y=gr(e),p=q(...y?[g,t,f]:t===null?[]:[t]),x=(r=v.unmount)==null||r?Z.Unmount:Z.Hidden,{show:S,appear:L,initial:j}=xl(),[k,A]=o.useState(S?"visible":"hidden"),H=$l(),{register:I,unregister:T}=H;N(()=>I(g),[I,g]),N(()=>{if(x===Z.Hidden&&g.current){if(S&&k!=="visible"){A("visible");return}return G(k,{hidden:()=>T(g),visible:()=>I(g)})}},[k,g,I,T,S,x]);let _=Se();N(()=>{if(y&&_&&k==="visible"&&g.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[g,k,_,y]);let pe=j&&!L,se=L&&S&&j,F=o.useRef(!1),he=wr(()=>{F.current||(A("hidden"),T(g))},H),Ze=P(Ot=>{F.current=!0;let Qe=Ot?"enter":"leave";he.onStart(g,Qe,Pe=>{Pe==="enter"?i==null||i():Pe==="leave"&&(u==null||u())})}),ee=P(Ot=>{let Qe=Ot?"enter":"leave";F.current=!1,he.onStop(g,Qe,Pe=>{Pe==="enter"?a==null||a():Pe==="leave"&&(s==null||s())}),Qe==="leave"&&!Ke(he)&&(A("hidden"),T(g))});o.useEffect(()=>{y&&l||(Ze(S),ee(S))},[S,y,l]);let $t=!(!l||!y||!_||pe),[,C]=zn($t,c,S,{start:Ze,end:ee}),Je=ne({ref:p,className:((n=st(v.className,se&&d,se&&h,C.enter&&d,C.enter&&C.closed&&h,C.enter&&!C.closed&&b,C.leave&&w,C.leave&&!C.closed&&m,C.leave&&C.closed&&$,!C.transition&&S&&E))==null?void 0:n.trim())||void 0,...Xn(C)}),Ce=0;k==="visible"&&(Ce|=V.Open),k==="hidden"&&(Ce|=V.Closed),S&&k==="hidden"&&(Ce|=V.Opening),!S&&k==="visible"&&(Ce|=V.Closing);let Gl=W();return o.createElement(Ge.Provider,{value:he},o.createElement(Zn,{value:Ce},Gl({ourProps:Je,theirProps:v,defaultTag:br,features:yr,visible:k==="visible",name:"Transition.Child"})))}function Sl(e,t){let{show:r,appear:n=!1,unmount:l=!0,...i}=e,a=o.useRef(null),u=gr(e),s=q(...u?[a,t]:t===null?[]:[t]);Se();let d=Xe();if(r===void 0&&d!==null&&(r=(d&V.Open)===V.Open),r===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,b]=o.useState(r?"visible":"hidden"),E=wr(()=>{r||b("hidden")}),[w,m]=o.useState(!0),$=o.useRef([r]);N(()=>{w!==!1&&$.current[$.current.length-1]!==r&&($.current.push(r),m(!1))},[$,r]);let v=o.useMemo(()=>({show:r,appear:n,initial:w}),[r,n,w]);N(()=>{r?b("visible"):!Ke(E)&&a.current!==null&&b("hidden")},[r,E]);let c={unmount:l},f=P(()=>{var p;w&&m(!1),(p=e.beforeEnter)==null||p.call(e)}),g=P(()=>{var p;w&&m(!1),(p=e.beforeLeave)==null||p.call(e)}),y=W();return o.createElement(Ge.Provider,{value:E},o.createElement(ze.Provider,{value:v},y({ourProps:{...c,as:o.Fragment,children:o.createElement(Er,{ref:s,...c,...i,beforeEnter:f,beforeLeave:g})},theirProps:{},defaultTag:o.Fragment,features:yr,visible:h==="visible",name:"Transition"})))}function Ml(e,t){let r=o.useContext(ze)!==null,n=Xe()!==null;return o.createElement(o.Fragment,null,!r&&n?o.createElement(yt,{ref:t,...e}):o.createElement(Er,{ref:t,...e}))}let yt=D(Sl),Er=D(Ol),me=D(Ml),xr=Object.assign(yt,{Child:me,Root:yt});var Cl=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Cl||{}),Pl=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Pl||{});let Tl={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},Et=o.createContext(null);Et.displayName="DialogContext";function Ye(e){let t=o.useContext(Et);if(t===null){let r=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Ye),r}return t}function kl(e,t){return G(t.type,Tl,e,t)}let $r=D(function(e,t){let r=o.useId(),{id:n=`headlessui-dialog-${r}`,open:l,onClose:i,initialFocus:a,role:u="dialog",autoFocus:s=!0,__demoMode:d=!1,unmount:h=!1,...b}=e,E=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(E.current||(E.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let w=Xe();l===void 0&&w!==null&&(l=(w&V.Open)===V.Open);let m=o.useRef(null),$=q(m,t),v=Be(m),c=l?0:1,[f,g]=o.useReducer(kl,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=P(()=>i(!1)),p=P(C=>g({type:0,id:C})),x=Se()?c===0:!1,[S,L]=il(),j={get current(){var C;return(C=f.panelRef.current)!=null?C:m.current}},k=pr(),{resolveContainers:A}=cl({mainTreeNode:k,portals:S,defaultContainers:[j]}),H=w!==null?(w&V.Closing)===V.Closing:!1;xn(d||H?!1:x,{allowed:P(()=>{var C,Je;return[(Je=(C=m.current)==null?void 0:C.closest("[data-headlessui-portal]"))!=null?Je:null]}),disallowed:P(()=>{var C;return[(C=k==null?void 0:k.closest("body > *:not(#headlessui-portal-root)"))!=null?C:null]})});let I=Xt.get(null);N(()=>{if(x)return I.actions.push(n),()=>I.actions.pop(n)},[I,n,x]);let T=Yt(I,o.useCallback(C=>I.selectors.isTop(C,n),[I,n]));In(T,A,C=>{C.preventDefault(),y()}),al(T,v==null?void 0:v.defaultView,C=>{C.preventDefault(),C.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Vn(d||H?!1:x,v,A),$n(x,m,y);let[_,pe]=en(),se=o.useMemo(()=>[{dialogState:c,close:y,setTitleId:p,unmount:h},f],[c,f,y,p,h]),F=o.useMemo(()=>({open:c===0}),[c]),he={ref:$,id:n,role:u,tabIndex:-1,"aria-modal":d?void 0:c===0?!0:void 0,"aria-labelledby":f.titleId,"aria-describedby":_,unmount:h},Ze=!dl(),ee=ie.None;x&&!d&&(ee|=ie.RestoreFocus,ee|=ie.TabLock,s&&(ee|=ie.AutoFocus),Ze&&(ee|=ie.InitialFocus));let $t=W();return o.createElement(Jn,null,o.createElement(ur,{force:!0},o.createElement(ul,null,o.createElement(Et.Provider,{value:se},o.createElement(cr,{target:m},o.createElement(ur,{force:!1},o.createElement(pe,{slot:F},o.createElement(L,null,o.createElement(vl,{initialFocus:a,initialFocusFallback:m,containers:A,features:ee},o.createElement(sn,{value:y},$t({ourProps:he,theirProps:b,slot:F,defaultTag:Fl,features:Ll,visible:c===0,name:"Dialog"})))))))))))}),Fl="div",Ll=je.RenderStrategy|je.Static;function Al(e,t){let{transition:r=!1,open:n,...l}=e,i=Xe(),a=e.hasOwnProperty("open")||i!==null,u=e.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(n!==void 0||r)&&!l.static?o.createElement(mr,null,o.createElement(xr,{show:n,transition:r,unmount:l.unmount},o.createElement($r,{ref:t,...l}))):o.createElement(mr,null,o.createElement($r,{ref:t,open:n,...l}))}let Il="div";function Nl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-panel-${r}`,transition:l=!1,...i}=e,[{dialogState:a,unmount:u},s]=Ye("Dialog.Panel"),d=q(t,s.panelRef),h=o.useMemo(()=>({open:a===0}),[a]),b=P(v=>{v.stopPropagation()}),E={ref:d,id:n,onClick:b},w=l?me:o.Fragment,m=l?{unmount:u}:{},$=W();return o.createElement(w,{...m},$({ourProps:E,theirProps:i,slot:h,defaultTag:Il,name:"Dialog.Panel"}))}let Dl="div";function jl(e,t){let{transition:r=!1,...n}=e,[{dialogState:l,unmount:i}]=Ye("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},s=r?me:o.Fragment,d=r?{unmount:i}:{},h=W();return o.createElement(s,{...d},h({ourProps:u,theirProps:n,slot:a,defaultTag:Dl,name:"Dialog.Backdrop"}))}let _l="h2";function Wl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-title-${r}`,...l}=e,[{dialogState:i,setTitleId:a}]=Ye("Dialog.Title"),u=q(t);o.useEffect(()=>(a(n),()=>a(null)),[n,a]);let s=o.useMemo(()=>({open:i===0}),[i]),d={ref:u,id:n};return W()({ourProps:d,theirProps:l,slot:s,defaultTag:_l,name:"Dialog.Title"})}let Ul=D(Al),xt=D(Nl);D(jl);let Hl=D(Wl),Vl=Object.assign(Ul,{Panel:xt,Title:Hl,Description:ln});function Or({onClick:e}){return O.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[O.jsx("span",{className:"sr-only",children:"Close"}),O.jsx("svg",{className:"size-6",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor","aria-hidden":"true",children:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const Bl=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return O.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:O.jsx("div",{className:Ie("im-modal-positioner flex min-h-full justify-center",{"items-start":t.position==="top","items-center":t.position==="center","items-end":t.position==="bottom"}),children:O.jsx(me,{as:"div",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Ie("im-modal-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:O.jsxs(xt,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&O.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:O.jsx(Or,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},ql=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return O.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:O.jsx("div",{className:Ie("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(t==null?void 0:t.position)==="left","justify-end rtl:justify-start":(t==null?void 0:t.position)==="right"}),children:O.jsx(me,{as:"div",enterFrom:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Ie("im-slideover-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:O.jsxs(xt,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&O.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:O.jsx(Or,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},Sr=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,onAfterLeave:a=null,...u},s)=>{const d=b=>typeof t=="function"?t(b):t,h=o.useRef(null);return o.useImperativeHandle(s,()=>h.current,[h]),O.jsx(lt,{ref:h,name:e,onFocus:r,onBlur:n,onClose:l,onSuccess:i,...u,children:({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:S,shouldRender:L})=>O.jsx(xr,{appear:!0,show:g??!1,afterLeave:a,children:O.jsxs(Vl,{as:"div",className:"im-dialog relative z-20",onClose:()=>w.closeExplicitly?null:E(),"data-inertiaui-modal-id":c,"data-inertiaui-modal-index":f,children:[f===0?O.jsx(me,{enter:"transition transform ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition transform ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:p?O.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):O.jsx("div",{})}):null,f>0&&p?O.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,w.slideover?O.jsx(ql,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:S,shouldRender:L})}):O.jsx(Bl,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:S,shouldRender:L})})]})})})});Sr.displayName="Modal";const Xl=({href:e,method:t="get",data:r={},as:n="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:s=null,onError:d=null,onFocus:h=null,onStart:b=null,onSuccess:E=null,navigate:w=null,children:m,...$})=>{const[v,c]=o.useState(!1),[f,g]=o.useState(null),{stack:y,visit:p}=be(),x=o.useMemo(()=>w??Fe("navigate"),[w]),S={},L={};Object.keys($).forEach(T=>{Pt.includes(T)||(T.startsWith("on")&&typeof $[T]=="function"?T.toLowerCase()in window?S[T]=$[T]:L[T]=$[T]:S[T]=$[T])});const[j,k]=o.useState(!1);o.useEffect(()=>{f&&(f.onTopOfStack&&j?h==null||h():!f.onTopOfStack&&!j&&(u==null||u()),k(!f.onTopOfStack))},[y]);const A=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{g(null),a==null||a()},[a]),I=o.useCallback(T=>{T==null||T.preventDefault(),!v&&(e.startsWith("#")||(c(!0),b==null||b()),p(e,t,r,l,jr(Dr($,Pt)),()=>A(y.length),H,i,x).then(_=>{g(_),_.registerEventListenersFromProps(L),E==null||E()}).catch(_=>{console.error(_),d==null||d(_)}).finally(()=>c(!1)))},[e,t,r,l,i,$,A,H]);return O.jsx(n,{...S,href:e,onClick:I,children:typeof m=="function"?m({loading:v}):m})},Mr=({children:e,data:t,params:r,buffer:n,as:l,always:i,fallback:a})=>{i=i??!1,l=l??"div",a=a??null;const[u,s]=o.useState(!1),d=o.useRef(!1),h=o.useRef(!1),b=o.useRef(null),E=nt(),w=o.useCallback(()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!r)throw new Error("You must provide either a `data` or `params` prop.");return r},[r,t]);return o.useEffect(()=>{if(!b.current)return;const m=new IntersectionObserver($=>{if(!$[0].isIntersecting||(!i&&d.current&&m.disconnect(),h.current))return;d.current=!0,h.current=!0;const v=w();E.reload({...v,onStart:c=>{var f;h.current=!0,(f=v.onStart)==null||f.call(v,c)},onFinish:c=>{var f;s(!0),h.current=!1,(f=v.onFinish)==null||f.call(v,c),i||m.disconnect()}})},{rootMargin:`${n||0}px`});return m.observe(b.current),()=>{m.disconnect()}},[b,w,n]),i||!u?o.createElement(l,{props:null,ref:b},u?e:a):u?e:null};Mr.displayName="InertiaWhenVisible";const zl=e=>t=>(t.default.layout=r=>o.createElement(e,{},r),t);M.Deferred=Lt,M.HeadlessModal=lt,M.Modal=Sr,M.ModalLink=Xl,M.ModalRoot=kt,M.ModalStackProvider=Ct,M.WhenVisible=Mr,M.getConfig=Fe,M.initFromPageProps=Tt,M.putConfig=Ar,M.renderApp=_r,M.resetConfig=Lr,M.setPageLayout=zl,M.useModal=nt,M.useModalIndex=rt,M.useModalStack=be,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiaui/modal-react",
|
|
3
3
|
"author": "Pascal Baljet <pascal@protone.media>",
|
|
4
|
-
"version": "1.0.0-beta-
|
|
4
|
+
"version": "1.0.0-beta-2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
"react": "^18.2.0||^19.0.0",
|
|
52
52
|
"react-dom": "^18.2.0||^19.0.0"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|
package/src/ModalRoot.jsx
CHANGED
|
@@ -325,6 +325,9 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
325
325
|
options.onAfterLeave,
|
|
326
326
|
options.queryStringArrayFormat ?? 'brackets',
|
|
327
327
|
options.navigate ?? getConfig('navigate'),
|
|
328
|
+
options.onStart,
|
|
329
|
+
options.onSuccess,
|
|
330
|
+
options.onError,
|
|
328
331
|
).then((modal) => {
|
|
329
332
|
const listeners = options.listeners ?? {}
|
|
330
333
|
|
|
@@ -347,6 +350,9 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
347
350
|
onAfterLeave = null,
|
|
348
351
|
queryStringArrayFormat = 'brackets',
|
|
349
352
|
useBrowserHistory = false,
|
|
353
|
+
onStart = null,
|
|
354
|
+
onSuccess = null,
|
|
355
|
+
onError = null,
|
|
350
356
|
) => {
|
|
351
357
|
const modalId = generateId()
|
|
352
358
|
|
|
@@ -391,7 +397,16 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
391
397
|
headers,
|
|
392
398
|
preserveScroll: true,
|
|
393
399
|
preserveState: true,
|
|
394
|
-
onError
|
|
400
|
+
onError(...args) {
|
|
401
|
+
onError?.(...args)
|
|
402
|
+
reject(...args)
|
|
403
|
+
},
|
|
404
|
+
onStart(...args) {
|
|
405
|
+
onStart?.(...args)
|
|
406
|
+
},
|
|
407
|
+
onSuccess(...args) {
|
|
408
|
+
onSuccess?.(...args)
|
|
409
|
+
},
|
|
395
410
|
onBefore: () => {
|
|
396
411
|
baseModalsToWaitFor[modalId] = resolve
|
|
397
412
|
},
|
|
@@ -400,15 +415,21 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
400
415
|
|
|
401
416
|
//
|
|
402
417
|
|
|
418
|
+
onStart?.()
|
|
419
|
+
|
|
403
420
|
Axios({
|
|
404
421
|
url,
|
|
405
422
|
method,
|
|
406
423
|
data,
|
|
407
424
|
headers,
|
|
408
425
|
})
|
|
409
|
-
.then((response) =>
|
|
410
|
-
|
|
411
|
-
|
|
426
|
+
.then((response) => {
|
|
427
|
+
onSuccess?.(response)
|
|
428
|
+
resolve(pushFromResponseData(response.data, config, onClose, onAfterLeave))
|
|
429
|
+
})
|
|
430
|
+
.catch((...args) => {
|
|
431
|
+
onError?.(...args)
|
|
432
|
+
reject(...args)
|
|
412
433
|
})
|
|
413
434
|
})
|
|
414
435
|
}
|