@redneckz/wildless-cms-uni-blocks 0.7.5 → 0.7.6

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 (117) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +103 -19
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/Tabs/LinkTab.d.ts +1 -0
  5. package/bundle/components/Tabs/ScrollableTabs.d.ts +8 -0
  6. package/bundle/components/Tabs/TabsContent.d.ts +12 -0
  7. package/bundle/components/Tabs/renderGroupTab.d.ts +2 -2
  8. package/bundle/components/Tabs/renderTab.d.ts +2 -1
  9. package/bundle/components/Tabs/tabItemClasses.d.ts +6 -1
  10. package/dist/components/Tabs/LinkTab.d.ts +1 -0
  11. package/dist/components/Tabs/LinkTab.js +2 -2
  12. package/dist/components/Tabs/LinkTab.js.map +1 -1
  13. package/dist/components/Tabs/ScrollableTabs.d.ts +8 -0
  14. package/dist/components/Tabs/ScrollableTabs.js +24 -0
  15. package/dist/components/Tabs/ScrollableTabs.js.map +1 -0
  16. package/dist/components/Tabs/Tabs.js +9 -2
  17. package/dist/components/Tabs/Tabs.js.map +1 -1
  18. package/dist/components/Tabs/TabsContent.d.ts +12 -0
  19. package/dist/components/Tabs/renderGroupTab.d.ts +2 -2
  20. package/dist/components/Tabs/renderGroupTab.js +12 -4
  21. package/dist/components/Tabs/renderGroupTab.js.map +1 -1
  22. package/dist/components/Tabs/renderTab.d.ts +2 -1
  23. package/dist/components/Tabs/renderTab.js +4 -6
  24. package/dist/components/Tabs/renderTab.js.map +1 -1
  25. package/dist/components/Tabs/tabItemClasses.d.ts +6 -1
  26. package/dist/components/Tabs/tabItemClasses.js +61 -2
  27. package/dist/components/Tabs/tabItemClasses.js.map +1 -1
  28. package/dist/setup-fixture.js +0 -1
  29. package/dist/setup-fixture.js.map +1 -1
  30. package/lib/common.css +1 -1
  31. package/lib/components/Tabs/LinkTab.d.ts +1 -0
  32. package/lib/components/Tabs/LinkTab.js +3 -3
  33. package/lib/components/Tabs/LinkTab.js.map +1 -1
  34. package/lib/components/Tabs/ScrollableTabs.d.ts +8 -0
  35. package/lib/components/Tabs/ScrollableTabs.js +22 -0
  36. package/lib/components/Tabs/ScrollableTabs.js.map +1 -0
  37. package/lib/components/Tabs/Tabs.fixture.d.ts +1 -0
  38. package/lib/components/Tabs/Tabs.js +9 -2
  39. package/lib/components/Tabs/Tabs.js.map +1 -1
  40. package/lib/components/Tabs/TabsContent.d.ts +12 -0
  41. package/lib/components/Tabs/renderGroupTab.d.ts +2 -2
  42. package/lib/components/Tabs/renderGroupTab.js +13 -5
  43. package/lib/components/Tabs/renderGroupTab.js.map +1 -1
  44. package/lib/components/Tabs/renderTab.d.ts +2 -1
  45. package/lib/components/Tabs/renderTab.js +4 -6
  46. package/lib/components/Tabs/renderTab.js.map +1 -1
  47. package/lib/components/Tabs/tabItemClasses.d.ts +6 -1
  48. package/lib/components/Tabs/tabItemClasses.js +58 -1
  49. package/lib/components/Tabs/tabItemClasses.js.map +1 -1
  50. package/lib/setup-fixture.js +0 -1
  51. package/lib/setup-fixture.js.map +1 -1
  52. package/mobile/bundle/bundle.umd.js +1 -1
  53. package/mobile/bundle/bundle.umd.min.js +1 -1
  54. package/mobile/bundle/components/Tabs/LinkTab.d.ts +1 -0
  55. package/mobile/bundle/components/Tabs/ScrollableTabs.d.ts +8 -0
  56. package/mobile/bundle/components/Tabs/TabsContent.d.ts +12 -0
  57. package/mobile/bundle/components/Tabs/renderGroupTab.d.ts +2 -2
  58. package/mobile/bundle/components/Tabs/renderTab.d.ts +2 -1
  59. package/mobile/bundle/components/Tabs/tabItemClasses.d.ts +6 -1
  60. package/mobile/dist/components/Tabs/LinkTab.d.ts +1 -0
  61. package/mobile/dist/components/Tabs/LinkTab.js +2 -2
  62. package/mobile/dist/components/Tabs/LinkTab.js.map +1 -1
  63. package/mobile/dist/components/Tabs/ScrollableTabs.d.ts +8 -0
  64. package/mobile/dist/components/Tabs/ScrollableTabs.js +24 -0
  65. package/mobile/dist/components/Tabs/ScrollableTabs.js.map +1 -0
  66. package/mobile/dist/components/Tabs/Tabs.js +9 -2
  67. package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
  68. package/mobile/dist/components/Tabs/TabsContent.d.ts +12 -0
  69. package/mobile/dist/components/Tabs/renderGroupTab.d.ts +2 -2
  70. package/mobile/dist/components/Tabs/renderGroupTab.js +12 -4
  71. package/mobile/dist/components/Tabs/renderGroupTab.js.map +1 -1
  72. package/mobile/dist/components/Tabs/renderTab.d.ts +2 -1
  73. package/mobile/dist/components/Tabs/renderTab.js +4 -6
  74. package/mobile/dist/components/Tabs/renderTab.js.map +1 -1
  75. package/mobile/dist/components/Tabs/tabItemClasses.d.ts +6 -1
  76. package/mobile/dist/components/Tabs/tabItemClasses.js +61 -2
  77. package/mobile/dist/components/Tabs/tabItemClasses.js.map +1 -1
  78. package/mobile/dist/setup-fixture.js +0 -1
  79. package/mobile/dist/setup-fixture.js.map +1 -1
  80. package/mobile/lib/components/Tabs/LinkTab.d.ts +1 -0
  81. package/mobile/lib/components/Tabs/LinkTab.js +3 -3
  82. package/mobile/lib/components/Tabs/LinkTab.js.map +1 -1
  83. package/mobile/lib/components/Tabs/ScrollableTabs.d.ts +8 -0
  84. package/mobile/lib/components/Tabs/ScrollableTabs.js +22 -0
  85. package/mobile/lib/components/Tabs/ScrollableTabs.js.map +1 -0
  86. package/mobile/lib/components/Tabs/Tabs.js +9 -2
  87. package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
  88. package/mobile/lib/components/Tabs/TabsContent.d.ts +12 -0
  89. package/mobile/lib/components/Tabs/renderGroupTab.d.ts +2 -2
  90. package/mobile/lib/components/Tabs/renderGroupTab.js +13 -5
  91. package/mobile/lib/components/Tabs/renderGroupTab.js.map +1 -1
  92. package/mobile/lib/components/Tabs/renderTab.d.ts +2 -1
  93. package/mobile/lib/components/Tabs/renderTab.js +4 -6
  94. package/mobile/lib/components/Tabs/renderTab.js.map +1 -1
  95. package/mobile/lib/components/Tabs/tabItemClasses.d.ts +6 -1
  96. package/mobile/lib/components/Tabs/tabItemClasses.js +58 -1
  97. package/mobile/lib/components/Tabs/tabItemClasses.js.map +1 -1
  98. package/mobile/lib/setup-fixture.js +0 -1
  99. package/mobile/lib/setup-fixture.js.map +1 -1
  100. package/mobile/src/components/Tabs/LinkTab.tsx +5 -13
  101. package/mobile/src/components/Tabs/ScrollableTabs.tsx +55 -0
  102. package/mobile/src/components/Tabs/Tabs.tsx +26 -4
  103. package/mobile/src/components/Tabs/TabsContent.ts +13 -0
  104. package/mobile/src/components/Tabs/renderGroupTab.tsx +30 -20
  105. package/mobile/src/components/Tabs/renderTab.tsx +8 -5
  106. package/mobile/src/components/Tabs/tabItemClasses.ts +65 -1
  107. package/mobile/src/setup-fixture.ts +0 -1
  108. package/package.json +1 -1
  109. package/src/components/Tabs/LinkTab.tsx +5 -13
  110. package/src/components/Tabs/ScrollableTabs.tsx +55 -0
  111. package/src/components/Tabs/Tabs.fixture.tsx +22 -0
  112. package/src/components/Tabs/Tabs.tsx +26 -4
  113. package/src/components/Tabs/TabsContent.ts +13 -0
  114. package/src/components/Tabs/renderGroupTab.tsx +30 -20
  115. package/src/components/Tabs/renderTab.tsx +8 -5
  116. package/src/components/Tabs/tabItemClasses.ts +65 -1
  117. package/src/setup-fixture.ts +0 -1
