@shopgate/pwa-ui-shared 7.30.4-beta.1 → 7.31.0-alpha.2

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.
Files changed (326) hide show
  1. package/ActionButton/index.js +66 -67
  2. package/AddToCartButton/index.js +217 -185
  3. package/AddToCartButton/style.js +8 -0
  4. package/Availability/index.js +24 -6
  5. package/Button/index.js +105 -82
  6. package/Button/spec.js +3 -4
  7. package/Card/index.js +26 -7
  8. package/CardList/components/Item/index.js +15 -3
  9. package/CartTotalLine/components/Amount/index.js +13 -4
  10. package/CartTotalLine/components/Hint/index.js +13 -4
  11. package/CartTotalLine/components/Label/index.js +23 -10
  12. package/CartTotalLine/index.js +41 -7
  13. package/Checkbox/index.js +41 -17
  14. package/Chip/index.js +82 -7
  15. package/ContextMenu/components/Item/index.js +38 -20
  16. package/ContextMenu/components/Position/index.js +38 -56
  17. package/ContextMenu/index.js +64 -28
  18. package/Dialog/components/BasicDialog/index.js +1 -0
  19. package/Dialog/components/HtmlContentDialog/spec.js +39 -0
  20. package/Dialog/components/PipelineErrorDialog/index.js +108 -157
  21. package/Dialog/components/PipelineErrorDialog/spec.js +12 -18
  22. package/Dialog/components/TextMessageDialog/index.js +1 -1
  23. package/Dialog/components/VariantSelectModal/index.js +1 -1
  24. package/Dialog/index.js +1 -1
  25. package/DiscountBadge/index.js +48 -15
  26. package/FavoritesButton/index.js +95 -100
  27. package/FavoritesButton/spec.js +5 -2
  28. package/Form/Builder/classes/ActionListener/index.js +1 -0
  29. package/Form/Checkbox/index.js +64 -56
  30. package/Form/InfoField/index.js +18 -6
  31. package/Form/Password/index.js +39 -52
  32. package/Form/RadioGroup/components/Item/index.js +72 -56
  33. package/Form/RadioGroup/index.js +79 -90
  34. package/Form/Select/index.js +108 -130
  35. package/Form/SelectContextChoices/index.js +30 -8
  36. package/Form/TextField/index.js +106 -82
  37. package/Form/TextField/spec.js +4 -3
  38. package/FormElement/components/ErrorText/index.js +32 -14
  39. package/FormElement/components/Label/index.js +56 -6
  40. package/FormElement/components/Placeholder/index.js +44 -11
  41. package/FormElement/components/Underline/index.js +63 -12
  42. package/FormElement/index.js +62 -85
  43. package/Glow/index.js +73 -83
  44. package/IndicatorCircle/index.js +73 -17
  45. package/IndicatorCircle/spec.js +2 -5
  46. package/LoadingIndicator/index.js +34 -12
  47. package/Manufacturer/index.js +21 -10
  48. package/MessageBar/index.js +12 -38
  49. package/NoResults/components/Icon/index.js +30 -14
  50. package/NoResults/index.js +35 -7
  51. package/Placeholder/index.js +34 -23
  52. package/PlaceholderLabel/index.js +17 -3
  53. package/Price/index.js +34 -21
  54. package/PriceInfo/index.js +23 -9
  55. package/PriceStriked/index.js +67 -77
  56. package/ProgressBar/index.js +112 -77
  57. package/RadioButton/index.js +29 -11
  58. package/RatingStars/index.js +122 -137
  59. package/Ripple/components/RippleAnimation/index.js +13 -3
  60. package/Ripple/index.js +158 -212
  61. package/RippleButton/index.js +63 -60
  62. package/RippleButton/spec.js +15 -9
  63. package/ScannerOverlay/components/CameraOverlay/index.js +54 -10
  64. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +53 -27
  65. package/ScannerOverlay/components/ScannerBar/index.js +50 -26
  66. package/Sheet/components/Header/components/SearchBar/index.js +54 -10
  67. package/Sheet/components/Header/index.js +96 -76
  68. package/Sheet/index.js +295 -157
  69. package/Sheet/spec.js +8 -6
  70. package/TaxDisclaimer/index.js +17 -4
  71. package/TaxDisclaimer/spec.js +16 -5
  72. package/TextField/components/ErrorText/index.js +35 -14
  73. package/TextField/components/FormElement/index.js +29 -4
  74. package/TextField/components/Hint/index.js +39 -10
  75. package/TextField/components/Label/index.js +43 -6
  76. package/TextField/components/Underline/index.js +64 -13
  77. package/TextField/index.js +157 -171
  78. package/TextField/spec.js +5 -3
  79. package/icons/AccountBoxIcon.d.ts +7 -0
  80. package/icons/AccountBoxIcon.d.ts.map +1 -0
  81. package/icons/AccountBoxIcon.js +1 -4
  82. package/icons/AddMoreIcon.d.ts +7 -0
  83. package/icons/AddMoreIcon.d.ts.map +1 -0
  84. package/icons/AddMoreIcon.js +0 -3
  85. package/icons/ArrowDropIcon.d.ts +7 -0
  86. package/icons/ArrowDropIcon.d.ts.map +1 -0
  87. package/icons/ArrowDropIcon.js +0 -3
  88. package/icons/ArrowIcon.d.ts +10 -0
  89. package/icons/ArrowIcon.d.ts.map +1 -0
  90. package/icons/ArrowIcon.js +2 -11
  91. package/icons/BarcodeScannerIcon.d.ts +7 -0
  92. package/icons/BarcodeScannerIcon.d.ts.map +1 -0
  93. package/icons/BarcodeScannerIcon.js +0 -3
  94. package/icons/BoxIcon.d.ts +7 -0
  95. package/icons/BoxIcon.d.ts.map +1 -0
  96. package/icons/BoxIcon.js +0 -3
  97. package/icons/BrowseIcon.d.ts +7 -0
  98. package/icons/BrowseIcon.d.ts.map +1 -0
  99. package/icons/BrowseIcon.js +1 -3
  100. package/icons/BurgerIcon.d.ts +7 -0
  101. package/icons/BurgerIcon.d.ts.map +1 -0
  102. package/icons/BurgerIcon.js +0 -3
  103. package/icons/CalendarIcon.d.ts +7 -0
  104. package/icons/CalendarIcon.d.ts.map +1 -0
  105. package/icons/CalendarIcon.js +0 -2
  106. package/icons/CartCouponIcon.d.ts +7 -0
  107. package/icons/CartCouponIcon.d.ts.map +1 -0
  108. package/icons/CartCouponIcon.js +0 -2
  109. package/icons/CartIcon.d.ts +7 -0
  110. package/icons/CartIcon.d.ts.map +1 -0
  111. package/icons/CartIcon.js +0 -2
  112. package/icons/CartPlusIcon.d.ts +7 -0
  113. package/icons/CartPlusIcon.d.ts.map +1 -0
  114. package/icons/CartPlusIcon.js +0 -2
  115. package/icons/CheckIcon.d.ts +7 -0
  116. package/icons/CheckIcon.d.ts.map +1 -0
  117. package/icons/CheckIcon.js +0 -2
  118. package/icons/CheckedIcon.d.ts +7 -0
  119. package/icons/CheckedIcon.d.ts.map +1 -0
  120. package/icons/CheckedIcon.js +0 -3
  121. package/icons/ChevronIcon.d.ts +7 -0
  122. package/icons/ChevronIcon.d.ts.map +1 -0
  123. package/icons/ChevronIcon.js +0 -2
  124. package/icons/CreditCardIcon.d.ts +7 -0
  125. package/icons/CreditCardIcon.d.ts.map +1 -0
  126. package/icons/CreditCardIcon.js +0 -2
  127. package/icons/CrossIcon.d.ts +7 -0
  128. package/icons/CrossIcon.d.ts.map +1 -0
  129. package/icons/CrossIcon.js +0 -2
  130. package/icons/DescriptionIcon.d.ts +7 -0
  131. package/icons/DescriptionIcon.d.ts.map +1 -0
  132. package/icons/DescriptionIcon.js +0 -2
  133. package/icons/FilterIcon.d.ts +7 -0
  134. package/icons/FilterIcon.d.ts.map +1 -0
  135. package/icons/FilterIcon.js +0 -2
  136. package/icons/FlashDisabledIcon.d.ts +7 -0
  137. package/icons/FlashDisabledIcon.d.ts.map +1 -0
  138. package/icons/FlashDisabledIcon.js +0 -2
  139. package/icons/FlashEnabledIcon.d.ts +7 -0
  140. package/icons/FlashEnabledIcon.d.ts.map +1 -0
  141. package/icons/FlashEnabledIcon.js +0 -2
  142. package/icons/GridIcon.d.ts +7 -0
  143. package/icons/GridIcon.d.ts.map +1 -0
  144. package/icons/GridIcon.js +1 -3
  145. package/icons/HeartIcon.d.ts +7 -0
  146. package/icons/HeartIcon.d.ts.map +1 -0
  147. package/icons/HeartIcon.js +0 -2
  148. package/icons/HeartOutlineIcon.d.ts +7 -0
  149. package/icons/HeartOutlineIcon.d.ts.map +1 -0
  150. package/icons/HeartOutlineIcon.js +1 -3
  151. package/icons/HeartPlusIcon.d.ts +7 -0
  152. package/icons/HeartPlusIcon.d.ts.map +1 -0
  153. package/icons/HeartPlusIcon.js +1 -3
  154. package/icons/HeartPlusOutlineIcon.d.ts +7 -0
  155. package/icons/HeartPlusOutlineIcon.d.ts.map +1 -0
  156. package/icons/HeartPlusOutlineIcon.js +1 -3
  157. package/icons/HomeIcon.d.ts +7 -0
  158. package/icons/HomeIcon.d.ts.map +1 -0
  159. package/icons/HomeIcon.js +0 -2
  160. package/icons/InfoIcon.d.ts +7 -0
  161. package/icons/InfoIcon.d.ts.map +1 -0
  162. package/icons/InfoIcon.js +0 -2
  163. package/icons/InfoOutlineIcon.d.ts +7 -0
  164. package/icons/InfoOutlineIcon.d.ts.map +1 -0
  165. package/icons/InfoOutlineIcon.js +0 -2
  166. package/icons/ListIcon.d.ts +7 -0
  167. package/icons/ListIcon.d.ts.map +1 -0
  168. package/icons/ListIcon.js +0 -2
  169. package/icons/LocalShippingIcon.d.ts +7 -0
  170. package/icons/LocalShippingIcon.d.ts.map +1 -0
  171. package/icons/LocalShippingIcon.js +0 -2
  172. package/icons/LocationIcon.d.ts +7 -0
  173. package/icons/LocationIcon.d.ts.map +1 -0
  174. package/icons/LocationIcon.js +1 -4
  175. package/icons/LocatorIcon.d.ts +7 -0
  176. package/icons/LocatorIcon.d.ts.map +1 -0
  177. package/icons/LocatorIcon.js +1 -3
  178. package/icons/LockIcon.d.ts +9 -0
  179. package/icons/LockIcon.d.ts.map +1 -0
  180. package/icons/LockIcon.js +1 -2
  181. package/icons/LogoutIcon.d.ts +7 -0
  182. package/icons/LogoutIcon.d.ts.map +1 -0
  183. package/icons/LogoutIcon.js +0 -2
  184. package/icons/MagnifierIcon.d.ts +7 -0
  185. package/icons/MagnifierIcon.d.ts.map +1 -0
  186. package/icons/MagnifierIcon.js +0 -2
  187. package/icons/MapMarkerIcon.d.ts +7 -0
  188. package/icons/MapMarkerIcon.d.ts.map +1 -0
  189. package/icons/MapMarkerIcon.js +1 -3
  190. package/icons/MoreIcon.d.ts +7 -0
  191. package/icons/MoreIcon.d.ts.map +1 -0
  192. package/icons/MoreIcon.js +1 -3
  193. package/icons/MoreVertIcon.d.ts +7 -0
  194. package/icons/MoreVertIcon.d.ts.map +1 -0
  195. package/icons/MoreVertIcon.js +1 -3
  196. package/icons/NotificationIcon.d.ts +7 -0
  197. package/icons/NotificationIcon.d.ts.map +1 -0
  198. package/icons/NotificationIcon.js +1 -3
  199. package/icons/PersonIcon.d.ts +9 -0
  200. package/icons/PersonIcon.d.ts.map +1 -0
  201. package/icons/PersonIcon.js +0 -3
  202. package/icons/PhoneIcon.d.ts +7 -0
  203. package/icons/PhoneIcon.d.ts.map +1 -0
  204. package/icons/PhoneIcon.js +1 -4
  205. package/icons/PlaceholderIcon.d.ts +7 -0
  206. package/icons/PlaceholderIcon.d.ts.map +1 -0
  207. package/icons/PlaceholderIcon.js +0 -2
  208. package/icons/RadioCheckedIcon.d.ts +10 -0
  209. package/icons/RadioCheckedIcon.d.ts.map +1 -0
  210. package/icons/RadioCheckedIcon.js +0 -2
  211. package/icons/RadioUncheckedIcon.d.ts +10 -0
  212. package/icons/RadioUncheckedIcon.d.ts.map +1 -0
  213. package/icons/RadioUncheckedIcon.js +0 -2
  214. package/icons/SecurityIcon.d.ts +7 -0
  215. package/icons/SecurityIcon.d.ts.map +1 -0
  216. package/icons/SecurityIcon.js +0 -2
  217. package/icons/ShippingMethodIcon.d.ts +7 -0
  218. package/icons/ShippingMethodIcon.d.ts.map +1 -0
  219. package/icons/ShippingMethodIcon.js +0 -2
  220. package/icons/ShoppingCartIcon.d.ts +7 -0
  221. package/icons/ShoppingCartIcon.d.ts.map +1 -0
  222. package/icons/ShoppingCartIcon.js +0 -2
  223. package/icons/SortIcon.d.ts +7 -0
  224. package/icons/SortIcon.d.ts.map +1 -0
  225. package/icons/SortIcon.js +0 -2
  226. package/icons/StarHalfIcon.d.ts +7 -0
  227. package/icons/StarHalfIcon.d.ts.map +1 -0
  228. package/icons/StarHalfIcon.js +0 -9
  229. package/icons/StarIcon.d.ts +7 -0
  230. package/icons/StarIcon.d.ts.map +1 -0
  231. package/icons/StarIcon.js +0 -9
  232. package/icons/StarOutlineIcon.d.ts +7 -0
  233. package/icons/StarOutlineIcon.d.ts.map +1 -0
  234. package/icons/StarOutlineIcon.js +0 -2
  235. package/icons/StopIcon.d.ts +7 -0
  236. package/icons/StopIcon.d.ts.map +1 -0
  237. package/icons/StopIcon.js +0 -2
  238. package/icons/TickIcon.d.ts +7 -0
  239. package/icons/TickIcon.d.ts.map +1 -0
  240. package/icons/TickIcon.js +0 -2
  241. package/icons/TimeIcon.d.ts +7 -0
  242. package/icons/TimeIcon.d.ts.map +1 -0
  243. package/icons/TimeIcon.js +0 -2
  244. package/icons/TrashIcon.d.ts +7 -0
  245. package/icons/TrashIcon.d.ts.map +1 -0
  246. package/icons/TrashIcon.js +0 -3
  247. package/icons/TrashOutlineIcon.d.ts +8 -0
  248. package/icons/TrashOutlineIcon.d.ts.map +1 -0
  249. package/icons/TrashOutlineIcon.js +0 -2
  250. package/icons/UncheckedIcon.d.ts +7 -0
  251. package/icons/UncheckedIcon.d.ts.map +1 -0
  252. package/icons/UncheckedIcon.js +0 -2
  253. package/icons/ViewListIcon.d.ts +7 -0
  254. package/icons/ViewListIcon.d.ts.map +1 -0
  255. package/icons/ViewListIcon.js +0 -2
  256. package/icons/VisibilityIcon.d.ts +8 -0
  257. package/icons/VisibilityIcon.d.ts.map +1 -0
  258. package/icons/VisibilityIcon.js +2 -4
  259. package/icons/VisibilityOffIcon.d.ts +8 -0
  260. package/icons/VisibilityOffIcon.d.ts.map +1 -0
  261. package/icons/VisibilityOffIcon.js +2 -4
  262. package/icons/WarningIcon.d.ts +7 -0
  263. package/icons/WarningIcon.d.ts.map +1 -0
  264. package/icons/WarningIcon.js +1 -3
  265. package/package.json +5 -5
  266. package/tsconfig.build.json +16 -0
  267. package/tsconfig.json +3 -0
  268. package/ActionButton/style.js +0 -22
  269. package/Availability/style.js +0 -19
  270. package/Button/style.js +0 -155
  271. package/Card/style.js +0 -11
  272. package/CardList/components/Item/style.js +0 -7
  273. package/CartTotalLine/components/Amount/style.js +0 -8
  274. package/CartTotalLine/components/Hint/style.js +0 -12
  275. package/CartTotalLine/components/Label/style.js +0 -17
  276. package/CartTotalLine/style.js +0 -31
  277. package/Checkbox/style.js +0 -18
  278. package/Chip/style.js +0 -78
  279. package/ContextMenu/components/Item/style.js +0 -34
  280. package/ContextMenu/components/Position/style.js +0 -11
  281. package/ContextMenu/style.js +0 -45
  282. package/DiscountBadge/style.js +0 -36
  283. package/FavoritesButton/style.js +0 -26
  284. package/Form/Checkbox/style.js +0 -25
  285. package/Form/InfoField/style.js +0 -11
  286. package/Form/Password/style.js +0 -11
  287. package/Form/RadioGroup/components/Item/style.js +0 -32
  288. package/Form/RadioGroup/style.js +0 -20
  289. package/Form/Select/style.js +0 -27
  290. package/Form/SelectContextChoices/style.js +0 -23
  291. package/Form/TextField/style.js +0 -70
  292. package/FormElement/components/ErrorText/style.js +0 -13
  293. package/FormElement/components/Label/style.js +0 -89
  294. package/FormElement/components/Placeholder/style.js +0 -56
  295. package/FormElement/components/Underline/style.js +0 -60
  296. package/FormElement/style.js +0 -14
  297. package/Glow/style.js +0 -18
  298. package/IndicatorCircle/style.js +0 -65
  299. package/LoadingIndicator/style.js +0 -20
  300. package/Manufacturer/style.js +0 -5
  301. package/MessageBar/spec.js +0 -80
  302. package/MessageBar/style.js +0 -38
  303. package/NoResults/components/Icon/style.js +0 -17
  304. package/NoResults/style.js +0 -31
  305. package/Placeholder/style.js +0 -11
  306. package/PlaceholderLabel/style.js +0 -12
  307. package/Price/style.js +0 -22
  308. package/PriceInfo/style.js +0 -5
  309. package/PriceStriked/style.js +0 -36
  310. package/ProgressBar/style.js +0 -85
  311. package/RadioButton/style.js +0 -21
  312. package/RatingStars/style.js +0 -53
  313. package/Ripple/style.js +0 -18
  314. package/ScannerOverlay/components/CameraOverlay/style.js +0 -40
  315. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +0 -28
  316. package/ScannerOverlay/components/ScannerBar/style.js +0 -20
  317. package/Sheet/components/Header/components/SearchBar/style.js +0 -47
  318. package/Sheet/components/Header/style.js +0 -50
  319. package/Sheet/style.js +0 -143
  320. package/TaxDisclaimer/style.js +0 -9
  321. package/TextField/components/ErrorText/style.js +0 -27
  322. package/TextField/components/FormElement/style.js +0 -34
  323. package/TextField/components/Hint/style.js +0 -46
  324. package/TextField/components/Label/style.js +0 -80
  325. package/TextField/components/Underline/style.js +0 -60
  326. package/TextField/style.js +0 -35
