@tamagui/alert-dialog 2.7.7 → 3.0.0-beta.643.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 +173 -230
- package/dist/cjs/AlertDialog.native.cjs +309 -0
- package/dist/cjs/AlertDialog.native.js +255 -322
- package/dist/cjs/AlertDialog.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/AlertDialog.mjs +138 -187
- package/dist/esm/AlertDialog.mjs.map +1 -1
- package/dist/esm/AlertDialog.native.js +227 -289
- package/dist/esm/AlertDialog.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/jsx/AlertDialog.mjs +138 -187
- package/dist/jsx/AlertDialog.mjs.map +1 -1
- package/dist/jsx/AlertDialog.native.cjs +309 -0
- package/dist/jsx/AlertDialog.native.js +255 -322
- package/dist/jsx/AlertDialog.native.js.map +1 -1
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.native.cjs +21 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +20 -19
- package/src/AlertDialog.tsx +106 -75
- package/types/AlertDialog.d.ts +40 -74
- package/types/AlertDialog.d.ts.map +1 -1
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,372 +8,304 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
14
15
|
};
|
|
15
16
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
23
24
|
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
32
28
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
30
|
var AlertDialog_exports = {};
|
|
37
31
|
__export(AlertDialog_exports, {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
AlertDialog: () => AlertDialog,
|
|
33
|
+
AlertDialogAction: () => AlertDialogAction,
|
|
34
|
+
AlertDialogCancel: () => AlertDialogCancel,
|
|
35
|
+
AlertDialogContent: () => AlertDialogContent,
|
|
36
|
+
AlertDialogDescription: () => AlertDialogDescription,
|
|
37
|
+
AlertDialogDestructive: () => AlertDialogDestructive,
|
|
38
|
+
AlertDialogOverlay: () => AlertDialogOverlay,
|
|
39
|
+
AlertDialogPortal: () => AlertDialogPortal,
|
|
40
|
+
AlertDialogTitle: () => AlertDialogTitle,
|
|
41
|
+
AlertDialogTrigger: () => AlertDialogTrigger
|
|
48
42
|
});
|
|
49
43
|
module.exports = __toCommonJS(AlertDialog_exports);
|
|
50
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var import_core = require("@tamagui/core");
|
|
51
46
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
52
47
|
var import_constants = require("@tamagui/constants");
|
|
53
|
-
var
|
|
48
|
+
var import_core2 = require("@tamagui/core");
|
|
54
49
|
var import_dialog = require("@tamagui/dialog");
|
|
55
50
|
var import_helpers = require("@tamagui/helpers");
|
|
56
51
|
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
57
52
|
var React = __toESM(require("react"), 1);
|
|
58
53
|
var import_react_native = require("react-native");
|
|
59
|
-
var getAlertDialogScope = function
|
|
60
|
-
|
|
54
|
+
var getAlertDialogScope = function(scope) {
|
|
55
|
+
return scope;
|
|
61
56
|
};
|
|
62
57
|
var ROOT_NAME = "AlertDialog";
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} = props;
|
|
84
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dialog.DialogTrigger, {
|
|
85
|
-
scope: getAlertDialogScope(scope),
|
|
86
|
-
...triggerProps,
|
|
87
|
-
ref: forwardedRef
|
|
88
|
-
});
|
|
58
|
+
var ALERT_DIALOG_PART = /* @__PURE__ */ Symbol("AlertDialogPart");
|
|
59
|
+
var markAlertDialogPart = function(component, part) {
|
|
60
|
+
Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });
|
|
61
|
+
};
|
|
62
|
+
var NativeAlertDialogTriggerFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogTrigger" });
|
|
63
|
+
markAlertDialogPart(NativeAlertDialogTriggerFrame, "trigger");
|
|
64
|
+
var AlertDialogTrigger = (0, import_core.createStyledHOC)(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {
|
|
65
|
+
if (props["__native"]) {
|
|
66
|
+
var { __native, onPress, __onPress, ...rest } = props;
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NativeAlertDialogTriggerFrame, {
|
|
68
|
+
...rest,
|
|
69
|
+
onPress: (0, import_helpers.composeEventHandlers)(onPress, __onPress)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
var { scope, ...triggerProps } = props;
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTrigger, {
|
|
74
|
+
scope: getAlertDialogScope(scope),
|
|
75
|
+
...triggerProps,
|
|
76
|
+
ref: forwardedRef
|
|
77
|
+
});
|
|
89
78
|
});
|
|
90
79
|
var AlertDialogPortal = function AlertDialogPortal2(props) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
scope: getAlertDialogScope(scope),
|
|
97
|
-
...portalProps
|
|
98
|
-
});
|
|
80
|
+
var { scope, ...portalProps } = props;
|
|
81
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogPortal, {
|
|
82
|
+
scope: getAlertDialogScope(scope),
|
|
83
|
+
...portalProps
|
|
84
|
+
});
|
|
99
85
|
};
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
scope: getAlertDialogScope(scope),
|
|
109
|
-
...overlayProps,
|
|
110
|
-
ref: forwardedRef
|
|
111
|
-
});
|
|
86
|
+
var AlertDialogOverlayFrame = (0, import_core2.styled)(import_dialog.DialogOverlayFrame, { displayName: "AlertDialogOverlay" });
|
|
87
|
+
var AlertDialogOverlay = (0, import_core.createStyledHOC)(AlertDialogOverlayFrame, function AlertDialogOverlay2(props, forwardedRef) {
|
|
88
|
+
var { scope, ...overlayProps } = props;
|
|
89
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogOverlay, {
|
|
90
|
+
scope: getAlertDialogScope(scope),
|
|
91
|
+
...overlayProps,
|
|
92
|
+
ref: forwardedRef
|
|
93
|
+
});
|
|
112
94
|
});
|
|
113
95
|
var CONTENT_NAME = "AlertDialogContent";
|
|
114
|
-
var {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
})]
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
});
|
|
96
|
+
var { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = (0, import_core2.createStyledContext)({}, "AlertDialogContext");
|
|
97
|
+
var AlertDialogContent = (0, import_core.createRefComponent)(function AlertDialogContent2(props, forwardedRef) {
|
|
98
|
+
var { scope, children, ...contentProps } = props;
|
|
99
|
+
var dialogScope = getAlertDialogScope(scope);
|
|
100
|
+
var contentRef = React.useRef(null);
|
|
101
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
102
|
+
var cancelRef = React.useRef(null);
|
|
103
|
+
var destructiveRef = React.useRef(null);
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogWarningProvider, {
|
|
105
|
+
contentName: CONTENT_NAME,
|
|
106
|
+
titleName: TITLE_NAME,
|
|
107
|
+
docsSlug: "alert-dialog",
|
|
108
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogContextProvider, {
|
|
109
|
+
scope,
|
|
110
|
+
cancelRef,
|
|
111
|
+
destructiveRef,
|
|
112
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogContent, {
|
|
113
|
+
role: "alertdialog",
|
|
114
|
+
"aria-modal": true,
|
|
115
|
+
scope: dialogScope,
|
|
116
|
+
...contentProps,
|
|
117
|
+
ref: composedRefs,
|
|
118
|
+
onOpenAutoFocus: (0, import_helpers.composeEventHandlers)(contentProps.onOpenAutoFocus, function(event) {
|
|
119
|
+
event.cancel();
|
|
120
|
+
if (import_constants.isWeb) {
|
|
121
|
+
var _cancelRef_current;
|
|
122
|
+
(_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 || _cancelRef_current.focus({ preventScroll: true });
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
onPointerDownOutside: function(event) {
|
|
126
|
+
return event.cancel();
|
|
127
|
+
},
|
|
128
|
+
onInteractOutside: function(event) {
|
|
129
|
+
return event.cancel();
|
|
130
|
+
},
|
|
131
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slottable, { children }), process.env.NODE_ENV === "development" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionWarning, { contentRef })]
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
});
|
|
166
135
|
});
|
|
167
136
|
var TITLE_NAME = "AlertDialogTitle";
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
...titleProps,
|
|
178
|
-
ref: forwardedRef
|
|
179
|
-
});
|
|
137
|
+
var AlertDialogTitleFrame = (0, import_core2.styled)(import_core2.View, { displayName: TITLE_NAME });
|
|
138
|
+
markAlertDialogPart(AlertDialogTitleFrame, "title");
|
|
139
|
+
var AlertDialogTitle = (0, import_core.createStyledHOC)(AlertDialogTitleFrame, function AlertDialogTitle2(props, forwardedRef) {
|
|
140
|
+
var { scope, ...titleProps } = props;
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, {
|
|
142
|
+
scope: getAlertDialogScope(scope),
|
|
143
|
+
...titleProps,
|
|
144
|
+
ref: forwardedRef
|
|
145
|
+
});
|
|
180
146
|
});
|
|
181
147
|
var DESCRIPTION_NAME = "AlertDialogDescription";
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
...descriptionProps,
|
|
192
|
-
ref: forwardedRef
|
|
193
|
-
});
|
|
148
|
+
var AlertDialogDescriptionFrame = (0, import_core2.styled)(import_core2.View, { displayName: DESCRIPTION_NAME });
|
|
149
|
+
markAlertDialogPart(AlertDialogDescriptionFrame, "description");
|
|
150
|
+
var AlertDialogDescription = (0, import_core.createStyledHOC)(AlertDialogDescriptionFrame, function AlertDialogDescription2(props, forwardedRef) {
|
|
151
|
+
var { scope, ...descriptionProps } = props;
|
|
152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogDescription, {
|
|
153
|
+
scope: getAlertDialogScope(scope),
|
|
154
|
+
...descriptionProps,
|
|
155
|
+
ref: forwardedRef
|
|
156
|
+
});
|
|
194
157
|
});
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
scope: getAlertDialogScope(scope),
|
|
205
|
-
...actionProps,
|
|
206
|
-
ref: forwardedRef
|
|
207
|
-
});
|
|
158
|
+
var AlertDialogActionFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogAction" });
|
|
159
|
+
markAlertDialogPart(AlertDialogActionFrame, "action");
|
|
160
|
+
var AlertDialogAction = (0, import_core.createStyledHOC)(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {
|
|
161
|
+
var { scope, ...actionProps } = props;
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
163
|
+
scope: getAlertDialogScope(scope),
|
|
164
|
+
...actionProps,
|
|
165
|
+
ref: forwardedRef
|
|
166
|
+
});
|
|
208
167
|
});
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
});
|
|
168
|
+
var AlertDialogCancelFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogCancel" });
|
|
169
|
+
markAlertDialogPart(AlertDialogCancelFrame, "cancel");
|
|
170
|
+
var AlertDialogCancel = (0, import_core.createStyledHOC)(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {
|
|
171
|
+
var { scope, ...cancelProps } = props;
|
|
172
|
+
var { cancelRef } = useAlertDialogContentContext(scope);
|
|
173
|
+
var ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, cancelRef);
|
|
174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
175
|
+
scope: getAlertDialogScope(scope),
|
|
176
|
+
...cancelProps,
|
|
177
|
+
ref
|
|
178
|
+
});
|
|
226
179
|
});
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
});
|
|
180
|
+
var AlertDialogDestructiveFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogDestructive" });
|
|
181
|
+
markAlertDialogPart(AlertDialogDestructiveFrame, "destructive");
|
|
182
|
+
var AlertDialogDestructive = (0, import_core.createStyledHOC)(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {
|
|
183
|
+
var { scope, ...destructiveProps } = props;
|
|
184
|
+
var { destructiveRef } = useAlertDialogContentContext(scope);
|
|
185
|
+
var ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, destructiveRef);
|
|
186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
|
|
187
|
+
scope: getAlertDialogScope(scope),
|
|
188
|
+
...destructiveProps,
|
|
189
|
+
ref
|
|
190
|
+
});
|
|
244
191
|
});
|
|
245
|
-
var DescriptionWarning = function
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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.
|
|
192
|
+
var DescriptionWarning = function(param) {
|
|
193
|
+
var { contentRef } = param;
|
|
194
|
+
if (process.env.NODE_ENV === "development") React.useEffect(function() {
|
|
195
|
+
var _contentRef_current;
|
|
196
|
+
if (!import_constants.isWeb) return;
|
|
197
|
+
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.
|
|
253
198
|
|
|
254
199
|
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.
|
|
255
200
|
|
|
256
201
|
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.
|
|
257
202
|
|
|
258
203
|
For more information, see https://tamagui.dev/docs/components/alert-dialog`);
|
|
259
|
-
|
|
260
|
-
|
|
204
|
+
}, [contentRef]);
|
|
205
|
+
return null;
|
|
261
206
|
};
|
|
262
|
-
var AlertDialogInner = function
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
});
|
|
207
|
+
var AlertDialogInner = function(props) {
|
|
208
|
+
var { scope, native, ...alertDialogProps } = props;
|
|
209
|
+
var dialogScope = getAlertDialogScope(scope);
|
|
210
|
+
var [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
211
|
+
prop: props.open,
|
|
212
|
+
defaultProp: props.defaultOpen || false,
|
|
213
|
+
onChange: props.onOpenChange,
|
|
214
|
+
transition: true
|
|
215
|
+
});
|
|
216
|
+
var triggerElement = null;
|
|
217
|
+
var title = "";
|
|
218
|
+
var description = "";
|
|
219
|
+
var buttons = [];
|
|
220
|
+
forEachChildDeep(React.Children.toArray(props.children), function(child) {
|
|
221
|
+
if (!/* @__PURE__ */ React.isValidElement(child)) return false;
|
|
222
|
+
var part = (0, import_core2.isTamaguiElement)(child) ? child.type.staticConfig[ALERT_DIALOG_PART] : void 0;
|
|
223
|
+
switch (part) {
|
|
224
|
+
case "trigger":
|
|
225
|
+
triggerElement = /* @__PURE__ */ React.cloneElement(child, { __native: true });
|
|
226
|
+
return false;
|
|
227
|
+
case "title":
|
|
228
|
+
title = getStringChildren(child);
|
|
229
|
+
return false;
|
|
230
|
+
case "description":
|
|
231
|
+
description = getStringChildren(child);
|
|
232
|
+
return false;
|
|
233
|
+
case "action":
|
|
234
|
+
case "destructive":
|
|
235
|
+
case "cancel":
|
|
236
|
+
var style = part === "action" ? "default" : part === "destructive" ? "destructive" : "cancel";
|
|
237
|
+
var text = getStringChildren(child);
|
|
238
|
+
var onPress = function() {
|
|
239
|
+
var _childProps_onPress;
|
|
240
|
+
var childProps = child.props;
|
|
241
|
+
childProps === null || childProps === void 0 || (_childProps_onPress = childProps.onPress) == null || _childProps_onPress.call(childProps, { native: true });
|
|
242
|
+
setOpen(false);
|
|
243
|
+
};
|
|
244
|
+
buttons.push({
|
|
245
|
+
style,
|
|
246
|
+
text,
|
|
247
|
+
onPress
|
|
248
|
+
});
|
|
249
|
+
return false;
|
|
250
|
+
default: return true;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
254
|
+
if (!open || !native) return;
|
|
255
|
+
if (title || description) import_react_native.Alert.alert(title, description, buttons);
|
|
256
|
+
}, [native, open]);
|
|
257
|
+
if (native) return /* @__PURE__ */ React.cloneElement(triggerElement, { __onPress: function() {
|
|
258
|
+
setOpen(true);
|
|
259
|
+
} });
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog, {
|
|
261
|
+
scope: dialogScope,
|
|
262
|
+
...alertDialogProps,
|
|
263
|
+
modal: true
|
|
264
|
+
});
|
|
331
265
|
};
|
|
332
266
|
function forEachChildDeep(children, onChild) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
}
|
|
267
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
268
|
+
try {
|
|
269
|
+
for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
270
|
+
var child = _step.value;
|
|
271
|
+
if (!/* @__PURE__ */ React.isValidElement(child)) continue;
|
|
272
|
+
if (!onChild(child)) continue;
|
|
273
|
+
var childProps = child.props;
|
|
274
|
+
if (childProps.children) forEachChildDeep(React.Children.toArray(childProps.children), onChild);
|
|
275
|
+
}
|
|
276
|
+
} catch (err) {
|
|
277
|
+
_didIteratorError = true;
|
|
278
|
+
_iteratorError = err;
|
|
279
|
+
} finally {
|
|
280
|
+
try {
|
|
281
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
282
|
+
} finally {
|
|
283
|
+
if (_didIteratorError) throw _iteratorError;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
354
286
|
}
|
|
355
287
|
function getStringChildren(child) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
288
|
+
var string = "";
|
|
289
|
+
forEachChildDeep(React.Children.toArray(child), function(child2) {
|
|
290
|
+
if (typeof child2.props.children === "string") {
|
|
291
|
+
string = child2.props.children;
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
return true;
|
|
295
|
+
});
|
|
296
|
+
return string;
|
|
365
297
|
}
|
|
366
298
|
var AlertDialog = (0, import_helpers.withStaticProperties)(AlertDialogInner, {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
299
|
+
Trigger: AlertDialogTrigger,
|
|
300
|
+
Portal: AlertDialogPortal,
|
|
301
|
+
Overlay: AlertDialogOverlay,
|
|
302
|
+
Content: AlertDialogContent,
|
|
303
|
+
Action: AlertDialogAction,
|
|
304
|
+
Cancel: AlertDialogCancel,
|
|
305
|
+
Destructive: AlertDialogDestructive,
|
|
306
|
+
Title: AlertDialogTitle,
|
|
307
|
+
Description: AlertDialogDescription
|
|
376
308
|
});
|
|
377
309
|
AlertDialog.displayName = ROOT_NAME;
|
|
310
|
+
|
|
378
311
|
//# sourceMappingURL=AlertDialog.native.js.map
|