@pareto-engineering/design-system 4.0.0-alpha.62 → 4.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 (192) hide show
  1. package/dist/cjs/f/FormInput/FormInput.js +43 -13
  2. package/dist/cjs/f/common/V2/Description/Description.js +76 -0
  3. package/dist/cjs/f/common/V2/Description/index.js +13 -0
  4. package/dist/cjs/f/common/V2/Description/styles.scss +10 -0
  5. package/dist/cjs/f/common/V2/Label/Label.js +84 -0
  6. package/dist/cjs/f/common/V2/Label/index.js +13 -0
  7. package/dist/cjs/f/common/V2/Label/styles.scss +9 -0
  8. package/dist/cjs/f/common/V2/index.js +19 -0
  9. package/dist/cjs/f/common/index.js +12 -0
  10. package/dist/cjs/f/fields/V2/Checkbox/Checkbox.js +122 -0
  11. package/dist/cjs/f/fields/V2/Checkbox/index.js +13 -0
  12. package/dist/cjs/f/fields/V2/Checkbox/styles.scss +16 -0
  13. package/dist/cjs/f/fields/V2/ChoicesInput/ChoicesInput.js +154 -0
  14. package/dist/cjs/f/fields/V2/ChoicesInput/common/Choice/Choice.js +104 -0
  15. package/dist/cjs/f/fields/V2/ChoicesInput/common/Choice/index.js +13 -0
  16. package/dist/cjs/f/fields/V2/ChoicesInput/common/index.js +12 -0
  17. package/dist/cjs/f/fields/V2/ChoicesInput/index.js +13 -0
  18. package/dist/cjs/f/fields/V2/ChoicesInput/styles.scss +79 -0
  19. package/dist/cjs/f/fields/V2/EditorInput/EditorInput.js +197 -0
  20. package/dist/cjs/f/fields/V2/EditorInput/common/Toolbar.js +257 -0
  21. package/dist/cjs/f/fields/V2/EditorInput/common/TreeViewPlugin.js +18 -0
  22. package/dist/cjs/f/fields/V2/EditorInput/common/index.js +20 -0
  23. package/dist/cjs/f/fields/V2/EditorInput/index.js +13 -0
  24. package/dist/cjs/f/fields/V2/EditorInput/styles.scss +149 -0
  25. package/dist/cjs/f/fields/V2/LinkInput/LinkInput.js +156 -0
  26. package/dist/cjs/f/fields/V2/LinkInput/index.js +13 -0
  27. package/dist/cjs/f/fields/V2/LinkInput/styles.scss +90 -0
  28. package/dist/cjs/f/fields/V2/QueryChoices/QueryChoices.js +137 -0
  29. package/dist/cjs/f/fields/V2/QueryChoices/index.js +13 -0
  30. package/dist/cjs/f/fields/V2/QueryCombobox/QueryCombobox.js +229 -0
  31. package/dist/cjs/f/fields/V2/QueryCombobox/common/Combobox/Combobox.js +236 -0
  32. package/dist/cjs/f/fields/V2/QueryCombobox/common/Combobox/index.js +13 -0
  33. package/dist/cjs/f/fields/V2/QueryCombobox/common/Menu/Menu.js +83 -0
  34. package/dist/cjs/f/fields/V2/QueryCombobox/common/Menu/index.js +13 -0
  35. package/dist/cjs/f/fields/V2/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +300 -0
  36. package/dist/cjs/f/fields/V2/QueryCombobox/common/MultipleCombobox/index.js +13 -0
  37. package/dist/cjs/f/fields/V2/QueryCombobox/common/index.js +26 -0
  38. package/dist/cjs/f/fields/V2/QueryCombobox/index.js +13 -0
  39. package/dist/cjs/f/fields/V2/QueryCombobox/styles.scss +127 -0
  40. package/dist/cjs/f/fields/V2/QuerySelect/QuerySelect.js +198 -0
  41. package/dist/cjs/f/fields/V2/QuerySelect/index.js +13 -0
  42. package/dist/cjs/f/fields/V2/RatingsInput/RatingsInput.js +130 -0
  43. package/dist/cjs/f/fields/V2/RatingsInput/common/Rating/Rating.js +117 -0
  44. package/dist/cjs/f/fields/V2/RatingsInput/common/Rating/index.js +13 -0
  45. package/dist/cjs/f/fields/V2/RatingsInput/common/index.js +12 -0
  46. package/dist/cjs/f/fields/V2/RatingsInput/index.js +13 -0
  47. package/dist/cjs/f/fields/V2/RatingsInput/styles.scss +48 -0
  48. package/dist/cjs/f/fields/V2/SelectInput/SelectInput.js +154 -0
  49. package/dist/cjs/f/fields/V2/SelectInput/index.js +13 -0
  50. package/dist/cjs/f/fields/V2/SelectInput/styles.scss +87 -0
  51. package/dist/cjs/f/fields/V2/TextInput/TextInput.js +155 -0
  52. package/dist/cjs/f/fields/V2/TextInput/index.js +13 -0
  53. package/dist/cjs/f/fields/V2/TextInput/styles.scss +78 -0
  54. package/dist/cjs/f/fields/V2/TextareaInput/TextareaInput.js +152 -0
  55. package/dist/cjs/f/fields/V2/TextareaInput/index.js +13 -0
  56. package/dist/cjs/f/fields/V2/TextareaInput/styles.scss +53 -0
  57. package/dist/cjs/f/fields/V2/index.js +82 -0
  58. package/dist/cjs/f/fields/index.js +26 -1
  59. package/dist/es/f/FormInput/FormInput.js +33 -3
  60. package/dist/es/f/common/V2/Description/Description.js +68 -0
  61. package/dist/es/f/common/V2/Description/index.js +2 -0
  62. package/dist/es/f/common/V2/Description/styles.scss +10 -0
  63. package/dist/es/f/common/V2/Label/Label.js +76 -0
  64. package/dist/es/f/common/V2/Label/index.js +2 -0
  65. package/dist/es/f/common/V2/Label/styles.scss +9 -0
  66. package/dist/es/f/common/V2/index.js +2 -0
  67. package/dist/es/f/common/index.js +2 -1
  68. package/dist/es/f/fields/V2/Checkbox/Checkbox.js +114 -0
  69. package/dist/es/f/fields/V2/Checkbox/index.js +2 -0
  70. package/dist/es/f/fields/V2/Checkbox/styles.scss +16 -0
  71. package/dist/es/f/fields/V2/ChoicesInput/ChoicesInput.js +148 -0
  72. package/dist/es/f/fields/V2/ChoicesInput/common/Choice/Choice.js +97 -0
  73. package/dist/es/f/fields/V2/ChoicesInput/common/Choice/index.js +2 -0
  74. package/dist/es/f/fields/V2/ChoicesInput/common/index.js +1 -0
  75. package/dist/es/f/fields/V2/ChoicesInput/index.js +2 -0
  76. package/dist/es/f/fields/V2/ChoicesInput/styles.scss +79 -0
  77. package/dist/es/f/fields/V2/EditorInput/EditorInput.js +192 -0
  78. package/dist/es/f/fields/V2/EditorInput/common/Toolbar.js +246 -0
  79. package/dist/es/f/fields/V2/EditorInput/common/TreeViewPlugin.js +11 -0
  80. package/dist/es/f/fields/V2/EditorInput/common/index.js +2 -0
  81. package/dist/es/f/fields/V2/EditorInput/index.js +2 -0
  82. package/dist/es/f/fields/V2/EditorInput/styles.scss +149 -0
  83. package/dist/es/f/fields/V2/LinkInput/LinkInput.js +148 -0
  84. package/dist/es/f/fields/V2/LinkInput/index.js +2 -0
  85. package/dist/es/f/fields/V2/LinkInput/styles.scss +90 -0
  86. package/dist/es/f/fields/V2/QueryChoices/QueryChoices.js +126 -0
  87. package/dist/es/f/fields/V2/QueryChoices/index.js +2 -0
  88. package/dist/es/f/fields/V2/QueryCombobox/QueryCombobox.js +221 -0
  89. package/dist/es/f/fields/V2/QueryCombobox/common/Combobox/Combobox.js +229 -0
  90. package/dist/es/f/fields/V2/QueryCombobox/common/Combobox/index.js +2 -0
  91. package/dist/es/f/fields/V2/QueryCombobox/common/Menu/Menu.js +73 -0
  92. package/dist/es/f/fields/V2/QueryCombobox/common/Menu/index.js +2 -0
  93. package/dist/es/f/fields/V2/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +293 -0
  94. package/dist/es/f/fields/V2/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  95. package/dist/es/f/fields/V2/QueryCombobox/common/index.js +3 -0
  96. package/dist/es/f/fields/V2/QueryCombobox/index.js +2 -0
  97. package/dist/es/f/fields/V2/QueryCombobox/styles.scss +127 -0
  98. package/dist/es/f/fields/V2/QuerySelect/QuerySelect.js +186 -0
  99. package/dist/es/f/fields/V2/QuerySelect/index.js +2 -0
  100. package/dist/es/f/fields/V2/RatingsInput/RatingsInput.js +124 -0
  101. package/dist/es/f/fields/V2/RatingsInput/common/Rating/Rating.js +109 -0
  102. package/dist/es/f/fields/V2/RatingsInput/common/Rating/index.js +2 -0
  103. package/dist/es/f/fields/V2/RatingsInput/common/index.js +1 -0
  104. package/dist/es/f/fields/V2/RatingsInput/index.js +2 -0
  105. package/dist/es/f/fields/V2/RatingsInput/styles.scss +48 -0
  106. package/dist/es/f/fields/V2/SelectInput/SelectInput.js +146 -0
  107. package/dist/es/f/fields/V2/SelectInput/index.js +2 -0
  108. package/dist/es/f/fields/V2/SelectInput/styles.scss +87 -0
  109. package/dist/es/f/fields/V2/TextInput/TextInput.js +147 -0
  110. package/dist/es/f/fields/V2/TextInput/index.js +2 -0
  111. package/dist/es/f/fields/V2/TextInput/styles.scss +78 -0
  112. package/dist/es/f/fields/V2/TextareaInput/TextareaInput.js +146 -0
  113. package/dist/es/f/fields/V2/TextareaInput/index.js +2 -0
  114. package/dist/es/f/fields/V2/TextareaInput/styles.scss +53 -0
  115. package/dist/es/f/fields/V2/index.js +11 -0
  116. package/dist/es/f/fields/index.js +2 -1
  117. package/package.json +3 -3
  118. package/src/stories/f/v2/Checkbox.stories.jsx +102 -0
  119. package/src/stories/f/v2/ChoicesInput.stories.jsx +139 -0
  120. package/src/stories/f/v2/EditorInput.stories.jsx +81 -0
  121. package/src/stories/f/v2/LinkInput.stories.jsx +93 -0
  122. package/src/stories/f/v2/QueryChoices.stories.jsx +144 -0
  123. package/src/stories/f/v2/QueryCombobox.stories.jsx +301 -0
  124. package/src/stories/f/v2/QuerySelect.stories.jsx +150 -0
  125. package/src/stories/f/v2/RatingsInput.stories.jsx +77 -0
  126. package/src/stories/f/v2/SelectInput.stories.jsx +95 -0
  127. package/src/stories/f/v2/TextInput.stories.jsx +120 -0
  128. package/src/stories/f/v2/TextareaInput.stories.jsx +107 -0
  129. package/src/stories/f/v2/__generated__/FormInputAllTaskStatusesQuery.graphql.js +122 -0
  130. package/src/stories/f/v2/__generated__/FormInputAllTeamsQuery.graphql.js +139 -0
  131. package/src/stories/f/v2/__generated__/QueryChoicesAllTaskStatusesQuery.graphql.js +122 -0
  132. package/src/stories/f/v2/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
  133. package/src/stories/f/v2/__generated__/QuerySelectAllTaskStatusesQuery.graphql.js +122 -0
  134. package/src/ui/f/FormInput/FormInput.jsx +57 -12
  135. package/src/ui/f/common/V2/Description/Description.jsx +94 -0
  136. package/src/ui/f/common/V2/Description/index.js +2 -0
  137. package/src/ui/f/common/V2/Description/styles.scss +10 -0
  138. package/src/ui/f/common/V2/Label/Label.jsx +102 -0
  139. package/src/ui/f/common/V2/Label/index.js +2 -0
  140. package/src/ui/f/common/V2/Label/styles.scss +9 -0
  141. package/src/ui/f/common/V2/index.js +2 -0
  142. package/src/ui/f/common/index.js +1 -0
  143. package/src/ui/f/fields/V2/Checkbox/Checkbox.jsx +146 -0
  144. package/src/ui/f/fields/V2/Checkbox/index.js +2 -0
  145. package/src/ui/f/fields/V2/Checkbox/styles.scss +16 -0
  146. package/src/ui/f/fields/V2/ChoicesInput/ChoicesInput.jsx +183 -0
  147. package/src/ui/f/fields/V2/ChoicesInput/common/Choice/Choice.jsx +125 -0
  148. package/src/ui/f/fields/V2/ChoicesInput/common/Choice/index.js +2 -0
  149. package/src/ui/f/fields/V2/ChoicesInput/common/index.js +1 -0
  150. package/src/ui/f/fields/V2/ChoicesInput/index.js +2 -0
  151. package/src/ui/f/fields/V2/ChoicesInput/styles.scss +79 -0
  152. package/src/ui/f/fields/V2/EditorInput/EditorInput.jsx +244 -0
  153. package/src/ui/f/fields/V2/EditorInput/common/Toolbar.jsx +356 -0
  154. package/src/ui/f/fields/V2/EditorInput/common/TreeViewPlugin.jsx +16 -0
  155. package/src/ui/f/fields/V2/EditorInput/common/index.jsx +2 -0
  156. package/src/ui/f/fields/V2/EditorInput/index.js +2 -0
  157. package/src/ui/f/fields/V2/EditorInput/styles.scss +149 -0
  158. package/src/ui/f/fields/V2/LinkInput/LinkInput.jsx +187 -0
  159. package/src/ui/f/fields/V2/LinkInput/index.js +2 -0
  160. package/src/ui/f/fields/V2/LinkInput/styles.scss +90 -0
  161. package/src/ui/f/fields/V2/QueryChoices/QueryChoices.jsx +153 -0
  162. package/src/ui/f/fields/V2/QueryChoices/index.js +2 -0
  163. package/src/ui/f/fields/V2/QueryCombobox/QueryCombobox.jsx +254 -0
  164. package/src/ui/f/fields/V2/QueryCombobox/common/Combobox/Combobox.jsx +276 -0
  165. package/src/ui/f/fields/V2/QueryCombobox/common/Combobox/index.js +2 -0
  166. package/src/ui/f/fields/V2/QueryCombobox/common/Menu/Menu.jsx +103 -0
  167. package/src/ui/f/fields/V2/QueryCombobox/common/Menu/index.js +2 -0
  168. package/src/ui/f/fields/V2/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +362 -0
  169. package/src/ui/f/fields/V2/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  170. package/src/ui/f/fields/V2/QueryCombobox/common/index.js +3 -0
  171. package/src/ui/f/fields/V2/QueryCombobox/index.js +2 -0
  172. package/src/ui/f/fields/V2/QueryCombobox/styles.scss +127 -0
  173. package/src/ui/f/fields/V2/QuerySelect/QuerySelect.jsx +220 -0
  174. package/src/ui/f/fields/V2/QuerySelect/index.js +2 -0
  175. package/src/ui/f/fields/V2/RatingsInput/RatingsInput.jsx +152 -0
  176. package/src/ui/f/fields/V2/RatingsInput/common/Rating/Rating.jsx +142 -0
  177. package/src/ui/f/fields/V2/RatingsInput/common/Rating/index.js +2 -0
  178. package/src/ui/f/fields/V2/RatingsInput/common/index.js +1 -0
  179. package/src/ui/f/fields/V2/RatingsInput/index.js +2 -0
  180. package/src/ui/f/fields/V2/RatingsInput/styles.scss +48 -0
  181. package/src/ui/f/fields/V2/SelectInput/SelectInput.jsx +187 -0
  182. package/src/ui/f/fields/V2/SelectInput/index.js +2 -0
  183. package/src/ui/f/fields/V2/SelectInput/styles.scss +87 -0
  184. package/src/ui/f/fields/V2/TextInput/TextInput.jsx +192 -0
  185. package/src/ui/f/fields/V2/TextInput/index.js +2 -0
  186. package/src/ui/f/fields/V2/TextInput/styles.scss +78 -0
  187. package/src/ui/f/fields/V2/TextareaInput/TextareaInput.jsx +180 -0
  188. package/src/ui/f/fields/V2/TextareaInput/index.js +2 -0
  189. package/src/ui/f/fields/V2/TextareaInput/styles.scss +53 -0
  190. package/src/ui/f/fields/V2/index.js +11 -0
  191. package/src/ui/f/fields/index.js +1 -0
  192. package/tests/__snapshots__/Storyshots.test.js.snap +5909 -0
