@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 throttle from 'lodash/throttle';
@@ -11,30 +12,31 @@ import { ITEMS_PER_LOAD } from "../../constants/DisplayOptions";
11
12
  * more items from it when the user reaches the end of the
12
13
  * (parent) scroll container.
13
14
  */
14
- class InfiniteContainer extends Component {
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ let InfiniteContainer = /*#__PURE__*/function (_Component) {
15
17
  /**
16
18
  * The component constructor.
17
19
  * @param {Object} props The component props.
18
20
  * @param {Object} context The component context.
19
21
  */
20
- constructor(props, context) {
21
- super(props, context);
22
- this.domElement = null;
23
- this.domScrollContainer = null;
22
+ function InfiniteContainer(props, context) {
23
+ var _this;
24
+ _this = _Component.call(this, props, context) || this;
25
+ _this.domScrollContainer = null;
24
26
  /**
25
27
  * 10ms was chosen because, on the one hand, it prevents the scroll event from flooding but,
26
28
  * on the other hand, it does not hinder users that scroll quickly from reloading next chunk.
27
29
  */
28
- this.handleLoadingProxy = throttle(() => {
30
+ _this.handleLoadingProxy = throttle(() => {
29
31
  if (props.enablePromiseBasedLoading) {
30
- this.handleLoadingPromise();
32
+ _this.handleLoadingPromise();
31
33
  } else {
32
- this.handleLoading();
34
+ _this.handleLoading();
33
35
  }
34
36
  }, 10);
35
37
 
36
38
  // A flag to prevent concurrent loading requests.
37
- this.isLoading = false;
39
+ _this.isLoading = false;
38
40
 
39
41
  // Determine the initial offset of items.
40
42
  const {
@@ -48,13 +50,14 @@ class InfiniteContainer extends Component {
48
50
  offset = 0
49
51
  } = {}
50
52
  } = context || {};
51
- this.state = {
53
+ _this.state = {
52
54
  itemCount: items.length,
53
55
  offset: [offset, currentOffset],
54
56
  // A state flag that will be true as long as we await more items.
55
57
  // The loading indicator will be shown accordingly.
56
58
  awaitingItems: true
57
59
  };
60
+ return _this;
58
61
  }
59
62
 
60
63
  /**
@@ -62,7 +65,9 @@ class InfiniteContainer extends Component {
62
65
  * parent scroll container if available.
63
66
  * After that it calls for the initial data to load.
64
67
  */
65
- componentDidMount() {
68
+ _inheritsLoose(InfiniteContainer, _Component);
69
+ var _proto = InfiniteContainer.prototype;
70
+ _proto.componentDidMount = function componentDidMount() {
66
71
  const {
67
72
  current
68
73
  } = this.props.containerRef;
@@ -82,8 +87,8 @@ class InfiniteContainer extends Component {
82
87
  /**
83
88
  * Checks if the component received new items or already received all items.
84
89
  * @param {Object} nextProps The next props.
85
- */
86
- UNSAFE_componentWillReceiveProps(nextProps) {
90
+ */;
91
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
87
92
  /**
88
93
  * Downstream logic to process the props. It's wrapped into a separate function, since it might
89
94
  * be executed after the state was updated to avoid race conditions.
@@ -128,15 +133,15 @@ class InfiniteContainer extends Component {
128
133
  * @param {Object} nextProps The next component props.
129
134
  * @param {Object} nextState The next component state.
130
135
  * @returns {boolean}
131
- */
132
- shouldComponentUpdate(nextProps, nextState) {
136
+ */;
137
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
133
138
  return !isEqual(this.props.containerRef, nextProps.containerRef) || !isEqual(this.props.columns, nextProps.columns) || !isEqual(this.props.items, nextProps.items) || !isEqual(this.state, nextState);
134
139
  }
135
140
 
136
141
  /**
137
142
  * Reset the loading flag.
138
- */
139
- componentDidUpdate() {
143
+ */;
144
+ _proto.componentDidUpdate = function componentDidUpdate() {
140
145
  // When promise based implementation is active, `isLoading` is reset when response comes in.
141
146
  // In the legacy implementation this happens after the fetched items reached the component and
142
147
  // is not necessary here anymore.
@@ -147,8 +152,8 @@ class InfiniteContainer extends Component {
147
152
 
148
153
  /**
149
154
  * When the component will unmount it unbinds all previously bound event listeners.
150
- */
151
- componentWillUnmount() {
155
+ */;
156
+ _proto.componentWillUnmount = function componentWillUnmount() {
152
157
  router.update(this.context.id, {
153
158
  offset: this.state.offset[0]
154
159
  }, false);
@@ -157,8 +162,8 @@ class InfiniteContainer extends Component {
157
162
 
158
163
  /**
159
164
  * Adds scroll event listeners to the scroll container if available.
160
- */
161
- bindEvents() {
165
+ */;
166
+ _proto.bindEvents = function bindEvents() {
162
167
  if (this.domScrollContainer) {
163
168
  this.domScrollContainer.addEventListener('scroll', this.handleLoadingProxy);
164
169
  }
@@ -167,8 +172,8 @@ class InfiniteContainer extends Component {
167
172
  /**
168
173
  * Removes scroll event listeners from the scroll container.
169
174
  * @param {Node} container A reference to an old scroll container.
170
- */
171
- unbindEvents(container) {
175
+ */;
176
+ _proto.unbindEvents = function unbindEvents(container) {
172
177
  if (container) {
173
178
  container.removeEventListener('scroll', this.handleLoadingProxy);
174
179
  } else if (this.domScrollContainer) {
@@ -180,8 +185,8 @@ class InfiniteContainer extends Component {
180
185
  * Tests if there are more items to be received via items prop.
181
186
  * @param {Object} [props] The current or next component props.
182
187
  * @returns {boolean}
183
- */
184
- needsToReceiveItems(props = this.props) {
188
+ */;
189
+ _proto.needsToReceiveItems = function needsToReceiveItems(props = this.props) {
185
190
  return props.totalItems === null || props.items.length < props.totalItems;
186
191
  }
187
192
 
@@ -189,8 +194,8 @@ class InfiniteContainer extends Component {
189
194
  * Tests if the total amount of items has been received via totalItems prop.
190
195
  * @param {Object} nextProps The next component props.
191
196
  * @returns {boolean}
192
- */
193
- receivedTotalItems(nextProps) {
197
+ */;
198
+ _proto.receivedTotalItems = function receivedTotalItems(nextProps) {
194
199
  return nextProps.totalItems !== null && nextProps.totalItems !== this.props.totalItems;
195
200
  }
196
201
 
@@ -198,8 +203,8 @@ class InfiniteContainer extends Component {
198
203
  * Tests if all items have been received and are visible based on current offset.
199
204
  * @param {Object} [props] The current or next component props.
200
205
  * @returns {boolean}
201
- */
202
- allItemsAreRendered(props = this.props) {
206
+ */;
207
+ _proto.allItemsAreRendered = function allItemsAreRendered(props = this.props) {
203
208
  const {
204
209
  totalItems,
205
210
  items
@@ -217,8 +222,8 @@ class InfiniteContainer extends Component {
217
222
  /**
218
223
  * Increases the current offset by limit (from props).
219
224
  * @returns {Object}
220
- */
221
- increaseOffset() {
225
+ */;
226
+ _proto.increaseOffset = function increaseOffset() {
222
227
  const [start, length] = this.state.offset;
223
228
  let newOffset = start + length;
224
229
 
@@ -245,8 +250,8 @@ class InfiniteContainer extends Component {
245
250
  * Resets the state.
246
251
  * @param {Function} callback A callback which is invoked after the state was updated.
247
252
  * This is necessary to avoid race conditions with downstream code.
248
- */
249
- resetComponent(callback) {
253
+ */;
254
+ _proto.resetComponent = function resetComponent(callback) {
250
255
  this.setState({
251
256
  offset: [0, this.props.limit],
252
257
  awaitingItems: true,
@@ -260,8 +265,8 @@ class InfiniteContainer extends Component {
260
265
 
261
266
  /**
262
267
  * Stops the lazy loading processes
263
- */
264
- stopLazyLoading() {
268
+ */;
269
+ _proto.stopLazyLoading = function stopLazyLoading() {
265
270
  this.setState({
266
271
  awaitingItems: false
267
272
  });
@@ -272,8 +277,8 @@ class InfiniteContainer extends Component {
272
277
  * Verifies if all items are loaded and shown, then set final state and unbind events.
273
278
  * @param {Object} [props] The current or next component props.
274
279
  * @returns {boolean} Returns true if the component has reached the final state.
275
- */
276
- verifyAllDone(props = this.props) {
280
+ */;
281
+ _proto.verifyAllDone = function verifyAllDone(props = this.props) {
277
282
  if (this.allItemsAreRendered(props)) {
278
283
  this.stopLazyLoading();
279
284
  return true;
@@ -285,8 +290,8 @@ class InfiniteContainer extends Component {
285
290
  * Tests if the current scroll position is near the bottom
286
291
  * of the scroll container.
287
292
  * @returns {boolean}
288
- */
289
- validateScrollPosition() {
293
+ */;
294
+ _proto.validateScrollPosition = function validateScrollPosition() {
290
295
  if (!this.domScrollContainer) {
291
296
  return true;
292
297
  }
@@ -319,8 +324,8 @@ class InfiniteContainer extends Component {
319
324
  * Handles incrementing of render offset and the request of new items if necessary.
320
325
  * @param {boolean} [force] If set to true, proceed independently of scroll validation.
321
326
  * @param {Object} [props] The current or next component props.
322
- */
323
- handleLoading(force = false, props = this.props) {
327
+ */;
328
+ _proto.handleLoading = function handleLoading(force = false, props = this.props) {
324
329
  // Do not load if there is an update in progress.
325
330
  if (this.isLoading) {
326
331
  return;
@@ -362,8 +367,8 @@ class InfiniteContainer extends Component {
362
367
  * for offset handling.
363
368
  * @param {boolean} [force] If set to true, proceed independently of scroll validation.
364
369
  * @param {Object} [props] The current or next component props.
365
- */
366
- async handleLoadingPromise(force = false, props = this.props) {
370
+ */;
371
+ _proto.handleLoadingPromise = async function handleLoadingPromise(force = false, props = this.props) {
367
372
  if (this.isLoading) {
368
373
  return;
369
374
  }
@@ -395,8 +400,8 @@ class InfiniteContainer extends Component {
395
400
  /**
396
401
  * Renders the component.
397
402
  * @returns {JSX}
398
- */
399
- render() {
403
+ */;
404
+ _proto.render = function render() {
400
405
  const {
401
406
  wrapper,
402
407
  items,
@@ -416,14 +421,15 @@ class InfiniteContainer extends Component {
416
421
  const content = typeof wrapper === 'function' ? wrapper({
417
422
  children
418
423
  }) : (/*#__PURE__*/React.createElement(wrapper, {}, children));
419
- return /*#__PURE__*/React.createElement("div", {
420
- ref: elementRef => {
421
- this.domElement = elementRef;
422
- },
423
- className: "common__infinite-container"
424
- }, /*#__PURE__*/React.createElement("div", null, content), awaitingItems && loadingIndicator);
425
- }
426
- }
424
+ return /*#__PURE__*/_jsxs("div", {
425
+ className: "common__infinite-container",
426
+ children: [/*#__PURE__*/_jsx("div", {
427
+ children: content
428
+ }), awaitingItems && loadingIndicator]
429
+ });
430
+ };
431
+ return InfiniteContainer;
432
+ }(Component);
427
433
  InfiniteContainer.contextType = RouteContext;
428
434
  InfiniteContainer.defaultProps = {
429
435
  columns: 2,
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { shallow, mount } from 'enzyme';
4
4
  import { ITEMS_PER_LOAD } from "../../constants/DisplayOptions";
5
5
  import InfiniteContainer from "./index";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
6
7
  global.console.error = jest.fn();
7
8
  const context = {
8
9
  state: {}
@@ -23,7 +24,9 @@ describe('<InfiniteContainer />', () => {
23
24
  * @param {Object} props The component props.
24
25
  */
25
26
  const renderComponent = props => {
26
- renderedElement = shallow(/*#__PURE__*/React.createElement(InfiniteContainer, props), {
27
+ renderedElement = shallow(/*#__PURE__*/_jsx(InfiniteContainer, {
28
+ ...props
29
+ }), {
27
30
  context
28
31
  });
29
32
  renderedInstance = renderedElement.instance();
@@ -44,9 +47,9 @@ describe('<InfiniteContainer />', () => {
44
47
  };
45
48
  beforeEach(() => {
46
49
  mockLoader = jest.fn();
47
- mockIterator = jest.fn(data => /*#__PURE__*/React.createElement("li", {
48
- key: data.id
49
- }, data.title));
50
+ mockIterator = jest.fn(data => /*#__PURE__*/_jsx("li", {
51
+ children: data.title
52
+ }, data.id));
50
53
  });
51
54
  describe('Given the component was mounted to the DOM', () => {
52
55
  beforeEach(() => {
@@ -182,7 +185,9 @@ describe('<InfiniteContainer />', () => {
182
185
  totalItems: mockData.length,
183
186
  requestHash: 'default'
184
187
  };
185
- const wrapper = mount(/*#__PURE__*/React.createElement(InfiniteContainer, props));
188
+ const wrapper = mount(/*#__PURE__*/_jsx(InfiniteContainer, {
189
+ ...props
190
+ }));
186
191
  const instance = wrapper.instance();
187
192
  instance.componentDidMount();
188
193
  instance.domScrollContainer = document.createElement('div');
@@ -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,