@shopgate/pwa-common 7.30.0-alpha.9 → 7.30.0-beta.2
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 +2 -1
- 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 +16 -12
- 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 +8 -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 +5 -4
- package/components/Widgets/components/WidgetGrid/index.js +27 -19
- package/components/Widgets/components/WidgetGrid/spec.js +4 -3
- package/components/Widgets/index.js +33 -26
- package/components/Widgets/spec.js +12 -13
- 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 -5
- 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,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -7,6 +7,13 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
* @param {Object} context The component context.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
Placeholder
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const Placeholder = props => props.children;
|
|
12
|
+
Placeholder.format = props => /*#__PURE__*/_jsx(Placeholder, {
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
Placeholder.propTypes = {
|
|
16
|
+
children: PropTypes.node.isRequired,
|
|
17
|
+
forKey: PropTypes.string.isRequired
|
|
18
|
+
};
|
|
12
19
|
export default Placeholder;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import { i18n } from '@shopgate/engage/core';
|
|
4
4
|
import I18n from "../../index";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
6
|
jest.unmock('@shopgate/engage/core/helpers/i18n');
|
|
6
7
|
describe('<Placeholder />', () => {
|
|
7
8
|
const locales = {
|
|
@@ -15,11 +16,17 @@ describe('<Placeholder />', () => {
|
|
|
15
16
|
describe('Given the component was mounted to the DOM', () => {
|
|
16
17
|
let renderedElement;
|
|
17
18
|
it('should render', () => {
|
|
18
|
-
renderedElement = mount(/*#__PURE__*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
renderedElement = mount(/*#__PURE__*/_jsx(I18n.Provider, {
|
|
20
|
+
children: /*#__PURE__*/_jsxs(I18n.Text, {
|
|
21
|
+
string: "greeting",
|
|
22
|
+
children: [/*#__PURE__*/_jsx(I18n.Placeholder, {
|
|
23
|
+
forKey: "world",
|
|
24
|
+
children: /*#__PURE__*/_jsx("strong", {
|
|
25
|
+
children: "WORLD"
|
|
26
|
+
})
|
|
27
|
+
}), "/"]
|
|
28
|
+
})
|
|
29
|
+
}));
|
|
23
30
|
expect(renderedElement).toMatchSnapshot();
|
|
24
31
|
});
|
|
25
32
|
it('should render with a placeholder text', () => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import "core-js/modules/es.array.reduce.js";
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
@@ -24,6 +23,7 @@ import { i18n } from '@shopgate/engage/core/helpers/i18n';
|
|
|
24
23
|
* also handle human readable texts that contain text replacement placeholders.
|
|
25
24
|
* @returns {JSX.Element} The translated string as JSX component.
|
|
26
25
|
*/
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
27
|
const Translate = ({
|
|
28
28
|
string,
|
|
29
29
|
children,
|
|
@@ -38,10 +38,12 @@ const Translate = ({
|
|
|
38
38
|
return string;
|
|
39
39
|
}
|
|
40
40
|
if (!i18n.ready) {
|
|
41
|
-
return /*#__PURE__*/
|
|
41
|
+
return /*#__PURE__*/_jsx("span", {
|
|
42
42
|
className: className,
|
|
43
|
-
role: role
|
|
44
|
-
|
|
43
|
+
role: role,
|
|
44
|
+
...rest,
|
|
45
|
+
children: string
|
|
46
|
+
});
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
// When the input string is malformed, return the original string rather than raising an error.
|
|
@@ -64,14 +66,16 @@ const Translate = ({
|
|
|
64
66
|
|
|
65
67
|
// Create a new array containing the separated chunks of the text and merge the substitutions.
|
|
66
68
|
// The result can be an array with multiple strings and will be joined together.
|
|
67
|
-
formatted = stringParts.reduce((result, text, index) => [
|
|
69
|
+
formatted = stringParts.reduce((result, text, index) => [].concat(result, [text, childrenArray[index]]), []);
|
|
68
70
|
} catch (e) {
|
|
69
71
|
logger.error('i18n error for string %s', string, e);
|
|
70
72
|
}
|
|
71
|
-
return /*#__PURE__*/
|
|
73
|
+
return /*#__PURE__*/_jsx("span", {
|
|
72
74
|
className: className,
|
|
73
|
-
role: role
|
|
74
|
-
|
|
75
|
+
role: role,
|
|
76
|
+
...rest,
|
|
77
|
+
children: !transform ? formatted : transform(renderToString(formatted))
|
|
78
|
+
});
|
|
75
79
|
};
|
|
76
80
|
Translate.defaultProps = {
|
|
77
81
|
children: null,
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import { i18n } from '@shopgate/engage/core';
|
|
4
4
|
import I18n from "../../index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
jest.unmock('@shopgate/engage/core/helpers/i18n');
|
|
6
7
|
describe('<Translate />', () => {
|
|
7
8
|
const locales = {
|
|
@@ -14,12 +15,14 @@ describe('<Translate />', () => {
|
|
|
14
15
|
describe('Given the component was mounted to the DOM', () => {
|
|
15
16
|
let renderedElement;
|
|
16
17
|
it('should match snapshot', () => {
|
|
17
|
-
renderedElement = mount(/*#__PURE__*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
renderedElement = mount(/*#__PURE__*/_jsx(I18n.Provider, {
|
|
19
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
20
|
+
string: "greeting",
|
|
21
|
+
params: {
|
|
22
|
+
name: 'Test'
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}));
|
|
23
26
|
expect(renderedElement).toMatchSnapshot();
|
|
24
27
|
});
|
|
25
28
|
it('should render translated text', () => {
|
package/components/Icon/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import styles from "./style";
|
|
|
11
11
|
* @param {number} [props.size=24] The icon size
|
|
12
12
|
* @returns {JSX.Element}
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const Icon = props => /*#__PURE__*/_jsx("svg", {
|
|
15
16
|
className: `${styles} ${props.className} common__icon`,
|
|
16
17
|
viewBox: props.viewBox,
|
|
17
18
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6,6 +6,7 @@ import { themeConfig } from '@shopgate/engage';
|
|
|
6
6
|
import { getFullImageSource } from '@shopgate/engage/core/helpers';
|
|
7
7
|
import styles from "./style";
|
|
8
8
|
import ImageInner from "./ImageInner";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
const {
|
|
10
11
|
colors: themeColors
|
|
11
12
|
} = themeConfig;
|
|
@@ -134,7 +135,7 @@ const Image = ({
|
|
|
134
135
|
}, [ratio, resolutions]);
|
|
135
136
|
if (unwrapped) {
|
|
136
137
|
if (!(src && !parentRendersPlaceholder)) return null;
|
|
137
|
-
return /*#__PURE__*/
|
|
138
|
+
return /*#__PURE__*/_jsx(ImageInner, {
|
|
138
139
|
ref: imgRef,
|
|
139
140
|
src: sources.main,
|
|
140
141
|
className: classNames(classNameImg),
|
|
@@ -154,26 +155,27 @@ const Image = ({
|
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
157
|
const containerStyle = styles.container(backgroundColor, paddingHackRatio);
|
|
157
|
-
return /*#__PURE__*/
|
|
158
|
-
className: classNames(containerStyle, className, 'common__image__container')
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
158
|
+
return /*#__PURE__*/_jsx("div", {
|
|
159
|
+
className: classNames(containerStyle, className, 'common__image__container'),
|
|
160
|
+
children: src && !parentRendersPlaceholder && /*#__PURE__*/_jsx(ImageInner, {
|
|
161
|
+
ref: imgRef,
|
|
162
|
+
src: sources.main,
|
|
163
|
+
className: classNames(classNameImg),
|
|
164
|
+
style: {
|
|
165
|
+
aspectRatio,
|
|
166
|
+
...(isInView && sources.preview && {
|
|
167
|
+
backgroundImage: `url(${sources.preview})`,
|
|
168
|
+
backgroundSize: 'contain',
|
|
169
|
+
backgroundRepeat: 'no-repeat',
|
|
170
|
+
backgroundPosition: 'center'
|
|
171
|
+
})
|
|
172
|
+
},
|
|
173
|
+
alt: alt,
|
|
174
|
+
lazy: lazy,
|
|
175
|
+
onLoad: handleOnLoad,
|
|
176
|
+
onError: handleOnError
|
|
177
|
+
})
|
|
178
|
+
});
|
|
177
179
|
};
|
|
178
180
|
const defaultResolutions = [{
|
|
179
181
|
width: 440,
|
|
@@ -10,6 +10,7 @@ import styles from "./style";
|
|
|
10
10
|
* @param {Function} ref The component reference
|
|
11
11
|
* @returns {JSX.Element}
|
|
12
12
|
*/
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
const ImageInner = /*#__PURE__*/forwardRef(({
|
|
14
15
|
src,
|
|
15
16
|
className,
|
|
@@ -18,7 +19,7 @@ const ImageInner = /*#__PURE__*/forwardRef(({
|
|
|
18
19
|
onLoad,
|
|
19
20
|
onError,
|
|
20
21
|
style
|
|
21
|
-
}, ref) => /*#__PURE__*/
|
|
22
|
+
}, ref) => /*#__PURE__*/_jsx("img", {
|
|
22
23
|
ref: ref,
|
|
23
24
|
loading: lazy ? 'lazy' : 'eager',
|
|
24
25
|
src: src,
|
|
@@ -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 throttle from 'lodash/throttle';
|
|
@@ -11,30 +12,31 @@ import { ITEMS_PER_LOAD } from "../../constants/DisplayOptions";
|
|
|
11
12
|
* more items from it when the user reaches the end of the
|
|
12
13
|
* (parent) scroll container.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
let InfiniteContainer = /*#__PURE__*/function (_Component) {
|
|
15
17
|
/**
|
|
16
18
|
* The component constructor.
|
|
17
19
|
* @param {Object} props The component props.
|
|
18
20
|
* @param {Object} context The component context.
|
|
19
21
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
function InfiniteContainer(props, context) {
|
|
23
|
+
var _this;
|
|
24
|
+
_this = _Component.call(this, props, context) || this;
|
|
25
|
+
_this.domScrollContainer = null;
|
|
24
26
|
/**
|
|
25
27
|
* 10ms was chosen because, on the one hand, it prevents the scroll event from flooding but,
|
|
26
28
|
* on the other hand, it does not hinder users that scroll quickly from reloading next chunk.
|
|
27
29
|
*/
|
|
28
|
-
|
|
30
|
+
_this.handleLoadingProxy = throttle(() => {
|
|
29
31
|
if (props.enablePromiseBasedLoading) {
|
|
30
|
-
|
|
32
|
+
_this.handleLoadingPromise();
|
|
31
33
|
} else {
|
|
32
|
-
|
|
34
|
+
_this.handleLoading();
|
|
33
35
|
}
|
|
34
36
|
}, 10);
|
|
35
37
|
|
|
36
38
|
// A flag to prevent concurrent loading requests.
|
|
37
|
-
|
|
39
|
+
_this.isLoading = false;
|
|
38
40
|
|
|
39
41
|
// Determine the initial offset of items.
|
|
40
42
|
const {
|
|
@@ -48,13 +50,14 @@ class InfiniteContainer extends Component {
|
|
|
48
50
|
offset = 0
|
|
49
51
|
} = {}
|
|
50
52
|
} = context || {};
|
|
51
|
-
|
|
53
|
+
_this.state = {
|
|
52
54
|
itemCount: items.length,
|
|
53
55
|
offset: [offset, currentOffset],
|
|
54
56
|
// A state flag that will be true as long as we await more items.
|
|
55
57
|
// The loading indicator will be shown accordingly.
|
|
56
58
|
awaitingItems: true
|
|
57
59
|
};
|
|
60
|
+
return _this;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -62,7 +65,9 @@ class InfiniteContainer extends Component {
|
|
|
62
65
|
* parent scroll container if available.
|
|
63
66
|
* After that it calls for the initial data to load.
|
|
64
67
|
*/
|
|
65
|
-
|
|
68
|
+
_inheritsLoose(InfiniteContainer, _Component);
|
|
69
|
+
var _proto = InfiniteContainer.prototype;
|
|
70
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
66
71
|
const {
|
|
67
72
|
current
|
|
68
73
|
} = this.props.containerRef;
|
|
@@ -82,8 +87,8 @@ class InfiniteContainer extends Component {
|
|
|
82
87
|
/**
|
|
83
88
|
* Checks if the component received new items or already received all items.
|
|
84
89
|
* @param {Object} nextProps The next props.
|
|
85
|
-
|
|
86
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
90
|
+
*/;
|
|
91
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
87
92
|
/**
|
|
88
93
|
* Downstream logic to process the props. It's wrapped into a separate function, since it might
|
|
89
94
|
* be executed after the state was updated to avoid race conditions.
|
|
@@ -128,15 +133,15 @@ class InfiniteContainer extends Component {
|
|
|
128
133
|
* @param {Object} nextProps The next component props.
|
|
129
134
|
* @param {Object} nextState The next component state.
|
|
130
135
|
* @returns {boolean}
|
|
131
|
-
|
|
132
|
-
shouldComponentUpdate(nextProps, nextState) {
|
|
136
|
+
*/;
|
|
137
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
|
|
133
138
|
return !isEqual(this.props.containerRef, nextProps.containerRef) || !isEqual(this.props.columns, nextProps.columns) || !isEqual(this.props.items, nextProps.items) || !isEqual(this.state, nextState);
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
/**
|
|
137
142
|
* Reset the loading flag.
|
|
138
|
-
|
|
139
|
-
componentDidUpdate() {
|
|
143
|
+
*/;
|
|
144
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
140
145
|
// When promise based implementation is active, `isLoading` is reset when response comes in.
|
|
141
146
|
// In the legacy implementation this happens after the fetched items reached the component and
|
|
142
147
|
// is not necessary here anymore.
|
|
@@ -147,8 +152,8 @@ class InfiniteContainer extends Component {
|
|
|
147
152
|
|
|
148
153
|
/**
|
|
149
154
|
* When the component will unmount it unbinds all previously bound event listeners.
|
|
150
|
-
|
|
151
|
-
componentWillUnmount() {
|
|
155
|
+
*/;
|
|
156
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
152
157
|
router.update(this.context.id, {
|
|
153
158
|
offset: this.state.offset[0]
|
|
154
159
|
}, false);
|
|
@@ -157,8 +162,8 @@ class InfiniteContainer extends Component {
|
|
|
157
162
|
|
|
158
163
|
/**
|
|
159
164
|
* Adds scroll event listeners to the scroll container if available.
|
|
160
|
-
|
|
161
|
-
bindEvents() {
|
|
165
|
+
*/;
|
|
166
|
+
_proto.bindEvents = function bindEvents() {
|
|
162
167
|
if (this.domScrollContainer) {
|
|
163
168
|
this.domScrollContainer.addEventListener('scroll', this.handleLoadingProxy);
|
|
164
169
|
}
|
|
@@ -167,8 +172,8 @@ class InfiniteContainer extends Component {
|
|
|
167
172
|
/**
|
|
168
173
|
* Removes scroll event listeners from the scroll container.
|
|
169
174
|
* @param {Node} container A reference to an old scroll container.
|
|
170
|
-
|
|
171
|
-
unbindEvents(container) {
|
|
175
|
+
*/;
|
|
176
|
+
_proto.unbindEvents = function unbindEvents(container) {
|
|
172
177
|
if (container) {
|
|
173
178
|
container.removeEventListener('scroll', this.handleLoadingProxy);
|
|
174
179
|
} else if (this.domScrollContainer) {
|
|
@@ -180,8 +185,8 @@ class InfiniteContainer extends Component {
|
|
|
180
185
|
* Tests if there are more items to be received via items prop.
|
|
181
186
|
* @param {Object} [props] The current or next component props.
|
|
182
187
|
* @returns {boolean}
|
|
183
|
-
|
|
184
|
-
needsToReceiveItems(props = this.props) {
|
|
188
|
+
*/;
|
|
189
|
+
_proto.needsToReceiveItems = function needsToReceiveItems(props = this.props) {
|
|
185
190
|
return props.totalItems === null || props.items.length < props.totalItems;
|
|
186
191
|
}
|
|
187
192
|
|
|
@@ -189,8 +194,8 @@ class InfiniteContainer extends Component {
|
|
|
189
194
|
* Tests if the total amount of items has been received via totalItems prop.
|
|
190
195
|
* @param {Object} nextProps The next component props.
|
|
191
196
|
* @returns {boolean}
|
|
192
|
-
|
|
193
|
-
receivedTotalItems(nextProps) {
|
|
197
|
+
*/;
|
|
198
|
+
_proto.receivedTotalItems = function receivedTotalItems(nextProps) {
|
|
194
199
|
return nextProps.totalItems !== null && nextProps.totalItems !== this.props.totalItems;
|
|
195
200
|
}
|
|
196
201
|
|
|
@@ -198,8 +203,8 @@ class InfiniteContainer extends Component {
|
|
|
198
203
|
* Tests if all items have been received and are visible based on current offset.
|
|
199
204
|
* @param {Object} [props] The current or next component props.
|
|
200
205
|
* @returns {boolean}
|
|
201
|
-
|
|
202
|
-
allItemsAreRendered(props = this.props) {
|
|
206
|
+
*/;
|
|
207
|
+
_proto.allItemsAreRendered = function allItemsAreRendered(props = this.props) {
|
|
203
208
|
const {
|
|
204
209
|
totalItems,
|
|
205
210
|
items
|
|
@@ -217,8 +222,8 @@ class InfiniteContainer extends Component {
|
|
|
217
222
|
/**
|
|
218
223
|
* Increases the current offset by limit (from props).
|
|
219
224
|
* @returns {Object}
|
|
220
|
-
|
|
221
|
-
increaseOffset() {
|
|
225
|
+
*/;
|
|
226
|
+
_proto.increaseOffset = function increaseOffset() {
|
|
222
227
|
const [start, length] = this.state.offset;
|
|
223
228
|
let newOffset = start + length;
|
|
224
229
|
|
|
@@ -245,8 +250,8 @@ class InfiniteContainer extends Component {
|
|
|
245
250
|
* Resets the state.
|
|
246
251
|
* @param {Function} callback A callback which is invoked after the state was updated.
|
|
247
252
|
* This is necessary to avoid race conditions with downstream code.
|
|
248
|
-
|
|
249
|
-
resetComponent(callback) {
|
|
253
|
+
*/;
|
|
254
|
+
_proto.resetComponent = function resetComponent(callback) {
|
|
250
255
|
this.setState({
|
|
251
256
|
offset: [0, this.props.limit],
|
|
252
257
|
awaitingItems: true,
|
|
@@ -260,8 +265,8 @@ class InfiniteContainer extends Component {
|
|
|
260
265
|
|
|
261
266
|
/**
|
|
262
267
|
* Stops the lazy loading processes
|
|
263
|
-
|
|
264
|
-
stopLazyLoading() {
|
|
268
|
+
*/;
|
|
269
|
+
_proto.stopLazyLoading = function stopLazyLoading() {
|
|
265
270
|
this.setState({
|
|
266
271
|
awaitingItems: false
|
|
267
272
|
});
|
|
@@ -272,8 +277,8 @@ class InfiniteContainer extends Component {
|
|
|
272
277
|
* Verifies if all items are loaded and shown, then set final state and unbind events.
|
|
273
278
|
* @param {Object} [props] The current or next component props.
|
|
274
279
|
* @returns {boolean} Returns true if the component has reached the final state.
|
|
275
|
-
|
|
276
|
-
verifyAllDone(props = this.props) {
|
|
280
|
+
*/;
|
|
281
|
+
_proto.verifyAllDone = function verifyAllDone(props = this.props) {
|
|
277
282
|
if (this.allItemsAreRendered(props)) {
|
|
278
283
|
this.stopLazyLoading();
|
|
279
284
|
return true;
|
|
@@ -285,8 +290,8 @@ class InfiniteContainer extends Component {
|
|
|
285
290
|
* Tests if the current scroll position is near the bottom
|
|
286
291
|
* of the scroll container.
|
|
287
292
|
* @returns {boolean}
|
|
288
|
-
|
|
289
|
-
validateScrollPosition() {
|
|
293
|
+
*/;
|
|
294
|
+
_proto.validateScrollPosition = function validateScrollPosition() {
|
|
290
295
|
if (!this.domScrollContainer) {
|
|
291
296
|
return true;
|
|
292
297
|
}
|
|
@@ -319,8 +324,8 @@ class InfiniteContainer extends Component {
|
|
|
319
324
|
* Handles incrementing of render offset and the request of new items if necessary.
|
|
320
325
|
* @param {boolean} [force] If set to true, proceed independently of scroll validation.
|
|
321
326
|
* @param {Object} [props] The current or next component props.
|
|
322
|
-
|
|
323
|
-
handleLoading(force = false, props = this.props) {
|
|
327
|
+
*/;
|
|
328
|
+
_proto.handleLoading = function handleLoading(force = false, props = this.props) {
|
|
324
329
|
// Do not load if there is an update in progress.
|
|
325
330
|
if (this.isLoading) {
|
|
326
331
|
return;
|
|
@@ -362,8 +367,8 @@ class InfiniteContainer extends Component {
|
|
|
362
367
|
* for offset handling.
|
|
363
368
|
* @param {boolean} [force] If set to true, proceed independently of scroll validation.
|
|
364
369
|
* @param {Object} [props] The current or next component props.
|
|
365
|
-
|
|
366
|
-
async handleLoadingPromise(force = false, props = this.props) {
|
|
370
|
+
*/;
|
|
371
|
+
_proto.handleLoadingPromise = async function handleLoadingPromise(force = false, props = this.props) {
|
|
367
372
|
if (this.isLoading) {
|
|
368
373
|
return;
|
|
369
374
|
}
|
|
@@ -395,8 +400,8 @@ class InfiniteContainer extends Component {
|
|
|
395
400
|
/**
|
|
396
401
|
* Renders the component.
|
|
397
402
|
* @returns {JSX}
|
|
398
|
-
|
|
399
|
-
render() {
|
|
403
|
+
*/;
|
|
404
|
+
_proto.render = function render() {
|
|
400
405
|
const {
|
|
401
406
|
wrapper,
|
|
402
407
|
items,
|
|
@@ -416,14 +421,15 @@ class InfiniteContainer extends Component {
|
|
|
416
421
|
const content = typeof wrapper === 'function' ? wrapper({
|
|
417
422
|
children
|
|
418
423
|
}) : (/*#__PURE__*/React.createElement(wrapper, {}, children));
|
|
419
|
-
return /*#__PURE__*/
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
424
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
425
|
+
className: "common__infinite-container",
|
|
426
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
427
|
+
children: content
|
|
428
|
+
}), awaitingItems && loadingIndicator]
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
return InfiniteContainer;
|
|
432
|
+
}(Component);
|
|
427
433
|
InfiniteContainer.contextType = RouteContext;
|
|
428
434
|
InfiniteContainer.defaultProps = {
|
|
429
435
|
columns: 2,
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { shallow, mount } from 'enzyme';
|
|
4
4
|
import { ITEMS_PER_LOAD } from "../../constants/DisplayOptions";
|
|
5
5
|
import InfiniteContainer from "./index";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
global.console.error = jest.fn();
|
|
7
8
|
const context = {
|
|
8
9
|
state: {}
|
|
@@ -23,7 +24,9 @@ describe('<InfiniteContainer />', () => {
|
|
|
23
24
|
* @param {Object} props The component props.
|
|
24
25
|
*/
|
|
25
26
|
const renderComponent = props => {
|
|
26
|
-
renderedElement = shallow(/*#__PURE__*/
|
|
27
|
+
renderedElement = shallow(/*#__PURE__*/_jsx(InfiniteContainer, {
|
|
28
|
+
...props
|
|
29
|
+
}), {
|
|
27
30
|
context
|
|
28
31
|
});
|
|
29
32
|
renderedInstance = renderedElement.instance();
|
|
@@ -44,9 +47,9 @@ describe('<InfiniteContainer />', () => {
|
|
|
44
47
|
};
|
|
45
48
|
beforeEach(() => {
|
|
46
49
|
mockLoader = jest.fn();
|
|
47
|
-
mockIterator = jest.fn(data => /*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
}, data.
|
|
50
|
+
mockIterator = jest.fn(data => /*#__PURE__*/_jsx("li", {
|
|
51
|
+
children: data.title
|
|
52
|
+
}, data.id));
|
|
50
53
|
});
|
|
51
54
|
describe('Given the component was mounted to the DOM', () => {
|
|
52
55
|
beforeEach(() => {
|
|
@@ -182,7 +185,9 @@ describe('<InfiniteContainer />', () => {
|
|
|
182
185
|
totalItems: mockData.length,
|
|
183
186
|
requestHash: 'default'
|
|
184
187
|
};
|
|
185
|
-
const wrapper = mount(/*#__PURE__*/
|
|
188
|
+
const wrapper = mount(/*#__PURE__*/_jsx(InfiniteContainer, {
|
|
189
|
+
...props
|
|
190
|
+
}));
|
|
186
191
|
const instance = wrapper.instance();
|
|
187
192
|
instance.componentDidMount();
|
|
188
193
|
instance.domScrollContainer = document.createElement('div');
|