@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.
- package/dist/{Avatar_cjs_CZ0XJ6d2.js → Avatar_cjs_CvbURI0f.js} +1 -1
- package/dist/{Avatar_es_B2gMldVe.js → Avatar_es_CV-ffIJu.js} +1 -1
- package/dist/{ChipsGroup_cjs_D0xy5I4S.js → ChipsGroup_cjs_CE-nNENH.js} +2 -4
- package/dist/{ChipsGroup_es_C_dgXLfC.js → ChipsGroup_es_CxqwFgoo.js} +2 -4
- package/dist/{Image_cjs_C_FMjUjx.js → Image_cjs_Hvjp2QDB.js} +2 -2
- package/dist/{Image_es_Ca7UQOkj.js → Image_es_DpOCNWpn.js} +2 -2
- package/dist/{SelectContainer_cjs_DshFNYWN.js → SelectContainer_cjs_qWAMLIkz.js} +5 -5
- package/dist/{SelectContainer_es_BQ3-SqL2.js → SelectContainer_es_kRH4DsEh.js} +5 -5
- package/dist/cjs/components/Avatar.js +2 -2
- package/dist/cjs/components/AvatarStack.js +2 -2
- package/dist/cjs/components/Checkbox.js +47 -50
- package/dist/cjs/components/Checkmark.js +31 -6
- package/dist/cjs/components/Chips.js +1 -1
- package/dist/cjs/components/DatePeriod.js +8 -8
- package/dist/cjs/components/DatePicker.js +4 -4
- package/dist/cjs/components/Drawer.js +23 -24
- package/dist/cjs/components/Image.js +1 -1
- package/dist/cjs/components/InputPassword.js +1 -1
- package/dist/cjs/components/Select/stories/__mock__.js +4 -4
- package/dist/cjs/components/Select.js +2 -2
- package/dist/cjs/components/Tile.js +2 -1
- package/dist/cjs/context/Notifications.js +1 -1
- package/dist/cjs/context/UIContext.js +7 -1
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.helpers.js +9 -9
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.js +3 -3
- package/dist/cjs/hooks/useStyles/styleAttributes.js +166 -43
- package/dist/cjs/hooks/useStyles/useStyles.js +169 -155
- package/dist/cjs/utils/mergeAppearanceKeys.js +14 -1
- package/dist/components/Avatar.js +2 -2
- package/dist/components/AvatarStack.js +2 -2
- package/dist/components/Checkbox.js +47 -50
- package/dist/components/Checkmark.js +31 -6
- package/dist/components/Chips.js +1 -1
- package/dist/components/DatePeriod.js +8 -8
- package/dist/components/DatePicker.js +4 -4
- package/dist/components/Drawer.js +23 -24
- package/dist/components/Image.js +1 -1
- package/dist/components/InputPassword.js +1 -1
- package/dist/components/Select/stories/__mock__.js +4 -4
- package/dist/components/Select.js +2 -2
- package/dist/components/Tile.js +2 -1
- package/dist/context/Notifications.js +1 -1
- package/dist/context/UIContext.js +7 -1
- package/dist/css/styles/bundles.css +102 -97
- package/dist/hooks/useActiveClasses/useActiveClasses.helpers.js +9 -9
- package/dist/hooks/useActiveClasses/useActiveClasses.js +3 -3
- package/dist/hooks/useStyles/styleAttributes.js +166 -43
- package/dist/hooks/useStyles/useStyles.js +169 -155
- package/dist/types/components/Avatar/Avatar.interface.d.ts +2 -2
- package/dist/types/components/AvatarStack/AvatarStack.interface.d.ts +9 -15
- package/dist/types/components/Breadcrumbs/Breadcrumbs.interface.d.ts +9 -8
- package/dist/types/components/Checkbox/Checkbox.interface.d.ts +3 -3
- package/dist/types/components/Checkbox/appearance/checkboxShape.d.ts +3 -0
- package/dist/types/components/Checkmark/Checkmark.interface.d.ts +8 -2
- package/dist/types/components/Checkmark/appearance/checkmarkError.d.ts +3 -0
- package/dist/types/components/Checkmark/stories/CheckmarkError.stories.d.ts +23 -0
- package/dist/types/components/Chips/Chips.interface.d.ts +2 -2
- package/dist/types/components/DatePeriod/DatePeriod.interface.d.ts +20 -19
- package/dist/types/components/DatePeriod/stories/DatePeriodSize.stories.d.ts +3 -0
- package/dist/types/components/DatePicker/DatePicker.interface.d.ts +4 -3
- package/dist/types/components/HeroTitle/HeroTitle.interface.d.ts +1 -1
- package/dist/types/components/Link/Link.interface.d.ts +1 -1
- package/dist/types/components/List/List.interface.d.ts +1 -1
- package/dist/types/components/Loader/Loader.interface.d.ts +4 -3
- package/dist/types/components/MenuItem/MenuItem.interface.d.ts +1 -1
- package/dist/types/components/Notification/Notification.interface.d.ts +2 -2
- package/dist/types/components/Search/Search.interface.d.ts +10 -9
- package/dist/types/components/Search/SearchInput.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputDefault.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputDemo.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputDisabled.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputError.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputRequire.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputShape.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputSize.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputStyle.stories.d.ts +7 -7
- package/dist/types/components/Search/stories/SearchInputSuccess.stories.d.ts +7 -7
- package/dist/types/components/Select/Select.interface.d.ts +9 -7
- package/dist/types/components/Select/SelectContainer.d.ts +4 -1
- package/dist/types/components/Select/SelectMultiValue.d.ts +2 -2
- package/dist/types/components/Select/stories/Select.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectDefault.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectDisabled.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectError.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectRequire.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectShape.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectSize.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectStyle.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/SelectSuccess.stories.d.ts +5 -3
- package/dist/types/components/Select/stories/__mock__/index.d.ts +2 -2
- package/dist/types/components/Swiper/Swiper.interface.d.ts +2 -11
- package/dist/types/components/Text/Text.interface.d.ts +2 -2
- package/dist/types/context/Notifications.d.ts +1 -1
- package/dist/types/context/Notifications.interface.d.ts +2 -1
- package/dist/types/context/UIContext.d.ts +10 -4
- package/dist/types/hooks/useActiveClasses/useActiveClasses.interface.d.ts +1 -2
- package/dist/types/hooks/useStyles/styleAttributes.d.ts +2 -3
- package/dist/types/hooks/useStyles/styleAttributes.interface.d.ts +9 -3
- package/dist/types/hooks/useStyles/useStyles.d.ts +4 -1
- package/dist/types/utils/mergeAppearanceKeys.d.ts +6 -1
- package/dist/utils/mergeAppearanceKeys.js +14 -1
- package/package.json +12 -12
- package/dist/{DatePicker_cjs_avA-OHmZ.js → DatePicker_cjs_BJzVpk0o.js} +3 -3
- 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: ({
|
|
5
|
+
stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
key: 'fillHoverClass',
|
|
9
|
-
stateFn: ({
|
|
9
|
+
stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
key: 'fillActiveClass',
|
|
13
|
-
stateFn: ({
|
|
13
|
+
stateFn: ({ isActive, isDisabled }) => Boolean(isActive) && !isDisabled,
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
key: 'fillActiveHoverClass',
|
|
17
|
-
stateFn: ({
|
|
17
|
+
stateFn: ({ isActive, isDisabled }) => Boolean(isActive) && !isDisabled,
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
key: 'fillDisabledClass',
|
|
21
|
-
stateFn: ({
|
|
21
|
+
stateFn: ({ isActive, isDisabled }) => !isActive && Boolean(isDisabled),
|
|
22
22
|
},
|
|
23
23
|
],
|
|
24
24
|
borderColor: [
|
|
25
25
|
{
|
|
26
26
|
key: 'borderColorClass',
|
|
27
|
-
stateFn: ({
|
|
27
|
+
stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
key: 'borderColorHoverClass',
|
|
31
|
-
stateFn: ({
|
|
31
|
+
stateFn: ({ isActive, isDisabled }) => !isActive && !isDisabled,
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
key: 'borderColorActiveClass',
|
|
35
|
-
stateFn: ({
|
|
35
|
+
stateFn: ({ isActive, isDisabled }) => Boolean(isActive) && !isDisabled,
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
textColor: [
|
|
39
39
|
{
|
|
40
40
|
key: 'textColorClass',
|
|
41
|
-
stateFn: ({
|
|
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 {
|
|
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({
|
|
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({
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
'alignContent',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
18
|
-
icon?:
|
|
17
|
+
fillHover?: FillHoverProps;
|
|
18
|
+
icon?: IconProps['SvgImage'];
|
|
19
19
|
iconFill?: IconProps['fill'];
|
|
20
20
|
iconFillHover?: IconProps['fillHover'];
|
|
21
21
|
iconFillSize?: IconProps['fillSize'];
|