@redneckz/wildless-cms-uni-blocks 0.14.394 → 0.14.396

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 (167) hide show
  1. package/bundle/bundle.umd.js +156 -118
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/Header/HeaderTopMenu.d.ts +22 -0
  4. package/bundle/components/Header/HeaderTopMenuItem.d.ts +9 -0
  5. package/bundle/components/Tabs/renderTabs.d.ts +1 -1
  6. package/bundle/components/TabsLayout/renderTabsLayout.d.ts +1 -1
  7. package/bundle/ui-kit/TabsControl/TabsControlProps.d.ts +6 -1
  8. package/bundle/utils/getUrlParams.d.ts +1 -0
  9. package/dist/components/Header/DropdownMenu.js +1 -1
  10. package/dist/components/Header/DropdownMenu.js.map +1 -1
  11. package/dist/components/Header/Header.js +2 -4
  12. package/dist/components/Header/Header.js.map +1 -1
  13. package/dist/components/Header/HeaderSecondaryMenu.js +1 -1
  14. package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  15. package/dist/components/Header/HeaderSubMenu.js +1 -1
  16. package/dist/components/Header/HeaderSubMenu.js.map +1 -1
  17. package/dist/components/Header/HeaderTopMenu.d.ts +22 -0
  18. package/dist/components/Header/HeaderTopMenu.js +24 -0
  19. package/dist/components/Header/HeaderTopMenu.js.map +1 -0
  20. package/dist/components/Header/HeaderTopMenuItem.d.ts +9 -0
  21. package/dist/components/Header/HeaderTopMenuItem.js +20 -0
  22. package/dist/components/Header/HeaderTopMenuItem.js.map +1 -0
  23. package/dist/components/Tabs/Tabs.js +1 -1
  24. package/dist/components/Tabs/Tabs.js.map +1 -1
  25. package/dist/components/Tabs/renderTabs.d.ts +1 -1
  26. package/dist/components/TabsLayout/TabsLayout.js +17 -11
  27. package/dist/components/TabsLayout/TabsLayout.js.map +1 -1
  28. package/dist/components/TabsLayout/renderTabsLayout.d.ts +1 -1
  29. package/dist/ui-kit/BaseFiltration/useHotFilters.js +1 -1
  30. package/dist/ui-kit/BaseFiltration/useHotFilters.js.map +1 -1
  31. package/dist/ui-kit/TabsControl/ScrollableTabsControl.js +5 -5
  32. package/dist/ui-kit/TabsControl/ScrollableTabsControl.js.map +1 -1
  33. package/dist/ui-kit/TabsControl/TabsControl.js +1 -1
  34. package/dist/ui-kit/TabsControl/TabsControl.js.map +1 -1
  35. package/dist/ui-kit/TabsControl/TabsControlProps.d.ts +6 -1
  36. package/dist/utils/getUrlParams.d.ts +1 -0
  37. package/dist/utils/getUrlParams.js +8 -0
  38. package/dist/utils/getUrlParams.js.map +1 -0
  39. package/lib/common.css +1 -1
  40. package/lib/components/Header/DropdownMenu.js +1 -1
  41. package/lib/components/Header/DropdownMenu.js.map +1 -1
  42. package/lib/components/Header/Header.js +2 -4
  43. package/lib/components/Header/Header.js.map +1 -1
  44. package/lib/components/Header/HeaderSecondaryMenu.js +1 -1
  45. package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  46. package/lib/components/Header/HeaderSubMenu.js +1 -1
  47. package/lib/components/Header/HeaderSubMenu.js.map +1 -1
  48. package/lib/components/Header/HeaderTopMenu.d.ts +22 -0
  49. package/lib/components/Header/HeaderTopMenu.js +22 -0
  50. package/lib/components/Header/HeaderTopMenu.js.map +1 -0
  51. package/lib/components/Header/HeaderTopMenuItem.d.ts +9 -0
  52. package/lib/components/Header/HeaderTopMenuItem.js +18 -0
  53. package/lib/components/Header/HeaderTopMenuItem.js.map +1 -0
  54. package/lib/components/Tabs/Tabs.js +1 -1
  55. package/lib/components/Tabs/Tabs.js.map +1 -1
  56. package/lib/components/Tabs/renderTabs.d.ts +1 -1
  57. package/lib/components/TabsLayout/TabsLayout.fixture.d.ts +1 -0
  58. package/lib/components/TabsLayout/TabsLayout.js +17 -11
  59. package/lib/components/TabsLayout/TabsLayout.js.map +1 -1
  60. package/lib/components/TabsLayout/renderTabsLayout.d.ts +1 -1
  61. package/lib/ui-kit/BaseFiltration/useHotFilters.js +1 -1
  62. package/lib/ui-kit/BaseFiltration/useHotFilters.js.map +1 -1
  63. package/lib/ui-kit/TabsControl/ScrollableTabsControl.js +5 -5
  64. package/lib/ui-kit/TabsControl/ScrollableTabsControl.js.map +1 -1
  65. package/lib/ui-kit/TabsControl/TabsControl.js +1 -1
  66. package/lib/ui-kit/TabsControl/TabsControl.js.map +1 -1
  67. package/lib/ui-kit/TabsControl/TabsControlProps.d.ts +6 -1
  68. package/lib/utils/getUrlParams.d.ts +1 -0
  69. package/lib/utils/getUrlParams.js +5 -0
  70. package/lib/utils/getUrlParams.js.map +1 -0
  71. package/mobile/bundle/bundle.umd.js +35 -25
  72. package/mobile/bundle/bundle.umd.min.js +1 -1
  73. package/mobile/bundle/components/Header/HeaderTopMenu.d.ts +22 -0
  74. package/mobile/bundle/components/Header/HeaderTopMenuItem.d.ts +9 -0
  75. package/mobile/bundle/components/Tabs/renderTabs.d.ts +1 -1
  76. package/mobile/bundle/components/TabsLayout/renderTabsLayout.d.ts +1 -1
  77. package/mobile/bundle/ui-kit/TabsControl/TabsControlProps.d.ts +6 -1
  78. package/mobile/bundle/utils/getUrlParams.d.ts +1 -0
  79. package/mobile/dist/components/Header/DropdownMenu.js +1 -1
  80. package/mobile/dist/components/Header/DropdownMenu.js.map +1 -1
  81. package/mobile/dist/components/Header/HeaderSecondaryMenu.js +1 -1
  82. package/mobile/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  83. package/mobile/dist/components/Header/HeaderSubMenu.js +1 -1
  84. package/mobile/dist/components/Header/HeaderSubMenu.js.map +1 -1
  85. package/mobile/dist/components/Header/HeaderTopMenu.d.ts +22 -0
  86. package/mobile/dist/components/Header/HeaderTopMenu.js +24 -0
  87. package/mobile/dist/components/Header/HeaderTopMenu.js.map +1 -0
  88. package/mobile/dist/components/Header/HeaderTopMenuItem.d.ts +9 -0
  89. package/mobile/dist/components/Header/HeaderTopMenuItem.js +20 -0
  90. package/mobile/dist/components/Header/HeaderTopMenuItem.js.map +1 -0
  91. package/mobile/dist/components/Tabs/Tabs.js +1 -1
  92. package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
  93. package/mobile/dist/components/Tabs/renderTabs.d.ts +1 -1
  94. package/mobile/dist/components/TabsLayout/TabsLayout.js +17 -11
  95. package/mobile/dist/components/TabsLayout/TabsLayout.js.map +1 -1
  96. package/mobile/dist/components/TabsLayout/renderTabsLayout.d.ts +1 -1
  97. package/mobile/dist/ui-kit/BaseFiltration/useHotFilters.js +1 -1
  98. package/mobile/dist/ui-kit/BaseFiltration/useHotFilters.js.map +1 -1
  99. package/mobile/dist/ui-kit/TabsControl/ScrollableTabsControl.js +5 -5
  100. package/mobile/dist/ui-kit/TabsControl/ScrollableTabsControl.js.map +1 -1
  101. package/mobile/dist/ui-kit/TabsControl/TabsControl.js +1 -1
  102. package/mobile/dist/ui-kit/TabsControl/TabsControl.js.map +1 -1
  103. package/mobile/dist/ui-kit/TabsControl/TabsControlProps.d.ts +6 -1
  104. package/mobile/dist/utils/getUrlParams.d.ts +1 -0
  105. package/mobile/dist/utils/getUrlParams.js +8 -0
  106. package/mobile/dist/utils/getUrlParams.js.map +1 -0
  107. package/mobile/lib/common.css +1 -1
  108. package/mobile/lib/components/Header/DropdownMenu.js +1 -1
  109. package/mobile/lib/components/Header/DropdownMenu.js.map +1 -1
  110. package/mobile/lib/components/Header/HeaderSecondaryMenu.js +1 -1
  111. package/mobile/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  112. package/mobile/lib/components/Header/HeaderSubMenu.js +1 -1
  113. package/mobile/lib/components/Header/HeaderSubMenu.js.map +1 -1
  114. package/mobile/lib/components/Header/HeaderTopMenu.d.ts +22 -0
  115. package/mobile/lib/components/Header/HeaderTopMenu.js +22 -0
  116. package/mobile/lib/components/Header/HeaderTopMenu.js.map +1 -0
  117. package/mobile/lib/components/Header/HeaderTopMenuItem.d.ts +9 -0
  118. package/mobile/lib/components/Header/HeaderTopMenuItem.js +18 -0
  119. package/mobile/lib/components/Header/HeaderTopMenuItem.js.map +1 -0
  120. package/mobile/lib/components/Tabs/Tabs.js +1 -1
  121. package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
  122. package/mobile/lib/components/Tabs/renderTabs.d.ts +1 -1
  123. package/mobile/lib/components/TabsLayout/TabsLayout.js +17 -11
  124. package/mobile/lib/components/TabsLayout/TabsLayout.js.map +1 -1
  125. package/mobile/lib/components/TabsLayout/renderTabsLayout.d.ts +1 -1
  126. package/mobile/lib/ui-kit/BaseFiltration/useHotFilters.js +1 -1
  127. package/mobile/lib/ui-kit/BaseFiltration/useHotFilters.js.map +1 -1
  128. package/mobile/lib/ui-kit/TabsControl/ScrollableTabsControl.js +5 -5
  129. package/mobile/lib/ui-kit/TabsControl/ScrollableTabsControl.js.map +1 -1
  130. package/mobile/lib/ui-kit/TabsControl/TabsControl.js +1 -1
  131. package/mobile/lib/ui-kit/TabsControl/TabsControl.js.map +1 -1
  132. package/mobile/lib/ui-kit/TabsControl/TabsControlProps.d.ts +6 -1
  133. package/mobile/lib/utils/getUrlParams.d.ts +1 -0
  134. package/mobile/lib/utils/getUrlParams.js +5 -0
  135. package/mobile/lib/utils/getUrlParams.js.map +1 -0
  136. package/mobile/src/components/Header/DropdownMenu.tsx +1 -1
  137. package/mobile/src/components/Header/HeaderSecondaryMenu.tsx +8 -2
  138. package/mobile/src/components/Header/HeaderSubMenu.tsx +0 -1
  139. package/mobile/src/components/Header/HeaderTopMenu.tsx +96 -0
  140. package/mobile/src/components/Header/HeaderTopMenuItem.tsx +40 -0
  141. package/mobile/src/components/Tabs/Tabs.tsx +1 -1
  142. package/mobile/src/components/Tabs/renderTabs.tsx +1 -1
  143. package/mobile/src/components/TabsLayout/TabsLayout.tsx +26 -17
  144. package/mobile/src/components/TabsLayout/renderTabsLayout.tsx +1 -1
  145. package/mobile/src/ui-kit/BaseFiltration/useHotFilters.tsx +1 -1
  146. package/mobile/src/ui-kit/TabsControl/ScrollableTabsControl.tsx +13 -5
  147. package/mobile/src/ui-kit/TabsControl/TabsControl.tsx +2 -2
  148. package/mobile/src/ui-kit/TabsControl/TabsControlProps.ts +6 -1
  149. package/mobile/src/utils/getUrlParams.ts +5 -0
  150. package/package.json +1 -1
  151. package/src/components/Header/DropdownMenu.tsx +1 -1
  152. package/src/components/Header/Header.tsx +7 -10
  153. package/src/components/Header/HeaderSecondaryMenu.tsx +8 -2
  154. package/src/components/Header/HeaderSubMenu.tsx +0 -1
  155. package/src/components/Header/HeaderTopMenu.tsx +96 -0
  156. package/src/components/Header/HeaderTopMenuItem.tsx +40 -0
  157. package/src/components/Tabs/Tabs.tsx +1 -1
  158. package/src/components/Tabs/renderTabs.tsx +1 -1
  159. package/src/components/TabsLayout/TabsLayout.fixture.tsx +26 -2
  160. package/src/components/TabsLayout/TabsLayout.tsx +26 -17
  161. package/src/components/TabsLayout/renderTabsLayout.tsx +1 -1
  162. package/src/ui-kit/BaseFiltration/useHotFilters.tsx +1 -1
  163. package/src/ui-kit/TabsControl/ScrollableTabsControl.tsx +13 -5
  164. package/src/ui-kit/TabsControl/TabsControl.fixture.tsx +3 -3
  165. package/src/ui-kit/TabsControl/TabsControl.tsx +2 -2
  166. package/src/ui-kit/TabsControl/TabsControlProps.ts +6 -1
  167. package/src/utils/getUrlParams.ts +5 -0
