@sproutsocial/racine 8.6.0 → 8.6.3
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/CHANGELOG.md +19 -0
- package/__flow__/Collapsible/index.js +1 -0
- package/__flow__/Collapsible/styles.js +23 -24
- package/__flow__/Listbox/__snapshots__/index.test.js.snap +104 -42
- package/__flow__/Listbox/index.stories.js +33 -0
- package/__flow__/Listbox/index.test.js +52 -2
- package/__flow__/Menu/__snapshots__/index.test.js.snap +14 -0
- package/__flow__/Menu/hooks.js +8 -3
- package/__flow__/Menu/index.flow.js +1 -0
- package/__flow__/Menu/index.js +31 -4
- package/__flow__/Menu/index.stories.js +30 -0
- package/__flow__/Menu/styles.js +8 -0
- package/commonjs/Collapsible/index.js +1 -0
- package/commonjs/Collapsible/styles.js +5 -7
- package/commonjs/Menu/hooks.js +12 -3
- package/commonjs/Menu/index.js +26 -6
- package/commonjs/Menu/styles.js +5 -3
- package/lib/Collapsible/index.js +1 -0
- package/lib/Collapsible/styles.js +5 -7
- package/lib/Menu/hooks.js +12 -3
- package/lib/Menu/index.js +26 -6
- package/lib/Menu/styles.js +5 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 777fcd7: Unset inverted icon color when menu item is hovered and active
|
|
8
|
+
|
|
9
|
+
## 8.6.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 039da3f: Address visual bug on collapsible shadow
|
|
14
|
+
|
|
15
|
+
## 8.6.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- c46c79d: Pressing space on a filter input in listbox triggers a submit, preventing users from entering text with spaces. This fix changes the behavior such that if the input is in focus, the space won't trigger a select.
|
|
20
|
+
- b34b463: Invert the icon colors in menu items to mirror the text behavior.
|
|
21
|
+
|
|
3
22
|
## 8.6.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -10,29 +10,28 @@ export const CollapsingBox = styled<typeof Box, TypeTheme, *>(Box)`
|
|
|
10
10
|
will-change: max-height;
|
|
11
11
|
position: relative;
|
|
12
12
|
overflow: auto;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
rgba(255, 255, 255, 0),
|
|
19
|
-
${(p) => p.theme.colors.neutral[100]} 70%
|
|
20
|
-
)
|
|
21
|
-
0 100%,
|
|
22
|
-
/* Shadows */
|
|
23
|
-
radial-gradient(
|
|
24
|
-
farthest-side at 50% 0,
|
|
25
|
-
rgb(39 51 51 / 5%),
|
|
26
|
-
rgba(0, 0, 0, 0)
|
|
13
|
+
${({ hasShadow, theme, scrollable }) =>
|
|
14
|
+
hasShadow
|
|
15
|
+
? `background: /* Shadow covers */ linear-gradient(
|
|
16
|
+
transparent 30%,
|
|
17
|
+
rgba(255, 255, 255, 0)
|
|
27
18
|
),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
linear-gradient(rgba(255, 255, 255, 0), transparent 70%) 0 100%,
|
|
20
|
+
/* Shadows */
|
|
21
|
+
radial-gradient(
|
|
22
|
+
farthest-side at 50% 0,
|
|
23
|
+
rgb(39 51 51 / 5%),
|
|
24
|
+
rgba(0, 0, 0, 0)
|
|
25
|
+
),
|
|
26
|
+
radial-gradient(
|
|
27
|
+
farthest-side at 50% 100%,
|
|
28
|
+
rgb(39 51 51 / 5%),
|
|
29
|
+
rgba(0, 0, 0, 0)
|
|
30
|
+
)
|
|
31
|
+
0 100%;
|
|
32
|
+
background-repeat: no-repeat;
|
|
33
|
+
background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
|
|
34
|
+
background-attachment: local, local, scroll, scroll;
|
|
35
|
+
${scrollable ? `overflow: auto` : `overflow: hidden`};`
|
|
36
|
+
: ""}
|
|
38
37
|
`;
|
|
@@ -142,7 +142,7 @@ html .c5 {
|
|
|
142
142
|
class="c1 c2"
|
|
143
143
|
data-qa-button=""
|
|
144
144
|
data-qa-button-isdisabled="false"
|
|
145
|
-
id="MenuButton-
|
|
145
|
+
id="MenuButton-20"
|
|
146
146
|
type="button"
|
|
147
147
|
>
|
|
148
148
|
Select a fruit
|
|
@@ -413,6 +413,11 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
413
413
|
background-color: #f3f4f4;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
.c6:focus .Icon-svg,
|
|
417
|
+
.c6:hover .Icon-svg {
|
|
418
|
+
color: unset;
|
|
419
|
+
}
|
|
420
|
+
|
|
416
421
|
.c6:hover {
|
|
417
422
|
cursor: pointer;
|
|
418
423
|
}
|
|
@@ -436,12 +441,21 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
436
441
|
background-color: #364141;
|
|
437
442
|
}
|
|
438
443
|
|
|
444
|
+
.c4 .Icon-svg {
|
|
445
|
+
color: #FFFFFF;
|
|
446
|
+
}
|
|
447
|
+
|
|
439
448
|
.c4:focus,
|
|
440
449
|
.c4:hover {
|
|
441
450
|
color: #364141;
|
|
442
451
|
background-color: #f3f4f4;
|
|
443
452
|
}
|
|
444
453
|
|
|
454
|
+
.c4:focus .Icon-svg,
|
|
455
|
+
.c4:hover .Icon-svg {
|
|
456
|
+
color: unset;
|
|
457
|
+
}
|
|
458
|
+
|
|
445
459
|
.c4:hover {
|
|
446
460
|
cursor: pointer;
|
|
447
461
|
}
|
|
@@ -535,7 +549,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
535
549
|
|
|
536
550
|
<div>
|
|
537
551
|
<ul
|
|
538
|
-
aria-activedescendant="MenuItem-
|
|
552
|
+
aria-activedescendant="MenuItem-28"
|
|
539
553
|
aria-multiselectable="true"
|
|
540
554
|
class="c0 c1"
|
|
541
555
|
overflow="hidden"
|
|
@@ -552,7 +566,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
552
566
|
class="c2 c4"
|
|
553
567
|
data-qa-menu-item="Apple"
|
|
554
568
|
data-value="Apple"
|
|
555
|
-
id="MenuItem-
|
|
569
|
+
id="MenuItem-28"
|
|
556
570
|
role="menuitemcheckbox"
|
|
557
571
|
tabindex="-1"
|
|
558
572
|
value="Apple"
|
|
@@ -565,10 +579,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
565
579
|
class="c5"
|
|
566
580
|
>
|
|
567
581
|
<input
|
|
568
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
582
|
+
data-qa-checkbox="Checkbox-MenuItem-28"
|
|
569
583
|
data-qa-checkbox-ischecked="false"
|
|
570
584
|
data-qa-checkbox-isdisabled="false"
|
|
571
|
-
id="Checkbox-MenuItem-
|
|
585
|
+
id="Checkbox-MenuItem-28"
|
|
572
586
|
tabindex="-1"
|
|
573
587
|
type="checkbox"
|
|
574
588
|
value=""
|
|
@@ -586,7 +600,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
586
600
|
class="c2 c6"
|
|
587
601
|
data-qa-menu-item="Banana"
|
|
588
602
|
data-value="Banana"
|
|
589
|
-
id="MenuItem-
|
|
603
|
+
id="MenuItem-29"
|
|
590
604
|
role="menuitemcheckbox"
|
|
591
605
|
tabindex="-1"
|
|
592
606
|
value="Banana"
|
|
@@ -599,10 +613,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
599
613
|
class="c5"
|
|
600
614
|
>
|
|
601
615
|
<input
|
|
602
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
616
|
+
data-qa-checkbox="Checkbox-MenuItem-29"
|
|
603
617
|
data-qa-checkbox-ischecked="false"
|
|
604
618
|
data-qa-checkbox-isdisabled="false"
|
|
605
|
-
id="Checkbox-MenuItem-
|
|
619
|
+
id="Checkbox-MenuItem-29"
|
|
606
620
|
tabindex="-1"
|
|
607
621
|
type="checkbox"
|
|
608
622
|
value=""
|
|
@@ -620,7 +634,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
620
634
|
class="c2 c6"
|
|
621
635
|
data-qa-menu-item="Orange"
|
|
622
636
|
data-value="Orange"
|
|
623
|
-
id="MenuItem-
|
|
637
|
+
id="MenuItem-30"
|
|
624
638
|
role="menuitemcheckbox"
|
|
625
639
|
tabindex="-1"
|
|
626
640
|
value="Orange"
|
|
@@ -633,10 +647,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
633
647
|
class="c5"
|
|
634
648
|
>
|
|
635
649
|
<input
|
|
636
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
650
|
+
data-qa-checkbox="Checkbox-MenuItem-30"
|
|
637
651
|
data-qa-checkbox-ischecked="false"
|
|
638
652
|
data-qa-checkbox-isdisabled="false"
|
|
639
|
-
id="Checkbox-MenuItem-
|
|
653
|
+
id="Checkbox-MenuItem-30"
|
|
640
654
|
tabindex="-1"
|
|
641
655
|
type="checkbox"
|
|
642
656
|
value=""
|
|
@@ -694,6 +708,11 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
694
708
|
background-color: #f3f4f4;
|
|
695
709
|
}
|
|
696
710
|
|
|
711
|
+
.c7:focus .Icon-svg,
|
|
712
|
+
.c7:hover .Icon-svg {
|
|
713
|
+
color: unset;
|
|
714
|
+
}
|
|
715
|
+
|
|
697
716
|
.c7:hover {
|
|
698
717
|
cursor: pointer;
|
|
699
718
|
}
|
|
@@ -717,12 +736,21 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
717
736
|
background-color: #364141;
|
|
718
737
|
}
|
|
719
738
|
|
|
739
|
+
.c5 .Icon-svg {
|
|
740
|
+
color: #FFFFFF;
|
|
741
|
+
}
|
|
742
|
+
|
|
720
743
|
.c5:focus,
|
|
721
744
|
.c5:hover {
|
|
722
745
|
color: #364141;
|
|
723
746
|
background-color: #f3f4f4;
|
|
724
747
|
}
|
|
725
748
|
|
|
749
|
+
.c5:focus .Icon-svg,
|
|
750
|
+
.c5:hover .Icon-svg {
|
|
751
|
+
color: unset;
|
|
752
|
+
}
|
|
753
|
+
|
|
726
754
|
.c5:hover {
|
|
727
755
|
cursor: pointer;
|
|
728
756
|
}
|
|
@@ -873,7 +901,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
873
901
|
|
|
874
902
|
<div>
|
|
875
903
|
<ul
|
|
876
|
-
aria-activedescendant="MenuItem-
|
|
904
|
+
aria-activedescendant="MenuItem-34"
|
|
877
905
|
aria-multiselectable="true"
|
|
878
906
|
class="c0 c1"
|
|
879
907
|
overflow="hidden"
|
|
@@ -906,7 +934,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
906
934
|
class="c2 c5"
|
|
907
935
|
data-qa-menu-item="Apple"
|
|
908
936
|
data-value="Apple"
|
|
909
|
-
id="MenuItem-
|
|
937
|
+
id="MenuItem-34"
|
|
910
938
|
role="menuitemcheckbox"
|
|
911
939
|
tabindex="-1"
|
|
912
940
|
value="Apple"
|
|
@@ -919,10 +947,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
919
947
|
class="c6"
|
|
920
948
|
>
|
|
921
949
|
<input
|
|
922
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
950
|
+
data-qa-checkbox="Checkbox-MenuItem-34"
|
|
923
951
|
data-qa-checkbox-ischecked="false"
|
|
924
952
|
data-qa-checkbox-isdisabled="false"
|
|
925
|
-
id="Checkbox-MenuItem-
|
|
953
|
+
id="Checkbox-MenuItem-34"
|
|
926
954
|
tabindex="-1"
|
|
927
955
|
type="checkbox"
|
|
928
956
|
value=""
|
|
@@ -940,7 +968,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
940
968
|
class="c2 c7"
|
|
941
969
|
data-qa-menu-item="Banana"
|
|
942
970
|
data-value="Banana"
|
|
943
|
-
id="MenuItem-
|
|
971
|
+
id="MenuItem-35"
|
|
944
972
|
role="menuitemcheckbox"
|
|
945
973
|
tabindex="-1"
|
|
946
974
|
value="Banana"
|
|
@@ -953,10 +981,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
953
981
|
class="c6"
|
|
954
982
|
>
|
|
955
983
|
<input
|
|
956
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
984
|
+
data-qa-checkbox="Checkbox-MenuItem-35"
|
|
957
985
|
data-qa-checkbox-ischecked="false"
|
|
958
986
|
data-qa-checkbox-isdisabled="false"
|
|
959
|
-
id="Checkbox-MenuItem-
|
|
987
|
+
id="Checkbox-MenuItem-35"
|
|
960
988
|
tabindex="-1"
|
|
961
989
|
type="checkbox"
|
|
962
990
|
value=""
|
|
@@ -974,7 +1002,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
974
1002
|
class="c2 c7"
|
|
975
1003
|
data-qa-menu-item="Orange"
|
|
976
1004
|
data-value="Orange"
|
|
977
|
-
id="MenuItem-
|
|
1005
|
+
id="MenuItem-36"
|
|
978
1006
|
role="menuitemcheckbox"
|
|
979
1007
|
tabindex="-1"
|
|
980
1008
|
value="Orange"
|
|
@@ -987,10 +1015,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
987
1015
|
class="c6"
|
|
988
1016
|
>
|
|
989
1017
|
<input
|
|
990
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1018
|
+
data-qa-checkbox="Checkbox-MenuItem-36"
|
|
991
1019
|
data-qa-checkbox-ischecked="false"
|
|
992
1020
|
data-qa-checkbox-isdisabled="false"
|
|
993
|
-
id="Checkbox-MenuItem-
|
|
1021
|
+
id="Checkbox-MenuItem-36"
|
|
994
1022
|
tabindex="-1"
|
|
995
1023
|
type="checkbox"
|
|
996
1024
|
value=""
|
|
@@ -1008,7 +1036,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1008
1036
|
class="c2 c7"
|
|
1009
1037
|
data-qa-menu-item="Tomato"
|
|
1010
1038
|
data-value="Tomato"
|
|
1011
|
-
id="MenuItem-
|
|
1039
|
+
id="MenuItem-37"
|
|
1012
1040
|
role="menuitemcheckbox"
|
|
1013
1041
|
tabindex="-1"
|
|
1014
1042
|
value="Tomato"
|
|
@@ -1021,10 +1049,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1021
1049
|
class="c6"
|
|
1022
1050
|
>
|
|
1023
1051
|
<input
|
|
1024
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1052
|
+
data-qa-checkbox="Checkbox-MenuItem-37"
|
|
1025
1053
|
data-qa-checkbox-ischecked="false"
|
|
1026
1054
|
data-qa-checkbox-isdisabled="false"
|
|
1027
|
-
id="Checkbox-MenuItem-
|
|
1055
|
+
id="Checkbox-MenuItem-37"
|
|
1028
1056
|
tabindex="-1"
|
|
1029
1057
|
type="checkbox"
|
|
1030
1058
|
value=""
|
|
@@ -1042,7 +1070,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1042
1070
|
class="c2 c7"
|
|
1043
1071
|
data-qa-menu-item="Cucumber"
|
|
1044
1072
|
data-value="Cucumber"
|
|
1045
|
-
id="MenuItem-
|
|
1073
|
+
id="MenuItem-38"
|
|
1046
1074
|
role="menuitemcheckbox"
|
|
1047
1075
|
tabindex="-1"
|
|
1048
1076
|
value="Cucumber"
|
|
@@ -1055,10 +1083,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1055
1083
|
class="c6"
|
|
1056
1084
|
>
|
|
1057
1085
|
<input
|
|
1058
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1086
|
+
data-qa-checkbox="Checkbox-MenuItem-38"
|
|
1059
1087
|
data-qa-checkbox-ischecked="false"
|
|
1060
1088
|
data-qa-checkbox-isdisabled="false"
|
|
1061
|
-
id="Checkbox-MenuItem-
|
|
1089
|
+
id="Checkbox-MenuItem-38"
|
|
1062
1090
|
tabindex="-1"
|
|
1063
1091
|
type="checkbox"
|
|
1064
1092
|
value=""
|
|
@@ -1076,7 +1104,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1076
1104
|
class="c2 c7"
|
|
1077
1105
|
data-qa-menu-item="Squash"
|
|
1078
1106
|
data-value="Squash"
|
|
1079
|
-
id="MenuItem-
|
|
1107
|
+
id="MenuItem-39"
|
|
1080
1108
|
role="menuitemcheckbox"
|
|
1081
1109
|
tabindex="-1"
|
|
1082
1110
|
value="Squash"
|
|
@@ -1089,10 +1117,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1089
1117
|
class="c6"
|
|
1090
1118
|
>
|
|
1091
1119
|
<input
|
|
1092
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1120
|
+
data-qa-checkbox="Checkbox-MenuItem-39"
|
|
1093
1121
|
data-qa-checkbox-ischecked="false"
|
|
1094
1122
|
data-qa-checkbox-isdisabled="false"
|
|
1095
|
-
id="Checkbox-MenuItem-
|
|
1123
|
+
id="Checkbox-MenuItem-39"
|
|
1096
1124
|
tabindex="-1"
|
|
1097
1125
|
type="checkbox"
|
|
1098
1126
|
value=""
|
|
@@ -1110,7 +1138,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1110
1138
|
class="c2 c7"
|
|
1111
1139
|
data-qa-menu-item="Cantaloupe"
|
|
1112
1140
|
data-value="Cantaloupe"
|
|
1113
|
-
id="MenuItem-
|
|
1141
|
+
id="MenuItem-40"
|
|
1114
1142
|
role="menuitemcheckbox"
|
|
1115
1143
|
tabindex="-1"
|
|
1116
1144
|
value="Cantaloupe"
|
|
@@ -1123,10 +1151,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1123
1151
|
class="c6"
|
|
1124
1152
|
>
|
|
1125
1153
|
<input
|
|
1126
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1154
|
+
data-qa-checkbox="Checkbox-MenuItem-40"
|
|
1127
1155
|
data-qa-checkbox-ischecked="false"
|
|
1128
1156
|
data-qa-checkbox-isdisabled="false"
|
|
1129
|
-
id="Checkbox-MenuItem-
|
|
1157
|
+
id="Checkbox-MenuItem-40"
|
|
1130
1158
|
tabindex="-1"
|
|
1131
1159
|
type="checkbox"
|
|
1132
1160
|
value=""
|
|
@@ -1144,7 +1172,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1144
1172
|
class="c2 c7"
|
|
1145
1173
|
data-qa-menu-item="Jackalope"
|
|
1146
1174
|
data-value="Jackalope"
|
|
1147
|
-
id="MenuItem-
|
|
1175
|
+
id="MenuItem-41"
|
|
1148
1176
|
role="menuitemcheckbox"
|
|
1149
1177
|
tabindex="-1"
|
|
1150
1178
|
value="Jackalope"
|
|
@@ -1157,10 +1185,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1157
1185
|
class="c6"
|
|
1158
1186
|
>
|
|
1159
1187
|
<input
|
|
1160
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1188
|
+
data-qa-checkbox="Checkbox-MenuItem-41"
|
|
1161
1189
|
data-qa-checkbox-ischecked="false"
|
|
1162
1190
|
data-qa-checkbox-isdisabled="false"
|
|
1163
|
-
id="Checkbox-MenuItem-
|
|
1191
|
+
id="Checkbox-MenuItem-41"
|
|
1164
1192
|
tabindex="-1"
|
|
1165
1193
|
type="checkbox"
|
|
1166
1194
|
value=""
|
|
@@ -1178,7 +1206,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1178
1206
|
class="c2 c7"
|
|
1179
1207
|
data-qa-menu-item="Lingonberry"
|
|
1180
1208
|
data-value="Lingonberry"
|
|
1181
|
-
id="MenuItem-
|
|
1209
|
+
id="MenuItem-42"
|
|
1182
1210
|
role="menuitemcheckbox"
|
|
1183
1211
|
tabindex="-1"
|
|
1184
1212
|
value="Lingonberry"
|
|
@@ -1191,10 +1219,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1191
1219
|
class="c6"
|
|
1192
1220
|
>
|
|
1193
1221
|
<input
|
|
1194
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1222
|
+
data-qa-checkbox="Checkbox-MenuItem-42"
|
|
1195
1223
|
data-qa-checkbox-ischecked="false"
|
|
1196
1224
|
data-qa-checkbox-isdisabled="false"
|
|
1197
|
-
id="Checkbox-MenuItem-
|
|
1225
|
+
id="Checkbox-MenuItem-42"
|
|
1198
1226
|
tabindex="-1"
|
|
1199
1227
|
type="checkbox"
|
|
1200
1228
|
value=""
|
|
@@ -1212,7 +1240,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1212
1240
|
class="c2 c7"
|
|
1213
1241
|
data-qa-menu-item="Dingleberry"
|
|
1214
1242
|
data-value="Dingleberry"
|
|
1215
|
-
id="MenuItem-
|
|
1243
|
+
id="MenuItem-43"
|
|
1216
1244
|
role="menuitemcheckbox"
|
|
1217
1245
|
tabindex="-1"
|
|
1218
1246
|
value="Dingleberry"
|
|
@@ -1225,10 +1253,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1225
1253
|
class="c6"
|
|
1226
1254
|
>
|
|
1227
1255
|
<input
|
|
1228
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1256
|
+
data-qa-checkbox="Checkbox-MenuItem-43"
|
|
1229
1257
|
data-qa-checkbox-ischecked="false"
|
|
1230
1258
|
data-qa-checkbox-isdisabled="false"
|
|
1231
|
-
id="Checkbox-MenuItem-
|
|
1259
|
+
id="Checkbox-MenuItem-43"
|
|
1232
1260
|
tabindex="-1"
|
|
1233
1261
|
type="checkbox"
|
|
1234
1262
|
value=""
|
|
@@ -1241,6 +1269,40 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1241
1269
|
</div>
|
|
1242
1270
|
</div>
|
|
1243
1271
|
</li>
|
|
1272
|
+
<li
|
|
1273
|
+
aria-checked="false"
|
|
1274
|
+
class="c2 c7"
|
|
1275
|
+
data-qa-menu-item="Kaffir Lime"
|
|
1276
|
+
data-value="Kaffir Lime"
|
|
1277
|
+
id="MenuItem-44"
|
|
1278
|
+
role="menuitemcheckbox"
|
|
1279
|
+
tabindex="-1"
|
|
1280
|
+
value="Kaffir Lime"
|
|
1281
|
+
>
|
|
1282
|
+
<div
|
|
1283
|
+
style="display: flex; align-items: center; justify-content: space-between;"
|
|
1284
|
+
>
|
|
1285
|
+
<span
|
|
1286
|
+
aria-hidden="true"
|
|
1287
|
+
class="c6"
|
|
1288
|
+
>
|
|
1289
|
+
<input
|
|
1290
|
+
data-qa-checkbox="Checkbox-MenuItem-44"
|
|
1291
|
+
data-qa-checkbox-ischecked="false"
|
|
1292
|
+
data-qa-checkbox-isdisabled="false"
|
|
1293
|
+
id="Checkbox-MenuItem-44"
|
|
1294
|
+
tabindex="-1"
|
|
1295
|
+
type="checkbox"
|
|
1296
|
+
value=""
|
|
1297
|
+
/>
|
|
1298
|
+
</span>
|
|
1299
|
+
<div
|
|
1300
|
+
style="flex-grow: 1; word-break: break-word; min-width: 0;"
|
|
1301
|
+
>
|
|
1302
|
+
Kaffir Lime
|
|
1303
|
+
</div>
|
|
1304
|
+
</div>
|
|
1305
|
+
</li>
|
|
1244
1306
|
</div>
|
|
1245
1307
|
</ul>
|
|
1246
1308
|
</div>
|
|
@@ -196,3 +196,36 @@ export const BigVirtualizedExample = () => {
|
|
|
196
196
|
</Box>
|
|
197
197
|
);
|
|
198
198
|
};
|
|
199
|
+
|
|
200
|
+
const ListboxFilterInput = () => {
|
|
201
|
+
const { value, onChange } = useSelect({ initialValue: null });
|
|
202
|
+
const { inputValue } = useSelect({ initialValue: null });
|
|
203
|
+
return (
|
|
204
|
+
<>
|
|
205
|
+
<Text>{inputValue}</Text>
|
|
206
|
+
<ListboxButton
|
|
207
|
+
minWidth="200px"
|
|
208
|
+
aria-label="Favorite fruit"
|
|
209
|
+
content={
|
|
210
|
+
<Listbox onChange={onChange} value={value} width="200px">
|
|
211
|
+
<Listbox.Group>
|
|
212
|
+
<Listbox.FilterInput placeholder="Filter items" mb={300} />
|
|
213
|
+
<Listbox.Item value="Apple">Apple</Listbox.Item>
|
|
214
|
+
<Listbox.Item value="Orange">Orange</Listbox.Item>
|
|
215
|
+
<Listbox.Item value="Banana">Banana</Listbox.Item>
|
|
216
|
+
<Listbox.Item value="Kaffir Lime">Kaffir Lime</Listbox.Item>
|
|
217
|
+
</Listbox.Group>
|
|
218
|
+
</Listbox>
|
|
219
|
+
}
|
|
220
|
+
>
|
|
221
|
+
{value || "Select a fruit"}
|
|
222
|
+
</ListboxButton>
|
|
223
|
+
</>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const FilterInput = () => <ListboxFilterInput />;
|
|
228
|
+
|
|
229
|
+
FilterInput.story = {
|
|
230
|
+
name: "FilterInput",
|
|
231
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
render,
|
|
4
|
+
fireEvent,
|
|
5
|
+
cleanup,
|
|
6
|
+
userEvent,
|
|
7
|
+
} from "../utils/react-testing-library";
|
|
3
8
|
import Listbox, { ListboxButton } from "./";
|
|
4
9
|
import { useSelect, useMultiselect } from "../utils/hooks";
|
|
5
10
|
import { MENU_ITEM_ROLES } from "../Menu/constants";
|
|
@@ -16,6 +21,7 @@ const lotsOfFruit = [
|
|
|
16
21
|
"Jackalope",
|
|
17
22
|
"Lingonberry",
|
|
18
23
|
"Dingleberry",
|
|
24
|
+
"Kaffir Lime",
|
|
19
25
|
];
|
|
20
26
|
const mockOnClick = jest.fn();
|
|
21
27
|
|
|
@@ -182,6 +188,26 @@ describe("Listbox", () => {
|
|
|
182
188
|
expect(await findByText(fruit[1])).toBeInTheDocument();
|
|
183
189
|
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
184
190
|
});
|
|
191
|
+
|
|
192
|
+
it("should trigger select on enter", async () => {
|
|
193
|
+
const { findByText, queryByLabelText } = render(<AsListbox />);
|
|
194
|
+
const button = queryByLabelText(/Select a fruit/);
|
|
195
|
+
|
|
196
|
+
fireEvent.click(button);
|
|
197
|
+
userEvent.keyboard("{enter}");
|
|
198
|
+
expect(await findByText(fruit[0])).toBeInTheDocument();
|
|
199
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should trigger select on space", async () => {
|
|
203
|
+
const { findByText, queryByLabelText } = render(<AsListbox />);
|
|
204
|
+
const button = queryByLabelText(/Select a fruit/);
|
|
205
|
+
|
|
206
|
+
fireEvent.click(button);
|
|
207
|
+
userEvent.keyboard("{space}");
|
|
208
|
+
expect(await findByText(fruit[0])).toBeInTheDocument();
|
|
209
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
210
|
+
});
|
|
185
211
|
});
|
|
186
212
|
|
|
187
213
|
describe("AsListbox multiselect", () => {
|
|
@@ -252,9 +278,33 @@ describe("Listbox", () => {
|
|
|
252
278
|
<AsListboxWithFilterInput />
|
|
253
279
|
);
|
|
254
280
|
const input = queryByLabelText("Search fruit...");
|
|
255
|
-
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(
|
|
281
|
+
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(11);
|
|
256
282
|
fireEvent.change(input, { target: { value: "berry" } });
|
|
257
283
|
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(2);
|
|
258
284
|
});
|
|
285
|
+
|
|
286
|
+
it("should allow spaces to be typed in the input", async () => {
|
|
287
|
+
const { queryByLabelText, queryAllByRole } = render(
|
|
288
|
+
<AsListboxWithFilterInput />
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
const input = queryByLabelText("Search fruit...");
|
|
292
|
+
userEvent.type(input, "Kaffir{space}L");
|
|
293
|
+
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(1);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("should trigger a submit on space if the input is not focused", async () => {
|
|
297
|
+
const { queryByRole } = render(<AsListboxWithFilterInput />);
|
|
298
|
+
|
|
299
|
+
// tab focus away from input
|
|
300
|
+
userEvent.tab();
|
|
301
|
+
userEvent.keyboard("{space}");
|
|
302
|
+
const firstItem = queryByRole(MENU_ITEM_ROLES.CHECKBOX, {
|
|
303
|
+
name: fruit[0],
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
expect(firstItem).toHaveAttribute("aria-checked", "true");
|
|
307
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
308
|
+
});
|
|
259
309
|
});
|
|
260
310
|
});
|
|
@@ -47,6 +47,11 @@ exports[`Menu AsMenu should match snapshot 1`] = `
|
|
|
47
47
|
background-color: #f3f4f4;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
.c7:focus .Icon-svg,
|
|
51
|
+
.c7:hover .Icon-svg {
|
|
52
|
+
color: unset;
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
.c7:hover {
|
|
51
56
|
cursor: pointer;
|
|
52
57
|
}
|
|
@@ -70,12 +75,21 @@ exports[`Menu AsMenu should match snapshot 1`] = `
|
|
|
70
75
|
background-color: #364141;
|
|
71
76
|
}
|
|
72
77
|
|
|
78
|
+
.c6 .Icon-svg {
|
|
79
|
+
color: #FFFFFF;
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
.c6:focus,
|
|
74
83
|
.c6:hover {
|
|
75
84
|
color: #364141;
|
|
76
85
|
background-color: #f3f4f4;
|
|
77
86
|
}
|
|
78
87
|
|
|
88
|
+
.c6:focus .Icon-svg,
|
|
89
|
+
.c6:hover .Icon-svg {
|
|
90
|
+
color: unset;
|
|
91
|
+
}
|
|
92
|
+
|
|
79
93
|
.c6:hover {
|
|
80
94
|
cursor: pointer;
|
|
81
95
|
}
|
package/__flow__/Menu/hooks.js
CHANGED
|
@@ -24,6 +24,7 @@ export const MenuContext = createContext<TypeMenuContext>({
|
|
|
24
24
|
selectionIndex: 0,
|
|
25
25
|
filterQuery: "",
|
|
26
26
|
filteredItems: null,
|
|
27
|
+
isFilterInputFocused: false,
|
|
27
28
|
},
|
|
28
29
|
setState: () => {},
|
|
29
30
|
selectCallbacks: {
|
|
@@ -75,7 +76,7 @@ export function useMenuKeyDown() {
|
|
|
75
76
|
selectCallbacks,
|
|
76
77
|
setState,
|
|
77
78
|
multiselect,
|
|
78
|
-
state: { filterQuery, selectionIndex, filteredItems },
|
|
79
|
+
state: { filterQuery, selectionIndex, filteredItems, isFilterInputFocused },
|
|
79
80
|
} = useContext(MenuContext);
|
|
80
81
|
const { closePopout, closeOnItemClick } = useContext(MenuButtonContext);
|
|
81
82
|
const { descendants: items } = useContext(MenuDescendantContext);
|
|
@@ -142,10 +143,14 @@ export function useMenuKeyDown() {
|
|
|
142
143
|
handleKeyDown: wrapEvent<SyntheticKeyboardEvent<>>(
|
|
143
144
|
function (event) {
|
|
144
145
|
const { key } = event;
|
|
145
|
-
|
|
146
146
|
switch (key) {
|
|
147
|
-
case "Enter":
|
|
148
147
|
case " ":
|
|
148
|
+
if (isFilterInputFocused) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// falls through
|
|
152
|
+
// eslint-disable-next-line no-fallthrough
|
|
153
|
+
case "Enter":
|
|
149
154
|
const selected = items[selectionIndex];
|
|
150
155
|
|
|
151
156
|
if (selected) {
|
package/__flow__/Menu/index.js
CHANGED
|
@@ -308,14 +308,40 @@ export const MenuDivider = (props: any) => (
|
|
|
308
308
|
);
|
|
309
309
|
|
|
310
310
|
const MenuFilterInput = (props: React$ElementConfig<typeof Input>) => {
|
|
311
|
+
const { onChange, onFocus, onBlur } = props;
|
|
311
312
|
const { state, setState } = useContext(MenuContext);
|
|
312
|
-
const
|
|
313
|
-
(event) =>
|
|
314
|
-
|
|
313
|
+
const handleOnChange = useCallback(
|
|
314
|
+
(event, value) => {
|
|
315
|
+
onChange && onChange(event, value);
|
|
316
|
+
setState({ filterQuery: value });
|
|
317
|
+
},
|
|
318
|
+
[setState, onChange]
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
const handleOnFocus = useCallback(
|
|
322
|
+
(event) => {
|
|
323
|
+
onFocus && onFocus(event);
|
|
324
|
+
setState({ isFilterInputFocused: true });
|
|
325
|
+
},
|
|
326
|
+
[setState, onFocus]
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const handleOnBlur = useCallback(
|
|
330
|
+
(event) => {
|
|
331
|
+
onBlur && onBlur(event);
|
|
332
|
+
setState({ isFilterInputFocused: false });
|
|
333
|
+
},
|
|
334
|
+
[setState, onBlur]
|
|
315
335
|
);
|
|
316
336
|
|
|
317
337
|
return (
|
|
318
|
-
<Input
|
|
338
|
+
<Input
|
|
339
|
+
{...props}
|
|
340
|
+
value={state.filterQuery}
|
|
341
|
+
onChange={handleOnChange}
|
|
342
|
+
onFocus={handleOnFocus}
|
|
343
|
+
onBlur={handleOnBlur}
|
|
344
|
+
/>
|
|
319
345
|
);
|
|
320
346
|
};
|
|
321
347
|
|
|
@@ -364,6 +390,7 @@ export const Menu = ({
|
|
|
364
390
|
selectionIndex: 0,
|
|
365
391
|
filterQuery: "",
|
|
366
392
|
filteredItems: null,
|
|
393
|
+
isFilterInputFocused: false,
|
|
367
394
|
});
|
|
368
395
|
const selectCallbacks = useRef<(?(() => void))[]>([]);
|
|
369
396
|
const menuRef = useRef(null);
|
|
@@ -5,6 +5,7 @@ import OverflowList from "../OverflowList";
|
|
|
5
5
|
import Icon from "../Icon";
|
|
6
6
|
import { names } from "./names";
|
|
7
7
|
import Text from "../Text";
|
|
8
|
+
import Box from "../Box";
|
|
8
9
|
|
|
9
10
|
const fruit = ["Apple", "Banana", "Orange"];
|
|
10
11
|
const maybeFruit = ["Tomato", "Cucumber", "Squash"];
|
|
@@ -203,3 +204,32 @@ export const MenuWithCheckboxes = (props) => {
|
|
|
203
204
|
</Menu>
|
|
204
205
|
);
|
|
205
206
|
};
|
|
207
|
+
|
|
208
|
+
// Specifically testing that icons with a color inverse when active like the text does.
|
|
209
|
+
export const MenuWithIcons = (props) => {
|
|
210
|
+
return (
|
|
211
|
+
<Box
|
|
212
|
+
width="200px"
|
|
213
|
+
border={500}
|
|
214
|
+
borderRadius="outer"
|
|
215
|
+
borderColor="container.border.base"
|
|
216
|
+
boxShadow={300}
|
|
217
|
+
backgroundColor="container.background.base"
|
|
218
|
+
>
|
|
219
|
+
<Menu {...props}>
|
|
220
|
+
<Menu.Item key="positive" onClick={() => alert("positive")}>
|
|
221
|
+
<Icon name="flat-positive-sentiment" mr={200} color="icon.info" />
|
|
222
|
+
Positive
|
|
223
|
+
</Menu.Item>
|
|
224
|
+
<Menu.Item key="negative" onClick={() => alert("negative")}>
|
|
225
|
+
<Icon name="flat-negative-sentiment" mr={200} color="icon.error" />
|
|
226
|
+
Negative
|
|
227
|
+
</Menu.Item>
|
|
228
|
+
<Menu.Item key="neutral" onClick={() => alert("neutral")}>
|
|
229
|
+
<Icon name="flat-neutral-sentiment" mr={200} />
|
|
230
|
+
Neutral
|
|
231
|
+
</Menu.Item>
|
|
232
|
+
</Menu>
|
|
233
|
+
</Box>
|
|
234
|
+
);
|
|
235
|
+
};
|
package/__flow__/Menu/styles.js
CHANGED
|
@@ -41,6 +41,10 @@ export const MenuItemContainer = styled<
|
|
|
41
41
|
css`
|
|
42
42
|
color: ${(props) => props.theme.colors.text.inverse};
|
|
43
43
|
background-color: ${props.theme.colors.listItem.background.selected};
|
|
44
|
+
|
|
45
|
+
.Icon-svg {
|
|
46
|
+
color: ${(props) => props.theme.colors.text.inverse};
|
|
47
|
+
}
|
|
44
48
|
`}
|
|
45
49
|
|
|
46
50
|
${(props) =>
|
|
@@ -58,6 +62,10 @@ export const MenuItemContainer = styled<
|
|
|
58
62
|
color: ${(props) => props.theme.colors.text.body};
|
|
59
63
|
background-color: ${(props) =>
|
|
60
64
|
props.theme.colors.listItem.background.hover};
|
|
65
|
+
|
|
66
|
+
.Icon-svg {
|
|
67
|
+
color: unset;
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
`}
|
|
63
71
|
|
|
@@ -118,6 +118,7 @@ var Panel = function Panel(_ref3) {
|
|
|
118
118
|
}
|
|
119
119
|
}, [isOpen]);
|
|
120
120
|
return /*#__PURE__*/React.createElement(_styles.CollapsingBox, _extends({
|
|
121
|
+
hasShadow: collapsedHeight || openHeight > 0,
|
|
121
122
|
scrollable: isOpen,
|
|
122
123
|
maxHeight: isOpen ? maxHeight : collapsedHeight,
|
|
123
124
|
minHeight: collapsedHeight,
|
|
@@ -12,16 +12,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
var CollapsingBox = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
13
13
|
displayName: "styles__CollapsingBox",
|
|
14
14
|
componentId: "sc-1xvfbl7-0"
|
|
15
|
-
})(["transition:max-height ", " ", ";will-change:max-height;position:relative;overflow:auto;
|
|
15
|
+
})(["transition:max-height ", " ", ";will-change:max-height;position:relative;overflow:auto;", ""], function (p) {
|
|
16
16
|
return p.theme.duration.medium;
|
|
17
17
|
}, function (p) {
|
|
18
18
|
return p.theme.easing.ease_inout;
|
|
19
|
-
}, function (p) {
|
|
20
|
-
return p.theme.colors.neutral[100];
|
|
21
|
-
}, function (p) {
|
|
22
|
-
return p.theme.colors.neutral[100];
|
|
23
19
|
}, function (_ref) {
|
|
24
|
-
var
|
|
25
|
-
|
|
20
|
+
var hasShadow = _ref.hasShadow,
|
|
21
|
+
theme = _ref.theme,
|
|
22
|
+
scrollable = _ref.scrollable;
|
|
23
|
+
return hasShadow ? "background: /* Shadow covers */ linear-gradient(\n transparent 30%,\n rgba(255, 255, 255, 0)\n ),\n linear-gradient(rgba(255, 255, 255, 0), transparent 70%) 0 100%,\n /* Shadows */\n radial-gradient(\n farthest-side at 50% 0,\n rgb(39 51 51 / 5%),\n rgba(0, 0, 0, 0)\n ),\n radial-gradient(\n farthest-side at 50% 100%,\n rgb(39 51 51 / 5%),\n rgba(0, 0, 0, 0)\n )\n 0 100%;\n background-repeat: no-repeat;\n background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;\n background-attachment: local, local, scroll, scroll;\n " + (scrollable ? "overflow: auto" : "overflow: hidden") + ";" : "";
|
|
26
24
|
});
|
|
27
25
|
exports.CollapsingBox = CollapsingBox;
|
package/commonjs/Menu/hooks.js
CHANGED
|
@@ -25,7 +25,8 @@ var MenuContext = /*#__PURE__*/(0, _react.createContext)({
|
|
|
25
25
|
state: {
|
|
26
26
|
selectionIndex: 0,
|
|
27
27
|
filterQuery: "",
|
|
28
|
-
filteredItems: null
|
|
28
|
+
filteredItems: null,
|
|
29
|
+
isFilterInputFocused: false
|
|
29
30
|
},
|
|
30
31
|
setState: function setState() {},
|
|
31
32
|
selectCallbacks: {
|
|
@@ -75,7 +76,8 @@ function useMenuKeyDown() {
|
|
|
75
76
|
_useContext$state = _useContext.state,
|
|
76
77
|
filterQuery = _useContext$state.filterQuery,
|
|
77
78
|
selectionIndex = _useContext$state.selectionIndex,
|
|
78
|
-
filteredItems = _useContext$state.filteredItems
|
|
79
|
+
filteredItems = _useContext$state.filteredItems,
|
|
80
|
+
isFilterInputFocused = _useContext$state.isFilterInputFocused;
|
|
79
81
|
|
|
80
82
|
var _useContext2 = (0, _react.useContext)(MenuButtonContext),
|
|
81
83
|
closePopout = _useContext2.closePopout,
|
|
@@ -134,8 +136,15 @@ function useMenuKeyDown() {
|
|
|
134
136
|
var key = event.key;
|
|
135
137
|
|
|
136
138
|
switch (key) {
|
|
137
|
-
case "Enter":
|
|
138
139
|
case " ":
|
|
140
|
+
if (isFilterInputFocused) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// falls through
|
|
145
|
+
// eslint-disable-next-line no-fallthrough
|
|
146
|
+
|
|
147
|
+
case "Enter":
|
|
139
148
|
var selected = items[selectionIndex];
|
|
140
149
|
|
|
141
150
|
if (selected) {
|
package/commonjs/Menu/index.js
CHANGED
|
@@ -296,18 +296,37 @@ var MenuDivider = function MenuDivider(props) {
|
|
|
296
296
|
exports.MenuDivider = MenuDivider;
|
|
297
297
|
|
|
298
298
|
var MenuFilterInput = function MenuFilterInput(props) {
|
|
299
|
+
var onChange = props.onChange,
|
|
300
|
+
onFocus = props.onFocus,
|
|
301
|
+
onBlur = props.onBlur;
|
|
302
|
+
|
|
299
303
|
var _useContext3 = (0, React.useContext)(_hooks2.MenuContext),
|
|
300
304
|
state = _useContext3.state,
|
|
301
305
|
setState = _useContext3.setState;
|
|
302
306
|
|
|
303
|
-
var
|
|
304
|
-
|
|
305
|
-
|
|
307
|
+
var handleOnChange = (0, React.useCallback)(function (event, value) {
|
|
308
|
+
onChange && onChange(event, value);
|
|
309
|
+
setState({
|
|
310
|
+
filterQuery: value
|
|
311
|
+
});
|
|
312
|
+
}, [setState, onChange]);
|
|
313
|
+
var handleOnFocus = (0, React.useCallback)(function (event) {
|
|
314
|
+
onFocus && onFocus(event);
|
|
315
|
+
setState({
|
|
316
|
+
isFilterInputFocused: true
|
|
317
|
+
});
|
|
318
|
+
}, [setState, onFocus]);
|
|
319
|
+
var handleOnBlur = (0, React.useCallback)(function (event) {
|
|
320
|
+
onBlur && onBlur(event);
|
|
321
|
+
setState({
|
|
322
|
+
isFilterInputFocused: false
|
|
306
323
|
});
|
|
307
|
-
}, [setState]);
|
|
324
|
+
}, [setState, onBlur]);
|
|
308
325
|
return /*#__PURE__*/React.createElement(_Input.default, _extends({}, props, {
|
|
309
326
|
value: state.filterQuery,
|
|
310
|
-
onChange:
|
|
327
|
+
onChange: handleOnChange,
|
|
328
|
+
onFocus: handleOnFocus,
|
|
329
|
+
onBlur: handleOnBlur
|
|
311
330
|
}));
|
|
312
331
|
};
|
|
313
332
|
|
|
@@ -353,7 +372,8 @@ var Menu = function Menu(_ref4) {
|
|
|
353
372
|
var _useState = (0, React.useState)({
|
|
354
373
|
selectionIndex: 0,
|
|
355
374
|
filterQuery: "",
|
|
356
|
-
filteredItems: null
|
|
375
|
+
filteredItems: null,
|
|
376
|
+
isFilterInputFocused: false
|
|
357
377
|
}),
|
|
358
378
|
state = _useState[0],
|
|
359
379
|
setState = _useState[1];
|
package/commonjs/Menu/styles.js
CHANGED
|
@@ -35,15 +35,17 @@ var MenuItemContainer = (0, _styledComponents.default)(_Box.default).withConfig(
|
|
|
35
35
|
}, function (props) {
|
|
36
36
|
return (0, _styledComponents.css)(["", ";"], props.theme.typography[200]);
|
|
37
37
|
}, function (props) {
|
|
38
|
-
return props.active && !props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";"], function (props) {
|
|
38
|
+
return props.active && !props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";.Icon-svg{color:", ";}"], function (props) {
|
|
39
39
|
return props.theme.colors.text.inverse;
|
|
40
|
-
}, props.theme.colors.listItem.background.selected)
|
|
40
|
+
}, props.theme.colors.listItem.background.selected, function (props) {
|
|
41
|
+
return props.theme.colors.text.inverse;
|
|
42
|
+
});
|
|
41
43
|
}, function (props) {
|
|
42
44
|
return props.selected && !props.isCheckboxOrRadio && (0, _styledComponents.css)(["font-weight:", ";"], function (props) {
|
|
43
45
|
return props.theme.fontWeights.semibold;
|
|
44
46
|
});
|
|
45
47
|
}, function (props) {
|
|
46
|
-
return !props.disabled && (0, _styledComponents.css)(["&:focus,&:hover{color:", ";background-color:", ";}"], function (props) {
|
|
48
|
+
return !props.disabled && (0, _styledComponents.css)(["&:focus,&:hover{color:", ";background-color:", ";.Icon-svg{color:unset;}}"], function (props) {
|
|
47
49
|
return props.theme.colors.text.body;
|
|
48
50
|
}, function (props) {
|
|
49
51
|
return props.theme.colors.listItem.background.hover;
|
package/lib/Collapsible/index.js
CHANGED
|
@@ -104,6 +104,7 @@ var Panel = function Panel(_ref3) {
|
|
|
104
104
|
}
|
|
105
105
|
}, [isOpen]);
|
|
106
106
|
return /*#__PURE__*/React.createElement(CollapsingBox, _extends({
|
|
107
|
+
hasShadow: collapsedHeight || openHeight > 0,
|
|
107
108
|
scrollable: isOpen,
|
|
108
109
|
maxHeight: isOpen ? maxHeight : collapsedHeight,
|
|
109
110
|
minHeight: collapsedHeight,
|
|
@@ -3,15 +3,13 @@ import Box from "../Box";
|
|
|
3
3
|
export var CollapsingBox = styled(Box).withConfig({
|
|
4
4
|
displayName: "styles__CollapsingBox",
|
|
5
5
|
componentId: "sc-1xvfbl7-0"
|
|
6
|
-
})(["transition:max-height ", " ", ";will-change:max-height;position:relative;overflow:auto;
|
|
6
|
+
})(["transition:max-height ", " ", ";will-change:max-height;position:relative;overflow:auto;", ""], function (p) {
|
|
7
7
|
return p.theme.duration.medium;
|
|
8
8
|
}, function (p) {
|
|
9
9
|
return p.theme.easing.ease_inout;
|
|
10
|
-
}, function (p) {
|
|
11
|
-
return p.theme.colors.neutral[100];
|
|
12
|
-
}, function (p) {
|
|
13
|
-
return p.theme.colors.neutral[100];
|
|
14
10
|
}, function (_ref) {
|
|
15
|
-
var
|
|
16
|
-
|
|
11
|
+
var hasShadow = _ref.hasShadow,
|
|
12
|
+
theme = _ref.theme,
|
|
13
|
+
scrollable = _ref.scrollable;
|
|
14
|
+
return hasShadow ? "background: /* Shadow covers */ linear-gradient(\n transparent 30%,\n rgba(255, 255, 255, 0)\n ),\n linear-gradient(rgba(255, 255, 255, 0), transparent 70%) 0 100%,\n /* Shadows */\n radial-gradient(\n farthest-side at 50% 0,\n rgb(39 51 51 / 5%),\n rgba(0, 0, 0, 0)\n ),\n radial-gradient(\n farthest-side at 50% 100%,\n rgb(39 51 51 / 5%),\n rgba(0, 0, 0, 0)\n )\n 0 100%;\n background-repeat: no-repeat;\n background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;\n background-attachment: local, local, scroll, scroll;\n " + (scrollable ? "overflow: auto" : "overflow: hidden") + ";" : "";
|
|
17
15
|
});
|
package/lib/Menu/hooks.js
CHANGED
|
@@ -13,7 +13,8 @@ export var MenuContext = /*#__PURE__*/createContext({
|
|
|
13
13
|
state: {
|
|
14
14
|
selectionIndex: 0,
|
|
15
15
|
filterQuery: "",
|
|
16
|
-
filteredItems: null
|
|
16
|
+
filteredItems: null,
|
|
17
|
+
isFilterInputFocused: false
|
|
17
18
|
},
|
|
18
19
|
setState: function setState() {},
|
|
19
20
|
selectCallbacks: {
|
|
@@ -59,7 +60,8 @@ export function useMenuKeyDown() {
|
|
|
59
60
|
_useContext$state = _useContext.state,
|
|
60
61
|
filterQuery = _useContext$state.filterQuery,
|
|
61
62
|
selectionIndex = _useContext$state.selectionIndex,
|
|
62
|
-
filteredItems = _useContext$state.filteredItems
|
|
63
|
+
filteredItems = _useContext$state.filteredItems,
|
|
64
|
+
isFilterInputFocused = _useContext$state.isFilterInputFocused;
|
|
63
65
|
|
|
64
66
|
var _useContext2 = useContext(MenuButtonContext),
|
|
65
67
|
closePopout = _useContext2.closePopout,
|
|
@@ -118,8 +120,15 @@ export function useMenuKeyDown() {
|
|
|
118
120
|
var key = event.key;
|
|
119
121
|
|
|
120
122
|
switch (key) {
|
|
121
|
-
case "Enter":
|
|
122
123
|
case " ":
|
|
124
|
+
if (isFilterInputFocused) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// falls through
|
|
129
|
+
// eslint-disable-next-line no-fallthrough
|
|
130
|
+
|
|
131
|
+
case "Enter":
|
|
123
132
|
var selected = items[selectionIndex];
|
|
124
133
|
|
|
125
134
|
if (selected) {
|
package/lib/Menu/index.js
CHANGED
|
@@ -258,18 +258,37 @@ export var MenuDivider = function MenuDivider(props) {
|
|
|
258
258
|
};
|
|
259
259
|
|
|
260
260
|
var MenuFilterInput = function MenuFilterInput(props) {
|
|
261
|
+
var onChange = props.onChange,
|
|
262
|
+
onFocus = props.onFocus,
|
|
263
|
+
onBlur = props.onBlur;
|
|
264
|
+
|
|
261
265
|
var _useContext3 = useContext(MenuContext),
|
|
262
266
|
state = _useContext3.state,
|
|
263
267
|
setState = _useContext3.setState;
|
|
264
268
|
|
|
265
|
-
var
|
|
266
|
-
|
|
267
|
-
|
|
269
|
+
var handleOnChange = useCallback(function (event, value) {
|
|
270
|
+
onChange && onChange(event, value);
|
|
271
|
+
setState({
|
|
272
|
+
filterQuery: value
|
|
273
|
+
});
|
|
274
|
+
}, [setState, onChange]);
|
|
275
|
+
var handleOnFocus = useCallback(function (event) {
|
|
276
|
+
onFocus && onFocus(event);
|
|
277
|
+
setState({
|
|
278
|
+
isFilterInputFocused: true
|
|
279
|
+
});
|
|
280
|
+
}, [setState, onFocus]);
|
|
281
|
+
var handleOnBlur = useCallback(function (event) {
|
|
282
|
+
onBlur && onBlur(event);
|
|
283
|
+
setState({
|
|
284
|
+
isFilterInputFocused: false
|
|
268
285
|
});
|
|
269
|
-
}, [setState]);
|
|
286
|
+
}, [setState, onBlur]);
|
|
270
287
|
return /*#__PURE__*/React.createElement(Input, _extends({}, props, {
|
|
271
288
|
value: state.filterQuery,
|
|
272
|
-
onChange:
|
|
289
|
+
onChange: handleOnChange,
|
|
290
|
+
onFocus: handleOnFocus,
|
|
291
|
+
onBlur: handleOnBlur
|
|
273
292
|
}));
|
|
274
293
|
};
|
|
275
294
|
|
|
@@ -315,7 +334,8 @@ export var Menu = function Menu(_ref4) {
|
|
|
315
334
|
var _useState = useState({
|
|
316
335
|
selectionIndex: 0,
|
|
317
336
|
filterQuery: "",
|
|
318
|
-
filteredItems: null
|
|
337
|
+
filteredItems: null,
|
|
338
|
+
isFilterInputFocused: false
|
|
319
339
|
}),
|
|
320
340
|
state = _useState[0],
|
|
321
341
|
setState = _useState[1];
|
package/lib/Menu/styles.js
CHANGED
|
@@ -21,15 +21,17 @@ export var MenuItemContainer = styled(Box).withConfig({
|
|
|
21
21
|
}, function (props) {
|
|
22
22
|
return css(["", ";"], props.theme.typography[200]);
|
|
23
23
|
}, function (props) {
|
|
24
|
-
return props.active && !props.disabled && css(["color:", ";background-color:", ";"], function (props) {
|
|
24
|
+
return props.active && !props.disabled && css(["color:", ";background-color:", ";.Icon-svg{color:", ";}"], function (props) {
|
|
25
25
|
return props.theme.colors.text.inverse;
|
|
26
|
-
}, props.theme.colors.listItem.background.selected)
|
|
26
|
+
}, props.theme.colors.listItem.background.selected, function (props) {
|
|
27
|
+
return props.theme.colors.text.inverse;
|
|
28
|
+
});
|
|
27
29
|
}, function (props) {
|
|
28
30
|
return props.selected && !props.isCheckboxOrRadio && css(["font-weight:", ";"], function (props) {
|
|
29
31
|
return props.theme.fontWeights.semibold;
|
|
30
32
|
});
|
|
31
33
|
}, function (props) {
|
|
32
|
-
return !props.disabled && css(["&:focus,&:hover{color:", ";background-color:", ";}"], function (props) {
|
|
34
|
+
return !props.disabled && css(["&:focus,&:hover{color:", ";background-color:", ";.Icon-svg{color:unset;}}"], function (props) {
|
|
33
35
|
return props.theme.colors.text.body;
|
|
34
36
|
}, function (props) {
|
|
35
37
|
return props.theme.colors.listItem.background.hover;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/racine",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"__flow__",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@storybook/react": "^6.1.11",
|
|
110
110
|
"@storybook/theming": "^6.1.11",
|
|
111
111
|
"@testing-library/react": "^11.2.2",
|
|
112
|
-
"@testing-library/user-event": "^
|
|
112
|
+
"@testing-library/user-event": "^13.0.0",
|
|
113
113
|
"babel-core": "^7.0.0-bridge",
|
|
114
114
|
"babel-eslint": "10.1.0",
|
|
115
115
|
"babel-jest": "26.1.0",
|