@itcase/ui 1.9.57 → 1.9.59

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 (184) hide show
  1. package/dist/{Avatar_cjs_BIHJrAbQ.js → Avatar_cjs_BcCK-1qn.js} +5 -8
  2. package/dist/{Avatar_es_CtP68jPM.js → Avatar_es_Dn6PILdH.js} +2 -5
  3. package/dist/{Button_cjs_BCcz3-Fw.js → Button_cjs_DqbZe2Sk.js} +7 -13
  4. package/dist/{Button_es_DAzeb-vJ.js → Button_es_C9pw5qr_.js} +2 -8
  5. package/dist/{ChipsGroup_cjs_C27x9x9O.js → ChipsGroup_cjs_BNapN3BL.js} +7 -11
  6. package/dist/{ChipsGroup_es_BTe1MYhV.js → ChipsGroup_es_CYtMZd_G.js} +1 -5
  7. package/dist/{DatePicker_cjs_Dvw_cGFH.js → DatePicker_cjs_CY3VQDAV.js} +10 -14
  8. package/dist/{DatePicker_es_t3u6yddn.js → DatePicker_es_C110M8WT.js} +4 -8
  9. package/dist/{Group_cjs_MYtD5is_.js → Group_cjs_CvX0cIz2.js} +5 -17
  10. package/dist/{Group_es_C_WChp2_.js → Group_es_BgJhtaOv.js} +2 -14
  11. package/dist/{Image_cjs_Hvjp2QDB.js → Image_cjs_BdHJJUTP.js} +4 -6
  12. package/dist/{Image_es_DpOCNWpn.js → Image_es_5EyRL35j.js} +1 -3
  13. package/dist/{Input_cjs_BQIi1N63.js → Input_cjs_BStFgIuQ.js} +3 -4
  14. package/dist/{Input_es_BYbc2X9M.js → Input_es_BVvf5Gpr.js} +1 -2
  15. package/dist/{Label_cjs_RI5tFcPt.js → Label_cjs_BYjXyKWj.js} +5 -9
  16. package/dist/{Label_es_CNRTIAWo.js → Label_es_SG60qCRL.js} +1 -5
  17. package/dist/{Loader_cjs_CJpdLndn.js → Loader_cjs_BgiKK0BF.js} +5 -8
  18. package/dist/{Loader_es_CqlLujBJ.js → Loader_es_DzjoV2MF.js} +1 -4
  19. package/dist/{Overlay_cjs_BK_0yTLw.js → Overlay_cjs_OmKx5lKU.js} +4 -6
  20. package/dist/{Overlay_es_DOO535JM.js → Overlay_es_DhKLpjdA.js} +1 -3
  21. package/dist/{SelectContainer_cjs_DTIqXM5V.js → SelectContainer_cjs_CdxNPEhL.js} +17 -22
  22. package/dist/{SelectContainer_es_CXkK4_Om.js → SelectContainer_es_BQNyIzfX.js} +3 -8
  23. package/dist/cjs/components/Accordion.js +7 -22
  24. package/dist/cjs/components/Avatar.js +4 -18
  25. package/dist/cjs/components/AvatarStack.js +8 -22
  26. package/dist/cjs/components/Badge.js +5 -19
  27. package/dist/cjs/components/Breadcrumbs.js +7 -21
  28. package/dist/cjs/components/Button.js +4 -18
  29. package/dist/cjs/components/Cell.js +6 -20
  30. package/dist/cjs/components/Checkbox.js +7 -15
  31. package/dist/cjs/components/Checkmark.js +5 -19
  32. package/dist/cjs/components/Chips.js +2 -16
  33. package/dist/cjs/components/Choice.js +7 -21
  34. package/dist/cjs/components/Code.js +5 -10
  35. package/dist/cjs/components/CookiesWarning.js +7 -21
  36. package/dist/cjs/components/Dadata.js +4 -9
  37. package/dist/cjs/components/DatePeriod.js +18 -33
  38. package/dist/cjs/components/DatePicker.js +7 -21
  39. package/dist/cjs/components/Divider.js +6 -14
  40. package/dist/cjs/components/Dot.js +4 -10
  41. package/dist/cjs/components/Drawer.js +6 -21
  42. package/dist/cjs/components/Dropdown.js +5 -21
  43. package/dist/cjs/components/Dropzone.js +11 -25
  44. package/dist/cjs/components/Flex.js +6 -12
  45. package/dist/cjs/components/Grid.js +8 -14
  46. package/dist/cjs/components/Group.js +3 -10
  47. package/dist/cjs/components/HTMLContent.js +4 -10
  48. package/dist/cjs/components/HeroTitle.js +5 -19
  49. package/dist/cjs/components/Icon.js +5 -19
  50. package/dist/cjs/components/Image.js +4 -12
  51. package/dist/cjs/components/Input.js +4 -9
  52. package/dist/cjs/components/InputNumber.js +6 -20
  53. package/dist/cjs/components/InputPassword.js +5 -19
  54. package/dist/cjs/components/Label.js +2 -16
  55. package/dist/cjs/components/Link.js +6 -14
  56. package/dist/cjs/components/List.js +8 -16
  57. package/dist/cjs/components/Loader.js +3 -11
  58. package/dist/cjs/components/Logo.js +8 -18
  59. package/dist/cjs/components/MenuItem.js +5 -19
  60. package/dist/cjs/components/Modal.js +7 -21
  61. package/dist/cjs/components/ModalSheetBottom.js +5 -19
  62. package/dist/cjs/components/Notification.js +11 -25
  63. package/dist/cjs/components/Overlay.js +3 -10
  64. package/dist/cjs/components/Pagination.js +8 -24
  65. package/dist/cjs/components/Radio.js +5 -13
  66. package/dist/cjs/components/RangeSlider.js +4 -10
  67. package/dist/cjs/components/Response.js +10 -24
  68. package/dist/cjs/components/SVGContent.js +5 -14
  69. package/dist/cjs/components/ScrollOnDrag.js +4 -10
  70. package/dist/cjs/components/ScrollToView.js +4 -10
  71. package/dist/cjs/components/Search.js +7 -21
  72. package/dist/cjs/components/Segmented.js +6 -20
  73. package/dist/cjs/components/Select.js +5 -20
  74. package/dist/cjs/components/Swiper.js +6 -20
  75. package/dist/cjs/components/Switch.js +5 -13
  76. package/dist/cjs/components/Tab.js +8 -23
  77. package/dist/cjs/components/Text.js +6 -14
  78. package/dist/cjs/components/Textarea.js +5 -10
  79. package/dist/cjs/components/Tile.js +5 -19
  80. package/dist/cjs/components/Title.js +5 -19
  81. package/dist/cjs/components/Tooltip.js +5 -19
  82. package/dist/cjs/components/Video.js +5 -9
  83. package/dist/cjs/components/Warning.js +5 -19
  84. package/dist/cjs/context/Notifications.js +16 -188
  85. package/dist/cjs/context/UIContext.js +14 -71
  86. package/dist/cjs/context/UrlAssetPrefix.js +15 -13
  87. package/dist/cjs/hoc/urlWithAssetPrefix.js +14 -73
  88. package/dist/cjs/hooks/useAppearanceConfig/useAppearanceConfig.js +14 -25
  89. package/dist/cjs/hooks/useAppearanceConfig.js +12 -2
  90. package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +10 -124
  91. package/dist/cjs/hooks/useDevicePropsGenerator.js +6 -9
  92. package/dist/cjs/hooks/useDeviceTargetClass.js +8 -4
  93. package/dist/cjs/hooks/useMediaQueries/useMediaQueries.js +13 -116
  94. package/dist/cjs/hooks/useMediaQueries.js +11 -2
  95. package/dist/cjs/hooks/useStyles/styleAttributes.js +15 -168
  96. package/dist/cjs/hooks/useStyles/useStyles.js +10 -196
  97. package/dist/cjs/hooks/useStyles.js +7 -10
  98. package/dist/cjs/hooks.js +15 -6
  99. package/dist/cjs/utils/mergeAppearanceKeys.js +15 -15
  100. package/dist/cjs/utils/setViewportProperty.js +15 -5
  101. package/dist/cjs/utils.js +14 -4
  102. package/dist/components/Accordion.js +1 -16
  103. package/dist/components/Avatar.js +4 -18
  104. package/dist/components/AvatarStack.js +4 -18
  105. package/dist/components/Badge.js +2 -16
  106. package/dist/components/Breadcrumbs.js +1 -15
  107. package/dist/components/Button.js +4 -18
  108. package/dist/components/Cell.js +2 -16
  109. package/dist/components/Checkbox.js +4 -12
  110. package/dist/components/Checkmark.js +1 -15
  111. package/dist/components/Chips.js +2 -16
  112. package/dist/components/Choice.js +2 -16
  113. package/dist/components/Code.js +3 -8
  114. package/dist/components/CookiesWarning.js +4 -18
  115. package/dist/components/Dadata.js +4 -9
  116. package/dist/components/DatePeriod.js +12 -27
  117. package/dist/components/DatePicker.js +7 -21
  118. package/dist/components/Divider.js +3 -11
  119. package/dist/components/Dot.js +2 -8
  120. package/dist/components/Drawer.js +3 -18
  121. package/dist/components/Dropdown.js +1 -17
  122. package/dist/components/Dropzone.js +7 -21
  123. package/dist/components/Flex.js +2 -8
  124. package/dist/components/Grid.js +2 -8
  125. package/dist/components/Group/Group.appearance.js +1 -4
  126. package/dist/components/Group.js +3 -10
  127. package/dist/components/HTMLContent.js +2 -8
  128. package/dist/components/HeroTitle.js +1 -15
  129. package/dist/components/Icon.js +2 -16
  130. package/dist/components/Image.js +4 -12
  131. package/dist/components/Input.js +4 -9
  132. package/dist/components/InputNumber.js +4 -18
  133. package/dist/components/InputPassword.js +2 -16
  134. package/dist/components/Label.js +2 -16
  135. package/dist/components/Link.js +2 -10
  136. package/dist/components/List.js +2 -10
  137. package/dist/components/Loader.js +3 -11
  138. package/dist/components/Logo.js +3 -13
  139. package/dist/components/MenuItem.js +1 -15
  140. package/dist/components/Modal.js +3 -17
  141. package/dist/components/ModalSheetBottom.js +1 -15
  142. package/dist/components/Notification.js +5 -19
  143. package/dist/components/Overlay.js +3 -10
  144. package/dist/components/Pagination.js +1 -17
  145. package/dist/components/Radio.js +2 -10
  146. package/dist/components/RangeSlider.js +2 -8
  147. package/dist/components/Response.js +5 -19
  148. package/dist/components/SVGContent.js +2 -11
  149. package/dist/components/ScrollOnDrag.js +2 -8
  150. package/dist/components/ScrollToView.js +2 -8
  151. package/dist/components/Search.js +1 -15
  152. package/dist/components/Segmented.js +2 -16
  153. package/dist/components/Select.js +5 -20
  154. package/dist/components/Swiper.js +2 -16
  155. package/dist/components/Switch.js +2 -10
  156. package/dist/components/Tab.js +2 -17
  157. package/dist/components/Text.js +3 -11
  158. package/dist/components/Textarea.js +3 -8
  159. package/dist/components/Tile.js +1 -15
  160. package/dist/components/Title.js +2 -16
  161. package/dist/components/Tooltip.js +2 -16
  162. package/dist/components/Video.js +4 -8
  163. package/dist/components/Warning.js +1 -15
  164. package/dist/hooks/useAppearanceConfig.js +11 -1
  165. package/dist/hooks/useDevicePropsGenerator.js +5 -8
  166. package/dist/hooks/useMediaQueries.js +10 -1
  167. package/dist/hooks/useStyles.js +6 -9
  168. package/dist/hooks.js +12 -7
  169. package/dist/primitives_cjs_DX--6Yn5.js +2715 -0
  170. package/dist/primitives_es_BNlMaZfZ.js +2672 -0
  171. package/dist/utils.js +12 -2
  172. package/package.json +1 -1
  173. package/dist/Divider_cjs_C5Ou2Kqa.js +0 -104
  174. package/dist/Divider_es_D2snK_vn.js +0 -100
  175. package/dist/DropdownItem_cjs_k28TIoDU.js +0 -230
  176. package/dist/DropdownItem_es_DjPgbwtU.js +0 -225
  177. package/dist/Icon_cjs_DTvdhr8B.js +0 -1099
  178. package/dist/Icon_es_kewxGRUB.js +0 -1086
  179. package/dist/Link_cjs_Dn7UhCYe.js +0 -277
  180. package/dist/Link_es_BDAmhIzd.js +0 -272
  181. package/dist/Text_cjs_erTy2pUN.js +0 -68
  182. package/dist/Text_es_DVNvU0m0.js +0 -64
  183. package/dist/components/Group/appearance/groupSurface.js +0 -8
  184. package/dist/types/components/Group/appearance/groupSurface.d.ts +0 -3
