@tamagui/alert-dialog 3.0.0-beta.922.1 → 3.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.
Files changed (52) hide show
  1. package/dist/cjs/AlertDialog.cjs +34 -31
  2. package/dist/cjs/AlertDialog.native.cjs +33 -106
  3. package/dist/cjs/AlertDialog.native.js +33 -106
  4. package/dist/cjs/AlertDialog.native.js.map +1 -1
  5. package/dist/cjs/alertDialogPart.cjs +30 -0
  6. package/dist/cjs/alertDialogPart.native.cjs +32 -0
  7. package/dist/cjs/alertDialogPart.native.js +34 -0
  8. package/dist/cjs/alertDialogPart.native.js.map +1 -0
  9. package/dist/cjs/useNativeAlertDialog.cjs +24 -0
  10. package/dist/cjs/useNativeAlertDialog.native.cjs +139 -0
  11. package/dist/cjs/useNativeAlertDialog.native.js +141 -0
  12. package/dist/cjs/useNativeAlertDialog.native.js.map +1 -0
  13. package/dist/esm/AlertDialog.mjs +35 -19
  14. package/dist/esm/AlertDialog.mjs.map +1 -1
  15. package/dist/esm/AlertDialog.native.js +33 -104
  16. package/dist/esm/AlertDialog.native.js.map +1 -1
  17. package/dist/esm/alertDialogPart.mjs +7 -0
  18. package/dist/esm/alertDialogPart.mjs.map +1 -0
  19. package/dist/esm/alertDialogPart.native.js +7 -0
  20. package/dist/esm/alertDialogPart.native.js.map +1 -0
  21. package/dist/esm/useNativeAlertDialog.mjs +4 -0
  22. package/dist/esm/useNativeAlertDialog.mjs.map +1 -0
  23. package/dist/esm/useNativeAlertDialog.native.js +112 -0
  24. package/dist/esm/useNativeAlertDialog.native.js.map +1 -0
  25. package/dist/jsx/AlertDialog.mjs +35 -19
  26. package/dist/jsx/AlertDialog.mjs.map +1 -1
  27. package/dist/jsx/AlertDialog.native.cjs +33 -106
  28. package/dist/jsx/AlertDialog.native.js +33 -106
  29. package/dist/jsx/AlertDialog.native.js.map +1 -1
  30. package/dist/jsx/alertDialogPart.mjs +7 -0
  31. package/dist/jsx/alertDialogPart.mjs.map +1 -0
  32. package/dist/jsx/alertDialogPart.native.cjs +32 -0
  33. package/dist/jsx/alertDialogPart.native.js +34 -0
  34. package/dist/jsx/alertDialogPart.native.js.map +1 -0
  35. package/dist/jsx/useNativeAlertDialog.mjs +4 -0
  36. package/dist/jsx/useNativeAlertDialog.mjs.map +1 -0
  37. package/dist/jsx/useNativeAlertDialog.native.cjs +139 -0
  38. package/dist/jsx/useNativeAlertDialog.native.js +141 -0
  39. package/dist/jsx/useNativeAlertDialog.native.js.map +1 -0
  40. package/package.json +21 -19
  41. package/src/AlertDialog.tsx +19 -141
  42. package/src/alertDialogPart.ts +26 -0
  43. package/src/useNativeAlertDialog.native.tsx +129 -0
  44. package/src/useNativeAlertDialog.ts +11 -0
  45. package/types/AlertDialog.d.ts +41 -83
  46. package/types/AlertDialog.d.ts.map +1 -1
  47. package/types/alertDialogPart.d.ts +15 -0
  48. package/types/alertDialogPart.d.ts.map +1 -0
  49. package/types/useNativeAlertDialog.d.ts +11 -0
  50. package/types/useNativeAlertDialog.d.ts.map +1 -0
  51. package/types/useNativeAlertDialog.native.d.ts +11 -0
  52. package/types/useNativeAlertDialog.native.d.ts.map +1 -0
