@itcase/ui 1.9.51 → 1.9.52

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 (104) hide show
  1. package/dist/{Avatar_cjs_CZ0XJ6d2.js → Avatar_cjs_CvbURI0f.js} +1 -1
  2. package/dist/{Avatar_es_B2gMldVe.js → Avatar_es_CV-ffIJu.js} +1 -1
  3. package/dist/{ChipsGroup_cjs_D0xy5I4S.js → ChipsGroup_cjs_CE-nNENH.js} +2 -4
  4. package/dist/{ChipsGroup_es_C_dgXLfC.js → ChipsGroup_es_CxqwFgoo.js} +2 -4
  5. package/dist/{Image_cjs_C_FMjUjx.js → Image_cjs_Hvjp2QDB.js} +2 -2
  6. package/dist/{Image_es_Ca7UQOkj.js → Image_es_DpOCNWpn.js} +2 -2
  7. package/dist/{SelectContainer_cjs_DshFNYWN.js → SelectContainer_cjs_qWAMLIkz.js} +5 -5
  8. package/dist/{SelectContainer_es_BQ3-SqL2.js → SelectContainer_es_kRH4DsEh.js} +5 -5
  9. package/dist/cjs/components/Avatar.js +2 -2
  10. package/dist/cjs/components/AvatarStack.js +2 -2
  11. package/dist/cjs/components/Checkbox.js +47 -50
  12. package/dist/cjs/components/Checkmark.js +31 -6
  13. package/dist/cjs/components/Chips.js +1 -1
  14. package/dist/cjs/components/DatePeriod.js +8 -8
  15. package/dist/cjs/components/DatePicker.js +4 -4
  16. package/dist/cjs/components/Drawer.js +23 -24
  17. package/dist/cjs/components/Image.js +1 -1
  18. package/dist/cjs/components/InputPassword.js +1 -1
  19. package/dist/cjs/components/Select/stories/__mock__.js +4 -4
  20. package/dist/cjs/components/Select.js +2 -2
  21. package/dist/cjs/components/Tile.js +2 -1
  22. package/dist/cjs/context/Notifications.js +1 -1
  23. package/dist/cjs/context/UIContext.js +7 -1
  24. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.helpers.js +9 -9
  25. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.js +3 -3
  26. package/dist/cjs/hooks/useStyles/styleAttributes.js +166 -43
  27. package/dist/cjs/hooks/useStyles/useStyles.js +169 -155
  28. package/dist/cjs/utils/mergeAppearanceKeys.js +14 -1
  29. package/dist/components/Avatar.js +2 -2
  30. package/dist/components/AvatarStack.js +2 -2
  31. package/dist/components/Checkbox.js +47 -50
  32. package/dist/components/Checkmark.js +31 -6
  33. package/dist/components/Chips.js +1 -1
  34. package/dist/components/DatePeriod.js +8 -8
  35. package/dist/components/DatePicker.js +4 -4
  36. package/dist/components/Drawer.js +23 -24
  37. package/dist/components/Image.js +1 -1
  38. package/dist/components/InputPassword.js +1 -1
  39. package/dist/components/Select/stories/__mock__.js +4 -4
  40. package/dist/components/Select.js +2 -2
  41. package/dist/components/Tile.js +2 -1
  42. package/dist/context/Notifications.js +1 -1
  43. package/dist/context/UIContext.js +7 -1
  44. package/dist/css/styles/bundles.css +102 -97
  45. package/dist/hooks/useActiveClasses/useActiveClasses.helpers.js +9 -9
  46. package/dist/hooks/useActiveClasses/useActiveClasses.js +3 -3
  47. package/dist/hooks/useStyles/styleAttributes.js +166 -43
  48. package/dist/hooks/useStyles/useStyles.js +169 -155
  49. package/dist/types/components/Avatar/Avatar.interface.d.ts +2 -2
  50. package/dist/types/components/AvatarStack/AvatarStack.interface.d.ts +9 -15
  51. package/dist/types/components/Breadcrumbs/Breadcrumbs.interface.d.ts +9 -8
  52. package/dist/types/components/Checkbox/Checkbox.interface.d.ts +3 -3
  53. package/dist/types/components/Checkbox/appearance/checkboxShape.d.ts +3 -0
  54. package/dist/types/components/Checkmark/Checkmark.interface.d.ts +8 -2
  55. package/dist/types/components/Checkmark/appearance/checkmarkError.d.ts +3 -0
  56. package/dist/types/components/Checkmark/stories/CheckmarkError.stories.d.ts +23 -0
  57. package/dist/types/components/Chips/Chips.interface.d.ts +2 -2
  58. package/dist/types/components/DatePeriod/DatePeriod.interface.d.ts +20 -19
  59. package/dist/types/components/DatePeriod/stories/DatePeriodSize.stories.d.ts +3 -0
  60. package/dist/types/components/DatePicker/DatePicker.interface.d.ts +4 -3
  61. package/dist/types/components/HeroTitle/HeroTitle.interface.d.ts +1 -1
  62. package/dist/types/components/Link/Link.interface.d.ts +1 -1
  63. package/dist/types/components/List/List.interface.d.ts +1 -1
  64. package/dist/types/components/Loader/Loader.interface.d.ts +4 -3
  65. package/dist/types/components/MenuItem/MenuItem.interface.d.ts +1 -1
  66. package/dist/types/components/Notification/Notification.interface.d.ts +2 -2
  67. package/dist/types/components/Search/Search.interface.d.ts +10 -9
  68. package/dist/types/components/Search/SearchInput.d.ts +7 -7
  69. package/dist/types/components/Search/stories/SearchInputDefault.stories.d.ts +7 -7
  70. package/dist/types/components/Search/stories/SearchInputDemo.stories.d.ts +7 -7
  71. package/dist/types/components/Search/stories/SearchInputDisabled.stories.d.ts +7 -7
  72. package/dist/types/components/Search/stories/SearchInputError.stories.d.ts +7 -7
  73. package/dist/types/components/Search/stories/SearchInputRequire.stories.d.ts +7 -7
  74. package/dist/types/components/Search/stories/SearchInputShape.stories.d.ts +7 -7
  75. package/dist/types/components/Search/stories/SearchInputSize.stories.d.ts +7 -7
  76. package/dist/types/components/Search/stories/SearchInputStyle.stories.d.ts +7 -7
  77. package/dist/types/components/Search/stories/SearchInputSuccess.stories.d.ts +7 -7
  78. package/dist/types/components/Select/Select.interface.d.ts +9 -7
  79. package/dist/types/components/Select/SelectContainer.d.ts +4 -1
  80. package/dist/types/components/Select/SelectMultiValue.d.ts +2 -2
  81. package/dist/types/components/Select/stories/Select.stories.d.ts +5 -3
  82. package/dist/types/components/Select/stories/SelectDefault.stories.d.ts +5 -3
  83. package/dist/types/components/Select/stories/SelectDisabled.stories.d.ts +5 -3
  84. package/dist/types/components/Select/stories/SelectError.stories.d.ts +5 -3
  85. package/dist/types/components/Select/stories/SelectRequire.stories.d.ts +5 -3
  86. package/dist/types/components/Select/stories/SelectShape.stories.d.ts +5 -3
  87. package/dist/types/components/Select/stories/SelectSize.stories.d.ts +5 -3
  88. package/dist/types/components/Select/stories/SelectStyle.stories.d.ts +5 -3
  89. package/dist/types/components/Select/stories/SelectSuccess.stories.d.ts +5 -3
  90. package/dist/types/components/Select/stories/__mock__/index.d.ts +2 -2
  91. package/dist/types/components/Swiper/Swiper.interface.d.ts +2 -11
  92. package/dist/types/components/Text/Text.interface.d.ts +2 -2
  93. package/dist/types/context/Notifications.d.ts +1 -1
  94. package/dist/types/context/Notifications.interface.d.ts +2 -1
  95. package/dist/types/context/UIContext.d.ts +10 -4
  96. package/dist/types/hooks/useActiveClasses/useActiveClasses.interface.d.ts +1 -2
  97. package/dist/types/hooks/useStyles/styleAttributes.d.ts +2 -3
  98. package/dist/types/hooks/useStyles/styleAttributes.interface.d.ts +9 -3
  99. package/dist/types/hooks/useStyles/useStyles.d.ts +4 -1
  100. package/dist/types/utils/mergeAppearanceKeys.d.ts +6 -1
  101. package/dist/utils/mergeAppearanceKeys.js +14 -1
  102. package/package.json +12 -12
  103. package/dist/{DatePicker_cjs_avA-OHmZ.js → DatePicker_cjs_BJzVpk0o.js} +3 -3
  104. package/dist/{DatePicker_es_ungoFvip.js → DatePicker_es_BP0iWHMt.js} +3 -3