@@ -4219,99 +4219,12 @@
4219
4219
  return isURL(href) ? router.href : joinPath(basePath, router.pathname);
4220
4220
  };
4221
4221
 
4222
- const TopItem = JSX(({ className = '', active, flat, children, data, ...rest }) => {
4223
- const link = useLink();
4224
- const { href, target, text, onClick } = link(rest);
4225
- return (jsx("a", { className: style(getLinkStyle(active, flat), className), href: href, target: target, onClick: onClick, rel: "noopener noreferrer", "aria-label": text, ...getAspectsAttributes(data), children: jsx("span", { suppressHydrationWarning: true, className: getTextStyle$1(active, flat), children: text || children }) }));
4226
- });
4227
- const getLinkStyle = (active = false, flat = false) => style('inline-block border border-solid bg-transparent text-center no-underline', active
4228
- ? 'rounded-md border-primary-main group-data-transparent:border-white'
4229
- : 'border-transparent', flat ? '' : 'px-m py-xs');
4230
- const getTextStyle$1 = (active = false, flat = false) => {
4231
- const activeFlatStyle = flat ? 'text-primary-text' : 'text-secondary-text';
4232
- return style('font-sans text-s font-light', active ? 'text-primary-main' : style(activeFlatStyle, 'hover:text-primary-main'), 'group-data-transparent:text-white group-data-transparent:hover:text-primary-hover');
4233
- };
4234
-
4235
- const groupBy = (list, keyGetter) => {
4236
- const result = new Map();
4237
- for (const item of list) {
4238
- const key = keyGetter(item);
4239
- const group = result.get(key) || [];
4240
- result.set(key, [...group, item]);
4241
- }
4242
- return result;
4243
- };
4244
-
4245
- const renderForeignOffices = (foreignOffices) => foreignOffices?.length ? (jsxs("div", { className: "sm:border-t sm:border-main-divider mt-2xs pt-2xs", children: [jsx("div", { className: "mb-m", children: jsx(Text, { size: "text-m", font: "font-light", color: "text-secondary-text", children: "\u041F\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u0430 \u0437\u0430 \u0440\u0443\u0431\u0435\u0436\u043E\u043C:" }) }), jsx("div", { className: "flex flex-col sm:flex-row gap-5xl", children: foreignOffices.map((office, i) => (jsx(ForeignOffice, { ...office }, String(i)))) })] })) : null;
4246
- const ForeignOffice = JSX(({ icon, ...rest }) => {
4247
- const link = useLink();
4248
- const { text, target, href, onClick } = link(rest);
4249
- return (jsxs("div", { className: "flex gap-s items-center", children: [icon ? jsx(Img, { pathPrefix: "/wcms-resources/", image: icon }) : null, text ? (jsx("a", { className: "hover:text-primary-hover", href: href, target: target, onClick: onClick, children: jsx(Text, { size: "text-l", font: "font-light", color: "text-primary-text", children: text }) })) : null] }));
4250
- });
4251
-
4252
- const renderRegion = (data, onChangeLocation) => (region) => region.name ? (jsx(LinkWrapper, { href: `/branches/${region.slug}`, className: "mb-xs sm:mb-2xs hover:text-primary-hover", onClick: () => onChangeLocation?.(region), data: getAspectsWithInclude(data, region.name), children: jsx(Text, { size: "text-l", font: "font-light", children: region.name }) }, String(region.id))) : null;
4253
-
4254
- const renderRegionGroup = (onChangeLocation, data) => ([letter, regions]) => (jsxs("div", { className: "break-inside-avoid mb-2xl w-56", children: [jsx("div", { className: "mb-s", children: jsx(Text, { size: "text-h6", children: letter }) }), regions.map(renderRegion(data, onChangeLocation))] }, letter));
4255
-
4256
- const SearchBar = JSX(({ className, searchTerm, onSearch }) => {
4257
- return (jsxs("form", { className: `font-sans relative ${className}`, children: [jsx("div", { className: "absolute rounded h-full flex items-center justify-center pl-m max-w-44 gap-s pointer-events-none", children: searchTerm ? null : (jsx("label", { htmlFor: "search-bar-input", className: `text-secondary-text `, children: "\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0444\u0438\u043B\u0438\u0430\u043B\u0430\u043C" })) }), jsx("input", { id: "search-bar-input", className: style(inputValidStyle, `h-12 pl-m w-full peer text-l text-black rounded-md box-border`), value: searchTerm, onChange: (e) => onSearch(e.target.value.toLowerCase()), type: "text", name: "location-search-bar-input" })] }));
4258
- });
4259
-
4260
- const SEARCH_TERM_MIN_LENGTH = 3;
4261
- const LocationDialog = JSX(({ foreignOffices, branches }) => {
4262
- const [currentLocation, selectCurrentLocation] = useLocation(branches?.default);
4263
- const link = useLink();
4264
- const { href } = link({ href: `/branches/${currentLocation.slug}` });
4265
- const [query, setQuery] = useState('');
4266
- const regions = cleanUpRegions(useRegions()).sort((a, b) => a.name.localeCompare(b.name));
4267
- const regionsGroupByLetter = groupBy(regions, regionFirstLetter);
4268
- const { close } = useDialogManager();
4269
- const handleChangeLocation = useCallback((region) => {
4270
- selectCurrentLocation(region);
4271
- close();
4272
- }, []);
4273
- return (jsxs(Dialog, { className: "pb-20", head: jsxs("div", { children: [jsx(Text, { size: "text-h4", color: "text-primary-text", children: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B" }), currentLocation ? (jsx("div", { className: "mb-s", children: jsxs(Paragraph, { size: "text-l", color: "text-primary-text", children: ["\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044B\u0431\u0440\u0430\u043D:", jsx(LinkWrapper, { href: href, className: "inline mx-2xs text-primary-main", children: currentLocation.name })] }) })) : null, jsx(SearchBar, { onSearch: setQuery, searchTerm: query })] }), children: [query && query.length >= SEARCH_TERM_MIN_LENGTH ? (jsx("div", { children: regions
4274
- .filter(({ name }) => name && jaroWinklerDistance(name.toLowerCase())(query.toLowerCase()) >= 0.8)
4275
- .map(renderRegion(branches?.dataSelect, handleChangeLocation)) })) : (jsx("div", { className: "columns-1 sm:columns-5", children: Array.from(regionsGroupByLetter.entries()).map(renderRegionGroup(handleChangeLocation, branches?.dataSelect)) })), renderForeignOffices(foreignOffices)] }));
4276
- });
4277
- const regionFirstLetter = (region) => region.name?.charAt(0) || '';
4278
- const cleanUpRegions = (regions) => regions.map((region) => ({
4279
- ...region,
4280
- name: region.name?.replace(/республика|область|край'/gi, '').trim() || '',
4281
- }));
4282
-
4283
- const useLocationDialog = (props) => {
4284
- const { open, close } = useDialogManager();
4285
- return {
4286
- open: (options = {}) => open(jsx(LocationDialog, { ...props }), options),
4287
- close,
4288
- };
4289
- };
4290
-
4291
- const BUTTON_SIZE_STYLE = {
4292
- default: 'w-6 h-6',
4293
- large: 'w-12 h-12',
4294
- };
4295
- const HeaderSecondaryMenuButton = JSX(({ className, isRounded, buttonSize = 'default', isGrayBg = false, disabled, ariaLabel, image, data, onClick, }) => (jsx("button", { className: style('group/btn border-0 flex shrink-0 items-center', isGrayBg ? 'p-s rounded-full' : 'p-0 bg-inherit', isGrayBg && !isRounded ? 'bg-main-divider' : '', isRounded
4296
- ? 'w-8 h-8 text-secondary-light hover:text-secondary-hove'
4297
- : `${BUTTON_SIZE_STYLE[buttonSize]} text-primary-text hover:text-primary-main`, 'group-data-transparent:text-white', className), type: "button", disabled: disabled, "aria-label": ariaLabel, onClick: onClick, ...getAspectsAttributes(data), children: jsx(Img, { image: image, className: style('h-full', isRounded ? 'bg-main-divider/20 rounded-full' : ''), imageClassName: "group-hover/btn:text-primary-hover group-hover/btn:invert-0" }) })));
4298
-
4299
- const HeaderSecondaryMenu = JSX(({ className, version, ...rest }) => {
4300
- const iconVersion = version === 'transparent' ? 'white' : 'black';
4301
- const [currentLocation] = useLocation(rest?.branches?.default);
4302
- const searchDialog = useSearchDialog(rest);
4303
- const locationDialog = useLocationDialog(rest);
4304
- const openSearchDialog = useCallback(() => searchDialog.open(), [searchDialog]);
4305
- const openLocationDialog = useCallback(() => locationDialog.open(), [locationDialog]);
4306
- return (jsxs("div", { className: style('flex items-center gap-lg', className), role: "navigation", children: [rest?.branches?.visible ? (jsx(TopItem, { flat: true, href: "#", text: currentLocation?.name, data: getAspectsWithInclude(rest?.branches?.dataClick, currentLocation?.name ?? ''), onClick: openLocationDialog })) : null, rest?.officesAtms?.href ? jsx(TopItem, { flat: true, ...rest.officesAtms }) : null, jsx(HeaderSecondaryMenuButton, { image: { icon: 'LoupeIcon', iconVersion }, ariaLabel: rest?.search?.ariaLabel ?? 'Поиск', onClick: openSearchDialog, data: rest?.search?.data })] }));
4307
- });
4308
-
4309
4222
  const DropdownMenu = JSX(({ className = '', items, activeItem, ariaLabel }) => {
4310
4223
  const [isVisible, { setFalse, toggle }] = useBool(false);
4311
4224
  const ref = useOutsideClick(setFalse);
4312
4225
  return (jsxs("div", { className: style(isVisible ? 'bg-white rounded-md shadow-blue-gray' : '', className), ref: ref, role: "navigation", children: [jsx("button", { type: "button", className: "group/btn flex justify-between items-center h-6", "aria-label": ariaLabel, onClick: toggle, children: Array(3)
4313
4226
  .fill(null)
4314
- .map((_, i) => (jsx("div", { className: "w-[3px] h-[3px] rounded mr-2xs bg-primary-text group-hover/btn:bg-primary-hover group-data-transparent:bg-white" }, String(i)))) }), jsx("div", { className: style('absolute flex flex-col rounded-md bg-white p-xl pb-xs w-56', isVisible ? '' : 'hidden'), "aria-hidden": !isVisible, children: items?.map((item, i) => (jsx(DropdownMenuItem, { isActive: item === activeItem, ...item }, item?.text ?? String(i)))) })] }));
4227
+ .map((_, i) => (jsx("div", { className: "w-[3px] h-[3px] rounded mr-2xs bg-primary-text group-hover/btn:bg-primary-hover group-data-transparent:bg-white" }, String(i)))) }), jsx("div", { className: style('absolute flex flex-col rounded-md bg-white p-xl pb-xs w-56 z-40', isVisible ? '' : 'hidden'), "aria-hidden": !isVisible, children: items?.map((item, i) => (jsx(DropdownMenuItem, { isActive: item === activeItem, ...item }, item?.text ?? String(i)))) })] }));
4315
4228
  });
