@widergy/energy-ui 3.69.7 → 3.71.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,17 @@
1
+ # [3.71.0](https://github.com/widergy/energy-ui/compare/v3.70.0...v3.71.0) (2025-05-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * add hide amount ([#605](https://github.com/widergy/energy-ui/issues/605)) ([cd7a226](https://github.com/widergy/energy-ui/commit/cd7a22622e0f7b5c924f9190b2f500fb5e567747))
7
+
8
+ # [3.70.0](https://github.com/widergy/energy-ui/compare/v3.69.7...v3.70.0) (2025-05-05)
9
+
10
+
11
+ ### Features
12
+
13
+ * add helpText and change error to ut validations ([#607](https://github.com/widergy/energy-ui/issues/607)) ([bea2a56](https://github.com/widergy/energy-ui/commit/bea2a56b82f6fdca3ded911e2e39556fce296a98))
14
+
1
15
  ## [3.69.7](https://github.com/widergy/energy-ui/compare/v3.69.6...v3.69.7) (2025-04-30)
2
16
 
3
17
 
@@ -0,0 +1,28 @@
1
+ # UTConsumptionBar
2
+
3
+ ## Description
4
+
5
+ `UTConsumptionBar` is a dynamic and customizable component designed to visually represent different consumption levels within a continuous bar. It allows users to easily identify their current consumption relative to predefined thresholds, including subsidy limits or critical consumption points.
6
+ This component is ideal for displaying energy usage, resource consumption, or similar progressive metrics in a clear and user-friendly way.
7
+
8
+ ## Props
9
+
10
+ | Name | Type | Default | Description |
11
+ | ------------- | -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12
+ | categoryLines | object | | Defines the segments or categories shown in the bar, including their labels. |
13
+ | classes | object | | Custom class names to apply to different elements of the `UTConsumptionBar`. |
14
+ | hideAmount | bool | | If `true`, hides the numeric total value (e.g., cost of consumption) displayed on the bar, while keeping the current consumption value and visual indicators visible. |
15
+ | values | arrayOf(shape) | false | Array of indicators or key values to be displayed on the bar. |
16
+ | |
17
+
18
+ ### Values Object
19
+
20
+ The `values` prop is an array of objects, each representing an indicator:
21
+
22
+ | Name | Type | Description |
23
+ | -------- | ------ | ------------------------------------------------------------ |
24
+ | position | string | Position or reference point of the indicator within the bar. |
25
+ | subtitle | string | A subtitle providing additional context for the indicator. |
26
+ | title | string | The main title describing the indicator. |
27
+ | total | number | The total value associated with this indicator. |
28
+ | value | number | The current value for this indicator. |
@@ -16,7 +16,8 @@ const ConsumptionBarIndicator = _ref => {
16
16
  value,
17
17
  unit = 'kWh',
18
18
  total,
19
- classes
19
+ classes,
20
+ hideAmount
20
21
  } = _ref;
21
22
  return /*#__PURE__*/_react.default.createElement("div", {
22
23
  className: _stylesModule.default.indicator,
@@ -31,7 +32,7 @@ const ConsumptionBarIndicator = _ref => {
31
32
  className: _stylesModule.default.alignCenter,
32
33
  colorTheme: "information",
33
34
  weight: "bold"
34
- }, "".concat(Math.round(value), " ").concat(unit)), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
35
+ }, "".concat(Math.round(value), " ").concat(unit)), !hideAmount && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
35
36
  className: _stylesModule.default.lightGray,
36
37
  colorTheme: "gray",
37
38
  weight: "bold"
@@ -39,9 +40,10 @@ const ConsumptionBarIndicator = _ref => {
39
40
  };
40
41
  ConsumptionBarIndicator.propTypes = {
41
42
  classes: _propTypes.object,
43
+ hideAmount: _propTypes.bool,
42
44
  left: _propTypes.number,
43
- value: _propTypes.number,
45
+ total: _propTypes.number,
44
46
  unit: _propTypes.string,
45
- total: _propTypes.number
47
+ value: _propTypes.number
46
48
  };
47
49
  var _default = exports.default = ConsumptionBarIndicator;
@@ -16,10 +16,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
16
16
  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); }
