@consta/header 2.1.0 → 3.0.0-beta.2

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 (155) hide show
  1. package/Navbar/index.d.ts +1 -0
  2. package/Navbar/index.js +1 -0
  3. package/__internal__/src/components/ButtonMenu/types.d.ts +1 -2
  4. package/__internal__/src/components/ButtonMenu/types.js.map +1 -1
  5. package/__internal__/src/components/MegaMenu/MegaMenu.js +1 -1
  6. package/__internal__/src/components/MegaMenu/MegaMenu.js.map +1 -1
  7. package/__internal__/src/components/MegaMenu/MegaMenuBannerBar/MegaMenuBannerBarItem/MegaMenuBannerBarItem.js +1 -1
  8. package/__internal__/src/components/MegaMenu/MegaMenuBannerBar/MegaMenuBannerBarItem/MegaMenuBannerBarItem.js.map +1 -1
  9. package/__internal__/src/components/MegaMenu/MegaMenuBannerBar/types.d.ts +1 -2
  10. package/__internal__/src/components/MegaMenu/MegaMenuBannerBar/types.js.map +1 -1
  11. package/__internal__/src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobal.js +1 -1
  12. package/__internal__/src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobal.js.map +1 -1
  13. package/__internal__/src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobalGroup/MegaMenuGlobalGroup.js +1 -1
  14. package/__internal__/src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobalGroup/MegaMenuGlobalGroup.js.map +1 -1
  15. package/__internal__/src/components/MegaMenu/MegaMenuGlobal/types.d.ts +2 -4
  16. package/__internal__/src/components/MegaMenu/MegaMenuGlobal/types.js.map +1 -1
  17. package/__internal__/src/components/MegaMenu/MegaMenuNavBar/types.d.ts +1 -2
  18. package/__internal__/src/components/MegaMenu/MegaMenuNavBar/types.js.map +1 -1
  19. package/__internal__/src/components/MegaMenu/types.d.ts +1 -2
  20. package/__internal__/src/components/MegaMenu/types.js.map +1 -1
  21. package/__internal__/src/components/Menu/Menu.js +1 -1
  22. package/__internal__/src/components/Menu/Menu.js.map +1 -1
  23. package/__internal__/src/components/Menu/types.d.ts +1 -2
  24. package/__internal__/src/components/Menu/types.js.map +1 -1
  25. package/__internal__/src/components/Navbar/Navbar.js +2 -0
  26. package/__internal__/src/components/Navbar/Navbar.js.map +1 -0
  27. package/__internal__/src/components/Navbar/NavbarArrow/NavbarArrow.js.map +1 -0
  28. package/__internal__/src/components/Navbar/NavbarArrow/index.js.map +1 -0
  29. package/__internal__/src/components/Navbar/NavbarItem/NavbarDrawer.js +2 -0
  30. package/__internal__/src/components/Navbar/NavbarItem/NavbarDrawer.js.map +1 -0
  31. package/__internal__/src/components/Navbar/NavbarItem/NavbarItem.js.map +1 -0
  32. package/__internal__/src/components/Navbar/NavbarItem/index.js.map +1 -0
  33. package/__internal__/src/components/Navbar/NavbarMixDriverLeftAnimate/NavbarMixDriverLeftAnimate.js.map +1 -0
  34. package/__internal__/src/components/Navbar/NavbarMixDriverLeftAnimate/index.js.map +1 -0
  35. package/__internal__/src/components/Navbar/NavbarMixDriverRightAnimate/NavbarMixDriverRightAnimate.js.map +1 -0
  36. package/__internal__/src/components/Navbar/NavbarMixDriverRightAnimate/index.js.map +1 -0
  37. package/__internal__/src/components/Navbar/NavbarMixFadeAnimate/NavbarMixFadeAnimate.js.map +1 -0
  38. package/__internal__/src/components/Navbar/NavbarMixFadeAnimate/index.js.map +1 -0
  39. package/__internal__/src/components/Navbar/NavbarRail/NavbarRail.js.map +1 -0
  40. package/__internal__/src/components/Navbar/NavbarRail/index.js.map +1 -0
  41. package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRailItem/NavbarRailItem.js +1 -1
  42. package/__internal__/src/components/Navbar/NavbarRailItem/NavbarRailItem.js.map +1 -0
  43. package/__internal__/src/components/Navbar/NavbarRailItem/index.js.map +1 -0
  44. package/__internal__/src/components/Navbar/helpers.js.map +1 -0
  45. package/__internal__/src/components/Navbar/index.js.map +1 -0
  46. package/__internal__/src/components/Navbar/types.js.map +1 -0
  47. package/__internal__/src/components/Notifications/NotificationsActions/NotificationsActions.js +1 -1
  48. package/__internal__/src/components/Notifications/NotificationsActions/NotificationsActions.js.map +1 -1
  49. package/__internal__/src/components/Notifications/NotificationsActions/types.d.ts +1 -2
  50. package/__internal__/src/components/Notifications/NotificationsActions/types.js.map +1 -1
  51. package/__internal__/src/components/Notifications/NotificationsItem/NotificationsItem.css +1 -1
  52. package/__internal__/src/components/Notifications/NotificationsItem/NotificationsItem.d.ts +1 -1
  53. package/__internal__/src/components/Notifications/NotificationsItem/NotificationsItem.js +1 -1
  54. package/__internal__/src/components/Notifications/NotificationsItem/NotificationsItem.js.map +1 -1
  55. package/__internal__/src/components/Notifications/NotificationsItemFooter/NotificationsItemFooter.css +1 -0
  56. package/__internal__/src/components/Notifications/NotificationsItemFooter/NotificationsItemFooter.d.ts +4 -0
  57. package/__internal__/src/components/Notifications/NotificationsItemFooter/NotificationsItemFooter.js +2 -0
  58. package/__internal__/src/components/Notifications/NotificationsItemFooter/NotificationsItemFooter.js.map +1 -0
  59. package/__internal__/src/components/Notifications/NotificationsItemFooter/helpers.js.map +1 -0
  60. package/__internal__/src/components/Notifications/NotificationsItemFooter/index.d.ts +1 -0
  61. package/__internal__/src/components/Notifications/NotificationsItemFooter/index.js +2 -0
  62. package/__internal__/src/components/Notifications/NotificationsItemFooter/index.js.map +1 -0
  63. package/__internal__/src/components/Notifications/NotificationsItemFooter/types.d.ts +12 -0
  64. package/__internal__/src/components/Notifications/NotificationsItemFooter/types.js +2 -0
  65. package/__internal__/src/components/Notifications/NotificationsItemFooter/types.js.map +1 -0
  66. package/__internal__/src/components/Notifications/NotificationsList/NotificationsList.js +1 -1
  67. package/__internal__/src/components/Notifications/NotificationsList/NotificationsList.js.map +1 -1
  68. package/__internal__/src/components/Notifications/NotificationsList/helpers.d.ts +1 -1
  69. package/__internal__/src/components/SelectMenu/SelectMenu.js +1 -1
  70. package/__internal__/src/components/SelectMenu/SelectMenu.js.map +1 -1
  71. package/__internal__/src/components/SelectMenu/types.d.ts +1 -2
  72. package/__internal__/src/components/SelectMenu/types.js.map +1 -1
  73. package/__internal__/src/components/Sidebar/Sidebar.js +1 -1
  74. package/__internal__/src/components/Sidebar/Sidebar.js.map +1 -1
  75. package/__internal__/src/components/TileMenu/TileMenuItem/TileMenuItem.js +1 -1
  76. package/__internal__/src/components/TileMenu/TileMenuItem/TileMenuItem.js.map +1 -1
  77. package/__internal__/src/components/TileMenu/TileMenuList/types.d.ts +1 -2
  78. package/__internal__/src/components/TileMenu/TileMenuList/types.js.map +1 -1
  79. package/__internal__/src/components/VerticalMenu/VerticalMenuItem/VerticalMenuItem.js +1 -1
  80. package/__internal__/src/components/VerticalMenu/VerticalMenuItem/VerticalMenuItem.js.map +1 -1
  81. package/__internal__/src/components/VerticalMenu/VerticalMenuLevel/VerticalMenuLevel.js +1 -1
  82. package/__internal__/src/components/VerticalMenu/VerticalMenuLevel/VerticalMenuLevel.js.map +1 -1
  83. package/__internal__/src/components/VerticalMenu/types.d.ts +1 -2
  84. package/__internal__/src/components/VerticalMenu/types.js.map +1 -1
  85. package/__internal__/src/helpers/getItemClick.d.ts +1 -2
  86. package/__internal__/src/helpers/getItemClick.js +1 -1
  87. package/__internal__/src/helpers/getItemClick.js.map +1 -1
  88. package/__internal__/src/utils/bem.d.ts +3 -0
  89. package/__internal__/src/utils/bem.js +1 -1
  90. package/__internal__/src/utils/bem.js.map +1 -1
  91. package/package.json +3 -3
  92. package/__internal__/src/components/NavbarCanary/Navbar.js +0 -2
  93. package/__internal__/src/components/NavbarCanary/Navbar.js.map +0 -1
  94. package/__internal__/src/components/NavbarCanary/NavbarArrow/NavbarArrow.js.map +0 -1
  95. package/__internal__/src/components/NavbarCanary/NavbarArrow/index.js.map +0 -1
  96. package/__internal__/src/components/NavbarCanary/NavbarItem/NavbarDrawer.js +0 -2
  97. package/__internal__/src/components/NavbarCanary/NavbarItem/NavbarDrawer.js.map +0 -1
  98. package/__internal__/src/components/NavbarCanary/NavbarItem/NavbarItem.js.map +0 -1
  99. package/__internal__/src/components/NavbarCanary/NavbarItem/index.js.map +0 -1
  100. package/__internal__/src/components/NavbarCanary/NavbarMixDriverLeftAnimate/NavbarMixDriverLeftAnimate.js.map +0 -1
  101. package/__internal__/src/components/NavbarCanary/NavbarMixDriverLeftAnimate/index.js.map +0 -1
  102. package/__internal__/src/components/NavbarCanary/NavbarMixDriverRightAnimate/NavbarMixDriverRightAnimate.js.map +0 -1
  103. package/__internal__/src/components/NavbarCanary/NavbarMixDriverRightAnimate/index.js.map +0 -1
  104. package/__internal__/src/components/NavbarCanary/NavbarMixFadeAnimate/NavbarMixFadeAnimate.js.map +0 -1
  105. package/__internal__/src/components/NavbarCanary/NavbarMixFadeAnimate/index.js.map +0 -1
  106. package/__internal__/src/components/NavbarCanary/NavbarRail/NavbarRail.js.map +0 -1
  107. package/__internal__/src/components/NavbarCanary/NavbarRail/index.js.map +0 -1
  108. package/__internal__/src/components/NavbarCanary/NavbarRailItem/NavbarRailItem.js.map +0 -1
  109. package/__internal__/src/components/NavbarCanary/NavbarRailItem/index.js.map +0 -1
  110. package/__internal__/src/components/NavbarCanary/helpers.js.map +0 -1
  111. package/__internal__/src/components/NavbarCanary/index.js.map +0 -1
  112. package/__internal__/src/components/NavbarCanary/types.js.map +0 -1
  113. package/__internal__/src/components/Notifications/NotificationsItem/helpers.js.map +0 -1
  114. /package/__internal__/src/components/{NavbarCanary → Navbar}/Navbar.d.ts +0 -0
  115. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarArrow/NavbarArrow.d.ts +0 -0
  116. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarArrow/NavbarArrow.js +0 -0
  117. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarArrow/index.d.ts +0 -0
  118. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarArrow/index.js +0 -0
  119. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarItem/NavbarDrawer.d.ts +0 -0
  120. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarItem/NavbarItem.css +0 -0
  121. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarItem/NavbarItem.d.ts +0 -0
  122. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarItem/NavbarItem.js +0 -0
  123. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarItem/index.d.ts +0 -0
  124. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarItem/index.js +0 -0
  125. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverLeftAnimate/NavbarMixDriverLeftAnimate.css +0 -0
  126. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverLeftAnimate/NavbarMixDriverLeftAnimate.d.ts +0 -0
  127. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverLeftAnimate/NavbarMixDriverLeftAnimate.js +0 -0
  128. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverLeftAnimate/index.d.ts +0 -0
  129. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverLeftAnimate/index.js +0 -0
  130. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverRightAnimate/NavbarMixDriverRightAnimate.css +0 -0
  131. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverRightAnimate/NavbarMixDriverRightAnimate.d.ts +0 -0
  132. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverRightAnimate/NavbarMixDriverRightAnimate.js +0 -0
  133. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverRightAnimate/index.d.ts +0 -0
  134. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixDriverRightAnimate/index.js +0 -0
  135. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixFadeAnimate/NavbarMixFadeAnimate.css +0 -0
  136. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixFadeAnimate/NavbarMixFadeAnimate.d.ts +0 -0
  137. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixFadeAnimate/NavbarMixFadeAnimate.js +0 -0
  138. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixFadeAnimate/index.d.ts +0 -0
  139. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarMixFadeAnimate/index.js +0 -0
  140. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRail/NavbarRail.d.ts +0 -0
  141. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRail/NavbarRail.js +0 -0
  142. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRail/index.d.ts +0 -0
  143. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRail/index.js +0 -0
  144. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRailItem/NavbarRailItem.css +0 -0
  145. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRailItem/NavbarRailItem.d.ts +0 -0
  146. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRailItem/index.d.ts +0 -0
  147. /package/__internal__/src/components/{NavbarCanary → Navbar}/NavbarRailItem/index.js +0 -0
  148. /package/__internal__/src/components/{NavbarCanary → Navbar}/helpers.d.ts +0 -0
  149. /package/__internal__/src/components/{NavbarCanary → Navbar}/helpers.js +0 -0
  150. /package/__internal__/src/components/{NavbarCanary → Navbar}/index.d.ts +0 -0
  151. /package/__internal__/src/components/{NavbarCanary → Navbar}/index.js +0 -0
  152. /package/__internal__/src/components/{NavbarCanary → Navbar}/types.d.ts +0 -0
  153. /package/__internal__/src/components/{NavbarCanary → Navbar}/types.js +0 -0
  154. /package/__internal__/src/components/Notifications/{NotificationsItem → NotificationsItemFooter}/helpers.d.ts +0 -0
  155. /package/__internal__/src/components/Notifications/{NotificationsItem → NotificationsItemFooter}/helpers.js +0 -0
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/components/Navbar";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/components/Navbar";
@@ -14,9 +14,8 @@ export type ButtonMenuPropGetItemHref<ITEM> = (item: ITEM) => string | undefined
14
14
  export type ButtonMenuPropGetItemTarget<ITEM> = (item: ITEM) => string | undefined;
15
15
  export type ButtonMenuPropGetItemIcon<ITEM> = (item: ITEM) => IconComponent | undefined;
16
16
  export type ButtonMenuPropGetItemOnClick<ITEM> = (item: ITEM) => React.EventHandler<React.MouseEvent> | undefined;
