@pareto-engineering/design-system 5.2.1 → 5.3.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 +60 -5
- package/dist/cjs/a/Charts/AreaChart/styles.scss +22 -0
- package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +19 -5
- package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +133 -68
- package/dist/cjs/a/Charts/PieChart/PieChart.js +20 -7
- package/dist/cjs/a/ThroughPutIndicator/ThroughPutIndicator.js +78 -0
- package/dist/cjs/a/ThroughPutIndicator/index.js +13 -0
- package/dist/cjs/a/ThroughPutIndicator/styles.scss +35 -0
- package/dist/cjs/a/ToggleSwitch/ToggleSwitch.js +2 -1
- package/dist/cjs/a/ToggleSwitch/styles.scss +9 -2
- package/dist/cjs/a/Tooltip/Tooltip.js +19 -2
- package/dist/cjs/a/Tooltip/styles.scss +32 -4
- package/dist/cjs/a/index.js +8 -1
- package/dist/cjs/f/FormInput/FormInput.js +7 -1
- package/dist/cjs/f/fields/ToggleInput/ToggleInput.js +126 -0
- package/dist/cjs/f/fields/ToggleInput/index.js +13 -0
- package/dist/cjs/f/fields/ToggleInput/styles.scss +22 -0
- package/dist/cjs/f/fields/index.js +8 -1
- package/dist/cjs/utils/formatting.js +27 -18
- package/dist/cjs/utils/index.js +6 -0
- package/dist/es/a/Charts/AreaChart/AreaChart.js +61 -6
- package/dist/es/a/Charts/AreaChart/styles.scss +22 -0
- package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +19 -5
- package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +122 -66
- package/dist/es/a/Charts/PieChart/PieChart.js +20 -7
- package/dist/es/a/ThroughPutIndicator/ThroughPutIndicator.js +66 -0
- package/dist/es/a/ThroughPutIndicator/index.js +2 -0
- package/dist/es/a/ThroughPutIndicator/styles.scss +35 -0
- package/dist/es/a/ToggleSwitch/ToggleSwitch.js +2 -1
- package/dist/es/a/ToggleSwitch/styles.scss +9 -2
- package/dist/es/a/Tooltip/Tooltip.js +31 -12
- package/dist/es/a/Tooltip/styles.scss +32 -4
- package/dist/es/a/index.js +2 -1
- package/dist/es/f/FormInput/FormInput.js +8 -2
- package/dist/es/f/fields/ToggleInput/ToggleInput.js +116 -0
- package/dist/es/f/fields/ToggleInput/index.js +2 -0
- package/dist/es/f/fields/ToggleInput/styles.scss +22 -0
- package/dist/es/f/fields/index.js +2 -1
- package/dist/es/utils/formatting.js +25 -17
- package/dist/es/utils/index.js +1 -1
- package/package.json +5 -5
- package/src/ui/a/Charts/AreaChart/AreaChart.jsx +73 -9
- package/src/ui/a/Charts/AreaChart/styles.scss +22 -0
- package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +20 -5
- package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +126 -79
- package/src/ui/a/Charts/PieChart/PieChart.jsx +38 -17
- package/src/ui/a/ThroughPutIndicator/ThroughPutIndicator.jsx +90 -0
- package/src/ui/a/ThroughPutIndicator/index.js +2 -0
- package/src/ui/a/ThroughPutIndicator/styles.scss +35 -0
- package/src/ui/a/ToggleSwitch/ToggleSwitch.jsx +1 -1
- package/src/ui/a/ToggleSwitch/styles.scss +9 -2
- package/src/ui/a/Tooltip/Tooltip.jsx +55 -26
- package/src/ui/a/Tooltip/styles.scss +32 -4
- package/src/ui/a/index.js +1 -0
- package/src/ui/f/FormInput/FormInput.jsx +11 -0
- package/src/ui/f/fields/ToggleInput/ToggleInput.jsx +140 -0
- package/src/ui/f/fields/ToggleInput/index.js +2 -0
- package/src/ui/f/fields/ToggleInput/styles.scss +22 -0
- package/src/ui/f/fields/index.js +1 -0
- package/src/ui/utils/formatting.js +38 -29
- package/src/ui/utils/index.js +1 -1
- package/tests/__snapshots__/Storyshots.test.js.snap +7 -1
|
@@ -24,25 +24,53 @@ $default-width: var(--tooltip-width, 20rem);
|
|
|
24
24
|
visibility: hidden;
|
|
25
25
|
z-index: 10;
|
|
26
26
|
|
|
27
|
-
&.top {
|
|
27
|
+
&.floating.top {
|
|
28
|
+
left: var(--mouse-x);
|
|
29
|
+
position: fixed;
|
|
30
|
+
top: calc(var(--mouse-y) - $default-block-padding);
|
|
31
|
+
transform: translate(-50%, -100%);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.floating.right {
|
|
35
|
+
left: calc(var(--mouse-x) + $default-inline-padding);
|
|
36
|
+
position: fixed;
|
|
37
|
+
top: var(--mouse-y);
|
|
38
|
+
transform: translateY(-50%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.floating.bottom {
|
|
42
|
+
left: var(--mouse-x);
|
|
43
|
+
position: fixed;
|
|
44
|
+
top: calc(var(--mouse-y) + $default-block-padding);
|
|
45
|
+
transform: translateX(-50%);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.floating.left {
|
|
49
|
+
left: calc(var(--mouse-x) - $default-inline-padding);
|
|
50
|
+
position: fixed;
|
|
51
|
+
top: var(--mouse-y);
|
|
52
|
+
transform: translate(-100%, -50%);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:not(.floating).top {
|
|
28
56
|
--horizontal: -50%;
|
|
29
57
|
bottom: calc(100% + $default-block-padding);
|
|
30
58
|
left: 50%;
|
|
31
59
|
}
|
|
32
60
|
|
|
33
|
-
|
|
61
|
+
&:not(.floating).right {
|
|
34
62
|
--vertical: 50%;
|
|
35
63
|
bottom: 50%;
|
|
36
64
|
left: calc(100% + $default-inline-padding);
|
|
37
65
|
}
|
|
38
66
|
|
|
39
|
-
|
|
67
|
+
&:not(.floating).bottom {
|
|
40
68
|
--horizontal: -50%;
|
|
41
69
|
left: 50%;
|
|
42
70
|
top: calc(100% + $default-block-padding);
|
|
43
71
|
}
|
|
44
72
|
|
|
45
|
-
|
|
73
|
+
&:not(.floating).left {
|
|
46
74
|
--vertical: 50%;
|
|
47
75
|
bottom: 50%;
|
|
48
76
|
right: calc(100% + $default-inline-padding);
|
package/src/ui/a/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
EditorInput,
|
|
20
20
|
FileUpload,
|
|
21
21
|
LatexPreviewInput,
|
|
22
|
+
ToggleInput,
|
|
22
23
|
} from '../fields'
|
|
23
24
|
|
|
24
25
|
import './styles.scss'
|
|
@@ -100,6 +101,15 @@ const FormInput = ({
|
|
|
100
101
|
/>
|
|
101
102
|
)
|
|
102
103
|
}
|
|
104
|
+
if (type === 'toggle') {
|
|
105
|
+
return (
|
|
106
|
+
<ToggleInput
|
|
107
|
+
className={newClassName}
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
{...otherProps}
|
|
110
|
+
/>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
103
113
|
|
|
104
114
|
if (type === 'query-choices') {
|
|
105
115
|
return (
|
|
@@ -218,6 +228,7 @@ FormInput.propTypes = {
|
|
|
218
228
|
'url',
|
|
219
229
|
'rating',
|
|
220
230
|
'checkbox',
|
|
231
|
+
'toggle',
|
|
221
232
|
// to be removed
|
|
222
233
|
'extendedTypeInput',
|
|
223
234
|
]),
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.3 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import { useField } from 'formik'
|
|
5
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
6
|
+
import { ToggleSwitch } from 'ui/a'
|
|
7
|
+
import { FormLabel, FormDescription } from '../../common'
|
|
8
|
+
|
|
9
|
+
import './styles.scss'
|
|
10
|
+
|
|
11
|
+
// Local Definitions
|
|
12
|
+
const baseClassName = styleNames.base
|
|
13
|
+
const componentClassName = 'toggle-input'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Toggle input field component that wraps ToggleSwitch for use with Formik
|
|
17
|
+
*/
|
|
18
|
+
const ToggleInput = ({
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
style,
|
|
22
|
+
name,
|
|
23
|
+
label,
|
|
24
|
+
color,
|
|
25
|
+
labelColor,
|
|
26
|
+
validate,
|
|
27
|
+
description,
|
|
28
|
+
disabled,
|
|
29
|
+
optional,
|
|
30
|
+
size,
|
|
31
|
+
// ...otherProps
|
|
32
|
+
}) => {
|
|
33
|
+
const [field, , helpers] = useField({ name, validate, type: 'checkbox' })
|
|
34
|
+
|
|
35
|
+
const handleChange = () => {
|
|
36
|
+
helpers.setValue(!field.value)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
id={id}
|
|
42
|
+
className={[
|
|
43
|
+
baseClassName,
|
|
44
|
+
componentClassName,
|
|
45
|
+
userClassName,
|
|
46
|
+
`y-${color}`,
|
|
47
|
+
]
|
|
48
|
+
.filter((e) => e)
|
|
49
|
+
.join(' ')}
|
|
50
|
+
style={style}
|
|
51
|
+
>
|
|
52
|
+
<FormLabel
|
|
53
|
+
name={name}
|
|
54
|
+
color={labelColor}
|
|
55
|
+
optional={optional}
|
|
56
|
+
>
|
|
57
|
+
{label}
|
|
58
|
+
</FormLabel>
|
|
59
|
+
<div className="toggle-wrapper">
|
|
60
|
+
<ToggleSwitch
|
|
61
|
+
checked={Boolean(field.value)}
|
|
62
|
+
handleOnChange={handleChange}
|
|
63
|
+
inputId={name}
|
|
64
|
+
size={size}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
<FormDescription className="s-1" description={description} name={name} />
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ToggleInput.propTypes = {
|
|
74
|
+
/**
|
|
75
|
+
* The HTML id for this element
|
|
76
|
+
*/
|
|
77
|
+
id:PropTypes.string,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The HTML class names for this element
|
|
81
|
+
*/
|
|
82
|
+
className:PropTypes.string,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The React-written, css properties for this element.
|
|
86
|
+
*/
|
|
87
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The input name (html - and Formik state)
|
|
91
|
+
*/
|
|
92
|
+
name:PropTypes.string.isRequired,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The input label
|
|
96
|
+
*/
|
|
97
|
+
label:PropTypes.string.isRequired,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The input label color
|
|
101
|
+
*/
|
|
102
|
+
labelColor:PropTypes.string,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The input field validator function
|
|
106
|
+
*/
|
|
107
|
+
validate:PropTypes.func,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Input description
|
|
111
|
+
*/
|
|
112
|
+
description:PropTypes.string,
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Whether the toggle input should be disabled
|
|
116
|
+
*/
|
|
117
|
+
disabled:PropTypes.bool,
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The text input color
|
|
121
|
+
*/
|
|
122
|
+
color:PropTypes.string,
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Whether the input is optional or not
|
|
126
|
+
*/
|
|
127
|
+
optional:PropTypes.bool,
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The size of the toggle switch
|
|
131
|
+
*/
|
|
132
|
+
size:PropTypes.string,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
ToggleInput.defaultProps = {
|
|
136
|
+
color :'paragraph',
|
|
137
|
+
disabled:false,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default ToggleInput
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.3 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
@use "@pareto-engineering/styles/src/mixins";
|
|
5
|
+
@use "@pareto-engineering/styles/src/globals" as *;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.toggle-input {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
|
|
11
|
+
> .#{bem.$base}.form-label {
|
|
12
|
+
margin-bottom: var(--gap);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
> .toggle-wrapper {
|
|
16
|
+
align-items: center;
|
|
17
|
+
display: flex;
|
|
18
|
+
margin-bottom: calc(var(--gap) / 2);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
package/src/ui/f/fields/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export const DATE_FORMATS = {
|
|
2
|
-
HUMAN_READABLE:'human_readable',
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
HUMAN_READABLE :'human_readable',
|
|
3
|
+
HUMAN_READABLE_WITH_TIME:'human_readable_with_time',
|
|
4
|
+
TIME :'time',
|
|
5
|
+
DATETIME :'datetime',
|
|
6
|
+
CHART_DATE :'chart_date',
|
|
7
|
+
CHART_TIME :'chart_time',
|
|
8
|
+
WEEKDAY_DATE :'weekday_date',
|
|
9
|
+
DAY_VIEW :'day_view',
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const isValidDate = (date) => date instanceof Date && !Number.isNaN(date)
|
|
@@ -52,28 +53,6 @@ export const formatTime = (seconds) => {
|
|
|
52
53
|
return parts.join(' ')
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
const parseDate = (input) => {
|
|
56
|
-
if (input instanceof Date) return input
|
|
57
|
-
if (typeof input === 'number') return new Date(input)
|
|
58
|
-
|
|
59
|
-
if (typeof input === 'string') {
|
|
60
|
-
if (isTimeSliceFormat(input)) {
|
|
61
|
-
return createTimeFromSlice(input)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const parsed = new Date(input)
|
|
65
|
-
if (isValidDate(parsed)) return parsed
|
|
66
|
-
|
|
67
|
-
const timestamp = parseInt(input, 10)
|
|
68
|
-
if (!Number.isNaN(timestamp)) {
|
|
69
|
-
const date = new Date(timestamp * 1000)
|
|
70
|
-
if (isValidDate(date)) return date
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
56
|
const formatStrategies = {
|
|
78
57
|
[DATE_FORMATS.CHART_DATE]:(date) => {
|
|
79
58
|
const monthDay = date.toLocaleDateString('en-US', {
|
|
@@ -95,9 +74,39 @@ const formatStrategies = {
|
|
|
95
74
|
timeZone:'UTC',
|
|
96
75
|
}),
|
|
97
76
|
|
|
77
|
+
[DATE_FORMATS.HUMAN_READABLE_WITH_TIME]:(date) => date.toLocaleString('en-US', {
|
|
78
|
+
year :'numeric',
|
|
79
|
+
month :'short',
|
|
80
|
+
day :'numeric',
|
|
81
|
+
hour :'2-digit',
|
|
82
|
+
timeZone:'UTC',
|
|
83
|
+
}),
|
|
84
|
+
|
|
98
85
|
default:(date) => date.toISOString(),
|
|
99
86
|
}
|
|
100
87
|
|
|
88
|
+
export const parseDate = (input) => {
|
|
89
|
+
if (input instanceof Date) return input
|
|
90
|
+
if (typeof input === 'number') return new Date(input)
|
|
91
|
+
|
|
92
|
+
if (typeof input === 'string') {
|
|
93
|
+
if (isTimeSliceFormat(input)) {
|
|
94
|
+
return createTimeFromSlice(input)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const parsed = new Date(input)
|
|
98
|
+
if (isValidDate(parsed)) return parsed
|
|
99
|
+
|
|
100
|
+
const timestamp = parseInt(input, 10)
|
|
101
|
+
if (!Number.isNaN(timestamp)) {
|
|
102
|
+
const date = new Date(timestamp * 1000)
|
|
103
|
+
if (isValidDate(date)) return date
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null
|
|
108
|
+
}
|
|
109
|
+
|
|
101
110
|
export const formatDate = (input, format = DATE_FORMATS.HUMAN_READABLE) => {
|
|
102
111
|
try {
|
|
103
112
|
if (typeof input === 'string' && isTimeSliceFormat(input)) {
|
package/src/ui/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useWindowSize, useDynamicPosition, useOutsideClick } from './hooks'
|
|
2
2
|
export {
|
|
3
|
-
formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase,
|
|
3
|
+
formatTime, formatDate, DATE_FORMATS, parseDate, snakeCaseToTitleCase,
|
|
4
4
|
} from './formatting'
|
|
5
5
|
export { applyCharacterLimit } from './applyCharacterLimit'
|
|
@@ -14669,6 +14669,7 @@ exports[`Storyshots a/ToggleSwitch Multiple 1`] = `
|
|
|
14669
14669
|
type="checkbox"
|
|
14670
14670
|
/>
|
|
14671
14671
|
<label
|
|
14672
|
+
className=""
|
|
14672
14673
|
htmlFor="option1"
|
|
14673
14674
|
/>
|
|
14674
14675
|
</button>,
|
|
@@ -14686,6 +14687,7 @@ exports[`Storyshots a/ToggleSwitch Multiple 1`] = `
|
|
|
14686
14687
|
type="checkbox"
|
|
14687
14688
|
/>
|
|
14688
14689
|
<label
|
|
14690
|
+
className=""
|
|
14689
14691
|
htmlFor="option2"
|
|
14690
14692
|
/>
|
|
14691
14693
|
</button>,
|
|
@@ -14703,6 +14705,7 @@ exports[`Storyshots a/ToggleSwitch Multiple 1`] = `
|
|
|
14703
14705
|
type="checkbox"
|
|
14704
14706
|
/>
|
|
14705
14707
|
<label
|
|
14708
|
+
className=""
|
|
14706
14709
|
htmlFor="option3"
|
|
14707
14710
|
/>
|
|
14708
14711
|
</button>,
|
|
@@ -14722,7 +14725,9 @@ exports[`Storyshots a/ToggleSwitch Single 1`] = `
|
|
|
14722
14725
|
<input
|
|
14723
14726
|
type="checkbox"
|
|
14724
14727
|
/>
|
|
14725
|
-
<label
|
|
14728
|
+
<label
|
|
14729
|
+
className=""
|
|
14730
|
+
/>
|
|
14726
14731
|
</button>
|
|
14727
14732
|
`;
|
|
14728
14733
|
|
|
@@ -26737,6 +26742,7 @@ exports[`Storyshots b/ThemeSelector Base 1`] = `
|
|
|
26737
26742
|
type="checkbox"
|
|
26738
26743
|
/>
|
|
26739
26744
|
<label
|
|
26745
|
+
className=""
|
|
26740
26746
|
htmlFor="theme-toggle"
|
|
26741
26747
|
/>
|
|
26742
26748
|
</button>
|