@@ -1606,7 +1606,7 @@
1606
1606
 
1607
1607
  const ITEMS_GAP = 4;
1608
1608
  const blurBaseStyle = 'absolute top-0 bottom-0 z-50 w-[84px] pointer-events-none';
1609
- const scrollButtonStyle = 'absolute top-[calc(50%-12px)] z-50';
1609
+ const scrollButtonStyle$1 = 'absolute top-[calc(50%-12px)] z-50';
1610
1610
  const Carousel = JSX(({ className = '', itemCount, visibleItemCount, isBlur = true, isCyclic = false, isPadding = true, ...rest }) => {
1611
1611
  const { blocks: childBlocks } = rest.block || {};
1612
1612
  const count = itemCount || childBlocks?.length || 0;
@@ -1626,7 +1626,7 @@
1626
1626
  'CarouselTariffsCard',
1627
1627
  'CarouselInvestmentCard',
1628
1628
  ];
1629
- const renderScrollButtons = ({ scrollLeft, scrollRight, canScrollLeft, canScrollRight, }) => (jsxs("div", { children: [canScrollLeft ? (jsx(ScrollLeftButton, { className: `${scrollButtonStyle} left-8`, onClick: scrollLeft })) : null, canScrollRight ? (jsx(ScrollRightButton, { className: `${scrollButtonStyle} right-8`, onClick: scrollRight })) : null] }));
1629
+ const renderScrollButtons = ({ scrollLeft, scrollRight, canScrollLeft, canScrollRight, }) => (jsxs("div", { children: [canScrollLeft ? (jsx(ScrollLeftButton, { className: `${scrollButtonStyle$1} left-8`, onClick: scrollLeft })) : null, canScrollRight ? (jsx(ScrollRightButton, { className: `${scrollButtonStyle$1} right-8`, onClick: scrollRight })) : null] }));
1630
1630
  const getPaddingStyle = (isPadding) => (isPadding ? 'p-12' : '');
1631
1631
 
1632
1632
  const BLOCK_CLASSES = 'absolute border border-solid border-gray w-full h-full';
@@ -3638,60 +3638,139 @@
3638
3638
  };
