@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
6 lines (3 loc) • 6.33 kB
JavaScript
"use strict";const V=require("react"),g=require("./index-DMAkK3b-.js"),p=require("./index-CajSSBH7.js"),O=require("./index-DO-atGp-.js"),_=require("./index-C7R_tQdV.js"),z=require("./index-BhY3ui5c.js"),N=require("./index-Do9UgWQm.js"),D=require("./index-BjyM_flz.js"),h=require("./index-B4SDXrpf.js");require("react-dom");const i=require("react/jsx-runtime");function K(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const a=K(V);var U=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v=U.reduce((e,t)=>{const o=p.createSlot(`Primitive.${t}`),r=a.forwardRef((s,n)=>{const{asChild:l,...c}=s,d=l?o:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(d,{...c,ref:n})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),x="Dialog",[I]=O.createContextScope(x),[Y,u]=I(x),b=e=>{const{__scopeDialog:t,children:o,open:r,defaultOpen:s,onOpenChange:n,modal:l=!0}=e,c=a.useRef(null),d=a.useRef(null),[C,R]=z.useControllableState({prop:r,defaultProp:s??!1,onChange:n,caller:x});return i.jsx(Y,{scope:t,triggerRef:c,contentRef:d,contentId:_.useId(),titleId:_.useId(),descriptionId:_.useId(),open:C,onOpenChange:R,onOpenToggle:a.useCallback(()=>R(B=>!B),[R]),modal:l,children:o})};b.displayName=x;var j="DialogTrigger",T=a.forwardRef((e,t)=>{const{__scopeDialog:o,...r}=e,s=u(j,o),n=p.useComposedRefs(t,s.triggerRef);return i.jsx(v.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":P(s.open),...r,ref:n,onClick:g.composeEventHandlers(e.onClick,s.onOpenToggle)})});T.displayName=j;var y="DialogPortal",[Z,A]=I(y,{forceMount:void 0}),w=e=>{const{__scopeDialog:t,forceMount:o,children:r,container:s}=e,n=u(y,t);return i.jsx(Z,{scope:t,forceMount:o,children:a.Children.map(r,l=>i.jsx(h.Presence,{present:o||n.open,children:i.jsx(N.Portal,{asChild:!0,container:s,children:l})}))})};w.displayName=y;var m="DialogOverlay",M=a.forwardRef((e,t)=>{const o=A(m,e.__scopeDialog),{forceMount:r=o.forceMount,...s}=e,n=u(m,e.__scopeDialog);return n.modal?i.jsx(h.Presence,{present:r||n.open,children:i.jsx(Q,{...s,ref:t})}):null});M.displayName=m;var J=p.createSlot("DialogOverlay.RemoveScroll"),Q=a.forwardRef((e,t)=>{const{__scopeDialog:o,...r}=e,s=u(m,o);return i.jsx(D.ReactRemoveScroll,{as:J,allowPinchZoom:!0,shards:[s.contentRef],children:i.jsx(v.div,{"data-state":P(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),f="DialogContent",S=a.forwardRef((e,t)=>{const o=A(f,e.__scopeDialog),{forceMount:r=o.forceMount,...s}=e,n=u(f,e.__scopeDialog);return i.jsx(h.Presence,{present:r||n.open,children:n.modal?i.jsx(X,{...s,ref:t}):i.jsx(ee,{...s,ref:t})})});S.displayName=f;var X=a.forwardRef((e,t)=>{const o=u(f,e.__scopeDialog),r=a.useRef(null),s=p.useComposedRefs(t,o.contentRef,r);return a.useEffect(()=>{const n=r.current;if(n)return D.hideOthers(n)},[]),i.jsx(F,{...e,ref:s,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:g.composeEventHandlers(e.onCloseAutoFocus,n=>{n.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:g.composeEventHandlers(e.onPointerDownOutside,n=>{const l=n.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&n.preventDefault()}),onFocusOutside:g.composeEventHandlers(e.onFocusOutside,n=>n.preventDefault())})}),ee=a.forwardRef((e,t)=>{const o=u(f,e.__scopeDialog),r=a.useRef(!1),s=a.useRef(!1);return i.jsx(F,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{e.onCloseAutoFocus?.(n),n.defaultPrevented||(r.current||o.triggerRef.current?.focus(),n.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:n=>{e.onInteractOutside?.(n),n.defaultPrevented||(r.current=!0,n.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const l=n.target;o.triggerRef.current?.contains(l)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&s.current&&n.preventDefault()}})}),F=a.forwardRef((e,t)=>{const{__scopeDialog:o,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:n,...l}=e,c=u(f,o),d=a.useRef(null),C=p.useComposedRefs(t,d);return D.useFocusGuards(),i.jsxs(i.Fragment,{children:[i.jsx(D.FocusScope,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:n,children:i.jsx(N.DismissableLayer,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":P(c.open),...l,ref:C,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(te,{titleId:c.titleId}),i.jsx(ne,{contentRef:d,descriptionId:c.descriptionId})]})]})}),E="DialogTitle",$=a.forwardRef((e,t)=>{const{__scopeDialog:o,...r}=e,s=u(E,o);return i.jsx(v.h2,{id:s.titleId,...r,ref:t})});$.displayName=E;var q="DialogDescription",W=a.forwardRef((e,t)=>{const{__scopeDialog:o,...r}=e,s=u(q,o);return i.jsx(v.p,{id:s.descriptionId,...r,ref:t})});W.displayName=q;var k="DialogClose",G=a.forwardRef((e,t)=>{const{__scopeDialog:o,...r}=e,s=u(k,o);return i.jsx(v.button,{type:"button",...r,ref:t,onClick:g.composeEventHandlers(e.onClick,()=>s.onOpenChange(!1))})});G.displayName=k;function P(e){return e?"open":"closed"}var L="DialogTitleWarning",[fe,H]=O.createContext2(L,{contentName:f,titleName:E,docsSlug:"dialog"}),te=({titleId:e})=>{const t=H(L),o=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return a.useEffect(()=>{e&&(document.getElementById(e)||console.error(o))},[o,e]),null},oe="DialogDescriptionWarning",ne=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${H(oe).contentName}}.`;return a.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},re=b,se=T,ie=w,ae=M,ce=S,le=$,ue=W,de=G;exports.Close=de;exports.Content=ce;exports.Description=ue;exports.Overlay=ae;exports.Portal=ie;exports.Root=re;exports.Title=le;exports.Trigger=se;