@wix/site-ui 1.30.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/1268.js +99 -0
- package/dist/1279.js +7 -0
- package/dist/1457.js +10 -0
- package/dist/1477.js +106 -0
- package/dist/1500.js +111 -0
- package/dist/167.js +6 -0
- package/dist/2274.js +34 -0
- package/dist/2287.js +17 -0
- package/dist/2418.js +31 -0
- package/dist/2801.js +20 -0
- package/dist/285.js +86 -0
- package/dist/2861.js +6 -0
- package/dist/3020.js +7 -0
- package/dist/3021.js +72 -0
- package/dist/3056.js +229 -0
- package/dist/3140.js +4 -0
- package/dist/3248.js +307 -0
- package/dist/3296.js +4 -0
- package/dist/3319.js +400 -0
- package/dist/3395.js +4 -0
- package/dist/3485.js +854 -0
- package/dist/353.js +14 -0
- package/dist/3670.js +418 -0
- package/dist/3829.js +113 -0
- package/dist/4026.js +12 -0
- package/dist/4143.js +46 -0
- package/dist/42.js +32 -0
- package/dist/4281.js +30 -0
- package/dist/4346.js +2 -0
- package/dist/4388.js +418 -0
- package/dist/4490.js +32 -0
- package/dist/4495.js +9 -0
- package/dist/4549.js +24 -0
- package/dist/4586.js +41 -0
- package/dist/4586.js.LICENSE.txt +19 -0
- package/dist/4707.js +19 -0
- package/dist/4723.js +7 -0
- package/dist/4745.js +7 -0
- package/dist/4768.js +35 -0
- package/dist/4922.js +15 -0
- package/dist/5036.js +17 -0
- package/dist/5085.js +20 -0
- package/dist/5299.js +597 -0
- package/dist/5659.js +4 -0
- package/dist/5778.js +10 -0
- package/dist/5864.js +86 -0
- package/dist/5992.js +913 -0
- package/dist/5992.js.LICENSE.txt +19 -0
- package/dist/6003.js +10 -0
- package/dist/6046.js +29 -0
- package/dist/6089.js +2355 -0
- package/dist/6107.js +10 -0
- package/dist/6247.js +20 -0
- package/dist/6270.js +487 -0
- package/dist/6329.js +32 -0
- package/dist/6330.js +30 -0
- package/dist/6499.js +7 -0
- package/dist/6535.js +71 -0
- package/dist/6588.js +382 -0
- package/dist/6706.js +16 -0
- package/dist/6825.js +7 -0
- package/dist/6882.js +1562 -0
- package/dist/6914.js +30 -0
- package/dist/7021.js +13 -0
- package/dist/7366.js +83 -0
- package/dist/7373.js +25 -0
- package/dist/7541.js +25 -0
- package/dist/7564.js +10 -0
- package/dist/7642.js +20 -0
- package/dist/7725.js +10 -0
- package/dist/7871.js +38 -0
- package/dist/8052.js +352 -0
- package/dist/8106.js +238 -0
- package/dist/8171.js +346 -0
- package/dist/8225.js +21 -0
- package/dist/8272.js +333 -0
- package/dist/8527.js +58 -0
- package/dist/8724.js +10 -0
- package/dist/8750.js +1920 -0
- package/dist/8758.js +43 -0
- package/dist/880.js +149 -0
- package/dist/8935.js +8 -0
- package/dist/8960.js +22 -0
- package/dist/8971.js +40 -0
- package/dist/8979.js +10 -0
- package/dist/8996.js +71 -0
- package/dist/904.js +121 -0
- package/dist/9048.js +52 -0
- package/dist/9087.js +256 -0
- package/dist/9189.js +158 -0
- package/dist/9255.js +136 -0
- package/dist/9352.js +148 -0
- package/dist/951.js +22 -0
- package/dist/9635.js +22 -0
- package/dist/9829.js +4 -0
- package/dist/9863.js +8 -0
- package/dist/Accordion/index.d.ts +569 -12
- package/dist/Accordion/index.js +423 -8
- package/dist/AlertDialog/index.d.ts +1417 -18
- package/dist/AlertDialog/index.js +34 -14
- package/dist/Autocomplete/index.d.ts +1861 -38
- package/dist/Autocomplete/index.js +98 -24
- package/dist/Avatar/index.d.ts +129 -7
- package/dist/Avatar/index.js +149 -6
- package/dist/Breadcrumbs/index.d.ts +960 -7
- package/dist/Breadcrumbs/index.js +5 -5
- package/dist/Button/index.d.ts +88 -6
- package/dist/Button/index.js +27 -3
- package/dist/Checkbox/index.d.ts +425 -5
- package/dist/Checkbox/index.js +45 -5
- package/dist/CheckboxGroup/index.d.ts +318 -3
- package/dist/CheckboxGroup/index.js +166 -3
- package/dist/Collapsible/index.d.ts +377 -7
- package/dist/Collapsible/index.js +160 -6
- package/dist/Combobox/index.d.ts +1984 -48
- package/dist/Combobox/index.js +352 -29
- package/dist/ContextMenu/index.d.ts +2340 -36
- package/dist/ContextMenu/index.js +197 -22
- package/dist/Dialog/index.d.ts +1355 -18
- package/dist/Dialog/index.js +16 -14
- package/dist/Drawer/index.d.ts +1653 -18
- package/dist/Drawer/index.js +2797 -20
- package/dist/Field/index.d.ts +655 -15
- package/dist/Field/index.js +677 -10
- package/dist/Fieldset/index.d.ts +94 -5
- package/dist/Fieldset/index.js +68 -5
- package/dist/Form/index.d.ts +331 -2
- package/dist/Form/index.js +106 -3
- package/dist/Input/index.d.ts +692 -3
- package/dist/Input/index.js +10 -3
- package/dist/Menu/index.d.ts +2301 -36
- package/dist/Menu/index.js +365 -26
- package/dist/Menubar/index.d.ts +2301 -3
- package/dist/Menubar/index.js +105 -3
- package/dist/Meter/index.d.ts +175 -11
- package/dist/Meter/index.js +129 -9
- package/dist/NavigationMenu/index.d.ts +978 -28
- package/dist/NavigationMenu/index.js +1034 -17
- package/dist/NumberField/index.d.ts +612 -15
- package/dist/NumberField/index.js +1409 -11
- package/dist/Popover/index.d.ts +1655 -20
- package/dist/Popover/index.js +792 -17
- package/dist/PreviewCard/index.d.ts +1523 -14
- package/dist/PreviewCard/index.js +679 -14
- package/dist/Progress/index.d.ts +183 -11
- package/dist/Progress/index.js +181 -9
- package/dist/Radio/index.d.ts +185 -6
- package/dist/Radio/index.js +253 -6
- package/dist/RadioGroup/index.d.ts +341 -2
- package/dist/RadioGroup/index.js +154 -3
- package/dist/ScrollArea/index.d.ts +265 -13
- package/dist/ScrollArea/index.js +892 -10
- package/dist/Select/index.d.ts +1493 -38
- package/dist/Select/index.js +1824 -23
- package/dist/Separator/index.d.ts +80 -6
- package/dist/Separator/index.js +3 -3
- package/dist/Slider/index.d.ts +678 -16
- package/dist/Slider/index.js +1199 -11
- package/dist/Switch/index.d.ts +393 -5
- package/dist/Switch/index.js +208 -6
- package/dist/Tabs/index.d.ts +523 -12
- package/dist/Tabs/index.js +685 -9
- package/dist/Toggle/index.d.ts +305 -2
- package/dist/Toggle/index.js +76 -3
- package/dist/ToggleGroup/index.d.ts +316 -2
- package/dist/ToggleGroup/index.js +102 -3
- package/dist/Toolbar/index.d.ts +282 -13
- package/dist/Toolbar/index.js +230 -9
- package/dist/Tooltip/index.d.ts +1572 -14
- package/dist/Tooltip/index.js +965 -14
- package/dist/index.d.ts +12749 -652
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/353.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { esm_formatErrorMessage } from "./8272.js";
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
const FieldsetRootContext = /*#__PURE__*/ __rspack_external_react.createContext({
|
|
4
|
+
legendId: void 0,
|
|
5
|
+
setLegendId: ()=>{},
|
|
6
|
+
disabled: void 0
|
|
7
|
+
});
|
|
8
|
+
if ("production" !== process.env.NODE_ENV) FieldsetRootContext.displayName = "FieldsetRootContext";
|
|
9
|
+
function useFieldsetRootContext(optional = false) {
|
|
10
|
+
const context = __rspack_external_react.useContext(FieldsetRootContext);
|
|
11
|
+
if (!context && !optional) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: FieldsetRootContext is missing. Fieldset parts must be placed within <Fieldset.Root>.' : esm_formatErrorMessage(86));
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
14
|
+
export { FieldsetRootContext, useFieldsetRootContext };
|
package/dist/3670.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { useFloatingTree } from "./285.js";
|
|
2
|
+
import { useHoverInteractionSharedState, clearSafePolygonPointerEventsMutation, getDelay, applySafePolygonPointerEventsMutation, getRestMs, useHoverShared_isClickLikeOpenEvent } from "./3056.js";
|
|
3
|
+
import { useValueAsRef } from "./4707.js";
|
|
4
|
+
import { useStableCallback } from "./7541.js";
|
|
5
|
+
import { getTarget, contains } from "./4549.js";
|
|
6
|
+
import { isElement } from "./3829.js";
|
|
7
|
+
import { ownerDocument } from "./9829.js";
|
|
8
|
+
import { triggerHover } from "./2418.js";
|
|
9
|
+
import { createChangeEventDetails } from "./4768.js";
|
|
10
|
+
import { isMouseLikePointerType } from "./6330.js";
|
|
11
|
+
import { isTargetInsideEnabledTrigger } from "./8758.js";
|
|
12
|
+
import { mergeCleanups } from "./4495.js";
|
|
13
|
+
import { addEventListener } from "./4723.js";
|
|
14
|
+
import { Timeout } from "./42.js";
|
|
15
|
+
import { getNodeChildren } from "./5992.js";
|
|
16
|
+
import * as __rspack_external_react from "react";
|
|
17
|
+
import * as __rspack_external_react_dom_7136dc57 from "react-dom";
|
|
18
|
+
const EMPTY_REF = {
|
|
19
|
+
current: null
|
|
20
|
+
};
|
|
21
|
+
function useHoverReferenceInteraction(context, props = {}) {
|
|
22
|
+
const { enabled = true, delay = 0, handleClose = null, mouseOnly = false, restMs = 0, move = true, triggerElementRef = EMPTY_REF, externalTree, isActiveTrigger = true, getHandleCloseContext, isClosing, shouldOpen: shouldOpenProp } = props;
|
|
23
|
+
const store = 'rootStore' in context ? context.rootStore : context;
|
|
24
|
+
const { dataRef, events } = store.context;
|
|
25
|
+
const tree = useFloatingTree(externalTree);
|
|
26
|
+
const instance = useHoverInteractionSharedState(store);
|
|
27
|
+
const isHoverCloseActiveRef = __rspack_external_react.useRef(false);
|
|
28
|
+
const handleCloseRef = useValueAsRef(handleClose);
|
|
29
|
+
const delayRef = useValueAsRef(delay);
|
|
30
|
+
const restMsRef = useValueAsRef(restMs);
|
|
31
|
+
const enabledRef = useValueAsRef(enabled);
|
|
32
|
+
const shouldOpenRef = useValueAsRef(shouldOpenProp);
|
|
33
|
+
const isClosingRef = useValueAsRef(isClosing);
|
|
34
|
+
const isClickLikeOpenEvent = useStableCallback(()=>useHoverShared_isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside));
|
|
35
|
+
const checkShouldOpen = useStableCallback(()=>shouldOpenRef.current?.() !== false);
|
|
36
|
+
const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target)=>{
|
|
37
|
+
const allTriggers = store.context.triggerElements;
|
|
38
|
+
if (allTriggers.hasElement(currentTarget)) return !currentDomReference || !contains(currentDomReference, currentTarget);
|
|
39
|
+
if (!isElement(target)) return false;
|
|
40
|
+
const targetElement = target;
|
|
41
|
+
return allTriggers.hasMatchingElement((trigger)=>contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
|
|
42
|
+
});
|
|
43
|
+
const cleanupMouseMoveHandler = useStableCallback(()=>{
|
|
44
|
+
if (!instance.handler) return;
|
|
45
|
+
const doc = ownerDocument(store.select('domReferenceElement'));
|
|
46
|
+
doc.removeEventListener('mousemove', instance.handler);
|
|
47
|
+
instance.handler = void 0;
|
|
48
|
+
});
|
|
49
|
+
const clearPointerEvents = useStableCallback(()=>{
|
|
50
|
+
clearSafePolygonPointerEventsMutation(instance);
|
|
51
|
+
});
|
|
52
|
+
if (isActiveTrigger) instance.handleCloseOptions = handleCloseRef.current?.__options;
|
|
53
|
+
__rspack_external_react.useEffect(()=>cleanupMouseMoveHandler, [
|
|
54
|
+
cleanupMouseMoveHandler
|
|
55
|
+
]);
|
|
56
|
+
__rspack_external_react.useEffect(()=>{
|
|
57
|
+
if (!enabled) return;
|
|
58
|
+
function onOpenChangeLocal(details) {
|
|
59
|
+
if (details.open) isHoverCloseActiveRef.current = false;
|
|
60
|
+
else {
|
|
61
|
+
isHoverCloseActiveRef.current = details.reason === triggerHover;
|
|
62
|
+
cleanupMouseMoveHandler();
|
|
63
|
+
instance.openChangeTimeout.clear();
|
|
64
|
+
instance.restTimeout.clear();
|
|
65
|
+
instance.blockMouseMove = true;
|
|
66
|
+
instance.restTimeoutPending = false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
events.on('openchange', onOpenChangeLocal);
|
|
70
|
+
return ()=>{
|
|
71
|
+
events.off('openchange', onOpenChangeLocal);
|
|
72
|
+
};
|
|
73
|
+
}, [
|
|
74
|
+
enabled,
|
|
75
|
+
events,
|
|
76
|
+
instance,
|
|
77
|
+
cleanupMouseMoveHandler
|
|
78
|
+
]);
|
|
79
|
+
__rspack_external_react.useEffect(()=>{
|
|
80
|
+
if (!enabled) return;
|
|
81
|
+
function closeWithDelay(event, runElseBranch = true) {
|
|
82
|
+
const closeDelay = getDelay(delayRef.current, 'close', instance.pointerType);
|
|
83
|
+
if (closeDelay) instance.openChangeTimeout.start(closeDelay, ()=>{
|
|
84
|
+
store.setOpen(false, createChangeEventDetails(triggerHover, event));
|
|
85
|
+
tree?.events.emit('floating.closed', event);
|
|
86
|
+
});
|
|
87
|
+
else if (runElseBranch) {
|
|
88
|
+
instance.openChangeTimeout.clear();
|
|
89
|
+
store.setOpen(false, createChangeEventDetails(triggerHover, event));
|
|
90
|
+
tree?.events.emit('floating.closed', event);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select('domReferenceElement') : null);
|
|
94
|
+
if (!isElement(trigger)) return;
|
|
95
|
+
function onMouseEnter(event) {
|
|
96
|
+
instance.openChangeTimeout.clear();
|
|
97
|
+
instance.blockMouseMove = false;
|
|
98
|
+
if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) return;
|
|
99
|
+
const restMsValue = getRestMs(restMsRef.current);
|
|
100
|
+
const openDelay = getDelay(delayRef.current, 'open', instance.pointerType);
|
|
101
|
+
const eventTarget = getTarget(event);
|
|
102
|
+
const currentTarget = event.currentTarget ?? null;
|
|
103
|
+
const currentDomReference = store.select('domReferenceElement');
|
|
104
|
+
let triggerNode = currentTarget;
|
|
105
|
+
if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
|
|
106
|
+
for (const triggerElement of store.context.triggerElements.elements())if (contains(triggerElement, eventTarget)) {
|
|
107
|
+
triggerNode = triggerElement;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) triggerNode = currentDomReference;
|
|
112
|
+
const isOverInactive = null == triggerNode ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
|
|
113
|
+
const isOpen = store.select('open');
|
|
114
|
+
const isInClosingTransition = isClosingRef.current?.() ?? 'ending' === store.select('transitionStatus');
|
|
115
|
+
const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
|
|
116
|
+
const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
|
|
117
|
+
const isRestOnlyDelay = restMsValue > 0 && !openDelay;
|
|
118
|
+
const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
|
|
119
|
+
const shouldOpen = !isOpen || isOverInactive;
|
|
120
|
+
if (shouldOpenImmediately) {
|
|
121
|
+
if (checkShouldOpen()) store.setOpen(true, createChangeEventDetails(triggerHover, event, triggerNode));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (isRestOnlyDelay) return;
|
|
125
|
+
if (openDelay) instance.openChangeTimeout.start(openDelay, ()=>{
|
|
126
|
+
if (shouldOpen && checkShouldOpen()) store.setOpen(true, createChangeEventDetails(triggerHover, event, triggerNode));
|
|
127
|
+
});
|
|
128
|
+
else if (shouldOpen) {
|
|
129
|
+
if (checkShouldOpen()) store.setOpen(true, createChangeEventDetails(triggerHover, event, triggerNode));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function onMouseLeave(event) {
|
|
133
|
+
if (isClickLikeOpenEvent()) return void clearPointerEvents();
|
|
134
|
+
cleanupMouseMoveHandler();
|
|
135
|
+
const domReferenceElement = store.select('domReferenceElement');
|
|
136
|
+
const doc = ownerDocument(domReferenceElement);
|
|
137
|
+
instance.restTimeout.clear();
|
|
138
|
+
instance.restTimeoutPending = false;
|
|
139
|
+
const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
|
|
140
|
+
if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) return;
|
|
141
|
+
if (handleCloseRef.current && handleCloseContextBase) {
|
|
142
|
+
if (!store.select('open')) instance.openChangeTimeout.clear();
|
|
143
|
+
const currentTrigger = triggerElementRef.current;
|
|
144
|
+
instance.handler = handleCloseRef.current({
|
|
145
|
+
...handleCloseContextBase,
|
|
146
|
+
tree,
|
|
147
|
+
x: event.clientX,
|
|
148
|
+
y: event.clientY,
|
|
149
|
+
onClose () {
|
|
150
|
+
clearPointerEvents();
|
|
151
|
+
cleanupMouseMoveHandler();
|
|
152
|
+
if (enabledRef.current && !isClickLikeOpenEvent() && currentTrigger === store.select('domReferenceElement')) closeWithDelay(event, true);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
doc.addEventListener('mousemove', instance.handler);
|
|
156
|
+
instance.handler(event);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const shouldClose = 'touch' === instance.pointerType ? !contains(store.select('floatingElement'), event.relatedTarget) : true;
|
|
160
|
+
if (shouldClose) closeWithDelay(event);
|
|
161
|
+
}
|
|
162
|
+
if (move) return mergeCleanups(addEventListener(trigger, 'mousemove', onMouseEnter, {
|
|
163
|
+
once: true
|
|
164
|
+
}), addEventListener(trigger, 'mouseenter', onMouseEnter), addEventListener(trigger, 'mouseleave', onMouseLeave));
|
|
165
|
+
return mergeCleanups(addEventListener(trigger, 'mouseenter', onMouseEnter), addEventListener(trigger, 'mouseleave', onMouseLeave));
|
|
166
|
+
}, [
|
|
167
|
+
cleanupMouseMoveHandler,
|
|
168
|
+
clearPointerEvents,
|
|
169
|
+
dataRef,
|
|
170
|
+
delayRef,
|
|
171
|
+
store,
|
|
172
|
+
enabled,
|
|
173
|
+
handleCloseRef,
|
|
174
|
+
instance,
|
|
175
|
+
isActiveTrigger,
|
|
176
|
+
isOverInactiveTrigger,
|
|
177
|
+
isClickLikeOpenEvent,
|
|
178
|
+
mouseOnly,
|
|
179
|
+
move,
|
|
180
|
+
restMsRef,
|
|
181
|
+
triggerElementRef,
|
|
182
|
+
tree,
|
|
183
|
+
enabledRef,
|
|
184
|
+
getHandleCloseContext,
|
|
185
|
+
isClosingRef,
|
|
186
|
+
checkShouldOpen
|
|
187
|
+
]);
|
|
188
|
+
return __rspack_external_react.useMemo(()=>{
|
|
189
|
+
if (!enabled) return;
|
|
190
|
+
function setPointerRef(event) {
|
|
191
|
+
instance.pointerType = event.pointerType;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
onPointerDown: setPointerRef,
|
|
195
|
+
onPointerEnter: setPointerRef,
|
|
196
|
+
onMouseMove (event) {
|
|
197
|
+
const { nativeEvent } = event;
|
|
198
|
+
const trigger = event.currentTarget;
|
|
199
|
+
const currentDomReference = store.select('domReferenceElement');
|
|
200
|
+
const currentOpen = store.select('open');
|
|
201
|
+
const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
|
|
202
|
+
if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) return;
|
|
203
|
+
if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
|
|
204
|
+
const floatingElement = store.select('floatingElement');
|
|
205
|
+
if (floatingElement) {
|
|
206
|
+
const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
|
|
207
|
+
applySafePolygonPointerEventsMutation(instance, {
|
|
208
|
+
scopeElement,
|
|
209
|
+
referenceElement: trigger,
|
|
210
|
+
floatingElement
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const restMsValue = getRestMs(restMsRef.current);
|
|
215
|
+
if (currentOpen && !isOverInactive || 0 === restMsValue) return;
|
|
216
|
+
if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) return;
|
|
217
|
+
instance.restTimeout.clear();
|
|
218
|
+
function handleMouseMove() {
|
|
219
|
+
instance.restTimeoutPending = false;
|
|
220
|
+
if (isClickLikeOpenEvent()) return;
|
|
221
|
+
const latestOpen = store.select('open');
|
|
222
|
+
if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) store.setOpen(true, createChangeEventDetails(triggerHover, nativeEvent, trigger));
|
|
223
|
+
}
|
|
224
|
+
if ('touch' === instance.pointerType) __rspack_external_react_dom_7136dc57.flushSync(()=>{
|
|
225
|
+
handleMouseMove();
|
|
226
|
+
});
|
|
227
|
+
else if (isOverInactive && currentOpen) handleMouseMove();
|
|
228
|
+
else {
|
|
229
|
+
instance.restTimeoutPending = true;
|
|
230
|
+
instance.restTimeout.start(restMsValue, handleMouseMove);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}, [
|
|
235
|
+
enabled,
|
|
236
|
+
instance,
|
|
237
|
+
isClickLikeOpenEvent,
|
|
238
|
+
isOverInactiveTrigger,
|
|
239
|
+
mouseOnly,
|
|
240
|
+
store,
|
|
241
|
+
restMsRef,
|
|
242
|
+
checkShouldOpen
|
|
243
|
+
]);
|
|
244
|
+
}
|
|
245
|
+
const CURSOR_SPEED_THRESHOLD = 0.1;
|
|
246
|
+
const CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
|
|
247
|
+
const POLYGON_BUFFER = 0.5;
|
|
248
|
+
function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
|
|
249
|
+
return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
|
|
250
|
+
}
|
|
251
|
+
function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
252
|
+
let isInsideValue = false;
|
|
253
|
+
if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) isInsideValue = !isInsideValue;
|
|
254
|
+
if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) isInsideValue = !isInsideValue;
|
|
255
|
+
if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) isInsideValue = !isInsideValue;
|
|
256
|
+
if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) isInsideValue = !isInsideValue;
|
|
257
|
+
return isInsideValue;
|
|
258
|
+
}
|
|
259
|
+
function isInsideRect(pointX, pointY, rect) {
|
|
260
|
+
return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
|
|
261
|
+
}
|
|
262
|
+
function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
|
|
263
|
+
const minX = Math.min(x1, x2);
|
|
264
|
+
const maxX = Math.max(x1, x2);
|
|
265
|
+
const minY = Math.min(y1, y2);
|
|
266
|
+
const maxY = Math.max(y1, y2);
|
|
267
|
+
return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
|
|
268
|
+
}
|
|
269
|
+
function safePolygon(options = {}) {
|
|
270
|
+
const { blockPointerEvents = false } = options;
|
|
271
|
+
const timeout = new Timeout();
|
|
272
|
+
const fn = ({ x, y, placement, elements, onClose, nodeId, tree })=>{
|
|
273
|
+
const side = placement?.split('-')[0];
|
|
274
|
+
let hasLanded = false;
|
|
275
|
+
let lastX = null;
|
|
276
|
+
let lastY = null;
|
|
277
|
+
let lastCursorTime = "u" > typeof performance ? performance.now() : 0;
|
|
278
|
+
function isCursorMovingSlowly(nextX, nextY) {
|
|
279
|
+
const currentTime = performance.now();
|
|
280
|
+
const elapsedTime = currentTime - lastCursorTime;
|
|
281
|
+
if (null === lastX || null === lastY || 0 === elapsedTime) {
|
|
282
|
+
lastX = nextX;
|
|
283
|
+
lastY = nextY;
|
|
284
|
+
lastCursorTime = currentTime;
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
const deltaX = nextX - lastX;
|
|
288
|
+
const deltaY = nextY - lastY;
|
|
289
|
+
const distanceSquared = deltaX * deltaX + deltaY * deltaY;
|
|
290
|
+
const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
|
|
291
|
+
lastX = nextX;
|
|
292
|
+
lastY = nextY;
|
|
293
|
+
lastCursorTime = currentTime;
|
|
294
|
+
return distanceSquared < thresholdSquared;
|
|
295
|
+
}
|
|
296
|
+
function close() {
|
|
297
|
+
timeout.clear();
|
|
298
|
+
onClose();
|
|
299
|
+
}
|
|
300
|
+
return function(event) {
|
|
301
|
+
timeout.clear();
|
|
302
|
+
const domReference = elements.domReference;
|
|
303
|
+
const floating = elements.floating;
|
|
304
|
+
if (!domReference || !floating || null == side || null == x || null == y) return;
|
|
305
|
+
const { clientX, clientY } = event;
|
|
306
|
+
const target = getTarget(event);
|
|
307
|
+
const isLeave = 'mouseleave' === event.type;
|
|
308
|
+
const isOverFloatingEl = contains(floating, target);
|
|
309
|
+
const isOverReferenceEl = contains(domReference, target);
|
|
310
|
+
if (isOverFloatingEl) {
|
|
311
|
+
hasLanded = true;
|
|
312
|
+
if (!isLeave) return;
|
|
313
|
+
}
|
|
314
|
+
if (isOverReferenceEl) {
|
|
315
|
+
hasLanded = false;
|
|
316
|
+
if (!isLeave) {
|
|
317
|
+
hasLanded = true;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) return;
|
|
322
|
+
function hasOpenChildNode() {
|
|
323
|
+
return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
|
|
324
|
+
}
|
|
325
|
+
function closeIfNoOpenChild() {
|
|
326
|
+
if (!hasOpenChildNode()) close();
|
|
327
|
+
}
|
|
328
|
+
if (hasOpenChildNode()) return;
|
|
329
|
+
const refRect = domReference.getBoundingClientRect();
|
|
330
|
+
const rect = floating.getBoundingClientRect();
|
|
331
|
+
const cursorLeaveFromRight = x > rect.right - rect.width / 2;
|
|
332
|
+
const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;
|
|
333
|
+
const isFloatingWider = rect.width > refRect.width;
|
|
334
|
+
const isFloatingTaller = rect.height > refRect.height;
|
|
335
|
+
const left = (isFloatingWider ? refRect : rect).left;
|
|
336
|
+
const right = (isFloatingWider ? refRect : rect).right;
|
|
337
|
+
const top = (isFloatingTaller ? refRect : rect).top;
|
|
338
|
+
const bottom = (isFloatingTaller ? refRect : rect).bottom;
|
|
339
|
+
if ('top' === side && y >= refRect.bottom - 1 || 'bottom' === side && y <= refRect.top + 1 || 'left' === side && x >= refRect.right - 1 || 'right' === side && x <= refRect.left + 1) return void closeIfNoOpenChild();
|
|
340
|
+
let isInsideTroughRect = false;
|
|
341
|
+
switch(side){
|
|
342
|
+
case 'top':
|
|
343
|
+
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
|
|
344
|
+
break;
|
|
345
|
+
case 'bottom':
|
|
346
|
+
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
|
|
347
|
+
break;
|
|
348
|
+
case 'left':
|
|
349
|
+
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
|
|
350
|
+
break;
|
|
351
|
+
case 'right':
|
|
352
|
+
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
|
|
353
|
+
break;
|
|
354
|
+
default:
|
|
355
|
+
}
|
|
356
|
+
if (isInsideTroughRect) return;
|
|
357
|
+
if (hasLanded && !isInsideRect(clientX, clientY, refRect)) return void closeIfNoOpenChild();
|
|
358
|
+
if (!isLeave && isCursorMovingSlowly(clientX, clientY)) return void closeIfNoOpenChild();
|
|
359
|
+
let isInsidePolygon = false;
|
|
360
|
+
switch(side){
|
|
361
|
+
case 'top':
|
|
362
|
+
{
|
|
363
|
+
const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : 4 * POLYGON_BUFFER;
|
|
364
|
+
const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
365
|
+
const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
366
|
+
const cursorPointY = y + POLYGON_BUFFER + 1;
|
|
367
|
+
const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
|
|
368
|
+
const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
|
|
369
|
+
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
case 'bottom':
|
|
373
|
+
{
|
|
374
|
+
const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : 4 * POLYGON_BUFFER;
|
|
375
|
+
const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
376
|
+
const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
377
|
+
const cursorPointY = y - POLYGON_BUFFER;
|
|
378
|
+
const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
|
|
379
|
+
const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
|
|
380
|
+
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
case 'left':
|
|
384
|
+
{
|
|
385
|
+
const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : 4 * POLYGON_BUFFER;
|
|
386
|
+
const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
387
|
+
const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
388
|
+
const cursorPointX = x + POLYGON_BUFFER + 1;
|
|
389
|
+
const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
|
|
390
|
+
const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
|
|
391
|
+
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
case 'right':
|
|
395
|
+
{
|
|
396
|
+
const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : 4 * POLYGON_BUFFER;
|
|
397
|
+
const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
398
|
+
const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
399
|
+
const cursorPointX = x - POLYGON_BUFFER;
|
|
400
|
+
const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
|
|
401
|
+
const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
|
|
402
|
+
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
default:
|
|
406
|
+
}
|
|
407
|
+
if (isInsidePolygon) {
|
|
408
|
+
if (!hasLanded) timeout.start(40, closeIfNoOpenChild);
|
|
409
|
+
} else closeIfNoOpenChild();
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
fn.__options = {
|
|
413
|
+
...options,
|
|
414
|
+
blockPointerEvents
|
|
415
|
+
};
|
|
416
|
+
return fn;
|
|
417
|
+
}
|
|
418
|
+
export { safePolygon, useHoverReferenceInteraction };
|
package/dist/3829.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function hasWindow() {
|
|
2
|
+
return "u" > typeof window;
|
|
3
|
+
}
|
|
4
|
+
function getNodeName(node) {
|
|
5
|
+
if (isNode(node)) return (node.nodeName || '').toLowerCase();
|
|
6
|
+
return '#document';
|
|
7
|
+
}
|
|
8
|
+
function getWindow(node) {
|
|
9
|
+
var _node$ownerDocument;
|
|
10
|
+
return (null == node || null == (_node$ownerDocument = node.ownerDocument) ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
11
|
+
}
|
|
12
|
+
function getDocumentElement(node) {
|
|
13
|
+
var _ref;
|
|
14
|
+
return null == (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) ? void 0 : _ref.documentElement;
|
|
15
|
+
}
|
|
16
|
+
function isNode(value) {
|
|
17
|
+
if (!hasWindow()) return false;
|
|
18
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
19
|
+
}
|
|
20
|
+
function isElement(value) {
|
|
21
|
+
if (!hasWindow()) return false;
|
|
22
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
23
|
+
}
|
|
24
|
+
function isHTMLElement(value) {
|
|
25
|
+
if (!hasWindow()) return false;
|
|
26
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
27
|
+
}
|
|
28
|
+
function isShadowRoot(value) {
|
|
29
|
+
if (!hasWindow() || "u" < typeof ShadowRoot) return false;
|
|
30
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
31
|
+
}
|
|
32
|
+
function isOverflowElement(element) {
|
|
33
|
+
const { overflow, overflowX, overflowY, display } = getComputedStyle(element);
|
|
34
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && 'inline' !== display && 'contents' !== display;
|
|
35
|
+
}
|
|
36
|
+
function isTableElement(element) {
|
|
37
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
38
|
+
}
|
|
39
|
+
function isTopLayer(element) {
|
|
40
|
+
try {
|
|
41
|
+
if (element.matches(':popover-open')) return true;
|
|
42
|
+
} catch (_e) {}
|
|
43
|
+
try {
|
|
44
|
+
return element.matches(':modal');
|
|
45
|
+
} catch (_e) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
50
|
+
const containRe = /paint|layout|strict|content/;
|
|
51
|
+
const isNotNone = (value)=>!!value && 'none' !== value;
|
|
52
|
+
let isWebKitValue;
|
|
53
|
+
function isContainingBlock(elementOrCss) {
|
|
54
|
+
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
55
|
+
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
|
|
56
|
+
}
|
|
57
|
+
function getContainingBlock(element) {
|
|
58
|
+
let currentNode = getParentNode(element);
|
|
59
|
+
while(isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)){
|
|
60
|
+
if (isContainingBlock(currentNode)) return currentNode;
|
|
61
|
+
if (isTopLayer(currentNode)) break;
|
|
62
|
+
currentNode = getParentNode(currentNode);
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function isWebKit() {
|
|
67
|
+
if (null == isWebKitValue) isWebKitValue = "u" > typeof CSS && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
|
|
68
|
+
return isWebKitValue;
|
|
69
|
+
}
|
|
70
|
+
function isLastTraversableNode(node) {
|
|
71
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
72
|
+
}
|
|
73
|
+
function getComputedStyle(element) {
|
|
74
|
+
return getWindow(element).getComputedStyle(element);
|
|
75
|
+
}
|
|
76
|
+
function getNodeScroll(element) {
|
|
77
|
+
if (isElement(element)) return {
|
|
78
|
+
scrollLeft: element.scrollLeft,
|
|
79
|
+
scrollTop: element.scrollTop
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
scrollLeft: element.scrollX,
|
|
83
|
+
scrollTop: element.scrollY
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function getParentNode(node) {
|
|
87
|
+
if ('html' === getNodeName(node)) return node;
|
|
88
|
+
const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
|
|
89
|
+
return isShadowRoot(result) ? result.host : result;
|
|
90
|
+
}
|
|
91
|
+
function getNearestOverflowAncestor(node) {
|
|
92
|
+
const parentNode = getParentNode(node);
|
|
93
|
+
if (isLastTraversableNode(parentNode)) return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
94
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
|
|
95
|
+
return getNearestOverflowAncestor(parentNode);
|
|
96
|
+
}
|
|
97
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
98
|
+
var _node$ownerDocument2;
|
|
99
|
+
if (void 0 === list) list = [];
|
|
100
|
+
if (void 0 === traverseIframes) traverseIframes = true;
|
|
101
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
102
|
+
const isBody = scrollableAncestor === (null == (_node$ownerDocument2 = node.ownerDocument) ? void 0 : _node$ownerDocument2.body);
|
|
103
|
+
const win = getWindow(scrollableAncestor);
|
|
104
|
+
if (!isBody) return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
105
|
+
{
|
|
106
|
+
const frameElement = getFrameElement(win);
|
|
107
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function getFrameElement(win) {
|
|
111
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
112
|
+
}
|
|
113
|
+
export { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };
|
package/dist/4026.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
let set;
|
|
2
|
+
if ('production' !== process.env.NODE_ENV) set = new Set();
|
|
3
|
+
function error(...messages) {
|
|
4
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
5
|
+
const messageKey = messages.join(' ');
|
|
6
|
+
if (!set.has(messageKey)) {
|
|
7
|
+
set.add(messageKey);
|
|
8
|
+
console.error(`Base UI: ${messageKey}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export { error };
|
package/dist/4143.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useLabelableContext } from "./1477.js";
|
|
2
|
+
import { useStableCallback } from "./7541.js";
|
|
3
|
+
import { useRegisteredLabelId } from "./6706.js";
|
|
4
|
+
import { ownerDocument } from "./9829.js";
|
|
5
|
+
import { isHTMLElement } from "./3829.js";
|
|
6
|
+
import { getTarget } from "./4549.js";
|
|
7
|
+
function useLabel(params = {}) {
|
|
8
|
+
const { id: idProp, fallbackControlId, native = false, setLabelId: setLabelIdProp, focusControl: focusControlProp } = params;
|
|
9
|
+
const { controlId: contextControlId, setLabelId: setContextLabelId } = useLabelableContext();
|
|
10
|
+
const syncLabelId = useStableCallback((nextLabelId)=>{
|
|
11
|
+
setContextLabelId(nextLabelId);
|
|
12
|
+
setLabelIdProp?.(nextLabelId);
|
|
13
|
+
});
|
|
14
|
+
const id = useRegisteredLabelId(idProp, syncLabelId);
|
|
15
|
+
const resolvedControlId = contextControlId ?? fallbackControlId;
|
|
16
|
+
function focusControl(event) {
|
|
17
|
+
if (focusControlProp) return void focusControlProp(event, resolvedControlId);
|
|
18
|
+
if (!resolvedControlId) return;
|
|
19
|
+
const controlElement = ownerDocument(event.currentTarget).getElementById(resolvedControlId);
|
|
20
|
+
if (isHTMLElement(controlElement)) focusElementWithVisible(controlElement);
|
|
21
|
+
}
|
|
22
|
+
function handleInteraction(event) {
|
|
23
|
+
const target = getTarget(event.nativeEvent);
|
|
24
|
+
if (target?.closest('button,input,select,textarea')) return;
|
|
25
|
+
if (!event.defaultPrevented && event.detail > 1) event.preventDefault();
|
|
26
|
+
if (native) return;
|
|
27
|
+
focusControl(event);
|
|
28
|
+
}
|
|
29
|
+
return native ? {
|
|
30
|
+
id,
|
|
31
|
+
htmlFor: resolvedControlId ?? void 0,
|
|
32
|
+
onMouseDown: handleInteraction
|
|
33
|
+
} : {
|
|
34
|
+
id,
|
|
35
|
+
onClick: handleInteraction,
|
|
36
|
+
onPointerDown (event) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function focusElementWithVisible(element) {
|
|
42
|
+
element.focus({
|
|
43
|
+
focusVisible: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export { focusElementWithVisible, useLabel };
|
package/dist/42.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useRefWithInit } from "./8272.js";
|
|
2
|
+
import { useOnMount } from "./2861.js";
|
|
3
|
+
const EMPTY = 0;
|
|
4
|
+
class Timeout {
|
|
5
|
+
static create() {
|
|
6
|
+
return new Timeout();
|
|
7
|
+
}
|
|
8
|
+
currentId = EMPTY;
|
|
9
|
+
start(delay, fn) {
|
|
10
|
+
this.clear();
|
|
11
|
+
this.currentId = setTimeout(()=>{
|
|
12
|
+
this.currentId = EMPTY;
|
|
13
|
+
fn();
|
|
14
|
+
}, delay);
|
|
15
|
+
}
|
|
16
|
+
isStarted() {
|
|
17
|
+
return this.currentId !== EMPTY;
|
|
18
|
+
}
|
|
19
|
+
clear = ()=>{
|
|
20
|
+
if (this.currentId !== EMPTY) {
|
|
21
|
+
clearTimeout(this.currentId);
|
|
22
|
+
this.currentId = EMPTY;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
disposeEffect = ()=>this.clear;
|
|
26
|
+
}
|
|
27
|
+
function useTimeout() {
|
|
28
|
+
const timeout = useRefWithInit(Timeout.create).current;
|
|
29
|
+
useOnMount(timeout.disposeEffect);
|
|
30
|
+
return timeout;
|
|
31
|
+
}
|
|
32
|
+
export { Timeout, useTimeout };
|
package/dist/4281.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useFieldRootContext } from "./1477.js";
|
|
2
|
+
import { useIsoLayoutEffect } from "./6499.js";
|
|
3
|
+
import * as __rspack_external_react from "react";
|
|
4
|
+
function useRegisterFieldControl(controlRef, id, value, getFormValueOverride, enabled = true) {
|
|
5
|
+
const { registerFieldControl } = useFieldRootContext();
|
|
6
|
+
const sourceRef = __rspack_external_react.useRef(null);
|
|
7
|
+
if (!sourceRef.current) sourceRef.current = Symbol();
|
|
8
|
+
useIsoLayoutEffect(()=>{
|
|
9
|
+
const source = sourceRef.current;
|
|
10
|
+
if (!source || !enabled) return;
|
|
11
|
+
const registration = {
|
|
12
|
+
controlRef,
|
|
13
|
+
getValue: getFormValueOverride,
|
|
14
|
+
id,
|
|
15
|
+
value
|
|
16
|
+
};
|
|
17
|
+
registerFieldControl(source, registration);
|
|
18
|
+
return ()=>{
|
|
19
|
+
registerFieldControl(source, void 0);
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
controlRef,
|
|
23
|
+
enabled,
|
|
24
|
+
getFormValueOverride,
|
|
25
|
+
id,
|
|
26
|
+
registerFieldControl,
|
|
27
|
+
value
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
export { useRegisterFieldControl };
|