@itcase/ui 1.8.107 → 1.8.109

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 (227) hide show
  1. package/dist/{Avatar_cjs_bOSuIjlv.js → Avatar_cjs_joB9qjwk.js} +36 -60
  2. package/dist/{Avatar_es_CEiiRkAd.js → Avatar_es_C3HGSiHU.js} +36 -60
  3. package/dist/{Button_cjs_eGfgY2Dz.js → Button_cjs_mau_55Fl.js} +6 -6
  4. package/dist/{Button_es_CEXL2diU.js → Button_es_D_IlkeBp.js} +6 -6
  5. package/dist/{ChipsGroup_cjs_DKLEgUi2.js → ChipsGroup_cjs_D454M1-p.js} +2 -2
  6. package/dist/{ChipsGroup_es_vMh6YMRm.js → ChipsGroup_es_BKG5mK5N.js} +2 -2
  7. package/dist/{DatePicker_cjs_T63y9kcH.js → DatePicker_cjs_Bm8nwWKa.js} +4 -4
  8. package/dist/{DatePicker_es_B87jj8h6.js → DatePicker_es_DAV92A4A.js} +4 -4
  9. package/dist/{DropdownItem_cjs_BGp4XAme.js → DropdownItem_cjs_D2hHKA5E.js} +2 -2
  10. package/dist/{DropdownItem_es_BwdenrJx.js → DropdownItem_es_D9JBMV70.js} +2 -2
  11. package/dist/{Group_cjs_CHcrOFx0.js → Group_cjs_BxBk5T7A.js} +2 -2
  12. package/dist/{Group_es_DHJcG2MA.js → Group_es_DIfmrMSM.js} +2 -2
  13. package/dist/{Icon_cjs_LSfBwmrG.js → Icon_cjs_ZerVip3X.js} +32 -47
  14. package/dist/{Icon_es_BYO1LdXJ.js → Icon_es_C76te22j.js} +32 -47
  15. package/dist/{Label_cjs_Df_mrKBf.js → Label_cjs_CaTh_laL.js} +2 -2
  16. package/dist/{Label_es_Dl5zb0RD.js → Label_es_CoIII7Ty.js} +2 -2
  17. package/dist/{Loader_cjs_Db9diKuF.js → Loader_cjs_c6yF7akz.js} +1 -1
  18. package/dist/{Loader_es_AhHU-s7_.js → Loader_es_C8ETXkiZ.js} +1 -1
  19. package/dist/{Text_cjs_CeJHeRfI.js → Text_cjs_DpRclhwc.js} +2 -5
  20. package/dist/{Text_es_BXh9Y3hR.js → Text_es_CtCwsa3V.js} +2 -5
  21. package/dist/cjs/components/Accordion.js +4 -3
  22. package/dist/cjs/components/Avatar.js +5 -4
  23. package/dist/cjs/components/AvatarStack.js +6 -5
  24. package/dist/cjs/components/Badge.js +4 -3
  25. package/dist/cjs/components/Breadcrumbs.js +4 -3
  26. package/dist/cjs/components/Button.js +6 -5
  27. package/dist/cjs/components/Cell.js +5 -4
  28. package/dist/cjs/components/Checkbox.js +3 -2
  29. package/dist/cjs/components/Checkmark.js +2 -1
  30. package/dist/cjs/components/Chips.js +5 -4
  31. package/dist/cjs/components/Choice.js +5 -4
  32. package/dist/cjs/components/Code.js +2 -0
  33. package/dist/cjs/components/CookiesWarning.js +6 -5
  34. package/dist/cjs/components/Dadata.js +2 -0
  35. package/dist/cjs/components/DatePeriod.js +8 -7
  36. package/dist/cjs/components/DatePicker.js +8 -7
  37. package/dist/cjs/components/Divider.js +2 -1
  38. package/dist/cjs/components/Dot.js +2 -1
  39. package/dist/cjs/components/Drawer.js +3 -2
  40. package/dist/cjs/components/Dropdown.js +5 -4
  41. package/dist/cjs/components/Flex.js +2 -1
  42. package/dist/cjs/components/Grid.js +2 -1
  43. package/dist/cjs/components/Group.js +3 -2
  44. package/dist/cjs/components/HTMLContent.js +2 -1
  45. package/dist/cjs/components/HeroTitle.js +4 -3
  46. package/dist/cjs/components/Icon.js +4 -3
  47. package/dist/cjs/components/Image.js +2 -1
  48. package/dist/cjs/components/Input.js +2 -0
  49. package/dist/cjs/components/InputPassword.js +4 -3
  50. package/dist/cjs/components/Label.js +5 -4
  51. package/dist/cjs/components/Link.js +2 -1
  52. package/dist/cjs/components/List.js +2 -1
  53. package/dist/cjs/components/Loader.js +4 -3
  54. package/dist/cjs/components/Logo.js +2 -1
  55. package/dist/cjs/components/MenuItem.js +4 -3
  56. package/dist/cjs/components/Modal.js +5 -4
  57. package/dist/cjs/components/ModalSheetBottom.js +4 -3
  58. package/dist/cjs/components/Notification.js +4 -3
  59. package/dist/cjs/components/Overlay.js +2 -1
  60. package/dist/cjs/components/Pagination.js +5 -4
  61. package/dist/cjs/components/Radio.js +8 -4
  62. package/dist/cjs/components/RangeSlider.js +2 -1
  63. package/dist/cjs/components/Response.js +7 -6
  64. package/dist/cjs/components/SVGContent.js +2 -1
  65. package/dist/cjs/components/ScrollOnDrag.js +2 -1
  66. package/dist/cjs/components/ScrollToView.js +2 -1
  67. package/dist/cjs/components/Search.js +4 -3
  68. package/dist/cjs/components/Segmented.js +3 -2
  69. package/dist/cjs/components/Select.js +5 -4
  70. package/dist/cjs/components/Swiper.js +4 -3
  71. package/dist/cjs/components/Switch.js +3 -2
  72. package/dist/cjs/components/Tab.js +14 -16
  73. package/dist/cjs/components/Text.js +3 -2
  74. package/dist/cjs/components/Textarea.js +2 -0
  75. package/dist/cjs/components/Tile.js +4 -3
  76. package/dist/cjs/components/Title.js +4 -3
  77. package/dist/cjs/components/Tooltip.js +4 -3
  78. package/dist/cjs/components/Video.js +1 -0
  79. package/dist/cjs/components/Warning.js +4 -3
  80. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.helpers.js +120 -0
  81. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.interface.js +65 -0
  82. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.js +64 -0
  83. package/dist/cjs/hooks/useActiveClasses.js +9 -0
  84. package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +11 -1
  85. package/dist/cjs/hooks/useDevicePropsGenerator.js +2 -0
  86. package/dist/cjs/hooks/useStyles/useStyles.js +5 -3
  87. package/dist/cjs/hooks/useStyles.js +1 -0
  88. package/dist/cjs/hooks.js +9 -0
  89. package/dist/components/Accordion.js +4 -3
  90. package/dist/components/Avatar.js +5 -4
  91. package/dist/components/AvatarStack.js +6 -5
  92. package/dist/components/Badge.js +4 -3
  93. package/dist/components/Breadcrumbs.js +4 -3
  94. package/dist/components/Button.js +6 -5
  95. package/dist/components/Cell.js +5 -4
  96. package/dist/components/Checkbox.js +3 -2
  97. package/dist/components/Checkmark.js +2 -1
  98. package/dist/components/Chips.js +5 -4
  99. package/dist/components/Choice.js +5 -4
  100. package/dist/components/Code.js +2 -0
  101. package/dist/components/CookiesWarning.js +6 -5
  102. package/dist/components/Dadata.js +2 -0
  103. package/dist/components/DatePeriod.js +8 -7
  104. package/dist/components/DatePicker.js +8 -7
  105. package/dist/components/Divider.js +2 -1
  106. package/dist/components/Dot.js +2 -1
  107. package/dist/components/Drawer.js +3 -2
  108. package/dist/components/Dropdown.js +5 -4
  109. package/dist/components/Flex.js +2 -1
  110. package/dist/components/Grid.js +2 -1
  111. package/dist/components/Group.js +3 -2
  112. package/dist/components/HTMLContent.js +2 -1
  113. package/dist/components/HeroTitle.js +4 -3
  114. package/dist/components/Icon.js +4 -3
  115. package/dist/components/Image.js +2 -1
  116. package/dist/components/Input.js +2 -0
  117. package/dist/components/InputPassword.js +4 -3
  118. package/dist/components/Label.js +5 -4
  119. package/dist/components/Link.js +2 -1
  120. package/dist/components/List.js +2 -1
  121. package/dist/components/Loader.js +4 -3
  122. package/dist/components/Logo.js +2 -1
  123. package/dist/components/MenuItem.js +4 -3
  124. package/dist/components/Modal.js +5 -4
  125. package/dist/components/ModalSheetBottom.js +4 -3
  126. package/dist/components/Notification.js +4 -3
  127. package/dist/components/Overlay.js +2 -1
  128. package/dist/components/Pagination.js +5 -4
  129. package/dist/components/Radio.js +8 -4
  130. package/dist/components/RangeSlider.js +2 -1
  131. package/dist/components/Response.js +7 -6
  132. package/dist/components/SVGContent.js +2 -1
  133. package/dist/components/ScrollOnDrag.js +2 -1
  134. package/dist/components/ScrollToView.js +2 -1
  135. package/dist/components/Search.js +4 -3
  136. package/dist/components/Segmented.js +3 -2
  137. package/dist/components/Select.js +5 -4
  138. package/dist/components/Swiper.js +4 -3
  139. package/dist/components/Switch.js +3 -2
  140. package/dist/components/Tab.js +14 -16
  141. package/dist/components/Text.js +3 -2
  142. package/dist/components/Textarea.js +2 -0
  143. package/dist/components/Tile.js +4 -3
  144. package/dist/components/Title.js +4 -3
  145. package/dist/components/Tooltip.js +4 -3
  146. package/dist/components/Video.js +1 -0
  147. package/dist/components/Warning.js +4 -3
  148. package/dist/css/components/Icon/Icon.css +12 -19
  149. package/dist/css/components/Radio/Radio.css +0 -1
  150. package/dist/css/styles/align/align.css +1 -1
  151. package/dist/css/styles/align/align_horizontal-reverse.css +1 -1
  152. package/dist/css/styles/align/align_horizontal.css +1 -1
  153. package/dist/css/styles/align/align_vertical-reverse.css +1 -1
  154. package/dist/css/styles/align/align_vertical.css +1 -1
  155. package/dist/css/styles/border-color/border-color.css +1 -1
  156. package/dist/css/styles/border-color/border-color_active.css +1 -1
  157. package/dist/css/styles/border-color/border-color_active_hover.css +1 -1
  158. package/dist/css/styles/border-color/border-color_focus.css +1 -1
  159. package/dist/css/styles/border-color/border-color_hover.css +1 -1
  160. package/dist/css/styles/bundle.css +15 -15
  161. package/dist/css/styles/fill/fill.css +1 -1
  162. package/dist/css/styles/fill/fill_active.css +1 -1
  163. package/dist/css/styles/fill/fill_active_hover.css +1 -1
  164. package/dist/css/styles/fill/fill_gradient.css +1 -1
  165. package/dist/css/styles/fill/fill_hover.css +1 -1
  166. package/dist/hooks/useActiveClasses/useActiveClasses.helpers.js +116 -0
  167. package/dist/hooks/useActiveClasses/useActiveClasses.interface.js +63 -0
  168. package/dist/hooks/useActiveClasses/useActiveClasses.js +62 -0
  169. package/dist/hooks/useActiveClasses.js +3 -0
  170. package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +11 -1
  171. package/dist/hooks/useDevicePropsGenerator.js +2 -0
  172. package/dist/hooks/useStyles/useStyles.js +5 -3
  173. package/dist/hooks/useStyles.js +1 -0
  174. package/dist/hooks.js +7 -0
  175. package/dist/stories/useActiveClasses.mdx +134 -0
  176. package/dist/types/components/Avatar/Avatar.appearance.d.ts +1878 -2
  177. package/dist/types/components/Avatar/Avatar.interface.d.ts +48 -37
  178. package/dist/types/components/Avatar/appearance/avatarDefault.d.ts +2 -19
  179. package/dist/types/components/Avatar/appearance/avatarShape.d.ts +2 -24
  180. package/dist/types/components/Avatar/appearance/avatarSize.d.ts +2 -83
  181. package/dist/types/components/Avatar/appearance/avatarStyle.d.ts +2 -15
  182. package/dist/types/components/Badge/Badge.appearance.d.ts +986 -228
  183. package/dist/types/components/Badge/Badge.interface.d.ts +6 -6
  184. package/dist/types/components/Badge/appearance/badgeAccent.d.ts +2 -37
  185. package/dist/types/components/Badge/appearance/badgeDanger.d.ts +2 -16
  186. package/dist/types/components/Badge/appearance/badgeDisabled.d.ts +2 -14
  187. package/dist/types/components/Badge/appearance/badgeError.d.ts +2 -16
  188. package/dist/types/components/Badge/appearance/badgeInfo.d.ts +2 -15
  189. package/dist/types/components/Badge/appearance/badgePrimary.d.ts +2 -16
  190. package/dist/types/components/Badge/appearance/badgeSecondary.d.ts +2 -16
  191. package/dist/types/components/Badge/appearance/badgeShape.d.ts +2 -24
  192. package/dist/types/components/Badge/appearance/badgeSize.d.ts +2 -31
  193. package/dist/types/components/Badge/appearance/badgeStyle.d.ts +2 -13
  194. package/dist/types/components/Badge/appearance/badgeSuccess.d.ts +2 -16
  195. package/dist/types/components/Badge/appearance/badgeSurface.d.ts +2 -24
  196. package/dist/types/components/Badge/appearance/badgeWarning.d.ts +2 -16
  197. package/dist/types/components/Icon/Icon.d.ts +30 -6
  198. package/dist/types/components/Icon/Icon.interface.d.ts +2 -0
  199. package/dist/types/components/Radio/Radio.appearance.d.ts +3 -0
  200. package/dist/types/components/Radio/appearance/radioDefault.d.ts +3 -0
  201. package/dist/types/components/Tab/appearance/tabSurface.d.ts +1 -0
  202. package/dist/types/components/Text/Text.appearance.d.ts +698 -2
  203. package/dist/types/components/Text/Text.interface.d.ts +32 -47
  204. package/dist/types/components/Text/appearance/textSize.d.ts +2 -23
  205. package/dist/types/components/Title/Title.appearance.d.ts +2225 -2
  206. package/dist/types/components/Title/Title.interface.d.ts +56 -38
  207. package/dist/types/components/Title/appearance/titleAccent.d.ts +2 -19
  208. package/dist/types/components/Title/appearance/titleDanger.d.ts +2 -6
  209. package/dist/types/components/Title/appearance/titleDisabled.d.ts +2 -19
  210. package/dist/types/components/Title/appearance/titleError.d.ts +2 -10
  211. package/dist/types/components/Title/appearance/titleInfo.d.ts +2 -20
  212. package/dist/types/components/Title/appearance/titlePrimary.d.ts +2 -7
  213. package/dist/types/components/Title/appearance/titleRequire.d.ts +2 -19
  214. package/dist/types/components/Title/appearance/titleSecondary.d.ts +2 -7
  215. package/dist/types/components/Title/appearance/titleSize.d.ts +2 -44
  216. package/dist/types/components/Title/appearance/titleStyle.d.ts +2 -15
  217. package/dist/types/components/Title/appearance/titleSuccess.d.ts +2 -10
  218. package/dist/types/components/Title/appearance/titleSurface.d.ts +2 -24
  219. package/dist/types/components/Title/appearance/titleWarning.d.ts +2 -10
  220. package/dist/types/hooks/index.helpers.d.ts +3 -0
  221. package/dist/types/hooks/useActiveClasses/index.d.ts +2 -0
  222. package/dist/types/hooks/useActiveClasses/useActiveClasses.d.ts +3 -0
  223. package/dist/types/hooks/useActiveClasses/useActiveClasses.helpers.d.ts +5 -0
  224. package/dist/types/hooks/useActiveClasses/useActiveClasses.interface.d.ts +26 -0
  225. package/dist/types/hooks/useDevicePropsGenerator/useDevicePropsGenerator.d.ts +1 -1
  226. package/dist/types/hooks/useStyles/styleAttributes.interface.d.ts +3 -0
  227. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- @each $selector in button, input, textarea {
1
+ @each $selector in div, button, input, textarea {
2
2
  .fill,
3
3
  $(selector).fill {
4
4
  &_none {
@@ -1,4 +1,4 @@
1
- @each $selector in button, input, textarea {
1
+ @each $selector in div, button, input, textarea {
2
2
  .fill,
3
3
  $(selector).fill {
4
4
  &_active {
@@ -1,4 +1,4 @@
1
- @each $selector in button, input, textarea {
1
+ @each $selector in div, button, input, textarea {
2
2
  .fill,
3
3
  $(selector).fill {
4
4
  &_active {
@@ -1,4 +1,4 @@
1
- @each $selector in button, input, textarea {
1
+ @each $selector in div, button, input, textarea {
2
2
  .fill_gradient,
3
3
  $(selector).fill_gradient {
4
4
  @each $type in primary, secondary, tertiary, quaternary {
@@ -1,4 +1,4 @@
1
- @each $selector in button, input, textarea {
1
+ @each $selector in div, button, input, textarea {
2
2
  .fill,
3
3
  $(selector).fill {
4
4
  &_hover {
@@ -0,0 +1,116 @@
1
+ var CLASS_RULES = {
2
+ fill: [
3
+ {
4
+ key: 'fillClass',
5
+ stateFn: function (_a) {
6
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
7
+ return !isActive && !isDisabled;
8
+ },
9
+ },
10
+ {
11
+ key: 'fillHoverClass',
12
+ stateFn: function (_a) {
13
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
14
+ return !isActive && !isDisabled;
15
+ },
16
+ },
17
+ {
18
+ key: 'fillActiveClass',
19
+ stateFn: function (_a) {
20
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
21
+ return Boolean(isActive) && !isDisabled;
22
+ },
23
+ },
24
+ {
25
+ key: 'fillActiveHoverClass',
26
+ stateFn: function (_a) {
27
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
28
+ return Boolean(isActive) && !isDisabled;
29
+ },
30
+ },
31
+ {
32
+ key: 'fillDisabledClass',
33
+ stateFn: function (_a) {
34
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
35
+ return !isActive && Boolean(isDisabled);
36
+ },
37
+ },
38
+ ],
39
+ borderColor: [
40
+ {
41
+ key: 'borderColorClass',
42
+ stateFn: function (_a) {
43
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
44
+ return !isActive && !isDisabled;
45
+ },
46
+ },
47
+ {
48
+ key: 'borderColorHoverClass',
49
+ stateFn: function (_a) {
50
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
51
+ return !isActive && !isDisabled;
52
+ },
53
+ },
54
+ {
55
+ key: 'borderColorActiveClass',
56
+ stateFn: function (_a) {
57
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
58
+ return Boolean(isActive) && !isDisabled;
59
+ },
60
+ },
61
+ ],
62
+ textColor: [
63
+ {
64
+ key: 'textColorClass',
65
+ stateFn: function (_a) {
66
+ var isDisabled = _a.isDisabled, isActive = _a.isActive;
67
+ return !isActive && !isDisabled;
68
+ },
69
+ },
70
+ ],
71
+ };
72
+ var formatState = function (key) {
73
+ // Try to find one of the state tokens in the input key:
74
+ // - matches "ActiveHover", "Active", "Hover" or "Disabled"
75
+ // - case-insensitive because of the /i flag
76
+ // Examples of matches:
77
+ // "fillActiveHoverColor" -> match[0] === "ActiveHover"
78
+ // "borderDisabled" -> match[0] === "Disabled"
79
+ var stateMatch = key.match(/(ActiveHover|Active|Hover|Disabled)/i);
80
+ if (!stateMatch) {
81
+ return '';
82
+ }
83
+ // Replace the matched token with a normalized snake-like form and
84
+ // prepend an underscore. The chained replace calls map:
85
+ // ActiveHover -> active_hover
86
+ // Active -> active
87
+ // Hover -> hover
88
+ // Disabled -> disabled
89
+ // The final .toLowerCase() ensures output is lowercased regardless of input casing.
90
+ // Examples:
91
+ // "fillActiveHoverColor" -> "_active_hover"
92
+ // "borderDisabled" -> "disabled"
93
+ return ('_' +
94
+ stateMatch[0]
95
+ .replace(/ActiveHover/i, 'active_hover')
96
+ .replace(/Active/i, 'active')
97
+ .replace(/Hover/i, 'hover')
98
+ .replace(/Disabled/i, 'disabled')
99
+ .toLowerCase());
100
+ };
101
+ // Insert a hyphen between a lowercase letter followed by an uppercase letter:
102
+ // - regex: /([a-z])([A-Z])/g
103
+ // ([a-z]) -> capture group 1: a lowercase letter
104
+ // ([A-Z]) -> capture group 2: an uppercase letter
105
+ // g -> global: replace all occurrences
106
+ // - replacement: '$1-$2' puts a hyphen between the two captured groups
107
+ // - finally .toLowerCase() to produce a full kebab-case string
108
+ //
109
+ // Examples:
110
+ // "myTestString" -> "my-test-string"
111
+ // "borderColorActiveHover" -> "border-color-active-hover"
112
+ var toKebabCase = function (str) {
113
+ return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
114
+ };
115
+
116
+ export { CLASS_RULES, formatState, toKebabCase };
@@ -0,0 +1,63 @@
1
+ var suffix = [
2
+ 'Button',
3
+ 'Checkbox',
4
+ 'Radio',
5
+ 'Checkmark',
6
+ 'Avatar',
7
+ 'AvatarStack',
8
+ 'Badge',
9
+ 'Breadcrumbs',
10
+ 'Cell',
11
+ 'Chips',
12
+ 'Choice',
13
+ 'Code',
14
+ 'CookiesWarning',
15
+ 'Dadata',
16
+ 'DatePeriod',
17
+ 'Divider',
18
+ 'Dot',
19
+ 'Drawer',
20
+ 'Dropdown',
21
+ 'DropdownItem',
22
+ 'Flex',
23
+ 'Grid',
24
+ 'Group',
25
+ 'HeroTitle',
26
+ 'HTMLContent',
27
+ 'Icon',
28
+ 'Image',
29
+ 'Input',
30
+ 'InputPassword',
31
+ 'Label',
32
+ 'Link',
33
+ 'List',
34
+ 'Loader',
35
+ 'Logo',
36
+ 'MenuItem',
37
+ 'Modal',
38
+ 'ModalSheetBottom',
39
+ 'Notification',
40
+ 'Overlay',
41
+ 'Pagination',
42
+ 'RangeSlider',
43
+ 'Response',
44
+ 'ScrollBar',
45
+ 'ScrollOnDrag',
46
+ 'ScrollToView',
47
+ 'Search',
48
+ 'Segmented',
49
+ 'Select',
50
+ 'SvgContent',
51
+ 'Swiper',
52
+ 'Switch',
53
+ 'Tab',
54
+ 'Text',
55
+ 'Textarea',
56
+ 'Tile',
57
+ 'Title',
58
+ 'Tooltip',
59
+ 'Video',
60
+ 'Warning',
61
+ ];
62
+
63
+ export { suffix };
@@ -0,0 +1,62 @@
1
+ import clsx from 'clsx';
2
+ import { CLASS_RULES, toKebabCase, formatState } from './useActiveClasses.helpers.js';
3
+
4
+ var useActiveClasses = function (params) {
5
+ var isDisabled = params.isDisabled, propsGenerator = params.propsGenerator, _a = params.suffixes, suffixes = _a === void 0 ? [] : _a, isActive = params.isActive;
6
+ var rootClassesArray = [];
7
+ Object.entries(CLASS_RULES).forEach(function (_a) {
8
+ var rulesName = _a[0], rules = _a[1];
9
+ var kebabRuleName = toKebabCase(rulesName);
10
+ rules.forEach(function (_a) {
11
+ var key = _a.key, stateFn = _a.stateFn;
12
+ var value = propsGenerator[key];
13
+ if (!value) {
14
+ return;
15
+ }
16
+ if (stateFn) {
17
+ var active = stateFn({ isDisabled: isDisabled, isActive: isActive });
18
+ if (!active) {
19
+ return;
20
+ }
21
+ }
22
+ var stateName = formatState(key);
23
+ rootClassesArray.push("".concat(kebabRuleName).concat(stateName, "_").concat(value));
24
+ });
25
+ });
26
+ var rootClasses = clsx(rootClassesArray);
27
+ var suffixClasses = suffixes.reduce(function (acc, suffix) {
28
+ var classes = [];
29
+ Object.entries(CLASS_RULES).forEach(function (_a) {
30
+ var rulesName = _a[0], rules = _a[1];
31
+ rules.forEach(function (_a) {
32
+ var key = _a.key, stateFn = _a.stateFn;
33
+ var withoutPrefixRulesName = key.replace(rulesName, '');
34
+ var propKey = rulesName + suffix + withoutPrefixRulesName;
35
+ var value = propsGenerator[propKey];
36
+ if (!value) {
37
+ return;
38
+ }
39
+ if (stateFn) {
40
+ var active = stateFn({ isDisabled: isDisabled, isActive: isActive });
41
+ if (!active) {
42
+ return;
43
+ }
44
+ }
45
+ var state = formatState(propKey);
46
+ var kebabName = toKebabCase(rulesName);
47
+ classes.push("".concat(kebabName).concat(state, "_").concat(value));
48
+ });
49
+ });
50
+ var suffixKey = suffix === 'HTMLContent'
51
+ ? 'htmlContent'
52
+ : (suffix[0].toLowerCase() + suffix.slice(1));
53
+ acc[suffixKey] = clsx(classes);
54
+ return acc;
55
+ }, {});
56
+ return {
57
+ rootClasses: rootClasses,
58
+ suffixClasses: suffixClasses,
59
+ };
60
+ };
61
+
62
+ export { useActiveClasses };
@@ -0,0 +1,3 @@
1
+ export { useActiveClasses } from './useActiveClasses/useActiveClasses.js';
2
+ import 'clsx';
3
+ import './useActiveClasses/useActiveClasses.helpers.js';
@@ -5,6 +5,8 @@ import castArray from 'lodash/castArray';
5
5
  import upperFirst from 'lodash/upperFirst';
6
6
  import '../../context/Notifications.js';
7
7
  import { useUserDeviceContext } from '../../context/UIContext.js';
8
+ import { getStyleAttributeKey } from '../../hooks.js';
9
+ import styleAttributes from '../useStyles/styleAttributes.js';
8
10
  import 'react/jsx-runtime';
9
11
  import 'uuid';
10
12
  import '@itcase/common';
@@ -70,8 +72,16 @@ function useDevicePropsGenerator(componentProps, appearanceConfig) {
70
72
  // eslint-disable-next-line perfectionist/sort-objects
71
73
  getClassName: function (propKey, params) {
72
74
  var _a = params || {}, _b = _a.prefix, prefix = _b === void 0 ? '' : _b, _c = _a.replace, replace = _c === void 0 ? [/([A-Z])/g, '-$1'] : _c;
73
- // prettier-ignore
74
75
  var targetClassValue = this.getProp(String(propKey));
76
+ var styleAttributeKeys = styleAttributes.map(function (attr) {
77
+ return getStyleAttributeKey(attr);
78
+ });
79
+ if (styleAttributeKeys.includes(String(propKey)) &&
80
+ (typeof targetClassValue === 'number' ||
81
+ (typeof targetClassValue === 'string' &&
82
+ !isNaN(parseFloat(targetClassValue))))) {
83
+ return '';
84
+ }
75
85
  if (targetClassValue) {
76
86
  var cleanClassValue = String(targetClassValue);
77
87
  if (!cleanClassValue.includes('.')) {
@@ -12,3 +12,5 @@ import '../context/UIContext.js';
12
12
  import './useMediaQueries/useMediaQueries.js';
13
13
  import 'react-responsive';
14
14
  import '../utils/setViewportProperty.js';
15
+ import '../hooks.js';
16
+ import './useStyles/styleAttributes.js';
@@ -4,6 +4,7 @@ import maxBy from 'lodash/maxBy';
4
4
  import upperFirst from 'lodash/upperFirst';
5
5
  import '../../context/Notifications.js';
6
6
  import { useUserDeviceContext } from '../../context/UIContext.js';
7
+ import { getStyleAttributeKey } from '../../hooks.js';
7
8
  import styleAttributes from './styleAttributes.js';
8
9
  import '../../tslib.es6_es_Bwu1Cn-t.js';
9
10
  import 'react/jsx-runtime';
@@ -137,6 +138,7 @@ function useStyles(props) {
137
138
  return resultStylesGroups;
138
139
  // eslint-disable-next-line react-hooks/exhaustive-deps
139
140
  }, [deviceCurrentMainType, deviceCurrentType, ...Object.values(propsStyleAttributes)]);
141
+ console.error('collectedStyles', collectedStyles);
140
142
  return collectedStyles;
141
143
  }
142
144
  const removeDeviceType = (originalKey, deviceTypesList) => {
@@ -181,10 +183,10 @@ const getTargetStyleAttributeKey = (styleKey, styleValue = '') => {
181
183
 
182
184
  // Get longest style key (e.g. "borderLeftWidth")
183
185
  const targetStyleAttribute = maxBy(possibleStyleAttributesList, styleAttribute => {
184
- const styleAttributeKey = Array.isArray(styleAttribute) ? styleAttribute[0] : styleAttribute;
185
- return styleAttributeKey.length;
186
+ const key = getStyleAttributeKey(styleAttribute);
187
+ return key.length;
186
188
  });
187
- const styleAttributeKey = Array.isArray(targetStyleAttribute) ? targetStyleAttribute[0] : targetStyleAttribute;
189
+ const styleAttributeKey = getStyleAttributeKey(targetStyleAttribute);
188
190
  return styleAttributeKey;
189
191
  };
190
192
 
@@ -12,4 +12,5 @@ import '../context/UIContext.js';
12
12
  import './useMediaQueries/useMediaQueries.js';
13
13
  import 'react-responsive';
14
14
  import '../utils/setViewportProperty.js';
15
+ import '../hooks.js';
15
16
  import './useStyles/styleAttributes.js';
package/dist/hooks.js ADDED
@@ -0,0 +1,7 @@
1
+ var getStyleAttributeKey = function (targetStyleAttribute) {
2
+ return Array.isArray(targetStyleAttribute)
3
+ ? targetStyleAttribute[0]
4
+ : targetStyleAttribute;
5
+ };
6
+
7
+ export { getStyleAttributeKey };
@@ -0,0 +1,134 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ <Meta title="Hooks / useActiveClasses" />
4
+
5
+ # `useActiveClasses`
6
+ Генерирует CSS‑классы по правилам `CLASS_RULES` из `propsGenerator` с учетом состояний (`isActive`, `isDisabled`).
7
+
8
+ > ℹ️ Данный хук использует термины, о которых рассказывается в `useDevicePropsGenerator`, необходимо предварительно ознакомиться с ним
9
+
10
+ ### Параметры
11
+
12
+ <table>
13
+ <thead>
14
+ <tr>
15
+ <th>Название</th>
16
+ <th>Обязательный</th>
17
+ <th>Тип</th>
18
+ <th>Значение</th>
19
+ <th>Описание</th>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <tr>
24
+ <td>isDisabled</td>
25
+ <td>Нет</td>
26
+ <td>`boolean`</td>
27
+ <td>false</td>
28
+ <td>`Boolean` флаг</td>
29
+ </tr>
30
+ <tr>
31
+ <td>propsGenerator</td>
32
+ <td>Да</td>
33
+ <td>`[key: string]: string`</td>
34
+ <td>
35
+ propsGenerator[propsKey]
36
+ </td>
37
+ <td>Генератор классов</td>
38
+ </tr>
39
+ <tr>
40
+ <td>suffixes</td>
41
+ <td>Нет</td>
42
+ <td>`string[]`</td>
43
+ <td>
44
+ ['Checkmark']
45
+ </td>
46
+ <td>Массив суффиксов</td>
47
+ </tr>
48
+ <tr>
49
+ <td>isActive</td>
50
+ <td>Нет</td>
51
+ <td>`boolean`</td>
52
+ <td>false</td>
53
+ <td>`Boolean` флаг</td>
54
+ </tr>
55
+ </tbody>
56
+ </table>
57
+
58
+ ### Результат
59
+
60
+ Возвращает объект, значения объекта:
61
+
62
+ <table>
63
+ <thead>
64
+ <tr>
65
+ <th>Название</th>
66
+ <th>Тип</th>
67
+ <th>Значение</th>
68
+ <th>Описание</th>
69
+ </tr>
70
+ </thead>
71
+ <tbody>
72
+ <tr>
73
+ <td>rootClasses</td>
74
+ <td>`string`</td>
75
+ <td>`'fill_surface-secondary borderColor_surface-border-quaternary'`</td>
76
+ <td>Строка из классами для корневого `html-тега`</td>
77
+ </tr>
78
+ <tr>
79
+ <td>suffixClasses</td>
80
+ <td>`string`</td>
81
+ <td>
82
+ `'fill_surface-secondary borderColor_accent-primary'`
83
+ </td>
84
+ <td>Строка из классов для вложенных `html-тэгов`</td>
85
+ </tr>
86
+ </tbody>
87
+ </table>
88
+
89
+ ### Примечание
90
+ Чтобы на выходе получалась строка из классов, необходимо предварительно в `appearance` прописать значения, например:
91
+
92
+ ```js
93
+ const radioAppearanceDefault = {
94
+ defaultPrimary: {
95
+ fill: 'surfaceSecondary',
96
+ fillRado: 'accentPrimary',
97
+ fillCheckmark: 'surfaceQuaternary'
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Использование
103
+ Для генерации классов вложенных `html-тегов`, задаем массив суффиксов
104
+
105
+ ```jsx
106
+ function Radio({ isActive, isDisabled, propsGenerator }) {
107
+ const { rootClasses, suffixClasses } = useActiveClasses({
108
+ isDisabled,
109
+ propsGenerator,
110
+ suffixes: ['Checkmark', 'Radio'],
111
+ isActive,
112
+ })
113
+
114
+ return (
115
+ <label className={clsx('radio', rootClasses)}>
116
+ <div className={clsx('radio__state', suffixClasses.Radio)}>
117
+ <span>State</span>
118
+ </div>
119
+ <div className={clsx('radio__state-checkmark', suffixClasses.Checkmark)}>
120
+ <span>Checkmark</span>
121
+ </div>
122
+ </label>
123
+ )
124
+ }
125
+
126
+ export { Radio }
127
+ ```
128
+
129
+ В данном случае
130
+ - `rootClasses` = 'fill_surface-secondary'
131
+ - `suffixClasses.Radio` = 'fill_surface-quaternary',
132
+ - `suffixClasses.Chekmark` = 'fill_accent-primary'
133
+
134
+ И все данные значение получены из `appearance`, которые указали ранее