@redneckz/wildless-cms-uni-blocks 0.14.254 → 0.14.255

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.
Files changed (42) hide show
  1. package/bundle/bundle.umd.js +1 -1
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/StickyBottomMenu/StickyBottomMenuItem.d.ts +2 -1
  4. package/bundle/data/StickyMobileData.d.ts +2 -2
  5. package/dist/components/StickyBottomMenu/StickyBottomMenu.mobile.js +61 -4
  6. package/dist/components/StickyBottomMenu/StickyBottomMenu.mobile.js.map +1 -1
  7. package/dist/components/StickyBottomMenu/StickyBottomMenuItem.d.ts +2 -1
  8. package/dist/components/StickyBottomMenu/StickyBottomMenuItem.js +1 -4
  9. package/dist/components/StickyBottomMenu/StickyBottomMenuItem.js.map +1 -1
  10. package/dist/data/StickyMobileData.d.ts +2 -2
  11. package/lib/common.css +1 -1
  12. package/lib/components/StickyBottomMenu/StickyBottomMenu.mobile.js +61 -4
  13. package/lib/components/StickyBottomMenu/StickyBottomMenu.mobile.js.map +1 -1
  14. package/lib/components/StickyBottomMenu/StickyBottomMenuItem.d.ts +2 -1
  15. package/lib/components/StickyBottomMenu/StickyBottomMenuItem.js +1 -4
  16. package/lib/components/StickyBottomMenu/StickyBottomMenuItem.js.map +1 -1
  17. package/lib/data/StickyMobileData.d.ts +2 -2
  18. package/mobile/bundle/bundle.umd.js +69 -18
  19. package/mobile/bundle/bundle.umd.min.js +1 -1
  20. package/mobile/bundle/components/StickyBottomMenu/StickyBottomMenuItem.d.ts +2 -1
  21. package/mobile/bundle/data/StickyMobileData.d.ts +2 -2
  22. package/mobile/dist/components/StickyBottomMenu/StickyBottomMenu.js +61 -4
  23. package/mobile/dist/components/StickyBottomMenu/StickyBottomMenu.js.map +1 -1
  24. package/mobile/dist/components/StickyBottomMenu/StickyBottomMenuItem.d.ts +2 -1
  25. package/mobile/dist/components/StickyBottomMenu/StickyBottomMenuItem.js +1 -4
  26. package/mobile/dist/components/StickyBottomMenu/StickyBottomMenuItem.js.map +1 -1
  27. package/mobile/dist/data/StickyMobileData.d.ts +2 -2
  28. package/mobile/lib/common.css +1 -1
  29. package/mobile/lib/components/StickyBottomMenu/StickyBottomMenu.js +61 -4
  30. package/mobile/lib/components/StickyBottomMenu/StickyBottomMenu.js.map +1 -1
  31. package/mobile/lib/components/StickyBottomMenu/StickyBottomMenuItem.d.ts +2 -1
  32. package/mobile/lib/components/StickyBottomMenu/StickyBottomMenuItem.js +1 -4
  33. package/mobile/lib/components/StickyBottomMenu/StickyBottomMenuItem.js.map +1 -1
  34. package/mobile/lib/data/StickyMobileData.d.ts +2 -2
  35. package/mobile/src/components/StickyBottomMenu/StickyBottomMenu.tsx +119 -11
  36. package/mobile/src/components/StickyBottomMenu/StickyBottomMenuItem.tsx +5 -10
  37. package/mobile/src/data/StickyMobileData.ts +2 -2
  38. package/package.json +1 -1
  39. package/src/components/StickyBottomMenu/StickyBottomMenu.fixture.mobile.tsx +2 -0
  40. package/src/components/StickyBottomMenu/StickyBottomMenu.mobile.tsx +119 -11
  41. package/src/components/StickyBottomMenu/StickyBottomMenuItem.tsx +5 -10
  42. package/src/data/StickyMobileData.ts +2 -2
@@ -4755,23 +4755,12 @@
4755
4755
  };
4756
4756
  const getIconSizeStyle = (size) => (size === 'normal' ? '38' : '24');
4757
4757
 
