@pareto-engineering/design-system 2.0.0-alpha.45 → 2.0.0-alpha.48
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/dist/cjs/f/FormInput/FormInput.js +8 -1
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +29 -6
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +29 -5
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +101 -26
- package/dist/cjs/f/fields/QueryCombobox/common/index.js +9 -1
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +24 -5
- package/dist/es/f/FormInput/FormInput.js +9 -2
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +30 -7
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +30 -6
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +101 -27
- package/dist/es/f/fields/QueryCombobox/common/index.js +2 -1
- package/dist/es/f/fields/QueryCombobox/styles.scss +24 -5
- package/package.json +2 -2
- package/src/__snapshots__/Storyshots.test.js.snap +379 -14
- package/src/local.scss +3 -3
- package/src/stories/f/FormInput.stories.jsx +115 -0
- package/src/stories/f/QueryCombobox.stories.jsx +55 -8
- package/src/stories/f/__generated__/FormInputAllTeamsQuery.graphql.js +139 -0
- package/src/ui/f/FormInput/FormInput.jsx +11 -0
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +29 -6
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +27 -3
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +318 -0
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/index.js +1 -0
- package/src/ui/f/fields/QueryCombobox/styles.scss +24 -5
|
@@ -10637,6 +10637,161 @@ exports[`Storyshots f/FormInput Extensible Form Input 1`] = `
|
|
|
10637
10637
|
</form>
|
|
10638
10638
|
`;
|
|
10639
10639
|
|
|
10640
|
+
exports[`Storyshots f/FormInput With Query Combobox 1`] = `
|
|
10641
|
+
<form
|
|
10642
|
+
action="#"
|
|
10643
|
+
onReset={[Function]}
|
|
10644
|
+
onSubmit={[Function]}
|
|
10645
|
+
>
|
|
10646
|
+
<div
|
|
10647
|
+
className="base text-input form-input y-background2"
|
|
10648
|
+
>
|
|
10649
|
+
<label
|
|
10650
|
+
className="base label v50 mb-v x-main2"
|
|
10651
|
+
htmlFor="firstName"
|
|
10652
|
+
>
|
|
10653
|
+
What's your first name ?
|
|
10654
|
+
</label>
|
|
10655
|
+
<input
|
|
10656
|
+
className="input"
|
|
10657
|
+
disabled={false}
|
|
10658
|
+
id="firstName"
|
|
10659
|
+
name="firstName"
|
|
10660
|
+
onBlur={[Function]}
|
|
10661
|
+
onChange={[Function]}
|
|
10662
|
+
type="text"
|
|
10663
|
+
value="Test"
|
|
10664
|
+
/>
|
|
10665
|
+
</div>
|
|
10666
|
+
<div
|
|
10667
|
+
className="base choices-input form-input x-background2 y-main2"
|
|
10668
|
+
style={
|
|
10669
|
+
Object {
|
|
10670
|
+
"--grid-columns-desktop": 3,
|
|
10671
|
+
"--grid-columns-mobile": 2,
|
|
10672
|
+
}
|
|
10673
|
+
}
|
|
10674
|
+
>
|
|
10675
|
+
<p
|
|
10676
|
+
className="base label x-main2"
|
|
10677
|
+
>
|
|
10678
|
+
What are your favourite colors ?
|
|
10679
|
+
</p>
|
|
10680
|
+
<div
|
|
10681
|
+
className="choices"
|
|
10682
|
+
>
|
|
10683
|
+
<div
|
|
10684
|
+
className="base choice"
|
|
10685
|
+
>
|
|
10686
|
+
<input
|
|
10687
|
+
disabled={false}
|
|
10688
|
+
id="undefined-red"
|
|
10689
|
+
name="colors"
|
|
10690
|
+
onBlur={[Function]}
|
|
10691
|
+
onChange={[Function]}
|
|
10692
|
+
type="radio"
|
|
10693
|
+
value="red"
|
|
10694
|
+
/>
|
|
10695
|
+
<label
|
|
10696
|
+
htmlFor="undefined-red"
|
|
10697
|
+
>
|
|
10698
|
+
Color Red
|
|
10699
|
+
</label>
|
|
10700
|
+
</div>
|
|
10701
|
+
<div
|
|
10702
|
+
className="base choice"
|
|
10703
|
+
>
|
|
10704
|
+
<input
|
|
10705
|
+
disabled={false}
|
|
10706
|
+
id="undefined-blue"
|
|
10707
|
+
name="colors"
|
|
10708
|
+
onBlur={[Function]}
|
|
10709
|
+
onChange={[Function]}
|
|
10710
|
+
type="radio"
|
|
10711
|
+
value="blue"
|
|
10712
|
+
/>
|
|
10713
|
+
<label
|
|
10714
|
+
htmlFor="undefined-blue"
|
|
10715
|
+
>
|
|
10716
|
+
Color Blue
|
|
10717
|
+
</label>
|
|
10718
|
+
</div>
|
|
10719
|
+
<div
|
|
10720
|
+
className="base choice"
|
|
10721
|
+
>
|
|
10722
|
+
<input
|
|
10723
|
+
disabled={false}
|
|
10724
|
+
id="undefined-green"
|
|
10725
|
+
name="colors"
|
|
10726
|
+
onBlur={[Function]}
|
|
10727
|
+
onChange={[Function]}
|
|
10728
|
+
type="radio"
|
|
10729
|
+
value="green"
|
|
10730
|
+
/>
|
|
10731
|
+
<label
|
|
10732
|
+
htmlFor="undefined-green"
|
|
10733
|
+
>
|
|
10734
|
+
Color Green
|
|
10735
|
+
</label>
|
|
10736
|
+
</div>
|
|
10737
|
+
</div>
|
|
10738
|
+
</div>
|
|
10739
|
+
<div
|
|
10740
|
+
className="base combobox form-input y-background2"
|
|
10741
|
+
>
|
|
10742
|
+
<label
|
|
10743
|
+
className="base label x-main2"
|
|
10744
|
+
htmlFor="team"
|
|
10745
|
+
id="downshift-0-label"
|
|
10746
|
+
>
|
|
10747
|
+
Search for a team
|
|
10748
|
+
</label>
|
|
10749
|
+
<div
|
|
10750
|
+
aria-expanded={false}
|
|
10751
|
+
aria-haspopup="listbox"
|
|
10752
|
+
aria-owns="downshift-0-menu"
|
|
10753
|
+
className="input-wrapper"
|
|
10754
|
+
role="combobox"
|
|
10755
|
+
>
|
|
10756
|
+
<input
|
|
10757
|
+
aria-autocomplete="list"
|
|
10758
|
+
aria-controls="downshift-0-menu"
|
|
10759
|
+
aria-labelledby="downshift-0-label"
|
|
10760
|
+
autoComplete="off"
|
|
10761
|
+
className="input"
|
|
10762
|
+
id="downshift-0-input"
|
|
10763
|
+
onBlur={[Function]}
|
|
10764
|
+
onChange={[Function]}
|
|
10765
|
+
onKeyDown={[Function]}
|
|
10766
|
+
value=""
|
|
10767
|
+
/>
|
|
10768
|
+
</div>
|
|
10769
|
+
<div
|
|
10770
|
+
className="base popover x-background1 bottom left"
|
|
10771
|
+
>
|
|
10772
|
+
<ul
|
|
10773
|
+
aria-labelledby="downshift-0-label"
|
|
10774
|
+
className="base menu"
|
|
10775
|
+
id="downshift-0-menu"
|
|
10776
|
+
onMouseLeave={[Function]}
|
|
10777
|
+
role="listbox"
|
|
10778
|
+
/>
|
|
10779
|
+
</div>
|
|
10780
|
+
</div>
|
|
10781
|
+
<div
|
|
10782
|
+
className="debugger"
|
|
10783
|
+
>
|
|
10784
|
+
<button
|
|
10785
|
+
className="base button x-main2"
|
|
10786
|
+
onClick={[Function]}
|
|
10787
|
+
type="button"
|
|
10788
|
+
>
|
|
10789
|
+
Open FormDebugger
|
|
10790
|
+
</button>
|
|
10791
|
+
</div>
|
|
10792
|
+
</form>
|
|
10793
|
+
`;
|
|
10794
|
+
|
|
10640
10795
|
exports[`Storyshots f/common/Description Base 1`] = `
|
|
10641
10796
|
<div
|
|
10642
10797
|
className="base description x-metadata"
|
|
@@ -11198,38 +11353,39 @@ exports[`Storyshots f/fields/ChoicesInput Multiple With Grid 1`] = `
|
|
|
11198
11353
|
</form>
|
|
11199
11354
|
`;
|
|
11200
11355
|
|
|
11201
|
-
exports[`Storyshots f/fields/QueryCombobox
|
|
11356
|
+
exports[`Storyshots f/fields/QueryCombobox Multiple Select 1`] = `
|
|
11202
11357
|
<form
|
|
11203
11358
|
action="#"
|
|
11204
11359
|
onReset={[Function]}
|
|
11205
11360
|
onSubmit={[Function]}
|
|
11206
11361
|
>
|
|
11207
11362
|
<div
|
|
11208
|
-
className="base combobox y-background2"
|
|
11363
|
+
className="base multiple-combobox y-background2"
|
|
11209
11364
|
>
|
|
11210
11365
|
<label
|
|
11211
11366
|
className="base label x-main2"
|
|
11212
|
-
htmlFor="
|
|
11213
|
-
id="downshift-
|
|
11367
|
+
htmlFor="teams"
|
|
11368
|
+
id="downshift-3-label"
|
|
11214
11369
|
>
|
|
11215
11370
|
Search for a team
|
|
11216
11371
|
</label>
|
|
11217
11372
|
<div
|
|
11218
11373
|
aria-expanded={false}
|
|
11219
11374
|
aria-haspopup="listbox"
|
|
11220
|
-
aria-owns="downshift-
|
|
11375
|
+
aria-owns="downshift-3-menu"
|
|
11221
11376
|
className="input-wrapper"
|
|
11222
11377
|
role="combobox"
|
|
11223
11378
|
>
|
|
11224
11379
|
<input
|
|
11225
11380
|
aria-autocomplete="list"
|
|
11226
|
-
aria-controls="downshift-
|
|
11227
|
-
aria-labelledby="downshift-
|
|
11381
|
+
aria-controls="downshift-3-menu"
|
|
11382
|
+
aria-labelledby="downshift-3-label"
|
|
11228
11383
|
autoComplete="off"
|
|
11229
11384
|
className="input"
|
|
11230
|
-
id="downshift-
|
|
11385
|
+
id="downshift-3-input"
|
|
11231
11386
|
onBlur={[Function]}
|
|
11232
11387
|
onChange={[Function]}
|
|
11388
|
+
onClick={[Function]}
|
|
11233
11389
|
onKeyDown={[Function]}
|
|
11234
11390
|
value=""
|
|
11235
11391
|
/>
|
|
@@ -11238,9 +11394,9 @@ exports[`Storyshots f/fields/QueryCombobox Single Select 1`] = `
|
|
|
11238
11394
|
className="base popover x-background1 bottom left"
|
|
11239
11395
|
>
|
|
11240
11396
|
<ul
|
|
11241
|
-
aria-labelledby="downshift-
|
|
11397
|
+
aria-labelledby="downshift-3-label"
|
|
11242
11398
|
className="base menu"
|
|
11243
|
-
id="downshift-
|
|
11399
|
+
id="downshift-3-menu"
|
|
11244
11400
|
onMouseLeave={[Function]}
|
|
11245
11401
|
role="listbox"
|
|
11246
11402
|
/>
|
|
@@ -11271,13 +11427,143 @@ exports[`Storyshots f/fields/QueryCombobox Single Select 1`] = `
|
|
|
11271
11427
|
onClick={[Function]}
|
|
11272
11428
|
type="button"
|
|
11273
11429
|
>
|
|
11274
|
-
|
|
11430
|
+
Add formik values
|
|
11275
11431
|
</button>
|
|
11276
11432
|
</div>
|
|
11277
11433
|
</form>
|
|
11278
11434
|
`;
|
|
11279
11435
|
|
|
11280
|
-
exports[`Storyshots f/fields/QueryCombobox
|
|
11436
|
+
exports[`Storyshots f/fields/QueryCombobox Multiple Select With Default Formik State 1`] = `
|
|
11437
|
+
<form
|
|
11438
|
+
action="#"
|
|
11439
|
+
onReset={[Function]}
|
|
11440
|
+
onSubmit={[Function]}
|
|
11441
|
+
>
|
|
11442
|
+
<div
|
|
11443
|
+
className="base multiple-combobox y-background2"
|
|
11444
|
+
>
|
|
11445
|
+
<label
|
|
11446
|
+
className="base label x-main2"
|
|
11447
|
+
htmlFor="teams"
|
|
11448
|
+
id="downshift-4-label"
|
|
11449
|
+
>
|
|
11450
|
+
Search for a team
|
|
11451
|
+
</label>
|
|
11452
|
+
<div
|
|
11453
|
+
className="selected-items"
|
|
11454
|
+
>
|
|
11455
|
+
<div
|
|
11456
|
+
className="item"
|
|
11457
|
+
onClick={[Function]}
|
|
11458
|
+
onKeyDown={[Function]}
|
|
11459
|
+
tabIndex={-1}
|
|
11460
|
+
>
|
|
11461
|
+
<button
|
|
11462
|
+
className="base button x-background2 modifierCompact modifierSimple"
|
|
11463
|
+
onClick={[Function]}
|
|
11464
|
+
type="button"
|
|
11465
|
+
>
|
|
11466
|
+
<span
|
|
11467
|
+
className="v25 mr-v"
|
|
11468
|
+
>
|
|
11469
|
+
Apple
|
|
11470
|
+
</span>
|
|
11471
|
+
<span
|
|
11472
|
+
className="f-icons close"
|
|
11473
|
+
>
|
|
11474
|
+
Y
|
|
11475
|
+
</span>
|
|
11476
|
+
</button>
|
|
11477
|
+
</div>
|
|
11478
|
+
<div
|
|
11479
|
+
className="item"
|
|
11480
|
+
onClick={[Function]}
|
|
11481
|
+
onKeyDown={[Function]}
|
|
11482
|
+
tabIndex={-1}
|
|
11483
|
+
>
|
|
11484
|
+
<button
|
|
11485
|
+
className="base button x-background2 modifierCompact modifierSimple"
|
|
11486
|
+
onClick={[Function]}
|
|
11487
|
+
type="button"
|
|
11488
|
+
>
|
|
11489
|
+
<span
|
|
11490
|
+
className="v25 mr-v"
|
|
11491
|
+
>
|
|
11492
|
+
Pear
|
|
11493
|
+
</span>
|
|
11494
|
+
<span
|
|
11495
|
+
className="f-icons close"
|
|
11496
|
+
>
|
|
11497
|
+
Y
|
|
11498
|
+
</span>
|
|
11499
|
+
</button>
|
|
11500
|
+
</div>
|
|
11501
|
+
</div>
|
|
11502
|
+
<div
|
|
11503
|
+
aria-expanded={false}
|
|
11504
|
+
aria-haspopup="listbox"
|
|
11505
|
+
aria-owns="downshift-4-menu"
|
|
11506
|
+
className="input-wrapper"
|
|
11507
|
+
role="combobox"
|
|
11508
|
+
>
|
|
11509
|
+
<input
|
|
11510
|
+
aria-autocomplete="list"
|
|
11511
|
+
aria-controls="downshift-4-menu"
|
|
11512
|
+
aria-labelledby="downshift-4-label"
|
|
11513
|
+
autoComplete="off"
|
|
11514
|
+
className="input"
|
|
11515
|
+
id="downshift-4-input"
|
|
11516
|
+
onBlur={[Function]}
|
|
11517
|
+
onChange={[Function]}
|
|
11518
|
+
onClick={[Function]}
|
|
11519
|
+
onKeyDown={[Function]}
|
|
11520
|
+
value=""
|
|
11521
|
+
/>
|
|
11522
|
+
</div>
|
|
11523
|
+
<div
|
|
11524
|
+
className="base popover x-background1 bottom left"
|
|
11525
|
+
>
|
|
11526
|
+
<ul
|
|
11527
|
+
aria-labelledby="downshift-4-label"
|
|
11528
|
+
className="base menu"
|
|
11529
|
+
id="downshift-4-menu"
|
|
11530
|
+
onMouseLeave={[Function]}
|
|
11531
|
+
role="listbox"
|
|
11532
|
+
/>
|
|
11533
|
+
</div>
|
|
11534
|
+
</div>
|
|
11535
|
+
<div
|
|
11536
|
+
style={
|
|
11537
|
+
Object {
|
|
11538
|
+
"alignItems": "flex-end",
|
|
11539
|
+
"display": "flex",
|
|
11540
|
+
"flexDirection": "column",
|
|
11541
|
+
}
|
|
11542
|
+
}
|
|
11543
|
+
>
|
|
11544
|
+
<div
|
|
11545
|
+
className="debugger"
|
|
11546
|
+
>
|
|
11547
|
+
<button
|
|
11548
|
+
className="base button x-main2"
|
|
11549
|
+
onClick={[Function]}
|
|
11550
|
+
type="button"
|
|
11551
|
+
>
|
|
11552
|
+
Open FormDebugger
|
|
11553
|
+
</button>
|
|
11554
|
+
</div>
|
|
11555
|
+
<button
|
|
11556
|
+
className="base button x-main1"
|
|
11557
|
+
onClick={[Function]}
|
|
11558
|
+
type="button"
|
|
11559
|
+
>
|
|
11560
|
+
Add formik values
|
|
11561
|
+
</button>
|
|
11562
|
+
</div>
|
|
11563
|
+
</form>
|
|
11564
|
+
`;
|
|
11565
|
+
|
|
11566
|
+
exports[`Storyshots f/fields/QueryCombobox Single Select 1`] = `
|
|
11281
11567
|
<form
|
|
11282
11568
|
action="#"
|
|
11283
11569
|
onReset={[Function]}
|
|
@@ -11310,7 +11596,7 @@ exports[`Storyshots f/fields/QueryCombobox Single Select With Default Formik Sta
|
|
|
11310
11596
|
onBlur={[Function]}
|
|
11311
11597
|
onChange={[Function]}
|
|
11312
11598
|
onKeyDown={[Function]}
|
|
11313
|
-
value="
|
|
11599
|
+
value=""
|
|
11314
11600
|
/>
|
|
11315
11601
|
</div>
|
|
11316
11602
|
<div
|
|
@@ -11350,7 +11636,86 @@ exports[`Storyshots f/fields/QueryCombobox Single Select With Default Formik Sta
|
|
|
11350
11636
|
onClick={[Function]}
|
|
11351
11637
|
type="button"
|
|
11352
11638
|
>
|
|
11353
|
-
Replace
|
|
11639
|
+
Replace formik value
|
|
11640
|
+
</button>
|
|
11641
|
+
</div>
|
|
11642
|
+
</form>
|
|
11643
|
+
`;
|
|
11644
|
+
|
|
11645
|
+
exports[`Storyshots f/fields/QueryCombobox Single Select With Default Formik State 1`] = `
|
|
11646
|
+
<form
|
|
11647
|
+
action="#"
|
|
11648
|
+
onReset={[Function]}
|
|
11649
|
+
onSubmit={[Function]}
|
|
11650
|
+
>
|
|
11651
|
+
<div
|
|
11652
|
+
className="base combobox y-background2"
|
|
11653
|
+
>
|
|
11654
|
+
<label
|
|
11655
|
+
className="base label x-main2"
|
|
11656
|
+
htmlFor="team"
|
|
11657
|
+
id="downshift-2-label"
|
|
11658
|
+
>
|
|
11659
|
+
Search for a team
|
|
11660
|
+
</label>
|
|
11661
|
+
<div
|
|
11662
|
+
aria-expanded={false}
|
|
11663
|
+
aria-haspopup="listbox"
|
|
11664
|
+
aria-owns="downshift-2-menu"
|
|
11665
|
+
className="input-wrapper"
|
|
11666
|
+
role="combobox"
|
|
11667
|
+
>
|
|
11668
|
+
<input
|
|
11669
|
+
aria-autocomplete="list"
|
|
11670
|
+
aria-controls="downshift-2-menu"
|
|
11671
|
+
aria-labelledby="downshift-2-label"
|
|
11672
|
+
autoComplete="off"
|
|
11673
|
+
className="input"
|
|
11674
|
+
id="downshift-2-input"
|
|
11675
|
+
onBlur={[Function]}
|
|
11676
|
+
onChange={[Function]}
|
|
11677
|
+
onKeyDown={[Function]}
|
|
11678
|
+
value="Apple"
|
|
11679
|
+
/>
|
|
11680
|
+
</div>
|
|
11681
|
+
<div
|
|
11682
|
+
className="base popover x-background1 bottom left"
|
|
11683
|
+
>
|
|
11684
|
+
<ul
|
|
11685
|
+
aria-labelledby="downshift-2-label"
|
|
11686
|
+
className="base menu"
|
|
11687
|
+
id="downshift-2-menu"
|
|
11688
|
+
onMouseLeave={[Function]}
|
|
11689
|
+
role="listbox"
|
|
11690
|
+
/>
|
|
11691
|
+
</div>
|
|
11692
|
+
</div>
|
|
11693
|
+
<div
|
|
11694
|
+
style={
|
|
11695
|
+
Object {
|
|
11696
|
+
"alignItems": "flex-end",
|
|
11697
|
+
"display": "flex",
|
|
11698
|
+
"flexDirection": "column",
|
|
11699
|
+
}
|
|
11700
|
+
}
|
|
11701
|
+
>
|
|
11702
|
+
<div
|
|
11703
|
+
className="debugger"
|
|
11704
|
+
>
|
|
11705
|
+
<button
|
|
11706
|
+
className="base button x-main2"
|
|
11707
|
+
onClick={[Function]}
|
|
11708
|
+
type="button"
|
|
11709
|
+
>
|
|
11710
|
+
Open FormDebugger
|
|
11711
|
+
</button>
|
|
11712
|
+
</div>
|
|
11713
|
+
<button
|
|
11714
|
+
className="base button x-main1"
|
|
11715
|
+
onClick={[Function]}
|
|
11716
|
+
type="button"
|
|
11717
|
+
>
|
|
11718
|
+
Replace formik value
|
|
11354
11719
|
</button>
|
|
11355
11720
|
</div>
|
|
11356
11721
|
</form>
|
package/src/local.scss
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
--theme-border-style: 1px solid;
|
|
6
6
|
--theme-border-color: var(--paragraph);
|
|
7
7
|
--theme-border: var(--theme-border-style) var(--theme-border-color);
|
|
8
|
+
--default-gap: 1em;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
html {
|
|
11
12
|
font-family: var(--font-default);
|
|
12
13
|
font-size: 18px;
|
|
13
|
-
font-feature-settings:'liga' on;
|
|
14
|
+
font-feature-settings: 'liga' on;
|
|
14
15
|
scroll-behavior: smooth;
|
|
15
|
-
}
|
|
16
|
-
|
|
16
|
+
}
|
|
@@ -8,6 +8,15 @@ import {
|
|
|
8
8
|
FormDebugger,
|
|
9
9
|
} from 'ui'
|
|
10
10
|
|
|
11
|
+
import { fruits } from '../utils/testData'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
RelayEnvironmentProvider,
|
|
15
|
+
mockRelayOperation,
|
|
16
|
+
} from '../utils/relay'
|
|
17
|
+
|
|
18
|
+
import generateNodeId from '../utils/generateNodeId'
|
|
19
|
+
|
|
11
20
|
export default {
|
|
12
21
|
title :'f/FormInput',
|
|
13
22
|
component :FormInput,
|
|
@@ -25,6 +34,11 @@ export default {
|
|
|
25
34
|
</Form>
|
|
26
35
|
</Formik>
|
|
27
36
|
),
|
|
37
|
+
(storyfn) => (
|
|
38
|
+
<RelayEnvironmentProvider>
|
|
39
|
+
{ storyfn() }
|
|
40
|
+
</RelayEnvironmentProvider>
|
|
41
|
+
),
|
|
28
42
|
],
|
|
29
43
|
argTypes:{
|
|
30
44
|
backgroundColor:{ control: 'color' },
|
|
@@ -99,6 +113,107 @@ export const Base = () => {
|
|
|
99
113
|
)
|
|
100
114
|
}
|
|
101
115
|
|
|
116
|
+
const allTeamsMockData = {
|
|
117
|
+
PageInfo() {
|
|
118
|
+
return {
|
|
119
|
+
hasNextPage :true,
|
|
120
|
+
hasPreviousPage:true,
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
TeamNodeConnection:(args) => {
|
|
124
|
+
const edges = fruits.map((fruit) => ({
|
|
125
|
+
node:{
|
|
126
|
+
id :generateNodeId('TeamNode'),
|
|
127
|
+
name:fruit,
|
|
128
|
+
},
|
|
129
|
+
}))
|
|
130
|
+
|
|
131
|
+
// eslint-disable-next-line camelcase
|
|
132
|
+
const { name_Icontains } = args?.args || {}
|
|
133
|
+
|
|
134
|
+
return ({
|
|
135
|
+
pageInfo:{
|
|
136
|
+
hasNextPage :true,
|
|
137
|
+
hasPreviousPage:true,
|
|
138
|
+
},
|
|
139
|
+
// eslint-disable-next-line camelcase
|
|
140
|
+
edges:name_Icontains?.trim()
|
|
141
|
+
? edges.filter(({ node }) => node.name
|
|
142
|
+
.toLowerCase()
|
|
143
|
+
.includes(name_Icontains.toLowerCase()))
|
|
144
|
+
: [],
|
|
145
|
+
})
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const FETCH_TEAMS_QUERY = graphql`
|
|
150
|
+
query FormInputAllTeamsQuery($name_Icontains: String) {
|
|
151
|
+
allTeams(name_Icontains: $name_Icontains) {
|
|
152
|
+
edges {
|
|
153
|
+
node {
|
|
154
|
+
id
|
|
155
|
+
name
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`
|
|
161
|
+
|
|
162
|
+
export const WithQueryCombobox = () => {
|
|
163
|
+
const inputMap = [
|
|
164
|
+
{
|
|
165
|
+
type :'text',
|
|
166
|
+
name :'firstName',
|
|
167
|
+
label:"What's your first name ?",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type :'choices',
|
|
171
|
+
name :'colors',
|
|
172
|
+
label :'What are your favourite colors ?',
|
|
173
|
+
options:[
|
|
174
|
+
{
|
|
175
|
+
value:'red',
|
|
176
|
+
label:'Color Red',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
value:'blue',
|
|
180
|
+
label:'Color Blue',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
value:'green',
|
|
184
|
+
label:'Color Green',
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type :'query-combobox',
|
|
190
|
+
name :'team',
|
|
191
|
+
query :FETCH_TEAMS_QUERY,
|
|
192
|
+
label :'Search for a team',
|
|
193
|
+
optionsKeyMap:{
|
|
194
|
+
value:'id',
|
|
195
|
+
label:'name',
|
|
196
|
+
},
|
|
197
|
+
graphQlNode :'allTeams',
|
|
198
|
+
searchVariable:'name_Icontains',
|
|
199
|
+
},
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
mockRelayOperation(allTeamsMockData)
|
|
203
|
+
mockRelayOperation(allTeamsMockData)
|
|
204
|
+
mockRelayOperation(allTeamsMockData)
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<>
|
|
208
|
+
{
|
|
209
|
+
inputMap.map((input) => <FormInput {...input} key={input.name} />)
|
|
210
|
+
}
|
|
211
|
+
<FormDebugger />
|
|
212
|
+
|
|
213
|
+
</>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
102
217
|
export const ExtensibleFormInput = () => {
|
|
103
218
|
const ExtendedTextInput = (props) => (
|
|
104
219
|
<TextInput
|
|
@@ -80,7 +80,7 @@ const FETCH_TEAMS_QUERY = graphql`
|
|
|
80
80
|
`
|
|
81
81
|
|
|
82
82
|
// eslint-disable-next-line react/prop-types
|
|
83
|
-
const ResolvedTemplate = ({ multiple, defaultFormikState
|
|
83
|
+
const ResolvedTemplate = ({ multiple, defaultFormikState }) => {
|
|
84
84
|
mockRelayOperation(allTeamsMockData)
|
|
85
85
|
mockRelayOperation(allTeamsMockData)
|
|
86
86
|
mockRelayOperation(allTeamsMockData)
|
|
@@ -88,15 +88,31 @@ const ResolvedTemplate = ({ multiple, defaultFormikState = {} }) => {
|
|
|
88
88
|
const Content = () => {
|
|
89
89
|
const name = multiple ? 'teams' : 'team'
|
|
90
90
|
|
|
91
|
-
const [, , helpers] = useField(name)
|
|
91
|
+
const [, meta, helpers] = useField(name)
|
|
92
|
+
|
|
93
|
+
const { value } = meta
|
|
92
94
|
|
|
93
95
|
const { setValue } = helpers
|
|
94
96
|
|
|
95
97
|
const updateFormikState = () => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
if (multiple) {
|
|
99
|
+
setValue([
|
|
100
|
+
...(value || []),
|
|
101
|
+
{
|
|
102
|
+
value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNk',
|
|
103
|
+
label:'Matomoko',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNp',
|
|
107
|
+
label:'Chungwa',
|
|
108
|
+
},
|
|
109
|
+
])
|
|
110
|
+
} else {
|
|
111
|
+
setValue({
|
|
112
|
+
value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNk',
|
|
113
|
+
label:'Kafagoho',
|
|
114
|
+
})
|
|
115
|
+
}
|
|
100
116
|
}
|
|
101
117
|
|
|
102
118
|
return (
|
|
@@ -124,16 +140,24 @@ const ResolvedTemplate = ({ multiple, defaultFormikState = {} }) => {
|
|
|
124
140
|
<Button
|
|
125
141
|
onClick={updateFormikState}
|
|
126
142
|
>
|
|
127
|
-
{multiple ? 'Add
|
|
143
|
+
{multiple ? 'Add formik values' : 'Replace formik value'}
|
|
128
144
|
</Button>
|
|
129
145
|
</div>
|
|
130
146
|
</>
|
|
131
147
|
)
|
|
132
148
|
}
|
|
133
149
|
|
|
150
|
+
let initialValues = defaultFormikState
|
|
151
|
+
|
|
152
|
+
if (!defaultFormikState && multiple) {
|
|
153
|
+
initialValues = []
|
|
154
|
+
} else if (!defaultFormikState && !multiple) {
|
|
155
|
+
initialValues = {}
|
|
156
|
+
}
|
|
157
|
+
|
|
134
158
|
return (
|
|
135
159
|
<Formik
|
|
136
|
-
initialValues={
|
|
160
|
+
initialValues={initialValues}
|
|
137
161
|
>
|
|
138
162
|
<Form>
|
|
139
163
|
<Content />
|
|
@@ -158,6 +182,29 @@ SingleSelectWithDefaultFormikState.args = {
|
|
|
158
182
|
},
|
|
159
183
|
}
|
|
160
184
|
|
|
185
|
+
export const MultipleSelect = ResolvedTemplate.bind({})
|
|
186
|
+
MultipleSelect.args = {
|
|
187
|
+
multiple :true,
|
|
188
|
+
defaultFormikState:{ teams: [] },
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const MultipleSelectWithDefaultFormikState = ResolvedTemplate.bind({})
|
|
192
|
+
MultipleSelectWithDefaultFormikState.args = {
|
|
193
|
+
multiple :true,
|
|
194
|
+
defaultFormikState:{
|
|
195
|
+
teams:[
|
|
196
|
+
{
|
|
197
|
+
value:'VGVhbU5vZGU6MDAxZTIyOGEtYzA5My00MGI0LWE1MTUtYTNkMTM1NTE1MDNl',
|
|
198
|
+
label:'Apple',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
value:'VGVhbU5vZGU6MDA0N2U4MzktODY0Zi00N2U5LTg3ZjgtZGUwMmM2Yzg1YWJm',
|
|
202
|
+
label:'Pear',
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
|
|
161
208
|
// eslint-disable-next-line react/prop-types
|
|
162
209
|
// const RejectedTemplate = ({ multiple }) => {
|
|
163
210
|
// const Content = () => {
|