@shopgate/pwa-ui-shared 7.30.0-alpha.7 → 7.30.0-alpha.9
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 +39 -5
- package/AccordionContainer/spec.js +25 -2
- package/ActionButton/index.js +63 -7
- package/ActionButton/spec.js +63 -2
- package/ActionButton/style.js +22 -1
- package/AddToCartButton/index.js +184 -27
- package/AddToCartButton/mock.js +18 -4
- package/AddToCartButton/spec.js +65 -2
- package/AddToCartButton/style.js +127 -11
- package/Availability/index.js +34 -2
- package/Availability/spec.js +41 -1
- package/Availability/style.js +19 -1
- package/Button/index.js +76 -5
- package/Button/spec.js +33 -1
- package/Button/style.js +130 -21
- package/ButtonLink/connector.js +11 -2
- package/ButtonLink/index.js +44 -6
- package/ButtonLink/spec.js +23 -1
- package/Card/index.js +19 -2
- package/Card/style.js +11 -1
- package/CardList/components/Item/index.js +26 -2
- package/CardList/components/Item/style.js +7 -1
- package/CardList/index.js +34 -3
- package/CartTotalLine/components/Amount/index.js +28 -2
- package/CartTotalLine/components/Amount/style.js +8 -1
- package/CartTotalLine/components/Hint/index.js +23 -2
- package/CartTotalLine/components/Hint/style.js +12 -1
- package/CartTotalLine/components/Label/index.js +36 -2
- package/CartTotalLine/components/Label/style.js +17 -1
- package/CartTotalLine/components/Spacer/index.js +16 -2
- package/CartTotalLine/index.js +39 -2
- package/CartTotalLine/style.js +31 -1
- package/Checkbox/index.js +31 -2
- package/Checkbox/style.js +18 -1
- package/Chip/index.js +61 -2
- package/Chip/spec.js +24 -1
- package/Chip/style.js +71 -3
- package/ContextMenu/ContextMenu.hooks.js +6 -2
- package/ContextMenu/ContextMenuProvider.context.js +9 -3
- package/ContextMenu/ContextMenuProvider.js +21 -2
- package/ContextMenu/components/Item/index.js +67 -5
- package/ContextMenu/components/Item/style.js +32 -3
- package/ContextMenu/components/Position/index.js +61 -10
- package/ContextMenu/components/Position/style.js +11 -1
- package/ContextMenu/index.js +124 -3
- package/ContextMenu/spec.js +101 -2
- package/ContextMenu/style.js +45 -1
- package/Dialog/components/BasicDialog/index.js +5 -1
- package/Dialog/components/HtmlContentDialog/index.js +22 -2
- package/Dialog/components/HtmlContentDialog/spec.js +59 -1
- package/Dialog/components/PipelineErrorDialog/index.js +114 -25
- package/Dialog/components/PipelineErrorDialog/spec.js +92 -12
- package/Dialog/components/TextMessageDialog/index.js +28 -2
- package/Dialog/components/TextMessageDialog/spec.js +59 -1
- package/Dialog/components/VariantSelectModal/connector.js +11 -2
- package/Dialog/components/VariantSelectModal/index.js +65 -6
- package/Dialog/components/VariantSelectModal/spec.js +51 -2
- package/Dialog/constants.js +6 -1
- package/Dialog/index.js +114 -7
- package/Dialog/spec.js +81 -3
- package/DiscountBadge/index.js +30 -2
- package/DiscountBadge/spec.js +19 -1
- package/DiscountBadge/style.js +34 -2
- package/FavoritesButton/connector.js +18 -3
- package/FavoritesButton/index.js +118 -15
- package/FavoritesButton/mock.js +50 -4
- package/FavoritesButton/spec.js +120 -2
- package/FavoritesButton/style.js +26 -1
- package/Form/Builder/builders/buildCountryList.js +40 -6
- package/Form/Builder/builders/buildFormDefaults.js +35 -6
- package/Form/Builder/builders/buildFormElements.js +68 -10
- package/Form/Builder/builders/buildProvinceList.js +19 -2
- package/Form/Builder/builders/buildValidationErrorList.js +7 -2
- package/Form/Builder/classes/ActionListener/constants.js +22 -2
- package/Form/Builder/classes/ActionListener/index.js +441 -93
- package/Form/Builder/classes/ActionListener/spec.js +321 -19
- package/Form/Builder/components/CheckboxElement.js +35 -3
- package/Form/Builder/components/CountryElement.js +40 -3
- package/Form/Builder/components/ProvinceElement.js +40 -3
- package/Form/Builder/components/RadioElement.js +41 -3
- package/Form/Builder/components/SelectElement.js +39 -3
- package/Form/Builder/components/TextElement.js +49 -4
- package/Form/Builder/elementTypes.js +11 -1
- package/Form/Builder/index.js +298 -52
- package/Form/Builder/iso-3166-2.js +4943 -1
- package/Form/Builder/spec.js +308 -16
- package/Form/Checkbox/index.js +66 -4
- package/Form/Checkbox/style.js +25 -2
- package/Form/InfoField/index.js +50 -2
- package/Form/InfoField/spec.js +9 -1
- package/Form/InfoField/style.js +11 -1
- package/Form/Password/index.js +51 -6
- package/Form/Password/spec.js +34 -1
- package/Form/Password/style.js +11 -1
- package/Form/RadioGroup/components/Item/index.js +59 -3
- package/Form/RadioGroup/components/Item/style.js +32 -2
- package/Form/RadioGroup/index.js +101 -9
- package/Form/RadioGroup/spec.js +83 -3
- package/Form/RadioGroup/style.js +18 -2
- package/Form/Select/index.js +158 -10
- package/Form/Select/spec.js +36 -5
- package/Form/Select/style.js +27 -1
- package/Form/SelectContextChoices/index.js +77 -3
- package/Form/SelectContextChoices/spec.js +33 -4
- package/Form/SelectContextChoices/style.js +23 -1
- package/Form/TextField/index.js +92 -8
- package/Form/TextField/spec.js +110 -1
- package/Form/TextField/style.js +66 -8
- package/Form/index.js +54 -13
- package/FormElement/components/ErrorText/index.js +31 -2
- package/FormElement/components/ErrorText/style.js +13 -1
- package/FormElement/components/Label/index.js +35 -2
- package/FormElement/components/Label/style.js +76 -8
- package/FormElement/components/Placeholder/index.js +26 -2
- package/FormElement/components/Placeholder/style.js +48 -6
- package/FormElement/components/Underline/index.js +18 -2
- package/FormElement/components/Underline/style.js +51 -4
- package/FormElement/index.js +91 -6
- package/FormElement/spec.js +67 -2
- package/FormElement/style.js +13 -2
- package/Glow/index.js +90 -7
- package/Glow/spec.js +9 -1
- package/Glow/style.js +18 -1
- package/IndicatorCircle/index.js +33 -3
- package/IndicatorCircle/spec.js +28 -1
- package/IndicatorCircle/style.js +57 -3
- package/LoadingIndicator/index.js +29 -2
- package/LoadingIndicator/style.js +20 -1
- package/Manufacturer/index.js +20 -2
- package/Manufacturer/style.js +5 -1
- package/MessageBar/index.js +36 -2
- package/MessageBar/spec.js +79 -1
- package/MessageBar/style.js +38 -1
- package/NoResults/components/Icon/index.js +130 -2
- package/NoResults/components/Icon/style.js +17 -1
- package/NoResults/index.js +46 -2
- package/NoResults/style.js +31 -1
- package/Placeholder/index.js +25 -3
- package/Placeholder/style.js +11 -1
- package/PlaceholderLabel/index.js +27 -2
- package/PlaceholderLabel/spec.js +19 -1
- package/PlaceholderLabel/style.js +12 -1
- package/PlaceholderParagraph/index.js +36 -2
- package/PlaceholderParagraph/spec.js +19 -1
- package/Price/index.js +88 -7
- package/Price/style.js +22 -1
- package/PriceInfo/index.js +20 -2
- package/PriceInfo/style.js +5 -1
- package/PriceStriked/index.js +83 -12
- package/PriceStriked/style.js +33 -3
- package/ProductProperties/index.js +32 -2
- package/ProgressBar/index.js +101 -13
- package/ProgressBar/spec.js +13 -1
- package/ProgressBar/style.js +83 -2
- package/RadioButton/index.js +18 -2
- package/RadioButton/spec.js +21 -1
- package/RadioButton/style.js +21 -1
- package/RatingNumber/index.js +29 -2
- package/RatingStars/constants.js +2 -1
- package/RatingStars/index.js +130 -12
- package/RatingStars/spec.js +90 -3
- package/RatingStars/style.js +51 -2
- package/Ripple/components/RippleAnimation/index.js +88 -6
- package/Ripple/index.js +218 -40
- package/Ripple/style.js +18 -1
- package/RippleButton/index.js +52 -5
- package/RippleButton/spec.js +45 -1
- package/ScannerOverlay/components/CameraOverlay/index.js +13 -2
- package/ScannerOverlay/components/CameraOverlay/style.js +40 -1
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +34 -2
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +28 -1
- package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +11 -2
- package/ScannerOverlay/components/ScannerBar/index.js +31 -2
- package/ScannerOverlay/components/ScannerBar/style.js +20 -1
- package/ScannerOverlay/index.js +47 -7
- package/Sheet/components/Header/components/SearchBar/index.js +46 -2
- package/Sheet/components/Header/components/SearchBar/spec.js +21 -3
- package/Sheet/components/Header/components/SearchBar/style.js +47 -1
- package/Sheet/components/Header/index.js +75 -7
- package/Sheet/components/Header/spec.js +14 -1
- package/Sheet/components/Header/style.js +50 -1
- package/Sheet/index.js +170 -17
- package/Sheet/spec.js +85 -5
- package/Sheet/style.js +143 -2
- package/TaxDisclaimer/index.js +34 -4
- package/TaxDisclaimer/spec.js +31 -3
- package/TaxDisclaimer/style.js +9 -1
- package/TextField/components/ErrorText/index.js +33 -2
- package/TextField/components/ErrorText/style.js +25 -3
- package/TextField/components/FormElement/index.js +19 -2
- package/TextField/components/FormElement/style.js +32 -4
- package/TextField/components/Hint/index.js +21 -2
- package/TextField/components/Hint/style.js +40 -5
- package/TextField/components/Label/index.js +32 -3
- package/TextField/components/Label/style.js +68 -8
- package/TextField/components/Underline/index.js +19 -2
- package/TextField/components/Underline/style.js +51 -4
- package/TextField/index.js +189 -27
- package/TextField/spec.js +128 -3
- package/TextField/style.js +34 -4
- package/ToggleIcon/index.js +58 -8
- package/ToggleIcon/spec.js +35 -1
- package/icons/AccountBoxIcon.js +11 -2
- package/icons/AddMoreIcon.js +11 -2
- package/icons/ArrowDropIcon.js +11 -2
- package/icons/ArrowIcon.js +21 -2
- package/icons/BarcodeScannerIcon.js +11 -2
- package/icons/BoxIcon.js +11 -2
- package/icons/BrowseIcon.js +11 -2
- package/icons/BurgerIcon.js +11 -2
- package/icons/CalendarIcon.js +15 -3
- package/icons/CartCouponIcon.js +72 -2
- package/icons/CartIcon.js +11 -2
- package/icons/CartPlusIcon.js +11 -2
- package/icons/CheckIcon.js +11 -2
- package/icons/CheckedIcon.js +11 -2
- package/icons/ChevronIcon.js +11 -2
- package/icons/CreditCardIcon.js +11 -2
- package/icons/CrossIcon.js +11 -2
- package/icons/DescriptionIcon.js +11 -2
- package/icons/FilterIcon.js +11 -2
- package/icons/FlashDisabledIcon.js +11 -2
- package/icons/FlashEnabledIcon.js +11 -2
- package/icons/GridIcon.js +11 -2
- package/icons/HeartIcon.js +11 -2
- package/icons/HeartOutlineIcon.js +11 -2
- package/icons/HeartPlusIcon.js +12 -2
- package/icons/HeartPlusOutlineIcon.js +12 -2
- package/icons/HomeIcon.js +11 -2
- package/icons/InfoIcon.js +11 -2
- package/icons/InfoOutlineIcon.js +11 -2
- package/icons/ListIcon.js +11 -2
- package/icons/LocalShippingIcon.js +11 -2
- package/icons/LocationIcon.js +13 -3
- package/icons/LocatorIcon.js +11 -2
- package/icons/LockIcon.js +11 -2
- package/icons/LogoutIcon.js +11 -2
- package/icons/MagnifierIcon.js +11 -2
- package/icons/MapMarkerIcon.js +24 -3
- package/icons/MoreIcon.js +11 -2
- package/icons/MoreVertIcon.js +11 -2
- package/icons/NotificationIcon.js +14 -3
- package/icons/PersonIcon.js +12 -2
- package/icons/PhoneIcon.js +13 -3
- package/icons/PlaceholderIcon.js +11 -2
- package/icons/RadioCheckedIcon.js +11 -2
- package/icons/RadioUncheckedIcon.js +11 -2
- package/icons/SecurityIcon.js +11 -2
- package/icons/ShippingMethodIcon.js +18 -3
- package/icons/ShoppingCartIcon.js +11 -2
- package/icons/SortIcon.js +11 -2
- package/icons/StarHalfIcon.js +18 -2
- package/icons/StarIcon.js +18 -2
- package/icons/StarOutlineIcon.js +11 -2
- package/icons/StopIcon.js +11 -2
- package/icons/TickIcon.js +11 -2
- package/icons/TimeIcon.js +14 -3
- package/icons/TrashIcon.js +11 -2
- package/icons/TrashOutlineIcon.js +12 -2
- package/icons/UncheckedIcon.js +11 -2
- package/icons/ViewListIcon.js +11 -2
- package/icons/VisibilityIcon.js +11 -2
- package/icons/VisibilityOffIcon.js +11 -2
- package/icons/WarningIcon.js +11 -2
- package/index.js +13 -1
- package/package.json +5 -5
package/ButtonLink/index.js
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import ActionButton from "../ActionButton";
|
|
5
|
+
import connect from "./connector";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* Simple wrapper around ActionButton so it's easy to render buttons which behave as links.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
*/
|
|
10
|
+
class ButtonLink extends Component {
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
13
|
+
/**
|
|
14
|
+
* Opens the given url on click.
|
|
15
|
+
* @returns {undefined}
|
|
16
|
+
*/
|
|
17
|
+
this.handleClick = () => {
|
|
18
|
+
this.props.navigate(this.props.href);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
7
22
|
* Renders an ActionButton and handles link handling.
|
|
8
23
|
* @returns {JSX.Element}
|
|
9
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
render() {
|
|
26
|
+
const {
|
|
27
|
+
children,
|
|
28
|
+
href,
|
|
29
|
+
navigate,
|
|
30
|
+
...props
|
|
31
|
+
} = this.props;
|
|
32
|
+
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
33
|
+
className: "ui-shared__button-link",
|
|
34
|
+
onClick: this.handleClick,
|
|
35
|
+
type: "secondary"
|
|
36
|
+
}, props), children);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
ButtonLink.defaultProps = {
|
|
40
|
+
disabled: false,
|
|
41
|
+
className: '',
|
|
42
|
+
navigate: () => {},
|
|
43
|
+
noGap: false,
|
|
44
|
+
flat: true
|
|
45
|
+
};
|
|
46
|
+
export default connect(ButtonLink);
|
|
47
|
+
export { ButtonLink as UnwrappedButtonLink };
|
package/ButtonLink/spec.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import ActionButton from "../ActionButton";
|
|
4
|
+
import { UnwrappedButtonLink as ButtonLink } from "./index";
|
|
5
|
+
describe('<ButtonLink>', () => {
|
|
6
|
+
describe('On click action', () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
ActionButton.clickDelay = 0;
|
|
9
|
+
});
|
|
10
|
+
it('should create component and open page on click', () => {
|
|
11
|
+
const mockedNavigate = jest.fn();
|
|
12
|
+
const link = 'https://example.com';
|
|
13
|
+
const component = shallow(/*#__PURE__*/React.createElement(ButtonLink, {
|
|
14
|
+
href: link,
|
|
15
|
+
navigate: mockedNavigate
|
|
16
|
+
}, "Text inside"));
|
|
17
|
+
expect(component).toMatchSnapshot();
|
|
18
|
+
component.simulate('click');
|
|
19
|
+
expect(mockedNavigate).toHaveBeenCalledTimes(1);
|
|
20
|
+
expect(mockedNavigate).toHaveBeenCalledWith(link);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
package/Card/index.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styles from "./style";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* Renders the card component.
|
|
3
7
|
* @param {Object} props The component properties.
|
|
4
8
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const Card = ({
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
id
|
|
14
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: `ui-shared__card ${styles} ${className}`,
|
|
16
|
+
id: id
|
|
17
|
+
}, children);
|
|
18
|
+
Card.defaultProps = {
|
|
19
|
+
className: '',
|
|
20
|
+
id: null
|
|
21
|
+
};
|
|
22
|
+
export default Card;
|
package/Card/style.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig, themeName } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const isIOS = themeName.includes('ios');
|
|
4
|
+
export default css({
|
|
5
|
+
boxShadow: themeConfig.shadows.productCard,
|
|
6
|
+
margin: '5px 5px 10px',
|
|
7
|
+
borderRadius: isIOS ? 10 : 2,
|
|
8
|
+
background: themeConfig.colors.light,
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
position: 'relative'
|
|
11
|
+
}).toString();
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
import React,{Children}
|
|
1
|
+
import React, { Children } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ListItem from '@shopgate/pwa-common/components/List/components/Item';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The Card List Item component implemented as class so that ref prop is available.
|
|
3
8
|
* @param {Object} props The component props.
|
|
4
9
|
* @return {JSX}
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const Item = ({
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
isSelected
|
|
15
|
+
}) => {
|
|
16
|
+
if (!Children.count(children)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /*#__PURE__*/React.createElement(ListItem, {
|
|
20
|
+
className: `${styles} ${className}`,
|
|
21
|
+
isSelected: isSelected
|
|
22
|
+
}, children);
|
|
23
|
+
};
|
|
24
|
+
Item.defaultProps = {
|
|
25
|
+
children: null,
|
|
26
|
+
className: null,
|
|
27
|
+
isSelected: false
|
|
28
|
+
};
|
|
29
|
+
export default Item;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
export default css({
|
|
4
|
+
background: themeConfig.colors.light,
|
|
5
|
+
marginBottom: themeConfig.variables.gap.small / 2,
|
|
6
|
+
position: 'relative'
|
|
7
|
+
}).toString();
|
package/CardList/index.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { Component, Children, isValidElement } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import List from '@shopgate/pwa-common/components/List';
|
|
4
|
+
import Item from "./components/Item";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The CardList component.
|
|
3
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
class CardList extends Component {
|
|
10
|
+
/**
|
|
4
11
|
* Renders the component.
|
|
5
12
|
* @return {JSX}
|
|
6
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
render() {
|
|
15
|
+
const {
|
|
16
|
+
children,
|
|
17
|
+
className
|
|
18
|
+
} = this.props;
|
|
19
|
+
if (!Children.count(children)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/React.createElement(List, {
|
|
23
|
+
className: `ui-shared__card-list ${className}`
|
|
24
|
+
}, Children.map(children, child => {
|
|
25
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return child;
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
CardList.Item = Item;
|
|
33
|
+
CardList.defaultProps = {
|
|
34
|
+
children: null,
|
|
35
|
+
className: ''
|
|
36
|
+
};
|
|
37
|
+
export default CardList;
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The Amount component.
|
|
3
8
|
* @param {Object} props The component props.
|
|
4
9
|
* @return {JSX}
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const Amount = ({
|
|
12
|
+
amount,
|
|
13
|
+
currency
|
|
14
|
+
}) => {
|
|
15
|
+
if (amount === null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: styles.amount
|
|
20
|
+
}, typeof amount === 'string' && /*#__PURE__*/React.createElement(I18n.Text, {
|
|
21
|
+
string: amount
|
|
22
|
+
}), typeof amount === 'number' && /*#__PURE__*/React.createElement(I18n.Price, {
|
|
23
|
+
price: amount,
|
|
24
|
+
currency: currency
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
Amount.defaultProps = {
|
|
28
|
+
amount: null,
|
|
29
|
+
currency: null
|
|
30
|
+
};
|
|
31
|
+
export default Amount;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The Hint component.
|
|
3
8
|
* @param {Object} props The component props.
|
|
4
9
|
* @return {JSX|null}
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const Hint = ({
|
|
12
|
+
hint
|
|
13
|
+
}) => {
|
|
14
|
+
if (hint === null) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: styles.hint
|
|
19
|
+
}, /*#__PURE__*/React.createElement(I18n.Text, {
|
|
20
|
+
string: hint
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
Hint.defaultProps = {
|
|
24
|
+
hint: null
|
|
25
|
+
};
|
|
26
|
+
export default Hint;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const {
|
|
4
|
+
variables
|
|
5
|
+
} = themeConfig;
|
|
6
|
+
const hint = css({
|
|
7
|
+
paddingLeft: variables.gap.small,
|
|
8
|
+
order: 5
|
|
9
|
+
}).toString();
|
|
10
|
+
export default {
|
|
11
|
+
hint
|
|
12
|
+
};
|
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { I18n } from '@shopgate/engage/components';
|
|
5
|
+
import styles from "./style";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* The ShippingCostsLabel component.
|
|
3
9
|
* @param {Object} props The component props.
|
|
4
10
|
* @return {JSX|null}
|
|
5
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
function Label({
|
|
13
|
+
label,
|
|
14
|
+
showSeparator,
|
|
15
|
+
labelParams,
|
|
16
|
+
suffix
|
|
17
|
+
}) {
|
|
18
|
+
if (!label) {
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: styles.label
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: styles.label
|
|
25
|
+
}, /*#__PURE__*/React.createElement(I18n.Text, {
|
|
26
|
+
string: label,
|
|
27
|
+
params: labelParams,
|
|
28
|
+
className: classNames({
|
|
29
|
+
[styles.labelWithSuffix]: !!suffix
|
|
30
|
+
})
|
|
31
|
+
}), suffix, `${showSeparator ? ':' : ''}`);
|
|
32
|
+
}
|
|
33
|
+
Label.defaultProps = {
|
|
34
|
+
label: null,
|
|
35
|
+
suffix: null,
|
|
36
|
+
showSeparator: true,
|
|
37
|
+
labelParams: {}
|
|
38
|
+
};
|
|
39
|
+
export default Label;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const {
|
|
4
|
+
variables
|
|
5
|
+
} = themeConfig;
|
|
6
|
+
const label = css({
|
|
7
|
+
flexGrow: 1,
|
|
8
|
+
paddingRight: variables.gap.small,
|
|
9
|
+
order: 3
|
|
10
|
+
}).toString();
|
|
11
|
+
const labelWithSuffix = css({
|
|
12
|
+
paddingRight: variables.gap.small
|
|
13
|
+
});
|
|
14
|
+
export default {
|
|
15
|
+
label,
|
|
16
|
+
labelWithSuffix
|
|
17
|
+
};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {props} The component props
|
|
3
6
|
* @returns {JSX}
|
|
4
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const Spacer = ({
|
|
9
|
+
children,
|
|
10
|
+
className
|
|
11
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: className
|
|
13
|
+
}, children);
|
|
14
|
+
Spacer.defaultProps = {
|
|
15
|
+
children: null,
|
|
16
|
+
className: null
|
|
17
|
+
};
|
|
18
|
+
export default Spacer;
|
package/CartTotalLine/index.js
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import Label from "./components/Label";
|
|
5
|
+
import Amount from "./components/Amount";
|
|
6
|
+
import Hint from "./components/Hint";
|
|
7
|
+
import Spacer from "./components/Spacer";
|
|
8
|
+
import styles from "./style";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* @returns {JSX}
|
|
3
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const CartTotalLine = ({
|
|
14
|
+
children,
|
|
15
|
+
type,
|
|
16
|
+
isDisabled,
|
|
17
|
+
className
|
|
18
|
+
}) => {
|
|
19
|
+
if (!children) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: classNames(className, `ui-shared__cart-total-line ui-shared__cart-${type}-line`, styles.line, {
|
|
24
|
+
[styles.disabled]: isDisabled,
|
|
25
|
+
[styles[type] || styles.base]: true
|
|
26
|
+
}),
|
|
27
|
+
"data-test-id": `${type}CartTotal`
|
|
28
|
+
}, children);
|
|
29
|
+
};
|
|
30
|
+
CartTotalLine.defaultProps = {
|
|
31
|
+
children: null,
|
|
32
|
+
className: null,
|
|
33
|
+
isDisabled: false,
|
|
34
|
+
type: null
|
|
35
|
+
};
|
|
36
|
+
CartTotalLine.Label = Label;
|
|
37
|
+
CartTotalLine.Amount = Amount;
|
|
38
|
+
CartTotalLine.Hint = Hint;
|
|
39
|
+
CartTotalLine.Spacer = Spacer;
|
|
40
|
+
export default CartTotalLine;
|
package/CartTotalLine/style.js
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const {
|
|
4
|
+
colors
|
|
5
|
+
} = themeConfig;
|
|
6
|
+
const disabled = css({
|
|
7
|
+
color: `${colors.shade4} !important`
|
|
8
|
+
}).toString();
|
|
9
|
+
const base = css({
|
|
10
|
+
color: colors.shade9
|
|
11
|
+
}).toString();
|
|
12
|
+
const subTotal = css({
|
|
13
|
+
color: `${colors.dark}`
|
|
14
|
+
}).toString();
|
|
15
|
+
const grandTotal = css({
|
|
16
|
+
color: `${colors.dark}`,
|
|
17
|
+
fontSize: '1rem !important'
|
|
18
|
+
}).toString();
|
|
19
|
+
const line = css({
|
|
20
|
+
display: 'flex',
|
|
21
|
+
justifyContent: 'space-between',
|
|
22
|
+
fontSize: '0.875rem',
|
|
23
|
+
alignItems: 'baseline'
|
|
24
|
+
}).toString();
|
|
25
|
+
export default {
|
|
26
|
+
subTotal,
|
|
27
|
+
grandTotal,
|
|
28
|
+
base,
|
|
29
|
+
line,
|
|
30
|
+
disabled
|
|
31
|
+
};
|
package/Checkbox/index.js
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import BaseCheckbox from '@shopgate/pwa-common/components/Checkbox';
|
|
6
|
+
import CheckedIcon from "../icons/CheckedIcon";
|
|
7
|
+
import UncheckedIcon from "../icons/UncheckedIcon";
|
|
8
|
+
import styles from "./style";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* The checkbox template component.
|
|
3
12
|
* @param {Object} props The component props
|
|
4
13
|
* @param {string} props.className Class for the underlying Checkbox component
|
|
5
14
|
* @param {string} props.checkedClassName Class for checked icon.
|
|
6
15
|
* @param {string} props.unCheckedClassName Class for unchecked icon.
|
|
7
16
|
* @returns {JSX.Element}
|
|
8
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
const Checkbox = ({
|
|
19
|
+
checkedClassName,
|
|
20
|
+
unCheckedClassName,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}) => /*#__PURE__*/React.createElement(BaseCheckbox, _extends({}, props, {
|
|
24
|
+
className: `ui-shared__checkbox ${className}`,
|
|
25
|
+
checkedIcon: /*#__PURE__*/React.createElement(CheckedIcon, {
|
|
26
|
+
className: classNames(styles.icon, checkedClassName, 'checkedIcon')
|
|
27
|
+
}),
|
|
28
|
+
uncheckedIcon: /*#__PURE__*/React.createElement(UncheckedIcon, {
|
|
29
|
+
className: classNames(styles.icon, unCheckedClassName, 'uncheckedIcon')
|
|
30
|
+
})
|
|
31
|
+
}));
|
|
32
|
+
Checkbox.defaultProps = {
|
|
33
|
+
checkedClassName: styles.checkedIcon,
|
|
34
|
+
className: '',
|
|
35
|
+
unCheckedClassName: styles.uncheckedIcon
|
|
36
|
+
};
|
|
37
|
+
export default Checkbox;
|
package/Checkbox/style.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const icon = css({
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24,
|
|
6
|
+
flexShrink: 0
|
|
7
|
+
}).toString();
|
|
8
|
+
const checkedIcon = css({
|
|
9
|
+
color: `var(--color-secondary, ${themeConfig.colors.accent})`
|
|
10
|
+
}).toString();
|
|
11
|
+
const uncheckedIcon = css({
|
|
12
|
+
color: themeConfig.colors.shade6
|
|
13
|
+
}).toString();
|
|
14
|
+
export default {
|
|
15
|
+
icon,
|
|
16
|
+
checkedIcon,
|
|
17
|
+
uncheckedIcon
|
|
18
|
+
};
|
package/Chip/index.js
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
|
-
import React,{useRef,useCallback,useEffect}
|
|
1
|
+
import React, { useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Button from '@shopgate/pwa-common/components/Button';
|
|
4
|
+
import ResponsiveContainer from '@shopgate/engage/components/ResponsiveContainer';
|
|
5
|
+
import CrossIcon from "../icons/CrossIcon";
|
|
6
|
+
import styles from "./style";
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* The chip component.
|
|
3
10
|
* @param {Object} props The component props.
|
|
4
11
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
function Chip(props) {
|
|
14
|
+
const {
|
|
15
|
+
removable,
|
|
16
|
+
children,
|
|
17
|
+
id,
|
|
18
|
+
onClick,
|
|
19
|
+
onRemove,
|
|
20
|
+
invert,
|
|
21
|
+
removeLabel,
|
|
22
|
+
editLabel
|
|
23
|
+
} = props;
|
|
24
|
+
const ref = useRef(null);
|
|
25
|
+
const handleRemove = useCallback(() => {
|
|
26
|
+
onRemove(id);
|
|
27
|
+
}, [onRemove, id]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
ref.current.removeAttribute('style');
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
ref: ref,
|
|
33
|
+
className: `ui-shared__chip ${styles.chip(removable, invert)}`,
|
|
34
|
+
"data-test-id": id
|
|
35
|
+
}, removable && /*#__PURE__*/React.createElement(Button, {
|
|
36
|
+
className: styles.removeButton,
|
|
37
|
+
onClick: handleRemove,
|
|
38
|
+
testId: "removeFilter",
|
|
39
|
+
"aria-label": removeLabel
|
|
40
|
+
}, /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
41
|
+
breakpoint: "<=xs",
|
|
42
|
+
appAlways: true
|
|
43
|
+
}, /*#__PURE__*/React.createElement(CrossIcon, {
|
|
44
|
+
size: 16
|
|
45
|
+
})), /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
46
|
+
breakpoint: ">xs",
|
|
47
|
+
webOnly: true
|
|
48
|
+
}, /*#__PURE__*/React.createElement(CrossIcon, {
|
|
49
|
+
size: 18
|
|
50
|
+
}))), /*#__PURE__*/React.createElement(Button, {
|
|
51
|
+
className: styles.name,
|
|
52
|
+
onClick: onClick,
|
|
53
|
+
"aria-label": editLabel
|
|
54
|
+
}, children));
|
|
55
|
+
}
|
|
56
|
+
Chip.defaultProps = {
|
|
57
|
+
invert: false,
|
|
58
|
+
onClick: () => {},
|
|
59
|
+
onRemove: () => {},
|
|
60
|
+
removable: true,
|
|
61
|
+
removeLabel: null,
|
|
62
|
+
editLabel: null
|
|
63
|
+
};
|
|
64
|
+
export default Chip;
|
package/Chip/spec.js
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import Chip from '.';
|
|
4
|
+
describe('<Chip />', () => {
|
|
5
|
+
it('should render a tag', () => {
|
|
6
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(Chip, {
|
|
7
|
+
id: "some-id"
|
|
8
|
+
}, "text"));
|
|
9
|
+
expect(wrapper).toMatchSnapshot();
|
|
10
|
+
expect(wrapper.find('button').length).toEqual(2);
|
|
11
|
+
expect(wrapper.find('button').at(1).text()).toEqual('text');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe('<Chip />', () => {
|
|
15
|
+
it('should render a without removable icon', () => {
|
|
16
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(Chip, {
|
|
17
|
+
id: "some-id",
|
|
18
|
+
removable: false
|
|
19
|
+
}, "text"));
|
|
20
|
+
expect(wrapper).toMatchSnapshot();
|
|
21
|
+
expect(wrapper.find('button').length).toEqual(1);
|
|
22
|
+
expect(wrapper.find('button').at(0).text()).toEqual('text');
|
|
23
|
+
});
|
|
24
|
+
});
|