@tamagui/dialog 1.0.1-beta.149 → 1.0.1-beta.152
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 +302 -239
- package/dist/cjs/Dialog.js.map +2 -2
- package/dist/esm/Dialog.js +298 -238
- package/dist/esm/Dialog.js.map +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/Dialog.js +163 -132
- package/dist/jsx/Dialog.js.map +2 -2
- package/dist/jsx/index.js.map +1 -1
- package/package.json +17 -17
package/dist/cjs/Dialog.js
CHANGED
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var Dialog_exports = {};
|
|
23
26
|
__export(Dialog_exports, {
|
|
@@ -35,6 +38,7 @@ __export(Dialog_exports, {
|
|
|
35
38
|
createDialogScope: () => createDialogScope
|
|
36
39
|
});
|
|
37
40
|
module.exports = __toCommonJS(Dialog_exports);
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
42
|
var import_animate_presence = require("@tamagui/animate-presence");
|
|
39
43
|
var import_aria_hidden = require("@tamagui/aria-hidden");
|
|
40
44
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
@@ -56,21 +60,23 @@ const TRIGGER_NAME = "DialogTrigger";
|
|
|
56
60
|
const DialogTriggerFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
57
61
|
name: TRIGGER_NAME
|
|
58
62
|
});
|
|
59
|
-
const DialogTrigger = React.forwardRef(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
63
|
+
const DialogTrigger = React.forwardRef(
|
|
64
|
+
(props, forwardedRef) => {
|
|
65
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
66
|
+
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
67
|
+
const composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTriggerFrame, {
|
|
69
|
+
tag: "button",
|
|
70
|
+
"aria-haspopup": "dialog",
|
|
71
|
+
"aria-expanded": context.open,
|
|
72
|
+
"aria-controls": context.contentId,
|
|
73
|
+
"data-state": getState(context.open),
|
|
74
|
+
...triggerProps,
|
|
75
|
+
ref: composedTriggerRef,
|
|
76
|
+
onPress: (0, import_core.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
);
|
|
74
80
|
DialogTrigger.displayName = TRIGGER_NAME;
|
|
75
81
|
const PORTAL_NAME = "DialogPortal";
|
|
76
82
|
const [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
@@ -85,29 +91,39 @@ const DialogPortalFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
|
85
91
|
maxHeight: "100vh"
|
|
86
92
|
}
|
|
87
93
|
});
|
|
88
|
-
const DialogPortal = DialogPortalFrame.extractable(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const DialogPortal = DialogPortalFrame.extractable(
|
|
95
|
+
(props) => {
|
|
96
|
+
const { __scopeDialog, forceMount, children, ...frameProps } = props;
|
|
97
|
+
const themeName = (0, import_core.useThemeName)();
|
|
98
|
+
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
99
|
+
const isShowing = forceMount || context.open;
|
|
100
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
|
|
101
|
+
children: isShowing ? children : null
|
|
102
|
+
});
|
|
103
|
+
const isSheet = useShowDialogSheet(context);
|
|
104
|
+
if (!context.modal || isSheet) {
|
|
105
|
+
return contents;
|
|
106
|
+
}
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
108
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogProvider, {
|
|
109
|
+
scope: __scopeDialog,
|
|
110
|
+
...context,
|
|
111
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
112
|
+
name: themeName,
|
|
113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, {
|
|
114
|
+
scope: __scopeDialog,
|
|
115
|
+
forceMount,
|
|
116
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalFrame, {
|
|
117
|
+
pointerEvents: isShowing ? "auto" : "none",
|
|
118
|
+
...frameProps,
|
|
119
|
+
children: contents
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
});
|
|
97
125
|
}
|
|
98
|
-
|
|
99
|
-
scope: __scopeDialog,
|
|
100
|
-
...context
|
|
101
|
-
}, /* @__PURE__ */ React.createElement(import_core.Theme, {
|
|
102
|
-
name: themeName
|
|
103
|
-
}, /* @__PURE__ */ React.createElement(PortalProvider, {
|
|
104
|
-
scope: __scopeDialog,
|
|
105
|
-
forceMount
|
|
106
|
-
}, /* @__PURE__ */ React.createElement(DialogPortalFrame, {
|
|
107
|
-
pointerEvents: isShowing ? "auto" : "none",
|
|
108
|
-
...frameProps
|
|
109
|
-
}, contents)))));
|
|
110
|
-
});
|
|
126
|
+
);
|
|
111
127
|
DialogPortal.displayName = PORTAL_NAME;
|
|
112
128
|
const OVERLAY_NAME = "DialogOverlay";
|
|
113
129
|
const DialogOverlayFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
@@ -115,38 +131,43 @@ const DialogOverlayFrame = (0, import_core.styled)(import_stacks.ThemeableStack,
|
|
|
115
131
|
backgrounded: true,
|
|
116
132
|
fullscreen: true
|
|
117
133
|
});
|
|
118
|
-
const DialogOverlay = React.forwardRef(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!
|
|
125
|
-
|
|
134
|
+
const DialogOverlay = React.forwardRef(
|
|
135
|
+
({ __scopeDialog, ...props }, forwardedRef) => {
|
|
136
|
+
const portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog);
|
|
137
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
138
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
139
|
+
const showSheet = useShowDialogSheet(context);
|
|
140
|
+
if (!forceMount) {
|
|
141
|
+
if (!context.modal || showSheet) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
126
144
|
}
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogOverlayImpl, {
|
|
146
|
+
context,
|
|
147
|
+
...overlayProps,
|
|
148
|
+
ref: forwardedRef
|
|
149
|
+
});
|
|
127
150
|
}
|
|
128
|
-
|
|
129
|
-
context,
|
|
130
|
-
...overlayProps,
|
|
131
|
-
ref: forwardedRef
|
|
132
|
-
});
|
|
133
|
-
});
|
|
151
|
+
);
|
|
134
152
|
DialogOverlay.displayName = OVERLAY_NAME;
|
|
135
|
-
const DialogOverlayImpl = React.forwardRef(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
153
|
+
const DialogOverlayImpl = React.forwardRef(
|
|
154
|
+
(props, forwardedRef) => {
|
|
155
|
+
const { context, ...overlayProps } = props;
|
|
156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_remove_scroll.RemoveScroll, {
|
|
157
|
+
enabled: context.open,
|
|
158
|
+
as: import_core.Slot,
|
|
159
|
+
allowPinchZoom: context.allowPinchZoom,
|
|
160
|
+
shards: [context.contentRef],
|
|
161
|
+
removeScrollBar: false,
|
|
162
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogOverlayFrame, {
|
|
163
|
+
"data-state": getState(context.open),
|
|
164
|
+
pointerEvents: context.open ? "auto" : "none",
|
|
165
|
+
...overlayProps,
|
|
166
|
+
ref: forwardedRef
|
|
167
|
+
})
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
);
|
|
150
171
|
const CONTENT_NAME = "DialogContent";
|
|
151
172
|
const DialogContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
152
173
|
name: CONTENT_NAME,
|
|
@@ -167,144 +188,173 @@ const DialogContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack,
|
|
|
167
188
|
size: "$4"
|
|
168
189
|
}
|
|
169
190
|
});
|
|
170
|
-
const DialogContent = DialogContentFrame.extractable(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
const DialogContent = DialogContentFrame.extractable(
|
|
192
|
+
React.forwardRef(
|
|
193
|
+
({ __scopeDialog, ...props }, forwardedRef) => {
|
|
194
|
+
const portalContext = usePortalContext(CONTENT_NAME, __scopeDialog);
|
|
195
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
196
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
198
|
+
children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentModal, {
|
|
199
|
+
context,
|
|
200
|
+
...contentProps,
|
|
201
|
+
ref: forwardedRef
|
|
202
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentNonModal, {
|
|
203
|
+
context,
|
|
204
|
+
...contentProps,
|
|
205
|
+
ref: forwardedRef
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
);
|
|
184
211
|
DialogContent.displayName = CONTENT_NAME;
|
|
185
|
-
const DialogContentModal = React.forwardRef(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
(_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
205
|
-
}),
|
|
206
|
-
onPointerDownOutside: (0, import_core.composeEventHandlers)(props.onPointerDownOutside, (event) => {
|
|
207
|
-
const originalEvent = event["detail"].originalEvent;
|
|
208
|
-
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
209
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
210
|
-
if (isRightClick)
|
|
212
|
+
const DialogContentModal = React.forwardRef(
|
|
213
|
+
({ children, context, ...props }, forwardedRef) => {
|
|
214
|
+
const contentRef = React.useRef(null);
|
|
215
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.contentRef, contentRef);
|
|
216
|
+
React.useEffect(() => {
|
|
217
|
+
if (!context.open)
|
|
218
|
+
return;
|
|
219
|
+
const content = contentRef.current;
|
|
220
|
+
if (content)
|
|
221
|
+
return (0, import_aria_hidden.hideOthers)(content);
|
|
222
|
+
}, [context.open]);
|
|
223
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentImpl, {
|
|
224
|
+
...props,
|
|
225
|
+
context,
|
|
226
|
+
ref: composedRefs,
|
|
227
|
+
trapFocus: context.open,
|
|
228
|
+
disableOutsidePointerEvents: true,
|
|
229
|
+
onCloseAutoFocus: (0, import_core.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
230
|
+
var _a;
|
|
211
231
|
event.preventDefault();
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
(_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
233
|
+
}),
|
|
234
|
+
onPointerDownOutside: (0, import_core.composeEventHandlers)(props.onPointerDownOutside, (event) => {
|
|
235
|
+
const originalEvent = event["detail"].originalEvent;
|
|
236
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
237
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
238
|
+
if (isRightClick)
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
}),
|
|
241
|
+
onFocusOutside: (0, import_core.composeEventHandlers)(
|
|
242
|
+
props.onFocusOutside,
|
|
243
|
+
(event) => event.preventDefault()
|
|
244
|
+
),
|
|
245
|
+
children
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
const DialogContentNonModal = React.forwardRef(
|
|
250
|
+
(props, forwardedRef) => {
|
|
251
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentImpl, {
|
|
253
|
+
...props,
|
|
254
|
+
ref: forwardedRef,
|
|
255
|
+
trapFocus: false,
|
|
256
|
+
disableOutsidePointerEvents: false,
|
|
257
|
+
onCloseAutoFocus: (event) => {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
console.log("on close autofocus");
|
|
260
|
+
(_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
|
|
261
|
+
if (!event.defaultPrevented) {
|
|
262
|
+
if (!hasInteractedOutsideRef.current) {
|
|
263
|
+
(_b = props.context.triggerRef.current) == null ? void 0 : _b.focus();
|
|
264
|
+
}
|
|
265
|
+
event.preventDefault();
|
|
230
266
|
}
|
|
231
|
-
|
|
267
|
+
hasInteractedOutsideRef.current = false;
|
|
268
|
+
},
|
|
269
|
+
onInteractOutside: (event) => {
|
|
270
|
+
var _a;
|
|
271
|
+
(_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
|
|
272
|
+
if (!event.defaultPrevented)
|
|
273
|
+
hasInteractedOutsideRef.current = true;
|
|
274
|
+
const target = event.target;
|
|
275
|
+
const trigger = props.context.triggerRef.current;
|
|
276
|
+
if (!(trigger instanceof HTMLElement))
|
|
277
|
+
return;
|
|
278
|
+
const targetIsTrigger = trigger.contains(target);
|
|
279
|
+
if (targetIsTrigger)
|
|
280
|
+
event.preventDefault();
|
|
232
281
|
}
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
onInteractOutside: (event) => {
|
|
236
|
-
var _a;
|
|
237
|
-
(_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
|
|
238
|
-
if (!event.defaultPrevented)
|
|
239
|
-
hasInteractedOutsideRef.current = true;
|
|
240
|
-
const target = event.target;
|
|
241
|
-
const trigger = props.context.triggerRef.current;
|
|
242
|
-
if (!(trigger instanceof HTMLElement))
|
|
243
|
-
return;
|
|
244
|
-
const targetIsTrigger = trigger.contains(target);
|
|
245
|
-
if (targetIsTrigger)
|
|
246
|
-
event.preventDefault();
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
const DialogContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
251
|
-
const {
|
|
252
|
-
__scopeDialog,
|
|
253
|
-
trapFocus,
|
|
254
|
-
onOpenAutoFocus,
|
|
255
|
-
onCloseAutoFocus,
|
|
256
|
-
disableOutsidePointerEvents,
|
|
257
|
-
onEscapeKeyDown,
|
|
258
|
-
onPointerDownOutside,
|
|
259
|
-
onFocusOutside,
|
|
260
|
-
onInteractOutside,
|
|
261
|
-
context,
|
|
262
|
-
...contentProps
|
|
263
|
-
} = props;
|
|
264
|
-
const contentRef = React.useRef(null);
|
|
265
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
266
|
-
const showSheet = useShowDialogSheet(context);
|
|
267
|
-
const contents = /* @__PURE__ */ React.createElement(DialogContentFrame, {
|
|
268
|
-
id: context.contentId,
|
|
269
|
-
"aria-describedby": context.descriptionId,
|
|
270
|
-
"aria-labelledby": context.titleId,
|
|
271
|
-
"data-state": getState(context.open),
|
|
272
|
-
...contentProps
|
|
273
|
-
});
|
|
274
|
-
if (showSheet) {
|
|
275
|
-
return /* @__PURE__ */ React.createElement(import_portal.PortalItem, {
|
|
276
|
-
hostName: `${context.scopeKey}SheetContents`
|
|
277
|
-
}, contentProps.children);
|
|
282
|
+
});
|
|
278
283
|
}
|
|
279
|
-
|
|
280
|
-
|
|
284
|
+
);
|
|
285
|
+
const DialogContentImpl = React.forwardRef(
|
|
286
|
+
(props, forwardedRef) => {
|
|
287
|
+
const {
|
|
288
|
+
__scopeDialog,
|
|
289
|
+
trapFocus,
|
|
290
|
+
onOpenAutoFocus,
|
|
291
|
+
onCloseAutoFocus,
|
|
292
|
+
disableOutsidePointerEvents,
|
|
293
|
+
onEscapeKeyDown,
|
|
294
|
+
onPointerDownOutside,
|
|
295
|
+
onFocusOutside,
|
|
296
|
+
onInteractOutside,
|
|
297
|
+
context,
|
|
298
|
+
...contentProps
|
|
299
|
+
} = props;
|
|
300
|
+
const contentRef = React.useRef(null);
|
|
301
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
302
|
+
const showSheet = useShowDialogSheet(context);
|
|
303
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentFrame, {
|
|
304
|
+
id: context.contentId,
|
|
305
|
+
"aria-describedby": context.descriptionId,
|
|
306
|
+
"aria-labelledby": context.titleId,
|
|
307
|
+
"data-state": getState(context.open),
|
|
308
|
+
...contentProps
|
|
309
|
+
});
|
|
310
|
+
if (showSheet) {
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
312
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
313
|
+
children: contentProps.children
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (!import_core.isWeb) {
|
|
317
|
+
return contents;
|
|
318
|
+
}
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_focus_scope.FocusScope, {
|
|
322
|
+
loop: true,
|
|
323
|
+
trapped: trapFocus,
|
|
324
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
325
|
+
forceUnmount: !context.open,
|
|
326
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dismissable.Dismissable, {
|
|
328
|
+
disableOutsidePointerEvents: context.open && disableOutsidePointerEvents,
|
|
329
|
+
forceUnmount: !context.open,
|
|
330
|
+
onEscapeKeyDown,
|
|
331
|
+
onPointerDownOutside,
|
|
332
|
+
onFocusOutside,
|
|
333
|
+
onInteractOutside,
|
|
334
|
+
ref: composedRefs,
|
|
335
|
+
onDismiss: () => context.onOpenChange(false),
|
|
336
|
+
children: contents
|
|
337
|
+
})
|
|
338
|
+
}),
|
|
339
|
+
process.env.NODE_ENV === "development" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
340
|
+
children: [
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TitleWarning, {
|
|
342
|
+
titleId: context.titleId
|
|
343
|
+
}),
|
|
344
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionWarning, {
|
|
345
|
+
contentRef,
|
|
346
|
+
descriptionId: context.descriptionId
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
});
|
|
281
352
|
}
|
|
282
|
-
|
|
283
|
-
loop: true,
|
|
284
|
-
trapped: trapFocus,
|
|
285
|
-
onMountAutoFocus: onOpenAutoFocus,
|
|
286
|
-
forceUnmount: !context.open,
|
|
287
|
-
onUnmountAutoFocus: onCloseAutoFocus
|
|
288
|
-
}, /* @__PURE__ */ React.createElement(import_dismissable.Dismissable, {
|
|
289
|
-
disableOutsidePointerEvents: context.open && disableOutsidePointerEvents,
|
|
290
|
-
forceUnmount: !context.open,
|
|
291
|
-
onEscapeKeyDown,
|
|
292
|
-
onPointerDownOutside,
|
|
293
|
-
onFocusOutside,
|
|
294
|
-
onInteractOutside,
|
|
295
|
-
ref: composedRefs,
|
|
296
|
-
onDismiss: () => context.onOpenChange(false)
|
|
297
|
-
}, contents)), process.env.NODE_ENV === "development" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TitleWarning, {
|
|
298
|
-
titleId: context.titleId
|
|
299
|
-
}), /* @__PURE__ */ React.createElement(DescriptionWarning, {
|
|
300
|
-
contentRef,
|
|
301
|
-
descriptionId: context.descriptionId
|
|
302
|
-
})));
|
|
303
|
-
});
|
|
353
|
+
);
|
|
304
354
|
const SHEET_CONTENTS_NAME = "DialogSheetContents";
|
|
305
355
|
const DialogSheetContents = ({ __scopeDialog }) => {
|
|
306
356
|
const context = useDialogContext(SHEET_CONTENTS_NAME, __scopeDialog);
|
|
307
|
-
return /* @__PURE__ */
|
|
357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, {
|
|
308
358
|
name: `${context.scopeKey}SheetContents`
|
|
309
359
|
});
|
|
310
360
|
};
|
|
@@ -313,45 +363,51 @@ const TITLE_NAME = "DialogTitle";
|
|
|
313
363
|
const DialogTitleFrame = (0, import_core.styled)(import_text.H2, {
|
|
314
364
|
name: TITLE_NAME
|
|
315
365
|
});
|
|
316
|
-
const DialogTitle = React.forwardRef(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
});
|
|
366
|
+
const DialogTitle = React.forwardRef(
|
|
367
|
+
(props, forwardedRef) => {
|
|
368
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
369
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
370
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitleFrame, {
|
|
371
|
+
id: context.titleId,
|
|
372
|
+
...titleProps,
|
|
373
|
+
ref: forwardedRef
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
);
|
|
325
377
|
DialogTitle.displayName = TITLE_NAME;
|
|
326
378
|
const DialogDescriptionFrame = (0, import_core.styled)(import_text.Paragraph, {
|
|
327
379
|
name: "DialogDescription"
|
|
328
380
|
});
|
|
329
381
|
const DESCRIPTION_NAME = "DialogDescription";
|
|
330
|
-
const DialogDescription = React.forwardRef(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
});
|
|
382
|
+
const DialogDescription = React.forwardRef(
|
|
383
|
+
(props, forwardedRef) => {
|
|
384
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
385
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescriptionFrame, {
|
|
387
|
+
id: context.descriptionId,
|
|
388
|
+
...descriptionProps,
|
|
389
|
+
ref: forwardedRef
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
);
|
|
339
393
|
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
340
394
|
const CLOSE_NAME = "DialogClose";
|
|
341
|
-
const DialogClose = React.forwardRef(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
395
|
+
const DialogClose = React.forwardRef(
|
|
396
|
+
(props, forwardedRef) => {
|
|
397
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
398
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
399
|
+
const isSheet = useShowDialogSheet(context);
|
|
400
|
+
if (isSheet) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
404
|
+
tag: "button",
|
|
405
|
+
...closeProps,
|
|
406
|
+
ref: forwardedRef,
|
|
407
|
+
onPress: (0, import_core.composeEventHandlers)(props.onPress, () => context.onOpenChange(false))
|
|
408
|
+
});
|
|
347
409
|
}
|
|
348
|
-
|
|
349
|
-
tag: "button",
|
|
350
|
-
...closeProps,
|
|
351
|
-
ref: forwardedRef,
|
|
352
|
-
onPress: (0, import_core.composeEventHandlers)(props.onPress, () => context.onOpenChange(false))
|
|
353
|
-
});
|
|
354
|
-
});
|
|
410
|
+
);
|
|
355
411
|
DialogClose.displayName = CLOSE_NAME;
|
|
356
412
|
function getState(open) {
|
|
357
413
|
return open ? "open" : "closed";
|
|
@@ -418,10 +474,14 @@ const DialogInner = React.forwardRef(function Dialog(props, ref) {
|
|
|
418
474
|
defaultProp: defaultOpen,
|
|
419
475
|
onChange: onOpenChange
|
|
420
476
|
});
|
|
421
|
-
React.useImperativeHandle(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
477
|
+
React.useImperativeHandle(
|
|
478
|
+
ref,
|
|
479
|
+
() => ({
|
|
480
|
+
open: setOpen
|
|
481
|
+
}),
|
|
482
|
+
[setOpen]
|
|
483
|
+
);
|
|
484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogProvider, {
|
|
425
485
|
scope: __scopeDialog,
|
|
426
486
|
scopeKey: __scopeDialog ? Object.keys(__scopeDialog)[0] : "",
|
|
427
487
|
triggerRef,
|
|
@@ -434,11 +494,13 @@ const DialogInner = React.forwardRef(function Dialog(props, ref) {
|
|
|
434
494
|
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
435
495
|
modal,
|
|
436
496
|
allowPinchZoom,
|
|
437
|
-
sheetBreakpoint
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
497
|
+
sheetBreakpoint,
|
|
498
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogSheetController, {
|
|
499
|
+
onChangeOpen: setOpen,
|
|
500
|
+
__scopeDialog,
|
|
501
|
+
children
|
|
502
|
+
})
|
|
503
|
+
});
|
|
442
504
|
});
|
|
443
505
|
const Dialog2 = (0, import_core.withStaticProperties)(DialogInner, {
|
|
444
506
|
Trigger: DialogTrigger,
|
|
@@ -456,15 +518,16 @@ const DialogSheetController = (props) => {
|
|
|
456
518
|
const showSheet = useShowDialogSheet(context);
|
|
457
519
|
const breakpointActive = useSheetBreakpointActive(context);
|
|
458
520
|
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
459
|
-
return /* @__PURE__ */
|
|
521
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sheet.SheetController, {
|
|
460
522
|
onChangeOpen: (val) => {
|
|
461
523
|
if (getShowSheet()) {
|
|
462
524
|
props.onChangeOpen(val);
|
|
463
525
|
}
|
|
464
526
|
},
|
|
465
527
|
open: context.open,
|
|
466
|
-
hidden: breakpointActive === false
|
|
467
|
-
|
|
528
|
+
hidden: breakpointActive === false,
|
|
529
|
+
children: props.children
|
|
530
|
+
});
|
|
468
531
|
};
|
|
469
532
|
const useSheetBreakpointActive = (context) => {
|
|
470
533
|
const media = (0, import_core.useMedia)();
|