@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 React, { Component } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import padStart from 'lodash/padStart';
@@ -11,6 +12,7 @@ import I18n from "../I18n";
11
12
  * @param {number} seconds The remaining seconds.
12
13
  * @return {Object} String and params for the i18n component
13
14
  */
15
+ import { jsx as _jsx } from "react/jsx-runtime";
14
16
  export const getFormattedTimeString = (days, hours, minutes, seconds) => {
15
17
  const formattedHours = padStart(hours, 2, '0');
16
18
  const formattedMinutes = padStart(minutes, 2, '0');
@@ -44,27 +46,31 @@ const createFormattedTime = timeSpanInput => {
44
46
  /**
45
47
  * The Countdown timer component.
46
48
  */
47
- class CountdownTimer extends Component {
49
+ let CountdownTimer = /*#__PURE__*/function (_Component) {
48
50
  /**
49
51
  * The component constructor.
50
52
  * @param {Object} props The component properties.
51
53
  */
52
- constructor(props) {
53
- super(props);
54
- this.intervalHandle = null;
55
- this.remainingTime = this.getRemainingTime();
56
- this.expired = this.remainingTime <= 0;
54
+ function CountdownTimer(props) {
55
+ var _this;
56
+ _this = _Component.call(this, props) || this;
57
+ _this.intervalHandle = null;
58
+ _this.remainingTime = _this.getRemainingTime();
59
+ _this.expired = _this.remainingTime <= 0;
57
60
 
58
61
  // Calculate the initial formatted time string.
59
- this.state = {
60
- formattedTime: createFormattedTime(this.remainingTime)
62
+ _this.state = {
63
+ formattedTime: createFormattedTime(_this.remainingTime)
61
64
  };
65
+ return _this;
62
66
  }
63
67
 
64
68
  /**
65
69
  * Installs a new interval to update the timer if the component did mount.
66
70
  */
67
- componentDidMount() {
71
+ _inheritsLoose(CountdownTimer, _Component);
72
+ var _proto = CountdownTimer.prototype;
73
+ _proto.componentDidMount = function componentDidMount() {
68
74
  // Install the interval.
69
75
  this.intervalHandle = setInterval(() => {
70
76
  /**
@@ -78,8 +84,8 @@ class CountdownTimer extends Component {
78
84
 
79
85
  /**
80
86
  * Clears the timer interval.
81
- */
82
- componentWillUnmount() {
87
+ */;
88
+ _proto.componentWillUnmount = function componentWillUnmount() {
83
89
  if (this.intervalHandle) {
84
90
  clearInterval(this.intervalHandle);
85
91
  }
@@ -87,15 +93,15 @@ class CountdownTimer extends Component {
87
93
 
88
94
  /**
89
95
  * @returns {number} The remaining time until the timer runs out.
90
- */
91
- getRemainingTime() {
96
+ */;
97
+ _proto.getRemainingTime = function getRemainingTime() {
92
98
  return Math.ceil(this.props.timeout - Date.now() / 1000);
93
99
  }
94
100
 
95
101
  /**
96
102
  * Updates the formatted time. Will not cause a re-rendering of the component.
97
- */
98
- updateTimer() {
103
+ */;
104
+ _proto.updateTimer = function updateTimer() {
99
105
  // Calculate the remaining time until the timer is expired. Also ignore negative durations.
100
106
  const deltaTime = Math.max(0, this.remainingTime);
101
107
  const isExpired = deltaTime <= 0;
@@ -119,15 +125,16 @@ class CountdownTimer extends Component {
119
125
  /**
120
126
  * Renders the element.
121
127
  * @return {JSX.Element}
122
- */
123
- render() {
124
- return /*#__PURE__*/React.createElement(I18n.Text, {
128
+ */;
129
+ _proto.render = function render() {
130
+ return /*#__PURE__*/_jsx(I18n.Text, {
125
131
  string: this.state.formattedTime.string,
126
132
  params: this.state.formattedTime.params,
127
133
  className: `${this.props.className} common__countdown-timer`
128
134
  });
129
- }
130
- }
135
+ };
136
+ return CountdownTimer;
137
+ }(Component);
131
138
  CountdownTimer.defaultProps = {
132
139
  className: '',
133
140
  onExpire: null
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
+ import { act } from 'react-dom/test-utils';
3
4
  import CountdownTimer, { getFormattedTimeString } from "./index";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
4
6
  describe('<CountdownTimer>', () => {
5
7
  jest.useFakeTimers();
6
8
 
@@ -15,7 +17,7 @@ describe('<CountdownTimer>', () => {
15
17
  */
16
18
  const createTimerElement = (remainingDays, remainingHours, remainingMinutes, remainingSeconds, callback) => {
17
19
  const timeout = Math.floor(Date.now() / 1000) + remainingDays * 86400 + remainingHours * 3600 + remainingMinutes * 60 + remainingSeconds;
18
- const wrapper = shallow(/*#__PURE__*/React.createElement(CountdownTimer, {
20
+ const wrapper = shallow(/*#__PURE__*/_jsx(CountdownTimer, {
19
21
  timeout: timeout,
20
22
  onExpire: callback
21
23
  }));
@@ -36,24 +38,23 @@ describe('<CountdownTimer>', () => {
36
38
  */
37
39
  const performFormatCheck = (remainingDays, remainingHours, remainingMinutes, remainingSeconds) => {
38
40
  jest.clearAllTimers();
39
- setInterval.mock.calls = [];
41
+ const intervalSpy = jest.spyOn(global, 'setInterval');
40
42
  const wrapper = createTimerElement(remainingDays, remainingHours, remainingMinutes, remainingSeconds, null);
41
- const expectedTimeFormat = getFormattedTimeString(remainingDays, remainingHours, remainingMinutes, remainingSeconds - 1 // Expect the decremented timeout.
42
- );
43
-
44
- // We cannot perform a snapshot match here because the timestamp changes for each call.
45
- expect(setInterval.mock.calls.length).toBe(1);
46
- jest.runTimersToTime(1000);
43
+ const expectedTimeFormat = getFormattedTimeString(remainingDays, remainingHours, remainingMinutes, remainingSeconds - 1);
44
+ expect(intervalSpy).toHaveBeenCalledTimes(1);
45
+ act(() => {
46
+ jest.advanceTimersByTime(1000);
47
+ });
47
48
  wrapper.update();
48
49
  const {
49
50
  params,
50
51
  string
51
52
  } = wrapper.props();
52
- const renderedTimeFormat = {
53
+ expect({
53
54
  params,
54
55
  string
55
- };
56
- expect(renderedTimeFormat).toEqual(expectedTimeFormat);
56
+ }).toEqual(expectedTimeFormat);
57
+ intervalSpy.mockRestore();
57
58
  };
58
59
  it('should render the correct time for < 24h', () => performFormatCheck(0, 0, 0, 5));
59
60
  it('should render the correct time for 24h - 48h', () => performFormatCheck(1, 12, 6, 5));
@@ -62,46 +63,44 @@ describe('<CountdownTimer>', () => {
62
63
  jest.clearAllTimers();
63
64
  const wrapper = createTimerElement(-1, -2, -3, -5, null);
64
65
  const expectedTimeFormat = getFormattedTimeString(0, 0, 0, 0);
65
- jest.runTimersToTime(1000);
66
+ act(() => {
67
+ jest.advanceTimersByTime(1000);
68
+ });
66
69
  const {
67
70
  params,
68
71
  string
69
72
  } = wrapper.props();
70
- const renderedTimeFormat = {
73
+ expect({
71
74
  params,
72
75
  string
73
- };
74
- expect(renderedTimeFormat).toEqual(expectedTimeFormat);
76
+ }).toEqual(expectedTimeFormat);
75
77
  });
76
78
  it('should stop at 00:00:00 when the timer expires', () => {
77
79
  const wrapper = createTimerElement(0, 0, 0, 1, null);
78
80
  const expectedTimeFormat = getFormattedTimeString(0, 0, 0, 0);
79
- let renderedTimeFormat;
80
-
81
- // Run down to 00:00:00.
82
- jest.runTimersToTime(1000);
81
+ act(() => {
82
+ jest.advanceTimersByTime(1000);
83
+ });
83
84
  wrapper.update();
84
85
  let {
85
86
  params,
86
87
  string
87
88
  } = wrapper.props();
88
- renderedTimeFormat = {
89
+ expect({
89
90
  params,
90
91
  string
91
- };
92
- expect(renderedTimeFormat).toEqual(expectedTimeFormat);
93
-
94
- // Advance time a bit further and make sure the timer stays at 00:00:00.
95
- jest.runTimersToTime(1000);
92
+ }).toEqual(expectedTimeFormat);
93
+ act(() => {
94
+ jest.advanceTimersByTime(1000);
95
+ });
96
96
  ({
97
97
  params,
98
98
  string
99
99
  } = wrapper.props());
100
- renderedTimeFormat = {
100
+ expect({
101
101
  params,
102
102
  string
103
- };
104
- expect(renderedTimeFormat).toEqual(expectedTimeFormat);
103
+ }).toEqual(expectedTimeFormat);
105
104
  });
106
105
  it('should invoke the callback when the timer expires', () => {
107
106
  let timesCallbackInvoked = 0;
@@ -112,17 +111,17 @@ describe('<CountdownTimer>', () => {
112
111
  timesCallbackInvoked += 1;
113
112
  };
114
113
  createTimerElement(0, 0, 0, 2, callback);
115
-
116
- // The timer is not expired yet. Make sure the callback is not invoked.
117
- jest.runTimersToTime(1000);
114
+ act(() => {
115
+ jest.advanceTimersByTime(1000);
116
+ });
118
117
  expect(timesCallbackInvoked).toBe(0);
119
-
120
- // The timer should expire by now.
121
- jest.runTimersToTime(1000);
118
+ act(() => {
119
+ jest.advanceTimersByTime(1000);
120
+ });
122
121
  expect(timesCallbackInvoked).toBe(1);
123
-
124
- // Run it again and make sure it won't be called twice.
125
- jest.runTimersToTime(1000);
122
+ act(() => {
123
+ jest.advanceTimersByTime(1000);
124
+ });
126
125
  expect(timesCallbackInvoked).toBe(1);
127
126
  });
128
127
  it('should not invoke the callback when the timeout is already expired.', () => {
@@ -134,7 +133,9 @@ describe('<CountdownTimer>', () => {
134
133
  timesCallbackInvoked += 1;
135
134
  };
136
135
  createTimerElement(0, 0, 0, 0, callback);
137
- jest.runTimersToTime(1000);
136
+ act(() => {
137
+ jest.advanceTimersByTime(1000);
138
+ });
138
139
  expect(timesCallbackInvoked).toBe(0);
139
140
  });
140
141
  });
@@ -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';
@@ -6,34 +7,39 @@ import styles from "./style";
6
7
  /**
7
8
  * Drawer component.
8
9
  */
9
- class Drawer extends Component {
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ let Drawer = /*#__PURE__*/function (_Component) {
10
12
  /**
11
13
  * Initializes the Drawer component.
12
14
  * @param {Object} props The components props.
13
15
  */
14
- constructor(props) {
15
- super(props);
16
+ function Drawer(props) {
17
+ var _this;
18
+ _this = _Component.call(this, props) || this;
16
19
  /**
17
20
  * Syncs the internal active state when an animation ends.
18
21
  */
19
- this.handleAnimationEnd = () => {
20
- this.setState({
21
- active: this.props.isOpen
22
+ _this.handleAnimationEnd = () => {
23
+ _this.setState({
24
+ active: _this.props.isOpen
22
25
  });
23
- if (!this.props.isOpen) {
24
- this.props.onDidClose();
26
+ if (!_this.props.isOpen) {
27
+ _this.props.onDidClose();
25
28
  } else {
26
- this.props.onDidOpen();
29
+ _this.props.onDidOpen();
27
30
  }
28
31
  };
29
- this.sheetRef = /*#__PURE__*/React.createRef();
30
- this.state = {
32
+ _this.sheetRef = /*#__PURE__*/React.createRef();
33
+ _this.state = {
31
34
  active: props.isOpen
32
35
  };
36
+ return _this;
33
37
  }
34
38
 
35
39
  /** inheritdoc */
36
- componentDidMount() {
40
+ _inheritsLoose(Drawer, _Component);
41
+ var _proto = Drawer.prototype;
42
+ _proto.componentDidMount = function componentDidMount() {
37
43
  if (this.props.isOpen) {
38
44
  if (this.sheetRef.current) {
39
45
  this.sheetRef.current.focus();
@@ -44,8 +50,8 @@ class Drawer extends Component {
44
50
  /**
45
51
  * Update state when isOpen changes.
46
52
  * @param {Object} nextProps The next component props.
47
- */
48
- UNSAFE_componentWillReceiveProps(nextProps) {
53
+ */;
54
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
49
55
  if (this.props.isOpen !== nextProps.isOpen) {
50
56
  if (nextProps.isOpen) {
51
57
  if (typeof nextProps.onOpen === 'function') {
@@ -63,19 +69,19 @@ class Drawer extends Component {
63
69
  /**
64
70
  * Set focus for a11y when sheet opens
65
71
  * @param {Object} prevProps The previous component props.
66
- */
67
- componentDidUpdate(prevProps) {
72
+ */;
73
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
68
74
  if (!prevProps.isOpen && this.props.isOpen) {
69
75
  if (this.sheetRef.current) {
70
76
  this.sheetRef.current.focus();
71
77
  }
72
78
  }
73
- }
79
+ };
74
80
  /**
75
81
  * Renders the component.
76
82
  * @returns {JSX}
77
83
  */
78
- render() {
84
+ _proto.render = function render() {
79
85
  const {
80
86
  className,
81
87
  children,
@@ -96,7 +102,7 @@ class Drawer extends Component {
96
102
  if (typeof animation.duration === 'number') {
97
103
  style.animationDuration = `${animation.duration}ms`;
98
104
  }
99
- return active ? /*#__PURE__*/React.createElement("div", {
105
+ return active ? /*#__PURE__*/_jsx("div", {
100
106
  ref: this.sheetRef,
101
107
  className: combinedClassName,
102
108
  style: style,
@@ -111,10 +117,12 @@ class Drawer extends Component {
111
117
  },
112
118
  role: "dialog",
113
119
  "aria-modal": true,
114
- tabIndex: -1
115
- }, children) : null;
116
- }
117
- }
120
+ tabIndex: -1,
121
+ children: children
122
+ }) : null;
123
+ };
124
+ return Drawer;
125
+ }(Component);
118
126
  /**
119
127
  * The component prop types.
120
128
  * @type {Object}
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { mount, shallow } from 'enzyme';
3
3
  import Drawer from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  jest.mock('@shopgate/engage/a11y/components');
5
6
  describe('<Drawer />', () => {
6
7
  const onOpen = jest.fn();
@@ -11,11 +12,11 @@ describe('<Drawer />', () => {
11
12
  jest.clearAllMocks();
12
13
  });
13
14
  it('should render', () => {
14
- const wrapper = shallow(/*#__PURE__*/React.createElement(Drawer, null));
15
+ const wrapper = shallow(/*#__PURE__*/_jsx(Drawer, {}));
15
16
  expect(wrapper).toMatchSnapshot();
16
17
  });
17
18
  it('should execute callback when drawer is opened', () => {
18
- const wrapper = mount(/*#__PURE__*/React.createElement(Drawer, {
19
+ const wrapper = mount(/*#__PURE__*/_jsx(Drawer, {
19
20
  onOpen: onOpen
20
21
  }));
21
22
  wrapper.setProps({
@@ -24,7 +25,7 @@ describe('<Drawer />', () => {
24
25
  expect(onOpen).toBeCalled();
25
26
  });
26
27
  it('should execute callback when drawer is closed', () => {
27
- const wrapper = mount(/*#__PURE__*/React.createElement(Drawer, {
28
+ const wrapper = mount(/*#__PURE__*/_jsx(Drawer, {
28
29
  isOpen: true,
29
30
  onClose: onClose
30
31
  }));
@@ -34,7 +35,7 @@ describe('<Drawer />', () => {
34
35
  expect(onClose).toBeCalled();
35
36
  });
36
37
  it('should add custom classes', () => {
37
- const wrapper = mount(/*#__PURE__*/React.createElement(Drawer, {
38
+ const wrapper = mount(/*#__PURE__*/_jsx(Drawer, {
38
39
  className: "custom-class-name",
39
40
  isOpen: true
40
41
  }));
@@ -42,7 +43,7 @@ describe('<Drawer />', () => {
42
43
  expect(wrapper.hasClass('custom-class-name')).toEqual(true);
43
44
  });
44
45
  it('should execute callback when drawer open animation did end', () => {
45
- const wrapper = mount(/*#__PURE__*/React.createElement(Drawer, {
46
+ const wrapper = mount(/*#__PURE__*/_jsx(Drawer, {
46
47
  className: "custom-class-name",
47
48
  isOpen: false,
48
49
  onOpen: onOpen,
@@ -58,7 +59,7 @@ describe('<Drawer />', () => {
58
59
  expect(onDidOpen).toBeCalled();
59
60
  });
60
61
  it('should execute callback when drawer close animation did end', () => {
61
- const wrapper = mount(/*#__PURE__*/React.createElement(Drawer, {
62
+ const wrapper = mount(/*#__PURE__*/_jsx(Drawer, {
62
63
  className: "custom-class-name",
63
64
  isOpen: true,
64
65
  onClose: onClose,
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import React, { Component } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import Transition from "../Transition";
@@ -9,23 +9,28 @@ import transitions from "./transitions";
9
9
  * This component slides it's child content up or down based on it's isOpen property.
10
10
  * @returns {JSX}
11
11
  */
12
- class Dropdown extends Component {
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let Dropdown = /*#__PURE__*/function (_Component) {
13
14
  /**
14
15
  * Constructor
15
16
  * @param {Object} props Props of the Component
16
17
  */
17
- constructor(props) {
18
- super(props);
19
- this.state = {
18
+ function Dropdown(props) {
19
+ var _this;
20
+ _this = _Component.call(this, props) || this;
21
+ _this.state = {
20
22
  initialRender: true
21
23
  };
24
+ return _this;
22
25
  }
23
26
 
24
27
  /**
25
28
  * Update the initialRender state if the isOpen state changes from false to true
26
29
  * @param {Object} nextProps The new props
27
30
  */
28
- UNSAFE_componentWillReceiveProps(nextProps) {
31
+ _inheritsLoose(Dropdown, _Component);
32
+ var _proto = Dropdown.prototype;
33
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
29
34
  if (this.props.isOpen === false && nextProps.isOpen === true) {
30
35
  this.setState({
31
36
  initialRender: false
@@ -37,33 +42,37 @@ class Dropdown extends Component {
37
42
  * Only update the component if isOpen changed
38
43
  * @param {Object} nextProps The new props
39
44
  * @returns {boolean}
40
- */
41
- shouldComponentUpdate(nextProps) {
45
+ */;
46
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
42
47
  return this.props.isOpen !== nextProps.isOpen;
43
48
  }
44
49
 
45
50
  /**
46
51
  * Renders the component.
47
52
  * @returns {JSX}
48
- */
49
- render() {
53
+ */;
54
+ _proto.render = function render() {
50
55
  let transitionProps;
51
56
  if (this.props.isOpen) {
52
57
  transitionProps = this.state.initialRender ? transitions.initialOpen : transitions.open;
53
58
  } else {
54
59
  transitionProps = this.state.initialRender ? transitions.initialClose : transitions.close;
55
60
  }
56
- return /*#__PURE__*/React.createElement(Transition, _extends({}, transitionProps, {
61
+ return /*#__PURE__*/_jsx(Transition, {
62
+ ...transitionProps,
57
63
  onComplete: this.props.onComplete,
58
64
  onStart: this.props.onStart,
59
65
  duration: this.props.duration,
60
- easing: this.props.easing
61
- }), /*#__PURE__*/React.createElement("div", {
62
- className: `${styles} ${this.props.className} common__dropdown`,
63
- "aria-hidden": !this.props.isOpen
64
- }, this.props.children));
65
- }
66
- }
66
+ easing: this.props.easing,
67
+ children: /*#__PURE__*/_jsx("div", {
68
+ className: `${styles} ${this.props.className} common__dropdown`,
69
+ "aria-hidden": !this.props.isOpen,
70
+ children: this.props.children
71
+ })
72
+ });
73
+ };
74
+ return Dropdown;
75
+ }(Component);
67
76
  Dropdown.defaultProps = {
68
77
  className: '',
69
78
  children: null,
@@ -7,11 +7,13 @@ import Dotdotdot from 'react-dotdotdot';
7
7
  * @param {Object} props The component props.
8
8
  * @returns {JSX.Element}
9
9
  */
10
- const Ellipsis = props => /*#__PURE__*/React.createElement(Dotdotdot, {
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const Ellipsis = props => /*#__PURE__*/_jsx(Dotdotdot, {
11
12
  clamp: props.rows,
12
13
  className: `${props.className} common__ellipsis`,
13
- useNativeClamp: true
14
- }, props.children);
14
+ useNativeClamp: true,
15
+ children: props.children
16
+ });
15
17
  Ellipsis.defaultProps = {
16
18
  className: '',
17
19
  rows: 3
@@ -1,13 +1,15 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import Ellipsis from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  const clamp = 3;
5
6
  const text = 'Some very long text that should be cut off by this ellipsis component.';
6
7
  describe('<Ellipsis />', () => {
7
8
  it('should render', () => {
8
- const wrapper = shallow(/*#__PURE__*/React.createElement(Ellipsis, {
9
- rows: clamp
10
- }, text));
9
+ const wrapper = shallow(/*#__PURE__*/_jsx(Ellipsis, {
10
+ rows: clamp,
11
+ children: text
12
+ }));
11
13
  expect(wrapper).toMatchSnapshot();
12
14
  });
13
15
  });
@@ -7,6 +7,7 @@ import { embeddedMedia } from '@shopgate/pwa-common/collections';
7
7
  * EmbeddedMedia component. Handles loading of media related scripts e.g. the Vimeo Player.
8
8
  * @returns {JSX}
9
9
  */
10
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
10
11
  const EmbeddedMedia = ({
11
12
  children,
12
13
  cookieConsentSettings
@@ -45,12 +46,14 @@ const EmbeddedMedia = ({
45
46
  src: provider.remoteScriptUrl,
46
47
  type: 'text/javascript'
47
48
  }));
48
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Helmet, {
49
- script: scripts
50
- // Helmet doesn't support `onload` in script objects so we have to hack in our own
51
- ,
52
- onChangeClientState: (newState, addedTags) => updateProviderScripts(addedTags)
53
- }), children);
49
+ return /*#__PURE__*/_jsxs(_Fragment, {
50
+ children: [/*#__PURE__*/_jsx(Helmet, {
51
+ script: scripts
52
+ // Helmet doesn't support `onload` in script objects so we have to hack in our own
53
+ ,
54
+ onChangeClientState: (newState, addedTags) => updateProviderScripts(addedTags)
55
+ }), children]
56
+ });
54
57
  };
55
58
  EmbeddedMedia.defaultProps = {
56
59
  cookieConsentSettings: {
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import { embeddedMedia } from '@shopgate/pwa-common/collections';
4
4
  import EmbeddedMedia from "./index";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
5
6
  jest.mock('@shopgate/pwa-common/collections', () => ({
6
7
  embeddedMedia: {
7
8
  getHasPendingProviders: jest.fn(),
@@ -21,12 +22,20 @@ describe('<EmbeddedMedia />', () => {
21
22
  });
22
23
  it('should return children', () => {
23
24
  embeddedMedia.getHasPendingProviders.mockReturnValueOnce(false);
24
- const wrapper = shallow(/*#__PURE__*/React.createElement(EmbeddedMedia, null, /*#__PURE__*/React.createElement("div", null, "Children")));
25
+ const wrapper = shallow(/*#__PURE__*/_jsx(EmbeddedMedia, {
26
+ children: /*#__PURE__*/_jsx("div", {
27
+ children: "Children"
28
+ })
29
+ }));
25
30
  expect(wrapper.html()).toEqual('<div>Children</div>');
26
31
  });
27
32
  it.skip('should render Helmet with a script', () => {
28
33
  embeddedMedia.getHasPendingProviders.mockReturnValueOnce(true);
29
- const wrapper = shallow(/*#__PURE__*/React.createElement(EmbeddedMedia, null, /*#__PURE__*/React.createElement("div", null, "Content with embedded media (youtube, vimeo, etc)")));
34
+ const wrapper = shallow(/*#__PURE__*/_jsx(EmbeddedMedia, {
35
+ children: /*#__PURE__*/_jsx("div", {
36
+ children: "Content with embedded media (youtube, vimeo, etc)"
37
+ })
38
+ }));
30
39
  const helmetProps = wrapper.find('HelmetWrapper').props();
31
40
  expect(helmetProps).toEqual({
32
41
  defer: true,