@arc-ui/components 11.24.2 → 11.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/Button/Button.cjs.js +1 -1
  2. package/dist/Button/Button.esm.js +1 -1
  3. package/dist/DatePicker/DatePicker.cjs.js +1276 -22
  4. package/dist/DatePicker/DatePicker.esm.js +1245 -10
  5. package/dist/InformationCard/InformationCard.cjs.js +1 -1
  6. package/dist/InformationCard/InformationCard.esm.js +1 -1
  7. package/dist/Modal/Modal.cjs.js +438 -225
  8. package/dist/Modal/Modal.esm.js +420 -225
  9. package/dist/PaginationSimple/PaginationSimple.cjs.js +23 -2
  10. package/dist/PaginationSimple/PaginationSimple.esm.js +23 -2
  11. package/dist/Select/Select.cjs.js +1514 -1065
  12. package/dist/Select/Select.esm.js +1496 -1066
  13. package/dist/SiteHeader/SiteHeader.cjs.js +2 -2
  14. package/dist/SiteHeader/SiteHeader.esm.js +2 -2
  15. package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +2 -2
  16. package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +2 -2
  17. package/dist/Tabs/Tabs.cjs.js +4 -6
  18. package/dist/Tabs/Tabs.esm.js +4 -6
  19. package/dist/TextArea/TextArea.cjs.js +10 -13
  20. package/dist/TextArea/TextArea.esm.js +10 -13
  21. package/dist/Toast/Toast.cjs.js +4 -6
  22. package/dist/Toast/Toast.esm.js +4 -6
  23. package/dist/UniversalHeader/UniversalHeader.cjs.js +2 -2
  24. package/dist/UniversalHeader/UniversalHeader.esm.js +2 -2
  25. package/dist/_shared/cjs/{Button-6ba21d3b.js → Button-5b28f0ce.js} +3 -3
  26. package/dist/_shared/cjs/{SiteHeader.rehydrator-9d8f3dad.js → SiteHeader.rehydrator-8fa9d174.js} +1 -1
  27. package/dist/_shared/cjs/{SiteHeaderV2-ce1c8737.js → SiteHeaderV2-ca2f13a8.js} +1 -1
  28. package/dist/_shared/cjs/{Tabs-bc9fac46.js → Tabs-89455281.js} +19 -15
  29. package/dist/_shared/cjs/{Toast-26207fef.js → Toast-c760c89d.js} +32 -14
  30. package/dist/_shared/cjs/{UniversalHeader-b8389447.js → UniversalHeader-73e154eb.js} +6 -2
  31. package/dist/_shared/cjs/component-4979b2e7.js +409 -0
  32. package/dist/_shared/cjs/{index-77ab5c6a.js → floating-ui.react-dom-08b8b87c.js} +12 -284
  33. package/dist/_shared/cjs/index-1efbba95.js +1252 -0
  34. package/dist/_shared/cjs/{index-74004a9c.js → index-4edec793.js} +1 -1
  35. package/dist/_shared/cjs/{index-dd1d18ea.js → index-7641213c.js} +127 -2
  36. package/dist/_shared/cjs/{index-9f99d686.js → index-af744fa9.js} +1 -1
  37. package/dist/_shared/cjs/{index-6eb396a3.js → index-fb0cad18.js} +1 -1
  38. package/dist/_shared/esm/{Button-a7d134c6.js → Button-5b48b7ce.js} +3 -3
  39. package/dist/_shared/esm/{SiteHeader.rehydrator-2ec02ee7.js → SiteHeader.rehydrator-8f3c5d6e.js} +1 -1
  40. package/dist/_shared/esm/{SiteHeaderV2-a7c1b1cb.js → SiteHeaderV2-cb081752.js} +1 -1
  41. package/dist/_shared/esm/{Tabs-9485cab6.js → Tabs-959e885d.js} +10 -6
  42. package/dist/_shared/esm/{Toast-fcbfc194.js → Toast-a590067d.js} +25 -7
  43. package/dist/_shared/esm/{UniversalHeader-80c7313f.js → UniversalHeader-96bfbacc.js} +6 -2
  44. package/dist/_shared/esm/component-d7b471ff.js +382 -0
  45. package/dist/_shared/esm/{index-b84a20c6.js → floating-ui.react-dom-1bb71aae.js} +4 -281
  46. package/dist/_shared/esm/{index-7b531fa7.js → index-0ae23b06.js} +126 -2
  47. package/dist/_shared/esm/index-307f1bbc.js +1212 -0
  48. package/dist/_shared/esm/{index-044da8d0.js → index-9e54cc7d.js} +1 -1
  49. package/dist/_shared/esm/{index-efa9be1a.js → index-af7b6e55.js} +1 -1
  50. package/dist/_shared/esm/{index-2cfab9f2.js → index-ebe72f34.js} +1 -1
  51. package/dist/index.es.js +3608 -2938
  52. package/dist/index.es.js.map +1 -1
  53. package/dist/index.js +3591 -2921
  54. package/dist/index.js.map +1 -1
  55. package/dist/styles.css +2 -2
  56. package/dist/types/components/Button/Button.d.ts +12 -0
  57. package/dist/types/components/PaginationSimple/PaginationSimple.d.ts +28 -0
  58. package/dist/types/components/UniversalHeader/UniversalHeader.d.ts +4 -0
  59. package/package.json +3 -3
  60. package/dist/_shared/cjs/Combination-9974f2e2.js +0 -1330
  61. package/dist/_shared/cjs/index-a31e64a9.js +0 -27
  62. package/dist/_shared/cjs/index-d38f1bd0.js +0 -131
  63. package/dist/_shared/cjs/index-dcfdd5da.js +0 -11
  64. package/dist/_shared/esm/Combination-e9f7e64e.js +0 -1301
  65. package/dist/_shared/esm/index-25a5b393.js +0 -25
  66. package/dist/_shared/esm/index-a624de47.js +0 -9
  67. package/dist/_shared/esm/index-ca72c9d5.js +0 -129
