@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,105 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
6
|
+
|
|
7
|
+
import { formatTime, formatDate, DATE_FORMATS } from 'ui/utils'
|
|
8
|
+
|
|
9
|
+
import './styles.scss'
|
|
10
|
+
|
|
11
|
+
const baseClassName = styleNames.base
|
|
12
|
+
|
|
13
|
+
const componentClassName = 'custom-tooltip-content'
|
|
14
|
+
|
|
15
|
+
const CustomTooltipContent = ({
|
|
16
|
+
id,
|
|
17
|
+
className: userClassName,
|
|
18
|
+
xLabel,
|
|
19
|
+
dateFormat,
|
|
20
|
+
isTimeFormat,
|
|
21
|
+
active,
|
|
22
|
+
payload,
|
|
23
|
+
label,
|
|
24
|
+
}) => {
|
|
25
|
+
if (active && payload && payload.length) {
|
|
26
|
+
const newPayload = payload.filter((item) => item.name !== 'bounds')
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
id={id}
|
|
30
|
+
className={[
|
|
31
|
+
baseClassName,
|
|
32
|
+
componentClassName,
|
|
33
|
+
userClassName,
|
|
34
|
+
]
|
|
35
|
+
.filter((e) => e)
|
|
36
|
+
.join(' ')}
|
|
37
|
+
>
|
|
38
|
+
<p className="label">
|
|
39
|
+
{`${xLabel}: ${formatDate(label, dateFormat)}`}
|
|
40
|
+
</p>
|
|
41
|
+
{newPayload.map((entry) => (
|
|
42
|
+
<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
|
+
}`}
|
|
48
|
+
</p>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
CustomTooltipContent.propTypes = {
|
|
57
|
+
/**
|
|
58
|
+
* The id of the dropdown component.
|
|
59
|
+
*/
|
|
60
|
+
id:PropTypes.string,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Additional class names for the dropdown component.
|
|
64
|
+
*/
|
|
65
|
+
className:PropTypes.string,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The label for the x-axis.
|
|
69
|
+
*/
|
|
70
|
+
xLabel:PropTypes.string,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Flag on whether it is a timeformat or not
|
|
74
|
+
*/
|
|
75
|
+
isTimeFormat:PropTypes.bool,
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The type of format for the datetime value
|
|
79
|
+
*/
|
|
80
|
+
dateFormat:PropTypes.oneOf(Object.values(DATE_FORMATS)),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* If set true, the tooltip is displayed.
|
|
84
|
+
* If set false, the tooltip is hidden, usually calculated internally.
|
|
85
|
+
*/
|
|
86
|
+
active:PropTypes.bool.isRequired,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The source data of the content to be displayed in the tooltip,
|
|
90
|
+
* always calculated internally and cannot be user set.
|
|
91
|
+
*/
|
|
92
|
+
payload:PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
*The label value which is active now, usually calculated internally.
|
|
96
|
+
*/
|
|
97
|
+
label:PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
CustomTooltipContent.defaultProps = {
|
|
101
|
+
isTimeFormat:false,
|
|
102
|
+
dateFormat :DATE_FORMATS.HUMAN_READABLE,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
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,121 @@
|
|
|
1
|
+
// DropdownStatus.js
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
7
|
+
|
|
8
|
+
import './styles.scss'
|
|
9
|
+
|
|
10
|
+
// Local Definitions
|
|
11
|
+
|
|
12
|
+
const baseClassName = styleNames.base
|
|
13
|
+
|
|
14
|
+
const componentClassName = 'y-labels-dropdown'
|
|
15
|
+
|
|
16
|
+
const YLabelsDropDown = ({
|
|
17
|
+
id,
|
|
18
|
+
className: userClassName,
|
|
19
|
+
placeholder,
|
|
20
|
+
selectedYLabels,
|
|
21
|
+
setSelectedYLabels,
|
|
22
|
+
allYLabels,
|
|
23
|
+
}) => {
|
|
24
|
+
const [isOpen, setIsOpen] = React.useState(false)
|
|
25
|
+
|
|
26
|
+
const toggleYLabel = (yLabel) => {
|
|
27
|
+
setSelectedYLabels((prev) => (prev.some((label) => label.label === yLabel.label)
|
|
28
|
+
? prev.filter((label) => label.label !== yLabel.label)
|
|
29
|
+
: [...prev, yLabel]),
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
id={id}
|
|
36
|
+
className={[
|
|
37
|
+
baseClassName,
|
|
38
|
+
componentClassName,
|
|
39
|
+
userClassName,
|
|
40
|
+
]
|
|
41
|
+
.filter((e) => e)
|
|
42
|
+
.join(' ')}
|
|
43
|
+
>
|
|
44
|
+
<button
|
|
45
|
+
className="dropdown-button"
|
|
46
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
47
|
+
type="button"
|
|
48
|
+
>
|
|
49
|
+
{placeholder}
|
|
50
|
+
<span className={`icon ${isOpen ? styleNames.modifierOpen : ''}`}>
|
|
51
|
+
W
|
|
52
|
+
</span>
|
|
53
|
+
</button>
|
|
54
|
+
<div className={`dropdown-content ${isOpen ? styleNames.modifierOpen : ''}`}>
|
|
55
|
+
{allYLabels.map((item) => (
|
|
56
|
+
// eslint-disable-next-line max-len
|
|
57
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
|
|
58
|
+
<div
|
|
59
|
+
key={item.label}
|
|
60
|
+
className={`dropdown-item ${selectedYLabels.some((label) => label.label === item.label) ? styleNames.modifierActive : ''}`}
|
|
61
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
62
|
+
onClick={() => toggleYLabel(item)}
|
|
63
|
+
>
|
|
64
|
+
<span
|
|
65
|
+
className="status-dot"
|
|
66
|
+
style={{ backgroundColor: item.color }}
|
|
67
|
+
/>
|
|
68
|
+
{item.label}
|
|
69
|
+
{selectedYLabels.some((label) => label.label === item.label) && (
|
|
70
|
+
<span className="icon checkmark">I</span>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
YLabelsDropDown.propTypes = {
|
|
80
|
+
/**
|
|
81
|
+
* The id of the dropdown component.
|
|
82
|
+
*/
|
|
83
|
+
id:PropTypes.string,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Additional class names for the dropdown component.
|
|
87
|
+
*/
|
|
88
|
+
className:PropTypes.string,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Placeholder text for the dropdown button.
|
|
92
|
+
*/
|
|
93
|
+
placeholder:PropTypes.string,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Array of selected Y labels with their corresponding colors.
|
|
97
|
+
*/
|
|
98
|
+
selectedYLabels:PropTypes.arrayOf(PropTypes.shape({
|
|
99
|
+
label:PropTypes.string,
|
|
100
|
+
color:PropTypes.string,
|
|
101
|
+
})),
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Function to set the selected Y labels.
|
|
105
|
+
*/
|
|
106
|
+
setSelectedYLabels:PropTypes.func,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Array of all Y labels with their corresponding colors.
|
|
110
|
+
*/
|
|
111
|
+
allYLabels:PropTypes.arrayOf(PropTypes.shape({
|
|
112
|
+
label:PropTypes.string,
|
|
113
|
+
color:PropTypes.string,
|
|
114
|
+
})),
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
YLabelsDropDown.defaultProps = {
|
|
118
|
+
placeholder:'Submission status',
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
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/src/ui/a/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
LinkInput,
|
|
19
19
|
EditorInput,
|
|
20
20
|
FileUpload,
|
|
21
|
+
LatexPreviewInput,
|
|
21
22
|
} from '../fields'
|
|
22
23
|
|
|
23
24
|
import './styles.scss'
|
|
@@ -158,6 +159,16 @@ const FormInput = ({
|
|
|
158
159
|
)
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
if (type === 'latex-preview-input') {
|
|
163
|
+
return (
|
|
164
|
+
<LatexPreviewInput
|
|
165
|
+
className={newClassName}
|
|
166
|
+
disabled={disabled}
|
|
167
|
+
{...otherProps}
|
|
168
|
+
/>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
161
172
|
if (extraTypes?.[type]) {
|
|
162
173
|
const Component = extraTypes[type]
|
|
163
174
|
return (
|
|
@@ -19,6 +19,16 @@ const baseClassName = styleNames.base
|
|
|
19
19
|
|
|
20
20
|
const componentClassName = 'file-upload'
|
|
21
21
|
|
|
22
|
+
const generateUniqueFileName = (originalName, existingFileNames) => {
|
|
23
|
+
const lastDotIndex = originalName.lastIndexOf('.')
|
|
24
|
+
const name = originalName.substring(0, lastDotIndex)
|
|
25
|
+
const ext = originalName.split('.').pop()
|
|
26
|
+
const numDuplicates = existingFileNames.filter(
|
|
27
|
+
(existingFileName) => existingFileName?.startsWith(name),
|
|
28
|
+
).length
|
|
29
|
+
return numDuplicates > 0 ? `${name} (${numDuplicates}).${ext}` : originalName
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
/**
|
|
23
33
|
* This is the component description.
|
|
24
34
|
*/
|
|
@@ -54,7 +64,7 @@ const FileUpload = ({
|
|
|
54
64
|
|
|
55
65
|
const handleChange = (event) => {
|
|
56
66
|
setTouched(true, false)
|
|
57
|
-
|
|
67
|
+
let newFiles = Array.from(event.currentTarget.files)
|
|
58
68
|
const currentFiles = value || []
|
|
59
69
|
|
|
60
70
|
const currentCount = currentFiles.length + newFiles.length
|
|
@@ -63,13 +73,23 @@ const FileUpload = ({
|
|
|
63
73
|
return
|
|
64
74
|
}
|
|
65
75
|
|
|
76
|
+
const uploadedFiles = Object.keys(uploadStatus) || []
|
|
77
|
+
|
|
66
78
|
const duplicateFiles = newFiles.filter(
|
|
67
|
-
(newFile) =>
|
|
79
|
+
(newFile) => uploadedFiles.some((uploadedFile) => uploadedFile === newFile.name),
|
|
68
80
|
)
|
|
69
81
|
|
|
70
82
|
if (duplicateFiles.length > 0) {
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
newFiles = newFiles.map((file) => {
|
|
84
|
+
if (duplicateFiles.some((duplicateFile) => duplicateFile.name === file.name)) {
|
|
85
|
+
return new File(
|
|
86
|
+
[file],
|
|
87
|
+
generateUniqueFileName(file.name, uploadedFiles),
|
|
88
|
+
{ type: file.type },
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
return file
|
|
92
|
+
})
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
if (maxSize) {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { memo, useMemo } from 'react'
|
|
5
|
+
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
|
|
8
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
9
|
+
|
|
10
|
+
import { useFormikContext } from 'formik'
|
|
11
|
+
|
|
12
|
+
import convertLatexToHtml from './convertLatexToHtml'
|
|
13
|
+
|
|
14
|
+
import { TextareaInput } from '../TextareaInput'
|
|
15
|
+
|
|
16
|
+
import './styles.scss'
|
|
17
|
+
|
|
18
|
+
// Local Definitions
|
|
19
|
+
|
|
20
|
+
const baseClassName = styleNames.base
|
|
21
|
+
|
|
22
|
+
const componentClassName = 'latex-preview-input'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This is the component description.
|
|
26
|
+
*/
|
|
27
|
+
const LatexPreviewInput = ({
|
|
28
|
+
id,
|
|
29
|
+
className,
|
|
30
|
+
userClassName,
|
|
31
|
+
disabled,
|
|
32
|
+
style,
|
|
33
|
+
...otherProps
|
|
34
|
+
}) => {
|
|
35
|
+
const { name } = otherProps
|
|
36
|
+
|
|
37
|
+
const { values } = useFormikContext()
|
|
38
|
+
|
|
39
|
+
const LatexPreview = useMemo(() => convertLatexToHtml(values[name]), [values[name]])
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
id={id}
|
|
44
|
+
className={[
|
|
45
|
+
baseClassName,
|
|
46
|
+
componentClassName,
|
|
47
|
+
userClassName,
|
|
48
|
+
'form-input',
|
|
49
|
+
]
|
|
50
|
+
.filter((e) => e)
|
|
51
|
+
.join(' ')}
|
|
52
|
+
style={style}
|
|
53
|
+
>
|
|
54
|
+
<TextareaInput
|
|
55
|
+
className="preview-child"
|
|
56
|
+
disabled={disabled}
|
|
57
|
+
{...otherProps}
|
|
58
|
+
/>
|
|
59
|
+
{/* eslint-disable-next-line react/no-danger */}
|
|
60
|
+
<div className="latex-container preview-child" dangerouslySetInnerHTML={{ __html: LatexPreview }} />
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
LatexPreviewInput.propTypes = {
|
|
66
|
+
/**
|
|
67
|
+
* The HTML id for this element
|
|
68
|
+
*/
|
|
69
|
+
id:PropTypes.string,
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The HTML class names for this element
|
|
73
|
+
*/
|
|
74
|
+
className:PropTypes.string,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The React-written, css properties for this element.
|
|
78
|
+
*/
|
|
79
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether the Form input input should be disabled
|
|
83
|
+
*/
|
|
84
|
+
disabled:PropTypes.bool,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
LatexPreviewInput.defaultProps = {
|
|
88
|
+
disabled:false,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default memo(LatexPreviewInput)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import ReactMarkdown from 'react-markdown'
|
|
4
|
+
|
|
5
|
+
import RemarkMathPlugin from 'remark-math'
|
|
6
|
+
|
|
7
|
+
import { MathJax, MathJaxContext } from 'better-react-mathjax'
|
|
8
|
+
|
|
9
|
+
import rehypeMathjax from 'rehype-mathjax/svg'
|
|
10
|
+
|
|
11
|
+
import ReactDOMServer from 'react-dom/server'
|
|
12
|
+
|
|
13
|
+
const convertLatexToHtml = (content) => {
|
|
14
|
+
if (content.includes('https://forte-assets.pareto.ai/')) {
|
|
15
|
+
return content
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const processedContent = content.replaceAll(/\\\\/g, '\n\n')
|
|
19
|
+
|
|
20
|
+
const renderedContent = ReactDOMServer.renderToString(
|
|
21
|
+
<MathJaxContext>
|
|
22
|
+
<ReactMarkdown
|
|
23
|
+
remarkPlugins={[RemarkMathPlugin]}
|
|
24
|
+
rehypePlugins={[rehypeMathjax]}
|
|
25
|
+
components={{
|
|
26
|
+
math :({ value }) => <MathJax.Node formula={value} />,
|
|
27
|
+
inlineMath:({ value }) => <MathJax.Node inline formula={value} />,
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{processedContent}
|
|
31
|
+
</ReactMarkdown>
|
|
32
|
+
</MathJaxContext>,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return renderedContent
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
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
|
+
}
|
package/src/ui/f/fields/index.js
CHANGED
|
@@ -9,6 +9,10 @@ export { Checkbox } from './Checkbox'
|
|
|
9
9
|
export { QueryChoices } from './QueryChoices'
|
|
10
10
|
export { LinkInput } from './LinkInput'
|
|
11
11
|
export { EditorInput } from './EditorInput'
|
|
12
|
+
export {
|
|
13
|
+
LatexPreviewInput,
|
|
14
|
+
convertLatexToHtml,
|
|
15
|
+
} from './LatexPreviewInput'
|
|
12
16
|
export {
|
|
13
17
|
FileUpload,
|
|
14
18
|
fileUploadOptions,
|
|
@@ -36,7 +36,6 @@ const FormBuilder = ({
|
|
|
36
36
|
fileUploadStatus,
|
|
37
37
|
handleFileDelete,
|
|
38
38
|
taskData,
|
|
39
|
-
customInputMap,
|
|
40
39
|
// ...otherProps
|
|
41
40
|
}) => {
|
|
42
41
|
const formattedJson = JSON.stringify(taskData, null, 2)
|
|
@@ -68,7 +67,6 @@ const FormBuilder = ({
|
|
|
68
67
|
onSave={onBuilderFormSave}
|
|
69
68
|
onError={onBuilderError}
|
|
70
69
|
validate={onBuilderValidate}
|
|
71
|
-
customInputMap={customInputMap}
|
|
72
70
|
/>
|
|
73
71
|
)}
|
|
74
72
|
{mode === 'render' && (
|
|
@@ -80,7 +78,6 @@ const FormBuilder = ({
|
|
|
80
78
|
fileUploadStatus={fileUploadStatus}
|
|
81
79
|
handleFileDelete={handleFileDelete}
|
|
82
80
|
onFileUpload={onFileUpload}
|
|
83
|
-
customInputMap={customInputMap}
|
|
84
81
|
/>
|
|
85
82
|
)}
|
|
86
83
|
</div>
|
|
@@ -43,7 +43,6 @@ const Builder = ({
|
|
|
43
43
|
onError,
|
|
44
44
|
validate,
|
|
45
45
|
formBuilderId,
|
|
46
|
-
customInputMap,
|
|
47
46
|
initialValues = {},
|
|
48
47
|
// ...otherProps
|
|
49
48
|
}) => {
|
|
@@ -126,7 +125,6 @@ const Builder = ({
|
|
|
126
125
|
handleDeleteSection={() => handleDeleteSection({
|
|
127
126
|
index, remove, values, setFieldValue,
|
|
128
127
|
})}
|
|
129
|
-
customInputMap={customInputMap}
|
|
130
128
|
/>
|
|
131
129
|
))}
|
|
132
130
|
<div className="section-footer">
|