@pareto-engineering/design-system 2.0.0-alpha.64 → 2.0.0-alpha.65

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 (35) hide show
  1. package/dist/cjs/f/common/Label/Label.js +10 -4
  2. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +9 -2
  3. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +8 -1
  4. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +10 -3
  5. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +9 -2
  6. package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +8 -1
  7. package/dist/cjs/f/fields/SelectInput/SelectInput.js +9 -2
  8. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +9 -2
  9. package/dist/es/f/common/Label/Label.js +10 -4
  10. package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +9 -2
  11. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +8 -1
  12. package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +10 -3
  13. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +9 -2
  14. package/dist/es/f/fields/QuerySelect/QuerySelect.js +8 -1
  15. package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
  16. package/dist/es/f/fields/TextareaInput/TextareaInput.js +9 -2
  17. package/package.json +1 -1
  18. package/src/__snapshots__/Storyshots.test.js.snap +670 -27
  19. package/src/stories/f/Checkbox.stories.jsx +1 -1
  20. package/src/stories/f/ChoicesInput.stories.jsx +8 -0
  21. package/src/stories/f/Label.stories.jsx +8 -3
  22. package/src/stories/f/QueryCombobox.stories.jsx +6 -0
  23. package/src/stories/f/QuerySelect.stories.jsx +8 -1
  24. package/src/stories/f/RatingsInput.stories.jsx +7 -0
  25. package/src/stories/f/SelectInput.stories.jsx +7 -0
  26. package/src/stories/f/TextInput.stories.jsx +7 -0
  27. package/src/stories/f/TextareaInput.stories.jsx +7 -0
  28. package/src/ui/f/common/Label/Label.jsx +9 -3
  29. package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +7 -1
  30. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +7 -0
  31. package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +11 -1
  32. package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +11 -1
  33. package/src/ui/f/fields/QuerySelect/QuerySelect.jsx +7 -0
  34. package/src/ui/f/fields/SelectInput/SelectInput.jsx +7 -1
  35. package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +7 -0
@@ -90,6 +90,6 @@ Disabled.args = {
90
90
 
91
91
  export const Optional = Template.bind({})
92
92
  Optional.args = {
93
- ...Base.args,
93
+ ...WithLabel.args,
94
94
  optional:true,
95
95
  }
@@ -26,6 +26,7 @@ export default {
26
26
  multiple :{ control: 'boolean' },
27
27
  gridColumnsDesktop:{ control: 'number' },
28
28
  disabled :{ control: 'boolean' },
29
+ optional :{ control: 'boolean' },
29
30
  },
30
31
  }
31
32
 
@@ -125,6 +126,13 @@ ChoicesWithLabel.args = {
125
126
  label:'Select color',
126
127
  }
127
128
 
129
+ export const Optional = Template.bind({})
130
+ Optional.args = {
131
+ ...Base.args,
132
+ label :'Select color',
133
+ optional:true,
134
+ }
135
+
128
136
  export const DisabledChoicesInput = Template.bind({})
129
137
  DisabledChoicesInput.args = {
130
138
  ...ChoicesWithLabel.args,
@@ -17,6 +17,11 @@ export default {
17
17
  },
18
18
  }
19
19
 
20
- export const Base = () => (
21
- <Label>Sample Label</Label>
22
- )
20
+ const Template = (args) => <Label {...args}>Sample Label</Label>
21
+
22
+ export const Base = Template.bind()
23
+
24
+ export const Optional = Template.bind({})
25
+ Optional.args = {
26
+ optional:true,
27
+ }
@@ -32,6 +32,7 @@ export default {
32
32
  // backgroundColor:{ control: 'color' },
33
33
  multiple:{ control: 'boolean' },
34
34
  disabled:{ control: 'boolean' },
35
+ optional:{ control: 'boolean' },
35
36
  },
36
37
  }
37
38
 
@@ -172,6 +173,11 @@ const ResolvedTemplate = ({ defaultFormikState, ...otherProps }) => {
172
173
  )
173
174
  }
174
175
 
