@octanejs/base-ui 0.1.30 → 0.1.32
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/cjs/accordion.cjs +497 -0
- package/dist/cjs/alert-dialog.cjs +65 -0
- package/dist/cjs/avatar.cjs +234 -0
- package/dist/cjs/button.cjs +54 -0
- package/dist/cjs/checkbox-group.cjs +165 -0
- package/dist/cjs/checkbox.cjs +475 -0
- package/dist/cjs/collapsible.cjs +700 -0
- package/dist/cjs/context-menu.cjs +257 -0
- package/dist/cjs/csp-provider.cjs +40 -0
- package/dist/cjs/dialog.cjs +741 -0
- package/dist/cjs/direction-provider.cjs +35 -0
- package/dist/cjs/field.cjs +559 -0
- package/dist/cjs/fieldset.cjs +101 -0
- package/dist/cjs/form.cjs +177 -0
- package/dist/cjs/index.cjs +133 -0
- package/dist/cjs/input.cjs +32 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/menu.cjs +2420 -0
- package/dist/cjs/menubar.cjs +132 -0
- package/dist/cjs/merge-props.cjs +34 -0
- package/dist/cjs/meter.cjs +169 -0
- package/dist/cjs/number-field.cjs +812 -0
- package/dist/cjs/popover.cjs +966 -0
- package/dist/cjs/preview-card.cjs +632 -0
- package/dist/cjs/progress.cjs +206 -0
- package/dist/cjs/radio-group.cjs +264 -0
- package/dist/cjs/radio.cjs +327 -0
- package/dist/cjs/separator.cjs +44 -0
- package/dist/cjs/slider.cjs +1384 -0
- package/dist/cjs/switch.cjs +306 -0
- package/dist/cjs/tabs.cjs +727 -0
- package/dist/cjs/toast.cjs +1766 -0
- package/dist/cjs/toggle-group.cjs +118 -0
- package/dist/cjs/toggle.cjs +121 -0
- package/dist/cjs/tooltip.cjs +835 -0
- package/dist/cjs/unstable-use-media-query.cjs +79 -0
- package/dist/cjs/use-render.cjs +40 -0
- package/dist/cjs/utils/CSPContext.cjs +38 -0
- package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
- package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
- package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
- package/dist/cjs/utils/DirectionContext.cjs +34 -0
- package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
- package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
- package/dist/cjs/utils/MenubarContext.cjs +40 -0
- package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
- package/dist/cjs/utils/RequestQueue.cjs +111 -0
- package/dist/cjs/utils/TimeoutManager.cjs +50 -0
- package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
- package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
- package/dist/cjs/utils/addEventListener.cjs +33 -0
- package/dist/cjs/utils/areArraysEqual.cjs +30 -0
- package/dist/cjs/utils/clamp.cjs +30 -0
- package/dist/cjs/utils/closePart.cjs +70 -0
- package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
- package/dist/cjs/utils/composeRefs.cjs +68 -0
- package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
- package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
- package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
- package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
- package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
- package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
- package/dist/cjs/utils/composite/keys.cjs +174 -0
- package/dist/cjs/utils/composite/list-utils.cjs +90 -0
- package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
- package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
- package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
- package/dist/cjs/utils/constants.cjs +56 -0
- package/dist/cjs/utils/contains.cjs +46 -0
- package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
- package/dist/cjs/utils/dom.cjs +35 -0
- package/dist/cjs/utils/empty.cjs +34 -0
- package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
- package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
- package/dist/cjs/utils/field/FormContext.cjs +41 -0
- package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
- package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
- package/dist/cjs/utils/field/constants.cjs +68 -0
- package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
- package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
- package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
- package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
- package/dist/cjs/utils/field/useLabel.cjs +99 -0
- package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
- package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
- package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
- package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
- package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
- package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
- package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
- package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
- package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
- package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
- package/dist/cjs/utils/floating/composite.cjs +42 -0
- package/dist/cjs/utils/floating/constants.cjs +34 -0
- package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
- package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
- package/dist/cjs/utils/floating/element.cjs +103 -0
- package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
- package/dist/cjs/utils/floating/event.cjs +65 -0
- package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
- package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
- package/dist/cjs/utils/floating/markOthers.cjs +181 -0
- package/dist/cjs/utils/floating/nodes.cjs +48 -0
- package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
- package/dist/cjs/utils/floating/tabbable.cjs +242 -0
- package/dist/cjs/utils/floating/types.cjs +16 -0
- package/dist/cjs/utils/floating/useClick.cjs +153 -0
- package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
- package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
- package/dist/cjs/utils/floating/useFloating.cjs +186 -0
- package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
- package/dist/cjs/utils/floating/useFocus.cjs +184 -0
- package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
- package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
- package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
- package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
- package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
- package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
- package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
- package/dist/cjs/utils/formatNumber.cjs +60 -0
- package/dist/cjs/utils/generateId.cjs +32 -0
- package/dist/cjs/utils/getCssDimensions.cjs +42 -0
- package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
- package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
- package/dist/cjs/utils/getElementRef.cjs +35 -0
- package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
- package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
- package/dist/cjs/utils/hideMiddleware.cjs +42 -0
- package/dist/cjs/utils/inertValue.cjs +30 -0
- package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
- package/dist/cjs/utils/mergeCleanups.cjs +37 -0
- package/dist/cjs/utils/mergeObjects.cjs +39 -0
- package/dist/cjs/utils/mergeProps.cjs +182 -0
- package/dist/cjs/utils/noop.cjs +29 -0
- package/dist/cjs/utils/number/constants.cjs +34 -0
- package/dist/cjs/utils/number/parse.cjs +258 -0
- package/dist/cjs/utils/number/types.cjs +16 -0
- package/dist/cjs/utils/number/validate.cjs +104 -0
- package/dist/cjs/utils/owner.cjs +35 -0
- package/dist/cjs/utils/platform.cjs +83 -0
- package/dist/cjs/utils/popupStateMapping.cjs +74 -0
- package/dist/cjs/utils/popups/index.cjs +39 -0
- package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
- package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
- package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
- package/dist/cjs/utils/popups/store.cjs +118 -0
- package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
- package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
- package/dist/cjs/utils/resolveClassName.cjs +30 -0
- package/dist/cjs/utils/resolveRef.cjs +33 -0
- package/dist/cjs/utils/resolveStyle.cjs +30 -0
- package/dist/cjs/utils/serializeValue.cjs +40 -0
- package/dist/cjs/utils/slider/asc.cjs +30 -0
- package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
- package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
- package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
- package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
- package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
- package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
- package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
- package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
- package/dist/cjs/utils/store/ReactStore.cjs +135 -0
- package/dist/cjs/utils/store/Store.cjs +83 -0
- package/dist/cjs/utils/store/createSelector.cjs +74 -0
- package/dist/cjs/utils/store/useStore.cjs +51 -0
- package/dist/cjs/utils/stringifyLocale.cjs +36 -0
- package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
- package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
- package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
- package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
- package/dist/cjs/utils/useBaseUiId.cjs +36 -0
- package/dist/cjs/utils/useButton.cjs +177 -0
- package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
- package/dist/cjs/utils/useControlled.cjs +47 -0
- package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
- package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
- package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
- package/dist/cjs/utils/useIsHydrating.cjs +44 -0
- package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
- package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
- package/dist/cjs/utils/useOnMount.cjs +36 -0
- package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
- package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
- package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
- package/dist/cjs/utils/usePopupViewport.cjs +283 -0
- package/dist/cjs/utils/usePositioner.cjs +53 -0
- package/dist/cjs/utils/usePressAndHold.cjs +51 -0
- package/dist/cjs/utils/usePreviousValue.cjs +47 -0
- package/dist/cjs/utils/useRefWithInit.cjs +41 -0
- package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
- package/dist/cjs/utils/useRenderElement.cjs +106 -0
- package/dist/cjs/utils/useScrollLock.cjs +232 -0
- package/dist/cjs/utils/useStableCallback.cjs +41 -0
- package/dist/cjs/utils/useTimeout.cjs +66 -0
- package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
- package/dist/cjs/utils/useValueAsRef.cjs +43 -0
- package/dist/cjs/utils/useValueChanged.cjs +55 -0
- package/dist/cjs/utils/valueToPercent.cjs +30 -0
- package/dist/cjs/utils/visuallyHidden.cjs +49 -0
- package/package.json +20 -8
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useFloatingRootContext_exports = {};
|
|
20
|
+
__export(useFloatingRootContext_exports, {
|
|
21
|
+
useFloatingRootContext: () => useFloatingRootContext
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useFloatingRootContext_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_dom = require("../dom.cjs");
|
|
27
|
+
var import_useRefWithInit = require("../useRefWithInit.cjs");
|
|
28
|
+
var import_popups = require("../popups/index.cjs");
|
|
29
|
+
var import_FloatingTree = require("./FloatingTree.cjs");
|
|
30
|
+
var import_FloatingRootStore = require("./FloatingRootStore.cjs");
|
|
31
|
+
function useFloatingRootContext(options, slot) {
|
|
32
|
+
const localSlot = slot ?? (0, import_internal.S)("useFloatingRootContext");
|
|
33
|
+
const { open = false, onOpenChange, elements = {} } = options;
|
|
34
|
+
const floatingId = (0, import_octane.useId)((0, import_internal.subSlot)(localSlot, "id"));
|
|
35
|
+
const nested = (0, import_FloatingTree.useFloatingParentNodeId)() != null;
|
|
36
|
+
const store = (0, import_useRefWithInit.useRefWithInit)(
|
|
37
|
+
() => new import_FloatingRootStore.FloatingRootStore({
|
|
38
|
+
open,
|
|
39
|
+
transitionStatus: void 0,
|
|
40
|
+
onOpenChange,
|
|
41
|
+
referenceElement: elements.reference ?? null,
|
|
42
|
+
floatingElement: elements.floating ?? null,
|
|
43
|
+
triggerElements: new import_popups.PopupTriggerMap(),
|
|
44
|
+
floatingId,
|
|
45
|
+
syncOnly: false,
|
|
46
|
+
nested
|
|
47
|
+
}),
|
|
48
|
+
(0, import_internal.subSlot)(localSlot, "store")
|
|
49
|
+
).current;
|
|
50
|
+
(0, import_octane.useLayoutEffect)(
|
|
51
|
+
() => {
|
|
52
|
+
const valuesToSync = {
|
|
53
|
+
open,
|
|
54
|
+
floatingId
|
|
55
|
+
};
|
|
56
|
+
if (elements.reference !== void 0) {
|
|
57
|
+
valuesToSync.referenceElement = elements.reference;
|
|
58
|
+
valuesToSync.domReferenceElement = (0, import_dom.isElement)(elements.reference) ? elements.reference : null;
|
|
59
|
+
}
|
|
60
|
+
if (elements.floating !== void 0) {
|
|
61
|
+
valuesToSync.floatingElement = elements.floating;
|
|
62
|
+
}
|
|
63
|
+
store.update(valuesToSync);
|
|
64
|
+
},
|
|
65
|
+
[open, floatingId, elements.reference, elements.floating, store],
|
|
66
|
+
(0, import_internal.subSlot)(localSlot, "eff")
|
|
67
|
+
);
|
|
68
|
+
store.context.onOpenChange = onOpenChange;
|
|
69
|
+
store.context.nested = nested;
|
|
70
|
+
return store;
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
useFloatingRootContext
|
|
75
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useFocus_exports = {};
|
|
20
|
+
__export(useFocus_exports, {
|
|
21
|
+
useFocus: () => useFocus
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useFocus_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_addEventListener = require("../addEventListener.cjs");
|
|
27
|
+
var import_mergeCleanups = require("../mergeCleanups.cjs");
|
|
28
|
+
var import_owner = require("../owner.cjs");
|
|
29
|
+
var import_platform = require("../platform.cjs");
|
|
30
|
+
var import_useTimeout = require("../useTimeout.cjs");
|
|
31
|
+
var import_dom = require("../dom.cjs");
|
|
32
|
+
var import_matchesFocusVisible = require("../matchesFocusVisible.cjs");
|
|
33
|
+
var import_createChangeEventDetails = require("../createChangeEventDetails.cjs");
|
|
34
|
+
var import_createAttribute = require("./createAttribute.cjs");
|
|
35
|
+
var import_element = require("./element.cjs");
|
|
36
|
+
const isMacSafari = import_platform.platform.os.mac && import_platform.platform.engine.webkit;
|
|
37
|
+
function useFocus(...args) {
|
|
38
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
39
|
+
const slot = slotArg ?? (0, import_internal.S)("useFocus");
|
|
40
|
+
const context = user[0];
|
|
41
|
+
const props = user[1] ?? {};
|
|
42
|
+
const { enabled = true, delay } = props;
|
|
43
|
+
const store = context != null && "rootStore" in context ? context.rootStore : context;
|
|
44
|
+
const { events, dataRef } = store.context;
|
|
45
|
+
const blockFocusRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "block"));
|
|
46
|
+
const blockedReferenceRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "blockedRef"));
|
|
47
|
+
const keyboardModalityRef = (0, import_octane.useRef)(true, (0, import_internal.subSlot)(slot, "kbd"));
|
|
48
|
+
const timeout = (0, import_useTimeout.useTimeout)((0, import_internal.subSlot)(slot, "to"));
|
|
49
|
+
(0, import_octane.useEffect)(
|
|
50
|
+
() => {
|
|
51
|
+
const domReference = store.select("domReferenceElement");
|
|
52
|
+
if (!enabled) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
const win = (0, import_owner.ownerWindow)(domReference);
|
|
56
|
+
function onBlur() {
|
|
57
|
+
const currentDomReference = store.select("domReferenceElement");
|
|
58
|
+
if (!store.select("open") && (0, import_dom.isHTMLElement)(currentDomReference) && currentDomReference === (0, import_element.activeElement)((0, import_owner.ownerDocument)(currentDomReference))) {
|
|
59
|
+
blockFocusRef.current = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function onKeyDown() {
|
|
63
|
+
keyboardModalityRef.current = true;
|
|
64
|
+
}
|
|
65
|
+
function onPointerDown() {
|
|
66
|
+
keyboardModalityRef.current = false;
|
|
67
|
+
}
|
|
68
|
+
return (0, import_mergeCleanups.mergeCleanups)(
|
|
69
|
+
(0, import_addEventListener.addEventListener)(win, "blur", onBlur),
|
|
70
|
+
isMacSafari && (0, import_addEventListener.addEventListener)(win, "keydown", onKeyDown, true),
|
|
71
|
+
isMacSafari && (0, import_addEventListener.addEventListener)(win, "pointerdown", onPointerDown, true)
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
[store, enabled],
|
|
75
|
+
(0, import_internal.subSlot)(slot, "e:win")
|
|
76
|
+
);
|
|
77
|
+
(0, import_octane.useEffect)(
|
|
78
|
+
() => {
|
|
79
|
+
if (!enabled) {
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
function onOpenChangeLocal(details) {
|
|
83
|
+
if (details.reason === import_createChangeEventDetails.REASONS.triggerPress || details.reason === import_createChangeEventDetails.REASONS.escapeKey) {
|
|
84
|
+
const referenceElement = store.select("domReferenceElement");
|
|
85
|
+
if ((0, import_dom.isElement)(referenceElement)) {
|
|
86
|
+
blockedReferenceRef.current = referenceElement;
|
|
87
|
+
blockFocusRef.current = true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
events.on("openchange", onOpenChangeLocal);
|
|
92
|
+
return () => {
|
|
93
|
+
events.off("openchange", onOpenChangeLocal);
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
[events, enabled, store],
|
|
97
|
+
(0, import_internal.subSlot)(slot, "e:openchange")
|
|
98
|
+
);
|
|
99
|
+
const reference = (0, import_octane.useMemo)(
|
|
100
|
+
() => {
|
|
101
|
+
function resetBlockedFocus() {
|
|
102
|
+
blockFocusRef.current = false;
|
|
103
|
+
blockedReferenceRef.current = null;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
onMouseLeave() {
|
|
107
|
+
resetBlockedFocus();
|
|
108
|
+
},
|
|
109
|
+
onFocus(event) {
|
|
110
|
+
const focusTarget = event.currentTarget;
|
|
111
|
+
if (blockFocusRef.current) {
|
|
112
|
+
if (blockedReferenceRef.current === focusTarget) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
resetBlockedFocus();
|
|
116
|
+
}
|
|
117
|
+
const target = (0, import_element.getTarget)(event);
|
|
118
|
+
if ((0, import_dom.isElement)(target)) {
|
|
119
|
+
if (isMacSafari && !event.relatedTarget) {
|
|
120
|
+
if (!keyboardModalityRef.current && !(0, import_element.isTypeableElement)(target)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
} else if (!(0, import_matchesFocusVisible.matchesFocusVisible)(target)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const movedFromOtherEnabledTrigger = (0, import_element.isTargetInsideEnabledTrigger)(
|
|
128
|
+
event.relatedTarget,
|
|
129
|
+
store.context.triggerElements
|
|
130
|
+
);
|
|
131
|
+
const currentTarget = event.currentTarget;
|
|
132
|
+
const delayValue = typeof delay === "function" ? delay() : delay;
|
|
133
|
+
if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
|
|
134
|
+
store.setOpen(
|
|
135
|
+
true,
|
|
136
|
+
(0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.triggerFocus, event, currentTarget)
|
|
137
|
+
);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
timeout.start(delayValue, () => {
|
|
141
|
+
if (blockFocusRef.current) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
store.setOpen(
|
|
145
|
+
true,
|
|
146
|
+
(0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.triggerFocus, event, currentTarget)
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
onBlur(event) {
|
|
151
|
+
resetBlockedFocus();
|
|
152
|
+
const relatedTarget = event.relatedTarget;
|
|
153
|
+
const movedToFocusGuard = (0, import_dom.isElement)(relatedTarget) && relatedTarget.hasAttribute((0, import_createAttribute.createAttribute)("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
|
|
154
|
+
timeout.start(0, () => {
|
|
155
|
+
const domReference = store.select("domReferenceElement");
|
|
156
|
+
const activeEl = (0, import_element.activeElement)((0, import_owner.ownerDocument)(domReference));
|
|
157
|
+
if (!relatedTarget && activeEl === domReference) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if ((0, import_element.contains)(dataRef.current.floatingContext?.refs.floating.current, activeEl) || (0, import_element.contains)(domReference, activeEl) || movedToFocusGuard) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const nextFocusedElement = relatedTarget ?? activeEl;
|
|
164
|
+
if ((0, import_element.isTargetInsideEnabledTrigger)(nextFocusedElement, store.context.triggerElements)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.triggerFocus, event));
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
[dataRef, delay, store, timeout],
|
|
173
|
+
(0, import_internal.subSlot)(slot, "ref")
|
|
174
|
+
);
|
|
175
|
+
return (0, import_octane.useMemo)(
|
|
176
|
+
() => enabled ? { reference, trigger: reference } : {},
|
|
177
|
+
[enabled, reference],
|
|
178
|
+
(0, import_internal.subSlot)(slot, "out")
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
182
|
+
0 && (module.exports = {
|
|
183
|
+
useFocus
|
|
184
|
+
});
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useHoverFloatingInteraction_exports = {};
|
|
20
|
+
__export(useHoverFloatingInteraction_exports, {
|
|
21
|
+
useHoverFloatingInteraction: () => useHoverFloatingInteraction
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useHoverFloatingInteraction_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_addEventListener = require("../addEventListener.cjs");
|
|
27
|
+
var import_mergeCleanups = require("../mergeCleanups.cjs");
|
|
28
|
+
var import_owner = require("../owner.cjs");
|
|
29
|
+
var import_useStableCallback = require("../useStableCallback.cjs");
|
|
30
|
+
var import_useTimeout = require("../useTimeout.cjs");
|
|
31
|
+
var import_dom = require("../dom.cjs");
|
|
32
|
+
var import_createChangeEventDetails = require("../createChangeEventDetails.cjs");
|
|
33
|
+
var import_FloatingTree = require("./FloatingTree.cjs");
|
|
34
|
+
var import_element = require("./element.cjs");
|
|
35
|
+
var import_nodes = require("./nodes.cjs");
|
|
36
|
+
var import_useHoverInteractionSharedState = require("./useHoverInteractionSharedState.cjs");
|
|
37
|
+
var import_useHoverShared = require("./useHoverShared.cjs");
|
|
38
|
+
function useHoverFloatingInteraction(...args) {
|
|
39
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
40
|
+
const slot = slotArg ?? (0, import_internal.S)("useHoverFloatingInteraction");
|
|
41
|
+
const context = user[0];
|
|
42
|
+
const parameters = user[1] ?? {};
|
|
43
|
+
const { enabled = true, closeDelay: closeDelayProp = 0, nodeId: nodeIdProp } = parameters;
|
|
44
|
+
const store = context != null && "rootStore" in context ? context.rootStore : context;
|
|
45
|
+
const open = store.useState("open", (0, import_internal.subSlot)(slot, "s:open"));
|
|
46
|
+
const floatingElement = store.useState("floatingElement", (0, import_internal.subSlot)(slot, "s:floating"));
|
|
47
|
+
const domReferenceElement = store.useState("domReferenceElement", (0, import_internal.subSlot)(slot, "s:ref"));
|
|
48
|
+
const dataRef = store.context.dataRef;
|
|
49
|
+
const tree = (0, import_FloatingTree.useFloatingTree)();
|
|
50
|
+
const parentId = (0, import_FloatingTree.useFloatingParentNodeId)();
|
|
51
|
+
const instance = (0, import_useHoverInteractionSharedState.useHoverInteractionSharedState)(store, (0, import_internal.subSlot)(slot, "shared"));
|
|
52
|
+
const childClosedTimeout = (0, import_useTimeout.useTimeout)((0, import_internal.subSlot)(slot, "cct"));
|
|
53
|
+
const isClickLikeOpenEvent = (0, import_useStableCallback.useStableCallback)(
|
|
54
|
+
() => {
|
|
55
|
+
return (0, import_useHoverShared.isClickLikeOpenEvent)(dataRef.current.openEvent?.type, instance.interactedInside);
|
|
56
|
+
},
|
|
57
|
+
(0, import_internal.subSlot)(slot, "iclo")
|
|
58
|
+
);
|
|
59
|
+
const isHoverOpen = (0, import_useStableCallback.useStableCallback)(
|
|
60
|
+
() => {
|
|
61
|
+
return (0, import_useHoverShared.isHoverOpenEvent)(dataRef.current.openEvent?.type);
|
|
62
|
+
},
|
|
63
|
+
(0, import_internal.subSlot)(slot, "iho")
|
|
64
|
+
);
|
|
65
|
+
const clearPointerEvents = (0, import_useStableCallback.useStableCallback)(
|
|
66
|
+
() => {
|
|
67
|
+
(0, import_useHoverInteractionSharedState.clearSafePolygonPointerEventsMutation)(instance);
|
|
68
|
+
},
|
|
69
|
+
(0, import_internal.subSlot)(slot, "cpe")
|
|
70
|
+
);
|
|
71
|
+
(0, import_octane.useLayoutEffect)(
|
|
72
|
+
() => {
|
|
73
|
+
if (!open) {
|
|
74
|
+
instance.pointerType = void 0;
|
|
75
|
+
instance.restTimeoutPending = false;
|
|
76
|
+
instance.interactedInside = false;
|
|
77
|
+
clearPointerEvents();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[open, instance, clearPointerEvents],
|
|
81
|
+
(0, import_internal.subSlot)(slot, "l:reset")
|
|
82
|
+
);
|
|
83
|
+
(0, import_octane.useEffect)(
|
|
84
|
+
() => {
|
|
85
|
+
return clearPointerEvents;
|
|
86
|
+
},
|
|
87
|
+
[clearPointerEvents],
|
|
88
|
+
(0, import_internal.subSlot)(slot, "e:cpe")
|
|
89
|
+
);
|
|
90
|
+
(0, import_octane.useLayoutEffect)(
|
|
91
|
+
() => {
|
|
92
|
+
if (!enabled) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && (0, import_dom.isElement)(domReferenceElement) && floatingElement) {
|
|
96
|
+
const ref = domReferenceElement;
|
|
97
|
+
const floatingEl = floatingElement;
|
|
98
|
+
const doc = (0, import_owner.ownerDocument)(floatingElement);
|
|
99
|
+
const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
|
|
100
|
+
if (parentFloating) {
|
|
101
|
+
parentFloating.style.pointerEvents = "";
|
|
102
|
+
}
|
|
103
|
+
const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
|
|
104
|
+
const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
|
|
105
|
+
const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
|
|
106
|
+
(0, import_useHoverInteractionSharedState.applySafePolygonPointerEventsMutation)(instance, {
|
|
107
|
+
scopeElement,
|
|
108
|
+
referenceElement: ref,
|
|
109
|
+
floatingElement: floatingEl
|
|
110
|
+
});
|
|
111
|
+
return () => {
|
|
112
|
+
clearPointerEvents();
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return void 0;
|
|
116
|
+
},
|
|
117
|
+
[
|
|
118
|
+
enabled,
|
|
119
|
+
open,
|
|
120
|
+
domReferenceElement,
|
|
121
|
+
floatingElement,
|
|
122
|
+
instance,
|
|
123
|
+
isHoverOpen,
|
|
124
|
+
tree,
|
|
125
|
+
parentId,
|
|
126
|
+
clearPointerEvents
|
|
127
|
+
],
|
|
128
|
+
(0, import_internal.subSlot)(slot, "l:blockPointer")
|
|
129
|
+
);
|
|
130
|
+
(0, import_octane.useEffect)(
|
|
131
|
+
() => {
|
|
132
|
+
if (!enabled) {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
function hasParentChildren() {
|
|
136
|
+
return !!(tree && parentId && (0, import_nodes.getNodeChildren)(tree.nodesRef.current, parentId).length > 0);
|
|
137
|
+
}
|
|
138
|
+
function closeWithDelay(event) {
|
|
139
|
+
const closeDelay = (0, import_useHoverShared.getDelay)(closeDelayProp, "close", instance.pointerType);
|
|
140
|
+
const close = () => {
|
|
141
|
+
store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.triggerHover, event));
|
|
142
|
+
tree?.events.emit("floating.closed", event);
|
|
143
|
+
};
|
|
144
|
+
if (closeDelay) {
|
|
145
|
+
instance.openChangeTimeout.start(closeDelay, close);
|
|
146
|
+
} else {
|
|
147
|
+
instance.openChangeTimeout.clear();
|
|
148
|
+
close();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function handleInteractInside(event) {
|
|
152
|
+
const target = (0, import_element.getTarget)(event);
|
|
153
|
+
if (!(0, import_useHoverInteractionSharedState.isInteractiveElement)(target)) {
|
|
154
|
+
instance.interactedInside = false;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
instance.interactedInside = target?.closest("[aria-haspopup]") != null;
|
|
158
|
+
}
|
|
159
|
+
function onFloatingMouseEnter() {
|
|
160
|
+
instance.openChangeTimeout.clear();
|
|
161
|
+
childClosedTimeout.clear();
|
|
162
|
+
tree?.events.off("floating.closed", onNodeClosed);
|
|
163
|
+
clearPointerEvents();
|
|
164
|
+
}
|
|
165
|
+
function onFloatingMouseLeave(event) {
|
|
166
|
+
if (hasParentChildren() && tree) {
|
|
167
|
+
tree.events.on("floating.closed", onNodeClosed);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if ((0, import_useHoverShared.isInsideEnabledTrigger)(event.relatedTarget, store.context.triggerElements)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
|
|
174
|
+
const relatedTarget = event.relatedTarget;
|
|
175
|
+
const isMovingIntoDescendantFloating = tree && currentNodeId && (0, import_dom.isElement)(relatedTarget) && (0, import_nodes.getNodeChildren)(tree.nodesRef.current, currentNodeId, false).some(
|
|
176
|
+
(node) => (0, import_element.contains)(node.context?.elements.floating, relatedTarget)
|
|
177
|
+
);
|
|
178
|
+
if (isMovingIntoDescendantFloating) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (instance.handler) {
|
|
182
|
+
instance.handler(event);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
clearPointerEvents();
|
|
186
|
+
if (isHoverOpen() && !isClickLikeOpenEvent()) {
|
|
187
|
+
closeWithDelay(event);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function onNodeClosed(event) {
|
|
191
|
+
if (!tree || !parentId || hasParentChildren()) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
childClosedTimeout.start(0, () => {
|
|
195
|
+
tree.events.off("floating.closed", onNodeClosed);
|
|
196
|
+
store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.triggerHover, event));
|
|
197
|
+
tree.events.emit("floating.closed", event);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const floating = floatingElement;
|
|
201
|
+
return (0, import_mergeCleanups.mergeCleanups)(
|
|
202
|
+
floating && (0, import_addEventListener.addEventListener)(floating, "mouseenter", onFloatingMouseEnter),
|
|
203
|
+
floating && (0, import_addEventListener.addEventListener)(floating, "mouseleave", onFloatingMouseLeave),
|
|
204
|
+
floating && (0, import_addEventListener.addEventListener)(floating, "pointerdown", handleInteractInside, true),
|
|
205
|
+
() => {
|
|
206
|
+
tree?.events.off("floating.closed", onNodeClosed);
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
enabled,
|
|
212
|
+
floatingElement,
|
|
213
|
+
store,
|
|
214
|
+
dataRef,
|
|
215
|
+
closeDelayProp,
|
|
216
|
+
nodeIdProp,
|
|
217
|
+
isHoverOpen,
|
|
218
|
+
isClickLikeOpenEvent,
|
|
219
|
+
clearPointerEvents,
|
|
220
|
+
instance,
|
|
221
|
+
tree,
|
|
222
|
+
parentId,
|
|
223
|
+
childClosedTimeout
|
|
224
|
+
],
|
|
225
|
+
(0, import_internal.subSlot)(slot, "e:listeners")
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
229
|
+
0 && (module.exports = {
|
|
230
|
+
useHoverFloatingInteraction
|
|
231
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useHoverInteractionSharedState_exports = {};
|
|
20
|
+
__export(useHoverInteractionSharedState_exports, {
|
|
21
|
+
HoverInteraction: () => HoverInteraction,
|
|
22
|
+
applySafePolygonPointerEventsMutation: () => applySafePolygonPointerEventsMutation,
|
|
23
|
+
clearSafePolygonPointerEventsMutation: () => clearSafePolygonPointerEventsMutation,
|
|
24
|
+
isInteractiveElement: () => import_element.isInteractiveElement,
|
|
25
|
+
useHoverInteractionSharedState: () => useHoverInteractionSharedState
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useHoverInteractionSharedState_exports);
|
|
28
|
+
var import_octane = require("octane");
|
|
29
|
+
var import_internal = require("../../internal.cjs");
|
|
30
|
+
var import_useTimeout = require("../useTimeout.cjs");
|
|
31
|
+
var import_useRefWithInit = require("../useRefWithInit.cjs");
|
|
32
|
+
var import_element = require("./element.cjs");
|
|
33
|
+
class HoverInteraction {
|
|
34
|
+
pointerType = void 0;
|
|
35
|
+
interactedInside = false;
|
|
36
|
+
handler = void 0;
|
|
37
|
+
blockMouseMove = true;
|
|
38
|
+
performedPointerEventsMutation = false;
|
|
39
|
+
pointerEventsScopeElement = null;
|
|
40
|
+
pointerEventsReferenceElement = null;
|
|
41
|
+
pointerEventsFloatingElement = null;
|
|
42
|
+
restTimeoutPending = false;
|
|
43
|
+
openChangeTimeout = new import_useTimeout.Timeout();
|
|
44
|
+
restTimeout = new import_useTimeout.Timeout();
|
|
45
|
+
handleCloseOptions = void 0;
|
|
46
|
+
static create() {
|
|
47
|
+
return new HoverInteraction();
|
|
48
|
+
}
|
|
49
|
+
dispose = () => {
|
|
50
|
+
this.openChangeTimeout.clear();
|
|
51
|
+
this.restTimeout.clear();
|
|
52
|
+
};
|
|
53
|
+
disposeEffect = () => {
|
|
54
|
+
return this.dispose;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
|
|
58
|
+
function clearSafePolygonPointerEventsMutation(instance) {
|
|
59
|
+
if (!instance.performedPointerEventsMutation) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const scopeElement = instance.pointerEventsScopeElement;
|
|
63
|
+
if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
|
|
64
|
+
instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
|
|
65
|
+
instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
|
|
66
|
+
instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
|
|
67
|
+
pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
|
|
68
|
+
}
|
|
69
|
+
instance.performedPointerEventsMutation = false;
|
|
70
|
+
instance.pointerEventsScopeElement = null;
|
|
71
|
+
instance.pointerEventsReferenceElement = null;
|
|
72
|
+
instance.pointerEventsFloatingElement = null;
|
|
73
|
+
}
|
|
74
|
+
function applySafePolygonPointerEventsMutation(instance, options) {
|
|
75
|
+
const { scopeElement, referenceElement, floatingElement } = options;
|
|
76
|
+
const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
|
|
77
|
+
if (existingOwner && existingOwner !== instance) {
|
|
78
|
+
clearSafePolygonPointerEventsMutation(existingOwner);
|
|
79
|
+
}
|
|
80
|
+
clearSafePolygonPointerEventsMutation(instance);
|
|
81
|
+
instance.performedPointerEventsMutation = true;
|
|
82
|
+
instance.pointerEventsScopeElement = scopeElement;
|
|
83
|
+
instance.pointerEventsReferenceElement = referenceElement;
|
|
84
|
+
instance.pointerEventsFloatingElement = floatingElement;
|
|
85
|
+
pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
|
|
86
|
+
scopeElement.style.pointerEvents = "none";
|
|
87
|
+
referenceElement.style.pointerEvents = "auto";
|
|
88
|
+
floatingElement.style.pointerEvents = "auto";
|
|
89
|
+
}
|
|
90
|
+
function useHoverInteractionSharedState(...args) {
|
|
91
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
92
|
+
const slot = slotArg ?? (0, import_internal.S)("useHoverInteractionSharedState");
|
|
93
|
+
const store = user[0];
|
|
94
|
+
const data = store.context.dataRef.current;
|
|
95
|
+
const instance = (0, import_useRefWithInit.useRefWithInit)(
|
|
96
|
+
() => data.hoverInteractionState ?? HoverInteraction.create(),
|
|
97
|
+
void 0,
|
|
98
|
+
(0, import_internal.subSlot)(slot, "inst")
|
|
99
|
+
).current;
|
|
100
|
+
if (!data.hoverInteractionState) {
|
|
101
|
+
data.hoverInteractionState = instance;
|
|
102
|
+
}
|
|
103
|
+
(0, import_octane.useEffect)(data.hoverInteractionState.disposeEffect, [], (0, import_internal.subSlot)(slot, "e:mount"));
|
|
104
|
+
return data.hoverInteractionState;
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
HoverInteraction,
|
|
109
|
+
applySafePolygonPointerEventsMutation,
|
|
110
|
+
clearSafePolygonPointerEventsMutation,
|
|
111
|
+
isInteractiveElement,
|
|
112
|
+
useHoverInteractionSharedState
|
|
113
|
+
});
|