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