176
+ export const Optional = ResolvedTemplate.bind({})
177
+ Optional.args = {
178
+ optional:true,
179
+ }
180
+
175
181
  export const SingleSelect = ResolvedTemplate.bind({})
176
182
  SingleSelect.args = {
177
183
  multiple:false,
@@ -30,6 +30,7 @@ export default {
30
30
  argTypes:{
31
31
  // backgroundColor:{ control: 'color' },
32
32
  isLoading:{ control: 'boolean' },
33
+ optional :{ control: 'boolean' },
33
34
  },
34
35
  }
35
36
  const statuses = [
@@ -76,7 +77,7 @@ const FETCH_ALL_TASK_STATUSES = graphql`
76
77
  `
77
78
 
78
79
  // eslint-disable-next-line react/prop-types
79
- const Template = ({ isLoading, defaultFormikState }) => {
80
+ const Template = ({ isLoading, defaultFormikState, ...args }) => {
80
81
  if (isLoading) {
81
82
  setTimeout(() => {
82
83
  mockRelayOperation(allTaskStatusesMockData)
@@ -104,6 +105,7 @@ const Template = ({ isLoading, defaultFormikState }) => {
104
105
  value :'id',
105
106
  getLabel:(node) => node.status,
106
107
  }}
108
+ {...args}
107
109
  />
108
110
  <FormDebugger />
109
111
  </>
@@ -133,3 +135,8 @@ export const LoadingOptions = Template.bind({})
133
135
  LoadingOptions.args = {
134
136
  isLoading:true,
135
137
  }
138
+
139
+ export const Optional = Template.bind({})
140
+ Optional.args = {
141
+ optional:true,
142
+ }
@@ -31,6 +31,7 @@ export default {
31
31
  displayRatingsLabel:{ control: 'boolean' },
32
32
  labelMax :{ control: 'text' },
33
33
  labelMin :{ control: 'text' },
34
+ optional :{ control: 'boolean' },
34
35
  },
35
36
  }
36
37
 
@@ -48,6 +49,12 @@ Base.args = {
48
49
  label :'Your Rating',
49
50
  }
50
51
 
52
+ export const Optional = Template.bind({})
53
+ Optional.args = {
54
+ ...Base.args,
55
+ optional:true,
56
+ }
57
+
51
58
  export const Numbers = Template.bind({})
52
59
  Numbers.args = {
53
60
  ...Base.args,
@@ -24,6 +24,7 @@ export default {
24
24
  argTypes:{
25
25
  // backgroundColor:{ control: 'color' },
26
26
  disabled:{ control: 'boolean' },
27
+ optional:{ control: 'boolean' },
27
28
  },
28
29
  }
29
30
 
@@ -46,6 +47,12 @@ Base.args = {
46
47
  ],
47
48
  }
48
49
 
50
+ export const Optional = Template.bind({})
51
+ Optional.args = {
52
+ ...Base.args,
53
+ optional:true,
54
+ }
55
+
49
56
  export const StringAndObjects = Template.bind({})
50
57
  StringAndObjects.args = {
51
58
  ...Base.args,
@@ -33,6 +33,7 @@ export default {
33
33
  type :{ control: 'text' },
34
34
  name :{ control: 'text' },
35
35
  label :{ control: 'text' },
36
+ optional :{ control: 'boolean' },
36
37
  },
37
38
  }
38
39
 
@@ -50,6 +51,12 @@ Base.args = {
50
51
  label:"What's your first name ?",
51
52
  }
52
53
 
54
+ export const Optional = Template.bind({})
55
+ Optional.args = {
56
+ ...Base.args,
57
+ optional:true,
58
+ }
59
+
53
60
  const validate = (value) => {
54
61
  let errorMessage = ''
55
62
  const isValid = value.length > 3
@@ -30,6 +30,7 @@ export default {
30
30
  placeholder :{ control: 'text' },
31
31
  disabled :{ control: 'boolean' },
32
32
  labelAsDescription:{ control: 'boolean' },
33
+ optional :{ control: 'boolean' },
33
34
  },
34
35
  }
35
36
 
@@ -46,6 +47,12 @@ Base.args = {
46
47
  label:'What can we improve on?',
47
48
  }
48
49
 
50
+ export const Optional = Template.bind({})
51
+ Optional.args = {
52
+ ...Base.args,
53
+ optional:true,
54
+ }
55
+
49
56
  export const Placeholder = Template.bind({})
50
57
  Placeholder.args = {
51
58
  ...Base.args,
@@ -23,6 +23,7 @@ const Label = ({
23
23
  children,
24
24
  name,
25
25
  color,
26
+ optional,
26
27
  as:Wrapper,
27
28
  // ...otherProps
28
29
  }) => {
@@ -46,6 +47,7 @@ const Label = ({
46
47
  // {...otherProps}
47
48
  >
48
49
  {children}
50
+ {optional && '(Optional)'}
49
51
  </Wrapper>
50
52
  )
51
53
  }
@@ -85,12 +87,16 @@ Label.propTypes = {
85
87
  */
86
88
  color:PropTypes.string,
87
89
 
90
+ /**
91
+ * Whether the input should have an optional tag
92
+ */
93
+ optional:PropTypes.bool,
88
94
  }
89
95
 
90
96
  Label.defaultProps = {
91
- // someProp:false
92
- as :'label',
93
- color:'main2',
97
+ as :'label',
98
+ color :'main2',
99
+ optional:false,
94
100
  }
95
101
 
96
102
  export default Label
@@ -33,6 +33,7 @@ const ChoicesInput = ({
33
33
  color,
34
34
  colorChecked,
35
35
  label,
36
+ optional,
36
37
  disabled,
37
38
  // ...otherProps
38
39
  }) => {
@@ -63,7 +64,7 @@ const ChoicesInput = ({
63
64
  // {...otherProps}
64
65
  >
65
66
  {label && (
66
- <FormLabel as="p">
67
+ <FormLabel as="p" optional={optional}>
67
68
  {label}
68
69
  </FormLabel>
69
70
  )}
@@ -142,6 +143,11 @@ ChoicesInput.propTypes = {
142
143
  * Whether all the Choices inputs should be disabled
143
144
  */
144
145
  disabled :PropTypes.bool,
146
+
147
+ /**
148
+ * Whether the input is optional or not
149
+ */
150
+ optional:PropTypes.bool,
145
151
  }
146
152
 
147
153
  ChoicesInput.defaultProps = {
@@ -25,6 +25,7 @@ const QueryCombobox = ({
25
25
  name,
26
26
  label,
27
27
  color,
28
+ optional,
28
29
  description,
29
30
  disabled,
30
31
  debounceMs,
@@ -100,6 +101,7 @@ const QueryCombobox = ({
100
101
  disabled,
101
102
  name,
102
103
  label,
104
+ optional,
103
105
  description,
104
106
  setValue,
105
107
  value,
@@ -215,6 +217,11 @@ QueryCombobox.propTypes = {
215
217
  * The query combobox field validator function
216
218
  */
217
219
  validate:PropTypes.func,
220
+
221
+ /*
222
+ * Whether the input is optional or not
223
+ */
224
+ optional:PropTypes.bool,
218
225
  }
219
226
 
220
227
  QueryCombobox.defaultProps = {
@@ -40,6 +40,7 @@ const Combobox = ({
40
40
  isFetching,
41
41
  transformSearch,
42
42
  disabled,
43
+ optional,
43
44
  // ...otherProps
44
45
  }) => {
45
46
  const {
@@ -97,7 +98,11 @@ const Combobox = ({
97
98
  style={style}
98
99
  ref={parentRef}
99
100
  >
100
- <FormLabel {...getLabelProps()} name={name}>
101
+ <FormLabel
102
+ {...getLabelProps()}
103
+ name={name}
104
+ optional={optional}
105
+ >
101
106
  {label}
102
107
  </FormLabel>
103
108
 
@@ -209,6 +214,11 @@ Combobox.propTypes = {
209
214
  * Whether the input filed shpuld be disabled
210
215
  */
211
216
  disabled:PropTypes.bool,
217
+
218
+ /**
219
+ * Whether the input is optional or not
220
+ */
221
+ optional:PropTypes.bool,
212
222
  }
213
223
 
214
224
  Combobox.defaultProps = {
@@ -43,6 +43,7 @@ const MultipleCombobox = ({
43
43
  style,
44
44
  label,
45
45
  name,
46
+ optional,
46
47
  options:items,
47
48
  getOptions,
48
49
  setValue,
@@ -160,7 +161,11 @@ const MultipleCombobox = ({
160
161
  style={style}
161
162
  >
162
163
 
163
- <FormLabel {...getLabelProps()} name={name}>
164
+ <FormLabel
165
+ {...getLabelProps()}
166
+ name={name}
167
+ optional={optional}
168
+ >
164
169
  {label}
165
170
  </FormLabel>
166
171
 
@@ -305,6 +310,11 @@ MultipleCombobox.propTypes = {
305
310
  * Whether the input filed shpuld be disabled
306
311
  */
307
312
  disabled:PropTypes.bool,
313
+
314
+ /**
315
+ * Whether the input is optional or not
316
+ */
317
+ optional:PropTypes.bool,
308
318
  }
309
319
 
310
320
  MultipleCombobox.defaultProps = {
@@ -22,6 +22,7 @@ const QuerySelect = ({
22
22
  style,
23
23
  name,
24
24
  label,
25
+ optional,
25
26
  query,
26
27
  variables,
27
28
  optionsKeyMap,
@@ -88,6 +89,7 @@ const QuerySelect = ({
88
89
  style={style}
89
90
  name={name}
90
91
  label={label}
92
+ optional={optional}
91
93
  color={color}
92
94
  description={description}
93
95
  disabled={isFetching || disabled}
@@ -186,6 +188,11 @@ QuerySelect.propTypes = {
186
188
  * The query select field validator function
187
189
  */
188
190
  validate:PropTypes.func,
191
+
192
+ /*
193
+ * Whether the input is optional or not
194
+ */
195
+ optional:PropTypes.bool,
189
196
  }
190
197
 
191
198
  QuerySelect.defaultProps = {
@@ -31,6 +31,7 @@ const SelectInput = ({
31
31
  color,
32
32
  options,
33
33
  validate,
34
+ optional,
34
35
  description,
35
36
  disabled,
36
37
  isLoading,
@@ -59,7 +60,7 @@ const SelectInput = ({
59
60
  style={style}
60
61
  // {...otherProps}
61
62
  >
62
- <FormLabel name={name}>{label}</FormLabel>
63
+ <FormLabel name={name} optional={optional}>{label}</FormLabel>
63
64
  <div className="select-wrapper">
64
65
  <select
65
66
  className="input"
@@ -162,6 +163,11 @@ SelectInput.propTypes = {
162
163
  * The autoComplete value that the browser should watch for the input
163
164
  */
164
165
  autoComplete:PropTypes.string,
166
+
167
+ /**
168
+ * Whether the input is optional or not
169
+ */
170
+ optional:PropTypes.bool,
165
171
  }
166
172
 
167
173
  SelectInput.defaultProps = {
@@ -30,6 +30,7 @@ const TextareaInput = ({
30
30
  labelAsDescription,
31
31
  textAreaId,
32
32
  rows,
33
+ optional,
33
34
  textAreaColor,
34
35
  labelColor,
35
36
  description,
@@ -67,6 +68,7 @@ const TextareaInput = ({
67
68
  .join(' ')}
68
69
  name={name}
69
70
  color={labelColor}
71
+ optional={optional}
70
72
  >
71
73
  { label }
72
74
  </FormLabel>
@@ -168,6 +170,11 @@ TextareaInput.propTypes = {
168
170
  * Textarea docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
169
171
  */
170
172
  resize:PropTypes.string,
173
+
174
+ /**
175
+ * Whether the input is optional or not
176
+ */
177
+ optional:PropTypes.bool,
171
178
  }
172
179
 
173
180
  TextareaInput.defaultProps = {