@shopgate/pwa-common 7.30.0-alpha.8 → 7.30.0-beta.1
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/App.js +28 -13
- package/actions/app/handleUniversalLink.js +0 -2
- package/collections/AuthRoutes.js +15 -13
- package/collections/Configuration.js +11 -10
- package/collections/EmbeddedMedia.js +21 -19
- package/collections/PersistedReducers.js +11 -9
- package/collections/Redirects.js +15 -13
- package/collections/media-providers/MediaProvider.js +23 -21
- package/collections/media-providers/Vimeo.js +28 -22
- package/collections/media-providers/YouTube.js +17 -10
- package/components/Backdrop/index.js +15 -13
- package/components/Backdrop/spec.js +3 -2
- package/components/Button/index.js +41 -29
- package/components/Button/spec.js +16 -10
- package/components/Checkbox/index.js +36 -28
- package/components/Checkbox/spec.js +40 -27
- package/components/Consume/index.js +4 -1
- package/components/CountdownTimer/index.js +27 -20
- package/components/CountdownTimer/spec.js +39 -38
- package/components/Drawer/index.js +31 -23
- package/components/Drawer/spec.js +7 -6
- package/components/Dropdown/index.js +27 -18
- package/components/Ellipsis/index.js +5 -3
- package/components/Ellipsis/spec.js +5 -3
- package/components/EmbeddedMedia/index.js +9 -6
- package/components/EmbeddedMedia/spec.js +11 -2
- package/components/ErrorBoundary/index.js +26 -16
- package/components/Grid/components/Item/index.js +13 -6
- package/components/Grid/components/Item/spec.js +4 -3
- package/components/Grid/index.js +13 -6
- package/components/Grid/spec.js +4 -3
- package/components/HtmlSanitizer/index.js +42 -45
- package/components/HtmlSanitizer/spec.js +31 -21
- package/components/I18n/components/FormatDate/index.js +11 -4
- package/components/I18n/components/FormatDate/spec.js +22 -14
- package/components/I18n/components/FormatNumber/index.js +8 -6
- package/components/I18n/components/FormatNumber/spec.js +10 -5
- package/components/I18n/components/FormatPrice/index.js +5 -3
- package/components/I18n/components/FormatPrice/spec.js +22 -14
- package/components/I18n/components/FormatTime/index.js +11 -4
- package/components/I18n/components/FormatTime/spec.js +22 -14
- package/components/I18n/components/I18nProvider/index.js +18 -11
- package/components/I18n/components/I18nProvider/spec.js +2 -1
- package/components/I18n/components/Placeholder/index.js +10 -3
- package/components/I18n/components/Placeholder/spec.js +12 -5
- package/components/I18n/components/Translate/index.js +12 -8
- package/components/I18n/components/Translate/spec.js +9 -6
- package/components/Icon/index.js +2 -1
- package/components/Image/Image.js +23 -21
- package/components/Image/ImageInner.js +2 -1
- package/components/InfiniteContainer/index.js +59 -53
- package/components/InfiniteContainer/spec.js +10 -5
- package/components/Input/components/MultiLineInput.js +33 -26
- package/components/Input/components/SimpleInput.js +70 -54
- package/components/Input/index.js +7 -17
- package/components/Input/spec.js +12 -11
- package/components/KeyboardConsumer/index.js +19 -13
- package/components/Link/index.js +28 -20
- package/components/Link/spec.js +13 -9
- package/components/List/components/Item/index.js +5 -3
- package/components/List/index.js +5 -3
- package/components/List/spec.js +6 -9
- package/components/Loading/index.js +1 -3
- package/components/Modal/index.js +13 -10
- package/components/ModalContainer/spec.js +24 -20
- package/components/Picker/components/Button/index.js +18 -12
- package/components/Picker/components/List/index.js +19 -16
- package/components/Picker/components/Modal/index.js +34 -25
- package/components/Picker/index.js +44 -33
- package/components/Picker/spec.js +4 -1
- package/components/Portal/index.js +26 -17
- package/components/ProductCharacteristics/index.js +65 -57
- package/components/RangeSlider/components/Handle/index.js +7 -5
- package/components/RangeSlider/index.js +98 -84
- package/components/Route/RouteNotFound.js +30 -19
- package/components/Route/index.js +31 -21
- package/components/Router/index.js +51 -34
- package/components/ScannerContainer/index.js +17 -10
- package/components/Select/components/Item/index.js +5 -3
- package/components/Select/index.js +59 -47
- package/components/Select/spec.js +7 -6
- package/components/SelectBox/components/Item/index.js +23 -13
- package/components/SelectBox/index.js +83 -80
- package/components/SelectBox/spec.js +8 -5
- package/components/SurroundPortals/index.js +15 -11
- package/components/Swiper/components/SwiperItem/index.js +6 -5
- package/components/Swiper/components/SwiperItem/spec.js +12 -4
- package/components/Swiper/index.js +23 -20
- package/components/Toaster/index.js +4 -1
- package/components/Transition/index.js +19 -12
- package/components/Widgets/components/Widget/index.js +27 -16
- package/components/Widgets/components/Widget/spec.js +6 -5
- package/components/Widgets/components/WidgetGrid/index.js +27 -19
- package/components/Widgets/components/WidgetGrid/spec.js +5 -4
- package/components/Widgets/index.js +33 -26
- package/components/Widgets/spec.js +32 -18
- package/helpers/data/index.js +1 -1
- package/helpers/portals/portalCollection.js +13 -10
- package/helpers/redux/mutable.js +2 -2
- package/package.json +5 -6
- package/providers/loading/index.js +71 -57
- package/providers/toast/index.js +39 -28
- package/reducers/modal/index.js +1 -1
- package/store/index.js +1 -1
- package/subscriptions/helpers/buildRegisterUrl.js +1 -0
- package/components/Input/components/DateInput.js +0 -273
|
@@ -2,18 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import SimpleInput from "./components/SimpleInput";
|
|
4
4
|
import MultiLineInput from "./components/MultiLineInput";
|
|
5
|
-
import DateInput from "./components/DateInput";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
const isDateSupported = () => {
|
|
11
|
-
const input = document.createElement('input');
|
|
12
|
-
const value = 'a';
|
|
13
|
-
input.setAttribute('type', 'date');
|
|
14
|
-
input.setAttribute('value', value);
|
|
15
|
-
return input.value !== value;
|
|
16
|
-
};
|
|
17
5
|
|
|
18
6
|
/**
|
|
19
7
|
* Input component.
|
|
@@ -21,14 +9,16 @@ const isDateSupported = () => {
|
|
|
21
9
|
* @param {Object} props Props
|
|
22
10
|
* @return {JSX}
|
|
23
11
|
*/
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
13
|
const Factory = props => {
|
|
25
|
-
if (props.type === 'date' && !isDateSupported()) {
|
|
26
|
-
return /*#__PURE__*/React.createElement(DateInput, props);
|
|
27
|
-
}
|
|
28
14
|
if (props.multiLine) {
|
|
29
|
-
return /*#__PURE__*/
|
|
15
|
+
return /*#__PURE__*/_jsx(MultiLineInput, {
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
30
18
|
}
|
|
31
|
-
return /*#__PURE__*/
|
|
19
|
+
return /*#__PURE__*/_jsx(SimpleInput, {
|
|
20
|
+
...props
|
|
21
|
+
});
|
|
32
22
|
};
|
|
33
23
|
Factory.defaultProps = {
|
|
34
24
|
multiLine: false,
|
package/components/Input/spec.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mount, shallow } from 'enzyme';
|
|
3
3
|
import Input from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
describe('<Input />', () => {
|
|
5
6
|
it('should render a simple input field', () => {
|
|
6
|
-
const wrapper = mount(/*#__PURE__*/
|
|
7
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {}));
|
|
7
8
|
expect(wrapper).toMatchSnapshot();
|
|
8
9
|
expect(wrapper.find('input').length).toBe(1);
|
|
9
10
|
});
|
|
10
11
|
it('should render the input as password', () => {
|
|
11
|
-
const wrapper = mount(/*#__PURE__*/
|
|
12
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
12
13
|
password: true
|
|
13
14
|
}));
|
|
14
15
|
expect(wrapper).toMatchSnapshot();
|
|
15
16
|
expect(wrapper.find('input[type="password"]').length).toBe(1);
|
|
16
17
|
});
|
|
17
18
|
it('should render the input with a default value', () => {
|
|
18
|
-
const wrapper = mount(/*#__PURE__*/
|
|
19
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
19
20
|
value: "FooBar"
|
|
20
21
|
}));
|
|
21
22
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -23,7 +24,7 @@ describe('<Input />', () => {
|
|
|
23
24
|
});
|
|
24
25
|
it('should trigger the onChange callback', () => {
|
|
25
26
|
const onChangeMock = jest.fn();
|
|
26
|
-
const wrapper = mount(/*#__PURE__*/
|
|
27
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
27
28
|
onChange: onChangeMock
|
|
28
29
|
}));
|
|
29
30
|
wrapper.find('input').simulate('change', {
|
|
@@ -35,7 +36,7 @@ describe('<Input />', () => {
|
|
|
35
36
|
expect(wrapper.find('input').props().value).toEqual('a');
|
|
36
37
|
});
|
|
37
38
|
it('should receive the correct value while typing', () => {
|
|
38
|
-
const wrapper = mount(/*#__PURE__*/
|
|
39
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {}));
|
|
39
40
|
const input = wrapper.find('input');
|
|
40
41
|
input.simulate('change', {
|
|
41
42
|
target: {
|
|
@@ -46,7 +47,7 @@ describe('<Input />', () => {
|
|
|
46
47
|
expect(wrapper.find('SimpleInput').instance().value).toBe('foobar');
|
|
47
48
|
});
|
|
48
49
|
it('should sanitize the input', () => {
|
|
49
|
-
const wrapper = mount(/*#__PURE__*/
|
|
50
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
50
51
|
onSanitize: value => value.toUpperCase()
|
|
51
52
|
}));
|
|
52
53
|
const input = wrapper.find('input');
|
|
@@ -59,7 +60,7 @@ describe('<Input />', () => {
|
|
|
59
60
|
expect(wrapper.find('SimpleInput').instance().value).toBe('FOOBAR');
|
|
60
61
|
});
|
|
61
62
|
it('should validate the input', () => {
|
|
62
|
-
const wrapper = mount(/*#__PURE__*/
|
|
63
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
63
64
|
onValidate: () => false
|
|
64
65
|
}));
|
|
65
66
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -67,7 +68,7 @@ describe('<Input />', () => {
|
|
|
67
68
|
});
|
|
68
69
|
it('should focus the input', () => {
|
|
69
70
|
const onFocusMock = jest.fn();
|
|
70
|
-
const wrapper = mount(/*#__PURE__*/
|
|
71
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
71
72
|
onFocusChange: onFocusMock
|
|
72
73
|
}));
|
|
73
74
|
const input = wrapper.find('input');
|
|
@@ -79,7 +80,7 @@ describe('<Input />', () => {
|
|
|
79
80
|
expect(wrapper.find('SimpleInput').instance().isFocused).toBe(false);
|
|
80
81
|
});
|
|
81
82
|
it('should change the value on user input', () => {
|
|
82
|
-
const wrapper = mount(/*#__PURE__*/
|
|
83
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
83
84
|
value: "My initial value"
|
|
84
85
|
}));
|
|
85
86
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -96,7 +97,7 @@ describe('<Input />', () => {
|
|
|
96
97
|
const multiLineValue = `dfsdsdf
|
|
97
98
|
sdfdsff
|
|
98
99
|
dsf`;
|
|
99
|
-
const wrapper = mount(/*#__PURE__*/
|
|
100
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Input, {
|
|
100
101
|
value: "",
|
|
101
102
|
multiLine: true
|
|
102
103
|
}));
|
|
@@ -108,7 +109,7 @@ describe('<Input />', () => {
|
|
|
108
109
|
expect(wrapper.find('textarea').getDOMNode().innerHTML).toEqual(multiLineValue);
|
|
109
110
|
});
|
|
110
111
|
it('should render additional html attributes', () => {
|
|
111
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
112
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Input, {
|
|
112
113
|
type: "date",
|
|
113
114
|
attributes: {
|
|
114
115
|
min: '1970-01-01',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import { PureComponent } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import Event from '@shopgate/pwa-core/classes/Event';
|
|
@@ -6,10 +7,11 @@ import { EVENT_KEYBOARD_WILL_CHANGE } from '@shopgate/pwa-core/constants/AppEven
|
|
|
6
7
|
/**
|
|
7
8
|
* Keyboard state consumer.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
10
|
+
let KeyboardConsumer = /*#__PURE__*/function (_PureComponent) {
|
|
11
|
+
function KeyboardConsumer(...args) {
|
|
12
|
+
var _this;
|
|
13
|
+
_this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
|
|
14
|
+
_this.state = {
|
|
13
15
|
open: false,
|
|
14
16
|
overlap: 0,
|
|
15
17
|
duration: 0
|
|
@@ -17,36 +19,40 @@ class KeyboardConsumer extends PureComponent {
|
|
|
17
19
|
/**
|
|
18
20
|
* Stores current keyboard state.
|
|
19
21
|
*/
|
|
20
|
-
|
|
22
|
+
_this.handleKeyboardChange = ({
|
|
21
23
|
open,
|
|
22
24
|
overlap,
|
|
23
25
|
duration
|
|
24
26
|
}) => {
|
|
25
|
-
|
|
27
|
+
_this.setState({
|
|
26
28
|
open,
|
|
27
29
|
overlap,
|
|
28
30
|
duration
|
|
29
31
|
});
|
|
30
32
|
};
|
|
33
|
+
return _this;
|
|
31
34
|
}
|
|
35
|
+
_inheritsLoose(KeyboardConsumer, _PureComponent);
|
|
36
|
+
var _proto = KeyboardConsumer.prototype;
|
|
32
37
|
/**
|
|
33
38
|
* Listen to keyboard changes as soon as the component mounts.
|
|
34
39
|
*/
|
|
35
|
-
componentDidMount() {
|
|
40
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
36
41
|
Event.addCallback(EVENT_KEYBOARD_WILL_CHANGE, this.handleKeyboardChange);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
/**
|
|
40
45
|
* Remove listener when component will unmount.
|
|
41
|
-
|
|
42
|
-
componentWillUnmount() {
|
|
46
|
+
*/;
|
|
47
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
43
48
|
Event.removeCallback(EVENT_KEYBOARD_WILL_CHANGE, this.handleKeyboardChange);
|
|
44
|
-
}
|
|
49
|
+
};
|
|
45
50
|
/**
|
|
46
51
|
* @returns {JSX}
|
|
47
52
|
*/
|
|
48
|
-
render() {
|
|
53
|
+
_proto.render = function render() {
|
|
49
54
|
return this.props.children(this.state);
|
|
50
|
-
}
|
|
51
|
-
|
|
55
|
+
};
|
|
56
|
+
return KeyboardConsumer;
|
|
57
|
+
}(PureComponent);
|
|
52
58
|
export default KeyboardConsumer;
|
package/components/Link/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import "core-js/modules/es.string.replace.js";
|
|
2
3
|
import React, { Component } from 'react';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
@@ -10,34 +11,36 @@ import styles from "./style";
|
|
|
10
11
|
* @param {Object} props Props for the component.
|
|
11
12
|
* @returns {JSX}
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
let Link = /*#__PURE__*/function (_Component) {
|
|
16
|
+
function Link(...args) {
|
|
17
|
+
var _this;
|
|
18
|
+
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
16
19
|
/**
|
|
17
20
|
* Opens the link.
|
|
18
21
|
* @param {Event} e An event object.
|
|
19
22
|
*/
|
|
20
|
-
|
|
23
|
+
_this.handleOpenLink = e => {
|
|
21
24
|
e.preventDefault();
|
|
22
|
-
if (
|
|
25
|
+
if (_this.props.disabled) {
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
28
|
const params = {
|
|
26
|
-
pathname:
|
|
29
|
+
pathname: _this.props.href,
|
|
27
30
|
state: {
|
|
28
|
-
...(
|
|
29
|
-
...(
|
|
30
|
-
target:
|
|
31
|
+
...(_this.props.state || {}),
|
|
32
|
+
...(_this.props.target ? {
|
|
33
|
+
target: _this.props.target
|
|
31
34
|
} : {})
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
// setTimeout prevents double click while VoiceOver is active
|
|
36
39
|
setTimeout(() => {
|
|
37
|
-
if (
|
|
38
|
-
|
|
40
|
+
if (_this.props.replace) {
|
|
41
|
+
_this.props.historyReplace(params);
|
|
39
42
|
} else {
|
|
40
|
-
|
|
43
|
+
_this.props.historyPush(params);
|
|
41
44
|
}
|
|
42
45
|
}, 0);
|
|
43
46
|
};
|
|
@@ -45,17 +48,20 @@ class Link extends Component {
|
|
|
45
48
|
* key listener for screen readers
|
|
46
49
|
* @param {Object} event The event object
|
|
47
50
|
*/
|
|
48
|
-
|
|
51
|
+
_this.handleKeyDown = event => {
|
|
49
52
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
50
|
-
|
|
53
|
+
_this.handleOpenLink(event);
|
|
51
54
|
}
|
|
52
55
|
};
|
|
56
|
+
return _this;
|
|
53
57
|
}
|
|
58
|
+
_inheritsLoose(Link, _Component);
|
|
59
|
+
var _proto = Link.prototype;
|
|
54
60
|
/**
|
|
55
61
|
* Renders the component.
|
|
56
62
|
* @returns {JSX.Element}
|
|
57
63
|
*/
|
|
58
|
-
render() {
|
|
64
|
+
_proto.render = function render() {
|
|
59
65
|
const {
|
|
60
66
|
tag,
|
|
61
67
|
className,
|
|
@@ -74,7 +80,7 @@ class Link extends Component {
|
|
|
74
80
|
*/
|
|
75
81
|
Tag = 'span';
|
|
76
82
|
}
|
|
77
|
-
return /*#__PURE__*/
|
|
83
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
78
84
|
className: `${styles} ${className} common__link`,
|
|
79
85
|
onClick: this.handleOpenLink,
|
|
80
86
|
onKeyDown: this.handleKeyDown,
|
|
@@ -83,10 +89,12 @@ class Link extends Component {
|
|
|
83
89
|
"aria-label": ariaLabel,
|
|
84
90
|
tabIndex: tabIndex,
|
|
85
91
|
"aria-hidden": ariaHidden,
|
|
86
|
-
href: href && Tag === 'a' ? href : null
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
92
|
+
href: href && Tag === 'a' ? href : null,
|
|
93
|
+
children: children
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
return Link;
|
|
97
|
+
}(Component);
|
|
90
98
|
Link.defaultProps = {
|
|
91
99
|
'aria-hidden': null,
|
|
92
100
|
'aria-label': null,
|
package/components/Link/spec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow, mount } from 'enzyme';
|
|
3
3
|
import { Disconnected as Link } from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
describe('<Link />', () => {
|
|
5
6
|
const historyPush = jest.fn();
|
|
6
7
|
const historyReplace = jest.fn();
|
|
@@ -16,21 +17,23 @@ describe('<Link />', () => {
|
|
|
16
17
|
jest.useRealTimers();
|
|
17
18
|
});
|
|
18
19
|
it('renders with children', () => {
|
|
19
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
20
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Link, {
|
|
20
21
|
href: pathname,
|
|
21
22
|
historyPush: historyPush,
|
|
22
|
-
historyReplace: historyReplace
|
|
23
|
-
|
|
23
|
+
historyReplace: historyReplace,
|
|
24
|
+
children: /*#__PURE__*/_jsx("span", {})
|
|
25
|
+
}));
|
|
24
26
|
expect(wrapper).toMatchSnapshot();
|
|
25
27
|
expect(wrapper.find('span').length).toBe(1);
|
|
26
28
|
});
|
|
27
29
|
it('handles a push', () => {
|
|
28
|
-
const wrapper = mount(/*#__PURE__*/
|
|
30
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Link, {
|
|
29
31
|
href: pathname,
|
|
30
32
|
state: state,
|
|
31
33
|
historyPush: historyPush,
|
|
32
|
-
historyReplace: historyReplace
|
|
33
|
-
|
|
34
|
+
historyReplace: historyReplace,
|
|
35
|
+
children: /*#__PURE__*/_jsx("span", {})
|
|
36
|
+
}));
|
|
34
37
|
wrapper.find('div').simulate('click');
|
|
35
38
|
jest.runAllTimers();
|
|
36
39
|
expect(historyPush).toHaveBeenLastCalledWith({
|
|
@@ -39,13 +42,14 @@ describe('<Link />', () => {
|
|
|
39
42
|
});
|
|
40
43
|
});
|
|
41
44
|
it('handles a replace', () => {
|
|
42
|
-
const wrapper = mount(/*#__PURE__*/
|
|
45
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Link, {
|
|
43
46
|
href: pathname,
|
|
44
47
|
historyPush: historyPush,
|
|
45
48
|
historyReplace: historyReplace,
|
|
46
49
|
state: state,
|
|
47
|
-
replace: true
|
|
48
|
-
|
|
50
|
+
replace: true,
|
|
51
|
+
children: /*#__PURE__*/_jsx("span", {})
|
|
52
|
+
}));
|
|
49
53
|
wrapper.find('div').simulate('click');
|
|
50
54
|
jest.runAllTimers();
|
|
51
55
|
expect(historyReplace).toHaveBeenLastCalledWith({
|
|
@@ -6,6 +6,7 @@ import styles from "./style";
|
|
|
6
6
|
* The ListItem component.
|
|
7
7
|
* @returns {JSX}
|
|
8
8
|
*/
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
const ListItem = ({
|
|
10
11
|
children,
|
|
11
12
|
className,
|
|
@@ -22,11 +23,12 @@ const ListItem = ({
|
|
|
22
23
|
|
|
23
24
|
// Add selected or unselected styling.
|
|
24
25
|
classes += ` common__list__list-item ${isSelected ? styles.selected : styles.unselected}`;
|
|
25
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/_jsx("li", {
|
|
26
27
|
className: classes,
|
|
27
28
|
"data-test-id": "listItem",
|
|
28
|
-
role: role
|
|
29
|
-
|
|
29
|
+
role: role,
|
|
30
|
+
children: children
|
|
31
|
+
});
|
|
30
32
|
};
|
|
31
33
|
ListItem.defaultProps = {
|
|
32
34
|
className: null,
|
package/components/List/index.js
CHANGED
|
@@ -7,14 +7,16 @@ import ListItem from "./components/Item";
|
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const List = ({
|
|
11
12
|
children,
|
|
12
13
|
className,
|
|
13
14
|
role
|
|
14
|
-
}) => /*#__PURE__*/
|
|
15
|
+
}) => /*#__PURE__*/_jsx("ul", {
|
|
15
16
|
className: `${className} common_list`,
|
|
16
|
-
role: role
|
|
17
|
-
|
|
17
|
+
role: role,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
18
20
|
List.Item = ListItem;
|
|
19
21
|
List.defaultProps = {
|
|
20
22
|
className: '',
|
package/components/List/spec.js
CHANGED
|
@@ -2,27 +2,24 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { shallow } from 'enzyme';
|
|
4
4
|
import List from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
console.error = jest.fn();
|
|
6
7
|
describe('<List />', () => {
|
|
7
|
-
const children = [/*#__PURE__*/
|
|
8
|
-
key: "0"
|
|
9
|
-
}), /*#__PURE__*/React.createElement(List.Item, {
|
|
10
|
-
key: "1"
|
|
11
|
-
}), /*#__PURE__*/React.createElement(List.Item, {
|
|
12
|
-
key: "2"
|
|
13
|
-
})];
|
|
8
|
+
const children = [/*#__PURE__*/_jsx(List.Item, {}, "0"), /*#__PURE__*/_jsx(List.Item, {}, "1"), /*#__PURE__*/_jsx(List.Item, {}, "2")];
|
|
14
9
|
beforeEach(() => {
|
|
15
10
|
jest.clearAllMocks();
|
|
16
11
|
});
|
|
17
12
|
it('renders with children', () => {
|
|
18
13
|
const numChildren = children.length;
|
|
19
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
14
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(List, {
|
|
15
|
+
children: children
|
|
16
|
+
}));
|
|
20
17
|
expect(wrapper).toMatchSnapshot();
|
|
21
18
|
expect(wrapper.find(List.Item).length).toBe(numChildren);
|
|
22
19
|
expect(console.error).not.toHaveBeenCalled();
|
|
23
20
|
});
|
|
24
21
|
it('renders without children', () => {
|
|
25
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
22
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(List, {}));
|
|
26
23
|
expect(wrapper).toMatchSnapshot();
|
|
27
24
|
expect(wrapper.find(List.Item).length).toBe(0);
|
|
28
25
|
expect(console.error).toHaveBeenCalledTimes(1);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { forwardRef } from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { createPortal } from 'react-dom';
|
|
@@ -12,6 +11,7 @@ import styles from "./style";
|
|
|
12
11
|
* @param {Object} props.classes The component classes.
|
|
13
12
|
* @returns {JSX.Element}
|
|
14
13
|
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const Modal = /*#__PURE__*/forwardRef(({
|
|
16
16
|
children,
|
|
17
17
|
classes,
|
|
@@ -19,17 +19,20 @@ const Modal = /*#__PURE__*/forwardRef(({
|
|
|
19
19
|
}, ref) => {
|
|
20
20
|
// Track modal visibility for accessibility purposes.
|
|
21
21
|
useTrackModalState();
|
|
22
|
-
return /*#__PURE__*/createPortal(/*#__PURE__*/
|
|
22
|
+
return /*#__PURE__*/createPortal(/*#__PURE__*/_jsx("div", {
|
|
23
23
|
className: classNames(styles.container, classes?.container, 'common__modal'),
|
|
24
24
|
role: "alertdialog",
|
|
25
|
-
"aria-modal": true
|
|
26
|
-
|
|
27
|
-
ref: ref
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
"aria-modal": true,
|
|
26
|
+
...props,
|
|
27
|
+
ref: ref,
|
|
28
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
29
|
+
className: classNames(styles.layout, classes?.layout),
|
|
30
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: classNames(styles.content, classes?.content),
|
|
32
|
+
children: children
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
}), document.getElementById('portals'));
|
|
33
36
|
});
|
|
34
37
|
Modal.defaultProps = {
|
|
35
38
|
children: null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
1
|
+
/* eslint-disable no-unused-vars, jsx-a11y/control-has-associated-label */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { mount } from 'enzyme';
|
|
4
4
|
import { Provider } from 'react-redux';
|
|
@@ -9,6 +9,7 @@ import ModalContainer from "./index";
|
|
|
9
9
|
|
|
10
10
|
// const store = configureStore({ modal: modalReducer });
|
|
11
11
|
// Replacement for commented out configureStore()
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
const store = {};
|
|
13
14
|
jest.mock('redux-logger', () => ({
|
|
14
15
|
createLogger: () => () => next => action => next(action)
|
|
@@ -25,17 +26,18 @@ const MockModal = ({
|
|
|
25
26
|
onConfirm,
|
|
26
27
|
// eslint-disable-line react/prop-types
|
|
27
28
|
onDismiss // eslint-disable-line react/prop-types
|
|
28
|
-
}) => /*#__PURE__*/
|
|
29
|
-
className: "modal"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}), /*#__PURE__*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
29
|
+
}) => /*#__PURE__*/_jsxs("div", {
|
|
30
|
+
className: "modal",
|
|
31
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
32
|
+
className: "confirmBtn",
|
|
33
|
+
onClick: onConfirm,
|
|
34
|
+
type: "button"
|
|
35
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
36
|
+
className: "dismissBtn",
|
|
37
|
+
onClick: onDismiss,
|
|
38
|
+
type: "button"
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
39
41
|
describe.skip('<ModalContainer />', () => {
|
|
40
42
|
let renderedElement;
|
|
41
43
|
const {
|
|
@@ -47,13 +49,15 @@ describe.skip('<ModalContainer />', () => {
|
|
|
47
49
|
* The rendered component.
|
|
48
50
|
*/
|
|
49
51
|
const renderComponent = () => {
|
|
50
|
-
renderedElement = mount(/*#__PURE__*/
|
|
51
|
-
store: store
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
renderedElement = mount(/*#__PURE__*/_jsx(Provider, {
|
|
53
|
+
store: store,
|
|
54
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
55
|
+
id: "container",
|
|
56
|
+
children: /*#__PURE__*/_jsx(ModalContainer, {
|
|
57
|
+
component: MockModal
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
}));
|
|
57
61
|
};
|
|
58
62
|
beforeEach(() => {
|
|
59
63
|
// Reset the modals state before each test.
|
|
@@ -108,4 +112,4 @@ describe.skip('<ModalContainer />', () => {
|
|
|
108
112
|
});
|
|
109
113
|
});
|
|
110
114
|
|
|
111
|
-
/* eslint-enable no-unused-vars */
|
|
115
|
+
/* eslint-enable no-unused-vars, jsx-a11y/control-has-associated-label */
|
|
@@ -6,29 +6,35 @@ import styles from "./style";
|
|
|
6
6
|
* The default button for the Picker component.
|
|
7
7
|
* @returns {JSX} The button component.
|
|
8
8
|
*/
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const PickerButton = ({
|
|
10
11
|
value,
|
|
11
12
|
label,
|
|
12
13
|
openList
|
|
13
14
|
}) => {
|
|
14
15
|
if (value !== null) {
|
|
15
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
16
17
|
className: styles.button,
|
|
17
18
|
onClick: openList,
|
|
18
|
-
type: "button"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
type: "button",
|
|
20
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
21
|
+
className: styles.label,
|
|
22
|
+
children: label
|
|
23
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
24
|
+
className: styles.value,
|
|
25
|
+
children: value
|
|
26
|
+
})]
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
|
-
return /*#__PURE__*/
|
|
29
|
+
return /*#__PURE__*/_jsx("button", {
|
|
26
30
|
className: styles.button,
|
|
27
31
|
onClick: openList,
|
|
28
|
-
type: "button"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
type: "button",
|
|
33
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
34
|
+
className: styles.label,
|
|
35
|
+
children: label
|
|
36
|
+
})
|
|
37
|
+
});
|
|
32
38
|
};
|
|
33
39
|
PickerButton.defaultProps = {
|
|
34
40
|
value: null
|
|
@@ -7,27 +7,30 @@ import styles from "./style";
|
|
|
7
7
|
* The default button for the Picker component.
|
|
8
8
|
* @returns {JSX} The button component.
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const PickerList = ({
|
|
11
12
|
items,
|
|
12
13
|
onClose,
|
|
13
14
|
onSelect,
|
|
14
15
|
selectedIndex
|
|
15
|
-
}) => /*#__PURE__*/
|
|
16
|
-
className: "common__picker__list"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
16
|
+
}) => /*#__PURE__*/_jsx("ul", {
|
|
17
|
+
className: "common__picker__list",
|
|
18
|
+
children: items.map((item, currentIndex) => /*#__PURE__*/_jsx("li", {
|
|
19
|
+
className: classNames({
|
|
20
|
+
[styles.active]: currentIndex === selectedIndex
|
|
21
|
+
}),
|
|
22
|
+
children: /*#__PURE__*/_jsx("button", {
|
|
23
|
+
className: styles.button,
|
|
24
|
+
disabled: item.disabled,
|
|
25
|
+
onClick: () => {
|
|
26
|
+
onSelect(item.value);
|
|
27
|
+
onClose();
|
|
28
|
+
},
|
|
29
|
+
type: "button",
|
|
30
|
+
children: item.label
|
|
31
|
+
})
|
|
32
|
+
}, item.value))
|
|
33
|
+
});
|
|
31
34
|
PickerList.defaultProps = {
|
|
32
35
|
onClose: () => {},
|
|
33
36
|
selectedIndex: null
|