@pareto-engineering/design-system 2.0.0-alpha.62 → 2.0.0-alpha.63

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.
Files changed (27) hide show
  1. package/dist/cjs/f/FormInput/FormInput.js +2 -1
  2. package/dist/cjs/f/common/Label/Label.js +1 -1
  3. package/dist/cjs/f/common/Label/styles.scss +1 -4
  4. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  5. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +5 -2
  6. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +12 -3
  7. package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +12 -3
  8. package/dist/cjs/f/fields/RatingsInput/common/Rating/Rating.js +11 -2
  9. package/dist/es/f/FormInput/FormInput.js +2 -1
  10. package/dist/es/f/common/Label/Label.js +1 -1
  11. package/dist/es/f/common/Label/styles.scss +1 -4
  12. package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  13. package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +5 -2
  14. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +12 -3
  15. package/dist/es/f/fields/QuerySelect/QuerySelect.js +12 -3
  16. package/dist/es/f/fields/RatingsInput/common/Rating/Rating.js +11 -2
  17. package/package.json +1 -1
  18. package/src/__snapshots__/Storyshots.test.js.snap +583 -157
  19. package/src/stories/f/ChoicesInput.stories.jsx +38 -10
  20. package/src/ui/f/FormInput/FormInput.jsx +1 -0
  21. package/src/ui/f/common/Label/Label.jsx +1 -1
  22. package/src/ui/f/common/Label/styles.scss +1 -4
  23. package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +1 -1
  24. package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +10 -2
  25. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +7 -1
  26. package/src/ui/f/fields/QuerySelect/QuerySelect.jsx +7 -1
  27. 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,
@@ -100,6 +100,7 @@ const FormInput = ({
100
100
  return (
101
101
  <Checkbox
102
102
  className={newClassName}
103
+ disabled={disabled}
103
104
  {...otherProps}
104
105
  />
105
106
  )
@@ -11,7 +11,7 @@ import styleNames from '@pareto-engineering/bem'
11
11
 
12
12
  const baseClassName = styleNames.base
13
13
 
14
- const componentClassName = 'label'
14
+ const componentClassName = 'form-label'
15
15
 
16
16
  /**
17
17
  * This is the component description.
@@ -3,9 +3,6 @@
3
3
  @use "@pareto-engineering/bem";
4
4
  @use "../../../form.scss";
5
5
 
6
-
7
- .#{bem.$base}.label {
6
+ .#{bem.$base}.form-label {
8
7
  color: var(--dark-x);
9
8
  }
10
-
11
-
@@ -72,7 +72,7 @@ const ChoicesInput = ({
72
72
  <Choice
73
73
  key={choice.value}
74
74
  name={name}
75
- id={`${id}-${choice.value}`}
75
+ id={`${name}-${choice.value}`}
76
76
  multiple={multiple}
77
77
  validate={validate}
78
78
  disabled={disabled}
@@ -28,7 +28,15 @@ const Choice = ({
28
28
  validate,
29
29
  disabled,
30
30
  }) => {
31
- const [field] = useField({ name, validate })
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={multiple ? 'checkbox' : 'radio'}
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 = {