@pareto-engineering/design-system 4.0.0-alpha.61 → 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 (198) hide show
  1. package/dist/cjs/a/TextSteps/TextSteps.js +4 -4
  2. package/dist/cjs/a/TextSteps/styles.scss +1 -1
  3. package/dist/cjs/f/FormInput/FormInput.js +43 -13
  4. package/dist/cjs/f/common/V2/Description/Description.js +76 -0
  5. package/dist/cjs/f/common/V2/Description/index.js +13 -0
  6. package/dist/cjs/f/common/V2/Description/styles.scss +10 -0
  7. package/dist/cjs/f/common/V2/Label/Label.js +84 -0
  8. package/dist/cjs/f/common/V2/Label/index.js +13 -0
  9. package/dist/cjs/f/common/V2/Label/styles.scss +9 -0
  10. package/dist/cjs/f/common/V2/index.js +19 -0
  11. package/dist/cjs/f/common/index.js +12 -0
  12. package/dist/cjs/f/fields/V2/Checkbox/Checkbox.js +122 -0
  13. package/dist/cjs/f/fields/V2/Checkbox/index.js +13 -0
  14. package/dist/cjs/f/fields/V2/Checkbox/styles.scss +16 -0
  15. package/dist/cjs/f/fields/V2/ChoicesInput/ChoicesInput.js +154 -0
  16. package/dist/cjs/f/fields/V2/ChoicesInput/common/Choice/Choice.js +104 -0
  17. package/dist/cjs/f/fields/V2/ChoicesInput/common/Choice/index.js +13 -0
  18. package/dist/cjs/f/fields/V2/ChoicesInput/common/index.js +12 -0
  19. package/dist/cjs/f/fields/V2/ChoicesInput/index.js +13 -0
  20. package/dist/cjs/f/fields/V2/ChoicesInput/styles.scss +79 -0
  21. package/dist/cjs/f/fields/V2/EditorInput/EditorInput.js +197 -0
  22. package/dist/cjs/f/fields/V2/EditorInput/common/Toolbar.js +257 -0
  23. package/dist/cjs/f/fields/V2/EditorInput/common/TreeViewPlugin.js +18 -0
  24. package/dist/cjs/f/fields/V2/EditorInput/common/index.js +20 -0
  25. package/dist/cjs/f/fields/V2/EditorInput/index.js +13 -0
  26. package/dist/cjs/f/fields/V2/EditorInput/styles.scss +149 -0
  27. package/dist/cjs/f/fields/V2/LinkInput/LinkInput.js +156 -0
  28. package/dist/cjs/f/fields/V2/LinkInput/index.js +13 -0
  29. package/dist/cjs/f/fields/V2/LinkInput/styles.scss +90 -0
  30. package/dist/cjs/f/fields/V2/QueryChoices/QueryChoices.js +137 -0
  31. package/dist/cjs/f/fields/V2/QueryChoices/index.js +13 -0
  32. package/dist/cjs/f/fields/V2/QueryCombobox/QueryCombobox.js +229 -0
  33. package/dist/cjs/f/fields/V2/QueryCombobox/common/Combobox/Combobox.js +236 -0
  34. package/dist/cjs/f/fields/V2/QueryCombobox/common/Combobox/index.js +13 -0
  35. package/dist/cjs/f/fields/V2/QueryCombobox/common/Menu/Menu.js +83 -0
  36. package/dist/cjs/f/fields/V2/QueryCombobox/common/Menu/index.js +13 -0
  37. package/dist/cjs/f/fields/V2/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +300 -0
  38. package/dist/cjs/f/fields/V2/QueryCombobox/common/MultipleCombobox/index.js +13 -0
  39. package/dist/cjs/f/fields/V2/QueryCombobox/common/index.js +26 -0
  40. package/dist/cjs/f/fields/V2/QueryCombobox/index.js +13 -0
  41. package/dist/cjs/f/fields/V2/QueryCombobox/styles.scss +127 -0
  42. package/dist/cjs/f/fields/V2/QuerySelect/QuerySelect.js +198 -0
  43. package/dist/cjs/f/fields/V2/QuerySelect/index.js +13 -0
  44. package/dist/cjs/f/fields/V2/RatingsInput/RatingsInput.js +130 -0
  45. package/dist/cjs/f/fields/V2/RatingsInput/common/Rating/Rating.js +117 -0
  46. package/dist/cjs/f/fields/V2/RatingsInput/common/Rating/index.js +13 -0
  47. package/dist/cjs/f/fields/V2/RatingsInput/common/index.js +12 -0
  48. package/dist/cjs/f/fields/V2/RatingsInput/index.js +13 -0
  49. package/dist/cjs/f/fields/V2/RatingsInput/styles.scss +48 -0
  50. package/dist/cjs/f/fields/V2/SelectInput/SelectInput.js +154 -0
  51. package/dist/cjs/f/fields/V2/SelectInput/index.js +13 -0
  52. package/dist/cjs/f/fields/V2/SelectInput/styles.scss +87 -0
  53. package/dist/cjs/f/fields/V2/TextInput/TextInput.js +155 -0
  54. package/dist/cjs/f/fields/V2/TextInput/index.js +13 -0
  55. package/dist/cjs/f/fields/V2/TextInput/styles.scss +78 -0
  56. package/dist/cjs/f/fields/V2/TextareaInput/TextareaInput.js +152 -0
  57. package/dist/cjs/f/fields/V2/TextareaInput/index.js +13 -0
  58. package/dist/cjs/f/fields/V2/TextareaInput/styles.scss +53 -0
  59. package/dist/cjs/f/fields/V2/index.js +82 -0
  60. package/dist/cjs/f/fields/index.js +26 -1
  61. package/dist/es/a/TextSteps/TextSteps.js +4 -4
  62. package/dist/es/a/TextSteps/styles.scss +1 -1
  63. package/dist/es/f/FormInput/FormInput.js +33 -3
  64. package/dist/es/f/common/V2/Description/Description.js +68 -0
  65. package/dist/es/f/common/V2/Description/index.js +2 -0
  66. package/dist/es/f/common/V2/Description/styles.scss +10 -0
  67. package/dist/es/f/common/V2/Label/Label.js +76 -0
  68. package/dist/es/f/common/V2/Label/index.js +2 -0
  69. package/dist/es/f/common/V2/Label/styles.scss +9 -0
  70. package/dist/es/f/common/V2/index.js +2 -0
  71. package/dist/es/f/common/index.js +2 -1
  72. package/dist/es/f/fields/V2/Checkbox/Checkbox.js +114 -0
  73. package/dist/es/f/fields/V2/Checkbox/index.js +2 -0
  74. package/dist/es/f/fields/V2/Checkbox/styles.scss +16 -0
  75. package/dist/es/f/fields/V2/ChoicesInput/ChoicesInput.js +148 -0
  76. package/dist/es/f/fields/V2/ChoicesInput/common/Choice/Choice.js +97 -0
  77. package/dist/es/f/fields/V2/ChoicesInput/common/Choice/index.js +2 -0
  78. package/dist/es/f/fields/V2/ChoicesInput/common/index.js +1 -0
  79. package/dist/es/f/fields/V2/ChoicesInput/index.js +2 -0
  80. package/dist/es/f/fields/V2/ChoicesInput/styles.scss +79 -0
  81. package/dist/es/f/fields/V2/EditorInput/EditorInput.js +192 -0
  82. package/dist/es/f/fields/V2/EditorInput/common/Toolbar.js +246 -0
  83. package/dist/es/f/fields/V2/EditorInput/common/TreeViewPlugin.js +11 -0
  84. package/dist/es/f/fields/V2/EditorInput/common/index.js +2 -0
  85. package/dist/es/f/fields/V2/EditorInput/index.js +2 -0
  86. package/dist/es/f/fields/V2/EditorInput/styles.scss +149 -0
  87. package/dist/es/f/fields/V2/LinkInput/LinkInput.js +148 -0
  88. package/dist/es/f/fields/V2/LinkInput/index.js +2 -0
  89. package/dist/es/f/fields/V2/LinkInput/styles.scss +90 -0
  90. package/dist/es/f/fields/V2/QueryChoices/QueryChoices.js +126 -0
  91. package/dist/es/f/fields/V2/QueryChoices/index.js +2 -0
  92. package/dist/es/f/fields/V2/QueryCombobox/QueryCombobox.js +221 -0
  93. package/dist/es/f/fields/V2/QueryCombobox/common/Combobox/Combobox.js +229 -0
  94. package/dist/es/f/fields/V2/QueryCombobox/common/Combobox/index.js +2 -0
  95. package/dist/es/f/fields/V2/QueryCombobox/common/Menu/Menu.js +73 -0
  96. package/dist/es/f/fields/V2/QueryCombobox/common/Menu/index.js +2 -0
  97. package/dist/es/f/fields/V2/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +293 -0
  98. package/dist/es/f/fields/V2/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  99. package/dist/es/f/fields/V2/QueryCombobox/common/index.js +3 -0
  100. package/dist/es/f/fields/V2/QueryCombobox/index.js +2 -0
  101. package/dist/es/f/fields/V2/QueryCombobox/styles.scss +127 -0
  102. package/dist/es/f/fields/V2/QuerySelect/QuerySelect.js +186 -0
  103. package/dist/es/f/fields/V2/QuerySelect/index.js +2 -0
  104. package/dist/es/f/fields/V2/RatingsInput/RatingsInput.js +124 -0
  105. package/dist/es/f/fields/V2/RatingsInput/common/Rating/Rating.js +109 -0
  106. package/dist/es/f/fields/V2/RatingsInput/common/Rating/index.js +2 -0
  107. package/dist/es/f/fields/V2/RatingsInput/common/index.js +1 -0
  108. package/dist/es/f/fields/V2/RatingsInput/index.js +2 -0
  109. package/dist/es/f/fields/V2/RatingsInput/styles.scss +48 -0
  110. package/dist/es/f/fields/V2/SelectInput/SelectInput.js +146 -0
  111. package/dist/es/f/fields/V2/SelectInput/index.js +2 -0
  112. package/dist/es/f/fields/V2/SelectInput/styles.scss +87 -0
  113. package/dist/es/f/fields/V2/TextInput/TextInput.js +147 -0
  114. package/dist/es/f/fields/V2/TextInput/index.js +2 -0
  115. package/dist/es/f/fields/V2/TextInput/styles.scss +78 -0
  116. package/dist/es/f/fields/V2/TextareaInput/TextareaInput.js +146 -0
  117. package/dist/es/f/fields/V2/TextareaInput/index.js +2 -0
  118. package/dist/es/f/fields/V2/TextareaInput/styles.scss +53 -0
  119. package/dist/es/f/fields/V2/index.js +11 -0
  120. package/dist/es/f/fields/index.js +2 -1
  121. package/package.json +3 -3
  122. package/src/stories/f/v2/Checkbox.stories.jsx +102 -0
  123. package/src/stories/f/v2/ChoicesInput.stories.jsx +139 -0
  124. package/src/stories/f/v2/EditorInput.stories.jsx +81 -0
  125. package/src/stories/f/v2/LinkInput.stories.jsx +93 -0
  126. package/src/stories/f/v2/QueryChoices.stories.jsx +144 -0
  127. package/src/stories/f/v2/QueryCombobox.stories.jsx +301 -0
  128. package/src/stories/f/v2/QuerySelect.stories.jsx +150 -0
  129. package/src/stories/f/v2/RatingsInput.stories.jsx +77 -0
  130. package/src/stories/f/v2/SelectInput.stories.jsx +95 -0
  131. package/src/stories/f/v2/TextInput.stories.jsx +120 -0
  132. package/src/stories/f/v2/TextareaInput.stories.jsx +107 -0
  133. package/src/stories/f/v2/__generated__/FormInputAllTaskStatusesQuery.graphql.js +122 -0
  134. package/src/stories/f/v2/__generated__/FormInputAllTeamsQuery.graphql.js +139 -0
  135. package/src/stories/f/v2/__generated__/QueryChoicesAllTaskStatusesQuery.graphql.js +122 -0
  136. package/src/stories/f/v2/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
  137. package/src/stories/f/v2/__generated__/QuerySelectAllTaskStatusesQuery.graphql.js +122 -0
  138. package/src/ui/a/TextSteps/TextSteps.jsx +4 -4
  139. package/src/ui/a/TextSteps/styles.scss +1 -1
  140. package/src/ui/f/FormInput/FormInput.jsx +57 -12
  141. package/src/ui/f/common/V2/Description/Description.jsx +94 -0
  142. package/src/ui/f/common/V2/Description/index.js +2 -0
  143. package/src/ui/f/common/V2/Description/styles.scss +10 -0
  144. package/src/ui/f/common/V2/Label/Label.jsx +102 -0
  145. package/src/ui/f/common/V2/Label/index.js +2 -0
  146. package/src/ui/f/common/V2/Label/styles.scss +9 -0
  147. package/src/ui/f/common/V2/index.js +2 -0
  148. package/src/ui/f/common/index.js +1 -0
  149. package/src/ui/f/fields/V2/Checkbox/Checkbox.jsx +146 -0
  150. package/src/ui/f/fields/V2/Checkbox/index.js +2 -0
  151. package/src/ui/f/fields/V2/Checkbox/styles.scss +16 -0
  152. package/src/ui/f/fields/V2/ChoicesInput/ChoicesInput.jsx +183 -0
  153. package/src/ui/f/fields/V2/ChoicesInput/common/Choice/Choice.jsx +125 -0
  154. package/src/ui/f/fields/V2/ChoicesInput/common/Choice/index.js +2 -0
  155. package/src/ui/f/fields/V2/ChoicesInput/common/index.js +1 -0
  156. package/src/ui/f/fields/V2/ChoicesInput/index.js +2 -0
  157. package/src/ui/f/fields/V2/ChoicesInput/styles.scss +79 -0
  158. package/src/ui/f/fields/V2/EditorInput/EditorInput.jsx +244 -0
  159. package/src/ui/f/fields/V2/EditorInput/common/Toolbar.jsx +356 -0
  160. package/src/ui/f/fields/V2/EditorInput/common/TreeViewPlugin.jsx +16 -0
  161. package/src/ui/f/fields/V2/EditorInput/common/index.jsx +2 -0
  162. package/src/ui/f/fields/V2/EditorInput/index.js +2 -0
  163. package/src/ui/f/fields/V2/EditorInput/styles.scss +149 -0
  164. package/src/ui/f/fields/V2/LinkInput/LinkInput.jsx +187 -0
  165. package/src/ui/f/fields/V2/LinkInput/index.js +2 -0
  166. package/src/ui/f/fields/V2/LinkInput/styles.scss +90 -0
  167. package/src/ui/f/fields/V2/QueryChoices/QueryChoices.jsx +153 -0
  168. package/src/ui/f/fields/V2/QueryChoices/index.js +2 -0
  169. package/src/ui/f/fields/V2/QueryCombobox/QueryCombobox.jsx +254 -0
  170. package/src/ui/f/fields/V2/QueryCombobox/common/Combobox/Combobox.jsx +276 -0
  171. package/src/ui/f/fields/V2/QueryCombobox/common/Combobox/index.js +2 -0
  172. package/src/ui/f/fields/V2/QueryCombobox/common/Menu/Menu.jsx +103 -0
  173. package/src/ui/f/fields/V2/QueryCombobox/common/Menu/index.js +2 -0
  174. package/src/ui/f/fields/V2/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +362 -0
  175. package/src/ui/f/fields/V2/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  176. package/src/ui/f/fields/V2/QueryCombobox/common/index.js +3 -0
  177. package/src/ui/f/fields/V2/QueryCombobox/index.js +2 -0
  178. package/src/ui/f/fields/V2/QueryCombobox/styles.scss +127 -0
  179. package/src/ui/f/fields/V2/QuerySelect/QuerySelect.jsx +220 -0
  180. package/src/ui/f/fields/V2/QuerySelect/index.js +2 -0
  181. package/src/ui/f/fields/V2/RatingsInput/RatingsInput.jsx +152 -0
  182. package/src/ui/f/fields/V2/RatingsInput/common/Rating/Rating.jsx +142 -0
  183. package/src/ui/f/fields/V2/RatingsInput/common/Rating/index.js +2 -0
  184. package/src/ui/f/fields/V2/RatingsInput/common/index.js +1 -0
  185. package/src/ui/f/fields/V2/RatingsInput/index.js +2 -0
  186. package/src/ui/f/fields/V2/RatingsInput/styles.scss +48 -0
  187. package/src/ui/f/fields/V2/SelectInput/SelectInput.jsx +187 -0
  188. package/src/ui/f/fields/V2/SelectInput/index.js +2 -0
  189. package/src/ui/f/fields/V2/SelectInput/styles.scss +87 -0
  190. package/src/ui/f/fields/V2/TextInput/TextInput.jsx +192 -0
  191. package/src/ui/f/fields/V2/TextInput/index.js +2 -0
  192. package/src/ui/f/fields/V2/TextInput/styles.scss +78 -0
  193. package/src/ui/f/fields/V2/TextareaInput/TextareaInput.jsx +180 -0
  194. package/src/ui/f/fields/V2/TextareaInput/index.js +2 -0
  195. package/src/ui/f/fields/V2/TextareaInput/styles.scss +53 -0
  196. package/src/ui/f/fields/V2/index.js +11 -0
  197. package/src/ui/f/fields/index.js +1 -0
  198. package/tests/__snapshots__/Storyshots.test.js.snap +5910 -1
