@pareto-engineering/design-system 5.0.5 → 5.1.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/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/EditorInput/EditorInput.js +7 -3
- package/dist/cjs/f/fields/EditorInput/common/ExposePlainTextPlugin.js +40 -0
- package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +1 -1
- package/dist/cjs/f/fields/EditorInput/common/index.js +7 -0
- 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/ExpandableLexicalPreview/ExpandableLexicalPreview.js +4 -2
- package/dist/cjs/g/ExpandableLexicalPreview/styles.scss +0 -1
- 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/EditorInput/EditorInput.js +8 -4
- package/dist/es/f/fields/EditorInput/common/ExposePlainTextPlugin.js +32 -0
- package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +1 -1
- package/dist/es/f/fields/EditorInput/common/index.js +2 -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/ExpandableLexicalPreview/ExpandableLexicalPreview.js +4 -2
- package/dist/es/g/ExpandableLexicalPreview/styles.scss +0 -1
- 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/EditorInput/EditorInput.jsx +24 -9
- package/src/ui/f/fields/EditorInput/common/ExposePlainTextPlugin.jsx +42 -0
- package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +1 -1
- package/src/ui/f/fields/EditorInput/common/index.js +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/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +3 -3
- package/src/ui/g/ExpandableLexicalPreview/styles.scss +0 -1
- 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 +1167 -447
|
@@ -1,20 +1,30 @@
|
|
|
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 { formatTime, formatDate, DATE_FORMATS } from "../../../../utils";
|
|
4
|
+
import { formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase } from "../../../../utils";
|
|
5
5
|
import "./styles.scss";
|
|
6
6
|
const baseClassName = styleNames.base;
|
|
7
7
|
const componentClassName = 'custom-tooltip-content';
|
|
8
8
|
const CustomTooltipContent = ({
|
|
9
9
|
id,
|
|
10
10
|
className: userClassName,
|
|
11
|
-
xLabel,
|
|
12
11
|
dateFormat,
|
|
13
12
|
isTimeFormat,
|
|
13
|
+
isDateValue,
|
|
14
14
|
active,
|
|
15
15
|
payload,
|
|
16
16
|
label
|
|
17
17
|
}) => {
|
|
18
|
+
const formatLabelValue = value => {
|
|
19
|
+
if (isTimeFormat) {
|
|
20
|
+
return formatTime(value);
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === 'number') {
|
|
23
|
+
if (Number.isInteger(value)) return value;
|
|
24
|
+
return value.toFixed(2);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
18
28
|
if (active && payload && payload.length) {
|
|
19
29
|
const newPayload = payload.filter(item => item.name !== 'bounds');
|
|
20
30
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -22,14 +32,14 @@ const CustomTooltipContent = ({
|
|
|
22
32
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
|
|
23
33
|
}, /*#__PURE__*/React.createElement("p", {
|
|
24
34
|
className: "label"
|
|
25
|
-
},
|
|
35
|
+
}, isDateValue ? formatDate(label, dateFormat) : label), newPayload.map(entry => /*#__PURE__*/React.createElement("p", {
|
|
26
36
|
className: "label",
|
|
27
37
|
key: `${entry.name}`,
|
|
28
38
|
style: {
|
|
29
39
|
color: entry.color,
|
|
30
40
|
textTransform: 'capitalize'
|
|
31
41
|
}
|
|
32
|
-
}, `${entry.name}: ${
|
|
42
|
+
}, `${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`)));
|
|
33
43
|
}
|
|
34
44
|
return null;
|
|
35
45
|
};
|
|
@@ -42,10 +52,6 @@ CustomTooltipContent.propTypes = {
|
|
|
42
52
|
* Additional class names for the dropdown component.
|
|
43
53
|
*/
|
|
44
54
|
className: PropTypes.string,
|
|
45
|
-
/**
|
|
46
|
-
* The label for the x-axis.
|
|
47
|
-
*/
|
|
48
|
-
xLabel: PropTypes.string,
|
|
49
55
|
/**
|
|
50
56
|
* Flag on whether it is a timeformat or not
|
|
51
57
|
*/
|
|
@@ -54,6 +60,10 @@ CustomTooltipContent.propTypes = {
|
|
|
54
60
|
* The type of format for the datetime value
|
|
55
61
|
*/
|
|
56
62
|
dateFormat: PropTypes.oneOf(Object.values(DATE_FORMATS)),
|
|
63
|
+
/**
|
|
64
|
+
* Flag on whether the label is a date value or not
|
|
65
|
+
*/
|
|
66
|
+
isDateValue: PropTypes.bool,
|
|
57
67
|
/**
|
|
58
68
|
* If set true, the tooltip is displayed.
|
|
59
69
|
* If set false, the tooltip is hidden, usually calculated internally.
|
|
@@ -71,6 +81,7 @@ CustomTooltipContent.propTypes = {
|
|
|
71
81
|
};
|
|
72
82
|
CustomTooltipContent.defaultProps = {
|
|
73
83
|
isTimeFormat: false,
|
|
84
|
+
isDateValue: true,
|
|
74
85
|
dateFormat: DATE_FORMATS.HUMAN_READABLE
|
|
75
86
|
};
|
|
76
87
|
export default CustomTooltipContent;
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styleNames from '@pareto-engineering/bem/exports';
|
|
5
|
+
import { snakeCaseToTitleCase } from "../../../../utils";
|
|
5
6
|
import "./styles.scss";
|
|
6
|
-
|
|
7
|
-
// Local Definitions
|
|
8
|
-
|
|
9
7
|
const baseClassName = styleNames.base;
|
|
10
8
|
const componentClassName = 'y-labels-dropdown';
|
|
11
9
|
const YLabelsDropDown = ({
|
|
@@ -46,7 +44,7 @@ const YLabelsDropDown = ({
|
|
|
46
44
|
style: {
|
|
47
45
|
backgroundColor: item.color
|
|
48
46
|
}
|
|
49
|
-
}), item.label, selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
}), snakeCaseToTitleCase(item.label), selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
|
|
50
48
|
className: "icon checkmark"
|
|
51
49
|
}, "I")))));
|
|
52
50
|
};
|
|
@@ -83,6 +81,6 @@ YLabelsDropDown.propTypes = {
|
|
|
83
81
|
}))
|
|
84
82
|
};
|
|
85
83
|
YLabelsDropDown.defaultProps = {
|
|
86
|
-
placeholder: '
|
|
84
|
+
placeholder: 'Select Item'
|
|
87
85
|
};
|
|
88
86
|
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,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
|
+
}
|
|
@@ -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/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, BarChart } from "./Charts";
|
|
31
|
+
export { AreaChart, BarChart, PieChart } from "./Charts";
|
|
@@ -22,7 +22,7 @@ const FormInput = ({
|
|
|
22
22
|
disabled,
|
|
23
23
|
...otherProps
|
|
24
24
|
}) => {
|
|
25
|
-
const newClassName = [className, componentClassName].filter(Boolean).join(' ');
|
|
25
|
+
const newClassName = [className, componentClassName, otherProps.hasCharacterLimit && otherProps.maxLength && `limit-character-count-${otherProps.maxLength}`].filter(Boolean).join(' ');
|
|
26
26
|
if (type === 'textarea') {
|
|
27
27
|
return /*#__PURE__*/React.createElement(TextareaInput, _extends({
|
|
28
28
|
className: newClassName,
|
|
@@ -25,7 +25,7 @@ import styleNames from '@pareto-engineering/bem/exports';
|
|
|
25
25
|
// Local Definitions
|
|
26
26
|
|
|
27
27
|
import { FormLabel, FormDescription } from "../../common";
|
|
28
|
-
import { ToolbarPlugin, TreeViewPlugin, StopPropagationPlugin } from "./common";
|
|
28
|
+
import { ToolbarPlugin, TreeViewPlugin, StopPropagationPlugin, ExposePlainTextPlugin } from "./common";
|
|
29
29
|
import "./styles.scss";
|
|
30
30
|
const baseClassName = styleNames.base;
|
|
31
31
|
const componentClassName = 'editor-input';
|
|
@@ -56,7 +56,8 @@ const EditorInput = ({
|
|
|
56
56
|
description,
|
|
57
57
|
disabled,
|
|
58
58
|
showDebugger,
|
|
59
|
-
setEditorState
|
|
59
|
+
setEditorState,
|
|
60
|
+
setPlainTextKey
|
|
60
61
|
// ...otherProps
|
|
61
62
|
}) => {
|
|
62
63
|
const [field,,] = useField(name);
|
|
@@ -128,7 +129,7 @@ const EditorInput = ({
|
|
|
128
129
|
'--resize': resize,
|
|
129
130
|
'--rows': `${rows}em`
|
|
130
131
|
}
|
|
131
|
-
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
132
|
+
}, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
132
133
|
name: name,
|
|
133
134
|
color: labelColor,
|
|
134
135
|
optional: optional
|
|
@@ -147,7 +148,10 @@ const EditorInput = ({
|
|
|
147
148
|
className: "s-1",
|
|
148
149
|
description: description,
|
|
149
150
|
name: name
|
|
150
|
-
}), showDebugger && /*#__PURE__*/React.createElement(TreeViewPlugin, null)
|
|
151
|
+
}), showDebugger && /*#__PURE__*/React.createElement(TreeViewPlugin, null), setPlainTextKey && /*#__PURE__*/React.createElement(ExposePlainTextPlugin, {
|
|
152
|
+
setFieldValue: setFieldValue,
|
|
153
|
+
setPlainTextKey: setPlainTextKey
|
|
154
|
+
})));
|
|
151
155
|
};
|
|
152
156
|
EditorInput.propTypes = {
|
|
153
157
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { $getRoot } from 'lexical';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is the component description
|
|
8
|
+
*/
|
|
9
|
+
const ExposePlainTextPlugin = ({
|
|
10
|
+
setFieldValue,
|
|
11
|
+
setPlainTextKey
|
|
12
|
+
}) => {
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
useEffect(() => editor.registerUpdateListener(({
|
|
15
|
+
editorState
|
|
16
|
+
}) => {
|
|
17
|
+
editorState.read(() => {
|
|
18
|
+
const root = $getRoot();
|
|
19
|
+
const textContent = root.getTextContent();
|
|
20
|
+
setFieldValue(setPlainTextKey, textContent);
|
|
21
|
+
});
|
|
22
|
+
}), [editor]);
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
ExposePlainTextPlugin.propTypes = {
|
|
26
|
+
setFieldValue: PropTypes.func.isRequired,
|
|
27
|
+
setPlainTextKey: PropTypes.string.isRequired
|
|
28
|
+
};
|
|
29
|
+
ExposePlainTextPlugin.defaultProps = {
|
|
30
|
+
//
|
|
31
|
+
};
|
|
32
|
+
export default ExposePlainTextPlugin;
|
|
@@ -168,7 +168,7 @@ const ToolbarPlugin = ({
|
|
|
168
168
|
}, [applyStyleText]);
|
|
169
169
|
return /*#__PURE__*/React.createElement("div", {
|
|
170
170
|
id: id,
|
|
171
|
-
className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor}`].filter(e => e).join(' '),
|
|
171
|
+
className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor} b-x`].filter(e => e).join(' '),
|
|
172
172
|
style: inlineStyles
|
|
173
173
|
}, /*#__PURE__*/React.createElement("div", {
|
|
174
174
|
className: "group"
|
|
@@ -3,4 +3,5 @@ export { default as TreeViewPlugin } from "./TreeViewPlugin";
|
|
|
3
3
|
export { default as StopPropagationPlugin } from "./StopPropagationPlugin";
|
|
4
4
|
export { ToolbarPlugin } from "./ToolbarPlugin";
|
|
5
5
|
export { ColorPicker } from "./ColorPicker";
|
|
6
|
-
export { FontSizeDropDown } from "./FontSizeDropDown";
|
|
6
|
+
export { FontSizeDropDown } from "./FontSizeDropDown";
|
|
7
|
+
export { default as ExposePlainTextPlugin } from "./ExposePlainTextPlugin";
|
|
@@ -34,7 +34,7 @@ const LatexPreviewInput = ({
|
|
|
34
34
|
const LatexPreview = useMemo(() => convertLatexToHtml(values[name]), [values[name]]);
|
|
35
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
36
36
|
id: id,
|
|
37
|
-
className: [baseClassName, componentClassName, userClassName, 'form-input'].filter(e => e).join(' '),
|
|
37
|
+
className: [baseClassName, componentClassName, className, userClassName, 'form-input'].filter(e => e).join(' '),
|
|
38
38
|
style: style
|
|
39
39
|
}, /*#__PURE__*/React.createElement(TextareaInput, _extends({
|
|
40
40
|
className: "preview-child",
|
|
@@ -31,7 +31,8 @@ const TextareaInput = ({
|
|
|
31
31
|
disabled,
|
|
32
32
|
placeholder,
|
|
33
33
|
autoComplete,
|
|
34
|
-
resize
|
|
34
|
+
resize,
|
|
35
|
+
maxLength
|
|
35
36
|
// ...otherProps
|
|
36
37
|
}) => {
|
|
37
38
|
const [field] = useField({
|
|
@@ -56,7 +57,8 @@ const TextareaInput = ({
|
|
|
56
57
|
placeholder: placeholder,
|
|
57
58
|
rows: rows,
|
|
58
59
|
disabled: disabled,
|
|
59
|
-
autoComplete: autoComplete
|
|
60
|
+
autoComplete: autoComplete,
|
|
61
|
+
maxLength: maxLength
|
|
60
62
|
})), /*#__PURE__*/React.createElement(FormDescription, {
|
|
61
63
|
className: "s-1",
|
|
62
64
|
description: description,
|
|
@@ -27,7 +27,8 @@ const ExpandableLexicalPreview = ({
|
|
|
27
27
|
pageTitle,
|
|
28
28
|
onBlock,
|
|
29
29
|
onOpen,
|
|
30
|
-
header
|
|
30
|
+
header,
|
|
31
|
+
rows
|
|
31
32
|
// ...otherProps
|
|
32
33
|
}) => {
|
|
33
34
|
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
@@ -68,7 +69,8 @@ const ExpandableLexicalPreview = ({
|
|
|
68
69
|
name: name,
|
|
69
70
|
resize: resize,
|
|
70
71
|
disabled: true,
|
|
71
|
-
id:
|
|
72
|
+
id: `${id}-editor-input`,
|
|
73
|
+
rows: rows
|
|
72
74
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
73
75
|
id: id,
|
|
74
76
|
className: "expand-button ai-icon",
|
|
@@ -53,6 +53,7 @@ const InputBuilder = ({
|
|
|
53
53
|
const handleToggleShowSpecificFileTypes = () => {
|
|
54
54
|
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.showSpecificFileTypes`, !input.showSpecificFileTypes);
|
|
55
55
|
};
|
|
56
|
+
const textChoices = ['text', 'number', 'textarea', 'latex-preview-input'];
|
|
56
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
58
|
id: id,
|
|
58
59
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
@@ -129,7 +130,32 @@ const InputBuilder = ({
|
|
|
129
130
|
label: "Description (optional)",
|
|
130
131
|
name: `sections.${sectionIndex}.inputs.${inputIndex}.description`,
|
|
131
132
|
placeholder: "Describe details for the question"
|
|
132
|
-
})),
|
|
133
|
+
})), textChoices.includes(input?.type) && /*#__PURE__*/React.createElement("div", {
|
|
134
|
+
className: "character-limit-container"
|
|
135
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
className: "is-required"
|
|
137
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
138
|
+
className: "s0"
|
|
139
|
+
}, "Limit number of characters permitted for this input"), /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
140
|
+
handleOnChange: () => {
|
|
141
|
+
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.hasCharacterLimit`, !input?.hasCharacterLimit);
|
|
142
|
+
if (!input?.hasCharacterLimit) {
|
|
143
|
+
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.maxLength`, '');
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
checked: input?.hasCharacterLimit,
|
|
147
|
+
style: getToggleSwitchStyles(!input?.hasCharacterLimit),
|
|
148
|
+
inputId: `sections_${sectionIndex}_inputs.${inputIndex}_character_limit_toggle`
|
|
149
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
className: "character-limit-input"
|
|
151
|
+
}, input?.hasCharacterLimit && /*#__PURE__*/React.createElement(TextInput, {
|
|
152
|
+
label: "Enter the maximum number of characters permitted.",
|
|
153
|
+
name: `sections.${sectionIndex}.inputs.${inputIndex}.maxLength`,
|
|
154
|
+
placeholder: "",
|
|
155
|
+
type: "number",
|
|
156
|
+
validate: integerAndGreaterThanZero,
|
|
157
|
+
value: input?.maxLength
|
|
158
|
+
}))), shouldRenderOptions && /*#__PURE__*/React.createElement(FieldArray, {
|
|
133
159
|
name: `sections.${sectionIndex}.inputs.${inputIndex}.options`
|
|
134
160
|
}, ({
|
|
135
161
|
push,
|
|
@@ -64,6 +64,21 @@ $default-list-width: var(--action-button-width, 18rem);
|
|
|
64
64
|
margin-bottom: $default-margin;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
> .character-limit-container {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: var(--gap);
|
|
71
|
+
|
|
72
|
+
> .is-required {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: row;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
> .character-limit-input {
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
67
82
|
> .input-options {
|
|
68
83
|
display: flex;
|
|
69
84
|
flex-direction: column;
|
|
@@ -49,7 +49,10 @@ const Section = ({
|
|
|
49
49
|
inputs
|
|
50
50
|
} = section;
|
|
51
51
|
useEffect(() => {
|
|
52
|
-
const
|
|
52
|
+
const orderMap = new Map();
|
|
53
|
+
section.orderedInputDragIds.forEach((identifier, indx) => orderMap.set(identifier, indx));
|
|
54
|
+
const orderedInputs = inputs.sort((a, b) => orderMap.get(a.name) - orderMap.get(b.name));
|
|
55
|
+
const items = orderedInputs.map((input, indx) => ({
|
|
53
56
|
Content: /*#__PURE__*/React.createElement(InputBuilder, {
|
|
54
57
|
key: input.name,
|
|
55
58
|
sectionIndex: index,
|
|
@@ -61,6 +64,7 @@ const Section = ({
|
|
|
61
64
|
}));
|
|
62
65
|
setDraggableInputs(items);
|
|
63
66
|
}, [inputs.length, index]);
|
|
67
|
+
const dragAndDropKey = draggableInputs.map(e => e.identifier).join(',');
|
|
64
68
|
return /*#__PURE__*/React.createElement("div", {
|
|
65
69
|
id: id,
|
|
66
70
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
@@ -92,7 +96,7 @@ const Section = ({
|
|
|
92
96
|
const ids = reOrderedItems.map(e => e.identifier);
|
|
93
97
|
setFieldValue(`sections.${index}.orderedInputDragIds`, ids);
|
|
94
98
|
},
|
|
95
|
-
key:
|
|
99
|
+
key: dragAndDropKey
|
|
96
100
|
}), /*#__PURE__*/React.createElement("button", {
|
|
97
101
|
type: "button",
|
|
98
102
|
className: "add-question-cta",
|
|
@@ -10,6 +10,7 @@ import "./styles.scss";
|
|
|
10
10
|
|
|
11
11
|
// Local Definitions
|
|
12
12
|
|
|
13
|
+
import { applyCharacterLimit } from "../../../../utils";
|
|
13
14
|
import { Section } from "./common";
|
|
14
15
|
const baseClassName = styleNames.base;
|
|
15
16
|
const componentClassName = 'renderer';
|
|
@@ -134,6 +135,11 @@ const Renderer = ({
|
|
|
134
135
|
onSave?.(formDataWithValues);
|
|
135
136
|
}
|
|
136
137
|
}, [values]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
applyCharacterLimit({
|
|
140
|
+
setMaxLength: false
|
|
141
|
+
});
|
|
142
|
+
}, [values]);
|
|
137
143
|
const hasErrors = Object.keys(errors).length > 0;
|
|
138
144
|
return /*#__PURE__*/React.createElement(Form, null, updatedFormData.sections.map((section, sectionIndex) => sectionIndex === currentSectionIndex && /*#__PURE__*/React.createElement(Section, _extends({
|
|
139
145
|
key: `${section.title}`
|