@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
@@ -0,0 +1,20 @@
1
+ export var Themes;
2
+ (function (Themes) {
3
+ Themes["Purple"] = "purple";
4
+ Themes["PurpleDark"] = "purpleDark";
5
+ Themes["Green"] = "green";
6
+ Themes["GreenDark"] = "greenDark";
7
+ })(Themes || (Themes = {}));
8
+ export var Brand;
9
+ (function (Brand) {
10
+ Brand["Cloud"] = "Cloud";
11
+ Brand["CloudDark"] = "CloudDark";
12
+ Brand["MLSpace"] = "MLSpace";
13
+ Brand["MLSpaceDark"] = "MLSpaceDark";
14
+ Brand["Site"] = "Site";
15
+ Brand["SiteDark"] = "SiteDark";
16
+ Brand["Admin"] = "Admin";
17
+ Brand["AdminDark"] = "AdminDark";
18
+ Brand["GigaId"] = "GigaId";
19
+ Brand["GigaIdDark"] = "GigaIdDark";
20
+ })(Brand || (Brand = {}));
@@ -0,0 +1,4 @@
1
+ import { AriaAttributes } from 'react';
2
+ export type WithSupportProps<T> = {
3
+ 'data-test-id'?: string;
4
+ } & AriaAttributes & T;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const error: (message: string, localCondition?: boolean) => void, warning: (message: string, localCondition?: boolean) => void;
2
+ export { error, warning };
@@ -0,0 +1,3 @@
1
+ import { configureDevAlerts } from '@cloud-ru/ft-debug-mode';
2
+ const { error, warning } = configureDevAlerts({ scope: 'uikit-product', enabled: true });
3
+ export { error, warning };
@@ -0,0 +1,2 @@
1
+ import { LanguageCodeType } from '../types/language';
2
+ export declare function createTextProvider<T extends string = string, V = string>(dictionary: Partial<Record<LanguageCodeType, Record<T, V>>>, packageName: string): <R extends V>(language: LanguageCodeType, entity: T) => R;
@@ -0,0 +1,13 @@
1
+ import { LanguageCodeType } from '../types/language';
2
+ export function createTextProvider(dictionary, packageName) {
3
+ return (language, entity) => {
4
+ var _a;
5
+ const langKey = language === LanguageCodeType.cimode ? LanguageCodeType.ruRU : language;
6
+ const value = ((_a = dictionary === null || dictionary === void 0 ? void 0 : dictionary[langKey]) === null || _a === void 0 ? void 0 : _a[entity]) || '';
7
+ if (language === LanguageCodeType.cimode) {
8
+ const key = `uikit-${packageName}.${entity}`;
9
+ return (value instanceof Function ? () => key : key);
10
+ }
11
+ return value;
12
+ };
13
+ }
@@ -0,0 +1,3 @@
1
+ export declare function excludeSupportProps(props: Record<string, unknown>): {
2
+ [x: string]: unknown;
3
+ };
@@ -0,0 +1,5 @@
1
+ import { DATA_AND_ARIA_REGEXP } from './private/constants';
2
+ import { excludeProps } from './private/excludeProps';
3
+ export function excludeSupportProps(props) {
4
+ return excludeProps(props, DATA_AND_ARIA_REGEXP);
5
+ }
@@ -0,0 +1 @@
1
+ export declare function extractSupportProps(props: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,5 @@
1
+ import { DATA_AND_ARIA_REGEXP } from './private/constants';
2
+ import { extractProps } from './private/extractProps';
3
+ export function extractSupportProps(props) {
4
+ return extractProps(props, DATA_AND_ARIA_REGEXP);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { AdaptiveQueriesTitle } from '../constants/adaptive';
2
+ import { LayoutType, MatchMediaGeneric } from '../types/adaptive';
3
+ export declare function getAdaptive({ isMobile }: MatchMediaGeneric<AdaptiveQueriesTitle>): {
4
+ layoutType: LayoutType;
5
+ };
@@ -0,0 +1,17 @@
1
+ import { getUserAgentInfo } from './getUserAgentInfo';
2
+ export function getAdaptive({ isMobile }) {
3
+ const { device } = getUserAgentInfo();
4
+ let layoutType;
5
+ switch (device.type) {
6
+ case 'mobile':
7
+ layoutType = 'mobile';
8
+ break;
9
+ case 'tablet':
10
+ layoutType = 'tablet';
11
+ break;
12
+ default:
13
+ layoutType = isMobile ? 'desktopSmall' : 'desktop';
14
+ break;
15
+ }
16
+ return { layoutType };
17
+ }
@@ -0,0 +1,3 @@
1
+ import { DISPLAY_MODE_QUERIES } from '../constants/displayMode';
2
+ import { MatchMediaGeneric } from '../types';
3
+ export declare function getDisplayMode(matchMedia: MatchMediaGeneric<keyof typeof DISPLAY_MODE_QUERIES>): string;
@@ -0,0 +1,25 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
2
+ import { DISPLAY_MODES } from '../constants/displayMode';
3
+ export function getDisplayMode(matchMedia) {
4
+ if (isBrowser()) {
5
+ if (document.referrer.startsWith('android-app://')) {
6
+ return 'twa';
7
+ }
8
+ if (matchMedia.isBrowser) {
9
+ return DISPLAY_MODES.Browser;
10
+ }
11
+ if (matchMedia.isPwa) {
12
+ return DISPLAY_MODES.Pwa;
13
+ }
14
+ if (matchMedia.isFullscreen) {
15
+ return DISPLAY_MODES.Fullscreen;
16
+ }
17
+ if (matchMedia.isMinimalUI) {
18
+ return DISPLAY_MODES.MinimalUI;
19
+ }
20
+ if (matchMedia.isWindowControlsOverlay) {
21
+ return DISPLAY_MODES.WindowControlsOverlay;
22
+ }
23
+ }
24
+ return 'unknown';
25
+ }
@@ -0,0 +1,10 @@
1
+ import { MatchMediaGeneric } from '../types';
2
+ export declare function getMediaQueryListGeneric<T extends string>({ queryValues }: {
3
+ queryValues: Record<T, string>;
4
+ }): Array<[T, MediaQueryList]>;
5
+ export declare function getMatchMediaGeneric<T extends string>({ queryValues, initialValues, }: {
6
+ queryValues: Record<T, string>;
7
+ initialValues: MatchMediaGeneric<T>;
8
+ }): MatchMediaGeneric<T>;
9
+ export declare const getAdaptiveMatchMedia: () => MatchMediaGeneric<import("../constants/adaptive").AdaptiveQueriesTitle>;
10
+ export declare const getDisplayModeMatchMedia: () => MatchMediaGeneric<"isBrowser" | "isPwa" | "isFullscreen" | "isMinimalUI" | "isWindowControlsOverlay">;
@@ -0,0 +1,14 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
2
+ import { ADAPTIVE_QUERIES, INITIAL_ADAPTIVE_QUERIES_VALUE } from '../constants/adaptive';
3
+ import { DISPLAY_MODE_QUERIES, INITIAL_DISPLAY_MODE_QUERIES_VALUE } from '../constants/displayMode';
4
+ function getMediaQueries({ queryValues }) {
5
+ return Object.keys(queryValues).reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: isBrowser() ? globalThis.matchMedia(queryValues[key]) : undefined })), {});
6
+ }
7
+ export function getMediaQueryListGeneric({ queryValues }) {
8
+ return Object.entries(getMediaQueries({ queryValues }));
9
+ }
10
+ export function getMatchMediaGeneric({ queryValues, initialValues, }) {
11
+ return getMediaQueryListGeneric({ queryValues }).reduce((acc, [key, q]) => (Object.assign(Object.assign({}, acc), { [key]: (q === null || q === void 0 ? void 0 : q.matches) || false })), initialValues);
12
+ }
13
+ export const getAdaptiveMatchMedia = () => getMatchMediaGeneric({ queryValues: ADAPTIVE_QUERIES, initialValues: INITIAL_ADAPTIVE_QUERIES_VALUE });
14
+ export const getDisplayModeMatchMedia = () => getMatchMediaGeneric({ queryValues: DISPLAY_MODE_QUERIES, initialValues: INITIAL_DISPLAY_MODE_QUERIES_VALUE });
@@ -0,0 +1,20 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ declare const DEVICE_TYPE: {
3
+ readonly Console: "console";
4
+ readonly Mobile: "mobile";
5
+ readonly Tablet: "tablet";
6
+ readonly Smarttv: "smarttv";
7
+ readonly Wearable: "wearable";
8
+ readonly Embedded: "embedded";
9
+ readonly Desktop: "desktop";
10
+ };
11
+ type DeviceType = ValueOf<typeof DEVICE_TYPE>;
12
+ export declare function getUserAgentInfo(): {
13
+ device: {
14
+ model: string | undefined;
15
+ type: DeviceType;
16
+ };
17
+ os: import("ua-parser-js").IOS;
18
+ browser: import("ua-parser-js").IBrowser;
19
+ };
20
+ export {};
@@ -0,0 +1,26 @@
1
+ import { UAParser } from 'ua-parser-js';
2
+ const DEVICE_TYPE = {
3
+ Console: 'console',
4
+ Mobile: 'mobile',
5
+ Tablet: 'tablet',
6
+ Smarttv: 'smarttv',
7
+ Wearable: 'wearable',
8
+ Embedded: 'embedded',
9
+ Desktop: 'desktop',
10
+ };
11
+ const DEVICE_TYPES = Object.values(DEVICE_TYPE);
12
+ const getDeviceType = (type) => DEVICE_TYPES.find(value => value === type) || DEVICE_TYPE.Desktop;
13
+ export function getUserAgentInfo() {
14
+ const parser = new UAParser(globalThis.navigator.userAgent);
15
+ const device = parser.getDevice();
16
+ const browser = parser.getBrowser();
17
+ const os = parser.getOS();
18
+ return {
19
+ device: {
20
+ model: device.model,
21
+ type: getDeviceType(device.type),
22
+ },
23
+ os,
24
+ browser,
25
+ };
26
+ }
@@ -0,0 +1,10 @@
1
+ export * from './alert';
2
+ export * from './createTextProvider';
3
+ export * from './excludeSupportProps';
4
+ export * from './extractSupportProps';
5
+ export * from './getAdaptive';
6
+ export * from './getDisplayMode';
7
+ export * from './getMatchMedia';
8
+ export * from './getUserAgentInfo';
9
+ export * from './keyboardSelectHandler';
10
+ export * from './uniqueId';
@@ -0,0 +1,10 @@
1
+ export * from './alert';
2
+ export * from './createTextProvider';
3
+ export * from './excludeSupportProps';
4
+ export * from './extractSupportProps';
5
+ export * from './getAdaptive';
6
+ export * from './getDisplayMode';
7
+ export * from './getMatchMedia';
8
+ export * from './getUserAgentInfo';
9
+ export * from './keyboardSelectHandler';
10
+ export * from './uniqueId';
@@ -0,0 +1,2 @@
1
+ import { KeyboardEvent } from 'react';
2
+ export declare function keyboardSelectHandler<T>(callback: (event?: KeyboardEvent<T>) => void): (event: KeyboardEvent<T>) => void;
@@ -0,0 +1,7 @@
1
+ export function keyboardSelectHandler(callback) {
2
+ return (event) => {
3
+ if (!['Enter', 'Space'].includes(event.code))
4
+ return;
5
+ callback(event);
6
+ };
7
+ }
@@ -0,0 +1 @@
1
+ export declare const DATA_AND_ARIA_REGEXP: RegExp;
@@ -0,0 +1 @@
1
+ export const DATA_AND_ARIA_REGEXP = /^(data|aria)-/;
@@ -0,0 +1,3 @@
1
+ export declare function excludeProps(props: Record<string, unknown>, regexp: RegExp): {
2
+ [x: string]: unknown;
3
+ };
@@ -0,0 +1,5 @@
1
+ export function excludeProps(props, regexp) {
2
+ return Object.keys(props)
3
+ .filter(prop => !prop.match(regexp))
4
+ .reduce((nextProps, prop) => (Object.assign(Object.assign({}, nextProps), { [prop]: props[prop] })), {});
5
+ }
@@ -0,0 +1 @@
1
+ export declare function extractProps(props: Record<string, unknown>, regex: RegExp): Record<string, unknown>;
@@ -0,0 +1,7 @@
1
+ export function extractProps(props, regex) {
2
+ return Object.keys(props).reduce((nextProps, prop) => {
3
+ if (prop.match(regex))
4
+ nextProps[prop] = props[prop];
5
+ return nextProps;
6
+ }, {});
7
+ }
@@ -0,0 +1,8 @@
1
+ declare const KEY: unique symbol;
2
+ declare global {
3
+ interface Window {
4
+ [KEY]: Record<string, number>;
5
+ }
6
+ }
7
+ export declare function uniqueId(namespace?: string): string;
8
+ export {};
@@ -0,0 +1,10 @@
1
+ const KEY = Symbol.for('SBERCLOUD_UIKIT_PRODUCT_UTILS_UNIQUE_ID_KEY');
2
+ const DEFAULT_NAMESPACE = '__DEFAULT_NAMESPACE__';
3
+ export function uniqueId(namespace = DEFAULT_NAMESPACE) {
4
+ var _a, _b;
5
+ var _c;
6
+ (_a = window[KEY]) !== null && _a !== void 0 ? _a : (window[KEY] = {});
7
+ (_b = (_c = window[KEY])[namespace]) !== null && _b !== void 0 ? _b : (_c[namespace] = 0);
8
+ const id = ++window[KEY][namespace];
9
+ return namespace === DEFAULT_NAMESPACE ? id.toString() : `${namespace}__${id}`;
10
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-utils",
3
3
  "title": "Utils",
4
- "version": "7.0.0",
4
+ "version": "7.0.2",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -30,6 +30,7 @@
30
30
  "name": "Akhremenko Grigorii",
31
31
  "url": "https://github.com/AGrigorii"
32
32
  },
