@widergy/energy-ui 3.115.0 → 3.116.0

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,10 @@
1
+ # [3.116.0](https://github.com/widergy/energy-ui/compare/v3.115.0...v3.116.0) (2025-10-30)
2
+
3
+
4
+ ### Features
5
+
6
+ * [AXCH-830] add new props to utstatus ([#713](https://github.com/widergy/energy-ui/issues/713)) ([3bd7b6e](https://github.com/widergy/energy-ui/commit/3bd7b6e85b18e3cc1edfe70da6715b6c9b5e8119))
7
+
1
8
  # [3.115.0](https://github.com/widergy/energy-ui/compare/v3.114.1...v3.115.0) (2025-10-30)
2
9
 
3
10
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.WithoutIcon = exports.WithTooltip = exports.Default = exports.CustomIcon = exports.AllVariants = exports.AllTypes = exports.AllSizes = void 0;
6
+ exports.default = exports.WithoutIcon = exports.WithoutArea = exports.WithTooltip = exports.WithAdornments = exports.RoundedArea = exports.Default = exports.CustomIcon = exports.AllVariants = exports.AllTypes = exports.AllSizes = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _utils = require("stories/utils");
9
9
  var _constants = require("./constants");
@@ -153,6 +153,43 @@ var _default = exports.default = {
153
153
  summary: 'string'
154
154
  }
155
155
  }
156
+ },
157
+ adornments: {
158
+ control: 'object',
159
+ description: 'Array de adornos (badges e iconos) para mostrar junto al estado.',
160
+ table: {
161
+ defaultValue: {
162
+ summary: '[]'
163
+ },
164
+ type: {
165
+ summary: 'array'
166
+ }
167
+ }
168
+ },
169
+ area: {
170
+ control: 'boolean',
171
+ description: 'Determina si se debe mostrar el área de fondo del componente.',
172
+ table: {
173
+ defaultValue: {
174
+ summary: 'true'
175
+ },
176
+ type: {
177
+ summary: 'boolean'
178
+ }
179
+ }
180
+ },
181
+ areaType: {
182
+ control: 'select',
183
+ description: 'Determina el tipo de área a usar.',
184
+ options: Object.keys(_constants.AREA_TYPES),
185
+ table: {
186
+ defaultValue: {
187
+ summary: _constants.DEFAULT_PROPS.areaType
188
+ },
189
+ type: {
190
+ summary: (0, _utils.joinArgTypes)(Object.keys(_constants.AREA_TYPES))
191
+ }
192
+ }
156
193
  }
157
194
  },
158
195
  component: _.default,
@@ -172,7 +209,9 @@ const Default = exports.Default = {
172
209
  size: _constants.DEFAULT_PROPS.size,
173
210
  type: _constants.DEFAULT_PROPS.type,
174
211
  variant: _constants.DEFAULT_PROPS.variant,
175
- withoutIcon: _constants.DEFAULT_PROPS.withoutIcon
212
+ withoutIcon: _constants.DEFAULT_PROPS.withoutIcon,
213
+ area: _constants.DEFAULT_PROPS.area,
214
+ areaType: _constants.DEFAULT_PROPS.areaType
176
215
  },
177
216
  name: 'Playground'
178
217
  };
@@ -299,4 +338,54 @@ const CustomIcon = exports.CustomIcon = {
299
338
  }
300
339
  }
301
340
  }
