@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.
- package/dist/cjs/AlertDialog.cjs +34 -31
- package/dist/cjs/AlertDialog.native.cjs +33 -106
- package/dist/cjs/AlertDialog.native.js +33 -106
- package/dist/cjs/AlertDialog.native.js.map +1 -1
- package/dist/cjs/alertDialogPart.cjs +30 -0
- package/dist/cjs/alertDialogPart.native.cjs +32 -0
- package/dist/cjs/alertDialogPart.native.js +34 -0
- package/dist/cjs/alertDialogPart.native.js.map +1 -0
- package/dist/cjs/useNativeAlertDialog.cjs +24 -0
- package/dist/cjs/useNativeAlertDialog.native.cjs +139 -0
- package/dist/cjs/useNativeAlertDialog.native.js +141 -0
- package/dist/cjs/useNativeAlertDialog.native.js.map +1 -0
- package/dist/esm/AlertDialog.mjs +35 -19
- package/dist/esm/AlertDialog.mjs.map +1 -1
- package/dist/esm/AlertDialog.native.js +33 -104
- package/dist/esm/AlertDialog.native.js.map +1 -1
- package/dist/esm/alertDialogPart.mjs +7 -0
- package/dist/esm/alertDialogPart.mjs.map +1 -0
- package/dist/esm/alertDialogPart.native.js +7 -0
- package/dist/esm/alertDialogPart.native.js.map +1 -0
- package/dist/esm/useNativeAlertDialog.mjs +4 -0
- package/dist/esm/useNativeAlertDialog.mjs.map +1 -0
- package/dist/esm/useNativeAlertDialog.native.js +112 -0
- package/dist/esm/useNativeAlertDialog.native.js.map +1 -0
- package/dist/jsx/AlertDialog.mjs +35 -19
- package/dist/jsx/AlertDialog.mjs.map +1 -1
- package/dist/jsx/AlertDialog.native.cjs +33 -106
- package/dist/jsx/AlertDialog.native.js +33 -106
- package/dist/jsx/AlertDialog.native.js.map +1 -1
- package/dist/jsx/alertDialogPart.mjs +7 -0
- package/dist/jsx/alertDialogPart.mjs.map +1 -0
- package/dist/jsx/alertDialogPart.native.cjs +32 -0
- package/dist/jsx/alertDialogPart.native.js +34 -0
- package/dist/jsx/alertDialogPart.native.js.map +1 -0
- package/dist/jsx/useNativeAlertDialog.mjs +4 -0
- package/dist/jsx/useNativeAlertDialog.mjs.map +1 -0
- package/dist/jsx/useNativeAlertDialog.native.cjs +139 -0
- package/dist/jsx/useNativeAlertDialog.native.js +141 -0
- package/dist/jsx/useNativeAlertDialog.native.js.map +1 -0
- package/package.json +21 -19
- package/src/AlertDialog.tsx +19 -141
- package/src/alertDialogPart.ts +26 -0
- package/src/useNativeAlertDialog.native.tsx +129 -0
- package/src/useNativeAlertDialog.ts +11 -0
- package/types/AlertDialog.d.ts +41 -83
- package/types/AlertDialog.d.ts.map +1 -1
- package/types/alertDialogPart.d.ts +15 -0
- package/types/alertDialogPart.d.ts.map +1 -0
- package/types/useNativeAlertDialog.d.ts +11 -0
- package/types/useNativeAlertDialog.d.ts.map +1 -0
- package/types/useNativeAlertDialog.native.d.ts +11 -0
- package/types/useNativeAlertDialog.native.d.ts.map +1 -0
package/dist/esm/AlertDialog.mjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { Slottable, View,
|
|
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
|
|
12
|
-
const
|
|
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
|
|
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
|
|
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
|
|
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)
|
|
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
|
|
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
|
|
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
|
|
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")
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
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:
|
|
168
|
+
scope: dialogScope,
|
|
153
169
|
...alertDialogProps,
|
|
154
170
|
modal: true
|
|
155
171
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.js","names":[],"sources":["esm/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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,KAAK,KAAK,aAAa;;6CAExE,aAAa,oBAAoB,iBAAiB;;oKAEqE,aAAa;;mFAE9F;CAClF,GAAG,CAAC,UAAU,CAAC;CACf,OAAO;AACR;AACA,MAAM,oBAAoB,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":["esm/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,K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A,MAAM,cAAc,qBAAqB,kBAAkB;CACzD,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,OAAO;CACP,aAAa;AACf,CAAC;AACD,YAAY,cAAc"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Slottable, View,
|
|
2
|
+
import { Slottable, View, createStyledContext, createStyledHOC, styled } from "@tamagui/core";
|
|
3
3
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
4
|
-
import { isWeb
|
|
5
|
-
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from "@tamagui/dialog";
|
|
4
|
+
import { isWeb } from "@tamagui/constants";
|
|
5
|
+
import { Dialog, DialogClose, DialogContent, DialogContentFrame, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from "@tamagui/dialog";
|
|
6
6
|
import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
|
|
7
|
-
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
8
7
|
import * as React from "react";
|
|
9
|
-
import {
|
|
8
|
+
import { markAlertDialogPart } from "./alertDialogPart.native.js";
|
|
9
|
+
import { useNativeAlertDialog } from "./useNativeAlertDialog.native.js";
|
|
10
10
|
|
|
11
11
|
var getAlertDialogScope = function(scope) {
|
|
12
12
|
return scope;
|
|
13
13
|
};
|
|
14
14
|
var ROOT_NAME = "AlertDialog";
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });
|
|
18
|
-
};
|
|
19
|
-
var NativeAlertDialogTriggerFrame = styled(View, { displayName: "AlertDialogTrigger" });
|
|
15
|
+
var TRIGGER_NAME = "AlertDialogTrigger";
|
|
16
|
+
var NativeAlertDialogTriggerFrame = styled(View, { displayName: TRIGGER_NAME });
|
|
20
17
|
markAlertDialogPart(NativeAlertDialogTriggerFrame, "trigger");
|
|
21
18
|
var AlertDialogTrigger = createStyledHOC(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {
|
|
22
19
|
if (props["__native"]) {
|
|
@@ -40,7 +37,9 @@ var AlertDialogPortal = function AlertDialogPortal2(props) {
|
|
|
40
37
|
...portalProps
|
|
41
38
|
});
|
|
42
39
|
};
|
|
43
|
-
var
|
|
40
|
+
var OVERLAY_NAME = "AlertDialogOverlay";
|
|
41
|
+
var AlertDialogOverlayFrame = styled(DialogOverlayFrame, { displayName: OVERLAY_NAME });
|
|
42
|
+
var AlertDialogOverlay = createStyledHOC(AlertDialogOverlayFrame, function AlertDialogOverlay2(props, forwardedRef) {
|
|
44
43
|
var { scope, ...overlayProps } = props;
|
|
45
44
|
return /* @__PURE__ */ jsx(DialogOverlay, {
|
|
46
45
|
scope: getAlertDialogScope(scope),
|
|
@@ -50,12 +49,14 @@ var AlertDialogOverlay = createStyledHOC(styled(DialogOverlayFrame, { displayNam
|
|
|
50
49
|
});
|
|
51
50
|
var CONTENT_NAME = "AlertDialogContent";
|
|
52
51
|
var { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = createStyledContext({}, "AlertDialogContext");
|
|
53
|
-
var
|
|
52
|
+
var AlertDialogContentFrame = styled(DialogContentFrame, { displayName: CONTENT_NAME });
|
|
53
|
+
var AlertDialogContent = createStyledHOC(AlertDialogContentFrame, function AlertDialogContent2(props, forwardedRef) {
|
|
54
54
|
var { scope, children, ...contentProps } = props;
|
|
55
55
|
var dialogScope = getAlertDialogScope(scope);
|
|
56
56
|
var contentRef = React.useRef(null);
|
|
57
57
|
var composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
58
58
|
var cancelRef = React.useRef(null);
|
|
59
|
+
var destructiveRef = React.useRef(null);
|
|
59
60
|
return /* @__PURE__ */ jsx(DialogWarningProvider, {
|
|
60
61
|
contentName: CONTENT_NAME,
|
|
61
62
|
titleName: TITLE_NAME,
|
|
@@ -63,7 +64,7 @@ var AlertDialogContent = createRefComponent(function AlertDialogContent2(props,
|
|
|
63
64
|
children: /* @__PURE__ */ jsx(AlertDialogContextProvider, {
|
|
64
65
|
scope,
|
|
65
66
|
cancelRef,
|
|
66
|
-
destructiveRef
|
|
67
|
+
destructiveRef,
|
|
67
68
|
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
68
69
|
role: "alertdialog",
|
|
69
70
|
"aria-modal": true,
|
|
@@ -74,7 +75,7 @@ var AlertDialogContent = createRefComponent(function AlertDialogContent2(props,
|
|
|
74
75
|
event.cancel();
|
|
75
76
|
if (isWeb) {
|
|
76
77
|
var _cancelRef_current;
|
|
77
|
-
(_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0
|
|
78
|
+
(_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 ? void 0 : _cancelRef_current.focus({ preventScroll: true });
|
|
78
79
|
}
|
|
79
80
|
}),
|
|
80
81
|
onPointerDownOutside: function(event) {
|
|
@@ -110,7 +111,8 @@ var AlertDialogDescription = createStyledHOC(AlertDialogDescriptionFrame, functi
|
|
|
110
111
|
ref: forwardedRef
|
|
111
112
|
});
|
|
112
113
|
});
|
|
113
|
-
var
|
|
114
|
+
var ACTION_NAME = "AlertDialogAction";
|
|
115
|
+
var AlertDialogActionFrame = styled(View, { displayName: ACTION_NAME });
|
|
114
116
|
markAlertDialogPart(AlertDialogActionFrame, "action");
|
|
115
117
|
var AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {
|
|
116
118
|
var { scope, ...actionProps } = props;
|
|
@@ -120,7 +122,8 @@ var AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function AlertDi
|
|
|
120
122
|
ref: forwardedRef
|
|
121
123
|
});
|
|
122
124
|
});
|
|
123
|
-
var
|
|
125
|
+
var CANCEL_NAME = "AlertDialogCancel";
|
|
126
|
+
var AlertDialogCancelFrame = styled(View, { displayName: CANCEL_NAME });
|
|
124
127
|
markAlertDialogPart(AlertDialogCancelFrame, "cancel");
|
|
125
128
|
var AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {
|
|
126
129
|
var { scope, ...cancelProps } = props;
|
|
@@ -132,7 +135,8 @@ var AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function AlertDi
|
|
|
132
135
|
ref
|
|
133
136
|
});
|
|
134
137
|
});
|
|
135
|
-
var
|
|
138
|
+
var DESTRUCTIVE_NAME = "AlertDialogDestructive";
|
|
139
|
+
var AlertDialogDestructiveFrame = styled(View, { displayName: DESTRUCTIVE_NAME });
|
|
136
140
|
markAlertDialogPart(AlertDialogDestructiveFrame, "destructive");
|
|
137
141
|
var AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {
|
|
138
142
|
var { scope, ...destructiveProps } = props;
|
|
@@ -146,110 +150,35 @@ var AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, functi
|
|
|
146
150
|
});
|
|
147
151
|
var DescriptionWarning = function(param) {
|
|
148
152
|
var { contentRef } = param;
|
|
149
|
-
if (process.env.NODE_ENV === "development")
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
if (process.env.NODE_ENV === "development") {
|
|
154
|
+
React.useEffect(function() {
|
|
155
|
+
var _contentRef_current;
|
|
156
|
+
if (!isWeb) return;
|
|
157
|
+
var hasDescription = document.getElementById((_contentRef_current = contentRef.current) === null || _contentRef_current === void 0 ? void 0 : _contentRef_current.getAttribute("aria-describedby"));
|
|
158
|
+
if (!hasDescription) {
|
|
159
|
+
console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
153
160
|
|
|
154
161
|
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.
|
|
155
162
|
|
|
156
163
|
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.
|
|
157
164
|
|
|
158
165
|
For more information, see https://tamagui.dev/docs/components/alert-dialog`);
|
|
159
|
-
|
|
166
|
+
}
|
|
167
|
+
}, [contentRef]);
|
|
168
|
+
}
|
|
160
169
|
return null;
|
|
161
170
|
};
|
|
162
171
|
var AlertDialogInner = function(props) {
|
|
163
172
|
var { scope, native, ...alertDialogProps } = props;
|
|
164
173
|
var dialogScope = getAlertDialogScope(scope);
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
defaultProp: props.defaultOpen || false,
|
|
168
|
-
onChange: props.onOpenChange,
|
|
169
|
-
transition: true
|
|
170
|
-
});
|
|
171
|
-
var triggerElement = null;
|
|
172
|
-
var title = "";
|
|
173
|
-
var description = "";
|
|
174
|
-
var buttons = [];
|
|
175
|
-
forEachChildDeep(React.Children.toArray(props.children), function(child) {
|
|
176
|
-
if (!/* @__PURE__ */ React.isValidElement(child)) return false;
|
|
177
|
-
var part = isTamaguiElement(child) ? child.type.staticConfig[ALERT_DIALOG_PART] : void 0;
|
|
178
|
-
switch (part) {
|
|
179
|
-
case "trigger":
|
|
180
|
-
triggerElement = /* @__PURE__ */ React.cloneElement(child, { __native: true });
|
|
181
|
-
return false;
|
|
182
|
-
case "title":
|
|
183
|
-
title = getStringChildren(child);
|
|
184
|
-
return false;
|
|
185
|
-
case "description":
|
|
186
|
-
description = getStringChildren(child);
|
|
187
|
-
return false;
|
|
188
|
-
case "action":
|
|
189
|
-
case "destructive":
|
|
190
|
-
case "cancel":
|
|
191
|
-
var style = part === "action" ? "default" : part === "destructive" ? "destructive" : "cancel";
|
|
192
|
-
var text = getStringChildren(child);
|
|
193
|
-
var onPress = function() {
|
|
194
|
-
var _childProps_onPress;
|
|
195
|
-
var childProps = child.props;
|
|
196
|
-
childProps === null || childProps === void 0 || (_childProps_onPress = childProps.onPress) == null || _childProps_onPress.call(childProps, { native: true });
|
|
197
|
-
setOpen(false);
|
|
198
|
-
};
|
|
199
|
-
buttons.push({
|
|
200
|
-
style,
|
|
201
|
-
text,
|
|
202
|
-
onPress
|
|
203
|
-
});
|
|
204
|
-
return false;
|
|
205
|
-
default: return true;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
useIsomorphicLayoutEffect(function() {
|
|
209
|
-
if (!open || !native) return;
|
|
210
|
-
if (title || description) Alert.alert(title, description, buttons);
|
|
211
|
-
}, [native, open]);
|
|
212
|
-
if (native) return /* @__PURE__ */ React.cloneElement(triggerElement, { __onPress: function() {
|
|
213
|
-
setOpen(true);
|
|
214
|
-
} });
|
|
174
|
+
var nativeAlert = useNativeAlertDialog(props);
|
|
175
|
+
if (nativeAlert) return nativeAlert;
|
|
215
176
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
216
177
|
scope: dialogScope,
|
|
217
178
|
...alertDialogProps,
|
|
218
179
|
modal: true
|
|
219
180
|
});
|
|
220
181
|
};
|
|
221
|
-
function forEachChildDeep(children, onChild) {
|
|
222
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
223
|
-
try {
|
|
224
|
-
for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
225
|
-
var child = _step.value;
|
|
226
|
-
if (!/* @__PURE__ */ React.isValidElement(child)) continue;
|
|
227
|
-
if (!onChild(child)) continue;
|
|
228
|
-
var childProps = child.props;
|
|
229
|
-
if (childProps.children) forEachChildDeep(React.Children.toArray(childProps.children), onChild);
|
|
230
|
-
}
|
|
231
|
-
} catch (err) {
|
|
232
|
-
_didIteratorError = true;
|
|
233
|
-
_iteratorError = err;
|
|
234
|
-
} finally {
|
|
235
|
-
try {
|
|
236
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
237
|
-
} finally {
|
|
238
|
-
if (_didIteratorError) throw _iteratorError;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
function getStringChildren(child) {
|
|
243
|
-
var string = "";
|
|
244
|
-
forEachChildDeep(React.Children.toArray(child), function(child2) {
|
|
245
|
-
if (typeof child2.props.children === "string") {
|
|
246
|
-
string = child2.props.children;
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
return true;
|
|
250
|
-
});
|
|
251
|
-
return string;
|
|
252
|
-
}
|
|
253
182
|
var AlertDialog = withStaticProperties(AlertDialogInner, {
|
|
254
183
|
Trigger: AlertDialogTrigger,
|
|
255
184
|
Portal: AlertDialogPortal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.native.js","names":[],"sources":["esm/AlertDialog.native.js"],"sourcesContent":["import { jsx, jsxs } from \"react/jsx-runtime\";\nimport { Slottable, View, createRefComponent, createStyledContext, createStyledHOC, isTamaguiElement, styled } from \"@tamagui/core\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from \"@tamagui/dialog\";\nimport { composeEventHandlers, withStaticProperties } from \"@tamagui/helpers\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport * as React from \"react\";\nimport { Alert } from \"react-native\";\n\nvar getAlertDialogScope = function(scope) {\n\treturn scope;\n};\nvar ROOT_NAME = \"AlertDialog\";\nvar ALERT_DIALOG_PART = /* @__PURE__ */ Symbol(\"AlertDialogPart\");\nvar markAlertDialogPart = function(component, part) {\n\tObject.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });\n};\nvar NativeAlertDialogTriggerFrame = styled(View, { displayName: \"AlertDialogTrigger\" });\nmarkAlertDialogPart(NativeAlertDialogTriggerFrame, \"trigger\");\nvar AlertDialogTrigger = createStyledHOC(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {\n\tif (props[\"__native\"]) {\n\t\tvar { __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\tvar { scope, ...triggerProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogTrigger, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...triggerProps,\n\t\tref: forwardedRef\n\t});\n});\nvar AlertDialogPortal = function AlertDialogPortal2(props) {\n\tvar { scope, ...portalProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogPortal, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...portalProps\n\t});\n};\nvar AlertDialogOverlay = createStyledHOC(styled(DialogOverlayFrame, { displayName: \"AlertDialogOverlay\" }), function AlertDialogOverlay2(props, forwardedRef) {\n\tvar { scope, ...overlayProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogOverlay, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...overlayProps,\n\t\tref: forwardedRef\n\t});\n});\nvar CONTENT_NAME = \"AlertDialogContent\";\nvar { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = createStyledContext({}, \"AlertDialogContext\");\nvar AlertDialogContent = createRefComponent(function AlertDialogContent2(props, forwardedRef) {\n\tvar { scope, children, ...contentProps } = props;\n\tvar dialogScope = getAlertDialogScope(scope);\n\tvar contentRef = React.useRef(null);\n\tvar composedRefs = useComposedRefs(forwardedRef, contentRef);\n\tvar 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, function(event) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t\tif (isWeb) {\n\t\t\t\t\t\tvar _cancelRef_current;\n\t\t\t\t\t\t(_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 || _cancelRef_current.focus({ preventScroll: true });\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tonPointerDownOutside: function(event) {\n\t\t\t\t\treturn event.cancel();\n\t\t\t\t},\n\t\t\t\tonInteractOutside: function(event) {\n\t\t\t\t\treturn event.cancel();\n\t\t\t\t},\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});\nvar TITLE_NAME = \"AlertDialogTitle\";\nvar AlertDialogTitleFrame = styled(View, { displayName: TITLE_NAME });\nmarkAlertDialogPart(AlertDialogTitleFrame, \"title\");\nvar AlertDialogTitle = createStyledHOC(AlertDialogTitleFrame, function AlertDialogTitle2(props, forwardedRef) {\n\tvar { scope, ...titleProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogTitle, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...titleProps,\n\t\tref: forwardedRef\n\t});\n});\nvar DESCRIPTION_NAME = \"AlertDialogDescription\";\nvar AlertDialogDescriptionFrame = styled(View, { displayName: DESCRIPTION_NAME });\nmarkAlertDialogPart(AlertDialogDescriptionFrame, \"description\");\nvar AlertDialogDescription = createStyledHOC(AlertDialogDescriptionFrame, function AlertDialogDescription2(props, forwardedRef) {\n\tvar { scope, ...descriptionProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogDescription, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...descriptionProps,\n\t\tref: forwardedRef\n\t});\n});\nvar AlertDialogActionFrame = styled(View, { displayName: \"AlertDialogAction\" });\nmarkAlertDialogPart(AlertDialogActionFrame, \"action\");\nvar AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {\n\tvar { scope, ...actionProps } = props;\n\treturn /* @__PURE__ */ jsx(DialogClose, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...actionProps,\n\t\tref: forwardedRef\n\t});\n});\nvar AlertDialogCancelFrame = styled(View, { displayName: \"AlertDialogCancel\" });\nmarkAlertDialogPart(AlertDialogCancelFrame, \"cancel\");\nvar AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {\n\tvar { scope, ...cancelProps } = props;\n\tvar { cancelRef } = useAlertDialogContentContext(scope);\n\tvar ref = useComposedRefs(forwardedRef, cancelRef);\n\treturn /* @__PURE__ */ jsx(DialogClose, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...cancelProps,\n\t\tref\n\t});\n});\nvar AlertDialogDestructiveFrame = styled(View, { displayName: \"AlertDialogDestructive\" });\nmarkAlertDialogPart(AlertDialogDestructiveFrame, \"destructive\");\nvar AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {\n\tvar { scope, ...destructiveProps } = props;\n\tvar { destructiveRef } = useAlertDialogContentContext(scope);\n\tvar ref = useComposedRefs(forwardedRef, destructiveRef);\n\treturn /* @__PURE__ */ jsx(DialogClose, {\n\t\tscope: getAlertDialogScope(scope),\n\t\t...destructiveProps,\n\t\tref\n\t});\n});\nvar DescriptionWarning = function(param) {\n\tvar { contentRef } = param;\n\tif (process.env.NODE_ENV === \"development\") React.useEffect(function() {\n\t\tvar _contentRef_current;\n\t\tif (!isWeb) return;\n\t\tif (!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.\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};\nvar AlertDialogInner = function(props) {\n\tvar { scope, native, ...alertDialogProps } = props;\n\tvar dialogScope = getAlertDialogScope(scope);\n\tvar [open, setOpen] = useControllableState({\n\t\tprop: props.open,\n\t\tdefaultProp: props.defaultOpen || false,\n\t\tonChange: props.onOpenChange,\n\t\ttransition: true\n\t});\n\tvar triggerElement = null;\n\tvar title = \"\";\n\tvar description = \"\";\n\tvar buttons = [];\n\tforEachChildDeep(React.Children.toArray(props.children), function(child) {\n\t\tif (!/* @__PURE__ */ React.isValidElement(child)) return false;\n\t\tvar part = isTamaguiElement(child) ? child.type.staticConfig[ALERT_DIALOG_PART] : void 0;\n\t\tswitch (part) {\n\t\t\tcase \"trigger\":\n\t\t\t\ttriggerElement = /* @__PURE__ */ React.cloneElement(child, { __native: true });\n\t\t\t\treturn false;\n\t\t\tcase \"title\":\n\t\t\t\ttitle = getStringChildren(child);\n\t\t\t\treturn false;\n\t\t\tcase \"description\":\n\t\t\t\tdescription = getStringChildren(child);\n\t\t\t\treturn false;\n\t\t\tcase \"action\":\n\t\t\tcase \"destructive\":\n\t\t\tcase \"cancel\":\n\t\t\t\tvar style = part === \"action\" ? \"default\" : part === \"destructive\" ? \"destructive\" : \"cancel\";\n\t\t\t\tvar text = getStringChildren(child);\n\t\t\t\tvar onPress = function() {\n\t\t\t\t\tvar _childProps_onPress;\n\t\t\t\t\tvar childProps = child.props;\n\t\t\t\t\tchildProps === null || childProps === void 0 || (_childProps_onPress = childProps.onPress) == null || _childProps_onPress.call(childProps, { native: true });\n\t\t\t\t\tsetOpen(false);\n\t\t\t\t};\n\t\t\t\tbuttons.push({\n\t\t\t\t\tstyle,\n\t\t\t\t\ttext,\n\t\t\t\t\tonPress\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\tdefault: return true;\n\t\t}\n\t});\n\tuseIsomorphicLayoutEffect(function() {\n\t\tif (!open || !native) return;\n\t\tif (title || description) Alert.alert(title, description, buttons);\n\t}, [native, open]);\n\tif (native) return /* @__PURE__ */ React.cloneElement(triggerElement, { __onPress: function() {\n\t\tsetOpen(true);\n\t} });\n\treturn /* @__PURE__ */ jsx(Dialog, {\n\t\tscope: dialogScope,\n\t\t...alertDialogProps,\n\t\tmodal: true\n\t});\n};\nfunction forEachChildDeep(children, onChild) {\n\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\ttry {\n\t\tfor (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\tvar child = _step.value;\n\t\t\tif (!/* @__PURE__ */ React.isValidElement(child)) continue;\n\t\t\tif (!onChild(child)) continue;\n\t\t\tvar childProps = child.props;\n\t\t\tif (childProps.children) forEachChildDeep(React.Children.toArray(childProps.children), onChild);\n\t\t}\n\t} catch (err) {\n\t\t_didIteratorError = true;\n\t\t_iteratorError = err;\n\t} finally {\n\t\ttry {\n\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t} finally {\n\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t}\n\t}\n}\nfunction getStringChildren(child) {\n\tvar string = \"\";\n\tforEachChildDeep(React.Children.toArray(child), function(child2) {\n\t\tif (typeof child2.props.children === \"string\") {\n\t\t\tstring = child2.props.children;\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\treturn string;\n}\nvar 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":";;;;;;;;;;;AAUA,IAAI,sBAAsB,SAAS,OAAO;CACzC,OAAO;AACR;AACA,IAAI,YAAY;AAChB,IAAI,oBAAoC,uBAAO,iBAAiB;AAChE,IAAI,sBAAsB,SAAS,WAAW,MAAM;CACnD,OAAO,OAAO,UAAU,cAAc,GAAG,oBAAoB,KAAK,CAAC;AACpE;AACA,IAAI,gCAAgC,OAAO,MAAM,EAAE,aAAa,qBAAqB,CAAC;AACtF,oBAAoB,+BAA+B,SAAS;AAC5D,IAAI,qBAAqB,gBAAgB,+BAA+B,SAAS,oBAAoB,OAAO,cAAc;CACzH,IAAI,MAAM,aAAa;EACtB,IAAI,EAAE,UAAU,SAAS,WAAW,GAAG,SAAS;EAChD,OAAuB,oBAAI,+BAA+B;GACzD,GAAG;GACH,SAAS,qBAAqB,SAAS,SAAS;EACjD,CAAC;CACF;CACA,IAAI,EAAE,OAAO,GAAG,iBAAiB;CACjC,OAAuB,oBAAI,eAAe;EACzC,OAAO,oBAAoB,KAAK;EAChC,GAAG;EACH,KAAK;CACN,CAAC;AACF,CAAC;AACD,IAAI,oBAAoB,SAAS,mBAAmB,OAAO;CAC1D,IAAI,EAAE,OAAO,G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AAiB,KAAK;CACvF,IAAI;EACH,KAAK,IAAI,YAAY,SAAS,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GAC1J,IAAI,QAAQ,MAAM;GAClB,IAAI,CAAiB,sBAAM,eAAe,KAAK,GAAG;GAClD,IAAI,CAAC,QAAQ,KAAK,GAAG;GACrB,IAAI,aAAa,MAAM;GACvB,IAAI,WAAW,UAAU,iBAAiB,MAAM,SAAS,QAAQ,WAAW,QAAQ,GAAG,OAAO;EAC/F;CACD,SAAS,KAAK;EACb,oBAAoB;EACpB,iBAAiB;CAClB,UAAU;EACT,IAAI;GACH,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM,UAAU,OAAO;EAC9E,UAAU;GACT,IAAI,mBAAmB,MAAM;EAC9B;CACD;AACD;AACA,SAAS,kBAAkB,OAAO;CACjC,IAAI,SAAS;CACb,iBAAiB,MAAM,SAAS,QAAQ,KAAK,GAAG,SAAS,QAAQ;EAChE,IAAI,OAAO,OAAO,MAAM,aAAa,UAAU;GAC9C,SAAS,OAAO,MAAM;GACtB,OAAO;EACR;EACA,OAAO;CACR,CAAC;CACD,OAAO;AACR;AACA,IAAI,cAAc,qBAAqB,kBAAkB;CACxD,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.native.js","names":[],"sources":["esm/AlertDialog.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { createStyledHOC } from \"@tamagui/core\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { Slottable, View, createStyledContext, styled } from \"@tamagui/core\";\nimport { Dialog, DialogClose, DialogContent, DialogContentFrame, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider } from \"@tamagui/dialog\";\nimport { composeEventHandlers, withStaticProperties } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { markAlertDialogPart } from \"./alertDialogPart\";\nimport { useNativeAlertDialog } from \"./useNativeAlertDialog\";\nvar getAlertDialogScope = function(scope) {\n return scope;\n};\nvar ROOT_NAME = \"AlertDialog\";\nvar TRIGGER_NAME = \"AlertDialogTrigger\";\nvar NativeAlertDialogTriggerFrame = styled(View, {\n displayName: TRIGGER_NAME\n});\nmarkAlertDialogPart(NativeAlertDialogTriggerFrame, \"trigger\");\nvar AlertDialogTrigger = createStyledHOC(NativeAlertDialogTriggerFrame, function AlertDialogTrigger2(props, forwardedRef) {\n if (props[\"__native\"]) {\n var { __native, onPress, __onPress, ...rest } = props;\n return /* @__PURE__ */ _jsx(NativeAlertDialogTriggerFrame, {\n ...rest,\n onPress: composeEventHandlers(onPress, __onPress)\n });\n }\n var { scope, ...triggerProps } = props;\n return /* @__PURE__ */ _jsx(DialogTrigger, {\n scope: getAlertDialogScope(scope),\n ...triggerProps,\n ref: forwardedRef\n });\n});\nvar AlertDialogPortal = function AlertDialogPortal2(props) {\n var { scope, ...portalProps } = props;\n return /* @__PURE__ */ _jsx(DialogPortal, {\n scope: getAlertDialogScope(scope),\n ...portalProps\n });\n};\nvar OVERLAY_NAME = \"AlertDialogOverlay\";\nvar AlertDialogOverlayFrame = styled(DialogOverlayFrame, {\n displayName: OVERLAY_NAME\n});\nvar AlertDialogOverlay = createStyledHOC(AlertDialogOverlayFrame, function AlertDialogOverlay2(props, forwardedRef) {\n var { scope, ...overlayProps } = props;\n return /* @__PURE__ */ _jsx(DialogOverlay, {\n scope: getAlertDialogScope(scope),\n ...overlayProps,\n ref: forwardedRef\n });\n});\nvar CONTENT_NAME = \"AlertDialogContent\";\nvar { Provider: AlertDialogContextProvider, useStyledContext: useAlertDialogContentContext } = createStyledContext({}, \"AlertDialogContext\");\nvar AlertDialogContentFrame = styled(DialogContentFrame, {\n displayName: CONTENT_NAME\n});\nvar AlertDialogContent = createStyledHOC(AlertDialogContentFrame, function AlertDialogContent2(props, forwardedRef) {\n var { scope, children, ...contentProps } = props;\n var dialogScope = getAlertDialogScope(scope);\n var contentRef = React.useRef(null);\n var composedRefs = useComposedRefs(forwardedRef, contentRef);\n var cancelRef = React.useRef(null);\n var destructiveRef = React.useRef(null);\n return /* @__PURE__ */ _jsx(DialogWarningProvider, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: \"alert-dialog\",\n children: /* @__PURE__ */ _jsx(AlertDialogContextProvider, {\n scope,\n cancelRef,\n destructiveRef,\n children: /* @__PURE__ */ _jsxs(DialogContent, {\n role: \"alertdialog\",\n \"aria-modal\": true,\n scope: dialogScope,\n ...contentProps,\n ref: composedRefs,\n onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, function(event) {\n event.cancel();\n if (isWeb) {\n var _cancelRef_current;\n (_cancelRef_current = cancelRef.current) === null || _cancelRef_current === void 0 ? void 0 : _cancelRef_current.focus({\n preventScroll: true\n });\n }\n }),\n onPointerDownOutside: function(event) {\n return event.cancel();\n },\n onInteractOutside: function(event) {\n return event.cancel();\n },\n children: [\n /**\n * We have to use `Slottable` here as we cannot wrap the `AlertDialogContentProvider`\n * around everything, otherwise the `DescriptionWarning` would be rendered straight away.\n * This is because we want the accessibility checks to run only once the content is actually\n * open and that behaviour is already encapsulated in `DialogContent`.\n */\n /* @__PURE__ */ _jsx(Slottable, {\n children\n }),\n process.env.NODE_ENV === \"development\" && /* @__PURE__ */ _jsx(DescriptionWarning, {\n contentRef\n })\n ]\n })\n })\n });\n});\nvar TITLE_NAME = \"AlertDialogTitle\";\nvar AlertDialogTitleFrame = styled(View, {\n displayName: TITLE_NAME\n});\nmarkAlertDialogPart(AlertDialogTitleFrame, \"title\");\nvar AlertDialogTitle = createStyledHOC(AlertDialogTitleFrame, function AlertDialogTitle2(props, forwardedRef) {\n var { scope, ...titleProps } = props;\n return /* @__PURE__ */ _jsx(DialogTitle, {\n scope: getAlertDialogScope(scope),\n ...titleProps,\n ref: forwardedRef\n });\n});\nvar DESCRIPTION_NAME = \"AlertDialogDescription\";\nvar AlertDialogDescriptionFrame = styled(View, {\n displayName: DESCRIPTION_NAME\n});\nmarkAlertDialogPart(AlertDialogDescriptionFrame, \"description\");\nvar AlertDialogDescription = createStyledHOC(AlertDialogDescriptionFrame, function AlertDialogDescription2(props, forwardedRef) {\n var { scope, ...descriptionProps } = props;\n return /* @__PURE__ */ _jsx(DialogDescription, {\n scope: getAlertDialogScope(scope),\n ...descriptionProps,\n ref: forwardedRef\n });\n});\nvar ACTION_NAME = \"AlertDialogAction\";\nvar AlertDialogActionFrame = styled(View, {\n displayName: ACTION_NAME\n});\nmarkAlertDialogPart(AlertDialogActionFrame, \"action\");\nvar AlertDialogAction = createStyledHOC(AlertDialogActionFrame, function AlertDialogAction2(props, forwardedRef) {\n var { scope, ...actionProps } = props;\n return /* @__PURE__ */ _jsx(DialogClose, {\n scope: getAlertDialogScope(scope),\n ...actionProps,\n ref: forwardedRef\n });\n});\nvar CANCEL_NAME = \"AlertDialogCancel\";\nvar AlertDialogCancelFrame = styled(View, {\n displayName: CANCEL_NAME\n});\nmarkAlertDialogPart(AlertDialogCancelFrame, \"cancel\");\nvar AlertDialogCancel = createStyledHOC(AlertDialogCancelFrame, function AlertDialogCancel2(props, forwardedRef) {\n var { scope, ...cancelProps } = props;\n var { cancelRef } = useAlertDialogContentContext(scope);\n var ref = useComposedRefs(forwardedRef, cancelRef);\n return /* @__PURE__ */ _jsx(DialogClose, {\n scope: getAlertDialogScope(scope),\n ...cancelProps,\n ref\n });\n});\nvar DESTRUCTIVE_NAME = \"AlertDialogDestructive\";\nvar AlertDialogDestructiveFrame = styled(View, {\n displayName: DESTRUCTIVE_NAME\n});\nmarkAlertDialogPart(AlertDialogDestructiveFrame, \"destructive\");\nvar AlertDialogDestructive = createStyledHOC(AlertDialogDestructiveFrame, function AlertDialogDestructive2(props, forwardedRef) {\n var { scope, ...destructiveProps } = props;\n var { destructiveRef } = useAlertDialogContentContext(scope);\n var ref = useComposedRefs(forwardedRef, destructiveRef);\n return /* @__PURE__ */ _jsx(DialogClose, {\n scope: getAlertDialogScope(scope),\n ...destructiveProps,\n ref\n });\n});\nvar DescriptionWarning = function(param) {\n var { contentRef } = param;\n if (process.env.NODE_ENV === \"development\") {\n React.useEffect(function() {\n var _contentRef_current;\n if (!isWeb) return;\n var hasDescription = document.getElementById((_contentRef_current = contentRef.current) === null || _contentRef_current === void 0 ? void 0 : _contentRef_current.getAttribute(\"aria-describedby\"));\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 }, [\n contentRef\n ]);\n }\n return null;\n};\nvar AlertDialogInner = function(props) {\n var { scope, native, ...alertDialogProps } = props;\n var dialogScope = getAlertDialogScope(scope);\n var nativeAlert = useNativeAlertDialog(props);\n if (nativeAlert) return nativeAlert;\n return /* @__PURE__ */ _jsx(Dialog, {\n scope: dialogScope,\n ...alertDialogProps,\n modal: true\n });\n};\nvar 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":";;;;;;;;;;;AAUA,IAAI,sBAAsB,SAAS,OAAO;CACxC,OAAO;AACT;AACA,IAAI,YAAY;AAChB,IAAI,eAAe;AACnB,IAAI,gCAAgC,OAAO,MAAM,EAC/C,aAAa,aACf,CAAC;AACD,oBAAoB,+BAA+B,SAAS;AAC5D,IAAI,qBAAqB,gBAAgB,+BAA+B,SAAS,oBAAoB,OAAO,cAAc;CACxH,IAAI,MAAM,aAAa;EACrB,IAAI,EAAE,UAAU,SAAS,WAAW,GAAG,SAAS;EAChD,OAAuB,oBAAK,+BAA+B;GACzD,GAAG;GACH,SAAS,qBAAqB,SAAS,SAAS;EAClD,CAAC;CACH;CACA,IAAI,EAAE,OAAO,GAAG,iBAAiB;CACjC,OAAuB,oBAAK,eAAe;EACzC,OAAO,oBAAoB,KAAK;EAChC,GAAG;EACH,KAAK;CACP,CAAC;AACH,CAAC;AACD,IAAI,oBAAoB,SAAS,mBAAmB,OAAO;CACzD,IAAI,EAAE,OAAO,GAAG,gBAAgB;CAChC,OAAuB,oBAAK,cAAc;EACxC,OAAO,oBAAoB,KAAK;EAChC,GAAG;CACL,CAAC;AACH;AACA,IAAI,eAAe;AACnB,IAAI,0BAA0B,OAAO,oBAAoB,EACvD,aAAa,aACf,CAAC;AACD,IAAI,qBAAqB,gBAAgB,yBAAyB,SAAS,oBAAoB,OAAO,cAAc;CAClH,IAAI,EAAE,OAAO,GAAG,iBAAiB;CACjC,OAAuB,oBAAK,eAAe;EACzC,OAAO,oBAAoB,KAAK;EAChC,GAAG;EACH,KAAK;CACP,CAAC;AACH,CAAC;AACD,IAAI,eAAe;AACnB,IAAI,EAAE,UAAU,4BAA4B,kB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|
+
const markAlertDialogPart = (component, part) => {
|
|
3
|
+
Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export { ALERT_DIALOG_PART, markAlertDialogPart };
|
|
7
|
+
//# sourceMappingURL=alertDialogPart.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alertDialogPart.js","names":[],"sources":["esm/alertDialogPart.js"],"sourcesContent":["const ALERT_DIALOG_PART = /* @__PURE__ */ Symbol(\"AlertDialogPart\");\nconst markAlertDialogPart = (component, part) => {\n Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });\n};\nexport {\n ALERT_DIALOG_PART,\n markAlertDialogPart\n};\n//# sourceMappingURL=alertDialogPart.js.map\n"],"mappings":";AAAA,MAAM,oBAAoC,uBAAO,iBAAiB;AAClE,MAAM,uBAAuB,WAAW,SAAS;CAC/C,OAAO,OAAO,UAAU,cAAc,GAAG,oBAAoB,KAAK,CAAC;AACrE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var ALERT_DIALOG_PART = /* @__PURE__ */ Symbol("AlertDialogPart");
|
|
2
|
+
var markAlertDialogPart = function(component, part) {
|
|
3
|
+
Object.assign(component.staticConfig, { [ALERT_DIALOG_PART]: part });
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export { ALERT_DIALOG_PART, markAlertDialogPart };
|
|
7
|
+
//# sourceMappingURL=alertDialogPart.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alertDialogPart.native.js","names":[],"sources":["esm/alertDialogPart.native.js"],"sourcesContent":["var ALERT_DIALOG_PART = /* @__PURE__ */ Symbol(\"AlertDialogPart\");\nvar markAlertDialogPart = function(component, part) {\n Object.assign(component.staticConfig, {\n [ALERT_DIALOG_PART]: part\n });\n};\nexport {\n ALERT_DIALOG_PART,\n markAlertDialogPart\n};\n//# sourceMappingURL=alertDialogPart.js.map\n"],"mappings":";AAAA,IAAI,oBAAoC,uBAAO,iBAAiB;AAChE,IAAI,sBAAsB,SAAS,WAAW,MAAM;CAClD,OAAO,OAAO,UAAU,cAAc,GACnC,oBAAoB,KACvB,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNativeAlertDialog.js","names":[],"sources":["esm/useNativeAlertDialog.js"],"sourcesContent":["const useNativeAlertDialog = (_props) => null;\nexport {\n useNativeAlertDialog\n};\n//# sourceMappingURL=useNativeAlertDialog.js.map\n"],"mappings":";AAAA,MAAM,wBAAwB,WAAW"}
|