@shopgate/pwa-ui-shared 7.30.0-alpha.10 → 7.30.0-alpha.12
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/AccordionContainer/index.js +17 -11
- package/AccordionContainer/spec.js +12 -3
- package/ActionButton/index.js +47 -33
- package/ActionButton/spec.js +5 -1
- package/AddToCartButton/index.js +44 -33
- package/AddToCartButton/mock.js +20 -8
- package/AddToCartButton/spec.js +4 -3
- package/Availability/index.js +5 -3
- package/Availability/spec.js +6 -5
- package/Button/index.js +73 -58
- package/Button/spec.js +16 -10
- package/ButtonLink/index.js +20 -12
- package/ButtonLink/spec.js +5 -3
- package/Card/index.js +5 -3
- package/CardList/components/Item/index.js +5 -3
- package/CardList/index.js +21 -12
- package/CartTotalLine/components/Amount/index.js +10 -8
- package/CartTotalLine/components/Hint/index.js +7 -5
- package/CartTotalLine/components/Label/index.js +12 -10
- package/CartTotalLine/components/Spacer/index.js +5 -3
- package/CartTotalLine/index.js +5 -3
- package/Checkbox/index.js +6 -5
- package/Chip/index.js +28 -22
- package/Chip/spec.js +9 -6
- package/ContextMenu/ContextMenuProvider.js +5 -3
- package/ContextMenu/components/Item/index.js +14 -11
- package/ContextMenu/components/Position/index.js +20 -12
- package/ContextMenu/index.js +54 -44
- package/ContextMenu/spec.js +31 -20
- package/Dialog/components/HtmlContentDialog/index.js +9 -7
- package/Dialog/components/HtmlContentDialog/spec.js +9 -6
- package/Dialog/components/PipelineErrorDialog/index.js +106 -47
- package/Dialog/components/PipelineErrorDialog/spec.js +5 -4
- package/Dialog/components/TextMessageDialog/index.js +9 -7
- package/Dialog/components/TextMessageDialog/spec.js +9 -6
- package/Dialog/components/VariantSelectModal/index.js +7 -5
- package/Dialog/components/VariantSelectModal/spec.js +6 -3
- package/Dialog/index.js +12 -8
- package/Dialog/spec.js +7 -6
- package/DiscountBadge/index.js +10 -8
- package/DiscountBadge/spec.js +3 -2
- package/FavoritesButton/index.js +40 -31
- package/FavoritesButton/spec.js +7 -3
- package/Form/Builder/classes/ActionListener/index.js +400 -401
- package/Form/Builder/components/CheckboxElement.js +13 -5
- package/Form/Builder/components/CountryElement.js +13 -5
- package/Form/Builder/components/ProvinceElement.js +13 -5
- package/Form/Builder/components/RadioElement.js +19 -11
- package/Form/Builder/components/SelectElement.js +26 -16
- package/Form/Builder/components/TextElement.js +13 -5
- package/Form/Builder/index.js +70 -60
- package/Form/Builder/spec.js +10 -9
- package/Form/Checkbox/index.js +31 -21
- package/Form/InfoField/index.js +19 -12
- package/Form/InfoField/spec.js +4 -1
- package/Form/Password/index.js +22 -15
- package/Form/Password/spec.js +10 -5
- package/Form/RadioGroup/components/Item/index.js +34 -25
- package/Form/RadioGroup/index.js +37 -28
- package/Form/RadioGroup/spec.js +45 -31
- package/Form/Select/index.js +52 -43
- package/Form/Select/spec.js +5 -2
- package/Form/SelectContextChoices/index.js +26 -22
- package/Form/SelectContextChoices/spec.js +4 -1
- package/Form/TextField/index.js +40 -27
- package/Form/TextField/spec.js +34 -21
- package/Form/index.js +23 -15
- package/FormElement/components/ErrorText/index.js +7 -5
- package/FormElement/components/Label/index.js +6 -4
- package/FormElement/components/Placeholder/index.js +7 -5
- package/FormElement/components/Underline/index.js +8 -6
- package/FormElement/index.js +62 -46
- package/FormElement/spec.js +10 -9
- package/Glow/index.js +30 -22
- package/Glow/spec.js +6 -1
- package/IndicatorCircle/index.js +10 -8
- package/IndicatorCircle/spec.js +3 -2
- package/LoadingIndicator/index.js +8 -6
- package/Manufacturer/index.js +9 -7
- package/MessageBar/index.js +20 -17
- package/MessageBar/spec.js +6 -5
- package/NoResults/components/Icon/index.js +134 -110
- package/NoResults/index.js +27 -21
- package/Placeholder/index.js +13 -5
- package/PlaceholderLabel/index.js +2 -1
- package/PlaceholderLabel/spec.js +13 -6
- package/PlaceholderParagraph/index.js +13 -12
- package/PlaceholderParagraph/spec.js +13 -6
- package/Price/index.js +46 -28
- package/PriceInfo/index.js +2 -1
- package/PriceStriked/index.js +41 -29
- package/ProductProperties/index.js +13 -10
- package/ProgressBar/index.js +28 -19
- package/ProgressBar/spec.js +2 -1
- package/RadioButton/index.js +6 -5
- package/RadioButton/spec.js +3 -2
- package/RatingNumber/index.js +2 -1
- package/RatingStars/index.js +50 -34
- package/RatingStars/spec.js +7 -6
- package/Ripple/components/RippleAnimation/index.js +12 -10
- package/Ripple/index.js +72 -62
- package/RippleButton/index.js +44 -27
- package/RippleButton/spec.js +20 -13
- package/ScannerOverlay/components/CameraOverlay/index.js +8 -5
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +25 -21
- package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +7 -5
- package/ScannerOverlay/components/ScannerBar/index.js +17 -12
- package/ScannerOverlay/index.js +24 -15
- package/Sheet/components/Header/components/SearchBar/index.js +35 -28
- package/Sheet/components/Header/components/SearchBar/spec.js +2 -1
- package/Sheet/components/Header/index.js +47 -34
- package/Sheet/components/Header/spec.js +2 -1
- package/Sheet/index.js +80 -65
- package/Sheet/spec.js +27 -14
- package/TaxDisclaimer/index.js +13 -10
- package/TaxDisclaimer/spec.js +3 -2
- package/TextField/components/ErrorText/index.js +7 -5
- package/TextField/components/FormElement/index.js +4 -3
- package/TextField/components/Hint/index.js +7 -5
- package/TextField/components/Label/index.js +6 -4
- package/TextField/components/Underline/index.js +8 -6
- package/TextField/index.js +102 -85
- package/TextField/spec.js +37 -23
- package/ToggleIcon/index.js +23 -15
- package/ToggleIcon/spec.js +12 -8
- package/icons/AccountBoxIcon.js +5 -4
- package/icons/AddMoreIcon.js +5 -4
- package/icons/ArrowDropIcon.js +5 -4
- package/icons/ArrowIcon.js +5 -4
- package/icons/BarcodeScannerIcon.js +5 -4
- package/icons/BoxIcon.js +5 -4
- package/icons/BrowseIcon.js +5 -4
- package/icons/BurgerIcon.js +5 -4
- package/icons/CalendarIcon.js +5 -5
- package/icons/CartCouponIcon.js +5 -4
- package/icons/CartIcon.js +5 -4
- package/icons/CartPlusIcon.js +5 -4
- package/icons/CheckIcon.js +5 -4
- package/icons/CheckedIcon.js +5 -4
- package/icons/ChevronIcon.js +5 -4
- package/icons/CreditCardIcon.js +5 -4
- package/icons/CrossIcon.js +5 -4
- package/icons/DescriptionIcon.js +5 -4
- package/icons/FilterIcon.js +5 -4
- package/icons/FlashDisabledIcon.js +5 -4
- package/icons/FlashEnabledIcon.js +5 -4
- package/icons/GridIcon.js +5 -4
- package/icons/HeartIcon.js +5 -4
- package/icons/HeartOutlineIcon.js +5 -4
- package/icons/HeartPlusIcon.js +5 -4
- package/icons/HeartPlusOutlineIcon.js +5 -4
- package/icons/HomeIcon.js +5 -4
- package/icons/InfoIcon.js +5 -4
- package/icons/InfoOutlineIcon.js +5 -4
- package/icons/ListIcon.js +5 -4
- package/icons/LocalShippingIcon.js +5 -4
- package/icons/LocationIcon.js +5 -4
- package/icons/LocatorIcon.js +5 -4
- package/icons/LockIcon.js +5 -4
- package/icons/LogoutIcon.js +5 -4
- package/icons/MagnifierIcon.js +5 -4
- package/icons/MapMarkerIcon.js +5 -4
- package/icons/MoreIcon.js +5 -4
- package/icons/MoreVertIcon.js +5 -4
- package/icons/NotificationIcon.js +5 -4
- package/icons/PersonIcon.js +5 -4
- package/icons/PhoneIcon.js +5 -4
- package/icons/PlaceholderIcon.js +5 -4
- package/icons/RadioCheckedIcon.js +5 -4
- package/icons/RadioUncheckedIcon.js +5 -4
- package/icons/SecurityIcon.js +5 -4
- package/icons/ShippingMethodIcon.js +5 -4
- package/icons/ShoppingCartIcon.js +5 -4
- package/icons/SortIcon.js +5 -4
- package/icons/StarHalfIcon.js +5 -4
- package/icons/StarIcon.js +5 -4
- package/icons/StarOutlineIcon.js +5 -4
- package/icons/StopIcon.js +5 -4
- package/icons/TickIcon.js +5 -4
- package/icons/TimeIcon.js +5 -4
- package/icons/TrashIcon.js +5 -4
- package/icons/TrashOutlineIcon.js +5 -4
- package/icons/UncheckedIcon.js +5 -4
- package/icons/ViewListIcon.js +5 -4
- package/icons/VisibilityIcon.js +5 -4
- package/icons/VisibilityOffIcon.js +5 -4
- package/icons/WarningIcon.js +5 -4
- package/package.json +7 -8
package/Ripple/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
3
|
import React, { PureComponent } from 'react';
|
|
2
4
|
import PropTypes from 'prop-types';
|
|
3
5
|
import { findDOMNode } from 'react-dom';
|
|
@@ -11,59 +13,64 @@ import style from "./style";
|
|
|
11
13
|
/**
|
|
12
14
|
* The ripple component.
|
|
13
15
|
*/
|
|
14
|
-
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
let Ripple = /*#__PURE__*/function (_PureComponent) {
|
|
15
18
|
/**
|
|
16
19
|
* Constructor.
|
|
17
20
|
* @param {Object} props The component props.
|
|
18
21
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
function Ripple(props) {
|
|
23
|
+
var _this;
|
|
24
|
+
_this = _PureComponent.call(this, props) || this;
|
|
21
25
|
/**
|
|
22
26
|
* Triggers adding of a new ripple on touch start event.
|
|
23
27
|
* @param {Object} event The even object.
|
|
24
28
|
*/
|
|
25
|
-
|
|
26
|
-
if (
|
|
29
|
+
_this.handleClick = event => {
|
|
30
|
+
if (_this.props.disabled) {
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
_this.addRipple(event, true);
|
|
34
|
+
_this.props.onClick();
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
37
|
* Will be triggered from the ripple animation component, when the
|
|
34
38
|
* ripple animation is over. It removes the ripple from the queue again.
|
|
35
39
|
*/
|
|
36
|
-
|
|
37
|
-
if (!
|
|
40
|
+
_this.removeRipple = () => {
|
|
41
|
+
if (!_this.mounted) {
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
_this.setState(prevState => {
|
|
41
45
|
const ripples = shift(prevState.ripples);
|
|
42
|
-
|
|
46
|
+
_this.props.onComplete();
|
|
43
47
|
return {
|
|
44
48
|
ripples,
|
|
45
49
|
hasRipples: !!ripples.length
|
|
46
50
|
};
|
|
47
51
|
});
|
|
48
52
|
};
|
|
49
|
-
|
|
53
|
+
_this.state = {
|
|
50
54
|
ripples: [],
|
|
51
55
|
nextKey: 0,
|
|
52
56
|
hasRipples: false
|
|
53
57
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
_this.duration = 500;
|
|
59
|
+
_this.ignoreNextMouseDown = false;
|
|
60
|
+
_this.mounted = false;
|
|
61
|
+
_this.offset = null;
|
|
62
|
+
_this.position = null;
|
|
63
|
+
_this.rootNode = null;
|
|
64
|
+
_this.style = null;
|
|
65
|
+
return _this;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
/**
|
|
64
69
|
* Sets the `mounted` flag to true.
|
|
65
70
|
*/
|
|
66
|
-
|
|
71
|
+
_inheritsLoose(Ripple, _PureComponent);
|
|
72
|
+
var _proto = Ripple.prototype;
|
|
73
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
67
74
|
const {
|
|
68
75
|
fill
|
|
69
76
|
} = this.props;
|
|
@@ -94,42 +101,21 @@ class Ripple extends PureComponent {
|
|
|
94
101
|
|
|
95
102
|
/**
|
|
96
103
|
* Sets the `mounted` flag to false
|
|
97
|
-
|
|
98
|
-
componentWillUnmount() {
|
|
104
|
+
*/;
|
|
105
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
99
106
|
this.mounted = false;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
/**
|
|
103
110
|
* Calculate the size of the ripple.
|
|
104
111
|
* @returns {number}
|
|
105
|
-
|
|
106
|
-
get rippleSize() {
|
|
107
|
-
if (this.props.size) {
|
|
108
|
-
if (this.props.fill) {
|
|
109
|
-
return this.props.size * 2;
|
|
110
|
-
}
|
|
111
|
-
return this.props.size;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* We want the Ripple to fill the element. We set the diameter of the Ripple
|
|
116
|
-
* to double the distance of the opposing corners of the node. That way the Ripple
|
|
117
|
-
* will reach the furthest away corner if you click at a corner.
|
|
118
|
-
*/
|
|
119
|
-
if (this.props.fill) {
|
|
120
|
-
return Math.sqrt(this.rootNode.offsetWidth ** 2 + this.rootNode.offsetHeight ** 2) * 2;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Otherwise we set the size to be the smaller of the element's height and width.
|
|
124
|
-
return Math.min(this.rootNode.offsetWidth, this.rootNode.offsetHeight);
|
|
125
|
-
}
|
|
126
|
-
|
|
112
|
+
*/;
|
|
127
113
|
/**
|
|
128
114
|
* Calculates the ripple position from the event.
|
|
129
115
|
* @param {Object} event The event object.
|
|
130
116
|
* @returns {Object} An object containing x and y values for the ripple.
|
|
131
117
|
*/
|
|
132
|
-
getRipplePosition(event) {
|
|
118
|
+
_proto.getRipplePosition = function getRipplePosition(event) {
|
|
133
119
|
// If the Ripple is to fill the element then we should set the
|
|
134
120
|
// Starting position to be where the user clicked within that element.
|
|
135
121
|
if (this.props.fill) {
|
|
@@ -145,13 +131,13 @@ class Ripple extends PureComponent {
|
|
|
145
131
|
this.position.y = pageY - this.offset.top;
|
|
146
132
|
}
|
|
147
133
|
return this.position;
|
|
148
|
-
}
|
|
134
|
+
};
|
|
149
135
|
/**
|
|
150
136
|
* Adds a new Ripple to the queue.
|
|
151
137
|
* @param {Object} event The event object.
|
|
152
138
|
* @param {boolean} isTouchGenerated Whether the action was triggered by a touch or click.
|
|
153
139
|
*/
|
|
154
|
-
addRipple(event, isTouchGenerated) {
|
|
140
|
+
_proto.addRipple = function addRipple(event, isTouchGenerated) {
|
|
155
141
|
// If the adding of the Ripple was already triggered
|
|
156
142
|
// By a touch start event, no further action will be done.
|
|
157
143
|
if (this.ignoreNextMouseDown && !isTouchGenerated) {
|
|
@@ -172,16 +158,15 @@ class Ripple extends PureComponent {
|
|
|
172
158
|
} = this.state;
|
|
173
159
|
|
|
174
160
|
// Append the new ripple to the ripples array.
|
|
175
|
-
ripples.push(/*#__PURE__*/
|
|
161
|
+
ripples.push(/*#__PURE__*/_jsx(RippleAnimation, {
|
|
176
162
|
color: this.props.color,
|
|
177
163
|
duration: this.duration,
|
|
178
164
|
fill: this.props.fill,
|
|
179
|
-
key: this.state.nextKey,
|
|
180
165
|
onComplete: this.removeRipple,
|
|
181
166
|
size: this.rippleSize,
|
|
182
167
|
x: x,
|
|
183
168
|
y: y
|
|
184
|
-
}));
|
|
169
|
+
}, this.state.nextKey));
|
|
185
170
|
this.ignoreNextMouseDown = isTouchGenerated;
|
|
186
171
|
|
|
187
172
|
// Update the state.
|
|
@@ -197,34 +182,59 @@ class Ripple extends PureComponent {
|
|
|
197
182
|
/**
|
|
198
183
|
* Renders all the ripples in the queue.
|
|
199
184
|
* @returns {JSX|null}
|
|
200
|
-
|
|
201
|
-
renderRipples() {
|
|
185
|
+
*/;
|
|
186
|
+
_proto.renderRipples = function renderRipples() {
|
|
202
187
|
// It only needs to render, if there is at least one ripple in the queue.
|
|
203
188
|
if (!this.state.hasRipples) {
|
|
204
189
|
return null;
|
|
205
190
|
}
|
|
206
|
-
return /*#__PURE__*/
|
|
207
|
-
className: style.container
|
|
208
|
-
|
|
191
|
+
return /*#__PURE__*/_jsx("div", {
|
|
192
|
+
className: style.container,
|
|
193
|
+
children: this.state.ripples
|
|
194
|
+
});
|
|
209
195
|
}
|
|
210
196
|
|
|
211
197
|
/**
|
|
212
198
|
* Renders the final ripple component including it's contents.
|
|
213
199
|
* @returns {JSX}
|
|
214
|
-
|
|
215
|
-
render() {
|
|
200
|
+
*/;
|
|
201
|
+
_proto.render = function render() {
|
|
216
202
|
/* eslint-disable jsx-a11y/click-events-have-key-events,
|
|
217
203
|
jsx-a11y/no-static-element-interactions */
|
|
218
|
-
return /*#__PURE__*/
|
|
204
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
219
205
|
className: `ui-shared__ripple ${this.props.className}`,
|
|
220
206
|
"data-test-id": "Ripple",
|
|
221
207
|
onClick: this.handleClick,
|
|
222
|
-
style: this.style
|
|
223
|
-
|
|
208
|
+
style: this.style,
|
|
209
|
+
children: [this.renderRipples(), this.props.children]
|
|
210
|
+
});
|
|
224
211
|
/* eslint-enable jsx-a11y/click-events-have-key-events,
|
|
225
212
|
jsx-a11y/no-static-element-interactions */
|
|
226
|
-
}
|
|
227
|
-
|
|
213
|
+
};
|
|
214
|
+
return _createClass(Ripple, [{
|
|
215
|
+
key: "rippleSize",
|
|
216
|
+
get: function () {
|
|
217
|
+
if (this.props.size) {
|
|
218
|
+
if (this.props.fill) {
|
|
219
|
+
return this.props.size * 2;
|
|
220
|
+
}
|
|
221
|
+
return this.props.size;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* We want the Ripple to fill the element. We set the diameter of the Ripple
|
|
226
|
+
* to double the distance of the opposing corners of the node. That way the Ripple
|
|
227
|
+
* will reach the furthest away corner if you click at a corner.
|
|
228
|
+
*/
|
|
229
|
+
if (this.props.fill) {
|
|
230
|
+
return Math.sqrt(this.rootNode.offsetWidth ** 2 + this.rootNode.offsetHeight ** 2) * 2;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Otherwise we set the size to be the smaller of the element's height and width.
|
|
234
|
+
return Math.min(this.rootNode.offsetWidth, this.rootNode.offsetHeight);
|
|
235
|
+
}
|
|
236
|
+
}]);
|
|
237
|
+
}(PureComponent);
|
|
228
238
|
Ripple.defaultProps = {
|
|
229
239
|
className: '',
|
|
230
240
|
color: themeConfig.colors.dark,
|
package/RippleButton/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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 Ripple from "../Ripple";
|
|
@@ -9,34 +10,25 @@ import style from "../Button/style";
|
|
|
9
10
|
* The ripple button component is a special derivation of the basic button component
|
|
10
11
|
* that adds a ripple effect when clicked.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
get buttonProps() {
|
|
18
|
-
return {
|
|
19
|
-
className: `${this.props.className} ui-shared__ripple-button`,
|
|
20
|
-
disabled: this.props.disabled,
|
|
21
|
-
onClick: this.props.onClick,
|
|
22
|
-
flat: this.props.flat,
|
|
23
|
-
type: this.props.type,
|
|
24
|
-
wrapContent: false,
|
|
25
|
-
'aria-label': this.props['aria-label'],
|
|
26
|
-
'aria-haspopup': this.props['aria-haspopup']
|
|
27
|
-
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
let RippleButton = /*#__PURE__*/function (_Component) {
|
|
15
|
+
function RippleButton() {
|
|
16
|
+
return _Component.apply(this, arguments) || this;
|
|
28
17
|
}
|
|
29
|
-
|
|
18
|
+
_inheritsLoose(RippleButton, _Component);
|
|
19
|
+
var _proto = RippleButton.prototype;
|
|
30
20
|
/**
|
|
31
21
|
* Renders the component.
|
|
32
22
|
* @returns {JSX}
|
|
33
23
|
*/
|
|
34
|
-
render() {
|
|
24
|
+
_proto.render = function render() {
|
|
35
25
|
if (this.props.disabled) {
|
|
36
26
|
// Don't show the ripple effect when the button is disabled.
|
|
37
|
-
return /*#__PURE__*/
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
28
|
+
...this.buttonProps,
|
|
29
|
+
wrapContent: true,
|
|
30
|
+
children: this.props.children
|
|
31
|
+
});
|
|
40
32
|
}
|
|
41
33
|
const rippleProps = {
|
|
42
34
|
className: `${style.contentWrapper} ${this.props.rippleClassName}`,
|
|
@@ -44,11 +36,36 @@ class RippleButton extends Component {
|
|
|
44
36
|
size: this.props.rippleSize,
|
|
45
37
|
overflow: true
|
|
46
38
|
};
|
|
47
|
-
return /*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
40
|
+
...this.buttonProps,
|
|
41
|
+
testId: this.props.testId,
|
|
42
|
+
children: /*#__PURE__*/_jsx(Ripple, {
|
|
43
|
+
...rippleProps,
|
|
44
|
+
children: this.props.children
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return _createClass(RippleButton, [{
|
|
49
|
+
key: "buttonProps",
|
|
50
|
+
get:
|
|
51
|
+
/**
|
|
52
|
+
* Getter for the calculated button props.
|
|
53
|
+
* @returns {Object}
|
|
54
|
+
*/
|
|
55
|
+
function () {
|
|
56
|
+
return {
|
|
57
|
+
className: `${this.props.className} ui-shared__ripple-button`,
|
|
58
|
+
disabled: this.props.disabled,
|
|
59
|
+
onClick: this.props.onClick,
|
|
60
|
+
flat: this.props.flat,
|
|
61
|
+
type: this.props.type,
|
|
62
|
+
wrapContent: false,
|
|
63
|
+
'aria-label': this.props['aria-label'],
|
|
64
|
+
'aria-haspopup': this.props['aria-haspopup']
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}]);
|
|
68
|
+
}(Component);
|
|
52
69
|
RippleButton.defaultProps = {
|
|
53
70
|
...Button.defaultProps,
|
|
54
71
|
rippleClassName: '',
|
package/RippleButton/spec.js
CHANGED
|
@@ -5,40 +5,47 @@ import Button from '@shopgate/pwa-common/components/Button';
|
|
|
5
5
|
import Ripple from "../Ripple";
|
|
6
6
|
import styles from "../Button/style";
|
|
7
7
|
import RippleButton from "./index";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
9
|
describe('<RippleButton />', () => {
|
|
9
10
|
it('should render as a regular ripple button effect if type is omitted', () => {
|
|
10
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
11
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RippleButton, {
|
|
12
|
+
children: "Press me"
|
|
13
|
+
}));
|
|
11
14
|
expect(wrapper).toMatchSnapshot();
|
|
12
15
|
expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
|
|
13
16
|
});
|
|
14
17
|
it('should render as a regular ripple button if type is explicitly defined', () => {
|
|
15
|
-
const wrapper = mount(/*#__PURE__*/
|
|
16
|
-
type: "regular"
|
|
17
|
-
|
|
18
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
|
|
19
|
+
type: "regular",
|
|
20
|
+
children: "Press me"
|
|
21
|
+
}));
|
|
18
22
|
expect(trim(wrapper.find(Button).props().className)).toEqual(`ui-shared__button ${styles.regular(false).button} ui-shared__ripple-button`);
|
|
19
23
|
expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
|
|
20
24
|
expect(wrapper).toMatchSnapshot();
|
|
21
25
|
});
|
|
22
26
|
it('should render as a primary ripple button', () => {
|
|
23
|
-
const wrapper = mount(/*#__PURE__*/
|
|
24
|
-
type: "primary"
|
|
25
|
-
|
|
27
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
|
|
28
|
+
type: "primary",
|
|
29
|
+
children: "Press me"
|
|
30
|
+
}));
|
|
26
31
|
expect(trim(wrapper.find(Button).props().className)).toEqual(`ui-shared__button ${styles.primary(false).button} ui-shared__ripple-button`);
|
|
27
32
|
expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
|
|
28
33
|
expect(wrapper).toMatchSnapshot();
|
|
29
34
|
});
|
|
30
35
|
it('should render as a secondary ripple button', () => {
|
|
31
|
-
const wrapper = mount(/*#__PURE__*/
|
|
32
|
-
type: "secondary"
|
|
33
|
-
|
|
36
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
|
|
37
|
+
type: "secondary",
|
|
38
|
+
children: "Press me"
|
|
39
|
+
}));
|
|
34
40
|
expect(trim(wrapper.find(Button).props().className)).toEqual(`ui-shared__button ${styles.secondary(false).button} ui-shared__ripple-button`);
|
|
35
41
|
expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
|
|
36
42
|
expect(wrapper).toMatchSnapshot();
|
|
37
43
|
});
|
|
38
44
|
it('should render as a disabled ripple button', () => {
|
|
39
|
-
const wrapper = mount(/*#__PURE__*/
|
|
40
|
-
disabled: true
|
|
41
|
-
|
|
45
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
|
|
46
|
+
disabled: true,
|
|
47
|
+
children: "Press me"
|
|
48
|
+
}));
|
|
42
49
|
expect(wrapper.find(Button).props().disabled).toBe(true);
|
|
43
50
|
expect(wrapper).toMatchSnapshot();
|
|
44
51
|
});
|
|
@@ -6,9 +6,12 @@ import styles from "./style";
|
|
|
6
6
|
/**
|
|
7
7
|
* @returns {JSX}
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const CameraOverlay = () => /*#__PURE__*/_jsx(SurroundPortals, {
|
|
11
|
+
portalName: SCANNER_CAMERA,
|
|
12
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
13
|
+
className: styles,
|
|
14
|
+
children: /*#__PURE__*/_jsx("div", {})
|
|
15
|
+
})
|
|
16
|
+
});
|
|
14
17
|
export default CameraOverlay;
|
|
@@ -9,28 +9,32 @@ import styles from "./style";
|
|
|
9
9
|
* The FlashlightButton component.
|
|
10
10
|
* @returns {JSX.Element}
|
|
11
11
|
*/
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
const FlashlightButton = ({
|
|
13
14
|
flashlightState,
|
|
14
15
|
onToggle
|
|
15
|
-
}) => /*#__PURE__*/
|
|
16
|
-
portalName: SCANNER_FLASH
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
}) => /*#__PURE__*/_jsxs(SurroundPortals, {
|
|
17
|
+
portalName: SCANNER_FLASH,
|
|
18
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
19
|
+
className: styles.button,
|
|
20
|
+
onClick: onToggle,
|
|
21
|
+
role: "link",
|
|
22
|
+
type: "button",
|
|
23
|
+
"aria-label": i18n.text(flashlightState ? 'scanner.flashlight.switchOff' : 'scanner.flashlight.switchOn'),
|
|
24
|
+
children: /*#__PURE__*/_jsx(ToggleIcon, {
|
|
25
|
+
on: flashlightState,
|
|
26
|
+
onIcon: /*#__PURE__*/_jsx(FlashEnabledIcon, {
|
|
27
|
+
className: styles.icon
|
|
28
|
+
}),
|
|
29
|
+
offIcon: /*#__PURE__*/_jsx(FlashDisabledIcon, {
|
|
30
|
+
className: styles.icon
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
34
|
+
className: "sr-only",
|
|
35
|
+
role: "status",
|
|
36
|
+
"aria-live": "polite",
|
|
37
|
+
children: i18n.text(flashlightState ? 'scanner.flashlight.on' : 'scanner.flashlight.off')
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
36
40
|
export default FlashlightButton;
|
|
@@ -5,9 +5,11 @@ import { SCANNER_INSTRUCTIONS } from '@shopgate/engage/scanner/constants';
|
|
|
5
5
|
* The Scanner Instructions component.
|
|
6
6
|
* @returns {JSX.Element}
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const ScannerInstructions = () => /*#__PURE__*/_jsx(SurroundPortals, {
|
|
10
|
+
portalName: SCANNER_INSTRUCTIONS,
|
|
11
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
12
|
+
string: "scanner.instructions"
|
|
13
|
+
})
|
|
14
|
+
});
|
|
13
15
|
export default ScannerInstructions;
|
|
@@ -13,23 +13,28 @@ import styles from "./style";
|
|
|
13
13
|
* @param {Function} props.onToggleFlashlight The toggle event triggered by the user.
|
|
14
14
|
* @returns {React.ReactPortal} A React portal that renders the scanner bar in the AppFooter.
|
|
15
15
|
*/
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
const ScannerBar = ({
|
|
17
18
|
flashlightState,
|
|
18
19
|
onToggleFlashlight
|
|
19
|
-
}) => /*#__PURE__*/createPortal(/*#__PURE__*/
|
|
20
|
+
}) => /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(SurroundPortals, {
|
|
20
21
|
portalName: SCANNER_BAR,
|
|
21
22
|
portalProps: {
|
|
22
23
|
flashlightState,
|
|
23
24
|
onToggleFlashlight
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
},
|
|
26
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
27
|
+
className: `${styles.container} ui-shared__scanner-bar`,
|
|
28
|
+
children: [/*#__PURE__*/_jsx(Grid.Item, {
|
|
29
|
+
className: styles.column,
|
|
30
|
+
children: /*#__PURE__*/_jsx(FlashlightButton, {
|
|
31
|
+
onToggle: onToggleFlashlight,
|
|
32
|
+
flashlightState: flashlightState
|
|
33
|
+
})
|
|
34
|
+
}), /*#__PURE__*/_jsx(Grid.Item, {
|
|
35
|
+
className: styles.column,
|
|
36
|
+
children: /*#__PURE__*/_jsx(ScannerInstructions, {})
|
|
37
|
+
})]
|
|
38
|
+
})
|
|
39
|
+
}), document.getElementById('AppFooter'));
|
|
35
40
|
export default ScannerBar;
|
package/ScannerOverlay/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { Fragment, PureComponent } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import AppScanner from '@shopgate/pwa-core/classes/Scanner';
|
|
@@ -7,44 +8,52 @@ import ScannerBar from "./components/ScannerBar";
|
|
|
7
8
|
/**
|
|
8
9
|
* The scanner overlay component.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
let ScannerOverlay = /*#__PURE__*/function (_PureComponent) {
|
|
11
13
|
/**
|
|
12
14
|
* Initializes the component.
|
|
13
15
|
* @param {Object} props The components props.
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
function ScannerOverlay(props) {
|
|
18
|
+
var _this;
|
|
19
|
+
_this = _PureComponent.call(this, props) || this;
|
|
20
|
+
_this.handleToggleFlashlight = () => {
|
|
21
|
+
_this.setState({
|
|
19
22
|
flashlight: AppScanner.toggleFlashlight()
|
|
20
23
|
});
|
|
21
24
|
};
|
|
22
|
-
|
|
25
|
+
_this.state = {
|
|
23
26
|
flashlight: props.flashlight
|
|
24
27
|
};
|
|
28
|
+
return _this;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* @param {Object} nextProps New props to apply.
|
|
29
33
|
*/
|
|
30
|
-
|
|
34
|
+
_inheritsLoose(ScannerOverlay, _PureComponent);
|
|
35
|
+
var _proto = ScannerOverlay.prototype;
|
|
36
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
31
37
|
if (this.state.flashlight !== nextProps.flashlight) {
|
|
32
38
|
this.setState({
|
|
33
39
|
flashlight: nextProps.flashlight
|
|
34
40
|
});
|
|
35
41
|
}
|
|
36
|
-
}
|
|
42
|
+
};
|
|
37
43
|
/**
|
|
38
44
|
* Render the camera overlay and the bottom bar with its contents.
|
|
39
45
|
* @returns {JSX}
|
|
40
46
|
*/
|
|
41
|
-
render() {
|
|
42
|
-
return /*#__PURE__*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
47
|
+
_proto.render = function render() {
|
|
48
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
49
|
+
children: [/*#__PURE__*/_jsx(CameraOverlay, {}), /*#__PURE__*/_jsx(ScannerBar, {
|
|
50
|
+
flashlightState: this.state.flashlight,
|
|
51
|
+
onToggleFlashlight: this.handleToggleFlashlight
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return ScannerOverlay;
|
|
56
|
+
}(PureComponent);
|
|
48
57
|
ScannerOverlay.defaultProps = {
|
|
49
58
|
flashlight: false
|
|
50
59
|
};
|