PageSourceSearch

https://partners.iloq.com/assets/use-presence-context-BJjp31MD.js

js iloq.com collected 2026-10-02 03:30:05 UTC 5,663 bytes, 2 lines download raw bytes

1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{a as r,n as i,t as a}from"./normalize-props-Du9-vdMM.js";import{C as o,u as s}from"./create-anatomy-B4c88YjK.js";import{a as c,n as l,s as u}from"./set-BSgR-XWP.js";import{t as d}from"./computed-style-BAhfhoBo.js";import{a as f}from"./event-BBQWg4aY.js";function p(e,t){return Array.from(e?.querySelectorAll(t)??[])}var m=e=>e.id;function h(e,t,n=m){return e.find(e=>n(e)===t)}function g(e,t,n=m){let r=h(e,t,n);return r?e.indexOf(r):-1}function _(e,t,n=!0){let r=g(e,t);return r=n?(r+1)%e.length:Math.min(r+1,e.length-1),e[r]}function v(e,t,n=!0){let r=g(e,t);return r===-1?n?e[e.length-1]:null:(r=n?(r-1+e.length)%e.length:Math.max(0,r-1),e[r])}var y=e(t(),1),b=(e=>Reflect.get(e,`Activity`))(y),x=b!==void 0;function S(e,t={}){let{sync:n=!1}=t,r=C(e);return(0,y.useCallback)((...e)=>n?queueMicrotask(()=>r.current?.(...e)):r.current?.(...e),[n,r])}function C(e){let t=(0,y.useRef)(e);return t.current=e,t}function w(e,t){let{state:n,send:r,context:i}=e,a=n.matches(`mounted`,`unmountSuspended`);return{skip:!i.get(`initial`),present:a,setNode(e){e&&r({type:`NODE.SET`,node:e})},unmount(){r({type:`UNMOUNT`})}}}var T=r({props({props:e}){return{...e,present:!!e.present}},initialState({prop:e}){return e(`present`)?`mounted`:`unmounted`},refs(){return{node:null,styles:null}},context({bindable:e}){return{unmountAnimationName:e(()=>({defaultValue:null})),prevAnimationName:e(()=>({defaultValue:null})),present:e(()=>({defaultValue:!1})),initial:e(()=>({sync:!0,defaultValue:!1}))}},exit:[`cleanupNode`],watch({track:e,prop:t,send:n}){e([()=>t(`present`)],()=>{n({type:`PRESENCE.CHANGED`})})},on:{"NODE.SET":{actions:[`setupNode`]},"PRESENCE.CHANGED":{actions:[`setInitial`,`syncPresence`]}},states:{mounted:{effects:[`trackEnterAnimation`],on:{UNMOUNT:{target:`unmounted`,actions:[`clearPrevAnimationName`,`invokeOnExitComplete`]},"UNMOUNT.SUSPEND":{target:`unmountSuspended`}}},unmountSuspended:{effects:[`trackExitAnimation`],on:{MOUNT:{target:`mounted`,actions:[`setPrevAnimationName`]},UNMOUNT:{target:`unmounted`,actions:[`clearPrevAnimationName`,`invokeOnExitComplete`]}}},unmounted:{on:{MOUNT:{target:`mounted`,actions:[`setPrevAnimationName`]}}}},implementations:{actions:{setInitial:({context:e})=>{e.get(`initial`)||queueMicrotask(()=>{e.set(`initial`,!0)})},invokeOnExitComplete:({prop:e,refs:t})=>{e(`onExitComplete`)?.();let n=t.get(`node`);if(!n)return;let r=new(s(n)).CustomEvent(`exitcomplete`,{bubbles:!1});n.dispatchEvent(r)},setupNode:({refs:e,event:t})=>{e.get(`node`)!==t.node&&(e.set(`node`,t.node),e.set(`styles`,d(t.node)))},cleanupNode:({refs:e})=>{e.set(`node`,null),e.set(`styles`,null)},syncPresence:({context:e,refs:t,send:n,prop:r})=>{let i=r(`present`);if(i)return n({type:`MOUNT`,src:`presence.changed`});let a=t.get(`node`);if(!i&&a?.ownerDocument.visibilityState===`hidden`)return n({type:`UNMOUNT`,src:`visibilitychange`});u(()=>{if(r(`present`))return;let i=E(t.get(`styles`));e.set(`unmountAnimationName`,i),i===`none`||i===e.get(`prevAnimationName`)||t.get(`styles`)?.display===`none`||t.get(`styles`)?.animationDuration===`0s`?n({type:`UNMOUNT`,src:`presence.changed`}):n({type:`UNMOUNT.SUSPEND`})})},setPrevAnimationName:({context:e,refs:t})=>{u(()=>{e.set(`prevAnimationName`,E(t.get(`styles`)))})},clearPrevAnimationName:({context:e})=>{e.set(`prevAnimationName`,null)}},effects:{trackEnterAnimation:({context:e,refs:t,prop:n})=>{if(!n(`onEnterComplete`)||!e.get(`initial`))return;let r,i=()=>{r=u(()=>{let e=t.get(`node`);if(!e||!e.isConnected){i();return}let r=d(e);if(E(r)===`none`||r.display===`none`||r.animationDuration===`0s`){n(`onEnterComplete`)?.();return}let a=t=>{f(t)===e&&n(`present`)&&(e.removeEventListener(`animationend`,a),n(`onEnterComplete`)?.())};return e.addEventListener(`animationend`,a),()=>{e.removeEventListener(`animationend`,a)}})};return i(),()=>r?.()},trackExitAnimation:({context:e,refs:t,send:n,prop:r})=>{let i=t.get(`node`);if(!i)return;let a=n=>{(n.composedPath?.()?.[0]??n.target)===i&&e.set(`prevAnimationName`,E(t.get(`styles`)))},o=a=>{let o=E(t.get(`styles`));f(a)===i&&o===e.get(`unmountAnimationName`)&&!r(`present`)&&n({type:`UNMOUNT`,src:`animationend`})},s=e=>{f(e)===i&&!r(`present`)&&n({type:`UNMOUNT`,src:`animationcancel`})};i.addEventListener(`animationstart`,a),i.addEventListener(`animationcancel`,s),i.addEventListener(`animationend`,o);let u=l(i,{animationFillMode:`forwards`});return()=>{i.removeEventListener(`animationstart`,a),i.removeEventListener(`animationcancel`,s),i.removeEventListener(`animationend`,o),c(()=>u())}}}}});function E(e){return e?.animationName||`none`}var D=(e={})=>{let{lazyMount:t,unmountOnExit:n,hideMode:r=`display-none`,present:o,skipAnimationOnMount:s=!1,...c}=e,l=(0,y.useRef)(!1),u={...c,present:o,onEnterComplete:S(e.onEnterComplete),onExitComplete:S(e.onExitComplete)},d=w(i(T,u),a);d.present&&(l.current=!0);let f=!d.present&&!l.current&&t||n&&!d.present&&l.current,p=r===`activity`&&x?`activity`:`display-none`;return{ref:d.setNode,getPresenceProps:()=>({"data-state":d.skip&&s?void 0:o?`open`:`closed`,hidden:p!==`activity`&&!d.present}),present:d.present,unmounted:f,hideMode:p}},O=n(),k=e=>{let{presence:t,children:n}=e;return t.unmounted?null:t.hideMode===`activity`&&b?(0,O.jsx)(b,{mode:t.present?`visible`:`hidden`,children:n}):n},[A,j]=o({name:`PresenceContext`,hookName:`usePresenceContext`,providerName:`<PresenceProvider />`});export{S as a,m as c,_ as d,v as f,D as i,g as l,j as n,b as o,p,k as r,x as s,A as t,h as u};
2//# sourceMappingURL=use-presence-context-BJjp31MD.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.