@pareto-engineering/design-system 2.0.0-alpha.42 → 2.0.0-alpha.45

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 (90) hide show
  1. package/.env.scripts.example +4 -0
  2. package/.eslintrc.js +25 -1
  3. package/babel.config.js +1 -0
  4. package/dist/cjs/a/Popover/styles.scss +9 -19
  5. package/dist/cjs/f/FormInput/FormInput.js +5 -2
  6. package/dist/cjs/f/FormInput/styles.scss +11 -0
  7. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +207 -0
  8. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +181 -0
  9. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/index.js +15 -0
  10. package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +103 -0
  11. package/dist/cjs/f/fields/QueryCombobox/common/Menu/index.js +15 -0
  12. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +229 -0
  13. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/index.js +15 -0
  14. package/dist/cjs/f/fields/QueryCombobox/common/index.js +21 -0
  15. package/dist/cjs/f/fields/QueryCombobox/index.js +15 -0
  16. package/dist/cjs/f/fields/QueryCombobox/styles.scss +71 -0
  17. package/dist/cjs/f/fields/SelectInput/SelectInput.js +0 -1
  18. package/dist/cjs/f/fields/SelectInput/styles.scss +8 -6
  19. package/dist/cjs/f/fields/index.js +9 -1
  20. package/dist/cjs/index.js +13 -0
  21. package/dist/cjs/test/QueryLoader/QueryLoader.js +41 -0
  22. package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
  23. package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +49 -0
  24. package/dist/cjs/test/QueryLoader/common/PreloadedTestData/index.js +15 -0
  25. package/dist/cjs/test/QueryLoader/common/index.js +13 -0
  26. package/dist/cjs/test/QueryLoader/index.js +15 -0
  27. package/dist/cjs/test/QueryLoader/styles.scss +9 -0
  28. package/dist/cjs/test/index.js +13 -0
  29. package/dist/es/a/Popover/styles.scss +9 -19
  30. package/dist/es/f/FormInput/FormInput.js +4 -1
  31. package/dist/es/f/FormInput/styles.scss +11 -0
  32. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +184 -0
  33. package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +161 -0
  34. package/dist/es/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
  35. package/dist/es/f/fields/QueryCombobox/common/Menu/Menu.js +77 -0
  36. package/dist/es/f/fields/QueryCombobox/common/Menu/index.js +2 -0
  37. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +202 -0
  38. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  39. package/dist/es/f/fields/QueryCombobox/common/index.js +2 -0
  40. package/dist/es/f/fields/QueryCombobox/index.js +2 -0
  41. package/dist/es/f/fields/QueryCombobox/styles.scss +71 -0
  42. package/dist/es/f/fields/SelectInput/SelectInput.js +0 -1
  43. package/dist/es/f/fields/SelectInput/styles.scss +8 -6
  44. package/dist/es/f/fields/index.js +2 -1
  45. package/dist/es/index.js +2 -1
  46. package/dist/es/test/QueryLoader/QueryLoader.js +29 -0
  47. package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
  48. package/dist/es/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +31 -0
  49. package/dist/es/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
  50. package/dist/es/test/QueryLoader/common/index.js +1 -0
  51. package/dist/es/test/QueryLoader/index.js +2 -0
  52. package/dist/es/test/QueryLoader/styles.scss +9 -0
  53. package/dist/es/test/index.js +1 -0
  54. package/package.json +16 -3
  55. package/relay.config.js +12 -0
  56. package/schema.graphql +4075 -0
  57. package/scripts/fetchSchema.js +74 -0
  58. package/src/__snapshots__/Storyshots.test.js.snap +168 -8
  59. package/src/stories/f/QueryCombobox.stories.jsx +220 -0
  60. package/src/stories/f/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
  61. package/src/stories/test/QueryLoader.stories.jsx +36 -0
  62. package/src/stories/utils/generateNodeId.js +12 -0
  63. package/src/stories/utils/relay/EnvironmentProvider.jsx +14 -0
  64. package/src/stories/utils/relay/environment.js +5 -0
  65. package/src/stories/utils/relay/index.js +4 -0
  66. package/src/stories/utils/relay/mockRelayOperation.js +14 -0
  67. package/src/stories/utils/relay/mockResolvers.js +299 -0
  68. package/src/stories/utils/testData.js +63 -0
  69. package/src/ui/a/Popover/styles.scss +9 -19
  70. package/src/ui/f/FormInput/FormInput.jsx +5 -1
  71. package/src/ui/f/FormInput/styles.scss +11 -0
  72. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +200 -0
  73. package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +198 -0
  74. package/src/ui/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
  75. package/src/ui/f/fields/QueryCombobox/common/Menu/Menu.jsx +103 -0
  76. package/src/ui/f/fields/QueryCombobox/common/Menu/index.js +2 -0
  77. package/src/ui/f/fields/QueryCombobox/common/index.js +2 -0
  78. package/src/ui/f/fields/QueryCombobox/index.js +2 -0
  79. package/src/ui/f/fields/QueryCombobox/styles.scss +71 -0
  80. package/src/ui/f/fields/SelectInput/SelectInput.jsx +1 -1
  81. package/src/ui/f/fields/SelectInput/styles.scss +8 -6
  82. package/src/ui/f/fields/index.js +1 -0
  83. package/src/ui/index.js +1 -0
  84. package/src/ui/test/QueryLoader/QueryLoader.jsx +41 -0
  85. package/src/ui/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +68 -0
  86. package/src/ui/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.jsx +51 -0
  87. package/src/ui/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
  88. package/src/ui/test/QueryLoader/common/index.js +1 -0
  89. package/src/ui/test/QueryLoader/index.js +2 -0
  90. package/src/ui/test/index.js +1 -0