@@ -1,251 +1,446 @@
1
1
  import { _ as __rest, a as __assign, f as filterDataAttrs } from '../_shared/esm/filter-data-attrs-ea8f4ed4.js';
2
- import React__default, { useRef, createElement, useCallback, Children, forwardRef, useEffect, Fragment, useContext } from 'react';
2
+ import * as React from 'react';
3
+ import React__default, { useContext, useRef } from 'react';
3
4
  import { c as classNames } from '../_shared/esm/index-2e73c2e9.js';
4
5
  import { B as BtIconCrossAlt2Px } from '../_shared/esm/BtIconCrossAlt2Px.esm-7165ab1a.js';
5
- import { _ as _extends } from '../_shared/esm/extends-8cc61aad.js';
6
- import { $ as $c512c27ab02ef895$export$50c7b4e9d9f19c1, a as $71cd76cc60e0454e$export$6f32135080cb4c3, c as $5e63c961fc1ce211$export$8c6ed5c666ac1360, e as $8927f6f2acc4f386$export$250ffa63cdc0d034, b as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, d as $e42e1063c40fb3ef$export$b9ecd428b558ff10 } from '../_shared/esm/index-7b531fa7.js';
7
- import { $ as $1746a345f3d73bb7$export$f680877a34711e37 } from '../_shared/esm/index-efa9be1a.js';
8
- import { $ as $f1701beae083dbae$export$602eac185826482c, a as $01b9c$RemoveScroll, h as hideOthers, b as $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c, c as $d3863c46a17e8a28$export$20e40289641fbbb6, d as $5cb92bef7577960e$export$177fb62ff3ec1f22 } from '../_shared/esm/Combination-e9f7e64e.js';
9
- import { $ as $921a889cee6df7e8$export$99c2b779aa4e8b8b } from '../_shared/esm/index-ca72c9d5.js';
6
+ import { u as useComposedRefs, a as useLayoutEffect2, c as createContextScope, P as Primitive, b as composeEventHandlers, R as RemoveScroll, S as Slot, h as hideOthers, d as useFocusGuards, F as FocusScope, D as DismissableLayer, e as createContext2, f as useControllableState, g as useId, i as Portal$1 } from '../_shared/esm/index-307f1bbc.js';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
8
  import { I as Icon } from '../_shared/esm/Icon-15799695.js';
11
9
  import { A as ArcRootElementContext } from '../_shared/esm/Base-211ca3a4.js';
12
10
  import { H as Heading } from '../_shared/esm/Heading-d16e0e53.js';
13
- import { B as Button } from '../_shared/esm/Button-a7d134c6.js';
11
+ import { B as Button } from '../_shared/esm/Button-5b48b7ce.js';
14
12
  import { T as Text } from '../_shared/esm/Text-14f586ac.js';
15
13
  import { V as VerticalSpace } from '../_shared/esm/VerticalSpace-43cd9138.js';
16
14
  import 'react-dom';
17
- import '../_shared/esm/index-2cfab9f2.js';
15
+ import '../_shared/esm/component-d7b471ff.js';
18
16
  import '../_shared/esm/suffix-modifier-3d548e45.js';
19
17
  import '../_shared/esm/Surface-0ca6817d.js';
20
18
  import '../_shared/esm/BtIconChevronLeftMid.esm-1ed8330b.js';
21
19
  import '../_shared/esm/BtIconChevronRightMid.esm-32268f1a.js';
22
20
 
