@pareto-engineering/design-system 4.12.0 → 5.0.1
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/{AreaChart → Charts/AreaChart}/AreaChart.js +89 -63
- package/dist/cjs/a/Charts/AreaChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/BarChart/BarChart.js +135 -0
- package/dist/cjs/a/Charts/BarChart/index.js +13 -0
- package/dist/cjs/a/Charts/BarChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +69 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/index.js +13 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +40 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +86 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/index.js +13 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +98 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/index.js +13 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +88 -0
- package/dist/cjs/a/Charts/Common/index.js +26 -0
- package/dist/cjs/a/Charts/index.js +19 -0
- package/dist/cjs/a/Tooltip/styles.scss +1 -1
- package/dist/cjs/a/index.js +8 -2
- package/dist/cjs/f/FormInput/FormInput.js +6 -0
- package/dist/cjs/f/fields/FileUpload/FileUpload.js +18 -4
- package/dist/cjs/f/fields/LatexPreviewInput/LatexPreviewInput.js +78 -0
- package/dist/cjs/f/fields/LatexPreviewInput/convertLatexToHtml.js +46 -0
- package/dist/cjs/f/fields/LatexPreviewInput/index.js +20 -0
- package/dist/cjs/f/fields/LatexPreviewInput/styles.scss +24 -0
- package/dist/cjs/f/fields/index.js +13 -0
- package/dist/cjs/g/FormBuilder/FormBuilder.js +3 -6
- package/dist/cjs/g/FormBuilder/common/Builder/Builder.js +1 -3
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
- package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
- package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +2 -4
- package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -10
- package/dist/cjs/utils/formatting.js +111 -0
- package/dist/cjs/utils/index.js +20 -1
- package/dist/es/a/{AreaChart → Charts/AreaChart}/AreaChart.js +88 -59
- package/dist/es/a/Charts/AreaChart/styles.scss +48 -0
- package/dist/es/a/Charts/BarChart/BarChart.js +126 -0
- package/dist/es/a/Charts/BarChart/index.js +1 -0
- package/dist/es/a/Charts/BarChart/styles.scss +48 -0
- package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +59 -0
- package/dist/es/a/Charts/Common/CustomLegend/index.js +1 -0
- package/dist/es/a/Charts/Common/CustomLegend/styles.scss +40 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +76 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/index.js +1 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +88 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/index.js +1 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +88 -0
- package/dist/es/a/Charts/Common/index.js +3 -0
- package/dist/es/a/Charts/index.js +2 -0
- package/dist/es/a/Tooltip/styles.scss +1 -1
- package/dist/es/a/index.js +1 -1
- package/dist/es/f/FormInput/FormInput.js +7 -1
- package/dist/es/f/fields/FileUpload/FileUpload.js +18 -4
- package/dist/es/f/fields/LatexPreviewInput/LatexPreviewInput.js +70 -0
- package/dist/es/f/fields/LatexPreviewInput/convertLatexToHtml.js +31 -0
- package/dist/es/f/fields/LatexPreviewInput/index.js +3 -0
- package/dist/es/f/fields/LatexPreviewInput/styles.scss +24 -0
- package/dist/es/f/fields/index.js +1 -0
- package/dist/es/g/FormBuilder/FormBuilder.js +3 -6
- package/dist/es/g/FormBuilder/common/Builder/Builder.js +1 -3
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
- package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
- package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +2 -4
- package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +32 -42
- package/dist/es/utils/formatting.js +102 -0
- package/dist/es/utils/index.js +2 -1
- package/jest.config.js +3 -0
- package/package.json +13 -9
- package/src/stories/a/BarChart.stories.jsx +89 -0
- package/src/ui/a/{AreaChart → Charts/AreaChart}/AreaChart.jsx +109 -54
- package/src/ui/a/Charts/AreaChart/styles.scss +48 -0
- package/src/ui/a/Charts/BarChart/BarChart.jsx +165 -0
- package/src/ui/a/Charts/BarChart/index.js +1 -0
- package/src/ui/a/Charts/BarChart/styles.scss +48 -0
- package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +84 -0
- package/src/ui/a/Charts/Common/CustomLegend/index.js +1 -0
- package/src/ui/a/Charts/Common/CustomLegend/styles.scss +40 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +105 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/index.js +1 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
- package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +121 -0
- package/src/ui/a/Charts/Common/YLabelsDropDown/index.js +1 -0
- package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +88 -0
- package/src/ui/a/Charts/Common/index.js +3 -0
- package/src/ui/a/Charts/index.js +2 -0
- package/src/ui/a/Tooltip/styles.scss +1 -1
- package/src/ui/a/index.js +1 -1
- package/src/ui/f/FormInput/FormInput.jsx +11 -0
- package/src/ui/f/fields/FileUpload/FileUpload.jsx +24 -4
- package/src/ui/f/fields/LatexPreviewInput/LatexPreviewInput.jsx +91 -0
- package/src/ui/f/fields/LatexPreviewInput/convertLatexToHtml.jsx +38 -0
- package/src/ui/f/fields/LatexPreviewInput/index.js +3 -0
- package/src/ui/f/fields/LatexPreviewInput/styles.scss +24 -0
- package/src/ui/f/fields/index.js +4 -0
- package/src/ui/g/FormBuilder/FormBuilder.jsx +0 -3
- package/src/ui/g/FormBuilder/common/Builder/Builder.jsx +0 -2
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +4 -7
- package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +0 -2
- package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +0 -2
- package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +49 -64
- package/src/ui/utils/formatting.js +125 -0
- package/src/ui/utils/index.js +1 -0
- package/tests/__snapshots__/Storyshots.test.js.snap +1257 -62
- package/tests/emptyMock.js +3 -0
- package/tests/mockTextEncoder.js +7 -0
- package/tests/test-setup.js +7 -0
- package/dist/cjs/a/AreaChart/styles.scss +0 -89
- package/dist/es/a/AreaChart/styles.scss +0 -89
- package/src/ui/a/AreaChart/styles.scss +0 -89
- /package/dist/cjs/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
- /package/dist/es/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
- /package/src/ui/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { BarChart as RechartsBarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
5
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
6
|
+
import { CustomLegend, CustomTooltipContent, YLabelsDropDown } from "../Common";
|
|
7
|
+
import "./styles.scss";
|
|
8
|
+
|
|
9
|
+
// Local Definitions
|
|
10
|
+
|
|
11
|
+
const baseClassName = styleNames.base;
|
|
12
|
+
const componentClassName = 'bar-chart';
|
|
13
|
+
const BarChart = ({
|
|
14
|
+
id,
|
|
15
|
+
className: userClassName,
|
|
16
|
+
data,
|
|
17
|
+
title,
|
|
18
|
+
xKey,
|
|
19
|
+
yKeys,
|
|
20
|
+
xLabel,
|
|
21
|
+
yLabel,
|
|
22
|
+
colors,
|
|
23
|
+
height,
|
|
24
|
+
width
|
|
25
|
+
// ...otherProps
|
|
26
|
+
}) => {
|
|
27
|
+
const allYLabels = yKeys.map(key => ({
|
|
28
|
+
label: key,
|
|
29
|
+
color: colors[yKeys.indexOf(key)]
|
|
30
|
+
}));
|
|
31
|
+
const [selectedYLabels, setSelectedYLabels] = useState(allYLabels);
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
id: id,
|
|
34
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
35
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "chart-header"
|
|
37
|
+
}, /*#__PURE__*/React.createElement("h3", null, title), /*#__PURE__*/React.createElement(YLabelsDropDown, {
|
|
38
|
+
allYLabels: allYLabels,
|
|
39
|
+
selectedYLabels: selectedYLabels,
|
|
40
|
+
setSelectedYLabels: setSelectedYLabels
|
|
41
|
+
})), /*#__PURE__*/React.createElement(CustomLegend, {
|
|
42
|
+
colorsArray: selectedYLabels.map(item => item.color),
|
|
43
|
+
yKeysArray: selectedYLabels.map(item => item.label)
|
|
44
|
+
}), /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
45
|
+
width: width,
|
|
46
|
+
height: height
|
|
47
|
+
}, /*#__PURE__*/React.createElement(RechartsBarChart, {
|
|
48
|
+
data: data
|
|
49
|
+
}, /*#__PURE__*/React.createElement(CartesianGrid, {
|
|
50
|
+
vertical: false
|
|
51
|
+
}), /*#__PURE__*/React.createElement(XAxis, {
|
|
52
|
+
dataKey: xKey,
|
|
53
|
+
label: {
|
|
54
|
+
value: xLabel,
|
|
55
|
+
position: 'insideBottom',
|
|
56
|
+
offset: -5
|
|
57
|
+
} // Adjusted offset for padding
|
|
58
|
+
,
|
|
59
|
+
axisLine: false,
|
|
60
|
+
tickLine: false,
|
|
61
|
+
tickCount: 3
|
|
62
|
+
}), /*#__PURE__*/React.createElement(YAxis, {
|
|
63
|
+
label: {
|
|
64
|
+
value: yLabel,
|
|
65
|
+
angle: -90,
|
|
66
|
+
position: 'insideLeft',
|
|
67
|
+
offset: 15
|
|
68
|
+
},
|
|
69
|
+
axisLine: false,
|
|
70
|
+
tickLine: false
|
|
71
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
72
|
+
content: /*#__PURE__*/React.createElement(CustomTooltipContent, {
|
|
73
|
+
xLabel: xLabel
|
|
74
|
+
})
|
|
75
|
+
}), selectedYLabels.map(key => /*#__PURE__*/React.createElement(Bar, {
|
|
76
|
+
stackId: "a",
|
|
77
|
+
id: key.label,
|
|
78
|
+
key: key.label,
|
|
79
|
+
dataKey: key.label,
|
|
80
|
+
fill: key.color
|
|
81
|
+
})))));
|
|
82
|
+
};
|
|
83
|
+
BarChart.propTypes = {
|
|
84
|
+
/**
|
|
85
|
+
* Array of data objects to be displayed in the chart.
|
|
86
|
+
*/
|
|
87
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
88
|
+
data: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
89
|
+
/**
|
|
90
|
+
* Title of the chart.
|
|
91
|
+
*/
|
|
92
|
+
title: PropTypes.string.isRequired,
|
|
93
|
+
/**
|
|
94
|
+
* Key for the x-axis data.
|
|
95
|
+
*/
|
|
96
|
+
xKey: PropTypes.string.isRequired,
|
|
97
|
+
/**
|
|
98
|
+
* Array of keys for the y-axis data.
|
|
99
|
+
*/
|
|
100
|
+
yKeys: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
101
|
+
/**
|
|
102
|
+
* Label for the x-axis.
|
|
103
|
+
*/
|
|
104
|
+
xLabel: PropTypes.string,
|
|
105
|
+
/**
|
|
106
|
+
* Label for the y-axis.
|
|
107
|
+
*/
|
|
108
|
+
yLabel: PropTypes.string,
|
|
109
|
+
/**
|
|
110
|
+
* Array of colors corresponding to the y-axis data keys.
|
|
111
|
+
*/
|
|
112
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
113
|
+
/**
|
|
114
|
+
* Height of the chart.
|
|
115
|
+
*/
|
|
116
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
117
|
+
/**
|
|
118
|
+
* Width of the chart.
|
|
119
|
+
*/
|
|
120
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
121
|
+
};
|
|
122
|
+
BarChart.defaultProps = {
|
|
123
|
+
width: '100%',
|
|
124
|
+
height: 300
|
|
125
|
+
};
|
|
126
|
+
export default BarChart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BarChart } from "./BarChart";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-margin: 1rem;
|
|
4
|
+
$default-padding: 1rem;
|
|
5
|
+
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
6
|
+
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
7
|
+
|
|
8
|
+
.#{bem.$base} {
|
|
9
|
+
&.bar-chart {
|
|
10
|
+
background-color: var(--background-far);
|
|
11
|
+
border-radius: var(--theme-default-border-radius);
|
|
12
|
+
box-shadow: $default-box-shadow;
|
|
13
|
+
margin: $default-margin 0;
|
|
14
|
+
padding: $default-padding;
|
|
15
|
+
|
|
16
|
+
.chart-header {
|
|
17
|
+
align-items: center;
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
margin-bottom: $default-margin;
|
|
21
|
+
|
|
22
|
+
h3 {
|
|
23
|
+
color: var(--subtitle);
|
|
24
|
+
margin: calc($default-margin / 5);
|
|
25
|
+
text-align: left;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* stylelint-disable selector-max-compound-selectors -- nested elements */
|
|
30
|
+
.recharts-wrapper {
|
|
31
|
+
.recharts-surface {
|
|
32
|
+
.recharts-cartesian-grid line {
|
|
33
|
+
stroke: var(--ui-lines);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.recharts-text {
|
|
37
|
+
fill: var(--soft-paragraph);
|
|
38
|
+
font-size: calc($default-text-font-size * .75);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.recharts-text.recharts-label {
|
|
42
|
+
fill: var(--paragraph);
|
|
43
|
+
font-size: $default-text-font-size;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
4
|
+
import "./styles.scss";
|
|
5
|
+
const baseClassName = styleNames.base;
|
|
6
|
+
const componentClassName = 'custom-legend';
|
|
7
|
+
const CustomLegend = ({
|
|
8
|
+
id,
|
|
9
|
+
className: userClassName,
|
|
10
|
+
colorsArray,
|
|
11
|
+
yKeysArray,
|
|
12
|
+
capitalizedLegend
|
|
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
|
+
};
|
|
34
|
+
CustomLegend.propTypes = {
|
|
35
|
+
/**
|
|
36
|
+
* The id of the dropdown component.
|
|
37
|
+
*/
|
|
38
|
+
id: PropTypes.string,
|
|
39
|
+
/**
|
|
40
|
+
* Additional class names for the dropdown component.
|
|
41
|
+
*/
|
|
42
|
+
className: PropTypes.string,
|
|
43
|
+
/**
|
|
44
|
+
* Array of colors corresponding to the y-axis data keys.
|
|
45
|
+
*/
|
|
46
|
+
colorsArray: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
47
|
+
/**
|
|
48
|
+
* Array of keys for the y-axis data.
|
|
49
|
+
*/
|
|
50
|
+
yKeysArray: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
51
|
+
/**
|
|
52
|
+
* Flag on whether to capitalize legend keys
|
|
53
|
+
*/
|
|
54
|
+
capitalizedLegend: PropTypes.bool
|
|
55
|
+
};
|
|
56
|
+
CustomLegend.defaultProps = {
|
|
57
|
+
capitalizedLegend: false
|
|
58
|
+
};
|
|
59
|
+
export default CustomLegend;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CustomLegend } from "./CustomLegend";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-padding: 1rem;
|
|
4
|
+
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
5
|
+
$default-border-radius: .25rem;
|
|
6
|
+
$default-legend-gap: .625rem;
|
|
7
|
+
$default-legend-padding: calc($default-padding * .125) calc($default-padding * .625);
|
|
8
|
+
$default-legend-dot-width: .5rem;
|
|
9
|
+
$default-legend-dot-height: .5rem;
|
|
10
|
+
$default-legend-dot-margin-right: .3125rem;
|
|
11
|
+
|
|
12
|
+
.#{bem.$base} {
|
|
13
|
+
&.custom-legend {
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: $default-legend-gap;
|
|
16
|
+
justify-content: flex-end;
|
|
17
|
+
padding-bottom: $default-padding;
|
|
18
|
+
padding-right: calc($default-padding * .25);
|
|
19
|
+
|
|
20
|
+
.item {
|
|
21
|
+
align-items: center;
|
|
22
|
+
border-radius: $default-border-radius;
|
|
23
|
+
display: flex;
|
|
24
|
+
padding: $default-legend-padding;
|
|
25
|
+
}
|
|
26
|
+
|
|
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
|
+
}
|
|
34
|
+
|
|
35
|
+
.text {
|
|
36
|
+
color: var(--paragraph);
|
|
37
|
+
font-size: calc($default-text-font-size * .75);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
4
|
+
import { formatTime, formatDate, DATE_FORMATS } from "../../../../utils";
|
|
5
|
+
import "./styles.scss";
|
|
6
|
+
const baseClassName = styleNames.base;
|
|
7
|
+
const componentClassName = 'custom-tooltip-content';
|
|
8
|
+
const CustomTooltipContent = ({
|
|
9
|
+
id,
|
|
10
|
+
className: userClassName,
|
|
11
|
+
xLabel,
|
|
12
|
+
dateFormat,
|
|
13
|
+
isTimeFormat,
|
|
14
|
+
active,
|
|
15
|
+
payload,
|
|
16
|
+
label
|
|
17
|
+
}) => {
|
|
18
|
+
if (active && payload && payload.length) {
|
|
19
|
+
const newPayload = payload.filter(item => item.name !== 'bounds');
|
|
20
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
id: id,
|
|
22
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
23
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
24
|
+
className: "label"
|
|
25
|
+
}, `${xLabel}: ${formatDate(label, dateFormat)}`), newPayload.map(entry => /*#__PURE__*/React.createElement("p", {
|
|
26
|
+
className: "label",
|
|
27
|
+
key: `${entry.name}`,
|
|
28
|
+
style: {
|
|
29
|
+
color: entry.color,
|
|
30
|
+
textTransform: 'capitalize'
|
|
31
|
+
}
|
|
32
|
+
}, `${entry.name}: ${isTimeFormat ? formatTime(entry.value) : entry.value}`)));
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
CustomTooltipContent.propTypes = {
|
|
37
|
+
/**
|
|
38
|
+
* The id of the dropdown component.
|
|
39
|
+
*/
|
|
40
|
+
id: PropTypes.string,
|
|
41
|
+
/**
|
|
42
|
+
* Additional class names for the dropdown component.
|
|
43
|
+
*/
|
|
44
|
+
className: PropTypes.string,
|
|
45
|
+
/**
|
|
46
|
+
* The label for the x-axis.
|
|
47
|
+
*/
|
|
48
|
+
xLabel: PropTypes.string,
|
|
49
|
+
/**
|
|
50
|
+
* Flag on whether it is a timeformat or not
|
|
51
|
+
*/
|
|
52
|
+
isTimeFormat: PropTypes.bool,
|
|
53
|
+
/**
|
|
54
|
+
* The type of format for the datetime value
|
|
55
|
+
*/
|
|
56
|
+
dateFormat: PropTypes.oneOf(Object.values(DATE_FORMATS)),
|
|
57
|
+
/**
|
|
58
|
+
* If set true, the tooltip is displayed.
|
|
59
|
+
* If set false, the tooltip is hidden, usually calculated internally.
|
|
60
|
+
*/
|
|
61
|
+
active: PropTypes.bool.isRequired,
|
|
62
|
+
/**
|
|
63
|
+
* The source data of the content to be displayed in the tooltip,
|
|
64
|
+
* always calculated internally and cannot be user set.
|
|
65
|
+
*/
|
|
66
|
+
payload: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
67
|
+
/**
|
|
68
|
+
*The label value which is active now, usually calculated internally.
|
|
69
|
+
*/
|
|
70
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
|
71
|
+
};
|
|
72
|
+
CustomTooltipContent.defaultProps = {
|
|
73
|
+
isTimeFormat: false,
|
|
74
|
+
dateFormat: DATE_FORMATS.HUMAN_READABLE
|
|
75
|
+
};
|
|
76
|
+
export default CustomTooltipContent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CustomTooltipContent } from "./CustomTooltipContent";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-margin: 1rem;
|
|
4
|
+
$default-padding: 1rem;
|
|
5
|
+
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
6
|
+
$default-border-radius: .25rem;
|
|
7
|
+
$default-border-line-width: .0625rem;
|
|
8
|
+
|
|
9
|
+
.#{bem.$base} {
|
|
10
|
+
&.custom-tooltip-content {
|
|
11
|
+
background-color: var(--background-far);
|
|
12
|
+
border: $default-border-line-width solid var(--ui-lines);
|
|
13
|
+
border-radius: $default-border-radius;
|
|
14
|
+
padding: calc($default-padding * .25);
|
|
15
|
+
|
|
16
|
+
.label {
|
|
17
|
+
color: var(--hard-paragraph);
|
|
18
|
+
font-size: $default-text-font-size;
|
|
19
|
+
margin: calc($default-margin * .25);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// DropdownStatus.js
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
5
|
+
import "./styles.scss";
|
|
6
|
+
|
|
7
|
+
// Local Definitions
|
|
8
|
+
|
|
9
|
+
const baseClassName = styleNames.base;
|
|
10
|
+
const componentClassName = 'y-labels-dropdown';
|
|
11
|
+
const YLabelsDropDown = ({
|
|
12
|
+
id,
|
|
13
|
+
className: userClassName,
|
|
14
|
+
placeholder,
|
|
15
|
+
selectedYLabels,
|
|
16
|
+
setSelectedYLabels,
|
|
17
|
+
allYLabels
|
|
18
|
+
}) => {
|
|
19
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
20
|
+
const toggleYLabel = yLabel => {
|
|
21
|
+
setSelectedYLabels(prev => prev.some(label => label.label === yLabel.label) ? prev.filter(label => label.label !== yLabel.label) : [...prev, yLabel]);
|
|
22
|
+
};
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
id: id,
|
|
25
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
26
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
27
|
+
className: "dropdown-button",
|
|
28
|
+
onClick: () => setIsOpen(!isOpen),
|
|
29
|
+
type: "button"
|
|
30
|
+
}, placeholder, /*#__PURE__*/React.createElement("span", {
|
|
31
|
+
className: `icon ${isOpen ? styleNames.modifierOpen : ''}`
|
|
32
|
+
}, "W")), /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: `dropdown-content ${isOpen ? styleNames.modifierOpen : ''}`
|
|
34
|
+
}, allYLabels.map(item =>
|
|
35
|
+
/*#__PURE__*/
|
|
36
|
+
// eslint-disable-next-line max-len
|
|
37
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
|
|
38
|
+
React.createElement("div", {
|
|
39
|
+
key: item.label,
|
|
40
|
+
className: `dropdown-item ${selectedYLabels.some(label => label.label === item.label) ? styleNames.modifierActive : ''}`
|
|
41
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
42
|
+
,
|
|
43
|
+
onClick: () => toggleYLabel(item)
|
|
44
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "status-dot",
|
|
46
|
+
style: {
|
|
47
|
+
backgroundColor: item.color
|
|
48
|
+
}
|
|
49
|
+
}), item.label, selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
|
|
50
|
+
className: "icon checkmark"
|
|
51
|
+
}, "I")))));
|
|
52
|
+
};
|
|
53
|
+
YLabelsDropDown.propTypes = {
|
|
54
|
+
/**
|
|
55
|
+
* The id of the dropdown component.
|
|
56
|
+
*/
|
|
57
|
+
id: PropTypes.string,
|
|
58
|
+
/**
|
|
59
|
+
* Additional class names for the dropdown component.
|
|
60
|
+
*/
|
|
61
|
+
className: PropTypes.string,
|
|
62
|
+
/**
|
|
63
|
+
* Placeholder text for the dropdown button.
|
|
64
|
+
*/
|
|
65
|
+
placeholder: PropTypes.string,
|
|
66
|
+
/**
|
|
67
|
+
* Array of selected Y labels with their corresponding colors.
|
|
68
|
+
*/
|
|
69
|
+
selectedYLabels: PropTypes.arrayOf(PropTypes.shape({
|
|
70
|
+
label: PropTypes.string,
|
|
71
|
+
color: PropTypes.string
|
|
72
|
+
})),
|
|
73
|
+
/**
|
|
74
|
+
* Function to set the selected Y labels.
|
|
75
|
+
*/
|
|
76
|
+
setSelectedYLabels: PropTypes.func,
|
|
77
|
+
/**
|
|
78
|
+
* Array of all Y labels with their corresponding colors.
|
|
79
|
+
*/
|
|
80
|
+
allYLabels: PropTypes.arrayOf(PropTypes.shape({
|
|
81
|
+
label: PropTypes.string,
|
|
82
|
+
color: PropTypes.string
|
|
83
|
+
}))
|
|
84
|
+
};
|
|
85
|
+
YLabelsDropDown.defaultProps = {
|
|
86
|
+
placeholder: 'Submission status'
|
|
87
|
+
};
|
|
88
|
+
export default YLabelsDropDown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as YLabelsDropDown } from "./YlabelsDropDown";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-margin: 1rem;
|
|
4
|
+
$default-border-radius: .25rem;
|
|
5
|
+
$default-padding: 1rem;
|
|
6
|
+
$default-width: 15rem;
|
|
7
|
+
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
8
|
+
$default-dot-width: .5rem;
|
|
9
|
+
$default-dot-height: .5rem;
|
|
10
|
+
$default-checkmark-font-size: calc(var(--s-1) * .75rem);
|
|
11
|
+
|
|
12
|
+
.#{bem.$base} {
|
|
13
|
+
&.y-labels-dropdown {
|
|
14
|
+
display: inline-block;
|
|
15
|
+
position: relative;
|
|
16
|
+
|
|
17
|
+
.dropdown-button {
|
|
18
|
+
align-items: center;
|
|
19
|
+
background-color: var(--soft-background-inputs);
|
|
20
|
+
border: none;
|
|
21
|
+
border-radius: $default-border-radius;
|
|
22
|
+
color: var(--hard-paragraph);
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
padding: calc($default-padding * .5);
|
|
27
|
+
text-align: left;
|
|
28
|
+
width: $default-width;
|
|
29
|
+
|
|
30
|
+
.icon {
|
|
31
|
+
color: var(--hard-ui-icons);
|
|
32
|
+
font-size: calc($default-checkmark-font-size * 1.25);
|
|
33
|
+
|
|
34
|
+
&.#{bem.$modifier-open} {
|
|
35
|
+
transform: rotate(180deg);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.dropdown-content {
|
|
41
|
+
background-color: var(--background-far);
|
|
42
|
+
border-radius: $default-border-radius;
|
|
43
|
+
box-shadow: $default-box-shadow;
|
|
44
|
+
display: none;
|
|
45
|
+
margin-top: calc($default-margin * .125);
|
|
46
|
+
position: absolute;
|
|
47
|
+
width: $default-width;
|
|
48
|
+
z-index: 1;
|
|
49
|
+
|
|
50
|
+
&.#{bem.$modifier-open} {
|
|
51
|
+
display: block;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.dropdown-item {
|
|
55
|
+
align-items: center;
|
|
56
|
+
border-radius: $default-border-radius;
|
|
57
|
+
color: var(--hard-paragraph);
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
display: flex;
|
|
60
|
+
margin: calc($default-margin * .125);
|
|
61
|
+
padding: calc($default-padding * .5);
|
|
62
|
+
text-decoration: none;
|
|
63
|
+
|
|
64
|
+
&.#{bem.$modifier-active} {
|
|
65
|
+
background-color: var(--background-near);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
background-color: var(--background-near);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.status-dot {
|
|
73
|
+
border-radius: 50%;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
height: $default-dot-height;
|
|
76
|
+
margin-right: calc($default-margin * .5);
|
|
77
|
+
width: $default-dot-width;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.checkmark {
|
|
81
|
+
color: var(--hard-main);
|
|
82
|
+
font-size: $default-checkmark-font-size;
|
|
83
|
+
margin-left: auto;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -14,6 +14,7 @@ $default-width: var(--tooltip-width, 20rem);
|
|
|
14
14
|
background: var(--x);
|
|
15
15
|
border: var(--theme-default-border-style) var(--ui-lines);
|
|
16
16
|
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
17
|
+
min-width: $default-width;
|
|
17
18
|
opacity: 0;
|
|
18
19
|
overflow: hidden;
|
|
19
20
|
padding: $default-block-padding $default-inline-padding;
|
|
@@ -21,7 +22,6 @@ $default-width: var(--tooltip-width, 20rem);
|
|
|
21
22
|
transform: translateX(var(--horizontal, 0)) translateY(var(--vertical, 0));
|
|
22
23
|
transition: opacity .2s ease, transform .2s ease;
|
|
23
24
|
visibility: hidden;
|
|
24
|
-
width: $default-width;
|
|
25
25
|
z-index: 10;
|
|
26
26
|
|
|
27
27
|
&.top {
|
package/dist/es/a/index.js
CHANGED
|
@@ -28,4 +28,4 @@ export { ToggleSwitch } from "./ToggleSwitch";
|
|
|
28
28
|
export { XMLEditor } from "./XMLEditor";
|
|
29
29
|
export { DatePicker } from "./DatePicker";
|
|
30
30
|
export { Tooltip } from "./Tooltip";
|
|
31
|
-
export { AreaChart } from "./
|
|
31
|
+
export { AreaChart, BarChart } from "./Charts";
|
|
@@ -3,7 +3,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { memo } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput, Checkbox, QueryChoices, LinkInput, EditorInput, FileUpload } from "../fields";
|
|
6
|
+
import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput, Checkbox, QueryChoices, LinkInput, EditorInput, FileUpload, LatexPreviewInput } from "../fields";
|
|
7
7
|
import "./styles.scss";
|
|
8
8
|
|
|
9
9
|
// Local Definitions
|
|
@@ -95,6 +95,12 @@ const FormInput = ({
|
|
|
95
95
|
disabled: disabled
|
|
96
96
|
}, otherProps));
|
|
97
97
|
}
|
|
98
|
+
if (type === 'latex-preview-input') {
|
|
99
|
+
return /*#__PURE__*/React.createElement(LatexPreviewInput, _extends({
|
|
100
|
+
className: newClassName,
|
|
101
|
+
disabled: disabled
|
|
102
|
+
}, otherProps));
|
|
103
|
+
}
|
|
98
104
|
if (extraTypes?.[type]) {
|
|
99
105
|
const Component = extraTypes[type];
|
|
100
106
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
@@ -11,6 +11,13 @@ import { FormLabel, FormDescription } from "../../common";
|
|
|
11
11
|
|
|
12
12
|
const baseClassName = styleNames.base;
|
|
13
13
|
const componentClassName = 'file-upload';
|
|
14
|
+
const generateUniqueFileName = (originalName, existingFileNames) => {
|
|
15
|
+
const lastDotIndex = originalName.lastIndexOf('.');
|
|
16
|
+
const name = originalName.substring(0, lastDotIndex);
|
|
17
|
+
const ext = originalName.split('.').pop();
|
|
18
|
+
const numDuplicates = existingFileNames.filter(existingFileName => existingFileName?.startsWith(name)).length;
|
|
19
|
+
return numDuplicates > 0 ? `${name} (${numDuplicates}).${ext}` : originalName;
|
|
20
|
+
};
|
|
14
21
|
|
|
15
22
|
/**
|
|
16
23
|
* This is the component description.
|
|
@@ -52,17 +59,24 @@ const FileUpload = ({
|
|
|
52
59
|
} = helpers;
|
|
53
60
|
const handleChange = event => {
|
|
54
61
|
setTouched(true, false);
|
|
55
|
-
|
|
62
|
+
let newFiles = Array.from(event.currentTarget.files);
|
|
56
63
|
const currentFiles = value || [];
|
|
57
64
|
const currentCount = currentFiles.length + newFiles.length;
|
|
58
65
|
if (maxCount && currentCount > maxCount) {
|
|
59
66
|
setError(maxCountError || `Maximum of ${maxCount} files allowed`);
|
|
60
67
|
return;
|
|
61
68
|
}
|
|
62
|
-
const
|
|
69
|
+
const uploadedFiles = Object.keys(uploadStatus) || [];
|
|
70
|
+
const duplicateFiles = newFiles.filter(newFile => uploadedFiles.some(uploadedFile => uploadedFile === newFile.name));
|
|
63
71
|
if (duplicateFiles.length > 0) {
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
newFiles = newFiles.map(file => {
|
|
73
|
+
if (duplicateFiles.some(duplicateFile => duplicateFile.name === file.name)) {
|
|
74
|
+
return new File([file], generateUniqueFileName(file.name, uploadedFiles), {
|
|
75
|
+
type: file.type
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return file;
|
|
79
|
+
});
|
|
66
80
|
}
|
|
67
81
|
if (maxSize) {
|
|
68
82
|
const oversizedFiles = newFiles.filter(file => file.size > maxSize);
|