@@ -0,0 +1,12 @@
1
+ /* eslint-disable no-bitwise */
2
+ /* eslint-disable no-mixed-operators */
3
+ const uuidv4 = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11)
4
+ .replace(
5
+ /[018]/g,
6
+ (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4)
7
+ .toString(16),
8
+ )
9
+
10
+ const generateNodeId = (objectNode) => btoa(`${objectNode}:${uuidv4()}`)
11
+
12
+ export default generateNodeId
@@ -0,0 +1,14 @@
1
+ import React from 'react'
2
+ import { RelayEnvironmentProvider } from 'react-relay/hooks'
3
+
4
+ import environment from './environment'
5
+
6
+ const RelayEnvProvider = (props) => (
7
+ <RelayEnvironmentProvider
8
+ environment={environment}
9
+ // history={history}
10
+ {...props}
11
+ />
12
+ )
13
+
14
+ export default RelayEnvProvider
@@ -0,0 +1,5 @@
1
+ import { createMockEnvironment } from 'relay-test-utils'
2
+
3
+ const environment = createMockEnvironment()
4
+
5
+ export default environment
@@ -0,0 +1,4 @@
1
+ export { default as RelayEnvironmentProvider } from './EnvironmentProvider'
2
+ export { default as environment } from './environment'
3
+ export { default as mockResolvers } from './mockResolvers'
4
+ export { default as mockRelayOperation } from './mockRelayOperation'
@@ -0,0 +1,14 @@
1
+ import { MockPayloadGenerator } from 'relay-test-utils'
2
+ import relayEnvironment from './environment'
3
+ import mockResolvers from './mockResolvers'
4
+
5
+ function mockRelayOperation(overrideMockResolvers = null) {
6
+ relayEnvironment.mock.queueOperationResolver(
7
+ (operation) => MockPayloadGenerator.generate(
8
+ operation,
9
+ overrideMockResolvers || mockResolvers,
10
+ ),
11
+ )
12
+ }
13
+
14
+ export default mockRelayOperation
@@ -0,0 +1,299 @@
1
+ const customMockResolvers = {
2
+ String :() => 'Test string',
3
+ UserNode:() => ({
4
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
5
+ firstName :'Collins',
6
+ isSuperuser:false,
7
+ }),
8
+ TaskNode:() => ({
9
+ id :'VGFza05vZGU6MDAwZmQ4N2UtYjNlNS00NWE5LTg5ZjEtNWI0ZDViNWE2NTlj',
10
+ title :'Task1',
11
+ status:{
12
+ id :'VGFza1N0YXR1c05vZGU6OTczYmM4NTgtMzA0NC00NWNiLTg2MDQtYTRhM2JmNjFmZjEx',
13
+ status:'In Review',
14
+ },
15
+ requester:{
16
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
17
+ firstName:'Collins',
18
+ },
19
+ userTeam:{
20
+ id :'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
21
+ name:'Team 1',
22
+ },
23
+ manager:{
24
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
25
+ firstName:'manager',
26
+ },
27
+ createdAt :'2021-09-23',
28
+ dueDate :'2021-10-30',
29
+ requestDate:'2020-01-01',
30
+ description:'First task',
31
+ }),
32
+ TeamNode:() => ({
33
+ id :'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
34
+ name :'Team 1',
35
+ credits :20.12,
36
+ billingEmail:'team1@hellopareto.com',
37
+ hourlyRate :20,
38
+ partner :{
39
+ firstName:'Test1',
40
+ lastName :'assd',
41
+ },
42
+
43
+ }),
44
+ GroupNode:() => ({
45
+ id :'VGFza05vZGU6MDAwZmQ4N2UtYjNlNS00NWE5LTg5ZjEtNWI0ZDViNWE2NTlk',
46
+ name:'admin',
47
+ }),
48
+ TaskNodeConnection:() => ({
49
+ pageInfo:{
50
+ hasNextPage :true,
51
+ hasPreviousPage:true,
52
+ },
53
+ edges:[
54
+ {
55
+ node:{
56
+ id :'VGFza05vZGU6MDAwZmQ4N2UtYjNlNS00NWE5LTg5ZjEtNWI0ZDViNWE2NTlj',
57
+ title :'Task1',
58
+ status:{
59
+ id :'VGFza1N0YXR1c05vZGU6OTczYmM4NTgtMzA0NC00NWNiLTg2MDQtYTRhM2JmNjFmZjEx',
60
+ status:'In Review',
61
+ },
62
+ requester:{
63
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
64
+ firstName:'Collins',
65
+ },
66
+ userTeam:{
67
+ id :'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
68
+ name:'Team 1',
69
+ },
70
+ manager:{
71
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
72
+ firstName:'manager',
73
+ },
74
+ createdAt :'2021-09-23',
75
+ dueDate :'2021-10-30',
76
+ requestDate:'2020-01-01',
77
+ description:'First task',
78
+ },
79
+ },
80
+ {
81
+ node:{
82
+ id :'VGFza05vZGU6MDAwZmQ4N2UtYjNlNS00NWE5LTg5ZjEtNWI0ZDViNWE2NTlj',
83
+ title :'Task2',
84
+ status:{
85
+ id :'VGFza1N0YXR1c05vZGU6OTczYmM4NTgtMzA0NC00NWNiLTg2MDQtYTRhM2JmNjFmZjEx',
86
+ status:'In Review',
87
+ },
88
+ requester:{
89
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
90
+ firstName:'Collins',
91
+ },
92
+ userTeam:{
93
+ id :'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
94
+ name:'Team 2',
95
+ },
96
+ manager:{
97
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
98
+ firstName:'manager',
99
+ },
100
+ createdAt :'2021-09-23',
101
+ dueDate :'2021-10-30',
102
+ requestDate:'2020-01-01',
103
+ description:'Second task',
104
+ },
105
+ },
106
+ ],
107
+ }),
108
+ UserNodeConnection:(allArgs) => {
109
+ const { args :{ first, offset } } = allArgs
110
+
111
+ const edges = [
112
+ {
113
+ node:{
114
+ id :'VXNlck5vZGU6OTZkZTA3M2MtNTE3Ni00ZjgyLTg4OWMtMzIwYmVmYzU5ODFj',
115
+ firstName:'Collins',
116
+ },
117
+ },
118
+ {
119
+ node:{
120
+ id :'VXNlck5vZGU6MDEyN2E1NmItYjAxOS00NmQxLTg2NTEtYWEzOGIxZTUwNTA5',
121
+ firstName:'Amritha',
122
+ },
123
+ },
124
+ {
125
+ node:{
126
+ id :'VXNlck5vZGU6YzcwYWIxMDItZWE2Yy00ZWNhLTk0M2ItOTA2OWQwN2RiMDQ0',
127
+ firstName:'Marsya',
128
+ },
129
+ },
130
+ {
131
+ node:{
132
+ id :'VXNlck5vZGU6OTUyNjg1NWYtZTg3NC00ZTlkLWFlZTgtZDZjODc3NDNlNTRh',
133
+ firstName:'James',
134
+ },
135
+ },
136
+ {
137
+ node:{
138
+ id :'VXNlck5vZGU6OTFmOTE4NTYtNjg0Yi00ODhhLWE0YzktZGU5ZDQ5YmJjM2Mz',
139
+ firstName:'Adrian',
140
+ },
141
+ },
142
+ {
143
+ node:{
144
+ id :'VXNlck5vZGU6OTNkZGU3NGEtYTA2Yi00MDMzLWIwMDAtMTFkZDY0N2Y3OWE4',
145
+ firstName:'Melissa',
146
+ },
147
+ },
148
+ {
149
+ node:{
150
+ id :'VXNlck5vZGU6MjgyYTk1MjctMDI4OS00MDlhLWFjNTktYWJkNTFkODAyMjFj',
151
+ firstName:'Beto',
152
+ },
153
+ },
154
+ {
155
+ node:{
156
+ id :'VXNlck5vZGU6YmIxYzI5YmEtYTk0OS00M2I3LWIxMWEtZDQxMjM5ZWI0ZWI2',
157
+ firstName:'Romie',
158
+ },
159
+ },
160
+ {
161
+ node:{
162
+ id :'VXNlck5vZGU6ZjZhNzBiZTgtY2FkMC00NzNjLWEyODUtNDdkMGVmYjQxYTRl',
163
+ firstName:'Miguel',
164
+ },
165
+ },
166
+ {
167
+ node:{
168
+ id :'VXNlck5vZGU6Y2JlOGM4ZTYtY2Q2Zi00M2RlLWI4YmQtODU3YWRhZjYyMzVj',
169
+ firstName:'Phoebe',
170
+ },
171
+ },
172
+ {
173
+ node:{
174
+ id :'VXNlck5vZGU6NDA5MWM1MDUtYjY1MC00M2Y1LTg3NTEtMDc1NTBkMzJhYTcy',
175
+ firstName:'Kim',
176
+ },
177
+ },
178
+ {
179
+ node:{
180
+ id :'VXNlck5vZGU6ZjE0MGUxYTItM2I4My00NmY1LWIzMDQtYmFiOGZjMTc5ZmU4',
181
+ firstName:'Liz',
182
+ },
183
+ },
184
+ {
185
+ node:{
186
+ id :'VXNlck5vZGU6ZGYyOGE5MDYtM2NhMS00NTVmLWIzZmUtNjY5YWFkZTNiZjRk',
187
+ firstName:'Deepanshu',
188
+ },
189
+ },
190
+ {
191
+ node:{
192
+ id :'VXNlck5vZGU6MjBhMDBkYjgtZDExNi00YzAyLWEyOTUtYWM5MzIwMjUwMWU3',
193
+ firstName:'Jennica',
194
+ },
195
+ },
196
+ {
197
+ node:{
198
+ id :'VXNlck5vZGU6MjczNDllYjMtYzNmYi00ZmVkLWE1N2YtNTFjZGJlODI0MWU2',
199
+ firstName:'Michelle',
200
+ },
201
+ },
202
+ ]
203
+
204
+ return ({
205
+ pageInfo:{
206
+ hasNextPage :true,
207
+ hasPreviousPage:true,
208
+ },
209
+ edges:edges.slice(offset, offset + first),
210
+ })
211
+ },
212
+ WorkHoursNodeConnection:() => ({
213
+ pageInfo:{
214
+ hasNextPage :true,
215
+ hasPreviousPage:true,
216
+ },
217
+ edges:[
218
+ {
219
+ node:{
220
+ id :'V29ya0hvdXJzTm9kZTplYWJlYmEyNC0wNTlmLTQxMjEtODIzYi0yYmU2YzMxMmZlNzA=',
221
+ associate:{
222
+ firstName:'Des',
223
+ lastName :'assd',
224
+ },
225
+ timeSpent :15,
226
+ log :'asd',
227
+ paidOut :false,
228
+ sentInvoice:true,
229
+ createdAt :'2021-09-05T17:08:49.000-0430',
230
+ startedAt :'2021-09-05T17:08:49.000-0430',
231
+ },
232
+ },
233
+ {
234
+ node:{
235
+ id :'V29ya0hvdXJzTm9kZTplYmZiZTllZS04NWNkLTRhNDktYTZhMi0zNmNhMTU0M2EwMDU=',
236
+ associate:{
237
+ firstName:'Ella',
238
+ lastName :'asdasd',
239
+ },
240
+ timeSpent :25,
241
+ log :'aasdasdsd',
242
+ paidOut :true,
243
+ sentInvoice:false,
244
+ createdAt :'2021-09-15T17:08:49.000-0430',
245
+ startedAt :'2021-09-15T17:08:49.000-0430',
246
+ },
247
+ },
248
+ ],
249
+ }),
250
+ TeamNodeConnection:() => ({
251
+ pageInfo:{
252
+ hasNextPage :true,
253
+ hasPreviousPage:true,
254
+ },
255
+ edges:[
256
+ {
257
+ node:{
258
+ id :'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
259
+ name :'Team 1',
260
+ credits :20.12,
261
+ billingEmail:'team1@hellopareto.com',
262
+ hourlyRate :20,
263
+ partner :{
264
+ firstName:'Test1',
265
+ lastName :'assd',
266
+ },
267
+ },
268
+ },
269
+ {
270
+ node:{
271
+ id :'VGVhbU5vZGU6MDA0N2U4MzktODY0Zi00N2U5LTg3ZjgtZGUwMmM2Yzg1YWJm',
272
+ name :'Team 2',
273
+ credits :20.12,
274
+ billingEmail:'team2@hellopareto.com',
275
+ hourlyRate :20,
276
+ partner :{
277
+ firstName:'Test2',
278
+ lastName :'assd',
279
+ },
280
+ },
281
+ },
282
+ {
283
+ node:{
284
+ id :'VGVhbU5vZGU6MDExMmEyZmEtYzE0YS00MGRhLThiNWQtMDMzNTkyNDQ3ZDI2',
285
+ name :'Team 3',
286
+ credits :20.12,
287
+ billingEmail:'team3@hellopareto.com',
288
+ hourlyRate :20,
289
+ partner :{
290
+ firstName:'Test3',
291
+ lastName :'assd',
292
+ },
293
+ },
294
+ },
295
+ ],
296
+ }),
297
+ }
298
+
299
+ export default customMockResolvers
@@ -0,0 +1,63 @@
1
+ export const fruits = [
2
+ 'Apple',
3
+ 'Apricot',
4
+ 'Avocado',
5
+ 'Banana',
6
+ 'Bilberry',
7
+ 'Blackberry',
8
+ 'Blackcurrant',
9
+ 'Blueberry',
10
+ 'Currant',
11
+ 'Cherry',
12
+ 'Cherimoya',
13
+ 'Clementine',
14
+ 'Date',
15
+ 'Damson',
16
+ 'Durian',
17
+ 'Eggplant',
18
+ 'Elderberry',
19
+ 'Feijoa',
20
+ 'Gooseberry',
21
+ 'Grape',
22
+ 'Grapefruit',
23
+ 'Guava',
24
+ 'Huckleberry',
25
+ 'Jackfruit',
26
+ 'Jambul',
27
+ 'Kiwi fruit',
28
+ 'Kumquat',
29
+ 'Legume',
30
+ 'Lemon',
31
+ 'Lime',
32
+ 'Lychee',
33
+ 'Mango',
34
+ 'Mangostine',
35
+ 'Melon',
36
+ 'Cantaloupe',
37
+ 'Honeydew melon',
38
+ 'Rock melon',
39
+ 'Nectarine',
40
+ 'Orange',
41
+ 'Peach',
42
+ 'Pear',
43
+ 'Williams pear or Bartlett pear',
44
+ 'Pitaya',
45
+ 'Physalis',
46
+ 'Plum/prune (dried plum)',
47
+ 'Pineapple',
48
+ 'Pomegranate',
49
+ 'Raisin',
50
+ 'Raspberry',
51
+ 'Western raspberry (blackcap)',
52
+ 'Rambutan',
53
+ 'Redcurrant',
54
+ 'Salal berry',
55
+ 'Satsuma',
56
+ 'Star fruit',
57
+ 'Strawberry',
58
+ 'Tangerine',
59
+ 'Tomato',
60
+ 'Ugli fruit',
61
+ 'Watermelon',
62
+ 'Ziziphus mauritiana',
63
+ ]
@@ -1,24 +1,17 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  @use "@pareto-engineering/bem";
3
3
 
