@transferwise/components 0.0.0-experimental-47ae02a → 0.0.0-experimental-3118bd2
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.map +1 -1
- package/build/index.mjs.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +6 -5
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +2 -2
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dateLookup/DateLookup.tsx +14 -9
- package/src/inputs/SelectInput.story.tsx +2 -2
- package/src/inputs/contexts.tsx +4 -4
- package/src/snackbar/Snackbar.story.tsx +4 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PureComponent, KeyboardEvent } from 'react';
|
|
2
2
|
import { Size, MonthFormat, SizeSmall, SizeMedium, SizeLarge } from '../common';
|
|
3
3
|
import { WithInputAttributesProps } from '../inputs/contexts';
|
|
4
|
-
export interface DateLookupProps
|
|
4
|
+
export interface DateLookupProps {
|
|
5
5
|
id?: string;
|
|
6
6
|
value: Date | null;
|
|
7
7
|
min?: Date | null;
|
|
@@ -17,6 +17,7 @@ export interface DateLookupProps extends Partial<WithInputAttributesProps> {
|
|
|
17
17
|
onFocus?: () => void;
|
|
18
18
|
onBlur?: () => void;
|
|
19
19
|
}
|
|
20
|
+
type DateLookupPropsWithInputAttributes = DateLookupProps & Partial<WithInputAttributesProps>;
|
|
20
21
|
interface DateLookupState {
|
|
21
22
|
selectedDate: Date | null;
|
|
22
23
|
originalDate: Date | null;
|
|
@@ -28,8 +29,8 @@ interface DateLookupState {
|
|
|
28
29
|
mode: 'day' | 'month' | 'year';
|
|
29
30
|
isMobile: boolean;
|
|
30
31
|
}
|
|
31
|
-
declare class DateLookup extends PureComponent<
|
|
32
|
-
props:
|
|
32
|
+
declare class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateLookupState> {
|
|
33
|
+
props: DateLookupPropsWithInputAttributes & Required<Pick<DateLookupPropsWithInputAttributes, keyof typeof DateLookup.defaultProps>>;
|
|
33
34
|
static defaultProps: {
|
|
34
35
|
value: null;
|
|
35
36
|
min: null;
|
|
@@ -51,7 +52,7 @@ declare class DateLookup extends PureComponent<DateLookupProps, DateLookupState>
|
|
|
51
52
|
viewMonth: number;
|
|
52
53
|
viewYear: number;
|
|
53
54
|
} | null;
|
|
54
|
-
componentDidUpdate(previousProps:
|
|
55
|
+
componentDidUpdate(previousProps: DateLookupPropsWithInputAttributes): void;
|
|
55
56
|
componentWillUnmount(): void;
|
|
56
57
|
open: () => void;
|
|
57
58
|
discard: () => void;
|
|
@@ -74,7 +75,7 @@ declare class DateLookup extends PureComponent<DateLookupProps, DateLookupState>
|
|
|
74
75
|
}
|
|
75
76
|
export declare const DateLookupWithoutInputAttributes: typeof DateLookup;
|
|
76
77
|
declare const _default: {
|
|
77
|
-
(props:
|
|
78
|
+
(props: Omit<DateLookupPropsWithInputAttributes, "inputAttributes">): import("react").JSX.Element;
|
|
78
79
|
displayName: string;
|
|
79
80
|
};
|
|
80
81
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EACL,IAAI,EACJ,WAAW,EAGX,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,wBAAwB,EAAuB,MAAM,oBAAoB,CAAC;AAOnF,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EACL,IAAI,EACJ,WAAW,EAGX,SA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Aa,CAAC,kCAAkC,EAAE,eAAe,CAAC;IACjF,KAAK,EAAE,kCAAkC,GAC/C,QAAQ,CAAC,IAAI,CAAC,kCAAkC,EAAE,MAAM,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;IAE3F,MAAM,CAAC,YAAY;;;;;;;;;;MAUqC;IAExD,OAAO,4CAA+B;IACtC,QAAQ,4CAA+B;gBAE3B,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;IAetC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,eAAe;;;;;;;IAwBlF,kBAAkB,CAAC,aAAa,EAAE,kCAAkC;IAQpE,oBAAoB;IAKpB,IAAI,aAOF;IAEF,OAAO,aAML;IAEF,KAAK,aAMH;IAEF,aAAa,UAAW,cAAc,cAAc,CAAC,UA6CnD;IAEF,UAAU,cAAe,MAAM,eAAe,MAAM,cAAc,MAAM,UAqBtE;IAEF,OAAO,qBAAsB,MAAM,oBAAoB,MAAM,UAO3D;IAEF,UAAU,SAAU,KAAK,GAAG,OAAO,GAAG,MAAM,UAI1C;IAEF,YAAY,aAAgC;IAE5C,cAAc,aAAkC;IAEhD,aAAa,aAAiC;IAE9C,wBAAwB,iBAAkB,IAAI,UAM5C;IAEF,oBAAoB;;;eAElB;IAEF,WAAW,oCA2CT;IAEF,WAAW,aAGT;IAEF,MAAM;CAiDP;AAED,eAAO,MAAM,gCAAgC,mBAAa,CAAC;;;;;AAE3D,wBAKE"}
|
|
@@ -16,8 +16,8 @@ export declare function useInputAttributes({ nonLabelable }?: UseInputAttributes
|
|
|
16
16
|
export interface WithInputAttributesProps {
|
|
17
17
|
inputAttributes: ReturnType<typeof useInputAttributes>;
|
|
18
18
|
}
|
|
19
|
-
export declare function withInputAttributes<T
|
|
20
|
-
(props: T): import("react").JSX.Element;
|
|
19
|
+
export declare function withInputAttributes<T extends Partial<WithInputAttributesProps>>(Component: React.ComponentType<T>, args?: UseInputAttributesArgs): {
|
|
20
|
+
(props: Omit<T, keyof WithInputAttributesProps>): import("react").JSX.Element;
|
|
21
21
|
displayName: string;
|
|
22
22
|
};
|
|
23
23
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/inputs/contexts.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,2BAA2B,8CAA+B,CAAC;AAGxE,eAAO,MAAM,sBAAsB,8CAA0B,CAAC;AAG9D,eAAO,MAAM,wBAAwB,8CAAmC,CAAC;AAGzE,eAAO,MAAM,oBAAoB,+CAA+B,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,gLAAgL;IAChL,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,YAAY,EAAE,GAAE,sBAA2B;;;;;EAQ/E;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;CACxD;AAED,wBAAgB,mBAAmB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/inputs/contexts.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,2BAA2B,8CAA+B,CAAC;AAGxE,eAAO,MAAM,sBAAsB,8CAA0B,CAAC;AAG9D,eAAO,MAAM,wBAAwB,8CAAmC,CAAC;AAGzE,eAAO,MAAM,oBAAoB,+CAA+B,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,gLAAgL;IAChL,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,YAAY,EAAE,GAAE,sBAA2B;;;;;EAQ/E;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;CACxD;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAC,wBAAwB,CAAC,EAC7E,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,IAAI,CAAC,EAAE,sBAAsB;YAEgB,KAAK,CAAC,EAAE,MAAM,wBAAwB,CAAC;;EAOrF"}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ import { getStartOfDay } from './getStartOfDay';
|
|
|
19
19
|
import MonthCalendar from './monthCalendar';
|
|
20
20
|
import YearCalendar from './yearCalendar';
|
|
21
21
|
|
|
22
|
-
export interface DateLookupProps
|
|
22
|
+
export interface DateLookupProps {
|
|
23
23
|
id?: string;
|
|
24
24
|
value: Date | null;
|
|
25
25
|
min?: Date | null;
|
|
@@ -36,6 +36,8 @@ export interface DateLookupProps extends Partial<WithInputAttributesProps> {
|
|
|
36
36
|
onBlur?: () => void;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
type DateLookupPropsWithInputAttributes = DateLookupProps & Partial<WithInputAttributesProps>;
|
|
40
|
+
|
|
39
41
|
interface DateLookupState {
|
|
40
42
|
selectedDate: Date | null;
|
|
41
43
|
originalDate: Date | null;
|
|
@@ -48,9 +50,9 @@ interface DateLookupState {
|
|
|
48
50
|
isMobile: boolean;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
class DateLookup extends PureComponent<
|
|
52
|
-
declare props:
|
|
53
|
-
Required<Pick<
|
|
53
|
+
class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateLookupState> {
|
|
54
|
+
declare props: DateLookupPropsWithInputAttributes &
|
|
55
|
+
Required<Pick<DateLookupPropsWithInputAttributes, keyof typeof DateLookup.defaultProps>>;
|
|
54
56
|
|
|
55
57
|
static defaultProps = {
|
|
56
58
|
value: null,
|
|
@@ -62,7 +64,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
62
64
|
monthFormat: MonthFormat.LONG,
|
|
63
65
|
disabled: false,
|
|
64
66
|
clearable: false,
|
|
65
|
-
} satisfies Partial<
|
|
67
|
+
} satisfies Partial<DateLookupPropsWithInputAttributes>;
|
|
66
68
|
|
|
67
69
|
element = createRef<HTMLDivElement>();
|
|
68
70
|
dropdown = createRef<HTMLDivElement>();
|
|
@@ -106,7 +108,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
106
108
|
return null;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
componentDidUpdate(previousProps:
|
|
111
|
+
componentDidUpdate(previousProps: DateLookupPropsWithInputAttributes) {
|
|
110
112
|
if (this.props.value?.getTime() !== previousProps.value?.getTime() && this.state.open) {
|
|
111
113
|
this.focusOn('.active');
|
|
112
114
|
}
|
|
@@ -350,6 +352,9 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
350
352
|
|
|
351
353
|
export const DateLookupWithoutInputAttributes = DateLookup;
|
|
352
354
|
|
|
353
|
-
export default withInputAttributes(
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
export default withInputAttributes(
|
|
356
|
+
DateLookup as React.ComponentType<DateLookupPropsWithInputAttributes>,
|
|
357
|
+
{
|
|
358
|
+
nonLabelable: true,
|
|
359
|
+
},
|
|
360
|
+
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { expect, fn, type Mock, screen, userEvent, within } from '@storybook/test';
|
|
2
|
+
import { expect, fn, type Mock, screen, userEvent, waitFor, within } from '@storybook/test';
|
|
3
3
|
import { Calendar, ChevronDown } from '@transferwise/icons';
|
|
4
4
|
import { Flag } from '@wise/art';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -197,7 +197,7 @@ export const Currencies: Story<Currency> = {
|
|
|
197
197
|
|
|
198
198
|
const input = screen.getByRole('searchbox');
|
|
199
199
|
|
|
200
|
-
await userEvent.click(input);
|
|
200
|
+
await userEvent.click(input); // TODO: Remove
|
|
201
201
|
await userEvent.type(input, 'huf');
|
|
202
202
|
await expect(
|
|
203
203
|
within(screen.getByRole('listbox')).queryByRole('option'),
|
package/src/inputs/contexts.tsx
CHANGED
|
@@ -31,12 +31,12 @@ export interface WithInputAttributesProps {
|
|
|
31
31
|
inputAttributes: ReturnType<typeof useInputAttributes>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function withInputAttributes<T
|
|
35
|
-
Component: React.ComponentType<T
|
|
34
|
+
export function withInputAttributes<T extends Partial<WithInputAttributesProps>>(
|
|
35
|
+
Component: React.ComponentType<T>,
|
|
36
36
|
args?: UseInputAttributesArgs,
|
|
37
37
|
) {
|
|
38
|
-
function ComponentWithInputAttributes(props: T) {
|
|
39
|
-
return <Component inputAttributes={useInputAttributes(args)} {...props} />;
|
|
38
|
+
function ComponentWithInputAttributes(props: Omit<T, keyof WithInputAttributesProps>) {
|
|
39
|
+
return <Component inputAttributes={useInputAttributes(args)} {...(props as T)} />;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions';
|
|
2
2
|
import { number } from '@storybook/addon-knobs';
|
|
3
3
|
import { StoryContext } from '@storybook/react';
|
|
4
|
-
import { userEvent, within } from '@storybook/test';
|
|
4
|
+
import { userEvent, waitFor, within } from '@storybook/test';
|
|
5
5
|
import { Mobile, Theme, Switch, Bulb, Info, Coins } from '@transferwise/icons';
|
|
6
6
|
|
|
7
7
|
import Button from '../button';
|
|
@@ -123,5 +123,7 @@ export const basic = () => {
|
|
|
123
123
|
|
|
124
124
|
basic.play = async ({ canvasElement }: StoryContext) => {
|
|
125
125
|
const canvas = within(canvasElement);
|
|
126
|
-
await
|
|
126
|
+
await waitFor(async () => {
|
|
127
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
128
|
+
});
|
|
127
129
|
};
|