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