@telegraph/modal 0.0.49 → 0.0.50

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @telegraph/modal
2
2
 
3
+ ## 0.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d28f9c`](https://github.com/knocklabs/telegraph/commit/9d28f9ca6024e20b8bf4e537dab53aa9f9d127a3) Thanks [@kylemcd](https://github.com/kylemcd)! - Remove layer concept because of modal re-rendering issues
8
+
3
9
  ## 0.0.49
4
10
 
5
11
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),G=require("@radix-ui/react-dialog"),J=require("@radix-ui/react-focus-scope"),b=require("react"),$=require("react-dom"),Q=require("@radix-ui/react-visually-hidden"),ee=require("@telegraph/button"),te=require("@telegraph/helpers"),ne=require("@telegraph/icon"),m=require("@telegraph/layout"),R=require("framer-motion");function j(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const g=j(G),o=j(b),re=j($),se=j(Q);function oe(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function ie(...t){return e=>t.forEach(n=>oe(n,e))}var k=o.forwardRef((t,e)=>{const{children:n,...r}=t,s=o.Children.toArray(n),i=s.find(ce);if(i){const a=i.props.children,l=s.map(y=>y===i?o.Children.count(a)>1?o.Children.only(null):o.isValidElement(a)?a.props.children:null:y);return c.jsx(T,{...r,ref:e,children:o.isValidElement(a)?o.cloneElement(a,void 0,l):null})}return c.jsx(T,{...r,ref:e,children:n})});k.displayName="Slot";var T=o.forwardRef((t,e)=>{const{children:n,...r}=t;if(o.isValidElement(n)){const s=ue(n);return o.cloneElement(n,{...le(r,n.props),ref:e?ie(e,s):s})}return o.Children.count(n)>1?o.Children.only(null):null});T.displayName="SlotClone";var ae=({children:t})=>c.jsx(c.Fragment,{children:t});function ce(t){return o.isValidElement(t)&&t.type===ae}function le(t,e){const n={...e};for(const r in e){const s=t[r],i=e[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...l)=>{i(...l),s(...l)}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...t,...n}}function ue(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var de=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],fe=de.reduce((t,e)=>{const n=o.forwardRef((r,s)=>{const{asChild:i,...a}=r,l=i?k:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{}),pe=globalThis!=null&&globalThis.document?o.useLayoutEffect:()=>{},ye="Portal",q=o.forwardRef((t,e)=>{var l;const{container:n,...r}=t,[s,i]=o.useState(!1);pe(()=>i(!0),[]);const a=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?$.createPortal(c.jsx(fe.div,{...r,ref:e}),a):null});q.displayName=ye;var he=q;function I(t){const e=o.useRef(t);return o.useEffect(()=>{e.current=t}),o.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function ve({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,s]=me({defaultProp:e,onChange:n}),i=t!==void 0,a=i?t:r,l=I(n),y=o.useCallback(u=>{if(i){const f=typeof u=="function"?u(t):u;f!==t&&l(f)}else s(u)},[i,t,s,l]);return[a,y]}function me({defaultProp:t,onChange:e}){const n=o.useState(t),[r]=n,s=o.useRef(r),i=I(e);return o.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),n}function D(t,e,{checkForDefaultPrevented:n=!0}={}){return function(s){if(t==null||t(s),n===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}var ge=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],z=ge.reduce((t,e)=>{const n=o.forwardRef((r,s)=>{const{asChild:i,...a}=r,l=i?k:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function be(t,e){t&&re.flushSync(()=>t.dispatchEvent(e))}function Ee(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function xe(...t){return e=>t.forEach(n=>Ee(n,e))}function U(...t){return o.useCallback(xe(...t),t)}function M(t){const e=o.useRef(t);return o.useEffect(()=>{e.current=t}),o.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function Ce(t,e=globalThis==null?void 0:globalThis.document){const n=M(t);o.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var Pe="DismissableLayer",N="dismissableLayer.update",Le="dismissableLayer.pointerDownOutside",we="dismissableLayer.focusOutside",A,V=o.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),K=o.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...y}=t,u=o.useContext(V),[d,f]=o.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=o.useState({}),O=U(e,p=>f(p)),C=Array.from(u.layers),[P]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),L=C.indexOf(P),v=d?C.indexOf(d):-1,B=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=L,Z=Oe(p=>{const w=p.target,_=[...u.branches].some(S=>S.contains(w));!E||_||(s==null||s(p),a==null||a(p),p.defaultPrevented||l==null||l())},h),W=Se(p=>{const w=p.target;[...u.branches].some(S=>S.contains(w))||(i==null||i(p),a==null||a(p),p.defaultPrevented||l==null||l())},h);return Ce(p=>{v===u.layers.size-1&&(r==null||r(p),!p.defaultPrevented&&l&&(p.preventDefault(),l()))},h),o.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(A=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),F(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=A)}},[d,h,n,u]),o.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),F())},[d,u]),o.useEffect(()=>{const p=()=>x({});return document.addEventListener(N,p),()=>document.removeEventListener(N,p)},[]),c.jsx(z.div,{...y,ref:O,style:{pointerEvents:B?E?"auto":"none":void 0,...t.style},onFocusCapture:D(t.onFocusCapture,W.onFocusCapture),onBlurCapture:D(t.onBlurCapture,W.onBlurCapture),onPointerDownCapture:D(t.onPointerDownCapture,Z.onPointerDownCapture)})});K.displayName=Pe;var Re="DismissableLayerBranch",je=o.forwardRef((t,e)=>{const n=o.useContext(V),r=o.useRef(null),s=U(e,r);return o.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),c.jsx(z.div,{...t,ref:s})});je.displayName=Re;function Oe(t,e=globalThis==null?void 0:globalThis.document){const n=M(t),r=o.useRef(!1),s=o.useRef(()=>{});return o.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let y=function(){H(Le,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=y,e.addEventListener("click",s.current,{once:!0})):y()}else e.removeEventListener("click",s.current);r.current=!1},a=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),e.removeEventListener("pointerdown",i),e.removeEventListener("click",s.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function Se(t,e=globalThis==null?void 0:globalThis.document){const n=M(t),r=o.useRef(!1);return o.useEffect(()=>{const s=i=>{i.target&&!r.current&&H(we,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function F(){const t=new CustomEvent(N);document.dispatchEvent(t)}function H(t,e,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?be(s,i):s.dispatchEvent(i)}const De=({id:t,layers:e,children:n,...r})=>t===e[e.length-1]?c.jsx(K,{...r,children:n}):c.jsx(c.Fragment,{children:n}),X=b.createContext({layers:[],setLayers:()=>{},addLayer:()=>{},removeLayer:()=>{},removeTopLayer:()=>{}}),Te=({children:t})=>{const[e,n]=b.useState([]),r=(a,l={})=>{const{layer:y}=l;if(typeof y=="number")return n(u=>u.length-1<y?[...u,a]:[...u.slice(0,y),a,...u.slice(y)]);n(u=>[...u,a])},s=a=>{n(e.filter(l=>l!==a))},i=()=>{const a=e[e.length-1];a&&s(a)};return c.jsx(X.Provider,{value:{layers:e,setLayers:n,addLayer:r,removeLayer:s,removeTopLayer:i},children:t})},Ne=()=>b.useContext(X),ke=({defaultOpen:t,open:e,onOpenChange:n,...r})=>{const[s,i]=ve({prop:e,onChange:n,defaultProp:t});if(s)return c.jsx(Me,{open:s,onOpenChange:i,...r})},Me=({open:t,onOpenChange:e,a11yTitle:n,a11yDescription:r,children:s,layer:i,trapped:a,onMountAutoFocus:l,onUnmountAutoFocus:y,...u})=>{var P,L;const d=n,f=Ne();b.useEffect(()=>{!f||!t||f.layers.includes(d)||f.addLayer(d,{layer:i})},[d,i,f,t]);const h=((P=f.layers)==null?void 0:P.indexOf(d))||0,x=((L=f.layers)==null?void 0:L.length)||0,O=h!==0,C=d===f.layers[f.layers.length-1];return c.jsx(De,{id:d,layers:f.layers,onEscapeKeyDown:v=>{v.preventDefault(),f.removeTopLayer(),e(!1)},onPointerDownOutside:v=>{v.preventDefault(),f.removeTopLayer(),e(!1)},children:c.jsxs(g.Root,{open:t,onOpenChange:v=>{var E;if(((E=f==null?void 0:f.layers)==null?void 0:E.length)>0)return v===!1&&d===f.layers[f.layers.length-1]?(f.removeLayer(d),e(!1)):void 0;e(v)},children:[c.jsxs(se.Root,{children:[c.jsx(g.Title,{children:n}),r&&c.jsx(g.Description,{children:r})]}),c.jsx(R.AnimatePresence,{children:t&&c.jsx(he,{className:"tgph",children:c.jsx(Be,{layer:h,children:c.jsx(J.FocusScope,{trapped:typeof a=="boolean"?a:C,onMountAutoFocus:l,onUnmountAutoFocus:y,asChild:!0,children:c.jsx(te.RefToTgphRef,{children:c.jsx(m.Stack,{as:R.motion.div,initial:{top:`calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${x-1})`},animate:{top:O?`calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${h} )`:"var(--tgph-spacing-16)"},exit:{top:0},transition:{type:"spring",duration:.3,bounce:0},w:"full",justify:"center",style:{position:"fixed",left:0,maxHeight:"calc(100vh - var(--tgph-spacing-32))",maxWidth:"calc(100vw - var(--tgph-spacing-8))",zIndex:`calc(var(--tgph-zIndex-modal) + ${h})`},children:c.jsx(m.Stack,{direction:"column",as:R.motion.div,animate:{scale:1.02-Math.abs(x-h)*.02,transformOrigin:"center center"},transition:{duration:.2,bounce:0,type:"spring"},maxW:u.maxW??"160",w:u.w??"full",bg:"surface-1",border:"px",rounded:"4",shadow:"3",...u,children:s},`content-${d}`)},`container-${d}`)})})})})})]},d)})},Be=({layer:t,children:e})=>t>0?e:c.jsxs(g.Overlay,{children:[c.jsx(m.Box,{as:R.motion.div,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3,bounce:0,type:"spring"},bg:"alpha-black-6",w:"full",h:"full",zIndex:"overlay",style:{position:"fixed",cursor:"pointer",inset:"0px"}}),e]}),We=b.forwardRef(({children:t,...e},n)=>c.jsx(g.Content,{ref:n,asChild:!0,...e,children:c.jsx(m.Stack,{direction:"column",h:"full",...e,children:t})})),_e=({size:t="1",variant:e="ghost",...n})=>c.jsx(g.Close,{asChild:!0,children:c.jsx(ee.Button,{icon:{icon:ne.Lucide.X,alt:"Close Modal"},variant:e,size:t,...n})}),Ae=({style:t,children:e,...n})=>c.jsx(m.Stack,{direction:"column",px:"6",py:"4",style:{overflowY:"auto",...t},...n,children:e}),Fe=({children:t,...e})=>c.jsx(m.Stack,{direction:"row",justify:"space-between",align:"center",px:"6",py:"4",borderBottom:"px",...e,children:t}),$e=({children:t,...e})=>c.jsx(m.Stack,{direction:"row",align:"center",justify:"flex-end",gap:"2",px:"6",py:"4",borderTop:"px",...e,children:t}),Y={};Object.assign(Y,{Root:ke,Content:We,Close:_e,Body:Ae,Header:Fe,Footer:$e});exports.Modal=Y;exports.ModalStackingProvider=Te;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),Y=require("@radix-ui/react-dialog"),E=require("react"),Z=require("react-dom"),G=require("@radix-ui/react-focus-scope"),J=require("@radix-ui/react-portal"),Q=require("@radix-ui/react-visually-hidden"),ee=require("@telegraph/button"),te=require("@telegraph/helpers"),ne=require("@telegraph/icon"),m=require("@telegraph/layout"),L=require("framer-motion");function x(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const g=x(Y),o=x(E),re=x(Z),se=x(J),oe=x(Q);function D(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function ie(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ae(...e){return t=>e.forEach(n=>ie(n,t))}var A=o.forwardRef((e,t)=>{const{children:n,...r}=e,s=o.Children.toArray(n),i=s.find(le);if(i){const u=i.props.children,d=s.map(p=>p===i?o.Children.count(u)>1?o.Children.only(null):o.isValidElement(u)?u.props.children:null:p);return l.jsx(T,{...r,ref:t,children:o.isValidElement(u)?o.cloneElement(u,void 0,d):null})}return l.jsx(T,{...r,ref:t,children:n})});A.displayName="Slot";var T=o.forwardRef((e,t)=>{const{children:n,...r}=e;if(o.isValidElement(n)){const s=de(n);return o.cloneElement(n,{...ue(r,n.props),ref:t?ae(t,s):s})}return o.Children.count(n)>1?o.Children.only(null):null});T.displayName="SlotClone";var ce=({children:e})=>l.jsx(l.Fragment,{children:e});function le(e){return o.isValidElement(e)&&e.type===ce}function ue(e,t){const n={...t};for(const r in t){const s=e[r],i=t[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...d)=>{i(...d),s(...d)}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...e,...n}}function de(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],q=fe.reduce((e,t)=>{const n=o.forwardRef((r,s)=>{const{asChild:i,...u}=r,d=i?A:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(d,{...u,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function pe(e,t){e&&re.flushSync(()=>e.dispatchEvent(t))}function ye(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function he(...e){return t=>e.forEach(n=>ye(n,t))}function I(...e){return o.useCallback(he(...e),e)}function B(e){const t=o.useRef(e);return o.useEffect(()=>{t.current=e}),o.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ve(e,t=globalThis==null?void 0:globalThis.document){const n=B(e);o.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var me="DismissableLayer",k="dismissableLayer.update",ge="dismissableLayer.pointerDownOutside",Ee="dismissableLayer.focusOutside",_,$=o.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),z=o.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:u,onDismiss:d,...p}=e,a=o.useContext($),[c,y]=o.useState(null),h=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,O]=o.useState({}),j=I(t,f=>y(f)),b=Array.from(a.layers),[C]=[...a.layersWithOutsidePointerEventsDisabled].slice(-1),v=b.indexOf(C),w=c?b.indexOf(c):-1,P=a.layersWithOutsidePointerEventsDisabled.size>0,M=w>=v,X=Ce(f=>{const R=f.target,W=[...a.branches].some(S=>S.contains(R));!M||W||(s==null||s(f),u==null||u(f),f.defaultPrevented||d==null||d())},h),N=Pe(f=>{const R=f.target;[...a.branches].some(S=>S.contains(R))||(i==null||i(f),u==null||u(f),f.defaultPrevented||d==null||d())},h);return ve(f=>{w===a.layers.size-1&&(r==null||r(f),!f.defaultPrevented&&d&&(f.preventDefault(),d()))},h),o.useEffect(()=>{if(c)return n&&(a.layersWithOutsidePointerEventsDisabled.size===0&&(_=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),a.layersWithOutsidePointerEventsDisabled.add(c)),a.layers.add(c),F(),()=>{n&&a.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=_)}},[c,h,n,a]),o.useEffect(()=>()=>{c&&(a.layers.delete(c),a.layersWithOutsidePointerEventsDisabled.delete(c),F())},[c,a]),o.useEffect(()=>{const f=()=>O({});return document.addEventListener(k,f),()=>document.removeEventListener(k,f)},[]),l.jsx(q.div,{...p,ref:j,style:{pointerEvents:P?M?"auto":"none":void 0,...e.style},onFocusCapture:D(e.onFocusCapture,N.onFocusCapture),onBlurCapture:D(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:D(e.onPointerDownCapture,X.onPointerDownCapture)})});z.displayName=me;var be="DismissableLayerBranch",xe=o.forwardRef((e,t)=>{const n=o.useContext($),r=o.useRef(null),s=I(t,r);return o.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),l.jsx(q.div,{...e,ref:s})});xe.displayName=be;function Ce(e,t=globalThis==null?void 0:globalThis.document){const n=B(e),r=o.useRef(!1),s=o.useRef(()=>{});return o.useEffect(()=>{const i=d=>{if(d.target&&!r.current){let p=function(){U(ge,n,a,{discrete:!0})};const a={originalEvent:d};d.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=p,t.addEventListener("click",s.current,{once:!0})):p()}else t.removeEventListener("click",s.current);r.current=!1},u=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(u),t.removeEventListener("pointerdown",i),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Pe(e,t=globalThis==null?void 0:globalThis.document){const n=B(e),r=o.useRef(!1);return o.useEffect(()=>{const s=i=>{i.target&&!r.current&&U(Ee,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function F(){const e=new CustomEvent(k);document.dispatchEvent(e)}function U(e,t,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?pe(s,i):s.dispatchEvent(i)}function V(e){const t=o.useRef(e);return o.useEffect(()=>{t.current=e}),o.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Re({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,s]=Le({defaultProp:t,onChange:n}),i=e!==void 0,u=i?e:r,d=V(n),p=o.useCallback(a=>{if(i){const y=typeof a=="function"?a(e):a;y!==e&&d(y)}else s(a)},[i,e,s,d]);return[u,p]}function Le({defaultProp:e,onChange:t}){const n=o.useState(e),[r]=n,s=o.useRef(r),i=V(t);return o.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),n}const K=E.createContext({layers:[],setLayers:()=>{},addLayer:()=>{},removeLayer:()=>{},removeTopLayer:()=>{}}),Oe=({children:e})=>{const[t,n]=E.useState([]),r=u=>{n(d=>[...d,u])},s=u=>{n(t.filter(d=>d!==u))},i=()=>{const u=t[t.length-1];u&&s(u)};return l.jsx(K.Provider,{value:{layers:t,setLayers:n,addLayer:r,removeLayer:s,removeTopLayer:i},children:e})},je=()=>E.useContext(K),we=({defaultOpen:e,open:t,onOpenChange:n,...r})=>{const[s,i]=Re({prop:t,onChange:n,defaultProp:e});if(s)return l.jsx(Se,{open:s,onOpenChange:i,...r})},Se=({open:e,onOpenChange:t,a11yTitle:n,a11yDescription:r,children:s,trapped:i,onMountAutoFocus:u,onUnmountAutoFocus:d,...p})=>{var b,C;const a=n,c=je();E.useEffect(()=>{!c||!e||c.layers.includes(a)||c.addLayer(a)},[a,c,e]);const y=((b=c.layers)==null?void 0:b.indexOf(a))||0,h=((C=c.layers)==null?void 0:C.length)||0,O=y!==0,j=a===c.layers[c.layers.length-1];return l.jsx(z,{onEscapeKeyDown:v=>{v.preventDefault(),c.removeTopLayer(),t(!1)},onPointerDownOutside:v=>{v.preventDefault(),c.removeTopLayer(),t(!1)},children:l.jsxs(g.Root,{open:e,onOpenChange:v=>{var P;if(((P=c==null?void 0:c.layers)==null?void 0:P.length)>0)return v===!1&&a===c.layers[c.layers.length-1]?(c.removeLayer(a),t(!1)):void 0;t(v)},children:[l.jsxs(oe.Root,{children:[l.jsx(g.Title,{children:n}),r&&l.jsx(g.Description,{children:r})]}),l.jsx(L.AnimatePresence,{children:e&&l.jsx(se.Root,{className:"tgph",children:l.jsx(De,{layer:y,children:l.jsx(G.FocusScope,{trapped:typeof i=="boolean"?i:j,onMountAutoFocus:u,onUnmountAutoFocus:d,asChild:!0,children:l.jsx(te.RefToTgphRef,{children:l.jsx(m.Stack,{as:L.motion.div,initial:{top:`calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${h-1})`},animate:{top:O?`calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${y} )`:"var(--tgph-spacing-16)"},exit:{top:0},transition:{type:"spring",duration:.3,bounce:0},w:"full",justify:"center",style:{position:"fixed",left:0,maxHeight:"calc(100vh - var(--tgph-spacing-32))",maxWidth:"calc(100vw - var(--tgph-spacing-8))",zIndex:`calc(var(--tgph-zIndex-modal) + ${y})`},children:l.jsx(m.Stack,{direction:"column",as:L.motion.div,animate:{scale:1.02-Math.abs(h-y)*.02,transformOrigin:"center center"},transition:{duration:.2,bounce:0,type:"spring"},maxW:p.maxW??"160",w:p.w??"full",bg:"surface-1",border:"px",rounded:"4",shadow:"3",...p,children:s},`content-${a}`)},`container-${a}`)})})})})})]},a)})},De=({layer:e,children:t})=>e>0?t:l.jsxs(g.Overlay,{children:[l.jsx(m.Box,{as:L.motion.div,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3,bounce:0,type:"spring"},bg:"alpha-black-6",w:"full",h:"full",zIndex:"overlay",style:{position:"fixed",cursor:"pointer",inset:"0px"}}),t]}),Te=E.forwardRef(({children:e,...t},n)=>l.jsx(g.Content,{ref:n,asChild:!0,...t,children:l.jsx(m.Stack,{direction:"column",h:"full",...t,children:e})})),ke=({size:e="1",variant:t="ghost",...n})=>l.jsx(g.Close,{asChild:!0,children:l.jsx(ee.Button,{icon:{icon:ne.Lucide.X,alt:"Close Modal"},variant:t,size:e,...n})}),Be=({style:e,children:t,...n})=>l.jsx(m.Stack,{direction:"column",px:"6",py:"4",style:{overflowY:"auto",...e},...n,children:t}),Me=({children:e,...t})=>l.jsx(m.Stack,{direction:"row",justify:"space-between",align:"center",px:"6",py:"4",borderBottom:"px",...t,children:e}),Ne=({children:e,...t})=>l.jsx(m.Stack,{direction:"row",align:"center",justify:"flex-end",gap:"2",px:"6",py:"4",borderTop:"px",...t,children:e}),H={};Object.assign(H,{Root:we,Content:Te,Close:ke,Body:Be,Header:Me,Footer:Ne});exports.Modal=H;exports.ModalStackingProvider=Oe;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../node_modules/@radix-ui/react-slot/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../../node_modules/@radix-ui/react-slot/dist/index.mjs","../../../../node_modules/@radix-ui/react-portal/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../../node_modules/@radix-ui/react-portal/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs","../../../../node_modules/@radix-ui/react-portal/dist/index.mjs","../../../../node_modules/@radix-ui/react-use-controllable-state/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs","../../../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/primitive/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs","../../src/Modal/Modal.helpers.tsx","../../src/Modal/ModalStacking.tsx","../../src/Modal/Modal.tsx"],"sourcesContent":["// packages/react/compose-refs/src/composeRefs.tsx\nimport * as React from \"react\";\nfunction setRef(ref, value) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null && ref !== void 0) {\n ref.current = value;\n }\n}\nfunction composeRefs(...refs) {\n return (node) => refs.forEach((ref) => setRef(ref, node));\n}\nfunction useComposedRefs(...refs) {\n return React.useCallback(composeRefs(...refs), refs);\n}\nexport {\n composeRefs,\n useComposedRefs\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/slot/src/Slot.tsx\nimport * as React from \"react\";\nimport { composeRefs } from \"@radix-ui/react-compose-refs\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\nvar Slot = React.forwardRef((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n if (slottable) {\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement) ? newElement.props.children : null;\n } else {\n return child;\n }\n });\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });\n }\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });\n});\nSlot.displayName = \"Slot\";\nvar SlotClone = React.forwardRef((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n return React.cloneElement(children, {\n ...mergeProps(slotProps, children.props),\n // @ts-ignore\n ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef\n });\n }\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n});\nSlotClone.displayName = \"SlotClone\";\nvar Slottable = ({ children }) => {\n return /* @__PURE__ */ jsx(Fragment, { children });\n};\nfunction isSlottable(child) {\n return React.isValidElement(child) && child.type === Slottable;\n}\nfunction mergeProps(slotProps, childProps) {\n const overrideProps = { ...childProps };\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args) => {\n childPropValue(...args);\n slotPropValue(...args);\n };\n } else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n } else if (propName === \"style\") {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === \"className\") {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(\" \");\n }\n }\n return { ...slotProps, ...overrideProps };\n}\nfunction getElementRef(element) {\n let getter = Object.getOwnPropertyDescriptor(element.props, \"ref\")?.get;\n let mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.ref;\n }\n getter = Object.getOwnPropertyDescriptor(element, \"ref\")?.get;\n mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.props.ref;\n }\n return element.props.ref || element.ref;\n}\nvar Root = Slot;\nexport {\n Root,\n Slot,\n Slottable\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/primitive/src/Primitive.tsx\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NODES = [\n \"a\",\n \"button\",\n \"div\",\n \"form\",\n \"h2\",\n \"h3\",\n \"img\",\n \"input\",\n \"label\",\n \"li\",\n \"nav\",\n \"ol\",\n \"p\",\n \"span\",\n \"svg\",\n \"ul\"\n];\nvar Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props, forwardedRef) => {\n const { asChild, ...primitiveProps } = props;\n const Comp = asChild ? Slot : node;\n if (typeof window !== \"undefined\") {\n window[Symbol.for(\"radix-ui\")] = true;\n }\n return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });\n });\n Node.displayName = `Primitive.${node}`;\n return { ...primitive, [node]: Node };\n}, {});\nfunction dispatchDiscreteCustomEvent(target, event) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\nvar Root = Primitive;\nexport {\n Primitive,\n Root,\n dispatchDiscreteCustomEvent\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-layout-effect/src/useLayoutEffect.tsx\nimport * as React from \"react\";\nvar useLayoutEffect2 = Boolean(globalThis?.document) ? React.useLayoutEffect : () => {\n};\nexport {\n useLayoutEffect2 as useLayoutEffect\n};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\n\n// packages/react/portal/src/Portal.tsx\nimport * as React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useLayoutEffect } from \"@radix-ui/react-use-layout-effect\";\nimport { jsx } from \"react/jsx-runtime\";\nvar PORTAL_NAME = \"Portal\";\nvar Portal = React.forwardRef((props, forwardedRef) => {\n const { container: containerProp, ...portalProps } = props;\n const [mounted, setMounted] = React.useState(false);\n useLayoutEffect(() => setMounted(true), []);\n const container = containerProp || mounted && globalThis?.document?.body;\n return container ? ReactDOM.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;\n});\nPortal.displayName = PORTAL_NAME;\nvar Root = Portal;\nexport {\n Portal,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-callback-ref/src/useCallbackRef.tsx\nimport * as React from \"react\";\nfunction useCallbackRef(callback) {\n const callbackRef = React.useRef(callback);\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);\n}\nexport {\n useCallbackRef\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-controllable-state/src/useControllableState.tsx\nimport * as React from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nfunction useControllableState({\n prop,\n defaultProp,\n onChange = () => {\n }\n}) {\n const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });\n const isControlled = prop !== void 0;\n const value = isControlled ? prop : uncontrolledProp;\n const handleChange = useCallbackRef(onChange);\n const setValue = React.useCallback(\n (nextValue) => {\n if (isControlled) {\n const setter = nextValue;\n const value2 = typeof nextValue === \"function\" ? setter(prop) : nextValue;\n if (value2 !== prop) handleChange(value2);\n } else {\n setUncontrolledProp(nextValue);\n }\n },\n [isControlled, prop, setUncontrolledProp, handleChange]\n );\n return [value, setValue];\n}\nfunction useUncontrolledState({\n defaultProp,\n onChange\n}) {\n const uncontrolledState = React.useState(defaultProp);\n const [value] = uncontrolledState;\n const prevValueRef = React.useRef(value);\n const handleChange = useCallbackRef(onChange);\n React.useEffect(() => {\n if (prevValueRef.current !== value) {\n handleChange(value);\n prevValueRef.current = value;\n }\n }, [value, prevValueRef, handleChange]);\n return uncontrolledState;\n}\nexport {\n useControllableState\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/core/primitive/src/primitive.tsx\nfunction composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {\n return function handleEvent(event) {\n originalEventHandler?.(event);\n if (checkForDefaultPrevented === false || !event.defaultPrevented) {\n return ourEventHandler?.(event);\n }\n };\n}\nexport {\n composeEventHandlers\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/primitive/src/Primitive.tsx\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NODES = [\n \"a\",\n \"button\",\n \"div\",\n \"form\",\n \"h2\",\n \"h3\",\n \"img\",\n \"input\",\n \"label\",\n \"li\",\n \"nav\",\n \"ol\",\n \"p\",\n \"span\",\n \"svg\",\n \"ul\"\n];\nvar Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props, forwardedRef) => {\n const { asChild, ...primitiveProps } = props;\n const Comp = asChild ? Slot : node;\n if (typeof window !== \"undefined\") {\n window[Symbol.for(\"radix-ui\")] = true;\n }\n return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });\n });\n Node.displayName = `Primitive.${node}`;\n return { ...primitive, [node]: Node };\n}, {});\nfunction dispatchDiscreteCustomEvent(target, event) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\nvar Root = Primitive;\nexport {\n Primitive,\n Root,\n dispatchDiscreteCustomEvent\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/compose-refs/src/composeRefs.tsx\nimport * as React from \"react\";\nfunction setRef(ref, value) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null && ref !== void 0) {\n ref.current = value;\n }\n}\nfunction composeRefs(...refs) {\n return (node) => refs.forEach((ref) => setRef(ref, node));\n}\nfunction useComposedRefs(...refs) {\n return React.useCallback(composeRefs(...refs), refs);\n}\nexport {\n composeRefs,\n useComposedRefs\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-callback-ref/src/useCallbackRef.tsx\nimport * as React from \"react\";\nfunction useCallbackRef(callback) {\n const callbackRef = React.useRef(callback);\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);\n}\nexport {\n useCallbackRef\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-escape-keydown/src/useEscapeKeydown.tsx\nimport * as React from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nfunction useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n React.useEffect(() => {\n const handleKeyDown = (event) => {\n if (event.key === \"Escape\") {\n onEscapeKeyDown(event);\n }\n };\n ownerDocument.addEventListener(\"keydown\", handleKeyDown, { capture: true });\n return () => ownerDocument.removeEventListener(\"keydown\", handleKeyDown, { capture: true });\n }, [onEscapeKeyDown, ownerDocument]);\n}\nexport {\n useEscapeKeydown\n};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\n\n// packages/react/dismissable-layer/src/DismissableLayer.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { Primitive, dispatchDiscreteCustomEvent } from \"@radix-ui/react-primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useEscapeKeydown } from \"@radix-ui/react-use-escape-keydown\";\nimport { jsx } from \"react/jsx-runtime\";\nvar DISMISSABLE_LAYER_NAME = \"DismissableLayer\";\nvar CONTEXT_UPDATE = \"dismissableLayer.update\";\nvar POINTER_DOWN_OUTSIDE = \"dismissableLayer.pointerDownOutside\";\nvar FOCUS_OUTSIDE = \"dismissableLayer.focusOutside\";\nvar originalBodyPointerEvents;\nvar DismissableLayerContext = React.createContext({\n layers: /* @__PURE__ */ new Set(),\n layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),\n branches: /* @__PURE__ */ new Set()\n});\nvar DismissableLayer = React.forwardRef(\n (props, forwardedRef) => {\n const {\n disableOutsidePointerEvents = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);\n const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n const pointerDownOutside = usePointerDownOutside((event) => {\n const target = event.target;\n const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));\n if (!isPointerEventsEnabled || isPointerDownOnBranch) return;\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n const focusOutside = useFocusOutside((event) => {\n const target = event.target;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n useEscapeKeydown((event) => {\n const isHighestLayer = index === context.layers.size - 1;\n if (!isHighestLayer) return;\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n }, ownerDocument);\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = \"none\";\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n return /* @__PURE__ */ jsx(\n Primitive.div,\n {\n ...layerProps,\n ref: composedRefs,\n style: {\n pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? \"auto\" : \"none\" : void 0,\n ...props.style\n },\n onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),\n onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),\n onPointerDownCapture: composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture\n )\n }\n );\n }\n);\nDismissableLayer.displayName = DISMISSABLE_LAYER_NAME;\nvar BRANCH_NAME = \"DismissableLayerBranch\";\nvar DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });\n});\nDismissableLayerBranch.displayName = BRANCH_NAME;\nfunction usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);\n const isPointerInsideReactTreeRef = React.useRef(false);\n const handleClickRef = React.useRef(() => {\n });\n React.useEffect(() => {\n const handlePointerDown = (event) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n let handleAndDispatchPointerDownOutsideEvent2 = function() {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true }\n );\n };\n var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;\n const eventDetail = { originalEvent: event };\n if (event.pointerType === \"touch\") {\n ownerDocument.removeEventListener(\"click\", handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;\n ownerDocument.addEventListener(\"click\", handleClickRef.current, { once: true });\n } else {\n handleAndDispatchPointerDownOutsideEvent2();\n }\n } else {\n ownerDocument.removeEventListener(\"click\", handleClickRef.current);\n }\n isPointerInsideReactTreeRef.current = false;\n };\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener(\"pointerdown\", handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener(\"pointerdown\", handlePointerDown);\n ownerDocument.removeEventListener(\"click\", handleClickRef.current);\n };\n }, [ownerDocument, handlePointerDownOutside]);\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true\n };\n}\nfunction useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {\n const handleFocusOutside = useCallbackRef(onFocusOutside);\n const isFocusInsideReactTreeRef = React.useRef(false);\n React.useEffect(() => {\n const handleFocus = (event) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false\n });\n }\n };\n ownerDocument.addEventListener(\"focusin\", handleFocus);\n return () => ownerDocument.removeEventListener(\"focusin\", handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n return {\n onFocusCapture: () => isFocusInsideReactTreeRef.current = true,\n onBlurCapture: () => isFocusInsideReactTreeRef.current = false\n };\n}\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\nfunction handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler, { once: true });\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\nvar Root = DismissableLayer;\nvar Branch = DismissableLayerBranch;\nexport {\n Branch,\n DismissableLayer,\n DismissableLayerBranch,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","import {\n DismissableLayer,\n type DismissableLayerProps,\n} from \"@radix-ui/react-dismissable-layer\";\n\ntype DismissableWrapperProps = DismissableLayerProps & {\n id: string;\n layers: Array<string>;\n children: React.ReactNode;\n};\n\n//\n// Handles the logic for when a global action like \"esc\" or clicking outside\n// should close the modal. When stacking modals, we don't want to close the\n// modal if we are not on the top-most layer.\n//\nconst DismissableWrapper = ({\n id,\n layers,\n children,\n ...props\n}: DismissableWrapperProps) => {\n const isTopLayer = id === layers[layers.length - 1];\n\n if (isTopLayer) {\n return <DismissableLayer {...props}>{children}</DismissableLayer>;\n }\n\n return <>{children}</>;\n};\n\nexport { DismissableWrapper };\n","import React from \"react\";\n\ntype AddLayerOptions = {\n layer?: number;\n};\n\nconst ModalStackingContext = React.createContext<{\n layers: Array<string>;\n setLayers: React.Dispatch<React.SetStateAction<Array<string>>>;\n addLayer: (id: string, options: AddLayerOptions) => void;\n removeLayer: (id: string) => void;\n removeTopLayer: () => void;\n}>({\n layers: [],\n setLayers: () => {},\n addLayer: () => {},\n removeLayer: () => {},\n removeTopLayer: () => {},\n});\n\ntype ModalStackingProviderProps = {\n children: React.ReactNode;\n};\n\nconst ModalStackingProvider = ({ children }: ModalStackingProviderProps) => {\n const [layers, setLayers] = React.useState<Array<string>>([]);\n\n const addLayer = (id: string, options: AddLayerOptions = {}) => {\n const { layer } = options;\n\n // If a layer is specified, insert the layer at the specified index\n // so that the modal renders at the correct layer in the stack.\n if (typeof layer === \"number\") {\n return setLayers((current) => {\n if (current.length - 1 < layer) {\n return [...current, id];\n }\n\n return [...current.slice(0, layer), id, ...current.slice(layer)];\n });\n } else {\n setLayers((current) => [...current, id]);\n }\n };\n\n const removeLayer = (id: string) => {\n setLayers(layers.filter((layer) => layer !== id));\n };\n\n const removeTopLayer = () => {\n const id = layers[layers.length - 1];\n if (!id) return;\n removeLayer(id);\n };\n\n return (\n <ModalStackingContext.Provider\n value={{ layers, setLayers, addLayer, removeLayer, removeTopLayer }}\n >\n {children}\n </ModalStackingContext.Provider>\n );\n};\n\nconst useModalStacking = () => {\n return React.useContext(ModalStackingContext);\n};\n\nexport { ModalStackingProvider, useModalStacking };\n","import * as Dialog from \"@radix-ui/react-dialog\";\nimport { FocusScope } from \"@radix-ui/react-focus-scope\";\nimport * as Portal from \"@radix-ui/react-portal\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as VisuallyHidden from \"@radix-ui/react-visually-hidden\";\nimport { Button } from \"@telegraph/button\";\nimport { RefToTgphRef } from \"@telegraph/helpers\";\nimport type {\n PolymorphicProps,\n TgphComponentProps,\n TgphElement,\n} from \"@telegraph/helpers\";\nimport { Lucide } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport React from \"react\";\n\nimport { DismissableWrapper } from \"./Modal.helpers\";\nimport { useModalStacking } from \"./ModalStacking\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.ComponentPropsWithoutRef<typeof FocusScope> &\n TgphComponentProps<typeof Stack> & {\n a11yTitle: string;\n a11yDescription?: string;\n layer?: number;\n };\n\nconst Root = ({\n defaultOpen: defaultOpenProp,\n open: openProp,\n onOpenChange: onOpenChangeProp,\n ...props\n}: RootProps) => {\n const [open, onOpenChange] = useControllableState({\n prop: openProp,\n onChange: onOpenChangeProp,\n defaultProp: defaultOpenProp,\n });\n\n // Prevent rendering anything within the modal if it is not open\n if (!open) return;\n\n return <RootComponent open={open} onOpenChange={onOpenChange} {...props} />;\n};\n\ntype RootComponentProps = RootProps & {\n open: boolean;\n onOpenChange: (value: boolean) => void;\n};\n\nconst RootComponent = ({\n open,\n onOpenChange,\n a11yTitle,\n a11yDescription,\n children,\n layer: layerProp,\n // Focus scope props\n trapped,\n onMountAutoFocus,\n onUnmountAutoFocus,\n ...props\n}: RootComponentProps) => {\n // We use the a11yTitle as the id for the modal as it is unique\n // and can be used to identify the modal in the stacking context.\n // Without the need to generate a random id and manage between\n // different modal rendering patterns.\n const id = a11yTitle;\n const stacking = useModalStacking();\n React.useEffect(() => {\n if (!stacking || !open || stacking.layers.includes(id)) return;\n stacking.addLayer(id, { layer: layerProp });\n }, [id, layerProp, stacking, open]);\n\n const layer = stacking.layers?.indexOf(id) || 0;\n const layersLength = stacking.layers?.length || 0;\n const isStacked = layer !== 0;\n const isTopLayer = id === stacking.layers[stacking.layers.length - 1];\n\n return (\n <DismissableWrapper\n id={id}\n layers={stacking.layers}\n onEscapeKeyDown={(event) => {\n event.preventDefault();\n stacking.removeTopLayer();\n onOpenChange(false);\n }}\n onPointerDownOutside={(event) => {\n event.preventDefault();\n stacking.removeTopLayer();\n onOpenChange(false);\n }}\n >\n <Dialog.Root\n open={open}\n onOpenChange={(value) => {\n const hasLayers = stacking?.layers?.length > 0;\n\n if (hasLayers) {\n if (\n value === false &&\n id === stacking.layers[stacking.layers.length - 1]\n ) {\n stacking.removeLayer(id);\n return onOpenChange(false);\n }\n // If the modal is not the top layer, do not call onOpenChange\n // when we are stacking the modals\n return;\n }\n\n onOpenChange(value);\n }}\n key={id}\n >\n <VisuallyHidden.Root>\n <Dialog.Title>{a11yTitle}</Dialog.Title>\n {a11yDescription && (\n <Dialog.Description>{a11yDescription}</Dialog.Description>\n )}\n </VisuallyHidden.Root>\n <AnimatePresence>\n {open && (\n // We add the className \"tgph\" here so that styles within\n // the portal get scoped properly to telegraph\n <Portal.Root className=\"tgph\">\n <Overlay layer={layer}>\n <FocusScope\n trapped={typeof trapped === \"boolean\" ? trapped : isTopLayer}\n onMountAutoFocus={onMountAutoFocus}\n onUnmountAutoFocus={onUnmountAutoFocus}\n asChild\n >\n <RefToTgphRef>\n <Stack\n as={motion.div}\n initial={{\n top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${layersLength - 1})`,\n }}\n animate={{\n top: isStacked\n ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${layer} )`\n : \"var(--tgph-spacing-16)\",\n }}\n exit={{ top: 0 }}\n transition={{ type: \"spring\", duration: 0.3, bounce: 0 }}\n w=\"full\"\n justify=\"center\"\n style={{\n position: \"fixed\",\n left: 0,\n maxHeight: \"calc(100vh - var(--tgph-spacing-32))\",\n maxWidth: \"calc(100vw - var(--tgph-spacing-8))\",\n zIndex: `calc(var(--tgph-zIndex-modal) + ${layer})`,\n }}\n key={`container-${id}`}\n >\n <Stack\n direction=\"column\"\n as={motion.div}\n animate={{\n scale: 1.02 - Math.abs(layersLength - layer) * 0.02,\n transformOrigin: \"center center\",\n }}\n transition={{\n duration: 0.2,\n bounce: 0,\n type: \"spring\",\n }}\n maxW={props.maxW ?? \"160\"}\n w={props.w ?? \"full\"}\n bg=\"surface-1\"\n border=\"px\"\n rounded=\"4\"\n shadow=\"3\"\n key={`content-${id}`}\n {...props}\n >\n {children}\n </Stack>\n </Stack>\n </RefToTgphRef>\n </FocusScope>\n </Overlay>\n </Portal.Root>\n )}\n </AnimatePresence>\n </Dialog.Root>\n </DismissableWrapper>\n );\n};\n\ntype OverlayProps = TgphComponentProps<typeof Box> & {\n layer: number;\n};\n\nconst Overlay = ({ layer, children }: OverlayProps) => {\n // If the layer is greater than 0, we don't want to show this\n // overlay as to not stack the overlays on top of each other.\n if (layer > 0) return children;\n return (\n <Dialog.Overlay>\n <Box\n as={motion.div}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.3, bounce: 0, type: \"spring\" }}\n bg=\"alpha-black-6\"\n w=\"full\"\n h=\"full\"\n zIndex=\"overlay\"\n style={{\n position: \"fixed\",\n cursor: \"pointer\",\n inset: \"0px\",\n }}\n />\n {children}\n </Dialog.Overlay>\n );\n};\n\ntype ContentProps = React.ComponentPropsWithoutRef<typeof Dialog.Content> &\n TgphComponentProps<typeof Stack>;\ntype ContentRef = React.ElementRef<typeof Dialog.Content>;\n\nconst Content = React.forwardRef<ContentRef, ContentProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Dialog.Content ref={forwardedRef} asChild {...props}>\n <Stack direction=\"column\" h=\"full\" {...props}>\n {children}\n </Stack>\n </Dialog.Content>\n );\n },\n);\n\ntype CloseProps<T extends TgphElement> = TgphComponentProps<typeof Button<T>> &\n Omit<React.ComponentPropsWithoutRef<typeof Dialog.Close>, \"color\">;\nconst Close = <T extends TgphElement>({\n size = \"1\",\n variant = \"ghost\",\n ...props\n}: CloseProps<T>) => {\n return (\n <Dialog.Close asChild>\n <Button\n icon={{ icon: Lucide.X, alt: \"Close Modal\" }}\n variant={variant}\n size={size}\n {...props}\n />\n </Dialog.Close>\n );\n};\n\ntype BodyProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Stack>;\n\nconst Body = <T extends TgphElement>({\n style,\n children,\n ...props\n}: BodyProps<T>) => {\n return (\n <Stack\n direction=\"column\"\n px=\"6\"\n py=\"4\"\n style={{\n overflowY: \"auto\",\n ...style,\n }}\n {...props}\n >\n {children}\n </Stack>\n );\n};\n\ntype HeaderProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Stack>;\n\nconst Header = <T extends TgphElement>({\n children,\n ...props\n}: HeaderProps<T>) => {\n return (\n <Stack\n direction=\"row\"\n justify=\"space-between\"\n align=\"center\"\n px=\"6\"\n py=\"4\"\n borderBottom=\"px\"\n {...props}\n >\n {children}\n </Stack>\n );\n};\n\ntype FooterProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Stack>;\n\nconst Footer = <T extends TgphElement>({\n children,\n ...props\n}: FooterProps<T>) => {\n return (\n <Stack\n direction=\"row\"\n align=\"center\"\n justify=\"flex-end\"\n gap=\"2\"\n px=\"6\"\n py=\"4\"\n borderTop=\"px\"\n {...props}\n >\n {children}\n </Stack>\n );\n};\n\nconst Modal = {} as {\n Root: typeof Root;\n Content: typeof Content;\n Close: typeof Close;\n Body: typeof Body;\n Header: typeof Header;\n Footer: typeof Footer;\n};\n\nObject.assign(Modal, {\n Root,\n Content,\n Close,\n Body,\n Header,\n Footer,\n});\n\nexport { Modal };\n"],"names":["setRef","ref","value","composeRefs","refs","node","Slot","React","props","forwardedRef","children","slotProps","childrenArray","slottable","isSlottable","newElement","newChildren","child","jsx","SlotClone","childrenRef","getElementRef","mergeProps","Slottable","Fragment","childProps","overrideProps","propName","slotPropValue","childPropValue","args","element","getter","_a","mayWarn","_b","NODES","Primitive","primitive","Node","asChild","primitiveProps","Comp","useLayoutEffect2","PORTAL_NAME","Portal","containerProp","portalProps","mounted","setMounted","useLayoutEffect","container","ReactDOM","Root","useCallbackRef","callback","callbackRef","useControllableState","prop","defaultProp","onChange","uncontrolledProp","setUncontrolledProp","useUncontrolledState","isControlled","handleChange","setValue","nextValue","value2","uncontrolledState","prevValueRef","composeEventHandlers","originalEventHandler","ourEventHandler","checkForDefaultPrevented","event","dispatchDiscreteCustomEvent","target","useComposedRefs","useEscapeKeydown","onEscapeKeyDownProp","ownerDocument","onEscapeKeyDown","handleKeyDown","DISMISSABLE_LAYER_NAME","CONTEXT_UPDATE","POINTER_DOWN_OUTSIDE","FOCUS_OUTSIDE","originalBodyPointerEvents","DismissableLayerContext","DismissableLayer","disableOutsidePointerEvents","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","layerProps","context","setNode","force","composedRefs","node2","layers","highestLayerWithOutsidePointerEventsDisabled","highestLayerWithOutsidePointerEventsDisabledIndex","index","isBodyPointerEventsDisabled","isPointerEventsEnabled","pointerDownOutside","usePointerDownOutside","isPointerDownOnBranch","branch","focusOutside","useFocusOutside","dispatchUpdate","handleUpdate","BRANCH_NAME","DismissableLayerBranch","handlePointerDownOutside","isPointerInsideReactTreeRef","handleClickRef","handlePointerDown","handleAndDispatchPointerDownOutsideEvent2","handleAndDispatchCustomEvent","eventDetail","timerId","handleFocusOutside","isFocusInsideReactTreeRef","handleFocus","name","handler","detail","discrete","DismissableWrapper","id","ModalStackingContext","ModalStackingProvider","setLayers","addLayer","options","layer","current","removeLayer","removeTopLayer","useModalStacking","defaultOpenProp","openProp","onOpenChangeProp","open","onOpenChange","RootComponent","a11yTitle","a11yDescription","layerProp","trapped","onMountAutoFocus","onUnmountAutoFocus","stacking","layersLength","isStacked","isTopLayer","jsxs","Dialog","VisuallyHidden","AnimatePresence","Portal.Root","Overlay","FocusScope","RefToTgphRef","Stack","motion","Box","Content","Close","size","variant","Button","Lucide","Body","style","Header","Footer","Modal"],"mappings":"muBAEA,SAASA,GAAOC,EAAKC,EAAO,CACtB,OAAOD,GAAQ,WACjBA,EAAIC,CAAK,EACAD,GAAQ,OACjBA,EAAI,QAAUC,EAElB,CACA,SAASC,MAAeC,EAAM,CAC5B,OAAQC,GAASD,EAAK,QAASH,GAAQD,GAAOC,EAAKI,CAAI,CAAC,CAC1D,CCPA,IAAIC,EAAOC,EAAM,WAAW,CAACC,EAAOC,IAAiB,CACnD,KAAM,CAAE,SAAAC,EAAU,GAAGC,CAAS,EAAKH,EAC7BI,EAAgBL,EAAM,SAAS,QAAQG,CAAQ,EAC/CG,EAAYD,EAAc,KAAKE,EAAW,EAChD,GAAID,EAAW,CACb,MAAME,EAAaF,EAAU,MAAM,SAC7BG,EAAcJ,EAAc,IAAKK,GACjCA,IAAUJ,EACRN,EAAM,SAAS,MAAMQ,CAAU,EAAI,EAAUR,EAAM,SAAS,KAAK,IAAI,EAClEA,EAAM,eAAeQ,CAAU,EAAIA,EAAW,MAAM,SAAW,KAE/DE,CAEV,EACD,OAAuBC,EAAG,IAACC,EAAW,CAAE,GAAGR,EAAW,IAAKF,EAAc,SAAUF,EAAM,eAAeQ,CAAU,EAAIR,EAAM,aAAaQ,EAAY,OAAQC,CAAW,EAAI,IAAI,CAAE,CACnL,CACD,OAAuBE,EAAG,IAACC,EAAW,CAAE,GAAGR,EAAW,IAAKF,EAAc,SAAAC,CAAQ,CAAE,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K,EAEH,SAAAE,CAAA,CAAA,EAQD2K,GAAS,CAAwB,CACrC,SAAA3K,EACA,GAAGF,CACL,IAEIU,EAAA,IAACuJ,EAAA,MAAA,CACC,UAAU,MACV,MAAM,SACN,QAAQ,WACR,IAAI,IACJ,GAAG,IACH,GAAG,IACH,UAAU,KACT,GAAGjK,EAEH,SAAAE,CAAA,CAAA,EAKD4K,EAAQ,CAAC,EASf,OAAO,OAAOA,EAAO,CACnB,KAAAjI,GACA,QAAAuH,GACA,MAAAC,GACA,KAAAK,GACA,OAAAE,GACA,OAAAC,EACF,CAAC","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12]}
1
+ {"version":3,"file":"index.js","sources":["../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/primitive/dist/index.mjs","../../../../node_modules/@radix-ui/react-slot/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../../node_modules/@radix-ui/react-slot/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs","../../../../node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs","../../../../node_modules/@radix-ui/react-use-controllable-state/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs","../../../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs","../../src/Modal/ModalStacking.tsx","../../src/Modal/Modal.tsx"],"sourcesContent":["// packages/core/primitive/src/primitive.tsx\nfunction composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {\n return function handleEvent(event) {\n originalEventHandler?.(event);\n if (checkForDefaultPrevented === false || !event.defaultPrevented) {\n return ourEventHandler?.(event);\n }\n };\n}\nexport {\n composeEventHandlers\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/compose-refs/src/composeRefs.tsx\nimport * as React from \"react\";\nfunction setRef(ref, value) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null && ref !== void 0) {\n ref.current = value;\n }\n}\nfunction composeRefs(...refs) {\n return (node) => refs.forEach((ref) => setRef(ref, node));\n}\nfunction useComposedRefs(...refs) {\n return React.useCallback(composeRefs(...refs), refs);\n}\nexport {\n composeRefs,\n useComposedRefs\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/slot/src/Slot.tsx\nimport * as React from \"react\";\nimport { composeRefs } from \"@radix-ui/react-compose-refs\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\nvar Slot = React.forwardRef((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n if (slottable) {\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement) ? newElement.props.children : null;\n } else {\n return child;\n }\n });\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });\n }\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });\n});\nSlot.displayName = \"Slot\";\nvar SlotClone = React.forwardRef((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n return React.cloneElement(children, {\n ...mergeProps(slotProps, children.props),\n // @ts-ignore\n ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef\n });\n }\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n});\nSlotClone.displayName = \"SlotClone\";\nvar Slottable = ({ children }) => {\n return /* @__PURE__ */ jsx(Fragment, { children });\n};\nfunction isSlottable(child) {\n return React.isValidElement(child) && child.type === Slottable;\n}\nfunction mergeProps(slotProps, childProps) {\n const overrideProps = { ...childProps };\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args) => {\n childPropValue(...args);\n slotPropValue(...args);\n };\n } else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n } else if (propName === \"style\") {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === \"className\") {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(\" \");\n }\n }\n return { ...slotProps, ...overrideProps };\n}\nfunction getElementRef(element) {\n let getter = Object.getOwnPropertyDescriptor(element.props, \"ref\")?.get;\n let mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.ref;\n }\n getter = Object.getOwnPropertyDescriptor(element, \"ref\")?.get;\n mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.props.ref;\n }\n return element.props.ref || element.ref;\n}\nvar Root = Slot;\nexport {\n Root,\n Slot,\n Slottable\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/primitive/src/Primitive.tsx\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NODES = [\n \"a\",\n \"button\",\n \"div\",\n \"form\",\n \"h2\",\n \"h3\",\n \"img\",\n \"input\",\n \"label\",\n \"li\",\n \"nav\",\n \"ol\",\n \"p\",\n \"span\",\n \"svg\",\n \"ul\"\n];\nvar Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props, forwardedRef) => {\n const { asChild, ...primitiveProps } = props;\n const Comp = asChild ? Slot : node;\n if (typeof window !== \"undefined\") {\n window[Symbol.for(\"radix-ui\")] = true;\n }\n return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });\n });\n Node.displayName = `Primitive.${node}`;\n return { ...primitive, [node]: Node };\n}, {});\nfunction dispatchDiscreteCustomEvent(target, event) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\nvar Root = Primitive;\nexport {\n Primitive,\n Root,\n dispatchDiscreteCustomEvent\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/compose-refs/src/composeRefs.tsx\nimport * as React from \"react\";\nfunction setRef(ref, value) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null && ref !== void 0) {\n ref.current = value;\n }\n}\nfunction composeRefs(...refs) {\n return (node) => refs.forEach((ref) => setRef(ref, node));\n}\nfunction useComposedRefs(...refs) {\n return React.useCallback(composeRefs(...refs), refs);\n}\nexport {\n composeRefs,\n useComposedRefs\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-callback-ref/src/useCallbackRef.tsx\nimport * as React from \"react\";\nfunction useCallbackRef(callback) {\n const callbackRef = React.useRef(callback);\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);\n}\nexport {\n useCallbackRef\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-escape-keydown/src/useEscapeKeydown.tsx\nimport * as React from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nfunction useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n React.useEffect(() => {\n const handleKeyDown = (event) => {\n if (event.key === \"Escape\") {\n onEscapeKeyDown(event);\n }\n };\n ownerDocument.addEventListener(\"keydown\", handleKeyDown, { capture: true });\n return () => ownerDocument.removeEventListener(\"keydown\", handleKeyDown, { capture: true });\n }, [onEscapeKeyDown, ownerDocument]);\n}\nexport {\n useEscapeKeydown\n};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\n\n// packages/react/dismissable-layer/src/DismissableLayer.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { Primitive, dispatchDiscreteCustomEvent } from \"@radix-ui/react-primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useEscapeKeydown } from \"@radix-ui/react-use-escape-keydown\";\nimport { jsx } from \"react/jsx-runtime\";\nvar DISMISSABLE_LAYER_NAME = \"DismissableLayer\";\nvar CONTEXT_UPDATE = \"dismissableLayer.update\";\nvar POINTER_DOWN_OUTSIDE = \"dismissableLayer.pointerDownOutside\";\nvar FOCUS_OUTSIDE = \"dismissableLayer.focusOutside\";\nvar originalBodyPointerEvents;\nvar DismissableLayerContext = React.createContext({\n layers: /* @__PURE__ */ new Set(),\n layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),\n branches: /* @__PURE__ */ new Set()\n});\nvar DismissableLayer = React.forwardRef(\n (props, forwardedRef) => {\n const {\n disableOutsidePointerEvents = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);\n const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n const pointerDownOutside = usePointerDownOutside((event) => {\n const target = event.target;\n const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));\n if (!isPointerEventsEnabled || isPointerDownOnBranch) return;\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n const focusOutside = useFocusOutside((event) => {\n const target = event.target;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n useEscapeKeydown((event) => {\n const isHighestLayer = index === context.layers.size - 1;\n if (!isHighestLayer) return;\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n }, ownerDocument);\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = \"none\";\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n return /* @__PURE__ */ jsx(\n Primitive.div,\n {\n ...layerProps,\n ref: composedRefs,\n style: {\n pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? \"auto\" : \"none\" : void 0,\n ...props.style\n },\n onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),\n onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),\n onPointerDownCapture: composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture\n )\n }\n );\n }\n);\nDismissableLayer.displayName = DISMISSABLE_LAYER_NAME;\nvar BRANCH_NAME = \"DismissableLayerBranch\";\nvar DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });\n});\nDismissableLayerBranch.displayName = BRANCH_NAME;\nfunction usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);\n const isPointerInsideReactTreeRef = React.useRef(false);\n const handleClickRef = React.useRef(() => {\n });\n React.useEffect(() => {\n const handlePointerDown = (event) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n let handleAndDispatchPointerDownOutsideEvent2 = function() {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true }\n );\n };\n var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;\n const eventDetail = { originalEvent: event };\n if (event.pointerType === \"touch\") {\n ownerDocument.removeEventListener(\"click\", handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;\n ownerDocument.addEventListener(\"click\", handleClickRef.current, { once: true });\n } else {\n handleAndDispatchPointerDownOutsideEvent2();\n }\n } else {\n ownerDocument.removeEventListener(\"click\", handleClickRef.current);\n }\n isPointerInsideReactTreeRef.current = false;\n };\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener(\"pointerdown\", handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener(\"pointerdown\", handlePointerDown);\n ownerDocument.removeEventListener(\"click\", handleClickRef.current);\n };\n }, [ownerDocument, handlePointerDownOutside]);\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true\n };\n}\nfunction useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {\n const handleFocusOutside = useCallbackRef(onFocusOutside);\n const isFocusInsideReactTreeRef = React.useRef(false);\n React.useEffect(() => {\n const handleFocus = (event) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false\n });\n }\n };\n ownerDocument.addEventListener(\"focusin\", handleFocus);\n return () => ownerDocument.removeEventListener(\"focusin\", handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n return {\n onFocusCapture: () => isFocusInsideReactTreeRef.current = true,\n onBlurCapture: () => isFocusInsideReactTreeRef.current = false\n };\n}\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\nfunction handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler, { once: true });\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\nvar Root = DismissableLayer;\nvar Branch = DismissableLayerBranch;\nexport {\n Branch,\n DismissableLayer,\n DismissableLayerBranch,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-callback-ref/src/useCallbackRef.tsx\nimport * as React from \"react\";\nfunction useCallbackRef(callback) {\n const callbackRef = React.useRef(callback);\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);\n}\nexport {\n useCallbackRef\n};\n//# sourceMappingURL=index.mjs.map\n","// packages/react/use-controllable-state/src/useControllableState.tsx\nimport * as React from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nfunction useControllableState({\n prop,\n defaultProp,\n onChange = () => {\n }\n}) {\n const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });\n const isControlled = prop !== void 0;\n const value = isControlled ? prop : uncontrolledProp;\n const handleChange = useCallbackRef(onChange);\n const setValue = React.useCallback(\n (nextValue) => {\n if (isControlled) {\n const setter = nextValue;\n const value2 = typeof nextValue === \"function\" ? setter(prop) : nextValue;\n if (value2 !== prop) handleChange(value2);\n } else {\n setUncontrolledProp(nextValue);\n }\n },\n [isControlled, prop, setUncontrolledProp, handleChange]\n );\n return [value, setValue];\n}\nfunction useUncontrolledState({\n defaultProp,\n onChange\n}) {\n const uncontrolledState = React.useState(defaultProp);\n const [value] = uncontrolledState;\n const prevValueRef = React.useRef(value);\n const handleChange = useCallbackRef(onChange);\n React.useEffect(() => {\n if (prevValueRef.current !== value) {\n handleChange(value);\n prevValueRef.current = value;\n }\n }, [value, prevValueRef, handleChange]);\n return uncontrolledState;\n}\nexport {\n useControllableState\n};\n//# sourceMappingURL=index.mjs.map\n","import React from \"react\";\n\nconst ModalStackingContext = React.createContext<{\n layers: Array<string>;\n setLayers: React.Dispatch<React.SetStateAction<Array<string>>>;\n addLayer: (id: string) => void;\n removeLayer: (id: string) => void;\n removeTopLayer: () => void;\n}>({\n layers: [],\n setLayers: () => {},\n addLayer: () => {},\n removeLayer: () => {},\n removeTopLayer: () => {},\n});\n\ntype ModalStackingProviderProps = {\n children: React.ReactNode;\n};\n\nconst ModalStackingProvider = ({ children }: ModalStackingProviderProps) => {\n const [layers, setLayers] = React.useState<Array<string>>([]);\n\n const addLayer = (id: string) => {\n setLayers((current) => [...current, id]);\n };\n\n const removeLayer = (id: string) => {\n setLayers(layers.filter((layer) => layer !== id));\n };\n\n const removeTopLayer = () => {\n const id = layers[layers.length - 1];\n if (!id) return;\n removeLayer(id);\n };\n\n return (\n <ModalStackingContext.Provider\n value={{ layers, setLayers, addLayer, removeLayer, removeTopLayer }}\n >\n {children}\n </ModalStackingContext.Provider>\n );\n};\n\nconst useModalStacking = () => {\n return React.useContext(ModalStackingContext);\n};\n\nexport { ModalStackingProvider, useModalStacking };\n","import * as Dialog from \"@radix-ui/react-dialog\";\nimport { DismissableLayer } from \"@radix-ui/react-dismissable-layer\";\nimport { FocusScope } from \"@radix-ui/react-focus-scope\";\nimport * as Portal from \"@radix-ui/react-portal\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as VisuallyHidden from \"@radix-ui/react-visually-hidden\";\nimport { Button } from \"@telegraph/button\";\nimport { RefToTgphRef } from \"@telegraph/helpers\";\nimport type {\n PolymorphicProps,\n TgphComponentProps,\n TgphElement,\n} from \"@telegraph/helpers\";\nimport { Lucide } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport React from \"react\";\n\nimport { useModalStacking } from \"./ModalStacking\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.ComponentPropsWithoutRef<typeof FocusScope> &\n TgphComponentProps<typeof Stack> & {\n a11yTitle: string;\n a11yDescription?: string;\n layer?: number;\n };\n\nconst Root = ({\n defaultOpen: defaultOpenProp,\n open: openProp,\n onOpenChange: onOpenChangeProp,\n ...props\n}: RootProps) => {\n const [open, onOpenChange] = useControllableState({\n prop: openProp,\n onChange: onOpenChangeProp,\n defaultProp: defaultOpenProp,\n });\n\n // Prevent rendering anything within the modal if it is not open\n if (!open) return;\n\n return <RootComponent open={open} onOpenChange={onOpenChange} {...props} />;\n};\n\ntype RootComponentProps = RootProps & {\n open: boolean;\n onOpenChange: (value: boolean) => void;\n};\n\nconst RootComponent = ({\n open,\n onOpenChange,\n a11yTitle,\n a11yDescription,\n children,\n // Focus scope props\n trapped,\n onMountAutoFocus,\n onUnmountAutoFocus,\n ...props\n}: RootComponentProps) => {\n // We use the a11yTitle as the id for the modal as it is unique\n // and can be used to identify the modal in the stacking context.\n // Without the need to generate a random id and manage between\n // different modal rendering patterns.\n const id = a11yTitle;\n const stacking = useModalStacking();\n React.useEffect(() => {\n if (!stacking || !open || stacking.layers.includes(id)) return;\n stacking.addLayer(id);\n }, [id, stacking, open]);\n\n const layer = stacking.layers?.indexOf(id) || 0;\n const layersLength = stacking.layers?.length || 0;\n const isStacked = layer !== 0;\n const isTopLayer = id === stacking.layers[stacking.layers.length - 1];\n\n return (\n <DismissableLayer\n onEscapeKeyDown={(event) => {\n event.preventDefault();\n stacking.removeTopLayer();\n onOpenChange(false);\n }}\n onPointerDownOutside={(event) => {\n event.preventDefault();\n stacking.removeTopLayer();\n onOpenChange(false);\n }}\n >\n <Dialog.Root\n open={open}\n onOpenChange={(value) => {\n const hasLayers = stacking?.layers?.length > 0;\n\n if (hasLayers) {\n if (\n value === false &&\n id === stacking.layers[stacking.layers.length - 1]\n ) {\n stacking.removeLayer(id);\n return onOpenChange(false);\n }\n // If the modal is not the top layer, do not call onOpenChange\n // when we are stacking the modals\n return;\n }\n\n onOpenChange(value);\n }}\n key={id}\n >\n <VisuallyHidden.Root>\n <Dialog.Title>{a11yTitle}</Dialog.Title>\n {a11yDescription && (\n <Dialog.Description>{a11yDescription}</Dialog.Description>\n )}\n </VisuallyHidden.Root>\n <AnimatePresence>\n {open && (\n // We add the className \"tgph\" here so that styles within\n // the portal get scoped properly to telegraph\n <Portal.Root className=\"tgph\">\n <Overlay layer={layer}>\n <FocusScope\n trapped={typeof trapped === \"boolean\" ? trapped : isTopLayer}\n onMountAutoFocus={onMountAutoFocus}\n onUnmountAutoFocus={onUnmountAutoFocus}\n asChild\n >\n <RefToTgphRef>\n <Stack\n as={motion.div}\n initial={{\n top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${layersLength - 1})`,\n }}\n animate={{\n top: isStacked\n ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${layer} )`\n : \"var(--tgph-spacing-16)\",\n }}\n exit={{ top: 0 }}\n transition={{ type: \"spring\", duration: 0.3, bounce: 0 }}\n w=\"full\"\n justify=\"center\"\n style={{\n position: \"fixed\",\n left: 0,\n maxHeight: \"calc(100vh - var(--tgph-spacing-32))\",\n maxWidth: \"calc(100vw - var(--tgph-spacing-8))\",\n zIndex: `calc(var(--tgph-zIndex-modal) + ${layer})`,\n }}\n key={`container-${id}`}\n >\n <Stack\n direction=\"column\"\n as={motion.div}\n animate={{\n scale: 1.02 - Math.abs(layersLength - layer) * 0.02,\n transformOrigin: \"center center\",\n }}\n transition={{\n duration: 0.2,\n bounce: 0,\n type: \"spring\",\n }}\n maxW={props.maxW ?? \"160\"}\n w={props.w ?? \"full\"}\n bg=\"surface-1\"\n border=\"px\"\n rounded=\"4\"\n shadow=\"3\"\n key={`content-${id}`}\n {...props}\n >\n {children}\n </Stack>\n </Stack>\n </RefToTgphRef>\n </FocusScope>\n </Overlay>\n </Portal.Root>\n )}\n </AnimatePresence>\n </Dialog.Root>\n </DismissableLayer>\n );\n};\n\ntype OverlayProps = TgphComponentProps<typeof Box> & {\n layer: number;\n};\n\nconst Overlay = ({ layer, children }: OverlayProps) => {\n // If the layer is greater than 0, we don't want to show this\n // overlay as to not stack the overlays on top of each other.\n if (layer > 0) return children;\n return (\n <Dialog.Overlay>\n <Box\n as={motion.div}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.3, bounce: 0, type: \"spring\" }}\n bg=\"alpha-black-6\"\n w=\"full\"\n h=\"full\"\n zIndex=\"overlay\"\n style={{\n position: \"fixed\",\n cursor: \"pointer\",\n inset: \"0px\",\n }}\n />\n {children}\n </Dialog.Overlay>\n );\n};\n\ntype ContentProps = React.ComponentPropsWithoutRef<typeof Dialog.Content> &\n TgphComponentProps<typeof Stack>;\ntype ContentRef = React.ElementRef<typeof Dialog.Content>;\n\nconst Content = React.forwardRef<ContentRef, ContentProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Dialog.Content ref={forwardedRef} asChild {...props}>\n <Stack direction=\"column\" h=\"full\" {...props}>\n {children}\n </Stack>\n </Dialog.Content>\n );\n },\n);\n\ntype CloseProps<T extends TgphElement> = TgphComponentProps<typeof Button<T>> &\n Omit<React.ComponentPropsWithoutRef<typeof Dialog.Close>, \"color\">;\nconst Close = <T extends TgphElement>({\n size = \"1\",\n variant = \"ghost\",\n ...props\n}: CloseProps<T>) => {\n return (\n <Dialog.Close asChild>\n <Button\n icon={{ icon: Lucide.X, alt: \"Close Modal\" }}\n variant={variant}\n size={size}\n {...props}\n />\n </Dialog.Close>\n );\n};\n\ntype BodyProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Stack>;\n\nconst Body = <T extends TgphElement>({\n style,\n children,\n ...props\n}: BodyProps<T>) => {\n return (\n <Stack\n direction=\"column\"\n px=\"6\"\n py=\"4\"\n style={{\n overflowY: \"auto\",\n ...style,\n }}\n {...props}\n >\n {children}\n </Stack>\n );\n};\n\ntype HeaderProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Stack>;\n\nconst Header = <T extends TgphElement>({\n children,\n ...props\n}: HeaderProps<T>) => {\n return (\n <Stack\n direction=\"row\"\n justify=\"space-between\"\n align=\"center\"\n px=\"6\"\n py=\"4\"\n borderBottom=\"px\"\n {...props}\n >\n {children}\n </Stack>\n );\n};\n\ntype FooterProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Stack>;\n\nconst Footer = <T extends TgphElement>({\n children,\n ...props\n}: FooterProps<T>) => {\n return (\n <Stack\n direction=\"row\"\n align=\"center\"\n justify=\"flex-end\"\n gap=\"2\"\n px=\"6\"\n py=\"4\"\n borderTop=\"px\"\n {...props}\n >\n {children}\n </Stack>\n );\n};\n\nconst Modal = {} as {\n Root: typeof Root;\n Content: typeof Content;\n Close: typeof Close;\n Body: typeof Body;\n Header: typeof Header;\n Footer: typeof Footer;\n};\n\nObject.assign(Modal, {\n Root,\n Content,\n Close,\n Body,\n Header,\n Footer,\n});\n\nexport { Modal };\n"],"names":["composeEventHandlers","originalEventHandler","ourEventHandler","checkForDefaultPrevented","event","setRef","ref","value","composeRefs","refs","node","Slot","React","props","forwardedRef","children","slotProps","childrenArray","slottable","isSlottable","newElement","newChildren","child","jsx","SlotClone","childrenRef","getElementRef","mergeProps","Slottable","Fragment","childProps","overrideProps","propName","slotPropValue","childPropValue","args","element","getter","_a","mayWarn","_b","NODES","Primitive","primitive","Node","asChild","primitiveProps","Comp","dispatchDiscreteCustomEvent","target","ReactDOM","useComposedRefs","useCallbackRef","callback","callbackRef","useEscapeKeydown","onEscapeKeyDownProp","ownerDocument","onEscapeKeyDown","handleKeyDown","DISMISSABLE_LAYER_NAME","CONTEXT_UPDATE","POINTER_DOWN_OUTSIDE","FOCUS_OUTSIDE","originalBodyPointerEvents","DismissableLayerContext","DismissableLayer","disableOutsidePointerEvents","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","layerProps","context","setNode","force","composedRefs","node2","layers","highestLayerWithOutsidePointerEventsDisabled","highestLayerWithOutsidePointerEventsDisabledIndex","index","isBodyPointerEventsDisabled","isPointerEventsEnabled","pointerDownOutside","usePointerDownOutside","isPointerDownOnBranch","branch","focusOutside","useFocusOutside","dispatchUpdate","handleUpdate","BRANCH_NAME","DismissableLayerBranch","handlePointerDownOutside","isPointerInsideReactTreeRef","handleClickRef","handlePointerDown","handleAndDispatchPointerDownOutsideEvent2","handleAndDispatchCustomEvent","eventDetail","timerId","handleFocusOutside","isFocusInsideReactTreeRef","handleFocus","name","handler","detail","discrete","useControllableState","prop","defaultProp","onChange","uncontrolledProp","setUncontrolledProp","useUncontrolledState","isControlled","handleChange","setValue","nextValue","value2","uncontrolledState","prevValueRef","ModalStackingContext","ModalStackingProvider","setLayers","addLayer","id","current","removeLayer","layer","removeTopLayer","useModalStacking","Root","defaultOpenProp","openProp","onOpenChangeProp","open","onOpenChange","RootComponent","a11yTitle","a11yDescription","trapped","onMountAutoFocus","onUnmountAutoFocus","stacking","layersLength","isStacked","isTopLayer","jsxs","Dialog","VisuallyHidden","AnimatePresence","Portal","Overlay","FocusScope","RefToTgphRef","Stack","motion","Box","Content","Close","size","variant","Button","Lucide","Body","style","Header","Footer","Modal"],"mappings":"+wBACA,SAASA,EAAqBC,EAAsBC,EAAiB,CAAE,yBAAAC,EAA2B,EAAM,EAAG,GAAI,CAC7G,OAAO,SAAqBC,EAAO,CAEjC,GADAH,GAAA,MAAAA,EAAuBG,GACnBD,IAA6B,IAAS,CAACC,EAAM,iBAC/C,OAAOF,GAAA,YAAAA,EAAkBE,EAE/B,CACA,CCNA,SAASC,GAAOC,EAAKC,EAAO,CACtB,OAAOD,GAAQ,WACjBA,EAAIC,CAAK,EACAD,GAAQ,OACjBA,EAAI,QAAUC,EAElB,CACA,SAASC,MAAeC,EAAM,CAC5B,OAAQC,GAASD,EAAK,QAASH,GAAQD,GAAOC,EAAKI,CAAI,CAAC,CAC1D,CCPA,IAAIC,EAAOC,EAAM,WAAW,CAACC,EAAOC,IAAiB,CACnD,KAAM,CAAE,SAAAC,EAAU,GAAGC,CAAS,EAAKH,EAC7BI,EAAgBL,EAAM,SAAS,QAAQG,CAAQ,EAC/CG,EAAYD,EAAc,KAAKE,EAAW,EAChD,GAAID,EAAW,CACb,MAAME,EAAaF,EAAU,MAAM,SAC7BG,EAAcJ,EAAc,IAAKK,GACjCA,IAAUJ,EACRN,EAAM,SAAS,MAAMQ,CAAU,EAAI,EAAUR,EAAM,SAAS,KAAK,IAAI,EAClEA,EAAM,eAAeQ,CAAU,EAAIA,EAAW,MAAM,SAAW,KAE/DE,CAEV,EACD,OAAuBC,EAAG,IAACC,EAAW,CAAE,GAAGR,EAAW,IAAKF,EAAc,SAAUF,EAAM,eAAeQ,CAAU,EAAIR,EAAM,aAAaQ,EAA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