4758
- const isHrefActive = (router) => ({ href }) => !href ? false : withoutQuery(getRouterHref(href, router)).startsWith(withoutQuery(href));
4759
- const getRouterHref = (href, router) => isURL(href) ? router.href : router.pathname;
4760
-
4761
- const isTopItemActive = (router) => isHrefActive(projectSettings.BASE_PATH ? { pathname: projectSettings.BASE_PATH } : router);
4762
-
4763
- function useActiveRoute(items = []) {
4764
- const router = useRouter();
4765
- const activeIndex = items.findIndex(isTopItemActive(router));
4766
- return [activeIndex, items[activeIndex]];
4767
- }
4758
+ const CloseButton = JSX(({ className, onClose }) => (jsx("button", { className: style('flex justify-center items-center w-12 h-12 p-2xs bg-transparent border-none', className), onClick: onClose, title: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C", type: "button", children: jsx(Img, { image: { icon: 'CloseIcon' }, width: "24", height: "24" }) })));
4768
4759
 
4769
4760
  const StickyBottomMenuBurger = JSX(({ isActive, onClick }) => (jsxs("button", { className: style(isActive ? 'text-primary-main' : 'text-primary-text', `w-10 m-4 flex justify-center items-center flex-col text-xs cursor-pointer`), onClick: onClick, type: "button", children: [jsx(Icon, { className: "w-6 h-6", name: "BurgerIcon", iconVersion: isActive ? 'color' : 'black' }), "\u041C\u0435\u043D\u044E"] })));
4770
4761
 
4771
4762
  const StickyBottomMenuItem = JSX(({ isActive, item, onClick }) => {
4772
- const link = useLink({ isRemote: true });
4773
- const { href, onClick: handleClick } = link({ href: item?.href, onClick });
4774
- return (jsxs("a", { className: style(isActive ? 'text-primary-main' : 'text-primary-text', `w-10 m-4 flex justify-center items-center flex-col text-xs cursor-pointer`), href: href, target: "_self", title: item?.title || '', onClick: handleClick, children: [jsx(Icon, { className: "w-6 h-6", name: item?.icon?.icon, iconVersion: isActive ? 'color' : 'black' }), item?.title || ''] }));
4763
+ return (jsxs("div", { className: style(isActive ? 'text-primary-main' : 'text-primary-text', `w-10 m-4 flex justify-center items-center flex-col text-xs cursor-pointer`), title: item?.title || '', onClick: onClick, children: [jsx(Icon, { className: "w-6 h-6", name: item?.icon?.icon, iconVersion: isActive ? 'color' : 'black' }), item?.title || ''] }));
4775
4764
  });
4776
4765
 
4777
4766
  const isDialogOpen = (id, dialogs) => Boolean(dialogs.find((item) => item.id === id, id));
@@ -4815,7 +4804,16 @@
4815
4804
  return dialogs;
4816
4805
  };
4817
4806
 
4818
- const CloseButton = JSX(({ className, onClose }) => (jsx("button", { className: style('flex justify-center items-center w-12 h-12 p-2xs bg-transparent border-none', className), onClick: onClose, title: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C", type: "button", children: jsx(Img, { image: { icon: 'CloseIcon' }, width: "24", height: "24" }) })));
4807
+ const isHrefActive = (router) => ({ href }) => !href ? false : withoutQuery(getRouterHref(href, router)).startsWith(withoutQuery(href));
4808
+ const getRouterHref = (href, router) => isURL(href) ? router.href : router.pathname;
4809
+
4810
+ const isTopItemActive = (router) => isHrefActive(projectSettings.BASE_PATH ? { pathname: projectSettings.BASE_PATH } : router);
4811
+
4812
+ function useActiveRoute(items = []) {
4813
+ const router = useRouter();
4814
+ const activeIndex = items.findIndex(isTopItemActive(router));
4815
+ return [activeIndex, items[activeIndex]];
4816
+ }
4819
4817
 
4820
4818
  const Dialog = JSX(({ className, head, children, onClose }) => {
4821
4819
  const { close } = useDialogManager();
@@ -4878,16 +4876,69 @@
4878
4876
  };
4879
4877
 
4880
4878
  const EMPTY_MENU = [];
4879
+ // eslint-disable-next-line max-lines-per-function
4881
4880
  const StickyBottomMenu = UniBlock(({ sticky, ...rest }) => {
4882
4881
  const { menuItems = EMPTY_MENU } = sticky ?? {};
4883
4882
  const [isBurgerMenuDialogOpen, { toggle, close }] = useBurgerMenuDialog(rest.options?.page?.sitemap ?? {});
4884
- const [, activeItem] = useActiveRoute(menuItems);
4883
+ const popup = usePopupManager();
4885
4884
  const middleIdx = Math.floor(menuItems.length / 2);
4886
4885
  const leftItems = menuItems.slice(0, middleIdx);
4887
4886
  const rightItems = menuItems.slice(middleIdx);
4888
- return (jsx(BlockWrapper, { className: "h-[74px] z-[100] relative", defaultPadding: "p-0", ...rest, children: jsxs("div", { className: "ml-auto container bg-white flex justify-center shadow-blue-gray", children: [leftItems.map(renderMenuItem(activeItem, close)), jsx(StickyBottomMenuBurger, { isActive: isBurgerMenuDialogOpen, onClick: toggle }), rightItems.map(renderMenuItem(activeItem, close))] }) }));
4887
+ const [activeIndex, setActiveIndex] = useState(-1);
4888
+ const [currentItemPosition, setCurrentItemPosition] = useState('');
4889
+ const [popupState, { setFalse: setPopupClosed, setTrue: setPopupOpened }] = useBool();
4890
+ const closePopup = useCallback(() => {
4891
+ setPopupClosed();
4892
+ setActiveIndex(-1);
4893
+ setCurrentItemPosition('');
4894
+ popup.close();
4895
+ }, [popup]);
4896
+ const menuRef = useRef(null);
4897
+ const popupRef = useOutsideClick(closePopup);
4898
+ const openPopup = useCallback((index, itemsPosition) => {
4899
+ setPopupOpened();
4900
+ close();
4901
+ const menuDimensions = menuRef?.current?.getBoundingClientRect();
4902
+ popup.open(jsxs("div", { onClick: (e) => e.stopPropagation(), className: "sticky py-xl top-0 rounded-t-3xl bg-white z-10", children: [jsxs("div", { className: "container px-xl text-center text-h3", children: [itemsPosition === 'left' ? leftItems[index].title : rightItems[index].title, jsx(CloseButton, { className: "absolute top-0 right-0", onClose: closePopup })] }), jsx("div", { className: "bg-white text-l h-[70vh] overflow-y-auto no-scrollbar", ref: popupRef })] }), {
4903
+ top: -Math.max(globalThis.document?.documentElement?.clientHeight || 0, globalThis.innerHeight || 0) *
4904
+ 0.7 -
4905
+ 56,
4906
+ left: menuDimensions?.left || 0,
4907
+ width: menuDimensions?.width,
4908
+ });
4909
+ }, [close, popup]);
4910
+ const handleMenuItemClick = useCallback((index, itemsPosition) => {
4911
+ setCurrentItemPosition(itemsPosition);
4912
+ setActiveIndex(index);
4913
+ openPopup(index, itemsPosition);
4914
+ }, [openPopup]);
4915
+ useEffect(() => {
4916
+ if (!popupRef.current) {
4917
+ return;
4918
+ }
4919
+ if (!popupRef.current.shadowRoot) {
4920
+ popupRef.current?.attachShadow({ mode: 'open' });
4921
+ }
4922
+ const shadowRoot = popupRef.current.shadowRoot;
4923
+ if (!shadowRoot) {
4924
+ return;
4925
+ }
4926
+ if (currentItemPosition === 'left') {
4927
+ shadowRoot.innerHTML = leftItems[activeIndex]?.__html || '';
4928
+ }
4929
+ else {
4930
+ shadowRoot.innerHTML = rightItems[activeIndex]?.__html || '';
4931
+ }
4932
+ }, [activeIndex, currentItemPosition, popupState]);
4933
+ return (jsx(BlockWrapper, { className: "h-[74px] z-[100] relative", defaultPadding: "p-0", ...rest, children: jsxs("div", { ref: menuRef, className: "ml-auto container bg-white flex justify-center shadow-blue-gray", children: [leftItems.map(renderMenuItem(handleMenuItemClick, 'left', { activeIndex, currentItemPosition })), jsx(StickyBottomMenuBurger, { isActive: isBurgerMenuDialogOpen, onClick: toggle }), rightItems.map(renderMenuItem(handleMenuItemClick, 'right', { activeIndex, currentItemPosition }))] }) }));
4889
4934
  });
4890
- const renderMenuItem = (activeItem, close) => (_, i) => (jsx(StickyBottomMenuItem, { isActive: _ === activeItem, item: _, onClick: close }, _.href || String(i)));
4935
+ const renderMenuItem = (handleMenuItemClick, itemsPosition, currentActiveItem) => (_, i, arr) => {
4936
+ return (jsx(StickyBottomMenuItem, { item: _, isActive: arr[currentActiveItem.activeIndex]?.title === _?.title &&
4937
+ currentActiveItem.currentItemPosition === itemsPosition, onClick: (e) => {
4938
+ e.stopPropagation();
4939
+ handleMenuItemClick(i, itemsPosition);
4940
+ } }, _.title || String(i)));
4941
+ };
4891
4942
 
4892
4943
  const scrollButtonStyle = 'hidden sm:flex absolute z-40 top-0';
4893
4944
  const ScrollableTabsControl = JSX(({ className, items = [], value, onChange, tabsType }) => {
@@ -5479,7 +5530,7 @@
5479
5530
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
5480
5531
  });
5481
5532
 
5482
- const packageVersion = "0.14.253";
5533
+ const packageVersion = "0.14.254";
5483
5534
 
5484
5535
  exports.Blocks = Blocks;
5485
5536
  exports.ContentPage = ContentPage;