@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
|
@@ -1,41 +1,47 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import { Component } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The Accordion container component.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
let AccordionContainer = /*#__PURE__*/function (_Component) {
|
|
8
9
|
/**
|
|
9
10
|
* Init
|
|
10
11
|
* @param {Object} props Props
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function AccordionContainer(props) {
|
|
14
|
+
var _this;
|
|
15
|
+
_this = _Component.call(this, props) || this;
|
|
16
|
+
_this.open = () => {
|
|
17
|
+
_this.setState({
|
|
16
18
|
open: true
|
|
17
19
|
});
|
|
18
20
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
_this.close = () => {
|
|
22
|
+
_this.setState({
|
|
21
23
|
open: false
|
|
22
24
|
});
|
|
23
25
|
};
|
|
24
|
-
|
|
26
|
+
_this.state = {
|
|
25
27
|
open: props.open
|
|
26
28
|
};
|
|
29
|
+
return _this;
|
|
27
30
|
}
|
|
31
|
+
_inheritsLoose(AccordionContainer, _Component);
|
|
32
|
+
var _proto = AccordionContainer.prototype;
|
|
28
33
|
/**
|
|
29
34
|
* @returns {JSX}
|
|
30
35
|
*/
|
|
31
|
-
render() {
|
|
36
|
+
_proto.render = function render() {
|
|
32
37
|
return this.props.children({
|
|
33
38
|
handleClose: this.close,
|
|
34
39
|
open: this.state.open,
|
|
35
40
|
handleOpen: this.open
|
|
36
41
|
});
|
|
37
|
-
}
|
|
38
|
-
|
|
42
|
+
};
|
|
43
|
+
return AccordionContainer;
|
|
44
|
+
}(Component);
|
|
39
45
|
AccordionContainer.defaultProps = {
|
|
40
46
|
open: false
|
|
41
47
|
};
|
|
@@ -5,10 +5,15 @@ import AccordionContainer from "./index";
|
|
|
5
5
|
/**
|
|
6
6
|
* @returns {JSX}
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const Child = () => /*#__PURE__*/_jsx("div", {});
|
|
9
10
|
describe('<AccordionContainer />', () => {
|
|
10
11
|
it('should render children with props', () => {
|
|
11
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
12
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(AccordionContainer, {
|
|
13
|
+
children: props => /*#__PURE__*/_jsx(Child, {
|
|
14
|
+
...props
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
12
17
|
const props = wrapper.find('Child').props();
|
|
13
18
|
expect(wrapper).toMatchSnapshot();
|
|
14
19
|
expect(props.open).toEqual(false);
|
|
@@ -16,7 +21,11 @@ describe('<AccordionContainer />', () => {
|
|
|
16
21
|
expect(typeof props.handleClose).toEqual('function');
|
|
17
22
|
});
|
|
18
23
|
it('should update children props when state changes', () => {
|
|
19
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
24
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(AccordionContainer, {
|
|
25
|
+
children: props => /*#__PURE__*/_jsx(Child, {
|
|
26
|
+
...props
|
|
27
|
+
})
|
|
28
|
+
}));
|
|
20
29
|
wrapper.setState({
|
|
21
30
|
open: true
|
|
22
31
|
});
|
package/ActionButton/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 IndicatorCircle from "../IndicatorCircle";
|
|
@@ -8,58 +9,71 @@ import styles from "./style";
|
|
|
8
9
|
/**
|
|
9
10
|
* The action button component.
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
let ActionButton = /*#__PURE__*/function (_Component) {
|
|
14
|
+
function ActionButton(...args) {
|
|
15
|
+
var _this;
|
|
16
|
+
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
14
17
|
/**
|
|
15
18
|
* The click handler
|
|
16
19
|
* @param {Object} event The event object for the click handler
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
_this.handleClick = event => {
|
|
19
22
|
const {
|
|
20
23
|
clickDelay
|
|
21
|
-
} =
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
+
} = _this.constructor;
|
|
25
|
+
if (_this.props.disableClickDelay) {
|
|
26
|
+
_this.props.onClick(event);
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
29
|
setTimeout(() => {
|
|
27
|
-
|
|
30
|
+
_this.props.onClick(event);
|
|
28
31
|
}, clickDelay);
|
|
29
32
|
};
|
|
33
|
+
return _this;
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @returns {Object}
|
|
34
|
-
*/
|
|
35
|
-
get buttonProps() {
|
|
36
|
-
const buttonProps = {
|
|
37
|
-
className: this.props.className,
|
|
38
|
-
disabled: this.props.disabled,
|
|
39
|
-
flat: this.props.flat,
|
|
40
|
-
type: this.props.type
|
|
41
|
-
};
|
|
42
|
-
return buttonProps;
|
|
43
|
-
}
|
|
35
|
+
_inheritsLoose(ActionButton, _Component);
|
|
36
|
+
var _proto = ActionButton.prototype;
|
|
44
37
|
/**
|
|
45
38
|
* The render function.
|
|
46
39
|
* @returns {JSX}
|
|
47
40
|
*/
|
|
48
|
-
render() {
|
|
41
|
+
_proto.render = function render() {
|
|
49
42
|
const containerClass = this.props.noGap ? styles.noGapContainer : styles.container;
|
|
50
43
|
if (this.props.loading) {
|
|
51
|
-
return /*#__PURE__*/
|
|
52
|
-
className: styles.containerCircle
|
|
53
|
-
|
|
44
|
+
return /*#__PURE__*/_jsx("div", {
|
|
45
|
+
className: styles.containerCircle,
|
|
46
|
+
children: /*#__PURE__*/_jsx(IndicatorCircle, {})
|
|
47
|
+
});
|
|
54
48
|
}
|
|
55
|
-
return /*#__PURE__*/
|
|
49
|
+
return /*#__PURE__*/_jsx("div", {
|
|
56
50
|
className: `ui-shared__action-button ${containerClass}`,
|
|
57
|
-
"data-test-id": this.props.testId
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
51
|
+
"data-test-id": this.props.testId,
|
|
52
|
+
children: /*#__PURE__*/_jsx(RippleButton, {
|
|
53
|
+
...this.buttonProps,
|
|
54
|
+
onClick: this.handleClick,
|
|
55
|
+
children: this.props.children
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return _createClass(ActionButton, [{
|
|
60
|
+
key: "buttonProps",
|
|
61
|
+
get:
|
|
62
|
+
/**
|
|
63
|
+
* Getter for the calculated button props.
|
|
64
|
+
* @returns {Object}
|
|
65
|
+
*/
|
|
66
|
+
function () {
|
|
67
|
+
const buttonProps = {
|
|
68
|
+
className: this.props.className,
|
|
69
|
+
disabled: this.props.disabled,
|
|
70
|
+
flat: this.props.flat,
|
|
71
|
+
type: this.props.type
|
|
72
|
+
};
|
|
73
|
+
return buttonProps;
|
|
74
|
+
}
|
|
75
|
+
}]);
|
|
76
|
+
}(Component);
|
|
63
77
|
ActionButton.clickDelay = 300;
|
|
64
78
|
ActionButton.defaultProps = {
|
|
65
79
|
...RippleButton.defaultProps,
|
package/ActionButton/spec.js
CHANGED
|
@@ -3,6 +3,7 @@ import { shallow } from 'enzyme';
|
|
|
3
3
|
import IndicatorCircle from "../IndicatorCircle";
|
|
4
4
|
import RippleButton from "../RippleButton";
|
|
5
5
|
import ActionButton from "./index";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
describe('<ActionButton />', () => {
|
|
7
8
|
let renderedElement;
|
|
8
9
|
let mockOnClick;
|
|
@@ -13,7 +14,10 @@ describe('<ActionButton />', () => {
|
|
|
13
14
|
* @param {Object} props The component props.
|
|
14
15
|
*/
|
|
15
16
|
const renderComponent = (props = {}) => {
|
|
16
|
-
renderedElement = shallow(/*#__PURE__*/
|
|
17
|
+
renderedElement = shallow(/*#__PURE__*/_jsx(ActionButton, {
|
|
18
|
+
...props,
|
|
19
|
+
children: "Action Button"
|
|
20
|
+
}));
|
|
17
21
|
};
|
|
18
22
|
describe('Given the component was mounted to the DOM', () => {
|
|
19
23
|
beforeEach(() => {
|
package/AddToCartButton/index.js
CHANGED
|
@@ -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 { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
@@ -10,13 +11,15 @@ import styles from "./style";
|
|
|
10
11
|
/**
|
|
11
12
|
* AddToCartButton component.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
let AddToCartButton = /*#__PURE__*/function (_Component) {
|
|
14
16
|
/**
|
|
15
17
|
* Constructor for the AddToCartButton component.
|
|
16
18
|
* @param {Object} props Props for the component.
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
function AddToCartButton(props) {
|
|
21
|
+
var _this;
|
|
22
|
+
_this = _Component.call(this, props) || this;
|
|
20
23
|
/**
|
|
21
24
|
* Handles the button click.
|
|
22
25
|
* - Show checkmark.
|
|
@@ -25,24 +28,24 @@ class AddToCartButton extends Component {
|
|
|
25
28
|
* - Show cart icon again.
|
|
26
29
|
* @param {Event} e Event
|
|
27
30
|
*/
|
|
28
|
-
|
|
31
|
+
_this.handleClick = e => {
|
|
29
32
|
// Ignore clicks when check mark or loading spinner is shown or the button is disabled.
|
|
30
|
-
if (
|
|
33
|
+
if (_this.state.showCheckmark || _this.props.isLoading || _this.props.isDisabled) {
|
|
31
34
|
return;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/** */
|
|
35
38
|
const handleCompletion = () => {
|
|
36
|
-
|
|
39
|
+
_this.setState({
|
|
37
40
|
showCheckmark: true
|
|
38
41
|
});
|
|
39
42
|
setTimeout(() => {
|
|
40
|
-
|
|
43
|
+
_this.setState({
|
|
41
44
|
showCheckmark: false
|
|
42
45
|
});
|
|
43
46
|
}, 900);
|
|
44
47
|
};
|
|
45
|
-
const result =
|
|
48
|
+
const result = _this.props.onClick(e);
|
|
46
49
|
if (result === false) {
|
|
47
50
|
// Do not trigger animation when adding to cart was aborted by the parent component (PWA-2764)
|
|
48
51
|
return;
|
|
@@ -68,23 +71,26 @@ class AddToCartButton extends Component {
|
|
|
68
71
|
* This is caused by CSS animations that get re-applied when
|
|
69
72
|
* setting an element from hidden (display: none) to visible.
|
|
70
73
|
*/
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
+
_this.handleCartAnimationEnd = () => {
|
|
75
|
+
if (_this.state.showCheckmark === false) {
|
|
76
|
+
_this.setState({
|
|
74
77
|
showCheckmark: null
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
|
-
|
|
80
|
+
_this.props.onReset();
|
|
78
81
|
};
|
|
79
|
-
|
|
82
|
+
_this.state = {
|
|
80
83
|
showCheckmark: null
|
|
81
84
|
};
|
|
85
|
+
return _this;
|
|
82
86
|
}
|
|
87
|
+
_inheritsLoose(AddToCartButton, _Component);
|
|
88
|
+
var _proto = AddToCartButton.prototype;
|
|
83
89
|
/**
|
|
84
90
|
* Renders the component
|
|
85
91
|
* @returns {JSX}
|
|
86
92
|
*/
|
|
87
|
-
render() {
|
|
93
|
+
_proto.render = function render() {
|
|
88
94
|
// Set initial base styles
|
|
89
95
|
let buttonStyle = styles.buttonReady;
|
|
90
96
|
let tickIconStyle = styles.icon;
|
|
@@ -162,7 +168,7 @@ class AddToCartButton extends Component {
|
|
|
162
168
|
if (this.props.noShadow) {
|
|
163
169
|
className = styles.buttonWrapperNoShadow(this.props.buttonSize, this.props.iconSize);
|
|
164
170
|
}
|
|
165
|
-
return /*#__PURE__*/
|
|
171
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
166
172
|
"data-test-id": "addToCartButton",
|
|
167
173
|
className: `ui-shared__add-to-cart-button ${this.props.className} ${className} ${buttonStyle}`,
|
|
168
174
|
onClick: this.handleClick,
|
|
@@ -170,24 +176,29 @@ class AddToCartButton extends Component {
|
|
|
170
176
|
"aria-label": this.props['aria-label'],
|
|
171
177
|
"aria-disabled": this.props.isDisabled,
|
|
172
178
|
ref: this.props.forwardedRef,
|
|
173
|
-
type: "button"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
179
|
+
type: "button",
|
|
180
|
+
children: [this.props.isLoading && /*#__PURE__*/_jsx("div", {
|
|
181
|
+
className: `${styles.icon} ${styles.spinnerIcon}`,
|
|
182
|
+
style: spinnerInlineStyle,
|
|
183
|
+
children: /*#__PURE__*/_jsx(IndicatorCircle, {
|
|
184
|
+
color: themeConfig.colors.primaryContrast,
|
|
185
|
+
strokeWidth: 5,
|
|
186
|
+
paused: !this.props.isLoading
|
|
187
|
+
})
|
|
188
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
189
|
+
className: tickIconStyle,
|
|
190
|
+
style: tickInlineStyle,
|
|
191
|
+
children: /*#__PURE__*/_jsx(TickIcon, {})
|
|
192
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
193
|
+
className: cartPlusIconStyle,
|
|
194
|
+
style: cartInlineStyle,
|
|
195
|
+
onAnimationEnd: this.handleCartAnimationEnd,
|
|
196
|
+
children: /*#__PURE__*/_jsx(CartPlusIcon, {})
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
return AddToCartButton;
|
|
201
|
+
}(Component);
|
|
191
202
|
AddToCartButton.defaultProps = {
|
|
192
203
|
'aria-hidden': false,
|
|
193
204
|
'aria-label': null,
|
package/AddToCartButton/mock.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
var _Class;
|
|
2
3
|
import React, { Component } from 'react';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
@@ -7,17 +8,28 @@ import PropTypes from 'prop-types';
|
|
|
7
8
|
* @deprecated
|
|
8
9
|
*/
|
|
9
10
|
// eslint-disable-next-line react/prefer-stateless-function
|
|
10
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
export const MockedAddToCartButton = (_Class = /*#__PURE__*/function (_Component) {
|
|
13
|
+
function MockedAddToCartButton() {
|
|
14
|
+
return _Component.apply(this, arguments) || this;
|
|
15
|
+
}
|
|
16
|
+
_inheritsLoose(MockedAddToCartButton, _Component);
|
|
17
|
+
var _proto = MockedAddToCartButton.prototype;
|
|
11
18
|
/**
|
|
12
19
|
* Renders mocked button.
|
|
13
20
|
* @return {JSX}
|
|
14
21
|
*/
|
|
15
|
-
render() {
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
_proto.render = function render() {
|
|
23
|
+
return (
|
|
24
|
+
/*#__PURE__*/
|
|
25
|
+
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
26
|
+
_jsx("button", {
|
|
27
|
+
onClick: this.props.onClick,
|
|
28
|
+
type: "button"
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
return MockedAddToCartButton;
|
|
33
|
+
}(Component), _Class.defaultProps = {
|
|
22
34
|
onClick: () => {}
|
|
23
35
|
}, _Class);
|
package/AddToCartButton/spec.js
CHANGED
|
@@ -7,11 +7,12 @@ import AddToCartButton from "./index";
|
|
|
7
7
|
* Flushes the promise queue.
|
|
8
8
|
* @returns {Promise}
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const flushMicrotasks = () => Promise.resolve();
|
|
11
12
|
describe('<AddToCartButton />', () => {
|
|
12
13
|
it('should render in loading state and should not be clickable', () => {
|
|
13
14
|
const spy = jest.fn(() => Promise.resolve());
|
|
14
|
-
const wrapper = mount(/*#__PURE__*/
|
|
15
|
+
const wrapper = mount(/*#__PURE__*/_jsx(AddToCartButton, {
|
|
15
16
|
onClick: spy,
|
|
16
17
|
isLoading: true,
|
|
17
18
|
isOrderable: true,
|
|
@@ -25,7 +26,7 @@ describe('<AddToCartButton />', () => {
|
|
|
25
26
|
});
|
|
26
27
|
it('should render with checkmark icon and should not be clickable the second time', async () => {
|
|
27
28
|
const spy = jest.fn(() => Promise.resolve());
|
|
28
|
-
const wrapper = mount(/*#__PURE__*/
|
|
29
|
+
const wrapper = mount(/*#__PURE__*/_jsx(AddToCartButton, {
|
|
29
30
|
onClick: spy,
|
|
30
31
|
isLoading: false,
|
|
31
32
|
isOrderable: true,
|
|
@@ -50,7 +51,7 @@ describe('<AddToCartButton />', () => {
|
|
|
50
51
|
});
|
|
51
52
|
it('should render with cart icon and should be clickable', async () => {
|
|
52
53
|
const spy = jest.fn(() => Promise.resolve());
|
|
53
|
-
const wrapper = mount(/*#__PURE__*/
|
|
54
|
+
const wrapper = mount(/*#__PURE__*/_jsx(AddToCartButton, {
|
|
54
55
|
onClick: spy,
|
|
55
56
|
isLoading: false,
|
|
56
57
|
isOrderable: true,
|
package/Availability/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import styles from "./style";
|
|
|
13
13
|
* @param {string} [props.className] CSS classes
|
|
14
14
|
* @return {JSX}
|
|
15
15
|
*/
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
const Availability = ({
|
|
17
18
|
text,
|
|
18
19
|
state,
|
|
@@ -29,10 +30,11 @@ const Availability = ({
|
|
|
29
30
|
if (state === AVAILABILITY_STATE_ALERT) {
|
|
30
31
|
style = styles.stateAlert;
|
|
31
32
|
}
|
|
32
|
-
return /*#__PURE__*/
|
|
33
|
+
return /*#__PURE__*/_jsx("div", {
|
|
33
34
|
className: `ui-shared__availability ${className} ${style}`,
|
|
34
|
-
"data-test-id": `availabilityText: ${text}
|
|
35
|
-
|
|
35
|
+
"data-test-id": `availabilityText: ${text}`,
|
|
36
|
+
children: text
|
|
37
|
+
});
|
|
36
38
|
};
|
|
37
39
|
Availability.defaultProps = {
|
|
38
40
|
className: '',
|
package/Availability/spec.js
CHANGED
|
@@ -2,22 +2,23 @@ import React from 'react';
|
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import { AVAILABILITY_STATE_OK, AVAILABILITY_STATE_WARNING, AVAILABILITY_STATE_ALERT } from '@shopgate/pwa-common-commerce/product/constants';
|
|
4
4
|
import Availability from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
describe('<Availability />', () => {
|
|
6
7
|
it('should not render when text is empty', () => {
|
|
7
|
-
const wrapper = mount(/*#__PURE__*/
|
|
8
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
|
|
8
9
|
text: ""
|
|
9
10
|
}));
|
|
10
11
|
expect(wrapper).toMatchSnapshot();
|
|
11
12
|
});
|
|
12
13
|
it('should not render by default if state is "ok"', () => {
|
|
13
|
-
const wrapper = mount(/*#__PURE__*/
|
|
14
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
|
|
14
15
|
state: AVAILABILITY_STATE_OK,
|
|
15
16
|
text: "Available"
|
|
16
17
|
}));
|
|
17
18
|
expect(wrapper).toMatchSnapshot();
|
|
18
19
|
});
|
|
19
20
|
it('should render if state is "ok" when "showWhenAvailable" is set', () => {
|
|
20
|
-
const wrapper = mount(/*#__PURE__*/
|
|
21
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
|
|
21
22
|
state: AVAILABILITY_STATE_OK,
|
|
22
23
|
text: "Available",
|
|
23
24
|
showWhenAvailable: true
|
|
@@ -25,14 +26,14 @@ describe('<Availability />', () => {
|
|
|
25
26
|
expect(wrapper).toMatchSnapshot();
|
|
26
27
|
});
|
|
27
28
|
it('should render if state is "warning"', () => {
|
|
28
|
-
const wrapper = mount(/*#__PURE__*/
|
|
29
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
|
|
29
30
|
state: AVAILABILITY_STATE_WARNING,
|
|
30
31
|
text: "Only 5 left"
|
|
31
32
|
}));
|
|
32
33
|
expect(wrapper).toMatchSnapshot();
|
|
33
34
|
});
|
|
34
35
|
it('should render if state is "warning"', () => {
|
|
35
|
-
const wrapper = mount(/*#__PURE__*/
|
|
36
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
|
|
36
37
|
state: AVAILABILITY_STATE_ALERT,
|
|
37
38
|
text: "Out of stock"
|
|
38
39
|
}));
|
package/Button/index.js
CHANGED
|
@@ -1,79 +1,94 @@
|
|
|
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 BaseButton from '@shopgate/pwa-common/components/Button';
|
|
5
6
|
import styles from "./style";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
8
|
/**
|
|
7
9
|
* The basic button component. This components applies Material Design styles and acts as
|
|
8
10
|
* base to more feature-rich button components such as ActionButton and RippleButton, but can
|
|
9
11
|
* also be used as standalone component or any other kind of new button.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @returns {Object}
|
|
15
|
-
*/
|
|
16
|
-
get style() {
|
|
17
|
-
const {
|
|
18
|
-
flat,
|
|
19
|
-
disabled
|
|
20
|
-
} = this.props;
|
|
21
|
-
switch (this.props.type) {
|
|
22
|
-
case 'plain':
|
|
23
|
-
return styles.plain();
|
|
24
|
-
case 'regular':
|
|
25
|
-
return styles.regular(disabled);
|
|
26
|
-
case 'simple':
|
|
27
|
-
return styles.simple(disabled);
|
|
28
|
-
default:
|
|
29
|
-
case 'primary':
|
|
30
|
-
return styles.primary(disabled, flat);
|
|
31
|
-
case 'secondary':
|
|
32
|
-
return styles.secondary(disabled, flat);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Getter for the calculated button props.
|
|
38
|
-
* @returns {Object}
|
|
39
|
-
*/
|
|
40
|
-
get buttonProps() {
|
|
41
|
-
const {
|
|
42
|
-
className,
|
|
43
|
-
disabled,
|
|
44
|
-
onClick,
|
|
45
|
-
testId,
|
|
46
|
-
type,
|
|
47
|
-
wrapContent,
|
|
48
|
-
flat,
|
|
49
|
-
...rest
|
|
50
|
-
} = this.props;
|
|
51
|
-
const buttonProps = {
|
|
52
|
-
className,
|
|
53
|
-
disabled,
|
|
54
|
-
onClick,
|
|
55
|
-
...rest
|
|
56
|
-
};
|
|
57
|
-
return buttonProps;
|
|
13
|
+
let Button = /*#__PURE__*/function (_Component) {
|
|
14
|
+
function Button() {
|
|
15
|
+
return _Component.apply(this, arguments) || this;
|
|
58
16
|
}
|
|
59
|
-
|
|
17
|
+
_inheritsLoose(Button, _Component);
|
|
18
|
+
var _proto = Button.prototype;
|
|
60
19
|
/**
|
|
61
20
|
* Renders the component.
|
|
62
21
|
* @return {JSX}
|
|
63
22
|
*/
|
|
64
|
-
render() {
|
|
23
|
+
_proto.render = function render() {
|
|
65
24
|
const {
|
|
66
25
|
style
|
|
67
26
|
} = this;
|
|
68
|
-
const content = this.props.wrapContent ? /*#__PURE__*/
|
|
69
|
-
className: style.content
|
|
70
|
-
|
|
71
|
-
|
|
27
|
+
const content = this.props.wrapContent ? /*#__PURE__*/_jsx("div", {
|
|
28
|
+
className: style.content,
|
|
29
|
+
children: this.props.children
|
|
30
|
+
}) : this.props.children;
|
|
31
|
+
return /*#__PURE__*/_jsx(BaseButton, {
|
|
32
|
+
...this.buttonProps,
|
|
72
33
|
className: `ui-shared__button ${style.button} ${this.props.className}`,
|
|
73
|
-
testId: this.props.testId
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
34
|
+
testId: this.props.testId,
|
|
35
|
+
children: content
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
return _createClass(Button, [{
|
|
39
|
+
key: "style",
|
|
40
|
+
get:
|
|
41
|
+
/**
|
|
42
|
+
* Getter for style depending on prop type.
|
|
43
|
+
* @returns {Object}
|
|
44
|
+
*/
|
|
45
|
+
function () {
|
|
46
|
+
const {
|
|
47
|
+
flat,
|
|
48
|
+
disabled
|
|
49
|
+
} = this.props;
|
|
50
|
+
switch (this.props.type) {
|
|
51
|
+
case 'plain':
|
|
52
|
+
return styles.plain();
|
|
53
|
+
case 'regular':
|
|
54
|
+
return styles.regular(disabled);
|
|
55
|
+
case 'simple':
|
|
56
|
+
return styles.simple(disabled);
|
|
57
|
+
default:
|
|
58
|
+
case 'primary':
|
|
59
|
+
return styles.primary(disabled, flat);
|
|
60
|
+
case 'secondary':
|
|
61
|
+
return styles.secondary(disabled, flat);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Getter for the calculated button props.
|
|
67
|
+
* @returns {Object}
|
|
68
|
+
*/
|
|
69
|
+
}, {
|
|
70
|
+
key: "buttonProps",
|
|
71
|
+
get: function () {
|
|
72
|
+
const {
|
|
73
|
+
className,
|
|
74
|
+
disabled,
|
|
75
|
+
onClick,
|
|
76
|
+
testId,
|
|
77
|
+
type,
|
|
78
|
+
wrapContent,
|
|
79
|
+
flat,
|
|
80
|
+
...rest
|
|
81
|
+
} = this.props;
|
|
82
|
+
const buttonProps = {
|
|
83
|
+
className,
|
|
84
|
+
disabled,
|
|
85
|
+
onClick,
|
|
86
|
+
...rest
|
|
87
|
+
};
|
|
88
|
+
return buttonProps;
|
|
89
|
+
}
|
|
90
|
+
}]);
|
|
91
|
+
}(Component);
|
|
77
92
|
Button.defaultProps = {
|
|
78
93
|
...BaseButton.defaultProps,
|
|
79
94
|
className: '',
|