@@ -0,0 +1,112 @@
1
+ import { useIsomorphicLayoutEffect } from "@tamagui/constants";
2
+ import { isTamaguiElement } from "@tamagui/core";
3
+ import { useControllableState } from "@tamagui/use-controllable-state";
4
+ import * as React from "react";
5
+ import { Alert } from "react-native";
6
+ import { ALERT_DIALOG_PART } from "./alertDialogPart.native.js";
7
+
8
+ var useNativeAlertDialog = function(props) {
9
+ var { native } = props;
10
+ var [open, setOpen] = useControllableState({
11
+ prop: props.open,
12
+ defaultProp: props.defaultOpen || false,
13
+ onChange: props.onOpenChange,
14
+ transition: true
15
+ });
16
+ var triggerElement = null;
17
+ var title = "";
18
+ var description = "";
19
+ var buttons = [];
20
+ forEachChildDeep(React.Children.toArray(props.children), function(child) {
21
+ if (!/* @__PURE__ */ React.isValidElement(child)) return false;
22
+ var part = isTamaguiElement(child) ? child.type.staticConfig[ALERT_DIALOG_PART] : void 0;
23
+ switch (part) {
24
+ case "trigger": {
25
+ triggerElement = /* @__PURE__ */ React.cloneElement(child, { __native: true });
26
+ return false;
27
+ }
28
+ case "title": {
29
+ title = getStringChildren(child);
30
+ return false;
31
+ }
32
+ case "description": {
33
+ description = getStringChildren(child);
34
+ return false;
35
+ }
36
+ case "action":
37
+ case "destructive":
38
+ case "cancel": {
39
+ var style = part === "action" ? "default" : part === "destructive" ? "destructive" : "cancel";
40
+ var text = getStringChildren(child);
41
+ var onPress = function() {
42
+ var _childProps_onPress;
43
+ var childProps = child.props;
44
+ childProps === null || childProps === void 0 ? void 0 : (_childProps_onPress = childProps.onPress) === null || _childProps_onPress === void 0 ? void 0 : _childProps_onPress.call(childProps, { native: true });
45
+ setOpen(false);
46
+ };
47
+ buttons.push({
48
+ style,
49
+ text,
50
+ onPress
51
+ });
52
+ return false;
53
+ }
54
+ default: {
55
+ return true;
56
+ }
57
+ }
58
+ });
59
+ useIsomorphicLayoutEffect(function() {
60
+ if (!open || !native) return;
61
+ if (title || description) {
62
+ Alert.alert(title, description, buttons);
63
+ }
64
+ }, [native, open]);
65
+ if (native) {
66
+ return /* @__PURE__ */ React.cloneElement(triggerElement, { __onPress: function() {
67
+ setOpen(true);
68
+ } });
69
+ }
70
+ return null;
71
+ };
72
+ function forEachChildDeep(children, onChild) {
73
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
74
+ try {
75
+ for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
76
+ var child = _step.value;
77
+ if (!/* @__PURE__ */ React.isValidElement(child)) continue;
78
+ if (!onChild(child)) continue;
79
+ var childProps = child.props;
80
+ if (childProps.children) {
81
+ forEachChildDeep(React.Children.toArray(childProps.children), onChild);
82
+ }
83
+ }
84
+ } catch (err) {
85
+ _didIteratorError = true;
86
+ _iteratorError = err;
87
+ } finally {
88
+ try {
89
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
90
+ _iterator.return();
91
+ }
92
+ } finally {
93
+ if (_didIteratorError) {
94
+ throw _iteratorError;
95
+ }
96
+ }
97
+ }
98
+ }
99
+ function getStringChildren(child) {
100
+ var string = "";
101
+ forEachChildDeep(React.Children.toArray(child), function(child2) {
102
+ if (typeof child2.props.children === "string") {
103
+ string = child2.props.children;
104
+ return false;
105
+ }
106
+ return true;
107
+ });
108
+ return string;
109
+ }
110
+
111
+ export { useNativeAlertDialog };
112
+ //# sourceMappingURL=useNativeAlertDialog.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNativeAlertDialog.native.js","names":[],"sources":["esm/useNativeAlertDialog.native.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { isTamaguiElement } from \"@tamagui/core\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport * as React from \"react\";\nimport { Alert } from \"react-native\";\nimport { ALERT_DIALOG_PART } from \"./alertDialogPart\";\nvar useNativeAlertDialog = function(props) {\n var { native } = props;\n var [open, setOpen] = useControllableState({\n prop: props.open,\n defaultProp: props.defaultOpen || false,\n onChange: props.onOpenChange,\n transition: true\n });\n var triggerElement = null;\n var title = \"\";\n var description = \"\";\n var buttons = [];\n forEachChildDeep(React.Children.toArray(props.children), function(child) {\n if (!/* @__PURE__ */ React.isValidElement(child)) return false;\n var part = isTamaguiElement(child) ? child.type.staticConfig[ALERT_DIALOG_PART] : void 0;\n switch (part) {\n case \"trigger\": {\n triggerElement = /* @__PURE__ */ React.cloneElement(child, {\n __native: true\n });\n return false;\n }\n case \"title\": {\n title = getStringChildren(child);\n return false;\n }\n case \"description\": {\n description = getStringChildren(child);\n return false;\n }\n case \"action\":\n case \"destructive\":\n case \"cancel\": {\n var style = part === \"action\" ? \"default\" : part === \"destructive\" ? \"destructive\" : \"cancel\";\n var text = getStringChildren(child);\n var onPress = function() {\n var _childProps_onPress;\n var childProps = child.props;\n childProps === null || childProps === void 0 ? void 0 : (_childProps_onPress = childProps.onPress) === null || _childProps_onPress === void 0 ? void 0 : _childProps_onPress.call(childProps, {\n native: true\n });\n setOpen(false);\n };\n buttons.push({\n style,\n text,\n // @ts-ignore\n onPress\n });\n return false;\n }\n default: {\n return true;\n }\n }\n });\n useIsomorphicLayoutEffect(function() {\n if (!open || !native) return;\n if (title || description) {\n Alert.alert(title, description, buttons);\n }\n }, [\n native,\n open\n ]);\n if (native) {\n return /* @__PURE__ */ React.cloneElement(triggerElement, {\n __onPress: function() {\n setOpen(true);\n }\n });\n }\n return null;\n};\nfunction forEachChildDeep(children, onChild) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var child = _step.value;\n if (!/* @__PURE__ */ React.isValidElement(child)) continue;\n if (!onChild(child)) continue;\n var childProps = child.props;\n if (childProps.children) {\n forEachChildDeep(React.Children.toArray(childProps.children), onChild);\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction getStringChildren(child) {\n var string = \"\";\n forEachChildDeep(React.Children.toArray(child), function(child2) {\n if (typeof child2.props.children === \"string\") {\n string = child2.props.children;\n return false;\n }\n return true;\n });\n return string;\n}\nexport {\n useNativeAlertDialog\n};\n//# sourceMappingURL=useNativeAlertDialog.native.js.map\n"],"mappings":";;;;;;;;AAMA,IAAI,uBAAuB,SAAS,OAAO;CACzC,IAAI,EAAE,WAAW;CACjB,IAAI,CAAC,MAAM,WAAW,qBAAqB;EACzC,MAAM,MAAM;EACZ,aAAa,MAAM,eAAe;EAClC,UAAU,MAAM;EAChB,YAAY;CACd,CAAC;CACD,IAAI,iB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T;AACA,SAAS,iBAAiB,UAAU,SAAS;CAC3C,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;CACvF,IAAI;EACF,KAAK,IAAI,YAAY,SAAS,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GACzJ,IAAI,QAAQ,MAAM;GAClB,IAAI,CAAiB,sBAAM,eAAe,KAAK,GAAG;GAClD,IAAI,CAAC,QAAQ,KAAK,GAAG;GACrB,IAAI,aAAa,MAAM;GACvB,IAAI,WAAW,UAAU;IACvB,iBAAiB,MAAM,SAAS,QAAQ,WAAW,QAAQ,GAAG,OAAO;GACvE;EACF;CACF,SAAS,KAAK;EACZ,oBAAoB;EACpB,iBAAiB;CACnB,UAAU;EACR,IAAI;GACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;IAC1D,UAAU,OAAO;GACnB;EACF,UAAU;GACR,IAAI,mBAAmB;IACrB,MAAM;GACR;EACF;CACF;AACF;AACA,SAAS,kBAAkB,OAAO;CAChC,IAAI,SAAS;CACb,iBAAiB,MAAM,SAAS,QAAQ,KAAK,GAAG,SAAS,QAAQ;EAC/D,IAAI,OAAO,OAAO,MAAM,aAAa,UAAU;GAC7C,SAAS,OAAO,MAAM;GACtB,OAAO;EACT;EACA,OAAO;CACT,CAAC;CACD,OAAO;AACT"}
@@ -1,18 +1,17 @@
1
- import { Slottable, View, createRefComponent, createStyledContext, createStyledHOC, styled } from "@tamagui/core";
1
+ import { Slottable, View, createStyledContext, createStyledHOC, styled } from "@tamagui/core";
2
2
  import { useComposedRefs } from "@tamagui/compose-refs";
3
3
  import { isWeb } from "@tamagui/constants";
