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