@transferwise/components 0.0.0-experimental-ef158b4 → 0.0.0-experimental-4f82861
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 +139 -46
- package/build/index.esm.js.map +1 -1
- package/build/index.js +139 -46
- package/build/index.js.map +1 -1
- package/build/main.css +2 -1
- package/build/styles/main.css +2 -1
- package/build/styles/modal/Modal.css +2 -1
- package/build/types/typeahead/Typeahead.d.ts +57 -98
- package/build/types/typeahead/Typeahead.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/package.json +1 -4
- package/src/main.css +2 -1
- package/src/modal/Modal.css +2 -1
- package/src/modal/Modal.less +1 -1
- package/src/modal/Modal.story.tsx +53 -21
- package/src/typeahead/{Typeahead.tsx → Typeahead.js} +106 -105
- package/src/typeahead/{Typeahead.story.tsx → Typeahead.story.js} +7 -8
- package/src/typeahead/typeaheadInput/{TypeaheadInput.tsx → TypeaheadInput.js} +42 -43
- package/src/typeahead/typeaheadOption/{TypeaheadOption.tsx → TypeaheadOption.js} +20 -10
package/build/main.css
CHANGED
package/build/styles/main.css
CHANGED
|
@@ -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>, "keyboardFocusedOptionIndex" | "query"> & {
|
|
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,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: HTMLInputElement | null;
|
|
20
|
-
sizerRef: HTMLDivElement | null;
|
|
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"}
|
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-4f82861",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -97,9 +97,6 @@
|
|
|
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",
|
|
103
100
|
"@types/lodash.throttle": "^4.1.7",
|
|
104
101
|
"classnames": "^2.2.6",
|
|
105
102
|
"commonmark": "0.29.1",
|
package/src/main.css
CHANGED
package/src/modal/Modal.css
CHANGED
package/src/modal/Modal.less
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions';
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { ScreenMode, ThemeProvider } from '@wise/components-theming';
|
|
3
4
|
import { useState } from 'react';
|
|
4
5
|
|
|
5
|
-
import { Button, Modal } from '..';
|
|
6
|
-
import { Scroll } from '../common';
|
|
7
|
-
import { lorem10, lorem1000, storyConfig } from '../test-utils';
|
|
6
|
+
import { Button, Modal, ModalProps } from '..';
|
|
7
|
+
import { CommonProps, Scroll } from '../common';
|
|
8
|
+
import { lorem10, lorem100, lorem1000, storyConfig } from '../test-utils';
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
component: Modal,
|
|
@@ -23,6 +24,39 @@ export default {
|
|
|
23
24
|
|
|
24
25
|
type Story = StoryObj<typeof Modal>;
|
|
25
26
|
|
|
27
|
+
export interface StoryContentProps {
|
|
28
|
+
args: CommonProps & ModalProps;
|
|
29
|
+
screenMode?: ScreenMode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const StoryContent = ({ args, screenMode }: StoryContentProps) => {
|
|
33
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
34
|
+
const [open, setOpen] = useState(args.open);
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<Button onClick={() => setOpen(true)}>Open Modal</Button>
|
|
38
|
+
<Modal
|
|
39
|
+
{...args}
|
|
40
|
+
body={
|
|
41
|
+
!screenMode ? (
|
|
42
|
+
args.body
|
|
43
|
+
) : (
|
|
44
|
+
<ThemeProvider theme="personal" screenMode={screenMode}>
|
|
45
|
+
{lorem100}
|
|
46
|
+
</ThemeProvider>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
open={open}
|
|
50
|
+
disableDimmerClickToClose={args.disableDimmerClickToClose}
|
|
51
|
+
onClose={() => {
|
|
52
|
+
setOpen(false);
|
|
53
|
+
action('Modal closed')();
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
26
60
|
export const Basic: Story = {
|
|
27
61
|
args: {
|
|
28
62
|
title: 'Title',
|
|
@@ -30,24 +64,7 @@ export const Basic: Story = {
|
|
|
30
64
|
scroll: Scroll.VIEWPORT,
|
|
31
65
|
footer: <Button block>Action</Button>,
|
|
32
66
|
},
|
|
33
|
-
render: (args) => {
|
|
34
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
35
|
-
const [open, setOpen] = useState(args.open);
|
|
36
|
-
return (
|
|
37
|
-
<>
|
|
38
|
-
<Button onClick={() => setOpen(true)}>Open Modal</Button>
|
|
39
|
-
<Modal
|
|
40
|
-
{...args}
|
|
41
|
-
open={open}
|
|
42
|
-
disableDimmerClickToClose={args.disableDimmerClickToClose}
|
|
43
|
-
onClose={() => {
|
|
44
|
-
setOpen(false);
|
|
45
|
-
action('Modal closed')();
|
|
46
|
-
}}
|
|
47
|
-
/>
|
|
48
|
-
</>
|
|
49
|
-
);
|
|
50
|
-
},
|
|
67
|
+
render: (args) => <StoryContent args={args} />,
|
|
51
68
|
};
|
|
52
69
|
|
|
53
70
|
export const BasicMobile: Story = storyConfig(Basic, { variants: ['mobile'] });
|
|
@@ -80,3 +97,18 @@ export const WithoutTitle: Story = {
|
|
|
80
97
|
};
|
|
81
98
|
|
|
82
99
|
export const WithoutTitleMobile: Story = storyConfig(WithoutTitle, { variants: ['mobile'] });
|
|
100
|
+
|
|
101
|
+
export const WithThemeProviderInContentProps: Story = {
|
|
102
|
+
args: {
|
|
103
|
+
title: lorem10,
|
|
104
|
+
body: lorem100,
|
|
105
|
+
scroll: Scroll.VIEWPORT,
|
|
106
|
+
footer: <Button block>Action</Button>,
|
|
107
|
+
},
|
|
108
|
+
render: (args, { globals: { screenMode } }) => (
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
110
|
+
<StoryContent args={args} screenMode={screenMode} />
|
|
111
|
+
),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const WithThemeProviderInContent: Story = storyConfig(WithThemeProviderInContentProps, {});
|