4316
4229
  const DropdownMenuItem = JSX(({ isActive, ...rest }) => {
4317
4230
  const link = useLink();
@@ -4319,6 +4232,14 @@
4319
4232
  return (jsx("a", { className: style('text-l font-light pb-m hover:text-primary-main', isActive ? 'text-primary-main' : ''), href: href, target: target, onClick: onClick, role: "menuitem", ...getAspectsAttributes(rest?.data), children: text }));
4320
4233
  });
4321
4234
 
4235
+ const BUTTON_SIZE_STYLE = {
4236
+ default: 'w-6 h-6',
4237
+ large: 'w-12 h-12',
4238
+ };
4239
+ const HeaderSecondaryMenuButton = JSX(({ className, isRounded, buttonSize = 'default', isGrayBg = false, disabled, ariaLabel, image, data, onClick, }) => (jsx("button", { className: style('group/btn border-0 flex shrink-0 items-center', isGrayBg ? 'p-s rounded-full' : 'p-0 bg-inherit', isGrayBg && !isRounded ? 'bg-main-divider' : '', isRounded
4240
+ ? 'w-8 h-8 text-secondary-light hover:text-secondary-hove'
4241
+ : `${BUTTON_SIZE_STYLE[buttonSize]} text-primary-text hover:text-primary-main`, 'group-data-transparent:text-white', className), type: "button", disabled: disabled, "aria-label": ariaLabel, onClick: onClick, ...getAspectsAttributes(data), children: jsx(Img, { image: image, className: style('h-full', isRounded ? 'bg-main-divider/20 rounded-full' : ''), imageClassName: "group-hover/btn:text-primary-hover group-hover/btn:invert-0" }) })));
4242
+
4322
4243
  const getNS = (_) => globalThis[_];
