@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.
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 +2 -1
  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 +16 -12
  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 +8 -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 +5 -4
  93. package/components/Widgets/components/WidgetGrid/index.js +27 -19
  94. package/components/Widgets/components/WidgetGrid/spec.js +4 -3
  95. package/components/Widgets/index.js +33 -26
  96. package/components/Widgets/spec.js +12 -13
  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 -5
  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,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import React from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { logger } from '@shopgate/pwa-core';
@@ -9,37 +9,42 @@ import SimpleInput from "./SimpleInput";
9
9
  * This component has no styling and should not be used directly.
10
10
  * You may want to use an appropriate form field component from the template instead.
11
11
  */
12
- class MultiLineInput extends SimpleInput {
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let MultiLineInput = /*#__PURE__*/function (_SimpleInput) {
13
14
  /**
14
15
  * Creates a new input component.
15
16
  * @param {Object} props The component properties.
16
17
  */
17
- constructor(props) {
18
- super(props);
18
+ function MultiLineInput(props) {
19
+ var _this;
20
+ _this = _SimpleInput.call(this, props) || this;
19
21
  /**
20
22
  * Sets an initial height of the multiline HTMLElement.
21
23
  */
22
- this.setBaseHeight = () => {
23
- if (this.baseHeight !== null) {
24
+ _this.setBaseHeight = () => {
25
+ if (_this.baseHeight !== null) {
24
26
  return;
25
27
  }
26
- this.baseHeight = this.ref.clientHeight;
28
+ _this.baseHeight = _this.ref.clientHeight;
27
29
  };
28
- this.baseHeight = null;
30
+ _this.baseHeight = null;
29
31
  // First render must be empty.
30
- const sanitizedValue = this.props.onSanitize('');
31
- this.state = {
32
+ const sanitizedValue = _this.props.onSanitize('');
33
+ _this.state = {
32
34
  value: sanitizedValue,
33
- isValid: this.props.onValidate(sanitizedValue, true),
35
+ isValid: _this.props.onValidate(sanitizedValue, true),
34
36
  isFocused: false
35
37
  };
38
+ return _this;
36
39
  }
37
40
 
38
41
  /**
39
42
  * Additional function to make avoid .setState use in componentDidMount
40
43
  * usage violation.
41
44
  */
42
- doComponentDidMount() {
45
+ _inheritsLoose(MultiLineInput, _SimpleInput);
46
+ var _proto = MultiLineInput.prototype;
47
+ _proto.doComponentDidMount = function doComponentDidMount() {
43
48
  const sanitizedValue = this.props.onSanitize(this.props.value || '');
44
49
  this.props.onChange(sanitizedValue);
45
50
  this.setState({
@@ -52,37 +57,37 @@ class MultiLineInput extends SimpleInput {
52
57
  /**
53
58
  * Set real value and trigger second render.
54
59
  * Initially trigger onChange() to set the initial value.
55
- */
56
- componentDidMount() {
60
+ */;
61
+ _proto.componentDidMount = function componentDidMount() {
57
62
  // No super, would have to sanitize anyway.
58
63
  this.doComponentDidMount();
59
64
  }
60
65
 
61
66
  /**
62
67
  * Adjusts the element height.
63
- */
64
- componentDidUpdate() {
68
+ */;
69
+ _proto.componentDidUpdate = function componentDidUpdate() {
65
70
  if (!(this.ref instanceof HTMLElement)) {
66
71
  logger.error('Ref is not an HTMLElement');
67
72
  return;
68
73
  }
69
74
  this.ref.style.height = `${this.baseHeight}px`;
70
75
  this.ref.style.height = `${this.ref.scrollHeight}px`;
71
- }
76
+ };
72
77
  /**
73
78
  * Handles reference passing to callback and assignation.
74
79
  * @param {HTMLElement} ref The element
75
80
  */
76
- handleRef(ref) {
77
- super.handleRef(ref);
81
+ _proto.handleRef = function handleRef(ref) {
82
+ _SimpleInput.prototype.handleRef.call(this, ref);
78
83
  this.setBaseHeight();
79
84
  }
80
85
 
81
86
  /**
82
87
  * Renders the component.
83
88
  * @returns {JSX}
84
- */
85
- render() {
89
+ */;
90
+ _proto.render = function render() {
86
91
  const {
87
92
  className,
88
93
  password,
@@ -94,7 +99,7 @@ class MultiLineInput extends SimpleInput {
94
99
  const {
95
100
  value
96
101
  } = this.state;
97
- return /*#__PURE__*/React.createElement("textarea", _extends({
102
+ return /*#__PURE__*/_jsx("textarea", {
98
103
  id: this.props.id,
99
104
  name: this.props.name,
100
105
  ref: ref => this.handleRef(ref),
@@ -105,8 +110,10 @@ class MultiLineInput extends SimpleInput {
105
110
  onFocus: this.handleFocus,
106
111
  onBlur: this.handleBlur,
107
112
  required: required,
108
- disabled: disabled
109
- }, attributes));
110
- }
111
- }
113
+ disabled: disabled,
114
+ ...attributes
115
+ });
116
+ };
117
+ return MultiLineInput;
118
+ }(SimpleInput);
112
119
  export default MultiLineInput;
@@ -1,4 +1,5 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
3
  import React, { Component } from 'react';
3
4
  import PropTypes from 'prop-types';
4
5
  import classNames from 'classnames';
@@ -8,81 +9,86 @@ import classNames from 'classnames';
8
9
  * This component has no styling and should not be used directly.
9
10
  * You may want to use an appropriate form field component from the template instead.
10
11
  */
11
- class SimpleInput extends Component {
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let SimpleInput = /*#__PURE__*/function (_Component) {
12
14
  /**
13
15
  * Creates a new input component.
14
16
  * @param {Object} props The component properties.
15
17
  */
16
- constructor(props) {
17
- super(props);
18
+ function SimpleInput(props) {
19
+ var _this;
20
+ _this = _Component.call(this, props) || this;
18
21
  /**
19
22
  * Internal focus event handler.
20
23
  * @param {Object} e The event object.
21
24
  */
22
- this.handleFocus = e => {
23
- this.setState({
25
+ _this.handleFocus = e => {
26
+ _this.setState({
24
27
  isFocused: true
25
28
  });
26
- this.props.onFocusChange(true, e);
29
+ _this.props.onFocusChange(true, e);
27
30
  };
28
31
  /**
29
32
  * Internal blur event handler.
30
33
  * @param {Object} e The event object.
31
34
  */
32
- this.handleBlur = e => {
35
+ _this.handleBlur = e => {
33
36
  const newState = {
34
37
  isFocused: false
35
38
  };
36
- if (this.props.validateOnBlur) {
39
+ if (_this.props.validateOnBlur) {
37
40
  // Validate the value.
38
- newState.isValid = this.props.onValidate(this.value, false);
41
+ newState.isValid = _this.props.onValidate(_this.value, false);
39
42
  }
40
- this.setState(newState);
41
- this.props.onFocusChange(false, e);
43
+ _this.setState(newState);
44
+ _this.props.onFocusChange(false, e);
42
45
  };
43
46
  /**
44
47
  * Internal change event handler.
45
48
  * @param {Object} event The event object.
46
49
  */
47
- this.handleChange = event => {
50
+ _this.handleChange = event => {
48
51
  const {
49
52
  value
50
- } = this.state;
53
+ } = _this.state;
51
54
  const {
52
55
  type
53
- } = this.props;
56
+ } = _this.props;
54
57
 
55
58
  // Special handling to prevent invalid characters within number inputs on Firefox / Safari
56
59
  if (type === 'number' && event?.target?.validity?.badInput) {
57
60
  event.preventDefault();
58
61
  event.stopPropagation();
59
- this.ref.value = value;
62
+ _this.ref.value = value;
60
63
  return;
61
64
  }
62
65
 
63
66
  // Sanitize the input value.
64
- const sanitizedValue = this.props.onSanitize(event.target.value || '');
67
+ const sanitizedValue = _this.props.onSanitize(event.target.value || '');
65
68
 
66
69
  // Update the state.
67
- this.updateValue(sanitizedValue, !this.props.isControlled);
70
+ _this.updateValue(sanitizedValue, !_this.props.isControlled);
68
71
 
69
72
  // Emit an event.
70
- this.props.onChange(sanitizedValue, event);
73
+ _this.props.onChange(sanitizedValue, event);
71
74
  };
72
- this.ref = null;
75
+ _this.ref = null;
73
76
  // Initially sanitize the value.
74
- const _sanitizedValue = this.props.onSanitize(this.props.value || '');
75
- this.state = {
77
+ const _sanitizedValue = _this.props.onSanitize(_this.props.value || '');
78
+ _this.state = {
76
79
  value: _sanitizedValue,
77
- isValid: this.props.onValidate(_sanitizedValue, true),
80
+ isValid: _this.props.onValidate(_sanitizedValue, true),
78
81
  isFocused: false
79
82
  };
83
+ return _this;
80
84
  }
81
85
 
82
86
  /**
83
87
  * Initially trigger onChange() to set the initial value.
84
88
  */
85
- componentDidMount() {
89
+ _inheritsLoose(SimpleInput, _Component);
90
+ var _proto = SimpleInput.prototype;
91
+ _proto.componentDidMount = function componentDidMount() {
86
92
  const sanitizedValue = this.props.onSanitize(this.props.value || '');
87
93
  this.props.onChange(sanitizedValue);
88
94
  }
@@ -90,8 +96,8 @@ class SimpleInput extends Component {
90
96
  /**
91
97
  * Updates the value of the input field if the props has been modified.
92
98
  * @param {Object} nextProps The new properties.
93
- */
94
- UNSAFE_componentWillReceiveProps(nextProps) {
99
+ */;
100
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
95
101
  /**
96
102
  * Only set the state value if the value prop has been changed,
97
103
  * otherwise use the current input state.
@@ -102,31 +108,15 @@ class SimpleInput extends Component {
102
108
  }
103
109
  }
104
110
 
111
+ /* eslint-disable react/no-unused-class-component-methods */
105
112
  /**
106
113
  * @returns {boolean} Whether the current value of the input field is valid.
107
- */
108
- get isValid() {
109
- return this.state.isValid;
110
- }
111
-
112
- /**
113
- * @return {boolean} Whether the input field is focused.
114
- */
115
- get isFocused() {
116
- return this.state.isFocused;
117
- }
118
-
119
- /**
120
- * @returns {string} The current value of the input field.
121
- */
122
- get value() {
123
- return this.state.value;
124
- }
114
+ */;
125
115
  /**
126
116
  * Handles reference passing to callback and assignation.
127
117
  * @param {HTMLElement} ref The element
128
118
  */
129
- handleRef(ref) {
119
+ _proto.handleRef = function handleRef(ref) {
130
120
  this.ref = ref;
131
121
  this.props.setRef(ref);
132
122
  }
@@ -135,8 +125,8 @@ class SimpleInput extends Component {
135
125
  * Updates and validates the internal state value of the input field.
136
126
  * @param {string} newValue The new value.
137
127
  * @param {boolean} setOwnState Specifies whether or not to update the internal state.
138
- */
139
- updateValue(newValue, setOwnState) {
128
+ */;
129
+ _proto.updateValue = function updateValue(newValue, setOwnState) {
140
130
  const newState = {
141
131
  value: newValue
142
132
  };
@@ -154,8 +144,8 @@ class SimpleInput extends Component {
154
144
  /**
155
145
  * Renders the component.
156
146
  * @returns {JSX.Element}
157
- */
158
- render() {
147
+ */;
148
+ _proto.render = function render() {
159
149
  const {
160
150
  attributes,
161
151
  className,
@@ -174,7 +164,7 @@ class SimpleInput extends Component {
174
164
  const autoComplete = this.props.autoComplete ? 'on' : 'off';
175
165
  const autoCorrect = this.props.autoCorrect ? 'on' : 'off';
176
166
  const InputComponent = this.props.inputComponent;
177
- return /*#__PURE__*/React.createElement(InputComponent, _extends({
167
+ return /*#__PURE__*/_jsx(InputComponent, {
178
168
  id: id,
179
169
  name: name,
180
170
  ref: ref => this.handleRef(ref),
@@ -197,10 +187,36 @@ class SimpleInput extends Component {
197
187
  autoCorrect: autoCorrect,
198
188
  autoComplete: autoComplete,
199
189
  maxLength: maxLength,
200
- required: required
201
- }, attributes));
202
- }
203
- }
190
+ required: required,
191
+ ...attributes
192
+ });
193
+ };
194
+ return _createClass(SimpleInput, [{
195
+ key: "isValid",
196
+ get: function () {
197
+ return this.state.isValid;
198
+ }
199
+
200
+ /**
201
+ * @return {boolean} Whether the input field is focused.
202
+ */
203
+ }, {
204
+ key: "isFocused",
205
+ get: function () {
206
+ return this.state.isFocused;
207
+ }
208
+ /* eslint-enable react/no-unused-class-component-methods */
209
+
210
+ /**
211
+ * @returns {string} The current value of the input field.
212
+ */
213
+ }, {
214
+ key: "value",
215
+ get: function () {
216
+ return this.state.value;
217
+ }
218
+ }]);
219
+ }(Component);
204
220
  SimpleInput.defaultProps = {
205
221
  attributes: null,
206
222
  autoComplete: false,
@@ -2,18 +2,6 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import SimpleInput from "./components/SimpleInput";
4
4
  import MultiLineInput from "./components/MultiLineInput";
5
- import DateInput from "./components/DateInput";
6
-
7
- /**
8
- * @returns {boolean}
9
- */
10
- const isDateSupported = () => {
11
- const input = document.createElement('input');
12
- const value = 'a';
13
- input.setAttribute('type', 'date');
14
- input.setAttribute('value', value);
15
- return input.value !== value;
16
- };
17
5
 
18
6
  /**
19
7
  * Input component.
@@ -21,14 +9,16 @@ const isDateSupported = () => {
21
9
  * @param {Object} props Props
22
10
  * @return {JSX}
23
11
  */
12
+ import { jsx as _jsx } from "react/jsx-runtime";
24
13
  const Factory = props => {
25
- if (props.type === 'date' && !isDateSupported()) {
26
- return /*#__PURE__*/React.createElement(DateInput, props);
27
- }
28
14
  if (props.multiLine) {
29
- return /*#__PURE__*/React.createElement(MultiLineInput, props);
15
+ return /*#__PURE__*/_jsx(MultiLineInput, {
16
+ ...props
17
+ });
30
18
  }
31
- return /*#__PURE__*/React.createElement(SimpleInput, props);
19
+ return /*#__PURE__*/_jsx(SimpleInput, {
20
+ ...props
21
+ });
32
22
  };
33
23
  Factory.defaultProps = {
34
24
  multiLine: false,
@@ -1,21 +1,22 @@
1
1
  import React from 'react';
2
2
  import { mount, shallow } from 'enzyme';
3
3
  import Input from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  describe('<Input />', () => {
5
6
  it('should render a simple input field', () => {
6
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, null));
7
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {}));
7
8
  expect(wrapper).toMatchSnapshot();
8
9
  expect(wrapper.find('input').length).toBe(1);
9
10
  });
10
11
  it('should render the input as password', () => {
11
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
12
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
12
13
  password: true
13
14
  }));
14
15
  expect(wrapper).toMatchSnapshot();
15
16
  expect(wrapper.find('input[type="password"]').length).toBe(1);
16
17
  });
17
18
  it('should render the input with a default value', () => {
18
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
19
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
19
20
  value: "FooBar"
20
21
  }));
21
22
  expect(wrapper).toMatchSnapshot();
@@ -23,7 +24,7 @@ describe('<Input />', () => {
23
24
  });
24
25
  it('should trigger the onChange callback', () => {
25
26
  const onChangeMock = jest.fn();
26
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
27
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
27
28
  onChange: onChangeMock
28
29
  }));
29
30
  wrapper.find('input').simulate('change', {
@@ -35,7 +36,7 @@ describe('<Input />', () => {
35
36
  expect(wrapper.find('input').props().value).toEqual('a');
36
37
  });
37
38
  it('should receive the correct value while typing', () => {
38
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, null));
39
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {}));
39
40
  const input = wrapper.find('input');
40
41
  input.simulate('change', {
41
42
  target: {
@@ -46,7 +47,7 @@ describe('<Input />', () => {
46
47
  expect(wrapper.find('SimpleInput').instance().value).toBe('foobar');
47
48
  });
48
49
  it('should sanitize the input', () => {
49
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
50
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
50
51
  onSanitize: value => value.toUpperCase()
51
52
  }));
52
53
  const input = wrapper.find('input');
@@ -59,7 +60,7 @@ describe('<Input />', () => {
59
60
  expect(wrapper.find('SimpleInput').instance().value).toBe('FOOBAR');
60
61
  });
61
62
  it('should validate the input', () => {
62
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
63
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
63
64
  onValidate: () => false
64
65
  }));
65
66
  expect(wrapper).toMatchSnapshot();
@@ -67,7 +68,7 @@ describe('<Input />', () => {
67
68
  });
68
69
  it('should focus the input', () => {
69
70
  const onFocusMock = jest.fn();
70
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
71
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
71
72
  onFocusChange: onFocusMock
72
73
  }));
73
74
  const input = wrapper.find('input');
@@ -79,7 +80,7 @@ describe('<Input />', () => {
79
80
  expect(wrapper.find('SimpleInput').instance().isFocused).toBe(false);
80
81
  });
81
82
  it('should change the value on user input', () => {
82
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
83
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
83
84
  value: "My initial value"
84
85
  }));
85
86
  expect(wrapper).toMatchSnapshot();
@@ -96,7 +97,7 @@ describe('<Input />', () => {
96
97
  const multiLineValue = `dfsdsdf
97
98
  sdfdsff
98
99
  dsf`;
99
- const wrapper = mount(/*#__PURE__*/React.createElement(Input, {
100
+ const wrapper = mount(/*#__PURE__*/_jsx(Input, {
100
101
  value: "",
101
102
  multiLine: true
102
103
  }));
@@ -108,7 +109,7 @@ describe('<Input />', () => {
108
109
  expect(wrapper.find('textarea').getDOMNode().innerHTML).toEqual(multiLineValue);
109
110
  });
110
111
  it('should render additional html attributes', () => {
111
- const wrapper = shallow(/*#__PURE__*/React.createElement(Input, {
112
+ const wrapper = shallow(/*#__PURE__*/_jsx(Input, {
112
113
  type: "date",
113
114
  attributes: {
114
115
  min: '1970-01-01',
@@ -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 Event from '@shopgate/pwa-core/classes/Event';
@@ -6,10 +7,11 @@ import { EVENT_KEYBOARD_WILL_CHANGE } from '@shopgate/pwa-core/constants/AppEven
6
7
  /**
7
8
  * Keyboard state consumer.
8
9
  */
9
- class KeyboardConsumer extends PureComponent {
10
- constructor(...args) {
11
- super(...args);
12
- this.state = {
10
+ let KeyboardConsumer = /*#__PURE__*/function (_PureComponent) {
11
+ function KeyboardConsumer(...args) {
12
+ var _this;
13
+ _this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
14
+ _this.state = {
13
15
  open: false,
14
16
  overlap: 0,
15
17
  duration: 0
@@ -17,36 +19,40 @@ class KeyboardConsumer extends PureComponent {
17
19
  /**
18
20
  * Stores current keyboard state.
19
21
  */
20
- this.handleKeyboardChange = ({
22
+ _this.handleKeyboardChange = ({
21
23
  open,
22
24
  overlap,
23
25
  duration
24
26
  }) => {
25
- this.setState({
27
+ _this.setState({
26
28
  open,
27
29
  overlap,
28
30
  duration
29
31
  });
30
32
  };
33
+ return _this;
31
34
  }
35
+ _inheritsLoose(KeyboardConsumer, _PureComponent);
36
+ var _proto = KeyboardConsumer.prototype;
32
37
  /**
33
38
  * Listen to keyboard changes as soon as the component mounts.
34
39
  */
35
- componentDidMount() {
40
+ _proto.componentDidMount = function componentDidMount() {
36
41
  Event.addCallback(EVENT_KEYBOARD_WILL_CHANGE, this.handleKeyboardChange);
37
42
  }
38
43
 
39
44
  /**
40
45
  * Remove listener when component will unmount.
41
- */
42
- componentWillUnmount() {
46
+ */;
47
+ _proto.componentWillUnmount = function componentWillUnmount() {
43
48
  Event.removeCallback(EVENT_KEYBOARD_WILL_CHANGE, this.handleKeyboardChange);
44
- }
49
+ };
45
50
  /**
46
51
  * @returns {JSX}
47
52
  */
48
- render() {
53
+ _proto.render = function render() {
49
54
  return this.props.children(this.state);
50
- }
51
- }
55
+ };
56
+ return KeyboardConsumer;
57
+ }(PureComponent);
52
58
  export default KeyboardConsumer;
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import "core-js/modules/es.string.replace.js";
2
3
  import React, { Component } from 'react';
3
4
  import PropTypes from 'prop-types';
@@ -10,34 +11,36 @@ import styles from "./style";
10
11
  * @param {Object} props Props for the component.
11
12
  * @returns {JSX}
12
13
  */
13
- class Link extends Component {
14
- constructor(...args) {
15
- super(...args);
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ let Link = /*#__PURE__*/function (_Component) {
16
+ function Link(...args) {
17
+ var _this;
18
+ _this = _Component.call.apply(_Component, [this].concat(args)) || this;
16
19
  /**
17
20
  * Opens the link.
18
21
  * @param {Event} e An event object.
19
22
  */
20
- this.handleOpenLink = e => {
23
+ _this.handleOpenLink = e => {
21
24
  e.preventDefault();
22
- if (this.props.disabled) {
25
+ if (_this.props.disabled) {
23
26
  return;
24
27
  }
25
28
  const params = {
26
- pathname: this.props.href,
29
+ pathname: _this.props.href,
27
30
  state: {
28
- ...(this.props.state || {}),
29
- ...(this.props.target ? {
30
- target: this.props.target
31
+ ...(_this.props.state || {}),
32
+ ...(_this.props.target ? {
33
+ target: _this.props.target
31
34
  } : {})
32
35
  }
33
36
  };
34
37
 
35
38
  // setTimeout prevents double click while VoiceOver is active
36
39
  setTimeout(() => {
37
- if (this.props.replace) {
38
- this.props.historyReplace(params);
40
+ if (_this.props.replace) {
41
+ _this.props.historyReplace(params);
39
42
  } else {
40
- this.props.historyPush(params);
43
+ _this.props.historyPush(params);
41
44
  }
42
45
  }, 0);
43
46
  };
@@ -45,17 +48,20 @@ class Link extends Component {
45
48
  * key listener for screen readers
46
49
  * @param {Object} event The event object
47
50
  */
48
- this.handleKeyDown = event => {
51
+ _this.handleKeyDown = event => {
49
52
  if (event.key === 'Enter' || event.key === ' ') {
50
- this.handleOpenLink(event);
53
+ _this.handleOpenLink(event);
51
54
  }
52
55
  };
56
+ return _this;
53
57
  }
58
+ _inheritsLoose(Link, _Component);
59
+ var _proto = Link.prototype;
54
60
  /**
55
61
  * Renders the component.
56
62
  * @returns {JSX.Element}
57
63
  */
58
- render() {
64
+ _proto.render = function render() {
59
65
  const {
60
66
  tag,
61
67
  className,
@@ -74,7 +80,7 @@ class Link extends Component {
74
80
  */
75
81
  Tag = 'span';
76
82
  }
77
- return /*#__PURE__*/React.createElement(Tag, {
83
+ return /*#__PURE__*/_jsx(Tag, {
78
84
  className: `${styles} ${className} common__link`,
79
85
  onClick: this.handleOpenLink,
80
86
  onKeyDown: this.handleKeyDown,
@@ -83,10 +89,12 @@ class Link extends Component {
83
89
  "aria-label": ariaLabel,
84
90
  tabIndex: tabIndex,
85
91
  "aria-hidden": ariaHidden,
86
- href: href && Tag === 'a' ? href : null
87
- }, children);
88
- }
89
- }
92
+ href: href && Tag === 'a' ? href : null,
93
+ children: children
94
+ });
95
+ };
96
+ return Link;
97
+ }(Component);
90
98
  Link.defaultProps = {
91
99
  'aria-hidden': null,
92
100
  'aria-label': null,