@widergy/energy-ui 3.18.0 → 3.18.2

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [3.18.2](https://github.com/widergy/energy-ui/compare/v3.18.1...v3.18.2) (2024-08-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * minor fix ([#481](https://github.com/widergy/energy-ui/issues/481)) ([a5d456e](https://github.com/widergy/energy-ui/commit/a5d456e9b89148c03126f1437c432da098457b19))
7
+
8
+ ## [3.18.1](https://github.com/widergy/energy-ui/compare/v3.18.0...v3.18.1) (2024-08-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add counter ([#480](https://github.com/widergy/energy-ui/issues/480)) ([7d2d122](https://github.com/widergy/energy-ui/commit/7d2d12228d53af2937c0258756037329ba32714d))
14
+
1
15
  # [3.18.0](https://github.com/widergy/energy-ui/compare/v3.17.1...v3.18.0) (2024-08-26)
2
16
 
3
17
 
@@ -3,16 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DEFAULT_PROPS = exports.COLORS_MAPPER = void 0;
7
- const COLORS_MAPPER = exports.COLORS_MAPPER = {
8
- alert: 'error',
9
- identity: 'accent',
10
- identitySecondary: 'neutral',
11
- information: 'information',
12
- negative: 'negative',
13
- success: 'success',
14
- warning: 'warning'
15
- };
6
+ exports.DEFAULT_PROPS = void 0;
16
7
  const DEFAULT_PROPS = exports.DEFAULT_PROPS = {
17
- colorTheme: 'alert'
8
+ colorTheme: 'error'
18
9
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = require("prop-types");
9
+ var _Palette = require("../../constants/Palette");
9
10
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
10
11
  var _WithTheme = _interopRequireDefault(require("../WithTheme"));
11
12
  var _theme = require("./theme");
@@ -19,7 +20,7 @@ const UTBadge = _ref => {
19
20
  className,
20
21
  colorTheme
21
22
  } = _ref;
22
- const textColorTheme = colorTheme === 'negative' ? 'dark' : 'negative';
23
+ const textColorTheme = [_Palette.COLOR_THEMES.negative, _Palette.COLOR_THEMES.light].includes(colorTheme) ? 'dark' : 'negative';
23
24
  const Component = children ? _UTLabel.default : 'span';
24
25
  const componentProps = children ? {
25
26
  colorTheme: textColorTheme,
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.variantsColorTheme = exports.retrieveStyle = void 0;
7
+ var _componentUtils = require("../../utils/componentUtils");
7
8
  var _constants = require("./constants");
8
9
  const variantsColorTheme = (theme, colorTheme) => {
9
- const colorName = _constants.COLORS_MAPPER[colorTheme] || _constants.COLORS_MAPPER[_constants.DEFAULT_PROPS.colorTheme];
10
- const paletteTheme = theme.Palette[colorName] || theme.Palette.actions?.[colorName];
11
- const backgroundColorMapper = {
12
- alert: paletteTheme['04'],
13
- information: paletteTheme['05'],
14
- warning: paletteTheme['05'],
15
- success: paletteTheme['05'],
16
- identity: paletteTheme['05'],
17
- identitySecondary: paletteTheme['05'],
18
- negative: paletteTheme['04']
19
- };
10
+ const colorThemeDefinition = theme.Palette[colorTheme] || theme.Palette.actions?.[colorTheme] || theme.Palette[_constants.DEFAULT_PROPS.colorTheme];
11
+ const colorShade = (0, _componentUtils.getDefaultColorShade)(colorTheme);
20
12
  return {
21
- backgroundColor: backgroundColorMapper[colorTheme]
13
+ backgroundColor: colorThemeDefinition[colorShade]
22
14
  };
23
15
  };
24
16
  exports.variantsColorTheme = variantsColorTheme;
@@ -29,7 +21,6 @@ const baseButtonTheme = () => ({
29
21
  display: 'inline-flex',
30
22
  height: 'fit-content',
31
23
  justifyContent: 'center',
32
- margin: 10,
33
24
  minHeight: '10px',
34
25
  minWidth: '10px',
35
26
  verticalAlign: 'middle'
@@ -8,7 +8,9 @@ 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 = require("../../utils/componentUtils");
11
12
  var _classesUtils = require("../../utils/classesUtils");
13
+ var _UTBadge = _interopRequireDefault(require("../UTBadge"));
12
14
  var _WithTheme = _interopRequireDefault(require("../WithTheme"));
13
15
  var _constants = require("./constants");
14
16
  var _theme = require("./theme");
@@ -23,6 +25,7 @@ const UTButton = _ref => {
23
25
  classes: theme,
24
26
  classNames,
25
27
  colorTheme,
28
+ count,
26
29
  dataTestId,
27
30
  disabled,
28
31
  hideTextOnResponsive,
@@ -54,16 +57,21 @@ const UTButton = _ref => {
54
57
  variant
55
58
  }), [colorTheme, children, hideTextOnResponsive, icon, Icon, size, variant]);
56
59
  const IconToShow = IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, iconProps);
60
+ const counterColorTheme = (0, _utils.getCounterColorTheme)(colorTheme, variant);
57
61
  const RenderedChildren = /*#__PURE__*/_react.default.createElement("div", {
58
- className: `
59
- ${childrenContainer}
60
- ${_stylesModule.default.childrenContainer}
61
- `
62
- }, iconPlacement === _constants.ICON_PLACEMENTS.left && IconToShow, children !== null && children !== undefined && children !== false && /*#__PURE__*/_react.default.createElement("div", {
63
- className: `${_stylesModule.default.text} ${hideTextOnResponsive && _stylesModule.default.hideTextOnResponsive} ${classes.text}`
62
+ className: `${childrenContainer} ${_stylesModule.default.childrenContainer}`
63
+ }, count && /*#__PURE__*/_react.default.createElement(_UTBadge.default, {
64
+ colorTheme: counterColorTheme
65
+ }, count), iconPlacement === _constants.ICON_PLACEMENTS.left && IconToShow, children !== null && children !== undefined && children !== false && /*#__PURE__*/_react.default.createElement("div", {
66
+ className: `${_stylesModule.default.textContainer} ${classes.text}`
64
67
  }, children), iconPlacement !== _constants.ICON_PLACEMENTS.left && IconToShow);
65
68
  return /*#__PURE__*/_react.default.createElement(_Button.default, {
66
69
  classes: materialButtonClasses,
70
+ className: `
71
+ ${_stylesModule.default[`padding${(0, _componentUtils.capitalize)(size)}`]}
72
+ ${hideTextOnResponsive && _stylesModule.default.hideTextOnResponsive}
73
+ ${!hideTextOnResponsive && !children && _stylesModule.default.noChildren}
74
+ `,
67
75
  "data-testid": dataTestId,
68
76
  disabled: disabled || loading,
69
77
  onClick: onClick,
@@ -80,6 +88,7 @@ UTButton.propTypes = {
80
88
  classes: (0, _propTypes.objectOf)(_propTypes.string),
81
89
  classNames: (0, _propTypes.objectOf)(_propTypes.string),
82
90
  colorTheme: _propTypes.string,
91
+ count: _propTypes.number,
83
92
  dataTestId: _propTypes.string,
84
93
  disabled: _propTypes.bool,
85
94
  hideTextOnResponsive: _propTypes.bool,
@@ -3,26 +3,6 @@
3
3
  $big-icon: 1.5rem;
4
4
  $small-icon: 1.25rem;
5
5
 
6
- .hideTextOnResponsive {
7
- @media #{$mobile} {
8
- display: none;
9
- }
10
- }
11
-
12
- .text {
13
- .baseIcon + &,
14
- & + .baseIcon {
15
- margin-left: 8px;
16
-
17
- &.adaptableIconMedium,
18
- &.adaptableIconLarge {
19
- @media #{$mobile} {
20
- margin-left: -4px;
21
- }
22
- }
23
- }
24
- }
25
-
26
6
  .baseIcon {
27
7
  box-sizing: border-box;
28
8
  flex-shrink: 0;
@@ -40,26 +20,14 @@ $small-icon: 1.25rem;
40
20
  .iconOnlyMedium {
41
21
  font-size: $big-icon;
42
22
  height: $big-icon;
43
- margin: -1px -5px;
44
23
  width: $big-icon;
45
24
  }
46
25
 
47
- .iconOnlySmall {
48
- margin: -1px -5px;
49
- }
50
-
51
- .adaptableIconSmall {
52
- @media #{$mobile} {
53
- margin: -1px -5px;
54
- }
55
- }
56
-
57
26
  .adaptableIconLarge,
58
27
  .adaptableIconMedium {
59
28
  @media #{$mobile} {
60
29
  font-size: $big-icon;
61
30
  height: $big-icon;
62
- margin: -1px -5px;
63
31
  width: $big-icon;
64
32
  }
65
33
  }
@@ -67,9 +35,62 @@ $small-icon: 1.25rem;
67
35
  .childrenContainer {
68
36
  align-items: center;
69
37
  display: flex;
38
+ grid-gap: 8px;
70
39
  justify-content: flex-start;
71
40
  }
72
41
 
73
42
  .loading {
74
43
  position: absolute;
75
44
  }
45
+
46
+ .paddingLarge {
47
+ padding: 12px 16px;
48
+ }
49
+
50
+ .paddingMedium {
51
+ padding: 8px 12px;
52
+ }
53
+
54
+ .paddingSmall {
55
+ padding: 4px 8px;
56
+ }
57
+
58
+ .hideTextOnResponsive {
59
+ .textContainer {
60
+ @media #{$mobile} {
61
+ display: none;
62
+ }
63
+ }
64
+
65
+ &.paddingLarge {
66
+ @media #{$mobile} {
67
+ padding: 12px;
68
+ }
69
+ }
70
+
71
+ &.paddingMedium {
72
+ @media #{$mobile} {
73
+ padding: 8px;
74
+ }
75
+ }
76
+
77
+ &.paddingSmall {
78
+ @media #{$mobile} {
79
+ padding: 4px;
80
+ }
81
+ }
82
+ }
83
+
84
+ .noChildren {
85
+ &.paddingLarge {
86
+ padding: 12px;
87
+ }
88
+
89
+ &.paddingMedium {
90
+ padding: 8px;
91
+ }
92
+
93
+ &.paddingSmall {
94
+ padding: 4px;
95
+ }
96
+ }
@@ -135,19 +135,16 @@ const baseButtonTheme = theme => ({
135
135
  fontWeight: '500',
136
136
  lineHeight: '1.375rem',
137
137
  minWidth: 'auto',
138
- padding: '8px 12px',
139
138
  textTransform: 'none',
140
139
  transition: 'background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms'
141
140
  },
142
141
  sizeLarge: {
143
142
  fontSize: '1rem',
144
- fontWeight: '500',
145
- padding: '12px 16px'
143
+ fontWeight: '500'
146
144
  },
147
145
  sizeSmall: {
148
146
  fontSize: '0.875rem',
149
- fontWeight: '500',
150
- padding: '4px 8px'
147
+ fontWeight: '500'
151
148
  },
152
149
  circularProgress: {
153
150
  color: theme.UTButton?.circularProgress?.color || '484848'
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getIconProps = void 0;
6
+ exports.getIconProps = exports.getCounterColorTheme = void 0;
7
7
  var _Palette = require("../../constants/Palette");
8
8
  var _componentUtils = require("../../utils/componentUtils");
9
9
  var _UTIcon = _interopRequireDefault(require("../UTIcon"));
@@ -36,4 +36,6 @@ const getIconProps = _ref => {
36
36
  } : {})
37
37
  };
