@pareto-engineering/design-system 5.0.5 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a/Charts/AreaChart/AreaChart.js +3 -13
- package/dist/cjs/a/Charts/BarChart/BarChart.js +6 -4
- package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +26 -7
- package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +41 -14
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +18 -7
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +3 -4
- package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +7 -6
- 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 +8 -1
- package/dist/cjs/a/Notification/styles.scss +17 -5
- package/dist/cjs/a/index.js +6 -0
- package/dist/cjs/f/FormInput/FormInput.js +1 -1
- package/dist/cjs/f/fields/LatexPreviewInput/LatexPreviewInput.js +1 -1
- package/dist/cjs/f/fields/LatexPreviewInput/styles.scss +1 -0
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +4 -2
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +27 -1
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +15 -0
- package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +6 -2
- package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +6 -0
- package/dist/cjs/utils/applyCharacterLimit.js +75 -0
- package/dist/cjs/utils/formatting.js +10 -2
- package/dist/cjs/utils/index.js +14 -1
- package/dist/es/a/Charts/AreaChart/AreaChart.js +3 -13
- package/dist/es/a/Charts/BarChart/BarChart.js +6 -4
- package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +38 -21
- package/dist/es/a/Charts/Common/CustomLegend/styles.scss +41 -14
- package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +19 -8
- package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +3 -5
- package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +7 -6
- 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 +2 -1
- package/dist/es/a/Notification/styles.scss +17 -5
- package/dist/es/a/index.js +1 -1
- package/dist/es/f/FormInput/FormInput.js +1 -1
- package/dist/es/f/fields/LatexPreviewInput/LatexPreviewInput.js +1 -1
- package/dist/es/f/fields/LatexPreviewInput/styles.scss +1 -0
- package/dist/es/f/fields/TextareaInput/TextareaInput.js +4 -2
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +27 -1
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +15 -0
- package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +6 -2
- package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +6 -0
- package/dist/es/utils/applyCharacterLimit.js +67 -0
- package/dist/es/utils/formatting.js +7 -0
- package/dist/es/utils/index.js +2 -1
- package/package.json +3 -3
- package/src/stories/a/AreaChart.stories.jsx +1 -1
- package/src/stories/a/BarChart.stories.jsx +1 -1
- package/src/stories/a/PieChart.stories.jsx +53 -0
- package/src/ui/a/Charts/AreaChart/AreaChart.jsx +8 -14
- package/src/ui/a/Charts/BarChart/BarChart.jsx +4 -2
- package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +54 -29
- package/src/ui/a/Charts/Common/CustomLegend/styles.scss +41 -14
- package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +25 -13
- package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +4 -4
- package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +7 -6
- 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 +1 -0
- package/src/ui/a/Notification/styles.scss +17 -5
- package/src/ui/a/index.js +1 -1
- package/src/ui/f/FormInput/FormInput.jsx +1 -0
- package/src/ui/f/fields/LatexPreviewInput/LatexPreviewInput.jsx +1 -0
- package/src/ui/f/fields/LatexPreviewInput/styles.scss +1 -0
- package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +2 -0
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +34 -0
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +15 -0
- package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +10 -2
- package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +5 -0
- package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +0 -1
- package/src/ui/utils/applyCharacterLimit.js +80 -0
- package/src/ui/utils/formatting.js +8 -0
- package/src/ui/utils/index.js +4 -1
- package/tests/__snapshots__/Storyshots.test.js.snap +1165 -429
|
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
|
|
5
5
|
import styleNames from '@pareto-engineering/bem/exports'
|
|
6
6
|
|
|
7
|
+
import { snakeCaseToTitleCase } from 'ui/utils'
|
|
8
|
+
|
|
7
9
|
import './styles.scss'
|
|
8
10
|
|
|
9
11
|
const baseClassName = styleNames.base
|
|
@@ -15,40 +17,44 @@ const CustomLegend = ({
|
|
|
15
17
|
className: userClassName,
|
|
16
18
|
colorsArray,
|
|
17
19
|
yKeysArray,
|
|
20
|
+
orientation,
|
|
21
|
+
getLegendItemTitle,
|
|
22
|
+
getLegendItemSubtitle,
|
|
18
23
|
capitalizedLegend,
|
|
19
|
-
}) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
className=
|
|
33
|
-
|
|
34
|
-
componentClassName,
|
|
35
|
-
userClassName,
|
|
36
|
-
]
|
|
37
|
-
.filter((e) => e)
|
|
38
|
-
.join(' ')}
|
|
39
|
-
>
|
|
40
|
-
{yKeysArray.map((key, index) => (
|
|
41
|
-
<div key={key} className="item">
|
|
24
|
+
}) => (
|
|
25
|
+
<div
|
|
26
|
+
id={id}
|
|
27
|
+
className={[
|
|
28
|
+
baseClassName,
|
|
29
|
+
componentClassName,
|
|
30
|
+
userClassName,
|
|
31
|
+
orientation,
|
|
32
|
+
]
|
|
33
|
+
.filter((e) => e)
|
|
34
|
+
.join(' ')}
|
|
35
|
+
>
|
|
36
|
+
{yKeysArray.map((key, index) => (
|
|
37
|
+
<div key={key} className="item">
|
|
38
|
+
<div className="title">
|
|
42
39
|
<span
|
|
43
40
|
className="dot"
|
|
44
41
|
style={{ backgroundColor: colorsArray[index] }}
|
|
45
42
|
/>
|
|
46
|
-
<span className="text">
|
|
43
|
+
<span className="text">
|
|
44
|
+
{
|
|
45
|
+
capitalizedLegend
|
|
46
|
+
? snakeCaseToTitleCase(getLegendItemTitle(key))
|
|
47
|
+
: getLegendItemTitle(key)
|
|
48
|
+
}
|
|
49
|
+
</span>
|
|
47
50
|
</div>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
<span className="sub-title">
|
|
52
|
+
{getLegendItemSubtitle(key)}
|
|
53
|
+
</span>
|
|
54
|
+
</div>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
52
58
|
|
|
53
59
|
CustomLegend.propTypes = {
|
|
54
60
|
/**
|
|
@@ -71,6 +77,21 @@ CustomLegend.propTypes = {
|
|
|
71
77
|
*/
|
|
72
78
|
yKeysArray:PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
73
79
|
|
|
80
|
+
/**
|
|
81
|
+
* The orientation of the Legend
|
|
82
|
+
*/
|
|
83
|
+
orientation:PropTypes.oneOf(['vertical', 'horizontal']),
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The function to get the legendItemKey
|
|
87
|
+
*/
|
|
88
|
+
getLegendItemTitle:PropTypes.func,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The function to get legend children
|
|
92
|
+
*/
|
|
93
|
+
getLegendItemSubtitle:PropTypes.func,
|
|
94
|
+
|
|
74
95
|
/**
|
|
75
96
|
* Flag on whether to capitalize legend keys
|
|
76
97
|
*/
|
|
@@ -78,7 +99,11 @@ CustomLegend.propTypes = {
|
|
|
78
99
|
}
|
|
79
100
|
|
|
80
101
|
CustomLegend.defaultProps = {
|
|
81
|
-
|
|
102
|
+
orientation :'horizontal',
|
|
103
|
+
getLegendItemTitle :(key) => key,
|
|
104
|
+
/* eslint-disable no-unused-vars */
|
|
105
|
+
getLegendItemSubtitle:() => {},
|
|
106
|
+
capitalizedLegend :false,
|
|
82
107
|
}
|
|
83
108
|
|
|
84
109
|
export default CustomLegend
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@use "@pareto-engineering/bem";
|
|
2
2
|
|
|
3
3
|
$default-padding: 1rem;
|
|
4
|
+
$default-margin: 1rem;
|
|
4
5
|
$default-text-font-size: calc(var(--s-1) * 1rem);
|
|
5
6
|
$default-border-radius: .25rem;
|
|
6
7
|
$default-legend-gap: .625rem;
|
|
@@ -8,33 +9,59 @@ $default-legend-padding: calc($default-padding * .125) calc($default-padding * .
|
|
|
8
9
|
$default-legend-dot-width: .5rem;
|
|
9
10
|
$default-legend-dot-height: .5rem;
|
|
10
11
|
$default-legend-dot-margin-right: .3125rem;
|
|
12
|
+
$default-box-shadow: 0 4px 16px 0 var(--soft-shadow);
|
|
11
13
|
|
|
12
14
|
.#{bem.$base} {
|
|
13
15
|
&.custom-legend {
|
|
14
|
-
display: flex;
|
|
15
16
|
gap: $default-legend-gap;
|
|
16
17
|
justify-content: flex-end;
|
|
17
18
|
padding-bottom: $default-padding;
|
|
18
19
|
padding-right: calc($default-padding * .25);
|
|
19
20
|
|
|
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
|
+
|
|
20
36
|
.item {
|
|
21
|
-
align-items: center;
|
|
22
37
|
border-radius: $default-border-radius;
|
|
23
|
-
display: flex;
|
|
24
38
|
padding: $default-legend-padding;
|
|
25
|
-
}
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
.title {
|
|
41
|
+
align-items: center;
|
|
42
|
+
display: flex;
|
|
43
|
+
|
|
44
|
+
.dot {
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
display: inline-block;
|
|
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
|
+
}
|
|
34
57
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
.sub-title {
|
|
59
|
+
color: var(--heading);
|
|
60
|
+
display: flex;
|
|
61
|
+
font-size: calc($default-text-font-size * 1.2);
|
|
62
|
+
font-weight: 500;
|
|
63
|
+
justify-content: flex-end;
|
|
64
|
+
}
|
|
38
65
|
}
|
|
39
66
|
}
|
|
40
67
|
}
|
|
@@ -4,7 +4,9 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
|
|
5
5
|
import styleNames from '@pareto-engineering/bem/exports'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase,
|
|
9
|
+
} from 'ui/utils'
|
|
8
10
|
|
|
9
11
|
import './styles.scss'
|
|
10
12
|
|
|
@@ -15,13 +17,26 @@ const componentClassName = 'custom-tooltip-content'
|
|
|
15
17
|
const CustomTooltipContent = ({
|
|
16
18
|
id,
|
|
17
19
|
className: userClassName,
|
|
18
|
-
xLabel,
|
|
19
20
|
dateFormat,
|
|
20
21
|
isTimeFormat,
|
|
22
|
+
isDateValue,
|
|
21
23
|
active,
|
|
22
24
|
payload,
|
|
23
25
|
label,
|
|
24
26
|
}) => {
|
|
27
|
+
const formatLabelValue = (value) => {
|
|
28
|
+
if (isTimeFormat) {
|
|
29
|
+
return formatTime(value)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof value === 'number') {
|
|
33
|
+
if (Number.isInteger(value)) return value
|
|
34
|
+
return value.toFixed(2)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return value
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
if (active && payload && payload.length) {
|
|
26
41
|
const newPayload = payload.filter((item) => item.name !== 'bounds')
|
|
27
42
|
return (
|
|
@@ -36,15 +51,11 @@ const CustomTooltipContent = ({
|
|
|
36
51
|
.join(' ')}
|
|
37
52
|
>
|
|
38
53
|
<p className="label">
|
|
39
|
-
{
|
|
54
|
+
{isDateValue ? formatDate(label, dateFormat) : label}
|
|
40
55
|
</p>
|
|
41
56
|
{newPayload.map((entry) => (
|
|
42
57
|
<p className="label" key={`${entry.name}`} style={{ color: entry.color, textTransform: 'capitalize' }}>
|
|
43
|
-
{`${entry.name}: ${
|
|
44
|
-
isTimeFormat
|
|
45
|
-
? formatTime(entry.value)
|
|
46
|
-
: entry.value
|
|
47
|
-
}`}
|
|
58
|
+
{`${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`}
|
|
48
59
|
</p>
|
|
49
60
|
))}
|
|
50
61
|
</div>
|
|
@@ -64,11 +75,6 @@ CustomTooltipContent.propTypes = {
|
|
|
64
75
|
*/
|
|
65
76
|
className:PropTypes.string,
|
|
66
77
|
|
|
67
|
-
/**
|
|
68
|
-
* The label for the x-axis.
|
|
69
|
-
*/
|
|
70
|
-
xLabel:PropTypes.string,
|
|
71
|
-
|
|
72
78
|
/**
|
|
73
79
|
* Flag on whether it is a timeformat or not
|
|
74
80
|
*/
|
|
@@ -79,6 +85,11 @@ CustomTooltipContent.propTypes = {
|
|
|
79
85
|
*/
|
|
80
86
|
dateFormat:PropTypes.oneOf(Object.values(DATE_FORMATS)),
|
|
81
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Flag on whether the label is a date value or not
|
|
90
|
+
*/
|
|
91
|
+
isDateValue:PropTypes.bool,
|
|
92
|
+
|
|
82
93
|
/**
|
|
83
94
|
* If set true, the tooltip is displayed.
|
|
84
95
|
* If set false, the tooltip is hidden, usually calculated internally.
|
|
@@ -99,6 +110,7 @@ CustomTooltipContent.propTypes = {
|
|
|
99
110
|
|
|
100
111
|
CustomTooltipContent.defaultProps = {
|
|
101
112
|
isTimeFormat:false,
|
|
113
|
+
isDateValue :true,
|
|
102
114
|
dateFormat :DATE_FORMATS.HUMAN_READABLE,
|
|
103
115
|
}
|
|
104
116
|
|
|
@@ -5,9 +5,9 @@ import PropTypes from 'prop-types'
|
|
|
5
5
|
|
|
6
6
|
import styleNames from '@pareto-engineering/bem/exports'
|
|
7
7
|
|
|
8
|
-
import '
|
|
8
|
+
import { snakeCaseToTitleCase } from 'ui/utils'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import './styles.scss'
|
|
11
11
|
|
|
12
12
|
const baseClassName = styleNames.base
|
|
13
13
|
|
|
@@ -65,7 +65,7 @@ const YLabelsDropDown = ({
|
|
|
65
65
|
className="status-dot"
|
|
66
66
|
style={{ backgroundColor: item.color }}
|
|
67
67
|
/>
|
|
68
|
-
{item.label}
|
|
68
|
+
{snakeCaseToTitleCase(item.label)}
|
|
69
69
|
{selectedYLabels.some((label) => label.label === item.label) && (
|
|
70
70
|
<span className="icon checkmark">I</span>
|
|
71
71
|
)}
|
|
@@ -115,7 +115,7 @@ YLabelsDropDown.propTypes = {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
YLabelsDropDown.defaultProps = {
|
|
118
|
-
placeholder:'
|
|
118
|
+
placeholder:'Select Item',
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export default YLabelsDropDown
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
@use "@pareto-engineering/bem";
|
|
2
2
|
|
|
3
3
|
$default-margin: 1rem;
|
|
4
|
-
$default-border
|
|
4
|
+
$default-border: var(--theme-default-input-border);
|
|
5
|
+
$default-border-radius: var(--theme-default-input-border-radius);
|
|
5
6
|
$default-padding: 1rem;
|
|
6
7
|
$default-width: 15rem;
|
|
7
8
|
$default-box-shadow: 0 .25rem .75rem var(--ui-lines);
|
|
@@ -16,9 +17,9 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
|
|
|
16
17
|
|
|
17
18
|
.dropdown-button {
|
|
18
19
|
align-items: center;
|
|
19
|
-
background-color: var(--
|
|
20
|
-
border:
|
|
21
|
-
border-radius: $default-border-radius;
|
|
20
|
+
background-color: var(--background-far);
|
|
21
|
+
border: $default-border;
|
|
22
|
+
border-radius: calc($default-border-radius / 2);
|
|
22
23
|
color: var(--hard-paragraph);
|
|
23
24
|
cursor: pointer;
|
|
24
25
|
display: flex;
|
|
@@ -53,8 +54,8 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
|
|
|
53
54
|
|
|
54
55
|
.dropdown-item {
|
|
55
56
|
align-items: center;
|
|
56
|
-
border-radius: $default-border-radius;
|
|
57
|
-
color: var(--
|
|
57
|
+
border-radius: calc($default-border-radius / 2);
|
|
58
|
+
color: var(--paragraph);
|
|
58
59
|
cursor: pointer;
|
|
59
60
|
display: flex;
|
|
60
61
|
margin: calc($default-margin * .125);
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
PieChart as RechartsPieChart,
|
|
7
|
+
Pie,
|
|
8
|
+
Cell,
|
|
9
|
+
ResponsiveContainer,
|
|
10
|
+
Tooltip,
|
|
11
|
+
} from 'recharts'
|
|
12
|
+
|
|
13
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
14
|
+
|
|
15
|
+
import { CustomLegend, CustomTooltipContent } from '../Common'
|
|
16
|
+
|
|
17
|
+
import './styles.scss'
|
|
18
|
+
|
|
19
|
+
const baseClassName = styleNames.base
|
|
20
|
+
|
|
21
|
+
const componentClassName = 'pie-chart'
|
|
22
|
+
|
|
23
|
+
const PieChart = ({
|
|
24
|
+
id,
|
|
25
|
+
className: userClassName,
|
|
26
|
+
data,
|
|
27
|
+
title,
|
|
28
|
+
valueKey,
|
|
29
|
+
labelKey,
|
|
30
|
+
colors,
|
|
31
|
+
height,
|
|
32
|
+
width,
|
|
33
|
+
innerRadius,
|
|
34
|
+
outerRadius,
|
|
35
|
+
}) => {
|
|
36
|
+
const total = data.reduce((sum, item) => sum + item[valueKey], 0)
|
|
37
|
+
|
|
38
|
+
const formattedData = data.map((item) => ({
|
|
39
|
+
...item,
|
|
40
|
+
label :item[labelKey],
|
|
41
|
+
color :colors[data.indexOf(item)],
|
|
42
|
+
percentage:((item[valueKey] / total) * 100).toFixed(0),
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
id={id}
|
|
48
|
+
className={[
|
|
49
|
+
baseClassName,
|
|
50
|
+
componentClassName,
|
|
51
|
+
userClassName,
|
|
52
|
+
]
|
|
53
|
+
.filter((e) => e)
|
|
54
|
+
.join(' ')}
|
|
55
|
+
>
|
|
56
|
+
<div className="chart-header">
|
|
57
|
+
<h3>{title}</h3>
|
|
58
|
+
</div>
|
|
59
|
+
<div className="chart-content">
|
|
60
|
+
<ResponsiveContainer width={width} height={height}>
|
|
61
|
+
<RechartsPieChart>
|
|
62
|
+
<Pie
|
|
63
|
+
data={formattedData}
|
|
64
|
+
dataKey={valueKey}
|
|
65
|
+
nameKey={labelKey}
|
|
66
|
+
cx="50%"
|
|
67
|
+
cy="50%"
|
|
68
|
+
innerRadius={innerRadius}
|
|
69
|
+
outerRadius={outerRadius}
|
|
70
|
+
label={false}
|
|
71
|
+
paddingAngle={0}
|
|
72
|
+
>
|
|
73
|
+
{formattedData.map((entry, index) => (
|
|
74
|
+
<Cell
|
|
75
|
+
key={entry[labelKey]}
|
|
76
|
+
fill={colors[index]}
|
|
77
|
+
strokeWidth={0}
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
80
|
+
</Pie>
|
|
81
|
+
<Tooltip content={<CustomTooltipContent isDateValue={false} />} />
|
|
82
|
+
</RechartsPieChart>
|
|
83
|
+
</ResponsiveContainer>
|
|
84
|
+
<CustomLegend
|
|
85
|
+
colorsArray={colors}
|
|
86
|
+
yKeysArray={formattedData}
|
|
87
|
+
capitalizedLegend
|
|
88
|
+
orientation="vertical"
|
|
89
|
+
getLegendItemTitle={(entry) => entry[labelKey]}
|
|
90
|
+
getLegendItemSubtitle={(entry) => entry[valueKey]}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
PieChart.propTypes = {
|
|
98
|
+
id :PropTypes.string,
|
|
99
|
+
className:PropTypes.string,
|
|
100
|
+
data :PropTypes.arrayOf(PropTypes.shape({
|
|
101
|
+
[PropTypes.string]:PropTypes.oneOfType([
|
|
102
|
+
PropTypes.string,
|
|
103
|
+
PropTypes.number,
|
|
104
|
+
]),
|
|
105
|
+
})).isRequired,
|
|
106
|
+
title :PropTypes.string.isRequired,
|
|
107
|
+
valueKey :PropTypes.string.isRequired,
|
|
108
|
+
labelKey :PropTypes.string.isRequired,
|
|
109
|
+
colors :PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
110
|
+
height :PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
111
|
+
width :PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
112
|
+
innerRadius:PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
113
|
+
outerRadius:PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
PieChart.defaultProps = {
|
|
117
|
+
id :undefined,
|
|
118
|
+
className :undefined,
|
|
119
|
+
width :'100%',
|
|
120
|
+
height :300,
|
|
121
|
+
innerRadius:'0%',
|
|
122
|
+
outerRadius:'100%',
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
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
|
+
}
|
package/src/ui/a/Charts/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
@use "@pareto-engineering/styles/src/mixins";
|
|
5
5
|
@use "@pareto-engineering/styles/src/globals" as *;
|
|
6
6
|
|
|
7
|
+
$default-border: 1px solid var(--x);
|
|
7
8
|
$default-padding: 1rem;
|
|
8
9
|
$default-margin: 1rem;
|
|
9
10
|
$default-border-radius: 1.5rem;
|
|
@@ -12,10 +13,11 @@ $default-height: var(--notification-height, 5rem);
|
|
|
12
13
|
|
|
13
14
|
.#{bem.$base}.notification {
|
|
14
15
|
align-items: center;
|
|
15
|
-
background-color: var(--
|
|
16
|
+
background-color: var(--background-far);
|
|
17
|
+
border: $default-border;
|
|
16
18
|
border-radius: $default-border-radius;
|
|
17
19
|
bottom: 0;
|
|
18
|
-
color: var(--
|
|
20
|
+
color: var(--paragraph);
|
|
19
21
|
display: flex;
|
|
20
22
|
justify-content: space-between;
|
|
21
23
|
margin-bottom: $default-margin;
|
|
@@ -31,8 +33,16 @@ $default-height: var(--notification-height, 5rem);
|
|
|
31
33
|
> .message-container {
|
|
32
34
|
align-items: center;
|
|
33
35
|
display: flex;
|
|
36
|
+
gap: $default-padding;
|
|
34
37
|
overflow: auto;
|
|
35
38
|
|
|
39
|
+
> .icon {
|
|
40
|
+
background-color: var(--x);
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
color: var(--white);
|
|
43
|
+
padding: calc($default-padding / 2);
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
> .message {
|
|
37
47
|
font-size: calc(var(--s0) * 1rem);
|
|
38
48
|
margin-left: calc($default-margin / 2);
|
|
@@ -44,12 +54,14 @@ $default-height: var(--notification-height, 5rem);
|
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
.#{bem.$base}.button {
|
|
57
|
+
background-color: transparent;
|
|
58
|
+
color: var(--paragraph);
|
|
47
59
|
padding: calc($default-padding / 2);
|
|
48
60
|
|
|
49
|
-
&:focus
|
|
61
|
+
&:focus,
|
|
62
|
+
&:hover {
|
|
50
63
|
background-color: transparent;
|
|
64
|
+
color: var(--hard-paragraph);
|
|
51
65
|
}
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
|
-
|
|
55
|
-
|
package/src/ui/a/index.js
CHANGED
|
@@ -30,4 +30,4 @@ export { ToggleSwitch } from './ToggleSwitch'
|
|
|
30
30
|
export { XMLEditor } from './XMLEditor'
|
|
31
31
|
export { DatePicker } from './DatePicker'
|
|
32
32
|
export { Tooltip } from './Tooltip'
|
|
33
|
-
export { AreaChart, BarChart } from './Charts'
|
|
33
|
+
export { AreaChart, BarChart, PieChart } from './Charts'
|
|
@@ -38,6 +38,7 @@ const TextareaInput = ({
|
|
|
38
38
|
placeholder,
|
|
39
39
|
autoComplete,
|
|
40
40
|
resize,
|
|
41
|
+
maxLength,
|
|
41
42
|
// ...otherProps
|
|
42
43
|
}) => {
|
|
43
44
|
const [field] = useField({ name, validate })
|
|
@@ -73,6 +74,7 @@ const TextareaInput = ({
|
|
|
73
74
|
rows={rows}
|
|
74
75
|
disabled={disabled}
|
|
75
76
|
autoComplete={autoComplete}
|
|
77
|
+
maxLength={maxLength}
|
|
76
78
|
>
|
|
77
79
|
{/* It was a dark and stormy night... */}
|
|
78
80
|
</textarea>
|
|
@@ -70,6 +70,8 @@ const InputBuilder = ({
|
|
|
70
70
|
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.showSpecificFileTypes`, !input.showSpecificFileTypes)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const textChoices = ['text', 'number', 'textarea', 'latex-preview-input']
|
|
74
|
+
|
|
73
75
|
return (
|
|
74
76
|
<div
|
|
75
77
|
id={id}
|
|
@@ -179,6 +181,38 @@ const InputBuilder = ({
|
|
|
179
181
|
/>
|
|
180
182
|
)}
|
|
181
183
|
</div>
|
|
184
|
+
{textChoices.includes(input?.type) && (
|
|
185
|
+
<div className="character-limit-container">
|
|
186
|
+
<div className="is-required">
|
|
187
|
+
<span className="s0">
|
|
188
|
+
Limit number of characters permitted for this input
|
|
189
|
+
</span>
|
|
190
|
+
<ToggleSwitch
|
|
191
|
+
handleOnChange={() => {
|
|
192
|
+
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.hasCharacterLimit`, !input?.hasCharacterLimit)
|
|
193
|
+
if (!input?.hasCharacterLimit) {
|
|
194
|
+
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.maxLength`, '')
|
|
195
|
+
}
|
|
196
|
+
}}
|
|
197
|
+
checked={input?.hasCharacterLimit}
|
|
198
|
+
style={getToggleSwitchStyles(!input?.hasCharacterLimit)}
|
|
199
|
+
inputId={`sections_${sectionIndex}_inputs.${inputIndex}_character_limit_toggle`}
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
<div className="character-limit-input">
|
|
203
|
+
{input?.hasCharacterLimit && (
|
|
204
|
+
<TextInput
|
|
205
|
+
label="Enter the maximum number of characters permitted."
|
|
206
|
+
name={`sections.${sectionIndex}.inputs.${inputIndex}.maxLength`}
|
|
207
|
+
placeholder=""
|
|
208
|
+
type="number"
|
|
209
|
+
validate={integerAndGreaterThanZero}
|
|
210
|
+
value={input?.maxLength}
|
|
211
|
+
/>
|
|
212
|
+
)}
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
)}
|
|
182
216
|
{shouldRenderOptions && (
|
|
183
217
|
<FieldArray name={`sections.${sectionIndex}.inputs.${inputIndex}.options`}>
|
|
184
218
|
{({ push, remove }) => (
|