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

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 (49) hide show
  1. package/dist/cjs/a/ContentTree/ContentTree.js +1 -1
  2. package/dist/cjs/f/common/Label/Label.js +10 -4
  3. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +9 -2
  4. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +8 -1
  5. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +27 -6
  6. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +23 -4
  7. package/dist/cjs/f/fields/QueryCombobox/styles.scss +2 -1
  8. package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +8 -1
  9. package/dist/cjs/f/fields/SelectInput/SelectInput.js +9 -2
  10. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +9 -2
  11. package/dist/cjs/v3/Button/Button.js +70 -0
  12. package/dist/cjs/v3/Button/index.js +15 -0
  13. package/dist/cjs/v3/Button/styles.scss +9 -0
  14. package/dist/cjs/v3/index.js +13 -0
  15. package/dist/es/a/ContentTree/ContentTree.js +1 -1
  16. package/dist/es/f/common/Label/Label.js +10 -4
  17. package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +9 -2
  18. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +8 -1
  19. package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +27 -7
  20. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +23 -4
  21. package/dist/es/f/fields/QueryCombobox/styles.scss +2 -1
  22. package/dist/es/f/fields/QuerySelect/QuerySelect.js +8 -1
  23. package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
  24. package/dist/es/f/fields/TextareaInput/TextareaInput.js +9 -2
  25. package/dist/es/v3/Button/Button.js +54 -0
  26. package/dist/es/v3/Button/index.js +2 -0
  27. package/dist/es/v3/Button/styles.scss +9 -0
  28. package/dist/es/v3/index.js +1 -0
  29. package/package.json +1 -1
  30. package/src/__snapshots__/Storyshots.test.js.snap +682 -28
  31. package/src/stories/f/Checkbox.stories.jsx +1 -1
  32. package/src/stories/f/ChoicesInput.stories.jsx +8 -0
  33. package/src/stories/f/Label.stories.jsx +8 -3
  34. package/src/stories/f/QueryCombobox.stories.jsx +6 -0
  35. package/src/stories/f/QuerySelect.stories.jsx +8 -1
  36. package/src/stories/f/RatingsInput.stories.jsx +7 -0
  37. package/src/stories/f/SelectInput.stories.jsx +7 -0
  38. package/src/stories/f/TextInput.stories.jsx +7 -0
  39. package/src/stories/f/TextareaInput.stories.jsx +7 -0
  40. package/src/ui/a/ContentTree/ContentTree.jsx +1 -1
  41. package/src/ui/f/common/Label/Label.jsx +9 -3
  42. package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +7 -1
  43. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +7 -0
  44. package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +26 -3
  45. package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +27 -1
  46. package/src/ui/f/fields/QueryCombobox/styles.scss +2 -1
  47. package/src/ui/f/fields/QuerySelect/QuerySelect.jsx +7 -0
  48. package/src/ui/f/fields/SelectInput/SelectInput.jsx +7 -1
  49. 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,
@@ -77,7 +77,7 @@ ContentTree.propTypes = {
77
77
  */
78
78
  target:PropTypes.oneOfType([
79
79
  PropTypes.func,
80
- PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
80
+ PropTypes.shape({ current: PropTypes.instanceOf(String) }),
81
81
  ]),
82
82
  }
83
83
 