23
- /* -------------------------------------------------------------------------------------------------
24
- * Dialog
25
- * -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$DIALOG_NAME = 'Dialog';
26
- const [$5d3850c4d0b4e6c7$var$createDialogContext, $5d3850c4d0b4e6c7$export$cc702773b8ea3e41] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($5d3850c4d0b4e6c7$var$DIALOG_NAME);
27
- const [$5d3850c4d0b4e6c7$var$DialogProvider, $5d3850c4d0b4e6c7$var$useDialogContext] = $5d3850c4d0b4e6c7$var$createDialogContext($5d3850c4d0b4e6c7$var$DIALOG_NAME);
28
- const $5d3850c4d0b4e6c7$export$3ddf2d174ce01153 = (props)=>{
29
- const { __scopeDialog: __scopeDialog , children: children , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , modal: modal = true } = props;
30
- const triggerRef = useRef(null);
31
- const contentRef = useRef(null);
32
- const [open = false, setOpen] = $71cd76cc60e0454e$export$6f32135080cb4c3({
33
- prop: openProp,
34
- defaultProp: defaultOpen,
35
- onChange: onOpenChange
36
- });
37
- return /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$DialogProvider, {
38
- scope: __scopeDialog,
39
- triggerRef: triggerRef,
40
- contentRef: contentRef,
41
- contentId: $1746a345f3d73bb7$export$f680877a34711e37(),
42
- titleId: $1746a345f3d73bb7$export$f680877a34711e37(),
43
- descriptionId: $1746a345f3d73bb7$export$f680877a34711e37(),
44
- open: open,
45
- onOpenChange: setOpen,
46
- onOpenToggle: useCallback(()=>setOpen((prevOpen)=>!prevOpen
47
- )
48
- , [
49
- setOpen
50
- ]),
51
- modal: modal
52
- }, children);
21
+ function useStateMachine(initialState, machine) {
22
+ return React.useReducer((state, event) => {
23
+ const nextState = machine[state][event];
24
+ return nextState ?? state;
25
+ }, initialState);
26
+ }
27
+
28
+ // packages/react/presence/src/Presence.tsx
29
+ var Presence = (props) => {
30
+ const { present, children } = props;
31
+ const presence = usePresence(present);
32
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
33
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
34
+ const forceMount = typeof children === "function";
35
+ return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
53
36
  };
54
- /* -------------------------------------------------------------------------------------------------
55
- * DialogPortal
56
- * -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$PORTAL_NAME = 'DialogPortal';
57
- const [$5d3850c4d0b4e6c7$var$PortalProvider, $5d3850c4d0b4e6c7$var$usePortalContext] = $5d3850c4d0b4e6c7$var$createDialogContext($5d3850c4d0b4e6c7$var$PORTAL_NAME, {
58
- forceMount: undefined
59
- });
60
- const $5d3850c4d0b4e6c7$export$dad7c95542bacce0 = (props)=>{
61
- const { __scopeDialog: __scopeDialog , forceMount: forceMount , children: children , container: container } = props;
62
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$PORTAL_NAME, __scopeDialog);
63
- return /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$PortalProvider, {
64
- scope: __scopeDialog,
65
- forceMount: forceMount
66
- }, Children.map(children, (child)=>/*#__PURE__*/ createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
67
- present: forceMount || context.open
68
- }, /*#__PURE__*/ createElement($f1701beae083dbae$export$602eac185826482c, {
69
- asChild: true,
70
- container: container
71
- }, child))
72
- ));
37
+ Presence.displayName = "Presence";
38
+ function usePresence(present) {
39
+ const [node, setNode] = React.useState();
40
+ const stylesRef = React.useRef({});
41
+ const prevPresentRef = React.useRef(present);
42
+ const prevAnimationNameRef = React.useRef("none");
43
+ const initialState = present ? "mounted" : "unmounted";
44
+ const [state, send] = useStateMachine(initialState, {
45
+ mounted: {
46
+ UNMOUNT: "unmounted",
47
+ ANIMATION_OUT: "unmountSuspended"
48
+ },
49
+ unmountSuspended: {
50
+ MOUNT: "mounted",
51
+ ANIMATION_END: "unmounted"
52
+ },
53
+ unmounted: {
54
+ MOUNT: "mounted"
55
+ }
56
+ });
57
+ React.useEffect(() => {
58
+ const currentAnimationName = getAnimationName(stylesRef.current);
59
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
60
+ }, [state]);
61
+ useLayoutEffect2(() => {
62
+ const styles = stylesRef.current;
63
+ const wasPresent = prevPresentRef.current;
64
+ const hasPresentChanged = wasPresent !== present;
65
+ if (hasPresentChanged) {
66
+ const prevAnimationName = prevAnimationNameRef.current;
67
+ const currentAnimationName = getAnimationName(styles);
68
+ if (present) {
69
+ send("MOUNT");
70
+ } else if (currentAnimationName === "none" || styles?.display === "none") {
71
+ send("UNMOUNT");
72
+ } else {
73
+ const isAnimating = prevAnimationName !== currentAnimationName;
74
+ if (wasPresent && isAnimating) {
75
+ send("ANIMATION_OUT");
76
+ } else {
77
+ send("UNMOUNT");
78
+ }
79
+ }
80
+ prevPresentRef.current = present;
81
+ }
82
+ }, [present, send]);
83
+ useLayoutEffect2(() => {
84
+ if (node) {
85
+ let timeoutId;
86
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
87
+ const handleAnimationEnd = (event) => {
88
+ const currentAnimationName = getAnimationName(stylesRef.current);
89
+ const isCurrentAnimation = currentAnimationName.includes(event.animationName);
90
+ if (event.target === node && isCurrentAnimation) {
91
+ send("ANIMATION_END");
92
+ if (!prevPresentRef.current) {
93
+ const currentFillMode = node.style.animationFillMode;
94
+ node.style.animationFillMode = "forwards";
95
+ timeoutId = ownerWindow.setTimeout(() => {
96
+ if (node.style.animationFillMode === "forwards") {
97
+ node.style.animationFillMode = currentFillMode;
98
+ }
99
+ });
100
+ }
101
+ }
102
+ };
103
+ const handleAnimationStart = (event) => {
104
+ if (event.target === node) {
105
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
106
+ }
107
+ };
108
+ node.addEventListener("animationstart", handleAnimationStart);
109
+ node.addEventListener("animationcancel", handleAnimationEnd);
110
+ node.addEventListener("animationend", handleAnimationEnd);
111
+ return () => {
112
+ ownerWindow.clearTimeout(timeoutId);
113
+ node.removeEventListener("animationstart", handleAnimationStart);
114
+ node.removeEventListener("animationcancel", handleAnimationEnd);
115
+ node.removeEventListener("animationend", handleAnimationEnd);
116
+ };
117
+ } else {
118
+ send("ANIMATION_END");
119
+ }
120
+ }, [node, send]);
121
+ return {
122
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
123
+ ref: React.useCallback((node2) => {
124
+ if (node2) stylesRef.current = getComputedStyle(node2);
125
+ setNode(node2);
126
+ }, [])
127
+ };
128
+ }
129
+ function getAnimationName(styles) {
130
+ return styles?.animationName || "none";
131
+ }
132
+ function getElementRef(element) {
133
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
134
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
135
+ if (mayWarn) {
136
+ return element.ref;
137
+ }
138
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
139
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
140
+ if (mayWarn) {
141
+ return element.props.ref;
142
+ }
143
+ return element.props.ref || element.ref;
144
+ }
145
+
146
+ var DIALOG_NAME = "Dialog";
147
+ var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
148
+ var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
149
+ var Dialog = (props) => {
150
+ const {
151
+ __scopeDialog,
152
+ children,
153
+ open: openProp,
154
+ defaultOpen,
155
+ onOpenChange,
156
+ modal = true
157
+ } = props;
158
+ const triggerRef = React.useRef(null);
159
+ const contentRef = React.useRef(null);
160
+ const [open = false, setOpen] = useControllableState({
161
+ prop: openProp,
162
+ defaultProp: defaultOpen,
163
+ onChange: onOpenChange
164
+ });
165
+ return /* @__PURE__ */ jsx(
166
+ DialogProvider,
167
+ {
168
+ scope: __scopeDialog,
169
+ triggerRef,
170
+ contentRef,
171
+ contentId: useId(),
172
+ titleId: useId(),
173
+ descriptionId: useId(),
174
+ open,
175
+ onOpenChange: setOpen,
176
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
177
+ modal,
178
+ children
179
+ }
180
+ );
73
181
  };
