@radix-ui/react-dialog 1.0.6-rc.6 → 1.1.0-rc.2
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.mts +52 -40
- package/dist/index.d.ts +52 -40
- package/dist/index.js +325 -363
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +310 -335
- package/dist/index.mjs.map +7 -1
- package/package.json +13 -14
- package/dist/index.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,365 +1,340 @@
|
|
|
1
|
-
|
|
2
|
-
import {useRef as $67UHm$useRef, createElement as $67UHm$createElement, useCallback as $67UHm$useCallback, forwardRef as $67UHm$forwardRef, Children as $67UHm$Children, useEffect as $67UHm$useEffect, Fragment as $67UHm$Fragment} from "react";
|
|
3
|
-
import {composeEventHandlers as $67UHm$composeEventHandlers} from "@radix-ui/primitive";
|
|
4
|
-
import {useComposedRefs as $67UHm$useComposedRefs} from "@radix-ui/react-compose-refs";
|
|
5
|
-
import {createContextScope as $67UHm$createContextScope, createContext as $67UHm$createContext} from "@radix-ui/react-context";
|
|
6
|
-
import {useId as $67UHm$useId} from "@radix-ui/react-id";
|
|
7
|
-
import {useControllableState as $67UHm$useControllableState} from "@radix-ui/react-use-controllable-state";
|
|
8
|
-
import {DismissableLayer as $67UHm$DismissableLayer} from "@radix-ui/react-dismissable-layer";
|
|
9
|
-
import {FocusScope as $67UHm$FocusScope} from "@radix-ui/react-focus-scope";
|
|
10
|
-
import {Portal as $67UHm$Portal} from "@radix-ui/react-portal";
|
|
11
|
-
import {Presence as $67UHm$Presence} from "@radix-ui/react-presence";
|
|
12
|
-
import {Primitive as $67UHm$Primitive} from "@radix-ui/react-primitive";
|
|
13
|
-
import {useFocusGuards as $67UHm$useFocusGuards} from "@radix-ui/react-focus-guards";
|
|
14
|
-
import {RemoveScroll as $67UHm$RemoveScroll} from "react-remove-scroll";
|
|
15
|
-
import {hideOthers as $67UHm$hideOthers} from "aria-hidden";
|
|
16
|
-
import {Slot as $67UHm$Slot} from "@radix-ui/react-slot";
|
|
1
|
+
"use client";
|
|
17
2
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
3
|
+
// packages/react/dialog/src/Dialog.tsx
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
6
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
7
|
+
import { createContext, createContextScope } from "@radix-ui/react-context";
|
|
8
|
+
import { useId } from "@radix-ui/react-id";
|
|
9
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
10
|
+
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
11
|
+
import { FocusScope } from "@radix-ui/react-focus-scope";
|
|
12
|
+
import { Portal as PortalPrimitive } from "@radix-ui/react-portal";
|
|
13
|
+
import { Presence } from "@radix-ui/react-presence";
|
|
14
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
15
|
+
import { useFocusGuards } from "@radix-ui/react-focus-guards";
|
|
16
|
+
import { RemoveScroll } from "react-remove-scroll";
|
|
17
|
+
import { hideOthers } from "aria-hidden";
|
|
18
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
19
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var DIALOG_NAME = "Dialog";
|
|
21
|
+
var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
|
|
22
|
+
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
23
|
+
var Dialog = (props) => {
|
|
24
|
+
const {
|
|
25
|
+
__scopeDialog,
|
|
26
|
+
children,
|
|
27
|
+
open: openProp,
|
|
28
|
+
defaultOpen,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
modal = true
|
|
31
|
+
} = props;
|
|
32
|
+
const triggerRef = React.useRef(null);
|
|
33
|
+
const contentRef = React.useRef(null);
|
|
34
|
+
const [open = false, setOpen] = useControllableState({
|
|
35
|
+
prop: openProp,
|
|
36
|
+
defaultProp: defaultOpen,
|
|
37
|
+
onChange: onOpenChange
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
DialogProvider,
|
|
41
|
+
{
|
|
42
|
+
scope: __scopeDialog,
|
|
43
|
+
triggerRef,
|
|
44
|
+
contentRef,
|
|
45
|
+
contentId: useId(),
|
|
46
|
+
titleId: useId(),
|
|
47
|
+
descriptionId: useId(),
|
|
48
|
+
open,
|
|
49
|
+
onOpenChange: setOpen,
|
|
50
|
+
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
51
|
+
modal,
|
|
52
|
+
children
|
|
53
|
+
}
|
|
54
|
+
);
|
|
64
55
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return /*#__PURE__*/ $67UHm$createElement($67UHm$Primitive.button, $67UHm$babelruntimehelpersesmextends({
|
|
56
|
+
Dialog.displayName = DIALOG_NAME;
|
|
57
|
+
var TRIGGER_NAME = "DialogTrigger";
|
|
58
|
+
var DialogTrigger = React.forwardRef(
|
|
59
|
+
(props, forwardedRef) => {
|
|
60
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
61
|
+
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
62
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
Primitive.button,
|
|
65
|
+
{
|
|
76
66
|
type: "button",
|
|
77
67
|
"aria-haspopup": "dialog",
|
|
78
68
|
"aria-expanded": context.open,
|
|
79
69
|
"aria-controls": context.contentId,
|
|
80
|
-
"data-state":
|
|
81
|
-
|
|
70
|
+
"data-state": getState(context.open),
|
|
71
|
+
...triggerProps,
|
|
82
72
|
ref: composedTriggerRef,
|
|
83
|
-
onClick:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
DialogTrigger.displayName = TRIGGER_NAME;
|
|
79
|
+
var PORTAL_NAME = "DialogPortal";
|
|
80
|
+
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
81
|
+
forceMount: void 0
|
|
88
82
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
forceMount: undefined
|
|
94
|
-
});
|
|
95
|
-
const $5d3850c4d0b4e6c7$export$dad7c95542bacce0 = (props)=>{
|
|
96
|
-
const { __scopeDialog: __scopeDialog , forceMount: forceMount , children: children , container: container } = props;
|
|
97
|
-
const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$PORTAL_NAME, __scopeDialog);
|
|
98
|
-
return /*#__PURE__*/ $67UHm$createElement($5d3850c4d0b4e6c7$var$PortalProvider, {
|
|
99
|
-
scope: __scopeDialog,
|
|
100
|
-
forceMount: forceMount
|
|
101
|
-
}, $67UHm$Children.map(children, (child)=>/*#__PURE__*/ $67UHm$createElement($67UHm$Presence, {
|
|
102
|
-
present: forceMount || context.open
|
|
103
|
-
}, /*#__PURE__*/ $67UHm$createElement($67UHm$Portal, {
|
|
104
|
-
asChild: true,
|
|
105
|
-
container: container
|
|
106
|
-
}, child))
|
|
107
|
-
));
|
|
83
|
+
var DialogPortal = (props) => {
|
|
84
|
+
const { __scopeDialog, forceMount, children, container } = props;
|
|
85
|
+
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
86
|
+
return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: React.Children.map(children, (child) => /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(PortalPrimitive, { asChild: true, container, children: child }) })) });
|
|
108
87
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
as: $67UHm$Slot,
|
|
135
|
-
allowPinchZoom: true,
|
|
136
|
-
shards: [
|
|
137
|
-
context.contentRef
|
|
138
|
-
]
|
|
139
|
-
}, /*#__PURE__*/ $67UHm$createElement($67UHm$Primitive.div, $67UHm$babelruntimehelpersesmextends({
|
|
140
|
-
"data-state": $5d3850c4d0b4e6c7$var$getState(context.open)
|
|
141
|
-
}, overlayProps, {
|
|
142
|
-
ref: forwardedRef // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.
|
|
143
|
-
,
|
|
144
|
-
style: {
|
|
145
|
-
pointerEvents: 'auto',
|
|
146
|
-
...overlayProps.style
|
|
88
|
+
DialogPortal.displayName = PORTAL_NAME;
|
|
89
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
90
|
+
var DialogOverlay = React.forwardRef(
|
|
91
|
+
(props, forwardedRef) => {
|
|
92
|
+
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
93
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
94
|
+
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
95
|
+
return context.modal ? /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
DialogOverlay.displayName = OVERLAY_NAME;
|
|
99
|
+
var DialogOverlayImpl = React.forwardRef(
|
|
100
|
+
(props, forwardedRef) => {
|
|
101
|
+
const { __scopeDialog, ...overlayProps } = props;
|
|
102
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
103
|
+
return (
|
|
104
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
105
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
106
|
+
/* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx(
|
|
107
|
+
Primitive.div,
|
|
108
|
+
{
|
|
109
|
+
"data-state": getState(context.open),
|
|
110
|
+
...overlayProps,
|
|
111
|
+
ref: forwardedRef,
|
|
112
|
+
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
147
113
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const contentRef = $67UHm$useRef(null);
|
|
171
|
-
const composedRefs = $67UHm$useComposedRefs(forwardedRef, context.contentRef, contentRef); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
|
|
172
|
-
$67UHm$useEffect(()=>{
|
|
173
|
-
const content = contentRef.current;
|
|
174
|
-
if (content) return $67UHm$hideOthers(content);
|
|
114
|
+
) })
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
var CONTENT_NAME = "DialogContent";
|
|
119
|
+
var DialogContent = React.forwardRef(
|
|
120
|
+
(props, forwardedRef) => {
|
|
121
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
122
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
123
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
124
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
DialogContent.displayName = CONTENT_NAME;
|
|
128
|
+
var DialogContentModal = React.forwardRef(
|
|
129
|
+
(props, forwardedRef) => {
|
|
130
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
131
|
+
const contentRef = React.useRef(null);
|
|
132
|
+
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
133
|
+
React.useEffect(() => {
|
|
134
|
+
const content = contentRef.current;
|
|
135
|
+
if (content) return hideOthers(content);
|
|
175
136
|
}, []);
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
DialogContentImpl,
|
|
139
|
+
{
|
|
140
|
+
...props,
|
|
141
|
+
ref: composedRefs,
|
|
179
142
|
trapFocus: context.open,
|
|
180
143
|
disableOutsidePointerEvents: true,
|
|
181
|
-
onCloseAutoFocus:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
(_context$triggerRef$c = context.triggerRef.current) === null || _context$triggerRef$c === void 0 || _context$triggerRef$c.focus();
|
|
144
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
context.triggerRef.current?.focus();
|
|
185
147
|
}),
|
|
186
|
-
onPointerDownOutside:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
148
|
+
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
149
|
+
const originalEvent = event.detail.originalEvent;
|
|
150
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
151
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
152
|
+
if (isRightClick) event.preventDefault();
|
|
153
|
+
}),
|
|
154
|
+
onFocusOutside: composeEventHandlers(
|
|
155
|
+
props.onFocusOutside,
|
|
156
|
+
(event) => event.preventDefault()
|
|
195
157
|
)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
var DialogContentNonModal = React.forwardRef(
|
|
163
|
+
(props, forwardedRef) => {
|
|
164
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
165
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
166
|
+
const hasPointerDownOutsideRef = React.useRef(false);
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
DialogContentImpl,
|
|
169
|
+
{
|
|
170
|
+
...props,
|
|
203
171
|
ref: forwardedRef,
|
|
204
172
|
trapFocus: false,
|
|
205
173
|
disableOutsidePointerEvents: false,
|
|
206
|
-
onCloseAutoFocus: (event)=>{
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
hasInteractedOutsideRef.current = false;
|
|
215
|
-
hasPointerDownOutsideRef.current = false;
|
|
174
|
+
onCloseAutoFocus: (event) => {
|
|
175
|
+
props.onCloseAutoFocus?.(event);
|
|
176
|
+
if (!event.defaultPrevented) {
|
|
177
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
}
|
|
180
|
+
hasInteractedOutsideRef.current = false;
|
|
181
|
+
hasPointerDownOutsideRef.current = false;
|
|
216
182
|
},
|
|
217
|
-
onInteractOutside: (event)=>{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// already had a pointer down outside event.
|
|
232
|
-
if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) event.preventDefault();
|
|
183
|
+
onInteractOutside: (event) => {
|
|
184
|
+
props.onInteractOutside?.(event);
|
|
185
|
+
if (!event.defaultPrevented) {
|
|
186
|
+
hasInteractedOutsideRef.current = true;
|
|
187
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
188
|
+
hasPointerDownOutsideRef.current = true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const target = event.target;
|
|
192
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
193
|
+
if (targetIsTrigger) event.preventDefault();
|
|
194
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
}
|
|
233
197
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const { __scopeDialog
|
|
280
|
-
const context =
|
|
281
|
-
return
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
/*
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
var DialogContentImpl = React.forwardRef(
|
|
203
|
+
(props, forwardedRef) => {
|
|
204
|
+
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
205
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
206
|
+
const contentRef = React.useRef(null);
|
|
207
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
208
|
+
useFocusGuards();
|
|
209
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
210
|
+
/* @__PURE__ */ jsx(
|
|
211
|
+
FocusScope,
|
|
212
|
+
{
|
|
213
|
+
asChild: true,
|
|
214
|
+
loop: true,
|
|
215
|
+
trapped: trapFocus,
|
|
216
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
217
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
218
|
+
children: /* @__PURE__ */ jsx(
|
|
219
|
+
DismissableLayer,
|
|
220
|
+
{
|
|
221
|
+
role: "dialog",
|
|
222
|
+
id: context.contentId,
|
|
223
|
+
"aria-describedby": context.descriptionId,
|
|
224
|
+
"aria-labelledby": context.titleId,
|
|
225
|
+
"data-state": getState(context.open),
|
|
226
|
+
...contentProps,
|
|
227
|
+
ref: composedRefs,
|
|
228
|
+
onDismiss: () => context.onOpenChange(false)
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
234
|
+
/* @__PURE__ */ jsx(TitleWarning, { titleId: context.titleId }),
|
|
235
|
+
/* @__PURE__ */ jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
236
|
+
] })
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
var TITLE_NAME = "DialogTitle";
|
|
241
|
+
var DialogTitle = React.forwardRef(
|
|
242
|
+
(props, forwardedRef) => {
|
|
243
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
244
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
245
|
+
return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
DialogTitle.displayName = TITLE_NAME;
|
|
249
|
+
var DESCRIPTION_NAME = "DialogDescription";
|
|
250
|
+
var DialogDescription = React.forwardRef(
|
|
251
|
+
(props, forwardedRef) => {
|
|
252
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
253
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
254
|
+
return /* @__PURE__ */ jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
258
|
+
var CLOSE_NAME = "DialogClose";
|
|
259
|
+
var DialogClose = React.forwardRef(
|
|
260
|
+
(props, forwardedRef) => {
|
|
261
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
262
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
Primitive.button,
|
|
265
|
+
{
|
|
266
|
+
type: "button",
|
|
267
|
+
...closeProps,
|
|
299
268
|
ref: forwardedRef,
|
|
300
|
-
onClick:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return open ? 'open' : 'closed';
|
|
269
|
+
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
DialogClose.displayName = CLOSE_NAME;
|
|
275
|
+
function getState(open) {
|
|
276
|
+
return open ? "open" : "closed";
|
|
309
277
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
278
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
279
|
+
var [WarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {
|
|
280
|
+
contentName: CONTENT_NAME,
|
|
281
|
+
titleName: TITLE_NAME,
|
|
282
|
+
docsSlug: "dialog"
|
|
315
283
|
});
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
284
|
+
var TitleWarning = ({ titleId }) => {
|
|
285
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
286
|
+
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
319
287
|
|
|
320
288
|
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
321
289
|
|
|
322
290
|
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
titleId
|
|
331
|
-
]);
|
|
332
|
-
return null;
|
|
291
|
+
React.useEffect(() => {
|
|
292
|
+
if (titleId) {
|
|
293
|
+
const hasTitle = document.getElementById(titleId);
|
|
294
|
+
if (!hasTitle) throw new Error(MESSAGE);
|
|
295
|
+
}
|
|
296
|
+
}, [MESSAGE, titleId]);
|
|
297
|
+
return null;
|
|
333
298
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
299
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
300
|
+
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
301
|
+
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
302
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
303
|
+
React.useEffect(() => {
|
|
304
|
+
const describedById = contentRef.current?.getAttribute("aria-describedby");
|
|
305
|
+
if (descriptionId && describedById) {
|
|
306
|
+
const hasDescription = document.getElementById(descriptionId);
|
|
307
|
+
if (!hasDescription) console.warn(MESSAGE);
|
|
308
|
+
}
|
|
309
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
310
|
+
return null;
|
|
311
|
+
};
|
|
312
|
+
var Root = Dialog;
|
|
313
|
+
var Trigger = DialogTrigger;
|
|
314
|
+
var Portal = DialogPortal;
|
|
315
|
+
var Overlay = DialogOverlay;
|
|
316
|
+
var Content = DialogContent;
|
|
317
|
+
var Title = DialogTitle;
|
|
318
|
+
var Description = DialogDescription;
|
|
319
|
+
var Close = DialogClose;
|
|
320
|
+
export {
|
|
321
|
+
Close,
|
|
322
|
+
Content,
|
|
323
|
+
Description,
|
|
324
|
+
Dialog,
|
|
325
|
+
DialogClose,
|
|
326
|
+
DialogContent,
|
|
327
|
+
DialogDescription,
|
|
328
|
+
DialogOverlay,
|
|
329
|
+
DialogPortal,
|
|
330
|
+
DialogTitle,
|
|
331
|
+
DialogTrigger,
|
|
332
|
+
Overlay,
|
|
333
|
+
Portal,
|
|
334
|
+
Root,
|
|
335
|
+
Title,
|
|
336
|
+
Trigger,
|
|
337
|
+
WarningProvider,
|
|
338
|
+
createDialogScope
|
|
351
339
|
};
|
|
352
|
-
const $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9 = $5d3850c4d0b4e6c7$export$3ddf2d174ce01153;
|
|
353
|
-
const $5d3850c4d0b4e6c7$export$41fb9f06171c75f4 = $5d3850c4d0b4e6c7$export$2e1e1122cf0cba88;
|
|
354
|
-
const $5d3850c4d0b4e6c7$export$602eac185826482c = $5d3850c4d0b4e6c7$export$dad7c95542bacce0;
|
|
355
|
-
const $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff = $5d3850c4d0b4e6c7$export$bd1d06c79be19e17;
|
|
356
|
-
const $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 = $5d3850c4d0b4e6c7$export$b6d9565de1e068cf;
|
|
357
|
-
const $5d3850c4d0b4e6c7$export$f99233281efd08a0 = $5d3850c4d0b4e6c7$export$16f7638e4a34b909;
|
|
358
|
-
const $5d3850c4d0b4e6c7$export$393edc798c47379d = $5d3850c4d0b4e6c7$export$94e94c2ec2c954d5;
|
|
359
|
-
const $5d3850c4d0b4e6c7$export$f39c2d165cd861fe = $5d3850c4d0b4e6c7$export$fba2fb7cd781b7ac;
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
export {$5d3850c4d0b4e6c7$export$cc702773b8ea3e41 as createDialogScope, $5d3850c4d0b4e6c7$export$3ddf2d174ce01153 as Dialog, $5d3850c4d0b4e6c7$export$2e1e1122cf0cba88 as DialogTrigger, $5d3850c4d0b4e6c7$export$dad7c95542bacce0 as DialogPortal, $5d3850c4d0b4e6c7$export$bd1d06c79be19e17 as DialogOverlay, $5d3850c4d0b4e6c7$export$b6d9565de1e068cf as DialogContent, $5d3850c4d0b4e6c7$export$16f7638e4a34b909 as DialogTitle, $5d3850c4d0b4e6c7$export$94e94c2ec2c954d5 as DialogDescription, $5d3850c4d0b4e6c7$export$fba2fb7cd781b7ac as DialogClose, $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9 as Root, $5d3850c4d0b4e6c7$export$41fb9f06171c75f4 as Trigger, $5d3850c4d0b4e6c7$export$602eac185826482c as Portal, $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff as Overlay, $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 as Content, $5d3850c4d0b4e6c7$export$f99233281efd08a0 as Title, $5d3850c4d0b4e6c7$export$393edc798c47379d as Description, $5d3850c4d0b4e6c7$export$f39c2d165cd861fe as Close, $5d3850c4d0b4e6c7$export$69b62a49393917d6 as WarningProvider};
|
|
365
340
|
//# sourceMappingURL=index.mjs.map
|