@redneckz/wildless-cms-uni-blocks 0.4.2 → 0.4.3

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 (96) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +59 -31
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/dist/components/Tabs/Tabs.d.ts +2 -1
  5. package/dist/components/Tabs/Tabs.js +3 -3
  6. package/dist/components/Tabs/Tabs.js.map +1 -1
  7. package/dist/components/Tabs/TabsContent.d.ts +8 -2
  8. package/dist/components/Tabs/renderGroupTab.d.ts +4 -0
  9. package/dist/components/Tabs/renderGroupTab.js +18 -0
  10. package/dist/components/Tabs/renderGroupTab.js.map +1 -0
  11. package/dist/components/Tabs/renderLinkTab.d.ts +8 -0
  12. package/dist/components/Tabs/renderLinkTab.js +7 -0
  13. package/dist/components/Tabs/renderLinkTab.js.map +1 -0
  14. package/dist/components/Tabs/renderTab.d.ts +5 -5
  15. package/dist/components/Tabs/renderTab.js +14 -14
  16. package/dist/components/Tabs/renderTab.js.map +1 -1
  17. package/dist/components/Tabs/tabItemClasses.d.ts +6 -0
  18. package/dist/components/Tabs/tabItemClasses.js +9 -0
  19. package/dist/components/Tabs/tabItemClasses.js.map +1 -0
  20. package/dist/ui-kit/BlockWrapper.js +10 -1
  21. package/dist/ui-kit/BlockWrapper.js.map +1 -1
  22. package/lib/common.css +1 -1
  23. package/lib/components/Tabs/Tabs.d.ts +2 -1
  24. package/lib/components/Tabs/Tabs.js +3 -3
  25. package/lib/components/Tabs/Tabs.js.map +1 -1
  26. package/lib/components/Tabs/TabsContent.d.ts +8 -2
  27. package/lib/components/Tabs/renderGroupTab.d.ts +4 -0
  28. package/lib/components/Tabs/renderGroupTab.js +15 -0
  29. package/lib/components/Tabs/renderGroupTab.js.map +1 -0
  30. package/lib/components/Tabs/renderLinkTab.d.ts +8 -0
  31. package/lib/components/Tabs/renderLinkTab.js +4 -0
  32. package/lib/components/Tabs/renderLinkTab.js.map +1 -0
  33. package/lib/components/Tabs/renderTab.d.ts +5 -5
  34. package/lib/components/Tabs/renderTab.js +14 -14
  35. package/lib/components/Tabs/renderTab.js.map +1 -1
  36. package/lib/components/Tabs/tabItemClasses.d.ts +6 -0
  37. package/lib/components/Tabs/tabItemClasses.js +7 -0
  38. package/lib/components/Tabs/tabItemClasses.js.map +1 -0
  39. package/lib/ui-kit/BlockWrapper.js +10 -1
  40. package/lib/ui-kit/BlockWrapper.js.map +1 -1
  41. package/mobile/bundle/bundle.umd.js +10 -1
  42. package/mobile/bundle/bundle.umd.min.js +1 -1
  43. package/mobile/dist/components/Tabs/Tabs.d.ts +2 -1
  44. package/mobile/dist/components/Tabs/Tabs.js +3 -3
  45. package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
  46. package/mobile/dist/components/Tabs/TabsContent.d.ts +8 -2
  47. package/mobile/dist/components/Tabs/renderGroupTab.d.ts +4 -0
  48. package/mobile/dist/components/Tabs/renderGroupTab.js +18 -0
  49. package/mobile/dist/components/Tabs/renderGroupTab.js.map +1 -0
  50. package/mobile/dist/components/Tabs/renderLinkTab.d.ts +8 -0
  51. package/mobile/dist/components/Tabs/renderLinkTab.js +7 -0
  52. package/mobile/dist/components/Tabs/renderLinkTab.js.map +1 -0
  53. package/mobile/dist/components/Tabs/renderTab.d.ts +5 -5
  54. package/mobile/dist/components/Tabs/renderTab.js +14 -14
  55. package/mobile/dist/components/Tabs/renderTab.js.map +1 -1
  56. package/mobile/dist/components/Tabs/tabItemClasses.d.ts +6 -0
  57. package/mobile/dist/components/Tabs/tabItemClasses.js +9 -0
  58. package/mobile/dist/components/Tabs/tabItemClasses.js.map +1 -0
  59. package/mobile/dist/ui-kit/BlockWrapper.js +10 -1
  60. package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
  61. package/mobile/lib/components/Tabs/Tabs.d.ts +2 -1
  62. package/mobile/lib/components/Tabs/Tabs.js +3 -3
  63. package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
  64. package/mobile/lib/components/Tabs/TabsContent.d.ts +8 -2
  65. package/mobile/lib/components/Tabs/renderGroupTab.d.ts +4 -0
  66. package/mobile/lib/components/Tabs/renderGroupTab.js +15 -0
  67. package/mobile/lib/components/Tabs/renderGroupTab.js.map +1 -0
  68. package/mobile/lib/components/Tabs/renderLinkTab.d.ts +8 -0
  69. package/mobile/lib/components/Tabs/renderLinkTab.js +4 -0
  70. package/mobile/lib/components/Tabs/renderLinkTab.js.map +1 -0
  71. package/mobile/lib/components/Tabs/renderTab.d.ts +5 -5
  72. package/mobile/lib/components/Tabs/renderTab.js +14 -14
  73. package/mobile/lib/components/Tabs/renderTab.js.map +1 -1
  74. package/mobile/lib/components/Tabs/tabItemClasses.d.ts +6 -0
  75. package/mobile/lib/components/Tabs/tabItemClasses.js +7 -0
  76. package/mobile/lib/components/Tabs/tabItemClasses.js.map +1 -0
  77. package/mobile/lib/ui-kit/BlockWrapper.js +10 -1
  78. package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
  79. package/mobile/src/components/Tabs/Tabs.example.json +3 -3
  80. package/mobile/src/components/Tabs/Tabs.tsx +5 -4
  81. package/mobile/src/components/Tabs/TabsContent.ts +9 -2
  82. package/mobile/src/components/Tabs/renderGroupTab.tsx +51 -0
  83. package/mobile/src/components/Tabs/renderLinkTab.tsx +25 -0
  84. package/mobile/src/components/Tabs/renderTab.tsx +18 -38
  85. package/mobile/src/components/Tabs/tabItemClasses.ts +7 -0
  86. package/mobile/src/ui-kit/BlockWrapper.tsx +12 -1
  87. package/package.json +1 -1
  88. package/src/components/Tabs/Tabs.example.json +3 -3
  89. package/src/components/Tabs/Tabs.fixture.tsx +3 -3
  90. package/src/components/Tabs/Tabs.tsx +5 -4
  91. package/src/components/Tabs/TabsContent.ts +9 -2
  92. package/src/components/Tabs/renderGroupTab.tsx +51 -0
  93. package/src/components/Tabs/renderLinkTab.tsx +25 -0
  94. package/src/components/Tabs/renderTab.tsx +18 -38
  95. package/src/components/Tabs/tabItemClasses.ts +7 -0
  96. package/src/ui-kit/BlockWrapper.tsx +12 -1