33
+ "contributors": [],
33
34
  "license": "Apache-2.0",
34
35
  "publishConfig": {
35
36
  "access": "public"
@@ -43,12 +44,29 @@
43
44
  "devDependencies": {
44
45
  "@types/ua-parser-js": "0.7.39"
45
46
  },
46
- "optionalDependencies": {
47
+ "peerDependencies": {
47
48
  "@sbercloud/figma-tokens-admin": "*",
48
49
  "@sbercloud/figma-tokens-cloud-platform": "*",
49
50
  "@sbercloud/figma-tokens-giga-id": "*",
50
51
  "@sbercloud/figma-tokens-mlspace": "*",
51
52
  "@sbercloud/figma-tokens-web": "*"
52
53
  },
53
- "gitHead": "e8bd79bc92b26a8f52611972eec98a867536ccd3"
54
+ "peerDependenciesMeta": {
55
+ "@sbercloud/figma-tokens-admin": {
56
+ "optional": true
57
+ },
58
+ "@sbercloud/figma-tokens-cloud-platform": {
59
+ "optional": true
60
+ },
61
+ "@sbercloud/figma-tokens-giga-id": {
62
+ "optional": true
63
+ },
64
+ "@sbercloud/figma-tokens-mlspace": {
65
+ "optional": true
66
+ },
67
+ "@sbercloud/figma-tokens-web": {
68
+ "optional": true
69
+ }
70
+ },
71
+ "gitHead": "bf479ecf7238ef20b78f20acaef439efa535d1a1"
54
72
  }