@@ -2,43 +2,43 @@ const CLASS_RULES = {
2
2
  fill: [
3
3
  {
4
4
  key: 'fillClass',
5
- stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
5
+ stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
6
6
  },
7
7
  {
8
8
  key: 'fillHoverClass',
9
- stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
9
+ stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
10
10
  },
11
11
  {
12
12
  key: 'fillActiveClass',
13
- stateFn: ({ isDisabled, isActive }) => Boolean(isActive) && !isDisabled,
13
+ stateFn: ({ isActive, isDisabled }) => Boolean(isActive) && !isDisabled,
14
14
  },
15
15
  {
16
16
  key: 'fillActiveHoverClass',
17
- stateFn: ({ isDisabled, isActive }) => Boolean(isActive) && !isDisabled,
17
+ stateFn: ({ isActive, isDisabled }) => Boolean(isActive) && !isDisabled,
18
18
  },
19
19
  {
20
20
  key: 'fillDisabledClass',
21
- stateFn: ({ isDisabled, isActive }) => !isActive && Boolean(isDisabled),
21
+ stateFn: ({ isActive, isDisabled }) => !isActive && Boolean(isDisabled),
22
22
  },
23
23
  ],
24
24
  borderColor: [
25
25
  {
26
26
  key: 'borderColorClass',
27
- stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
27
+ stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
28
28
  },
29
29
  {
30
30
  key: 'borderColorHoverClass',
31
- stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
31
+ stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
32
32
  },
33
33
  {
34
34
  key: 'borderColorActiveClass',
35
- stateFn: ({ isDisabled, isActive }) => Boolean(isActive) && !isDisabled,
35
+ stateFn: ({ isActive, isDisabled }) => Boolean(isActive) && !isDisabled,
36
36
  },
37
37
  ],
38
38
  textColor: [
39
39
  {
40
40
  key: 'textColorClass',
41
- stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
41
+ stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
42
42
  },
43
43
  ],
44
44
  };
