@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.
- package/dist/Button/Button.cjs.js +1 -1
- package/dist/Button/Button.esm.js +1 -1
- package/dist/DatePicker/DatePicker.cjs.js +1276 -22
- package/dist/DatePicker/DatePicker.esm.js +1245 -10
- package/dist/InformationCard/InformationCard.cjs.js +1 -1
- package/dist/InformationCard/InformationCard.esm.js +1 -1
- package/dist/Modal/Modal.cjs.js +438 -225
- package/dist/Modal/Modal.esm.js +420 -225
- package/dist/PaginationSimple/PaginationSimple.cjs.js +23 -2
- package/dist/PaginationSimple/PaginationSimple.esm.js +23 -2
- package/dist/Select/Select.cjs.js +1514 -1065
- package/dist/Select/Select.esm.js +1496 -1066
- package/dist/SiteHeader/SiteHeader.cjs.js +2 -2
- package/dist/SiteHeader/SiteHeader.esm.js +2 -2
- package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +2 -2
- package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +2 -2
- package/dist/Tabs/Tabs.cjs.js +4 -6
- package/dist/Tabs/Tabs.esm.js +4 -6
- package/dist/TextArea/TextArea.cjs.js +10 -13
- package/dist/TextArea/TextArea.esm.js +10 -13
- package/dist/Toast/Toast.cjs.js +4 -6
- package/dist/Toast/Toast.esm.js +4 -6
- package/dist/UniversalHeader/UniversalHeader.cjs.js +2 -2
- package/dist/UniversalHeader/UniversalHeader.esm.js +2 -2
- package/dist/_shared/cjs/{Button-6ba21d3b.js → Button-5b28f0ce.js} +3 -3
- package/dist/_shared/cjs/{SiteHeader.rehydrator-9d8f3dad.js → SiteHeader.rehydrator-8fa9d174.js} +1 -1
- package/dist/_shared/cjs/{SiteHeaderV2-ce1c8737.js → SiteHeaderV2-ca2f13a8.js} +1 -1
- package/dist/_shared/cjs/{Tabs-bc9fac46.js → Tabs-89455281.js} +19 -15
- package/dist/_shared/cjs/{Toast-26207fef.js → Toast-c760c89d.js} +32 -14
- package/dist/_shared/cjs/{UniversalHeader-b8389447.js → UniversalHeader-73e154eb.js} +6 -2
- package/dist/_shared/cjs/component-4979b2e7.js +409 -0
- package/dist/_shared/cjs/{index-77ab5c6a.js → floating-ui.react-dom-08b8b87c.js} +12 -284
- package/dist/_shared/cjs/index-1efbba95.js +1252 -0
- package/dist/_shared/cjs/{index-74004a9c.js → index-4edec793.js} +1 -1
- package/dist/_shared/cjs/{index-dd1d18ea.js → index-7641213c.js} +127 -2
- package/dist/_shared/cjs/{index-9f99d686.js → index-af744fa9.js} +1 -1
- package/dist/_shared/cjs/{index-6eb396a3.js → index-fb0cad18.js} +1 -1
- package/dist/_shared/esm/{Button-a7d134c6.js → Button-5b48b7ce.js} +3 -3
- package/dist/_shared/esm/{SiteHeader.rehydrator-2ec02ee7.js → SiteHeader.rehydrator-8f3c5d6e.js} +1 -1
- package/dist/_shared/esm/{SiteHeaderV2-a7c1b1cb.js → SiteHeaderV2-cb081752.js} +1 -1
- package/dist/_shared/esm/{Tabs-9485cab6.js → Tabs-959e885d.js} +10 -6
- package/dist/_shared/esm/{Toast-fcbfc194.js → Toast-a590067d.js} +25 -7
- package/dist/_shared/esm/{UniversalHeader-80c7313f.js → UniversalHeader-96bfbacc.js} +6 -2
- package/dist/_shared/esm/component-d7b471ff.js +382 -0
- package/dist/_shared/esm/{index-b84a20c6.js → floating-ui.react-dom-1bb71aae.js} +4 -281
- package/dist/_shared/esm/{index-7b531fa7.js → index-0ae23b06.js} +126 -2
- package/dist/_shared/esm/index-307f1bbc.js +1212 -0
- package/dist/_shared/esm/{index-044da8d0.js → index-9e54cc7d.js} +1 -1
- package/dist/_shared/esm/{index-efa9be1a.js → index-af7b6e55.js} +1 -1
- package/dist/_shared/esm/{index-2cfab9f2.js → index-ebe72f34.js} +1 -1
- package/dist/index.es.js +3608 -2938
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3591 -2921
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/types/components/Button/Button.d.ts +12 -0
- package/dist/types/components/PaginationSimple/PaginationSimple.d.ts +28 -0
- package/dist/types/components/UniversalHeader/UniversalHeader.d.ts +4 -0
- package/package.json +3 -3
- package/dist/_shared/cjs/Combination-9974f2e2.js +0 -1330
- package/dist/_shared/cjs/index-a31e64a9.js +0 -27
- package/dist/_shared/cjs/index-d38f1bd0.js +0 -131
- package/dist/_shared/cjs/index-dcfdd5da.js +0 -11
- package/dist/_shared/esm/Combination-e9f7e64e.js +0 -1301
- package/dist/_shared/esm/index-25a5b393.js +0 -25
- package/dist/_shared/esm/index-a624de47.js +0 -9
- package/dist/_shared/esm/index-ca72c9d5.js +0 -129
package/dist/Modal/Modal.cjs.js
CHANGED
|
@@ -4,21 +4,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var filterDataAttrs = require('../_shared/cjs/filter-data-attrs-1c9a530c.js');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var index$
|
|
7
|
+
var index$1 = require('../_shared/cjs/index-9947ac13.js');
|
|
8
8
|
var BtIconCrossAlt2Px_esm = require('../_shared/cjs/BtIconCrossAlt2Px.esm-1452b14b.js');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var index$1 = require('../_shared/cjs/index-6eb396a3.js');
|
|
12
|
-
var Combination = require('../_shared/cjs/Combination-9974f2e2.js');
|
|
13
|
-
var index$2 = require('../_shared/cjs/index-d38f1bd0.js');
|
|
9
|
+
var index = require('../_shared/cjs/index-1efbba95.js');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
14
11
|
var Icon = require('../_shared/cjs/Icon-b46897a3.js');
|
|
15
12
|
var Base = require('../_shared/cjs/Base-4676f12e.js');
|
|
16
13
|
var Heading = require('../_shared/cjs/Heading-27cba320.js');
|
|
17
|
-
var Button = require('../_shared/cjs/Button-
|
|
14
|
+
var Button = require('../_shared/cjs/Button-5b28f0ce.js');
|
|
18
15
|
var Text = require('../_shared/cjs/Text-606ca3a2.js');
|
|
19
16
|
var VerticalSpace = require('../_shared/cjs/VerticalSpace-dc53bb70.js');
|
|
20
17
|
require('react-dom');
|
|
21
|
-
require('../_shared/cjs/
|
|
18
|
+
require('../_shared/cjs/component-4979b2e7.js');
|
|
22
19
|
require('../_shared/cjs/suffix-modifier-64dcd338.js');
|
|
23
20
|
require('../_shared/cjs/Surface-038db6e1.js');
|
|
24
21
|
require('../_shared/cjs/BtIconChevronLeftMid.esm-0aaa6770.js');
|
|
@@ -26,234 +23,450 @@ require('../_shared/cjs/BtIconChevronRightMid.esm-d01ebbd4.js');
|
|
|
26
23
|
|
|
27
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
25
|
|
|
26
|
+
function _interopNamespace(e) {
|
|
27
|
+
if (e && e.__esModule) return e;
|
|
28
|
+
var n = Object.create(null);
|
|
29
|
+
if (e) {
|
|
30
|
+
Object.keys(e).forEach(function (k) {
|
|
31
|
+
if (k !== 'default') {
|
|
32
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
33
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return e[k]; }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
n["default"] = e;
|
|
41
|
+
return Object.freeze(n);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
45
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
46
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
scope: __scopeDialog,
|
|
47
|
-
triggerRef: triggerRef,
|
|
48
|
-
contentRef: contentRef,
|
|
49
|
-
contentId: index$1.$1746a345f3d73bb7$export$f680877a34711e37(),
|
|
50
|
-
titleId: index$1.$1746a345f3d73bb7$export$f680877a34711e37(),
|
|
51
|
-
descriptionId: index$1.$1746a345f3d73bb7$export$f680877a34711e37(),
|
|
52
|
-
open: open,
|
|
53
|
-
onOpenChange: setOpen,
|
|
54
|
-
onOpenToggle: React.useCallback(()=>setOpen((prevOpen)=>!prevOpen
|
|
55
|
-
)
|
|
56
|
-
, [
|
|
57
|
-
setOpen
|
|
58
|
-
]),
|
|
59
|
-
modal: modal
|
|
60
|
-
}, children);
|
|
47
|
+
function useStateMachine(initialState, machine) {
|
|
48
|
+
return React__namespace.useReducer((state, event) => {
|
|
49
|
+
const nextState = machine[state][event];
|
|
50
|
+
return nextState ?? state;
|
|
51
|
+
}, initialState);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// packages/react/presence/src/Presence.tsx
|
|
55
|
+
var Presence = (props) => {
|
|
56
|
+
const { present, children } = props;
|
|
57
|
+
const presence = usePresence(present);
|
|
58
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React__namespace.Children.only(children);
|
|
59
|
+
const ref = index.useComposedRefs(presence.ref, getElementRef(child));
|
|
60
|
+
const forceMount = typeof children === "function";
|
|
61
|
+
return forceMount || presence.isPresent ? React__namespace.cloneElement(child, { ref }) : null;
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
Presence.displayName = "Presence";
|
|
64
|
+
function usePresence(present) {
|
|
65
|
+
const [node, setNode] = React__namespace.useState();
|
|
66
|
+
const stylesRef = React__namespace.useRef({});
|
|
67
|
+
const prevPresentRef = React__namespace.useRef(present);
|
|
68
|
+
const prevAnimationNameRef = React__namespace.useRef("none");
|
|
69
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
70
|
+
const [state, send] = useStateMachine(initialState, {
|
|
71
|
+
mounted: {
|
|
72
|
+
UNMOUNT: "unmounted",
|
|
73
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
74
|
+
},
|
|
75
|
+
unmountSuspended: {
|
|
76
|
+
MOUNT: "mounted",
|
|
77
|
+
ANIMATION_END: "unmounted"
|
|
78
|
+
},
|
|
79
|
+
unmounted: {
|
|
80
|
+
MOUNT: "mounted"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
React__namespace.useEffect(() => {
|
|
84
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
85
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
86
|
+
}, [state]);
|
|
87
|
+
index.useLayoutEffect2(() => {
|
|
88
|
+
const styles = stylesRef.current;
|
|
89
|
+
const wasPresent = prevPresentRef.current;
|
|
90
|
+
const hasPresentChanged = wasPresent !== present;
|
|
91
|
+
if (hasPresentChanged) {
|
|
92
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
93
|
+
const currentAnimationName = getAnimationName(styles);
|
|
94
|
+
if (present) {
|
|
95
|
+
send("MOUNT");
|
|
96
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
97
|
+
send("UNMOUNT");
|
|
98
|
+
} else {
|
|
99
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
100
|
+
if (wasPresent && isAnimating) {
|
|
101
|
+
send("ANIMATION_OUT");
|
|
102
|
+
} else {
|
|
103
|
+
send("UNMOUNT");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
prevPresentRef.current = present;
|
|
107
|
+
}
|
|
108
|
+
}, [present, send]);
|
|
109
|
+
index.useLayoutEffect2(() => {
|
|
110
|
+
if (node) {
|
|
111
|
+
let timeoutId;
|
|
112
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
113
|
+
const handleAnimationEnd = (event) => {
|
|
114
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
115
|
+
const isCurrentAnimation = currentAnimationName.includes(event.animationName);
|
|
116
|
+
if (event.target === node && isCurrentAnimation) {
|
|
117
|
+
send("ANIMATION_END");
|
|
118
|
+
if (!prevPresentRef.current) {
|
|
119
|
+
const currentFillMode = node.style.animationFillMode;
|
|
120
|
+
node.style.animationFillMode = "forwards";
|
|
121
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
122
|
+
if (node.style.animationFillMode === "forwards") {
|
|
123
|
+
node.style.animationFillMode = currentFillMode;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleAnimationStart = (event) => {
|
|
130
|
+
if (event.target === node) {
|
|
131
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
135
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
136
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
137
|
+
return () => {
|
|
138
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
139
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
140
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
141
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
142
|
+
};
|
|
143
|
+
} else {
|
|
144
|
+
send("ANIMATION_END");
|
|
145
|
+
}
|
|
146
|
+
}, [node, send]);
|
|
147
|
+
return {
|
|
148
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
149
|
+
ref: React__namespace.useCallback((node2) => {
|
|
150
|
+
if (node2) stylesRef.current = getComputedStyle(node2);
|
|
151
|
+
setNode(node2);
|
|
152
|
+
}, [])
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function getAnimationName(styles) {
|
|
156
|
+
return styles?.animationName || "none";
|
|
157
|
+
}
|
|
158
|
+
function getElementRef(element) {
|
|
159
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
160
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
161
|
+
if (mayWarn) {
|
|
162
|
+
return element.ref;
|
|
163
|
+
}
|
|
164
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
165
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
166
|
+
if (mayWarn) {
|
|
167
|
+
return element.props.ref;
|
|
168
|
+
}
|
|
169
|
+
return element.props.ref || element.ref;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var DIALOG_NAME = "Dialog";
|
|
173
|
+
var [createDialogContext, createDialogScope] = index.createContextScope(DIALOG_NAME);
|
|
174
|
+
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
175
|
+
var Dialog = (props) => {
|
|
176
|
+
const {
|
|
177
|
+
__scopeDialog,
|
|
178
|
+
children,
|
|
179
|
+
open: openProp,
|
|
180
|
+
defaultOpen,
|
|
181
|
+
onOpenChange,
|
|
182
|
+
modal = true
|
|
183
|
+
} = props;
|
|
184
|
+
const triggerRef = React__namespace.useRef(null);
|
|
185
|
+
const contentRef = React__namespace.useRef(null);
|
|
186
|
+
const [open = false, setOpen] = index.useControllableState({
|
|
187
|
+
prop: openProp,
|
|
188
|
+
defaultProp: defaultOpen,
|
|
189
|
+
onChange: onOpenChange
|
|
190
|
+
});
|
|
191
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
192
|
+
DialogProvider,
|
|
193
|
+
{
|
|
194
|
+
scope: __scopeDialog,
|
|
195
|
+
triggerRef,
|
|
196
|
+
contentRef,
|
|
197
|
+
contentId: index.useId(),
|
|
198
|
+
titleId: index.useId(),
|
|
199
|
+
descriptionId: index.useId(),
|
|
200
|
+
open,
|
|
201
|
+
onOpenChange: setOpen,
|
|
202
|
+
onOpenToggle: React__namespace.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
203
|
+
modal,
|
|
204
|
+
children
|
|
205
|
+
}
|
|
206
|
+
);
|
|
81
207
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
208
|
+
Dialog.displayName = DIALOG_NAME;
|
|
209
|
+
var TRIGGER_NAME = "DialogTrigger";
|
|
210
|
+
var DialogTrigger = React__namespace.forwardRef(
|
|
211
|
+
(props, forwardedRef) => {
|
|
212
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
213
|
+
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
214
|
+
const composedTriggerRef = index.useComposedRefs(forwardedRef, context.triggerRef);
|
|
215
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
216
|
+
index.Primitive.button,
|
|
217
|
+
{
|
|
218
|
+
type: "button",
|
|
219
|
+
"aria-haspopup": "dialog",
|
|
220
|
+
"aria-expanded": context.open,
|
|
221
|
+
"aria-controls": context.contentId,
|
|
222
|
+
"data-state": getState(context.open),
|
|
223
|
+
...triggerProps,
|
|
224
|
+
ref: composedTriggerRef,
|
|
225
|
+
onClick: index.composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
DialogTrigger.displayName = TRIGGER_NAME;
|
|
231
|
+
var PORTAL_NAME = "DialogPortal";
|
|
232
|
+
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
233
|
+
forceMount: void 0
|
|
94
234
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
235
|
+
var DialogPortal = (props) => {
|
|
236
|
+
const { __scopeDialog, forceMount, children, container } = props;
|
|
237
|
+
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
238
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: React__namespace.Children.map(children, (child) => /* @__PURE__ */ jsxRuntime.jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsxRuntime.jsx(index.Portal, { asChild: true, container, children: child }) })) });
|
|
239
|
+
};
|
|
240
|
+
DialogPortal.displayName = PORTAL_NAME;
|
|
241
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
242
|
+
var DialogOverlay = React__namespace.forwardRef(
|
|
243
|
+
(props, forwardedRef) => {
|
|
244
|
+
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
245
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
246
|
+
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
247
|
+
return context.modal ? /* @__PURE__ */ jsxRuntime.jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsxRuntime.jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
DialogOverlay.displayName = OVERLAY_NAME;
|
|
251
|
+
var DialogOverlayImpl = React__namespace.forwardRef(
|
|
252
|
+
(props, forwardedRef) => {
|
|
253
|
+
const { __scopeDialog, ...overlayProps } = props;
|
|
254
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
255
|
+
return (
|
|
256
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
257
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
258
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.RemoveScroll, { as: index.Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
259
|
+
index.Primitive.div,
|
|
260
|
+
{
|
|
261
|
+
"data-state": getState(context.open),
|
|
262
|
+
...overlayProps,
|
|
263
|
+
ref: forwardedRef,
|
|
264
|
+
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
114
265
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const content = contentRef.current;
|
|
138
|
-
if (content) return Combination.hideOthers(content);
|
|
266
|
+
) })
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
var CONTENT_NAME = "DialogContent";
|
|
271
|
+
var DialogContent = React__namespace.forwardRef(
|
|
272
|
+
(props, forwardedRef) => {
|
|
273
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
274
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
275
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
276
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsxRuntime.jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsxRuntime.jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
DialogContent.displayName = CONTENT_NAME;
|
|
280
|
+
var DialogContentModal = React__namespace.forwardRef(
|
|
281
|
+
(props, forwardedRef) => {
|
|
282
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
283
|
+
const contentRef = React__namespace.useRef(null);
|
|
284
|
+
const composedRefs = index.useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
285
|
+
React__namespace.useEffect(() => {
|
|
286
|
+
const content = contentRef.current;
|
|
287
|
+
if (content) return index.hideOthers(content);
|
|
139
288
|
}, []);
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
|
|
289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
290
|
+
DialogContentImpl,
|
|
291
|
+
{
|
|
292
|
+
...props,
|
|
293
|
+
ref: composedRefs,
|
|
143
294
|
trapFocus: context.open,
|
|
144
295
|
disableOutsidePointerEvents: true,
|
|
145
|
-
onCloseAutoFocus: index
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
(_context$triggerRef$c = context.triggerRef.current) === null || _context$triggerRef$c === void 0 || _context$triggerRef$c.focus();
|
|
296
|
+
onCloseAutoFocus: index.composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
context.triggerRef.current?.focus();
|
|
149
299
|
}),
|
|
150
|
-
onPointerDownOutside: index
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
300
|
+
onPointerDownOutside: index.composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
301
|
+
const originalEvent = event.detail.originalEvent;
|
|
302
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
303
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
304
|
+
if (isRightClick) event.preventDefault();
|
|
305
|
+
}),
|
|
306
|
+
onFocusOutside: index.composeEventHandlers(
|
|
307
|
+
props.onFocusOutside,
|
|
308
|
+
(event) => event.preventDefault()
|
|
159
309
|
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
var DialogContentNonModal = React__namespace.forwardRef(
|
|
315
|
+
(props, forwardedRef) => {
|
|
316
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
317
|
+
const hasInteractedOutsideRef = React__namespace.useRef(false);
|
|
318
|
+
const hasPointerDownOutsideRef = React__namespace.useRef(false);
|
|
319
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
320
|
+
DialogContentImpl,
|
|
321
|
+
{
|
|
322
|
+
...props,
|
|
167
323
|
ref: forwardedRef,
|
|
168
324
|
trapFocus: false,
|
|
169
325
|
disableOutsidePointerEvents: false,
|
|
170
|
-
onCloseAutoFocus: (event)=>{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (!
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
hasInteractedOutsideRef.current = false;
|
|
179
|
-
hasPointerDownOutsideRef.current = false;
|
|
326
|
+
onCloseAutoFocus: (event) => {
|
|
327
|
+
props.onCloseAutoFocus?.(event);
|
|
328
|
+
if (!event.defaultPrevented) {
|
|
329
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
330
|
+
event.preventDefault();
|
|
331
|
+
}
|
|
332
|
+
hasInteractedOutsideRef.current = false;
|
|
333
|
+
hasPointerDownOutsideRef.current = false;
|
|
180
334
|
},
|
|
181
|
-
onInteractOutside: (event)=>{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
// already had a pointer down outside event.
|
|
196
|
-
if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) event.preventDefault();
|
|
335
|
+
onInteractOutside: (event) => {
|
|
336
|
+
props.onInteractOutside?.(event);
|
|
337
|
+
if (!event.defaultPrevented) {
|
|
338
|
+
hasInteractedOutsideRef.current = true;
|
|
339
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
340
|
+
hasPointerDownOutsideRef.current = true;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const target = event.target;
|
|
344
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
345
|
+
if (targetIsTrigger) event.preventDefault();
|
|
346
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
347
|
+
event.preventDefault();
|
|
348
|
+
}
|
|
197
349
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
var DialogContentImpl = React__namespace.forwardRef(
|
|
355
|
+
(props, forwardedRef) => {
|
|
356
|
+
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
357
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
358
|
+
const contentRef = React__namespace.useRef(null);
|
|
359
|
+
const composedRefs = index.useComposedRefs(forwardedRef, contentRef);
|
|
360
|
+
index.useFocusGuards();
|
|
361
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
362
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
363
|
+
index.FocusScope,
|
|
364
|
+
{
|
|
365
|
+
asChild: true,
|
|
366
|
+
loop: true,
|
|
367
|
+
trapped: trapFocus,
|
|
368
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
369
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
370
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
371
|
+
index.DismissableLayer,
|
|
372
|
+
{
|
|
373
|
+
role: "dialog",
|
|
374
|
+
id: context.contentId,
|
|
375
|
+
"aria-describedby": context.descriptionId,
|
|
376
|
+
"aria-labelledby": context.titleId,
|
|
377
|
+
"data-state": getState(context.open),
|
|
378
|
+
...contentProps,
|
|
379
|
+
ref: composedRefs,
|
|
380
|
+
onDismiss: () => context.onOpenChange(false)
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsx(TitleWarning, { titleId: context.titleId }),
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
388
|
+
] })
|
|
389
|
+
] });
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
var TITLE_NAME = "DialogTitle";
|
|
393
|
+
var DialogTitle = React__namespace.forwardRef(
|
|
394
|
+
(props, forwardedRef) => {
|
|
395
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
396
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
397
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
DialogTitle.displayName = TITLE_NAME;
|
|
401
|
+
var DESCRIPTION_NAME = "DialogDescription";
|
|
402
|
+
var DialogDescription = React__namespace.forwardRef(
|
|
403
|
+
(props, forwardedRef) => {
|
|
404
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
405
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
406
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
407
|
+
}
|
|
408
|
+
);
|
|
409
|
+
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
410
|
+
var CLOSE_NAME = "DialogClose";
|
|
411
|
+
var DialogClose = React__namespace.forwardRef(
|
|
412
|
+
(props, forwardedRef) => {
|
|
413
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
414
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
415
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
416
|
+
index.Primitive.button,
|
|
417
|
+
{
|
|
418
|
+
type: "button",
|
|
419
|
+
...closeProps,
|
|
420
|
+
ref: forwardedRef,
|
|
421
|
+
onClick: index.composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
DialogClose.displayName = CLOSE_NAME;
|
|
427
|
+
function getState(open) {
|
|
428
|
+
return open ? "open" : "closed";
|
|
250
429
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
430
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
431
|
+
var [WarningProvider, useWarningContext] = index.createContext2(TITLE_WARNING_NAME, {
|
|
432
|
+
contentName: CONTENT_NAME,
|
|
433
|
+
titleName: TITLE_NAME,
|
|
434
|
+
docsSlug: "dialog"
|
|
435
|
+
});
|
|
436
|
+
var TitleWarning = ({ titleId }) => {
|
|
437
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
438
|
+
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
439
|
+
|
|
440
|
+
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
441
|
+
|
|
442
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
443
|
+
React__namespace.useEffect(() => {
|
|
444
|
+
if (titleId) {
|
|
445
|
+
const hasTitle = document.getElementById(titleId);
|
|
446
|
+
if (!hasTitle) console.error(MESSAGE);
|
|
447
|
+
}
|
|
448
|
+
}, [MESSAGE, titleId]);
|
|
449
|
+
return null;
|
|
450
|
+
};
|
|
451
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
452
|
+
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
453
|
+
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
454
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
455
|
+
React__namespace.useEffect(() => {
|
|
456
|
+
const describedById = contentRef.current?.getAttribute("aria-describedby");
|
|
457
|
+
if (descriptionId && describedById) {
|
|
458
|
+
const hasDescription = document.getElementById(descriptionId);
|
|
459
|
+
if (!hasDescription) console.warn(MESSAGE);
|
|
460
|
+
}
|
|
461
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
462
|
+
return null;
|
|
463
|
+
};
|
|
464
|
+
var Root = Dialog;
|
|
465
|
+
var Portal = DialogPortal;
|
|
466
|
+
var Overlay = DialogOverlay;
|
|
467
|
+
var Content = DialogContent;
|
|
468
|
+
var Title = DialogTitle;
|
|
469
|
+
var Description = DialogDescription;
|
|
257
470
|
|
|
258
471
|
/** Use `Modal` to display information that needs immediate action from a user. */
|
|
259
472
|
var Modal = function (_a) {
|
|
@@ -277,19 +490,19 @@ var Modal = function (_a) {
|
|
|
277
490
|
onRequestClose();
|
|
278
491
|
}
|
|
279
492
|
};
|
|
280
|
-
return (React__default["default"].createElement(
|
|
281
|
-
React__default["default"].createElement(
|
|
282
|
-
React__default["default"].createElement(
|
|
283
|
-
React__default["default"].createElement(
|
|
493
|
+
return (React__default["default"].createElement(Root, { open: isOpen },
|
|
494
|
+
React__default["default"].createElement(Portal, { container: arcRootElement || undefined },
|
|
495
|
+
React__default["default"].createElement(Overlay, { className: "arc-Modal-overlay" },
|
|
496
|
+
React__default["default"].createElement(Content, filterDataAttrs.__assign({}, ariaProps, { role: role, onOpenAutoFocus: setTriggerElement, onCloseAutoFocus: focusTriggerElement, onEscapeKeyDown: closeModal, onInteractOutside: closeModal, "aria-modal": "true", className: index$1.classNames("arc-Modal-dialog", "arc-Modal-dialog--".concat(size), {
|
|
284
497
|
"arc-Modal-dialog--maxHeightWindow": isContentScrollable
|
|
285
498
|
}) }, filterDataAttrs.filterDataAttrs(props)),
|
|
286
499
|
React__default["default"].createElement("div", { className: "arc-Modal-section" },
|
|
287
|
-
React__default["default"].createElement(
|
|
500
|
+
React__default["default"].createElement(Title, { asChild: true },
|
|
288
501
|
React__default["default"].createElement(Heading.Heading, { level: "1", size: "m" }, title))),
|
|
289
502
|
React__default["default"].createElement(VerticalSpace.VerticalSpace, { size: "12" }),
|
|
290
503
|
hasContent && (React__default["default"].createElement("div", { className: "arc-Modal-content" },
|
|
291
504
|
React__default["default"].createElement("div", { className: "arc-Modal-section" },
|
|
292
|
-
description && (React__default["default"].createElement(
|
|
505
|
+
description && (React__default["default"].createElement(Description, { asChild: true },
|
|
293
506
|
React__default["default"].createElement(Text.Text, null, description))),
|
|
294
507
|
description && children && (React__default["default"].createElement(VerticalSpace.VerticalSpace, { "data-testid": "arc-modal-vertical-space", size: "20" })),
|
|
295
508
|
children))),
|