@tamagui/alert-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/AlertDialog.cjs +230 -227
- package/dist/cjs/AlertDialog.native.js +312 -313
- package/dist/cjs/AlertDialog.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/AlertDialog.mjs +199 -198
- package/dist/esm/AlertDialog.mjs.map +1 -1
- package/dist/esm/AlertDialog.native.js +277 -281
- package/dist/esm/AlertDialog.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/AlertDialog.mjs +199 -198
- package/dist/jsx/AlertDialog.mjs.map +1 -1
- package/dist/jsx/AlertDialog.native.js +312 -313
- package/dist/jsx/AlertDialog.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 +21 -22
- package/types/AlertDialog.d.ts +14 -14
- package/dist/cjs/AlertDialog.js +0 -209
- package/dist/cjs/AlertDialog.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/AlertDialog.js +0 -209
- package/dist/esm/AlertDialog.js.map +0 -6
- package/dist/jsx/AlertDialog.js +0 -209
- package/dist/jsx/AlertDialog.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 AlertDialog_exports = {};
|
|
35
37
|
__export(AlertDialog_exports, {
|
|
36
38
|
AlertDialog: () => AlertDialog,
|
|
@@ -45,314 +47,306 @@ __export(AlertDialog_exports, {
|
|
|
45
47
|
AlertDialogTrigger: () => AlertDialogTrigger
|
|
46
48
|
});
|
|
47
49
|
module.exports = __toCommonJS(AlertDialog_exports);
|
|
48
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var {
|
|
68
|
-
__native,
|
|
69
|
-
onPress,
|
|
70
|
-
__onPress,
|
|
71
|
-
...rest
|
|
72
|
-
} = props;
|
|
73
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeAlertDialogTriggerFrame, {
|
|
74
|
-
...rest,
|
|
75
|
-
onPress: (0, import_helpers.composeEventHandlers)(onPress, __onPress)
|
|
76
|
-
});
|
|
77
|
-
}
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
52
|
+
var import_constants = require("@tamagui/constants");
|
|
53
|
+
var import_core = require("@tamagui/core");
|
|
54
|
+
var import_dialog = require("@tamagui/dialog");
|
|
55
|
+
var import_helpers = require("@tamagui/helpers");
|
|
56
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
57
|
+
var React = __toESM(require("react"), 1);
|
|
58
|
+
var import_react_native = require("react-native");
|
|
59
|
+
var getAlertDialogScope = function (scope) {
|
|
60
|
+
return scope;
|
|
61
|
+
};
|
|
62
|
+
var ROOT_NAME = "AlertDialog";
|
|
63
|
+
var TRIGGER_NAME = "AlertDialogTrigger";
|
|
64
|
+
var NativeAlertDialogTriggerFrame = (0, import_core.styled)(import_core.View, {
|
|
65
|
+
name: TRIGGER_NAME
|
|
66
|
+
});
|
|
67
|
+
var AlertDialogTrigger = NativeAlertDialogTriggerFrame.styleable(function AlertDialogTrigger2(props, forwardedRef) {
|
|
68
|
+
if (props["__native"]) {
|
|
78
69
|
var {
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
__native,
|
|
71
|
+
onPress,
|
|
72
|
+
__onPress,
|
|
73
|
+
...rest
|
|
81
74
|
} = props;
|
|
82
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
ref: forwardedRef
|
|
75
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeAlertDialogTriggerFrame, {
|
|
76
|
+
...rest,
|
|
77
|
+
onPress: (0, import_helpers.composeEventHandlers)(onPress, __onPress)
|
|
86
78
|
});
|
|
79
|
+
}
|
|
80
|
+
var {
|
|
81
|
+
scope,
|
|
82
|
+
...triggerProps
|
|
83
|
+
} = props;
|
|
84
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogTrigger, {
|
|
85
|
+
scope: getAlertDialogScope(scope),
|
|
86
|
+
...triggerProps,
|
|
87
|
+
ref: forwardedRef
|
|
87
88
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
});
|
|
90
|
+
var AlertDialogPortal = function AlertDialogPortal2(props) {
|
|
91
|
+
var {
|
|
92
|
+
scope,
|
|
93
|
+
...portalProps
|
|
94
|
+
} = props;
|
|
95
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogPortal, {
|
|
96
|
+
scope: getAlertDialogScope(scope),
|
|
97
|
+
...portalProps
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var AlertDialogOverlay = (0, import_core.styled)(import_dialog.DialogOverlayFrame, {
|
|
101
|
+
name: "AlertDialogOverlay"
|
|
102
|
+
}).styleable(function AlertDialogOverlay2(props, forwardedRef) {
|
|
103
|
+
var {
|
|
104
|
+
scope,
|
|
105
|
+
...overlayProps
|
|
106
|
+
} = props;
|
|
107
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogOverlay, {
|
|
108
|
+
scope: getAlertDialogScope(scope),
|
|
109
|
+
...overlayProps,
|
|
110
|
+
ref: forwardedRef
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
var CONTENT_NAME = "AlertDialogContent";
|
|
114
|
+
var {
|
|
115
|
+
Provider: AlertDialogContextProvider,
|
|
116
|
+
useStyledContext: useAlertDialogContentContext
|
|
117
|
+
} = (0, import_core.createStyledContext)({}, "AlertDialogContext");
|
|
118
|
+
var AlertDialogContent = /* @__PURE__ */React.forwardRef(function AlertDialogContent2(props, forwardedRef) {
|
|
119
|
+
var {
|
|
120
|
+
scope,
|
|
121
|
+
children,
|
|
122
|
+
...contentProps
|
|
123
|
+
} = props;
|
|
124
|
+
var dialogScope = getAlertDialogScope(scope);
|
|
125
|
+
var contentRef = React.useRef(null);
|
|
126
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
127
|
+
var cancelRef = React.useRef(null);
|
|
128
|
+
var destructiveRef = React.useRef(null);
|
|
129
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogWarningProvider, {
|
|
130
|
+
contentName: CONTENT_NAME,
|
|
131
|
+
titleName: TITLE_NAME,
|
|
132
|
+
docsSlug: "alert-dialog",
|
|
133
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AlertDialogContextProvider, {
|
|
104
134
|
scope,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AlertDialogContextProvider, {
|
|
134
|
-
scope,
|
|
135
|
-
cancelRef,
|
|
136
|
-
destructiveRef,
|
|
137
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_dialog.DialogContent, {
|
|
138
|
-
role: "alertdialog",
|
|
139
|
-
"aria-modal": !0,
|
|
140
|
-
scope: dialogScope,
|
|
141
|
-
...contentProps,
|
|
142
|
-
ref: composedRefs,
|
|
143
|
-
onOpenAutoFocus: (0, import_helpers.composeEventHandlers)(contentProps.onOpenAutoFocus, function (event) {
|
|
144
|
-
if (event.preventDefault(), import_constants.isWeb) {
|
|
145
|
-
var _cancelRef_current;
|
|
146
|
-
(_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 || _cancelRef_current.focus({
|
|
147
|
-
preventScroll: !0
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}),
|
|
151
|
-
onPointerDownOutside: function (event) {
|
|
152
|
-
return event.preventDefault();
|
|
153
|
-
},
|
|
154
|
-
onInteractOutside: function (event) {
|
|
155
|
-
return event.preventDefault();
|
|
156
|
-
},
|
|
157
|
-
children: [
|
|
158
|
-
/**
|
|
159
|
-
* We have to use `Slottable` here as we cannot wrap the `AlertDialogContentProvider`
|
|
160
|
-
* around everything, otherwise the `DescriptionWarning` would be rendered straight away.
|
|
161
|
-
* This is because we want the accessibility checks to run only once the content is actually
|
|
162
|
-
* open and that behaviour is already encapsulated in `DialogContent`.
|
|
163
|
-
*/
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
(0, import_jsx_runtime.jsx)(import_core.Slottable, {
|
|
166
|
-
children
|
|
167
|
-
}), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
|
|
168
|
-
contentRef
|
|
169
|
-
})]
|
|
170
|
-
})
|
|
135
|
+
cancelRef,
|
|
136
|
+
destructiveRef,
|
|
137
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_dialog.DialogContent, {
|
|
138
|
+
role: "alertdialog",
|
|
139
|
+
"aria-modal": true,
|
|
140
|
+
scope: dialogScope,
|
|
141
|
+
...contentProps,
|
|
142
|
+
ref: composedRefs,
|
|
143
|
+
onOpenAutoFocus: (0, import_helpers.composeEventHandlers)(contentProps.onOpenAutoFocus, function (event) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
if (import_constants.isWeb) {
|
|
146
|
+
var _cancelRef_current;
|
|
147
|
+
(_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 || _cancelRef_current.focus({
|
|
148
|
+
preventScroll: true
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
onPointerDownOutside: function (event) {
|
|
153
|
+
return event.preventDefault();
|
|
154
|
+
},
|
|
155
|
+
onInteractOutside: function (event) {
|
|
156
|
+
return event.preventDefault();
|
|
157
|
+
},
|
|
158
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slottable, {
|
|
159
|
+
children
|
|
160
|
+
}), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
|
|
161
|
+
contentRef
|
|
162
|
+
})]
|
|
171
163
|
})
|
|
172
|
-
})
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
CANCEL_NAME
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
258
|
-
var
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return process.env.NODE_ENV === "development" && React.useEffect(function () {
|
|
262
|
-
var _contentRef_current;
|
|
263
|
-
if (import_constants.isWeb) {
|
|
264
|
-
var hasDescription = document.getElementById((_contentRef_current = contentRef.current) === null || _contentRef_current === void 0 ? void 0 : _contentRef_current.getAttribute("aria-describedby"));
|
|
265
|
-
hasDescription || console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
var TITLE_NAME = "AlertDialogTitle";
|
|
168
|
+
var AlertDialogTitle = (0, import_core.styled)(import_core.View, {
|
|
169
|
+
name: TITLE_NAME
|
|
170
|
+
}).styleable(function AlertDialogTitle2(props, forwardedRef) {
|
|
171
|
+
var {
|
|
172
|
+
scope,
|
|
173
|
+
...titleProps
|
|
174
|
+
} = props;
|
|
175
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, {
|
|
176
|
+
scope: getAlertDialogScope(scope),
|
|
177
|
+
...titleProps,
|
|
178
|
+
ref: forwardedRef
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
var DESCRIPTION_NAME = "AlertDialogDescription";
|
|
182
|
+
var AlertDialogDescription = (0, import_core.styled)(import_core.View, {
|
|
183
|
+
name: DESCRIPTION_NAME
|
|
184
|
+
}).styleable(function AlertDialogDescription2(props, forwardedRef) {
|
|
185
|
+
var {
|
|
186
|
+
scope,
|
|
187
|
+
...descriptionProps
|
|
188
|
+
} = props;
|
|
189
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogDescription, {
|
|
190
|
+
scope: getAlertDialogScope(scope),
|
|
191
|
+
...descriptionProps,
|
|
192
|
+
ref: forwardedRef
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
var ACTION_NAME = "AlertDialogAction";
|
|
196
|
+
var AlertDialogAction = (0, import_core.styled)(import_core.View, {
|
|
197
|
+
name: ACTION_NAME
|
|
198
|
+
}).styleable(function AlertDialogAction2(props, forwardedRef) {
|
|
199
|
+
var {
|
|
200
|
+
scope,
|
|
201
|
+
...actionProps
|
|
202
|
+
} = props;
|
|
203
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
204
|
+
scope: getAlertDialogScope(scope),
|
|
205
|
+
...actionProps,
|
|
206
|
+
ref: forwardedRef
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
var CANCEL_NAME = "AlertDialogCancel";
|
|
210
|
+
var AlertDialogCancel = (0, import_core.styled)(import_core.View, {
|
|
211
|
+
name: CANCEL_NAME
|
|
212
|
+
}).styleable(function AlertDialogCancel2(props, forwardedRef) {
|
|
213
|
+
var {
|
|
214
|
+
scope,
|
|
215
|
+
...cancelProps
|
|
216
|
+
} = props;
|
|
217
|
+
var {
|
|
218
|
+
cancelRef
|
|
219
|
+
} = useAlertDialogContentContext(scope);
|
|
220
|
+
var ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, cancelRef);
|
|
221
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
222
|
+
scope: getAlertDialogScope(scope),
|
|
223
|
+
...cancelProps,
|
|
224
|
+
ref
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
var DESTRUCTIVE_NAME = "AlertDialogDestructive";
|
|
228
|
+
var AlertDialogDestructive = (0, import_core.styled)(import_core.View, {
|
|
229
|
+
name: DESTRUCTIVE_NAME
|
|
230
|
+
}).styleable(function AlertDialogDestructive2(props, forwardedRef) {
|
|
231
|
+
var {
|
|
232
|
+
scope,
|
|
233
|
+
...destructiveProps
|
|
234
|
+
} = props;
|
|
235
|
+
var {
|
|
236
|
+
destructiveRef
|
|
237
|
+
} = useAlertDialogContentContext(scope);
|
|
238
|
+
var ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, destructiveRef);
|
|
239
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
240
|
+
scope: getAlertDialogScope(scope),
|
|
241
|
+
...destructiveProps,
|
|
242
|
+
ref
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
var DescriptionWarning = function (param) {
|
|
246
|
+
var {
|
|
247
|
+
contentRef
|
|
248
|
+
} = param;
|
|
249
|
+
if (process.env.NODE_ENV === "development") React.useEffect(function () {
|
|
250
|
+
var _contentRef_current;
|
|
251
|
+
if (!import_constants.isWeb) return;
|
|
252
|
+
if (!document.getElementById((_contentRef_current = contentRef.current) === null || _contentRef_current === void 0 ? void 0 : _contentRef_current.getAttribute("aria-describedby"))) console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
266
253
|
|
|
267
254
|
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.
|
|
268
255
|
|
|
269
256
|
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.
|
|
270
257
|
|
|
271
258
|
For more information, see https://tamagui.dev/docs/components/alert-dialog`);
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
};
|
|
259
|
+
}, [contentRef]);
|
|
260
|
+
return null;
|
|
261
|
+
};
|
|
262
|
+
var AlertDialogInner = function (props) {
|
|
263
|
+
var {
|
|
264
|
+
scope,
|
|
265
|
+
native,
|
|
266
|
+
...alertDialogProps
|
|
267
|
+
} = props;
|
|
268
|
+
var dialogScope = getAlertDialogScope(scope);
|
|
269
|
+
var [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
270
|
+
prop: props.open,
|
|
271
|
+
defaultProp: props.defaultOpen || false,
|
|
272
|
+
onChange: props.onOpenChange,
|
|
273
|
+
transition: true
|
|
274
|
+
});
|
|
275
|
+
var triggerElement = null;
|
|
276
|
+
var title = "";
|
|
277
|
+
var description = "";
|
|
278
|
+
var buttons = [];
|
|
279
|
+
forEachChildDeep(React.Children.toArray(props.children), function (child) {
|
|
280
|
+
if (! /* @__PURE__ */React.isValidElement(child)) return false;
|
|
281
|
+
var name = (0, import_core.isTamaguiElement)(child) ? child.type.staticConfig.componentName : child.type["displayName"];
|
|
282
|
+
switch (name) {
|
|
283
|
+
case TRIGGER_NAME:
|
|
284
|
+
triggerElement = /* @__PURE__ */React.cloneElement(child, {
|
|
285
|
+
__native: true
|
|
286
|
+
});
|
|
287
|
+
return false;
|
|
288
|
+
case TITLE_NAME:
|
|
289
|
+
title = getStringChildren(child);
|
|
290
|
+
return false;
|
|
291
|
+
case DESCRIPTION_NAME:
|
|
292
|
+
description = getStringChildren(child);
|
|
293
|
+
return false;
|
|
294
|
+
case ACTION_NAME:
|
|
295
|
+
case DESTRUCTIVE_NAME:
|
|
296
|
+
case CANCEL_NAME:
|
|
297
|
+
var style = name === ACTION_NAME ? "default" : name === DESTRUCTIVE_NAME ? "destructive" : "cancel";
|
|
298
|
+
var text = getStringChildren(child);
|
|
299
|
+
var onPress = function () {
|
|
300
|
+
var _childProps_onPress;
|
|
301
|
+
var childProps = child.props;
|
|
302
|
+
childProps === null || childProps === void 0 || (_childProps_onPress = childProps.onPress) == null || _childProps_onPress.call(childProps, {
|
|
303
|
+
native: true
|
|
304
|
+
});
|
|
305
|
+
setOpen(false);
|
|
306
|
+
};
|
|
307
|
+
buttons.push({
|
|
308
|
+
style,
|
|
309
|
+
text,
|
|
310
|
+
onPress
|
|
311
|
+
});
|
|
312
|
+
return false;
|
|
313
|
+
default:
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
318
|
+
if (!open || !native) return;
|
|
319
|
+
if (title || description) import_react_native.Alert.alert(title, description, buttons);
|
|
320
|
+
}, [native, open]);
|
|
321
|
+
if (native) return /* @__PURE__ */React.cloneElement(triggerElement, {
|
|
322
|
+
__onPress: function () {
|
|
323
|
+
setOpen(true);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.Dialog, {
|
|
327
|
+
scope: dialogScope,
|
|
328
|
+
...alertDialogProps,
|
|
329
|
+
modal: true
|
|
330
|
+
});
|
|
331
|
+
};
|
|
339
332
|
function forEachChildDeep(children, onChild) {
|
|
340
|
-
var _iteratorNormalCompletion =
|
|
341
|
-
_didIteratorError =
|
|
333
|
+
var _iteratorNormalCompletion = true,
|
|
334
|
+
_didIteratorError = false,
|
|
342
335
|
_iteratorError = void 0;
|
|
343
336
|
try {
|
|
344
|
-
for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
337
|
+
for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
345
338
|
var child = _step.value;
|
|
346
|
-
if (/* @__PURE__ */React.isValidElement(child)
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
339
|
+
if (! /* @__PURE__ */React.isValidElement(child)) continue;
|
|
340
|
+
if (!onChild(child)) continue;
|
|
341
|
+
var childProps = child.props;
|
|
342
|
+
if (childProps.children) forEachChildDeep(React.Children.toArray(childProps.children), onChild);
|
|
350
343
|
}
|
|
351
344
|
} catch (err) {
|
|
352
|
-
_didIteratorError =
|
|
345
|
+
_didIteratorError = true;
|
|
346
|
+
_iteratorError = err;
|
|
353
347
|
} finally {
|
|
354
348
|
try {
|
|
355
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
349
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
356
350
|
} finally {
|
|
357
351
|
if (_didIteratorError) throw _iteratorError;
|
|
358
352
|
}
|
|
@@ -360,9 +354,14 @@ function forEachChildDeep(children, onChild) {
|
|
|
360
354
|
}
|
|
361
355
|
function getStringChildren(child) {
|
|
362
356
|
var string = "";
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
357
|
+
forEachChildDeep(React.Children.toArray(child), function (child2) {
|
|
358
|
+
if (typeof child2.props.children === "string") {
|
|
359
|
+
string = child2.props.children;
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
return true;
|
|
363
|
+
});
|
|
364
|
+
return string;
|
|
366
365
|
}
|
|
367
366
|
var AlertDialog = (0, import_helpers.withStaticProperties)(AlertDialogInner, {
|
|
368
367
|
Trigger: AlertDialogTrigger,
|