@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,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import { UnwrappedVariantSelectModal as VariantSelectModal } from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
const message = 'This is the message.';
|
|
5
6
|
const title = 'This is the title.';
|
|
6
7
|
jest.mock('@shopgate/engage/a11y/components');
|
|
7
8
|
describe('<VariantSelectModal />', () => {
|
|
8
9
|
it('should render with minimal props', () => {
|
|
9
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
10
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
|
|
10
11
|
message: message,
|
|
11
12
|
actions: [],
|
|
12
13
|
navigate: () => {}
|
|
@@ -37,10 +38,12 @@ describe('<VariantSelectModal />', () => {
|
|
|
37
38
|
message,
|
|
38
39
|
title,
|
|
39
40
|
params,
|
|
40
|
-
actions: [
|
|
41
|
+
actions: [].concat(actions),
|
|
41
42
|
navigate: mockNavigate
|
|
42
43
|
};
|
|
43
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
44
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
|
|
45
|
+
...mockedProps
|
|
46
|
+
}));
|
|
44
47
|
expect(wrapper).toMatchSnapshot();
|
|
45
48
|
const reordered = wrapper.find('BasicDialog').props().actions;
|
|
46
49
|
const last = reordered.slice(-1)[0];
|
package/Dialog/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import TextMessageDialog from "./components/TextMessageDialog";
|
|
|
10
10
|
import HtmlContentDialog from "./components/HtmlContentDialog";
|
|
11
11
|
import BasicDialog from "./components/BasicDialog";
|
|
12
12
|
import VariantSelectModal from "./components/VariantSelectModal";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const dialogTypes = {
|
|
14
15
|
[DIALOG_TEXT_MESSAGE]: TextMessageDialog,
|
|
15
16
|
[DIALOG_HTML_CONTENT]: HtmlContentDialog,
|
|
@@ -74,7 +75,7 @@ const Dialog = ({
|
|
|
74
75
|
}
|
|
75
76
|
let dialogTitle = title;
|
|
76
77
|
if (titleParams) {
|
|
77
|
-
dialogTitle = /*#__PURE__*/
|
|
78
|
+
dialogTitle = /*#__PURE__*/_jsx(I18n.Text, {
|
|
78
79
|
string: title,
|
|
79
80
|
params: titleParams
|
|
80
81
|
});
|
|
@@ -105,15 +106,18 @@ const Dialog = ({
|
|
|
105
106
|
});
|
|
106
107
|
};
|
|
107
108
|
}, []);
|
|
108
|
-
return /*#__PURE__*/
|
|
109
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
109
110
|
classes: {
|
|
110
111
|
container: 'ui-shared__dialog-modal'
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
},
|
|
113
|
+
children: [/*#__PURE__*/_jsx(Backdrop, {
|
|
114
|
+
isVisible: true,
|
|
115
|
+
level: 0,
|
|
116
|
+
opacity: 30
|
|
117
|
+
}), /*#__PURE__*/_jsx(DialogComponent, {
|
|
118
|
+
...dialogProps
|
|
119
|
+
})]
|
|
120
|
+
});
|
|
117
121
|
};
|
|
118
122
|
Dialog.defaultProps = {
|
|
119
123
|
onConfirm: () => {},
|
package/Dialog/spec.js
CHANGED
|
@@ -3,18 +3,19 @@ import { shallow, ReactWrapper } from 'enzyme';
|
|
|
3
3
|
import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
|
|
4
4
|
import { MODAL_VARIANT_SELECT } from "./constants";
|
|
5
5
|
import Dialog from "./index";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
jest.mock("./components/VariantSelectModal", () => {
|
|
7
8
|
/**
|
|
8
9
|
* VariantSelectModal mock.
|
|
9
10
|
* @return {JSX}
|
|
10
11
|
*/
|
|
11
|
-
const VariantSelectModal = () => /*#__PURE__*/
|
|
12
|
+
const VariantSelectModal = () => /*#__PURE__*/_jsx("div", {});
|
|
12
13
|
return VariantSelectModal;
|
|
13
14
|
});
|
|
14
15
|
jest.mock('@shopgate/engage/components');
|
|
15
16
|
describe('<Dialog />', () => {
|
|
16
17
|
it('should render without props', () => {
|
|
17
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
18
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
18
19
|
modal: {
|
|
19
20
|
message: 'msg'
|
|
20
21
|
}
|
|
@@ -23,7 +24,7 @@ describe('<Dialog />', () => {
|
|
|
23
24
|
expect(wrapper.find('TextMessageDialog').length).toBe(1);
|
|
24
25
|
});
|
|
25
26
|
it('should render BasicDialog when no message given', () => {
|
|
26
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
27
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
27
28
|
modal: {
|
|
28
29
|
message: null
|
|
29
30
|
}
|
|
@@ -38,7 +39,7 @@ describe('<Dialog />', () => {
|
|
|
38
39
|
pipeline: '',
|
|
39
40
|
request: {}
|
|
40
41
|
};
|
|
41
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
42
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
42
43
|
modal: {
|
|
43
44
|
type: MODAL_PIPELINE_ERROR,
|
|
44
45
|
params
|
|
@@ -52,7 +53,7 @@ describe('<Dialog />', () => {
|
|
|
52
53
|
const params = {
|
|
53
54
|
productId: 'product_1'
|
|
54
55
|
};
|
|
55
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
56
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
56
57
|
modal: {
|
|
57
58
|
message: 'Test',
|
|
58
59
|
type: MODAL_VARIANT_SELECT,
|
|
@@ -70,7 +71,7 @@ describe('<Dialog />', () => {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
73
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
74
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
74
75
|
modal: {
|
|
75
76
|
title,
|
|
76
77
|
titleParams
|
package/DiscountBadge/index.js
CHANGED
|
@@ -11,22 +11,24 @@ import styles from "./style";
|
|
|
11
11
|
* @param {string} props.text The text contents of the component.
|
|
12
12
|
* @returns {JSX.Element}
|
|
13
13
|
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const DiscountBadge = ({
|
|
15
16
|
text,
|
|
16
17
|
className,
|
|
17
18
|
display,
|
|
18
19
|
discount
|
|
19
|
-
}) => /*#__PURE__*/
|
|
20
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
20
21
|
"data-test-id": text,
|
|
21
22
|
className: "ui-shared__discount-badge",
|
|
22
23
|
"aria-label": `${i18n.text('cart.discount')}: ${text}`,
|
|
23
|
-
tabIndex: -1
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
26
|
+
className: `${styles[display]} ${className} theme__discount-badge`,
|
|
27
|
+
string: text,
|
|
28
|
+
params: [discount],
|
|
29
|
+
"aria-hidden": true
|
|
30
|
+
})
|
|
31
|
+
});
|
|
30
32
|
DiscountBadge.defaultProps = {
|
|
31
33
|
className: '',
|
|
32
34
|
discount: null,
|
package/DiscountBadge/spec.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import DiscountBadge from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
jest.mock('@shopgate/engage/components');
|
|
5
6
|
describe('<DiscountBadge />', () => {
|
|
6
7
|
it('should render the text', () => {
|
|
7
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
8
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(DiscountBadge, {
|
|
8
9
|
text: "foo"
|
|
9
10
|
}));
|
|
10
11
|
expect(wrapper).toMatchSnapshot();
|
|
11
12
|
});
|
|
12
13
|
it('should render the text and discount', () => {
|
|
13
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
14
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(DiscountBadge, {
|
|
14
15
|
text: "SAVE {0}%",
|
|
15
16
|
discount: 20
|
|
16
17
|
}));
|
package/FavoritesButton/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 appConfig from '@shopgate/pwa-common/helpers/config';
|
|
@@ -12,95 +13,103 @@ import connect from "./connector";
|
|
|
12
13
|
/**
|
|
13
14
|
* The favorites button component.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
let FavoritesButton = /*#__PURE__*/function (_Component) {
|
|
16
18
|
/**
|
|
17
19
|
* Construct and init state
|
|
18
20
|
* @param {Object} props Component props
|
|
19
21
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
function FavoritesButton(props) {
|
|
23
|
+
var _this;
|
|
24
|
+
_this = _Component.call(this, props) || this;
|
|
22
25
|
/**
|
|
23
26
|
* Callback for the moment when the ripple animation is done.
|
|
24
27
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
_this.onRippleComplete = () => {
|
|
29
|
+
_this.props.onRippleComplete(_this.props.active);
|
|
27
30
|
};
|
|
28
31
|
/**
|
|
29
32
|
* Adds or removes a given product ID from the favorite list.
|
|
30
33
|
* @param {Object} event The click event object.
|
|
31
34
|
*/
|
|
32
|
-
|
|
35
|
+
_this.handleClick = event => {
|
|
33
36
|
event.preventDefault();
|
|
34
37
|
event.stopPropagation();
|
|
35
|
-
if (
|
|
38
|
+
if (_this.props.once && _this.clickedOnce) {
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
if (!
|
|
41
|
+
_this.clickedOnce = true;
|
|
42
|
+
if (!_this.props.productId) {
|
|
40
43
|
return;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// When wishlist item quantity is active, items cannot be removed via the button
|
|
44
|
-
if (!
|
|
45
|
-
|
|
47
|
+
if (!_this.props.active || _this.props.wishlistItemQuantityEnabled) {
|
|
48
|
+
_this.props.addFavorites(_this.props.productId);
|
|
46
49
|
} else {
|
|
47
50
|
setTimeout(() => {
|
|
48
|
-
|
|
49
|
-
},
|
|
51
|
+
_this.props.removeFavorites(_this.props.productId, _this.props.removeWithRelatives);
|
|
52
|
+
}, _this.props.removeThrottle);
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
|
-
|
|
55
|
+
_this.clickedOnce = false;
|
|
56
|
+
return _this;
|
|
53
57
|
}
|
|
58
|
+
_inheritsLoose(FavoritesButton, _Component);
|
|
59
|
+
var _proto = FavoritesButton.prototype;
|
|
54
60
|
/**
|
|
55
61
|
* Returns text for aria-label.
|
|
56
62
|
* @returns {string}
|
|
57
63
|
*/
|
|
58
|
-
getLabel() {
|
|
64
|
+
_proto.getLabel = function getLabel() {
|
|
59
65
|
const {
|
|
60
66
|
__
|
|
61
67
|
} = this.context.i18n();
|
|
62
68
|
const lang = this.props.active ? 'favorites.remove' : 'favorites.add';
|
|
63
69
|
return __(lang);
|
|
64
|
-
}
|
|
70
|
+
};
|
|
65
71
|
/**
|
|
66
72
|
* Renders the heart icon as filled or outlined, depending on the favorite button being active.
|
|
67
73
|
* @returns {JSX}
|
|
68
74
|
*/
|
|
69
|
-
renderIcon() {
|
|
75
|
+
_proto.renderIcon = function renderIcon() {
|
|
70
76
|
if (!this.props.loadWishlistOnAppStartEnabled || this.props.wishlistItemQuantityEnabled && !this.props.active) {
|
|
71
|
-
return /*#__PURE__*/
|
|
77
|
+
return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
|
|
72
78
|
}
|
|
73
79
|
if (this.props.wishlistItemQuantityEnabled && this.props.active) {
|
|
74
|
-
return /*#__PURE__*/
|
|
80
|
+
return /*#__PURE__*/_jsx(HeartPlus, {});
|
|
75
81
|
}
|
|
76
82
|
if (this.props.active) {
|
|
77
|
-
return /*#__PURE__*/
|
|
83
|
+
return /*#__PURE__*/_jsx(HeartIcon, {});
|
|
78
84
|
}
|
|
79
|
-
return /*#__PURE__*/
|
|
85
|
+
return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
/**
|
|
83
89
|
* Renders the component.
|
|
84
90
|
* @returns {JSX|null}
|
|
85
|
-
|
|
86
|
-
render() {
|
|
91
|
+
*/;
|
|
92
|
+
_proto.render = function render() {
|
|
87
93
|
if (!appConfig.hasFavorites) {
|
|
88
94
|
return null;
|
|
89
95
|
}
|
|
90
96
|
const className = this.props.noShadow ? styles.buttonFlat : styles.button;
|
|
91
|
-
return /*#__PURE__*/
|
|
97
|
+
return /*#__PURE__*/_jsx("button", {
|
|
92
98
|
"aria-label": this.getLabel(),
|
|
93
99
|
"aria-hidden": this.props['aria-hidden'],
|
|
94
100
|
className: `ui-shared__favorites-button ${className} ${this.props.className}`,
|
|
95
101
|
onClick: this.handleClick,
|
|
96
102
|
"data-test-id": "favoriteButton",
|
|
97
|
-
type: "button"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
103
|
+
type: "button",
|
|
104
|
+
children: /*#__PURE__*/_jsx(Ripple, {
|
|
105
|
+
className: `${styles.ripple} ${this.props.rippleClassName}`,
|
|
106
|
+
onComplete: this.onRippleComplete,
|
|
107
|
+
children: this.renderIcon()
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return FavoritesButton;
|
|
112
|
+
}(Component);
|
|
104
113
|
/**
|
|
105
114
|
* Context types definition.
|
|
106
115
|
* @type {{i18n: shim}}
|
package/FavoritesButton/spec.js
CHANGED
|
@@ -6,6 +6,7 @@ import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOpti
|
|
|
6
6
|
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
7
7
|
import FavoritesButton from "./index";
|
|
8
8
|
import { mockedStateEmpty, mockedStateOnList, mockedStateNotOnList } from "./mock";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
const mockedStore = configureStore();
|
|
10
11
|
const dispatcher = jest.fn();
|
|
11
12
|
jest.mock('@shopgate/pwa-common/helpers/config');
|
|
@@ -29,9 +30,12 @@ describe('<FavoritesButton />', () => {
|
|
|
29
30
|
}) => {
|
|
30
31
|
const store = mockedStore(mockedState);
|
|
31
32
|
store.dispatch = dispatcher;
|
|
32
|
-
return mount(/*#__PURE__*/
|
|
33
|
-
store: store
|
|
34
|
-
|
|
33
|
+
return mount(/*#__PURE__*/_jsx(Provider, {
|
|
34
|
+
store: store,
|
|
35
|
+
children: /*#__PURE__*/_jsx(FavoritesButton, {
|
|
36
|
+
...props
|
|
37
|
+
})
|
|
38
|
+
}), mockRenderOptions);
|
|
35
39
|
};
|
|
36
40
|
beforeEach(() => {
|
|
37
41
|
dispatcher.mockReset();
|