4323
4244
  const initializeExternalNS = (namespaceName, url) => {
4324
4245
  const script = document.getElementById(url);
@@ -4417,9 +4338,9 @@
4417
4338
  const HeaderItem = JSX(({ className = '', active, dataItemName, children, data, ...rest }) => {
4418
4339
  const link = useLink();
4419
4340
  const { href, target, text, onClick } = link(rest);
4420
- return (jsxs("a", { className: style('relative inline-block bg-transparent text-center no-underline', className), href: href, target: target, "data-item-name": dataItemName, onClick: onClick, ...getAspectsAttributes(data), children: [jsx("span", { className: getTextStyle(active), children: text || children }), active ? (jsx("div", { className: "absolute left-0 right-0 -bottom-3 h-0.5 bg-primary-main group-data-transparent:bg-transparent" })) : null] }));
4341
+ return (jsxs("a", { className: style('relative inline-block bg-transparent text-center no-underline', className), href: href, target: target, "data-item-name": dataItemName, onClick: onClick, ...getAspectsAttributes(data), children: [jsx("span", { className: getTextStyle$1(active), children: text || children }), active ? (jsx("div", { className: "absolute left-0 right-0 -bottom-3 h-0.5 bg-primary-main group-data-transparent:bg-transparent" })) : null] }));
4421
4342
  });
4422
- const getTextStyle = (active = false) => style('font-sans text-l font-light', active ? 'text-primary-main' : 'text-primary-text hover:text-primary-main', 'group-data-transparent:text-white group-data-transparent:hover:text-primary-hover');
4343
+ const getTextStyle$1 = (active = false) => style('font-sans text-l font-light', active ? 'text-primary-main' : 'text-primary-text hover:text-primary-main', 'group-data-transparent:text-white group-data-transparent:hover:text-primary-hover');
4423
4344
 
4424
4345
  const HeaderSubMenuItem = JSX(({ observerOptions, onVisibilityChange, children, className, ...rest }) => {
4425
4346
  const observerCallback = useCallback((entries) => {
@@ -4453,11 +4374,118 @@
4453
4374
  const subItemsListRef = useRef(null);
4454
4375
  const observerOptions = { rootRef: subItemsListRef };
4455
4376
  const subItemsVisibilityHandlers = useMemo(() => subItems.map((_, index) => (isIntersecting) => {
4377
+ setVisibleItemsCount(isIntersecting
4378
+ ? handleIntersectionActivation$1(index)
4379
+ : handleIntersectionDeactivation$1(index));
4380
+ }), [subItems]);
4381
+ return (jsxs("nav", { className: "relative mt-s flex gap-s items-center justify-between", children: [jsx("div", { ref: subItemsListRef, className: "overflow-hidden whitespace-nowrap pb-s mt-xs space-x-3xl", role: "menu", children: subItems.map((_, i) => (jsx(HeaderSubMenuItem, { className: visibleItemsCount - 1 < i ? 'invisible' : '', active: _ === activeSubItem, observerOptions: observerOptions, onVisibilityChange: subItemsVisibilityHandlers[i], data: _.dataHeader, ..._ }, String(i)))) }), dropDownMenuItems.length ? (jsx(DropdownMenu, { items: dropDownMenuItems, activeItem: activeSubItem, ariaLabel: dropdownMenuAriaLabel })) : null, projectSettings.CHAT_BOT ? (jsx(HeaderChatBotButton, { iconVersion: iconVersion, chat: projectSettings.CHAT_BOT, ariaLabel: chatBotAriaLabel })) : null, jsx(InternetBankButton, { version: version, ...internetBankButton })] }));
4382
+ });
4383
+ const handleIntersectionActivation$1 = (index) => (prev) => Math.max(prev, index + 1);
4384
+ const handleIntersectionDeactivation$1 = (index) => (prev) => Math.min(prev, index);
4385
+
4386
+ const groupBy = (list, keyGetter) => {
4387
+ const result = new Map();
4388
+ for (const item of list) {
4389
+ const key = keyGetter(item);
4390
+ const group = result.get(key) || [];
4391
+ result.set(key, [...group, item]);
4392
+ }
4393
+ return result;
4394
+ };
4395
+
4396
+ const renderForeignOffices = (foreignOffices) => foreignOffices?.length ? (jsxs("div", { className: "sm:border-t sm:border-main-divider mt-2xs pt-2xs", children: [jsx("div", { className: "mb-m", children: jsx(Text, { size: "text-m", font: "font-light", color: "text-secondary-text", children: "\u041F\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u0430 \u0437\u0430 \u0440\u0443\u0431\u0435\u0436\u043E\u043C:" }) }), jsx("div", { className: "flex flex-col sm:flex-row gap-5xl", children: foreignOffices.map((office, i) => (jsx(ForeignOffice, { ...office }, String(i)))) })] })) : null;
4397
+ const ForeignOffice = JSX(({ icon, ...rest }) => {
4398
+ const link = useLink();
4399
+ const { text, target, href, onClick } = link(rest);
4400
+ return (jsxs("div", { className: "flex gap-s items-center", children: [icon ? jsx(Img, { pathPrefix: "/wcms-resources/", image: icon }) : null, text ? (jsx("a", { className: "hover:text-primary-hover", href: href, target: target, onClick: onClick, children: jsx(Text, { size: "text-l", font: "font-light", color: "text-primary-text", children: text }) })) : null] }));
4401
+ });
4402
+
4403
+ const renderRegion = (data, onChangeLocation) => (region) => region.name ? (jsx(LinkWrapper, { href: `/branches/${region.slug}`, className: "mb-xs sm:mb-2xs hover:text-primary-hover", onClick: () => onChangeLocation?.(region), data: getAspectsWithInclude(data, region.name), children: jsx(Text, { size: "text-l", font: "font-light", children: region.name }) }, String(region.id))) : null;
4404
+
4405
+ const renderRegionGroup = (onChangeLocation, data) => ([letter, regions]) => (jsxs("div", { className: "break-inside-avoid mb-2xl w-56", children: [jsx("div", { className: "mb-s", children: jsx(Text, { size: "text-h6", children: letter }) }), regions.map(renderRegion(data, onChangeLocation))] }, letter));
4406
+
4407
+ const SearchBar = JSX(({ className, searchTerm, onSearch }) => {
4408
+ return (jsxs("form", { className: `font-sans relative ${className}`, children: [jsx("div", { className: "absolute rounded h-full flex items-center justify-center pl-m max-w-44 gap-s pointer-events-none", children: searchTerm ? null : (jsx("label", { htmlFor: "search-bar-input", className: `text-secondary-text `, children: "\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0444\u0438\u043B\u0438\u0430\u043B\u0430\u043C" })) }), jsx("input", { id: "search-bar-input", className: style(inputValidStyle, `h-12 pl-m w-full peer text-l text-black rounded-md box-border`), value: searchTerm, onChange: (e) => onSearch(e.target.value.toLowerCase()), type: "text", name: "location-search-bar-input" })] }));
4409
+ });
4410
+
4411
+ const SEARCH_TERM_MIN_LENGTH = 3;
4412
+ const LocationDialog = JSX(({ foreignOffices, branches }) => {
4413
+ const [currentLocation, selectCurrentLocation] = useLocation(branches?.default);
4414
+ const link = useLink();
4415
+ const { href } = link({ href: `/branches/${currentLocation.slug}` });
4416
+ const [query, setQuery] = useState('');
4417
+ const regions = cleanUpRegions(useRegions()).sort((a, b) => a.name.localeCompare(b.name));
4418
+ const regionsGroupByLetter = groupBy(regions, regionFirstLetter);
4419
+ const { close } = useDialogManager();
4420
+ const handleChangeLocation = useCallback((region) => {
4421
+ selectCurrentLocation(region);
4422
+ close();
4423
+ }, []);
4424
+ return (jsxs(Dialog, { className: "pb-20", head: jsxs("div", { children: [jsx(Text, { size: "text-h4", color: "text-primary-text", children: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B" }), currentLocation ? (jsx("div", { className: "mb-s", children: jsxs(Paragraph, { size: "text-l", color: "text-primary-text", children: ["\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044B\u0431\u0440\u0430\u043D:", jsx(LinkWrapper, { href: href, className: "inline mx-2xs text-primary-main", children: currentLocation.name })] }) })) : null, jsx(SearchBar, { onSearch: setQuery, searchTerm: query })] }), children: [query && query.length >= SEARCH_TERM_MIN_LENGTH ? (jsx("div", { children: regions
4425
+ .filter(({ name }) => name && jaroWinklerDistance(name.toLowerCase())(query.toLowerCase()) >= 0.8)
4426
+ .map(renderRegion(branches?.dataSelect, handleChangeLocation)) })) : (jsx("div", { className: "columns-1 sm:columns-5", children: Array.from(regionsGroupByLetter.entries()).map(renderRegionGroup(handleChangeLocation, branches?.dataSelect)) })), renderForeignOffices(foreignOffices)] }));
4427
+ });
4428
+ const regionFirstLetter = (region) => region.name?.charAt(0) || '';
4429
+ const cleanUpRegions = (regions) => regions.map((region) => ({
4430
+ ...region,
4431
+ name: region.name?.replace(/республика|область|край'/gi, '').trim() || '',
4432
+ }));
4433
+
4434
+ const useLocationDialog = (props) => {
4435
+ const { open, close } = useDialogManager();
4436
+ return {
4437
+ open: (options = {}) => open(jsx(LocationDialog, { ...props }), options),
4438
+ close,
4439
+ };
4440
+ };
4441
+
4442
+ const TopItem = JSX(({ className = '', active, flat, children, data, ...rest }) => {
4443
+ const link = useLink();
4444
+ const { href, target, text, onClick } = link(rest);
4445
+ return (jsx("a", { className: style(getLinkStyle(active, flat), className), href: href, target: target, onClick: onClick, rel: "noopener noreferrer", "aria-label": text, ...getAspectsAttributes(data), children: jsx("span", { suppressHydrationWarning: true, className: getTextStyle(active, flat), children: text || children }) }));
4446
+ });
4447
+ const getLinkStyle = (active = false, flat = false) => style('inline-block border border-solid bg-transparent text-center no-underline', active
4448
+ ? 'rounded-md border-primary-main group-data-transparent:border-white'
4449
+ : 'border-transparent', flat ? '' : 'px-m py-xs');
4450
+ const getTextStyle = (active = false, flat = false) => {
4451
+ const activeFlatStyle = flat ? 'text-primary-text' : 'text-secondary-text';
4452
+ return style('font-sans text-s font-light', active ? 'text-primary-main' : style(activeFlatStyle, 'hover:text-primary-main'), 'group-data-transparent:text-white group-data-transparent:hover:text-primary-hover');
4453
+ };
4454
+
4455
+ const HeaderSecondaryMenu = JSX(({ className, version, ...rest }) => {
4456
+ const iconVersion = version === 'transparent' ? 'white' : 'black';
4457
+ const [currentLocation] = useLocation(rest?.branches?.default);
4458
+ const searchDialog = useSearchDialog(rest);
4459
+ const locationDialog = useLocationDialog(rest);
4460
+ const openSearchDialog = useCallback(() => searchDialog.open(), [searchDialog]);
4461
+ const openLocationDialog = useCallback(() => locationDialog.open(), [locationDialog]);
4462
+ return (jsxs("div", { className: style('flex items-center ml-5 md:max-w-[300px] xl:max-w-full gap-lg', className), role: "navigation", children: [rest?.branches?.visible ? (jsx(TopItem, { className: "whitespace-nowrap text-ellipsis overflow-hidden", flat: true, href: "#", text: currentLocation?.name, data: getAspectsWithInclude(rest?.branches?.dataClick, currentLocation?.name ?? ''), onClick: openLocationDialog })) : null, rest?.officesAtms?.href ? (jsx(TopItem, { className: "whitespace-nowrap", flat: true, ...rest.officesAtms })) : null, jsx(HeaderSecondaryMenuButton, { image: { icon: 'LoupeIcon', iconVersion }, ariaLabel: rest?.search?.ariaLabel ?? 'Поиск', onClick: openSearchDialog, data: rest?.search?.data })] }));
4463
+ });
4464
+
4465
+ const HeaderTopMenuItem = JSX(({ observerOptions, onVisibilityChange, children, className, ...rest }) => {
4466
+ const observerCallback = useCallback((entries) => {
4467
+ if (!entries.length || !onVisibilityChange) {
4468
+ return;
4469
+ }
4470
+ // Assumption about entries order (by time)
4471
+ const entry = entries[entries.length - 1];
4472
+ onVisibilityChange(entry.isIntersecting);
4473
+ }, [onVisibilityChange]);
4474
+ const ref = useIntersectionObserver(observerCallback, observerOptions);
4475
+ return (jsx("span", { ref: ref, className: className, role: "menuitem", children: jsx(TopItem, { ...rest, children: children }) }));
4476
+ });
4477
+
4478
+ const HeaderTopMenu = JSX(({ topItems = [], activeTopItem, dropdownMenuAriaLabel, version, sitemap, bgColor, logo, data, }) => {
4479
+ const [visibleItemsCount, setVisibleItemsCount] = useState(topItems.length);
4480
+ const dropDownMenuItems = topItems.slice(visibleItemsCount);
4481
+ const topItemsListRef = useRef(null);
4482
+ const observerOptions = { rootRef: topItemsListRef };
4483
+ const topItemsVisibilityHandlers = useMemo(() => topItems.map((_, index) => (isIntersecting) => {
4456
4484
  setVisibleItemsCount(isIntersecting
4457
4485
  ? handleIntersectionActivation(index)
4458
4486
  : handleIntersectionDeactivation(index));
4459
- }), [subItems]);
4460
- return (jsxs("nav", { className: "relative mt-s flex gap-s items-center justify-between", children: [jsx("div", { ref: subItemsListRef, className: "overflow-hidden whitespace-nowrap pb-s mt-xs space-x-3xl", role: "menu", children: subItems.map((_, i) => (jsx(HeaderSubMenuItem, { className: visibleItemsCount - 1 < i ? 'invisible' : '', active: _ === activeSubItem, observerOptions: observerOptions, onVisibilityChange: subItemsVisibilityHandlers[i], data: _.dataHeader, ..._ }, String(i)))) }), dropDownMenuItems.length ? (jsx(DropdownMenu, { className: "relative w-auto z-40", items: dropDownMenuItems, activeItem: activeSubItem, ariaLabel: dropdownMenuAriaLabel })) : null, projectSettings.CHAT_BOT ? (jsx(HeaderChatBotButton, { iconVersion: iconVersion, chat: projectSettings.CHAT_BOT, ariaLabel: chatBotAriaLabel })) : null, jsx(InternetBankButton, { version: version, ...internetBankButton })] }));
4487
+ }), [topItems]);
4488
+ return (jsxs("div", { className: "flex items-center justify-between", children: [jsx(Logo, { className: "mr-3xl", bgColor: bgColor, logo: logo, data: data }), jsx("div", { ref: topItemsListRef, className: "overflow-hidden min-w-[160px] pb-xs mt-xs", role: "menu", children: topItems.map((_, i) => (jsx(HeaderTopMenuItem, { className: visibleItemsCount - 1 < i ? 'invisible' : '', active: _ === activeTopItem, observerOptions: observerOptions, onVisibilityChange: topItemsVisibilityHandlers[i], data: _.dataHeader, ..._ }, String(i)))) }), dropDownMenuItems.length ? (jsx(DropdownMenu, { className: "mx-xs", items: dropDownMenuItems, activeItem: activeTopItem, ariaLabel: dropdownMenuAriaLabel })) : null, jsx(HeaderSecondaryMenu, { version: version, className: "ml-auto", ...sitemap })] }));
4461
4489
  });
4462
4490
  const handleIntersectionActivation = (index) => (prev) => Math.max(prev, index + 1);
4463
4491
  const handleIntersectionDeactivation = (index) => (prev) => Math.min(prev, index);
@@ -4474,7 +4502,7 @@
4474
4502
  const { dataFooter, dataHeader, ...logoProps } = logo ?? {};
4475
4503
  const [, activeTopItem] = useActiveRoute(topItems);
4476
4504
  const { internetBankButton } = portal || {};
4477
- return (jsx(BlockWrapper, { tag: "header", className: style('pt-3xl px-20', activeTopItem?.items?.length ? 'pb-m' : 'pb-lg', className), defaultPadding: "", version: version, ...rest, children: jsxs("div", { className: "container", children: [jsxs("div", { className: "flex items-center", children: [jsx(Logo, { className: "mr-3xl", bgColor: bgColor, logo: customLogo ?? logoProps, data: dataHeader }), topItems?.filter(isVisibleItem(HEADER_AREA_KEYS)).map((_, i) => (jsx(TopItem, { active: _ === activeTopItem, data: _.dataHeader, ..._ }, String(i)))), jsx(HeaderSecondaryMenu, { version: version, className: "ml-auto", ...sitemap })] }), jsx("div", { className: style('mt-xl h-px bg-main-divider', getVersionStyle(version)) }), activeTopItem?.items?.length ? (jsx(HeaderSubMenu, { subItems: activeTopItem?.items?.filter(isVisibleItem(HEADER_AREA_KEYS)), version: version, internetBankButton: internetBankButton })) : null] }) }));
4505
+ return (jsx(BlockWrapper, { tag: "header", className: style('pt-3xl px-20', activeTopItem?.items?.length ? 'pb-m' : 'pb-lg', className), defaultPadding: "", version: version, ...rest, children: jsxs("div", { className: "container", children: [jsx("div", { className: "whitespace-nowrap", children: jsx(HeaderTopMenu, { activeTopItem: activeTopItem, topItems: topItems?.filter(isVisibleItem(HEADER_AREA_KEYS)), version: version, sitemap: sitemap, bgColor: bgColor, logo: customLogo ?? logoProps, data: dataHeader }) }), jsx("div", { className: style('mt-xl h-px bg-main-divider', getVersionStyle(version)) }), activeTopItem?.items?.length ? (jsx(HeaderSubMenu, { subItems: activeTopItem?.items?.filter(isVisibleItem(HEADER_AREA_KEYS)), version: version, internetBankButton: internetBankButton })) : null] }) }));
4478
4506
  });
