@wix/editor-react-components 1.2317.0 → 1.2319.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.
@@ -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, useMemo, useState, useCallback, useRef, useEffect, useLayoutEffect } from "react";
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,
@@ -2057,6 +2091,7 @@ const HamburgerMenu = ({
2057
2091
  }
2058
2092
  }
2059
2093
  }) => {
2094
+ const { translations } = useMenuContext();
2060
2095
  const siteScrollBlocker = useService(SiteScrollBlockerDefinition);
2061
2096
  const [isOpen, setIsOpen] = useState(false);
2062
2097
  useEffect(() => {
@@ -2113,6 +2148,10 @@ const HamburgerMenu = ({
2113
2148
  Button,
2114
2149
  {
2115
2150
  ...hamburgerOpenButtonProps,
2151
+ a11y: {
2152
+ ariaLabel: translations.hamburgerOpenButtonAriaLabel,
2153
+ ...hamburgerOpenButtonProps == null ? void 0 : hamburgerOpenButtonProps.a11y
2154
+ },
2116
2155
  className: clsx(
2117
2156
  selectors.hamburgerMenuOpenButton,
2118
2157
  classes.openButton
@@ -2149,6 +2188,10 @@ const HamburgerMenu = ({
2149
2188
  Button,
2150
2189
  {
2151
2190
  ...hamburgerCloseButtonProps,
2191
+ a11y: {
2192
+ ariaLabel: translations.hamburgerCloseButtonAriaLabel,
2193
+ ...hamburgerCloseButtonProps == null ? void 0 : hamburgerCloseButtonProps.a11y
2194
+ },
2152
2195
  className: clsx(
2153
2196
  selectors.hamburgerMenuCloseButton,
2154
2197
  classes.closeButton
@@ -2226,7 +2269,13 @@ const Menu = (props) => {
2226
2269
  menuNavAriaLabel: translate(ARIA_LABEL_NAMESPACE)(translationsKeys.menuNavAriaLabel) || defaultTranslations.menuNavAriaLabel,
2227
2270
  dropdownButtonAriaLabel: translate(ARIA_LABEL_NAMESPACE)(
2228
2271
  translationsKeys.dropdownButtonAriaLabel
2229
- ) || defaultTranslations.dropdownButtonAriaLabel
2272
+ ) || defaultTranslations.dropdownButtonAriaLabel,
2273
+ hamburgerOpenButtonAriaLabel: translate(ARIA_LABEL_NAMESPACE)(
2274
+ translationsKeys.hamburgerOpenButtonAriaLabel
2275
+ ) || defaultTranslations.hamburgerOpenButtonAriaLabel,
2276
+ hamburgerCloseButtonAriaLabel: translate(ARIA_LABEL_NAMESPACE)(
2277
+ translationsKeys.hamburgerCloseButtonAriaLabel
2278
+ ) || defaultTranslations.hamburgerCloseButtonAriaLabel
2230
2279
  };
2231
2280
  const presetsWrapperProps = (wix == null ? void 0 : wix.presetsWrapperProps) || {};
2232
2281
  return /* @__PURE__ */ jsx("div", { className: presetWrapperStyles.presetWrapper, ...presetsWrapperProps, children: /* @__PURE__ */ jsx(
@@ -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
  };
@@ -301,11 +301,15 @@ export declare const ARIA_LABEL_NAMESPACE = "ariaLabels";
301
301
  export declare const translationsKeys: {
302
302
  menuNavAriaLabel: string;
303
303
  dropdownButtonAriaLabel: string;
304
+ hamburgerOpenButtonAriaLabel: string;
305
+ hamburgerCloseButtonAriaLabel: string;
304
306
  };
305
307
  export type Translations = {
306
308
  translations: {
307
309
  dropdownButtonAriaLabel?: string;
308
310
  menuNavAriaLabel?: string;
311
+ hamburgerOpenButtonAriaLabel?: string;
312
+ hamburgerCloseButtonAriaLabel?: string;
309
313
  };
310
314
  };
311
315
  export declare const defaultTranslations: Translations['translations'];
@@ -9,6 +9,8 @@ export type MenuContextValue = {
9
9
  translations: {
10
10
  dropdownButtonAriaLabel?: string;
11
11
  menuNavAriaLabel?: string;
12
+ hamburgerOpenButtonAriaLabel?: string;
13
+ hamburgerCloseButtonAriaLabel?: string;
12
14
  };
13
15
  customClassNames?: Array<string>;
14
16
  navAriaLabel: string;
@@ -18,6 +20,8 @@ export type MenuContextValue = {
18
20
  setIsHamburgerMenuOpened?: (isOpen: boolean) => void;
19
21
  a11yProps: React.AriaAttributes;
20
22
  dropdownAnchor?: DropdownAnchorType;
23
+ closeActiveDropdown?: () => void;
24
+ setActiveDropdown?: (closeImmediately: () => void) => void;
21
25
  };
22
26
  export declare const MenuContext: React.Context<MenuContextValue>;
23
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 = {
@@ -363,11 +374,15 @@ const DropdownAnchorPositions = {
363
374
  const ARIA_LABEL_NAMESPACE = "ariaLabels";
364
375
  const translationsKeys = {
365
376
  menuNavAriaLabel: "dropDownMenu_AriaLabel_TopLevel_SiteNavigation",
366
- dropdownButtonAriaLabel: "menu_dropdown_chevron_button_aria_label"
377
+ dropdownButtonAriaLabel: "menu_dropdown_chevron_button_aria_label",
378
+ hamburgerOpenButtonAriaLabel: "Mobile_Hamburger_Menu_AriaLabel_Open",
379
+ hamburgerCloseButtonAriaLabel: "Mobile_Hamburger_Menu_AriaLabel_Close"
367
380
  };
368
381
  const defaultTranslations = {
369
382
  menuNavAriaLabel: "Site",
370
- dropdownButtonAriaLabel: "More pages"
383
+ dropdownButtonAriaLabel: "More pages",
384
+ hamburgerOpenButtonAriaLabel: "Open navigation menu",
385
+ hamburgerCloseButtonAriaLabel: "Close navigation menu"
371
386
  };
372
387
  const MenuParts = {
373
388
  Navbar: "navbar",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/editor-react-components",
3
- "version": "1.2317.0",
3
+ "version": "1.2319.0",
4
4
  "description": "React components for the Wix Editor",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -66,7 +66,7 @@
66
66
  "format:check": "yarn run -T format:package:check"
67
67
  },
68
68
  "peerDependencies": {
69
- "@wix/editor-react-types": "^1.0.62",
69
+ "@wix/editor-react-types": "^1.0.65",
70
70
  "react": "^18.2.0",
71
71
  "react-dom": "^18.2.0"
72
72
  },
@@ -78,7 +78,7 @@
78
78
  "@wix/ambassador-devcenter-v1-component-type-data": "^1.0.436",
79
79
  "@wix/sdk": "^1.21.13",
80
80
  "@wix/services-manager-react": "^0.1.27",
81
- "@wix/site-ui": "1.151.0",
81
+ "@wix/site-ui": "1.152.0",
82
82
  "@wix/video": "^1.85.0",
83
83
  "@wix/viewer-service-consent-policy": "^1.0.100",
84
84
  "@wix/web-bi-logger": "^2.1.26",
@@ -119,7 +119,7 @@
119
119
  "@wix/editor": "^1.586.0",
120
120
  "@wix/editor-elements-scripts": "^1.0.0",
121
121
  "@wix/editor-elements-test-utils": "^1.0.0",
122
- "@wix/editor-react-types": "^1.0.62",
122
+ "@wix/editor-react-types": "^1.0.65",
123
123
  "@wix/essentials": "^0.1.28",
124
124
  "@wix/fed-cli-sled": "1.0.25",
125
125
  "@wix/image": "^1.437.0",
@@ -193,5 +193,5 @@
193
193
  "registry": "https://registry.npmjs.org/",
194
194
  "access": "public"
195
195
  },
196
- "falconPackageHash": "c91c184b34796ac1ce4bc4dc4e65477804628175cb95b757deea76a7"
196
+ "falconPackageHash": "b14d57b121e6ffbf3528f42ca0337723d35d4d2d8c9b7c3c64b9bccb"
197
197
  }