@pareto-engineering/design-system 5.0.2 → 5.0.5
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/dist/cjs/a/Charts/AreaChart/AreaChart.js +13 -3
- package/dist/cjs/a/Charts/BarChart/BarChart.js +4 -6
- package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +7 -26
- package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +14 -41
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +7 -18
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +4 -3
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +6 -7
- package/dist/cjs/a/Charts/index.js +1 -8
- package/dist/cjs/a/index.js +0 -6
- package/dist/cjs/f/fields/FileUpload/common/Preview/Preview.js +9 -2
- package/dist/cjs/utils/formatting.js +2 -10
- package/dist/cjs/utils/index.js +0 -6
- package/dist/es/a/Charts/AreaChart/AreaChart.js +13 -3
- package/dist/es/a/Charts/BarChart/BarChart.js +4 -6
- package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +21 -38
- package/dist/es/a/Charts/Common/CustomLegend/styles.scss +14 -41
- package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +8 -19
- package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +5 -3
- package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +6 -7
- package/dist/es/a/Charts/index.js +1 -2
- package/dist/es/a/index.js +1 -1
- package/dist/es/f/fields/FileUpload/common/Preview/Preview.js +9 -2
- package/dist/es/utils/formatting.js +0 -7
- package/dist/es/utils/index.js +1 -1
- package/package.json +2 -2
- package/src/stories/a/AreaChart.stories.jsx +1 -1
- package/src/stories/a/BarChart.stories.jsx +1 -1
- package/src/ui/a/Charts/AreaChart/AreaChart.jsx +14 -8
- package/src/ui/a/Charts/BarChart/BarChart.jsx +2 -4
- package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +29 -54
- package/src/ui/a/Charts/Common/CustomLegend/styles.scss +14 -41
- package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +13 -25
- package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +4 -4
- package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +6 -7
- package/src/ui/a/Charts/index.js +0 -1
- package/src/ui/a/index.js +1 -1
- package/src/ui/f/fields/FileUpload/common/Preview/Preview.jsx +26 -12
- package/src/ui/utils/formatting.js +0 -8
- package/src/ui/utils/index.js +1 -3
- package/tests/__snapshots__/Storyshots.test.js.snap +428 -1164
- package/dist/cjs/a/Charts/PieChart/PieChart.js +0 -99
- package/dist/cjs/a/Charts/PieChart/index.js +0 -13
- package/dist/cjs/a/Charts/PieChart/styles.scss +0 -48
- package/dist/es/a/Charts/PieChart/PieChart.js +0 -89
- package/dist/es/a/Charts/PieChart/index.js +0 -1
- package/dist/es/a/Charts/PieChart/styles.scss +0 -48
- package/src/stories/a/PieChart.stories.jsx +0 -53
- package/src/ui/a/Charts/PieChart/PieChart.jsx +0 -125
- package/src/ui/a/Charts/PieChart/index.js +0 -1
- package/src/ui/a/Charts/PieChart/styles.scss +0 -48
|
@@ -40,6 +40,17 @@ const AreaChart = _ref => {
|
|
|
40
40
|
color: colors[yKeys.indexOf(key)]
|
|
41
41
|
}));
|
|
42
42
|
const [selectedYLabels, setSelectedYLabels] = (0, _react.useState)(allYLabels);
|
|
43
|
+
const processedData = data.map(item => {
|
|
44
|
+
const yValues = yKeys.map(key => item[key]);
|
|
45
|
+
const lowerBound = Math.min(...yValues);
|
|
46
|
+
const upperBound = Math.max(...yValues);
|
|
47
|
+
const margin = (upperBound - lowerBound) * 0.1;
|
|
48
|
+
return {
|
|
49
|
+
...item,
|
|
50
|
+
bounds: [lowerBound - margin, upperBound + margin],
|
|
51
|
+
isTimeFormat
|
|
52
|
+
};
|
|
53
|
+
});
|
|
43
54
|
const yAxisBounds = () => {
|
|
44
55
|
const yValues = data.map(item => yKeys.map(key => item[key]));
|
|
45
56
|
const min = Math.min(...yValues.flat());
|
|
@@ -64,7 +75,7 @@ const AreaChart = _ref => {
|
|
|
64
75
|
width: width,
|
|
65
76
|
height: height
|
|
66
77
|
}, /*#__PURE__*/React.createElement(_recharts.AreaChart, {
|
|
67
|
-
data:
|
|
78
|
+
data: processedData
|
|
68
79
|
}, /*#__PURE__*/React.createElement(_recharts.CartesianGrid, {
|
|
69
80
|
strokeDasharray: "3 3"
|
|
70
81
|
}), /*#__PURE__*/React.createElement(_recharts.XAxis, {
|
|
@@ -105,8 +116,7 @@ const AreaChart = _ref => {
|
|
|
105
116
|
}
|
|
106
117
|
}), /*#__PURE__*/React.createElement(_recharts.Tooltip, {
|
|
107
118
|
content: /*#__PURE__*/React.createElement(_Common.CustomTooltipContent, {
|
|
108
|
-
|
|
109
|
-
isTimeFormat: isTimeFormat
|
|
119
|
+
xLabel: xLabel
|
|
110
120
|
})
|
|
111
121
|
}), filled && /*#__PURE__*/React.createElement(_recharts.Area, {
|
|
112
122
|
id: "bounds",
|
|
@@ -30,9 +30,8 @@ const BarChart = _ref => {
|
|
|
30
30
|
yLabel,
|
|
31
31
|
colors,
|
|
32
32
|
height,
|
|
33
|
-
width
|
|
34
|
-
|
|
35
|
-
capitalizedLegend
|
|
33
|
+
width
|
|
34
|
+
// ...otherProps
|
|
36
35
|
} = _ref;
|
|
37
36
|
const allYLabels = yKeys.map(key => ({
|
|
38
37
|
label: key,
|
|
@@ -50,8 +49,7 @@ const BarChart = _ref => {
|
|
|
50
49
|
setSelectedYLabels: setSelectedYLabels
|
|
51
50
|
})), /*#__PURE__*/React.createElement(_Common.CustomLegend, {
|
|
52
51
|
colorsArray: selectedYLabels.map(item => item.color),
|
|
53
|
-
yKeysArray: selectedYLabels.map(item => item.label)
|
|
54
|
-
capitalizedLegend: capitalizedLegend
|
|
52
|
+
yKeysArray: selectedYLabels.map(item => item.label)
|
|
55
53
|
}), /*#__PURE__*/React.createElement(_recharts.ResponsiveContainer, {
|
|
56
54
|
width: width,
|
|
57
55
|
height: height
|
|
@@ -81,7 +79,7 @@ const BarChart = _ref => {
|
|
|
81
79
|
tickLine: false
|
|
82
80
|
}), /*#__PURE__*/React.createElement(_recharts.Tooltip, {
|
|
83
81
|
content: /*#__PURE__*/React.createElement(_Common.CustomTooltipContent, {
|
|
84
|
-
|
|
82
|
+
xLabel: xLabel
|
|
85
83
|
})
|
|
86
84
|
}), selectedYLabels.map(key => /*#__PURE__*/React.createElement(_recharts.Bar, {
|
|
87
85
|
stackId: "a",
|
|
@@ -7,7 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
10
|
-
var _utils = require("../../../../utils");
|
|
11
10
|
require("./styles.scss");
|
|
12
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
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); }
|
|
@@ -20,19 +19,19 @@ const CustomLegend = _ref => {
|
|
|
20
19
|
className: userClassName,
|
|
21
20
|
colorsArray,
|
|
22
21
|
yKeysArray,
|
|
23
|
-
orientation,
|
|
24
|
-
getLegendItemTitle,
|
|
25
|
-
getLegendItemSubtitle,
|
|
26
22
|
capitalizedLegend
|
|
27
23
|
} = _ref;
|
|
24
|
+
const capitalizeWord = word => {
|
|
25
|
+
if (!capitalizedLegend) return word;
|
|
26
|
+
const wordsToCapitalize = ['average', 'best', 'worst'];
|
|
27
|
+
return word.split(' ').map(part => wordsToCapitalize.includes(part.toLowerCase()) ? part.charAt(0).toUpperCase() + part.slice(1).toLowerCase() : part).join(' ');
|
|
28
|
+
};
|
|
28
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
30
|
id: id,
|
|
30
|
-
className: [baseClassName, componentClassName, userClassName
|
|
31
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
31
32
|
}, yKeysArray.map((key, index) => /*#__PURE__*/React.createElement("div", {
|
|
32
33
|
key: key,
|
|
33
34
|
className: "item"
|
|
34
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
-
className: "title"
|
|
36
35
|
}, /*#__PURE__*/React.createElement("span", {
|
|
37
36
|
className: "dot",
|
|
38
37
|
style: {
|
|
@@ -40,9 +39,7 @@ const CustomLegend = _ref => {
|
|
|
40
39
|
}
|
|
41
40
|
}), /*#__PURE__*/React.createElement("span", {
|
|
42
41
|
className: "text"
|
|
43
|
-
},
|
|
44
|
-
className: "sub-title"
|
|
45
|
-
}, getLegendItemSubtitle(key)))));
|
|
42
|
+
}, capitalizeWord(key)))));
|
|
46
43
|
};
|
|
47
44
|
CustomLegend.propTypes = {
|
|
48
45
|
/**
|
|
@@ -61,28 +58,12 @@ CustomLegend.propTypes = {
|
|
|
61
58
|
* Array of keys for the y-axis data.
|
|
62
59
|
*/
|
|
63
60
|
yKeysArray: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
64
|
-
/**
|
|
65
|
-
* The orientation of the Legend
|
|
66
|
-
*/
|
|
67
|
-
orientation: _propTypes.default.oneOf(['vertical', 'horizontal']),
|
|
68
|
-
/**
|
|
69
|
-
* The function to get the legendItemKey
|
|
70
|
-
*/
|
|
71
|
-
getLegendItemTitle: _propTypes.default.func,
|
|
72
|
-
/**
|
|
73
|
-
* The function to get legend children
|
|
74
|
-
*/
|
|
75
|
-
getLegendItemSubtitle: _propTypes.default.func,
|
|
76
61
|
/**
|
|
77
62
|
* Flag on whether to capitalize legend keys
|
|
78
63
|
*/
|
|
79
64
|
capitalizedLegend: _propTypes.default.bool
|
|
80
65
|
};
|
|
81
66
|
CustomLegend.defaultProps = {
|
|
82
|
-
orientation: 'horizontal',
|
|
83
|
-
getLegendItemTitle: key => key,
|
|
84
|
-
/* eslint-disable no-unused-vars */
|
|
85
|
-
getLegendItemSubtitle: () => {},
|
|
86
67
|
capitalizedLegend: false
|
|
87
68
|
};
|
|
88
69
|
var _default = exports.default = CustomLegend;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
@use "@pareto-engineering/bem";
|
|
2
2
|
|
|
3
3
|
$default-padding: 1rem;
|
|
4
|
-
$default-margin: 1rem;
|
|
5
4
|
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
6
5
|
$default-border-radius: .25rem;
|
|
7
6
|
$default-legend-gap: .625rem;
|
|
@@ -9,59 +8,33 @@ $default-legend-padding: calc($default-padding * .125) calc($default-padding * .
|
|
|
9
8
|
$default-legend-dot-width: .5rem;
|
|
10
9
|
$default-legend-dot-height: .5rem;
|
|
11
10
|
$default-legend-dot-margin-right: .3125rem;
|
|
12
|
-
$default-box-shadow: 0 4px 16px 0 var(--soft-shadow);
|
|
13
11
|
|
|
14
12
|
.#{bem.$base} {
|
|
15
13
|
&.custom-legend {
|
|
14
|
+
display: flex;
|
|
16
15
|
gap: $default-legend-gap;
|
|
17
16
|
justify-content: flex-end;
|
|
18
17
|
padding-bottom: $default-padding;
|
|
19
18
|
padding-right: calc($default-padding * .25);
|
|
20
19
|
|
|
21
|
-
&.vertical {
|
|
22
|
-
display: block;
|
|
23
|
-
margin-right: calc($default-margin * 2);
|
|
24
|
-
min-width: fit-content;
|
|
25
|
-
|
|
26
|
-
.item {
|
|
27
|
-
box-shadow: $default-box-shadow;
|
|
28
|
-
padding-top: $default-padding;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.horizontal {
|
|
33
|
-
display: flex;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
20
|
.item {
|
|
21
|
+
align-items: center;
|
|
37
22
|
border-radius: $default-border-radius;
|
|
23
|
+
display: flex;
|
|
38
24
|
padding: $default-legend-padding;
|
|
25
|
+
}
|
|
39
26
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
height: $default-legend-dot-height;
|
|
48
|
-
margin-right: $default-legend-dot-margin-right;
|
|
49
|
-
width: $default-legend-dot-width;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.text {
|
|
53
|
-
color: var(--paragraph);
|
|
54
|
-
font-size: calc($default-text-font-size * .75);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
27
|
+
.dot {
|
|
28
|
+
border-radius: 50%;
|
|
29
|
+
display: inline-block;
|
|
30
|
+
height: $default-legend-dot-height;
|
|
31
|
+
margin-right: $default-legend-dot-margin-right;
|
|
32
|
+
width: $default-legend-dot-width;
|
|
33
|
+
}
|
|
57
34
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
font-size: calc($default-text-font-size * 1.2);
|
|
62
|
-
font-weight: 500;
|
|
63
|
-
justify-content: flex-end;
|
|
64
|
-
}
|
|
35
|
+
.text {
|
|
36
|
+
color: var(--paragraph);
|
|
37
|
+
font-size: calc($default-text-font-size * .75);
|
|
65
38
|
}
|
|
66
39
|
}
|
|
67
40
|
}
|
|
@@ -18,23 +18,13 @@ const CustomTooltipContent = _ref => {
|
|
|
18
18
|
let {
|
|
19
19
|
id,
|
|
20
20
|
className: userClassName,
|
|
21
|
+
xLabel,
|
|
21
22
|
dateFormat,
|
|
22
23
|
isTimeFormat,
|
|
23
|
-
isDateValue,
|
|
24
24
|
active,
|
|
25
25
|
payload,
|
|
26
26
|
label
|
|
27
27
|
} = _ref;
|
|
28
|
-
const formatLabelValue = value => {
|
|
29
|
-
if (isTimeFormat) {
|
|
30
|
-
return (0, _utils.formatTime)(value);
|
|
31
|
-
}
|
|
32
|
-
if (typeof value === 'number') {
|
|
33
|
-
if (Number.isInteger(value)) return value;
|
|
34
|
-
return value.toFixed(2);
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
};
|
|
38
28
|
if (active && payload && payload.length) {
|
|
39
29
|
const newPayload = payload.filter(item => item.name !== 'bounds');
|
|
40
30
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -42,14 +32,14 @@ const CustomTooltipContent = _ref => {
|
|
|
42
32
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
43
33
|
}, /*#__PURE__*/React.createElement("p", {
|
|
44
34
|
className: "label"
|
|
45
|
-
},
|
|
35
|
+
}, `${xLabel}: ${(0, _utils.formatDate)(label, dateFormat)}`), newPayload.map(entry => /*#__PURE__*/React.createElement("p", {
|
|
46
36
|
className: "label",
|
|
47
37
|
key: `${entry.name}`,
|
|
48
38
|
style: {
|
|
49
39
|
color: entry.color,
|
|
50
40
|
textTransform: 'capitalize'
|
|
51
41
|
}
|
|
52
|
-
}, `${(0, _utils.
|
|
42
|
+
}, `${entry.name}: ${isTimeFormat ? (0, _utils.formatTime)(entry.value) : entry.value}`)));
|
|
53
43
|
}
|
|
54
44
|
return null;
|
|
55
45
|
};
|
|
@@ -62,6 +52,10 @@ CustomTooltipContent.propTypes = {
|
|
|
62
52
|
* Additional class names for the dropdown component.
|
|
63
53
|
*/
|
|
64
54
|
className: _propTypes.default.string,
|
|
55
|
+
/**
|
|
56
|
+
* The label for the x-axis.
|
|
57
|
+
*/
|
|
58
|
+
xLabel: _propTypes.default.string,
|
|
65
59
|
/**
|
|
66
60
|
* Flag on whether it is a timeformat or not
|
|
67
61
|
*/
|
|
@@ -70,10 +64,6 @@ CustomTooltipContent.propTypes = {
|
|
|
70
64
|
* The type of format for the datetime value
|
|
71
65
|
*/
|
|
72
66
|
dateFormat: _propTypes.default.oneOf(Object.values(_utils.DATE_FORMATS)),
|
|
73
|
-
/**
|
|
74
|
-
* Flag on whether the label is a date value or not
|
|
75
|
-
*/
|
|
76
|
-
isDateValue: _propTypes.default.bool,
|
|
77
67
|
/**
|
|
78
68
|
* If set true, the tooltip is displayed.
|
|
79
69
|
* If set false, the tooltip is hidden, usually calculated internally.
|
|
@@ -91,7 +81,6 @@ CustomTooltipContent.propTypes = {
|
|
|
91
81
|
};
|
|
92
82
|
CustomTooltipContent.defaultProps = {
|
|
93
83
|
isTimeFormat: false,
|
|
94
|
-
isDateValue: true,
|
|
95
84
|
dateFormat: _utils.DATE_FORMATS.HUMAN_READABLE
|
|
96
85
|
};
|
|
97
86
|
var _default = exports.default = CustomTooltipContent;
|
|
@@ -7,13 +7,14 @@ exports.default = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
10
|
-
var _utils = require("../../../../utils");
|
|
11
10
|
require("./styles.scss");
|
|
12
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
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); }
|
|
14
13
|
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; }
|
|
15
14
|
// DropdownStatus.js
|
|
16
15
|
|
|
16
|
+
// Local Definitions
|
|
17
|
+
|
|
17
18
|
const baseClassName = _exports.default.base;
|
|
18
19
|
const componentClassName = 'y-labels-dropdown';
|
|
19
20
|
const YLabelsDropDown = _ref => {
|
|
@@ -55,7 +56,7 @@ const YLabelsDropDown = _ref => {
|
|
|
55
56
|
style: {
|
|
56
57
|
backgroundColor: item.color
|
|
57
58
|
}
|
|
58
|
-
}),
|
|
59
|
+
}), item.label, selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
|
|
59
60
|
className: "icon checkmark"
|
|
60
61
|
}, "I")))));
|
|
61
62
|
};
|
|
@@ -92,6 +93,6 @@ YLabelsDropDown.propTypes = {
|
|
|
92
93
|
}))
|
|
93
94
|
};
|
|
94
95
|
YLabelsDropDown.defaultProps = {
|
|
95
|
-
placeholder: '
|
|
96
|
+
placeholder: 'Submission status'
|
|
96
97
|
};
|
|
97
98
|
var _default = exports.default = YLabelsDropDown;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
@use "@pareto-engineering/bem";
|
|
2
2
|
|
|
3
3
|
$default-margin: 1rem;
|
|
4
|
-
$default-border:
|
|
5
|
-
$default-border-radius: var(--theme-default-input-border-radius);
|
|
4
|
+
$default-border-radius: .25rem;
|
|
6
5
|
$default-padding: 1rem;
|
|
7
6
|
$default-width: 15rem;
|
|
8
7
|
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
@@ -17,9 +16,9 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
|
|
|
17
16
|
|
|
18
17
|
.dropdown-button {
|
|
19
18
|
align-items: center;
|
|
20
|
-
background-color: var(--background-
|
|
21
|
-
border:
|
|
22
|
-
border-radius:
|
|
19
|
+
background-color: var(--soft-background-inputs);
|
|
20
|
+
border: none;
|
|
21
|
+
border-radius: $default-border-radius;
|
|
23
22
|
color: var(--hard-paragraph);
|
|
24
23
|
cursor: pointer;
|
|
25
24
|
display: flex;
|
|
@@ -54,8 +53,8 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
|
|
|
54
53
|
|
|
55
54
|
.dropdown-item {
|
|
56
55
|
align-items: center;
|
|
57
|
-
border-radius:
|
|
58
|
-
color: var(--paragraph);
|
|
56
|
+
border-radius: $default-border-radius;
|
|
57
|
+
color: var(--hard-paragraph);
|
|
59
58
|
cursor: pointer;
|
|
60
59
|
display: flex;
|
|
61
60
|
margin: calc($default-margin * .125);
|
|
@@ -15,12 +15,5 @@ Object.defineProperty(exports, "BarChart", {
|
|
|
15
15
|
return _BarChart.BarChart;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "PieChart", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _PieChart.PieChart;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
18
|
var _AreaChart = require("./AreaChart");
|
|
25
|
-
var _BarChart = require("./BarChart");
|
|
26
|
-
var _PieChart = require("./PieChart");
|
|
19
|
+
var _BarChart = require("./BarChart");
|
package/dist/cjs/a/index.js
CHANGED
|
@@ -123,12 +123,6 @@ Object.defineProperty(exports, "People", {
|
|
|
123
123
|
return _People.People;
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
Object.defineProperty(exports, "PieChart", {
|
|
127
|
-
enumerable: true,
|
|
128
|
-
get: function () {
|
|
129
|
-
return _Charts.PieChart;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
126
|
Object.defineProperty(exports, "Popover", {
|
|
133
127
|
enumerable: true,
|
|
134
128
|
get: function () {
|
|
@@ -67,12 +67,19 @@ const Preview = _ref => {
|
|
|
67
67
|
}, type), /*#__PURE__*/React.createElement("span", {
|
|
68
68
|
title: file.name,
|
|
69
69
|
className: "name"
|
|
70
|
-
}, file.name), isFileBroken ? /*#__PURE__*/React.createElement(_a.Tooltip, {
|
|
70
|
+
}, file.name), isFileBroken ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_a.Tooltip, {
|
|
71
71
|
description: "bulk-updates-text",
|
|
72
72
|
content: /*#__PURE__*/React.createElement("p", null, "This file doesn't have a link or the link is invalid.")
|
|
73
73
|
}, /*#__PURE__*/React.createElement("span", {
|
|
74
74
|
className: "icon x-ui-icons c-x"
|
|
75
|
-
}, "h"))
|
|
75
|
+
}, "h")), writeOnly && /*#__PURE__*/React.createElement(_b.Button, {
|
|
76
|
+
color: "ui-icons",
|
|
77
|
+
isCompact: true,
|
|
78
|
+
isSimple: true,
|
|
79
|
+
onClick: () => handleDelete()
|
|
80
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: "icon"
|
|
82
|
+
}, canDelete ? 'Y' : '9'))) : /*#__PURE__*/React.createElement(_b.Button, {
|
|
76
83
|
color: "ui-icons",
|
|
77
84
|
isCompact: true,
|
|
78
85
|
isSimple: true,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.formatTime = exports.formatDate = exports.DATE_FORMATS = void 0;
|
|
7
7
|
const DATE_FORMATS = exports.DATE_FORMATS = {
|
|
8
8
|
HUMAN_READABLE: 'human_readable',
|
|
9
9
|
TIME: 'time',
|
|
@@ -43,9 +43,6 @@ const formatTime = seconds => {
|
|
|
43
43
|
if (hours > 0) parts.push(`${hours}h`);
|
|
44
44
|
if (minutes > 0 || hours > 0 && remainingSeconds > 0) parts.push(`${minutes}m`);
|
|
45
45
|
if (remainingSeconds > 0) parts.push(`${remainingSeconds}s`);
|
|
46
|
-
|
|
47
|
-
// Cater for decimal seconds
|
|
48
|
-
if (parts.length === 0) return '0s';
|
|
49
46
|
return parts.join(' ');
|
|
50
47
|
};
|
|
51
48
|
exports.formatTime = formatTime;
|
|
@@ -111,9 +108,4 @@ const formatDate = function (input) {
|
|
|
111
108
|
return 'Invalid Date';
|
|
112
109
|
}
|
|
113
110
|
};
|
|
114
|
-
exports.formatDate = formatDate;
|
|
115
|
-
const snakeCaseToTitleCase = word => {
|
|
116
|
-
const result = word.replace(/([A-Z])/g, ' $1');
|
|
117
|
-
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
118
|
-
};
|
|
119
|
-
exports.snakeCaseToTitleCase = snakeCaseToTitleCase;
|
|
111
|
+
exports.formatDate = formatDate;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "formatTime", {
|
|
|
21
21
|
return _formatting.formatTime;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "snakeCaseToTitleCase", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _formatting.snakeCaseToTitleCase;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
24
|
Object.defineProperty(exports, "useDynamicPosition", {
|
|
31
25
|
enumerable: true,
|
|
32
26
|
get: function () {
|
|
@@ -30,6 +30,17 @@ const AreaChart = ({
|
|
|
30
30
|
color: colors[yKeys.indexOf(key)]
|
|
31
31
|
}));
|
|
32
32
|
const [selectedYLabels, setSelectedYLabels] = useState(allYLabels);
|
|
33
|
+
const processedData = data.map(item => {
|
|
34
|
+
const yValues = yKeys.map(key => item[key]);
|
|
35
|
+
const lowerBound = Math.min(...yValues);
|
|
36
|
+
const upperBound = Math.max(...yValues);
|
|
37
|
+
const margin = (upperBound - lowerBound) * 0.1;
|
|
38
|
+
return {
|
|
39
|
+
...item,
|
|
40
|
+
bounds: [lowerBound - margin, upperBound + margin],
|
|
41
|
+
isTimeFormat
|
|
42
|
+
};
|
|
43
|
+
});
|
|
33
44
|
const yAxisBounds = () => {
|
|
34
45
|
const yValues = data.map(item => yKeys.map(key => item[key]));
|
|
35
46
|
const min = Math.min(...yValues.flat());
|
|
@@ -54,7 +65,7 @@ const AreaChart = ({
|
|
|
54
65
|
width: width,
|
|
55
66
|
height: height
|
|
56
67
|
}, /*#__PURE__*/React.createElement(RechartsAreaChart, {
|
|
57
|
-
data:
|
|
68
|
+
data: processedData
|
|
58
69
|
}, /*#__PURE__*/React.createElement(CartesianGrid, {
|
|
59
70
|
strokeDasharray: "3 3"
|
|
60
71
|
}), /*#__PURE__*/React.createElement(XAxis, {
|
|
@@ -95,8 +106,7 @@ const AreaChart = ({
|
|
|
95
106
|
}
|
|
96
107
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
97
108
|
content: /*#__PURE__*/React.createElement(CustomTooltipContent, {
|
|
98
|
-
|
|
99
|
-
isTimeFormat: isTimeFormat
|
|
109
|
+
xLabel: xLabel
|
|
100
110
|
})
|
|
101
111
|
}), filled && /*#__PURE__*/React.createElement(Area, {
|
|
102
112
|
id: "bounds",
|
|
@@ -21,9 +21,8 @@ const BarChart = ({
|
|
|
21
21
|
yLabel,
|
|
22
22
|
colors,
|
|
23
23
|
height,
|
|
24
|
-
width
|
|
25
|
-
|
|
26
|
-
capitalizedLegend
|
|
24
|
+
width
|
|
25
|
+
// ...otherProps
|
|
27
26
|
}) => {
|
|
28
27
|
const allYLabels = yKeys.map(key => ({
|
|
29
28
|
label: key,
|
|
@@ -41,8 +40,7 @@ const BarChart = ({
|
|
|
41
40
|
setSelectedYLabels: setSelectedYLabels
|
|
42
41
|
})), /*#__PURE__*/React.createElement(CustomLegend, {
|
|
43
42
|
colorsArray: selectedYLabels.map(item => item.color),
|
|
44
|
-
yKeysArray: selectedYLabels.map(item => item.label)
|
|
45
|
-
capitalizedLegend: capitalizedLegend
|
|
43
|
+
yKeysArray: selectedYLabels.map(item => item.label)
|
|
46
44
|
}), /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
47
45
|
width: width,
|
|
48
46
|
height: height
|
|
@@ -72,7 +70,7 @@ const BarChart = ({
|
|
|
72
70
|
tickLine: false
|
|
73
71
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
74
72
|
content: /*#__PURE__*/React.createElement(CustomTooltipContent, {
|
|
75
|
-
|
|
73
|
+
xLabel: xLabel
|
|
76
74
|
})
|
|
77
75
|
}), selectedYLabels.map(key => /*#__PURE__*/React.createElement(Bar, {
|
|
78
76
|
stackId: "a",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styleNames from '@pareto-engineering/bem/exports';
|
|
4
|
-
import { snakeCaseToTitleCase } from "../../../../utils";
|
|
5
4
|
import "./styles.scss";
|
|
6
5
|
const baseClassName = styleNames.base;
|
|
7
6
|
const componentClassName = 'custom-legend';
|
|
@@ -10,28 +9,28 @@ const CustomLegend = ({
|
|
|
10
9
|
className: userClassName,
|
|
11
10
|
colorsArray,
|
|
12
11
|
yKeysArray,
|
|
13
|
-
orientation,
|
|
14
|
-
getLegendItemTitle,
|
|
15
|
-
getLegendItemSubtitle,
|
|
16
12
|
capitalizedLegend
|
|
17
|
-
}) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
13
|
+
}) => {
|
|
14
|
+
const capitalizeWord = word => {
|
|
15
|
+
if (!capitalizedLegend) return word;
|
|
16
|
+
const wordsToCapitalize = ['average', 'best', 'worst'];
|
|
17
|
+
return word.split(' ').map(part => wordsToCapitalize.includes(part.toLowerCase()) ? part.charAt(0).toUpperCase() + part.slice(1).toLowerCase() : part).join(' ');
|
|
18
|
+
};
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
id: id,
|
|
21
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
22
|
+
}, yKeysArray.map((key, index) => /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
key: key,
|
|
24
|
+
className: "item"
|
|
25
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: "dot",
|
|
27
|
+
style: {
|
|
28
|
+
backgroundColor: colorsArray[index]
|
|
29
|
+
}
|
|
30
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
31
|
+
className: "text"
|
|
32
|
+
}, capitalizeWord(key)))));
|
|
33
|
+
};
|
|
35
34
|
CustomLegend.propTypes = {
|
|
36
35
|
/**
|
|
37
36
|
* The id of the dropdown component.
|
|
@@ -49,28 +48,12 @@ CustomLegend.propTypes = {
|
|
|
49
48
|
* Array of keys for the y-axis data.
|
|
50
49
|
*/
|
|
51
50
|
yKeysArray: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
52
|
-
/**
|
|
53
|
-
* The orientation of the Legend
|
|
54
|
-
*/
|
|
55
|
-
orientation: PropTypes.oneOf(['vertical', 'horizontal']),
|
|
56
|
-
/**
|
|
57
|
-
* The function to get the legendItemKey
|
|
58
|
-
*/
|
|
59
|
-
getLegendItemTitle: PropTypes.func,
|
|
60
|
-
/**
|
|
61
|
-
* The function to get legend children
|
|
62
|
-
*/
|
|
63
|
-
getLegendItemSubtitle: PropTypes.func,
|
|
64
51
|
/**
|
|
65
52
|
* Flag on whether to capitalize legend keys
|
|
66
53
|
*/
|
|
67
54
|
capitalizedLegend: PropTypes.bool
|
|
68
55
|
};
|
|
69
56
|
CustomLegend.defaultProps = {
|
|
70
|
-
orientation: 'horizontal',
|
|
71
|
-
getLegendItemTitle: key => key,
|
|
72
|
-
/* eslint-disable no-unused-vars */
|
|
73
|
-
getLegendItemSubtitle: () => {},
|
|
74
57
|
capitalizedLegend: false
|
|
75
58
|
};
|
|
76
59
|
export default CustomLegend;
|