@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,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('<FormatPrice />', () => {
|
|
7
8
|
const locales = {
|
|
@@ -18,20 +19,27 @@ describe('<FormatPrice />', () => {
|
|
|
18
19
|
describe('Given the component was mounted to the DOM', () => {
|
|
19
20
|
let renderedElement;
|
|
20
21
|
it('should match snapshot', () => {
|
|
21
|
-
renderedElement = mount(/*#__PURE__*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
renderedElement = mount(/*#__PURE__*/_jsx(I18n.Provider, {
|
|
23
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
24
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
25
|
+
className: "only-price",
|
|
26
|
+
children: /*#__PURE__*/_jsx(I18n.Price, {
|
|
27
|
+
price: price,
|
|
28
|
+
currency: currency
|
|
29
|
+
})
|
|
30
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
31
|
+
className: "text-with-price",
|
|
32
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
33
|
+
string: "greeting",
|
|
34
|
+
children: /*#__PURE__*/_jsx(I18n.Price, {
|
|
35
|
+
forKey: "price",
|
|
36
|
+
price: price,
|
|
37
|
+
currency: currency
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})]
|
|
41
|
+
})
|
|
42
|
+
}));
|
|
35
43
|
expect(renderedElement).toMatchSnapshot();
|
|
36
44
|
});
|
|
37
45
|
it('should render formatted price', () => {
|
|
@@ -7,13 +7,16 @@ import { i18n } from '@shopgate/engage/core/helpers/i18n';
|
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const FormatTime = ({
|
|
11
12
|
timestamp,
|
|
12
13
|
format
|
|
13
|
-
}) => /*#__PURE__*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
}) => /*#__PURE__*/_jsx(_Fragment, {
|
|
15
|
+
children: FormatTime.format({
|
|
16
|
+
timestamp,
|
|
17
|
+
format
|
|
18
|
+
})
|
|
19
|
+
});
|
|
17
20
|
FormatTime.format = ({
|
|
18
21
|
timestamp,
|
|
19
22
|
format
|
|
@@ -23,6 +26,10 @@ FormatTime.format = ({
|
|
|
23
26
|
}
|
|
24
27
|
return i18n.time(timestamp, format);
|
|
25
28
|
};
|
|
29
|
+
FormatTime.propTypes = {
|
|
30
|
+
timestamp: PropTypes.number.isRequired,
|
|
31
|
+
format: PropTypes.string
|
|
32
|
+
};
|
|
26
33
|
FormatTime.defaultProps = {
|
|
27
34
|
format: 'medium'
|
|
28
35
|
};
|
|
@@ -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('<FormatTime />', () => {
|
|
7
8
|
const locales = {
|
|
@@ -17,20 +18,27 @@ describe('<FormatTime />', () => {
|
|
|
17
18
|
});
|
|
18
19
|
describe('Given the component was mounted to the DOM', () => {
|
|
19
20
|
// TODO: Handle snapshot test.
|
|
20
|
-
const renderedElement = mount(/*#__PURE__*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
const renderedElement = mount(/*#__PURE__*/_jsx(I18n.Provider, {
|
|
22
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
23
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
24
|
+
className: "only-time",
|
|
25
|
+
children: /*#__PURE__*/_jsx(I18n.Time, {
|
|
26
|
+
timestamp: timestamp,
|
|
27
|
+
format: format
|
|
28
|
+
})
|
|
29
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
30
|
+
className: "text-with-time",
|
|
31
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
32
|
+
string: "greeting",
|
|
33
|
+
children: /*#__PURE__*/_jsx(I18n.Time, {
|
|
34
|
+
forKey: "time",
|
|
35
|
+
timestamp: timestamp,
|
|
36
|
+
format: format
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})]
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
34
42
|
it('should render formatted time', () => {
|
|
35
43
|
const text = renderedElement.find('.only-time').text();
|
|
36
44
|
expect(text).toBe(formattedTime);
|
|
@@ -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 { i18n } from '@shopgate/engage/core/helpers/i18n';
|
|
@@ -7,53 +8,59 @@ import { logger } from '@shopgate/pwa-core/helpers';
|
|
|
7
8
|
* A React component that provides child components with i18n features.
|
|
8
9
|
* @returns {React.Component}
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
let I18nProvider = /*#__PURE__*/function (_Component) {
|
|
11
12
|
/**
|
|
12
13
|
* @inheritDoc
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
function I18nProvider(props) {
|
|
16
|
+
var _this;
|
|
17
|
+
_this = _Component.call(this, props) || this;
|
|
16
18
|
// eslint-disable-next-line react/prop-types
|
|
17
19
|
/**
|
|
18
20
|
* Gets a shortcut to i18n functionality with preset language.
|
|
19
21
|
* @returns {Object}
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
_this.getI18nInstance = () => ({
|
|
22
24
|
__: i18n.text,
|
|
23
25
|
_p: i18n.price,
|
|
24
26
|
_d: i18n.date,
|
|
25
27
|
_t: i18n.time,
|
|
26
28
|
_n: i18n.number
|
|
27
29
|
});
|
|
28
|
-
if (
|
|
30
|
+
if (_this.props.lang || _this.props.locales) {
|
|
29
31
|
logger.warn(`===== I18nProvider deprecated =====\nI18nProvider and it's related components (@shopgate/pwa-common/component/I18n) or context types are deprecated and will be removed in @shopgate/engage v7.0.0.\nPlease use { i18n } from @shopgate/engage/core.\n===================================
|
|
30
32
|
`);
|
|
31
33
|
}
|
|
34
|
+
return _this;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* Provides context for child components.
|
|
36
39
|
* @returns {Object}
|
|
37
40
|
*/
|
|
38
|
-
|
|
41
|
+
_inheritsLoose(I18nProvider, _Component);
|
|
42
|
+
var _proto = I18nProvider.prototype;
|
|
43
|
+
_proto.getChildContext = function getChildContext() {
|
|
39
44
|
return {
|
|
40
45
|
i18n: this.getI18nInstance
|
|
41
46
|
};
|
|
42
|
-
}
|
|
47
|
+
};
|
|
43
48
|
/**
|
|
44
49
|
* Renders the component.
|
|
45
50
|
* @returns {JSX}
|
|
46
51
|
*/
|
|
47
|
-
render() {
|
|
52
|
+
_proto.render = function render() {
|
|
48
53
|
const {
|
|
49
54
|
children
|
|
50
55
|
} = this.props;
|
|
51
56
|
return children ? /*#__PURE__*/React.cloneElement(children) : null;
|
|
52
|
-
}
|
|
53
|
-
|
|
57
|
+
};
|
|
58
|
+
return I18nProvider;
|
|
59
|
+
}(Component);
|
|
54
60
|
I18nProvider.childContextTypes = {
|
|
55
61
|
i18n: PropTypes.func.isRequired
|
|
56
62
|
};
|
|
57
63
|
I18nProvider.defaultProps = {
|
|
58
64
|
children: null
|
|
59
|
-
};
|
|
65
|
+
};
|
|
66
|
+
export { I18nProvider as default };
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import { i18n as i18nHelper } from '@shopgate/engage/core';
|
|
4
4
|
import I18nProvider from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
jest.unmock('@shopgate/engage/core/helpers/i18n');
|
|
6
7
|
describe('<I18nProvider />', () => {
|
|
7
8
|
const locales = {
|
|
@@ -16,7 +17,7 @@ describe('<I18nProvider />', () => {
|
|
|
16
17
|
let renderedElement;
|
|
17
18
|
let renderedInstance;
|
|
18
19
|
it('should match snapshot', () => {
|
|
19
|
-
renderedElement = shallow(/*#__PURE__*/
|
|
20
|
+
renderedElement = shallow(/*#__PURE__*/_jsx(I18nProvider, {}));
|
|
20
21
|
renderedInstance = renderedElement.instance();
|
|
21
22
|
expect(renderedElement).toMatchSnapshot();
|
|
22
23
|
});
|
|
@@ -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,
|