@widergy/utilitygo-smart-bill-web 3.1.0 → 3.3.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/SmartBillSummary/constants.js +24 -0
  3. package/dist/components/SmartBillSummary/index.js +95 -0
  4. package/dist/components/SmartBillSummary/styles.module.scss +48 -0
  5. package/dist/components/SmartBillSummary/tabs/Billing/components/DebtStatusLabel/constants.js +9 -0
  6. package/dist/components/SmartBillSummary/tabs/Billing/components/DebtStatusLabel/index.js +34 -0
  7. package/dist/components/SmartBillSummary/tabs/Billing/components/DebtStatusLabel/styles.module.scss +16 -0
  8. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/constants.js +8 -0
  9. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/index.js +154 -0
  10. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/styles.module.scss +174 -0
  11. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/utils.js +88 -0
  12. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/index.js +165 -0
  13. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/styles.module.scss +60 -0
  14. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/utils.js +14 -0
  15. package/dist/components/SmartBillSummary/tabs/Billing/index.js +288 -0
  16. package/dist/components/SmartBillSummary/tabs/Billing/styles.module.scss +132 -0
  17. package/dist/components/SmartBillSummary/tabs/Billing/utils.js +13 -0
  18. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/constants.js +9 -0
  19. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/index.js +90 -0
  20. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/styles.module.scss +55 -0
  21. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/utils.js +32 -0
  22. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/constants.js +13 -0
  23. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/index.js +78 -0
  24. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/styles.module.scss +43 -0
  25. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/constants.js +9 -0
  26. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/index.js +68 -0
  27. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/styles.module.scss +43 -0
  28. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/utils.js +35 -0
  29. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/index.js +72 -0
  30. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/styles.module.scss +29 -0
  31. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/utils.js +71 -0
  32. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/index.js +64 -0
  33. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/styles.module.scss +22 -0
  34. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/utils.js +56 -0
  35. package/dist/components/SmartBillSummary/tabs/Consumptions/index.js +54 -0
  36. package/dist/components/SmartBillSummary/tabs/Consumptions/styles.module.scss +31 -0
  37. package/dist/components/SmartBillSummary/utils.js +30 -0
  38. package/dist/index.js +14 -0
  39. package/dist/shared/constants/tabs.js +11 -0
  40. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [3.3.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.2.0...v3.3.0) (2025-03-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * [CX-201] billing tab smartbill ([#44](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/44)) ([d4175c3](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/d4175c3fd8a6e773b750bfe9d0c525c35689e8ef))
7
+
8
+ # [3.2.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.1.0...v3.2.0) (2025-03-12)
9
+
10
+
11
+ ### Features
12
+
13
+ * [CX-199] smartbill new experience consumption tab ([#41](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/41)) ([ac3a0ef](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/ac3a0efc5fa2c9b2c2deca2f9aa9dedbdfd38e42))
14
+
1
15
  # [3.1.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.0.4...v3.1.0) (2025-03-07)
2
16
 
3
17
 
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TAB_COMPONENT_MAPPER = exports.BIMESTRAL_PERIODICITY = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _tabs = require("../../shared/constants/tabs");
9
+ var _Consumptions = _interopRequireDefault(require("./tabs/Consumptions"));
10
+ var _Billing = _interopRequireDefault(require("./tabs/Billing"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ 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/prop-types */
13
+ const BIMESTRAL_PERIODICITY = exports.BIMESTRAL_PERIODICITY = 'BIMESTRAL';
14
+ const renderComponentWithProps = (Component, tab) => props => /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
15
+ assets: props?.assets?.[tab] || {},
16
+ translations: props?.translations?.[tab] || {}
17
+ }));
18
+ const TAB_COMPONENT_MAPPER = exports.TAB_COMPONENT_MAPPER = {
19
+ [_tabs.SMARTBILL_TABS.CONSUMPTIONS]: renderComponentWithProps(_Consumptions.default, _tabs.SMARTBILL_TABS.CONSUMPTIONS),
20
+ [_tabs.SMARTBILL_TABS.BILLING]: renderComponentWithProps(_Billing.default, _tabs.SMARTBILL_TABS.BILLING),
21
+ [_tabs.SMARTBILL_TABS.GLOSSARY]: renderComponentWithProps(() => /*#__PURE__*/_react.default.createElement("div", null, "Glosario: CX-243"),
22
+ // TODO
23
+ _tabs.SMARTBILL_TABS.GLOSSARY)
24
+ };
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _energyUi = require("@widergy/energy-ui");
9
+ var _propTypes = require("prop-types");
10
+ var _billDataTypes = require("../../shared/types/billDataTypes");
11
+ var _constants = require("./constants");
12
+ var _utils = require("./utils");
13
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ 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); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ const SmartBillSummary = _ref => {
18
+ let {
19
+ assets,
20
+ constants,
21
+ consumptionLevels,
22
+ components,
23
+ currentAccount,
24
+ handlers,
25
+ isDesktopSize,
26
+ loading,
27
+ smartBill,
28
+ tabOptions,
29
+ translations,
30
+ utils
31
+ } = _ref;
32
+ const filteredTabOptions = (0, _utils.getTabOptions)(tabOptions, smartBill) || [];
33
+ const defaultCurrentTab = (0, _utils.getDefaultCurrentTab)(filteredTabOptions);
34
+ const [currentTab, setCurrentTab] = (0, _react.useState)(defaultCurrentTab);
35
+ const changeCurrentTab = newTab => setCurrentTab(newTab);
36
+ (0, _react.useEffect)(() => {
37
+ if (defaultCurrentTab) changeCurrentTab(defaultCurrentTab);
38
+ }, [defaultCurrentTab]);
39
+ return /*#__PURE__*/_react.default.createElement(_energyUi.UTLoading, {
40
+ className: _stylesModule.default.loadingContainer,
41
+ loading: loading
42
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTTabs, {
43
+ classNames: {
44
+ baseLabel: _stylesModule.default.tabLabel,
45
+ baseSelected: _stylesModule.default.baseSelected,
46
+ flexContainer: _stylesModule.default.tabsContainer
47
+ },
48
+ onChange: changeCurrentTab,
49
+ options: filteredTabOptions,
50
+ tabsProps: {
51
+ orientation: 'horizontal',
52
+ variant: 'fullWidth'
53
+ },
54
+ value: currentTab
55
+ }), /*#__PURE__*/_react.default.createElement("div", {
56
+ className: _stylesModule.default.contentContainer
57
+ }, _constants.TAB_COMPONENT_MAPPER?.[currentTab]?.({
58
+ assets,
59
+ constants,
60
+ consumptionLevels,
61
+ components,
62
+ currentAccount,
63
+ handlers,
64
+ isDesktopSize,
65
+ loading,
66
+ smartBill,
67
+ translations,
68
+ utils
69
+ })));
70
+ };
71
+ SmartBillSummary.propTypes = {
72
+ assets: _propTypes.object,
73
+ constants: _propTypes.object,
74
+ consumptionLevels: _propTypes.array,
75
+ components: (0, _propTypes.shape)({
76
+ [_propTypes.string]: _propTypes.elementType
77
+ }),
78
+ currentAccount: _propTypes.array,
79
+ handlers: (0, _propTypes.shape)({
80
+ [_propTypes.string]: _propTypes.func
81
+ }),
82
+ isDesktopSize: _propTypes.bool,
83
+ loading: _propTypes.bool,
84
+ smartBill: _billDataTypes.billDataTypes,
85
+ tabOptions: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
86
+ defaultSelected: _propTypes.bool,
87
+ enabled: _propTypes.bool,
88
+ icon: _propTypes.string,
89
+ label: _propTypes.string,
90
+ value: _propTypes.string
91
+ })),
92
+ translations: _propTypes.object,
93
+ utils: _propTypes.object
94
+ };
95
+ var _default = exports.default = SmartBillSummary;
@@ -0,0 +1,48 @@
1
+ @import '../../scss/variables/sizes.module.scss';
2
+
3
+ $max-content-width: 1264px;
4
+ $tab-height: 48px;
5
+
6
+ .tabsContainer {
7
+ > button {
8
+ border-bottom: 1px solid var(--light04);
9
+ height: $tab-height;
10
+ max-width: unset;
11
+ min-height: $tab-height;
12
+ }
13
+ }
14
+
15
+ .contentContainer {
16
+ flex: 1;
17
+ margin: 0 auto;
18
+ max-height: calc(100vh - var(--workflowTopbarHeight) - #{$tab-height});
19
+ max-width: $max-content-width;
20
+ overflow-y: auto;
21
+ width: 100%;
22
+ }
23
+
24
+ .tabLabel {
25
+ align-items: center;
26
+ display: flex;
27
+ flex-direction: row;
28
+ grid-gap: 8px;
29
+
30
+ svg {
31
+ margin-bottom: 0 !important;
32
+ }
33
+ }
34
+
35
+ .baseSelected {
36
+ svg {
37
+ stroke: var(--actionAccent04);
38
+ }
39
+ }
40
+
41
+ .loadingContainer {
42
+ align-items: center;
43
+ display: flex;
44
+ flex: 1;
45
+ height: 100%;
46
+ justify-content: center;
47
+ width: 100%;
48
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_WARNING_ICON = exports.DEFAULT_SUCCESS_ICON = exports.DEFAULT_ICON_SIZE = void 0;
7
+ const DEFAULT_WARNING_ICON = exports.DEFAULT_WARNING_ICON = 'IconAlertTriangle';
8
+ const DEFAULT_SUCCESS_ICON = exports.DEFAULT_SUCCESS_ICON = 'IconCheck';
9
+ const DEFAULT_ICON_SIZE = exports.DEFAULT_ICON_SIZE = 16;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _energyUi = require("@widergy/energy-ui");
9
+ var _propTypes = require("prop-types");
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 DebtStatusLabel = _ref => {
14
+ let {
15
+ debtStatusLabel,
16
+ isWarning
17
+ } = _ref;
18
+ return /*#__PURE__*/_react.default.createElement("div", {
19
+ className: `${_stylesModule.default.container} ${isWarning ? _stylesModule.default.withDebtsContainer : _stylesModule.default.adheredToAutomaticDebit} `
20
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
21
+ colorTheme: isWarning ? 'warning' : 'success',
22
+ name: isWarning ? _constants.DEFAULT_WARNING_ICON : _constants.DEFAULT_SUCCESS_ICON,
23
+ size: _constants.DEFAULT_ICON_SIZE
24
+ }), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
25
+ colorTheme: isWarning ? 'warning' : 'success',
26
+ variant: "small",
27
+ weight: "medium"
28
+ }, debtStatusLabel));
29
+ };
30
+ DebtStatusLabel.propTypes = {
31
+ debtStatusLabel: _propTypes.string,
32
+ isWarning: _propTypes.bool
33
+ };
34
+ var _default = exports.default = DebtStatusLabel;
@@ -0,0 +1,16 @@
1
+ .container {
2
+ align-items: center;
3
+ border-radius: 4px;
4
+ display: flex;
5
+ grid-gap: 8px;
6
+ justify-content: space-between;
7
+ padding: 4px 8px;
8
+ }
9
+
10
+ .withDebtsContainer {
11
+ background-color: var(--semanticWarning01);
12
+ }
13
+
14
+ .adheredToAutomaticDebit {
15
+ background-color: var(--semanticSuccess01);
16
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MIN_VALUE_PROGRESS = exports.MAX_VALUE_PROGRESS = void 0;
7
+ const MIN_VALUE_PROGRESS = exports.MIN_VALUE_PROGRESS = 0;
8
+ const MAX_VALUE_PROGRESS = exports.MAX_VALUE_PROGRESS = 100;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = require("prop-types");
9
+ var _energyUi = require("@widergy/energy-ui");
10
+ var _utils = require("./utils");
11
+ var _constants = require("./constants");
12
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ 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); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const ProgressBar = _ref => {
17
+ let {
18
+ components = {},
19
+ currentPeriod,
20
+ data,
21
+ isT1,
22
+ limitValue,
23
+ specificRate,
24
+ tooltipContent,
25
+ translations,
26
+ value
27
+ } = _ref;
28
+ const {
29
+ LinearProgress
30
+ } = components;
31
+ const lastRange = data[data.length - 1]?.range[1];
32
+ const totalRange = lastRange === 'Infinity' ? data[data.length - 2]?.range[1] * 1.5 : lastRange;
33
+ const progressOverlayValue = (0, _utils.getProgressOverlayValue)(specificRate, totalRange, value);
34
+ const isOverLimit = value > limitValue;
35
+ const {
36
+ initialLabel,
37
+ dynamicLabel,
38
+ finalLabel,
39
+ currentValueLabel,
40
+ contrastValueLabel
41
+ } = (0, _utils.formatLabels)({
42
+ currentPeriod,
43
+ isOverLimit,
44
+ limitValue,
45
+ translations,
46
+ value
47
+ }) || {};
48
+ const consumptionPercentage = (0, _utils.getConsumptionPercentage)(value, limitValue, isOverLimit) || _constants.MAX_VALUE_PROGRESS;
49
+ const shouldRenderDynamicLabel = value > 0 && limitValue > 0;
50
+ const [limitLabelWidth, setLimitLabelWidth] = (0, _react.useState)(0);
51
+ const limitLabelRef = (0, _react.useRef)(null);
52
+ (0, _react.useEffect)(() => {
53
+ if (limitLabelRef.current) {
54
+ setLimitLabelWidth(limitLabelRef.current.offsetWidth);
55
+ }
56
+ }, [dynamicLabel, finalLabel]);
57
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, isT1 ? /*#__PURE__*/_react.default.createElement("div", {
58
+ className: _stylesModule.default.progressBar
59
+ }, /*#__PURE__*/_react.default.createElement("div", {
60
+ className: _stylesModule.default.progressBackground
61
+ }, data.map(_ref2 => {
62
+ let {
63
+ range,
64
+ name
65
+ } = _ref2;
66
+ const isLast = range[1] === 'Infinity';
67
+ const width = isLast ? '20%' : `${range[1] / totalRange * 100}%`;
68
+ return /*#__PURE__*/_react.default.createElement("div", {
69
+ key: name,
70
+ className: _stylesModule.default.progressSegment,
71
+ style: {
72
+ width,
73
+ flexGrow: isLast ? 1 : 0
74
+ }
75
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
76
+ className: _stylesModule.default.segmentName,
77
+ colorTheme: "gray",
78
+ variant: "xsmall"
79
+ }, name));
80
+ })), /*#__PURE__*/_react.default.createElement("div", {
81
+ className: _stylesModule.default.progressOverlay,
82
+ style: {
83
+ left: `${progressOverlayValue}%`,
84
+ width: `calc(100% - ${progressOverlayValue - 0.5}%)`
85
+ }
86
+ })) : /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
87
+ className: `
88
+ ${_stylesModule.default.powerAndDatesContainer}
89
+ ${isOverLimit && _stylesModule.default.overHiredContainer}
90
+ `
91
+ }, /*#__PURE__*/_react.default.createElement("div", {
92
+ className: _stylesModule.default.consumptionDetailsContainer
93
+ }, /*#__PURE__*/_react.default.createElement("div", {
94
+ className: _stylesModule.default.consumptionComparison
95
+ }, value >= 0 && /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
96
+ variant: "subtitle1"
97
+ }, currentValueLabel), value >= 0 && limitValue > 0 && /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
98
+ colorTheme: "gray",
99
+ variant: "small"
100
+ }, contrastValueLabel)), tooltipContent && /*#__PURE__*/_react.default.createElement(_energyUi.UTTooltip, {
101
+ content: tooltipContent
102
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
103
+ colorTheme: "neutral",
104
+ name: "EnergyIconQuestionFilled",
105
+ size: 20
106
+ }))))), /*#__PURE__*/_react.default.createElement("div", {
107
+ className: _stylesModule.default.progressContainer
108
+ }, /*#__PURE__*/_react.default.createElement(LinearProgress, {
109
+ classes: (0, _utils.getProgressBarClasses)({
110
+ consumptionPercentage,
111
+ limitValue,
112
+ value,
113
+ hiredValue: limitValue,
114
+ isOverLimit,
115
+ styles: _stylesModule.default
116
+ }),
117
+ value: consumptionPercentage,
118
+ variant: "determinate"
119
+ }), /*#__PURE__*/_react.default.createElement("div", {
120
+ className: _stylesModule.default.progressLabels
121
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
122
+ colorTheme: "gray",
123
+ variant: "xsmall"
124
+ }, initialLabel), shouldRenderDynamicLabel && /*#__PURE__*/_react.default.createElement("div", {
125
+ className: _stylesModule.default.dinamicLabel,
126
+ style: {
127
+ left: (0, _utils.getDynamicPosition)(consumptionPercentage, limitLabelWidth)
128
+ }
129
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
130
+ colorTheme: "gray",
131
+ variant: "xsmall"
132
+ }, dynamicLabel)), /*#__PURE__*/_react.default.createElement("span", {
133
+ className: _stylesModule.default.smallGrayLabel,
134
+ ref: limitLabelRef
135
+ }, finalLabel)))));
136
+ };
137
+ ProgressBar.propTypes = {
138
+ components: (0, _propTypes.shape)({
139
+ [_propTypes.string]: _propTypes.elementType
140
+ }),
141
+ currentPeriod: _propTypes.object,
142
+ data: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
143
+ name: _propTypes.string,
144
+ color: _propTypes.string,
145
+ range: (0, _propTypes.arrayOf)((0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]))
146
+ })),
147
+ isT1: _propTypes.bool,
148
+ limitValue: _propTypes.number,
149
+ specificRate: _propTypes.string,
150
+ tooltipContent: _propTypes.string,
151
+ translations: _propTypes.object,
152
+ value: _propTypes.number
153
+ };
154
+ var _default = exports.default = ProgressBar;
@@ -0,0 +1,174 @@
1
+ @import '../../../../../../../../scss/variables/fontSizes.module.scss';
2
+
3
+ $default-border-radius: 100px;
4
+ $default-progress-bar-background: linear-gradient(88.75deg, #30e3a2 1.07%, #efc73c 50.13%, #ec574d 98.93%);
5
+ $default-information-color: #21c7e4;
6
+
7
+ .progressBar {
8
+ height: 9px;
9
+ margin: 0 24px;
10
+ position: relative;
11
+ }
12
+
13
+ .progressBackground {
14
+ background: $default-progress-bar-background;
15
+ border-radius: $default-border-radius;
16
+ display: flex;
17
+ height: 100%;
18
+ left: 0;
19
+ position: absolute;
20
+ top: 0;
21
+ width: 100%;
22
+ }
23
+
24
+ .progressSegment {
25
+ flex-grow: 1;
26
+ height: 100%;
27
+ position: relative;
28
+
29
+ &:last-child {
30
+ border-bottom-right-radius: $default-border-radius;
31
+ border-top-right-radius: $default-border-radius;
32
+ &::after {
33
+ display: none;
34
+ }
35
+ }
36
+ }
37
+
38
+ .progressSegment::after {
39
+ background-color: var(--light01);
40
+ content: '';
41
+ height: 100%;
42
+ position: absolute;
43
+ right: 0;
44
+ top: 0;
45
+ width: 2px;
46
+ z-index: 3;
47
+ }
48
+
49
+ .segmentName {
50
+ position: absolute;
51
+ top: 18px;
52
+ }
53
+
54
+ .progressOverlay {
55
+ background-color: var(--light04);
56
+ height: 100%;
57
+ left: 0;
58
+ pointer-events: none;
59
+ position: absolute;
60
+ top: 0;
61
+ width: 100%;
62
+ z-index: 2;
63
+
64
+ &:last-child {
65
+ border-bottom-right-radius: $default-border-radius;
66
+ border-top-right-radius: $default-border-radius;
67
+ }
68
+ }
69
+
70
+ .backgroundBar {
71
+ background: var(--light02);
72
+ border-radius: $default-border-radius;
73
+ height: 9px;
74
+ }
75
+
76
+ .foregroundBar {
77
+ background: $default-information-color;
78
+ border-radius: $default-border-radius;
79
+ }
80
+
81
+ .overHiredBackgroundBar {
82
+ background: var(--semanticWarning04);
83
+ border-radius: $default-border-radius;
84
+ }
85
+
86
+ .overHiredForegroundBar {
87
+ background: var(--chartGradientHorizontal1);
88
+ border-radius: $default-border-radius;
89
+ }
90
+
91
+ .powerAndDatesContainer {
92
+ display: flex;
93
+ height: unset !important;
94
+ justify-content: space-between;
95
+ margin: 0 24px;
96
+ position: relative;
97
+ }
98
+
99
+ .highestConsumptionContainer {
100
+ display: flex;
101
+ flex-direction: column;
102
+ place-items: flex-start;
103
+ }
104
+
105
+ .hiredPowerContainer {
106
+ display: flex;
107
+ flex-direction: column;
108
+ place-items: flex-end;
109
+ }
110
+
111
+ .powerAmount {
112
+ align-items: baseline;
113
+ display: flex;
114
+ }
115
+
116
+ .hidden {
117
+ display: none;
118
+ }
119
+
120
+ .overHiredContainer {
121
+ flex-direction: row-reverse;
122
+ margin-bottom: 8px;
123
+
124
+ .highestConsumptionContainer {
125
+ place-items: flex-end;
126
+ }
127
+
128
+ .hiredPowerContainer {
129
+ place-items: flex-start;
130
+ }
131
+ }
132
+
133
+ .hiredLabel {
134
+ color: var(--actionNeutral04);
135
+ }
136
+
137
+ .progressContainer {
138
+ margin: 0 24px;
139
+ position: relative;
140
+ }
141
+
142
+ .progressLabels {
143
+ display: flex;
144
+ justify-content: space-between;
145
+ margin: 8px 0 -24px;
146
+ position: relative;
147
+ }
148
+
149
+ .dinamicLabel {
150
+ position: absolute;
151
+ top: 0;
152
+ transform: translateX(-50%);
153
+ }
154
+
155
+ .consumptionDetailsContainer {
156
+ display: flex;
157
+ flex: 1;
158
+ flex-direction: row;
159
+ grid-gap: 4px;
160
+ justify-content: space-between;
161
+ }
162
+
163
+ .consumptionComparison {
164
+ display: flex;
165
+ flex-direction: row;
166
+ grid-gap: 4px;
167
+ margin-bottom: 8px;
168
+ }
169
+
170
+ .smallGrayLabel {
171
+ color: var(--gray04);
172
+ font-size: $small;
173
+ line-height: 1.125rem;
174
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getProgressOverlayValue = exports.getProgressBarClasses = exports.getDynamicPosition = exports.getConsumptionPercentage = exports.formatMaxPowerRegisteredDate = exports.formatLabels = void 0;
7
+ var _dayjs = _interopRequireDefault(require("dayjs"));
8
+ var _numeral = _interopRequireDefault(require("numeral"));
9
+ var _isBetween = _interopRequireDefault(require("dayjs/plugin/isBetween"));
10
+ var _constants = require("./constants");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const getConsumptionPercentage = (currentValue, contrastValue, isOverLimit) => (currentValue > contrastValue ? isOverLimit ? contrastValue / currentValue : 1 : currentValue / contrastValue) * 100;
13
+ exports.getConsumptionPercentage = getConsumptionPercentage;
14
+ const formatMaxPowerRegisteredDate = maxConsumptionDay => (0, _dayjs.default)(maxConsumptionDay).tz().format('D MMM');
15
+ exports.formatMaxPowerRegisteredDate = formatMaxPowerRegisteredDate;
16
+ const getDynamicPosition = (percentage, labelWidth) => `clamp(50px, calc(${percentage}% - 10px), calc(100% - ${labelWidth + 28}px))`;
17
+ exports.getDynamicPosition = getDynamicPosition;
18
+ _dayjs.default.extend(_isBetween.default);
19
+ const formatLabels = _ref => {
20
+ let {
21
+ currentPeriod,
22
+ isOverLimit,
23
+ limitValue,
24
+ translations = {},
25
+ value
26
+ } = _ref;
27
+ const currentValueFormatted = (0, _numeral.default)(value).format('0,0.[00]');
28
+ const contrastValueFormatted = (0, _numeral.default)(limitValue).format('0,0.[00]') || 0;
29
+ const maxConsumptionDay = (0, _dayjs.default)(`${currentPeriod?.year}-${currentPeriod?.number}-01`);
30
+ const {
31
+ currentValueWithUnitLabel,
32
+ maxValueWithUnitLabel
33
+ } = translations;
34
+ return {
35
+ initialLabel: _constants.MIN_VALUE_PROGRESS,
36
+ dynamicLabel: isOverLimit ? contrastValueFormatted : currentValueFormatted,
37
+ finalLabel: isOverLimit || !limitValue ? currentValueFormatted : contrastValueFormatted,
38
+ currentValueLabel: currentValueWithUnitLabel?.({
39
+ value: currentValueFormatted,
40
+ day: formatMaxPowerRegisteredDate(maxConsumptionDay)
41
+ }),
42
+ contrastValueLabel: maxValueWithUnitLabel?.({
43
+ detailLabel: 'contratada',
44
+ value: contrastValueFormatted
45
+ })
46
+ };
47
+ };
48
+ exports.formatLabels = formatLabels;
49
+ const getProgressBarClasses = _ref2 => {
50
+ let {
51
+ consumptionPercentage,
52
+ contrastValue,
53
+ currentValue,
54
+ hiredValue,
55
+ isOverLimit,
56
+ styles
57
+ } = _ref2;
58
+ return {
59
+ root: `${isOverLimit && styles.overHiredBackgroundBar} ${styles.backgroundBar}`,
60
+ bar: `
61
+ ${!isOverLimit ? styles.foregroundBar : styles.overHiredForegroundBar}
62
+ ${currentValue > hiredValue && !contrastValue && styles.overHiredBackgroundBar}
63
+ ${!consumptionPercentage && styles.hidden}
64
+ `
65
+ };
66
+ };
67
+ exports.getProgressBarClasses = getProgressBarClasses;
68
+ const getProgressOverlayValue = (rate, totalRange, value) => {
69
+ const rateName = rate?.name;
70
+ const defaultProgress = value / totalRange * 100;
71
+ switch (rateName) {
72
+ case 'R1':
73
+ return defaultProgress * 0.4;
74
+ case 'R2':
75
+ return defaultProgress * 0.55;
76
+ case 'R3':
77
+ return defaultProgress * 0.85;
78
+ case 'R4':
79
+ return defaultProgress * 1.13;
80
+ case 'R5':
81
+ return defaultProgress * 1.368;
82
+ case 'R6':
83
+ return defaultProgress * 1.37;
84
+ default:
85
+ return defaultProgress;
86
+ }
87
+ };
88
+ exports.getProgressOverlayValue = getProgressOverlayValue;