@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,121 +1,116 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { useCallback, useRef, useMemo, memo } from 'react';
3
2
  import PropTypes from 'prop-types';
4
- import appConfig from '@shopgate/pwa-common/helpers/config';
3
+ import appConfig, { themeShadows, themeColors } from '@shopgate/pwa-common/helpers/config';
4
+ import { i18n } from '@shopgate/engage/core/helpers';
5
+ import { makeStyles } from '@shopgate/engage/styles';
5
6
  import HeartIcon from "../icons/HeartIcon";
6
7
  import HeartOutlineIcon from "../icons/HeartOutlineIcon";
7
8
  import HeartPlusOutlineIcon from "../icons/HeartPlusOutlineIcon";
8
9
  import HeartPlus from "../icons/HeartPlusIcon";
9
10
  import Ripple from "../Ripple";
10
- import styles from "./style";
11
11
  import connect from "./connector";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const buttonProto = {
14
+ display: 'block',
15
+ position: 'relative',
16
+ background: themeColors.light,
17
+ borderRadius: '50%',
18
+ padding: 0,
19
+ fontSize: 20,
20
+ lineHeight: 1,
21
+ color: 'var(--color-secondary)',
22
+ outline: 0
23
+ };
24
+ const useStyles = makeStyles()({
25
+ buttonFlat: {
26
+ ...buttonProto
27
+ },
28
+ button: {
29
+ ...buttonProto,
30
+ boxShadow: themeShadows.buttons.elevated
31
+ },
32
+ ripple: {
33
+ padding: 6
34
+ }
35
+ });
12
36
 