17
17
  const UTConsumptionBar = _ref => {
18
18
  let {
19
- small,
20
- values,
21
19
  categoryLines,
22
- classes
20
+ classes,
21
+ hideAmount = false,
22
+ values
23
23
  } = _ref;
24
24
  const widthRef = (0, _react.useRef)();
25
25
  const [showLabel, setShowLabel] = (0, _react.useState)(true);
@@ -92,9 +92,9 @@ const UTConsumptionBar = _ref => {
92
92
  })), categoryLines.rates.map(renderCategoryLines), downIndicators.map(indicator => /*#__PURE__*/_react.default.createElement(_ConsumptionBarIndicator.default, {
93
93
  classes: classes,
94
94
  className: _stylesModule.default.indicator,
95
+ hideAmount: hideAmount,
95
96
  key: indicator.title,
96
97
  left: getIndicatorPosition(indicator.value),
97
- small: small,
98
98
  total: indicator.total,
99
99
  unit: indicator.title,
100
100
  value: indicator.value
@@ -105,7 +105,7 @@ const UTConsumptionBar = _ref => {
105
105
  UTConsumptionBar.propTypes = {
106
106
  categoryLines: _propTypes.object,
107
107
  classes: _propTypes.object,
108
- small: _propTypes.bool,
108
+ hideAmount: _propTypes.bool,
109
109
  values: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
110
110
  position: _propTypes.string,
111
111
  subtitle: _propTypes.string,
@@ -77,7 +77,7 @@
77
77
  background-color: $gray-3;
78
78
  height: 23px;
79
79
  min-width: 26px;
80
- width: 26px;
80
+ width: 15%;
81
81
  }
82
82
 
83
83
  .colorizedLine {
@@ -12,17 +12,20 @@ var _dayjs2 = _interopRequireDefault(require("dayjs"));
12
12
  var _es = _interopRequireDefault(require("dayjs/locale/es"));
13
13
  var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
14
14
  var _form = require("@widergy/web-utils/lib/form");
15
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
15
16
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
16
17
  var _UTFieldLabel = _interopRequireDefault(require("../UTFieldLabel"));
17
18
  var _WithTheme = _interopRequireDefault(require("../WithTheme"));
18
19
  var _buttonTypes = require("../../types/buttonTypes");
19
20
  var _formTypes = require("../../types/formTypes");
20
21
  var _classesUtils = require("../../utils/classesUtils");
22
+ var _UTValidation = _interopRequireDefault(require("../UTValidation"));
23
+ var _utils = require("../UTValidation/utils");
21
24
  var _Day = _interopRequireDefault(require("./components/Day"));
22
25
  var _theme = require("./theme");
23
26
  var _types = require("./types");
24
27
  var _constants = require("./constants");
25
- var _utils = require("./utils");
28
+ var _utils2 = require("./utils");
26
29
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27
30
  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); }
28
31
  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); }
@@ -65,6 +68,7 @@ const UTDatePicker = _ref => {
65
68
  disableToolbar = true,
66
69
  disabled,
67
70
  field,
71
+ helpText,
68
72
  iconAnchor,
69
73
  input,
70
74
  inputProps,
@@ -83,18 +87,18 @@ const UTDatePicker = _ref => {
83
87
  } = _ref;
84
88
  const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(themeClasses, classNames), [classNames]);
85
89
  const configMask = (field === null || field === void 0 || (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.date_mask) || _constants.OUTPUT_LABEL_MASK;
86
- const onlyPastMonth = ((_field$configuration2 = field.configuration) === null || _field$configuration2 === void 0 || (_field$configuration2 = _field$configuration2.customDateValidations) === null || _field$configuration2 === void 0 || (_field$configuration2 = _field$configuration2.onlyPastMonth) === null || _field$configuration2 === void 0 ? void 0 : _field$configuration2.active) || false;
87
- const avoidFutureDates = ((_field$configuration3 = field.configuration) === null || _field$configuration3 === void 0 || (_field$configuration3 = _field$configuration3.customDateValidations) === null || _field$configuration3 === void 0 || (_field$configuration3 = _field$configuration3.avoidFutureDates) === null || _field$configuration3 === void 0 ? void 0 : _field$configuration3.active) || false;
90
+ const onlyPastMonth = (field === null || field === void 0 || (_field$configuration2 = field.configuration) === null || _field$configuration2 === void 0 || (_field$configuration2 = _field$configuration2.customDateValidations) === null || _field$configuration2 === void 0 || (_field$configuration2 = _field$configuration2.onlyPastMonth) === null || _field$configuration2 === void 0 ? void 0 : _field$configuration2.active) || false;
91
+ const avoidFutureDates = (field === null || field === void 0 || (_field$configuration3 = field.configuration) === null || _field$configuration3 === void 0 || (_field$configuration3 = _field$configuration3.customDateValidations) === null || _field$configuration3 === void 0 || (_field$configuration3 = _field$configuration3.avoidFutureDates) === null || _field$configuration3 === void 0 ? void 0 : _field$configuration3.active) || false;
88
92
  const {
89
93
  minDate,
90
94
  maxDate
91
- } = (onlyPastMonth ? (0, _utils.getPastMonthDates)() : avoidFutureDates ? (0, _utils.getMaxDate)() : range) || {};
95
+ } = (onlyPastMonth ? (0, _utils2.getPastMonthDates)() : avoidFutureDates ? (0, _utils2.getMaxDate)() : range) || {};
92
96
  const [pickedDate, setPickedDate] = (0, _react.useState)(null);
93
97
  const [internalError, setInternalError] = (0, _react.useState)(null);
94
98
  const handleChange = date => {
95
99
  setPickedDate(date);
96
100
  const newValue = (0, _dayjs2.default)(date, _constants.OUTPUT_LABEL_MASK, true);
97
- if ((0, _utils.isValidDate)({
101
+ if ((0, _utils2.isValidDate)({
98
102
  avoidFutureDates,
99
103
  newValue,
100
104
  onlyPastMonth,
@@ -102,7 +106,7 @@ const UTDatePicker = _ref => {
102
106
  })) input.onChange(newValue.format(configMask));else input.onChange('');
103
107
  };
104
108
  (0, _react.useEffect)(() => {
105
- if (!input.value && pickedDate !== null && pickedDate !== void 0 && pickedDate.isValid()) setPickedDate(null);else if ((0, _utils.dateMatchesFormat)(input.value, configMask)) setPickedDate((0, _dayjs2.default)(input.value, configMask));
109
+ if (!input.value && pickedDate !== null && pickedDate !== void 0 && pickedDate.isValid()) setPickedDate(null);else if ((0, _utils2.dateMatchesFormat)(input.value, configMask)) setPickedDate((0, _dayjs2.default)(input.value, configMask));
106
110
  }, [input.value]);
107
111
  const renderDay = (date, _, dayInCurrentMonth) => /*#__PURE__*/_react.default.createElement(_Day.default, {
108
112
  classes: classes,
@@ -131,11 +135,13 @@ const UTDatePicker = _ref => {
131
135
  value: pickedDate,
132
136
  label: inputVariant === 'standard' && (field === null || field === void 0 ? void 0 : field.title),
133
137
  error: (0, _form.shouldShowErrors)(meta),
134
- helperText: errorMessage ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
135
- className: classes.errorLabel,
136
- colorTheme: "error",
137
- variant: "small"
138
- }, errorMessage) : undefined,
138
+ helperText: /*#__PURE__*/_react.default.createElement(_react.Fragment, null, helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
139
+ colorTheme: "gray",
140
+ variant: "small",
141
+ withMarkdown: true
142
+ }, helpText), !(0, _isEmpty.default)(errorMessage) && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
143
+ validationData: (0, _utils.formatErrorToValidation)(errorMessage)
144
+ })),
139
145
  onError: handleError,
140
146
  onAccept: handleRemoveError,
141
147
  disableToolbar: disableToolbar,
@@ -180,6 +186,7 @@ UTDatePicker.propTypes = {
180
186
  disableToolbar: _propTypes.bool,
181
187
  disabled: _propTypes.bool,
182
188
  field: _formTypes.fieldType,
189
+ helpText: _propTypes.string,
183
190
  iconAnchor: _propTypes.bool,
184
191
  input: _formTypes.inputPropTypes.isRequired,
185
192
  inputFormat: _propTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.69.7",
3
+ "version": "3.71.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",