@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 classNames from 'classnames';
@@ -6,62 +7,70 @@ import styles from "./style";
6
7
  /**
7
8
  * The picker modal.
8
9
  */
9
- class PickerModal extends Component {
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ let PickerModal = /*#__PURE__*/function (_Component) {
10
12
  /**
11
13
  * The constructor.
12
14
  * @param {Object} props The props.
13
15
  */
14
- constructor(props) {
15
- super(props);
16
+ function PickerModal(props) {
17
+ var _this;
18
+ _this = _Component.call(this, props) || this;
16
19
  /**
17
20
  * Closes the modal after the closing animations have finished.
18
21
  */
19
- this.closeModal = () => {
20
- this.setState({
22
+ _this.closeModal = () => {
23
+ _this.setState({
21
24
  active: false
22
25
  });
23
- clearTimeout(this.timeout);
24
- this.timeout = setTimeout(this.props.onClose, styles.duration);
26
+ clearTimeout(_this.timeout);
27
+ _this.timeout = setTimeout(_this.props.onClose, styles.duration);
25
28
  };
26
- this.timeout = null;
27
- this.state = {
29
+ _this.timeout = null;
30
+ _this.state = {
28
31
  active: true
29
32
  };
33
+ return _this;
30
34
  }
31
35
 
32
36
  /**
33
37
  * Update state when isOpen changes.
34
38
  * @param {Object} nextProps The next component props.
35
39
  */
36
- UNSAFE_componentWillReceiveProps(nextProps) {
40
+ _inheritsLoose(PickerModal, _Component);
41
+ var _proto = PickerModal.prototype;
42
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
37
43
  if (this.props.isOpen !== nextProps.isOpen) {
38
44
  this.setState({
39
45
  active: nextProps.isOpen
40
46
  });
41
47
  }
42
- }
48
+ };
43
49
  /**
44
50
  * Render all the things!
45
51
  * @returns {JSX} The picker modal with the picker list inside.
46
52
  */
47
- render() {
53
+ _proto.render = function render() {
48
54
  const backgroundClassName = classNames(styles.background.base, {
49
55
  [styles.background.inactive]: !this.state.active
50
56
  });
51
57
  const containerClassName = classNames(styles.container.base, {
52
58
  [styles.container.inactive]: !this.state.active
53
59
  });
54
- return this.props.isOpen ? /*#__PURE__*/React.createElement("div", {
55
- className: `${styles.wrapper} common__picker__modal`
56
- }, /*#__PURE__*/React.createElement("div", {
57
- "aria-hidden": true,
58
- className: backgroundClassName,
59
- onClick: this.closeModal
60
- }), /*#__PURE__*/React.createElement("div", {
61
- className: containerClassName
62
- }, /*#__PURE__*/React.cloneElement(this.props.children, {
63
- onClose: this.closeModal
64
- }))) : null;
65
- }
66
- }
60
+ return this.props.isOpen ? /*#__PURE__*/_jsxs("div", {
61
+ className: `${styles.wrapper} common__picker__modal`,
62
+ children: [/*#__PURE__*/_jsx("div", {
63
+ "aria-hidden": true,
64
+ className: backgroundClassName,
65
+ onClick: this.closeModal
66
+ }), /*#__PURE__*/_jsx("div", {
67
+ className: containerClassName,
68
+ children: /*#__PURE__*/React.cloneElement(this.props.children, {
69
+ onClose: this.closeModal
70
+ })
71
+ })]
72
+ }) : null;
73
+ };
74
+ return PickerModal;
75
+ }(Component);
67
76
  export default PickerModal;
@@ -1,3 +1,5 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
3
  import React, { Component } from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { ConnectedReactPortal } from '@shopgate/engage/components';
@@ -13,6 +15,7 @@ import PickerList from "./components/List";
13
15
  * @returns {Object} An object representation of the item.
14
16
  * @deprecated Use Picker from engage instead
15
17
  */
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
19
  const normalizeItem = item => {
17
20
  if (item !== null && typeof item !== 'undefined') {
18
21
  const itemDefaults = {
@@ -44,69 +47,73 @@ const findItemIndexByValue = (items, value) => items.map(normalizeItem).findInde
44
47
  * @deprecated Will be remove in Engage v7.0.0.
45
48
  * Please use `import { Picker } from '@shopgate/engage/components'` instead.
46
49
  */
47
- class Picker extends Component {
50
+ let Picker = /*#__PURE__*/function (_Component) {
48
51
  /**
49
52
  * The constructor.
50
53
  * @param {Object} props - The component props.
51
54
  */
52
- constructor(props) {
53
- super(props);
55
+ function Picker(props) {
56
+ var _this;
57
+ _this = _Component.call(this, props) || this;
54
58
  /**
55
59
  * Triggers the onChange callback if the selected value has changed.
56
60
  * @param {Object} nextValue - The value the user picked.
57
61
  */
58
- this.triggerChangeCallback = nextValue => {
59
- const nextSelectedIndex = findItemIndexByValue(this.props.items, nextValue);
60
- if (nextSelectedIndex > -1 && this.state.selectedIndex !== nextSelectedIndex) {
61
- this.props.onChange(nextValue);
62
+ _this.triggerChangeCallback = nextValue => {
63
+ const nextSelectedIndex = findItemIndexByValue(_this.props.items, nextValue);
64
+ if (nextSelectedIndex > -1 && _this.state.selectedIndex !== nextSelectedIndex) {
65
+ _this.props.onChange(nextValue);
62
66
  }
63
- this.props.onSelect(nextValue);
67
+ _this.props.onSelect(nextValue);
64
68
  };
65
69
  /**
66
70
  * Triggers the onChange callback if the selected value has changed.
67
71
  * @param {Object} nextOpenState - The value the user picked.
68
72
  */
69
- this.triggerCloseCallback = nextOpenState => {
70
- if (this.state.isOpen && !nextOpenState) {
71
- this.props.onClose();
73
+ _this.triggerCloseCallback = nextOpenState => {
74
+ if (_this.state.isOpen && !nextOpenState) {
75
+ _this.props.onClose();
72
76
  }
73
77
  };
74
78
  /**
75
79
  * Gets called when a new item is selected
76
80
  * @param {string} value - The selected value.
77
81
  */
78
- this.handleItemSelect = value => {
79
- this.triggerChangeCallback(value);
80
- this.setState({
81
- selectedIndex: findItemIndexByValue(this.props.items, value)
82
+ _this.handleItemSelect = value => {
83
+ _this.triggerChangeCallback(value);
84
+ _this.setState({
85
+ selectedIndex: findItemIndexByValue(_this.props.items, value)
82
86
  });
83
87
  };
84
88
  /**
85
89
  * Sets or toggles the open state of the component.
86
90
  * @param {boolean} [open] New open state.
87
91
  */
88
- this.toggleOpenState = open => {
89
- this.setState(({
92
+ _this.toggleOpenState = open => {
93
+ _this.setState(({
90
94
  isOpen
91
95
  }) => {
92
96
  const nextIsOpen = typeof open === 'boolean' ? open : !isOpen;
93
- this.triggerCloseCallback(nextIsOpen);
97
+ _this.triggerCloseCallback(nextIsOpen);
94
98
  return {
95
99
  isOpen: nextIsOpen
96
100
  };
97
101
  });
98
102
  };
99
- this.state = {
103
+ _this.state = {
100
104
  selectedIndex: findItemIndexByValue(props.items, props.value),
101
105
  isOpen: props.isOpen
102
106
  };
107
+ return _this;
103
108
  }
104
109
 
105
110
  /**
106
111
  * Updates the selected item when the value prop changes.
107
112
  * @param {Object} nextProps - The next props.
108
113
  */
109
- UNSAFE_componentWillReceiveProps(nextProps) {
114
+ _inheritsLoose(Picker, _Component);
115
+ var _proto = Picker.prototype;
116
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
110
117
  // Only update if a value is present and also changed.
111
118
  if (!this.selectedItem || nextProps.value !== this.selectedItem.value) {
112
119
  this.setState({
@@ -122,15 +129,12 @@ class Picker extends Component {
122
129
 
123
130
  /**
124
131
  * Getter for the selected item.
125
- */
126
- get selectedItem() {
127
- return normalizeItem(this.props.items[this.state.selectedIndex]);
128
- }
132
+ */;
129
133
  /**
130
134
  * Renders the component.
131
135
  * @returns {JSX}
132
136
  */
133
- render() {
137
+ _proto.render = function render() {
134
138
  const hasSelection = !!this.selectedItem;
135
139
  const buttonValue = hasSelection ? this.selectedItem.label : '';
136
140
  const buttonLabel = hasSelection ? this.props.label : this.props.placeholder;
@@ -153,18 +157,25 @@ class Picker extends Component {
153
157
  selectedIndex: this.state.selectedIndex,
154
158
  onSelect: this.handleItemSelect
155
159
  };
156
- return /*#__PURE__*/React.createElement("div", {
160
+ return /*#__PURE__*/_jsxs("div", {
157
161
  role: "button",
158
162
  className: `${this.props.className} common__picker`,
159
163
  ref: this.props.forwardedRef,
160
164
  tabIndex: 0,
161
- "aria-haspopup": true
162
- }, /*#__PURE__*/React.createElement(this.props.buttonComponent, buttonProps), /*#__PURE__*/React.createElement(ConnectedReactPortal, {
163
- onClose: () => this.toggleOpenState(false),
164
- isOpened: true
165
- }, /*#__PURE__*/React.createElement(this.props.modalComponent, modalProps, /*#__PURE__*/React.createElement(this.props.listComponent, listProps))));
166
- }
167
- }
165
+ "aria-haspopup": true,
166
+ children: [/*#__PURE__*/React.createElement(this.props.buttonComponent, buttonProps), /*#__PURE__*/_jsx(ConnectedReactPortal, {
167
+ isOpened: true,
168
+ children: /*#__PURE__*/React.createElement(this.props.modalComponent, modalProps, /*#__PURE__*/React.createElement(this.props.listComponent, listProps))
169
+ })]
170
+ });
171
+ };
172
+ return _createClass(Picker, [{
173
+ key: "selectedItem",
174
+ get: function () {
175
+ return normalizeItem(this.props.items[this.state.selectedIndex]);
176
+ }
177
+ }]);
178
+ }(Component);
168
179
  Picker.defaultProps = {
169
180
  buttonComponent: PickerButton,
170
181
  buttonProps: {},
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { mount } from 'enzyme';
3
3
  import Picker from "./index";
4
4
  import PickerList from "./components/List";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
5
6
  jest.mock('@shopgate/engage/components');
6
7
  jest.mock('@shopgate/engage/core');
7
8
  describe('<Picker />', () => {
@@ -21,7 +22,9 @@ describe('<Picker />', () => {
21
22
  * @param {Object} props The component props.
22
23
  */
23
24
  const renderComponent = props => {
24
- renderedElement = mount(/*#__PURE__*/React.createElement(Picker, props));
25
+ renderedElement = mount(/*#__PURE__*/_jsx(Picker, {
26
+ ...props
27
+ }));
25
28
  renderedInstance = renderedElement.find('Picker').instance();
26
29
  };
27
30
  beforeEach(() => {
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { PureComponent, Suspense } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { logger } from '@shopgate/pwa-core/helpers';
@@ -8,19 +9,21 @@ import { componentsConfig } from "../../helpers/config";
8
9
  /**
9
10
  * The Portal component.
10
11
  */
11
- class Portal extends PureComponent {
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let Portal = /*#__PURE__*/function (_PureComponent) {
12
14
  /**
13
15
  * Constructor.
14
16
  * @param {Object} props The component props.
15
17
  */
16
- constructor(_props) {
17
- super(_props);
18
+ function Portal(_props) {
19
+ var _this;
20
+ _this = _PureComponent.call(this, _props) || this;
18
21
  /**
19
22
  * Returns the portal components.
20
23
  * @param {Object} props - The props to pass to the component.
21
24
  * @return {Array}
22
25
  */
23
- this.getRenderedComponents = props => {
26
+ _this.getRenderedComponents = props => {
24
27
  const {
25
28
  props: propsFromProps,
26
29
  ...reducedProps
@@ -29,20 +32,22 @@ class Portal extends PureComponent {
29
32
  ...propsFromProps,
30
33
  ...reducedProps
31
34
  };
32
- return this.components.map(({
35
+ return _this.components.map(({
33
36
  PortalComponent,
34
37
  key
35
- }) => /*#__PURE__*/React.createElement(Suspense, {
36
- fallback: /*#__PURE__*/React.createElement(Loading, null),
37
- key: key
38
- }, /*#__PURE__*/React.createElement(PortalComponent, componentProps)));
38
+ }) => /*#__PURE__*/_jsx(Suspense, {
39
+ fallback: /*#__PURE__*/_jsx(Loading, {}),
40
+ children: /*#__PURE__*/_jsx(PortalComponent, {
41
+ ...componentProps
42
+ })
43
+ }, key));
39
44
  };
40
45
  /**
41
46
  * Returns the portal components.
42
47
  * @param {string} name Name of the portal position
43
48
  * @return {Array}
44
49
  */
45
- this.getPortalComponents = name => {
50
+ _this.getPortalComponents = name => {
46
51
  const components = [];
47
52
  const portals = portalCollection.getPortals();
48
53
  if (!portals) {
@@ -81,10 +86,11 @@ class Portal extends PureComponent {
81
86
  });
82
87
  return components;
83
88
  };
84
- this.state = {
89
+ _this.state = {
85
90
  hasError: false
86
91
  };
87
- this.components = this.getPortalComponents(_props.name);
92
+ _this.components = _this.getPortalComponents(_props.name);
93
+ return _this;
88
94
  }
89
95
 
90
96
  /**
@@ -92,17 +98,19 @@ class Portal extends PureComponent {
92
98
  * @param {Error} error The caught error.
93
99
  * @param {Object} info The stacktrace info.
94
100
  */
95
- componentDidCatch(error, info) {
101
+ _inheritsLoose(Portal, _PureComponent);
102
+ var _proto = Portal.prototype;
103
+ _proto.componentDidCatch = function componentDidCatch(error, info) {
96
104
  this.setState({
97
105
  hasError: true
98
106
  });
99
107
  logger.error(error, info);
100
- }
108
+ };
101
109
  /**
102
110
  * Renders the component.
103
111
  * @return {JSX}
104
112
  */
105
- render() {
113
+ _proto.render = function render() {
106
114
  const {
107
115
  children
108
116
  } = this.props;
@@ -135,8 +143,9 @@ class Portal extends PureComponent {
135
143
  return renderedComponents;
136
144
  }
137
145
  return children;
138
- }
139
- }
146
+ };
147
+ return Portal;
148
+ }(PureComponent);
140
149
  Portal.defaultProps = {
141
150
  children: null,
142
151
  props: null
@@ -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 isMatch from 'lodash/isMatch';
@@ -12,23 +13,25 @@ import { isCharacteristicEnabled, getSelectedValue, prepareState, selectCharacte
12
13
  * @deprecated Please use the component via
13
14
  * `import { ProductCharacteristics } from '@shopgate/engage/product'`
14
15
  */
15
- class ProductCharacteristics extends Component {
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ let ProductCharacteristics = /*#__PURE__*/function (_Component) {
16
18
  /**
17
19
  * @param {Object} props The component props.
18
20
  */
19
- constructor(_props) {
20
- super(_props);
21
+ function ProductCharacteristics(_props) {
22
+ var _this;
23
+ _this = _Component.call(this, _props) || this;
21
24
  /**
22
25
  * Sets the refs to the characteristics selects.
23
26
  * @param {Object} props The props to check against.
24
27
  */
25
- this.setRefs = props => {
28
+ _this.setRefs = props => {
26
29
  const {
27
30
  variants
28
31
  } = props;
29
32
  if (variants) {
30
33
  variants.characteristics.forEach(char => {
31
- this.refsStore[char.id] = /*#__PURE__*/React.createRef();
34
+ _this.refsStore[char.id] = /*#__PURE__*/React.createRef();
32
35
  });
33
36
  }
34
37
  };
@@ -36,23 +39,23 @@ class ProductCharacteristics extends Component {
36
39
  * Checks if all selections have been made.
37
40
  * @return {boolean}
38
41
  */
39
- this.checkSelection = () => {
42
+ _this.checkSelection = () => {
40
43
  const {
41
44
  characteristics
42
- } = this.state;
45
+ } = _this.state;
43
46
  const {
44
47
  variants,
45
48
  variantId
46
- } = this.props;
49
+ } = _this.props;
47
50
  if (!variants) {
48
51
  return true;
49
52
  }
50
53
  const filteredValues = Object.keys(characteristics).filter(key => !!characteristics[key]);
51
54
  const selected = !!(filteredValues.length === variants.characteristics.length && variantId);
52
55
  if (!selected) {
53
- const firstUnselected = this.findUnselectedCharacteristic();
56
+ const firstUnselected = _this.findUnselectedCharacteristic();
54
57
  if (firstUnselected) {
55
- const ref = this.refsStore[firstUnselected.id];
58
+ const ref = _this.refsStore[firstUnselected.id];
56
59
 
57
60
  // Focus the item for screen readers and broadcast a related live message.
58
61
  ref.current.focus();
@@ -74,22 +77,22 @@ class ProductCharacteristics extends Component {
74
77
  behavior: 'smooth'
75
78
  });
76
79
  }
77
- this.setState({
80
+ _this.setState({
78
81
  highlight: firstUnselected.id
79
82
  });
80
83
  }
81
84
  }
82
85
  return selected;
83
86
  };
84
- this.checkSelectedCharacteristics = () => {
87
+ _this.checkSelectedCharacteristics = () => {
85
88
  const {
86
89
  characteristics
87
- } = this.state;
90
+ } = _this.state;
88
91
  const {
89
92
  variantId,
90
93
  variants,
91
94
  finishTimeout
92
- } = this.props;
95
+ } = _this.props;
93
96
  if (!variants) {
94
97
  return;
95
98
  }
@@ -105,23 +108,23 @@ class ProductCharacteristics extends Component {
105
108
  return;
106
109
  }
107
110
  setTimeout(() => {
108
- this.props.navigate(products[0].id);
111
+ _this.props.navigate(products[0].id);
109
112
  }, finishTimeout);
110
113
  };
111
114
  /**
112
115
  * Stores a selected characteristic into the local state.
113
116
  * @param {Object} selection The selected item.
114
117
  */
115
- this.handleSelection = selection => {
118
+ _this.handleSelection = selection => {
116
119
  const {
117
120
  variants,
118
121
  setCharacteristics
119
- } = this.props;
122
+ } = _this.props;
120
123
  const {
121
124
  id,
122
125
  value
123
126
  } = selection;
124
- this.setState(({
127
+ _this.setState(({
125
128
  characteristics
126
129
  }) => {
127
130
  const state = prepareState(id, value, characteristics, variants.characteristics, variants.products);
@@ -132,7 +135,7 @@ class ProductCharacteristics extends Component {
132
135
  },
133
136
  highlight: null
134
137
  };
135
- }, this.checkSelectedCharacteristics);
138
+ }, _this.checkSelectedCharacteristics);
136
139
  };
137
140
  /**
138
141
  * @param {Object} selections The selections stored in the state.
@@ -142,7 +145,7 @@ class ProductCharacteristics extends Component {
142
145
  * @param {string|null} selectedValue selectedValue
143
146
  * @return {Array}
144
147
  */
145
- this.buildValues = (selections, charId, values, charIndex, selectedValue) => {
148
+ _this.buildValues = (selections, charId, values, charIndex, selectedValue) => {
146
149
  // If this is the first characteristic then all values are selectable.
147
150
  if (charIndex === 0) {
148
151
  return values.map(value => ({
@@ -153,7 +156,7 @@ class ProductCharacteristics extends Component {
153
156
  }
154
157
  const {
155
158
  variants
156
- } = this.props;
159
+ } = _this.props;
157
160
  const subset = {};
158
161
  Object.keys(selections).forEach((item, index) => {
159
162
  if (index < charIndex) {
@@ -183,29 +186,32 @@ class ProductCharacteristics extends Component {
183
186
  /**
184
187
  * Resets the highlight state
185
188
  */
186
- this.resetHighlight = () => {
187
- this.setState({
189
+ _this.resetHighlight = () => {
190
+ _this.setState({
188
191
  highlight: null
189
192
  });
190
193
  };
191
- this.refsStore = {};
192
- this.state = {
194
+ _this.refsStore = {};
195
+ _this.state = {
193
196
  highlight: null,
194
197
  characteristics: selectCharacteristics(_props)
195
198
  };
196
- this.setRefs(_props);
197
- _props.conditioner.addConditioner('product-variants', this.checkSelection);
199
+ _this.setRefs(_props);
200
+ _props.conditioner.addConditioner('product-variants', _this.checkSelection);
201
+ return _this;
198
202
  }
199
203
 
200
204
  /** @inheritDoc */
201
- componentDidMount() {
205
+ _inheritsLoose(ProductCharacteristics, _Component);
206
+ var _proto = ProductCharacteristics.prototype;
207
+ _proto.componentDidMount = function componentDidMount() {
202
208
  this.checkSelectedCharacteristics();
203
209
  }
204
210
 
205
211
  /**
206
212
  * @param {Object} nextProps The next component props.
207
- */
208
- UNSAFE_componentWillReceiveProps(nextProps) {
213
+ */;
214
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
209
215
  if (!this.props.variants && nextProps.variants) {
210
216
  // Initialize refs and characteristics when the variants prop was updated with a valid value.
211
217
  this.setRefs(nextProps);
@@ -213,12 +219,12 @@ class ProductCharacteristics extends Component {
213
219
  characteristics: selectCharacteristics(nextProps)
214
220
  }, this.checkSelectedCharacteristics);
215
221
  }
216
- }
222
+ };
217
223
  /**
218
224
  * Finds the first unselected characteristic.
219
225
  * @return {Object|null}
220
226
  */
221
- findUnselectedCharacteristic() {
227
+ _proto.findUnselectedCharacteristic = function findUnselectedCharacteristic() {
222
228
  const {
223
229
  characteristics
224
230
  } = this.state;
@@ -231,8 +237,8 @@ class ProductCharacteristics extends Component {
231
237
 
232
238
  /**
233
239
  * @return {JSX}
234
- */
235
- render() {
240
+ */;
241
+ _proto.render = function render() {
236
242
  const {
237
243
  characteristics
238
244
  } = this.state;
@@ -242,29 +248,31 @@ class ProductCharacteristics extends Component {
242
248
  if (!variants) {
243
249
  return null;
244
250
  }
245
- return /*#__PURE__*/React.createElement(VariantsContext.Provider, {
246
- value: this.state
247
- }, variants.characteristics.map((char, index) => {
248
- const disabled = !isCharacteristicEnabled(characteristics, index);
249
- const selected = getSelectedValue(char.id, characteristics);
250
- const values = this.buildValues(characteristics, char.id, char.values, index, selected);
251
- return this.props.render({
252
- charRef: this.refsStore[char.id],
253
- disabled,
254
- highlight: this.state.highlight === char.id,
255
- id: char.id,
256
- key: char.id,
257
- label: char.label,
258
- swatch: !!char.swatch,
259
- // BETA
260
- select: this.handleSelection,
261
- selected,
262
- values,
263
- resetHighlight: this.resetHighlight
264
- });
265
- }));
266
- }
267
- }
251
+ return /*#__PURE__*/_jsx(VariantsContext.Provider, {
252
+ value: this.state,
253
+ children: variants.characteristics.map((char, index) => {
254
+ const disabled = !isCharacteristicEnabled(characteristics, index);
255
+ const selected = getSelectedValue(char.id, characteristics);
256
+ const values = this.buildValues(characteristics, char.id, char.values, index, selected);
257
+ return this.props.render({
258
+ charRef: this.refsStore[char.id],
259
+ disabled,
260
+ highlight: this.state.highlight === char.id,
261
+ id: char.id,
262
+ key: char.id,
263
+ label: char.label,
264
+ swatch: !!char.swatch,
265
+ // BETA
266
+ select: this.handleSelection,
267
+ selected,
268
+ values,
269
+ resetHighlight: this.resetHighlight
270
+ });
271
+ })
272
+ });
273
+ };
274
+ return ProductCharacteristics;
275
+ }(Component);
268
276
  ProductCharacteristics.defaultProps = {
269
277
  finishTimeout: 0,
270
278
  variantId: null,