@wix/editor-react-components 1.2318.0 → 1.2320.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/site/components/Menu/component.js +40 -6
- package/dist/site/components/Menu/components/MenuContent/MenuItem/useAnimationState.d.ts +1 -0
- package/dist/site/components/Menu/components/MenuContent/MenuItem/useDropdown.d.ts +1 -0
- package/dist/site/components/Menu/contexts/MenuContext.d.ts +2 -0
- package/dist/site/components/chunks/constants26.js +12 -1
- package/package.json +7 -3
|
@@ -5,7 +5,7 @@ import { U as UrlDefinition } from "../chunks/index11.js";
|
|
|
5
5
|
import { d as defineService } from "../chunks/index7.js";
|
|
6
6
|
import { T as TranslationsDefinition } from "../chunks/index5.js";
|
|
7
7
|
import { M as MenuAnimationName, d as defaultTranslations, a as MenuOrientation, A as AnimationPhase, V as VerticalDropdownDisplay, D as DropdownAnimationName, H as HamburgerMenuAnimationName, b as MenuParts, s as selectors, u as useAnimationState, c as ARIA_LABEL_NAMESPACE, t as translationsKeys } from "../chunks/constants26.js";
|
|
8
|
-
import React__default, { createContext, useContext,
|
|
8
|
+
import React__default, { createContext, useContext, useRef, useCallback, useMemo, useState, useEffect, useLayoutEffect } from "react";
|
|
9
9
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
10
10
|
import { g as getItemDepthSelector, r as rootItemDepthLevel, s as subItemDepthLevel, a as subSubItemDepthLevel } from "../chunks/utils2.js";
|
|
11
11
|
import { d as debounce } from "../chunks/performanceUtils.js";
|
|
@@ -48,6 +48,15 @@ const MenuContextProvider = ({
|
|
|
48
48
|
a11yProps,
|
|
49
49
|
dropdownAnchor
|
|
50
50
|
}) => {
|
|
51
|
+
const activeDropdownCloseRef = useRef(null);
|
|
52
|
+
const closeActiveDropdown = useCallback(() => {
|
|
53
|
+
var _a;
|
|
54
|
+
(_a = activeDropdownCloseRef.current) == null ? void 0 : _a.call(activeDropdownCloseRef);
|
|
55
|
+
activeDropdownCloseRef.current = null;
|
|
56
|
+
}, []);
|
|
57
|
+
const setActiveDropdown = useCallback((closeImmediately) => {
|
|
58
|
+
activeDropdownCloseRef.current = closeImmediately;
|
|
59
|
+
}, []);
|
|
51
60
|
const contextValue = useMemo(
|
|
52
61
|
() => ({
|
|
53
62
|
items,
|
|
@@ -62,7 +71,9 @@ const MenuContextProvider = ({
|
|
|
62
71
|
isHamburgerMenuOpened,
|
|
63
72
|
setIsHamburgerMenuOpened,
|
|
64
73
|
a11yProps,
|
|
65
|
-
dropdownAnchor
|
|
74
|
+
dropdownAnchor,
|
|
75
|
+
closeActiveDropdown,
|
|
76
|
+
setActiveDropdown
|
|
66
77
|
}),
|
|
67
78
|
[
|
|
68
79
|
items,
|
|
@@ -77,7 +88,9 @@ const MenuContextProvider = ({
|
|
|
77
88
|
isHamburgerMenuOpened,
|
|
78
89
|
setIsHamburgerMenuOpened,
|
|
79
90
|
a11yProps,
|
|
80
|
-
dropdownAnchor
|
|
91
|
+
dropdownAnchor,
|
|
92
|
+
closeActiveDropdown,
|
|
93
|
+
setActiveDropdown
|
|
81
94
|
]
|
|
82
95
|
);
|
|
83
96
|
return /* @__PURE__ */ jsx(MenuContext.Provider, { value: contextValue, children });
|
|
@@ -1085,7 +1098,8 @@ const useDropdown = ({
|
|
|
1085
1098
|
animationState,
|
|
1086
1099
|
initEnterAnimation,
|
|
1087
1100
|
initExitAnimation,
|
|
1088
|
-
skipToEnterDone
|
|
1101
|
+
skipToEnterDone,
|
|
1102
|
+
skipToExitDone
|
|
1089
1103
|
} = useAnimationState(
|
|
1090
1104
|
DROPDOWN_ANIMATION_CONFIG,
|
|
1091
1105
|
INITIAL_DROPDOWN_ANIMATION_STATE
|
|
@@ -1115,9 +1129,20 @@ const useDropdown = ({
|
|
|
1115
1129
|
setIsOpen(true);
|
|
1116
1130
|
};
|
|
1117
1131
|
const hideDropdown = () => {
|
|
1132
|
+
if (!isOpen) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1118
1135
|
const dropdownAnimationName = getDropdownAnimationName();
|
|
1119
1136
|
initExitAnimation(dropdownAnimationName, () => setIsOpen(false));
|
|
1120
1137
|
};
|
|
1138
|
+
const hideDropdownImmediate = () => {
|
|
1139
|
+
if (!isOpen) {
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
const dropdownAnimationName = getDropdownAnimationName();
|
|
1143
|
+
skipToExitDone(dropdownAnimationName);
|
|
1144
|
+
setIsOpen(false);
|
|
1145
|
+
};
|
|
1121
1146
|
const toggleDropdown = () => {
|
|
1122
1147
|
if (isOpen) {
|
|
1123
1148
|
hideDropdown();
|
|
@@ -1146,6 +1171,7 @@ const useDropdown = ({
|
|
|
1146
1171
|
showDropdown,
|
|
1147
1172
|
showDropdownImmediate,
|
|
1148
1173
|
hideDropdown,
|
|
1174
|
+
hideDropdownImmediate,
|
|
1149
1175
|
toggleDropdown,
|
|
1150
1176
|
updateDropdownDomStyles: updateDropdownDomStyles$1
|
|
1151
1177
|
};
|
|
@@ -1511,6 +1537,7 @@ const MenuItem = (props) => {
|
|
|
1511
1537
|
showDropdown,
|
|
1512
1538
|
showDropdownImmediate,
|
|
1513
1539
|
hideDropdown,
|
|
1540
|
+
hideDropdownImmediate,
|
|
1514
1541
|
toggleDropdown,
|
|
1515
1542
|
updateDropdownDomStyles: updateDropdownDomStyles2
|
|
1516
1543
|
} = useDropdown({
|
|
@@ -1518,7 +1545,14 @@ const MenuItem = (props) => {
|
|
|
1518
1545
|
forceOpen,
|
|
1519
1546
|
getAnimationPackage
|
|
1520
1547
|
});
|
|
1521
|
-
const { isHamburgerMenuOpened } = useMenuContext();
|
|
1548
|
+
const { isHamburgerMenuOpened, closeActiveDropdown, setActiveDropdown } = useMenuContext();
|
|
1549
|
+
const hideDropdownImmediateRef = useRef(hideDropdownImmediate);
|
|
1550
|
+
hideDropdownImmediateRef.current = hideDropdownImmediate;
|
|
1551
|
+
const showDropdownCoordinated = useCallback(() => {
|
|
1552
|
+
closeActiveDropdown == null ? void 0 : closeActiveDropdown();
|
|
1553
|
+
showDropdown();
|
|
1554
|
+
setActiveDropdown == null ? void 0 : setActiveDropdown(() => hideDropdownImmediateRef.current());
|
|
1555
|
+
}, [closeActiveDropdown, showDropdown, setActiveDropdown]);
|
|
1522
1556
|
const { setDropdownDomStylesApplier, dropdownElementRef } = useContext(DropdownContext);
|
|
1523
1557
|
useEffect(() => {
|
|
1524
1558
|
if (forceOpen) {
|
|
@@ -1526,7 +1560,7 @@ const MenuItem = (props) => {
|
|
|
1526
1560
|
}
|
|
1527
1561
|
}, [forceOpen, setDropdownDomStylesApplier, updateDropdownDomStyles2]);
|
|
1528
1562
|
const eventListeners = createEventListeners({
|
|
1529
|
-
showDropdown,
|
|
1563
|
+
showDropdown: showDropdownCoordinated,
|
|
1530
1564
|
hideDropdown,
|
|
1531
1565
|
itemRef,
|
|
1532
1566
|
getMenuItemAnimationName,
|
|
@@ -20,5 +20,6 @@ export declare const useAnimationState: <AnimationNameType extends string>(anima
|
|
|
20
20
|
initEnterAnimation: (animationName: AnimationNameType, onAnimationDone?: () => void) => void;
|
|
21
21
|
initExitAnimation: (animationName: AnimationNameType, onAnimationDone?: () => void) => void;
|
|
22
22
|
skipToEnterDone: (animationName: AnimationNameType) => void;
|
|
23
|
+
skipToExitDone: (animationName: AnimationNameType) => void;
|
|
23
24
|
};
|
|
24
25
|
export {};
|
|
@@ -10,6 +10,7 @@ export declare const useDropdown: ({ itemRef, forceOpen, getAnimationPackage, }:
|
|
|
10
10
|
showDropdown: () => void;
|
|
11
11
|
showDropdownImmediate: () => void;
|
|
12
12
|
hideDropdown: () => void;
|
|
13
|
+
hideDropdownImmediate: () => void;
|
|
13
14
|
toggleDropdown: () => void;
|
|
14
15
|
updateDropdownDomStyles: () => void;
|
|
15
16
|
};
|
|
@@ -20,6 +20,8 @@ export type MenuContextValue = {
|
|
|
20
20
|
setIsHamburgerMenuOpened?: (isOpen: boolean) => void;
|
|
21
21
|
a11yProps: React.AriaAttributes;
|
|
22
22
|
dropdownAnchor?: DropdownAnchorType;
|
|
23
|
+
closeActiveDropdown?: () => void;
|
|
24
|
+
setActiveDropdown?: (closeImmediately: () => void) => void;
|
|
23
25
|
};
|
|
24
26
|
export declare const MenuContext: React.Context<MenuContextValue>;
|
|
25
27
|
export declare const useMenuContext: () => MenuContextValue;
|
|
@@ -49,6 +49,16 @@ const useAnimationState = (animationConfigMap, initialAnimationState) => {
|
|
|
49
49
|
phase: AnimationPhase.EnterDone
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
+
const skipToExitDone = (animationName) => {
|
|
53
|
+
abortAnimationCallbacks();
|
|
54
|
+
if (animationName === DISABLED_ANIMATION_NAME) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setAnimationState({
|
|
58
|
+
name: animationName,
|
|
59
|
+
phase: AnimationPhase.ExitDone
|
|
60
|
+
});
|
|
61
|
+
};
|
|
52
62
|
const initExitAnimation = (animationName, onAnimationDone) => {
|
|
53
63
|
abortAnimationCallbacks();
|
|
54
64
|
if (animationName === DISABLED_ANIMATION_NAME) {
|
|
@@ -95,7 +105,8 @@ const useAnimationState = (animationConfigMap, initialAnimationState) => {
|
|
|
95
105
|
animationState,
|
|
96
106
|
initEnterAnimation,
|
|
97
107
|
initExitAnimation,
|
|
98
|
-
skipToEnterDone
|
|
108
|
+
skipToEnterDone,
|
|
109
|
+
skipToExitDone
|
|
99
110
|
};
|
|
100
111
|
};
|
|
101
112
|
const MenuOrientation = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/editor-react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2320.0",
|
|
4
4
|
"description": "React components for the Wix Editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -176,7 +176,11 @@
|
|
|
176
176
|
},
|
|
177
177
|
"validations": {
|
|
178
178
|
"postDependenciesBuild": [
|
|
179
|
-
"check:lint-and-format"
|
|
179
|
+
"check:lint-and-format",
|
|
180
|
+
{
|
|
181
|
+
"scriptName": "test",
|
|
182
|
+
"timeout": 15
|
|
183
|
+
}
|
|
180
184
|
],
|
|
181
185
|
"postBuild": [
|
|
182
186
|
{
|
|
@@ -193,5 +197,5 @@
|
|
|
193
197
|
"registry": "https://registry.npmjs.org/",
|
|
194
198
|
"access": "public"
|
|
195
199
|
},
|
|
196
|
-
"falconPackageHash": "
|
|
200
|
+
"falconPackageHash": "ce7595d36305832b009ccf9beb4bd7fc578bffa366e83cd362d4324c"
|
|
197
201
|
}
|