@@ -261,13 +261,22 @@
261
261
  const { IntersectionObserverTag } = context;
262
262
  const [shouldRenderBlock, setShouldRenderBlock] = useState(true);
263
263
  useEffect(() => EventBus.inst.subscribe('tab', (event) => {
264
- setShouldRenderBlock(!labels?.length || !event.label || labels.includes(event.label));
264
+ if (event.type === 'group') {
265
+ setShouldRenderBlock(!labels?.length || !event.label || labels.includes(event.label));
266
+ }
267
+ else {
268
+ setShouldRenderBlock(true);
269
+ scrollToBlock(event.label);
270
+ }
265
271
  }), [labels]);
266
272
  if (!shouldRenderBlock) {
267
273
  return null;
268
274
  }
269
275
  return anchor ? (jsx(IntersectionObserverTag, { tag: tag, className: className, observerCallback: changeHashOnObserve, observerOptions: { threshold: 1 }, anchor: anchor, children: children })) : (jsx(Tag, { className: className, children: children }));
270
276
  });
277
+ function scrollToBlock(label) {
278
+ setTimeout(() => globalThis.document.getElementById(`#${label}`)?.scrollIntoView({ behavior: 'smooth' }));
279
+ }
271
280
 
272
281
  const HEADING_STYLE_MAP = {
273
282
  h0: 'text-h0',
@@ -1993,9 +2002,9 @@
1993
2002
  transparent: 'text-white',
1994
2003
  };
