@tamagui/alert-dialog 1.88.13 → 1.89.0-1706308641099

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,211 @@
1
+ import { useComposedRefs } from "@tamagui/compose-refs";
2
+ import { isWeb } from "@tamagui/constants";
3
+ import { Slottable, View, styled } from "@tamagui/core";
4
+ import { createContextScope } from "@tamagui/create-context";
5
+ import { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider, createDialogScope } from "@tamagui/dialog";
6
+ import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
7
+ import * as React from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ const ROOT_NAME = "AlertDialog",
10
+ [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [createDialogScope]),
11
+ useDialogScope = createDialogScope(),
12
+ TRIGGER_NAME = "AlertDialogTrigger",
13
+ NativeAlertDialogTriggerFrame = styled(View, {
14
+ name: TRIGGER_NAME
15
+ }),
16
+ AlertDialogTrigger = React.forwardRef((props, forwardedRef) => {
17
+ if (props.__native) {
18
+ const {
19
+ __native,
20
+ onPress,
21
+ __onPress,
22
+ ...rest
23
+ } = props;
24
+ return /* @__PURE__ */jsx(NativeAlertDialogTriggerFrame, {
25
+ ...rest,
26
+ onPress: composeEventHandlers(onPress, __onPress)
27
+ });
28
+ }
29
+ const {
30
+ __scopeAlertDialog,
31
+ ...triggerProps
32
+ } = props,
33
+ dialogScope = useDialogScope(__scopeAlertDialog);
34
+ return /* @__PURE__ */jsx(DialogTrigger, {
35
+ ...dialogScope,
36
+ ...triggerProps,
37
+ ref: forwardedRef
38
+ });
39
+ });
40
+ AlertDialogTrigger.displayName = TRIGGER_NAME;
41
+ const PORTAL_NAME = "AlertDialogPortal",
42
+ AlertDialogPortal = props => {
43
+ const {
44
+ __scopeAlertDialog,
45
+ ...portalProps
46
+ } = props,
47
+ dialogScope = useDialogScope(__scopeAlertDialog);
48
+ return /* @__PURE__ */jsx(DialogPortal, {
49
+ ...dialogScope,
50
+ ...portalProps
51
+ });
52
+ };
53
+ AlertDialogPortal.displayName = PORTAL_NAME;
54
+ const OVERLAY_NAME = "AlertDialogOverlay",
55
+ AlertDialogOverlayFrame = styled(DialogOverlayFrame, {
56
+ name: OVERLAY_NAME
57
+ }),
58
+ AlertDialogOverlay = AlertDialogOverlayFrame.extractable(React.forwardRef((props, forwardedRef) => {
59
+ const {
60
+ __scopeAlertDialog,
61
+ ...overlayProps
62
+ } = props,
63
+ dialogScope = useDialogScope(__scopeAlertDialog);
64
+ return /* @__PURE__ */jsx(DialogOverlay, {
65
+ ...dialogScope,
66
+ ...overlayProps,
67
+ ref: forwardedRef
68
+ });
69
+ }));
70
+ AlertDialogOverlay.displayName = OVERLAY_NAME;
71
+ const CONTENT_NAME = "AlertDialogContent",
72
+ [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME),
73
+ AlertDialogContent = React.forwardRef((props, forwardedRef) => {
74
+ const {
75
+ __scopeAlertDialog,
76
+ children,
77
+ ...contentProps
78
+ } = props,
79
+ dialogScope = useDialogScope(__scopeAlertDialog),
80
+ contentRef = React.useRef(null),
81
+ composedRefs = useComposedRefs(forwardedRef, contentRef),
82
+ cancelRef = React.useRef(null);
83
+ return /* @__PURE__ */jsx(DialogWarningProvider, {
84
+ contentName: CONTENT_NAME,
85
+ titleName: TITLE_NAME,
86
+ docsSlug: "alert-dialog",
87
+ children: /* @__PURE__ */jsx(AlertDialogContentProvider, {
88
+ scope: __scopeAlertDialog,
89
+ cancelRef,
90
+ children: /* @__PURE__ */jsxs(DialogContent, {
91
+ role: "alertdialog",
92
+ ...dialogScope,
93
+ ...contentProps,
94
+ ref: composedRefs,
95
+ onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, event => {
96
+ event.preventDefault(), isWeb && cancelRef.current?.focus({
97
+ preventScroll: !0
98
+ });
99
+ }),
100
+ onPointerDownOutside: event => event.preventDefault(),
101
+ onInteractOutside: event => event.preventDefault(),
102
+ children: [/* @__PURE__ */jsx(Slottable, {
103
+ children
104
+ }), process.env.NODE_ENV === "development" && /* @__PURE__ */jsx(DescriptionWarning, {
105
+ contentRef
106
+ })]
107
+ })
108
+ })
109
+ });
110
+ });
111
+ AlertDialogContent.displayName = CONTENT_NAME;
112
+ const TITLE_NAME = "AlertDialogTitle",
113
+ AlertDialogTitle = React.forwardRef((props, forwardedRef) => {
114
+ const {
115
+ __scopeAlertDialog,
116
+ ...titleProps
117
+ } = props,
118
+ dialogScope = useDialogScope(__scopeAlertDialog);
119
+ return /* @__PURE__ */jsx(DialogTitle, {
120
+ ...dialogScope,
121
+ ...titleProps,
122
+ ref: forwardedRef
123
+ });
124
+ });
125
+ AlertDialogTitle.displayName = TITLE_NAME;
126
+ const DESCRIPTION_NAME = "AlertDialogDescription",
127
+ AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
128
+ const {
129
+ __scopeAlertDialog,
130
+ ...descriptionProps
131
+ } = props,
132
+ dialogScope = useDialogScope(__scopeAlertDialog);
133
+ return /* @__PURE__ */jsx(DialogDescription, {
134
+ ...dialogScope,
135
+ ...descriptionProps,
136
+ ref: forwardedRef
137
+ });
138
+ });
139
+ AlertDialogDescription.displayName = DESCRIPTION_NAME;
140
+ const ACTION_NAME = "AlertDialogAction",
141
+ AlertDialogAction = React.forwardRef((props, forwardedRef) => {
142
+ const {
143
+ __scopeAlertDialog,
144
+ ...actionProps
145
+ } = props,
146
+ dialogScope = useDialogScope(__scopeAlertDialog);
147
+ return /* @__PURE__ */jsx(DialogClose, {
148
+ ...dialogScope,
149
+ ...actionProps,
150
+ ref: forwardedRef
151
+ });
152
+ });
153
+ AlertDialogAction.displayName = ACTION_NAME;
154
+ const CANCEL_NAME = "AlertDialogCancel",
155
+ AlertDialogCancel = React.forwardRef((props, forwardedRef) => {
156
+ const {
157
+ __scopeAlertDialog,
158
+ ...cancelProps
159
+ } = props,
160
+ {
161
+ cancelRef
162
+ } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog),
163
+ dialogScope = useDialogScope(__scopeAlertDialog),
164
+ ref = useComposedRefs(forwardedRef, cancelRef);
165
+ return /* @__PURE__ */jsx(DialogClose, {
166
+ ...dialogScope,
167
+ ...cancelProps,
168
+ ref
169
+ });
170
+ });
171
+ AlertDialogCancel.displayName = CANCEL_NAME;
172
+ const DescriptionWarning = ({
173
+ contentRef
174
+ }) => (process.env.NODE_ENV === "development" && React.useEffect(() => {
175
+ if (!isWeb) return;
176
+ document.getElementById(
177
+ // @ts-ignore
178
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
179
+ contentRef.current?.getAttribute("aria-describedby")) || console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
180
+
181
+ 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.
182
+
183
+ 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.
184
+
185
+ For more information, see https://tamagui.dev/docs/components/alert-dialog`);
186
+ }, [contentRef]), null),
187
+ AlertDialogInner = props => {
188
+ const {
189
+ __scopeAlertDialog,
190
+ native,
191
+ ...alertDialogProps
192
+ } = props,
193
+ dialogScope = useDialogScope(__scopeAlertDialog);
194
+ return /* @__PURE__ */jsx(Dialog, {
195
+ ...dialogScope,
196
+ ...alertDialogProps,
197
+ modal: !0
198
+ });
199
+ };
200
+ const AlertDialog = withStaticProperties(AlertDialogInner, {
201
+ Trigger: AlertDialogTrigger,
202
+ Portal: AlertDialogPortal,
203
+ Overlay: AlertDialogOverlay,
204
+ Content: AlertDialogContent,
205
+ Action: AlertDialogAction,
206
+ Cancel: AlertDialogCancel,
207
+ Title: AlertDialogTitle,
208
+ Description: AlertDialogDescription
209
+ });
210
+ AlertDialog.displayName = ROOT_NAME;
211
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, createAlertDialogScope };
@@ -0,0 +1 @@
1
+ export * from "./AlertDialog.mjs";
@@ -0,0 +1,211 @@
1
+ import { useComposedRefs } from "@tamagui/compose-refs";
2
+ import { isWeb } from "@tamagui/constants";
3
+ import { Slottable, View, styled } from "@tamagui/core";
4
+ import { createContextScope } from "@tamagui/create-context";
5
+ import { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogOverlayFrame, DialogPortal, DialogTitle, DialogTrigger, DialogWarningProvider, createDialogScope } from "@tamagui/dialog";
6
+ import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
7
+ import * as React from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ const ROOT_NAME = "AlertDialog",
10
+ [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [createDialogScope]),
11
+ useDialogScope = createDialogScope(),
12
+ TRIGGER_NAME = "AlertDialogTrigger",
13
+ NativeAlertDialogTriggerFrame = styled(View, {
14
+ name: TRIGGER_NAME
15
+ }),
16
+ AlertDialogTrigger = React.forwardRef((props, forwardedRef) => {
17
+ if (props.__native) {
18
+ const {
19
+ __native,
20
+ onPress,
21
+ __onPress,
22
+ ...rest
23
+ } = props;
24
+ return /* @__PURE__ */jsx(NativeAlertDialogTriggerFrame, {
25
+ ...rest,
26
+ onPress: composeEventHandlers(onPress, __onPress)
27
+ });
28
+ }
29
+ const {
30
+ __scopeAlertDialog,
31
+ ...triggerProps
32
+ } = props,
33
+ dialogScope = useDialogScope(__scopeAlertDialog);
34
+ return /* @__PURE__ */jsx(DialogTrigger, {
35
+ ...dialogScope,
36
+ ...triggerProps,
37
+ ref: forwardedRef
38
+ });
39
+ });
40
+ AlertDialogTrigger.displayName = TRIGGER_NAME;
41
+ const PORTAL_NAME = "AlertDialogPortal",
42
+ AlertDialogPortal = props => {
43
+ const {
44
+ __scopeAlertDialog,
45
+ ...portalProps
46
+ } = props,
47
+ dialogScope = useDialogScope(__scopeAlertDialog);
48
+ return /* @__PURE__ */jsx(DialogPortal, {
49
+ ...dialogScope,
50
+ ...portalProps
51
+ });
52
+ };
53
+ AlertDialogPortal.displayName = PORTAL_NAME;
54
+ const OVERLAY_NAME = "AlertDialogOverlay",
55
+ AlertDialogOverlayFrame = styled(DialogOverlayFrame, {
56
+ name: OVERLAY_NAME
57
+ }),
58
+ AlertDialogOverlay = AlertDialogOverlayFrame.extractable(React.forwardRef((props, forwardedRef) => {
59
+ const {
60
+ __scopeAlertDialog,
61
+ ...overlayProps
62
+ } = props,
63
+ dialogScope = useDialogScope(__scopeAlertDialog);
64
+ return /* @__PURE__ */jsx(DialogOverlay, {
65
+ ...dialogScope,
66
+ ...overlayProps,
67
+ ref: forwardedRef
68
+ });
69
+ }));
70
+ AlertDialogOverlay.displayName = OVERLAY_NAME;
71
+ const CONTENT_NAME = "AlertDialogContent",
72
+ [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME),
73
+ AlertDialogContent = React.forwardRef((props, forwardedRef) => {
74
+ const {
75
+ __scopeAlertDialog,
76
+ children,
77
+ ...contentProps
78
+ } = props,
79
+ dialogScope = useDialogScope(__scopeAlertDialog),
80
+ contentRef = React.useRef(null),
81
+ composedRefs = useComposedRefs(forwardedRef, contentRef),
82
+ cancelRef = React.useRef(null);
83
+ return /* @__PURE__ */jsx(DialogWarningProvider, {
84
+ contentName: CONTENT_NAME,
85
+ titleName: TITLE_NAME,
86
+ docsSlug: "alert-dialog",
87
+ children: /* @__PURE__ */jsx(AlertDialogContentProvider, {
88
+ scope: __scopeAlertDialog,
89
+ cancelRef,
90
+ children: /* @__PURE__ */jsxs(DialogContent, {
91
+ role: "alertdialog",
92
+ ...dialogScope,
93
+ ...contentProps,
94
+ ref: composedRefs,
95
+ onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, event => {
96
+ event.preventDefault(), isWeb && cancelRef.current?.focus({
97
+ preventScroll: !0
98
+ });
99
+ }),
100
+ onPointerDownOutside: event => event.preventDefault(),
101
+ onInteractOutside: event => event.preventDefault(),
102
+ children: [/* @__PURE__ */jsx(Slottable, {
103
+ children
104
+ }), process.env.NODE_ENV === "development" && /* @__PURE__ */jsx(DescriptionWarning, {
105
+ contentRef
106
+ })]
107
+ })
108
+ })
109
+ });
110
+ });
111
+ AlertDialogContent.displayName = CONTENT_NAME;
112
+ const TITLE_NAME = "AlertDialogTitle",
113
+ AlertDialogTitle = React.forwardRef((props, forwardedRef) => {
114
+ const {
115
+ __scopeAlertDialog,
116
+ ...titleProps
117
+ } = props,
118
+ dialogScope = useDialogScope(__scopeAlertDialog);
119
+ return /* @__PURE__ */jsx(DialogTitle, {
120
+ ...dialogScope,
121
+ ...titleProps,
122
+ ref: forwardedRef
123
+ });
124
+ });
125
+ AlertDialogTitle.displayName = TITLE_NAME;
126
+ const DESCRIPTION_NAME = "AlertDialogDescription",
127
+ AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
128
+ const {
129
+ __scopeAlertDialog,
130
+ ...descriptionProps
131
+ } = props,
132
+ dialogScope = useDialogScope(__scopeAlertDialog);
133
+ return /* @__PURE__ */jsx(DialogDescription, {
134
+ ...dialogScope,
135
+ ...descriptionProps,
136
+ ref: forwardedRef
137
+ });
138
+ });
139
+ AlertDialogDescription.displayName = DESCRIPTION_NAME;
140
+ const ACTION_NAME = "AlertDialogAction",
141
+ AlertDialogAction = React.forwardRef((props, forwardedRef) => {
142
+ const {
143
+ __scopeAlertDialog,
144
+ ...actionProps
145
+ } = props,
146
+ dialogScope = useDialogScope(__scopeAlertDialog);
147
+ return /* @__PURE__ */jsx(DialogClose, {
148
+ ...dialogScope,
149
+ ...actionProps,
150
+ ref: forwardedRef
151
+ });
152
+ });
153
+ AlertDialogAction.displayName = ACTION_NAME;
154
+ const CANCEL_NAME = "AlertDialogCancel",
155
+ AlertDialogCancel = React.forwardRef((props, forwardedRef) => {
156
+ const {
157
+ __scopeAlertDialog,
158
+ ...cancelProps
159
+ } = props,
160
+ {
161
+ cancelRef
162
+ } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog),
163
+ dialogScope = useDialogScope(__scopeAlertDialog),
164
+ ref = useComposedRefs(forwardedRef, cancelRef);
165
+ return /* @__PURE__ */jsx(DialogClose, {
166
+ ...dialogScope,
167
+ ...cancelProps,
168
+ ref
169
+ });
170
+ });
171
+ AlertDialogCancel.displayName = CANCEL_NAME;
172
+ const DescriptionWarning = ({
173
+ contentRef
174
+ }) => (process.env.NODE_ENV === "development" && React.useEffect(() => {
175
+ if (!isWeb) return;
176
+ document.getElementById(
177
+ // @ts-ignore
178
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
179
+ contentRef.current?.getAttribute("aria-describedby")) || console.warn(`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
180
+
181
+ 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.
182
+
183
+ 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.
184
+
185
+ For more information, see https://tamagui.dev/docs/components/alert-dialog`);
186
+ }, [contentRef]), null),
187
+ AlertDialogInner = props => {
188
+ const {
189
+ __scopeAlertDialog,
190
+ native,
191
+ ...alertDialogProps
192
+ } = props,
193
+ dialogScope = useDialogScope(__scopeAlertDialog);
194
+ return /* @__PURE__ */jsx(Dialog, {
195
+ ...dialogScope,
196
+ ...alertDialogProps,
197
+ modal: !0
198
+ });
199
+ };
200
+ const AlertDialog = withStaticProperties(AlertDialogInner, {
201
+ Trigger: AlertDialogTrigger,
202
+ Portal: AlertDialogPortal,
203
+ Overlay: AlertDialogOverlay,
204
+ Content: AlertDialogContent,
205
+ Action: AlertDialogAction,
206
+ Cancel: AlertDialogCancel,
207
+ Title: AlertDialogTitle,
208
+ Description: AlertDialogDescription
209
+ });
210
+ AlertDialog.displayName = ROOT_NAME;
211
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, createAlertDialogScope };
@@ -0,0 +1 @@
1
+ export * from "./AlertDialog.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/alert-dialog",
3
- "version": "1.88.13",
3
+ "version": "1.89.0-1706308641099",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -33,30 +33,30 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@tamagui/animate-presence": "1.88.13",
37
- "@tamagui/aria-hidden": "1.88.13",
38
- "@tamagui/compose-refs": "1.88.13",
39
- "@tamagui/constants": "1.88.13",
40
- "@tamagui/core": "1.88.13",
41
- "@tamagui/create-context": "1.88.13",
42
- "@tamagui/dialog": "1.88.13",
43
- "@tamagui/dismissable": "1.88.13",
44
- "@tamagui/focus-scope": "1.88.13",
45
- "@tamagui/helpers": "1.88.13",
46
- "@tamagui/polyfill-dev": "1.88.13",
47
- "@tamagui/popper": "1.88.13",
48
- "@tamagui/portal": "1.88.13",
49
- "@tamagui/remove-scroll": "1.88.13",
50
- "@tamagui/stacks": "1.88.13",
51
- "@tamagui/text": "1.88.13",
52
- "@tamagui/use-controllable-state": "1.88.13"
36
+ "@tamagui/animate-presence": "1.89.0-1706308641099",
37
+ "@tamagui/aria-hidden": "1.89.0-1706308641099",
38
+ "@tamagui/compose-refs": "1.89.0-1706308641099",
39
+ "@tamagui/constants": "1.89.0-1706308641099",
40
+ "@tamagui/core": "1.89.0-1706308641099",
41
+ "@tamagui/create-context": "1.89.0-1706308641099",
42
+ "@tamagui/dialog": "1.89.0-1706308641099",
43
+ "@tamagui/dismissable": "1.89.0-1706308641099",
44
+ "@tamagui/focus-scope": "1.89.0-1706308641099",
45
+ "@tamagui/helpers": "1.89.0-1706308641099",
46
+ "@tamagui/polyfill-dev": "1.89.0-1706308641099",
47
+ "@tamagui/popper": "1.89.0-1706308641099",
48
+ "@tamagui/portal": "1.89.0-1706308641099",
49
+ "@tamagui/remove-scroll": "1.89.0-1706308641099",
50
+ "@tamagui/stacks": "1.89.0-1706308641099",
51
+ "@tamagui/text": "1.89.0-1706308641099",
52
+ "@tamagui/use-controllable-state": "1.89.0-1706308641099"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "react": "*",
56
56
  "react-native": "*"
57
57
  },
58
58
  "devDependencies": {
59
- "@tamagui/build": "1.88.13",
59
+ "@tamagui/build": "1.89.0-1706308641099",
60
60
  "react": "^18.2.0",
61
61
  "react-native": "^0.72.6"
62
62
  },