@@ -0,0 +1,301 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { Formik, Form, useField } from 'formik'
5
+
6
+ import { Button, FormDebugger, QueryComboboxV2 } from 'ui'
7
+
8
+ import { fruits } from '../../utils/testData'
9
+
10
+ import generateNodeId from '../../utils/generateNodeId'
11
+
12
+ import {
13
+ RelayEnvironmentProvider,
14
+ mockRelayOperation,
15
+ // environment,
16
+ } from '../../utils/relay'
17
+
18
+ export default {
19
+ title :'f/fields/V2/QueryComboboxV2',
20
+ component :QueryComboboxV2,
21
+ subcomponents:{
22
+ // Item:QueryComboboxV2.Item
23
+ },
24
+ decorators:[
25
+ (storyfn) => (
26
+ <RelayEnvironmentProvider>
27
+ { storyfn() }
28
+ </RelayEnvironmentProvider>
29
+ ),
30
+ ],
31
+ argTypes:{
32
+ disabled :{ control: 'boolean' },
33
+ type :{ control: 'text' },
34
+ name :{ control: 'text' },
35
+ color :{ control: 'text' },
36
+ label :{ control: 'text' },
37
+ labelColor:{ control: 'text' },
38
+ multiple :{ control: 'boolean' },
39
+ optional :{ control: 'boolean' },
40
+ },
41
+ }
42
+
43
+ const allTeamsMockData = {
44
+ PageInfo() {
45
+ return {
46
+ hasNextPage :true,
47
+ hasPreviousPage:true,
48
+ }
49
+ },
50
+ TeamNodeConnection:(args) => {
51
+ const edges = fruits.map((fruit) => ({
52
+ node:{
53
+ id :generateNodeId('TeamNode'),
54
+ name:fruit,
55
+ },
56
+ }))
57
+
58
+ // eslint-disable-next-line camelcase
59
+ const { name_Icontains } = args?.args || {}
60
+
61
+ return ({
62
+ pageInfo:{
63
+ hasNextPage :true,
64
+ hasPreviousPage:true,
65
+ },
66
+ // eslint-disable-next-line camelcase
67
+ edges:name_Icontains?.trim()
68
+ ? edges.filter(({ node }) => node.name
69
+ .toLowerCase()
70
+ .includes(name_Icontains.toLowerCase()))
71
+ : [],
72
+ })
73
+ },
74
+ }
75
+
76
+ const FETCH_TEAMS_QUERY = graphql`
77
+ query QueryComboboxAllTeamsQuery($name_Icontains: String) {
78
+ allTeams(name_Icontains: $name_Icontains) {
79
+ edges {
80
+ node {
81
+ id
82
+ name
83
+ }
84
+ }
85
+ }
86
+ }
87
+ `
88
+
89
+ // eslint-disable-next-line react/prop-types
90
+ const ResolvedTemplate = ({ defaultFormikState, ...otherProps }) => {
91
+ mockRelayOperation(allTeamsMockData)
92
+ mockRelayOperation(allTeamsMockData)
93
+ mockRelayOperation(allTeamsMockData)
94
+
95
+ const { multiple } = otherProps
96
+
97
+ const Content = () => {
98
+ const name = multiple ? 'teams' : 'team'
99
+
100
+ const [, meta, helpers] = useField(name)
101
+
102
+ const { value } = meta
103
+
104
+ const { setValue } = helpers
105
+
106
+ const updateFormikState = () => {
107
+ if (multiple) {
108
+ setValue([
109
+ ...(value || []),
110
+ {
111
+ value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNk',
112
+ label:'Matomoko',
113
+ },
114
+ {
115
+ value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNp',
116
+ label:'Chungwa',
117
+ },
118
+ ])
119
+ } else {
120
+ setValue({
121
+ value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNk',
122
+ label:'Kafagoho',
123
+ })
124
+ }
125
+ }
126
+
127
+ return (
128
+ <div
129
+ style={{
130
+ display :'flex',
131
+ flexDirection:'column',
132
+ gap :'1rem',
133
+ }}
134
+ >
135
+ <QueryComboboxV2
136
+ label="Search for a team"
137
+ optionsKeyMap={{
138
+ value :'id',
139
+ getLabel:(node) => node.name,
140
+ }}
141
+ query={{
142
+ graphql :FETCH_TEAMS_QUERY,
143
+ accessor:'allTeams',
144
+ }}
145
+ name={name}
146
+ searchVariable="name_Icontains"
147
+ {...otherProps}
148
+ />
149
+ <div>
150
+ <FormDebugger />
151
+ <Button
152
+ onClick={updateFormikState}
153
+ >
154
+ {multiple ? 'Add formik values' : 'Replace formik value'}
155
+ </Button>
156
+ </div>
157
+ </div>
158
+ )
159
+ }
160
+
161
+ let initialValues = defaultFormikState
162
+
163
+ if (!defaultFormikState && multiple) {
164
+ initialValues = []
165
+ } else if (!defaultFormikState && !multiple) {
166
+ initialValues = {}
167
+ }
168
+
169
+ return (
170
+ <Formik
171
+ initialValues={initialValues}
172
+ >
173
+ <Form>
174
+ <Content />
175
+ </Form>
176
+ </Formik>
177
+ )
178
+ }
179
+
180
+ export const Optional = ResolvedTemplate.bind({})
181
+ Optional.args = {
182
+ optional:true,
183
+ }
184
+
185
+ export const WithPlaceholder = ResolvedTemplate.bind({})
186
+ WithPlaceholder.args = {
187
+ placeholder:'Search for a team',
188
+ }
189
+
190
+ export const WithPromptToCreateNewOption = ResolvedTemplate.bind({})
191
+ WithPromptToCreateNewOption.args = {
192
+ placeholder :'Search for a team',
193
+ promptCreateNewOption:true,
194
+ }
195
+
196
+ export const SingleSelect = ResolvedTemplate.bind({})
197
+ SingleSelect.args = {
198
+ multiple:false,
199
+ }
200
+
201
+ export const SingleSelectWithDefaultFormikState = ResolvedTemplate.bind({})
202
+ SingleSelectWithDefaultFormikState.args = {
203
+ multiple :false,
204
+ defaultFormikState:{
205
+ team:{
206
+ value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
207
+ label:'Apple',
208
+ },
209
+ },
210
+ }
211
+
212
+ export const MultipleSelect = ResolvedTemplate.bind({})
213
+ MultipleSelect.args = {
214
+ multiple :true,
215
+ defaultFormikState:{ teams: [] },
216
+ }
217
+
218
+ export const MultipleSelectWithPromptForNewOptions = ResolvedTemplate.bind({})
219
+ MultipleSelectWithPromptForNewOptions.args = {
220
+ multiple :true,
221
+ promptCreateNewOption:true,
222
+ defaultFormikState :{ teams: [] },
223
+ }
224
+
225
+ export const MultipleSelectWithDefaultFormikState = ResolvedTemplate.bind({})
226
+ MultipleSelectWithDefaultFormikState.args = {
227
+ multiple :true,
228
+ defaultFormikState:{
229
+ teams:[
230
+ {
231
+ value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
232
+ label:'Apple',
233
+ },
234
+ {
235
+ value:'VGVhbU5vZGU6MDA0N2U4MzktODY0Zi00N2U5LTg3ZjgtZGUwMmM2Yzg1YWJm',
236
+ label:'Pear',
237
+ },
238
+ ],
239
+ },
240
+ }
241
+
242
+ // eslint-disable-next-line react/prop-types
243
+ // const RejectedTemplate = ({ multiple }) => {
244
+ // const Content = () => {
245
+ // environment.mock.queuePendingOperation(
246
+ // FETCH_TEAMS_QUERY,
247
+ // { name_Icontains: 'a' },
248
+ // )
249
+
250
+ // environment.mock.rejectMostRecentOperation('An error has occured while fetching the teams')
251
+
252
+ // const name = multiple ? 'teams' : 'team'
253
+
254
+ // const [, meta, helpers] = useField(name)
255
+
256
+ // const { setValue, setError } = helpers
257
+
258
+ // const { error } = meta
259
+
260
+ // return (
261
+ // <>
262
+ // <QueryCombobox
263
+ // query={FETCH_TEAMS_QUERY}
264
+ // label="Search for a team"
265
+ // optionsKeyMap={{
266
+ // value:'id',
267
+ // label:'name',
268
+ // }}
269
+ // error={error}
270
+ // setValue={setValue}
271
+ // setError={setError}
272
+ // name={name}
273
+ // multiple={multiple}
274
+ // graphQlNode="allTeams"
275
+ // searchVariable="name_Icontains"
276
+ // />
277
+ // <FormDebugger />
278
+ // </>
279
+ // )
280
+ // }
281
+
282
+ // return (
283
+ // <Formik
284
+ // initialValues={{ team: '' }}
285
+ // >
286
+ // <Form>
287
+ // <Content />
288
+ // </Form>
289
+ // </Formik>
290
+ // )
291
+ // }
292
+
293
+ // export const SingleSelectWithError = RejectedTemplate.bind({})
294
+ // SingleSelectWithError.args = {
295
+ // multiple:false,
296
+ // }
297
+
298
+ // export const MultipleSelectWithError = RejectedTemplate.bind({})
299
+ // MultipleSelectWithError.args = {
300
+ // multiple:true,
301
+ // }
@@ -0,0 +1,150 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { QuerySelectV2, FormDebugger } from 'ui'
5
+
6
+ import { Formik, Form } from 'formik'
7
+
8
+ import generateNodeId from '../../utils/generateNodeId'
9
+
10
+ import {
11
+ RelayEnvironmentProvider,
12
+ mockRelayOperation,
13
+ environment,
14
+ } from '../../utils/relay'
15
+
16
+ export default {
17
+ title :'f/fields/V2/QuerySelectV2',
18
+ component :QuerySelectV2,
19
+ subcomponents:{
20
+ // Item:QuerySelectV2.Item
21
+ },
22
+ decorators:[
23
+ // storyfn => <div className="">{ storyfn() }</div>,
24
+ (storyfn) => (
25
+ <RelayEnvironmentProvider>
26
+ { storyfn() }
27
+ </RelayEnvironmentProvider>
28
+ ),
29
+ ],
30
+ argTypes:{
31
+ color :{ control: 'text' },
32
+ label :{ control: 'text' },
33
+ labelColor:{ control: 'text' },
34
+ isLoading :{ control: 'boolean' },
35
+ optional :{ control: 'boolean' },
36
+ },
37
+ }
38
+ const statuses = [
39
+ 'Backlog',
40
+ 'In Review',
41
+ 'In Progress',
42
+ 'Requested',
43
+ 'Blocked',
44
+ 'Completed',
45
+ ]
46
+ const allTaskStatusesMockData = {
47
+ PageInfo() {
48
+ return {
49
+ hasNextPage :true,
50
+ hasPreviousPage:true,
51
+ }
52
+ },
53
+ TaskStatusNodeConnection:() => ({
54
+ pageInfo:{
55
+ hasNextPage :true,
56
+ hasPreviousPage:true,
57
+ },
58
+
59
+ edges:statuses.map((status) => ({
60
+ node:{
61
+ id:generateNodeId('TaskStatusNode'),
62
+ status,
63
+ },
64
+ })),
65
+ }),
66
+ }
67
+
68
+ const FETCH_ALL_TASK_STATUSES = graphql`
69
+ query QuerySelectAllTaskStatusesQuery {
70
+ allTaskStatuses {
71
+ edges {
72
+ node {
73
+ id
74
+ status
75
+ }
76
+ }
77
+ }
78
+ }
79
+ `
80
+
81
+ // eslint-disable-next-line react/prop-types
82
+ const Template = ({ isLoading, defaultFormikState, ...args }) => {
83
+ if (isLoading) {
84
+ setTimeout(() => {
85
+ mockRelayOperation(allTaskStatusesMockData)
86
+ environment.mock.queuePendingOperation(
87
+ FETCH_ALL_TASK_STATUSES,
88
+ )
89
+ }, 500)
90
+ } else {
91
+ mockRelayOperation(allTaskStatusesMockData)
92
+ environment.mock.queuePendingOperation(
93
+ FETCH_ALL_TASK_STATUSES,
94
+ )
95
+ }
96
+
97
+ const Content = () => (
98
+ <div
99
+ style={{
100
+ display :'flex',
101
+ flexDirection:'column',
102
+ gap :'1rem',
103
+ }}
104
+ >
105
+ <QuerySelectV2
106
+ name="status"
107
+ label="Select Task Status"
108
+ query={{
109
+ graphql :FETCH_ALL_TASK_STATUSES,
110
+ accessor:'allTaskStatuses',
111
+ }}
112
+ optionsKeyMap={{
113
+ value :'id',
114
+ getLabel:(node) => node.status,
115
+ }}
116
+ {...args}
117
+ />
118
+ <FormDebugger />
119
+ </div>
120
+ )
121
+
122
+ const initialValues = defaultFormikState ?? { status: '' }
123
+
124
+ return (
125
+ <Formik
126
+ initialValues={initialValues}
127
+ >
128
+ <Form>
129
+ <Content />
130
+ </Form>
131
+ </Formik>
132
+ )
133
+ }
134
+
135
+ export const Base = Template.bind({})
136
+ export const WithDefaultValue = Template.bind({})
137
+ WithDefaultValue.args = {
138
+ defaultFormikState:{
139
+ status:'VGFza1N0YXR1c05vZGU6NGRiYjNlMmItMGIxYy00ZjIxLTk0MmUtZTNjZGQwMjdiNjU3',
140
+ },
141
+ }
142
+ export const LoadingOptions = Template.bind({})
143
+ LoadingOptions.args = {
144
+ isLoading:true,
145
+ }
146
+
147
+ export const Optional = Template.bind({})
148
+ Optional.args = {
149
+ optional:true,
150
+ }
@@ -0,0 +1,77 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { Formik, Form } from 'formik'
5
+
6
+ import { RatingsInputV2, FormDebugger } from 'ui'
7
+
8
+ export default {
9
+ title :'f/fields/V2/RatingsInputV2',
10
+ component :RatingsInputV2,
11
+ subcomponents:{
12
+ // Item:RatingsInputV2.Item
13
+ },
14
+ decorators:[
15
+ (storyfn) => (
16
+ <Formik
17
+ initialValues={{ ratings: '' }}
18
+ >
19
+ <Form>
20
+ { storyfn() }
21
+ </Form>
22
+ </Formik>
23
+ ),
24
+ ],
25
+ argTypes:{
26
+ // backgroundColor:{ control: 'color' },
27
+ ratingCount :{ control: 'number' },
28
+ name :{ control: 'text' },
29
+ label :{ control: 'text' },
30
+ labelColor :{ control: 'text' },
31
+ showRatingValue :{ control: 'boolean' },
32
+ displayRatingsLabel:{ control: 'boolean' },
33
+ labelMax :{ control: 'text' },
34
+ labelMin :{ control: 'text' },
35
+ optional :{ control: 'boolean' },
36
+ },
37
+ }
38
+
39
+ const Template = (args) => (
40
+ <div
41
+ style={{
42
+ display :'flex',
43
+ flexDirection:'column',
44
+ gap :'1rem',
45
+ }}
46
+ >
47
+ <RatingsInputV2 {...args} />
48
+ <FormDebugger />
49
+ </div>
50
+ )
51
+
52
+ export const Base = Template.bind({})
53
+ Base.args = {
54
+ ratingCount:5,
55
+ name :'ratings',
56
+ label :'Your Rating',
57
+ }
58
+
59
+ export const Optional = Template.bind({})
60
+ Optional.args = {
61
+ ...Base.args,
62
+ optional:true,
63
+ }
64
+
65
+ export const Numbers = Template.bind({})
66
+ Numbers.args = {
67
+ ...Base.args,
68
+ showRatingValue:true,
69
+ }
70
+
71
+ export const Labels = Template.bind({})
72
+ Labels.args = {
73
+ ...Numbers.args,
74
+ labelMax :'very satisfied.',
75
+ labelMin :'not satisfied.',
76
+ displayRatingsLabel:true,
77
+ }
@@ -0,0 +1,95 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+ import { Formik, Form } from 'formik'
4
+
5
+ import { SelectInputV2, FormDebugger } from 'ui'
6
+
7
+ export default {
8
+ title :'f/fields/V2/SelectInputV2',
9
+ component :SelectInputV2,
10
+ subcomponents:{
11
+ // Item:SelectInputV2.Item
12
+ },
13
+ decorators:[
14
+ (storyfn) => (
15
+ <Formik
16
+ initialValues={{ workType: '' }}
17
+ >
18
+ <Form>
19
+ { storyfn() }
20
+ </Form>
21
+ </Formik>
22
+ ),
23
+ ],
24
+ argTypes:{
25
+ color :{ control: 'text' },
26
+ label :{ control: 'text' },
27
+ labelColor:{ control: 'text' },
28
+ disabled :{ control: 'boolean' },
29
+ optional :{ control: 'boolean' },
30
+ },
31
+ }
32
+
33
+ const Template = (args) => (
34
+ <div
35
+ style={{
36
+ display :'flex',
37
+ flexDirection:'column',
38
+ gap :'1rem',
39
+ }}
40
+ >
41
+ <SelectInputV2 {...args} />
42
+ <FormDebugger />
43
+ </div>
44
+ )
45
+
46
+ export const Base = Template.bind({})
47
+ Base.args = {
48
+ name :'workType',
49
+ label :'Work Type',
50
+ options:[
51
+ { value: '', label: 'Select an option', disabled: true },
52
+ { value: 'Work', label: 'Work' },
53
+ { value: 'Managing', label: 'Managing' },
54
+ { value: 'Training', label: 'Training' },
55
+ ],
56
+ }
57
+
58
+ export const Optional = Template.bind({})
59
+ Optional.args = {
60
+ ...Base.args,
61
+ optional:true,
62
+ }
63
+
64
+ export const StringAndObjects = Template.bind({})
65
+ StringAndObjects.args = {
66
+ ...Base.args,
67
+ options:[...Base.args.options, 'Option1', 'Option2', 'Option3'],
68
+ }
69
+
70
+ const requiredInput = (inputValue) => {
71
+ let error = ''
72
+
73
+ if (!inputValue || !inputValue?.length === 0) {
74
+ error = 'This information is required'
75
+ }
76
+ return error
77
+ }
78
+ export const Required = Template.bind({})
79
+ Required.args = {
80
+ ...Base.args,
81
+ validate:requiredInput,
82
+ }
83
+
84
+ export const DisabledSelectInput = Template.bind({})
85
+ DisabledSelectInput.args = {
86
+ ...Base.args,
87
+ disabled:true,
88
+ }
89
+
90
+ export const DisabledWithDescriptionSelectInput = Template.bind({})
91
+ DisabledWithDescriptionSelectInput.args = {
92
+ ...Base.args,
93
+ disabled :true,
94
+ description:'This is a description',
95
+ }