74
- /* -------------------------------------------------------------------------------------------------
75
- * DialogOverlay
76
- * -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$OVERLAY_NAME = 'DialogOverlay';
77
- const $5d3850c4d0b4e6c7$export$bd1d06c79be19e17 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
78
- const portalContext = $5d3850c4d0b4e6c7$var$usePortalContext($5d3850c4d0b4e6c7$var$OVERLAY_NAME, props.__scopeDialog);
79
- const { forceMount: forceMount = portalContext.forceMount , ...overlayProps } = props;
80
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$OVERLAY_NAME, props.__scopeDialog);
81
- return context.modal ? /*#__PURE__*/ createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
82
- present: forceMount || context.open
83
- }, /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$DialogOverlayImpl, _extends({}, overlayProps, {
84
- ref: forwardedRef
85
- }))) : null;
182
+ Dialog.displayName = DIALOG_NAME;
183
+ var TRIGGER_NAME = "DialogTrigger";
184
+ var DialogTrigger = React.forwardRef(
185
+ (props, forwardedRef) => {
186
+ const { __scopeDialog, ...triggerProps } = props;
187
+ const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
188
+ const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
189
+ return /* @__PURE__ */ jsx(
190
+ Primitive.button,
191
+ {
192
+ type: "button",
193
+ "aria-haspopup": "dialog",
194
+ "aria-expanded": context.open,
195
+ "aria-controls": context.contentId,
196
+ "data-state": getState(context.open),
197
+ ...triggerProps,
198
+ ref: composedTriggerRef,
199
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
200
+ }
201
+ );
202
+ }
203
+ );
204
+ DialogTrigger.displayName = TRIGGER_NAME;
205
+ var PORTAL_NAME = "DialogPortal";
206
+ var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
207
+ forceMount: void 0
86
208
  });
