tfy-web-components 0.0.44 → 0.0.45
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-BdNaawKV.js → Button-HHEfL8b9.js} +5 -4
- package/dist/{Button-BdNaawKV.js.map → Button-HHEfL8b9.js.map} +1 -1
- package/dist/CSPContext-Cldo9QDp.js +13 -0
- package/dist/CSPContext-Cldo9QDp.js.map +1 -0
- package/dist/{CompositeItem-EOSJycCk.js → CompositeItem-GNejxLcK.js} +3 -3
- package/dist/{CompositeItem-EOSJycCk.js.map → CompositeItem-GNejxLcK.js.map} +1 -1
- package/dist/{CompositeRoot-DnijP7Jm.js → CompositeRoot-7_u1HqDT.js} +9 -47
- package/dist/CompositeRoot-7_u1HqDT.js.map +1 -0
- package/dist/DropdownMenu-Crlf-J4E.js +3304 -0
- package/dist/DropdownMenu-Crlf-J4E.js.map +1 -0
- package/dist/{Input-D0UuCXLs.js → Input-BS9fWUAf.js} +3 -3
- package/dist/{Input-D0UuCXLs.js.map → Input-BS9fWUAf.js.map} +1 -1
- package/dist/{Modal-BFnf68oS.js → Modal-DaHG8mjy.js} +10 -10
- package/dist/{Modal-BFnf68oS.js.map → Modal-DaHG8mjy.js.map} +1 -1
- package/dist/Popover-A8IyEt2w.js +400 -0
- package/dist/Popover-A8IyEt2w.js.map +1 -0
- package/dist/{Popover-B6z7exNd.js → PopoverPopup-teGm7D5T.js} +25 -498
- package/dist/PopoverPopup-teGm7D5T.js.map +1 -0
- package/dist/{PrehydrationScript--08s8Mfl.js → PrehydrationScript-B3u_PP2W.js} +5 -12
- package/dist/PrehydrationScript-B3u_PP2W.js.map +1 -0
- package/dist/Select-BtX40h2K.js +2187 -0
- package/dist/Select-BtX40h2K.js.map +1 -0
- package/dist/{useValueAsRef-BfFRcMg6.js → addEventListener-D-i9O6BG.js} +8 -8
- package/dist/addEventListener-D-i9O6BG.js.map +1 -0
- package/dist/clamp-D7_nsB8C.js +30 -0
- package/dist/clamp-D7_nsB8C.js.map +1 -0
- package/dist/components/atoms/Accordion.es.js +9 -9
- package/dist/components/atoms/Avatar.es.js +9 -9
- package/dist/components/atoms/Avatar.es.js.map +1 -1
- package/dist/components/atoms/Badge.d.ts +5 -6
- package/dist/components/atoms/Badge.es.js +80 -43
- package/dist/components/atoms/Badge.es.js.map +1 -1
- package/dist/components/atoms/Button.d.ts +1 -1
- package/dist/components/atoms/Button.es.js +2 -2
- package/dist/components/atoms/ButtonGroup.es.js +1 -1
- package/dist/components/atoms/Combobox.d.ts +34 -0
- package/dist/components/atoms/Combobox.es.js +3252 -0
- package/dist/components/atoms/Combobox.es.js.map +1 -0
- package/dist/components/atoms/ContextMenu.d.ts +12 -0
- package/dist/components/atoms/ContextMenu.es.js +259 -0
- package/dist/components/atoms/ContextMenu.es.js.map +1 -0
- package/dist/components/atoms/DropdownMenu.d.ts +51 -0
- package/dist/components/atoms/DropdownMenu.es.js +31 -0
- package/dist/components/atoms/DropdownMenu.es.js.map +1 -0
- package/dist/components/atoms/IconButton.d.ts +1 -1
- package/dist/components/atoms/IconButton.es.js +3 -3
- package/dist/components/atoms/IconButton.es.js.map +1 -1
- package/dist/components/atoms/IconProvider.es.js +3 -1
- package/dist/components/atoms/IconProvider.es.js.map +1 -1
- package/dist/components/atoms/Modal.es.js +1 -1
- package/dist/components/atoms/OverflowButton.es.js +2 -2
- package/dist/components/atoms/PaginationDot.d.ts +14 -0
- package/dist/components/atoms/PaginationDot.es.js +58 -0
- package/dist/components/atoms/PaginationDot.es.js.map +1 -0
- package/dist/components/atoms/PaginationItem.d.ts +15 -0
- package/dist/components/atoms/PaginationItem.es.js +87 -0
- package/dist/components/atoms/PaginationItem.es.js.map +1 -0
- package/dist/components/atoms/Popover.d.ts +10 -0
- package/dist/components/atoms/Popover.es.js +50 -0
- package/dist/components/atoms/Popover.es.js.map +1 -0
- package/dist/components/atoms/Select.d.ts +63 -0
- package/dist/components/atoms/Select.es.js +23 -0
- package/dist/components/atoms/Select.es.js.map +1 -0
- package/dist/components/atoms/Switch.es.js +7 -6
- package/dist/components/atoms/Switch.es.js.map +1 -1
- package/dist/components/atoms/TabButton.es.js +14 -12
- package/dist/components/atoms/TabButton.es.js.map +1 -1
- package/dist/components/atoms/Tag.d.ts +2 -2
- package/dist/components/atoms/Tag.es.js +66 -33
- package/dist/components/atoms/Tag.es.js.map +1 -1
- package/dist/components/atoms/Tooltip.es.js +1153 -19
- package/dist/components/atoms/Tooltip.es.js.map +1 -1
- package/dist/components/atoms/stories/OverlayThemePanels.d.ts +8 -0
- package/dist/components/molecules/Alert.es.js +3 -3
- package/dist/components/molecules/CopyField.es.js +2 -2
- package/dist/components/molecules/CustomDrawer.es.js +1 -1
- package/dist/components/molecules/Dialog.es.js +1 -1
- package/dist/components/molecules/ImagesPreview.es.js +2 -2
- package/dist/components/molecules/Input.es.js +2 -2
- package/dist/components/molecules/Markdown.es.js +1 -1
- package/dist/components/molecules/Pagination.d.ts +58 -0
- package/dist/components/molecules/Pagination.es.js +272 -0
- package/dist/components/molecules/Pagination.es.js.map +1 -0
- package/dist/components/molecules/SimpleCodeEditor.es.js +3 -3
- package/dist/components/molecules/SimpleCodeEditor.es.js.map +1 -1
- package/dist/components/molecules/TagGroup.d.ts +11 -0
- package/dist/components/molecules/TagGroup.es.js +59 -0
- package/dist/components/molecules/TagGroup.es.js.map +1 -0
- package/dist/components/molecules/ToggleButton.es.js +2 -2
- package/dist/components/molecules/agent-chat/AssistantMessage.d.ts +3 -1
- package/dist/components/molecules/agent-chat.es.js +4 -3
- package/dist/components/molecules/agent-chat.es.js.map +1 -1
- package/dist/composite-DnShFmi7.js +551 -0
- package/dist/composite-DnShFmi7.js.map +1 -0
- package/dist/{composite-BDBV1Jsx.js → composite-IA--dSel.js} +2 -2
- package/dist/{composite-BDBV1Jsx.js.map → composite-IA--dSel.js.map} +1 -1
- package/dist/constants-BaUKmVF_.js +103 -0
- package/dist/constants-BaUKmVF_.js.map +1 -0
- package/dist/{index-B6xFUIBK.js → element-B1vbc-LG.js} +69 -111
- package/dist/element-B1vbc-LG.js.map +1 -0
- package/dist/error-nCTLdGUr.js +6 -0
- package/dist/{error-FX4R42W-.js.map → error-nCTLdGUr.js.map} +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.es.js +61 -11
- package/dist/index.es.js.map +1 -1
- package/dist/{inertValue-IJM5NA30.js → inertValue-C1Ml1s55.js} +2 -2
- package/dist/{inertValue-IJM5NA30.js.map → inertValue-C1Ml1s55.js.map} +1 -1
- package/dist/isElementDisabled-lq1fKien.js +47 -0
- package/dist/isElementDisabled-lq1fKien.js.map +1 -0
- package/dist/new-components/atoms/Alert.d.ts +7 -1
- package/dist/new-components/atoms/Alert.es.js +23 -4
- package/dist/new-components/atoms/Alert.es.js.map +1 -1
- package/dist/new-components/atoms/Checkbox.es.js +8 -7
- package/dist/new-components/atoms/Checkbox.es.js.map +1 -1
- package/dist/new-components/atoms/EmptyState.d.ts +3 -0
- package/dist/new-components/atoms/EmptyState.es.js +9 -4
- package/dist/new-components/atoms/EmptyState.es.js.map +1 -1
- package/dist/new-components/atoms/Popover.es.js +3 -2
- package/dist/new-components/atoms/Popover.es.js.map +1 -1
- package/dist/new-components/atoms/Radio.es.js +13 -24
- package/dist/new-components/atoms/Radio.es.js.map +1 -1
- package/dist/new-components/atoms/SegmentedControl.es.js +7 -7
- package/dist/new-components/atoms/Slider.es.js +14 -43
- package/dist/new-components/atoms/Slider.es.js.map +1 -1
- package/dist/new-components/atoms/Toast.d.ts +8 -12
- package/dist/new-components/atoms/Toast.es.js +202 -145
- package/dist/new-components/atoms/Toast.es.js.map +1 -1
- package/dist/new-components/atoms/Toggletip.es.js +3 -2
- package/dist/new-components/atoms/Toggletip.es.js.map +1 -1
- package/dist/new-components/atoms/stories/ThemeComparison.d.ts +2 -1
- package/dist/serializeValue-BLvnTy3o.js +17 -0
- package/dist/serializeValue-BLvnTy3o.js.map +1 -0
- package/dist/stringifyLocale-DOx30wH1.js +13 -0
- package/dist/stringifyLocale-DOx30wH1.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tokens.css +3 -0
- package/dist/{useAnimationFrame-DwhymJoW.js → useAnimationFrame-DqvuRtgK.js} +2 -2
- package/dist/{useAnimationFrame-DwhymJoW.js.map → useAnimationFrame-DqvuRtgK.js.map} +1 -1
- package/dist/{useAriaLabelledBy-C9SDiruE.js → useAriaLabelledBy-CP4wKTYs.js} +3 -3
- package/dist/{useAriaLabelledBy-C9SDiruE.js.map → useAriaLabelledBy-CP4wKTYs.js.map} +1 -1
- package/dist/{useBaseUiId-jtgiQp--.js → useBaseUiId-CYT1vFMG.js} +57 -37
- package/dist/{useBaseUiId-jtgiQp--.js.map → useBaseUiId-CYT1vFMG.js.map} +1 -1
- package/dist/{useButton-BalOc_EL.js → useButton-BlHadUfM.js} +4 -4
- package/dist/{useButton-BalOc_EL.js.map → useButton-BlHadUfM.js.map} +1 -1
- package/dist/{CompositeList-D4xmSZ5V.js → useCompositeListItem-DlAKWsHE.js} +59 -59
- package/dist/useCompositeListItem-DlAKWsHE.js.map +1 -0
- package/dist/{useControlled-BSyYkg5C.js → useControlled-DMDWXIzj.js} +2 -2
- package/dist/{useControlled-BSyYkg5C.js.map → useControlled-DMDWXIzj.js.map} +1 -1
- package/dist/useFocus-C__7iwl1.js +137 -0
- package/dist/useFocus-C__7iwl1.js.map +1 -0
- package/dist/{useIsoLayoutEffect-e9VA-ICd.js → useIsoLayoutEffect-D2lpsB9D.js} +8 -4
- package/dist/{useIsoLayoutEffect-e9VA-ICd.js.map → useIsoLayoutEffect-D2lpsB9D.js.map} +1 -1
- package/dist/{usePopupHandleStore-DYUo-Fyk.js → usePopupHandleStore-C_Vw7xcw.js} +1966 -2002
- package/dist/usePopupHandleStore-C_Vw7xcw.js.map +1 -0
- package/dist/{Tooltip-6R-t7wt1.js → usePositioner-BmYVsMO_.js} +17 -1403
- package/dist/usePositioner-BmYVsMO_.js.map +1 -0
- package/dist/{useOpenInteractionType-BnUZ2Eio.js → useScrollLock-By-42HSc.js} +74 -58
- package/dist/useScrollLock-By-42HSc.js.map +1 -0
- package/dist/{useLabelableId-CQqNbBk1.js → useSetFieldFocused-CcdG6FNp.js} +27 -35
- package/dist/useSetFieldFocused-CcdG6FNp.js.map +1 -0
- package/dist/{useTimeout-BXf1hDIL.js → useTimeout-D1vYJgq4.js} +3 -3
- package/dist/{useTimeout-BXf1hDIL.js.map → useTimeout-D1vYJgq4.js.map} +1 -1
- package/dist/{useTransitionStatus-C9gg_XJ-.js → useTransitionStatus-CHrs3i5F.js} +3 -3
- package/dist/{useTransitionStatus-C9gg_XJ-.js.map → useTransitionStatus-CHrs3i5F.js.map} +1 -1
- package/dist/useTriggerFocusGuards-CXAhW8P6.js +100 -0
- package/dist/useTriggerFocusGuards-CXAhW8P6.js.map +1 -0
- package/dist/useValueChanged-BnlOop8k.js +16 -0
- package/dist/useValueChanged-BnlOop8k.js.map +1 -0
- package/package.json +1 -1
- package/dist/CompositeList-D4xmSZ5V.js.map +0 -1
- package/dist/CompositeRoot-DnijP7Jm.js.map +0 -1
- package/dist/Popover-B6z7exNd.js.map +0 -1
- package/dist/PrehydrationScript--08s8Mfl.js.map +0 -1
- package/dist/Tooltip-6R-t7wt1.js.map +0 -1
- package/dist/composite-rAI4IlWK.js +0 -66
- package/dist/composite-rAI4IlWK.js.map +0 -1
- package/dist/error-FX4R42W-.js +0 -6
- package/dist/index-B6xFUIBK.js.map +0 -1
- package/dist/shadowDom-CRvvf3qf.js +0 -52
- package/dist/shadowDom-CRvvf3qf.js.map +0 -1
- package/dist/useLabelableId-CQqNbBk1.js.map +0 -1
- package/dist/useOpenInteractionType-BnUZ2Eio.js.map +0 -1
- package/dist/usePopupHandleStore-DYUo-Fyk.js.map +0 -1
- package/dist/useValueAsRef-BfFRcMg6.js.map +0 -1
|
@@ -2,2148 +2,2109 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var _a;
|
|
5
|
-
import { t as transitionStatusMapping, u as useTransitionStatus, a as useOpenChangeComplete } from "./useTransitionStatus-
|
|
5
|
+
import { t as transitionStatusMapping, u as useTransitionStatus, a as useOpenChangeComplete } from "./useTransitionStatus-CHrs3i5F.js";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import React__default from "react";
|
|
8
8
|
import * as ReactDOM from "react-dom";
|
|
9
|
-
import { i as isHTMLElement,
|
|
10
|
-
import { a as addEventListener } from "./
|
|
11
|
-
import {
|
|
9
|
+
import { i as isHTMLElement, M as getNodeName, N as isShadowRoot, g as getComputedStyle, j as useId, O as isNode, c as createChangeEventDetails, s as focusOut, t as triggerPress, r as escapeKey, A as isElement, h as isLastTraversableNode, f as getParentNode, v as outsidePress, e as useForcedRerendering, n as none, I as triggerHover, J as triggerFocus } from "./useBaseUiId-CYT1vFMG.js";
|
|
10
|
+
import { a as addEventListener } from "./addEventListener-D-i9O6BG.js";
|
|
11
|
+
import { e as useRefWithInit, i as isReactVersionAtLeast, u as useIsoLayoutEffect, a as useStableCallback, N as NOOP, b as useRenderElement, d as EMPTY_OBJECT } from "./useIsoLayoutEffect-D2lpsB9D.js";
|
|
12
12
|
import { a as visuallyHidden } from "./visuallyHidden-B6H2X3_Y.js";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { u as useTimeout, T as Timeout } from "./useTimeout-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const ANCHOR_HIDDEN_HOOK = {
|
|
37
|
-
[anchorHidden]: ""
|
|
38
|
-
};
|
|
39
|
-
const triggerOpenStateMapping = {
|
|
40
|
-
open(value) {
|
|
41
|
-
if (value) {
|
|
42
|
-
return TRIGGER_HOOK;
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const pressableTriggerOpenStateMapping = {
|
|
48
|
-
open(value) {
|
|
49
|
-
if (value) {
|
|
50
|
-
return PRESSABLE_TRIGGER_HOOK;
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const popupStateMapping = {
|
|
56
|
-
open(value) {
|
|
57
|
-
if (value) {
|
|
58
|
-
return POPUP_OPEN_HOOK;
|
|
59
|
-
}
|
|
60
|
-
return POPUP_CLOSED_HOOK;
|
|
61
|
-
},
|
|
62
|
-
anchorHidden(value) {
|
|
63
|
-
if (value) {
|
|
64
|
-
return ANCHOR_HIDDEN_HOOK;
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
14
|
+
import { n as apple, k as isElementVisible, o as isReactEvent, d as isVirtualClick, p as isClickLikeEvent } from "./composite-DnShFmi7.js";
|
|
15
|
+
import { s as shimExports, o as ownerDocument, c as isEventTargetWithin, d as isRootElement } from "./element-B1vbc-LG.js";
|
|
16
|
+
import { h as lowerUserAgent, c as contains, a as activeElement, g as getTarget, F as FOCUSABLE_ATTRIBUTE } from "./constants-BaUKmVF_.js";
|
|
17
|
+
import { u as useTimeout, T as Timeout } from "./useTimeout-D1vYJgq4.js";
|
|
18
|
+
var withSelector = { exports: {} };
|
|
19
|
+
var withSelector_production = {};
|
|
20
|
+
/**
|
|
21
|
+
* @license React
|
|
22
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
25
|
+
*
|
|
26
|
+
* This source code is licensed under the MIT license found in the
|
|
27
|
+
* LICENSE file in the root directory of this source tree.
|
|
28
|
+
*/
|
|
29
|
+
var hasRequiredWithSelector_production;
|
|
30
|
+
function requireWithSelector_production() {
|
|
31
|
+
if (hasRequiredWithSelector_production) return withSelector_production;
|
|
32
|
+
hasRequiredWithSelector_production = 1;
|
|
33
|
+
var React2 = React__default, shim = shimExports;
|
|
34
|
+
function is(x, y) {
|
|
35
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
67
36
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
37
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef = React2.useRef, useEffect = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
38
|
+
withSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
39
|
+
var instRef = useRef(null);
|
|
40
|
+
if (null === instRef.current) {
|
|
41
|
+
var inst = { hasValue: false, value: null };
|
|
42
|
+
instRef.current = inst;
|
|
43
|
+
} else inst = instRef.current;
|
|
44
|
+
instRef = useMemo(
|
|
45
|
+
function() {
|
|
46
|
+
function memoizedSelector(nextSnapshot) {
|
|
47
|
+
if (!hasMemo) {
|
|
48
|
+
hasMemo = true;
|
|
49
|
+
memoizedSnapshot = nextSnapshot;
|
|
50
|
+
nextSnapshot = selector(nextSnapshot);
|
|
51
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
52
|
+
var currentSelection = inst.value;
|
|
53
|
+
if (isEqual(currentSelection, nextSnapshot))
|
|
54
|
+
return memoizedSelection = currentSelection;
|
|
55
|
+
}
|
|
56
|
+
return memoizedSelection = nextSnapshot;
|
|
57
|
+
}
|
|
58
|
+
currentSelection = memoizedSelection;
|
|
59
|
+
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
60
|
+
var nextSelection = selector(nextSnapshot);
|
|
61
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
62
|
+
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
63
|
+
memoizedSnapshot = nextSnapshot;
|
|
64
|
+
return memoizedSelection = nextSelection;
|
|
65
|
+
}
|
|
66
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
67
|
+
return [
|
|
68
|
+
function() {
|
|
69
|
+
return memoizedSelector(getSnapshot());
|
|
70
|
+
},
|
|
71
|
+
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
72
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
},
|
|
76
|
+
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
77
|
+
);
|
|
78
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
79
|
+
useEffect(
|
|
80
|
+
function() {
|
|
81
|
+
inst.hasValue = true;
|
|
82
|
+
inst.value = value;
|
|
83
|
+
},
|
|
84
|
+
[value]
|
|
85
|
+
);
|
|
86
|
+
useDebugValue(value);
|
|
87
|
+
return value;
|
|
88
|
+
};
|
|
89
|
+
return withSelector_production;
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
var withSelector_development = {};
|
|
92
|
+
/**
|
|
93
|
+
* @license React
|
|
94
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
95
|
+
*
|
|
96
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
97
|
+
*
|
|
98
|
+
* This source code is licensed under the MIT license found in the
|
|
99
|
+
* LICENSE file in the root directory of this source tree.
|
|
100
|
+
*/
|
|
101
|
+
var hasRequiredWithSelector_development;
|
|
102
|
+
function requireWithSelector_development() {
|
|
103
|
+
if (hasRequiredWithSelector_development) return withSelector_development;
|
|
104
|
+
hasRequiredWithSelector_development = 1;
|
|
105
|
+
"production" !== process.env.NODE_ENV && function() {
|
|
106
|
+
function is(x, y) {
|
|
107
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
108
|
+
}
|
|
109
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
110
|
+
var React2 = React__default, shim = shimExports, objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef = React2.useRef, useEffect = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
111
|
+
withSelector_development.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
112
|
+
var instRef = useRef(null);
|
|
113
|
+
if (null === instRef.current) {
|
|
114
|
+
var inst = { hasValue: false, value: null };
|
|
115
|
+
instRef.current = inst;
|
|
116
|
+
} else inst = instRef.current;
|
|
117
|
+
instRef = useMemo(
|
|
118
|
+
function() {
|
|
119
|
+
function memoizedSelector(nextSnapshot) {
|
|
120
|
+
if (!hasMemo) {
|
|
121
|
+
hasMemo = true;
|
|
122
|
+
memoizedSnapshot = nextSnapshot;
|
|
123
|
+
nextSnapshot = selector(nextSnapshot);
|
|
124
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
125
|
+
var currentSelection = inst.value;
|
|
126
|
+
if (isEqual(currentSelection, nextSnapshot))
|
|
127
|
+
return memoizedSelection = currentSelection;
|
|
128
|
+
}
|
|
129
|
+
return memoizedSelection = nextSnapshot;
|
|
130
|
+
}
|
|
131
|
+
currentSelection = memoizedSelection;
|
|
132
|
+
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
133
|
+
return currentSelection;
|
|
134
|
+
var nextSelection = selector(nextSnapshot);
|
|
135
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
136
|
+
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
137
|
+
memoizedSnapshot = nextSnapshot;
|
|
138
|
+
return memoizedSelection = nextSelection;
|
|
139
|
+
}
|
|
140
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
141
|
+
return [
|
|
142
|
+
function() {
|
|
143
|
+
return memoizedSelector(getSnapshot());
|
|
144
|
+
},
|
|
145
|
+
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
146
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
},
|
|
150
|
+
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
151
|
+
);
|
|
152
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
153
|
+
useEffect(
|
|
154
|
+
function() {
|
|
155
|
+
inst.hasValue = true;
|
|
156
|
+
inst.value = value;
|
|
157
|
+
},
|
|
158
|
+
[value]
|
|
159
|
+
);
|
|
160
|
+
useDebugValue(value);
|
|
161
|
+
return value;
|
|
162
|
+
};
|
|
163
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
164
|
+
}();
|
|
165
|
+
return withSelector_development;
|
|
89
166
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (android && event.pointerType) {
|
|
95
|
-
return event.type === "click" && event.buttons === 1;
|
|
96
|
-
}
|
|
97
|
-
return event.detail === 0 && !event.pointerType;
|
|
167
|
+
if (process.env.NODE_ENV === "production") {
|
|
168
|
+
withSelector.exports = requireWithSelector_production();
|
|
169
|
+
} else {
|
|
170
|
+
withSelector.exports = requireWithSelector_development();
|
|
98
171
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return
|
|
104
|
-
// `pointerdown` with no pressure. TalkBack can report a pressed button, while desktop
|
|
105
|
-
// mouse presses can report no pressure, so only require no pressed button off Android.
|
|
106
|
-
event.type === "pointerdown" && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" && (android || event.buttons === 0) || // iOS VoiceOver returns 0.333• for width/height.
|
|
107
|
-
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
|
|
108
|
-
}
|
|
109
|
-
function isMouseLikePointerType(pointerType, strict) {
|
|
110
|
-
const values = ["mouse", "pen"];
|
|
111
|
-
if (!strict) {
|
|
112
|
-
values.push("", void 0);
|
|
113
|
-
}
|
|
114
|
-
return values.includes(pointerType);
|
|
172
|
+
var withSelectorExports = withSelector.exports;
|
|
173
|
+
const hooks = [];
|
|
174
|
+
let currentInstance = void 0;
|
|
175
|
+
function getInstance() {
|
|
176
|
+
return currentInstance;
|
|
115
177
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
|
|
178
|
+
function register(hook) {
|
|
179
|
+
hooks.push(hook);
|
|
119
180
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
181
|
+
function fastComponent(fn) {
|
|
182
|
+
const FastComponent = (props, forwardedRef) => {
|
|
183
|
+
const instance = useRefWithInit(createInstance).current;
|
|
184
|
+
let result;
|
|
185
|
+
try {
|
|
186
|
+
currentInstance = instance;
|
|
187
|
+
for (const hook of hooks) {
|
|
188
|
+
hook.before(instance);
|
|
189
|
+
}
|
|
190
|
+
result = fn(props, forwardedRef);
|
|
191
|
+
for (const hook of hooks) {
|
|
192
|
+
hook.after(instance);
|
|
126
193
|
}
|
|
194
|
+
instance.didInitialize = true;
|
|
195
|
+
} finally {
|
|
196
|
+
currentInstance = void 0;
|
|
127
197
|
}
|
|
198
|
+
return result;
|
|
128
199
|
};
|
|
200
|
+
FastComponent.displayName = fn.displayName || fn.name;
|
|
201
|
+
return FastComponent;
|
|
129
202
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
useIsoLayoutEffect(() => {
|
|
133
|
-
if (voiceOver && webkit) {
|
|
134
|
-
setRole("button");
|
|
135
|
-
}
|
|
136
|
-
}, []);
|
|
137
|
-
const restProps = {
|
|
138
|
-
tabIndex: 0,
|
|
139
|
-
// Role is only for VoiceOver
|
|
140
|
-
role
|
|
141
|
-
};
|
|
142
|
-
return /* @__PURE__ */ jsx("span", {
|
|
143
|
-
...props,
|
|
144
|
-
ref,
|
|
145
|
-
style: visuallyHidden,
|
|
146
|
-
"aria-hidden": role ? void 0 : true,
|
|
147
|
-
...restProps,
|
|
148
|
-
"data-base-ui-focus-guard": ""
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
if (process.env.NODE_ENV !== "production") FocusGuard.displayName = "FocusGuard";
|
|
152
|
-
const CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
|
|
153
|
-
function getParentElement(element) {
|
|
154
|
-
const assignedSlot = element.assignedSlot;
|
|
155
|
-
if (assignedSlot) {
|
|
156
|
-
return assignedSlot;
|
|
157
|
-
}
|
|
158
|
-
if (element.parentElement) {
|
|
159
|
-
return element.parentElement;
|
|
160
|
-
}
|
|
161
|
-
const rootNode = element.getRootNode();
|
|
162
|
-
return isShadowRoot(rootNode) ? rootNode.host : null;
|
|
203
|
+
function fastComponentRef(fn) {
|
|
204
|
+
return /* @__PURE__ */ React.forwardRef(fastComponent(fn));
|
|
163
205
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return null;
|
|
206
|
+
function createInstance() {
|
|
207
|
+
return {
|
|
208
|
+
didInitialize: false
|
|
209
|
+
};
|
|
171
210
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
211
|
+
const canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
|
|
212
|
+
const useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
|
|
213
|
+
function useStore(store, selector, a1, a2, a3) {
|
|
214
|
+
return useStoreImplementation(store, selector, a1, a2, a3);
|
|
175
215
|
}
|
|
176
|
-
function
|
|
177
|
-
const
|
|
178
|
-
return
|
|
216
|
+
function useStoreR19(store, selector, a1, a2, a3) {
|
|
217
|
+
const getSelection = React.useCallback(() => selector(store.getSnapshot(), a1, a2, a3), [store, selector, a1, a2, a3]);
|
|
218
|
+
return shimExports.useSyncExternalStore(store.subscribe, getSelection, getSelection);
|
|
179
219
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
220
|
+
register({
|
|
221
|
+
before(instance) {
|
|
222
|
+
instance.syncIndex = 0;
|
|
223
|
+
if (!instance.didInitialize) {
|
|
224
|
+
instance.syncTick = 1;
|
|
225
|
+
instance.syncHooks = [];
|
|
226
|
+
instance.didChangeStore = true;
|
|
227
|
+
instance.getSnapshot = () => {
|
|
228
|
+
let didChange = false;
|
|
229
|
+
for (let i = 0; i < instance.syncHooks.length; i += 1) {
|
|
230
|
+
const hook = instance.syncHooks[i];
|
|
231
|
+
const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
|
|
232
|
+
if (!Object.is(hook.value, value)) {
|
|
233
|
+
didChange = true;
|
|
234
|
+
hook.value = value;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (didChange) {
|
|
238
|
+
instance.syncTick += 1;
|
|
239
|
+
}
|
|
240
|
+
return instance.syncTick;
|
|
241
|
+
};
|
|
189
242
|
}
|
|
190
|
-
|
|
191
|
-
|
|
243
|
+
},
|
|
244
|
+
after(instance) {
|
|
245
|
+
if (instance.syncHooks.length > 0) {
|
|
246
|
+
if (instance.didChangeStore) {
|
|
247
|
+
instance.didChangeStore = false;
|
|
248
|
+
instance.subscribe = (onStoreChange) => {
|
|
249
|
+
const stores = /* @__PURE__ */ new Set();
|
|
250
|
+
for (const hook of instance.syncHooks) {
|
|
251
|
+
stores.add(hook.store);
|
|
252
|
+
}
|
|
253
|
+
const unsubscribes = [];
|
|
254
|
+
for (const store of stores) {
|
|
255
|
+
unsubscribes.push(store.subscribe(onStoreChange));
|
|
256
|
+
}
|
|
257
|
+
return () => {
|
|
258
|
+
for (const unsubscribe of unsubscribes) {
|
|
259
|
+
unsubscribe();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
shimExports.useSyncExternalStore(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
|
|
192
265
|
}
|
|
193
266
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return isElementVisible(element, styles);
|
|
267
|
+
});
|
|
268
|
+
function useStoreFast(store, selector, a1, a2, a3) {
|
|
269
|
+
const instance = getInstance();
|
|
270
|
+
if (!instance) {
|
|
271
|
+
return useStoreR19(store, selector, a1, a2, a3);
|
|
200
272
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
273
|
+
const index = instance.syncIndex;
|
|
274
|
+
instance.syncIndex += 1;
|
|
275
|
+
let hook;
|
|
276
|
+
if (!instance.didInitialize) {
|
|
277
|
+
hook = {
|
|
278
|
+
store,
|
|
279
|
+
selector,
|
|
280
|
+
a1,
|
|
281
|
+
a2,
|
|
282
|
+
a3,
|
|
283
|
+
value: selector(store.getSnapshot(), a1, a2, a3)
|
|
284
|
+
};
|
|
285
|
+
instance.syncHooks.push(hook);
|
|
286
|
+
} else {
|
|
287
|
+
hook = instance.syncHooks[index];
|
|
288
|
+
if (hook.store !== store || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
|
|
289
|
+
if (hook.store !== store) {
|
|
290
|
+
instance.didChangeStore = true;
|
|
291
|
+
}
|
|
292
|
+
hook.store = store;
|
|
293
|
+
hook.selector = selector;
|
|
294
|
+
hook.a1 = a1;
|
|
295
|
+
hook.a2 = a2;
|
|
296
|
+
hook.a3 = a3;
|
|
297
|
+
hook.value = selector(store.getSnapshot(), a1, a2, a3);
|
|
209
298
|
}
|
|
210
299
|
}
|
|
211
|
-
return
|
|
212
|
-
}
|
|
213
|
-
function getNamedRadioInput(element) {
|
|
214
|
-
if (getNodeName(element) !== "input") {
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
const input = element;
|
|
218
|
-
return input.type === "radio" && input.name !== "" ? input : null;
|
|
300
|
+
return hook.value;
|
|
219
301
|
}
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
if (!input) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
const checkedRadio = candidates.find((candidate) => {
|
|
226
|
-
const radio = getNamedRadioInput(candidate);
|
|
227
|
-
return (radio == null ? void 0 : radio.name) === input.name && radio.form === input.form && radio.checked;
|
|
228
|
-
});
|
|
229
|
-
if (checkedRadio) {
|
|
230
|
-
return checkedRadio === input;
|
|
231
|
-
}
|
|
232
|
-
return candidates.find((candidate) => {
|
|
233
|
-
const radio = getNamedRadioInput(candidate);
|
|
234
|
-
return (radio == null ? void 0 : radio.name) === input.name && radio.form === input.form;
|
|
235
|
-
}) === input;
|
|
302
|
+
function useStoreLegacy(store, selector, a1, a2, a3) {
|
|
303
|
+
return withSelectorExports.useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector(state, a1, a2, a3));
|
|
236
304
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
305
|
+
class Store {
|
|
306
|
+
/**
|
|
307
|
+
* The current state of the store.
|
|
308
|
+
* This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
|
|
309
|
+
* To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
|
|
310
|
+
* The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
|
|
311
|
+
*
|
|
312
|
+
* Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
|
|
313
|
+
*/
|
|
314
|
+
// Internal state to handle recursive `setState()` calls
|
|
315
|
+
constructor(state) {
|
|
316
|
+
/**
|
|
317
|
+
* Registers a listener that will be called whenever the store's state changes.
|
|
318
|
+
*
|
|
319
|
+
* @param fn The listener function to be called on state changes.
|
|
320
|
+
* @returns A function to unsubscribe the listener.
|
|
321
|
+
*/
|
|
322
|
+
__publicField(this, "subscribe", (fn) => {
|
|
323
|
+
this.listeners.add(fn);
|
|
324
|
+
return () => {
|
|
325
|
+
this.listeners.delete(fn);
|
|
326
|
+
};
|
|
241
327
|
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
328
|
+
/**
|
|
329
|
+
* Returns the current state of the store.
|
|
330
|
+
*/
|
|
331
|
+
__publicField(this, "getSnapshot", () => {
|
|
332
|
+
return this.state;
|
|
333
|
+
});
|
|
334
|
+
this.state = state;
|
|
335
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
336
|
+
this.updateTick = 0;
|
|
245
337
|
}
|
|
246
|
-
|
|
247
|
-
|
|
338
|
+
/**
|
|
339
|
+
* Creates a store with the given initial state, constructing the class it is called on.
|
|
340
|
+
* Calling it on a generic base class (e.g. `ReactStore.create(...)`) constructs that
|
|
341
|
+
* class but degrades the inferred instance type to `Store`; use `new` there instead.
|
|
342
|
+
*/
|
|
343
|
+
static create(state) {
|
|
344
|
+
return new this(state);
|
|
248
345
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Updates the entire store's state and notifies all registered listeners.
|
|
348
|
+
*
|
|
349
|
+
* @param newState The new state to set for the store.
|
|
350
|
+
*/
|
|
351
|
+
setState(newState) {
|
|
352
|
+
if (this.state === newState) {
|
|
353
|
+
return;
|
|
255
354
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
355
|
+
this.state = newState;
|
|
356
|
+
this.updateTick += 1;
|
|
357
|
+
const currentTick = this.updateTick;
|
|
358
|
+
for (const listener of this.listeners) {
|
|
359
|
+
if (currentTick !== this.updateTick) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
listener(newState);
|
|
263
363
|
}
|
|
264
|
-
appendMatchingElements(child, selector, list);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
function isTabbable(element) {
|
|
268
|
-
return isFocusableElement(element) && getTabIndex(element) >= 0;
|
|
269
|
-
}
|
|
270
|
-
function focusable(container) {
|
|
271
|
-
const candidates = [];
|
|
272
|
-
appendCandidates(container, candidates);
|
|
273
|
-
return candidates.filter(isFocusableElement);
|
|
274
|
-
}
|
|
275
|
-
function tabbable(container) {
|
|
276
|
-
const candidates = focusable(container);
|
|
277
|
-
return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
|
|
278
|
-
}
|
|
279
|
-
function getTabbableIn(container, dir) {
|
|
280
|
-
const list = tabbable(container);
|
|
281
|
-
const len = list.length;
|
|
282
|
-
if (len === 0) {
|
|
283
|
-
return void 0;
|
|
284
|
-
}
|
|
285
|
-
const active = activeElement(ownerDocument(container));
|
|
286
|
-
const index = list.indexOf(active);
|
|
287
|
-
const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
|
|
288
|
-
return list[nextIndex];
|
|
289
|
-
}
|
|
290
|
-
function getNextTabbable(referenceElement) {
|
|
291
|
-
return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
|
|
292
|
-
}
|
|
293
|
-
function getPreviousTabbable(referenceElement) {
|
|
294
|
-
return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
|
|
295
|
-
}
|
|
296
|
-
function getTabbableNearElement(referenceElement, direction, exclude) {
|
|
297
|
-
if (!referenceElement) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
const list = [];
|
|
301
|
-
appendCandidates(ownerDocument(referenceElement).body, list);
|
|
302
|
-
const index = list.indexOf(referenceElement);
|
|
303
|
-
if (index === -1) {
|
|
304
|
-
return null;
|
|
305
364
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Merges the provided changes into the current state and notifies listeners if there are changes.
|
|
367
|
+
* Each value must match its state key. Pass an exact known subset rather than a broad
|
|
368
|
+
* `Partial<State>`, which may contain `undefined` for required state fields.
|
|
369
|
+
*
|
|
370
|
+
* @param changes An object containing the changes to apply to the current state.
|
|
371
|
+
*/
|
|
372
|
+
update(changes) {
|
|
373
|
+
for (const key in changes) {
|
|
374
|
+
if (!Object.is(this.state[key], changes[key])) {
|
|
375
|
+
this.setState({
|
|
376
|
+
...this.state,
|
|
377
|
+
...changes
|
|
378
|
+
});
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
311
381
|
}
|
|
312
382
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
function enableFocusInside(container) {
|
|
328
|
-
const elements = [];
|
|
329
|
-
appendMatchingElements(container, "[data-tabindex]", elements);
|
|
330
|
-
elements.forEach((element) => {
|
|
331
|
-
const tabindex = element.dataset.tabindex;
|
|
332
|
-
delete element.dataset.tabindex;
|
|
333
|
-
if (tabindex) {
|
|
334
|
-
element.setAttribute("tabindex", tabindex);
|
|
335
|
-
} else {
|
|
336
|
-
element.removeAttribute("tabindex");
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
function getNodeChildren(nodes, id, onlyOpenChildren = true) {
|
|
341
|
-
const directChildren = nodes.filter((node) => node.parentId === id);
|
|
342
|
-
return directChildren.flatMap((child) => {
|
|
343
|
-
var _a2;
|
|
344
|
-
return [...!onlyOpenChildren || ((_a2 = child.context) == null ? void 0 : _a2.open) ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)];
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
function getNodeAncestors(nodes, id) {
|
|
348
|
-
var _a2;
|
|
349
|
-
let allAncestors = [];
|
|
350
|
-
let currentParentId = (_a2 = nodes.find((node) => node.id === id)) == null ? void 0 : _a2.parentId;
|
|
351
|
-
while (currentParentId) {
|
|
352
|
-
const currentNode = nodes.find((node) => node.id === currentParentId);
|
|
353
|
-
currentParentId = currentNode == null ? void 0 : currentNode.parentId;
|
|
354
|
-
if (currentNode) {
|
|
355
|
-
allAncestors = allAncestors.concat(currentNode);
|
|
383
|
+
/**
|
|
384
|
+
* Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
|
|
385
|
+
*
|
|
386
|
+
* @param key The key in the store's state to update.
|
|
387
|
+
* @param value The new value to set for the specified key.
|
|
388
|
+
*/
|
|
389
|
+
set(key, value) {
|
|
390
|
+
if (!Object.is(this.state[key], value)) {
|
|
391
|
+
this.setState({
|
|
392
|
+
...this.state,
|
|
393
|
+
[key]: value
|
|
394
|
+
});
|
|
356
395
|
}
|
|
357
396
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
397
|
+
/**
|
|
398
|
+
* Gives the state a new reference and updates all registered listeners.
|
|
399
|
+
*/
|
|
400
|
+
notifyAll() {
|
|
401
|
+
const newState = {
|
|
402
|
+
...this.state
|
|
403
|
+
};
|
|
404
|
+
this.setState(newState);
|
|
405
|
+
}
|
|
406
|
+
use(selector, a1, a2, a3) {
|
|
407
|
+
return useStore(this, selector, a1, a2, a3);
|
|
408
|
+
}
|
|
362
409
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
410
|
+
class ReactStore extends Store {
|
|
411
|
+
/**
|
|
412
|
+
* Creates a new ReactStore instance.
|
|
413
|
+
*
|
|
414
|
+
* @param state Initial state of the store.
|
|
415
|
+
* @param context Non-reactive context values.
|
|
416
|
+
* @param selectors Optional selectors for use with `useState`.
|
|
417
|
+
*/
|
|
418
|
+
constructor(state, context = {}, selectors2) {
|
|
419
|
+
super(state);
|
|
420
|
+
this.context = context;
|
|
421
|
+
this.selectors = selectors2;
|
|
367
422
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
function useFloatingPortalNode(props = {}) {
|
|
384
|
-
const {
|
|
385
|
-
ref,
|
|
386
|
-
container: containerProp,
|
|
387
|
-
componentProps = EMPTY_OBJECT,
|
|
388
|
-
elementProps
|
|
389
|
-
} = props;
|
|
390
|
-
const uniqueId = useId();
|
|
391
|
-
const portalContext = usePortalContext();
|
|
392
|
-
const parentPortalNode = portalContext == null ? void 0 : portalContext.portalNode;
|
|
393
|
-
const [containerElement, setContainerElement] = React.useState(null);
|
|
394
|
-
const [portalNode, setPortalNode] = React.useState(null);
|
|
395
|
-
const setPortalNodeRef = useStableCallback((node) => {
|
|
396
|
-
if (node !== null) {
|
|
397
|
-
setPortalNode(node);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
const containerRef = React.useRef(null);
|
|
401
|
-
useIsoLayoutEffect(() => {
|
|
402
|
-
if (containerProp === null) {
|
|
403
|
-
if (containerRef.current) {
|
|
404
|
-
containerRef.current = null;
|
|
405
|
-
setPortalNode(null);
|
|
406
|
-
setContainerElement(null);
|
|
423
|
+
/**
|
|
424
|
+
* Non-reactive values such as refs, callbacks, etc.
|
|
425
|
+
*/
|
|
426
|
+
/**
|
|
427
|
+
* Synchronizes a single external value into the store.
|
|
428
|
+
*
|
|
429
|
+
* Note that the while the value in `state` is updated immediately, the value returned
|
|
430
|
+
* by `useState` is updated before the next render (similarly to React's `useState`).
|
|
431
|
+
*/
|
|
432
|
+
useSyncedValue(key, value) {
|
|
433
|
+
React.useDebugValue(key);
|
|
434
|
+
const store = this;
|
|
435
|
+
useIsoLayoutEffect(() => {
|
|
436
|
+
if (store.state[key] !== value) {
|
|
437
|
+
store.set(key, value);
|
|
407
438
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
439
|
+
}, [store, key, value]);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Synchronizes a single external value into the store and
|
|
443
|
+
* cleans it up (sets to `undefined`) on unmount.
|
|
444
|
+
*
|
|
445
|
+
* Note that the while the value in `state` is updated immediately, the value returned
|
|
446
|
+
* by `useState` is updated before the next render (similarly to React's `useState`).
|
|
447
|
+
*/
|
|
448
|
+
useSyncedValueWithCleanup(key, value) {
|
|
449
|
+
const store = this;
|
|
450
|
+
useIsoLayoutEffect(() => {
|
|
451
|
+
if (store.state[key] !== value) {
|
|
452
|
+
store.set(key, value);
|
|
453
|
+
}
|
|
454
|
+
return () => {
|
|
455
|
+
store.set(key, void 0);
|
|
456
|
+
};
|
|
457
|
+
}, [store, key, value]);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Synchronizes multiple external values into the store.
|
|
461
|
+
* Each value must match its state key. Pass an exact known subset rather than a broad
|
|
462
|
+
* `Partial<State>`, which may contain `undefined` for required state fields.
|
|
463
|
+
*
|
|
464
|
+
* Note that the while the values in `state` are updated immediately, the values returned
|
|
465
|
+
* by `useState` are updated before the next render (similarly to React's `useState`).
|
|
466
|
+
*
|
|
467
|
+
* @param statePart An exact subset of state fields to synchronize. Unknown keys are not accepted.
|
|
468
|
+
*/
|
|
469
|
+
useSyncedValues(statePart) {
|
|
470
|
+
const store = this;
|
|
471
|
+
if (process.env.NODE_ENV !== "production") {
|
|
472
|
+
React.useDebugValue(statePart, (p) => Object.keys(p));
|
|
473
|
+
const keys = React.useRef(Object.keys(statePart)).current;
|
|
474
|
+
const nextKeys = Object.keys(statePart);
|
|
475
|
+
if (keys.length !== nextKeys.length || keys.some((key, index) => key !== nextKeys[index])) {
|
|
476
|
+
console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
|
|
416
477
|
}
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
if (containerRef.current !== resolvedContainer) {
|
|
420
|
-
containerRef.current = resolvedContainer;
|
|
421
|
-
setPortalNode(null);
|
|
422
|
-
setContainerElement(resolvedContainer);
|
|
423
478
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
render,
|
|
444
|
-
className,
|
|
445
|
-
style,
|
|
446
|
-
children,
|
|
447
|
-
container,
|
|
448
|
-
portalOwnerRole,
|
|
449
|
-
...elementProps
|
|
450
|
-
} = componentProps;
|
|
451
|
-
const {
|
|
452
|
-
node: portalNode,
|
|
453
|
-
nodeId: portalNodeId,
|
|
454
|
-
subtree: portalSubtree
|
|
455
|
-
} = useFloatingPortalNode({
|
|
456
|
-
container,
|
|
457
|
-
ref: forwardedRef,
|
|
458
|
-
componentProps,
|
|
459
|
-
elementProps
|
|
460
|
-
});
|
|
461
|
-
const beforeOutsideRef = React.useRef(null);
|
|
462
|
-
const afterOutsideRef = React.useRef(null);
|
|
463
|
-
const beforeInsideRef = React.useRef(null);
|
|
464
|
-
const afterInsideRef = React.useRef(null);
|
|
465
|
-
const [focusManagerState, setFocusManagerState] = React.useState(null);
|
|
466
|
-
const focusInsideDisabledRef = React.useRef(false);
|
|
467
|
-
const modal = focusManagerState == null ? void 0 : focusManagerState.modal;
|
|
468
|
-
const open2 = focusManagerState == null ? void 0 : focusManagerState.open;
|
|
469
|
-
const shouldRenderGuards = !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
|
|
470
|
-
React.useEffect(() => {
|
|
471
|
-
if (!portalNode || modal) {
|
|
472
|
-
return void 0;
|
|
473
|
-
}
|
|
474
|
-
function onFocus(event) {
|
|
475
|
-
if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
|
|
476
|
-
if (event.type === "focusin") {
|
|
477
|
-
if (focusInsideDisabledRef.current) {
|
|
478
|
-
enableFocusInside(portalNode);
|
|
479
|
-
focusInsideDisabledRef.current = false;
|
|
480
|
-
}
|
|
481
|
-
} else {
|
|
482
|
-
disableFocusInside(portalNode);
|
|
483
|
-
focusInsideDisabledRef.current = true;
|
|
484
|
-
}
|
|
479
|
+
const dependencies = Object.values(statePart);
|
|
480
|
+
useIsoLayoutEffect(() => {
|
|
481
|
+
store.update(statePart);
|
|
482
|
+
}, [store, ...dependencies]);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
|
|
486
|
+
* is non-undefined, the store's state at `key` is updated to match `controlled`.
|
|
487
|
+
*/
|
|
488
|
+
useControlledProp(key, controlled) {
|
|
489
|
+
React.useDebugValue(key);
|
|
490
|
+
const store = this;
|
|
491
|
+
const isControlled = controlled !== void 0;
|
|
492
|
+
useIsoLayoutEffect(() => {
|
|
493
|
+
if (isControlled && !Object.is(store.state[key], controlled)) {
|
|
494
|
+
store.setState({
|
|
495
|
+
...store.state,
|
|
496
|
+
[key]: controlled
|
|
497
|
+
});
|
|
485
498
|
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}, [open2, portalNode]);
|
|
496
|
-
const portalContextValue = React.useMemo(() => ({
|
|
497
|
-
beforeOutsideRef,
|
|
498
|
-
afterOutsideRef,
|
|
499
|
-
beforeInsideRef,
|
|
500
|
-
afterInsideRef,
|
|
501
|
-
portalNode,
|
|
502
|
-
setFocusManagerState
|
|
503
|
-
}), [portalNode]);
|
|
504
|
-
return /* @__PURE__ */ jsxs(React.Fragment, {
|
|
505
|
-
children: [portalSubtree, /* @__PURE__ */ jsxs(PortalContext.Provider, {
|
|
506
|
-
value: portalContextValue,
|
|
507
|
-
children: [shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
|
|
508
|
-
"data-type": "outside",
|
|
509
|
-
ref: beforeOutsideRef,
|
|
510
|
-
onFocus: (event) => {
|
|
511
|
-
var _a2;
|
|
512
|
-
if (isOutsideEvent(event, portalNode)) {
|
|
513
|
-
(_a2 = beforeInsideRef.current) == null ? void 0 : _a2.focus();
|
|
514
|
-
} else {
|
|
515
|
-
const domReference = focusManagerState ? focusManagerState.domReference : null;
|
|
516
|
-
const prevTabbable = getPreviousTabbable(domReference);
|
|
517
|
-
prevTabbable == null ? void 0 : prevTabbable.focus();
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx("span", {
|
|
521
|
-
role: portalOwnerRole,
|
|
522
|
-
"aria-owns": portalNodeId,
|
|
523
|
-
style: ownerVisuallyHidden
|
|
524
|
-
}), portalNode && /* @__PURE__ */ ReactDOM.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
|
|
525
|
-
"data-type": "outside",
|
|
526
|
-
ref: afterOutsideRef,
|
|
527
|
-
onFocus: (event) => {
|
|
528
|
-
var _a2;
|
|
529
|
-
if (isOutsideEvent(event, portalNode)) {
|
|
530
|
-
(_a2 = afterInsideRef.current) == null ? void 0 : _a2.focus();
|
|
531
|
-
} else {
|
|
532
|
-
const domReference = focusManagerState ? focusManagerState.domReference : null;
|
|
533
|
-
const nextTabbable = getNextTabbable(domReference);
|
|
534
|
-
nextTabbable == null ? void 0 : nextTabbable.focus();
|
|
535
|
-
if (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) {
|
|
536
|
-
focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, createChangeEventDetails(focusOut, event.nativeEvent));
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
})]
|
|
541
|
-
})]
|
|
542
|
-
});
|
|
543
|
-
});
|
|
544
|
-
if (process.env.NODE_ENV !== "production") FloatingPortal.displayName = "FloatingPortal";
|
|
545
|
-
function createEventEmitter() {
|
|
546
|
-
const map = /* @__PURE__ */ new Map();
|
|
547
|
-
return {
|
|
548
|
-
emit(event, data) {
|
|
549
|
-
var _a2;
|
|
550
|
-
(_a2 = map.get(event)) == null ? void 0 : _a2.forEach((listener) => listener(data));
|
|
551
|
-
},
|
|
552
|
-
on(event, listener) {
|
|
553
|
-
if (!map.has(event)) {
|
|
554
|
-
map.set(event, /* @__PURE__ */ new Set());
|
|
499
|
+
}, [store, key, controlled, isControlled]);
|
|
500
|
+
if (process.env.NODE_ENV !== "production") {
|
|
501
|
+
const cache = this.controlledValues ?? (this.controlledValues = /* @__PURE__ */ new Map());
|
|
502
|
+
if (!cache.has(key)) {
|
|
503
|
+
cache.set(key, isControlled);
|
|
504
|
+
}
|
|
505
|
+
const previouslyControlled = cache.get(key);
|
|
506
|
+
if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
|
|
507
|
+
console.error(`A component is changing the ${previouslyControlled ? "" : "un"}controlled state of ${key.toString()} to be ${previouslyControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
|
|
555
508
|
}
|
|
556
|
-
map.get(event).add(listener);
|
|
557
|
-
},
|
|
558
|
-
off(event, listener) {
|
|
559
|
-
var _a2;
|
|
560
|
-
(_a2 = map.get(event)) == null ? void 0 : _a2.delete(listener);
|
|
561
509
|
}
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
class FloatingTreeStore {
|
|
565
|
-
constructor() {
|
|
566
|
-
__publicField(this, "nodesRef", {
|
|
567
|
-
current: []
|
|
568
|
-
});
|
|
569
|
-
__publicField(this, "events", createEventEmitter());
|
|
570
510
|
}
|
|
571
|
-
|
|
572
|
-
|
|
511
|
+
/** Gets the current value from the store using a selector with the provided key.
|
|
512
|
+
*
|
|
513
|
+
* @param key Key of the selector to use.
|
|
514
|
+
*/
|
|
515
|
+
select(key, a1, a2, a3) {
|
|
516
|
+
const selector = this.selectors[key];
|
|
517
|
+
return selector(this.state, a1, a2, a3);
|
|
573
518
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
519
|
+
/**
|
|
520
|
+
* Returns a value from the store's state using a selector function.
|
|
521
|
+
* Used to subscribe to specific parts of the state.
|
|
522
|
+
* This methods causes a rerender whenever the selected state changes.
|
|
523
|
+
*
|
|
524
|
+
* @param key Key of the selector to use.
|
|
525
|
+
*/
|
|
526
|
+
useState(key, a1, a2, a3) {
|
|
527
|
+
React.useDebugValue(key);
|
|
528
|
+
return useStore(this, this.selectors[key], a1, a2, a3);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Wraps a function with `useStableCallback` to ensure it has a stable reference
|
|
532
|
+
* and assigns it to the context.
|
|
533
|
+
*
|
|
534
|
+
* @param key Key of the event callback. Must be a function in the context.
|
|
535
|
+
* @param fn Function to assign.
|
|
536
|
+
*/
|
|
537
|
+
useContextCallback(key, fn) {
|
|
538
|
+
React.useDebugValue(key);
|
|
539
|
+
const stableFunction = useStableCallback(fn ?? NOOP);
|
|
540
|
+
this.context[key] = stableFunction;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Returns a stable setter function for a specific key in the store's state.
|
|
544
|
+
* It's commonly used to pass as a ref callback to React elements.
|
|
545
|
+
*
|
|
546
|
+
* @param key Key of the state to set.
|
|
547
|
+
*/
|
|
548
|
+
useStateSetter(key) {
|
|
549
|
+
const ref = React.useRef(void 0);
|
|
550
|
+
if (ref.current === void 0) {
|
|
551
|
+
ref.current = (value) => {
|
|
552
|
+
this.set(key, value);
|
|
553
|
+
};
|
|
578
554
|
}
|
|
555
|
+
return ref.current;
|
|
579
556
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
};
|
|
593
|
-
function useFloatingNodeId(externalTree) {
|
|
594
|
-
const id = useId();
|
|
595
|
-
const tree = useFloatingTree(externalTree);
|
|
596
|
-
const parentId = useFloatingParentNodeId();
|
|
597
|
-
useIsoLayoutEffect(() => {
|
|
598
|
-
if (!id) {
|
|
599
|
-
return void 0;
|
|
557
|
+
/**
|
|
558
|
+
* Observes changes derived from the store's selectors and calls the listener when the selected value changes.
|
|
559
|
+
*
|
|
560
|
+
* @param key Key of the selector to observe.
|
|
561
|
+
* @param listener Listener function called when the selector result changes.
|
|
562
|
+
*/
|
|
563
|
+
observe(selector, listener) {
|
|
564
|
+
let selectFn;
|
|
565
|
+
if (typeof selector === "function") {
|
|
566
|
+
selectFn = selector;
|
|
567
|
+
} else {
|
|
568
|
+
selectFn = this.selectors[selector];
|
|
600
569
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
function FloatingNode(props) {
|
|
613
|
-
const {
|
|
614
|
-
children,
|
|
615
|
-
id
|
|
616
|
-
} = props;
|
|
617
|
-
const parentId = useFloatingParentNodeId();
|
|
618
|
-
return /* @__PURE__ */ jsx(FloatingNodeContext.Provider, {
|
|
619
|
-
value: React.useMemo(() => ({
|
|
620
|
-
id,
|
|
621
|
-
parentId
|
|
622
|
-
}), [id, parentId]),
|
|
623
|
-
children
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
function FloatingTree(props) {
|
|
627
|
-
const {
|
|
628
|
-
children,
|
|
629
|
-
externalTree
|
|
630
|
-
} = props;
|
|
631
|
-
const tree = useRefWithInit(() => externalTree ?? new FloatingTreeStore()).current;
|
|
632
|
-
return /* @__PURE__ */ jsx(FloatingTreeContext.Provider, {
|
|
633
|
-
value: tree,
|
|
634
|
-
children
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
function alwaysFalse() {
|
|
638
|
-
return false;
|
|
570
|
+
let prevValue = selectFn(this.state);
|
|
571
|
+
listener(prevValue, prevValue, this);
|
|
572
|
+
return this.subscribe((nextState) => {
|
|
573
|
+
const nextValue = selectFn(nextState);
|
|
574
|
+
if (!Object.is(prevValue, nextValue)) {
|
|
575
|
+
const oldValue = prevValue;
|
|
576
|
+
prevValue = nextValue;
|
|
577
|
+
listener(nextValue, oldValue, this);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
639
581
|
}
|
|
640
|
-
function
|
|
641
|
-
return {
|
|
642
|
-
|
|
643
|
-
|
|
582
|
+
function mergeCleanups(...cleanups) {
|
|
583
|
+
return () => {
|
|
584
|
+
for (let i = 0; i < cleanups.length; i += 1) {
|
|
585
|
+
const cleanup = cleanups[i];
|
|
586
|
+
if (cleanup) {
|
|
587
|
+
cleanup();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
644
590
|
};
|
|
645
591
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const isComposingRef = React.useRef(false);
|
|
676
|
-
const currentPointerTypeRef = React.useRef("");
|
|
677
|
-
const touchStateRef = React.useRef(null);
|
|
678
|
-
const cancelDismissOnEndTimeout = useTimeout();
|
|
679
|
-
const clearInsideReactTreeTimeout = useTimeout();
|
|
680
|
-
const compositionTimeout = useTimeout();
|
|
681
|
-
const clearInsideReactTree = useStableCallback(() => {
|
|
682
|
-
clearInsideReactTreeTimeout.clear();
|
|
683
|
-
dataRef.current.insideReactTree = false;
|
|
684
|
-
});
|
|
685
|
-
const hasBlockingChild = useStableCallback((bubbleKey) => {
|
|
686
|
-
var _a2;
|
|
687
|
-
const nodeId = (_a2 = dataRef.current.floatingContext) == null ? void 0 : _a2.nodeId;
|
|
688
|
-
const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
|
|
689
|
-
return children.some((child) => {
|
|
690
|
-
var _a3;
|
|
691
|
-
return ((_a3 = child.context) == null ? void 0 : _a3.open) && !child.context.dataRef.current[bubbleKey];
|
|
692
|
-
});
|
|
693
|
-
});
|
|
694
|
-
const isEventWithinOwnElements = useStableCallback((event) => {
|
|
695
|
-
return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
|
|
696
|
-
});
|
|
697
|
-
const closeOnReferencePress = useStableCallback((event) => {
|
|
698
|
-
if (!referencePress()) {
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
store.setOpen(false, createChangeEventDetails(triggerPress, event.nativeEvent));
|
|
702
|
-
});
|
|
703
|
-
const closeOnEscapeKeyDown = useStableCallback((event) => {
|
|
704
|
-
if (!open2 || !enabled || !escapeKey$1 || event.key !== "Escape") {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
const native = isReactEvent(event) ? event.nativeEvent : event;
|
|
708
|
-
if (isComposingRef.current || native.isComposing) {
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
const eventDetails = createChangeEventDetails(escapeKey, native);
|
|
715
|
-
store.setOpen(false, eventDetails);
|
|
716
|
-
if (!eventDetails.isCanceled) {
|
|
717
|
-
event.preventDefault();
|
|
592
|
+
const webkit = typeof CSS !== "undefined" && !!((_a = CSS.supports) == null ? void 0 : _a.call(CSS, "-webkit-backdrop-filter:none"));
|
|
593
|
+
const gecko = !webkit && lowerUserAgent.includes("firefox");
|
|
594
|
+
!webkit && lowerUserAgent.includes("chrom");
|
|
595
|
+
const voiceOver = apple;
|
|
596
|
+
const open = "data-open";
|
|
597
|
+
const closed = "data-closed";
|
|
598
|
+
const anchorHidden = "data-anchor-hidden";
|
|
599
|
+
const popupOpen = "data-popup-open";
|
|
600
|
+
const pressed = "data-pressed";
|
|
601
|
+
const TRIGGER_HOOK = {
|
|
602
|
+
[popupOpen]: ""
|
|
603
|
+
};
|
|
604
|
+
const PRESSABLE_TRIGGER_HOOK = {
|
|
605
|
+
[popupOpen]: "",
|
|
606
|
+
[pressed]: ""
|
|
607
|
+
};
|
|
608
|
+
const POPUP_OPEN_HOOK = {
|
|
609
|
+
[open]: ""
|
|
610
|
+
};
|
|
611
|
+
const POPUP_CLOSED_HOOK = {
|
|
612
|
+
[closed]: ""
|
|
613
|
+
};
|
|
614
|
+
const ANCHOR_HIDDEN_HOOK = {
|
|
615
|
+
[anchorHidden]: ""
|
|
616
|
+
};
|
|
617
|
+
const triggerOpenStateMapping = {
|
|
618
|
+
open(value) {
|
|
619
|
+
if (value) {
|
|
620
|
+
return TRIGGER_HOOK;
|
|
718
621
|
}
|
|
719
|
-
|
|
720
|
-
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
const pressableTriggerOpenStateMapping = {
|
|
626
|
+
open(value) {
|
|
627
|
+
if (value) {
|
|
628
|
+
return PRESSABLE_TRIGGER_HOOK;
|
|
721
629
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
return;
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
const popupStateMapping = {
|
|
634
|
+
open(value) {
|
|
635
|
+
if (value) {
|
|
636
|
+
return POPUP_OPEN_HOOK;
|
|
730
637
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
638
|
+
return POPUP_CLOSED_HOOK;
|
|
639
|
+
},
|
|
640
|
+
anchorHidden(value) {
|
|
641
|
+
if (value) {
|
|
642
|
+
return ANCHOR_HIDDEN_HOOK;
|
|
734
643
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
const popupTransitionStateMapping = {
|
|
648
|
+
...popupStateMapping,
|
|
649
|
+
...transitionStatusMapping
|
|
650
|
+
};
|
|
651
|
+
const FocusGuard = /* @__PURE__ */ React.forwardRef(function FocusGuard2(props, ref) {
|
|
652
|
+
const [role, setRole] = React.useState();
|
|
653
|
+
useIsoLayoutEffect(() => {
|
|
654
|
+
if (voiceOver && webkit) {
|
|
655
|
+
setRole("button");
|
|
738
656
|
}
|
|
657
|
+
}, []);
|
|
658
|
+
const restProps = {
|
|
659
|
+
tabIndex: 0,
|
|
660
|
+
// Role is only for VoiceOver
|
|
661
|
+
role
|
|
662
|
+
};
|
|
663
|
+
return /* @__PURE__ */ jsx("span", {
|
|
664
|
+
...props,
|
|
665
|
+
ref,
|
|
666
|
+
style: visuallyHidden,
|
|
667
|
+
"aria-hidden": role ? void 0 : true,
|
|
668
|
+
...restProps,
|
|
669
|
+
"data-base-ui-focus-guard": ""
|
|
739
670
|
});
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
671
|
+
});
|
|
672
|
+
if (process.env.NODE_ENV !== "production") FocusGuard.displayName = "FocusGuard";
|
|
673
|
+
const CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
|
|
674
|
+
function getParentElement(element) {
|
|
675
|
+
const assignedSlot = element.assignedSlot;
|
|
676
|
+
if (assignedSlot) {
|
|
677
|
+
return assignedSlot;
|
|
678
|
+
}
|
|
679
|
+
if (element.parentElement) {
|
|
680
|
+
return element.parentElement;
|
|
681
|
+
}
|
|
682
|
+
const rootNode = element.getRootNode();
|
|
683
|
+
return isShadowRoot(rootNode) ? rootNode.host : null;
|
|
684
|
+
}
|
|
685
|
+
function getDetailsSummary(details) {
|
|
686
|
+
for (const child of Array.from(details.children)) {
|
|
687
|
+
if (getNodeName(child) === "summary") {
|
|
688
|
+
return child;
|
|
743
689
|
}
|
|
744
|
-
|
|
745
|
-
|
|
690
|
+
}
|
|
691
|
+
return null;
|
|
692
|
+
}
|
|
693
|
+
function isWithinOpenDetailsSummary(element, details) {
|
|
694
|
+
const summary = getDetailsSummary(details);
|
|
695
|
+
return !!summary && (element === summary || contains(summary, element));
|
|
696
|
+
}
|
|
697
|
+
function isFocusableCandidate(element) {
|
|
698
|
+
const nodeName = element ? getNodeName(element) : "";
|
|
699
|
+
return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
|
|
700
|
+
}
|
|
701
|
+
function isFocusableElement(element) {
|
|
702
|
+
if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
for (let current = element; current; current = getParentElement(current)) {
|
|
706
|
+
const isAncestor = current !== element;
|
|
707
|
+
const isSlot = getNodeName(current) === "slot";
|
|
708
|
+
if (current.hasAttribute("inert")) {
|
|
709
|
+
return false;
|
|
746
710
|
}
|
|
747
|
-
if (
|
|
748
|
-
|
|
711
|
+
if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
|
|
712
|
+
return false;
|
|
749
713
|
}
|
|
714
|
+
}
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
717
|
+
function isVisibleInTabbableTree(element, isAncestor) {
|
|
718
|
+
const styles = getComputedStyle(element);
|
|
719
|
+
if (!isAncestor) {
|
|
720
|
+
return isElementVisible(element, styles);
|
|
721
|
+
}
|
|
722
|
+
return styles.display !== "none";
|
|
723
|
+
}
|
|
724
|
+
function getTabIndex(element) {
|
|
725
|
+
const tabIndex = element.tabIndex;
|
|
726
|
+
if (tabIndex < 0) {
|
|
727
|
+
const nodeName = getNodeName(element);
|
|
728
|
+
if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
|
|
729
|
+
return 0;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return tabIndex;
|
|
733
|
+
}
|
|
734
|
+
function getNamedRadioInput(element) {
|
|
735
|
+
if (getNodeName(element) !== "input") {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
const input = element;
|
|
739
|
+
return input.type === "radio" && input.name !== "" ? input : null;
|
|
740
|
+
}
|
|
741
|
+
function isTabbableRadio(element, candidates) {
|
|
742
|
+
const input = getNamedRadioInput(element);
|
|
743
|
+
if (!input) {
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
const checkedRadio = candidates.find((candidate) => {
|
|
747
|
+
const radio = getNamedRadioInput(candidate);
|
|
748
|
+
return (radio == null ? void 0 : radio.name) === input.name && radio.form === input.form && radio.checked;
|
|
750
749
|
});
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
750
|
+
if (checkedRadio) {
|
|
751
|
+
return checkedRadio === input;
|
|
752
|
+
}
|
|
753
|
+
return candidates.find((candidate) => {
|
|
754
|
+
const radio = getNamedRadioInput(candidate);
|
|
755
|
+
return (radio == null ? void 0 : radio.name) === input.name && radio.form === input.form;
|
|
756
|
+
}) === input;
|
|
757
|
+
}
|
|
758
|
+
function getComposedChildren(container) {
|
|
759
|
+
if (isHTMLElement(container) && getNodeName(container) === "slot") {
|
|
760
|
+
const assignedElements = container.assignedElements({
|
|
761
|
+
flatten: true
|
|
762
|
+
});
|
|
763
|
+
if (assignedElements.length > 0) {
|
|
764
|
+
return assignedElements;
|
|
756
765
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
isComposingRef.current = false;
|
|
768
|
-
currentPointerTypeRef.current = "";
|
|
769
|
-
touchStateRef.current = null;
|
|
770
|
-
}
|
|
771
|
-
return clearInsideReactTree;
|
|
766
|
+
}
|
|
767
|
+
if (isHTMLElement(container) && container.shadowRoot) {
|
|
768
|
+
return Array.from(container.shadowRoot.children);
|
|
769
|
+
}
|
|
770
|
+
return Array.from(container.children);
|
|
771
|
+
}
|
|
772
|
+
function appendCandidates(container, list) {
|
|
773
|
+
getComposedChildren(container).forEach((child) => {
|
|
774
|
+
if (isFocusableCandidate(child)) {
|
|
775
|
+
list.push(child);
|
|
772
776
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
777
|
+
appendCandidates(child, list);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function appendMatchingElements(container, selector, list) {
|
|
781
|
+
getComposedChildren(container).forEach((child) => {
|
|
782
|
+
if (isHTMLElement(child) && child.matches(selector)) {
|
|
783
|
+
list.push(child);
|
|
780
784
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
785
|
+
appendMatchingElements(child, selector, list);
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
function isTabbable(element) {
|
|
789
|
+
return isFocusableElement(element) && getTabIndex(element) >= 0;
|
|
790
|
+
}
|
|
791
|
+
function focusable(container) {
|
|
792
|
+
const candidates = [];
|
|
793
|
+
appendCandidates(container, candidates);
|
|
794
|
+
return candidates.filter(isFocusableElement);
|
|
795
|
+
}
|
|
796
|
+
function tabbable(container) {
|
|
797
|
+
const candidates = focusable(container);
|
|
798
|
+
return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
|
|
799
|
+
}
|
|
800
|
+
function getTabbableIn(container, dir) {
|
|
801
|
+
const list = tabbable(container);
|
|
802
|
+
const len = list.length;
|
|
803
|
+
if (len === 0) {
|
|
804
|
+
return void 0;
|
|
805
|
+
}
|
|
806
|
+
const active = activeElement(ownerDocument(container));
|
|
807
|
+
const index = list.indexOf(active);
|
|
808
|
+
const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
|
|
809
|
+
return list[nextIndex];
|
|
810
|
+
}
|
|
811
|
+
function getNextTabbable(referenceElement) {
|
|
812
|
+
return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
|
|
813
|
+
}
|
|
814
|
+
function getPreviousTabbable(referenceElement) {
|
|
815
|
+
return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
|
|
816
|
+
}
|
|
817
|
+
function getTabbableNearElement(referenceElement, direction, exclude) {
|
|
818
|
+
if (!referenceElement) {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
const list = [];
|
|
822
|
+
appendCandidates(ownerDocument(referenceElement).body, list);
|
|
823
|
+
const index = list.indexOf(referenceElement);
|
|
824
|
+
if (index === -1) {
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
const candidates = list.filter(isFocusableElement);
|
|
828
|
+
for (let offset = 1; offset < list.length; offset += 1) {
|
|
829
|
+
const element = list[(index + direction * offset + list.length) % list.length];
|
|
830
|
+
if (!contains(exclude, element) && isTabbable(element) && isTabbableRadio(element, candidates)) {
|
|
831
|
+
return element;
|
|
791
832
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
833
|
+
}
|
|
834
|
+
return list[index];
|
|
835
|
+
}
|
|
836
|
+
function isOutsideEvent(event, container) {
|
|
837
|
+
const containerElement = container || event.currentTarget;
|
|
838
|
+
const relatedTarget = event.relatedTarget;
|
|
839
|
+
return !relatedTarget || !contains(containerElement, relatedTarget);
|
|
840
|
+
}
|
|
841
|
+
function disableFocusInside(container) {
|
|
842
|
+
const tabbableElements = tabbable(container);
|
|
843
|
+
tabbableElements.forEach((element) => {
|
|
844
|
+
element.dataset.tabindex = element.getAttribute("tabindex") || "";
|
|
845
|
+
element.setAttribute("tabindex", "-1");
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function enableFocusInside(container) {
|
|
849
|
+
const elements = [];
|
|
850
|
+
appendMatchingElements(container, "[data-tabindex]", elements);
|
|
851
|
+
elements.forEach((element) => {
|
|
852
|
+
const tabindex = element.dataset.tabindex;
|
|
853
|
+
delete element.dataset.tabindex;
|
|
854
|
+
if (tabindex) {
|
|
855
|
+
element.setAttribute("tabindex", tabindex);
|
|
856
|
+
} else {
|
|
857
|
+
element.removeAttribute("tabindex");
|
|
797
858
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
function getNodeChildren(nodes, id, onlyOpenChildren = true) {
|
|
862
|
+
const directChildren = nodes.filter((node) => node.parentId === id);
|
|
863
|
+
return directChildren.flatMap((child) => {
|
|
864
|
+
var _a2;
|
|
865
|
+
return [...!onlyOpenChildren || ((_a2 = child.context) == null ? void 0 : _a2.open) ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)];
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
function getNodeAncestors(nodes, id) {
|
|
869
|
+
var _a2;
|
|
870
|
+
let allAncestors = [];
|
|
871
|
+
let currentParentId = (_a2 = nodes.find((node) => node.id === id)) == null ? void 0 : _a2.parentId;
|
|
872
|
+
while (currentParentId) {
|
|
873
|
+
const currentNode = nodes.find((node) => node.id === currentParentId);
|
|
874
|
+
currentParentId = currentNode == null ? void 0 : currentNode.parentId;
|
|
875
|
+
if (currentNode) {
|
|
876
|
+
allAncestors = allAncestors.concat(currentNode);
|
|
801
877
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
878
|
+
}
|
|
879
|
+
return allAncestors;
|
|
880
|
+
}
|
|
881
|
+
function createAttribute(name) {
|
|
882
|
+
return `data-base-ui-${name}`;
|
|
883
|
+
}
|
|
884
|
+
const TYPEAHEAD_RESET_MS = 500;
|
|
885
|
+
const PATIENT_CLICK_THRESHOLD = 500;
|
|
886
|
+
const DISABLED_TRANSITIONS_STYLE = {
|
|
887
|
+
style: {
|
|
888
|
+
transition: "none"
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
const CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
|
|
892
|
+
const DROPDOWN_COLLISION_AVOIDANCE = {
|
|
893
|
+
fallbackAxisSide: "none"
|
|
894
|
+
};
|
|
895
|
+
const POPUP_COLLISION_AVOIDANCE = {
|
|
896
|
+
fallbackAxisSide: "end"
|
|
897
|
+
};
|
|
898
|
+
const ownerVisuallyHidden = {
|
|
899
|
+
clipPath: "inset(50%)",
|
|
900
|
+
position: "fixed",
|
|
901
|
+
top: 0,
|
|
902
|
+
left: 0
|
|
903
|
+
};
|
|
904
|
+
const PortalContext = /* @__PURE__ */ React.createContext(null);
|
|
905
|
+
if (process.env.NODE_ENV !== "production") PortalContext.displayName = "PortalContext";
|
|
906
|
+
const usePortalContext = () => React.useContext(PortalContext);
|
|
907
|
+
const attr = createAttribute("portal");
|
|
908
|
+
function useFloatingPortalNode(props = {}) {
|
|
909
|
+
const {
|
|
910
|
+
ref,
|
|
911
|
+
container: containerProp,
|
|
912
|
+
componentProps = EMPTY_OBJECT,
|
|
913
|
+
elementProps
|
|
914
|
+
} = props;
|
|
915
|
+
const uniqueId = useId();
|
|
916
|
+
const portalContext = usePortalContext();
|
|
917
|
+
const parentPortalNode = portalContext == null ? void 0 : portalContext.portalNode;
|
|
918
|
+
const [containerElement, setContainerElement] = React.useState(null);
|
|
919
|
+
const [portalNode, setPortalNode] = React.useState(null);
|
|
920
|
+
const setPortalNodeRef = useStableCallback((node) => {
|
|
921
|
+
if (node !== null) {
|
|
922
|
+
setPortalNode(node);
|
|
811
923
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
var _a3;
|
|
821
|
-
return isEventTargetWithin(event, (_a3 = node.context) == null ? void 0 : _a3.elements.floating);
|
|
822
|
-
});
|
|
823
|
-
return isEventWithinOwnElements(event) || targetIsInsideChildren;
|
|
824
|
-
}
|
|
825
|
-
function closeOnPressOutside(event) {
|
|
826
|
-
if (shouldIgnoreEvent(event)) {
|
|
827
|
-
if (event.type !== "click" && !isEventWithinOwnElements(event)) {
|
|
828
|
-
preventedPressSuppressionTimeout.clear();
|
|
829
|
-
suppressNextOutsideClickRef.current = false;
|
|
830
|
-
}
|
|
831
|
-
clearInsideReactTree();
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
if (dataRef.current.insideReactTree) {
|
|
835
|
-
clearInsideReactTree();
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
const target = getTarget(event);
|
|
839
|
-
const inertSelector = `[${createAttribute("inert")}]`;
|
|
840
|
-
const targetRoot = isElement(target) ? target.getRootNode() : null;
|
|
841
|
-
const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
|
|
842
|
-
const triggers = store.context.triggerElements;
|
|
843
|
-
if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
let targetRootAncestor = isElement(target) ? target : null;
|
|
847
|
-
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
848
|
-
const nextParent = getParentNode(targetRootAncestor);
|
|
849
|
-
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
|
|
850
|
-
break;
|
|
851
|
-
}
|
|
852
|
-
targetRootAncestor = nextParent;
|
|
853
|
-
}
|
|
854
|
-
if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
855
|
-
!contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
|
|
856
|
-
// element was injected after the floating element rendered.
|
|
857
|
-
markers.every((marker) => !contains(targetRootAncestor, marker))) {
|
|
858
|
-
return;
|
|
859
|
-
}
|
|
860
|
-
if (isHTMLElement(target) && !("touches" in event)) {
|
|
861
|
-
const lastTraversableNode = isLastTraversableNode(target);
|
|
862
|
-
const style = getComputedStyle(target);
|
|
863
|
-
const scrollRe = /auto|scroll/;
|
|
864
|
-
const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
|
|
865
|
-
const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
|
|
866
|
-
const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
|
|
867
|
-
const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
|
|
868
|
-
const isRTL = style.direction === "rtl";
|
|
869
|
-
const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
|
|
870
|
-
const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
|
|
871
|
-
if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
if (isEventWithinFloatingTree(event)) {
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
if (getOutsidePressEvent() === "intentional") {
|
|
879
|
-
if (event.detail !== 0 && !isVirtualClick(event) && !sawPressWhileOpenRef.current) {
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
if (suppressNextOutsideClickRef.current) {
|
|
883
|
-
preventedPressSuppressionTimeout.clear();
|
|
884
|
-
suppressNextOutsideClickRef.current = false;
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
if (typeof outsidePress$1 === "function" && !outsidePress$1(event)) {
|
|
889
|
-
return;
|
|
890
|
-
}
|
|
891
|
-
if (hasBlockingChild("__outsidePressBubbles")) {
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
894
|
-
store.setOpen(false, createChangeEventDetails(outsidePress, event));
|
|
895
|
-
clearInsideReactTree();
|
|
896
|
-
}
|
|
897
|
-
function handlePointerDown(event) {
|
|
898
|
-
if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
|
|
899
|
-
return;
|
|
924
|
+
});
|
|
925
|
+
const containerRef = React.useRef(null);
|
|
926
|
+
useIsoLayoutEffect(() => {
|
|
927
|
+
if (containerProp === null) {
|
|
928
|
+
if (containerRef.current) {
|
|
929
|
+
containerRef.current = null;
|
|
930
|
+
setPortalNode(null);
|
|
931
|
+
setContainerElement(null);
|
|
900
932
|
}
|
|
901
|
-
|
|
933
|
+
return;
|
|
902
934
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
touchStateRef.current = {
|
|
910
|
-
startTime: Date.now(),
|
|
911
|
-
startX: touch.clientX,
|
|
912
|
-
startY: touch.clientY,
|
|
913
|
-
dismissOnTouchEnd: false,
|
|
914
|
-
dismissOnMouseDown: true
|
|
915
|
-
};
|
|
916
|
-
cancelDismissOnEndTimeout.start(1e3, () => {
|
|
917
|
-
if (touchStateRef.current) {
|
|
918
|
-
touchStateRef.current.dismissOnTouchEnd = false;
|
|
919
|
-
touchStateRef.current.dismissOnMouseDown = false;
|
|
920
|
-
}
|
|
921
|
-
});
|
|
935
|
+
const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
|
|
936
|
+
if (resolvedContainer == null) {
|
|
937
|
+
if (containerRef.current) {
|
|
938
|
+
containerRef.current = null;
|
|
939
|
+
setPortalNode(null);
|
|
940
|
+
setContainerElement(null);
|
|
922
941
|
}
|
|
942
|
+
return;
|
|
923
943
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
}
|
|
929
|
-
const unsubscribe2 = addEventListener(target, event.type, () => {
|
|
930
|
-
listener(event);
|
|
931
|
-
unsubscribe2();
|
|
932
|
-
});
|
|
944
|
+
if (containerRef.current !== resolvedContainer) {
|
|
945
|
+
containerRef.current = resolvedContainer;
|
|
946
|
+
setPortalNode(null);
|
|
947
|
+
setContainerElement(resolvedContainer);
|
|
933
948
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
949
|
+
}, [containerProp, parentPortalNode]);
|
|
950
|
+
const portalElement = useRenderElement("div", componentProps, {
|
|
951
|
+
ref: [ref, setPortalNodeRef],
|
|
952
|
+
props: [{
|
|
953
|
+
id: uniqueId,
|
|
954
|
+
[attr]: ""
|
|
955
|
+
}, elementProps]
|
|
956
|
+
});
|
|
957
|
+
const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM.createPortal(portalElement, containerElement) : null;
|
|
958
|
+
return {
|
|
959
|
+
node: portalNode,
|
|
960
|
+
// `id` and `render` props can override or remove the generated ID. Use the exact
|
|
961
|
+
// rendered value so `aria-owns` never points at an ID absent from the DOM.
|
|
962
|
+
nodeId: /* @__PURE__ */ React.isValidElement(portalElement) ? portalElement.props.id : void 0,
|
|
963
|
+
subtree: portalSubtree
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
const FloatingPortal = /* @__PURE__ */ React.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
|
|
967
|
+
const {
|
|
968
|
+
render,
|
|
969
|
+
className,
|
|
970
|
+
style,
|
|
971
|
+
children,
|
|
972
|
+
container,
|
|
973
|
+
portalOwnerRole,
|
|
974
|
+
...elementProps
|
|
975
|
+
} = componentProps;
|
|
976
|
+
const {
|
|
977
|
+
node: portalNode,
|
|
978
|
+
nodeId: portalNodeId,
|
|
979
|
+
subtree: portalSubtree
|
|
980
|
+
} = useFloatingPortalNode({
|
|
981
|
+
container,
|
|
982
|
+
ref: forwardedRef,
|
|
983
|
+
componentProps,
|
|
984
|
+
elementProps
|
|
985
|
+
});
|
|
986
|
+
const beforeOutsideRef = React.useRef(null);
|
|
987
|
+
const afterOutsideRef = React.useRef(null);
|
|
988
|
+
const beforeInsideRef = React.useRef(null);
|
|
989
|
+
const afterInsideRef = React.useRef(null);
|
|
990
|
+
const [focusManagerState, setFocusManagerState] = React.useState(null);
|
|
991
|
+
const focusInsideDisabledRef = React.useRef(false);
|
|
992
|
+
const modal = focusManagerState == null ? void 0 : focusManagerState.modal;
|
|
993
|
+
const open2 = focusManagerState == null ? void 0 : focusManagerState.open;
|
|
994
|
+
const shouldRenderGuards = !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
|
|
995
|
+
React.useEffect(() => {
|
|
996
|
+
if (!portalNode || modal) {
|
|
997
|
+
return void 0;
|
|
937
998
|
}
|
|
938
|
-
function
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
}
|
|
946
|
-
if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
addTargetEventListenerOnce(event, (targetEvent) => {
|
|
950
|
-
if (targetEvent.type === "pointerdown") {
|
|
951
|
-
handlePointerDown(targetEvent);
|
|
999
|
+
function onFocus(event) {
|
|
1000
|
+
if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
|
|
1001
|
+
if (event.type === "focusin") {
|
|
1002
|
+
if (focusInsideDisabledRef.current) {
|
|
1003
|
+
enableFocusInside(portalNode);
|
|
1004
|
+
focusInsideDisabledRef.current = false;
|
|
1005
|
+
}
|
|
952
1006
|
} else {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
function handlePressEndCapture(event) {
|
|
958
|
-
if (event.type === "pointercancel") {
|
|
959
|
-
sawPressWhileOpenRef.current = false;
|
|
960
|
-
}
|
|
961
|
-
if (!pressStartedInsideRef.current) {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
|
-
const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
|
|
965
|
-
resetPressStartState();
|
|
966
|
-
if (getOutsidePressEvent() !== "intentional") {
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
if (event.type === "pointercancel") {
|
|
970
|
-
if (pressStartedInsideDefaultPrevented) {
|
|
971
|
-
suppressImmediateOutsideClickAfterPreventedStart();
|
|
1007
|
+
disableFocusInside(portalNode);
|
|
1008
|
+
focusInsideDisabledRef.current = true;
|
|
972
1009
|
}
|
|
973
|
-
return;
|
|
974
|
-
}
|
|
975
|
-
if (isEventWithinFloatingTree(event)) {
|
|
976
|
-
return;
|
|
977
1010
|
}
|
|
978
|
-
if (pressStartedInsideDefaultPrevented) {
|
|
979
|
-
suppressImmediateOutsideClickAfterPreventedStart();
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (typeof outsidePress$1 === "function" && !outsidePress$1(event)) {
|
|
983
|
-
return;
|
|
984
|
-
}
|
|
985
|
-
preventedPressSuppressionTimeout.clear();
|
|
986
|
-
suppressNextOutsideClickRef.current = true;
|
|
987
|
-
clearInsideReactTree();
|
|
988
1011
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
if (!touch) {
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
|
|
998
|
-
const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
|
|
999
|
-
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1000
|
-
if (distance > 5) {
|
|
1001
|
-
touchStateRef.current.dismissOnTouchEnd = true;
|
|
1002
|
-
}
|
|
1003
|
-
if (distance > 10) {
|
|
1004
|
-
closeOnPressOutside(event);
|
|
1005
|
-
cancelDismissOnEndTimeout.clear();
|
|
1006
|
-
touchStateRef.current = null;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
function handleTouchMoveCapture(event) {
|
|
1010
|
-
addTargetEventListenerOnce(event, handleTouchMove);
|
|
1012
|
+
return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
|
|
1013
|
+
}, [portalNode, modal]);
|
|
1014
|
+
useIsoLayoutEffect(() => {
|
|
1015
|
+
if (!portalNode || open2 !== true || !focusInsideDisabledRef.current) {
|
|
1016
|
+
return;
|
|
1011
1017
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
+
enableFocusInside(portalNode);
|
|
1019
|
+
focusInsideDisabledRef.current = false;
|
|
1020
|
+
}, [open2, portalNode]);
|
|
1021
|
+
const portalContextValue = React.useMemo(() => ({
|
|
1022
|
+
beforeOutsideRef,
|
|
1023
|
+
afterOutsideRef,
|
|
1024
|
+
beforeInsideRef,
|
|
1025
|
+
afterInsideRef,
|
|
1026
|
+
portalNode,
|
|
1027
|
+
setFocusManagerState
|
|
1028
|
+
}), [portalNode]);
|
|
1029
|
+
return /* @__PURE__ */ jsxs(React.Fragment, {
|
|
1030
|
+
children: [portalSubtree, /* @__PURE__ */ jsxs(PortalContext.Provider, {
|
|
1031
|
+
value: portalContextValue,
|
|
1032
|
+
children: [shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
|
|
1033
|
+
"data-type": "outside",
|
|
1034
|
+
ref: beforeOutsideRef,
|
|
1035
|
+
onFocus: (event) => {
|
|
1036
|
+
var _a2;
|
|
1037
|
+
if (isOutsideEvent(event, portalNode)) {
|
|
1038
|
+
(_a2 = beforeInsideRef.current) == null ? void 0 : _a2.focus();
|
|
1039
|
+
} else {
|
|
1040
|
+
const domReference = focusManagerState ? focusManagerState.domReference : null;
|
|
1041
|
+
const prevTabbable = getPreviousTabbable(domReference);
|
|
1042
|
+
prevTabbable == null ? void 0 : prevTabbable.focus();
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx("span", {
|
|
1046
|
+
role: portalOwnerRole,
|
|
1047
|
+
"aria-owns": portalNodeId,
|
|
1048
|
+
style: ownerVisuallyHidden
|
|
1049
|
+
}), portalNode && /* @__PURE__ */ ReactDOM.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
|
|
1050
|
+
"data-type": "outside",
|
|
1051
|
+
ref: afterOutsideRef,
|
|
1052
|
+
onFocus: (event) => {
|
|
1053
|
+
var _a2;
|
|
1054
|
+
if (isOutsideEvent(event, portalNode)) {
|
|
1055
|
+
(_a2 = afterInsideRef.current) == null ? void 0 : _a2.focus();
|
|
1056
|
+
} else {
|
|
1057
|
+
const domReference = focusManagerState ? focusManagerState.domReference : null;
|
|
1058
|
+
const nextTabbable = getNextTabbable(domReference);
|
|
1059
|
+
nextTabbable == null ? void 0 : nextTabbable.focus();
|
|
1060
|
+
if (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) {
|
|
1061
|
+
focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, createChangeEventDetails(focusOut, event.nativeEvent));
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
})]
|
|
1066
|
+
})]
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
1069
|
+
if (process.env.NODE_ENV !== "production") FloatingPortal.displayName = "FloatingPortal";
|
|
1070
|
+
function createEventEmitter() {
|
|
1071
|
+
const map = /* @__PURE__ */ new Map();
|
|
1072
|
+
return {
|
|
1073
|
+
emit(event, data) {
|
|
1074
|
+
var _a2;
|
|
1075
|
+
(_a2 = map.get(event)) == null ? void 0 : _a2.forEach((listener) => listener(data));
|
|
1076
|
+
},
|
|
1077
|
+
on(event, listener) {
|
|
1078
|
+
if (!map.has(event)) {
|
|
1079
|
+
map.set(event, /* @__PURE__ */ new Set());
|
|
1018
1080
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1081
|
+
map.get(event).add(listener);
|
|
1082
|
+
},
|
|
1083
|
+
off(event, listener) {
|
|
1084
|
+
var _a2;
|
|
1085
|
+
(_a2 = map.get(event)) == null ? void 0 : _a2.delete(listener);
|
|
1021
1086
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
class FloatingTreeStore {
|
|
1090
|
+
constructor() {
|
|
1091
|
+
__publicField(this, "nodesRef", {
|
|
1092
|
+
current: []
|
|
1093
|
+
});
|
|
1094
|
+
__publicField(this, "events", createEventEmitter());
|
|
1095
|
+
}
|
|
1096
|
+
addNode(node) {
|
|
1097
|
+
this.nodesRef.current.push(node);
|
|
1098
|
+
}
|
|
1099
|
+
removeNode(node) {
|
|
1100
|
+
const index = this.nodesRef.current.findIndex((n) => n === node);
|
|
1101
|
+
if (index !== -1) {
|
|
1102
|
+
this.nodesRef.current.splice(index, 1);
|
|
1024
1103
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
|
|
1107
|
+
if (process.env.NODE_ENV !== "production") FloatingNodeContext.displayName = "FloatingNodeContext";
|
|
1108
|
+
const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
|
|
1109
|
+
if (process.env.NODE_ENV !== "production") FloatingTreeContext.displayName = "FloatingTreeContext";
|
|
1110
|
+
const useFloatingParentNodeId = () => {
|
|
1111
|
+
var _a2;
|
|
1112
|
+
return ((_a2 = React.useContext(FloatingNodeContext)) == null ? void 0 : _a2.id) || null;
|
|
1113
|
+
};
|
|
1114
|
+
const useFloatingTree = (externalTree) => {
|
|
1115
|
+
const contextTree = React.useContext(FloatingTreeContext);
|
|
1116
|
+
return externalTree ?? contextTree;
|
|
1117
|
+
};
|
|
1118
|
+
function useFloatingNodeId(externalTree) {
|
|
1119
|
+
const id = useId();
|
|
1120
|
+
const tree = useFloatingTree(externalTree);
|
|
1121
|
+
const parentId = useFloatingParentNodeId();
|
|
1122
|
+
useIsoLayoutEffect(() => {
|
|
1123
|
+
if (!id) {
|
|
1124
|
+
return void 0;
|
|
1125
|
+
}
|
|
1126
|
+
const node = {
|
|
1127
|
+
id,
|
|
1128
|
+
parentId
|
|
1129
|
+
};
|
|
1130
|
+
tree == null ? void 0 : tree.addNode(node);
|
|
1035
1131
|
return () => {
|
|
1036
|
-
|
|
1037
|
-
preventedPressSuppressionTimeout.clear();
|
|
1038
|
-
resetPressStartState();
|
|
1039
|
-
suppressNextOutsideClickRef.current = false;
|
|
1132
|
+
tree == null ? void 0 : tree.removeNode(node);
|
|
1040
1133
|
};
|
|
1041
|
-
}, [
|
|
1042
|
-
|
|
1043
|
-
onKeyDown: closeOnEscapeKeyDown,
|
|
1044
|
-
onPointerDown: closeOnReferencePress,
|
|
1045
|
-
onClick: closeOnReferencePress
|
|
1046
|
-
}), [closeOnEscapeKeyDown, closeOnReferencePress]);
|
|
1047
|
-
const floating = React.useMemo(() => ({
|
|
1048
|
-
onKeyDown: closeOnEscapeKeyDown,
|
|
1049
|
-
// `onMouseDown` may be blocked if `event.preventDefault()` is called in
|
|
1050
|
-
// `onPointerDown`, such as with <NumberField.ScrubArea>.
|
|
1051
|
-
// See https://github.com/mui/base-ui/pull/3379
|
|
1052
|
-
onPointerDown: markInsidePressStartPrevented,
|
|
1053
|
-
onMouseDown: markInsidePressStartPrevented,
|
|
1054
|
-
onClickCapture: markInsideReactTree,
|
|
1055
|
-
onMouseDownCapture(event) {
|
|
1056
|
-
markInsideReactTree();
|
|
1057
|
-
markPressStartedInsideReactTree(event);
|
|
1058
|
-
},
|
|
1059
|
-
onPointerDownCapture(event) {
|
|
1060
|
-
markInsideReactTree();
|
|
1061
|
-
markPressStartedInsideReactTree(event);
|
|
1062
|
-
},
|
|
1063
|
-
onMouseUpCapture: markInsideReactTree,
|
|
1064
|
-
onTouchEndCapture: markInsideReactTree,
|
|
1065
|
-
onTouchMoveCapture: markInsideReactTree
|
|
1066
|
-
}), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
|
|
1067
|
-
return React.useMemo(() => enabled ? {
|
|
1068
|
-
reference,
|
|
1069
|
-
floating,
|
|
1070
|
-
trigger: reference
|
|
1071
|
-
} : {}, [enabled, reference, floating]);
|
|
1134
|
+
}, [tree, id, parentId]);
|
|
1135
|
+
return id;
|
|
1072
1136
|
}
|
|
1073
|
-
function
|
|
1137
|
+
function FloatingNode(props) {
|
|
1074
1138
|
const {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
popupStore.useSyncedValue("floatingId", floatingId);
|
|
1087
|
-
useIsoLayoutEffect(() => {
|
|
1088
|
-
const valuesToSync = {
|
|
1089
|
-
open: open2,
|
|
1090
|
-
floatingId,
|
|
1091
|
-
referenceElement,
|
|
1092
|
-
floatingElement
|
|
1093
|
-
};
|
|
1094
|
-
if (isElement(referenceElement)) {
|
|
1095
|
-
valuesToSync.domReferenceElement = referenceElement;
|
|
1096
|
-
}
|
|
1097
|
-
if (store.state.positionReference === store.state.referenceElement) {
|
|
1098
|
-
valuesToSync.positionReference = referenceElement;
|
|
1099
|
-
}
|
|
1100
|
-
store.update(valuesToSync);
|
|
1101
|
-
}, [open2, floatingId, referenceElement, floatingElement, store]);
|
|
1102
|
-
store.context.onOpenChange = handleOpenChange;
|
|
1103
|
-
store.context.nested = nested;
|
|
1104
|
-
return store;
|
|
1139
|
+
children,
|
|
1140
|
+
id
|
|
1141
|
+
} = props;
|
|
1142
|
+
const parentId = useFloatingParentNodeId();
|
|
1143
|
+
return /* @__PURE__ */ jsx(FloatingNodeContext.Provider, {
|
|
1144
|
+
value: React.useMemo(() => ({
|
|
1145
|
+
id,
|
|
1146
|
+
parentId
|
|
1147
|
+
}), [id, parentId]),
|
|
1148
|
+
children
|
|
1149
|
+
});
|
|
1105
1150
|
}
|
|
1106
|
-
function
|
|
1151
|
+
function FloatingTree(props) {
|
|
1107
1152
|
const {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1153
|
+
children,
|
|
1154
|
+
externalTree
|
|
1155
|
+
} = props;
|
|
1156
|
+
const tree = useRefWithInit(() => externalTree ?? new FloatingTreeStore()).current;
|
|
1157
|
+
return /* @__PURE__ */ jsx(FloatingTreeContext.Provider, {
|
|
1158
|
+
value: tree,
|
|
1159
|
+
children
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
function alwaysFalse() {
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
function normalizeProp(normalizable) {
|
|
1166
|
+
return {
|
|
1167
|
+
escapeKey: typeof normalizable === "boolean" ? normalizable : (normalizable == null ? void 0 : normalizable.escapeKey) ?? false,
|
|
1168
|
+
outsidePress: typeof normalizable === "boolean" ? normalizable : (normalizable == null ? void 0 : normalizable.outsidePress) ?? true
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
function useDismiss(store, props = {}) {
|
|
1116
1172
|
const {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1173
|
+
enabled = true,
|
|
1174
|
+
escapeKey: escapeKey$1 = true,
|
|
1175
|
+
outsidePress: outsidePressProp = true,
|
|
1176
|
+
outsidePressEvent = "sloppy",
|
|
1177
|
+
referencePress = alwaysFalse,
|
|
1178
|
+
bubbles,
|
|
1179
|
+
externalTree
|
|
1180
|
+
} = props;
|
|
1181
|
+
const open2 = store.useState("open");
|
|
1182
|
+
const floatingElement = store.useState("floatingElement");
|
|
1183
|
+
const {
|
|
1184
|
+
dataRef,
|
|
1185
|
+
events
|
|
1186
|
+
} = store.context;
|
|
1187
|
+
const tree = useFloatingTree(externalTree);
|
|
1188
|
+
const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
|
|
1189
|
+
const outsidePress$1 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
|
|
1190
|
+
const outsidePressEnabled = outsidePress$1 !== false;
|
|
1191
|
+
const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
|
|
1192
|
+
const {
|
|
1193
|
+
escapeKey: escapeKeyBubbles,
|
|
1194
|
+
outsidePress: outsidePressBubbles
|
|
1195
|
+
} = normalizeProp(bubbles);
|
|
1196
|
+
const pressStartedInsideRef = React.useRef(false);
|
|
1197
|
+
const pressStartPreventedRef = React.useRef(false);
|
|
1198
|
+
const suppressNextOutsideClickRef = React.useRef(false);
|
|
1199
|
+
const sawPressWhileOpenRef = React.useRef(false);
|
|
1200
|
+
const isComposingRef = React.useRef(false);
|
|
1201
|
+
const currentPointerTypeRef = React.useRef("");
|
|
1202
|
+
const touchStateRef = React.useRef(null);
|
|
1203
|
+
const cancelDismissOnEndTimeout = useTimeout();
|
|
1204
|
+
const clearInsideReactTreeTimeout = useTimeout();
|
|
1205
|
+
const compositionTimeout = useTimeout();
|
|
1206
|
+
const clearInsideReactTree = useStableCallback(() => {
|
|
1207
|
+
clearInsideReactTreeTimeout.clear();
|
|
1208
|
+
dataRef.current.insideReactTree = false;
|
|
1209
|
+
});
|
|
1210
|
+
const hasBlockingChild = useStableCallback((bubbleKey) => {
|
|
1211
|
+
var _a2;
|
|
1212
|
+
const nodeId = (_a2 = dataRef.current.floatingContext) == null ? void 0 : _a2.nodeId;
|
|
1213
|
+
const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
|
|
1214
|
+
return children.some((child) => {
|
|
1215
|
+
var _a3;
|
|
1216
|
+
return ((_a3 = child.context) == null ? void 0 : _a3.open) && !child.context.dataRef.current[bubbleKey];
|
|
1217
|
+
});
|
|
1218
|
+
});
|
|
1219
|
+
const isEventWithinOwnElements = useStableCallback((event) => {
|
|
1220
|
+
return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
|
|
1221
|
+
});
|
|
1222
|
+
const closeOnReferencePress = useStableCallback((event) => {
|
|
1223
|
+
if (!referencePress()) {
|
|
1224
|
+
return;
|
|
1142
1225
|
}
|
|
1226
|
+
store.setOpen(false, createChangeEventDetails(triggerPress, event.nativeEvent));
|
|
1143
1227
|
});
|
|
1144
|
-
const
|
|
1145
|
-
if (!
|
|
1228
|
+
const closeOnEscapeKeyDown = useStableCallback((event) => {
|
|
1229
|
+
if (!open2 || !enabled || !escapeKey$1 || event.key !== "Escape") {
|
|
1146
1230
|
return;
|
|
1147
1231
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
rerender();
|
|
1232
|
+
const native = isReactEvent(event) ? event.nativeEvent : event;
|
|
1233
|
+
if (isComposingRef.current || native.isComposing) {
|
|
1151
1234
|
return;
|
|
1152
1235
|
}
|
|
1153
|
-
|
|
1236
|
+
if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
const eventDetails = createChangeEventDetails(escapeKey, native);
|
|
1240
|
+
store.setOpen(false, eventDetails);
|
|
1241
|
+
if (!eventDetails.isCanceled) {
|
|
1242
|
+
event.preventDefault();
|
|
1243
|
+
}
|
|
1244
|
+
if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
|
|
1245
|
+
event.stopPropagation();
|
|
1246
|
+
}
|
|
1154
1247
|
});
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1248
|
+
const markInsideReactTree = useStableCallback(() => {
|
|
1249
|
+
dataRef.current.insideReactTree = true;
|
|
1250
|
+
clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
|
|
1251
|
+
});
|
|
1252
|
+
const markPressStartedInsideReactTree = useStableCallback((event) => {
|
|
1253
|
+
if (!open2 || !enabled || event.button !== 0) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
const target = getTarget(event.nativeEvent);
|
|
1257
|
+
if (!contains(store.select("floatingElement"), target)) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
if (!pressStartedInsideRef.current) {
|
|
1261
|
+
pressStartedInsideRef.current = true;
|
|
1262
|
+
pressStartPreventedRef.current = false;
|
|
1163
1263
|
}
|
|
1164
1264
|
});
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
};
|
|
1176
|
-
function createDefaultInitialFocus(popupRef) {
|
|
1177
|
-
return (interactionType) => interactionType === "touch" ? popupRef.current : true;
|
|
1178
|
-
}
|
|
1179
|
-
function usePopupRootStore(createStore, treatPopupAsFloatingElement = false) {
|
|
1180
|
-
const floatingId = useId();
|
|
1181
|
-
const nested = useFloatingParentNodeId() != null;
|
|
1182
|
-
const store = useRefWithInit(() => createStore(floatingId, nested)).current;
|
|
1183
|
-
useSyncedFloatingRootContext({
|
|
1184
|
-
popupStore: store,
|
|
1185
|
-
treatPopupAsFloatingElement,
|
|
1186
|
-
floatingRootContext: store.state.floatingRootContext,
|
|
1187
|
-
floatingId,
|
|
1188
|
-
nested,
|
|
1189
|
-
onOpenChange: store.setOpen
|
|
1265
|
+
const markInsidePressStartPrevented = useStableCallback((event) => {
|
|
1266
|
+
if (!open2 || !enabled) {
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
if (pressStartedInsideRef.current) {
|
|
1273
|
+
pressStartPreventedRef.current = true;
|
|
1274
|
+
}
|
|
1190
1275
|
});
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
store
|
|
1196
|
-
}) {
|
|
1197
|
-
useIsoLayoutEffect(() => {
|
|
1198
|
-
return handle.attachStore(store);
|
|
1199
|
-
}, [handle, store]);
|
|
1200
|
-
return null;
|
|
1201
|
-
}
|
|
1202
|
-
function syncTriggerCount(store) {
|
|
1203
|
-
const triggerCount = store.context.triggerElements.size;
|
|
1204
|
-
if (store.select("open") && store.state.triggerCount !== triggerCount) {
|
|
1205
|
-
store.set("triggerCount", triggerCount);
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function useTriggerRegistration(id, store) {
|
|
1209
|
-
const registrationRef = React.useRef(null);
|
|
1210
|
-
return useStableCallback((element) => {
|
|
1211
|
-
const registration = registrationRef.current;
|
|
1212
|
-
if (registration !== null) {
|
|
1213
|
-
if (registration.element === element && registration.store === store && registration.id === id) {
|
|
1214
|
-
return;
|
|
1276
|
+
React.useEffect(() => {
|
|
1277
|
+
function handleOpenChange(details) {
|
|
1278
|
+
if (!details.open) {
|
|
1279
|
+
sawPressWhileOpenRef.current = false;
|
|
1215
1280
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1281
|
+
}
|
|
1282
|
+
events.on("openchange", handleOpenChange);
|
|
1283
|
+
return () => {
|
|
1284
|
+
events.off("openchange", handleOpenChange);
|
|
1285
|
+
};
|
|
1286
|
+
}, [events]);
|
|
1287
|
+
React.useEffect(() => clearInsideReactTree, [clearInsideReactTree]);
|
|
1288
|
+
React.useEffect(() => {
|
|
1289
|
+
if (!open2 || !enabled) {
|
|
1290
|
+
if (!open2) {
|
|
1291
|
+
sawPressWhileOpenRef.current = false;
|
|
1292
|
+
isComposingRef.current = false;
|
|
1293
|
+
currentPointerTypeRef.current = "";
|
|
1294
|
+
touchStateRef.current = null;
|
|
1221
1295
|
}
|
|
1296
|
+
return clearInsideReactTree;
|
|
1222
1297
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
syncTriggerCount(store);
|
|
1298
|
+
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
1299
|
+
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
1300
|
+
const preventedPressSuppressionTimeout = new Timeout();
|
|
1301
|
+
const doc = ownerDocument(floatingElement);
|
|
1302
|
+
function handleCompositionStart() {
|
|
1303
|
+
compositionTimeout.clear();
|
|
1304
|
+
isComposingRef.current = true;
|
|
1231
1305
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
let activeTriggerId = state.activeTriggerId;
|
|
1243
|
-
let activeTriggerElement = state.activeTriggerElement;
|
|
1244
|
-
if (triggerId || open2) {
|
|
1245
|
-
activeTriggerId = triggerId;
|
|
1246
|
-
activeTriggerElement = trigger ?? null;
|
|
1247
|
-
}
|
|
1248
|
-
return {
|
|
1249
|
-
open: open2,
|
|
1250
|
-
preventUnmountingOnClose,
|
|
1251
|
-
activeTriggerId,
|
|
1252
|
-
activeTriggerElement,
|
|
1253
|
-
// An open request without a trigger (a handle's `open(null)` or `openWithPayload()`) must not
|
|
1254
|
-
// be reassociated with a lone registered trigger later on. Controlled and default opens never
|
|
1255
|
-
// pass through here, so they keep claiming a lone trigger. A close request keeps the flag: a
|
|
1256
|
-
// controlled root may decline it and stay open, so the Root clears the flag only once the
|
|
1257
|
-
// popup is effectively closed.
|
|
1258
|
-
openedWithoutTrigger: open2 ? trigger == null : state.openedWithoutTrigger
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
function attachPreventUnmountOnClose(eventDetails) {
|
|
1262
|
-
let preventUnmountOnClose = false;
|
|
1263
|
-
eventDetails.preventUnmountOnClose = () => {
|
|
1264
|
-
preventUnmountOnClose = true;
|
|
1265
|
-
};
|
|
1266
|
-
return () => preventUnmountOnClose;
|
|
1267
|
-
}
|
|
1268
|
-
function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
|
|
1269
|
-
var _a2, _b, _c;
|
|
1270
|
-
const reason = eventDetails.reason;
|
|
1271
|
-
const isHover = reason === triggerHover;
|
|
1272
|
-
const isFocusOpen = nextOpen && reason === triggerFocus;
|
|
1273
|
-
const isDismissClose = !nextOpen && (reason === triggerPress || reason === escapeKey);
|
|
1274
|
-
const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
|
|
1275
|
-
(_b = (_a2 = store.context).onOpenChange) == null ? void 0 : _b.call(_a2, nextOpen, eventDetails);
|
|
1276
|
-
if (eventDetails.isCanceled) {
|
|
1277
|
-
return;
|
|
1278
|
-
}
|
|
1279
|
-
(_c = options.onBeforeDispatch) == null ? void 0 : _c.call(options);
|
|
1280
|
-
store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
|
|
1281
|
-
const changeState = () => {
|
|
1282
|
-
const popupOpenState = createPopupOpenState(store.state, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
|
|
1283
|
-
const updatedState = {
|
|
1284
|
-
...options.extraState,
|
|
1285
|
-
...popupOpenState
|
|
1286
|
-
};
|
|
1287
|
-
if (isFocusOpen) {
|
|
1288
|
-
updatedState.instantType = "focus";
|
|
1289
|
-
} else if (isDismissClose) {
|
|
1290
|
-
updatedState.instantType = "dismiss";
|
|
1291
|
-
} else if (isHover) {
|
|
1292
|
-
updatedState.instantType = void 0;
|
|
1306
|
+
function handleCompositionEnd() {
|
|
1307
|
+
isComposingRef.current = true;
|
|
1308
|
+
compositionTimeout.start(
|
|
1309
|
+
// 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
|
|
1310
|
+
// Only apply to WebKit for the test to remain 0ms.
|
|
1311
|
+
webkit ? 5 : 0,
|
|
1312
|
+
() => {
|
|
1313
|
+
isComposingRef.current = false;
|
|
1314
|
+
}
|
|
1315
|
+
);
|
|
1293
1316
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
changeState();
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
|
|
1303
|
-
const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
|
|
1304
|
-
const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
|
|
1305
|
-
const applyTriggerData = useStableCallback((element) => {
|
|
1306
|
-
const open2 = store.select("open");
|
|
1307
|
-
const activeTriggerId = store.select("activeTriggerId");
|
|
1308
|
-
if (activeTriggerId === triggerId) {
|
|
1309
|
-
const changes = {
|
|
1310
|
-
activeTriggerElement: element,
|
|
1311
|
-
...open2 ? stateUpdates : null
|
|
1312
|
-
};
|
|
1313
|
-
store.update(changes);
|
|
1314
|
-
return;
|
|
1317
|
+
function suppressImmediateOutsideClickAfterPreventedStart() {
|
|
1318
|
+
suppressNextOutsideClickRef.current = true;
|
|
1319
|
+
preventedPressSuppressionTimeout.start(0, () => {
|
|
1320
|
+
suppressNextOutsideClickRef.current = false;
|
|
1321
|
+
});
|
|
1315
1322
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
activeTriggerElement: element,
|
|
1320
|
-
...stateUpdates
|
|
1321
|
-
};
|
|
1322
|
-
store.update(changes);
|
|
1323
|
+
function resetPressStartState() {
|
|
1324
|
+
pressStartedInsideRef.current = false;
|
|
1325
|
+
pressStartPreventedRef.current = false;
|
|
1323
1326
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1327
|
+
function getOutsidePressEvent() {
|
|
1328
|
+
const type = currentPointerTypeRef.current;
|
|
1329
|
+
const computedType = type === "pen" || !type ? "mouse" : type;
|
|
1330
|
+
const outsidePressEventValue = getOutsidePressEventProp();
|
|
1331
|
+
const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
|
|
1332
|
+
if (typeof resolved === "string") {
|
|
1333
|
+
return resolved;
|
|
1334
|
+
}
|
|
1335
|
+
return resolved[computedType];
|
|
1329
1336
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
return () => registerTrigger(null);
|
|
1334
|
-
}, [registerTrigger, triggerElementRef, store, triggerId]);
|
|
1335
|
-
useIsoLayoutEffect(() => {
|
|
1336
|
-
if (isMountedByThisTrigger) {
|
|
1337
|
-
const changes = {
|
|
1338
|
-
activeTriggerElement: triggerElementRef.current,
|
|
1339
|
-
...stateUpdates
|
|
1340
|
-
};
|
|
1341
|
-
store.update(changes);
|
|
1337
|
+
function shouldIgnoreEvent(event) {
|
|
1338
|
+
const computedOutsidePressEvent = getOutsidePressEvent();
|
|
1339
|
+
return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
|
|
1342
1340
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
resolvedActiveTriggerIdRef.current = null;
|
|
1361
|
-
if (store.state.triggerCount !== 0) {
|
|
1362
|
-
store.set("triggerCount", 0);
|
|
1341
|
+
function isEventWithinFloatingTree(event) {
|
|
1342
|
+
var _a2;
|
|
1343
|
+
const nodeId = (_a2 = dataRef.current.floatingContext) == null ? void 0 : _a2.nodeId;
|
|
1344
|
+
const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => {
|
|
1345
|
+
var _a3;
|
|
1346
|
+
return isEventTargetWithin(event, (_a3 = node.context) == null ? void 0 : _a3.elements.floating);
|
|
1347
|
+
});
|
|
1348
|
+
return isEventWithinOwnElements(event) || targetIsInsideChildren;
|
|
1349
|
+
}
|
|
1350
|
+
function closeOnPressOutside(event) {
|
|
1351
|
+
if (shouldIgnoreEvent(event)) {
|
|
1352
|
+
if (event.type !== "click" && !isEventWithinOwnElements(event)) {
|
|
1353
|
+
preventedPressSuppressionTimeout.clear();
|
|
1354
|
+
suppressNextOutsideClickRef.current = false;
|
|
1355
|
+
}
|
|
1356
|
+
clearInsideReactTree();
|
|
1357
|
+
return;
|
|
1363
1358
|
}
|
|
1364
|
-
if (
|
|
1365
|
-
|
|
1359
|
+
if (dataRef.current.insideReactTree) {
|
|
1360
|
+
clearInsideReactTree();
|
|
1361
|
+
return;
|
|
1366
1362
|
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
if (triggerElement === store.state.activeTriggerElement) {
|
|
1381
|
-
stateUpdates.activeTriggerId = triggerId;
|
|
1382
|
-
stateUpdates.activeTriggerElement = triggerElement;
|
|
1383
|
-
resolvedActiveTriggerIdRef.current = triggerId;
|
|
1384
|
-
break;
|
|
1385
|
-
}
|
|
1363
|
+
const target = getTarget(event);
|
|
1364
|
+
const inertSelector = `[${createAttribute("inert")}]`;
|
|
1365
|
+
const targetRoot = isElement(target) ? target.getRootNode() : null;
|
|
1366
|
+
const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
|
|
1367
|
+
const triggers = store.context.triggerElements;
|
|
1368
|
+
if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
let targetRootAncestor = isElement(target) ? target : null;
|
|
1372
|
+
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
1373
|
+
const nextParent = getParentNode(targetRootAncestor);
|
|
1374
|
+
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
|
|
1375
|
+
break;
|
|
1386
1376
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1377
|
+
targetRootAncestor = nextParent;
|
|
1378
|
+
}
|
|
1379
|
+
if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
1380
|
+
!contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
|
|
1381
|
+
// element was injected after the floating element rendered.
|
|
1382
|
+
markers.every((marker) => !contains(targetRootAncestor, marker))) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
if (isHTMLElement(target) && !("touches" in event)) {
|
|
1386
|
+
const lastTraversableNode = isLastTraversableNode(target);
|
|
1387
|
+
const style = getComputedStyle(target);
|
|
1388
|
+
const scrollRe = /auto|scroll/;
|
|
1389
|
+
const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
|
|
1390
|
+
const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
|
|
1391
|
+
const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
|
|
1392
|
+
const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
|
|
1393
|
+
const isRTL = style.direction === "rtl";
|
|
1394
|
+
const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
|
|
1395
|
+
const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
|
|
1396
|
+
if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
|
|
1397
|
+
return;
|
|
1393
1398
|
}
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1399
|
+
}
|
|
1400
|
+
if (isEventWithinFloatingTree(event)) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (getOutsidePressEvent() === "intentional") {
|
|
1404
|
+
if (event.detail !== 0 && !isVirtualClick(event) && !sawPressWhileOpenRef.current) {
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
if (suppressNextOutsideClickRef.current) {
|
|
1408
|
+
preventedPressSuppressionTimeout.clear();
|
|
1409
|
+
suppressNextOutsideClickRef.current = false;
|
|
1410
|
+
return;
|
|
1398
1411
|
}
|
|
1399
1412
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
}
|
|
1403
|
-
if (!lostActiveTriggerId && !currentActiveTriggerId && !store.state.openedWithoutTrigger && triggerCount === 1) {
|
|
1404
|
-
const iteratorResult = store.context.triggerElements.entries().next();
|
|
1405
|
-
if (!iteratorResult.done) {
|
|
1406
|
-
const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
|
|
1407
|
-
stateUpdates.activeTriggerId = implicitTriggerId;
|
|
1408
|
-
stateUpdates.activeTriggerElement = implicitTriggerElement;
|
|
1409
|
-
resolvedActiveTriggerIdRef.current = implicitTriggerId;
|
|
1413
|
+
if (typeof outsidePress$1 === "function" && !outsidePress$1(event)) {
|
|
1414
|
+
return;
|
|
1410
1415
|
}
|
|
1416
|
+
if (hasBlockingChild("__outsidePressBubbles")) {
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
store.setOpen(false, createChangeEventDetails(outsidePress, event));
|
|
1420
|
+
clearInsideReactTree();
|
|
1411
1421
|
}
|
|
1412
|
-
|
|
1413
|
-
store.
|
|
1414
|
-
|
|
1415
|
-
if (lostActiveTriggerId) {
|
|
1416
|
-
if (closeOnActiveTriggerUnmount) {
|
|
1417
|
-
queueMicrotask(() => {
|
|
1418
|
-
if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
|
|
1419
|
-
const eventDetails = createChangeEventDetails(none);
|
|
1420
|
-
store.setOpen(false, eventDetails);
|
|
1421
|
-
if (!eventDetails.isCanceled) {
|
|
1422
|
-
store.update({
|
|
1423
|
-
activeTriggerId: null,
|
|
1424
|
-
activeTriggerElement: null
|
|
1425
|
-
});
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1422
|
+
function handlePointerDown(event) {
|
|
1423
|
+
if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
|
|
1424
|
+
return;
|
|
1429
1425
|
}
|
|
1426
|
+
closeOnPressOutside(event);
|
|
1430
1427
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
});
|
|
1452
|
-
onUnmount == null ? void 0 : onUnmount();
|
|
1453
|
-
(_b = (_a2 = store.context).onOpenChangeComplete) == null ? void 0 : _b.call(_a2, false);
|
|
1428
|
+
function handleTouchStart(event) {
|
|
1429
|
+
if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
const touch = event.touches[0];
|
|
1433
|
+
if (touch) {
|
|
1434
|
+
touchStateRef.current = {
|
|
1435
|
+
startTime: Date.now(),
|
|
1436
|
+
startX: touch.clientX,
|
|
1437
|
+
startY: touch.clientY,
|
|
1438
|
+
dismissOnTouchEnd: false,
|
|
1439
|
+
dismissOnMouseDown: true
|
|
1440
|
+
};
|
|
1441
|
+
cancelDismissOnEndTimeout.start(1e3, () => {
|
|
1442
|
+
if (touchStateRef.current) {
|
|
1443
|
+
touchStateRef.current.dismissOnTouchEnd = false;
|
|
1444
|
+
touchStateRef.current.dismissOnMouseDown = false;
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1454
1448
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
return {
|
|
1465
|
-
forceUnmount,
|
|
1466
|
-
transitionStatus
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
function usePopupInteractionProps(store, statePart) {
|
|
1470
|
-
store.useSyncedValues(statePart);
|
|
1471
|
-
useIsoLayoutEffect(() => () => {
|
|
1472
|
-
store.update({
|
|
1473
|
-
activeTriggerProps: EMPTY_OBJECT,
|
|
1474
|
-
inactiveTriggerProps: EMPTY_OBJECT,
|
|
1475
|
-
popupProps: EMPTY_OBJECT
|
|
1476
|
-
});
|
|
1477
|
-
}, [store]);
|
|
1478
|
-
}
|
|
1479
|
-
function usePopupRootSync(store, open2) {
|
|
1480
|
-
useIsoLayoutEffect(() => {
|
|
1481
|
-
if (!open2 && store.state.openMethod !== null) {
|
|
1482
|
-
store.set("openMethod", null);
|
|
1449
|
+
function addTargetEventListenerOnce(event, listener) {
|
|
1450
|
+
const target = getTarget(event);
|
|
1451
|
+
if (!target) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
const unsubscribe2 = addEventListener(target, event.type, () => {
|
|
1455
|
+
listener(event);
|
|
1456
|
+
unsubscribe2();
|
|
1457
|
+
});
|
|
1483
1458
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
store.set("openMethod", null);
|
|
1459
|
+
function handleTouchStartCapture(event) {
|
|
1460
|
+
currentPointerTypeRef.current = "touch";
|
|
1461
|
+
addTargetEventListenerOnce(event, handleTouchStart);
|
|
1488
1462
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
elementIds = /* @__PURE__ */ new WeakMap();
|
|
1497
|
-
devElementIdsByMap.set(map, elementIds);
|
|
1498
|
-
}
|
|
1499
|
-
return elementIds;
|
|
1500
|
-
}
|
|
1501
|
-
class PopupTriggerMap {
|
|
1502
|
-
constructor() {
|
|
1503
|
-
__publicField(this, "idMap", /* @__PURE__ */ new Map());
|
|
1504
|
-
}
|
|
1505
|
-
/**
|
|
1506
|
-
* Adds a trigger element with the given ID.
|
|
1507
|
-
*
|
|
1508
|
-
* Note: The provided element is assumed to not be registered under multiple IDs.
|
|
1509
|
-
*/
|
|
1510
|
-
add(id, element) {
|
|
1511
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1512
|
-
const elementIds = getDevElementIds(this);
|
|
1513
|
-
const existingId = elementIds.get(element);
|
|
1514
|
-
if (existingId !== void 0 && existingId !== id) {
|
|
1515
|
-
throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
|
|
1463
|
+
function closeOnPressOutsideCapture(event) {
|
|
1464
|
+
cancelDismissOnEndTimeout.clear();
|
|
1465
|
+
if (event.type === "pointerdown") {
|
|
1466
|
+
if (event.button === 0) {
|
|
1467
|
+
sawPressWhileOpenRef.current = true;
|
|
1468
|
+
}
|
|
1469
|
+
currentPointerTypeRef.current = event.pointerType;
|
|
1516
1470
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
elementIds.delete(previousElement);
|
|
1471
|
+
if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
|
|
1472
|
+
return;
|
|
1520
1473
|
}
|
|
1521
|
-
|
|
1474
|
+
addTargetEventListenerOnce(event, (targetEvent) => {
|
|
1475
|
+
if (targetEvent.type === "pointerdown") {
|
|
1476
|
+
handlePointerDown(targetEvent);
|
|
1477
|
+
} else {
|
|
1478
|
+
closeOnPressOutside(targetEvent);
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1522
1481
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (
|
|
1533
|
-
|
|
1482
|
+
function handlePressEndCapture(event) {
|
|
1483
|
+
if (event.type === "pointercancel") {
|
|
1484
|
+
sawPressWhileOpenRef.current = false;
|
|
1485
|
+
}
|
|
1486
|
+
if (!pressStartedInsideRef.current) {
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
|
|
1490
|
+
resetPressStartState();
|
|
1491
|
+
if (getOutsidePressEvent() !== "intentional") {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
if (event.type === "pointercancel") {
|
|
1495
|
+
if (pressStartedInsideDefaultPrevented) {
|
|
1496
|
+
suppressImmediateOutsideClickAfterPreventedStart();
|
|
1497
|
+
}
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
if (isEventWithinFloatingTree(event)) {
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
if (pressStartedInsideDefaultPrevented) {
|
|
1504
|
+
suppressImmediateOutsideClickAfterPreventedStart();
|
|
1505
|
+
return;
|
|
1534
1506
|
}
|
|
1507
|
+
if (typeof outsidePress$1 === "function" && !outsidePress$1(event)) {
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
preventedPressSuppressionTimeout.clear();
|
|
1511
|
+
suppressNextOutsideClickRef.current = true;
|
|
1512
|
+
clearInsideReactTree();
|
|
1535
1513
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1514
|
+
function handleTouchMove(event) {
|
|
1515
|
+
if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
const touch = event.touches[0];
|
|
1519
|
+
if (!touch) {
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
|
|
1523
|
+
const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
|
|
1524
|
+
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1525
|
+
if (distance > 5) {
|
|
1526
|
+
touchStateRef.current.dismissOnTouchEnd = true;
|
|
1527
|
+
}
|
|
1528
|
+
if (distance > 10) {
|
|
1529
|
+
closeOnPressOutside(event);
|
|
1530
|
+
cancelDismissOnEndTimeout.clear();
|
|
1531
|
+
touchStateRef.current = null;
|
|
1545
1532
|
}
|
|
1546
1533
|
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
if (
|
|
1555
|
-
|
|
1534
|
+
function handleTouchMoveCapture(event) {
|
|
1535
|
+
addTargetEventListenerOnce(event, handleTouchMove);
|
|
1536
|
+
}
|
|
1537
|
+
function handleTouchEnd(event) {
|
|
1538
|
+
if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
if (touchStateRef.current.dismissOnTouchEnd) {
|
|
1542
|
+
closeOnPressOutside(event);
|
|
1556
1543
|
}
|
|
1544
|
+
cancelDismissOnEndTimeout.clear();
|
|
1545
|
+
touchStateRef.current = null;
|
|
1557
1546
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
/**
|
|
1561
|
-
* Returns the trigger element associated with the given ID, or undefined if no such element exists.
|
|
1562
|
-
*/
|
|
1563
|
-
getById(id) {
|
|
1564
|
-
return this.idMap.get(id);
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
|
|
1568
|
-
*/
|
|
1569
|
-
entries() {
|
|
1570
|
-
return this.idMap.entries();
|
|
1571
|
-
}
|
|
1572
|
-
/**
|
|
1573
|
-
* Returns an iterable of all registered trigger elements.
|
|
1574
|
-
*/
|
|
1575
|
-
elements() {
|
|
1576
|
-
return this.idMap.values();
|
|
1577
|
-
}
|
|
1578
|
-
/**
|
|
1579
|
-
* Returns the number of registered trigger elements.
|
|
1580
|
-
*/
|
|
1581
|
-
get size() {
|
|
1582
|
-
return this.idMap.size;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
var withSelector = { exports: {} };
|
|
1586
|
-
var withSelector_production = {};
|
|
1587
|
-
/**
|
|
1588
|
-
* @license React
|
|
1589
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
1590
|
-
*
|
|
1591
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1592
|
-
*
|
|
1593
|
-
* This source code is licensed under the MIT license found in the
|
|
1594
|
-
* LICENSE file in the root directory of this source tree.
|
|
1595
|
-
*/
|
|
1596
|
-
var hasRequiredWithSelector_production;
|
|
1597
|
-
function requireWithSelector_production() {
|
|
1598
|
-
if (hasRequiredWithSelector_production) return withSelector_production;
|
|
1599
|
-
hasRequiredWithSelector_production = 1;
|
|
1600
|
-
var React2 = React__default, shim = shimExports;
|
|
1601
|
-
function is(x, y) {
|
|
1602
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
1603
|
-
}
|
|
1604
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef = React2.useRef, useEffect = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
1605
|
-
withSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
1606
|
-
var instRef = useRef(null);
|
|
1607
|
-
if (null === instRef.current) {
|
|
1608
|
-
var inst = { hasValue: false, value: null };
|
|
1609
|
-
instRef.current = inst;
|
|
1610
|
-
} else inst = instRef.current;
|
|
1611
|
-
instRef = useMemo(
|
|
1612
|
-
function() {
|
|
1613
|
-
function memoizedSelector(nextSnapshot) {
|
|
1614
|
-
if (!hasMemo) {
|
|
1615
|
-
hasMemo = true;
|
|
1616
|
-
memoizedSnapshot = nextSnapshot;
|
|
1617
|
-
nextSnapshot = selector(nextSnapshot);
|
|
1618
|
-
if (void 0 !== isEqual && inst.hasValue) {
|
|
1619
|
-
var currentSelection = inst.value;
|
|
1620
|
-
if (isEqual(currentSelection, nextSnapshot))
|
|
1621
|
-
return memoizedSelection = currentSelection;
|
|
1622
|
-
}
|
|
1623
|
-
return memoizedSelection = nextSnapshot;
|
|
1624
|
-
}
|
|
1625
|
-
currentSelection = memoizedSelection;
|
|
1626
|
-
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
1627
|
-
var nextSelection = selector(nextSnapshot);
|
|
1628
|
-
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
1629
|
-
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
1630
|
-
memoizedSnapshot = nextSnapshot;
|
|
1631
|
-
return memoizedSelection = nextSelection;
|
|
1632
|
-
}
|
|
1633
|
-
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
1634
|
-
return [
|
|
1635
|
-
function() {
|
|
1636
|
-
return memoizedSelector(getSnapshot());
|
|
1637
|
-
},
|
|
1638
|
-
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
1639
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
1640
|
-
}
|
|
1641
|
-
];
|
|
1642
|
-
},
|
|
1643
|
-
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
1644
|
-
);
|
|
1645
|
-
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
1646
|
-
useEffect(
|
|
1647
|
-
function() {
|
|
1648
|
-
inst.hasValue = true;
|
|
1649
|
-
inst.value = value;
|
|
1650
|
-
},
|
|
1651
|
-
[value]
|
|
1652
|
-
);
|
|
1653
|
-
useDebugValue(value);
|
|
1654
|
-
return value;
|
|
1655
|
-
};
|
|
1656
|
-
return withSelector_production;
|
|
1657
|
-
}
|
|
1658
|
-
var withSelector_development = {};
|
|
1659
|
-
/**
|
|
1660
|
-
* @license React
|
|
1661
|
-
* use-sync-external-store-shim/with-selector.development.js
|
|
1662
|
-
*
|
|
1663
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1664
|
-
*
|
|
1665
|
-
* This source code is licensed under the MIT license found in the
|
|
1666
|
-
* LICENSE file in the root directory of this source tree.
|
|
1667
|
-
*/
|
|
1668
|
-
var hasRequiredWithSelector_development;
|
|
1669
|
-
function requireWithSelector_development() {
|
|
1670
|
-
if (hasRequiredWithSelector_development) return withSelector_development;
|
|
1671
|
-
hasRequiredWithSelector_development = 1;
|
|
1672
|
-
"production" !== process.env.NODE_ENV && function() {
|
|
1673
|
-
function is(x, y) {
|
|
1674
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
1547
|
+
function handleTouchEndCapture(event) {
|
|
1548
|
+
addTargetEventListenerOnce(event, handleTouchEnd);
|
|
1675
1549
|
}
|
|
1676
|
-
"
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
if (void 0 !== isEqual && inst.hasValue) {
|
|
1692
|
-
var currentSelection = inst.value;
|
|
1693
|
-
if (isEqual(currentSelection, nextSnapshot))
|
|
1694
|
-
return memoizedSelection = currentSelection;
|
|
1695
|
-
}
|
|
1696
|
-
return memoizedSelection = nextSnapshot;
|
|
1697
|
-
}
|
|
1698
|
-
currentSelection = memoizedSelection;
|
|
1699
|
-
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
1700
|
-
return currentSelection;
|
|
1701
|
-
var nextSelection = selector(nextSnapshot);
|
|
1702
|
-
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
1703
|
-
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
1704
|
-
memoizedSnapshot = nextSnapshot;
|
|
1705
|
-
return memoizedSelection = nextSelection;
|
|
1706
|
-
}
|
|
1707
|
-
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
1708
|
-
return [
|
|
1709
|
-
function() {
|
|
1710
|
-
return memoizedSelector(getSnapshot());
|
|
1711
|
-
},
|
|
1712
|
-
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
1713
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
1714
|
-
}
|
|
1715
|
-
];
|
|
1716
|
-
},
|
|
1717
|
-
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
1718
|
-
);
|
|
1719
|
-
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
1720
|
-
useEffect(
|
|
1721
|
-
function() {
|
|
1722
|
-
inst.hasValue = true;
|
|
1723
|
-
inst.value = value;
|
|
1724
|
-
},
|
|
1725
|
-
[value]
|
|
1726
|
-
);
|
|
1727
|
-
useDebugValue(value);
|
|
1728
|
-
return value;
|
|
1550
|
+
const unsubscribe = mergeCleanups(escapeKey$1 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, {
|
|
1551
|
+
capture: true,
|
|
1552
|
+
passive: true
|
|
1553
|
+
}), addEventListener(doc, "touchmove", handleTouchMoveCapture, {
|
|
1554
|
+
capture: true,
|
|
1555
|
+
passive: true
|
|
1556
|
+
}), addEventListener(doc, "touchend", handleTouchEndCapture, {
|
|
1557
|
+
capture: true,
|
|
1558
|
+
passive: true
|
|
1559
|
+
})));
|
|
1560
|
+
return () => {
|
|
1561
|
+
unsubscribe();
|
|
1562
|
+
preventedPressSuppressionTimeout.clear();
|
|
1563
|
+
resetPressStartState();
|
|
1564
|
+
suppressNextOutsideClickRef.current = false;
|
|
1729
1565
|
};
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1566
|
+
}, [dataRef, floatingElement, escapeKey$1, outsidePressEnabled, outsidePress$1, open2, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout, compositionTimeout]);
|
|
1567
|
+
const reference = React.useMemo(() => ({
|
|
1568
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
1569
|
+
onPointerDown: closeOnReferencePress,
|
|
1570
|
+
onClick: closeOnReferencePress
|
|
1571
|
+
}), [closeOnEscapeKeyDown, closeOnReferencePress]);
|
|
1572
|
+
const floating = React.useMemo(() => ({
|
|
1573
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
1574
|
+
// `onMouseDown` may be blocked if `event.preventDefault()` is called in
|
|
1575
|
+
// `onPointerDown`, such as with <NumberField.ScrubArea>.
|
|
1576
|
+
// See https://github.com/mui/base-ui/pull/3379
|
|
1577
|
+
onPointerDown: markInsidePressStartPrevented,
|
|
1578
|
+
onMouseDown: markInsidePressStartPrevented,
|
|
1579
|
+
onClickCapture: markInsideReactTree,
|
|
1580
|
+
onMouseDownCapture(event) {
|
|
1581
|
+
markInsideReactTree();
|
|
1582
|
+
markPressStartedInsideReactTree(event);
|
|
1583
|
+
},
|
|
1584
|
+
onPointerDownCapture(event) {
|
|
1585
|
+
markInsideReactTree();
|
|
1586
|
+
markPressStartedInsideReactTree(event);
|
|
1587
|
+
},
|
|
1588
|
+
onMouseUpCapture: markInsideReactTree,
|
|
1589
|
+
onTouchEndCapture: markInsideReactTree,
|
|
1590
|
+
onTouchMoveCapture: markInsideReactTree
|
|
1591
|
+
}), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
|
|
1592
|
+
return React.useMemo(() => enabled ? {
|
|
1593
|
+
reference,
|
|
1594
|
+
floating,
|
|
1595
|
+
trigger: reference
|
|
1596
|
+
} : {}, [enabled, reference, floating]);
|
|
1597
|
+
}
|
|
1598
|
+
function useSyncedFloatingRootContext(options) {
|
|
1599
|
+
const {
|
|
1600
|
+
popupStore,
|
|
1601
|
+
treatPopupAsFloatingElement = false,
|
|
1602
|
+
floatingRootContext: store,
|
|
1603
|
+
floatingId,
|
|
1604
|
+
nested,
|
|
1605
|
+
onOpenChange
|
|
1606
|
+
} = options;
|
|
1607
|
+
const open2 = popupStore.useState("open");
|
|
1608
|
+
const referenceElement = popupStore.useState("activeTriggerElement");
|
|
1609
|
+
const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
|
|
1610
|
+
const handleOpenChange = onOpenChange;
|
|
1611
|
+
popupStore.useSyncedValue("floatingId", floatingId);
|
|
1612
|
+
useIsoLayoutEffect(() => {
|
|
1613
|
+
const valuesToSync = {
|
|
1614
|
+
open: open2,
|
|
1615
|
+
floatingId,
|
|
1616
|
+
referenceElement,
|
|
1617
|
+
floatingElement
|
|
1618
|
+
};
|
|
1619
|
+
if (isElement(referenceElement)) {
|
|
1620
|
+
valuesToSync.domReferenceElement = referenceElement;
|
|
1621
|
+
}
|
|
1622
|
+
if (store.state.positionReference === store.state.referenceElement) {
|
|
1623
|
+
valuesToSync.positionReference = referenceElement;
|
|
1624
|
+
}
|
|
1625
|
+
store.update(valuesToSync);
|
|
1626
|
+
}, [open2, floatingId, referenceElement, floatingElement, store]);
|
|
1627
|
+
store.context.onOpenChange = handleOpenChange;
|
|
1628
|
+
store.context.nested = nested;
|
|
1629
|
+
return store;
|
|
1630
|
+
}
|
|
1631
|
+
function useUnmountAfterClose(parameters) {
|
|
1632
|
+
const {
|
|
1633
|
+
open: open2,
|
|
1634
|
+
ref,
|
|
1635
|
+
preventUnmountOnClose,
|
|
1636
|
+
setPreventUnmountOnClose: setPreventUnmountOnCloseParam,
|
|
1637
|
+
onUnmount,
|
|
1638
|
+
animateInitialOpen
|
|
1639
|
+
} = parameters;
|
|
1640
|
+
const setPreventUnmountOnClose = useStableCallback(setPreventUnmountOnCloseParam);
|
|
1641
|
+
const {
|
|
1642
|
+
mounted,
|
|
1643
|
+
setMounted,
|
|
1644
|
+
transitionStatus
|
|
1645
|
+
} = useTransitionStatus(open2, false, false, animateInitialOpen);
|
|
1646
|
+
const preventUnmountingOnClose = open2 ? false : preventUnmountOnClose;
|
|
1647
|
+
useIsoLayoutEffect(() => {
|
|
1648
|
+
if (open2) {
|
|
1649
|
+
setPreventUnmountOnClose(false);
|
|
1650
|
+
}
|
|
1651
|
+
}, [open2, setPreventUnmountOnClose]);
|
|
1652
|
+
const mountedRef = React.useRef(mounted);
|
|
1653
|
+
const pendingUnmountRef = React.useRef(false);
|
|
1654
|
+
const rerender = useForcedRerendering();
|
|
1655
|
+
const unmount = () => {
|
|
1656
|
+
mountedRef.current = false;
|
|
1657
|
+
setMounted(false);
|
|
1658
|
+
onUnmount();
|
|
1659
|
+
};
|
|
1660
|
+
useIsoLayoutEffect(() => {
|
|
1661
|
+
mountedRef.current = mounted;
|
|
1662
|
+
if (pendingUnmountRef.current) {
|
|
1663
|
+
pendingUnmountRef.current = false;
|
|
1664
|
+
if (!open2 && mounted) {
|
|
1665
|
+
unmount();
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
});
|
|
1669
|
+
const forceUnmount = useStableCallback(() => {
|
|
1670
|
+
if (!mountedRef.current) {
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
if (open2) {
|
|
1674
|
+
pendingUnmountRef.current = true;
|
|
1675
|
+
rerender();
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
unmount();
|
|
1679
|
+
});
|
|
1680
|
+
useOpenChangeComplete({
|
|
1681
|
+
enabled: mounted && !open2 && !preventUnmountingOnClose,
|
|
1682
|
+
open: open2,
|
|
1683
|
+
ref,
|
|
1684
|
+
onComplete() {
|
|
1685
|
+
if (!open2) {
|
|
1686
|
+
forceUnmount();
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
return {
|
|
1691
|
+
mounted,
|
|
1692
|
+
transitionStatus,
|
|
1693
|
+
preventUnmountingOnClose,
|
|
1694
|
+
forceUnmount
|
|
1695
|
+
};
|
|
1733
1696
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1697
|
+
const FOCUSABLE_POPUP_PROPS = {
|
|
1698
|
+
tabIndex: -1,
|
|
1699
|
+
[FOCUSABLE_ATTRIBUTE]: ""
|
|
1700
|
+
};
|
|
1701
|
+
function createDefaultInitialFocus(popupRef) {
|
|
1702
|
+
return (interactionType) => interactionType === "touch" ? popupRef.current : true;
|
|
1738
1703
|
}
|
|
1739
|
-
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1704
|
+
function usePopupRootStore(createStore, treatPopupAsFloatingElement = false) {
|
|
1705
|
+
const floatingId = useId();
|
|
1706
|
+
const nested = useFloatingParentNodeId() != null;
|
|
1707
|
+
const store = useRefWithInit(() => createStore(floatingId, nested)).current;
|
|
1708
|
+
useSyncedFloatingRootContext({
|
|
1709
|
+
popupStore: store,
|
|
1710
|
+
treatPopupAsFloatingElement,
|
|
1711
|
+
floatingRootContext: store.state.floatingRootContext,
|
|
1712
|
+
floatingId,
|
|
1713
|
+
nested,
|
|
1714
|
+
onOpenChange: store.setOpen
|
|
1715
|
+
});
|
|
1716
|
+
return store;
|
|
1744
1717
|
}
|
|
1745
|
-
function
|
|
1746
|
-
|
|
1718
|
+
function PopupHandleAttachment({
|
|
1719
|
+
handle,
|
|
1720
|
+
store
|
|
1721
|
+
}) {
|
|
1722
|
+
useIsoLayoutEffect(() => {
|
|
1723
|
+
return handle.attachStore(store);
|
|
1724
|
+
}, [handle, store]);
|
|
1725
|
+
return null;
|
|
1747
1726
|
}
|
|
1748
|
-
function
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1727
|
+
function syncTriggerCount(store) {
|
|
1728
|
+
const triggerCount = store.context.triggerElements.size;
|
|
1729
|
+
if (store.select("open") && store.state.triggerCount !== triggerCount) {
|
|
1730
|
+
store.set("triggerCount", triggerCount);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
function useTriggerRegistration(id, store) {
|
|
1734
|
+
const registrationRef = React.useRef(null);
|
|
1735
|
+
return useStableCallback((element) => {
|
|
1736
|
+
const registration = registrationRef.current;
|
|
1737
|
+
if (registration !== null) {
|
|
1738
|
+
if (registration.element === element && registration.store === store && registration.id === id) {
|
|
1739
|
+
return;
|
|
1756
1740
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1741
|
+
registrationRef.current = null;
|
|
1742
|
+
const registeredStore = registration.store;
|
|
1743
|
+
if (registeredStore.context.triggerElements.getById(registration.id) === registration.element) {
|
|
1744
|
+
registeredStore.context.triggerElements.delete(registration.id);
|
|
1745
|
+
syncTriggerCount(registeredStore);
|
|
1760
1746
|
}
|
|
1761
|
-
instance.didInitialize = true;
|
|
1762
|
-
} finally {
|
|
1763
|
-
currentInstance = void 0;
|
|
1764
1747
|
}
|
|
1765
|
-
|
|
1748
|
+
if (element !== null && id !== void 0) {
|
|
1749
|
+
registrationRef.current = {
|
|
1750
|
+
store,
|
|
1751
|
+
id,
|
|
1752
|
+
element
|
|
1753
|
+
};
|
|
1754
|
+
store.context.triggerElements.add(id, element);
|
|
1755
|
+
syncTriggerCount(store);
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
function createPopupOpenState(state, open2, trigger, preventUnmountOnClose = false) {
|
|
1760
|
+
let preventUnmountingOnClose = state.preventUnmountingOnClose;
|
|
1761
|
+
if (open2) {
|
|
1762
|
+
preventUnmountingOnClose = false;
|
|
1763
|
+
} else if (preventUnmountOnClose) {
|
|
1764
|
+
preventUnmountingOnClose = true;
|
|
1765
|
+
}
|
|
1766
|
+
const triggerId = (trigger == null ? void 0 : trigger.id) ?? null;
|
|
1767
|
+
let activeTriggerId = state.activeTriggerId;
|
|
1768
|
+
let activeTriggerElement = state.activeTriggerElement;
|
|
1769
|
+
if (triggerId || open2) {
|
|
1770
|
+
activeTriggerId = triggerId;
|
|
1771
|
+
activeTriggerElement = trigger ?? null;
|
|
1772
|
+
}
|
|
1773
|
+
return {
|
|
1774
|
+
open: open2,
|
|
1775
|
+
preventUnmountingOnClose,
|
|
1776
|
+
activeTriggerId,
|
|
1777
|
+
activeTriggerElement,
|
|
1778
|
+
// An open request without a trigger (a handle's `open(null)` or `openWithPayload()`) must not
|
|
1779
|
+
// be reassociated with a lone registered trigger later on. Controlled and default opens never
|
|
1780
|
+
// pass through here, so they keep claiming a lone trigger. A close request keeps the flag: a
|
|
1781
|
+
// controlled root may decline it and stay open, so the Root clears the flag only once the
|
|
1782
|
+
// popup is effectively closed.
|
|
1783
|
+
openedWithoutTrigger: open2 ? trigger == null : state.openedWithoutTrigger
|
|
1766
1784
|
};
|
|
1767
|
-
FastComponent.displayName = fn.displayName || fn.name;
|
|
1768
|
-
return FastComponent;
|
|
1769
1785
|
}
|
|
1770
|
-
function
|
|
1771
|
-
|
|
1786
|
+
function attachPreventUnmountOnClose(eventDetails) {
|
|
1787
|
+
let preventUnmountOnClose = false;
|
|
1788
|
+
eventDetails.preventUnmountOnClose = () => {
|
|
1789
|
+
preventUnmountOnClose = true;
|
|
1790
|
+
};
|
|
1791
|
+
return () => preventUnmountOnClose;
|
|
1772
1792
|
}
|
|
1773
|
-
function
|
|
1793
|
+
function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
|
|
1794
|
+
var _a2, _b, _c;
|
|
1795
|
+
const reason = eventDetails.reason;
|
|
1796
|
+
const isHover = reason === triggerHover;
|
|
1797
|
+
const isFocusOpen = nextOpen && reason === triggerFocus;
|
|
1798
|
+
const isDismissClose = !nextOpen && (reason === triggerPress || reason === escapeKey);
|
|
1799
|
+
const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
|
|
1800
|
+
(_b = (_a2 = store.context).onOpenChange) == null ? void 0 : _b.call(_a2, nextOpen, eventDetails);
|
|
1801
|
+
if (eventDetails.isCanceled) {
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
(_c = options.onBeforeDispatch) == null ? void 0 : _c.call(options);
|
|
1805
|
+
store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
|
|
1806
|
+
const changeState = () => {
|
|
1807
|
+
const popupOpenState = createPopupOpenState(store.state, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
|
|
1808
|
+
const updatedState = {
|
|
1809
|
+
...options.extraState,
|
|
1810
|
+
...popupOpenState
|
|
1811
|
+
};
|
|
1812
|
+
if (isFocusOpen) {
|
|
1813
|
+
updatedState.instantType = "focus";
|
|
1814
|
+
} else if (isDismissClose) {
|
|
1815
|
+
updatedState.instantType = "dismiss";
|
|
1816
|
+
} else if (isHover) {
|
|
1817
|
+
updatedState.instantType = void 0;
|
|
1818
|
+
}
|
|
1819
|
+
store.update(updatedState);
|
|
1820
|
+
};
|
|
1821
|
+
if (isHover) {
|
|
1822
|
+
ReactDOM.flushSync(changeState);
|
|
1823
|
+
} else {
|
|
1824
|
+
changeState();
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
|
|
1828
|
+
const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
|
|
1829
|
+
const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
|
|
1830
|
+
const applyTriggerData = useStableCallback((element) => {
|
|
1831
|
+
const open2 = store.select("open");
|
|
1832
|
+
const activeTriggerId = store.select("activeTriggerId");
|
|
1833
|
+
if (activeTriggerId === triggerId) {
|
|
1834
|
+
const changes = {
|
|
1835
|
+
activeTriggerElement: element,
|
|
1836
|
+
...open2 ? stateUpdates : null
|
|
1837
|
+
};
|
|
1838
|
+
store.update(changes);
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
if (activeTriggerId == null && open2 && !store.state.openedWithoutTrigger) {
|
|
1842
|
+
const changes = {
|
|
1843
|
+
activeTriggerId: triggerId ?? null,
|
|
1844
|
+
activeTriggerElement: element,
|
|
1845
|
+
...stateUpdates
|
|
1846
|
+
};
|
|
1847
|
+
store.update(changes);
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
const registerTrigger = useStableCallback((element) => {
|
|
1851
|
+
baseRegisterTrigger(element);
|
|
1852
|
+
if (element) {
|
|
1853
|
+
applyTriggerData(element);
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
useIsoLayoutEffect(() => {
|
|
1857
|
+
registerTrigger(triggerElementRef.current);
|
|
1858
|
+
return () => registerTrigger(null);
|
|
1859
|
+
}, [registerTrigger, triggerElementRef, store, triggerId]);
|
|
1860
|
+
useIsoLayoutEffect(() => {
|
|
1861
|
+
if (isMountedByThisTrigger) {
|
|
1862
|
+
const changes = {
|
|
1863
|
+
activeTriggerElement: triggerElementRef.current,
|
|
1864
|
+
...stateUpdates
|
|
1865
|
+
};
|
|
1866
|
+
store.update(changes);
|
|
1867
|
+
}
|
|
1868
|
+
}, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
|
|
1774
1869
|
return {
|
|
1775
|
-
|
|
1870
|
+
registerTrigger,
|
|
1871
|
+
isMountedByThisTrigger
|
|
1776
1872
|
};
|
|
1777
1873
|
}
|
|
1778
|
-
|
|
1779
|
-
const
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
const
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
const hook = instance.syncHooks[i];
|
|
1798
|
-
const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
|
|
1799
|
-
if (!Object.is(hook.value, value)) {
|
|
1800
|
-
didChange = true;
|
|
1801
|
-
hook.value = value;
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
if (didChange) {
|
|
1805
|
-
instance.syncTick += 1;
|
|
1806
|
-
}
|
|
1807
|
-
return instance.syncTick;
|
|
1808
|
-
};
|
|
1874
|
+
function useImplicitActiveTrigger(store, options = {}) {
|
|
1875
|
+
const {
|
|
1876
|
+
closeOnActiveTriggerUnmount = false
|
|
1877
|
+
} = options;
|
|
1878
|
+
const resolvedActiveTriggerIdRef = React.useRef(null);
|
|
1879
|
+
const open2 = store.useState("open");
|
|
1880
|
+
const reactiveTriggerCount = store.useState("triggerCount");
|
|
1881
|
+
const activeTriggerId = store.useState("activeTriggerId");
|
|
1882
|
+
const reactiveActiveTriggerElement = store.useState("activeTriggerElement");
|
|
1883
|
+
useIsoLayoutEffect(() => {
|
|
1884
|
+
if (!open2) {
|
|
1885
|
+
resolvedActiveTriggerIdRef.current = null;
|
|
1886
|
+
if (store.state.triggerCount !== 0) {
|
|
1887
|
+
store.set("triggerCount", 0);
|
|
1888
|
+
}
|
|
1889
|
+
if (store.state.openedWithoutTrigger) {
|
|
1890
|
+
store.set("openedWithoutTrigger", false);
|
|
1891
|
+
}
|
|
1892
|
+
return;
|
|
1809
1893
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
if (
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1894
|
+
const triggerCount = store.context.triggerElements.size;
|
|
1895
|
+
const stateUpdates = {};
|
|
1896
|
+
if (store.state.triggerCount !== triggerCount) {
|
|
1897
|
+
stateUpdates.triggerCount = triggerCount;
|
|
1898
|
+
}
|
|
1899
|
+
const currentActiveTriggerId = store.select("activeTriggerId");
|
|
1900
|
+
let lostActiveTriggerId = null;
|
|
1901
|
+
if (currentActiveTriggerId) {
|
|
1902
|
+
const activeTriggerElement = store.context.triggerElements.getById(currentActiveTriggerId);
|
|
1903
|
+
if (!activeTriggerElement) {
|
|
1904
|
+
for (const [triggerId, triggerElement] of store.context.triggerElements.entries()) {
|
|
1905
|
+
if (triggerElement === store.state.activeTriggerElement) {
|
|
1906
|
+
stateUpdates.activeTriggerId = triggerId;
|
|
1907
|
+
stateUpdates.activeTriggerElement = triggerElement;
|
|
1908
|
+
resolvedActiveTriggerIdRef.current = triggerId;
|
|
1909
|
+
break;
|
|
1819
1910
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1911
|
+
}
|
|
1912
|
+
if (stateUpdates.activeTriggerId === void 0) {
|
|
1913
|
+
if (resolvedActiveTriggerIdRef.current === currentActiveTriggerId) {
|
|
1914
|
+
lostActiveTriggerId = currentActiveTriggerId;
|
|
1915
|
+
} else {
|
|
1916
|
+
resolvedActiveTriggerIdRef.current = null;
|
|
1823
1917
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
}
|
|
1918
|
+
}
|
|
1919
|
+
} else {
|
|
1920
|
+
resolvedActiveTriggerIdRef.current = currentActiveTriggerId;
|
|
1921
|
+
if (activeTriggerElement !== store.state.activeTriggerElement) {
|
|
1922
|
+
stateUpdates.activeTriggerElement = activeTriggerElement;
|
|
1923
|
+
}
|
|
1830
1924
|
}
|
|
1831
|
-
|
|
1925
|
+
} else {
|
|
1926
|
+
resolvedActiveTriggerIdRef.current = null;
|
|
1832
1927
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
const index = instance.syncIndex;
|
|
1841
|
-
instance.syncIndex += 1;
|
|
1842
|
-
let hook;
|
|
1843
|
-
if (!instance.didInitialize) {
|
|
1844
|
-
hook = {
|
|
1845
|
-
store,
|
|
1846
|
-
selector,
|
|
1847
|
-
a1,
|
|
1848
|
-
a2,
|
|
1849
|
-
a3,
|
|
1850
|
-
value: selector(store.getSnapshot(), a1, a2, a3)
|
|
1851
|
-
};
|
|
1852
|
-
instance.syncHooks.push(hook);
|
|
1853
|
-
} else {
|
|
1854
|
-
hook = instance.syncHooks[index];
|
|
1855
|
-
if (hook.store !== store || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
|
|
1856
|
-
if (hook.store !== store) {
|
|
1857
|
-
instance.didChangeStore = true;
|
|
1928
|
+
if (!lostActiveTriggerId && !currentActiveTriggerId && !store.state.openedWithoutTrigger && triggerCount === 1) {
|
|
1929
|
+
const iteratorResult = store.context.triggerElements.entries().next();
|
|
1930
|
+
if (!iteratorResult.done) {
|
|
1931
|
+
const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
|
|
1932
|
+
stateUpdates.activeTriggerId = implicitTriggerId;
|
|
1933
|
+
stateUpdates.activeTriggerElement = implicitTriggerElement;
|
|
1934
|
+
resolvedActiveTriggerIdRef.current = implicitTriggerId;
|
|
1858
1935
|
}
|
|
1859
|
-
hook.store = store;
|
|
1860
|
-
hook.selector = selector;
|
|
1861
|
-
hook.a1 = a1;
|
|
1862
|
-
hook.a2 = a2;
|
|
1863
|
-
hook.a3 = a3;
|
|
1864
|
-
hook.value = selector(store.getSnapshot(), a1, a2, a3);
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
return hook.value;
|
|
1868
|
-
}
|
|
1869
|
-
function useStoreLegacy(store, selector, a1, a2, a3) {
|
|
1870
|
-
return withSelectorExports.useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector(state, a1, a2, a3));
|
|
1871
|
-
}
|
|
1872
|
-
class Store {
|
|
1873
|
-
/**
|
|
1874
|
-
* The current state of the store.
|
|
1875
|
-
* This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
|
|
1876
|
-
* To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
|
|
1877
|
-
* The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
|
|
1878
|
-
*
|
|
1879
|
-
* Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
|
|
1880
|
-
*/
|
|
1881
|
-
// Internal state to handle recursive `setState()` calls
|
|
1882
|
-
constructor(state) {
|
|
1883
|
-
/**
|
|
1884
|
-
* Registers a listener that will be called whenever the store's state changes.
|
|
1885
|
-
*
|
|
1886
|
-
* @param fn The listener function to be called on state changes.
|
|
1887
|
-
* @returns A function to unsubscribe the listener.
|
|
1888
|
-
*/
|
|
1889
|
-
__publicField(this, "subscribe", (fn) => {
|
|
1890
|
-
this.listeners.add(fn);
|
|
1891
|
-
return () => {
|
|
1892
|
-
this.listeners.delete(fn);
|
|
1893
|
-
};
|
|
1894
|
-
});
|
|
1895
|
-
/**
|
|
1896
|
-
* Returns the current state of the store.
|
|
1897
|
-
*/
|
|
1898
|
-
__publicField(this, "getSnapshot", () => {
|
|
1899
|
-
return this.state;
|
|
1900
|
-
});
|
|
1901
|
-
this.state = state;
|
|
1902
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
1903
|
-
this.updateTick = 0;
|
|
1904
|
-
}
|
|
1905
|
-
/**
|
|
1906
|
-
* Creates a store with the given initial state, constructing the class it is called on.
|
|
1907
|
-
* Calling it on a generic base class (e.g. `ReactStore.create(...)`) constructs that
|
|
1908
|
-
* class but degrades the inferred instance type to `Store`; use `new` there instead.
|
|
1909
|
-
*/
|
|
1910
|
-
static create(state) {
|
|
1911
|
-
return new this(state);
|
|
1912
|
-
}
|
|
1913
|
-
/**
|
|
1914
|
-
* Updates the entire store's state and notifies all registered listeners.
|
|
1915
|
-
*
|
|
1916
|
-
* @param newState The new state to set for the store.
|
|
1917
|
-
*/
|
|
1918
|
-
setState(newState) {
|
|
1919
|
-
if (this.state === newState) {
|
|
1920
|
-
return;
|
|
1921
1936
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
const currentTick = this.updateTick;
|
|
1925
|
-
for (const listener of this.listeners) {
|
|
1926
|
-
if (currentTick !== this.updateTick) {
|
|
1927
|
-
return;
|
|
1928
|
-
}
|
|
1929
|
-
listener(newState);
|
|
1937
|
+
if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
|
|
1938
|
+
store.update(stateUpdates);
|
|
1930
1939
|
}
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
...changes
|
|
1940
|
+
if (lostActiveTriggerId) {
|
|
1941
|
+
if (closeOnActiveTriggerUnmount) {
|
|
1942
|
+
queueMicrotask(() => {
|
|
1943
|
+
if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
|
|
1944
|
+
const eventDetails = createChangeEventDetails(none);
|
|
1945
|
+
store.setOpen(false, eventDetails);
|
|
1946
|
+
if (!eventDetails.isCanceled) {
|
|
1947
|
+
store.update({
|
|
1948
|
+
activeTriggerId: null,
|
|
1949
|
+
activeTriggerElement: null
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1945
1953
|
});
|
|
1946
|
-
return;
|
|
1947
1954
|
}
|
|
1948
1955
|
}
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1956
|
+
}, [open2, store, reactiveTriggerCount, activeTriggerId, reactiveActiveTriggerElement, closeOnActiveTriggerUnmount]);
|
|
1957
|
+
}
|
|
1958
|
+
function useOpenStateTransitions(open2, store, onUnmount, animateInitialOpen) {
|
|
1959
|
+
const {
|
|
1960
|
+
mounted,
|
|
1961
|
+
transitionStatus,
|
|
1962
|
+
forceUnmount
|
|
1963
|
+
} = useUnmountAfterClose({
|
|
1964
|
+
open: open2,
|
|
1965
|
+
ref: store.context.popupRef,
|
|
1966
|
+
preventUnmountOnClose: store.useState("preventUnmountingOnClose"),
|
|
1967
|
+
setPreventUnmountOnClose: (preventUnmountOnClose) => store.set("preventUnmountingOnClose", preventUnmountOnClose),
|
|
1968
|
+
animateInitialOpen,
|
|
1969
|
+
onUnmount() {
|
|
1970
|
+
var _a2, _b;
|
|
1971
|
+
store.update({
|
|
1972
|
+
activeTriggerId: null,
|
|
1973
|
+
activeTriggerElement: null,
|
|
1974
|
+
mounted: false,
|
|
1975
|
+
preventUnmountingOnClose: false
|
|
1961
1976
|
});
|
|
1977
|
+
onUnmount == null ? void 0 : onUnmount();
|
|
1978
|
+
(_b = (_a2 = store.context).onOpenChangeComplete) == null ? void 0 : _b.call(_a2, false);
|
|
1962
1979
|
}
|
|
1980
|
+
});
|
|
1981
|
+
useRefWithInit(() => {
|
|
1982
|
+
store.set("mounted", mounted);
|
|
1983
|
+
return null;
|
|
1984
|
+
});
|
|
1985
|
+
store.useSyncedValues({
|
|
1986
|
+
mounted,
|
|
1987
|
+
transitionStatus
|
|
1988
|
+
});
|
|
1989
|
+
return {
|
|
1990
|
+
forceUnmount,
|
|
1991
|
+
transitionStatus
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
function usePopupInteractionProps(store, statePart) {
|
|
1995
|
+
store.useSyncedValues(statePart);
|
|
1996
|
+
useIsoLayoutEffect(() => () => {
|
|
1997
|
+
store.update({
|
|
1998
|
+
activeTriggerProps: EMPTY_OBJECT,
|
|
1999
|
+
inactiveTriggerProps: EMPTY_OBJECT,
|
|
2000
|
+
popupProps: EMPTY_OBJECT
|
|
2001
|
+
});
|
|
2002
|
+
}, [store]);
|
|
2003
|
+
}
|
|
2004
|
+
function usePopupRootSync(store, open2) {
|
|
2005
|
+
useIsoLayoutEffect(() => {
|
|
2006
|
+
if (!open2 && store.state.openMethod !== null) {
|
|
2007
|
+
store.set("openMethod", null);
|
|
2008
|
+
}
|
|
2009
|
+
}, [open2, store]);
|
|
2010
|
+
useIsoLayoutEffect(() => () => {
|
|
2011
|
+
if (store.state.openMethod !== null) {
|
|
2012
|
+
store.set("openMethod", null);
|
|
2013
|
+
}
|
|
2014
|
+
}, [store]);
|
|
2015
|
+
}
|
|
2016
|
+
let devElementIdsByMap;
|
|
2017
|
+
function getDevElementIds(map) {
|
|
2018
|
+
devElementIdsByMap ?? (devElementIdsByMap = /* @__PURE__ */ new WeakMap());
|
|
2019
|
+
let elementIds = devElementIdsByMap.get(map);
|
|
2020
|
+
if (!elementIds) {
|
|
2021
|
+
elementIds = /* @__PURE__ */ new WeakMap();
|
|
2022
|
+
devElementIdsByMap.set(map, elementIds);
|
|
1963
2023
|
}
|
|
1964
|
-
|
|
1965
|
-
* Gives the state a new reference and updates all registered listeners.
|
|
1966
|
-
*/
|
|
1967
|
-
notifyAll() {
|
|
1968
|
-
const newState = {
|
|
1969
|
-
...this.state
|
|
1970
|
-
};
|
|
1971
|
-
this.setState(newState);
|
|
1972
|
-
}
|
|
1973
|
-
use(selector, a1, a2, a3) {
|
|
1974
|
-
return useStore(this, selector, a1, a2, a3);
|
|
1975
|
-
}
|
|
2024
|
+
return elementIds;
|
|
1976
2025
|
}
|
|
1977
|
-
class
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
*
|
|
1981
|
-
* @param state Initial state of the store.
|
|
1982
|
-
* @param context Non-reactive context values.
|
|
1983
|
-
* @param selectors Optional selectors for use with `useState`.
|
|
1984
|
-
*/
|
|
1985
|
-
constructor(state, context = {}, selectors2) {
|
|
1986
|
-
super(state);
|
|
1987
|
-
this.context = context;
|
|
1988
|
-
this.selectors = selectors2;
|
|
2026
|
+
class PopupTriggerMap {
|
|
2027
|
+
constructor() {
|
|
2028
|
+
__publicField(this, "idMap", /* @__PURE__ */ new Map());
|
|
1989
2029
|
}
|
|
1990
2030
|
/**
|
|
1991
|
-
*
|
|
1992
|
-
*/
|
|
1993
|
-
/**
|
|
1994
|
-
* Synchronizes a single external value into the store.
|
|
2031
|
+
* Adds a trigger element with the given ID.
|
|
1995
2032
|
*
|
|
1996
|
-
* Note
|
|
1997
|
-
* by `useState` is updated before the next render (similarly to React's `useState`).
|
|
2033
|
+
* Note: The provided element is assumed to not be registered under multiple IDs.
|
|
1998
2034
|
*/
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
if (
|
|
2004
|
-
|
|
2035
|
+
add(id, element) {
|
|
2036
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2037
|
+
const elementIds = getDevElementIds(this);
|
|
2038
|
+
const existingId = elementIds.get(element);
|
|
2039
|
+
if (existingId !== void 0 && existingId !== id) {
|
|
2040
|
+
throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
|
|
2005
2041
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
* Synchronizes a single external value into the store and
|
|
2010
|
-
* cleans it up (sets to `undefined`) on unmount.
|
|
2011
|
-
*
|
|
2012
|
-
* Note that the while the value in `state` is updated immediately, the value returned
|
|
2013
|
-
* by `useState` is updated before the next render (similarly to React's `useState`).
|
|
2014
|
-
*/
|
|
2015
|
-
useSyncedValueWithCleanup(key, value) {
|
|
2016
|
-
const store = this;
|
|
2017
|
-
useIsoLayoutEffect(() => {
|
|
2018
|
-
if (store.state[key] !== value) {
|
|
2019
|
-
store.set(key, value);
|
|
2042
|
+
const previousElement = this.idMap.get(id);
|
|
2043
|
+
if (previousElement !== void 0 && previousElement !== element) {
|
|
2044
|
+
elementIds.delete(previousElement);
|
|
2020
2045
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
}, [store, key, value]);
|
|
2046
|
+
elementIds.set(element, id);
|
|
2047
|
+
}
|
|
2048
|
+
this.idMap.set(id, element);
|
|
2025
2049
|
}
|
|
2026
2050
|
/**
|
|
2027
|
-
*
|
|
2028
|
-
* Each value must match its state key. Pass an exact known subset rather than a broad
|
|
2029
|
-
* `Partial<State>`, which may contain `undefined` for required state fields.
|
|
2030
|
-
*
|
|
2031
|
-
* Note that the while the values in `state` are updated immediately, the values returned
|
|
2032
|
-
* by `useState` are updated before the next render (similarly to React's `useState`).
|
|
2033
|
-
*
|
|
2034
|
-
* @param statePart An exact subset of state fields to synchronize. Unknown keys are not accepted.
|
|
2051
|
+
* Removes the trigger element with the given ID.
|
|
2035
2052
|
*/
|
|
2036
|
-
|
|
2037
|
-
|
|
2053
|
+
delete(id) {
|
|
2054
|
+
var _a2;
|
|
2038
2055
|
if (process.env.NODE_ENV !== "production") {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
if (keys.length !== nextKeys.length || keys.some((key, index) => key !== nextKeys[index])) {
|
|
2043
|
-
console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
|
|
2056
|
+
const element = this.idMap.get(id);
|
|
2057
|
+
if (element !== void 0) {
|
|
2058
|
+
(_a2 = devElementIdsByMap == null ? void 0 : devElementIdsByMap.get(this)) == null ? void 0 : _a2.delete(element);
|
|
2044
2059
|
}
|
|
2045
2060
|
}
|
|
2046
|
-
|
|
2047
|
-
useIsoLayoutEffect(() => {
|
|
2048
|
-
store.update(statePart);
|
|
2049
|
-
}, [store, ...dependencies]);
|
|
2061
|
+
this.idMap.delete(id);
|
|
2050
2062
|
}
|
|
2051
2063
|
/**
|
|
2052
|
-
*
|
|
2053
|
-
* is non-undefined, the store's state at `key` is updated to match `controlled`.
|
|
2064
|
+
* Whether the given element is registered as a trigger.
|
|
2054
2065
|
*/
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
useIsoLayoutEffect(() => {
|
|
2060
|
-
if (isControlled && !Object.is(store.state[key], controlled)) {
|
|
2061
|
-
store.setState({
|
|
2062
|
-
...store.state,
|
|
2063
|
-
[key]: controlled
|
|
2064
|
-
});
|
|
2065
|
-
}
|
|
2066
|
-
}, [store, key, controlled, isControlled]);
|
|
2067
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2068
|
-
const cache = this.controlledValues ?? (this.controlledValues = /* @__PURE__ */ new Map());
|
|
2069
|
-
if (!cache.has(key)) {
|
|
2070
|
-
cache.set(key, isControlled);
|
|
2071
|
-
}
|
|
2072
|
-
const previouslyControlled = cache.get(key);
|
|
2073
|
-
if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
|
|
2074
|
-
console.error(`A component is changing the ${previouslyControlled ? "" : "un"}controlled state of ${key.toString()} to be ${previouslyControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
|
|
2066
|
+
hasElement(element) {
|
|
2067
|
+
for (const registered of this.idMap.values()) {
|
|
2068
|
+
if (registered === element) {
|
|
2069
|
+
return true;
|
|
2075
2070
|
}
|
|
2076
2071
|
}
|
|
2072
|
+
return false;
|
|
2077
2073
|
}
|
|
2078
|
-
/**
|
|
2079
|
-
*
|
|
2080
|
-
* @param key Key of the selector to use.
|
|
2074
|
+
/**
|
|
2075
|
+
* Whether there is a registered trigger element matching the given predicate.
|
|
2081
2076
|
*/
|
|
2082
|
-
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2077
|
+
hasMatchingElement(predicate) {
|
|
2078
|
+
for (const element of this.idMap.values()) {
|
|
2079
|
+
if (predicate(element)) {
|
|
2080
|
+
return true;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
return false;
|
|
2085
2084
|
}
|
|
2086
2085
|
/**
|
|
2087
|
-
* Returns
|
|
2088
|
-
* Used to subscribe to specific parts of the state.
|
|
2089
|
-
* This methods causes a rerender whenever the selected state changes.
|
|
2090
|
-
*
|
|
2091
|
-
* @param key Key of the selector to use.
|
|
2086
|
+
* Returns the trigger element associated with the given ID, or undefined if no such element exists.
|
|
2092
2087
|
*/
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
return useStore(this, this.selectors[key], a1, a2, a3);
|
|
2088
|
+
getById(id) {
|
|
2089
|
+
return this.idMap.get(id);
|
|
2096
2090
|
}
|
|
2097
2091
|
/**
|
|
2098
|
-
*
|
|
2099
|
-
* and assigns it to the context.
|
|
2100
|
-
*
|
|
2101
|
-
* @param key Key of the event callback. Must be a function in the context.
|
|
2102
|
-
* @param fn Function to assign.
|
|
2092
|
+
* Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
|
|
2103
2093
|
*/
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
const stableFunction = useStableCallback(fn ?? NOOP);
|
|
2107
|
-
this.context[key] = stableFunction;
|
|
2094
|
+
entries() {
|
|
2095
|
+
return this.idMap.entries();
|
|
2108
2096
|
}
|
|
2109
2097
|
/**
|
|
2110
|
-
* Returns
|
|
2111
|
-
* It's commonly used to pass as a ref callback to React elements.
|
|
2112
|
-
*
|
|
2113
|
-
* @param key Key of the state to set.
|
|
2098
|
+
* Returns an iterable of all registered trigger elements.
|
|
2114
2099
|
*/
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
if (ref.current === void 0) {
|
|
2118
|
-
ref.current = (value) => {
|
|
2119
|
-
this.set(key, value);
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
return ref.current;
|
|
2100
|
+
elements() {
|
|
2101
|
+
return this.idMap.values();
|
|
2123
2102
|
}
|
|
2124
2103
|
/**
|
|
2125
|
-
*
|
|
2126
|
-
*
|
|
2127
|
-
* @param key Key of the selector to observe.
|
|
2128
|
-
* @param listener Listener function called when the selector result changes.
|
|
2104
|
+
* Returns the number of registered trigger elements.
|
|
2129
2105
|
*/
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
if (typeof selector === "function") {
|
|
2133
|
-
selectFn = selector;
|
|
2134
|
-
} else {
|
|
2135
|
-
selectFn = this.selectors[selector];
|
|
2136
|
-
}
|
|
2137
|
-
let prevValue = selectFn(this.state);
|
|
2138
|
-
listener(prevValue, prevValue, this);
|
|
2139
|
-
return this.subscribe((nextState) => {
|
|
2140
|
-
const nextValue = selectFn(nextState);
|
|
2141
|
-
if (!Object.is(prevValue, nextValue)) {
|
|
2142
|
-
const oldValue = prevValue;
|
|
2143
|
-
prevValue = nextValue;
|
|
2144
|
-
listener(nextValue, oldValue, this);
|
|
2145
|
-
}
|
|
2146
|
-
});
|
|
2106
|
+
get size() {
|
|
2107
|
+
return this.idMap.size;
|
|
2147
2108
|
}
|
|
2148
2109
|
}
|
|
2149
2110
|
const selectors = {
|
|
@@ -2313,60 +2274,63 @@ function usePopupHandleStore(handle) {
|
|
|
2313
2274
|
return shimExports.useSyncExternalStore(subscribe, getSnapshot, () => handle == null ? void 0 : handle.serverStore);
|
|
2314
2275
|
}
|
|
2315
2276
|
export {
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2277
|
+
isTabbable as $,
|
|
2278
|
+
FloatingTree as A,
|
|
2279
|
+
fastComponentRef as B,
|
|
2280
|
+
usePopupHandleStore as C,
|
|
2281
|
+
DROPDOWN_COLLISION_AVOIDANCE as D,
|
|
2282
|
+
useTriggerDataForwarding as E,
|
|
2283
|
+
FOCUSABLE_POPUP_PROPS as F,
|
|
2284
|
+
FocusGuard as G,
|
|
2285
|
+
PATIENT_CLICK_THRESHOLD as H,
|
|
2286
|
+
useTriggerRegistration as I,
|
|
2287
|
+
voiceOver as J,
|
|
2288
|
+
createDefaultInitialFocus as K,
|
|
2289
|
+
usePopupRootStore as L,
|
|
2290
|
+
usePopupRootSync as M,
|
|
2291
|
+
CLICK_TRIGGER_IDENTIFIER as N,
|
|
2292
|
+
mergeCleanups as O,
|
|
2293
|
+
PopupTriggerMap as P,
|
|
2294
|
+
getNodeChildren as Q,
|
|
2334
2295
|
ReactStore as R,
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2296
|
+
DISABLED_TRANSITIONS_STYLE as S,
|
|
2297
|
+
TYPEAHEAD_RESET_MS as T,
|
|
2298
|
+
usePortalContext as U,
|
|
2299
|
+
tabbable as V,
|
|
2300
|
+
createAttribute as W,
|
|
2301
|
+
getNodeAncestors as X,
|
|
2302
|
+
isOutsideEvent as Y,
|
|
2303
|
+
getNextTabbable as Z,
|
|
2304
|
+
getPreviousTabbable as _,
|
|
2344
2305
|
attachPreventUnmountOnClose as a,
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
pressableTriggerOpenStateMapping as
|
|
2306
|
+
focusable as a0,
|
|
2307
|
+
getTabbableNearElement as a1,
|
|
2308
|
+
applyPopupOpenChange as a2,
|
|
2309
|
+
useFloatingPortalNode as a3,
|
|
2310
|
+
useDismiss as b,
|
|
2311
|
+
FloatingPortal as c,
|
|
2312
|
+
popupStateMapping as d,
|
|
2313
|
+
useFloatingParentNodeId as e,
|
|
2314
|
+
FloatingRootStore as f,
|
|
2315
|
+
gecko as g,
|
|
2316
|
+
useFloatingTree as h,
|
|
2317
|
+
popupTransitionStateMapping as i,
|
|
2318
|
+
FloatingNode as j,
|
|
2319
|
+
POPUP_COLLISION_AVOIDANCE as k,
|
|
2320
|
+
popupStoreSelectors as l,
|
|
2321
|
+
FloatingTreeStore as m,
|
|
2322
|
+
createInitialPopupStoreState as n,
|
|
2323
|
+
fastComponent as o,
|
|
2324
|
+
pressableTriggerOpenStateMapping as p,
|
|
2325
|
+
useFloatingNodeId as q,
|
|
2326
|
+
useImplicitActiveTrigger as r,
|
|
2327
|
+
useOpenStateTransitions as s,
|
|
2364
2328
|
triggerOpenStateMapping as t,
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2329
|
+
useUnmountAfterClose as u,
|
|
2330
|
+
createPopupOpenState as v,
|
|
2331
|
+
webkit as w,
|
|
2332
|
+
useSyncedFloatingRootContext as x,
|
|
2333
|
+
usePopupInteractionProps as y,
|
|
2334
|
+
PopupHandleAttachment as z
|
|
2371
2335
|
};
|
|
2372
|
-
//# sourceMappingURL=usePopupHandleStore-
|
|
2336
|
+
//# sourceMappingURL=usePopupHandleStore-C_Vw7xcw.js.map
|