1995
2004
  const Logo = JSX(({ className = '', href, logo, children = logo?.title, targetBlank, bgColor = 'bg-white', hideTitle, }) => {
1996
- return (jsxs("a", { className: `inline-flex items-center font-sans no-underline ${className}`, href: href || '/', target: targetBlank ? '_blank' : '_self', "aria-label": logo?.title || 'Россельхозбанк', children: [logo?.image?.src ? (jsx(Img, { image: logo.image, className: SVG_COLOR[bgColor], width: "40", height: "45", asSVG: true })) : (jsx(Img, { image: { icon: 'Logo' }, className: `${SVG_COLOR[bgColor]} w-10`, width: "40", height: "45", asSVG: true })), hideTitle ? null : renderTitle(children, bgColor, logo?.title)] }));
2005
+ return (jsxs("a", { className: `inline-flex items-center font-sans no-underline ${className}`, href: href || '/', target: targetBlank ? '_blank' : '_self', "aria-label": logo?.title || 'Россельхозбанк', children: [logo?.image?.src ? (jsx(Img, { image: logo.image, className: SVG_COLOR[bgColor], width: "40", height: "45", asSVG: true })) : (jsx(Img, { image: { icon: 'Logo' }, className: `${SVG_COLOR[bgColor]} w-10`, width: "40", height: "45", asSVG: true })), hideTitle ? null : renderTitle$1(children, bgColor, logo?.title)] }));
1997
2006
  });
1998
- const renderTitle = (children, bgColor, title) => {
2007
+ const renderTitle$1 = (children, bgColor, title) => {
1999
2008
  const text = children || title || 'Россельхозбанк';
2000
2009
  return jsx("span", { className: `${TEXT_COLOR[bgColor]} font-medium ml-2.5`, children: text });
2001
2010
  };
@@ -2194,12 +2203,12 @@
2194
2203
  const { className = '', tabs, currentTag, isShowCounter = false, onTabClick } = props;
2195
2204
  return (jsx("div", { className: `box-border flex gap-x-1 h-14 ${className}`, role: "tablist", children: tabs?.map(renderTab$2({ currentTag, isShowCounter, onTabClick })) }));
2196
2205
  });
