@radix-ui/react-dialog 0.0.19 → 0.1.0
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 +50 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +12 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,77 +1,82 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
3
3
|
import { FocusScope } from "@radix-ui/react-focus-scope";
|
|
4
|
+
import * as Radix from "@radix-ui/react-primitive";
|
|
4
5
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
5
|
-
|
|
6
|
-
type DialogOwnProps = {
|
|
6
|
+
export interface DialogProps {
|
|
7
7
|
open?: boolean;
|
|
8
8
|
defaultOpen?: boolean;
|
|
9
9
|
onOpenChange?(open: boolean): void;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
modal?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export const Dialog: React.FC<DialogProps>;
|
|
13
|
+
type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
14
|
+
export interface DialogTriggerProps extends PrimitiveButtonProps {
|
|
15
|
+
}
|
|
16
|
+
export const DialogTrigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
export interface DialogOverlayProps extends DialogOverlayImplProps {
|
|
17
18
|
/**
|
|
18
19
|
* Used to force mounting when more control is needed. Useful when
|
|
19
20
|
* controlling animation with React animation libraries.
|
|
20
21
|
*/
|
|
21
22
|
forceMount?: true;
|
|
22
|
-
}
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type DialogContentOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof DialogContentImpl>, {
|
|
23
|
+
}
|
|
24
|
+
export const DialogOverlay: React.ForwardRefExoticComponent<DialogOverlayProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
26
|
+
interface DialogOverlayImplProps extends PrimitiveDivProps {
|
|
27
|
+
}
|
|
28
|
+
export interface DialogContentProps extends DialogContentTypeProps {
|
|
29
29
|
/**
|
|
30
30
|
* Used to force mounting when more control is needed. Useful when
|
|
31
31
|
* controlling animation with React animation libraries.
|
|
32
32
|
*/
|
|
33
33
|
forceMount?: true;
|
|
34
|
-
}
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
type
|
|
34
|
+
}
|
|
35
|
+
export const DialogContent: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
interface DialogContentTypeProps extends Omit<DialogContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {
|
|
37
|
+
}
|
|
38
|
+
type DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;
|
|
39
|
+
type FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;
|
|
40
|
+
interface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {
|
|
41
|
+
/**
|
|
42
|
+
* When `true`, focus cannot escape the `Content` via keyboard,
|
|
43
|
+
* pointer, or a programmatic focus.
|
|
44
|
+
* @defaultValue false
|
|
45
|
+
*/
|
|
46
|
+
trapFocus?: FocusScopeProps['trapped'];
|
|
39
47
|
/**
|
|
40
48
|
* Event handler called when auto-focusing on open.
|
|
41
49
|
* Can be prevented.
|
|
42
50
|
*/
|
|
43
|
-
onOpenAutoFocus?:
|
|
51
|
+
onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];
|
|
44
52
|
/**
|
|
45
53
|
* Event handler called when auto-focusing on close.
|
|
46
54
|
* Can be prevented.
|
|
47
55
|
*/
|
|
48
|
-
onCloseAutoFocus?:
|
|
49
|
-
}
|
|
50
|
-
type
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
type DialogCloseOwnProps = Polymorphic.OwnProps<typeof Primitive>;
|
|
62
|
-
export type DialogClosePrimitive = Polymorphic.ForwardRefComponent<typeof CLOSE_DEFAULT_TAG, DialogCloseOwnProps>;
|
|
63
|
-
export const DialogClose: DialogClosePrimitive;
|
|
56
|
+
onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
|
|
57
|
+
}
|
|
58
|
+
type PrimitiveHeading2Props = Radix.ComponentPropsWithoutRef<typeof Primitive.h2>;
|
|
59
|
+
export interface DialogTitleProps extends PrimitiveHeading2Props {
|
|
60
|
+
}
|
|
61
|
+
export const DialogTitle: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
62
|
+
type PrimitiveParagraphProps = Radix.ComponentPropsWithoutRef<typeof Primitive.p>;
|
|
63
|
+
export interface DialogDescriptionProps extends PrimitiveParagraphProps {
|
|
64
|
+
}
|
|
65
|
+
export const DialogDescription: React.ForwardRefExoticComponent<DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
66
|
+
export interface DialogCloseProps extends PrimitiveButtonProps {
|
|
67
|
+
}
|
|
68
|
+
export const DialogClose: React.ForwardRefExoticComponent<DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
64
69
|
export const LabelWarningProvider: React.Provider<{
|
|
65
70
|
contentName: string;
|
|
66
71
|
titleName: string;
|
|
67
72
|
docsSlug: string;
|
|
68
73
|
}>;
|
|
69
|
-
export const Root: React.FC<
|
|
70
|
-
export const Trigger:
|
|
71
|
-
export const Overlay:
|
|
72
|
-
export const Content:
|
|
73
|
-
export const Title:
|
|
74
|
-
export const Description:
|
|
75
|
-
export const Close:
|
|
74
|
+
export const Root: React.FC<DialogProps>;
|
|
75
|
+
export const Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
76
|
+
export const Overlay: React.ForwardRefExoticComponent<DialogOverlayProps & React.RefAttributes<HTMLDivElement>>;
|
|
77
|
+
export const Content: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
78
|
+
export const Title: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
79
|
+
export const Description: React.ForwardRefExoticComponent<DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
80
|
+
export const Close: React.ForwardRefExoticComponent<DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
76
81
|
|
|
77
82
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"A;A;A;A;A;
|
|
1
|
+
{"mappings":"A;A;A;A;A;AAoCA;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;CACjB;AAED,OAAA,MAAM,QAAQ,MAAM,EAAE,CAAC,WAAW,CAuBjC,CAAC;AAWF,4BAA4B,MAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC;AACpF,mCAA6B,SAAQ,oBAAoB;CAAG;AAE5D,OAAA,MAAM,2GAiBL,CAAC;AAWF,mCAA6B,SAAQ,sBAAsB;IACzD;A;A;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED,OAAA,MAAM,wGAUL,CAAC;AAKF,y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B,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,r,o=require("aria-hidden").hideOthers,n=require("react-remove-scroll").RemoveScroll,a=require("@radix-ui/react-focus-guards").useFocusGuards,i=require("@radix-ui/react-
|
|
1
|
+
var e,t,r,o=require("aria-hidden").hideOthers,n=require("react-remove-scroll").RemoveScroll,a=require("@radix-ui/react-focus-guards").useFocusGuards,i=require("@radix-ui/react-primitive").Primitive,l=require("@radix-ui/react-presence").Presence,s=require("@radix-ui/react-portal").Portal,u=require("@radix-ui/react-focus-scope").FocusScope,c=require("@radix-ui/react-dismissable-layer").DismissableLayer,d=require("@radix-ui/react-use-controllable-state").useControllableState,p=require("@radix-ui/react-id").useId,f=require("@radix-ui/react-context").createContext,g=require("@radix-ui/react-compose-refs").useComposedRefs,m=require("@radix-ui/primitive").composeEventHandlers,v=(e={},t=require("react"),Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e),D=(r=require("@babel/runtime/helpers/extends"))&&r.__esModule?r.default:r;const[x,C]=f("Dialog"),b=e=>{const{children:t,open:r,defaultOpen:o,onOpenChange:n,modal:a=!0}=e,i=v.useRef(null),[l=!1,s]=d({prop:r,defaultProp:o,onChange:n});/*#__PURE__*/return v.createElement(x,{triggerRef:i,contentId:p(),titleId:p(),descriptionId:p(),open:l,onOpenChange:s,onOpenToggle:v.useCallback((()=>s((e=>!e))),[s]),modal:a},t)};exports.Dialog=b;const E=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogTrigger"),o=g(t,r.triggerRef);/*#__PURE__*/return v.createElement(i.button,D({type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":T(r.open)},e,{ref:o,onClick:m(e.onClick,r.onOpenToggle)}))}));exports.DialogTrigger=E;const O=/*#__PURE__*/v.forwardRef(((e,t)=>{const{forceMount:r,...o}=e,n=C("DialogOverlay");return n.modal?/*#__PURE__*/v.createElement(l,{present:r||n.open},/*#__PURE__*/v.createElement(R,D({},o,{ref:t}))):null}));exports.DialogOverlay=O;const R=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogOverlay");/*#__PURE__*/return v.createElement(s,null,/*#__PURE__*/v.createElement(i.div,D({"data-state":T(r.open)},e,{ref:t})))})),F=/*#__PURE__*/v.forwardRef(((e,t)=>{const{forceMount:r,...o}=e,n=C("DialogContent");/*#__PURE__*/return v.createElement(l,{present:r||n.open},n.modal?/*#__PURE__*/v.createElement(q,D({},o,{ref:t})):/*#__PURE__*/v.createElement(y,D({},o,{ref:t})))}));exports.DialogContent=F;const q=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogContent"),a=v.useRef(null),i=g(t,a);return v.useEffect((()=>{const e=a.current;if(e)return o(e)}),[]),/*#__PURE__*/v.createElement(s,null,/*#__PURE__*/v.createElement(n,null,/*#__PURE__*/v.createElement(h,D({},e,{ref:i,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:m(e.onCloseAutoFocus,(e=>{var t;e.preventDefault(),null===(t=r.triggerRef.current)||void 0===t||t.focus()})),onPointerDownOutside:m(e.onPointerDownOutside,(e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()})),onFocusOutside:m(e.onFocusOutside,(e=>e.preventDefault()))}))))})),y=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogContent"),o=v.useRef(!1);/*#__PURE__*/return v.createElement(s,null,/*#__PURE__*/v.createElement(h,D({},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)||(o.current||null===(a=r.triggerRef.current)||void 0===a||a.focus(),t.preventDefault());o.current=!1},onInteractOutside:t=>{var n,a;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||(o.current=!0);const i=t.target;(null===(a=r.triggerRef.current)||void 0===a?void 0:a.contains(i))&&t.preventDefault()}})))})),h=/*#__PURE__*/v.forwardRef(((e,t)=>{const{"aria-label":r,"aria-labelledby":o,"aria-describedby":n,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:s,...d}=e,p=C("DialogContent"),f=v.useRef(null),m=g(t,f);return a(),/*#__PURE__*/v.createElement(v.Fragment,null,/*#__PURE__*/v.createElement(u,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:l,onUnmountAutoFocus:s},/*#__PURE__*/v.createElement(c,D({role:"dialog",id:p.contentId,"aria-describedby":n||p.descriptionId,"aria-labelledby":r?void 0:o||p.titleId,"aria-label":r||void 0,"data-state":T(p.open)},d,{ref:m,onDismiss:()=>p.onOpenChange(!1)}))),!1)})),P=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogTitle");/*#__PURE__*/return v.createElement(i.h2,D({id:r.titleId},e,{ref:t}))}));exports.DialogTitle=P;const w=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogDescription");/*#__PURE__*/return v.createElement(i.p,D({id:r.descriptionId},e,{ref:t}))}));exports.DialogDescription=w;const I=/*#__PURE__*/v.forwardRef(((e,t)=>{const r=C("DialogClose");/*#__PURE__*/return v.createElement(i.button,D({type:"button"},e,{ref:t,onClick:m(e.onClick,(()=>r.onOpenChange(!1)))}))}));function T(e){return e?"open":"closed"}exports.DialogClose=I;const A=/*#__PURE__*/v.createContext({contentName:"DialogContent",titleName:"DialogTitle",docsSlug:"dialog"}),k=A.Provider;exports.LabelWarningProvider=k;const M=b;exports.Root=M;const S=E;exports.Trigger=S;const _=O;exports.Overlay=_;const j=F;exports.Content=j;const L=P;exports.Title=L;const N=w;exports.Description=N;const G=I;exports.Close=G;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"IAYgCA,EAAMC,EAZNC,wsBAYAF,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,ECqBzC,MAWOU,EAAgBC,GAAoBC,EAXvB,UAmBdC,EAAoCC,IACxC,MAAMC,SAAEA,EAAUC,KAAMC,EAAlBC,YAA4BA,EAA5BC,aAAyCA,GAAiBL,EAC1DM,EAAaC,EAAMC,OAA0B,OAC5CN,GAAO,EAAOO,GAAWC,EAAqB,CACnDC,KAAMR,EACNS,YAAaR,EACbS,SAAUR,iBAGZ,OACES,EAAAC,cAACC,EAAD,CACEV,WAAYA,EACZW,UAAWC,IACXC,QAASD,IACTE,cAAeF,IACfhB,KAAMA,EACNG,aAAcI,GAEbR,qBAWP,MACMoB,EAAsB,SAQtBC,eAAgBf,EAAMgB,YAAW,CAACvB,EAAOwB,KAC7C,MAAMC,GAAEA,EAAKJ,KAAwBK,GAAiB1B,EAChD2B,EAAU9B,EAXG,iBAYb+B,EAAqBC,EAAgBL,EAAcG,EAAQrB,yBACjE,OACEQ,EAAAC,cAACe,EAADC,EAAA,CACEC,KAAK,SACLC,gBAAc,SACdC,gBAAeP,EAAQzB,KACvBiC,gBAAeR,EAAQV,UACvBmB,aAAYC,EAASV,EAAQzB,OACzBwB,EANN,CAOED,GAAIA,EACJa,IAAKV,EACLW,QAASC,EAAqBxC,EAAMuC,SAAS,IAAMZ,EAAQtB,cAAa,mCAW9E,MAkBMoC,eAAgBlC,EAAMgB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CAGE1E,GAAIA,EACJa,IAAKd,EACLe,QAASC,EAAqBxC,EAAMuC,SAAS,IAAMZ,EAAQtB,cAAa,WAS9E,SAASgC,EAASnC,GAChB,OAAOA,EAAO,OAAS,+BAGzB,MAAMkG,eAAsB7F,EAAMT,cAAc,CAC9CuG,YAjNmB,gBAkNnBC,UA3EiB,cA4EjBC,SAAU,WAGNC,EAAuBJ,EAAoBK,wCAMjD,MAsBMC,EAAO3G,iBACb,MAAM4G,EAAUrF,oBAChB,MAAMsF,EAAUnE,oBAChB,MAAMoE,EAAU5D,oBAChB,MAAM6D,EAAQlB,kBACd,MAAMmB,EAAchB,wBACpB,MAAMiB,EAAQd","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 } 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 { Portal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\n\nimport type * as Polymorphic from '@radix-ui/react-polymorphic';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\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};\n\nconst [DialogProvider, useDialogContext] = createContext<DialogContextValue>(DIALOG_NAME);\n\ntype DialogOwnProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n};\n\nconst Dialog: React.FC<DialogOwnProps> = (props) => {\n const { children, open: openProp, defaultOpen, onOpenChange } = 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 triggerRef={triggerRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\nconst TRIGGER_DEFAULT_TAG = 'button';\n\ntype DialogTriggerOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogTriggerPrimitive = Polymorphic.ForwardRefComponent<\n typeof TRIGGER_DEFAULT_TAG,\n DialogTriggerOwnProps\n>;\n\nconst DialogTrigger = React.forwardRef((props, forwardedRef) => {\n const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive\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 as={as}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(true))}\n />\n );\n}) as DialogTriggerPrimitive;\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof DialogOverlayImpl>,\n {\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>;\n\ntype DialogOverlayPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof DialogOverlayImpl>,\n DialogOverlayOwnProps\n>;\n\nconst DialogOverlay = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl data-state={getState(context.open)} {...overlayProps} ref={forwardedRef} />\n </Presence>\n );\n}) as DialogOverlayPrimitive;\n\ntype DialogOverlayImplOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogOverlayImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof Primitive>,\n DialogOverlayImplOwnProps\n>;\n\nconst DialogOverlayImpl = React.forwardRef((props, forwardedRef) => {\n return (\n <Portal>\n <Primitive {...props} ref={forwardedRef} />\n </Portal>\n );\n}) as DialogOverlayImplPrimitive;\n\nDialogOverlay.displayName = OVERLAY_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof DialogContentImpl>,\n {\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>;\n\ntype DialogContentPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof DialogContentImpl>,\n DialogContentOwnProps\n>;\n\nconst DialogContent = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <DialogContentImpl data-state={getState(context.open)} {...contentProps} ref={forwardedRef} />\n </Presence>\n );\n}) as DialogContentPrimitive;\n\ntype FocusScopeOwnProps = Polymorphic.OwnProps<typeof FocusScope>;\n\ntype DialogContentImplOwnProps = Polymorphic.Merge<\n Omit<\n Polymorphic.OwnProps<typeof DismissableLayer>,\n 'disableOutsidePointerEvents' | 'onFocusOutside' | 'onInteractOutside' | 'onDismiss'\n >,\n {\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeOwnProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeOwnProps['onUnmountAutoFocus'];\n }\n>;\n\ntype DialogContentImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof DismissableLayer>,\n DialogContentImplOwnProps\n>;\n\nconst DialogContentImpl = React.forwardRef((props, forwardedRef) => {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onPointerDownOutside,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME);\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 // Hide everything from ARIA except the content\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <>\n <Portal>\n <RemoveScroll>\n <FocusScope\n as={Slot}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapped={context.open}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-modal\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 {...contentProps}\n ref={composedRefs}\n disableOutsidePointerEvents\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={composeEventHandlers(onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent as MouseEvent;\n const isRightClick =\n originalEvent.button === 2 ||\n (originalEvent.button === 0 && originalEvent.ctrlKey === true);\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={(event) => event.preventDefault()}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n </RemoveScroll>\n </Portal>\n {process.env.NODE_ENV === 'development' && <LabelWarning contentRef={contentRef} />}\n </>\n );\n}) as DialogContentImplPrimitive;\n\nDialogContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'DialogTitle';\nconst TITLE_DEFAULT_TAG = 'h2';\n\ntype DialogTitleOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogTitlePrimitive = Polymorphic.ForwardRefComponent<\n typeof TITLE_DEFAULT_TAG,\n DialogTitleOwnProps\n>;\n\nconst DialogTitle = React.forwardRef((props, forwardedRef) => {\n const { as = TITLE_DEFAULT_TAG, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME);\n return <Primitive id={context.titleId} {...titleProps} as={as} ref={forwardedRef} />;\n}) as DialogTitlePrimitive;\n\nDialogTitle.displayName = TITLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'DialogDescription';\nconst DESCRIPTION_DEFAULT_TAG = 'p';\n\ntype DialogDescriptionOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogDescriptionPrimitive = Polymorphic.ForwardRefComponent<\n typeof DESCRIPTION_DEFAULT_TAG,\n DialogDescriptionOwnProps\n>;\n\nconst DialogDescription = React.forwardRef((props, forwardedRef) => {\n const { as = DESCRIPTION_DEFAULT_TAG, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME);\n return <Primitive id={context.descriptionId} {...descriptionProps} as={as} ref={forwardedRef} />;\n}) as DialogDescriptionPrimitive;\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\nconst CLOSE_DEFAULT_TAG = 'button';\n\ntype DialogCloseOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogClosePrimitive = Polymorphic.ForwardRefComponent<\n typeof CLOSE_DEFAULT_TAG,\n DialogCloseOwnProps\n>;\n\nconst DialogClose = React.forwardRef((props, forwardedRef) => {\n const { as = CLOSE_DEFAULT_TAG, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME);\n return (\n <Primitive\n type=\"button\"\n {...closeProps}\n as={as}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n}) as DialogClosePrimitive;\n\nDialogClose.displayName = CLOSE_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst LabelWarningContext = React.createContext({\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\nconst LabelWarningProvider = LabelWarningContext.Provider;\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<React.ElementRef<typeof DialogContent>>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = React.useContext(LabelWarningContext);\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 Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogTriggerPrimitive,\n DialogOverlayPrimitive,\n DialogContentPrimitive,\n DialogTitlePrimitive,\n DialogDescriptionPrimitive,\n DialogClosePrimitive,\n};\n"],"names":["dest","source","a","Object","keys","forEach","key","defineProperty","enumerable","get","__esModule","default","DialogProvider","useDialogContext","createContext","Dialog","props","children","open","openProp","defaultOpen","onOpenChange","triggerRef","React","useRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$b0496301423b3238f89fb15bee25ad02$var$DialogProvider","contentId","useId","titleId","descriptionId","TRIGGER_DEFAULT_TAG","DialogTrigger","forwardRef","forwardedRef","as","triggerProps","context","composedTriggerRef","useComposedRefs","Primitive","_babelRuntimeHelpersExtends","type","aria-haspopup","aria-expanded","aria-controls","data-state","getState","ref","onClick","composeEventHandlers","DialogOverlay","forceMount","overlayProps","Presence","present","$b0496301423b3238f89fb15bee25ad02$var$DialogOverlayImpl","DialogOverlayImpl","Portal","DialogContent","contentProps","$b0496301423b3238f89fb15bee25ad02$var$DialogContentImpl","DialogContentImpl","aria-label","ariaLabel","aria-labelledby","ariaLabelledBy","aria-describedby","ariaDescribedBy","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","contentRef","composedRefs","useFocusGuards","useEffect","content","current","hideOthers","Fragment","RemoveScroll","FocusScope","Slot","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","aria-modal","undefined","disableOutsidePointerEvents","event","originalEvent","detail","button","ctrlKey","preventDefault","onFocusOutside","onDismiss","TITLE_DEFAULT_TAG","DialogTitle","titleProps","DESCRIPTION_DEFAULT_TAG","DialogDescription","descriptionProps","CLOSE_DEFAULT_TAG","DialogClose","closeProps","LabelWarningContext","contentName","titleName","docsSlug","LabelWarningProvider","Provider","Root","Trigger","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.js.map"}
|
|
1
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U,WAGNC,EAAuBJ,EAAoBK,wCAMjD,MAsBMC,EAAOnH,iBACb,MAAMoH,EAAU1F,oBAChB,MAAM2F,EAAU7E,oBAChB,MAAM8E,EAAUrE,oBAChB,MAAMsE,EAAQf,kBACd,MAAMgB,EAAcd,wBACpB,MAAMe,EAAQb","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 } 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 { Portal } 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';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\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};\n\nconst [DialogProvider, useDialogContext] = createContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\n}\n\nconst Dialog: React.FC<DialogProps> = (props) => {\n const { children, open: openProp, defaultOpen, onOpenChange, modal = true } = 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 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 >\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, forwardedRef) => {\n const context = useDialogContext(TRIGGER_NAME);\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 {...props}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nDialogTrigger.displayName = TRIGGER_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, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME);\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, forwardedRef) => {\n const context = useDialogContext(OVERLAY_NAME);\n return (\n <Portal>\n <Primitive.div data-state={getState(context.open)} {...props} ref={forwardedRef} />\n </Portal>\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, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME);\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, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME);\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 <Portal>\n <RemoveScroll>\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 </RemoveScroll>\n </Portal>\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME);\n const hasInteractedOutsideRef = React.useRef(false);\n\n return (\n <Portal>\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 </Portal>\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, forwardedRef) => {\n const {\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);\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, forwardedRef) => {\n const context = useDialogContext(TITLE_NAME);\n return <Primitive.h2 id={context.titleId} {...props} 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, forwardedRef) => {\n const context = useDialogContext(DESCRIPTION_NAME);\n return <Primitive.p id={context.descriptionId} {...props} 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, forwardedRef) => {\n const context = useDialogContext(CLOSE_NAME);\n return (\n <Primitive.button\n type=\"button\"\n {...props}\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 LabelWarningContext = React.createContext({\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\nconst LabelWarningProvider = LabelWarningContext.Provider;\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = React.useContext(LabelWarningContext);\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 Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\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","DialogProvider","useDialogContext","createContext","Dialog","props","children","open","openProp","defaultOpen","onOpenChange","modal","triggerRef","React","useRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$b0496301423b3238f89fb15bee25ad02$var$DialogProvider","contentId","useId","titleId","descriptionId","onOpenToggle","useCallback","prevOpen","DialogTrigger","forwardRef","forwardedRef","context","composedTriggerRef","useComposedRefs","Primitive","button","_babelRuntimeHelpersExtends","type","getState","ref","onClick","composeEventHandlers","DialogOverlay","forceMount","overlayProps","Presence","present","$b0496301423b3238f89fb15bee25ad02$var$DialogOverlayImpl","DialogOverlayImpl","Portal","div","DialogContent","contentProps","$b0496301423b3238f89fb15bee25ad02$var$DialogContentModal","$b0496301423b3238f89fb15bee25ad02$var$DialogContentNonModal","DialogContentModal","contentRef","composedRefs","useEffect","content","current","hideOthers","RemoveScroll","$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","Fragment","FocusScope","asChild","loop","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","undefined","onDismiss","DialogTitle","h2","DialogDescription","p","DialogClose","LabelWarningContext","contentName","titleName","docsSlug","LabelWarningProvider","Provider","Root","Trigger","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{hideOthers as e}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as o}from"@radix-ui/react-focus-guards";import{
|
|
1
|
+
import{hideOthers as e}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as o}from"@radix-ui/react-focus-guards";import{Primitive as r}from"@radix-ui/react-primitive";import{Presence as n}from"@radix-ui/react-presence";import{Portal as a}from"@radix-ui/react-portal";import{FocusScope as i}from"@radix-ui/react-focus-scope";import{DismissableLayer as l}from"@radix-ui/react-dismissable-layer";import{useControllableState as c}from"@radix-ui/react-use-controllable-state";import{useId as s}from"@radix-ui/react-id";import{createContext as u}from"@radix-ui/react-context";import{useComposedRefs as d}from"@radix-ui/react-compose-refs";import{composeEventHandlers as p}from"@radix-ui/primitive";import*as f from"react";import m from"@babel/runtime/helpers/esm/extends";const[g,D]=u("Dialog");export const Dialog=e=>{const{children:t,open:o,defaultOpen:r,onOpenChange:n,modal:a=!0}=e,i=f.useRef(null),[l=!1,u]=c({prop:o,defaultProp:r,onChange:n});/*#__PURE__*/return f.createElement(g,{triggerRef:i,contentId:s(),titleId:s(),descriptionId:s(),open:l,onOpenChange:u,onOpenToggle:f.useCallback((()=>u((e=>!e))),[u]),modal:a},t)};/*#__PURE__*/export const DialogTrigger=/*#__PURE__*/f.forwardRef(((e,t)=>{const o=D("DialogTrigger"),n=d(t,o.triggerRef);/*#__PURE__*/return f.createElement(r.button,m({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":E(o.open)},e,{ref:n,onClick:p(e.onClick,o.onOpenToggle)}))}));/*#__PURE__*/export const DialogOverlay=/*#__PURE__*/f.forwardRef(((e,t)=>{const{forceMount:o,...r}=e,a=D("DialogOverlay");return a.modal?/*#__PURE__*/f.createElement(n,{present:o||a.open},/*#__PURE__*/f.createElement(v,m({},r,{ref:t}))):null}));/*#__PURE__*/const v=/*#__PURE__*/f.forwardRef(((e,t)=>{const o=D("DialogOverlay");/*#__PURE__*/return f.createElement(a,null,/*#__PURE__*/f.createElement(r.div,m({"data-state":E(o.open)},e,{ref:t})))}));export const DialogContent=/*#__PURE__*/f.forwardRef(((e,t)=>{const{forceMount:o,...r}=e,a=D("DialogContent");/*#__PURE__*/return f.createElement(n,{present:o||a.open},a.modal?/*#__PURE__*/f.createElement(x,m({},r,{ref:t})):/*#__PURE__*/f.createElement(C,m({},r,{ref:t})))}));/*#__PURE__*/const x=/*#__PURE__*/f.forwardRef(((o,r)=>{const n=D("DialogContent"),i=f.useRef(null),l=d(r,i);return f.useEffect((()=>{const t=i.current;if(t)return e(t)}),[]),/*#__PURE__*/f.createElement(a,null,/*#__PURE__*/f.createElement(t,null,/*#__PURE__*/f.createElement(b,m({},o,{ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:p(o.onCloseAutoFocus,(e=>{var t;e.preventDefault(),null===(t=n.triggerRef.current)||void 0===t||t.focus()})),onPointerDownOutside:p(o.onPointerDownOutside,(e=>{const t=e.detail.originalEvent,o=0===t.button&&!0===t.ctrlKey;(2===t.button||o)&&e.preventDefault()})),onFocusOutside:p(o.onFocusOutside,(e=>e.preventDefault()))}))))})),C=/*#__PURE__*/f.forwardRef(((e,t)=>{const o=D("DialogContent"),r=f.useRef(!1);/*#__PURE__*/return f.createElement(a,null,/*#__PURE__*/f.createElement(b,m({},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 i=t.target;(null===(a=o.triggerRef.current)||void 0===a?void 0:a.contains(i))&&t.preventDefault()}})))})),b=/*#__PURE__*/f.forwardRef(((e,t)=>{const{"aria-label":r,"aria-labelledby":n,"aria-describedby":a,trapFocus:c,onOpenAutoFocus:s,onCloseAutoFocus:u,...p}=e,g=D("DialogContent"),v=f.useRef(null),x=d(t,v);return o(),/*#__PURE__*/f.createElement(f.Fragment,null,/*#__PURE__*/f.createElement(i,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:s,onUnmountAutoFocus:u},/*#__PURE__*/f.createElement(l,m({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":E(g.open)},p,{ref:x,onDismiss:()=>g.onOpenChange(!1)}))),!1)}));export const DialogTitle=/*#__PURE__*/f.forwardRef(((e,t)=>{const o=D("DialogTitle");/*#__PURE__*/return f.createElement(r.h2,m({id:o.titleId},e,{ref:t}))}));/*#__PURE__*/export const DialogDescription=/*#__PURE__*/f.forwardRef(((e,t)=>{const o=D("DialogDescription");/*#__PURE__*/return f.createElement(r.p,m({id:o.descriptionId},e,{ref:t}))}));/*#__PURE__*/export const DialogClose=/*#__PURE__*/f.forwardRef(((e,t)=>{const o=D("DialogClose");/*#__PURE__*/return f.createElement(r.button,m({type:"button"},e,{ref:t,onClick:p(e.onClick,(()=>o.onOpenChange(!1)))}))}));/*#__PURE__*/function E(e){return e?"open":"closed"}const O=/*#__PURE__*/f.createContext({contentName:"DialogContent",titleName:"DialogTitle",docsSlug:"dialog"});export const LabelWarningProvider=O.Provider;export const Root=Dialog;export const Trigger=DialogTrigger;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
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"m1BAsBA,MAWOA,EAAgBC,GAAoBC,EAXvB,iBAmBpB,MAAMC,OAAoCC,IACxC,MAAMC,SAAEA,EAAUC,KAAMC,EAAlBC,YAA4BA,EAA5BC,aAAyCA,GAAiBL,EAC1DM,EAAaC,EAAMC,OAA0B,OAC5CN,GAAO,EAAOO,GAAWC,EAAqB,CACnDC,KAAMR,EACNS,YAAaR,EACbS,SAAUR,iBAGZ,OACES,EAAAC,cAACC,EAAD,CACEV,WAAYA,EACZW,UAAWC,IACXC,QAASD,IACTE,cAAeF,IACfhB,KAAMA,EACNG,aAAcI,GAEbR,iBAWP,MACMoB,EAAsB,gBAQ5B,MAAMC,2BAAgBf,EAAMgB,YAAW,CAACvB,EAAOwB,KAC7C,MAAMC,GAAEA,EAAKJ,KAAwBK,GAAiB1B,EAChD2B,EAAU9B,EAXG,iBAYb+B,EAAqBC,EAAgBL,EAAcG,EAAQrB,yBACjE,OACEQ,EAAAC,cAACe,EAADC,EAAA,CACEC,KAAK,SACLC,gBAAc,SACdC,gBAAeP,EAAQzB,KACvBiC,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ASlF,MACMyE,EAAoB,gBAQ1B,MAAMC,yBAAc3F,EAAMgB,YAAW,CAACvB,EAAOwB,KAC3C,MAAMC,GAAEA,EAAKwE,KAAsBE,GAAenG,EAC5C2B,EAAU9B,EAXC,4BAYjB,OACEiB,EAAAC,cAACe,EAADC,EAAA,CACEC,KAAK,UACDmE,EAFN,CAGE1E,GAAIA,EACJa,IAAKd,EACLe,QAASC,EAAqBxC,EAAMuC,SAAS,IAAMZ,EAAQtB,cAAa,wBAS9E,SAASgC,EAASnC,GAChB,OAAOA,EAAO,OAAS,SAGzB,MAAMkG,eAAsB7F,EAAMT,cAAc,CAC9CuG,YAjNmB,gBAkNnBC,UA3EiB,cA4EjBC,SAAU,kBAGZ,MAAMC,qBAAuBJ,EAAoBK,gBA4BjD,MAAMC,KAAO3G,cACb,MAAM4G,QAAUrF,qBAChB,MAAMsF,QAAUnE,qBAChB,MAAMoE,QAAU5D,qBAChB,MAAM6D,MAAQlB,mBACd,MAAMmB,YAAchB,yBACpB,MAAMiB,MAAQd","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 } 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 { Portal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\n\nimport type * as Polymorphic from '@radix-ui/react-polymorphic';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\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};\n\nconst [DialogProvider, useDialogContext] = createContext<DialogContextValue>(DIALOG_NAME);\n\ntype DialogOwnProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n};\n\nconst Dialog: React.FC<DialogOwnProps> = (props) => {\n const { children, open: openProp, defaultOpen, onOpenChange } = 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 triggerRef={triggerRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\nconst TRIGGER_DEFAULT_TAG = 'button';\n\ntype DialogTriggerOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogTriggerPrimitive = Polymorphic.ForwardRefComponent<\n typeof TRIGGER_DEFAULT_TAG,\n DialogTriggerOwnProps\n>;\n\nconst DialogTrigger = React.forwardRef((props, forwardedRef) => {\n const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive\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 as={as}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(true))}\n />\n );\n}) as DialogTriggerPrimitive;\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof DialogOverlayImpl>,\n {\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>;\n\ntype DialogOverlayPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof DialogOverlayImpl>,\n DialogOverlayOwnProps\n>;\n\nconst DialogOverlay = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl data-state={getState(context.open)} {...overlayProps} ref={forwardedRef} />\n </Presence>\n );\n}) as DialogOverlayPrimitive;\n\ntype DialogOverlayImplOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogOverlayImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof Primitive>,\n DialogOverlayImplOwnProps\n>;\n\nconst DialogOverlayImpl = React.forwardRef((props, forwardedRef) => {\n return (\n <Portal>\n <Primitive {...props} ref={forwardedRef} />\n </Portal>\n );\n}) as DialogOverlayImplPrimitive;\n\nDialogOverlay.displayName = OVERLAY_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof DialogContentImpl>,\n {\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>;\n\ntype DialogContentPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof DialogContentImpl>,\n DialogContentOwnProps\n>;\n\nconst DialogContent = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <DialogContentImpl data-state={getState(context.open)} {...contentProps} ref={forwardedRef} />\n </Presence>\n );\n}) as DialogContentPrimitive;\n\ntype FocusScopeOwnProps = Polymorphic.OwnProps<typeof FocusScope>;\n\ntype DialogContentImplOwnProps = Polymorphic.Merge<\n Omit<\n Polymorphic.OwnProps<typeof DismissableLayer>,\n 'disableOutsidePointerEvents' | 'onFocusOutside' | 'onInteractOutside' | 'onDismiss'\n >,\n {\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeOwnProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeOwnProps['onUnmountAutoFocus'];\n }\n>;\n\ntype DialogContentImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof DismissableLayer>,\n DialogContentImplOwnProps\n>;\n\nconst DialogContentImpl = React.forwardRef((props, forwardedRef) => {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onPointerDownOutside,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME);\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 // Hide everything from ARIA except the content\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <>\n <Portal>\n <RemoveScroll>\n <FocusScope\n as={Slot}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapped={context.open}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-modal\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 {...contentProps}\n ref={composedRefs}\n disableOutsidePointerEvents\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={composeEventHandlers(onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent as MouseEvent;\n const isRightClick =\n originalEvent.button === 2 ||\n (originalEvent.button === 0 && originalEvent.ctrlKey === true);\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={(event) => event.preventDefault()}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n </RemoveScroll>\n </Portal>\n {process.env.NODE_ENV === 'development' && <LabelWarning contentRef={contentRef} />}\n </>\n );\n}) as DialogContentImplPrimitive;\n\nDialogContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'DialogTitle';\nconst TITLE_DEFAULT_TAG = 'h2';\n\ntype DialogTitleOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogTitlePrimitive = Polymorphic.ForwardRefComponent<\n typeof TITLE_DEFAULT_TAG,\n DialogTitleOwnProps\n>;\n\nconst DialogTitle = React.forwardRef((props, forwardedRef) => {\n const { as = TITLE_DEFAULT_TAG, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME);\n return <Primitive id={context.titleId} {...titleProps} as={as} ref={forwardedRef} />;\n}) as DialogTitlePrimitive;\n\nDialogTitle.displayName = TITLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'DialogDescription';\nconst DESCRIPTION_DEFAULT_TAG = 'p';\n\ntype DialogDescriptionOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogDescriptionPrimitive = Polymorphic.ForwardRefComponent<\n typeof DESCRIPTION_DEFAULT_TAG,\n DialogDescriptionOwnProps\n>;\n\nconst DialogDescription = React.forwardRef((props, forwardedRef) => {\n const { as = DESCRIPTION_DEFAULT_TAG, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME);\n return <Primitive id={context.descriptionId} {...descriptionProps} as={as} ref={forwardedRef} />;\n}) as DialogDescriptionPrimitive;\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\nconst CLOSE_DEFAULT_TAG = 'button';\n\ntype DialogCloseOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype DialogClosePrimitive = Polymorphic.ForwardRefComponent<\n typeof CLOSE_DEFAULT_TAG,\n DialogCloseOwnProps\n>;\n\nconst DialogClose = React.forwardRef((props, forwardedRef) => {\n const { as = CLOSE_DEFAULT_TAG, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME);\n return (\n <Primitive\n type=\"button\"\n {...closeProps}\n as={as}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n}) as DialogClosePrimitive;\n\nDialogClose.displayName = CLOSE_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst LabelWarningContext = React.createContext({\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\nconst LabelWarningProvider = LabelWarningContext.Provider;\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<React.ElementRef<typeof DialogContent>>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = React.useContext(LabelWarningContext);\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 Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogTriggerPrimitive,\n DialogOverlayPrimitive,\n DialogContentPrimitive,\n DialogTitlePrimitive,\n DialogDescriptionPrimitive,\n DialogClosePrimitive,\n};\n"],"names":["DialogProvider","useDialogContext","createContext","Dialog","props","children","open","openProp","defaultOpen","onOpenChange","triggerRef","React","useRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$da81f3af863821fb8a193d321c41d$var$DialogProvider","contentId","useId","titleId","descriptionId","TRIGGER_DEFAULT_TAG","DialogTrigger","forwardRef","forwardedRef","as","triggerProps","context","composedTriggerRef","useComposedRefs","Primitive","_babelRuntimeHelpersEsmExtends","type","aria-haspopup","aria-expanded","aria-controls","data-state","getState","ref","onClick","composeEventHandlers","DialogOverlay","forceMount","overlayProps","Presence","present","$da81f3af863821fb8a193d321c41d$var$DialogOverlayImpl","DialogOverlayImpl","Portal","DialogContent","contentProps","$da81f3af863821fb8a193d321c41d$var$DialogContentImpl","DialogContentImpl","aria-label","ariaLabel","aria-labelledby","ariaLabelledBy","aria-describedby","ariaDescribedBy","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","contentRef","composedRefs","useFocusGuards","useEffect","content","current","hideOthers","Fragment","RemoveScroll","FocusScope","Slot","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","aria-modal","undefined","disableOutsidePointerEvents","event","originalEvent","detail","button","ctrlKey","preventDefault","onFocusOutside","onDismiss","TITLE_DEFAULT_TAG","DialogTitle","titleProps","DESCRIPTION_DEFAULT_TAG","DialogDescription","descriptionProps","CLOSE_DEFAULT_TAG","DialogClose","closeProps","LabelWarningContext","contentName","titleName","docsSlug","LabelWarningProvider","Provider","Root","Trigger","Overlay","Content","Title","Description","Close"],"version":3,"file":"index.module.js.map"}
|
|
1
|
+
{"mappings":"uyBAqBA,MAaOA,EAAgBC,GAAoBC,EAbvB,iBAsBpB,MAAMC,OAAiCC,IACrC,MAAMC,SAAEA,EAAUC,KAAMC,EAAlBC,YAA4BA,EAA5BC,aAAyCA,EAAzCC,MAAuDA,GAAQ,GAASN,EACxEO,EAAaC,EAAMC,OAA0B,OAC5CP,GAAO,EAAOQ,GAAWC,EAAqB,CACnDC,KAAMT,EACNU,YAAaT,EACbU,SAAUT,iBAGZ,OACEU,EAAAC,cAACC,EAAD,CACEV,WAAYA,EACZW,UAAWC,IACXC,QAASD,IACTE,cAAeF,IACfjB,KAAMA,EACNG,aAAcK,EACdY,aAAcd,EAA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xE,EAAQR,SAAapB,EAAvC,CAA8CoC,IAAKT,4BAgB9D,MAAM8E,+BAAoBjG,EAAMkB,YAC9B,CAAC1B,EAAO2B,KACN,MAAMC,EAAU/B,EARK,kCASrB,OAAOkB,EAAAC,cAACe,EAAU2E,EAAXzE,EAAA,CAAamE,GAAIxE,EAAQP,eAAmBrB,EAA5C,CAAmDoC,IAAKT,4BAenE,MAAMgF,yBAAcnG,EAAMkB,YACxB,CAAC1B,EAAO2B,KACN,MAAMC,EAAU/B,EAPD,4BAQf,OACEkB,EAAAC,cAACe,EAAUC,OAAXC,EAAA,CACEC,KAAK,UACDlC,EAFN,CAGEoC,IAAKT,EACLU,QAASC,EAAqBtC,EAAMqC,SAAS,IAAMT,EAAQvB,cAAa,wBAUhF,SAAS8B,EAASjC,GAChB,OAAOA,EAAO,OAAS,SAGzB,MAAM0G,eAAsBpG,EAAMV,cAAc,CAC9C+G,YAjRmB,gBAkRnBC,UAnEiB,cAoEjBC,SAAU,kBAGZ,MAAMC,qBAAuBJ,EAAoBK,gBA4BjD,MAAMC,KAAOnH,cACb,MAAMoH,QAAU1F,qBAChB,MAAM2F,QAAU7E,qBAChB,MAAM8E,QAAUrE,qBAChB,MAAMsE,MAAQf,mBACd,MAAMgB,YAAcd,yBACpB,MAAMe,MAAQb","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 } 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 { Portal } 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';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\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};\n\nconst [DialogProvider, useDialogContext] = createContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\n}\n\nconst Dialog: React.FC<DialogProps> = (props) => {\n const { children, open: openProp, defaultOpen, onOpenChange, modal = true } = 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 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 >\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, forwardedRef) => {\n const context = useDialogContext(TRIGGER_NAME);\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 {...props}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nDialogTrigger.displayName = TRIGGER_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, forwardedRef) => {\n const { forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME);\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, forwardedRef) => {\n const context = useDialogContext(OVERLAY_NAME);\n return (\n <Portal>\n <Primitive.div data-state={getState(context.open)} {...props} ref={forwardedRef} />\n </Portal>\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, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME);\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, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME);\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 <Portal>\n <RemoveScroll>\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 </RemoveScroll>\n </Portal>\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(\n (props, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME);\n const hasInteractedOutsideRef = React.useRef(false);\n\n return (\n <Portal>\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 </Portal>\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, forwardedRef) => {\n const {\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);\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, forwardedRef) => {\n const context = useDialogContext(TITLE_NAME);\n return <Primitive.h2 id={context.titleId} {...props} 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, forwardedRef) => {\n const context = useDialogContext(DESCRIPTION_NAME);\n return <Primitive.p id={context.descriptionId} {...props} 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, forwardedRef) => {\n const context = useDialogContext(CLOSE_NAME);\n return (\n <Primitive.button\n type=\"button\"\n {...props}\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 LabelWarningContext = React.createContext({\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: 'dialog',\n});\n\nconst LabelWarningProvider = LabelWarningContext.Provider;\n\ntype LabelWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n};\n\nconst LabelWarning: React.FC<LabelWarningProps> = ({ contentRef }) => {\n const labelWarningContext = React.useContext(LabelWarningContext);\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 Overlay = DialogOverlay;\nconst Content = DialogContent;\nconst Title = DialogTitle;\nconst Description = DialogDescription;\nconst Close = DialogClose;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n //\n LabelWarningProvider,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],"names":["DialogProvider","useDialogContext","createContext","Dialog","props","children","open","openProp","defaultOpen","onOpenChange","modal","triggerRef","React","useRef","setOpen","useControllableState","prop","defaultProp","onChange","_react","createElement","$da81f3af863821fb8a193d321c41d$var$DialogProvider","contentId","useId","titleId","descriptionId","onOpenToggle","useCallback","prevOpen","DialogTrigger","forwardRef","forwardedRef","context","composedTriggerRef","useComposedRefs","Primitive","button","_babelRuntimeHelpersEsmExtends","type","getState","ref","onClick","composeEventHandlers","DialogOverlay","forceMount","overlayProps","Presence","present","$da81f3af863821fb8a193d321c41d$var$DialogOverlayImpl","DialogOverlayImpl","Portal","div","DialogContent","contentProps","$da81f3af863821fb8a193d321c41d$var$DialogContentModal","$da81f3af863821fb8a193d321c41d$var$DialogContentNonModal","DialogContentModal","contentRef","composedRefs","useEffect","content","current","hideOthers","RemoveScroll","$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","Fragment","FocusScope","asChild","loop","trapped","onMountAutoFocus","onUnmountAutoFocus","DismissableLayer","role","id","undefined","onDismiss","DialogTitle","h2","DialogDescription","p","DialogClose","LabelWarningContext","contentName","titleName","docsSlug","LabelWarningProvider","Provider","Root","Trigger","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.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,24 +13,21 @@
|
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"scripts": {
|
|
15
15
|
"clean": "rm -rf dist",
|
|
16
|
-
"prepublish": "yarn clean",
|
|
17
16
|
"version": "yarn version"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"@babel/runtime": "^7.13.10",
|
|
21
|
-
"@radix-ui/primitive": "0.0
|
|
22
|
-
"@radix-ui/react-compose-refs": "0.0
|
|
23
|
-
"@radix-ui/react-context": "0.0
|
|
24
|
-
"@radix-ui/react-dismissable-layer": "0.0
|
|
25
|
-
"@radix-ui/react-focus-guards": "0.0
|
|
26
|
-
"@radix-ui/react-focus-scope": "0.0
|
|
27
|
-
"@radix-ui/react-id": "0.0
|
|
28
|
-
"@radix-ui/react-
|
|
29
|
-
"@radix-ui/react-
|
|
30
|
-
"@radix-ui/react-
|
|
31
|
-
"@radix-ui/react-
|
|
32
|
-
"@radix-ui/react-slot": "0.0.12",
|
|
33
|
-
"@radix-ui/react-use-controllable-state": "0.0.6",
|
|
20
|
+
"@radix-ui/primitive": "0.1.0",
|
|
21
|
+
"@radix-ui/react-compose-refs": "0.1.0",
|
|
22
|
+
"@radix-ui/react-context": "0.1.0",
|
|
23
|
+
"@radix-ui/react-dismissable-layer": "0.1.0",
|
|
24
|
+
"@radix-ui/react-focus-guards": "0.1.0",
|
|
25
|
+
"@radix-ui/react-focus-scope": "0.1.0",
|
|
26
|
+
"@radix-ui/react-id": "0.1.0",
|
|
27
|
+
"@radix-ui/react-portal": "0.1.0",
|
|
28
|
+
"@radix-ui/react-presence": "0.1.0",
|
|
29
|
+
"@radix-ui/react-primitive": "0.1.0",
|
|
30
|
+
"@radix-ui/react-use-controllable-state": "0.1.0",
|
|
34
31
|
"aria-hidden": "^1.1.1",
|
|
35
32
|
"react-remove-scroll": "^2.4.0"
|
|
36
33
|
},
|