4
- $default-padding: 1em;
5
- $default-margin: 1em;
6
4
  $default-border: var(--theme-border-style) var(--metadata);
7
5
 
8
- .#{bem.$base}.popover{
9
- position: absolute;
10
- z-index: 1;
11
- background-color: var(--x);
12
- padding: $default-padding;
13
- border: $default-border;
6
+ .#{bem.$base}.popover {
7
+ position: absolute;
8
+ z-index: 1;
9
+ background-color: var(--x);
10
+ border: $default-border;
14
11
 
15
- &:not(.open) {
16
- display: none;
17
- }
18
-
19
- > *:not(:last-child) {
20
- margin-bottom: $default-margin / 2;
21
- }
12
+ &:not(.open) {
13
+ display: none;
14
+ }
22
15
 
23
16
  &.bottom {
24
17
  top: 100%;
@@ -37,7 +30,4 @@ $default-border: var(--theme-border-style) var(--metadata);
37
30
  bottom: 100%;
38
31
  top: auto;
39
32
  }
40
- }
41
-
42
-
43
-
33
+ }
@@ -1,7 +1,7 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  import * as React from 'react'
3
3
 
4
- import { memo } from 'react'
4
+ import { memo, useLayoutEffect } from 'react'
5
5
 
6
6
  import PropTypes from 'prop-types'