13
37
  /**
14
38
  * The favorites button component.
39
+ * @param {Object} props Props.
40
+ * @returns {JSX.Element|null}
15
41
  */
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
- let FavoritesButton = /*#__PURE__*/function (_Component) {
18
- /**
19
- * Construct and init state
20
- * @param {Object} props Component props
21
- */
22
- function FavoritesButton(props) {
23
- var _this;
24
- _this = _Component.call(this, props) || this;
25
- /**
26
- * Callback for the moment when the ripple animation is done.
27
- */
28
- _this.onRippleComplete = () => {
29
- _this.props.onRippleComplete(_this.props.active);
30
- };
31
- /**
32
- * Adds or removes a given product ID from the favorite list.
33
- * @param {Object} event The click event object.
34
- */
35
- _this.handleClick = event => {
36
- event.preventDefault();
37
- event.stopPropagation();
38
- if (_this.props.once && _this.clickedOnce) {
39
- return;
40
- }
41
- _this.clickedOnce = true;
42
- if (!_this.props.productId) {
43
- return;
44
- }
45
-
46
- // When wishlist item quantity is active, items cannot be removed via the button
47
- if (!_this.props.active || _this.props.wishlistItemQuantityEnabled) {
48
- _this.props.addFavorites(_this.props.productId);
49
- } else {
50
- setTimeout(() => {
51
- _this.props.removeFavorites(_this.props.productId, _this.props.removeWithRelatives);
52
- }, _this.props.removeThrottle);
53
- }
54
- };
55
- _this.clickedOnce = false;
56
- return _this;
57
- }
58
- _inheritsLoose(FavoritesButton, _Component);
59
- var _proto = FavoritesButton.prototype;
60
- /**
61
- * Returns text for aria-label.
62
- * @returns {string}
63
- */
64
- _proto.getLabel = function getLabel() {
65
- const {
66
- __
67
- } = this.context.i18n();
68
- const lang = this.props.active ? 'favorites.remove' : 'favorites.add';
69
- return __(lang);
70
- };
71
- /**
72
- * Renders the heart icon as filled or outlined, depending on the favorite button being active.
73
- * @returns {JSX}
74
- */
75
- _proto.renderIcon = function renderIcon() {
76
- if (!this.props.loadWishlistOnAppStartEnabled || this.props.wishlistItemQuantityEnabled && !this.props.active) {
42
+ const FavoritesButton = ({
43
+ active,
44
+ addFavorites,
45
+ 'aria-hidden': ariaHidden,
46
+ className,
47
+ loadWishlistOnAppStartEnabled,
48
+ noShadow,
49
+ once,
50
+ onRippleComplete,
51
+ productId,
52
+ removeFavorites,
53
+ removeThrottle,
54
+ removeWithRelatives,
55
+ rippleClassName,
56
+ wishlistItemQuantityEnabled
57
+ }) => {
58
+ const {
59
+ classes,
60
+ cx
61
+ } = useStyles();
62
+ const clickedOnceRef = useRef(false);
63
+ const handleRippleComplete = useCallback(() => {
64
+ onRippleComplete(active);
65
+ }, [onRippleComplete, active]);
66
+ const handleClick = useCallback(event => {
67
+ event.preventDefault();
68
+ event.stopPropagation();
69
+ if (once && clickedOnceRef.current) {
70
+ return;
71
+ }
72
+ clickedOnceRef.current = true;
73
+ if (!productId) {
74
+ return;
75
+ }
76
+ if (!active || wishlistItemQuantityEnabled) {
77
+ addFavorites(productId);
78
+ } else {
79
+ setTimeout(() => {
80
+ removeFavorites(productId, removeWithRelatives);
81
+ }, removeThrottle);
82
+ }
83
+ }, [once, productId, active, wishlistItemQuantityEnabled, addFavorites, removeFavorites, removeWithRelatives, removeThrottle]);
84
+ const icon = useMemo(() => {
85
+ if (!loadWishlistOnAppStartEnabled || wishlistItemQuantityEnabled && !active) {
77
86
  return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
78
87
  }
79
- if (this.props.wishlistItemQuantityEnabled && this.props.active) {
88
+ if (wishlistItemQuantityEnabled && active) {
80
89
  return /*#__PURE__*/_jsx(HeartPlus, {});
81
90
  }
82
- if (this.props.active) {
91
+ if (active) {
83
92
  return /*#__PURE__*/_jsx(HeartIcon, {});
84
93
  }
85
94
  return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
95
+ }, [loadWishlistOnAppStartEnabled, wishlistItemQuantityEnabled, active]);
96
+ if (!appConfig.hasFavorites) {
97
+ return null;
86
98
  }
87
-
88
- /**
89
- * Renders the component.
90
- * @returns {JSX|null}
91
- */;
92
- _proto.render = function render() {
93
- if (!appConfig.hasFavorites) {
94
- return null;
95
- }
96
- const className = this.props.noShadow ? styles.buttonFlat : styles.button;
97
- return /*#__PURE__*/_jsx("button", {
98
- "aria-label": this.getLabel(),
99
- "aria-hidden": this.props['aria-hidden'],
100
- className: `ui-shared__favorites-button ${className} ${this.props.className}`,
101
- onClick: this.handleClick,
102
- "data-test-id": "favoriteButton",
103
- type: "button",
104
- children: /*#__PURE__*/_jsx(Ripple, {
105
- className: `${styles.ripple} ${this.props.rippleClassName}`,
106
- onComplete: this.onRippleComplete,
107
- children: this.renderIcon()
108
- })
109
- });
110
- };
111
- return FavoritesButton;
112
- }(Component);
113
- /**
114
- * Context types definition.
115
- * @type {{i18n: shim}}
116
- */
117
- FavoritesButton.contextTypes = {
118
- i18n: PropTypes.func
99
+ const buttonClass = noShadow ? classes.buttonFlat : classes.button;
100
+ const ariaLabel = i18n.text(active ? 'favorites.remove' : 'favorites.add');
101
+ return /*#__PURE__*/_jsx("button", {
102
+ "aria-label": ariaLabel,
103
+ "aria-hidden": ariaHidden,
104
+ className: cx('ui-shared__favorites-button', buttonClass, className),
105
+ onClick: handleClick,
106
+ "data-test-id": "favoriteButton",
107
+ type: "button",
108
+ children: /*#__PURE__*/_jsx(Ripple, {
109
+ className: cx(classes.ripple, rippleClassName),
110
+ onComplete: handleRippleComplete,
111
+ children: icon
112
+ })
113
+ });
119
114
  };
120
115
  FavoritesButton.defaultProps = {
121
116
  active: false,
@@ -133,4 +128,4 @@ FavoritesButton.defaultProps = {
133
128
  wishlistItemQuantityEnabled: false,
134
129
  loadWishlistOnAppStartEnabled: true
135
130
  };
136
- export default connect(FavoritesButton);
131
+ export default connect(/*#__PURE__*/memo(FavoritesButton));
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { act } from 'react-dom/test-utils';
2
3
  import { Provider } from 'react-redux';
3
4
  import configureStore from 'redux-mock-store';
4
5
  import { mount } from 'enzyme';
@@ -80,14 +81,16 @@ describe('<FavoritesButton />', () => {
80
81
  done();
81
82
  }, 0);
82
83
  });
83
- it('should process ripple complete callback', () => {
84
+ it('should process ripple complete callback', async () => {
84
85
  const onRippleComplete = jest.fn();
85
86
  component = createComponent(mockedStateOnList, {
86
87
  productId: '1',
87
88
  active: true,
88
89
  onRippleComplete
89
90
  });
90
- component.find('Ripple').instance().props.onComplete();
91
+ await act(async () => {
92
+ component.find('Ripple').invoke('onComplete')();
93
+ });
91
94
  component.update();
92
95
  expect(onRippleComplete).toHaveBeenCalled();
93
96
  });
@@ -1,3 +1,4 @@
1
+ import "core-js/modules/es.array.includes.js";
1
2
  import { logger } from '@shopgate/pwa-core/helpers';
2
3
  import { ELEMENT_TYPE_NUMBER, ELEMENT_TYPE_COUNTRY, ELEMENT_TYPE_PROVINCE, ELEMENT_TYPE_CHECKBOX } from "../../elementTypes";
3
4
  import { ACTION_TYPE_UPDATE_PROVINCE_ELEMENT, ACTION_TYPE_SET_VISIBILITY, ACTION_TYPE_SET_VALUE, ACTION_TYPE_TRANSFORM, ACTION_SET_VALUE_FIXED, ACTION_SET_VALUE_COPY_FROM, ACTION_SET_VALUE_LENGTH_OF, ACTION_RULE_TYPE_NOT_IN, ACTION_RULE_TYPE_ONE_OF, ACTION_RULE_TYPE_BOOLEAN, ACTION_RULE_TYPE_REGEX, ACTION_RULE_DATA_TYPES, ACTION_RULES_CONCAT_METHOD_ALL, ACTION_RULES_CONCAT_METHOD_ANY, ACTION_RULES_CONCAT_METHOD_NONE } from "./constants";
@@ -1,11 +1,28 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { PureComponent } from 'react';
1
+ import React from 'react';
3
2
  import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
- import I18n from '@shopgate/pwa-common/components/I18n';
3
+ import { I18n } from '@shopgate/engage/components';
6
4
  import UICheckbox from '@shopgate/pwa-ui-shared/Checkbox';
7
5
  import FormElement from '@shopgate/pwa-ui-shared/FormElement';
8
- import style from "./style";
6
+ import { makeStyles } from '@shopgate/engage/styles';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const useStyles = makeStyles()(theme => ({
9
+ root: {
10
+ marginLeft: -2,
11
+ cursor: 'pointer',
12
+ '& svg': {
13
+ float: 'left'
14
+ }
15
+ },
16
+ label: {
17
+ lineHeight: 1.6
18
+ },
19
+ labelWrapper: {
20
+ marginLeft: theme.spacing(4)
21
+ },
22
+ checked: {
23
+ color: 'var(--color-primary)'
24
+ }
25
+ }));
9
26
 
10
27
  /**
11
28
  * @typedef {Object} Props
@@ -27,57 +44,48 @@ import style from "./style";
27
44
  * @extends {React.Component<Props>}
28
45
  * @returns {JSX.Element}
29
46
  */
30
- import { jsx as _jsx } from "react/jsx-runtime";
31
- let Checkbox = /*#__PURE__*/function (_PureComponent) {
32
- function Checkbox() {
33
- return _PureComponent.apply(this, arguments) || this;
34
- }
35
- _inheritsLoose(Checkbox, _PureComponent);
36
- var _proto = Checkbox.prototype;
37
- /**
38
- * @return {JSX}
39
- */
40
- _proto.render = function render() {
41
- const {
42
- name,
43
- label,
44
- onChange,
45
- className,
46
- errorText,
47
- translateErrorText,
48
- showErrorText,
49
- checkboxClassName,
50
- ...restProps
51
- } = this.props;
52
- return /*#__PURE__*/_jsx(FormElement, {
53
- className: classNames(className, style.root, 'checkbox', 'ui-shared__form__checkbox'),
54
- htmlFor: name,
55
- errorText: errorText,
56
- translateErrorText: translateErrorText,
57
- hasUnderline: false,
58
- hasPlaceholder: false,
59
- disabled: restProps.disabled,
60
- showErrorText: showErrorText,
61
- children: /*#__PURE__*/_jsx(UICheckbox, {
62
- ...restProps,
63
- className: checkboxClassName,
64
- name: name,
65
- onCheck: onChange,
66
- checkedClassName: `${className} ${style.checked}`,
67
- unCheckedClassName: className,
68
- labelPosition: "right",
69
- label: typeof label === 'string' ? /*#__PURE__*/_jsx("div", {
70
- className: classNames(style.labelWrapper, 'label'),
71
- children: /*#__PURE__*/_jsx(I18n.Text, {
72
- className: style.label,
73
- string: label
74
- })
75
- }) : label
76
- })
77
- });
78
- };
79
- return Checkbox;
80
- }(PureComponent);
47
+ const Checkbox = ({
48
+ name,
49
+ label,
50
+ onChange,
51
+ className,
52
+ errorText,
53
+ translateErrorText,
54
+ showErrorText,
55
+ checkboxClassName,
56
+ ...restProps
57
+ }) => {
58
+ const {
59
+ classes,
60
+ cx
61
+ } = useStyles();
62
+ return /*#__PURE__*/_jsx(FormElement, {
63
+ className: cx(classes.root, 'checkbox', 'ui-shared__form__checkbox', className),
64
+ htmlFor: name,
65
+ errorText: errorText,
66
+ translateErrorText: translateErrorText,
67
+ hasUnderline: false,
68
+ hasPlaceholder: false,
69
+ disabled: restProps.disabled,
70
+ showErrorText: showErrorText,
71
+ children: /*#__PURE__*/_jsx(UICheckbox, {
72
+ ...restProps,
73
+ className: checkboxClassName,
74
+ name: name,
75
+ onCheck: onChange,
76
+ checkedClassName: `${className} ${classes.checked}`,
77
+ unCheckedClassName: className,
78
+ labelPosition: "right",
79
+ label: typeof label === 'string' ? /*#__PURE__*/_jsx("div", {
80
+ className: cx(classes.labelWrapper, 'label'),
81
+ children: /*#__PURE__*/_jsx(I18n.Text, {
82
+ className: classes.label,
83
+ string: label
84
+ })
85
+ }) : label
86
+ })
87
+ });
88
+ };
81
89
  Checkbox.defaultProps = {
82
90
  className: '',
83
91
  checkboxClassName: undefined,
@@ -1,14 +1,22 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Grid from '@shopgate/pwa-common/components/Grid';
4
+ import { makeStyles } from '@shopgate/engage/styles';
4
5
  import FormElement from "../../FormElement";
5
- import style from "./style";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const useStyles = makeStyles()({
8
+ info: {
9
+ paddingTop: 24
10
+ },
11
+ element: {
12
+ marginTop: 16
13
+ }
14
+ });
6
15
 
7
16
  /**
8
- * @param {Object} props .
17
+ * @param {Object} props Props.
9
18
  * @returns {JSX}
10
19
  */
11
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
20
  const InfoField = props => {
13
21
  const {
14
22
  className,
@@ -21,6 +29,10 @@ const InfoField = props => {
21
29
  hasValue,
22
30
  showErrorText
23
31
  } = props;
32
+ const {
33
+ classes,
34
+ cx
35
+ } = useStyles();
24
36
  return /*#__PURE__*/_jsx(FormElement, {
25
37
  className: className,
26
38
  label: label,
@@ -32,15 +44,15 @@ const InfoField = props => {
32
44
  children: /*#__PURE__*/_jsxs(Grid, {
33
45
  children: [leftElement && /*#__PURE__*/_jsx(Grid.Item, {
34
46
  grow: 0,
35
- className: style.element,
47
+ className: classes.element,
36
48
  children: leftElement
37
49
  }), /*#__PURE__*/_jsx(Grid.Item, {
38
50
  grow: 1,
39
- className: `${style.info} info-field`,
51
+ className: cx(classes.info, 'info-field'),
40
52
  children: children
41
53
  }), rightElement && /*#__PURE__*/_jsx(Grid.Item, {
42
54
  grow: 0,
43
- className: style.element,
55
+ className: classes.element,
44
56
  children: rightElement
45
57
  })]
46
58
  })
@@ -1,62 +1,49 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { useState, useCallback } from 'react';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ import { makeStyles } from '@shopgate/engage/styles';
3
4
  import ToggleIcon from "../../ToggleIcon";
4
5
  import VisibilityIcon from "../../icons/VisibilityIcon";
5
6
  import VisibilityOffIcon from "../../icons/VisibilityOffIcon";
6
7
  import TextField from "../TextField";
7
- import style from "./style";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const {
10
+ colors
11
+ } = themeConfig;
12
+ const useStyles = makeStyles()({
13
+ visOff: {
14
+ color: colors.shade4
15
+ }
16
+ });
8
17
 
9
18
  /**
10
19
  * A component that provides a password field with visibility toggle.
20
+ * @param {Object} props Props (same as TextField).
21
+ * @returns {JSX.Element}
11
22
  */
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- let Password = /*#__PURE__*/function (_Component) {
14
- /**
15
- * Initializes the component.
16
- * @param {Object} props The components props.
17
- */
18
- function Password(props) {
19
- var _this;
20
- _this = _Component.call(this, props) || this;
21
- /**
22
- * @param {boolean} isVisible The next isVisible state.
23
- */
24
- _this.togglePasswordVisibility = isVisible => {
25
- _this.setState({
26
- isVisible
27
- });
28
- };
29
- _this.state = {
30
- isVisible: false
31
- };
32
- return _this;
33
- }
34
- _inheritsLoose(Password, _Component);
35
- var _proto = Password.prototype;
36
- /**
37
- * @return {*}
38
- */
39
- _proto.render = function render() {
40
- const {
41
- isVisible
42
- } = this.state;
43
- return /*#__PURE__*/_jsx(TextField, {
44
- ...this.props,
45
- className: `ui-shared__form__password ${this.props.className}`,
46
- rightElement: /*#__PURE__*/_jsx(ToggleIcon, {
47
- on: isVisible,
48
- onIcon: /*#__PURE__*/_jsx(VisibilityIcon, {
49
- size: 24
50
- }),
51
- offIcon: /*#__PURE__*/_jsx(VisibilityOffIcon, {
52
- size: 24,
53
- className: style.visOff
54
- }),
55
- toggleHandler: this.togglePasswordVisibility
23
+ const Password = props => {
24
+ const {
25
+ classes,
26
+ cx
27
+ } = useStyles();
28
+ const [isVisible, setIsVisible] = useState(false);
29
+ const togglePasswordVisibility = useCallback(visible => {
30
+ setIsVisible(visible);
31
+ }, []);
32
+ return /*#__PURE__*/_jsx(TextField, {
33
+ ...props,
34
+ className: cx('ui-shared__form__password', props.className || ''),
35
+ rightElement: /*#__PURE__*/_jsx(ToggleIcon, {
36
+ on: isVisible,
37
+ onIcon: /*#__PURE__*/_jsx(VisibilityIcon, {
38
+ size: 24
39
+ }),
40
+ offIcon: /*#__PURE__*/_jsx(VisibilityOffIcon, {
41
+ size: 24,
42
+ className: classes.visOff
56
43
  }),
57
- type: isVisible ? 'text' : 'password'
58
- });
59
- };
60
- return Password;
61
- }(Component);
44
+ toggleHandler: togglePasswordVisibility
45
+ }),
46
+ type: isVisible ? 'text' : 'password'
47
+ });
48
+ };
62
49
  export default Password;