@itcase/ui 1.0.43 → 1.0.44
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/components/Accordion.js +56 -58
- package/dist/components/Avatar.js +31 -29
- package/dist/components/Background.js +15 -12
- package/dist/components/Badge.js +13 -11
- package/dist/components/Breadcrumbs.js +72 -71
- package/dist/components/Button.js +56 -53
- package/dist/components/Caption.js +11 -8
- package/dist/components/Card.js +22 -20
- package/dist/components/Cell.js +52 -50
- package/dist/components/Checkbox.js +31 -29
- package/dist/components/Chips.js +21 -18
- package/dist/components/Choice.js +43 -49
- package/dist/components/Code.js +260 -105
- package/dist/components/ContextMenu.js +38 -34
- package/dist/components/CookiesWarning.js +26 -27
- package/dist/components/DatePicker.js +64 -67
- package/dist/components/Divider.js +15 -12
- package/dist/components/Dot.js +8 -6
- package/dist/components/Dropdown.js +88 -88
- package/dist/components/Empty.js +21 -19
- package/dist/components/Fader.js +13 -10
- package/dist/components/Flex.js +43 -37
- package/dist/components/FormField.js +77 -66
- package/dist/components/Grid.js +66 -57
- package/dist/components/Group.js +33 -30
- package/dist/components/Icon.js +41 -38
- package/dist/components/Image.js +34 -28
- package/dist/components/Input.js +29 -28
- package/dist/components/InputPassword.js +45 -48
- package/dist/components/Label.js +29 -26
- package/dist/components/LanguageSelector.js +29 -30
- package/dist/components/Link.js +43 -39
- package/dist/components/List.js +35 -29
- package/dist/components/Loader.js +22 -19
- package/dist/components/Logo.js +17 -14
- package/dist/components/Menu.js +20 -19
- package/dist/components/MenuItem.js +55 -52
- package/dist/components/Modal.js +51 -63
- package/dist/components/Notification.js +41 -38
- package/dist/components/Pagination.js +17 -15
- package/dist/components/RadioButton.js +31 -29
- package/dist/components/RangeSlider.js +29 -26
- package/dist/components/Scrollbar.js +6 -4
- package/dist/components/Search.js +66 -61
- package/dist/components/Segmented.js +52 -58
- package/dist/components/Select.js +181 -168
- package/dist/components/SiteMenu.js +34 -28
- package/dist/components/Swiper.js +104 -92
- package/dist/components/Switch.js +11 -9
- package/dist/components/Tab.js +95 -80
- package/dist/components/Text.js +27 -24
- package/dist/components/Textarea.js +23 -21
- package/dist/components/Tile.js +37 -34
- package/dist/components/Title.js +38 -30
- package/dist/components/Tooltip.js +24 -21
- package/dist/components/Video.js +16 -13
- package/dist/components/Wrapper.js +23 -20
- package/dist/constants/componentProps/align.js +1 -1
- package/dist/constants/componentProps/alignDirection.js +1 -1
- package/dist/constants/componentProps/borderColor.js +1 -1
- package/dist/constants/componentProps/borderType.js +1 -1
- package/dist/constants/componentProps/captionPosition.js +1 -1
- package/dist/constants/componentProps/direction.js +1 -1
- package/dist/constants/componentProps/emojiSize.js +1 -1
- package/dist/constants/componentProps/fill.js +1 -1
- package/dist/constants/componentProps/fillGradient.js +1 -1
- package/dist/constants/componentProps/fillType.js +1 -1
- package/dist/constants/componentProps/flexAlign.js +1 -1
- package/dist/constants/componentProps/flexJustifyContent.js +1 -1
- package/dist/constants/componentProps/flexWrap.js +1 -1
- package/dist/constants/componentProps/gridAlign.js +1 -1
- package/dist/constants/componentProps/gridAlignSelf.js +1 -1
- package/dist/constants/componentProps/gridJustifyItems.js +1 -1
- package/dist/constants/componentProps/gridJustifySelf.js +1 -1
- package/dist/constants/componentProps/horizontalContentAlign.js +1 -1
- package/dist/constants/componentProps/horizontalResizeMode.js +1 -1
- package/dist/constants/componentProps/iconSize.js +1 -1
- package/dist/constants/componentProps/position.js +1 -1
- package/dist/constants/componentProps/resizeMode.js +1 -1
- package/dist/constants/componentProps/shape.js +1 -1
- package/dist/constants/componentProps/size.js +1 -1
- package/dist/constants/componentProps/stacking.js +1 -1
- package/dist/constants/componentProps/strokeColor.js +1 -1
- package/dist/constants/componentProps/textAlign.js +1 -1
- package/dist/constants/componentProps/textColor.js +1 -1
- package/dist/constants/componentProps/textColorActive.js +1 -1
- package/dist/constants/componentProps/textColorHover.js +1 -1
- package/dist/constants/componentProps/textGradient.js +1 -1
- package/dist/constants/componentProps/textStyle.js +1 -1
- package/dist/constants/componentProps/textTag.js +1 -1
- package/dist/constants/componentProps/textWeight.js +1 -1
- package/dist/constants/componentProps/titleSize.js +1 -1
- package/dist/constants/componentProps/type.js +1 -1
- package/dist/constants/componentProps/underline.js +1 -1
- package/dist/constants/componentProps/verticalContentAlign.js +1 -1
- package/dist/constants/componentProps/verticalResizeMode.js +1 -1
- package/dist/constants/componentProps/width.js +1 -1
- package/dist/constants/componentProps/wrap.js +1 -1
- package/dist/context/Notifications.js +38 -53
- package/dist/context/UIContext.js +14 -17
- package/dist/css/components/Choice/Choice.css +8 -0
- package/dist/css/components/Code/Code.css +35 -34
- package/dist/css/components/DatePicker/DatePicker.css +39 -0
- package/dist/css/components/Swiper/Swiper.css +6 -3
- package/dist/css/components/Tab/Tab.css +10 -1
- package/dist/css/styles/align/align.css +0 -1
- package/dist/css/styles/align/align_horizontal-reverse.css +6 -6
- package/dist/css/styles/align/align_horizontal.css +9 -9
- package/dist/css/styles/border-color/border-color.css +15 -1
- package/dist/css/styles/column-gap/column-gap.css +3 -1
- package/dist/css/styles/gap/gap.css +3 -1
- package/dist/css/styles/row-gap/row-gap.css +3 -1
- package/dist/hooks/useDeviceTargetClass.js +19 -18
- package/dist/hooks/useMediaQueries.js +7 -10
- package/dist/hooks/useStyles.js +127 -8
- package/package.json +30 -29
- package/dist/useStyles-e4accb53.js +0 -153
|
@@ -27,30 +27,31 @@ function useDeviceTargetClass(componentProps, hookProps) {
|
|
|
27
27
|
* "hookProps" - special props for generating class
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
prefix =
|
|
32
|
-
propsKey
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
isMobile
|
|
37
|
-
isTablet
|
|
38
|
-
isDesktop
|
|
39
|
-
|
|
30
|
+
const {
|
|
31
|
+
prefix = '',
|
|
32
|
+
propsKey,
|
|
33
|
+
replace = [/([A-Z])/g, '-$1']
|
|
34
|
+
} = hookProps;
|
|
35
|
+
const {
|
|
36
|
+
isMobile,
|
|
37
|
+
isTablet,
|
|
38
|
+
isDesktop
|
|
39
|
+
} = UIContext.useUserDeviceContext();
|
|
40
|
+
const targetClassValue = React.useMemo(() => {
|
|
40
41
|
// prettier-ignore
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const deviceBasePart = isMobile && 'Mobile' || isTablet && 'Tablet' || isDesktop && 'Desktop' || '';
|
|
43
|
+
const valueForDevice = componentProps[`${propsKey}${deviceBasePart}`];
|
|
44
|
+
const valueDefault = componentProps[propsKey];
|
|
44
45
|
return valueForDevice || valueDefault;
|
|
45
|
-
}, [isMobile, isTablet, isDesktop, componentProps[propsKey], componentProps[propsKey
|
|
46
|
-
|
|
46
|
+
}, [isMobile, isTablet, isDesktop, componentProps[propsKey], componentProps[`${propsKey}Mobile`], componentProps[`${propsKey}Tablet`], componentProps[`${propsKey}Desktop`]]);
|
|
47
|
+
const targetClass = React.useMemo(() => {
|
|
47
48
|
if (targetClassValue) {
|
|
48
|
-
|
|
49
|
+
let cleanClassValue = camelCase__default.default(String(targetClassValue));
|
|
49
50
|
if (replace) {
|
|
50
|
-
|
|
51
|
+
const replaceList = castArray__default.default(replace);
|
|
51
52
|
cleanClassValue = cleanClassValue.replace(replaceList[0], replaceList[1] || '');
|
|
52
53
|
}
|
|
53
|
-
return
|
|
54
|
+
return `${prefix}${cleanClassValue}`.toLowerCase();
|
|
54
55
|
}
|
|
55
56
|
return null;
|
|
56
57
|
}, [targetClassValue, prefix, replace]);
|
|
@@ -23,14 +23,11 @@ var mediaQueries = {
|
|
|
23
23
|
"desktop-huge": "160em"
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
function useMediaQueries(userDevice) {
|
|
28
|
-
if (userDevice === void 0) {
|
|
29
|
-
userDevice = {};
|
|
30
|
-
}
|
|
26
|
+
const isSSR = typeof window === 'undefined';
|
|
27
|
+
function useMediaQueries(userDevice = {}) {
|
|
31
28
|
// const isWarning = useMediaQuery({ maxWidth: mediaQueries['mobile-tiny'] })
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
const isMobile = reactResponsive.useMediaQuery({
|
|
34
31
|
minWidth: mediaQueries['mobile-tiny'],
|
|
35
32
|
maxWidth: mediaQueries['tablet']
|
|
36
33
|
}) || isSSR && Boolean(userDevice.isMobile);
|
|
@@ -63,7 +60,7 @@ function useMediaQueries(userDevice) {
|
|
|
63
60
|
minWidth: mediaQueries['mobile-super-extra-large'],
|
|
64
61
|
maxWidth: mediaQueries['tablet']
|
|
65
62
|
});
|
|
66
|
-
|
|
63
|
+
const isTablet = reactResponsive.useMediaQuery({
|
|
67
64
|
minWidth: mediaQueries['tablet'],
|
|
68
65
|
maxWidth: mediaQueries['desktop-small']
|
|
69
66
|
}) || isSSR && Boolean(userDevice.isTablet);
|
|
@@ -76,7 +73,7 @@ function useMediaQueries(userDevice) {
|
|
|
76
73
|
// maxWidth: mediaQueries['tablet-large'],
|
|
77
74
|
// })
|
|
78
75
|
|
|
79
|
-
|
|
76
|
+
const isDesktop = reactResponsive.useMediaQuery({
|
|
80
77
|
minWidth: mediaQueries['desktop-small'],
|
|
81
78
|
maxWidth: mediaQueries['desktop-super-huge']
|
|
82
79
|
}) || isSSR && Boolean(userDevice.isDesktop);
|
|
@@ -104,7 +101,7 @@ function useMediaQueries(userDevice) {
|
|
|
104
101
|
// minWidth: mediaQueries['desktop-super-extra-large'],
|
|
105
102
|
// maxWidth: mediaQueries['desktop-huge'],
|
|
106
103
|
// })
|
|
107
|
-
|
|
104
|
+
const isDesktopMega = reactResponsive.useMediaQuery({
|
|
108
105
|
minWidth: mediaQueries['desktop-huge']
|
|
109
106
|
});
|
|
110
107
|
return {
|
|
@@ -127,7 +124,7 @@ function useMediaQueries(userDevice) {
|
|
|
127
124
|
// isDesktopStandart,
|
|
128
125
|
// isDesktopLarge,
|
|
129
126
|
// isDesktopHuge,
|
|
130
|
-
isDesktopMega
|
|
127
|
+
isDesktopMega
|
|
131
128
|
};
|
|
132
129
|
}
|
|
133
130
|
|
package/dist/hooks/useStyles.js
CHANGED
|
@@ -1,16 +1,135 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('
|
|
5
|
-
require('lodash/
|
|
6
|
-
require('lodash/
|
|
7
|
-
require('
|
|
8
|
-
require('
|
|
9
|
-
require('../context/UIContext.js');
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var camelCase = require('lodash/camelCase');
|
|
5
|
+
var maxBy = require('lodash/maxBy');
|
|
6
|
+
var upperFirst = require('lodash/upperFirst');
|
|
7
|
+
var styleAttributes = require('./styleAttributes.js');
|
|
8
|
+
var UIContext = require('../context/UIContext.js');
|
|
10
9
|
require('prop-types');
|
|
11
10
|
require('./useMediaQueries.js');
|
|
12
11
|
require('react-responsive');
|
|
13
12
|
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
15
|
+
var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
|
|
16
|
+
var maxBy__default = /*#__PURE__*/_interopDefault(maxBy);
|
|
17
|
+
var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
let DEVICE_TYPES = [];
|
|
20
|
+
const removeDeviceType = originalKey => {
|
|
21
|
+
// Remove "mobile"/"tablet"/"desktop"
|
|
22
|
+
const withOutDeviceType = DEVICE_TYPES.reduce((cleanKey, deviceType) => {
|
|
23
|
+
if (cleanKey.endsWith(upperFirst__default.default(deviceType))) {
|
|
24
|
+
return cleanKey.replace(upperFirst__default.default(deviceType), '');
|
|
25
|
+
}
|
|
26
|
+
return cleanKey;
|
|
27
|
+
}, originalKey);
|
|
28
|
+
return withOutDeviceType;
|
|
29
|
+
};
|
|
30
|
+
function useStyles(props) {
|
|
31
|
+
const allDevicesTypes = UIContext.useUserDeviceContext();
|
|
32
|
+
const {
|
|
33
|
+
isMobile,
|
|
34
|
+
isTablet,
|
|
35
|
+
isDesktop,
|
|
36
|
+
...fullNamedDeviceTypes
|
|
37
|
+
} = allDevicesTypes;
|
|
38
|
+
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
const deviceBasePart = React.useMemo(() => isMobile && 'Mobile' || isTablet && 'Tablet' || isDesktop && 'Desktop' || '', [isMobile, isTablet, isDesktop]);
|
|
41
|
+
/*
|
|
42
|
+
* rule of prop key:
|
|
43
|
+
*
|
|
44
|
+
* first is style second is div targer thrid is device
|
|
45
|
+
* paddingHorizontal GridInnerWrapper MobileNormal
|
|
46
|
+
*
|
|
47
|
+
* paddingHorizontalGridInnerWrapperMobileNormal: "10px"
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
const currentDevice = React.useMemo(() => {
|
|
51
|
+
const deviceTypes = Object.keys(allDevicesTypes).map(key => camelCase__default.default(key.replace('is', '')));
|
|
52
|
+
|
|
53
|
+
// if "fullNamedDeviceTypes.isMobileLarge": true - that our device
|
|
54
|
+
let currentDevice = Object.keys(fullNamedDeviceTypes).find(key => fullNamedDeviceTypes[key]);
|
|
55
|
+
if (!currentDevice) {
|
|
56
|
+
currentDevice = deviceBasePart;
|
|
57
|
+
}
|
|
58
|
+
currentDevice = upperFirst__default.default(camelCase__default.default(currentDevice.replace('is', '')));
|
|
59
|
+
DEVICE_TYPES = deviceTypes;
|
|
60
|
+
|
|
61
|
+
// Set non-existent "currentDevice" value, to collect default styles later
|
|
62
|
+
return currentDevice || '__DEVICE_IS_NOT_FOUND__';
|
|
63
|
+
}, [allDevicesTypes, deviceBasePart]);
|
|
64
|
+
const collectedStyles = React.useMemo(() => {
|
|
65
|
+
const resultStyles = {};
|
|
66
|
+
|
|
67
|
+
// For every component props
|
|
68
|
+
Object.entries(props).forEach(([propKey, propValue]) => {
|
|
69
|
+
// Collect list of possible styles for propKey. e.g:
|
|
70
|
+
// "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
|
|
71
|
+
const possibleStyleAttributes = styleAttributes.default.filter(styleAttribute => {
|
|
72
|
+
return propKey.startsWith(styleAttribute);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Get longest style key (e.g. "borderLeftWidth")
|
|
76
|
+
const currentStyleAttribute = maxBy__default.default(possibleStyleAttributes, 'length');
|
|
77
|
+
if (currentStyleAttribute) {
|
|
78
|
+
const isStyleForCurrentDevice = propKey.toLowerCase().endsWith(currentDevice.toLowerCase());
|
|
79
|
+
let value = null;
|
|
80
|
+
|
|
81
|
+
// e.g. "GridWrapperInner"
|
|
82
|
+
const targetElementKey = removeDeviceType(propKey.replace(currentStyleAttribute, ''));
|
|
83
|
+
const targetElementResultKey = camelCase__default.default(targetElementKey) || 'styles';
|
|
84
|
+
if (!resultStyles[targetElementResultKey]) {
|
|
85
|
+
resultStyles[targetElementResultKey] = {};
|
|
86
|
+
}
|
|
87
|
+
if (isStyleForCurrentDevice) {
|
|
88
|
+
value = propValue;
|
|
89
|
+
} else {
|
|
90
|
+
const propKeyWithOutDeviceType = `${currentStyleAttribute}${targetElementKey}`;
|
|
91
|
+
const propKeyWithBaseDeviceType = `${propKeyWithOutDeviceType}${deviceBasePart}`;
|
|
92
|
+
const defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
|
|
93
|
+
let currentValue = resultStyles[targetElementResultKey][currentStyleAttribute];
|
|
94
|
+
if (propKeyWithOutDeviceType.includes('Horizontal')) {
|
|
95
|
+
const keyLeft = currentStyleAttribute.replace('Horizontal', 'Left');
|
|
96
|
+
currentValue = resultStyles[targetElementResultKey][keyLeft];
|
|
97
|
+
} else if (propKeyWithOutDeviceType.includes('Vertical')) {
|
|
98
|
+
const keyTop = currentStyleAttribute.replace('Vertical', 'Top');
|
|
99
|
+
currentValue = resultStyles[targetElementResultKey][keyTop];
|
|
100
|
+
}
|
|
101
|
+
if (!currentValue) {
|
|
102
|
+
value = defaultValue;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (value) {
|
|
106
|
+
// TODO: handle 16px/9px propValues for Horizontal(Left/Right) and Vertical(Top/Bottom)
|
|
107
|
+
const HAS_UNIT = /\D/;
|
|
108
|
+
// prettier-ignore
|
|
109
|
+
const ignorePX = currentStyleAttribute.includes('zIndex') || currentStyleAttribute.includes('order');
|
|
110
|
+
if (!HAS_UNIT.test(value) && !ignorePX) {
|
|
111
|
+
value = `${value}px`;
|
|
112
|
+
}
|
|
113
|
+
if (currentStyleAttribute.includes('Horizontal')) {
|
|
114
|
+
const keyLeft = currentStyleAttribute.replace('Horizontal', 'Left');
|
|
115
|
+
const keyRight = currentStyleAttribute.replace('Horizontal', 'Right');
|
|
116
|
+
resultStyles[targetElementResultKey][keyLeft] = value;
|
|
117
|
+
resultStyles[targetElementResultKey][keyRight] = value;
|
|
118
|
+
} else if (currentStyleAttribute.includes('Vertical')) {
|
|
119
|
+
const keyTop = currentStyleAttribute.replace('Vertical', 'Top');
|
|
120
|
+
const keyBottom = currentStyleAttribute.replace('Vertical', 'Bottom');
|
|
121
|
+
resultStyles[targetElementResultKey][keyTop] = value;
|
|
122
|
+
resultStyles[targetElementResultKey][keyBottom] = value;
|
|
123
|
+
} else {
|
|
124
|
+
resultStyles[targetElementResultKey][currentStyleAttribute] = value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return resultStyles;
|
|
130
|
+
}, [currentDevice, props.display]); // "props" object maybe big and frequently changing
|
|
131
|
+
|
|
132
|
+
return collectedStyles;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exports.useStyles = useStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"description": "UI components (Modal, Loader, Popup, etc)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Modal",
|
|
@@ -40,64 +40,65 @@
|
|
|
40
40
|
"registry": "https://registry.npmjs.org/"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@itcase/common": "^1.1.
|
|
43
|
+
"@itcase/common": "^1.1.6",
|
|
44
44
|
"clsx": "^2.0.0",
|
|
45
45
|
"html5-boilerplate": "^8.0.0",
|
|
46
46
|
"js-cookie": "^3.0.5",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
|
-
"luxon": "^3.3
|
|
48
|
+
"luxon": "^3.4.3",
|
|
49
49
|
"prop-types": "^15.8.1",
|
|
50
50
|
"rc-slider": "^10.2.1",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-date-range": "^1.4.0",
|
|
53
53
|
"react-dom": "^18.2.0",
|
|
54
|
-
"react-inlinesvg": "^
|
|
54
|
+
"react-inlinesvg": "^4.0.3",
|
|
55
|
+
"react-otp-input": "^3.0.4",
|
|
55
56
|
"react-paginate": "^8.2.0",
|
|
56
57
|
"react-responsive": "^9.0.2",
|
|
57
58
|
"react-scrollbars-custom": "^4.1.1",
|
|
58
59
|
"react-select": "^5.7.4",
|
|
59
|
-
"swiper": "^10.
|
|
60
|
+
"swiper": "^10.2.0",
|
|
60
61
|
"uuid": "^9.0.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@babel/core": "^7.22.
|
|
64
|
-
"@babel/eslint-parser": "^7.22.
|
|
65
|
-
"@babel/preset-env": "^7.22.
|
|
66
|
-
"@babel/preset-react": "^7.22.
|
|
67
|
-
"@commitlint/cli": "^17.
|
|
68
|
-
"@commitlint/config-conventional": "^17.
|
|
64
|
+
"@babel/core": "^7.22.17",
|
|
65
|
+
"@babel/eslint-parser": "^7.22.15",
|
|
66
|
+
"@babel/preset-env": "^7.22.15",
|
|
67
|
+
"@babel/preset-react": "^7.22.15",
|
|
68
|
+
"@commitlint/cli": "^17.7.1",
|
|
69
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
69
70
|
"@rollup/plugin-babel": "^6.0.3",
|
|
70
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
71
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
71
72
|
"@rollup/plugin-json": "^6.0.0",
|
|
72
|
-
"@rollup/plugin-node-resolve": "^15.1
|
|
73
|
+
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
73
74
|
"@rollup/plugin-terser": "^0.4.3",
|
|
74
75
|
"@semantic-release/changelog": "^6.0.3",
|
|
75
76
|
"@semantic-release/git": "^10.0.1",
|
|
76
|
-
"@semantic-release/release-notes-generator": "^11.0.
|
|
77
|
+
"@semantic-release/release-notes-generator": "^11.0.7",
|
|
77
78
|
"babel-loader": "^9.1.3",
|
|
78
79
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
79
80
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
80
|
-
"eslint": "8.
|
|
81
|
-
"eslint-config-prettier": "^
|
|
81
|
+
"eslint": "8.49.0",
|
|
82
|
+
"eslint-config-prettier": "^9.0.0",
|
|
82
83
|
"eslint-config-standard": "^17.1.0",
|
|
83
84
|
"eslint-plugin-babel": "^5.3.1",
|
|
84
|
-
"eslint-plugin-import": "^2.28.
|
|
85
|
-
"eslint-plugin-n": "^16.0.
|
|
85
|
+
"eslint-plugin-import": "^2.28.1",
|
|
86
|
+
"eslint-plugin-n": "^16.0.2",
|
|
86
87
|
"eslint-plugin-node": "^11.1.0",
|
|
87
88
|
"eslint-plugin-prettier": "^5.0.0",
|
|
88
89
|
"eslint-plugin-promise": "^6.1.1",
|
|
89
|
-
"eslint-plugin-react": "^7.33.
|
|
90
|
+
"eslint-plugin-react": "^7.33.2",
|
|
90
91
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
91
92
|
"eslint-plugin-standard": "^5.0.0",
|
|
92
93
|
"husky": "^8.0.3",
|
|
93
|
-
"lint-staged": "^
|
|
94
|
-
"npm": "^
|
|
95
|
-
"postcss": "^8.4.
|
|
94
|
+
"lint-staged": "^14.0.1",
|
|
95
|
+
"npm": "^10.1.0",
|
|
96
|
+
"postcss": "^8.4.29",
|
|
96
97
|
"postcss-aspect-ratio-polyfill": "^2.0.0",
|
|
97
98
|
"postcss-cli": "^10.1.0",
|
|
98
99
|
"postcss-combine-duplicated-selectors": "^10.0.3",
|
|
99
100
|
"postcss-csso": "^6.0.1",
|
|
100
|
-
"postcss-dark-theme-class": "^0.
|
|
101
|
+
"postcss-dark-theme-class": "^1.0.0",
|
|
101
102
|
"postcss-discard-duplicates": "^6.0.0",
|
|
102
103
|
"postcss-each": "^1.1.0",
|
|
103
104
|
"postcss-easings": "^4.0.0",
|
|
@@ -110,16 +111,16 @@
|
|
|
110
111
|
"postcss-nested-ancestors": "^3.0.0",
|
|
111
112
|
"postcss-normalize": "^10.0.1",
|
|
112
113
|
"postcss-prepend-imports": "^1.0.1",
|
|
113
|
-
"postcss-preset-env": "^9.1.
|
|
114
|
+
"postcss-preset-env": "^9.1.3",
|
|
114
115
|
"postcss-pxtorem": "^6.0.0",
|
|
115
116
|
"postcss-responsive-type": "github:ITCase/postcss-responsive-type",
|
|
116
117
|
"postcss-sort-media-queries": "^5.2.0",
|
|
117
|
-
"prettier": "^3.0.
|
|
118
|
-
"react-datepicker": "^4.
|
|
119
|
-
"rollup": "^3.
|
|
118
|
+
"prettier": "^3.0.3",
|
|
119
|
+
"react-datepicker": "^4.17.0",
|
|
120
|
+
"rollup": "^3.29.1",
|
|
120
121
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
121
|
-
"semantic-release": "^21.
|
|
122
|
-
"stylelint": "^15.10.
|
|
122
|
+
"semantic-release": "^21.1.1",
|
|
123
|
+
"stylelint": "^15.10.3",
|
|
123
124
|
"stylelint-config-standard": "^34.0.0",
|
|
124
125
|
"stylelint-no-unsupported-browser-features": "^7.0.0",
|
|
125
126
|
"stylelint-order": "^6.0.3"
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var camelCase = require('lodash/camelCase');
|
|
5
|
-
var maxBy = require('lodash/maxBy');
|
|
6
|
-
var upperFirst = require('lodash/upperFirst');
|
|
7
|
-
var styleAttributes = require('./hooks/styleAttributes.js');
|
|
8
|
-
var UIContext = require('./context/UIContext.js');
|
|
9
|
-
|
|
10
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
|
|
13
|
-
var maxBy__default = /*#__PURE__*/_interopDefault(maxBy);
|
|
14
|
-
var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
|
|
15
|
-
|
|
16
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
17
|
-
if (source == null) return {};
|
|
18
|
-
var target = {};
|
|
19
|
-
var sourceKeys = Object.keys(source);
|
|
20
|
-
var key, i;
|
|
21
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
22
|
-
key = sourceKeys[i];
|
|
23
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
24
|
-
target[key] = source[key];
|
|
25
|
-
}
|
|
26
|
-
return target;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var _excluded = ["isMobile", "isTablet", "isDesktop"];
|
|
30
|
-
var DEVICE_TYPES = [];
|
|
31
|
-
var removeDeviceType = function removeDeviceType(originalKey) {
|
|
32
|
-
// Remove "mobile"/"tablet"/"desktop"
|
|
33
|
-
var withOutDeviceType = DEVICE_TYPES.reduce(function (cleanKey, deviceType) {
|
|
34
|
-
if (cleanKey.endsWith(upperFirst__default.default(deviceType))) {
|
|
35
|
-
return cleanKey.replace(upperFirst__default.default(deviceType), '');
|
|
36
|
-
}
|
|
37
|
-
return cleanKey;
|
|
38
|
-
}, originalKey);
|
|
39
|
-
return withOutDeviceType;
|
|
40
|
-
};
|
|
41
|
-
function useStyles(props) {
|
|
42
|
-
var allDevicesTypes = UIContext.useUserDeviceContext();
|
|
43
|
-
var isMobile = allDevicesTypes.isMobile,
|
|
44
|
-
isTablet = allDevicesTypes.isTablet,
|
|
45
|
-
isDesktop = allDevicesTypes.isDesktop,
|
|
46
|
-
fullNamedDeviceTypes = _objectWithoutPropertiesLoose(allDevicesTypes, _excluded);
|
|
47
|
-
|
|
48
|
-
// prettier-ignore
|
|
49
|
-
var deviceBasePart = React.useMemo(function () {
|
|
50
|
-
return isMobile && 'Mobile' || isTablet && 'Tablet' || isDesktop && 'Desktop' || '';
|
|
51
|
-
}, [isMobile, isTablet, isDesktop]);
|
|
52
|
-
/*
|
|
53
|
-
* rule of prop key:
|
|
54
|
-
*
|
|
55
|
-
* first is style second is div targer thrid is device
|
|
56
|
-
* paddingHorizontal GridInnerWrapper MobileNormal
|
|
57
|
-
*
|
|
58
|
-
* paddingHorizontalGridInnerWrapperMobileNormal: "10px"
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
var currentDevice = React.useMemo(function () {
|
|
62
|
-
var deviceTypes = Object.keys(allDevicesTypes).map(function (key) {
|
|
63
|
-
return camelCase__default.default(key.replace('is', ''));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// if "fullNamedDeviceTypes.isMobileLarge": true - that our device
|
|
67
|
-
var currentDevice = Object.keys(fullNamedDeviceTypes).find(function (key) {
|
|
68
|
-
return fullNamedDeviceTypes[key];
|
|
69
|
-
});
|
|
70
|
-
if (!currentDevice) {
|
|
71
|
-
currentDevice = deviceBasePart;
|
|
72
|
-
}
|
|
73
|
-
currentDevice = upperFirst__default.default(camelCase__default.default(currentDevice.replace('is', '')));
|
|
74
|
-
DEVICE_TYPES = deviceTypes;
|
|
75
|
-
|
|
76
|
-
// Set non-existent "currentDevice" value, to collect default styles later
|
|
77
|
-
return currentDevice || '__DEVICE_IS_NOT_FOUND__';
|
|
78
|
-
}, [allDevicesTypes, deviceBasePart]);
|
|
79
|
-
var collectedStyles = React.useMemo(function () {
|
|
80
|
-
var resultStyles = {};
|
|
81
|
-
|
|
82
|
-
// For every component props
|
|
83
|
-
Object.entries(props).forEach(function (_ref) {
|
|
84
|
-
var propKey = _ref[0],
|
|
85
|
-
propValue = _ref[1];
|
|
86
|
-
// Collect list of possible styles for propKey. e.g:
|
|
87
|
-
// "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
|
|
88
|
-
var possibleStyleAttributes = styleAttributes.default.filter(function (styleAttribute) {
|
|
89
|
-
return propKey.startsWith(styleAttribute);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// Get longest style key (e.g. "borderLeftWidth")
|
|
93
|
-
var currentStyleAttribute = maxBy__default.default(possibleStyleAttributes, 'length');
|
|
94
|
-
if (currentStyleAttribute) {
|
|
95
|
-
var isStyleForCurrentDevice = propKey.toLowerCase().endsWith(currentDevice.toLowerCase());
|
|
96
|
-
var value = null;
|
|
97
|
-
|
|
98
|
-
// e.g. "GridWrapperInner"
|
|
99
|
-
var targetElementKey = removeDeviceType(propKey.replace(currentStyleAttribute, ''));
|
|
100
|
-
var targetElementResultKey = camelCase__default.default(targetElementKey) || 'styles';
|
|
101
|
-
if (!resultStyles[targetElementResultKey]) {
|
|
102
|
-
resultStyles[targetElementResultKey] = {};
|
|
103
|
-
}
|
|
104
|
-
if (isStyleForCurrentDevice) {
|
|
105
|
-
value = propValue;
|
|
106
|
-
} else {
|
|
107
|
-
var propKeyWithOutDeviceType = "" + currentStyleAttribute + targetElementKey;
|
|
108
|
-
var propKeyWithBaseDeviceType = "" + propKeyWithOutDeviceType + deviceBasePart;
|
|
109
|
-
var defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
|
|
110
|
-
var currentValue = resultStyles[targetElementResultKey][currentStyleAttribute];
|
|
111
|
-
if (propKeyWithOutDeviceType.includes('Horizontal')) {
|
|
112
|
-
var keyLeft = currentStyleAttribute.replace('Horizontal', 'Left');
|
|
113
|
-
currentValue = resultStyles[targetElementResultKey][keyLeft];
|
|
114
|
-
} else if (propKeyWithOutDeviceType.includes('Vertical')) {
|
|
115
|
-
var keyTop = currentStyleAttribute.replace('Vertical', 'Top');
|
|
116
|
-
currentValue = resultStyles[targetElementResultKey][keyTop];
|
|
117
|
-
}
|
|
118
|
-
if (!currentValue) {
|
|
119
|
-
value = defaultValue;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (value) {
|
|
123
|
-
// TODO: handle 16px/9px propValues for Horizontal(Left/Right) and Vertical(Top/Bottom)
|
|
124
|
-
var HAS_UNIT = /\D/;
|
|
125
|
-
// prettier-ignore
|
|
126
|
-
var ignorePX = currentStyleAttribute.includes('zIndex') || currentStyleAttribute.includes('order');
|
|
127
|
-
if (!HAS_UNIT.test(value) && !ignorePX) {
|
|
128
|
-
value = value + "px";
|
|
129
|
-
}
|
|
130
|
-
if (currentStyleAttribute.includes('Horizontal')) {
|
|
131
|
-
var _keyLeft = currentStyleAttribute.replace('Horizontal', 'Left');
|
|
132
|
-
var keyRight = currentStyleAttribute.replace('Horizontal', 'Right');
|
|
133
|
-
resultStyles[targetElementResultKey][_keyLeft] = value;
|
|
134
|
-
resultStyles[targetElementResultKey][keyRight] = value;
|
|
135
|
-
} else if (currentStyleAttribute.includes('Vertical')) {
|
|
136
|
-
var _keyTop = currentStyleAttribute.replace('Vertical', 'Top');
|
|
137
|
-
var keyBottom = currentStyleAttribute.replace('Vertical', 'Bottom');
|
|
138
|
-
resultStyles[targetElementResultKey][_keyTop] = value;
|
|
139
|
-
resultStyles[targetElementResultKey][keyBottom] = value;
|
|
140
|
-
} else {
|
|
141
|
-
resultStyles[targetElementResultKey][currentStyleAttribute] = value;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
return resultStyles;
|
|
147
|
-
}, [currentDevice, props.display]); // "props" object maybe big and frequently changing
|
|
148
|
-
|
|
149
|
-
return collectedStyles;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
exports._objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
|
|
153
|
-
exports.useStyles = useStyles;
|