@aclymatepackages/modules 1.0.18 → 1.0.20
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.
|
@@ -276,7 +276,9 @@ const EmissionsChart = _ref10 => {
|
|
|
276
276
|
chartRef: chartRef,
|
|
277
277
|
type: type,
|
|
278
278
|
displayUnitLabel: isPercentageChart ? "%" : displayUnit || displayUnitLabel,
|
|
279
|
-
chartArray: chartArray,
|
|
279
|
+
chartArray: chartArray.map(obj => _objectSpread(_objectSpread({}, obj), {}, {
|
|
280
|
+
viewMode
|
|
281
|
+
})),
|
|
280
282
|
aspect: aspect,
|
|
281
283
|
showTooltip: showTooltip
|
|
282
284
|
})));
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
3
|
require("core-js/modules/es.object.assign.js");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
require("core-js/modules/es.
|
|
10
|
-
require("core-js/modules/es.
|
|
11
|
-
require("core-js/modules/esnext.string.replace-all.js");
|
|
12
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
8
|
+
require("core-js/modules/es.array.reduce.js");
|
|
9
|
+
require("core-js/modules/es.symbol.description.js");
|
|
13
10
|
var _react = _interopRequireDefault(require("react"));
|
|
14
11
|
var _material = require("@mui/material");
|
|
15
12
|
var _atoms = require("@aclymatepackages/atoms");
|
|
@@ -17,8 +14,6 @@ var _formatters = require("@aclymatepackages/formatters");
|
|
|
17
14
|
var _themes = require("@aclymatepackages/themes");
|
|
18
15
|
var _CustomTooltipDisplayRow = _interopRequireDefault(require("./CustomTooltipDisplayRow"));
|
|
19
16
|
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
20
|
-
const _excluded = ["label", "trendline", "emissionsSumTons", "projectedEmissionsSumTons", "id"],
|
|
21
|
-
_excluded2 = ["subcategory"];
|
|
22
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
18
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
24
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -26,8 +21,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
26
21
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
28
23
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
29
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
30
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
24
|
const StatusDisplay = _ref => {
|
|
32
25
|
let {
|
|
33
26
|
dataArray,
|
|
@@ -74,72 +67,52 @@ const StatusDisplay = _ref => {
|
|
|
74
67
|
}, tooltip)))))));
|
|
75
68
|
};
|
|
76
69
|
const EmissionsCustomTooltip = _ref2 => {
|
|
77
|
-
var _payload$;
|
|
78
70
|
let {
|
|
79
|
-
payload,
|
|
71
|
+
payload: passedPayload,
|
|
80
72
|
categoriesArray,
|
|
81
73
|
labelAnnotation = "",
|
|
82
74
|
dataArray = [],
|
|
83
75
|
displayUnitLabel
|
|
84
76
|
} = _ref2;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const filteredFormattedGraphValuesArray = Object.entries(graphValues).filter(_ref4 => {
|
|
98
|
-
let [_, value] = _ref4;
|
|
99
|
-
return value;
|
|
100
|
-
}).map(_ref5 => {
|
|
101
|
-
let [key, value] = _ref5;
|
|
102
|
-
const [subcategory, projected] = key.split("_");
|
|
103
|
-
return {
|
|
104
|
-
subcategory,
|
|
105
|
-
projected: !!projected,
|
|
106
|
-
value
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
const uniqueSubcategories = [...new Set(filteredFormattedGraphValuesArray.map(_ref6 => {
|
|
77
|
+
if (!passedPayload.length) {
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
79
|
+
}
|
|
80
|
+
const buildSubtitle = carbonValue => "".concat((0, _formatters.formatDecimal)(carbonValue), " ").concat(displayUnitLabel, " CO2");
|
|
81
|
+
const {
|
|
82
|
+
payload: columnDetails
|
|
83
|
+
} = passedPayload[0];
|
|
84
|
+
const {
|
|
85
|
+
label = "",
|
|
86
|
+
id
|
|
87
|
+
} = columnDetails || {};
|
|
88
|
+
const payloadDisplayArray = passedPayload.filter(_ref3 => {
|
|
110
89
|
let {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const subcategoryDisplayArray = uniqueSubcategories.map(subcategory => {
|
|
116
|
-
var _filteredFormattedGra;
|
|
117
|
-
const realValue = (_filteredFormattedGra = filteredFormattedGraphValuesArray.find(graphValue => graphValue.subcategory === subcategory)) === null || _filteredFormattedGra === void 0 ? void 0 : _filteredFormattedGra.value;
|
|
118
|
-
return {
|
|
119
|
-
subcategory,
|
|
120
|
-
subtitle: buildSubtitle(realValue)
|
|
121
|
-
};
|
|
90
|
+
value,
|
|
91
|
+
dataKey
|
|
92
|
+
} = _ref3;
|
|
93
|
+
return !!value && dataKey !== "trendline";
|
|
122
94
|
});
|
|
123
|
-
const
|
|
95
|
+
const formattedDisplayArray = payloadDisplayArray.map(_ref4 => {
|
|
124
96
|
let {
|
|
97
|
+
dataKey,
|
|
98
|
+
value
|
|
99
|
+
} = _ref4;
|
|
100
|
+
const chartSubcategory = categoriesArray.find(_ref5 => {
|
|
101
|
+
let {
|
|
125
102
|
subcategory
|
|
126
|
-
} =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
return _objectSpread({
|
|
133
|
-
subcategory,
|
|
134
|
-
color,
|
|
135
|
-
name
|
|
136
|
-
}, otherProps);
|
|
137
|
-
}).filter(_ref8 => {
|
|
138
|
-
let {
|
|
139
|
-
color
|
|
140
|
-
} = _ref8;
|
|
141
|
-
return color;
|
|
103
|
+
} = _ref5;
|
|
104
|
+
return subcategory === dataKey;
|
|
105
|
+
});
|
|
106
|
+
return _objectSpread(_objectSpread({}, chartSubcategory), {}, {
|
|
107
|
+
subtitle: buildSubtitle(value)
|
|
108
|
+
});
|
|
142
109
|
});
|
|
110
|
+
const emissionsSumTons = payloadDisplayArray.reduce((sum, _ref6) => {
|
|
111
|
+
let {
|
|
112
|
+
value
|
|
113
|
+
} = _ref6;
|
|
114
|
+
return value + sum;
|
|
115
|
+
}, 0);
|
|
143
116
|
return /*#__PURE__*/_react.default.createElement(_atoms.DefaultPaper, {
|
|
144
117
|
style: {
|
|
145
118
|
zIndex: 99999,
|
|
@@ -154,10 +127,10 @@ const EmissionsCustomTooltip = _ref2 => {
|
|
|
154
127
|
}, /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
155
128
|
variant: "h6",
|
|
156
129
|
color: "textPrimary"
|
|
157
|
-
}, "".concat(
|
|
130
|
+
}, "".concat(label, " Emissions")), /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
158
131
|
variant: "subtitle2",
|
|
159
132
|
color: "textSecondary"
|
|
160
|
-
}, "".concat(buildSubtitle(emissionsSumTons
|
|
133
|
+
}, "".concat(buildSubtitle(emissionsSumTons), " ").concat(labelAnnotation))), formattedDisplayArray.map((displayData, idx) => /*#__PURE__*/_react.default.createElement(_CustomTooltipDisplayRow.default, _extends({
|
|
161
134
|
key: "tooltip-display-row-".concat(idx)
|
|
162
135
|
}, displayData))), /*#__PURE__*/_react.default.createElement(StatusDisplay, {
|
|
163
136
|
id: id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aclymatepackages/modules",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "Aclymate modules",
|
|
5
5
|
"author": "William Loopesko",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@aclymatepackages/multi-part-form": "1.0.1",
|
|
17
17
|
"@aclymatepackages/other-helpers": "^1.0.3",
|
|
18
18
|
"@aclymatepackages/reg-exp": "^1.0.0",
|
|
19
|
+
"@aclymatepackages/subcategories": "^1.0.4",
|
|
19
20
|
"@aclymatepackages/themes": "^1.0.0",
|
|
20
21
|
"@babel/preset-react": "^7.16.7",
|
|
21
22
|
"@emotion/react": "^11.11.1",
|
|
@@ -299,7 +299,7 @@ const EmissionsChart = ({
|
|
|
299
299
|
displayUnitLabel={
|
|
300
300
|
isPercentageChart ? "%" : displayUnit || displayUnitLabel
|
|
301
301
|
}
|
|
302
|
-
chartArray={chartArray}
|
|
302
|
+
chartArray={chartArray.map((obj) => ({ ...obj, viewMode }))}
|
|
303
303
|
aspect={aspect}
|
|
304
304
|
showTooltip={showTooltip}
|
|
305
305
|
/>
|
|
@@ -44,59 +44,40 @@ const StatusDisplay = ({ dataArray, id }) => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const EmissionsCustomTooltip = ({
|
|
47
|
-
payload,
|
|
47
|
+
payload: passedPayload,
|
|
48
48
|
categoriesArray,
|
|
49
49
|
labelAnnotation = "",
|
|
50
50
|
dataArray = [],
|
|
51
51
|
displayUnitLabel,
|
|
52
52
|
}) => {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
if (!passedPayload.length) {
|
|
54
|
+
return <></>;
|
|
55
|
+
}
|
|
55
56
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
label = "",
|
|
59
|
-
trendline,
|
|
60
|
-
emissionsSumTons,
|
|
61
|
-
projectedEmissionsSumTons,
|
|
62
|
-
id,
|
|
63
|
-
...graphValues
|
|
64
|
-
} = columnDetails || {};
|
|
65
|
-
const cleanLabel = label.replaceAll(/[*]/gi, "");
|
|
57
|
+
const buildSubtitle = (carbonValue) =>
|
|
58
|
+
`${formatDecimal(carbonValue)} ${displayUnitLabel} CO2`;
|
|
66
59
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
.map(([key, value]) => {
|
|
70
|
-
const [subcategory, projected] = key.split("_");
|
|
71
|
-
return { subcategory, projected: !!projected, value };
|
|
72
|
-
});
|
|
60
|
+
const { payload: columnDetails } = passedPayload[0];
|
|
61
|
+
const { label = "", id } = columnDetails || {};
|
|
73
62
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
),
|
|
78
|
-
];
|
|
63
|
+
const payloadDisplayArray = passedPayload.filter(
|
|
64
|
+
({ value, dataKey }) => !!value && dataKey !== "trendline"
|
|
65
|
+
);
|
|
79
66
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
const formattedDisplayArray = payloadDisplayArray.map(
|
|
68
|
+
({ dataKey, value }) => {
|
|
69
|
+
const chartSubcategory = categoriesArray.find(
|
|
70
|
+
({ subcategory }) => subcategory === dataKey
|
|
71
|
+
);
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
});
|
|
73
|
+
return { ...chartSubcategory, subtitle: buildSubtitle(value) };
|
|
74
|
+
}
|
|
75
|
+
);
|
|
90
76
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(categoryObj) => categoryObj.subcategory === subcategory
|
|
96
|
-
) || {};
|
|
97
|
-
return { subcategory, color, name, ...otherProps };
|
|
98
|
-
})
|
|
99
|
-
.filter(({ color }) => color);
|
|
77
|
+
const emissionsSumTons = payloadDisplayArray.reduce(
|
|
78
|
+
(sum, { value }) => value + sum,
|
|
79
|
+
0
|
|
80
|
+
);
|
|
100
81
|
|
|
101
82
|
return (
|
|
102
83
|
<DefaultPaper style={{ zIndex: 99999, borderColor: "transparent" }}>
|
|
@@ -105,15 +86,12 @@ const EmissionsCustomTooltip = ({
|
|
|
105
86
|
<Typography
|
|
106
87
|
variant="h6"
|
|
107
88
|
color="textPrimary"
|
|
108
|
-
>{`${
|
|
89
|
+
>{`${label} Emissions`}</Typography>
|
|
109
90
|
<Typography variant="subtitle2" color="textSecondary">
|
|
110
|
-
{`${buildSubtitle(
|
|
111
|
-
emissionsSumTons,
|
|
112
|
-
projectedEmissionsSumTons
|
|
113
|
-
)} ${labelAnnotation}`}
|
|
91
|
+
{`${buildSubtitle(emissionsSumTons)} ${labelAnnotation}`}
|
|
114
92
|
</Typography>
|
|
115
93
|
</Grid>
|
|
116
|
-
{
|
|
94
|
+
{formattedDisplayArray.map((displayData, idx) => (
|
|
117
95
|
<CustomTooltipDisplayRow
|
|
118
96
|
key={`tooltip-display-row-${idx}`}
|
|
119
97
|
{...displayData}
|