@hanzogui/alert-dialog 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 WorkOS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,276 @@
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,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var AlertDialog_exports = {};
33
+ __export(AlertDialog_exports, {
34
+ AlertDialog: () => AlertDialog,
35
+ AlertDialogAction: () => AlertDialogAction,
36
+ AlertDialogCancel: () => AlertDialogCancel,
37
+ AlertDialogContent: () => AlertDialogContent,
38
+ AlertDialogDescription: () => AlertDialogDescription,
39
+ AlertDialogDestructive: () => AlertDialogDestructive,
40
+ AlertDialogOverlay: () => AlertDialogOverlay,
41
+ AlertDialogPortal: () => AlertDialogPortal,
42
+ AlertDialogTitle: () => AlertDialogTitle,
43
+ AlertDialogTrigger: () => AlertDialogTrigger
44
+ });
45
+ module.exports = __toCommonJS(AlertDialog_exports);
46
+ var import_gui_compose_refs = require("@hanzo/gui-compose-refs"),
47
+ import_gui_constants = require("@hanzo/gui-constants"),
48
+ import_gui_core = require("@hanzo/gui-core"),
49
+ import_gui_dialog = require("@hanzo/gui-dialog"),
50
+ import_gui_helpers = require("@hanzo/gui-helpers"),
51
+ import_gui_use_controllable_state = require("@hanzo/gui-use-controllable-state"),
52
+ React = __toESM(require("react"), 1),
53
+ import_react_native = require("react-native-web"),
54
+ import_jsx_runtime = require("react/jsx-runtime");
55
+ const getAlertDialogScope = scope => scope,
56
+ ROOT_NAME = "AlertDialog",
57
+ TRIGGER_NAME = "AlertDialogTrigger",
58
+ NativeAlertDialogTriggerFrame = (0, import_gui_core.styled)(import_gui_core.View, {
59
+ name: TRIGGER_NAME
60
+ }),
61
+ AlertDialogTrigger = NativeAlertDialogTriggerFrame.styleable(function (props, forwardedRef) {
62
+ if (props.__native) {
63
+ const {
64
+ __native,
65
+ onPress,
66
+ __onPress,
67
+ ...rest
68
+ } = props;
69
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeAlertDialogTriggerFrame, {
70
+ ...rest,
71
+ onPress: (0, import_gui_helpers.composeEventHandlers)(onPress, __onPress)
72
+ });
73
+ }
74
+ const {
75
+ scope,
76
+ ...triggerProps
77
+ } = props;
78
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogTrigger, {
79
+ scope: getAlertDialogScope(scope),
80
+ ...triggerProps,
81
+ ref: forwardedRef
82
+ });
83
+ });
84
+ const AlertDialogPortal = function (props) {
85
+ const {
86
+ scope,
87
+ ...portalProps
88
+ } = props;
89
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogPortal, {
90
+ scope: getAlertDialogScope(scope),
91
+ ...portalProps
92
+ });
93
+ },
94
+ OVERLAY_NAME = "AlertDialogOverlay",
95
+ AlertDialogOverlayFrame = (0, import_gui_core.styled)(import_gui_dialog.DialogOverlayFrame, {
96
+ name: OVERLAY_NAME
97
+ }),
98
+ AlertDialogOverlay = AlertDialogOverlayFrame.styleable(function (props, forwardedRef) {
99
+ const {
100
+ scope,
101
+ ...overlayProps
102
+ } = props;
103
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogOverlay, {
104
+ scope: getAlertDialogScope(scope),
105
+ ...overlayProps,
106
+ ref: forwardedRef
107
+ });
108
+ }),
109
+ CONTENT_NAME = "AlertDialogContent",
110
+ {
111
+ Provider: AlertDialogContextProvider,
112
+ useStyledContext: useAlertDialogContentContext
113
+ } = (0, import_gui_core.createStyledContext)({}, "AlertDialogContext"),
114
+ AlertDialogContent = React.forwardRef(function (props, forwardedRef) {
115
+ const {
116
+ scope,
117
+ children,
118
+ ...contentProps
119
+ } = props,
120
+ dialogScope = getAlertDialogScope(scope),
121
+ contentRef = React.useRef(null),
122
+ composedRefs = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, contentRef),
123
+ cancelRef = React.useRef(null),
124
+ destructiveRef = React.useRef(null);
125
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogWarningProvider, {
126
+ contentName: CONTENT_NAME,
127
+ titleName: TITLE_NAME,
128
+ docsSlug: "alert-dialog",
129
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AlertDialogContextProvider, {
130
+ scope,
131
+ cancelRef,
132
+ destructiveRef,
133
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_gui_dialog.DialogContent, {
134
+ role: "alertdialog",
135
+ "aria-modal": !0,
136
+ scope: dialogScope,
137
+ ...contentProps,
138
+ ref: composedRefs,
139
+ onOpenAutoFocus: (0, import_gui_helpers.composeEventHandlers)(contentProps.onOpenAutoFocus, event => {
140
+ event.preventDefault(), import_gui_constants.isWeb && cancelRef.current?.focus({
141
+ preventScroll: !0
142
+ });
143
+ }),
144
+ onPointerDownOutside: event => event.preventDefault(),
145
+ onInteractOutside: event => event.preventDefault(),
146
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_core.Slottable, {
147
+ children
148
+ }), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
149
+ contentRef
150
+ })]
151
+ })
152
+ })
153
+ });
154
+ }),
155
+ TITLE_NAME = "AlertDialogTitle",
156
+ AlertDialogTitleFrame = (0, import_gui_core.styled)(import_gui_core.View, {
157
+ name: TITLE_NAME
158
+ }),
159
+ AlertDialogTitle = AlertDialogTitleFrame.styleable(function (props, forwardedRef) {
160
+ const {
161
+ scope,
162
+ ...titleProps
163
+ } = props;
164
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogTitle, {
165
+ scope: getAlertDialogScope(scope),
166
+ ...titleProps,
167
+ ref: forwardedRef
168
+ });
169
+ }),
170
+ DESCRIPTION_NAME = "AlertDialogDescription",
171
+ AlertDialogDescriptionFrame = (0, import_gui_core.styled)(import_gui_core.View, {
172
+ name: DESCRIPTION_NAME
173
+ }),
174
+ AlertDialogDescription = AlertDialogDescriptionFrame.styleable(function (props, forwardedRef) {
175
+ const {
176
+ scope,
177
+ ...descriptionProps
178
+ } = props;
179
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogDescription, {
180
+ scope: getAlertDialogScope(scope),
181
+ ...descriptionProps,
182
+ ref: forwardedRef
183
+ });
184
+ }),
185
+ ACTION_NAME = "AlertDialogAction",
186
+ AlertDialogActionFrame = (0, import_gui_core.styled)(import_gui_core.View, {
187
+ name: ACTION_NAME
188
+ }),
189
+ AlertDialogAction = AlertDialogActionFrame.styleable(function (props, forwardedRef) {
190
+ const {
191
+ scope,
192
+ ...actionProps
193
+ } = props;
194
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogClose, {
195
+ scope: getAlertDialogScope(scope),
196
+ ...actionProps,
197
+ ref: forwardedRef
198
+ });
199
+ }),
200
+ CANCEL_NAME = "AlertDialogCancel",
201
+ AlertDialogCancelFrame = (0, import_gui_core.styled)(import_gui_core.View, {
202
+ name: CANCEL_NAME
203
+ }),
204
+ AlertDialogCancel = AlertDialogCancelFrame.styleable(function (props, forwardedRef) {
205
+ const {
206
+ scope,
207
+ ...cancelProps
208
+ } = props,
209
+ {
210
+ cancelRef
211
+ } = useAlertDialogContentContext(scope),
212
+ ref = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, cancelRef);
213
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogClose, {
214
+ scope: getAlertDialogScope(scope),
215
+ ...cancelProps,
216
+ ref
217
+ });
218
+ }),
219
+ DESTRUCTIVE_NAME = "AlertDialogDestructive",
220
+ AlertDialogDestructiveFrame = (0, import_gui_core.styled)(import_gui_core.View, {
221
+ name: DESTRUCTIVE_NAME
222
+ }),
223
+ AlertDialogDestructive = AlertDialogDestructiveFrame.styleable(function (props, forwardedRef) {
224
+ const {
225
+ scope,
226
+ ...destructiveProps
227
+ } = props,
228
+ {
229
+ destructiveRef
230
+ } = useAlertDialogContentContext(scope),
231
+ ref = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, destructiveRef);
232
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogClose, {
233
+ scope: getAlertDialogScope(scope),
234
+ ...destructiveProps,
235
+ ref
236
+ });
237
+ }),
238
+ DescriptionWarning = ({
239
+ contentRef
240
+ }) => (process.env.NODE_ENV === "development" && React.useEffect(() => {
241
+ if (!import_gui_constants.isWeb) return;
242
+ document.getElementById(
243
+ // @ts-ignore
244
+ contentRef.current?.getAttribute("aria-describedby")) || console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
245
+
246
+ 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.
247
+
248
+ 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.
249
+
250
+ For more information, see https://tamagui.dev/docs/components/alert-dialog`);
251
+ }, [contentRef]), null),
252
+ AlertDialogInner = props => {
253
+ const {
254
+ scope,
255
+ native,
256
+ ...alertDialogProps
257
+ } = props,
258
+ dialogScope = getAlertDialogScope(scope);
259
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.Dialog, {
260
+ scope: dialogScope,
261
+ ...alertDialogProps,
262
+ modal: !0
263
+ });
264
+ };
265
+ const AlertDialog = (0, import_gui_helpers.withStaticProperties)(AlertDialogInner, {
266
+ Trigger: AlertDialogTrigger,
267
+ Portal: AlertDialogPortal,
268
+ Overlay: AlertDialogOverlay,
269
+ Content: AlertDialogContent,
270
+ Action: AlertDialogAction,
271
+ Cancel: AlertDialogCancel,
272
+ Destructive: AlertDialogDestructive,
273
+ Title: AlertDialogTitle,
274
+ Description: AlertDialogDescription
275
+ });
276
+ AlertDialog.displayName = ROOT_NAME;
@@ -0,0 +1,379 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: !0
13
+ });
14
+ },
15
+ __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: !0
30
+ }) : target, mod)),
31
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: !0
33
+ }), mod);
34
+ var AlertDialog_exports = {};
35
+ __export(AlertDialog_exports, {
36
+ AlertDialog: () => AlertDialog,
37
+ AlertDialogAction: () => AlertDialogAction,
38
+ AlertDialogCancel: () => AlertDialogCancel,
39
+ AlertDialogContent: () => AlertDialogContent,
40
+ AlertDialogDescription: () => AlertDialogDescription,
41
+ AlertDialogDestructive: () => AlertDialogDestructive,
42
+ AlertDialogOverlay: () => AlertDialogOverlay,
43
+ AlertDialogPortal: () => AlertDialogPortal,
44
+ AlertDialogTitle: () => AlertDialogTitle,
45
+ AlertDialogTrigger: () => AlertDialogTrigger
46
+ });
47
+ module.exports = __toCommonJS(AlertDialog_exports);
48
+ var import_jsx_runtime = require("react/jsx-runtime"),
49
+ import_gui_compose_refs = require("@hanzo/gui-compose-refs"),
50
+ import_gui_constants = require("@hanzo/gui-constants"),
51
+ import_gui_core = require("@hanzo/gui-core"),
52
+ import_gui_dialog = require("@hanzo/gui-dialog"),
53
+ import_gui_helpers = require("@hanzo/gui-helpers"),
54
+ import_gui_use_controllable_state = require("@hanzo/gui-use-controllable-state"),
55
+ React = __toESM(require("react"), 1),
56
+ import_react_native = require("react-native"),
57
+ getAlertDialogScope = function (scope) {
58
+ return scope;
59
+ },
60
+ ROOT_NAME = "AlertDialog",
61
+ TRIGGER_NAME = "AlertDialogTrigger",
62
+ NativeAlertDialogTriggerFrame = (0, import_gui_core.styled)(import_gui_core.View, {
63
+ name: TRIGGER_NAME
64
+ }),
65
+ AlertDialogTrigger = NativeAlertDialogTriggerFrame.styleable(function (props, forwardedRef) {
66
+ if (props.__native) {
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_gui_helpers.composeEventHandlers)(onPress, __onPress)
76
+ });
77
+ }
78
+ var {
79
+ scope,
80
+ ...triggerProps
81
+ } = props;
82
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogTrigger, {
83
+ scope: getAlertDialogScope(scope),
84
+ ...triggerProps,
85
+ ref: forwardedRef
86
+ });
87
+ });
88
+ var AlertDialogPortal = function (props) {
89
+ var {
90
+ scope,
91
+ ...portalProps
92
+ } = props;
93
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogPortal, {
94
+ scope: getAlertDialogScope(scope),
95
+ ...portalProps
96
+ });
97
+ },
98
+ OVERLAY_NAME = "AlertDialogOverlay",
99
+ AlertDialogOverlayFrame = (0, import_gui_core.styled)(import_gui_dialog.DialogOverlayFrame, {
100
+ name: OVERLAY_NAME
101
+ }),
102
+ AlertDialogOverlay = AlertDialogOverlayFrame.styleable(function (props, forwardedRef) {
103
+ var {
104
+ scope,
105
+ ...overlayProps
106
+ } = props;
107
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogOverlay, {
108
+ scope: getAlertDialogScope(scope),
109
+ ...overlayProps,
110
+ ref: forwardedRef
111
+ });
112
+ }),
113
+ CONTENT_NAME = "AlertDialogContent",
114
+ {
115
+ Provider: AlertDialogContextProvider,
116
+ useStyledContext: useAlertDialogContentContext
117
+ } = (0, import_gui_core.createStyledContext)({}, "AlertDialogContext"),
118
+ AlertDialogContent = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
119
+ var {
120
+ scope,
121
+ children,
122
+ ...contentProps
123
+ } = props,
124
+ dialogScope = getAlertDialogScope(scope),
125
+ contentRef = React.useRef(null),
126
+ composedRefs = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, contentRef),
127
+ cancelRef = React.useRef(null),
128
+ destructiveRef = React.useRef(null);
129
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogWarningProvider, {
130
+ contentName: CONTENT_NAME,
131
+ titleName: TITLE_NAME,
132
+ docsSlug: "alert-dialog",
133
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AlertDialogContextProvider, {
134
+ scope,
135
+ cancelRef,
136
+ destructiveRef,
137
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_gui_dialog.DialogContent, {
138
+ role: "alertdialog",
139
+ "aria-modal": !0,
140
+ scope: dialogScope,
141
+ ...contentProps,
142
+ ref: composedRefs,
143
+ onOpenAutoFocus: (0, import_gui_helpers.composeEventHandlers)(contentProps.onOpenAutoFocus, function (event) {
144
+ if (event.preventDefault(), import_gui_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_gui_core.Slottable, {
166
+ children
167
+ }), process.env.NODE_ENV === "development" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(DescriptionWarning, {
168
+ contentRef
169
+ })]
170
+ })
171
+ })
172
+ });
173
+ }),
174
+ TITLE_NAME = "AlertDialogTitle",
175
+ AlertDialogTitleFrame = (0, import_gui_core.styled)(import_gui_core.View, {
176
+ name: TITLE_NAME
177
+ }),
178
+ AlertDialogTitle = AlertDialogTitleFrame.styleable(function (props, forwardedRef) {
179
+ var {
180
+ scope,
181
+ ...titleProps
182
+ } = props;
183
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogTitle, {
184
+ scope: getAlertDialogScope(scope),
185
+ ...titleProps,
186
+ ref: forwardedRef
187
+ });
188
+ }),
189
+ DESCRIPTION_NAME = "AlertDialogDescription",
190
+ AlertDialogDescriptionFrame = (0, import_gui_core.styled)(import_gui_core.View, {
191
+ name: DESCRIPTION_NAME
192
+ }),
193
+ AlertDialogDescription = AlertDialogDescriptionFrame.styleable(function (props, forwardedRef) {
194
+ var {
195
+ scope,
196
+ ...descriptionProps
197
+ } = props;
198
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogDescription, {
199
+ scope: getAlertDialogScope(scope),
200
+ ...descriptionProps,
201
+ ref: forwardedRef
202
+ });
203
+ }),
204
+ ACTION_NAME = "AlertDialogAction",
205
+ AlertDialogActionFrame = (0, import_gui_core.styled)(import_gui_core.View, {
206
+ name: ACTION_NAME
207
+ }),
208
+ AlertDialogAction = AlertDialogActionFrame.styleable(function (props, forwardedRef) {
209
+ var {
210
+ scope,
211
+ ...actionProps
212
+ } = props;
213
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogClose, {
214
+ scope: getAlertDialogScope(scope),
215
+ ...actionProps,
216
+ ref: forwardedRef
217
+ });
218
+ }),
219
+ CANCEL_NAME = "AlertDialogCancel",
220
+ AlertDialogCancelFrame = (0, import_gui_core.styled)(import_gui_core.View, {
221
+ name: CANCEL_NAME
222
+ }),
223
+ AlertDialogCancel = AlertDialogCancelFrame.styleable(function (props, forwardedRef) {
224
+ var {
225
+ scope,
226
+ ...cancelProps
227
+ } = props,
228
+ {
229
+ cancelRef
230
+ } = useAlertDialogContentContext(scope),
231
+ ref = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, cancelRef);
232
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogClose, {
233
+ scope: getAlertDialogScope(scope),
234
+ ...cancelProps,
235
+ ref
236
+ });
237
+ }),
238
+ DESTRUCTIVE_NAME = "AlertDialogDestructive",
239
+ AlertDialogDestructiveFrame = (0, import_gui_core.styled)(import_gui_core.View, {
240
+ name: DESTRUCTIVE_NAME
241
+ }),
242
+ AlertDialogDestructive = AlertDialogDestructiveFrame.styleable(function (props, forwardedRef) {
243
+ var {
244
+ scope,
245
+ ...destructiveProps
246
+ } = props,
247
+ {
248
+ destructiveRef
249
+ } = useAlertDialogContentContext(scope),
250
+ ref = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, destructiveRef);
251
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.DialogClose, {
252
+ scope: getAlertDialogScope(scope),
253
+ ...destructiveProps,
254
+ ref
255
+ });
256
+ }),
257
+ DescriptionWarning = function (param) {
258
+ var {
259
+ contentRef
260
+ } = param;
261
+ return process.env.NODE_ENV === "development" && React.useEffect(function () {
262
+ var _contentRef_current;
263
+ if (import_gui_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.
266
+
267
+ 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
+
269
+ 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
+
271
+ For more information, see https://tamagui.dev/docs/components/alert-dialog`);
272
+ }
273
+ }, [contentRef]), null;
274
+ },
275
+ AlertDialogInner = function (props) {
276
+ var {
277
+ scope,
278
+ native,
279
+ ...alertDialogProps
280
+ } = props,
281
+ dialogScope = getAlertDialogScope(scope),
282
+ [open, setOpen] = (0, import_gui_use_controllable_state.useControllableState)({
283
+ prop: props.open,
284
+ defaultProp: props.defaultOpen || !1,
285
+ onChange: props.onOpenChange,
286
+ transition: !0
287
+ }),
288
+ triggerElement = null,
289
+ title = "",
290
+ description = "",
291
+ buttons = [];
292
+ return forEachChildDeep(React.Children.toArray(props.children), function (child) {
293
+ if (! /* @__PURE__ */React.isValidElement(child)) return !1;
294
+ var name = (0, import_gui_core.isTamaguiElement)(child) ? child.type.staticConfig.componentName : child.type.displayName;
295
+ switch (name) {
296
+ case TRIGGER_NAME:
297
+ return triggerElement = /* @__PURE__ */React.cloneElement(child, {
298
+ __native: !0
299
+ }), !1;
300
+ case TITLE_NAME:
301
+ return title = getStringChildren(child), !1;
302
+ case DESCRIPTION_NAME:
303
+ return description = getStringChildren(child), !1;
304
+ case ACTION_NAME:
305
+ case DESTRUCTIVE_NAME:
306
+ case CANCEL_NAME:
307
+ {
308
+ var style = name === ACTION_NAME ? "default" : name === DESTRUCTIVE_NAME ? "destructive" : "cancel",
309
+ text = getStringChildren(child),
310
+ onPress = function () {
311
+ var _childProps_onPress,
312
+ childProps = child.props;
313
+ childProps == null || (_childProps_onPress = childProps.onPress) === null || _childProps_onPress === void 0 || _childProps_onPress.call(childProps, {
314
+ native: !0
315
+ }), setOpen(!1);
316
+ };
317
+ return buttons.push({
318
+ style,
319
+ text,
320
+ // @ts-ignore
321
+ onPress
322
+ }), !1;
323
+ }
324
+ default:
325
+ return !0;
326
+ }
327
+ }), (0, import_gui_constants.useIsomorphicLayoutEffect)(function () {
328
+ !open || !native || (title || description) && import_react_native.Alert.alert(title, description, buttons);
329
+ }, [native, open]), native ? /* @__PURE__ */React.cloneElement(triggerElement, {
330
+ __onPress: function () {
331
+ setOpen(!0);
332
+ }
333
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_dialog.Dialog, {
334
+ scope: dialogScope,
335
+ ...alertDialogProps,
336
+ modal: !0
337
+ });
338
+ };
339
+ function forEachChildDeep(children, onChild) {
340
+ var _iteratorNormalCompletion = !0,
341
+ _didIteratorError = !1,
342
+ _iteratorError = void 0;
343
+ try {
344
+ for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
345
+ var child = _step.value;
346
+ if (/* @__PURE__ */React.isValidElement(child) && onChild(child)) {
347
+ var childProps = child.props;
348
+ childProps.children && forEachChildDeep(React.Children.toArray(childProps.children), onChild);
349
+ }
350
+ }
351
+ } catch (err) {
352
+ _didIteratorError = !0, _iteratorError = err;
353
+ } finally {
354
+ try {
355
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
356
+ } finally {
357
+ if (_didIteratorError) throw _iteratorError;
358
+ }
359
+ }
360
+ }
361
+ function getStringChildren(child) {
362
+ var string = "";
363
+ return forEachChildDeep(React.Children.toArray(child), function (child2) {
364
+ return typeof child2.props.children == "string" ? (string = child2.props.children, !1) : !0;
365
+ }), string;
366
+ }
367
+ var AlertDialog = (0, import_gui_helpers.withStaticProperties)(AlertDialogInner, {
368
+ Trigger: AlertDialogTrigger,
369
+ Portal: AlertDialogPortal,
370
+ Overlay: AlertDialogOverlay,
371
+ Content: AlertDialogContent,
372
+ Action: AlertDialogAction,
373
+ Cancel: AlertDialogCancel,
374
+ Destructive: AlertDialogDestructive,
375
+ Title: AlertDialogTitle,
376
+ Description: AlertDialogDescription
377
+ });
378
+ AlertDialog.displayName = ROOT_NAME;
379
+ //# sourceMappingURL=AlertDialog.native.js.map