87
- const $5d3850c4d0b4e6c7$var$DialogOverlayImpl = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
88
- const { __scopeDialog: __scopeDialog , ...overlayProps } = props;
89
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$OVERLAY_NAME, __scopeDialog);
90
- return(/*#__PURE__*/ // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
91
- // ie. when `Overlay` and `Content` are siblings
92
- createElement($01b9c$RemoveScroll, {
93
- as: $5e63c961fc1ce211$export$8c6ed5c666ac1360,
94
- allowPinchZoom: true,
95
- shards: [
96
- context.contentRef
97
- ]
98
- }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
99
- "data-state": $5d3850c4d0b4e6c7$var$getState(context.open)
100
- }, overlayProps, {
101
- ref: forwardedRef // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.
102
- ,
103
- style: {
104
- pointerEvents: 'auto',
105
- ...overlayProps.style
209
+ var DialogPortal = (props) => {
210
+ const { __scopeDialog, forceMount, children, container } = props;
211
+ const context = useDialogContext(PORTAL_NAME, __scopeDialog);
212
+ return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: React.Children.map(children, (child) => /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children: child }) })) });
213
+ };
214
+ DialogPortal.displayName = PORTAL_NAME;
215
+ var OVERLAY_NAME = "DialogOverlay";
216
+ var DialogOverlay = React.forwardRef(
217
+ (props, forwardedRef) => {
218
+ const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
219
+ const { forceMount = portalContext.forceMount, ...overlayProps } = props;
220
+ const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
221
+ return context.modal ? /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
222
+ }
223
+ );
224
+ DialogOverlay.displayName = OVERLAY_NAME;
225
+ var DialogOverlayImpl = React.forwardRef(
226
+ (props, forwardedRef) => {
227
+ const { __scopeDialog, ...overlayProps } = props;
228
+ const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
229
+ return (
230
+ // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
231
+ // ie. when `Overlay` and `Content` are siblings
232
+ /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx(
233
+ Primitive.div,
234
+ {
235
+ "data-state": getState(context.open),
236
+ ...overlayProps,
237
+ ref: forwardedRef,
238
+ style: { pointerEvents: "auto", ...overlayProps.style }
106
239
  }
107
- }))));
108
- });
109
- /* -------------------------------------------------------------------------------------------------
110
- * DialogContent
111
- * -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$CONTENT_NAME = 'DialogContent';
112
- const $5d3850c4d0b4e6c7$export$b6d9565de1e068cf = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
113
- const portalContext = $5d3850c4d0b4e6c7$var$usePortalContext($5d3850c4d0b4e6c7$var$CONTENT_NAME, props.__scopeDialog);
114
- const { forceMount: forceMount = portalContext.forceMount , ...contentProps } = props;
115
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$CONTENT_NAME, props.__scopeDialog);
116
- return /*#__PURE__*/ createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
117
- present: forceMount || context.open
118
- }, context.modal ? /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$DialogContentModal, _extends({}, contentProps, {
119
- ref: forwardedRef
120
- })) : /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$DialogContentNonModal, _extends({}, contentProps, {
121
- ref: forwardedRef
122
- })));
123
- });
124
- /* -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$DialogContentModal = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
125
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$CONTENT_NAME, props.__scopeDialog);
126
- const contentRef = useRef(null);
127
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.contentRef, contentRef); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
128
- useEffect(()=>{
129
- const content = contentRef.current;
130
- if (content) return hideOthers(content);
240
+ ) })
241
+ );
242
+ }
243
+ );
244
+ var CONTENT_NAME = "DialogContent";
245
+ var DialogContent = React.forwardRef(
246
+ (props, forwardedRef) => {
247
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
248
+ const { forceMount = portalContext.forceMount, ...contentProps } = props;
249
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
250
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
251
+ }
252
+ );
253
+ DialogContent.displayName = CONTENT_NAME;
254
+ var DialogContentModal = React.forwardRef(
255
+ (props, forwardedRef) => {
256
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
257
+ const contentRef = React.useRef(null);
258
+ const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
259
+ React.useEffect(() => {
260
+ const content = contentRef.current;
261
+ if (content) return hideOthers(content);
131
262
  }, []);
132
- return /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$DialogContentImpl, _extends({}, props, {
133
- ref: composedRefs // we make sure focus isn't trapped once `DialogContent` has been closed
134
- ,
263
+ return /* @__PURE__ */ jsx(
264
+ DialogContentImpl,
265
+ {
266
+ ...props,
267
+ ref: composedRefs,
135
268
  trapFocus: context.open,
136
269
  disableOutsidePointerEvents: true,
137
- onCloseAutoFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onCloseAutoFocus, (event)=>{
138
- var _context$triggerRef$c;
139
- event.preventDefault();
140
- (_context$triggerRef$c = context.triggerRef.current) === null || _context$triggerRef$c === void 0 || _context$triggerRef$c.focus();
270
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
271
+ event.preventDefault();
272
+ context.triggerRef.current?.focus();
141
273
  }),
142
- onPointerDownOutside: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownOutside, (event)=>{
143
- const originalEvent = event.detail.originalEvent;
144
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
145
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick; // If the event is a right-click, we shouldn't close because
146
- // it is effectively as if we right-clicked the `Overlay`.
147
- if (isRightClick) event.preventDefault();
148
- }) // When focus is trapped, a `focusout` event may still happen.
149
- ,
150
- onFocusOutside: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusOutside, (event)=>event.preventDefault()
274
+ onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
275
+ const originalEvent = event.detail.originalEvent;
276
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
277
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
278
+ if (isRightClick) event.preventDefault();
279
+ }),
280
+ onFocusOutside: composeEventHandlers(
281
+ props.onFocusOutside,
282
+ (event) => event.preventDefault()
151
283
  )
