@gravity-ui/page-constructor 8.0.0-beta.2 → 8.1.0

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 (595) hide show
  1. package/README.md +39 -2
  2. package/build/cjs/_vendor/swiper-modules.js +1309 -0
  3. package/build/cjs/_vendor/swiper-modules.js.map +7 -0
  4. package/build/cjs/_vendor/swiper-react.js +4651 -0
  5. package/build/cjs/_vendor/swiper-react.js.map +7 -0
  6. package/build/cjs/_vendor/swiper.js +3822 -0
  7. package/build/cjs/_vendor/swiper.js.map +7 -0
  8. package/build/cjs/blocks/CardLayout/CardLayout.css +6 -0
  9. package/build/cjs/blocks/CardLayout/CardLayout.d.ts +1 -1
  10. package/build/cjs/blocks/CardLayout/CardLayout.js +2 -2
  11. package/build/cjs/blocks/CardLayout/CardLayout.js.map +1 -1
  12. package/build/cjs/blocks/Companies/schema.d.ts +1 -0
  13. package/build/cjs/blocks/Companies/schema.js +2 -1
  14. package/build/cjs/blocks/Companies/schema.js.map +1 -1
  15. package/build/cjs/blocks/ContentLayout/ContentLayout.js +4 -2
  16. package/build/cjs/blocks/ContentLayout/ContentLayout.js.map +1 -1
  17. package/build/cjs/blocks/ContentLayout/schema.d.ts +11 -0
  18. package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.css +5 -5
  19. package/build/cjs/blocks/FilterBlock/FilterBlock.d.ts +1 -2
  20. package/build/cjs/blocks/FilterBlock/FilterBlock.js.map +1 -1
  21. package/build/cjs/blocks/FoldableList/schema.d.ts +11 -0
  22. package/build/cjs/blocks/Form/Form.css +5 -2
  23. package/build/cjs/blocks/Form/Form.d.ts +2 -3
  24. package/build/cjs/blocks/Form/Form.js +14 -11
  25. package/build/cjs/blocks/Form/Form.js.map +1 -1
  26. package/build/cjs/blocks/Form/schema.d.ts +12 -4
  27. package/build/cjs/blocks/Form/schema.js +1 -4
  28. package/build/cjs/blocks/Form/schema.js.map +1 -1
  29. package/build/cjs/blocks/Form/utils.d.ts +3 -0
  30. package/build/cjs/blocks/Form/utils.js +20 -0
  31. package/build/cjs/blocks/Form/utils.js.map +1 -0
  32. package/build/cjs/blocks/Header/Header.css +13 -0
  33. package/build/cjs/blocks/Header/Header.d.ts +7 -1
  34. package/build/cjs/blocks/Header/Header.js +11 -18
  35. package/build/cjs/blocks/Header/Header.js.map +1 -1
  36. package/build/cjs/blocks/Header/schema.d.ts +77 -0
  37. package/build/cjs/blocks/Header/schema.js +13 -1
  38. package/build/cjs/blocks/Header/schema.js.map +1 -1
  39. package/build/cjs/blocks/HeaderSlider/schema.d.ts +29 -0
  40. package/build/cjs/blocks/Info/schema.d.ts +22 -0
  41. package/build/cjs/blocks/Map/Map.js.map +1 -1
  42. package/build/cjs/blocks/Map/schema.d.ts +101 -0
  43. package/build/cjs/blocks/Media/Media.js +1 -1
  44. package/build/cjs/blocks/Media/Media.js.map +1 -1
  45. package/build/cjs/blocks/Media/schema.d.ts +22 -0
  46. package/build/cjs/blocks/Questions/QuestionBlockItem/QuestionBlockItem.js +3 -4
  47. package/build/cjs/blocks/Questions/QuestionBlockItem/QuestionBlockItem.js.map +1 -1
  48. package/build/cjs/blocks/Questions/Questions.js +32 -7
  49. package/build/cjs/blocks/Questions/Questions.js.map +1 -1
  50. package/build/cjs/blocks/Questions/schema.d.ts +11 -0
  51. package/build/cjs/blocks/Share/Share.js +1 -3
  52. package/build/cjs/blocks/Share/Share.js.map +1 -1
  53. package/build/cjs/blocks/Slider/Slider.css +62 -1
  54. package/build/cjs/blocks/Slider/Slider.d.ts +6 -4
  55. package/build/cjs/blocks/Slider/Slider.js +7 -7
  56. package/build/cjs/blocks/Slider/Slider.js.map +1 -1
  57. package/build/cjs/blocks/Slider/useSlider.d.ts +1 -2
  58. package/build/cjs/blocks/Slider/useSlider.js +3 -7
  59. package/build/cjs/blocks/Slider/useSlider.js.map +1 -1
  60. package/build/cjs/blocks/Slider/useSliderPagination.d.ts +1 -1
  61. package/build/cjs/blocks/Slider/useSliderPagination.js.map +1 -1
  62. package/build/cjs/blocks/Slider/utils.d.ts +1 -1
  63. package/build/cjs/blocks/Slider/utils.js.map +1 -1
  64. package/build/cjs/blocks/Table/Table.js +16 -3
  65. package/build/cjs/blocks/Table/Table.js.map +1 -1
  66. package/build/cjs/blocks/Tabs/TabContent/TabContent.js +12 -12
  67. package/build/cjs/blocks/Tabs/TabContent/TabContent.js.map +1 -1
  68. package/build/cjs/blocks/Tabs/Tabs.js +1 -1
  69. package/build/cjs/blocks/Tabs/Tabs.js.map +1 -1
  70. package/build/cjs/blocks/Tabs/schema.d.ts +11 -0
  71. package/build/cjs/components/Button/Button.css +2 -7
  72. package/build/cjs/components/Button/Button.js +29 -4
  73. package/build/cjs/components/Button/Button.js.map +1 -1
  74. package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +1 -1
  75. package/build/cjs/components/ButtonTabs/ButtonTabs.js.map +1 -1
  76. package/build/cjs/components/Buttons/Buttons.css +3 -0
  77. package/build/cjs/components/Buttons/Buttons.d.ts +1 -2
  78. package/build/cjs/components/Buttons/Buttons.js +1 -1
  79. package/build/cjs/components/Buttons/Buttons.js.map +1 -1
  80. package/build/cjs/components/CardBase/CardBase.css +15 -0
  81. package/build/cjs/components/CardBase/CardBase.d.ts +3 -5
  82. package/build/cjs/components/CardBase/CardBase.js.map +1 -1
  83. package/build/cjs/components/ContentIcon/ContentIcon.d.ts +8 -0
  84. package/build/cjs/components/ContentIcon/ContentIcon.js +22 -0
  85. package/build/cjs/components/ContentIcon/ContentIcon.js.map +1 -0
  86. package/build/cjs/components/ContentLabels/ContentLabels.css +53 -0
  87. package/build/cjs/components/ContentLabels/ContentLabels.d.ts +3 -0
  88. package/build/cjs/components/ContentLabels/ContentLabels.js +16 -0
  89. package/build/cjs/components/ContentLabels/ContentLabels.js.map +1 -0
  90. package/build/cjs/components/ContentList/ContentList.js +3 -3
  91. package/build/cjs/components/ContentList/ContentList.js.map +1 -1
  92. package/build/cjs/components/DefaultVideo/DefaultVideo.js +23 -2
  93. package/build/cjs/components/DefaultVideo/DefaultVideo.js.map +1 -1
  94. package/build/cjs/components/FullscreenMedia/FullscreenMedia.css +3 -1
  95. package/build/cjs/components/Icon/Icon.css +10 -0
  96. package/build/cjs/components/Icon/Icon.d.ts +9 -0
  97. package/build/cjs/components/Icon/Icon.js +24 -0
  98. package/build/cjs/components/Icon/Icon.js.map +1 -0
  99. package/build/cjs/components/IconWrapper/IconWrapper.css +16 -1
  100. package/build/cjs/components/IconWrapper/IconWrapper.js +10 -6
  101. package/build/cjs/components/IconWrapper/IconWrapper.js.map +1 -1
  102. package/build/cjs/components/InnerForm/InnerForm.d.ts +1 -2
  103. package/build/cjs/components/InnerForm/InnerForm.js.map +1 -1
  104. package/build/cjs/components/Link/Link.d.ts +2 -2
  105. package/build/cjs/components/Link/Link.js +2 -2
  106. package/build/cjs/components/Link/Link.js.map +1 -1
  107. package/build/cjs/components/Links/Links.d.ts +1 -1
  108. package/build/cjs/components/Links/Links.js +1 -1
  109. package/build/cjs/components/Links/Links.js.map +1 -1
  110. package/build/cjs/components/Map/GoogleMap.d.ts +1 -2
  111. package/build/cjs/components/Map/GoogleMap.js +19 -3
  112. package/build/cjs/components/Map/GoogleMap.js.map +1 -1
  113. package/build/cjs/components/Map/YMap/YMap.d.ts +4 -4
  114. package/build/cjs/components/Map/YMap/YMap.js +46 -15
  115. package/build/cjs/components/Map/YMap/YMap.js.map +1 -1
  116. package/build/cjs/components/Map/YMap/YandexMap.d.ts +1 -2
  117. package/build/cjs/components/Map/YMap/YandexMap.js +73 -7
  118. package/build/cjs/components/Map/YMap/YandexMap.js.map +1 -1
  119. package/build/cjs/components/Map/YMap/utils.d.ts +8 -0
  120. package/build/cjs/components/Map/YMap/utils.js +96 -0
  121. package/build/cjs/components/Map/YMap/utils.js.map +1 -0
  122. package/build/cjs/components/Media/FullscreenVideo/FullscreenVideo.d.ts +1 -2
  123. package/build/cjs/components/Media/FullscreenVideo/FullscreenVideo.js.map +1 -1
  124. package/build/cjs/components/Media/Video/Video.js +2 -13
  125. package/build/cjs/components/Media/Video/Video.js.map +1 -1
  126. package/build/cjs/components/MediaBase/MediaBase.d.ts +1 -3
  127. package/build/cjs/components/MediaBase/MediaBase.js.map +1 -1
  128. package/build/cjs/components/ReactPlayer/ReactPlayer.d.ts +1 -2
  129. package/build/cjs/components/ReactPlayer/ReactPlayer.js +19 -13
  130. package/build/cjs/components/ReactPlayer/ReactPlayer.js.map +1 -1
  131. package/build/cjs/components/Title/Title.d.ts +3 -2
  132. package/build/cjs/components/Title/Title.js +2 -2
  133. package/build/cjs/components/Title/Title.js.map +1 -1
  134. package/build/cjs/components/UnpublishedLabel/UnpublishedLabel.js.map +1 -1
  135. package/build/cjs/components/YandexForm/YandexForm.js +1 -1
  136. package/build/cjs/components/YandexForm/YandexForm.js.map +1 -1
  137. package/build/cjs/components/index.d.ts +2 -0
  138. package/build/cjs/components/index.js +5 -1
  139. package/build/cjs/components/index.js.map +1 -1
  140. package/build/cjs/constructor-items.d.ts +7 -7
  141. package/build/cjs/containers/PageConstructor/PageConstructor.css +0 -1
  142. package/build/cjs/containers/PageConstructor/Provider.js +2 -0
  143. package/build/cjs/containers/PageConstructor/Provider.js.map +1 -1
  144. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts +1 -2
  145. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js.map +1 -1
  146. package/build/cjs/context/locationContext/locationContext.d.ts +1 -1
  147. package/build/cjs/context/locationContext/locationContext.js.map +1 -1
  148. package/build/cjs/context/mapsContext/mapsProvider.d.ts +1 -1
  149. package/build/cjs/context/mapsContext/mapsProvider.js.map +1 -1
  150. package/build/cjs/context/windowWidthContext/WindowWidthContext.d.ts +4 -0
  151. package/build/cjs/context/windowWidthContext/WindowWidthContext.js +28 -0
  152. package/build/cjs/context/windowWidthContext/WindowWidthContext.js.map +1 -0
  153. package/build/cjs/context/windowWidthContext/index.d.ts +1 -0
  154. package/build/cjs/context/windowWidthContext/index.js +5 -0
  155. package/build/cjs/context/windowWidthContext/index.js.map +1 -0
  156. package/build/cjs/editor/components/AddBlock/AddBlock.d.ts +1 -2
  157. package/build/cjs/editor/components/AddBlock/AddBlock.js.map +1 -1
  158. package/build/cjs/editor/components/Layout/Layout.d.ts +2 -6
  159. package/build/cjs/editor/components/Layout/Layout.js.map +1 -1
  160. package/build/cjs/editor/data/previews/default-preview.d.ts +1 -1
  161. package/build/cjs/editor/data/previews/default-preview.js.map +1 -1
  162. package/build/cjs/editor/data/previews/header-block.d.ts +1 -1
  163. package/build/cjs/editor/data/previews/header-block.js.map +1 -1
  164. package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.d.ts +2 -3
  165. package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +1 -1
  166. package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js.map +1 -1
  167. package/build/cjs/editor/icons/Tablet.d.ts +1 -1
  168. package/build/cjs/editor/icons/Tablet.js.map +1 -1
  169. package/build/cjs/grid/Grid/Grid.js.map +1 -1
  170. package/build/cjs/grid/Row/Row.d.ts +1 -1
  171. package/build/cjs/grid/Row/Row.js.map +1 -1
  172. package/build/cjs/hooks/useDeviceValue.d.ts +2 -0
  173. package/build/cjs/hooks/useDeviceValue.js +33 -0
  174. package/build/cjs/hooks/useDeviceValue.js.map +1 -0
  175. package/build/cjs/icons/BrandIconDark.d.ts +1 -1
  176. package/build/cjs/icons/BrandIconDark.js.map +1 -1
  177. package/build/cjs/icons/BrandIconLight.d.ts +1 -1
  178. package/build/cjs/icons/BrandIconLight.js.map +1 -1
  179. package/build/cjs/icons/BrandName.d.ts +1 -1
  180. package/build/cjs/icons/BrandName.js.map +1 -1
  181. package/build/cjs/icons/Chevron.d.ts +1 -1
  182. package/build/cjs/icons/Chevron.js.map +1 -1
  183. package/build/cjs/icons/Facebook.d.ts +1 -1
  184. package/build/cjs/icons/Facebook.js.map +1 -1
  185. package/build/cjs/icons/Github.d.ts +1 -1
  186. package/build/cjs/icons/Github.js.map +1 -1
  187. package/build/cjs/icons/Linkedin.d.ts +1 -1
  188. package/build/cjs/icons/Linkedin.js.map +1 -1
  189. package/build/cjs/icons/NavigationArrow.d.ts +1 -1
  190. package/build/cjs/icons/NavigationArrow.js.map +1 -1
  191. package/build/cjs/icons/NavigationChevron.d.ts +1 -1
  192. package/build/cjs/icons/NavigationChevron.js.map +1 -1
  193. package/build/cjs/icons/Telegram.d.ts +1 -1
  194. package/build/cjs/icons/Telegram.js.map +1 -1
  195. package/build/cjs/icons/Twitter.d.ts +1 -1
  196. package/build/cjs/icons/Twitter.js.map +1 -1
  197. package/build/cjs/icons/Vk.d.ts +1 -1
  198. package/build/cjs/icons/Vk.js.map +1 -1
  199. package/build/cjs/internal-typings/global.d.ts +4 -2
  200. package/build/cjs/models/constructor-items/blocks.d.ts +42 -17
  201. package/build/cjs/models/constructor-items/blocks.js.map +1 -1
  202. package/build/cjs/models/constructor-items/common.d.ts +42 -4
  203. package/build/cjs/models/constructor-items/common.js.map +1 -1
  204. package/build/cjs/models/constructor-items/sub-blocks.d.ts +17 -6
  205. package/build/cjs/models/constructor-items/sub-blocks.js.map +1 -1
  206. package/build/cjs/models/navigation.d.ts +2 -1
  207. package/build/cjs/models/navigation.js.map +1 -1
  208. package/build/cjs/navigation/components/DesktopNavigation/DesktopNavigation.d.ts +1 -2
  209. package/build/cjs/navigation/components/DesktopNavigation/DesktopNavigation.js.map +1 -1
  210. package/build/cjs/navigation/components/Logo/Logo.d.ts +1 -2
  211. package/build/cjs/navigation/components/Logo/Logo.js.map +1 -1
  212. package/build/cjs/navigation/components/MobileMenuButton/MobileMenuButton.d.ts +1 -2
  213. package/build/cjs/navigation/components/MobileMenuButton/MobileMenuButton.js.map +1 -1
  214. package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.d.ts +1 -2
  215. package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.js.map +1 -1
  216. package/build/cjs/navigation/components/Navigation/Navigation.d.ts +2 -1
  217. package/build/cjs/navigation/components/Navigation/Navigation.js +5 -2
  218. package/build/cjs/navigation/components/Navigation/Navigation.js.map +1 -1
  219. package/build/cjs/navigation/components/NavigationItem/NavigationItem.d.ts +1 -2
  220. package/build/cjs/navigation/components/NavigationItem/NavigationItem.js.map +1 -1
  221. package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.d.ts +1 -2
  222. package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js.map +1 -1
  223. package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +1 -2
  224. package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js.map +1 -1
  225. package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +1 -2
  226. package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +12 -3
  227. package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js.map +1 -1
  228. package/build/cjs/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +3 -4
  229. package/build/cjs/navigation/components/NavigationList/NavigationList.d.ts +1 -2
  230. package/build/cjs/navigation/components/NavigationList/NavigationList.js.map +1 -1
  231. package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.d.ts +1 -2
  232. package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.js.map +1 -1
  233. package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -2
  234. package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js +1 -1
  235. package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js.map +1 -1
  236. package/build/cjs/navigation/components/SocialIcon/SocialIcon.d.ts +1 -2
  237. package/build/cjs/navigation/components/SocialIcon/SocialIcon.js.map +1 -1
  238. package/build/cjs/navigation/containers/Layout/Layout.d.ts +1 -1
  239. package/build/cjs/navigation/containers/Layout/Layout.js.map +1 -1
  240. package/build/cjs/navigation/hooks/useActiveNavItem.d.ts +8 -7
  241. package/build/cjs/navigation/utils.d.ts +4 -3
  242. package/build/cjs/node_modules/swiper/modules/a11y.css +9 -0
  243. package/build/cjs/node_modules/swiper/modules/autoplay.css +0 -0
  244. package/build/cjs/node_modules/swiper/modules/index.js +1309 -0
  245. package/build/cjs/node_modules/swiper/modules/pagination.css +181 -0
  246. package/build/cjs/node_modules/swiper/package.json +14 -0
  247. package/build/cjs/node_modules/swiper/swiper-react.d.ts +497 -0
  248. package/build/cjs/node_modules/swiper/swiper-react.js +4651 -0
  249. package/build/cjs/node_modules/swiper/swiper.css +229 -0
  250. package/build/cjs/node_modules/swiper/swiper.d.ts +5 -0
  251. package/build/cjs/node_modules/swiper/swiper.js +3822 -0
  252. package/build/cjs/node_modules/swiper/types/index.d.ts +6 -0
  253. package/build/cjs/node_modules/swiper/types/modules/index.d.ts +53 -0
  254. package/build/cjs/schema/constants.d.ts +62 -0
  255. package/build/cjs/schema/validators/common.d.ts +156 -1
  256. package/build/cjs/schema/validators/common.js +74 -1
  257. package/build/cjs/schema/validators/common.js.map +1 -1
  258. package/build/cjs/sub-blocks/BackgroundCard/BackgroundCard.js +2 -2
  259. package/build/cjs/sub-blocks/BackgroundCard/BackgroundCard.js.map +1 -1
  260. package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +16 -0
  261. package/build/cjs/sub-blocks/BackgroundCard/schema.js +1 -0
  262. package/build/cjs/sub-blocks/BackgroundCard/schema.js.map +1 -1
  263. package/build/cjs/sub-blocks/BasicCard/BasicCard.js +15 -2
  264. package/build/cjs/sub-blocks/BasicCard/BasicCard.js.map +1 -1
  265. package/build/cjs/sub-blocks/BasicCard/schema.d.ts +38 -0
  266. package/build/cjs/sub-blocks/BasicCard/schema.js +7 -0
  267. package/build/cjs/sub-blocks/BasicCard/schema.js.map +1 -1
  268. package/build/cjs/sub-blocks/Content/Content.css +16 -2
  269. package/build/cjs/sub-blocks/Content/Content.js +12 -3
  270. package/build/cjs/sub-blocks/Content/Content.js.map +1 -1
  271. package/build/cjs/sub-blocks/Content/schema.d.ts +134 -1
  272. package/build/cjs/sub-blocks/Content/schema.js +23 -2
  273. package/build/cjs/sub-blocks/Content/schema.js.map +1 -1
  274. package/build/cjs/sub-blocks/ImageCard/schema.d.ts +11 -0
  275. package/build/cjs/sub-blocks/LayoutItem/LayoutItem.js +2 -2
  276. package/build/cjs/sub-blocks/LayoutItem/LayoutItem.js.map +1 -1
  277. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +11 -0
  278. package/build/cjs/text-transform/common.d.ts +2 -1
  279. package/build/cjs/text-transform/common.js +2 -2
  280. package/build/cjs/text-transform/common.js.map +1 -1
  281. package/build/cjs/text-transform/config.js +16 -11
  282. package/build/cjs/text-transform/config.js.map +1 -1
  283. package/build/cjs/utils/breakpoint.d.ts +7 -0
  284. package/build/cjs/utils/breakpoint.js +12 -0
  285. package/build/cjs/utils/breakpoint.js.map +1 -0
  286. package/build/cjs/utils/icons.d.ts +3 -0
  287. package/build/cjs/utils/icons.js +16 -0
  288. package/build/cjs/utils/icons.js.map +1 -0
  289. package/build/cjs/utils/index.d.ts +2 -0
  290. package/build/cjs/utils/index.js +2 -0
  291. package/build/cjs/utils/index.js.map +1 -1
  292. package/build/esm/blocks/CardLayout/CardLayout.css +6 -0
  293. package/build/esm/blocks/CardLayout/CardLayout.d.ts +1 -1
  294. package/build/esm/blocks/CardLayout/CardLayout.js +3 -3
  295. package/build/esm/blocks/CardLayout/CardLayout.js.map +1 -1
  296. package/build/esm/blocks/Companies/schema.d.ts +1 -0
  297. package/build/esm/blocks/Companies/schema.js +2 -1
  298. package/build/esm/blocks/Companies/schema.js.map +1 -1
  299. package/build/esm/blocks/ContentLayout/ContentLayout.js +4 -2
  300. package/build/esm/blocks/ContentLayout/ContentLayout.js.map +1 -1
  301. package/build/esm/blocks/ContentLayout/schema.d.ts +11 -0
  302. package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.css +5 -5
  303. package/build/esm/blocks/FilterBlock/FilterBlock.d.ts +1 -2
  304. package/build/esm/blocks/FilterBlock/FilterBlock.js.map +1 -1
  305. package/build/esm/blocks/FoldableList/schema.d.ts +11 -0
  306. package/build/esm/blocks/Form/Form.css +5 -2
  307. package/build/esm/blocks/Form/Form.d.ts +2 -3
  308. package/build/esm/blocks/Form/Form.js +14 -11
  309. package/build/esm/blocks/Form/Form.js.map +1 -1
  310. package/build/esm/blocks/Form/schema.d.ts +12 -4
  311. package/build/esm/blocks/Form/schema.js +1 -4
  312. package/build/esm/blocks/Form/schema.js.map +1 -1
  313. package/build/esm/blocks/Form/utils.d.ts +3 -0
  314. package/build/esm/blocks/Form/utils.js +16 -0
  315. package/build/esm/blocks/Form/utils.js.map +1 -0
  316. package/build/esm/blocks/Header/Header.css +13 -0
  317. package/build/esm/blocks/Header/Header.d.ts +7 -1
  318. package/build/esm/blocks/Header/Header.js +11 -18
  319. package/build/esm/blocks/Header/Header.js.map +1 -1
  320. package/build/esm/blocks/Header/schema.d.ts +77 -0
  321. package/build/esm/blocks/Header/schema.js +12 -0
  322. package/build/esm/blocks/Header/schema.js.map +1 -1
  323. package/build/esm/blocks/HeaderSlider/schema.d.ts +29 -0
  324. package/build/esm/blocks/Info/schema.d.ts +22 -0
  325. package/build/esm/blocks/Map/Map.js.map +1 -1
  326. package/build/esm/blocks/Map/schema.d.ts +101 -0
  327. package/build/esm/blocks/Media/Media.js +1 -1
  328. package/build/esm/blocks/Media/Media.js.map +1 -1
  329. package/build/esm/blocks/Media/schema.d.ts +22 -0
  330. package/build/esm/blocks/Questions/QuestionBlockItem/QuestionBlockItem.js +3 -4
  331. package/build/esm/blocks/Questions/QuestionBlockItem/QuestionBlockItem.js.map +1 -1
  332. package/build/esm/blocks/Questions/Questions.js +32 -7
  333. package/build/esm/blocks/Questions/Questions.js.map +1 -1
  334. package/build/esm/blocks/Questions/schema.d.ts +11 -0
  335. package/build/esm/blocks/Share/Share.js +1 -3
  336. package/build/esm/blocks/Share/Share.js.map +1 -1
  337. package/build/esm/blocks/Slider/Slider.css +62 -1
  338. package/build/esm/blocks/Slider/Slider.d.ts +6 -4
  339. package/build/esm/blocks/Slider/Slider.js +7 -7
  340. package/build/esm/blocks/Slider/Slider.js.map +1 -1
  341. package/build/esm/blocks/Slider/useSlider.d.ts +2 -3
  342. package/build/esm/blocks/Slider/useSlider.js +3 -7
  343. package/build/esm/blocks/Slider/useSlider.js.map +1 -1
  344. package/build/esm/blocks/Slider/useSliderPagination.d.ts +1 -1
  345. package/build/esm/blocks/Slider/useSliderPagination.js.map +1 -1
  346. package/build/esm/blocks/Slider/utils.d.ts +1 -1
  347. package/build/esm/blocks/Slider/utils.js.map +1 -1
  348. package/build/esm/blocks/Table/Table.js +15 -3
  349. package/build/esm/blocks/Table/Table.js.map +1 -1
  350. package/build/esm/blocks/Tabs/TabContent/TabContent.js +7 -7
  351. package/build/esm/blocks/Tabs/TabContent/TabContent.js.map +1 -1
  352. package/build/esm/blocks/Tabs/Tabs.js +2 -2
  353. package/build/esm/blocks/Tabs/Tabs.js.map +1 -1
  354. package/build/esm/blocks/Tabs/schema.d.ts +11 -0
  355. package/build/esm/components/Button/Button.css +2 -7
  356. package/build/esm/components/Button/Button.js +29 -4
  357. package/build/esm/components/Button/Button.js.map +1 -1
  358. package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +1 -1
  359. package/build/esm/components/ButtonTabs/ButtonTabs.js.map +1 -1
  360. package/build/esm/components/Buttons/Buttons.css +3 -0
  361. package/build/esm/components/Buttons/Buttons.d.ts +1 -2
  362. package/build/esm/components/Buttons/Buttons.js +1 -1
  363. package/build/esm/components/Buttons/Buttons.js.map +1 -1
  364. package/build/esm/components/CardBase/CardBase.css +15 -0
  365. package/build/esm/components/CardBase/CardBase.d.ts +3 -5
  366. package/build/esm/components/CardBase/CardBase.js.map +1 -1
  367. package/build/esm/components/ContentIcon/ContentIcon.d.ts +8 -0
  368. package/build/esm/components/ContentIcon/ContentIcon.js +19 -0
  369. package/build/esm/components/ContentIcon/ContentIcon.js.map +1 -0
  370. package/build/esm/components/ContentLabels/ContentLabels.css +53 -0
  371. package/build/esm/components/ContentLabels/ContentLabels.d.ts +4 -0
  372. package/build/esm/components/ContentLabels/ContentLabels.js +14 -0
  373. package/build/esm/components/ContentLabels/ContentLabels.js.map +1 -0
  374. package/build/esm/components/ContentList/ContentList.js +3 -3
  375. package/build/esm/components/ContentList/ContentList.js.map +1 -1
  376. package/build/esm/components/DefaultVideo/DefaultVideo.js +23 -2
  377. package/build/esm/components/DefaultVideo/DefaultVideo.js.map +1 -1
  378. package/build/esm/components/FullscreenMedia/FullscreenMedia.css +3 -1
  379. package/build/esm/components/Icon/Icon.css +10 -0
  380. package/build/esm/components/Icon/Icon.d.ts +10 -0
  381. package/build/esm/components/Icon/Icon.js +22 -0
  382. package/build/esm/components/Icon/Icon.js.map +1 -0
  383. package/build/esm/components/IconWrapper/IconWrapper.css +16 -1
  384. package/build/esm/components/IconWrapper/IconWrapper.js +10 -6
  385. package/build/esm/components/IconWrapper/IconWrapper.js.map +1 -1
  386. package/build/esm/components/InnerForm/InnerForm.d.ts +1 -2
  387. package/build/esm/components/InnerForm/InnerForm.js.map +1 -1
  388. package/build/esm/components/Link/Link.d.ts +2 -2
  389. package/build/esm/components/Link/Link.js +2 -2
  390. package/build/esm/components/Link/Link.js.map +1 -1
  391. package/build/esm/components/Links/Links.d.ts +1 -1
  392. package/build/esm/components/Links/Links.js +1 -1
  393. package/build/esm/components/Links/Links.js.map +1 -1
  394. package/build/esm/components/Map/GoogleMap.d.ts +1 -2
  395. package/build/esm/components/Map/GoogleMap.js +19 -3
  396. package/build/esm/components/Map/GoogleMap.js.map +1 -1
  397. package/build/esm/components/Map/YMap/YMap.d.ts +4 -4
  398. package/build/esm/components/Map/YMap/YMap.js +46 -15
  399. package/build/esm/components/Map/YMap/YMap.js.map +1 -1
  400. package/build/esm/components/Map/YMap/YandexMap.d.ts +1 -2
  401. package/build/esm/components/Map/YMap/YandexMap.js +73 -7
  402. package/build/esm/components/Map/YMap/YandexMap.js.map +1 -1
  403. package/build/esm/components/Map/YMap/utils.d.ts +8 -0
  404. package/build/esm/components/Map/YMap/utils.js +90 -0
  405. package/build/esm/components/Map/YMap/utils.js.map +1 -0
  406. package/build/esm/components/Media/FullscreenVideo/FullscreenVideo.d.ts +1 -2
  407. package/build/esm/components/Media/FullscreenVideo/FullscreenVideo.js.map +1 -1
  408. package/build/esm/components/Media/Video/Video.js +2 -13
  409. package/build/esm/components/Media/Video/Video.js.map +1 -1
  410. package/build/esm/components/MediaBase/MediaBase.d.ts +1 -3
  411. package/build/esm/components/MediaBase/MediaBase.js.map +1 -1
  412. package/build/esm/components/ReactPlayer/ReactPlayer.d.ts +1 -2
  413. package/build/esm/components/ReactPlayer/ReactPlayer.js +19 -13
  414. package/build/esm/components/ReactPlayer/ReactPlayer.js.map +1 -1
  415. package/build/esm/components/Title/Title.d.ts +3 -2
  416. package/build/esm/components/Title/Title.js +2 -2
  417. package/build/esm/components/Title/Title.js.map +1 -1
  418. package/build/esm/components/UnpublishedLabel/UnpublishedLabel.js.map +1 -1
  419. package/build/esm/components/YandexForm/YandexForm.js +1 -1
  420. package/build/esm/components/YandexForm/YandexForm.js.map +1 -1
  421. package/build/esm/components/index.d.ts +2 -0
  422. package/build/esm/components/index.js +2 -0
  423. package/build/esm/components/index.js.map +1 -1
  424. package/build/esm/constructor-items.d.ts +7 -7
  425. package/build/esm/containers/PageConstructor/PageConstructor.css +0 -1
  426. package/build/esm/containers/PageConstructor/Provider.js +2 -0
  427. package/build/esm/containers/PageConstructor/Provider.js.map +1 -1
  428. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts +1 -2
  429. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js.map +1 -1
  430. package/build/esm/context/locationContext/locationContext.d.ts +1 -1
  431. package/build/esm/context/locationContext/locationContext.js.map +1 -1
  432. package/build/esm/context/mapsContext/mapsProvider.d.ts +1 -1
  433. package/build/esm/context/mapsContext/mapsProvider.js.map +1 -1
  434. package/build/esm/context/windowWidthContext/WindowWidthContext.d.ts +4 -0
  435. package/build/esm/context/windowWidthContext/WindowWidthContext.js +22 -0
  436. package/build/esm/context/windowWidthContext/WindowWidthContext.js.map +1 -0
  437. package/build/esm/context/windowWidthContext/index.d.ts +1 -0
  438. package/build/esm/context/windowWidthContext/index.js +2 -0
  439. package/build/esm/context/windowWidthContext/index.js.map +1 -0
  440. package/build/esm/editor/components/AddBlock/AddBlock.d.ts +1 -2
  441. package/build/esm/editor/components/AddBlock/AddBlock.js.map +1 -1
  442. package/build/esm/editor/components/Layout/Layout.d.ts +2 -6
  443. package/build/esm/editor/components/Layout/Layout.js.map +1 -1
  444. package/build/esm/editor/data/previews/default-preview.d.ts +1 -1
  445. package/build/esm/editor/data/previews/default-preview.js.map +1 -1
  446. package/build/esm/editor/data/previews/header-block.d.ts +1 -1
  447. package/build/esm/editor/data/previews/header-block.js.map +1 -1
  448. package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.d.ts +2 -3
  449. package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +1 -1
  450. package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js.map +1 -1
  451. package/build/esm/editor/icons/Tablet.d.ts +1 -1
  452. package/build/esm/editor/icons/Tablet.js.map +1 -1
  453. package/build/esm/grid/Grid/Grid.d.ts +1 -1
  454. package/build/esm/grid/Grid/Grid.js +1 -1
  455. package/build/esm/grid/Grid/Grid.js.map +1 -1
  456. package/build/esm/grid/Row/Row.d.ts +1 -1
  457. package/build/esm/grid/Row/Row.js.map +1 -1
  458. package/build/esm/hooks/useDeviceValue.d.ts +2 -0
  459. package/build/esm/hooks/useDeviceValue.js +29 -0
  460. package/build/esm/hooks/useDeviceValue.js.map +1 -0
  461. package/build/esm/icons/BrandIconDark.d.ts +1 -1
  462. package/build/esm/icons/BrandIconDark.js.map +1 -1
  463. package/build/esm/icons/BrandIconLight.d.ts +1 -1
  464. package/build/esm/icons/BrandIconLight.js.map +1 -1
  465. package/build/esm/icons/BrandName.d.ts +1 -1
  466. package/build/esm/icons/BrandName.js.map +1 -1
  467. package/build/esm/icons/Chevron.d.ts +1 -1
  468. package/build/esm/icons/Chevron.js.map +1 -1
  469. package/build/esm/icons/Facebook.d.ts +1 -1
  470. package/build/esm/icons/Facebook.js.map +1 -1
  471. package/build/esm/icons/Github.d.ts +1 -1
  472. package/build/esm/icons/Github.js.map +1 -1
  473. package/build/esm/icons/Linkedin.d.ts +1 -1
  474. package/build/esm/icons/Linkedin.js.map +1 -1
  475. package/build/esm/icons/NavigationArrow.d.ts +1 -1
  476. package/build/esm/icons/NavigationArrow.js.map +1 -1
  477. package/build/esm/icons/NavigationChevron.d.ts +1 -1
  478. package/build/esm/icons/NavigationChevron.js.map +1 -1
  479. package/build/esm/icons/Telegram.d.ts +1 -1
  480. package/build/esm/icons/Telegram.js.map +1 -1
  481. package/build/esm/icons/Twitter.d.ts +1 -1
  482. package/build/esm/icons/Twitter.js.map +1 -1
  483. package/build/esm/icons/Vk.d.ts +1 -1
  484. package/build/esm/icons/Vk.js.map +1 -1
  485. package/build/esm/internal-typings/global.d.ts +4 -2
  486. package/build/esm/models/constructor-items/blocks.d.ts +42 -17
  487. package/build/esm/models/constructor-items/blocks.js.map +1 -1
  488. package/build/esm/models/constructor-items/common.d.ts +42 -4
  489. package/build/esm/models/constructor-items/common.js.map +1 -1
  490. package/build/esm/models/constructor-items/sub-blocks.d.ts +17 -6
  491. package/build/esm/models/constructor-items/sub-blocks.js.map +1 -1
  492. package/build/esm/models/navigation.d.ts +2 -1
  493. package/build/esm/models/navigation.js.map +1 -1
  494. package/build/esm/navigation/components/DesktopNavigation/DesktopNavigation.d.ts +1 -2
  495. package/build/esm/navigation/components/DesktopNavigation/DesktopNavigation.js.map +1 -1
  496. package/build/esm/navigation/components/Logo/Logo.d.ts +1 -2
  497. package/build/esm/navigation/components/Logo/Logo.js.map +1 -1
  498. package/build/esm/navigation/components/MobileMenuButton/MobileMenuButton.d.ts +1 -2
  499. package/build/esm/navigation/components/MobileMenuButton/MobileMenuButton.js.map +1 -1
  500. package/build/esm/navigation/components/MobileNavigation/MobileNavigation.d.ts +1 -2
  501. package/build/esm/navigation/components/MobileNavigation/MobileNavigation.js.map +1 -1
  502. package/build/esm/navigation/components/Navigation/Navigation.d.ts +2 -1
  503. package/build/esm/navigation/components/Navigation/Navigation.js +5 -2
  504. package/build/esm/navigation/components/Navigation/Navigation.js.map +1 -1
  505. package/build/esm/navigation/components/NavigationItem/NavigationItem.d.ts +1 -2
  506. package/build/esm/navigation/components/NavigationItem/NavigationItem.js.map +1 -1
  507. package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.d.ts +1 -2
  508. package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js.map +1 -1
  509. package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +1 -2
  510. package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js.map +1 -1
  511. package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +1 -2
  512. package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +12 -3
  513. package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js.map +1 -1
  514. package/build/esm/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +3 -4
  515. package/build/esm/navigation/components/NavigationList/NavigationList.d.ts +1 -2
  516. package/build/esm/navigation/components/NavigationList/NavigationList.js.map +1 -1
  517. package/build/esm/navigation/components/NavigationListItem/NavigationListItem.d.ts +1 -2
  518. package/build/esm/navigation/components/NavigationListItem/NavigationListItem.js.map +1 -1
  519. package/build/esm/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -2
  520. package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js +1 -1
  521. package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js.map +1 -1
  522. package/build/esm/navigation/components/SocialIcon/SocialIcon.d.ts +1 -2
  523. package/build/esm/navigation/components/SocialIcon/SocialIcon.js.map +1 -1
  524. package/build/esm/navigation/containers/Layout/Layout.d.ts +1 -1
  525. package/build/esm/navigation/containers/Layout/Layout.js.map +1 -1
  526. package/build/esm/navigation/hooks/useActiveNavItem.d.ts +8 -7
  527. package/build/esm/navigation/utils.d.ts +4 -3
  528. package/build/esm/schema/constants.d.ts +62 -0
  529. package/build/esm/schema/validators/common.d.ts +156 -1
  530. package/build/esm/schema/validators/common.js +73 -2
  531. package/build/esm/schema/validators/common.js.map +1 -1
  532. package/build/esm/sub-blocks/BackgroundCard/BackgroundCard.js +2 -2
  533. package/build/esm/sub-blocks/BackgroundCard/BackgroundCard.js.map +1 -1
  534. package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +16 -0
  535. package/build/esm/sub-blocks/BackgroundCard/schema.js +2 -1
  536. package/build/esm/sub-blocks/BackgroundCard/schema.js.map +1 -1
  537. package/build/esm/sub-blocks/BasicCard/BasicCard.js +15 -2
  538. package/build/esm/sub-blocks/BasicCard/BasicCard.js.map +1 -1
  539. package/build/esm/sub-blocks/BasicCard/schema.d.ts +38 -0
  540. package/build/esm/sub-blocks/BasicCard/schema.js +8 -1
  541. package/build/esm/sub-blocks/BasicCard/schema.js.map +1 -1
  542. package/build/esm/sub-blocks/Content/Content.css +16 -2
  543. package/build/esm/sub-blocks/Content/Content.js +11 -3
  544. package/build/esm/sub-blocks/Content/Content.js.map +1 -1
  545. package/build/esm/sub-blocks/Content/schema.d.ts +134 -1
  546. package/build/esm/sub-blocks/Content/schema.js +23 -2
  547. package/build/esm/sub-blocks/Content/schema.js.map +1 -1
  548. package/build/esm/sub-blocks/ImageCard/schema.d.ts +11 -0
  549. package/build/esm/sub-blocks/LayoutItem/LayoutItem.js +2 -2
  550. package/build/esm/sub-blocks/LayoutItem/LayoutItem.js.map +1 -1
  551. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +11 -0
  552. package/build/esm/text-transform/common.d.ts +2 -1
  553. package/build/esm/text-transform/common.js +2 -2
  554. package/build/esm/text-transform/common.js.map +1 -1
  555. package/build/esm/text-transform/config.js +16 -11
  556. package/build/esm/text-transform/config.js.map +1 -1
  557. package/build/esm/utils/breakpoint.d.ts +7 -0
  558. package/build/esm/utils/breakpoint.js +9 -0
  559. package/build/esm/utils/breakpoint.js.map +1 -0
  560. package/build/esm/utils/icons.d.ts +3 -0
  561. package/build/esm/utils/icons.js +11 -0
  562. package/build/esm/utils/icons.js.map +1 -0
  563. package/build/esm/utils/index.d.ts +2 -0
  564. package/build/esm/utils/index.js +2 -0
  565. package/build/esm/utils/index.js.map +1 -1
  566. package/package.json +7 -5
  567. package/schema/index.js +1 -1
  568. package/server/models/constructor-items/blocks.d.ts +42 -17
  569. package/server/models/constructor-items/common.d.ts +42 -4
  570. package/server/models/constructor-items/sub-blocks.d.ts +17 -6
  571. package/server/models/navigation.d.ts +2 -1
  572. package/server/text-transform/common.d.ts +2 -1
  573. package/server/text-transform/common.js +2 -2
  574. package/server/text-transform/config.js +16 -11
  575. package/server/utils/breakpoint.d.ts +7 -0
  576. package/server/utils/breakpoint.js +11 -0
  577. package/server/utils/icons.d.ts +3 -0
  578. package/server/utils/icons.js +47 -0
  579. package/server/utils/index.d.ts +2 -0
  580. package/server/utils/index.js +2 -0
  581. package/styles/mixins.scss +20 -0
  582. package/styles/root.scss +0 -1
  583. package/styles/storybook/index.scss +1 -0
  584. package/build/cjs/blocks/Questions/models.d.ts +0 -11
  585. package/build/cjs/blocks/Questions/models.js +0 -15
  586. package/build/cjs/blocks/Questions/models.js.map +0 -1
  587. package/build/cjs/components/ContentList/ContentListItemIcon.d.ts +0 -7
  588. package/build/cjs/components/ContentList/ContentListItemIcon.js +0 -23
  589. package/build/cjs/components/ContentList/ContentListItemIcon.js.map +0 -1
  590. package/build/esm/blocks/Questions/models.d.ts +0 -11
  591. package/build/esm/blocks/Questions/models.js +0 -12
  592. package/build/esm/blocks/Questions/models.js.map +0 -1
  593. package/build/esm/components/ContentList/ContentListItemIcon.d.ts +0 -7
  594. package/build/esm/components/ContentList/ContentListItemIcon.js +0 -20
  595. package/build/esm/components/ContentList/ContentListItemIcon.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sourceRoot":"../../../../src","sources":["components/Link/Link.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAC,aAAa,EAAC,6CAAoC;AAC1D,OAAO,EAAC,eAAe,EAAC,+CAAsC;AAC9D,OAAO,EAAC,YAAY,EAAC,6BAAoB;AACzC,OAAO,EAEH,iBAAiB,GAKpB,8BAAqB;AAEtB,OAAO,EAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAC,6BAAoB;AAC5E,OAAO,QAAQ,gCAA6B;AAC5C,OAAO,QAAQ,gCAA6B;AAE5C,OAAO,YAAY,CAAC;AAEpB,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,QAAQ,CAAC;AAIjC,SAAS,YAAY,CAAC,IAAc;IAChC,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,GAAG;YACJ,OAAO,EAAE,CAAC;QACd,KAAK,GAAG,CAAC;QACT,KAAK,IAAI;YACL,OAAO,EAAE,CAAC;QACd,KAAK,GAAG;YACJ,OAAO,EAAE,CAAC;QACd;YACI,OAAO,EAAE,CAAC;IAClB,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,EAAC,IAAI,EAAE,KAAK,EAAsC;IACnE,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,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,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {ChevronRight} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\n\nimport {LocaleContext} from '../../context/localeContext';\nimport {LocationContext} from '../../context/locationContext';\nimport {useAnalytics} from '../../hooks';\nimport {\n ClassNameProps,\n DefaultEventNames,\n LinkProps,\n LinkTheme,\n Tabbable,\n TextSize,\n} from '../../models';\nimport {QAProps} from '../../models/common';\nimport {block, getLinkProps, getQaAttrubutes, setUrlTld} from '../../utils';\nimport BackLink from '../BackLink/BackLink';\nimport FileLink from '../FileLink/FileLink';\n\nimport './Link.scss';\n\nconst b = block('link-block');\nconst WORD_JOINER_SYM = '\\u200b';\n\nexport type LinkFullProps = LinkProps & ClassNameProps & Tabbable & QAProps;\n\nfunction getArrowSize(size: TextSize) {\n switch (size) {\n case 'l':\n return 20;\n case 'm':\n case 'sm':\n return 18;\n case 's':\n return 14;\n default:\n return 14;\n }\n}\n\nfunction getTextSize({size, theme}: {size?: TextSize; theme: LinkTheme}) {\n if (!size) {\n return theme === 'back' ? 'l' : 'm';\n }\n\n if (size === 'sm') {\n return 'm';\n }\n\n return size;\n}\n\nconst LinkBlock = (props: React.PropsWithChildren<LinkFullProps>) => {\n const {\n text,\n url,\n arrow,\n analyticsEvents,\n theme = 'file-link',\n colorTheme = 'light',\n textSize = 'm',\n className,\n target,\n children,\n tabIndex,\n qa,\n urlTitle,\n extraProps,\n } = props;\n const qaAttributes = getQaAttrubutes(qa, ['normal']);\n\n const handleAnalytics = useAnalytics(DefaultEventNames.Link, url);\n const {hostname} = React.useContext(LocationContext);\n const {tld} = React.useContext(LocaleContext);\n const href = setUrlTld(props.url, tld);\n\n const onClick = () => {\n handleAnalytics(analyticsEvents);\n };\n\n const getLinkByType = () => {\n switch (theme) {\n case 'back':\n return (\n <BackLink\n title={children || text}\n url={href}\n onClick={onClick}\n tabIndex={tabIndex}\n extraProps={extraProps}\n />\n );\n case 'file-link':\n case 'underline':\n return (\n <FileLink\n text={children || text}\n href={href}\n type=\"horizontal\"\n textSize={textSize}\n onClick={onClick}\n tabIndex={tabIndex}\n extraProps={extraProps}\n />\n );\n case 'normal': {\n const linkProps = getLinkProps(url, hostname, target);\n const content = children || text;\n\n return (\n <a\n className={b('link', {theme: colorTheme, 'has-arrow': arrow})}\n href={href}\n onClick={onClick}\n tabIndex={tabIndex}\n title={urlTitle}\n {...linkProps}\n data-qa={qaAttributes.normal}\n {...extraProps}\n >\n {arrow ? (\n <React.Fragment>\n <span className={b('content')}>{content}</span>\n {WORD_JOINER_SYM}\n <Icon\n className={b('arrow')}\n data={ChevronRight}\n size={getArrowSize(textSize)}\n />\n </React.Fragment>\n ) : (\n content\n )}\n </a>\n );\n }\n default:\n return null;\n }\n };\n return (\n <div className={b({size: getTextSize({size: textSize, theme})}, className)}>\n {getLinkByType()}\n </div>\n );\n};\n\nexport default LinkBlock;\n"]}
1
+ {"version":3,"file":"Link.js","sourceRoot":"../../../../src","sources":["components/Link/Link.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAC,aAAa,EAAC,6CAAoC;AAC1D,OAAO,EAAC,eAAe,EAAC,+CAAsC;AAC9D,OAAO,EAAC,YAAY,EAAC,6BAAoB;AACzC,OAAO,EAEH,iBAAiB,GAKpB,8BAAqB;AAEtB,OAAO,EAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAC,6BAAoB;AAC5E,OAAO,QAAQ,gCAA6B;AAC5C,OAAO,QAAQ,gCAA6B;AAE5C,OAAO,YAAY,CAAC;AAEpB,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,QAAQ,CAAC;AA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E,CAAC,CAAC,OAAO,CAAC,EACrB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,GAC9B,IACW,CACpB,CAAC,CAAC,CAAC,CACA,OAAO,CACV,GACD,CACP,CAAC;YACN,CAAC;YACD;gBACI,OAAO,IAAI,CAAC;QACpB,CAAC;IACL,CAAC,CAAC;IACF,OAAO,CACH,cAAK,SAAS,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,WAAW,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE,SAAS,CAAC,YACrE,aAAa,EAAE,GACd,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {ChevronRight} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\n\nimport {LocaleContext} from '../../context/localeContext';\nimport {LocationContext} from '../../context/locationContext';\nimport {useAnalytics} from '../../hooks';\nimport {\n ClassNameProps,\n DefaultEventNames,\n LinkProps,\n LinkTheme,\n Tabbable,\n TextSize,\n} from '../../models';\nimport {QAProps} from '../../models/common';\nimport {block, getLinkProps, getQaAttrubutes, setUrlTld} from '../../utils';\nimport BackLink from '../BackLink/BackLink';\nimport FileLink from '../FileLink/FileLink';\n\nimport './Link.scss';\n\nconst b = block('link-block');\nconst WORD_JOINER_SYM = '\\u200b';\n\nexport type LinkFullProps = LinkProps & ClassNameProps & Tabbable & QAProps;\n\nfunction getArrowSize(size: TextSize) {\n switch (size) {\n case 'l':\n return 20;\n case 'm':\n case 'sm':\n return 18;\n case 's':\n return 14;\n default:\n return 14;\n }\n}\n\nfunction getTextSize({size, theme}: {size?: TextSize; theme: LinkTheme}) {\n if (!size) {\n return theme === 'back' ? 'l' : 'm';\n }\n\n if (size === 'sm') {\n return 'm';\n }\n\n return size;\n}\n\nconst Link = (props: React.PropsWithChildren<LinkFullProps>) => {\n const {\n text,\n url,\n arrow,\n analyticsEvents,\n theme = 'file-link',\n colorTheme = 'light',\n textSize = 'm',\n className,\n target,\n children,\n tabIndex,\n qa,\n urlTitle,\n extraProps,\n } = props;\n const qaAttributes = getQaAttrubutes(qa, ['normal']);\n\n const handleAnalytics = useAnalytics(DefaultEventNames.Link, url);\n const {hostname} = React.useContext(LocationContext);\n const {tld} = React.useContext(LocaleContext);\n const href = setUrlTld(props.url, tld);\n\n const onClick = () => {\n handleAnalytics(analyticsEvents);\n };\n\n const getLinkByType = () => {\n switch (theme) {\n case 'back':\n return (\n <BackLink\n title={children || text}\n url={href}\n onClick={onClick}\n tabIndex={tabIndex}\n extraProps={extraProps}\n />\n );\n case 'file-link':\n case 'underline':\n return (\n <FileLink\n text={children || text}\n href={href}\n type=\"horizontal\"\n textSize={textSize}\n onClick={onClick}\n tabIndex={tabIndex}\n extraProps={extraProps}\n />\n );\n case 'normal': {\n const linkProps = getLinkProps(url, hostname, target);\n const content = children || text;\n\n return (\n <a\n className={b('link', {theme: colorTheme, 'has-arrow': arrow})}\n href={href}\n onClick={onClick}\n tabIndex={tabIndex}\n title={urlTitle}\n {...linkProps}\n data-qa={qaAttributes.normal}\n {...extraProps}\n >\n {arrow ? (\n <React.Fragment>\n <span className={b('content')}>{content}</span>\n {WORD_JOINER_SYM}\n <Icon\n className={b('arrow')}\n data={ChevronRight}\n size={getArrowSize(textSize)}\n />\n </React.Fragment>\n ) : (\n content\n )}\n </a>\n );\n }\n default:\n return null;\n }\n };\n return (\n <div className={b({size: getTextSize({size: textSize, theme})}, className)}>\n {getLinkByType()}\n </div>\n );\n};\n\nexport default Link;\n"]}
@@ -9,5 +9,5 @@ type LinksProps = {
9
9
  qa?: string;
10
10
  linkQa?: string;
11
11
  };
12
- declare const Links: React.FC<LinksProps>;
12
+ declare const Links: ({ className, titleId, links, size, qa, linkQa, }: React.PropsWithChildren<LinksProps>) => import("react/jsx-runtime").JSX.Element | null;
13
13
  export default Links;
@@ -13,7 +13,7 @@ function getLinkSize(size) {
13
13
  return 'l';
14
14
  }
15
15
  }
16
- const Links = ({ className, titleId, links, size = 's', qa, linkQa }) => links ? (_jsx("div", { className: b({ size }, className), "data-qa": qa, children: links?.map((link) => (_createElement(Link, { className: b('link'), ...link, textSize: getLinkSize(size), key: link.url, qa: linkQa, extraProps: {
16
+ const Links = ({ className, titleId, links, size = 's', qa, linkQa, }) => links ? (_jsx("div", { className: b({ size }, className), "data-qa": qa, children: links?.map((link) => (_createElement(Link, { className: b('link'), ...link, textSize: getLinkSize(size), key: link.url, qa: linkQa, extraProps: {
17
17
  'aria-describedby': link.urlTitle ? undefined : titleId,
18
18
  ...link.extraProps,
19
19
  } }))) })) : null;
@@ -1 +1 @@
1
- {"version":3,"file":"Links.js","sourceRoot":"../../../../src","sources":["components/Links/Links.tsx"],"names":[],"mappings":";;AAGA,OAAO,EAAC,KAAK,EAAC,6BAAoB;AAClC,OAAO,IAAI,wBAAqB;AAEhC,OAAO,aAAa,CAAC;AAErB,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;AAEzB,SAAS,WAAW,CAAC,IAAiB;IAClC,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,GAAG;YACJ,OAAO,GAAG,CAAC;QACf,KAAK,GAAG,CAAC;QACT;YACI,OAAO,GAAG,CAAC;IACnB,CAAC;AACL,CAAC;AAWD,MAAM,KAAK,GAAyB,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,EAAC,EAAE,EAAE,CACxF,KAAK,CAAC,CAAC,CAAC,CACJ,cAAK,SAAS,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,EAAE,SAAS,CAAC,aAAW,EAAE,YAC5C,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAClB,eAAC,IAAI,IACD,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAChB,IAAI,EACR,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,EAC3B,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,EAAE,EAAE,MAAM,EACV,UAAU,EAAE;YACR,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;YACvD,GAAG,IAAI,CAAC,UAAU;SACrB,GACH,CACL,CAAC,GACA,CACT,CAAC,CAAC,CAAC,IAAI,CAAC;AAEb,eAAe,KAAK,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {ContentSize, LinkProps} from '../../models';\nimport {block} from '../../utils';\nimport Link from '../Link/Link';\n\nimport './Links.scss';\n\nconst b = block('links');\n\nfunction getLinkSize(size: ContentSize) {\n switch (size) {\n case 's':\n return 'm';\n case 'l':\n default:\n return 'l';\n }\n}\n\ntype LinksProps = {\n className?: string;\n titleId?: string;\n links?: LinkProps[];\n size?: ContentSize;\n qa?: string;\n linkQa?: string;\n};\n\nconst Links: React.FC<LinksProps> = ({className, titleId, links, size = 's', qa, linkQa}) =>\n links ? (\n <div className={b({size}, className)} data-qa={qa}>\n {links?.map((link) => (\n <Link\n className={b('link')}\n {...link}\n textSize={getLinkSize(size)}\n key={link.url}\n qa={linkQa}\n extraProps={{\n 'aria-describedby': link.urlTitle ? undefined : titleId,\n ...link.extraProps,\n }}\n />\n ))}\n </div>\n ) : null;\n\nexport default Links;\n"]}
1
+ {"version":3,"file":"Links.js","sourceRoot":"../../../../src","sources":["components/Links/Links.tsx"],"names":[],"mappings":";;AAGA,OAAO,EAAC,KAAK,EAAC,6BAAoB;AAClC,OAAO,IAAI,wBAAqB;AAEhC,OAAO,aAAa,CAAC;AAErB,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;AAEzB,SAAS,WAAW,CAAC,IAAiB;IAClC,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,GAAG;YACJ,OAAO,GAAG,CAAC;QACf,KAAK,GAAG,CAAC;QACT;YACI,OAAO,GAAG,CAAC;IACnB,CAAC;AACL,CAAC;AAWD,MAAM,KAAK,GAAG,CAAC,EACX,SAAS,EACT,OAAO,EACP,KAAK,EACL,IAAI,GAAG,GAAG,EACV,EAAE,EACF,MAAM,GAC4B,EAAE,EAAE,CACtC,KAAK,CAAC,CAAC,CAAC,CACJ,cAAK,SAAS,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,EAAE,SAAS,CAAC,aAAW,EAAE,YAC5C,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAClB,eAAC,IAAI,IACD,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAChB,IAAI,EACR,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,EAC3B,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,EAAE,EAAE,MAAM,EACV,UAAU,EAAE;YACR,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;YACvD,GAAG,IAAI,CAAC,UAAU;SACrB,GACH,CACL,CAAC,GACA,CACT,CAAC,CAAC,CAAC,IAAI,CAAC;AAEb,eAAe,KAAK,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {ContentSize, LinkProps} from '../../models';\nimport {block} from '../../utils';\nimport Link from '../Link/Link';\n\nimport './Links.scss';\n\nconst b = block('links');\n\nfunction getLinkSize(size: ContentSize) {\n switch (size) {\n case 's':\n return 'm';\n case 'l':\n default:\n return 'l';\n }\n}\n\ntype LinksProps = {\n className?: string;\n titleId?: string;\n links?: LinkProps[];\n size?: ContentSize;\n qa?: string;\n linkQa?: string;\n};\n\nconst Links = ({\n className,\n titleId,\n links,\n size = 's',\n qa,\n linkQa,\n}: React.PropsWithChildren<LinksProps>) =>\n links ? (\n <div className={b({size}, className)} data-qa={qa}>\n {links?.map((link) => (\n <Link\n className={b('link')}\n {...link}\n textSize={getLinkSize(size)}\n key={link.url}\n qa={linkQa}\n extraProps={{\n 'aria-describedby': link.urlTitle ? undefined : titleId,\n ...link.extraProps,\n }}\n />\n ))}\n </div>\n ) : null;\n\nexport default Links;\n"]}
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { GMapProps } from "../../models/index.js";
3
- declare const GoogleMap: React.FC<GMapProps>;
2
+ declare const GoogleMap: (props: GMapProps) => import("react/jsx-runtime").JSX.Element | null;
4
3
  export default GoogleMap;
@@ -13,7 +13,7 @@ function getScriptSrc(params) {
13
13
  return `${scriptSrc}?key=${apiKey}&language=${lang}${zoom ? '&zoom=' + zoom : ''}&q=${encodeURI(address)}`;
14
14
  }
15
15
  const GoogleMap = (props) => {
16
- const { address, zoom, className } = props;
16
+ const { address, zoom, className, forceAspectRatio = true } = props;
17
17
  const { apiKey, scriptSrc } = React.useContext(MapsContext);
18
18
  const { lang = Lang.Ru } = React.useContext(LocaleContext);
19
19
  const isMobile = React.useContext(MobileContext);
@@ -21,6 +21,9 @@ const GoogleMap = (props) => {
21
21
  const ref = React.useRef(null);
22
22
  const src = React.useMemo(() => getScriptSrc({ apiKey, scriptSrc, address, lang, zoom }), [apiKey, scriptSrc, address, lang, zoom]);
23
23
  React.useEffect(() => {
24
+ if (!forceAspectRatio) {
25
+ return;
26
+ }
24
27
  const updateSize = debounce(() => {
25
28
  if (ref.current) {
26
29
  setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));
@@ -28,16 +31,29 @@ const GoogleMap = (props) => {
28
31
  }, 100);
29
32
  updateSize();
30
33
  window.addEventListener('resize', updateSize, { passive: true });
34
+ // eslint-disable-next-line consistent-return
31
35
  return () => {
32
36
  window.removeEventListener('resize', updateSize);
33
37
  };
34
- }, [isMobile]);
38
+ }, [forceAspectRatio, isMobile]);
39
+ // Generate Schema.org JSON-LD for Google Map
40
+ const mapMicrodataScript = React.useMemo(() => {
41
+ if (!address) {
42
+ return null;
43
+ }
44
+ const json = JSON.stringify({
45
+ '@context': 'https://schema.org',
46
+ '@type': 'Place',
47
+ address,
48
+ });
49
+ return _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json } });
50
+ }, [address]);
35
51
  if (!apiKey || !address) {
36
52
  return null;
37
53
  }
38
54
  return (_jsx("iframe", { className: b(null, className), ref: ref, style: {
39
55
  height,
40
- }, title: "Google Map", loading: "lazy", allowFullScreen: true, referrerPolicy: "no-referrer-when-downgrade", src: src }));
56
+ }, title: "Google Map", loading: "lazy", allowFullScreen: true, referrerPolicy: "no-referrer-when-downgrade", src: src, children: mapMicrodataScript }));
41
57
  };
