@tamagui/dialog 2.0.0-rc.9 → 2.0.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.cjs +622 -521
- package/dist/cjs/Dialog.native.js +658 -575
- package/dist/cjs/Dialog.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Dialog.mjs +580 -481
- package/dist/esm/Dialog.mjs.map +1 -1
- package/dist/esm/Dialog.native.js +616 -535
- package/dist/esm/Dialog.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/Dialog.mjs +580 -481
- package/dist/jsx/Dialog.mjs.map +1 -1
- package/dist/jsx/Dialog.native.js +658 -575
- package/dist/jsx/Dialog.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/package.json +24 -25
- package/src/Dialog.tsx +68 -4
- package/types/Dialog.d.ts +15 -2
- package/types/Dialog.d.ts.map +1 -1
- package/dist/cjs/Dialog.js +0 -489
- package/dist/cjs/Dialog.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/Dialog.js +0 -502
- package/dist/esm/Dialog.js.map +0 -6
- package/dist/jsx/Dialog.js +0 -502
- package/dist/jsx/Dialog.js.map +0 -6
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var Dialog_exports = {};
|
|
35
37
|
__export(Dialog_exports, {
|
|
36
38
|
Dialog: () => Dialog,
|
|
@@ -49,171 +51,204 @@ __export(Dialog_exports, {
|
|
|
49
51
|
useDialogContext: () => useDialogContext
|
|
50
52
|
});
|
|
51
53
|
module.exports = __toCommonJS(Dialog_exports);
|
|
52
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
55
|
+
var import_adapt = require("@tamagui/adapt");
|
|
56
|
+
var import_animate = require("@tamagui/animate");
|
|
57
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
58
|
+
var import_constants = require("@tamagui/constants");
|
|
59
|
+
var import_core = require("@tamagui/core");
|
|
60
|
+
var import_create_context = require("@tamagui/create-context");
|
|
61
|
+
var import_dismissable = require("@tamagui/dismissable");
|
|
62
|
+
var import_focus_scope = require("@tamagui/focus-scope");
|
|
63
|
+
var import_helpers = require("@tamagui/helpers");
|
|
64
|
+
var import_portal = require("@tamagui/portal");
|
|
65
|
+
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
66
|
+
var import_controller = require("@tamagui/sheet/controller");
|
|
67
|
+
var import_stacks = require("@tamagui/stacks");
|
|
68
|
+
var import_text = require("@tamagui/text");
|
|
69
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
70
|
+
var import_z_index_stack = require("@tamagui/z-index-stack");
|
|
71
|
+
var React = __toESM(require("react"), 1);
|
|
70
72
|
function _instanceof(left, right) {
|
|
71
|
-
|
|
73
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
74
|
+
return !!right[Symbol.hasInstance](left);
|
|
75
|
+
} else {
|
|
76
|
+
return left instanceof right;
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
var DialogContext = (0, import_core.createStyledContext)(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
80
|
+
// since we always provide this we can avoid setting here
|
|
81
|
+
{}, "Dialog__");
|
|
82
|
+
var {
|
|
83
|
+
useStyledContext: useDialogContext,
|
|
84
|
+
Provider: DialogProvider
|
|
85
|
+
} = DialogContext;
|
|
86
|
+
var DialogAdaptHiddenContext = /* @__PURE__ */React.createContext(true);
|
|
87
|
+
var DialogTriggerFrame = (0, import_core.styled)(import_core.View, {
|
|
88
|
+
name: "DialogTrigger"
|
|
89
|
+
});
|
|
90
|
+
var DialogTrigger = DialogTriggerFrame.styleable(function DialogTrigger2(props, forwardedRef) {
|
|
91
|
+
var {
|
|
92
|
+
scope,
|
|
93
|
+
...triggerProps
|
|
94
|
+
} = props;
|
|
95
|
+
var isInsideButton = React.useContext(import_stacks.ButtonNestingContext);
|
|
96
|
+
var context = useDialogContext(scope);
|
|
97
|
+
var composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
98
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
|
|
99
|
+
value: true,
|
|
100
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogTriggerFrame, {
|
|
101
|
+
render: isInsideButton ? "span" : "button",
|
|
102
|
+
"aria-haspopup": "dialog",
|
|
103
|
+
"aria-expanded": context.open,
|
|
104
|
+
"aria-controls": context.contentId,
|
|
105
|
+
"data-state": getState(context.open),
|
|
106
|
+
...triggerProps,
|
|
107
|
+
ref: composedTriggerRef,
|
|
108
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
var DialogPortalFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
113
|
+
pointerEvents: "none",
|
|
114
|
+
render: "dialog",
|
|
115
|
+
variants: {
|
|
116
|
+
unstyled: {
|
|
117
|
+
false: {
|
|
118
|
+
alignItems: "center",
|
|
119
|
+
justifyContent: "center",
|
|
120
|
+
fullscreen: true,
|
|
121
|
+
"$platform-web": {
|
|
122
|
+
// undo dialog styles
|
|
123
|
+
borderWidth: 0,
|
|
124
|
+
backgroundColor: "transparent",
|
|
125
|
+
color: "inherit",
|
|
126
|
+
maxInlineSize: "none",
|
|
127
|
+
margin: 0,
|
|
128
|
+
width: "auto",
|
|
129
|
+
height: "auto",
|
|
130
|
+
// ensure always in frame and right height
|
|
131
|
+
maxHeight: "100vh",
|
|
132
|
+
position: "fixed",
|
|
133
|
+
// ensure dialog inherits stacking context from portal wrapper
|
|
134
|
+
zIndex: 1
|
|
129
135
|
}
|
|
130
136
|
}
|
|
131
|
-
},
|
|
132
|
-
defaultVariants: {
|
|
133
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
134
137
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
},
|
|
139
|
+
defaultVariants: {
|
|
140
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
var needsRepropagation = (0, import_portal.needsPortalRepropagation)();
|
|
144
|
+
var DialogPortalItem = function (param) {
|
|
145
|
+
var {
|
|
146
|
+
context,
|
|
147
|
+
children
|
|
148
|
+
} = param;
|
|
149
|
+
var themeName = (0, import_core.useThemeName)();
|
|
150
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
151
|
+
var adaptContext = (0, import_adapt.useAdaptContext)(context.adaptScope);
|
|
152
|
+
var content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
153
|
+
name: themeName,
|
|
154
|
+
children
|
|
155
|
+
});
|
|
156
|
+
if (needsRepropagation) {
|
|
157
|
+
content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
150
158
|
...adaptContext,
|
|
151
159
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogProvider, {
|
|
152
160
|
...context,
|
|
153
161
|
children: content
|
|
154
162
|
})
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return isAdapted ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {
|
|
166
|
+
scope: context.adaptScope,
|
|
167
|
+
children: content
|
|
168
|
+
}) : context.modal ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
169
|
+
hostName: context.modal ? "root" : context.adaptScope,
|
|
170
|
+
children: content
|
|
171
|
+
}) : content;
|
|
172
|
+
};
|
|
173
|
+
var DialogPortal = /* @__PURE__ */React.forwardRef(function (props, forwardRef) {
|
|
174
|
+
var {
|
|
175
|
+
scope,
|
|
176
|
+
forceMount,
|
|
177
|
+
children,
|
|
178
|
+
...frameProps
|
|
179
|
+
} = props;
|
|
180
|
+
var dialogRef = React.useRef(null);
|
|
181
|
+
var ref = (0, import_compose_refs.composeRefs)(dialogRef, forwardRef);
|
|
182
|
+
var context = useDialogContext(scope);
|
|
183
|
+
var keepMounted = forceMount || context.keepChildrenMounted;
|
|
184
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
185
|
+
var [isFullyHidden, setIsFullyHidden] = React.useState(!context.open);
|
|
186
|
+
if (context.open && isFullyHidden) {
|
|
187
|
+
setIsFullyHidden(false);
|
|
188
|
+
}
|
|
189
|
+
var isVisible = context.open ? true : !isFullyHidden;
|
|
190
|
+
if (import_constants.isWeb) {
|
|
191
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
179
192
|
var node = dialogRef.current;
|
|
180
|
-
if (_instanceof(node, HTMLDialogElement))
|
|
193
|
+
if (!_instanceof(node, HTMLDialogElement)) return;
|
|
194
|
+
if (isVisible) {
|
|
181
195
|
var _node_show;
|
|
182
|
-
(_node_show = node.show) === null || _node_show === void 0
|
|
196
|
+
(_node_show = node.show) === null || _node_show === void 0 ? void 0 : _node_show.call(node);
|
|
183
197
|
} else {
|
|
184
198
|
var _node_close;
|
|
185
|
-
(_node_close = node.close) === null || _node_close === void 0
|
|
199
|
+
(_node_close = node.close) === null || _node_close === void 0 ? void 0 : _node_close.call(node);
|
|
186
200
|
}
|
|
187
201
|
}, [isVisible]);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
+
}
|
|
203
|
+
var onAnimationCompleteRef = React.useRef(context.onAnimationComplete);
|
|
204
|
+
onAnimationCompleteRef.current = context.onAnimationComplete;
|
|
205
|
+
var handleExitComplete = React.useCallback(function () {
|
|
206
|
+
var _onAnimationCompleteRef_current;
|
|
207
|
+
setIsFullyHidden(true);
|
|
208
|
+
(_onAnimationCompleteRef_current = onAnimationCompleteRef.current) === null || _onAnimationCompleteRef_current === void 0 ? void 0 : _onAnimationCompleteRef_current.call(onAnimationCompleteRef, {
|
|
209
|
+
open: false
|
|
210
|
+
});
|
|
211
|
+
}, []);
|
|
212
|
+
React.useEffect(function () {
|
|
213
|
+
if (context.open && !isAdapted && onAnimationCompleteRef.current) {
|
|
214
|
+
var tm = setTimeout(function () {
|
|
215
|
+
var _onAnimationCompleteRef_current;
|
|
216
|
+
(_onAnimationCompleteRef_current = onAnimationCompleteRef.current) === null || _onAnimationCompleteRef_current === void 0 ? void 0 : _onAnimationCompleteRef_current.call(onAnimationCompleteRef, {
|
|
217
|
+
open: true
|
|
218
|
+
});
|
|
219
|
+
}, 350);
|
|
220
|
+
return function () {
|
|
221
|
+
return clearTimeout(tm);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}, [context.open, isAdapted]);
|
|
225
|
+
var zIndex = (0, import_core.getExpandedShorthand)("zIndex", props);
|
|
226
|
+
var contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_z_index_stack.StackZIndexContext, {
|
|
227
|
+
zIndex: (0, import_portal.resolveViewZIndex)(zIndex),
|
|
228
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate.Animate, {
|
|
229
|
+
type: "presence",
|
|
230
|
+
present: Boolean(context.open),
|
|
231
|
+
keepChildrenMounted: Boolean(keepMounted),
|
|
232
|
+
onExitComplete: handleExitComplete,
|
|
233
|
+
passThrough: isAdapted,
|
|
234
|
+
children
|
|
235
|
+
})
|
|
236
|
+
});
|
|
237
|
+
var framedContents = isFullyHidden && !keepMounted && !isAdapted ? null : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
|
|
238
|
+
disable: !context.open,
|
|
239
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogPortalFrame, {
|
|
240
|
+
ref,
|
|
241
|
+
...(import_constants.isWeb && context.open && {
|
|
242
|
+
"aria-modal": true
|
|
202
243
|
}),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
...frameProps,
|
|
212
|
-
className: "_no_backdrop " + (frameProps.className || ""),
|
|
213
|
-
children: contents
|
|
214
|
-
})
|
|
215
|
-
});
|
|
216
|
-
return import_constants.isWeb ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
244
|
+
pointerEvents: context.open ? "auto" : "none",
|
|
245
|
+
...frameProps,
|
|
246
|
+
className: `_no_backdrop ` + (frameProps.className || ""),
|
|
247
|
+
children: contents
|
|
248
|
+
})
|
|
249
|
+
});
|
|
250
|
+
if (import_constants.isWeb) {
|
|
251
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
217
252
|
zIndex,
|
|
218
253
|
// set to 100000 which ensures dialogs are above most fixed UI (headers, navs)
|
|
219
254
|
// this makes sure its above typical stacking contexts
|
|
@@ -223,449 +258,497 @@ var DialogContext = (0, import_core.createStyledContext)(
|
|
|
223
258
|
passThrough: isAdapted,
|
|
224
259
|
children: framedContents
|
|
225
260
|
})
|
|
226
|
-
}) : isAdapted ? framedContents : /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogPortalItem, {
|
|
227
|
-
context,
|
|
228
|
-
children: framedContents
|
|
229
261
|
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
}
|
|
263
|
+
return isAdapted ? framedContents : /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogPortalItem, {
|
|
264
|
+
context,
|
|
265
|
+
children: framedContents
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
var PassthroughTheme = function (param) {
|
|
269
|
+
var {
|
|
270
|
+
children,
|
|
271
|
+
passThrough
|
|
272
|
+
} = param;
|
|
273
|
+
var themeName = (0, import_core.useThemeName)();
|
|
274
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
275
|
+
passThrough,
|
|
276
|
+
name: themeName,
|
|
277
|
+
forceClassName: true,
|
|
278
|
+
children
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
282
|
+
var DialogOverlayFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
283
|
+
name: OVERLAY_NAME,
|
|
284
|
+
zIndex: 1,
|
|
285
|
+
variants: {
|
|
286
|
+
open: {
|
|
287
|
+
true: {
|
|
288
|
+
pointerEvents: "auto"
|
|
255
289
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
fullscreen: !0,
|
|
259
|
-
position: "absolute",
|
|
260
|
-
backgroundColor: "$background",
|
|
261
|
-
zIndex: 99999,
|
|
262
|
-
pointerEvents: "auto"
|
|
263
|
-
}
|
|
290
|
+
false: {
|
|
291
|
+
pointerEvents: "none"
|
|
264
292
|
}
|
|
265
293
|
},
|
|
266
|
-
|
|
267
|
-
|
|
294
|
+
unstyled: {
|
|
295
|
+
false: {
|
|
296
|
+
fullscreen: true,
|
|
297
|
+
position: "absolute",
|
|
298
|
+
backgroundColor: "$background",
|
|
299
|
+
pointerEvents: "auto"
|
|
300
|
+
}
|
|
268
301
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
elevate: !0,
|
|
312
|
-
zIndex: 1e5,
|
|
313
|
-
// Ensure content receives pointer events (fixes React 19 + display:contents inheritance)
|
|
314
|
-
pointerEvents: "auto"
|
|
315
|
-
}
|
|
302
|
+
},
|
|
303
|
+
defaultVariants: {
|
|
304
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
var DialogOverlay = DialogOverlayFrame.styleable(function DialogOverlay2(param, forwardedRef) {
|
|
308
|
+
var {
|
|
309
|
+
scope,
|
|
310
|
+
...props
|
|
311
|
+
} = param;
|
|
312
|
+
var context = useDialogContext(scope);
|
|
313
|
+
var {
|
|
314
|
+
forceMount = context.forceMount,
|
|
315
|
+
...overlayProps
|
|
316
|
+
} = props;
|
|
317
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
318
|
+
if (!forceMount) {
|
|
319
|
+
if (!context.modal || isAdapted) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogOverlayFrame, {
|
|
324
|
+
"data-state": getState(context.open),
|
|
325
|
+
// TODO: this will be apply for v2
|
|
326
|
+
// onPress={() => {
|
|
327
|
+
// // if the overlay is pressed, close the dialog
|
|
328
|
+
// context.onOpenChange(false)
|
|
329
|
+
// }}
|
|
330
|
+
// We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.
|
|
331
|
+
pointerEvents: context.open ? "auto" : "none",
|
|
332
|
+
...overlayProps,
|
|
333
|
+
ref: forwardedRef
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
var CONTENT_NAME = "DialogContent";
|
|
337
|
+
var DialogContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
338
|
+
name: CONTENT_NAME,
|
|
339
|
+
zIndex: 2,
|
|
340
|
+
variants: {
|
|
341
|
+
size: {
|
|
342
|
+
"...size": function (val, extras) {
|
|
343
|
+
return {};
|
|
316
344
|
}
|
|
317
345
|
},
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
346
|
+
unstyled: {
|
|
347
|
+
false: {
|
|
348
|
+
position: "relative",
|
|
349
|
+
backgroundColor: "$background",
|
|
350
|
+
borderWidth: 1,
|
|
351
|
+
borderColor: "$borderColor",
|
|
352
|
+
padding: "$true",
|
|
353
|
+
borderRadius: "$true",
|
|
354
|
+
elevate: true,
|
|
355
|
+
// Ensure content receives pointer events (fixes React 19 + display:contents inheritance)
|
|
356
|
+
pointerEvents: "auto"
|
|
357
|
+
}
|
|
321
358
|
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
ref: forwardedRef
|
|
338
|
-
})
|
|
339
|
-
});
|
|
340
|
-
return !import_constants.isWeb || context.disableRemoveScroll ? contents : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_remove_scroll.RemoveScroll, {
|
|
341
|
-
enabled: context.open,
|
|
342
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)("div", {
|
|
343
|
-
"data-remove-scroll-container": !0,
|
|
344
|
-
className: "_dsp_contents",
|
|
345
|
-
children: contents
|
|
346
|
-
})
|
|
347
|
-
});
|
|
348
|
-
}),
|
|
349
|
-
DialogContentModal = /* @__PURE__ */React.forwardRef(function (param, forwardedRef) {
|
|
350
|
-
var {
|
|
351
|
-
children,
|
|
352
|
-
context,
|
|
353
|
-
...props
|
|
354
|
-
} = param,
|
|
355
|
-
contentRef = React.useRef(null),
|
|
356
|
-
composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.contentRef, contentRef);
|
|
357
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentImpl, {
|
|
359
|
+
},
|
|
360
|
+
defaultVariants: {
|
|
361
|
+
size: "$true",
|
|
362
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
var DialogContent = DialogContentFrame.styleable(function DialogContent2(param, forwardedRef) {
|
|
366
|
+
var {
|
|
367
|
+
scope,
|
|
368
|
+
...props
|
|
369
|
+
} = param;
|
|
370
|
+
var context = useDialogContext(scope);
|
|
371
|
+
var contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
372
|
+
children: context.modal ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentModal, {
|
|
373
|
+
context,
|
|
358
374
|
...props,
|
|
375
|
+
ref: forwardedRef
|
|
376
|
+
}) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentNonModal, {
|
|
359
377
|
context,
|
|
360
|
-
ref: composedRefs,
|
|
361
|
-
// we make sure focus isn't trapped once `DialogContent` has been closed
|
|
362
|
-
// (closed !== unmounted when animating out)
|
|
363
|
-
trapFocus: context.open,
|
|
364
|
-
disableOutsidePointerEvents: !0,
|
|
365
|
-
onCloseAutoFocus: (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, function (event) {
|
|
366
|
-
var _context_triggerRef_current;
|
|
367
|
-
event.preventDefault(), (_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 || _context_triggerRef_current.focus();
|
|
368
|
-
}),
|
|
369
|
-
onPointerDownOutside: (0, import_helpers.composeEventHandlers)(props.onPointerDownOutside, function (event) {
|
|
370
|
-
var originalEvent = event.detail.originalEvent,
|
|
371
|
-
ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0,
|
|
372
|
-
isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
373
|
-
isRightClick && event.preventDefault();
|
|
374
|
-
}),
|
|
375
|
-
// When focus is trapped, a `focusout` event may still happen.
|
|
376
|
-
// We make sure we don't trigger our `onDismiss` in such case.
|
|
377
|
-
onFocusOutside: (0, import_helpers.composeEventHandlers)(props.onFocusOutside, function (event) {
|
|
378
|
-
return event.preventDefault();
|
|
379
|
-
}),
|
|
380
|
-
...(!props.unstyled && {
|
|
381
|
-
outlineStyle: "none"
|
|
382
|
-
}),
|
|
383
|
-
children
|
|
384
|
-
});
|
|
385
|
-
}),
|
|
386
|
-
DialogContentNonModal = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
387
|
-
var hasInteractedOutsideRef = React.useRef(!1);
|
|
388
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentImpl, {
|
|
389
378
|
...props,
|
|
390
|
-
ref: forwardedRef
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
379
|
+
ref: forwardedRef
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
if (!import_constants.isWeb || context.disableRemoveScroll) {
|
|
383
|
+
return contents;
|
|
384
|
+
}
|
|
385
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_remove_scroll.RemoveScroll, {
|
|
386
|
+
enabled: context.open,
|
|
387
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)("div", {
|
|
388
|
+
"data-remove-scroll-container": true,
|
|
389
|
+
className: "_dsp_contents",
|
|
390
|
+
children: contents
|
|
391
|
+
})
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
var DialogContentModal = /* @__PURE__ */React.forwardRef(function (param, forwardedRef) {
|
|
395
|
+
var {
|
|
396
|
+
children,
|
|
397
|
+
context,
|
|
398
|
+
...props
|
|
399
|
+
} = param;
|
|
400
|
+
var contentRef = React.useRef(null);
|
|
401
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.contentRef, contentRef);
|
|
402
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentImpl, {
|
|
403
|
+
...props,
|
|
404
|
+
context,
|
|
405
|
+
ref: composedRefs,
|
|
406
|
+
// we make sure focus isn't trapped once `DialogContent` has been closed
|
|
407
|
+
// (closed !== unmounted when animating out)
|
|
408
|
+
trapFocus: context.open,
|
|
409
|
+
disableOutsidePointerEvents: true,
|
|
410
|
+
onCloseAutoFocus: (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, function (event) {
|
|
411
|
+
var _context_triggerRef_current;
|
|
412
|
+
event.preventDefault();
|
|
413
|
+
(_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 ? void 0 : _context_triggerRef_current.focus();
|
|
414
|
+
}),
|
|
415
|
+
onPointerDownOutside: (0, import_helpers.composeEventHandlers)(props.onPointerDownOutside, function (event) {
|
|
416
|
+
var originalEvent = event["detail"].originalEvent;
|
|
417
|
+
var ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
418
|
+
var isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
419
|
+
if (isRightClick) event.preventDefault();
|
|
420
|
+
}),
|
|
421
|
+
// When focus is trapped, a `focusout` event may still happen.
|
|
422
|
+
// We make sure we don't trigger our `onDismiss` in such case.
|
|
423
|
+
onFocusOutside: (0, import_helpers.composeEventHandlers)(props.onFocusOutside, function (event) {
|
|
424
|
+
return event.preventDefault();
|
|
425
|
+
}),
|
|
426
|
+
...(!props.unstyled && {
|
|
427
|
+
outlineStyle: "none"
|
|
428
|
+
}),
|
|
429
|
+
children
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
var DialogContentNonModal = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
433
|
+
var hasInteractedOutsideRef = React.useRef(false);
|
|
434
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentImpl, {
|
|
435
|
+
...props,
|
|
436
|
+
ref: forwardedRef,
|
|
437
|
+
trapFocus: false,
|
|
438
|
+
disableOutsidePointerEvents: false,
|
|
439
|
+
onCloseAutoFocus: function (event) {
|
|
440
|
+
var _props_onCloseAutoFocus;
|
|
441
|
+
(_props_onCloseAutoFocus = props.onCloseAutoFocus) === null || _props_onCloseAutoFocus === void 0 ? void 0 : _props_onCloseAutoFocus.call(props, event);
|
|
442
|
+
if (!event.defaultPrevented) {
|
|
443
|
+
if (!hasInteractedOutsideRef.current) {
|
|
444
|
+
var _props_context_triggerRef_current;
|
|
445
|
+
(_props_context_triggerRef_current = props.context.triggerRef.current) === null || _props_context_triggerRef_current === void 0 ? void 0 : _props_context_triggerRef_current.focus();
|
|
412
446
|
}
|
|
447
|
+
event.preventDefault();
|
|
413
448
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
449
|
+
hasInteractedOutsideRef.current = false;
|
|
450
|
+
},
|
|
451
|
+
onInteractOutside: function (event) {
|
|
452
|
+
var _props_onInteractOutside;
|
|
453
|
+
(_props_onInteractOutside = props.onInteractOutside) === null || _props_onInteractOutside === void 0 ? void 0 : _props_onInteractOutside.call(props, event);
|
|
454
|
+
if (!event.defaultPrevented) hasInteractedOutsideRef.current = true;
|
|
455
|
+
var target = event.target;
|
|
456
|
+
var trigger = props.context.triggerRef.current;
|
|
457
|
+
if (!_instanceof(trigger, HTMLElement)) return;
|
|
458
|
+
var targetIsTrigger = trigger.contains(target);
|
|
459
|
+
if (targetIsTrigger) event.preventDefault();
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
var DialogContentImpl = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
464
|
+
var {
|
|
465
|
+
trapFocus,
|
|
466
|
+
onOpenAutoFocus,
|
|
467
|
+
onCloseAutoFocus,
|
|
468
|
+
disableOutsidePointerEvents,
|
|
469
|
+
onEscapeKeyDown,
|
|
470
|
+
onPointerDownOutside,
|
|
471
|
+
onFocusOutside,
|
|
472
|
+
onInteractOutside,
|
|
473
|
+
context,
|
|
474
|
+
...contentProps
|
|
475
|
+
} = props;
|
|
476
|
+
var contentRef = React.useRef(null);
|
|
477
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
478
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
479
|
+
var isAdaptFullyHidden = React.useContext(DialogAdaptHiddenContext);
|
|
480
|
+
if (isAdapted) {
|
|
481
|
+
if (!context.open && !context.keepChildrenMounted && isAdaptFullyHidden) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogPortalItem, {
|
|
433
485
|
context,
|
|
434
486
|
children: contentProps.children
|
|
435
487
|
});
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
488
|
+
}
|
|
489
|
+
var contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogContentFrame, {
|
|
490
|
+
ref: composedRefs,
|
|
491
|
+
id: context.contentId,
|
|
492
|
+
role: "dialog",
|
|
493
|
+
"aria-modal": context.modal,
|
|
494
|
+
"aria-describedby": context.descriptionId,
|
|
495
|
+
"aria-labelledby": context.titleId,
|
|
496
|
+
"data-state": getState(context.open),
|
|
497
|
+
// allow clicking through content during exit animation
|
|
498
|
+
pointerEvents: context.open ? "auto" : "none",
|
|
499
|
+
...contentProps
|
|
500
|
+
});
|
|
501
|
+
if (!import_constants.isWeb) {
|
|
502
|
+
return contents;
|
|
503
|
+
}
|
|
504
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
505
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dismissable.Dismissable, {
|
|
506
|
+
disableOutsidePointerEvents: context.open && disableOutsidePointerEvents,
|
|
507
|
+
forceUnmount: !context.open,
|
|
508
|
+
onEscapeKeyDown,
|
|
509
|
+
onPointerDownOutside,
|
|
510
|
+
onFocusOutside,
|
|
511
|
+
onInteractOutside,
|
|
512
|
+
onDismiss: function () {
|
|
513
|
+
var _context_onOpenChange;
|
|
514
|
+
return context === null || context === void 0 ? void 0 : (_context_onOpenChange = context.onOpenChange) === null || _context_onOpenChange === void 0 ? void 0 : _context_onOpenChange.call(context, false);
|
|
515
|
+
},
|
|
516
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_focus_scope.FocusScope, {
|
|
517
|
+
loop: true,
|
|
518
|
+
enabled: context.open,
|
|
519
|
+
trapped: trapFocus,
|
|
520
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
451
521
|
forceUnmount: !context.open,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
onFocusOutside,
|
|
455
|
-
onInteractOutside,
|
|
456
|
-
onDismiss: function () {
|
|
457
|
-
var _context_onOpenChange;
|
|
458
|
-
return context == null || (_context_onOpenChange = context.onOpenChange) === null || _context_onOpenChange === void 0 ? void 0 : _context_onOpenChange.call(context, !1);
|
|
459
|
-
},
|
|
460
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_focus_scope.FocusScope, {
|
|
461
|
-
loop: !0,
|
|
462
|
-
enabled: context.open,
|
|
463
|
-
trapped: trapFocus,
|
|
464
|
-
onMountAutoFocus: onOpenAutoFocus,
|
|
465
|
-
forceUnmount: !context.open,
|
|
466
|
-
onUnmountAutoFocus: onCloseAutoFocus,
|
|
467
|
-
children: contents
|
|
468
|
-
})
|
|
469
|
-
}), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
470
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(TitleWarning, {
|
|
471
|
-
titleId: context.titleId
|
|
472
|
-
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
|
|
473
|
-
contentRef,
|
|
474
|
-
descriptionId: context.descriptionId
|
|
475
|
-
})]
|
|
476
|
-
})]
|
|
477
|
-
}) : contents;
|
|
478
|
-
}),
|
|
479
|
-
DialogTitleFrame = (0, import_core.styled)(import_text.H2, {
|
|
480
|
-
name: "DialogTitle"
|
|
481
|
-
}),
|
|
482
|
-
DialogTitle = DialogTitleFrame.styleable(function (props, forwardedRef) {
|
|
483
|
-
var {
|
|
484
|
-
scope,
|
|
485
|
-
...titleProps
|
|
486
|
-
} = props,
|
|
487
|
-
context = useDialogContext(scope);
|
|
488
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogTitleFrame, {
|
|
489
|
-
id: context.titleId,
|
|
490
|
-
...titleProps,
|
|
491
|
-
ref: forwardedRef
|
|
492
|
-
});
|
|
493
|
-
}),
|
|
494
|
-
DialogDescriptionFrame = (0, import_core.styled)(import_text.Paragraph, {
|
|
495
|
-
name: "DialogDescription"
|
|
496
|
-
}),
|
|
497
|
-
DialogDescription = DialogDescriptionFrame.styleable(function (props, forwardedRef) {
|
|
498
|
-
var {
|
|
499
|
-
scope,
|
|
500
|
-
...descriptionProps
|
|
501
|
-
} = props,
|
|
502
|
-
context = useDialogContext(scope);
|
|
503
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogDescriptionFrame, {
|
|
504
|
-
id: context.descriptionId,
|
|
505
|
-
...descriptionProps,
|
|
506
|
-
ref: forwardedRef
|
|
507
|
-
});
|
|
508
|
-
}),
|
|
509
|
-
CLOSE_NAME = "DialogClose",
|
|
510
|
-
DialogCloseFrame = (0, import_core.styled)(import_core.View, {
|
|
511
|
-
name: CLOSE_NAME,
|
|
512
|
-
render: "button"
|
|
513
|
-
}),
|
|
514
|
-
DialogClose = DialogCloseFrame.styleable(function (props, forwardedRef) {
|
|
515
|
-
var {
|
|
516
|
-
scope,
|
|
517
|
-
displayWhenAdapted,
|
|
518
|
-
...closeProps
|
|
519
|
-
} = props,
|
|
520
|
-
context = useDialogContext(scope),
|
|
521
|
-
isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope),
|
|
522
|
-
isInsideButton = React.useContext(import_stacks.ButtonNestingContext);
|
|
523
|
-
return isAdapted && !displayWhenAdapted ? null : /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogCloseFrame, {
|
|
524
|
-
"aria-label": "Dialog Close",
|
|
525
|
-
render: isInsideButton ? "span" : "button",
|
|
526
|
-
...closeProps,
|
|
527
|
-
ref: forwardedRef,
|
|
528
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, function () {
|
|
529
|
-
context.onOpenChange(!1);
|
|
522
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
523
|
+
children: contents
|
|
530
524
|
})
|
|
531
|
-
})
|
|
525
|
+
}), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
526
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(TitleWarning, {
|
|
527
|
+
titleId: context.titleId
|
|
528
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
|
|
529
|
+
contentRef,
|
|
530
|
+
descriptionId: context.descriptionId
|
|
531
|
+
})]
|
|
532
|
+
})]
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
var DialogTitleFrame = (0, import_core.styled)(import_text.H2, {
|
|
536
|
+
name: "DialogTitle"
|
|
537
|
+
});
|
|
538
|
+
var DialogTitle = DialogTitleFrame.styleable(function DialogTitle2(props, forwardedRef) {
|
|
539
|
+
var {
|
|
540
|
+
scope,
|
|
541
|
+
...titleProps
|
|
542
|
+
} = props;
|
|
543
|
+
var context = useDialogContext(scope);
|
|
544
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogTitleFrame, {
|
|
545
|
+
id: context.titleId,
|
|
546
|
+
...titleProps,
|
|
547
|
+
ref: forwardedRef
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
var DialogDescriptionFrame = (0, import_core.styled)(import_text.Paragraph, {
|
|
551
|
+
name: "DialogDescription"
|
|
552
|
+
});
|
|
553
|
+
var DialogDescription = DialogDescriptionFrame.styleable(function DialogDescription2(props, forwardedRef) {
|
|
554
|
+
var {
|
|
555
|
+
scope,
|
|
556
|
+
...descriptionProps
|
|
557
|
+
} = props;
|
|
558
|
+
var context = useDialogContext(scope);
|
|
559
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogDescriptionFrame, {
|
|
560
|
+
id: context.descriptionId,
|
|
561
|
+
...descriptionProps,
|
|
562
|
+
ref: forwardedRef
|
|
532
563
|
});
|
|
564
|
+
});
|
|
565
|
+
var CLOSE_NAME = "DialogClose";
|
|
566
|
+
var DialogCloseFrame = (0, import_core.styled)(import_core.View, {
|
|
567
|
+
name: CLOSE_NAME,
|
|
568
|
+
render: "button"
|
|
569
|
+
});
|
|
570
|
+
var DialogClose = DialogCloseFrame.styleable(function (props, forwardedRef) {
|
|
571
|
+
var {
|
|
572
|
+
scope,
|
|
573
|
+
displayWhenAdapted,
|
|
574
|
+
...closeProps
|
|
575
|
+
} = props;
|
|
576
|
+
var context = useDialogContext(scope);
|
|
577
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
578
|
+
var isInsideButton = React.useContext(import_stacks.ButtonNestingContext);
|
|
579
|
+
if (isAdapted && !displayWhenAdapted) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogCloseFrame, {
|
|
583
|
+
"aria-label": "Dialog Close",
|
|
584
|
+
render: isInsideButton ? "span" : "button",
|
|
585
|
+
...closeProps,
|
|
586
|
+
ref: forwardedRef,
|
|
587
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, function () {
|
|
588
|
+
context.onOpenChange(false);
|
|
589
|
+
})
|
|
590
|
+
});
|
|
591
|
+
});
|
|
533
592
|
function getState(open) {
|
|
534
593
|
return open ? "open" : "closed";
|
|
535
594
|
}
|
|
536
|
-
var TITLE_WARNING_NAME = "DialogTitleWarning"
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
595
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
596
|
+
var [DialogWarningProvider, useWarningContext] = (0, import_create_context.createContext)(TITLE_WARNING_NAME, {
|
|
597
|
+
contentName: CONTENT_NAME,
|
|
598
|
+
titleName: "DialogTitle",
|
|
599
|
+
docsSlug: "dialog"
|
|
600
|
+
});
|
|
601
|
+
var TitleWarning = function (param) {
|
|
602
|
+
var {
|
|
603
|
+
titleId
|
|
604
|
+
} = param;
|
|
605
|
+
if (process.env.NODE_ENV === "development") {
|
|
606
|
+
var titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
607
|
+
var MESSAGE = `\`${titleWarningContext.contentName}\` wants a \`${titleWarningContext.titleName}\` to be accessible. If you want to hide the \`${titleWarningContext.titleName}\`, wrap it with <VisuallyHidden />.`;
|
|
608
|
+
React.useEffect(function () {
|
|
609
|
+
if (!import_constants.isWeb) return;
|
|
610
|
+
if (titleId) {
|
|
611
|
+
var hasTitle = document.getElementById(titleId);
|
|
612
|
+
if (!hasTitle) {
|
|
613
|
+
console.warn(MESSAGE);
|
|
553
614
|
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
615
|
+
}
|
|
616
|
+
}, [MESSAGE, titleId]);
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
};
|
|
620
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
621
|
+
var DescriptionWarning = function (param) {
|
|
622
|
+
var {
|
|
623
|
+
contentRef,
|
|
624
|
+
descriptionId
|
|
625
|
+
} = param;
|
|
626
|
+
if (process.env.NODE_ENV === "development") {
|
|
627
|
+
var descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
628
|
+
var MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
629
|
+
React.useEffect(function () {
|
|
630
|
+
if (!import_constants.isWeb) return;
|
|
631
|
+
var contentNode = contentRef.current;
|
|
632
|
+
if (!_instanceof(contentNode, HTMLElement)) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
var describedById = contentNode.getAttribute("aria-describedby");
|
|
636
|
+
if (descriptionId && describedById) {
|
|
637
|
+
var hasDescription = document.getElementById(descriptionId);
|
|
638
|
+
if (!hasDescription) {
|
|
639
|
+
console.warn(MESSAGE);
|
|
577
640
|
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
641
|
+
}
|
|
642
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
643
|
+
}
|
|
644
|
+
return null;
|
|
645
|
+
};
|
|
646
|
+
var Dialog = (0, import_helpers.withStaticProperties)(/* @__PURE__ */React.forwardRef(function Dialog2(props, ref) {
|
|
647
|
+
var {
|
|
648
|
+
scope = "",
|
|
649
|
+
children,
|
|
650
|
+
open: openProp,
|
|
651
|
+
defaultOpen = false,
|
|
652
|
+
onOpenChange,
|
|
653
|
+
modal = true,
|
|
654
|
+
keepChildrenMounted,
|
|
655
|
+
disableRemoveScroll = false,
|
|
656
|
+
onAnimationComplete
|
|
657
|
+
} = props;
|
|
658
|
+
var baseId = React.useId();
|
|
659
|
+
var dialogId = `Dialog-${scope}-${baseId}`;
|
|
660
|
+
var contentId = `${dialogId}-content`;
|
|
661
|
+
var titleId = `${dialogId}-title`;
|
|
662
|
+
var descriptionId = `${dialogId}-description`;
|
|
663
|
+
var triggerRef = React.useRef(null);
|
|
664
|
+
var contentRef = React.useRef(null);
|
|
665
|
+
var [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
666
|
+
prop: openProp,
|
|
667
|
+
defaultProp: defaultOpen,
|
|
668
|
+
onChange: onOpenChange
|
|
669
|
+
});
|
|
670
|
+
var onOpenToggle = React.useCallback(function () {
|
|
671
|
+
setOpen(function (prevOpen) {
|
|
672
|
+
return !prevOpen;
|
|
673
|
+
});
|
|
674
|
+
}, [setOpen]);
|
|
675
|
+
var adaptScope = `DialogAdapt${scope}`;
|
|
676
|
+
var context = {
|
|
677
|
+
dialogScope: scope,
|
|
678
|
+
adaptScope,
|
|
679
|
+
triggerRef,
|
|
680
|
+
contentRef,
|
|
681
|
+
contentId,
|
|
682
|
+
titleId,
|
|
683
|
+
descriptionId,
|
|
684
|
+
open,
|
|
685
|
+
onOpenChange: setOpen,
|
|
686
|
+
onOpenToggle,
|
|
687
|
+
modal,
|
|
688
|
+
keepChildrenMounted,
|
|
689
|
+
disableRemoveScroll,
|
|
690
|
+
onAnimationComplete
|
|
691
|
+
};
|
|
692
|
+
React.useImperativeHandle(ref, function () {
|
|
693
|
+
return {
|
|
694
|
+
open: setOpen
|
|
695
|
+
};
|
|
696
|
+
}, [setOpen]);
|
|
697
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
698
|
+
scope: adaptScope,
|
|
699
|
+
portal: {
|
|
700
|
+
forwardProps: props
|
|
701
|
+
},
|
|
702
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogProvider, {
|
|
703
|
+
scope,
|
|
704
|
+
...context,
|
|
705
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogSheetController, {
|
|
620
706
|
onOpenChange: setOpen,
|
|
621
|
-
onOpenToggle,
|
|
622
|
-
modal,
|
|
623
|
-
keepChildrenMounted,
|
|
624
|
-
disableRemoveScroll
|
|
625
|
-
};
|
|
626
|
-
return React.useImperativeHandle(ref, function () {
|
|
627
|
-
return {
|
|
628
|
-
open: setOpen
|
|
629
|
-
};
|
|
630
|
-
}, [setOpen]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
631
|
-
scope: adaptScope,
|
|
632
|
-
portal: {
|
|
633
|
-
forwardProps: props
|
|
634
|
-
},
|
|
635
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogProvider, {
|
|
636
707
|
scope,
|
|
637
|
-
|
|
638
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogSheetController, {
|
|
639
|
-
onOpenChange: setOpen,
|
|
640
|
-
scope,
|
|
641
|
-
children
|
|
642
|
-
})
|
|
708
|
+
children
|
|
643
709
|
})
|
|
644
|
-
})
|
|
645
|
-
}), {
|
|
646
|
-
Trigger: DialogTrigger,
|
|
647
|
-
Portal: DialogPortal,
|
|
648
|
-
Overlay: DialogOverlay,
|
|
649
|
-
Content: DialogContent,
|
|
650
|
-
Title: DialogTitle,
|
|
651
|
-
Description: DialogDescription,
|
|
652
|
-
Close: DialogClose,
|
|
653
|
-
FocusScope: import_focus_scope.FocusScopeController,
|
|
654
|
-
Adapt: import_adapt.Adapt
|
|
710
|
+
})
|
|
655
711
|
});
|
|
712
|
+
}), {
|
|
713
|
+
Trigger: DialogTrigger,
|
|
714
|
+
Portal: DialogPortal,
|
|
715
|
+
Overlay: DialogOverlay,
|
|
716
|
+
Content: DialogContent,
|
|
717
|
+
Title: DialogTitle,
|
|
718
|
+
Description: DialogDescription,
|
|
719
|
+
Close: DialogClose,
|
|
720
|
+
FocusScope: import_focus_scope.FocusScopeController,
|
|
721
|
+
Adapt: import_adapt.Adapt
|
|
722
|
+
});
|
|
656
723
|
var DialogSheetController = function (props) {
|
|
657
|
-
var context = useDialogContext(props.scope)
|
|
658
|
-
|
|
724
|
+
var context = useDialogContext(props.scope);
|
|
725
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
726
|
+
var [isAdaptFullyHidden, setIsAdaptFullyHidden] = React.useState(!context.open);
|
|
727
|
+
if (context.open && isAdaptFullyHidden) {
|
|
728
|
+
setIsAdaptFullyHidden(false);
|
|
729
|
+
}
|
|
730
|
+
var handleSheetAnimationComplete = React.useCallback(function (param) {
|
|
731
|
+
var {
|
|
732
|
+
open
|
|
733
|
+
} = param;
|
|
734
|
+
if (!open) {
|
|
735
|
+
setIsAdaptFullyHidden(true);
|
|
736
|
+
}
|
|
737
|
+
}, []);
|
|
659
738
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_controller.SheetController, {
|
|
660
739
|
onOpenChange: function (val) {
|
|
661
740
|
if (isAdapted) {
|
|
662
741
|
var _props_onOpenChange;
|
|
663
|
-
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0
|
|
742
|
+
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 ? void 0 : _props_onOpenChange.call(props, val);
|
|
664
743
|
}
|
|
665
744
|
},
|
|
745
|
+
onAnimationComplete: handleSheetAnimationComplete,
|
|
666
746
|
open: context.open,
|
|
667
747
|
hidden: !isAdapted,
|
|
668
|
-
children:
|
|
748
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DialogAdaptHiddenContext.Provider, {
|
|
749
|
+
value: isAdaptFullyHidden,
|
|
750
|
+
children: props.children
|
|
751
|
+
})
|
|
669
752
|
});
|
|
670
753
|
};
|
|
671
754
|
//# sourceMappingURL=Dialog.native.js.map
|