@transferwise/components 0.0.0-experimental-77b2752 → 0.0.0-experimental-c9a3ec4
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.esm.js +51 -154
- package/build/index.esm.js.map +1 -1
- package/build/index.js +51 -154
- package/build/index.js.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +2 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +77 -57
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +28 -41
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts +9 -17
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/inputs/SelectInput.spec.tsx +7 -0
- package/src/inputs/SelectInput.story.tsx +221 -315
- package/src/inputs/SelectInput.tsx +4 -0
- package/src/typeahead/{Typeahead.story.js → Typeahead.story.tsx} +8 -7
- package/src/typeahead/{Typeahead.js → Typeahead.tsx} +101 -114
- package/src/typeahead/typeaheadInput/{TypeaheadInput.js → TypeaheadInput.tsx} +45 -42
- package/src/typeahead/typeaheadOption/{TypeaheadOption.js → TypeaheadOption.tsx} +10 -20
|
@@ -16,6 +16,7 @@ export interface SelectInputSeparatorItem {
|
|
|
16
16
|
}
|
|
17
17
|
export type SelectInputItem<T = string> = SelectInputOptionItem<T> | SelectInputGroupItem<T> | SelectInputSeparatorItem;
|
|
18
18
|
export interface SelectInputProps<T = string, M extends boolean = false> {
|
|
19
|
+
id?: string;
|
|
19
20
|
name?: string;
|
|
20
21
|
multiple?: M;
|
|
21
22
|
placeholder?: string;
|
|
@@ -48,7 +49,7 @@ export interface SelectInputProps<T = string, M extends boolean = false> {
|
|
|
48
49
|
onChange?: (value: M extends true ? T[] : T) => void;
|
|
49
50
|
onClear?: () => void;
|
|
50
51
|
}
|
|
51
|
-
export declare function SelectInput<T = string, M extends boolean = false>({ name, multiple, placeholder, items, defaultValue, value: controlledValue, compareValues, renderValue, renderFooter, renderTrigger, filterable, filterPlaceholder, disabled, size, className, onFilterChange, onChange, onClear, }: SelectInputProps<T, M>): import("react").JSX.Element;
|
|
52
|
+
export declare function SelectInput<T = string, M extends boolean = false>({ id, name, multiple, placeholder, items, defaultValue, value: controlledValue, compareValues, renderValue, renderFooter, renderTrigger, filterable, filterPlaceholder, disabled, size, className, onFilterChange, onChange, onClear, }: SelectInputProps<T, M>): import("react").JSX.Element;
|
|
52
53
|
type SelectInputTriggerButtonElementType = 'button' | React.ComponentType;
|
|
53
54
|
export type SelectInputTriggerButtonProps<T extends SelectInputTriggerButtonElementType = 'button'> = Merge<React.ComponentPropsWithoutRef<T>, {
|
|
54
55
|
as?: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../src/inputs/SelectInput.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../src/inputs/SelectInput.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAoCjC,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,MAAM;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,CAAC,CAAC;IACT,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,MAAM;IAC9C,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;CAC9C;A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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import { DebouncedFunc } from 'lodash';
|
|
2
|
+
import { Component, ReactNode } from 'react';
|
|
3
|
+
import TypeaheadOption from './typeaheadOption/TypeaheadOption';
|
|
4
|
+
export type TypeaheadOption<T = string> = {
|
|
5
|
+
label: string;
|
|
6
|
+
note?: string;
|
|
7
|
+
secondary?: string;
|
|
8
|
+
value?: T;
|
|
9
|
+
};
|
|
10
|
+
export type TypeaheadProps<T> = {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
options: TypeaheadOption<T>[];
|
|
14
|
+
initialValue?: TypeaheadOption<T>[];
|
|
15
|
+
onChange: (options: TypeaheadOption<T>[]) => void;
|
|
16
|
+
allowNew?: boolean;
|
|
17
|
+
autoFocus?: boolean;
|
|
18
|
+
clearable?: boolean;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
showSuggestions?: boolean;
|
|
21
|
+
showNewEntry?: boolean;
|
|
22
|
+
searchDelay?: number;
|
|
23
|
+
maxHeight?: number;
|
|
24
|
+
minQueryLength?: number;
|
|
25
|
+
addon?: ReactNode;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
alert?: {
|
|
28
|
+
message: string;
|
|
29
|
+
type: 'error' | 'warning' | 'neutral';
|
|
30
|
+
};
|
|
31
|
+
footer: ReactNode;
|
|
32
|
+
validateChip?: (chip: TypeaheadOption<T>) => boolean;
|
|
33
|
+
onSearch?: (query: string) => void;
|
|
34
|
+
onBlur?: () => void;
|
|
35
|
+
onInputChange?: (query: string) => void;
|
|
36
|
+
onFocus?: () => void;
|
|
37
|
+
chipSeparators?: string[];
|
|
38
|
+
size?: 'md' | 'lg';
|
|
39
|
+
inputAutoComplete?: string;
|
|
40
|
+
autoFillOnBlur?: boolean;
|
|
41
|
+
};
|
|
42
|
+
type TypeaheadState<T> = {
|
|
43
|
+
selected: TypeaheadOption<T>[];
|
|
44
|
+
keyboardFocusedOptionIndex: number | null;
|
|
45
|
+
errorState: boolean;
|
|
46
|
+
query: string;
|
|
47
|
+
optionsShown?: boolean;
|
|
48
|
+
isFocused?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export default class Typeahead<T> extends Component<TypeaheadProps<T>, TypeaheadState<T>> {
|
|
51
|
+
constructor(props: TypeaheadProps<T>);
|
|
52
|
+
handleSearchDebounced: DebouncedFunc<(query: string) => void>;
|
|
53
|
+
UNSAFE_componentWillReceiveProps(nextProps: TypeaheadProps<T>): void;
|
|
54
|
+
componentWillUnmount(): void;
|
|
55
|
+
handleOnFocus: () => void;
|
|
56
|
+
onOptionSelected: (event: React.MouseEvent, item: TypeaheadOption<T>) => void;
|
|
57
|
+
handleOnChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
58
|
+
handleOnPaste: React.ClipboardEventHandler<HTMLInputElement>;
|
|
59
|
+
handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
60
|
+
moveFocusedOption(offset: number): void;
|
|
61
|
+
selectItem: (item: TypeaheadOption<T>) => void;
|
|
62
|
+
stopPropagation: (event: React.MouseEvent) => void;
|
|
63
|
+
handleSearch: (query: string) => void;
|
|
64
|
+
handleDocumentClick: () => void;
|
|
65
|
+
showMenu: () => void;
|
|
66
|
+
hideMenu: () => void;
|
|
67
|
+
updateSelectedValue: (selected: TypeaheadOption<T>[]) => void;
|
|
68
|
+
clear: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
69
|
+
removeChip: (option: TypeaheadOption<T>) => void;
|
|
70
|
+
renderChip: (option: TypeaheadOption<T>, idx: number) => ReactNode;
|
|
71
|
+
renderMenu: ({ footer, options, id, keyboardFocusedOptionIndex, query, allowNew, showNewEntry, dropdownOpen, }: Pick<TypeaheadProps<T>, "id" | "footer" | "options" | "allowNew" | "showNewEntry"> & Pick<TypeaheadState<T>, "keyboardFocusedOptionIndex" | "query"> & {
|
|
72
|
+
dropdownOpen?: boolean | undefined;
|
|
73
|
+
}) => import("react").JSX.Element;
|
|
74
|
+
render(): import("react").JSX.Element;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=Typeahead.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../../src/typeahead/Typeahead.
|
|
1
|
+
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../../src/typeahead/Typeahead.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAW7C,OAAO,eAAe,MAAM,mCAAmC,CAAC;AAKhE,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,MAAM,IAAI;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;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C;IAapC,qBAAqB,EAAE,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAE9D,gCAAgC,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAkB7D,oBAAoB;IAIpB,aAAa,aAGX;IAEF,gBAAgB,UAAW,gBAAgB,QAAQ,gBAAgB,CAAC,CAAC,UAGnE;IAGF,cAAc,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAoBxD;IAEF,aAAa,EAAE,KAAK,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAiB1D;IAEF,eAAe,EAAE,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAyC3D;IAEF,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAchC,UAAU,SAAU,gBAAgB,CAAC,CAAC,UAiBpC;IAEF,eAAe,UAAW,gBAAgB,UAMxC;IAEF,YAAY,UAAW,MAAM,UAS3B;IAEF,mBAAmB,aAgBjB;IAEF,QAAQ,aAWN;IAEF,QAAQ,aAWN;IAEF,mBAAmB,aAAc,gBAAgB,CAAC,CAAC,EAAE,UAOnD;IAEF,KAAK,UAAW,gBAAgB,CAAC,iBAAiB,CAAC,UASjD;IAEF,UAAU,WAAY,gBAAgB,CAAC,CAAC,UAMtC;IAEF,UAAU,WAAY,gBAAgB,CAAC,CAAC,OAAO,MAAM,KAAG,SAAS,CAc/D;IAEF,UAAU;;sCA6CR;IAEF,MAAM;CAqGP"}
|
|
@@ -1,47 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
|
2
|
+
import { TypeaheadOption } from '../Typeahead';
|
|
3
|
+
export type TypeaheadInputProps<T> = {
|
|
4
|
+
typeaheadId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
autoFocus?: boolean;
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
value: string;
|
|
9
|
+
selected: TypeaheadOption<T>[];
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
optionsShown?: boolean;
|
|
12
|
+
maxHeight: number | null;
|
|
13
|
+
autoComplete: string;
|
|
14
|
+
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
15
|
+
onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
16
|
+
onFocus: () => void;
|
|
17
|
+
onPaste: React.ClipboardEventHandler<HTMLInputElement>;
|
|
18
|
+
renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;
|
|
19
|
+
};
|
|
20
|
+
type TypeaheadInputState = {
|
|
21
|
+
inputWidth: number;
|
|
22
|
+
};
|
|
23
|
+
export default class TypeaheadInput<T> extends Component<TypeaheadInputProps<T>, TypeaheadInputState> {
|
|
24
|
+
inputRef: HTMLInputElement | null;
|
|
25
|
+
sizerRef: HTMLDivElement | null;
|
|
26
|
+
constructor(props: TypeaheadInputProps<T>);
|
|
6
27
|
componentDidMount(): void;
|
|
7
|
-
componentDidUpdate(previousProps:
|
|
28
|
+
componentDidUpdate(previousProps: TypeaheadInputProps<T>): void;
|
|
8
29
|
recalculateWidth: () => void;
|
|
9
30
|
renderInput: () => import("react").JSX.Element;
|
|
10
|
-
inputRef: HTMLInputElement | null | undefined;
|
|
11
31
|
render(): import("react").JSX.Element;
|
|
12
|
-
sizerRef: HTMLDivElement | null | undefined;
|
|
13
32
|
}
|
|
14
|
-
|
|
15
|
-
namespace propTypes {
|
|
16
|
-
const typeaheadId: any;
|
|
17
|
-
const name: any;
|
|
18
|
-
const autoFocus: any;
|
|
19
|
-
const multiple: any;
|
|
20
|
-
const value: any;
|
|
21
|
-
const selected: any;
|
|
22
|
-
const placeholder: any;
|
|
23
|
-
const optionsShown: any;
|
|
24
|
-
const maxHeight: any;
|
|
25
|
-
const autoComplete: any;
|
|
26
|
-
const onChange: any;
|
|
27
|
-
const renderChip: any;
|
|
28
|
-
const onKeyDown: any;
|
|
29
|
-
const onFocus: any;
|
|
30
|
-
const onPaste: any;
|
|
31
|
-
}
|
|
32
|
-
namespace defaultProps {
|
|
33
|
-
const autoFocus_1: boolean;
|
|
34
|
-
export { autoFocus_1 as autoFocus };
|
|
35
|
-
const maxHeight_1: null;
|
|
36
|
-
export { maxHeight_1 as maxHeight };
|
|
37
|
-
const placeholder_1: string;
|
|
38
|
-
export { placeholder_1 as placeholder };
|
|
39
|
-
const optionsShown_1: boolean;
|
|
40
|
-
export { optionsShown_1 as optionsShown };
|
|
41
|
-
const selected_1: never[];
|
|
42
|
-
export { selected_1 as selected };
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export default TypeaheadInput;
|
|
46
|
-
import { Component } from "react";
|
|
33
|
+
export {};
|
|
47
34
|
//# sourceMappingURL=TypeaheadInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeaheadInput.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/typeaheadInput/TypeaheadInput.
|
|
1
|
+
{"version":3,"file":"TypeaheadInput.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/typeaheadInput/TypeaheadInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IACrD,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACxD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;CACpE,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,cAAc,CAAC,CAAC,CAAE,SAAQ,SAAS,CACtD,mBAAmB,CAAC,CAAC,CAAC,EACtB,mBAAmB,CACpB;IACC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACzC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAQ;gBAE3B,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAOzC,iBAAiB;IAOjB,kBAAkB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAMxD,gBAAgB,aAQd;IAEF,WAAW,oCA4CT;IAEF,MAAM;CA8BP"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TypeaheadOption } from '../Typeahead';
|
|
3
|
+
export type TypeaheadOptionProps<T> = {
|
|
4
|
+
option: TypeaheadOption<T>;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
onClick?: React.MouseEventHandler;
|
|
7
|
+
query?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const Option: <T>(props: TypeaheadOptionProps<T>) => import("react").JSX.Element;
|
|
1
10
|
export default Option;
|
|
2
|
-
declare function Option(props: any): import("react").JSX.Element;
|
|
3
|
-
declare namespace Option {
|
|
4
|
-
namespace propTypes {
|
|
5
|
-
const option: any;
|
|
6
|
-
const query: any;
|
|
7
|
-
const selected: any;
|
|
8
|
-
const onClick: any;
|
|
9
|
-
}
|
|
10
|
-
namespace defaultProps {
|
|
11
|
-
const selected_1: boolean;
|
|
12
|
-
export { selected_1 as selected };
|
|
13
|
-
const query_1: string;
|
|
14
|
-
export { query_1 as query };
|
|
15
|
-
export function onClick_1(): void;
|
|
16
|
-
export { onClick_1 as onClick };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
11
|
//# sourceMappingURL=TypeaheadOption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeaheadOption.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/typeaheadOption/TypeaheadOption.
|
|
1
|
+
{"version":3,"file":"TypeaheadOption.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/typeaheadOption/TypeaheadOption.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,QAAA,MAAM,MAAM,oEAqBX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-c9a3ec4",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -97,6 +97,9 @@
|
|
|
97
97
|
"@react-spring/web": "~9.6.1",
|
|
98
98
|
"@transferwise/formatting": "^2.1.0",
|
|
99
99
|
"@transferwise/neptune-validation": "^3.1.0",
|
|
100
|
+
"@types/lodash": "4.14.202",
|
|
101
|
+
"@types/lodash.clamp": "^4.0.9",
|
|
102
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
100
103
|
"@types/lodash.throttle": "^4.1.7",
|
|
101
104
|
"classnames": "^2.2.6",
|
|
102
105
|
"commonmark": "0.29.1",
|
|
@@ -208,4 +208,11 @@ describe('SelectInput', () => {
|
|
|
208
208
|
|
|
209
209
|
expect(trigger).toHaveTextContent('USD, EUR');
|
|
210
210
|
});
|
|
211
|
+
|
|
212
|
+
it('supports custom `id` attribute', () => {
|
|
213
|
+
render(<SelectInput id="custom" items={[]} />);
|
|
214
|
+
|
|
215
|
+
const trigger = screen.getAllByRole('button')[0];
|
|
216
|
+
expect(trigger).toHaveAttribute('id', 'custom');
|
|
217
|
+
});
|
|
211
218
|
});
|