@transferwise/components 46.8.0 → 46.10.0
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 +76 -127
- package/build/index.esm.js.map +1 -1
- package/build/index.js +76 -127
- package/build/index.js.map +1 -1
- package/build/types/checkboxOption/CheckboxOption.d.ts +2 -2
- package/build/types/checkboxOption/CheckboxOption.d.ts.map +1 -1
- package/build/types/common/index.d.ts +0 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +2 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/snackbar/Snackbar.d.ts +30 -22
- package/build/types/snackbar/Snackbar.d.ts.map +1 -1
- package/build/types/snackbar/SnackbarContext.d.ts +7 -2
- package/build/types/snackbar/SnackbarContext.d.ts.map +1 -1
- package/build/types/snackbar/SnackbarProvider.d.ts +7 -12
- package/build/types/snackbar/SnackbarProvider.d.ts.map +1 -1
- package/build/types/snackbar/index.d.ts +2 -0
- package/build/types/snackbar/index.d.ts.map +1 -0
- package/build/types/snackbar/useSnackbar.d.ts +1 -1
- package/build/types/snackbar/useSnackbar.d.ts.map +1 -1
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/build/types/tabs/Tabs.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/withNextPortal/withNextPortal.d.ts +1 -1
- package/build/types/withNextPortal/withNextPortal.d.ts.map +1 -1
- package/package.json +16 -19
- package/src/button/Button.story.tsx +3 -3
- package/src/checkboxOption/CheckboxOption.tsx +2 -2
- package/src/common/fakeEvents.js +2 -2
- package/src/common/index.js +0 -1
- package/src/dateInput/DateInput.story.tsx +4 -3
- package/src/dateLookup/DateLookup.js +6 -7
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +24 -25
- package/src/dateLookup/DateLookup.story.js +4 -3
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +3 -3
- package/src/index.ts +2 -0
- package/src/info/Info.story.tsx +3 -3
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +2 -7
- package/src/inputs/SelectInput.spec.tsx +7 -0
- package/src/inputs/SelectInput.story.tsx +7 -7
- package/src/inputs/SelectInput.tsx +4 -0
- package/src/logo/Logo.js +4 -4
- package/src/moneyInput/MoneyInput.story.tsx +3 -3
- package/src/moneyInput/MoneyInput.tsx +14 -24
- package/src/select/Select.js +8 -9
- package/src/snackbar/{Snackbar.story.js → Snackbar.story.tsx} +4 -3
- package/src/snackbar/{Snackbar.js → Snackbar.tsx} +31 -32
- package/src/snackbar/SnackbarContext.ts +11 -0
- package/src/snackbar/SnackbarProvider.tsx +39 -0
- package/src/switch/Switch.spec.js +2 -3
- package/src/switch/Switch.tsx +1 -2
- package/src/switchOption/SwitchOption.spec.js +1 -4
- package/src/tabs/Tabs.js +1 -2
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +5 -4
- package/src/tile/Tile.js +2 -2
- package/src/tile/Tile.spec.js +5 -5
- package/src/tooltip/Tooltip.story.tsx +3 -3
- package/src/typeahead/Typeahead.js +5 -6
- package/src/typeahead/Typeahead.spec.js +3 -8
- package/src/typeahead/Typeahead.story.js +3 -4
- package/src/withNextPortal/withNextPortal.tsx +1 -1
- package/build/types/common/key.d.ts +0 -9
- package/build/types/common/key.d.ts.map +0 -1
- package/build/types/common/keyCodes.d.ts +0 -16
- package/build/types/common/keyCodes.d.ts.map +0 -1
- package/src/common/key.js +0 -8
- package/src/common/keyCodes.js +0 -19
- package/src/snackbar/SnackbarContext.js +0 -4
- package/src/snackbar/SnackbarProvider.js +0 -51
- /package/src/snackbar/{index.js → index.ts} +0 -0
- /package/src/snackbar/{useSnackbar.js → useSnackbar.ts} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import SnackbarPortal, { SnackbarProps } from './Snackbar';
|
|
4
|
+
import { SnackbarContext } from './SnackbarContext';
|
|
5
|
+
|
|
6
|
+
export interface SnackbarProviderProps {
|
|
7
|
+
timeout?: number;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function SnackbarProvider({ timeout = 4500, children }: SnackbarProviderProps) {
|
|
12
|
+
const [state, setState] = useState<Omit<SnackbarProps, 'timeout'>>({
|
|
13
|
+
text: '',
|
|
14
|
+
timestamp: 0,
|
|
15
|
+
});
|
|
16
|
+
const { action, text, theme, timestamp } = state;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<SnackbarContext.Provider
|
|
20
|
+
value={useMemo(
|
|
21
|
+
() => ({
|
|
22
|
+
createSnackbar: ({ action, text, theme }) => {
|
|
23
|
+
setState({ action, text, theme, timestamp: Date.now() });
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
[],
|
|
27
|
+
)}
|
|
28
|
+
>
|
|
29
|
+
<SnackbarPortal
|
|
30
|
+
action={action}
|
|
31
|
+
text={text}
|
|
32
|
+
timestamp={timestamp}
|
|
33
|
+
timeout={timeout}
|
|
34
|
+
theme={theme}
|
|
35
|
+
/>
|
|
36
|
+
{children}
|
|
37
|
+
</SnackbarContext.Provider>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import KeyCodes from '../common/keyCodes';
|
|
2
1
|
import { render, fireEvent, screen } from '../test-utils';
|
|
3
2
|
|
|
4
3
|
import Switch from './Switch';
|
|
@@ -69,9 +68,9 @@ describe('Switch', () => {
|
|
|
69
68
|
);
|
|
70
69
|
|
|
71
70
|
const input = screen.getAllByRole('checkbox')[0];
|
|
72
|
-
fireEvent.keyDown(input, { key: '
|
|
71
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
73
72
|
expect(props.onClick).not.toHaveBeenCalled();
|
|
74
|
-
fireEvent.keyDown(input, { key: '
|
|
73
|
+
fireEvent.keyDown(input, { key: ' ' });
|
|
75
74
|
expect(props.onClick).toHaveBeenCalledTimes(1);
|
|
76
75
|
});
|
|
77
76
|
|
package/src/switch/Switch.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import classnames from 'classnames';
|
|
|
4
4
|
import { KeyboardEventHandler, MouseEvent, ReactElement } from 'react';
|
|
5
5
|
|
|
6
6
|
import { CommonProps } from '../common';
|
|
7
|
-
import KeyCodes from '../common/keyCodes';
|
|
8
7
|
import { logActionRequiredIf } from '../utilities';
|
|
9
8
|
|
|
10
9
|
type Props = CommonProps & {
|
|
@@ -26,7 +25,7 @@ const Switch = (props: Props): ReactElement => {
|
|
|
26
25
|
const { checked, className, id, onClick, disabled } = props;
|
|
27
26
|
|
|
28
27
|
const handleKeyDown: KeyboardEventHandler = (event) => {
|
|
29
|
-
if (event.
|
|
28
|
+
if (event.key === ' ') {
|
|
30
29
|
event.preventDefault();
|
|
31
30
|
onClick();
|
|
32
31
|
}
|
|
@@ -63,10 +63,7 @@ describe('SwitchOption', () => {
|
|
|
63
63
|
|
|
64
64
|
expect(getSwitch()).toBeChecked();
|
|
65
65
|
|
|
66
|
-
fireEvent.keyDown(getSwitch(), {
|
|
67
|
-
keyCode: 32,
|
|
68
|
-
code: 'Space',
|
|
69
|
-
});
|
|
66
|
+
fireEvent.keyDown(getSwitch(), { key: ' ' });
|
|
70
67
|
|
|
71
68
|
expect(mockOnChange).toHaveBeenLastCalledWith(false);
|
|
72
69
|
expect(mockOnChange).toHaveBeenCalledTimes(2);
|
package/src/tabs/Tabs.js
CHANGED
|
@@ -6,7 +6,6 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { Component, createRef, Fragment, RefObject } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Size, Width, Direction } from '../common';
|
|
9
|
-
import KeyCodes from '../common/keyCodes';
|
|
10
9
|
import { DirectionContext } from '../provider/direction';
|
|
11
10
|
|
|
12
11
|
import Tab from './Tab';
|
|
@@ -294,7 +293,7 @@ class Tabs extends Component {
|
|
|
294
293
|
};
|
|
295
294
|
|
|
296
295
|
onKeyDown = (index) => (event) => {
|
|
297
|
-
if (event && event.
|
|
296
|
+
if (event && event.key === 'Enter') {
|
|
298
297
|
this.switchTab(index);
|
|
299
298
|
}
|
|
300
299
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { userEvent, within } from '../test-utils';
|
|
2
|
+
import { userEvent, within } from '@storybook/test';
|
|
4
3
|
|
|
5
4
|
import TextareaWithDisplayFormat from './TextareaWithDisplayFormat';
|
|
6
5
|
|
|
@@ -25,8 +24,10 @@ export const Basic: Story = {
|
|
|
25
24
|
},
|
|
26
25
|
// intentionally use interactive typing (over init value via `value` prop)
|
|
27
26
|
// to trigger event handlers in the component
|
|
28
|
-
play: ({ canvasElement }) => {
|
|
27
|
+
play: async ({ canvasElement }) => {
|
|
29
28
|
const canvas = within(canvasElement);
|
|
30
|
-
userEvent.type(canvas.getByRole('textbox'), '111122223333'
|
|
29
|
+
await userEvent.type(canvas.getByRole('textbox'), '111122223333', {
|
|
30
|
+
initialSelectionStart: Number.MAX_SAFE_INTEGER,
|
|
31
|
+
});
|
|
31
32
|
},
|
|
32
33
|
};
|
package/src/tile/Tile.js
CHANGED
|
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import Body from '../body';
|
|
5
|
-
import { Size,
|
|
5
|
+
import { Size, Typography } from '../common';
|
|
6
6
|
import Title from '../title';
|
|
7
7
|
|
|
8
8
|
export const Tile = ({
|
|
@@ -41,7 +41,7 @@ export const Tile = ({
|
|
|
41
41
|
disabled
|
|
42
42
|
? null
|
|
43
43
|
: ({ key }) => {
|
|
44
|
-
if (key ===
|
|
44
|
+
if (key === 'Enter' || key === ' ') {
|
|
45
45
|
onClick();
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/tile/Tile.spec.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Size } from '../common';
|
|
2
2
|
import { render, fireEvent, screen } from '../test-utils';
|
|
3
3
|
|
|
4
4
|
import Tile from '.';
|
|
@@ -44,11 +44,11 @@ describe(Tile, () => {
|
|
|
44
44
|
|
|
45
45
|
const title = screen.getByText('Receive money');
|
|
46
46
|
|
|
47
|
-
fireEvent.keyDown(title, { key:
|
|
47
|
+
fireEvent.keyDown(title, { key: 'Enter' });
|
|
48
48
|
|
|
49
49
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
50
50
|
|
|
51
|
-
fireEvent.keyDown(title, { key:
|
|
51
|
+
fireEvent.keyDown(title, { key: ' ' });
|
|
52
52
|
|
|
53
53
|
expect(onClick).toHaveBeenCalledTimes(2);
|
|
54
54
|
});
|
|
@@ -66,11 +66,11 @@ describe(Tile, () => {
|
|
|
66
66
|
|
|
67
67
|
const title = screen.getByText('Receive money');
|
|
68
68
|
|
|
69
|
-
fireEvent.keyDown(title, { key:
|
|
69
|
+
fireEvent.keyDown(title, { key: 'Enter' });
|
|
70
70
|
|
|
71
71
|
expect(onClick).not.toHaveBeenCalled();
|
|
72
72
|
|
|
73
|
-
fireEvent.keyDown(title, { key:
|
|
73
|
+
fireEvent.keyDown(title, { key: ' ' });
|
|
74
74
|
|
|
75
75
|
expect(onClick).not.toHaveBeenCalled();
|
|
76
76
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { userEvent, within } from '@storybook/
|
|
2
|
+
import { userEvent, within } from '@storybook/test';
|
|
3
3
|
|
|
4
4
|
import Button from '../button';
|
|
5
5
|
import { storyConfig } from '../test-utils';
|
|
@@ -33,9 +33,9 @@ export const OpenedTooltip: Story = {
|
|
|
33
33
|
delay: 1000,
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
|
-
play: ({ canvasElement }) => {
|
|
36
|
+
play: async ({ canvasElement }) => {
|
|
37
37
|
const canvas = within(canvasElement);
|
|
38
|
-
userEvent.hover(canvas.getByRole('button'));
|
|
38
|
+
await userEvent.hover(canvas.getByRole('button'));
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -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
|
}
|
|
@@ -4,7 +4,6 @@ import doTimes from 'lodash.times';
|
|
|
4
4
|
import { InlineAlert } from '..';
|
|
5
5
|
import { Sentiment } from '../common';
|
|
6
6
|
import { fakeEvent, fakeKeyDownEventForKey } from '../common/fakeEvents';
|
|
7
|
-
import KeyCodes from '../common/keyCodes';
|
|
8
7
|
|
|
9
8
|
import Typeahead from './Typeahead';
|
|
10
9
|
|
|
@@ -94,7 +93,6 @@ describe('Typeahead', () => {
|
|
|
94
93
|
it('removes last selected value when backspace clicked on empty input', () => {
|
|
95
94
|
const event = {
|
|
96
95
|
key: 'Backspace',
|
|
97
|
-
keyCode: KeyCodes.BACKSPACE,
|
|
98
96
|
};
|
|
99
97
|
|
|
100
98
|
component.setProps({
|
|
@@ -116,7 +114,6 @@ describe('Typeahead', () => {
|
|
|
116
114
|
it('does not remove last selected value when backspace clicked on non-empty input', () => {
|
|
117
115
|
const event = {
|
|
118
116
|
key: 'Backspace',
|
|
119
|
-
keyCode: KeyCodes.BACKSPACE,
|
|
120
117
|
};
|
|
121
118
|
|
|
122
119
|
component.setProps({
|
|
@@ -228,21 +225,20 @@ describe('Typeahead', () => {
|
|
|
228
225
|
});
|
|
229
226
|
|
|
230
227
|
it('moves selected items when down and up keys pressed', () => {
|
|
231
|
-
doTimes(3, () => input().simulate('keyDown', fakeKeyDownEventForKey(
|
|
228
|
+
doTimes(3, () => input().simulate('keyDown', fakeKeyDownEventForKey('ArrowDown')));
|
|
232
229
|
|
|
233
230
|
expect(option().at(2).parent().is('.tw-dropdown-item--focused')).toBe(true);
|
|
234
231
|
|
|
235
|
-
input().simulate('keyDown', fakeKeyDownEventForKey(
|
|
232
|
+
input().simulate('keyDown', fakeKeyDownEventForKey('ArrowUp'));
|
|
236
233
|
expect(option().at(1).parent().is('.tw-dropdown-item--focused')).toBe(true);
|
|
237
234
|
|
|
238
|
-
doTimes(5, () => input().simulate('keyDown', fakeKeyDownEventForKey(
|
|
235
|
+
doTimes(5, () => input().simulate('keyDown', fakeKeyDownEventForKey('ArrowDown')));
|
|
239
236
|
expect(option().last().parent().is('.tw-dropdown-item--focused')).toBe(true);
|
|
240
237
|
});
|
|
241
238
|
|
|
242
239
|
it('adds new value as selected and clears the input when no option is highlighted and enter is pressed', () => {
|
|
243
240
|
const event = {
|
|
244
241
|
key: 'Enter',
|
|
245
|
-
keyCode: KeyCodes.ENTER,
|
|
246
242
|
preventDefault: jest.fn(),
|
|
247
243
|
};
|
|
248
244
|
const text = 'test';
|
|
@@ -263,7 +259,6 @@ describe('Typeahead', () => {
|
|
|
263
259
|
it('displays alert when alert is provided and chips are valid or alert type is error', () => {
|
|
264
260
|
const event = {
|
|
265
261
|
key: 'Enter',
|
|
266
|
-
keyCode: KeyCodes.ENTER,
|
|
267
262
|
preventDefault: jest.fn(),
|
|
268
263
|
};
|
|
269
264
|
const text = 'test';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { select, boolean } from '@storybook/addon-knobs';
|
|
2
|
+
import { userEvent, within } from '@storybook/test';
|
|
2
3
|
import { Search as SearchIcon } from '@transferwise/icons';
|
|
3
4
|
import { useState } from 'react';
|
|
4
5
|
|
|
5
6
|
import { Sentiment } from '../common';
|
|
6
|
-
import { within, userEvent } from '../test-utils';
|
|
7
7
|
|
|
8
8
|
import Typeahead from './Typeahead';
|
|
9
9
|
|
|
@@ -45,7 +45,7 @@ export const createable = () => {
|
|
|
45
45
|
|
|
46
46
|
createable.play = async ({ canvasElement }) => {
|
|
47
47
|
const canvas = within(canvasElement);
|
|
48
|
-
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
|
-
userEvent.type(canvas.getByRole('combobox'), 'abc');
|
|
121
|
-
userEvent.type(canvas.getByRole('combobox'), '{arrowDown}');
|
|
120
|
+
await userEvent.type(canvas.getByRole('combobox'), 'abc{ArrowDown}');
|
|
122
121
|
};
|
|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
export default function withNextPortalWrapper<T extends Record<string, any>>(
|
|
5
|
-
Component: React.
|
|
5
|
+
Component: React.ComponentType<T>,
|
|
6
6
|
) {
|
|
7
7
|
return function (props: T) {
|
|
8
8
|
const [mounted, setMounted] = useState(false);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../../src/common/key.js"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
const DOWN: number;
|
|
3
|
-
const UP: number;
|
|
4
|
-
const LEFT: number;
|
|
5
|
-
const RIGHT: number;
|
|
6
|
-
const ENTER: number;
|
|
7
|
-
const ESCAPE: number;
|
|
8
|
-
const TAB: number;
|
|
9
|
-
const SPACE: number;
|
|
10
|
-
const BACKSPACE: number;
|
|
11
|
-
const DELETE: number;
|
|
12
|
-
const COMMA: number;
|
|
13
|
-
const PERIOD: number;
|
|
14
|
-
}
|
|
15
|
-
export default _default;
|
|
16
|
-
//# sourceMappingURL=keyCodes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyCodes.d.ts","sourceRoot":"","sources":["../../../src/common/keyCodes.js"],"names":[],"mappings":""}
|
package/src/common/key.js
DELETED
package/src/common/keyCodes.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TODO: mention what to use instead or consider to delete this object
|
|
3
|
-
*
|
|
4
|
-
* @deprecated
|
|
5
|
-
*/
|
|
6
|
-
export default {
|
|
7
|
-
DOWN: 40,
|
|
8
|
-
UP: 38,
|
|
9
|
-
LEFT: 37,
|
|
10
|
-
RIGHT: 39,
|
|
11
|
-
ENTER: 13,
|
|
12
|
-
ESCAPE: 27,
|
|
13
|
-
TAB: 9,
|
|
14
|
-
SPACE: 32,
|
|
15
|
-
BACKSPACE: 8,
|
|
16
|
-
DELETE: 46,
|
|
17
|
-
COMMA: 188,
|
|
18
|
-
PERIOD: 190,
|
|
19
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { Component } from 'react';
|
|
3
|
-
|
|
4
|
-
import SnackbarPortal from './Snackbar';
|
|
5
|
-
import { SnackbarContext } from './SnackbarContext';
|
|
6
|
-
|
|
7
|
-
class SnackbarProvider extends Component {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
this.state = {
|
|
11
|
-
text: '',
|
|
12
|
-
timestamp: 0,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
create = ({ action, text, theme }) => {
|
|
17
|
-
this.setState({ action, text, theme, timestamp: Date.now() });
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
render() {
|
|
21
|
-
const { action, text, theme, timestamp } = this.state;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<SnackbarContext.Provider
|
|
25
|
-
value={{
|
|
26
|
-
createSnackbar: this.create,
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
<SnackbarPortal
|
|
30
|
-
action={action}
|
|
31
|
-
text={text}
|
|
32
|
-
timestamp={timestamp}
|
|
33
|
-
timeout={this.props.timeout}
|
|
34
|
-
theme={theme}
|
|
35
|
-
/>
|
|
36
|
-
{this.props.children}
|
|
37
|
-
</SnackbarContext.Provider>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
SnackbarProvider.propTypes = {
|
|
43
|
-
children: PropTypes.node.isRequired,
|
|
44
|
-
timeout: PropTypes.number,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
SnackbarProvider.defaultProps = {
|
|
48
|
-
timeout: 4500,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default SnackbarProvider;
|
|
File without changes
|
|
File without changes
|