341
+ };
342
+ const WithAdornments = exports.WithAdornments = {
343
+ args: {
344
+ children: 'Estado con adornos',
345
+ variant: 'success',
346
+ adornments: [{
347
+ name: 'Badge',
348
+ props: {
349
+ variant: 'information'
350
+ }
351
+ }]
352
+ },
353
+ name: 'Con Adornos',
354
+ parameters: {
355
+ docs: {
356
+ description: {
357
+ story: 'Ejemplo del componente UTStatus con adornos (badges e iconos) adicionales.'
358
+ }
359
+ }
360
+ }
361
+ };
362
+ const WithoutArea = exports.WithoutArea = {
363
+ args: {
364
+ children: 'Estado sin área',
365
+ variant: 'warning',
366
+ area: false
367
+ },
368
+ name: 'Sin Área',
369
+ parameters: {
370
+ docs: {
371
+ description: {
372
+ story: 'Ejemplo del componente UTStatus sin el área de fondo, útil para integración en diseños más minimalistas.'
373
+ }
374
+ }
375
+ }
376
+ };
377
+ const RoundedArea = exports.RoundedArea = {
378
+ args: {
379
+ children: 'Área redondeada',
380
+ variant: 'success',
381
+ areaType: 'full'
382
+ },
383
+ name: 'Área Redondeada',
384
+ parameters: {
385
+ docs: {
386
+ description: {
387
+ story: 'Ejemplo del componente UTStatus con área completamente redondeada.'
388
+ }
389
+ }
390
+ }
302
391
  };