4479
4507
  const getVersionStyle = (version) => (version === 'transparent' ? 'opacity-30' : '');
4480
4508
 
@@ -4700,7 +4728,7 @@
4700
4728
  onFiltrationStateChange(hotFilters[items.indexOf(_)].filter);
4701
4729
  }, [hotFilters, items]);
4702
4730
  return {
4703
- value: items[activeItemIndex],
4731
+ activeItem: items[activeItemIndex],
4704
4732
  items: items,
4705
4733
  onChange: handleChange,
4706
4734
  };
@@ -4785,7 +4813,7 @@
4785
4813
 
4786
4814
  const renderTab = (activeTab, onClick, type) => (tab, i) => (jsx(TabItem, { isActive: tab === activeTab, onClick: onClick, type: type, item: tab }, String(i)));
4787
4815
 
4788
- const TabsControl = JSX(({ className, tabsType = 'default', items = [], value, onChange }) => (jsx("div", { className: style('flex gap-x-2xs overflow-x-auto no-scrollbar', className), role: "tabpanel", children: items.map(renderTab(value, onChange, tabsType)) })));
4816
+ const TabsControl = JSX(({ className, tabsType = 'default', items = [], activeItem, onChange }) => (jsx("div", { className: style('flex gap-x-2xs overflow-x-auto no-scrollbar', className), role: "tabpanel", children: items.map(renderTab(activeItem, onChange, tabsType)) })));
4789
4817
 
