@tamagui/dialog 1.116.0 → 1.116.2
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.
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
+
mod
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
+
var Dialog_exports = {};
|
|
24
|
+
__export(Dialog_exports, {
|
|
25
|
+
Dialog: () => Dialog,
|
|
26
|
+
DialogClose: () => DialogClose,
|
|
27
|
+
DialogContent: () => DialogContent,
|
|
28
|
+
DialogDescription: () => DialogDescription,
|
|
29
|
+
DialogOverlay: () => DialogOverlay,
|
|
30
|
+
DialogOverlayFrame: () => DialogOverlayFrame,
|
|
31
|
+
DialogPortal: () => DialogPortal,
|
|
32
|
+
DialogPortalFrame: () => DialogPortalFrame,
|
|
33
|
+
DialogTitle: () => DialogTitle,
|
|
34
|
+
DialogTrigger: () => DialogTrigger,
|
|
35
|
+
DialogWarningProvider: () => DialogWarningProvider,
|
|
36
|
+
createDialogScope: () => createDialogScope
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(Dialog_exports);
|
|
39
|
+
var import_adapt = require("@tamagui/adapt"), import_animate_presence = require("@tamagui/animate-presence"), import_aria_hidden = require("@tamagui/aria-hidden"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_dismissable = require("@tamagui/dismissable"), import_focus_scope = require("@tamagui/focus-scope"), import_helpers = require("@tamagui/helpers"), import_portal = require("@tamagui/portal"), import_remove_scroll = require("@tamagui/remove-scroll"), import_sheet = require("@tamagui/sheet"), import_stacks = require("@tamagui/stacks"), import_text = require("@tamagui/text"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
const DIALOG_NAME = "Dialog", [createDialogContext, createDialogScope] = (0, import_create_context.createContextScope)(DIALOG_NAME), [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME), TRIGGER_NAME = "DialogTrigger", DialogTriggerFrame = (0, import_core.styled)(import_core.View, {
|
|
41
|
+
name: TRIGGER_NAME
|
|
42
|
+
}), DialogTrigger = DialogTriggerFrame.styleable(function(props, forwardedRef) {
|
|
43
|
+
const { __scopeDialog, ...triggerProps } = props, isInsideButton = React.useContext(import_stacks.ButtonNestingContext), context = useDialogContext(TRIGGER_NAME, __scopeDialog), composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, { value: !0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
DialogTriggerFrame,
|
|
46
|
+
{
|
|
47
|
+
tag: isInsideButton ? "span" : "button",
|
|
48
|
+
"aria-haspopup": "dialog",
|
|
49
|
+
"aria-expanded": context.open,
|
|
50
|
+
"aria-controls": context.contentId,
|
|
51
|
+
"data-state": getState(context.open),
|
|
52
|
+
...triggerProps,
|
|
53
|
+
ref: composedTriggerRef,
|
|
54
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
55
|
+
}
|
|
56
|
+
) });
|
|
57
|
+
}), PORTAL_NAME = "DialogPortal", [PortalProvider, usePortalContext] = createDialogContext(
|
|
58
|
+
PORTAL_NAME,
|
|
59
|
+
{
|
|
60
|
+
forceMount: void 0
|
|
61
|
+
}
|
|
62
|
+
), DialogPortalFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
63
|
+
pointerEvents: "none",
|
|
64
|
+
variants: {
|
|
65
|
+
unstyled: {
|
|
66
|
+
false: {
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
fullscreen: !0,
|
|
70
|
+
zIndex: 1e5,
|
|
71
|
+
...import_constants.isWeb && {
|
|
72
|
+
maxHeight: "100vh",
|
|
73
|
+
position: "fixed"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
80
|
+
}
|
|
81
|
+
}), DialogPortalItem = (props) => {
|
|
82
|
+
const { __scopeDialog, children, space, spaceDirection, separator } = props, themeName = (0, import_core.useThemeName)(), context = useDialogContext(PORTAL_NAME, props.__scopeDialog);
|
|
83
|
+
let childrenSpaced = children;
|
|
84
|
+
return (space || separator) && (childrenSpaced = (0, import_core.spacedChildren)({
|
|
85
|
+
children,
|
|
86
|
+
separator,
|
|
87
|
+
space,
|
|
88
|
+
direction: spaceDirection
|
|
89
|
+
})), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogProvider, { scope: __scopeDialog, ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { name: themeName, children: childrenSpaced }) }) });
|
|
90
|
+
}, DialogPortal = (props) => {
|
|
91
|
+
const { __scopeDialog, forceMount, children, ...frameProps } = props, context = useDialogContext(PORTAL_NAME, __scopeDialog), isShowing = forceMount || context.open, [isFullyHidden, setIsFullyHidden] = React.useState(!isShowing);
|
|
92
|
+
isShowing && isFullyHidden && setIsFullyHidden(!1);
|
|
93
|
+
const handleExitComplete = React.useCallback(() => {
|
|
94
|
+
setIsFullyHidden(!0);
|
|
95
|
+
}, []), contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { onExitComplete: handleExitComplete, children: isShowing ? children : null });
|
|
96
|
+
if ((0, import_adapt.useAdaptIsActive)())
|
|
97
|
+
return children;
|
|
98
|
+
if (context.modal) {
|
|
99
|
+
if (isFullyHidden)
|
|
100
|
+
return null;
|
|
101
|
+
const framedContents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopeDialog, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalFrame, { pointerEvents: isShowing ? "auto" : "none", ...frameProps, children: contents }) });
|
|
102
|
+
return import_constants.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { zIndex: props.zIndex ?? 1e5, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PassthroughTheme, { children: framedContents }) }) : framedContents;
|
|
103
|
+
}
|
|
104
|
+
return contents;
|
|
105
|
+
}, PassthroughTheme = ({ children }) => {
|
|
106
|
+
const themeName = (0, import_core.useThemeName)();
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { name: themeName, forceClassName: !0, children });
|
|
108
|
+
}, OVERLAY_NAME = "DialogOverlay", DialogOverlayFrame = (0, import_core.styled)(import_sheet.Overlay, {
|
|
109
|
+
name: OVERLAY_NAME
|
|
110
|
+
}), DialogOverlay = DialogOverlayFrame.extractable(
|
|
111
|
+
React.forwardRef(function({ __scopeDialog, ...props }, forwardedRef) {
|
|
112
|
+
const portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...overlayProps } = props, context = useDialogContext(OVERLAY_NAME, __scopeDialog), isAdapted = (0, import_adapt.useAdaptIsActive)();
|
|
113
|
+
return !forceMount && (!context.modal || isAdapted) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
|
+
DialogOverlayFrame,
|
|
115
|
+
{
|
|
116
|
+
"data-state": getState(context.open),
|
|
117
|
+
pointerEvents: context.open ? "auto" : "none",
|
|
118
|
+
...overlayProps,
|
|
119
|
+
ref: forwardedRef
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
})
|
|
123
|
+
), CONTENT_NAME = "DialogContent", DialogContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
124
|
+
name: CONTENT_NAME,
|
|
125
|
+
tag: "dialog",
|
|
126
|
+
variants: {
|
|
127
|
+
size: {
|
|
128
|
+
"...size": (val, extras) => ({})
|
|
129
|
+
},
|
|
130
|
+
unstyled: {
|
|
131
|
+
false: {
|
|
132
|
+
position: "relative",
|
|
133
|
+
backgrounded: !0,
|
|
134
|
+
padded: !0,
|
|
135
|
+
radiused: !0,
|
|
136
|
+
elevate: !0,
|
|
137
|
+
zIndex: 1e5
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
defaultVariants: {
|
|
142
|
+
size: "$true",
|
|
143
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
144
|
+
}
|
|
145
|
+
}), DialogContent = DialogContentFrame.extractable(
|
|
146
|
+
React.forwardRef(function({ __scopeDialog, ...props }, forwardedRef) {
|
|
147
|
+
const portalContext = usePortalContext(CONTENT_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...contentProps } = props, context = useDialogContext(CONTENT_NAME, __scopeDialog), contents = context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentModal, { context, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContentNonModal, { context, ...contentProps, ref: forwardedRef });
|
|
148
|
+
return !import_constants.isWeb || context.disableRemoveScroll ? contents : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
149
|
+
import_remove_scroll.RemoveScroll,
|
|
150
|
+
{
|
|
151
|
+
forwardProps: !0,
|
|
152
|
+
enabled: context.open,
|
|
153
|
+
allowPinchZoom: context.allowPinchZoom,
|
|
154
|
+
shards: [context.contentRef],
|
|
155
|
+
removeScrollBar: !1,
|
|
156
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-remove-scroll-container": !0, className: "_dsp_contents", children: contents })
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
})
|
|
160
|
+
), DialogContentModal = React.forwardRef(
|
|
161
|
+
({ children, context, ...props }, forwardedRef) => {
|
|
162
|
+
const contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.contentRef, contentRef);
|
|
163
|
+
return import_constants.isWeb && React.useEffect(() => {
|
|
164
|
+
if (!context.open) return;
|
|
165
|
+
const content = contentRef.current;
|
|
166
|
+
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
167
|
+
}, [context.open]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
+
DialogContentImpl,
|
|
169
|
+
{
|
|
170
|
+
...props,
|
|
171
|
+
context,
|
|
172
|
+
ref: composedRefs,
|
|
173
|
+
trapFocus: context.open,
|
|
174
|
+
disableOutsidePointerEvents: !0,
|
|
175
|
+
onCloseAutoFocus: (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
176
|
+
event.preventDefault(), context.triggerRef.current?.focus();
|
|
177
|
+
}),
|
|
178
|
+
onPointerDownOutside: (0, import_helpers.composeEventHandlers)(
|
|
179
|
+
props.onPointerDownOutside,
|
|
180
|
+
(event) => {
|
|
181
|
+
const originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0;
|
|
182
|
+
(originalEvent.button === 2 || ctrlLeftClick) && event.preventDefault();
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
onFocusOutside: (0, import_helpers.composeEventHandlers)(
|
|
186
|
+
props.onFocusOutside,
|
|
187
|
+
(event) => event.preventDefault()
|
|
188
|
+
),
|
|
189
|
+
...!props.unstyled && {
|
|
190
|
+
outlineStyle: "none"
|
|
191
|
+
},
|
|
192
|
+
children
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
), DialogContentNonModal = React.forwardRef(
|
|
197
|
+
(props, forwardedRef) => {
|
|
198
|
+
const hasInteractedOutsideRef = React.useRef(!1);
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
200
|
+
DialogContentImpl,
|
|
201
|
+
{
|
|
202
|
+
...props,
|
|
203
|
+
ref: forwardedRef,
|
|
204
|
+
trapFocus: !1,
|
|
205
|
+
disableOutsidePointerEvents: !1,
|
|
206
|
+
onCloseAutoFocus: (event) => {
|
|
207
|
+
props.onCloseAutoFocus?.(event), event.defaultPrevented || (hasInteractedOutsideRef.current || props.context.triggerRef.current?.focus(), event.preventDefault()), hasInteractedOutsideRef.current = !1;
|
|
208
|
+
},
|
|
209
|
+
onInteractOutside: (event) => {
|
|
210
|
+
props.onInteractOutside?.(event), event.defaultPrevented || (hasInteractedOutsideRef.current = !0);
|
|
211
|
+
const target = event.target, trigger = props.context.triggerRef.current;
|
|
212
|
+
if (!(trigger instanceof HTMLElement)) return;
|
|
213
|
+
trigger.contains(target) && event.preventDefault();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
), DialogContentImpl = React.forwardRef(
|
|
219
|
+
(props, forwardedRef) => {
|
|
220
|
+
const {
|
|
221
|
+
__scopeDialog,
|
|
222
|
+
trapFocus,
|
|
223
|
+
onOpenAutoFocus,
|
|
224
|
+
onCloseAutoFocus,
|
|
225
|
+
disableOutsidePointerEvents,
|
|
226
|
+
onEscapeKeyDown,
|
|
227
|
+
onPointerDownOutside,
|
|
228
|
+
onFocusOutside,
|
|
229
|
+
onInteractOutside,
|
|
230
|
+
context,
|
|
231
|
+
...contentProps
|
|
232
|
+
} = props, contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
233
|
+
if ((0, import_adapt.useAdaptIsActive)())
|
|
234
|
+
return !import_constants.isWeb && !context.open ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPortalItem, { children: contentProps.children });
|
|
235
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
236
|
+
DialogContentFrame,
|
|
237
|
+
{
|
|
238
|
+
id: context.contentId,
|
|
239
|
+
"aria-describedby": context.descriptionId,
|
|
240
|
+
"aria-labelledby": context.titleId,
|
|
241
|
+
"data-state": getState(context.open),
|
|
242
|
+
...contentProps
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
return import_constants.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
+
import_dismissable.Dismissable,
|
|
248
|
+
{
|
|
249
|
+
disableOutsidePointerEvents: context.open && disableOutsidePointerEvents,
|
|
250
|
+
forceUnmount: !context.open,
|
|
251
|
+
onEscapeKeyDown,
|
|
252
|
+
onPointerDownOutside,
|
|
253
|
+
onFocusOutside,
|
|
254
|
+
onInteractOutside,
|
|
255
|
+
ref: composedRefs,
|
|
256
|
+
onDismiss: () => context.onOpenChange(!1),
|
|
257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
258
|
+
import_focus_scope.FocusScope,
|
|
259
|
+
{
|
|
260
|
+
loop: !0,
|
|
261
|
+
enabled: context.open,
|
|
262
|
+
trapped: trapFocus,
|
|
263
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
264
|
+
forceUnmount: !context.open,
|
|
265
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
266
|
+
children: contents
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
process.env.NODE_ENV === "development" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
272
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TitleWarning, { titleId: context.titleId }),
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
274
|
+
DescriptionWarning,
|
|
275
|
+
{
|
|
276
|
+
contentRef,
|
|
277
|
+
descriptionId: context.descriptionId
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
] })
|
|
281
|
+
] }) : contents;
|
|
282
|
+
}
|
|
283
|
+
), DialogTitleFrame = (0, import_core.styled)(import_text.H2, {
|
|
284
|
+
name: "DialogTitle"
|
|
285
|
+
}), DialogTitle = DialogTitleFrame.styleable(function(props, forwardedRef) {
|
|
286
|
+
const { __scopeDialog, ...titleProps } = props, context = useDialogContext("DialogTitle", __scopeDialog);
|
|
287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitleFrame, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
288
|
+
}), DialogDescriptionFrame = (0, import_core.styled)(import_text.Paragraph, {
|
|
289
|
+
name: "DialogDescription"
|
|
290
|
+
}), DESCRIPTION_NAME = "DialogDescription", DialogDescription = DialogDescriptionFrame.styleable(function(props, forwardedRef) {
|
|
291
|
+
const { __scopeDialog, ...descriptionProps } = props, context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
293
|
+
DialogDescriptionFrame,
|
|
294
|
+
{
|
|
295
|
+
id: context.descriptionId,
|
|
296
|
+
...descriptionProps,
|
|
297
|
+
ref: forwardedRef
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}), CLOSE_NAME = "DialogClose", DialogCloseFrame = (0, import_core.styled)(import_core.View, {
|
|
301
|
+
name: CLOSE_NAME,
|
|
302
|
+
tag: "button"
|
|
303
|
+
}), DialogClose = DialogCloseFrame.styleable(
|
|
304
|
+
(props, forwardedRef) => {
|
|
305
|
+
const { __scopeDialog, displayWhenAdapted, ...closeProps } = props, context = useDialogContext(CLOSE_NAME, __scopeDialog, {
|
|
306
|
+
warn: !1,
|
|
307
|
+
fallback: {}
|
|
308
|
+
}), isAdapted = (0, import_adapt.useAdaptIsActive)(), isInsideButton = React.useContext(import_stacks.ButtonNestingContext);
|
|
309
|
+
return isAdapted && !displayWhenAdapted ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
310
|
+
DialogCloseFrame,
|
|
311
|
+
{
|
|
312
|
+
accessibilityLabel: "Dialog Close",
|
|
313
|
+
tag: isInsideButton ? "span" : "button",
|
|
314
|
+
...closeProps,
|
|
315
|
+
ref: forwardedRef,
|
|
316
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, () => {
|
|
317
|
+
context.onOpenChange(!1);
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
function getState(open) {
|
|
324
|
+
return open ? "open" : "closed";
|
|
325
|
+
}
|
|
326
|
+
const TITLE_WARNING_NAME = "DialogTitleWarning", [DialogWarningProvider, useWarningContext] = (0, import_create_context.createContext)(TITLE_WARNING_NAME, {
|
|
327
|
+
contentName: CONTENT_NAME,
|
|
328
|
+
titleName: "DialogTitle",
|
|
329
|
+
docsSlug: "dialog"
|
|
330
|
+
}), TitleWarning = ({ titleId }) => {
|
|
331
|
+
if (process.env.NODE_ENV === "development") {
|
|
332
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME), MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
333
|
+
|
|
334
|
+
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.`;
|
|
335
|
+
React.useEffect(() => {
|
|
336
|
+
import_constants.isWeb && titleId && (document.getElementById(titleId) || console.warn(MESSAGE));
|
|
337
|
+
}, [MESSAGE, titleId]);
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}, DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning", DescriptionWarning = ({
|
|
341
|
+
contentRef,
|
|
342
|
+
descriptionId
|
|
343
|
+
}) => {
|
|
344
|
+
if (process.env.NODE_ENV === "development") {
|
|
345
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${useWarningContext(DESCRIPTION_WARNING_NAME).contentName}}.`;
|
|
346
|
+
React.useEffect(() => {
|
|
347
|
+
if (!import_constants.isWeb) return;
|
|
348
|
+
const contentNode = contentRef.current;
|
|
349
|
+
if (!(contentNode instanceof HTMLElement))
|
|
350
|
+
return;
|
|
351
|
+
const describedById = contentNode.getAttribute("aria-describedby");
|
|
352
|
+
descriptionId && describedById && (document.getElementById(descriptionId) || console.warn(MESSAGE));
|
|
353
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
354
|
+
}
|
|
355
|
+
return null;
|
|
356
|
+
}, Dialog = (0, import_helpers.withStaticProperties)(
|
|
357
|
+
React.forwardRef(function(props, ref) {
|
|
358
|
+
const {
|
|
359
|
+
__scopeDialog,
|
|
360
|
+
children,
|
|
361
|
+
open: openProp,
|
|
362
|
+
defaultOpen = !1,
|
|
363
|
+
onOpenChange,
|
|
364
|
+
modal = !0,
|
|
365
|
+
allowPinchZoom = !1,
|
|
366
|
+
disableRemoveScroll = !1
|
|
367
|
+
} = props, baseId = React.useId(), scopeId = `scope-${baseId}`, contentId = `content-${baseId}`, titleId = `title-${baseId}`, descriptionId = `description-${baseId}`, scopeKey = __scopeDialog ? Object.keys(__scopeDialog)[0] : scopeId, adaptName = getAdaptName({ scopeKey, contentId }), triggerRef = React.useRef(null), contentRef = React.useRef(null), [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
368
|
+
prop: openProp,
|
|
369
|
+
defaultProp: defaultOpen,
|
|
370
|
+
onChange: onOpenChange
|
|
371
|
+
}), onOpenToggle = React.useCallback(() => {
|
|
372
|
+
setOpen((prevOpen) => !prevOpen);
|
|
373
|
+
}, [setOpen]), context = {
|
|
374
|
+
scope: __scopeDialog,
|
|
375
|
+
scopeKey,
|
|
376
|
+
triggerRef,
|
|
377
|
+
contentRef,
|
|
378
|
+
contentId,
|
|
379
|
+
titleId,
|
|
380
|
+
descriptionId,
|
|
381
|
+
open,
|
|
382
|
+
onOpenChange: setOpen,
|
|
383
|
+
onOpenToggle,
|
|
384
|
+
modal,
|
|
385
|
+
allowPinchZoom,
|
|
386
|
+
disableRemoveScroll
|
|
387
|
+
};
|
|
388
|
+
return React.useImperativeHandle(
|
|
389
|
+
ref,
|
|
390
|
+
() => ({
|
|
391
|
+
open: setOpen
|
|
392
|
+
}),
|
|
393
|
+
[setOpen]
|
|
394
|
+
), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
395
|
+
import_adapt.AdaptParent,
|
|
396
|
+
{
|
|
397
|
+
scope: adaptName,
|
|
398
|
+
portal: {
|
|
399
|
+
forwardProps: props
|
|
400
|
+
},
|
|
401
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogProvider, { ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogSheetController, { onOpenChange: setOpen, __scopeDialog, children }) })
|
|
402
|
+
}
|
|
403
|
+
);
|
|
404
|
+
}),
|
|
405
|
+
{
|
|
406
|
+
Trigger: DialogTrigger,
|
|
407
|
+
Portal: DialogPortal,
|
|
408
|
+
Overlay: DialogOverlay,
|
|
409
|
+
Content: DialogContent,
|
|
410
|
+
Title: DialogTitle,
|
|
411
|
+
Description: DialogDescription,
|
|
412
|
+
Close: DialogClose,
|
|
413
|
+
Sheet: import_sheet.Sheet.Controlled,
|
|
414
|
+
Adapt: import_adapt.Adapt
|
|
415
|
+
}
|
|
416
|
+
), getAdaptName = ({
|
|
417
|
+
scopeKey,
|
|
418
|
+
contentId
|
|
419
|
+
}) => `${scopeKey || contentId}DialogAdapt`, DialogSheetController = (props) => {
|
|
420
|
+
const context = useDialogContext("DialogSheetController", props.__scopeDialog), isAdapted = (0, import_adapt.useAdaptIsActive)();
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
422
|
+
import_sheet.SheetController,
|
|
423
|
+
{
|
|
424
|
+
onOpenChange: (val) => {
|
|
425
|
+
isAdapted && props.onOpenChange?.(val);
|
|
426
|
+
},
|
|
427
|
+
open: context.open,
|
|
428
|
+
hidden: !isAdapted,
|
|
429
|
+
children: props.children
|
|
430
|
+
}
|
|
431
|
+
);
|
|
432
|
+
};
|
|
433
|
+
//# sourceMappingURL=Dialog.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
return to;
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var src_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(src_exports);
|
|
14
|
+
__reExport(src_exports, require("./Dialog"), module.exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/dialog",
|
|
3
|
-
"version": "1.116.
|
|
3
|
+
"version": "1.116.2",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -34,30 +34,30 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tamagui/adapt": "1.116.
|
|
38
|
-
"@tamagui/animate-presence": "1.116.
|
|
39
|
-
"@tamagui/aria-hidden": "1.116.
|
|
40
|
-
"@tamagui/compose-refs": "1.116.
|
|
41
|
-
"@tamagui/constants": "1.116.
|
|
42
|
-
"@tamagui/core": "1.116.
|
|
43
|
-
"@tamagui/create-context": "1.116.
|
|
44
|
-
"@tamagui/dismissable": "1.116.
|
|
45
|
-
"@tamagui/focus-scope": "1.116.
|
|
46
|
-
"@tamagui/helpers": "1.116.
|
|
47
|
-
"@tamagui/polyfill-dev": "1.116.
|
|
48
|
-
"@tamagui/popper": "1.116.
|
|
49
|
-
"@tamagui/portal": "1.116.
|
|
50
|
-
"@tamagui/remove-scroll": "1.116.
|
|
51
|
-
"@tamagui/sheet": "1.116.
|
|
52
|
-
"@tamagui/stacks": "1.116.
|
|
53
|
-
"@tamagui/text": "1.116.
|
|
54
|
-
"@tamagui/use-controllable-state": "1.116.
|
|
37
|
+
"@tamagui/adapt": "1.116.2",
|
|
38
|
+
"@tamagui/animate-presence": "1.116.2",
|
|
39
|
+
"@tamagui/aria-hidden": "1.116.2",
|
|
40
|
+
"@tamagui/compose-refs": "1.116.2",
|
|
41
|
+
"@tamagui/constants": "1.116.2",
|
|
42
|
+
"@tamagui/core": "1.116.2",
|
|
43
|
+
"@tamagui/create-context": "1.116.2",
|
|
44
|
+
"@tamagui/dismissable": "1.116.2",
|
|
45
|
+
"@tamagui/focus-scope": "1.116.2",
|
|
46
|
+
"@tamagui/helpers": "1.116.2",
|
|
47
|
+
"@tamagui/polyfill-dev": "1.116.2",
|
|
48
|
+
"@tamagui/popper": "1.116.2",
|
|
49
|
+
"@tamagui/portal": "1.116.2",
|
|
50
|
+
"@tamagui/remove-scroll": "1.116.2",
|
|
51
|
+
"@tamagui/sheet": "1.116.2",
|
|
52
|
+
"@tamagui/stacks": "1.116.2",
|
|
53
|
+
"@tamagui/text": "1.116.2",
|
|
54
|
+
"@tamagui/use-controllable-state": "1.116.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "*"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@tamagui/build": "1.116.
|
|
60
|
+
"@tamagui/build": "1.116.2",
|
|
61
61
|
"react": "^18.2.0 || ^19.0.0",
|
|
62
62
|
"react-native": "0.74.1"
|
|
63
63
|
},
|
|
File without changes
|
|
File without changes
|