@shopgate/pwa-ui-shared 7.30.0-alpha.10 → 7.30.0-alpha.11
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/PriceStriked/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 I18n from '@shopgate/pwa-common/components/I18n';
|
|
@@ -8,6 +9,7 @@ import styles from "./style";
|
|
|
8
9
|
* @param {HTMLElement} element The price element
|
|
9
10
|
* @returns {number} the calculated angle
|
|
10
11
|
*/
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
13
|
const calcAngle = element => {
|
|
12
14
|
/**
|
|
13
15
|
* If the element is in a hidden container the browser won't calculate it's size.
|
|
@@ -31,66 +33,76 @@ const calcAngle = element => {
|
|
|
31
33
|
* @param {string} [props.className] CSS classes
|
|
32
34
|
* @return {JSX}
|
|
33
35
|
*/
|
|
34
|
-
|
|
36
|
+
let PriceStriked = /*#__PURE__*/function (_Component) {
|
|
35
37
|
/**
|
|
36
38
|
* Constructor
|
|
37
39
|
* @param {Object} props The component props
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
function PriceStriked(props) {
|
|
42
|
+
var _this;
|
|
43
|
+
_this = _Component.call(this, props) || this;
|
|
41
44
|
/**
|
|
42
45
|
* Sets the calculated angle for the DOM element
|
|
43
46
|
* and returns true if succeeded.
|
|
44
47
|
* @returns {boolean}
|
|
45
48
|
*/
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
+
_this.setAngle = () => {
|
|
50
|
+
if (_this.element) {
|
|
51
|
+
_this.angle = calcAngle(_this.element);
|
|
49
52
|
return true;
|
|
50
53
|
}
|
|
51
54
|
return false;
|
|
52
55
|
};
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
_this.angle = null;
|
|
57
|
+
_this.element = null;
|
|
58
|
+
return _this;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
/**
|
|
58
62
|
* Updates the component one more time with the calculated angle
|
|
59
63
|
* based on the DOM element.
|
|
60
64
|
*/
|
|
61
|
-
|
|
65
|
+
_inheritsLoose(PriceStriked, _Component);
|
|
66
|
+
var _proto = PriceStriked.prototype;
|
|
67
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
62
68
|
if (this.setAngle()) {
|
|
63
69
|
this.forceUpdate();
|
|
64
70
|
}
|
|
65
|
-
}
|
|
71
|
+
};
|
|
66
72
|
/**
|
|
67
73
|
* Renders the component.
|
|
68
74
|
* @returns {JSX.Element}
|
|
69
75
|
*/
|
|
70
|
-
render() {
|
|
76
|
+
_proto.render = function render() {
|
|
71
77
|
const {
|
|
72
78
|
__,
|
|
73
79
|
_p
|
|
74
80
|
} = this.context.i18n();
|
|
75
81
|
const angleStyle = this.angle ? styles.getAngleStyle(this.angle) : '';
|
|
76
|
-
return /*#__PURE__*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
83
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
84
|
+
className: `${styles.basic} ${this.props.className} ${angleStyle} price-striked ui-shared__price-striked`,
|
|
85
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
86
|
+
"aria-hidden": true,
|
|
87
|
+
ref: ref => {
|
|
88
|
+
this.element = ref;
|
|
89
|
+
},
|
|
90
|
+
"data-test-id": `strikedPrice: ${this.props.value}`,
|
|
91
|
+
children: /*#__PURE__*/_jsx(I18n.Price, {
|
|
92
|
+
price: this.props.value,
|
|
93
|
+
currency: this.props.currency
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
97
|
+
className: "sr-only",
|
|
98
|
+
children: __('price.label_old_price', {
|
|
99
|
+
price: _p(this.props.value, this.props.currency, true)
|
|
100
|
+
})
|
|
101
|
+
})]
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
return PriceStriked;
|
|
105
|
+
}(Component);
|
|
94
106
|
PriceStriked.defaultProps = {
|
|
95
107
|
className: ''
|
|
96
108
|
};
|
|
@@ -8,6 +8,7 @@ import Ellipsis from '@shopgate/pwa-common/components/Ellipsis';
|
|
|
8
8
|
* @param {Object} props The component props.
|
|
9
9
|
* @returns {JSX}
|
|
10
10
|
*/
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const Properties = ({
|
|
12
13
|
lineClamp,
|
|
13
14
|
properties,
|
|
@@ -16,16 +17,18 @@ const Properties = ({
|
|
|
16
17
|
if (!properties.length) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
|
-
return /*#__PURE__*/
|
|
20
|
-
className: classNames(className, 'ui-shared__product-properties')
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
return /*#__PURE__*/_jsx("ul", {
|
|
21
|
+
className: classNames(className, 'ui-shared__product-properties'),
|
|
22
|
+
children: properties.map(({
|
|
23
|
+
label,
|
|
24
|
+
value
|
|
25
|
+
}) => /*#__PURE__*/_jsxs("li", {
|
|
26
|
+
children: [lineClamp && /*#__PURE__*/_jsx(Ellipsis, {
|
|
27
|
+
rows: lineClamp,
|
|
28
|
+
children: `${label}: ${value}`
|
|
29
|
+
}), !lineClamp && `${label}: ${value}`]
|
|
30
|
+
}, `${label}-${value}`))
|
|
31
|
+
});
|
|
29
32
|
};
|
|
30
33
|
Properties.defaultProps = {
|
|
31
34
|
className: null,
|
package/ProgressBar/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
var _ProgressBar;
|
|
2
3
|
import React, { Component } from 'react';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
5
|
import Transition from 'react-transition-group/Transition';
|
|
5
6
|
import UIEvents from '@shopgate/pwa-core/emitters/ui';
|
|
6
7
|
import styles from "./style";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
const duration = 150;
|
|
8
10
|
const transitionStyles = {
|
|
9
11
|
entering: {
|
|
@@ -24,24 +26,28 @@ const transitionStyles = {
|
|
|
24
26
|
* A component for visualizing any kind of progress.
|
|
25
27
|
* This component will show the current progress in a linear bar.
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
let ProgressBar = /*#__PURE__*/function (_Component) {
|
|
28
30
|
/**
|
|
29
31
|
* The constructor
|
|
30
32
|
* @param {Object} props The component props.
|
|
31
33
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
function ProgressBar(props) {
|
|
35
|
+
var _this;
|
|
36
|
+
_this = _Component.call(this, props) || this;
|
|
37
|
+
_this.state = {
|
|
35
38
|
isAnimating: props.isVisible,
|
|
36
39
|
isVisible: props.isVisible
|
|
37
40
|
};
|
|
41
|
+
return _this;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* Update the state based on props.
|
|
42
46
|
* @param {Object} nextProps The next set of props.
|
|
43
47
|
*/
|
|
44
|
-
|
|
48
|
+
_inheritsLoose(ProgressBar, _Component);
|
|
49
|
+
var _proto = ProgressBar.prototype;
|
|
50
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
45
51
|
if (this.props.isVisible === nextProps.isVisible) {
|
|
46
52
|
return;
|
|
47
53
|
}
|
|
@@ -58,38 +64,41 @@ class ProgressBar extends Component {
|
|
|
58
64
|
* @param {Object} nextProps The next set of props.
|
|
59
65
|
* @param {Object} nextState The next component state.
|
|
60
66
|
* @returns {boolean}
|
|
61
|
-
|
|
62
|
-
shouldComponentUpdate(nextProps, nextState) {
|
|
67
|
+
*/;
|
|
68
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
|
|
63
69
|
return this.state.isAnimating !== nextState.isAnimating || this.state.isVisible !== nextState.isVisible;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
/**
|
|
67
73
|
* Renders the component.
|
|
68
74
|
* @return {JSX}
|
|
69
|
-
|
|
70
|
-
render() {
|
|
75
|
+
*/;
|
|
76
|
+
_proto.render = function render() {
|
|
71
77
|
const animationClasses = [styles.innerElement];
|
|
72
78
|
|
|
73
79
|
// Add the animation if we need it.
|
|
74
80
|
if (this.state.isAnimating) {
|
|
75
81
|
animationClasses.push(styles.animating);
|
|
76
82
|
}
|
|
77
|
-
return /*#__PURE__*/
|
|
83
|
+
return /*#__PURE__*/_jsx(Transition, {
|
|
78
84
|
in: this.state.isVisible,
|
|
79
85
|
timeout: duration,
|
|
80
86
|
onExited: () => {
|
|
81
87
|
this.setState({
|
|
82
88
|
isAnimating: false
|
|
83
89
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
90
|
+
},
|
|
91
|
+
children: state => /*#__PURE__*/_jsx("div", {
|
|
92
|
+
className: `${styles.wrapper()} ui-shared__progress-bar`,
|
|
93
|
+
style: transitionStyles[state],
|
|
94
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
95
|
+
className: animationClasses.join(' ')
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
return ProgressBar;
|
|
101
|
+
}(Component);
|
|
93
102
|
_ProgressBar = ProgressBar;
|
|
94
103
|
ProgressBar.PROGRESS_BAR_SHOW = 'PROGRESS_BAR_SHOW';
|
|
95
104
|
ProgressBar.PROGRESS_BAR_HIDE = 'PROGRESS_BAR_HIDE';
|
package/ProgressBar/spec.js
CHANGED
|
@@ -2,9 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import Transition from 'react-transition-group/Transition';
|
|
4
4
|
import ProgressBar from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
describe('<ProgressBar />', () => {
|
|
6
7
|
it('renders an indeterminate progress bar.', () => {
|
|
7
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
8
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(ProgressBar, {
|
|
8
9
|
isVisible: true
|
|
9
10
|
}));
|
|
10
11
|
expect(wrapper).toMatchSnapshot();
|
package/RadioButton/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import BaseCheckbox from '@shopgate/pwa-common/components/Checkbox';
|
|
4
3
|
import CheckedIcon from "../icons/RadioCheckedIcon";
|
|
@@ -10,12 +9,14 @@ import styles from "./style";
|
|
|
10
9
|
* @param {Object} props The component properties.
|
|
11
10
|
* @returns {JSX}
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const RadioButton = props => /*#__PURE__*/_jsx(BaseCheckbox, {
|
|
14
|
+
...props,
|
|
15
|
+
checkedIcon: /*#__PURE__*/_jsx(CheckedIcon, {
|
|
15
16
|
className: styles.checkedIcon
|
|
16
17
|
}),
|
|
17
|
-
uncheckedIcon: /*#__PURE__*/
|
|
18
|
+
uncheckedIcon: /*#__PURE__*/_jsx(UncheckedIcon, {
|
|
18
19
|
className: styles.uncheckedIcon
|
|
19
20
|
})
|
|
20
|
-
})
|
|
21
|
+
});
|
|
21
22
|
export default RadioButton;
|
package/RadioButton/spec.js
CHANGED
|
@@ -3,9 +3,10 @@ import { mount } from 'enzyme';
|
|
|
3
3
|
import CheckedIcon from "../icons/RadioCheckedIcon";
|
|
4
4
|
import UncheckedIcon from "../icons/RadioUncheckedIcon";
|
|
5
5
|
import RadioButton from "./index";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
describe('RadioButton', () => {
|
|
7
8
|
it('should render selected RadioButton', () => {
|
|
8
|
-
const wrapper = mount(/*#__PURE__*/
|
|
9
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioButton, {
|
|
9
10
|
checked: true
|
|
10
11
|
}));
|
|
11
12
|
expect(wrapper.find(CheckedIcon).exists()).toBe(true);
|
|
@@ -13,7 +14,7 @@ describe('RadioButton', () => {
|
|
|
13
14
|
expect(wrapper).toMatchSnapshot();
|
|
14
15
|
});
|
|
15
16
|
it('should render unselected RadioButton', () => {
|
|
16
|
-
const wrapper = mount(/*#__PURE__*/
|
|
17
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioButton, {}));
|
|
17
18
|
expect(wrapper.find(CheckedIcon).exists()).toBe(false);
|
|
18
19
|
expect(wrapper.find(UncheckedIcon).exists()).toBe(true);
|
|
19
20
|
expect(wrapper).toMatchSnapshot();
|
package/RatingNumber/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { RATING_SCALE_DIVISOR } from "../RatingStars/constants";
|
|
|
10
10
|
* @param {string} props.className Class name.
|
|
11
11
|
* @returns {JSX.Element}
|
|
12
12
|
*/
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
const RatingNumber = ({
|
|
14
15
|
rating,
|
|
15
16
|
className
|
|
@@ -21,7 +22,7 @@ const RatingNumber = ({
|
|
|
21
22
|
if (Number.isNaN(number)) {
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
|
-
return /*#__PURE__*/
|
|
25
|
+
return /*#__PURE__*/_jsx(I18n.Number, {
|
|
25
26
|
number: number,
|
|
26
27
|
className: `${className} ui-shared__rating-number`,
|
|
27
28
|
fractions: 2
|
package/RatingStars/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 times from 'lodash/times';
|
|
@@ -9,7 +10,7 @@ import { RATING_SCALE_DIVISOR } from "./constants";
|
|
|
9
10
|
/**
|
|
10
11
|
* The available style keys for the rating stars.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const numStars = 5;
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -17,13 +18,18 @@ const numStars = 5;
|
|
|
17
18
|
* @param {Object} props The component props.
|
|
18
19
|
* @returns {JSX}
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
let RatingStars = /*#__PURE__*/function (_Component) {
|
|
22
|
+
function RatingStars() {
|
|
23
|
+
return _Component.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
_inheritsLoose(RatingStars, _Component);
|
|
26
|
+
var _proto = RatingStars.prototype;
|
|
21
27
|
/**
|
|
22
28
|
* Only update the component if the star rating changed.
|
|
23
29
|
* @param {Object} nextProps The next component props.
|
|
24
30
|
* @returns {boolean}
|
|
25
31
|
*/
|
|
26
|
-
shouldComponentUpdate(nextProps) {
|
|
32
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
27
33
|
return nextProps.value !== this.props.value;
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -31,8 +37,8 @@ class RatingStars extends Component {
|
|
|
31
37
|
* Returns textual version of stars for screen readers.
|
|
32
38
|
* @param {number} stars Number of stars.
|
|
33
39
|
* @returns {string}
|
|
34
|
-
|
|
35
|
-
getTextualFinal(stars) {
|
|
40
|
+
*/;
|
|
41
|
+
_proto.getTextualFinal = function getTextualFinal(stars) {
|
|
36
42
|
const {
|
|
37
43
|
__
|
|
38
44
|
} = this.context.i18n();
|
|
@@ -46,8 +52,8 @@ class RatingStars extends Component {
|
|
|
46
52
|
* Returns text for call to a
|
|
47
53
|
* @param {number} stars Number of stars.
|
|
48
54
|
* @returns {string}
|
|
49
|
-
|
|
50
|
-
getTextualCTA(stars) {
|
|
55
|
+
*/;
|
|
56
|
+
_proto.getTextualCTA = function getTextualCTA(stars) {
|
|
51
57
|
const {
|
|
52
58
|
__
|
|
53
59
|
} = this.context.i18n();
|
|
@@ -60,8 +66,8 @@ class RatingStars extends Component {
|
|
|
60
66
|
* Handles click on RatingStars.
|
|
61
67
|
* @param {Object} e SyntheticEvent.
|
|
62
68
|
* @param {number} pos Position/Index of clicked RatingStar.
|
|
63
|
-
|
|
64
|
-
handleSelection(e, pos) {
|
|
69
|
+
*/;
|
|
70
|
+
_proto.handleSelection = function handleSelection(e, pos) {
|
|
65
71
|
const {
|
|
66
72
|
onSelection
|
|
67
73
|
} = this.props;
|
|
@@ -72,8 +78,8 @@ class RatingStars extends Component {
|
|
|
72
78
|
/**
|
|
73
79
|
* Renders the component.
|
|
74
80
|
* @returns {JSX.Element}
|
|
75
|
-
|
|
76
|
-
render() {
|
|
81
|
+
*/;
|
|
82
|
+
_proto.render = function render() {
|
|
77
83
|
const {
|
|
78
84
|
value,
|
|
79
85
|
isSelectable
|
|
@@ -84,7 +90,7 @@ class RatingStars extends Component {
|
|
|
84
90
|
const size = styles.iconStyles[this.props.display].iconSize;
|
|
85
91
|
const className = [styles.container, this.props.className, 'ui-shared__rating-stars'].join(' ');
|
|
86
92
|
const iconClassName = [styles.iconStyles[this.props.display].iconStyle, styles.icon].join(' ');
|
|
87
|
-
const emptyStars = [
|
|
93
|
+
const emptyStars = [].concat(times(numStars, i => {
|
|
88
94
|
const pos = i + 1;
|
|
89
95
|
const starProps = {
|
|
90
96
|
className: iconClassName,
|
|
@@ -95,11 +101,14 @@ class RatingStars extends Component {
|
|
|
95
101
|
onClick: e => this.handleSelection(e, pos)
|
|
96
102
|
})
|
|
97
103
|
};
|
|
98
|
-
return /*#__PURE__*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
return /*#__PURE__*/_jsx("div", {
|
|
105
|
+
...starProps,
|
|
106
|
+
children: /*#__PURE__*/_jsx(StarIcon, {
|
|
107
|
+
size: size
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
}));
|
|
111
|
+
const filledStars = [].concat(times(numFullStars, i => {
|
|
103
112
|
const pos = i + 1;
|
|
104
113
|
const starProps = {
|
|
105
114
|
className: iconClassName,
|
|
@@ -111,27 +120,34 @@ class RatingStars extends Component {
|
|
|
111
120
|
onClick: e => this.handleSelection(e, pos)
|
|
112
121
|
})
|
|
113
122
|
};
|
|
114
|
-
return /*#__PURE__*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
return /*#__PURE__*/_jsx("div", {
|
|
124
|
+
...starProps,
|
|
125
|
+
children: /*#__PURE__*/_jsx(StarIcon, {
|
|
126
|
+
size: size
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}), times(numHalfStars, i => /*#__PURE__*/_jsx("div", {
|
|
118
130
|
className: iconClassName,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
})))
|
|
123
|
-
return /*#__PURE__*/
|
|
131
|
+
children: /*#__PURE__*/_jsx(StarHalfIcon, {
|
|
132
|
+
size: size
|
|
133
|
+
})
|
|
134
|
+
}, i + numFullStars)));
|
|
135
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
124
136
|
role: isSelectable ? undefined : 'img',
|
|
125
137
|
className: className,
|
|
126
138
|
"aria-label": this.getTextualFinal(ratedStars),
|
|
127
|
-
"data-test-id": `ratedStars: ${ratedStars}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
139
|
+
"data-test-id": `ratedStars: ${ratedStars}`,
|
|
140
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
141
|
+
className: `${styles.emptyStars} rating-stars-empty`,
|
|
142
|
+
children: emptyStars
|
|
143
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
144
|
+
className: `${styles.filledStars} rating-stars-filled`,
|
|
145
|
+
children: filledStars
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
return RatingStars;
|
|
150
|
+
}(Component);
|
|
135
151
|
/**
|
|
136
152
|
* Context types definition.
|
|
137
153
|
* @type {{i18n: function}}
|
package/RatingStars/spec.js
CHANGED
|
@@ -4,10 +4,11 @@ import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOpti
|
|
|
4
4
|
import StarIcon from "../icons/StarIcon";
|
|
5
5
|
import StarHalfIcon from "../icons/StarHalfIcon";
|
|
6
6
|
import RatingStars from "./index";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
const numEmptyStars = 5;
|
|
8
9
|
describe('<RatingStars />', () => {
|
|
9
10
|
it('renders with value of 50', () => {
|
|
10
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
11
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
|
|
11
12
|
value: 50
|
|
12
13
|
}), mockRenderOptions);
|
|
13
14
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -15,7 +16,7 @@ describe('<RatingStars />', () => {
|
|
|
15
16
|
expect(wrapper.find(StarHalfIcon).length).toBe(1);
|
|
16
17
|
});
|
|
17
18
|
it('renders with value of 0', () => {
|
|
18
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
19
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
|
|
19
20
|
value: 0
|
|
20
21
|
}), mockRenderOptions);
|
|
21
22
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -23,7 +24,7 @@ describe('<RatingStars />', () => {
|
|
|
23
24
|
expect(wrapper.find(StarHalfIcon).length).toBe(0);
|
|
24
25
|
});
|
|
25
26
|
it('renders with value of 100', () => {
|
|
26
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
27
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
|
|
27
28
|
value: 100
|
|
28
29
|
}), mockRenderOptions);
|
|
29
30
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -31,7 +32,7 @@ describe('<RatingStars />', () => {
|
|
|
31
32
|
expect(wrapper.find(StarHalfIcon).length).toBe(0);
|
|
32
33
|
});
|
|
33
34
|
it('should change rating on click', () => {
|
|
34
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
35
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
|
|
35
36
|
value: 100,
|
|
36
37
|
isSelectable: true
|
|
37
38
|
}), mockRenderOptions);
|
|
@@ -50,7 +51,7 @@ describe('<RatingStars />', () => {
|
|
|
50
51
|
});
|
|
51
52
|
it('should call onSelection callback when component is selectable', () => {
|
|
52
53
|
const spy = jest.fn();
|
|
53
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
54
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
|
|
54
55
|
value: 100,
|
|
55
56
|
isSelectable: true,
|
|
56
57
|
onSelection: e => {
|
|
@@ -79,7 +80,7 @@ describe('<RatingStars />', () => {
|
|
|
79
80
|
});
|
|
80
81
|
it('should NOT call onSelection callback when component is NOT selectable', () => {
|
|
81
82
|
const spy = jest.fn();
|
|
82
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
83
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
|
|
83
84
|
value: 100,
|
|
84
85
|
onSelection: spy
|
|
85
86
|
}), mockRenderOptions);
|
|
@@ -17,6 +17,7 @@ import style from "../../style";
|
|
|
17
17
|
* @param {number} props.y The y coordinate of the ripple center.
|
|
18
18
|
* @returns {JSX.Element}
|
|
19
19
|
*/
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
21
|
function RippleAnimation({
|
|
21
22
|
color,
|
|
22
23
|
duration,
|
|
@@ -74,21 +75,22 @@ function RippleAnimation({
|
|
|
74
75
|
el.addEventListener('transitionend', handleEnd);
|
|
75
76
|
return () => el.removeEventListener('transitionend', handleEnd);
|
|
76
77
|
}, [onComplete]);
|
|
77
|
-
return /*#__PURE__*/
|
|
78
|
+
return /*#__PURE__*/_jsx(Transition, {
|
|
78
79
|
in: inProp,
|
|
79
80
|
timeout: duration,
|
|
80
81
|
appear: true,
|
|
81
82
|
mountOnEnter: true,
|
|
82
83
|
unmountOnExit: true,
|
|
83
|
-
nodeRef: nodeRef
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
nodeRef: nodeRef,
|
|
85
|
+
children: state => /*#__PURE__*/_jsx("div", {
|
|
86
|
+
ref: nodeRef,
|
|
87
|
+
className: style.ripple,
|
|
88
|
+
style: {
|
|
89
|
+
...baseStyle,
|
|
90
|
+
...transitionStyles[state]
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
});
|
|
92
94
|
}
|
|
93
95
|
RippleAnimation.defaultProps = {
|
|
94
96
|
color: themeConfig.colors.dark,
|