@transferwise/components 46.10.1 → 46.12.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 +14 -1
- package/build/i18n/zh-HK.json +2 -2
- package/build/index.esm.js +49 -147
- package/build/index.esm.js.map +1 -1
- package/build/index.js +49 -147
- package/build/index.js.map +1 -1
- package/build/mocks.esm.js +40 -0
- package/build/mocks.esm.js.map +1 -0
- package/build/mocks.js +43 -0
- package/build/mocks.js.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/mocks.d.ts +9 -0
- package/build/types/mocks.d.ts.map +1 -0
- package/build/types/test-utils/window-mock.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +95 -57
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/typeahead/index.d.ts +2 -2
- package/build/types/typeahead/index.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +23 -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/build/types/typeahead/util/highlight.d.ts +2 -1
- package/build/types/typeahead/util/highlight.d.ts.map +1 -1
- package/package.json +26 -7
- package/src/dimmer/Dimmer.spec.js +0 -4
- package/src/i18n/zh-HK.json +2 -2
- package/src/index.ts +1 -0
- package/src/mocks.ts +48 -0
- package/src/snackbar/Snackbar.spec.js +0 -4
- package/src/test-utils/window-mock.ts +7 -23
- package/src/typeahead/{Typeahead.story.js → Typeahead.story.tsx} +8 -7
- package/src/typeahead/{Typeahead.js → Typeahead.tsx} +110 -111
- package/src/typeahead/index.ts +2 -0
- package/src/typeahead/typeaheadInput/TypeaheadInput.spec.js +1 -0
- package/src/typeahead/typeaheadInput/{TypeaheadInput.js → TypeaheadInput.tsx} +35 -46
- package/src/typeahead/typeaheadOption/{TypeaheadOption.js → TypeaheadOption.tsx} +10 -20
- package/src/typeahead/util/{highlight.js → highlight.tsx} +1 -1
- package/src/withNextPortal/withNextPortal.spec.js +0 -4
- package/src/typeahead/index.js +0 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const defaultStubGlobal = (name, value) => {
|
|
2
|
+
Object.defineProperty(globalThis, name, {
|
|
3
|
+
value,
|
|
4
|
+
writable: true,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
function mockMatchMedia({
|
|
10
|
+
fn,
|
|
11
|
+
stubGlobal = defaultStubGlobal
|
|
12
|
+
}) {
|
|
13
|
+
stubGlobal('matchMedia', fn(query => {
|
|
14
|
+
const matches = /^\(min-width: (\d+)px\)$/u.exec(query);
|
|
15
|
+
const minWidth = matches != null ? Number(matches[1]) : undefined;
|
|
16
|
+
return {
|
|
17
|
+
matches: minWidth != null ? window.innerWidth >= minWidth : false,
|
|
18
|
+
media: query,
|
|
19
|
+
onchange: null,
|
|
20
|
+
addListener: fn(),
|
|
21
|
+
removeListener: fn(),
|
|
22
|
+
addEventListener: fn(),
|
|
23
|
+
removeEventListener: fn(),
|
|
24
|
+
dispatchEvent: fn()
|
|
25
|
+
};
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
function mockResizeObserver({
|
|
29
|
+
fn,
|
|
30
|
+
stubGlobal = defaultStubGlobal
|
|
31
|
+
}) {
|
|
32
|
+
stubGlobal('ResizeObserver', fn(() => ({
|
|
33
|
+
observe: fn(),
|
|
34
|
+
unobserve: fn(),
|
|
35
|
+
disconnect: fn()
|
|
36
|
+
})));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { mockMatchMedia, mockResizeObserver };
|
|
40
|
+
//# sourceMappingURL=mocks.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.esm.js","sources":["../../src/mocks.ts"],"sourcesContent":[null],"names":["defaultStubGlobal","name","value","Object","defineProperty","globalThis","writable","enumerable","configurable"],"mappings":"AAAA,MAAeA,iBAAQ,GAAEA,CAAAC,IAAA,EAAAC,KAAa,KAAK;AAE3CC,EAAAA,MAAU,CAAgBC,cAAA,CAAAC,UAAA,EAAAJ,IAAA,EAAA;IACpBC;AACMI,IAAAA,QAAG,EAAA,IAAA;AACdC,IAAAA,UAAA,EAAA,IAAA;AAWeC,IAAAA,YAAA,EAAA,IAAA;AAoBA,GAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/mocks.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const defaultStubGlobal = (name, value) => {
|
|
4
|
+
Object.defineProperty(globalThis, name, {
|
|
5
|
+
value,
|
|
6
|
+
writable: true,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
function mockMatchMedia({
|
|
12
|
+
fn,
|
|
13
|
+
stubGlobal = defaultStubGlobal
|
|
14
|
+
}) {
|
|
15
|
+
stubGlobal('matchMedia', fn(query => {
|
|
16
|
+
const matches = /^\(min-width: (\d+)px\)$/u.exec(query);
|
|
17
|
+
const minWidth = matches != null ? Number(matches[1]) : undefined;
|
|
18
|
+
return {
|
|
19
|
+
matches: minWidth != null ? window.innerWidth >= minWidth : false,
|
|
20
|
+
media: query,
|
|
21
|
+
onchange: null,
|
|
22
|
+
addListener: fn(),
|
|
23
|
+
removeListener: fn(),
|
|
24
|
+
addEventListener: fn(),
|
|
25
|
+
removeEventListener: fn(),
|
|
26
|
+
dispatchEvent: fn()
|
|
27
|
+
};
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function mockResizeObserver({
|
|
31
|
+
fn,
|
|
32
|
+
stubGlobal = defaultStubGlobal
|
|
33
|
+
}) {
|
|
34
|
+
stubGlobal('ResizeObserver', fn(() => ({
|
|
35
|
+
observe: fn(),
|
|
36
|
+
unobserve: fn(),
|
|
37
|
+
disconnect: fn()
|
|
38
|
+
})));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.mockMatchMedia = mockMatchMedia;
|
|
42
|
+
exports.mockResizeObserver = mockResizeObserver;
|
|
43
|
+
//# sourceMappingURL=mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.js","sources":["../../src/mocks.ts"],"sourcesContent":[null],"names":["defaultStubGlobal","name","value","Object","defineProperty","globalThis","writable","enumerable","configurable"],"mappings":";;AAAA,MAAeA,iBAAQ,GAAEA,CAAAC,IAAA,EAAAC,KAAa,KAAK;AAE3CC,EAAAA,MAAU,CAAgBC,cAAA,CAAAC,UAAA,EAAAJ,IAAA,EAAA;IACpBC;AACMI,IAAAA,QAAG,EAAA,IAAA;AACdC,IAAAA,UAAA,EAAA,IAAA;AAWeC,IAAAA,YAAA,EAAA,IAAA;AAoBA,GAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { ModalProps } from './modal';
|
|
|
16
16
|
export type { CurrencyHeaderItem, CurrencyItem, CurrencyOptionItem, MoneyInputProps, } from './moneyInput';
|
|
17
17
|
export type { LayoutDirection, TypographyTypes, TitleTypes, BodyTypes, LinkTypes, DisplayTypes, } from './common';
|
|
18
18
|
export type { SegmentedControlProps } from './segmentedControl';
|
|
19
|
+
export type { TypeaheadProps, TypeaheadOption } from './typeahead';
|
|
19
20
|
/**
|
|
20
21
|
* Components
|
|
21
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,2B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BAAwB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D;;GAEG;AACH,OAAO,EACL,SAAS,EACT,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type StubGlobal = (name: PropertyKey, value: unknown) => void;
|
|
2
|
+
interface GlobalMockParams {
|
|
3
|
+
fn: <T extends (...args: never[]) => unknown>(implementation?: T) => T;
|
|
4
|
+
stubGlobal?: StubGlobal;
|
|
5
|
+
}
|
|
6
|
+
export declare function mockMatchMedia({ fn, stubGlobal }: GlobalMockParams): void;
|
|
7
|
+
export declare function mockResizeObserver({ fn, stubGlobal }: GlobalMockParams): void;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=mocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/mocks.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,UAAU,gBAAgB;IACxB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACvE,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAWD,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,UAA8B,EAAE,EAAE,gBAAgB,QAkBtF;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,UAA8B,EAAE,EAAE,gBAAgB,QAW1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window-mock.d.ts","sourceRoot":"","sources":["../../../src/test-utils/window-mock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"window-mock.d.ts","sourceRoot":"","sources":["../../../src/test-utils/window-mock.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,SAE7B;AAED,wBAAgB,kBAAkB,SAIjC"}
|
|
@@ -1,57 +1,95 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
validateChip?: (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import { DebouncedFunc } from 'lodash';
|
|
2
|
+
import { Component, ReactNode } from 'react';
|
|
3
|
+
import { Size, SizeMedium, SizeLarge } from '../common';
|
|
4
|
+
import { InlineAlertProps } from '../inlineAlert/InlineAlert';
|
|
5
|
+
import TypeaheadOption from './typeaheadOption/TypeaheadOption';
|
|
6
|
+
export type TypeaheadOption<T = string> = {
|
|
7
|
+
label: string;
|
|
8
|
+
note?: string;
|
|
9
|
+
secondary?: string;
|
|
10
|
+
value?: T;
|
|
11
|
+
};
|
|
12
|
+
export interface TypeaheadProps<T> {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
addon?: ReactNode;
|
|
16
|
+
alert?: {
|
|
17
|
+
message: InlineAlertProps['children'];
|
|
18
|
+
type?: InlineAlertProps['type'];
|
|
19
|
+
};
|
|
20
|
+
allowNew?: boolean;
|
|
21
|
+
autoFillOnBlur?: boolean;
|
|
22
|
+
autoFocus?: boolean;
|
|
23
|
+
chipSeparators?: string[];
|
|
24
|
+
clearable?: boolean;
|
|
25
|
+
footer?: ReactNode;
|
|
26
|
+
initialValue?: TypeaheadOption<T>[];
|
|
27
|
+
inputAutoComplete?: string;
|
|
28
|
+
maxHeight?: number;
|
|
29
|
+
minQueryLength?: number;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
multiple?: boolean;
|
|
32
|
+
options: TypeaheadOption<T>[];
|
|
33
|
+
searchDelay?: number;
|
|
34
|
+
showSuggestions?: boolean;
|
|
35
|
+
showNewEntry?: boolean;
|
|
36
|
+
size?: SizeMedium | SizeLarge;
|
|
37
|
+
onBlur?: () => void;
|
|
38
|
+
onChange: (options: TypeaheadOption<T>[]) => void;
|
|
39
|
+
onFocus?: () => void;
|
|
40
|
+
onInputChange?: (query: string) => void;
|
|
41
|
+
onSearch?: (query: string) => void;
|
|
42
|
+
validateChip?: (chip: TypeaheadOption<T>) => boolean;
|
|
43
|
+
}
|
|
44
|
+
type TypeaheadState<T> = {
|
|
45
|
+
selected: TypeaheadOption<T>[];
|
|
46
|
+
keyboardFocusedOptionIndex: number | null;
|
|
47
|
+
errorState: boolean;
|
|
48
|
+
query: string;
|
|
49
|
+
optionsShown: boolean;
|
|
50
|
+
isFocused: boolean;
|
|
51
|
+
};
|
|
52
|
+
export default class Typeahead<T> extends Component<TypeaheadProps<T>, TypeaheadState<T>> {
|
|
53
|
+
props: TypeaheadProps<T> & Required<Pick<TypeaheadProps<T>, keyof typeof Typeahead.defaultProps>>;
|
|
54
|
+
static defaultProps: {
|
|
55
|
+
allowNew: false;
|
|
56
|
+
autoFillOnBlur: true;
|
|
57
|
+
autoFocus: false;
|
|
58
|
+
chipSeparators: never[];
|
|
59
|
+
clearable: true;
|
|
60
|
+
initialValue: never[];
|
|
61
|
+
inputAutoComplete: string;
|
|
62
|
+
minQueryLength: number;
|
|
63
|
+
multiple: false;
|
|
64
|
+
searchDelay: number;
|
|
65
|
+
showSuggestions: true;
|
|
66
|
+
showNewEntry: true;
|
|
67
|
+
size: Size.MEDIUM;
|
|
68
|
+
validateChip: () => true;
|
|
69
|
+
};
|
|
70
|
+
constructor(props: TypeaheadProps<T>);
|
|
71
|
+
handleSearchDebounced: DebouncedFunc<Typeahead<T>['handleSearch']>;
|
|
72
|
+
UNSAFE_componentWillReceiveProps(nextProps: TypeaheadProps<T>): void;
|
|
73
|
+
componentWillUnmount(): void;
|
|
74
|
+
handleOnFocus: () => void;
|
|
75
|
+
onOptionSelected: (event: React.MouseEvent, item: TypeaheadOption<T>) => void;
|
|
76
|
+
handleOnChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
77
|
+
handleOnPaste: React.ClipboardEventHandler<HTMLInputElement>;
|
|
78
|
+
handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
79
|
+
moveFocusedOption(offset: number): void;
|
|
80
|
+
selectItem: (item: TypeaheadOption<T>) => void;
|
|
81
|
+
handleSearch: (query: string) => void;
|
|
82
|
+
handleDocumentClick: () => void;
|
|
83
|
+
showMenu: () => void;
|
|
84
|
+
hideMenu: () => void;
|
|
85
|
+
updateSelectedValue: (selected: TypeaheadOption<T>[]) => void;
|
|
86
|
+
clear: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
87
|
+
removeChip: (option: TypeaheadOption<T>) => void;
|
|
88
|
+
renderChip: (option: TypeaheadOption<T>, idx: number) => ReactNode;
|
|
89
|
+
renderMenu: ({ footer, options, id, keyboardFocusedOptionIndex, query, allowNew, showNewEntry, dropdownOpen, }: Pick<TypeaheadProps<T>, "id" | "footer" | "options" | "allowNew" | "showNewEntry"> & Pick<TypeaheadState<T>, "query" | "keyboardFocusedOptionIndex"> & {
|
|
90
|
+
dropdownOpen: boolean;
|
|
91
|
+
}) => import("react").JSX.Element;
|
|
92
|
+
render(): import("react").JSX.Element;
|
|
93
|
+
}
|
|
94
|
+
export {};
|
|
95
|
+
//# 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,MAA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E,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IAEnE,gCAAgC,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAkB7D,oBAAoB;IAIpB,aAAa,aAGX;IAEF,gBAAgB,UAAW,gBAAgB,QAAQ,gBAAgB,CAAC,CAAC,UAGnE;IAEF,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,CAmC3D;IAEF,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAchC,UAAU,SAAU,gBAAgB,CAAC,CAAC,UAiBpC;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;sBAWQ,OAAO;sCAkCvB;IAEF,MAAM;CAuGP"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default Typeahead;
|
|
2
|
-
|
|
1
|
+
export { default } from './Typeahead';
|
|
2
|
+
export type { TypeaheadOption, TypeaheadProps } from './Typeahead';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/typeahead/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/typeahead/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,47 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
|
2
|
+
import { TypeaheadOption, TypeaheadProps } from '../Typeahead';
|
|
3
|
+
export type TypeaheadInputProps<T> = {
|
|
4
|
+
typeaheadId: string;
|
|
5
|
+
value: string;
|
|
6
|
+
selected: TypeaheadOption<T>[];
|
|
7
|
+
optionsShown?: boolean;
|
|
8
|
+
autoComplete: string;
|
|
9
|
+
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
10
|
+
onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
11
|
+
onFocus: () => void;
|
|
12
|
+
onPaste: React.ClipboardEventHandler<HTMLInputElement>;
|
|
13
|
+
renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;
|
|
14
|
+
} & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;
|
|
15
|
+
type TypeaheadInputState = {
|
|
16
|
+
inputWidth: number;
|
|
17
|
+
};
|
|
18
|
+
export default class TypeaheadInput<T> extends Component<TypeaheadInputProps<T>, TypeaheadInputState> {
|
|
19
|
+
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
20
|
+
sizerRef: import("react").RefObject<HTMLDivElement>;
|
|
21
|
+
constructor(props: TypeaheadInputProps<T>);
|
|
6
22
|
componentDidMount(): void;
|
|
7
|
-
componentDidUpdate(previousProps:
|
|
23
|
+
componentDidUpdate(previousProps: TypeaheadInputProps<T>): void;
|
|
8
24
|
recalculateWidth: () => void;
|
|
9
25
|
renderInput: () => import("react").JSX.Element;
|
|
10
|
-
inputRef: HTMLInputElement | null | undefined;
|
|
11
26
|
render(): import("react").JSX.Element;
|
|
12
|
-
sizerRef: HTMLDivElement | null | undefined;
|
|
13
27
|
}
|
|
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";
|
|
28
|
+
export {};
|
|
47
29
|
//# 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,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAA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<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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/util/highlight.
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/util/highlight.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,wCAe7D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.12.0",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,22 @@
|
|
|
12
12
|
"sideEffects": [
|
|
13
13
|
"*.css"
|
|
14
14
|
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./build/types/index.d.ts",
|
|
18
|
+
"import": "./build/index.esm.js",
|
|
19
|
+
"require": "./build/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./mocks": {
|
|
22
|
+
"types": "./build/types/mocks.d.ts",
|
|
23
|
+
"import": "./build/mocks.esm.js",
|
|
24
|
+
"require": "./build/mocks.js"
|
|
25
|
+
},
|
|
26
|
+
"./build/*": "./build/*.js",
|
|
27
|
+
"./build/*.css": "./build/*.css",
|
|
28
|
+
"./build/*.json": "./build/*.json",
|
|
29
|
+
"./build/i18n": "./build/i18n"
|
|
30
|
+
},
|
|
15
31
|
"main": "./build/index.js",
|
|
16
32
|
"module": "./build/index.esm.js",
|
|
17
33
|
"types": "./build/types/index.d.ts",
|
|
@@ -53,7 +69,11 @@
|
|
|
53
69
|
"@transferwise/neptune-tokens": "^8.8.1",
|
|
54
70
|
"@tsconfig/recommended": "^1.0.2",
|
|
55
71
|
"@types/babel__core": "^7.20.1",
|
|
56
|
-
"@types/jest": "^
|
|
72
|
+
"@types/jest": "^29.5.12",
|
|
73
|
+
"@types/lodash": "4.14.202",
|
|
74
|
+
"@types/lodash.clamp": "^4.0.9",
|
|
75
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
76
|
+
"@types/lodash.throttle": "^4.1.7",
|
|
57
77
|
"@types/node": "^14.14.31",
|
|
58
78
|
"@types/react": "^17.0.65",
|
|
59
79
|
"@types/react-dom": "^17.0.20",
|
|
@@ -65,8 +85,8 @@
|
|
|
65
85
|
"babel-plugin-formatjs": "^10.5.13",
|
|
66
86
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
67
87
|
"enzyme": "^3.11.0",
|
|
68
|
-
"jest": "^
|
|
69
|
-
"jest-
|
|
88
|
+
"jest": "^29.7.0",
|
|
89
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
70
90
|
"jest-fetch-mock": "^3.0.3",
|
|
71
91
|
"lodash.times": "^4.3.2",
|
|
72
92
|
"react-intl": "^5.10.0",
|
|
@@ -97,7 +117,6 @@
|
|
|
97
117
|
"@react-spring/web": "~9.6.1",
|
|
98
118
|
"@transferwise/formatting": "^2.1.0",
|
|
99
119
|
"@transferwise/neptune-validation": "^3.1.0",
|
|
100
|
-
"@types/lodash.throttle": "^4.1.7",
|
|
101
120
|
"classnames": "^2.2.6",
|
|
102
121
|
"commonmark": "0.29.1",
|
|
103
122
|
"core-js": "^3.8.0",
|
|
@@ -133,8 +152,8 @@
|
|
|
133
152
|
"build:copy-css": "cpx 'src/main.css' build/ & cpx 'src/**/*.css' build/styles/",
|
|
134
153
|
"build:copy-lang": "cpx 'src/i18n/*.json' build/i18n && cpx 'src/i18n/index.js' build/i18n",
|
|
135
154
|
"docs": "pnpm build",
|
|
136
|
-
"test": "jest
|
|
137
|
-
"test:watch": "jest --watch
|
|
155
|
+
"test": "jest",
|
|
156
|
+
"test:watch": "jest --watch",
|
|
138
157
|
"lint": "pnpm run lint:check",
|
|
139
158
|
"lint:check": "npm-run-all --parallel lint:check:*",
|
|
140
159
|
"lint:check:format": "prettier --check --ignore-path ../../.prettierignore . || echo \"Prettier failed. Remove this to make this a failure\"",
|
|
@@ -33,10 +33,6 @@ describe('Dimmer', () => {
|
|
|
33
33
|
mount(<DimmerAppendingToBody {...props} />);
|
|
34
34
|
|
|
35
35
|
expect(ReactDOM.createPortal).toHaveBeenCalledTimes(1);
|
|
36
|
-
/** Using toBeCalledWith was not matching properly */
|
|
37
|
-
const [comp, body] = ReactDOM.createPortal.mock.calls[0];
|
|
38
|
-
expect(comp).toMatchObject(component);
|
|
39
|
-
expect(body).toMatchObject(document.body);
|
|
40
36
|
});
|
|
41
37
|
|
|
42
38
|
it('renders with right props', () => {
|
package/src/i18n/zh-HK.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"neptune.ClearButton.ariaLabel": "清除",
|
|
5
5
|
"neptune.CloseButton.ariaLabel": "關閉",
|
|
6
6
|
"neptune.DateInput.day.label": "日",
|
|
7
|
-
"neptune.DateInput.day.placeholder": "
|
|
7
|
+
"neptune.DateInput.day.placeholder": "DD",
|
|
8
8
|
"neptune.DateInput.month.label": "月",
|
|
9
9
|
"neptune.DateInput.year.label": "年",
|
|
10
|
-
"neptune.DateInput.year.placeholder": "
|
|
10
|
+
"neptune.DateInput.year.placeholder": "YYYY",
|
|
11
11
|
"neptune.DateLookup.day": "日",
|
|
12
12
|
"neptune.DateLookup.goTo20YearView": "切換至20年視圖",
|
|
13
13
|
"neptune.DateLookup.month": "月",
|
package/src/index.ts
CHANGED
package/src/mocks.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
type StubGlobal = (name: PropertyKey, value: unknown) => void;
|
|
2
|
+
|
|
3
|
+
interface GlobalMockParams {
|
|
4
|
+
fn: <T extends (...args: never[]) => unknown>(implementation?: T) => T;
|
|
5
|
+
stubGlobal?: StubGlobal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const defaultStubGlobal: StubGlobal = (name, value) => {
|
|
9
|
+
Object.defineProperty(globalThis, name, {
|
|
10
|
+
value,
|
|
11
|
+
writable: true,
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function mockMatchMedia({ fn, stubGlobal = defaultStubGlobal }: GlobalMockParams) {
|
|
18
|
+
stubGlobal(
|
|
19
|
+
'matchMedia',
|
|
20
|
+
fn<Window['matchMedia']>((query) => {
|
|
21
|
+
const matches = /^\(min-width: (\d+)px\)$/u.exec(query);
|
|
22
|
+
const minWidth = matches != null ? Number(matches[1]) : undefined;
|
|
23
|
+
return {
|
|
24
|
+
matches: minWidth != null ? window.innerWidth >= minWidth : false,
|
|
25
|
+
media: query,
|
|
26
|
+
onchange: null,
|
|
27
|
+
addListener: fn(),
|
|
28
|
+
removeListener: fn(),
|
|
29
|
+
addEventListener: fn(),
|
|
30
|
+
removeEventListener: fn(),
|
|
31
|
+
dispatchEvent: fn(),
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function mockResizeObserver({ fn, stubGlobal = defaultStubGlobal }: GlobalMockParams) {
|
|
38
|
+
stubGlobal(
|
|
39
|
+
'ResizeObserver',
|
|
40
|
+
fn(
|
|
41
|
+
(): ResizeObserver => ({
|
|
42
|
+
observe: fn(),
|
|
43
|
+
unobserve: fn(),
|
|
44
|
+
disconnect: fn(),
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -45,10 +45,6 @@ describe('Snackbar', () => {
|
|
|
45
45
|
mount(<SnackbarAppendingToBody {...props} />);
|
|
46
46
|
|
|
47
47
|
expect(createPortal).toHaveBeenCalledTimes(1);
|
|
48
|
-
/** Using toBeCalledWith was not matching properly */
|
|
49
|
-
const [comp, body] = ReactDOM.createPortal.mock.calls[0];
|
|
50
|
-
expect(comp).toMatchObject(snackbar());
|
|
51
|
-
expect(body).toMatchObject(document.body);
|
|
52
48
|
jest.clearAllMocks();
|
|
53
49
|
});
|
|
54
50
|
|