@@ -0,0 +1,93 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+ import { Formik, Form } from 'formik'
4
+
5
+ import {
6
+ LinkInputV2,
7
+ FormDebugger,
8
+ } from 'ui'
9
+
10
+ export default {
11
+ title :'f/fields/V2/LinkInputV2',
12
+ component :LinkInputV2,
13
+ subcomponents:{
14
+ // Item:TextInput.Item
15
+ },
16
+ decorators:[
17
+ (storyfn) => (
18
+ <Formik
19
+ initialValues={{ email: '', name: '', company: '' }}
20
+ >
21
+ <Form>
22
+
23
+ { storyfn() }
24
+ </Form>
25
+ </Formik>
26
+ ),
27
+ ],
28
+ argTypes:{
29
+ // backgroundColor:{ control: 'color' },
30
+ placeholder :{ control: 'text' },
31
+ autoComplete:{ control: 'select', options: ['off', 'on'] },
32
+ disabled :{ control: 'boolean' },
33
+ name :{ control: 'text' },
34
+ label :{ control: 'text' },
35
+ labelColor :{ control: 'text' },
36
+ optional :{ control: 'boolean' },
37
+ symbol :{ control: 'text' },
38
+ },
39
+ }
40
+
41
+ // eslint-disable-next-line react/prop-types
42
+ const Template = (args) => (
43
+ <div
44
+ style={{
45
+ display :'flex',
46
+ flexDirection:'column',
47
+ gap :'1rem',
48
+ }}
49
+ >
50
+ <LinkInputV2 {...args} />
51
+ <FormDebugger />
52
+ </div>
53
+ )
54
+
55
+ export const Base = Template.bind({})
56
+ Base.args = {
57
+ name :'link',
58
+ label:'Spreadsheet Link',
59
+ }
60
+
61
+ export const Optional = Template.bind({})
62
+ Optional.args = {
63
+ ...Base.args,
64
+ optional:true,
65
+ }
66
+
67
+ const validate = (value) => {
68
+ let errorMessage = ''
69
+ const isValid = value.length > 3
70
+
71
+ if (!isValid) {
72
+ errorMessage = 'Value should be greater than 3 characters'
73
+ }
74
+ return errorMessage
75
+ }
76
+
77
+ export const WithValidation = Template.bind({})
78
+ WithValidation.args = {
79
+ ...Base.args,
80
+ validate,
81
+ }
82
+
83
+ export const WithPlaceholder = Template.bind({})
84
+ WithPlaceholder.args = {
85
+ ...Base.args,
86
+ placeholder:'Email address',
87
+ }
88
+
89
+ export const WithDisabled = Template.bind({})
90
+ WithDisabled.args = {
91
+ ...Base.args,
92
+ disabled:true,
93
+ }
@@ -0,0 +1,144 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { QueryChoicesV2, FormDebugger } from 'ui'
5
+
6
+ import { Formik, Form } from 'formik'
7
+
8
+ import {
9
+ RelayEnvironmentProvider,
10
+ mockRelayOperation,
11
+ environment,
12
+ } from '../../utils/relay'
13
+
14
+ import generateNodeId from '../../utils/generateNodeId'
15
+
16
+ export default {
17
+ title :'f/fields/V2/QueryChoicesV2',
18
+ component :QueryChoicesV2,
19
+ subcomponents:{
20
+ // Item:QueryChoicesV2.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: 'color' },
32
+ labelColor:{ control: 'color' },
33
+ multiple :{ control: 'boolean' },
34
+ isLoading :{ control: 'boolean' },
35
+ optional :{ control: 'boolean' },
36
+ },
37
+ }
38
+
39
+ const statuses = [
40
+ 'Backlog',
41
+ 'In Review',
42
+ 'In Progress',
43
+ 'Requested',
44
+ 'Blocked',
45
+ 'Completed',
46
+ ]
47
+
48
+ const allTaskStatusesMockData = {
49
+ PageInfo() {
50
+ return {
51
+ hasNextPage :true,
52
+ hasPreviousPage:true,
53
+ }
54
+ },
55
+ TaskStatusNodeConnection:() => ({
56
+ pageInfo:{
57
+ hasNextPage :true,
58
+ hasPreviousPage:true,
59
+ },
60
+
61
+ edges:statuses.map((status) => ({
62
+ node:{
63
+ id:generateNodeId('TaskStatusNode'),
64
+ status,
65
+ },
66
+ })),
67
+ }),
68
+ }
69
+
70
+ const FETCH_ALL_TASK_STATUSES = graphql`
71
+ query QueryChoicesAllTaskStatusesQuery {
72
+ allTaskStatuses {
73
+ edges {
74
+ node {
75
+ id
76
+ status
77
+ }
78
+ }
79
+ }
80
+ }
81
+ `
82
+
83
+ // eslint-disable-next-line react/prop-types
84
+ const Template = ({ isLoading, defaultFormikState, ...args }) => {
85
+ if (isLoading) {
86
+ setTimeout(() => {
87
+ mockRelayOperation(allTaskStatusesMockData)
88
+ environment.mock.queuePendingOperation(
89
+ FETCH_ALL_TASK_STATUSES,
90
+ {},
91
+ )
92
+ }, 500)
93
+ } else {
94
+ mockRelayOperation(allTaskStatusesMockData)
95
+ environment.mock.queuePendingOperation(
96
+ FETCH_ALL_TASK_STATUSES,
97
+ {},
98
+ )
99
+ }
100
+
101
+ const Content = () => (
102
+ <div
103
+ style={{
104
+ display :'flex',
105
+ flexDirection:'column',
106
+ gap :'1rem',
107
+ }}
108
+ >
109
+ <QueryChoicesV2
110
+ name="status"
111
+ label="Select Status"
112
+ query={{
113
+ graphql :FETCH_ALL_TASK_STATUSES,
114
+ accessor:'allTaskStatuses',
115
+ }}
116
+ optionsKeyMap={{
117
+ value :'id',
118
+ getLabel:(node) => node.status,
119
+ }}
120
+ {...args}
121
+ />
122
+ <FormDebugger />
123
+ </div>
124
+ )
125
+
126
+ const initialValues = defaultFormikState ?? { status: '' }
127
+
128
+ return (
129
+ <Formik
130
+ initialValues={initialValues}
131
+ >
132
+ <Form>
133
+ <Content />
134
+ </Form>
135
+ </Formik>
136
+ )
137
+ }
138
+
139
+ export const Base = Template.bind({})
140
+
141
+ export const Optional = Template.bind({})
142
+ Optional.args = {
143
+ optional:true,
144
+ }
@@ -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
+ }