@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { Component } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import classNames from 'classnames';
|
|
@@ -10,26 +11,22 @@ import styles from "./style";
|
|
|
10
11
|
/**
|
|
11
12
|
* The select box component.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
let SelectBox = /*#__PURE__*/function (_Component) {
|
|
14
16
|
/**
|
|
15
17
|
* Initializes the component.
|
|
16
18
|
* @param {Object} props The components props.
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* When dropdown animation is finished.
|
|
22
|
-
*/
|
|
23
|
-
this.onDropdownComplete = () => {
|
|
24
|
-
this.dropdownCompleted = true;
|
|
25
|
-
};
|
|
20
|
+
function SelectBox(props) {
|
|
21
|
+
var _this;
|
|
22
|
+
_this = _Component.call(this, props) || this;
|
|
26
23
|
/**
|
|
27
24
|
* Handles any interaction the user does outside of the component.
|
|
28
25
|
* In this case the select gets closed.
|
|
29
26
|
* @param {Object} event The event object.
|
|
30
27
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
_this.handleInteractionOutside = event => {
|
|
29
|
+
_this.setState({
|
|
33
30
|
isOpen: false
|
|
34
31
|
});
|
|
35
32
|
event.preventDefault();
|
|
@@ -38,61 +35,62 @@ class SelectBox extends Component {
|
|
|
38
35
|
/**
|
|
39
36
|
* Sets the open state to true
|
|
40
37
|
*/
|
|
41
|
-
|
|
42
|
-
if (
|
|
38
|
+
_this.handleOpenList = () => {
|
|
39
|
+
if (_this.state.isOpen) {
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
this.setState({
|
|
42
|
+
_this.setState({
|
|
47
43
|
isOpen: true
|
|
48
44
|
});
|
|
49
|
-
if (
|
|
50
|
-
|
|
45
|
+
if (_this.firstItemRef) {
|
|
46
|
+
_this.firstItemRef.focus();
|
|
51
47
|
}
|
|
52
48
|
};
|
|
53
49
|
/**
|
|
54
50
|
* Sets the new active selection.
|
|
55
51
|
* @param {string} value Value of the selected item.
|
|
56
52
|
*/
|
|
57
|
-
|
|
58
|
-
const selection = find(
|
|
53
|
+
_this.handleSelectionUpdate = value => {
|
|
54
|
+
const selection = find(_this.props.items, {
|
|
59
55
|
value
|
|
60
56
|
});
|
|
61
|
-
|
|
57
|
+
_this.setState({
|
|
62
58
|
selected: selection,
|
|
63
59
|
isOpen: false
|
|
64
60
|
});
|
|
65
61
|
|
|
66
62
|
// Delay the callback to make sure actions are fired after animations are done.
|
|
67
63
|
setTimeout(() => {
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
if (
|
|
71
|
-
|
|
64
|
+
_this.props.handleSelectionUpdate(selection.value);
|
|
65
|
+
}, _this.props.duration);
|
|
66
|
+
if (_this.controlRef) {
|
|
67
|
+
_this.controlRef.focus();
|
|
72
68
|
}
|
|
73
69
|
};
|
|
74
70
|
/** @param {HTMLElement} ref The element */
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
_this.setControlRef = ref => {
|
|
72
|
+
_this.controlRef = ref;
|
|
77
73
|
};
|
|
78
74
|
/** @param {HTMLElement} ref The element */
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
_this.setFirstItemRef = ref => {
|
|
76
|
+
_this.firstItemRef = ref;
|
|
81
77
|
};
|
|
82
|
-
|
|
83
|
-
this.state = {
|
|
78
|
+
_this.state = {
|
|
84
79
|
isOpen: false,
|
|
85
80
|
selected: find(props.items, {
|
|
86
81
|
value: props.initialValue
|
|
87
82
|
})
|
|
88
83
|
};
|
|
84
|
+
return _this;
|
|
89
85
|
}
|
|
90
86
|
|
|
91
87
|
/**
|
|
92
88
|
* Reset selected when changing the initial value.
|
|
93
89
|
* @param {Object} nextProps The next props the component will receive.
|
|
94
90
|
*/
|
|
95
|
-
|
|
91
|
+
_inheritsLoose(SelectBox, _Component);
|
|
92
|
+
var _proto = SelectBox.prototype;
|
|
93
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
96
94
|
if (this.props.initialValue !== nextProps.initialValue) {
|
|
97
95
|
this.setState({
|
|
98
96
|
selected: find(nextProps.items, {
|
|
@@ -100,12 +98,12 @@ class SelectBox extends Component {
|
|
|
100
98
|
})
|
|
101
99
|
});
|
|
102
100
|
}
|
|
103
|
-
}
|
|
101
|
+
};
|
|
104
102
|
/**
|
|
105
103
|
* Renders the component
|
|
106
104
|
* @returns {JSX}
|
|
107
105
|
*/
|
|
108
|
-
render() {
|
|
106
|
+
_proto.render = function render() {
|
|
109
107
|
const Icon = this.props.icon;
|
|
110
108
|
const {
|
|
111
109
|
icon,
|
|
@@ -120,54 +118,59 @@ class SelectBox extends Component {
|
|
|
120
118
|
const iconClasses = classNames(icon, {
|
|
121
119
|
[iconOpen]: this.state.isOpen && iconOpen !== null
|
|
122
120
|
});
|
|
123
|
-
return /*#__PURE__*/
|
|
121
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
124
122
|
className: `${this.props.className} common__select-box`,
|
|
125
|
-
"data-test-id": this.props.testId
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
123
|
+
"data-test-id": this.props.testId,
|
|
124
|
+
children: [/*#__PURE__*/_jsxs("button", {
|
|
125
|
+
className: button,
|
|
126
|
+
onClick: this.handleOpenList,
|
|
127
|
+
"data-test-id": buttonLabel,
|
|
128
|
+
type: "button",
|
|
129
|
+
"aria-haspopup": true,
|
|
130
|
+
"aria-expanded": this.state.isOpen ? true : null,
|
|
131
|
+
"aria-controls": buttonLabel,
|
|
132
|
+
ref: this.setControlRef,
|
|
133
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
134
|
+
className: selection,
|
|
135
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
136
|
+
string: buttonLabel
|
|
137
|
+
})
|
|
138
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
139
|
+
className: iconClasses,
|
|
140
|
+
children: /*#__PURE__*/_jsx(Icon, {})
|
|
141
|
+
})]
|
|
142
|
+
}), /*#__PURE__*/_jsx(Dropdown, {
|
|
143
|
+
className: dropdown,
|
|
144
|
+
isOpen: this.state.isOpen,
|
|
145
|
+
duration: this.props.duration,
|
|
146
|
+
children: /*#__PURE__*/_jsx("ul", {
|
|
147
|
+
role: "menu",
|
|
148
|
+
id: buttonLabel,
|
|
149
|
+
tabIndex: "-1",
|
|
150
|
+
children: this.props.items.map(item => /*#__PURE__*/_jsx(SelectBoxItem, {
|
|
151
|
+
classNames: {
|
|
152
|
+
selectItem,
|
|
153
|
+
selectItemSelected
|
|
154
|
+
},
|
|
155
|
+
wrapper: this.props.item,
|
|
156
|
+
value: item.value,
|
|
157
|
+
label: item.label,
|
|
158
|
+
handleSelectionUpdate: this.handleSelectionUpdate,
|
|
159
|
+
isSelected: buttonLabel === item.label,
|
|
160
|
+
forwardedRef: buttonLabel === item.label ? this.setFirstItemRef : null
|
|
161
|
+
}, item.value))
|
|
162
|
+
})
|
|
163
|
+
}), this.state.isOpen && /*#__PURE__*/_jsx("button", {
|
|
164
|
+
className: styles.overlay,
|
|
165
|
+
onClick: this.handleInteractionOutside,
|
|
166
|
+
onTouchMove: this.handleInteractionOutside,
|
|
167
|
+
type: "button",
|
|
168
|
+
"aria-hidden": true
|
|
169
|
+
})]
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
return SelectBox;
|
|
173
|
+
}(Component);
|
|
171
174
|
SelectBox.defaultProps = {
|
|
172
175
|
className: '',
|
|
173
176
|
classNames: {},
|
|
@@ -7,7 +7,8 @@ import SelectBox from "./index";
|
|
|
7
7
|
* Mock Icon component.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const MockIconComponent = () => /*#__PURE__*/_jsx("span", {
|
|
11
12
|
id: "icon"
|
|
12
13
|
});
|
|
13
14
|
|
|
@@ -19,7 +20,9 @@ const MockIconComponent = () => /*#__PURE__*/React.createElement("span", {
|
|
|
19
20
|
*/
|
|
20
21
|
const MockItemComponent = ({
|
|
21
22
|
children
|
|
22
|
-
}) => /*#__PURE__*/
|
|
23
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
24
|
+
children: children
|
|
25
|
+
});
|
|
23
26
|
describe('<SelectBox>', () => {
|
|
24
27
|
const dummyItems = [{
|
|
25
28
|
label: 'My item #1',
|
|
@@ -32,7 +35,7 @@ describe('<SelectBox>', () => {
|
|
|
32
35
|
value: 'item_3'
|
|
33
36
|
}];
|
|
34
37
|
it('should render the selectbox with given mock components', () => {
|
|
35
|
-
const wrapper = mount(/*#__PURE__*/
|
|
38
|
+
const wrapper = mount(/*#__PURE__*/_jsx(SelectBox, {
|
|
36
39
|
icon: MockIconComponent,
|
|
37
40
|
item: MockItemComponent,
|
|
38
41
|
items: dummyItems
|
|
@@ -42,7 +45,7 @@ describe('<SelectBox>', () => {
|
|
|
42
45
|
expect(wrapper.find(MockItemComponent).length).toEqual(3);
|
|
43
46
|
});
|
|
44
47
|
it('should render with a default text', () => {
|
|
45
|
-
const wrapper = mount(/*#__PURE__*/
|
|
48
|
+
const wrapper = mount(/*#__PURE__*/_jsx(SelectBox, {
|
|
46
49
|
icon: MockIconComponent,
|
|
47
50
|
item: MockItemComponent,
|
|
48
51
|
items: dummyItems,
|
|
@@ -52,7 +55,7 @@ describe('<SelectBox>', () => {
|
|
|
52
55
|
expect(wrapper.find('span').at(0).text()).toEqual('Foo');
|
|
53
56
|
});
|
|
54
57
|
it('should render with a preselected selection', () => {
|
|
55
|
-
const wrapper = mount(/*#__PURE__*/
|
|
58
|
+
const wrapper = mount(/*#__PURE__*/_jsx(SelectBox, {
|
|
56
59
|
icon: MockIconComponent,
|
|
57
60
|
item: MockItemComponent,
|
|
58
61
|
items: dummyItems,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Portal from "../Portal";
|
|
4
4
|
import { AFTER, BEFORE } from "../../constants/Portals";
|
|
@@ -15,20 +15,24 @@ import { AFTER, BEFORE } from "../../constants/Portals";
|
|
|
15
15
|
* @param {React.ReactNode} props.children Component children
|
|
16
16
|
* @returns {JSX.Element}
|
|
17
17
|
*/
|
|
18
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
const SurroundPortals = ({
|
|
19
20
|
portalName,
|
|
20
21
|
portalProps,
|
|
21
22
|
children
|
|
22
|
-
}) => /*#__PURE__*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
23
|
+
}) => /*#__PURE__*/_jsxs(_Fragment, {
|
|
24
|
+
children: [/*#__PURE__*/_jsx(Portal, {
|
|
25
|
+
name: `${portalName}.${BEFORE}`,
|
|
26
|
+
props: portalProps
|
|
27
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
28
|
+
name: portalName,
|
|
29
|
+
props: portalProps,
|
|
30
|
+
children: children
|
|
31
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
32
|
+
name: `${portalName}.${AFTER}`,
|
|
33
|
+
props: portalProps
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
32
36
|
SurroundPortals.defaultProps = {
|
|
33
37
|
children: null,
|
|
34
38
|
portalProps: null
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
|
-
// eslint-disable-next-line import/no-unresolved
|
|
6
4
|
import { SwiperSlide } from 'swiper/react';
|
|
7
5
|
import { item } from "./styles";
|
|
8
6
|
|
|
@@ -15,15 +13,18 @@ import { item } from "./styles";
|
|
|
15
13
|
* @param {SwiperSlideProps} props The component props.
|
|
16
14
|
* @returns {React.Node}
|
|
17
15
|
*/
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
17
|
function SwiperItem({
|
|
19
18
|
children,
|
|
20
19
|
className,
|
|
21
20
|
...slideProps
|
|
22
21
|
}) {
|
|
23
|
-
return /*#__PURE__*/
|
|
22
|
+
return /*#__PURE__*/_jsx(SwiperSlide, {
|
|
23
|
+
...slideProps,
|
|
24
24
|
className: classNames(item, className),
|
|
25
|
-
"data-test-id": "Slider"
|
|
26
|
-
|
|
25
|
+
"data-test-id": "Slider",
|
|
26
|
+
children: children
|
|
27
|
+
});
|
|
27
28
|
}
|
|
28
29
|
SwiperItem.displayName = 'SwiperSlide';
|
|
29
30
|
SwiperItem.defaultProps = {
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import SwiperItem from '.';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
jest.mock('react', () => ({
|
|
6
|
+
...jest.requireActual('react'),
|
|
7
|
+
useLayoutEffect: jest.requireActual('react').useEffect
|
|
8
|
+
}));
|
|
4
9
|
describe('<SwiperItem />', () => {
|
|
5
10
|
it('should not render without children', () => {
|
|
6
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
11
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(SwiperItem, {
|
|
12
|
+
children: /*#__PURE__*/_jsx("div", {})
|
|
13
|
+
}));
|
|
7
14
|
expect(wrapper).toMatchSnapshot();
|
|
8
15
|
expect(wrapper.html()).toEqual('<div class="swiper-slide css-10a4qrv" data-test-id="Slider"><div></div></div>');
|
|
9
16
|
});
|
|
10
17
|
it('should add custom className', () => {
|
|
11
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
12
|
-
className: "test"
|
|
13
|
-
|
|
18
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(SwiperItem, {
|
|
19
|
+
className: "test",
|
|
20
|
+
children: /*#__PURE__*/_jsx("div", {})
|
|
21
|
+
}));
|
|
14
22
|
expect(wrapper).toMatchSnapshot();
|
|
15
23
|
expect(wrapper.html()).toEqual('<div class="swiper-slide css-10a4qrv test" data-test-id="Slider"><div></div></div>');
|
|
16
24
|
});
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { useMemo, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import cls from 'classnames';
|
|
5
4
|
import { A11y, Autoplay, FreeMode, Navigation, Pagination, Zoom } from 'swiper/modules';
|
|
6
|
-
/* eslint-disable import/no-unresolved */
|
|
7
5
|
import { Swiper as OriginalSwiper } from 'swiper/react';
|
|
8
6
|
import 'swiper/css';
|
|
9
7
|
import 'swiper/css/a11y';
|
|
10
8
|
import 'swiper/css/pagination';
|
|
11
9
|
import 'swiper/css/navigation';
|
|
12
10
|
import 'swiper/css/zoom';
|
|
13
|
-
/* eslint-enable import/no-unresolved */
|
|
14
11
|
import { useReduceMotion } from '@shopgate/engage/a11y/hooks';
|
|
15
12
|
import SwiperItem from "./components/SwiperItem";
|
|
16
13
|
import { container, innerContainer, zoomFix, buttonNext, buttonPrev } from "./styles";
|
|
@@ -28,6 +25,7 @@ import { container, innerContainer, zoomFix, buttonNext, buttonPrev } from "./st
|
|
|
28
25
|
* @param {SwiperClass} swiper Swiper instance
|
|
29
26
|
* @param {boolean} loop Whether the loop mode should be enabled or not.
|
|
30
27
|
*/
|
|
28
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
29
|
const handleLoopPropUpdate = (swiper, loop) => {
|
|
32
30
|
const realIndex = swiper?.realIndex || 0;
|
|
33
31
|
|
|
@@ -102,7 +100,7 @@ const Swiper = ({
|
|
|
102
100
|
* @type {SwiperCmpProps}
|
|
103
101
|
*/
|
|
104
102
|
const internalProps = useMemo(() => ({
|
|
105
|
-
modules: [A11y, Autoplay, FreeMode, Navigation, Pagination, Zoom
|
|
103
|
+
modules: [A11y, Autoplay, FreeMode, Navigation, Pagination, Zoom].concat(Array.isArray(additionalModules) ? additionalModules : []),
|
|
106
104
|
className: cls(innerContainer, classNames.container, {
|
|
107
105
|
[zoomFix]: swiperProps?.zoom
|
|
108
106
|
}),
|
|
@@ -188,23 +186,28 @@ const Swiper = ({
|
|
|
188
186
|
onBreakpoint(swiper, breakpoint);
|
|
189
187
|
}
|
|
190
188
|
}, [delay, loopProp, onBreakpoint]);
|
|
191
|
-
return /*#__PURE__*/
|
|
189
|
+
return /*#__PURE__*/_jsx("div", {
|
|
192
190
|
className: cls(container, className, 'common__swiper'),
|
|
193
|
-
"aria-hidden": ariaHidden
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
191
|
+
"aria-hidden": ariaHidden,
|
|
192
|
+
children: /*#__PURE__*/_jsxs(OriginalSwiper, {
|
|
193
|
+
"aria-live": "off",
|
|
194
|
+
a11y: {
|
|
195
|
+
enabled: false
|
|
196
|
+
},
|
|
197
|
+
...internalProps,
|
|
198
|
+
...swiperProps,
|
|
199
|
+
loop: shouldLoop,
|
|
200
|
+
onBreakpoint: handleOnBreakpoint,
|
|
201
|
+
ref: swiperRef,
|
|
202
|
+
children: [children, hasControls && /*#__PURE__*/_jsxs(_Fragment, {
|
|
203
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
204
|
+
className: `swiper-button-next ${buttonNext}`
|
|
205
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
206
|
+
className: `swiper-button-prev ${buttonPrev}`
|
|
207
|
+
})]
|
|
208
|
+
})]
|
|
209
|
+
})
|
|
210
|
+
});
|
|
208
211
|
};
|
|
209
212
|
Swiper.Item = SwiperItem;
|
|
210
213
|
Swiper.defaultProps = {
|
|
@@ -6,7 +6,10 @@ import ToastContext from "../../providers/toast/context";
|
|
|
6
6
|
* The Toaster component.
|
|
7
7
|
* @returns {JSX}
|
|
8
8
|
*/
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
const Toaster = ({
|
|
10
11
|
render
|
|
11
|
-
}) => /*#__PURE__*/
|
|
12
|
+
}) => /*#__PURE__*/_jsx(ToastContext.Consumer, {
|
|
13
|
+
children: context => render(context)
|
|
14
|
+
});
|
|
12
15
|
export default Toaster;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import isEqual from 'lodash/isEqual';
|
|
2
3
|
import React, { Component } from 'react';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
@@ -8,19 +9,24 @@ import gsap from 'gsap';
|
|
|
8
9
|
* Handles a transition of an object.
|
|
9
10
|
* This component only can have one child element at a time!
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
let Transition = /*#__PURE__*/function (_Component) {
|
|
13
|
+
function Transition() {
|
|
14
|
+
return _Component.apply(this, arguments) || this;
|
|
15
|
+
}
|
|
16
|
+
_inheritsLoose(Transition, _Component);
|
|
17
|
+
var _proto = Transition.prototype;
|
|
12
18
|
/**
|
|
13
19
|
* Runs the transition animation initially.
|
|
14
20
|
*/
|
|
15
|
-
componentDidMount() {
|
|
21
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
16
22
|
this.animate();
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Checks if transition related props (from/to) have updated and runs the animation.
|
|
21
27
|
* @param {Object} nextProps - The received props.
|
|
22
|
-
|
|
23
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
28
|
+
*/;
|
|
29
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
24
30
|
if (!isEqual(this.props.from, nextProps.from) || !isEqual(this.props.to, nextProps.to)) {
|
|
25
31
|
this.animate(nextProps);
|
|
26
32
|
}
|
|
@@ -29,8 +35,8 @@ class Transition extends Component {
|
|
|
29
35
|
/**
|
|
30
36
|
* Returns the first child of children.
|
|
31
37
|
* @returns {React.Element}
|
|
32
|
-
|
|
33
|
-
getFirstChild() {
|
|
38
|
+
*/;
|
|
39
|
+
_proto.getFirstChild = function getFirstChild() {
|
|
34
40
|
return React.Children.map(this.props.children, (element, idx) => (/*#__PURE__*/React.cloneElement(element, {
|
|
35
41
|
ref: idx
|
|
36
42
|
})))[0];
|
|
@@ -39,8 +45,8 @@ class Transition extends Component {
|
|
|
39
45
|
/**
|
|
40
46
|
* Sets the transition state and runs the transition animation.
|
|
41
47
|
* @param {Object} props - The props object the animation should be based upon.
|
|
42
|
-
|
|
43
|
-
animate(props = this.props) {
|
|
48
|
+
*/;
|
|
49
|
+
_proto.animate = function animate(props = this.props) {
|
|
44
50
|
// eslint-disable-next-line react/no-find-dom-node, react/no-string-refs
|
|
45
51
|
const element = findDOMNode(this.refs[0]);
|
|
46
52
|
const duration = props.duration / 1000;
|
|
@@ -83,11 +89,12 @@ class Transition extends Component {
|
|
|
83
89
|
/**
|
|
84
90
|
* Renders the component.
|
|
85
91
|
* @returns {JSX}
|
|
86
|
-
|
|
87
|
-
render() {
|
|
92
|
+
*/;
|
|
93
|
+
_proto.render = function render() {
|
|
88
94
|
return React.Children.only(this.getFirstChild());
|
|
89
|
-
}
|
|
90
|
-
|
|
95
|
+
};
|
|
96
|
+
return Transition;
|
|
97
|
+
}(Component);
|
|
91
98
|
Transition.defaultProps = {
|
|
92
99
|
easing: 'Power1.easeOut',
|
|
93
100
|
origin: '0 0 0',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { Component, Suspense } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import isEqual from 'lodash/isEqual';
|
|
@@ -7,12 +8,18 @@ import styles from "./style";
|
|
|
7
8
|
/**
|
|
8
9
|
* The widget component.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
let Widget = /*#__PURE__*/function (_Component) {
|
|
13
|
+
function Widget() {
|
|
14
|
+
return _Component.apply(this, arguments) || this;
|
|
15
|
+
}
|
|
16
|
+
_inheritsLoose(Widget, _Component);
|
|
17
|
+
var _proto = Widget.prototype;
|
|
11
18
|
/**
|
|
12
19
|
* @param {Object} nextProps The next component props.
|
|
13
20
|
* @return {boolean}
|
|
14
21
|
*/
|
|
15
|
-
shouldComponentUpdate(nextProps) {
|
|
22
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
16
23
|
if (this.props.component !== nextProps.component) return true;
|
|
17
24
|
if (!isEqual(this.props.config, nextProps.config)) return true;
|
|
18
25
|
return false;
|
|
@@ -20,8 +27,8 @@ class Widget extends Component {
|
|
|
20
27
|
|
|
21
28
|
/**
|
|
22
29
|
* @return {JSX}
|
|
23
|
-
|
|
24
|
-
render() {
|
|
30
|
+
*/;
|
|
31
|
+
_proto.render = function render() {
|
|
25
32
|
const {
|
|
26
33
|
col,
|
|
27
34
|
row,
|
|
@@ -32,24 +39,28 @@ class Widget extends Component {
|
|
|
32
39
|
if (!this.props.component) {
|
|
33
40
|
return null;
|
|
34
41
|
}
|
|
35
|
-
return /*#__PURE__*/
|
|
42
|
+
return /*#__PURE__*/_jsx(Grid.Item, {
|
|
36
43
|
className: `common__widgets__widget ${styles.widgetCell({
|
|
37
44
|
col,
|
|
38
45
|
row,
|
|
39
46
|
height,
|
|
40
47
|
width
|
|
41
48
|
})}`,
|
|
42
|
-
component: "div"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
49
|
+
component: "div",
|
|
50
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
51
|
+
className: styles.content,
|
|
52
|
+
children: /*#__PURE__*/_jsx(Suspense, {
|
|
53
|
+
fallback: /*#__PURE__*/_jsx(Loading, {}),
|
|
54
|
+
children: /*#__PURE__*/React.createElement(this.props.component, {
|
|
55
|
+
settings,
|
|
56
|
+
ratio: [width, height]
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return Widget;
|
|
63
|
+
}(Component);
|
|
53
64
|
Widget.defaultProps = {
|
|
54
65
|
component: null
|
|
55
66
|
};
|