@tamagui/alert-dialog 1.2.9 → 1.2.10

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.
@@ -0,0 +1,295 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useComposedRefs } from "@tamagui/compose-refs";
3
+ import {
4
+ Slottable,
5
+ composeEventHandlers,
6
+ isTamaguiElement,
7
+ isWeb,
8
+ styled,
9
+ useIsomorphicLayoutEffect,
10
+ withStaticProperties
11
+ } from "@tamagui/core";
12
+ import { createContextScope } from "@tamagui/create-context";
13
+ import {
14
+ Dialog,
15
+ DialogClose,
16
+ DialogContent,
17
+ DialogDescription,
18
+ DialogOverlay,
19
+ DialogPortal,
20
+ DialogTitle,
21
+ DialogTrigger,
22
+ DialogWarningProvider,
23
+ createDialogScope
24
+ } from "@tamagui/dialog";
25
+ import { YStack } from "@tamagui/stacks";
26
+ import { useControllableState } from "@tamagui/use-controllable-state";
27
+ import * as React from "react";
28
+ import { Alert } from "react-native";
29
+ const ROOT_NAME = "AlertDialog";
30
+ const [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [
31
+ createDialogScope
32
+ ]);
33
+ const useDialogScope = createDialogScope();
34
+ const TRIGGER_NAME = "AlertDialogTrigger";
35
+ const NativeAlertDialogTriggerFrame = styled(YStack, {
36
+ name: "DialogTrigger"
37
+ });
38
+ const AlertDialogTrigger = React.forwardRef(
39
+ (props, forwardedRef) => {
40
+ if (props["__native"]) {
41
+ const { __native, onPress, __onPress, ...rest } = props;
42
+ return /* @__PURE__ */ jsx(
43
+ NativeAlertDialogTriggerFrame,
44
+ {
45
+ ...rest,
46
+ onPress: composeEventHandlers(onPress, __onPress)
47
+ }
48
+ );
49
+ }
50
+ const { __scopeAlertDialog, ...triggerProps } = props;
51
+ const dialogScope = useDialogScope(__scopeAlertDialog);
52
+ return /* @__PURE__ */ jsx(DialogTrigger, { ...dialogScope, ...triggerProps, ref: forwardedRef });
53
+ }
54
+ );
55
+ AlertDialogTrigger.displayName = TRIGGER_NAME;
56
+ const PORTAL_NAME = "AlertDialogPortal";
57
+ const AlertDialogPortal = (props) => {
58
+ const { __scopeAlertDialog, ...portalProps } = props;
59
+ const dialogScope = useDialogScope(__scopeAlertDialog);
60
+ return /* @__PURE__ */ jsx(DialogPortal, { ...dialogScope, ...portalProps });
61
+ };
62
+ AlertDialogPortal.displayName = PORTAL_NAME;
63
+ const OVERLAY_NAME = "AlertDialogOverlay";
64
+ const AlertDialogOverlay = React.forwardRef(
65
+ (props, forwardedRef) => {
66
+ const { __scopeAlertDialog, ...overlayProps } = props;
67
+ const dialogScope = useDialogScope(__scopeAlertDialog);
68
+ return /* @__PURE__ */ jsx(DialogOverlay, { ...dialogScope, ...overlayProps, ref: forwardedRef });
69
+ }
70
+ );
71
+ AlertDialogOverlay.displayName = OVERLAY_NAME;
72
+ const CONTENT_NAME = "AlertDialogContent";
73
+ const [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME);
74
+ const AlertDialogContent = React.forwardRef(
75
+ (props, forwardedRef) => {
76
+ const { __scopeAlertDialog, children, ...contentProps } = props;
77
+ const dialogScope = useDialogScope(__scopeAlertDialog);
78
+ const contentRef = React.useRef(null);
79
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
80
+ const cancelRef = React.useRef(null);
81
+ return /* @__PURE__ */ jsx(
82
+ DialogWarningProvider,
83
+ {
84
+ contentName: CONTENT_NAME,
85
+ titleName: TITLE_NAME,
86
+ docsSlug: "alert-dialog",
87
+ children: /* @__PURE__ */ jsx(AlertDialogContentProvider, { scope: __scopeAlertDialog, cancelRef, children: /* @__PURE__ */ jsxs(
88
+ DialogContent,
89
+ {
90
+ role: "alertdialog",
91
+ ...dialogScope,
92
+ ...contentProps,
93
+ ref: composedRefs,
94
+ onOpenAutoFocus: composeEventHandlers(
95
+ contentProps.onOpenAutoFocus,
96
+ (event) => {
97
+ var _a;
98
+ event.preventDefault();
99
+ if (isWeb) {
100
+ (_a = cancelRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
101
+ }
102
+ }
103
+ ),
104
+ onPointerDownOutside: (event) => event.preventDefault(),
105
+ onInteractOutside: (event) => event.preventDefault(),
106
+ children: [
107
+ /* @__PURE__ */ jsx(Slottable, { children }),
108
+ process.env.NODE_ENV === "development" && /* @__PURE__ */ jsx(DescriptionWarning, { contentRef })
109
+ ]
110
+ }
111
+ ) })
112
+ }
113
+ );
114
+ }
115
+ );
116
+ AlertDialogContent.displayName = CONTENT_NAME;
117
+ const TITLE_NAME = "AlertDialogTitle";
118
+ const AlertDialogTitle = React.forwardRef(
119
+ (props, forwardedRef) => {
120
+ const { __scopeAlertDialog, ...titleProps } = props;
121
+ const dialogScope = useDialogScope(__scopeAlertDialog);
122
+ return /* @__PURE__ */ jsx(DialogTitle, { ...dialogScope, ...titleProps, ref: forwardedRef });
123
+ }
124
+ );
125
+ AlertDialogTitle.displayName = TITLE_NAME;
126
+ const DESCRIPTION_NAME = "AlertDialogDescription";
127
+ const AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
128
+ const { __scopeAlertDialog, ...descriptionProps } = props;
129
+ const dialogScope = useDialogScope(__scopeAlertDialog);
130
+ return /* @__PURE__ */ jsx(DialogDescription, { ...dialogScope, ...descriptionProps, ref: forwardedRef });
131
+ });
132
+ AlertDialogDescription.displayName = DESCRIPTION_NAME;
133
+ const ACTION_NAME = "AlertDialogAction";
134
+ const AlertDialogAction = React.forwardRef(
135
+ (props, forwardedRef) => {
136
+ const { __scopeAlertDialog, ...actionProps } = props;
137
+ const dialogScope = useDialogScope(__scopeAlertDialog);
138
+ return /* @__PURE__ */ jsx(DialogClose, { ...dialogScope, ...actionProps, ref: forwardedRef });
139
+ }
140
+ );
141
+ AlertDialogAction.displayName = ACTION_NAME;
142
+ const CANCEL_NAME = "AlertDialogCancel";
143
+ const AlertDialogCancel = React.forwardRef(
144
+ (props, forwardedRef) => {
145
+ const { __scopeAlertDialog, ...cancelProps } = props;
146
+ const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
147
+ const dialogScope = useDialogScope(__scopeAlertDialog);
148
+ const ref = useComposedRefs(forwardedRef, cancelRef);
149
+ return /* @__PURE__ */ jsx(DialogClose, { ...dialogScope, ...cancelProps, ref });
150
+ }
151
+ );
152
+ AlertDialogCancel.displayName = CANCEL_NAME;
153
+ const DescriptionWarning = ({ contentRef }) => {
154
+ if (process.env.NODE_ENV === "development") {
155
+ React.useEffect(() => {
156
+ var _a;
157
+ if (!isWeb)
158
+ return;
159
+ const hasDescription = document.getElementById(
160
+ // @ts-ignore
161
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
162
+ (_a = contentRef.current) == null ? void 0 : _a.getAttribute("aria-describedby")
163
+ );
164
+ if (!hasDescription) {
165
+ console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
166
+
167
+ 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.
168
+
169
+ 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.
170
+
171
+ For more information, see https://tamagui.dev/docs/components/alert-dialog`);
172
+ }
173
+ }, [contentRef]);
174
+ }
175
+ return null;
176
+ };
177
+ const AlertDialogInner = (props) => {
178
+ const { __scopeAlertDialog, native, ...alertDialogProps } = props;
179
+ const dialogScope = useDialogScope(__scopeAlertDialog);
180
+ if (process.env.TAMAGUI_TARGET === "native") {
181
+ const [open, setOpen] = useControllableState({
182
+ prop: props.open,
183
+ defaultProp: props.defaultOpen || false,
184
+ onChange: props.onOpenChange,
185
+ transition: true
186
+ });
187
+ let triggerElement = null;
188
+ let title = "";
189
+ let description = "";
190
+ const buttons = [];
191
+ forEachChildDeep(React.Children.toArray(props.children), (child) => {
192
+ if (!React.isValidElement(child))
193
+ return false;
194
+ const name = isTamaguiElement(child) ? child.type.staticConfig.componentName : child.type["displayName"];
195
+ switch (name) {
196
+ case TRIGGER_NAME: {
197
+ triggerElement = React.cloneElement(child, {
198
+ __native: true
199
+ });
200
+ return false;
201
+ }
202
+ case TITLE_NAME: {
203
+ title = getStringChildren(child);
204
+ return false;
205
+ }
206
+ case DESCRIPTION_NAME: {
207
+ description = getStringChildren(child);
208
+ return false;
209
+ }
210
+ case ACTION_NAME:
211
+ case CANCEL_NAME: {
212
+ const style = name === ACTION_NAME ? "default" : "cancel";
213
+ const text = getStringChildren(child);
214
+ const onPress = () => {
215
+ var _a;
216
+ const childProps = child.props;
217
+ (_a = childProps == null ? void 0 : childProps.onPress) == null ? void 0 : _a.call(childProps, { native: true });
218
+ setOpen(false);
219
+ };
220
+ buttons.push({
221
+ style,
222
+ text,
223
+ // @ts-ignore
224
+ onPress
225
+ });
226
+ return false;
227
+ }
228
+ default: {
229
+ return true;
230
+ }
231
+ }
232
+ });
233
+ useIsomorphicLayoutEffect(() => {
234
+ if (!open || !native)
235
+ return;
236
+ if (title || description) {
237
+ Alert.alert(title, description, buttons);
238
+ }
239
+ }, [native, open]);
240
+ if (native) {
241
+ return React.cloneElement(triggerElement, {
242
+ __onPress: () => {
243
+ setOpen(true);
244
+ }
245
+ });
246
+ }
247
+ }
248
+ return /* @__PURE__ */ jsx(Dialog, { ...dialogScope, ...alertDialogProps, modal: true });
249
+ };
250
+ function forEachChildDeep(children, onChild) {
251
+ for (const child of children) {
252
+ if (!React.isValidElement(child))
253
+ continue;
254
+ if (!onChild(child))
255
+ continue;
256
+ if (child.props.children) {
257
+ forEachChildDeep(React.Children.toArray(child.props.children), onChild);
258
+ }
259
+ }
260
+ }
261
+ function getStringChildren(child) {
262
+ let string = "";
263
+ forEachChildDeep(React.Children.toArray(child), (child2) => {
264
+ if (typeof child2.props.children === "string") {
265
+ string = child2.props.children;
266
+ return false;
267
+ }
268
+ return true;
269
+ });
270
+ return string;
271
+ }
272
+ const AlertDialog = withStaticProperties(AlertDialogInner, {
273
+ Trigger: AlertDialogTrigger,
274
+ Portal: AlertDialogPortal,
275
+ Overlay: AlertDialogOverlay,
276
+ Content: AlertDialogContent,
277
+ Action: AlertDialogAction,
278
+ Cancel: AlertDialogCancel,
279
+ Title: AlertDialogTitle,
280
+ Description: AlertDialogDescription
281
+ });
282
+ AlertDialog.displayName = ROOT_NAME;
283
+ export {
284
+ AlertDialog,
285
+ AlertDialogAction,
286
+ AlertDialogCancel,
287
+ AlertDialogContent,
288
+ AlertDialogDescription,
289
+ AlertDialogOverlay,
290
+ AlertDialogPortal,
291
+ AlertDialogTitle,
292
+ AlertDialogTrigger,
293
+ createAlertDialogScope
294
+ };
295
+ //# sourceMappingURL=AlertDialog.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/AlertDialog.tsx"],
4
+ "sourcesContent": ["// forked from radix-ui\n// https://github.com/radix-ui/primitives/blob/main/packages/react/alert-dialog/src/AlertDialog.tsx\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n Slottable,\n TamaguiElement,\n composeEventHandlers,\n isTamaguiElement,\n isWeb,\n styled,\n useIsomorphicLayoutEffect,\n withStaticProperties,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport {\n Dialog,\n DialogClose,\n DialogCloseProps,\n DialogContent,\n DialogContentProps,\n DialogDescription,\n DialogDescriptionProps,\n DialogOverlay,\n DialogOverlayProps,\n DialogPortal,\n DialogPortalProps,\n DialogProps,\n DialogTitle,\n DialogTitleProps,\n DialogTrigger,\n DialogTriggerProps,\n DialogWarningProvider,\n createDialogScope,\n} from '@tamagui/dialog'\nimport { YStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { Alert } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst ROOT_NAME = 'AlertDialog'\n\ntype ScopedProps<P> = P & { __scopeAlertDialog?: Scope }\nconst [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [\n createDialogScope,\n])\n\nconst useDialogScope = createDialogScope()\n\ntype AlertDialogProps = DialogProps & {\n native?: boolean\n}\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'AlertDialogTrigger'\n\ninterface AlertDialogTriggerProps extends DialogTriggerProps {}\n\nconst NativeAlertDialogTriggerFrame = styled(YStack, {\n name: 'DialogTrigger',\n})\n\nconst AlertDialogTrigger = React.forwardRef<TamaguiElement, AlertDialogTriggerProps>(\n (props: ScopedProps<AlertDialogTriggerProps>, forwardedRef) => {\n if (props['__native']) {\n const { __native, onPress, __onPress, ...rest } = props as any\n return (\n <NativeAlertDialogTriggerFrame\n {...rest}\n onPress={composeEventHandlers(onPress, __onPress)}\n />\n )\n }\n\n const { __scopeAlertDialog, ...triggerProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogTrigger {...dialogScope} {...triggerProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'AlertDialogPortal'\n\ninterface AlertDialogPortalProps extends DialogPortalProps {}\n\nconst AlertDialogPortal: React.FC<AlertDialogPortalProps> = (\n props: ScopedProps<AlertDialogPortalProps>\n) => {\n const { __scopeAlertDialog, ...portalProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogPortal {...dialogScope} {...portalProps} />\n}\n\nAlertDialogPortal.displayName = PORTAL_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'AlertDialogOverlay'\n\ninterface AlertDialogOverlayProps extends DialogOverlayProps {}\n\nconst AlertDialogOverlay = React.forwardRef<TamaguiElement, AlertDialogOverlayProps>(\n (props: ScopedProps<AlertDialogOverlayProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...overlayProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogOverlay {...dialogScope} {...overlayProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogOverlay.displayName = OVERLAY_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'AlertDialogContent'\n\ntype AlertDialogContentContextValue = {\n cancelRef: React.MutableRefObject<TamaguiElement | null>\n}\n\nconst [AlertDialogContentProvider, useAlertDialogContentContext] =\n createAlertDialogContext<AlertDialogContentContextValue>(CONTENT_NAME)\n\ninterface AlertDialogContentProps\n extends Omit<DialogContentProps, 'onPointerDownOutside' | 'onInteractOutside'> {}\n\nconst AlertDialogContent = React.forwardRef<TamaguiElement, AlertDialogContentProps>(\n (props: ScopedProps<AlertDialogContentProps>, forwardedRef) => {\n const { __scopeAlertDialog, children, ...contentProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n const contentRef = React.useRef<TamaguiElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, contentRef)\n const cancelRef = React.useRef<TamaguiElement | null>(null)\n\n return (\n <DialogWarningProvider\n contentName={CONTENT_NAME}\n titleName={TITLE_NAME}\n docsSlug=\"alert-dialog\"\n >\n <AlertDialogContentProvider scope={__scopeAlertDialog} cancelRef={cancelRef}>\n <DialogContent\n // @ts-ignore\n role=\"alertdialog\"\n {...dialogScope}\n {...contentProps}\n ref={composedRefs}\n onOpenAutoFocus={composeEventHandlers(\n contentProps.onOpenAutoFocus,\n (event) => {\n event.preventDefault()\n if (isWeb) {\n // @ts-ignore\n cancelRef.current?.focus({ preventScroll: true })\n }\n }\n )}\n onPointerDownOutside={(event) => event.preventDefault()}\n onInteractOutside={(event) => event.preventDefault()}\n >\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 <Slottable>{children}</Slottable>\n {process.env.NODE_ENV === 'development' && (\n <DescriptionWarning contentRef={contentRef} />\n )}\n </DialogContent>\n </AlertDialogContentProvider>\n </DialogWarningProvider>\n )\n }\n)\n\nAlertDialogContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'AlertDialogTitle'\n\ntype AlertDialogTitleProps = DialogTitleProps\n\nconst AlertDialogTitle = React.forwardRef<TamaguiElement, AlertDialogTitleProps>(\n (props: ScopedProps<AlertDialogTitleProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...titleProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogTitle {...dialogScope} {...titleProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'AlertDialogDescription'\n\ntype AlertDialogDescriptionProps = DialogDescriptionProps\n\nconst AlertDialogDescription = React.forwardRef<\n TamaguiElement,\n AlertDialogDescriptionProps\n>((props: ScopedProps<AlertDialogDescriptionProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...descriptionProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogDescription {...dialogScope} {...descriptionProps} ref={forwardedRef} />\n})\n\nAlertDialogDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'AlertDialogAction'\n\ntype AlertDialogActionProps = DialogCloseProps\n\nconst AlertDialogAction = React.forwardRef<TamaguiElement, AlertDialogActionProps>(\n (props: ScopedProps<AlertDialogActionProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...actionProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogClose {...dialogScope} {...actionProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogCancel\n * -----------------------------------------------------------------------------------------------*/\n\nconst CANCEL_NAME = 'AlertDialogCancel'\n\ninterface AlertDialogCancelProps extends DialogCloseProps {}\n\nconst AlertDialogCancel = React.forwardRef<TamaguiElement, AlertDialogCancelProps>(\n (props: ScopedProps<AlertDialogCancelProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...cancelProps } = props\n const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog)\n const dialogScope = useDialogScope(__scopeAlertDialog)\n const ref = useComposedRefs(forwardedRef, cancelRef)\n return <DialogClose {...dialogScope} {...cancelProps} ref={ref} />\n }\n)\n\nAlertDialogCancel.displayName = CANCEL_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype DescriptionWarningProps = {\n contentRef: React.RefObject<TamaguiElement>\n}\n\nconst DescriptionWarning: React.FC<DescriptionWarningProps> = ({ contentRef }) => {\n if (process.env.NODE_ENV === 'development') {\n React.useEffect(() => {\n if (!isWeb) return\n const hasDescription = document.getElementById(\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n contentRef.current?.getAttribute('aria-describedby')!\n )\n if (!hasDescription) {\n // eslint-disable-next-line no-console\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\n return null\n}\n\nconst AlertDialogInner: React.FC<AlertDialogProps> = (\n props: ScopedProps<AlertDialogProps>\n) => {\n const { __scopeAlertDialog, native, ...alertDialogProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n const [open, setOpen] = useControllableState({\n prop: props.open,\n defaultProp: props.defaultOpen || false,\n onChange: props.onOpenChange,\n transition: true,\n })\n\n let triggerElement: any = null\n let title = ''\n let description = ''\n const buttons: {\n text: string\n onPress: (value?: string | undefined) => void\n style?: 'default' | 'cancel' | 'destructive'\n }[] = []\n\n forEachChildDeep(React.Children.toArray(props.children), (child) => {\n if (!React.isValidElement(child)) return false\n const name = isTamaguiElement(child)\n ? child.type.staticConfig.componentName\n : (child.type['displayName'] as string | undefined)\n switch (name) {\n case TRIGGER_NAME: {\n triggerElement = React.cloneElement(child as any, {\n __native: true,\n })\n return false\n }\n case TITLE_NAME: {\n title = getStringChildren(child)\n return false\n }\n case DESCRIPTION_NAME: {\n description = getStringChildren(child)\n return false\n }\n case ACTION_NAME:\n case CANCEL_NAME: {\n const style = name === ACTION_NAME ? 'default' : 'cancel'\n const text = getStringChildren(child)\n const onPress = () => {\n const childProps = child.props as any\n childProps?.onPress?.({ native: true })\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\n useIsomorphicLayoutEffect(() => {\n if (!open || !native) return\n if (title || description) {\n Alert.alert(title, description, buttons)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [native, open])\n\n if (native) {\n return React.cloneElement(triggerElement, {\n __onPress: () => {\n setOpen(true)\n },\n })\n }\n }\n\n return <Dialog {...dialogScope} {...alertDialogProps} modal />\n}\n\nfunction forEachChildDeep(\n children: React.ReactNode[],\n onChild: (el: React.ReactElement) => boolean\n) {\n for (const child of children) {\n if (!React.isValidElement(child)) continue\n if (!onChild(child)) continue\n if (child.props.children) {\n forEachChildDeep(React.Children.toArray(child.props.children), onChild)\n }\n }\n}\n\nfunction getStringChildren(child: React.ReactElement) {\n let string = ''\n forEachChildDeep(React.Children.toArray(child), (child) => {\n if (typeof child.props.children === 'string') {\n string = child.props.children\n return false\n }\n return true\n })\n return string\n}\n\nconst AlertDialog = withStaticProperties(AlertDialogInner, {\n Trigger: AlertDialogTrigger,\n Portal: AlertDialogPortal,\n Overlay: AlertDialogOverlay,\n Content: AlertDialogContent,\n Action: AlertDialogAction,\n Cancel: AlertDialogCancel,\n Title: AlertDialogTitle,\n Description: AlertDialogDescription,\n})\n\nAlertDialog.displayName = ROOT_NAME\n\nexport {\n createAlertDialogScope,\n //\n AlertDialog,\n AlertDialogTrigger,\n AlertDialogPortal,\n AlertDialogOverlay,\n AlertDialogContent,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogTitle,\n AlertDialogDescription,\n}\nexport type {\n AlertDialogProps,\n AlertDialogTriggerProps,\n AlertDialogPortalProps,\n AlertDialogOverlayProps,\n AlertDialogContentProps,\n AlertDialogActionProps,\n AlertDialogCancelProps,\n AlertDialogTitleProps,\n AlertDialogDescriptionProps,\n}\n"],
5
+ "mappings": "AA0EQ,cAkFE,YAlFF;AAvER,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,0BAA0B;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAGA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,YA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AlertDialog";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './AlertDialog'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,280 @@
1
+ import { useComposedRefs } from "@tamagui/compose-refs";
2
+ import {
3
+ Slottable,
4
+ composeEventHandlers,
5
+ isTamaguiElement,
6
+ isWeb,
7
+ styled,
8
+ useIsomorphicLayoutEffect,
9
+ withStaticProperties
10
+ } from "@tamagui/core";
11
+ import { createContextScope } from "@tamagui/create-context";
12
+ import {
13
+ Dialog,
14
+ DialogClose,
15
+ DialogContent,
16
+ DialogDescription,
17
+ DialogOverlay,
18
+ DialogPortal,
19
+ DialogTitle,
20
+ DialogTrigger,
21
+ DialogWarningProvider,
22
+ createDialogScope
23
+ } from "@tamagui/dialog";
24
+ import { YStack } from "@tamagui/stacks";
25
+ import { useControllableState } from "@tamagui/use-controllable-state";
26
+ import * as React from "react";
27
+ import { Alert } from "react-native";
28
+ const ROOT_NAME = "AlertDialog";
29
+ const [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [
30
+ createDialogScope
31
+ ]);
32
+ const useDialogScope = createDialogScope();
33
+ const TRIGGER_NAME = "AlertDialogTrigger";
34
+ const NativeAlertDialogTriggerFrame = styled(YStack, {
35
+ name: "DialogTrigger"
36
+ });
37
+ const AlertDialogTrigger = React.forwardRef(
38
+ (props, forwardedRef) => {
39
+ if (props["__native"]) {
40
+ const { __native, onPress, __onPress, ...rest } = props;
41
+ return <NativeAlertDialogTriggerFrame
42
+ {...rest}
43
+ onPress={composeEventHandlers(onPress, __onPress)}
44
+ />;
45
+ }
46
+ const { __scopeAlertDialog, ...triggerProps } = props;
47
+ const dialogScope = useDialogScope(__scopeAlertDialog);
48
+ return <DialogTrigger {...dialogScope} {...triggerProps} ref={forwardedRef} />;
49
+ }
50
+ );
51
+ AlertDialogTrigger.displayName = TRIGGER_NAME;
52
+ const PORTAL_NAME = "AlertDialogPortal";
53
+ const AlertDialogPortal = (props) => {
54
+ const { __scopeAlertDialog, ...portalProps } = props;
55
+ const dialogScope = useDialogScope(__scopeAlertDialog);
56
+ return <DialogPortal {...dialogScope} {...portalProps} />;
57
+ };
58
+ AlertDialogPortal.displayName = PORTAL_NAME;
59
+ const OVERLAY_NAME = "AlertDialogOverlay";
60
+ const AlertDialogOverlay = React.forwardRef(
61
+ (props, forwardedRef) => {
62
+ const { __scopeAlertDialog, ...overlayProps } = props;
63
+ const dialogScope = useDialogScope(__scopeAlertDialog);
64
+ return <DialogOverlay {...dialogScope} {...overlayProps} ref={forwardedRef} />;
65
+ }
66
+ );
67
+ AlertDialogOverlay.displayName = OVERLAY_NAME;
68
+ const CONTENT_NAME = "AlertDialogContent";
69
+ const [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME);
70
+ const AlertDialogContent = React.forwardRef(
71
+ (props, forwardedRef) => {
72
+ const { __scopeAlertDialog, children, ...contentProps } = props;
73
+ const dialogScope = useDialogScope(__scopeAlertDialog);
74
+ const contentRef = React.useRef(null);
75
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
76
+ const cancelRef = React.useRef(null);
77
+ return <DialogWarningProvider
78
+ contentName={CONTENT_NAME}
79
+ titleName={TITLE_NAME}
80
+ docsSlug="alert-dialog"
81
+ ><AlertDialogContentProvider scope={__scopeAlertDialog} cancelRef={cancelRef}><DialogContent
82
+ role="alertdialog"
83
+ {...dialogScope}
84
+ {...contentProps}
85
+ ref={composedRefs}
86
+ onOpenAutoFocus={composeEventHandlers(
87
+ contentProps.onOpenAutoFocus,
88
+ (event) => {
89
+ event.preventDefault();
90
+ if (isWeb) {
91
+ cancelRef.current?.focus({ preventScroll: true });
92
+ }
93
+ }
94
+ )}
95
+ onPointerDownOutside={(event) => event.preventDefault()}
96
+ onInteractOutside={(event) => event.preventDefault()}
97
+ >
98
+ <Slottable>{children}</Slottable>
99
+ {process.env.NODE_ENV === "development" && <DescriptionWarning contentRef={contentRef} />}
100
+ </DialogContent></AlertDialogContentProvider></DialogWarningProvider>;
101
+ }
102
+ );
103
+ AlertDialogContent.displayName = CONTENT_NAME;
104
+ const TITLE_NAME = "AlertDialogTitle";
105
+ const AlertDialogTitle = React.forwardRef(
106
+ (props, forwardedRef) => {
107
+ const { __scopeAlertDialog, ...titleProps } = props;
108
+ const dialogScope = useDialogScope(__scopeAlertDialog);
109
+ return <DialogTitle {...dialogScope} {...titleProps} ref={forwardedRef} />;
110
+ }
111
+ );
112
+ AlertDialogTitle.displayName = TITLE_NAME;
113
+ const DESCRIPTION_NAME = "AlertDialogDescription";
114
+ const AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
115
+ const { __scopeAlertDialog, ...descriptionProps } = props;
116
+ const dialogScope = useDialogScope(__scopeAlertDialog);
117
+ return <DialogDescription {...dialogScope} {...descriptionProps} ref={forwardedRef} />;
118
+ });
119
+ AlertDialogDescription.displayName = DESCRIPTION_NAME;
120
+ const ACTION_NAME = "AlertDialogAction";
121
+ const AlertDialogAction = React.forwardRef(
122
+ (props, forwardedRef) => {
123
+ const { __scopeAlertDialog, ...actionProps } = props;
124
+ const dialogScope = useDialogScope(__scopeAlertDialog);
125
+ return <DialogClose {...dialogScope} {...actionProps} ref={forwardedRef} />;
126
+ }
127
+ );
128
+ AlertDialogAction.displayName = ACTION_NAME;
129
+ const CANCEL_NAME = "AlertDialogCancel";
130
+ const AlertDialogCancel = React.forwardRef(
131
+ (props, forwardedRef) => {
132
+ const { __scopeAlertDialog, ...cancelProps } = props;
133
+ const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
134
+ const dialogScope = useDialogScope(__scopeAlertDialog);
135
+ const ref = useComposedRefs(forwardedRef, cancelRef);
136
+ return <DialogClose {...dialogScope} {...cancelProps} ref={ref} />;
137
+ }
138
+ );
139
+ AlertDialogCancel.displayName = CANCEL_NAME;
140
+ const DescriptionWarning = ({ contentRef }) => {
141
+ if (process.env.NODE_ENV === "development") {
142
+ React.useEffect(() => {
143
+ if (!isWeb)
144
+ return;
145
+ const hasDescription = document.getElementById(
146
+ // @ts-ignore
147
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
148
+ contentRef.current?.getAttribute("aria-describedby")
149
+ );
150
+ if (!hasDescription) {
151
+ console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
152
+
153
+ 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.
154
+
155
+ 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.
156
+
157
+ For more information, see https://tamagui.dev/docs/components/alert-dialog`);
158
+ }
159
+ }, [contentRef]);
160
+ }
161
+ return null;
162
+ };
163
+ const AlertDialogInner = (props) => {
164
+ const { __scopeAlertDialog, native, ...alertDialogProps } = props;
165
+ const dialogScope = useDialogScope(__scopeAlertDialog);
166
+ if (process.env.TAMAGUI_TARGET === "native") {
167
+ const [open, setOpen] = useControllableState({
168
+ prop: props.open,
169
+ defaultProp: props.defaultOpen || false,
170
+ onChange: props.onOpenChange,
171
+ transition: true
172
+ });
173
+ let triggerElement = null;
174
+ let title = "";
175
+ let description = "";
176
+ const buttons = [];
177
+ forEachChildDeep(React.Children.toArray(props.children), (child) => {
178
+ if (!React.isValidElement(child))
179
+ return false;
180
+ const name = isTamaguiElement(child) ? child.type.staticConfig.componentName : child.type["displayName"];
181
+ switch (name) {
182
+ case TRIGGER_NAME: {
183
+ triggerElement = React.cloneElement(child, {
184
+ __native: true
185
+ });
186
+ return false;
187
+ }
188
+ case TITLE_NAME: {
189
+ title = getStringChildren(child);
190
+ return false;
191
+ }
192
+ case DESCRIPTION_NAME: {
193
+ description = getStringChildren(child);
194
+ return false;
195
+ }
196
+ case ACTION_NAME:
197
+ case CANCEL_NAME: {
198
+ const style = name === ACTION_NAME ? "default" : "cancel";
199
+ const text = getStringChildren(child);
200
+ const onPress = () => {
201
+ const childProps = child.props;
202
+ childProps?.onPress?.({ native: true });
203
+ setOpen(false);
204
+ };
205
+ buttons.push({
206
+ style,
207
+ text,
208
+ // @ts-ignore
209
+ onPress
210
+ });
211
+ return false;
212
+ }
213
+ default: {
214
+ return true;
215
+ }
216
+ }
217
+ });
218
+ useIsomorphicLayoutEffect(() => {
219
+ if (!open || !native)
220
+ return;
221
+ if (title || description) {
222
+ Alert.alert(title, description, buttons);
223
+ }
224
+ }, [native, open]);
225
+ if (native) {
226
+ return React.cloneElement(triggerElement, {
227
+ __onPress: () => {
228
+ setOpen(true);
229
+ }
230
+ });
231
+ }
232
+ }
233
+ return <Dialog {...dialogScope} {...alertDialogProps} modal />;
234
+ };
235
+ function forEachChildDeep(children, onChild) {
236
+ for (const child of children) {
237
+ if (!React.isValidElement(child))
238
+ continue;
239
+ if (!onChild(child))
240
+ continue;
241
+ if (child.props.children) {
242
+ forEachChildDeep(React.Children.toArray(child.props.children), onChild);
243
+ }
244
+ }
245
+ }
246
+ function getStringChildren(child) {
247
+ let string = "";
248
+ forEachChildDeep(React.Children.toArray(child), (child2) => {
249
+ if (typeof child2.props.children === "string") {
250
+ string = child2.props.children;
251
+ return false;
252
+ }
253
+ return true;
254
+ });
255
+ return string;
256
+ }
257
+ const AlertDialog = withStaticProperties(AlertDialogInner, {
258
+ Trigger: AlertDialogTrigger,
259
+ Portal: AlertDialogPortal,
260
+ Overlay: AlertDialogOverlay,
261
+ Content: AlertDialogContent,
262
+ Action: AlertDialogAction,
263
+ Cancel: AlertDialogCancel,
264
+ Title: AlertDialogTitle,
265
+ Description: AlertDialogDescription
266
+ });
267
+ AlertDialog.displayName = ROOT_NAME;
268
+ export {
269
+ AlertDialog,
270
+ AlertDialogAction,
271
+ AlertDialogCancel,
272
+ AlertDialogContent,
273
+ AlertDialogDescription,
274
+ AlertDialogOverlay,
275
+ AlertDialogPortal,
276
+ AlertDialogTitle,
277
+ AlertDialogTrigger,
278
+ createAlertDialogScope
279
+ };
280
+ //# sourceMappingURL=AlertDialog.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/AlertDialog.tsx"],
4
+ "sourcesContent": ["// forked from radix-ui\n// https://github.com/radix-ui/primitives/blob/main/packages/react/alert-dialog/src/AlertDialog.tsx\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n Slottable,\n TamaguiElement,\n composeEventHandlers,\n isTamaguiElement,\n isWeb,\n styled,\n useIsomorphicLayoutEffect,\n withStaticProperties,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport {\n Dialog,\n DialogClose,\n DialogCloseProps,\n DialogContent,\n DialogContentProps,\n DialogDescription,\n DialogDescriptionProps,\n DialogOverlay,\n DialogOverlayProps,\n DialogPortal,\n DialogPortalProps,\n DialogProps,\n DialogTitle,\n DialogTitleProps,\n DialogTrigger,\n DialogTriggerProps,\n DialogWarningProvider,\n createDialogScope,\n} from '@tamagui/dialog'\nimport { YStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { Alert } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst ROOT_NAME = 'AlertDialog'\n\ntype ScopedProps<P> = P & { __scopeAlertDialog?: Scope }\nconst [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [\n createDialogScope,\n])\n\nconst useDialogScope = createDialogScope()\n\ntype AlertDialogProps = DialogProps & {\n native?: boolean\n}\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'AlertDialogTrigger'\n\ninterface AlertDialogTriggerProps extends DialogTriggerProps {}\n\nconst NativeAlertDialogTriggerFrame = styled(YStack, {\n name: 'DialogTrigger',\n})\n\nconst AlertDialogTrigger = React.forwardRef<TamaguiElement, AlertDialogTriggerProps>(\n (props: ScopedProps<AlertDialogTriggerProps>, forwardedRef) => {\n if (props['__native']) {\n const { __native, onPress, __onPress, ...rest } = props as any\n return (\n <NativeAlertDialogTriggerFrame\n {...rest}\n onPress={composeEventHandlers(onPress, __onPress)}\n />\n )\n }\n\n const { __scopeAlertDialog, ...triggerProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogTrigger {...dialogScope} {...triggerProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'AlertDialogPortal'\n\ninterface AlertDialogPortalProps extends DialogPortalProps {}\n\nconst AlertDialogPortal: React.FC<AlertDialogPortalProps> = (\n props: ScopedProps<AlertDialogPortalProps>\n) => {\n const { __scopeAlertDialog, ...portalProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogPortal {...dialogScope} {...portalProps} />\n}\n\nAlertDialogPortal.displayName = PORTAL_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'AlertDialogOverlay'\n\ninterface AlertDialogOverlayProps extends DialogOverlayProps {}\n\nconst AlertDialogOverlay = React.forwardRef<TamaguiElement, AlertDialogOverlayProps>(\n (props: ScopedProps<AlertDialogOverlayProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...overlayProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogOverlay {...dialogScope} {...overlayProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogOverlay.displayName = OVERLAY_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'AlertDialogContent'\n\ntype AlertDialogContentContextValue = {\n cancelRef: React.MutableRefObject<TamaguiElement | null>\n}\n\nconst [AlertDialogContentProvider, useAlertDialogContentContext] =\n createAlertDialogContext<AlertDialogContentContextValue>(CONTENT_NAME)\n\ninterface AlertDialogContentProps\n extends Omit<DialogContentProps, 'onPointerDownOutside' | 'onInteractOutside'> {}\n\nconst AlertDialogContent = React.forwardRef<TamaguiElement, AlertDialogContentProps>(\n (props: ScopedProps<AlertDialogContentProps>, forwardedRef) => {\n const { __scopeAlertDialog, children, ...contentProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n const contentRef = React.useRef<TamaguiElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, contentRef)\n const cancelRef = React.useRef<TamaguiElement | null>(null)\n\n return (\n <DialogWarningProvider\n contentName={CONTENT_NAME}\n titleName={TITLE_NAME}\n docsSlug=\"alert-dialog\"\n >\n <AlertDialogContentProvider scope={__scopeAlertDialog} cancelRef={cancelRef}>\n <DialogContent\n // @ts-ignore\n role=\"alertdialog\"\n {...dialogScope}\n {...contentProps}\n ref={composedRefs}\n onOpenAutoFocus={composeEventHandlers(\n contentProps.onOpenAutoFocus,\n (event) => {\n event.preventDefault()\n if (isWeb) {\n // @ts-ignore\n cancelRef.current?.focus({ preventScroll: true })\n }\n }\n )}\n onPointerDownOutside={(event) => event.preventDefault()}\n onInteractOutside={(event) => event.preventDefault()}\n >\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 <Slottable>{children}</Slottable>\n {process.env.NODE_ENV === 'development' && (\n <DescriptionWarning contentRef={contentRef} />\n )}\n </DialogContent>\n </AlertDialogContentProvider>\n </DialogWarningProvider>\n )\n }\n)\n\nAlertDialogContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'AlertDialogTitle'\n\ntype AlertDialogTitleProps = DialogTitleProps\n\nconst AlertDialogTitle = React.forwardRef<TamaguiElement, AlertDialogTitleProps>(\n (props: ScopedProps<AlertDialogTitleProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...titleProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogTitle {...dialogScope} {...titleProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'AlertDialogDescription'\n\ntype AlertDialogDescriptionProps = DialogDescriptionProps\n\nconst AlertDialogDescription = React.forwardRef<\n TamaguiElement,\n AlertDialogDescriptionProps\n>((props: ScopedProps<AlertDialogDescriptionProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...descriptionProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogDescription {...dialogScope} {...descriptionProps} ref={forwardedRef} />\n})\n\nAlertDialogDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'AlertDialogAction'\n\ntype AlertDialogActionProps = DialogCloseProps\n\nconst AlertDialogAction = React.forwardRef<TamaguiElement, AlertDialogActionProps>(\n (props: ScopedProps<AlertDialogActionProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...actionProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <DialogClose {...dialogScope} {...actionProps} ref={forwardedRef} />\n }\n)\n\nAlertDialogAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogCancel\n * -----------------------------------------------------------------------------------------------*/\n\nconst CANCEL_NAME = 'AlertDialogCancel'\n\ninterface AlertDialogCancelProps extends DialogCloseProps {}\n\nconst AlertDialogCancel = React.forwardRef<TamaguiElement, AlertDialogCancelProps>(\n (props: ScopedProps<AlertDialogCancelProps>, forwardedRef) => {\n const { __scopeAlertDialog, ...cancelProps } = props\n const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog)\n const dialogScope = useDialogScope(__scopeAlertDialog)\n const ref = useComposedRefs(forwardedRef, cancelRef)\n return <DialogClose {...dialogScope} {...cancelProps} ref={ref} />\n }\n)\n\nAlertDialogCancel.displayName = CANCEL_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype DescriptionWarningProps = {\n contentRef: React.RefObject<TamaguiElement>\n}\n\nconst DescriptionWarning: React.FC<DescriptionWarningProps> = ({ contentRef }) => {\n if (process.env.NODE_ENV === 'development') {\n React.useEffect(() => {\n if (!isWeb) return\n const hasDescription = document.getElementById(\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n contentRef.current?.getAttribute('aria-describedby')!\n )\n if (!hasDescription) {\n // eslint-disable-next-line no-console\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\n return null\n}\n\nconst AlertDialogInner: React.FC<AlertDialogProps> = (\n props: ScopedProps<AlertDialogProps>\n) => {\n const { __scopeAlertDialog, native, ...alertDialogProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n const [open, setOpen] = useControllableState({\n prop: props.open,\n defaultProp: props.defaultOpen || false,\n onChange: props.onOpenChange,\n transition: true,\n })\n\n let triggerElement: any = null\n let title = ''\n let description = ''\n const buttons: {\n text: string\n onPress: (value?: string | undefined) => void\n style?: 'default' | 'cancel' | 'destructive'\n }[] = []\n\n forEachChildDeep(React.Children.toArray(props.children), (child) => {\n if (!React.isValidElement(child)) return false\n const name = isTamaguiElement(child)\n ? child.type.staticConfig.componentName\n : (child.type['displayName'] as string | undefined)\n switch (name) {\n case TRIGGER_NAME: {\n triggerElement = React.cloneElement(child as any, {\n __native: true,\n })\n return false\n }\n case TITLE_NAME: {\n title = getStringChildren(child)\n return false\n }\n case DESCRIPTION_NAME: {\n description = getStringChildren(child)\n return false\n }\n case ACTION_NAME:\n case CANCEL_NAME: {\n const style = name === ACTION_NAME ? 'default' : 'cancel'\n const text = getStringChildren(child)\n const onPress = () => {\n const childProps = child.props as any\n childProps?.onPress?.({ native: true })\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\n useIsomorphicLayoutEffect(() => {\n if (!open || !native) return\n if (title || description) {\n Alert.alert(title, description, buttons)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [native, open])\n\n if (native) {\n return React.cloneElement(triggerElement, {\n __onPress: () => {\n setOpen(true)\n },\n })\n }\n }\n\n return <Dialog {...dialogScope} {...alertDialogProps} modal />\n}\n\nfunction forEachChildDeep(\n children: React.ReactNode[],\n onChild: (el: React.ReactElement) => boolean\n) {\n for (const child of children) {\n if (!React.isValidElement(child)) continue\n if (!onChild(child)) continue\n if (child.props.children) {\n forEachChildDeep(React.Children.toArray(child.props.children), onChild)\n }\n }\n}\n\nfunction getStringChildren(child: React.ReactElement) {\n let string = ''\n forEachChildDeep(React.Children.toArray(child), (child) => {\n if (typeof child.props.children === 'string') {\n string = child.props.children\n return false\n }\n return true\n })\n return string\n}\n\nconst AlertDialog = withStaticProperties(AlertDialogInner, {\n Trigger: AlertDialogTrigger,\n Portal: AlertDialogPortal,\n Overlay: AlertDialogOverlay,\n Content: AlertDialogContent,\n Action: AlertDialogAction,\n Cancel: AlertDialogCancel,\n Title: AlertDialogTitle,\n Description: AlertDialogDescription,\n})\n\nAlertDialog.displayName = ROOT_NAME\n\nexport {\n createAlertDialogScope,\n //\n AlertDialog,\n AlertDialogTrigger,\n AlertDialogPortal,\n AlertDialogOverlay,\n AlertDialogContent,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogTitle,\n AlertDialogDescription,\n}\nexport type {\n AlertDialogProps,\n AlertDialogTriggerProps,\n AlertDialogPortalProps,\n AlertDialogOverlayProps,\n AlertDialogContentProps,\n AlertDialogActionProps,\n AlertDialogCancelProps,\n AlertDialogTitleProps,\n AlertDialogDescriptionProps,\n}\n"],
5
+ "mappings": "AAGA,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,0BAA0B;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAGA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,YAAY,WAAW;AACvB,SAAS,aAAa;AAMtB,MAAM,YAAY;AAGlB,MAAM,CAAC,0BAA0B,sBAAsB,IAAI,mBAAmB,WAAW;AAAA,EACvF;AACF,CAAC;AAED,MAAM,iBAAiB,kBAAkB;AAUzC,MAAM,eAAe;AAIrB,MAAM,gCAAgC,OAAO,QAAQ;AAAA,EACnD,MAAM;AACR,CAAC;AAED,MAAM,qBAAqB,MAAM;AAAA,EAC/B,CAAC,OAA6C,iBAAiB;AAC7D,QAAI,MAAM,UAAU,GAAG;AACrB,YAAM,EAAE,UAAU,SAAS,WAAW,GAA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AU;AAC5B,QAAI,CAAC,MAAM,eAAe,KAAK;AAAG;AAClC,QAAI,CAAC,QAAQ,KAAK;AAAG;AACrB,QAAI,MAAM,MAAM,UAAU;AACxB,uBAAiB,MAAM,SAAS,QAAQ,MAAM,MAAM,QAAQ,GAAG,OAAO;AAAA,IACxE;AAAA,EACF;AACF;AAEA,SAAS,kBAAkB,OAA2B;AACpD,MAAI,SAAS;AACb,mBAAiB,MAAM,SAAS,QAAQ,KAAK,GAAG,CAACA,WAAU;AACzD,QAAI,OAAOA,OAAM,MAAM,aAAa,UAAU;AAC5C,eAASA,OAAM,MAAM;AACrB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,CAAC;AACD,SAAO;AACT;AAEA,MAAM,cAAc,qBAAqB,kBAAkB;AAAA,EACzD,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AACf,CAAC;AAED,YAAY,cAAc;",
6
+ "names": ["child"]
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./AlertDialog";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './AlertDialog'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/alert-dialog",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -21,21 +21,21 @@
21
21
  "clean:build": "tamagui-build clean:build"
