@pareto-engineering/design-system 5.0.0 → 5.0.2
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 -73
- package/dist/cjs/a/Charts/AreaChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/BarChart/BarChart.js +137 -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 +88 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/index.js +13 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +67 -0
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +97 -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 +97 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/index.js +13 -0
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
- package/dist/cjs/a/Charts/Common/index.js +26 -0
- package/dist/cjs/a/Charts/PieChart/PieChart.js +99 -0
- package/dist/cjs/a/Charts/PieChart/index.js +13 -0
- package/dist/cjs/a/Charts/PieChart/styles.scss +48 -0
- package/dist/cjs/a/Charts/index.js +26 -0
- package/dist/cjs/a/Tooltip/styles.scss +1 -1
- package/dist/cjs/a/index.js +14 -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 +119 -0
- package/dist/cjs/utils/index.js +26 -1
- package/dist/es/a/{AreaChart → Charts/AreaChart}/AreaChart.js +88 -69
- package/dist/es/a/Charts/AreaChart/styles.scss +48 -0
- package/dist/es/a/Charts/BarChart/BarChart.js +128 -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 +76 -0
- package/dist/es/a/Charts/Common/CustomLegend/index.js +1 -0
- package/dist/es/a/Charts/Common/CustomLegend/styles.scss +67 -0
- package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +87 -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 +86 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/index.js +1 -0
- package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
- package/dist/es/a/Charts/Common/index.js +3 -0
- package/dist/es/a/Charts/PieChart/PieChart.js +89 -0
- package/dist/es/a/Charts/PieChart/index.js +1 -0
- package/dist/es/a/Charts/PieChart/styles.scss +48 -0
- package/dist/es/a/Charts/index.js +3 -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 +109 -0
- package/dist/es/utils/index.js +2 -1
- package/jest.config.js +3 -0
- package/package.json +7 -3
- package/src/stories/a/AreaChart.stories.jsx +1 -1
- package/src/stories/a/BarChart.stories.jsx +89 -0
- package/src/stories/a/PieChart.stories.jsx +53 -0
- package/src/ui/a/{AreaChart → Charts/AreaChart}/AreaChart.jsx +114 -65
- package/src/ui/a/Charts/AreaChart/styles.scss +48 -0
- package/src/ui/a/Charts/BarChart/BarChart.jsx +167 -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 +109 -0
- package/src/ui/a/Charts/Common/CustomLegend/index.js +1 -0
- package/src/ui/a/Charts/Common/CustomLegend/styles.scss +67 -0
- package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +117 -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 +89 -0
- package/src/ui/a/Charts/Common/index.js +3 -0
- package/src/ui/a/Charts/PieChart/PieChart.jsx +125 -0
- package/src/ui/a/Charts/PieChart/index.js +1 -0
- package/src/ui/a/Charts/PieChart/styles.scss +48 -0
- package/src/ui/a/Charts/index.js +3 -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 +133 -0
- package/src/ui/utils/index.js +3 -0
- package/tests/__snapshots__/Storyshots.test.js.snap +2227 -296
- 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,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,86 @@
|
|
|
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 { snakeCaseToTitleCase } from "../../../../utils";
|
|
6
|
+
import "./styles.scss";
|
|
7
|
+
const baseClassName = styleNames.base;
|
|
8
|
+
const componentClassName = 'y-labels-dropdown';
|
|
9
|
+
const YLabelsDropDown = ({
|
|
10
|
+
id,
|
|
11
|
+
className: userClassName,
|
|
12
|
+
placeholder,
|
|
13
|
+
selectedYLabels,
|
|
14
|
+
setSelectedYLabels,
|
|
15
|
+
allYLabels
|
|
16
|
+
}) => {
|
|
17
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
18
|
+
const toggleYLabel = yLabel => {
|
|
19
|
+
setSelectedYLabels(prev => prev.some(label => label.label === yLabel.label) ? prev.filter(label => label.label !== yLabel.label) : [...prev, yLabel]);
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
id: id,
|
|
23
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
24
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
25
|
+
className: "dropdown-button",
|
|
26
|
+
onClick: () => setIsOpen(!isOpen),
|
|
27
|
+
type: "button"
|
|
28
|
+
}, placeholder, /*#__PURE__*/React.createElement("span", {
|
|
29
|
+
className: `icon ${isOpen ? styleNames.modifierOpen : ''}`
|
|
30
|
+
}, "W")), /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: `dropdown-content ${isOpen ? styleNames.modifierOpen : ''}`
|
|
32
|
+
}, allYLabels.map(item =>
|
|
33
|
+
/*#__PURE__*/
|
|
34
|
+
// eslint-disable-next-line max-len
|
|
35
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
|
|
36
|
+
React.createElement("div", {
|
|
37
|
+
key: item.label,
|
|
38
|
+
className: `dropdown-item ${selectedYLabels.some(label => label.label === item.label) ? styleNames.modifierActive : ''}`
|
|
39
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
40
|
+
,
|
|
41
|
+
onClick: () => toggleYLabel(item)
|
|
42
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
className: "status-dot",
|
|
44
|
+
style: {
|
|
45
|
+
backgroundColor: item.color
|
|
46
|
+
}
|
|
47
|
+
}), snakeCaseToTitleCase(item.label), selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
|
|
48
|
+
className: "icon checkmark"
|
|
49
|
+
}, "I")))));
|
|
50
|
+
};
|
|
51
|
+
YLabelsDropDown.propTypes = {
|
|
52
|
+
/**
|
|
53
|
+
* The id of the dropdown component.
|
|
54
|
+
*/
|
|
55
|
+
id: PropTypes.string,
|
|
56
|
+
/**
|
|
57
|
+
* Additional class names for the dropdown component.
|
|
58
|
+
*/
|
|
59
|
+
className: PropTypes.string,
|
|
60
|
+
/**
|
|
61
|
+
* Placeholder text for the dropdown button.
|
|
62
|
+
*/
|
|
63
|
+
placeholder: PropTypes.string,
|
|
64
|
+
/**
|
|
65
|
+
* Array of selected Y labels with their corresponding colors.
|
|
66
|
+
*/
|
|
67
|
+
selectedYLabels: PropTypes.arrayOf(PropTypes.shape({
|
|
68
|
+
label: PropTypes.string,
|
|
69
|
+
color: PropTypes.string
|
|
70
|
+
})),
|
|
71
|
+
/**
|
|
72
|
+
* Function to set the selected Y labels.
|
|
73
|
+
*/
|
|
74
|
+
setSelectedYLabels: PropTypes.func,
|
|
75
|
+
/**
|
|
76
|
+
* Array of all Y labels with their corresponding colors.
|
|
77
|
+
*/
|
|
78
|
+
allYLabels: PropTypes.arrayOf(PropTypes.shape({
|
|
79
|
+
label: PropTypes.string,
|
|
80
|
+
color: PropTypes.string
|
|
81
|
+
}))
|
|
82
|
+
};
|
|
83
|
+
YLabelsDropDown.defaultProps = {
|
|
84
|
+
placeholder: 'Select Item'
|
|
85
|
+
};
|
|
86
|
+
export default YLabelsDropDown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as YLabelsDropDown } from "./YlabelsDropDown";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
@use "@pareto-engineering/bem";
|
|
2
|
+
|
|
3
|
+
$default-margin: 1rem;
|
|
4
|
+
$default-border: var(--theme-default-input-border);
|
|
5
|
+
$default-border-radius: var(--theme-default-input-border-radius);
|
|
6
|
+
$default-padding: 1rem;
|
|
7
|
+
$default-width: 15rem;
|
|
8
|
+
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
9
|
+
$default-dot-width: .5rem;
|
|
10
|
+
$default-dot-height: .5rem;
|
|
11
|
+
$default-checkmark-font-size: calc(var(--s-1) * .75rem);
|
|
12
|
+
|
|
13
|
+
.#{bem.$base} {
|
|
14
|
+
&.y-labels-dropdown {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
.dropdown-button {
|
|
19
|
+
align-items: center;
|
|
20
|
+
background-color: var(--background-far);
|
|
21
|
+
border: $default-border;
|
|
22
|
+
border-radius: calc($default-border-radius / 2);
|
|
23
|
+
color: var(--hard-paragraph);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
padding: calc($default-padding * .5);
|
|
28
|
+
text-align: left;
|
|
29
|
+
width: $default-width;
|
|
30
|
+
|
|
31
|
+
.icon {
|
|
32
|
+
color: var(--hard-ui-icons);
|
|
33
|
+
font-size: calc($default-checkmark-font-size * 1.25);
|
|
34
|
+
|
|
35
|
+
&.#{bem.$modifier-open} {
|
|
36
|
+
transform: rotate(180deg);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dropdown-content {
|
|
42
|
+
background-color: var(--background-far);
|
|
43
|
+
border-radius: $default-border-radius;
|
|
44
|
+
box-shadow: $default-box-shadow;
|
|
45
|
+
display: none;
|
|
46
|
+
margin-top: calc($default-margin * .125);
|
|
47
|
+
position: absolute;
|
|
48
|
+
width: $default-width;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
|
|
51
|
+
&.#{bem.$modifier-open} {
|
|
52
|
+
display: block;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.dropdown-item {
|
|
56
|
+
align-items: center;
|
|
57
|
+
border-radius: calc($default-border-radius / 2);
|
|
58
|
+
color: var(--paragraph);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
display: flex;
|
|
61
|
+
margin: calc($default-margin * .125);
|
|
62
|
+
padding: calc($default-padding * .5);
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
|
|
65
|
+
&.#{bem.$modifier-active} {
|
|
66
|
+
background-color: var(--background-near);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
background-color: var(--background-near);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.status-dot {
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
display: inline-block;
|
|
76
|
+
height: $default-dot-height;
|
|
77
|
+
margin-right: calc($default-margin * .5);
|
|
78
|
+
width: $default-dot-width;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.checkmark {
|
|
82
|
+
color: var(--hard-main);
|
|
83
|
+
font-size: $default-checkmark-font-size;
|
|
84
|
+
margin-left: auto;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { PieChart as RechartsPieChart, Pie, Cell, ResponsiveContainer, Tooltip } from 'recharts';
|
|
4
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
5
|
+
import { CustomLegend, CustomTooltipContent } from "../Common";
|
|
6
|
+
import "./styles.scss";
|
|
7
|
+
const baseClassName = styleNames.base;
|
|
8
|
+
const componentClassName = 'pie-chart';
|
|
9
|
+
const PieChart = ({
|
|
10
|
+
id,
|
|
11
|
+
className: userClassName,
|
|
12
|
+
data,
|
|
13
|
+
title,
|
|
14
|
+
valueKey,
|
|
15
|
+
labelKey,
|
|
16
|
+
colors,
|
|
17
|
+
height,
|
|
18
|
+
width,
|
|
19
|
+
innerRadius,
|
|
20
|
+
outerRadius
|
|
21
|
+
}) => {
|
|
22
|
+
const total = data.reduce((sum, item) => sum + item[valueKey], 0);
|
|
23
|
+
const formattedData = data.map(item => ({
|
|
24
|
+
...item,
|
|
25
|
+
label: item[labelKey],
|
|
26
|
+
color: colors[data.indexOf(item)],
|
|
27
|
+
percentage: (item[valueKey] / total * 100).toFixed(0)
|
|
28
|
+
}));
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
id: id,
|
|
31
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
32
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: "chart-header"
|
|
34
|
+
}, /*#__PURE__*/React.createElement("h3", null, title)), /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "chart-content"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
37
|
+
width: width,
|
|
38
|
+
height: height
|
|
39
|
+
}, /*#__PURE__*/React.createElement(RechartsPieChart, null, /*#__PURE__*/React.createElement(Pie, {
|
|
40
|
+
data: formattedData,
|
|
41
|
+
dataKey: valueKey,
|
|
42
|
+
nameKey: labelKey,
|
|
43
|
+
cx: "50%",
|
|
44
|
+
cy: "50%",
|
|
45
|
+
innerRadius: innerRadius,
|
|
46
|
+
outerRadius: outerRadius,
|
|
47
|
+
label: false,
|
|
48
|
+
paddingAngle: 0
|
|
49
|
+
}, formattedData.map((entry, index) => /*#__PURE__*/React.createElement(Cell, {
|
|
50
|
+
key: entry[labelKey],
|
|
51
|
+
fill: colors[index],
|
|
52
|
+
strokeWidth: 0
|
|
53
|
+
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
54
|
+
content: /*#__PURE__*/React.createElement(CustomTooltipContent, {
|
|
55
|
+
isDateValue: false
|
|
56
|
+
})
|
|
57
|
+
}))), /*#__PURE__*/React.createElement(CustomLegend, {
|
|
58
|
+
colorsArray: colors,
|
|
59
|
+
yKeysArray: formattedData,
|
|
60
|
+
capitalizedLegend: true,
|
|
61
|
+
orientation: "vertical",
|
|
62
|
+
getLegendItemTitle: entry => entry[labelKey],
|
|
63
|
+
getLegendItemSubtitle: entry => entry[valueKey]
|
|
64
|
+
})));
|
|
65
|
+
};
|
|
66
|
+
PieChart.propTypes = {
|
|
67
|
+
id: PropTypes.string,
|
|
68
|
+
className: PropTypes.string,
|
|
69
|
+
data: PropTypes.arrayOf(PropTypes.shape({
|
|
70
|
+
[PropTypes.string]: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
71
|
+
})).isRequired,
|
|
72
|
+
title: PropTypes.string.isRequired,
|
|
73
|
+
valueKey: PropTypes.string.isRequired,
|
|
74
|
+
labelKey: PropTypes.string.isRequired,
|
|
75
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
76
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
77
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
78
|
+
innerRadius: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
79
|
+
outerRadius: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
80
|
+
};
|
|
81
|
+
PieChart.defaultProps = {
|
|
82
|
+
id: undefined,
|
|
83
|
+
className: undefined,
|
|
84
|
+
width: '100%',
|
|
85
|
+
height: 300,
|
|
86
|
+
innerRadius: '0%',
|
|
87
|
+
outerRadius: '100%'
|
|
88
|
+
};
|
|
89
|
+
export default PieChart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PieChart } from "./PieChart";
|
|
@@ -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
|
+
&.pie-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
|
+
.chart-content {
|
|
30
|
+
align-items: flex-start;
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.recharts-wrapper {
|
|
35
|
+
.recharts-surface {
|
|
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
|
+
}
|
|
@@ -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, PieChart } 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);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
7
|
+
import { useFormikContext } from 'formik';
|
|
8
|
+
import convertLatexToHtml from "./convertLatexToHtml";
|
|
9
|
+
import { TextareaInput } from "../TextareaInput";
|
|
10
|
+
import "./styles.scss";
|
|
11
|
+
|
|
12
|
+
// Local Definitions
|
|
13
|
+
|
|
14
|
+
const baseClassName = styleNames.base;
|
|
15
|
+
const componentClassName = 'latex-preview-input';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This is the component description.
|
|
19
|
+
*/
|
|
20
|
+
const LatexPreviewInput = ({
|
|
21
|
+
id,
|
|
22
|
+
className,
|
|
23
|
+
userClassName,
|
|
24
|
+
disabled,
|
|
25
|
+
style,
|
|
26
|
+
...otherProps
|
|
27
|
+
}) => {
|
|
28
|
+
const {
|
|
29
|
+
name
|
|
30
|
+
} = otherProps;
|
|
31
|
+
const {
|
|
32
|
+
values
|
|
33
|
+
} = useFormikContext();
|
|
34
|
+
const LatexPreview = useMemo(() => convertLatexToHtml(values[name]), [values[name]]);
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
id: id,
|
|
37
|
+
className: [baseClassName, componentClassName, userClassName, 'form-input'].filter(e => e).join(' '),
|
|
38
|
+
style: style
|
|
39
|
+
}, /*#__PURE__*/React.createElement(TextareaInput, _extends({
|
|
40
|
+
className: "preview-child",
|
|
41
|
+
disabled: disabled
|
|
42
|
+
}, otherProps)), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "latex-container preview-child",
|
|
44
|
+
dangerouslySetInnerHTML: {
|
|
45
|
+
__html: LatexPreview
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
LatexPreviewInput.propTypes = {
|
|
50
|
+
/**
|
|
51
|
+
* The HTML id for this element
|
|
52
|
+
*/
|
|
53
|
+
id: PropTypes.string,
|
|
54
|
+
/**
|
|
55
|
+
* The HTML class names for this element
|
|
56
|
+
*/
|
|
57
|
+
className: PropTypes.string,
|
|
58
|
+
/**
|
|
59
|
+
* The React-written, css properties for this element.
|
|
60
|
+
*/
|
|
61
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
62
|
+
/**
|
|
63
|
+
* Whether the Form input input should be disabled
|
|
64
|
+
*/
|
|
65
|
+
disabled: PropTypes.bool
|
|
66
|
+
};
|
|
67
|
+
LatexPreviewInput.defaultProps = {
|
|
68
|
+
disabled: false
|
|
69
|
+
};
|
|
70
|
+
export default /*#__PURE__*/memo(LatexPreviewInput);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ReactMarkdown from 'react-markdown';
|
|
3
|
+
import RemarkMathPlugin from 'remark-math';
|
|
4
|
+
import { MathJax, MathJaxContext } from 'better-react-mathjax';
|
|
5
|
+
import rehypeMathjax from 'rehype-mathjax/svg';
|
|
6
|
+
import ReactDOMServer from 'react-dom/server';
|
|
7
|
+
const convertLatexToHtml = content => {
|
|
8
|
+
if (content.includes('https://forte-assets.pareto.ai/')) {
|
|
9
|
+
return content;
|
|
10
|
+
}
|
|
11
|
+
const processedContent = content.replaceAll(/\\\\/g, '\n\n');
|
|
12
|
+
const renderedContent = ReactDOMServer.renderToString(/*#__PURE__*/React.createElement(MathJaxContext, null, /*#__PURE__*/React.createElement(ReactMarkdown, {
|
|
13
|
+
remarkPlugins: [RemarkMathPlugin],
|
|
14
|
+
rehypePlugins: [rehypeMathjax],
|
|
15
|
+
components: {
|
|
16
|
+
math: ({
|
|
17
|
+
value
|
|
18
|
+
}) => /*#__PURE__*/React.createElement(MathJax.Node, {
|
|
19
|
+
formula: value
|
|
20
|
+
}),
|
|
21
|
+
inlineMath: ({
|
|
22
|
+
value
|
|
23
|
+
}) => /*#__PURE__*/React.createElement(MathJax.Node, {
|
|
24
|
+
inline: true,
|
|
25
|
+
formula: value
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}, processedContent)));
|
|
29
|
+
return renderedContent;
|
|
30
|
+
};
|
|
31
|
+
export default convertLatexToHtml;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-margin: 1em;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.latex-preview-input {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
gap: $default-margin;
|
|
11
|
+
|
|
12
|
+
> .preview-child {
|
|
13
|
+
flex: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
> .latex-container {
|
|
17
|
+
border: 1px solid var(--ui-lines);
|
|
18
|
+
border-radius: var(--theme-default-border-radius);
|
|
19
|
+
margin-top: calc($default-margin * 2.5);
|
|
20
|
+
max-width: 50%;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
padding: 0 $default-margin;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -9,4 +9,5 @@ export { Checkbox } from "./Checkbox";
|
|
|
9
9
|
export { QueryChoices } from "./QueryChoices";
|
|
10
10
|
export { LinkInput } from "./LinkInput";
|
|
11
11
|
export { EditorInput } from "./EditorInput";
|
|
12
|
+
export { LatexPreviewInput, convertLatexToHtml } from "./LatexPreviewInput";
|
|
12
13
|
export { FileUpload, fileUploadOptions, getFileType, getFileTypeFromUrl } from "./FileUpload";
|
|
@@ -30,8 +30,7 @@ const FormBuilder = ({
|
|
|
30
30
|
initialBuilderValues,
|
|
31
31
|
fileUploadStatus,
|
|
32
32
|
handleFileDelete,
|
|
33
|
-
taskData
|
|
34
|
-
customInputMap
|
|
33
|
+
taskData
|
|
35
34
|
// ...otherProps
|
|
36
35
|
}) => {
|
|
37
36
|
const formattedJson = JSON.stringify(taskData, null, 2);
|
|
@@ -47,8 +46,7 @@ const FormBuilder = ({
|
|
|
47
46
|
formBuilderId: formBuilderId,
|
|
48
47
|
onSave: onBuilderFormSave,
|
|
49
48
|
onError: onBuilderError,
|
|
50
|
-
validate: onBuilderValidate
|
|
51
|
-
customInputMap: customInputMap
|
|
49
|
+
validate: onBuilderValidate
|
|
52
50
|
}), mode === 'render' && /*#__PURE__*/React.createElement(Renderer, {
|
|
53
51
|
formData: formData,
|
|
54
52
|
onSave: onRendererFormSave,
|
|
@@ -56,8 +54,7 @@ const FormBuilder = ({
|
|
|
56
54
|
shouldSubmit: shouldSubmit,
|
|
57
55
|
fileUploadStatus: fileUploadStatus,
|
|
58
56
|
handleFileDelete: handleFileDelete,
|
|
59
|
-
onFileUpload: onFileUpload
|
|
60
|
-
customInputMap: customInputMap
|
|
57
|
+
onFileUpload: onFileUpload
|
|
61
58
|
}));
|
|
62
59
|
};
|
|
63
60
|
FormBuilder.propTypes = {
|
|
@@ -32,7 +32,6 @@ const Builder = ({
|
|
|
32
32
|
onError,
|
|
33
33
|
validate,
|
|
34
34
|
formBuilderId,
|
|
35
|
-
customInputMap,
|
|
36
35
|
initialValues = {}
|
|
37
36
|
// ...otherProps
|
|
38
37
|
}) => {
|
|
@@ -107,8 +106,7 @@ const Builder = ({
|
|
|
107
106
|
remove,
|
|
108
107
|
values,
|
|
109
108
|
setFieldValue
|
|
110
|
-
})
|
|
111
|
-
customInputMap: customInputMap
|
|
109
|
+
})
|
|
112
110
|
})), /*#__PURE__*/React.createElement("div", {
|
|
113
111
|
className: "section-footer"
|
|
114
112
|
}, /*#__PURE__*/React.createElement("button", {
|
|
@@ -26,8 +26,7 @@ const InputBuilder = ({
|
|
|
26
26
|
style,
|
|
27
27
|
sectionIndex,
|
|
28
28
|
inputIndex,
|
|
29
|
-
onDelete
|
|
30
|
-
customInputMap
|
|
29
|
+
onDelete
|
|
31
30
|
// ...otherProps
|
|
32
31
|
}) => {
|
|
33
32
|
const {
|
|
@@ -54,7 +53,6 @@ const InputBuilder = ({
|
|
|
54
53
|
const handleToggleShowSpecificFileTypes = () => {
|
|
55
54
|
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.showSpecificFileTypes`, !input.showSpecificFileTypes);
|
|
56
55
|
};
|
|
57
|
-
const customInputTypes = customInputMap ? Object.keys(customInputMap) : [];
|
|
58
56
|
return /*#__PURE__*/React.createElement("div", {
|
|
59
57
|
id: id,
|
|
60
58
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
@@ -94,10 +92,10 @@ const InputBuilder = ({
|
|
|
94
92
|
}, {
|
|
95
93
|
value: 'file',
|
|
96
94
|
label: 'File upload'
|
|
97
|
-
},
|
|
98
|
-
value:
|
|
99
|
-
label:
|
|
100
|
-
}
|
|
95
|
+
}, {
|
|
96
|
+
value: 'latex-preview-input',
|
|
97
|
+
label: 'Textbox with LaTeX preview'
|
|
98
|
+
}]
|
|
101
99
|
}), /*#__PURE__*/React.createElement("div", {
|
|
102
100
|
className: "controls"
|
|
103
101
|
}, /*#__PURE__*/React.createElement("button", {
|