@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.
- package/.env.scripts.example +4 -0
- package/.eslintrc.js +25 -1
- package/babel.config.js +1 -0
- package/dist/cjs/a/Popover/styles.scss +9 -19
- package/dist/cjs/f/FormInput/FormInput.js +5 -2
- package/dist/cjs/f/FormInput/styles.scss +11 -0
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +207 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +181 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +103 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Menu/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +229 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/index.js +21 -0
- package/dist/cjs/f/fields/QueryCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +71 -0
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +0 -1
- package/dist/cjs/f/fields/SelectInput/styles.scss +8 -6
- package/dist/cjs/f/fields/index.js +9 -1
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/test/QueryLoader/QueryLoader.js +41 -0
- package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
- package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +49 -0
- package/dist/cjs/test/QueryLoader/common/PreloadedTestData/index.js +15 -0
- package/dist/cjs/test/QueryLoader/common/index.js +13 -0
- package/dist/cjs/test/QueryLoader/index.js +15 -0
- package/dist/cjs/test/QueryLoader/styles.scss +9 -0
- package/dist/cjs/test/index.js +13 -0
- package/dist/es/a/Popover/styles.scss +9 -19
- package/dist/es/f/FormInput/FormInput.js +4 -1
- package/dist/es/f/FormInput/styles.scss +11 -0
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +184 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +161 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/Menu/Menu.js +77 -0
- package/dist/es/f/fields/QueryCombobox/common/Menu/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +202 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/styles.scss +71 -0
- package/dist/es/f/fields/SelectInput/SelectInput.js +0 -1
- package/dist/es/f/fields/SelectInput/styles.scss +8 -6
- package/dist/es/f/fields/index.js +2 -1
- package/dist/es/index.js +2 -1
- package/dist/es/test/QueryLoader/QueryLoader.js +29 -0
- package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
- package/dist/es/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +31 -0
- package/dist/es/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
- package/dist/es/test/QueryLoader/common/index.js +1 -0
- package/dist/es/test/QueryLoader/index.js +2 -0
- package/dist/es/test/QueryLoader/styles.scss +9 -0
- package/dist/es/test/index.js +1 -0
- package/package.json +16 -3
- package/relay.config.js +12 -0
- package/schema.graphql +4075 -0
- package/scripts/fetchSchema.js +74 -0
- package/src/__snapshots__/Storyshots.test.js.snap +168 -8
- package/src/stories/f/QueryCombobox.stories.jsx +220 -0
- package/src/stories/f/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
- package/src/stories/test/QueryLoader.stories.jsx +36 -0
- package/src/stories/utils/generateNodeId.js +12 -0
- package/src/stories/utils/relay/EnvironmentProvider.jsx +14 -0
- package/src/stories/utils/relay/environment.js +5 -0
- package/src/stories/utils/relay/index.js +4 -0
- package/src/stories/utils/relay/mockRelayOperation.js +14 -0
- package/src/stories/utils/relay/mockResolvers.js +299 -0
- package/src/stories/utils/testData.js +63 -0
- package/src/ui/a/Popover/styles.scss +9 -19
- package/src/ui/f/FormInput/FormInput.jsx +5 -1
- package/src/ui/f/FormInput/styles.scss +11 -0
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +200 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +198 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/Menu/Menu.jsx +103 -0
- package/src/ui/f/fields/QueryCombobox/common/Menu/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/styles.scss +71 -0
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +1 -1
- package/src/ui/f/fields/SelectInput/styles.scss +8 -6
- package/src/ui/f/fields/index.js +1 -0
- package/src/ui/index.js +1 -0
- package/src/ui/test/QueryLoader/QueryLoader.jsx +41 -0
- package/src/ui/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +68 -0
- package/src/ui/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.jsx +51 -0
- package/src/ui/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
- package/src/ui/test/QueryLoader/common/index.js +1 -0
- package/src/ui/test/QueryLoader/index.js +2 -0
- package/src/ui/test/index.js +1 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const https = require('https')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
|
|
4
|
+
require('dotenv').config({ path: '.env.scripts' })
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
GITHUB_BACKEND_ORG,
|
|
8
|
+
GITHUB_BACKEND_REPO,
|
|
9
|
+
GITHUB_READONLY_PAT,
|
|
10
|
+
DEBUG,
|
|
11
|
+
} = process.env
|
|
12
|
+
|
|
13
|
+
const isDebug = DEBUG === 'True'
|
|
14
|
+
|
|
15
|
+
const host = 'api.github.com'
|
|
16
|
+
const contentEndpoint = `/repos/${GITHUB_BACKEND_ORG}/${GITHUB_BACKEND_REPO}/contents/schema.graphql`
|
|
17
|
+
const authToken = GITHUB_READONLY_PAT
|
|
18
|
+
|
|
19
|
+
const defaultBranch = 'development'
|
|
20
|
+
const indexOfRefArg = process.argv.findIndex((arg) => arg === '--ref')
|
|
21
|
+
const selectedRef = (indexOfRefArg > -1) ? process.argv[indexOfRefArg + 1] : defaultBranch
|
|
22
|
+
|
|
23
|
+
const filename = 'schema.graphql'
|
|
24
|
+
|
|
25
|
+
const processContent = (data) => {
|
|
26
|
+
if (data.content) {
|
|
27
|
+
if (isDebug) {
|
|
28
|
+
console.log(Buffer.from(data.content, 'base64').toString('utf-8'))
|
|
29
|
+
}
|
|
30
|
+
fs.writeFile(filename, Buffer.from(data.content, 'base64'), 'utf8', (err) => {
|
|
31
|
+
if (err) {
|
|
32
|
+
console.log(err)
|
|
33
|
+
} else {
|
|
34
|
+
console.log(`${filename} successfully saved`)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
} else {
|
|
38
|
+
console.error('Error in downloading the schema.')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function performRequest(success) {
|
|
43
|
+
console.log(`Fetching schema from ref=${selectedRef}`)
|
|
44
|
+
const options = {
|
|
45
|
+
host,
|
|
46
|
+
path :`${contentEndpoint}?ref=${selectedRef}`,
|
|
47
|
+
method :'GET',
|
|
48
|
+
headers:{
|
|
49
|
+
Authorization:`token ${authToken}`,
|
|
50
|
+
'User-Agent' :'Nodejs CI script',
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const req = https.request(options, (res) => {
|
|
55
|
+
res.setEncoding('utf-8')
|
|
56
|
+
|
|
57
|
+
let responseString = ''
|
|
58
|
+
|
|
59
|
+
res.on('data', (data) => {
|
|
60
|
+
responseString += data
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
res.on('end', () => {
|
|
64
|
+
// console.log(responseString)
|
|
65
|
+
const responseObject = JSON.parse(responseString)
|
|
66
|
+
success(responseObject)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// req.write()
|
|
71
|
+
req.end()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
performRequest(processContent)
|
|
@@ -2663,7 +2663,7 @@ exports[`Storyshots a/Timestamp Distance Format 1`] = `
|
|
|
2663
2663
|
className="base timestamp"
|
|
2664
2664
|
onClick={[Function]}
|
|
2665
2665
|
>
|
|
2666
|
-
in
|
|
2666
|
+
in 4 months
|
|
2667
2667
|
</p>
|
|
2668
2668
|
`;
|
|
2669
2669
|
|
|
@@ -10361,7 +10361,7 @@ exports[`Storyshots f/FormInput Base 1`] = `
|
|
|
10361
10361
|
className="base select-input form-input y-background2"
|
|
10362
10362
|
>
|
|
10363
10363
|
<label
|
|
10364
|
-
className="base label
|
|
10364
|
+
className="base label x-main2"
|
|
10365
10365
|
htmlFor="food"
|
|
10366
10366
|
>
|
|
10367
10367
|
What do you want for dinner ?
|
|
@@ -10550,7 +10550,7 @@ exports[`Storyshots f/FormInput Disabled Form Input 1`] = `
|
|
|
10550
10550
|
className="base select-input form-input y-background2"
|
|
10551
10551
|
>
|
|
10552
10552
|
<label
|
|
10553
|
-
className="base label
|
|
10553
|
+
className="base label x-main2"
|
|
10554
10554
|
htmlFor="food"
|
|
10555
10555
|
>
|
|
10556
10556
|
What do you want for dinner ?
|
|
@@ -11198,6 +11198,164 @@ exports[`Storyshots f/fields/ChoicesInput Multiple With Grid 1`] = `
|
|
|
11198
11198
|
</form>
|
|
11199
11199
|
`;
|
|
11200
11200
|
|
|
11201
|
+
exports[`Storyshots f/fields/QueryCombobox Single Select 1`] = `
|
|
11202
|
+
<form
|
|
11203
|
+
action="#"
|
|
11204
|
+
onReset={[Function]}
|
|
11205
|
+
onSubmit={[Function]}
|
|
11206
|
+
>
|
|
11207
|
+
<div
|
|
11208
|
+
className="base combobox y-background2"
|
|
11209
|
+
>
|
|
11210
|
+
<label
|
|
11211
|
+
className="base label x-main2"
|
|
11212
|
+
htmlFor="team"
|
|
11213
|
+
id="downshift-0-label"
|
|
11214
|
+
>
|
|
11215
|
+
Search for a team
|
|
11216
|
+
</label>
|
|
11217
|
+
<div
|
|
11218
|
+
aria-expanded={false}
|
|
11219
|
+
aria-haspopup="listbox"
|
|
11220
|
+
aria-owns="downshift-0-menu"
|
|
11221
|
+
className="input-wrapper"
|
|
11222
|
+
role="combobox"
|
|
11223
|
+
>
|
|
11224
|
+
<input
|
|
11225
|
+
aria-autocomplete="list"
|
|
11226
|
+
aria-controls="downshift-0-menu"
|
|
11227
|
+
aria-labelledby="downshift-0-label"
|
|
11228
|
+
autoComplete="off"
|
|
11229
|
+
className="input"
|
|
11230
|
+
id="downshift-0-input"
|
|
11231
|
+
onBlur={[Function]}
|
|
11232
|
+
onChange={[Function]}
|
|
11233
|
+
onKeyDown={[Function]}
|
|
11234
|
+
value=""
|
|
11235
|
+
/>
|
|
11236
|
+
</div>
|
|
11237
|
+
<div
|
|
11238
|
+
className="base popover x-background1 bottom left"
|
|
11239
|
+
>
|
|
11240
|
+
<ul
|
|
11241
|
+
aria-labelledby="downshift-0-label"
|
|
11242
|
+
className="base menu"
|
|
11243
|
+
id="downshift-0-menu"
|
|
11244
|
+
onMouseLeave={[Function]}
|
|
11245
|
+
role="listbox"
|
|
11246
|
+
/>
|
|
11247
|
+
</div>
|
|
11248
|
+
</div>
|
|
11249
|
+
<div
|
|
11250
|
+
style={
|
|
11251
|
+
Object {
|
|
11252
|
+
"alignItems": "flex-end",
|
|
11253
|
+
"display": "flex",
|
|
11254
|
+
"flexDirection": "column",
|
|
11255
|
+
}
|
|
11256
|
+
}
|
|
11257
|
+
>
|
|
11258
|
+
<div
|
|
11259
|
+
className="debugger"
|
|
11260
|
+
>
|
|
11261
|
+
<button
|
|
11262
|
+
className="base button x-main2"
|
|
11263
|
+
onClick={[Function]}
|
|
11264
|
+
type="button"
|
|
11265
|
+
>
|
|
11266
|
+
Open FormDebugger
|
|
11267
|
+
</button>
|
|
11268
|
+
</div>
|
|
11269
|
+
<button
|
|
11270
|
+
className="base button x-main1"
|
|
11271
|
+
onClick={[Function]}
|
|
11272
|
+
type="button"
|
|
11273
|
+
>
|
|
11274
|
+
Replace initial value
|
|
11275
|
+
</button>
|
|
11276
|
+
</div>
|
|
11277
|
+
</form>
|
|
11278
|
+
`;
|
|
11279
|
+
|
|
11280
|
+
exports[`Storyshots f/fields/QueryCombobox Single Select With Default Formik State 1`] = `
|
|
11281
|
+
<form
|
|
11282
|
+
action="#"
|
|
11283
|
+
onReset={[Function]}
|
|
11284
|
+
onSubmit={[Function]}
|
|
11285
|
+
>
|
|
11286
|
+
<div
|
|
11287
|
+
className="base combobox y-background2"
|
|
11288
|
+
>
|
|
11289
|
+
<label
|
|
11290
|
+
className="base label x-main2"
|
|
11291
|
+
htmlFor="team"
|
|
11292
|
+
id="downshift-1-label"
|
|
11293
|
+
>
|
|
11294
|
+
Search for a team
|
|
11295
|
+
</label>
|
|
11296
|
+
<div
|
|
11297
|
+
aria-expanded={false}
|
|
11298
|
+
aria-haspopup="listbox"
|
|
11299
|
+
aria-owns="downshift-1-menu"
|
|
11300
|
+
className="input-wrapper"
|
|
11301
|
+
role="combobox"
|
|
11302
|
+
>
|
|
11303
|
+
<input
|
|
11304
|
+
aria-autocomplete="list"
|
|
11305
|
+
aria-controls="downshift-1-menu"
|
|
11306
|
+
aria-labelledby="downshift-1-label"
|
|
11307
|
+
autoComplete="off"
|
|
11308
|
+
className="input"
|
|
11309
|
+
id="downshift-1-input"
|
|
11310
|
+
onBlur={[Function]}
|
|
11311
|
+
onChange={[Function]}
|
|
11312
|
+
onKeyDown={[Function]}
|
|
11313
|
+
value="Apple"
|
|
11314
|
+
/>
|
|
11315
|
+
</div>
|
|
11316
|
+
<div
|
|
11317
|
+
className="base popover x-background1 bottom left"
|
|
11318
|
+
>
|
|
11319
|
+
<ul
|
|
11320
|
+
aria-labelledby="downshift-1-label"
|
|
11321
|
+
className="base menu"
|
|
11322
|
+
id="downshift-1-menu"
|
|
11323
|
+
onMouseLeave={[Function]}
|
|
11324
|
+
role="listbox"
|
|
11325
|
+
/>
|
|
11326
|
+
</div>
|
|
11327
|
+
</div>
|
|
11328
|
+
<div
|
|
11329
|
+
style={
|
|
11330
|
+
Object {
|
|
11331
|
+
"alignItems": "flex-end",
|
|
11332
|
+
"display": "flex",
|
|
11333
|
+
"flexDirection": "column",
|
|
11334
|
+
}
|
|
11335
|
+
}
|
|
11336
|
+
>
|
|
11337
|
+
<div
|
|
11338
|
+
className="debugger"
|
|
11339
|
+
>
|
|
11340
|
+
<button
|
|
11341
|
+
className="base button x-main2"
|
|
11342
|
+
onClick={[Function]}
|
|
11343
|
+
type="button"
|
|
11344
|
+
>
|
|
11345
|
+
Open FormDebugger
|
|
11346
|
+
</button>
|
|
11347
|
+
</div>
|
|
11348
|
+
<button
|
|
11349
|
+
className="base button x-main1"
|
|
11350
|
+
onClick={[Function]}
|
|
11351
|
+
type="button"
|
|
11352
|
+
>
|
|
11353
|
+
Replace initial value
|
|
11354
|
+
</button>
|
|
11355
|
+
</div>
|
|
11356
|
+
</form>
|
|
11357
|
+
`;
|
|
11358
|
+
|
|
11201
11359
|
exports[`Storyshots f/fields/RatingsInput Base 1`] = `
|
|
11202
11360
|
<form
|
|
11203
11361
|
action="#"
|
|
@@ -11995,7 +12153,7 @@ exports[`Storyshots f/fields/SelectInput Base 1`] = `
|
|
|
11995
12153
|
className="base select-input y-background2"
|
|
11996
12154
|
>
|
|
11997
12155
|
<label
|
|
11998
|
-
className="base label
|
|
12156
|
+
className="base label x-main2"
|
|
11999
12157
|
htmlFor="workType"
|
|
12000
12158
|
>
|
|
12001
12159
|
Work Type
|
|
@@ -12059,7 +12217,7 @@ exports[`Storyshots f/fields/SelectInput Disabled Select Input 1`] = `
|
|
|
12059
12217
|
className="base select-input y-background2"
|
|
12060
12218
|
>
|
|
12061
12219
|
<label
|
|
12062
|
-
className="base label
|
|
12220
|
+
className="base label x-main2"
|
|
12063
12221
|
htmlFor="workType"
|
|
12064
12222
|
>
|
|
12065
12223
|
Work Type
|
|
@@ -12135,7 +12293,7 @@ exports[`Storyshots f/fields/SelectInput Objects 1`] = `
|
|
|
12135
12293
|
className="base select-input y-background2"
|
|
12136
12294
|
>
|
|
12137
12295
|
<label
|
|
12138
|
-
className="base label
|
|
12296
|
+
className="base label x-main2"
|
|
12139
12297
|
htmlFor="workType"
|
|
12140
12298
|
>
|
|
12141
12299
|
Work Type
|
|
@@ -12193,7 +12351,7 @@ exports[`Storyshots f/fields/SelectInput Required Select 1`] = `
|
|
|
12193
12351
|
className="base select-input y-background2"
|
|
12194
12352
|
>
|
|
12195
12353
|
<label
|
|
12196
|
-
className="base label
|
|
12354
|
+
className="base label x-main2"
|
|
12197
12355
|
htmlFor="activity"
|
|
12198
12356
|
>
|
|
12199
12357
|
Activity Type
|
|
@@ -12251,7 +12409,7 @@ exports[`Storyshots f/fields/SelectInput String And Objects 1`] = `
|
|
|
12251
12409
|
className="base select-input y-background2"
|
|
12252
12410
|
>
|
|
12253
12411
|
<label
|
|
12254
|
-
className="base label
|
|
12412
|
+
className="base label x-main2"
|
|
12255
12413
|
htmlFor="workType"
|
|
12256
12414
|
>
|
|
12257
12415
|
Work Type
|
|
@@ -12674,3 +12832,5 @@ exports[`Storyshots f/fields/TextareaInput Validation 1`] = `
|
|
|
12674
12832
|
exports[`Storyshots r/SwitchRouteMap Base 1`] = `"This component does not need a visual test."`;
|
|
12675
12833
|
|
|
12676
12834
|
exports[`Storyshots r/common/PrivateRoute Base 1`] = `"This component does not need a visual test."`;
|
|
12835
|
+
|
|
12836
|
+
exports[`Storyshots test/QueryLoader Base 1`] = `null`;
|
|
@@ -0,0 +1,220 @@
|
|
|
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, QueryCombobox } 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/QueryCombobox',
|
|
20
|
+
component :QueryCombobox,
|
|
21
|
+
subcomponents:{
|
|
22
|
+
// Item:QueryCombobox.Item
|
|
23
|
+
},
|
|
24
|
+
decorators:[
|
|
25
|
+
(storyfn) => (
|
|
26
|
+
<RelayEnvironmentProvider>
|
|
27
|
+
{ storyfn() }
|
|
28
|
+
</RelayEnvironmentProvider>
|
|
29
|
+
),
|
|
30
|
+
],
|
|
31
|
+
argTypes:{
|
|
32
|
+
backgroundColor:{ control: 'color' },
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const allTeamsMockData = {
|
|
37
|
+
PageInfo() {
|
|
38
|
+
return {
|
|
39
|
+
hasNextPage :true,
|
|
40
|
+
hasPreviousPage:true,
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
TeamNodeConnection:(args) => {
|
|
44
|
+
const edges = fruits.map((fruit) => ({
|
|
45
|
+
node:{
|
|
46
|
+
id :generateNodeId('TeamNode'),
|
|
47
|
+
name:fruit,
|
|
48
|
+
},
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line camelcase
|
|
52
|
+
const { name_Icontains } = args?.args || {}
|
|
53
|
+
|
|
54
|
+
return ({
|
|
55
|
+
pageInfo:{
|
|
56
|
+
hasNextPage :true,
|
|
57
|
+
hasPreviousPage:true,
|
|
58
|
+
},
|
|
59
|
+
// eslint-disable-next-line camelcase
|
|
60
|
+
edges:name_Icontains?.trim()
|
|
61
|
+
? edges.filter(({ node }) => node.name
|
|
62
|
+
.toLowerCase()
|
|
63
|
+
.includes(name_Icontains.toLowerCase()))
|
|
64
|
+
: [],
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const FETCH_TEAMS_QUERY = graphql`
|
|
70
|
+
query QueryComboboxAllTeamsQuery($name_Icontains: String) {
|
|
71
|
+
allTeams(name_Icontains: $name_Icontains) {
|
|
72
|
+
edges {
|
|
73
|
+
node {
|
|
74
|
+
id
|
|
75
|
+
name
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`
|
|
81
|
+
|
|
82
|
+
// eslint-disable-next-line react/prop-types
|
|
83
|
+
const ResolvedTemplate = ({ multiple, defaultFormikState = {} }) => {
|
|
84
|
+
mockRelayOperation(allTeamsMockData)
|
|
85
|
+
mockRelayOperation(allTeamsMockData)
|
|
86
|
+
mockRelayOperation(allTeamsMockData)
|
|
87
|
+
|
|
88
|
+
const Content = () => {
|
|
89
|
+
const name = multiple ? 'teams' : 'team'
|
|
90
|
+
|
|
91
|
+
const [, , helpers] = useField(name)
|
|
92
|
+
|
|
93
|
+
const { setValue } = helpers
|
|
94
|
+
|
|
95
|
+
const updateFormikState = () => {
|
|
96
|
+
setValue({
|
|
97
|
+
value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNk',
|
|
98
|
+
label:'Kafagoho',
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<>
|
|
104
|
+
<QueryCombobox
|
|
105
|
+
query={FETCH_TEAMS_QUERY}
|
|
106
|
+
label="Search for a team"
|
|
107
|
+
optionsKeyMap={{
|
|
108
|
+
value:'id',
|
|
109
|
+
label:'name',
|
|
110
|
+
}}
|
|
111
|
+
name={name}
|
|
112
|
+
multiple={multiple}
|
|
113
|
+
graphQlNode="allTeams"
|
|
114
|
+
searchVariable="name_Icontains"
|
|
115
|
+
/>
|
|
116
|
+
<div
|
|
117
|
+
style={{
|
|
118
|
+
display :'flex',
|
|
119
|
+
alignItems :'flex-end',
|
|
120
|
+
flexDirection:'column',
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<FormDebugger />
|
|
124
|
+
<Button
|
|
125
|
+
onClick={updateFormikState}
|
|
126
|
+
>
|
|
127
|
+
{multiple ? 'Add more initial values' : 'Replace initial value'}
|
|
128
|
+
</Button>
|
|
129
|
+
</div>
|
|
130
|
+
</>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Formik
|
|
136
|
+
initialValues={defaultFormikState}
|
|
137
|
+
>
|
|
138
|
+
<Form>
|
|
139
|
+
<Content />
|
|
140
|
+
</Form>
|
|
141
|
+
</Formik>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const SingleSelect = ResolvedTemplate.bind({})
|
|
146
|
+
SingleSelect.args = {
|
|
147
|
+
multiple:false,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const SingleSelectWithDefaultFormikState = ResolvedTemplate.bind({})
|
|
151
|
+
SingleSelectWithDefaultFormikState.args = {
|
|
152
|
+
multiple :false,
|
|
153
|
+
defaultFormikState:{
|
|
154
|
+
team:{
|
|
155
|
+
value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
|
|
156
|
+
label:'Apple',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// eslint-disable-next-line react/prop-types
|
|
162
|
+
// const RejectedTemplate = ({ multiple }) => {
|
|
163
|
+
// const Content = () => {
|
|
164
|
+
// environment.mock.queuePendingOperation(
|
|
165
|
+
// FETCH_TEAMS_QUERY,
|
|
166
|
+
// { name_Icontains: 'a' },
|
|
167
|
+
// )
|
|
168
|
+
|
|
169
|
+
// environment.mock.rejectMostRecentOperation('An error has occured while fetching the teams')
|
|
170
|
+
|
|
171
|
+
// const name = multiple ? 'teams' : 'team'
|
|
172
|
+
|
|
173
|
+
// const [, meta, helpers] = useField(name)
|
|
174
|
+
|
|
175
|
+
// const { setValue, setError } = helpers
|
|
176
|
+
|
|
177
|
+
// const { error } = meta
|
|
178
|
+
|
|
179
|
+
// return (
|
|
180
|
+
// <>
|
|
181
|
+
// <QueryCombobox
|
|
182
|
+
// query={FETCH_TEAMS_QUERY}
|
|
183
|
+
// label="Search for a team"
|
|
184
|
+
// optionsKeyMap={{
|
|
185
|
+
// value:'id',
|
|
186
|
+
// label:'name',
|
|
187
|
+
// }}
|
|
188
|
+
// error={error}
|
|
189
|
+
// setValue={setValue}
|
|
190
|
+
// setError={setError}
|
|
191
|
+
// name={name}
|
|
192
|
+
// multiple={multiple}
|
|
193
|
+
// graphQlNode="allTeams"
|
|
194
|
+
// searchVariable="name_Icontains"
|
|
195
|
+
// />
|
|
196
|
+
// <FormDebugger />
|
|
197
|
+
// </>
|
|
198
|
+
// )
|
|
199
|
+
// }
|
|
200
|
+
|
|
201
|
+
// return (
|
|
202
|
+
// <Formik
|
|
203
|
+
// initialValues={{ team: '' }}
|
|
204
|
+
// >
|
|
205
|
+
// <Form>
|
|
206
|
+
// <Content />
|
|
207
|
+
// </Form>
|
|
208
|
+
// </Formik>
|
|
209
|
+
// )
|
|
210
|
+
// }
|
|
211
|
+
|
|
212
|
+
// export const SingleSelectWithError = RejectedTemplate.bind({})
|
|
213
|
+
// SingleSelectWithError.args = {
|
|
214
|
+
// multiple:false,
|
|
215
|
+
// }
|
|
216
|
+
|
|
217
|
+
// export const MultipleSelectWithError = RejectedTemplate.bind({})
|
|
218
|
+
// MultipleSelectWithError.args = {
|
|
219
|
+
// multiple:true,
|
|
220
|
+
// }
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flow
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
/*::
|
|
10
|
+
import type { ConcreteRequest } from 'relay-runtime';
|
|
11
|
+
export type QueryComboboxAllTeamsQueryVariables = {|
|
|
12
|
+
name_Icontains?: ?string
|
|
13
|
+
|};
|
|
14
|
+
export type QueryComboboxAllTeamsQueryResponse = {|
|
|
15
|
+
+allTeams: ?{|
|
|
16
|
+
+edges: $ReadOnlyArray<?{|
|
|
17
|
+
+node: ?{|
|
|
18
|
+
+id: string,
|
|
19
|
+
+name: string,
|
|
20
|
+
|}
|
|
21
|
+
|}>
|
|
22
|
+
|}
|
|
23
|
+
|};
|
|
24
|
+
export type QueryComboboxAllTeamsQuery = {|
|
|
25
|
+
variables: QueryComboboxAllTeamsQueryVariables,
|
|
26
|
+
response: QueryComboboxAllTeamsQueryResponse,
|
|
27
|
+
|};
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
query QueryComboboxAllTeamsQuery(
|
|
33
|
+
$name_Icontains: String
|
|
34
|
+
) {
|
|
35
|
+
allTeams(name_Icontains: $name_Icontains) {
|
|
36
|
+
edges {
|
|
37
|
+
node {
|
|
38
|
+
id
|
|
39
|
+
name
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
const node/*: ConcreteRequest*/ = (function(){
|
|
47
|
+
var v0 = [
|
|
48
|
+
{
|
|
49
|
+
"defaultValue": null,
|
|
50
|
+
"kind": "LocalArgument",
|
|
51
|
+
"name": "name_Icontains"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
v1 = [
|
|
55
|
+
{
|
|
56
|
+
"alias": null,
|
|
57
|
+
"args": [
|
|
58
|
+
{
|
|
59
|
+
"kind": "Variable",
|
|
60
|
+
"name": "name_Icontains",
|
|
61
|
+
"variableName": "name_Icontains"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"concreteType": "TeamNodeConnection",
|
|
65
|
+
"kind": "LinkedField",
|
|
66
|
+
"name": "allTeams",
|
|
67
|
+
"plural": false,
|
|
68
|
+
"selections": [
|
|
69
|
+
{
|
|
70
|
+
"alias": null,
|
|
71
|
+
"args": null,
|
|
72
|
+
"concreteType": "TeamNodeEdge",
|
|
73
|
+
"kind": "LinkedField",
|
|
74
|
+
"name": "edges",
|
|
75
|
+
"plural": true,
|
|
76
|
+
"selections": [
|
|
77
|
+
{
|
|
78
|
+
"alias": null,
|
|
79
|
+
"args": null,
|
|
80
|
+
"concreteType": "TeamNode",
|
|
81
|
+
"kind": "LinkedField",
|
|
82
|
+
"name": "node",
|
|
83
|
+
"plural": false,
|
|
84
|
+
"selections": [
|
|
85
|
+
{
|
|
86
|
+
"alias": null,
|
|
87
|
+
"args": null,
|
|
88
|
+
"kind": "ScalarField",
|
|
89
|
+
"name": "id",
|
|
90
|
+
"storageKey": null
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"alias": null,
|
|
94
|
+
"args": null,
|
|
95
|
+
"kind": "ScalarField",
|
|
96
|
+
"name": "name",
|
|
97
|
+
"storageKey": null
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"storageKey": null
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"storageKey": null
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"storageKey": null
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
return {
|
|
110
|
+
"fragment": {
|
|
111
|
+
"argumentDefinitions": (v0/*: any*/),
|
|
112
|
+
"kind": "Fragment",
|
|
113
|
+
"metadata": null,
|
|
114
|
+
"name": "QueryComboboxAllTeamsQuery",
|
|
115
|
+
"selections": (v1/*: any*/),
|
|
116
|
+
"type": "Query",
|
|
117
|
+
"abstractKey": null
|
|
118
|
+
},
|
|
119
|
+
"kind": "Request",
|
|
120
|
+
"operation": {
|
|
121
|
+
"argumentDefinitions": (v0/*: any*/),
|
|
122
|
+
"kind": "Operation",
|
|
123
|
+
"name": "QueryComboboxAllTeamsQuery",
|
|
124
|
+
"selections": (v1/*: any*/)
|
|
125
|
+
},
|
|
126
|
+
"params": {
|
|
127
|
+
"cacheID": "a507170c1616920d93ea7ceb061097d1",
|
|
128
|
+
"id": null,
|
|
129
|
+
"metadata": {},
|
|
130
|
+
"name": "QueryComboboxAllTeamsQuery",
|
|
131
|
+
"operationKind": "query",
|
|
132
|
+
"text": "query QueryComboboxAllTeamsQuery(\n $name_Icontains: String\n) {\n allTeams(name_Icontains: $name_Icontains) {\n edges {\n node {\n id\n name\n }\n }\n }\n}\n"
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
})();
|
|
136
|
+
// prettier-ignore
|
|
137
|
+
(node/*: any*/).hash = '243f007a2e8d0c359ad2976f1c68a472';
|
|
138
|
+
|
|
139
|
+
module.exports = node;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { QueryLoader } from 'ui'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
RelayEnvironmentProvider,
|
|
8
|
+
mockRelayOperation,
|
|
9
|
+
} from '../utils/relay'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title :'test/QueryLoader',
|
|
13
|
+
component :QueryLoader,
|
|
14
|
+
subcomponents:{
|
|
15
|
+
// Item:QueryLoader.Item
|
|
16
|
+
},
|
|
17
|
+
decorators:[
|
|
18
|
+
// storyfn => <div className="">{ storyfn() }</div>,
|
|
19
|
+
(storyfn) => (
|
|
20
|
+
<RelayEnvironmentProvider>
|
|
21
|
+
{ storyfn() }
|
|
22
|
+
</RelayEnvironmentProvider>
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
argTypes:{
|
|
26
|
+
backgroundColor:{ control: 'color' },
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Base = () => {
|
|
31
|
+
mockRelayOperation()
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<QueryLoader />
|
|
35
|
+
)
|
|
36
|
+
}
|