@wix/site-ui 1.29.0 → 1.31.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/Badge/index.css +44 -0
- package/dist/Badge/index.d.ts +22 -0
- package/dist/Badge/index.js +23 -0
- 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 +12758 -646
- package/dist/index.js +1 -0
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/8106.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { FloatingRootStore } from "./5992.js";
|
|
2
|
+
import { useIsoLayoutEffect } from "./6499.js";
|
|
3
|
+
import { isElement } from "./3829.js";
|
|
4
|
+
import { FOCUSABLE_ATTRIBUTE } from "./4745.js";
|
|
5
|
+
import { useId } from "./6046.js";
|
|
6
|
+
import { useFloatingParentNodeId } from "./285.js";
|
|
7
|
+
import { useStableCallback } from "./7541.js";
|
|
8
|
+
import { useOpenChangeComplete, useTransitionStatus } from "./880.js";
|
|
9
|
+
import { EMPTY_OBJECT } from "./8272.js";
|
|
10
|
+
import * as __rspack_external_react from "react";
|
|
11
|
+
function useSyncedFloatingRootContext(options) {
|
|
12
|
+
const { popupStore, treatPopupAsFloatingElement = false, floatingRootContext: floatingRootContextProp, floatingId, nested, onOpenChange } = options;
|
|
13
|
+
const open = popupStore.useState('open');
|
|
14
|
+
const referenceElement = popupStore.useState('activeTriggerElement');
|
|
15
|
+
const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? 'popupElement' : 'positionerElement');
|
|
16
|
+
const triggerElements = popupStore.context.triggerElements;
|
|
17
|
+
const handleOpenChange = onOpenChange;
|
|
18
|
+
const internalStoreRef = __rspack_external_react.useRef(null);
|
|
19
|
+
if (void 0 === floatingRootContextProp && null === internalStoreRef.current) internalStoreRef.current = new FloatingRootStore({
|
|
20
|
+
open,
|
|
21
|
+
transitionStatus: void 0,
|
|
22
|
+
referenceElement,
|
|
23
|
+
floatingElement,
|
|
24
|
+
triggerElements,
|
|
25
|
+
onOpenChange: handleOpenChange,
|
|
26
|
+
floatingId,
|
|
27
|
+
syncOnly: true,
|
|
28
|
+
nested
|
|
29
|
+
});
|
|
30
|
+
const store = floatingRootContextProp ?? internalStoreRef.current;
|
|
31
|
+
popupStore.useSyncedValue('floatingId', floatingId);
|
|
32
|
+
useIsoLayoutEffect(()=>{
|
|
33
|
+
const valuesToSync = {
|
|
34
|
+
open,
|
|
35
|
+
floatingId,
|
|
36
|
+
referenceElement,
|
|
37
|
+
floatingElement
|
|
38
|
+
};
|
|
39
|
+
if (isElement(referenceElement)) valuesToSync.domReferenceElement = referenceElement;
|
|
40
|
+
if (store.state.positionReference === store.state.referenceElement) valuesToSync.positionReference = referenceElement;
|
|
41
|
+
store.update(valuesToSync);
|
|
42
|
+
}, [
|
|
43
|
+
open,
|
|
44
|
+
floatingId,
|
|
45
|
+
referenceElement,
|
|
46
|
+
floatingElement,
|
|
47
|
+
store
|
|
48
|
+
]);
|
|
49
|
+
store.context.onOpenChange = handleOpenChange;
|
|
50
|
+
store.context.nested = nested;
|
|
51
|
+
return store;
|
|
52
|
+
}
|
|
53
|
+
const FOCUSABLE_POPUP_PROPS = {
|
|
54
|
+
tabIndex: -1,
|
|
55
|
+
[FOCUSABLE_ATTRIBUTE]: ''
|
|
56
|
+
};
|
|
57
|
+
function usePopupStore(externalStore, createStore, treatPopupAsFloatingElement = false) {
|
|
58
|
+
const floatingId = useId();
|
|
59
|
+
const nested = null != useFloatingParentNodeId();
|
|
60
|
+
const internalStoreRef = __rspack_external_react.useRef(null);
|
|
61
|
+
if (void 0 === externalStore && null === internalStoreRef.current) internalStoreRef.current = createStore(floatingId, nested);
|
|
62
|
+
const store = externalStore ?? internalStoreRef.current;
|
|
63
|
+
useSyncedFloatingRootContext({
|
|
64
|
+
popupStore: store,
|
|
65
|
+
treatPopupAsFloatingElement,
|
|
66
|
+
floatingRootContext: store.state.floatingRootContext,
|
|
67
|
+
floatingId,
|
|
68
|
+
nested,
|
|
69
|
+
onOpenChange: store.setOpen
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
store,
|
|
73
|
+
internalStore: internalStoreRef.current
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function useTriggerRegistration(id, store) {
|
|
77
|
+
const registeredElementIdRef = __rspack_external_react.useRef(null);
|
|
78
|
+
const registeredElementRef = __rspack_external_react.useRef(null);
|
|
79
|
+
return __rspack_external_react.useCallback((element)=>{
|
|
80
|
+
if (void 0 === id) return;
|
|
81
|
+
let shouldSyncTriggerCount = false;
|
|
82
|
+
if (null !== registeredElementIdRef.current) {
|
|
83
|
+
const registeredId = registeredElementIdRef.current;
|
|
84
|
+
const registeredElement = registeredElementRef.current;
|
|
85
|
+
const currentElement = store.context.triggerElements.getById(registeredId);
|
|
86
|
+
if (registeredElement && currentElement === registeredElement) {
|
|
87
|
+
store.context.triggerElements.delete(registeredId);
|
|
88
|
+
shouldSyncTriggerCount = true;
|
|
89
|
+
}
|
|
90
|
+
registeredElementIdRef.current = null;
|
|
91
|
+
registeredElementRef.current = null;
|
|
92
|
+
}
|
|
93
|
+
if (null !== element) {
|
|
94
|
+
registeredElementIdRef.current = id;
|
|
95
|
+
registeredElementRef.current = element;
|
|
96
|
+
store.context.triggerElements.add(id, element);
|
|
97
|
+
shouldSyncTriggerCount = true;
|
|
98
|
+
}
|
|
99
|
+
if (shouldSyncTriggerCount) {
|
|
100
|
+
const triggerCount = store.context.triggerElements.size;
|
|
101
|
+
if (store.select('open') && store.state.triggerCount !== triggerCount) store.set('triggerCount', triggerCount);
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
store,
|
|
105
|
+
id
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
function setOpenTriggerState(state, open, trigger) {
|
|
109
|
+
const triggerId = trigger?.id ?? null;
|
|
110
|
+
if (triggerId || open) {
|
|
111
|
+
state.activeTriggerId = triggerId;
|
|
112
|
+
state.activeTriggerElement = trigger ?? null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
|
|
116
|
+
const isMountedByThisTrigger = store.useState('isMountedByTrigger', triggerId);
|
|
117
|
+
const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
|
|
118
|
+
const registerTrigger = useStableCallback((element)=>{
|
|
119
|
+
baseRegisterTrigger(element);
|
|
120
|
+
if (!element) return;
|
|
121
|
+
const open = store.select('open');
|
|
122
|
+
const activeTriggerId = store.select('activeTriggerId');
|
|
123
|
+
if (activeTriggerId === triggerId) return void store.update({
|
|
124
|
+
activeTriggerElement: element,
|
|
125
|
+
...open ? stateUpdates : null
|
|
126
|
+
});
|
|
127
|
+
if (null == activeTriggerId && open) store.update({
|
|
128
|
+
activeTriggerId: triggerId,
|
|
129
|
+
activeTriggerElement: element,
|
|
130
|
+
...stateUpdates
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
useIsoLayoutEffect(()=>{
|
|
134
|
+
if (isMountedByThisTrigger) store.update({
|
|
135
|
+
activeTriggerElement: triggerElementRef.current,
|
|
136
|
+
...stateUpdates
|
|
137
|
+
});
|
|
138
|
+
}, [
|
|
139
|
+
isMountedByThisTrigger,
|
|
140
|
+
store,
|
|
141
|
+
triggerElementRef,
|
|
142
|
+
...Object.values(stateUpdates)
|
|
143
|
+
]);
|
|
144
|
+
return {
|
|
145
|
+
registerTrigger,
|
|
146
|
+
isMountedByThisTrigger
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function useImplicitActiveTrigger(store) {
|
|
150
|
+
const open = store.useState('open');
|
|
151
|
+
const reactiveTriggerCount = store.useState('triggerCount');
|
|
152
|
+
useIsoLayoutEffect(()=>{
|
|
153
|
+
if (!open) {
|
|
154
|
+
if (0 !== store.state.triggerCount) store.set('triggerCount', 0);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const triggerCount = store.context.triggerElements.size;
|
|
158
|
+
const stateUpdates = {};
|
|
159
|
+
if (store.state.triggerCount !== triggerCount) stateUpdates.triggerCount = triggerCount;
|
|
160
|
+
if (!store.select('activeTriggerId') && 1 === triggerCount) {
|
|
161
|
+
const iteratorResult = store.context.triggerElements.entries().next();
|
|
162
|
+
if (!iteratorResult.done) {
|
|
163
|
+
const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
|
|
164
|
+
stateUpdates.activeTriggerId = implicitTriggerId;
|
|
165
|
+
stateUpdates.activeTriggerElement = implicitTriggerElement;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (void 0 !== stateUpdates.triggerCount || void 0 !== stateUpdates.activeTriggerId) store.update(stateUpdates);
|
|
169
|
+
}, [
|
|
170
|
+
open,
|
|
171
|
+
store,
|
|
172
|
+
reactiveTriggerCount
|
|
173
|
+
]);
|
|
174
|
+
}
|
|
175
|
+
function useOpenStateTransitions(open, store, onUnmount) {
|
|
176
|
+
const { mounted, setMounted, transitionStatus } = useTransitionStatus(open);
|
|
177
|
+
store.useSyncedValues({
|
|
178
|
+
mounted,
|
|
179
|
+
transitionStatus
|
|
180
|
+
});
|
|
181
|
+
const forceUnmount = useStableCallback(()=>{
|
|
182
|
+
setMounted(false);
|
|
183
|
+
store.update({
|
|
184
|
+
activeTriggerId: null,
|
|
185
|
+
activeTriggerElement: null,
|
|
186
|
+
mounted: false,
|
|
187
|
+
preventUnmountingOnClose: false
|
|
188
|
+
});
|
|
189
|
+
onUnmount?.();
|
|
190
|
+
store.context.onOpenChangeComplete?.(false);
|
|
191
|
+
});
|
|
192
|
+
const preventUnmountingOnClose = store.useState('preventUnmountingOnClose');
|
|
193
|
+
useOpenChangeComplete({
|
|
194
|
+
enabled: mounted && !open && !preventUnmountingOnClose,
|
|
195
|
+
open,
|
|
196
|
+
ref: store.context.popupRef,
|
|
197
|
+
onComplete () {
|
|
198
|
+
if (!open) forceUnmount();
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
forceUnmount,
|
|
203
|
+
transitionStatus
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function usePopupInteractionProps(store, statePart) {
|
|
207
|
+
store.useSyncedValues(statePart);
|
|
208
|
+
useIsoLayoutEffect(()=>()=>{
|
|
209
|
+
store.update({
|
|
210
|
+
activeTriggerProps: EMPTY_OBJECT,
|
|
211
|
+
inactiveTriggerProps: EMPTY_OBJECT,
|
|
212
|
+
popupProps: EMPTY_OBJECT
|
|
213
|
+
});
|
|
214
|
+
}, [
|
|
215
|
+
store
|
|
216
|
+
]);
|
|
217
|
+
}
|
|
218
|
+
function usePopupRootSync(store, open) {
|
|
219
|
+
useIsoLayoutEffect(()=>{
|
|
220
|
+
if (!open && null !== store.state.openMethod) store.set('openMethod', null);
|
|
221
|
+
}, [
|
|
222
|
+
open,
|
|
223
|
+
store
|
|
224
|
+
]);
|
|
225
|
+
useIsoLayoutEffect(()=>()=>{
|
|
226
|
+
if (null !== store.state.openMethod) store.set('openMethod', null);
|
|
227
|
+
}, [
|
|
228
|
+
store
|
|
229
|
+
]);
|
|
230
|
+
}
|
|
231
|
+
function useOnFirstRender(fn) {
|
|
232
|
+
const ref = __rspack_external_react.useRef(true);
|
|
233
|
+
if (ref.current) {
|
|
234
|
+
ref.current = false;
|
|
235
|
+
fn();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
export { FOCUSABLE_POPUP_PROPS, setOpenTriggerState, useImplicitActiveTrigger, useOnFirstRender, useOpenStateTransitions, usePopupInteractionProps, usePopupRootSync, usePopupStore, useSyncedFloatingRootContext, useTriggerDataForwarding, useTriggerRegistration };
|
package/dist/8171.js
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAnimationsFinished } from "./880.js";
|
|
3
|
+
import { useAnimationFrame } from "./8996.js";
|
|
4
|
+
import { NOOP, EMPTY_OBJECT } from "./8272.js";
|
|
5
|
+
import { useStableCallback } from "./7541.js";
|
|
6
|
+
import { useIsoLayoutEffect } from "./6499.js";
|
|
7
|
+
import { getCssDimensions } from "./7642.js";
|
|
8
|
+
import { useDirection } from "./9863.js";
|
|
9
|
+
import { usePreviousValue } from "./7021.js";
|
|
10
|
+
import { ownerDocument } from "./9829.js";
|
|
11
|
+
import { inertValue } from "./167.js";
|
|
12
|
+
import * as __rspack_external_react from "react";
|
|
13
|
+
import * as __rspack_external_react_dom_7136dc57 from "react-dom";
|
|
14
|
+
const DEFAULT_ENABLED = ()=>true;
|
|
15
|
+
function usePopupAutoResize(parameters) {
|
|
16
|
+
const { popupElement, positionerElement, content, mounted, enabled = DEFAULT_ENABLED, onMeasureLayout: onMeasureLayoutParam, onMeasureLayoutComplete: onMeasureLayoutCompleteParam, side, direction } = parameters;
|
|
17
|
+
const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
|
|
18
|
+
const animationFrame = useAnimationFrame();
|
|
19
|
+
const committedDimensionsRef = __rspack_external_react.useRef(null);
|
|
20
|
+
const liveDimensionsRef = __rspack_external_react.useRef(null);
|
|
21
|
+
const isInitialRenderRef = __rspack_external_react.useRef(true);
|
|
22
|
+
const restoreAnchoringStylesRef = __rspack_external_react.useRef(NOOP);
|
|
23
|
+
const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
|
|
24
|
+
const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
|
|
25
|
+
const anchoringStyles = __rspack_external_react.useMemo(()=>{
|
|
26
|
+
let isOriginSide = 'top' === side;
|
|
27
|
+
let isPhysicalLeft = 'left' === side;
|
|
28
|
+
if ('rtl' === direction) {
|
|
29
|
+
isOriginSide = isOriginSide || 'inline-end' === side;
|
|
30
|
+
isPhysicalLeft = isPhysicalLeft || 'inline-end' === side;
|
|
31
|
+
} else {
|
|
32
|
+
isOriginSide = isOriginSide || 'inline-start' === side;
|
|
33
|
+
isPhysicalLeft = isPhysicalLeft || 'inline-start' === side;
|
|
34
|
+
}
|
|
35
|
+
return isOriginSide ? {
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
['top' === side ? 'bottom' : 'top']: '0',
|
|
38
|
+
[isPhysicalLeft ? 'right' : 'left']: '0'
|
|
39
|
+
} : EMPTY_OBJECT;
|
|
40
|
+
}, [
|
|
41
|
+
side,
|
|
42
|
+
direction
|
|
43
|
+
]);
|
|
44
|
+
useIsoLayoutEffect(()=>{
|
|
45
|
+
if (!mounted || !enabled() || 'function' != typeof ResizeObserver) {
|
|
46
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
47
|
+
isInitialRenderRef.current = true;
|
|
48
|
+
committedDimensionsRef.current = null;
|
|
49
|
+
liveDimensionsRef.current = null;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!popupElement || !positionerElement) return;
|
|
53
|
+
restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
|
|
54
|
+
const observer = new ResizeObserver((entries)=>{
|
|
55
|
+
const entry = entries[0];
|
|
56
|
+
if (entry) liveDimensionsRef.current = {
|
|
57
|
+
width: Math.ceil(entry.borderBoxSize[0].inlineSize),
|
|
58
|
+
height: Math.ceil(entry.borderBoxSize[0].blockSize)
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
observer.observe(popupElement);
|
|
62
|
+
setPopupCssSize(popupElement, 'auto');
|
|
63
|
+
const restorePopupPosition = overrideElementStyle(popupElement, 'position', 'static');
|
|
64
|
+
const restorePopupTransform = overrideElementStyle(popupElement, 'transform', 'none');
|
|
65
|
+
const restorePopupScale = overrideElementStyle(popupElement, 'scale', '1');
|
|
66
|
+
const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
|
|
67
|
+
'--available-width': 'max-content',
|
|
68
|
+
'--available-height': 'max-content'
|
|
69
|
+
});
|
|
70
|
+
function restoreMeasurementOverrides() {
|
|
71
|
+
restorePopupPosition();
|
|
72
|
+
restorePopupTransform();
|
|
73
|
+
restorePositionerAvailableSize();
|
|
74
|
+
}
|
|
75
|
+
function restoreMeasurementOverridesIncludingScale() {
|
|
76
|
+
restoreMeasurementOverrides();
|
|
77
|
+
restorePopupScale();
|
|
78
|
+
}
|
|
79
|
+
onMeasureLayout?.();
|
|
80
|
+
if (isInitialRenderRef.current || null === committedDimensionsRef.current) {
|
|
81
|
+
setPositionerCssSize(positionerElement, 'max-content');
|
|
82
|
+
const dimensions = getCssDimensions(popupElement);
|
|
83
|
+
committedDimensionsRef.current = dimensions;
|
|
84
|
+
setPositionerCssSize(positionerElement, dimensions);
|
|
85
|
+
restoreMeasurementOverridesIncludingScale();
|
|
86
|
+
onMeasureLayoutComplete?.(null, dimensions);
|
|
87
|
+
isInitialRenderRef.current = false;
|
|
88
|
+
return ()=>{
|
|
89
|
+
observer.disconnect();
|
|
90
|
+
restoreAnchoringStylesRef.current();
|
|
91
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
setPopupCssSize(popupElement, 'auto');
|
|
95
|
+
setPositionerCssSize(positionerElement, 'max-content');
|
|
96
|
+
const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
|
|
97
|
+
const newDimensions = getCssDimensions(popupElement);
|
|
98
|
+
committedDimensionsRef.current = newDimensions;
|
|
99
|
+
if (!previousDimensions) {
|
|
100
|
+
setPositionerCssSize(positionerElement, newDimensions);
|
|
101
|
+
restoreMeasurementOverridesIncludingScale();
|
|
102
|
+
onMeasureLayoutComplete?.(null, newDimensions);
|
|
103
|
+
return ()=>{
|
|
104
|
+
observer.disconnect();
|
|
105
|
+
animationFrame.cancel();
|
|
106
|
+
restoreAnchoringStylesRef.current();
|
|
107
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
setPopupCssSize(popupElement, previousDimensions);
|
|
111
|
+
restoreMeasurementOverridesIncludingScale();
|
|
112
|
+
onMeasureLayoutComplete?.(previousDimensions, newDimensions);
|
|
113
|
+
setPositionerCssSize(positionerElement, newDimensions);
|
|
114
|
+
const abortController = new AbortController();
|
|
115
|
+
animationFrame.request(()=>{
|
|
116
|
+
setPopupCssSize(popupElement, newDimensions);
|
|
117
|
+
runOnceAnimationsFinish(()=>{
|
|
118
|
+
popupElement.style.setProperty('--popup-width', 'auto');
|
|
119
|
+
popupElement.style.setProperty('--popup-height', 'auto');
|
|
120
|
+
}, abortController.signal);
|
|
121
|
+
});
|
|
122
|
+
return ()=>{
|
|
123
|
+
observer.disconnect();
|
|
124
|
+
abortController.abort();
|
|
125
|
+
animationFrame.cancel();
|
|
126
|
+
restoreAnchoringStylesRef.current();
|
|
127
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
128
|
+
};
|
|
129
|
+
}, [
|
|
130
|
+
content,
|
|
131
|
+
popupElement,
|
|
132
|
+
positionerElement,
|
|
133
|
+
runOnceAnimationsFinish,
|
|
134
|
+
animationFrame,
|
|
135
|
+
enabled,
|
|
136
|
+
mounted,
|
|
137
|
+
onMeasureLayout,
|
|
138
|
+
onMeasureLayoutComplete,
|
|
139
|
+
anchoringStyles
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
function overrideElementStyle(element, property, value) {
|
|
143
|
+
const originalValue = element.style.getPropertyValue(property);
|
|
144
|
+
element.style.setProperty(property, value);
|
|
145
|
+
return ()=>{
|
|
146
|
+
element.style.setProperty(property, originalValue);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function applyElementStyles(element, styles) {
|
|
150
|
+
const restorers = [];
|
|
151
|
+
for (const [key, value] of Object.entries(styles))restorers.push(overrideElementStyle(element, key, value));
|
|
152
|
+
return restorers.length ? ()=>{
|
|
153
|
+
restorers.forEach((restore)=>restore());
|
|
154
|
+
} : NOOP;
|
|
155
|
+
}
|
|
156
|
+
function setPopupCssSize(popupElement, size) {
|
|
157
|
+
const width = 'auto' === size ? 'auto' : `${size.width}px`;
|
|
158
|
+
const height = 'auto' === size ? 'auto' : `${size.height}px`;
|
|
159
|
+
popupElement.style.setProperty('--popup-width', width);
|
|
160
|
+
popupElement.style.setProperty('--popup-height', height);
|
|
161
|
+
}
|
|
162
|
+
function setPositionerCssSize(positionerElement, size) {
|
|
163
|
+
const width = 'max-content' === size ? 'max-content' : `${size.width}px`;
|
|
164
|
+
const height = 'max-content' === size ? 'max-content' : `${size.height}px`;
|
|
165
|
+
positionerElement.style.setProperty('--positioner-width', width);
|
|
166
|
+
positionerElement.style.setProperty('--positioner-height', height);
|
|
167
|
+
}
|
|
168
|
+
function usePopupViewport(parameters) {
|
|
169
|
+
const { store, side, cssVars, children } = parameters;
|
|
170
|
+
const direction = useDirection();
|
|
171
|
+
const activeTrigger = store.useState('activeTriggerElement');
|
|
172
|
+
const activeTriggerId = store.useState('activeTriggerId');
|
|
173
|
+
const open = store.useState('open');
|
|
174
|
+
const payload = store.useState('payload');
|
|
175
|
+
const mounted = store.useState('mounted');
|
|
176
|
+
const popupElement = store.useState('popupElement');
|
|
177
|
+
const positionerElement = store.useState('positionerElement');
|
|
178
|
+
const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
|
|
179
|
+
const currentContentKey = usePopupContentKey(activeTriggerId, payload);
|
|
180
|
+
const capturedNodeRef = __rspack_external_react.useRef(null);
|
|
181
|
+
const [previousContentNode, setPreviousContentNode] = __rspack_external_react.useState(null);
|
|
182
|
+
const [newTriggerOffset, setNewTriggerOffset] = __rspack_external_react.useState(null);
|
|
183
|
+
const currentContainerRef = __rspack_external_react.useRef(null);
|
|
184
|
+
const previousContainerRef = __rspack_external_react.useRef(null);
|
|
185
|
+
const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
|
|
186
|
+
const cleanupFrame = useAnimationFrame();
|
|
187
|
+
const [previousContentDimensions, setPreviousContentDimensions] = __rspack_external_react.useState(null);
|
|
188
|
+
const [showStartingStyleAttribute, setShowStartingStyleAttribute] = __rspack_external_react.useState(false);
|
|
189
|
+
useIsoLayoutEffect(()=>{
|
|
190
|
+
store.set('hasViewport', true);
|
|
191
|
+
return ()=>{
|
|
192
|
+
store.set('hasViewport', false);
|
|
193
|
+
};
|
|
194
|
+
}, [
|
|
195
|
+
store
|
|
196
|
+
]);
|
|
197
|
+
const handleMeasureLayout = useStableCallback(()=>{
|
|
198
|
+
currentContainerRef.current?.style.setProperty('animation', 'none');
|
|
199
|
+
currentContainerRef.current?.style.setProperty('transition', 'none');
|
|
200
|
+
previousContainerRef.current?.style.setProperty('display', 'none');
|
|
201
|
+
});
|
|
202
|
+
const handleMeasureLayoutComplete = useStableCallback((previousDimensions)=>{
|
|
203
|
+
currentContainerRef.current?.style.removeProperty('animation');
|
|
204
|
+
currentContainerRef.current?.style.removeProperty('transition');
|
|
205
|
+
previousContainerRef.current?.style.removeProperty('display');
|
|
206
|
+
if (previousDimensions) setPreviousContentDimensions(previousDimensions);
|
|
207
|
+
});
|
|
208
|
+
const lastHandledTriggerRef = __rspack_external_react.useRef(null);
|
|
209
|
+
useIsoLayoutEffect(()=>{
|
|
210
|
+
if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
|
|
211
|
+
setPreviousContentNode(capturedNodeRef.current);
|
|
212
|
+
setShowStartingStyleAttribute(true);
|
|
213
|
+
const offset = calculateRelativePosition(previousActiveTrigger, activeTrigger);
|
|
214
|
+
setNewTriggerOffset(offset);
|
|
215
|
+
cleanupFrame.request(()=>{
|
|
216
|
+
__rspack_external_react_dom_7136dc57.flushSync(()=>{
|
|
217
|
+
setShowStartingStyleAttribute(false);
|
|
218
|
+
});
|
|
219
|
+
onAnimationsFinished(()=>{
|
|
220
|
+
setPreviousContentNode(null);
|
|
221
|
+
setPreviousContentDimensions(null);
|
|
222
|
+
capturedNodeRef.current = null;
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
lastHandledTriggerRef.current = activeTrigger;
|
|
226
|
+
}
|
|
227
|
+
}, [
|
|
228
|
+
activeTrigger,
|
|
229
|
+
previousActiveTrigger,
|
|
230
|
+
previousContentNode,
|
|
231
|
+
onAnimationsFinished,
|
|
232
|
+
cleanupFrame
|
|
233
|
+
]);
|
|
234
|
+
useIsoLayoutEffect(()=>{
|
|
235
|
+
const source = currentContainerRef.current;
|
|
236
|
+
if (!source) return;
|
|
237
|
+
const wrapper = ownerDocument(source).createElement('div');
|
|
238
|
+
for (const child of Array.from(source.childNodes))wrapper.appendChild(child.cloneNode(true));
|
|
239
|
+
capturedNodeRef.current = wrapper;
|
|
240
|
+
});
|
|
241
|
+
const isTransitioning = null != previousContentNode;
|
|
242
|
+
let childrenToRender;
|
|
243
|
+
childrenToRender = isTransitioning ? /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
244
|
+
children: [
|
|
245
|
+
/*#__PURE__*/ jsx("div", {
|
|
246
|
+
"data-previous": true,
|
|
247
|
+
inert: inertValue(true),
|
|
248
|
+
ref: previousContainerRef,
|
|
249
|
+
style: {
|
|
250
|
+
...previousContentDimensions ? {
|
|
251
|
+
[cssVars.popupWidth]: `${previousContentDimensions.width}px`,
|
|
252
|
+
[cssVars.popupHeight]: `${previousContentDimensions.height}px`
|
|
253
|
+
} : null,
|
|
254
|
+
position: 'absolute'
|
|
255
|
+
},
|
|
256
|
+
"data-ending-style": showStartingStyleAttribute ? void 0 : ''
|
|
257
|
+
}, "previous"),
|
|
258
|
+
/*#__PURE__*/ jsx("div", {
|
|
259
|
+
"data-current": true,
|
|
260
|
+
ref: currentContainerRef,
|
|
261
|
+
"data-starting-style": showStartingStyleAttribute ? '' : void 0,
|
|
262
|
+
children: children
|
|
263
|
+
}, currentContentKey)
|
|
264
|
+
]
|
|
265
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
266
|
+
"data-current": true,
|
|
267
|
+
ref: currentContainerRef,
|
|
268
|
+
children: children
|
|
269
|
+
}, currentContentKey);
|
|
270
|
+
useIsoLayoutEffect(()=>{
|
|
271
|
+
const container = previousContainerRef.current;
|
|
272
|
+
if (!container || !previousContentNode) return;
|
|
273
|
+
container.replaceChildren(...Array.from(previousContentNode.childNodes));
|
|
274
|
+
}, [
|
|
275
|
+
previousContentNode
|
|
276
|
+
]);
|
|
277
|
+
usePopupAutoResize({
|
|
278
|
+
popupElement,
|
|
279
|
+
positionerElement,
|
|
280
|
+
mounted,
|
|
281
|
+
content: payload,
|
|
282
|
+
onMeasureLayout: handleMeasureLayout,
|
|
283
|
+
onMeasureLayoutComplete: handleMeasureLayoutComplete,
|
|
284
|
+
side,
|
|
285
|
+
direction
|
|
286
|
+
});
|
|
287
|
+
const state = {
|
|
288
|
+
activationDirection: getActivationDirection(newTriggerOffset),
|
|
289
|
+
transitioning: isTransitioning
|
|
290
|
+
};
|
|
291
|
+
return {
|
|
292
|
+
children: childrenToRender,
|
|
293
|
+
state
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function getActivationDirection(offset) {
|
|
297
|
+
if (!offset) return;
|
|
298
|
+
return `${getValueWithTolerance(offset.horizontal, 5, 'right', 'left')} ${getValueWithTolerance(offset.vertical, 5, 'down', 'up')}`;
|
|
299
|
+
}
|
|
300
|
+
function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
|
|
301
|
+
if (value > tolerance) return positiveLabel;
|
|
302
|
+
if (value < -tolerance) return negativeLabel;
|
|
303
|
+
return '';
|
|
304
|
+
}
|
|
305
|
+
function calculateRelativePosition(from, to) {
|
|
306
|
+
const fromRect = from.getBoundingClientRect();
|
|
307
|
+
const toRect = to.getBoundingClientRect();
|
|
308
|
+
const fromCenter = {
|
|
309
|
+
x: fromRect.left + fromRect.width / 2,
|
|
310
|
+
y: fromRect.top + fromRect.height / 2
|
|
311
|
+
};
|
|
312
|
+
const toCenter = {
|
|
313
|
+
x: toRect.left + toRect.width / 2,
|
|
314
|
+
y: toRect.top + toRect.height / 2
|
|
315
|
+
};
|
|
316
|
+
return {
|
|
317
|
+
horizontal: toCenter.x - fromCenter.x,
|
|
318
|
+
vertical: toCenter.y - fromCenter.y
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function usePopupContentKey(activeTriggerId, payload) {
|
|
322
|
+
const [contentKey, setContentKey] = __rspack_external_react.useState(0);
|
|
323
|
+
const previousActiveTriggerIdRef = __rspack_external_react.useRef(activeTriggerId);
|
|
324
|
+
const previousPayloadRef = __rspack_external_react.useRef(payload);
|
|
325
|
+
const pendingPayloadUpdateRef = __rspack_external_react.useRef(false);
|
|
326
|
+
useIsoLayoutEffect(()=>{
|
|
327
|
+
const previousActiveTriggerId = previousActiveTriggerIdRef.current;
|
|
328
|
+
const previousPayload = previousPayloadRef.current;
|
|
329
|
+
const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
|
|
330
|
+
const payloadChanged = payload !== previousPayload;
|
|
331
|
+
if (triggerIdChanged) {
|
|
332
|
+
setContentKey((value)=>value + 1);
|
|
333
|
+
pendingPayloadUpdateRef.current = !payloadChanged;
|
|
334
|
+
} else if (pendingPayloadUpdateRef.current && payloadChanged) {
|
|
335
|
+
setContentKey((value)=>value + 1);
|
|
336
|
+
pendingPayloadUpdateRef.current = false;
|
|
337
|
+
}
|
|
338
|
+
previousActiveTriggerIdRef.current = activeTriggerId;
|
|
339
|
+
previousPayloadRef.current = payload;
|
|
340
|
+
}, [
|
|
341
|
+
activeTriggerId,
|
|
342
|
+
payload
|
|
343
|
+
]);
|
|
344
|
+
return `${activeTriggerId ?? 'current'}-${contentKey}`;
|
|
345
|
+
}
|
|
346
|
+
export { usePopupViewport };
|
package/dist/8225.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const visuallyHiddenBase = {
|
|
2
|
+
clipPath: 'inset(50%)',
|
|
3
|
+
overflow: 'hidden',
|
|
4
|
+
whiteSpace: 'nowrap',
|
|
5
|
+
border: 0,
|
|
6
|
+
padding: 0,
|
|
7
|
+
width: 1,
|
|
8
|
+
height: 1,
|
|
9
|
+
margin: -1
|
|
10
|
+
};
|
|
11
|
+
const visuallyHidden = {
|
|
12
|
+
...visuallyHiddenBase,
|
|
13
|
+
position: 'fixed',
|
|
14
|
+
top: 0,
|
|
15
|
+
left: 0
|
|
16
|
+
};
|
|
17
|
+
const visuallyHiddenInput = {
|
|
18
|
+
...visuallyHiddenBase,
|
|
19
|
+
position: 'absolute'
|
|
20
|
+
};
|
|
21
|
+
export { visuallyHidden, visuallyHiddenInput };
|