@transferwise/components 0.0.0-experimental-4d1e1cf → 0.0.0-experimental-a53ae95
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/index.esm.js +147 -49
- package/build/index.esm.js.map +1 -1
- package/build/index.js +147 -49
- 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 +0 -1
- 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 +57 -98
- 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 +41 -23
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts +17 -9
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/build/types/typeahead/util/highlight.d.ts +1 -2
- package/build/types/typeahead/util/highlight.d.ts.map +1 -1
- package/package.json +23 -10
- package/src/dimmer/Dimmer.spec.js +0 -4
- package/src/index.ts +0 -1
- 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.tsx → Typeahead.js} +108 -107
- package/src/typeahead/{Typeahead.story.tsx → Typeahead.story.js} +7 -8
- package/src/typeahead/index.js +3 -0
- package/src/typeahead/typeaheadInput/{TypeaheadInput.tsx → TypeaheadInput.js} +51 -43
- package/src/typeahead/typeaheadOption/{TypeaheadOption.tsx → TypeaheadOption.js} +20 -10
- package/src/typeahead/util/{highlight.tsx → highlight.js} +1 -1
- package/src/withNextPortal/withNextPortal.spec.js +0 -4
- package/src/typeahead/index.ts +0 -2
|
@@ -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,7 +16,6 @@ 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';
|
|
20
19
|
/**
|
|
21
20
|
* Components
|
|
22
21
|
*/
|
|
@@ -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,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EAAE,eAAe,EAAE,MAAM,qB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;;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,98 +1,57 @@
|
|
|
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
|
-
|
|
58
|
-
autoFocus: boolean;
|
|
59
|
-
chipSeparators: never[];
|
|
60
|
-
clearable: boolean;
|
|
61
|
-
footer: null;
|
|
62
|
-
initialValue: never[];
|
|
63
|
-
inputAutoComplete: string;
|
|
64
|
-
maxHeight: null;
|
|
65
|
-
minQueryLength: number;
|
|
66
|
-
multiple: boolean;
|
|
67
|
-
searchDelay: number;
|
|
68
|
-
showSuggestions: boolean;
|
|
69
|
-
showNewEntry: boolean;
|
|
70
|
-
size: Size;
|
|
71
|
-
validateChip: () => boolean;
|
|
72
|
-
};
|
|
73
|
-
constructor(props: TypeaheadProps<T>);
|
|
74
|
-
handleSearchDebounced: DebouncedFunc<(query: string) => void>;
|
|
75
|
-
UNSAFE_componentWillReceiveProps(nextProps: TypeaheadProps<T>): void;
|
|
76
|
-
componentWillUnmount(): void;
|
|
77
|
-
handleOnFocus: () => void;
|
|
78
|
-
onOptionSelected: (event: React.MouseEvent, item: TypeaheadOption<T>) => void;
|
|
79
|
-
handleOnChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
80
|
-
handleOnPaste: React.ClipboardEventHandler<HTMLInputElement>;
|
|
81
|
-
handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
82
|
-
moveFocusedOption(offset: number): void;
|
|
83
|
-
selectItem: (item: TypeaheadOption<T>) => void;
|
|
84
|
-
handleSearch: (query: string) => void;
|
|
85
|
-
handleDocumentClick: () => void;
|
|
86
|
-
showMenu: () => void;
|
|
87
|
-
hideMenu: () => void;
|
|
88
|
-
updateSelectedValue: (selected: TypeaheadOption<T>[]) => void;
|
|
89
|
-
clear: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
90
|
-
removeChip: (option: TypeaheadOption<T>) => void;
|
|
91
|
-
renderChip: (option: TypeaheadOption<T>, idx: number) => ReactNode;
|
|
92
|
-
renderMenu: ({ footer, options, id, keyboardFocusedOptionIndex, query, allowNew, showNewEntry, dropdownOpen, }: Pick<TypeaheadProps<T>, "id" | "footer" | "options" | "allowNew" | "showNewEntry"> & Pick<TypeaheadState<T>, "query" | "keyboardFocusedOptionIndex"> & {
|
|
93
|
-
dropdownOpen?: boolean | undefined;
|
|
94
|
-
}) => import("react").JSX.Element;
|
|
95
|
-
render(): import("react").JSX.Element;
|
|
96
|
-
}
|
|
97
|
-
export {};
|
|
98
|
-
//# sourceMappingURL=Typeahead.d.ts.map
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface TypeaheadOptions {
|
|
4
|
+
label: string;
|
|
5
|
+
note?: string;
|
|
6
|
+
secondary?: string;
|
|
7
|
+
value?: Object;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TypeaheadInitialValue {
|
|
11
|
+
label: string;
|
|
12
|
+
note?: string;
|
|
13
|
+
secondary?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TypeaheadAlert {
|
|
17
|
+
message: string;
|
|
18
|
+
type: "error" | "warning" | "neutral";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TypeaheadSize = "md" | "lg";
|
|
22
|
+
|
|
23
|
+
export interface TypeaheadProps {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
options: TypeaheadOptions[];
|
|
27
|
+
initialValue?: TypeaheadInitialValue[];
|
|
28
|
+
onChange: (...args: any[])=>any;
|
|
29
|
+
allowNew?: boolean;
|
|
30
|
+
autoFocus?: boolean;
|
|
31
|
+
clearable?: boolean;
|
|
32
|
+
multiple?: boolean;
|
|
33
|
+
showSuggestions?: boolean;
|
|
34
|
+
showNewEntry?: boolean;
|
|
35
|
+
searchDelay?: number;
|
|
36
|
+
maxHeight?: number;
|
|
37
|
+
minQueryLength?: number;
|
|
38
|
+
addon?: React.ReactNode;
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
alert?: TypeaheadAlert;
|
|
41
|
+
footer?: React.ReactNode;
|
|
42
|
+
validateChip?: (...args: any[])=>any;
|
|
43
|
+
onSearch?: (...args: any[])=>any;
|
|
44
|
+
onBlur?: (...args: any[])=>any;
|
|
45
|
+
onInputChange?: (...args: any[])=>any;
|
|
46
|
+
onFocus?: (...args: any[])=>any;
|
|
47
|
+
chipSeparators?: string[];
|
|
48
|
+
size?: TypeaheadSize;
|
|
49
|
+
inputAutoComplete?: string;
|
|
50
|
+
autoFillOnBlur?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default class Typeahead extends React.Component<TypeaheadProps, any> {
|
|
54
|
+
render(): JSX.Element;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
@@ -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.js"],"names":[],"mappings":"AAyBA;IACE,wBAWC;IARC,2BAAqE;IAErE;;;;;MAKC;IAGH,uDAeC;IAED,6BAEC;IAED,0BAOE;IAEF,kDAGE;IAEF,qCAoBE;IAEF,oCAiBE;IAEF,sCAmCE;IAEF,qCAYC;IAED,gCAiBE;IAEF,sCAME;IAEF,mCASE;IAEF,gCAgBE;IAEF,qBAWE;IAEF,qBAWE;IAEF,6CAOE;IAEF,4BASE;IAEF,kCAME;IAEF,mEAcE;IAEF;;;;;;;;;sCA0CE;IAEF,sCAmGC;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqEe,0CAAU;;;;;;;;;;AAle1B,gCAAyB;AADzB,0CAAmC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export default Typeahead;
|
|
2
|
+
import Typeahead 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.js"],"names":[],"mappings":""}
|
|
@@ -1,29 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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' | 'onFocus'>;
|
|
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>);
|
|
1
|
+
declare class TypeaheadInput extends Component<any, any, any> {
|
|
2
|
+
constructor();
|
|
3
|
+
state: {
|
|
4
|
+
inputWidth: number;
|
|
5
|
+
};
|
|
22
6
|
componentDidMount(): void;
|
|
23
|
-
componentDidUpdate(previousProps:
|
|
7
|
+
componentDidUpdate(previousProps: any): void;
|
|
24
8
|
recalculateWidth: () => void;
|
|
25
9
|
renderInput: () => import("react").JSX.Element;
|
|
10
|
+
inputRef: HTMLInputElement | null | undefined;
|
|
26
11
|
render(): import("react").JSX.Element;
|
|
12
|
+
sizerRef: HTMLDivElement | null | undefined;
|
|
27
13
|
}
|
|
28
|
-
|
|
14
|
+
declare namespace TypeaheadInput {
|
|
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";
|
|
29
47
|
//# 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.js"],"names":[],"mappings":"AAWA;IACE,cAKC;IAHC;;MAEC;IAGH,0BAKC;IAED,6CAIC;IAED,6BAME;IAEF,+CA4CE;IAtBM,8CAAyB;IAwBjC,sCA6BC;IAVS,4CAAyB;CAWpC"}
|
|
@@ -1,11 +1,19 @@
|
|
|
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;
|
|
10
1
|
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
|
+
}
|
|
11
19
|
//# 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.js"],"names":[],"mappings":";AAMA,iEAqBC;;;;;;;;;;;;;QAgBU,kCAAQ"}
|
|
@@ -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.js"],"names":[],"mappings":"AAAA,+DAeC"}
|
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-a53ae95",
|
|
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,11 +69,7 @@
|
|
|
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": "^
|
|
57
|
-
"@types/lodash": "4.14.202",
|
|
58
|
-
"@types/lodash.clamp": "^4.0.9",
|
|
59
|
-
"@types/lodash.debounce": "^4.0.9",
|
|
60
|
-
"@types/lodash.throttle": "^4.1.7",
|
|
72
|
+
"@types/jest": "^29.5.12",
|
|
61
73
|
"@types/node": "^14.14.31",
|
|
62
74
|
"@types/react": "^17.0.65",
|
|
63
75
|
"@types/react-dom": "^17.0.20",
|
|
@@ -69,8 +81,8 @@
|
|
|
69
81
|
"babel-plugin-formatjs": "^10.5.13",
|
|
70
82
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
71
83
|
"enzyme": "^3.11.0",
|
|
72
|
-
"jest": "^
|
|
73
|
-
"jest-
|
|
84
|
+
"jest": "^29.7.0",
|
|
85
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
74
86
|
"jest-fetch-mock": "^3.0.3",
|
|
75
87
|
"lodash.times": "^4.3.2",
|
|
76
88
|
"react-intl": "^5.10.0",
|
|
@@ -101,6 +113,7 @@
|
|
|
101
113
|
"@react-spring/web": "~9.6.1",
|
|
102
114
|
"@transferwise/formatting": "^2.1.0",
|
|
103
115
|
"@transferwise/neptune-validation": "^3.1.0",
|
|
116
|
+
"@types/lodash.throttle": "^4.1.7",
|
|
104
117
|
"classnames": "^2.2.6",
|
|
105
118
|
"commonmark": "0.29.1",
|
|
106
119
|
"core-js": "^3.8.0",
|
|
@@ -136,8 +149,8 @@
|
|
|
136
149
|
"build:copy-css": "cpx 'src/main.css' build/ & cpx 'src/**/*.css' build/styles/",
|
|
137
150
|
"build:copy-lang": "cpx 'src/i18n/*.json' build/i18n && cpx 'src/i18n/index.js' build/i18n",
|
|
138
151
|
"docs": "pnpm build",
|
|
139
|
-
"test": "jest
|
|
140
|
-
"test:watch": "jest --watch
|
|
152
|
+
"test": "jest",
|
|
153
|
+
"test:watch": "jest --watch",
|
|
141
154
|
"lint": "pnpm run lint:check",
|
|
142
155
|
"lint:check": "npm-run-all --parallel lint:check:*",
|
|
143
156
|
"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/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
|
|