@@ -3,7 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VARIANTS = exports.TYPES = exports.SIZES = exports.ICON_SIZE = exports.DEFAULT_PROPS = void 0;
6
+ exports.VARIANTS = exports.TYPES = exports.SIZES = exports.ICON_SIZE = exports.DEFAULT_PROPS = exports.COMPONENT_KEYS = exports.COMPONENTS_MAPPER = exports.AREA_TYPES = void 0;
7
+ var _UTBadge = _interopRequireDefault(require("../UTBadge"));
8
+ var _UTIcon = _interopRequireDefault(require("../UTIcon"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
10
  const ICON_SIZE = exports.ICON_SIZE = 20;
8
11
  const SIZES = exports.SIZES = {
9
12
  large: 'large',
@@ -23,9 +26,22 @@ const TYPES = exports.TYPES = {
23
26
  light: 'light',
24
27
  negative: 'negative'
25
28
  };
29
+ const AREA_TYPES = exports.AREA_TYPES = {
30
+ SQUARE: 'SQUARE',
31
+ ROUNDED: 'ROUNDED'
32
+ };
26
33
  const DEFAULT_PROPS = exports.DEFAULT_PROPS = {
34
+ areaType: AREA_TYPES.SQUARE,
27
35
  size: 'medium',
28
36
  type: 'default',
29
37
  variant: 'success',
30
38
  withoutIcon: false
39
+ };
40
+ const COMPONENT_KEYS = exports.COMPONENT_KEYS = {
41
+ BADGE: 'Badge',
42
+ ICON: 'Icon'
43
+ };
44
+ const COMPONENTS_MAPPER = exports.COMPONENTS_MAPPER = {
45
+ [COMPONENT_KEYS.BADGE]: _UTBadge.default,
46
+ [COMPONENT_KEYS.ICON]: _UTIcon.default
31
47
  };
@@ -16,10 +16,12 @@ var _constants = require("./constants");
16
16
  var _utils = require("./utils");
17
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
18
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
19
- /* eslint-disable react/no-children-prop */
20
-
19
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } /* eslint-disable react/no-children-prop */
21
20
  const UTStatus = _ref => {
22
21
  let {
22
+ adornments = [],
23
+ area = true,
24
+ areaType = _constants.DEFAULT_PROPS.areaType,
23
25
  children,
24
26
  classes,
25
27
  className,
@@ -29,11 +31,13 @@ const UTStatus = _ref => {
29
31
  title,
30
32
  tooltip,
31
33
  tooltipProps = {},
32
- type,
33
- variant,
34
+ type = _constants.DEFAULT_PROPS.type,
35
+ variant = _constants.DEFAULT_PROPS.variant,
34
36
  withoutIcon
35
37
  } = _ref;
36
38
  const StatusIcon = Icon !== null && Icon !== void 0 ? Icon : (0, _theme.defaultIconMapper)(variant);
39
+ const validAdornments = (0, _react.useMemo)(() => (0, _utils.validateAdornments)(adornments) ? adornments : [], [adornments]);
40
+ const useValidAdornments = validAdornments.length > 0;
37
41
  const {
38
42
  IconComponent,
39
43
  ...iconProps
@@ -45,15 +49,34 @@ const UTStatus = _ref => {
45
49
  size
46
50
  })), [StatusIcon, type, variant, classes.icon]);
47
51
  const showTooltip = !(0, _isEmpty.default)(tooltip);
52
+ const colorTheme = (0, _theme.getColorTheme)((0, _theme.validateProps)({
53
+ type,
54
+ variant
55
+ }));
56
+ const renderAdornment = (0, _react.useCallback)(adornment => {
57
+ const Component = _constants.COMPONENTS_MAPPER[adornment.name];
58
+ const themeProps = (0, _utils.getAdornmentsThemeProps)({
59
+ area,
60
+ classes,
61
+ size,
62
+ adornmentName: adornment.name
63
+ });
64
+ const adornmentProps = {
65
+ variant,
66
+ ...((adornment === null || adornment === void 0 ? void 0 : adornment.props) || {}),
67
+ ...themeProps
68
+ };
69
+ return Component ? /*#__PURE__*/_react.default.createElement(Component, _extends({}, adornmentProps, {
70
+ key: (adornment === null || adornment === void 0 ? void 0 : adornment.key) || adornment.name
71
+ })) : null;
72
+ }, []);
48
73
  const StatusRender = /*#__PURE__*/_react.default.createElement("div", {
49
- className: "".concat(classes.root, " ").concat(className || ''),
74
+ className: "".concat(classes.root, " ").concat(className || '', " ").concat(area ? '' : classes.withoutArea, " ").concat(areaType === _constants.AREA_TYPES.SQUARE ? '' : classes.roundedArea),
50
75
  title: title
51
- }, withoutIcon ? null : /*#__PURE__*/_react.default.createElement(IconComponent, iconProps), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
76
+ }, useValidAdornments && validAdornments.map(renderAdornment), withoutIcon || useValidAdornments ? null : /*#__PURE__*/_react.default.createElement(IconComponent, iconProps), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
52
77
  className: classes.label,
53
- colorTheme: (0, _theme.getColorTheme)((0, _theme.validateProps)({
54
- type,
55
- variant
56
- })),
78
+ colorTheme: colorTheme,
79
+ shade: type !== _constants.TYPES.negative ? '05' : undefined,
57
80
  dataTestId: labelDataTestId,
58
81
  variant: (0, _theme.getLabelVariant)({
59
82
  size
@@ -72,6 +95,9 @@ const UTStatus = _ref => {
72
95
  };
73
96
  UTStatus.defaultProps = _constants.DEFAULT_PROPS;
74
97
  UTStatus.propTypes = {
98
+ adornments: (0, _propTypes.arrayOf)(_propTypes.object),
99
+ area: _propTypes.bool,
100
+ areaType: _propTypes.string,
75
101
  classes: (0, _propTypes.objectOf)(_propTypes.string),
76
102
  className: _propTypes.string,
77
103
  Icon: _propTypes.elementType,
@@ -84,9 +84,9 @@ const retrieveStyle = _ref7 => {
84
84
  let {
85
85
  theme,
86
86
  size = _constants.DEFAULT_PROPS.size,
87
- type,
87
+ type = _constants.DEFAULT_PROPS.type,
88
88
  uppercase,
89
- variant
89
+ variant = _constants.DEFAULT_PROPS.variant
90
90
  } = _ref7;
91
91
  return {
92
92
  root: {
@@ -128,6 +128,51 @@ const retrieveStyle = _ref7 => {
128
128
  })
129
129
  })
130
130
  }
131
+ },
132
+ badge: {
133
+ backgroundColor: type === _constants.TYPES.negative ? "".concat(theme.Palette[variant !== _constants.VARIANTS.unassigned ? variant : _Palette.COLOR_THEMES.gray]['03'], " !important") : "".concat(theme.Palette[variant !== _constants.VARIANTS.unassigned ? variant : _Palette.COLOR_THEMES.gray]['04'], " !important")
134
+ },
135
+ adornmentIcon: {
136
+ flexShrink: '0',
137
+ '& path': {
138
+ stroke: getIconFill({
139
+ theme,
140
+ ...validateProps({
141
+ type,
142
+ variant
143
+ })
144
+ })
145
+ }
146
+ },
147
+ iconSmall: {
148
+ height: '14px',
149
+ width: '14px'
150
+ },
151
+ iconMedium: {
152
+ height: '16px',
153
+ width: '16px'
154
+ },
155
+ iconLarge: {
156
+ height: '20px',
157
+ width: '20px'
158
+ },
159
+ badgeSmall: {
160
+ height: '8px',
161
+ width: '8px'
162
+ },
163
+ badgeMedium: {
164
+ height: '10px',
165
+ width: '10px'
166
+ },
167
+ badgeLarge: {
168
+ height: '10px',
169
+ width: '10px'
170
+ },
171
+ withoutArea: {
172
+ backgroundColor: 'transparent !important'
173
+ },
174
+ roundedArea: {
175
+ borderRadius: '100px'
131
176
  }
132
177
  };
133
178
  };
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getIconProps = void 0;
6
+ exports.validateAdornments = exports.getIconProps = exports.getAdornmentsThemeProps = void 0;
7
7
  var _componentUtils = require("../../utils/componentUtils");
8
8
  var _UTIcon = _interopRequireDefault(require("../UTIcon"));
9
+ var _constants = require("./constants");
9
10
  var _theme = require("./theme");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
12
  const getIconProps = _ref => {
@@ -32,4 +33,49 @@ const getIconProps = _ref => {
32
33
  })
33
34
  };
