@tamagui/dialog 1.111.7 → 1.111.9
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/esm/Dialog.native.js +544 -417
- package/dist/esm/Dialog.native.js.map +1 -6
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/index.native.js.map +1 -6
- package/package.json +21 -21
- package/dist/esm/Dialog.native.mjs +0 -619
- package/dist/esm/Dialog.native.mjs.map +0 -1
- package/dist/esm/index.native.mjs +0 -2
- package/dist/esm/index.native.mjs.map +0 -1
|
@@ -16,253 +16,339 @@ import { ButtonNestingContext, ThemeableStack, YStack } from "@tamagui/stacks";
|
|
|
16
16
|
import { H2, Paragraph } from "@tamagui/text";
|
|
17
17
|
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
18
18
|
import * as React from "react";
|
|
19
|
-
var DIALOG_NAME = "Dialog",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
var DIALOG_NAME = "Dialog",
|
|
20
|
+
[createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME),
|
|
21
|
+
[DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME),
|
|
22
|
+
TRIGGER_NAME = "DialogTrigger",
|
|
23
|
+
DialogTriggerFrame = styled(View, {
|
|
24
|
+
name: TRIGGER_NAME
|
|
25
|
+
}),
|
|
26
|
+
DialogTrigger = DialogTriggerFrame.styleable(function (props, forwardedRef) {
|
|
27
|
+
var {
|
|
28
|
+
__scopeDialog,
|
|
29
|
+
...triggerProps
|
|
30
|
+
} = props,
|
|
31
|
+
isInsideButton = React.useContext(ButtonNestingContext),
|
|
32
|
+
context = useDialogContext(TRIGGER_NAME, __scopeDialog),
|
|
33
|
+
composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
34
|
+
return /* @__PURE__ */_jsx(ButtonNestingContext.Provider, {
|
|
35
|
+
value: !0,
|
|
36
|
+
children: /* @__PURE__ */_jsx(DialogTriggerFrame, {
|
|
37
|
+
tag: isInsideButton ? "span" : "button",
|
|
38
|
+
"aria-haspopup": "dialog",
|
|
39
|
+
"aria-expanded": context.open,
|
|
40
|
+
"aria-controls": context.contentId,
|
|
41
|
+
"data-state": getState(context.open),
|
|
42
|
+
...triggerProps,
|
|
43
|
+
ref: composedTriggerRef,
|
|
44
|
+
onPress: composeEventHandlers(props.onPress, context.onOpenToggle)
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}),
|
|
48
|
+
PORTAL_NAME = "DialogPortal",
|
|
49
|
+
[PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
50
|
+
forceMount: void 0
|
|
51
|
+
}),
|
|
52
|
+
DialogPortalFrame = styled(YStack, {
|
|
53
|
+
pointerEvents: "none",
|
|
54
|
+
variants: {
|
|
55
|
+
unstyled: {
|
|
56
|
+
false: {
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
fullscreen: !0,
|
|
60
|
+
zIndex: 1e5,
|
|
61
|
+
...(isWeb && {
|
|
62
|
+
maxHeight: "100vh",
|
|
63
|
+
position: "fixed"
|
|
64
|
+
})
|
|
50
65
|
}
|
|
51
66
|
}
|
|
67
|
+
},
|
|
68
|
+
defaultVariants: {
|
|
69
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
52
70
|
}
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
};
|
|
71
|
+
}),
|
|
72
|
+
DialogPortalItem = function (props) {
|
|
73
|
+
var themeName = useThemeName(),
|
|
74
|
+
context = useDialogContext(PORTAL_NAME, props.__scopeDialog);
|
|
75
|
+
return /* @__PURE__ */_jsx(PortalItem, {
|
|
76
|
+
hostName: props.hostName,
|
|
77
|
+
children: /* @__PURE__ */_jsx(DialogPortalItemContent, {
|
|
78
|
+
...props,
|
|
79
|
+
themeName,
|
|
80
|
+
context
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
68
84
|
function DialogPortalItemContent(props) {
|
|
69
|
-
var {
|
|
85
|
+
var {
|
|
86
|
+
__scopeDialog,
|
|
87
|
+
children,
|
|
88
|
+
context,
|
|
89
|
+
themeName,
|
|
90
|
+
space,
|
|
91
|
+
spaceDirection,
|
|
92
|
+
separator
|
|
93
|
+
} = props,
|
|
94
|
+
childrenSpaced = children;
|
|
70
95
|
return (space || separator) && (childrenSpaced = spacedChildren({
|
|
71
96
|
children,
|
|
72
97
|
separator,
|
|
73
98
|
space,
|
|
74
99
|
direction: spaceDirection
|
|
75
|
-
})), /* @__PURE__ */
|
|
100
|
+
})), /* @__PURE__ */_jsx(DialogProvider, {
|
|
76
101
|
scope: __scopeDialog,
|
|
77
102
|
...context,
|
|
78
|
-
children: /* @__PURE__ */
|
|
103
|
+
children: /* @__PURE__ */_jsx(Theme, {
|
|
79
104
|
name: themeName,
|
|
80
105
|
children: childrenSpaced
|
|
81
106
|
})
|
|
82
107
|
});
|
|
83
108
|
}
|
|
84
|
-
var DialogPortal = function(props) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
children:
|
|
109
|
+
var DialogPortal = function (props) {
|
|
110
|
+
var {
|
|
111
|
+
__scopeDialog,
|
|
112
|
+
forceMount,
|
|
113
|
+
children,
|
|
114
|
+
...frameProps
|
|
115
|
+
} = props,
|
|
116
|
+
context = useDialogContext(PORTAL_NAME, __scopeDialog),
|
|
117
|
+
isShowing = forceMount || context.open,
|
|
118
|
+
[isFullyHidden, setIsFullyHidden] = React.useState(!isShowing);
|
|
119
|
+
isShowing && isFullyHidden && setIsFullyHidden(!1);
|
|
120
|
+
var handleExitComplete = React.useCallback(function () {
|
|
121
|
+
setIsFullyHidden(!0);
|
|
122
|
+
}, []),
|
|
123
|
+
contents = /* @__PURE__ */_jsx(AnimatePresence, {
|
|
124
|
+
onExitComplete: handleExitComplete,
|
|
125
|
+
children: isShowing ? children : null
|
|
126
|
+
}),
|
|
127
|
+
isSheet = useShowDialogSheet(context);
|
|
128
|
+
if (isSheet) return children;
|
|
129
|
+
if (context.modal) {
|
|
130
|
+
if (isFullyHidden) return null;
|
|
131
|
+
var framedContents = /* @__PURE__ */_jsx(PortalProvider, {
|
|
132
|
+
scope: __scopeDialog,
|
|
133
|
+
forceMount,
|
|
134
|
+
children: /* @__PURE__ */_jsx(DialogPortalFrame, {
|
|
135
|
+
pointerEvents: isShowing ? "auto" : "none",
|
|
136
|
+
...frameProps,
|
|
137
|
+
children: contents
|
|
113
138
|
})
|
|
114
139
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
var { children } = param, themeName = useThemeName();
|
|
124
|
-
return /* @__PURE__ */ _jsx(Theme, {
|
|
125
|
-
name: themeName,
|
|
126
|
-
forceClassName: !0,
|
|
127
|
-
children
|
|
128
|
-
});
|
|
129
|
-
}, OVERLAY_NAME = "DialogOverlay", DialogOverlayFrame = styled(Overlay, {
|
|
130
|
-
name: OVERLAY_NAME
|
|
131
|
-
}), DialogOverlay = DialogOverlayFrame.extractable(/* @__PURE__ */ React.forwardRef(function(param, forwardedRef) {
|
|
132
|
-
var { __scopeDialog, ...props } = param, portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...overlayProps } = props, context = useDialogContext(OVERLAY_NAME, __scopeDialog), showSheet = useShowDialogSheet(context);
|
|
133
|
-
return !forceMount && (!context.modal || showSheet) ? null : /* @__PURE__ */ _jsx(DialogOverlayFrame, {
|
|
134
|
-
"data-state": getState(context.open),
|
|
135
|
-
// We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.
|
|
136
|
-
pointerEvents: context.open ? "auto" : "none",
|
|
137
|
-
...overlayProps,
|
|
138
|
-
ref: forwardedRef
|
|
139
|
-
});
|
|
140
|
-
})), CONTENT_NAME = "DialogContent", DialogContentFrame = styled(ThemeableStack, {
|
|
141
|
-
name: CONTENT_NAME,
|
|
142
|
-
tag: "dialog",
|
|
143
|
-
variants: {
|
|
144
|
-
size: {
|
|
145
|
-
"...size": function(val, extras) {
|
|
146
|
-
return {};
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
unstyled: {
|
|
150
|
-
false: {
|
|
151
|
-
position: "relative",
|
|
152
|
-
backgrounded: !0,
|
|
153
|
-
padded: !0,
|
|
154
|
-
radiused: !0,
|
|
155
|
-
elevate: !0,
|
|
156
|
-
zIndex: 1e5
|
|
140
|
+
if (isWeb) {
|
|
141
|
+
var _props_zIndex;
|
|
142
|
+
return /* @__PURE__ */_jsx(Portal, {
|
|
143
|
+
zIndex: (_props_zIndex = props.zIndex) !== null && _props_zIndex !== void 0 ? _props_zIndex : 1e5,
|
|
144
|
+
children: /* @__PURE__ */_jsx(PassthroughTheme, {
|
|
145
|
+
children: framedContents
|
|
146
|
+
})
|
|
147
|
+
});
|
|
157
148
|
}
|
|
149
|
+
return /* @__PURE__ */_jsx(DialogPortalItem, {
|
|
150
|
+
__scopeDialog,
|
|
151
|
+
children: framedContents
|
|
152
|
+
});
|
|
158
153
|
}
|
|
154
|
+
return contents;
|
|
159
155
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}),
|
|
214
|
-
// When focus is trapped, a `focusout` event may still happen.
|
|
215
|
-
// We make sure we don't trigger our `onDismiss` in such case.
|
|
216
|
-
onFocusOutside: composeEventHandlers(props.onFocusOutside, function(event) {
|
|
217
|
-
return event.preventDefault();
|
|
218
|
-
}),
|
|
219
|
-
...!props.unstyled && {
|
|
220
|
-
outlineStyle: "none"
|
|
221
|
-
},
|
|
222
|
-
children
|
|
223
|
-
});
|
|
224
|
-
}), DialogContentNonModal = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
225
|
-
var hasInteractedOutsideRef = React.useRef(!1);
|
|
226
|
-
return /* @__PURE__ */ _jsx(DialogContentImpl, {
|
|
227
|
-
...props,
|
|
228
|
-
ref: forwardedRef,
|
|
229
|
-
trapFocus: !1,
|
|
230
|
-
disableOutsidePointerEvents: !1,
|
|
231
|
-
onCloseAutoFocus: function(event) {
|
|
232
|
-
var _props_onCloseAutoFocus;
|
|
233
|
-
if ((_props_onCloseAutoFocus = props.onCloseAutoFocus) === null || _props_onCloseAutoFocus === void 0 || _props_onCloseAutoFocus.call(props, event), !event.defaultPrevented) {
|
|
234
|
-
if (!hasInteractedOutsideRef.current) {
|
|
235
|
-
var _props_context_triggerRef_current;
|
|
236
|
-
(_props_context_triggerRef_current = props.context.triggerRef.current) === null || _props_context_triggerRef_current === void 0 || _props_context_triggerRef_current.focus();
|
|
156
|
+
PassthroughTheme = function (param) {
|
|
157
|
+
var {
|
|
158
|
+
children
|
|
159
|
+
} = param,
|
|
160
|
+
themeName = useThemeName();
|
|
161
|
+
return /* @__PURE__ */_jsx(Theme, {
|
|
162
|
+
name: themeName,
|
|
163
|
+
forceClassName: !0,
|
|
164
|
+
children
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
OVERLAY_NAME = "DialogOverlay",
|
|
168
|
+
DialogOverlayFrame = styled(Overlay, {
|
|
169
|
+
name: OVERLAY_NAME
|
|
170
|
+
}),
|
|
171
|
+
DialogOverlay = DialogOverlayFrame.extractable(/* @__PURE__ */React.forwardRef(function (param, forwardedRef) {
|
|
172
|
+
var {
|
|
173
|
+
__scopeDialog,
|
|
174
|
+
...props
|
|
175
|
+
} = param,
|
|
176
|
+
portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog),
|
|
177
|
+
{
|
|
178
|
+
forceMount = portalContext.forceMount,
|
|
179
|
+
...overlayProps
|
|
180
|
+
} = props,
|
|
181
|
+
context = useDialogContext(OVERLAY_NAME, __scopeDialog),
|
|
182
|
+
showSheet = useShowDialogSheet(context);
|
|
183
|
+
return !forceMount && (!context.modal || showSheet) ? null : /* @__PURE__ */_jsx(DialogOverlayFrame, {
|
|
184
|
+
"data-state": getState(context.open),
|
|
185
|
+
// We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.
|
|
186
|
+
pointerEvents: context.open ? "auto" : "none",
|
|
187
|
+
...overlayProps,
|
|
188
|
+
ref: forwardedRef
|
|
189
|
+
});
|
|
190
|
+
})),
|
|
191
|
+
CONTENT_NAME = "DialogContent",
|
|
192
|
+
DialogContentFrame = styled(ThemeableStack, {
|
|
193
|
+
name: CONTENT_NAME,
|
|
194
|
+
tag: "dialog",
|
|
195
|
+
variants: {
|
|
196
|
+
size: {
|
|
197
|
+
"...size": function (val, extras) {
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
unstyled: {
|
|
202
|
+
false: {
|
|
203
|
+
position: "relative",
|
|
204
|
+
backgrounded: !0,
|
|
205
|
+
padded: !0,
|
|
206
|
+
radiused: !0,
|
|
207
|
+
elevate: !0,
|
|
208
|
+
zIndex: 1e5
|
|
237
209
|
}
|
|
238
|
-
event.preventDefault();
|
|
239
210
|
}
|
|
240
|
-
hasInteractedOutsideRef.current = !1;
|
|
241
211
|
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
var target = event.target, trigger = props.context.triggerRef.current;
|
|
246
|
-
if (trigger instanceof HTMLElement) {
|
|
247
|
-
var targetIsTrigger = trigger.contains(target);
|
|
248
|
-
targetIsTrigger && event.preventDefault();
|
|
249
|
-
}
|
|
212
|
+
defaultVariants: {
|
|
213
|
+
size: "$true",
|
|
214
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
250
215
|
}
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
216
|
+
}),
|
|
217
|
+
DialogContent = DialogContentFrame.extractable(/* @__PURE__ */React.forwardRef(function (param, forwardedRef) {
|
|
218
|
+
var {
|
|
219
|
+
__scopeDialog,
|
|
220
|
+
...props
|
|
221
|
+
} = param,
|
|
222
|
+
portalContext = usePortalContext(CONTENT_NAME, __scopeDialog),
|
|
223
|
+
{
|
|
224
|
+
forceMount = portalContext.forceMount,
|
|
225
|
+
...contentProps
|
|
226
|
+
} = props,
|
|
227
|
+
context = useDialogContext(CONTENT_NAME, __scopeDialog),
|
|
228
|
+
contents = context.modal ? /* @__PURE__ */_jsx(DialogContentModal, {
|
|
229
|
+
context,
|
|
230
|
+
...contentProps,
|
|
231
|
+
ref: forwardedRef
|
|
232
|
+
}) : /* @__PURE__ */_jsx(DialogContentNonModal, {
|
|
233
|
+
context,
|
|
234
|
+
...contentProps,
|
|
235
|
+
ref: forwardedRef
|
|
236
|
+
});
|
|
237
|
+
return !isWeb || context.disableRemoveScroll ? contents : /* @__PURE__ */_jsx(RemoveScroll, {
|
|
238
|
+
forwardProps: !0,
|
|
239
|
+
enabled: context.open,
|
|
240
|
+
allowPinchZoom: context.allowPinchZoom,
|
|
241
|
+
shards: [context.contentRef],
|
|
242
|
+
// causes lots of bugs on touch web on site
|
|
243
|
+
removeScrollBar: !1,
|
|
244
|
+
children: /* @__PURE__ */_jsx("div", {
|
|
245
|
+
"data-remove-scroll-container": !0,
|
|
246
|
+
className: "_dsp_contents",
|
|
247
|
+
children: contents
|
|
248
|
+
})
|
|
249
|
+
});
|
|
250
|
+
})),
|
|
251
|
+
DialogContentModal = /* @__PURE__ */React.forwardRef(function (param, forwardedRef) {
|
|
252
|
+
var {
|
|
253
|
+
children,
|
|
254
|
+
context,
|
|
255
|
+
...props
|
|
256
|
+
} = param,
|
|
257
|
+
contentRef = React.useRef(null),
|
|
258
|
+
composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
259
|
+
return isWeb && React.useEffect(function () {
|
|
260
|
+
if (context.open) {
|
|
261
|
+
var content = contentRef.current;
|
|
262
|
+
if (content) return hideOthers(content);
|
|
263
|
+
}
|
|
264
|
+
}, [context.open]), /* @__PURE__ */_jsx(DialogContentImpl, {
|
|
265
|
+
...props,
|
|
266
|
+
context,
|
|
267
|
+
ref: composedRefs,
|
|
268
|
+
// we make sure focus isn't trapped once `DialogContent` has been closed
|
|
269
|
+
// (closed !== unmounted when animating out)
|
|
270
|
+
trapFocus: context.open,
|
|
271
|
+
disableOutsidePointerEvents: !0,
|
|
272
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, function (event) {
|
|
273
|
+
var _context_triggerRef_current;
|
|
274
|
+
event.preventDefault(), (_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 || _context_triggerRef_current.focus();
|
|
275
|
+
}),
|
|
276
|
+
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, function (event) {
|
|
277
|
+
var originalEvent = event.detail.originalEvent,
|
|
278
|
+
ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0,
|
|
279
|
+
isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
280
|
+
isRightClick && event.preventDefault();
|
|
281
|
+
}),
|
|
282
|
+
// When focus is trapped, a `focusout` event may still happen.
|
|
283
|
+
// We make sure we don't trigger our `onDismiss` in such case.
|
|
284
|
+
onFocusOutside: composeEventHandlers(props.onFocusOutside, function (event) {
|
|
285
|
+
return event.preventDefault();
|
|
286
|
+
}),
|
|
287
|
+
...(!props.unstyled && {
|
|
288
|
+
outlineStyle: "none"
|
|
289
|
+
}),
|
|
290
|
+
children
|
|
291
|
+
});
|
|
292
|
+
}),
|
|
293
|
+
DialogContentNonModal = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
294
|
+
var hasInteractedOutsideRef = React.useRef(!1);
|
|
295
|
+
return /* @__PURE__ */_jsx(DialogContentImpl, {
|
|
296
|
+
...props,
|
|
297
|
+
ref: forwardedRef,
|
|
298
|
+
trapFocus: !1,
|
|
299
|
+
disableOutsidePointerEvents: !1,
|
|
300
|
+
onCloseAutoFocus: function (event) {
|
|
301
|
+
var _props_onCloseAutoFocus;
|
|
302
|
+
if ((_props_onCloseAutoFocus = props.onCloseAutoFocus) === null || _props_onCloseAutoFocus === void 0 || _props_onCloseAutoFocus.call(props, event), !event.defaultPrevented) {
|
|
303
|
+
if (!hasInteractedOutsideRef.current) {
|
|
304
|
+
var _props_context_triggerRef_current;
|
|
305
|
+
(_props_context_triggerRef_current = props.context.triggerRef.current) === null || _props_context_triggerRef_current === void 0 || _props_context_triggerRef_current.focus();
|
|
306
|
+
}
|
|
307
|
+
event.preventDefault();
|
|
308
|
+
}
|
|
309
|
+
hasInteractedOutsideRef.current = !1;
|
|
310
|
+
},
|
|
311
|
+
onInteractOutside: function (event) {
|
|
312
|
+
var _props_onInteractOutside;
|
|
313
|
+
(_props_onInteractOutside = props.onInteractOutside) === null || _props_onInteractOutside === void 0 || _props_onInteractOutside.call(props, event), event.defaultPrevented || (hasInteractedOutsideRef.current = !0);
|
|
314
|
+
var target = event.target,
|
|
315
|
+
trigger = props.context.triggerRef.current;
|
|
316
|
+
if (trigger instanceof HTMLElement) {
|
|
317
|
+
var targetIsTrigger = trigger.contains(target);
|
|
318
|
+
targetIsTrigger && event.preventDefault();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}),
|
|
323
|
+
DialogContentImpl = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
324
|
+
var {
|
|
325
|
+
__scopeDialog,
|
|
326
|
+
trapFocus,
|
|
327
|
+
onOpenAutoFocus,
|
|
328
|
+
onCloseAutoFocus,
|
|
329
|
+
disableOutsidePointerEvents,
|
|
330
|
+
onEscapeKeyDown,
|
|
331
|
+
onPointerDownOutside,
|
|
332
|
+
onFocusOutside,
|
|
333
|
+
onInteractOutside,
|
|
334
|
+
context,
|
|
335
|
+
...contentProps
|
|
336
|
+
} = props,
|
|
337
|
+
contentRef = React.useRef(null),
|
|
338
|
+
composedRefs = useComposedRefs(forwardedRef, contentRef),
|
|
339
|
+
showSheet = useShowDialogSheet(context),
|
|
340
|
+
contents = /* @__PURE__ */_jsx(DialogContentFrame, {
|
|
341
|
+
id: context.contentId,
|
|
342
|
+
"aria-describedby": context.descriptionId,
|
|
343
|
+
"aria-labelledby": context.titleId,
|
|
344
|
+
"data-state": getState(context.open),
|
|
345
|
+
...contentProps
|
|
346
|
+
});
|
|
347
|
+
return showSheet ? /* @__PURE__ */_jsx(DialogPortalItem, {
|
|
348
|
+
hostName: getSheetContentsName(context),
|
|
349
|
+
children: contentProps.children
|
|
350
|
+
}) : isWeb ? /* @__PURE__ */_jsxs(_Fragment, {
|
|
351
|
+
children: [/* @__PURE__ */_jsx(Dismissable, {
|
|
266
352
|
disableOutsidePointerEvents: context.open && disableOutsidePointerEvents,
|
|
267
353
|
forceUnmount: !context.open,
|
|
268
354
|
onEscapeKeyDown,
|
|
@@ -271,10 +357,10 @@ var DialogPortal = function(props) {
|
|
|
271
357
|
onInteractOutside,
|
|
272
358
|
// @ts-ignore
|
|
273
359
|
ref: composedRefs,
|
|
274
|
-
onDismiss: function() {
|
|
360
|
+
onDismiss: function () {
|
|
275
361
|
return context.onOpenChange(!1);
|
|
276
362
|
},
|
|
277
|
-
children: /* @__PURE__ */
|
|
363
|
+
children: /* @__PURE__ */_jsx(FocusScope, {
|
|
278
364
|
loop: !0,
|
|
279
365
|
enabled: context.open,
|
|
280
366
|
trapped: trapFocus,
|
|
@@ -283,210 +369,251 @@ var DialogPortal = function(props) {
|
|
|
283
369
|
onUnmountAutoFocus: onCloseAutoFocus,
|
|
284
370
|
children: contents
|
|
285
371
|
})
|
|
372
|
+
}), process.env.NODE_ENV === "development" && /* @__PURE__ */_jsxs(_Fragment, {
|
|
373
|
+
children: [/* @__PURE__ */_jsx(TitleWarning, {
|
|
374
|
+
titleId: context.titleId
|
|
375
|
+
}), /* @__PURE__ */_jsx(DescriptionWarning, {
|
|
376
|
+
contentRef,
|
|
377
|
+
descriptionId: context.descriptionId
|
|
378
|
+
})]
|
|
379
|
+
})]
|
|
380
|
+
}) : contents;
|
|
381
|
+
}),
|
|
382
|
+
DialogTitleFrame = styled(H2, {
|
|
383
|
+
name: "DialogTitle"
|
|
384
|
+
}),
|
|
385
|
+
DialogTitle = DialogTitleFrame.styleable(function (props, forwardedRef) {
|
|
386
|
+
var {
|
|
387
|
+
__scopeDialog,
|
|
388
|
+
...titleProps
|
|
389
|
+
} = props,
|
|
390
|
+
context = useDialogContext("DialogTitle", __scopeDialog);
|
|
391
|
+
return /* @__PURE__ */_jsx(DialogTitleFrame, {
|
|
392
|
+
id: context.titleId,
|
|
393
|
+
...titleProps,
|
|
394
|
+
ref: forwardedRef
|
|
395
|
+
});
|
|
396
|
+
}),
|
|
397
|
+
DialogDescriptionFrame = styled(Paragraph, {
|
|
398
|
+
name: "DialogDescription"
|
|
399
|
+
}),
|
|
400
|
+
DESCRIPTION_NAME = "DialogDescription",
|
|
401
|
+
DialogDescription = DialogDescriptionFrame.styleable(function (props, forwardedRef) {
|
|
402
|
+
var {
|
|
403
|
+
__scopeDialog,
|
|
404
|
+
...descriptionProps
|
|
405
|
+
} = props,
|
|
406
|
+
context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
407
|
+
return /* @__PURE__ */_jsx(DialogDescriptionFrame, {
|
|
408
|
+
id: context.descriptionId,
|
|
409
|
+
...descriptionProps,
|
|
410
|
+
ref: forwardedRef
|
|
411
|
+
});
|
|
412
|
+
}),
|
|
413
|
+
CLOSE_NAME = "DialogClose",
|
|
414
|
+
DialogCloseFrame = styled(View, {
|
|
415
|
+
name: CLOSE_NAME,
|
|
416
|
+
tag: "button"
|
|
417
|
+
}),
|
|
418
|
+
DialogClose = DialogCloseFrame.styleable(function (props, forwardedRef) {
|
|
419
|
+
var {
|
|
420
|
+
__scopeDialog,
|
|
421
|
+
displayWhenAdapted,
|
|
422
|
+
...closeProps
|
|
423
|
+
} = props,
|
|
424
|
+
context = useDialogContext(CLOSE_NAME, __scopeDialog, {
|
|
425
|
+
warn: !1,
|
|
426
|
+
fallback: {}
|
|
286
427
|
}),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
]
|
|
428
|
+
isSheet = useShowDialogSheet(context),
|
|
429
|
+
isInsideButton = React.useContext(ButtonNestingContext);
|
|
430
|
+
return isSheet && !displayWhenAdapted ? null : /* @__PURE__ */_jsx(DialogCloseFrame, {
|
|
431
|
+
accessibilityLabel: "Dialog Close",
|
|
432
|
+
tag: isInsideButton ? "span" : "button",
|
|
433
|
+
...closeProps,
|
|
434
|
+
ref: forwardedRef,
|
|
435
|
+
onPress: composeEventHandlers(props.onPress, function () {
|
|
436
|
+
context.onOpenChange(!1);
|
|
297
437
|
})
|
|
298
|
-
|
|
299
|
-
}) : contents;
|
|
300
|
-
}), DialogTitleFrame = styled(H2, {
|
|
301
|
-
name: "DialogTitle"
|
|
302
|
-
}), DialogTitle = DialogTitleFrame.styleable(function(props, forwardedRef) {
|
|
303
|
-
var { __scopeDialog, ...titleProps } = props, context = useDialogContext("DialogTitle", __scopeDialog);
|
|
304
|
-
return /* @__PURE__ */ _jsx(DialogTitleFrame, {
|
|
305
|
-
id: context.titleId,
|
|
306
|
-
...titleProps,
|
|
307
|
-
ref: forwardedRef
|
|
308
|
-
});
|
|
309
|
-
}), DialogDescriptionFrame = styled(Paragraph, {
|
|
310
|
-
name: "DialogDescription"
|
|
311
|
-
}), DESCRIPTION_NAME = "DialogDescription", DialogDescription = DialogDescriptionFrame.styleable(function(props, forwardedRef) {
|
|
312
|
-
var { __scopeDialog, ...descriptionProps } = props, context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
313
|
-
return /* @__PURE__ */ _jsx(DialogDescriptionFrame, {
|
|
314
|
-
id: context.descriptionId,
|
|
315
|
-
...descriptionProps,
|
|
316
|
-
ref: forwardedRef
|
|
317
|
-
});
|
|
318
|
-
}), CLOSE_NAME = "DialogClose", DialogCloseFrame = styled(View, {
|
|
319
|
-
name: CLOSE_NAME,
|
|
320
|
-
tag: "button"
|
|
321
|
-
}), DialogClose = DialogCloseFrame.styleable(function(props, forwardedRef) {
|
|
322
|
-
var { __scopeDialog, displayWhenAdapted, ...closeProps } = props, context = useDialogContext(CLOSE_NAME, __scopeDialog, {
|
|
323
|
-
warn: !1,
|
|
324
|
-
fallback: {}
|
|
325
|
-
}), isSheet = useShowDialogSheet(context), isInsideButton = React.useContext(ButtonNestingContext);
|
|
326
|
-
return isSheet && !displayWhenAdapted ? null : /* @__PURE__ */ _jsx(DialogCloseFrame, {
|
|
327
|
-
accessibilityLabel: "Dialog Close",
|
|
328
|
-
tag: isInsideButton ? "span" : "button",
|
|
329
|
-
...closeProps,
|
|
330
|
-
ref: forwardedRef,
|
|
331
|
-
onPress: composeEventHandlers(props.onPress, function() {
|
|
332
|
-
context.onOpenChange(!1);
|
|
333
|
-
})
|
|
438
|
+
});
|
|
334
439
|
});
|
|
335
|
-
});
|
|
336
440
|
function getState(open) {
|
|
337
441
|
return open ? "open" : "closed";
|
|
338
442
|
}
|
|
339
|
-
var TITLE_WARNING_NAME = "DialogTitleWarning",
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
var
|
|
443
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning",
|
|
444
|
+
[DialogWarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {
|
|
445
|
+
contentName: CONTENT_NAME,
|
|
446
|
+
titleName: "DialogTitle",
|
|
447
|
+
docsSlug: "dialog"
|
|
448
|
+
}),
|
|
449
|
+
TitleWarning = function (param) {
|
|
450
|
+
var {
|
|
451
|
+
titleId
|
|
452
|
+
} = param;
|
|
453
|
+
if (process.env.NODE_ENV === "development") {
|
|
454
|
+
var titleWarningContext = useWarningContext(TITLE_WARNING_NAME),
|
|
455
|
+
MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
347
456
|
|
|
348
457
|
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.`;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
}, [
|
|
355
|
-
MESSAGE,
|
|
356
|
-
titleId
|
|
357
|
-
]);
|
|
358
|
-
}
|
|
359
|
-
return null;
|
|
360
|
-
}, DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning", DescriptionWarning = function(param) {
|
|
361
|
-
var { contentRef, descriptionId } = param;
|
|
362
|
-
if (process.env.NODE_ENV === "development") {
|
|
363
|
-
var descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME), MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
364
|
-
React.useEffect(function() {
|
|
365
|
-
if (isWeb) {
|
|
366
|
-
var contentNode = contentRef.current;
|
|
367
|
-
if (contentNode instanceof HTMLElement) {
|
|
368
|
-
var describedById = contentNode.getAttribute("aria-describedby");
|
|
369
|
-
if (descriptionId && describedById) {
|
|
370
|
-
var hasDescription = document.getElementById(descriptionId);
|
|
371
|
-
hasDescription || console.warn(MESSAGE);
|
|
372
|
-
}
|
|
458
|
+
React.useEffect(function () {
|
|
459
|
+
if (isWeb && titleId) {
|
|
460
|
+
var hasTitle = document.getElementById(titleId);
|
|
461
|
+
hasTitle || console.warn(MESSAGE);
|
|
373
462
|
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
463
|
+
}, [MESSAGE, titleId]);
|
|
464
|
+
}
|
|
465
|
+
return null;
|
|
466
|
+
},
|
|
467
|
+
DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning",
|
|
468
|
+
DescriptionWarning = function (param) {
|
|
469
|
+
var {
|
|
377
470
|
contentRef,
|
|
378
471
|
descriptionId
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
contentRef,
|
|
401
|
-
contentId,
|
|
402
|
-
titleId,
|
|
403
|
-
descriptionId,
|
|
404
|
-
open,
|
|
405
|
-
onOpenChange: setOpen,
|
|
406
|
-
onOpenToggle,
|
|
407
|
-
modal,
|
|
408
|
-
allowPinchZoom
|
|
409
|
-
}, { when, AdaptProvider } = useAdaptParent({
|
|
410
|
-
Contents: React.useCallback(function(props2) {
|
|
411
|
-
return /* @__PURE__ */ _jsx(PortalHost, {
|
|
412
|
-
forwardProps: props2,
|
|
413
|
-
name: sheetContentsName
|
|
414
|
-
});
|
|
415
|
-
}, [
|
|
416
|
-
sheetContentsName
|
|
417
|
-
])
|
|
418
|
-
});
|
|
419
|
-
return React.useImperativeHandle(ref, function() {
|
|
420
|
-
return {
|
|
421
|
-
open: setOpen
|
|
422
|
-
};
|
|
423
|
-
}, [
|
|
424
|
-
setOpen
|
|
425
|
-
]), /* @__PURE__ */ _jsx(AdaptProvider, {
|
|
426
|
-
children: /* @__PURE__ */ _jsx(DialogProvider, {
|
|
427
|
-
...context,
|
|
428
|
-
sheetBreakpoint: when,
|
|
429
|
-
disableRemoveScroll,
|
|
430
|
-
children: /* @__PURE__ */ _jsx(DialogSheetController, {
|
|
431
|
-
onOpenChange: setOpen,
|
|
472
|
+
} = param;
|
|
473
|
+
if (process.env.NODE_ENV === "development") {
|
|
474
|
+
var descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME),
|
|
475
|
+
MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
476
|
+
React.useEffect(function () {
|
|
477
|
+
if (isWeb) {
|
|
478
|
+
var contentNode = contentRef.current;
|
|
479
|
+
if (contentNode instanceof HTMLElement) {
|
|
480
|
+
var describedById = contentNode.getAttribute("aria-describedby");
|
|
481
|
+
if (descriptionId && describedById) {
|
|
482
|
+
var hasDescription = document.getElementById(descriptionId);
|
|
483
|
+
hasDescription || console.warn(MESSAGE);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
488
|
+
}
|
|
489
|
+
return null;
|
|
490
|
+
},
|
|
491
|
+
Dialog = withStaticProperties(/* @__PURE__ */React.forwardRef(function (props, ref) {
|
|
492
|
+
var {
|
|
432
493
|
__scopeDialog,
|
|
433
|
-
children
|
|
494
|
+
children,
|
|
495
|
+
open: openProp,
|
|
496
|
+
defaultOpen = !1,
|
|
497
|
+
onOpenChange,
|
|
498
|
+
modal = !0,
|
|
499
|
+
allowPinchZoom = !1,
|
|
500
|
+
disableRemoveScroll = !1
|
|
501
|
+
} = props,
|
|
502
|
+
baseId = React.useId(),
|
|
503
|
+
scopeId = `scope-${baseId}`,
|
|
504
|
+
contentId = `content-${baseId}`,
|
|
505
|
+
titleId = `title-${baseId}`,
|
|
506
|
+
descriptionId = `description-${baseId}`,
|
|
507
|
+
scopeKey = __scopeDialog ? Object.keys(__scopeDialog)[0] : scopeId,
|
|
508
|
+
sheetContentsName = getSheetContentsName({
|
|
509
|
+
scopeKey,
|
|
510
|
+
contentId
|
|
511
|
+
}),
|
|
512
|
+
triggerRef = React.useRef(null),
|
|
513
|
+
contentRef = React.useRef(null),
|
|
514
|
+
[open, setOpen] = useControllableState({
|
|
515
|
+
prop: openProp,
|
|
516
|
+
defaultProp: defaultOpen,
|
|
517
|
+
onChange: onOpenChange
|
|
518
|
+
}),
|
|
519
|
+
onOpenToggle = React.useCallback(function () {
|
|
520
|
+
setOpen(function (prevOpen) {
|
|
521
|
+
return !prevOpen;
|
|
522
|
+
});
|
|
523
|
+
}, [setOpen]),
|
|
524
|
+
context = {
|
|
525
|
+
scope: __scopeDialog,
|
|
526
|
+
scopeKey,
|
|
527
|
+
triggerRef,
|
|
528
|
+
contentRef,
|
|
529
|
+
contentId,
|
|
530
|
+
titleId,
|
|
531
|
+
descriptionId,
|
|
532
|
+
open,
|
|
533
|
+
onOpenChange: setOpen,
|
|
534
|
+
onOpenToggle,
|
|
535
|
+
modal,
|
|
536
|
+
allowPinchZoom
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
when,
|
|
540
|
+
AdaptProvider
|
|
541
|
+
} = useAdaptParent({
|
|
542
|
+
Contents: React.useCallback(function (props2) {
|
|
543
|
+
return /* @__PURE__ */_jsx(PortalHost, {
|
|
544
|
+
forwardProps: props2,
|
|
545
|
+
name: sheetContentsName
|
|
546
|
+
});
|
|
547
|
+
}, [sheetContentsName])
|
|
548
|
+
});
|
|
549
|
+
return React.useImperativeHandle(ref, function () {
|
|
550
|
+
return {
|
|
551
|
+
open: setOpen
|
|
552
|
+
};
|
|
553
|
+
}, [setOpen]), /* @__PURE__ */_jsx(AdaptProvider, {
|
|
554
|
+
children: /* @__PURE__ */_jsx(DialogProvider, {
|
|
555
|
+
...context,
|
|
556
|
+
sheetBreakpoint: when,
|
|
557
|
+
disableRemoveScroll,
|
|
558
|
+
children: /* @__PURE__ */_jsx(DialogSheetController, {
|
|
559
|
+
onOpenChange: setOpen,
|
|
560
|
+
__scopeDialog,
|
|
561
|
+
children
|
|
562
|
+
})
|
|
434
563
|
})
|
|
435
|
-
})
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
Adapt
|
|
447
|
-
});
|
|
448
|
-
var DialogSheetContents = function(param) {
|
|
449
|
-
var { name, ...props } = param;
|
|
450
|
-
return /* @__PURE__ */ _jsx(PortalHost, {
|
|
451
|
-
forwardProps: props,
|
|
452
|
-
name
|
|
453
|
-
});
|
|
454
|
-
}, getSheetContentsName = function(param) {
|
|
455
|
-
var { scopeKey, contentId } = param;
|
|
456
|
-
return `${scopeKey || contentId}SheetContents`;
|
|
457
|
-
}, DialogSheetController = function(props) {
|
|
458
|
-
var context = useDialogContext("DialogSheetController", props.__scopeDialog), showSheet = useShowDialogSheet(context), breakpointActive = useSheetBreakpointActive(context), getShowSheet = useGet(showSheet);
|
|
459
|
-
return /* @__PURE__ */ _jsx(SheetController, {
|
|
460
|
-
onOpenChange: function(val) {
|
|
461
|
-
if (getShowSheet()) {
|
|
462
|
-
var _props_onOpenChange;
|
|
463
|
-
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 || _props_onOpenChange.call(props, val);
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
open: context.open,
|
|
467
|
-
hidden: breakpointActive === !1,
|
|
468
|
-
children: props.children
|
|
564
|
+
});
|
|
565
|
+
}), {
|
|
566
|
+
Trigger: DialogTrigger,
|
|
567
|
+
Portal: DialogPortal,
|
|
568
|
+
Overlay: DialogOverlay,
|
|
569
|
+
Content: DialogContent,
|
|
570
|
+
Title: DialogTitle,
|
|
571
|
+
Description: DialogDescription,
|
|
572
|
+
Close: DialogClose,
|
|
573
|
+
Sheet: Sheet.Controlled,
|
|
574
|
+
Adapt
|
|
469
575
|
});
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
576
|
+
var DialogSheetContents = function (param) {
|
|
577
|
+
var {
|
|
578
|
+
name,
|
|
579
|
+
...props
|
|
580
|
+
} = param;
|
|
581
|
+
return /* @__PURE__ */_jsx(PortalHost, {
|
|
582
|
+
forwardProps: props,
|
|
583
|
+
name
|
|
584
|
+
});
|
|
585
|
+
},
|
|
586
|
+
getSheetContentsName = function (param) {
|
|
587
|
+
var {
|
|
588
|
+
scopeKey,
|
|
589
|
+
contentId
|
|
590
|
+
} = param;
|
|
591
|
+
return `${scopeKey || contentId}SheetContents`;
|
|
592
|
+
},
|
|
593
|
+
DialogSheetController = function (props) {
|
|
594
|
+
var context = useDialogContext("DialogSheetController", props.__scopeDialog),
|
|
595
|
+
showSheet = useShowDialogSheet(context),
|
|
596
|
+
breakpointActive = useSheetBreakpointActive(context),
|
|
597
|
+
getShowSheet = useGet(showSheet);
|
|
598
|
+
return /* @__PURE__ */_jsx(SheetController, {
|
|
599
|
+
onOpenChange: function (val) {
|
|
600
|
+
if (getShowSheet()) {
|
|
601
|
+
var _props_onOpenChange;
|
|
602
|
+
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 || _props_onOpenChange.call(props, val);
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
open: context.open,
|
|
606
|
+
hidden: breakpointActive === !1,
|
|
607
|
+
children: props.children
|
|
608
|
+
});
|
|
609
|
+
},
|
|
610
|
+
useSheetBreakpointActive = function (context) {
|
|
611
|
+
var media = useMedia();
|
|
612
|
+
return context.sheetBreakpoint ? context.sheetBreakpoint === !0 ? !0 : media[context.sheetBreakpoint] : !1;
|
|
613
|
+
},
|
|
614
|
+
useShowDialogSheet = function (context) {
|
|
615
|
+
var breakpointActive = useSheetBreakpointActive(context);
|
|
616
|
+
return context.open === !1 ? !1 : breakpointActive;
|
|
617
|
+
};
|
|
618
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogPortalFrame, DialogSheetContents, DialogTitle, DialogTrigger, DialogWarningProvider, createDialogScope };
|
|
619
|
+
//# sourceMappingURL=Dialog.native.js.map
|