@pareto-engineering/design-system 2.0.0-alpha.62 → 2.0.0-alpha.64
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/Label/styles.scss +3 -3
- package/dist/cjs/f/FormInput/FormInput.js +2 -1
- package/dist/cjs/f/common/Label/Label.js +1 -1
- package/dist/cjs/f/common/Label/styles.scss +1 -4
- package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
- package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +5 -2
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +12 -3
- package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +12 -3
- package/dist/cjs/f/fields/RatingsInput/common/Rating/Rating.js +11 -2
- package/dist/es/a/Label/styles.scss +3 -3
- package/dist/es/f/FormInput/FormInput.js +2 -1
- package/dist/es/f/common/Label/Label.js +1 -1
- package/dist/es/f/common/Label/styles.scss +1 -4
- package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +1 -1
- package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +5 -2
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +12 -3
- package/dist/es/f/fields/QuerySelect/QuerySelect.js +12 -3
- package/dist/es/f/fields/RatingsInput/common/Rating/Rating.js +11 -2
- package/package.json +1 -1
- package/src/__snapshots__/Storyshots.test.js.snap +584 -158
- package/src/stories/f/ChoicesInput.stories.jsx +38 -10
- package/src/ui/a/Label/styles.scss +3 -3
- package/src/ui/f/FormInput/FormInput.jsx +1 -0
- package/src/ui/f/common/Label/Label.jsx +1 -1
- package/src/ui/f/common/Label/styles.scss +1 -4
- package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +1 -1
- package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +10 -2
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +7 -1
- package/src/ui/f/fields/QuerySelect/QuerySelect.jsx +7 -1
- package/src/ui/f/fields/RatingsInput/common/Rating/Rating.jsx +7 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
2
|
import * as React from 'react'
|
|
3
|
-
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
4
|
import { ChoicesInput, FormDebugger } from 'ui'
|
|
5
|
-
import { Formik, Form } from 'formik'
|
|
5
|
+
import { Formik, Form, useField } from 'formik'
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
title :'f/fields/ChoicesInput',
|
|
@@ -29,14 +29,6 @@ export default {
|
|
|
29
29
|
},
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const Template = (args) => (
|
|
33
|
-
<>
|
|
34
|
-
<ChoicesInput {...args} />
|
|
35
|
-
<FormDebugger />
|
|
36
|
-
</>
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
export const Base = Template.bind({})
|
|
40
32
|
const optionsMap = [
|
|
41
33
|
{
|
|
42
34
|
value:'red',
|
|
@@ -72,18 +64,54 @@ const optionsMap = [
|
|
|
72
64
|
},
|
|
73
65
|
]
|
|
74
66
|
|
|
67
|
+
// eslint-disable-next-line react/prop-types
|
|
68
|
+
const Template = ({ defaultValue, ...args }) => {
|
|
69
|
+
const Content = () => {
|
|
70
|
+
const [, , helpers] = useField(args.name)
|
|
71
|
+
const { setValue } = helpers
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (defaultValue) {
|
|
75
|
+
setValue(defaultValue)
|
|
76
|
+
}
|
|
77
|
+
}, [defaultValue])
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
<ChoicesInput {...args} />
|
|
82
|
+
<FormDebugger />
|
|
83
|
+
</>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
return <Content />
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const Base = Template.bind({})
|
|
75
90
|
Base.args = {
|
|
76
91
|
id :'colors',
|
|
77
92
|
options:optionsMap,
|
|
78
93
|
name :'color',
|
|
79
94
|
}
|
|
80
95
|
|
|
96
|
+
export const WithDefaultFormikValue = Template.bind({})
|
|
97
|
+
WithDefaultFormikValue.args = {
|
|
98
|
+
...Base.args,
|
|
99
|
+
defaultValue:'red',
|
|
100
|
+
}
|
|
101
|
+
|
|
81
102
|
export const Multiple = Template.bind({})
|
|
82
103
|
Multiple.args = {
|
|
83
104
|
...Base.args,
|
|
84
105
|
multiple:true,
|
|
85
106
|
}
|
|
86
107
|
|
|
108
|
+
export const MultipleWithDefaultFormikValue = Template.bind({})
|
|
109
|
+
MultipleWithDefaultFormikValue.args = {
|
|
110
|
+
...Base.args,
|
|
111
|
+
multiple :true,
|
|
112
|
+
defaultValue:['brown', 'violet'],
|
|
113
|
+
}
|
|
114
|
+
|
|
87
115
|
export const MultipleWithGrid = Template.bind({})
|
|
88
116
|
MultipleWithGrid.args = {
|
|
89
117
|
...Base.args,
|
|
@@ -10,9 +10,9 @@ $default-padding: $default-padding-top $default-padding-side $default-padding-bo
|
|
|
10
10
|
|
|
11
11
|
$default-color: primary;
|
|
12
12
|
$default-image-size: 2em;
|
|
13
|
-
$default-font-size: calc(
|
|
13
|
+
$default-font-size: calc(1em * var(--s-1));
|
|
14
14
|
|
|
15
|
-
.#{bem.$base}.label{
|
|
15
|
+
.#{bem.$base}.label {
|
|
16
16
|
align-items: center;
|
|
17
17
|
background: var(--x, var(--#{$default-color}));
|
|
18
18
|
border-radius: 3em;
|
|
@@ -31,4 +31,4 @@ $default-font-size: calc(1 em * var(--s-1));
|
|
|
31
31
|
border: 1px solid var(--x, var(--#{$default-color}));
|
|
32
32
|
color: var(--x, var(--#{$default-color}));
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
@@ -28,7 +28,15 @@ const Choice = ({
|
|
|
28
28
|
validate,
|
|
29
29
|
disabled,
|
|
30
30
|
}) => {
|
|
31
|
-
const
|
|
31
|
+
const type = multiple ? 'checkbox' : 'radio'
|
|
32
|
+
|
|
33
|
+
const [field] = useField({
|
|
34
|
+
name,
|
|
35
|
+
validate,
|
|
36
|
+
type,
|
|
37
|
+
value,
|
|
38
|
+
})
|
|
39
|
+
|
|
32
40
|
return (
|
|
33
41
|
<div
|
|
34
42
|
className={[
|
|
@@ -43,7 +51,7 @@ const Choice = ({
|
|
|
43
51
|
style={style}
|
|
44
52
|
>
|
|
45
53
|
<input
|
|
46
|
-
type={
|
|
54
|
+
type={type}
|
|
47
55
|
id={id}
|
|
48
56
|
name={name}
|
|
49
57
|
{...field}
|
|
@@ -33,13 +33,14 @@ const QueryCombobox = ({
|
|
|
33
33
|
optionsKeyMap,
|
|
34
34
|
minLength,
|
|
35
35
|
transformSearch,
|
|
36
|
+
validate,
|
|
36
37
|
// ...otherProps
|
|
37
38
|
}) => {
|
|
38
39
|
useLayoutEffect(() => {
|
|
39
40
|
import('./styles.scss')
|
|
40
41
|
}, [])
|
|
41
42
|
|
|
42
|
-
const [, meta, helpers] = useField(name)
|
|
43
|
+
const [, meta, helpers] = useField({ name, validate })
|
|
43
44
|
|
|
44
45
|
const { setValue, setError } = helpers
|
|
45
46
|
|
|
@@ -209,6 +210,11 @@ QueryCombobox.propTypes = {
|
|
|
209
210
|
* The function to transform the search input
|
|
210
211
|
*/
|
|
211
212
|
transformSearch:PropTypes.func,
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The query combobox field validator function
|
|
216
|
+
*/
|
|
217
|
+
validate:PropTypes.func,
|
|
212
218
|
}
|
|
213
219
|
|
|
214
220
|
QueryCombobox.defaultProps = {
|
|
@@ -30,9 +30,10 @@ const QuerySelect = ({
|
|
|
30
30
|
color,
|
|
31
31
|
loadingOption,
|
|
32
32
|
defaultOption,
|
|
33
|
+
validate,
|
|
33
34
|
// ...otherProps
|
|
34
35
|
}) => {
|
|
35
|
-
const [, , helpers] = useField(name)
|
|
36
|
+
const [, , helpers] = useField({ name, validate })
|
|
36
37
|
|
|
37
38
|
const { setError } = helpers
|
|
38
39
|
|
|
@@ -180,6 +181,11 @@ QuerySelect.propTypes = {
|
|
|
180
181
|
label :PropTypes.string.isRequired,
|
|
181
182
|
disabled:PropTypes.bool.isRequired,
|
|
182
183
|
}),
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The query select field validator function
|
|
187
|
+
*/
|
|
188
|
+
validate:PropTypes.func,
|
|
183
189
|
}
|
|
184
190
|
|
|
185
191
|
QuerySelect.defaultProps = {
|
|
@@ -25,12 +25,13 @@ const Rating = ({
|
|
|
25
25
|
ratingId,
|
|
26
26
|
hover,
|
|
27
27
|
setHover,
|
|
28
|
+
validate,
|
|
28
29
|
activeBackgroundColor,
|
|
29
30
|
inactiveBackgroundColor,
|
|
30
31
|
showRatingValue,
|
|
31
32
|
// ...otherProps
|
|
32
33
|
}) => {
|
|
33
|
-
const [field] = useField(name)
|
|
34
|
+
const [field] = useField({ name, validate })
|
|
34
35
|
|
|
35
36
|
return (
|
|
36
37
|
<div
|
|
@@ -125,6 +126,11 @@ Rating.propTypes = {
|
|
|
125
126
|
* Determines if the rating start value should be shown
|
|
126
127
|
*/
|
|
127
128
|
showRatingValue :PropTypes.bool,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The rating field validator function
|
|
132
|
+
*/
|
|
133
|
+
validate:PropTypes.func,
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
Rating.defaultProps = {
|