@widergy/energy-ui 3.16.3 → 3.16.4
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/CHANGELOG.md +7 -0
- package/dist/components/UTButton/constants.js +12 -5
- package/dist/components/UTButton/index.js +16 -17
- package/dist/components/UTButton/styles.module.scss +21 -6
- package/dist/components/UTButton/theme.js +5 -5
- package/dist/components/UTButton/utils.js +39 -0
- package/dist/components/UTIcon/theme.js +7 -2
- package/dist/components/UTModal/index.js +6 -5
- package/dist/utils/componentUtils.js +7 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.16.4](https://github.com/widergy/energy-ui/compare/v3.16.3...v3.16.4) (2024-08-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* button color & icon ([#476](https://github.com/widergy/energy-ui/issues/476)) ([887a843](https://github.com/widergy/energy-ui/commit/887a843d9cbf077a94b9c5a326409d6956edc9e6))
|
|
7
|
+
|
|
1
8
|
## [3.16.3](https://github.com/widergy/energy-ui/compare/v3.16.2...v3.16.3) (2024-08-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -3,15 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VARIANTS = exports.SIZES = exports.SHADOW_MAPPER = exports.ICON_PLACEMENTS = exports.DEFAULT_PROPS = exports.COLORS_MAPPER = void 0;
|
|
6
|
+
exports.VARIANTS_NAMES = exports.VARIANTS = exports.SIZES = exports.SHADOW_MAPPER = exports.ICON_PLACEMENTS = exports.DEFAULT_PROPS = exports.COLORS_MAPPER = void 0;
|
|
7
7
|
var _Palette = require("../../constants/Palette");
|
|
8
|
-
const
|
|
9
|
-
filled: '
|
|
8
|
+
const VARIANTS_NAMES = exports.VARIANTS_NAMES = {
|
|
9
|
+
filled: 'filled',
|
|
10
10
|
outlined: 'outlined',
|
|
11
|
-
semitransparent: '
|
|
12
|
-
shadow: '
|
|
11
|
+
semitransparent: 'semitransparent',
|
|
12
|
+
shadow: 'shadow',
|
|
13
13
|
text: 'text'
|
|
14
14
|
};
|
|
15
|
+
const VARIANTS = exports.VARIANTS = {
|
|
16
|
+
[VARIANTS_NAMES.filled]: 'contained',
|
|
17
|
+
[VARIANTS_NAMES.outlined]: 'outlined',
|
|
18
|
+
[VARIANTS_NAMES.semitransparent]: 'contained',
|
|
19
|
+
[VARIANTS_NAMES.shadow]: 'text',
|
|
20
|
+
[VARIANTS_NAMES.text]: 'text'
|
|
21
|
+
};
|
|
15
22
|
const SIZES = exports.SIZES = {
|
|
16
23
|
small: 'small',
|
|
17
24
|
medium: 'medium',
|
|
@@ -8,12 +8,11 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
9
9
|
var _CircularProgress = _interopRequireDefault(require("@material-ui/core/CircularProgress"));
|
|
10
10
|
var _propTypes = require("prop-types");
|
|
11
|
-
var _componentUtils = _interopRequireDefault(require("../../utils/componentUtils"));
|
|
12
11
|
var _classesUtils = require("../../utils/classesUtils");
|
|
13
12
|
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
14
|
-
var _UTIcon = _interopRequireDefault(require("../UTIcon"));
|
|
15
13
|
var _constants = require("./constants");
|
|
16
14
|
var _theme = require("./theme");
|
|
15
|
+
var _utils = require("./utils");
|
|
17
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
18
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -23,6 +22,7 @@ const UTButton = _ref => {
|
|
|
23
22
|
children,
|
|
24
23
|
classes: theme,
|
|
25
24
|
classNames,
|
|
25
|
+
colorTheme,
|
|
26
26
|
dataTestId,
|
|
27
27
|
disabled,
|
|
28
28
|
hideTextOnResponsive,
|
|
@@ -34,9 +34,6 @@ const UTButton = _ref => {
|
|
|
34
34
|
type,
|
|
35
35
|
variant
|
|
36
36
|
} = _ref;
|
|
37
|
-
const {
|
|
38
|
-
isUTIcon
|
|
39
|
-
} = _componentUtils.default;
|
|
40
37
|
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(theme, classNames), [classNames, theme]);
|
|
41
38
|
const {
|
|
42
39
|
childrenContainer,
|
|
@@ -44,18 +41,19 @@ const UTButton = _ref => {
|
|
|
44
41
|
icon,
|
|
45
42
|
...materialButtonClasses
|
|
46
43
|
} = classes;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}));
|
|
44
|
+
const {
|
|
45
|
+
IconComponent,
|
|
46
|
+
...iconProps
|
|
47
|
+
} = (0, _react.useMemo)(() => (0, _utils.getIconProps)({
|
|
48
|
+
className: icon,
|
|
49
|
+
colorTheme,
|
|
50
|
+
hasContent: !!children,
|
|
51
|
+
hideTextOnResponsive,
|
|
52
|
+
Icon,
|
|
53
|
+
size,
|
|
54
|
+
variant
|
|
55
|
+
}), [colorTheme, children, hideTextOnResponsive, icon, Icon, size, variant]);
|
|
56
|
+
const IconToShow = IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, iconProps);
|
|
59
57
|
const RenderedChildren = /*#__PURE__*/_react.default.createElement("div", {
|
|
60
58
|
className: `
|
|
61
59
|
${childrenContainer}
|
|
@@ -81,6 +79,7 @@ UTButton.defaultProps = _constants.DEFAULT_PROPS;
|
|
|
81
79
|
UTButton.propTypes = {
|
|
82
80
|
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
83
81
|
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
82
|
+
colorTheme: _propTypes.string,
|
|
84
83
|
dataTestId: _propTypes.string,
|
|
85
84
|
disabled: _propTypes.bool,
|
|
86
85
|
hideTextOnResponsive: _propTypes.bool,
|
|
@@ -14,7 +14,8 @@ $small-icon: 1.25rem;
|
|
|
14
14
|
& + .baseIcon {
|
|
15
15
|
margin-left: 8px;
|
|
16
16
|
|
|
17
|
-
&.
|
|
17
|
+
&.adaptableIconMedium,
|
|
18
|
+
&.adaptableIconLarge {
|
|
18
19
|
@media #{$mobile} {
|
|
19
20
|
margin-left: -4px;
|
|
20
21
|
}
|
|
@@ -27,24 +28,38 @@ $small-icon: 1.25rem;
|
|
|
27
28
|
flex-shrink: 0;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
.icon
|
|
31
|
+
.icon,
|
|
32
|
+
.iconOnlySmall,
|
|
33
|
+
.adaptableIconSmall {
|
|
31
34
|
font-size: $small-icon;
|
|
32
35
|
height: $small-icon;
|
|
33
36
|
width: $small-icon;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
.
|
|
39
|
+
.iconOnlyLarge,
|
|
40
|
+
.iconOnlyMedium {
|
|
37
41
|
font-size: $big-icon;
|
|
38
42
|
height: $big-icon;
|
|
39
|
-
margin:
|
|
43
|
+
margin: -1px -5px;
|
|
40
44
|
width: $big-icon;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
.
|
|
47
|
+
.iconOnlySmall {
|
|
48
|
+
margin: -1px -5px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.adaptableIconSmall {
|
|
52
|
+
@media #{$mobile} {
|
|
53
|
+
margin: -1px -5px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.adaptableIconLarge,
|
|
58
|
+
.adaptableIconMedium {
|
|
44
59
|
@media #{$mobile} {
|
|
45
60
|
font-size: $big-icon;
|
|
46
61
|
height: $big-icon;
|
|
47
|
-
margin:
|
|
62
|
+
margin: -1px -5px;
|
|
48
63
|
width: $big-icon;
|
|
49
64
|
}
|
|
50
65
|
}
|
|
@@ -15,7 +15,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
15
15
|
const negativeTheme = actionPaletteColors[_constants.COLORS_MAPPER.negative];
|
|
16
16
|
const neutralTheme = actionPaletteColors[_constants.COLORS_MAPPER.secondary];
|
|
17
17
|
const definition = {
|
|
18
|
-
filled: {
|
|
18
|
+
[_constants.VARIANTS_NAMES.filled]: {
|
|
19
19
|
backgroundColor: actionTheme['04'],
|
|
20
20
|
border: '1px solid transparent',
|
|
21
21
|
color: colorTheme === _constants.COLORS_MAPPER.negative ? neutralTheme['05'] : negativeTheme['05'],
|
|
@@ -40,7 +40,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
40
40
|
opacity: (0, _classesUtils.withImportant)(0.5)
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
semitransparent: {
|
|
43
|
+
[_constants.VARIANTS_NAMES.semitransparent]: {
|
|
44
44
|
backgroundColor: actionTheme['01'],
|
|
45
45
|
border: '1px solid transparent',
|
|
46
46
|
color: actionTheme['05'],
|
|
@@ -59,7 +59,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
59
59
|
opacity: (0, _classesUtils.withImportant)(0.5)
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
outlined: {
|
|
62
|
+
[_constants.VARIANTS_NAMES.outlined]: {
|
|
63
63
|
border: `1px solid ${actionTheme['05']}`,
|
|
64
64
|
color: actionTheme['05'],
|
|
65
65
|
fill: actionTheme['05'],
|
|
@@ -77,7 +77,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
77
77
|
opacity: (0, _classesUtils.withImportant)(0.5)
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
text: {
|
|
80
|
+
[_constants.VARIANTS_NAMES.text]: {
|
|
81
81
|
border: '1px solid transparent',
|
|
82
82
|
color: actionTheme['05'],
|
|
83
83
|
fill: actionTheme['05'],
|
|
@@ -94,7 +94,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
94
94
|
opacity: (0, _classesUtils.withImportant)(0.5)
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
shadow: {
|
|
97
|
+
[_constants.VARIANTS_NAMES.shadow]: {
|
|
98
98
|
backgroundColor: colorTheme === _constants.COLORS_MAPPER.negative ? neutralTheme['05'] : negativeTheme['05'],
|
|
99
99
|
boxShadow: (0, _shadowUtils.getShadow)({
|
|
100
100
|
color: shadowTheme,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getIconProps = void 0;
|
|
7
|
+
var _Palette = require("../../constants/Palette");
|
|
8
|
+
var _componentUtils = require("../../utils/componentUtils");
|
|
9
|
+
var _UTIcon = _interopRequireDefault(require("../UTIcon"));
|
|
10
|
+
var _constants = require("./constants");
|
|
11
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const getIconProps = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
className,
|
|
16
|
+
colorTheme,
|
|
17
|
+
hasContent,
|
|
18
|
+
hideTextOnResponsive,
|
|
19
|
+
Icon,
|
|
20
|
+
size,
|
|
21
|
+
variant
|
|
22
|
+
} = _ref;
|
|
23
|
+
if (!Icon) return {};
|
|
24
|
+
const actionColorName = _constants.COLORS_MAPPER[colorTheme] || _constants.COLORS_MAPPER[_constants.DEFAULT_PROPS.colorTheme];
|
|
25
|
+
return {
|
|
26
|
+
IconComponent: _componentUtils.isUTIcon ? _UTIcon.default : Icon,
|
|
27
|
+
className: `
|
|
28
|
+
${_stylesModule.default.baseIcon}
|
|
29
|
+
${className}
|
|
30
|
+
${hasContent ? _stylesModule.default.icon : _stylesModule.default[`iconOnly${(0, _componentUtils.capitalize)(size)}`]}
|
|
31
|
+
${hideTextOnResponsive ? _stylesModule.default[`adaptableIcon${(0, _componentUtils.capitalize)(size)}`] : ''}
|
|
32
|
+
`,
|
|
33
|
+
...(_componentUtils.isUTIcon ? {
|
|
34
|
+
colorTheme: variant === _constants.VARIANTS_NAMES.filled ? actionColorName === _constants.COLORS_MAPPER.negative ? _Palette.COLOR_THEMES.neutral : _Palette.COLOR_THEMES.light : actionColorName,
|
|
35
|
+
name: Icon
|
|
36
|
+
} : {})
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.getIconProps = getIconProps;
|
|
@@ -43,16 +43,21 @@ const getIconProps = _ref2 => {
|
|
|
43
43
|
theme,
|
|
44
44
|
shade: fillShade || _constants.DEFAULT_INTERNAL_SHADE
|
|
45
45
|
});
|
|
46
|
+
const baseIconProps = {
|
|
47
|
+
flexShrink: 0
|
|
48
|
+
};
|
|
46
49
|
const defaultIconProps = {
|
|
47
50
|
color: iconColor,
|
|
48
|
-
size
|
|
51
|
+
size,
|
|
52
|
+
...baseIconProps
|
|
49
53
|
};
|
|
50
54
|
const energyIconProps = {
|
|
51
55
|
stroke: iconColor,
|
|
52
56
|
...(size && {
|
|
53
57
|
width: size,
|
|
54
58
|
height: size
|
|
55
|
-
})
|
|
59
|
+
}),
|
|
60
|
+
...baseIconProps
|
|
56
61
|
};
|
|
57
62
|
return {
|
|
58
63
|
style: filled ? {
|
|
@@ -7,10 +7,11 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
9
|
var _object = require("@widergy/web-utils/lib/object");
|
|
10
|
+
var _componentUtils = require("../../utils/componentUtils");
|
|
10
11
|
var _classesUtils = require("../../utils/classesUtils");
|
|
11
|
-
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
12
|
-
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
13
12
|
var _UTButton = _interopRequireDefault(require("../UTButton"));
|
|
13
|
+
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
14
|
+
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
14
15
|
var _theme = require("./theme");
|
|
15
16
|
var _constants = require("./constants");
|
|
16
17
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
@@ -44,13 +45,13 @@ const UTModal = _ref => {
|
|
|
44
45
|
const StatusIcon = _constants.STATUS_ICONS[status];
|
|
45
46
|
const withSecondaryActions = !(0, _object.objectIsEmpty)(secondaryAction) || SecondaryActionComponent;
|
|
46
47
|
return /*#__PURE__*/_react.default.createElement("dialog", {
|
|
47
|
-
className: `${_stylesModule.default.container} ${classes.container} ${size ? _stylesModule.default[`container${
|
|
48
|
+
className: `${_stylesModule.default.container} ${classes.container} ${size ? _stylesModule.default[`container${(0, _componentUtils.capitalize)(size)}`] : _stylesModule.default.containerM}`,
|
|
48
49
|
onClick: onClickDialog,
|
|
49
50
|
ref: dialogRef
|
|
50
51
|
}, /*#__PURE__*/_react.default.createElement("div", null, StatusIcon && /*#__PURE__*/_react.default.createElement("div", {
|
|
51
|
-
className: `${_stylesModule.default.status} ${classes[`status${
|
|
52
|
+
className: `${_stylesModule.default.status} ${classes[`status${(0, _componentUtils.capitalize)(status)}`]}`
|
|
52
53
|
}, /*#__PURE__*/_react.default.createElement(StatusIcon, {
|
|
53
|
-
className: `${_stylesModule.default.icon} ${classes[`icon${
|
|
54
|
+
className: `${_stylesModule.default.icon} ${classes[`icon${(0, _componentUtils.capitalize)(status)}`]}`
|
|
54
55
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
55
56
|
className: _stylesModule.default.header
|
|
56
57
|
}, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.isUTIcon = exports.default = exports.capitalize = void 0;
|
|
7
7
|
const A_CHAR_CODE = 65;
|
|
8
8
|
const Z_CHAR_CODE = 90;
|
|
9
|
-
const
|
|
9
|
+
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
10
|
+
exports.capitalize = capitalize;
|
|
10
11
|
const getAvatarColors = (userName, colors) => {
|
|
11
12
|
const hashIndex = userName?.split('').reduce((acum, _letter, index) => {
|
|
12
13
|
const letterCode = userName.toUpperCase().charCodeAt(index);
|
|
@@ -14,9 +15,12 @@ const getAvatarColors = (userName, colors) => {
|
|
|
14
15
|
}, 0) || 0;
|
|
15
16
|
return colors[hashIndex % colors.length];
|
|
16
17
|
};
|
|
18
|
+
const getFirstLetter = userName => userName?.trim().slice(0, 1).toUpperCase() || 'A';
|
|
17
19
|
const isUTIcon = icon => typeof icon === 'string';
|
|
20
|
+
exports.isUTIcon = isUTIcon;
|
|
18
21
|
var _default = exports.default = {
|
|
19
|
-
|
|
22
|
+
capitalize,
|
|
20
23
|
getAvatarColors,
|
|
24
|
+
getFirstLetter,
|
|
21
25
|
isUTIcon
|
|
22
26
|
};
|