22
22
  },
23
23
  "dependencies": {
24
- "@tamagui/animate-presence": "^1.2.9",
25
- "@tamagui/aria-hidden": "^1.2.9",
26
- "@tamagui/compose-refs": "^1.2.9",
27
- "@tamagui/core": "^1.2.9",
28
- "@tamagui/create-context": "^1.2.9",
29
- "@tamagui/dialog": "^1.2.9",
30
- "@tamagui/dismissable": "^1.2.9",
31
- "@tamagui/focus-scope": "^1.2.9",
32
- "@tamagui/polyfill-dev": "^1.2.9",
33
- "@tamagui/popper": "^1.2.9",
34
- "@tamagui/portal": "^1.2.9",
35
- "@tamagui/remove-scroll": "^1.2.9",
36
- "@tamagui/stacks": "^1.2.9",
37
- "@tamagui/text": "^1.2.9",
38
- "@tamagui/use-controllable-state": "^1.2.9"
24
+ "@tamagui/animate-presence": "^1.2.10",
25
+ "@tamagui/aria-hidden": "^1.2.10",
26
+ "@tamagui/compose-refs": "^1.2.10",
27
+ "@tamagui/core": "^1.2.10",
28
+ "@tamagui/create-context": "^1.2.10",
29
+ "@tamagui/dialog": "^1.2.10",
30
+ "@tamagui/dismissable": "^1.2.10",
31
+ "@tamagui/focus-scope": "^1.2.10",
32
+ "@tamagui/polyfill-dev": "^1.2.10",
33
+ "@tamagui/popper": "^1.2.10",
34
+ "@tamagui/portal": "^1.2.10",
35
+ "@tamagui/remove-scroll": "^1.2.10",
36
+ "@tamagui/stacks": "^1.2.10",
37
+ "@tamagui/text": "^1.2.10",
38
+ "@tamagui/use-controllable-state": "^1.2.10"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "*",
@@ -43,7 +43,7 @@
43
43
  "react-native": "*"
44
44
  },
45
45
  "devDependencies": {
46
- "@tamagui/build": "^1.2.9",
46
+ "@tamagui/build": "^1.2.10",
47
47
  "react": "^18.2.0",
48
48
  "react-dom": "^18.2.0",
49
49
  "react-native": "*"