152
- }));
153
- });
154
- /* -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$DialogContentNonModal = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
155
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$CONTENT_NAME, props.__scopeDialog);
156
- const hasInteractedOutsideRef = useRef(false);
157
- const hasPointerDownOutsideRef = useRef(false);
158
- return /*#__PURE__*/ createElement($5d3850c4d0b4e6c7$var$DialogContentImpl, _extends({}, props, {
284
+ }
285
+ );
286
+ }
287
+ );
288
+ var DialogContentNonModal = React.forwardRef(
289
+ (props, forwardedRef) => {
290
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
291
+ const hasInteractedOutsideRef = React.useRef(false);
292
+ const hasPointerDownOutsideRef = React.useRef(false);
293
+ return /* @__PURE__ */ jsx(
294
+ DialogContentImpl,
295
+ {
296
+ ...props,
159
297
  ref: forwardedRef,
160
298
  trapFocus: false,
161
299
  disableOutsidePointerEvents: false,
162
- onCloseAutoFocus: (event)=>{
163
- var _props$onCloseAutoFoc;
164
- (_props$onCloseAutoFoc = props.onCloseAutoFocus) === null || _props$onCloseAutoFoc === void 0 || _props$onCloseAutoFoc.call(props, event);
165
- if (!event.defaultPrevented) {
166
- var _context$triggerRef$c2;
167
- if (!hasInteractedOutsideRef.current) (_context$triggerRef$c2 = context.triggerRef.current) === null || _context$triggerRef$c2 === void 0 || _context$triggerRef$c2.focus(); // Always prevent auto focus because we either focus manually or want user agent focus
168
- event.preventDefault();
169
- }
170
- hasInteractedOutsideRef.current = false;
171
- hasPointerDownOutsideRef.current = false;
300
+ onCloseAutoFocus: (event) => {
301
+ props.onCloseAutoFocus?.(event);
302
+ if (!event.defaultPrevented) {
303
+ if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
304
+ event.preventDefault();
305
+ }
306
+ hasInteractedOutsideRef.current = false;
307
+ hasPointerDownOutsideRef.current = false;
172
308
  },
173
- onInteractOutside: (event)=>{
174
- var _props$onInteractOuts, _context$triggerRef$c3;
175
- (_props$onInteractOuts = props.onInteractOutside) === null || _props$onInteractOuts === void 0 || _props$onInteractOuts.call(props, event);
176
- if (!event.defaultPrevented) {
177
- hasInteractedOutsideRef.current = true;
178
- if (event.detail.originalEvent.type === 'pointerdown') hasPointerDownOutsideRef.current = true;
179
- } // Prevent dismissing when clicking the trigger.
180
- // As the trigger is already setup to close, without doing so would
181
- // cause it to close and immediately open.
182
- const target = event.target;
183
- const targetIsTrigger = (_context$triggerRef$c3 = context.triggerRef.current) === null || _context$triggerRef$c3 === void 0 ? void 0 : _context$triggerRef$c3.contains(target);
184
- if (targetIsTrigger) event.preventDefault(); // On Safari if the trigger is inside a container with tabIndex={0}, when clicked
185
- // we will get the pointer down outside event on the trigger, but then a subsequent
186
- // focus outside event on the container, we ignore any focus outside event when we've
187
- // already had a pointer down outside event.
188
- if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) event.preventDefault();
309
+ onInteractOutside: (event) => {
310
+ props.onInteractOutside?.(event);
311
+ if (!event.defaultPrevented) {
312
+ hasInteractedOutsideRef.current = true;
313
+ if (event.detail.originalEvent.type === "pointerdown") {
314
+ hasPointerDownOutsideRef.current = true;
315
+ }
316
+ }
317
+ const target = event.target;
318
+ const targetIsTrigger = context.triggerRef.current?.contains(target);
319
+ if (targetIsTrigger) event.preventDefault();
320
+ if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
321
+ event.preventDefault();
322
+ }
189
323
  }
190
- }));
191
- });
192
- /* -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$DialogContentImpl = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
193
- const { __scopeDialog: __scopeDialog , trapFocus: trapFocus , onOpenAutoFocus: onOpenAutoFocus , onCloseAutoFocus: onCloseAutoFocus , ...contentProps } = props;
194
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$CONTENT_NAME, __scopeDialog);
195
- const contentRef = useRef(null);
196
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentRef); // Make sure the whole tree has focus guards as our `Dialog` will be
197
- // the last element in the DOM (beacuse of the `Portal`)
198
- $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
199
- return /*#__PURE__*/ createElement(Fragment, null, /*#__PURE__*/ createElement($d3863c46a17e8a28$export$20e40289641fbbb6, {
200
- asChild: true,
201
- loop: true,
202
- trapped: trapFocus,
203
- onMountAutoFocus: onOpenAutoFocus,
204
- onUnmountAutoFocus: onCloseAutoFocus
205
- }, /*#__PURE__*/ createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, _extends({
206
- role: "dialog",
207
- id: context.contentId,
208
- "aria-describedby": context.descriptionId,
209
- "aria-labelledby": context.titleId,
210
- "data-state": $5d3850c4d0b4e6c7$var$getState(context.open)
211
- }, contentProps, {
212
- ref: composedRefs,
213
- onDismiss: ()=>context.onOpenChange(false)
214
- }))), false);
215
- });
216
- /* -------------------------------------------------------------------------------------------------
217
- * DialogTitle
218
- * -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$TITLE_NAME = 'DialogTitle';
219
- const $5d3850c4d0b4e6c7$export$16f7638e4a34b909 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
220
- const { __scopeDialog: __scopeDialog , ...titleProps } = props;
221
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$TITLE_NAME, __scopeDialog);
222
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.h2, _extends({
223
- id: context.titleId
224
- }, titleProps, {
225
- ref: forwardedRef
226
- }));
227
- });
228
- /* -------------------------------------------------------------------------------------------------
229
- * DialogDescription
230
- * -----------------------------------------------------------------------------------------------*/ const $5d3850c4d0b4e6c7$var$DESCRIPTION_NAME = 'DialogDescription';
231
- const $5d3850c4d0b4e6c7$export$94e94c2ec2c954d5 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
232
- const { __scopeDialog: __scopeDialog , ...descriptionProps } = props;
233
- const context = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$DESCRIPTION_NAME, __scopeDialog);
234
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.p, _extends({
235
- id: context.descriptionId
236
- }, descriptionProps, {
237
- ref: forwardedRef
238
- }));
239
- });
240
- /* -----------------------------------------------------------------------------------------------*/ function $5d3850c4d0b4e6c7$var$getState(open) {
241
- return open ? 'open' : 'closed';
324
+ }
325
+ );
326
+ }
327
+ );
328
+ var DialogContentImpl = React.forwardRef(
329
+ (props, forwardedRef) => {
330
+ const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
331
+ const context = useDialogContext(CONTENT_NAME, __scopeDialog);
332
+ const contentRef = React.useRef(null);
333
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
334
+ useFocusGuards();
335
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
336
+ /* @__PURE__ */ jsx(
337
+ FocusScope,
338
+ {
339
+ asChild: true,
340
+ loop: true,
341
+ trapped: trapFocus,
342
+ onMountAutoFocus: onOpenAutoFocus,
343
+ onUnmountAutoFocus: onCloseAutoFocus,
344
+ children: /* @__PURE__ */ jsx(
345
+ DismissableLayer,
346
+ {
347
+ role: "dialog",
348
+ id: context.contentId,
349
+ "aria-describedby": context.descriptionId,
350
+ "aria-labelledby": context.titleId,
351
+ "data-state": getState(context.open),
352
+ ...contentProps,
353
+ ref: composedRefs,
354
+ onDismiss: () => context.onOpenChange(false)
355
+ }
356
+ )
357
+ }
358
+ ),
359
+ /* @__PURE__ */ jsxs(Fragment, { children: [
360
+ /* @__PURE__ */ jsx(TitleWarning, { titleId: context.titleId }),
361
+ /* @__PURE__ */ jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
362
+ ] })
363
+ ] });
364
+ }
365
+ );
366
+ var TITLE_NAME = "DialogTitle";
367
+ var DialogTitle = React.forwardRef(
368
+ (props, forwardedRef) => {
369
+ const { __scopeDialog, ...titleProps } = props;
370
+ const context = useDialogContext(TITLE_NAME, __scopeDialog);
371
+ return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
372
+ }
373
+ );
374
+ DialogTitle.displayName = TITLE_NAME;
375
+ var DESCRIPTION_NAME = "DialogDescription";
376
+ var DialogDescription = React.forwardRef(
377
+ (props, forwardedRef) => {
378
+ const { __scopeDialog, ...descriptionProps } = props;
379
+ const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
380
+ return /* @__PURE__ */ jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
381
+ }
382
+ );
383
+ DialogDescription.displayName = DESCRIPTION_NAME;
384
+ var CLOSE_NAME = "DialogClose";
385
+ var DialogClose = React.forwardRef(
386
+ (props, forwardedRef) => {
387
+ const { __scopeDialog, ...closeProps } = props;
388
+ const context = useDialogContext(CLOSE_NAME, __scopeDialog);
389
+ return /* @__PURE__ */ jsx(
390
+ Primitive.button,
391
+ {
392
+ type: "button",
393
+ ...closeProps,
394
+ ref: forwardedRef,
395
+ onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
396
+ }
397
+ );
398
+ }
399
+ );
400
+ DialogClose.displayName = CLOSE_NAME;
401
+ function getState(open) {
402
+ return open ? "open" : "closed";
242
403
  }
