@wix/editor-react-components 1.2662.0 → 1.2664.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.
@@ -94,8 +94,7 @@ const manifest = {
94
94
  "blend-mode": {
95
95
  cssPropertyType: CSS_PROPERTIES.CSS_PROPERTY_TYPE.blendMode,
96
96
  displayName: "Blend Mode",
97
- defaultValue: "normal",
98
- spec: "sp.erc.imageBlendMode"
97
+ defaultValue: "normal"
99
98
  },
100
99
  opacity: {
101
100
  cssPropertyType: CSS_PROPERTIES.CSS_PROPERTY_TYPE.opacity,
@@ -107,6 +107,8 @@ export type DropdownProps = (HorizontalDropdownProps | VerticalDropdownProps) &
107
107
  menuOrientation: MenuOrientationType;
108
108
  className?: string;
109
109
  elementProps?: MenuDropdownItemsElementProps;
110
+ onMouseEnter?: () => void;
111
+ onMouseLeave?: () => void;
110
112
  };
111
113
  export type MenuStates = {
112
114
  hamburgerMenuOpen?: boolean;
@@ -320,7 +320,8 @@ const createEventListeners = ({
320
320
  initExitAnimation,
321
321
  isOpen,
322
322
  hasLink,
323
- dropdownAnimationState
323
+ dropdownAnimationState,
324
+ animationPhase
324
325
  }) => {
325
326
  const shouldDropdownBeHidden = () => {
326
327
  const isHorizontal = getMenuOrientation(itemRef) === MenuOrientation.Horizontal;
@@ -335,23 +336,17 @@ const createEventListeners = ({
335
336
  }
336
337
  return !!isHorizontal;
337
338
  };
339
+ const shouldSkipEnterAnimation = () => animationPhase === AnimationPhase.Enter || animationPhase === AnimationPhase.EnterActive || animationPhase === AnimationPhase.EnterDone;
338
340
  return {
339
341
  onMouseEnter: () => {
340
342
  const isHorizontal = getMenuOrientation(itemRef) === MenuOrientation.Horizontal;
341
- const isAlwaysOpen = getIsAlwaysOpen(itemRef);
342
- const isVerticalExpanded = getIsVerticalExpanded(
343
- isHorizontal,
344
- isOpen,
345
- dropdownAnimationState
346
- );
347
- if (!hasLink && (isAlwaysOpen || isVerticalExpanded)) {
348
- return;
349
- }
350
- const animationName = getMenuItemAnimationName();
351
343
  if (isHorizontal) {
352
344
  showDropdown();
353
345
  }
354
- initEnterAnimation(animationName);
346
+ if (!shouldSkipEnterAnimation()) {
347
+ const animationName = getMenuItemAnimationName();
348
+ initEnterAnimation(animationName);
349
+ }
355
350
  },
356
351
  onMouseLeave: () => {
357
352
  const animationName = getMenuItemAnimationName();
@@ -360,10 +355,21 @@ const createEventListeners = ({
360
355
  }
361
356
  initExitAnimation(animationName);
362
357
  },
358
+ onFocus: (event) => {
359
+ const isEnteringFromOutside = !event.relatedTarget || !event.currentTarget.contains(event.relatedTarget);
360
+ if (!isEnteringFromOutside || shouldSkipEnterAnimation()) {
361
+ return;
362
+ }
363
+ const animationName = getMenuItemAnimationName();
364
+ initEnterAnimation(animationName);
365
+ },
363
366
  onBlur: (event) => {
364
367
  const isOutsideElement = !event.relatedTarget || !event.currentTarget.contains(event.relatedTarget);
368
+ if (!isOutsideElement) {
369
+ return;
370
+ }
365
371
  const animationName = getMenuItemAnimationName();
366
- if (shouldDropdownBeHidden() && isOutsideElement) {
372
+ if (shouldDropdownBeHidden()) {
367
373
  hideDropdown();
368
374
  }
369
375
  initExitAnimation(animationName);
@@ -858,7 +864,10 @@ const MenuItemLabel = (props) => {
858
864
  dropdownAnimationState,
859
865
  submenuToggleId,
860
866
  itemClassName,
861
- BuilderAnimationIcon
867
+ BuilderAnimationIcon,
868
+ isHovered,
869
+ onHoverAreaEnter,
870
+ onHoverAreaLeave
862
871
  } = props;
863
872
  const isCurrentPage = isCurrentItem(item2, currentItem);
864
873
  const { label: label2, link } = item2;
@@ -870,7 +879,8 @@ const MenuItemLabel = (props) => {
870
879
  selectors.item,
871
880
  classes$6.labelContainer,
872
881
  itemClassName,
873
- isCurrentPage && DesignStates.item.selected.className
882
+ isCurrentPage && DesignStates.item.selected.className,
883
+ isHovered && DesignStates.item.hover.className
874
884
  );
875
885
  const isInteractive = (hasSubItems || hasLink) && !isCurrentPage;
876
886
  const isDropdownIconOpen = isOpen && dropdownAnimationState.phase !== AnimationPhase.ExitActive;
@@ -892,8 +902,14 @@ const MenuItemLabel = (props) => {
892
902
  "data-preview": partToPreviewStateMap == null ? void 0 : partToPreviewStateMap.item,
893
903
  "data-interactive": isInteractive,
894
904
  onClick: createSDKAction(item2, isCurrentPage, onItemClick),
895
- onMouseEnter: handleMouseEnter,
896
- onMouseLeave: handleMouseLeave,
905
+ onMouseEnter: (event) => {
906
+ handleMouseEnter(event);
907
+ onHoverAreaEnter == null ? void 0 : onHoverAreaEnter();
908
+ },
909
+ onMouseLeave: (event) => {
910
+ handleMouseLeave(event);
911
+ onHoverAreaLeave == null ? void 0 : onHoverAreaLeave();
912
+ },
897
913
  onDoubleClick: createSDKAction(item2, isCurrentPage, onItemDblClick),
898
914
  children: [
899
915
  /* @__PURE__ */ jsx(
@@ -1532,7 +1548,9 @@ const Dropdown = React__default.forwardRef(
1532
1548
  direction,
1533
1549
  onItemClick,
1534
1550
  className,
1535
- elementProps
1551
+ elementProps,
1552
+ onMouseEnter,
1553
+ onMouseLeave
1536
1554
  }, ref) => {
1537
1555
  var _a, _b;
1538
1556
  const rootClassNames = {
@@ -1556,6 +1574,8 @@ const Dropdown = React__default.forwardRef(
1556
1574
  ),
1557
1575
  dir: direction,
1558
1576
  ref,
1577
+ onMouseEnter,
1578
+ onMouseLeave,
1559
1579
  children: /* @__PURE__ */ jsx(
1560
1580
  MenuItemContext.Provider,
1561
1581
  {
@@ -1632,6 +1652,9 @@ const MenuItem = (props) => {
1632
1652
  }
1633
1653
  const chevronButtonRef = useRef(null);
1634
1654
  const itemRef = useRef(null);
1655
+ const itemWrapperRef = useRef(null);
1656
+ const [isHoverAreaActive, setIsHoverAreaActive] = useState(false);
1657
+ const [isOpenedByToggle, setIsOpenedByToggle] = useState(false);
1635
1658
  const getMenuItemAnimationName = () => {
1636
1659
  const animationPackage = getAnimationPackage();
1637
1660
  const menuItemAnimationName = ANIMATION_PACKAGE_CONFIG[animationPackage].menuItemAnimationName;
@@ -1665,6 +1688,18 @@ const MenuItem = (props) => {
1665
1688
  setDropdownDomStylesApplier(updateDropdownDomStyles2);
1666
1689
  }
1667
1690
  }, [forceOpen, setDropdownDomStylesApplier, updateDropdownDomStyles2]);
1691
+ useEffect(() => {
1692
+ if (!isOpen) {
1693
+ setIsOpenedByToggle(false);
1694
+ }
1695
+ }, [isOpen]);
1696
+ const toggleDropdownWithHoverLook = useCallback(() => {
1697
+ if (getMenuOrientation(itemRef) === MenuOrientation.Horizontal) {
1698
+ setIsOpenedByToggle(!isOpen);
1699
+ }
1700
+ toggleDropdown();
1701
+ }, [isOpen, toggleDropdown]);
1702
+ const isHovered = isHoverAreaActive || isOpenedByToggle && animationState.phase !== AnimationPhase.ExitActive && animationState.phase !== AnimationPhase.ExitDone;
1668
1703
  const eventListeners = createEventListeners({
1669
1704
  showDropdown: showDropdownCoordinated,
1670
1705
  hideDropdown,
@@ -1674,7 +1709,8 @@ const MenuItem = (props) => {
1674
1709
  initExitAnimation,
1675
1710
  isOpen,
1676
1711
  hasLink,
1677
- dropdownAnimationState
1712
+ dropdownAnimationState,
1713
+ animationPhase: animationState.phase
1678
1714
  });
1679
1715
  useEffect(() => {
1680
1716
  if ((currentItem == null ? void 0 : currentItem.id) === item2.id && itemRef.current) {
@@ -1682,13 +1718,16 @@ const MenuItem = (props) => {
1682
1718
  }
1683
1719
  }, [currentItem, item2, focusOnMenuItem]);
1684
1720
  useLayoutEffect(() => {
1685
- var _a2, _b2;
1721
+ var _a2, _b2, _c2;
1686
1722
  if ((((_a2 = submenuCheckboxRef.current) == null ? void 0 : _a2.checked) || prehydrationOpenRef.current) && !isOpen) {
1687
1723
  showDropdownImmediate();
1688
1724
  }
1689
- if (hasDropdownMenu && !isOpen && ((_b2 = itemRef.current) == null ? void 0 : _b2.matches(":hover"))) {
1725
+ if (((_b2 = itemRef.current) == null ? void 0 : _b2.matches(":hover")) && hasDropdownMenu && !isOpen) {
1690
1726
  showDropdownImmediate();
1691
1727
  }
1728
+ if ((_c2 = itemWrapperRef.current) == null ? void 0 : _c2.matches(":hover")) {
1729
+ setIsHoverAreaActive(true);
1730
+ }
1692
1731
  }, []);
1693
1732
  const prevHamburgerOpenRef = useRef(isHamburgerMenuOpened);
1694
1733
  useEffect(() => {
@@ -1769,31 +1808,44 @@ const MenuItem = (props) => {
1769
1808
  className: classes$6.hiddenToggle
1770
1809
  }
1771
1810
  ),
1772
- /* @__PURE__ */ jsxs("div", { className: classes$6.itemWrapper, ...eventListeners, children: [
1773
- /* @__PURE__ */ jsx(
1774
- MenuItemLabel,
1775
- {
1776
- ...props,
1777
- hasDropdownMenu,
1778
- hasSubItems,
1779
- hasContainer,
1780
- chevronButtonRef,
1781
- toggleDropdown,
1782
- isOpen,
1783
- dropdownAnimationState,
1784
- submenuToggleId,
1785
- itemClassName: (_d = menuElementProps == null ? void 0 : menuElementProps.item) == null ? void 0 : _d.className
1786
- }
1787
- ),
1788
- hasDropdownMenu && /* @__PURE__ */ jsx(
1789
- Dropdown,
1790
- {
1791
- ...sharedDropdownProps,
1792
- menuOrientation: "horizontal",
1793
- ref: forceOpen ? dropdownElementRef : void 0
1794
- }
1795
- )
1796
- ] }),
1811
+ /* @__PURE__ */ jsxs(
1812
+ "div",
1813
+ {
1814
+ className: classes$6.itemWrapper,
1815
+ ref: itemWrapperRef,
1816
+ ...eventListeners,
1817
+ children: [
1818
+ /* @__PURE__ */ jsx(
1819
+ MenuItemLabel,
1820
+ {
1821
+ ...props,
1822
+ hasDropdownMenu,
1823
+ hasSubItems,
1824
+ hasContainer,
1825
+ chevronButtonRef,
1826
+ toggleDropdown: toggleDropdownWithHoverLook,
1827
+ isOpen,
1828
+ dropdownAnimationState,
1829
+ submenuToggleId,
1830
+ itemClassName: (_d = menuElementProps == null ? void 0 : menuElementProps.item) == null ? void 0 : _d.className,
1831
+ isHovered,
1832
+ onHoverAreaEnter: () => setIsHoverAreaActive(true),
1833
+ onHoverAreaLeave: () => setIsHoverAreaActive(false)
1834
+ }
1835
+ ),
1836
+ hasDropdownMenu && /* @__PURE__ */ jsx(
1837
+ Dropdown,
1838
+ {
1839
+ ...sharedDropdownProps,
1840
+ menuOrientation: "horizontal",
1841
+ ref: forceOpen ? dropdownElementRef : void 0,
1842
+ onMouseEnter: () => setIsHoverAreaActive(true),
1843
+ onMouseLeave: () => setIsHoverAreaActive(false)
1844
+ }
1845
+ )
1846
+ ]
1847
+ }
1848
+ ),
1797
1849
  hasSubItems && /* @__PURE__ */ jsx(
1798
1850
  Dropdown,
1799
1851
  {
@@ -12,4 +12,7 @@ export declare const MenuItemLabel: React.FC<IMenuItemProps & {
12
12
  dropdownAnimationState: AnimationState<DropdownAnimationNameType>;
13
13
  submenuToggleId?: string;
14
14
  itemClassName?: string;
15
+ isHovered?: boolean;
16
+ onHoverAreaEnter?: () => void;
17
+ onHoverAreaLeave?: () => void;
15
18
  }>;
@@ -2,7 +2,7 @@ import { default as React } from 'react';
2
2
  import { IMenuItemSDKAction } from '../../../../../../common/sdk/props-factories/menuItemsPropsSDKFactory';
3
3
  import { IMenuItemProps } from '../../../Menu.types';
4
4
  import { DropdownAnimationNameType, MenuAnimationNameType, MenuOrientationType, MenuVerticalDropdownDisplayType } from '../../../constants';
5
- import { AnimationState } from './useAnimationState';
5
+ import { AnimationPhaseType, AnimationState } from './useAnimationState';
6
6
  export declare const createSDKAction: (item: Omit<IMenuItemProps["item"], "children">, selected: boolean, sdkAction?: IMenuItemSDKAction) => ((e: React.MouseEvent) => void) | undefined;
7
7
  export declare const getMenuOrientation: (itemRef: React.RefObject<HTMLLIElement>) => MenuOrientationType | undefined;
8
8
  export declare const getVerticalDropdownDispaly: (itemRef: React.RefObject<HTMLLIElement>) => MenuVerticalDropdownDisplayType | undefined;
@@ -17,10 +17,12 @@ type CreateEventListenersOptions = {
17
17
  isOpen: boolean;
18
18
  hasLink: boolean;
19
19
  dropdownAnimationState: AnimationState<DropdownAnimationNameType>;
20
+ animationPhase: AnimationPhaseType | undefined;
20
21
  };
21
- export declare const createEventListeners: ({ showDropdown, hideDropdown, itemRef, getMenuItemAnimationName, initEnterAnimation, initExitAnimation, isOpen, hasLink, dropdownAnimationState, }: CreateEventListenersOptions) => {
22
+ export declare const createEventListeners: ({ showDropdown, hideDropdown, itemRef, getMenuItemAnimationName, initEnterAnimation, initExitAnimation, isOpen, hasLink, dropdownAnimationState, animationPhase, }: CreateEventListenersOptions) => {
22
23
  onMouseEnter: () => void;
23
24
  onMouseLeave: () => void;
25
+ onFocus: (event: React.FocusEvent) => void;
24
26
  onBlur: (event: React.FocusEvent) => void;
25
27
  };
26
28
  export {};
@@ -59,37 +59,11 @@
59
59
  .labelContainer__E4y-p a {
60
60
  color: inherit;
61
61
  }
62
- [data-open]:not([data-animation-state=exitActive]):not([data-animation-state=exitDone]) > .itemWrapper__sn71X > .labelContainer__E4y-p, .labelContainer__E4y-p[data-interactive=true]:hover, .labelContainer__E4y-p[data-preview=hover], .labelContainer__E4y-p.hover__tD6A4, .labelContainer__E4y-p.menu__item--hover {
63
- background: var(--item-hover-background, var(--item-background));
64
- box-shadow: var(--item-hover-box-shadow, var(--item-box-shadow));
65
- border-top: var(--item-hover-border-top, var(--item-border-top));
66
- border-bottom: var(--item-hover-border-bottom, var(--item-border-bottom));
67
- }
68
- [data-open]:not([data-animation-state=exitActive]):not([data-animation-state=exitDone]) > .itemWrapper__sn71X > .labelContainer__E4y-p .label__BBchK, .labelContainer__E4y-p[data-interactive=true]:hover .label__BBchK, .labelContainer__E4y-p[data-preview=hover] .label__BBchK, .labelContainer__E4y-p.hover__tD6A4 .label__BBchK, .labelContainer__E4y-p.menu__item--hover .label__BBchK {
69
- color: var(--item-hover-color, var(--item-color));
70
- text-decoration-line: var(--item-hover-text-decoration, var(--item-text-decoration));
71
- text-shadow: var(--item-hover-text-outline, var(--item-text-outline)), var(--item-hover-text-shadow, var(--item-text-shadow));
72
- background-color: var(--item-hover-text-highlight, var(--item-text-highlight));
73
- line-height: var(--item-line-height);
74
- }
75
- [data-open]:not([data-animation-state=exitActive]):not([data-animation-state=exitDone]) > .itemWrapper__sn71X > .labelContainer__E4y-p path, .labelContainer__E4y-p[data-interactive=true]:hover path, .labelContainer__E4y-p[data-preview=hover] path, .labelContainer__E4y-p.hover__tD6A4 path, .labelContainer__E4y-p.menu__item--hover path {
76
- fill: var(--fill, var(--item-hover-icon-color, var(--item-icon-color, currentcolor)));
77
- }
78
- .labelContainer__E4y-p[data-selected], .labelContainer__E4y-p[data-preview=selected], .labelContainer__E4y-p.selected__qC-k6, .labelContainer__E4y-p.menu__item--selected {
79
- background: var(--item-selected-background, var(--item-background));
80
- box-shadow: var(--item-selected-box-shadow, var(--item-box-shadow));
81
- border-top: var(--item-selected-border-top, var(--item-border-top));
82
- border-bottom: var(--item-selected-border-bottom, var(--item-border-bottom));
83
- }
84
- .labelContainer__E4y-p[data-selected] .label__BBchK, .labelContainer__E4y-p[data-preview=selected] .label__BBchK, .labelContainer__E4y-p.selected__qC-k6 .label__BBchK, .labelContainer__E4y-p.menu__item--selected .label__BBchK {
85
- color: var(--item-selected-color, var(--item-color));
86
- text-decoration-line: var(--item-selected-text-decoration, var(--item-text-decoration));
87
- text-shadow: var(--item-selected-text-outline, var(--item-text-outline)), var(--item-selected-text-shadow, var(--item-text-shadow));
88
- background-color: var(--item-selected-text-highlight, var(--item-text-highlight));
89
- line-height: var(--item-line-height);
90
- }
91
- .labelContainer__E4y-p[data-selected] path, .labelContainer__E4y-p[data-preview=selected] path, .labelContainer__E4y-p.selected__qC-k6 path, .labelContainer__E4y-p.menu__item--selected path {
92
- fill: var(--fill, var(--item-selected-icon-color, var(--item-icon-color, currentcolor)));
62
+ .labelContainer__E4y-p.menu__item--hover .label__BBchK {
63
+ text-decoration-line: var(--item-hover-text-decoration, revert);
64
+ }
65
+ .labelContainer__E4y-p.menu__item--selected .label__BBchK {
66
+ text-decoration-line: var(--item-selected-text-decoration, revert);
93
67
  }
94
68
  .labelContainer__E4y-p > a::before {
95
69
  content: "";
@@ -584,11 +584,13 @@ const itemConfig = {
584
584
  removable: false
585
585
  },
586
586
  states: {
587
+ // Not native: the item must stay hovered while the pointer is over its
588
+ // mega menu dropdown, which isn't a DOM descendant of the item, so real
589
+ // :hover can't cover it — the className is toggled via JS instead
587
590
  hover: withSpec({
588
591
  spec: IS_SUPPORT_DESIGN_STATE_SPEC,
589
592
  displayName: DesignStates.item.hover.displayName,
590
- className: DesignStates.item.hover.className,
591
- pseudoClass: NativeStateType.hover
593
+ className: DesignStates.item.hover.className
592
594
  }),
593
595
  selected: withSpec({
594
596
  spec: IS_SUPPORT_DESIGN_STATE_SPEC,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/editor-react-components",
3
- "version": "1.2662.0",
3
+ "version": "1.2664.0",
4
4
  "description": "React components for the Wix Editor",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -200,5 +200,5 @@
200
200
  "registry": "https://registry.npmjs.org/",
201
201
  "access": "public"
202
202
  },
203
- "falconPackageHash": "973c337a161d00263624f2c40ccaadc9d46ee1edde103ae723c9103a"
203
+ "falconPackageHash": "cddd175b9c2aff8bcf779d96e918974fc24d35d3663640f28fd87ba4"
204
204
  }