@transferwise/components 0.0.0-experimental-35ce2be → 0.0.0-experimental-10c3d0b
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 +5 -5
- package/build/index.esm.js.map +1 -1
- package/build/index.js +5 -5
- package/build/index.js.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/fakeEvents.js +18 -0
- package/src/dateLookup/DateLookup.story.js +1 -1
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +3 -2
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +1 -5
- package/src/logo/Logo.js +4 -4
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +3 -1
- package/src/typeahead/Typeahead.js +5 -6
- package/src/typeahead/Typeahead.spec.js +0 -2
- package/src/typeahead/Typeahead.story.js +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../../src/typeahead/Typeahead.js"],"names":[],"mappings":"
|
|
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"}
|
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-10c3d0b",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"@babel/preset-typescript": "^7.22.15",
|
|
29
29
|
"@formatjs/cli": "^4.8.3",
|
|
30
30
|
"@rollup/plugin-babel": "^6.0.3",
|
|
31
|
-
"@rollup/plugin-image": "^3.0.2",
|
|
32
31
|
"@rollup/plugin-json": "^6.0.0",
|
|
33
32
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
34
33
|
"@rollup/plugin-typescript": "^11.1.3",
|
|
34
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
35
35
|
"@storybook/addon-a11y": "^7.6.17",
|
|
36
36
|
"@storybook/addon-actions": "^7.6.17",
|
|
37
37
|
"@storybook/addon-essentials": "^7.6.17",
|
package/src/common/fakeEvents.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
+
import keyCodes from './keyCodes';
|
|
2
|
+
|
|
1
3
|
export const fakeEvent = () => ({
|
|
2
4
|
nativeEvent: { stopImmediatePropagation() {} },
|
|
3
5
|
stopPropagation() {},
|
|
4
6
|
preventDefault() {},
|
|
5
7
|
});
|
|
6
8
|
|
|
9
|
+
const keyByKeyCode = {
|
|
10
|
+
[keyCodes.DOWN]: 'ArrowDown',
|
|
11
|
+
[keyCodes.UP]: 'ArrowUp',
|
|
12
|
+
[keyCodes.LEFT]: 'ArrowLeft',
|
|
13
|
+
[keyCodes.RIGHT]: 'ArrowRight',
|
|
14
|
+
[keyCodes.ENTER]: 'Enter',
|
|
15
|
+
[keyCodes.ESCAPE]: 'Escape',
|
|
16
|
+
[keyCodes.TAB]: 'Tab',
|
|
17
|
+
[keyCodes.SPACE]: ' ',
|
|
18
|
+
[keyCodes.BACKSPACE]: 'Backspace',
|
|
19
|
+
[keyCodes.DELETE]: 'Delete',
|
|
20
|
+
[keyCodes.COMMA]: ',',
|
|
21
|
+
[keyCodes.PERIOD]: '.',
|
|
22
|
+
};
|
|
23
|
+
|
|
7
24
|
export const fakeKeyDownEventForKey = (keyCode) => ({
|
|
8
25
|
...fakeEvent(),
|
|
9
26
|
keyCode,
|
|
27
|
+
key: keyByKeyCode[keyCode],
|
|
10
28
|
});
|
|
11
29
|
|
|
12
30
|
export const fakeKeyDownEvent = (eventAttribute = {}) => ({
|
|
@@ -50,7 +50,7 @@ Basic.play = async ({ canvasElement }) => {
|
|
|
50
50
|
// testing focus state on keyboard nav
|
|
51
51
|
const canvas = within(canvasElement);
|
|
52
52
|
await userEvent.tab(canvas.getByRole('button'));
|
|
53
|
-
await userEvent.keyboard('
|
|
53
|
+
await userEvent.keyboard(' ');
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export const Basic400Zoom = storyConfig(
|
|
@@ -3,6 +3,7 @@ import { shallow } from 'enzyme';
|
|
|
3
3
|
|
|
4
4
|
import Chevron from '../../chevron';
|
|
5
5
|
import { fakeKeyDownEventForKey } from '../../common/fakeEvents';
|
|
6
|
+
import keyCodes from '../../common/keyCodes';
|
|
6
7
|
|
|
7
8
|
import DateTrigger from '.';
|
|
8
9
|
|
|
@@ -111,14 +112,14 @@ describe('DateTrigger', () => {
|
|
|
111
112
|
it('calls onClear when user press Space', () => {
|
|
112
113
|
const onClear = jest.fn();
|
|
113
114
|
component.setProps({ onClear });
|
|
114
|
-
clearButton().simulate('keypress', fakeKeyDownEventForKey(
|
|
115
|
+
clearButton().simulate('keypress', fakeKeyDownEventForKey(keyCodes.SPACE));
|
|
115
116
|
expect(onClear).toHaveBeenCalledTimes(1);
|
|
116
117
|
});
|
|
117
118
|
|
|
118
119
|
it('calls onClear when user press Enter', () => {
|
|
119
120
|
const onClear = jest.fn();
|
|
120
121
|
component.setProps({ onClear });
|
|
121
|
-
clearButton().simulate('keypress', fakeKeyDownEventForKey(
|
|
122
|
+
clearButton().simulate('keypress', fakeKeyDownEventForKey(keyCodes.ENTER));
|
|
122
123
|
expect(onClear).toHaveBeenCalledTimes(1);
|
|
123
124
|
});
|
|
124
125
|
|
|
@@ -85,9 +85,5 @@ SecurityPinPlay.args = {
|
|
|
85
85
|
|
|
86
86
|
SecurityPinPlay.play = async ({ canvasElement }) => {
|
|
87
87
|
const canvas = within(canvasElement);
|
|
88
|
-
|
|
89
|
-
while (i < 6) {
|
|
90
|
-
await userEvent.type(canvas.getByPlaceholderText('*-*-*-*-*-*'), `${i + 1}`);
|
|
91
|
-
i++;
|
|
92
|
-
}
|
|
88
|
+
await userEvent.type(canvas.getByPlaceholderText('*-*-*-*-*-*'), '123456');
|
|
93
89
|
};
|
package/src/logo/Logo.js
CHANGED
|
@@ -2,10 +2,10 @@ import classNames from 'classnames';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import { LogoType } from './logoTypes';
|
|
5
|
-
import LogoFlagInverse from './svg/flag-inverse.svg';
|
|
6
|
-
import LogoFlag from './svg/flag.svg';
|
|
7
|
-
import LogoWiseInverse from './svg/logo-inverse.svg';
|
|
8
|
-
import LogoWise from './svg/logo.svg';
|
|
5
|
+
import { ReactComponent as LogoFlagInverse } from './svg/flag-inverse.svg';
|
|
6
|
+
import { ReactComponent as LogoFlag } from './svg/flag.svg';
|
|
7
|
+
import { ReactComponent as LogoWiseInverse } from './svg/logo-inverse.svg';
|
|
8
|
+
import { ReactComponent as LogoWise } from './svg/logo.svg';
|
|
9
9
|
|
|
10
10
|
const svgPaths = {
|
|
11
11
|
WISE: LogoWise,
|
|
@@ -26,6 +26,8 @@ export const Basic: Story = {
|
|
|
26
26
|
// to trigger event handlers in the component
|
|
27
27
|
play: async ({ canvasElement }) => {
|
|
28
28
|
const canvas = within(canvasElement);
|
|
29
|
-
await userEvent.type(canvas.getByRole('textbox'), '111122223333'
|
|
29
|
+
await userEvent.type(canvas.getByRole('textbox'), '111122223333', {
|
|
30
|
+
initialSelectionStart: Number.MAX_SAFE_INTEGER,
|
|
31
|
+
});
|
|
30
32
|
},
|
|
31
33
|
};
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
addClickClassToDocumentOnIos,
|
|
16
16
|
removeClickClassFromDocumentOnIos,
|
|
17
17
|
} from '../common/domHelpers';
|
|
18
|
-
import KeyCodes from '../common/keyCodes';
|
|
19
18
|
import InlineAlert from '../inlineAlert';
|
|
20
19
|
|
|
21
20
|
import TypeaheadInput from './typeaheadInput/TypeaheadInput';
|
|
@@ -123,16 +122,16 @@ export default class Typeahead extends Component {
|
|
|
123
122
|
event.preventDefault();
|
|
124
123
|
this.selectItem({ label: query });
|
|
125
124
|
} else {
|
|
126
|
-
switch (event.
|
|
127
|
-
case
|
|
125
|
+
switch (event.key) {
|
|
126
|
+
case 'ArrowDown':
|
|
128
127
|
event.preventDefault();
|
|
129
128
|
this.moveFocusedOption(1);
|
|
130
129
|
break;
|
|
131
|
-
case
|
|
130
|
+
case 'ArrowUp':
|
|
132
131
|
event.preventDefault();
|
|
133
132
|
this.moveFocusedOption(-1);
|
|
134
133
|
break;
|
|
135
|
-
case
|
|
134
|
+
case 'Enter':
|
|
136
135
|
event.preventDefault();
|
|
137
136
|
if (options[keyboardFocusedOptionIndex]) {
|
|
138
137
|
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
@@ -140,7 +139,7 @@ export default class Typeahead extends Component {
|
|
|
140
139
|
this.selectItem({ label: query });
|
|
141
140
|
}
|
|
142
141
|
break;
|
|
143
|
-
case
|
|
142
|
+
case 'Backspace':
|
|
144
143
|
if (multiple && !query && selected.length > 0) {
|
|
145
144
|
this.updateSelectedValue(selected.slice(0, -1));
|
|
146
145
|
}
|
|
@@ -94,7 +94,6 @@ describe('Typeahead', () => {
|
|
|
94
94
|
it('removes last selected value when backspace clicked on empty input', () => {
|
|
95
95
|
const event = {
|
|
96
96
|
key: 'Backspace',
|
|
97
|
-
keyCode: KeyCodes.BACKSPACE,
|
|
98
97
|
};
|
|
99
98
|
|
|
100
99
|
component.setProps({
|
|
@@ -116,7 +115,6 @@ describe('Typeahead', () => {
|
|
|
116
115
|
it('does not remove last selected value when backspace clicked on non-empty input', () => {
|
|
117
116
|
const event = {
|
|
118
117
|
key: 'Backspace',
|
|
119
|
-
keyCode: KeyCodes.BACKSPACE,
|
|
120
118
|
};
|
|
121
119
|
|
|
122
120
|
component.setProps({
|
|
@@ -45,7 +45,7 @@ export const createable = () => {
|
|
|
45
45
|
|
|
46
46
|
createable.play = async ({ canvasElement }) => {
|
|
47
47
|
const canvas = within(canvasElement);
|
|
48
|
-
await userEvent.type(canvas.getByRole('combobox'), 'chip{
|
|
48
|
+
await userEvent.type(canvas.getByRole('combobox'), 'chip{Enter}chip2{Enter}');
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export const Basic = () => {
|
|
@@ -117,6 +117,5 @@ export const Basic = () => {
|
|
|
117
117
|
|
|
118
118
|
Basic.play = async ({ canvasElement }) => {
|
|
119
119
|
const canvas = within(canvasElement);
|
|
120
|
-
await userEvent.type(canvas.getByRole('combobox'), 'abc');
|
|
121
|
-
await userEvent.type(canvas.getByRole('combobox'), '{arrowDown}');
|
|
120
|
+
await userEvent.type(canvas.getByRole('combobox'), 'abc{ArrowDown}');
|
|
122
121
|
};
|