@cloud-ru/uikit-product-utils 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/components/ConfigProvider/ConfigProvider.d.ts +13 -0
  3. package/dist/cjs/components/ConfigProvider/ConfigProvider.js +13 -0
  4. package/dist/cjs/components/ConfigProvider/index.d.ts +1 -0
  5. package/dist/cjs/components/ConfigProvider/index.js +17 -0
  6. package/dist/cjs/components/ForThemeMode/ForThemeMode.d.ts +6 -0
  7. package/dist/cjs/components/ForThemeMode/ForThemeMode.js +9 -0
  8. package/dist/cjs/components/ForThemeMode/hooks.d.ts +6 -0
  9. package/dist/cjs/components/ForThemeMode/hooks.js +13 -0
  10. package/dist/cjs/components/ForThemeMode/index.d.ts +2 -0
  11. package/dist/cjs/components/ForThemeMode/index.js +18 -0
  12. package/dist/cjs/components/index.d.ts +2 -0
  13. package/dist/cjs/components/index.js +18 -0
  14. package/dist/cjs/constants/adaptive.d.ts +34 -0
  15. package/dist/cjs/constants/adaptive.js +44 -0
  16. package/dist/cjs/constants/displayMode.d.ts +16 -0
  17. package/dist/cjs/constants/displayMode.js +24 -0
  18. package/dist/cjs/constants/environment.d.ts +14 -0
  19. package/dist/cjs/constants/environment.js +18 -0
  20. package/dist/cjs/helpers/tryParseJson.d.ts +1 -0
  21. package/dist/cjs/helpers/tryParseJson.js +15 -0
  22. package/dist/cjs/hooks/index.d.ts +13 -0
  23. package/dist/cjs/hooks/index.js +29 -0
  24. package/dist/cjs/hooks/private/getCustomStore.d.ts +2 -0
  25. package/dist/cjs/hooks/private/getCustomStore.js +11 -0
  26. package/dist/cjs/hooks/useAdaptive.d.ts +4 -0
  27. package/dist/cjs/hooks/useAdaptive.js +9 -0
  28. package/dist/cjs/hooks/useBrand.d.ts +5 -0
  29. package/dist/cjs/hooks/useBrand.js +28 -0
  30. package/dist/cjs/hooks/useComponentSize.d.ts +5 -0
  31. package/dist/cjs/hooks/useComponentSize.js +36 -0
  32. package/dist/cjs/hooks/useConfig.d.ts +8 -0
  33. package/dist/cjs/hooks/useConfig.js +126 -0
  34. package/dist/cjs/hooks/useDisplayMode.d.ts +3 -0
  35. package/dist/cjs/hooks/useDisplayMode.js +9 -0
  36. package/dist/cjs/hooks/useEventHandler.d.ts +1 -0
  37. package/dist/cjs/hooks/useEventHandler.js +17 -0
  38. package/dist/cjs/hooks/useForceUpdate.d.ts +1 -0
  39. package/dist/cjs/hooks/useForceUpdate.js +8 -0
  40. package/dist/cjs/hooks/useForceUpdateOnPageLoadedCompletely.d.ts +1 -0
  41. package/dist/cjs/hooks/useForceUpdateOnPageLoadedCompletely.js +14 -0
  42. package/dist/cjs/hooks/useLanguage.d.ts +9 -0
  43. package/dist/cjs/hooks/useLanguage.js +52 -0
  44. package/dist/cjs/hooks/useMatchMedia.d.ts +7 -0
  45. package/dist/cjs/hooks/useMatchMedia.js +39 -0
  46. package/dist/cjs/hooks/useTextProvider.d.ts +4 -0
  47. package/dist/cjs/hooks/useTextProvider.js +10 -0
  48. package/dist/cjs/hooks/useTheme.d.ts +5 -0
  49. package/dist/cjs/hooks/useTheme.js +28 -0
  50. package/dist/cjs/hooks/useUniqueId.d.ts +1 -0
  51. package/dist/cjs/hooks/useUniqueId.js +8 -0
  52. package/dist/cjs/index.d.ts +7 -0
  53. package/dist/cjs/index.js +23 -0
  54. package/dist/cjs/styles/default.d.ts +9 -0
  55. package/dist/cjs/styles/default.js +65 -0
  56. package/dist/cjs/styles/index.d.ts +1 -0
  57. package/dist/cjs/styles/index.js +17 -0
  58. package/dist/cjs/types/adaptive.d.ts +7 -0
  59. package/dist/cjs/types/adaptive.js +2 -0
  60. package/dist/cjs/types/general.d.ts +9 -0
  61. package/dist/cjs/types/general.js +2 -0
  62. package/dist/cjs/types/index.d.ts +5 -0
  63. package/dist/cjs/types/index.js +21 -0
  64. package/dist/cjs/types/language.d.ts +227 -0
  65. package/dist/cjs/types/language.js +231 -0
  66. package/dist/cjs/types/theme.d.ts +18 -0
  67. package/dist/cjs/types/theme.js +23 -0
  68. package/dist/cjs/types/withSupportProps.d.ts +4 -0
  69. package/dist/cjs/types/withSupportProps.js +2 -0
  70. package/dist/cjs/utils/alert.d.ts +2 -0
  71. package/dist/cjs/utils/alert.js +7 -0
  72. package/dist/cjs/utils/createTextProvider.d.ts +2 -0
  73. package/dist/cjs/utils/createTextProvider.js +16 -0
  74. package/dist/cjs/utils/excludeSupportProps.d.ts +3 -0
  75. package/dist/cjs/utils/excludeSupportProps.js +8 -0
  76. package/dist/cjs/utils/extractSupportProps.d.ts +1 -0
  77. package/dist/cjs/utils/extractSupportProps.js +8 -0
  78. package/dist/cjs/utils/getAdaptive.d.ts +5 -0
  79. package/dist/cjs/utils/getAdaptive.js +20 -0
  80. package/dist/cjs/utils/getDisplayMode.d.ts +3 -0
  81. package/dist/cjs/utils/getDisplayMode.js +28 -0
  82. package/dist/cjs/utils/getMatchMedia.d.ts +10 -0
  83. package/dist/cjs/utils/getMatchMedia.js +21 -0
  84. package/dist/cjs/utils/getUserAgentInfo.d.ts +20 -0
  85. package/dist/cjs/utils/getUserAgentInfo.js +29 -0
  86. package/dist/cjs/utils/index.d.ts +10 -0
  87. package/dist/cjs/utils/index.js +26 -0
  88. package/dist/cjs/utils/keyboardSelectHandler.d.ts +2 -0
  89. package/dist/cjs/utils/keyboardSelectHandler.js +10 -0
  90. package/dist/cjs/utils/private/constants.d.ts +1 -0
  91. package/dist/cjs/utils/private/constants.js +4 -0
  92. package/dist/cjs/utils/private/excludeProps.d.ts +3 -0
  93. package/dist/cjs/utils/private/excludeProps.js +8 -0
  94. package/dist/cjs/utils/private/extractProps.d.ts +1 -0
  95. package/dist/cjs/utils/private/extractProps.js +10 -0
  96. package/dist/cjs/utils/uniqueId.d.ts +8 -0
  97. package/dist/cjs/utils/uniqueId.js +13 -0
  98. package/dist/esm/components/ConfigProvider/ConfigProvider.d.ts +13 -0
  99. package/dist/esm/components/ConfigProvider/ConfigProvider.js +10 -0
  100. package/dist/esm/components/ConfigProvider/index.d.ts +1 -0
  101. package/dist/esm/components/ConfigProvider/index.js +1 -0
  102. package/dist/esm/components/ForThemeMode/ForThemeMode.d.ts +6 -0
  103. package/dist/esm/components/ForThemeMode/ForThemeMode.js +6 -0
  104. package/dist/esm/components/ForThemeMode/hooks.d.ts +6 -0
  105. package/dist/esm/components/ForThemeMode/hooks.js +10 -0
  106. package/dist/esm/components/ForThemeMode/index.d.ts +2 -0
  107. package/dist/esm/components/ForThemeMode/index.js +2 -0
  108. package/dist/esm/components/index.d.ts +2 -0
  109. package/dist/esm/components/index.js +2 -0
  110. package/dist/esm/constants/adaptive.d.ts +34 -0
  111. package/dist/esm/constants/adaptive.js +41 -0
  112. package/dist/esm/constants/displayMode.d.ts +16 -0
  113. package/dist/esm/constants/displayMode.js +21 -0
  114. package/dist/esm/constants/environment.d.ts +14 -0
  115. package/dist/esm/constants/environment.js +15 -0
  116. package/dist/esm/helpers/tryParseJson.d.ts +1 -0
  117. package/dist/esm/helpers/tryParseJson.js +12 -0
  118. package/dist/esm/hooks/index.d.ts +13 -0
  119. package/dist/esm/hooks/index.js +13 -0
  120. package/dist/esm/hooks/private/getCustomStore.d.ts +2 -0
  121. package/dist/esm/hooks/private/getCustomStore.js +8 -0
  122. package/dist/esm/hooks/useAdaptive.d.ts +4 -0
  123. package/dist/esm/hooks/useAdaptive.js +6 -0
  124. package/dist/esm/hooks/useBrand.d.ts +5 -0
  125. package/dist/esm/hooks/useBrand.js +24 -0
  126. package/dist/esm/hooks/useComponentSize.d.ts +5 -0
  127. package/dist/esm/hooks/useComponentSize.js +33 -0
  128. package/dist/esm/hooks/useConfig.d.ts +8 -0
  129. package/dist/esm/hooks/useConfig.js +120 -0
  130. package/dist/esm/hooks/useDisplayMode.d.ts +3 -0
  131. package/dist/esm/hooks/useDisplayMode.js +6 -0
  132. package/dist/esm/hooks/useEventHandler.d.ts +1 -0
  133. package/dist/esm/hooks/useEventHandler.js +14 -0
  134. package/dist/esm/hooks/useForceUpdate.d.ts +1 -0
  135. package/dist/esm/hooks/useForceUpdate.js +5 -0
  136. package/dist/esm/hooks/useForceUpdateOnPageLoadedCompletely.d.ts +1 -0
  137. package/dist/esm/hooks/useForceUpdateOnPageLoadedCompletely.js +11 -0
  138. package/dist/esm/hooks/useLanguage.d.ts +9 -0
  139. package/dist/esm/hooks/useLanguage.js +48 -0
  140. package/dist/esm/hooks/useMatchMedia.d.ts +7 -0
  141. package/dist/esm/hooks/useMatchMedia.js +33 -0
  142. package/dist/esm/hooks/useTextProvider.d.ts +4 -0
  143. package/dist/esm/hooks/useTextProvider.js +6 -0
  144. package/dist/esm/hooks/useTheme.d.ts +5 -0
  145. package/dist/esm/hooks/useTheme.js +24 -0
  146. package/dist/esm/hooks/useUniqueId.d.ts +1 -0
  147. package/dist/esm/hooks/useUniqueId.js +5 -0
  148. package/dist/esm/index.d.ts +7 -0
  149. package/dist/esm/index.js +7 -0
  150. package/dist/esm/styles/default.d.ts +9 -0
  151. package/dist/esm/styles/default.js +62 -0
  152. package/dist/esm/styles/index.d.ts +1 -0
  153. package/dist/esm/styles/index.js +1 -0
  154. package/dist/esm/types/adaptive.d.ts +7 -0
  155. package/dist/esm/types/adaptive.js +1 -0
  156. package/dist/esm/types/general.d.ts +9 -0
  157. package/dist/esm/types/general.js +1 -0
  158. package/dist/esm/types/index.d.ts +5 -0
  159. package/dist/esm/types/index.js +5 -0
  160. package/dist/esm/types/language.d.ts +227 -0
  161. package/dist/esm/types/language.js +228 -0
  162. package/dist/esm/types/theme.d.ts +18 -0
  163. package/dist/esm/types/theme.js +20 -0
  164. package/dist/esm/types/withSupportProps.d.ts +4 -0
  165. package/dist/esm/types/withSupportProps.js +1 -0
  166. package/dist/esm/utils/alert.d.ts +2 -0
  167. package/dist/esm/utils/alert.js +3 -0
  168. package/dist/esm/utils/createTextProvider.d.ts +2 -0
  169. package/dist/esm/utils/createTextProvider.js +13 -0
  170. package/dist/esm/utils/excludeSupportProps.d.ts +3 -0
  171. package/dist/esm/utils/excludeSupportProps.js +5 -0
  172. package/dist/esm/utils/extractSupportProps.d.ts +1 -0
  173. package/dist/esm/utils/extractSupportProps.js +5 -0
  174. package/dist/esm/utils/getAdaptive.d.ts +5 -0
  175. package/dist/esm/utils/getAdaptive.js +17 -0
  176. package/dist/esm/utils/getDisplayMode.d.ts +3 -0
  177. package/dist/esm/utils/getDisplayMode.js +25 -0
  178. package/dist/esm/utils/getMatchMedia.d.ts +10 -0
  179. package/dist/esm/utils/getMatchMedia.js +14 -0
  180. package/dist/esm/utils/getUserAgentInfo.d.ts +20 -0
  181. package/dist/esm/utils/getUserAgentInfo.js +26 -0
  182. package/dist/esm/utils/index.d.ts +10 -0
  183. package/dist/esm/utils/index.js +10 -0
  184. package/dist/esm/utils/keyboardSelectHandler.d.ts +2 -0
  185. package/dist/esm/utils/keyboardSelectHandler.js +7 -0
  186. package/dist/esm/utils/private/constants.d.ts +1 -0
  187. package/dist/esm/utils/private/constants.js +1 -0
  188. package/dist/esm/utils/private/excludeProps.d.ts +3 -0
  189. package/dist/esm/utils/private/excludeProps.js +5 -0
  190. package/dist/esm/utils/private/extractProps.d.ts +1 -0
  191. package/dist/esm/utils/private/extractProps.js +7 -0
  192. package/dist/esm/utils/uniqueId.d.ts +8 -0
  193. package/dist/esm/utils/uniqueId.js +10 -0
  194. package/package.json +21 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.0.2 (2025-11-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PD-3377:** move token deps back to peers ([1b99749](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/1b99749040515e23e094f814dbf46291a317c3ae))
12
+
13
+
14
+
15
+
16
+
17
+ ## 7.0.1 (2025-11-12)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **PD-3377:** contributors update to publish all packages ([719fd3e](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/719fd3e1249e247443b125c47ea408d92c8395c3))
23
+
24
+
25
+
26
+
27
+
6
28
  # 7.0.0 (2025-11-12)
7
29
 
8
30
 
@@ -0,0 +1,13 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { Brand, LanguageCodeType, Themes } from '../../types';
3
+ export type ConfigProviderProps = PropsWithChildren<{
4
+ languageCode?: LanguageCodeType;
5
+ theme?: Themes;
6
+ brand?: Brand;
7
+ }>;
8
+ export declare function ConfigProvider({ languageCode, theme, brand, children }: ConfigProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare namespace ConfigProvider {
10
+ var brand: typeof Brand;
11
+ var themes: typeof Themes;
12
+ var languages: typeof LanguageCodeType;
13
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigProvider = ConfigProvider;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const useConfig_1 = require("../../hooks/useConfig");
6
+ const types_1 = require("../../types");
7
+ function ConfigProvider({ languageCode, theme, brand, children }) {
8
+ (0, useConfig_1.useConfig)({ languageCode, theme, brand });
9
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
10
+ }
11
+ ConfigProvider.brand = types_1.Brand;
12
+ ConfigProvider.themes = types_1.Themes;
13
+ ConfigProvider.languages = types_1.LanguageCodeType;
@@ -0,0 +1 @@
1
+ export * from './ConfigProvider';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ConfigProvider"), exports);
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export type ForThemeModeProps = {
3
+ light: ReactNode;
4
+ dark: ReactNode;
5
+ };
6
+ export declare function ForThemeMode(props: ForThemeModeProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForThemeMode = ForThemeMode;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const hooks_1 = require("./hooks");
6
+ function ForThemeMode(props) {
7
+ const jsx = (0, hooks_1.useForThemeMode)(props);
8
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: jsx });
9
+ }
@@ -0,0 +1,6 @@
1
+ type UseForThemeModeParams<L, D> = {
2
+ light: L;
3
+ dark: D;
4
+ };
5
+ export declare function useForThemeMode<L, D>({ light, dark }: UseForThemeModeParams<L, D>): L | D;
6
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useForThemeMode = useForThemeMode;
4
+ const hooks_1 = require("../../hooks");
5
+ const theme_1 = require("../../types/theme");
6
+ const DARK_THEMES = [theme_1.Themes.GreenDark, theme_1.Themes.PurpleDark];
7
+ const DARK_BRANDS = [theme_1.Brand.CloudDark, theme_1.Brand.MLSpaceDark, theme_1.Brand.AdminDark, theme_1.Brand.SiteDark, theme_1.Brand.GigaIdDark];
8
+ function useForThemeMode({ light, dark }) {
9
+ const { theme } = (0, hooks_1.useTheme)();
10
+ const { brand } = (0, hooks_1.useBrand)();
11
+ const isDarkTheme = DARK_THEMES.includes(theme) || DARK_BRANDS.includes(brand);
12
+ return isDarkTheme ? dark : light;
13
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ForThemeMode';
2
+ export * from './hooks';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ForThemeMode"), exports);
18
+ __exportStar(require("./hooks"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './ConfigProvider';
2
+ export * from './ForThemeMode';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ConfigProvider"), exports);
18
+ __exportStar(require("./ForThemeMode"), exports);
@@ -0,0 +1,34 @@
1
+ export declare const Adaptive: {
2
+ mobile: number;
3
+ tablet: number;
4
+ smallDesktop: number;
5
+ desktop: number;
6
+ };
7
+ export declare const CSS_BREAKPOINTS: {
8
+ mobile: string;
9
+ tablet: string;
10
+ smallDesktop: string;
11
+ desktop: string;
12
+ large: string;
13
+ };
14
+ export declare const LAYOUT_TYPE: {
15
+ readonly Mobile: "mobile";
16
+ readonly Tablet: "tablet";
17
+ readonly Desktop: "desktop";
18
+ readonly DesktopSmall: "desktopSmall";
19
+ };
20
+ export declare enum AdaptiveQueriesTitle {
21
+ IsMobile = "isMobile",
22
+ IsTablet = "isTablet",
23
+ IsSmallDesktop = "isSmallDesktop",
24
+ IsDesktop = "isDesktop",
25
+ IsLarge = "isLarge"
26
+ }
27
+ export declare const ADAPTIVE_QUERIES: Record<AdaptiveQueriesTitle, string>;
28
+ export declare const INITIAL_ADAPTIVE_QUERIES_VALUE: {
29
+ isMobile: boolean;
30
+ isTablet: boolean;
31
+ isSmallDesktop: boolean;
32
+ isDesktop: boolean;
33
+ isLarge: boolean;
34
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INITIAL_ADAPTIVE_QUERIES_VALUE = exports.ADAPTIVE_QUERIES = exports.AdaptiveQueriesTitle = exports.LAYOUT_TYPE = exports.CSS_BREAKPOINTS = exports.Adaptive = void 0;
4
+ exports.Adaptive = {
5
+ mobile: 767,
6
+ tablet: 1023,
7
+ smallDesktop: 1279,
8
+ desktop: 1439,
9
+ };
10
+ exports.CSS_BREAKPOINTS = {
11
+ mobile: `(max-width: ${exports.Adaptive.mobile}px)`,
12
+ tablet: `(max-width: ${exports.Adaptive.tablet}px)`,
13
+ smallDesktop: `(max-width: ${exports.Adaptive.smallDesktop}px)`,
14
+ desktop: `(max-width: ${exports.Adaptive.desktop}px)`,
15
+ large: `(min-width: ${exports.Adaptive.desktop + 1}px)`,
16
+ };
17
+ exports.LAYOUT_TYPE = {
18
+ Mobile: 'mobile',
19
+ Tablet: 'tablet',
20
+ Desktop: 'desktop',
21
+ DesktopSmall: 'desktopSmall',
22
+ };
23
+ var AdaptiveQueriesTitle;
24
+ (function (AdaptiveQueriesTitle) {
25
+ AdaptiveQueriesTitle["IsMobile"] = "isMobile";
26
+ AdaptiveQueriesTitle["IsTablet"] = "isTablet";
27
+ AdaptiveQueriesTitle["IsSmallDesktop"] = "isSmallDesktop";
28
+ AdaptiveQueriesTitle["IsDesktop"] = "isDesktop";
29
+ AdaptiveQueriesTitle["IsLarge"] = "isLarge";
30
+ })(AdaptiveQueriesTitle || (exports.AdaptiveQueriesTitle = AdaptiveQueriesTitle = {}));
31
+ exports.ADAPTIVE_QUERIES = {
32
+ [AdaptiveQueriesTitle.IsMobile]: exports.CSS_BREAKPOINTS.mobile,
33
+ [AdaptiveQueriesTitle.IsTablet]: exports.CSS_BREAKPOINTS.tablet,
34
+ [AdaptiveQueriesTitle.IsSmallDesktop]: exports.CSS_BREAKPOINTS.smallDesktop,
35
+ [AdaptiveQueriesTitle.IsDesktop]: exports.CSS_BREAKPOINTS.desktop,
36
+ [AdaptiveQueriesTitle.IsLarge]: exports.CSS_BREAKPOINTS.large,
37
+ };
38
+ exports.INITIAL_ADAPTIVE_QUERIES_VALUE = {
39
+ [AdaptiveQueriesTitle.IsMobile]: false,
40
+ [AdaptiveQueriesTitle.IsTablet]: false,
41
+ [AdaptiveQueriesTitle.IsSmallDesktop]: false,
42
+ [AdaptiveQueriesTitle.IsDesktop]: false,
43
+ [AdaptiveQueriesTitle.IsLarge]: false,
44
+ };
@@ -0,0 +1,16 @@
1
+ import { MatchMediaGeneric } from '../types';
2
+ export declare const DISPLAY_MODES: {
3
+ Browser: string;
4
+ Pwa: string;
5
+ Fullscreen: string;
6
+ MinimalUI: string;
7
+ WindowControlsOverlay: string;
8
+ };
9
+ export declare const DISPLAY_MODE_QUERIES: {
10
+ isBrowser: string;
11
+ isPwa: string;
12
+ isFullscreen: string;
13
+ isMinimalUI: string;
14
+ isWindowControlsOverlay: string;
15
+ };
16
+ export declare const INITIAL_DISPLAY_MODE_QUERIES_VALUE: MatchMediaGeneric<keyof typeof DISPLAY_MODE_QUERIES>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INITIAL_DISPLAY_MODE_QUERIES_VALUE = exports.DISPLAY_MODE_QUERIES = exports.DISPLAY_MODES = void 0;
4
+ exports.DISPLAY_MODES = {
5
+ Browser: 'browser',
6
+ Pwa: 'pwa',
7
+ Fullscreen: 'fullscreen',
8
+ MinimalUI: 'minimal-ui',
9
+ WindowControlsOverlay: 'window-controls-overlay',
10
+ };
11
+ exports.DISPLAY_MODE_QUERIES = {
12
+ isBrowser: `(display-mode: browser)`,
13
+ isPwa: `(display-mode: standalone)`,
14
+ isFullscreen: `(display-mode: fullscreen)`,
15
+ isMinimalUI: `(display-mode: minimal-ui)`,
16
+ isWindowControlsOverlay: `(display-mode: window-controls-overlay)`,
17
+ };
18
+ exports.INITIAL_DISPLAY_MODE_QUERIES_VALUE = {
19
+ isBrowser: false,
20
+ isPwa: false,
21
+ isFullscreen: false,
22
+ isMinimalUI: false,
23
+ isWindowControlsOverlay: false,
24
+ };
@@ -0,0 +1,14 @@
1
+ import { Brand, LanguageCodeType, Themes } from '../types';
2
+ export declare const DEFAULT: {
3
+ LANGUAGE: LanguageCodeType;
4
+ BRAND: Brand;
5
+ THEME: Themes;
6
+ };
7
+ export declare enum POST_MESSAGE_KEY {
8
+ changeTheme = "changeTheme",
9
+ changeThemeDone = "changeThemeDone",
10
+ changeBrand = "changeBrand",
11
+ changeBrandDone = "changeBrandDone",
12
+ changeLanguage = "changeLanguage",
13
+ changeLanguageDone = "changeLanguageDone"
14
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POST_MESSAGE_KEY = exports.DEFAULT = void 0;
4
+ const types_1 = require("../types");
5
+ exports.DEFAULT = {
6
+ LANGUAGE: types_1.LanguageCodeType.ruRU,
7
+ BRAND: types_1.Brand.Cloud,
8
+ THEME: types_1.Themes.Purple,
9
+ };
10
+ var POST_MESSAGE_KEY;
11
+ (function (POST_MESSAGE_KEY) {
12
+ POST_MESSAGE_KEY["changeTheme"] = "changeTheme";
13
+ POST_MESSAGE_KEY["changeThemeDone"] = "changeThemeDone";
14
+ POST_MESSAGE_KEY["changeBrand"] = "changeBrand";
15
+ POST_MESSAGE_KEY["changeBrandDone"] = "changeBrandDone";
16
+ POST_MESSAGE_KEY["changeLanguage"] = "changeLanguage";
17
+ POST_MESSAGE_KEY["changeLanguageDone"] = "changeLanguageDone";
18
+ })(POST_MESSAGE_KEY || (exports.POST_MESSAGE_KEY = POST_MESSAGE_KEY = {}));
@@ -0,0 +1 @@
1
+ export declare function tryParseJson<T>(value: T): T | Record<string, unknown>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryParseJson = tryParseJson;
4
+ function isValidJson(value) {
5
+ try {
6
+ JSON.parse(value);
7
+ return true;
8
+ }
9
+ catch (_a) {
10
+ return false;
11
+ }
12
+ }
13
+ function tryParseJson(value) {
14
+ return typeof value === 'string' && isValidJson(value) ? JSON.parse(value) : value;
15
+ }
@@ -0,0 +1,13 @@
1
+ export * from './useLanguage';
2
+ export * from './useComponentSize';
3
+ export * from './useTheme';
4
+ export * from './useBrand';
5
+ export * from './useForceUpdate';
6
+ export * from './useForceUpdateOnPageLoadedCompletely';
7
+ export * from './useEventHandler';
8
+ export * from './useUniqueId';
9
+ export * from './useConfig';
10
+ export * from './useTextProvider';
11
+ export * from './useAdaptive';
12
+ export * from './useDisplayMode';
13
+ export * from './useMatchMedia';
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useLanguage"), exports);
18
+ __exportStar(require("./useComponentSize"), exports);
19
+ __exportStar(require("./useTheme"), exports);
20
+ __exportStar(require("./useBrand"), exports);
21
+ __exportStar(require("./useForceUpdate"), exports);
22
+ __exportStar(require("./useForceUpdateOnPageLoadedCompletely"), exports);
23
+ __exportStar(require("./useEventHandler"), exports);
24
+ __exportStar(require("./useUniqueId"), exports);
25
+ __exportStar(require("./useConfig"), exports);
26
+ __exportStar(require("./useTextProvider"), exports);
27
+ __exportStar(require("./useAdaptive"), exports);
28
+ __exportStar(require("./useDisplayMode"), exports);
29
+ __exportStar(require("./useMatchMedia"), exports);
@@ -0,0 +1,2 @@
1
+ import { WindowStore } from '../../types';
2
+ export declare function getCustomStore(defaultStore?: Partial<WindowStore['sbercloudUIKit']>): WindowStore['sbercloudUIKit'];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomStore = getCustomStore;
4
+ const environment_1 = require("../../constants/environment");
5
+ function getCustomStore(defaultStore = {}) {
6
+ const customWindow = globalThis;
7
+ if (!customWindow.sbercloudUIKit) {
8
+ customWindow.sbercloudUIKit = Object.assign({ brand: environment_1.DEFAULT.BRAND, theme: environment_1.DEFAULT.THEME, languageCode: environment_1.DEFAULT.LANGUAGE }, defaultStore);
9
+ }
10
+ return customWindow.sbercloudUIKit;
11
+ }
@@ -0,0 +1,4 @@
1
+ import { LayoutType } from '../types/adaptive';
2
+ export declare function useAdaptive(): {
3
+ layoutType: LayoutType;
4
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAdaptive = useAdaptive;
4
+ const utils_1 = require("../utils");
5
+ const useMatchMedia_1 = require("./useMatchMedia");
6
+ function useAdaptive() {
7
+ const matchMedia = (0, useMatchMedia_1.useAdaptiveMatchMedia)();
8
+ return (0, utils_1.getAdaptive)(matchMedia);
9
+ }
@@ -0,0 +1,5 @@
1
+ import { Brand } from '../types/theme';
2
+ export declare const useBrand: () => {
3
+ brand: Brand;
4
+ changeBrand: (brand: Brand) => void;
5
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBrand = void 0;
4
+ const react_1 = require("react");
5
+ const utils_1 = require("@snack-uikit/utils");
6
+ const environment_1 = require("../constants/environment");
7
+ const tryParseJson_1 = require("../helpers/tryParseJson");
8
+ const getCustomStore_1 = require("./private/getCustomStore");
9
+ const useBrand = () => {
10
+ const store = (0, getCustomStore_1.getCustomStore)();
11
+ const [brand, setBrand] = (0, react_1.useState)(store.brand || environment_1.DEFAULT.BRAND);
12
+ (0, react_1.useEffect)(() => {
13
+ const receiveChangeThemeDoneMessage = (event) => {
14
+ const eventData = (0, tryParseJson_1.tryParseJson)(event.data);
15
+ if (eventData.key !== environment_1.POST_MESSAGE_KEY.changeBrandDone)
16
+ return;
17
+ setBrand(eventData.value);
18
+ };
19
+ window.addEventListener('message', receiveChangeThemeDoneMessage, false);
20
+ return () => window.removeEventListener('message', receiveChangeThemeDoneMessage, false);
21
+ }, []);
22
+ const changeBrand = (0, react_1.useCallback)((brand) => {
23
+ (0, utils_1.isBrowser)() &&
24
+ window.postMessage(JSON.stringify({ key: environment_1.POST_MESSAGE_KEY.changeBrand, value: brand }), location.origin);
25
+ }, []);
26
+ return { brand, changeBrand };
27
+ };
28
+ exports.useBrand = useBrand;
@@ -0,0 +1,5 @@
1
+ import { RefObject } from 'react';
2
+ export declare function useComponentSize(ref: RefObject<HTMLElement>): {
3
+ width: number;
4
+ height: number;
5
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useComponentSize = useComponentSize;
4
+ const react_1 = require("react");
5
+ const utils_1 = require("@snack-uikit/utils");
6
+ function getSize(el) {
7
+ if (!el) {
8
+ return {
9
+ width: 0,
10
+ height: 0,
11
+ };
12
+ }
13
+ return {
14
+ width: el.offsetWidth,
15
+ height: el.offsetHeight,
16
+ };
17
+ }
18
+ function useComponentSize(ref) {
19
+ const [size, setSize] = (0, react_1.useState)(getSize(ref.current));
20
+ const handleResize = (0, react_1.useCallback)(() => {
21
+ if (ref.current) {
22
+ setSize(getSize(ref.current));
23
+ }
24
+ }, [ref]);
25
+ (0, utils_1.useLayoutEffect)(() => {
26
+ if (!ref.current)
27
+ return;
28
+ handleResize();
29
+ const resizeObserver = new ResizeObserver(handleResize);
30
+ resizeObserver.observe(ref.current);
31
+ return () => {
32
+ resizeObserver.disconnect();
33
+ };
34
+ }, [handleResize, ref]);
35
+ return size;
36
+ }
@@ -0,0 +1,8 @@
1
+ import { Brand, LanguageCodeType, Themes } from '../types';
2
+ type UseConfigProps = {
3
+ languageCode?: LanguageCodeType;
4
+ theme?: Themes;
5
+ brand?: Brand;
6
+ };
7
+ export declare function useConfig({ languageCode, theme, brand }: UseConfigProps): void;
8
+ export {};
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useConfig = useConfig;
7
+ const react_1 = require("react");
8
+ const brand_module_css_1 = __importDefault(require("@sbercloud/figma-tokens-admin/build/css/brand.module.css"));
9
+ const brand_module_css_2 = __importDefault(require("@sbercloud/figma-tokens-cloud-platform/build/css/brand.module.css"));
10
+ const brand_module_css_3 = __importDefault(require("@sbercloud/figma-tokens-giga-id/build/css/brand.module.css"));
11
+ const brand_module_css_4 = __importDefault(require("@sbercloud/figma-tokens-mlspace/build/css/brand.module.css"));
12
+ const brand_module_css_5 = __importDefault(require("@sbercloud/figma-tokens-web/build/css/brand.module.css"));
13
+ const utils_1 = require("@snack-uikit/utils");
14
+ const environment_1 = require("../constants/environment");
15
+ const tryParseJson_1 = require("../helpers/tryParseJson");
16
+ const types_1 = require("../types");
17
+ const getCustomStore_1 = require("./private/getCustomStore");
18
+ const themeMap = {
19
+ [types_1.Themes.Green]: brand_module_css_2.default.light,
20
+ [types_1.Themes.GreenDark]: brand_module_css_2.default.dark,
21
+ [types_1.Themes.Purple]: brand_module_css_4.default.light,
22
+ [types_1.Themes.PurpleDark]: brand_module_css_4.default.dark,
23
+ };
24
+ const brandMap = {
25
+ [types_1.Brand.Cloud]: brand_module_css_2.default.light,
26
+ [types_1.Brand.CloudDark]: brand_module_css_2.default.dark,
27
+ [types_1.Brand.MLSpace]: brand_module_css_4.default.light,
28
+ [types_1.Brand.MLSpaceDark]: brand_module_css_4.default.dark,
29
+ [types_1.Brand.Admin]: brand_module_css_1.default.light,
30
+ [types_1.Brand.AdminDark]: brand_module_css_1.default.dark,
31
+ [types_1.Brand.Site]: brand_module_css_5.default.light,
32
+ [types_1.Brand.SiteDark]: brand_module_css_5.default.dark,
33
+ [types_1.Brand.GigaId]: brand_module_css_3.default.light,
34
+ [types_1.Brand.GigaIdDark]: brand_module_css_3.default.dark,
35
+ };
36
+ function useConfig({ languageCode, theme, brand }) {
37
+ const store = (0, getCustomStore_1.getCustomStore)({ brand, theme, languageCode });
38
+ const [configLanguageCode, setConfigLanguageCodeTheme] = (0, react_1.useState)(store.languageCode);
39
+ const previousThemeRef = (0, react_1.useRef)();
40
+ const previousBrandRef = (0, react_1.useRef)();
41
+ const updateTheme = (0, react_1.useCallback)((newTheme) => {
42
+ if ((0, utils_1.isBrowser)()) {
43
+ store.theme = newTheme;
44
+ const html = document.getElementsByTagName('html')[0];
45
+ if (previousThemeRef.current) {
46
+ html.classList.remove(themeMap[previousThemeRef.current]);
47
+ }
48
+ html.setAttribute('data-theme', newTheme);
49
+ const body = document.getElementsByTagName('body')[0];
50
+ body.setAttribute('data-theme', newTheme);
51
+ html.classList.add(themeMap[newTheme]);
52
+ window.postMessage(JSON.stringify({ key: environment_1.POST_MESSAGE_KEY.changeThemeDone, value: newTheme }), location.origin);
53
+ previousThemeRef.current = newTheme;
54
+ }
55
+ }, [store]);
56
+ const updateBrand = (0, react_1.useCallback)((newBrand) => {
57
+ if ((0, utils_1.isBrowser)()) {
58
+ store.brand = newBrand;
59
+ const html = document.getElementsByTagName('html')[0];
60
+ if (previousBrandRef.current) {
61
+ html.classList.remove(brandMap[previousBrandRef.current]);
62
+ }
63
+ html.setAttribute('data-brand', newBrand);
64
+ const body = document.getElementsByTagName('body')[0];
65
+ body.setAttribute('data-brand', newBrand);
66
+ html.classList.add(brandMap[newBrand]);
67
+ window.postMessage(JSON.stringify({ key: environment_1.POST_MESSAGE_KEY.changeBrandDone, value: newBrand }), location.origin);
68
+ previousBrandRef.current = newBrand;
69
+ }
70
+ }, [store]);
71
+ (0, react_1.useEffect)(() => {
72
+ /*-----------
73
+ --- THEME/BRAND ---
74
+ -----------*/
75
+ const receiveChangeThemeMessage = (event) => {
76
+ const eventData = (0, tryParseJson_1.tryParseJson)(event.data);
77
+ switch (eventData.key) {
78
+ case environment_1.POST_MESSAGE_KEY.changeTheme:
79
+ updateTheme(eventData.value);
80
+ break;
81
+ case environment_1.POST_MESSAGE_KEY.changeBrand:
82
+ updateBrand(eventData.value);
83
+ break;
84
+ default:
85
+ return;
86
+ }
87
+ };
88
+ window.addEventListener('message', receiveChangeThemeMessage, false);
89
+ /*--------------
90
+ --- LANGUAGE ---
91
+ --------------*/
92
+ const receiveChangeLanguageMessage = (event) => {
93
+ const eventData = (0, tryParseJson_1.tryParseJson)(event.data);
94
+ if (eventData.key !== environment_1.POST_MESSAGE_KEY.changeLanguage)
95
+ return;
96
+ setConfigLanguageCodeTheme(eventData.value);
97
+ };
98
+ window.addEventListener('message', receiveChangeLanguageMessage, false);
99
+ return () => {
100
+ window.removeEventListener('message', receiveChangeThemeMessage, false);
101
+ window.removeEventListener('message', receiveChangeLanguageMessage, false);
102
+ };
103
+ }, [updateBrand, updateTheme]);
104
+ /*-------------
105
+ ---- THEME ----
106
+ -------------*/
107
+ // need to do it this way to update theme before any other child component render & useEffect/useLayoutEffect
108
+ if (previousThemeRef.current !== theme && theme) {
109
+ updateTheme(theme);
110
+ }
111
+ if (previousBrandRef.current !== brand && brand) {
112
+ updateBrand(brand);
113
+ }
114
+ /*--------------
115
+ --- LANGUAGE ---
116
+ --------------*/
117
+ (0, utils_1.useLayoutEffect)(() => {
118
+ if (languageCode) {
119
+ store.languageCode = languageCode;
120
+ setConfigLanguageCodeTheme(store.languageCode);
121
+ }
122
+ }, [languageCode, store]);
123
+ (0, react_1.useEffect)(() => {
124
+ window.postMessage(JSON.stringify({ key: environment_1.POST_MESSAGE_KEY.changeLanguageDone, value: configLanguageCode }), location.origin);
125
+ }, [configLanguageCode]);
126
+ }
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { DISPLAY_MODES } from '../constants/displayMode';
3
+ export declare function useDisplayMode(): 'unknown' | 'twa' | ValueOf<typeof DISPLAY_MODES>;