@shopgate/pwa-ui-shared 7.30.3 → 7.31.0-alpha.1
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/ActionButton/index.js +66 -67
- package/AddToCartButton/index.js +217 -185
- package/Availability/index.js +24 -6
- package/Button/index.js +105 -82
- package/Button/spec.js +3 -4
- package/Card/index.js +26 -7
- package/CardList/components/Item/index.js +15 -3
- package/CartTotalLine/components/Amount/index.js +13 -4
- package/CartTotalLine/components/Hint/index.js +13 -4
- package/CartTotalLine/components/Label/index.js +23 -10
- package/CartTotalLine/index.js +41 -7
- package/Checkbox/index.js +41 -17
- package/Chip/index.js +82 -7
- package/ContextMenu/components/Item/index.js +38 -20
- package/ContextMenu/components/Position/index.js +38 -56
- package/ContextMenu/index.js +64 -28
- package/Dialog/components/BasicDialog/index.js +1 -0
- package/Dialog/components/HtmlContentDialog/spec.js +39 -0
- package/Dialog/components/PipelineErrorDialog/index.js +108 -157
- package/Dialog/components/PipelineErrorDialog/spec.js +12 -18
- package/Dialog/components/TextMessageDialog/index.js +1 -1
- package/Dialog/components/VariantSelectModal/index.js +1 -1
- package/Dialog/index.js +1 -1
- package/DiscountBadge/index.js +48 -15
- package/FavoritesButton/index.js +95 -100
- package/FavoritesButton/spec.js +5 -2
- package/Form/Builder/classes/ActionListener/index.js +1 -0
- package/Form/Checkbox/index.js +64 -56
- package/Form/InfoField/index.js +18 -6
- package/Form/Password/index.js +39 -52
- package/Form/RadioGroup/components/Item/index.js +72 -56
- package/Form/RadioGroup/index.js +79 -90
- package/Form/Select/index.js +108 -130
- package/Form/SelectContextChoices/index.js +30 -8
- package/Form/TextField/index.js +106 -82
- package/Form/TextField/spec.js +4 -3
- package/FormElement/components/ErrorText/index.js +32 -14
- package/FormElement/components/Label/index.js +56 -6
- package/FormElement/components/Placeholder/index.js +44 -11
- package/FormElement/components/Underline/index.js +63 -12
- package/FormElement/index.js +62 -85
- package/Glow/index.js +73 -83
- package/IndicatorCircle/index.js +73 -17
- package/IndicatorCircle/spec.js +2 -5
- package/LoadingIndicator/index.js +34 -12
- package/Manufacturer/index.js +21 -10
- package/MessageBar/index.js +12 -38
- package/NoResults/components/Icon/index.js +30 -14
- package/NoResults/index.js +35 -7
- package/Placeholder/index.js +34 -23
- package/PlaceholderLabel/index.js +17 -3
- package/Price/index.js +34 -21
- package/PriceInfo/index.js +23 -9
- package/PriceStriked/index.js +67 -77
- package/ProgressBar/index.js +112 -77
- package/RadioButton/index.js +29 -11
- package/RatingStars/index.js +122 -137
- package/Ripple/components/RippleAnimation/index.js +13 -3
- package/Ripple/index.js +158 -212
- package/RippleButton/index.js +63 -60
- package/RippleButton/spec.js +15 -9
- package/ScannerOverlay/components/CameraOverlay/index.js +54 -10
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +53 -27
- package/ScannerOverlay/components/ScannerBar/index.js +50 -26
- package/Sheet/components/Header/components/SearchBar/index.js +54 -10
- package/Sheet/components/Header/index.js +96 -76
- package/Sheet/index.js +295 -157
- package/Sheet/spec.js +8 -6
- package/TaxDisclaimer/index.js +17 -4
- package/TaxDisclaimer/spec.js +16 -5
- package/TextField/components/ErrorText/index.js +35 -14
- package/TextField/components/FormElement/index.js +29 -4
- package/TextField/components/Hint/index.js +39 -10
- package/TextField/components/Label/index.js +43 -6
- package/TextField/components/Underline/index.js +64 -13
- package/TextField/index.js +157 -171
- package/TextField/spec.js +5 -3
- package/icons/AccountBoxIcon.d.ts +7 -0
- package/icons/AccountBoxIcon.d.ts.map +1 -0
- package/icons/AccountBoxIcon.js +1 -4
- package/icons/AddMoreIcon.d.ts +7 -0
- package/icons/AddMoreIcon.d.ts.map +1 -0
- package/icons/AddMoreIcon.js +0 -3
- package/icons/ArrowDropIcon.d.ts +7 -0
- package/icons/ArrowDropIcon.d.ts.map +1 -0
- package/icons/ArrowDropIcon.js +0 -3
- package/icons/ArrowIcon.d.ts +10 -0
- package/icons/ArrowIcon.d.ts.map +1 -0
- package/icons/ArrowIcon.js +2 -11
- package/icons/BarcodeScannerIcon.d.ts +7 -0
- package/icons/BarcodeScannerIcon.d.ts.map +1 -0
- package/icons/BarcodeScannerIcon.js +0 -3
- package/icons/BoxIcon.d.ts +7 -0
- package/icons/BoxIcon.d.ts.map +1 -0
- package/icons/BoxIcon.js +0 -3
- package/icons/BrowseIcon.d.ts +7 -0
- package/icons/BrowseIcon.d.ts.map +1 -0
- package/icons/BrowseIcon.js +1 -3
- package/icons/BurgerIcon.d.ts +7 -0
- package/icons/BurgerIcon.d.ts.map +1 -0
- package/icons/BurgerIcon.js +0 -3
- package/icons/CalendarIcon.d.ts +7 -0
- package/icons/CalendarIcon.d.ts.map +1 -0
- package/icons/CalendarIcon.js +0 -2
- package/icons/CartCouponIcon.d.ts +7 -0
- package/icons/CartCouponIcon.d.ts.map +1 -0
- package/icons/CartCouponIcon.js +0 -2
- package/icons/CartIcon.d.ts +7 -0
- package/icons/CartIcon.d.ts.map +1 -0
- package/icons/CartIcon.js +0 -2
- package/icons/CartPlusIcon.d.ts +7 -0
- package/icons/CartPlusIcon.d.ts.map +1 -0
- package/icons/CartPlusIcon.js +0 -2
- package/icons/CheckIcon.d.ts +7 -0
- package/icons/CheckIcon.d.ts.map +1 -0
- package/icons/CheckIcon.js +0 -2
- package/icons/CheckedIcon.d.ts +7 -0
- package/icons/CheckedIcon.d.ts.map +1 -0
- package/icons/CheckedIcon.js +0 -3
- package/icons/ChevronIcon.d.ts +7 -0
- package/icons/ChevronIcon.d.ts.map +1 -0
- package/icons/ChevronIcon.js +0 -2
- package/icons/CreditCardIcon.d.ts +7 -0
- package/icons/CreditCardIcon.d.ts.map +1 -0
- package/icons/CreditCardIcon.js +0 -2
- package/icons/CrossIcon.d.ts +7 -0
- package/icons/CrossIcon.d.ts.map +1 -0
- package/icons/CrossIcon.js +0 -2
- package/icons/DescriptionIcon.d.ts +7 -0
- package/icons/DescriptionIcon.d.ts.map +1 -0
- package/icons/DescriptionIcon.js +0 -2
- package/icons/FilterIcon.d.ts +7 -0
- package/icons/FilterIcon.d.ts.map +1 -0
- package/icons/FilterIcon.js +0 -2
- package/icons/FlashDisabledIcon.d.ts +7 -0
- package/icons/FlashDisabledIcon.d.ts.map +1 -0
- package/icons/FlashDisabledIcon.js +0 -2
- package/icons/FlashEnabledIcon.d.ts +7 -0
- package/icons/FlashEnabledIcon.d.ts.map +1 -0
- package/icons/FlashEnabledIcon.js +0 -2
- package/icons/GridIcon.d.ts +7 -0
- package/icons/GridIcon.d.ts.map +1 -0
- package/icons/GridIcon.js +1 -3
- package/icons/HeartIcon.d.ts +7 -0
- package/icons/HeartIcon.d.ts.map +1 -0
- package/icons/HeartIcon.js +0 -2
- package/icons/HeartOutlineIcon.d.ts +7 -0
- package/icons/HeartOutlineIcon.d.ts.map +1 -0
- package/icons/HeartOutlineIcon.js +1 -3
- package/icons/HeartPlusIcon.d.ts +7 -0
- package/icons/HeartPlusIcon.d.ts.map +1 -0
- package/icons/HeartPlusIcon.js +1 -3
- package/icons/HeartPlusOutlineIcon.d.ts +7 -0
- package/icons/HeartPlusOutlineIcon.d.ts.map +1 -0
- package/icons/HeartPlusOutlineIcon.js +1 -3
- package/icons/HomeIcon.d.ts +7 -0
- package/icons/HomeIcon.d.ts.map +1 -0
- package/icons/HomeIcon.js +0 -2
- package/icons/InfoIcon.d.ts +7 -0
- package/icons/InfoIcon.d.ts.map +1 -0
- package/icons/InfoIcon.js +0 -2
- package/icons/InfoOutlineIcon.d.ts +7 -0
- package/icons/InfoOutlineIcon.d.ts.map +1 -0
- package/icons/InfoOutlineIcon.js +0 -2
- package/icons/ListIcon.d.ts +7 -0
- package/icons/ListIcon.d.ts.map +1 -0
- package/icons/ListIcon.js +0 -2
- package/icons/LocalShippingIcon.d.ts +7 -0
- package/icons/LocalShippingIcon.d.ts.map +1 -0
- package/icons/LocalShippingIcon.js +0 -2
- package/icons/LocationIcon.d.ts +7 -0
- package/icons/LocationIcon.d.ts.map +1 -0
- package/icons/LocationIcon.js +1 -4
- package/icons/LocatorIcon.d.ts +7 -0
- package/icons/LocatorIcon.d.ts.map +1 -0
- package/icons/LocatorIcon.js +1 -3
- package/icons/LockIcon.d.ts +9 -0
- package/icons/LockIcon.d.ts.map +1 -0
- package/icons/LockIcon.js +1 -2
- package/icons/LogoutIcon.d.ts +7 -0
- package/icons/LogoutIcon.d.ts.map +1 -0
- package/icons/LogoutIcon.js +0 -2
- package/icons/MagnifierIcon.d.ts +7 -0
- package/icons/MagnifierIcon.d.ts.map +1 -0
- package/icons/MagnifierIcon.js +0 -2
- package/icons/MapMarkerIcon.d.ts +7 -0
- package/icons/MapMarkerIcon.d.ts.map +1 -0
- package/icons/MapMarkerIcon.js +1 -3
- package/icons/MoreIcon.d.ts +7 -0
- package/icons/MoreIcon.d.ts.map +1 -0
- package/icons/MoreIcon.js +1 -3
- package/icons/MoreVertIcon.d.ts +7 -0
- package/icons/MoreVertIcon.d.ts.map +1 -0
- package/icons/MoreVertIcon.js +1 -3
- package/icons/NotificationIcon.d.ts +7 -0
- package/icons/NotificationIcon.d.ts.map +1 -0
- package/icons/NotificationIcon.js +1 -3
- package/icons/PersonIcon.d.ts +9 -0
- package/icons/PersonIcon.d.ts.map +1 -0
- package/icons/PersonIcon.js +0 -3
- package/icons/PhoneIcon.d.ts +7 -0
- package/icons/PhoneIcon.d.ts.map +1 -0
- package/icons/PhoneIcon.js +1 -4
- package/icons/PlaceholderIcon.d.ts +7 -0
- package/icons/PlaceholderIcon.d.ts.map +1 -0
- package/icons/PlaceholderIcon.js +0 -2
- package/icons/RadioCheckedIcon.d.ts +10 -0
- package/icons/RadioCheckedIcon.d.ts.map +1 -0
- package/icons/RadioCheckedIcon.js +0 -2
- package/icons/RadioUncheckedIcon.d.ts +10 -0
- package/icons/RadioUncheckedIcon.d.ts.map +1 -0
- package/icons/RadioUncheckedIcon.js +0 -2
- package/icons/SecurityIcon.d.ts +7 -0
- package/icons/SecurityIcon.d.ts.map +1 -0
- package/icons/SecurityIcon.js +0 -2
- package/icons/ShippingMethodIcon.d.ts +7 -0
- package/icons/ShippingMethodIcon.d.ts.map +1 -0
- package/icons/ShippingMethodIcon.js +0 -2
- package/icons/ShoppingCartIcon.d.ts +7 -0
- package/icons/ShoppingCartIcon.d.ts.map +1 -0
- package/icons/ShoppingCartIcon.js +0 -2
- package/icons/SortIcon.d.ts +7 -0
- package/icons/SortIcon.d.ts.map +1 -0
- package/icons/SortIcon.js +0 -2
- package/icons/StarHalfIcon.d.ts +7 -0
- package/icons/StarHalfIcon.d.ts.map +1 -0
- package/icons/StarHalfIcon.js +0 -9
- package/icons/StarIcon.d.ts +7 -0
- package/icons/StarIcon.d.ts.map +1 -0
- package/icons/StarIcon.js +0 -9
- package/icons/StarOutlineIcon.d.ts +7 -0
- package/icons/StarOutlineIcon.d.ts.map +1 -0
- package/icons/StarOutlineIcon.js +0 -2
- package/icons/StopIcon.d.ts +7 -0
- package/icons/StopIcon.d.ts.map +1 -0
- package/icons/StopIcon.js +0 -2
- package/icons/TickIcon.d.ts +7 -0
- package/icons/TickIcon.d.ts.map +1 -0
- package/icons/TickIcon.js +0 -2
- package/icons/TimeIcon.d.ts +7 -0
- package/icons/TimeIcon.d.ts.map +1 -0
- package/icons/TimeIcon.js +0 -2
- package/icons/TrashIcon.d.ts +7 -0
- package/icons/TrashIcon.d.ts.map +1 -0
- package/icons/TrashIcon.js +0 -3
- package/icons/TrashOutlineIcon.d.ts +8 -0
- package/icons/TrashOutlineIcon.d.ts.map +1 -0
- package/icons/TrashOutlineIcon.js +0 -2
- package/icons/UncheckedIcon.d.ts +7 -0
- package/icons/UncheckedIcon.d.ts.map +1 -0
- package/icons/UncheckedIcon.js +0 -2
- package/icons/ViewListIcon.d.ts +7 -0
- package/icons/ViewListIcon.d.ts.map +1 -0
- package/icons/ViewListIcon.js +0 -2
- package/icons/VisibilityIcon.d.ts +8 -0
- package/icons/VisibilityIcon.d.ts.map +1 -0
- package/icons/VisibilityIcon.js +2 -4
- package/icons/VisibilityOffIcon.d.ts +8 -0
- package/icons/VisibilityOffIcon.d.ts.map +1 -0
- package/icons/VisibilityOffIcon.js +2 -4
- package/icons/WarningIcon.d.ts +7 -0
- package/icons/WarningIcon.d.ts.map +1 -0
- package/icons/WarningIcon.js +1 -3
- package/package.json +5 -5
- package/tsconfig.build.json +16 -0
- package/tsconfig.json +3 -0
- package/ActionButton/style.js +0 -22
- package/AddToCartButton/style.js +0 -148
- package/Availability/style.js +0 -19
- package/Button/style.js +0 -155
- package/Card/style.js +0 -11
- package/CardList/components/Item/style.js +0 -7
- package/CartTotalLine/components/Amount/style.js +0 -8
- package/CartTotalLine/components/Hint/style.js +0 -12
- package/CartTotalLine/components/Label/style.js +0 -17
- package/CartTotalLine/style.js +0 -31
- package/Checkbox/style.js +0 -18
- package/Chip/style.js +0 -78
- package/ContextMenu/components/Item/style.js +0 -34
- package/ContextMenu/components/Position/style.js +0 -11
- package/ContextMenu/style.js +0 -45
- package/DiscountBadge/style.js +0 -36
- package/FavoritesButton/style.js +0 -26
- package/Form/Checkbox/style.js +0 -25
- package/Form/InfoField/style.js +0 -11
- package/Form/Password/style.js +0 -11
- package/Form/RadioGroup/components/Item/style.js +0 -32
- package/Form/RadioGroup/style.js +0 -20
- package/Form/Select/style.js +0 -27
- package/Form/SelectContextChoices/style.js +0 -23
- package/Form/TextField/style.js +0 -70
- package/FormElement/components/ErrorText/style.js +0 -13
- package/FormElement/components/Label/style.js +0 -89
- package/FormElement/components/Placeholder/style.js +0 -56
- package/FormElement/components/Underline/style.js +0 -60
- package/FormElement/style.js +0 -14
- package/Glow/style.js +0 -18
- package/IndicatorCircle/style.js +0 -65
- package/LoadingIndicator/style.js +0 -20
- package/Manufacturer/style.js +0 -5
- package/MessageBar/spec.js +0 -80
- package/MessageBar/style.js +0 -38
- package/NoResults/components/Icon/style.js +0 -17
- package/NoResults/style.js +0 -31
- package/Placeholder/style.js +0 -11
- package/PlaceholderLabel/style.js +0 -12
- package/Price/style.js +0 -22
- package/PriceInfo/style.js +0 -5
- package/PriceStriked/style.js +0 -36
- package/ProgressBar/style.js +0 -85
- package/RadioButton/style.js +0 -21
- package/RatingStars/style.js +0 -53
- package/Ripple/style.js +0 -18
- package/ScannerOverlay/components/CameraOverlay/style.js +0 -40
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +0 -28
- package/ScannerOverlay/components/ScannerBar/style.js +0 -20
- package/Sheet/components/Header/components/SearchBar/style.js +0 -47
- package/Sheet/components/Header/style.js +0 -50
- package/Sheet/style.js +0 -143
- package/TaxDisclaimer/style.js +0 -9
- package/TextField/components/ErrorText/style.js +0 -27
- package/TextField/components/FormElement/style.js +0 -34
- package/TextField/components/Hint/style.js +0 -46
- package/TextField/components/Label/style.js +0 -80
- package/TextField/components/Underline/style.js +0 -60
- package/TextField/style.js +0 -35
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
|
-
import React, { Component } from 'react';
|
|
1
|
+
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
2
|
import PropTypes from 'prop-types';
|
|
5
|
-
import I18n from '@shopgate/
|
|
3
|
+
import { I18n } from '@shopgate/engage/components';
|
|
6
4
|
import BasicDialog from "../BasicDialog";
|
|
7
5
|
|
|
8
6
|
/**
|
|
@@ -16,168 +14,121 @@ const requiredTapsToSwitchModes = 10;
|
|
|
16
14
|
*/
|
|
17
15
|
const switchModeTapTimeout = 4000 / requiredTapsToSwitchModes;
|
|
18
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Checks the input to be truthy, "0" or "false" and enables it to be rendered then.
|
|
19
|
+
* @param {Object|string|number|boolean} value The value to be checked if it should be rendered.
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
const checkValue = value => !!value || value === 0 || value === false;
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
25
|
* This component displays a pipeline error dialog.
|
|
21
|
-
* The special
|
|
26
|
+
* The special behavior of this message is that the user may tap the message body
|
|
22
27
|
* ten times until it reveals additional information about the error that occurred.
|
|
28
|
+
* @param {Object} props Props.
|
|
29
|
+
* @returns {JSX.Element}
|
|
23
30
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
devMode: !devMode
|
|
54
|
-
}));
|
|
55
|
-
} else {
|
|
56
|
-
_this.tapTimeout = setTimeout(_this.handleTapTimeout, switchModeTapTimeout);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Renders the error message in developer mode.
|
|
61
|
-
* @returns {JSX}
|
|
62
|
-
*/
|
|
63
|
-
_this.renderDevErrorMessage = () => {
|
|
64
|
-
/**
|
|
65
|
-
* Checks the input to be truthy, "0" or "false" and enables it to be rendered then.
|
|
66
|
-
* @param {Object|string|number|boolean} value The value to be checked if it should be rendered.
|
|
67
|
-
* @returns {boolean}
|
|
68
|
-
*/
|
|
69
|
-
const checkValue = value => !!value || value === 0 || value === false;
|
|
70
|
-
const {
|
|
71
|
-
params
|
|
72
|
-
} = _this.props;
|
|
73
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
74
|
-
"aria-hidden": true,
|
|
75
|
-
children: [/*#__PURE__*/_jsxs("span", {
|
|
76
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
77
|
-
children: "Pipeline:"
|
|
78
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
79
|
-
children: ` ${params.pipeline}`
|
|
80
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
81
|
-
}), checkValue(params.entityId) && /*#__PURE__*/_jsxs("span", {
|
|
82
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
83
|
-
children: "Entity id:"
|
|
84
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
85
|
-
children: ` ${params.entityId}`
|
|
86
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
87
|
-
}), checkValue(params.code) && /*#__PURE__*/_jsxs("span", {
|
|
88
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
89
|
-
children: "Code:"
|
|
90
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
91
|
-
children: ` ${params.code}`
|
|
92
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
93
|
-
}), /*#__PURE__*/_jsxs("span", {
|
|
94
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
95
|
-
children: "Message:"
|
|
96
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
97
|
-
children: ` ${params.message}`
|
|
98
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
99
|
-
}), checkValue(params.translated) && /*#__PURE__*/_jsxs("span", {
|
|
100
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
101
|
-
children: "Message Translated:"
|
|
102
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
103
|
-
children: ` ${params.translated.toString()}`
|
|
104
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
105
|
-
}), checkValue(params.messageParams) && /*#__PURE__*/_jsxs("p", {
|
|
106
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
107
|
-
children: "Message Params:"
|
|
108
|
-
}), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("span", {
|
|
109
|
-
children: JSON.stringify(params.messageParams, null, ' ')
|
|
110
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
111
|
-
}), checkValue(params.request) && /*#__PURE__*/_jsxs("p", {
|
|
112
|
-
children: [/*#__PURE__*/_jsx("strong", {
|
|
113
|
-
children: "Request Params:"
|
|
114
|
-
}), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("span", {
|
|
115
|
-
children: JSON.stringify(params.request, null, ' ')
|
|
116
|
-
}), /*#__PURE__*/_jsx("br", {})]
|
|
117
|
-
})]
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Renders the regular error message in user mode.
|
|
122
|
-
* @returns {JSX}
|
|
123
|
-
*/
|
|
124
|
-
_this.renderUserErrorMessage = () => {
|
|
125
|
-
const {
|
|
126
|
-
message = '',
|
|
127
|
-
params = {}
|
|
128
|
-
} = _this.props;
|
|
129
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
130
|
-
children: [!!params.translated && (message || params.message || /*#__PURE__*/_jsx(I18n.Text, {
|
|
131
|
-
string: "modal.body_error"
|
|
132
|
-
})), !params.translated && /*#__PURE__*/_jsx(I18n.Text, {
|
|
133
|
-
string: message || params.message || 'modal.body_error',
|
|
134
|
-
params: params.messageParams || {}
|
|
135
|
-
})]
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
_this.tapTimeout = null;
|
|
139
|
-
_this.tapCounter = 0;
|
|
140
|
-
_this.state = {
|
|
141
|
-
devMode: false // Indicating whether we are in dev mode.
|
|
142
|
-
};
|
|
143
|
-
return _this;
|
|
144
|
-
}
|
|
31
|
+
const PipelineErrorDialog = ({
|
|
32
|
+
actions,
|
|
33
|
+
params,
|
|
34
|
+
message
|
|
35
|
+
}) => {
|
|
36
|
+
const [devMode, setDevMode] = useState(false);
|
|
37
|
+
const tapTimeoutRef = useRef(null);
|
|
38
|
+
const tapCounterRef = useRef(0);
|
|
39
|
+
const handleTapTimeout = useCallback(() => {
|
|
40
|
+
tapCounterRef.current = 0;
|
|
41
|
+
}, []);
|
|
42
|
+
const handleClick = useCallback(() => {
|
|
43
|
+
tapCounterRef.current += 1;
|
|
44
|
+
if (tapTimeoutRef.current) {
|
|
45
|
+
clearTimeout(tapTimeoutRef.current);
|
|
46
|
+
}
|
|
47
|
+
if (tapCounterRef.current >= requiredTapsToSwitchModes) {
|
|
48
|
+
tapCounterRef.current = 0;
|
|
49
|
+
setDevMode(prev => !prev);
|
|
50
|
+
} else {
|
|
51
|
+
tapTimeoutRef.current = setTimeout(handleTapTimeout, switchModeTapTimeout);
|
|
52
|
+
}
|
|
53
|
+
}, [handleTapTimeout]);
|
|
54
|
+
useEffect(() => () => {
|
|
55
|
+
if (tapTimeoutRef.current) {
|
|
56
|
+
clearTimeout(tapTimeoutRef.current);
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
const title = devMode ? 'Pipeline Error' : 'modal.title_error';
|
|
145
60
|
|
|
146
61
|
/**
|
|
147
|
-
* @
|
|
62
|
+
* @returns {JSX.Element}
|
|
148
63
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
64
|
+
const renderDevErrorMessage = () => /*#__PURE__*/_jsxs("div", {
|
|
65
|
+
"aria-hidden": true,
|
|
66
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
67
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
68
|
+
children: "Pipeline:"
|
|
69
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
70
|
+
children: ` ${params.pipeline}`
|
|
71
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
72
|
+
}), checkValue(params.entityId) && /*#__PURE__*/_jsxs("span", {
|
|
73
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
74
|
+
children: "Entity id:"
|
|
75
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
76
|
+
children: ` ${params.entityId}`
|
|
77
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
78
|
+
}), checkValue(params.code) && /*#__PURE__*/_jsxs("span", {
|
|
79
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
80
|
+
children: "Code:"
|
|
81
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
82
|
+
children: ` ${params.code}`
|
|
83
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
84
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
85
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
86
|
+
children: "Message:"
|
|
87
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
88
|
+
children: ` ${params.message}`
|
|
89
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
90
|
+
}), checkValue(params.translated) && /*#__PURE__*/_jsxs("span", {
|
|
91
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
92
|
+
children: "Message Translated:"
|
|
93
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
94
|
+
children: ` ${params.translated.toString()}`
|
|
95
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
96
|
+
}), checkValue(params.messageParams) && /*#__PURE__*/_jsxs("p", {
|
|
97
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
98
|
+
children: "Message Params:"
|
|
99
|
+
}), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("span", {
|
|
100
|
+
children: JSON.stringify(params.messageParams, null, ' ')
|
|
101
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
102
|
+
}), checkValue(params.request) && /*#__PURE__*/_jsxs("p", {
|
|
103
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
104
|
+
children: "Request Params:"
|
|
105
|
+
}), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("span", {
|
|
106
|
+
children: JSON.stringify(params.request, null, ' ')
|
|
107
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
|
|
151
111
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @return {JSX}
|
|
112
|
+
* @returns {JSX.Element}
|
|
154
113
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*/
|
|
174
|
-
}, {
|
|
175
|
-
key: "content",
|
|
176
|
-
get: function () {
|
|
177
|
-
return this.state.devMode ? this.renderDevErrorMessage() : this.renderUserErrorMessage();
|
|
178
|
-
}
|
|
179
|
-
}]);
|
|
180
|
-
}(Component);
|
|
114
|
+
const renderUserErrorMessage = () => /*#__PURE__*/_jsxs(_Fragment, {
|
|
115
|
+
children: [!!params.translated && (message || params.message || /*#__PURE__*/_jsx(I18n.Text, {
|
|
116
|
+
string: "modal.body_error"
|
|
117
|
+
})), !params.translated && /*#__PURE__*/_jsx(I18n.Text, {
|
|
118
|
+
string: message || params.message || 'modal.body_error',
|
|
119
|
+
params: params.messageParams || {}
|
|
120
|
+
})]
|
|
121
|
+
});
|
|
122
|
+
const content = devMode ? renderDevErrorMessage() : renderUserErrorMessage();
|
|
123
|
+
return /*#__PURE__*/_jsx(BasicDialog, {
|
|
124
|
+
title: title,
|
|
125
|
+
actions: actions,
|
|
126
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
127
|
+
onClick: handleClick,
|
|
128
|
+
children: content
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
};
|
|
181
132
|
PipelineErrorDialog.defaultProps = {
|
|
182
133
|
message: ''
|
|
183
134
|
};
|
|
@@ -34,21 +34,22 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
34
34
|
}));
|
|
35
35
|
const numTaps = 10;
|
|
36
36
|
const clickElement = wrapper.find('div[onClick]');
|
|
37
|
+
const devMarker = 'Pipeline:';
|
|
37
38
|
|
|
38
39
|
// Dev mode should be disabled.
|
|
39
40
|
for (let i = 0; i < numTaps; i += 1) {
|
|
40
|
-
expect(wrapper.
|
|
41
|
+
expect(wrapper.text()).not.toContain(devMarker);
|
|
41
42
|
clickElement.simulate('click');
|
|
42
43
|
}
|
|
44
|
+
expect(wrapper.text()).toContain(devMarker);
|
|
43
45
|
|
|
44
|
-
// Dev mode should be enabled.
|
|
45
|
-
for (let i = 0; i < numTaps; i += 1) {
|
|
46
|
-
expect(wrapper.
|
|
46
|
+
// Dev mode should be enabled until 10 more taps.
|
|
47
|
+
for (let i = 0; i < numTaps - 1; i += 1) {
|
|
48
|
+
expect(wrapper.text()).toContain(devMarker);
|
|
47
49
|
clickElement.simulate('click');
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
expect(wrapper.state().devMode).toBe(false);
|
|
51
|
+
clickElement.simulate('click');
|
|
52
|
+
expect(wrapper.text()).not.toContain(devMarker);
|
|
52
53
|
});
|
|
53
54
|
it('should not switch modes if tapped too slow', () => {
|
|
54
55
|
jest.useFakeTimers();
|
|
@@ -59,9 +60,8 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
59
60
|
const numTaps = 10;
|
|
60
61
|
const numTapsUntilTimeout = Math.round(numTaps / 2);
|
|
61
62
|
const clickElement = wrapper.find('div[onClick]');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
expect(wrapper.state().devMode).toBe(false);
|
|
63
|
+
const devMarker = 'Pipeline:';
|
|
64
|
+
expect(wrapper.text()).not.toContain(devMarker);
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Simulates multiple tap events.
|
|
@@ -82,14 +82,8 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
82
82
|
|
|
83
83
|
// Tap the remaining times.
|
|
84
84
|
tapOnElement(numTaps - numTapsUntilTimeout);
|
|
85
|
-
|
|
86
|
-
// We timed out and should not be in dev mode by now.
|
|
87
|
-
expect(wrapper.state().devMode).toBe(false);
|
|
88
|
-
|
|
89
|
-
// Add the remaining amount of taps to enter dev mode.
|
|
85
|
+
expect(wrapper.text()).not.toContain(devMarker);
|
|
90
86
|
tapOnElement(numTapsUntilTimeout);
|
|
91
|
-
|
|
92
|
-
// This time dev mode should be enabled.
|
|
93
|
-
expect(wrapper.state().devMode).toBe(true);
|
|
87
|
+
expect(wrapper.text()).toContain(devMarker);
|
|
94
88
|
});
|
|
95
89
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import I18n from '@shopgate/
|
|
3
|
+
import { I18n } from '@shopgate/engage/components';
|
|
4
4
|
import { i18n, nl2br } from '@shopgate/engage/core';
|
|
5
5
|
import BasicDialog from "../BasicDialog";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import I18n from '@shopgate/
|
|
3
|
+
import { I18n } from '@shopgate/engage/components';
|
|
4
4
|
import { ITEM_PATH } from '@shopgate/pwa-common-commerce/product/constants';
|
|
5
5
|
import { bin2hex } from '@shopgate/pwa-common/helpers/data';
|
|
6
6
|
import BasicDialog from "../BasicDialog";
|
package/Dialog/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import Modal from '@shopgate/pwa-common/components/Modal';
|
|
4
4
|
import Backdrop from '@shopgate/pwa-common/components/Backdrop';
|
|
5
5
|
import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
|
|
6
|
-
import I18n from '@shopgate/
|
|
6
|
+
import { I18n } from '@shopgate/engage/components';
|
|
7
7
|
import { DIALOG_TEXT_MESSAGE, MODAL_VARIANT_SELECT, MODAL_ACTION_TYPE_PRIMARY, MODAL_ACTION_TYPE_NORMAL, DIALOG_HTML_CONTENT } from "./constants";
|
|
8
8
|
import PipelineErrorDialog from "./components/PipelineErrorDialog";
|
|
9
9
|
import TextMessageDialog from "./components/TextMessageDialog";
|
package/DiscountBadge/index.js
CHANGED
|
@@ -2,8 +2,35 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { I18n } from '@shopgate/engage/components';
|
|
4
4
|
import { i18n } from '@shopgate/engage/core/helpers';
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const badgeBase = {
|
|
9
|
+
background: 'var(--color-primary)',
|
|
10
|
+
borderRadius: 2,
|
|
11
|
+
color: 'var(--color-primary-contrast)',
|
|
12
|
+
padding: 5,
|
|
13
|
+
width: '100%',
|
|
14
|
+
fontWeight: 700,
|
|
15
|
+
textAlign: 'center',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
lineHeight: 1,
|
|
20
|
+
whiteSpace: 'nowrap',
|
|
21
|
+
...themeConfig.variables.discountBadgeBase
|
|
22
|
+
};
|
|
23
|
+
const useStyles = makeStyles()(() => ({
|
|
24
|
+
small: {
|
|
25
|
+
...badgeBase
|
|
26
|
+
},
|
|
27
|
+
big: {
|
|
28
|
+
...badgeBase,
|
|
29
|
+
paddingTop: 5,
|
|
30
|
+
paddingLeft: 5,
|
|
31
|
+
paddingRight: 5
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
7
34
|
/**
|
|
8
35
|
* The discount badge component.
|
|
9
36
|
* @param {Object} props The component props
|
|
@@ -11,24 +38,30 @@ import styles from "./style";
|
|
|
11
38
|
* @param {string} props.text The text contents of the component.
|
|
12
39
|
* @returns {JSX.Element}
|
|
13
40
|
*/
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
41
|
const DiscountBadge = ({
|
|
16
42
|
text,
|
|
17
43
|
className,
|
|
18
44
|
display,
|
|
19
45
|
discount
|
|
20
|
-
}) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"aria-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
}) => {
|
|
47
|
+
const {
|
|
48
|
+
classes,
|
|
49
|
+
cx
|
|
50
|
+
} = useStyles();
|
|
51
|
+
const displayClass = display === 'big' ? classes.big : classes.small;
|
|
52
|
+
return /*#__PURE__*/_jsx("div", {
|
|
53
|
+
"data-test-id": text,
|
|
54
|
+
className: "ui-shared__discount-badge",
|
|
55
|
+
"aria-label": `${i18n.text('cart.discount')}: ${text}`,
|
|
56
|
+
tabIndex: -1,
|
|
57
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
58
|
+
className: cx(displayClass, className, 'theme__discount-badge'),
|
|
59
|
+
string: text,
|
|
60
|
+
params: [discount],
|
|
61
|
+
"aria-hidden": true
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
};
|
|
32
65
|
DiscountBadge.defaultProps = {
|
|
33
66
|
className: '',
|
|
34
67
|
discount: null,
|