@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.
- package/App.js +28 -13
- package/actions/app/handleUniversalLink.js +0 -2
- package/collections/AuthRoutes.js +15 -13
- package/collections/Configuration.js +11 -10
- package/collections/EmbeddedMedia.js +21 -19
- package/collections/PersistedReducers.js +11 -9
- package/collections/Redirects.js +15 -13
- package/collections/media-providers/MediaProvider.js +23 -21
- package/collections/media-providers/Vimeo.js +28 -22
- package/collections/media-providers/YouTube.js +17 -10
- package/components/Backdrop/index.js +15 -13
- package/components/Backdrop/spec.js +3 -2
- package/components/Button/index.js +41 -29
- package/components/Button/spec.js +16 -10
- package/components/Checkbox/index.js +36 -28
- package/components/Checkbox/spec.js +40 -27
- package/components/Consume/index.js +4 -1
- package/components/CountdownTimer/index.js +27 -20
- package/components/CountdownTimer/spec.js +2 -1
- package/components/Drawer/index.js +31 -23
- package/components/Drawer/spec.js +7 -6
- package/components/Dropdown/index.js +27 -18
- package/components/Ellipsis/index.js +5 -3
- package/components/Ellipsis/spec.js +5 -3
- package/components/EmbeddedMedia/index.js +9 -6
- package/components/EmbeddedMedia/spec.js +11 -2
- package/components/ErrorBoundary/index.js +26 -16
- package/components/Grid/components/Item/index.js +13 -6
- package/components/Grid/components/Item/spec.js +4 -3
- package/components/Grid/index.js +13 -6
- package/components/Grid/spec.js +4 -3
- package/components/HtmlSanitizer/index.js +42 -45
- package/components/HtmlSanitizer/spec.js +16 -12
- package/components/I18n/components/FormatDate/index.js +11 -4
- package/components/I18n/components/FormatDate/spec.js +22 -14
- package/components/I18n/components/FormatNumber/index.js +8 -6
- package/components/I18n/components/FormatNumber/spec.js +10 -5
- package/components/I18n/components/FormatPrice/index.js +5 -3
- package/components/I18n/components/FormatPrice/spec.js +22 -14
- package/components/I18n/components/FormatTime/index.js +11 -4
- package/components/I18n/components/FormatTime/spec.js +22 -14
- package/components/I18n/components/I18nProvider/index.js +18 -11
- package/components/I18n/components/I18nProvider/spec.js +2 -1
- package/components/I18n/components/Placeholder/index.js +10 -3
- package/components/I18n/components/Placeholder/spec.js +12 -5
- package/components/I18n/components/Translate/index.js +12 -8
- package/components/I18n/components/Translate/spec.js +9 -6
- package/components/Icon/index.js +2 -1
- package/components/Image/Image.js +23 -21
- package/components/Image/ImageInner.js +2 -1
- package/components/InfiniteContainer/index.js +59 -53
- package/components/InfiniteContainer/spec.js +10 -5
- package/components/Input/components/MultiLineInput.js +33 -26
- package/components/Input/components/SimpleInput.js +70 -54
- package/components/Input/index.js +7 -17
- package/components/Input/spec.js +12 -11
- package/components/KeyboardConsumer/index.js +19 -13
- package/components/Link/index.js +28 -20
- package/components/Link/spec.js +13 -9
- package/components/List/components/Item/index.js +5 -3
- package/components/List/index.js +5 -3
- package/components/List/spec.js +6 -9
- package/components/Loading/index.js +1 -3
- package/components/Modal/index.js +13 -10
- package/components/ModalContainer/spec.js +24 -20
- package/components/Picker/components/Button/index.js +18 -12
- package/components/Picker/components/List/index.js +19 -16
- package/components/Picker/components/Modal/index.js +34 -25
- package/components/Picker/index.js +44 -33
- package/components/Picker/spec.js +4 -1
- package/components/Portal/index.js +26 -17
- package/components/ProductCharacteristics/index.js +65 -57
- package/components/RangeSlider/components/Handle/index.js +7 -5
- package/components/RangeSlider/index.js +98 -84
- package/components/Route/RouteNotFound.js +30 -19
- package/components/Route/index.js +31 -21
- package/components/Router/index.js +51 -34
- package/components/ScannerContainer/index.js +17 -10
- package/components/Select/components/Item/index.js +5 -3
- package/components/Select/index.js +59 -47
- package/components/Select/spec.js +7 -6
- package/components/SelectBox/components/Item/index.js +23 -13
- package/components/SelectBox/index.js +83 -80
- package/components/SelectBox/spec.js +8 -5
- package/components/SurroundPortals/index.js +15 -11
- package/components/Swiper/components/SwiperItem/index.js +6 -5
- package/components/Swiper/components/SwiperItem/spec.js +8 -4
- package/components/Swiper/index.js +23 -20
- package/components/Toaster/index.js +4 -1
- package/components/Transition/index.js +19 -12
- package/components/Widgets/components/Widget/index.js +27 -16
- package/components/Widgets/components/Widget/spec.js +5 -4
- package/components/Widgets/components/WidgetGrid/index.js +27 -19
- package/components/Widgets/components/WidgetGrid/spec.js +4 -3
- package/components/Widgets/index.js +33 -26
- package/components/Widgets/spec.js +12 -13
- package/helpers/data/index.js +1 -1
- package/helpers/portals/portalCollection.js +13 -10
- package/helpers/redux/mutable.js +2 -2
- package/package.json +5 -5
- package/providers/loading/index.js +71 -57
- package/providers/toast/index.js +39 -28
- package/reducers/modal/index.js +1 -1
- package/store/index.js +1 -1
- package/subscriptions/helpers/buildRegisterUrl.js +1 -0
- package/components/Input/components/DateInput.js +0 -273
|
@@ -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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
|
35
|
+
return _this.components.map(({
|
|
33
36
|
PortalComponent,
|
|
34
37
|
key
|
|
35
|
-
}) => /*#__PURE__*/
|
|
36
|
-
fallback: /*#__PURE__*/
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
+
_this.state = {
|
|
85
90
|
hasError: false
|
|
86
91
|
};
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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
|
-
|
|
28
|
+
_this.setRefs = props => {
|
|
26
29
|
const {
|
|
27
30
|
variants
|
|
28
31
|
} = props;
|
|
29
32
|
if (variants) {
|
|
30
33
|
variants.characteristics.forEach(char => {
|
|
31
|
-
|
|
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
|
-
|
|
42
|
+
_this.checkSelection = () => {
|
|
40
43
|
const {
|
|
41
44
|
characteristics
|
|
42
|
-
} =
|
|
45
|
+
} = _this.state;
|
|
43
46
|
const {
|
|
44
47
|
variants,
|
|
45
48
|
variantId
|
|
46
|
-
} =
|
|
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 =
|
|
56
|
+
const firstUnselected = _this.findUnselectedCharacteristic();
|
|
54
57
|
if (firstUnselected) {
|
|
55
|
-
const ref =
|
|
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
|
-
|
|
80
|
+
_this.setState({
|
|
78
81
|
highlight: firstUnselected.id
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
return selected;
|
|
83
86
|
};
|
|
84
|
-
|
|
87
|
+
_this.checkSelectedCharacteristics = () => {
|
|
85
88
|
const {
|
|
86
89
|
characteristics
|
|
87
|
-
} =
|
|
90
|
+
} = _this.state;
|
|
88
91
|
const {
|
|
89
92
|
variantId,
|
|
90
93
|
variants,
|
|
91
94
|
finishTimeout
|
|
92
|
-
} =
|
|
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
|
-
|
|
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
|
-
|
|
118
|
+
_this.handleSelection = selection => {
|
|
116
119
|
const {
|
|
117
120
|
variants,
|
|
118
121
|
setCharacteristics
|
|
119
|
-
} =
|
|
122
|
+
} = _this.props;
|
|
120
123
|
const {
|
|
121
124
|
id,
|
|
122
125
|
value
|
|
123
126
|
} = selection;
|
|
124
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
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
|
-
} =
|
|
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
|
-
|
|
187
|
-
|
|
189
|
+
_this.resetHighlight = () => {
|
|
190
|
+
_this.setState({
|
|
188
191
|
highlight: null
|
|
189
192
|
});
|
|
190
193
|
};
|
|
191
|
-
|
|
192
|
-
|
|
194
|
+
_this.refsStore = {};
|
|
195
|
+
_this.state = {
|
|
193
196
|
highlight: null,
|
|
194
197
|
characteristics: selectCharacteristics(_props)
|
|
195
198
|
};
|
|
196
|
-
|
|
197
|
-
_props.conditioner.addConditioner('product-variants',
|
|
199
|
+
_this.setRefs(_props);
|
|
200
|
+
_props.conditioner.addConditioner('product-variants', _this.checkSelection);
|
|
201
|
+
return _this;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
204
|
/** @inheritDoc */
|
|
201
|
-
|
|
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__*/
|
|
246
|
-
value: this.state
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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,
|
|
@@ -11,20 +11,22 @@ import styles from "./style";
|
|
|
11
11
|
* @param {Object} props.classNames (Optional) An additional style classes for the handle.
|
|
12
12
|
* @returns {JSX}
|
|
13
13
|
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const RangeSliderHandle = ({
|
|
15
16
|
active,
|
|
16
17
|
index,
|
|
17
18
|
onTouchStart,
|
|
18
19
|
classNames
|
|
19
|
-
}) => /*#__PURE__*/
|
|
20
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
20
21
|
className: `${classNames.handleOuter || ''} ${styles}`,
|
|
21
22
|
style: {
|
|
22
23
|
zIndex: Number(active) || 0
|
|
23
24
|
},
|
|
24
|
-
onTouchStart: event => onTouchStart(event, index)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
25
|
+
onTouchStart: event => onTouchStart(event, index),
|
|
26
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
27
|
+
className: classNames.handleInner || ''
|
|
28
|
+
})
|
|
29
|
+
});
|
|
28
30
|
RangeSliderHandle.defaultProps = {
|
|
29
31
|
active: false,
|
|
30
32
|
classNames: {}
|