34
35
  };
35
- exports.getIconProps = getIconProps;
36
+ exports.getIconProps = getIconProps;
37
+ const validateAdornments = adornments => adornments.every(adornment => _constants.COMPONENTS_MAPPER[adornment.name]);
38
+ exports.validateAdornments = validateAdornments;
39
+ const interpreterSize = (size, classes) => {
40
+ const {
41
+ iconSmall,
42
+ iconMedium,
43
+ iconLarge,
44
+ badgeSmall,
45
+ badgeMedium,
46
+ badgeLarge
47
+ } = classes || {};
48
+ return {
49
+ [_constants.COMPONENT_KEYS.BADGE]: {
50
+ [_constants.SIZES.small]: badgeSmall,
51
+ [_constants.SIZES.medium]: badgeMedium,
52
+ [_constants.SIZES.large]: badgeLarge
53
+ }[size],
54
+ [_constants.COMPONENT_KEYS.ICON]: {
55
+ [_constants.SIZES.small]: iconSmall,
56
+ [_constants.SIZES.medium]: iconMedium,
57
+ [_constants.SIZES.large]: iconLarge
58
+ }[size]
59
+ };
60
+ };
61
+ const getAdornmentsThemeProps = props => {
62
+ const {
63
+ adornmentName,
64
+ classes,
65
+ size = _constants.SIZES.medium
66
+ } = props || {};
67
+ const {
68
+ badge,
69
+ adornmentIcon
70
+ } = classes || {};
71
+ const recoverClassForSizeAndType = interpreterSize(size, classes)[adornmentName];
72
+ return {
73
+ [_constants.COMPONENT_KEYS.BADGE]: {
74
+ className: "".concat(badge, " ").concat(recoverClassForSizeAndType)
75
+ },
76
+ [_constants.COMPONENT_KEYS.ICON]: {
77
+ className: "".concat(adornmentIcon, " ").concat(recoverClassForSizeAndType)
78
+ }
79
+ }[adornmentName];
80
+ };
81
+ exports.getAdornmentsThemeProps = getAdornmentsThemeProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.115.0",
3
+ "version": "3.116.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",