38
38
  };
39
- exports.getIconProps = getIconProps;
39
+ exports.getIconProps = getIconProps;
40
+ const getCounterColorTheme = (colorTheme, variant) => variant === _constants.VARIANTS_NAMES.filled ? colorTheme === _Palette.COLOR_THEMES.negative ? 'dark' : 'negative' : _constants.COLORS_MAPPER[colorTheme];
41
+ exports.getCounterColorTheme = getCounterColorTheme;
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.retrieveColor = exports.getIconProps = void 0;
7
- var _Palette = require("../../constants/Palette");
7
+ var _componentUtils = require("../../utils/componentUtils");
8
8
  var _constants = require("./constants");
9
- const getDefaultColorShade = colorTheme => colorTheme === _Palette.COLOR_THEMES.gray ? _Palette.COLOR_SHADES.shade04 : colorTheme === _Palette.COLOR_THEMES.light ? _Palette.COLOR_SHADES.shade01 : _Palette.COLOR_SHADES.shade05;
10
9
  const retrieveColor = _ref => {
11
10
  let {
12
11
  colorTheme,
@@ -14,7 +13,7 @@ const retrieveColor = _ref => {
14
13
  theme
15
14
  } = _ref;
16
15
  const colorThemeDefinition = theme.Palette[colorTheme] || theme.Palette.actions?.[colorTheme] || theme.Palette[_constants.DEFAULT_COLOR_THEME];
17
- const colorShade = shade || getDefaultColorShade(colorTheme);
16
+ const colorShade = shade || (0, _componentUtils.getDefaultColorShade)(colorTheme);
18
17
  return colorThemeDefinition[colorShade];
19
18
  };
20
19
  exports.retrieveColor = retrieveColor;
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.retrieveStyle = void 0;
7
- var _colorsModule = _interopRequireDefault(require("../../scss/variables/colors.module.scss"));
8
7
  var _Palette = require("../../constants/Palette");
8
+ var _componentUtils = require("../../utils/componentUtils");
9
+ var _colorsModule = _interopRequireDefault(require("../../scss/variables/colors.module.scss"));
9
10
  var _constants = require("./constants");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const getDefaultColorShade = colorTheme => colorTheme === _Palette.COLOR_THEMES.gray ? _Palette.COLOR_SHADES.shade04 : colorTheme === _Palette.COLOR_THEMES.light ? _Palette.COLOR_SHADES.shade01 : _Palette.COLOR_SHADES.shade05;
12
12
  const variantsColorTheme = (colorTheme, shade, theme) => {
13
13
  const colorThemeDefinition = theme.Palette[colorTheme] || theme.Palette.actions?.[colorTheme] || theme.Palette[_constants.DEFAULT_PROPS.colorTheme];
14
- const colorShade = Object.values(_Palette.COLOR_SHADES).includes(shade) ? shade : getDefaultColorShade(colorTheme);
14
+ const colorShade = Object.values(_Palette.COLOR_SHADES).includes(shade) ? shade : (0, _componentUtils.getDefaultColorShade)(colorTheme);
15
15
  return colorThemeDefinition[colorShade] || _colorsModule.default.black;
16
16
  };
17
17
  const linkColor = (theme, colorTheme) => {
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isUTIcon = exports.default = exports.capitalize = void 0;
6
+ exports.isUTIcon = exports.getDefaultColorShade = exports.default = exports.capitalize = void 0;
7
+ var _Palette = require("../constants/Palette");
7
8
  const A_CHAR_CODE = 65;
8
9
  const Z_CHAR_CODE = 90;
9
10
  const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
@@ -18,6 +19,8 @@ const getAvatarColors = (userName, colors) => {
18
19
  const getFirstLetter = userName => userName?.trim().slice(0, 1).toUpperCase() || 'A';
19
20
  const isUTIcon = icon => typeof icon === 'string';
20
21
  exports.isUTIcon = isUTIcon;
22
+ const getDefaultColorShade = colorTheme => colorTheme === _Palette.COLOR_THEMES.gray ? _Palette.COLOR_SHADES.shade04 : colorTheme === _Palette.COLOR_THEMES.light ? _Palette.COLOR_SHADES.shade01 : _Palette.COLOR_SHADES.shade05;
23
+ exports.getDefaultColorShade = getDefaultColorShade;
21
24
  var _default = exports.default = {
22
25
  capitalize,
23
26
  getAvatarColors,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.18.0",
3
+ "version": "3.18.2",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",