@@ -0,0 +1,2672 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import React, { useMemo, createContext, useState, useCallback, useEffect, useContext, memo, useRef, useImperativeHandle } from 'react';
4
+ import clsx from 'clsx';
5
+ import camelCase from 'lodash/camelCase';
6
+ import castArray from 'lodash/castArray';
7
+ import upperFirst from 'lodash/upperFirst';
8
+ import { v4 } from 'uuid';
9
+ import { axiosInstanceITCase, formatURL } from '@itcase/common';
10
+ import { useMediaQuery } from 'react-responsive';
11
+ import maxBy from 'lodash/maxBy';
12
+ import SVG from 'react-inlinesvg';
13
+
14
+ const useAppearanceConfig = (appearance, componentConfig, isDisabled) => {
15
+ const appearanceConfig = useMemo(() => {
16
+ if (appearance) {
17
+ const appearanceProps = appearance.split(' ').reduce((resultConfig, appearanceKey) => ({
18
+ ...resultConfig,
19
+ ...componentConfig.appearance?.[appearanceKey],
20
+ }), {});
21
+ if (isDisabled &&
22
+ (componentConfig?.appearance?.disabled ||
23
+ componentConfig?.appearance?.disabledPrimary)) {
24
+ Object.assign(appearanceProps, componentConfig?.appearance?.disabled ||
25
+ componentConfig?.appearance?.disabledPrimary);
26
+ }
27
+ return appearanceProps;
28
+ }
29
+ if (isDisabled) {
30
+ return (componentConfig?.appearance?.disabled ||
31
+ componentConfig?.appearance?.disabledPrimary);
32
+ }
33
+ return {};
34
+ }, [appearance, componentConfig?.appearance, isDisabled]);
35
+ return appearanceConfig;
36
+ };
37
+
38
+ const STATUSES = {
39
+ error: 'error',
40
+ info: 'info',
41
+ success: 'success',
42
+ warning: 'warning',
43
+ };
44
+ const NotificationsContext = createContext([]);
45
+ /* eslint-disable @typescript-eslint/no-unused-vars */
46
+ const NotificationsAPIContext = createContext({
47
+ hideNotifications: (targetId) => { },
48
+ showNotification: (notification, onClose) => { },
49
+ notificationStatuses: STATUSES,
50
+ });
51
+ /* eslint-enable @typescript-eslint/no-unused-vars */
52
+ function NotificationsProvider(props) {
53
+ const { initialNotificationsList = [], isLogRequestsErrors, children } = props;
54
+ const [notificationsList, setNotificationsList] = useState(() => {
55
+ // We need to set id to every notification item and original list also be have new id's
56
+ return (initialNotificationsList || []).map((notificationItem) => {
57
+ return createNotification(notificationItem, notificationItem.onClose);
58
+ });
59
+ });
60
+ const hideNotifications = useCallback((targetId) => {
61
+ // If not target, then nothing to hide
62
+ if (!targetId) {
63
+ return;
64
+ }
65
+ setNotificationsList((prevNotificationsList) => {
66
+ const newState = prevNotificationsList.filter((notificationItem) => {
67
+ // Check on need to hide, if current notification is target for hide
68
+ const isNeedToHide = String(notificationItem.id) === String(targetId);
69
+ // Callback for close if exists
70
+ if (isNeedToHide) {
71
+ clearTimeout(notificationItem._closeTimeout);
72
+ // @typescript-eslint/no-unused-expressions
73
+ notificationItem.onClose && notificationItem.onClose();
74
+ }
75
+ // Save in state if no need to hide
76
+ return !isNeedToHide;
77
+ });
78
+ // Set new notifications list without target item to state
79
+ return newState;
80
+ });
81
+ }, []);
82
+ const showNotification = useCallback((notification, onClose) => {
83
+ const newNotificationItem = createNotification(notification, onClose);
84
+ setNotificationsList((prevNotificationsList) => {
85
+ const newState = prevNotificationsList.slice();
86
+ const existsNotificationIndex = newState.findIndex((notificationItem) => String(notificationItem.id) === String(newNotificationItem.id));
87
+ // Add new notification
88
+ if (existsNotificationIndex === -1) {
89
+ return [...newState, newNotificationItem];
90
+ }
91
+ // Or update exists notification
92
+ const updatedNotificationItem = newState[existsNotificationIndex];
93
+ // Clear timeout to avoid close event for updated notification
94
+ clearTimeout(updatedNotificationItem._closeTimeout);
95
+ updatedNotificationItem._closeTimeout = undefined;
96
+ // Replace exists notification by new one
97
+ newState[existsNotificationIndex] = newNotificationItem;
98
+ return newState;
99
+ });
100
+ if (newNotificationItem.closeByTime) {
101
+ newNotificationItem._closeTimeout = setTimeout(() => hideNotifications(newNotificationItem.id), newNotificationItem.closeByTime);
102
+ }
103
+ return newNotificationItem;
104
+ },
105
+ // "hideNotifications" is never changed
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ []);
108
+ const notificationsAPI = useMemo(() => ({
109
+ hideNotifications: hideNotifications,
110
+ notificationStatuses: STATUSES,
111
+ showNotification: showNotification,
112
+ }),
113
+ // Functions is never changes, no sense to set as dependencies
114
+ // eslint-disable-next-line
115
+ []);
116
+ useEffect(() => {
117
+ // Set timeout for initial notifications list one time on first render
118
+ notificationsList.forEach((notificationItem) => {
119
+ if (notificationItem.closeByTime) {
120
+ setTimeout(() => hideNotifications(notificationItem.id), notificationItem.closeByTime);
121
+ }
122
+ });
123
+ // Show notifications on all requests errors.
124
+ // Enable one time without disabling. Use "isLogging" on request config level
125
+ // to disable notifications logger.
126
+ if (isLogRequestsErrors) {
127
+ axiosInstanceITCase.responseErrorHandler.loggerManager = {
128
+ log: (responseError) => {
129
+ if (responseError.message) {
130
+ // prevent from showing many network errors
131
+ const errorListToDedupe = ['network'];
132
+ const id = errorListToDedupe.includes(responseError.key)
133
+ ? responseError.key
134
+ : undefined;
135
+ showNotification({
136
+ id: id,
137
+ title: responseError.message,
138
+ status: 'error',
139
+ closeByTime: 4000,
140
+ });
141
+ }
142
+ },
143
+ };
144
+ }
145
+ // eslint-disable-next-line react-hooks/exhaustive-deps
146
+ }, []);
147
+ return (jsx(NotificationsAPIContext.Provider, { value: notificationsAPI, children: jsx(NotificationsContext.Provider, { value: notificationsList, children: children }) }));
148
+ }
149
+ function useNotifications() {
150
+ return useContext(NotificationsContext);
151
+ }
152
+ function useNotificationsAPI() {
153
+ return useContext(NotificationsAPIContext);
154
+ }
155
+ const statusToAppearanceList = {
156
+ error: 'errorPrimary sizeS solid rounded',
157
+ info: 'infoPrimary sizeS solid rounded',
158
+ success: 'successPrimary sizeS solid rounded',
159
+ warning: 'warningPrimary sizeS solid rounded',
160
+ };
161
+ function createNotification(notification, onClose) {
162
+ // Default notification item properties
163
+ let id = v4().split('-')[0];
164
+ let title = '';
165
+ let text = '';
166
+ let closeIcon = '';
167
+ let closeIconSrc = '';
168
+ let type = 'float';
169
+ let buttonLabel = '';
170
+ let status = STATUSES.warning;
171
+ let closeByTime = 4500;
172
+ let appearance = statusToAppearanceList[status];
173
+ let after = null;
174
+ let isLoading = false;
175
+ let closeIconAppearance = '';
176
+ let onClickButton = () => { };
177
+ if (typeof notification === 'string') {
178
+ text = notification;
179
+ }
180
+ else if (typeof notification === 'object') {
181
+ id = String(notification.id ?? id);
182
+ title = notification.title ?? title;
183
+ text = notification.text ?? text;
184
+ closeIconAppearance =
185
+ notification.closeIconAppearance ?? closeIconAppearance;
186
+ type = notification.type ?? type;
187
+ closeIcon = notification.closeIcon ?? closeIcon;
188
+ closeIconSrc = notification.closeIconSrc ?? closeIconSrc;
189
+ buttonLabel = notification.buttonLabel ?? buttonLabel;
190
+ onClickButton = notification.onClickButton ?? onClickButton;
191
+ status = notification.status ?? status;
192
+ closeByTime = notification.closeByTime ?? closeByTime;
193
+ isLoading = notification.isLoading ?? isLoading;
194
+ after = notification.after ?? after;
195
+ appearance =
196
+ notification.appearance ??
197
+ statusToAppearanceList[notification.status] ??
198
+ appearance;
199
+ }
200
+ return {
201
+ id: id,
202
+ appearance: appearance,
203
+ type: type,
204
+ title: title,
205
+ status: status,
206
+ text: text,
207
+ buttonLabel: buttonLabel,
208
+ after: after,
209
+ closeByTime: closeByTime,
210
+ closeIcon: closeIcon,
211
+ closeIconAppearance: closeIconAppearance,
212
+ closeIconSrc: closeIconSrc,
213
+ isLoading: isLoading,
214
+ onClickButton: onClickButton,
215
+ onClose: onClose,
216
+ };
217
+ }
218
+
219
+ var tablet = "48em";
220
+ var mediaQueries = {
221
+ "mobile-tiny": "15em",
222
+ "mobile-super-extra-large": "40em",
223
+ tablet: tablet,
224
+ "desktop-small": "60em",
225
+ "desktop-huge": "160em"
226
+ };
227
+
228
+ const isSSR = typeof window === 'undefined';
229
+ function useMediaQueries(userDevice = {}) {
230
+ // const isWarning = useMediaQuery({ maxWidth: mediaQueries['mobile-tiny'] })
231
+ // prettier-ignore
232
+ const isMobile = useMediaQuery({
233
+ minWidth: mediaQueries['mobile-tiny'],
234
+ maxWidth: mediaQueries['tablet']
235
+ }) || isSSR && Boolean(userDevice.isMobile);
236
+ // const isMobileTiny = useMediaQuery({
237
+ // minWidth: mediaQueries['mobile-tiny'],
238
+ // maxWidth: mediaQueries['mobile-small'],
239
+ // })
240
+ // const isMobileSmall = useMediaQuery({
241
+ // minWidth: mediaQueries['mobile-small'],
242
+ // maxWidth: mediaQueries['mobile-medium'],
243
+ // })
244
+ // const isMobileMedium = useMediaQuery({
245
+ // minWidth: mediaQueries['mobile-medium'],
246
+ // maxWidth: mediaQueries['mobile-normal'],
247
+ // })
248
+ // const isMobileNormal = useMediaQuery({
249
+ // minWidth: mediaQueries['mobile-normal'],
250
+ // maxWidth: mediaQueries['mobile-large'],
251
+ // })
252
+ // const isMobileStandart = useMediaQuery({
253
+ // minWidth: mediaQueries['mobile-large'],
254
+ // maxWidth: mediaQueries['mobile-extra-large'],
255
+ // })
256
+ // const isMobileLarge = useMediaQuery({
257
+ // minWidth: mediaQueries['mobile-extra-large'],
258
+ // maxWidth: mediaQueries['mobile-super-extra-large'],
259
+ // })
260
+ useMediaQuery({
261
+ minWidth: mediaQueries['mobile-super-extra-large'],
262
+ maxWidth: mediaQueries['tablet']
263
+ });
264
+ // prettier-ignore
265
+ const isTablet = useMediaQuery({
266
+ minWidth: mediaQueries['tablet'],
267
+ maxWidth: mediaQueries['desktop-small']
268
+ }) || isSSR && Boolean(userDevice.isTablet);
269
+ // const isTabletSmall = useMediaQuery({
270
+ // minWidth: mediaQueries['tablet-small'],
271
+ // maxWidth: mediaQueries['tablet'],
272
+ // })
273
+ // const isTabletLarge = useMediaQuery({
274
+ // minWidth: mediaQueries['tablet'],
275
+ // maxWidth: mediaQueries['tablet-large'],
276
+ // })
277
+ // prettier-ignore
278
+ const isDesktop = useMediaQuery({
279
+ minWidth: mediaQueries['desktop-small'],
280
+ maxWidth: mediaQueries['desktop-super-huge']
281
+ }) || isSSR && Boolean(userDevice.isDesktop);
282
+ // const isDesktopSmall = useMediaQuery({
283
+ // minWidth: mediaQueries['desktop-small'],
284
+ // maxWidth: mediaQueries['desktop-medium'],
285
+ // })
286
+ // const isDesktopMedium = useMediaQuery({
287
+ // minWidth: mediaQueries['desktop-medium'],
288
+ // maxWidth: mediaQueries['desktop-normal'],
289
+ // })
290
+ // const isDesktopNormal = useMediaQuery({
291
+ // minWidth: mediaQueries['desktop-normal'],
292
+ // maxWidth: mediaQueries['desktop-large'],
293
+ // })
294
+ // const isDesktopStandart = useMediaQuery({
295
+ // minWidth: mediaQueries['desktop-large'],
296
+ // maxWidth: mediaQueries['desktop-extra-large'],
297
+ // })
298
+ // const isDesktopLarge = useMediaQuery({
299
+ // minWidth: mediaQueries['desktop-extra-large'],
300
+ // maxWidth: mediaQueries['desktop-super-extra-large'],
301
+ // })
302
+ // const isDesktopHuge = useMediaQuery({
303
+ // minWidth: mediaQueries['desktop-super-extra-large'],
304
+ // maxWidth: mediaQueries['desktop-huge'],
305
+ // })
306
+ const isDesktopMega = useMediaQuery({
307
+ minWidth: mediaQueries['desktop-huge']
308
+ });
309
+ const deviceTypes = useMemo(() => ({
310
+ // isWarning,
311
+ isMobile: isMobile,
312
+ // isMobileTiny,
313
+ // isMobileSmall,
314
+ // isMobileMedium,
315
+ // isMobileNormal,
316
+ // isMobileStandart,
317
+ // isMobileLarge,
318
+ isMobileHuge: isMobile,
319
+ isTablet: isTablet,
320
+ // isTabletSmall,
321
+ // isTabletLarge,
322
+ isDesktop: isDesktop,
323
+ // isDesktopSmall,
324
+ // isDesktopMedium,
325
+ // isDesktopNormal,
326
+ // isDesktopStandart,
327
+ // isDesktopLarge,
328
+ // isDesktopHuge,
329
+ isDesktopMega: isDesktopMega
330
+ }), [isMobile, isTablet, isDesktop, isDesktopMega]);
331
+ return deviceTypes;
332
+ }
333
+
334
+ /**
335
+ * @example
336
+ * mergeAppearanceKeys(' ', '1', undefined, '2', '1') === '1 2'
337
+ */
338
+ const mergeAppearanceKeys = (...appearances) => {
339
+ const trimmedAppearances = appearances
340
+ .map((appearance) => appearance?.trim())
341
+ .filter(Boolean);
342
+ if (trimmedAppearances.length < 2) {
343
+ return trimmedAppearances[0] ?? '';
344
+ }
345
+ const uniqueAppearances = Array.from(new Set(trimmedAppearances));
346
+ return uniqueAppearances.join(' ');
347
+ };
348
+
349
+ const setViewportProperty = () => {
350
+ const vh = window.innerHeight * 0.01;
351
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
352
+ };
353
+
354
+ const UserDeviceContext = createContext({
355
+ isMobile: false,
356
+ isTablet: false,
357
+ isDesktop: false,
358
+ deviceCurrentMainType: '',
359
+ deviceCurrentType: '',
360
+ deviceTypesList: [],
361
+ });
362
+ const UIProvider = memo(function UIProvider(props) {
363
+ const { userDeviceState = {}, children } = props;
364
+ /** NOTE:
365
+ * Remember that the "useMediaQueries" hook works by next scenario:
366
+ * when changing the device type(browser width), the hook will first "enable"
367
+ * the new type(set true), and then "disable" the previous one(set false),
368
+ * what provoke to double rendering, and in moment we have two different types as "true".
369
+ * We will need to look at how to change this behavior.
370
+ */
371
+ const allDevicesTypes = useMediaQueries(userDeviceState);
372
+ const { isMobile, isTablet, isDesktop, ...fullNamedDeviceTypes } = allDevicesTypes;
373
+ const deviceCurrentMainType = (isMobile && 'mobile') ||
374
+ (isTablet && 'tablet') ||
375
+ (isDesktop && 'desktop') ||
376
+ '';
377
+ const [deviceCurrentType, deviceTypesList] = useMemo(() => {
378
+ const deviceTypesList = Object.keys(allDevicesTypes).map((key) => camelCase(key.replace('is', '')));
379
+ // In same time "allDevicesTypes" can contain "isMobile" and "isMobileLarge" as true
380
+ let deviceCurrentType = Object.keys(fullNamedDeviceTypes).find(
381
+ // If "fullNamedDeviceTypes.isMobileLarge: true" - that our device
382
+ (key) => fullNamedDeviceTypes[key]);
383
+ // Or set main type (e.g. "isMobile")
384
+ if (!deviceCurrentType) {
385
+ deviceCurrentType = deviceCurrentMainType;
386
+ }
387
+ deviceCurrentType = camelCase(deviceCurrentType.replace('is', ''));
388
+ // On server side render we doesn't known user device and we need to set special word
389
+ return [deviceCurrentType || '_none_', deviceTypesList];
390
+ }, [allDevicesTypes, deviceCurrentMainType, fullNamedDeviceTypes]);
391
+ const deviceContextState = useMemo(() => {
392
+ return {
393
+ ...allDevicesTypes,
394
+ deviceCurrentMainType: deviceCurrentMainType,
395
+ deviceCurrentType: deviceCurrentType,
396
+ deviceTypesList: deviceTypesList,
397
+ };
398
+ }, [
399
+ allDevicesTypes,
400
+ deviceCurrentMainType,
401
+ deviceCurrentType,
402
+ deviceTypesList,
403
+ ]);
404
+ useEffect(() => {
405
+ setViewportProperty();
406
+ window.addEventListener('resize', setViewportProperty);
407
+ }, []);
408
+ return (jsx(UserDeviceContext.Provider, { value: deviceContextState, children: children }));
409
+ });
410
+ function useUserDeviceContext() {
411
+ const context = useContext(UserDeviceContext);
412
+ if (!context) {
413
+ throw new Error('useUserDeviceContext is not defined');
414
+ }
415
+ return context;
416
+ }
417
+
418
+ const getStyleAttributeKey = (targetStyleAttribute) => {
419
+ return Array.isArray(targetStyleAttribute)
420
+ ? targetStyleAttribute[0]
421
+ : targetStyleAttribute;
422
+ };
423
+
424
+ var styleAttributes = [
425
+ /**
426
+ * Layout
427
+ */
428
+ 'alignContent',
429
+ 'alignItems',
430
+ 'alignSelf',
431
+ 'aspectRatio',
432
+ 'border',
433
+ 'borderBottomWidth',
434
+ 'borderLeftWidth',
435
+ 'borderRightWidth',
436
+ 'borderTopWidth',
437
+ 'borderWidth',
438
+ 'bottom',
439
+ 'display',
440
+ 'flex',
441
+ 'flexBasis',
442
+ 'flexDirection',
443
+ 'flexGrow',
444
+ 'flexShrink',
445
+ 'flexWrap',
446
+ 'gap',
447
+ 'rowGap',
448
+ 'columnGap',
449
+ 'columnWidth',
450
+ 'height',
451
+ 'justifyContent',
452
+ 'left',
453
+ 'margin',
454
+ 'marginBottom',
455
+ 'marginHorizontal',
456
+ 'marginLeft',
457
+ 'marginRight',
458
+ 'marginTop',
459
+ 'marginVertical',
460
+ 'maxHeight',
461
+ 'maxWidth',
462
+ 'minHeight',
463
+ 'minWidth',
464
+ 'overflow',
465
+ 'overflowY',
466
+ 'overflowX',
467
+ 'padding',
468
+ 'paddingBottom',
469
+ 'paddingEnd',
470
+ 'paddingHorizontal',
471
+ 'paddingLeft',
472
+ 'paddingRight',
473
+ 'paddingStart',
474
+ 'paddingTop',
475
+ 'paddingVertical',
476
+ 'position',
477
+ 'right',
478
+ 'top',
479
+ [
480
+ 'width',
481
+ {
482
+ validate: (value) => {
483
+ // Pass only number value for "width" style.
484
+ // If width have custom value, like "fill", we must set class by this value.
485
+ // "\d" - digit; "+" - 1 or more
486
+ return /\d+/.test(value);
487
+ },
488
+ },
489
+ ],
490
+ 'zIndex',
491
+ 'order',
492
+ /**
493
+ * Shadow
494
+ */
495
+ 'shadowColor',
496
+ 'shadowOffset',
497
+ 'shadowOpacity',
498
+ 'shadowRadius',
499
+ /**
500
+ * Transform
501
+ */
502
+ 'transform',
503
+ /**
504
+ * View
505
+ */
506
+ 'background',
507
+ 'backgroundColor',
508
+ 'borderBottomColor',
509
+ 'borderBottomEndRadius',
510
+ 'borderBottomLeftRadius',
511
+ 'borderBottomRightRadius',
512
+ 'borderBottomStartRadius',
513
+ 'borderColor',
514
+ 'borderCurve',
515
+ 'borderEndColor',
516
+ 'borderLeftColor',
517
+ 'borderRadius',
518
+ 'borderRightColor',
519
+ 'borderStartColor',
520
+ 'borderStyle',
521
+ 'borderTopColor',
522
+ 'borderTopEndRadius',
523
+ 'borderTopLeftRadius',
524
+ 'borderTopRightRadius',
525
+ 'borderTopStartRadius',
526
+ 'opacity',
527
+ 'cursor',
528
+ /**
529
+ * Text
530
+ */
531
+ 'color',
532
+ 'fontFamily',
533
+ 'fontSize',
534
+ 'fontStyle',
535
+ 'fontVariant',
536
+ 'fontWeight',
537
+ 'letterSpacing',
538
+ 'lineHeight',
539
+ 'textAlign',
540
+ 'textDecorationColor',
541
+ 'textDecorationLine',
542
+ 'textDecorationStyle',
543
+ 'textShadowColor',
544
+ 'textShadowOffset',
545
+ 'textShadowRadius',
546
+ 'textTransform',
547
+ 'verticalAlign',
548
+ 'writingMode',
549
+ 'whiteSpace',
550
+ /**
551
+ * Image
552
+ */
553
+ 'overlayColor',
554
+ 'resizeMode',
555
+ 'tintColor',
556
+ 'objectFit',
557
+ 'objectPosition',
558
+ /**
559
+ * Grid
560
+ */
561
+ 'gridTemplateColumns',
562
+ 'gridArea',
563
+ 'gridAutoColumns',
564
+ 'gridAutoFlow',
565
+ 'gridAutoRows',
566
+ 'gridTemplate',
567
+ 'gridTemplateAreas',
568
+ 'gridTemplateRows',
569
+ 'gridColumn',
570
+ 'gridColumnStart',
571
+ 'gridColumnEnd',
572
+ 'gridColumnGap',
573
+ 'gridRow',
574
+ 'gridRowStart',
575
+ 'gridRowEnd',
576
+ 'gridRowGap',
577
+ /**
578
+ * Filter
579
+ */
580
+ 'backdropFilter',
581
+ /**
582
+ * transition
583
+ */
584
+ 'transition',
585
+ 'transitionBehavior',
586
+ 'transitionDelay',
587
+ 'transitionDuration',
588
+ 'transitionProperty',
589
+ 'transitionTimingFunction',
590
+ ];
591
+
592
+ function useDevicePropsGenerator(componentProps, appearanceConfig) {
593
+ /** Get or generate(classname) a prop depending on the user's device.
594
+ * Props:
595
+ * - "componentProps" - original "props" from component
596
+ * - "appearanceConfig" - special appearance dictionary with styles presets
597
+ *
598
+ * Usage for create class value:
599
+ * const appearanceConfig = (
600
+ * appearance && componentConfig.appearance && componentConfig.appearance[appearance]
601
+ * )
602
+ * const propsGenerator = useDevicePropsGenerator(props, appearanceConfig)
603
+ * ---------
604
+ * const fillClass = propsGenerator.getClassName('fill')
605
+ * "fillClass" - is "surface-secondary"
606
+ * ---------
607
+ * const fillClass = propsGenerator.getClassName('fill', { prefix: 'fill_' })
608
+ * "fillClass" - is "fill_surface-secondary"
609
+ * ---------
610
+ * const fillClass = propsGenerator.fillClass
611
+ * "fillClass" - is "surface-secondary"
612
+ * ---------
613
+ * const { fillClass } = propsGenerator
614
+ * "fillClass" - is "surface-secondary"
615
+ *
616
+ * Usage for props value for device:
617
+ * const { titleTextSize } = propsGenerator / const titleTextSize = propsGenerator.titleTextSize
618
+ *
619
+ * "titleTextSize" - contain some value from props:
620
+ * - titleTextSize
621
+ * - titleTextSizeMobile
622
+ * - titleTextSizeTablet
623
+ * - titleTextSizeDesktop
624
+ * ---------
625
+ **/
626
+ const { deviceCurrentMainType } = useUserDeviceContext();
627
+ const devicePropsGenerator = useMemo(() => {
628
+ const propsGenerator = {
629
+ getProp(propKey) {
630
+ const propsForDeviceKey = `${propKey}${upperFirst(deviceCurrentMainType)}`;
631
+ const valueForDevice = componentProps[propsForDeviceKey];
632
+ const valueDefault = componentProps[propKey];
633
+ const appearanceForDevice = appearanceConfig?.[propsForDeviceKey];
634
+ const appearanceDefault = appearanceConfig?.[propKey];
635
+ // prettier-ignore
636
+ const targetPropsValue = (
637
+ // Value for device from props is first priority
638
+ valueForDevice ||
639
+ // Value without device from props is second priority
640
+ valueDefault ||
641
+ // Value for device from appearance config is third priority
642
+ appearanceForDevice ||
643
+ // Value without device from appearance config is last priority
644
+ appearanceDefault);
645
+ return targetPropsValue;
646
+ },
647
+ // eslint-disable-next-line perfectionist/sort-objects
648
+ getClassName(propKey, params) {
649
+ const { prefix = '', replace = [/([A-Z])/g, '-$1'] } = params || {};
650
+ const targetClassValue = this.getProp(String(propKey));
651
+ const styleAttributeKeys = styleAttributes.map((attr) => getStyleAttributeKey(attr));
652
+ if (styleAttributeKeys.includes(String(propKey)) &&
653
+ (typeof targetClassValue === 'number' ||
654
+ (typeof targetClassValue === 'string' &&
655
+ !isNaN(parseFloat(targetClassValue))))) {
656
+ return '';
657
+ }
658
+ if (targetClassValue) {
659
+ let cleanClassValue = String(targetClassValue);
660
+ if (!cleanClassValue.includes('.')) {
661
+ cleanClassValue = camelCase(cleanClassValue);
662
+ }
663
+ if (replace) {
664
+ const replaceList = castArray(replace);
665
+ cleanClassValue = cleanClassValue.replace(replaceList[0],
666
+ // @ts-expect-error
667
+ replaceList[1] || '');
668
+ }
669
+ // prettier-ignore
670
+ return `${prefix}${cleanClassValue}`.toLowerCase();
671
+ }
672
+ // If target key not exists in props and appearance config - return empty class
673
+ return '';
674
+ },
675
+ };
676
+ const generatorProxyHandler = {
677
+ get(target, propKey, receiver, ...args) {
678
+ if (typeof propKey === 'string') {
679
+ // If object does not have the property being retrieved
680
+ if (!Reflect.has(target, propKey)) {
681
+ // And property ended on "Class" keyword
682
+ if (propKey.endsWith('Class')) {
683
+ // prettier-ignore
684
+ const shortProp = propKey.substring(0, propKey.lastIndexOf('Class'));
685
+ // Return prop from props for device as formatted class name
686
+ return target.getClassName(shortProp);
687
+ }
688
+ // Return prop from props for device
689
+ return target.getProp(propKey);
690
+ }
691
+ // Return object property. Original "get".
692
+ // @ts-expect-error
693
+ return Reflect.get(target, propKey, receiver, ...args);
694
+ }
695
+ // In some cases, like in Chrome browser, sometime "prop" is not string.
696
+ // We return this object as is.
697
+ return propKey;
698
+ },
699
+ };
700
+ return new Proxy(propsGenerator, generatorProxyHandler);
701
+ // TODO: componentProps(react) and appearanceConfig(not memoized) is always new. maybe better check Object.values?
702
+ }, [componentProps, appearanceConfig, deviceCurrentMainType]);
703
+ return devicePropsGenerator;
704
+ }
705
+
706
+ /*
707
+ * rule of prop key:
708
+ *
709
+ * first is style second is div target third is device
710
+ * paddingHorizontal GridInnerWrapper MobileNormal
711
+ *
712
+ * paddingHorizontalGridInnerWrapperMobileNormal: "10px"
713
+ */
714
+ function useStyles(props) {
715
+ const { deviceCurrentMainType, deviceCurrentType, deviceTypesList } = useUserDeviceContext();
716
+ const propsStyleAttributes = useMemo(() => {
717
+ const styles = Object.entries(props).reduce((result, [propKey, propValue]) => {
718
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
719
+ if (styleAttributeKey) {
720
+ result[propKey] = propValue;
721
+ }
722
+ return result;
723
+ }, {});
724
+ return styles;
725
+ // "props" object maybe big and frequently changing
726
+ }, [props]);
727
+ const collectedStyles = useMemo(() => {
728
+ const resultStylesGroups = {};
729
+ for (const [propKey, propValue] of Object.entries(propsStyleAttributes)) {
730
+ let value = null;
731
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
732
+ const isStyleForCurrentDevice = propKey
733
+ .toLowerCase()
734
+ .endsWith(deviceCurrentType.toLowerCase());
735
+ // e.g. "GridWrapperInner"
736
+ const targetElementKey = removeDeviceType(propKey.replace(styleAttributeKey, ''), deviceTypesList);
737
+ const targetElementGroupKey = camelCase(targetElementKey) || 'styles';
738
+ if (!resultStylesGroups[targetElementGroupKey]) {
739
+ resultStylesGroups[targetElementGroupKey] = {};
740
+ }
741
+ if (isStyleForCurrentDevice) {
742
+ value = propValue;
743
+ }
744
+ else {
745
+ const propKeyWithOutDeviceType = `${styleAttributeKey}${targetElementKey}`;
746
+ const propKeyWithBaseDeviceType = `${propKeyWithOutDeviceType}${upperFirst(deviceCurrentMainType)}`;
747
+ const defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
748
+ let currentValue = resultStylesGroups[targetElementGroupKey][styleAttributeKey];
749
+ if (propKeyWithOutDeviceType.includes('Horizontal')) {
750
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
751
+ currentValue =
752
+ resultStylesGroups[targetElementGroupKey][keyLeft];
753
+ }
754
+ else if (propKeyWithOutDeviceType.includes('Vertical')) {
755
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
756
+ currentValue =
757
+ resultStylesGroups[targetElementGroupKey][keyTop];
758
+ }
759
+ if (!currentValue) {
760
+ value = defaultValue;
761
+ }
762
+ }
763
+ if (value) {
764
+ // Check not digit symbols. Chars means some unit ("px", "em", "rem" or custom "m")
765
+ const isValueHasUnit = /\D/.test(value);
766
+ // If value has some unit
767
+ if (isValueHasUnit) {
768
+ // Check value on our custom "m"(module) unit
769
+ /** Pattern for:
770
+ * 1m
771
+ * 1.5m
772
+ * 1m 1m 1.5m
773
+ * 0 0 1m 1m
774
+ */
775
+ const isValueHasModuleUnit = /\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(value);
776
+ // If value has module unit
777
+ if (isValueHasModuleUnit) {
778
+ /** Order for shorthand properties:
779
+ * top
780
+ * right
781
+ * bottom
782
+ * left
783
+ * or:
784
+ * top
785
+ * right and left
786
+ * bottom
787
+ * or:
788
+ * top and bottom
789
+ * right and left
790
+ */
791
+ const valuePxPartsList = value
792
+ .split(' ')
793
+ .map((valuePart) => {
794
+ const valueModule = valuePart.replace(/[a-z]/gi, '');
795
+ const valuePx = parseFloat(valueModule) * 8;
796
+ return `${valuePx}px`;
797
+ }, []);
798
+ value = valuePxPartsList.join(' ');
799
+ }
800
+ }
801
+ else {
802
+ // Some properties doesn't have any units
803
+ const ignorePX = ['zIndex', 'order', 'flexGrow'].includes(styleAttributeKey);
804
+ if (!ignorePX) {
805
+ // Add px to non-unit value
806
+ value = `${value}px`;
807
+ }
808
+ }
809
+ if (styleAttributeKey.includes('Horizontal')) {
810
+ const keyRight = styleAttributeKey.replace('Horizontal', 'Right');
811
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
812
+ const valuePartsList = value.split(' ');
813
+ const valueRight = valuePartsList[0];
814
+ const valueLeft = valuePartsList[1] || valuePartsList[0];
815
+ resultStylesGroups[targetElementGroupKey][keyRight] = valueRight;
816
+ resultStylesGroups[targetElementGroupKey][keyLeft] = valueLeft;
817
+ }
818
+ else if (styleAttributeKey.includes('Vertical')) {
819
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
820
+ const keyBottom = styleAttributeKey.replace('Vertical', 'Bottom');
821
+ const valuePartsList = value.split(' ');
822
+ const valueTop = valuePartsList[0];
823
+ const valueBottom = valuePartsList[1] || valuePartsList[0];
824
+ resultStylesGroups[targetElementGroupKey][keyTop] = valueTop;
825
+ resultStylesGroups[targetElementGroupKey][keyBottom] = valueBottom;
826
+ }
827
+ else {
828
+ resultStylesGroups[targetElementGroupKey][styleAttributeKey] = value;
829
+ }
830
+ }
831
+ }
832
+ return resultStylesGroups;
833
+ // eslint-disable-next-line react-hooks/exhaustive-deps
834
+ }, [
835
+ deviceCurrentMainType,
836
+ deviceCurrentType,
837
+ ...Object.values(propsStyleAttributes),
838
+ ]);
839
+ return collectedStyles;
840
+ }
841
+ const removeDeviceType = (originalKey, deviceTypesList) => {
842
+ // Remove "mobile"/"tablet"/"desktop"
843
+ const withOutDeviceType = deviceTypesList.reduce((cleanKey, deviceType) => {
844
+ if (cleanKey.endsWith(upperFirst(deviceType))) {
845
+ return cleanKey.replace(upperFirst(deviceType), '');
846
+ }
847
+ return cleanKey;
848
+ }, originalKey);
849
+ return withOutDeviceType;
850
+ };
851
+ const getTargetStyleAttributeKey = (styleKey, styleValue = '') => {
852
+ // Collect list of possible styles for propKey. e.g:
853
+ // "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
854
+ const possibleStyleAttributesList = styleAttributes.filter((styleAttribute) => {
855
+ // Attribute can be array with key on first position and params on second
856
+ if (Array.isArray(styleAttribute)) {
857
+ // First item always attribute key (e.g. border, width, etc)
858
+ const styleAttributeKey = styleAttribute[0];
859
+ // Second item always params with some settings or methods
860
+ const styleAttributeParams = styleAttribute[1] || {};
861
+ // If is target attribute key
862
+ if (styleKey.startsWith(styleAttributeKey)) {
863
+ // If target attribute params has validate method
864
+ if (styleAttributeParams.validate) {
865
+ // Return validation result for target attribute
866
+ return styleAttributeParams.validate(styleValue);
867
+ }
868
+ else {
869
+ // Or always add to list
870
+ return true;
871
+ }
872
+ }
873
+ else {
874
+ // Else ignore
875
+ return false;
876
+ }
877
+ }
878
+ else {
879
+ // If is target attribute
880
+ return styleKey.startsWith(String(styleAttribute));
881
+ }
882
+ });
883
+ // Get longest style key (e.g. "borderLeftWidth")
884
+ const targetStyleAttribute = maxBy(possibleStyleAttributesList, (styleAttribute) => {
885
+ const key = getStyleAttributeKey(styleAttribute);
886
+ return key.length;
887
+ });
888
+ const styleAttributeKey = getStyleAttributeKey(targetStyleAttribute);
889
+ return styleAttributeKey;
890
+ };
891
+
892
+ const badgeAppearanceAccent = {
893
+ accentPrimary: {
894
+ fill: 'accentPrimary',
895
+ borderColor: 'accentBorderQuaternary',
896
+ textColor: 'accentTextPrimary',
897
+ dotFill: 'accentItemPrimary',
898
+ iconFill: 'accentItemPrimary',
899
+ },
900
+ accentQuaternary: {
901
+ fill: 'accentQuaternary',
902
+ borderColor: 'accentBorderQuaternary',
903
+ textColor: 'accentTextPrimary',
904
+ dotFill: 'accentItemPrimary',
905
+ iconFill: 'accentItemPrimary',
906
+ },
907
+ accentSecondary: {
908
+ fill: 'accentSecondary',
909
+ borderColor: 'accentBorderQuaternary',
910
+ textColor: 'accentTextQuaternary',
911
+ dotFill: 'accentItemQuaternary',
912
+ iconFill: 'accentItemQuaternary',
913
+ },
914
+ accentTertiary: {
915
+ fill: 'accentTertiary',
916
+ borderColor: 'accentBorderSecondary',
917
+ textColor: 'accentTextSecondary',
918
+ dotFill: 'accentItemSecondary',
919
+ iconFill: 'accentItemSecondary',
920
+ },
921
+ };
922
+
923
+ const badgeAppearanceDanger = {
924
+ dangerPrimary: {
925
+ fill: 'dangerPrimary',
926
+ borderColor: 'dangerBorderPrimary',
927
+ textColor: 'dangerTextPrimary',
928
+ dotFill: 'dangerItemPrimary',
929
+ iconFill: 'dangerItemPrimary',
930
+ },
931
+ };
932
+
933
+ const badgeAppearanceDisabled = {
934
+ disabledPrimary: {
935
+ fill: 'surfacePrimary',
936
+ borderColor: 'surfaceBorderPrimary',
937
+ textColor: 'surfaceTextPrimary',
938
+ iconFill: 'surfaceItemPrimary',
939
+ },
940
+ };
941
+
942
+ const badgeAppearanceError = {
943
+ errorPrimary: {
944
+ fill: 'errorPrimary',
945
+ fillHover: 'errorHoverPrimary',
946
+ textColor: 'errorTextPrimary',
947
+ iconFill: 'errorItemPrimary',
948
+ },
949
+ };
950
+
951
+ const badgeAppearanceExtra = {
952
+ extraPrimary: {
953
+ fill: 'extraPrimary',
954
+ borderColor: 'extraBorderSecondary',
955
+ textColor: 'extraTextPrimary',
956
+ dotFill: 'extraItemPrimary',
957
+ iconFill: 'extraItemPrimary',
958
+ },
959
+ };
960
+
961
+ const badgeAppearanceInfo = {
962
+ infoPrimary: {
963
+ fill: 'infoPrimary',
964
+ borderColor: 'infoBorderSecondary',
965
+ textColor: 'infoTextPrimary',
966
+ dotFill: 'infoItemPrimary',
967
+ iconFill: 'infoItemPrimary',
968
+ },
969
+ infoSecondary: {
970
+ fill: 'infoSecondary',
971
+ borderColor: 'infoBorderSecondary',
972
+ textColor: 'infoTextSecondary',
973
+ dotFill: 'infoItemSecondary',
974
+ },
975
+ };
976
+
977
+ const badgeAppearanceShape = {
978
+ circular: {
979
+ shape: 'circular',
980
+ },
981
+ rounded: {
982
+ shape: 'rounded',
983
+ },
984
+ roundedXL: {
985
+ shape: 'rounded',
986
+ shapeStrength: '2m',
987
+ },
988
+ roundedL: {
989
+ shape: 'rounded',
990
+ shapeStrength: '1_5m',
991
+ },
992
+ roundedM: {
993
+ shape: 'rounded',
994
+ shapeStrength: '1m',
995
+ },
996
+ roundedS: {
997
+ shape: 'rounded',
998
+ shapeStrength: '0_5m',
999
+ },
1000
+ };
1001
+
1002
+ const badgeAppearanceSize = {
1003
+ sizeXXL: {
1004
+ size: 'xxl',
1005
+ textSize: 'xl',
1006
+ iconSize: '24',
1007
+ },
1008
+ sizeXL: {
1009
+ size: 'xl',
1010
+ textSize: 'l',
1011
+ iconSize: '24',
1012
+ },
1013
+ sizeL: {
1014
+ size: 'l',
1015
+ textSize: 'l',
1016
+ iconSize: '24',
1017
+ },
1018
+ sizeM: {
1019
+ size: 'm',
1020
+ textSize: 'm',
1021
+ iconSize: '24',
1022
+ },
1023
+ sizeS: {
1024
+ size: 's',
1025
+ textSize: 's',
1026
+ iconSize: '24',
1027
+ },
1028
+ sizeXS: {
1029
+ size: 'xs',
1030
+ textSize: 'xs',
1031
+ iconSize: '24',
1032
+ },
1033
+ sizeXXS: {
1034
+ size: 'xxs',
1035
+ textSize: 'xs',
1036
+ iconSize: '24',
1037
+ },
1038
+ };
1039
+
1040
+ const badgeAppearanceSpecial = {
1041
+ specialPrimary: {
1042
+ fill: 'specialPrimary',
1043
+ borderColor: 'specialBorderSecondary',
1044
+ textColor: 'specialTextPrimary',
1045
+ dotFill: 'specialItemPrimary',
1046
+ iconFill: 'specialItemPrimary',
1047
+ },
1048
+ };
1049
+
1050
+ const badgeAppearanceStyle = {
1051
+ solid: {
1052
+ borderColor: 'none',
1053
+ },
1054
+ outlined: {
1055
+ fill: 'none',
1056
+ },
1057
+ full: {},
1058
+ ghost: {
1059
+ fill: 'none',
1060
+ borderColor: 'none',
1061
+ },
1062
+ };
1063
+
1064
+ const badgeAppearanceSuccess = {
1065
+ successPrimary: {
1066
+ fill: 'successPrimary',
1067
+ borderColor: 'successBorderPrimary',
1068
+ textColor: 'successTextPrimary',
1069
+ dotFill: 'successItemPrimary',
1070
+ iconFill: 'successItemPrimary',
1071
+ },
1072
+ };
1073
+
1074
+ const badgeAppearanceSurface = {
1075
+ surfacePrimary: {
1076
+ fill: 'surfacePrimary',
1077
+ borderColor: 'surfaceBorderTertiary',
1078
+ textColor: 'surfaceTextPrimary',
1079
+ dotFill: 'surfaceItemPrimary',
1080
+ iconFill: 'surfaceItemPrimary',
1081
+ },
1082
+ surfaceQuaternary: {
1083
+ fill: 'accentPrimary',
1084
+ borderColor: 'surfaceBorderPrimary',
1085
+ textColor: 'surfaceTextPrimary',
1086
+ },
1087
+ surfaceSecondary: {
1088
+ fill: 'surfaceSecondary',
1089
+ borderColor: 'surfaceBorderSecondary',
1090
+ textColor: 'surfaceTextPrimary',
1091
+ },
1092
+ surfaceTertiary: {
1093
+ fill: 'surfaceTertiary',
1094
+ borderColor: 'surfaceBorderTertiary',
1095
+ textColor: 'surfaceTextPrimary',
1096
+ },
1097
+ };
1098
+
1099
+ const badgeAppearanceWarning = {
1100
+ warningPrimary: {
1101
+ fill: 'warningPrimary',
1102
+ borderColor: 'warningBorderPrimary',
1103
+ textColor: 'warningTextPrimary',
1104
+ dotFill: 'warningItemPrimary',
1105
+ iconFill: 'warningItemPrimary',
1106
+ },
1107
+ };
1108
+
1109
+ const badgeAppearance = {
1110
+ ...badgeAppearanceSize,
1111
+ ...badgeAppearanceShape,
1112
+ ...badgeAppearanceStyle,
1113
+ ...badgeAppearanceAccent,
1114
+ ...badgeAppearanceDanger,
1115
+ ...badgeAppearanceError,
1116
+ ...badgeAppearanceInfo,
1117
+ ...badgeAppearanceSpecial,
1118
+ ...badgeAppearanceExtra,
1119
+ ...badgeAppearanceSuccess,
1120
+ ...badgeAppearanceDisabled,
1121
+ ...badgeAppearanceSurface,
1122
+ ...badgeAppearanceWarning,
1123
+ };
1124
+
1125
+ const textAppearanceSize = {
1126
+ sizeXXL: {
1127
+ size: 'xxl',
1128
+ },
1129
+ sizeXL: {
1130
+ size: 'xl',
1131
+ },
1132
+ sizeL: {
1133
+ size: 'l',
1134
+ },
1135
+ sizeM: {
1136
+ size: 'm',
1137
+ },
1138
+ sizeS: {
1139
+ size: 's',
1140
+ },
1141
+ sizeXS: {
1142
+ size: 'xs',
1143
+ },
1144
+ sizeXXS: {
1145
+ size: 'xxs',
1146
+ },
1147
+ };
1148
+
1149
+ const textAppearance = {
1150
+ ...textAppearanceSize,
1151
+ };
1152
+
1153
+ const textConfig = {
1154
+ appearance: textAppearance,
1155
+ setAppearance: (appearanceConfig) => {
1156
+ textConfig.appearance = appearanceConfig;
1157
+ },
1158
+ };
1159
+ function Text(props) {
1160
+ const { appearance, className, dataTestId, dataTour, cursor, style, tag: Tag = 'span', before, after, isActive, isDisabled, isSkeleton, onClick, onDoubleClick, children, } = props;
1161
+ const appearanceConfig = useAppearanceConfig(appearance, textConfig, isDisabled);
1162
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
1163
+ const { textAlignClass, textColorActiveClass, textColorActiveHoverClass, textColorClass, textColorDisabledClass, textColorHoverClass, textFontClass, textStyleClass, textTruncateClass, textWeightClass, textWrapClass, cursorClass, sizeClass, widthClass, } = propsGenerator;
1164
+ const { styles: textStyles } = useStyles(props);
1165
+ return (jsxs(Tag, { className: clsx(className, 'text', sizeClass && `text_size_${sizeClass}`, textWeightClass && `text-weight_${textWeightClass}`, textAlignClass && `text-align_${textAlignClass}`, isDisabled &&
1166
+ textColorDisabledClass &&
1167
+ `text-color_${textColorDisabledClass}`, !isActive &&
1168
+ !isDisabled &&
1169
+ textColorClass &&
1170
+ `text-color_${textColorClass}`, !isActive &&
1171
+ !isDisabled &&
1172
+ textColorHoverClass &&
1173
+ `text-color_hover_${textColorHoverClass}`, isActive &&
1174
+ !isDisabled &&
1175
+ textColorActiveHoverClass &&
1176
+ `text-color_active_hover_${textColorActiveHoverClass}`, isActive &&
1177
+ !isDisabled &&
1178
+ textColorActiveClass &&
1179
+ `text-color_active_${textColorActiveClass}`, textFontClass && `text-font_${textFontClass}`, textStyleClass && `text-style_${textStyleClass}`, textWrapClass && `word-wrap_${textWrapClass}`, textTruncateClass && `text-truncate_${textTruncateClass}`, isSkeleton && 'text_skeleton', widthClass && `width_${widthClass}`, cursorClass && `cursor_${cursorClass}`, onClick && (cursor || 'cursor_type_pointer')), "data-testid": dataTestId, "data-tour": dataTour, style: Object.assign({}, textStyles, style), onClick: onClick, onDoubleClick: onDoubleClick, children: [before, children, after] }));
1180
+ }
1181
+
1182
+ const badgeConfig = {
1183
+ appearance: badgeAppearance,
1184
+ setAppearance: (appearanceConfig) => {
1185
+ badgeConfig.appearance = appearanceConfig;
1186
+ },
1187
+ };
1188
+ function Badge(props) {
1189
+ const { appearance, className, dataTestId, dataTour, dot, icon, iconSrc, value, isSkeleton, children, } = props;
1190
+ const appearanceConfig = useAppearanceConfig(appearance, badgeConfig);
1191
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
1192
+ const { fillClass, fillHoverClass, borderColorClass, borderColorHoverClass, borderTypeClass, borderWidthClass, textColor, textSize, dotFillClass, iconFill, iconShape, iconSize, shapeClass, shapeStrengthClass, sizeClass, } = propsGenerator;
1193
+ const { styles: badgeStyles } = useStyles(props);
1194
+ const badgeTypeClass = value
1195
+ ? icon
1196
+ ? dot
1197
+ ? 'badge_type_dot-icon-counter'
1198
+ : 'badge_type_icon-counter'
1199
+ : 'badge_type_counter'
1200
+ : icon
1201
+ ? 'badge_type_icon'
1202
+ : dot
1203
+ ? 'badge_type_dot'
1204
+ : 'badge_type_fill';
1205
+ return (jsxs("div", { className: clsx(className, 'badge', borderColorClass && `border-color_${borderColorClass}`, borderColorHoverClass && `border-color_hover_${borderColorHoverClass}`, borderWidthClass && `border-width_${borderWidthClass}`, borderTypeClass && `border_type_${borderTypeClass}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, sizeClass && `badge_size_${sizeClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, badgeTypeClass, isSkeleton && 'badge_skeleton'), "data-testid": dataTestId, "data-tour": dataTour, style: badgeStyles, children: [dot && (jsx("div", { className: clsx('badge__dot', dotFillClass && `svg_fill_${dotFillClass}`), children: jsx("svg", { width: "6", height: "6", viewBox: "0 0 6 6", xmlns: "http://www.w3.org/2000/svg", children: jsx("rect", { width: "6", height: "6", rx: "50" }) }) })), icon && (jsx(Icon, { className: "badge__icon", size: iconSize, iconFill: iconFill, imageSrc: iconSrc, shape: iconShape, SvgImage: icon })), children ||
1206
+ (value && (jsx(Text, { className: "badge__value", size: textSize, textColor: textColor, children: value })))] }));
1207
+ }
1208
+
1209
+ const linkAppearanceAccent = {
1210
+ accentPrimary: {
1211
+ fill: 'accentPrimary',
1212
+ fillHover: 'accentHoverPrimary',
1213
+ borderColor: 'accentBorderPrimary',
1214
+ },
1215
+ accentSecondary: {
1216
+ fill: 'accentPrimary',
1217
+ fillHover: 'accentHoverPrimary',
1218
+ labelTextColor: 'accentTextSecondary',
1219
+ labelTextColorHover: 'accentTextSecondary',
1220
+ borderColor: 'accentBorderPrimary',
1221
+ },
1222
+ };
1223
+
1224
+ const linkAppearanceDanger = {
1225
+ dangerPrimary: {
1226
+ fill: 'dangerPrimary',
1227
+ fillHover: 'dangerHoverPrimary',
1228
+ },
1229
+ };
1230
+
1231
+ const linkAppearanceDisabled = {
1232
+ disabledPrimary: {
1233
+ fill: 'surfaceDisabled',
1234
+ borderColor: 'errorBorderQuaternary',
1235
+ textColor: 'surfaceTextQuaternary',
1236
+ },
1237
+ disabledSecondary: {
1238
+ fill: 'surfaceSecondary',
1239
+ borderColor: 'surfaceBorderTertiary',
1240
+ borderColorHover: 'surfaceBorderQuaternary',
1241
+ },
1242
+ };
1243
+
1244
+ const linkAppearanceError = {
1245
+ errorPrimary: {
1246
+ fill: 'errorPrimary',
1247
+ fillHover: 'errorHoverPrimary',
1248
+ labelTextColor: 'errorTextPrimary',
1249
+ labelTextColorHover: 'errorTextPrimary',
1250
+ },
1251
+ };
1252
+
1253
+ const linkAppearanceExtra = {
1254
+ extraPrimary: {
1255
+ fill: 'extraPrimary',
1256
+ fillHover: 'extraHoverPrimary',
1257
+ labelTextColor: 'extraTextPrimary',
1258
+ },
1259
+ };
1260
+
1261
+ const linkAppearanceInfo = {
1262
+ infoPrimary: {
1263
+ fill: 'accentPrimary',
1264
+ fillHover: 'accentHoverPrimary',
1265
+ labelTextColor: 'accentTextPrimary',
1266
+ labelTextColorHover: 'accentTextPrimary',
1267
+ borderColor: 'accentBorderPrimary',
1268
+ },
1269
+ infoSecondary: {
1270
+ fill: 'accentPrimary',
1271
+ fillHover: 'accentHoverPrimary',
1272
+ labelTextColor: 'accentTextSecondary',
1273
+ labelTextColorHover: 'accentTextPrimary',
1274
+ borderColor: 'accentBorderPrimary',
1275
+ },
1276
+ };
1277
+
1278
+ const linkAppearanceRequire = {
1279
+ requirePrimary: {
1280
+ fill: 'warningTertiary',
1281
+ borderColor: 'warningBorderQuaternary',
1282
+ textColor: 'surfaceTextPrimary',
1283
+ },
1284
+ requireSecondary: {
1285
+ fill: 'surfaceSecondary',
1286
+ borderColor: 'surfaceBorderTertiary',
1287
+ },
1288
+ };
1289
+
1290
+ const linkAppearanceSize = {
1291
+ sizeXXL: {
1292
+ size: 'xxl',
1293
+ labelTextSize: 'xxl',
1294
+ iconAfterFillSize: '24',
1295
+ iconAfterSize: '24',
1296
+ iconBeforeFillSize: '24',
1297
+ iconBeforeSize: '24',
1298
+ },
1299
+ sizeXL: {
1300
+ size: 'xl',
1301
+ labelTextSize: 'l',
1302
+ iconAfterFillSize: '24',
1303
+ iconAfterSize: '24',
1304
+ iconBeforeFillSize: '24',
1305
+ iconBeforeSize: '24',
1306
+ },
1307
+ sizeL: {
1308
+ size: 'l',
1309
+ labelTextSize: 'l',
1310
+ iconAfterFillSize: '24',
1311
+ iconAfterSize: '24',
1312
+ iconBeforeFillSize: '24',
1313
+ iconBeforeSize: '24',
1314
+ },
1315
+ sizeM: {
1316
+ size: 'm',
1317
+ labelTextSize: 'm',
1318
+ iconAfterFillSize: '24',
1319
+ iconAfterSize: '24',
1320
+ iconBeforeFillSize: '24',
1321
+ iconBeforeSize: '24',
1322
+ },
1323
+ sizeS: {
1324
+ size: 's',
1325
+ labelTextSize: 's',
1326
+ iconAfterFillSize: '20',
1327
+ iconAfterSize: '20',
1328
+ iconBeforeFillSize: '20',
1329
+ iconBeforeSize: '20',
1330
+ },
1331
+ sizeXS: {
1332
+ size: 'xs',
1333
+ labelTextSize: 'xs',
1334
+ iconAfterFillSize: '16',
1335
+ iconAfterSize: '16',
1336
+ iconBeforeFillSize: '16',
1337
+ iconBeforeSize: '16',
1338
+ },
1339
+ sizeXXS: {
1340
+ size: 'xxs',
1341
+ labelTextSize: 'xs',
1342
+ iconAfterFillSize: '14',
1343
+ iconAfterSize: '14',
1344
+ iconBeforeFillSize: '14',
1345
+ iconBeforeSize: '14',
1346
+ },
1347
+ };
1348
+
1349
+ const linkAppearanceSpecial = {
1350
+ specialPrimary: {
1351
+ fill: 'specialPrimary',
1352
+ fillHover: 'specialHoverPrimary',
1353
+ labelTextColor: 'specialTextPrimary',
1354
+ },
1355
+ };
1356
+
1357
+ const linkAppearanceStyle = {
1358
+ solid: {
1359
+ borderColor: 'none',
1360
+ },
1361
+ outlined: {
1362
+ fill: 'none',
1363
+ },
1364
+ full: {
1365
+ borderColor: 'none',
1366
+ },
1367
+ ghost: {
1368
+ fill: 'none',
1369
+ borderColor: 'none',
1370
+ },
1371
+ };
1372
+
1373
+ const linkAppearanceSuccess = {
1374
+ successPrimary: {
1375
+ fill: 'successPrimary',
1376
+ fillHover: 'successHoverPrimary',
1377
+ labelTextColor: 'successTextSecondary',
1378
+ labelTextColorHover: 'successTextSecondary',
1379
+ },
1380
+ };
1381
+
1382
+ const linkAppearanceSurface = {
1383
+ surfacePrimary: {
1384
+ fill: 'surfacePrimary',
1385
+ fillHover: 'surfaceHoverPrimary',
1386
+ labelTextColor: 'surfaceTextPrimary',
1387
+ },
1388
+ surfaceQuaternary: {
1389
+ fill: 'surfaceQuaternary',
1390
+ fillHover: 'surfaceHoverQuaternary',
1391
+ labelTextColor: 'surfaceTextPrimary',
1392
+ },
1393
+ surfaceSecondary: {
1394
+ fill: 'surfaceSecondary',
1395
+ fillHover: 'surfaceHoverSecondary',
1396
+ labelTextColor: 'surfaceTextPrimary',
1397
+ },
1398
+ surfaceTertiary: {
1399
+ fill: 'surfaceTertiary',
1400
+ fillHover: 'surfaceHoverTertiary',
1401
+ labelTextColor: 'surfaceTextPrimary',
1402
+ },
1403
+ };
1404
+
1405
+ const linkAppearanceWarning = {
1406
+ warningPrimary: {
1407
+ fill: 'warningPrimary',
1408
+ fillHover: 'warningHoverPrimary',
1409
+ labelTextColor: 'warningTextSecondary',
1410
+ labelTextColorHover: 'warningTextSecondary',
1411
+ },
1412
+ };
1413
+
1414
+ const linkAppearance = {
1415
+ ...linkAppearanceSize,
1416
+ ...linkAppearanceDisabled,
1417
+ ...linkAppearanceRequire,
1418
+ ...linkAppearanceStyle,
1419
+ ...linkAppearanceAccent,
1420
+ ...linkAppearanceDanger,
1421
+ ...linkAppearanceError,
1422
+ ...linkAppearanceInfo,
1423
+ ...linkAppearanceSpecial,
1424
+ ...linkAppearanceExtra,
1425
+ ...linkAppearanceSuccess,
1426
+ ...linkAppearanceSurface,
1427
+ ...linkAppearanceWarning,
1428
+ };
1429
+
1430
+ const linkConfig = {
1431
+ appearance: linkAppearance,
1432
+ LinkComponent: 'a',
1433
+ setAppearance: (appearanceConfig) => {
1434
+ linkConfig.appearance = appearanceConfig;
1435
+ },
1436
+ setLinkComponent: (newComponent) => {
1437
+ linkConfig.LinkComponent = newComponent;
1438
+ },
1439
+ };
1440
+ function Link(props) {
1441
+ const { appearance, className, dataTestId, dataTour, text, href, link, LinkComponent, rel, style, target, before, after, isDisabled, onClick, onMouseDown, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, children, } = props;
1442
+ const appearanceConfig = useAppearanceConfig(appearance, linkConfig, isDisabled);
1443
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
1444
+ const { directionClass, fillClass, fillHoverClass, borderColorClass, borderColorHoverClass, borderTypeClass, borderWidthClass, textColorClass, textColorHoverClass, textGradientClass, textStyleClass, textWeightClass, heightClass, shapeClass, sizeClass, svgFillClass, svgFillHoverClass, underline = 'underline', widthClass, } = propsGenerator;
1445
+ const { styles } = useStyles(props);
1446
+ return (jsxs(LinkWrapper, { className: clsx(className, 'link', widthClass && `width_${widthClass}`, heightClass && `height_${heightClass}`, directionClass && `link_direction_${directionClass}`, sizeClass && `text_size_${sizeClass}`, svgFillClass && `svg_fill_${svgFillClass}`, svgFillHoverClass && `svg_fill_hover_${svgFillHoverClass}`, underline && `link_underline_${underline}`, 'text', (textColorClass ||
1447
+ textColorHoverClass ||
1448
+ textGradientClass ||
1449
+ textStyleClass ||
1450
+ textWeightClass) &&
1451
+ 'text', textColorClass && `text-color_${textColorClass}`, textColorHoverClass && `text-color_hover_${textColorHoverClass}`, textGradientClass && `text-gradient_${textGradientClass}`, textStyleClass && `text-style_${textStyleClass}`, textWeightClass && `text-weight_${textWeightClass}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, borderColorClass && `border-color_${borderColorClass}`, borderColorHoverClass && `border-color_hover_${borderColorHoverClass}`, borderWidthClass && `border-width_${borderWidthClass}`, borderTypeClass && `border_type_${borderTypeClass}`, shapeClass && `link_shape_${shapeClass}`), "data-testid": dataTestId, "data-tour": dataTour, href: href || link, LinkComponent: LinkComponent, rel: rel, style: Object.assign({}, styles, style), target: target, onClick: onClick, onMouseDown: onMouseDown, onPointerCancel: onPointerCancel, onPointerDown: onPointerDown, onPointerLeave: onPointerLeave, onPointerUp: onPointerUp, children: [before, children || text, after] }));
1452
+ }
1453
+ function LinkWrapper(props) {
1454
+ const { href, LinkComponent, rel, target, children, ...otherProps } = props;
1455
+ if (href) {
1456
+ const Component = LinkComponent || linkConfig.LinkComponent;
1457
+ if (Component) {
1458
+ return (jsx(Component, { href: href, rel: rel, target: target, ...otherProps, children: children }));
1459
+ }
1460
+ }
1461
+ else if (LinkComponent) {
1462
+ return jsx(LinkComponent, { ...otherProps, children: children });
1463
+ }
1464
+ return React.Children.toArray(children)
1465
+ .filter(Boolean)
1466
+ .map((child) => {
1467
+ return React.isValidElement(child)
1468
+ ? React.cloneElement(child, otherProps)
1469
+ : child;
1470
+ });
1471
+ }
1472
+
1473
+ const titleAppearanceAccent = {
1474
+ accentPrimary: {
1475
+ fill: 'accentPrimary',
1476
+ fillHover: 'accentHoverPrimary',
1477
+ },
1478
+ accentSecondary: {
1479
+ fill: 'accentPrimary',
1480
+ fillHover: 'accentHoverPrimary',
1481
+ },
1482
+ };
1483
+
1484
+ const titleAppearanceDanger = {
1485
+ dangerPrimary: {
1486
+ fill: 'dangerPrimary',
1487
+ fillHover: 'dangerHoverPrimary',
1488
+ },
1489
+ };
1490
+
1491
+ const titleAppearanceDisabled = {
1492
+ disabledPrimary: {
1493
+ fill: 'surfacePrimary',
1494
+ borderColor: 'errorBorderQuaternary',
1495
+ borderHover: 'errorBorderHoverQuaternary',
1496
+ textColor: 'surfaceTextQuaternary',
1497
+ iconBeforeFill: 'errorQuaternary',
1498
+ },
1499
+ disabledSecondary: {
1500
+ fill: 'surfaceSecondary',
1501
+ borderColor: 'surfaceBorderTertiary',
1502
+ borderHover: 'surfaceBorderHoverQuaternary',
1503
+ iconBeforeFill: 'surfaceQuaternary',
1504
+ },
1505
+ };
1506
+
1507
+ const titleAppearanceError = {
1508
+ errorPrimary: {
1509
+ fill: 'errorPrimary',
1510
+ fillHover: 'errorHoverPrimary',
1511
+ textColor: 'errorTextPrimary',
1512
+ textColorHover: 'errorTextPrimary',
1513
+ },
1514
+ };
1515
+
1516
+ const titleAppearanceExtra = {
1517
+ extraPrimary: {
1518
+ fill: 'extraPrimary',
1519
+ fillHover: 'extraHoverPrimary',
1520
+ textColor: 'extraTextPrimary',
1521
+ },
1522
+ };
1523
+
1524
+ const titleAppearanceInfo = {
1525
+ infoPrimary: {
1526
+ fill: 'accentPrimary',
1527
+ fillHover: 'accentHoverPrimary',
1528
+ },
1529
+ infoSecondary: {
1530
+ fill: 'accentPrimary',
1531
+ fillHover: 'accentHoverPrimary',
1532
+ },
1533
+ };
1534
+
1535
+ const titleAppearanceRequire = {
1536
+ requirePrimary: {
1537
+ fill: 'warningTertiary',
1538
+ borderColor: 'warningBorderQuaternary',
1539
+ borderHover: 'warningBorderQuaternary',
1540
+ textColor: 'surfaceTextPrimary',
1541
+ iconBeforeFill: 'warningQuaternary',
1542
+ },
1543
+ requireSecondary: {
1544
+ fill: 'surfaceSecondary',
1545
+ borderColor: 'surfaceBorderTertiary',
1546
+ borderHover: 'surfaceBorderQuaternary',
1547
+ iconBeforeFill: 'surfaceQuaternary',
1548
+ },
1549
+ };
1550
+
1551
+ const titleAppearanceSize = {
1552
+ h1: {
1553
+ size: 'h1',
1554
+ iconAfterFillSize: '24',
1555
+ iconAfterSize: '24',
1556
+ iconBeforeFillSize: '24',
1557
+ iconBeforeSize: '24',
1558
+ },
1559
+ h2: {
1560
+ size: 'h2',
1561
+ iconAfterFillSize: '24',
1562
+ iconAfterSize: '24',
1563
+ iconBeforeFillSize: '24',
1564
+ iconBeforeSize: '24',
1565
+ },
1566
+ h3: {
1567
+ size: 'h3',
1568
+ iconAfterFillSize: '24',
1569
+ iconAfterSize: '24',
1570
+ iconBeforeFillSize: '24',
1571
+ iconBeforeSize: '24',
1572
+ },
1573
+ h4: {
1574
+ size: 'h4',
1575
+ iconAfterFillSize: '24',
1576
+ iconAfterSize: '24',
1577
+ iconBeforeFillSize: '24',
1578
+ iconBeforeSize: '24',
1579
+ },
1580
+ h5: {
1581
+ size: 'h5',
1582
+ iconAfterFillSize: '20',
1583
+ iconAfterSize: '20',
1584
+ iconBeforeFillSize: '20',
1585
+ iconBeforeSize: '20',
1586
+ },
1587
+ h6: {
1588
+ size: 'h6',
1589
+ iconAfterFillSize: '16',
1590
+ iconAfterSize: '16',
1591
+ iconBeforeFillSize: '16',
1592
+ iconBeforeSize: '16',
1593
+ },
1594
+ };
1595
+
1596
+ const titleAppearanceSpecial = {
1597
+ specialPrimary: {
1598
+ fill: 'specialPrimary',
1599
+ fillHover: 'specialHoverPrimary',
1600
+ },
1601
+ };
1602
+
1603
+ const titleAppearanceStyle = {
1604
+ solid: {},
1605
+ outlined: {
1606
+ fill: 'none',
1607
+ },
1608
+ full: {},
1609
+ ghost: {
1610
+ fill: 'none',
1611
+ },
1612
+ };
1613
+
1614
+ const titleAppearanceSuccess = {
1615
+ successPrimary: {
1616
+ fill: 'successPrimary',
1617
+ fillHover: 'successHoverPrimary',
1618
+ },
1619
+ };
1620
+
1621
+ const titleAppearanceSurface = {
1622
+ surfacePrimary: {
1623
+ fill: 'surfacePrimary',
1624
+ fillHover: 'surfaceHoverPrimary',
1625
+ },
1626
+ surfaceQuaternary: {
1627
+ fill: 'surfaceQuaternary',
1628
+ fillHover: 'surfaceHoverQuaternary',
1629
+ },
1630
+ surfaceSecondary: {
1631
+ fill: 'surfaceSecondary',
1632
+ fillHover: 'surfaceHoverSecondary',
1633
+ },
1634
+ surfaceTertiary: {
1635
+ fill: 'surfaceTertiary',
1636
+ fillHover: 'surfaceHoverTertiary',
1637
+ },
1638
+ };
1639
+
1640
+ const titleAppearanceWarning = {
1641
+ warningPrimary: {
1642
+ fill: 'warningPrimary',
1643
+ fillHover: 'warningHoverPrimary',
1644
+ textColor: 'warningTextSecondary',
1645
+ textColorHover: 'warningTextSecondary',
1646
+ },
1647
+ };
1648
+
1649
+ const titleAppearance = {
1650
+ ...titleAppearanceSize,
1651
+ ...titleAppearanceDisabled,
1652
+ ...titleAppearanceStyle,
1653
+ ...titleAppearanceAccent,
1654
+ ...titleAppearanceDanger,
1655
+ ...titleAppearanceError,
1656
+ ...titleAppearanceInfo,
1657
+ ...titleAppearanceSpecial,
1658
+ ...titleAppearanceExtra,
1659
+ ...titleAppearanceSuccess,
1660
+ ...titleAppearanceSurface,
1661
+ ...titleAppearanceWarning,
1662
+ ...titleAppearanceRequire,
1663
+ };
1664
+
1665
+ const titleConfig = {
1666
+ appearance: titleAppearance,
1667
+ setAppearance: (appearanceConfig) => {
1668
+ titleConfig.appearance = appearanceConfig;
1669
+ },
1670
+ };
1671
+ function Title(props) {
1672
+ const { appearance, className, dataTestId, dataTour, text, afterWrapper, beforeWrapper, style, tag = 'span', before, after, isActive, isDisabled, isSkeleton, onClick, children, } = props;
1673
+ const appearanceConfig = useAppearanceConfig(appearance, titleConfig, isDisabled);
1674
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
1675
+ const { directionClass, size, fillClass, fillHoverClass, textAlignClass, textColorActiveClass, textColorActiveHoverClass, textColorClass, textColorDisabledClass, textColorHoverClass, textFontClass, textStyleClass, textTruncateClass, textWeightClass, textWrap, heightClass, iconAfter, iconAfterFill, iconAfterFillIcon, iconAfterFillSize, iconAfterShape, iconAfterSize, iconAfterSrc, iconBadgeAppearance, iconBadgeShape, iconBadgeSize, iconBadgeTextColor, iconBadgeTextSize, iconBadgeValue, iconBefore, iconBeforeFill, iconBeforeFillIcon, iconBeforeFillSize, iconBeforeShape, iconBeforeSize, iconBeforeSrc, svgFillClass, svgFillHoverClass, widthClass, wrapperDirectionClass, onClickIconAfter, onClickIconBefore, } = propsGenerator;
1676
+ const { styles: titleStyles, wrapper: titleWrapperStyles } = useStyles(props);
1677
+ const Tag = useMemo(() => {
1678
+ if (tag) {
1679
+ return tag;
1680
+ }
1681
+ return size ? size : 'span';
1682
+ }, [tag, size]);
1683
+ return (jsxs(Tag, { className: clsx(className, 'title', fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, svgFillClass && `svg_fill_${svgFillClass}`, svgFillHoverClass && `svg_fill_hover_${svgFillHoverClass}`, widthClass && `width_${widthClass}`, heightClass && `height_${heightClass}`, size && `title_size_${size}`, directionClass && `title_direction_${directionClass}`, isDisabled &&
1684
+ textColorDisabledClass &&
1685
+ `text-color_${textColorDisabledClass}`, !isActive &&
1686
+ !isDisabled &&
1687
+ textColorClass &&
1688
+ `text text-color_${textColorClass}`, isActive &&
1689
+ !isDisabled &&
1690
+ textColorActiveClass &&
1691
+ `text-color_active_${textColorActiveClass}`, !isActive &&
1692
+ !isDisabled &&
1693
+ textColorHoverClass &&
1694
+ `text-color_hover_${textColorHoverClass}`, isActive &&
1695
+ !isDisabled &&
1696
+ textColorActiveHoverClass &&
1697
+ `text-color_active_hover${textColorActiveHoverClass}`, textFontClass && `text-font_${textFontClass}`, textStyleClass && `text-style_${textStyleClass}`, textWeightClass && `text-weight_${textWeightClass}`, textWrap && `word-wrap_${textWrap}`, iconBadgeValue && 'title_badge', isSkeleton && 'title_skeleton'), "data-testid": dataTestId, "data-tour": dataTour, style: Object.assign({}, titleStyles, style), onClick: onClick, children: [before, jsxs("span", { className: clsx(textAlignClass && `text-align_${textAlignClass}`, wrapperDirectionClass && `title_direction_${wrapperDirectionClass}`, 'title__wrapper', textTruncateClass && `text-truncate_${textTruncateClass}`), style: titleWrapperStyles, children: [(iconBefore || iconBeforeSrc) && (jsx(Icon, { className: clsx('title__icon_before', iconBadgeValue && 'title__icon_before-badge'), fill: iconBeforeFill, fillSize: iconBeforeFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'title__icon_before_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore, onClick: onClickIconBefore })), beforeWrapper, children || text, afterWrapper, (iconAfter || iconAfterSrc) && (jsx(Icon, { className: clsx('title__icon_after', iconBadgeValue && 'title__icon_after-badge'), fill: iconAfterFill, fillSize: iconAfterFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'title__icon_after_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter, onClick: onClickIconAfter }))] }), after] }));
1698
+ }
1699
+
1700
+ const tooltipAppearanceDefault = {
1701
+ defaultPrimary: {
1702
+ fill: 'surfacePrimary',
1703
+ fillHover: 'surfaceHoverPrimary',
1704
+ titleColor: 'surfaceTextPrimary',
1705
+ borderColor: 'surfaceBorderPrimary',
1706
+ textColor: 'surfaceTextPrimary',
1707
+ },
1708
+ };
1709
+
1710
+ const tooltipAppearanceDisabled = {
1711
+ disabledPrimary: {
1712
+ fill: 'disabledPrimary',
1713
+ fillHover: 'disabledHoverPrimary',
1714
+ titleColor: 'surfaceTextPrimary',
1715
+ textColor: 'surfaceTextPrimary',
1716
+ },
1717
+ };
1718
+
1719
+ const tooltipAppearanceError = {
1720
+ errorPrimary: {
1721
+ fill: 'errorPrimary',
1722
+ fillHover: 'errorHoverPrimary',
1723
+ borderColor: 'errorBorderPrimary',
1724
+ titleColor: 'errorTextPrimary',
1725
+ textColor: 'errorTextPrimary',
1726
+ },
1727
+ };
1728
+
1729
+ const tooltipAppearanceRequire = {
1730
+ requirePrimary: {
1731
+ fill: 'warningPrimary',
1732
+ fillHover: 'warningHoverPrimary',
1733
+ borderColor: 'warningBorderPrimary',
1734
+ titleColor: 'warningTextPrimary',
1735
+ textColor: 'warningTextPrimary',
1736
+ },
1737
+ };
1738
+
1739
+ const tooltipAppearanceShape = {
1740
+ circular: {
1741
+ shape: 'circular',
1742
+ },
1743
+ rounded: {
1744
+ shape: 'rounded',
1745
+ },
1746
+ roundedXL: {
1747
+ shape: 'rounded',
1748
+ shapeStrength: '2m',
1749
+ },
1750
+ roundedL: {
1751
+ shape: 'rounded',
1752
+ shapeStrength: '1_5m',
1753
+ },
1754
+ roundedM: {
1755
+ shape: 'rounded',
1756
+ shapeStrength: '1m',
1757
+ },
1758
+ roundedS: {
1759
+ shape: 'rounded',
1760
+ shapeStrength: '0_5m',
1761
+ },
1762
+ };
1763
+
1764
+ const tooltipAppearanceSize = {
1765
+ sizeL: {
1766
+ size: 'l',
1767
+ titleSize: 'h5',
1768
+ textSize: 's',
1769
+ },
1770
+ sizeM: {
1771
+ size: 'm',
1772
+ titleSize: 'h5',
1773
+ textSize: 's',
1774
+ },
1775
+ sizeS: {
1776
+ size: 's',
1777
+ titleSize: 'h5',
1778
+ textSize: 's',
1779
+ },
1780
+ };
1781
+
1782
+ const tooltipAppearanceStyle = {
1783
+ solid: {
1784
+ borderColor: 'none',
1785
+ },
1786
+ outlined: {
1787
+ fill: 'none',
1788
+ },
1789
+ full: {},
1790
+ ghost: {
1791
+ fill: 'none',
1792
+ borderColor: 'none',
1793
+ },
1794
+ };
1795
+
1796
+ const tooltipAppearanceSuccess = {
1797
+ successPrimary: {
1798
+ fill: 'successPrimary',
1799
+ fillHover: 'successHoverPrimary',
1800
+ borderColor: 'successBorderPrimary',
1801
+ titleColor: 'successTextPrimary',
1802
+ textColor: 'successTextPrimary',
1803
+ },
1804
+ };
1805
+
1806
+ const tooltipAppearance = {
1807
+ ...tooltipAppearanceDefault,
1808
+ ...tooltipAppearanceSize,
1809
+ ...tooltipAppearanceDisabled,
1810
+ ...tooltipAppearanceRequire,
1811
+ ...tooltipAppearanceShape,
1812
+ ...tooltipAppearanceStyle,
1813
+ ...tooltipAppearanceError,
1814
+ ...tooltipAppearanceSuccess,
1815
+ };
1816
+
1817
+ const tooltipConfig = {
1818
+ appearance: tooltipAppearance,
1819
+ setAppearance: (appearanceConfig) => {
1820
+ tooltipConfig.appearance = appearanceConfig;
1821
+ },
1822
+ };
1823
+ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
1824
+ const { appearance, className, dataTestId, dataTour, initialIsVisible, title, text, before, after, openTimeoutDelay = 500, closeTimeoutDelay = 250, isSkeleton, isTooltipDisableState, children, } = props;
1825
+ const tooltipElementRef = useRef(null);
1826
+ const tooltipTimeoutHideRef = useRef(null);
1827
+ const tooltipTimeoutShowRef = useRef(null);
1828
+ const isTooltipCloseAnimationInProgressRef = useRef(false);
1829
+ const [isTooltipVisible, setIsTooltipVisible] = useState(initialIsVisible);
1830
+ const openTooltip = useCallback(() => {
1831
+ if (!isTooltipCloseAnimationInProgressRef.current) {
1832
+ if (tooltipTimeoutHideRef.current) {
1833
+ clearTimeout(tooltipTimeoutHideRef.current);
1834
+ }
1835
+ tooltipTimeoutShowRef.current = setTimeout(() => {
1836
+ setIsTooltipVisible(true);
1837
+ }, openTimeoutDelay);
1838
+ }
1839
+ }, [openTimeoutDelay]);
1840
+ const closeTooltip = useCallback(() => {
1841
+ if (tooltipTimeoutShowRef.current) {
1842
+ clearTimeout(tooltipTimeoutShowRef.current);
1843
+ }
1844
+ tooltipTimeoutHideRef.current = setTimeout(() => {
1845
+ setIsTooltipVisible((prevState) => {
1846
+ const newState = false;
1847
+ if (prevState === true) {
1848
+ isTooltipCloseAnimationInProgressRef.current = true;
1849
+ }
1850
+ return newState;
1851
+ });
1852
+ }, closeTimeoutDelay);
1853
+ }, [closeTimeoutDelay]);
1854
+ const onAnimationEnd = useCallback(() => {
1855
+ isTooltipCloseAnimationInProgressRef.current = false;
1856
+ }, []);
1857
+ useImperativeHandle(ref, () => ({
1858
+ get tooltipElement() {
1859
+ return tooltipElementRef.current;
1860
+ },
1861
+ openTooltip: openTooltip,
1862
+ closeTooltip: closeTooltip,
1863
+ isTooltipVisible: isTooltipVisible,
1864
+ }), [isTooltipVisible, openTooltip, closeTooltip]);
1865
+ const appearanceConfig = useAppearanceConfig(appearance, tooltipConfig);
1866
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
1867
+ const { alignClass, alignDirectionClass, alignmentClass, alignPosition, fillClass, titleColor, titleSize, titleWeight, borderColorClass, borderTypeClass, borderWidthClass, textColor, textSize, textWeight, arrowPosition, centeringClass, elevationClass, shapeClass, shapeStrengthClass, sizeClass, widthClass, } = propsGenerator;
1868
+ const { styles: tooltipStyles } = useStyles(props);
1869
+ return (jsxs("div", { className: clsx(className, 'tooltip', !isTooltipDisableState
1870
+ ? isTooltipVisible
1871
+ ? 'tooltip_state_open'
1872
+ : 'tooltip_state_close'
1873
+ : null, alignPosition && `tooltip_align-position_${alignPosition}`, alignDirectionClass && `align_${alignDirectionClass}`, alignClass && `align_${alignClass}`, elevationClass && `elevation_${elevationClass}`, centeringClass && `centering_${centeringClass}`, alignmentClass && `alignment_${alignmentClass}`, sizeClass && `tooltip_size_${sizeClass}`, isSkeleton && 'tooltip_skeleton', widthClass && `width_${widthClass}`), ref: tooltipElementRef, "data-testid": dataTestId, "data-tour": dataTour, style: tooltipStyles, onAnimationEnd: onAnimationEnd, children: [arrowPosition && (jsx("div", { className: clsx('tooltip__arrow', arrowPosition && `tooltip__arrow_position_${arrowPosition}`, fillClass && `fill_${fillClass}`), children: "\u00A0" })), before, jsxs("div", { className: clsx('tooltip__inner', borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderTypeClass && `border_type_${borderTypeClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`), children: [title && (jsx(Title, { className: "tooltip__title text", size: titleSize, textColor: titleColor, textWeight: titleWeight, children: title })), text && (jsx(Text, { className: "tooltip__text", size: textSize, textColor: textColor, textWeight: textWeight, children: text })), children] }), after] }));
1874
+ });
1875
+
1876
+ const UrlAssetPrefixContext = createContext({
1877
+ assetPrefix: undefined,
1878
+ ignorePathsList: undefined,
1879
+ });
1880
+ function UrlAssetPrefixProvider(props) {
1881
+ const { assetPrefix, ignorePathsList, children } = props;
1882
+ const value = useMemo(() => ({ assetPrefix, ignorePathsList }), [assetPrefix, ignorePathsList]);
1883
+ return (jsx(UrlAssetPrefixContext.Provider, { value: value, children: children }));
1884
+ }
1885
+
1886
+ const urlPropsList = ['src', 'imageSrc', 'svgSrc', 'placeholderUrl'];
1887
+ /**
1888
+ * HOC, который добавляет assetPrefix к URL-пропсам.
1889
+ *
1890
+ * @template P - Тип пропсов оборачиваемого компонента.
1891
+ * @template T - Тип ref (если используется forwardRef).
1892
+ * @template Check - Проверка на наличие хотя бы одного URL-пропа.
1893
+ *
1894
+ * @param WrappedComponent - Компонент, который оборачиваем.
1895
+ * @param _error - Проверка: если ни одного URL-пропа нет, будет ошибка компиляции.
1896
+ *
1897
+ * @example
1898
+ * const A = (props: { src?: string }) => <div />;
1899
+ * urlWithAssetPrefix(A); // ✅ OK
1900
+ *
1901
+ * const B = (props: { id: string }) => <div />;
1902
+ * urlWithAssetPrefix(B); // ❌ TS ошибка (нет url-пропов)
1903
+ */
1904
+ const urlWithAssetPrefix = (WrappedComponent, ..._error) => {
1905
+ const HOC = React.forwardRef(function HOC(props, ref) {
1906
+ const { assetPrefix, ignorePathsList } = useContext(UrlAssetPrefixContext);
1907
+ const overrideProps = urlPropsList.reduce((resultProps, propKey) => {
1908
+ let url = props[propKey];
1909
+ if (url && typeof url === 'string') {
1910
+ if (assetPrefix) {
1911
+ const isNeedAssetPrefix = checkIsNeedAssetPrefix(url, assetPrefix, ignorePathsList);
1912
+ if (isNeedAssetPrefix) {
1913
+ const prefixPath = formatURL(assetPrefix).slice(0, -1);
1914
+ url = `${prefixPath}${url}`;
1915
+ }
1916
+ }
1917
+ resultProps[propKey] = url;
1918
+ }
1919
+ return resultProps;
1920
+ }, {});
1921
+ return jsx(WrappedComponent, { ...props, ...overrideProps, ref: ref });
1922
+ });
1923
+ return HOC;
1924
+ };
1925
+ const checkIsNeedAssetPrefix = (url, assetPrefix, ignorePathsList = []) => {
1926
+ // Ignore prefix if:
1927
+ const isPrefixIgnore =
1928
+ // Url is absolute
1929
+ url.startsWith('http:') ||
1930
+ url.startsWith('https:') ||
1931
+ // Url is data string
1932
+ url.startsWith('data:') ||
1933
+ // Url already have prefix
1934
+ url.startsWith(assetPrefix);
1935
+ if (isPrefixIgnore) {
1936
+ return false;
1937
+ }
1938
+ // And check special paths for ignore prefix
1939
+ for (const urlPath of ignorePathsList) {
1940
+ if (urlPath instanceof RegExp) {
1941
+ if (urlPath.test(url)) {
1942
+ return false;
1943
+ }
1944
+ }
1945
+ else {
1946
+ if (formatURL(url).startsWith(formatURL(urlPath))) {
1947
+ return false;
1948
+ }
1949
+ }
1950
+ }
1951
+ // Need to add prefix to url
1952
+ return true;
1953
+ };
1954
+
1955
+ const iconAppearanceAccent = {
1956
+ accentPrimary: {
1957
+ fill: 'accentPrimary',
1958
+ fillHover: 'accentHoverPrimary',
1959
+ borderColor: 'accentBorderPrimary',
1960
+ badgeAppearance: 'surfacePrimary',
1961
+ iconFill: 'accentItemPrimary',
1962
+ },
1963
+ accentSecondary: {
1964
+ fill: 'accentPrimary',
1965
+ fillHover: 'accentHoverPrimary',
1966
+ borderColor: 'accentBorderPrimary',
1967
+ iconFill: 'accentItemPrimary',
1968
+ },
1969
+ };
1970
+
1971
+ const iconAppearanceDanger = {
1972
+ dangerPrimary: {
1973
+ fill: 'dangerPrimary',
1974
+ fillHover: 'dangerHoverPrimary',
1975
+ borderColor: 'dangerBorderSecondary',
1976
+ badgeAppearance: 'surfacePrimary',
1977
+ iconFill: 'dangerItemPrimary',
1978
+ },
1979
+ };
1980
+
1981
+ const iconAppearanceDisabled = {
1982
+ disabledPrimary: {
1983
+ fill: 'surfacePrimary',
1984
+ borderColor: 'surfaceBorderPrimary',
1985
+ badgeAppearance: 'surfacePrimary',
1986
+ iconFill: 'surfaceItemQuaternary',
1987
+ },
1988
+ };
1989
+
1990
+ const iconAppearanceError = {
1991
+ errorPrimary: {
1992
+ fill: 'errorPrimary',
1993
+ fillHover: 'errorHoverPrimary',
1994
+ borderColor: 'errorBorderPrimary',
1995
+ badgeAppearance: 'surfacePrimary',
1996
+ iconFill: 'errorItemPrimary',
1997
+ },
1998
+ };
1999
+
2000
+ const iconAppearanceExtra = {
2001
+ extraPrimary: {
2002
+ fill: 'extraPrimary',
2003
+ fillHover: 'extraHoverPrimary',
2004
+ borderColor: 'extraBorderQuaternary',
2005
+ badgeAppearance: 'surfacePrimary',
2006
+ iconFill: 'extraItemPrimary',
2007
+ },
2008
+ };
2009
+
2010
+ const iconAppearanceInfo = {
2011
+ infoPrimary: {
2012
+ fill: 'infoPrimary',
2013
+ borderColor: 'infoBorderPrimary',
2014
+ badgeAppearance: 'surfacePrimary',
2015
+ iconFill: 'infoItemPrimary',
2016
+ },
2017
+ infoSecondary: {
2018
+ fill: 'accentPrimary',
2019
+ fillHover: 'accentHoverPrimary',
2020
+ borderColor: 'accentBorderPrimary',
2021
+ iconFill: 'infoItemSecondary',
2022
+ },
2023
+ };
2024
+
2025
+ const iconAppearanceShape = {
2026
+ circular: {
2027
+ shape: 'circular',
2028
+ },
2029
+ rounded: {
2030
+ shape: 'rounded',
2031
+ },
2032
+ roundedXL: {
2033
+ shape: 'rounded',
2034
+ shapeStrength: '2m',
2035
+ },
2036
+ roundedL: {
2037
+ shape: 'rounded',
2038
+ shapeStrength: '1_5m',
2039
+ },
2040
+ roundedM: {
2041
+ shape: 'rounded',
2042
+ shapeStrength: '1m',
2043
+ },
2044
+ roundedS: {
2045
+ shape: 'rounded',
2046
+ shapeStrength: '0_5m',
2047
+ },
2048
+ };
2049
+
2050
+ const iconAppearanceSize = {
2051
+ size12_12: {
2052
+ fillSize: '12',
2053
+ badgeAppearanceSize: 'sizeXXS',
2054
+ badgeSize: 'xxs',
2055
+ iconSize: '12',
2056
+ },
2057
+ size14_12: {
2058
+ fillSize: '14',
2059
+ badgeAppearanceSize: 'sizeXXS',
2060
+ badgeSize: 'xxs',
2061
+ iconSize: '12',
2062
+ },
2063
+ size14_14: {
2064
+ fillSize: '14',
2065
+ badgeAppearanceSize: 'sizeXXS',
2066
+ badgeSize: 'xxs',
2067
+ iconSize: '14',
2068
+ },
2069
+ size16_12: {
2070
+ fillSize: '16',
2071
+ badgeAppearanceSize: 'sizeXXS',
2072
+ badgeSize: 'xxs',
2073
+ iconSize: '12',
2074
+ },
2075
+ size16_14: {
2076
+ fillSize: '16',
2077
+ badgeAppearanceSize: 'sizeXXS',
2078
+ badgeSize: 'xxs',
2079
+ iconSize: '14',
2080
+ },
2081
+ size16_16: {
2082
+ fillSize: '16',
2083
+ badgeAppearanceSize: 'sizeXXS',
2084
+ badgeSize: 'xxs',
2085
+ iconSize: '16',
2086
+ },
2087
+ size20_12: {
2088
+ fillSize: '20',
2089
+ badgeAppearanceSize: 'sizeXXS',
2090
+ badgeSize: 'xxs',
2091
+ iconSize: '12',
2092
+ },
2093
+ size20_14: {
2094
+ fillSize: '20',
2095
+ badgeAppearanceSize: 'sizeXXS',
2096
+ badgeSize: 'xxs',
2097
+ iconSize: '14',
2098
+ },
2099
+ size20_16: {
2100
+ fillSize: '20',
2101
+ badgeAppearanceSize: 'sizeXXS',
2102
+ badgeSize: 'xxs',
2103
+ iconSize: '16',
2104
+ },
2105
+ size20_20: {
2106
+ fillSize: '20',
2107
+ badgeAppearanceSize: 'sizeXXS',
2108
+ badgeSize: 'xxs',
2109
+ iconSize: '20',
2110
+ },
2111
+ size24_12: {
2112
+ fillSize: '24',
2113
+ badgeAppearanceSize: 'sizeXXS',
2114
+ badgeSize: 'xxs',
2115
+ iconSize: '12',
2116
+ },
2117
+ size24_14: {
2118
+ fillSize: '24',
2119
+ badgeAppearanceSize: 'sizeXXS',
2120
+ badgeSize: 'xxs',
2121
+ iconSize: '14',
2122
+ },
2123
+ size24_16: {
2124
+ fillSize: '24',
2125
+ badgeAppearanceSize: 'sizeXXS',
2126
+ badgeSize: 'xxs',
2127
+ iconSize: '16',
2128
+ },
2129
+ size24_20: {
2130
+ fillSize: '24',
2131
+ badgeAppearanceSize: 'sizeXXS',
2132
+ badgeSize: 'xxs',
2133
+ iconSize: '20',
2134
+ },
2135
+ size24_24: {
2136
+ fillSize: '24',
2137
+ badgeAppearanceSize: 'sizeXXS',
2138
+ badgeSize: 'xxs',
2139
+ iconSize: '24',
2140
+ },
2141
+ size32_12: {
2142
+ fillSize: '32',
2143
+ badgeAppearanceSize: 'sizeXXS',
2144
+ badgeSize: 'xxs',
2145
+ iconSize: '12',
2146
+ },
2147
+ size32_14: {
2148
+ fillSize: '32',
2149
+ badgeAppearanceSize: 'sizeXXS',
2150
+ badgeSize: 'xxs',
2151
+ iconSize: '14',
2152
+ },
2153
+ size32_16: {
2154
+ fillSize: '32',
2155
+ badgeAppearanceSize: 'sizeXXS',
2156
+ badgeSize: 'xxs',
2157
+ iconSize: '16',
2158
+ },
2159
+ size32_20: {
2160
+ fillSize: '32',
2161
+ badgeAppearanceSize: 'sizeXXS',
2162
+ badgeSize: 'xxs',
2163
+ iconSize: '20',
2164
+ },
2165
+ size32_24: {
2166
+ fillSize: '32',
2167
+ badgeAppearanceSize: 'sizeXXS',
2168
+ badgeSize: 'xxs',
2169
+ iconSize: '24',
2170
+ },
2171
+ size32_32: {
2172
+ fillSize: '32',
2173
+ badgeAppearanceSize: 'sizeXXS',
2174
+ badgeSize: 'xxs',
2175
+ iconSize: '32',
2176
+ },
2177
+ size40_12: {
2178
+ fillSize: '40',
2179
+ badgeAppearanceSize: 'sizeXXS',
2180
+ badgeSize: 'xxs',
2181
+ iconSize: '12',
2182
+ },
2183
+ size40_14: {
2184
+ fillSize: '40',
2185
+ badgeAppearanceSize: 'sizeXXS',
2186
+ badgeSize: 'xxs',
2187
+ iconSize: '14',
2188
+ },
2189
+ size40_16: {
2190
+ fillSize: '40',
2191
+ badgeAppearanceSize: 'sizeXXS',
2192
+ badgeSize: 'xxs',
2193
+ iconSize: '16',
2194
+ },
2195
+ size40_20: {
2196
+ fillSize: '40',
2197
+ badgeAppearanceSize: 'sizeXXS',
2198
+ badgeSize: 'xxs',
2199
+ iconSize: '20',
2200
+ },
2201
+ size40_24: {
2202
+ fillSize: '40',
2203
+ badgeAppearanceSize: 'sizeXXS',
2204
+ badgeSize: 'xxs',
2205
+ iconSize: '24',
2206
+ },
2207
+ size40_32: {
2208
+ fillSize: '40',
2209
+ badgeAppearanceSize: 'sizeXXS',
2210
+ badgeSize: 'xxs',
2211
+ iconSize: '32',
2212
+ },
2213
+ size40_40: {
2214
+ fillSize: '40',
2215
+ badgeAppearanceSize: 'sizeXXS',
2216
+ badgeSize: 'xxs',
2217
+ iconSize: '40',
2218
+ },
2219
+ };
2220
+
2221
+ const iconAppearanceSpecial = {
2222
+ specialPrimary: {
2223
+ fill: 'specialPrimary',
2224
+ fillHover: 'specialHoverPrimary',
2225
+ borderColor: 'specialBorderQuaternary',
2226
+ badgeAppearance: 'surfacePrimary',
2227
+ iconFill: 'specialItemPrimary',
2228
+ },
2229
+ };
2230
+
2231
+ const iconAppearanceStyle = {
2232
+ solid: {
2233
+ borderColor: 'none',
2234
+ },
2235
+ outlined: {
2236
+ fill: 'none',
2237
+ },
2238
+ full: {},
2239
+ ghost: {
2240
+ fill: 'none',
2241
+ borderColor: 'none',
2242
+ },
2243
+ };
2244
+
2245
+ const iconAppearanceSuccess = {
2246
+ successPrimary: {
2247
+ fill: 'successPrimary',
2248
+ fillHover: 'successHoverPrimary',
2249
+ borderColor: 'successBorderPrimary',
2250
+ badgeAppearance: 'surfacePrimary',
2251
+ iconFill: 'successItemPrimary',
2252
+ },
2253
+ };
2254
+
2255
+ const iconAppearanceSurface = {
2256
+ surfacePrimary: {
2257
+ fill: 'surfacePrimary',
2258
+ fillHover: 'surfaceHoverSecondary',
2259
+ borderColor: 'surfaceBorderTertiary',
2260
+ badgeAppearance: 'surfacePrimary',
2261
+ iconFill: 'surfaceItemPrimary',
2262
+ },
2263
+ surfaceQuaternary: {
2264
+ fill: 'surfaceQuaternary',
2265
+ fillHover: 'surfaceHoverQuaternary',
2266
+ badgeAppearance: 'accentPrimary',
2267
+ iconFill: 'surfaceItemPrimary',
2268
+ },
2269
+ surfaceSecondary: {
2270
+ fill: 'surfaceSecondary',
2271
+ fillHover: 'surfaceHoverSecondary',
2272
+ badgeAppearance: 'accentPrimary solid rounded',
2273
+ iconFill: 'surfaceItemPrimary',
2274
+ },
2275
+ surfaceTertiary: {
2276
+ fill: 'surfaceTertiary',
2277
+ fillHover: 'surfaceHoverTertiary',
2278
+ badgeAppearance: 'accentPrimary',
2279
+ iconFill: 'surfaceItemPrimary',
2280
+ },
2281
+ };
2282
+
2283
+ const iconAppearanceWarning = {
2284
+ warningPrimary: {
2285
+ fill: 'warningPrimary',
2286
+ fillHover: 'warningHoverPrimary',
2287
+ borderColor: 'warningBorderSecondary',
2288
+ badgeAppearance: 'surfacePrimary',
2289
+ iconFill: 'warningItemPrimary',
2290
+ },
2291
+ };
2292
+
2293
+ const iconAppearance = {
2294
+ ...iconAppearanceDisabled,
2295
+ ...iconAppearanceSize,
2296
+ ...iconAppearanceStyle,
2297
+ ...iconAppearanceAccent,
2298
+ ...iconAppearanceShape,
2299
+ ...iconAppearanceDanger,
2300
+ ...iconAppearanceError,
2301
+ ...iconAppearanceInfo,
2302
+ ...iconAppearanceSpecial,
2303
+ ...iconAppearanceExtra,
2304
+ ...iconAppearanceSuccess,
2305
+ ...iconAppearanceSurface,
2306
+ ...iconAppearanceWarning,
2307
+ };
2308
+
2309
+ const iconConfig = {
2310
+ appearance: iconAppearance,
2311
+ setAppearance: (appearanceConfig) => {
2312
+ iconConfig.appearance = appearanceConfig;
2313
+ },
2314
+ };
2315
+ const Icon = urlWithAssetPrefix(React.forwardRef(function Icon(props, ref) {
2316
+ const { id, appearance, className, dataTestId, dataTour, width, height, badgeClass, href, imageSrc, link, linkRel, linkTarget, notification, saveFillStroke, showTooltip, SvgImage, before, after, isActive, isDisabled, isSkeleton, onClick, onMouseEnter, onMouseLeave, } = props;
2317
+ const ImageComponent = useMemo(() => {
2318
+ if (SvgImage) {
2319
+ const SvgComponent = SvgImage;
2320
+ const sizes = {};
2321
+ if (width) {
2322
+ sizes.width = width;
2323
+ }
2324
+ if (height) {
2325
+ sizes.height = height;
2326
+ }
2327
+ return jsx(SvgComponent, { ...sizes });
2328
+ }
2329
+ if (imageSrc) {
2330
+ if (imageSrc.endsWith('.svg')) {
2331
+ if (saveFillStroke) {
2332
+ return jsx(SVG, { src: imageSrc });
2333
+ }
2334
+ return jsx(SVG, { src: imageSrc, preProcessor: removeFillStroke });
2335
+ }
2336
+ return jsx("img", { src: imageSrc });
2337
+ }
2338
+ return null;
2339
+ }, [SvgImage, imageSrc, width, height, saveFillStroke]);
2340
+ const appearanceConfig = useAppearanceConfig(appearance, iconConfig, isDisabled);
2341
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
2342
+ const { alignmentClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, fillSizeClass, borderColorClass, borderColorHoverClass, borderTypeClass, borderWidthClass, badgeAppearance, badgeAppearanceSize, badgeShape, badgeSize, badgeTextColor, badgeTextSize, badgeValue, centeringClass, iconFillActiveClass, iconFillActiveHoverClass, iconFillClass, iconFillDisabledClass, iconFillHoverClass, iconSizeClass, shapeClass, shapeStrengthClass, tooltipAppearance, tooltipText, tooltipTextSize, tooltipTitle, tooltipTitleSize, } = propsGenerator;
2343
+ const { styles: iconStyles } = useStyles(props);
2344
+ return (jsxs("div", { id: id, className: clsx(className, 'icon', !isActive
2345
+ ? fillClass && `fill_${fillClass}`
2346
+ : fillActiveClass && `fill_active_${fillActiveClass}`, !isActive
2347
+ ? fillHoverClass && `fill_hover_${fillHoverClass}`
2348
+ : fillActiveHoverClass &&
2349
+ `fill_active_hover_${fillActiveHoverClass}`, fillSizeClass && `icon_fill_size_${fillSizeClass}`, fillDisabledClass && `fill_disabled_${fillDisabledClass}`, !isActive
2350
+ ? iconFillClass && `icon_fill_${iconFillClass}`
2351
+ : iconFillActiveClass && `icon_fill_active_${iconFillActiveClass}`, !isActive
2352
+ ? iconFillHoverClass && `icon_fill_hover_${iconFillHoverClass}`
2353
+ : iconFillActiveHoverClass &&
2354
+ `icon_fill_active_hover_${iconFillActiveHoverClass}`, isDisabled &&
2355
+ iconFillDisabledClass &&
2356
+ `icon_fill_disabled_${iconFillDisabledClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderColorHoverClass &&
2357
+ `border-color_hover_${borderColorHoverClass}`, borderWidthClass && `border-width_${borderWidthClass}`, borderTypeClass && `border_type_${borderTypeClass}`, badgeValue && 'icon_with-badge', centeringClass && `centering_${centeringClass}`, onClick && 'cursor_type_pointer', isSkeleton && `icon_skeleton`), ref: ref, "data-testid": dataTestId, "data-tour": dataTour, style: iconStyles, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: [before, jsxs(LinkWrapper, { className: clsx((link || href || onClick) && 'cursor_type_pointer', link || href ? 'icon__link' : 'icon__item', iconSizeClass && `icon_size_${iconSizeClass}`), href: link || href, LinkComponent: "div", rel: linkRel, target: linkTarget, children: [ImageComponent, (badgeValue || notification) && (jsx(Badge, { appearance: mergeAppearanceKeys(badgeAppearance, badgeAppearanceSize), className: clsx(badgeClass, 'icon__badge'), size: badgeSize, textColor: badgeTextColor, textSize: badgeTextSize, shape: badgeShape, value: badgeValue })), showTooltip && (jsx(Tooltip, { appearance: tooltipAppearance, className: clsx(className, 'icon__tooltip', alignmentClass && `alignment_${alignmentClass}`), title: tooltipTitle, titleSize: tooltipTitleSize, text: tooltipText, textSize: tooltipTextSize }))] }), after] }));
2358
+ }));
2359
+ const removeFillStroke = (code) => {
2360
+ return code
2361
+ .replace(/fill=".*?"/g, 'fill=""')
2362
+ .replace(/stroke=".*?"/g, 'stroke=""');
2363
+ };
2364
+
2365
+ const dividerAppearanceAccent = {
2366
+ accentPrimary: {
2367
+ fill: 'accentPrimary',
2368
+ },
2369
+ };
2370
+
2371
+ const dividerAppearanceError = {
2372
+ errorPrimary: {
2373
+ fill: 'errorPrimary',
2374
+ },
2375
+ };
2376
+
2377
+ const dividerAppearanceExtra = {
2378
+ extraPrimary: {
2379
+ fill: 'extraPrimary',
2380
+ },
2381
+ };
2382
+
2383
+ const dividerAppearanceSize = {
2384
+ sizeL: {
2385
+ size: 'l',
2386
+ },
2387
+ sizeM: {
2388
+ size: 'm',
2389
+ },
2390
+ sizeS: {
2391
+ size: 's',
2392
+ },
2393
+ };
2394
+
2395
+ const dividerAppearanceSpecial = {
2396
+ specialPrimary: {
2397
+ fill: 'specialPrimary',
2398
+ },
2399
+ };
2400
+
2401
+ const dividerAppearanceSuccess = {
2402
+ successPrimary: {
2403
+ fill: 'successPrimary',
2404
+ },
2405
+ };
2406
+
2407
+ const dividerAppearanceSurface = {
2408
+ surfacePrimary: {
2409
+ fill: 'surfacePrimary',
2410
+ },
2411
+ surfaceQuaternary: {
2412
+ fill: 'surfaceQuaternary',
2413
+ },
2414
+ surfaceSecondary: {
2415
+ fill: 'surfaceSecondary',
2416
+ },
2417
+ surfaceTertiary: {
2418
+ fill: 'surfaceTertiary',
2419
+ },
2420
+ };
2421
+
2422
+ const dividerAppearanceWarning = {
2423
+ warningPrimary: {
2424
+ fill: 'warningPrimary',
2425
+ },
2426
+ };
2427
+
2428
+ const dividerAppearance = {
2429
+ ...dividerAppearanceSize,
2430
+ ...dividerAppearanceAccent,
2431
+ ...dividerAppearanceError,
2432
+ ...dividerAppearanceSpecial,
2433
+ ...dividerAppearanceExtra,
2434
+ ...dividerAppearanceSuccess,
2435
+ ...dividerAppearanceSurface,
2436
+ ...dividerAppearanceWarning,
2437
+ };
2438
+
2439
+ const dividerConfig = {
2440
+ appearance: dividerAppearance,
2441
+ setAppearance: (appearanceConfig) => {
2442
+ dividerConfig.appearance = appearanceConfig;
2443
+ },
2444
+ };
2445
+ function Divider(props) {
2446
+ const { appearance, className, dataTestId, dataTour, print, isActive, isDisabled, isSkeleton, } = props;
2447
+ const appearanceConfig = useAppearanceConfig(appearance, dividerConfig);
2448
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
2449
+ const { directionClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, shapeClass, shapeStrengthClass, sizeClass, widthClass, } = propsGenerator;
2450
+ const { styles: hrStyles } = useStyles(props);
2451
+ return (jsx("hr", { className: clsx(className, 'divider', widthClass && `width_${widthClass}`, directionClass && `divider_direction_${directionClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, sizeClass && `divider_size_${sizeClass}`, !isActive
2452
+ ? fillClass && `fill_${fillClass}`
2453
+ : fillActiveClass && `fill_active_${fillActiveClass}`, !isActive
2454
+ ? fillHoverClass && `fill_hover_${fillHoverClass}`
2455
+ : fillActiveHoverClass && `fill_active_hover_${fillActiveHoverClass}`, isDisabled && fillDisabledClass && `fill_disabled_${fillDisabledClass}`, isSkeleton && `divider_skeleton`, !print && 'no-print', print && 'print'), "data-testid": dataTestId, "data-tour": dataTour, style: hrStyles }));
2456
+ }
2457
+
2458
+ const dropdownAppearanceAccent = {
2459
+ accentPrimary: {
2460
+ fill: 'accentPrimary',
2461
+ fillActive: 'accentActivePrimary',
2462
+ fillActiveHover: 'accentActiveHoverPrimary',
2463
+ fillHover: 'accentHoverPrimary',
2464
+ labelTextColor: 'accentTextPrimary',
2465
+ labelTextColorActive: 'accentTextPrimary',
2466
+ labelTextColorActiveHover: 'accentTextPrimary',
2467
+ labelTextColorHover: 'accentTextPrimary',
2468
+ badgeAppearance: 'surfacePrimary',
2469
+ dividerFill: 'surfaceTertiary',
2470
+ emptyMessageTextColor: 'accentTextPrimary',
2471
+ iconAfterFillIcon: 'accentItemPrimary',
2472
+ iconBeforeFillIcon: 'accentItemPrimary',
2473
+ },
2474
+ accentSecondary: {
2475
+ fill: 'accentPrimary',
2476
+ fillHover: 'accentHoverPrimary',
2477
+ labelTextColor: 'accentTextSecondary',
2478
+ labelTextColorHover: 'accentTextSecondary',
2479
+ },
2480
+ };
2481
+
2482
+ const dropdownAppearanceShape = {
2483
+ circular: {
2484
+ shape: 'circular',
2485
+ },
2486
+ rounded: {
2487
+ shape: 'rounded',
2488
+ },
2489
+ roundedXL: {
2490
+ shape: 'rounded',
2491
+ shapeStrength: '2m',
2492
+ },
2493
+ roundedL: {
2494
+ shape: 'rounded',
2495
+ shapeStrength: '1_5m',
2496
+ },
2497
+ roundedM: {
2498
+ shape: 'rounded',
2499
+ shapeStrength: '1m',
2500
+ },
2501
+ roundedS: {
2502
+ shape: 'rounded',
2503
+ shapeStrength: '0_5m',
2504
+ },
2505
+ };
2506
+
2507
+ const dropdownAppearanceSize = {
2508
+ sizeL: {
2509
+ size: 'l',
2510
+ labelTextSize: 'm',
2511
+ badgeSize: 'xs',
2512
+ badgeTextSize: 'xs',
2513
+ dividerSize: 's',
2514
+ emptyMessageTextSize: 'm',
2515
+ iconAfterFillSize: '24',
2516
+ iconAfterSize: '24',
2517
+ iconBeforeFillSize: '24',
2518
+ iconBeforeSize: '24',
2519
+ },
2520
+ sizeS: {
2521
+ size: 's',
2522
+ labelTextSize: 's',
2523
+ badgeSize: 'xs',
2524
+ badgeTextSize: 'xs',
2525
+ dividerSize: 's',
2526
+ emptyMessageTextSize: 'm',
2527
+ iconAfterFillSize: '16',
2528
+ iconAfterSize: '16',
2529
+ iconBeforeFillSize: '16',
2530
+ iconBeforeSize: '16',
2531
+ },
2532
+ sizeXS: {
2533
+ size: 'xs',
2534
+ labelTextSize: 'xs',
2535
+ badgeSize: 'xs',
2536
+ badgeTextSize: 'xs',
2537
+ dividerSize: 's',
2538
+ emptyMessageTextSize: 'xs',
2539
+ iconAfterFillSize: '12',
2540
+ iconAfterSize: '12',
2541
+ iconBeforeFillSize: '12',
2542
+ iconBeforeSize: '12',
2543
+ },
2544
+ };
2545
+
2546
+ const dropdownAppearanceStyle = {
2547
+ solid: {
2548
+ borderColor: 'none',
2549
+ },
2550
+ outlined: {
2551
+ fill: 'none',
2552
+ },
2553
+ full: {},
2554
+ ghost: {
2555
+ fill: 'none',
2556
+ borderColor: 'none',
2557
+ },
2558
+ };
2559
+
2560
+ const dropdownAppearanceSurface = {
2561
+ surfacePrimary: {
2562
+ fill: 'surfacePrimary',
2563
+ fillActive: 'surfaceActivePrimary',
2564
+ fillHover: 'surfaceHoverPrimary',
2565
+ labelTextColor: 'surfaceTextPrimary',
2566
+ labelTextColorActive: 'surfaceTextPrimary',
2567
+ labelTextColorActiveHover: 'surfaceTextPrimary',
2568
+ labelTextColorHover: 'surfaceTextPrimary',
2569
+ badgeAppearance: 'accentPrimary',
2570
+ dividerFill: 'surfaceTertiary',
2571
+ emptyMessageTextColor: 'surfaceTextPrimary',
2572
+ iconAfterFillIcon: 'surfaceItemPrimary',
2573
+ iconBeforeFillIcon: 'surfaceItemPrimary',
2574
+ },
2575
+ surfaceQuaternary: {
2576
+ fill: 'surfaceQuaternary',
2577
+ fillHover: 'surfaceHoverQuaternary',
2578
+ labelTextColor: 'surfaceTextPrimary',
2579
+ },
2580
+ surfaceSecondary: {
2581
+ fill: 'surfaceSecondary',
2582
+ fillHover: 'surfaceHoverSecondary',
2583
+ labelTextColor: 'surfaceTextPrimary',
2584
+ },
2585
+ surfaceTertiary: {
2586
+ fill: 'surfaceTertiary',
2587
+ fillHover: 'surfaceHoverTertiary',
2588
+ labelTextColor: 'surfaceTextPrimary',
2589
+ },
2590
+ };
2591
+
2592
+ const dropdownAppearance = {
2593
+ ...dropdownAppearanceSurface,
2594
+ ...dropdownAppearanceStyle,
2595
+ ...dropdownAppearanceShape,
2596
+ ...dropdownAppearanceAccent,
2597
+ ...dropdownAppearanceSize,
2598
+ };
2599
+
2600
+ const dropdownConfig = {
2601
+ appearance: dropdownAppearance};
2602
+ function Dropdown(props) {
2603
+ const { appearance, className, dataTestId, dataTour, animationClose = 'dropdown_animation_close', animationOpen = 'dropdown_animation_open', dropdownList, showDivider, before, after, isSkeleton, isOpen, setIsOpen, onClickItem, children, } = props;
2604
+ const dropdownRef = useRef(null);
2605
+ const appearanceConfig = useAppearanceConfig(appearance, dropdownConfig);
2606
+ const [animationState, setAnimationState] = useState({
2607
+ className: '',
2608
+ });
2609
+ const onAnimationEnd = useCallback(() => {
2610
+ setAnimationState((prevState) => ({
2611
+ className: isOpen ? prevState.className : '',
2612
+ }));
2613
+ }, [isOpen]);
2614
+ useEffect(() => {
2615
+ if (animationOpen && animationClose) {
2616
+ // eslint-disable-next-line react-hooks/set-state-in-effect
2617
+ setAnimationState(() => ({
2618
+ className: isOpen ? animationOpen : animationClose,
2619
+ }));
2620
+ }
2621
+ }, [isOpen, animationOpen, animationClose]);
2622
+ useEffect(() => {
2623
+ function onClickWindow(event) {
2624
+ const dropdownElement = dropdownRef.current;
2625
+ if (dropdownElement && animationOpen) {
2626
+ const isContainsTarget = dropdownElement.contains(event.target);
2627
+ const hasOpenClass = dropdownElement.classList.contains(animationOpen);
2628
+ if (!isContainsTarget && hasOpenClass) {
2629
+ setIsOpen(false);
2630
+ }
2631
+ }
2632
+ }
2633
+ window.addEventListener('click', onClickWindow);
2634
+ return () => {
2635
+ window.removeEventListener('click', onClickWindow);
2636
+ };
2637
+ }, [animationOpen, setIsOpen]);
2638
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
2639
+ const { alignmentClass, fillClass, elevationClass, shapeClass, shapeStrengthClass, } = propsGenerator;
2640
+ const { styles } = useStyles(props);
2641
+ return (jsxs("div", { className: clsx(className, 'dropdown', alignmentClass && `alignment_${alignmentClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`, isOpen ? 'dropdown_state_open' : 'dropdown_state_close', animationState.className), ref: dropdownRef, "data-testid": dataTestId, "data-tour": dataTour, style: styles, children: [before, (children || dropdownList) && (jsxs("div", { className: clsx('dropdown__wrapper'), onAnimationEnd: onAnimationEnd, children: [dropdownList?.map((item) => (jsx(DropdownItem, { appearance: appearance, label: item.label, badgeValue: item.badgeValue, emptyMessage: item.emptyMessage, iconAfter: item.iconAfter, iconBefore: item.iconBefore, iconSrc: item.icon, showDivider: showDivider, isActive: item.isActive, isSkeleton: isSkeleton, onClick: item.onClick || ((event) => onClickItem?.(item, event)) }, item.key))), children] })), after] }));
2642
+ }
2643
+
2644
+ const dropdownItemAppearance = {
2645
+ ...dropdownAppearanceSurface,
2646
+ ...dropdownAppearanceStyle,
2647
+ ...dropdownAppearanceShape,
2648
+ ...dropdownAppearanceAccent,
2649
+ ...dropdownAppearanceSize,
2650
+ };
2651
+
2652
+ const dropdownItemConfig = {
2653
+ appearance: dropdownItemAppearance,
2654
+ setAppearance: (appearanceConfig) => {
2655
+ dropdownItemConfig.appearance = appearanceConfig;
2656
+ },
2657
+ };
2658
+ function DropdownItem(props) {
2659
+ const { appearance, className, dataTestId, dataTour, label, desc, badgeValue, emptyMessage, showDivider, before, after, isActive, isDisabled, isSkeleton, isHover, onClick, onMouseEnter, children, } = props;
2660
+ const appearanceConfig = useAppearanceConfig(appearance, dropdownItemConfig);
2661
+ const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
2662
+ const { directionClass, justifyContentClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, labelTextAlign, labelTextColor, labelTextColorActive, labelTextColorActiveHover, labelTextColorHover, labelTextSize, labelTextStyle, labelTextWeight, labelTextWrap, descTextColor, descTextColorHover, descTextGradient, descTextSize, descTextStyle, descTextWeight, descTextWrap, badgeAppearance, badgeShape, badgeSize, badgeTextColor, badgeTextSize, dividerDirection, dividerFill, dividerSize, emptyMessageTextColor, emptyMessageTextColorHover, emptyMessageTextSize, emptyMessageTextStyle, emptyMessageTextWeight, emptyMessageTextWrap, iconAfter, iconAfterFill, iconAfterFillIcon, iconAfterFillSize, iconAfterShape, iconAfterSize, iconAfterSrc, iconBadgeAppearance, iconBadgeShape, iconBadgeSize, iconBadgeTextColor, iconBadgeTextSize, iconBadgeValue, iconBefore, iconBeforeFill, iconBeforeFillIcon, iconBeforeFillSize, iconBeforeShape, iconBeforeSize, iconBeforeSrc, shapeClass, shapeStrengthClass, sizeClass, widthClass, } = propsGenerator;
2663
+ const { styles: dropdownItem } = useStyles(props);
2664
+ return (jsxs("div", { className: clsx('dropdown__item', isActive && 'dropdown__item_state_active', isHover && 'dropdown__item_state_hover', directionClass && `dropdown__item_direction_${directionClass}`, className, !isActive
2665
+ ? fillClass && `fill_${fillClass}`
2666
+ : fillActiveClass && `fill_active_${fillActiveClass}`, !isActive
2667
+ ? fillHoverClass && `fill_hover_${fillHoverClass}`
2668
+ : fillActiveHoverClass && `fill_active_hover_${fillActiveHoverClass}`, fillDisabledClass && `fill_disabled_${fillDisabledClass}`, sizeClass && `dropdown__item_size_${sizeClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, widthClass && `dropdown__item_width_${widthClass}`, isDisabled && `dropdown__item_state_disabled`, onClick && 'cursor_type_pointer', isSkeleton && `dropdown__item_skeleton`, justifyContentClass &&
2669
+ `dropdown__item_justify-content_${justifyContentClass}`), "data-testid": dataTestId, "data-tour": dataTour, style: dropdownItem, onClick: onClick, onMouseEnter: onMouseEnter, children: [jsx("div", { className: "dropdown__item-wrapper", children: jsxs(React.Fragment, { children: [before, (iconBefore || iconBeforeSrc) && (jsx(Icon, { className: clsx('dropdown__item_before', iconBadgeValue && 'dropdown__item_before-badge'), fill: iconBeforeFill, fillSize: iconBeforeFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'dropdown__item_before_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), children || (jsxs(React.Fragment, { children: [label && (jsx(Text, { className: "dropdown__item-label", size: labelTextSize, textAlign: labelTextAlign, textColor: labelTextColor, textColorActive: labelTextColorActive, textColorActiveHover: labelTextColorActiveHover, textColorHover: labelTextColorHover, textStyle: labelTextStyle, textWeight: labelTextWeight, textWrap: labelTextWrap, isActive: isActive, children: label })), badgeValue && (jsx(Badge, { appearance: badgeAppearance, size: badgeSize, textColor: badgeTextColor, textSize: badgeTextSize, shape: badgeShape, value: badgeValue })), desc && (jsx(Text, { className: "dropdown__item-desc", size: descTextSize, textColor: descTextColor, textColorGradient: descTextGradient, textColorHover: descTextColorHover, textStyle: descTextStyle, textWeight: descTextWeight, textWrap: descTextWrap, isActive: isActive, children: desc })), emptyMessage && (jsx(Text, { className: "dropdown__item", size: emptyMessageTextSize, textColor: emptyMessageTextColor, textColorHover: emptyMessageTextColorHover, textStyle: emptyMessageTextStyle, textWeight: emptyMessageTextWeight, textWrap: emptyMessageTextWrap, isActive: isActive, children: emptyMessage }))] })), after, (iconAfter || iconAfterSrc) && (jsx(Icon, { className: clsx('dropdown__item_after', iconBadgeValue && 'dropdown__item_after-badge'), fill: iconAfterFill, fillSize: iconAfterFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'dropdown__item_after_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter }))] }) }), showDivider && (jsx(Divider, { width: "fill", direction: dividerDirection, size: dividerSize, fill: dividerFill }))] }));
2670
+ }
2671
+
2672
+ export { tooltipConfig as A, Badge as B, UrlAssetPrefixContext as C, Divider as D, UrlAssetPrefixProvider as E, iconAppearance as F, iconConfig as G, dividerAppearance as H, Icon as I, dividerConfig as J, dropdownItemAppearance as K, LinkWrapper as L, dropdownItemConfig as M, NotificationsProvider as N, Title as T, UIProvider as U, useDevicePropsGenerator as a, Text as b, urlWithAssetPrefix as c, useAppearanceConfig as d, useUserDeviceContext as e, Dropdown as f, DropdownItem as g, Link as h, Tooltip as i, useNotifications as j, useNotificationsAPI as k, useMediaQueries as l, mergeAppearanceKeys as m, getStyleAttributeKey as n, styleAttributes as o, textConfig as p, badgeAppearance as q, badgeConfig as r, setViewportProperty as s, textAppearance as t, useStyles as u, linkAppearance as v, linkConfig as w, titleAppearance as x, titleConfig as y, tooltipAppearance as z };