243
- const $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9 = $5d3850c4d0b4e6c7$export$3ddf2d174ce01153;
244
- const $5d3850c4d0b4e6c7$export$602eac185826482c = $5d3850c4d0b4e6c7$export$dad7c95542bacce0;
245
- const $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff = $5d3850c4d0b4e6c7$export$bd1d06c79be19e17;
246
- const $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 = $5d3850c4d0b4e6c7$export$b6d9565de1e068cf;
247
- const $5d3850c4d0b4e6c7$export$f99233281efd08a0 = $5d3850c4d0b4e6c7$export$16f7638e4a34b909;
248
- const $5d3850c4d0b4e6c7$export$393edc798c47379d = $5d3850c4d0b4e6c7$export$94e94c2ec2c954d5;
404
+ var TITLE_WARNING_NAME = "DialogTitleWarning";
405
+ var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
406
+ contentName: CONTENT_NAME,
407
+ titleName: TITLE_NAME,
408
+ docsSlug: "dialog"
409
+ });
410
+ var TitleWarning = ({ titleId }) => {
411
+ const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
412
+ const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
413
+
414
+ If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
415
+
416
+ For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
417
+ React.useEffect(() => {
418
+ if (titleId) {
419
+ const hasTitle = document.getElementById(titleId);
420
+ if (!hasTitle) console.error(MESSAGE);
421
+ }
422
+ }, [MESSAGE, titleId]);
423
+ return null;
424
+ };
425
+ var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
426
+ var DescriptionWarning = ({ contentRef, descriptionId }) => {
427
+ const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
428
+ const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
429
+ React.useEffect(() => {
430
+ const describedById = contentRef.current?.getAttribute("aria-describedby");
431
+ if (descriptionId && describedById) {
432
+ const hasDescription = document.getElementById(descriptionId);
433
+ if (!hasDescription) console.warn(MESSAGE);
434
+ }
435
+ }, [MESSAGE, contentRef, descriptionId]);
436
+ return null;
437
+ };
438
+ var Root = Dialog;
439
+ var Portal = DialogPortal;
440
+ var Overlay = DialogOverlay;
441
+ var Content = DialogContent;
442
+ var Title = DialogTitle;
443
+ var Description = DialogDescription;
249
444
 