42
58
  export default GoogleMap;
43
59
  //# sourceMappingURL=GoogleMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMap.js","sourceRoot":"../../../../src","sources":["components/Map/GoogleMap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,QAAQ,2BAAwB;AAEvC,OAAO,EAAC,aAAa,EAAC,qDAAkD;AACxE,OAAO,EAAC,WAAW,EAAC,iDAA8C;AAClE,OAAO,EAAC,aAAa,EAAC,6CAAoC;AAE1D,OAAO,EAAC,KAAK,EAAC,6BAAoB;AAElC,OAAO,EAAC,YAAY,EAAC,qBAAkB;AAEvC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;AAUvB,SAAS,YAAY,CAAC,MAA2B;IAC7C,MAAM,EAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAC,GAAG,MAAM,CAAC;IAExD,OAAO,GAAG,SAAS,QAAQ,MAAM,aAAa,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,SAAS,CAC3F,OAAO,CACV,EAAE,CAAC;AACR,CAAC;AAED,MAAM,SAAS,GAAwB,CAAC,KAAK,EAAE,EAAE;IAC7C,MAAM,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,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,QAAQ,CAAC,CAAC,CAAC;IAEf,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CACH,iBACI,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAC7B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE;YACH,MAAM;SACT,EACD,KAAK,EAAC,YAAY,EAClB,OAAO,EAAC,MAAM,EACd,eAAe,QACf,cAAc,EAAC,4BAA4B,EAC3C,GAAG,EAAE,GAAG,GACV,CACL,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {Lang} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\n\nimport {LocaleContext} from '../../context/localeContext/localeContext';\nimport {MapsContext} from '../../context/mapsContext/mapsContext';\nimport {MobileContext} from '../../context/mobileContext';\nimport {GMapProps} from '../../models';\nimport {block} from '../../utils';\n\nimport {getMapHeight} from './helpers';\n\nconst b = block('map');\n\ninterface GoogleMapLinkParams {\n apiKey: string;\n scriptSrc: string;\n address: string;\n lang: `${Lang}`;\n zoom?: number;\n}\n\nfunction getScriptSrc(params: GoogleMapLinkParams) {\n const {apiKey, scriptSrc, address, lang, zoom} = params;\n\n return `${scriptSrc}?key=${apiKey}&language=${lang}${zoom ? '&zoom=' + zoom : ''}&q=${encodeURI(\n address,\n )}`;\n}\n\nconst GoogleMap: React.FC<GMapProps> = (props) => {\n const {address, zoom, className} = props;\n const {apiKey, scriptSrc} = React.useContext(MapsContext);\n const {lang = Lang.Ru} = React.useContext(LocaleContext);\n const isMobile = React.useContext(MobileContext);\n\n const [height, setHeight] = React.useState<number | undefined>(undefined);\n const ref = React.useRef<HTMLIFrameElement>(null);\n const src = React.useMemo(\n () => getScriptSrc({apiKey, scriptSrc, address, lang, zoom}),\n [apiKey, scriptSrc, address, lang, zoom],\n );\n\n React.useEffect(() => {\n const updateSize = debounce(() => {\n if (ref.current) {\n setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));\n }\n }, 100);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [isMobile]);\n\n if (!apiKey || !address) {\n return null;\n }\n\n return (\n <iframe\n className={b(null, className)}\n ref={ref}\n style={{\n height,\n }}\n title=\"Google Map\"\n loading=\"lazy\"\n allowFullScreen\n referrerPolicy=\"no-referrer-when-downgrade\"\n src={src}\n />\n );\n};\n\nexport default GoogleMap;\n"]}