@@ -1,8 +1,6 @@
1
- import _createClass from "@babel/runtime/helpers/createClass";
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/pwa-common/components/I18n';
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 behaviour of this message is that the user may tap the message body
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
- let PipelineErrorDialog = /*#__PURE__*/function (_Component) {
25
- /**
26
- * Creates the component.
27
- * @param {Object} props The component props.
28
- */
29
- function PipelineErrorDialog(props) {
30
- var _this;
31
- _this = _Component.call(this, props) || this;
32
- /**
33
- * Clears the tap counter once the
34
- */
35
- _this.handleTapTimeout = () => {
36
- _this.tapCounter = 0;
37
- };
38
- /**
39
- * User tapped the message, increase the tap counter and switch view modes if required.
40
- */
41
- _this.handleClick = () => {
42
- _this.tapCounter += 1;
43
- if (_this.tapTimeout) {
44
- // Clear the timeout.
45
- clearTimeout(_this.tapTimeout);
46
- }
47
- if (_this.tapCounter >= requiredTapsToSwitchModes) {
48
- // Switch modes and reset the tap counter.
49
- _this.tapCounter = 0;
50
- _this.setState(({
51
- devMode
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
- * @return {string} The title based on the current state of the dialog.
62
+ * @returns {JSX.Element}
148
63
  */
149
- _inheritsLoose(PipelineErrorDialog, _Component);
150
- var _proto = PipelineErrorDialog.prototype;
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
- * Renders the error message depending on the current mode.
153
- * @return {JSX}
112
+ * @returns {JSX.Element}
154
113
  */
155
- _proto.render = function render() {
156
- return /*#__PURE__*/_jsx(BasicDialog, {
157
- title: this.title,
158
- actions: this.props.actions,
159
- children: /*#__PURE__*/_jsx("div", {
160
- onClick: this.handleClick,
161
- children: this.content
162
- })
163
- });
164
- };
165
- return _createClass(PipelineErrorDialog, [{
166
- key: "title",
167
- get: function () {
168
- return this.state.devMode ? 'Pipeline Error' : 'modal.title_error';
169
- }
170
-
171
- /**
172
- * @return {JSX} The content component based on the the current state of the dialog.
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.state().devMode).toBe(false);
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.state().devMode).toBe(true);
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
- // Dev mode should be disabled again.
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
- // Dev mode should be disabled.
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/pwa-common/components/I18n';
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/pwa-common/components/I18n';
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/pwa-common/components/I18n';
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";
@@ -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 styles from "./style";
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
- }) => /*#__PURE__*/_jsx("div", {
21
- "data-test-id": text,
22
- className: "ui-shared__discount-badge",
23
- "aria-label": `${i18n.text('cart.discount')}: ${text}`,
24
- tabIndex: -1,
25
- children: /*#__PURE__*/_jsx(I18n.Text, {
26
- className: `${styles[display]} ${className} theme__discount-badge`,
27
- string: text,
28
- params: [discount],
29
- "aria-hidden": true
30
- })
31
- });
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,