250
445
  /** Use `Modal` to display information that needs immediate action from a user. */
251
446
  var Modal = function (_a) {
@@ -269,19 +464,19 @@ var Modal = function (_a) {
269
464
  onRequestClose();
270
465
  }
271
466
  };
272
- return (React__default.createElement($5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, { open: isOpen },
273
- React__default.createElement($5d3850c4d0b4e6c7$export$602eac185826482c, { container: arcRootElement || undefined },
274
- React__default.createElement($5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, { className: "arc-Modal-overlay" },
275
- React__default.createElement($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, __assign({}, ariaProps, { role: role, onOpenAutoFocus: setTriggerElement, onCloseAutoFocus: focusTriggerElement, onEscapeKeyDown: closeModal, onInteractOutside: closeModal, "aria-modal": "true", className: classNames("arc-Modal-dialog", "arc-Modal-dialog--".concat(size), {
467
+ return (React__default.createElement(Root, { open: isOpen },
468
+ React__default.createElement(Portal, { container: arcRootElement || undefined },
469
+ React__default.createElement(Overlay, { className: "arc-Modal-overlay" },
470
+ React__default.createElement(Content, __assign({}, ariaProps, { role: role, onOpenAutoFocus: setTriggerElement, onCloseAutoFocus: focusTriggerElement, onEscapeKeyDown: closeModal, onInteractOutside: closeModal, "aria-modal": "true", className: classNames("arc-Modal-dialog", "arc-Modal-dialog--".concat(size), {
276
471
  "arc-Modal-dialog--maxHeightWindow": isContentScrollable
277
472
  }) }, filterDataAttrs(props)),
278
473
  React__default.createElement("div", { className: "arc-Modal-section" },
279
- React__default.createElement($5d3850c4d0b4e6c7$export$f99233281efd08a0, { asChild: true },
474
+ React__default.createElement(Title, { asChild: true },
280
475
  React__default.createElement(Heading, { level: "1", size: "m" }, title))),
281
476
  React__default.createElement(VerticalSpace, { size: "12" }),
282
477
  hasContent && (React__default.createElement("div", { className: "arc-Modal-content" },
283
478
  React__default.createElement("div", { className: "arc-Modal-section" },
284
- description && (React__default.createElement($5d3850c4d0b4e6c7$export$393edc798c47379d, { asChild: true },
479
+ description && (React__default.createElement(Description, { asChild: true },
285
480
  React__default.createElement(Text, null, description))),
286
481
  description && children && (React__default.createElement(VerticalSpace, { "data-testid": "arc-modal-vertical-space", size: "20" })),
287
482
  children))),