@transferwise/components 0.0.0-experimental-2a40639 → 0.0.0-experimental-12d074a
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/build/button/Button.js +18 -4
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +18 -4
- package/build/button/Button.mjs.map +1 -1
- package/build/main.css +3 -0
- package/build/styles/button/Button.css +3 -0
- package/build/styles/main.css +3 -0
- package/build/typeahead/Typeahead.js +1 -2
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +1 -2
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.js +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.mjs +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/button/Button.css +3 -0
- package/src/button/Button.less +6 -0
- package/src/button/Button.spec.js +42 -46
- package/src/button/Button.story.tsx +43 -20
- package/src/button/Button.tsx +21 -5
- package/src/button/__snapshots__/Button.spec.js.snap +43 -0
- package/src/main.css +3 -0
- package/src/typeahead/Typeahead.spec.js +6 -0
- package/src/typeahead/Typeahead.story.tsx +12 -9
- package/src/typeahead/Typeahead.tsx +16 -14
- package/src/typeahead/typeaheadInput/TypeaheadInput.spec.js +6 -0
- package/src/typeahead/typeaheadInput/TypeaheadInput.tsx +1 -1
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
exports[`Button alternative states renders as block if block is true 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<button
|
|
6
|
+
aria-busy="false"
|
|
7
|
+
aria-disabled="false"
|
|
6
8
|
aria-live="off"
|
|
7
9
|
class="btn btn-md np-btn np-btn-md btn-block np-btn-block btn-accent btn-priority-1"
|
|
8
10
|
type="button"
|
|
@@ -15,6 +17,8 @@ exports[`Button alternative states renders as block if block is true 1`] = `
|
|
|
15
17
|
exports[`Button by default renders a medium button of type accent and priority primary 1`] = `
|
|
16
18
|
<div>
|
|
17
19
|
<button
|
|
20
|
+
aria-busy="false"
|
|
21
|
+
aria-disabled="false"
|
|
18
22
|
aria-live="off"
|
|
19
23
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
20
24
|
type="button"
|
|
@@ -27,6 +31,7 @@ exports[`Button by default renders a medium button of type accent and priority p
|
|
|
27
31
|
exports[`Button by default renders an anchor tag with button styles of type accent and priority primary 1`] = `
|
|
28
32
|
<div>
|
|
29
33
|
<a
|
|
34
|
+
aria-busy="false"
|
|
30
35
|
aria-live="off"
|
|
31
36
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
32
37
|
href="#"
|
|
@@ -39,6 +44,8 @@ exports[`Button by default renders an anchor tag with button styles of type acce
|
|
|
39
44
|
exports[`Button deprecated types renders danger as negative buttons with priority secondary and logs a warning 1`] = `
|
|
40
45
|
<div>
|
|
41
46
|
<button
|
|
47
|
+
aria-busy="false"
|
|
48
|
+
aria-disabled="false"
|
|
42
49
|
aria-live="off"
|
|
43
50
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
44
51
|
type="button"
|
|
@@ -51,6 +58,8 @@ exports[`Button deprecated types renders danger as negative buttons with priorit
|
|
|
51
58
|
exports[`Button deprecated types renders link as accent buttons with priority tertiary and logs a warning 1`] = `
|
|
52
59
|
<div>
|
|
53
60
|
<button
|
|
61
|
+
aria-busy="false"
|
|
62
|
+
aria-disabled="false"
|
|
54
63
|
aria-live="off"
|
|
55
64
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
|
|
56
65
|
type="button"
|
|
@@ -63,6 +72,8 @@ exports[`Button deprecated types renders link as accent buttons with priority te
|
|
|
63
72
|
exports[`Button deprecated types renders pay as positive buttons and logs a warning 1`] = `
|
|
64
73
|
<div>
|
|
65
74
|
<button
|
|
75
|
+
aria-busy="false"
|
|
76
|
+
aria-disabled="false"
|
|
66
77
|
aria-live="off"
|
|
67
78
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
68
79
|
type="button"
|
|
@@ -75,6 +86,8 @@ exports[`Button deprecated types renders pay as positive buttons and logs a warn
|
|
|
75
86
|
exports[`Button deprecated types renders primary as accent buttons and logs a warning 1`] = `
|
|
76
87
|
<div>
|
|
77
88
|
<button
|
|
89
|
+
aria-busy="false"
|
|
90
|
+
aria-disabled="false"
|
|
78
91
|
aria-live="off"
|
|
79
92
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
80
93
|
type="button"
|
|
@@ -87,6 +100,8 @@ exports[`Button deprecated types renders primary as accent buttons and logs a wa
|
|
|
87
100
|
exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 1`] = `
|
|
88
101
|
<div>
|
|
89
102
|
<button
|
|
103
|
+
aria-busy="false"
|
|
104
|
+
aria-disabled="false"
|
|
90
105
|
aria-live="off"
|
|
91
106
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
|
|
92
107
|
type="button"
|
|
@@ -99,6 +114,8 @@ exports[`Button priorities defaults tertiary buttons to secondary for positive b
|
|
|
99
114
|
exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 2`] = `
|
|
100
115
|
<div>
|
|
101
116
|
<button
|
|
117
|
+
aria-busy="false"
|
|
118
|
+
aria-disabled="false"
|
|
102
119
|
aria-live="off"
|
|
103
120
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
104
121
|
type="button"
|
|
@@ -111,6 +128,8 @@ exports[`Button priorities defaults tertiary buttons to secondary for positive b
|
|
|
111
128
|
exports[`Button priorities renders primary buttons 1`] = `
|
|
112
129
|
<div>
|
|
113
130
|
<button
|
|
131
|
+
aria-busy="false"
|
|
132
|
+
aria-disabled="false"
|
|
114
133
|
aria-live="off"
|
|
115
134
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
116
135
|
type="button"
|
|
@@ -123,6 +142,8 @@ exports[`Button priorities renders primary buttons 1`] = `
|
|
|
123
142
|
exports[`Button priorities renders primary buttons 2`] = `
|
|
124
143
|
<div>
|
|
125
144
|
<button
|
|
145
|
+
aria-busy="false"
|
|
146
|
+
aria-disabled="false"
|
|
126
147
|
aria-live="off"
|
|
127
148
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
128
149
|
type="button"
|
|
@@ -135,6 +156,8 @@ exports[`Button priorities renders primary buttons 2`] = `
|
|
|
135
156
|
exports[`Button priorities renders primary buttons 3`] = `
|
|
136
157
|
<div>
|
|
137
158
|
<button
|
|
159
|
+
aria-busy="false"
|
|
160
|
+
aria-disabled="false"
|
|
138
161
|
aria-live="off"
|
|
139
162
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
|
|
140
163
|
type="button"
|
|
@@ -147,6 +170,8 @@ exports[`Button priorities renders primary buttons 3`] = `
|
|
|
147
170
|
exports[`Button priorities renders secondary buttons 1`] = `
|
|
148
171
|
<div>
|
|
149
172
|
<button
|
|
173
|
+
aria-busy="false"
|
|
174
|
+
aria-disabled="false"
|
|
150
175
|
aria-live="off"
|
|
151
176
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-2"
|
|
152
177
|
type="button"
|
|
@@ -159,6 +184,8 @@ exports[`Button priorities renders secondary buttons 1`] = `
|
|
|
159
184
|
exports[`Button priorities renders secondary buttons 2`] = `
|
|
160
185
|
<div>
|
|
161
186
|
<button
|
|
187
|
+
aria-busy="false"
|
|
188
|
+
aria-disabled="false"
|
|
162
189
|
aria-live="off"
|
|
163
190
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
|
|
164
191
|
type="button"
|
|
@@ -171,6 +198,8 @@ exports[`Button priorities renders secondary buttons 2`] = `
|
|
|
171
198
|
exports[`Button priorities renders secondary buttons 3`] = `
|
|
172
199
|
<div>
|
|
173
200
|
<button
|
|
201
|
+
aria-busy="false"
|
|
202
|
+
aria-disabled="false"
|
|
174
203
|
aria-live="off"
|
|
175
204
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
176
205
|
type="button"
|
|
@@ -183,6 +212,8 @@ exports[`Button priorities renders secondary buttons 3`] = `
|
|
|
183
212
|
exports[`Button priorities renders tertiary buttons 1`] = `
|
|
184
213
|
<div>
|
|
185
214
|
<button
|
|
215
|
+
aria-busy="false"
|
|
216
|
+
aria-disabled="false"
|
|
186
217
|
aria-live="off"
|
|
187
218
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
|
|
188
219
|
type="button"
|
|
@@ -195,6 +226,8 @@ exports[`Button priorities renders tertiary buttons 1`] = `
|
|
|
195
226
|
exports[`Button sizes renders large buttons 1`] = `
|
|
196
227
|
<div>
|
|
197
228
|
<button
|
|
229
|
+
aria-busy="false"
|
|
230
|
+
aria-disabled="false"
|
|
198
231
|
aria-live="off"
|
|
199
232
|
class="btn btn-lg np-btn np-btn-lg btn-accent btn-priority-1"
|
|
200
233
|
type="button"
|
|
@@ -207,6 +240,8 @@ exports[`Button sizes renders large buttons 1`] = `
|
|
|
207
240
|
exports[`Button sizes renders medium buttons 1`] = `
|
|
208
241
|
<div>
|
|
209
242
|
<button
|
|
243
|
+
aria-busy="false"
|
|
244
|
+
aria-disabled="false"
|
|
210
245
|
aria-live="off"
|
|
211
246
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
212
247
|
type="button"
|
|
@@ -219,6 +254,8 @@ exports[`Button sizes renders medium buttons 1`] = `
|
|
|
219
254
|
exports[`Button sizes renders small buttons 1`] = `
|
|
220
255
|
<div>
|
|
221
256
|
<button
|
|
257
|
+
aria-busy="false"
|
|
258
|
+
aria-disabled="false"
|
|
222
259
|
aria-live="off"
|
|
223
260
|
class="btn btn-sm np-btn np-btn-sm btn-accent btn-priority-1"
|
|
224
261
|
type="button"
|
|
@@ -231,6 +268,8 @@ exports[`Button sizes renders small buttons 1`] = `
|
|
|
231
268
|
exports[`Button types renders accent buttons 1`] = `
|
|
232
269
|
<div>
|
|
233
270
|
<button
|
|
271
|
+
aria-busy="false"
|
|
272
|
+
aria-disabled="false"
|
|
234
273
|
aria-live="off"
|
|
235
274
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
236
275
|
type="button"
|
|
@@ -243,6 +282,8 @@ exports[`Button types renders accent buttons 1`] = `
|
|
|
243
282
|
exports[`Button types renders negative buttons 1`] = `
|
|
244
283
|
<div>
|
|
245
284
|
<button
|
|
285
|
+
aria-busy="false"
|
|
286
|
+
aria-disabled="false"
|
|
246
287
|
aria-live="off"
|
|
247
288
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
|
|
248
289
|
type="button"
|
|
@@ -255,6 +296,8 @@ exports[`Button types renders negative buttons 1`] = `
|
|
|
255
296
|
exports[`Button types renders positive buttons 1`] = `
|
|
256
297
|
<div>
|
|
257
298
|
<button
|
|
299
|
+
aria-busy="false"
|
|
300
|
+
aria-disabled="false"
|
|
258
301
|
aria-live="off"
|
|
259
302
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
260
303
|
type="button"
|
package/src/main.css
CHANGED
|
@@ -543,6 +543,9 @@ div.critical-comms .critical-comms-body {
|
|
|
543
543
|
.np-btn.np-btn-xs.btn-block > span.btn-loader {
|
|
544
544
|
top: 0;
|
|
545
545
|
}
|
|
546
|
+
.np-btn.disabled[class] {
|
|
547
|
+
pointer-events: auto;
|
|
548
|
+
}
|
|
546
549
|
.np-card {
|
|
547
550
|
overflow: hidden;
|
|
548
551
|
transition-property: transform, box-shadow;
|
|
@@ -347,6 +347,12 @@ describe('Typeahead', () => {
|
|
|
347
347
|
expect(options.every((label, i) => label === props.options[i].label)).toBe(true);
|
|
348
348
|
});
|
|
349
349
|
|
|
350
|
+
it('renders dropdown-menu if has options', () => {
|
|
351
|
+
expect(component.find('.dropdown-menu')).toHaveLength(1);
|
|
352
|
+
component.setProps({ options: [] });
|
|
353
|
+
expect(component.find('.dropdown-menu')).toHaveLength(0);
|
|
354
|
+
});
|
|
355
|
+
|
|
350
356
|
it('does not render new option if showNewEntry is false', () => {
|
|
351
357
|
component.setProps({
|
|
352
358
|
allowNew: true,
|
|
@@ -6,6 +6,7 @@ import Typeahead, { type TypeaheadOption } from './Typeahead';
|
|
|
6
6
|
import { Size } from '../common';
|
|
7
7
|
import { useState } from 'react';
|
|
8
8
|
import { Input } from '../inputs/Input';
|
|
9
|
+
import { Field } from '../field/Field';
|
|
9
10
|
|
|
10
11
|
type Story = StoryObj<typeof Typeahead>;
|
|
11
12
|
|
|
@@ -103,15 +104,17 @@ export const Basic: Story = {
|
|
|
103
104
|
|
|
104
105
|
export const Creatable: Story = {
|
|
105
106
|
render: (args) => (
|
|
106
|
-
<Typeahead
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
<Field id={`input-${args.id}`} label="Typeahead with values">
|
|
108
|
+
<Typeahead
|
|
109
|
+
{...args}
|
|
110
|
+
allowNew
|
|
111
|
+
multiple
|
|
112
|
+
initialValue={[]}
|
|
113
|
+
validateChip={validateOptionAsEmail}
|
|
114
|
+
addon={<SearchIcon size={24} />}
|
|
115
|
+
options={[]}
|
|
116
|
+
/>
|
|
117
|
+
</Field>
|
|
115
118
|
),
|
|
116
119
|
play: async ({ canvasElement }) => {
|
|
117
120
|
const canvas = within(canvasElement);
|
|
@@ -401,20 +401,22 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
401
401
|
className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}
|
|
402
402
|
id={`menu-${id}`}
|
|
403
403
|
>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
404
|
+
{!!optionsToRender.length && (
|
|
405
|
+
<ul className="dropdown-menu" role="menu">
|
|
406
|
+
{optionsToRender.map((option, idx) => (
|
|
407
|
+
<TypeaheadOption
|
|
408
|
+
key={`${option.label}${idx.toString()}`}
|
|
409
|
+
query={query}
|
|
410
|
+
option={option}
|
|
411
|
+
selected={keyboardFocusedOptionIndex === idx}
|
|
412
|
+
onClick={(event) => {
|
|
413
|
+
this.onOptionSelected(event, option);
|
|
414
|
+
}}
|
|
415
|
+
/>
|
|
416
|
+
))}
|
|
417
|
+
{footer}
|
|
418
|
+
</ul>
|
|
419
|
+
)}
|
|
418
420
|
</div>
|
|
419
421
|
);
|
|
420
422
|
};
|
|
@@ -45,6 +45,12 @@ describe('Typeahead input', () => {
|
|
|
45
45
|
expect(inputWrapper().find('span')).toHaveLength(selected.length);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
it('adds aria-controls prop if dropdown is open', () => {
|
|
49
|
+
expect(component.prop('aria-controls')).toBeUndefined();
|
|
50
|
+
component.setProps({ dropdownOpen: true });
|
|
51
|
+
expect(component.prop('aria-controls')).toBe('menu-test');
|
|
52
|
+
});
|
|
53
|
+
|
|
48
54
|
it('passes all callbacks to input', () => {
|
|
49
55
|
const event = {};
|
|
50
56
|
const extraProps = {
|
|
@@ -91,7 +91,7 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
91
91
|
aria-autocomplete="list"
|
|
92
92
|
aria-expanded={dropdownOpen}
|
|
93
93
|
aria-haspopup="listbox"
|
|
94
|
-
aria-controls={`menu-${typeaheadId}`}
|
|
94
|
+
aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}
|
|
95
95
|
autoComplete={autoComplete}
|
|
96
96
|
role="combobox"
|
|
97
97
|
value={value}
|