@transferwise/components 46.31.0 → 46.33.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/build/index.js +764 -474
- package/build/index.js.map +1 -1
- package/build/index.mjs +763 -474
- package/build/index.mjs.map +1 -1
- package/build/main.css +135 -0
- package/build/styles/carousel/Carousel.css +135 -0
- package/build/styles/main.css +135 -0
- package/build/types/carousel/Carousel.d.ts +26 -0
- package/build/types/carousel/Carousel.d.ts.map +1 -0
- package/build/types/carousel/index.d.ts +3 -0
- package/build/types/carousel/index.d.ts.map +1 -0
- package/build/types/common/card/Card.d.ts +2 -2
- package/build/types/common/card/Card.d.ts.map +1 -1
- package/build/types/common/domHelpers/documentIosClick.d.ts +0 -1
- package/build/types/common/domHelpers/documentIosClick.d.ts.map +1 -1
- package/build/types/common/domHelpers/index.d.ts +1 -1
- package/build/types/common/domHelpers/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +4 -2
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +16 -5
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/Select.d.ts +7 -7
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +4 -55
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/carousel/Carousel.css +135 -0
- package/src/carousel/Carousel.less +133 -0
- package/src/carousel/Carousel.spec.tsx +221 -0
- package/src/carousel/Carousel.story.tsx +63 -0
- package/src/carousel/Carousel.tsx +345 -0
- package/src/carousel/index.ts +3 -0
- package/src/common/card/Card.tsx +51 -43
- package/src/common/domHelpers/documentIosClick.ts +0 -5
- package/src/common/domHelpers/index.ts +0 -1
- package/src/dateLookup/DateLookup.rtl.spec.tsx +2 -3
- package/src/dateLookup/DateLookup.tsx +1 -3
- package/src/index.ts +2 -0
- package/src/inputs/SelectInput.spec.tsx +1 -1
- package/src/main.css +135 -0
- package/src/main.less +1 -0
- package/src/moneyInput/MoneyInput.rtl.spec.tsx +10 -0
- package/src/moneyInput/MoneyInput.spec.js +10 -5
- package/src/moneyInput/MoneyInput.tsx +21 -14
- package/src/phoneNumberInput/PhoneNumberInput.rtl.spec.tsx +10 -0
- package/src/phoneNumberInput/PhoneNumberInput.tsx +11 -2
- package/src/promoCard/PromoCard.story.tsx +2 -2
- package/src/promoCard/PromoCard.tsx +30 -9
- package/src/select/Select.js +18 -15
- package/src/select/Select.rtl.spec.tsx +17 -0
- package/src/select/Select.spec.js +2 -7
- package/src/typeahead/Typeahead.rtl.spec.tsx +16 -0
- package/src/typeahead/Typeahead.tsx +21 -7
|
@@ -5,11 +5,6 @@ import Select from '.';
|
|
|
5
5
|
|
|
6
6
|
mockMatchMedia();
|
|
7
7
|
|
|
8
|
-
jest.mock('../common/domHelpers', () => ({
|
|
9
|
-
...jest.requireActual('../common/domHelpers'),
|
|
10
|
-
getSimpleRandomId: jest.fn((prefix) => `${prefix}mock-random-id`),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
8
|
function enableDesktopScreen() {
|
|
14
9
|
window.innerWidth = Breakpoint.LARGE;
|
|
15
10
|
}
|
|
@@ -326,8 +321,8 @@ describe('Select', () => {
|
|
|
326
321
|
const button = screen.getByRole('button');
|
|
327
322
|
const options = screen.getByRole('listbox');
|
|
328
323
|
|
|
329
|
-
expect(button).toHaveAttribute('id'
|
|
330
|
-
expect(options).toHaveAttribute('id'
|
|
324
|
+
expect(button).toHaveAttribute('id');
|
|
325
|
+
expect(options).toHaveAttribute('id');
|
|
331
326
|
});
|
|
332
327
|
|
|
333
328
|
it('renders controls with passed id', async () => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Field } from '../field/Field';
|
|
2
|
+
import { mockMatchMedia, render, screen } from '../test-utils';
|
|
3
|
+
import Typeahead from './Typeahead';
|
|
4
|
+
|
|
5
|
+
mockMatchMedia();
|
|
6
|
+
|
|
7
|
+
describe('Typeahead', () => {
|
|
8
|
+
it('supports `Field` for labeling', () => {
|
|
9
|
+
render(
|
|
10
|
+
<Field id="test" label="Tags">
|
|
11
|
+
<Typeahead id="test" name="test" options={[{ label: 'Test' }]} onChange={() => {}} />
|
|
12
|
+
</Field>,
|
|
13
|
+
);
|
|
14
|
+
expect(screen.getAllByRole('group')[0]).toHaveAccessibleName(/^Tags/);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from '../common/domHelpers';
|
|
19
19
|
import InlineAlert from '../inlineAlert';
|
|
20
20
|
import { InlineAlertProps } from '../inlineAlert/InlineAlert';
|
|
21
|
+
import { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';
|
|
21
22
|
|
|
22
23
|
import TypeaheadInput from './typeaheadInput/TypeaheadInput';
|
|
23
24
|
import TypeaheadOption from './typeaheadOption/TypeaheadOption';
|
|
@@ -68,6 +69,8 @@ export interface TypeaheadProps<T> {
|
|
|
68
69
|
validateChip?: (chip: TypeaheadOption<T>) => boolean;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
type TypeaheadPropsWithInputAttributes<T> = TypeaheadProps<T> & Partial<WithInputAttributesProps>;
|
|
73
|
+
|
|
71
74
|
type TypeaheadState<T> = {
|
|
72
75
|
selected: readonly TypeaheadOption<T>[];
|
|
73
76
|
keyboardFocusedOptionIndex: number | null;
|
|
@@ -77,9 +80,9 @@ type TypeaheadState<T> = {
|
|
|
77
80
|
isFocused: boolean;
|
|
78
81
|
};
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
declare props:
|
|
82
|
-
Required<Pick<
|
|
83
|
+
class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, TypeaheadState<T>> {
|
|
84
|
+
declare props: TypeaheadPropsWithInputAttributes<T> &
|
|
85
|
+
Required<Pick<TypeaheadPropsWithInputAttributes<T>, keyof typeof Typeahead.defaultProps>>;
|
|
83
86
|
|
|
84
87
|
static defaultProps = {
|
|
85
88
|
allowNew: false,
|
|
@@ -98,7 +101,7 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
98
101
|
validateChip: () => true,
|
|
99
102
|
} satisfies Partial<TypeaheadProps<unknown>>;
|
|
100
103
|
|
|
101
|
-
constructor(props:
|
|
104
|
+
constructor(props: TypeaheadPropsWithInputAttributes<T>) {
|
|
102
105
|
super(props);
|
|
103
106
|
const { searchDelay, initialValue, multiple } = this.props;
|
|
104
107
|
this.handleSearchDebounced = debounce(this.handleSearch, searchDelay);
|
|
@@ -115,7 +118,7 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
115
118
|
|
|
116
119
|
handleSearchDebounced: DebouncedFunc<Typeahead<T>['handleSearch']>;
|
|
117
120
|
|
|
118
|
-
UNSAFE_componentWillReceiveProps(nextProps:
|
|
121
|
+
UNSAFE_componentWillReceiveProps(nextProps: TypeaheadPropsWithInputAttributes<T>) {
|
|
119
122
|
if (nextProps.multiple !== this.props.multiple) {
|
|
120
123
|
this.setState((previousState) => {
|
|
121
124
|
const { selected } = previousState;
|
|
@@ -374,7 +377,10 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
374
377
|
allowNew,
|
|
375
378
|
showNewEntry,
|
|
376
379
|
dropdownOpen,
|
|
377
|
-
}: Pick<
|
|
380
|
+
}: Pick<
|
|
381
|
+
TypeaheadPropsWithInputAttributes<T>,
|
|
382
|
+
'footer' | 'options' | 'id' | 'allowNew' | 'showNewEntry'
|
|
383
|
+
> &
|
|
378
384
|
Pick<TypeaheadState<T>, 'keyboardFocusedOptionIndex' | 'query'> & {
|
|
379
385
|
dropdownOpen: boolean;
|
|
380
386
|
}) => {
|
|
@@ -414,7 +420,8 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
414
420
|
|
|
415
421
|
render() {
|
|
416
422
|
const {
|
|
417
|
-
|
|
423
|
+
inputAttributes,
|
|
424
|
+
id: idProp,
|
|
418
425
|
placeholder,
|
|
419
426
|
multiple,
|
|
420
427
|
size,
|
|
@@ -432,6 +439,7 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
432
439
|
alert,
|
|
433
440
|
inputAutoComplete,
|
|
434
441
|
} = this.props;
|
|
442
|
+
const id = idProp ?? inputAttributes?.id;
|
|
435
443
|
|
|
436
444
|
const { errorState, query, selected, optionsShown, keyboardFocusedOptionIndex } = this.state;
|
|
437
445
|
|
|
@@ -457,6 +465,8 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
457
465
|
const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;
|
|
458
466
|
return (
|
|
459
467
|
<div
|
|
468
|
+
role="group"
|
|
469
|
+
{...inputAttributes}
|
|
460
470
|
id={id}
|
|
461
471
|
className={classNames('typeahead', `typeahead-${size}`, {
|
|
462
472
|
'typeahead--has-value': selected.length > 0,
|
|
@@ -515,3 +525,7 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
515
525
|
);
|
|
516
526
|
}
|
|
517
527
|
}
|
|
528
|
+
|
|
529
|
+
export default withInputAttributes(Typeahead, { nonLabelable: true }) as <T>(
|
|
530
|
+
props: TypeaheadProps<T>,
|
|
531
|
+
) => React.ReactElement;
|