@transferwise/components 46.1.0 → 46.2.0
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/README.md +3 -5
- package/build/index.esm.js +44 -23
- package/build/index.esm.js.map +1 -1
- package/build/index.js +44 -23
- package/build/index.js.map +1 -1
- package/build/main.css +5494 -1
- package/build/styles/accordion/Accordion.css +60 -1
- package/build/styles/actionButton/ActionButton.css +53 -1
- package/build/styles/avatar/Avatar.css +205 -1
- package/build/styles/badge/Badge.css +68 -1
- package/build/styles/button/Button.css +20 -1
- package/build/styles/card/Card.css +100 -1
- package/build/styles/checkboxButton/CheckboxButton.css +24 -1
- package/build/styles/chips/Chip.css +190 -1
- package/build/styles/circularButton/CircularButton.css +211 -1
- package/build/styles/common/Option/Option.css +100 -1
- package/build/styles/common/RadioButton/RadioButton.css +4 -1
- package/build/styles/common/bottomSheet/BottomSheet.css +53 -1
- package/build/styles/common/card/Card.css +49 -1
- package/build/styles/common/closeButton/CloseButton.css +79 -1
- package/build/styles/common/panel/Panel.css +73 -1
- package/build/styles/criticalBanner/CriticalCommsBanner.css +76 -1
- package/build/styles/dateInput/DateInput.css +3 -1
- package/build/styles/dateLookup/DateLookup.css +98 -1
- package/build/styles/dateLookup/dateTrigger/DateTrigger.css +68 -1
- package/build/styles/decision/Decision.css +93 -1
- package/build/styles/definitionList/DefinitionList.css +53 -1
- package/build/styles/dimmer/Dimmer.css +70 -1
- package/build/styles/drawer/Drawer.css +100 -1
- package/build/styles/dropFade/DropFade.css +19 -1
- package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -1
- package/build/styles/emphasis/Emphasis.css +31 -1
- package/build/styles/flowNavigation/FlowNavigation.css +72 -1
- package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +21 -1
- package/build/styles/flowNavigation/backButton/BackButton.css +32 -1
- package/build/styles/header/Header.css +28 -1
- package/build/styles/image/Image.css +13 -1
- package/build/styles/info/Info.css +32 -1
- package/build/styles/inputs/Input.css +105 -1
- package/build/styles/inputs/InputGroup.css +62 -1
- package/build/styles/inputs/SelectInput.css +374 -1
- package/build/styles/inputs/TextArea.css +109 -1
- package/build/styles/instructionsList/InstructionsList.css +22 -1
- package/build/styles/link/Link.css +15 -1
- package/build/styles/listItem/ListItem.css +6 -1
- package/build/styles/loader/Loader.css +313 -1
- package/build/styles/logo/Logo.css +26 -1
- package/build/styles/main.css +5494 -1
- package/build/styles/modal/Modal.css +155 -1
- package/build/styles/moneyInput/MoneyInput.css +66 -1
- package/build/styles/navigationOption/NavigationOption.css +69 -1
- package/build/styles/navigationOptionsList/NavigationOptionsList.css +13 -1
- package/build/styles/nudge/Nudge.css +179 -1
- package/build/styles/overlayHeader/OverlayHeader.css +15 -1
- package/build/styles/phoneNumberInput/PhoneNumberInput.css +23 -1
- package/build/styles/popover/Popover.css +43 -1
- package/build/styles/progress/Progress.css +43 -1
- package/build/styles/progressBar/ProgressBar.css +14 -1
- package/build/styles/promoCard/PromoCard.css +186 -1
- package/build/styles/section/Section.css +10 -1
- package/build/styles/select/Select.css +309 -1
- package/build/styles/slidingPanel/SlidingPanel.css +105 -1
- package/build/styles/snackbar/Snackbar.css +93 -1
- package/build/styles/statusIcon/StatusIcon.css +78 -1
- package/build/styles/stepper/Stepper.css +108 -1
- package/build/styles/summary/Summary.css +81 -1
- package/build/styles/switch/Switch.css +68 -1
- package/build/styles/tabs/Tabs.css +121 -1
- package/build/styles/tile/Tile.css +55 -1
- package/build/styles/tooltip/Tooltip.css +50 -1
- package/build/styles/typeahead/Typeahead.css +183 -1
- package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +9 -1
- package/build/styles/upload/Upload.css +15 -1
- package/build/styles/uploadInput/UploadInput.css +71 -1
- package/build/styles/uploadInput/uploadButton/UploadButton.css +49 -1
- package/build/styles/uploadInput/uploadItem/UploadItem.css +74 -1
- package/build/types/accordion/Accordion.d.ts +1 -0
- package/build/types/accordion/Accordion.d.ts.map +1 -1
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts +3 -0
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +6 -3
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts +2 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts +2 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/select/option/Option.d.ts.map +1 -1
- package/build/types/typeahead/util/highlight.d.ts +1 -1
- package/build/types/typeahead/util/highlight.d.ts.map +1 -1
- package/package.json +5 -11
- package/src/accordion/Accordion.css +60 -1
- package/src/accordion/Accordion.story.tsx +8 -0
- package/src/accordion/Accordion.tsx +2 -0
- package/src/accordion/AccordionItem/AccordionItem.tsx +5 -0
- package/src/actionButton/ActionButton.css +53 -1
- package/src/avatar/Avatar.css +205 -1
- package/src/badge/Badge.css +68 -1
- package/src/button/Button.css +20 -1
- package/src/card/Card.css +100 -1
- package/src/checkboxButton/CheckboxButton.css +24 -1
- package/src/chips/Chip.css +190 -1
- package/src/circularButton/CircularButton.css +211 -1
- package/src/common/Option/Option.css +100 -1
- package/src/common/RadioButton/RadioButton.css +4 -1
- package/src/common/bottomSheet/BottomSheet.css +53 -1
- package/src/common/card/Card.css +49 -1
- package/src/common/closeButton/CloseButton.css +79 -1
- package/src/common/panel/Panel.css +73 -1
- package/src/criticalBanner/CriticalCommsBanner.css +76 -1
- package/src/dateInput/DateInput.css +3 -1
- package/src/dateLookup/DateLookup.css +98 -1
- package/src/dateLookup/DateLookup.story.js +12 -8
- package/src/dateLookup/dateTrigger/DateTrigger.css +68 -1
- package/src/decision/Decision.css +93 -1
- package/src/definitionList/DefinitionList.css +53 -1
- package/src/dimmer/Dimmer.css +70 -1
- package/src/drawer/Drawer.css +100 -1
- package/src/dropFade/DropFade.css +19 -1
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -1
- package/src/emphasis/Emphasis.css +31 -1
- package/src/flowNavigation/FlowNavigation.css +72 -1
- package/src/flowNavigation/animatedLabel/AnimatedLabel.css +21 -1
- package/src/flowNavigation/backButton/BackButton.css +32 -1
- package/src/header/Header.css +28 -1
- package/src/image/Image.css +13 -1
- package/src/info/Info.css +32 -1
- package/src/inputs/Input.css +105 -1
- package/src/inputs/InputGroup.css +62 -1
- package/src/inputs/SelectInput.css +374 -1
- package/src/inputs/SelectInput.spec.tsx +52 -3
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/inputs/SelectInput.tsx +30 -15
- package/src/inputs/TextArea.css +109 -1
- package/src/inputs/_BottomSheet.tsx +3 -0
- package/src/inputs/_Popover.tsx +3 -0
- package/src/instructionsList/InstructionsList.css +22 -1
- package/src/link/Link.css +15 -1
- package/src/listItem/ListItem.css +6 -1
- package/src/loader/Loader.css +313 -1
- package/src/logo/Logo.css +26 -1
- package/src/main.css +5494 -1
- package/src/modal/Modal.css +155 -1
- package/src/moneyInput/MoneyInput.css +66 -1
- package/src/moneyInput/MoneyInput.js +3 -1
- package/src/moneyInput/MoneyInput.spec.js +4 -1
- package/src/navigationOption/NavigationOption.css +69 -1
- package/src/navigationOptionsList/NavigationOptionsList.css +13 -1
- package/src/nudge/Nudge.css +179 -1
- package/src/overlayHeader/OverlayHeader.css +15 -1
- package/src/phoneNumberInput/PhoneNumberInput.css +23 -1
- package/src/popover/Popover.css +43 -1
- package/src/progress/Progress.css +43 -1
- package/src/progressBar/ProgressBar.css +14 -1
- package/src/promoCard/PromoCard.css +186 -1
- package/src/section/Section.css +10 -1
- package/src/select/Select.css +309 -1
- package/src/select/Select.less +1 -8
- package/src/select/option/Option.spec.js +3 -21
- package/src/select/option/Option.tsx +2 -7
- package/src/slidingPanel/SlidingPanel.css +105 -1
- package/src/snackbar/Snackbar.css +93 -1
- package/src/statusIcon/StatusIcon.css +78 -1
- package/src/stepper/Stepper.css +108 -1
- package/src/summary/Summary.css +81 -1
- package/src/switch/Switch.css +68 -1
- package/src/tabs/Tabs.css +121 -1
- package/src/tile/Tile.css +55 -1
- package/src/tooltip/Tooltip.css +50 -1
- package/src/typeahead/Typeahead.css +183 -1
- package/src/typeahead/typeaheadOption/TypeaheadOption.css +9 -1
- package/src/typeahead/typeaheadOption/TypeaheadOption.js +3 -3
- package/src/typeahead/util/highlight.js +1 -1
- package/src/upload/Upload.css +15 -1
- package/src/uploadInput/UploadInput.css +71 -1
- package/src/uploadInput/uploadButton/UploadButton.css +49 -1
- package/src/uploadInput/uploadItem/UploadItem.css +74 -1
|
@@ -1 +1,374 @@
|
|
|
1
|
-
.np-bottom-sheet-v2-container
|
|
1
|
+
.np-bottom-sheet-v2-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
z-index: 1060;
|
|
4
|
+
}
|
|
5
|
+
.np-bottom-sheet-v2-backdrop-container--enter,
|
|
6
|
+
.np-bottom-sheet-v2-backdrop-container--leave {
|
|
7
|
+
transition-property: opacity;
|
|
8
|
+
transition-timing-function: ease-out;
|
|
9
|
+
transition-duration: 300ms;
|
|
10
|
+
}
|
|
11
|
+
.np-bottom-sheet-v2-backdrop-container--enter-from,
|
|
12
|
+
.np-bottom-sheet-v2-backdrop-container--leave-to {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
}
|
|
15
|
+
.np-bottom-sheet-v2-backdrop {
|
|
16
|
+
position: fixed;
|
|
17
|
+
inset: 0px;
|
|
18
|
+
background-color: #37517e;
|
|
19
|
+
background-color: var(--color-content-primary);
|
|
20
|
+
opacity: 0.4;
|
|
21
|
+
}
|
|
22
|
+
.np-bottom-sheet-v2 {
|
|
23
|
+
position: fixed;
|
|
24
|
+
inset: 0px;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
justify-content: flex-end;
|
|
28
|
+
padding-left: 8px;
|
|
29
|
+
padding-left: var(--size-8);
|
|
30
|
+
padding-right: 8px;
|
|
31
|
+
padding-right: var(--size-8);
|
|
32
|
+
padding-top: 64px;
|
|
33
|
+
padding-top: var(--size-64);
|
|
34
|
+
}
|
|
35
|
+
.np-bottom-sheet-v2-content {
|
|
36
|
+
max-height: 100%;
|
|
37
|
+
}
|
|
38
|
+
.np-bottom-sheet-v2-content--enter,
|
|
39
|
+
.np-bottom-sheet-v2-content--leave {
|
|
40
|
+
transition-property: transform;
|
|
41
|
+
transition-timing-function: ease-out;
|
|
42
|
+
transition-duration: 300ms;
|
|
43
|
+
}
|
|
44
|
+
@media (prefers-reduced-motion: reduce) {
|
|
45
|
+
.np-bottom-sheet-v2-content--enter,
|
|
46
|
+
.np-bottom-sheet-v2-content--leave {
|
|
47
|
+
transition-property: opacity;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
51
|
+
.np-bottom-sheet-v2-content--enter-from,
|
|
52
|
+
.np-bottom-sheet-v2-content--leave-to {
|
|
53
|
+
transform: translateY(100%);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
@media (prefers-reduced-motion: reduce) {
|
|
57
|
+
.np-bottom-sheet-v2-content--enter-from,
|
|
58
|
+
.np-bottom-sheet-v2-content--leave-to {
|
|
59
|
+
opacity: 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
.np-bottom-sheet-v2-content-inner-container {
|
|
63
|
+
display: flex;
|
|
64
|
+
height: 100%;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
border-top-left-radius: 32px;
|
|
67
|
+
/* TODO: Tokenize */
|
|
68
|
+
border-top-right-radius: 32px;
|
|
69
|
+
/* TODO: Tokenize */
|
|
70
|
+
background-color: #ffffff;
|
|
71
|
+
background-color: var(--color-background-elevated);
|
|
72
|
+
box-shadow: 0 0 40px rgba(69, 71, 69, 0.2);
|
|
73
|
+
}
|
|
74
|
+
.np-bottom-sheet-v2-content-inner-container:focus {
|
|
75
|
+
outline: none;
|
|
76
|
+
}
|
|
77
|
+
.np-bottom-sheet-v2-header {
|
|
78
|
+
align-self: flex-end;
|
|
79
|
+
padding: 16px;
|
|
80
|
+
padding: var(--size-16);
|
|
81
|
+
}
|
|
82
|
+
.np-bottom-sheet-v2-content-inner {
|
|
83
|
+
padding-top: 0px;
|
|
84
|
+
display: grid;
|
|
85
|
+
grid-row-gap: 8px;
|
|
86
|
+
grid-row-gap: var(--size-8);
|
|
87
|
+
row-gap: 8px;
|
|
88
|
+
row-gap: var(--size-8);
|
|
89
|
+
overflow-y: auto;
|
|
90
|
+
grid-template-rows: repeat(1, minmax(0, 1fr));
|
|
91
|
+
}
|
|
92
|
+
.np-bottom-sheet-v2-content-inner--has-title {
|
|
93
|
+
grid-template-rows: auto 1fr;
|
|
94
|
+
}
|
|
95
|
+
.np-bottom-sheet-v2-content-inner--padding-md {
|
|
96
|
+
padding: 16px;
|
|
97
|
+
padding: var(--size-16);
|
|
98
|
+
}
|
|
99
|
+
.np-bottom-sheet-v2-title {
|
|
100
|
+
color: #37517e;
|
|
101
|
+
color: var(--color-content-primary);
|
|
102
|
+
}
|
|
103
|
+
.np-bottom-sheet-v2-body {
|
|
104
|
+
color: #5d7079;
|
|
105
|
+
color: var(--color-content-secondary);
|
|
106
|
+
}
|
|
107
|
+
.np-button-input {
|
|
108
|
+
display: inline-grid;
|
|
109
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
110
|
+
align-content: center;
|
|
111
|
+
border-radius: 10px;
|
|
112
|
+
border-radius: var(--size-10);
|
|
113
|
+
text-align: start;
|
|
114
|
+
}
|
|
115
|
+
.np-popover-v2-container {
|
|
116
|
+
z-index: 1060;
|
|
117
|
+
display: flex;
|
|
118
|
+
max-height: var(--max-height);
|
|
119
|
+
width: var(--width);
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
border-radius: 10px;
|
|
123
|
+
border-radius: var(--radius-small);
|
|
124
|
+
background-color: #ffffff;
|
|
125
|
+
background-color: var(--color-background-elevated);
|
|
126
|
+
box-shadow: 0 0 40px rgba(69, 71, 69, 0.2);
|
|
127
|
+
}
|
|
128
|
+
.np-popover-v2-container--size-md {
|
|
129
|
+
min-width: 20rem;
|
|
130
|
+
}
|
|
131
|
+
.np-popover-v2-container--size-lg {
|
|
132
|
+
min-width: 24rem;
|
|
133
|
+
}
|
|
134
|
+
.np-popover-v2-container:focus {
|
|
135
|
+
outline: none;
|
|
136
|
+
}
|
|
137
|
+
.np-popover-v2 {
|
|
138
|
+
display: grid;
|
|
139
|
+
grid-row-gap: 8px;
|
|
140
|
+
grid-row-gap: var(--size-8);
|
|
141
|
+
row-gap: 8px;
|
|
142
|
+
row-gap: var(--size-8);
|
|
143
|
+
overflow-y: auto;
|
|
144
|
+
grid-template-rows: repeat(1, minmax(0, 1fr));
|
|
145
|
+
}
|
|
146
|
+
.np-popover-v2--has-title {
|
|
147
|
+
grid-template-rows: auto 1fr;
|
|
148
|
+
}
|
|
149
|
+
.np-popover-v2--padding-md {
|
|
150
|
+
padding: 16px;
|
|
151
|
+
padding: var(--size-16);
|
|
152
|
+
}
|
|
153
|
+
.np-popover-v2-title {
|
|
154
|
+
color: #37517e;
|
|
155
|
+
color: var(--color-content-primary);
|
|
156
|
+
}
|
|
157
|
+
.np-popover-v2-content {
|
|
158
|
+
color: #5d7079;
|
|
159
|
+
color: var(--color-content-secondary);
|
|
160
|
+
}
|
|
161
|
+
.np-select-input-placeholder {
|
|
162
|
+
overflow: hidden;
|
|
163
|
+
text-overflow: ellipsis;
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
color: #768e9c;
|
|
166
|
+
color: var(--color-content-tertiary);
|
|
167
|
+
}
|
|
168
|
+
.np-select-input-options-container {
|
|
169
|
+
display: flex;
|
|
170
|
+
height: 100%;
|
|
171
|
+
flex-direction: column;
|
|
172
|
+
}
|
|
173
|
+
.np-select-input-options-container:focus {
|
|
174
|
+
outline: none;
|
|
175
|
+
}
|
|
176
|
+
@media (min-width: 576px) {
|
|
177
|
+
.np-select-input-options-container {
|
|
178
|
+
max-height: 28rem /* 448px */;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
.np-select-input-options-status {
|
|
182
|
+
display: flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
-moz-column-gap: 8px;
|
|
185
|
+
column-gap: 8px;
|
|
186
|
+
-moz-column-gap: var(--size-8);
|
|
187
|
+
column-gap: var(--size-8);
|
|
188
|
+
padding: 8px 24px 0px;
|
|
189
|
+
padding: var(--size-8) var(--size-24) 0px;
|
|
190
|
+
}
|
|
191
|
+
.np-select-input-options-status-icon {
|
|
192
|
+
padding: 0 4px;
|
|
193
|
+
padding: 0 var(--size-4);
|
|
194
|
+
color: #768e9c;
|
|
195
|
+
color: var(--color-content-tertiary);
|
|
196
|
+
}
|
|
197
|
+
.np-select-input-query-container {
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
padding: 8px;
|
|
201
|
+
padding: var(--size-8);
|
|
202
|
+
}
|
|
203
|
+
.np-select-input-listbox-container {
|
|
204
|
+
position: relative;
|
|
205
|
+
height: var(--initial-height);
|
|
206
|
+
scroll-padding-top: 8px;
|
|
207
|
+
scroll-padding-top: var(--size-8);
|
|
208
|
+
scroll-padding-bottom: 8px;
|
|
209
|
+
scroll-padding-bottom: var(--size-8);
|
|
210
|
+
overflow-y: auto;
|
|
211
|
+
}
|
|
212
|
+
@media (min-width: 576px) {
|
|
213
|
+
.np-select-input-listbox-container {
|
|
214
|
+
height: auto;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
.np-select-input-listbox-container--has-group {
|
|
218
|
+
scroll-padding-top: 32px;
|
|
219
|
+
scroll-padding-top: var(--size-32);
|
|
220
|
+
}
|
|
221
|
+
.np-select-input-listbox {
|
|
222
|
+
border-radius: 10px;
|
|
223
|
+
border-radius: var(--radius-small);
|
|
224
|
+
padding: 8px;
|
|
225
|
+
padding: var(--size-8);
|
|
226
|
+
--ring-outline-offset: calc(-1 * var(--ring-outline-width));
|
|
227
|
+
}
|
|
228
|
+
.np-select-input-listbox:focus {
|
|
229
|
+
outline: none;
|
|
230
|
+
}
|
|
231
|
+
.np-select-input-listbox:focus-visible {
|
|
232
|
+
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
233
|
+
outline-offset: var(--ring-outline-offset);
|
|
234
|
+
}
|
|
235
|
+
.np-select-input-separator-item {
|
|
236
|
+
margin: 8px;
|
|
237
|
+
margin: var(--size-8);
|
|
238
|
+
border-top-width: 1px;
|
|
239
|
+
}
|
|
240
|
+
.np-select-input-group-item--without-needle:first-child {
|
|
241
|
+
margin-top: calc(-1 * 8px);
|
|
242
|
+
margin-top: calc(-1 * var(--size-8));
|
|
243
|
+
}
|
|
244
|
+
.np-select-input-group-item-header {
|
|
245
|
+
position: sticky;
|
|
246
|
+
top: 0px;
|
|
247
|
+
z-index: 10;
|
|
248
|
+
background-color: #ffffff;
|
|
249
|
+
background-color: var(--color-background-elevated);
|
|
250
|
+
padding: 8px 16px 4px;
|
|
251
|
+
padding: var(--size-8) var(--size-16) var(--size-4);
|
|
252
|
+
color: #5d7079;
|
|
253
|
+
color: var(--color-content-secondary);
|
|
254
|
+
}
|
|
255
|
+
.np-select-input-option-container {
|
|
256
|
+
display: flex;
|
|
257
|
+
cursor: default;
|
|
258
|
+
-webkit-user-select: none;
|
|
259
|
+
-moz-user-select: none;
|
|
260
|
+
user-select: none;
|
|
261
|
+
align-items: center;
|
|
262
|
+
-moz-column-gap: 8px;
|
|
263
|
+
column-gap: 8px;
|
|
264
|
+
-moz-column-gap: var(--size-8);
|
|
265
|
+
column-gap: var(--size-8);
|
|
266
|
+
border-radius: 10px;
|
|
267
|
+
border-radius: var(--radius-small);
|
|
268
|
+
padding: 12px 16px;
|
|
269
|
+
padding: var(--size-12) var(--size-16);
|
|
270
|
+
color: var(--color-interactive-primary);
|
|
271
|
+
}
|
|
272
|
+
.np-select-input-option-container--active {
|
|
273
|
+
box-shadow: inset 0 0 0 1px #c9cbce;
|
|
274
|
+
box-shadow: inset 0 0 0 1px var(--color-interactive-secondary);
|
|
275
|
+
}
|
|
276
|
+
.np-select-input-option-container--disabled {
|
|
277
|
+
opacity: 0.45;
|
|
278
|
+
}
|
|
279
|
+
.np-select-input-option-check--not-selected {
|
|
280
|
+
visibility: hidden;
|
|
281
|
+
}
|
|
282
|
+
.np-select-input-option {
|
|
283
|
+
flex: 1;
|
|
284
|
+
}
|
|
285
|
+
.np-select-input-option-content-container {
|
|
286
|
+
display: flex;
|
|
287
|
+
align-items: center;
|
|
288
|
+
-moz-column-gap: 8px;
|
|
289
|
+
column-gap: 8px;
|
|
290
|
+
-moz-column-gap: var(--size-8);
|
|
291
|
+
column-gap: var(--size-8);
|
|
292
|
+
color: #37517e;
|
|
293
|
+
color: var(--color-content-primary);
|
|
294
|
+
}
|
|
295
|
+
.np-select-input-option-content-icon {
|
|
296
|
+
display: flex;
|
|
297
|
+
}
|
|
298
|
+
.np-select-input-option-content-icon--not-within-trigger {
|
|
299
|
+
align-self: flex-start;
|
|
300
|
+
}
|
|
301
|
+
.np-select-input-option-content-text {
|
|
302
|
+
display: flex;
|
|
303
|
+
flex: 1;
|
|
304
|
+
flex-direction: column;
|
|
305
|
+
overflow: hidden;
|
|
306
|
+
}
|
|
307
|
+
.np-select-input-option-content-text-primary {
|
|
308
|
+
font: inherit;
|
|
309
|
+
}
|
|
310
|
+
.np-select-input-option-content-text-secondary {
|
|
311
|
+
color: #5d7079;
|
|
312
|
+
color: var(--color-content-secondary);
|
|
313
|
+
}
|
|
314
|
+
.np-select-input-option-content-text-within-trigger {
|
|
315
|
+
overflow: hidden;
|
|
316
|
+
text-overflow: ellipsis;
|
|
317
|
+
white-space: nowrap;
|
|
318
|
+
}
|
|
319
|
+
.np-select-input-option-content-text-line-1 > :not([hidden]) ~ :not([hidden]) {
|
|
320
|
+
margin-right: 8px;
|
|
321
|
+
margin-right: var(--size-8);
|
|
322
|
+
margin-left: 8px;
|
|
323
|
+
margin-left: var(--size-8);
|
|
324
|
+
}
|
|
325
|
+
.np-select-input-footer {
|
|
326
|
+
padding: 4px 24px 16px;
|
|
327
|
+
padding: var(--size-4) var(--size-24) var(--size-16);
|
|
328
|
+
}
|
|
329
|
+
.np-select-input-addon-container {
|
|
330
|
+
pointer-events: none;
|
|
331
|
+
margin-inline-start: 4px;
|
|
332
|
+
margin-inline-start: var(--size-4);
|
|
333
|
+
display: inline-flex;
|
|
334
|
+
align-items: center;
|
|
335
|
+
}
|
|
336
|
+
.np-select-input-addon-container > :not([hidden]) ~ :not([hidden]) {
|
|
337
|
+
margin-inline-start: 4px;
|
|
338
|
+
margin-inline-start: var(--size-4);
|
|
339
|
+
}
|
|
340
|
+
.np-select-input-addon {
|
|
341
|
+
border-width: 0;
|
|
342
|
+
background: none;
|
|
343
|
+
display: inline-flex;
|
|
344
|
+
height: 24px;
|
|
345
|
+
height: var(--size-24);
|
|
346
|
+
width: 24px;
|
|
347
|
+
width: var(--size-24);
|
|
348
|
+
align-items: center;
|
|
349
|
+
justify-content: center;
|
|
350
|
+
border-radius: 0.125rem /* 2px */;
|
|
351
|
+
/* TODO: Tokenize */
|
|
352
|
+
}
|
|
353
|
+
.np-select-input-addon--interactive {
|
|
354
|
+
pointer-events: auto;
|
|
355
|
+
color: #c9cbce;
|
|
356
|
+
color: var(--color-interactive-secondary);
|
|
357
|
+
}
|
|
358
|
+
.np-select-input-addon--interactive:hover {
|
|
359
|
+
color: #b5b7ba;
|
|
360
|
+
color: var(--color-interactive-secondary-hover);
|
|
361
|
+
}
|
|
362
|
+
.np-select-input-addon--interactive:focus {
|
|
363
|
+
outline: none;
|
|
364
|
+
}
|
|
365
|
+
.np-select-input-addon--interactive:focus-visible {
|
|
366
|
+
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
367
|
+
outline-offset: var(--ring-outline-offset);
|
|
368
|
+
}
|
|
369
|
+
.np-select-input-addon-separator {
|
|
370
|
+
height: 24px;
|
|
371
|
+
height: var(--size-24);
|
|
372
|
+
border-inline-start: 1px solid rgba(0,0,0,0.10196);
|
|
373
|
+
border-inline-start: 1px solid var(--color-border-neutral);
|
|
374
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { act, screen, within } from '@testing-library/react';
|
|
1
|
+
import { act, screen, waitFor, within } from '@testing-library/react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { render, mockMatchMedia, mockResizeObserver } from '../test-utils';
|
|
@@ -30,7 +30,7 @@ describe('SelectInput', () => {
|
|
|
30
30
|
{ type: 'option', value: 'USD' },
|
|
31
31
|
{ type: 'option', value: 'EUR' },
|
|
32
32
|
]}
|
|
33
|
-
renderFooter={({ normalizedQuery }) =>
|
|
33
|
+
renderFooter={({ queryNormalized: normalizedQuery }) =>
|
|
34
34
|
normalizedQuery != null ? (
|
|
35
35
|
<>Showing results for ‘{normalizedQuery}’</>
|
|
36
36
|
) : (
|
|
@@ -129,8 +129,57 @@ describe('SelectInput', () => {
|
|
|
129
129
|
expect(within(listbox).getByRole('option')).toBeInTheDocument();
|
|
130
130
|
|
|
131
131
|
const option = within(listbox).getAllByRole('option')[0];
|
|
132
|
-
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
133
|
+
await act(async () => {
|
|
134
|
+
userEvent.click(option);
|
|
135
|
+
});
|
|
133
136
|
|
|
134
137
|
expect(trigger).toHaveTextContent('EUR');
|
|
135
138
|
});
|
|
139
|
+
|
|
140
|
+
it('clears filter query on close', async () => {
|
|
141
|
+
const handleFilterChange = jest.fn();
|
|
142
|
+
|
|
143
|
+
render(
|
|
144
|
+
<SelectInput
|
|
145
|
+
items={[
|
|
146
|
+
{ type: 'option', value: 'USD' },
|
|
147
|
+
{ type: 'option', value: 'EUR' },
|
|
148
|
+
]}
|
|
149
|
+
filterable
|
|
150
|
+
onFilterChange={handleFilterChange}
|
|
151
|
+
/>,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const trigger = screen.getAllByRole('button')[0];
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
156
|
+
await act(async () => {
|
|
157
|
+
userEvent.tab();
|
|
158
|
+
userEvent.keyboard(' ');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(handleFilterChange).not.toHaveBeenCalled();
|
|
162
|
+
|
|
163
|
+
userEvent.keyboard(' x');
|
|
164
|
+
expect(handleFilterChange).toHaveBeenLastCalledWith({
|
|
165
|
+
query: ' x',
|
|
166
|
+
queryNormalized: 'x',
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
userEvent.keyboard('{Escape}');
|
|
170
|
+
await waitFor(() => {
|
|
171
|
+
expect(handleFilterChange).toHaveBeenLastCalledWith({
|
|
172
|
+
query: '',
|
|
173
|
+
queryNormalized: null,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
178
|
+
await act(async () => {
|
|
179
|
+
userEvent.click(trigger);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const listbox = screen.getByRole('listbox');
|
|
183
|
+
expect(within(listbox).getAllByRole('option')).toHaveLength(2);
|
|
184
|
+
});
|
|
136
185
|
});
|
|
@@ -266,7 +266,7 @@ export const Currencies: StoryObj<{
|
|
|
266
266
|
icon={<Flag code={currency.code} intrinsicSize={24} />}
|
|
267
267
|
/>
|
|
268
268
|
)}
|
|
269
|
-
renderFooter={({ resultsEmpty, normalizedQuery }) =>
|
|
269
|
+
renderFooter={({ resultsEmpty, queryNormalized: normalizedQuery }) =>
|
|
270
270
|
resultsEmpty && normalizedQuery != null && /^[a-z]{3}$/u.test(normalizedQuery) ? (
|
|
271
271
|
<>
|
|
272
272
|
It’s not possible use {normalizedQuery.toUpperCase()} yet.{' '}
|
|
@@ -138,7 +138,7 @@ export interface SelectInputProps<T = string> {
|
|
|
138
138
|
renderValue?: (value: NonNullable<T>, withinTrigger: boolean) => React.ReactNode;
|
|
139
139
|
renderFooter?: (args: {
|
|
140
140
|
resultsEmpty: boolean;
|
|
141
|
-
|
|
141
|
+
queryNormalized: string | null | undefined;
|
|
142
142
|
}) => React.ReactNode;
|
|
143
143
|
renderTrigger?: (args: {
|
|
144
144
|
content: React.ReactNode;
|
|
@@ -153,8 +153,8 @@ export interface SelectInputProps<T = string> {
|
|
|
153
153
|
disabled?: boolean;
|
|
154
154
|
size?: 'md' | 'lg';
|
|
155
155
|
className?: string;
|
|
156
|
+
onFilterChange?: (args: { query: string; queryNormalized: string | null }) => void;
|
|
156
157
|
onChange?: (value: T) => void;
|
|
157
|
-
onSearchChange?: (query: string) => void;
|
|
158
158
|
onClear?: () => void;
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -209,6 +209,8 @@ function SelectInputClearButton({ className, onClick }: SelectInputClearButtonPr
|
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
const noop = () => {};
|
|
213
|
+
|
|
212
214
|
export function SelectInput<T = string>({
|
|
213
215
|
name,
|
|
214
216
|
placeholder,
|
|
@@ -224,12 +226,21 @@ export function SelectInput<T = string>({
|
|
|
224
226
|
disabled,
|
|
225
227
|
size = 'md',
|
|
226
228
|
className,
|
|
229
|
+
onFilterChange = noop,
|
|
227
230
|
onChange,
|
|
228
|
-
onSearchChange,
|
|
229
231
|
onClear,
|
|
230
232
|
}: SelectInputProps<T>) {
|
|
231
233
|
const [open, setOpen] = useState(false);
|
|
232
234
|
|
|
235
|
+
const [filterQuery, _setFilterQuery] = useState('');
|
|
236
|
+
const setFilterQuery = useEffectEvent((query: string) => {
|
|
237
|
+
_setFilterQuery(query);
|
|
238
|
+
onFilterChange({
|
|
239
|
+
query,
|
|
240
|
+
queryNormalized: query ? searchableString(query) : null,
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
233
244
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
234
245
|
|
|
235
246
|
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
@@ -311,6 +322,11 @@ export function SelectInput<T = string>({
|
|
|
311
322
|
onClose={() => {
|
|
312
323
|
setOpen(false);
|
|
313
324
|
}}
|
|
325
|
+
onCloseEnd={() => {
|
|
326
|
+
if (filterQuery !== '') {
|
|
327
|
+
setFilterQuery('');
|
|
328
|
+
}
|
|
329
|
+
}}
|
|
314
330
|
>
|
|
315
331
|
<SelectInputOptions
|
|
316
332
|
items={items}
|
|
@@ -320,7 +336,8 @@ export function SelectInput<T = string>({
|
|
|
320
336
|
filterPlaceholder={filterPlaceholder}
|
|
321
337
|
searchInputRef={searchInputRef}
|
|
322
338
|
listboxRef={listboxRef}
|
|
323
|
-
|
|
339
|
+
filterQuery={filterQuery}
|
|
340
|
+
onFilterChange={setFilterQuery}
|
|
324
341
|
/>
|
|
325
342
|
</OptionsOverlay>
|
|
326
343
|
)}
|
|
@@ -407,7 +424,8 @@ interface SelectInputOptionsProps<T = string>
|
|
|
407
424
|
> {
|
|
408
425
|
searchInputRef: React.RefObject<HTMLInputElement>;
|
|
409
426
|
listboxRef: React.RefObject<HTMLDivElement>;
|
|
410
|
-
|
|
427
|
+
filterQuery: string;
|
|
428
|
+
onFilterChange: (query: string) => void;
|
|
411
429
|
}
|
|
412
430
|
|
|
413
431
|
function SelectInputOptions<T = string>({
|
|
@@ -418,19 +436,19 @@ function SelectInputOptions<T = string>({
|
|
|
418
436
|
filterPlaceholder,
|
|
419
437
|
searchInputRef,
|
|
420
438
|
listboxRef,
|
|
421
|
-
|
|
439
|
+
filterQuery,
|
|
440
|
+
onFilterChange,
|
|
422
441
|
}: SelectInputOptionsProps<T>) {
|
|
423
442
|
const intl = useIntl();
|
|
424
443
|
|
|
425
444
|
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
426
445
|
|
|
427
|
-
const [query, setQuery] = useState('');
|
|
428
446
|
const needle = useMemo(() => {
|
|
429
447
|
if (filterable) {
|
|
430
|
-
return
|
|
448
|
+
return filterQuery ? searchableString(filterQuery) : null;
|
|
431
449
|
}
|
|
432
450
|
return undefined;
|
|
433
|
-
}, [
|
|
451
|
+
}, [filterQuery, filterable]);
|
|
434
452
|
const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
|
|
435
453
|
|
|
436
454
|
const listboxContainerRef = useRef<HTMLDivElement>(null);
|
|
@@ -468,7 +486,7 @@ function SelectInputOptions<T = string>({
|
|
|
468
486
|
ref={searchInputRef}
|
|
469
487
|
shape="rectangle"
|
|
470
488
|
placeholder={filterPlaceholder}
|
|
471
|
-
value={
|
|
489
|
+
value={filterQuery}
|
|
472
490
|
aria-controls={listboxId}
|
|
473
491
|
aria-describedby={showStatus ? statusId : undefined}
|
|
474
492
|
onKeyDown={(event) => {
|
|
@@ -479,10 +497,7 @@ function SelectInputOptions<T = string>({
|
|
|
479
497
|
}
|
|
480
498
|
}}
|
|
481
499
|
onChange={(event) => {
|
|
482
|
-
|
|
483
|
-
if (onSearchChange) {
|
|
484
|
-
onSearchChange(event.currentTarget.value);
|
|
485
|
-
}
|
|
500
|
+
onFilterChange(event.currentTarget.value);
|
|
486
501
|
}}
|
|
487
502
|
/>
|
|
488
503
|
</div>
|
|
@@ -535,7 +550,7 @@ function SelectInputOptions<T = string>({
|
|
|
535
550
|
>
|
|
536
551
|
{renderFooter({
|
|
537
552
|
resultsEmpty,
|
|
538
|
-
|
|
553
|
+
queryNormalized: needle,
|
|
539
554
|
})}
|
|
540
555
|
</div>
|
|
541
556
|
</footer>
|