@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.
Files changed (106) hide show
  1. package/App.js +28 -13
  2. package/actions/app/handleUniversalLink.js +0 -2
  3. package/collections/AuthRoutes.js +15 -13
  4. package/collections/Configuration.js +11 -10
  5. package/collections/EmbeddedMedia.js +21 -19
  6. package/collections/PersistedReducers.js +11 -9
  7. package/collections/Redirects.js +15 -13
  8. package/collections/media-providers/MediaProvider.js +23 -21
  9. package/collections/media-providers/Vimeo.js +28 -22
  10. package/collections/media-providers/YouTube.js +17 -10
  11. package/components/Backdrop/index.js +15 -13
  12. package/components/Backdrop/spec.js +3 -2
  13. package/components/Button/index.js +41 -29
  14. package/components/Button/spec.js +16 -10
  15. package/components/Checkbox/index.js +36 -28
  16. package/components/Checkbox/spec.js +40 -27
  17. package/components/Consume/index.js +4 -1
  18. package/components/CountdownTimer/index.js +27 -20
  19. package/components/CountdownTimer/spec.js +39 -38
  20. package/components/Drawer/index.js +31 -23
  21. package/components/Drawer/spec.js +7 -6
  22. package/components/Dropdown/index.js +27 -18
  23. package/components/Ellipsis/index.js +5 -3
  24. package/components/Ellipsis/spec.js +5 -3
  25. package/components/EmbeddedMedia/index.js +9 -6
  26. package/components/EmbeddedMedia/spec.js +11 -2
  27. package/components/ErrorBoundary/index.js +26 -16
  28. package/components/Grid/components/Item/index.js +13 -6
  29. package/components/Grid/components/Item/spec.js +4 -3
  30. package/components/Grid/index.js +13 -6
  31. package/components/Grid/spec.js +4 -3
  32. package/components/HtmlSanitizer/index.js +42 -45
  33. package/components/HtmlSanitizer/spec.js +31 -21
  34. package/components/I18n/components/FormatDate/index.js +11 -4
  35. package/components/I18n/components/FormatDate/spec.js +22 -14
  36. package/components/I18n/components/FormatNumber/index.js +8 -6
  37. package/components/I18n/components/FormatNumber/spec.js +10 -5
  38. package/components/I18n/components/FormatPrice/index.js +5 -3
  39. package/components/I18n/components/FormatPrice/spec.js +22 -14
  40. package/components/I18n/components/FormatTime/index.js +11 -4
  41. package/components/I18n/components/FormatTime/spec.js +22 -14
  42. package/components/I18n/components/I18nProvider/index.js +18 -11
  43. package/components/I18n/components/I18nProvider/spec.js +2 -1
  44. package/components/I18n/components/Placeholder/index.js +10 -3
  45. package/components/I18n/components/Placeholder/spec.js +12 -5
  46. package/components/I18n/components/Translate/index.js +12 -8
  47. package/components/I18n/components/Translate/spec.js +9 -6
  48. package/components/Icon/index.js +2 -1
  49. package/components/Image/Image.js +23 -21
  50. package/components/Image/ImageInner.js +2 -1
  51. package/components/InfiniteContainer/index.js +59 -53
  52. package/components/InfiniteContainer/spec.js +10 -5
  53. package/components/Input/components/MultiLineInput.js +33 -26
  54. package/components/Input/components/SimpleInput.js +70 -54
  55. package/components/Input/index.js +7 -17
  56. package/components/Input/spec.js +12 -11
  57. package/components/KeyboardConsumer/index.js +19 -13
  58. package/components/Link/index.js +28 -20
  59. package/components/Link/spec.js +13 -9
  60. package/components/List/components/Item/index.js +5 -3
  61. package/components/List/index.js +5 -3
  62. package/components/List/spec.js +6 -9
  63. package/components/Loading/index.js +1 -3
  64. package/components/Modal/index.js +13 -10
  65. package/components/ModalContainer/spec.js +24 -20
  66. package/components/Picker/components/Button/index.js +18 -12
  67. package/components/Picker/components/List/index.js +19 -16
  68. package/components/Picker/components/Modal/index.js +34 -25
  69. package/components/Picker/index.js +44 -33
  70. package/components/Picker/spec.js +4 -1
  71. package/components/Portal/index.js +26 -17
  72. package/components/ProductCharacteristics/index.js +65 -57
  73. package/components/RangeSlider/components/Handle/index.js +7 -5
  74. package/components/RangeSlider/index.js +98 -84
  75. package/components/Route/RouteNotFound.js +30 -19
  76. package/components/Route/index.js +31 -21
  77. package/components/Router/index.js +51 -34
  78. package/components/ScannerContainer/index.js +17 -10
  79. package/components/Select/components/Item/index.js +5 -3
  80. package/components/Select/index.js +59 -47
  81. package/components/Select/spec.js +7 -6
  82. package/components/SelectBox/components/Item/index.js +23 -13
  83. package/components/SelectBox/index.js +83 -80
  84. package/components/SelectBox/spec.js +8 -5
  85. package/components/SurroundPortals/index.js +15 -11
  86. package/components/Swiper/components/SwiperItem/index.js +6 -5
  87. package/components/Swiper/components/SwiperItem/spec.js +12 -4
  88. package/components/Swiper/index.js +23 -20
  89. package/components/Toaster/index.js +4 -1
  90. package/components/Transition/index.js +19 -12
  91. package/components/Widgets/components/Widget/index.js +27 -16
  92. package/components/Widgets/components/Widget/spec.js +6 -5
  93. package/components/Widgets/components/WidgetGrid/index.js +27 -19
  94. package/components/Widgets/components/WidgetGrid/spec.js +5 -4
  95. package/components/Widgets/index.js +33 -26
  96. package/components/Widgets/spec.js +32 -18
  97. package/helpers/data/index.js +1 -1
  98. package/helpers/portals/portalCollection.js +13 -10
  99. package/helpers/redux/mutable.js +2 -2
  100. package/package.json +5 -6
  101. package/providers/loading/index.js +71 -57
  102. package/providers/toast/index.js +39 -28
  103. package/reducers/modal/index.js +1 -1
  104. package/store/index.js +1 -1
  105. package/subscriptions/helpers/buildRegisterUrl.js +1 -0
  106. package/components/Input/components/DateInput.js +0 -273