@@ -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 = {
@@ -13,6 +13,8 @@ import { FormLabel, FormDescription } from 'ui/f'
13
13
 
14
14
  import { Popover, LoadingCircle } from 'ui/a'
15
15
 
16
+ import { Button } from 'ui/b'
17
+
16
18
  // Local Definitions
17
19
 
18
20
  import { Menu } from '../Menu'
@@ -40,12 +42,15 @@ const Combobox = ({
40
42
  isFetching,
41
43
  transformSearch,
42
44
  disabled,
45
+ optional,
43
46
  // ...otherProps
44
47
  }) => {
45
48
  const {
46
49
  isOpen,
47
50
  selectItem,
48
51
  selectedItem,
52
+ inputValue,
53
+ setInputValue,
49
54
  getLabelProps,
50
55
  getMenuProps,
51
56
  getInputProps,
@@ -56,8 +61,8 @@ const Combobox = ({
56
61
  items,
57
62
  initialSelectedItem:value,
58
63
  itemToString :(item) => (item ? item.label : ''),
59
- onInputValueChange :({ inputValue }) => {
60
- const transformedInput = transformSearch(inputValue)
64
+ onInputValueChange :({ inputValue:searchInputValue }) => {
65
+ const transformedInput = transformSearch(searchInputValue)
61
66
  if (transformedInput.length > minLength) {
62
67
  getOptions(transformedInput)
63
68
  }
@@ -81,6 +86,8 @@ const Combobox = ({
81
86
 
82
87
  const parentRef = useRef(null)
83
88
 
89
+ const resetInputValue = () => setInputValue('')
90
+
84
91
  return (
85
92
  <div
86
93
  id={id}
@@ -97,7 +104,11 @@ const Combobox = ({
97
104
  style={style}
98
105
  ref={parentRef}
99
106
  >
100
- <FormLabel {...getLabelProps()} name={name}>
107
+ <FormLabel
108
+ {...getLabelProps()}
109
+ name={name}
110
+ optional={optional}
111
+ >
101
112
  {label}
102
113
  </FormLabel>
103
114
 
@@ -106,6 +117,13 @@ const Combobox = ({
106
117
  {isFetching && (
107
118
  <LoadingCircle className="x-main2" />
108
119
  )}
120
+ {inputValue.length > minLength && !isFetching && (
121
+ <Button isSimple isCompact color="main2" onClick={resetInputValue}>
122
+ <span className="f-icons">
123
+ Y
124
+ </span>
125
+ </Button>
126
+ )}
109
127
  </div>
110
128
 
111
129
  <Popover
@@ -209,6 +227,11 @@ Combobox.propTypes = {
209
227
  * Whether the input filed shpuld be disabled
210
228
  */
211
229
  disabled:PropTypes.bool,
230
+
231
+ /**
232
+ * Whether the input is optional or not
233
+ */
234
+ optional:PropTypes.bool,
212
235
  }
213
236
 
214
237
  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,
@@ -83,6 +84,8 @@ const MultipleCombobox = ({
83
84
  getComboboxProps,
84
85
  highlightedIndex,
85
86
  getItemProps,
87
+ inputValue,
88
+ setInputValue,
86
89
  } = useCombobox({
87
90
  searchInputValue,
88
91
  defaultHighlightedIndex:0, // after selection, highlight the first item.
@@ -144,6 +147,8 @@ const MultipleCombobox = ({
144
147
 
145
148
  const parentRef = useRef(null)
146
149
 
150
+ const resetInputValue = () => setInputValue('')
151
+
147
152
  return (
148
153
  <div
149
154
  id={id}
@@ -160,7 +165,11 @@ const MultipleCombobox = ({
160
165
  style={style}
161
166
  >
162
167
 
163
- <FormLabel {...getLabelProps()} name={name}>
168
+ <FormLabel
169
+ {...getLabelProps()}
170
+ name={name}
171
+ optional={optional}
172
+ >
164
173
  {label}
165
174
  </FormLabel>
166
175
 
@@ -199,6 +208,18 @@ const MultipleCombobox = ({
199
208
  {isFetching && (
200
209
  <LoadingCircle className="x-main2" />
201
210
  )}
211
+ {inputValue.length > minLength && !isFetching && (
212
+ <Button
213
+ isSimple
214
+ isCompact
215
+ color="main2"
216
+ onClick={resetInputValue}
217
+ >
218
+ <span className="f-icons">
219
+ Y
220
+ </span>
221
+ </Button>
222
+ )}
202
223
  </div>
203
224
 
204
225
  <Popover
@@ -305,6 +326,11 @@ MultipleCombobox.propTypes = {
305
326
  * Whether the input filed shpuld be disabled
306
327
  */
307
328
  disabled:PropTypes.bool,
329
+
330
+ /**
331
+ * Whether the input is optional or not
332
+ */
333
+ optional:PropTypes.bool,
308
334
  }
309
335
 
310
336
  MultipleCombobox.defaultProps = {
@@ -38,7 +38,8 @@ $default-loading-circle-displacement: 1em;
38
38
  >.input-wrapper {
39
39
  position: relative;
40
40
 
41
- >.#{bem.$base}.loading-circle {
41
+ >.#{bem.$base}.loading-circle,
42
+ >.#{bem.$base}.button {
42
43
  position: absolute;
43
44
  top: $default-loading-circle-displacement;
44
45
  right: $default-loading-circle-displacement;
@@ -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 = {