@radix-ui/react-dialog 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ export interface DialogPortalProps extends Omit<PortalProps, 'asChild'> {
32
32
  */
33
33
  forceMount?: true;
34
34
  }
35
- export const DialogPortal: React.ForwardRefExoticComponent<DialogPortalProps & React.RefAttributes<HTMLDivElement>>;
35
+ export const DialogPortal: React.FC<DialogPortalProps>;
36
36
  export interface DialogOverlayProps extends DialogOverlayImplProps {
37
37
  /**
38
38
  * Used to force mounting when more control is needed. Useful when
@@ -97,7 +97,7 @@ export const LabelWarningProvider: {
97
97
  };
98
98
  export const Root: React.FC<DialogProps>;
99
99
  export const Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
100
- export const Portal: React.ForwardRefExoticComponent<DialogPortalProps & React.RefAttributes<HTMLDivElement>>;
100
+ export const Portal: React.FC<DialogPortalProps>;
101
101
  export const Overlay: React.ForwardRefExoticComponent<DialogOverlayProps & React.RefAttributes<HTMLDivElement>>;
102
102
  export const Content: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;
103
103
  export const Title: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;A;A;A;AA0BA,OAAA,wFAAgF,CAAC;AAgBjF,yBAAyB,MAAM,cAAc,CAAC,mBAAmB,CAAC,CAAC;AACnE;IACE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;A;OAEG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACrD,QAA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;A;A;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;CAC1D;AA2DD,8BAA8B,MAAM,wBAAwB,CAAC,OAAO,UAAU,EAAE,CAAC,CAAC;AAClF,iCAA2B,SAAQ,sBAAsB;CAAG;AAE5D,OAAA,MAAM,wGAML,CAAC;AAWF,+BAA+B,MAAM,wBAAwB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;AAClF,uCAAiC,SAAQ,uBAAuB;CAAG;AAEnE,OAAA,MAAM,sHAML,CAAC;AAWF,iCAA2B,SAAQ,oBAAoB;CAAG;AAE1D,OAAA,MAAM,uGAaL,CAAC;AAYF,OAAA;A;A;A;A;A;A;A;A;CAIE,CAAC;AA4BH,OAAA,MAAM,2BAAa,CAAC;AACpB,OAAA,MAAM,qGAAuB,CAAC;AAC9B,OAAA,MAAM,gGAAqB,CAAC;AAC5B,OAAA,MAAM,kGAAuB,CAAC;AAC9B,OAAA,MAAM,kGAAuB,CAAC;AAC9B,OAAA,MAAM,kGAAmB,CAAC;AAC1B,OAAA,MAAM,gHAA+B,CAAC;AACtC,OAAA,MAAM,iGAAmB,CAAC","sources":["./packages/react/dialog/src/packages/react/dialog/src/Dialog.tsx","./packages/react/dialog/src/packages/react/dialog/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":"A;A;A;A;A;A;A;AA0BA,OAAA,wFAAgF,CAAC;AAiBjF,yBAAyB,MAAM,cAAc,CAAC,mBAAmB,CAAC,CAAC;AACnE;IACE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;A;OAEG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,MAAM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AC;IAEtD;A;A;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;CAC1D;AA2DD,8BAA8B,MAAM,wBAAwB,CAAC,OAAO,UAAU,EAAE,CAAC,CAAC;AAClF,iCAA2B,SAAQ,sBAAsB;CAAG;AAE5D,OAAA,MAAM,wGAML,CAAC;AAWF,+BAA+B,MAAM,wBAAwB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;AAClF,uCAAiC,SAAQ,uBAAuB;CAAG;AAEnE,OAAA,MAAM,sHAML,CAAC;AAWF,iCAA2B,SAAQ,oBAAoB;CAAG;AAE1D,OAAA,MAAM,uGAaL,CAAC;AAYF,OAAA;A;A;A;A;A;A;A;A;CAIE,CAAC;AA4BH,OAAA,MAAM,2BAAa,CAAC;AACpB,OAAA,MAAM,qGAAuB,CAAC;AAC9B,OAAA,MAAM,mCAAqB,CAAC;AAC5B,OAAA,MAAM,kGAAuB,CAAC;AAC9B,OAAA,MAAM,kGAAuB,CAAC;AAC9B,OAAA,MAAM,kGAAmB,CAAC;AAC1B,OAAA,MAAM,gHAA+B,CAAC;AACtC,OAAA,MAAM,iGAAmB,CAAC","sources":["./packages/react/dialog/src/packages/react/dialog/src/Dialog.tsx","./packages/react/dialog/src/packages/react/dialog/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e,t,o,r=require("@radix-ui/react-slot").Slot,n=require("aria-hidden").hideOthers,a=require("react-remove-scroll").RemoveScroll,l=require("@radix-ui/react-focus-guards").useFocusGuards,i=require("@radix-ui/react-primitive").Primitive,s=require("@radix-ui/react-presence").Presence,c=require("@radix-ui/react-portal").UnstablePortal,u=require("@radix-ui/react-focus-scope").FocusScope,d=require("@radix-ui/react-dismissable-layer").DismissableLayer,p=require("@radix-ui/react-use-controllable-state").useControllableState,g=require("@radix-ui/react-id").useId,f=require("@radix-ui/react-context"),D=f.createContext,m=f.createContextScope,v=require("@radix-ui/react-compose-refs").useComposedRefs,x=require("@radix-ui/primitive").composeEventHandlers,C=(e={},t=require("react"),Object.keys(t).forEach((function(o){"default"!==o&&"__esModule"!==o&&Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[o]}})})),e),b=(o=require("@babel/runtime/helpers/extends"))&&o.__esModule?o.default:o;const[_,E]=m("Dialog");exports.createDialogScope=E;const[O,R]=_("Dialog"),h=e=>{const{__scopeDialog:t,children:o,open:r,defaultOpen:n,onOpenChange:a,modal:l=!0,allowPinchZoom:i}=e,s=C.useRef(null),[c=!1,u]=p({prop:r,defaultProp:n,onChange:a});/*#__PURE__*/return C.createElement(O,{scope:t,triggerRef:s,contentId:g(),titleId:g(),descriptionId:g(),open:c,onOpenChange:u,onOpenToggle:C.useCallback((()=>u((e=>!e))),[u]),modal:l,allowPinchZoom:i},o)};exports.Dialog=h;const P=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=R("DialogTrigger",o),a=v(t,n.triggerRef);/*#__PURE__*/return C.createElement(i.button,b({type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":Z(n.open)},r,{ref:a,onClick:x(e.onClick,n.onOpenToggle)}))}));exports.DialogTrigger=P;const w=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,forceMount:r,children:n,...a}=e,l=R("DialogPortal",o);/*#__PURE__*/return C.createElement(C.Fragment,null,C.Children.map(n,(e=>/*#__PURE__*/C.createElement(s,{present:r||l.open},/*#__PURE__*/C.createElement(c,b({},a,{asChild:!0,ref:t}),e)))))}));exports.DialogPortal=w;const y=/*#__PURE__*/C.forwardRef(((e,t)=>{const{forceMount:o,...r}=e,n=R("DialogOverlay",e.__scopeDialog);return n.modal?/*#__PURE__*/C.createElement(s,{present:o||n.open},/*#__PURE__*/C.createElement(F,b({},r,{ref:t}))):null}));exports.DialogOverlay=y;const F=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...n}=e,l=R("DialogOverlay",o);/*#__PURE__*/return C.createElement(a,{as:r,allowPinchZoom:l.allowPinchZoom},/*#__PURE__*/C.createElement(i.div,b({"data-state":Z(l.open)},n,{ref:t,style:{pointerEvents:"auto",...n.style}})))})),q=/*#__PURE__*/C.forwardRef(((e,t)=>{const{forceMount:o,...r}=e,n=R("DialogContent",e.__scopeDialog);/*#__PURE__*/return C.createElement(s,{present:o||n.open},n.modal?/*#__PURE__*/C.createElement(I,b({},r,{ref:t})):/*#__PURE__*/C.createElement(T,b({},r,{ref:t})))}));exports.DialogContent=q;const I=/*#__PURE__*/C.forwardRef(((e,t)=>{const o=R("DialogContent",e.__scopeDialog),r=C.useRef(null),a=v(t,r);return C.useEffect((()=>{const e=r.current;if(e)return n(e)}),[]),/*#__PURE__*/C.createElement(A,b({},e,{ref:a,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:x(e.onCloseAutoFocus,(e=>{var t;e.preventDefault(),null===(t=o.triggerRef.current)||void 0===t||t.focus()})),onPointerDownOutside:x(e.onPointerDownOutside,(e=>{const t=e.detail.originalEvent,o=0===t.button&&!0===t.ctrlKey;(2===t.button||o)&&e.preventDefault()})),onFocusOutside:x(e.onFocusOutside,(e=>e.preventDefault()))}))})),T=/*#__PURE__*/C.forwardRef(((e,t)=>{const o=R("DialogContent",e.__scopeDialog),r=C.useRef(!1);/*#__PURE__*/return C.createElement(A,b({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var n,a;(null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),t.defaultPrevented)||(r.current||null===(a=o.triggerRef.current)||void 0===a||a.focus(),t.preventDefault());r.current=!1},onInteractOutside:t=>{var n,a;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||(r.current=!0);const l=t.target;(null===(a=o.triggerRef.current)||void 0===a?void 0:a.contains(l))&&t.preventDefault()}}))})),A=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,"aria-label":r,"aria-labelledby":n,"aria-describedby":a,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:c,...p}=e,g=R("DialogContent",o),f=C.useRef(null),D=v(t,f);return l(),/*#__PURE__*/C.createElement(C.Fragment,null,/*#__PURE__*/C.createElement(u,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:c},/*#__PURE__*/C.createElement(d,b({role:"dialog",id:g.contentId,"aria-describedby":a||g.descriptionId,"aria-labelledby":r?void 0:n||g.titleId,"aria-label":r||void 0,"data-state":Z(g.open)},p,{ref:D,onDismiss:()=>g.onOpenChange(!1)}))),!1)})),S=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=R("DialogTitle",o);/*#__PURE__*/return C.createElement(i.h2,b({id:n.titleId},r,{ref:t}))}));exports.DialogTitle=S;const k=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=R("DialogDescription",o);/*#__PURE__*/return C.createElement(i.p,b({id:n.descriptionId},r,{ref:t}))}));exports.DialogDescription=k;const M=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=R("DialogClose",o);/*#__PURE__*/return C.createElement(i.button,b({type:"button"},r,{ref:t,onClick:x(e.onClick,(()=>n.onOpenChange(!1)))}))}));function Z(e){return e?"open":"closed"}exports.DialogClose=M;const[L,j]=D("DialogLabelWarning",{contentName:"DialogContent",titleName:"DialogTitle",docsSlug:"dialog"});exports.LabelWarningProvider=L;const N=h;exports.Root=N;const U=P;exports.Trigger=U;const W=w;exports.Portal=W;const G=y;exports.Overlay=G;const H=q;exports.Content=H;const K=S;exports.Title=K;const z=k;exports.Description=z;const B=M;exports.Close=B;
1
+ var e,t,o,r=require("@radix-ui/react-slot").Slot,n=require("aria-hidden").hideOthers,a=require("react-remove-scroll").RemoveScroll,l=require("@radix-ui/react-focus-guards").useFocusGuards,i=require("@radix-ui/react-primitive").Primitive,s=require("@radix-ui/react-presence").Presence,c=require("@radix-ui/react-portal").UnstablePortal,u=require("@radix-ui/react-focus-scope").FocusScope,d=require("@radix-ui/react-dismissable-layer").DismissableLayer,p=require("@radix-ui/react-use-controllable-state").useControllableState,g=require("@radix-ui/react-id").useId,f=require("@radix-ui/react-context"),D=f.createContext,m=f.createContextScope,v=require("@radix-ui/react-compose-refs").useComposedRefs,x=require("@radix-ui/primitive").composeEventHandlers,C=(e={},t=require("react"),Object.keys(t).forEach((function(o){"default"!==o&&"__esModule"!==o&&Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[o]}})})),e),b=(o=require("@babel/runtime/helpers/extends"))&&o.__esModule?o.default:o;const[_,E]=m("Dialog");exports.createDialogScope=E;const[R,O]=_("Dialog"),h=e=>{const{__scopeDialog:t,children:o,open:r,defaultOpen:n,onOpenChange:a,modal:l=!0,allowPinchZoom:i}=e,s=C.useRef(null),c=C.useRef(null),[u=!1,d]=p({prop:r,defaultProp:n,onChange:a});/*#__PURE__*/return C.createElement(R,{scope:t,triggerRef:s,contentRef:c,contentId:g(),titleId:g(),descriptionId:g(),open:u,onOpenChange:d,onOpenToggle:C.useCallback((()=>d((e=>!e))),[d]),modal:l,allowPinchZoom:i},o)};exports.Dialog=h;const P=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=O("DialogTrigger",o),a=v(t,n.triggerRef);/*#__PURE__*/return C.createElement(i.button,b({type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":Z(n.open)},r,{ref:a,onClick:x(e.onClick,n.onOpenToggle)}))}));exports.DialogTrigger=P;const y=e=>{const{__scopeDialog:t,forceMount:o,children:r,container:n}=e,a=O("DialogPortal",t);/*#__PURE__*/return C.createElement(C.Fragment,null,C.Children.map(r,(e=>/*#__PURE__*/C.createElement(s,{present:o||a.open},/*#__PURE__*/C.createElement(c,{asChild:!0,container:n},e)))))};exports.DialogPortal=y;const F=/*#__PURE__*/C.forwardRef(((e,t)=>{const{forceMount:o,...r}=e,n=O("DialogOverlay",e.__scopeDialog);return n.modal?/*#__PURE__*/C.createElement(s,{present:o||n.open},/*#__PURE__*/C.createElement(q,b({},r,{ref:t}))):null}));exports.DialogOverlay=F;const q=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...n}=e,l=O("DialogOverlay",o);/*#__PURE__*/return C.createElement(a,{as:r,allowPinchZoom:l.allowPinchZoom,shards:[l.contentRef]},/*#__PURE__*/C.createElement(i.div,b({"data-state":Z(l.open)},n,{ref:t,style:{pointerEvents:"auto",...n.style}})))})),w=/*#__PURE__*/C.forwardRef(((e,t)=>{const{forceMount:o,...r}=e,n=O("DialogContent",e.__scopeDialog);/*#__PURE__*/return C.createElement(s,{present:o||n.open},n.modal?/*#__PURE__*/C.createElement(I,b({},r,{ref:t})):/*#__PURE__*/C.createElement(T,b({},r,{ref:t})))}));exports.DialogContent=w;const I=/*#__PURE__*/C.forwardRef(((e,t)=>{const o=O("DialogContent",e.__scopeDialog),r=C.useRef(null),a=v(t,o.contentRef,r);return C.useEffect((()=>{const e=r.current;if(e)return n(e)}),[]),/*#__PURE__*/C.createElement(A,b({},e,{ref:a,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:x(e.onCloseAutoFocus,(e=>{var t;e.preventDefault(),null===(t=o.triggerRef.current)||void 0===t||t.focus()})),onPointerDownOutside:x(e.onPointerDownOutside,(e=>{const t=e.detail.originalEvent,o=0===t.button&&!0===t.ctrlKey;(2===t.button||o)&&e.preventDefault()})),onFocusOutside:x(e.onFocusOutside,(e=>e.preventDefault()))}))})),T=/*#__PURE__*/C.forwardRef(((e,t)=>{const o=O("DialogContent",e.__scopeDialog),r=C.useRef(!1);/*#__PURE__*/return C.createElement(A,b({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var n,a;(null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),t.defaultPrevented)||(r.current||null===(a=o.triggerRef.current)||void 0===a||a.focus(),t.preventDefault());r.current=!1},onInteractOutside:t=>{var n,a;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||(r.current=!0);const l=t.target;(null===(a=o.triggerRef.current)||void 0===a?void 0:a.contains(l))&&t.preventDefault()}}))})),A=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,"aria-label":r,"aria-labelledby":n,"aria-describedby":a,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:c,...p}=e,g=O("DialogContent",o),f=C.useRef(null),D=v(t,f);return l(),/*#__PURE__*/C.createElement(C.Fragment,null,/*#__PURE__*/C.createElement(u,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:c},/*#__PURE__*/C.createElement(d,b({role:"dialog",id:g.contentId,"aria-describedby":a||g.descriptionId,"aria-labelledby":r?void 0:n||g.titleId,"aria-label":r||void 0,"data-state":Z(g.open)},p,{ref:D,onDismiss:()=>g.onOpenChange(!1)}))),!1)})),S=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=O("DialogTitle",o);/*#__PURE__*/return C.createElement(i.h2,b({id:n.titleId},r,{ref:t}))}));exports.DialogTitle=S;const k=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=O("DialogDescription",o);/*#__PURE__*/return C.createElement(i.p,b({id:n.descriptionId},r,{ref:t}))}));exports.DialogDescription=k;const M=/*#__PURE__*/C.forwardRef(((e,t)=>{const{__scopeDialog:o,...r}=e,n=O("DialogClose",o);/*#__PURE__*/return C.createElement(i.button,b({type:"button"},r,{ref:t,onClick:x(e.onClick,(()=>n.onOpenChange(!1)))}))}));function Z(e){return e?"open":"closed"}exports.DialogClose=M;const[L,j]=D("DialogLabelWarning",{contentName:"DialogContent",titleName:"DialogTitle",docsSlug:"dialog"});exports.LabelWarningProvider=L;const N=h;exports.Root=N;const U=P;exports.Trigger=U;const W=y;exports.Portal=W;const G=F;exports.Overlay=G;const H=w;exports.Content=H;const K=S;exports.Title=K;const z=k;exports.Description=z;const B=M;exports.Close=B;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"IAYgCA,EAAMC,EAZNC,2uBAYAF,KAAMC,mBACpCE,OAAOC,KAAKH,GAAQI,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeP,EAAMM,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOR,EAAOK,SAKbN,MA1BuBE,8CAClBA,EAAEQ,WAAaR,EAAES,QAAUT,ECsBzC,MAGOU,EAAqBC,GAAqBC,EAH7B,sCAiBpB,MAAOC,EAAgBC,GAAoBJ,EAjBvB,UAgCdK,EAAiCC,IACrC,MAAMC,cACJA,EADIC,SAEJA,EACAC,KAAMC,EAHFC,YAIJA,EAJIC,aAKJA,EALIC,MAMJA,GAAQ,EANJC,eAOJA,GACER,EACES,EAAaC,EAAMC,OAA0B,OAC5CR,GAAO,EAAOS,GAAWC,EAAqB,CACnDC,KAAMV,EACNW,YAAaV,EACbW,SAAUV,iBAGZ,OACEW,EAAAC,cAACC,EAAD,CACEC,MAAOnB,EACPQ,WAAYA,EACZY,UAAWC,IACXC,QAASD,IACTE,cAAeF,IACfnB,KAAMA,EACNG,aAAcM,EACda,aAAcf,EAAMgB,aAAY,IAAMd,GAASe,IAAcA,KAAW,CAACf,IACzEL,MAAOA,EACPC,eAAgBA,GAEfN,qBAWP,MAMM0B,eAAgBlB,EAAMmB,YAC1B,CAAC7B,EAAwC8B,KACvC,MAAM7B,cAAEA,KAAkB8B,GAAiB/B,EACrCgC,EAAUlC,EATC,gBAS8BG,GACzCgC,EAAqBC,EAAgBJ,EAAcE,EAAQvB,yBACjE,OACEQ,EAAAC,cAACiB,EAAUC,OAAXC,EAAA,CACEC,KAAK,SACL,gBAAc,SACd,gBAAe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js","./packages/react/dialog/src/Dialog.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext, createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { FocusScope } from '@radix-ui/react-focus-scope';\nimport { UnstablePortal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\nimport { Slot } from '@radix-ui/react-slot';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n allowPinchZoom: DialogProps['allowPinchZoom'];\n};\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ntype RemoveScrollProps = React.ComponentProps<typeof RemoveScroll>;\ninterface DialogProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom'];\n children?: React.ReactNode;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n allowPinchZoom,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n allowPinchZoom={allowPinchZoom}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n (props: ScopedProps<DialogTriggerProps>, forwardedRef) => {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof UnstablePortal>;\ntype DialogPortalElement = React.ElementRef<typeof UnstablePortal>;\ninterface DialogPortalProps extends Omit<PortalProps, 'asChild'> {\n children?: React.ReactNode;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogPortal = React.forwardRef<DialogPortalElement, DialogPortalProps>(\n (props: ScopedProps<DialogPortalProps>, forwardedRef) => {\n const { __scopeDialog, forceMount, children, ...portalProps } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <UnstablePortal {...portalProps} asChild ref={forwardedRef}>\n {child}\n </UnstablePortal>\n </Presence>\n ))}\n </>\n );\n }\n);\n\nDialogPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogOverlay = React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n (props: ScopedProps<DialogOverlayProps>, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n }\n);\n\nDialogOverlay.displayName = OVERLAY_NAME;\n\ntype DialogOverlayImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst DialogOverlayImpl = React.forwardRef<DialogOverlayImplElement, DialogOverlayImplProps>(\n (props: ScopedProps<DialogOverlayImplProps>, forwardedRef) => {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n return (\n <RemoveScroll as={Slot} allowPinchZoom={context.allowPinchZoom}>\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={forwardedRef}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogContent = React.forwardRef<DialogContentElement, DialogContentProps>(\n (props: ScopedProps<DialogContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n }\n);\n\nDialogContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps\n extends Omit<DialogContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {}\n\nconst DialogContentModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault()\n )}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) hasInteractedOutsideRef.current = true;\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n //\n // We use `onInteractOutside` as some browsers also\n // focus on pointer down, creating the same issue.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ElementRef<typeof DismissableLayer>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n}\n\nconst DialogContentImpl = React.forwardRef<DialogContentImplElement, DialogContentImplProps>(\n (props: ScopedProps<DialogContentImplProps>, forwardedRef) => {\n const {\n __scopeDialog,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (beacuse of the `Portal`)\n useFocusGuards();\n\n return (\n <>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-describedby={ariaDescribedBy || context.descriptionId}\n // If `aria-label` is set, ensure `aria-labelledby` is undefined as to avoid confusion.\n // Otherwise fallback to an explicit `aria-labelledby` or the ID used in the\n // `DialogTitle`\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy || context.titleId}\n aria-label={ariaLabel || undefined}\n data-state={getState(context.open)}\n {...contentProps}\n ref={composedRefs}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n {process.env.NODE_ENV === 'development' && <LabelWarning contentRef={contentRef} />}\n </>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'DialogTitle';\n\ntype DialogTitleElement = React.ElementRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = Radix.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = React.forwardRef<DialogTitleElement, DialogTitleProps>(\n (props: ScopedProps<DialogTitleProps>, forwardedRef) => {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME, __scopeDialog);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n }\n);\n\nDialogTitle.displayName = TITLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'DialogDescription';\n\ntype DialogDescriptionElement = React.ElementRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = Radix.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = React.forwardRef<DialogDescriptionElement, DialogDescriptionProps>(\n (props: ScopedProps<DialogDescriptionProps>, forwardedRef) => {\n const { __scopeDialog, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n }\n);\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ElementRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = React.forwardRef<DialogCloseElement, DialogCloseProps>(\n (props: ScopedProps<DialogCloseProps>, forwardedRef) => {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n }\n);\n\nDialogClose.displayName = CLOSE_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst LABEL_WARNING_NAME = 'DialogLabelWarning';\n\nconst [LabelWarningProvider, useLabelWarningContext] = createContext(LABEL_WARNING_NAME, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = useLabelWarningContext(LABEL_WARNING_NAME);\n\n const MESSAGE = `\\`${labelWarningContext.contentName}\\` requires a label for the component to be accessible for screen reader users.\n\nYou can label the \\`${labelWarningContext.contentName}\\` by passing a \\`${labelWarningContext.titleName}\\` component as a child, which also benefits sighted users by adding visible context to the dialog.\n\nAlternatively, you can use your own component as a title by assigning it an \\`id\\` and passing the same value to the \\`aria-labelledby\\` prop in \\`${labelWarningContext.contentName}\\`. If the label is confusing or duplicative for sighted users, you can also pass a label directly by using the \\`aria-label\\` prop.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${labelWarningContext.docsSlug}`;\n\n React.useEffect(() => {\n const hasLabel =\n contentRef.current?.getAttribute('aria-label') ||\n document.getElementById(contentRef.current?.getAttribute('aria-labelledby')!);\n\n if (!hasLabel) console.warn(MESSAGE);\n }, [MESSAGE, contentRef]);\n\n return null;\n};\n\nconst Root = Dialog;\nconst Trigger = DialogTrigger;\nconst Portal = DialogPortal;\nconst Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Portal,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],"names":["dest","source","a","Object","keys","forEach","key","defineProperty","enumerable","get","__esModule","default","createDialogContext","createDialogScope","createContextScope","DialogProvider","useDialogContext","Dialog","props","__scopeDialog","children","open","openProp","defaultOpen","onOpenChange","modal","allowPinchZoom","triggerRef","React","useRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$b0496301423b3238f89fb15bee25ad02$var$DialogProvider","scope","contentId","useId","titleId","descriptionId","onOpenToggle","useCallback","prevOpen","DialogTrigger","forwardRef","forwardedRef","triggerProps","context","composedTriggerRef","useComposedRefs","Primitive","button","_babelRuntimeHelpersExtends","type","getState","ref","onClick","composeEventHandlers","DialogPortal","forceMount","portalProps","Fragment","Children","map","child","Presence","present","UnstablePortal","asChild","DialogOverlay","overlayProps","$b0496301423b3238f89fb15bee25ad02$var$DialogOverlayImpl","DialogOverlayImpl","RemoveScroll","as","Slot","div","style","pointerEvents","DialogContent","contentProps","$b0496301423b3238f89fb15bee25ad02$var$DialogContentModal","$b0496301423b3238f89fb15bee25ad02$var$DialogContentNonModal","DialogContentModal","contentRef","composedRefs","useEffect","content","current","hideOthers","$b0496301423b3238f89fb15bee25ad02$var$DialogContentImpl","trapFocus","disableOutsidePointerEvents","onCloseAutoFocus","event","_context$triggerRef$c","preventDefault","focus","onPointerDownOutside","originalEvent","detail","ctrlLeftClick","ctrlKey","onFocusOutside","DialogContentNonModal","hasInteractedOutsideRef","_props$onCloseAutoFoc","_context$triggerRef$c2","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","_context$triggerRef$c3","target","contains","DialogContentImpl","ariaLabel","ariaLabelledBy","ariaDescribedBy","onOpenAutoFocus","useFocusGuards","FocusScope","loop","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","undefined","onDismiss","DialogTitle","titleProps","h2","DialogDescription","descriptionProps","p","DialogClose","closeProps","LabelWarningProvider","useLabelWarningContext","createContext","contentName","titleName","docsSlug","Root","Trigger","Portal","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.js.map"}
1
+ {"mappings":"IAYgCA,EAAMC,EAZNC,2uBAYAF,KAAMC,mBACpCE,OAAOC,KAAKH,GAAQI,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeP,EAAMM,EAAK,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jF,EAAQT,SAAa8F,EAAvC,CAAmD7E,IAAKV,8BAUnE,MAMMyF,eAAoB9G,EAAMoB,YAC9B,CAAC9B,EAA4C+B,KAC3C,MAAM9B,cAAEA,KAAkBwH,GAAqBzH,EACzCiC,EAAUnC,EATK,oBAS8BG,gBACnD,OAAOiB,EAAAC,cAACiB,EAAUsF,EAAXpF,EAAA,CAAa4E,GAAIjF,EAAQR,eAAmBgG,EAA5C,CAA8DhF,IAAKV,oCAU9E,MAKM4F,eAAcjH,EAAMoB,YACxB,CAAC9B,EAAsC+B,KACrC,MAAM9B,cAAEA,KAAkB2H,GAAe5H,EACnCiC,EAAUnC,EARD,cAQ8BG,gBAC7C,OACEiB,EAAAC,cAACiB,EAAUC,OAAXC,EAAA,CACEC,KAAK,UACDqF,EAFN,CAGEnF,IAAKV,EACLW,QAASC,EAAqB3C,EAAM0C,SAAS,IAAMT,EAAQ3B,cAAa,WAUhF,SAASkC,EAASrC,GAChB,OAAOA,EAAO,OAAS,+BAGzB,MAEO0H,EAAsBC,GAA0BC,EAF5B,qBAE8D,CACvFC,YAjRmB,gBAkRnBC,UAxEiB,cAyEjBC,SAAU,0CAOZ,MAsBMC,EAAOpI,iBACb,MAAMqI,EAAUvG,oBAChB,MAAMwG,EAASzF,mBACf,MAAM0F,EAAU/E,oBAChB,MAAMgF,EAAUrE,oBAChB,MAAMsE,EAAQnB,kBACd,MAAMoB,EAAcjB,wBACpB,MAAMkB,EAAQf","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/dialog/src/Dialog.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext, createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { FocusScope } from '@radix-ui/react-focus-scope';\nimport { UnstablePortal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\nimport { Slot } from '@radix-ui/react-slot';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentRef: React.RefObject<DialogContentElement>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n allowPinchZoom: DialogProps['allowPinchZoom'];\n};\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ntype RemoveScrollProps = React.ComponentProps<typeof RemoveScroll>;\ninterface DialogProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom'];\n children?: React.ReactNode;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n allowPinchZoom,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentRef = React.useRef<DialogContentElement>(null);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n allowPinchZoom={allowPinchZoom}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n (props: ScopedProps<DialogTriggerProps>, forwardedRef) => {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof UnstablePortal>;\ninterface DialogPortalProps extends Omit<PortalProps, 'asChild'> {\n children?: React.ReactNode;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (props: ScopedProps<DialogPortalProps>) => {\n const { __scopeDialog, forceMount, children, container } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <UnstablePortal asChild container={container}>\n {child}\n </UnstablePortal>\n </Presence>\n ))}\n </>\n );\n};\n\nDialogPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogOverlay = React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n (props: ScopedProps<DialogOverlayProps>, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n }\n);\n\nDialogOverlay.displayName = OVERLAY_NAME;\n\ntype DialogOverlayImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst DialogOverlayImpl = React.forwardRef<DialogOverlayImplElement, DialogOverlayImplProps>(\n (props: ScopedProps<DialogOverlayImplProps>, forwardedRef) => {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`\n // ie. when `Overlay` and `Content` are siblings\n <RemoveScroll as={Slot} allowPinchZoom={context.allowPinchZoom} shards={[context.contentRef]}>\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={forwardedRef}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogContent = React.forwardRef<DialogContentElement, DialogContentProps>(\n (props: ScopedProps<DialogContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n }\n);\n\nDialogContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps\n extends Omit<DialogContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {}\n\nconst DialogContentModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault()\n )}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) hasInteractedOutsideRef.current = true;\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n //\n // We use `onInteractOutside` as some browsers also\n // focus on pointer down, creating the same issue.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ElementRef<typeof DismissableLayer>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n}\n\nconst DialogContentImpl = React.forwardRef<DialogContentImplElement, DialogContentImplProps>(\n (props: ScopedProps<DialogContentImplProps>, forwardedRef) => {\n const {\n __scopeDialog,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (beacuse of the `Portal`)\n useFocusGuards();\n\n return (\n <>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-describedby={ariaDescribedBy || context.descriptionId}\n // If `aria-label` is set, ensure `aria-labelledby` is undefined as to avoid confusion.\n // Otherwise fallback to an explicit `aria-labelledby` or the ID used in the\n // `DialogTitle`\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy || context.titleId}\n aria-label={ariaLabel || undefined}\n data-state={getState(context.open)}\n {...contentProps}\n ref={composedRefs}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n {process.env.NODE_ENV === 'development' && <LabelWarning contentRef={contentRef} />}\n </>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'DialogTitle';\n\ntype DialogTitleElement = React.ElementRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = Radix.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = React.forwardRef<DialogTitleElement, DialogTitleProps>(\n (props: ScopedProps<DialogTitleProps>, forwardedRef) => {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME, __scopeDialog);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n }\n);\n\nDialogTitle.displayName = TITLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'DialogDescription';\n\ntype DialogDescriptionElement = React.ElementRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = Radix.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = React.forwardRef<DialogDescriptionElement, DialogDescriptionProps>(\n (props: ScopedProps<DialogDescriptionProps>, forwardedRef) => {\n const { __scopeDialog, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n }\n);\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ElementRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = React.forwardRef<DialogCloseElement, DialogCloseProps>(\n (props: ScopedProps<DialogCloseProps>, forwardedRef) => {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n }\n);\n\nDialogClose.displayName = CLOSE_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst LABEL_WARNING_NAME = 'DialogLabelWarning';\n\nconst [LabelWarningProvider, useLabelWarningContext] = createContext(LABEL_WARNING_NAME, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = useLabelWarningContext(LABEL_WARNING_NAME);\n\n const MESSAGE = `\\`${labelWarningContext.contentName}\\` requires a label for the component to be accessible for screen reader users.\n\nYou can label the \\`${labelWarningContext.contentName}\\` by passing a \\`${labelWarningContext.titleName}\\` component as a child, which also benefits sighted users by adding visible context to the dialog.\n\nAlternatively, you can use your own component as a title by assigning it an \\`id\\` and passing the same value to the \\`aria-labelledby\\` prop in \\`${labelWarningContext.contentName}\\`. If the label is confusing or duplicative for sighted users, you can also pass a label directly by using the \\`aria-label\\` prop.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${labelWarningContext.docsSlug}`;\n\n React.useEffect(() => {\n const hasLabel =\n contentRef.current?.getAttribute('aria-label') ||\n document.getElementById(contentRef.current?.getAttribute('aria-labelledby')!);\n\n if (!hasLabel) console.warn(MESSAGE);\n }, [MESSAGE, contentRef]);\n\n return null;\n};\n\nconst Root = Dialog;\nconst Trigger = DialogTrigger;\nconst Portal = DialogPortal;\nconst Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Portal,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],"names":["dest","source","a","Object","keys","forEach","key","defineProperty","enumerable","get","__esModule","default","createDialogContext","createDialogScope","createContextScope","DialogProvider","useDialogContext","Dialog","props","__scopeDialog","children","open","openProp","defaultOpen","onOpenChange","modal","allowPinchZoom","triggerRef","React","useRef","contentRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$b0496301423b3238f89fb15bee25ad02$var$DialogProvider","scope","contentId","useId","titleId","descriptionId","onOpenToggle","useCallback","prevOpen","DialogTrigger","forwardRef","forwardedRef","triggerProps","context","composedTriggerRef","useComposedRefs","Primitive","button","_babelRuntimeHelpersExtends","type","getState","ref","onClick","composeEventHandlers","DialogPortal","forceMount","container","Fragment","Children","map","child","Presence","present","UnstablePortal","asChild","DialogOverlay","overlayProps","$b0496301423b3238f89fb15bee25ad02$var$DialogOverlayImpl","DialogOverlayImpl","RemoveScroll","as","Slot","shards","div","style","pointerEvents","DialogContent","contentProps","$b0496301423b3238f89fb15bee25ad02$var$DialogContentModal","$b0496301423b3238f89fb15bee25ad02$var$DialogContentNonModal","DialogContentModal","composedRefs","useEffect","content","current","hideOthers","$b0496301423b3238f89fb15bee25ad02$var$DialogContentImpl","trapFocus","disableOutsidePointerEvents","onCloseAutoFocus","event","_context$triggerRef$c","preventDefault","focus","onPointerDownOutside","originalEvent","detail","ctrlLeftClick","ctrlKey","onFocusOutside","DialogContentNonModal","hasInteractedOutsideRef","_props$onCloseAutoFoc","_context$triggerRef$c2","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","_context$triggerRef$c3","target","contains","DialogContentImpl","ariaLabel","ariaLabelledBy","ariaDescribedBy","onOpenAutoFocus","useFocusGuards","FocusScope","loop","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","undefined","onDismiss","DialogTitle","titleProps","h2","DialogDescription","descriptionProps","p","DialogClose","closeProps","LabelWarningProvider","useLabelWarningContext","createContext","contentName","titleName","docsSlug","Root","Trigger","Portal","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.js.map"}
@@ -1,2 +1,2 @@
1
- import{Slot as e}from"@radix-ui/react-slot";import{hideOthers as o}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as r}from"@radix-ui/react-focus-guards";import{Primitive as n}from"@radix-ui/react-primitive";import{Presence as a}from"@radix-ui/react-presence";import{UnstablePortal as i}from"@radix-ui/react-portal";import{FocusScope as l}from"@radix-ui/react-focus-scope";import{DismissableLayer as c}from"@radix-ui/react-dismissable-layer";import{useControllableState as s}from"@radix-ui/react-use-controllable-state";import{useId as u}from"@radix-ui/react-id";import{createContext as p,createContextScope as d}from"@radix-ui/react-context";import{useComposedRefs as g}from"@radix-ui/react-compose-refs";import{composeEventHandlers as f}from"@radix-ui/primitive";import*as m from"react";import D from"@babel/runtime/helpers/esm/extends";const[x,v]=d("Dialog");export{v as createDialogScope};const[C,E]=x("Dialog");export const Dialog=e=>{const{__scopeDialog:o,children:t,open:r,defaultOpen:n,onOpenChange:a,modal:i=!0,allowPinchZoom:l}=e,c=m.useRef(null),[p=!1,d]=s({prop:r,defaultProp:n,onChange:a});/*#__PURE__*/return m.createElement(C,{scope:o,triggerRef:c,contentId:u(),titleId:u(),descriptionId:u(),open:p,onOpenChange:d,onOpenToggle:m.useCallback((()=>d((e=>!e))),[d]),modal:i,allowPinchZoom:l},t)};/*#__PURE__*/export const DialogTrigger=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogTrigger",t),i=g(o,a.triggerRef);/*#__PURE__*/return m.createElement(n.button,D({type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":h(a.open)},r,{ref:i,onClick:f(e.onClick,a.onOpenToggle)}))}));/*#__PURE__*/export const DialogPortal=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,forceMount:r,children:n,...l}=e,c=E("DialogPortal",t);/*#__PURE__*/return m.createElement(m.Fragment,null,m.Children.map(n,(e=>/*#__PURE__*/m.createElement(a,{present:r||c.open},/*#__PURE__*/m.createElement(i,D({},l,{asChild:!0,ref:o}),e)))))}));/*#__PURE__*/export const DialogOverlay=/*#__PURE__*/m.forwardRef(((e,o)=>{const{forceMount:t,...r}=e,n=E("DialogOverlay",e.__scopeDialog);return n.modal?/*#__PURE__*/m.createElement(a,{present:t||n.open},/*#__PURE__*/m.createElement(b,D({},r,{ref:o}))):null}));/*#__PURE__*/const b=/*#__PURE__*/m.forwardRef(((o,r)=>{const{__scopeDialog:a,...i}=o,l=E("DialogOverlay",a);/*#__PURE__*/return m.createElement(t,{as:e,allowPinchZoom:l.allowPinchZoom},/*#__PURE__*/m.createElement(n.div,D({"data-state":h(l.open)},i,{ref:r,style:{pointerEvents:"auto",...i.style}})))}));export const DialogContent=/*#__PURE__*/m.forwardRef(((e,o)=>{const{forceMount:t,...r}=e,n=E("DialogContent",e.__scopeDialog);/*#__PURE__*/return m.createElement(a,{present:t||n.open},n.modal?/*#__PURE__*/m.createElement(_,D({},r,{ref:o})):/*#__PURE__*/m.createElement(O,D({},r,{ref:o})))}));/*#__PURE__*/const _=/*#__PURE__*/m.forwardRef(((e,t)=>{const r=E("DialogContent",e.__scopeDialog),n=m.useRef(null),a=g(t,n);return m.useEffect((()=>{const e=n.current;if(e)return o(e)}),[]),/*#__PURE__*/m.createElement(R,D({},e,{ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:f(e.onCloseAutoFocus,(e=>{var o;e.preventDefault(),null===(o=r.triggerRef.current)||void 0===o||o.focus()})),onPointerDownOutside:f(e.onPointerDownOutside,(e=>{const o=e.detail.originalEvent,t=0===o.button&&!0===o.ctrlKey;(2===o.button||t)&&e.preventDefault()})),onFocusOutside:f(e.onFocusOutside,(e=>e.preventDefault()))}))})),O=/*#__PURE__*/m.forwardRef(((e,o)=>{const t=E("DialogContent",e.__scopeDialog),r=m.useRef(!1);/*#__PURE__*/return m.createElement(R,D({},e,{ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var n,a;(null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,o),o.defaultPrevented)||(r.current||null===(a=t.triggerRef.current)||void 0===a||a.focus(),o.preventDefault());r.current=!1},onInteractOutside:o=>{var n,a;null===(n=e.onInteractOutside)||void 0===n||n.call(e,o),o.defaultPrevented||(r.current=!0);const i=o.target;(null===(a=t.triggerRef.current)||void 0===a?void 0:a.contains(i))&&o.preventDefault()}}))})),R=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,"aria-label":n,"aria-labelledby":a,"aria-describedby":i,trapFocus:s,onOpenAutoFocus:u,onCloseAutoFocus:p,...d}=e,f=E("DialogContent",t),x=m.useRef(null),v=g(o,x);return r(),/*#__PURE__*/m.createElement(m.Fragment,null,/*#__PURE__*/m.createElement(l,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:u,onUnmountAutoFocus:p},/*#__PURE__*/m.createElement(c,D({role:"dialog",id:f.contentId,"aria-describedby":i||f.descriptionId,"aria-labelledby":n?void 0:a||f.titleId,"aria-label":n||void 0,"data-state":h(f.open)},d,{ref:v,onDismiss:()=>f.onOpenChange(!1)}))),!1)}));export const DialogTitle=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogTitle",t);/*#__PURE__*/return m.createElement(n.h2,D({id:a.titleId},r,{ref:o}))}));/*#__PURE__*/export const DialogDescription=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogDescription",t);/*#__PURE__*/return m.createElement(n.p,D({id:a.descriptionId},r,{ref:o}))}));/*#__PURE__*/export const DialogClose=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogClose",t);/*#__PURE__*/return m.createElement(n.button,D({type:"button"},r,{ref:o,onClick:f(e.onClick,(()=>a.onOpenChange(!1)))}))}));/*#__PURE__*/function h(e){return e?"open":"closed"}const[w,y]=p("DialogLabelWarning",{contentName:"DialogContent",titleName:"DialogTitle",docsSlug:"dialog"});export{w as LabelWarningProvider};export const Root=Dialog;export const Trigger=DialogTrigger;export const Portal=DialogPortal;export const Overlay=DialogOverlay;export const Content=DialogContent;export const Title=DialogTitle;export const Description=DialogDescription;export const Close=DialogClose;
1
+ import{Slot as e}from"@radix-ui/react-slot";import{hideOthers as o}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as r}from"@radix-ui/react-focus-guards";import{Primitive as n}from"@radix-ui/react-primitive";import{Presence as a}from"@radix-ui/react-presence";import{UnstablePortal as i}from"@radix-ui/react-portal";import{FocusScope as l}from"@radix-ui/react-focus-scope";import{DismissableLayer as c}from"@radix-ui/react-dismissable-layer";import{useControllableState as s}from"@radix-ui/react-use-controllable-state";import{useId as u}from"@radix-ui/react-id";import{createContext as p,createContextScope as d}from"@radix-ui/react-context";import{useComposedRefs as f}from"@radix-ui/react-compose-refs";import{composeEventHandlers as g}from"@radix-ui/primitive";import*as m from"react";import D from"@babel/runtime/helpers/esm/extends";const[x,v]=d("Dialog");export{v as createDialogScope};const[C,E]=x("Dialog");export const Dialog=e=>{const{__scopeDialog:o,children:t,open:r,defaultOpen:n,onOpenChange:a,modal:i=!0,allowPinchZoom:l}=e,c=m.useRef(null),p=m.useRef(null),[d=!1,f]=s({prop:r,defaultProp:n,onChange:a});/*#__PURE__*/return m.createElement(C,{scope:o,triggerRef:c,contentRef:p,contentId:u(),titleId:u(),descriptionId:u(),open:d,onOpenChange:f,onOpenToggle:m.useCallback((()=>f((e=>!e))),[f]),modal:i,allowPinchZoom:l},t)};/*#__PURE__*/export const DialogTrigger=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogTrigger",t),i=f(o,a.triggerRef);/*#__PURE__*/return m.createElement(n.button,D({type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":h(a.open)},r,{ref:i,onClick:g(e.onClick,a.onOpenToggle)}))}));/*#__PURE__*/export const DialogPortal=e=>{const{__scopeDialog:o,forceMount:t,children:r,container:n}=e,l=E("DialogPortal",o);/*#__PURE__*/return m.createElement(m.Fragment,null,m.Children.map(r,(e=>/*#__PURE__*/m.createElement(a,{present:t||l.open},/*#__PURE__*/m.createElement(i,{asChild:!0,container:n},e)))))};/*#__PURE__*/export const DialogOverlay=/*#__PURE__*/m.forwardRef(((e,o)=>{const{forceMount:t,...r}=e,n=E("DialogOverlay",e.__scopeDialog);return n.modal?/*#__PURE__*/m.createElement(a,{present:t||n.open},/*#__PURE__*/m.createElement(b,D({},r,{ref:o}))):null}));/*#__PURE__*/const b=/*#__PURE__*/m.forwardRef(((o,r)=>{const{__scopeDialog:a,...i}=o,l=E("DialogOverlay",a);/*#__PURE__*/return m.createElement(t,{as:e,allowPinchZoom:l.allowPinchZoom,shards:[l.contentRef]},/*#__PURE__*/m.createElement(n.div,D({"data-state":h(l.open)},i,{ref:r,style:{pointerEvents:"auto",...i.style}})))}));export const DialogContent=/*#__PURE__*/m.forwardRef(((e,o)=>{const{forceMount:t,...r}=e,n=E("DialogContent",e.__scopeDialog);/*#__PURE__*/return m.createElement(a,{present:t||n.open},n.modal?/*#__PURE__*/m.createElement(R,D({},r,{ref:o})):/*#__PURE__*/m.createElement(_,D({},r,{ref:o})))}));/*#__PURE__*/const R=/*#__PURE__*/m.forwardRef(((e,t)=>{const r=E("DialogContent",e.__scopeDialog),n=m.useRef(null),a=f(t,r.contentRef,n);return m.useEffect((()=>{const e=n.current;if(e)return o(e)}),[]),/*#__PURE__*/m.createElement(O,D({},e,{ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:g(e.onCloseAutoFocus,(e=>{var o;e.preventDefault(),null===(o=r.triggerRef.current)||void 0===o||o.focus()})),onPointerDownOutside:g(e.onPointerDownOutside,(e=>{const o=e.detail.originalEvent,t=0===o.button&&!0===o.ctrlKey;(2===o.button||t)&&e.preventDefault()})),onFocusOutside:g(e.onFocusOutside,(e=>e.preventDefault()))}))})),_=/*#__PURE__*/m.forwardRef(((e,o)=>{const t=E("DialogContent",e.__scopeDialog),r=m.useRef(!1);/*#__PURE__*/return m.createElement(O,D({},e,{ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var n,a;(null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,o),o.defaultPrevented)||(r.current||null===(a=t.triggerRef.current)||void 0===a||a.focus(),o.preventDefault());r.current=!1},onInteractOutside:o=>{var n,a;null===(n=e.onInteractOutside)||void 0===n||n.call(e,o),o.defaultPrevented||(r.current=!0);const i=o.target;(null===(a=t.triggerRef.current)||void 0===a?void 0:a.contains(i))&&o.preventDefault()}}))})),O=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,"aria-label":n,"aria-labelledby":a,"aria-describedby":i,trapFocus:s,onOpenAutoFocus:u,onCloseAutoFocus:p,...d}=e,g=E("DialogContent",t),x=m.useRef(null),v=f(o,x);return r(),/*#__PURE__*/m.createElement(m.Fragment,null,/*#__PURE__*/m.createElement(l,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:u,onUnmountAutoFocus:p},/*#__PURE__*/m.createElement(c,D({role:"dialog",id:g.contentId,"aria-describedby":i||g.descriptionId,"aria-labelledby":n?void 0:a||g.titleId,"aria-label":n||void 0,"data-state":h(g.open)},d,{ref:v,onDismiss:()=>g.onOpenChange(!1)}))),!1)}));export const DialogTitle=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogTitle",t);/*#__PURE__*/return m.createElement(n.h2,D({id:a.titleId},r,{ref:o}))}));/*#__PURE__*/export const DialogDescription=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogDescription",t);/*#__PURE__*/return m.createElement(n.p,D({id:a.descriptionId},r,{ref:o}))}));/*#__PURE__*/export const DialogClose=/*#__PURE__*/m.forwardRef(((e,o)=>{const{__scopeDialog:t,...r}=e,a=E("DialogClose",t);/*#__PURE__*/return m.createElement(n.button,D({type:"button"},r,{ref:o,onClick:g(e.onClick,(()=>a.onOpenChange(!1)))}))}));/*#__PURE__*/function h(e){return e?"open":"closed"}const[w,y]=p("DialogLabelWarning",{contentName:"DialogContent",titleName:"DialogTitle",docsSlug:"dialog"});export{w as LabelWarningProvider};export const Root=Dialog;export const Trigger=DialogTrigger;export const Portal=DialogPortal;export const Overlay=DialogOverlay;export const Content=DialogContent;export const Title=DialogTitle;export const Description=DialogDescription;export const Close=DialogClose;
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"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A4C8B,KAC3C,MAAM7B,cAAEA,KAAkBuH,GAAqBxH,EACzCgC,EAAUlC,EATK,oBAS8BG,gBACnD,OAAOgB,EAAAC,cAACiB,EAAUsF,EAAXpF,EAAA,CAAa4E,GAAIjF,EAAQR,eAAmBgG,EAA5C,CAA8DhF,IAAKV,4BAe9E,MAAM4F,yBAAchH,EAAMmB,YACxB,CAAC7B,EAAsC8B,KACrC,MAAM7B,cAAEA,KAAkB0H,GAAe3H,EACnCgC,EAAUlC,EARD,cAQ8BG,gBAC7C,OACEgB,EAAAC,cAACiB,EAAUC,OAAXC,EAAA,CACEC,KAAK,UACDqF,EAFN,CAGEnF,IAAKV,EACLW,QAASC,EAAqB1C,EAAMyC,SAAS,IAAMT,EAAQ1B,cAAa,wBAUhF,SAASiC,EAASpC,GAChB,OAAOA,EAAO,OAAS,SAGzB,MAEOyH,EAAsBC,GAA0BC,EAF5B,qBAE8D,CACvFC,YAjRmB,gBAkRnBC,UAxEiB,cAyEjBC,SAAU,oDA6BZ,MAAMC,KAAOnI,cACb,MAAMoI,QAAUvG,qBAChB,MAAMwG,OAASzF,oBACf,MAAM0F,QAAU/E,qBAChB,MAAMgF,QAAUtE,qBAChB,MAAMuE,MAAQnB,mBACd,MAAMoB,YAAcjB,yBACpB,MAAMkB,MAAQf","sources":["./packages/react/dialog/src/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext, createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { FocusScope } from '@radix-ui/react-focus-scope';\nimport { UnstablePortal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\nimport { Slot } from '@radix-ui/react-slot';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n allowPinchZoom: DialogProps['allowPinchZoom'];\n};\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ntype RemoveScrollProps = React.ComponentProps<typeof RemoveScroll>;\ninterface DialogProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom'];\n children?: React.ReactNode;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n allowPinchZoom,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n allowPinchZoom={allowPinchZoom}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n (props: ScopedProps<DialogTriggerProps>, forwardedRef) => {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof UnstablePortal>;\ntype DialogPortalElement = React.ElementRef<typeof UnstablePortal>;\ninterface DialogPortalProps extends Omit<PortalProps, 'asChild'> {\n children?: React.ReactNode;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogPortal = React.forwardRef<DialogPortalElement, DialogPortalProps>(\n (props: ScopedProps<DialogPortalProps>, forwardedRef) => {\n const { __scopeDialog, forceMount, children, ...portalProps } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <UnstablePortal {...portalProps} asChild ref={forwardedRef}>\n {child}\n </UnstablePortal>\n </Presence>\n ))}\n </>\n );\n }\n);\n\nDialogPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogOverlay = React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n (props: ScopedProps<DialogOverlayProps>, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n }\n);\n\nDialogOverlay.displayName = OVERLAY_NAME;\n\ntype DialogOverlayImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst DialogOverlayImpl = React.forwardRef<DialogOverlayImplElement, DialogOverlayImplProps>(\n (props: ScopedProps<DialogOverlayImplProps>, forwardedRef) => {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n return (\n <RemoveScroll as={Slot} allowPinchZoom={context.allowPinchZoom}>\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={forwardedRef}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogContent = React.forwardRef<DialogContentElement, DialogContentProps>(\n (props: ScopedProps<DialogContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n }\n);\n\nDialogContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps\n extends Omit<DialogContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {}\n\nconst DialogContentModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault()\n )}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) hasInteractedOutsideRef.current = true;\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n //\n // We use `onInteractOutside` as some browsers also\n // focus on pointer down, creating the same issue.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ElementRef<typeof DismissableLayer>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n}\n\nconst DialogContentImpl = React.forwardRef<DialogContentImplElement, DialogContentImplProps>(\n (props: ScopedProps<DialogContentImplProps>, forwardedRef) => {\n const {\n __scopeDialog,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (beacuse of the `Portal`)\n useFocusGuards();\n\n return (\n <>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-describedby={ariaDescribedBy || context.descriptionId}\n // If `aria-label` is set, ensure `aria-labelledby` is undefined as to avoid confusion.\n // Otherwise fallback to an explicit `aria-labelledby` or the ID used in the\n // `DialogTitle`\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy || context.titleId}\n aria-label={ariaLabel || undefined}\n data-state={getState(context.open)}\n {...contentProps}\n ref={composedRefs}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n {process.env.NODE_ENV === 'development' && <LabelWarning contentRef={contentRef} />}\n </>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'DialogTitle';\n\ntype DialogTitleElement = React.ElementRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = Radix.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = React.forwardRef<DialogTitleElement, DialogTitleProps>(\n (props: ScopedProps<DialogTitleProps>, forwardedRef) => {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME, __scopeDialog);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n }\n);\n\nDialogTitle.displayName = TITLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'DialogDescription';\n\ntype DialogDescriptionElement = React.ElementRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = Radix.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = React.forwardRef<DialogDescriptionElement, DialogDescriptionProps>(\n (props: ScopedProps<DialogDescriptionProps>, forwardedRef) => {\n const { __scopeDialog, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n }\n);\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ElementRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = React.forwardRef<DialogCloseElement, DialogCloseProps>(\n (props: ScopedProps<DialogCloseProps>, forwardedRef) => {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n }\n);\n\nDialogClose.displayName = CLOSE_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst LABEL_WARNING_NAME = 'DialogLabelWarning';\n\nconst [LabelWarningProvider, useLabelWarningContext] = createContext(LABEL_WARNING_NAME, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = useLabelWarningContext(LABEL_WARNING_NAME);\n\n const MESSAGE = `\\`${labelWarningContext.contentName}\\` requires a label for the component to be accessible for screen reader users.\n\nYou can label the \\`${labelWarningContext.contentName}\\` by passing a \\`${labelWarningContext.titleName}\\` component as a child, which also benefits sighted users by adding visible context to the dialog.\n\nAlternatively, you can use your own component as a title by assigning it an \\`id\\` and passing the same value to the \\`aria-labelledby\\` prop in \\`${labelWarningContext.contentName}\\`. If the label is confusing or duplicative for sighted users, you can also pass a label directly by using the \\`aria-label\\` prop.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${labelWarningContext.docsSlug}`;\n\n React.useEffect(() => {\n const hasLabel =\n contentRef.current?.getAttribute('aria-label') ||\n document.getElementById(contentRef.current?.getAttribute('aria-labelledby')!);\n\n if (!hasLabel) console.warn(MESSAGE);\n }, [MESSAGE, contentRef]);\n\n return null;\n};\n\nconst Root = Dialog;\nconst Trigger = DialogTrigger;\nconst Portal = DialogPortal;\nconst Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Portal,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],"names":["createDialogContext","createDialogScope","createContextScope","DialogProvider","useDialogContext","Dialog","props","__scopeDialog","children","open","openProp","defaultOpen","onOpenChange","modal","allowPinchZoom","triggerRef","React","useRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$da81f3af863821fb8a193d321c41d$var$DialogProvider","scope","contentId","useId","titleId","descriptionId","onOpenToggle","useCallback","prevOpen","DialogTrigger","forwardRef","forwardedRef","triggerProps","context","composedTriggerRef","useComposedRefs","Primitive","button","_babelRuntimeHelpersEsmExtends","type","getState","ref","onClick","composeEventHandlers","DialogPortal","forceMount","portalProps","Fragment","Children","map","child","Presence","present","UnstablePortal","asChild","DialogOverlay","overlayProps","$da81f3af863821fb8a193d321c41d$var$DialogOverlayImpl","DialogOverlayImpl","RemoveScroll","as","Slot","div","style","pointerEvents","DialogContent","contentProps","$da81f3af863821fb8a193d321c41d$var$DialogContentModal","$da81f3af863821fb8a193d321c41d$var$DialogContentNonModal","DialogContentModal","contentRef","composedRefs","useEffect","content","current","hideOthers","$da81f3af863821fb8a193d321c41d$var$DialogContentImpl","trapFocus","disableOutsidePointerEvents","onCloseAutoFocus","event","_context$triggerRef$c","preventDefault","focus","onPointerDownOutside","originalEvent","detail","ctrlLeftClick","ctrlKey","onFocusOutside","DialogContentNonModal","hasInteractedOutsideRef","_props$onCloseAutoFoc","_context$triggerRef$c2","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","_context$triggerRef$c3","target","contains","DialogContentImpl","ariaLabel","ariaLabelledBy","ariaDescribedBy","onOpenAutoFocus","useFocusGuards","FocusScope","loop","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","undefined","onDismiss","DialogTitle","titleProps","h2","DialogDescription","descriptionProps","p","DialogClose","closeProps","LabelWarningProvider","useLabelWarningContext","createContext","contentName","titleName","docsSlug","Root","Trigger","Portal","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":"m3BAuBA,MAGOA,EAAqBC,GAAqBC,EAH7B,yCAkBpB,MAAOC,EAAgBC,GAAoBJ,EAlBvB,iBAiCpB,MAAMK,OAAiCC,IACrC,MAAMC,cACJA,EADIC,SAEJA,EACAC,KAAMC,EAHFC,YAIJA,EAJIC,aAKJA,EALIC,MAMJA,GAAQ,EANJC,eAOJA,GACER,EACES,EAAaC,EAAMC,OAA0B,MAC7CC,EAAaF,EAAMC,OAA6B,OAC/CR,GAAO,EAAOU,GAAWC,EAAqB,CACnDC,KAAMX,EACNY,YAAaX,EACbY,SAAUX,iBAGZ,OACEY,EAAAC,cAACC,EAAD,CACEC,MAAOpB,EACPQ,WAAYA,EACZG,WAAYA,EACZU,UAAWC,IACXC,QAASD,IACTE,cAAeF,IACfpB,KAAMA,EACNG,aAAcO,EACda,aAAchB,EAAMiB,aAAY,IAAMd,GAASe,IAAcA,KAAW,CAACf,IACzEN,MAAOA,EACPC,eAAgBA,GAEfN,wBAiBP,MAAM2B,2BAAgBnB,EAAMoB,YAC1B,CAAC9B,EAAwC+B,KACvC,MAAM9B,cAAEA,KAAkB+B,GAAiBhC,EACrCiC,EAAUnC,EATC,gBAS8BG,GACzCiC,EAAqBC,EAAgBJ,EAAcE,EAAQxB,yBACjE,OACES,EAAAC,cAACiB,EAAUC,OAAXC,EAAA,CACEC,KAAK,SACL,gBAAc,SACd,gBAAeN,EAAQ9B,KACvB,gBAAe8B,EAAQX,UACvB,aAAYkB,EAASP,EAAQ9B,OACzB6B,EANN,CAOES,IAAKP,EACLQ,QAASC,EAAqB3C,EAAM0C,QAAST,EAAQP,wCAwB7D,MAAMkB,aAA6C5C,IACjD,MAAMC,cAAEA,EAAF4C,WAAiBA,EAAjB3C,SAA6BA,EAA7B4C,UAAuCA,GAAc9C,EACrDiC,EAAUnC,EAdE,eAc4BG,gBAC9C,OACEiB,EAAAC,cAAAD,EAAA6B,SAAA,KACGr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a8F,EAAvC,CAAmD7E,IAAKV,4BAgBnE,MAAMyF,+BAAoB9G,EAAMoB,YAC9B,CAAC9B,EAA4C+B,KAC3C,MAAM9B,cAAEA,KAAkBwH,GAAqBzH,EACzCiC,EAAUnC,EATK,oBAS8BG,gBACnD,OAAOiB,EAAAC,cAACiB,EAAUsF,EAAXpF,EAAA,CAAa4E,GAAIjF,EAAQR,eAAmBgG,EAA5C,CAA8DhF,IAAKV,4BAe9E,MAAM4F,yBAAcjH,EAAMoB,YACxB,CAAC9B,EAAsC+B,KACrC,MAAM9B,cAAEA,KAAkB2H,GAAe5H,EACnCiC,EAAUnC,EARD,cAQ8BG,gBAC7C,OACEiB,EAAAC,cAACiB,EAAUC,OAAXC,EAAA,CACEC,KAAK,UACDqF,EAFN,CAGEnF,IAAKV,EACLW,QAASC,EAAqB3C,EAAM0C,SAAS,IAAMT,EAAQ3B,cAAa,wBAUhF,SAASkC,EAASrC,GAChB,OAAOA,EAAO,OAAS,SAGzB,MAEO0H,EAAsBC,GAA0BC,EAF5B,qBAE8D,CACvFC,YAjRmB,gBAkRnBC,UAxEiB,cAyEjBC,SAAU,oDA6BZ,MAAMC,KAAOpI,cACb,MAAMqI,QAAUvG,qBAChB,MAAMwG,OAASzF,oBACf,MAAM0F,QAAU/E,qBAChB,MAAMgF,QAAUrE,qBAChB,MAAMsE,MAAQnB,mBACd,MAAMoB,YAAcjB,yBACpB,MAAMkB,MAAQf","sources":["./packages/react/dialog/src/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext, createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { FocusScope } from '@radix-ui/react-focus-scope';\nimport { UnstablePortal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\nimport { Slot } from '@radix-ui/react-slot';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentRef: React.RefObject<DialogContentElement>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n allowPinchZoom: DialogProps['allowPinchZoom'];\n};\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ntype RemoveScrollProps = React.ComponentProps<typeof RemoveScroll>;\ninterface DialogProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom'];\n children?: React.ReactNode;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n allowPinchZoom,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentRef = React.useRef<DialogContentElement>(null);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n allowPinchZoom={allowPinchZoom}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n (props: ScopedProps<DialogTriggerProps>, forwardedRef) => {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof UnstablePortal>;\ninterface DialogPortalProps extends Omit<PortalProps, 'asChild'> {\n children?: React.ReactNode;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (props: ScopedProps<DialogPortalProps>) => {\n const { __scopeDialog, forceMount, children, container } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <UnstablePortal asChild container={container}>\n {child}\n </UnstablePortal>\n </Presence>\n ))}\n </>\n );\n};\n\nDialogPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogOverlay = React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n (props: ScopedProps<DialogOverlayProps>, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n }\n);\n\nDialogOverlay.displayName = OVERLAY_NAME;\n\ntype DialogOverlayImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst DialogOverlayImpl = React.forwardRef<DialogOverlayImplElement, DialogOverlayImplProps>(\n (props: ScopedProps<DialogOverlayImplProps>, forwardedRef) => {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`\n // ie. when `Overlay` and `Content` are siblings\n <RemoveScroll as={Slot} allowPinchZoom={context.allowPinchZoom} shards={[context.contentRef]}>\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={forwardedRef}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogContent = React.forwardRef<DialogContentElement, DialogContentProps>(\n (props: ScopedProps<DialogContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n }\n);\n\nDialogContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps\n extends Omit<DialogContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {}\n\nconst DialogContentModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault()\n )}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) hasInteractedOutsideRef.current = true;\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n //\n // We use `onInteractOutside` as some browsers also\n // focus on pointer down, creating the same issue.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ElementRef<typeof DismissableLayer>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n}\n\nconst DialogContentImpl = React.forwardRef<DialogContentImplElement, DialogContentImplProps>(\n (props: ScopedProps<DialogContentImplProps>, forwardedRef) => {\n const {\n __scopeDialog,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (beacuse of the `Portal`)\n useFocusGuards();\n\n return (\n <>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-describedby={ariaDescribedBy || context.descriptionId}\n // If `aria-label` is set, ensure `aria-labelledby` is undefined as to avoid confusion.\n // Otherwise fallback to an explicit `aria-labelledby` or the ID used in the\n // `DialogTitle`\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy || context.titleId}\n aria-label={ariaLabel || undefined}\n data-state={getState(context.open)}\n {...contentProps}\n ref={composedRefs}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n {process.env.NODE_ENV === 'development' && <LabelWarning contentRef={contentRef} />}\n </>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'DialogTitle';\n\ntype DialogTitleElement = React.ElementRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = Radix.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = React.forwardRef<DialogTitleElement, DialogTitleProps>(\n (props: ScopedProps<DialogTitleProps>, forwardedRef) => {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME, __scopeDialog);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n }\n);\n\nDialogTitle.displayName = TITLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'DialogDescription';\n\ntype DialogDescriptionElement = React.ElementRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = Radix.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = React.forwardRef<DialogDescriptionElement, DialogDescriptionProps>(\n (props: ScopedProps<DialogDescriptionProps>, forwardedRef) => {\n const { __scopeDialog, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n }\n);\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ElementRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = React.forwardRef<DialogCloseElement, DialogCloseProps>(\n (props: ScopedProps<DialogCloseProps>, forwardedRef) => {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n }\n);\n\nDialogClose.displayName = CLOSE_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst LABEL_WARNING_NAME = 'DialogLabelWarning';\n\nconst [LabelWarningProvider, useLabelWarningContext] = createContext(LABEL_WARNING_NAME, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = useLabelWarningContext(LABEL_WARNING_NAME);\n\n const MESSAGE = `\\`${labelWarningContext.contentName}\\` requires a label for the component to be accessible for screen reader users.\n\nYou can label the \\`${labelWarningContext.contentName}\\` by passing a \\`${labelWarningContext.titleName}\\` component as a child, which also benefits sighted users by adding visible context to the dialog.\n\nAlternatively, you can use your own component as a title by assigning it an \\`id\\` and passing the same value to the \\`aria-labelledby\\` prop in \\`${labelWarningContext.contentName}\\`. If the label is confusing or duplicative for sighted users, you can also pass a label directly by using the \\`aria-label\\` prop.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${labelWarningContext.docsSlug}`;\n\n React.useEffect(() => {\n const hasLabel =\n contentRef.current?.getAttribute('aria-label') ||\n document.getElementById(contentRef.current?.getAttribute('aria-labelledby')!);\n\n if (!hasLabel) console.warn(MESSAGE);\n }, [MESSAGE, contentRef]);\n\n return null;\n};\n\nconst Root = Dialog;\nconst Trigger = DialogTrigger;\nconst Portal = DialogPortal;\nconst Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Portal,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],"names":["createDialogContext","createDialogScope","createContextScope","DialogProvider","useDialogContext","Dialog","props","__scopeDialog","children","open","openProp","defaultOpen","onOpenChange","modal","allowPinchZoom","triggerRef","React","useRef","contentRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$da81f3af863821fb8a193d321c41d$var$DialogProvider","scope","contentId","useId","titleId","descriptionId","onOpenToggle","useCallback","prevOpen","DialogTrigger","forwardRef","forwardedRef","triggerProps","context","composedTriggerRef","useComposedRefs","Primitive","button","_babelRuntimeHelpersEsmExtends","type","getState","ref","onClick","composeEventHandlers","DialogPortal","forceMount","container","Fragment","Children","map","child","Presence","present","UnstablePortal","asChild","DialogOverlay","overlayProps","$da81f3af863821fb8a193d321c41d$var$DialogOverlayImpl","DialogOverlayImpl","RemoveScroll","as","Slot","shards","div","style","pointerEvents","DialogContent","contentProps","$da81f3af863821fb8a193d321c41d$var$DialogContentModal","$da81f3af863821fb8a193d321c41d$var$DialogContentNonModal","DialogContentModal","composedRefs","useEffect","content","current","hideOthers","$da81f3af863821fb8a193d321c41d$var$DialogContentImpl","trapFocus","disableOutsidePointerEvents","onCloseAutoFocus","event","_context$triggerRef$c","preventDefault","focus","onPointerDownOutside","originalEvent","detail","ctrlLeftClick","ctrlKey","onFocusOutside","DialogContentNonModal","hasInteractedOutsideRef","_props$onCloseAutoFoc","_context$triggerRef$c2","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","_context$triggerRef$c3","target","contains","DialogContentImpl","ariaLabel","ariaLabelledBy","ariaDescribedBy","onOpenAutoFocus","useFocusGuards","FocusScope","loop","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","undefined","onDismiss","DialogTitle","titleProps","h2","DialogDescription","descriptionProps","p","DialogClose","closeProps","LabelWarningProvider","useLabelWarningContext","createContext","contentName","titleName","docsSlug","Root","Trigger","Portal","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-dialog",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -20,13 +20,13 @@
20
20
  "@radix-ui/primitive": "0.1.0",
21
21
  "@radix-ui/react-compose-refs": "0.1.0",
22
22
  "@radix-ui/react-context": "0.1.1",
23
- "@radix-ui/react-dismissable-layer": "0.1.2",
23
+ "@radix-ui/react-dismissable-layer": "0.1.3",
24
24
  "@radix-ui/react-focus-guards": "0.1.0",
25
- "@radix-ui/react-focus-scope": "0.1.2",
26
- "@radix-ui/react-id": "0.1.3",
27
- "@radix-ui/react-portal": "0.1.2",
25
+ "@radix-ui/react-focus-scope": "0.1.3",
26
+ "@radix-ui/react-id": "0.1.4",
27
+ "@radix-ui/react-portal": "0.1.3",
28
28
  "@radix-ui/react-presence": "0.1.1",
29
- "@radix-ui/react-primitive": "0.1.2",
29
+ "@radix-ui/react-primitive": "0.1.3",
30
30
  "@radix-ui/react-slot": "0.1.2",
31
31
  "@radix-ui/react-use-controllable-state": "0.1.0",
32
32
  "aria-hidden": "^1.1.1",