7
7
 
@@ -28,6 +28,10 @@ const FormInput = ({
28
28
  disabled,
29
29
  ...otherProps
30
30
  }) => {
31
+ useLayoutEffect(() => {
32
+ import('./styles.scss')
33
+ }, [])
34
+
31
35
  const newClassName = [
32
36
  className,
33
37
  componentClassName,
@@ -0,0 +1,11 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-margin: 1em;
6
+
7
+ .#{bem.$base}.form-input {
8
+ &+& {
9
+ margin-top: $default-margin;
10
+ }
11
+ }
@@ -0,0 +1,200 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { useState, useLayoutEffect } from 'react'
5
+
6
+ import { useField } from 'formik'
7
+
8
+ import { useRelayEnvironment, fetchQuery } from 'react-relay'
9
+
10
+ import PropTypes from 'prop-types'
11
+
12
+ // Local Definitions
13
+
14
+ import { Combobox } from './common'
15
+
16
+ /**
17
+ * This is the component description.
18
+ */
19
+ const QueryCombobox = ({
20
+ query,
21
+ // multiple,
22
+ name,
23
+ label,
24
+ color,
25
+ description,
26
+ disabled,
27
+ debounceMs,
28
+ graphQlNode,
29
+ searchVariable,
30
+ extraVariables,
31
+ optionsKeyMap,
32
+ // ...otherProps
33
+ }) => {
34
+ useLayoutEffect(() => {
35
+ import('./styles.scss')
36
+ }, [])
37
+
38
+ const [, meta, helpers] = useField(name)
39
+
40
+ const { setValue, setError } = helpers
41
+
42
+ const { error, value } = meta
43
+
44
+ const environment = useRelayEnvironment()
45
+
46
+ const [isFetching, setIsFetching] = useState(false)
47
+
48
+ const [options, setOptions] = useState([])
49
+
50
+ const getOptions = (inputValue) => {
51
+ if (isFetching) return
52
+
53
+ let variables = { [searchVariable]: inputValue }
54
+
55
+ if (extraVariables) {
56
+ variables = {
57
+ ...variables,
58
+ ...extraVariables,
59
+ }
60
+ }
61
+
62
+ fetchQuery(
63
+ environment,
64
+ query,
65
+ variables,
66
+ )
67
+ .subscribe({
68
+ start:() => {
69
+ setIsFetching(true)
70
+ },
71
+ complete:() => {
72
+ setIsFetching(false)
73
+ },
74
+ error:(fetchError) => {
75
+ setIsFetching(false)
76
+ if (setError)setError(fetchError.message)
77
+ },
78
+ next:(data) => {
79
+ setOptions(data[graphQlNode].edges.map(({ node }) => ({
80
+ value:node[optionsKeyMap.value],
81
+ label:node[optionsKeyMap.label],
82
+ })))
83
+ },
84
+ })
85
+ }
86
+
87
+ const comboboxProps = {
88
+ options,
89
+ getOptions,
90
+ debounceMs,
91
+ disabled,
92
+ name,
93
+ label,
94
+ description,
95
+ setValue,
96
+ error,
97
+ value,
98
+ color,
99
+ }
100
+
101
+ const Input = Combobox
102
+
103
+ return <Input {...comboboxProps} />
104
+ }
105
+
106
+ QueryCombobox.propTypes = {
107
+ /**
108
+ * The HTML id for this element
109
+ */
110
+ id:PropTypes.string,
111
+
112
+ /**
113
+ * The HTML class names for this element
114
+ */
115
+ className:PropTypes.string,
116
+
117
+ /**
118
+ * The React-written, css properties for this element.
119
+ */
120
+ style:PropTypes.objectOf(PropTypes.string),
121
+
122
+ /**
123
+ * The name of the custom select input
124
+ */
125
+ name:PropTypes.string,
126
+
127
+ /**
128
+ * The label of the custom select input
129
+ */
130
+ label:PropTypes.string,
131
+
132
+ /**
133
+ * The custom select input description
134
+ */
135
+ description:PropTypes.string,
136
+
137
+ /**
138
+ * Whether the input should be disabled
139
+ */
140
+ disabled:PropTypes.bool,
141
+
142
+ /**
143
+ * The base color of the custom select input
144
+ */
145
+ color:PropTypes.string,
146
+
147
+ /**
148
+ * The debounce time in milliseconds
149
+ */
150
+ debounceMs:PropTypes.number,
151
+
152
+ /**
153
+ * The query to fetch the options
154
+ */
155
+ query:PropTypes.oneOfType([
156
+ PropTypes.string,
157
+ PropTypes.object,
158
+ ]).isRequired,
159
+
160
+ /**
161
+ * The extra variables required to be used in the query.
162
+ */
163
+ extraVariables:PropTypes.objectOf(PropTypes.string),
164
+
165
+ /**
166
+ * The select option keys to be used to map the data to the select options.
167
+ * i.e `{ value: 'id', label: 'name' }`
168
+ */
169
+ optionsKeyMap:PropTypes.shape({
170
+ value:PropTypes.string.isRequired,
171
+ label:PropTypes.string.isRequired,
172
+ }),
173
+
174
+ /**
175
+ * Whether to allow multiple items selection
176
+ */
177
+ multiple:PropTypes.bool,
178
+
179
+ /**
180
+ * The graphql node to be used to destructure the fetched data
181
+ */
182
+ graphQlNode:PropTypes.string.isRequired,
183
+
184
+ /**
185
+ * The variable to be used to search the data
186
+ */
187
+ searchVariable:PropTypes.string,
188
+ }
189
+
190
+ QueryCombobox.defaultProps = {
191
+ optionsKeyMap:{
192
+ value:'id',
193
+ label:'name',
194
+ },
195
+ multiple :false,
196
+ color :'background2',
197
+ searchVariable:'search',
198
+ }
199
+
200
+ export default QueryCombobox