@transferwise/components 0.0.0-experimental-0400704 → 0.0.0-experimental-c09cb11
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/dateLookup/dateTrigger/DateTrigger.js +8 -4
- package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
- package/build/dateLookup/dateTrigger/DateTrigger.mjs +8 -4
- package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
- package/build/field/Field.js +34 -7
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +34 -7
- package/build/field/Field.mjs.map +1 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/inlineAlert/InlineAlert.js +13 -6
- package/build/inlineAlert/InlineAlert.js.map +1 -1
- package/build/inlineAlert/InlineAlert.mjs +13 -6
- package/build/inlineAlert/InlineAlert.mjs.map +1 -1
- package/build/label/Label.js +49 -5
- package/build/label/Label.js.map +1 -1
- package/build/label/Label.messages.js +12 -0
- package/build/label/Label.messages.js.map +1 -0
- package/build/label/Label.messages.mjs +10 -0
- package/build/label/Label.messages.mjs.map +1 -0
- package/build/label/Label.mjs +50 -6
- package/build/label/Label.mjs.map +1 -1
- package/build/main.css +4 -8
- package/build/styles/dateLookup/dateTrigger/DateTrigger.css +0 -8
- package/build/styles/field/Field.css +4 -0
- package/build/styles/main.css +4 -8
- package/build/tabs/Tab.js +38 -13
- package/build/tabs/Tab.js.map +1 -1
- package/build/tabs/Tab.mjs +34 -13
- package/build/tabs/Tab.mjs.map +1 -1
- package/build/tabs/TabList.js +11 -3
- package/build/tabs/TabList.js.map +1 -1
- package/build/tabs/TabList.mjs +7 -3
- package/build/tabs/TabList.mjs.map +1 -1
- package/build/tabs/TabPanel.js +16 -3
- package/build/tabs/TabPanel.js.map +1 -1
- package/build/tabs/TabPanel.mjs +12 -3
- package/build/tabs/TabPanel.mjs.map +1 -1
- package/build/tabs/Tabs.js +48 -24
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs +47 -24
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/tabs/utils.js +1 -0
- package/build/tabs/utils.js.map +1 -1
- package/build/tabs/utils.mjs +1 -0
- package/build/tabs/utils.mjs.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +4 -2
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +9 -0
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/label/Label.d.ts +39 -3
- package/build/types/label/Label.d.ts.map +1 -1
- package/build/types/label/Label.messages.d.ts +8 -0
- package/build/types/label/Label.messages.d.ts.map +1 -0
- package/build/types/label/index.d.ts +3 -0
- package/build/types/label/index.d.ts.map +1 -0
- package/build/types/tabs/Tab.d.ts +1 -12
- package/build/types/tabs/Tab.d.ts.map +1 -1
- package/build/types/tabs/TabList.d.ts +8 -3
- package/build/types/tabs/TabList.d.ts.map +1 -1
- package/build/types/tabs/TabPanel.d.ts +14 -6
- package/build/types/tabs/TabPanel.d.ts.map +1 -1
- package/build/types/tabs/Tabs.d.ts +30 -83
- package/build/types/tabs/Tabs.d.ts.map +1 -1
- package/build/types/tabs/index.d.ts +1 -2
- package/build/types/tabs/index.d.ts.map +1 -1
- package/build/types/tabs/utils.d.ts +7 -12
- package/build/types/tabs/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/dateInput/DateInput.tests.story.tsx +6 -41
- package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
- package/src/dateLookup/dateTrigger/DateTrigger.css +0 -8
- package/src/dateLookup/dateTrigger/DateTrigger.less +0 -8
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
- package/src/dateLookup/dateTrigger/DateTrigger.tsx +9 -4
- package/src/field/Field.css +4 -0
- package/src/field/Field.less +5 -0
- package/src/field/Field.spec.tsx +41 -5
- package/src/field/Field.story.tsx +105 -7
- package/src/field/Field.tsx +33 -9
- package/src/i18n/en.json +1 -0
- package/src/index.ts +1 -2
- package/src/inlineAlert/InlineAlert.story.tsx +7 -72
- package/src/inlineAlert/InlineAlert.tsx +14 -3
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +5 -10
- package/src/inputs/InputGroup.spec.tsx +1 -1
- package/src/inputs/SearchInput.spec.tsx +1 -1
- package/src/inputs/SelectInput.spec.tsx +1 -1
- package/src/label/Label.messages.tsx +8 -0
- package/src/label/Label.spec.tsx +42 -7
- package/src/label/Label.story.tsx +30 -25
- package/src/label/Label.tsx +66 -8
- package/src/label/index.ts +2 -0
- package/src/main.css +4 -8
- package/src/main.less +1 -0
- package/src/moneyInput/MoneyInput.story.tsx +11 -11
- package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
- package/src/select/Select.rtl.spec.tsx +1 -1
- package/src/switch/Switch.spec.tsx +1 -1
- package/src/switch/Switch.story.tsx +19 -21
- package/src/tabs/Tab.js +71 -0
- package/src/tabs/TabList.js +15 -0
- package/src/tabs/TabPanel.js +20 -0
- package/src/tabs/{Tabs.tsx → Tabs.js} +74 -111
- package/src/tabs/{Tabs.story.tsx → Tabs.story.js} +1 -1
- package/src/tabs/index.js +1 -0
- package/src/tabs/{utils.ts → utils.js} +9 -15
- package/src/tabs/{utils.spec.ts → utils.spec.js} +21 -24
- package/src/field/Field.tests.story.tsx +0 -33
- package/src/tabs/Tab.tsx +0 -72
- package/src/tabs/TabList.tsx +0 -11
- package/src/tabs/TabPanel.tsx +0 -14
- package/src/tabs/index.ts +0 -2
|
@@ -5,13 +5,12 @@ import {
|
|
|
5
5
|
getSwipeDifference,
|
|
6
6
|
swipeShouldChangeTab,
|
|
7
7
|
getVelocity,
|
|
8
|
-
Swipe,
|
|
9
8
|
} from './utils';
|
|
10
9
|
|
|
11
10
|
describe('Tabs Utility', () => {
|
|
12
|
-
let start
|
|
13
|
-
let end
|
|
14
|
-
let coords
|
|
11
|
+
let start;
|
|
12
|
+
let end;
|
|
13
|
+
let coords;
|
|
15
14
|
|
|
16
15
|
beforeEach(() => {
|
|
17
16
|
jest.clearAllMocks();
|
|
@@ -19,8 +18,8 @@ describe('Tabs Utility', () => {
|
|
|
19
18
|
|
|
20
19
|
describe('when the ending x axis is greater than the starting x axis', () => {
|
|
21
20
|
beforeEach(() => {
|
|
22
|
-
start = { x: 0,
|
|
23
|
-
end = { x: 50,
|
|
21
|
+
start = { x: 0, time: 1569538800000 };
|
|
22
|
+
end = { x: 50, time: 1569538800300 };
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
it('determines that the swipe was left to right', () => {
|
|
@@ -35,8 +34,8 @@ describe('Tabs Utility', () => {
|
|
|
35
34
|
|
|
36
35
|
describe('when the ending x axis is less than the starting x axis', () => {
|
|
37
36
|
beforeEach(() => {
|
|
38
|
-
start = { x: 50,
|
|
39
|
-
end = { x: 0,
|
|
37
|
+
start = { x: 50, time: 1569538800000 };
|
|
38
|
+
end = { x: 0, time: 1569538800300 };
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
it('determines that the swipe was right to left', () => {
|
|
@@ -51,20 +50,20 @@ describe('Tabs Utility', () => {
|
|
|
51
50
|
|
|
52
51
|
describe('checking if a swipe should change tabs', () => {
|
|
53
52
|
it('should change tab when the difference and velocity are significant', () => {
|
|
54
|
-
start = { x: 0,
|
|
55
|
-
end = { x: 100,
|
|
53
|
+
start = { x: 0, time: 1569538800000 };
|
|
54
|
+
end = { x: 100, time: 1569538800001 };
|
|
56
55
|
expect(swipeShouldChangeTab(start, end)).toBe(true);
|
|
57
56
|
});
|
|
58
57
|
|
|
59
58
|
it('should not change tab when the difference is small', () => {
|
|
60
|
-
start = { x: 0,
|
|
61
|
-
end = { x: 1,
|
|
59
|
+
start = { x: 0, time: 1569538800000 };
|
|
60
|
+
end = { x: 1, time: 1569538800001 };
|
|
62
61
|
expect(swipeShouldChangeTab(start, end)).toBe(false);
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
it('should not change tab when the velocity is small', () => {
|
|
66
|
-
start = { x: 0,
|
|
67
|
-
end = { x: 100,
|
|
65
|
+
start = { x: 0, time: 1569538800000 };
|
|
66
|
+
end = { x: 100, time: 1569538900000 };
|
|
68
67
|
expect(swipeShouldChangeTab(start, end)).toBe(false);
|
|
69
68
|
});
|
|
70
69
|
});
|
|
@@ -72,11 +71,11 @@ describe('Tabs Utility', () => {
|
|
|
72
71
|
describe('checking for velocity against an array of touches', () => {
|
|
73
72
|
beforeEach(() => {
|
|
74
73
|
coords = [
|
|
75
|
-
{ x: 0,
|
|
76
|
-
{ x: 100,
|
|
77
|
-
{ x: 200,
|
|
78
|
-
{ x: 300,
|
|
79
|
-
{ x: 400,
|
|
74
|
+
{ x: 0, time: 1569538800000 },
|
|
75
|
+
{ x: 100, time: 1569538825000 },
|
|
76
|
+
{ x: 200, time: 1569538850000 },
|
|
77
|
+
{ x: 300, time: 1569538875000 },
|
|
78
|
+
{ x: 400, time: 1569538900000 },
|
|
80
79
|
];
|
|
81
80
|
});
|
|
82
81
|
|
|
@@ -85,15 +84,13 @@ describe('Tabs Utility', () => {
|
|
|
85
84
|
});
|
|
86
85
|
|
|
87
86
|
it('should only take into account the last 5 coordinates', () => {
|
|
88
|
-
coords.unshift(
|
|
89
|
-
{ x: 10000, y: 0, time: 1569538800000 },
|
|
90
|
-
{ x: 100000, y: 0, time: 1569538800000 },
|
|
91
|
-
);
|
|
87
|
+
coords.unshift({ x: 10000, time: 1569538800000 }, { x: 100000, time: 1569538800000 });
|
|
92
88
|
expect(getVelocity(coords)).toBe(0.004);
|
|
93
89
|
});
|
|
94
90
|
|
|
95
91
|
it('returns a default 0 if there are any issues with the touches passed in', () => {
|
|
96
92
|
expect(getVelocity([])).toBe(0);
|
|
93
|
+
expect(getVelocity([null, null, null])).toBe(0);
|
|
97
94
|
});
|
|
98
95
|
});
|
|
99
96
|
|
|
@@ -122,5 +119,5 @@ describe('Tabs Utility', () => {
|
|
|
122
119
|
});
|
|
123
120
|
});
|
|
124
121
|
|
|
125
|
-
const getApproximateElasticDragDifference = (difference
|
|
122
|
+
const getApproximateElasticDragDifference = (difference) =>
|
|
126
123
|
Math.round(getElasticDragDifference(difference));
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Input } from '../inputs/Input';
|
|
4
|
-
import { Field } from './Field';
|
|
5
|
-
import { Sentiment } from '../common';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
component: Field,
|
|
9
|
-
title: 'Field/Tests',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const WithHelpAndErrorOnBlur = () => {
|
|
13
|
-
const [value, setValue] = useState('This is some text');
|
|
14
|
-
const [error, setError] = useState<string | undefined>(undefined);
|
|
15
|
-
return (
|
|
16
|
-
<Field
|
|
17
|
-
label="Phone number"
|
|
18
|
-
sentiment={error ? Sentiment.NEGATIVE : Sentiment.NEUTRAL}
|
|
19
|
-
message={error || 'Please include country code'}
|
|
20
|
-
>
|
|
21
|
-
<Input
|
|
22
|
-
value={value}
|
|
23
|
-
onChange={({ target }) => {
|
|
24
|
-
setValue(target.value);
|
|
25
|
-
setError(undefined);
|
|
26
|
-
}}
|
|
27
|
-
onBlur={() => {
|
|
28
|
-
setError('Something went wrong');
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
</Field>
|
|
32
|
-
);
|
|
33
|
-
};
|
package/src/tabs/Tab.tsx
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { clsx } from 'clsx';
|
|
2
|
-
import { forwardRef, useEffect, useRef } from 'react';
|
|
3
|
-
import { useEffectEvent } from '../common/hooks/useEffectEvent';
|
|
4
|
-
|
|
5
|
-
export interface TabProps {
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
selected?: boolean;
|
|
9
|
-
id: string;
|
|
10
|
-
panelId: string;
|
|
11
|
-
style?: React.CSSProperties;
|
|
12
|
-
focusTab?: () => void;
|
|
13
|
-
onKeyDown: React.KeyboardEventHandler<HTMLLIElement>;
|
|
14
|
-
onClick?: React.MouseEventHandler<HTMLLIElement>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const noop = () => {};
|
|
18
|
-
|
|
19
|
-
const Tab = forwardRef(function Tab(
|
|
20
|
-
{
|
|
21
|
-
children,
|
|
22
|
-
id,
|
|
23
|
-
disabled,
|
|
24
|
-
panelId,
|
|
25
|
-
selected,
|
|
26
|
-
onKeyDown,
|
|
27
|
-
onClick,
|
|
28
|
-
style,
|
|
29
|
-
focusTab = noop,
|
|
30
|
-
}: TabProps,
|
|
31
|
-
reference: React.ForwardedRef<HTMLLIElement>,
|
|
32
|
-
) {
|
|
33
|
-
const handleFocusTab = useEffectEvent(focusTab);
|
|
34
|
-
const firstUpdate = useRef(true);
|
|
35
|
-
useEffect(
|
|
36
|
-
function checkFocus() {
|
|
37
|
-
if (firstUpdate.current) {
|
|
38
|
-
firstUpdate.current = false;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (selected) {
|
|
43
|
-
handleFocusTab();
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
[handleFocusTab, selected],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<li
|
|
51
|
-
ref={reference}
|
|
52
|
-
className={clsx('tabs__tab', selected ? 'np-text-body-large-bold' : 'np-text-body-large', {
|
|
53
|
-
'tabs__tab--selected': selected,
|
|
54
|
-
clickable: !disabled,
|
|
55
|
-
disabled,
|
|
56
|
-
})}
|
|
57
|
-
role="tab"
|
|
58
|
-
id={id}
|
|
59
|
-
aria-selected={selected ? 'true' : 'false'}
|
|
60
|
-
aria-disabled={disabled ? 'true' : 'false'}
|
|
61
|
-
aria-controls={disabled ? undefined : panelId}
|
|
62
|
-
tabIndex={0}
|
|
63
|
-
style={style}
|
|
64
|
-
onKeyDown={disabled ? undefined : onKeyDown}
|
|
65
|
-
onClick={onClick}
|
|
66
|
-
>
|
|
67
|
-
<span className="tabs__tab__content">{children}</span>
|
|
68
|
-
</li>
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
export default Tab;
|
package/src/tabs/TabList.tsx
DELETED
package/src/tabs/TabPanel.tsx
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface TabPanelProps {
|
|
2
|
-
children?: React.ReactNode;
|
|
3
|
-
id: string;
|
|
4
|
-
tabId: string;
|
|
5
|
-
style: React.CSSProperties;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function TabPanel({ children, id, tabId, style }: TabPanelProps) {
|
|
9
|
-
return (
|
|
10
|
-
<div className="tabs__panel" role="tabpanel" id={id} aria-labelledby={tabId} style={style}>
|
|
11
|
-
{children}
|
|
12
|
-
</div>
|
|
13
|
-
);
|
|
14
|
-
}
|
package/src/tabs/index.ts
DELETED