1
+ {"version":3,"file":"GoogleMap.js","sourceRoot":"../../../../src","sources":["components/Map/GoogleMap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,QAAQ,2BAAwB;AAEvC,OAAO,EAAC,aAAa,EAAC,qDAAkD;AACxE,OAAO,EAAC,WAAW,EAAC,iDAA8C;AAClE,OAAO,EAAC,aAAa,EAAC,6CAAoC;AAE1D,OAAO,EAAC,KAAK,EAAC,6BAAoB;AAElC,OAAO,EAAC,YAAY,EAAC,qBAAkB;AAEvC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;AAUvB,SAAS,YAAY,CAAC,MAA2B;IAC7C,MAAM,EAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAC,GAAG,MAAM,CAAC;IAExD,OAAO,GAAG,SAAS,QAAQ,MAAM,aAAa,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,SAAS,CAC3F,OAAO,CACV,EAAE,CAAC;AACR,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,KAAgB,EAAE,EAAE;IACnC,MAAM,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,GAA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AAC,mBAAmB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEjC,6CAA6C;IAC7C,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YACxB,UAAU,EAAE,oBAAoB;YAChC,OAAO,EAAE,OAAO;YAChB,OAAO;SACV,CAAC,CAAC;QAEH,OAAO,iBAAQ,IAAI,EAAC,qBAAqB,EAAC,uBAAuB,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,GAAI,CAAC;IAC1F,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CACH,iBACI,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAC7B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE;YACH,MAAM;SACT,EACD,KAAK,EAAC,YAAY,EAClB,OAAO,EAAC,MAAM,EACd,eAAe,QACf,cAAc,EAAC,4BAA4B,EAC3C,GAAG,EAAE,GAAG,YAEP,kBAAkB,GACd,CACZ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {Lang} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\n\nimport {LocaleContext} from '../../context/localeContext/localeContext';\nimport {MapsContext} from '../../context/mapsContext/mapsContext';\nimport {MobileContext} from '../../context/mobileContext';\nimport {GMapProps} from '../../models';\nimport {block} from '../../utils';\n\nimport {getMapHeight} from './helpers';\n\nconst b = block('map');\n\ninterface GoogleMapLinkParams {\n apiKey: string;\n scriptSrc: string;\n address: string;\n lang: `${Lang}`;\n zoom?: number;\n}\n\nfunction getScriptSrc(params: GoogleMapLinkParams) {\n const {apiKey, scriptSrc, address, lang, zoom} = params;\n\n return `${scriptSrc}?key=${apiKey}&language=${lang}${zoom ? '&zoom=' + zoom : ''}&q=${encodeURI(\n address,\n )}`;\n}\n\nconst GoogleMap = (props: GMapProps) => {\n const {address, zoom, className, forceAspectRatio = true} = props;\n const {apiKey, scriptSrc} = React.useContext(MapsContext);\n const {lang = Lang.Ru} = React.useContext(LocaleContext);\n const isMobile = React.useContext(MobileContext);\n\n const [height, setHeight] = React.useState<number | undefined>(undefined);\n const ref = React.useRef<HTMLIFrameElement>(null);\n const src = React.useMemo(\n () => getScriptSrc({apiKey, scriptSrc, address, lang, zoom}),\n [apiKey, scriptSrc, address, lang, zoom],\n );\n\n React.useEffect(() => {\n if (!forceAspectRatio) {\n return;\n }\n\n const updateSize = debounce(() => {\n if (ref.current) {\n setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));\n }\n }, 100);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [forceAspectRatio, isMobile]);\n\n // Generate Schema.org JSON-LD for Google Map\n const mapMicrodataScript = React.useMemo(() => {\n if (!address) {\n return null;\n }\n\n const json = JSON.stringify({\n '@context': 'https://schema.org',\n '@type': 'Place',\n address,\n });\n\n return <script type=\"application/ld+json\" dangerouslySetInnerHTML={{__html: json}} />;\n }, [address]);\n\n if (!apiKey || !address) {\n return null;\n }\n\n return (\n <iframe\n className={b(null, className)}\n ref={ref}\n style={{\n height,\n }}\n title=\"Google Map\"\n loading=\"lazy\"\n allowFullScreen\n referrerPolicy=\"no-referrer-when-downgrade\"\n src={src}\n >\n {mapMicrodataScript}\n </iframe>\n );\n};\n\nexport default GoogleMap;\n"]}
@@ -1,13 +1,13 @@
1
- import { YMapMarker, YMapProps } from "../../../models/index.js";
2
- type PlacemarksProps = Pick<YMapProps, 'zoom' | 'markers'>;
1
+ import { YMapMarkerPrivate, YMapProps } from "../../../models/index.js";
2
+ type PlacemarksProps = Pick<YMapProps, 'zoom' | 'markers' | 'areaMargin'>;
3
3
  export declare class YMap {
4
4
  private ymap;
5
5
  private mapRef;
6
6
  private coords;
7
7
  constructor(ymap: Ymaps.Map, mapRef: HTMLDivElement | null);
8
8
  showPlacemarks(props: PlacemarksProps): Promise<void>;
9
- findAddress(marker: YMapMarker): Promise<void>;
10
- findCoordinate(marker: YMapMarker): void;
9
+ findAddress(marker: YMapMarkerPrivate): Promise<void>;
10
+ findCoordinate(marker: YMapMarkerPrivate): void;
11
11
  private drawPlaceMarkStyle;
12
12
  private recalcZoomAndCenter;
13
13
  private clearOldPlacemarks;
@@ -1,3 +1,4 @@
1
+ import { calculateMapParamsWithMarginAndZoom, parseMargin } from "./utils.js";
1
2
  var GeoObjectTypes;
2
3
  (function (GeoObjectTypes) {
3
4
  GeoObjectTypes["Properties"] = "properties";
@@ -8,9 +9,17 @@ const DEFAULT_PLACEMARKS_COLOR = '#dc534b';
8
9
  const DEFAULT_PLACEMARKS_PRESET = 'islands#dotIcon';
9
10
  const DEFAULT_MAP_CONTROL_BUTTON_HEIGHT = 30;
10
11
  const geoObjectPropsAndOptions = {
12
+ cursor: GeoObjectTypes.Options,
11
13
  iconCaption: GeoObjectTypes.Properties,
12
14
  iconContent: GeoObjectTypes.Properties,
13
15
  iconColor: GeoObjectTypes.Options,
16
+ iconImageHref: GeoObjectTypes.Options,
17
+ iconImageSize: GeoObjectTypes.Options,
18
+ iconImageOffset: GeoObjectTypes.Options,
19
+ iconImageClipRect: GeoObjectTypes.Options,
20
+ iconLayout: GeoObjectTypes.Options,
21
+ iconShape: GeoObjectTypes.Options,
22
+ interactivityModel: GeoObjectTypes.Options,
14
23
  preset: GeoObjectTypes.Options,
15
24
  };
16
25
  export class YMap {
@@ -57,40 +66,62 @@ export class YMap {
57
66
  if (!preset.includes('Stretchy') && !iconColor) {
58
67
  localIconColor = DEFAULT_PLACEMARKS_COLOR;
59
68
  }
60
- Object.entries({ ...marker.label, iconColor: localIconColor, preset }).forEach(([key, value]) => {
69
+ Object.entries({
70
+ ...marker.label,
71
+ iconColor: localIconColor,
72
+ preset,
73
+ }).forEach(([key, value]) => {
61
74
  const geoObjectParamType = geoObjectPropsAndOptions[key];
62
75
  if (value && geoObjectParamType) {
63
76
  geoObject[geoObjectParamType].set(key, value);
64
77
  }
65
78
  });
66
79
  }
80
+ // eslint-disable-next-line complexity
67
81
  recalcZoomAndCenter(props) {
68
82
  const coordsLength = this.coords.length;
69
- const { zoom = 0 } = props;
83
+ const { zoom = 0, areaMargin } = props;
70
84
  if (!coordsLength) {
71
85
  return;
72
86
  }
73
- let leftBottom = [Infinity, Infinity], rightTop = [-Infinity, -Infinity];
74
- this.coords.forEach((point) => {
75
- leftBottom = [Math.min(leftBottom[0], point[0]), Math.min(leftBottom[1], point[1])];
76
- rightTop = [Math.max(rightTop[0], point[0]), Math.max(rightTop[1], point[1])];
77
- });
87
+ const utils = window.ymaps.util.bounds;
88
+ const [leftTop, rightBottom] = utils.fromPoints(this.coords);
78
89
  let newMapParams = {
79
90
  zoom,
80
91
  center: [],
81
92
  };
82
- if (zoom) {
83
- // compute only the center
84
- newMapParams.center = window.ymaps.util.bounds.getCenter([leftBottom, rightTop]);
85
- }
86
- else {
87
- newMapParams = window.ymaps.util.bounds.getCenterAndZoom([leftBottom, rightTop], [this.mapRef?.clientWidth, this.mapRef?.clientHeight], undefined, { margin: DEFAULT_MAP_CONTROL_BUTTON_HEIGHT });
93
+ const parsedAreaMargin = areaMargin
94
+ ? parseMargin(areaMargin)
95
+ : [0, 0, 0, 0];
96
+ const hasZoom = Boolean(zoom);
97
+ const hasAreaMargin = parsedAreaMargin.some(Boolean);
98
+ const containerSize = [
99
+ this.mapRef?.clientWidth ?? 0,
100
+ this.mapRef?.clientHeight ?? 0,
101
+ ];
102
+ switch (true) {
103
+ case hasAreaMargin && hasZoom:
104
+ // calculate center and zoom in accordace with current zoom and margin
105
+ newMapParams = calculateMapParamsWithMarginAndZoom([leftTop, rightBottom], zoom, parsedAreaMargin, containerSize);
106
+ break;
107
+ case hasAreaMargin:
108
+ // calculate center and zoom with custom margin
109
+ newMapParams = utils.getCenterAndZoom([leftTop, rightBottom], containerSize, undefined, { margin: areaMargin, preciseZoom: true });
110
+ break;
111
+ case hasZoom:
112
+ // calculate only center
113
+ newMapParams.center = utils.getCenter([leftTop, rightBottom]);
114
+ break;
115
+ default:
116
+ // calculate center and zoom with default margin
117
+ newMapParams = utils.getCenterAndZoom([leftTop, rightBottom], containerSize, undefined, { margin: DEFAULT_MAP_CONTROL_BUTTON_HEIGHT });
88
118
  }
89
119
  this.ymap.setCenter(newMapParams.center);
90
120
  // Use default zoom for one placemark
91
- if (coordsLength > 1 && !zoom) {
92
- this.ymap.setZoom(newMapParams.zoom);
121
+ if (coordsLength <= 1 && !hasAreaMargin && hasZoom) {
122
+ return;
93
123
  }
124
+ this.ymap.setZoom(newMapParams.zoom);
94
125
  }
95
126
  clearOldPlacemarks() {
96
127
  if (this.coords.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"YMap.js","sourceRoot":"../../../../../src","sources":["components/Map/YMap/YMap.ts"],"names":[],"mappings":"AAGA,IAAK,cAGJ;AAHD,WAAK,cAAc;IACf,2CAAyB,CAAA;IACzB,qCAAmB,CAAA;AACvB,CAAC,EAHI,cAAc,KAAd,cAAc,QAGlB;AAED,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAC3C,mGAAmG;AACnG,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AACpD,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C,MAAM,wBAAwB,GAAG;IAC7B,WAAW,EAAE,cAAc,CAAC,UAAU;IACtC,WAAW,EAAE,cAAc,CAAC,UAAU;IACtC,SAAS,EAAE,cAAc,CAAC,OAAO;IACjC,MAAM,EAAE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ACT,EAAC,MAAM,EAAE,iCAAiC,EAAC,CAC9C,CAAC;QACN,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAEzC,qCAAqC;QACrC,IAAI,YAAY,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;IACL,CAAC;IAEO,kBAAkB;QACtB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;CACJ","sourcesContent":["import {YMapMarker, YMapMarkerLabel, YMapProps} from '../../../models';\nimport {Coordinate} from '../../../models/constructor-items/common';\n\nenum GeoObjectTypes {\n Properties = 'properties',\n Options = 'options',\n}\n\nconst DEFAULT_PLACEMARKS_COLOR = '#dc534b';\n// presetStorage: https://yandex.com/dev/maps/jsapi/doc/2.1/ref/reference/option.presetStorage.html\nconst DEFAULT_PLACEMARKS_PRESET = 'islands#dotIcon';\nconst DEFAULT_MAP_CONTROL_BUTTON_HEIGHT = 30;\n\nconst geoObjectPropsAndOptions = {\n iconCaption: GeoObjectTypes.Properties,\n iconContent: GeoObjectTypes.Properties,\n iconColor: GeoObjectTypes.Options,\n preset: GeoObjectTypes.Options,\n};\n\ntype PlacemarksProps = Pick<YMapProps, 'zoom' | 'markers'>;\n\nexport class YMap {\n private ymap: Ymaps.Map;\n private mapRef: HTMLDivElement | null;\n private coords: Coordinate[] = [];\n\n constructor(ymap: Ymaps.Map, mapRef: HTMLDivElement | null) {\n this.ymap = ymap;\n this.mapRef = mapRef;\n }\n\n async showPlacemarks(props: PlacemarksProps) {\n this.clearOldPlacemarks();\n\n for (const marker of props.markers) {\n if (marker.address) {\n await this.findAddress(marker);\n } else if (marker.coordinate) {\n this.findCoordinate(marker);\n }\n }\n\n this.recalcZoomAndCenter(props);\n }\n\n async findAddress(marker: YMapMarker) {\n try {\n const res = await window.ymaps.geocode(marker.address, {results: 1});\n const geoObject = res.geoObjects.get(0);\n const coordinate = geoObject.geometry.getCoordinates();\n\n this.coords.push(coordinate);\n\n this.drawPlaceMarkStyle(geoObject, marker);\n\n this.ymap.geoObjects.add(geoObject);\n } catch {} // If error - placemark will not be displayed\n }\n\n findCoordinate(marker: YMapMarker) {\n const geoObject = new window.ymaps.Placemark(marker.coordinate, {});\n\n this.coords.push(marker.coordinate as Coordinate);\n this.drawPlaceMarkStyle(geoObject, marker);\n this.ymap.geoObjects.add(geoObject);\n }\n\n private drawPlaceMarkStyle(geoObject: Ymaps.GeoObject, marker: YMapMarker) {\n const {iconColor, preset = DEFAULT_PLACEMARKS_PRESET} = marker.label || {};\n let localIconColor: string | undefined = iconColor;\n\n // You can set the preset option together with the iconColor option only if it not a 'Stretchy' preset\n if (!preset.includes('Stretchy') && !iconColor) {\n localIconColor = DEFAULT_PLACEMARKS_COLOR;\n }\n\n Object.entries({...marker.label, iconColor: localIconColor, preset}).forEach(\n ([key, value]) => {\n const geoObjectParamType: GeoObjectTypes | undefined =\n geoObjectPropsAndOptions[key as keyof YMapMarkerLabel];\n\n if (value && geoObjectParamType) {\n geoObject[geoObjectParamType].set(key, value);\n }\n },\n );\n }\n\n private recalcZoomAndCenter(props: PlacemarksProps) {\n const coordsLength = this.coords.length;\n const {zoom = 0} = props;\n\n if (!coordsLength) {\n return;\n }\n\n let leftBottom = [Infinity, Infinity],\n rightTop = [-Infinity, -Infinity];\n\n this.coords.forEach((point) => {\n leftBottom = [Math.min(leftBottom[0], point[0]), Math.min(leftBottom[1], point[1])];\n rightTop = [Math.max(rightTop[0], point[0]), Math.max(rightTop[1], point[1])];\n });\n\n let newMapParams = {\n zoom,\n center: [],\n };\n\n if (zoom) {\n // compute only the center\n newMapParams.center = window.ymaps.util.bounds.getCenter([leftBottom, rightTop]);\n } else {\n newMapParams = window.ymaps.util.bounds.getCenterAndZoom(\n [leftBottom, rightTop],\n [this.mapRef?.clientWidth, this.mapRef?.clientHeight],\n undefined,\n {margin: DEFAULT_MAP_CONTROL_BUTTON_HEIGHT},\n );\n }\n\n this.ymap.setCenter(newMapParams.center);\n\n // Use default zoom for one placemark\n if (coordsLength > 1 && !zoom) {\n this.ymap.setZoom(newMapParams.zoom);\n }\n }\n\n private clearOldPlacemarks() {\n if (this.coords.length === 0) {\n return;\n }\n\n this.ymap.geoObjects.removeAll();\n this.coords = [];\n }\n}\n"]}
1
+ {"version":3,"file":"YMap.js","sourceRoot":"../../../../../src","sources":["components/Map/YMap/YMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,mCAAmC,EAAE,WAAW,EAAC,mBAAgB;AAEvF,IAAK,cAGJ;AAHD,WAAK,cAAc;IACf,2CAAyB,CAAA;IACzB,qCAAmB,CAAA;AACvB,CAAC,EAHI,cAAc,KAAd,cAAc,QAGlB;AAED,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAC3C,mGAAmG;AACnG,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AACpD,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C,MAAM,wBAAwB,GAAyD;IACnF,MAAM,EAAE,cAAc,CAAC,OAAO;IAC9B,WAAW,EAAE,cAAc,CAAC,UAAU;IACtC,WAAW,EAAE,cAAc,CAAC,UAAU;IACtC,SAAS,EAAE,cAAc,CAAC,OAAO;IACjC,aAAa,EAAE,cAAc,CAAC,OAAO;IACrC,aAAa,EAAE,cAAc,CAAC,OAAO;IACrC,eAAe,EAAE,cAAc,CAAC,OAAO;IACvC,iBAAiB,EAAE,cAAc,CAAC,OAAO;IACzC,UAAU,EAAE,cAAc,CAAC,OAAO;IAClC,SAAS,EAAE,cAAc,CAAC,OAAO;IACjC,kBAAkB,EAAE,cAAc,CAAC,OAAO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KAAK,OAAO;gBACR,wBAAwB;gBACxB,YAAY,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;gBAC9D,MAAM;YACV;gBACI,gDAAgD;gBAChD,YAAY,GAAG,KAAK,CAAC,gBAAgB,CACjC,CAAC,OAAO,EAAE,WAAW,CAAC,EACtB,aAAa,EACb,SAAS,EACT,EAAC,MAAM,EAAE,iCAAiC,EAAC,CAC9C,CAAC;QACV,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAEzC,qCAAqC;QACrC,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,OAAO,EAAE,CAAC;YACjD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAEO,kBAAkB;QACtB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;CACJ","sourcesContent":["import {YMapMarkerLabelPrivate, YMapMarkerPrivate, YMapProps} from '../../../models';\nimport {Coordinate} from '../../../models/constructor-items/common';\n\nimport {ParsedMargin, calculateMapParamsWithMarginAndZoom, parseMargin} from './utils';\n\nenum GeoObjectTypes {\n Properties = 'properties',\n Options = 'options',\n}\n\nconst DEFAULT_PLACEMARKS_COLOR = '#dc534b';\n// presetStorage: https://yandex.com/dev/maps/jsapi/doc/2.1/ref/reference/option.presetStorage.html\nconst DEFAULT_PLACEMARKS_PRESET = 'islands#dotIcon';\nconst DEFAULT_MAP_CONTROL_BUTTON_HEIGHT = 30;\n\nconst geoObjectPropsAndOptions: Record<keyof YMapMarkerLabelPrivate, GeoObjectTypes> = {\n cursor: GeoObjectTypes.Options,\n iconCaption: GeoObjectTypes.Properties,\n iconContent: GeoObjectTypes.Properties,\n iconColor: GeoObjectTypes.Options,\n iconImageHref: GeoObjectTypes.Options,\n iconImageSize: GeoObjectTypes.Options,\n iconImageOffset: GeoObjectTypes.Options,\n iconImageClipRect: GeoObjectTypes.Options,\n iconLayout: GeoObjectTypes.Options,\n iconShape: GeoObjectTypes.Options,\n interactivityModel: GeoObjectTypes.Options,\n preset: GeoObjectTypes.Options,\n};\n\ntype PlacemarksProps = Pick<YMapProps, 'zoom' | 'markers' | 'areaMargin'>;\n\nexport class YMap {\n private ymap: Ymaps.Map;\n private mapRef: HTMLDivElement | null;\n private coords: Coordinate[] = [];\n\n constructor(ymap: Ymaps.Map, mapRef: HTMLDivElement | null) {\n this.ymap = ymap;\n this.mapRef = mapRef;\n }\n\n async showPlacemarks(props: PlacemarksProps) {\n this.clearOldPlacemarks();\n\n for (const marker of props.markers) {\n if (marker.address) {\n await this.findAddress(marker);\n } else if (marker.coordinate) {\n this.findCoordinate(marker);\n }\n }\n\n this.recalcZoomAndCenter(props);\n }\n\n async findAddress(marker: YMapMarkerPrivate) {\n try {\n const res = await window.ymaps.geocode(marker.address, {results: 1});\n const geoObject = res.geoObjects.get(0);\n const coordinate = geoObject.geometry.getCoordinates();\n\n this.coords.push(coordinate);\n\n this.drawPlaceMarkStyle(geoObject, marker);\n\n this.ymap.geoObjects.add(geoObject);\n } catch {} // If error - placemark will not be displayed\n }\n\n findCoordinate(marker: YMapMarkerPrivate) {\n const geoObject = new window.ymaps.Placemark(marker.coordinate, {});\n\n this.coords.push(marker.coordinate as Coordinate);\n this.drawPlaceMarkStyle(geoObject, marker);\n this.ymap.geoObjects.add(geoObject);\n }\n\n private drawPlaceMarkStyle(geoObject: Ymaps.GeoObject, marker: YMapMarkerPrivate) {\n const {iconColor, preset = DEFAULT_PLACEMARKS_PRESET} = marker.label || {};\n let localIconColor: string | undefined = iconColor;\n\n // You can set the preset option together with the iconColor option only if it not a 'Stretchy' preset\n if (!preset.includes('Stretchy') && !iconColor) {\n localIconColor = DEFAULT_PLACEMARKS_COLOR;\n }\n\n Object.entries({\n ...marker.label,\n iconColor: localIconColor,\n preset,\n }).forEach(([key, value]) => {\n const geoObjectParamType: GeoObjectTypes | undefined =\n geoObjectPropsAndOptions[key as keyof YMapMarkerLabelPrivate];\n\n if (value && geoObjectParamType) {\n geoObject[geoObjectParamType].set(key, value);\n }\n });\n }\n\n // eslint-disable-next-line complexity\n private recalcZoomAndCenter(props: PlacemarksProps) {\n const coordsLength = this.coords.length;\n const {zoom = 0, areaMargin} = props;\n\n if (!coordsLength) {\n return;\n }\n\n const utils = window.ymaps.util.bounds;\n\n const [leftTop, rightBottom] = utils.fromPoints(this.coords);\n\n let newMapParams = {\n zoom,\n center: [],\n };\n\n const parsedAreaMargin = areaMargin\n ? parseMargin(areaMargin)\n : ([0, 0, 0, 0] as ParsedMargin);\n\n const hasZoom = Boolean(zoom);\n const hasAreaMargin = parsedAreaMargin.some(Boolean);\n const containerSize = [\n this.mapRef?.clientWidth ?? 0,\n this.mapRef?.clientHeight ?? 0,\n ] as Coordinate;\n\n switch (true) {\n case hasAreaMargin && hasZoom:\n // calculate center and zoom in accordace with current zoom and margin\n newMapParams = calculateMapParamsWithMarginAndZoom(\n [leftTop, rightBottom],\n zoom,\n parsedAreaMargin,\n containerSize,\n );\n break;\n case hasAreaMargin:\n // calculate center and zoom with custom margin\n newMapParams = utils.getCenterAndZoom(\n [leftTop, rightBottom],\n containerSize,\n undefined,\n {margin: areaMargin, preciseZoom: true},\n );\n break;\n case hasZoom:\n // calculate only center\n newMapParams.center = utils.getCenter([leftTop, rightBottom]);\n break;\n default:\n // calculate center and zoom with default margin\n newMapParams = utils.getCenterAndZoom(\n [leftTop, rightBottom],\n containerSize,\n undefined,\n {margin: DEFAULT_MAP_CONTROL_BUTTON_HEIGHT},\n );\n }\n\n this.ymap.setCenter(newMapParams.center);\n\n // Use default zoom for one placemark\n if (coordsLength <= 1 && !hasAreaMargin && hasZoom) {\n return;\n }\n\n this.ymap.setZoom(newMapParams.zoom);\n }\n\n private clearOldPlacemarks() {\n if (this.coords.length === 0) {\n return;\n }\n\n this.ymap.geoObjects.removeAll();\n this.coords = [];\n }\n}\n"]}
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { YMapProps } from "../../../models/index.js";
3
- declare const YandexMap: React.FC<YMapProps>;
2
+ declare const YandexMap: (props: YMapProps) => import("react/jsx-runtime").JSX.Element | null;
4
3
  export default YandexMap;
@@ -18,8 +18,31 @@ const DEFAULT_ZOOM = 9;
18
18
  // We use this init center to create a map
19
19
  // The real center of the map will be calculated later, using the coordinates of the markers
20
20
  const INITIAL_CENTER = [0, 0];
21
+ const BALLOON_DISABLING_MARKER_OPTIONS = {
22
+ cursor: 'drag',
23
+ interactivityModel: 'default#silent',
24
+ };
25
+ // Helper function to convert YMapMarker to Schema.org Place object
26
+ const markerToSchemaPlace = (marker) => {
27
+ return {
28
+ '@type': 'Place',
29
+ address: marker.address
30
+ ? {
31
+ '@type': 'Text',
32
+ '@value': marker.address,
33
+ }
34
+ : undefined,
35
+ geo: marker.coordinate && marker.coordinate.length === 2
36
+ ? {
37
+ '@type': 'GeoCoordinates',
38
+ latitude: marker.coordinate[0],
39
+ longitude: marker.coordinate[1],
40
+ }
41
+ : undefined,
42
+ };
43
+ };
21
44
  const YandexMap = (props) => {
22
- const { markers, zoom, id, className } = props;
45
+ const { markers, zoom, id, disableControls = false, disableBalloons = false, areaMargin, copyrightPosition, className, forceAspectRatio = true, } = props;
23
46
  const { apiKey, scriptSrc, nonce } = React.useContext(MapsContext);
24
47
  const isMobile = React.useContext(MobileContext);
25
48
  const { lang = 'ru' } = React.useContext(LocaleContext);
@@ -41,12 +64,32 @@ const YandexMap = (props) => {
41
64
  setYmaps(new YMap(new window.ymaps.Map(containerId, {
42
65
  center: INITIAL_CENTER,
43
66
  zoom: zoom || DEFAULT_ZOOM,
44
- }, { autoFitToViewport: 'always' }), ref.current));
67
+ controls: disableControls ? [] : undefined,
68
+ }, {
69
+ autoFitToViewport: 'always',
70
+ suppressMapOpenBlock: disableControls,
71
+ yandexMapDisablePoiInteractivity: disableControls,
72
+ copyrightPosition,
73
+ }), ref.current));
45
74
  });
46
75
  setLoading(false);
47
76
  })();
48
- }, [apiKey, lang, scriptSrc, containerId, zoom, nonce, attemptsIndex, setLoading]);
77
+ }, [
78
+ apiKey,
79
+ lang,
80
+ scriptSrc,
81
+ containerId,
82
+ zoom,
83
+ nonce,
84
+ attemptsIndex,
85
+ setLoading,
86
+ disableControls,
87
+ copyrightPosition,
88
+ ]);
49
89
  React.useEffect(() => {
90
+ if (!forceAspectRatio) {
91
+ return;
92
+ }
50
93
  const updateSize = debounce(() => {
51
94
  if (ref.current) {
52
95
  setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));
@@ -54,23 +97,46 @@ const YandexMap = (props) => {
54
97
  }, 100);
55
98
  updateSize();
56
99
  window.addEventListener('resize', updateSize, { passive: true });
100
+ // eslint-disable-next-line consistent-return
57
101
  return () => {
58
102
  window.removeEventListener('resize', updateSize);
59
103
  };
60
- }, [markers, ymap, setYmaps, isMobile]);
104
+ }, [isMobile, forceAspectRatio]);
61
105
  React.useEffect(() => {
62
106
  if (ymap) {
63
107
  // show with computed center and placemarks
64
108
  const showPlacemarks = async () => {
65
- await ymap.showPlacemarks({ markers, zoom });
109
+ const privateMarkers = disableBalloons
110
+ ? markers.map(({ label, ...marker }) => ({
111
+ ...marker,
112
+ label: { ...label, ...BALLOON_DISABLING_MARKER_OPTIONS },
113
+ }))
114
+ : markers;
115
+ await ymap.showPlacemarks({ markers: privateMarkers, zoom, areaMargin });
66
116
  setReady(true);
67
117
  };
68
118
  showPlacemarks();
69
119
  }
70
- });
120
+ }, [ymap, markers, zoom, disableBalloons, areaMargin]);
121
+ const mapMicrodataScript = React.useMemo(() => {
122
+ if (!markers.length) {
123
+ return null;
124
+ }
125
+ const places = markers
126
+ .filter((marker) => marker.address || marker.coordinate)
127
+ .map(markerToSchemaPlace);
128
+ if (places.length === 0) {
129
+ return null;
130
+ }
131
+ const json = JSON.stringify({
132
+ '@context': 'https://schema.org',
133
+ '@graph': places,
134
+ });
135
+ return _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json } });
136
+ }, [markers]);
71
137
  if (!markers)