4790
4818
  const initialFiltrationState = {
4791
4819
  categories: [],
@@ -5682,15 +5710,15 @@
5682
5710
  buttonTop: 'top-0',
5683
5711
  },
5684
5712
  };
5685
- const ScrollableTabsControl = JSX(({ className, items = [], value, onChange, tabsType = 'default' }) => {
5713
+ const ScrollableTabsControl = JSX(({ className, items = [], activeItem, onChange, tabsType = 'default' }) => {
5686
5714
  const [containerRef, scroll] = useSwipeListScroll({
5687
5715
  itemCount: items?.length || 0,
5688
5716
  });
5689
- useEffect(() => scrollToSelected(containerRef.current, items), []);
5690
- return (jsxs("div", { className: style('relative overflow-x-auto no-scrollbar', className), children: [jsx(SwipeListContainer, { containerRef: containerRef, snapAlign: "snap-start", onVisibleIndicesChange: scroll.handleVisibleIndicesChange, itemClassName: scrollStyle[tabsType].item, gap: scrollStyle[tabsType].gap, children: items.map(renderTab(value, onChange, tabsType)) }), scroll.canScrollLeft ? (jsx(ScrollLeftButton, { className: style('left-6', scrollButtonStyle, scrollStyle[tabsType].buttonTop), onClick: scroll.scrollLeft })) : null, scroll.canScrollRight ? (jsx(ScrollRightButton, { className: style('right-6', scrollButtonStyle, scrollStyle[tabsType].buttonTop), onClick: scroll.scrollRight })) : null] }));
5717
+ useEffect(() => scrollToSelected(containerRef.current, items, activeItem), []);
5718
+ return (jsxs("div", { className: style('relative overflow-x-auto no-scrollbar', className), children: [jsx(SwipeListContainer, { containerRef: containerRef, snapAlign: "snap-start", onVisibleIndicesChange: scroll.handleVisibleIndicesChange, itemClassName: scrollStyle[tabsType].item, gap: scrollStyle[tabsType].gap, children: items.map(renderTab(activeItem, onChange, tabsType)) }), scroll.canScrollLeft ? (jsx(ScrollLeftButton, { className: style('left-6', scrollButtonStyle, scrollStyle[tabsType].buttonTop), onClick: scroll.scrollLeft })) : null, scroll.canScrollRight ? (jsx(ScrollRightButton, { className: style('right-6', scrollButtonStyle, scrollStyle[tabsType].buttonTop), onClick: scroll.scrollRight })) : null] }));
5691
5719
  });
5692
- const scrollToSelected = (container, items) => {
5693
- const selectedIndex = items.findIndex((_) => _?.selected);
5720
+ const scrollToSelected = (container, items, activeItem) => {
5721
+ const selectedIndex = items.findIndex((_) => _ === activeItem);
5694
5722
  if (container && selectedIndex > 0) {
5695
5723
  container.scrollTo({
5696
5724
  left: container?.children[selectedIndex]?.offsetLeft,
@@ -5710,7 +5738,7 @@
5710
5738
  }
5711
5739
  };
5712
5740
 
5713
- const TAB_QUERY_PARAM_KEY$1 = 'tab';
5741
+ const TAB_QUERY_PARAM_KEY = 'tab';
5714
5742
  const Tabs = JSX(({ className = '', isSticky, tabs = [], tabsMode, ...rest }) => {
5715
5743
  const router = useRouter();
5716
5744
  const { isReady } = router;
@@ -5720,8 +5748,8 @@
5720
5748
  if (!tabs || !tabs[0]) {
5721
5749
  return;
5722
5750
  }
5723
- const defaultTabIndex = router.query[TAB_QUERY_PARAM_KEY$1]
5724
- ? tabs.findIndex((_) => _.type === 'group' && _.ref === router.query[TAB_QUERY_PARAM_KEY$1]) || 0
5751
+ const defaultTabIndex = router.query[TAB_QUERY_PARAM_KEY]
5752
+ ? tabs.findIndex((_) => _.type === 'group' && _.ref === router.query[TAB_QUERY_PARAM_KEY]) || 0
5725
5753
  : 0;
5726
5754
  const defaultTab = tabs[defaultTabIndex] || tabs[0];
5727
5755
  setActiveTabIndex(defaultTabIndex);
@@ -5740,10 +5768,10 @@
5740
5768
  const updateUrlSearchTabParam = (_) => {
5741
5769
  const searchParams = new URLSearchParams(router.query);
5742
5770
  if (_.name) {
5743
- searchParams.set(TAB_QUERY_PARAM_KEY$1, _.name);
5771
+ searchParams.set(TAB_QUERY_PARAM_KEY, _.name);
5744
5772
  }
5745
5773
  else {
5746
- searchParams.delete(TAB_QUERY_PARAM_KEY$1);
5774
+ searchParams.delete(TAB_QUERY_PARAM_KEY);
5747
5775
  }
5748
5776
  router.replace(`${router.pathname}?${searchParams}`, '', { scroll: false });
5749
5777
  };
@@ -5758,7 +5786,7 @@
5758
5786
  }, [tabs, tabsControlItems]);
5759
5787
  return (jsx(BlockWrapper, { className: style(isSticky ? 'sticky top-1 z-20' : '', className), defaultPadding: "p-0", ...rest, children: renderTabs({
5760
5788
  items: tabsControlItems,
5761
- value: tabsControlItems[activeTabIndex],
5789
+ activeItem: tabsControlItems[activeTabIndex],
5762
5790
  tabsMode,
5763
5791
  onChange: handleChange,
5764
5792
  }) }));
@@ -5773,6 +5801,11 @@
5773
5801
  };
5774
5802
  const normalizeTab = (_) => _?.type === 'group' ? { text: _.title, name: _.ref } : _;
5775
5803
 
5804
+ const getUrlParams = (params = '') => {
5805
+ const href = globalThis?.location?.href;
5806
+ return href ? new URL(href).searchParams.get(params) : null;
5807
+ };
5808
+
5776
5809
  const tabsStyle = {
5777
5810
  default: {
5778
5811
  wrapper: '',
@@ -5789,8 +5822,8 @@
5789
5822
  };
5790
5823
  const renderTabsLayout = ({ tabsType = 'animated', ...props }) => tabsType ? (jsx("div", { className: tabsStyle[tabsType].wrapper, children: jsx(ScrollableTabsControl, { className: tabsStyle[tabsType].component, tabsType: tabsType, ...props }) })) : null;
5791
5824
 
5792
- const TAB_QUERY_PARAM_KEY = 'tab';
5793
5825
  const TabsLayout = UniBlock(({ className = '', tabs = [], block, tabsType, showCounter = false, ...rest }) => {
5826
+ const id = block?.__id ? `tabs-${block.__id}` : 'tabs';
5794
5827
  const router = useRouter();
5795
5828
  const tabsCounted = showCounter
5796
5829
  ? tabs.map((_) => ({
@@ -5799,22 +5832,24 @@
5799
5832
  }))
5800
5833
  : tabs;
5801
5834
  const { isReady } = router;
5802
- const [activeTabIndex, setActiveTabIndex] = useState(getInitSelectedIndex(tabsCounted));
5835
+ const [activeTabIndex, setActiveTabIndex] = useState(getInitSelectedIndex(tabsCounted, getUrlParams(id)));
5836
+ const activeItem = tabsCounted[activeTabIndex];
5803
5837
  const defaultSelectedTab = tabsCounted.findIndex((_) => Boolean(_.selected));
5838
+ //TODO: Вынести в отдельный хук
5804
5839
  useEffect(() => {
5805
- const defaultTabIndex = router.query[TAB_QUERY_PARAM_KEY]
5806
- ? tabsCounted.findIndex((_, index) => _.type === 'group' && String(index) === router.query[TAB_QUERY_PARAM_KEY])
5840
+ const defaultTabIndex = router.query[id]
5841
+ ? tabsCounted.findIndex((_, index) => _.type === 'group' && String(index) === router.query[id])
5807
5842
  : defaultSelectedTab;
5808
5843
  setActiveTabIndex(defaultTabIndex === -1 ? 0 : defaultTabIndex);
5809
- }, [isReady, defaultSelectedTab]);
5844
+ }, [isReady, defaultSelectedTab, id, tabsCounted]);
5810
5845
  const slotName = getSlotName(tabsCounted[activeTabIndex], activeTabIndex);
5811
5846
  const updateUrlSearchTabParam = (_, index) => {
5812
5847
  const searchParams = new URLSearchParams(router.query);
5813
5848
  if (_.text) {
5814
- searchParams.set(TAB_QUERY_PARAM_KEY, String(index));
5849
+ searchParams.set(id, String(index));
5815
5850
  }
5816
5851
  else {
5817
- searchParams.delete(TAB_QUERY_PARAM_KEY);
5852
+ searchParams.delete(id);
5818
5853
  }
5819
5854
  router.replace(`${router.pathname}?${searchParams}`, '', { scroll: false });
5820
5855
  };
@@ -5828,20 +5863,23 @@
5828
5863
  }, [tabsCounted]);
5829
5864
  return (jsxs(BlockWrapper, { className: style(className), defaultPadding: "p-0", ...rest, children: [renderTabsLayout({
5830
5865
  items: tabsCounted,
5831
- value: tabsCounted[activeTabIndex],
5866
+ activeItem,
5832
5867
  tabsType,
5833
5868
  onChange: handleChange,
5834
- }), jsx("div", { className: "space-y-px @5xl:space-y-0 @5xl:grid @5xl:grid-cols-12 @5xl:gap-2xs", children: renderBlocksList(block?.slots?.[slotName], {
5869
+ }), jsx("div", { className: "space-y-px @5xl:space-y-0 @5xl:grid @5xl:grid-cols-12 @5xl:gap-2xs", children: Object.entries(block?.slots ?? {}).map(([key, value]) => renderBlocksList(value, {
5835
5870
  ...rest?.options,
5836
5871
  slotName,
5837
5872
  parent: block,
5838
- }) })] }));
5873
+ extraProps: { className: key === slotName ? '' : 'hidden' },
5874
+ })) })] }));
5839
5875
  }, {
5840
5876
  slots: ({ tabs }) => tabs?.filter((_) => _.type === 'group').map(getSlotName) || [],
5841
5877
  childrenTypes: { exclude: ['TabsLayout'] }, // TODO: fix this on wcms
5842
5878
  });
5843
5879
  const getSlotName = (tab, index) => tab?.text || `Слот №${index}`;
5844
- const getInitSelectedIndex = (tabs) => tabs.reduce((selectedIndex, tab, i) => (tab.selected ? i : selectedIndex), 0);
5880
+ const getInitSelectedIndex = (tabs, paramsId) => paramsId
5881
+ ? Number(paramsId)
5882
+ : tabs.reduce((selectedIndex, tab, i) => (tab.selected ? i : selectedIndex), 0);
5845
5883
 
5846
5884
  const dividerStyle = '@4xl:border-main-divider @4xl:border-b';
5847
5885
  const firstCellStyle = 'w-80 flex-shrink-0';
@@ -6274,7 +6312,7 @@
6274
6312
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
6275
6313
  });
6276
6314
 
6277
- const packageVersion = "0.14.393";
6315
+ const packageVersion = "0.14.395";
6278
6316
 
6279
6317
  exports.Blocks = Blocks;
6280
6318
  exports.ContentPage = ContentPage;