@tamagui/alert-dialog 1.0.1-beta.108 → 1.0.1-beta.111
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.js +49 -59
- package/dist/cjs/AlertDialog.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/AlertDialog.js +48 -61
- package/dist/esm/AlertDialog.js.map +1 -1
- package/package.json +17 -17
- package/dist/cjs/Dialog.js +0 -523
- package/dist/cjs/Dialog.js.map +0 -7
- package/dist/esm/Dialog.js +0 -498
- package/dist/esm/Dialog.js.map +0 -7
- package/dist/jsx/Dialog.js +0 -355
- package/dist/jsx/Dialog.js.map +0 -7
package/dist/cjs/AlertDialog.js
CHANGED
|
@@ -1,38 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
8
|
var __export = (target, all) => {
|
|
37
9
|
for (var name in all)
|
|
38
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -73,33 +45,40 @@ const [createAlertDialogContext, createAlertDialogScope] = (0, import_create_con
|
|
|
73
45
|
const useDialogScope = (0, import_dialog.createDialogScope)();
|
|
74
46
|
const TRIGGER_NAME = "AlertDialogTrigger";
|
|
75
47
|
const AlertDialogTrigger = React.forwardRef((props, forwardedRef) => {
|
|
76
|
-
const
|
|
48
|
+
const { __scopeAlertDialog, ...triggerProps } = props;
|
|
77
49
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
78
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogTrigger,
|
|
50
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogTrigger, {
|
|
51
|
+
...dialogScope,
|
|
52
|
+
...triggerProps,
|
|
79
53
|
ref: forwardedRef
|
|
80
|
-
})
|
|
54
|
+
});
|
|
81
55
|
});
|
|
82
56
|
AlertDialogTrigger.displayName = TRIGGER_NAME;
|
|
83
57
|
const PORTAL_NAME = "AlertDialogPortal";
|
|
84
58
|
const AlertDialogPortal = (props) => {
|
|
85
|
-
const
|
|
59
|
+
const { __scopeAlertDialog, ...portalProps } = props;
|
|
86
60
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
87
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogPortal,
|
|
61
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogPortal, {
|
|
62
|
+
...dialogScope,
|
|
63
|
+
...portalProps
|
|
64
|
+
});
|
|
88
65
|
};
|
|
89
66
|
AlertDialogPortal.displayName = PORTAL_NAME;
|
|
90
67
|
const OVERLAY_NAME = "AlertDialogOverlay";
|
|
91
68
|
const AlertDialogOverlay = React.forwardRef((props, forwardedRef) => {
|
|
92
|
-
const
|
|
69
|
+
const { __scopeAlertDialog, ...overlayProps } = props;
|
|
93
70
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
94
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogOverlay,
|
|
71
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogOverlay, {
|
|
72
|
+
...dialogScope,
|
|
73
|
+
...overlayProps,
|
|
95
74
|
ref: forwardedRef
|
|
96
|
-
})
|
|
75
|
+
});
|
|
97
76
|
});
|
|
98
77
|
AlertDialogOverlay.displayName = OVERLAY_NAME;
|
|
99
78
|
const CONTENT_NAME = "AlertDialogContent";
|
|
100
79
|
const [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME);
|
|
101
80
|
const AlertDialogContent = React.forwardRef((props, forwardedRef) => {
|
|
102
|
-
const
|
|
81
|
+
const { __scopeAlertDialog, children, ...contentProps } = props;
|
|
103
82
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
104
83
|
const contentRef = React.useRef(null);
|
|
105
84
|
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
@@ -111,60 +90,69 @@ const AlertDialogContent = React.forwardRef((props, forwardedRef) => {
|
|
|
111
90
|
}, /* @__PURE__ */ React.createElement(AlertDialogContentProvider, {
|
|
112
91
|
scope: __scopeAlertDialog,
|
|
113
92
|
cancelRef
|
|
114
|
-
}, /* @__PURE__ */ React.createElement(import_dialog.DialogContent,
|
|
115
|
-
role: "alertdialog"
|
|
116
|
-
|
|
93
|
+
}, /* @__PURE__ */ React.createElement(import_dialog.DialogContent, {
|
|
94
|
+
role: "alertdialog",
|
|
95
|
+
...dialogScope,
|
|
96
|
+
...contentProps,
|
|
117
97
|
ref: composedRefs,
|
|
118
98
|
onOpenAutoFocus: (0, import_core.composeEventHandlers)(contentProps.onOpenAutoFocus, (event) => {
|
|
119
|
-
var
|
|
99
|
+
var _a;
|
|
120
100
|
event.preventDefault();
|
|
121
101
|
if (import_core.isWeb) {
|
|
122
|
-
(
|
|
102
|
+
(_a = cancelRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
123
103
|
}
|
|
124
104
|
}),
|
|
125
105
|
onPointerDownOutside: (event) => event.preventDefault(),
|
|
126
106
|
onInteractOutside: (event) => event.preventDefault()
|
|
127
|
-
}
|
|
107
|
+
}, /* @__PURE__ */ React.createElement(import_core.Slottable, null, children), process.env.NODE_ENV === "development" && /* @__PURE__ */ React.createElement(DescriptionWarning, {
|
|
128
108
|
contentRef
|
|
129
109
|
}))));
|
|
130
110
|
});
|
|
131
111
|
AlertDialogContent.displayName = CONTENT_NAME;
|
|
132
112
|
const TITLE_NAME = "AlertDialogTitle";
|
|
133
113
|
const AlertDialogTitle = React.forwardRef((props, forwardedRef) => {
|
|
134
|
-
const
|
|
114
|
+
const { __scopeAlertDialog, ...titleProps } = props;
|
|
135
115
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
136
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogTitle,
|
|
116
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogTitle, {
|
|
117
|
+
...dialogScope,
|
|
118
|
+
...titleProps,
|
|
137
119
|
ref: forwardedRef
|
|
138
|
-
})
|
|
120
|
+
});
|
|
139
121
|
});
|
|
140
122
|
AlertDialogTitle.displayName = TITLE_NAME;
|
|
141
123
|
const DESCRIPTION_NAME = "AlertDialogDescription";
|
|
142
124
|
const AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
|
|
143
|
-
const
|
|
125
|
+
const { __scopeAlertDialog, ...descriptionProps } = props;
|
|
144
126
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
145
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogDescription,
|
|
127
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogDescription, {
|
|
128
|
+
...dialogScope,
|
|
129
|
+
...descriptionProps,
|
|
146
130
|
ref: forwardedRef
|
|
147
|
-
})
|
|
131
|
+
});
|
|
148
132
|
});
|
|
149
133
|
AlertDialogDescription.displayName = DESCRIPTION_NAME;
|
|
150
134
|
const ACTION_NAME = "AlertDialogAction";
|
|
151
135
|
const AlertDialogAction = React.forwardRef((props, forwardedRef) => {
|
|
152
|
-
const
|
|
136
|
+
const { __scopeAlertDialog, ...actionProps } = props;
|
|
153
137
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
154
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogClose,
|
|
138
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogClose, {
|
|
139
|
+
...dialogScope,
|
|
140
|
+
...actionProps,
|
|
155
141
|
ref: forwardedRef
|
|
156
|
-
})
|
|
142
|
+
});
|
|
157
143
|
});
|
|
158
144
|
AlertDialogAction.displayName = ACTION_NAME;
|
|
159
145
|
const CANCEL_NAME = "AlertDialogCancel";
|
|
160
146
|
const AlertDialogCancel = React.forwardRef((props, forwardedRef) => {
|
|
161
|
-
const
|
|
147
|
+
const { __scopeAlertDialog, ...cancelProps } = props;
|
|
162
148
|
const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
|
|
163
149
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
164
150
|
const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, cancelRef);
|
|
165
|
-
return /* @__PURE__ */ React.createElement(import_dialog.DialogClose,
|
|
151
|
+
return /* @__PURE__ */ React.createElement(import_dialog.DialogClose, {
|
|
152
|
+
...dialogScope,
|
|
153
|
+
...cancelProps,
|
|
166
154
|
ref
|
|
167
|
-
})
|
|
155
|
+
});
|
|
168
156
|
});
|
|
169
157
|
AlertDialogCancel.displayName = CANCEL_NAME;
|
|
170
158
|
const DescriptionWarning = ({ contentRef }) => {
|
|
@@ -186,11 +174,13 @@ For more information, see https://tamagui.dev/docs/components/alert-dialog`;
|
|
|
186
174
|
return null;
|
|
187
175
|
};
|
|
188
176
|
const AlertDialogInner = (props) => {
|
|
189
|
-
const
|
|
177
|
+
const { __scopeAlertDialog, ...alertDialogProps } = props;
|
|
190
178
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
191
|
-
return /* @__PURE__ */ React.createElement(import_dialog.Dialog,
|
|
179
|
+
return /* @__PURE__ */ React.createElement(import_dialog.Dialog, {
|
|
180
|
+
...dialogScope,
|
|
181
|
+
...alertDialogProps,
|
|
192
182
|
modal: true
|
|
193
|
-
})
|
|
183
|
+
});
|
|
194
184
|
};
|
|
195
185
|
const AlertDialog = (0, import_core.withStaticProperties)(AlertDialogInner, {
|
|
196
186
|
Trigger: AlertDialogTrigger,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AlertDialog.tsx"],
|
|
4
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 isWeb,\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 * as React from 'react'\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\ninterface AlertDialogProps extends Omit<DialogProps, 'modal'> {}\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogTrigger\n * -----------------------------------------------------------------------------------------------*/\nconst TRIGGER_NAME = 'AlertDialogTrigger'\n\ninterface AlertDialogTriggerProps extends DialogTriggerProps {}\n\nconst AlertDialogTrigger = React.forwardRef<TamaguiElement, AlertDialogTriggerProps>(\n (props: ScopedProps<AlertDialogTriggerProps>, forwardedRef) => {\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(contentProps.onOpenAutoFocus, (event) => {\n event.preventDefault()\n if (isWeb) {\n // @ts-ignore\n cancelRef.current?.focus({ preventScroll: true })\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<TamaguiElement, 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)\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 const MESSAGE = `\\`${CONTENT_NAME}\\` requires a description for the component to be accessible for screen reader users.\n\nYou 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\nAlternatively, 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\nFor more information, see https://tamagui.dev/docs/components/alert-dialog`\n\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) console.warn(MESSAGE)\n }, [MESSAGE, contentRef])\n\n return null\n}\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst AlertDialogInner: React.FC<AlertDialogProps> = (props: ScopedProps<AlertDialogProps>) => {\n const { __scopeAlertDialog, ...alertDialogProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <Dialog {...dialogScope} {...alertDialogProps} modal={true} />\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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAgC;AAChC,kBAMO;AACP,4BAA0C;AAC1C,oBAmBO;AACP,YAAuB;AAEvB,MAAM,YAAY;AAGlB,MAAM,CAAC,0BAA0B,0BAA0B,8CAAmB,WAAW;AAAA,EACvF;AACF,CAAC;AAED,MAAM,iBAAiB,qCAAkB;AAOzC,MAAM,eAAe;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var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
1
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
33
2
|
import {
|
|
34
3
|
Slottable,
|
|
@@ -57,33 +26,40 @@ const [createAlertDialogContext, createAlertDialogScope] = createContextScope(RO
|
|
|
57
26
|
const useDialogScope = createDialogScope();
|
|
58
27
|
const TRIGGER_NAME = "AlertDialogTrigger";
|
|
59
28
|
const AlertDialogTrigger = React.forwardRef((props, forwardedRef) => {
|
|
60
|
-
const
|
|
29
|
+
const { __scopeAlertDialog, ...triggerProps } = props;
|
|
61
30
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
62
|
-
return /* @__PURE__ */ React.createElement(DialogTrigger,
|
|
31
|
+
return /* @__PURE__ */ React.createElement(DialogTrigger, {
|
|
32
|
+
...dialogScope,
|
|
33
|
+
...triggerProps,
|
|
63
34
|
ref: forwardedRef
|
|
64
|
-
})
|
|
35
|
+
});
|
|
65
36
|
});
|
|
66
37
|
AlertDialogTrigger.displayName = TRIGGER_NAME;
|
|
67
38
|
const PORTAL_NAME = "AlertDialogPortal";
|
|
68
39
|
const AlertDialogPortal = (props) => {
|
|
69
|
-
const
|
|
40
|
+
const { __scopeAlertDialog, ...portalProps } = props;
|
|
70
41
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
71
|
-
return /* @__PURE__ */ React.createElement(DialogPortal,
|
|
42
|
+
return /* @__PURE__ */ React.createElement(DialogPortal, {
|
|
43
|
+
...dialogScope,
|
|
44
|
+
...portalProps
|
|
45
|
+
});
|
|
72
46
|
};
|
|
73
47
|
AlertDialogPortal.displayName = PORTAL_NAME;
|
|
74
48
|
const OVERLAY_NAME = "AlertDialogOverlay";
|
|
75
49
|
const AlertDialogOverlay = React.forwardRef((props, forwardedRef) => {
|
|
76
|
-
const
|
|
50
|
+
const { __scopeAlertDialog, ...overlayProps } = props;
|
|
77
51
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
78
|
-
return /* @__PURE__ */ React.createElement(DialogOverlay,
|
|
52
|
+
return /* @__PURE__ */ React.createElement(DialogOverlay, {
|
|
53
|
+
...dialogScope,
|
|
54
|
+
...overlayProps,
|
|
79
55
|
ref: forwardedRef
|
|
80
|
-
})
|
|
56
|
+
});
|
|
81
57
|
});
|
|
82
58
|
AlertDialogOverlay.displayName = OVERLAY_NAME;
|
|
83
59
|
const CONTENT_NAME = "AlertDialogContent";
|
|
84
60
|
const [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME);
|
|
85
61
|
const AlertDialogContent = React.forwardRef((props, forwardedRef) => {
|
|
86
|
-
const
|
|
62
|
+
const { __scopeAlertDialog, children, ...contentProps } = props;
|
|
87
63
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
88
64
|
const contentRef = React.useRef(null);
|
|
89
65
|
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
@@ -95,60 +71,69 @@ const AlertDialogContent = React.forwardRef((props, forwardedRef) => {
|
|
|
95
71
|
}, /* @__PURE__ */ React.createElement(AlertDialogContentProvider, {
|
|
96
72
|
scope: __scopeAlertDialog,
|
|
97
73
|
cancelRef
|
|
98
|
-
}, /* @__PURE__ */ React.createElement(DialogContent,
|
|
99
|
-
role: "alertdialog"
|
|
100
|
-
|
|
74
|
+
}, /* @__PURE__ */ React.createElement(DialogContent, {
|
|
75
|
+
role: "alertdialog",
|
|
76
|
+
...dialogScope,
|
|
77
|
+
...contentProps,
|
|
101
78
|
ref: composedRefs,
|
|
102
79
|
onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {
|
|
103
|
-
var
|
|
80
|
+
var _a;
|
|
104
81
|
event.preventDefault();
|
|
105
82
|
if (isWeb) {
|
|
106
|
-
(
|
|
83
|
+
(_a = cancelRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
107
84
|
}
|
|
108
85
|
}),
|
|
109
86
|
onPointerDownOutside: (event) => event.preventDefault(),
|
|
110
87
|
onInteractOutside: (event) => event.preventDefault()
|
|
111
|
-
}
|
|
88
|
+
}, /* @__PURE__ */ React.createElement(Slottable, null, children), process.env.NODE_ENV === "development" && /* @__PURE__ */ React.createElement(DescriptionWarning, {
|
|
112
89
|
contentRef
|
|
113
90
|
}))));
|
|
114
91
|
});
|
|
115
92
|
AlertDialogContent.displayName = CONTENT_NAME;
|
|
116
93
|
const TITLE_NAME = "AlertDialogTitle";
|
|
117
94
|
const AlertDialogTitle = React.forwardRef((props, forwardedRef) => {
|
|
118
|
-
const
|
|
95
|
+
const { __scopeAlertDialog, ...titleProps } = props;
|
|
119
96
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
120
|
-
return /* @__PURE__ */ React.createElement(DialogTitle,
|
|
97
|
+
return /* @__PURE__ */ React.createElement(DialogTitle, {
|
|
98
|
+
...dialogScope,
|
|
99
|
+
...titleProps,
|
|
121
100
|
ref: forwardedRef
|
|
122
|
-
})
|
|
101
|
+
});
|
|
123
102
|
});
|
|
124
103
|
AlertDialogTitle.displayName = TITLE_NAME;
|
|
125
104
|
const DESCRIPTION_NAME = "AlertDialogDescription";
|
|
126
105
|
const AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
|
|
127
|
-
const
|
|
106
|
+
const { __scopeAlertDialog, ...descriptionProps } = props;
|
|
128
107
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
129
|
-
return /* @__PURE__ */ React.createElement(DialogDescription,
|
|
108
|
+
return /* @__PURE__ */ React.createElement(DialogDescription, {
|
|
109
|
+
...dialogScope,
|
|
110
|
+
...descriptionProps,
|
|
130
111
|
ref: forwardedRef
|
|
131
|
-
})
|
|
112
|
+
});
|
|
132
113
|
});
|
|
133
114
|
AlertDialogDescription.displayName = DESCRIPTION_NAME;
|
|
134
115
|
const ACTION_NAME = "AlertDialogAction";
|
|
135
116
|
const AlertDialogAction = React.forwardRef((props, forwardedRef) => {
|
|
136
|
-
const
|
|
117
|
+
const { __scopeAlertDialog, ...actionProps } = props;
|
|
137
118
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
138
|
-
return /* @__PURE__ */ React.createElement(DialogClose,
|
|
119
|
+
return /* @__PURE__ */ React.createElement(DialogClose, {
|
|
120
|
+
...dialogScope,
|
|
121
|
+
...actionProps,
|
|
139
122
|
ref: forwardedRef
|
|
140
|
-
})
|
|
123
|
+
});
|
|
141
124
|
});
|
|
142
125
|
AlertDialogAction.displayName = ACTION_NAME;
|
|
143
126
|
const CANCEL_NAME = "AlertDialogCancel";
|
|
144
127
|
const AlertDialogCancel = React.forwardRef((props, forwardedRef) => {
|
|
145
|
-
const
|
|
128
|
+
const { __scopeAlertDialog, ...cancelProps } = props;
|
|
146
129
|
const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
|
|
147
130
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
148
131
|
const ref = useComposedRefs(forwardedRef, cancelRef);
|
|
149
|
-
return /* @__PURE__ */ React.createElement(DialogClose,
|
|
132
|
+
return /* @__PURE__ */ React.createElement(DialogClose, {
|
|
133
|
+
...dialogScope,
|
|
134
|
+
...cancelProps,
|
|
150
135
|
ref
|
|
151
|
-
})
|
|
136
|
+
});
|
|
152
137
|
});
|
|
153
138
|
AlertDialogCancel.displayName = CANCEL_NAME;
|
|
154
139
|
const DescriptionWarning = ({ contentRef }) => {
|
|
@@ -170,11 +155,13 @@ For more information, see https://tamagui.dev/docs/components/alert-dialog`;
|
|
|
170
155
|
return null;
|
|
171
156
|
};
|
|
172
157
|
const AlertDialogInner = (props) => {
|
|
173
|
-
const
|
|
158
|
+
const { __scopeAlertDialog, ...alertDialogProps } = props;
|
|
174
159
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
175
|
-
return /* @__PURE__ */ React.createElement(Dialog,
|
|
160
|
+
return /* @__PURE__ */ React.createElement(Dialog, {
|
|
161
|
+
...dialogScope,
|
|
162
|
+
...alertDialogProps,
|
|
176
163
|
modal: true
|
|
177
|
-
})
|
|
164
|
+
});
|
|
178
165
|
};
|
|
179
166
|
const AlertDialog = withStaticProperties(AlertDialogInner, {
|
|
180
167
|
Trigger: AlertDialogTrigger,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AlertDialog.tsx"],
|
|
4
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 isWeb,\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 * as React from 'react'\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\ninterface AlertDialogProps extends Omit<DialogProps, 'modal'> {}\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialogTrigger\n * -----------------------------------------------------------------------------------------------*/\nconst TRIGGER_NAME = 'AlertDialogTrigger'\n\ninterface AlertDialogTriggerProps extends DialogTriggerProps {}\n\nconst AlertDialogTrigger = React.forwardRef<TamaguiElement, AlertDialogTriggerProps>(\n (props: ScopedProps<AlertDialogTriggerProps>, forwardedRef) => {\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(contentProps.onOpenAutoFocus, (event) => {\n event.preventDefault()\n if (isWeb) {\n // @ts-ignore\n cancelRef.current?.focus({ preventScroll: true })\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<TamaguiElement, 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)\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 const MESSAGE = `\\`${CONTENT_NAME}\\` requires a description for the component to be accessible for screen reader users.\n\nYou 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\nAlternatively, 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\nFor more information, see https://tamagui.dev/docs/components/alert-dialog`\n\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) console.warn(MESSAGE)\n }, [MESSAGE, contentRef])\n\n return null\n}\n\n/* -------------------------------------------------------------------------------------------------\n * AlertDialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst AlertDialogInner: React.FC<AlertDialogProps> = (props: ScopedProps<AlertDialogProps>) => {\n const { __scopeAlertDialog, ...alertDialogProps } = props\n const dialogScope = useDialogScope(__scopeAlertDialog)\n return <Dialog {...dialogScope} {...alertDialogProps} modal={true} />\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": "
|
|
5
|
+
"mappings": "AAGA;A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T,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AACf,CAAC;AAED,YAAY,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/alert-dialog",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.111",
|
|
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.0.1-beta.
|
|
25
|
-
"@tamagui/aria-hidden": "^1.0.1-beta.
|
|
26
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
27
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
28
|
-
"@tamagui/create-context": "^1.0.1-beta.
|
|
29
|
-
"@tamagui/dialog": "^1.0.1-beta.
|
|
30
|
-
"@tamagui/dismissable": "^1.0.1-beta.
|
|
31
|
-
"@tamagui/focus-scope": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/polyfill-dev": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/popper": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/portal": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/remove-scroll": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/stacks": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/text": "^1.0.1-beta.
|
|
38
|
-
"@tamagui/use-controllable-state": "^1.0.1-beta.
|
|
24
|
+
"@tamagui/animate-presence": "^1.0.1-beta.111",
|
|
25
|
+
"@tamagui/aria-hidden": "^1.0.1-beta.111",
|
|
26
|
+
"@tamagui/compose-refs": "^1.0.1-beta.111",
|
|
27
|
+
"@tamagui/core": "^1.0.1-beta.111",
|
|
28
|
+
"@tamagui/create-context": "^1.0.1-beta.111",
|
|
29
|
+
"@tamagui/dialog": "^1.0.1-beta.111",
|
|
30
|
+
"@tamagui/dismissable": "^1.0.1-beta.111",
|
|
31
|
+
"@tamagui/focus-scope": "^1.0.1-beta.111",
|
|
32
|
+
"@tamagui/polyfill-dev": "^1.0.1-beta.111",
|
|
33
|
+
"@tamagui/popper": "^1.0.1-beta.111",
|
|
34
|
+
"@tamagui/portal": "^1.0.1-beta.111",
|
|
35
|
+
"@tamagui/remove-scroll": "^1.0.1-beta.111",
|
|
36
|
+
"@tamagui/stacks": "^1.0.1-beta.111",
|
|
37
|
+
"@tamagui/text": "^1.0.1-beta.111",
|
|
38
|
+
"@tamagui/use-controllable-state": "^1.0.1-beta.111"
|
|
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.0.1-beta.
|
|
46
|
+
"@tamagui/build": "^1.0.1-beta.111",
|
|
47
47
|
"@types/react-dom": "^18.0.3",
|
|
48
48
|
"@types/react-native": "^0.69.2",
|
|
49
49
|
"react": "*",
|