@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
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { SurroundPortals, ToggleIcon, FlashEnabledIcon, FlashDisabledIcon } from '@shopgate/engage/components';
|
|
4
|
+
import { SCANNER_FLASH } from '@shopgate/engage/scanner/constants';
|
|
5
|
+
import { i18n } from '@shopgate/engage/core';
|
|
6
|
+
import styles from "./style";
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* The FlashlightButton component.
|
|
3
10
|
* @returns {JSX.Element}
|
|
4
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const FlashlightButton = ({
|
|
13
|
+
flashlightState,
|
|
14
|
+
onToggle
|
|
15
|
+
}) => /*#__PURE__*/React.createElement(SurroundPortals, {
|
|
16
|
+
portalName: SCANNER_FLASH
|
|
17
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
18
|
+
className: styles.button,
|
|
19
|
+
onClick: onToggle,
|
|
20
|
+
role: "link",
|
|
21
|
+
type: "button",
|
|
22
|
+
"aria-label": i18n.text(flashlightState ? 'scanner.flashlight.switchOff' : 'scanner.flashlight.switchOn')
|
|
23
|
+
}, /*#__PURE__*/React.createElement(ToggleIcon, {
|
|
24
|
+
on: flashlightState,
|
|
25
|
+
onIcon: /*#__PURE__*/React.createElement(FlashEnabledIcon, {
|
|
26
|
+
className: styles.icon
|
|
27
|
+
}),
|
|
28
|
+
offIcon: /*#__PURE__*/React.createElement(FlashDisabledIcon, {
|
|
29
|
+
className: styles.icon
|
|
30
|
+
})
|
|
31
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: "sr-only",
|
|
33
|
+
role: "status",
|
|
34
|
+
"aria-live": "polite"
|
|
35
|
+
}, i18n.text(flashlightState ? 'scanner.flashlight.on' : 'scanner.flashlight.off')));
|
|
36
|
+
export default FlashlightButton;
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const button = css({
|
|
4
|
+
alignItems: 'center',
|
|
5
|
+
color: 'inherit',
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flexShrink: 0,
|
|
8
|
+
fontSize: 24,
|
|
9
|
+
height: 44,
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
outline: 0,
|
|
12
|
+
padding: 0,
|
|
13
|
+
position: 'relative',
|
|
14
|
+
width: 44,
|
|
15
|
+
zIndex: 1
|
|
16
|
+
}).toString();
|
|
17
|
+
const iconWrapper = css({
|
|
18
|
+
width: 72
|
|
19
|
+
}).toString();
|
|
20
|
+
const icon = css({
|
|
21
|
+
boxSizing: 'content-box',
|
|
22
|
+
color: `var(--color-secondary, ${themeConfig.colors.accent})`
|
|
23
|
+
}).toString();
|
|
24
|
+
export default {
|
|
25
|
+
button,
|
|
26
|
+
iconWrapper,
|
|
27
|
+
icon
|
|
28
|
+
};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { I18n, SurroundPortals } from '@shopgate/engage/components';
|
|
3
|
+
import { SCANNER_INSTRUCTIONS } from '@shopgate/engage/scanner/constants';
|
|
4
|
+
/**
|
|
2
5
|
* The Scanner Instructions component.
|
|
3
6
|
* @returns {JSX.Element}
|
|
4
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const ScannerInstructions = () => /*#__PURE__*/React.createElement(SurroundPortals, {
|
|
9
|
+
portalName: SCANNER_INSTRUCTIONS
|
|
10
|
+
}, /*#__PURE__*/React.createElement(I18n.Text, {
|
|
11
|
+
string: "scanner.instructions"
|
|
12
|
+
}));
|
|
13
|
+
export default ScannerInstructions;
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { Grid, SurroundPortals } from '@shopgate/engage/components';
|
|
5
|
+
import { SCANNER_BAR } from '@shopgate/engage/scanner/constants';
|
|
6
|
+
import FlashlightButton from "./components/FlashlightButton";
|
|
7
|
+
import ScannerInstructions from "./components/ScannerInstructions";
|
|
8
|
+
import styles from "./style";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* @param {Object} props The component props.
|
|
3
12
|
* @param {boolean} props.flashlightState The on/off state of the flashlight.
|
|
4
13
|
* @param {Function} props.onToggleFlashlight The toggle event triggered by the user.
|
|
5
14
|
* @returns {React.ReactPortal} A React portal that renders the scanner bar in the AppFooter.
|
|
6
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
const ScannerBar = ({
|
|
17
|
+
flashlightState,
|
|
18
|
+
onToggleFlashlight
|
|
19
|
+
}) => /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(SurroundPortals, {
|
|
20
|
+
portalName: SCANNER_BAR,
|
|
21
|
+
portalProps: {
|
|
22
|
+
flashlightState,
|
|
23
|
+
onToggleFlashlight
|
|
24
|
+
}
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Grid, {
|
|
26
|
+
className: `${styles.container} ui-shared__scanner-bar`
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Grid.Item, {
|
|
28
|
+
className: styles.column
|
|
29
|
+
}, /*#__PURE__*/React.createElement(FlashlightButton, {
|
|
30
|
+
onToggle: onToggleFlashlight,
|
|
31
|
+
flashlightState: flashlightState
|
|
32
|
+
})), /*#__PURE__*/React.createElement(Grid.Item, {
|
|
33
|
+
className: styles.column
|
|
34
|
+
}, /*#__PURE__*/React.createElement(ScannerInstructions, null)))), document.getElementById('AppFooter'));
|
|
35
|
+
export default ScannerBar;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeShadows, themeColors, themeVariables } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const container = css({
|
|
4
|
+
bottom: 0,
|
|
5
|
+
backgroundColor: themeColors.overlay,
|
|
6
|
+
boxShadow: themeShadows.scannerBar,
|
|
7
|
+
fontSize: 14,
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
paddingBottom: 'var(--safe-area-inset-bottom)'
|
|
10
|
+
}).toString();
|
|
11
|
+
const column = css({
|
|
12
|
+
margin: `${themeVariables.gap.big}px`,
|
|
13
|
+
':not(:first-child)': {
|
|
14
|
+
marginLeft: 0
|
|
15
|
+
}
|
|
16
|
+
}).toString();
|
|
17
|
+
export default {
|
|
18
|
+
container,
|
|
19
|
+
column
|
|
20
|
+
};
|
package/ScannerOverlay/index.js
CHANGED
|
@@ -1,11 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { Fragment, PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import AppScanner from '@shopgate/pwa-core/classes/Scanner';
|
|
4
|
+
import CameraOverlay from "./components/CameraOverlay";
|
|
5
|
+
import ScannerBar from "./components/ScannerBar";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* The scanner overlay component.
|
|
3
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
class ScannerOverlay extends PureComponent {
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the component.
|
|
13
|
+
* @param {Object} props The components props.
|
|
14
|
+
*/
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.handleToggleFlashlight = () => {
|
|
18
|
+
this.setState({
|
|
19
|
+
flashlight: AppScanner.toggleFlashlight()
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
this.state = {
|
|
23
|
+
flashlight: props.flashlight
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
4
28
|
* @param {Object} nextProps New props to apply.
|
|
5
|
-
*/
|
|
29
|
+
*/
|
|
30
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
31
|
+
if (this.state.flashlight !== nextProps.flashlight) {
|
|
32
|
+
this.setState({
|
|
33
|
+
flashlight: nextProps.flashlight
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
6
38
|
* Render the camera overlay and the bottom bar with its contents.
|
|
7
39
|
* @returns {JSX}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
40
|
+
*/
|
|
41
|
+
render() {
|
|
42
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(CameraOverlay, null), /*#__PURE__*/React.createElement(ScannerBar, {
|
|
43
|
+
flashlightState: this.state.flashlight,
|
|
44
|
+
onToggleFlashlight: this.handleToggleFlashlight
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
ScannerOverlay.defaultProps = {
|
|
49
|
+
flashlight: false
|
|
50
|
+
};
|
|
51
|
+
export default ScannerOverlay;
|
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
5
|
+
import Input from '@shopgate/pwa-common/components/Input';
|
|
6
|
+
import MagnifierIcon from "../../../../../icons/MagnifierIcon";
|
|
7
|
+
import styles from "./style";
|
|
8
|
+
|
|
9
|
+
/**
|
|
2
10
|
* @return {JSX}
|
|
3
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const SearchBar = ({
|
|
13
|
+
handleChange
|
|
14
|
+
}) => {
|
|
15
|
+
const [query, setQuery] = useState('');
|
|
16
|
+
const name = 'search';
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "ui-shared__sheet__search-field",
|
|
19
|
+
"data-test-id": "SearchField"
|
|
20
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: styles.container
|
|
22
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: styles.inputWrapper
|
|
24
|
+
}, /*#__PURE__*/React.createElement("form", {
|
|
25
|
+
onSubmit: e => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
29
|
+
htmlFor: name,
|
|
30
|
+
className: styles.label
|
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: styles.icon
|
|
33
|
+
}, /*#__PURE__*/React.createElement(MagnifierIcon, null)), !query.length && /*#__PURE__*/React.createElement(I18n.Text, {
|
|
34
|
+
string: "search.placeholder"
|
|
35
|
+
})), /*#__PURE__*/React.createElement(Input, {
|
|
36
|
+
name: name,
|
|
37
|
+
autoComplete: false,
|
|
38
|
+
className: classNames(styles.input),
|
|
39
|
+
onChange: value => {
|
|
40
|
+
handleChange(value);
|
|
41
|
+
setQuery(value);
|
|
42
|
+
},
|
|
43
|
+
value: query,
|
|
44
|
+
type: "search"
|
|
45
|
+
})))));
|
|
46
|
+
};
|
|
47
|
+
export default SearchBar;
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import SearchBar from "./index";
|
|
4
|
+
describe('<SearchBar />', () => {
|
|
5
|
+
it('should call handleChange on input', async () => {
|
|
6
|
+
const handleChange = jest.fn();
|
|
7
|
+
const wrapper = await mount(/*#__PURE__*/React.createElement(SearchBar, {
|
|
8
|
+
handleChange: handleChange
|
|
9
|
+
}));
|
|
10
|
+
expect(wrapper).toMatchSnapshot();
|
|
11
|
+
// Update input
|
|
12
|
+
wrapper.find('input').first().simulate('change', {
|
|
13
|
+
target: {
|
|
14
|
+
name: 'search',
|
|
15
|
+
value: 'asdf'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
// Should call with updated state.
|
|
19
|
+
expect(handleChange).toHaveBeenCalledWith('asdf');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -1 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeColors } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const container = css({
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
flexWrap: 'nowrap',
|
|
7
|
+
marginBottom: 4,
|
|
8
|
+
paddingLeft: 16,
|
|
9
|
+
paddingRight: 16,
|
|
10
|
+
paddingTop: 5,
|
|
11
|
+
paddingBottom: 10
|
|
12
|
+
}).toString();
|
|
13
|
+
const inputWrapper = css({
|
|
14
|
+
position: 'relative',
|
|
15
|
+
flexGrow: 1
|
|
16
|
+
}).toString();
|
|
17
|
+
const input = css({
|
|
18
|
+
borderRadius: 10,
|
|
19
|
+
width: '100%',
|
|
20
|
+
padding: '4px 10px 4px 30px',
|
|
21
|
+
lineHeight: '28px',
|
|
22
|
+
outline: 'none',
|
|
23
|
+
background: themeColors.shade7,
|
|
24
|
+
verticalAlign: 'middle',
|
|
25
|
+
WebkitAppearance: 'none'
|
|
26
|
+
}).toString();
|
|
27
|
+
const label = css({
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
color: themeColors.shade3,
|
|
30
|
+
display: 'flex',
|
|
31
|
+
height: '36px',
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
pointerEvents: 'none',
|
|
34
|
+
width: '100%'
|
|
35
|
+
}).toString();
|
|
36
|
+
const icon = css({
|
|
37
|
+
padding: '0 6px',
|
|
38
|
+
color: themeColors.shade3,
|
|
39
|
+
fontSize: '1.235rem'
|
|
40
|
+
}).toString();
|
|
41
|
+
export default {
|
|
42
|
+
container,
|
|
43
|
+
inputWrapper,
|
|
44
|
+
input,
|
|
45
|
+
label,
|
|
46
|
+
icon
|
|
47
|
+
};
|
|
@@ -1,12 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import Grid from '@shopgate/pwa-common/components/Grid';
|
|
6
|
+
import Ripple from "../../../Ripple";
|
|
7
|
+
import CrossIcon from "../../../icons/CrossIcon";
|
|
8
|
+
import styles from "./style";
|
|
9
|
+
import SearchBar from "./components/SearchBar";
|
|
10
|
+
|
|
11
|
+
/**
|
|
2
12
|
* Header component.
|
|
3
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
class Header extends Component {
|
|
15
|
+
/**
|
|
4
16
|
* @param {Object} nextProps Next Props
|
|
5
17
|
* @returns {boolean}
|
|
6
|
-
*/
|
|
18
|
+
*/
|
|
19
|
+
shouldComponentUpdate(nextProps) {
|
|
20
|
+
return this.props.shadow !== nextProps.shadow || this.props.title !== nextProps.title;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
7
24
|
* Renders the component.
|
|
8
25
|
* @returns {JSX}
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
*/
|
|
27
|
+
render() {
|
|
28
|
+
const {
|
|
29
|
+
allowClose
|
|
30
|
+
} = this.props;
|
|
31
|
+
const classes = classNames(styles.wrapper);
|
|
32
|
+
const {
|
|
33
|
+
__
|
|
34
|
+
} = this.context.i18n();
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: classNames({
|
|
37
|
+
[styles.shadow]: this.props.shadow
|
|
38
|
+
})
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Grid, {
|
|
40
|
+
className: classes,
|
|
41
|
+
component: "div",
|
|
42
|
+
wrap: false
|
|
43
|
+
}, allowClose ? /*#__PURE__*/React.createElement("button", {
|
|
44
|
+
className: styles.closeButton,
|
|
45
|
+
onClick: this.props.onToggleClose,
|
|
46
|
+
"aria-label": __('common.close'),
|
|
47
|
+
type: "button"
|
|
48
|
+
}, /*#__PURE__*/React.createElement(Ripple, {
|
|
49
|
+
className: styles.closeIcon
|
|
50
|
+
}, /*#__PURE__*/React.createElement(CrossIcon, {
|
|
51
|
+
size: 24
|
|
52
|
+
}))) : /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: styles.closePlaceholder
|
|
54
|
+
}), /*#__PURE__*/React.createElement(Grid.Item, _extends({
|
|
55
|
+
className: styles.title,
|
|
56
|
+
component: "div",
|
|
57
|
+
grow: 1,
|
|
58
|
+
role: "heading"
|
|
59
|
+
}, allowClose ? {
|
|
60
|
+
tabIndex: 0
|
|
61
|
+
} : null), this.props.title)), this.props.showSearch && /*#__PURE__*/React.createElement(SearchBar, {
|
|
62
|
+
handleChange: this.props.handleChange
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The component's default props.
|
|
68
|
+
* @type {Object}
|
|
69
|
+
*/
|
|
70
|
+
Header.defaultProps = {
|
|
71
|
+
onToggleClose: () => {},
|
|
72
|
+
shadow: false,
|
|
73
|
+
allowClose: true,
|
|
74
|
+
handleChange: () => {},
|
|
75
|
+
showSearch: false
|
|
76
|
+
};
|
|
77
|
+
Header.contextTypes = {
|
|
78
|
+
i18n: PropTypes.func
|
|
79
|
+
};
|
|
80
|
+
export default Header;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
4
|
+
import Header from "./index";
|
|
5
|
+
describe('<Header />', () => {
|
|
6
|
+
it('should render with correct title', () => {
|
|
7
|
+
const title = 'My Title';
|
|
8
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(Header, {
|
|
9
|
+
title: title
|
|
10
|
+
}), mockRenderOptions);
|
|
11
|
+
expect(wrapper).toMatchSnapshot();
|
|
12
|
+
expect(wrapper.find('GridItem').first().props().children).toEqual(title);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const wrapper = css({
|
|
4
|
+
position: 'relative',
|
|
5
|
+
zIndex: 2
|
|
6
|
+
}).toString();
|
|
7
|
+
const closePlaceholder = css({
|
|
8
|
+
height: themeConfig.variables.navigator.height,
|
|
9
|
+
padding: 0,
|
|
10
|
+
lineHeight: 1
|
|
11
|
+
});
|
|
12
|
+
const closeButton = css({
|
|
13
|
+
lineHeight: 1,
|
|
14
|
+
outline: 0,
|
|
15
|
+
padding: 0,
|
|
16
|
+
minWidth: themeConfig.variables.navigator.height,
|
|
17
|
+
height: themeConfig.variables.navigator.height,
|
|
18
|
+
position: 'relative',
|
|
19
|
+
zIndex: 2,
|
|
20
|
+
color: 'var(--color-text-high-emphasis)'
|
|
21
|
+
}).toString();
|
|
22
|
+
const closeIcon = css({
|
|
23
|
+
display: 'flex',
|
|
24
|
+
height: '100%',
|
|
25
|
+
width: '100%',
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
alignItems: 'center'
|
|
28
|
+
}).toString();
|
|
29
|
+
const title = css({
|
|
30
|
+
fontSize: '1.25rem',
|
|
31
|
+
fontWeight: 500,
|
|
32
|
+
position: 'relative',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
padding: `0 ${themeConfig.variables.gap.big}px`,
|
|
35
|
+
overflow: 'hidden',
|
|
36
|
+
textOverflow: 'ellipsis',
|
|
37
|
+
whiteSpace: 'nowrap',
|
|
38
|
+
alignSelf: 'center'
|
|
39
|
+
}).toString();
|
|
40
|
+
const shadow = css({
|
|
41
|
+
boxShadow: themeConfig.shadows.material
|
|
42
|
+
});
|
|
43
|
+
export default {
|
|
44
|
+
wrapper,
|
|
45
|
+
closeButton,
|
|
46
|
+
closePlaceholder,
|
|
47
|
+
closeIcon,
|
|
48
|
+
title,
|
|
49
|
+
shadow
|
|
50
|
+
};
|