@tamagui/dialog 1.61.2 → 1.62.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/cjs/Dialog.js +113 -285
- package/dist/cjs/Dialog.js.map +2 -2
- package/dist/cjs/Dialog.native.js +508 -0
- package/dist/cjs/Dialog.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/Dialog.js +106 -257
- package/dist/esm/Dialog.js.map +2 -2
- package/dist/jsx/Dialog.js +101 -249
- package/dist/jsx/Dialog.js.map +2 -2
- package/dist/jsx/Dialog.native.js +443 -0
- package/dist/jsx/Dialog.native.js.map +6 -0
- package/dist/jsx/index.native.js +2 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/package.json +18 -18
- package/types/Dialog.d.ts +1 -0
- package/types/Dialog.d.ts.map +1 -1
package/dist/cjs/Dialog.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,10 +17,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var Dialog_exports = {};
|
|
30
24
|
__export(Dialog_exports, {
|
|
31
25
|
Dialog: () => Dialog,
|
|
@@ -43,34 +37,12 @@ __export(Dialog_exports, {
|
|
|
43
37
|
createDialogScope: () => createDialogScope
|
|
44
38
|
});
|
|
45
39
|
module.exports = __toCommonJS(Dialog_exports);
|
|
46
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
-
|
|
48
|
-
var import_animate_presence = require("@tamagui/animate-presence");
|
|
49
|
-
var import_aria_hidden = require("@tamagui/aria-hidden");
|
|
50
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
51
|
-
var import_core = require("@tamagui/core");
|
|
52
|
-
var import_create_context = require("@tamagui/create-context");
|
|
53
|
-
var import_dismissable = require("@tamagui/dismissable");
|
|
54
|
-
var import_focus_scope = require("@tamagui/focus-scope");
|
|
55
|
-
var import_portal = require("@tamagui/portal");
|
|
56
|
-
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
57
|
-
var import_sheet = require("@tamagui/sheet");
|
|
58
|
-
var import_stacks = require("@tamagui/stacks");
|
|
59
|
-
var import_text = require("@tamagui/text");
|
|
60
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
61
|
-
var React = __toESM(require("react"));
|
|
62
|
-
const DIALOG_NAME = "Dialog";
|
|
63
|
-
const [createDialogContext, createDialogScope] = (0, import_create_context.createContextScope)(DIALOG_NAME);
|
|
64
|
-
const [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
65
|
-
const TRIGGER_NAME = "DialogTrigger";
|
|
66
|
-
const DialogTriggerFrame = (0, import_core.styled)(import_core.View, {
|
|
40
|
+
var import_adapt = require("@tamagui/adapt"), import_animate_presence = require("@tamagui/animate-presence"), import_aria_hidden = require("@tamagui/aria-hidden"), import_compose_refs = require("@tamagui/compose-refs"), import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_dismissable = require("@tamagui/dismissable"), import_focus_scope = require("@tamagui/focus-scope"), import_portal = require("@tamagui/portal"), import_remove_scroll = require("@tamagui/remove-scroll"), import_sheet = require("@tamagui/sheet"), import_stacks = require("@tamagui/stacks"), import_text = require("@tamagui/text"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
const DIALOG_NAME = "Dialog", [createDialogContext, createDialogScope] = (0, import_create_context.createContextScope)(DIALOG_NAME), [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME), TRIGGER_NAME = "DialogTrigger", DialogTriggerFrame = (0, import_core.styled)(import_core.View, {
|
|
67
42
|
name: TRIGGER_NAME
|
|
68
|
-
})
|
|
69
|
-
const DialogTrigger = React.forwardRef(
|
|
43
|
+
}), DialogTrigger = React.forwardRef(
|
|
70
44
|
(props, forwardedRef) => {
|
|
71
|
-
const { __scopeDialog, ...triggerProps } = props;
|
|
72
|
-
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
73
|
-
const composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
45
|
+
const { __scopeDialog, ...triggerProps } = props, context = useDialogContext(TRIGGER_NAME, __scopeDialog), composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
74
46
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
47
|
DialogTriggerFrame,
|
|
76
48
|
{
|
|
@@ -87,20 +59,18 @@ const DialogTrigger = React.forwardRef(
|
|
|
87
59
|
}
|
|
88
60
|
);
|
|
89
61
|
DialogTrigger.displayName = TRIGGER_NAME;
|
|
90
|
-
const PORTAL_NAME = "DialogPortal"
|
|
91
|
-
const [PortalProvider, usePortalContext] = createDialogContext(
|
|
62
|
+
const PORTAL_NAME = "DialogPortal", [PortalProvider, usePortalContext] = createDialogContext(
|
|
92
63
|
PORTAL_NAME,
|
|
93
64
|
{
|
|
94
65
|
forceMount: void 0
|
|
95
66
|
}
|
|
96
|
-
)
|
|
97
|
-
const DialogPortalFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
67
|
+
), DialogPortalFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
98
68
|
variants: {
|
|
99
69
|
unstyled: {
|
|
100
70
|
false: {
|
|
101
71
|
alignItems: "center",
|
|
102
72
|
justifyContent: "center",
|
|
103
|
-
fullscreen:
|
|
73
|
+
fullscreen: !0,
|
|
104
74
|
zIndex: 1e5,
|
|
105
75
|
...import_core.isWeb && {
|
|
106
76
|
maxHeight: "100vh",
|
|
@@ -110,12 +80,10 @@ const DialogPortalFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
|
110
80
|
}
|
|
111
81
|
},
|
|
112
82
|
defaultVariants: {
|
|
113
|
-
unstyled:
|
|
83
|
+
unstyled: !1
|
|
114
84
|
}
|
|
115
|
-
})
|
|
116
|
-
const
|
|
117
|
-
const themeName = (0, import_core.useThemeName)();
|
|
118
|
-
const context = useDialogContext(PORTAL_NAME, props.__scopeDialog);
|
|
85
|
+
}), DialogPortalItem = (props) => {
|
|
86
|
+
const themeName = (0, import_core.useThemeName)(), context = useDialogContext(PORTAL_NAME, props.__scopeDialog);
|
|
119
87
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: props.hostName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalItemContent, { ...props, themeName, context }) });
|
|
120
88
|
};
|
|
121
89
|
function DialogPortalItemContent(props) {
|
|
@@ -129,63 +97,35 @@ function DialogPortalItemContent(props) {
|
|
|
129
97
|
separator
|
|
130
98
|
} = props;
|
|
131
99
|
let childrenSpaced = children;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogProvider, { scope: __scopeDialog, ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { name: themeName, children: childrenSpaced }) });
|
|
100
|
+
return (space || separator) && (childrenSpaced = (0, import_core.spacedChildren)({
|
|
101
|
+
children,
|
|
102
|
+
separator,
|
|
103
|
+
space,
|
|
104
|
+
direction: spaceDirection
|
|
105
|
+
})), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogProvider, { scope: __scopeDialog, ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { name: themeName, children: childrenSpaced }) });
|
|
141
106
|
}
|
|
142
107
|
const DialogPortal = (props) => {
|
|
143
|
-
const { __scopeDialog, forceMount, children, ...frameProps } = props;
|
|
144
|
-
|
|
145
|
-
const isShowing = forceMount || context.open;
|
|
146
|
-
const [isFullyHidden, setIsFullyHidden] = React.useState(!isShowing);
|
|
147
|
-
if (isShowing && isFullyHidden) {
|
|
148
|
-
setIsFullyHidden(false);
|
|
149
|
-
}
|
|
108
|
+
const { __scopeDialog, forceMount, children, ...frameProps } = props, context = useDialogContext(PORTAL_NAME, __scopeDialog), isShowing = forceMount || context.open, [isFullyHidden, setIsFullyHidden] = React.useState(!isShowing);
|
|
109
|
+
isShowing && isFullyHidden && setIsFullyHidden(!1);
|
|
150
110
|
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
111
|
import_animate_presence.AnimatePresence,
|
|
152
112
|
{
|
|
153
113
|
onExitComplete: () => {
|
|
154
|
-
setIsFullyHidden(
|
|
114
|
+
setIsFullyHidden(!0);
|
|
155
115
|
},
|
|
156
116
|
children: isShowing ? children : null
|
|
157
117
|
}
|
|
158
118
|
);
|
|
159
|
-
|
|
160
|
-
if (isSheet) {
|
|
161
|
-
return children;
|
|
162
|
-
}
|
|
163
|
-
if (context.modal) {
|
|
164
|
-
if (isFullyHidden) {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalItem, { __scopeDialog, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopeDialog, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalFrame, { pointerEvents: isShowing ? "auto" : "none", ...frameProps, children: contents }) }) });
|
|
168
|
-
}
|
|
169
|
-
return contents;
|
|
119
|
+
return useShowDialogSheet(context) ? children : context.modal ? isFullyHidden ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalItem, { __scopeDialog, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopeDialog, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalFrame, { pointerEvents: isShowing ? "auto" : "none", ...frameProps, children: contents }) }) }) : contents;
|
|
170
120
|
};
|
|
171
121
|
DialogPortal.displayName = PORTAL_NAME;
|
|
172
|
-
const OVERLAY_NAME = "DialogOverlay"
|
|
173
|
-
const DialogOverlayFrame = (0, import_core.styled)(import_sheet.Overlay, {
|
|
122
|
+
const OVERLAY_NAME = "DialogOverlay", DialogOverlayFrame = (0, import_core.styled)(import_sheet.Overlay, {
|
|
174
123
|
name: OVERLAY_NAME
|
|
175
|
-
})
|
|
176
|
-
const DialogOverlay = DialogOverlayFrame.extractable(
|
|
124
|
+
}), DialogOverlay = DialogOverlayFrame.extractable(
|
|
177
125
|
React.forwardRef(
|
|
178
126
|
({ __scopeDialog, ...props }, forwardedRef) => {
|
|
179
|
-
const portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog);
|
|
180
|
-
|
|
181
|
-
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
182
|
-
const showSheet = useShowDialogSheet(context);
|
|
183
|
-
if (!forceMount) {
|
|
184
|
-
if (!context.modal || showSheet) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogOverlayImpl, { context, ...overlayProps, ref: forwardedRef });
|
|
127
|
+
const portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...overlayProps } = props, context = useDialogContext(OVERLAY_NAME, __scopeDialog), showSheet = useShowDialogSheet(context);
|
|
128
|
+
return !forceMount && (!context.modal || showSheet) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogOverlayImpl, { context, ...overlayProps, ref: forwardedRef });
|
|
189
129
|
}
|
|
190
130
|
)
|
|
191
131
|
);
|
|
@@ -207,52 +147,41 @@ const DialogOverlayImpl = React.forwardRef(
|
|
|
207
147
|
)
|
|
208
148
|
);
|
|
209
149
|
}
|
|
210
|
-
)
|
|
211
|
-
const CONTENT_NAME = "DialogContent";
|
|
212
|
-
const DialogContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
150
|
+
), CONTENT_NAME = "DialogContent", DialogContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
213
151
|
name: CONTENT_NAME,
|
|
214
152
|
tag: "dialog",
|
|
215
153
|
variants: {
|
|
216
154
|
size: {
|
|
217
|
-
"...size": (val, extras) => {
|
|
218
|
-
return {};
|
|
219
|
-
}
|
|
155
|
+
"...size": (val, extras) => ({})
|
|
220
156
|
},
|
|
221
157
|
unstyled: {
|
|
222
158
|
false: {
|
|
223
159
|
position: "relative",
|
|
224
|
-
backgrounded:
|
|
225
|
-
padded:
|
|
226
|
-
radiused:
|
|
227
|
-
elevate:
|
|
160
|
+
backgrounded: !0,
|
|
161
|
+
padded: !0,
|
|
162
|
+
radiused: !0,
|
|
163
|
+
elevate: !0,
|
|
228
164
|
zIndex: 1e5
|
|
229
165
|
}
|
|
230
166
|
}
|
|
231
167
|
},
|
|
232
168
|
defaultVariants: {
|
|
233
169
|
size: "$true",
|
|
234
|
-
unstyled:
|
|
170
|
+
unstyled: !1
|
|
235
171
|
}
|
|
236
|
-
})
|
|
237
|
-
const DialogContent = DialogContentFrame.extractable(
|
|
172
|
+
}), DialogContent = DialogContentFrame.extractable(
|
|
238
173
|
React.forwardRef(
|
|
239
174
|
({ __scopeDialog, ...props }, forwardedRef) => {
|
|
240
|
-
const portalContext = usePortalContext(CONTENT_NAME, __scopeDialog);
|
|
241
|
-
|
|
242
|
-
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
243
|
-
const contents = context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentModal, { context, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentNonModal, { context, ...contentProps, ref: forwardedRef });
|
|
244
|
-
if (!import_core.isWeb || context.disableRemoveScroll) {
|
|
245
|
-
return contents;
|
|
246
|
-
}
|
|
247
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
175
|
+
const portalContext = usePortalContext(CONTENT_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...contentProps } = props, context = useDialogContext(CONTENT_NAME, __scopeDialog), contents = context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentModal, { context, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentNonModal, { context, ...contentProps, ref: forwardedRef });
|
|
176
|
+
return !import_core.isWeb || context.disableRemoveScroll ? contents : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
248
177
|
import_remove_scroll.RemoveScroll,
|
|
249
178
|
{
|
|
250
|
-
forwardProps:
|
|
179
|
+
forwardProps: !0,
|
|
251
180
|
enabled: context.open,
|
|
252
181
|
allowPinchZoom: context.allowPinchZoom,
|
|
253
182
|
shards: [context.contentRef],
|
|
254
|
-
removeScrollBar:
|
|
255
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-remove-scroll-container":
|
|
183
|
+
removeScrollBar: !1,
|
|
184
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-remove-scroll-container": !0, className: "_dsp_contents", children: contents })
|
|
256
185
|
}
|
|
257
186
|
);
|
|
258
187
|
}
|
|
@@ -261,37 +190,28 @@ const DialogContent = DialogContentFrame.extractable(
|
|
|
261
190
|
DialogContent.displayName = CONTENT_NAME;
|
|
262
191
|
const DialogContentModal = React.forwardRef(
|
|
263
192
|
({ children, context, ...props }, forwardedRef) => {
|
|
264
|
-
const contentRef = React.useRef(null);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return (0, import_aria_hidden.hideOthers)(content);
|
|
273
|
-
}, [context.open]);
|
|
274
|
-
}
|
|
275
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
+
const contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.contentRef, contentRef);
|
|
194
|
+
return import_core.isWeb && React.useEffect(() => {
|
|
195
|
+
if (!context.open)
|
|
196
|
+
return;
|
|
197
|
+
const content = contentRef.current;
|
|
198
|
+
if (content)
|
|
199
|
+
return (0, import_aria_hidden.hideOthers)(content);
|
|
200
|
+
}, [context.open]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
276
201
|
DialogContentImpl,
|
|
277
202
|
{
|
|
278
203
|
...props,
|
|
279
204
|
context,
|
|
280
205
|
ref: composedRefs,
|
|
281
|
-
disableOutsidePointerEvents:
|
|
206
|
+
disableOutsidePointerEvents: !0,
|
|
282
207
|
onCloseAutoFocus: (0, import_core.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
283
|
-
|
|
284
|
-
event.preventDefault();
|
|
285
|
-
(_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
208
|
+
event.preventDefault(), context.triggerRef.current?.focus();
|
|
286
209
|
}),
|
|
287
210
|
onPointerDownOutside: (0, import_core.composeEventHandlers)(
|
|
288
211
|
props.onPointerDownOutside,
|
|
289
212
|
(event) => {
|
|
290
|
-
const originalEvent = event
|
|
291
|
-
|
|
292
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
293
|
-
if (isRightClick)
|
|
294
|
-
event.preventDefault();
|
|
213
|
+
const originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0;
|
|
214
|
+
(originalEvent.button === 2 || ctrlLeftClick) && event.preventDefault();
|
|
295
215
|
}
|
|
296
216
|
),
|
|
297
217
|
onFocusOutside: (0, import_core.composeEventHandlers)(
|
|
@@ -302,46 +222,30 @@ const DialogContentModal = React.forwardRef(
|
|
|
302
222
|
}
|
|
303
223
|
);
|
|
304
224
|
}
|
|
305
|
-
)
|
|
306
|
-
const DialogContentNonModal = React.forwardRef(
|
|
225
|
+
), DialogContentNonModal = React.forwardRef(
|
|
307
226
|
(props, forwardedRef) => {
|
|
308
|
-
const hasInteractedOutsideRef = React.useRef(
|
|
227
|
+
const hasInteractedOutsideRef = React.useRef(!1);
|
|
309
228
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
310
229
|
DialogContentImpl,
|
|
311
230
|
{
|
|
312
231
|
...props,
|
|
313
232
|
ref: forwardedRef,
|
|
314
|
-
trapFocus:
|
|
315
|
-
disableOutsidePointerEvents:
|
|
233
|
+
trapFocus: !1,
|
|
234
|
+
disableOutsidePointerEvents: !1,
|
|
316
235
|
onCloseAutoFocus: (event) => {
|
|
317
|
-
|
|
318
|
-
(_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
|
|
319
|
-
if (!event.defaultPrevented) {
|
|
320
|
-
if (!hasInteractedOutsideRef.current) {
|
|
321
|
-
(_b = props.context.triggerRef.current) == null ? void 0 : _b.focus();
|
|
322
|
-
}
|
|
323
|
-
event.preventDefault();
|
|
324
|
-
}
|
|
325
|
-
hasInteractedOutsideRef.current = false;
|
|
236
|
+
props.onCloseAutoFocus?.(event), event.defaultPrevented || (hasInteractedOutsideRef.current || props.context.triggerRef.current?.focus(), event.preventDefault()), hasInteractedOutsideRef.current = !1;
|
|
326
237
|
},
|
|
327
238
|
onInteractOutside: (event) => {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (!event.defaultPrevented)
|
|
331
|
-
hasInteractedOutsideRef.current = true;
|
|
332
|
-
const target = event.target;
|
|
333
|
-
const trigger = props.context.triggerRef.current;
|
|
239
|
+
props.onInteractOutside?.(event), event.defaultPrevented || (hasInteractedOutsideRef.current = !0);
|
|
240
|
+
const target = event.target, trigger = props.context.triggerRef.current;
|
|
334
241
|
if (!(trigger instanceof HTMLElement))
|
|
335
242
|
return;
|
|
336
|
-
|
|
337
|
-
if (targetIsTrigger)
|
|
338
|
-
event.preventDefault();
|
|
243
|
+
trigger.contains(target) && event.preventDefault();
|
|
339
244
|
}
|
|
340
245
|
}
|
|
341
246
|
);
|
|
342
247
|
}
|
|
343
|
-
)
|
|
344
|
-
const DialogContentImpl = React.forwardRef(
|
|
248
|
+
), DialogContentImpl = React.forwardRef(
|
|
345
249
|
(props, forwardedRef) => {
|
|
346
250
|
const {
|
|
347
251
|
__scopeDialog,
|
|
@@ -355,11 +259,7 @@ const DialogContentImpl = React.forwardRef(
|
|
|
355
259
|
onInteractOutside,
|
|
356
260
|
context,
|
|
357
261
|
...contentProps
|
|
358
|
-
} = props
|
|
359
|
-
const contentRef = React.useRef(null);
|
|
360
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
361
|
-
const showSheet = useShowDialogSheet(context);
|
|
362
|
-
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
262
|
+
} = props, contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef), showSheet = useShowDialogSheet(context), contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
363
263
|
DialogContentFrame,
|
|
364
264
|
{
|
|
365
265
|
id: context.contentId,
|
|
@@ -369,17 +269,11 @@ const DialogContentImpl = React.forwardRef(
|
|
|
369
269
|
...contentProps
|
|
370
270
|
}
|
|
371
271
|
);
|
|
372
|
-
|
|
373
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalItem, { hostName: getSheetContentsName(context), children: contentProps.children });
|
|
374
|
-
}
|
|
375
|
-
if (!import_core.isWeb) {
|
|
376
|
-
return contents;
|
|
377
|
-
}
|
|
378
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
272
|
+
return showSheet ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalItem, { hostName: getSheetContentsName(context), children: contentProps.children }) : import_core.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
379
273
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
380
274
|
import_focus_scope.FocusScope,
|
|
381
275
|
{
|
|
382
|
-
loop:
|
|
276
|
+
loop: !0,
|
|
383
277
|
enabled: context.open,
|
|
384
278
|
trapped: trapFocus,
|
|
385
279
|
onMountAutoFocus: onOpenAutoFocus,
|
|
@@ -395,7 +289,7 @@ const DialogContentImpl = React.forwardRef(
|
|
|
395
289
|
onFocusOutside,
|
|
396
290
|
onInteractOutside,
|
|
397
291
|
ref: composedRefs,
|
|
398
|
-
onDismiss: () => context.onOpenChange(
|
|
292
|
+
onDismiss: () => context.onOpenChange(!1),
|
|
399
293
|
children: contents
|
|
400
294
|
}
|
|
401
295
|
)
|
|
@@ -411,28 +305,21 @@ const DialogContentImpl = React.forwardRef(
|
|
|
411
305
|
}
|
|
412
306
|
)
|
|
413
307
|
] })
|
|
414
|
-
] });
|
|
308
|
+
] }) : contents;
|
|
415
309
|
}
|
|
416
|
-
)
|
|
417
|
-
const TITLE_NAME = "DialogTitle";
|
|
418
|
-
const DialogTitleFrame = (0, import_core.styled)(import_text.H2, {
|
|
310
|
+
), TITLE_NAME = "DialogTitle", DialogTitleFrame = (0, import_core.styled)(import_text.H2, {
|
|
419
311
|
name: TITLE_NAME
|
|
420
|
-
})
|
|
421
|
-
const DialogTitle = React.forwardRef(
|
|
312
|
+
}), DialogTitle = React.forwardRef(
|
|
422
313
|
(props, forwardedRef) => {
|
|
423
|
-
const { __scopeDialog, ...titleProps } = props;
|
|
424
|
-
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
314
|
+
const { __scopeDialog, ...titleProps } = props, context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
425
315
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitleFrame, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
426
316
|
}
|
|
427
317
|
);
|
|
428
318
|
DialogTitle.displayName = TITLE_NAME;
|
|
429
319
|
const DialogDescriptionFrame = (0, import_core.styled)(import_text.Paragraph, {
|
|
430
320
|
name: "DialogDescription"
|
|
431
|
-
})
|
|
432
|
-
const
|
|
433
|
-
const DialogDescription = React.forwardRef((props, forwardedRef) => {
|
|
434
|
-
const { __scopeDialog, ...descriptionProps } = props;
|
|
435
|
-
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
321
|
+
}), DESCRIPTION_NAME = "DialogDescription", DialogDescription = React.forwardRef((props, forwardedRef) => {
|
|
322
|
+
const { __scopeDialog, ...descriptionProps } = props, context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
436
323
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
437
324
|
DialogDescriptionFrame,
|
|
438
325
|
{
|
|
@@ -443,8 +330,7 @@ const DialogDescription = React.forwardRef((props, forwardedRef) => {
|
|
|
443
330
|
);
|
|
444
331
|
});
|
|
445
332
|
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
446
|
-
const CLOSE_NAME = "DialogClose"
|
|
447
|
-
const DialogCloseFrame = (0, import_core.styled)(import_core.View, {
|
|
333
|
+
const CLOSE_NAME = "DialogClose", DialogCloseFrame = (0, import_core.styled)(import_core.View, {
|
|
448
334
|
name: CLOSE_NAME,
|
|
449
335
|
tag: "button",
|
|
450
336
|
variants: {
|
|
@@ -455,21 +341,15 @@ const DialogCloseFrame = (0, import_core.styled)(import_core.View, {
|
|
|
455
341
|
}
|
|
456
342
|
},
|
|
457
343
|
defaultVariants: {
|
|
458
|
-
unstyled:
|
|
344
|
+
unstyled: !1
|
|
459
345
|
}
|
|
460
|
-
})
|
|
461
|
-
const DialogClose = DialogCloseFrame.styleable(
|
|
346
|
+
}), DialogClose = DialogCloseFrame.styleable(
|
|
462
347
|
(props, forwardedRef) => {
|
|
463
|
-
const { __scopeDialog, displayWhenAdapted, ...closeProps } = props
|
|
464
|
-
|
|
465
|
-
warn: false,
|
|
348
|
+
const { __scopeDialog, displayWhenAdapted, ...closeProps } = props, context = useDialogContext(CLOSE_NAME, __scopeDialog, {
|
|
349
|
+
warn: !1,
|
|
466
350
|
fallback: {}
|
|
467
351
|
});
|
|
468
|
-
|
|
469
|
-
if (isSheet && !displayWhenAdapted) {
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
352
|
+
return useShowDialogSheet(context) && !displayWhenAdapted ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
473
353
|
DialogCloseFrame,
|
|
474
354
|
{
|
|
475
355
|
accessibilityLabel: "Dialog Close",
|
|
@@ -477,7 +357,7 @@ const DialogClose = DialogCloseFrame.styleable(
|
|
|
477
357
|
ref: forwardedRef,
|
|
478
358
|
onPress: (0, import_core.composeEventHandlers)(
|
|
479
359
|
props.onPress,
|
|
480
|
-
() => context.onOpenChange(
|
|
360
|
+
() => context.onOpenChange(!1)
|
|
481
361
|
)
|
|
482
362
|
}
|
|
483
363
|
);
|
|
@@ -486,87 +366,55 @@ const DialogClose = DialogCloseFrame.styleable(
|
|
|
486
366
|
function getState(open) {
|
|
487
367
|
return open ? "open" : "closed";
|
|
488
368
|
}
|
|
489
|
-
const TITLE_WARNING_NAME = "DialogTitleWarning"
|
|
490
|
-
const [DialogWarningProvider, useWarningContext] = (0, import_create_context.createContext)(TITLE_WARNING_NAME, {
|
|
369
|
+
const TITLE_WARNING_NAME = "DialogTitleWarning", [DialogWarningProvider, useWarningContext] = (0, import_create_context.createContext)(TITLE_WARNING_NAME, {
|
|
491
370
|
contentName: CONTENT_NAME,
|
|
492
371
|
titleName: TITLE_NAME,
|
|
493
372
|
docsSlug: "dialog"
|
|
494
|
-
})
|
|
495
|
-
const TitleWarning = ({ titleId }) => {
|
|
373
|
+
}), TitleWarning = ({ titleId }) => {
|
|
496
374
|
if (process.env.NODE_ENV === "development") {
|
|
497
|
-
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME)
|
|
498
|
-
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
375
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME), MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
499
376
|
|
|
500
377
|
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.`;
|
|
501
378
|
React.useEffect(() => {
|
|
502
|
-
|
|
503
|
-
return;
|
|
504
|
-
if (titleId) {
|
|
505
|
-
const hasTitle = document.getElementById(titleId);
|
|
506
|
-
if (!hasTitle) {
|
|
507
|
-
console.warn(MESSAGE);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
379
|
+
import_core.isWeb && titleId && (document.getElementById(titleId) || console.warn(MESSAGE));
|
|
510
380
|
}, [MESSAGE, titleId]);
|
|
511
381
|
}
|
|
512
382
|
return null;
|
|
513
|
-
}
|
|
514
|
-
const DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
515
|
-
const DescriptionWarning = ({
|
|
383
|
+
}, DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning", DescriptionWarning = ({
|
|
516
384
|
contentRef,
|
|
517
385
|
descriptionId
|
|
518
386
|
}) => {
|
|
519
387
|
if (process.env.NODE_ENV === "development") {
|
|
520
|
-
const
|
|
521
|
-
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
388
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${useWarningContext(DESCRIPTION_WARNING_NAME).contentName}}.`;
|
|
522
389
|
React.useEffect(() => {
|
|
523
390
|
if (!import_core.isWeb)
|
|
524
391
|
return;
|
|
525
392
|
const contentNode = contentRef.current;
|
|
526
|
-
if (!(contentNode instanceof HTMLElement))
|
|
393
|
+
if (!(contentNode instanceof HTMLElement))
|
|
527
394
|
return;
|
|
528
|
-
}
|
|
529
395
|
const describedById = contentNode.getAttribute("aria-describedby");
|
|
530
|
-
|
|
531
|
-
const hasDescription = document.getElementById(descriptionId);
|
|
532
|
-
if (!hasDescription) {
|
|
533
|
-
console.warn(MESSAGE);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
396
|
+
descriptionId && describedById && (document.getElementById(descriptionId) || console.warn(MESSAGE));
|
|
536
397
|
}, [MESSAGE, contentRef, descriptionId]);
|
|
537
398
|
}
|
|
538
399
|
return null;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
React.forwardRef(function Dialog2(props, ref) {
|
|
400
|
+
}, Dialog = (0, import_core.withStaticProperties)(
|
|
401
|
+
React.forwardRef(function(props, ref) {
|
|
542
402
|
const {
|
|
543
403
|
__scopeDialog,
|
|
544
404
|
children,
|
|
545
405
|
open: openProp,
|
|
546
|
-
defaultOpen =
|
|
406
|
+
defaultOpen = !1,
|
|
547
407
|
onOpenChange,
|
|
548
|
-
modal =
|
|
549
|
-
allowPinchZoom =
|
|
550
|
-
disableRemoveScroll =
|
|
551
|
-
} = props
|
|
552
|
-
const baseId = React.useId();
|
|
553
|
-
const scopeId = `scope-${baseId}`;
|
|
554
|
-
const contentId = `content-${baseId}`;
|
|
555
|
-
const titleId = `title-${baseId}`;
|
|
556
|
-
const descriptionId = `description-${baseId}`;
|
|
557
|
-
const scopeKey = __scopeDialog ? Object.keys(__scopeDialog)[0] : scopeId;
|
|
558
|
-
const sheetContentsName = getSheetContentsName({ scopeKey, contentId });
|
|
559
|
-
const triggerRef = React.useRef(null);
|
|
560
|
-
const contentRef = React.useRef(null);
|
|
561
|
-
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
408
|
+
modal = !0,
|
|
409
|
+
allowPinchZoom = !1,
|
|
410
|
+
disableRemoveScroll = !1
|
|
411
|
+
} = props, baseId = React.useId(), scopeId = `scope-${baseId}`, contentId = `content-${baseId}`, titleId = `title-${baseId}`, descriptionId = `description-${baseId}`, scopeKey = __scopeDialog ? Object.keys(__scopeDialog)[0] : scopeId, sheetContentsName = getSheetContentsName({ scopeKey, contentId }), triggerRef = React.useRef(null), contentRef = React.useRef(null), [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
562
412
|
prop: openProp,
|
|
563
413
|
defaultProp: defaultOpen,
|
|
564
414
|
onChange: onOpenChange
|
|
565
|
-
})
|
|
566
|
-
const onOpenToggle = React.useCallback(() => {
|
|
415
|
+
}), onOpenToggle = React.useCallback(() => {
|
|
567
416
|
setOpen((prevOpen) => !prevOpen);
|
|
568
|
-
}, [setOpen])
|
|
569
|
-
const context = {
|
|
417
|
+
}, [setOpen]), context = {
|
|
570
418
|
scope: __scopeDialog,
|
|
571
419
|
scopeKey,
|
|
572
420
|
triggerRef,
|
|
@@ -579,23 +427,19 @@ const Dialog = (0, import_core.withStaticProperties)(
|
|
|
579
427
|
onOpenToggle,
|
|
580
428
|
modal,
|
|
581
429
|
allowPinchZoom
|
|
582
|
-
}
|
|
583
|
-
const { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
|
|
430
|
+
}, { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
|
|
584
431
|
Contents: React.useCallback(
|
|
585
|
-
(props2) => {
|
|
586
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { forwardProps: props2, name: sheetContentsName });
|
|
587
|
-
},
|
|
432
|
+
(props2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { forwardProps: props2, name: sheetContentsName }),
|
|
588
433
|
[sheetContentsName]
|
|
589
434
|
)
|
|
590
435
|
});
|
|
591
|
-
React.useImperativeHandle(
|
|
436
|
+
return React.useImperativeHandle(
|
|
592
437
|
ref,
|
|
593
438
|
() => ({
|
|
594
439
|
open: setOpen
|
|
595
440
|
}),
|
|
596
441
|
[setOpen]
|
|
597
|
-
)
|
|
598
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
442
|
+
), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
599
443
|
DialogProvider,
|
|
600
444
|
{
|
|
601
445
|
...context,
|
|
@@ -616,49 +460,33 @@ const Dialog = (0, import_core.withStaticProperties)(
|
|
|
616
460
|
Sheet: import_sheet.Sheet.Controlled,
|
|
617
461
|
Adapt: import_adapt.Adapt
|
|
618
462
|
}
|
|
619
|
-
)
|
|
620
|
-
const SHEET_CONTENTS_NAME = "DialogSheetContents";
|
|
621
|
-
const DialogSheetContents = ({
|
|
463
|
+
), SHEET_CONTENTS_NAME = "DialogSheetContents", DialogSheetContents = ({
|
|
622
464
|
name,
|
|
623
465
|
...props
|
|
624
|
-
}) => {
|
|
625
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { forwardProps: props, name });
|
|
626
|
-
};
|
|
466
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { forwardProps: props, name });
|
|
627
467
|
DialogSheetContents.displayName = SHEET_CONTENTS_NAME;
|
|
628
468
|
const getSheetContentsName = ({
|
|
629
469
|
scopeKey,
|
|
630
470
|
contentId
|
|
631
|
-
}) => `${scopeKey || contentId}SheetContents
|
|
632
|
-
const
|
|
633
|
-
const context = useDialogContext("DialogSheetController", props.__scopeDialog);
|
|
634
|
-
const showSheet = useShowDialogSheet(context);
|
|
635
|
-
const breakpointActive = useSheetBreakpointActive(context);
|
|
636
|
-
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
471
|
+
}) => `${scopeKey || contentId}SheetContents`, DialogSheetController = (props) => {
|
|
472
|
+
const context = useDialogContext("DialogSheetController", props.__scopeDialog), showSheet = useShowDialogSheet(context), breakpointActive = useSheetBreakpointActive(context), getShowSheet = (0, import_core.useGet)(showSheet);
|
|
637
473
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
638
474
|
import_sheet.SheetController,
|
|
639
475
|
{
|
|
640
476
|
onOpenChange: (val) => {
|
|
641
|
-
|
|
642
|
-
props.onOpenChange(val);
|
|
643
|
-
}
|
|
477
|
+
getShowSheet() && props.onOpenChange(val);
|
|
644
478
|
},
|
|
645
479
|
open: context.open,
|
|
646
|
-
hidden: breakpointActive ===
|
|
480
|
+
hidden: breakpointActive === !1,
|
|
647
481
|
children: props.children
|
|
648
482
|
}
|
|
649
483
|
);
|
|
650
|
-
}
|
|
651
|
-
const useSheetBreakpointActive = (context) => {
|
|
484
|
+
}, useSheetBreakpointActive = (context) => {
|
|
652
485
|
const media = (0, import_core.useMedia)();
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
if (context.sheetBreakpoint === true)
|
|
656
|
-
return true;
|
|
657
|
-
return media[context.sheetBreakpoint];
|
|
658
|
-
};
|
|
659
|
-
const useShowDialogSheet = (context) => {
|
|
486
|
+
return context.sheetBreakpoint ? context.sheetBreakpoint === !0 ? !0 : media[context.sheetBreakpoint] : !1;
|
|
487
|
+
}, useShowDialogSheet = (context) => {
|
|
660
488
|
const breakpointActive = useSheetBreakpointActive(context);
|
|
661
|
-
return context.open ===
|
|
489
|
+
return context.open === !1 ? !1 : breakpointActive;
|
|
662
490
|
};
|
|
663
491
|
// Annotate the CommonJS export names for ESM import in node:
|
|
664
492
|
0 && (module.exports = {
|