2197
- const badgeStyle$1 = 'min-w-[22px] w-[22px] h-[22px] rounded-full text-xs-light ml-2';
2206
+ const badgeStyle = 'min-w-[22px] w-[22px] h-[22px] rounded-full text-xs-light ml-2';
2198
2207
  const renderTab$2 = ({ currentTag, isShowCounter, onTabClick }) => (tab, i) => {
2199
2208
  const isActive = currentTag === tab.tag;
2200
2209
  const tabBg = isActive ? 'bg-primary-main' : 'group bg-white';
2201
2210
  const tabText = `text-m-light ${isActive ? 'text-white' : 'text-secondary-text group-hover:text-primary-main'}`;
2202
- const counterBlockStyle = `${badgeStyle$1}
2211
+ const counterBlockStyle = `${badgeStyle}
2203
2212
  ${isActive
2204
2213
  ? 'bg-white/30 text-white'
2205
2214
  : 'bg-main-divider text-secondary-text group-hover:text-primary-main'}`;
@@ -2230,22 +2239,22 @@
2230
2239
  isHrefActive(topItem.href, router) ||
2231
2240
  checkIsHrefSameOrigin(topItem.href, router);
2232
2241
 
2233
- const TEXT_CLASSES$2 = 'font-sans text-s-light';
2234
- const LINK_CLASSES$1 = 'inline-block border border-solid bg-transparent text-center no-underline';
2242
+ const TEXT_CLASSES$3 = 'font-sans text-s-light';
2243
+ const LINK_CLASSES$2 = 'inline-block border border-solid bg-transparent text-center no-underline';
2235
2244
  const TopItem = JSX(({ className = '', text, href, target, active, flat, onClick, children, ariaLabel, bgColor = 'bg-white', }) => (jsx("a", { className: `${getLinkClasses$1(bgColor, active, flat)} ${className}`, href: href, target: target, onClick: onClick, rel: "noopener noreferrer", "aria-label": ariaLabel, children: jsx("span", { className: getTextClasses$2(bgColor, active, flat), children: text || children }) })));
2236
2245
  const getLinkClasses$1 = (bgColor, active = false, flat = false) => {
2237
2246
  let classes = 'border-transparent';
2238
2247
  if (active) {
2239
2248
  classes = `rounded-md ${bgColor === 'bg-white' ? 'border-primary-main' : 'border-white'}`;
2240
2249
  }
2241
- return `${classes} ${LINK_CLASSES$1} ${flat ? '' : 'px-4 py-2'}`;
2250
+ return `${classes} ${LINK_CLASSES$2} ${flat ? '' : 'px-4 py-2'}`;
2242
2251
  };
2243
2252
  const getTextClasses$2 = (bgColor, active = false, flat = false) => {
2244
2253
  if (bgColor !== 'bg-white') {
2245
- return `text-white ${TEXT_CLASSES$2}`;
2254
+ return `text-white ${TEXT_CLASSES$3}`;
2246
2255
  }
2247
2256
  const nonActiveAtoms = `${flat ? 'text-primary-text' : 'text-secondary-text'} hover:text-primary-main`;
2248
- return `${active ? 'text-primary-main' : nonActiveAtoms} ${TEXT_CLASSES$2}`;
2257
+ return `${active ? 'text-primary-main' : nonActiveAtoms} ${TEXT_CLASSES$3}`;
2249
2258
  };
2250
2259
 
2251
2260
  const DaData = DaDataAPI('https://10.80.4.9');
@@ -2292,7 +2301,7 @@
2292
2301
  : undefined;
2293
2302
  };
2294
2303
 
2295
- const TEXT_CLASSES$1 = 'font-sans text-l-light';
2304
+ const TEXT_CLASSES$2 = 'font-sans text-l-light';
2296
2305
  const BORDER_CLASSES = 'absolute left-0 -bottom-3 w-full h-[2px]';
2297
2306
  const HeaderItem = JSX(({ className = '', text, href, target, active, onClick, children, bgColor = 'bg-white', dataItemName, }) => (jsxs("a", { className: `relative inline-block bg-transparent text-center no-underline ${className}`, href: href, target: target, onClick: onClick, "data-item-name": dataItemName, children: [jsx("span", { className: getTextClasses$1(bgColor, active), children: text || children }), active ? jsx("div", { className: getBorderClasses(bgColor, active) }) : null] })));
2298
2307
  const getTextClasses$1 = (bgColor, active = false) => {
@@ -2300,7 +2309,7 @@
2300
2309
  if (bgColor === 'bg-white') {
2301
2310
  classes = active ? 'text-primary-main' : 'text-primary-text hover:text-primary-main';
2302
2311
  }
2303
- return `${classes} ${TEXT_CLASSES$1}`;
2312
+ return `${classes} ${TEXT_CLASSES$2}`;
2304
2313
  };
2305
2314
  const getBorderClasses = (bgColor, active = false) => {
2306
2315
  if (!active) {
@@ -2469,16 +2478,16 @@
2469
2478
  .map((button, i) => (jsx(NavigationItem, { className: "first:rounded-tl-md first:rounded-bl-md last:rounded-tr-md last:rounded-br-md", isActive: button === activeButton, ...useLink({ router, handlerDecorator }, button) }, String(i)))) })) : null] }));
2470
2479
  });
2471
2480
 
2472
- const TEXT_CLASSES = 'font-sans text-m';
2473
- const LINK_CLASSES = 'flex-1 flex items-center justify-center cursor-pointer';
2481
+ const TEXT_CLASSES$1 = 'font-sans text-m';
2482
+ const LINK_CLASSES$1 = 'flex-1 flex items-center justify-center cursor-pointer';
2474
2483
  const NavigatorTabItem = JSX(({ className = '', text, active, onClick, href, target = '_self', children }) => (jsx("a", { className: getLinkClasses(className, active), target: target, href: href, onClick: onClick, children: jsx("span", { className: getTextClasses(active), children: text || children }) })));
2475
2484
  const getLinkClasses = (className, active = false) => {
2476
2485
  const classes = active ? 'bg-primary-main' : 'group bg-white';
2477
- return `${classes} ${LINK_CLASSES} ${className}`;
2486
+ return `${classes} ${LINK_CLASSES$1} ${className}`;
2478
2487
  };
2479
2488
  const getTextClasses = (active = false) => {
2480
2489
  const classes = active ? 'text-white' : 'text-secondary-text group-hover:text-primary-main ';
2481
- return `${classes} ${TEXT_CLASSES}`;
2490
+ return `${classes} ${TEXT_CLASSES$1}`;
2482
2491
  };
2483
2492
 
2484
2493
  const NavigatorTabs = JSX(({ className = '', navigatorTabs, context, ...rest }) => {
@@ -2876,30 +2885,49 @@
2876
2885
  return (jsxs("div", { className: "flex flex-col items-center justify-between text-center relative w-[276px]\n whitespace-pre-line overflow-hidden", children: [step?.label ? jsx("div", { className: "text-xl m-0 mt-4", children: step.label }) : null, step?.description ? (jsx("div", { className: `text-l-light ${styleMap.description} ${additionalMarginClass}`, children: step.description })) : null, step.button?.text && !isMainButton ? (jsx(Button, { className: "box-border mt-8 py-3 h-12 w-full max-w-[240px]", ...useLink({ router, handlerDecorator }, step.button), version: version, children: step.button.text })) : null] }, String(i)));
2877
2886
  };
2878
2887
 
2879
- const badgeStyle = 'min-w-[22px] w-[22px] h-[22px] rounded-full text-xs-light ml-2';
2880
- const renderTab = ({ onClick, currentTab, showCounter, page }) => (tab, i) => {
2881
- const isActive = currentTab === tab;
2882
- const tabBg = isActive ? 'bg-primary-main' : 'group bg-white';
2883
- const tabText = `text-m-light ${isActive ? 'text-white' : 'text-secondary-text group-hover:text-primary-main'}`;
2884
- const counterBlockStyle = `${badgeStyle}
2885
- ${isActive
2886
- ? 'bg-white/30 text-white'
2887
- : 'bg-main-divider text-secondary-text group-hover:text-primary-main'}`;
2888
- const count = tab.id
2889
- ? page?.blocks?.filter((block) => block?.labels?.includes(tab.id)).length
2888
+ const LINK_CLASSES = 'h-12 flex-1 flex items-center justify-center cursor-pointer';
2889
+ const ACTIVE_LINK_CLASSES = 'bg-primary-main';
2890
+ const INACTIVE_LINK_CLASSES = 'group bg-white';
2891
+ const TEXT_CLASSES = 'font-sans text-m';
2892
+ const ACTIVE_TEXT_CLASSES = 'text-white';
2893
+ const INACTIVE_TEXT_CLASSES = 'text-secondary-text group-hover:text-primary-main';
2894
+
2895
+ const BADGE_CLASSES = 'min-w-[22px] w-[22px] h-[22px] rounded-full text-xs ml-2';
2896
+ const ACTIVE_BADGE_CLASSES = 'bg-white/30 text-white';
2897
+ const INACTIVE_BADGE_CLASSES = 'bg-main-divider text-secondary-text group-hover:text-primary-main';
2898
+ const renderGroupTab = ({ onClick, currentTab, showCounter, page }) => (tab, i) => {
2899
+ const active = currentTab === tab;
2900
+ const count = tab.ref
2901
+ ? page?.blocks?.filter((block) => block?.labels?.includes(tab.ref)).length
2890
2902
  : page?.blocks?.length;
2891
- return (jsx("div", { className: `flex h-12 w-full flex-1 cursor-pointer mr-2 last:mr-0 box-content ${tabBg}`, role: "tab", "aria-selected": isActive, onClick: () => onClick(tab), children: jsxs("div", { className: "flex flex-1 items-center justify-center", children: [tab?.title ? jsx("h3", { className: tabText, children: tab?.title }) : null, showCounter ? (jsx("div", { className: `flex items-center justify-center ${counterBlockStyle}`, children: count })) : null] }) }, String(i)));
2903
+ 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(tab.title, active) : null, showCounter && count ? renderCount(count, active) : null] }) }, String(i)));
2904
+ };
2905
+ const renderTitle = (title, active) => (jsx("h3", { className: `${TEXT_CLASSES} ${active ? ACTIVE_TEXT_CLASSES : INACTIVE_TEXT_CLASSES}`, children: title }));
2906
+ const renderCount = (count, active) => (jsx("div", { className: `${BADGE_CLASSES} ${active ? ACTIVE_BADGE_CLASSES : INACTIVE_BADGE_CLASSES}`, children: count }));
2907
+
2908
+ const renderLinkTab = ({ text, onClick, href, target = '_self', i }) => (jsx("a", { className: `${LINK_CLASSES} ${INACTIVE_LINK_CLASSES}`, target: target, href: href, onClick: onClick, children: jsx("span", { className: `${TEXT_CLASSES} ${INACTIVE_TEXT_CLASSES}`, children: text }) }, String(i)));
2909
+
2910
+ const renderTab = ({ onClick, currentTab, showCounter, page, context }) => (tab, i) => {
2911
+ const { useRouter, handlerDecorator } = context;
2912
+ const router = useRouter();
2913
+ if (isURL(tab?.ref)) {
2914
+ return renderLinkTab({
2915
+ ...useLink({ router, handlerDecorator }, { href: tab.ref, text: tab.title }),
2916
+ i,
2917
+ });
2918
+ }
2919
+ return renderGroupTab({ onClick, currentTab, showCounter, page, context })(tab, i);
2892
2920
  };
2893
2921
 
2894
2922
  const Tabs = JSX((props) => {
2895
2923
  const { context, className, tabs, page, showCounter } = props;
2896
2924
  const [currentTab, setCurrentTab] = useState(tabs ? tabs[0] : undefined);
2897
- useEffect(() => EventBus.inst.subject('tab', { label: currentTab?.id }), [currentTab]);
2925
+ useEffect(() => EventBus.inst.subject('tab', { label: currentTab?.ref }), [currentTab]);
2898
2926
  const handleClick = (selectedTab) => {
2899
- EventBus.inst.fire('tab', { label: selectedTab.id });
2927
+ EventBus.inst.fire('tab', { type: selectedTab.type, label: selectedTab.ref });
2900
2928
  setCurrentTab(selectedTab);
2901
2929
  };
2902
- return (jsx(BlockWrapper, { context: context, className: `mb-2 box-border flex gap-x-1 ${className}`, role: "tablist", children: tabs?.map(renderTab({ onClick: handleClick, currentTab, page, showCounter })) }));
2930
+ return (jsx(BlockWrapper, { context: context, className: `mb-2 box-border flex gap-x-1 ${className}`, role: "tablist", children: tabs?.map(renderTab({ onClick: handleClick, currentTab, page, showCounter, context })) }));
2903
2931
  });
2904
2932
 
2905
2933
  const DIVIDER_CLASSES = 'border-main-divider border border-t-0 border-x-0';