@@ -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 connector from "./connector";
@@ -5,27 +6,35 @@ import connector from "./connector";
5
6
  /**
6
7
  * The App error boundary component.
7
8
  */
8
- class ErrorBoundary extends PureComponent {
9
- constructor(...args) {
10
- super(...args);
11
- this.state = {
12
- hasError: false
13
- };
14
- }
9
+ let ErrorBoundary = /*#__PURE__*/function (_PureComponent) {
15
10
  /**
16
- * @returns {{hasError: boolean}}
11
+ * Constructor for the ErrorBoundary component.
12
+ * @param {Object} props - The component props.
17
13
  */
18
- static getDerivedStateFromError() {
19
- return {
20
- hasError: true
14
+ function ErrorBoundary(props) {
15
+ var _this;
16
+ _this = _PureComponent.call(this, props) || this;
17
+ _this.state = {
18
+ hasError: false
21
19
  };
20
+ return _this;
22
21
  }
23
22
 
24
23
  /**
25
24
  * @param {Object} error The error object.
26
25
  * @param {Object} errorInfo The error information.
27
26
  */
28
- componentDidCatch(error, errorInfo) {
27
+ _inheritsLoose(ErrorBoundary, _PureComponent);
28
+ /**
29
+ * @returns {{hasError: boolean}}
30
+ */
31
+ ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError() {
32
+ return {
33
+ hasError: true
34
+ };
35
+ };
36
+ var _proto = ErrorBoundary.prototype;
37
+ _proto.componentDidCatch = function componentDidCatch(error, errorInfo) {
29
38
  // eslint-disable-next-line no-param-reassign
30
39
  error.stack = errorInfo.componentStack;
31
40
  this.props.appError(error);
@@ -33,14 +42,15 @@ class ErrorBoundary extends PureComponent {
33
42
 
34
43
  /**
35
44
  * @returns {JSX}
36
- */
37
- render() {
45
+ */;
46
+ _proto.render = function render() {
38
47
  if (this.state.hasError) {
39
48
  return this.props.fallbackUi;
40
49
  }
41
50
  return this.props.children;
42
- }
43
- }
51
+ };
52
+ return ErrorBoundary;
53
+ }(PureComponent);
44
54
  ErrorBoundary.defaultProps = {
45
55
  fallbackUi: null
46
56
  };
@@ -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 { objectWithoutProps } from "../../../../helpers/data";
@@ -6,12 +7,17 @@ import styles from "./style";
6
7
  /**
7
8
  * The grid item component.
8
9
  */
9
- class GridItem extends Component {
10
+ let GridItem = /*#__PURE__*/function (_Component) {
11
+ function GridItem() {
12
+ return _Component.apply(this, arguments) || this;
13
+ }
14
+ _inheritsLoose(GridItem, _Component);
15
+ var _proto = GridItem.prototype;
10
16
  /**
11
17
  * Composes the props.
12
18
  * @returns {Object} The composed props.
13
19
  */
14
- getProps() {
20
+ _proto.getProps = function getProps() {
15
21
  let {
16
22
  className
17
23
  } = this.props;
@@ -31,11 +37,12 @@ class GridItem extends Component {
31
37
  /**
32
38
  * Renders the component.
33
39
  * @returns {JSX}
34
- */
35
- render() {
40
+ */;
41
+ _proto.render = function render() {
36
42
  return /*#__PURE__*/React.createElement(this.props.component, this.getProps());
37
- }
38
- }
43
+ };
44
+ return GridItem;
45
+ }(Component);
39
46
  GridItem.defaultProps = {
40
47
  className: '',
41
48
  component: 'li',
@@ -1,20 +1,21 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import GridItem from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  describe('<GridItem />', () => {
5
6
  it('should render without any further props', () => {
6
- const wrapper = shallow(/*#__PURE__*/React.createElement(GridItem, null));
7
+ const wrapper = shallow(/*#__PURE__*/_jsx(GridItem, {}));
7
8
  expect(wrapper).toMatchSnapshot();
8
9
  });
9
10
  it('should be able to render a custom tag', () => {
10
- const wrapper = shallow(/*#__PURE__*/React.createElement(GridItem, {
11
+ const wrapper = shallow(/*#__PURE__*/_jsx(GridItem, {
11
12
  component: "section"
12
13
  }));
13
14
  expect(wrapper).toMatchSnapshot();
14
15
  expect(wrapper.type()).toEqual('section');
15
16
  });
16
17
  it('should add custom classes on demand', () => {
17
- const wrapper = shallow(/*#__PURE__*/React.createElement(GridItem, {
18
+ const wrapper = shallow(/*#__PURE__*/_jsx(GridItem, {
18
19
  className: "custom-class-name"
19
20
  }));
20
21
  expect(wrapper).toMatchSnapshot();
@@ -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 { objectWithoutProps } from "../../helpers/data";
@@ -7,12 +8,17 @@ import styles, { wrap } from "./style";
7
8
  /**
8
9
  * The grid component.
9
10
  */
10
- class Grid extends Component {
11
+ let Grid = /*#__PURE__*/function (_Component) {
12
+ function Grid() {
13
+ return _Component.apply(this, arguments) || this;
14
+ }
15
+ _inheritsLoose(Grid, _Component);
16
+ var _proto = Grid.prototype;
11
17
  /**
12
18
  * Composes the props.
13
19
  * @returns {Object} The composed props.
14
20
  */
15
- getProps() {
21
+ _proto.getProps = function getProps() {
16
22
  let className = `${this.props.className} ${styles} common__grid`;
17
23
  if (this.props.wrap) {
18
24
  className += ` ${wrap(this.props.wrap)}`;
@@ -27,11 +33,12 @@ class Grid extends Component {
27
33
  /**
28
34
  * Renders the component.
29
35
  * @returns {JSX}
30
- */
31
- render() {
36
+ */;
37
+ _proto.render = function render() {
32
38
  return /*#__PURE__*/React.createElement(this.props.component, this.getProps());
33
- }
34
- }
39
+ };
40
+ return Grid;
41
+ }(Component);
35
42
  Grid.Item = GridItem;
36
43
  Grid.defaultProps = {
37
44
  className: '',
@@ -1,20 +1,21 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import Grid from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  describe('<Grid />', () => {
5
6
  it('should render without any further props', () => {
6
- const wrapper = shallow(/*#__PURE__*/React.createElement(Grid, null));
7
+ const wrapper = shallow(/*#__PURE__*/_jsx(Grid, {}));
7
8
  expect(wrapper).toMatchSnapshot();
8
9
  });
9
10
  it('should be able to render a custom tag', () => {
10
- const wrapper = shallow(/*#__PURE__*/React.createElement(Grid, {
11
+ const wrapper = shallow(/*#__PURE__*/_jsx(Grid, {
11
12
  component: "article"
12
13
  }));
13
14
  expect(wrapper).toMatchSnapshot();
14
15
  expect(wrapper.type()).toEqual('article');
15
16
  });
16
17
  it('should add custom classes on demand', () => {
17
- const wrapper = shallow(/*#__PURE__*/React.createElement(Grid, {
18
+ const wrapper = shallow(/*#__PURE__*/_jsx(Grid, {
18
19
  className: "custom-class-name"
19
20
  }));
20
21
  expect(wrapper).toMatchSnapshot();
@@ -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';
@@ -9,47 +10,41 @@ import connect from "./connector";
9
10
  /**
10
11
  * HtmlSanitizer component.
11
12
  */
12
- class HtmlSanitizer extends Component {
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ let HtmlSanitizer = /*#__PURE__*/function (_Component) {
13
15
  /**
14
16
  * @param {Object} props The component props.
15
17
  */
16
- constructor(props) {
17
- super(props);
18
+ function HtmlSanitizer(props) {
19
+ var _this;
20
+ _this = _Component.call(this, props) || this;
18
21
  /**
19
22
  * If the user tapped a link element, prevent the default behavior.
20
23
  * @param {Object} event The touchstart event.
21
24
  */
22
- this.handleTap = event => {
25
+ _this.handleClick = event => {
23
26
  const linkTag = event.target.closest('a');
24
- if (linkTag) {
25
- const {
26
- attributes: {
27
- href: {
28
- value: href = ''
29
- } = {},
30
- target: {
31
- value: target = ''
32
- } = {}
33
- } = {}
34
- } = linkTag;
35
- if (href) {
36
- event.preventDefault();
37
- if (this.props.settings.handleClick) {
38
- this.props.settings.handleClick(href, target);
39
- } else {
40
- this.props.navigate(href, target);
41
- }
42
- }
27
+ if (!linkTag) return;
28
+ const href = linkTag.getAttribute('href');
29
+ const target = linkTag.getAttribute('target') || '';
30
+ if (!href) return;
31
+ event.preventDefault();
32
+ if (_this.props.settings.handleClick) {
33
+ _this.props.settings.handleClick(href, target);
34
+ } else {
35
+ _this.props.navigate(href, target);
43
36
  }
44
37
  };
45
- this.htmlContainer = /*#__PURE__*/React.createRef();
38
+ _this.htmlContainer = /*#__PURE__*/React.createRef();
39
+ return _this;
46
40
  }
47
41
 
48
42
  /**
49
43
  * Registers the event handler for when the user taps inside the html content.
50
44
  */
51
- componentDidMount() {
52
- this.htmlContainer.current.addEventListener('click', this.handleTap, true);
45
+ _inheritsLoose(HtmlSanitizer, _Component);
46
+ var _proto = HtmlSanitizer.prototype;
47
+ _proto.componentDidMount = function componentDidMount() {
53
48
  embeddedMedia.add(this.htmlContainer.current);
54
49
  }
55
50
 
@@ -57,30 +52,29 @@ class HtmlSanitizer extends Component {
57
52
  * Only update if the HTML changed.
58
53
  * @param {Object} nextProps The next props for the component.
59
54
  * @return {boolean}
60
- */
61
- shouldComponentUpdate(nextProps) {
55
+ */;
56
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
62
57
  return nextProps.children !== this.props.children || nextProps.comfortCookiesAccepted !== this.props.comfortCookiesAccepted || nextProps.statisticsCookiesAccepted !== this.props.statisticsCookiesAccepted;
63
58
  }
64
59
 
65
60
  /**
66
61
  * Updates embedded media within the html container.
67
- */
68
- componentDidUpdate() {
62
+ */;
63
+ _proto.componentDidUpdate = function componentDidUpdate() {
69
64
  embeddedMedia.add(this.htmlContainer.current);
70
65
  }
71
66
 
72
67
  /**
73
68
  * Removes the event handler.
74
- */
75
- componentWillUnmount() {
76
- this.htmlContainer.current.removeEventListener('click', this.handleTap, true);
69
+ */;
70
+ _proto.componentWillUnmount = function componentWillUnmount() {
77
71
  embeddedMedia.remove(this.htmlContainer.current);
78
- }
72
+ };
79
73
  /**
80
74
  * Renders the component.
81
75
  * @returns {JSX}
82
76
  */
83
- render() {
77
+ _proto.render = function render() {
84
78
  const cookieConsentSettings = {
85
79
  comfortCookiesAccepted: this.props.comfortCookiesAccepted,
86
80
  statisticsCookiesAccepted: this.props.statisticsCookiesAccepted
@@ -91,16 +85,19 @@ class HtmlSanitizer extends Component {
91
85
  const {
92
86
  wrapper: Wrapper
93
87
  } = this.props;
94
- return /*#__PURE__*/React.createElement(Wrapper, {
95
- cookieConsentSettings: cookieConsentSettings
96
- }, /*#__PURE__*/React.createElement("div", {
97
- // eslint-disable-next-line react/no-danger
98
- dangerouslySetInnerHTML: innerHTML,
99
- ref: this.htmlContainer,
100
- className: classNames(this.props.className, 'common__html-sanitizer')
101
- }));
102
- }
103
- }
88
+ return /*#__PURE__*/_jsx(Wrapper, {
89
+ cookieConsentSettings: cookieConsentSettings,
90
+ children: /*#__PURE__*/_jsx("div", {
91
+ // eslint-disable-next-line react/no-danger
92
+ dangerouslySetInnerHTML: innerHTML,
93
+ ref: this.htmlContainer,
94
+ className: classNames(this.props.className, 'common__html-sanitizer'),
95
+ onClickCapture: this.handleClick
96
+ })
97
+ });
98
+ };
99
+ return HtmlSanitizer;
100
+ }(Component);
104
101
  HtmlSanitizer.defaultProps = {
105
102
  children: '',
106
103
  className: '',
@@ -1,9 +1,10 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ /** @jest-environment jsdom */
2
+
2
3
  import React from 'react';
3
4
  import { mount } from 'enzyme';
4
- import { JSDOM } from 'jsdom';
5
5
  import { embeddedMedia } from '@shopgate/pwa-common/collections';
6
6
  import HtmlSanitizer from "./index";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
7
8
  jest.mock("../EmbeddedMedia", () => ({
8
9
  children
9
10
  }) => children);
@@ -12,11 +13,13 @@ jest.mock("./connector", () => Cmp => Cmp);
12
13
  /**
13
14
  * @param {string} html HTML markup.
14
15
  * @param {Object} props Component props.
15
- * @returns {JSX}
16
+ * @returns {JSX.Element}
16
17
  */
17
- const createWrapper = (html, props = {}) => mount(/*#__PURE__*/React.createElement(HtmlSanitizer, _extends({
18
- navigate: () => {}
19
- }, props), html));
18
+ const createWrapper = (html, props = {}) => mount(/*#__PURE__*/_jsx(HtmlSanitizer, {
19
+ navigate: () => {},
20
+ ...props,
21
+ children: html
22
+ }));
20
23
  describe('<HtmlSanitizer />', () => {
21
24
  let embeddedMediaAddSpy;
22
25
  let embeddedMediaRemoveSpy;
@@ -125,47 +128,54 @@ describe('<HtmlSanitizer />', () => {
125
128
  mockedHandleClick.mockClear();
126
129
  });
127
130
  it('follows a link from a plain <a>', () => {
128
- const doc = new JSDOM('<!doctype html><html><body><div>/<div></body></html>').window.document;
131
+ // Create a real container element in the current document
132
+ const attachNode = document.createElement('div');
133
+ document.body.appendChild(attachNode);
129
134
  const html = '&lt;a id=&quot;link&quot; href=&quot;#follow-me-and-everything-is-alright&quot;&gt;Plain Link&lt;/a&gt;';
130
- const wrapper = mount(/*#__PURE__*/React.createElement(HtmlSanitizer, {
135
+ const wrapper = mount(/*#__PURE__*/_jsx(HtmlSanitizer, {
131
136
  decode: true,
132
137
  settings: {
133
138
  handleClick: mockedHandleClick
134
139
  },
135
- navigate: () => {}
136
- }, html), {
137
- attachTo: doc.getElementsByTagName('div')[0]
140
+ navigate: () => {},
141
+ children: html
142
+ }), {
143
+ attachTo: attachNode
138
144
  });
139
- const aTag = doc.getElementsByTagName('a')[0];
145
+ const aTag = attachNode.getElementsByTagName('a')[0];
140
146
  aTag.closest = () => aTag;
141
147
  const event = {
142
148
  target: aTag,
143
149
  preventDefault: () => {}
144
150
  };
145
- wrapper.instance().handleTap(event);
151
+ wrapper.instance().handleClick(event);
146
152
  expect(mockedHandleClick).toHaveBeenCalledTimes(1);
147
153
  expect(mockedHandleClick).toHaveBeenCalledWith('#follow-me-and-everything-is-alright', '');
154
+ wrapper.unmount();
155
+ attachNode.remove();
148
156
  });
149
157
  it('follows a link from a <a> with other HTML inside', () => {
150
- const doc = new JSDOM('<!doctype html><html><body><div>/<div></body></html>').window.document;
158
+ const attachNode = document.createElement('div');
159
+ document.body.appendChild(attachNode);
151
160
  const html = '&lt;a id=&quot;link&quot; target=&quot;_blank&quot; href=&quot;#I-ll-be-the-one-to-tuck-you-in-at-night&quot;&gt;&lt;span&gt;Span Link&lt;/span&gt;&lt;/a&gt;';
152
- const wrapper = mount(/*#__PURE__*/React.createElement(HtmlSanitizer, {
161
+ const wrapper = mount(/*#__PURE__*/_jsx(HtmlSanitizer, {
153
162
  decode: true,
154
163
  settings: {
155
164
  handleClick: mockedHandleClick
156
165
  },
157
- navigate: () => {}
158
- }, html), {
159
- attachTo: doc.getElementsByTagName('div')[0]
166
+ navigate: () => {},
167
+ children: html
168
+ }), {
169
+ attachTo: attachNode
160
170
  });
161
- const aTag = doc.getElementsByTagName('a')[0];
162
- const spanTag = doc.getElementsByTagName('span')[0];
171
+ const aTag = attachNode.getElementsByTagName('a')[0];
172
+ const spanTag = attachNode.getElementsByTagName('span')[0];
163
173
  spanTag.closest = () => aTag;
164
174
  const event = {
165
175
  target: spanTag,
166
176
  preventDefault: () => {}
167
177
  };
168
- wrapper.instance().handleTap(event);
178
+ wrapper.instance().handleClick(event);
169
179
  expect(mockedHandleClick).toHaveBeenCalledTimes(1);
170
180
  expect(mockedHandleClick).toHaveBeenCalledWith('#I-ll-be-the-one-to-tuck-you-in-at-night', '_blank');
171
181
  });
@@ -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 FormatDate = ({
11
12
  timestamp,
12
13
  format
13
- }) => /*#__PURE__*/React.createElement(Fragment, null, FormatDate.format({
14
- timestamp,
15
- format
16
- }));
14
+ }) => /*#__PURE__*/_jsx(_Fragment, {
15
+ children: FormatDate.format({
16
+ timestamp,
17
+ format
18
+ })
19
+ });
17
20
  FormatDate.format = ({
18
21
  timestamp,
19
22
  format
@@ -23,6 +26,10 @@ FormatDate.format = ({
23
26
  }
24
27
  return i18n.date(timestamp, format);
25
28
  };
29
+ FormatDate.propTypes = {
30
+ timestamp: PropTypes.number.isRequired,
31
+ format: PropTypes.string
32
+ };
26
33
  FormatDate.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('<FormatDate />', () => {
7
8
  const locales = {
@@ -18,20 +19,27 @@ describe('<FormatDate />', () => {
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__*/React.createElement(I18n.Provider, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
22
- className: "only-date"
23
- }, /*#__PURE__*/React.createElement(I18n.Date, {
24
- timestamp: timestamp,
25
- format: format
26
- })), /*#__PURE__*/React.createElement("span", {
27
- className: "text-with-date"
28
- }, /*#__PURE__*/React.createElement(I18n.Text, {
29
- string: "greeting"
30
- }, /*#__PURE__*/React.createElement(I18n.Date, {
31
- forKey: "date",
32
- timestamp: timestamp,
33
- format: format
34
- }))))));
22
+ renderedElement = mount(/*#__PURE__*/_jsx(I18n.Provider, {
23
+ children: /*#__PURE__*/_jsxs("div", {
24
+ children: [/*#__PURE__*/_jsx("span", {
25
+ className: "only-date",
26
+ children: /*#__PURE__*/_jsx(I18n.Date, {
27
+ timestamp: timestamp,
28
+ format: format
29
+ })
30
+ }), /*#__PURE__*/_jsx("span", {
31
+ className: "text-with-date",
32
+ children: /*#__PURE__*/_jsx(I18n.Text, {
33
+ string: "greeting",
34
+ children: /*#__PURE__*/_jsx(I18n.Date, {
35
+ forKey: "date",
36
+ timestamp: timestamp,
37
+ format: format
38
+ })
39
+ })
40
+ })]
41
+ })
42
+ }));
35
43
  expect(renderedElement).toMatchSnapshot();
36
44
  });
37
45
  it('should render formatted date', () => {
@@ -6,6 +6,7 @@ import { i18n } from '@shopgate/engage/core/helpers/i18n';
6
6
  * @param {Object} props The component props.
7
7
  * @returns {JSX}
8
8
  */
9
+ import { jsx as _jsx } from "react/jsx-runtime";
9
10
  const FormatNumber = ({
10
11
  className,
11
12
  number,
@@ -17,12 +18,13 @@ const FormatNumber = ({
17
18
  fractions
18
19
  });
19
20
  }
20
- return /*#__PURE__*/React.createElement("span", {
21
- className: className
22
- }, FormatNumber.format({
23
- number,
24
- fractions
25
- }));
21
+ return /*#__PURE__*/_jsx("span", {
22
+ className: className,
23
+ children: FormatNumber.format({
24
+ number,
25
+ fractions
26
+ })
27
+ });
26
28
  };
27
29
  FormatNumber.format = props => {
28
30
  if (!i18n.ready) {
@@ -3,11 +3,12 @@ import { mount } from 'enzyme';
3
3
  import { i18n } from '@shopgate/engage/core';
4
4
  import I18n from "../../index";
5
5
  import FormatNumber from "./index";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
6
7
  jest.unmock('@shopgate/engage/core/helpers/i18n');
7
8
  describe('<FormatNumber>', () => {
8
9
  describe('i18n not ready', () => {
9
10
  it('should return same number and className when i18n is not ready', () => {
10
- const component = mount(/*#__PURE__*/React.createElement(FormatNumber, {
11
+ const component = mount(/*#__PURE__*/_jsx(FormatNumber, {
11
12
  number: 1,
12
13
  fractions: 2,
13
14
  className: "some-class"
@@ -30,10 +31,14 @@ describe('<FormatNumber>', () => {
30
31
  * @param {number} fractions Decimal points.
31
32
  * @returns {Object}
32
33
  */
33
- const makeComponent = (number, fractions) => mount(/*#__PURE__*/React.createElement(I18n.Provider, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormatNumber, {
34
- number: number,
35
- fractions: fractions
36
- }))));
34
+ const makeComponent = (number, fractions) => mount(/*#__PURE__*/_jsx(I18n.Provider, {
35
+ children: /*#__PURE__*/_jsx("div", {
36
+ children: /*#__PURE__*/_jsx(FormatNumber, {
37
+ number: number,
38
+ fractions: fractions
39
+ })
40
+ })
41
+ }));
37
42
  pairs.forEach(([input, expexted, fractions]) => {
38
43
  it(`should format ${input} into ${expexted}`, () => {
39
44
  const component = makeComponent(input, fractions);
@@ -6,6 +6,7 @@ import { i18n } from '@shopgate/engage/core/helpers/i18n';
6
6
  * @param {Object} props The component props.
7
7
  * @returns {JSX}
8
8
  */
9
+ import { jsx as _jsx } from "react/jsx-runtime";
9
10
  const FormatPrice = props => {
10
11
  const {
11
12
  className,
@@ -14,9 +15,10 @@ const FormatPrice = props => {
14
15
  if (!className) {
15
16
  return FormatPrice.format(formatProps);
16
17
  }
17
- return /*#__PURE__*/React.createElement("span", {
18
- className: className
19
- }, FormatPrice.format(formatProps));
18
+ return /*#__PURE__*/_jsx("span", {
19
+ className: className,
20
+ children: FormatPrice.format(formatProps)
21
+ });
20
22
  };
21
23
  FormatPrice.format = ({
22
24
  price,