72
138
  return null;
73
- return (_jsx(ErrorWrapper, { isError: YMapsApiLoader.status === MapApiStatus.Error, text: i18n('map-load-error'), buttonText: i18n('map-try-again'), handler: onTryAgain, className: b('wrapper'), children: _jsxs("div", { className: b('wrapper'), children: [_jsx("div", { id: containerId, className: b({ hidden: !ready }, className), ref: ref, style: { height } }), loading ? _jsx(Spin, { size: "xl", className: b('spinner') }) : null] }) }));
139
+ return (_jsx(ErrorWrapper, { isError: YMapsApiLoader.status === MapApiStatus.Error, text: i18n('map-load-error'), buttonText: i18n('map-try-again'), handler: onTryAgain, className: b('wrapper'), children: _jsxs("div", { className: b('wrapper'), children: [mapMicrodataScript, _jsx("div", { id: containerId, className: b({ hidden: !ready }, className), ref: ref, style: { height } }), loading ? _jsx(Spin, { size: "xl", className: b('spinner') }) : null] }) }));
74
140
  };
75
141
  export default YandexMap;
76
142
  //# sourceMappingURL=YandexMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"YandexMap.js","sourceRoot":"../../../../../src","sources":["components/Map/YMap/YandexMap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,QAAQ,2BAAwB;AAEvC,OAAO,EAAC,aAAa,EAAC,wDAAqD;AAC3E,OAAO,EAAC,WAAW,EAAC,oDAAiD;AACrE,OAAO,EAAC,aAAa,EAAC,gDAAuC;AAE7D,OAAO,EAAC,KAAK,EAAC,gCAAuB;AACrC,OAAO,YAAY,2CAAwC;AAC3D,OAAO,E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,MAAM,EAAC,GACjB,EACD,OAAO,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,GAAI,CAAC,CAAC,CAAC,IAAI,IAC3D,GACK,CAClB,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {Spin} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\n\nimport {LocaleContext} from '../../../context/localeContext/localeContext';\nimport {MapsContext} from '../../../context/mapsContext/mapsContext';\nimport {MobileContext} from '../../../context/mobileContext';\nimport {YMapProps} from '../../../models';\nimport {block} from '../../../utils';\nimport ErrorWrapper from '../../ErrorWrapper/ErrorWrapper';\nimport {getMapHeight} from '../helpers';\n\nimport {YMap} from './YMap';\nimport {MapApiStatus, YMapsApiLoader} from './YandexMapApiLoader';\nimport {i18n} from './i18n';\n\nconst b = block('map');\nconst DEFAULT_CONTAINER_ID = 'ymap';\nconst DEFAULT_ZOOM = 9;\n// Center - is a required parameter for creating a new map\n// We use this init center to create a map\n// The real center of the map will be calculated later, using the coordinates of the markers\nconst INITIAL_CENTER = [0, 0];\n\nconst YandexMap: React.FC<YMapProps> = (props) => {\n const {markers, zoom, id, className} = props;\n const {apiKey, scriptSrc, nonce} = React.useContext(MapsContext);\n const isMobile = React.useContext(MobileContext);\n\n const {lang = 'ru'} = React.useContext(LocaleContext);\n const containerId = `${DEFAULT_CONTAINER_ID}-${id}`;\n\n const [ymap, setYmaps] = React.useState<YMap | null>(null);\n const [height, setHeight] = React.useState<number | undefined>(undefined);\n const ref = React.useRef<HTMLDivElement>(null);\n\n const [loading, setLoading] = React.useState<boolean>(false);\n const [ready, setReady] = React.useState<boolean>(false);\n const [attemptsIndex, setAttemptsIndex] = React.useState<number>(0);\n const onTryAgain = React.useCallback(() => {\n setAttemptsIndex(attemptsIndex + 1);\n }, [attemptsIndex]);\n\n React.useEffect(() => {\n (async function () {\n setLoading(true);\n\n await YMapsApiLoader.loadApi(apiKey, scriptSrc, lang, nonce);\n\n window.ymaps?.ready(() => {\n setYmaps(\n new YMap(\n new window.ymaps.Map(\n containerId,\n {\n center: INITIAL_CENTER,\n zoom: zoom || DEFAULT_ZOOM,\n },\n {autoFitToViewport: 'always'},\n ),\n ref.current,\n ),\n );\n });\n\n setLoading(false);\n })();\n }, [apiKey, lang, scriptSrc, containerId, zoom, nonce, attemptsIndex, setLoading]);\n\n React.useEffect(() => {\n const updateSize = debounce(() => {\n if (ref.current) {\n setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));\n }\n }, 100);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [markers, ymap, setYmaps, isMobile]);\n\n React.useEffect(() => {\n if (ymap) {\n // show with computed center and placemarks\n const showPlacemarks = async () => {\n await ymap.showPlacemarks({markers, zoom});\n\n setReady(true);\n };\n\n showPlacemarks();\n }\n });\n\n if (!markers) return null;\n\n return (\n <ErrorWrapper\n isError={YMapsApiLoader.status === MapApiStatus.Error}\n text={i18n('map-load-error')}\n buttonText={i18n('map-try-again')}\n handler={onTryAgain}\n className={b('wrapper')}\n >\n <div className={b('wrapper')}>\n {/* hidden - to show the map after calculating the center */}\n <div\n id={containerId}\n className={b({hidden: !ready}, className)}\n ref={ref}\n style={{height}}\n />\n {loading ? <Spin size=\"xl\" className={b('spinner')} /> : null}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default YandexMap;\n"]}