4
- import { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from "@tamagui/dialog";
4
+ import { Dialog, DialogClose, DialogContent, DialogContentFrame, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from "@tamagui/dialog";
5
5
  import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
6
6
  import * as React from "react";
7
+ import { markAlertDialogPart } from "./alertDialogPart.mjs";
8
+ import { useNativeAlertDialog } from "./useNativeAlertDialog.mjs";
7
9
  import { jsx, jsxs } from "react/jsx-runtime";
8
10
 
9
11
  const getAlertDialogScope = (scope) => scope;
10
12
  const ROOT_NAME = "AlertDialog";
11
- const ALERT_DIALOG_PART = /* @__PURE__ */ Symbol("AlertDialogPart");
12
- const markAlertDialogPart = (component, part) => {
13
- Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });
14
- };
15
- const NativeAlertDialogTriggerFrame = styled(View, { displayName: "AlertDialogTrigger" });
13
+ const TRIGGER_NAME = "AlertDialogTrigger";
14
+ const NativeAlertDialogTriggerFrame = styled(View, { displayName: TRIGGER_NAME });
16
15
  markAlertDialogPart(NativeAlertDialogTriggerFrame, "trigger");
17
16
  const AlertDialogTrigger = createStyledHOC(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {
18
17
  if (props["__native"]) {
@@ -36,7 +35,9 @@ const AlertDialogPortal = function AlertDialogPortal2(props) {
36
35
  ...portalProps
37
36
  });
38
37
  };
39
- const AlertDialogOverlay = createStyledHOC(styled(DialogOverlayFrame, { displayName: "AlertDialogOverlay" }), function AlertDialogOverlay2(props, forwardedRef) {
38
+ const OVERLAY_NAME = "AlertDialogOverlay";
39
+ const AlertDialogOverlayFrame = styled(DialogOverlayFrame, { displayName: OVERLAY_NAME });
40
+ const AlertDialogOverlay = createStyledHOC(AlertDialogOverlayFrame, function AlertDialogOverlay2(props, forwardedRef) {
40
41
  const { scope, ...overlayProps } = props;
41
42
  return /* @__PURE__ */ jsx(DialogOverlay, {
42
43
  scope: getAlertDialogScope(scope),
@@ -46,12 +47,14 @@ const AlertDialogOverlay = createStyledHOC(styled(DialogOverlayFrame, { displayN
46
47
  });
47
48
  const CONTENT_NAME = "AlertDialogContent";
48
49
  const { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = createStyledContext({}, "AlertDialogContext");
49
- const AlertDialogContent = createRefComponent(function AlertDialogContent2(props, forwardedRef) {
50
+ const AlertDialogContentFrame = styled(DialogContentFrame, { displayName: CONTENT_NAME });
51
+ const AlertDialogContent = createStyledHOC(AlertDialogContentFrame, function AlertDialogContent2(props, forwardedRef) {
50
52
  const { scope, children, ...contentProps } = props;
51
53
  const dialogScope = getAlertDialogScope(scope);
52
54
  const contentRef = React.useRef(null);
53
55
  const composedRefs = useComposedRefs(forwardedRef, contentRef);
54
56
  const cancelRef = React.useRef(null);
57
+ const destructiveRef = React.useRef(null);
55
58
  return /* @__PURE__ */ jsx(DialogWarningProvider, {
56
59
  contentName: CONTENT_NAME,
57
60
  titleName: TITLE_NAME,
@@ -59,7 +62,7 @@ const AlertDialogContent = createRefComponent(function AlertDialogContent2(props
59
62
  children: /* @__PURE__ */ jsx(AlertDialogContextProvider, {
60
63
  scope,
61
64
  cancelRef,
62
- destructiveRef: React.useRef(null),
65
+ destructiveRef,
63
66
  children: /* @__PURE__ */ jsxs(DialogContent, {
64
67
  role: "alertdialog",
65
68
  "aria-modal": true,
@@ -68,7 +71,9 @@ const AlertDialogContent = createRefComponent(function AlertDialogContent2(props
68
71
  ref: composedRefs,
69
72
  onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {
70
73
  event.cancel();
71
- if (isWeb) cancelRef.current?.focus({ preventScroll: true });
74
+ if (isWeb) {
75
+ cancelRef.current?.focus({ preventScroll: true });
76
+ }
72
77
  }),
73
78
  onPointerDownOutside: (event) => event.cancel(),
74
79
  onInteractOutside: (event) => event.cancel(),
@@ -99,7 +104,8 @@ const AlertDialogDescription = createStyledHOC(AlertDialogDescriptionFrame, func
99
104
  ref: forwardedRef
100
105
  });
101
106
  });
102
- const AlertDialogActionFrame = styled(View, { displayName: "AlertDialogAction" });
107
+ const ACTION_NAME = "AlertDialogAction";
108
+ const AlertDialogActionFrame = styled(View, { displayName: ACTION_NAME });
103
109
  markAlertDialogPart(AlertDialogActionFrame, "action");
104
110
  const AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {
105
111
  const { scope, ...actionProps } = props;
@@ -109,7 +115,8 @@ const AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function Alert
109
115
  ref: forwardedRef
110
116
  });
111
117
  });
112
- const AlertDialogCancelFrame = styled(View, { displayName: "AlertDialogCancel" });
118
+ const CANCEL_NAME = "AlertDialogCancel";
119
+ const AlertDialogCancelFrame = styled(View, { displayName: CANCEL_NAME });
113
120
  markAlertDialogPart(AlertDialogCancelFrame, "cancel");
114
121
  const AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {
115
122
  const { scope, ...cancelProps } = props;
@@ -121,7 +128,8 @@ const AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function Alert
121
128
  ref
122
129
  });
123
130
  });
124
- const AlertDialogDestructiveFrame = styled(View, { displayName: "AlertDialogDestructive" });
131
+ const DESTRUCTIVE_NAME = "AlertDialogDestructive";
132
+ const AlertDialogDestructiveFrame = styled(View, { displayName: DESTRUCTIVE_NAME });
125
133
  markAlertDialogPart(AlertDialogDestructiveFrame, "destructive");
126
134
  const AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {
127
135
  const { scope, ...destructiveProps } = props;
@@ -134,22 +142,30 @@ const AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, func
134
142
  });
135
143
  });
136
144
  const DescriptionWarning = ({ contentRef }) => {
137
- if (process.env.NODE_ENV === "development") React.useEffect(() => {
138
- if (!isWeb) return;
139
- if (!document.getElementById(contentRef.current?.getAttribute("aria-describedby"))) console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
145
+ if (process.env.NODE_ENV === "development") {
146
+ React.useEffect(() => {
147
+ if (!isWeb) return;
148
+ const hasDescription = document.getElementById(contentRef.current?.getAttribute("aria-describedby"));
149
+ if (!hasDescription) {
150
+ console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
140
151
 
141
152
  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.
142
153
 
143
154
  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.
144
155
 
145
156
  For more information, see https://tamagui.dev/docs/components/alert-dialog`);
146
- }, [contentRef]);
157
+ }
158
+ }, [contentRef]);
159
+ }
147
160
  return null;
148
161
  };
149
162
  const AlertDialogInner = (props) => {
150
163
  const { scope, native, ...alertDialogProps } = props;
164
+ const dialogScope = getAlertDialogScope(scope);
165
+ const nativeAlert = useNativeAlertDialog(props);
166
+ if (nativeAlert) return nativeAlert;
151
167
  return /* @__PURE__ */ jsx(Dialog, {
152
- scope: getAlertDialogScope(scope),
168
+ scope: dialogScope,
153
169
  ...alertDialogProps,
154
170
  modal: true
155
171
  });
@@ -1 +1 @@
1
- {"version":3,"file":"AlertDialog.js","names":[],"sources":["jsx/AlertDialog.js"],"sourcesContent":["import { Slottable, View, createRefComponent, createStyledContext, createStyledHOC, styled } from \"@tamagui/core\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from \"@tamagui/dialog\";\nimport { composeEventHandlers, withStaticProperties } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\n\nconst getAlertDialogScope = (scope) => scope;\nconst ROOT_NAME = \"AlertDialog\";\nconst ALERT_DIALOG_PART = /* @__PURE__ */ Symbol(\"AlertDialogPart\");\nconst markAlertDialogPart = (component, part) => {\n\tObject.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });\n};\nconst NativeAlertDialogTriggerFrame = styled(View, { displayName: \"AlertDialogTrigger\" });\nmarkAlertDialogPart(NativeAlertDialogTriggerFrame, \"trigger\");\nconst AlertDialogTrigger = createStyledHOC(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {\n\tif (props[\"__native\"]) {\n\t\tconst { __native, onPress, __onPress, ...rest } = props;\n\t\treturn /* @__PURE__ */ jsx(NativeAlertDialogTriggerFrame, {\n\t\t\t...rest,\n\t\t\tonPress: composeEventHandlers(onPress, __onPress)\n\t\t});\n\t}\n\tconst { scope, ...triggerProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogTrigger, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...triggerProps,\n\t\tref: forwardedRef\n\t});\n});\nconst AlertDialogPortal = function AlertDialogPortal2(props) {\n\tconst { scope, ...portalProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogPortal, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...portalProps\n\t});\n};\nconst AlertDialogOverlay = createStyledHOC(styled(DialogOverlayFrame, { displayName: \"AlertDialogOverlay\" }), function AlertDialogOverlay2(props, forwardedRef) {\n\tconst { scope, ...overlayProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogOverlay, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...overlayProps,\n\t\tref: forwardedRef\n\t});\n});\nconst CONTENT_NAME = \"AlertDialogContent\";\nconst { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = createStyledContext({}, \"AlertDialogContext\");\nconst AlertDialogContent = createRefComponent(function AlertDialogContent2(props, forwardedRef) {\n\tconst { scope, children, ...contentProps } = props;\n\tconst dialogScope = getAlertDialogScope(scope);\n\tconst contentRef = React.useRef(null);\n\tconst composedRefs = useComposedRefs(forwardedRef, contentRef);\n\tconst cancelRef = React.useRef(null);\n\treturn /* @__PURE__ */ jsx(DialogWarningProvider, {\n\t\tcontentName: CONTENT_NAME,\n\t\ttitleName: TITLE_NAME,\n\t\tdocsSlug: \"alert-dialog\",\n\t\tchildren: /* @__PURE__ */ jsx(AlertDialogContextProvider, {\n\t\t\tscope,\n\t\t\tcancelRef,\n\t\t\tdestructiveRef: React.useRef(null),\n\t\t\tchildren: /* @__PURE__ */ jsxs(DialogContent, {\n\t\t\t\trole: \"alertdialog\",\n\t\t\t\t\"aria-modal\": true,\n\t\t\t\tscope: dialogScope,\n\t\t\t\t...contentProps,\n\t\t\t\tref: composedRefs,\n\t\t\t\tonOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t\tif (isWeb) cancelRef.current?.focus({ preventScroll: true });\n\t\t\t\t}),\n\t\t\t\tonPointerDownOutside: (event) => event.cancel(),\n\t\t\t\tonInteractOutside: (event) => event.cancel(),\n\t\t\t\tchildren: [/* @__PURE__ */ jsx(Slottable, { children }), process.env.NODE_ENV === \"development\" && /* @__PURE__ */ jsx(DescriptionWarning, { contentRef })]\n\t\t\t})\n\t\t})\n\t});\n});\nconst TITLE_NAME = \"AlertDialogTitle\";\nconst AlertDialogTitleFrame = styled(View, { displayName: TITLE_NAME });\nmarkAlertDialogPart(AlertDialogTitleFrame, \"title\");\nconst AlertDialogTitle = createStyledHOC(AlertDialogTitleFrame, function AlertDialogTitle2(props, forwardedRef) {\n\tconst { scope, ...titleProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogTitle, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...titleProps,\n\t\tref: forwardedRef\n\t});\n});\nconst DESCRIPTION_NAME = \"AlertDialogDescription\";\nconst AlertDialogDescriptionFrame = styled(View, { displayName: DESCRIPTION_NAME });\nmarkAlertDialogPart(AlertDialogDescriptionFrame, \"description\");\nconst AlertDialogDescription = createStyledHOC(AlertDialogDescriptionFrame, function AlertDialogDescription2(props, forwardedRef) {\n\tconst { scope, ...descriptionProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogDescription, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...descriptionProps,\n\t\tref: forwardedRef\n\t});\n});\nconst AlertDialogActionFrame = styled(View, { displayName: \"AlertDialogAction\" });\nmarkAlertDialogPart(AlertDialogActionFrame, \"action\");\nconst AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {\n\tconst { scope, ...actionProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogClose, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...actionProps,\n\t\tref: forwardedRef\n\t});\n});\nconst AlertDialogCancelFrame = styled(View, { displayName: \"AlertDialogCancel\" });\nmarkAlertDialogPart(AlertDialogCancelFrame, \"cancel\");\nconst AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {\n\tconst { scope, ...cancelProps } = props;\n\tconst { cancelRef } = useAlertDialogContentContext(scope);\n\tconst ref = useComposedRefs(forwardedRef, cancelRef);\n\treturn /* @__PURE__ */ jsx(DialogClose, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...cancelProps,\n\t\tref\n\t});\n});\nconst AlertDialogDestructiveFrame = styled(View, { displayName: \"AlertDialogDestructive\" });\nmarkAlertDialogPart(AlertDialogDestructiveFrame, \"destructive\");\nconst AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {\n\tconst { scope, ...destructiveProps } = props;\n\tconst { destructiveRef } = useAlertDialogContentContext(scope);\n\tconst ref = useComposedRefs(forwardedRef, destructiveRef);\n\treturn /* @__PURE__ */ jsx(DialogClose, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...destructiveProps,\n\t\tref\n\t});\n});\nconst DescriptionWarning = ({ contentRef }) => {\n\tif (process.env.NODE_ENV === \"development\") React.useEffect(() => {\n\t\tif (!isWeb) return;\n\t\tif (!document.getElementById(contentRef.current?.getAttribute(\"aria-describedby\"))) console.warn(`\\`${CONTENT_NAME}\\` requires a description for the component to be accessible for screen reader users.\n \n 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.\n \n 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.\n \n For more information, see https://tamagui.dev/docs/components/alert-dialog`);\n\t}, [contentRef]);\n\treturn null;\n};\nconst AlertDialogInner = (props) => {\n\tconst { scope, native, ...alertDialogProps } = props;\n\treturn /* @__PURE__ */ jsx(Dialog, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...alertDialogProps,\n\t\tmodal: true\n\t});\n};\nconst AlertDialog = withStaticProperties(AlertDialogInner, {\n\tTrigger: AlertDialogTrigger,\n\tPortal: AlertDialogPortal,\n\tOverlay: AlertDialogOverlay,\n\tContent: AlertDialogContent,\n\tAction: AlertDialogAction,\n\tCancel: AlertDialogCancel,\n\tDestructive: AlertDialogDestructive,\n\tTitle: AlertDialogTitle,\n\tDescription: AlertDialogDescription\n});\nAlertDialog.displayName = ROOT_NAME;\n\nexport { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogDestructive, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger };"],"mappings":";;;;;;;;;AAQA,MAAM,uBAAuB,UAAU;AACvC,MAAM,YAAY;AAClB,MAAM,oBAAoC,uBAAO,iBAAiB;AAClE,MAAM,uBAAuB,WAAW,SAAS;CAChD,OAAO,OAAO,UAAU,cAAc,GAAG,oBAAoB,KAAK,CAAC;AACpE;AACA,MAAM,gCAAgC,OAAO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AoB,UAAU;CACnC,MAAM,EAAE,OAAO,QAAQ,GAAG,qBAAqB;CAC/C,OAAuB,oBAAI,QAAQ;EAClC,OAAO,oBAAoB,KAAK;EAChC,GAAG;EACH,OAAO;CACR,CAAC;AACF;AACA,MAAM,cAAc,qBAAqB,kBAAkB;CAC1D,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,OAAO;CACP,aAAa;AACd,CAAC;AACD,YAAY,cAAc"}
1
+ {"version":3,"file":"AlertDialog.js","names":[],"sources":["jsx/AlertDialog.js"],"sourcesContent":["import { createStyledHOC } from \"@tamagui/core\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { Slottable, View, createStyledContext, styled } from \"@tamagui/core\";\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogContentFrame,\n DialogDescription,\n DialogOverlay,\n DialogOverlayFrame,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n DialogWarningProvider\n} from \"@tamagui/dialog\";\nimport { composeEventHandlers, withStaticProperties } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { markAlertDialogPart } from \"./alertDialogPart\";\nimport { useNativeAlertDialog } from \"./useNativeAlertDialog\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nconst getAlertDialogScope = (scope) => scope;\nconst ROOT_NAME = \"AlertDialog\";\nconst TRIGGER_NAME = \"AlertDialogTrigger\";\nconst NativeAlertDialogTriggerFrame = styled(View, {\n displayName: TRIGGER_NAME\n});\nmarkAlertDialogPart(NativeAlertDialogTriggerFrame, \"trigger\");\nconst AlertDialogTrigger = createStyledHOC(\n NativeAlertDialogTriggerFrame,\n function AlertDialogTrigger2(props, forwardedRef) {\n if (props[\"__native\"]) {\n const { __native, onPress, __onPress, ...rest } = props;\n return /* @__PURE__ */ jsx(\n NativeAlertDialogTriggerFrame,\n {\n ...rest,\n onPress: composeEventHandlers(onPress, __onPress)\n }\n );\n }\n const { scope, ...triggerProps } = props;\n return /* @__PURE__ */ jsx(\n DialogTrigger,\n {\n scope: getAlertDialogScope(scope),\n ...triggerProps,\n ref: forwardedRef\n }\n );\n }\n);\nconst AlertDialogPortal = function AlertDialogPortal2(props) {\n const { scope, ...portalProps } = props;\n return /* @__PURE__ */ jsx(DialogPortal, { scope: getAlertDialogScope(scope), ...portalProps });\n};\nconst OVERLAY_NAME = \"AlertDialogOverlay\";\nconst AlertDialogOverlayFrame = styled(DialogOverlayFrame, {\n displayName: OVERLAY_NAME\n});\nconst AlertDialogOverlay = createStyledHOC(\n AlertDialogOverlayFrame,\n function AlertDialogOverlay2(props, forwardedRef) {\n const { scope, ...overlayProps } = props;\n return /* @__PURE__ */ jsx(\n DialogOverlay,\n {\n scope: getAlertDialogScope(scope),\n ...overlayProps,\n ref: forwardedRef\n }\n );\n }\n);\nconst CONTENT_NAME = \"AlertDialogContent\";\nconst {\n Provider: AlertDialogContextProvider,\n useStyledContext: useAlertDialogContentContext\n} = createStyledContext({}, \"AlertDialogContext\");\nconst AlertDialogContentFrame = styled(DialogContentFrame, {\n displayName: CONTENT_NAME\n});\nconst AlertDialogContent = createStyledHOC(\n AlertDialogContentFrame,\n function AlertDialogContent2(props, forwardedRef) {\n const { scope, children, ...contentProps } = props;\n const dialogScope = getAlertDialogScope(scope);\n const contentRef = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const cancelRef = React.useRef(null);\n const destructiveRef = React.useRef(null);\n return /* @__PURE__ */ jsx(\n DialogWarningProvider,\n {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: \"alert-dialog\",\n children: /* @__PURE__ */ jsx(\n AlertDialogContextProvider,\n {\n scope,\n cancelRef,\n destructiveRef,\n children: /* @__PURE__ */ jsxs(\n DialogContent,\n {\n role: \"alertdialog\",\n \"aria-modal\": true,\n scope: dialogScope,\n ...contentProps,\n ref: composedRefs,\n onOpenAutoFocus: composeEventHandlers(\n contentProps.onOpenAutoFocus,\n (event) => {\n event.cancel();\n if (isWeb) {\n cancelRef.current?.focus({ preventScroll: true });\n }\n }\n ),\n onPointerDownOutside: (event) => event.cancel(),\n onInteractOutside: (event) => event.cancel(),\n children: [\n /* @__PURE__ */ jsx(Slottable, { children }),\n process.env.NODE_ENV === \"development\" && /* @__PURE__ */ jsx(DescriptionWarning, { contentRef })\n ]\n }\n )\n }\n )\n }\n );\n }\n);\nconst TITLE_NAME = \"AlertDialogTitle\";\nconst AlertDialogTitleFrame = styled(View, {\n displayName: TITLE_NAME\n});\nmarkAlertDialogPart(AlertDialogTitleFrame, \"title\");\nconst AlertDialogTitle = createStyledHOC(\n AlertDialogTitleFrame,\n function AlertDialogTitle2(props, forwardedRef) {\n const { scope, ...titleProps } = props;\n return /* @__PURE__ */ jsx(\n DialogTitle,\n {\n scope: getAlertDialogScope(scope),\n ...titleProps,\n ref: forwardedRef\n }\n );\n }\n);\nconst DESCRIPTION_NAME = \"AlertDialogDescription\";\nconst AlertDialogDescriptionFrame = styled(View, {\n displayName: DESCRIPTION_NAME\n});\nmarkAlertDialogPart(AlertDialogDescriptionFrame, \"description\");\nconst AlertDialogDescription = createStyledHOC(\n AlertDialogDescriptionFrame,\n function AlertDialogDescription2(props, forwardedRef) {\n const { scope, ...descriptionProps } = props;\n return /* @__PURE__ */ jsx(\n DialogDescription,\n {\n scope: getAlertDialogScope(scope),\n ...descriptionProps,\n ref: forwardedRef\n }\n );\n }\n);\nconst ACTION_NAME = \"AlertDialogAction\";\nconst AlertDialogActionFrame = styled(View, {\n displayName: ACTION_NAME\n});\nmarkAlertDialogPart(AlertDialogActionFrame, \"action\");\nconst AlertDialogAction = createStyledHOC(\n AlertDialogActionFrame,\n function AlertDialogAction2(props, forwardedRef) {\n const { scope, ...actionProps } = props;\n return /* @__PURE__ */ jsx(\n DialogClose,\n {\n scope: getAlertDialogScope(scope),\n ...actionProps,\n ref: forwardedRef\n }\n );\n }\n);\nconst CANCEL_NAME = \"AlertDialogCancel\";\nconst AlertDialogCancelFrame = styled(View, {\n displayName: CANCEL_NAME\n});\nmarkAlertDialogPart(AlertDialogCancelFrame, \"cancel\");\nconst AlertDialogCancel = createStyledHOC(\n AlertDialogCancelFrame,\n function AlertDialogCancel2(props, forwardedRef) {\n const { scope, ...cancelProps } = props;\n const { cancelRef } = useAlertDialogContentContext(scope);\n const ref = useComposedRefs(forwardedRef, cancelRef);\n return /* @__PURE__ */ jsx(DialogClose, { scope: getAlertDialogScope(scope), ...cancelProps, ref });\n }\n);\nconst DESTRUCTIVE_NAME = \"AlertDialogDestructive\";\nconst AlertDialogDestructiveFrame = styled(View, {\n displayName: DESTRUCTIVE_NAME\n});\nmarkAlertDialogPart(AlertDialogDestructiveFrame, \"destructive\");\nconst AlertDialogDestructive = createStyledHOC(\n AlertDialogDestructiveFrame,\n function AlertDialogDestructive2(props, forwardedRef) {\n const { scope, ...destructiveProps } = props;\n const { destructiveRef } = useAlertDialogContentContext(scope);\n const ref = useComposedRefs(forwardedRef, destructiveRef);\n return /* @__PURE__ */ jsx(DialogClose, { scope: getAlertDialogScope(scope), ...destructiveProps, ref });\n }\n);\nconst DescriptionWarning = ({ contentRef }) => {\n if (process.env.NODE_ENV === \"development\") {\n React.useEffect(() => {\n if (!isWeb) return;\n const hasDescription = document.getElementById(\n // @ts-ignore\n contentRef.current?.getAttribute(\"aria-describedby\")\n );\n if (!hasDescription) {\n console.warn(`\\`${CONTENT_NAME}\\` requires a description for the component to be accessible for screen reader users.\n \n 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.\n \n 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.\n \n For more information, see https://tamagui.dev/docs/components/alert-dialog`);\n }\n }, [contentRef]);\n }\n return null;\n};\nconst AlertDialogInner = (props) => {\n const { scope, native, ...alertDialogProps } = props;\n const dialogScope = getAlertDialogScope(scope);\n const nativeAlert = useNativeAlertDialog(props);\n if (nativeAlert) return nativeAlert;\n return /* @__PURE__ */ jsx(Dialog, { scope: dialogScope, ...alertDialogProps, modal: true });\n};\nconst AlertDialog = withStaticProperties(AlertDialogInner, {\n Trigger: AlertDialogTrigger,\n Portal: AlertDialogPortal,\n Overlay: AlertDialogOverlay,\n Content: AlertDialogContent,\n Action: AlertDialogAction,\n Cancel: AlertDialogCancel,\n Destructive: AlertDialogDestructive,\n Title: AlertDialogTitle,\n Description: AlertDialogDescription\n});\nAlertDialog.displayName = ROOT_NAME;\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogDestructive,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger\n};\n//# sourceMappingURL=AlertDialog.js.map\n"],"mappings":";;;;;;;;;;;AAsBA,MAAM,uBAAuB,UAAU;AACvC,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,gCAAgC,OAAO,MAAM,EACjD,aAAa,aACf,CAAC;AACD,oBAAoB,+BAA+B,SAAS;AAC5D,MAAM,qBAAqB,gBACzB,+BACA,SAAS,oBAAoB,OAAO,cAAc;CAChD,IAAI,MAAM,aAAa;EACrB,MAAM,EAAE,UAAU,SAAS,WAAW,GAAG,SAAS;EAClD,OAAuB,oBACrB,+BACA;GACE,GAAG;GACH,SAAS,qBAAqB,SAAS,SAAS;EAClD,CACF;CACF;CACA,MAAM,EAAE,OAAO,GAAG,iBAAiB;CACnC,OAAuB,oBACrB,eACA;EACE,OAAO,oBAAoB,KAAK;EAChC,GAAG;EACH,KAAK;CACP,CACF;AACF,CACF;AACA,MAAM,oBAAoB,SAAS,mBAAmB,OAAO;CAC3D,MAAM,EAAE,OAAO,GAAG,gBAAgB;CAClC,OAAuB,oB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C;AACD,YAAY,cAAc"}
@@ -47,19 +47,16 @@ var import_constants = require("@tamagui/constants");
47
47
  var import_core2 = require("@tamagui/core");
48
48
  var import_dialog = require("@tamagui/dialog");
49
49
  var import_helpers = require("@tamagui/helpers");
50
- var import_use_controllable_state = require("@tamagui/use-controllable-state");
51
50
  var React = __toESM(require("react"), 1);
52
- var import_react_native = require("react-native");
51
+ var import_alertDialogPart = require("./alertDialogPart.native.js");
52
+ var import_useNativeAlertDialog = require("./useNativeAlertDialog.native.js");
53
53
  var getAlertDialogScope = function(scope) {
54
54
  return scope;
55
55
  };
56
56
  var ROOT_NAME = "AlertDialog";
57
- var ALERT_DIALOG_PART = /* @__PURE__ */ Symbol("AlertDialogPart");
58
- var markAlertDialogPart = function(component, part) {
59
- Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });
60
- };
61
- var NativeAlertDialogTriggerFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogTrigger" });
62
- markAlertDialogPart(NativeAlertDialogTriggerFrame, "trigger");
57
+ var TRIGGER_NAME = "AlertDialogTrigger";
58
+ var NativeAlertDialogTriggerFrame = (0, import_core2.styled)(import_core2.View, { displayName: TRIGGER_NAME });
59
+ (0, import_alertDialogPart.markAlertDialogPart)(NativeAlertDialogTriggerFrame, "trigger");
63
60
  var AlertDialogTrigger = (0, import_core.createStyledHOC)(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {
64
61
  if (props["__native"]) {
65
62
  var { __native, onPress, __onPress, ...rest } = props;
@@ -82,7 +79,8 @@ var AlertDialogPortal = function AlertDialogPortal2(props) {
82
79
  ...portalProps
83
80
  });
84
81
  };
85
- var AlertDialogOverlayFrame = (0, import_core2.styled)(import_dialog.DialogOverlayFrame, { displayName: "AlertDialogOverlay" });
82
+ var OVERLAY_NAME = "AlertDialogOverlay";
83
+ var AlertDialogOverlayFrame = (0, import_core2.styled)(import_dialog.DialogOverlayFrame, { displayName: OVERLAY_NAME });
86
84
  var AlertDialogOverlay = (0, import_core.createStyledHOC)(AlertDialogOverlayFrame, function AlertDialogOverlay2(props, forwardedRef) {
87
85
  var { scope, ...overlayProps } = props;
88
86
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogOverlay, {
@@ -93,7 +91,8 @@ var AlertDialogOverlay = (0, import_core.createStyledHOC)(AlertDialogOverlayFram
93
91
  });
94
92
  var CONTENT_NAME = "AlertDialogContent";
95
93
  var { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = (0, import_core2.createStyledContext)({}, "AlertDialogContext");
96
- var AlertDialogContent = (0, import_core.createRefComponent)(function AlertDialogContent2(props, forwardedRef) {
94
+ var AlertDialogContentFrame = (0, import_core2.styled)(import_dialog.DialogContentFrame, { displayName: CONTENT_NAME });
95
+ var AlertDialogContent = (0, import_core.createStyledHOC)(AlertDialogContentFrame, function AlertDialogContent2(props, forwardedRef) {
97
96
  var { scope, children, ...contentProps } = props;
98
97
  var dialogScope = getAlertDialogScope(scope);
99
98
  var contentRef = React.useRef(null);
@@ -118,7 +117,7 @@ var AlertDialogContent = (0, import_core.createRefComponent)(function AlertDialo
118
117
  event.cancel();
119
118
  if (import_constants.isWeb) {
120
119
  var _cancelRef_current;
121
- (_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 || _cancelRef_current.focus({ preventScroll: true });
120
+ (_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 ? void 0 : _cancelRef_current.focus({ preventScroll: true });
122
121
  }
123
122
  }),
124
123
  onPointerDownOutside: function(event) {
@@ -134,7 +133,7 @@ var AlertDialogContent = (0, import_core.createRefComponent)(function AlertDialo
134
133
  });
135
134
  var TITLE_NAME = "AlertDialogTitle";
136
135
  var AlertDialogTitleFrame = (0, import_core2.styled)(import_core2.View, { displayName: TITLE_NAME });
137
- markAlertDialogPart(AlertDialogTitleFrame, "title");
136
+ (0, import_alertDialogPart.markAlertDialogPart)(AlertDialogTitleFrame, "title");
138
137
  var AlertDialogTitle = (0, import_core.createStyledHOC)(AlertDialogTitleFrame, function AlertDialogTitle2(props, forwardedRef) {
139
138
  var { scope, ...titleProps } = props;
140
139
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, {
@@ -145,7 +144,7 @@ var AlertDialogTitle = (0, import_core.createStyledHOC)(AlertDialogTitleFrame, f
145
144
  });
146
145
  var DESCRIPTION_NAME = "AlertDialogDescription";
147
146
  var AlertDialogDescriptionFrame = (0, import_core2.styled)(import_core2.View, { displayName: DESCRIPTION_NAME });
148
- markAlertDialogPart(AlertDialogDescriptionFrame, "description");
147
+ (0, import_alertDialogPart.markAlertDialogPart)(AlertDialogDescriptionFrame, "description");
149
148
  var AlertDialogDescription = (0, import_core.createStyledHOC)(AlertDialogDescriptionFrame, function AlertDialogDescription2(props, forwardedRef) {
150
149
  var { scope, ...descriptionProps } = props;
151
150
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogDescription, {
@@ -154,8 +153,9 @@ var AlertDialogDescription = (0, import_core.createStyledHOC)(AlertDialogDescrip
154
153
  ref: forwardedRef
155
154
  });
156
155
  });
157
- var AlertDialogActionFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogAction" });
158
- markAlertDialogPart(AlertDialogActionFrame, "action");
156
+ var ACTION_NAME = "AlertDialogAction";
157
+ var AlertDialogActionFrame = (0, import_core2.styled)(import_core2.View, { displayName: ACTION_NAME });
158
+ (0, import_alertDialogPart.markAlertDialogPart)(AlertDialogActionFrame, "action");
159
159
  var AlertDialogAction = (0, import_core.createStyledHOC)(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {
160
160
  var { scope, ...actionProps } = props;
161
161
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, {
@@ -164,8 +164,9 @@ var AlertDialogAction = (0, import_core.createStyledHOC)(AlertDialogActionFrame,
164
164
  ref: forwardedRef
165
165
  });
166
166
  });
167
- var AlertDialogCancelFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogCancel" });
168
- markAlertDialogPart(AlertDialogCancelFrame, "cancel");
167
+ var CANCEL_NAME = "AlertDialogCancel";
168
+ var AlertDialogCancelFrame = (0, import_core2.styled)(import_core2.View, { displayName: CANCEL_NAME });
169
+ (0, import_alertDialogPart.markAlertDialogPart)(AlertDialogCancelFrame, "cancel");
169
170
  var AlertDialogCancel = (0, import_core.createStyledHOC)(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {
170
171
  var { scope, ...cancelProps } = props;
171
172
  var { cancelRef } = useAlertDialogContentContext(scope);
@@ -176,8 +177,9 @@ var AlertDialogCancel = (0, import_core.createStyledHOC)(AlertDialogCancelFrame,
176
177
  ref
177
178
  });
178
179
  });
179
- var AlertDialogDestructiveFrame = (0, import_core2.styled)(import_core2.View, { displayName: "AlertDialogDestructive" });
180
- markAlertDialogPart(AlertDialogDestructiveFrame, "destructive");
180
+ var DESTRUCTIVE_NAME = "AlertDialogDestructive";
181
+ var AlertDialogDestructiveFrame = (0, import_core2.styled)(import_core2.View, { displayName: DESTRUCTIVE_NAME });
182
+ (0, import_alertDialogPart.markAlertDialogPart)(AlertDialogDestructiveFrame, "destructive");
181
183
  var AlertDialogDestructive = (0, import_core.createStyledHOC)(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {
182
184
  var { scope, ...destructiveProps } = props;
183
185
  var { destructiveRef } = useAlertDialogContentContext(scope);
@@ -190,110 +192,35 @@ var AlertDialogDestructive = (0, import_core.createStyledHOC)(AlertDialogDestruc
190
192
  });
191
193
  var DescriptionWarning = function(param) {
192
194
  var { contentRef } = param;
193
- if (process.env.NODE_ENV === "development") React.useEffect(function() {
194
- var _contentRef_current;
195
- if (!import_constants.isWeb) return;
196
- 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.
195
+ if (process.env.NODE_ENV === "development") {
196
+ React.useEffect(function() {
197
+ var _contentRef_current;
198
+ if (!import_constants.isWeb) return;
199
+ var hasDescription = document.getElementById((_contentRef_current = contentRef.current) === null || _contentRef_current === void 0 ? void 0 : _contentRef_current.getAttribute("aria-describedby"));
200
+ if (!hasDescription) {
201
+ console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
197
202
 
198
203
  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.
199
204
 
200
205
  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.
201
206
 
202
207
  For more information, see https://tamagui.dev/docs/components/alert-dialog`);
203
- }, [contentRef]);
208
+ }
209
+ }, [contentRef]);
210
+ }
204
211
  return null;
205
212
  };
206
213
  var AlertDialogInner = function(props) {
207
214
  var { scope, native, ...alertDialogProps } = props;
208
215
  var dialogScope = getAlertDialogScope(scope);
209
- var [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
210
- prop: props.open,
211
- defaultProp: props.defaultOpen || false,
212
- onChange: props.onOpenChange,
213
- transition: true
214
- });
215
- var triggerElement = null;
216
- var title = "";
217
- var description = "";
218
- var buttons = [];
219
- forEachChildDeep(React.Children.toArray(props.children), function(child) {
220
- if (!/* @__PURE__ */ React.isValidElement(child)) return false;
221
- var part = (0, import_core2.isTamaguiElement)(child) ? child.type.staticConfig[ALERT_DIALOG_PART] : void 0;
222
- switch (part) {
223
- case "trigger":
224
- triggerElement = /* @__PURE__ */ React.cloneElement(child, { __native: true });
225
- return false;
226
- case "title":
227
- title = getStringChildren(child);
228
- return false;
229
- case "description":
230
- description = getStringChildren(child);
231
- return false;
232
- case "action":
233
- case "destructive":
234
- case "cancel":
235
- var style = part === "action" ? "default" : part === "destructive" ? "destructive" : "cancel";
236
- var text = getStringChildren(child);
237
- var onPress = function() {
238
- var _childProps_onPress;
239
- var childProps = child.props;
240
- childProps === null || childProps === void 0 || (_childProps_onPress = childProps.onPress) == null || _childProps_onPress.call(childProps, { native: true });
241
- setOpen(false);
242
- };
243
- buttons.push({
244
- style,
245
- text,
246
- onPress
247
- });
248
- return false;
249
- default: return true;
250
- }
251
- });
252
- (0, import_constants.useIsomorphicLayoutEffect)(function() {
253
- if (!open || !native) return;
254
- if (title || description) import_react_native.Alert.alert(title, description, buttons);
255
- }, [native, open]);
256
- if (native) return /* @__PURE__ */ React.cloneElement(triggerElement, { __onPress: function() {
257
- setOpen(true);
258
- } });
216
+ var nativeAlert = (0, import_useNativeAlertDialog.useNativeAlertDialog)(props);
217
+ if (nativeAlert) return nativeAlert;
259
218
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog, {
260
219
  scope: dialogScope,
261
220
  ...alertDialogProps,
262
221
  modal: true
263
222
  });
264
223
  };
265
- function forEachChildDeep(children, onChild) {
266
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
267
- try {
268
- for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
269
- var child = _step.value;
270
- if (!/* @__PURE__ */ React.isValidElement(child)) continue;
271
- if (!onChild(child)) continue;
272
- var childProps = child.props;
273
- if (childProps.children) forEachChildDeep(React.Children.toArray(childProps.children), onChild);
274
- }
275
- } catch (err) {
276
- _didIteratorError = true;
277
- _iteratorError = err;
278
- } finally {
279
- try {
280
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
281
- } finally {
282
- if (_didIteratorError) throw _iteratorError;
283
- }
284
- }
285
- }
286
- function getStringChildren(child) {
287
- var string = "";
288
- forEachChildDeep(React.Children.toArray(child), function(child2) {
289
- if (typeof child2.props.children === "string") {
290
- string = child2.props.children;
291
- return false;
292
- }
293
- return true;
294
- });
295
- return string;
296
- }
297
224
  var AlertDialog = (0, import_helpers.withStaticProperties)(AlertDialogInner, {
298
225
  Trigger: AlertDialogTrigger,
299
226
  Portal: AlertDialogPortal,