@@ -2,7 +2,7 @@ import clsx from 'clsx';
2
2
  import { CLASS_RULES, toKebabCase, formatState } from './useActiveClasses.helpers.js';
3
3
 
4
4
  const useActiveClasses = (params) => {
5
- const { isDisabled, propsGenerator, suffixes = [], isActive } = params;
5
+ const { propsGenerator, suffixes = [], isActive, isDisabled } = params;
6
6
  const rootClassesArray = [];
7
7
  Object.entries(CLASS_RULES).forEach(([rulesName, rules]) => {
8
8
  const kebabRuleName = toKebabCase(rulesName);
@@ -12,7 +12,7 @@ const useActiveClasses = (params) => {
12
12
  return;
13
13
  }
14
14
  if (stateFn) {
15
- const active = stateFn({ isDisabled, isActive });
15
+ const active = stateFn({ isActive, isDisabled });
16
16
  if (!active) {
17
17
  return;
18
18
  }
@@ -33,7 +33,7 @@ const useActiveClasses = (params) => {
33
33
  return;
34
34
  }
35
35
  if (stateFn) {
36
- const active = stateFn({ isDisabled, isActive });
36
+ const active = stateFn({ isActive, isDisabled });
37
37
  if (!active) {
38
38
  return;
39
39
  }
@@ -1,46 +1,169 @@
1
1
  var styleAttributes = [
2
- /**
3
- * Layout
4
- */
5
- 'alignContent', 'alignItems', 'alignSelf', 'aspectRatio', 'border', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth', 'borderWidth', 'bottom', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'gap', 'rowGap', 'columnGap', 'columnWidth', 'height', 'justifyContent', 'left', 'margin', 'marginBottom', 'marginHorizontal', 'marginLeft', 'marginRight', 'marginTop', 'marginVertical', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'overflow', 'overflowY', 'overflowX', 'padding', 'paddingBottom', 'paddingEnd', 'paddingHorizontal', 'paddingLeft', 'paddingRight', 'paddingStart', 'paddingTop', 'paddingVertical', 'position', 'right', 'top', ['width', {
6
- validate: value => {
7
- // Pass only number value for "width" style.
8
- // If width have custom value, like "fill", we must set class by this value.
9
- // "\d" - digit; "+" - 1 or more
10
- return /\d+/.test(value);
11
- }
12
- }], 'zIndex', 'order',
13
- /**
14
- * Shadow
15
- */
16
- 'shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius',
17
- /**
18
- * Transform
19
- */
20
- 'transform',
21
- /**
22
- * View
23
- */
24
- 'background', 'backgroundColor', 'borderBottomColor', 'borderBottomEndRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomStartRadius', 'borderColor', 'borderCurve', 'borderEndColor', 'borderLeftColor', 'borderRadius', 'borderRightColor', 'borderStartColor', 'borderStyle', 'borderTopColor', 'borderTopEndRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderTopStartRadius', 'opacity', 'cursor',
25
- /**
26
- * Text
27
- */
28
- 'color', 'fontFamily', 'fontSize', 'fontStyle', 'fontVariant', 'fontWeight', 'letterSpacing', 'lineHeight', 'textAlign', 'textDecorationColor', 'textDecorationLine', 'textDecorationStyle', 'textShadowColor', 'textShadowOffset', 'textShadowRadius', 'textTransform', 'verticalAlign', 'writingMode', 'whiteSpace',
29
- /**
30
- * Image
31
- */
32
- 'overlayColor', 'resizeMode', 'tintColor', 'objectFit', 'objectPosition',
33
- /**
34
- * Grid
35
- */
36
- 'gridTemplateColumns', 'gridArea', 'gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplate', 'gridTemplateAreas', 'gridTemplateRows', 'gridColumn', 'gridColumnStart', 'gridColumnEnd', 'gridColumnGap', 'gridRow', 'gridRowStart', 'gridRowEnd', 'gridRowGap',
37
- /**
38
- * Filter
39
- */
40
- 'backdropFilter',
41
- /**
42
- * transition
43
- */
44
- 'transition', 'transitionBehavior', 'transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'];
2
+ /**
3
+ * Layout
4
+ */
5
+ 'alignContent',
6
+ 'alignItems',
7
+ 'alignSelf',
8
+ 'aspectRatio',
9
+ 'border',
10
+ 'borderBottomWidth',
11
+ 'borderLeftWidth',
12
+ 'borderRightWidth',
13
+ 'borderTopWidth',
14
+ 'borderWidth',
15
+ 'bottom',
16
+ 'display',
17
+ 'flex',
18
+ 'flexBasis',
19
+ 'flexDirection',
20
+ 'flexGrow',
21
+ 'flexShrink',
22
+ 'flexWrap',
23
+ 'gap',
24
+ 'rowGap',
25
+ 'columnGap',
26
+ 'columnWidth',
27
+ 'height',
28
+ 'justifyContent',
29
+ 'left',
30
+ 'margin',
31
+ 'marginBottom',
32
+ 'marginHorizontal',
33
+ 'marginLeft',
34
+ 'marginRight',
35
+ 'marginTop',
36
+ 'marginVertical',
37
+ 'maxHeight',
38
+ 'maxWidth',
39
+ 'minHeight',
40
+ 'minWidth',
41
+ 'overflow',
42
+ 'overflowY',
43
+ 'overflowX',
44
+ 'padding',
45
+ 'paddingBottom',
46
+ 'paddingEnd',
47
+ 'paddingHorizontal',
48
+ 'paddingLeft',
49
+ 'paddingRight',
50
+ 'paddingStart',
51
+ 'paddingTop',
52
+ 'paddingVertical',
53
+ 'position',
54
+ 'right',
55
+ 'top',
56
+ [
57
+ 'width',
58
+ {
59
+ validate: (value) => {
60
+ // Pass only number value for "width" style.
61
+ // If width have custom value, like "fill", we must set class by this value.
62
+ // "\d" - digit; "+" - 1 or more
63
+ return /\d+/.test(value);
64
+ },
65
+ },
66
+ ],
67
+ 'zIndex',
68
+ 'order',
69
+ /**
70
+ * Shadow
71
+ */
72
+ 'shadowColor',
73
+ 'shadowOffset',
74
+ 'shadowOpacity',
75
+ 'shadowRadius',
76
+ /**
77
+ * Transform
78
+ */
79
+ 'transform',
80
+ /**
81
+ * View
82
+ */
83
+ 'background',
84
+ 'backgroundColor',
85
+ 'borderBottomColor',
86
+ 'borderBottomEndRadius',
87
+ 'borderBottomLeftRadius',
88
+ 'borderBottomRightRadius',
89
+ 'borderBottomStartRadius',
90
+ 'borderColor',
91
+ 'borderCurve',
92
+ 'borderEndColor',
93
+ 'borderLeftColor',
94
+ 'borderRadius',
95
+ 'borderRightColor',
96
+ 'borderStartColor',
97
+ 'borderStyle',
98
+ 'borderTopColor',
99
+ 'borderTopEndRadius',
100
+ 'borderTopLeftRadius',
101
+ 'borderTopRightRadius',
102
+ 'borderTopStartRadius',
103
+ 'opacity',
104
+ 'cursor',
105
+ /**
106
+ * Text
107
+ */
108
+ 'color',
109
+ 'fontFamily',
110
+ 'fontSize',
111
+ 'fontStyle',
112
+ 'fontVariant',
113
+ 'fontWeight',
114
+ 'letterSpacing',
115
+ 'lineHeight',
116
+ 'textAlign',
117
+ 'textDecorationColor',
118
+ 'textDecorationLine',
119
+ 'textDecorationStyle',
120
+ 'textShadowColor',
121
+ 'textShadowOffset',
122
+ 'textShadowRadius',
123
+ 'textTransform',
124
+ 'verticalAlign',
125
+ 'writingMode',
126
+ 'whiteSpace',
127
+ /**
128
+ * Image
129
+ */
130
+ 'overlayColor',
131
+ 'resizeMode',
132
+ 'tintColor',
133
+ 'objectFit',
134
+ 'objectPosition',
135
+ /**
136
+ * Grid
137
+ */
138
+ 'gridTemplateColumns',
139
+ 'gridArea',
140
+ 'gridAutoColumns',
141
+ 'gridAutoFlow',
142
+ 'gridAutoRows',
143
+ 'gridTemplate',
144
+ 'gridTemplateAreas',
145
+ 'gridTemplateRows',
146
+ 'gridColumn',
147
+ 'gridColumnStart',
148
+ 'gridColumnEnd',
149
+ 'gridColumnGap',
150
+ 'gridRow',
151
+ 'gridRowStart',
152
+ 'gridRowEnd',
153
+ 'gridRowGap',
154
+ /**
155
+ * Filter
156
+ */
157
+ 'backdropFilter',
158
+ /**
159
+ * transition
160
+ */
161
+ 'transition',
162
+ 'transitionBehavior',
163
+ 'transitionDelay',
164
+ 'transitionDuration',
165
+ 'transitionProperty',
166
+ 'transitionTimingFunction',
167
+ ];
45
168
 
46
169
  export { styleAttributes as default };
@@ -22,167 +22,181 @@ import '../../utils/setViewportProperty.js';
22
22
  * paddingHorizontalGridInnerWrapperMobileNormal: "10px"
23
23
  */
24
24
  function useStyles(props) {
25
- const {
26
- deviceCurrentMainType,
27
- deviceCurrentType,
28
- deviceTypesList
29
- } = useUserDeviceContext();
30
- const propsStyleAttributes = useMemo(() => {
31
- const styles = Object.entries(props).reduce((result, [propKey, propValue]) => {
32
- const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
33
- if (styleAttributeKey) {
34
- result[propKey] = propValue;
35
- }
36
- return result;
37
- }, {});
38
- return styles;
39
- // "props" object maybe big and frequently changing
40
- }, [props]);
41
- const collectedStyles = useMemo(() => {
42
- const resultStylesGroups = {};
43
- for (const [propKey, propValue] of Object.entries(propsStyleAttributes)) {
44
- let value = null;
45
- const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
46
- const isStyleForCurrentDevice = propKey.toLowerCase().endsWith(deviceCurrentType.toLowerCase());
47
- // e.g. "GridWrapperInner"
48
- const targetElementKey = removeDeviceType(propKey.replace(styleAttributeKey, ''), deviceTypesList);
49
- const targetElementGroupKey = camelCase(targetElementKey) || 'styles';
50
- if (!resultStylesGroups[targetElementGroupKey]) {
51
- resultStylesGroups[targetElementGroupKey] = {};
52
- }
53
- if (isStyleForCurrentDevice) {
54
- value = propValue;
55
- } else {
56
- const propKeyWithOutDeviceType = `${styleAttributeKey}${targetElementKey}`;
57
- const propKeyWithBaseDeviceType = `${propKeyWithOutDeviceType}${upperFirst(deviceCurrentMainType)}`;
58
- const defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
59
- let currentValue = resultStylesGroups[targetElementGroupKey][styleAttributeKey];
60
- if (propKeyWithOutDeviceType.includes('Horizontal')) {
61
- const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
62
- currentValue = resultStylesGroups[targetElementGroupKey][keyLeft];
63
- } else if (propKeyWithOutDeviceType.includes('Vertical')) {
64
- const keyTop = styleAttributeKey.replace('Vertical', 'Top');
65
- currentValue = resultStylesGroups[targetElementGroupKey][keyTop];
25
+ const { deviceCurrentMainType, deviceCurrentType, deviceTypesList } = useUserDeviceContext();
26
+ const propsStyleAttributes = useMemo(() => {
27
+ const styles = Object.entries(props).reduce((result, [propKey, propValue]) => {
28
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
29
+ if (styleAttributeKey) {
30
+ result[propKey] = propValue;
31
+ }
32
+ return result;
33
+ }, {});
34
+ return styles;
35
+ // "props" object maybe big and frequently changing
36
+ }, [props]);
37
+ const collectedStyles = useMemo(() => {
38
+ const resultStylesGroups = {};
39
+ for (const [propKey, propValue] of Object.entries(propsStyleAttributes)) {
40
+ let value = null;
41
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
42
+ const isStyleForCurrentDevice = propKey
43
+ .toLowerCase()
44
+ .endsWith(deviceCurrentType.toLowerCase());
45
+ // e.g. "GridWrapperInner"
46
+ const targetElementKey = removeDeviceType(propKey.replace(styleAttributeKey, ''), deviceTypesList);
47
+ const targetElementGroupKey = camelCase(targetElementKey) || 'styles';
48
+ if (!resultStylesGroups[targetElementGroupKey]) {
49
+ resultStylesGroups[targetElementGroupKey] = {};
50
+ }
51
+ if (isStyleForCurrentDevice) {
52
+ value = propValue;
53
+ }
54
+ else {
55
+ const propKeyWithOutDeviceType = `${styleAttributeKey}${targetElementKey}`;
56
+ const propKeyWithBaseDeviceType = `${propKeyWithOutDeviceType}${upperFirst(deviceCurrentMainType)}`;
57
+ const defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
58
+ let currentValue = resultStylesGroups[targetElementGroupKey][styleAttributeKey];
59
+ if (propKeyWithOutDeviceType.includes('Horizontal')) {
60
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
61
+ currentValue =
62
+ resultStylesGroups[targetElementGroupKey][keyLeft];
63
+ }
64
+ else if (propKeyWithOutDeviceType.includes('Vertical')) {
65
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
66
+ currentValue =
67
+ resultStylesGroups[targetElementGroupKey][keyTop];
68
+ }
69
+ if (!currentValue) {
70
+ value = defaultValue;
71
+ }
72
+ }
73
+ if (value) {
74
+ // Check not digit symbols. Chars means some unit ("px", "em", "rem" or custom "m")
75
+ const isValueHasUnit = /\D/.test(value);
76
+ // If value has some unit
77
+ if (isValueHasUnit) {
78
+ // Check value on our custom "m"(module) unit
79
+ /** Pattern for:
80
+ * 1m
81
+ * 1.5m
82
+ * 1m 1m 1.5m
83
+ * 0 0 1m 1m
84
+ */
85
+ const isValueHasModuleUnit = /\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(value);
86
+ // If value has module unit
87
+ if (isValueHasModuleUnit) {
88
+ /** Order for shorthand properties:
89
+ * top
90
+ * right
91
+ * bottom
92
+ * left
93
+ * or:
94
+ * top
95
+ * right and left
96
+ * bottom
97
+ * or:
98
+ * top and bottom
99
+ * right and left
100
+ */
101
+ const valuePxPartsList = value
102
+ .split(' ')
103
+ .map((valuePart) => {
104
+ const valueModule = valuePart.replace(/[a-z]/gi, '');
105
+ const valuePx = parseFloat(valueModule) * 8;
106
+ return `${valuePx}px`;
107
+ }, []);
108
+ value = valuePxPartsList.join(' ');
109
+ }
110
+ }
111
+ else {
112
+ // Some properties doesn't have any units
113
+ const ignorePX = ['zIndex', 'order', 'flexGrow'].includes(styleAttributeKey);
114
+ if (!ignorePX) {
115
+ // Add px to non-unit value
116
+ value = `${value}px`;
117
+ }
118
+ }
119
+ if (styleAttributeKey.includes('Horizontal')) {
120
+ const keyRight = styleAttributeKey.replace('Horizontal', 'Right');
121
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
122
+ const valuePartsList = value.split(' ');
123
+ const valueRight = valuePartsList[0];
124
+ const valueLeft = valuePartsList[1] || valuePartsList[0];
125
+ resultStylesGroups[targetElementGroupKey][keyRight] = valueRight;
126
+ resultStylesGroups[targetElementGroupKey][keyLeft] = valueLeft;
127
+ }
128
+ else if (styleAttributeKey.includes('Vertical')) {
129
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
130
+ const keyBottom = styleAttributeKey.replace('Vertical', 'Bottom');
131
+ const valuePartsList = value.split(' ');
132
+ const valueTop = valuePartsList[0];
133
+ const valueBottom = valuePartsList[1] || valuePartsList[0];
134
+ resultStylesGroups[targetElementGroupKey][keyTop] = valueTop;
135
+ resultStylesGroups[targetElementGroupKey][keyBottom] = valueBottom;
136
+ }
137
+ else {
138
+ resultStylesGroups[targetElementGroupKey][styleAttributeKey] = value;
139
+ }
140
+ }
66
141
  }
67
- if (!currentValue) {
68
- value = defaultValue;
69
- }
70
- }
71
- if (value) {
72
- // Check not digit symbols. Chars means some unit ("px", "em", "rem" or custom "m")
73
- const isValueHasUnit = /\D/.test(value);
74
- // If value has some unit
75
- if (isValueHasUnit) {
76
- // Check value on our custom "m"(module) unit
77
- /** Pattern for:
78
- * 1m
79
- * 1.5m
80
- * 1m 1m 1.5m
81
- * 0 0 1m 1m
82
- */
83
- const isValueHasModuleUnit = /\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(value);
84
- // If value has module unit
85
- if (isValueHasModuleUnit) {
86
- /** Order for shorthand properties:
87
- * top
88
- * right
89
- * bottom
90
- * left
91
- * or:
92
- * top
93
- * right and left
94
- * bottom
95
- * or:
96
- * top and bottom
97
- * right and left
98
- */
99
- const valuePxPartsList = value.split(' ').map(valuePart => {
100
- const valueModule = valuePart.replace(/[a-z]/gi, '');
101
- const valuePx = parseFloat(valueModule) * 8;
102
- return `${valuePx}px`;
103
- }, []);
104
- value = valuePxPartsList.join(' ');
105
- }
106
- } else {
107
- // Some properties doesn't have any units
108
- const ignorePX = ['zIndex', 'order', 'flexGrow'].includes(styleAttributeKey);
109
- if (!ignorePX) {
110
- // Add px to non-unit value
111
- value = `${value}px`;
112
- }
113
- }
114
- if (styleAttributeKey.includes('Horizontal')) {
115
- const keyRight = styleAttributeKey.replace('Horizontal', 'Right');
116
- const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
117
- const valuePartsList = value.split(' ');
118
- const valueRight = valuePartsList[0];
119
- const valueLeft = valuePartsList[1] || valuePartsList[0];
120
- resultStylesGroups[targetElementGroupKey][keyRight] = valueRight;
121
- resultStylesGroups[targetElementGroupKey][keyLeft] = valueLeft;
122
- } else if (styleAttributeKey.includes('Vertical')) {
123
- const keyTop = styleAttributeKey.replace('Vertical', 'Top');
124
- const keyBottom = styleAttributeKey.replace('Vertical', 'Bottom');
125
- const valuePartsList = value.split(' ');
126
- const valueTop = valuePartsList[0];
127
- const valueBottom = valuePartsList[1] || valuePartsList[0];
128
- resultStylesGroups[targetElementGroupKey][keyTop] = valueTop;
129
- resultStylesGroups[targetElementGroupKey][keyBottom] = valueBottom;
130
- } else {
131
- resultStylesGroups[targetElementGroupKey][styleAttributeKey] = value;
132
- }
133
- }
134
- }
135
- return resultStylesGroups;
136
- // eslint-disable-next-line react-hooks/exhaustive-deps
137
- }, [deviceCurrentMainType, deviceCurrentType, ...Object.values(propsStyleAttributes)]);
138
- return collectedStyles;
142
+ return resultStylesGroups;
143
+ // eslint-disable-next-line react-hooks/exhaustive-deps
144
+ }, [
145
+ deviceCurrentMainType,
146
+ deviceCurrentType,
147
+ ...Object.values(propsStyleAttributes),
148
+ ]);
149
+ return collectedStyles;
139
150
  }
140
151
  const removeDeviceType = (originalKey, deviceTypesList) => {
141
- // Remove "mobile"/"tablet"/"desktop"
142
- const withOutDeviceType = deviceTypesList.reduce((cleanKey, deviceType) => {
143
- if (cleanKey.endsWith(upperFirst(deviceType))) {
144
- return cleanKey.replace(upperFirst(deviceType), '');
145
- }
146
- return cleanKey;
147
- }, originalKey);
148
- return withOutDeviceType;
152
+ // Remove "mobile"/"tablet"/"desktop"
153
+ const withOutDeviceType = deviceTypesList.reduce((cleanKey, deviceType) => {
154
+ if (cleanKey.endsWith(upperFirst(deviceType))) {
155
+ return cleanKey.replace(upperFirst(deviceType), '');
156
+ }
157
+ return cleanKey;
158
+ }, originalKey);
159
+ return withOutDeviceType;
149
160
  };
150
161
  const getTargetStyleAttributeKey = (styleKey, styleValue = '') => {
151
- // Collect list of possible styles for propKey. e.g:
152
- // "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
153
- const possibleStyleAttributesList = styleAttributes.filter(styleAttribute => {
154
- // Attribute can be array with key on first position and params on second
155
- if (Array.isArray(styleAttribute)) {
156
- // First item always attribute key (e.g. border, width, etc)
157
- const styleAttributeKey = styleAttribute[0];
158
- // Second item always params with some settings or methods
159
- const styleAttributeParams = styleAttribute[1] || {};
160
- // If is target attribute key
161
- if (styleKey.startsWith(styleAttributeKey)) {
162
- // If target attribute params has validate method
163
- if (styleAttributeParams.validate) {
164
- // Return validation result for target attribute
165
- return styleAttributeParams.validate(styleValue);
166
- } else {
167
- // Or always add to list
168
- return true;
162
+ // Collect list of possible styles for propKey. e.g:
163
+ // "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
164
+ const possibleStyleAttributesList = styleAttributes.filter((styleAttribute) => {
165
+ // Attribute can be array with key on first position and params on second
166
+ if (Array.isArray(styleAttribute)) {
167
+ // First item always attribute key (e.g. border, width, etc)
168
+ const styleAttributeKey = styleAttribute[0];
169
+ // Second item always params with some settings or methods
170
+ const styleAttributeParams = styleAttribute[1] || {};
171
+ // If is target attribute key
172
+ if (styleKey.startsWith(styleAttributeKey)) {
173
+ // If target attribute params has validate method
174
+ if (styleAttributeParams.validate) {
175
+ // Return validation result for target attribute
176
+ return styleAttributeParams.validate(styleValue);
177
+ }
178
+ else {
179
+ // Or always add to list
180
+ return true;
181
+ }
182
+ }
183
+ else {
184
+ // Else ignore
185
+ return false;
186
+ }
187
+ }
188
+ else {
189
+ // If is target attribute
190
+ return styleKey.startsWith(String(styleAttribute));
169
191
  }
170
- } else {
171
- // Else ignore
172
- return false;
173
- }
174
- } else {
175
- // If is target attribute
176
- return styleKey.startsWith(styleAttribute);
177
- }
178
- });
179
- // Get longest style key (e.g. "borderLeftWidth")
180
- const targetStyleAttribute = maxBy(possibleStyleAttributesList, styleAttribute => {
181
- const key = getStyleAttributeKey(styleAttribute);
182
- return key.length;
183
- });
184
- const styleAttributeKey = getStyleAttributeKey(targetStyleAttribute);
185
- return styleAttributeKey;
192
+ });
193
+ // Get longest style key (e.g. "borderLeftWidth")
194
+ const targetStyleAttribute = maxBy(possibleStyleAttributesList, (styleAttribute) => {
195
+ const key = getStyleAttributeKey(styleAttribute);
196
+ return key.length;
197
+ });
198
+ const styleAttributeKey = getStyleAttributeKey(targetStyleAttribute);
199
+ return styleAttributeKey;
186
200
  };
187
201
 
188
202
  export { useStyles };
@@ -14,8 +14,8 @@ type AvatarAppearanceProps = {
14
14
  badgeValue?: BadgeProps['value'];
15
15
  borderColor?: BorderColorProps;
16
16
  fill?: FillProps;
17
- fillHoverClass?: FillHoverProps;
18
- icon?: string;
17
+ fillHover?: FillHoverProps;
18
+ icon?: IconProps['SvgImage'];
19
19
  iconFill?: IconProps['fill'];
20
20
  iconFillHover?: IconProps['fillHover'];
21
21
  iconFillSize?: IconProps['fillSize'];