@cloud-ru/uikit-product-header 5.0.17

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 (240) hide show
  1. package/CHANGELOG.md +3498 -0
  2. package/LICENSE +201 -0
  3. package/README.md +322 -0
  4. package/dist/cjs/components/HeaderLayout/HeaderLayout.d.ts +12 -0
  5. package/dist/cjs/components/HeaderLayout/HeaderLayout.js +25 -0
  6. package/dist/cjs/components/HeaderLayout/index.d.ts +1 -0
  7. package/dist/cjs/components/HeaderLayout/index.js +17 -0
  8. package/dist/cjs/components/HeaderLayout/styles.module.css +35 -0
  9. package/dist/cjs/components/Logo/Logo.d.ts +20 -0
  10. package/dist/cjs/components/Logo/Logo.js +61 -0
  11. package/dist/cjs/components/Logo/index.d.ts +1 -0
  12. package/dist/cjs/components/Logo/index.js +17 -0
  13. package/dist/cjs/components/Logo/styles.module.css +28 -0
  14. package/dist/cjs/components/MainMenu/Content/Content.d.ts +20 -0
  15. package/dist/cjs/components/MainMenu/Content/Content.js +36 -0
  16. package/dist/cjs/components/MainMenu/Content/index.d.ts +1 -0
  17. package/dist/cjs/components/MainMenu/Content/index.js +17 -0
  18. package/dist/cjs/components/MainMenu/Content/styles.module.css +40 -0
  19. package/dist/cjs/components/MainMenu/MainMenu.d.ts +4 -0
  20. package/dist/cjs/components/MainMenu/MainMenu.js +16 -0
  21. package/dist/cjs/components/MainMenu/MenuDesktop/MenuDesktop.d.ts +2 -0
  22. package/dist/cjs/components/MainMenu/MenuDesktop/MenuDesktop.js +34 -0
  23. package/dist/cjs/components/MainMenu/MenuDesktop/index.d.ts +1 -0
  24. package/dist/cjs/components/MainMenu/MenuDesktop/index.js +17 -0
  25. package/dist/cjs/components/MainMenu/MenuDesktop/styles.module.css +94 -0
  26. package/dist/cjs/components/MainMenu/MenuMobile/MenuMobile.d.ts +2 -0
  27. package/dist/cjs/components/MainMenu/MenuMobile/MenuMobile.js +31 -0
  28. package/dist/cjs/components/MainMenu/MenuMobile/index.d.ts +1 -0
  29. package/dist/cjs/components/MainMenu/MenuMobile/index.js +17 -0
  30. package/dist/cjs/components/MainMenu/MenuMobile/styles.module.css +23 -0
  31. package/dist/cjs/components/MainMenu/Search/SearchDesktop/SearchDesktop.d.ts +2 -0
  32. package/dist/cjs/components/MainMenu/Search/SearchDesktop/SearchDesktop.js +18 -0
  33. package/dist/cjs/components/MainMenu/Search/SearchDesktop/index.d.ts +1 -0
  34. package/dist/cjs/components/MainMenu/Search/SearchDesktop/index.js +17 -0
  35. package/dist/cjs/components/MainMenu/Search/SearchDesktop/styles.module.css +17 -0
  36. package/dist/cjs/components/MainMenu/Search/SearchMobile/SearchMobile.d.ts +2 -0
  37. package/dist/cjs/components/MainMenu/Search/SearchMobile/SearchMobile.js +42 -0
  38. package/dist/cjs/components/MainMenu/Search/SearchMobile/constants.d.ts +4 -0
  39. package/dist/cjs/components/MainMenu/Search/SearchMobile/constants.js +7 -0
  40. package/dist/cjs/components/MainMenu/Search/SearchMobile/hooks.d.ts +12 -0
  41. package/dist/cjs/components/MainMenu/Search/SearchMobile/hooks.js +40 -0
  42. package/dist/cjs/components/MainMenu/Search/SearchMobile/index.d.ts +1 -0
  43. package/dist/cjs/components/MainMenu/Search/SearchMobile/index.js +17 -0
  44. package/dist/cjs/components/MainMenu/Search/SearchMobile/styles.module.css +57 -0
  45. package/dist/cjs/components/MainMenu/Search/SearchSettingsButton/SearchSettingsButton.d.ts +4 -0
  46. package/dist/cjs/components/MainMenu/Search/SearchSettingsButton/SearchSettingsButton.js +13 -0
  47. package/dist/cjs/components/MainMenu/Search/SearchSettingsButton/index.d.ts +1 -0
  48. package/dist/cjs/components/MainMenu/Search/SearchSettingsButton/index.js +17 -0
  49. package/dist/cjs/components/MainMenu/Search/SearchSettingsButton/styles.module.css +11 -0
  50. package/dist/cjs/components/MainMenu/Search/index.d.ts +3 -0
  51. package/dist/cjs/components/MainMenu/Search/index.js +19 -0
  52. package/dist/cjs/components/MainMenu/Search/types.d.ts +14 -0
  53. package/dist/cjs/components/MainMenu/Search/types.js +2 -0
  54. package/dist/cjs/components/MainMenu/Search/useSearch.d.ts +8 -0
  55. package/dist/cjs/components/MainMenu/Search/useSearch.js +169 -0
  56. package/dist/cjs/components/MainMenu/hooks.d.ts +10 -0
  57. package/dist/cjs/components/MainMenu/hooks.js +108 -0
  58. package/dist/cjs/components/MainMenu/index.d.ts +4 -0
  59. package/dist/cjs/components/MainMenu/index.js +20 -0
  60. package/dist/cjs/components/MainMenu/styles.module.css +28 -0
  61. package/dist/cjs/components/MainMenu/types.d.ts +49 -0
  62. package/dist/cjs/components/MainMenu/types.js +2 -0
  63. package/dist/cjs/components/PathBreadcrumbs/PathBreadcrumbs.d.ts +7 -0
  64. package/dist/cjs/components/PathBreadcrumbs/PathBreadcrumbs.js +12 -0
  65. package/dist/cjs/components/PathBreadcrumbs/index.d.ts +1 -0
  66. package/dist/cjs/components/PathBreadcrumbs/index.js +17 -0
  67. package/dist/cjs/components/PathBreadcrumbs/styles.module.css +5 -0
  68. package/dist/cjs/components/PlatformLogo/Container.d.ts +12 -0
  69. package/dist/cjs/components/PlatformLogo/Container.js +28 -0
  70. package/dist/cjs/components/PlatformLogo/index.d.ts +4 -0
  71. package/dist/cjs/components/PlatformLogo/index.js +9 -0
  72. package/dist/cjs/components/PlatformLogo/styles.module.css +11 -0
  73. package/dist/cjs/components/UserMenu/UserMenu.d.ts +14 -0
  74. package/dist/cjs/components/UserMenu/UserMenu.js +54 -0
  75. package/dist/cjs/components/UserMenu/hooks/useLogoutItem.d.ts +6 -0
  76. package/dist/cjs/components/UserMenu/hooks/useLogoutItem.js +21 -0
  77. package/dist/cjs/components/UserMenu/hooks/useProfileItem.d.ts +3 -0
  78. package/dist/cjs/components/UserMenu/hooks/useProfileItem.js +29 -0
  79. package/dist/cjs/components/UserMenu/hooks/useThemeItem.d.ts +6 -0
  80. package/dist/cjs/components/UserMenu/hooks/useThemeItem.js +75 -0
  81. package/dist/cjs/components/UserMenu/hooks/useUserMenuItems.d.ts +13 -0
  82. package/dist/cjs/components/UserMenu/hooks/useUserMenuItems.js +42 -0
  83. package/dist/cjs/components/UserMenu/index.d.ts +2 -0
  84. package/dist/cjs/components/UserMenu/index.js +18 -0
  85. package/dist/cjs/components/UserMenu/styles.module.css +21 -0
  86. package/dist/cjs/components/UserMenu/types.d.ts +20 -0
  87. package/dist/cjs/components/UserMenu/types.js +8 -0
  88. package/dist/cjs/components/index.d.ts +6 -0
  89. package/dist/cjs/components/index.js +22 -0
  90. package/dist/cjs/hooks/index.d.ts +1 -0
  91. package/dist/cjs/hooks/index.js +17 -0
  92. package/dist/cjs/hooks/useLocalStorage.d.ts +1 -0
  93. package/dist/cjs/hooks/useLocalStorage.js +13 -0
  94. package/dist/cjs/index.d.ts +2 -0
  95. package/dist/cjs/index.js +18 -0
  96. package/dist/esm/components/HeaderLayout/HeaderLayout.d.ts +12 -0
  97. package/dist/esm/components/HeaderLayout/HeaderLayout.js +19 -0
  98. package/dist/esm/components/HeaderLayout/index.d.ts +1 -0
  99. package/dist/esm/components/HeaderLayout/index.js +1 -0
  100. package/dist/esm/components/HeaderLayout/styles.module.css +35 -0
  101. package/dist/esm/components/Logo/Logo.d.ts +20 -0
  102. package/dist/esm/components/Logo/Logo.js +54 -0
  103. package/dist/esm/components/Logo/index.d.ts +1 -0
  104. package/dist/esm/components/Logo/index.js +1 -0
  105. package/dist/esm/components/Logo/styles.module.css +28 -0
  106. package/dist/esm/components/MainMenu/Content/Content.d.ts +20 -0
  107. package/dist/esm/components/MainMenu/Content/Content.js +30 -0
  108. package/dist/esm/components/MainMenu/Content/index.d.ts +1 -0
  109. package/dist/esm/components/MainMenu/Content/index.js +1 -0
  110. package/dist/esm/components/MainMenu/Content/styles.module.css +40 -0
  111. package/dist/esm/components/MainMenu/MainMenu.d.ts +4 -0
  112. package/dist/esm/components/MainMenu/MainMenu.js +13 -0
  113. package/dist/esm/components/MainMenu/MenuDesktop/MenuDesktop.d.ts +2 -0
  114. package/dist/esm/components/MainMenu/MenuDesktop/MenuDesktop.js +28 -0
  115. package/dist/esm/components/MainMenu/MenuDesktop/index.d.ts +1 -0
  116. package/dist/esm/components/MainMenu/MenuDesktop/index.js +1 -0
  117. package/dist/esm/components/MainMenu/MenuDesktop/styles.module.css +94 -0
  118. package/dist/esm/components/MainMenu/MenuMobile/MenuMobile.d.ts +2 -0
  119. package/dist/esm/components/MainMenu/MenuMobile/MenuMobile.js +25 -0
  120. package/dist/esm/components/MainMenu/MenuMobile/index.d.ts +1 -0
  121. package/dist/esm/components/MainMenu/MenuMobile/index.js +1 -0
  122. package/dist/esm/components/MainMenu/MenuMobile/styles.module.css +23 -0
  123. package/dist/esm/components/MainMenu/Search/SearchDesktop/SearchDesktop.d.ts +2 -0
  124. package/dist/esm/components/MainMenu/Search/SearchDesktop/SearchDesktop.js +12 -0
  125. package/dist/esm/components/MainMenu/Search/SearchDesktop/index.d.ts +1 -0
  126. package/dist/esm/components/MainMenu/Search/SearchDesktop/index.js +1 -0
  127. package/dist/esm/components/MainMenu/Search/SearchDesktop/styles.module.css +17 -0
  128. package/dist/esm/components/MainMenu/Search/SearchMobile/SearchMobile.d.ts +2 -0
  129. package/dist/esm/components/MainMenu/Search/SearchMobile/SearchMobile.js +36 -0
  130. package/dist/esm/components/MainMenu/Search/SearchMobile/constants.d.ts +4 -0
  131. package/dist/esm/components/MainMenu/Search/SearchMobile/constants.js +4 -0
  132. package/dist/esm/components/MainMenu/Search/SearchMobile/hooks.d.ts +12 -0
  133. package/dist/esm/components/MainMenu/Search/SearchMobile/hooks.js +34 -0
  134. package/dist/esm/components/MainMenu/Search/SearchMobile/index.d.ts +1 -0
  135. package/dist/esm/components/MainMenu/Search/SearchMobile/index.js +1 -0
  136. package/dist/esm/components/MainMenu/Search/SearchMobile/styles.module.css +57 -0
  137. package/dist/esm/components/MainMenu/Search/SearchSettingsButton/SearchSettingsButton.d.ts +4 -0
  138. package/dist/esm/components/MainMenu/Search/SearchSettingsButton/SearchSettingsButton.js +7 -0
  139. package/dist/esm/components/MainMenu/Search/SearchSettingsButton/index.d.ts +1 -0
  140. package/dist/esm/components/MainMenu/Search/SearchSettingsButton/index.js +1 -0
  141. package/dist/esm/components/MainMenu/Search/SearchSettingsButton/styles.module.css +11 -0
  142. package/dist/esm/components/MainMenu/Search/index.d.ts +3 -0
  143. package/dist/esm/components/MainMenu/Search/index.js +3 -0
  144. package/dist/esm/components/MainMenu/Search/types.d.ts +14 -0
  145. package/dist/esm/components/MainMenu/Search/types.js +1 -0
  146. package/dist/esm/components/MainMenu/Search/useSearch.d.ts +8 -0
  147. package/dist/esm/components/MainMenu/Search/useSearch.js +161 -0
  148. package/dist/esm/components/MainMenu/hooks.d.ts +10 -0
  149. package/dist/esm/components/MainMenu/hooks.js +101 -0
  150. package/dist/esm/components/MainMenu/index.d.ts +4 -0
  151. package/dist/esm/components/MainMenu/index.js +4 -0
  152. package/dist/esm/components/MainMenu/styles.module.css +28 -0
  153. package/dist/esm/components/MainMenu/types.d.ts +49 -0
  154. package/dist/esm/components/MainMenu/types.js +1 -0
  155. package/dist/esm/components/PathBreadcrumbs/PathBreadcrumbs.d.ts +7 -0
  156. package/dist/esm/components/PathBreadcrumbs/PathBreadcrumbs.js +6 -0
  157. package/dist/esm/components/PathBreadcrumbs/index.d.ts +1 -0
  158. package/dist/esm/components/PathBreadcrumbs/index.js +1 -0
  159. package/dist/esm/components/PathBreadcrumbs/styles.module.css +5 -0
  160. package/dist/esm/components/PlatformLogo/Container.d.ts +12 -0
  161. package/dist/esm/components/PlatformLogo/Container.js +20 -0
  162. package/dist/esm/components/PlatformLogo/index.d.ts +4 -0
  163. package/dist/esm/components/PlatformLogo/index.js +6 -0
  164. package/dist/esm/components/PlatformLogo/styles.module.css +11 -0
  165. package/dist/esm/components/UserMenu/UserMenu.d.ts +14 -0
  166. package/dist/esm/components/UserMenu/UserMenu.js +48 -0
  167. package/dist/esm/components/UserMenu/hooks/useLogoutItem.d.ts +6 -0
  168. package/dist/esm/components/UserMenu/hooks/useLogoutItem.js +18 -0
  169. package/dist/esm/components/UserMenu/hooks/useProfileItem.d.ts +3 -0
  170. package/dist/esm/components/UserMenu/hooks/useProfileItem.js +23 -0
  171. package/dist/esm/components/UserMenu/hooks/useThemeItem.d.ts +6 -0
  172. package/dist/esm/components/UserMenu/hooks/useThemeItem.js +72 -0
  173. package/dist/esm/components/UserMenu/hooks/useUserMenuItems.d.ts +13 -0
  174. package/dist/esm/components/UserMenu/hooks/useUserMenuItems.js +39 -0
  175. package/dist/esm/components/UserMenu/index.d.ts +2 -0
  176. package/dist/esm/components/UserMenu/index.js +2 -0
  177. package/dist/esm/components/UserMenu/styles.module.css +21 -0
  178. package/dist/esm/components/UserMenu/types.d.ts +20 -0
  179. package/dist/esm/components/UserMenu/types.js +5 -0
  180. package/dist/esm/components/index.d.ts +6 -0
  181. package/dist/esm/components/index.js +6 -0
  182. package/dist/esm/hooks/index.d.ts +1 -0
  183. package/dist/esm/hooks/index.js +1 -0
  184. package/dist/esm/hooks/useLocalStorage.d.ts +1 -0
  185. package/dist/esm/hooks/useLocalStorage.js +10 -0
  186. package/dist/esm/index.d.ts +2 -0
  187. package/dist/esm/index.js +2 -0
  188. package/package.json +68 -0
  189. package/src/components/HeaderLayout/HeaderLayout.tsx +46 -0
  190. package/src/components/HeaderLayout/index.ts +1 -0
  191. package/src/components/HeaderLayout/styles.module.scss +38 -0
  192. package/src/components/Logo/Logo.tsx +93 -0
  193. package/src/components/Logo/index.ts +1 -0
  194. package/src/components/Logo/styles.module.scss +30 -0
  195. package/src/components/MainMenu/Content/Content.tsx +137 -0
  196. package/src/components/MainMenu/Content/index.ts +1 -0
  197. package/src/components/MainMenu/Content/styles.module.scss +35 -0
  198. package/src/components/MainMenu/MainMenu.tsx +51 -0
  199. package/src/components/MainMenu/MenuDesktop/MenuDesktop.tsx +120 -0
  200. package/src/components/MainMenu/MenuDesktop/index.ts +1 -0
  201. package/src/components/MainMenu/MenuDesktop/styles.module.scss +108 -0
  202. package/src/components/MainMenu/MenuMobile/MenuMobile.tsx +83 -0
  203. package/src/components/MainMenu/MenuMobile/index.ts +1 -0
  204. package/src/components/MainMenu/MenuMobile/styles.module.scss +26 -0
  205. package/src/components/MainMenu/Search/SearchDesktop/SearchDesktop.tsx +46 -0
  206. package/src/components/MainMenu/Search/SearchDesktop/index.ts +1 -0
  207. package/src/components/MainMenu/Search/SearchDesktop/styles.module.scss +21 -0
  208. package/src/components/MainMenu/Search/SearchMobile/SearchMobile.tsx +102 -0
  209. package/src/components/MainMenu/Search/SearchMobile/constants.ts +4 -0
  210. package/src/components/MainMenu/Search/SearchMobile/hooks.ts +43 -0
  211. package/src/components/MainMenu/Search/SearchMobile/index.ts +1 -0
  212. package/src/components/MainMenu/Search/SearchMobile/styles.module.scss +72 -0
  213. package/src/components/MainMenu/Search/SearchSettingsButton/SearchSettingsButton.tsx +22 -0
  214. package/src/components/MainMenu/Search/SearchSettingsButton/index.ts +1 -0
  215. package/src/components/MainMenu/Search/SearchSettingsButton/styles.module.scss +13 -0
  216. package/src/components/MainMenu/Search/index.ts +3 -0
  217. package/src/components/MainMenu/Search/types.ts +20 -0
  218. package/src/components/MainMenu/Search/useSearch.tsx +212 -0
  219. package/src/components/MainMenu/hooks.tsx +135 -0
  220. package/src/components/MainMenu/index.ts +4 -0
  221. package/src/components/MainMenu/styles.module.scss +28 -0
  222. package/src/components/MainMenu/types.ts +62 -0
  223. package/src/components/PathBreadcrumbs/PathBreadcrumbs.tsx +21 -0
  224. package/src/components/PathBreadcrumbs/index.ts +1 -0
  225. package/src/components/PathBreadcrumbs/styles.module.scss +10 -0
  226. package/src/components/PlatformLogo/Container.tsx +32 -0
  227. package/src/components/PlatformLogo/index.ts +8 -0
  228. package/src/components/PlatformLogo/styles.module.scss +13 -0
  229. package/src/components/UserMenu/UserMenu.tsx +138 -0
  230. package/src/components/UserMenu/hooks/useLogoutItem.tsx +28 -0
  231. package/src/components/UserMenu/hooks/useProfileItem.tsx +41 -0
  232. package/src/components/UserMenu/hooks/useThemeItem.tsx +116 -0
  233. package/src/components/UserMenu/hooks/useUserMenuItems.ts +77 -0
  234. package/src/components/UserMenu/index.ts +2 -0
  235. package/src/components/UserMenu/styles.module.scss +21 -0
  236. package/src/components/UserMenu/types.ts +24 -0
  237. package/src/components/index.ts +6 -0
  238. package/src/hooks/index.ts +1 -0
  239. package/src/hooks/useLocalStorage.ts +15 -0
  240. package/src/index.ts +2 -0
