@jobber/components 8.14.1 → 8.15.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/Autocomplete-es.js +1 -1
- package/dist/BottomSheet-cjs.js +109 -77
- package/dist/BottomSheet-es.js +103 -75
- package/dist/Card/index.cjs +1 -2
- package/dist/Card/index.mjs +1 -2
- package/dist/DataDump/index.cjs +1 -2
- package/dist/DataDump/index.mjs +1 -2
- package/dist/InputNumberExperimental-cjs.js +3 -4
- package/dist/InputNumberExperimental-es.js +2 -3
- package/dist/Menu/index.cjs +1 -2
- package/dist/Menu/index.mjs +1 -2
- package/dist/Menu-cjs.js +11 -56
- package/dist/Menu-es.js +4 -49
- package/dist/MenuSubmenuTrigger-cjs.js +160 -345
- package/dist/MenuSubmenuTrigger-es.js +4 -186
- package/dist/Modal/index.mjs +1 -1
- package/dist/NumberFieldInput-cjs.js +3 -4
- package/dist/NumberFieldInput-es.js +2 -3
- package/dist/Page/index.cjs +1 -2
- package/dist/Page/index.mjs +1 -2
- package/dist/{DrawerRoot-cjs.js → ScrollAreaViewport-cjs.js} +1042 -3
- package/dist/{DrawerRoot-es.js → ScrollAreaViewport-es.js} +1035 -5
- package/dist/floating-ui.react-es.js +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.mjs +1 -2
- package/dist/primitives/BottomSheet/BottomSheet.d.ts +15 -16
- package/dist/primitives/BottomSheet/BottomSheet.types.d.ts +27 -0
- package/dist/primitives/BottomSheet/BottomSheet.utils.d.ts +6 -0
- package/dist/primitives/BottomSheet/index.cjs +7 -2
- package/dist/primitives/BottomSheet/index.d.ts +1 -0
- package/dist/primitives/BottomSheet/index.mjs +7 -2
- package/dist/primitives/InputNumberExperimental/index.cjs +1 -2
- package/dist/primitives/InputNumberExperimental/index.mjs +1 -2
- package/dist/primitives/index.cjs +7 -8
- package/dist/primitives/index.mjs +7 -8
- package/dist/styles.css +62 -1
- package/dist/unstyledPrimitives/index.cjs +665 -297
- package/dist/unstyledPrimitives/index.d.ts +1 -0
- package/dist/unstyledPrimitives/index.mjs +375 -8
- package/dist/useRenderElement-es.js +1 -1
- package/dist/useValueChanged-cjs.js +251 -1
- package/dist/useValueChanged-es.js +248 -2
- package/package.json +2 -2
- package/dist/useBaseUiId-cjs.js +0 -275
- package/dist/useBaseUiId-es.js +0 -251
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var ScrollAreaViewport = require('./ScrollAreaViewport-cjs.js');
|
|
5
5
|
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
6
6
|
var useValueChanged = require('./useValueChanged-cjs.js');
|
|
7
|
-
var useBaseUiId = require('./useBaseUiId-cjs.js');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
var floatingUi_utils_dom = require('./floating-ui.utils.dom-cjs.js');
|
|
10
9
|
var index_esm = require('./index.esm-cjs.js');
|
|
@@ -47,7 +46,7 @@ const DialogClose = /*#__PURE__*/React__namespace.forwardRef(function DialogClos
|
|
|
47
46
|
} = componentProps;
|
|
48
47
|
const {
|
|
49
48
|
store
|
|
50
|
-
} =
|
|
49
|
+
} = ScrollAreaViewport.useDialogRootContext();
|
|
51
50
|
const open = store.useState('open');
|
|
52
51
|
function handleClick(event) {
|
|
53
52
|
if (open) {
|
|
@@ -57,7 +56,7 @@ const DialogClose = /*#__PURE__*/React__namespace.forwardRef(function DialogClos
|
|
|
57
56
|
const {
|
|
58
57
|
getButtonProps,
|
|
59
58
|
buttonRef
|
|
60
|
-
} =
|
|
59
|
+
} = useValueChanged.useButton({
|
|
61
60
|
disabled,
|
|
62
61
|
native: nativeButton
|
|
63
62
|
});
|
|
@@ -108,109 +107,6 @@ function isClickLikeOpenEvent(openEventType, interactedInside) {
|
|
|
108
107
|
return interactedInside || openEventType === 'click' || openEventType === 'mousedown';
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
/**
|
|
112
|
-
* Opens or closes the floating element when clicking the reference element.
|
|
113
|
-
* @see https://floating-ui.com/docs/useClick
|
|
114
|
-
*/
|
|
115
|
-
function useClick(context, props = {}) {
|
|
116
|
-
const store = 'rootStore' in context ? context.rootStore : context;
|
|
117
|
-
const dataRef = store.context.dataRef;
|
|
118
|
-
const {
|
|
119
|
-
enabled = true,
|
|
120
|
-
event: eventOption = 'click',
|
|
121
|
-
toggle = true,
|
|
122
|
-
ignoreMouse = false,
|
|
123
|
-
stickIfOpen = true,
|
|
124
|
-
touchOpenDelay = 0,
|
|
125
|
-
reason = useValueChanged.triggerPress
|
|
126
|
-
} = props;
|
|
127
|
-
const pointerTypeRef = React__namespace.useRef(undefined);
|
|
128
|
-
const frame = useValueChanged.useAnimationFrame();
|
|
129
|
-
const touchOpenTimeout = useValueChanged.useTimeout();
|
|
130
|
-
const reference = React__namespace.useMemo(() => ({
|
|
131
|
-
onPointerDown(event) {
|
|
132
|
-
pointerTypeRef.current = event.pointerType;
|
|
133
|
-
},
|
|
134
|
-
onMouseDown(event) {
|
|
135
|
-
const pointerType = pointerTypeRef.current;
|
|
136
|
-
const nativeEvent = event.nativeEvent;
|
|
137
|
-
const open = store.select('open');
|
|
138
|
-
|
|
139
|
-
// Ignore all buttons except for the "main" button.
|
|
140
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
141
|
-
if (event.button !== 0 || eventOption === 'click' || useValueChanged.isMouseLikePointerType(pointerType, true) && ignoreMouse) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const openEvent = dataRef.current.openEvent;
|
|
145
|
-
const openEventType = openEvent?.type;
|
|
146
|
-
const hasClickedOnInactiveTrigger = store.select('domReferenceElement') !== event.currentTarget;
|
|
147
|
-
const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? openEventType === 'click' || openEventType === 'mousedown' : true));
|
|
148
|
-
|
|
149
|
-
// Animations sometimes won't run on a typeable element if using a rAF.
|
|
150
|
-
// Focus is always set on these elements. For touch, we may delay opening.
|
|
151
|
-
if (DrawerRoot.isTypeableElement(nativeEvent.target)) {
|
|
152
|
-
const details = useValueChanged.createChangeEventDetails(reason, nativeEvent, nativeEvent.target);
|
|
153
|
-
if (nextOpen && pointerType === 'touch' && touchOpenDelay > 0) {
|
|
154
|
-
touchOpenTimeout.start(touchOpenDelay, () => {
|
|
155
|
-
store.setOpen(true, details);
|
|
156
|
-
});
|
|
157
|
-
} else {
|
|
158
|
-
store.setOpen(nextOpen, details);
|
|
159
|
-
}
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Capture the currentTarget before the rAF.
|
|
164
|
-
// as React sets it to null after the event handler completes.
|
|
165
|
-
const eventCurrentTarget = event.currentTarget;
|
|
166
|
-
|
|
167
|
-
// Wait until focus is set on the element. This is an alternative to
|
|
168
|
-
// `event.preventDefault()` to avoid :focus-visible from appearing when using a pointer.
|
|
169
|
-
frame.request(() => {
|
|
170
|
-
const details = useValueChanged.createChangeEventDetails(reason, nativeEvent, eventCurrentTarget);
|
|
171
|
-
if (nextOpen && pointerType === 'touch' && touchOpenDelay > 0) {
|
|
172
|
-
touchOpenTimeout.start(touchOpenDelay, () => {
|
|
173
|
-
store.setOpen(true, details);
|
|
174
|
-
});
|
|
175
|
-
} else {
|
|
176
|
-
store.setOpen(nextOpen, details);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
},
|
|
180
|
-
onClick(event) {
|
|
181
|
-
if (eventOption === 'mousedown-only') {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const pointerType = pointerTypeRef.current;
|
|
185
|
-
if (eventOption === 'mousedown' && pointerType) {
|
|
186
|
-
pointerTypeRef.current = undefined;
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (useValueChanged.isMouseLikePointerType(pointerType, true) && ignoreMouse) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
const open = store.select('open');
|
|
193
|
-
const openEvent = dataRef.current.openEvent;
|
|
194
|
-
const hasClickedOnInactiveTrigger = store.select('domReferenceElement') !== event.currentTarget;
|
|
195
|
-
const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? useValueChanged.isClickLikeEvent(openEvent) : true));
|
|
196
|
-
const details = useValueChanged.createChangeEventDetails(reason, event.nativeEvent, event.currentTarget);
|
|
197
|
-
if (nextOpen && pointerType === 'touch' && touchOpenDelay > 0) {
|
|
198
|
-
touchOpenTimeout.start(touchOpenDelay, () => {
|
|
199
|
-
store.setOpen(true, details);
|
|
200
|
-
});
|
|
201
|
-
} else {
|
|
202
|
-
store.setOpen(nextOpen, details);
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
onKeyDown() {
|
|
206
|
-
pointerTypeRef.current = undefined;
|
|
207
|
-
}
|
|
208
|
-
}), [dataRef, eventOption, ignoreMouse, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay, reason]);
|
|
209
|
-
return React__namespace.useMemo(() => enabled ? {
|
|
210
|
-
reference
|
|
211
|
-
} : useRenderElement.EMPTY_OBJECT, [enabled, reference]);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
110
|
function useFloatingRootContext(options) {
|
|
215
111
|
const {
|
|
216
112
|
open = false,
|
|
@@ -218,19 +114,19 @@ function useFloatingRootContext(options) {
|
|
|
218
114
|
elements = {}
|
|
219
115
|
} = options;
|
|
220
116
|
const floatingId = useValueChanged.useId();
|
|
221
|
-
const nested =
|
|
117
|
+
const nested = ScrollAreaViewport.useFloatingParentNodeId() != null;
|
|
222
118
|
if (process.env.NODE_ENV !== 'production') {
|
|
223
119
|
const optionDomReference = elements.reference;
|
|
224
120
|
if (optionDomReference && !floatingUi_utils_dom.isElement(optionDomReference)) {
|
|
225
121
|
console.error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `context.setPositionReference()`', 'instead.');
|
|
226
122
|
}
|
|
227
123
|
}
|
|
228
|
-
const store = useRenderElement.useRefWithInit(() => new
|
|
124
|
+
const store = useRenderElement.useRefWithInit(() => new ScrollAreaViewport.FloatingRootStore({
|
|
229
125
|
open,
|
|
230
126
|
onOpenChange,
|
|
231
127
|
referenceElement: elements.reference ?? null,
|
|
232
128
|
floatingElement: elements.floating ?? null,
|
|
233
|
-
triggerElements: new
|
|
129
|
+
triggerElements: new ScrollAreaViewport.PopupTriggerMap(),
|
|
234
130
|
floatingId,
|
|
235
131
|
nested,
|
|
236
132
|
noEmit: false
|
|
@@ -275,7 +171,7 @@ function useFloating(options = {}) {
|
|
|
275
171
|
};
|
|
276
172
|
const [positionReference, setPositionReferenceRaw] = React__namespace.useState(null);
|
|
277
173
|
const domReferenceRef = React__namespace.useRef(null);
|
|
278
|
-
const tree =
|
|
174
|
+
const tree = ScrollAreaViewport.useFloatingTree(externalTree);
|
|
279
175
|
useValueChanged.useIsoLayoutEffect(() => {
|
|
280
176
|
if (rootContextElements.domReference) {
|
|
281
177
|
domReferenceRef.current = rootContextElements.domReference;
|
|
@@ -400,7 +296,7 @@ function useFocus(context, props = {}) {
|
|
|
400
296
|
// return to the tab/window.
|
|
401
297
|
function onBlur() {
|
|
402
298
|
const currentDomReference = store.select('domReferenceElement');
|
|
403
|
-
if (!store.select('open') && floatingUi_utils_dom.isHTMLElement(currentDomReference) && currentDomReference ===
|
|
299
|
+
if (!store.select('open') && floatingUi_utils_dom.isHTMLElement(currentDomReference) && currentDomReference === ScrollAreaViewport.activeElement(useValueChanged.ownerDocument(currentDomReference))) {
|
|
404
300
|
blockFocusRef.current = true;
|
|
405
301
|
}
|
|
406
302
|
}
|
|
@@ -455,19 +351,19 @@ function useFocus(context, props = {}) {
|
|
|
455
351
|
blockFocusRef.current = false;
|
|
456
352
|
blockedReferenceRef.current = null;
|
|
457
353
|
}
|
|
458
|
-
const target =
|
|
354
|
+
const target = ScrollAreaViewport.getTarget(event.nativeEvent);
|
|
459
355
|
if (floatingUi_utils_dom.isElement(target)) {
|
|
460
356
|
// Safari fails to match `:focus-visible` if focus was initially
|
|
461
357
|
// outside the document.
|
|
462
358
|
if (isMacSafari && !event.relatedTarget) {
|
|
463
|
-
if (!keyboardModalityRef.current && !
|
|
359
|
+
if (!keyboardModalityRef.current && !ScrollAreaViewport.isTypeableElement(target)) {
|
|
464
360
|
return;
|
|
465
361
|
}
|
|
466
|
-
} else if (!
|
|
362
|
+
} else if (!ScrollAreaViewport.matchesFocusVisible(target)) {
|
|
467
363
|
return;
|
|
468
364
|
}
|
|
469
365
|
}
|
|
470
|
-
const movedFromOtherEnabledTrigger =
|
|
366
|
+
const movedFromOtherEnabledTrigger = ScrollAreaViewport.isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
|
|
471
367
|
const {
|
|
472
368
|
nativeEvent,
|
|
473
369
|
currentTarget
|
|
@@ -492,12 +388,12 @@ function useFocus(context, props = {}) {
|
|
|
492
388
|
|
|
493
389
|
// Hit the non-modal focus management portal guard. Focus will be
|
|
494
390
|
// moved into the floating element immediately after.
|
|
495
|
-
const movedToFocusGuard = floatingUi_utils_dom.isElement(relatedTarget) && relatedTarget.hasAttribute(
|
|
391
|
+
const movedToFocusGuard = floatingUi_utils_dom.isElement(relatedTarget) && relatedTarget.hasAttribute(ScrollAreaViewport.createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';
|
|
496
392
|
|
|
497
393
|
// Wait for the window blur listener to fire.
|
|
498
394
|
timeout.start(0, () => {
|
|
499
395
|
const domReference = store.select('domReferenceElement');
|
|
500
|
-
const activeEl =
|
|
396
|
+
const activeEl = ScrollAreaViewport.activeElement(domReference ? domReference.ownerDocument : document);
|
|
501
397
|
|
|
502
398
|
// Focus left the page, keep it open.
|
|
503
399
|
if (!relatedTarget && activeEl === domReference) {
|
|
@@ -511,7 +407,7 @@ function useFocus(context, props = {}) {
|
|
|
511
407
|
// as it will only point to the shadow host of the newly focused element
|
|
512
408
|
// and not the element that actually has received focus if it is located
|
|
513
409
|
// inside a shadow root.
|
|
514
|
-
if (
|
|
410
|
+
if (ScrollAreaViewport.contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || ScrollAreaViewport.contains(domReference, activeEl) || movedToFocusGuard) {
|
|
515
411
|
return;
|
|
516
412
|
}
|
|
517
413
|
|
|
@@ -519,7 +415,7 @@ function useFocus(context, props = {}) {
|
|
|
519
415
|
// the floating element. The focus handler of that trigger will
|
|
520
416
|
// handle the open state.
|
|
521
417
|
const nextFocusedElement = relatedTarget ?? activeEl;
|
|
522
|
-
if (
|
|
418
|
+
if (ScrollAreaViewport.isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
|
|
523
419
|
return;
|
|
524
420
|
}
|
|
525
421
|
store.setOpen(false, useValueChanged.createChangeEventDetails(useValueChanged.triggerFocus, nativeEvent));
|
|
@@ -532,7 +428,7 @@ function useFocus(context, props = {}) {
|
|
|
532
428
|
} : {}, [enabled, reference]);
|
|
533
429
|
}
|
|
534
430
|
|
|
535
|
-
const interactiveSelector = `button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${
|
|
431
|
+
const interactiveSelector = `button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${ScrollAreaViewport.TYPEABLE_SELECTOR}`;
|
|
536
432
|
function isInteractiveElement(element) {
|
|
537
433
|
return element ? Boolean(element.closest(interactiveSelector)) : false;
|
|
538
434
|
}
|
|
@@ -615,8 +511,8 @@ function useHoverFloatingInteraction(context, parameters = {}) {
|
|
|
615
511
|
closeDelay: closeDelayProp = 0
|
|
616
512
|
} = parameters;
|
|
617
513
|
const instance = useHoverInteractionSharedState(store);
|
|
618
|
-
const tree =
|
|
619
|
-
const parentId =
|
|
514
|
+
const tree = ScrollAreaViewport.useFloatingTree();
|
|
515
|
+
const parentId = ScrollAreaViewport.useFloatingParentNodeId();
|
|
620
516
|
const isClickLikeOpenEvent$1 = useValueChanged.useStableCallback(() => {
|
|
621
517
|
return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
|
|
622
518
|
});
|
|
@@ -625,7 +521,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
|
|
|
625
521
|
return type?.includes('mouse') && type !== 'mousedown';
|
|
626
522
|
});
|
|
627
523
|
const isRelatedTargetInsideEnabledTrigger = useValueChanged.useStableCallback(target => {
|
|
628
|
-
return
|
|
524
|
+
return ScrollAreaViewport.isTargetInsideEnabledTrigger(target, store.context.triggerElements);
|
|
629
525
|
});
|
|
630
526
|
const closeWithDelay = React__namespace.useCallback(event => {
|
|
631
527
|
const closeDelay = getDelay(closeDelayProp, 'close', instance.pointerType);
|
|
@@ -644,7 +540,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
|
|
|
644
540
|
clearSafePolygonPointerEventsMutation(instance);
|
|
645
541
|
});
|
|
646
542
|
const handleInteractInside = useValueChanged.useStableCallback(event => {
|
|
647
|
-
const target =
|
|
543
|
+
const target = ScrollAreaViewport.getTarget(event);
|
|
648
544
|
if (!isInteractiveElement(target)) {
|
|
649
545
|
instance.interactedInside = false;
|
|
650
546
|
return;
|
|
@@ -698,7 +594,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
|
|
|
698
594
|
clearPointerEvents();
|
|
699
595
|
}
|
|
700
596
|
function onFloatingMouseLeave(event) {
|
|
701
|
-
if (tree && parentId &&
|
|
597
|
+
if (tree && parentId && ScrollAreaViewport.getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
|
|
702
598
|
tree.events.on('floating.closed', onNodeClosed);
|
|
703
599
|
return;
|
|
704
600
|
}
|
|
@@ -719,7 +615,7 @@ function useHoverFloatingInteraction(context, parameters = {}) {
|
|
|
719
615
|
}
|
|
720
616
|
}
|
|
721
617
|
function onNodeClosed(event) {
|
|
722
|
-
if (!tree || !parentId ||
|
|
618
|
+
if (!tree || !parentId || ScrollAreaViewport.getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
|
|
723
619
|
return;
|
|
724
620
|
}
|
|
725
621
|
// Allow the mouseenter event to fire in case child was closed because mouse moved into parent.
|
|
@@ -772,7 +668,7 @@ function useHoverReferenceInteraction(context, props = {}) {
|
|
|
772
668
|
isActiveTrigger = true,
|
|
773
669
|
getHandleCloseContext
|
|
774
670
|
} = props;
|
|
775
|
-
const tree =
|
|
671
|
+
const tree = ScrollAreaViewport.useFloatingTree(externalTree);
|
|
776
672
|
const instance = useHoverInteractionSharedState(store);
|
|
777
673
|
const handleCloseRef = useValueChanged.useValueAsRef(handleClose);
|
|
778
674
|
const delayRef = useValueChanged.useValueAsRef(delay);
|
|
@@ -786,14 +682,14 @@ function useHoverReferenceInteraction(context, props = {}) {
|
|
|
786
682
|
return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
|
|
787
683
|
});
|
|
788
684
|
const isRelatedTargetInsideEnabledTrigger = useValueChanged.useStableCallback(target => {
|
|
789
|
-
return
|
|
685
|
+
return ScrollAreaViewport.isTargetInsideEnabledTrigger(target, store.context.triggerElements);
|
|
790
686
|
});
|
|
791
687
|
const isOverInactiveTrigger = useValueChanged.useStableCallback((currentDomReference, currentTarget, target) => {
|
|
792
688
|
const allTriggers = store.context.triggerElements;
|
|
793
689
|
|
|
794
690
|
// Fast path for normal usage where handlers are attached directly to triggers.
|
|
795
691
|
if (allTriggers.hasElement(currentTarget)) {
|
|
796
|
-
return !currentDomReference || !
|
|
692
|
+
return !currentDomReference || !ScrollAreaViewport.contains(currentDomReference, currentTarget);
|
|
797
693
|
}
|
|
798
694
|
|
|
799
695
|
// Fallback for delegated/wrapper usage where currentTarget may be outside the trigger map.
|
|
@@ -801,7 +697,7 @@ function useHoverReferenceInteraction(context, props = {}) {
|
|
|
801
697
|
return false;
|
|
802
698
|
}
|
|
803
699
|
const targetElement = target;
|
|
804
|
-
return allTriggers.hasMatchingElement(trigger =>
|
|
700
|
+
return allTriggers.hasMatchingElement(trigger => ScrollAreaViewport.contains(trigger, targetElement)) && (!currentDomReference || !ScrollAreaViewport.contains(currentDomReference, targetElement));
|
|
805
701
|
});
|
|
806
702
|
const closeWithDelay = React__namespace.useCallback((event, runElseBranch = true) => {
|
|
807
703
|
const closeDelay = getDelay(delayRef.current, 'close', instance.pointerType);
|
|
@@ -927,7 +823,7 @@ function useHoverReferenceInteraction(context, props = {}) {
|
|
|
927
823
|
instance.handler(event);
|
|
928
824
|
return;
|
|
929
825
|
}
|
|
930
|
-
const shouldClose = instance.pointerType === 'touch' ? !
|
|
826
|
+
const shouldClose = instance.pointerType === 'touch' ? !ScrollAreaViewport.contains(store.select('floatingElement'), event.relatedTarget) : true;
|
|
931
827
|
if (shouldClose) {
|
|
932
828
|
closeWithDelay(event);
|
|
933
829
|
}
|
|
@@ -1016,23 +912,23 @@ function doSwitch(orientation, vertical, horizontal) {
|
|
|
1016
912
|
}
|
|
1017
913
|
}
|
|
1018
914
|
function isMainOrientationKey(key, orientation) {
|
|
1019
|
-
const vertical = key ===
|
|
1020
|
-
const horizontal = key ===
|
|
915
|
+
const vertical = key === ScrollAreaViewport.ARROW_UP || key === ScrollAreaViewport.ARROW_DOWN;
|
|
916
|
+
const horizontal = key === ScrollAreaViewport.ARROW_LEFT || key === ScrollAreaViewport.ARROW_RIGHT;
|
|
1021
917
|
return doSwitch(orientation, vertical, horizontal);
|
|
1022
918
|
}
|
|
1023
919
|
function isMainOrientationToEndKey(key, orientation, rtl) {
|
|
1024
|
-
const vertical = key ===
|
|
1025
|
-
const horizontal = rtl ? key ===
|
|
920
|
+
const vertical = key === ScrollAreaViewport.ARROW_DOWN;
|
|
921
|
+
const horizontal = rtl ? key === ScrollAreaViewport.ARROW_LEFT : key === ScrollAreaViewport.ARROW_RIGHT;
|
|
1026
922
|
return doSwitch(orientation, vertical, horizontal) || key === 'Enter' || key === ' ' || key === '';
|
|
1027
923
|
}
|
|
1028
924
|
function isCrossOrientationOpenKey(key, orientation, rtl) {
|
|
1029
|
-
const vertical = rtl ? key ===
|
|
1030
|
-
const horizontal = key ===
|
|
925
|
+
const vertical = rtl ? key === ScrollAreaViewport.ARROW_LEFT : key === ScrollAreaViewport.ARROW_RIGHT;
|
|
926
|
+
const horizontal = key === ScrollAreaViewport.ARROW_DOWN;
|
|
1031
927
|
return doSwitch(orientation, vertical, horizontal);
|
|
1032
928
|
}
|
|
1033
929
|
function isCrossOrientationCloseKey(key, orientation, rtl, cols) {
|
|
1034
|
-
const vertical = rtl ? key ===
|
|
1035
|
-
const horizontal = key ===
|
|
930
|
+
const vertical = rtl ? key === ScrollAreaViewport.ARROW_RIGHT : key === ScrollAreaViewport.ARROW_LEFT;
|
|
931
|
+
const horizontal = key === ScrollAreaViewport.ARROW_UP;
|
|
1036
932
|
if (orientation === 'both' || orientation === 'horizontal' && cols && cols > 1) {
|
|
1037
933
|
return key === ESCAPE;
|
|
1038
934
|
}
|
|
@@ -1084,14 +980,14 @@ function useListNavigation(context, props) {
|
|
|
1084
980
|
console.warn('In grid list navigation mode (`cols` > 1), the `orientation` should', 'be either "horizontal" or "both".');
|
|
1085
981
|
}
|
|
1086
982
|
}
|
|
1087
|
-
const floatingFocusElement =
|
|
983
|
+
const floatingFocusElement = ScrollAreaViewport.getFloatingFocusElement(floatingElement);
|
|
1088
984
|
const floatingFocusElementRef = useValueChanged.useValueAsRef(floatingFocusElement);
|
|
1089
|
-
const parentId =
|
|
1090
|
-
const tree =
|
|
985
|
+
const parentId = ScrollAreaViewport.useFloatingParentNodeId();
|
|
986
|
+
const tree = ScrollAreaViewport.useFloatingTree(externalTree);
|
|
1091
987
|
useValueChanged.useIsoLayoutEffect(() => {
|
|
1092
988
|
dataRef.current.orientation = orientation;
|
|
1093
989
|
}, [dataRef, orientation]);
|
|
1094
|
-
const typeableComboboxReference =
|
|
990
|
+
const typeableComboboxReference = ScrollAreaViewport.isTypeableCombobox(domReferenceElement);
|
|
1095
991
|
const focusItemOnOpenRef = React__namespace.useRef(focusItemOnOpen);
|
|
1096
992
|
const indexRef = React__namespace.useRef(selectedIndex ?? -1);
|
|
1097
993
|
const keyRef = React__namespace.useRef(null);
|
|
@@ -1113,7 +1009,7 @@ function useListNavigation(context, props) {
|
|
|
1113
1009
|
if (virtual) {
|
|
1114
1010
|
tree?.events.emit('virtualfocus', item);
|
|
1115
1011
|
} else {
|
|
1116
|
-
|
|
1012
|
+
ScrollAreaViewport.enqueueFocus(item, {
|
|
1117
1013
|
sync: forceSyncFocusRef.current,
|
|
1118
1014
|
preventScroll: true
|
|
1119
1015
|
});
|
|
@@ -1210,14 +1106,14 @@ function useListNavigation(context, props) {
|
|
|
1210
1106
|
runs += 1;
|
|
1211
1107
|
} else {
|
|
1212
1108
|
// initially focus the first non-disabled item
|
|
1213
|
-
indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ?
|
|
1109
|
+
indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? ScrollAreaViewport.getMinListIndex(listRef) : ScrollAreaViewport.getMaxListIndex(listRef);
|
|
1214
1110
|
keyRef.current = null;
|
|
1215
1111
|
onNavigate();
|
|
1216
1112
|
}
|
|
1217
1113
|
};
|
|
1218
1114
|
waitForListPopulated();
|
|
1219
1115
|
}
|
|
1220
|
-
} else if (!
|
|
1116
|
+
} else if (!ScrollAreaViewport.isIndexOutOfListBounds(listRef, activeIndex)) {
|
|
1221
1117
|
indexRef.current = activeIndex;
|
|
1222
1118
|
focusItem();
|
|
1223
1119
|
forceScrollIntoViewRef.current = false;
|
|
@@ -1232,8 +1128,8 @@ function useListNavigation(context, props) {
|
|
|
1232
1128
|
}
|
|
1233
1129
|
const nodes = tree.nodesRef.current;
|
|
1234
1130
|
const parent = nodes.find(node => node.id === parentId)?.context?.elements.floating;
|
|
1235
|
-
const activeEl =
|
|
1236
|
-
const treeContainsActiveEl = nodes.some(node => node.context &&
|
|
1131
|
+
const activeEl = ScrollAreaViewport.activeElement(useValueChanged.ownerDocument(floatingElement));
|
|
1132
|
+
const treeContainsActiveEl = nodes.some(node => node.context && ScrollAreaViewport.contains(node.context.elements.floating, activeEl));
|
|
1237
1133
|
if (parent && !treeContainsActiveEl && isPointerModalityRef.current) {
|
|
1238
1134
|
parent.focus({
|
|
1239
1135
|
preventScroll: true
|
|
@@ -1293,15 +1189,15 @@ function useListNavigation(context, props) {
|
|
|
1293
1189
|
if (!resetOnPointerLeaveRef.current) {
|
|
1294
1190
|
return;
|
|
1295
1191
|
}
|
|
1296
|
-
|
|
1192
|
+
ScrollAreaViewport.enqueueFocus(null, {
|
|
1297
1193
|
sync: true
|
|
1298
1194
|
});
|
|
1299
1195
|
indexRef.current = -1;
|
|
1300
1196
|
onNavigate(event);
|
|
1301
1197
|
if (!virtual) {
|
|
1302
1198
|
const floatingFocusEl = floatingFocusElementRef.current;
|
|
1303
|
-
const activeEl =
|
|
1304
|
-
if (floatingFocusEl &&
|
|
1199
|
+
const activeEl = ScrollAreaViewport.activeElement(useValueChanged.ownerDocument(floatingFocusEl));
|
|
1200
|
+
if (floatingFocusEl && ScrollAreaViewport.contains(floatingFocusEl, activeEl)) {
|
|
1305
1201
|
floatingFocusEl.focus({
|
|
1306
1202
|
preventScroll: true
|
|
1307
1203
|
});
|
|
@@ -1349,8 +1245,8 @@ function useListNavigation(context, props) {
|
|
|
1349
1245
|
return;
|
|
1350
1246
|
}
|
|
1351
1247
|
const currentIndex = indexRef.current;
|
|
1352
|
-
const minIndex =
|
|
1353
|
-
const maxIndex =
|
|
1248
|
+
const minIndex = ScrollAreaViewport.getMinListIndex(listRef, disabledIndices);
|
|
1249
|
+
const maxIndex = ScrollAreaViewport.getMaxListIndex(listRef, disabledIndices);
|
|
1354
1250
|
if (!typeableComboboxReference) {
|
|
1355
1251
|
if (event.key === 'Home') {
|
|
1356
1252
|
useValueChanged.stopEvent(event);
|
|
@@ -1374,11 +1270,11 @@ function useListNavigation(context, props) {
|
|
|
1374
1270
|
}));
|
|
1375
1271
|
// To calculate movements on the grid, we use hypothetical cell indices
|
|
1376
1272
|
// as if every item was 1x1, then convert back to real indices.
|
|
1377
|
-
const cellMap =
|
|
1378
|
-
const minGridIndex = cellMap.findIndex(index => index != null && !
|
|
1273
|
+
const cellMap = ScrollAreaViewport.createGridCellMap(sizes, cols);
|
|
1274
|
+
const minGridIndex = cellMap.findIndex(index => index != null && !ScrollAreaViewport.isListIndexDisabled(listRef, index, disabledIndices));
|
|
1379
1275
|
// last enabled index
|
|
1380
|
-
const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !
|
|
1381
|
-
const index = cellMap[
|
|
1276
|
+
const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !ScrollAreaViewport.isListIndexDisabled(listRef, index, disabledIndices) ? cellIndex : foundIndex, -1);
|
|
1277
|
+
const index = cellMap[ScrollAreaViewport.getGridNavigatedIndex({
|
|
1382
1278
|
current: cellMap.map(itemIndex => itemIndex != null ? listRef.current[itemIndex] : null)
|
|
1383
1279
|
}, {
|
|
1384
1280
|
event,
|
|
@@ -1388,15 +1284,15 @@ function useListNavigation(context, props) {
|
|
|
1388
1284
|
cols,
|
|
1389
1285
|
// treat undefined (empty grid spaces) as disabled indices so we
|
|
1390
1286
|
// don't end up in them
|
|
1391
|
-
disabledIndices:
|
|
1287
|
+
disabledIndices: ScrollAreaViewport.getGridCellIndices([...((typeof disabledIndices !== 'function' ? disabledIndices : null) || listRef.current.map((_, listIndex) => ScrollAreaViewport.isListIndexDisabled(listRef, listIndex, disabledIndices) ? listIndex : undefined)), undefined], cellMap),
|
|
1392
1288
|
minIndex: minGridIndex,
|
|
1393
1289
|
maxIndex: maxGridIndex,
|
|
1394
|
-
prevIndex:
|
|
1290
|
+
prevIndex: ScrollAreaViewport.getGridCellIndexOfCorner(indexRef.current > maxIndex ? minIndex : indexRef.current, sizes, cellMap, cols,
|
|
1395
1291
|
// use a corner matching the edge closest to the direction
|
|
1396
1292
|
// we're moving in so we don't end up in the same item. Prefer
|
|
1397
1293
|
// top/left over bottom/right.
|
|
1398
1294
|
// eslint-disable-next-line no-nested-ternary
|
|
1399
|
-
event.key ===
|
|
1295
|
+
event.key === ScrollAreaViewport.ARROW_DOWN ? 'bl' : event.key === (rtl ? ScrollAreaViewport.ARROW_LEFT : ScrollAreaViewport.ARROW_RIGHT) ? 'tr' : 'tl'),
|
|
1400
1296
|
stopEvent: true
|
|
1401
1297
|
})];
|
|
1402
1298
|
if (index != null) {
|
|
@@ -1411,7 +1307,7 @@ function useListNavigation(context, props) {
|
|
|
1411
1307
|
useValueChanged.stopEvent(event);
|
|
1412
1308
|
|
|
1413
1309
|
// Reset the index if no item is focused.
|
|
1414
|
-
if (open && !virtual &&
|
|
1310
|
+
if (open && !virtual && ScrollAreaViewport.activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {
|
|
1415
1311
|
indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
|
|
1416
1312
|
onNavigate(event);
|
|
1417
1313
|
return;
|
|
@@ -1427,13 +1323,13 @@ function useListNavigation(context, props) {
|
|
|
1427
1323
|
indexRef.current = minIndex;
|
|
1428
1324
|
}
|
|
1429
1325
|
} else {
|
|
1430
|
-
indexRef.current =
|
|
1326
|
+
indexRef.current = ScrollAreaViewport.findNonDisabledListIndex(listRef, {
|
|
1431
1327
|
startingIndex: currentIndex,
|
|
1432
1328
|
disabledIndices
|
|
1433
1329
|
});
|
|
1434
1330
|
}
|
|
1435
1331
|
} else {
|
|
1436
|
-
indexRef.current = Math.min(maxIndex,
|
|
1332
|
+
indexRef.current = Math.min(maxIndex, ScrollAreaViewport.findNonDisabledListIndex(listRef, {
|
|
1437
1333
|
startingIndex: currentIndex,
|
|
1438
1334
|
disabledIndices
|
|
1439
1335
|
}));
|
|
@@ -1448,20 +1344,20 @@ function useListNavigation(context, props) {
|
|
|
1448
1344
|
indexRef.current = maxIndex;
|
|
1449
1345
|
}
|
|
1450
1346
|
} else {
|
|
1451
|
-
indexRef.current =
|
|
1347
|
+
indexRef.current = ScrollAreaViewport.findNonDisabledListIndex(listRef, {
|
|
1452
1348
|
startingIndex: currentIndex,
|
|
1453
1349
|
decrement: true,
|
|
1454
1350
|
disabledIndices
|
|
1455
1351
|
});
|
|
1456
1352
|
}
|
|
1457
1353
|
} else {
|
|
1458
|
-
indexRef.current = Math.max(minIndex,
|
|
1354
|
+
indexRef.current = Math.max(minIndex, ScrollAreaViewport.findNonDisabledListIndex(listRef, {
|
|
1459
1355
|
startingIndex: currentIndex,
|
|
1460
1356
|
decrement: true,
|
|
1461
1357
|
disabledIndices
|
|
1462
1358
|
}));
|
|
1463
1359
|
}
|
|
1464
|
-
if (
|
|
1360
|
+
if (ScrollAreaViewport.isIndexOutOfListBounds(listRef, indexRef.current)) {
|
|
1465
1361
|
indexRef.current = -1;
|
|
1466
1362
|
}
|
|
1467
1363
|
onNavigate(event);
|
|
@@ -1482,8 +1378,8 @@ function useListNavigation(context, props) {
|
|
|
1482
1378
|
// If the event originated from within a nested element (e.g., a Dialog opened from
|
|
1483
1379
|
// within the menu), don't close the menu. The nested element has its own focus
|
|
1484
1380
|
// management and should handle the Tab key.
|
|
1485
|
-
const target =
|
|
1486
|
-
if (target && !
|
|
1381
|
+
const target = ScrollAreaViewport.getTarget(event.nativeEvent);
|
|
1382
|
+
if (target && !ScrollAreaViewport.contains(floatingFocusElementRef.current, target)) {
|
|
1487
1383
|
return;
|
|
1488
1384
|
}
|
|
1489
1385
|
useValueChanged.stopEvent(event);
|
|
@@ -1539,7 +1435,7 @@ function useListNavigation(context, props) {
|
|
|
1539
1435
|
if (isParentCrossOpenKey) {
|
|
1540
1436
|
useValueChanged.stopEvent(event);
|
|
1541
1437
|
if (currentOpen) {
|
|
1542
|
-
indexRef.current =
|
|
1438
|
+
indexRef.current = ScrollAreaViewport.getMinListIndex(listRef, disabledIndicesRef.current);
|
|
1543
1439
|
onNavigate(event);
|
|
1544
1440
|
} else {
|
|
1545
1441
|
store.setOpen(true, useValueChanged.createChangeEventDetails(useValueChanged.listNavigation, event.nativeEvent, event.currentTarget));
|
|
@@ -1642,7 +1538,7 @@ function useTypeahead(context, props) {
|
|
|
1642
1538
|
const onKeyDown = useValueChanged.useStableCallback(event => {
|
|
1643
1539
|
function isVisible(index) {
|
|
1644
1540
|
const element = elementsRef?.current[index];
|
|
1645
|
-
return !element ||
|
|
1541
|
+
return !element || ScrollAreaViewport.isElementVisible(element);
|
|
1646
1542
|
}
|
|
1647
1543
|
function getMatchingIndex(list, string, startIndex = 0) {
|
|
1648
1544
|
if (list.length === 0) {
|
|
@@ -1724,8 +1620,8 @@ function useTypeahead(context, props) {
|
|
|
1724
1620
|
const next = event.relatedTarget;
|
|
1725
1621
|
const currentDomReferenceElement = store.select('domReferenceElement');
|
|
1726
1622
|
const currentFloatingElement = store.select('floatingElement');
|
|
1727
|
-
const withinReference =
|
|
1728
|
-
const withinFloating =
|
|
1623
|
+
const withinReference = ScrollAreaViewport.contains(currentDomReferenceElement, next);
|
|
1624
|
+
const withinFloating = ScrollAreaViewport.contains(currentFloatingElement, next);
|
|
1729
1625
|
|
|
1730
1626
|
// Keep the session if focus moves within the composite (reference <-> floating).
|
|
1731
1627
|
if (withinReference || withinFloating) {
|
|
@@ -1845,10 +1741,10 @@ function safePolygon(options = {}) {
|
|
|
1845
1741
|
clientX,
|
|
1846
1742
|
clientY
|
|
1847
1743
|
} = event;
|
|
1848
|
-
const target =
|
|
1744
|
+
const target = ScrollAreaViewport.getTarget(event);
|
|
1849
1745
|
const isLeave = event.type === 'mouseleave';
|
|
1850
|
-
const isOverFloatingEl =
|
|
1851
|
-
const isOverReferenceEl =
|
|
1746
|
+
const isOverFloatingEl = ScrollAreaViewport.contains(floating, target);
|
|
1747
|
+
const isOverReferenceEl = ScrollAreaViewport.contains(domReference, target);
|
|
1852
1748
|
if (isOverFloatingEl) {
|
|
1853
1749
|
hasLanded = true;
|
|
1854
1750
|
if (!isLeave) {
|
|
@@ -1865,11 +1761,11 @@ function safePolygon(options = {}) {
|
|
|
1865
1761
|
|
|
1866
1762
|
// Prevent overlapping floating element from being stuck in an open-close
|
|
1867
1763
|
// loop: https://github.com/floating-ui/floating-ui/issues/1910
|
|
1868
|
-
if (isLeave && floatingUi_utils_dom.isElement(event.relatedTarget) &&
|
|
1764
|
+
if (isLeave && floatingUi_utils_dom.isElement(event.relatedTarget) && ScrollAreaViewport.contains(floating, event.relatedTarget)) {
|
|
1869
1765
|
return undefined;
|
|
1870
1766
|
}
|
|
1871
1767
|
function hasOpenChildNode() {
|
|
1872
|
-
return Boolean(tree &&
|
|
1768
|
+
return Boolean(tree && ScrollAreaViewport.getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
|
|
1873
1769
|
}
|
|
1874
1770
|
function closeIfNoOpenChild() {
|
|
1875
1771
|
if (!hasOpenChildNode()) {
|
|
@@ -2010,8 +1906,8 @@ const DialogTitle = /*#__PURE__*/React__namespace.forwardRef(function DialogTitl
|
|
|
2010
1906
|
} = componentProps;
|
|
2011
1907
|
const {
|
|
2012
1908
|
store
|
|
2013
|
-
} =
|
|
2014
|
-
const id =
|
|
1909
|
+
} = ScrollAreaViewport.useDialogRootContext();
|
|
1910
|
+
const id = useValueChanged.useBaseUiId(idProp);
|
|
2015
1911
|
store.useSyncedValueWithCleanup('titleElementId', id);
|
|
2016
1912
|
return useRenderElement.useRenderElement('h2', componentProps, {
|
|
2017
1913
|
ref: forwardedRef,
|
|
@@ -2022,66 +1918,6 @@ const DialogTitle = /*#__PURE__*/React__namespace.forwardRef(function DialogTitl
|
|
|
2022
1918
|
});
|
|
2023
1919
|
if (process.env.NODE_ENV !== "production") DialogTitle.displayName = "DialogTitle";
|
|
2024
1920
|
|
|
2025
|
-
/**
|
|
2026
|
-
* A button that opens the dialog.
|
|
2027
|
-
* Renders a `<button>` element.
|
|
2028
|
-
*
|
|
2029
|
-
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
2030
|
-
*/
|
|
2031
|
-
const DialogTrigger = /*#__PURE__*/React__namespace.forwardRef(function DialogTrigger(componentProps, forwardedRef) {
|
|
2032
|
-
const {
|
|
2033
|
-
render,
|
|
2034
|
-
className,
|
|
2035
|
-
disabled = false,
|
|
2036
|
-
nativeButton = true,
|
|
2037
|
-
id: idProp,
|
|
2038
|
-
payload,
|
|
2039
|
-
handle,
|
|
2040
|
-
...elementProps
|
|
2041
|
-
} = componentProps;
|
|
2042
|
-
const dialogRootContext = DrawerRoot.useDialogRootContext(true);
|
|
2043
|
-
const store = handle?.store ?? dialogRootContext?.store;
|
|
2044
|
-
if (!store) {
|
|
2045
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle.' : useRenderElement.formatErrorMessage(79));
|
|
2046
|
-
}
|
|
2047
|
-
const thisTriggerId = useBaseUiId.useBaseUiId(idProp);
|
|
2048
|
-
const floatingContext = store.useState('floatingRootContext');
|
|
2049
|
-
const isOpenedByThisTrigger = store.useState('isOpenedByTrigger', thisTriggerId);
|
|
2050
|
-
const triggerElementRef = React__namespace.useRef(null);
|
|
2051
|
-
const {
|
|
2052
|
-
registerTrigger,
|
|
2053
|
-
isMountedByThisTrigger
|
|
2054
|
-
} = DrawerRoot.useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
|
|
2055
|
-
payload
|
|
2056
|
-
});
|
|
2057
|
-
const {
|
|
2058
|
-
getButtonProps,
|
|
2059
|
-
buttonRef
|
|
2060
|
-
} = useBaseUiId.useButton({
|
|
2061
|
-
disabled,
|
|
2062
|
-
native: nativeButton
|
|
2063
|
-
});
|
|
2064
|
-
const click = useClick(floatingContext, {
|
|
2065
|
-
enabled: floatingContext != null
|
|
2066
|
-
});
|
|
2067
|
-
const localInteractionProps = DrawerRoot.useInteractions([click]);
|
|
2068
|
-
const state = {
|
|
2069
|
-
disabled,
|
|
2070
|
-
open: isOpenedByThisTrigger
|
|
2071
|
-
};
|
|
2072
|
-
const rootTriggerProps = store.useState('triggerProps', isMountedByThisTrigger);
|
|
2073
|
-
return useRenderElement.useRenderElement('button', componentProps, {
|
|
2074
|
-
state,
|
|
2075
|
-
ref: [buttonRef, forwardedRef, registerTrigger, triggerElementRef],
|
|
2076
|
-
props: [localInteractionProps.getReferenceProps(), rootTriggerProps, {
|
|
2077
|
-
[DrawerRoot.CLICK_TRIGGER_IDENTIFIER]: '',
|
|
2078
|
-
id: thisTriggerId
|
|
2079
|
-
}, elementProps, getButtonProps],
|
|
2080
|
-
stateAttributesMapping: DrawerRoot.triggerOpenStateMapping
|
|
2081
|
-
});
|
|
2082
|
-
});
|
|
2083
|
-
if (process.env.NODE_ENV !== "production") DialogTrigger.displayName = "DialogTrigger";
|
|
2084
|
-
|
|
2085
1921
|
/**
|
|
2086
1922
|
* A heading that labels the drawer.
|
|
2087
1923
|
* Renders an `<h2>` element.
|
|
@@ -2090,14 +1926,6 @@ if (process.env.NODE_ENV !== "production") DialogTrigger.displayName = "DialogTr
|
|
|
2090
1926
|
*/
|
|
2091
1927
|
const DrawerTitle = DialogTitle;
|
|
2092
1928
|
|
|
2093
|
-
/**
|
|
2094
|
-
* A button that opens the drawer.
|
|
2095
|
-
* Renders a `<button>` element.
|
|
2096
|
-
*
|
|
2097
|
-
* Documentation: [Base UI Drawer](https://base-ui.com/react/components/drawer)
|
|
2098
|
-
*/
|
|
2099
|
-
const DrawerTrigger = DialogTrigger;
|
|
2100
|
-
|
|
2101
1929
|
const MenuPositionerContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
2102
1930
|
if (process.env.NODE_ENV !== "production") MenuPositionerContext.displayName = "MenuPositionerContext";
|
|
2103
1931
|
function useMenuPositionerContext(optional) {
|
|
@@ -2222,7 +2050,7 @@ function useMenuItem(params) {
|
|
|
2222
2050
|
const {
|
|
2223
2051
|
getButtonProps,
|
|
2224
2052
|
buttonRef
|
|
2225
|
-
} =
|
|
2053
|
+
} = useValueChanged.useButton({
|
|
2226
2054
|
disabled,
|
|
2227
2055
|
focusableWhenDisabled: true,
|
|
2228
2056
|
native: nativeButton,
|
|
@@ -2430,7 +2258,7 @@ const MenuGroupLabel = /*#__PURE__*/React__namespace.forwardRef(function MenuGro
|
|
|
2430
2258
|
id: idProp,
|
|
2431
2259
|
...elementProps
|
|
2432
2260
|
} = componentProps;
|
|
2433
|
-
const id =
|
|
2261
|
+
const id = useValueChanged.useBaseUiId(idProp);
|
|
2434
2262
|
const {
|
|
2435
2263
|
setLabelId
|
|
2436
2264
|
} = useMenuGroupRootContext();
|
|
@@ -2472,7 +2300,7 @@ const MenuItem = /*#__PURE__*/React__namespace.forwardRef(function MenuItem(comp
|
|
|
2472
2300
|
label
|
|
2473
2301
|
});
|
|
2474
2302
|
const menuPositionerContext = useMenuPositionerContext(true);
|
|
2475
|
-
const id =
|
|
2303
|
+
const id = useValueChanged.useBaseUiId(idProp);
|
|
2476
2304
|
const {
|
|
2477
2305
|
store
|
|
2478
2306
|
} = useMenuRootContext();
|
|
@@ -2524,7 +2352,7 @@ const MenuLinkItem = /*#__PURE__*/React__namespace.forwardRef(function MenuLinkI
|
|
|
2524
2352
|
});
|
|
2525
2353
|
const menuPositionerContext = useMenuPositionerContext(true);
|
|
2526
2354
|
const nodeId = menuPositionerContext?.nodeId;
|
|
2527
|
-
const id =
|
|
2355
|
+
const id = useValueChanged.useBaseUiId(idProp);
|
|
2528
2356
|
const {
|
|
2529
2357
|
store
|
|
2530
2358
|
} = useMenuRootContext();
|
|
@@ -2534,7 +2362,7 @@ const MenuLinkItem = /*#__PURE__*/React__namespace.forwardRef(function MenuLinkI
|
|
|
2534
2362
|
const {
|
|
2535
2363
|
getButtonProps,
|
|
2536
2364
|
buttonRef
|
|
2537
|
-
} =
|
|
2365
|
+
} = useValueChanged.useButton({
|
|
2538
2366
|
native: false,
|
|
2539
2367
|
composite: true
|
|
2540
2368
|
});
|
|
@@ -2572,11 +2400,11 @@ function useToolbarRootContext(optional) {
|
|
|
2572
2400
|
}
|
|
2573
2401
|
|
|
2574
2402
|
function getDisabledMountTransitionStyles(transitionStatus) {
|
|
2575
|
-
return transitionStatus === 'starting' ?
|
|
2403
|
+
return transitionStatus === 'starting' ? ScrollAreaViewport.DISABLED_TRANSITIONS_STYLE : useRenderElement.EMPTY_OBJECT;
|
|
2576
2404
|
}
|
|
2577
2405
|
|
|
2578
2406
|
const stateAttributesMapping = {
|
|
2579
|
-
...
|
|
2407
|
+
...ScrollAreaViewport.popupStateMapping,
|
|
2580
2408
|
...useValueChanged.transitionStatusMapping
|
|
2581
2409
|
};
|
|
2582
2410
|
|
|
@@ -2656,7 +2484,7 @@ const MenuPopup = /*#__PURE__*/React__namespace.forwardRef(function MenuPopup(co
|
|
|
2656
2484
|
stateAttributesMapping,
|
|
2657
2485
|
props: [popupProps, {
|
|
2658
2486
|
onKeyDown(event) {
|
|
2659
|
-
if (insideToolbar &&
|
|
2487
|
+
if (insideToolbar && ScrollAreaViewport.COMPOSITE_KEYS.has(event.key)) {
|
|
2660
2488
|
event.stopPropagation();
|
|
2661
2489
|
}
|
|
2662
2490
|
}
|
|
@@ -2668,7 +2496,7 @@ const MenuPopup = /*#__PURE__*/React__namespace.forwardRef(function MenuPopup(co
|
|
|
2668
2496
|
if (triggerElement || parent.type === 'menubar' && lastOpenChangeReason !== useValueChanged.outsidePress) {
|
|
2669
2497
|
returnFocus = true;
|
|
2670
2498
|
}
|
|
2671
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
2499
|
+
return /*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.FloatingFocusManager, {
|
|
2672
2500
|
context: floatingContext,
|
|
2673
2501
|
modal: isContextMenu,
|
|
2674
2502
|
disabled: !mounted,
|
|
@@ -2709,7 +2537,7 @@ const MenuPortal = /*#__PURE__*/React__namespace.forwardRef(function MenuPortal(
|
|
|
2709
2537
|
}
|
|
2710
2538
|
return /*#__PURE__*/jsxRuntime.jsx(MenuPortalContext.Provider, {
|
|
2711
2539
|
value: keepMounted,
|
|
2712
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
2540
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.FloatingPortal, {
|
|
2713
2541
|
ref: forwardedRef,
|
|
2714
2542
|
...portalProps
|
|
2715
2543
|
})
|
|
@@ -2717,16 +2545,6 @@ const MenuPortal = /*#__PURE__*/React__namespace.forwardRef(function MenuPortal(
|
|
|
2717
2545
|
});
|
|
2718
2546
|
if (process.env.NODE_ENV !== "production") MenuPortal.displayName = "MenuPortal";
|
|
2719
2547
|
|
|
2720
|
-
/**
|
|
2721
|
-
* @internal
|
|
2722
|
-
*/
|
|
2723
|
-
const DirectionContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
2724
|
-
if (process.env.NODE_ENV !== "production") DirectionContext.displayName = "DirectionContext";
|
|
2725
|
-
function useDirection() {
|
|
2726
|
-
const context = React__namespace.useContext(DirectionContext);
|
|
2727
|
-
return context?.direction ?? 'ltr';
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
2548
|
/**
|
|
2731
2549
|
* Fork of the original `arrow` middleware from Floating UI that allows
|
|
2732
2550
|
* configuring the offset parent.
|
|
@@ -2983,7 +2801,7 @@ function useAnchorPositioning(params) {
|
|
|
2983
2801
|
const anchorFnCallback = useValueChanged.useStableCallback(anchorFn);
|
|
2984
2802
|
const anchorDep = anchorFn ? anchorFnCallback : anchor;
|
|
2985
2803
|
const anchorValueRef = useValueChanged.useValueAsRef(anchor);
|
|
2986
|
-
const direction = useDirection();
|
|
2804
|
+
const direction = ScrollAreaViewport.useDirection();
|
|
2987
2805
|
const isRtl = direction === 'rtl';
|
|
2988
2806
|
const side = mountSide || {
|
|
2989
2807
|
top: 'top',
|
|
@@ -3456,7 +3274,7 @@ const MenuPositioner = /*#__PURE__*/React__namespace.forwardRef(function MenuPos
|
|
|
3456
3274
|
arrowPadding = 5,
|
|
3457
3275
|
sticky = false,
|
|
3458
3276
|
disableAnchorTracking = false,
|
|
3459
|
-
collisionAvoidance: collisionAvoidanceProp =
|
|
3277
|
+
collisionAvoidance: collisionAvoidanceProp = ScrollAreaViewport.DROPDOWN_COLLISION_AVOIDANCE,
|
|
3460
3278
|
...elementProps
|
|
3461
3279
|
} = componentProps;
|
|
3462
3280
|
const {
|
|
@@ -3499,7 +3317,7 @@ const MenuPositioner = /*#__PURE__*/React__namespace.forwardRef(function MenuPos
|
|
|
3499
3317
|
if (parent.type === 'menu') {
|
|
3500
3318
|
computedSide = computedSide ?? 'inline-end';
|
|
3501
3319
|
computedAlign = computedAlign ?? 'start';
|
|
3502
|
-
collisionAvoidance = componentProps.collisionAvoidance ??
|
|
3320
|
+
collisionAvoidance = componentProps.collisionAvoidance ?? ScrollAreaViewport.POPUP_COLLISION_AVOIDANCE;
|
|
3503
3321
|
} else if (parent.type === 'menubar') {
|
|
3504
3322
|
computedSide = computedSide ?? 'bottom';
|
|
3505
3323
|
computedAlign = computedAlign ?? 'start';
|
|
@@ -3657,7 +3475,7 @@ const MenuPositioner = /*#__PURE__*/React__namespace.forwardRef(function MenuPos
|
|
|
3657
3475
|
}), [positioner.side, positioner.align, positioner.arrowRef, positioner.arrowUncentered, positioner.arrowStyles, positioner.context.nodeId]);
|
|
3658
3476
|
const element = useRenderElement.useRenderElement('div', componentProps, {
|
|
3659
3477
|
state,
|
|
3660
|
-
stateAttributesMapping:
|
|
3478
|
+
stateAttributesMapping: ScrollAreaViewport.popupStateMapping,
|
|
3661
3479
|
ref: [forwardedRef, store.useStateSetter('positionerElement')],
|
|
3662
3480
|
props: [positionerProps, getDisabledMountTransitionStyles(transitionStatus), elementProps]
|
|
3663
3481
|
});
|
|
@@ -3672,11 +3490,11 @@ const MenuPositioner = /*#__PURE__*/React__namespace.forwardRef(function MenuPos
|
|
|
3672
3490
|
}
|
|
3673
3491
|
return /*#__PURE__*/jsxRuntime.jsxs(MenuPositionerContext.Provider, {
|
|
3674
3492
|
value: contextValue,
|
|
3675
|
-
children: [shouldRenderBackdrop && /*#__PURE__*/jsxRuntime.jsx(
|
|
3493
|
+
children: [shouldRenderBackdrop && /*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.InternalBackdrop, {
|
|
3676
3494
|
ref: parent.type === 'context-menu' || parent.type === 'nested-context-menu' ? parent.context.internalBackdropRef : null,
|
|
3677
|
-
inert:
|
|
3495
|
+
inert: ScrollAreaViewport.inertValue(!open),
|
|
3678
3496
|
cutout: backdropCutout
|
|
3679
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
3497
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.FloatingNode, {
|
|
3680
3498
|
id: floatingNodeId,
|
|
3681
3499
|
children: /*#__PURE__*/jsxRuntime.jsx(CompositeList, {
|
|
3682
3500
|
elementsRef: store.context.itemDomElements,
|
|
@@ -3777,7 +3595,7 @@ const MenuRadioItem = /*#__PURE__*/React__namespace.forwardRef(function MenuRadi
|
|
|
3777
3595
|
label
|
|
3778
3596
|
});
|
|
3779
3597
|
const menuPositionerContext = useMenuPositionerContext(true);
|
|
3780
|
-
const id =
|
|
3598
|
+
const id = useValueChanged.useBaseUiId(idProp);
|
|
3781
3599
|
const {
|
|
3782
3600
|
store
|
|
3783
3601
|
} = useMenuRootContext();
|
|
@@ -3891,35 +3709,35 @@ function useMenubarContext(optional) {
|
|
|
3891
3709
|
}
|
|
3892
3710
|
|
|
3893
3711
|
const selectors = {
|
|
3894
|
-
...
|
|
3895
|
-
disabled:
|
|
3896
|
-
modal:
|
|
3897
|
-
allowMouseEnter:
|
|
3898
|
-
stickIfOpen:
|
|
3899
|
-
parent:
|
|
3900
|
-
rootId:
|
|
3712
|
+
...ScrollAreaViewport.popupStoreSelectors,
|
|
3713
|
+
disabled: ScrollAreaViewport.createSelector(state => state.parent.type === 'menubar' ? state.parent.context.disabled || state.disabled : state.disabled),
|
|
3714
|
+
modal: ScrollAreaViewport.createSelector(state => (state.parent.type === undefined || state.parent.type === 'context-menu') && (state.modal ?? true)),
|
|
3715
|
+
allowMouseEnter: ScrollAreaViewport.createSelector(state => state.allowMouseEnter),
|
|
3716
|
+
stickIfOpen: ScrollAreaViewport.createSelector(state => state.stickIfOpen),
|
|
3717
|
+
parent: ScrollAreaViewport.createSelector(state => state.parent),
|
|
3718
|
+
rootId: ScrollAreaViewport.createSelector(state => {
|
|
3901
3719
|
if (state.parent.type === 'menu') {
|
|
3902
3720
|
return state.parent.store.select('rootId');
|
|
3903
3721
|
}
|
|
3904
3722
|
return state.parent.type !== undefined ? state.parent.context.rootId : state.rootId;
|
|
3905
3723
|
}),
|
|
3906
|
-
activeIndex:
|
|
3907
|
-
isActive:
|
|
3908
|
-
hoverEnabled:
|
|
3909
|
-
instantType:
|
|
3910
|
-
lastOpenChangeReason:
|
|
3911
|
-
floatingTreeRoot:
|
|
3724
|
+
activeIndex: ScrollAreaViewport.createSelector(state => state.activeIndex),
|
|
3725
|
+
isActive: ScrollAreaViewport.createSelector((state, itemIndex) => state.activeIndex === itemIndex),
|
|
3726
|
+
hoverEnabled: ScrollAreaViewport.createSelector(state => state.hoverEnabled),
|
|
3727
|
+
instantType: ScrollAreaViewport.createSelector(state => state.instantType),
|
|
3728
|
+
lastOpenChangeReason: ScrollAreaViewport.createSelector(state => state.openChangeReason),
|
|
3729
|
+
floatingTreeRoot: ScrollAreaViewport.createSelector(state => {
|
|
3912
3730
|
if (state.parent.type === 'menu') {
|
|
3913
3731
|
return state.parent.store.select('floatingTreeRoot');
|
|
3914
3732
|
}
|
|
3915
3733
|
return state.floatingTreeRoot;
|
|
3916
3734
|
}),
|
|
3917
|
-
floatingNodeId:
|
|
3918
|
-
floatingParentNodeId:
|
|
3919
|
-
itemProps:
|
|
3920
|
-
closeDelay:
|
|
3921
|
-
hasViewport:
|
|
3922
|
-
keyboardEventRelay:
|
|
3735
|
+
floatingNodeId: ScrollAreaViewport.createSelector(state => state.floatingNodeId),
|
|
3736
|
+
floatingParentNodeId: ScrollAreaViewport.createSelector(state => state.floatingParentNodeId),
|
|
3737
|
+
itemProps: ScrollAreaViewport.createSelector(state => state.itemProps),
|
|
3738
|
+
closeDelay: ScrollAreaViewport.createSelector(state => state.closeDelay),
|
|
3739
|
+
hasViewport: ScrollAreaViewport.createSelector(state => state.hasViewport),
|
|
3740
|
+
keyboardEventRelay: ScrollAreaViewport.createSelector(state => {
|
|
3923
3741
|
if (state.keyboardEventRelay) {
|
|
3924
3742
|
return state.keyboardEventRelay;
|
|
3925
3743
|
}
|
|
@@ -3929,7 +3747,7 @@ const selectors = {
|
|
|
3929
3747
|
return undefined;
|
|
3930
3748
|
})
|
|
3931
3749
|
};
|
|
3932
|
-
class MenuStore extends
|
|
3750
|
+
class MenuStore extends ScrollAreaViewport.ReactStore {
|
|
3933
3751
|
constructor(initialState) {
|
|
3934
3752
|
super({
|
|
3935
3753
|
...createInitialState(),
|
|
@@ -3952,7 +3770,7 @@ class MenuStore extends DrawerRoot.ReactStore {
|
|
|
3952
3770
|
triggerFocusTargetRef: /*#__PURE__*/React__namespace.createRef(),
|
|
3953
3771
|
beforeContentFocusGuardRef: /*#__PURE__*/React__namespace.createRef(),
|
|
3954
3772
|
onOpenChangeComplete: undefined,
|
|
3955
|
-
triggerElements: new
|
|
3773
|
+
triggerElements: new ScrollAreaViewport.PopupTriggerMap()
|
|
3956
3774
|
}, selectors);
|
|
3957
3775
|
|
|
3958
3776
|
// Set up propagation of state from parent menu if applicable.
|
|
@@ -4000,7 +3818,7 @@ class MenuStore extends DrawerRoot.ReactStore {
|
|
|
4000
3818
|
}
|
|
4001
3819
|
function createInitialState() {
|
|
4002
3820
|
return {
|
|
4003
|
-
...
|
|
3821
|
+
...ScrollAreaViewport.createInitialPopupStoreState(),
|
|
4004
3822
|
disabled: false,
|
|
4005
3823
|
modal: true,
|
|
4006
3824
|
allowMouseEnter: false,
|
|
@@ -4013,7 +3831,7 @@ function createInitialState() {
|
|
|
4013
3831
|
hoverEnabled: true,
|
|
4014
3832
|
instantType: undefined,
|
|
4015
3833
|
openChangeReason: null,
|
|
4016
|
-
floatingTreeRoot: new
|
|
3834
|
+
floatingTreeRoot: new ScrollAreaViewport.FloatingTreeStore(),
|
|
4017
3835
|
floatingNodeId: undefined,
|
|
4018
3836
|
floatingParentNodeId: null,
|
|
4019
3837
|
itemProps: useRenderElement.EMPTY_OBJECT,
|
|
@@ -4029,7 +3847,7 @@ function useMenuSubmenuRootContext() {
|
|
|
4029
3847
|
return React__namespace.useContext(MenuSubmenuRootContext);
|
|
4030
3848
|
}
|
|
4031
3849
|
|
|
4032
|
-
const MenuRoot =
|
|
3850
|
+
const MenuRoot = ScrollAreaViewport.fastComponent(function MenuRoot(props) {
|
|
4033
3851
|
const {
|
|
4034
3852
|
children,
|
|
4035
3853
|
open: openProp,
|
|
@@ -4087,7 +3905,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4087
3905
|
});
|
|
4088
3906
|
|
|
4089
3907
|
// Support initially open state when uncontrolled
|
|
4090
|
-
|
|
3908
|
+
ScrollAreaViewport.useOnFirstRender(() => {
|
|
4091
3909
|
if (openProp === undefined && store.state.open === false && defaultOpen === true) {
|
|
4092
3910
|
store.update({
|
|
4093
3911
|
open: true,
|
|
@@ -4099,8 +3917,8 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4099
3917
|
store.useControlledProp('triggerIdProp', triggerIdProp);
|
|
4100
3918
|
store.useContextCallback('onOpenChangeComplete', onOpenChangeComplete);
|
|
4101
3919
|
const floatingTreeRoot = store.useState('floatingTreeRoot');
|
|
4102
|
-
const floatingNodeIdFromContext =
|
|
4103
|
-
const floatingParentNodeIdFromContext =
|
|
3920
|
+
const floatingNodeIdFromContext = ScrollAreaViewport.useFloatingNodeId(floatingTreeRoot);
|
|
3921
|
+
const floatingParentNodeIdFromContext = ScrollAreaViewport.useFloatingParentNodeId();
|
|
4104
3922
|
useValueChanged.useIsoLayoutEffect(() => {
|
|
4105
3923
|
if (contextMenuContext && !parentMenuRootContext) {
|
|
4106
3924
|
// This is a context menu root.
|
|
@@ -4147,11 +3965,11 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4147
3965
|
const {
|
|
4148
3966
|
openMethod,
|
|
4149
3967
|
triggerProps: interactionTypeProps
|
|
4150
|
-
} =
|
|
4151
|
-
|
|
3968
|
+
} = ScrollAreaViewport.useOpenInteractionType(open);
|
|
3969
|
+
ScrollAreaViewport.useImplicitActiveTrigger(store);
|
|
4152
3970
|
const {
|
|
4153
3971
|
forceUnmount
|
|
4154
|
-
} =
|
|
3972
|
+
} = ScrollAreaViewport.useOpenStateTransitions(open, store, () => {
|
|
4155
3973
|
store.update({
|
|
4156
3974
|
allowMouseEnter: false,
|
|
4157
3975
|
stickIfOpen: true
|
|
@@ -4179,7 +3997,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4179
3997
|
allowOutsidePressDismissalRef.current = true;
|
|
4180
3998
|
});
|
|
4181
3999
|
}, [allowOutsidePressDismissalTimeout, open, parent.type]);
|
|
4182
|
-
|
|
4000
|
+
ScrollAreaViewport.useScrollLock(open && modal && lastOpenChangeReason !== useValueChanged.triggerHover && openMethod !== 'touch', positionerElement);
|
|
4183
4001
|
useValueChanged.useIsoLayoutEffect(() => {
|
|
4184
4002
|
if (!open && !hoverEnabled) {
|
|
4185
4003
|
store.set('hoverEnabled', true);
|
|
@@ -4288,7 +4106,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4288
4106
|
React__namespace.useImperativeHandle(ctx?.actionsRef, () => ({
|
|
4289
4107
|
setOpen
|
|
4290
4108
|
}), [setOpen]);
|
|
4291
|
-
const floatingRootContext =
|
|
4109
|
+
const floatingRootContext = ScrollAreaViewport.useSyncedFloatingRootContext({
|
|
4292
4110
|
popupStore: store,
|
|
4293
4111
|
onOpenChange: setOpen
|
|
4294
4112
|
});
|
|
@@ -4303,7 +4121,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4303
4121
|
floatingEvents?.off('setOpen', handleSetOpenEvent);
|
|
4304
4122
|
};
|
|
4305
4123
|
}, [floatingEvents, setOpen]);
|
|
4306
|
-
const dismiss =
|
|
4124
|
+
const dismiss = ScrollAreaViewport.useDismiss(floatingRootContext, {
|
|
4307
4125
|
enabled: !disabled,
|
|
4308
4126
|
bubbles: {
|
|
4309
4127
|
escapeKey: closeParentOnEsc && parent.type === 'menu'
|
|
@@ -4316,10 +4134,10 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4316
4134
|
},
|
|
4317
4135
|
externalTree: nested ? floatingTreeRoot : undefined
|
|
4318
4136
|
});
|
|
4319
|
-
const role =
|
|
4137
|
+
const role = ScrollAreaViewport.useRole(floatingRootContext, {
|
|
4320
4138
|
role: 'menu'
|
|
4321
4139
|
});
|
|
4322
|
-
const direction = useDirection();
|
|
4140
|
+
const direction = ScrollAreaViewport.useDirection();
|
|
4323
4141
|
const setActiveIndex = React__namespace.useCallback(index => {
|
|
4324
4142
|
if (store.select('activeIndex') === index) {
|
|
4325
4143
|
return;
|
|
@@ -4348,7 +4166,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4348
4166
|
listRef: store.context.itemLabels,
|
|
4349
4167
|
elementsRef: store.context.itemDomElements,
|
|
4350
4168
|
activeIndex,
|
|
4351
|
-
resetMs:
|
|
4169
|
+
resetMs: ScrollAreaViewport.TYPEAHEAD_RESET_MS,
|
|
4352
4170
|
onMatch: index => {
|
|
4353
4171
|
if (open && index !== activeIndex) {
|
|
4354
4172
|
store.set('activeIndex', index);
|
|
@@ -4361,7 +4179,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4361
4179
|
getFloatingProps,
|
|
4362
4180
|
getItemProps,
|
|
4363
4181
|
getTriggerProps
|
|
4364
|
-
} =
|
|
4182
|
+
} = ScrollAreaViewport.useInteractions([dismiss, role, listNavigation, typeahead]);
|
|
4365
4183
|
const activeTriggerProps = React__namespace.useMemo(() => {
|
|
4366
4184
|
const mergedProps = useRenderElement.mergeProps(getReferenceProps(), {
|
|
4367
4185
|
onMouseMove() {
|
|
@@ -4423,7 +4241,7 @@ const MenuRoot = DrawerRoot.fastComponent(function MenuRoot(props) {
|
|
|
4423
4241
|
});
|
|
4424
4242
|
if (parent.type === undefined || parent.type === 'context-menu') {
|
|
4425
4243
|
// set up a FloatingTree to provide the context to nested menus
|
|
4426
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
4244
|
+
return /*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.FloatingTree, {
|
|
4427
4245
|
externalTree: floatingTreeRoot,
|
|
4428
4246
|
children: content
|
|
4429
4247
|
});
|
|
@@ -4491,7 +4309,7 @@ function useCompositeItem(params = {}) {
|
|
|
4491
4309
|
highlightItemOnHover,
|
|
4492
4310
|
highlightedIndex,
|
|
4493
4311
|
onHighlightedIndexChange
|
|
4494
|
-
} =
|
|
4312
|
+
} = useValueChanged.useCompositeRootContext();
|
|
4495
4313
|
const {
|
|
4496
4314
|
ref,
|
|
4497
4315
|
index
|
|
@@ -4606,7 +4424,7 @@ const BOUNDARY_OFFSET = 2;
|
|
|
4606
4424
|
*
|
|
4607
4425
|
* Documentation: [Base UI Menu](https://base-ui.com/react/components/menu)
|
|
4608
4426
|
*/
|
|
4609
|
-
const MenuTrigger =
|
|
4427
|
+
const MenuTrigger = ScrollAreaViewport.fastComponentRef(function MenuTrigger(componentProps, forwardedRef) {
|
|
4610
4428
|
const {
|
|
4611
4429
|
render,
|
|
4612
4430
|
className,
|
|
@@ -4625,23 +4443,23 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4625
4443
|
if (!store) {
|
|
4626
4444
|
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: <Menu.Trigger> must be either used within a <Menu.Root> component or provided with a handle.' : useRenderElement.formatErrorMessage(85));
|
|
4627
4445
|
}
|
|
4628
|
-
const thisTriggerId =
|
|
4446
|
+
const thisTriggerId = useValueChanged.useBaseUiId(idProp);
|
|
4629
4447
|
const isTriggerActive = store.useState('isTriggerActive', thisTriggerId);
|
|
4630
4448
|
const floatingRootContext = store.useState('floatingRootContext');
|
|
4631
4449
|
const isOpenedByThisTrigger = store.useState('isOpenedByTrigger', thisTriggerId);
|
|
4632
4450
|
const triggerElementRef = React__namespace.useRef(null);
|
|
4633
4451
|
const parent = useMenuParent();
|
|
4634
|
-
const compositeRootContext =
|
|
4635
|
-
const floatingTreeRootFromContext =
|
|
4452
|
+
const compositeRootContext = useValueChanged.useCompositeRootContext(true);
|
|
4453
|
+
const floatingTreeRootFromContext = ScrollAreaViewport.useFloatingTree();
|
|
4636
4454
|
const floatingTreeRoot = React__namespace.useMemo(() => {
|
|
4637
|
-
return floatingTreeRootFromContext ?? new
|
|
4455
|
+
return floatingTreeRootFromContext ?? new ScrollAreaViewport.FloatingTreeStore();
|
|
4638
4456
|
}, [floatingTreeRootFromContext]);
|
|
4639
|
-
const floatingNodeId =
|
|
4640
|
-
const floatingParentNodeId =
|
|
4457
|
+
const floatingNodeId = ScrollAreaViewport.useFloatingNodeId(floatingTreeRoot);
|
|
4458
|
+
const floatingParentNodeId = ScrollAreaViewport.useFloatingParentNodeId();
|
|
4641
4459
|
const {
|
|
4642
4460
|
registerTrigger,
|
|
4643
4461
|
isMountedByThisTrigger
|
|
4644
|
-
} =
|
|
4462
|
+
} = ScrollAreaViewport.useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
|
|
4645
4463
|
payload,
|
|
4646
4464
|
closeDelay,
|
|
4647
4465
|
parent,
|
|
@@ -4656,7 +4474,7 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4656
4474
|
const {
|
|
4657
4475
|
getButtonProps,
|
|
4658
4476
|
buttonRef
|
|
4659
|
-
} =
|
|
4477
|
+
} = useValueChanged.useButton({
|
|
4660
4478
|
disabled,
|
|
4661
4479
|
native: nativeButton
|
|
4662
4480
|
});
|
|
@@ -4674,7 +4492,7 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4674
4492
|
allowMouseUpTriggerTimeout.clear();
|
|
4675
4493
|
store.context.allowMouseUpTriggerRef.current = false;
|
|
4676
4494
|
const mouseUpTarget = mouseEvent.target;
|
|
4677
|
-
if (
|
|
4495
|
+
if (ScrollAreaViewport.contains(triggerRef.current, mouseUpTarget) || ScrollAreaViewport.contains(store.select('positionerElement'), mouseUpTarget) || mouseUpTarget === triggerRef.current) {
|
|
4678
4496
|
return;
|
|
4679
4497
|
}
|
|
4680
4498
|
if (mouseUpTarget != null && findRootOwnerId(mouseUpTarget) === store.select('rootId')) {
|
|
@@ -4719,7 +4537,7 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4719
4537
|
// `lastOpenChangeReason` doesn't need to be reactive here, as we need to run this
|
|
4720
4538
|
// only when `isOpenedByThisTrigger` changes.
|
|
4721
4539
|
const stickIfOpen = useStickIfOpen(isOpenedByThisTrigger, store.select('lastOpenChangeReason'));
|
|
4722
|
-
const click = useClick(floatingRootContext, {
|
|
4540
|
+
const click = ScrollAreaViewport.useClick(floatingRootContext, {
|
|
4723
4541
|
enabled: !disabled && parent.type !== 'context-menu',
|
|
4724
4542
|
event: isOpenedByThisTrigger && isInMenubar ? 'click' : 'mousedown',
|
|
4725
4543
|
toggle: true,
|
|
@@ -4734,7 +4552,7 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4734
4552
|
enabled: isInMenubar,
|
|
4735
4553
|
mouseDownAction: 'open'
|
|
4736
4554
|
});
|
|
4737
|
-
const localInteractionProps =
|
|
4555
|
+
const localInteractionProps = ScrollAreaViewport.useInteractions([click, focus]);
|
|
4738
4556
|
const state = {
|
|
4739
4557
|
disabled,
|
|
4740
4558
|
open: isOpenedByThisTrigger
|
|
@@ -4766,21 +4584,21 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4766
4584
|
ReactDOM__namespace.flushSync(() => {
|
|
4767
4585
|
store.setOpen(false, useValueChanged.createChangeEventDetails(useValueChanged.focusOut, event.nativeEvent, event.currentTarget));
|
|
4768
4586
|
});
|
|
4769
|
-
const previousTabbable =
|
|
4587
|
+
const previousTabbable = ScrollAreaViewport.getTabbableBeforeElement(preFocusGuardRef.current);
|
|
4770
4588
|
previousTabbable?.focus();
|
|
4771
4589
|
});
|
|
4772
4590
|
const handleFocusTargetFocus = useValueChanged.useStableCallback(event => {
|
|
4773
4591
|
const currentPositionerElement = store.select('positionerElement');
|
|
4774
|
-
if (currentPositionerElement &&
|
|
4592
|
+
if (currentPositionerElement && ScrollAreaViewport.isOutsideEvent(event, currentPositionerElement)) {
|
|
4775
4593
|
store.context.beforeContentFocusGuardRef.current?.focus();
|
|
4776
4594
|
} else {
|
|
4777
4595
|
ReactDOM__namespace.flushSync(() => {
|
|
4778
4596
|
store.setOpen(false, useValueChanged.createChangeEventDetails(useValueChanged.focusOut, event.nativeEvent, event.currentTarget));
|
|
4779
4597
|
});
|
|
4780
|
-
let nextTabbable =
|
|
4781
|
-
while (nextTabbable !== null &&
|
|
4598
|
+
let nextTabbable = ScrollAreaViewport.getTabbableAfterElement(store.context.triggerFocusTargetRef.current || triggerElementRef.current);
|
|
4599
|
+
while (nextTabbable !== null && ScrollAreaViewport.contains(currentPositionerElement, nextTabbable)) {
|
|
4782
4600
|
const prevTabbable = nextTabbable;
|
|
4783
|
-
nextTabbable =
|
|
4601
|
+
nextTabbable = ScrollAreaViewport.getNextTabbable(nextTabbable);
|
|
4784
4602
|
if (nextTabbable === prevTabbable) {
|
|
4785
4603
|
break;
|
|
4786
4604
|
}
|
|
@@ -4790,7 +4608,7 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4790
4608
|
});
|
|
4791
4609
|
const element = useRenderElement.useRenderElement('button', componentProps, {
|
|
4792
4610
|
enabled: !isInMenubar,
|
|
4793
|
-
stateAttributesMapping:
|
|
4611
|
+
stateAttributesMapping: ScrollAreaViewport.pressableTriggerOpenStateMapping,
|
|
4794
4612
|
state,
|
|
4795
4613
|
ref,
|
|
4796
4614
|
props
|
|
@@ -4803,7 +4621,7 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4803
4621
|
state: state,
|
|
4804
4622
|
refs: ref,
|
|
4805
4623
|
props: props,
|
|
4806
|
-
stateAttributesMapping:
|
|
4624
|
+
stateAttributesMapping: ScrollAreaViewport.pressableTriggerOpenStateMapping
|
|
4807
4625
|
});
|
|
4808
4626
|
}
|
|
4809
4627
|
|
|
@@ -4812,12 +4630,12 @@ const MenuTrigger = DrawerRoot.fastComponentRef(function MenuTrigger(componentPr
|
|
|
4812
4630
|
|
|
4813
4631
|
if (isOpenedByThisTrigger) {
|
|
4814
4632
|
return /*#__PURE__*/jsxRuntime.jsxs(React__namespace.Fragment, {
|
|
4815
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
4633
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.FocusGuard, {
|
|
4816
4634
|
ref: preFocusGuardRef,
|
|
4817
4635
|
onFocus: handlePreFocusGuardFocus
|
|
4818
4636
|
}, `${thisTriggerId}-pre-focus-guard`), /*#__PURE__*/jsxRuntime.jsx(React__namespace.Fragment, {
|
|
4819
4637
|
children: element
|
|
4820
|
-
}, thisTriggerId), /*#__PURE__*/jsxRuntime.jsx(
|
|
4638
|
+
}, thisTriggerId), /*#__PURE__*/jsxRuntime.jsx(ScrollAreaViewport.FocusGuard, {
|
|
4821
4639
|
ref: store.context.triggerFocusTargetRef,
|
|
4822
4640
|
onFocus: handleFocusTargetFocus
|
|
4823
4641
|
}, `${thisTriggerId}-post-focus-guard`)]
|
|
@@ -4839,7 +4657,7 @@ function useStickIfOpen(open, openReason) {
|
|
|
4839
4657
|
// Only allow "patient" clicks to close the menu if it's open.
|
|
4840
4658
|
// If they clicked within 500ms of the menu opening, keep it open.
|
|
4841
4659
|
setStickIfOpen(true);
|
|
4842
|
-
stickIfOpenTimeout.start(
|
|
4660
|
+
stickIfOpenTimeout.start(ScrollAreaViewport.PATIENT_CLICK_THRESHOLD, () => {
|
|
4843
4661
|
setStickIfOpen(false);
|
|
4844
4662
|
});
|
|
4845
4663
|
} else if (!open) {
|
|
@@ -4901,11 +4719,11 @@ const MenuSubmenuTrigger = /*#__PURE__*/React__namespace.forwardRef(function Sub
|
|
|
4901
4719
|
const {
|
|
4902
4720
|
store
|
|
4903
4721
|
} = useMenuRootContext();
|
|
4904
|
-
const thisTriggerId =
|
|
4722
|
+
const thisTriggerId = useValueChanged.useBaseUiId(idProp);
|
|
4905
4723
|
const open = store.useState('open');
|
|
4906
4724
|
const floatingRootContext = store.useState('floatingRootContext');
|
|
4907
4725
|
const floatingTreeRoot = store.useState('floatingTreeRoot');
|
|
4908
|
-
const baseRegisterTrigger =
|
|
4726
|
+
const baseRegisterTrigger = ScrollAreaViewport.useTriggerRegistration(thisTriggerId, store);
|
|
4909
4727
|
const registerTrigger = React__namespace.useCallback(element => {
|
|
4910
4728
|
const cleanup = baseRegisterTrigger(element);
|
|
4911
4729
|
if (element !== null && store.select('open') && store.select('activeTriggerId') == null) {
|
|
@@ -4969,14 +4787,14 @@ const MenuSubmenuTrigger = /*#__PURE__*/React__namespace.forwardRef(function Sub
|
|
|
4969
4787
|
triggerElementRef,
|
|
4970
4788
|
externalTree: floatingTreeRoot
|
|
4971
4789
|
});
|
|
4972
|
-
const click = useClick(floatingRootContext, {
|
|
4790
|
+
const click = ScrollAreaViewport.useClick(floatingRootContext, {
|
|
4973
4791
|
enabled: !disabled,
|
|
4974
4792
|
event: 'mousedown',
|
|
4975
4793
|
toggle: !openOnHover,
|
|
4976
4794
|
ignoreMouse: openOnHover,
|
|
4977
4795
|
stickIfOpen: false
|
|
4978
4796
|
});
|
|
4979
|
-
const localInteractionProps =
|
|
4797
|
+
const localInteractionProps = ScrollAreaViewport.useInteractions([click]);
|
|
4980
4798
|
const rootTriggerProps = store.useState('triggerProps', true);
|
|
4981
4799
|
delete rootTriggerProps.id;
|
|
4982
4800
|
const state = {
|
|
@@ -4986,7 +4804,7 @@ const MenuSubmenuTrigger = /*#__PURE__*/React__namespace.forwardRef(function Sub
|
|
|
4986
4804
|
};
|
|
4987
4805
|
const element = useRenderElement.useRenderElement('div', componentProps, {
|
|
4988
4806
|
state,
|
|
4989
|
-
stateAttributesMapping:
|
|
4807
|
+
stateAttributesMapping: ScrollAreaViewport.triggerOpenStateMapping,
|
|
4990
4808
|
props: [localInteractionProps.getReferenceProps(), hoverProps, rootTriggerProps, itemProps, {
|
|
4991
4809
|
tabIndex: open || highlighted ? 0 : -1,
|
|
4992
4810
|
onBlur() {
|
|
@@ -5004,7 +4822,6 @@ if (process.env.NODE_ENV !== "production") MenuSubmenuTrigger.displayName = "Men
|
|
|
5004
4822
|
exports.CompositeList = CompositeList;
|
|
5005
4823
|
exports.DrawerClose = DrawerClose;
|
|
5006
4824
|
exports.DrawerTitle = DrawerTitle;
|
|
5007
|
-
exports.DrawerTrigger = DrawerTrigger;
|
|
5008
4825
|
exports.IndexGuessBehavior = IndexGuessBehavior;
|
|
5009
4826
|
exports.MenuGroup = MenuGroup;
|
|
5010
4827
|
exports.MenuGroupLabel = MenuGroupLabel;
|
|
@@ -5026,10 +4843,8 @@ exports.getDisabledMountTransitionStyles = getDisabledMountTransitionStyles;
|
|
|
5026
4843
|
exports.getPseudoElementBounds = getPseudoElementBounds;
|
|
5027
4844
|
exports.itemMapping = itemMapping;
|
|
5028
4845
|
exports.useAnchorPositioning = useAnchorPositioning;
|
|
5029
|
-
exports.useClick = useClick;
|
|
5030
4846
|
exports.useCompositeListItem = useCompositeListItem;
|
|
5031
4847
|
exports.useContextMenuRootContext = useContextMenuRootContext;
|
|
5032
|
-
exports.useDirection = useDirection;
|
|
5033
4848
|
exports.useFloatingRootContext = useFloatingRootContext;
|
|
5034
4849
|
exports.useListNavigation = useListNavigation;
|
|
5035
4850
|
exports.useMenuItem = useMenuItem;
|