@tamagui/alert-dialog 2.7.7 → 3.0.0-beta.1091.1
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/AlertDialog.cjs +178 -234
- package/dist/cjs/AlertDialog.native.cjs +234 -0
- package/dist/cjs/AlertDialog.native.js +182 -324
- package/dist/cjs/AlertDialog.native.js.map +1 -1
- package/dist/cjs/alertDialogPart.cjs +30 -0
- package/dist/cjs/alertDialogPart.native.cjs +32 -0
- package/dist/cjs/alertDialogPart.native.js +34 -0
- package/dist/cjs/alertDialogPart.native.js.map +1 -0
- package/dist/cjs/index.cjs +9 -11
- package/dist/cjs/index.native.cjs +20 -0
- package/dist/cjs/index.native.js +9 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useNativeAlertDialog.cjs +24 -0
- package/dist/cjs/useNativeAlertDialog.native.cjs +139 -0
- package/dist/cjs/useNativeAlertDialog.native.js +141 -0
- package/dist/cjs/useNativeAlertDialog.native.js.map +1 -0
- package/dist/esm/AlertDialog.mjs +153 -187
- package/dist/esm/AlertDialog.mjs.map +1 -1
- package/dist/esm/AlertDialog.native.js +158 -292
- package/dist/esm/AlertDialog.native.js.map +1 -1
- package/dist/esm/alertDialogPart.mjs +7 -0
- package/dist/esm/alertDialogPart.mjs.map +1 -0
- package/dist/esm/alertDialogPart.native.js +7 -0
- package/dist/esm/alertDialogPart.native.js.map +1 -0
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/esm/useNativeAlertDialog.mjs +4 -0
- package/dist/esm/useNativeAlertDialog.mjs.map +1 -0
- package/dist/esm/useNativeAlertDialog.native.js +112 -0
- package/dist/esm/useNativeAlertDialog.native.js.map +1 -0
- package/dist/jsx/AlertDialog.mjs +153 -187
- package/dist/jsx/AlertDialog.mjs.map +1 -1
- package/dist/jsx/AlertDialog.native.cjs +234 -0
- package/dist/jsx/AlertDialog.native.js +182 -324
- package/dist/jsx/AlertDialog.native.js.map +1 -1
- package/dist/jsx/alertDialogPart.mjs +7 -0
- package/dist/jsx/alertDialogPart.mjs.map +1 -0
- package/dist/jsx/alertDialogPart.native.cjs +32 -0
- package/dist/jsx/alertDialogPart.native.js +34 -0
- package/dist/jsx/alertDialogPart.native.js.map +1 -0
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.native.cjs +20 -0
- package/dist/jsx/index.native.js +9 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useNativeAlertDialog.mjs +4 -0
- package/dist/jsx/useNativeAlertDialog.mjs.map +1 -0
- package/dist/jsx/useNativeAlertDialog.native.cjs +139 -0
- package/dist/jsx/useNativeAlertDialog.native.js +141 -0
- package/dist/jsx/useNativeAlertDialog.native.js.map +1 -0
- package/package.json +22 -20
- package/src/AlertDialog.tsx +80 -181
- package/src/alertDialogPart.ts +26 -0
- package/src/useNativeAlertDialog.native.tsx +129 -0
- package/src/useNativeAlertDialog.ts +11 -0
- package/types/AlertDialog.d.ts +28 -62
- package/types/AlertDialog.d.ts.map +1 -1
- package/types/alertDialogPart.d.ts +15 -0
- package/types/alertDialogPart.d.ts.map +1 -0
- package/types/useNativeAlertDialog.d.ts +11 -0
- package/types/useNativeAlertDialog.d.ts.map +1 -0
- package/types/useNativeAlertDialog.native.d.ts +11 -0
- package/types/useNativeAlertDialog.native.d.ts.map +1 -0
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
package/dist/cjs/AlertDialog.cjs
CHANGED
|
@@ -5,275 +5,219 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
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: true
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
30
25
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var AlertDialog_exports = {};
|
|
35
28
|
__export(AlertDialog_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
AlertDialog: () => AlertDialog,
|
|
30
|
+
AlertDialogAction: () => AlertDialogAction,
|
|
31
|
+
AlertDialogCancel: () => AlertDialogCancel,
|
|
32
|
+
AlertDialogContent: () => AlertDialogContent,
|
|
33
|
+
AlertDialogDescription: () => AlertDialogDescription,
|
|
34
|
+
AlertDialogDestructive: () => AlertDialogDestructive,
|
|
35
|
+
AlertDialogOverlay: () => AlertDialogOverlay,
|
|
36
|
+
AlertDialogPortal: () => AlertDialogPortal,
|
|
37
|
+
AlertDialogTitle: () => AlertDialogTitle,
|
|
38
|
+
AlertDialogTrigger: () => AlertDialogTrigger
|
|
46
39
|
});
|
|
47
40
|
module.exports = __toCommonJS(AlertDialog_exports);
|
|
41
|
+
var import_core = require("@tamagui/core");
|
|
48
42
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
49
43
|
var import_constants = require("@tamagui/constants");
|
|
50
|
-
var
|
|
44
|
+
var import_core2 = require("@tamagui/core");
|
|
51
45
|
var import_dialog = require("@tamagui/dialog");
|
|
52
46
|
var import_helpers = require("@tamagui/helpers");
|
|
53
|
-
require("@tamagui/use-controllable-state");
|
|
54
47
|
var React = __toESM(require("react"), 1);
|
|
55
|
-
require("
|
|
48
|
+
var import_alertDialogPart = require("./alertDialogPart.cjs");
|
|
49
|
+
var import_useNativeAlertDialog = require("./useNativeAlertDialog.cjs");
|
|
56
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
|
-
const getAlertDialogScope = scope => scope;
|
|
51
|
+
const getAlertDialogScope = (scope) => scope;
|
|
58
52
|
const ROOT_NAME = "AlertDialog";
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const AlertDialogTrigger =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
scope,
|
|
77
|
-
...triggerProps
|
|
78
|
-
} = props;
|
|
79
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogTrigger, {
|
|
80
|
-
scope: getAlertDialogScope(scope),
|
|
81
|
-
...triggerProps,
|
|
82
|
-
ref: forwardedRef
|
|
83
|
-
});
|
|
53
|
+
const TRIGGER_NAME = "AlertDialogTrigger";
|
|
54
|
+
const NativeAlertDialogTriggerFrame = (0, import_core2.styled)(import_core2.View, { displayName: TRIGGER_NAME });
|
|
55
|
+
(0, import_alertDialogPart.markAlertDialogPart)(NativeAlertDialogTriggerFrame, "trigger");
|
|
56
|
+
const AlertDialogTrigger = (0, import_core.createStyledHOC)(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {
|
|
57
|
+
if (props["__native"]) {
|
|
58
|
+
const { __native, onPress, __onPress, ...rest } = props;
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NativeAlertDialogTriggerFrame, {
|
|
60
|
+
...rest,
|
|
61
|
+
onPress: (0, import_helpers.composeEventHandlers)(onPress, __onPress)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const { scope, ...triggerProps } = props;
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTrigger, {
|
|
66
|
+
scope: getAlertDialogScope(scope),
|
|
67
|
+
...triggerProps,
|
|
68
|
+
ref: forwardedRef
|
|
69
|
+
});
|
|
84
70
|
});
|
|
85
71
|
const AlertDialogPortal = function AlertDialogPortal2(props) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
scope: getAlertDialogScope(scope),
|
|
92
|
-
...portalProps
|
|
93
|
-
});
|
|
72
|
+
const { scope, ...portalProps } = props;
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogPortal, {
|
|
74
|
+
scope: getAlertDialogScope(scope),
|
|
75
|
+
...portalProps
|
|
76
|
+
});
|
|
94
77
|
};
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
...overlayProps,
|
|
105
|
-
ref: forwardedRef
|
|
106
|
-
});
|
|
78
|
+
const OVERLAY_NAME = "AlertDialogOverlay";
|
|
79
|
+
const AlertDialogOverlayFrame = (0, import_core2.styled)(import_dialog.DialogOverlayFrame, { displayName: OVERLAY_NAME });
|
|
80
|
+
const AlertDialogOverlay = (0, import_core.createStyledHOC)(AlertDialogOverlayFrame, function AlertDialogOverlay2(props, forwardedRef) {
|
|
81
|
+
const { scope, ...overlayProps } = props;
|
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogOverlay, {
|
|
83
|
+
scope: getAlertDialogScope(scope),
|
|
84
|
+
...overlayProps,
|
|
85
|
+
ref: forwardedRef
|
|
86
|
+
});
|
|
107
87
|
});
|
|
108
88
|
const CONTENT_NAME = "AlertDialogContent";
|
|
109
|
-
const {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}),
|
|
144
|
-
onPointerDownOutside: event => event.preventDefault(),
|
|
145
|
-
onInteractOutside: event => event.preventDefault(),
|
|
146
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slottable, {
|
|
147
|
-
children
|
|
148
|
-
}), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
|
|
149
|
-
contentRef
|
|
150
|
-
})]
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
});
|
|
89
|
+
const { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = (0, import_core2.createStyledContext)({}, "AlertDialogContext");
|
|
90
|
+
const AlertDialogContent = (0, import_core.createRefComponent)(function AlertDialogContent2(props, forwardedRef) {
|
|
91
|
+
const { scope, children, ...contentProps } = props;
|
|
92
|
+
const dialogScope = getAlertDialogScope(scope);
|
|
93
|
+
const contentRef = React.useRef(null);
|
|
94
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
95
|
+
const cancelRef = React.useRef(null);
|
|
96
|
+
const destructiveRef = React.useRef(null);
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogWarningProvider, {
|
|
98
|
+
contentName: CONTENT_NAME,
|
|
99
|
+
titleName: TITLE_NAME,
|
|
100
|
+
docsSlug: "alert-dialog",
|
|
101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogContextProvider, {
|
|
102
|
+
scope,
|
|
103
|
+
cancelRef,
|
|
104
|
+
destructiveRef,
|
|
105
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogContent, {
|
|
106
|
+
role: "alertdialog",
|
|
107
|
+
"aria-modal": true,
|
|
108
|
+
scope: dialogScope,
|
|
109
|
+
...contentProps,
|
|
110
|
+
ref: composedRefs,
|
|
111
|
+
onOpenAutoFocus: (0, import_helpers.composeEventHandlers)(contentProps.onOpenAutoFocus, (event) => {
|
|
112
|
+
event.cancel();
|
|
113
|
+
if (import_constants.isWeb) {
|
|
114
|
+
cancelRef.current?.focus({ preventScroll: true });
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
onPointerDownOutside: (event) => event.cancel(),
|
|
118
|
+
onInteractOutside: (event) => event.cancel(),
|
|
119
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slottable, { children }), process.env.NODE_ENV === "development" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionWarning, { contentRef })]
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
});
|
|
154
123
|
});
|
|
155
124
|
const TITLE_NAME = "AlertDialogTitle";
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
...titleProps,
|
|
166
|
-
ref: forwardedRef
|
|
167
|
-
});
|
|
125
|
+
const AlertDialogTitleFrame = (0, import_core2.styled)(import_core2.View, { displayName: TITLE_NAME });
|
|
126
|
+
(0, import_alertDialogPart.markAlertDialogPart)(AlertDialogTitleFrame, "title");
|
|
127
|
+
const AlertDialogTitle = (0, import_core.createStyledHOC)(AlertDialogTitleFrame, function AlertDialogTitle2(props, forwardedRef) {
|
|
128
|
+
const { scope, ...titleProps } = props;
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, {
|
|
130
|
+
scope: getAlertDialogScope(scope),
|
|
131
|
+
...titleProps,
|
|
132
|
+
ref: forwardedRef
|
|
133
|
+
});
|
|
168
134
|
});
|
|
169
135
|
const DESCRIPTION_NAME = "AlertDialogDescription";
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
...descriptionProps,
|
|
180
|
-
ref: forwardedRef
|
|
181
|
-
});
|
|
136
|
+
const AlertDialogDescriptionFrame = (0, import_core2.styled)(import_core2.View, { displayName: DESCRIPTION_NAME });
|
|
137
|
+
(0, import_alertDialogPart.markAlertDialogPart)(AlertDialogDescriptionFrame, "description");
|
|
138
|
+
const AlertDialogDescription = (0, import_core.createStyledHOC)(AlertDialogDescriptionFrame, function AlertDialogDescription2(props, forwardedRef) {
|
|
139
|
+
const { scope, ...descriptionProps } = props;
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogDescription, {
|
|
141
|
+
scope: getAlertDialogScope(scope),
|
|
142
|
+
...descriptionProps,
|
|
143
|
+
ref: forwardedRef
|
|
144
|
+
});
|
|
182
145
|
});
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
ref: forwardedRef
|
|
194
|
-
});
|
|
146
|
+
const ACTION_NAME = "AlertDialogAction";
|
|
147
|
+
const AlertDialogActionFrame = (0, import_core2.styled)(import_core2.View, { displayName: ACTION_NAME });
|
|
148
|
+
(0, import_alertDialogPart.markAlertDialogPart)(AlertDialogActionFrame, "action");
|
|
149
|
+
const AlertDialogAction = (0, import_core.createStyledHOC)(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {
|
|
150
|
+
const { scope, ...actionProps } = props;
|
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
152
|
+
scope: getAlertDialogScope(scope),
|
|
153
|
+
...actionProps,
|
|
154
|
+
ref: forwardedRef
|
|
155
|
+
});
|
|
195
156
|
});
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
scope: getAlertDialogScope(scope),
|
|
209
|
-
...cancelProps,
|
|
210
|
-
ref
|
|
211
|
-
});
|
|
157
|
+
const CANCEL_NAME = "AlertDialogCancel";
|
|
158
|
+
const AlertDialogCancelFrame = (0, import_core2.styled)(import_core2.View, { displayName: CANCEL_NAME });
|
|
159
|
+
(0, import_alertDialogPart.markAlertDialogPart)(AlertDialogCancelFrame, "cancel");
|
|
160
|
+
const AlertDialogCancel = (0, import_core.createStyledHOC)(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {
|
|
161
|
+
const { scope, ...cancelProps } = props;
|
|
162
|
+
const { cancelRef } = useAlertDialogContentContext(scope);
|
|
163
|
+
const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, cancelRef);
|
|
164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
165
|
+
scope: getAlertDialogScope(scope),
|
|
166
|
+
...cancelProps,
|
|
167
|
+
ref
|
|
168
|
+
});
|
|
212
169
|
});
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
scope: getAlertDialogScope(scope),
|
|
226
|
-
...destructiveProps,
|
|
227
|
-
ref
|
|
228
|
-
});
|
|
170
|
+
const DESTRUCTIVE_NAME = "AlertDialogDestructive";
|
|
171
|
+
const AlertDialogDestructiveFrame = (0, import_core2.styled)(import_core2.View, { displayName: DESTRUCTIVE_NAME });
|
|
172
|
+
(0, import_alertDialogPart.markAlertDialogPart)(AlertDialogDestructiveFrame, "destructive");
|
|
173
|
+
const AlertDialogDestructive = (0, import_core.createStyledHOC)(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {
|
|
174
|
+
const { scope, ...destructiveProps } = props;
|
|
175
|
+
const { destructiveRef } = useAlertDialogContentContext(scope);
|
|
176
|
+
const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, destructiveRef);
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
178
|
+
scope: getAlertDialogScope(scope),
|
|
179
|
+
...destructiveProps,
|
|
180
|
+
ref
|
|
181
|
+
});
|
|
229
182
|
});
|
|
230
|
-
const DescriptionWarning = ({
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
contentRef.current?.getAttribute("aria-describedby"))) console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
183
|
+
const DescriptionWarning = ({ contentRef }) => {
|
|
184
|
+
if (process.env.NODE_ENV === "development") {
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
if (!import_constants.isWeb) return;
|
|
187
|
+
const hasDescription = document.getElementById(contentRef.current?.getAttribute("aria-describedby"));
|
|
188
|
+
if (!hasDescription) {
|
|
189
|
+
console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
238
190
|
|
|
239
191
|
You can add a description to the \`${CONTENT_NAME}\` by passing a \`${DESCRIPTION_NAME}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
240
192
|
|
|
241
193
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
242
194
|
|
|
243
195
|
For more information, see https://tamagui.dev/docs/components/alert-dialog`);
|
|
244
|
-
|
|
245
|
-
|
|
196
|
+
}
|
|
197
|
+
}, [contentRef]);
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
246
200
|
};
|
|
247
|
-
const AlertDialogInner = props => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
modal: true
|
|
258
|
-
});
|
|
201
|
+
const AlertDialogInner = (props) => {
|
|
202
|
+
const { scope, native, ...alertDialogProps } = props;
|
|
203
|
+
const dialogScope = getAlertDialogScope(scope);
|
|
204
|
+
const nativeAlert = (0, import_useNativeAlertDialog.useNativeAlertDialog)(props);
|
|
205
|
+
if (nativeAlert) return nativeAlert;
|
|
206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog, {
|
|
207
|
+
scope: dialogScope,
|
|
208
|
+
...alertDialogProps,
|
|
209
|
+
modal: true
|
|
210
|
+
});
|
|
259
211
|
};
|
|
260
|
-
function forEachChildDeep(children, onChild) {
|
|
261
|
-
for (const child of children) {
|
|
262
|
-
if (!React.isValidElement(child)) continue;
|
|
263
|
-
if (!onChild(child)) continue;
|
|
264
|
-
const childProps = child.props;
|
|
265
|
-
if (childProps.children) forEachChildDeep(React.Children.toArray(childProps.children), onChild);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
212
|
const AlertDialog = (0, import_helpers.withStaticProperties)(AlertDialogInner, {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
213
|
+
Trigger: AlertDialogTrigger,
|
|
214
|
+
Portal: AlertDialogPortal,
|
|
215
|
+
Overlay: AlertDialogOverlay,
|
|
216
|
+
Content: AlertDialogContent,
|
|
217
|
+
Action: AlertDialogAction,
|
|
218
|
+
Cancel: AlertDialogCancel,
|
|
219
|
+
Destructive: AlertDialogDestructive,
|
|
220
|
+
Title: AlertDialogTitle,
|
|
221
|
+
Description: AlertDialogDescription
|
|
278
222
|
});
|
|
279
|
-
AlertDialog.displayName = ROOT_NAME;
|
|
223
|
+
AlertDialog.displayName = ROOT_NAME;
|