3639
3639
 
3640
3640
  const LINK_CLASSES = 'h-12 flex-1 flex items-center justify-center cursor-pointer';
3641
- const ACTIVE_LINK_CLASSES = 'bg-primary-main';
3642
3641
  const INACTIVE_LINK_CLASSES = 'group/btn bg-white';
3643
- const TEXT_CLASSES = 'font-sans text-m';
3642
+ const SCROLLABLE_ACTIVE_LINK_CLASSES = 'bg-white text-primary-main';
3643
+ const WIDESCREEN_ACTIVE_LINK_CLASSES = 'bg-primary-main text-white';
3644
+ const TEXT_CLASSES = 'font-sans text-m text-center';
3644
3645
  const ACTIVE_TEXT_CLASSES = 'text-white';
3645
3646
  const INACTIVE_TEXT_CLASSES = 'text-secondary-text group-hover/btn:text-primary-main';
3647
+ const WHITE_ACTIVE_TEXT_CLASSES = 'text-primary-main';
3648
+ const GROUP_TAB_CLASSES = {
3649
+ div: {
3650
+ scrollable: {
3651
+ active: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${SCROLLABLE_ACTIVE_LINK_CLASSES}`,
3652
+ default: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`,
3653
+ },
3654
+ default: {
3655
+ active: `${LINK_CLASSES} ${WIDESCREEN_ACTIVE_LINK_CLASSES} whitespace-nowrap`,
3656
+ default: `${LINK_CLASSES} ${INACTIVE_LINK_CLASSES} whitespace-nowrap`,
3657
+ },
3658
+ },
3659
+ text: {
3660
+ scrollable: {
3661
+ active: `h-full border-0 border-b-2`,
3662
+ default: ``,
3663
+ },
3664
+ default: {
3665
+ active: '',
3666
+ default: '',
3667
+ },
3668
+ },
3669
+ };
3670
+ const LINK_TAB_CLASSES = {
3671
+ link: {
3672
+ scrollable: {
3673
+ active: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${SCROLLABLE_ACTIVE_LINK_CLASSES}`,
3674
+ default: `inline-flex px-4 grow whitespace-nowrap ${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`,
3675
+ },
3676
+ default: {
3677
+ active: `${LINK_CLASSES} ${WIDESCREEN_ACTIVE_LINK_CLASSES}`,
3678
+ default: `${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`,
3679
+ },
3680
+ },
3681
+ text: {
3682
+ scrollable: {
3683
+ active: `${TEXT_CLASSES} flex items-center h-full border-0 border-b-2 ${WHITE_ACTIVE_TEXT_CLASSES}`,
3684
+ default: `${TEXT_CLASSES} ${INACTIVE_TEXT_CLASSES}`,
3685
+ },
3686
+ default: {
3687
+ active: `${TEXT_CLASSES} ${ACTIVE_TEXT_CLASSES}`,
3688
+ default: `${TEXT_CLASSES} ${INACTIVE_TEXT_CLASSES}`,
3689
+ },
3690
+ },
3691
+ };
3692
+ const getGroupTabClassName = (type, active, isScrollable) => {
3693
+ const styleType = isScrollable ? 'scrollable' : 'default';
3694
+ const styleActive = active ? 'active' : 'default';
3695
+ return GROUP_TAB_CLASSES[type][styleType][styleActive];
3696
+ };
3697
+ const getLinkTabClassName = (type, active, isScrollable) => {
3698
+ const styleType = isScrollable ? 'scrollable' : 'default';
3699
+ const styleActive = active ? 'active' : 'default';
3700
+ return LINK_TAB_CLASSES[type][styleType][styleActive];
3701
+ };
3646
3702
 
3647
3703
  const LinkTab = JSX((props) => {
3648
- const { tab, currentTab } = props;
3704
+ const { tab, currentTab, isScrollable = false } = props;
3649
3705
  const active = currentTab?.type === 'link' && currentTab.href === tab.href;
3650
3706
  const link = useLink();
3651
3707
  const adjustedProps = link(tab);
3652
- return (jsx("a", { role: "tab", className: `${LINK_CLASSES} ${active ? ACTIVE_LINK_CLASSES : INACTIVE_LINK_CLASSES}`, target: tab.target, href: adjustedProps.href, onClick: adjustedProps.onClick, children: jsx("span", { className: `${TEXT_CLASSES} ${active ? ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES}`, children: tab.text }) }));
3708
+ return (jsx("a", { role: "tab", className: getLinkTabClassName('link', active, isScrollable), target: tab.target, href: adjustedProps.href, onClick: adjustedProps.onClick, children: jsx("span", { className: getLinkTabClassName('text', active, isScrollable), children: tab.text }) }));
3653
3709
  });
3654
3710
 
3655
3711
  const BADGE_CLASSES = 'min-w-[22px] h-[22px] rounded-full text-xs ml-2 flex justify-center items-center';
3656
3712
  const ACTIVE_BADGE_CLASSES = 'bg-white/30 text-white';
3657
3713
  const INACTIVE_BADGE_CLASSES = 'bg-main-divider text-secondary-text group-hover/btn:text-primary-main';
3658
- const renderGroupTab = ({ page, currentTab, showCounter, onClick }) => (tab, i) => {
3714
+ const renderGroupTab = ({ page, currentTab, showCounter, onClick, isScrollable = false }) => (tab, i) => {
3659
3715
  const active = currentTab === tab;
3660
3716
  const count = tab.ref && page?.blocks
3661
3717
  ? page.blocks.filter((block) => block?.labels?.includes(tab.ref)).length
3662
3718
  : 0;
3663
- return (jsx("div", { className: `${LINK_CLASSES} ${active ? ACTIVE_LINK_CLASSES : INACTIVE_LINK_CLASSES}`, role: "tab", "aria-selected": active, onClick: () => onClick(tab), children: jsxs("div", { className: "flex flex-1 items-center justify-center", children: [tab?.title ? renderTitle$2(tab.title, active) : null, showCounter && count ? renderCount(count, active) : null] }) }, String(i)));
3719
+ return (jsx("div", { className: getGroupTabClassName('div', active, isScrollable), role: "tab", "aria-selected": active, onClick: () => onClick(tab), children: jsxs("div", { className: `flex flex-1 items-center justify-center ${getGroupTabClassName('text', active, isScrollable)}`, children: [renderTitle$2(tab.title, active, isScrollable), renderCount(showCounter, count, active)] }) }, `group-${String(i)}`));
3720
+ };
3721
+ const renderTitle$2 = (title, active, isScrollable) => {
3722
+ const activeClassName = active ? WHITE_ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES;
3723
+ const titleClassName = isScrollable
3724
+ ? `${TEXT_CLASSES} ${activeClassName}`
3725
+ : `${TEXT_CLASSES} ${active ? ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES}`;
3726
+ return title ? jsx("h3", { className: titleClassName, children: title }) : null;
3727
+ };
3728
+ const renderCount = (showCounter, count, active) => {
3729
+ return showCounter && count ? (jsx("div", { className: `${BADGE_CLASSES} ${active ? ACTIVE_BADGE_CLASSES : INACTIVE_BADGE_CLASSES}`, children: count })) : null;
3664
3730
  };
3665
- const renderTitle$2 = (title, active) => (jsx("h3", { className: `${TEXT_CLASSES} ${active ? ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES}`, children: title }));
3666
- const renderCount = (count, active) => (jsx("div", { className: `${BADGE_CLASSES} ${active ? ACTIVE_BADGE_CLASSES : INACTIVE_BADGE_CLASSES}`, children: count }));
3667
3731
 
3668
- const renderTab = ({ page, currentTab, showCounter, onClick }) =>
3669
- // Linter doesn't understand that switch processes all cases
3670
- // eslint-disable-next-line consistent-return
3671
- (tab, i) => {
3732
+ const renderTab = ({ page, currentTab, showCounter, onClick, isScrollable = false }) => (tab, i) => {
3672
3733
  const type = tab.type;
3673
3734
  if (!(type === 'group' || type === 'link')) {
3674
3735
  return null;
3675
3736
  }
3676
3737
  switch (type) {
3677
3738
  case 'group':
3678
- return renderGroupTab({ page, currentTab, showCounter, onClick })(tab, i);
3739
+ return renderGroupTab({ page, currentTab, showCounter, onClick, isScrollable })(tab, i);
3679
3740
  case 'link': {
3680
- return jsx(LinkTab, { tab: tab, currentTab: currentTab }, String(i));
3741
+ return (jsx(LinkTab, { tab: tab, currentTab: currentTab, isScrollable: isScrollable }, String(i)));
3681
3742
  }
3682
3743
  default:
3683
3744
  assertUnreachable(type);
3684
3745
  }
3746
+ return null;
3685
3747
  };
3686
3748
 
3749
+ const scrollButtonStyle = 'absolute z-50 top-0';
3750
+ const ScrollableTabs = JSX((props) => {
3751
+ const { tabs, onClick, currentTab, page, showCounter } = props;
3752
+ const [containerRef, scroll] = useSwipeListScroll({
3753
+ itemCount: tabs?.length || 0,
3754
+ isCyclic: false,
3755
+ });
3756
+ return (jsxs("div", { className: "relative max-w-full m-auto", children: [jsx("div", { className: `font-sans max-w-full w-full overflow-hidden relative bg-white`, children: jsx(SwipeListContainer, { containerRef: containerRef, snapAlign: "snap-start", onVisibleIndicesChange: scroll.handleVisibleIndicesChange, children: tabs?.map(renderTab({
3757
+ onClick,
3758
+ currentTab,
3759
+ showCounter,
3760
+ page,
3761
+ isScrollable: true,
3762
+ })) }) }), scroll.canScrollLeft ? (jsx(ScrollLeftButton, { className: `${scrollButtonStyle} left-6`, onClick: scroll.scrollLeft })) : null, scroll.canScrollRight ? (jsx(ScrollRightButton, { className: `${scrollButtonStyle} rotate-180 right-6`, onClick: scroll.scrollRight })) : null] }));
3763
+ });
3764
+
3687
3765
  const Tabs = JSX((props) => {
3688
- const { className = '', tabs, showCounter, isSticky, ...rest } = props;
3766
+ const { className = '', tabs, showCounter, isSticky, tabsMode, ...rest } = props;
3689
3767
  const [currentTab, setCurrentTab] = useState(tabs ? tabs[0] : undefined);
3690
3768
  useEffect(() => EventBus.inst.subscribe('tab', (event) => {
3691
3769
  const tab = tabs?.find(checkTab(event));
3692
3770
  if (event.type === 'link' && tab) {
3693
3771
  setCurrentTab(tab);
3694
3772
  }
3773
+ return [];
3695
3774
  }), [tabs]);
3696
3775
  useEffect(() => currentTab?.type === 'group'
3697
3776
  ? EventBus.inst.subject('tab', { label: currentTab.ref })
@@ -3702,7 +3781,12 @@
3702
3781
  }
3703
3782
  setCurrentTab(selectedTab);
3704
3783
  }, []);
3705
- return (jsx(BlockWrapper, { className: `${isSticky ? 'sticky top-1 z-20 ' : ''}box-border flex gap-x-1 ${className}`, role: "tablist", ...rest, children: tabs?.map(renderTab({ onClick: handleClick, currentTab, showCounter, ...rest })) }));
3784
+ return (jsx(BlockWrapper, { className: `relative box-border flex gap-x-1 w-full ${isSticky ? 'sticky top-1 z-20 ' : ''} ${className}`, role: "tablist", ...rest, children: tabsMode === 'scrollable' ? (jsx(ScrollableTabs, { tabs: tabs, onClick: handleClick, currentTab: currentTab, showCounter: showCounter, ...rest })) : (tabs?.map(renderTab({
3785
+ onClick: handleClick,
3786
+ currentTab,
3787
+ showCounter,
3788
+ ...rest,
3789
+ }))) }));
3706
3790
  });
3707
3791
  const checkTab = (event) => (_) => _.type === 'link' && _.href === `#${event.label}`;
3708
3792
 
@@ -4114,7 +4198,7 @@
4114
4198
  return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto" }) }));
4115
4199
  }
4116
4200
 
4117
- const packageVersion = "0.7.5";
4201
+ const packageVersion = "0.7.6";
4118
4202
 
4119
4203
  exports.Blocks = Blocks;
4120
4204
  exports.ContentPage = ContentPage;