1
+ {"version":3,"file":"YandexMap.js","sourceRoot":"../../../../../src","sources":["components/Map/YMap/YandexMap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,QAAQ,2BAAwB;AAEvC,OAAO,EAAC,aAAa,EAAC,wDAAqD;AAC3E,OAAO,EAAC,WAA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aACvD,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAE9B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YACxB,UAAU,EAAE,oBAAoB;YAChC,QAAQ,EAAE,MAAM;SACnB,CAAC,CAAC;QAEH,OAAO,iBAAQ,IAAI,EAAC,qBAAqB,EAAC,uBAAuB,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,GAAI,CAAC;IAC1F,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,OAAO,CACH,KAAC,YAAY,IACT,OAAO,EAAE,cAAc,CAAC,MAAM,KAAK,YAAY,CAAC,KAAK,EACrD,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAC5B,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,YAEvB,eAAK,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,aACvB,kBAAkB,EAEnB,cACI,EAAE,EAAE,WAAW,EACf,SAAS,EAAE,CAAC,CAAC,EAAC,MAAM,EAAE,CAAC,KAAK,EAAC,EAAE,SAAS,CAAC,EACzC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,EAAC,MAAM,EAAC,GACjB,EACD,OAAO,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,GAAI,CAAC,CAAC,CAAC,IAAI,IAC3D,GACK,CAClB,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {Spin} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\n\nimport {LocaleContext} from '../../../context/localeContext/localeContext';\nimport {MapsContext} from '../../../context/mapsContext/mapsContext';\nimport {MobileContext} from '../../../context/mobileContext';\nimport {YMapMarker, YMapMarkerLabelPrivate, YMapMarkerPrivate, YMapProps} from '../../../models';\nimport {block} from '../../../utils';\nimport ErrorWrapper from '../../ErrorWrapper/ErrorWrapper';\nimport {getMapHeight} from '../helpers';\n\nimport {YMap} from './YMap';\nimport {MapApiStatus, YMapsApiLoader} from './YandexMapApiLoader';\nimport {i18n} from './i18n';\n\nconst b = block('map');\nconst DEFAULT_CONTAINER_ID = 'ymap';\nconst DEFAULT_ZOOM = 9;\n// Center - is a required parameter for creating a new map\n// We use this init center to create a map\n// The real center of the map will be calculated later, using the coordinates of the markers\nconst INITIAL_CENTER = [0, 0];\n\nconst BALLOON_DISABLING_MARKER_OPTIONS: YMapMarkerLabelPrivate = {\n cursor: 'drag',\n interactivityModel: 'default#silent',\n};\n\n// Helper function to convert YMapMarker to Schema.org Place object\nconst markerToSchemaPlace = (marker: YMapMarker) => {\n return {\n '@type': 'Place',\n address: marker.address\n ? {\n '@type': 'Text',\n '@value': marker.address,\n }\n : undefined,\n geo:\n marker.coordinate && marker.coordinate.length === 2\n ? {\n '@type': 'GeoCoordinates',\n latitude: marker.coordinate[0],\n longitude: marker.coordinate[1],\n }\n : undefined,\n };\n};\n\nconst YandexMap = (props: YMapProps) => {\n const {\n markers,\n zoom,\n id,\n disableControls = false,\n disableBalloons = false,\n areaMargin,\n copyrightPosition,\n className,\n forceAspectRatio = true,\n } = props;\n const {apiKey, scriptSrc, nonce} = React.useContext(MapsContext);\n const isMobile = React.useContext(MobileContext);\n\n const {lang = 'ru'} = React.useContext(LocaleContext);\n const containerId = `${DEFAULT_CONTAINER_ID}-${id}`;\n\n const [ymap, setYmaps] = React.useState<YMap | null>(null);\n const [height, setHeight] = React.useState<number | undefined>(undefined);\n const ref = React.useRef<HTMLDivElement>(null);\n\n const [loading, setLoading] = React.useState<boolean>(false);\n const [ready, setReady] = React.useState<boolean>(false);\n const [attemptsIndex, setAttemptsIndex] = React.useState<number>(0);\n const onTryAgain = React.useCallback(() => {\n setAttemptsIndex(attemptsIndex + 1);\n }, [attemptsIndex]);\n\n React.useEffect(() => {\n (async function () {\n setLoading(true);\n\n await YMapsApiLoader.loadApi(apiKey, scriptSrc, lang, nonce);\n\n window.ymaps?.ready(() => {\n setYmaps(\n new YMap(\n new window.ymaps.Map(\n containerId,\n {\n center: INITIAL_CENTER,\n zoom: zoom || DEFAULT_ZOOM,\n controls: disableControls ? [] : undefined,\n },\n {\n autoFitToViewport: 'always',\n suppressMapOpenBlock: disableControls,\n yandexMapDisablePoiInteractivity: disableControls,\n copyrightPosition,\n },\n ),\n ref.current,\n ),\n );\n });\n\n setLoading(false);\n })();\n }, [\n apiKey,\n lang,\n scriptSrc,\n containerId,\n zoom,\n nonce,\n attemptsIndex,\n setLoading,\n disableControls,\n copyrightPosition,\n ]);\n\n React.useEffect(() => {\n if (!forceAspectRatio) {\n return;\n }\n\n const updateSize = debounce(() => {\n if (ref.current) {\n setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));\n }\n }, 100);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [isMobile, forceAspectRatio]);\n\n React.useEffect(() => {\n if (ymap) {\n // show with computed center and placemarks\n const showPlacemarks = async () => {\n const privateMarkers: YMapMarkerPrivate[] = disableBalloons\n ? markers.map(({label, ...marker}) => ({\n ...marker,\n label: {...label, ...BALLOON_DISABLING_MARKER_OPTIONS},\n }))\n : markers;\n\n await ymap.showPlacemarks({markers: privateMarkers, zoom, areaMargin});\n\n setReady(true);\n };\n\n showPlacemarks();\n }\n }, [ymap, markers, zoom, disableBalloons, areaMargin]);\n\n const mapMicrodataScript = React.useMemo(() => {\n if (!markers.length) {\n return null;\n }\n\n const places = markers\n .filter((marker) => marker.address || marker.coordinate)\n .map(markerToSchemaPlace);\n\n if (places.length === 0) {\n return null;\n }\n\n const json = JSON.stringify({\n '@context': 'https://schema.org',\n '@graph': places,\n });\n\n return <script type=\"application/ld+json\" dangerouslySetInnerHTML={{__html: json}} />;\n }, [markers]);\n\n if (!markers) return null;\n\n return (\n <ErrorWrapper\n isError={YMapsApiLoader.status === MapApiStatus.Error}\n text={i18n('map-load-error')}\n buttonText={i18n('map-try-again')}\n handler={onTryAgain}\n className={b('wrapper')}\n >\n <div className={b('wrapper')}>\n {mapMicrodataScript}\n {/* hidden - to show the map after calculating the center */}\n <div\n id={containerId}\n className={b({hidden: !ready}, className)}\n ref={ref}\n style={{height}}\n />\n {loading ? <Spin size=\"xl\" className={b('spinner')} /> : null}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default YandexMap;\n"]}
@@ -0,0 +1,8 @@
1
+ import { Coordinate, YMapMargin } from "../../../models/index.js";
2
+ export type ParsedMargin = [top: number, right: number, bottom: number, left: number];
3
+ export declare const parseMargin: (margin: YMapMargin) => ParsedMargin;
4
+ export declare const calcPixelBounds: ([leftTop, rightBottom]: [Coordinate, Coordinate], zoom: number, containerSize: Coordinate) => number[][];
5
+ export declare const calculateMapParamsWithMarginAndZoom: ([leftTop, rightBottom]: [Coordinate, Coordinate], zoom: number, areaMargin: ParsedMargin, containerSize: Coordinate) => {
6
+ center: any;
7
+ zoom: number;
8
+ };
@@ -0,0 +1,90 @@
1
+ export const parseMargin = (margin) => {
2
+ if (!Array.isArray(margin)) {
3
+ return [margin, margin, margin, margin];
4
+ }
5
+ if (margin.length === 2) {
6
+ return [margin[0], margin[1], margin[0], margin[1]];
7
+ }
8
+ return margin;
9
+ };
10
+ export const calcPixelBounds = ([leftTop, rightBottom], zoom, containerSize) => {
11
+ const utils = window.ymaps.util.bounds;
12
+ let [[leftPx, topPx], [rightPx, bottomPx]] = utils.toGlobalPixelBounds([leftTop, rightBottom], zoom);
13
+ // fall back to container size in case there is only one marker and area is 0
14
+ if (rightPx - leftPx <= 0) {
15
+ const halfX = containerSize[0] / 2;
16
+ leftPx -= halfX;
17
+ rightPx += halfX;
18
+ }
19
+ if (bottomPx - topPx <= 0) {
20
+ const halfY = containerSize[1] / 2;
21
+ topPx -= halfY;
22
+ bottomPx += halfY;
23
+ }
24
+ return [
25
+ [leftPx, topPx],
26
+ [rightPx, bottomPx],
27
+ ];
28
+ };
29
+ const calcNewZoom = (l, zoom, marginSum) => {
30
+ return Math.log2((Math.pow(2, zoom) * (l - marginSum)) / l);
31
+ };
32
+ export const calculateMapParamsWithMarginAndZoom = ([leftTop, rightBottom], zoom, areaMargin, containerSize) => {
33
+ const utils = window.ymaps.util.bounds;
34
+ // calculate pixel bounds with current zoom
35
+ let [[leftPx, topPx], [rightPx, bottomPx]] = calcPixelBounds([leftTop, rightBottom], zoom, containerSize);
36
+ const [topMargin, rightMargin, bottomMargin, leftMargin] = areaMargin;
37
+ let zoomV;
38
+ let zoomH;
39
+ // calculate new zoom value after margins are applied
40
+ if (leftMargin && rightMargin) {
41
+ zoomH = calcNewZoom(rightPx - leftPx, zoom, leftMargin + rightMargin);
42
+ }
43
+ else {
44
+ zoomH = zoom;
45
+ }
46
+ if (topMargin && bottomMargin) {
47
+ zoomV = calcNewZoom(bottomPx - topPx, zoom, topMargin + bottomMargin);
48
+ }
49
+ else {
50
+ zoomV = zoom;
51
+ }
52
+ const newZoom = Math.min(zoomV, zoomH);
53
+ // calculate pixel bounds with new zoom
54
+ [[leftPx, topPx], [rightPx, bottomPx]] = calcPixelBounds([leftTop, rightBottom], newZoom, containerSize);
55
+ // calculate new bounds (scale if both size are present, otherwise shift the map)
56
+ if (leftMargin && rightMargin) {
57
+ leftPx -= leftMargin;
58
+ rightPx += rightMargin;
59
+ }
60
+ else if (leftMargin) {
61
+ leftPx -= leftMargin;
62
+ rightPx -= leftMargin;
63
+ }
64
+ else if (rightMargin) {
65
+ leftPx += rightMargin;
66
+ rightPx += rightMargin;
67
+ }
68
+ if (topMargin && bottomMargin) {
69
+ topPx -= topMargin;
70
+ bottomPx += bottomMargin;
71
+ }
72
+ else if (topMargin) {
73
+ topPx -= topMargin;
74
+ bottomPx -= topMargin;
75
+ }
76
+ else if (bottomMargin) {
77
+ topPx += bottomMargin;
78
+ bottomPx += bottomMargin;
79
+ }
80
+ // transform new bounds into coordinates
81
+ const [newLeftTop, newRightBottom] = utils.fromGlobalPixelBounds([
82
+ [leftPx, topPx],
83
+ [rightPx, bottomPx],
84
+ ], newZoom);
85
+ return {
86
+ center: utils.getCenter([newLeftTop, newRightBottom]),
87
+ zoom: newZoom,
88
+ };
89
+ };
90
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"../../../../../src","sources":["components/Map/YMap/utils.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAgB,EAAE;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,CAAC,OAAO,EAAE,WAAW,CAA2B,EAChD,IAAY,EACZ,aAAyB,EAC3B,EAAE;IACA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;IAEvC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC,mBA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,IAAI,YAAY,CAAC;IAC7B,CAAC;SAAM,IAAI,SAAS,EAAE,CAAC;QACnB,KAAK,IAAI,SAAS,CAAC;QACnB,QAAQ,IAAI,SAAS,CAAC;IAC1B,CAAC;SAAM,IAAI,YAAY,EAAE,CAAC;QACtB,KAAK,IAAI,YAAY,CAAC;QACtB,QAAQ,IAAI,YAAY,CAAC;IAC7B,CAAC;IAED,wCAAwC;IACxC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAC5D;QACI,CAAC,MAAM,EAAE,KAAK,CAAC;QACf,CAAC,OAAO,EAAE,QAAQ,CAAC;KACtB,EACD,OAAO,CACV,CAAC;IAEF,OAAO;QACH,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACrD,IAAI,EAAE,OAAO;KAChB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Coordinate, YMapMargin} from '../../../models';\n\nexport type ParsedMargin = [top: number, right: number, bottom: number, left: number];\n\nexport const parseMargin = (margin: YMapMargin): ParsedMargin => {\n if (!Array.isArray(margin)) {\n return [margin, margin, margin, margin];\n }\n\n if (margin.length === 2) {\n return [margin[0], margin[1], margin[0], margin[1]];\n }\n\n return margin;\n};\n\nexport const calcPixelBounds = (\n [leftTop, rightBottom]: [Coordinate, Coordinate],\n zoom: number,\n containerSize: Coordinate,\n) => {\n const utils = window.ymaps.util.bounds;\n\n let [[leftPx, topPx], [rightPx, bottomPx]] = utils.toGlobalPixelBounds(\n [leftTop, rightBottom],\n zoom,\n ) as [Coordinate, Coordinate];\n\n // fall back to container size in case there is only one marker and area is 0\n if (rightPx - leftPx <= 0) {\n const halfX = containerSize[0] / 2;\n leftPx -= halfX;\n rightPx += halfX;\n }\n\n if (bottomPx - topPx <= 0) {\n const halfY = containerSize[1] / 2;\n topPx -= halfY;\n bottomPx += halfY;\n }\n\n return [\n [leftPx, topPx],\n [rightPx, bottomPx],\n ];\n};\n\nconst calcNewZoom = (l: number, zoom: number, marginSum: number) => {\n return Math.log2((Math.pow(2, zoom) * (l - marginSum)) / l);\n};\n\nexport const calculateMapParamsWithMarginAndZoom = (\n [leftTop, rightBottom]: [Coordinate, Coordinate],\n zoom: number,\n areaMargin: ParsedMargin,\n containerSize: Coordinate,\n) => {\n const utils = window.ymaps.util.bounds;\n\n // calculate pixel bounds with current zoom\n let [[leftPx, topPx], [rightPx, bottomPx]] = calcPixelBounds(\n [leftTop, rightBottom],\n zoom,\n containerSize,\n );\n\n const [topMargin, rightMargin, bottomMargin, leftMargin] = areaMargin;\n\n let zoomV: number;\n let zoomH: number;\n\n // calculate new zoom value after margins are applied\n if (leftMargin && rightMargin) {\n zoomH = calcNewZoom(rightPx - leftPx, zoom, leftMargin + rightMargin);\n } else {\n zoomH = zoom;\n }\n\n if (topMargin && bottomMargin) {\n zoomV = calcNewZoom(bottomPx - topPx, zoom, topMargin + bottomMargin);\n } else {\n zoomV = zoom;\n }\n\n const newZoom = Math.min(zoomV, zoomH);\n\n // calculate pixel bounds with new zoom\n [[leftPx, topPx], [rightPx, bottomPx]] = calcPixelBounds(\n [leftTop, rightBottom],\n newZoom,\n containerSize,\n );\n\n // calculate new bounds (scale if both size are present, otherwise shift the map)\n if (leftMargin && rightMargin) {\n leftPx -= leftMargin;\n rightPx += rightMargin;\n } else if (leftMargin) {\n leftPx -= leftMargin;\n rightPx -= leftMargin;\n } else if (rightMargin) {\n leftPx += rightMargin;\n rightPx += rightMargin;\n }\n\n if (topMargin && bottomMargin) {\n topPx -= topMargin;\n bottomPx += bottomMargin;\n } else if (topMargin) {\n topPx -= topMargin;\n bottomPx -= topMargin;\n } else if (bottomMargin) {\n topPx += bottomMargin;\n bottomPx += bottomMargin;\n }\n\n // transform new bounds into coordinates\n const [newLeftTop, newRightBottom] = utils.fromGlobalPixelBounds(\n [\n [leftPx, topPx],\n [rightPx, bottomPx],\n ],\n newZoom,\n );\n\n return {\n center: utils.getCenter([newLeftTop, newRightBottom]),\n zoom: newZoom,\n };\n};\n"]}