@@ -0,0 +1,4 @@
1
+ export type SearchSettingsButtonProps = {
2
+ onClick(): void;
3
+ };
4
+ export declare function SearchSettingsButton({ onClick }: SearchSettingsButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConfigurationSVG } from '@sbercloud/uikit-product-icons';
3
+ import { ButtonFunction } from '@snack-uikit/button';
4
+ import styles from './styles.module.css';
5
+ export function SearchSettingsButton({ onClick }) {
6
+ return (_jsx("div", { className: styles.searchSettings, children: _jsx(ButtonFunction, { icon: _jsx(ConfigurationSVG, {}), size: 'xs', className: styles.searchSettingsButton, onClick: onClick, "data-test-id": 'header__drawer-menu__search-config-button' }) }));
7
+ }
@@ -0,0 +1 @@
1
+ export * from './SearchSettingsButton';
@@ -0,0 +1 @@
1
+ export * from './SearchSettingsButton';
@@ -0,0 +1,11 @@
1
+ .searchSettings{
2
+ border-left:1px solid var(--sys-neutral-decor-default, #dde0ea);
3
+ height:100%;
4
+ display:flex;
5
+ flex-direction:column;
6
+ justify-content:center;
7
+ }
8
+
9
+ .searchSettingsButton{
10
+ margin-left:var(--dimension-1m, 8px);
11
+ }
@@ -0,0 +1,3 @@
1
+ export * from './SearchDesktop';
2
+ export * from './SearchMobile';
3
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ export * from './SearchDesktop';
2
+ export * from './SearchMobile';
3
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ import { LinksGroup } from '../types';
2
+ export type SearchHandler = (searchValue: string, items: LinksGroup[]) => LinksGroup[] | undefined;
3
+ export type SearchFunction = {
4
+ id: string;
5
+ label: string;
6
+ handler: SearchHandler;
7
+ };
8
+ export type SearchProps = {
9
+ searchValue: string;
10
+ onSearchValueChange(value: string): void;
11
+ searchFunctions: SearchFunction[];
12
+ onChangeSearchFn(id: string): void;
13
+ searchFn?: string;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { SearchProps } from './types';
2
+ export declare enum SearchGroupsAccessor {
3
+ GroupLabelText = "label.text",
4
+ ItemLabelText = "items.label",
5
+ ItemAliases = "items.aliases"
6
+ }
7
+ export declare function toggleLayout(text: string): string;
8
+ export declare function useSearch(): SearchProps;
@@ -0,0 +1,161 @@
1
+ import Fuse from 'fuse.js';
2
+ import { useMemo, useState } from 'react';
3
+ import { useLocale } from '@sbercloud/uikit-product-locale';
4
+ export var SearchGroupsAccessor;
5
+ (function (SearchGroupsAccessor) {
6
+ SearchGroupsAccessor["GroupLabelText"] = "label.text";
7
+ SearchGroupsAccessor["ItemLabelText"] = "items.label";
8
+ SearchGroupsAccessor["ItemAliases"] = "items.aliases";
9
+ })(SearchGroupsAccessor || (SearchGroupsAccessor = {}));
10
+ function matchSearchString(value, search) {
11
+ return value.trim().toLowerCase().includes(search.trim().toLowerCase());
12
+ }
13
+ const prepareItemAccessorKey = (groupId, alias) => `${groupId}-${alias}`;
14
+ function createItemsMap(links) {
15
+ const itemsMap = {};
16
+ links.forEach(group => {
17
+ group.items.forEach(item => {
18
+ item.aliases.forEach(alias => {
19
+ const key = prepareItemAccessorKey(group.id, alias);
20
+ itemsMap[key] = item;
21
+ });
22
+ });
23
+ });
24
+ return itemsMap;
25
+ }
26
+ const enCharacters = "qwertyuiop[]asdfghjkl;'zxcvbnm,./`";
27
+ const ruCharacters = 'йцукенгшщзхъфывапролджэячсмитьбю.ё';
28
+ const enToRuMap = {};
29
+ const ruToEnMap = {};
30
+ for (let i = 0; i < enCharacters.length; i++) {
31
+ enToRuMap[enCharacters[i]] = ruCharacters[i];
32
+ ruToEnMap[ruCharacters[i]] = enCharacters[i];
33
+ }
34
+ function convertLayout(text, direction = 'en-ru') {
35
+ const map = direction === 'en-ru' ? enToRuMap : ruToEnMap;
36
+ return text
37
+ .split('')
38
+ .map(ch => { var _a; return (_a = map[ch]) !== null && _a !== void 0 ? _a : ch; })
39
+ .join('');
40
+ }
41
+ function isCyrillic(text) {
42
+ return /[а-яё]/i.test(text);
43
+ }
44
+ function isLatin(text) {
45
+ return /[a-z]/i.test(text);
46
+ }
47
+ export function toggleLayout(text) {
48
+ const lowercaseValue = text.toLowerCase();
49
+ if (isCyrillic(lowercaseValue)) {
50
+ return convertLayout(lowercaseValue, 'ru-en');
51
+ }
52
+ if (isLatin(lowercaseValue)) {
53
+ return convertLayout(lowercaseValue, 'en-ru');
54
+ }
55
+ return text;
56
+ }
57
+ export function useSearch() {
58
+ const [searchValue, onSearchValueChange] = useState('');
59
+ const { t } = useLocale('Header');
60
+ const [searchFn, onChangeSearchFn] = useState('fuzzy');
61
+ const searchFunctions = useMemo(() => [
62
+ {
63
+ id: 'fuzzy',
64
+ label: t('searchSettingsFuzzyChipLabel'),
65
+ handler: (searchValue, links) => {
66
+ if (!searchValue) {
67
+ return links;
68
+ }
69
+ const itemsMap = createItemsMap(links);
70
+ const linksFuse = new Fuse(links, {
71
+ keys: Object.values(SearchGroupsAccessor),
72
+ includeMatches: true,
73
+ threshold: 0.3,
74
+ });
75
+ let fuseSearchResults = linksFuse.search(searchValue);
76
+ if (fuseSearchResults.length < 1) {
77
+ const fixedLayoutValue = toggleLayout(searchValue);
78
+ fuseSearchResults = linksFuse.search(fixedLayoutValue);
79
+ }
80
+ return fuseSearchResults.reduce((accResult, fuseResult) => {
81
+ if (!fuseResult.matches) {
82
+ return accResult;
83
+ }
84
+ const isMatchByGroup = fuseResult.matches.find(match => match.key === SearchGroupsAccessor.GroupLabelText);
85
+ if (isMatchByGroup) {
86
+ accResult.push(fuseResult.item);
87
+ return accResult;
88
+ }
89
+ const group = fuseResult.item;
90
+ const originalGroupIndex = fuseResult.refIndex;
91
+ const itemsInnerMap = {};
92
+ const items = [];
93
+ fuseResult.matches.forEach(match => {
94
+ if (match.refIndex === undefined) {
95
+ return;
96
+ }
97
+ switch (match.key) {
98
+ case SearchGroupsAccessor.ItemLabelText: {
99
+ const item = links[originalGroupIndex].items[match.refIndex];
100
+ if (item && !itemsInnerMap[item.id]) {
101
+ itemsInnerMap[item.id] = item;
102
+ items.push(item);
103
+ }
104
+ break;
105
+ }
106
+ case SearchGroupsAccessor.ItemAliases: {
107
+ if (!match.value) {
108
+ break;
109
+ }
110
+ const groupId = fuseResult.item.id;
111
+ const alias = match.value;
112
+ const key = prepareItemAccessorKey(groupId, alias);
113
+ const item = itemsMap[key];
114
+ if (item && !itemsInnerMap[item.id]) {
115
+ itemsInnerMap[item.id] = item;
116
+ items.push(item);
117
+ }
118
+ break;
119
+ }
120
+ case SearchGroupsAccessor.GroupLabelText:
121
+ default:
122
+ return;
123
+ }
124
+ });
125
+ if (items.length > 0) {
126
+ accResult.push(Object.assign(Object.assign({}, group), { items }));
127
+ }
128
+ return accResult;
129
+ }, []);
130
+ },
131
+ },
132
+ {
133
+ id: 'precise',
134
+ label: t('searchSettingsPreciseChipLabel'),
135
+ handler: (searchValue, links) => {
136
+ if (!searchValue || links.length < 1) {
137
+ return links;
138
+ }
139
+ return links.reduce((result, group) => {
140
+ if (group.label && matchSearchString(group.label.text, searchValue)) {
141
+ result.push(group);
142
+ return result;
143
+ }
144
+ const items = group.items.filter(item => matchSearchString(item.label, searchValue));
145
+ if (items.length > 0) {
146
+ result.push(Object.assign(Object.assign({}, group), { items }));
147
+ return result;
148
+ }
149
+ return result;
150
+ }, []);
151
+ },
152
+ },
153
+ ], [t]);
154
+ return {
155
+ searchValue,
156
+ onSearchValueChange,
157
+ searchFunctions,
158
+ onChangeSearchFn,
159
+ searchFn,
160
+ };
161
+ }
@@ -0,0 +1,10 @@
1
+ import { LinksGroup, MainMenuProps } from './types';
2
+ export declare function useHighlight(className: string): (elementToHighlight?: HTMLElement | null) => void;
3
+ type UseMenuItemsProps = Pick<MainMenuProps, 'favorite' | 'serviceGroups' | 'search'>;
4
+ export declare function useMenuItems({ search, serviceGroups, favorite }: UseMenuItemsProps): {
5
+ resultItems: LinksGroup[];
6
+ groupItems: import("@snack-uikit/list/dist/esm/components/Items").BaseItem[];
7
+ searchRef: import("react").RefObject<HTMLInputElement>;
8
+ scrollRef: import("react").RefObject<HTMLDivElement>;
9
+ };
10
+ export {};
@@ -0,0 +1,101 @@
1
+ import debounce from 'lodash.debounce';
2
+ import { useMemo, useRef } from 'react';
3
+ import { useLocale } from '@sbercloud/uikit-product-locale';
4
+ import styles from './styles.module.css';
5
+ export function useHighlight(className) {
6
+ const element = useRef();
7
+ const highlight = useMemo(() => {
8
+ const scheduleHighlight = debounce(() => {
9
+ var _a;
10
+ (_a = element.current) === null || _a === void 0 ? void 0 : _a.classList.add(className);
11
+ setTimeout(() => {
12
+ var _a;
13
+ (_a = element.current) === null || _a === void 0 ? void 0 : _a.classList.remove(className);
14
+ element.current = undefined;
15
+ }, 300, { trailing: false });
16
+ }, 80);
17
+ return (elementToHighlight) => {
18
+ if (elementToHighlight) {
19
+ element.current = elementToHighlight;
20
+ }
21
+ scheduleHighlight();
22
+ };
23
+ },
24
+ // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ []);
26
+ return highlight;
27
+ }
28
+ export function useMenuItems({ search, serviceGroups, favorite }) {
29
+ var _a, _b;
30
+ const { t } = useLocale('Header');
31
+ const { searchValue = '', searchFn, searchFunctions, onSearchValueChange } = search || {};
32
+ const searchRef = useRef(null);
33
+ const scrollRef = useRef(null);
34
+ const highlight = useHighlight(styles.highlight);
35
+ const groupWithFavorites = useMemo(() => {
36
+ if (!favorite || !favorite.value) {
37
+ return serviceGroups;
38
+ }
39
+ const flatMapItems = serviceGroups.flatMap(serviceGroup => serviceGroup.items);
40
+ const favoriteServices = favorite.value.reduce((acc, cur) => {
41
+ const item = flatMapItems.find(item => item.id === cur);
42
+ if (item) {
43
+ acc.push(item);
44
+ }
45
+ return acc;
46
+ }, []);
47
+ return [
48
+ {
49
+ id: 'favorite',
50
+ label: {
51
+ text: t('favorite'),
52
+ },
53
+ items: favoriteServices,
54
+ },
55
+ ].concat(serviceGroups);
56
+ }, [favorite, serviceGroups, t]);
57
+ const groupItems = groupWithFavorites
58
+ .filter(group => group.items.length > 0)
59
+ .map(({ id, label: { text } }) => ({
60
+ id,
61
+ content: {
62
+ option: text,
63
+ truncate: {
64
+ option: 2,
65
+ },
66
+ },
67
+ onClick() {
68
+ onSearchValueChange === null || onSearchValueChange === void 0 ? void 0 : onSearchValueChange('');
69
+ setTimeout(() => {
70
+ var _a, _b;
71
+ // TODO: remove or move
72
+ // eslint-disable-next-line @cloud-ru/ssr-safe-react/domApi
73
+ const element = document.getElementById(id);
74
+ if (!element)
75
+ return;
76
+ (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
77
+ left: 0,
78
+ top: element.offsetTop - (((_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || 0),
79
+ behavior: 'smooth',
80
+ });
81
+ // Задержка approximately равна времени скроллинга
82
+ setTimeout(() => {
83
+ highlight(element);
84
+ }, 500);
85
+ }, 0);
86
+ },
87
+ }));
88
+ const searchFnMap = searchFunctions === null || searchFunctions === void 0 ? void 0 : searchFunctions.reduce((acc, cur) => {
89
+ acc[cur.id] = cur.handler;
90
+ return acc;
91
+ }, {});
92
+ const itemsWithoutEmptyGroups = groupWithFavorites.filter(group => group.items.length > 0);
93
+ const resultItems = ((_b = (searchFn ? searchFnMap === null || searchFnMap === void 0 ? void 0 : searchFnMap[searchFn] : (_a = searchFunctions === null || searchFunctions === void 0 ? void 0 : searchFunctions[0]) === null || _a === void 0 ? void 0 : _a.handler)) === null || _b === void 0 ? void 0 : _b(searchValue, itemsWithoutEmptyGroups)) ||
94
+ itemsWithoutEmptyGroups;
95
+ return {
96
+ resultItems,
97
+ groupItems,
98
+ searchRef,
99
+ scrollRef,
100
+ };
101
+ }
@@ -0,0 +1,4 @@
1
+ export * from './MainMenu';
2
+ export * from './types';
3
+ export * from './Search/useSearch';
4
+ export * from './Search/types';
@@ -0,0 +1,4 @@
1
+ export * from './MainMenu';
2
+ export * from './types';
3
+ export * from './Search/useSearch';
4
+ export * from './Search/types';
@@ -0,0 +1,28 @@
1
+ .highlight{
2
+ animation:shake-animation 300ms ease 1;
3
+ transform-origin:100% 100%;
4
+ }
5
+
6
+ @keyframes shake-animation{
7
+ 0%{
8
+ transform:translate(0, 0);
9
+ }
10
+ 18%{
11
+ transform:translate(5px, 0);
12
+ }
13
+ 35%{
14
+ transform:translate(0, 0);
15
+ }
16
+ 53%{
17
+ transform:translate(5px, 0);
18
+ }
19
+ 71%{
20
+ transform:translate(0, 0);
21
+ }
22
+ 89%{
23
+ transform:translate(3px, 0);
24
+ }
25
+ 100%{
26
+ transform:translate(0, 0);
27
+ }
28
+ }
@@ -0,0 +1,49 @@
1
+ import { JSXElementConstructor, MouseEvent, MouseEventHandler, ReactNode } from 'react';
2
+ import { CardServiceSmallProps } from '@sbercloud/uikit-product-card-predefined';
3
+ import { ListProps } from '@snack-uikit/list';
4
+ import { SearchProps } from './Search/types';
5
+ export type InnerLink = {
6
+ id: string;
7
+ icon: JSXElementConstructor<{
8
+ size?: number;
9
+ className?: string;
10
+ }>;
11
+ label: string;
12
+ onClick(e?: MouseEvent<HTMLElement>): void;
13
+ href?: string;
14
+ disabled?: boolean;
15
+ hidden?: boolean;
16
+ badge?: CardServiceSmallProps['promoBadge'];
17
+ aliases: string[];
18
+ };
19
+ type TitleStatic = {
20
+ text: string;
21
+ onClick?: never;
22
+ };
23
+ type TitleClickable = {
24
+ text: string;
25
+ onClick?: MouseEventHandler<HTMLAnchorElement>;
26
+ };
27
+ export type LinksGroupTitle = TitleStatic | TitleClickable;
28
+ export type LinksGroup = {
29
+ id: string;
30
+ label: LinksGroupTitle;
31
+ hidden?: boolean;
32
+ items: InnerLink[];
33
+ };
34
+ export type MainMenuProps = {
35
+ open?: boolean;
36
+ setOpen?(open: boolean): void;
37
+ leftTop?: ReactNode;
38
+ rightTop?: ReactNode;
39
+ settingItems: ListProps['items'];
40
+ serviceGroups: LinksGroup[];
41
+ onLinkChange?(value: string): void;
42
+ favorite?: {
43
+ value: string[];
44
+ onChange: (productId: string) => (addingValue: boolean) => void;
45
+ };
46
+ search?: SearchProps;
47
+ isMobile?: boolean;
48
+ };
49
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { BreadcrumbsProps } from '@snack-uikit/breadcrumbs';
2
+ type PathBreadcrumbsProps = {
3
+ items: BreadcrumbsProps['items'];
4
+ isMobile?: boolean;
5
+ };
6
+ export declare function PathBreadcrumbs({ isMobile, items }: PathBreadcrumbsProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Breadcrumbs } from '@snack-uikit/breadcrumbs';
3
+ import styles from './styles.module.css';
4
+ export function PathBreadcrumbs({ isMobile, items }) {
5
+ return (_jsx(Breadcrumbs, { items: items, className: styles.breadcrumbs, inactiveLastItem: items.length > 1, separator: '/', size: isMobile ? 'xs' : 's', "data-test-id": 'header__breadcrumbs' }));
6
+ }
@@ -0,0 +1 @@
1
+ export * from './PathBreadcrumbs';
@@ -0,0 +1 @@
1
+ export * from './PathBreadcrumbs';
@@ -0,0 +1,5 @@
1
+ .breadcrumbs{
2
+ padding:var(--dimension-1m, 8px) !important;
3
+ margin:calc(0px - var(--dimension-1m, 8px)) 0 !important;
4
+ min-width:0;
5
+ }
@@ -0,0 +1,12 @@
1
+ import { JSXElementConstructor, PropsWithChildren } from 'react';
2
+ import { WithSupportProps } from '@sbercloud/uikit-product-utils';
3
+ export type ContainerProps = PropsWithChildren<WithSupportProps<{
4
+ className?: string;
5
+ }>>;
6
+ export declare function Container({ children, ...otherProps }: ContainerProps): import("react/jsx-runtime").JSX.Element;
7
+ export type IconComponentProps = {
8
+ className?: string;
9
+ };
10
+ export declare const getPlatformIconComponent: (Icon: JSXElementConstructor<{
11
+ size: number;
12
+ }>) => (props: IconComponentProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import styled from './styles.module.css';
14
+ export function Container(_a) {
15
+ var { children } = _a, otherProps = __rest(_a, ["children"]);
16
+ return (_jsx("div", Object.assign({ className: styled.container }, otherProps, { children: children })));
17
+ }
18
+ export const getPlatformIconComponent = (Icon) => function IconComponent(props) {
19
+ return (_jsx(Container, Object.assign({}, props, { children: _jsx(Icon, { size: 24 }) })));
20
+ };
@@ -0,0 +1,4 @@
1
+ export declare const AdvancedPlatformLogo: (props: import("./Container").IconComponentProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const EnterprisePlatformLogo: (props: import("./Container").IconComponentProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const EvolutionPlatformLogo: (props: import("./Container").IconComponentProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const MLSpacePlatformLogo: (props: import("./Container").IconComponentProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { AdvancedSVG, EvolutionSVG, MlSpaceSVG, VmwareSVG } from '@sbercloud/uikit-product-icons';
2
+ import { getPlatformIconComponent } from './Container';
3
+ export const AdvancedPlatformLogo = getPlatformIconComponent(AdvancedSVG);
4
+ export const EnterprisePlatformLogo = getPlatformIconComponent(VmwareSVG);
5
+ export const EvolutionPlatformLogo = getPlatformIconComponent(EvolutionSVG);
6
+ export const MLSpacePlatformLogo = getPlatformIconComponent(MlSpaceSVG);
@@ -0,0 +1,11 @@
1
+ .container{
2
+ width:24px;
3
+ height:24px;
4
+ color:var(--sys-primary-on-accent, #fbfffc);
5
+ fill:var(--sys-primary-on-accent, #fbfffc);
6
+ background-color:var(--sys-neutral-accent-default, #787b8a);
7
+ border-radius:var(--dimension-050m, 4px);
8
+ display:flex;
9
+ align-items:center;
10
+ justify-content:center;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseItemProps, ListProps } from '@snack-uikit/list';
2
+ import { ThemeProps, UserProfileProps } from './types';
3
+ export type UserMenuProps = {
4
+ profile?: UserProfileProps;
5
+ theme?: ThemeProps;
6
+ items?: ListProps['items'];
7
+ settingItems?: BaseItemProps[];
8
+ onLogout?(): void;
9
+ open?: boolean;
10
+ setOpen?(open: boolean): void;
11
+ onClick?(): void;
12
+ isMobile?: boolean;
13
+ };
14
+ export declare function UserMenu({ profile, open: openProp, setOpen: setOpenProp, onLogout, items, settingItems, theme, isMobile, onClick, }: UserMenuProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { useLocale } from '@sbercloud/uikit-product-locale';
4
+ import { MobileDrawerCustom } from '@sbercloud/uikit-product-mobile-drawer';
5
+ import { Avatar } from '@snack-uikit/avatar';
6
+ import { ButtonFunction } from '@snack-uikit/button';
7
+ import { Droplist, List } from '@snack-uikit/list';
8
+ import { Scroll } from '@snack-uikit/scroll';
9
+ import { useValueControl } from '@snack-uikit/utils';
10
+ import { useUserMenuItems } from './hooks/useUserMenuItems';
11
+ import styles from './styles.module.css';
12
+ export function UserMenu({ profile = {}, open: openProp, setOpen: setOpenProp, onLogout, items, settingItems, theme, isMobile, onClick, }) {
13
+ const { t } = useLocale('Header');
14
+ const [open = false, setOpen] = useValueControl({ value: openProp, onChange: setOpenProp });
15
+ const { fullName = '', inviteCount } = profile;
16
+ const userMenuItems = useUserMenuItems({
17
+ isMobile,
18
+ profile,
19
+ theme,
20
+ items,
21
+ settingItems,
22
+ onClose: () => {
23
+ setOpen(false);
24
+ },
25
+ onLogout,
26
+ });
27
+ const trigger = useMemo(() => (_jsx(ButtonFunction, { size: 'm', onClick: () => {
28
+ setOpen === null || setOpen === void 0 ? void 0 : setOpen(true);
29
+ onClick === null || onClick === void 0 ? void 0 : onClick();
30
+ }, counter: Number(inviteCount)
31
+ ? {
32
+ value: Number(inviteCount),
33
+ appearance: 'primary',
34
+ }
35
+ : undefined, "data-test-id": 'header__user-menu__button', icon: _jsx(Avatar, { size: 'xs', name: fullName, showTwoSymbols: true }) })), [fullName, inviteCount, onClick, setOpen]);
36
+ if (isMobile) {
37
+ return (_jsxs(_Fragment, { children: [trigger, _jsxs(MobileDrawerCustom, { open: open, onClose: () => {
38
+ setOpen(false);
39
+ }, position: 'right', swipeEnabled: false, "data-test-id": 'header__user-menu-mobile', closeOnPopstate: true, children: [_jsx(MobileDrawerCustom.Header, { title: t('user') }), _jsx(Scroll, { barHideStrategy: 'never', children: _jsx("div", { className: styles.mobileList, children: _jsx(List, { items: userMenuItems, selection: {
40
+ mode: 'single',
41
+ value: 'null',
42
+ }, size: 'm' }) }) })] })] }));
43
+ }
44
+ return (_jsx(_Fragment, { children: _jsx(Droplist, { items: userMenuItems, selection: {
45
+ mode: 'single',
46
+ value: 'null',
47
+ }, trigger: 'click', placement: 'bottom-end', className: styles.userMenuDroplist, closeOnPopstate: true, closeDroplistOnItemClick: true, "data-test-id": 'header__user-menu', children: trigger }) }));
48
+ }
@@ -0,0 +1,6 @@
1
+ import { ListProps } from '@snack-uikit/list';
2
+ type UseLogoutItemProps = {
3
+ onLogout?(): void;
4
+ };
5
+ export declare function useLogoutItem({ onLogout }: UseLogoutItemProps): ListProps['items'];
6
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { ExitSVG } from '@sbercloud/uikit-product-icons';
4
+ import { useLocale } from '@sbercloud/uikit-product-locale';
5
+ export function useLogoutItem({ onLogout }) {
6
+ const { t } = useLocale('Header');
7
+ return useMemo(() => [
8
+ { type: 'group', divider: true, items: [] },
9
+ {
10
+ content: {
11
+ option: t('logout'),
12
+ },
13
+ beforeContent: _jsx(ExitSVG, {}),
14
+ onClick: onLogout,
15
+ 'data-test-id': 'header__user-menu__logout',
16
+ },
17
+ ], [onLogout, t]);
18
+ }
@@ -0,0 +1,3 @@
1
+ import { BaseItemProps } from '@snack-uikit/list';
2
+ import { UserProfileProps } from '../types';
3
+ export declare function useProfileItem({ fullName, email, itemWrapRender, onClick, }: UserProfileProps): BaseItemProps;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { SettingsSVG } from '@sbercloud/uikit-product-icons';
4
+ import { Avatar } from '@snack-uikit/avatar';
5
+ import styles from '../styles.module.css';
6
+ export function useProfileItem({ fullName = '', email = '', itemWrapRender, onClick, }) {
7
+ return useMemo(() => ({
8
+ content: {
9
+ option: fullName,
10
+ description: email,
11
+ truncate: {
12
+ description: 1,
13
+ },
14
+ },
15
+ onClick,
16
+ beforeContent: _jsx(Avatar, { size: 'xs', name: fullName, showTwoSymbols: true }),
17
+ afterContent: (_jsx("div", { className: styles.settingIcon, children: _jsx(SettingsSVG, {}) })),
18
+ itemWrapRender,
19
+ id: 'header__user-menu__button',
20
+ 'data-test-id': 'header__user-menu__manage-profile',
21
+ className: styles.userMenuInfoItem,
22
+ }), [email, fullName, itemWrapRender, onClick]);
23
+ }