17
- export type ButtonMenuPropOnItemClick<ITEM> = (props: {
17
+ export type ButtonMenuPropOnItemClick<ITEM> = (item: ITEM, props: {
18
18
  e: React.MouseEvent;
19
- item: ITEM;
20
19
  }) => void;
21
20
  export type ButtonMenuProps<ITEM = ButtonMenuDefaultItem> = PropsWithHTMLAttributesAndRef<{
22
21
  items: ITEM[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/ButtonMenu/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport {\n ButtonPropForm,\n ButtonPropSize,\n ButtonPropView,\n} from '@consta/uikit/Button';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type ButtonMenuDefaultItem = {\n label: string;\n href?: string;\n target?: string;\n icon?: IconComponent;\n onClick?: React.EventHandler<React.MouseEvent>;\n};\n\nexport type ButtonMenuPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type ButtonMenuPropGetItemHref<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ButtonMenuPropGetItemTarget<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ButtonMenuPropGetItemIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type ButtonMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\nexport type ButtonMenuPropOnItemClick<ITEM> = (props: {\n e: React.MouseEvent;\n item: ITEM;\n}) => void;\n\nexport type ButtonMenuProps<ITEM = ButtonMenuDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onItemClick?: ButtonMenuPropOnItemClick<ITEM>;\n getItemHref?: ButtonMenuPropGetItemHref<ITEM>;\n getItemLabel?: ButtonMenuPropGetItemLabel<ITEM>;\n getItemTarget?: ButtonMenuPropGetItemTarget<ITEM>;\n getItemOnClick?: ButtonMenuPropGetItemOnClick<ITEM>;\n getItemIcon?: ButtonMenuPropGetItemIcon<ITEM>;\n form?: ButtonPropForm;\n size?: ButtonPropSize;\n view?: ButtonPropView;\n onlyIcon?: boolean;\n },\n HTMLDivElement\n > &\n (ITEM extends { label: ButtonMenuDefaultItem['label'] }\n ? {}\n : { getItemLabel: ButtonMenuPropGetItemLabel<ITEM> });\n\nexport type ButtonMenuComponent = <ITEM = ButtonMenuDefaultItem>(\n props: ButtonMenuProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/ButtonMenu/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport {\n ButtonPropForm,\n ButtonPropSize,\n ButtonPropView,\n} from '@consta/uikit/Button';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type ButtonMenuDefaultItem = {\n label: string;\n href?: string;\n target?: string;\n icon?: IconComponent;\n onClick?: React.EventHandler<React.MouseEvent>;\n};\n\nexport type ButtonMenuPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type ButtonMenuPropGetItemHref<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ButtonMenuPropGetItemTarget<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ButtonMenuPropGetItemIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type ButtonMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\nexport type ButtonMenuPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type ButtonMenuProps<ITEM = ButtonMenuDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onItemClick?: ButtonMenuPropOnItemClick<ITEM>;\n getItemHref?: ButtonMenuPropGetItemHref<ITEM>;\n getItemLabel?: ButtonMenuPropGetItemLabel<ITEM>;\n getItemTarget?: ButtonMenuPropGetItemTarget<ITEM>;\n getItemOnClick?: ButtonMenuPropGetItemOnClick<ITEM>;\n getItemIcon?: ButtonMenuPropGetItemIcon<ITEM>;\n form?: ButtonPropForm;\n size?: ButtonPropSize;\n view?: ButtonPropView;\n onlyIcon?: boolean;\n },\n HTMLDivElement\n > &\n (ITEM extends { label: ButtonMenuDefaultItem['label'] }\n ? {}\n : { getItemLabel: ButtonMenuPropGetItemLabel<ITEM> });\n\nexport type ButtonMenuComponent = <ITEM = ButtonMenuDefaultItem>(\n props: ButtonMenuProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","menuHideButtonText","menuMaxElements","menuShowButtonText","menuTitle","onItemClick","getItemAs","getItemKey","getItemAttributes","getItemSubMenu","getItemIconLeft","getItemLabel","getItemOnClick","banners","bannerPosition","onBannerClick","getBannerAs","getBannerAttributes","getBannerDescription","getBannerImage","getBannerLabel","getBannerOnClick","className"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./MegaMenu.css";import{IconArrowRight}from"@consta/icons/IconArrowRight";import React,{useCallback,useEffect,useMemo,useState}from"react";import{cn}from"../../utils/bem";import{getItemsDepth,separateItemsByDepth,withDefaultGetters}from"./helper";import{MegaMenuBannerBar}from"./MegaMenuBannerBar";import{MegaMenuGlobal}from"./MegaMenuGlobal";import{MegaMenuNavBar}from"./MegaMenuNavBar";const cnMegaMenu=cn("MegaMenu");export const MegaMenu=a=>{const b=withDefaultGetters(a),{items:c,menuHideButtonText:w="\u0421\u043A\u0440\u044B\u0442\u044C",menuMaxElements:d,menuShowButtonText:x="\u0415\u0449\u0451",menuTitle:e,onItemClick:f,getItemAs:g,getItemKey:h,getItemAttributes:i,getItemSubMenu:j,getItemIconLeft:k,getItemLabel:l,getItemOnClick:m,banners:n,bannerPosition:y="right",onBannerClick:o,getBannerAs:p,getBannerAttributes:q,getBannerDescription:r,getBannerImage:s,getBannerLabel:t,getBannerOnClick:u,className:v}=b,z=_objectWithoutProperties(b,_excluded),[A,B]=useState(),C=useCallback(a=>!!A&&h(A)===h(a),[A]),D=useMemo(()=>getItemsDepth(c,j),[c]),[E,F,G]=useMemo(()=>separateItemsByDepth({items:c,getItemKey:h,getItemSubMenu:j,getItemActive:C,depth:D}),[c,A]),{navItems:H,items:I,groups:J}=useMemo(()=>({navItems:2>D||2<D?E:void 0,groups:3>D?E:F,items:3>D?F:G}),[D,E,F,G]),K=(a,b)=>{null===f||void 0===f?void 0:f({e:a,item:b}),j(b)&&B(b)},L=(a,b)=>{var c;const d=null===(c=i(b))||void 0===c?void 0:c.onMouseEnter;null===d||void 0===d?void 0:d(a),j(b)&&B(b)};return useEffect(()=>{2<D&&j(c[0])&&B(c[0])},[D]),React.createElement("div",Object.assign({className:cnMegaMenu({withGlobalMenu:1<D,withBannersBar:0<(null!==n&&void 0!==n?n:[]).length,withNavBar:2!==D,bannerPosition:y},[v])},z),H&&React.createElement(MegaMenuNavBar,{items:H,className:cnMegaMenu("NavBar"),getItemActive:({item:a})=>C(a),getItemAs:({item:a})=>g(a),getItemAttributes:({item:a})=>_objectSpread(_objectSpread({},i(a)),{},{onMouseEnter:b=>L(b,a)}),getItemIconLeft:({item:a})=>k(a),getItemLabel:({item:a})=>l(a),getItemOnClick:({item:a})=>m(a),onItemClick:({e:a,item:{item:b}})=>K(a,b),getItemIconRight:({item:a})=>j(a)?IconArrowRight:void 0}),React.createElement("div",{className:cnMegaMenu("Wrapper")},2<=D&&React.createElement(MegaMenuGlobal,{className:cnMegaMenu("GlobalMenu"),items:I,groups:J,title:null!==e&&void 0!==e?e:A?l(A):void 0,getGroupKey:({item:a})=>h(a),getGroupLabel:({item:a})=>l(a),getItemAs:({item:a})=>g(a),getItemAttributes:({item:a})=>i(a),getItemGroupId:({groupId:a})=>a,getItemLabel:({item:a})=>l(a),getItemOnClick:({item:a})=>m(a),getGroupOnClick:({item:a})=>m(a),onGroupClick:f?({e:a,group:{item:b}})=>{null===f||void 0===f?void 0:f({e:a,item:b})}:void 0,onItemClick:f?({e:a,item:{item:b}})=>null===f||void 0===f?void 0:f({e:a,item:b}):void 0,maxElements:d,showButtonText:x,hideButtonText:w}),n&&React.createElement(MegaMenuBannerBar,{className:cnMegaMenu("BannerBar"),items:n,view:"right"===y?"vertical":"horizontal",onItemClick:o,getItemAs:p,getItemAttributes:q,getItemDescription:r,getItemImage:s,getItemLabel:t,getItemOnClick:u})))};export*from"./types";
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","menuHideButtonText","menuMaxElements","menuShowButtonText","menuTitle","onItemClick","getItemAs","getItemKey","getItemAttributes","getItemSubMenu","getItemIconLeft","getItemLabel","getItemOnClick","banners","bannerPosition","onBannerClick","getBannerAs","getBannerAttributes","getBannerDescription","getBannerImage","getBannerLabel","getBannerOnClick","className"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./MegaMenu.css";import{IconArrowRight}from"@consta/icons/IconArrowRight";import React,{useCallback,useEffect,useMemo,useState}from"react";import{cn}from"../../utils/bem";import{getItemsDepth,separateItemsByDepth,withDefaultGetters}from"./helper";import{MegaMenuBannerBar}from"./MegaMenuBannerBar";import{MegaMenuGlobal}from"./MegaMenuGlobal";import{MegaMenuNavBar}from"./MegaMenuNavBar";const cnMegaMenu=cn("MegaMenu");export const MegaMenu=a=>{const b=withDefaultGetters(a),{items:c,menuHideButtonText:w="\u0421\u043A\u0440\u044B\u0442\u044C",menuMaxElements:d,menuShowButtonText:x="\u0415\u0449\u0451",menuTitle:e,onItemClick:f,getItemAs:g,getItemKey:h,getItemAttributes:i,getItemSubMenu:j,getItemIconLeft:k,getItemLabel:l,getItemOnClick:m,banners:n,bannerPosition:y="right",onBannerClick:o,getBannerAs:p,getBannerAttributes:q,getBannerDescription:r,getBannerImage:s,getBannerLabel:t,getBannerOnClick:u,className:v}=b,z=_objectWithoutProperties(b,_excluded),[A,B]=useState(),C=useCallback(a=>!!A&&h(A)===h(a),[A]),D=useMemo(()=>getItemsDepth(c,j),[c]),[E,F,G]=useMemo(()=>separateItemsByDepth({items:c,getItemKey:h,getItemSubMenu:j,getItemActive:C,depth:D}),[c,A]),{navItems:H,items:I,groups:J}=useMemo(()=>({navItems:2>D||2<D?E:void 0,groups:3>D?E:F,items:3>D?F:G}),[D,E,F,G]),K=(a,b)=>{null===f||void 0===f?void 0:f(b,{e:a}),j(b)&&B(b)},L=(a,b)=>{var c;const d=null===(c=i(b))||void 0===c?void 0:c.onMouseEnter;null===d||void 0===d?void 0:d(a),j(b)&&B(b)};return useEffect(()=>{2<D&&j(c[0])&&B(c[0])},[D]),React.createElement("div",Object.assign({className:cnMegaMenu({withGlobalMenu:1<D,withBannersBar:0<(null!==n&&void 0!==n?n:[]).length,withNavBar:2!==D,bannerPosition:y},[v])},z),H&&React.createElement(MegaMenuNavBar,{items:H,className:cnMegaMenu("NavBar"),getItemActive:({item:a})=>C(a),getItemAs:({item:a})=>g(a),getItemAttributes:({item:a})=>_objectSpread(_objectSpread({},i(a)),{},{onMouseEnter:b=>L(b,a)}),getItemIconLeft:({item:a})=>k(a),getItemLabel:({item:a})=>l(a),getItemOnClick:({item:a})=>m(a),onItemClick:({item:a},{e:b})=>K(b,a),getItemIconRight:({item:a})=>j(a)?IconArrowRight:void 0}),React.createElement("div",{className:cnMegaMenu("Wrapper")},2<=D&&React.createElement(MegaMenuGlobal,{className:cnMegaMenu("GlobalMenu"),items:I,groups:J,title:null!==e&&void 0!==e?e:A?l(A):void 0,getGroupKey:({item:a})=>h(a),getGroupLabel:({item:a})=>l(a),getItemAs:({item:a})=>g(a),getItemAttributes:({item:a})=>i(a),getItemGroupId:({groupId:a})=>a,getItemLabel:({item:a})=>l(a),getItemOnClick:({item:a})=>m(a),getGroupOnClick:({item:a})=>m(a),onGroupClick:f?({item:a},{e:b})=>{null===f||void 0===f?void 0:f(a,{e:b})}:void 0,onItemClick:f?({item:a},{e:b})=>null===f||void 0===f?void 0:f(a,{e:b}):void 0,maxElements:d,showButtonText:x,hideButtonText:w}),n&&React.createElement(MegaMenuBannerBar,{className:cnMegaMenu("BannerBar"),items:n,view:"right"===y?"vertical":"horizontal",onItemClick:o,getItemAs:p,getItemAttributes:q,getItemDescription:r,getItemImage:s,getItemLabel:t,getItemOnClick:u})))};export*from"./types";
2
2
  //# sourceMappingURL=MegaMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MegaMenu.js","names":["IconArrowRight","React","useCallback","useEffect","useMemo","useState","cn","getItemsDepth","separateItemsByDepth","withDefaultGetters","MegaMenuBannerBar","MegaMenuGlobal","MegaMenuNavBar","cnMegaMenu","MegaMenu","props","b","items","itemsProp","menuHideButtonText","menuMaxElements","menuShowButtonText","menuTitle","onItemClick","onItemClickProp","getItemAs","getItemKey","getItemAttributes","getItemSubMenu","getItemIconLeft","getItemLabel","getItemOnClick","banners","bannerPosition","onBannerClick","getBannerAs","getBannerAttributes","getBannerDescription","getBannerImage","getBannerLabel","getBannerOnClick","className","otherProps","_objectWithoutProperties","_excluded","activeItem","setActiveItem","getItemActive","item","depth","firstLevel","secondLevel","thirdLevel","navItems","groups","handleNavBarClick","e","handleNavBarMouseEnter","c","onMouseEnter","createElement","Object","assign","withGlobalMenu","withBannersBar","length","withNavBar","_objectSpread","getItemIconRight","title","getGroupKey","getGroupLabel","getItemGroupId","groupId","getGroupOnClick","onGroupClick","group","maxElements","showButtonText","hideButtonText","view","getItemDescription","getItemImage"],"sources":["../../../../../src/components/MegaMenu/MegaMenu.tsx"],"sourcesContent":["import './MegaMenu.css';\n\nimport { IconArrowRight } from '@consta/icons/IconArrowRight';\nimport { AsTagAttribute } from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport {\n getItemsDepth,\n separateItemsByDepth,\n withDefaultGetters,\n} from './helper';\nimport { MegaMenuBannerBar } from './MegaMenuBannerBar';\nimport { MegaMenuGlobal } from './MegaMenuGlobal';\nimport { MegaMenuNavBar } from './MegaMenuNavBar';\nimport { MegaMenuProps } from './types';\n\nconst cnMegaMenu = cn('MegaMenu');\n\nexport const MegaMenu = (props: MegaMenuProps) => {\n const {\n // GlobalMenu\n items: itemsProp,\n menuHideButtonText = 'Скрыть',\n menuMaxElements,\n menuShowButtonText = 'Ещё',\n menuTitle,\n onItemClick: onItemClickProp,\n getItemAs,\n getItemKey,\n getItemAttributes,\n getItemSubMenu,\n getItemIconLeft,\n getItemLabel,\n getItemOnClick,\n // BannerBar\n banners,\n bannerPosition = 'right',\n onBannerClick,\n getBannerAs,\n getBannerAttributes,\n getBannerDescription,\n getBannerImage,\n getBannerLabel,\n getBannerOnClick,\n // Others\n className,\n ...otherProps\n } = withDefaultGetters(props);\n type ITEM = (typeof itemsProp)[number];\n\n const [activeItem, setActiveItem] = useState<ITEM | undefined>();\n\n const getItemActive = useCallback(\n (item: ITEM) =>\n activeItem ? getItemKey(activeItem) === getItemKey(item) : false,\n [activeItem],\n );\n\n const depth = useMemo(\n () => getItemsDepth(itemsProp, getItemSubMenu),\n [itemsProp],\n );\n\n const [firstLevel, secondLevel, thirdLevel] = useMemo(\n () =>\n separateItemsByDepth({\n items: itemsProp,\n getItemKey,\n getItemSubMenu,\n getItemActive,\n depth,\n }),\n [itemsProp, activeItem],\n );\n\n const { navItems, items, groups } = useMemo(() => {\n return {\n navItems: depth < 2 || depth > 2 ? firstLevel : undefined,\n groups: depth < 3 ? firstLevel : secondLevel,\n items: depth < 3 ? secondLevel : thirdLevel,\n };\n }, [depth, firstLevel, secondLevel, thirdLevel]);\n\n const handleNavBarClick = (e: React.MouseEvent, item: ITEM) => {\n onItemClickProp?.({ e, item });\n if (getItemSubMenu(item)) {\n setActiveItem(item);\n }\n };\n\n const handleNavBarMouseEnter = (\n e: React.MouseEvent<HTMLDivElement>,\n item: ITEM,\n ) => {\n const onMouseEnter = getItemAttributes(item)\n ?.onMouseEnter as AsTagAttribute<'div'>['onMouseEnter'];\n onMouseEnter?.(e);\n if (getItemSubMenu(item)) {\n setActiveItem(item);\n }\n };\n\n useEffect(() => {\n if (depth > 2 && getItemSubMenu(itemsProp[0])) {\n setActiveItem(itemsProp[0]);\n }\n }, [depth]);\n\n return (\n <div\n className={cnMegaMenu(\n {\n withGlobalMenu: depth > 1,\n withBannersBar: (banners ?? []).length > 0,\n withNavBar: depth !== 2,\n bannerPosition,\n },\n [className],\n )}\n {...otherProps}\n >\n {navItems && (\n <MegaMenuNavBar\n items={navItems}\n className={cnMegaMenu('NavBar')}\n getItemActive={({ item }) => getItemActive(item)}\n getItemAs={({ item }) => getItemAs(item)}\n getItemAttributes={({ item }) =>\n ({\n ...getItemAttributes(item),\n onMouseEnter: (e: React.MouseEvent<HTMLDivElement>) =>\n handleNavBarMouseEnter(e, item),\n } as AsTagAttribute<'div'>)\n }\n getItemIconLeft={({ item }) => getItemIconLeft(item)}\n getItemLabel={({ item }) => getItemLabel(item)}\n getItemOnClick={({ item }) => getItemOnClick(item)}\n onItemClick={({ e, item: { item } }) => handleNavBarClick(e, item)}\n getItemIconRight={({ item }) =>\n getItemSubMenu(item) ? IconArrowRight : undefined\n }\n />\n )}\n <div className={cnMegaMenu('Wrapper')}>\n {depth >= 2 && (\n <MegaMenuGlobal\n className={cnMegaMenu('GlobalMenu')}\n items={items}\n groups={groups}\n title={\n menuTitle ?? (activeItem ? getItemLabel(activeItem) : undefined)\n }\n getGroupKey={({ item }) => getItemKey(item)}\n getGroupLabel={({ item }) => getItemLabel(item)}\n getItemAs={({ item }) => getItemAs(item)}\n getItemAttributes={({ item }) => getItemAttributes(item)}\n getItemGroupId={({ groupId }) => groupId}\n getItemLabel={({ item }) => getItemLabel(item)}\n getItemOnClick={({ item }) => getItemOnClick(item)}\n getGroupOnClick={({ item }) => getItemOnClick(item)}\n onGroupClick={\n onItemClickProp\n ? ({ e, group: { item } }) => {\n onItemClickProp?.({ e, item });\n }\n : undefined\n }\n onItemClick={\n onItemClickProp\n ? ({ e, item: { item } }) => onItemClickProp?.({ e, item })\n : undefined\n }\n maxElements={menuMaxElements}\n showButtonText={menuShowButtonText}\n hideButtonText={menuHideButtonText}\n />\n )}\n {banners && (\n <MegaMenuBannerBar\n className={cnMegaMenu('BannerBar')}\n items={banners}\n view={bannerPosition === 'right' ? 'vertical' : 'horizontal'}\n onItemClick={onBannerClick}\n getItemAs={getBannerAs}\n getItemAttributes={getBannerAttributes}\n getItemDescription={getBannerDescription}\n getItemImage={getBannerImage}\n getItemLabel={getBannerLabel}\n getItemOnClick={getBannerOnClick}\n />\n )}\n </div>\n </div>\n );\n};\n\nexport * from './types';\n"],"mappings":"ioCAAA,uBAEA,OAASA,cAAc,KAAQ,8BAA8B,CAE7D,MAAO,CAAAC,KAAK,EAAIC,WAAW,CAAEC,SAAS,CAAEC,OAAO,CAAEC,QAAQ,KAAQ,OAAO,CAExE,OAASC,EAAE,uBAEX,OACEC,aAAa,CACbC,oBAAoB,CACpBC,kBAAkB,gBAEpB,OAASC,iBAAiB,2BAC1B,OAASC,cAAc,wBACvB,OAASC,cAAc,wBAGvB,KAAM,CAAAC,UAAU,CAAGP,EAAE,CAAC,UAAU,CAAC,CAEjC,MAAO,MAAM,CAAAQ,QAAQ,CAAIC,CAAoB,EAAK,OAAAC,CAAA,CA6B5CP,kBAAkB,CAACM,CAAK,CAAC,CA5BvB,CAEJE,KAAK,CAAEC,CAAS,CAChBC,kBAAkB,CAAlBA,CAAkB,CAAG,sCAAQ,CAC7BC,eAAe,CAAfA,CAAe,CACfC,kBAAkB,CAAlBA,CAAkB,CAAG,oBAAK,CAC1BC,SAAS,CAATA,CAAS,CACTC,WAAW,CAAEC,CAAe,CAC5BC,SAAS,CAATA,CAAS,CACTC,UAAU,CAAVA,CAAU,CACVC,iBAAiB,CAAjBA,CAAiB,CACjBC,cAAc,CAAdA,CAAc,CACdC,eAAe,CAAfA,CAAe,CACfC,YAAY,CAAZA,CAAY,CACZC,cAAc,CAAdA,CAAc,CAEdC,OAAO,CAAPA,CAAO,CACPC,cAAc,CAAdA,CAAc,CAAG,OAAO,CACxBC,aAAa,CAAbA,CAAa,CACbC,WAAW,CAAXA,CAAW,CACXC,mBAAmB,CAAnBA,CAAmB,CACnBC,oBAAoB,CAApBA,CAAoB,CACpBC,cAAc,CAAdA,CAAc,CACdC,cAAc,CAAdA,CAAc,CACdC,gBAAgB,CAAhBA,CAAgB,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AAgB,CAC7B0D,cAAc,CAAEzD,CAAmB,CACnC0D,cAAc,CAAE5D,CAAmB,CACpC,CACF,CACAa,CAAO,EACN/B,KAAA,CAAA2D,aAAA,CAAClD,iBAAiB,EAChB+B,SAAS,CAAE5B,UAAU,CAAC,WAAW,CAAE,CACnCI,KAAK,CAAEe,CAAQ,CACfgD,IAAI,CAAqB,OAAO,GAA1B/C,CAA0B,CAAG,UAAU,CAAG,YAAa,CAC7DV,WAAW,CAAEW,CAAc,CAC3BT,SAAS,CAAEU,CAAY,CACvBR,iBAAiB,CAAES,CAAoB,CACvC6C,kBAAkB,CAAE5C,CAAqB,CACzC6C,YAAY,CAAE5C,CAAe,CAC7BR,YAAY,CAAES,CAAe,CAC7BR,cAAc,CAAES,CAAiB,CAClC,CAEA,CACF,CAET,CAAC,CAED"}
1
+ {"version":3,"file":"MegaMenu.js","names":["IconArrowRight","React","useCallback","useEffect","useMemo","useState","cn","getItemsDepth","separateItemsByDepth","withDefaultGetters","MegaMenuBannerBar","MegaMenuGlobal","MegaMenuNavBar","cnMegaMenu","MegaMenu","props","b","items","itemsProp","menuHideButtonText","menuMaxElements","menuShowButtonText","menuTitle","onItemClick","onItemClickProp","getItemAs","getItemKey","getItemAttributes","getItemSubMenu","getItemIconLeft","getItemLabel","getItemOnClick","banners","bannerPosition","onBannerClick","getBannerAs","getBannerAttributes","getBannerDescription","getBannerImage","getBannerLabel","getBannerOnClick","className","otherProps","_objectWithoutProperties","_excluded","activeItem","setActiveItem","getItemActive","item","depth","firstLevel","secondLevel","thirdLevel","navItems","groups","handleNavBarClick","e","handleNavBarMouseEnter","c","onMouseEnter","createElement","Object","assign","withGlobalMenu","withBannersBar","length","withNavBar","_objectSpread","getItemIconRight","title","getGroupKey","getGroupLabel","getItemGroupId","groupId","getGroupOnClick","onGroupClick","maxElements","showButtonText","hideButtonText","view","getItemDescription","getItemImage"],"sources":["../../../../../src/components/MegaMenu/MegaMenu.tsx"],"sourcesContent":["import './MegaMenu.css';\n\nimport { IconArrowRight } from '@consta/icons/IconArrowRight';\nimport { AsTagAttribute } from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport {\n getItemsDepth,\n separateItemsByDepth,\n withDefaultGetters,\n} from './helper';\nimport { MegaMenuBannerBar } from './MegaMenuBannerBar';\nimport { MegaMenuGlobal } from './MegaMenuGlobal';\nimport { MegaMenuNavBar } from './MegaMenuNavBar';\nimport { MegaMenuProps } from './types';\n\nconst cnMegaMenu = cn('MegaMenu');\n\nexport const MegaMenu = (props: MegaMenuProps) => {\n const {\n // GlobalMenu\n items: itemsProp,\n menuHideButtonText = 'Скрыть',\n menuMaxElements,\n menuShowButtonText = 'Ещё',\n menuTitle,\n onItemClick: onItemClickProp,\n getItemAs,\n getItemKey,\n getItemAttributes,\n getItemSubMenu,\n getItemIconLeft,\n getItemLabel,\n getItemOnClick,\n // BannerBar\n banners,\n bannerPosition = 'right',\n onBannerClick,\n getBannerAs,\n getBannerAttributes,\n getBannerDescription,\n getBannerImage,\n getBannerLabel,\n getBannerOnClick,\n // Others\n className,\n ...otherProps\n } = withDefaultGetters(props);\n type ITEM = (typeof itemsProp)[number];\n\n const [activeItem, setActiveItem] = useState<ITEM | undefined>();\n\n const getItemActive = useCallback(\n (item: ITEM) =>\n activeItem ? getItemKey(activeItem) === getItemKey(item) : false,\n [activeItem],\n );\n\n const depth = useMemo(\n () => getItemsDepth(itemsProp, getItemSubMenu),\n [itemsProp],\n );\n\n const [firstLevel, secondLevel, thirdLevel] = useMemo(\n () =>\n separateItemsByDepth({\n items: itemsProp,\n getItemKey,\n getItemSubMenu,\n getItemActive,\n depth,\n }),\n [itemsProp, activeItem],\n );\n\n const { navItems, items, groups } = useMemo(() => {\n return {\n navItems: depth < 2 || depth > 2 ? firstLevel : undefined,\n groups: depth < 3 ? firstLevel : secondLevel,\n items: depth < 3 ? secondLevel : thirdLevel,\n };\n }, [depth, firstLevel, secondLevel, thirdLevel]);\n\n const handleNavBarClick = (e: React.MouseEvent, item: ITEM) => {\n onItemClickProp?.(item, { e });\n if (getItemSubMenu(item)) {\n setActiveItem(item);\n }\n };\n\n const handleNavBarMouseEnter = (\n e: React.MouseEvent<HTMLDivElement>,\n item: ITEM,\n ) => {\n const onMouseEnter = getItemAttributes(item)\n ?.onMouseEnter as AsTagAttribute<'div'>['onMouseEnter'];\n onMouseEnter?.(e);\n if (getItemSubMenu(item)) {\n setActiveItem(item);\n }\n };\n\n useEffect(() => {\n if (depth > 2 && getItemSubMenu(itemsProp[0])) {\n setActiveItem(itemsProp[0]);\n }\n }, [depth]);\n\n return (\n <div\n className={cnMegaMenu(\n {\n withGlobalMenu: depth > 1,\n withBannersBar: (banners ?? []).length > 0,\n withNavBar: depth !== 2,\n bannerPosition,\n },\n [className],\n )}\n {...otherProps}\n >\n {navItems && (\n <MegaMenuNavBar\n items={navItems}\n className={cnMegaMenu('NavBar')}\n getItemActive={({ item }) => getItemActive(item)}\n getItemAs={({ item }) => getItemAs(item)}\n getItemAttributes={({ item }) =>\n ({\n ...getItemAttributes(item),\n onMouseEnter: (e: React.MouseEvent<HTMLDivElement>) =>\n handleNavBarMouseEnter(e, item),\n } as AsTagAttribute<'div'>)\n }\n getItemIconLeft={({ item }) => getItemIconLeft(item)}\n getItemLabel={({ item }) => getItemLabel(item)}\n getItemOnClick={({ item }) => getItemOnClick(item)}\n onItemClick={({ item }, { e }) => handleNavBarClick(e, item)}\n getItemIconRight={({ item }) =>\n getItemSubMenu(item) ? IconArrowRight : undefined\n }\n />\n )}\n <div className={cnMegaMenu('Wrapper')}>\n {depth >= 2 && (\n <MegaMenuGlobal\n className={cnMegaMenu('GlobalMenu')}\n items={items}\n groups={groups}\n title={\n menuTitle ?? (activeItem ? getItemLabel(activeItem) : undefined)\n }\n getGroupKey={({ item }) => getItemKey(item)}\n getGroupLabel={({ item }) => getItemLabel(item)}\n getItemAs={({ item }) => getItemAs(item)}\n getItemAttributes={({ item }) => getItemAttributes(item)}\n getItemGroupId={({ groupId }) => groupId}\n getItemLabel={({ item }) => getItemLabel(item)}\n getItemOnClick={({ item }) => getItemOnClick(item)}\n getGroupOnClick={({ item }) => getItemOnClick(item)}\n onGroupClick={\n onItemClickProp\n ? ({ item }, { e }) => {\n onItemClickProp?.(item, { e });\n }\n : undefined\n }\n onItemClick={\n onItemClickProp\n ? ({ item }, { e }) => onItemClickProp?.(item, { e })\n : undefined\n }\n maxElements={menuMaxElements}\n showButtonText={menuShowButtonText}\n hideButtonText={menuHideButtonText}\n />\n )}\n {banners && (\n <MegaMenuBannerBar\n className={cnMegaMenu('BannerBar')}\n items={banners}\n view={bannerPosition === 'right' ? 'vertical' : 'horizontal'}\n onItemClick={onBannerClick}\n getItemAs={getBannerAs}\n getItemAttributes={getBannerAttributes}\n getItemDescription={getBannerDescription}\n getItemImage={getBannerImage}\n getItemLabel={getBannerLabel}\n getItemOnClick={getBannerOnClick}\n />\n )}\n </div>\n </div>\n );\n};\n\nexport * from './types';\n"],"mappings":"ioCAAA,uBAEA,OAASA,cAAc,KAAQ,8BAA8B,CAE7D,MAAO,CAAAC,KAAK,EAAIC,WAAW,CAAEC,SAAS,CAAEC,OAAO,CAAEC,QAAQ,KAAQ,OAAO,CAExE,OAASC,EAAE,uBAEX,OACEC,aAAa,CACbC,oBAAoB,CACpBC,kBAAkB,gBAEpB,OAASC,iBAAiB,2BAC1B,OAASC,cAAc,wBACvB,OAASC,cAAc,wBAGvB,KAAM,CAAAC,UAAU,CAAGP,EAAE,CAAC,UAAU,CAAC,CAEjC,MAAO,MAAM,CAAAQ,QAAQ,CAAIC,CAAoB,EAAK,OAAAC,CAAA,CA6B5CP,kBAAkB,CAACM,CAAK,CAAC,CA5BvB,CAEJE,KAAK,CAAEC,CAAS,CAChBC,kBAAkB,CAAlBA,CAAkB,CAAG,sCAAQ,CAC7BC,eAAe,CAAfA,CAAe,CACfC,kBAAkB,CAAlBA,CAAkB,CAAG,oBAAK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EwB,IAAI,CAAJA,CAAK,CAAC,CAAE,CAAEQ,CAAC,CAADA,CAAE,CAAC,GAAK,QACnBhC,CAAe,WAAfA,CAAe,QAAfA,CAAe,CAAGwB,CAAI,CAAE,CAAEQ,CAAC,CAADA,CAAE,CAAC,CAC/B,CAAC,OAEN,CACDjC,WAAW,CACTC,CAAe,CACX,CAAC,CAAEwB,IAAI,CAAJA,CAAK,CAAC,CAAE,CAAEQ,CAAC,CAADA,CAAE,CAAC,UAAKhC,CAAe,WAAfA,CAAe,QAAfA,CAAe,CAAGwB,CAAI,CAAE,CAAEQ,CAAC,CAADA,CAAE,CAAC,CAAC,OAExD,CACDoB,WAAW,CAAExD,CAAgB,CAC7ByD,cAAc,CAAExD,CAAmB,CACnCyD,cAAc,CAAE3D,CAAmB,CACpC,CACF,CACAa,CAAO,EACN/B,KAAA,CAAA2D,aAAA,CAAClD,iBAAiB,EAChB+B,SAAS,CAAE5B,UAAU,CAAC,WAAW,CAAE,CACnCI,KAAK,CAAEe,CAAQ,CACf+C,IAAI,CAAqB,OAAO,GAA1B9C,CAA0B,CAAG,UAAU,CAAG,YAAa,CAC7DV,WAAW,CAAEW,CAAc,CAC3BT,SAAS,CAAEU,CAAY,CACvBR,iBAAiB,CAAES,CAAoB,CACvC4C,kBAAkB,CAAE3C,CAAqB,CACzC4C,YAAY,CAAE3C,CAAe,CAC7BR,YAAY,CAAES,CAAe,CAC7BR,cAAc,CAAES,CAAiB,CAClC,CAEA,CACF,CAET,CAAC,CAED"}
@@ -1,2 +1,2 @@
1
- import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["label","description","image","onClick","as","className","view"];import"./MegaMenuBannerBarItem.css";import{IconForward}from"@consta/icons/IconForward";import{Button}from"@consta/uikit/Button";import{cnMixCard}from"@consta/uikit/MixCard";import{Text}from"@consta/uikit/Text";import React,{forwardRef}from"react";import{cn}from"../../../../utils/bem";const cnMegaMenuBannerBarItem=cn("MegaMenuBannerBarItem"),MegaMenuBannerBarItemRender=(a,b)=>{const{label:c,description:d,image:e,onClick:f,as:h="div",className:g,view:i="vertical"}=a,j=_objectWithoutProperties(a,_excluded);return React.createElement(h,Object.assign({className:cnMegaMenuBannerBarItem({view:i},[g,cnMixCard({verticalSpace:"l",horizontalSpace:"l",shadow:!0,form:"round"})]),ref:b},j),e&&React.createElement("div",{className:cnMegaMenuBannerBarItem("ImageContainer")},React.createElement("img",{className:cnMegaMenuBannerBarItem("Image"),alt:c,src:e})),React.createElement("div",{className:cnMegaMenuBannerBarItem("Content")},React.createElement(Text,{weight:"semibold",size:"m",lineHeight:"m",className:cnMegaMenuBannerBarItem("Title")},c),d&&React.createElement(Text,{className:cnMegaMenuBannerBarItem("Description"),size:"m",lineHeight:"m"},d),React.createElement(Button,{className:cnMegaMenuBannerBarItem("Button"),label:"\u041F\u043E\u0434\u0440\u043E\u0431\u043D\u0435\u0435",iconRight:IconForward,size:"s",view:"clear",onClick:f})))};export const MegaMenuBannerBarItem=forwardRef(MegaMenuBannerBarItemRender);
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["label","description","image","onClick","as","className","view"];import"./MegaMenuBannerBarItem.css";import{IconForward}from"@consta/icons/IconForward";import{Button}from"@consta/uikit/Button";import{cnMixCard}from"@consta/uikit/MixCard";import{Text}from"@consta/uikit/Text";import React,{forwardRef}from"react";import{cn}from"../../../../utils/bem";const cnMegaMenuBannerBarItem=cn("MegaMenuBannerBarItem"),MegaMenuBannerBarItemRender=(a,b)=>{const{label:c,description:d,image:e,onClick:f,as:h="div",className:g,view:i="vertical"}=a,j=_objectWithoutProperties(a,_excluded);return React.createElement(h,Object.assign({className:cnMegaMenuBannerBarItem({view:i},[g,cnMixCard({verticalSpace:"l",horizontalSpace:"l",shadow:!0,form:"round"})]),ref:b},j),e&&React.createElement("div",{className:cnMegaMenuBannerBarItem("ImageContainer")},React.createElement("img",{className:cnMegaMenuBannerBarItem("Image"),alt:c,src:e})),React.createElement("div",{className:cnMegaMenuBannerBarItem("Content")},React.createElement(Text,{view:"primary",weight:"semibold",size:"m",lineHeight:"m",className:cnMegaMenuBannerBarItem("Title")},c),d&&React.createElement(Text,{className:cnMegaMenuBannerBarItem("Description"),view:"primary",size:"m",lineHeight:"m"},d),React.createElement(Button,{className:cnMegaMenuBannerBarItem("Button"),label:"\u041F\u043E\u0434\u0440\u043E\u0431\u043D\u0435\u0435",iconRight:IconForward,size:"s",view:"clear",onClick:f})))};export const MegaMenuBannerBarItem=forwardRef(MegaMenuBannerBarItemRender);
2
2
  //# sourceMappingURL=MegaMenuBannerBarItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MegaMenuBannerBarItem.js","names":["IconForward","Button","cnMixCard","Text","React","forwardRef","cn","cnMegaMenuBannerBarItem","MegaMenuBannerBarItemRender","props","ref","label","description","image","onClick","as","Tag","className","view","otherProps","_objectWithoutProperties","_excluded","createElement","h","Object","assign","verticalSpace","horizontalSpace","shadow","form","alt","src","weight","size","lineHeight","iconRight","MegaMenuBannerBarItem"],"sources":["../../../../../../../src/components/MegaMenu/MegaMenuBannerBar/MegaMenuBannerBarItem/MegaMenuBannerBarItem.tsx"],"sourcesContent":["import './MegaMenuBannerBarItem.css';\n\nimport { IconForward } from '@consta/icons/IconForward';\nimport { Button } from '@consta/uikit/Button';\nimport { cnMixCard } from '@consta/uikit/MixCard';\nimport { Text } from '@consta/uikit/Text';\nimport React, { forwardRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport {\n MegaMenuBannerBarItemComponent,\n MegaMenuBannerBarItemProps,\n} from '../types';\n\nconst cnMegaMenuBannerBarItem = cn('MegaMenuBannerBarItem');\n\nconst MegaMenuBannerBarItemRender = (\n props: MegaMenuBannerBarItemProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n label,\n description,\n image,\n onClick,\n as: Tag = 'div',\n className,\n view = 'vertical',\n ...otherProps\n } = props;\n\n return (\n <Tag\n className={cnMegaMenuBannerBarItem({ view }, [\n className,\n cnMixCard({\n verticalSpace: 'l',\n horizontalSpace: 'l',\n shadow: true,\n form: 'round',\n }),\n ])}\n ref={ref}\n {...otherProps}\n >\n {image && (\n <div className={cnMegaMenuBannerBarItem('ImageContainer')}>\n <img\n className={cnMegaMenuBannerBarItem('Image')}\n alt={label}\n src={image}\n />\n </div>\n )}\n <div className={cnMegaMenuBannerBarItem('Content')}>\n <Text\n weight=\"semibold\"\n size=\"m\"\n lineHeight=\"m\"\n className={cnMegaMenuBannerBarItem('Title')}\n >\n {label}\n </Text>\n {description && (\n <Text\n className={cnMegaMenuBannerBarItem('Description')}\n size=\"m\"\n lineHeight=\"m\"\n >\n {description}\n </Text>\n )}\n <Button\n className={cnMegaMenuBannerBarItem('Button')}\n label=\"Подробнее\"\n iconRight={IconForward}\n size=\"s\"\n view=\"clear\"\n onClick={onClick}\n />\n </div>\n </Tag>\n );\n};\n\nexport const MegaMenuBannerBarItem = forwardRef(\n MegaMenuBannerBarItemRender,\n) as MegaMenuBannerBarItemComponent;\n"],"mappings":"uKAAA,oCAEA,OAASA,WAAW,KAAQ,2BAA2B,CACvD,OAASC,MAAM,KAAQ,sBAAsB,CAC7C,OAASC,SAAS,KAAQ,uBAAuB,CACjD,OAASC,IAAI,KAAQ,oBAAoB,CACzC,MAAO,CAAAC,KAAK,EAAIC,UAAU,KAAQ,OAAO,CAEzC,OAASC,EAAE,6BAAuB,KAO5B,CAAAC,uBAAuB,CAAGD,EAAE,CAAC,uBAAuB,CAAC,CAErDE,2BAA2B,CAAGA,CAClCC,CAAiC,CACjCC,CAA8B,GAC3B,CACH,KAAM,CACJC,KAAK,CAALA,CAAK,CACLC,WAAW,CAAXA,CAAW,CACXC,KAAK,CAALA,CAAK,CACLC,OAAO,CAAPA,CAAO,CACPC,EAAE,CAAEC,CAAG,CAAG,KAAK,CACfC,SAAS,CAATA,CAAS,CACTC,IAAI,CAAJA,CAAI,CAAG,UAET,CAAC,CAAGT,CAAK,CADJU,CAAU,CAAAC,wBAAA,C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AAQ,CAClB,CACE,CACF,CAET,CAAC,CAED,MAAO,MAAM,CAAAsB,qBAAqB,CAAG/B,UAAU,CAC7CG,2BACF,CAAmC"}
1
+ {"version":3,"file":"MegaMenuBannerBarItem.js","names":["IconForward","Button","cnMixCard","Text","React","forwardRef","cn","cnMegaMenuBannerBarItem","MegaMenuBannerBarItemRender","props","ref","label","description","image","onClick","as","Tag","className","view","otherProps","_objectWithoutProperties","_excluded","createElement","h","Object","assign","verticalSpace","horizontalSpace","shadow","form","alt","src","weight","size","lineHeight","iconRight","MegaMenuBannerBarItem"],"sources":["../../../../../../../src/components/MegaMenu/MegaMenuBannerBar/MegaMenuBannerBarItem/MegaMenuBannerBarItem.tsx"],"sourcesContent":["import './MegaMenuBannerBarItem.css';\n\nimport { IconForward } from '@consta/icons/IconForward';\nimport { Button } from '@consta/uikit/Button';\nimport { cnMixCard } from '@consta/uikit/MixCard';\nimport { Text } from '@consta/uikit/Text';\nimport React, { forwardRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport {\n MegaMenuBannerBarItemComponent,\n MegaMenuBannerBarItemProps,\n} from '../types';\n\nconst cnMegaMenuBannerBarItem = cn('MegaMenuBannerBarItem');\n\nconst MegaMenuBannerBarItemRender = (\n props: MegaMenuBannerBarItemProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n label,\n description,\n image,\n onClick,\n as: Tag = 'div',\n className,\n view = 'vertical',\n ...otherProps\n } = props;\n\n return (\n <Tag\n className={cnMegaMenuBannerBarItem({ view }, [\n className,\n cnMixCard({\n verticalSpace: 'l',\n horizontalSpace: 'l',\n shadow: true,\n form: 'round',\n }),\n ])}\n ref={ref}\n {...otherProps}\n >\n {image && (\n <div className={cnMegaMenuBannerBarItem('ImageContainer')}>\n <img\n className={cnMegaMenuBannerBarItem('Image')}\n alt={label}\n src={image}\n />\n </div>\n )}\n <div className={cnMegaMenuBannerBarItem('Content')}>\n <Text\n view=\"primary\"\n weight=\"semibold\"\n size=\"m\"\n lineHeight=\"m\"\n className={cnMegaMenuBannerBarItem('Title')}\n >\n {label}\n </Text>\n {description && (\n <Text\n className={cnMegaMenuBannerBarItem('Description')}\n view=\"primary\"\n size=\"m\"\n lineHeight=\"m\"\n >\n {description}\n </Text>\n )}\n <Button\n className={cnMegaMenuBannerBarItem('Button')}\n label=\"Подробнее\"\n iconRight={IconForward}\n size=\"s\"\n view=\"clear\"\n onClick={onClick}\n />\n </div>\n </Tag>\n );\n};\n\nexport const MegaMenuBannerBarItem = forwardRef(\n MegaMenuBannerBarItemRender,\n) as MegaMenuBannerBarItemComponent;\n"],"mappings":"uKAAA,oCAEA,OAASA,WAAW,KAAQ,2BAA2B,CACvD,OAASC,MAAM,KAAQ,sBAAsB,CAC7C,OAASC,SAAS,KAAQ,uBAAuB,CACjD,OAASC,IAAI,KAAQ,oBAAoB,CACzC,MAAO,CAAAC,KAAK,EAAIC,UAAU,KAAQ,OAAO,CAEzC,OAASC,EAAE,6BAAuB,KAO5B,CAAAC,uBAAuB,CAAGD,EAAE,CAAC,uBAAuB,CAAC,CAErDE,2BAA2B,CAAGA,CAClCC,CAAiC,CACjCC,CAA8B,GAC3B,CACH,KAAM,CACJC,KAAK,CAALA,CAAK,CACLC,WAAW,CAAXA,CAAW,CACXC,KAAK,CAALA,CAAK,CACLC,OAAO,CAAPA,CAAO,CACPC,EAAE,CAAEC,CAAG,CAAG,KAAK,CACfC,SAAS,CAATA,CAAS,CACTC,IAAI,CAAJA,CAAI,CAAG,UAET,CAAC,CAAGT,CAAK,CADJU,CAAU,CAAAC,wBAAA,CACXX,CAAK,CAAAY,SAAA,EAET,MACE,CAAAjB,KAAA,CAAAkB,aAAA,CAACC,CAAG,CAAAC,MAAA,CAAAC,MAAA,EACFR,SAAS,CAAEV,uBAAuB,CAAC,CAAEW,IAAI,CAAJA,CAAK,CAAC,CAAE,CAC3CD,CAAS,CACTf,SAAS,CAAC,CACRwB,aAAa,CAAE,GAAG,CAClBC,eAAe,CAAE,GAAG,CACpBC,MAAM,GAAM,CACZC,IAAI,CAAE,OACR,CAAC,CAAC,CACH,CAAE,CACHnB,GAAG,CAAEA,CAAI,EACLS,CAAU,EAEbN,CAAK,EACJT,KAAA,CAAAkB,aAAA,QAAKL,SAAS,CAAEV,uBAAuB,CAAC,gBAAgB,CAAE,EACxDH,KAAA,CAAAkB,aAAA,QACEL,SAAS,CAAEV,uBAAuB,CAAC,OAAO,CAAE,CAC5CuB,GAAG,CAAEnB,CAAM,CACXoB,GAAG,CAAElB,CAAM,CACZ,CACE,CACN,CACDT,KAAA,CAAAkB,aAAA,QAAKL,SAAS,CAAEV,uBAAuB,CAAC,SAAS,CAAE,EACjDH,KAAA,CAAAkB,aAAA,CAACnB,IAAI,EACHe,IAAI,CAAC,SAAS,CACdc,MAAM,CAAC,UAAU,CACjBC,IAAI,CAAC,GAAG,CACRC,UAAU,CAAC,GAAG,CACdjB,SAAS,CAAEV,uBAAuB,CAAC,OAAO,CAAE,EAE3CI,CACG,CAAC,CACNC,CAAW,EACVR,KAAA,CAAAkB,aAAA,CAACnB,IAAI,EACHc,SAAS,CAAEV,uBAAuB,CAAC,aAAa,CAAE,CAClDW,IAAI,CAAC,SAAS,CACde,IAAI,CAAC,GAAG,CACRC,UAAU,CAAC,GAAG,EAEbtB,CACG,CACP,CACDR,KAAA,CAAAkB,aAAA,CAACrB,MAAM,EACLgB,SAAS,CAAEV,uBAAuB,CAAC,QAAQ,CAAE,CAC7CI,KAAK,CAAC,wDAAW,CACjBwB,SAAS,CAAEnC,WAAY,CACvBiC,IAAI,CAAC,GAAG,CACRf,IAAI,CAAC,OAAO,CACZJ,OAAO,CAAEA,CAAQ,CAClB,CACE,CACF,CAET,CAAC,CAED,MAAO,MAAM,CAAAsB,qBAAqB,CAAG/B,UAAU,CAC7CG,2BACF,CAAmC"}
@@ -17,9 +17,8 @@ export type MegaMenuBannerBarPropGetItemImage<ITEM> = (item: ITEM) => string | u
17
17
  export type MegaMenuBannerBarPropGetItemOnClick<ITEM> = (item: ITEM) => React.MouseEventHandler | undefined;
18
18
  export type MegaMenuBannerBarPropGetItemAs<ITEM> = (item: ITEM) => AsTags | undefined;
19
19
  export type MegaMenuBannerBarPropGetItemAttributes<ITEM> = (item: ITEM) => AsAttributes | undefined;
20
- export type MegaMenuBannerBarPropOnItemClick<ITEM> = (params: {
20
+ export type MegaMenuBannerBarPropOnItemClick<ITEM> = (item: ITEM, props: {
21
21
  e: React.MouseEvent;
22
- item: ITEM;
23
22
  }) => void;
24
23
  export type MegaMenuBannerBarProps<ITEM = MegaMenuBannerBarDefaultItem> = PropsWithHTMLAttributesAndRef<{
25
24
  items: ITEM[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/MegaMenu/MegaMenuBannerBar/types.ts"],"sourcesContent":["import {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport { PropsWithAsAttributes } from '@consta/uikit/__internal__/src/utils/types/PropsWithAsAttributes';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MegaMenuBannerBarDefaultItem = {\n onClick?: React.MouseEventHandler;\n label: string;\n description?: string;\n image?: string;\n as?: AsTags;\n attributes?: AsAttributes;\n};\n\nexport type MegaMenuBannerBarPropView = 'vertical' | 'horizontal';\n\nexport type MegaMenuBannerBarPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuBannerBarPropGetItemDescription<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type MegaMenuBannerBarPropGetItemImage<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type MegaMenuBannerBarPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuBannerBarPropGetItemAs<ITEM> = (\n item: ITEM,\n) => AsTags | undefined;\nexport type MegaMenuBannerBarPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\n\nexport type MegaMenuBannerBarPropOnItemClick<ITEM> = (params: {\n e: React.MouseEvent;\n item: ITEM;\n}) => void;\n\nexport type MegaMenuBannerBarProps<ITEM = MegaMenuBannerBarDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n getItemLabel?: MegaMenuBannerBarPropGetItemLabel<ITEM>;\n getItemDescription?: MegaMenuBannerBarPropGetItemDescription<ITEM>;\n getItemImage?: MegaMenuBannerBarPropGetItemImage<ITEM>;\n getItemOnClick?: MegaMenuBannerBarPropGetItemOnClick<ITEM>;\n getItemAs?: MegaMenuBannerBarPropGetItemAs<ITEM>;\n getItemAttributes?: MegaMenuBannerBarPropGetItemAttributes<ITEM>;\n onItemClick?: MegaMenuBannerBarPropOnItemClick<ITEM>;\n view?: MegaMenuBannerBarPropView;\n },\n HTMLDivElement\n >;\n\nexport type MegaMenuBannerBarComponent = <ITEM = MegaMenuBannerBarDefaultItem>(\n props: MegaMenuBannerBarProps<ITEM>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuBannerBarItemProps<AS extends AsTags = 'div'> =\n PropsWithAsAttributes<\n {\n label: string;\n description?: string;\n image?: string;\n onClick?: React.MouseEventHandler;\n view?: MegaMenuBannerBarPropView;\n },\n AS\n >;\n\nexport type MegaMenuBannerBarItemComponent = <AS extends AsTags = 'div'>(\n props: MegaMenuBannerBarItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/MegaMenu/MegaMenuBannerBar/types.ts"],"sourcesContent":["import {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport { PropsWithAsAttributes } from '@consta/uikit/__internal__/src/utils/types/PropsWithAsAttributes';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MegaMenuBannerBarDefaultItem = {\n onClick?: React.MouseEventHandler;\n label: string;\n description?: string;\n image?: string;\n as?: AsTags;\n attributes?: AsAttributes;\n};\n\nexport type MegaMenuBannerBarPropView = 'vertical' | 'horizontal';\n\nexport type MegaMenuBannerBarPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuBannerBarPropGetItemDescription<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type MegaMenuBannerBarPropGetItemImage<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type MegaMenuBannerBarPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuBannerBarPropGetItemAs<ITEM> = (\n item: ITEM,\n) => AsTags | undefined;\nexport type MegaMenuBannerBarPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\n\nexport type MegaMenuBannerBarPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type MegaMenuBannerBarProps<ITEM = MegaMenuBannerBarDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n getItemLabel?: MegaMenuBannerBarPropGetItemLabel<ITEM>;\n getItemDescription?: MegaMenuBannerBarPropGetItemDescription<ITEM>;\n getItemImage?: MegaMenuBannerBarPropGetItemImage<ITEM>;\n getItemOnClick?: MegaMenuBannerBarPropGetItemOnClick<ITEM>;\n getItemAs?: MegaMenuBannerBarPropGetItemAs<ITEM>;\n getItemAttributes?: MegaMenuBannerBarPropGetItemAttributes<ITEM>;\n onItemClick?: MegaMenuBannerBarPropOnItemClick<ITEM>;\n view?: MegaMenuBannerBarPropView;\n },\n HTMLDivElement\n >;\n\nexport type MegaMenuBannerBarComponent = <ITEM = MegaMenuBannerBarDefaultItem>(\n props: MegaMenuBannerBarProps<ITEM>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuBannerBarItemProps<AS extends AsTags = 'div'> =\n PropsWithAsAttributes<\n {\n label: string;\n description?: string;\n image?: string;\n onClick?: React.MouseEventHandler;\n view?: MegaMenuBannerBarPropView;\n },\n AS\n >;\n\nexport type MegaMenuBannerBarItemComponent = <AS extends AsTags = 'div'>(\n props: MegaMenuBannerBarItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
- import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","getItemAs","getItemAttributes","getItemGroupId","title","getItemLabel","columns","getItemOnClick","getGroupKey","onItemClick","onGroupClick","getGroupLabel","getGroupOnClick","groups","showButtonText","hideButtonText","maxElements","className"];import"./MegaMenuGlobal.css";import{getGroups}from"@consta/uikit/__internal__/src/utils/getGroups";import{cnMixSpace}from"@consta/uikit/MixSpace";import{Text}from"@consta/uikit/Text";import{getLastPoint,useComponentBreakpoints}from"@consta/uikit/useComponentBreakpoints";import{useForkRef}from"@consta/uikit/useForkRef";import React,{forwardRef,useMemo,useRef}from"react";import{cn}from"../../../utils/bem";import{withDefaultGetters}from"./helper";import{MegaMenuGlobalGroup}from"./MegaMenuGlobalGroup";const cnMegaMenuGlobal=cn("MegaMenuGlobal"),noGroupKey="no-group",MegaMenuGlobalRender=(a,b)=>{const c=withDefaultGetters(a),{items:d,getItemAs:e,getItemAttributes:f,getItemGroupId:g,title:h,getItemLabel:j,columns:k,getItemOnClick:l,getGroupKey:m,onItemClick:n,onGroupClick:o,getGroupLabel:p,getGroupOnClick:q,groups:t=[],showButtonText:u="\u0415\u0449\u0451",hideButtonText:v="\u0421\u043A\u0440\u044B\u0442\u044C",maxElements:r,className:s}=c,w=_objectWithoutProperties(c,_excluded),x=useRef(null),y=getLastPoint(useComponentBreakpoints(x,{1:0,2:600,3:1e3,4:1600})),z=useMemo(()=>{const a=null!==k&&void 0!==k?k:+y,b=getGroups(d,g,t,m,void 0,noGroupKey),c=[];return b.forEach((b,d)=>{const e=d%a;c[e]||(c[e]=[]),c[e].push(b)}),c},[d,t,y,k]);return React.createElement("div",Object.assign({ref:useForkRef([b,x]),className:cnMegaMenuGlobal(null,[s])},w),h&&React.createElement(Text,{weight:"semibold",transform:"uppercase",className:cnMixSpace({mB:"xl"}),lineHeight:"m",size:"xl"},h),React.createElement("div",{style:{"--global-menu-columns":y},className:cnMegaMenuGlobal("Content")},z.map((a,b)=>React.createElement("div",{key:cnMegaMenuGlobal("Column",{index:b}),className:cnMegaMenuGlobal("Column")},a.map((a,c)=>{const d=a.group?q(a.group):void 0,h=a.group&&(!!d||!!o);return React.createElement(MegaMenuGlobalGroup,{title:a.group?p(a.group):void 0,key:cnMegaMenuGlobal("Group",{index:b,i:c}),onClick:h?b=>{null===d||void 0===d?void 0:d(b),a.group&&(null===o||void 0===o?void 0:o({e:b,group:a.group}))}:void 0,className:cnMegaMenuGlobal("Group"),items:a.items,showButtonText:u,hideButtonText:v,onItemClick:n,maxElements:r,getItemAs:e,getItemAttributes:f,getItemGroupId:g,getItemLabel:j,getItemOnClick:l})})))))};export const MegaMenuGlobal=forwardRef(MegaMenuGlobalRender);
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","getItemAs","getItemAttributes","getItemGroupId","title","getItemLabel","columns","getItemOnClick","getGroupKey","onItemClick","onGroupClick","getGroupLabel","getGroupOnClick","groups","showButtonText","hideButtonText","maxElements","className"];import"./MegaMenuGlobal.css";import{getGroups}from"@consta/uikit/__internal__/src/utils/getGroups";import{cnMixSpace}from"@consta/uikit/MixSpace";import{Text}from"@consta/uikit/Text";import{getLastPoint,useBreakpoints}from"@consta/uikit/useBreakpoints";import{useForkRef}from"@consta/uikit/useForkRef";import React,{forwardRef,useMemo,useRef}from"react";import{cn}from"../../../utils/bem";import{withDefaultGetters}from"./helper";import{MegaMenuGlobalGroup}from"./MegaMenuGlobalGroup";const cnMegaMenuGlobal=cn("MegaMenuGlobal"),noGroupKey="no-group",MegaMenuGlobalRender=(a,b)=>{const c=withDefaultGetters(a),{items:d,getItemAs:e,getItemAttributes:f,getItemGroupId:g,title:h,getItemLabel:j,columns:k,getItemOnClick:l,getGroupKey:m,onItemClick:n,onGroupClick:o,getGroupLabel:p,getGroupOnClick:q,groups:t=[],showButtonText:u="\u0415\u0449\u0451",hideButtonText:v="\u0421\u043A\u0440\u044B\u0442\u044C",maxElements:r,className:s}=c,w=_objectWithoutProperties(c,_excluded),x=useRef(null),y=getLastPoint(useBreakpoints({ref:x,map:{1:0,2:600,3:1e3,4:1600},isActive:!0})),z=useMemo(()=>{const a=null!==k&&void 0!==k?k:+y,b=getGroups(d,g,t,m,void 0,noGroupKey),c=[];return b.forEach((b,d)=>{const e=d%a;c[e]||(c[e]=[]),c[e].push(b)}),c},[d,t,y,k]);return React.createElement("div",Object.assign({ref:useForkRef([b,x]),className:cnMegaMenuGlobal(null,[s])},w),h&&React.createElement(Text,{weight:"semibold",transform:"uppercase",className:cnMixSpace({mB:"xl"}),lineHeight:"m",size:"xl",view:"primary"},h),React.createElement("div",{style:{"--global-menu-columns":y},className:cnMegaMenuGlobal("Content")},z.map((a,b)=>React.createElement("div",{key:cnMegaMenuGlobal("Column",{index:b}),className:cnMegaMenuGlobal("Column")},a.map((a,c)=>{const d=a.group?q(a.group):void 0,h=a.group&&(!!d||!!o);return React.createElement(MegaMenuGlobalGroup,{title:a.group?p(a.group):void 0,key:cnMegaMenuGlobal("Group",{index:b,i:c}),onClick:h?b=>{null===d||void 0===d?void 0:d(b),a.group&&(null===o||void 0===o?void 0:o(a.group,{e:b}))}:void 0,className:cnMegaMenuGlobal("Group"),items:a.items,showButtonText:u,hideButtonText:v,onItemClick:n,maxElements:r,getItemAs:e,getItemAttributes:f,getItemGroupId:g,getItemLabel:j,getItemOnClick:l})})))))};export const MegaMenuGlobal=forwardRef(MegaMenuGlobalRender);
2
2
  //# sourceMappingURL=MegaMenuGlobal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MegaMenuGlobal.js","names":["getGroups","cnMixSpace","Text","getLastPoint","useComponentBreakpoints","useForkRef","React","forwardRef","useMemo","useRef","cn","withDefaultGetters","MegaMenuGlobalGroup","cnMegaMenuGlobal","noGroupKey","MegaMenuGlobalRender","props","ref","c","items","getItemAs","getItemAttributes","getItemGroupId","title","getItemLabel","columns","columnsProp","getItemOnClick","getGroupKey","onItemClick","onGroupClick","getGroupLabel","getGroupOnClick","groups","groupsProp","showButtonText","hideButtonText","maxElements","className","otherProps","_objectWithoutProperties","_excluded","MegaMenuGlobalRef","sortedGroups","cols","arr","forEach","group","i","index","push","createElement","Object","assign","weight","transform","mB","lineHeight","size","style","\"--global-menu-columns\"","map","key","onClickGroup","hasClickableGroup","onClick","e","MegaMenuGlobal"],"sources":["../../../../../../src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobal.tsx"],"sourcesContent":["import './MegaMenuGlobal.css';\n\nimport { getGroups } from '@consta/uikit/__internal__/src/utils/getGroups';\nimport { cnMixSpace } from '@consta/uikit/MixSpace';\nimport { Text } from '@consta/uikit/Text';\nimport {\n getLastPoint,\n useComponentBreakpoints,\n} from '@consta/uikit/useComponentBreakpoints';\nimport { useForkRef } from '@consta/uikit/useForkRef';\nimport React, { forwardRef, useMemo, useRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport { withDefaultGetters } from './helper';\nimport { MegaMenuGlobalGroup } from './MegaMenuGlobalGroup';\nimport { MegaMenuGlobalComponent, MegaMenuGlobalProps } from './types';\n\nconst cnMegaMenuGlobal = cn('MegaMenuGlobal');\nconst noGroupKey = 'no-group';\n\nconst MegaMenuGlobalRender = (\n props: MegaMenuGlobalProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n items,\n getItemAs,\n getItemAttributes,\n getItemGroupId,\n title,\n getItemLabel,\n columns: columnsProp,\n getItemOnClick,\n getGroupKey,\n onItemClick,\n onGroupClick,\n getGroupLabel,\n getGroupOnClick,\n groups: groupsProp = [],\n showButtonText = 'Ещё',\n hideButtonText = 'Скрыть',\n maxElements,\n className,\n ...otherProps\n } = withDefaultGetters(props);\n\n const MegaMenuGlobalRef = useRef<HTMLDivElement>(null);\n\n const columns = getLastPoint(\n useComponentBreakpoints(MegaMenuGlobalRef, {\n 1: 0,\n 2: 600,\n 3: 1000,\n 4: 1600,\n }),\n );\n\n const sortedGroups = useMemo(() => {\n const cols = columnsProp ?? Number(columns);\n\n const groups = getGroups(\n items,\n getItemGroupId,\n groupsProp,\n getGroupKey,\n undefined,\n noGroupKey,\n );\n const arr: Array<typeof groups> = [];\n groups.forEach((group, i) => {\n const index = i % cols;\n if (!arr[index]) {\n arr[index] = [];\n }\n arr[index].push(group);\n });\n return arr;\n }, [items, groupsProp, columns, columnsProp]);\n\n return (\n <div\n ref={useForkRef([ref, MegaMenuGlobalRef])}\n className={cnMegaMenuGlobal(null, [className])}\n {...otherProps}\n >\n {title && (\n <Text\n weight=\"semibold\"\n transform=\"uppercase\"\n className={cnMixSpace({ mB: 'xl' })}\n lineHeight=\"m\"\n size=\"xl\"\n >\n {title}\n </Text>\n )}\n <div\n style={{\n ['--global-menu-columns' as string]: columns,\n }}\n className={cnMegaMenuGlobal('Content')}\n >\n {sortedGroups.map((groups, index) => (\n <div\n key={cnMegaMenuGlobal('Column', { index })}\n className={cnMegaMenuGlobal('Column')}\n >\n {groups.map((group, i) => {\n const onClickGroup = group.group\n ? getGroupOnClick(group.group)\n : undefined;\n const hasClickableGroup =\n group.group && (!!onClickGroup || !!onGroupClick);\n const onClick = (e: React.MouseEvent) => {\n onClickGroup?.(e);\n group.group && onGroupClick?.({ e, group: group.group });\n };\n\n return (\n <MegaMenuGlobalGroup\n title={group.group ? getGroupLabel(group.group) : undefined}\n key={cnMegaMenuGlobal('Group', { index, i })}\n onClick={hasClickableGroup ? onClick : undefined}\n className={cnMegaMenuGlobal('Group')}\n items={group.items}\n showButtonText={showButtonText}\n hideButtonText={hideButtonText}\n onItemClick={onItemClick}\n maxElements={maxElements}\n getItemAs={getItemAs}\n getItemAttributes={getItemAttributes}\n getItemGroupId={getItemGroupId}\n getItemLabel={getItemLabel}\n getItemOnClick={getItemOnClick}\n />\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nexport const MegaMenuGlobal = forwardRef(\n MegaMenuGlobalRender,\n) as MegaMenuGlobalComponent;\n"],"mappings":"oWAAA,6BAEA,OAASA,SAAS,KAAQ,gDAAgD,CAC1E,OAASC,UAAU,KAAQ,wBAAwB,CACnD,OAASC,IAAI,KAAQ,oBAAoB,CACzC,OACEC,YAAY,CACZC,uBAAuB,KAClB,uCAAuC,CAC9C,OAASC,UAAU,KAAQ,0BAA0B,CACrD,MAAO,CAAAC,KAAK,EAAIC,UAAU,CAAEC,OAAO,CAAEC,MAAM,KAAQ,OAAO,CAE1D,OAASC,EAAE,0BAEX,OAASC,kBAAkB,gBAC3B,OAASC,mBAAmB,6BAAgC,KAGtD,CAAAC,gBAAgB,CAAGH,EAAE,CAAC,gBAAgB,CAAC,CACvCI,UAAU,CAAG,UAAU,CAEvBC,oBAAoB,CAAGA,CAC3BC,CAA0B,CAC1BC,CAA8B,GAC3B,OAAAC,CAAA,CAqBCP,kBAAkB,CAACK,CAAK,CAAC,CApBvB,CACJG,KAAK,CAALA,CAAK,CACLC,SAAS,CAATA,CAAS,CACTC,iBAAiB,CAAjBA,CAAiB,CACjBC,cAAc,CAAdA,CAAc,CACdC,KAAK,CAALA,CAAK,CACLC,YAAY,CAAZA,CAAY,CACZC,OAAO,CAAEC,CAAW,CACpBC,cAAc,CAAdA,CAAc,CACdC,WAAW,CAAXA,CAAW,CACXC,WAAW,CAAXA,CAAW,CACXC,YAAY,CAAZA,CAAY,CACZC,aAAa,CAAbA,CAAa,CACbC,eAAe,CAAfA,CAAe,CACfC,MAAM,CAAEC,CAAU,CAAG,EAAE,CACvBC,cAAc,CAAdA,CAAc,CAAG,oBAAK,CACtBC,cAAc,CAAdA,CAAc,CAAG,sCAAQ,CACzBC,WAAW,CAAXA,CAAW,CACXC,SAAS,CAATA,CAEF,CAAC,CAAApB,C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,KAAK,CAAEA,CAAK,CAACA,KAAM,CAAC,CAAC,CAC1D,CAAC,OAMoD,CACjDT,SAAS,CAAEzB,gBAAgB,CAAC,OAAO,CAAE,CACrCM,KAAK,CAAE4B,CAAK,CAAC5B,KAAM,CACnBgB,cAAc,CAAEA,CAAe,CAC/BC,cAAc,CAAEA,CAAe,CAC/BP,WAAW,CAAEA,CAAY,CACzBQ,WAAW,CAAEA,CAAY,CACzBjB,SAAS,CAAEA,CAAU,CACrBC,iBAAiB,CAAEA,CAAkB,CACrCC,cAAc,CAAEA,CAAe,CAC/BE,YAAY,CAAEA,CAAa,CAC3BG,cAAc,CAAEA,CAAe,CAChC,CAEL,CAAC,CACE,CACN,CACE,CACF,CAET,CAAC,CAED,MAAO,MAAM,CAAAwC,cAAc,CAAG5D,UAAU,CACtCQ,oBACF,CAA4B"}
1
+ {"version":3,"file":"MegaMenuGlobal.js","names":["getGroups","cnMixSpace","Text","getLastPoint","useBreakpoints","useForkRef","React","forwardRef","useMemo","useRef","cn","withDefaultGetters","MegaMenuGlobalGroup","cnMegaMenuGlobal","noGroupKey","MegaMenuGlobalRender","props","ref","c","items","getItemAs","getItemAttributes","getItemGroupId","title","getItemLabel","columns","columnsProp","getItemOnClick","getGroupKey","onItemClick","onGroupClick","getGroupLabel","getGroupOnClick","groups","groupsProp","showButtonText","hideButtonText","maxElements","className","otherProps","_objectWithoutProperties","_excluded","MegaMenuGlobalRef","map","isActive","sortedGroups","cols","arr","forEach","group","i","index","push","createElement","Object","assign","weight","transform","mB","lineHeight","size","view","style","\"--global-menu-columns\"","key","onClickGroup","hasClickableGroup","onClick","e","MegaMenuGlobal"],"sources":["../../../../../../src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobal.tsx"],"sourcesContent":["import './MegaMenuGlobal.css';\n\nimport { getGroups } from '@consta/uikit/__internal__/src/utils/getGroups';\nimport { cnMixSpace } from '@consta/uikit/MixSpace';\nimport { Text } from '@consta/uikit/Text';\nimport { getLastPoint, useBreakpoints } from '@consta/uikit/useBreakpoints';\nimport { useForkRef } from '@consta/uikit/useForkRef';\nimport React, { forwardRef, useMemo, useRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport { withDefaultGetters } from './helper';\nimport { MegaMenuGlobalGroup } from './MegaMenuGlobalGroup';\nimport { MegaMenuGlobalComponent, MegaMenuGlobalProps } from './types';\n\nconst cnMegaMenuGlobal = cn('MegaMenuGlobal');\nconst noGroupKey = 'no-group';\n\nconst MegaMenuGlobalRender = (\n props: MegaMenuGlobalProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n items,\n getItemAs,\n getItemAttributes,\n getItemGroupId,\n title,\n getItemLabel,\n columns: columnsProp,\n getItemOnClick,\n getGroupKey,\n onItemClick,\n onGroupClick,\n getGroupLabel,\n getGroupOnClick,\n groups: groupsProp = [],\n showButtonText = 'Ещё',\n hideButtonText = 'Скрыть',\n maxElements,\n className,\n ...otherProps\n } = withDefaultGetters(props);\n\n const MegaMenuGlobalRef = useRef<HTMLDivElement>(null);\n\n const columns = getLastPoint(\n useBreakpoints({\n ref: MegaMenuGlobalRef,\n map: {\n 1: 0,\n 2: 600,\n 3: 1000,\n 4: 1600,\n },\n isActive: true,\n }),\n );\n\n const sortedGroups = useMemo(() => {\n const cols = columnsProp ?? Number(columns);\n\n const groups = getGroups(\n items,\n getItemGroupId,\n groupsProp,\n getGroupKey,\n undefined,\n noGroupKey,\n );\n const arr: Array<typeof groups> = [];\n groups.forEach((group, i) => {\n const index = i % cols;\n if (!arr[index]) {\n arr[index] = [];\n }\n arr[index].push(group);\n });\n return arr;\n }, [items, groupsProp, columns, columnsProp]);\n\n return (\n <div\n ref={useForkRef([ref, MegaMenuGlobalRef])}\n className={cnMegaMenuGlobal(null, [className])}\n {...otherProps}\n >\n {title && (\n <Text\n weight=\"semibold\"\n transform=\"uppercase\"\n className={cnMixSpace({ mB: 'xl' })}\n lineHeight=\"m\"\n size=\"xl\"\n view=\"primary\"\n >\n {title}\n </Text>\n )}\n <div\n style={{\n ['--global-menu-columns' as string]: columns,\n }}\n className={cnMegaMenuGlobal('Content')}\n >\n {sortedGroups.map((groups, index) => (\n <div\n key={cnMegaMenuGlobal('Column', { index })}\n className={cnMegaMenuGlobal('Column')}\n >\n {groups.map((group, i) => {\n const onClickGroup = group.group\n ? getGroupOnClick(group.group)\n : undefined;\n const hasClickableGroup =\n group.group && (!!onClickGroup || !!onGroupClick);\n const onClick = (e: React.MouseEvent) => {\n onClickGroup?.(e);\n group.group && onGroupClick?.(group.group, { e });\n };\n\n return (\n <MegaMenuGlobalGroup\n title={group.group ? getGroupLabel(group.group) : undefined}\n key={cnMegaMenuGlobal('Group', { index, i })}\n onClick={hasClickableGroup ? onClick : undefined}\n className={cnMegaMenuGlobal('Group')}\n items={group.items}\n showButtonText={showButtonText}\n hideButtonText={hideButtonText}\n onItemClick={onItemClick}\n maxElements={maxElements}\n getItemAs={getItemAs}\n getItemAttributes={getItemAttributes}\n getItemGroupId={getItemGroupId}\n getItemLabel={getItemLabel}\n getItemOnClick={getItemOnClick}\n />\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nexport const MegaMenuGlobal = forwardRef(\n MegaMenuGlobalRender,\n) as MegaMenuGlobalComponent;\n"],"mappings":"oWAAA,6BAEA,OAASA,SAAS,KAAQ,gDAAgD,CAC1E,OAASC,UAAU,KAAQ,wBAAwB,CACnD,OAASC,IAAI,KAAQ,oBAAoB,CACzC,OAASC,YAAY,CAAEC,cAAc,KAAQ,8BAA8B,CAC3E,OAASC,UAAU,KAAQ,0BAA0B,CACrD,MAAO,CAAAC,KAAK,EAAIC,UAAU,CAAEC,OAAO,CAAEC,MAAM,KAAQ,OAAO,CAE1D,OAASC,EAAE,0BAEX,OAASC,kBAAkB,gBAC3B,OAASC,mBAAmB,6BAAgC,KAGtD,CAAAC,gBAAgB,CAAGH,EAAE,CAAC,gBAAgB,CAAC,CACvCI,UAAU,CAAG,UAAU,CAEvBC,oBAAoB,CAAGA,CAC3B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ers/objectWithoutProperties";const _excluded=["items","title","getItemAs","getItemAttributes","getItemLabel","getItemOnClick","getItemGroupId","className","onClick","maxElements","showButtonText","hideButtonText","onItemClick"];import"./MegaMenuGlobalGroup.css";import{IconArrowDown}from"@consta/icons/IconArrowDown";import{Button}from"@consta/uikit/Button";import{List,ListBox}from"@consta/uikit/ListCanary";import{Text}from"@consta/uikit/Text";import{useFlag}from"@consta/uikit/useFlag";import React,{forwardRef,useMemo}from"react";import{getItemClick}from"../../../../helpers/getItemClick";import{cn}from"../../../../utils/bem";const cnMegaMenuGlobalGroup=cn("MegaMenuGlobalGroup"),MegaMenuGlobalGroupRender=(a,b)=>{const{items:c,title:d,getItemAs:e,getItemAttributes:f,getItemLabel:g,getItemOnClick:h,getItemGroupId:i,className:j,onClick:k,maxElements:l,showButtonText:m,hideButtonText:n,onItemClick:o}=a,p=_objectWithoutProperties(a,_excluded),[q,r]=useFlag(),s=0<(null!==l&&void 0!==l?l:0)?l:void 0,t=useMemo(()=>s?q?c:c.slice(0,s):c,[q,s,c]);return React.createElement("div",Object.assign({ref:b,className:cnMegaMenuGlobalGroup(null,[j])},p),d&&React.createElement(Text,{onClick:k,className:cnMegaMenuGlobalGroup("Title",{clickable:!!k}),size:"m",lineHeight:"m",weight:"bold"},d),React.createElement(ListBox,{className:cnMegaMenuGlobalGroup("Content")},React.createElement(List,{items:t,size:"m",itemSpase:{p:0},getItemLabel:g,getItemAs:e,getItemAttributes:f,getItemOnClick:a=>getItemClick(a,h,o),getItemAdditionalClassName:()=>cnMegaMenuGlobalGroup("Item")})),s&&s<c.length&&React.createElement(Button,{label:q?n:m,size:"s",view:"clear",onClick:r.toggle,iconRight:IconArrowDown,className:cnMegaMenuGlobalGroup("Button",{open:q})}))};export const MegaMenuGlobalGroup=forwardRef(MegaMenuGlobalGroupRender);
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","title","getItemAs","getItemAttributes","getItemLabel","getItemOnClick","getItemGroupId","className","onClick","maxElements","showButtonText","hideButtonText","onItemClick"];import"./MegaMenuGlobalGroup.css";import{IconArrowDown}from"@consta/icons/IconArrowDown";import{Button}from"@consta/uikit/Button";import{List,ListBox}from"@consta/uikit/ListCanary";import{Text}from"@consta/uikit/Text";import{useFlag}from"@consta/uikit/useFlag";import React,{forwardRef,useMemo}from"react";import{getItemClick}from"../../../../helpers/getItemClick";import{cn}from"../../../../utils/bem";const cnMegaMenuGlobalGroup=cn("MegaMenuGlobalGroup"),MegaMenuGlobalGroupRender=(a,b)=>{const{items:c,title:d,getItemAs:e,getItemAttributes:f,getItemLabel:g,getItemOnClick:h,getItemGroupId:i,className:j,onClick:k,maxElements:l,showButtonText:m,hideButtonText:n,onItemClick:o}=a,p=_objectWithoutProperties(a,_excluded),[q,r]=useFlag(),s=0<(null!==l&&void 0!==l?l:0)?l:void 0,t=useMemo(()=>s?q?c:c.slice(0,s):c,[q,s,c]);return React.createElement("div",Object.assign({ref:b,className:cnMegaMenuGlobalGroup(null,[j])},p),d&&React.createElement(Text,{onClick:k,className:cnMegaMenuGlobalGroup("Title",{clickable:!!k}),size:"m",lineHeight:"m",weight:"bold",view:"primary"},d),React.createElement(ListBox,{className:cnMegaMenuGlobalGroup("Content")},React.createElement(List,{items:t,size:"m",itemSpase:{p:0},getItemLabel:g,getItemAs:e,getItemAttributes:f,getItemOnClick:a=>getItemClick(a,h,o),getItemAdditionalClassName:()=>cnMegaMenuGlobalGroup("Item")})),s&&s<c.length&&React.createElement(Button,{label:q?n:m,size:"s",view:"clear",onClick:r.toggle,iconRight:IconArrowDown,className:cnMegaMenuGlobalGroup("Button",{open:q})}))};export const MegaMenuGlobalGroup=forwardRef(MegaMenuGlobalGroupRender);
2
2
  //# sourceMappingURL=MegaMenuGlobalGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MegaMenuGlobalGroup.js","names":["IconArrowDown","Button","List","ListBox","Text","useFlag","React","forwardRef","useMemo","getItemClick","cn","cnMegaMenuGlobalGroup","MegaMenuGlobalGroupRender","props","ref","items","itemsProp","title","getItemAs","getItemAttributes","getItemLabel","getItemOnClick","getItemGroupId","className","onClick","maxElements","maxElementsProp","showButtonText","hideButtonText","onItemClick","otherProps","_objectWithoutProperties","_excluded","showList","setShowList","slice","createElement","Object","assign","clickable","size","lineHeight","weight","itemSpase","p","item","getItemAdditionalClassName","length","label","view","toggle","iconRight","open","MegaMenuGlobalGroup"],"sources":["../../../../../../../src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobalGroup/MegaMenuGlobalGroup.tsx"],"sourcesContent":["import './MegaMenuGlobalGroup.css';\n\nimport { IconArrowDown } from '@consta/icons/IconArrowDown';\nimport { Button } from '@consta/uikit/Button';\nimport { List, ListBox } from '@consta/uikit/ListCanary';\nimport { Text } from '@consta/uikit/Text';\nimport { useFlag } from '@consta/uikit/useFlag';\nimport React, { forwardRef, useMemo } from 'react';\n\nimport { getItemClick } from '##/helpers/getItemClick';\nimport { cn } from '##/utils/bem';\n\nimport {\n MegaMenuGlobalGroupComponent,\n MegaMenuGlobalGroupProps,\n} from '../types';\n\nconst cnMegaMenuGlobalGroup = cn('MegaMenuGlobalGroup');\n\nconst MegaMenuGlobalGroupRender = (\n props: MegaMenuGlobalGroupProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n items: itemsProp,\n title,\n getItemAs,\n getItemAttributes,\n getItemLabel,\n getItemOnClick,\n getItemGroupId,\n className,\n onClick,\n maxElements: maxElementsProp,\n showButtonText,\n hideButtonText,\n onItemClick,\n ...otherProps\n } = props;\n const [showList, setShowList] = useFlag();\n\n const maxElements = (maxElementsProp ?? 0) > 0 ? maxElementsProp : undefined;\n\n const items = useMemo(() => {\n if (!maxElements) {\n return itemsProp;\n }\n return showList ? itemsProp : itemsProp.slice(0, maxElements);\n }, [showList, maxElements, itemsProp]);\n\n return (\n <div\n ref={ref}\n className={cnMegaMenuGlobalGroup(null, [className])}\n {...otherProps}\n >\n {title && (\n <Text\n onClick={onClick}\n className={cnMegaMenuGlobalGroup('Title', { clickable: !!onClick })}\n size=\"m\"\n lineHeight=\"m\"\n weight=\"bold\"\n >\n {title}\n </Text>\n )}\n <ListBox className={cnMegaMenuGlobalGroup('Content')}>\n <List\n items={items}\n size=\"m\"\n itemSpase={{ p: 0 }}\n getItemLabel={getItemLabel}\n getItemAs={getItemAs}\n getItemAttributes={getItemAttributes}\n getItemOnClick={(item) =>\n getItemClick(item, getItemOnClick, onItemClick)\n }\n getItemAdditionalClassName={() => cnMegaMenuGlobalGroup('Item')}\n />\n </ListBox>\n {maxElements && maxElements < itemsProp.length && (\n <Button\n label={showList ? hideButtonText : showButtonText}\n size=\"s\"\n view=\"clear\"\n onClick={setShowList.toggle}\n iconRight={IconArrowDown}\n className={cnMegaMenuGlobalGroup('Button', { open: showList })}\n />\n )}\n </div>\n );\n};\n\nexport const MegaMenuGlobalGroup = forwardRef(\n MegaMenuGlobalGroupRender,\n) as MegaMenuGlobalGroupComponent;\n"],"mappings":"4RAAA,kCAEA,OAASA,aAAa,KAAQ,6BAA6B,CAC3D,OAASC,MAAM,KAAQ,sBAAsB,CAC7C,OAASC,IAAI,CAAEC,OAAO,KAAQ,0BAA0B,CACxD,OAASC,IAAI,KAAQ,oBAAoB,CACzC,OAASC,OAAO,KAAQ,uBAAuB,CAC/C,MAAO,CAAAC,KAAK,EAAIC,UAAU,CAAEC,OAAO,KAAQ,OAAO,CAElD,OAASC,YAAY,wCACrB,OAASC,EAAE,6BAAuB,KAO5B,CAAAC,qBAAqB,CAAGD,EAAE,CAAC,qBAAqB,CAAC,CAEjDE,yBAAyB,CAAGA,CAChCC,CAA+B,CAC/BC,CAA8B,GAC3B,MACG,CACJC,KAAK,CAAEC,CAAS,CAChBC,KAAK,CAALA,CAAK,CACLC,SAAS,CAATA,CAAS,CACTC,iBAAiB,CAAjBA,CAAiB,CACjBC,YAAY,CAAZA,CAAY,CACZC,cAAc,CAAdA,CAAc,CACdC,cAAc,CAAdA,CAAc,CACdC,SAAS,CAATA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E,CAAEC,CAAC,CAAE,CAAE,CAAE,CACpBxB,YAAY,CAAEA,CAAa,CAC3BF,SAAS,CAAEA,CAAU,CACrBC,iBAAiB,CAAEA,CAAkB,CACrCE,cAAc,CAAGwB,CAAI,EACnBpC,YAAY,CAACoC,CAAI,CAAExB,CAAc,CAAEQ,CAAW,CAC/C,CACDiB,0BAA0B,CAAEA,CAAA,GAAMnC,qBAAqB,CAAC,MAAM,CAAE,CACjE,CACM,CAAC,CACTc,CAAW,EAAIA,CAAW,CAAGT,CAAS,CAAC+B,MAAM,EAC5CzC,KAAA,CAAA8B,aAAA,CAACnC,MAAM,EACL+C,KAAK,CAAEf,CAAQ,CAAGL,CAAc,CAAGD,CAAe,CAClDa,IAAI,CAAC,GAAG,CACRS,IAAI,CAAC,OAAO,CACZzB,OAAO,CAAEU,CAAW,CAACgB,MAAO,CAC5BC,SAAS,CAAEnD,aAAc,CACzBuB,SAAS,CAAEZ,qBAAqB,CAAC,QAAQ,CAAE,CAAEyC,IAAI,CAAEnB,CAAS,CAAC,CAAE,CAChE,CAEA,CAET,CAAC,CAED,MAAO,MAAM,CAAAoB,mBAAmB,CAAG9C,UAAU,CAC3CK,yBACF,CAAiC"}
1
+ {"version":3,"file":"MegaMenuGlobalGroup.js","names":["IconArrowDown","Button","List","ListBox","Text","useFlag","React","forwardRef","useMemo","getItemClick","cn","cnMegaMenuGlobalGroup","MegaMenuGlobalGroupRender","props","ref","items","itemsProp","title","getItemAs","getItemAttributes","getItemLabel","getItemOnClick","getItemGroupId","className","onClick","maxElements","maxElementsProp","showButtonText","hideButtonText","onItemClick","otherProps","_objectWithoutProperties","_excluded","showList","setShowList","slice","createElement","Object","assign","clickable","size","lineHeight","weight","view","itemSpase","p","item","getItemAdditionalClassName","length","label","toggle","iconRight","open","MegaMenuGlobalGroup"],"sources":["../../../../../../../src/components/MegaMenu/MegaMenuGlobal/MegaMenuGlobalGroup/MegaMenuGlobalGroup.tsx"],"sourcesContent":["import './MegaMenuGlobalGroup.css';\n\nimport { IconArrowDown } from '@consta/icons/IconArrowDown';\nimport { Button } from '@consta/uikit/Button';\nimport { List, ListBox } from '@consta/uikit/ListCanary';\nimport { Text } from '@consta/uikit/Text';\nimport { useFlag } from '@consta/uikit/useFlag';\nimport React, { forwardRef, useMemo } from 'react';\n\nimport { getItemClick } from '##/helpers/getItemClick';\nimport { cn } from '##/utils/bem';\n\nimport {\n MegaMenuGlobalGroupComponent,\n MegaMenuGlobalGroupProps,\n} from '../types';\n\nconst cnMegaMenuGlobalGroup = cn('MegaMenuGlobalGroup');\n\nconst MegaMenuGlobalGroupRender = (\n props: MegaMenuGlobalGroupProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n items: itemsProp,\n title,\n getItemAs,\n getItemAttributes,\n getItemLabel,\n getItemOnClick,\n getItemGroupId,\n className,\n onClick,\n maxElements: maxElementsProp,\n showButtonText,\n hideButtonText,\n onItemClick,\n ...otherProps\n } = props;\n const [showList, setShowList] = useFlag();\n\n const maxElements = (maxElementsProp ?? 0) > 0 ? maxElementsProp : undefined;\n\n const items = useMemo(() => {\n if (!maxElements) {\n return itemsProp;\n }\n return showList ? itemsProp : itemsProp.slice(0, maxElements);\n }, [showList, maxElements, itemsProp]);\n\n return (\n <div\n ref={ref}\n className={cnMegaMenuGlobalGroup(null, [className])}\n {...otherProps}\n >\n {title && (\n <Text\n onClick={onClick}\n className={cnMegaMenuGlobalGroup('Title', { clickable: !!onClick })}\n size=\"m\"\n lineHeight=\"m\"\n weight=\"bold\"\n view=\"primary\"\n >\n {title}\n </Text>\n )}\n <ListBox className={cnMegaMenuGlobalGroup('Content')}>\n <List\n items={items}\n size=\"m\"\n itemSpase={{ p: 0 }}\n getItemLabel={getItemLabel}\n getItemAs={getItemAs}\n getItemAttributes={getItemAttributes}\n getItemOnClick={(item) =>\n getItemClick(item, getItemOnClick, onItemClick)\n }\n getItemAdditionalClassName={() => cnMegaMenuGlobalGroup('Item')}\n />\n </ListBox>\n {maxElements && maxElements < itemsProp.length && (\n <Button\n label={showList ? hideButtonText : showButtonText}\n size=\"s\"\n view=\"clear\"\n onClick={setShowList.toggle}\n iconRight={IconArrowDown}\n className={cnMegaMenuGlobalGroup('Button', { open: showList })}\n />\n )}\n </div>\n );\n};\n\nexport const MegaMenuGlobalGroup = forwardRef(\n MegaMenuGlobalGroupRender,\n) as MegaMenuGlobalGroupComponent;\n"],"mappings":"4RAAA,kCAEA,OAASA,aAAa,KAAQ,6BAA6B,CAC3D,OAASC,MAAM,KAAQ,sBAAsB,CAC7C,OAASC,IAAI,CAAEC,OAAO,KAAQ,0BAA0B,CACxD,OAASC,IAAI,KAAQ,oBAAoB,CACzC,OAASC,OAAO,KAAQ,uBAAuB,CAC/C,MAAO,CAAAC,KAAK,EAAIC,UAAU,CAAEC,OAAO,KAAQ,OAAO,CAElD,OAASC,YAAY,wCACrB,OAASC,EAAE,6BAAuB,KAO5B,CAAAC,qBAAqB,CAAGD,EAAE,CAAC,qBAAqB,CAAC,CAEjDE,yBAAyB,CAAGA,CAChCC,CAA+B,CAC/BC,CAA8B,GAC3B,MACG,CACJC,KAAK,CAAEC,CAAS,CAChBC,KAAK,CAALA,CAAK,CACLC,SAAS,CAATA,CAAS,CACTC,iBAAiB,CAAjBA,CAAiB,CACjBC,YAAY,CAAZA,CAAY,CACZC,cAAc,CAAdA,CAAc,CACdC,cAAc,CAAdA,CAAc,CACdC,SAAS,CAATA,CAAS,CACTC,OAAO,CAAPA,CAAO,CACPC,WAAW,CAAEC,CAAe,CAC5BC,cAAc,CAAdA,CAAc,CACdC,cAAc,CAAdA,CAAc,CACdC,WAAW,CAAXA,CAEF,CAAC,CAAGhB,CAAK,CADJiB,CAAU,CAAAC,wBAAA,CACXlB,CAAK,CAAAmB,SAAA,EACH,CAACC,CAAQ,CAAEC,CAAW,CAAC,CAAG7B,OAAO,CAAC,CAAC,CAEnCoB,CAAW,CAA4B,CAAC,SAAzBC,CAAe,WAAfA,CAAe,CAAfA,CAAe,CAAI,CAAC,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gC,MAAM,EAC5C1C,KAAA,CAAA8B,aAAA,CAACnC,MAAM,EACLgD,KAAK,CAAEhB,CAAQ,CAAGL,CAAc,CAAGD,CAAe,CAClDa,IAAI,CAAC,GAAG,CACRG,IAAI,CAAC,OAAO,CACZnB,OAAO,CAAEU,CAAW,CAACgB,MAAO,CAC5BC,SAAS,CAAEnD,aAAc,CACzBuB,SAAS,CAAEZ,qBAAqB,CAAC,QAAQ,CAAE,CAAEyC,IAAI,CAAEnB,CAAS,CAAC,CAAE,CAChE,CAEA,CAET,CAAC,CAED,MAAO,MAAM,CAAAoB,mBAAmB,CAAG9C,UAAU,CAC3CK,yBACF,CAAiC"}
@@ -22,13 +22,11 @@ export type MegaMenuGlobalPropGetItemGroupId<ITEM> = (item: ITEM) => string | nu
22
22
  export type MegaMenuGlobalPropGetGroupId<ITEM> = (item: ITEM) => number | string | undefined;
23
23
  export type MegaMenuGlobalPropGetGroupLabel<ITEM> = (item: ITEM) => string;
24
24
  export type MegaMenuGlobalPropGetGroupOnClick<ITEM> = (item: ITEM) => React.MouseEventHandler | undefined;
25
- export type MegaMenuGlobalPropOnItemClick<ITEM> = (params: {
25
+ export type MegaMenuGlobalPropOnItemClick<ITEM> = (item: ITEM, props: {
26
26
  e: React.MouseEvent;
27
- item: ITEM;
28
27
  }) => void;
29
- export type MegaMenuGlobalPropOnGroupClick<GROUP> = (params: {
28
+ export type MegaMenuGlobalPropOnGroupClick<GROUP> = (group: GROUP, params: {
30
29
  e: React.MouseEvent;
31
- group: GROUP;
32
30
  }) => void;
33
31
  export type MappersItem<ITEM = MegaMenuGlobalDefaultItem> = {
34
32
  getItemLabel?: MegaMenuGlobalPropGetItemLabel<ITEM>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/MegaMenu/MegaMenuGlobal/types.ts"],"sourcesContent":["import {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport { PropsWithAsAttributes } from '@consta/uikit/__internal__/src/utils/types/PropsWithAsAttributes';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MegaMenuGlobalDefaultItem = {\n as?: AsTags;\n attributes?: AsAttributes;\n onClick?: React.MouseEventHandler;\n label: string;\n groupId?: string | number;\n};\n\nexport type MegaMenuGlobalDefaultGroup = {\n label: string;\n id?: string | number;\n onClick?: React.MouseEventHandler;\n};\n\nexport type MegaMenuGlobalPropGetItemAs<ITEM> = (\n item: ITEM,\n) => AsTags | undefined;\nexport type MegaMenuGlobalPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\nexport type MegaMenuGlobalPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuGlobalPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuGlobalPropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\n\nexport type MegaMenuGlobalPropGetGroupId<ITEM> = (\n item: ITEM,\n) => number | string | undefined;\nexport type MegaMenuGlobalPropGetGroupLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuGlobalPropGetGroupOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\n\nexport type MegaMenuGlobalPropOnItemClick<ITEM> = (params: {\n e: React.MouseEvent;\n item: ITEM;\n}) => void;\n\nexport type MegaMenuGlobalPropOnGroupClick<GROUP> = (params: {\n e: React.MouseEvent;\n group: GROUP;\n}) => void;\n\nexport type MappersItem<ITEM = MegaMenuGlobalDefaultItem> = {\n getItemLabel?: MegaMenuGlobalPropGetItemLabel<ITEM>;\n getItemAs?: MegaMenuGlobalPropGetItemAs<ITEM>;\n getItemGroupId?: MegaMenuGlobalPropGetItemGroupId<ITEM>;\n getItemAttributes?: MegaMenuGlobalPropGetItemAttributes<ITEM>;\n getItemOnClick?: MegaMenuGlobalPropGetItemOnClick<ITEM>;\n};\n\nexport type MegaMenuGlobalProps<\n ITEM = MegaMenuGlobalDefaultItem,\n GROUP = MegaMenuGlobalDefaultGroup,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n groups?: GROUP[];\n getGroupKey?: MegaMenuGlobalPropGetGroupId<GROUP>;\n getGroupLabel?: MegaMenuGlobalPropGetGroupLabel<GROUP>;\n getGroupOnClick?: MegaMenuGlobalPropGetGroupOnClick<GROUP>;\n maxElements?: number;\n onGroupClick?: MegaMenuGlobalPropOnGroupClick<GROUP>;\n onItemClick?: MegaMenuGlobalPropOnItemClick<ITEM>;\n columns?: number;\n title?: string;\n showButtonText?: string;\n hideButtonText?: string;\n } & MappersItem<ITEM> &\n (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel: MegaMenuGlobalPropGetItemLabel<ITEM>;\n }) &\n (GROUP extends { label: string | unknown }\n ? {}\n : {\n getGroupLabel: MegaMenuGlobalPropGetGroupLabel<GROUP>;\n }),\n HTMLDivElement\n>;\n\nexport type MegaMenuGlobalComponent = <\n ITEM = MegaMenuGlobalDefaultItem,\n GROUP = MegaMenuGlobalDefaultGroup,\n>(\n props: MegaMenuGlobalProps<ITEM, GROUP>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuGlobalGroupProps<ITEM = MegaMenuGlobalDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n title?: string;\n maxElements?: number;\n onItemClick?: MegaMenuGlobalPropOnItemClick<ITEM>;\n showButtonText?: string;\n hideButtonText?: string;\n } & Required<MappersItem<ITEM>>,\n HTMLDivElement\n >;\n\nexport type MegaMenuGlobalGroupComponent = <ITEM = MegaMenuGlobalDefaultItem>(\n props: MegaMenuGlobalGroupProps<ITEM>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuGlobalItemProps<AS extends AsTags = 'div'> =\n PropsWithAsAttributes<\n {\n label: string;\n onClick?: React.MouseEventHandler;\n },\n AS\n >;\n\nexport type MegaMenuGlobalItemComponent = <AS extends AsTags = 'div'>(\n props: MegaMenuGlobalItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/MegaMenu/MegaMenuGlobal/types.ts"],"sourcesContent":["import {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport { PropsWithAsAttributes } from '@consta/uikit/__internal__/src/utils/types/PropsWithAsAttributes';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MegaMenuGlobalDefaultItem = {\n as?: AsTags;\n attributes?: AsAttributes;\n onClick?: React.MouseEventHandler;\n label: string;\n groupId?: string | number;\n};\n\nexport type MegaMenuGlobalDefaultGroup = {\n label: string;\n id?: string | number;\n onClick?: React.MouseEventHandler;\n};\n\nexport type MegaMenuGlobalPropGetItemAs<ITEM> = (\n item: ITEM,\n) => AsTags | undefined;\nexport type MegaMenuGlobalPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\nexport type MegaMenuGlobalPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuGlobalPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuGlobalPropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\n\nexport type MegaMenuGlobalPropGetGroupId<ITEM> = (\n item: ITEM,\n) => number | string | undefined;\nexport type MegaMenuGlobalPropGetGroupLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuGlobalPropGetGroupOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\n\nexport type MegaMenuGlobalPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type MegaMenuGlobalPropOnGroupClick<GROUP> = (\n group: GROUP,\n params: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type MappersItem<ITEM = MegaMenuGlobalDefaultItem> = {\n getItemLabel?: MegaMenuGlobalPropGetItemLabel<ITEM>;\n getItemAs?: MegaMenuGlobalPropGetItemAs<ITEM>;\n getItemGroupId?: MegaMenuGlobalPropGetItemGroupId<ITEM>;\n getItemAttributes?: MegaMenuGlobalPropGetItemAttributes<ITEM>;\n getItemOnClick?: MegaMenuGlobalPropGetItemOnClick<ITEM>;\n};\n\nexport type MegaMenuGlobalProps<\n ITEM = MegaMenuGlobalDefaultItem,\n GROUP = MegaMenuGlobalDefaultGroup,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n groups?: GROUP[];\n getGroupKey?: MegaMenuGlobalPropGetGroupId<GROUP>;\n getGroupLabel?: MegaMenuGlobalPropGetGroupLabel<GROUP>;\n getGroupOnClick?: MegaMenuGlobalPropGetGroupOnClick<GROUP>;\n maxElements?: number;\n onGroupClick?: MegaMenuGlobalPropOnGroupClick<GROUP>;\n onItemClick?: MegaMenuGlobalPropOnItemClick<ITEM>;\n columns?: number;\n title?: string;\n showButtonText?: string;\n hideButtonText?: string;\n } & MappersItem<ITEM> &\n (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel: MegaMenuGlobalPropGetItemLabel<ITEM>;\n }) &\n (GROUP extends { label: string | unknown }\n ? {}\n : {\n getGroupLabel: MegaMenuGlobalPropGetGroupLabel<GROUP>;\n }),\n HTMLDivElement\n>;\n\nexport type MegaMenuGlobalComponent = <\n ITEM = MegaMenuGlobalDefaultItem,\n GROUP = MegaMenuGlobalDefaultGroup,\n>(\n props: MegaMenuGlobalProps<ITEM, GROUP>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuGlobalGroupProps<ITEM = MegaMenuGlobalDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n title?: string;\n maxElements?: number;\n onItemClick?: MegaMenuGlobalPropOnItemClick<ITEM>;\n showButtonText?: string;\n hideButtonText?: string;\n } & Required<MappersItem<ITEM>>,\n HTMLDivElement\n >;\n\nexport type MegaMenuGlobalGroupComponent = <ITEM = MegaMenuGlobalDefaultItem>(\n props: MegaMenuGlobalGroupProps<ITEM>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuGlobalItemProps<AS extends AsTags = 'div'> =\n PropsWithAsAttributes<\n {\n label: string;\n onClick?: React.MouseEventHandler;\n },\n AS\n >;\n\nexport type MegaMenuGlobalItemComponent = <AS extends AsTags = 'div'>(\n props: MegaMenuGlobalItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -19,9 +19,8 @@ export type MegaMenuNavBarPropGetItemActive<ITEM> = (item: ITEM) => boolean | un
19
19
  export type MegaMenuNavBarPropGetItemOnClick<ITEM> = (item: ITEM) => React.MouseEventHandler | undefined;
20
20
  export type MegaMenuNavBarPropGetItemAs<ITEM> = (item: ITEM) => AsTags | undefined;
21
21
  export type MegaMenuNavBarPropGetItemAttributes<ITEM> = (item: ITEM) => AsAttributes | undefined;
22
- export type MegaMenuNavBarPropOnItemClick<ITEM> = (params: {
22
+ export type MegaMenuNavBarPropOnItemClick<ITEM> = (item: ITEM, props: {
23
23
  e: React.MouseEvent;
24
- item: ITEM;
25
24
  }) => void;
26
25
  export type MegaMenuNavBarProps<ITEM = MegaMenuNavBarDefaultItem> = PropsWithHTMLAttributesAndRef<{
27
26
  items: ITEM[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/MegaMenu/MegaMenuNavBar/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport { PropsWithAsAttributes } from '@consta/uikit/__internal__/src/utils/types/PropsWithAsAttributes';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MegaMenuNavBarDefaultItem = {\n label: string;\n iconLeft?: IconComponent;\n iconRight?: IconComponent;\n active?: boolean;\n as?: AsTags;\n attributes?: AsAttributes;\n onClick?: React.MouseEventHandler;\n};\n\nexport type MegaMenuNavBarPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuNavBarPropGetItemIconLeft<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type MegaMenuNavBarPropGetItemIconRight<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type MegaMenuNavBarPropGetItemActive<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type MegaMenuNavBarPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuNavBarPropGetItemAs<ITEM> = (\n item: ITEM,\n) => AsTags | undefined;\nexport type MegaMenuNavBarPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\n\nexport type MegaMenuNavBarPropOnItemClick<ITEM> = (params: {\n e: React.MouseEvent;\n item: ITEM;\n}) => void;\n\nexport type MegaMenuNavBarProps<ITEM = MegaMenuNavBarDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n getItemLabel?: MegaMenuNavBarPropGetItemLabel<ITEM>;\n getItemActive?: MegaMenuNavBarPropGetItemActive<ITEM>;\n getItemOnClick?: MegaMenuNavBarPropGetItemOnClick<ITEM>;\n getItemIconLeft?: MegaMenuNavBarPropGetItemIconLeft<ITEM>;\n getItemIconRight?: MegaMenuNavBarPropGetItemIconRight<ITEM>;\n getItemAs?: MegaMenuNavBarPropGetItemAs<ITEM>;\n getItemAttributes?: MegaMenuNavBarPropGetItemAttributes<ITEM>;\n onItemClick?: MegaMenuNavBarPropOnItemClick<ITEM>;\n } & (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel: MegaMenuNavBarPropGetItemLabel<ITEM>;\n }),\n HTMLDivElement\n >;\n\nexport type MegaMenuNavBarComponent = <ITEM = MegaMenuNavBarDefaultItem>(\n props: MegaMenuNavBarProps<ITEM>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuNavBarItemProps<AS extends AsTags = 'div'> =\n PropsWithAsAttributes<\n {\n label: string;\n active?: boolean;\n onClick?: React.MouseEventHandler;\n iconLeft?: IconComponent;\n iconRight?: IconComponent;\n },\n AS\n >;\n\nexport type MegaMenuNavBarItemComponent = <AS extends AsTags = 'div'>(\n props: MegaMenuNavBarItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/MegaMenu/MegaMenuNavBar/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport { PropsWithAsAttributes } from '@consta/uikit/__internal__/src/utils/types/PropsWithAsAttributes';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MegaMenuNavBarDefaultItem = {\n label: string;\n iconLeft?: IconComponent;\n iconRight?: IconComponent;\n active?: boolean;\n as?: AsTags;\n attributes?: AsAttributes;\n onClick?: React.MouseEventHandler;\n};\n\nexport type MegaMenuNavBarPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuNavBarPropGetItemIconLeft<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type MegaMenuNavBarPropGetItemIconRight<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type MegaMenuNavBarPropGetItemActive<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type MegaMenuNavBarPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuNavBarPropGetItemAs<ITEM> = (\n item: ITEM,\n) => AsTags | undefined;\nexport type MegaMenuNavBarPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\n\nexport type MegaMenuNavBarPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type MegaMenuNavBarProps<ITEM = MegaMenuNavBarDefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n getItemLabel?: MegaMenuNavBarPropGetItemLabel<ITEM>;\n getItemActive?: MegaMenuNavBarPropGetItemActive<ITEM>;\n getItemOnClick?: MegaMenuNavBarPropGetItemOnClick<ITEM>;\n getItemIconLeft?: MegaMenuNavBarPropGetItemIconLeft<ITEM>;\n getItemIconRight?: MegaMenuNavBarPropGetItemIconRight<ITEM>;\n getItemAs?: MegaMenuNavBarPropGetItemAs<ITEM>;\n getItemAttributes?: MegaMenuNavBarPropGetItemAttributes<ITEM>;\n onItemClick?: MegaMenuNavBarPropOnItemClick<ITEM>;\n } & (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel: MegaMenuNavBarPropGetItemLabel<ITEM>;\n }),\n HTMLDivElement\n >;\n\nexport type MegaMenuNavBarComponent = <ITEM = MegaMenuNavBarDefaultItem>(\n props: MegaMenuNavBarProps<ITEM>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport type MegaMenuNavBarItemProps<AS extends AsTags = 'div'> =\n PropsWithAsAttributes<\n {\n label: string;\n active?: boolean;\n onClick?: React.MouseEventHandler;\n iconLeft?: IconComponent;\n iconRight?: IconComponent;\n },\n AS\n >;\n\nexport type MegaMenuNavBarItemComponent = <AS extends AsTags = 'div'>(\n props: MegaMenuNavBarItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -3,9 +3,8 @@ import { AsAttributes, AsTags } from '@consta/uikit/__internal__/src/utils/types
3
3
  import React from 'react';
4
4
  import { PropsWithHTMLAttributesAndRef } from "../../utils/types/PropsWithHTMLAttributes";
5
5
  import { MegaMenuBannerBarDefaultItem, MegaMenuBannerBarPropGetItemAs, MegaMenuBannerBarPropGetItemAttributes, MegaMenuBannerBarPropGetItemDescription, MegaMenuBannerBarPropGetItemImage, MegaMenuBannerBarPropGetItemLabel, MegaMenuBannerBarPropGetItemOnClick } from './MegaMenuBannerBar';
6
- export type MegaMenuPropOnItemClick<ITEM> = (params: {
6
+ export type MegaMenuPropOnItemClick<ITEM> = (item: ITEM, props: {
7
7
  e: React.MouseEvent;
8
- item: ITEM;
9
8
  }) => void;
10
9
  export type MegaMenuDefaultItem = {
11
10
  key: string | number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/MegaMenu/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nimport {\n MegaMenuBannerBarDefaultItem,\n MegaMenuBannerBarPropGetItemAs,\n MegaMenuBannerBarPropGetItemAttributes,\n MegaMenuBannerBarPropGetItemDescription,\n MegaMenuBannerBarPropGetItemImage,\n MegaMenuBannerBarPropGetItemLabel,\n MegaMenuBannerBarPropGetItemOnClick,\n} from './MegaMenuBannerBar';\n\nexport type MegaMenuPropOnItemClick<ITEM> = (params: {\n e: React.MouseEvent;\n item: ITEM;\n}) => void;\n\nexport type MegaMenuDefaultItem = {\n key: string | number;\n label: string;\n iconLeft?: IconComponent;\n as?: AsTags;\n attributes?: AsAttributes;\n subMenu?: MegaMenuDefaultItem[];\n onClick?: React.MouseEventHandler;\n};\n\nexport type MegaMenuPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type MegaMenuPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuPropGetItemIconLeft<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type MegaMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuPropGetItemAs<ITEM> = (item: ITEM) => AsTags | undefined;\nexport type MegaMenuPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\nexport type MegaMenuPropGetItemSubMenu<ITEM> = (\n item: ITEM,\n) => ITEM[] | undefined;\n\nexport type ItemMappers<ITEM = MegaMenuDefaultItem> = {\n getItemKey?: MegaMenuPropGetItemKey<ITEM>;\n getItemLabel?: MegaMenuPropGetItemLabel<ITEM>;\n getItemIconLeft?: MegaMenuPropGetItemIconLeft<ITEM>;\n getItemOnClick?: MegaMenuPropGetItemOnClick<ITEM>;\n getItemAs?: MegaMenuPropGetItemAs<ITEM>;\n getItemAttributes?: MegaMenuPropGetItemAttributes<ITEM>;\n getItemSubMenu?: MegaMenuPropGetItemSubMenu<ITEM>;\n};\n\nexport type BannerMappers<ITEM = MegaMenuBannerBarDefaultItem> = {\n getBannerLabel?: MegaMenuBannerBarPropGetItemLabel<ITEM>;\n getBannerOnClick?: MegaMenuBannerBarPropGetItemOnClick<ITEM>;\n getBannerDescription?: MegaMenuBannerBarPropGetItemDescription<ITEM>;\n getBannerImage?: MegaMenuBannerBarPropGetItemImage<ITEM>;\n getBannerAs?: MegaMenuBannerBarPropGetItemAs<ITEM>;\n getBannerAttributes?: MegaMenuBannerBarPropGetItemAttributes<ITEM>;\n};\n\nexport type MegaMenuProps<\n ITEM = MegaMenuDefaultItem,\n BANNER = MegaMenuBannerBarDefaultItem,\n> = PropsWithHTMLAttributesAndRef<\n {\n banners?: BANNER[];\n items: ITEM[];\n menuTitle?: string;\n menuShowButtonText?: string;\n menuHideButtonText?: string;\n menuMaxElements?: number;\n bannerPosition?: 'right' | 'bottom';\n onItemClick?: MegaMenuPropOnItemClick<ITEM>;\n onBannerClick?: MegaMenuPropOnItemClick<BANNER>;\n } & BannerMappers<BANNER> &\n ItemMappers<ITEM> &\n (ITEM extends { key: MegaMenuDefaultItem['key'] }\n ? {}\n : { getItemKey: MegaMenuPropGetItemKey<ITEM> }) &\n (ITEM extends { label: MegaMenuDefaultItem['label'] }\n ? {}\n : { getItemLabel: MegaMenuPropGetItemLabel<ITEM> }) &\n (BANNER extends { label: MegaMenuBannerBarDefaultItem['label'] | unknown }\n ? {}\n : { getBannerLabel: MegaMenuBannerBarPropGetItemLabel<ITEM> }),\n HTMLDivElement\n>;\n\nexport type MegaMenuComponent = <\n ITEM = MegaMenuDefaultItem,\n BANNER = MegaMenuBannerBarDefaultItem,\n>(\n props: MegaMenuProps<ITEM, BANNER>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/MegaMenu/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport {\n AsAttributes,\n AsTags,\n} from '@consta/uikit/__internal__/src/utils/types/AsTags';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nimport {\n MegaMenuBannerBarDefaultItem,\n MegaMenuBannerBarPropGetItemAs,\n MegaMenuBannerBarPropGetItemAttributes,\n MegaMenuBannerBarPropGetItemDescription,\n MegaMenuBannerBarPropGetItemImage,\n MegaMenuBannerBarPropGetItemLabel,\n MegaMenuBannerBarPropGetItemOnClick,\n} from './MegaMenuBannerBar';\n\nexport type MegaMenuPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type MegaMenuDefaultItem = {\n key: string | number;\n label: string;\n iconLeft?: IconComponent;\n as?: AsTags;\n attributes?: AsAttributes;\n subMenu?: MegaMenuDefaultItem[];\n onClick?: React.MouseEventHandler;\n};\n\nexport type MegaMenuPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type MegaMenuPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MegaMenuPropGetItemIconLeft<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type MegaMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.MouseEventHandler | undefined;\nexport type MegaMenuPropGetItemAs<ITEM> = (item: ITEM) => AsTags | undefined;\nexport type MegaMenuPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => AsAttributes | undefined;\nexport type MegaMenuPropGetItemSubMenu<ITEM> = (\n item: ITEM,\n) => ITEM[] | undefined;\n\nexport type ItemMappers<ITEM = MegaMenuDefaultItem> = {\n getItemKey?: MegaMenuPropGetItemKey<ITEM>;\n getItemLabel?: MegaMenuPropGetItemLabel<ITEM>;\n getItemIconLeft?: MegaMenuPropGetItemIconLeft<ITEM>;\n getItemOnClick?: MegaMenuPropGetItemOnClick<ITEM>;\n getItemAs?: MegaMenuPropGetItemAs<ITEM>;\n getItemAttributes?: MegaMenuPropGetItemAttributes<ITEM>;\n getItemSubMenu?: MegaMenuPropGetItemSubMenu<ITEM>;\n};\n\nexport type BannerMappers<ITEM = MegaMenuBannerBarDefaultItem> = {\n getBannerLabel?: MegaMenuBannerBarPropGetItemLabel<ITEM>;\n getBannerOnClick?: MegaMenuBannerBarPropGetItemOnClick<ITEM>;\n getBannerDescription?: MegaMenuBannerBarPropGetItemDescription<ITEM>;\n getBannerImage?: MegaMenuBannerBarPropGetItemImage<ITEM>;\n getBannerAs?: MegaMenuBannerBarPropGetItemAs<ITEM>;\n getBannerAttributes?: MegaMenuBannerBarPropGetItemAttributes<ITEM>;\n};\n\nexport type MegaMenuProps<\n ITEM = MegaMenuDefaultItem,\n BANNER = MegaMenuBannerBarDefaultItem,\n> = PropsWithHTMLAttributesAndRef<\n {\n banners?: BANNER[];\n items: ITEM[];\n menuTitle?: string;\n menuShowButtonText?: string;\n menuHideButtonText?: string;\n menuMaxElements?: number;\n bannerPosition?: 'right' | 'bottom';\n onItemClick?: MegaMenuPropOnItemClick<ITEM>;\n onBannerClick?: MegaMenuPropOnItemClick<BANNER>;\n } & BannerMappers<BANNER> &\n ItemMappers<ITEM> &\n (ITEM extends { key: MegaMenuDefaultItem['key'] }\n ? {}\n : { getItemKey: MegaMenuPropGetItemKey<ITEM> }) &\n (ITEM extends { label: MegaMenuDefaultItem['label'] }\n ? {}\n : { getItemLabel: MegaMenuPropGetItemLabel<ITEM> }) &\n (BANNER extends { label: MegaMenuBannerBarDefaultItem['label'] | unknown }\n ? {}\n : { getBannerLabel: MegaMenuBannerBarPropGetItemLabel<ITEM> }),\n HTMLDivElement\n>;\n\nexport type MegaMenuComponent = <\n ITEM = MegaMenuDefaultItem,\n BANNER = MegaMenuBannerBarDefaultItem,\n>(\n props: MegaMenuProps<ITEM, BANNER>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","className","width","getItemActive","getItemHref","getItemLabel","getItemOnClick","getItemTarget","getItemSubMenu","onItemClick"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Menu.css";import{IconMeatball}from"@consta/icons/IconMeatball";import{IconSelect}from"@consta/icons/IconSelect";import{Button}from"@consta/uikit/Button";import{ContextMenu}from"@consta/uikit/ContextMenu";import{animateTimeout}from"@consta/uikit/MixPopoverAnimate";import{useDebounce}from"@consta/uikit/useDebounce";import{useFlag}from"@consta/uikit/useFlag";import{useHideElementsInLine}from"@consta/uikit/useHideElementsInLine";import{useMutableRef}from"@consta/uikit/useMutableRef";import React,{forwardRef,useCallback,useEffect,useRef,useState}from"react";import{getItemClick}from"../../helpers/getItemClick";import{cn}from"../../utils/bem";import{withDefaultGetters}from"./helpers";export const cnMenu=cn("Menu");const MenuRender=(a,b)=>{var c;const d=withDefaultGetters(a),{items:e,className:f,width:g,getItemActive:h,getItemHref:i,getItemLabel:j,getItemOnClick:k,getItemTarget:l,getItemSubMenu:m,onItemClick:n}=d,o=_objectWithoutProperties(d,_excluded),[p,q]=useState(),[r,s]=useFlag(),{visibleItems:t,itemsRefs:u,wrapperRef:v,hiddenItems:w,moreRef:x}=useHideElementsInLine(e),y=useRef(null),z=useMutableRef(i),A=useMutableRef(l),B=useCallback(a=>z.current(a)?"a":"span",[]),C=useCallback(a=>{const b=z.current(a),c=A.current(a);return _objectSpread(_objectSpread({},b&&{href:z.current(a)}),c&&{href:A.current(a)})},[]),D="number"==typeof(null===(c=a.style)||void 0===c?void 0:c.zIndex)?a.style.zIndex+1:void 0;return useEffect(useDebounce(()=>{r||q(void 0)},animateTimeout),[r]),React.createElement("nav",Object.assign({},o,{className:cnMenu({width:g},[f]),onMouseLeave:s.off,onMouseEnter:s.on,ref:b}),React.createElement("ul",{className:cnMenu("List"),ref:v},e.map((a,b)=>{const c=j(a),d=i(a),e=d?l(a):void 0,f=h(a),g=d?"a":"span",o=m(a),r=p===b,s=!t[b];return React.createElement("li",{className:cnMenu("Item",{hidden:s,active:f,opened:r}),key:cnMenu("Item",{index:b}),ref:u[b],onMouseEnter:()=>q(b)},React.createElement(g,{className:cnMenu("Link"),href:d,target:e,onClick:getItemClick(a,k,n)},c),o&&React.createElement(IconSelect,{size:"s",className:cnMenu("Arrow")}),React.createElement(ContextMenu,{isOpen:o&&0<o.length&&r,items:o||[],getItemLabel:j,getItemSubMenu:m,anchorRef:u[b],onItemClick:({e:a,item:b})=>getItemClick(b,k,n)(a),direction:"downStartLeft",possibleDirections:["upStartLeft","downStartRight","downStartLeft","upStartRight"],spareDirection:"downStartLeft",getItemAs:B,getItemAttributes:C,style:{zIndex:D}}))}),0<w.length&&React.createElement("li",{className:cnMenu("Item"),key:cnMenu("Item",{more:!0}),ref:x,onMouseEnter:()=>q("more")},React.createElement(Button,{iconLeft:IconMeatball,ref:y,size:"xs",view:"clear"}),React.createElement(ContextMenu,{isOpen:"more"===p,items:w,getItemLabel:j,getItemSubMenu:m,anchorRef:y,onItemClick:({e:a,item:b})=>getItemClick(b,k,n)(a),direction:"downStartLeft",possibleDirections:["upStartLeft","downStartRight","downStartLeft","upStartRight"],spareDirection:"downStartRight",getItemAs:B,getItemAttributes:C,style:{zIndex:D},offset:8}))))};export const Menu=forwardRef(MenuRender);export*from"./types";
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","className","width","getItemActive","getItemHref","getItemLabel","getItemOnClick","getItemTarget","getItemSubMenu","onItemClick"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Menu.css";import{IconMeatball}from"@consta/icons/IconMeatball";import{IconSelect}from"@consta/icons/IconSelect";import{Button}from"@consta/uikit/Button";import{ContextMenu}from"@consta/uikit/ContextMenu";import{animateTimeout}from"@consta/uikit/MixPopoverAnimate";import{useDebounce}from"@consta/uikit/useDebounce";import{useFlag}from"@consta/uikit/useFlag";import{useHideElementsInLine}from"@consta/uikit/useHideElementsInLineDepricated";import{useMutableRef}from"@consta/uikit/useMutableRef";import React,{forwardRef,useCallback,useEffect,useRef,useState}from"react";import{getItemClick}from"../../helpers/getItemClick";import{cn}from"../../utils/bem";import{withDefaultGetters}from"./helpers";export const cnMenu=cn("Menu");const MenuRender=(a,b)=>{var c;const d=withDefaultGetters(a),{items:e,className:f,width:g,getItemActive:h,getItemHref:i,getItemLabel:j,getItemOnClick:k,getItemTarget:l,getItemSubMenu:m,onItemClick:n}=d,o=_objectWithoutProperties(d,_excluded),[p,q]=useState(),[r,s]=useFlag(),{visibleItems:t,itemsRefs:u,wrapperRef:v,hiddenItems:w,moreRef:x}=useHideElementsInLine(e),y=useRef(null),z=useMutableRef(i),A=useMutableRef(l),B=useCallback(a=>z.current(a)?"a":"span",[]),C=useCallback(a=>{const b=z.current(a),c=A.current(a);return _objectSpread(_objectSpread({},b&&{href:z.current(a)}),c&&{href:A.current(a)})},[]),D="number"==typeof(null===(c=a.style)||void 0===c?void 0:c.zIndex)?a.style.zIndex+1:void 0;return useEffect(useDebounce(()=>{r||q(void 0)},animateTimeout),[r]),React.createElement("nav",Object.assign({},o,{className:cnMenu({width:g},[f]),onMouseLeave:s.off,onMouseEnter:s.on,ref:b}),React.createElement("ul",{className:cnMenu("List"),ref:v},e.map((a,b)=>{const c=j(a),d=i(a),e=d?l(a):void 0,f=h(a),g=d?"a":"span",o=m(a),r=p===b,s=!t[b];return React.createElement("li",{className:cnMenu("Item",{hidden:s,active:f,opened:r}),key:cnMenu("Item",{index:b}),ref:u[b],onMouseEnter:()=>q(b)},React.createElement(g,{className:cnMenu("Link"),href:d,target:e,onClick:getItemClick(a,k,n)},c),o&&React.createElement(IconSelect,{size:"s",className:cnMenu("Arrow")}),React.createElement(ContextMenu,{isOpen:o&&0<o.length&&r,items:o||[],getItemLabel:j,getItemSubMenu:m,anchorRef:u[b],onItemClick:(a,{e:b})=>getItemClick(a,k,n)(b),direction:"downStartLeft",possibleDirections:["upStartLeft","downStartRight","downStartLeft","upStartRight"],spareDirection:"downStartLeft",getItemAs:B,getItemAttributes:C,style:{zIndex:D}}))}),0<w.length&&React.createElement("li",{className:cnMenu("Item"),key:cnMenu("Item",{more:!0}),ref:x,onMouseEnter:()=>q("more")},React.createElement(Button,{iconLeft:IconMeatball,ref:y,size:"xs",view:"clear"}),React.createElement(ContextMenu,{isOpen:"more"===p,items:w,getItemLabel:j,getItemSubMenu:m,anchorRef:y,onItemClick:(a,{e:b})=>getItemClick(a,k,n)(b),direction:"downStartLeft",possibleDirections:["upStartLeft","downStartRight","downStartLeft","upStartRight"],spareDirection:"downStartRight",getItemAs:B,getItemAttributes:C,style:{zIndex:D},offset:8}))))};export const Menu=forwardRef(MenuRender);export*from"./types";
2
2
  //# sourceMappingURL=Menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","names":["IconMeatball","IconSelect","Button","ContextMenu","animateTimeout","useDebounce","useFlag","useHideElementsInLine","useMutableRef","React","forwardRef","useCallback","useEffect","useRef","useState","getItemClick","cn","withDefaultGetters","cnMenu","MenuRender","props","ref","c","d","items","className","width","getItemActive","getItemHref","getItemLabel","getItemOnClick","getItemTarget","getItemSubMenu","onItemClick","otherProps","_objectWithoutProperties","_excluded","openedSubMenu","setOpenedSubMenu","mouseOnMenu","setMouseOnMenu","visibleItems","itemsRefs","wrapperRef","hiddenItems","moreRef","moreButtonRef","getItemHrefRef","getItemTargetRef","getItemAs","item","current","getItemHTMLAttributes","href","target","_objectSpread","elementZIndex","style","zIndex","createElement","Object","assign","onMouseLeave","off","onMouseEnter","on","map","index","label","active","Tag","subItems","opened","hidden","key","g","onClick","size","isOpen","length","anchorRef","e","direction","possibleDirections","spareDirection","getItemAttributes","more","iconLeft","view","offset","Menu"],"sources":["../../../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import './Menu.css';\n\nimport { IconMeatball } from '@consta/icons/IconMeatball';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport { Button } from '@consta/uikit/Button';\nimport { ContextMenu } from '@consta/uikit/ContextMenu';\nimport { animateTimeout } from '@consta/uikit/MixPopoverAnimate';\nimport { useDebounce } from '@consta/uikit/useDebounce';\nimport { useFlag } from '@consta/uikit/useFlag';\nimport { useHideElementsInLine } from '@consta/uikit/useHideElementsInLine';\nimport { useMutableRef } from '@consta/uikit/useMutableRef';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { getItemClick } from '##/helpers/getItemClick';\nimport { cn } from '##/utils/bem';\n\nimport { withDefaultGetters } from './helpers';\nimport { MenuComponent, MenuProps } from './types';\n\nexport const cnMenu = cn('Menu');\n\nconst MenuRender = (props: MenuProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n items,\n className,\n width,\n getItemActive,\n getItemHref,\n getItemLabel,\n getItemOnClick,\n getItemTarget,\n getItemSubMenu,\n onItemClick,\n ...otherProps\n } = withDefaultGetters(props);\n\n const [openedSubMenu, setOpenedSubMenu] = useState<\n number | 'more' | undefined\n >();\n const [mouseOnMenu, setMouseOnMenu] = useFlag();\n\n const { visibleItems, itemsRefs, wrapperRef, hiddenItems, moreRef } =\n useHideElementsInLine<\n (typeof items)[number],\n HTMLLIElement,\n HTMLUListElement\n >(items);\n\n const moreButtonRef = useRef<HTMLButtonElement>(null);\n\n const getItemHrefRef = useMutableRef(getItemHref);\n const getItemTargetRef = useMutableRef(getItemTarget);\n\n const getItemAs = useCallback((item: (typeof items)[number]) => {\n if (getItemHrefRef.current(item)) {\n return 'a';\n }\n return 'span';\n }, []);\n\n const getItemHTMLAttributes = useCallback((item: (typeof items)[number]) => {\n const href = getItemHrefRef.current(item);\n const target = getItemTargetRef.current(item);\n\n return {\n ...(href && { href: getItemHrefRef.current(item) }),\n ...(target && { href: getItemTargetRef.current(item) }),\n };\n }, []);\n\n const elementZIndex =\n typeof props.style?.zIndex === 'number'\n ? props.style.zIndex + 1\n : undefined;\n\n useEffect(\n useDebounce(() => {\n if (!mouseOnMenu) {\n setOpenedSubMenu(undefined);\n }\n }, animateTimeout),\n [mouseOnMenu],\n );\n\n return (\n <nav\n {...otherProps}\n className={cnMenu({ width }, [className])}\n onMouseLeave={setMouseOnMenu.off}\n onMouseEnter={setMouseOnMenu.on}\n ref={ref}\n >\n <ul className={cnMenu('List')} ref={wrapperRef}>\n {items.map((item, index) => {\n const label = getItemLabel(item);\n const href = getItemHref(item);\n const target = href ? getItemTarget(item) : undefined;\n const active = getItemActive(item);\n const Tag = href ? 'a' : 'span';\n const subItems = getItemSubMenu(item);\n const opened = openedSubMenu === index;\n const hidden = !visibleItems[index];\n return (\n <li\n className={cnMenu('Item', { hidden, active, opened })}\n key={cnMenu('Item', { index })}\n ref={itemsRefs[index]}\n onMouseEnter={() => setOpenedSubMenu(index)}\n >\n <Tag\n className={cnMenu('Link')}\n href={href}\n target={target}\n onClick={getItemClick(item, getItemOnClick, onItemClick)}\n >\n {label}\n </Tag>\n {subItems && <IconSelect size=\"s\" className={cnMenu('Arrow')} />}\n <ContextMenu\n isOpen={subItems && subItems.length > 0 && opened}\n items={subItems || []}\n getItemLabel={getItemLabel}\n getItemSubMenu={getItemSubMenu}\n anchorRef={itemsRefs[index]}\n onItemClick={({ e, item }) =>\n getItemClick(item, getItemOnClick, onItemClick)(e)\n }\n direction=\"downStartLeft\"\n possibleDirections={[\n 'upStartLeft',\n 'downStartRight',\n 'downStartLeft',\n 'upStartRight',\n ]}\n spareDirection=\"downStartLeft\"\n getItemAs={getItemAs}\n getItemAttributes={getItemHTMLAttributes}\n style={{ zIndex: elementZIndex }}\n />\n </li>\n );\n })}\n {hiddenItems.length > 0 && (\n <li\n className={cnMenu('Item')}\n key={cnMenu('Item', { more: true })}\n ref={moreRef}\n onMouseEnter={() => setOpenedSubMenu('more')}\n >\n <Button\n iconLeft={IconMeatball}\n ref={moreButtonRef}\n size=\"xs\"\n view=\"clear\"\n />\n <ContextMenu\n isOpen={openedSubMenu === 'more'}\n items={hiddenItems}\n getItemLabel={getItemLabel}\n getItemSubMenu={getItemSubMenu}\n anchorRef={moreButtonRef}\n onItemClick={({ e, item }) =>\n getItemClick(item, getItemOnClick, onItemClick)(e)\n }\n direction=\"downStartLeft\"\n possibleDirections={[\n 'upStartLeft',\n 'downStartRight',\n 'downStartLeft',\n 'upStartRight',\n ]}\n spareDirection=\"downStartRight\"\n getItemAs={getItemAs}\n getItemAttributes={getItemHTMLAttributes}\n style={{ zIndex: elementZIndex }}\n offset={8}\n />\n </li>\n )}\n </ul>\n </nav>\n );\n};\n\nexport const Menu = forwardRef(MenuRender) as MenuComponent;\n\nexport * from './types';\n"],"mappings":"q5BAAA,mBAEA,OAASA,YAAY,KAAQ,4BAA4B,CACzD,OAASC,UAAU,KAAQ,0BAA0B,CACrD,OAASC,MAAM,KAAQ,sBAAsB,CAC7C,OAASC,WAAW,KAAQ,2BAA2B,CACvD,OAASC,cAAc,KAAQ,iCAAiC,CAChE,OAASC,WAAW,KAAQ,2BAA2B,CACvD,OAASC,OAAO,KAAQ,uBAAuB,CAC/C,OAASC,qBAAqB,KAAQ,qCAAqC,CAC3E,OAASC,aAAa,KAAQ,6BAA6B,CAC3D,MAAO,CAAAC,KAAK,EACVC,UAAU,CACVC,WAAW,CACXC,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAASC,YAAY,kCACrB,OAASC,EAAE,uBAEX,OAASC,kBAAkB,iBAG3B,MAAO,MAAM,CAAAC,MAAM,CAAGF,EAAE,CAAC,MAAM,CAAC,CAEhC,KAAM,CAAAG,UAAU,CAAGA,CAACC,CAAgB,CAAEC,CAA8B,GAAK,KAAAC,CAAA,OAAAC,CAAA,CAanEN,kBAAkB,CAACG,CAAK,CAAC,CAZvB,CACJI,KAAK,CAALA,CAAK,CACLC,SAAS,CAATA,CAAS,CACTC,KAAK,CAALA,CAAK,CACLC,aAAa,CAAbA,CAAa,CACbC,WAAW,CAAXA,CAAW,CACXC,YAAY,CAAZA,CAAY,CACZC,cAAc,CAAdA,C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S,UAAU,CAAkB,CAE3D"}
1
+ {"version":3,"file":"Menu.js","names":["IconMeatball","IconSelect","Button","ContextMenu","animateTimeout","useDebounce","useFlag","useHideElementsInLine","useMutableRef","React","forwardRef","useCallback","useEffect","useRef","useState","getItemClick","cn","withDefaultGetters","cnMenu","MenuRender","props","ref","c","d","items","className","width","getItemActive","getItemHref","getItemLabel","getItemOnClick","getItemTarget","getItemSubMenu","onItemClick","otherProps","_objectWithoutProperties","_excluded","openedSubMenu","setOpenedSubMenu","mouseOnMenu","setMouseOnMenu","visibleItems","itemsRefs","wrapperRef","hiddenItems","moreRef","moreButtonRef","getItemHrefRef","getItemTargetRef","getItemAs","item","current","getItemHTMLAttributes","href","target","_objectSpread","elementZIndex","style","zIndex","createElement","Object","assign","onMouseLeave","off","onMouseEnter","on","map","index","label","active","Tag","subItems","opened","hidden","key","g","onClick","size","isOpen","length","anchorRef","e","direction","possibleDirections","spareDirection","getItemAttributes","more","iconLeft","view","offset","Menu"],"sources":["../../../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import './Menu.css';\n\nimport { IconMeatball } from '@consta/icons/IconMeatball';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport { Button } from '@consta/uikit/Button';\nimport { ContextMenu } from '@consta/uikit/ContextMenu';\nimport { animateTimeout } from '@consta/uikit/MixPopoverAnimate';\nimport { useDebounce } from '@consta/uikit/useDebounce';\nimport { useFlag } from '@consta/uikit/useFlag';\nimport { useHideElementsInLine } from '@consta/uikit/useHideElementsInLineDepricated';\nimport { useMutableRef } from '@consta/uikit/useMutableRef';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { getItemClick } from '##/helpers/getItemClick';\nimport { cn } from '##/utils/bem';\n\nimport { withDefaultGetters } from './helpers';\nimport { MenuComponent, MenuProps } from './types';\n\nexport const cnMenu = cn('Menu');\n\nconst MenuRender = (props: MenuProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n items,\n className,\n width,\n getItemActive,\n getItemHref,\n getItemLabel,\n getItemOnClick,\n getItemTarget,\n getItemSubMenu,\n onItemClick,\n ...otherProps\n } = withDefaultGetters(props);\n\n const [openedSubMenu, setOpenedSubMenu] = useState<\n number | 'more' | undefined\n >();\n const [mouseOnMenu, setMouseOnMenu] = useFlag();\n\n const { visibleItems, itemsRefs, wrapperRef, hiddenItems, moreRef } =\n useHideElementsInLine<\n (typeof items)[number],\n HTMLLIElement,\n HTMLUListElement\n >(items);\n\n const moreButtonRef = useRef<HTMLButtonElement>(null);\n\n const getItemHrefRef = useMutableRef(getItemHref);\n const getItemTargetRef = useMutableRef(getItemTarget);\n\n const getItemAs = useCallback((item: (typeof items)[number]) => {\n if (getItemHrefRef.current(item)) {\n return 'a';\n }\n return 'span';\n }, []);\n\n const getItemHTMLAttributes = useCallback((item: (typeof items)[number]) => {\n const href = getItemHrefRef.current(item);\n const target = getItemTargetRef.current(item);\n\n return {\n ...(href && { href: getItemHrefRef.current(item) }),\n ...(target && { href: getItemTargetRef.current(item) }),\n };\n }, []);\n\n const elementZIndex =\n typeof props.style?.zIndex === 'number'\n ? props.style.zIndex + 1\n : undefined;\n\n useEffect(\n useDebounce(() => {\n if (!mouseOnMenu) {\n setOpenedSubMenu(undefined);\n }\n }, animateTimeout),\n [mouseOnMenu],\n );\n\n return (\n <nav\n {...otherProps}\n className={cnMenu({ width }, [className])}\n onMouseLeave={setMouseOnMenu.off}\n onMouseEnter={setMouseOnMenu.on}\n ref={ref}\n >\n <ul className={cnMenu('List')} ref={wrapperRef}>\n {items.map((item, index) => {\n const label = getItemLabel(item);\n const href = getItemHref(item);\n const target = href ? getItemTarget(item) : undefined;\n const active = getItemActive(item);\n const Tag = href ? 'a' : 'span';\n const subItems = getItemSubMenu(item);\n const opened = openedSubMenu === index;\n const hidden = !visibleItems[index];\n return (\n <li\n className={cnMenu('Item', { hidden, active, opened })}\n key={cnMenu('Item', { index })}\n ref={itemsRefs[index]}\n onMouseEnter={() => setOpenedSubMenu(index)}\n >\n <Tag\n className={cnMenu('Link')}\n href={href}\n target={target}\n onClick={getItemClick(item, getItemOnClick, onItemClick)}\n >\n {label}\n </Tag>\n {subItems && <IconSelect size=\"s\" className={cnMenu('Arrow')} />}\n <ContextMenu\n isOpen={subItems && subItems.length > 0 && opened}\n items={subItems || []}\n getItemLabel={getItemLabel}\n getItemSubMenu={getItemSubMenu}\n anchorRef={itemsRefs[index]}\n onItemClick={(item, { e }) =>\n getItemClick(item, getItemOnClick, onItemClick)(e)\n }\n direction=\"downStartLeft\"\n possibleDirections={[\n 'upStartLeft',\n 'downStartRight',\n 'downStartLeft',\n 'upStartRight',\n ]}\n spareDirection=\"downStartLeft\"\n getItemAs={getItemAs}\n getItemAttributes={getItemHTMLAttributes}\n style={{ zIndex: elementZIndex }}\n />\n </li>\n );\n })}\n {hiddenItems.length > 0 && (\n <li\n className={cnMenu('Item')}\n key={cnMenu('Item', { more: true })}\n ref={moreRef}\n onMouseEnter={() => setOpenedSubMenu('more')}\n >\n <Button\n iconLeft={IconMeatball}\n ref={moreButtonRef}\n size=\"xs\"\n view=\"clear\"\n />\n <ContextMenu\n isOpen={openedSubMenu === 'more'}\n items={hiddenItems}\n getItemLabel={getItemLabel}\n getItemSubMenu={getItemSubMenu}\n anchorRef={moreButtonRef}\n onItemClick={(item, { e }) =>\n getItemClick(item, getItemOnClick, onItemClick)(e)\n }\n direction=\"downStartLeft\"\n possibleDirections={[\n 'upStartLeft',\n 'downStartRight',\n 'downStartLeft',\n 'upStartRight',\n ]}\n spareDirection=\"downStartRight\"\n getItemAs={getItemAs}\n getItemAttributes={getItemHTMLAttributes}\n style={{ zIndex: elementZIndex }}\n offset={8}\n />\n </li>\n )}\n </ul>\n </nav>\n );\n};\n\nexport const Menu = forwardRef(MenuRender) as MenuComponent;\n\nexport * from './types';\n"],"mappings":"q5BAAA,mBAEA,OAASA,YAAY,KAAQ,4BAA4B,CACzD,OAASC,UAAU,KAAQ,0BAA0B,CACrD,OAASC,MAAM,K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I,CAAC,OAAO,CACb,CAAC,CACF/E,KAAA,CAAAkD,aAAA,CAACxD,WAAW,EACV2E,MAAM,CAAoB,MAAM,GAAxBzC,CAAyB,CACjCb,KAAK,CAAEoB,CAAY,CACnBf,YAAY,CAAEA,CAAa,CAC3BG,cAAc,CAAEA,CAAe,CAC/BgD,SAAS,CAAElC,CAAc,CACzBb,WAAW,CAAEA,CAACiB,CAAI,CAAE,CAAE+B,CAAC,CAADA,CAAE,CAAC,GACvBlE,YAAY,CAACmC,CAAI,CAAEpB,CAAc,CAAEG,CAAW,CAAC,CAACgD,CAAC,CAClD,CACDC,SAAS,CAAC,eAAe,CACzBC,kBAAkB,CAAE,CAClB,aAAa,CACb,gBAAgB,CAChB,eAAe,CACf,cAAc,CACd,CACFC,cAAc,CAAC,gBAAgB,CAC/BnC,SAAS,CAAEA,CAAU,CACrBoC,iBAAiB,CAAEjC,CAAsB,CACzCK,KAAK,CAAE,CAAEC,MAAM,CAAEF,CAAc,CAAE,CACjCiC,MAAM,CAAE,CAAE,CACX,CACC,CAEJ,CACD,CAET,CAAC,CAED,MAAO,MAAM,CAAAC,IAAI,CAAGhF,UAAU,CAACS,UAAU,CAAkB,CAE3D"}
@@ -14,9 +14,8 @@ export type MenuPropGetItemTarget<ITEM> = (item: ITEM) => string | undefined;
14
14
  export type MenuPropGetItemActive<ITEM> = (item: ITEM) => boolean | undefined;
15
15
  export type MenuPropGetItemSubMenu<ITEM> = (item: ITEM) => ITEM[] | undefined;
16
16
  export type MenuPropGetItemOnClick<ITEM> = (item: ITEM) => React.EventHandler<React.MouseEvent> | undefined;
17
- export type MenuPropOnItemClick<ITEM> = (props: {
17
+ export type MenuPropOnItemClick<ITEM> = (item: ITEM, props: {
18
18
  e: React.MouseEvent;
19
- item: ITEM;
20
19
  }) => void;
21
20
  export type MenuProps<ITEM = MenuDefaultItem> = PropsWithHTMLAttributesAndRef<{
22
21
  items: ITEM[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/Menu/types.ts"],"sourcesContent":["import { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MenuDefaultItem = {\n label: string;\n href?: string;\n target?: string;\n active?: boolean;\n onClick?: React.EventHandler<React.MouseEvent>;\n subMenu?: MenuDefaultItem[];\n};\n\nexport type MenuPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MenuPropGetItemHref<ITEM> = (item: ITEM) => string | undefined;\nexport type MenuPropGetItemTarget<ITEM> = (item: ITEM) => string | undefined;\nexport type MenuPropGetItemActive<ITEM> = (item: ITEM) => boolean | undefined;\nexport type MenuPropGetItemSubMenu<ITEM> = (item: ITEM) => ITEM[] | undefined;\nexport type MenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\nexport type MenuPropOnItemClick<ITEM> = (props: {\n e: React.MouseEvent;\n item: ITEM;\n}) => void;\n\nexport type MenuProps<ITEM = MenuDefaultItem> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n width?: 'full';\n onItemClick?: MenuPropOnItemClick<ITEM>;\n getItemHref?: MenuPropGetItemHref<ITEM>;\n getItemLabel?: MenuPropGetItemLabel<ITEM>;\n getItemTarget?: MenuPropGetItemTarget<ITEM>;\n getItemActive?: MenuPropGetItemActive<ITEM>;\n getItemOnClick?: MenuPropGetItemOnClick<ITEM>;\n getItemSubMenu?: MenuPropGetItemSubMenu<ITEM>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: MenuDefaultItem['label'] }\n ? {}\n : { getItemLabel: MenuPropGetItemLabel<ITEM> });\n\nexport type MenuComponent = <ITEM = MenuDefaultItem>(\n props: MenuProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/Menu/types.ts"],"sourcesContent":["import { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type MenuDefaultItem = {\n label: string;\n href?: string;\n target?: string;\n active?: boolean;\n onClick?: React.EventHandler<React.MouseEvent>;\n subMenu?: MenuDefaultItem[];\n};\n\nexport type MenuPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type MenuPropGetItemHref<ITEM> = (item: ITEM) => string | undefined;\nexport type MenuPropGetItemTarget<ITEM> = (item: ITEM) => string | undefined;\nexport type MenuPropGetItemActive<ITEM> = (item: ITEM) => boolean | undefined;\nexport type MenuPropGetItemSubMenu<ITEM> = (item: ITEM) => ITEM[] | undefined;\nexport type MenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\nexport type MenuPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type MenuProps<ITEM = MenuDefaultItem> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n width?: 'full';\n onItemClick?: MenuPropOnItemClick<ITEM>;\n getItemHref?: MenuPropGetItemHref<ITEM>;\n getItemLabel?: MenuPropGetItemLabel<ITEM>;\n getItemTarget?: MenuPropGetItemTarget<ITEM>;\n getItemActive?: MenuPropGetItemActive<ITEM>;\n getItemOnClick?: MenuPropGetItemOnClick<ITEM>;\n getItemSubMenu?: MenuPropGetItemSubMenu<ITEM>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: MenuDefaultItem['label'] }\n ? {}\n : { getItemLabel: MenuPropGetItemLabel<ITEM> });\n\nexport type MenuComponent = <ITEM = MenuDefaultItem>(\n props: MenuProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";const _excluded=["items","onItemClick","groups","getItemLabel","getItemIcon","getItemRightSide","getItemAs","getItemAttributes","getItemGroupKey","getItemActive","getItemRef","getItemAdditionalClassName","getGroupKey","getGroupLabel","getGroupRightSide","getGroupAdditionalClassName","size","form","getItemSubMenu","getItemStatus","sortGroup","className"];import{getGroups}from"@consta/uikit/__internal__/src/utils/getGroups";import{renderHeader}from"@consta/uikit/ListCanary";import React,{forwardRef,useMemo}from"react";import{cnCanary}from"../../utils/bem";import{withDefaultGetters}from"./helpers";import{NavbarItem}from"./NavbarItem";import{defaultNavbarPropForm,defaultNavbarPropSize}from"./types";const cnNavbar=cnCanary("Navbar"),NavbarRender=(a,b)=>{const c=withDefaultGetters(a),{items:d,onItemClick:e,groups:f,getItemLabel:g,getItemIcon:h,getItemRightSide:i,getItemAs:j,getItemAttributes:k,getItemGroupKey:l,getItemActive:m,getItemRef:n,getItemAdditionalClassName:o,getGroupKey:p,getGroupLabel:q,getGroupRightSide:r,getGroupAdditionalClassName:s,size:x=defaultNavbarPropSize,form:y=defaultNavbarPropForm,getItemSubMenu:t,getItemStatus:u,sortGroup:v,className:w}=c,z=_objectWithoutProperties(c,_excluded),A=useMemo(()=>getGroups(d,l,f,p,v),[f,d]);return React.createElement("div",Object.assign({},z,{ref:b,className:cnNavbar(null,[w])}),A.map((a,b)=>React.createElement(React.Fragment,{key:a.key},renderHeader(a.group&&q(a.group),0===b,x,a.group&&r(a.group),{pV:"xs",mH:"m",mB:"2xs"},void 0,s&&a.group&&s(a.group)),a.items.map((b,c)=>React.createElement(React.Fragment,{key:`${a.key}-${c}`},React.createElement(NavbarItem,{size:x,item:b,level:0,onItemClick:e,getItemLabel:g,getItemActive:m,getItemAdditionalClassName:o,getItemAs:j,getItemAttributes:k,getItemIcon:h,getItemRef:n,getItemRightSide:i,getItemSubMenu:t,getItemStatus:u,form:y}))))))};export const Navbar=forwardRef(NavbarRender);
2
+ //# sourceMappingURL=Navbar.js.map