ba-js-common-header 0.0.22 → 0.0.25

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.
@@ -23673,6 +23673,14 @@ function World(props) {
23673
23673
  });
23674
23674
  });
23675
23675
  })(commonThin);
23676
+ function useOutsideClickHandler(ref, handleOutsideClick) {
23677
+ useEffect(() => {
23678
+ document.addEventListener("click", handleOutsideClick);
23679
+ return () => {
23680
+ document.removeEventListener("click", handleOutsideClick);
23681
+ };
23682
+ }, [ref]);
23683
+ }
23676
23684
  function isNotification(notifications) {
23677
23685
  return Array.isArray(notifications) && notifications.length > 0;
23678
23686
  }
@@ -23683,6 +23691,7 @@ function Notifications() {
23683
23691
  const {
23684
23692
  notifications: notificationsConfig
23685
23693
  } = useSelector((state) => state.titleBar);
23694
+ const [showNotifications, setShowNotifications] = useState(false);
23686
23695
  const notifications = useSelector((state) => state.notifications);
23687
23696
  const userLanguage = useSelector((state) => state.userLanguage);
23688
23697
  const {
@@ -23692,6 +23701,10 @@ function Notifications() {
23692
23701
  const styles = useSpring({
23693
23702
  opacity: isMobileOrTablet && isOpen ? 0 : 1
23694
23703
  });
23704
+ const ref = useRef();
23705
+ useOutsideClickHandler(ref, () => {
23706
+ setShowNotifications(false);
23707
+ });
23695
23708
  const dispatch = useDispatch();
23696
23709
  useEffect(() => {
23697
23710
  (async () => {
@@ -23720,15 +23733,12 @@ function Notifications() {
23720
23733
  }) => acc + items.length, 0));
23721
23734
  }
23722
23735
  }, [userLanguage, notifications]);
23723
- if (notificationsLang)
23736
+ if (!notificationsLang)
23724
23737
  return null;
23725
23738
  return /* @__PURE__ */ jsx(animated.div, {
23726
23739
  className: cn("col-auto", "pe-lg-0", "order-lg-4", {
23727
23740
  "hd-ringing": !notified
23728
23741
  }),
23729
- onClick: () => {
23730
- setNotified(true);
23731
- },
23732
23742
  id: "hd-notifications",
23733
23743
  style: styles,
23734
23744
  children: /* @__PURE__ */ jsx("div", {
@@ -23741,8 +23751,11 @@ function Notifications() {
23741
23751
  className: "btn px-0 py-2 dropdown-toggle",
23742
23752
  type: "button",
23743
23753
  id: "hd-dropdown-notifications",
23744
- "aria-haspopup": "true",
23745
- "aria-expanded": "false",
23754
+ onClick: (e2) => {
23755
+ e2.stopPropagation();
23756
+ setNotified(true);
23757
+ setShowNotifications(!showNotifications);
23758
+ },
23746
23759
  children: [/* @__PURE__ */ jsx(commonThin.Bell, {
23747
23760
  className: "hd-icon hd-icon-bell"
23748
23761
  }), notificationsCount > 0 && /* @__PURE__ */ jsxs(Fragment, {
@@ -23759,7 +23772,10 @@ function Notifications() {
23759
23772
  })]
23760
23773
  }), /* @__PURE__ */ jsx("ul", {
23761
23774
  className: "dropdown-menu",
23762
- "aria-labelledby": "hd-dropdown-notifications",
23775
+ style: showNotifications ? {
23776
+ display: "block"
23777
+ } : {},
23778
+ ref,
23763
23779
  children: notificationsLang.map((notification) => {
23764
23780
  const {
23765
23781
  title,
@@ -26390,9 +26406,11 @@ function UserLanguage(props) {
26390
26406
  onClick: (e2) => {
26391
26407
  e2.preventDefault();
26392
26408
  e2.stopPropagation();
26393
- dispatch(setUserLanguage(code));
26394
- if (typeof handleLanguageChange === "function") {
26395
- handleLanguageChange(code);
26409
+ if (code !== selectedLanguage) {
26410
+ dispatch(setUserLanguage(code));
26411
+ if (typeof handleLanguageChange === "function") {
26412
+ handleLanguageChange(code);
26413
+ }
26396
26414
  }
26397
26415
  dispatch(removeSubMenu(label));
26398
26416
  },
@@ -26875,18 +26893,12 @@ function Header(props) {
26875
26893
  if (userLanguage) {
26876
26894
  dispatch(setUserLanguage(userLanguage));
26877
26895
  }
26878
- }, []);
26879
- useEffect(() => {
26880
26896
  if (hotelInfo) {
26881
26897
  dispatch(setHotelInfo(hotelInfo));
26882
26898
  }
26883
- }, []);
26884
- useEffect(() => {
26885
26899
  if (userInfo) {
26886
26900
  dispatch(setUserInfo(userInfo));
26887
26901
  }
26888
- }, []);
26889
- useEffect(() => {
26890
26902
  if (i18nFeed) {
26891
26903
  dispatch(setI18nFeed(i18nFeed));
26892
26904
  }