@shopgate/pwa-ui-shared 7.30.4-beta.1 → 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.
Files changed (326) hide show
  1. package/ActionButton/index.js +66 -67
  2. package/AddToCartButton/index.js +217 -185
  3. package/Availability/index.js +24 -6
  4. package/Button/index.js +105 -82
  5. package/Button/spec.js +3 -4
  6. package/Card/index.js +26 -7
  7. package/CardList/components/Item/index.js +15 -3
  8. package/CartTotalLine/components/Amount/index.js +13 -4
  9. package/CartTotalLine/components/Hint/index.js +13 -4
  10. package/CartTotalLine/components/Label/index.js +23 -10
  11. package/CartTotalLine/index.js +41 -7
  12. package/Checkbox/index.js +41 -17
  13. package/Chip/index.js +82 -7
  14. package/ContextMenu/components/Item/index.js +38 -20
  15. package/ContextMenu/components/Position/index.js +38 -56
  16. package/ContextMenu/index.js +64 -28
  17. package/Dialog/components/BasicDialog/index.js +1 -0
  18. package/Dialog/components/HtmlContentDialog/spec.js +39 -0
  19. package/Dialog/components/PipelineErrorDialog/index.js +108 -157
  20. package/Dialog/components/PipelineErrorDialog/spec.js +12 -18
  21. package/Dialog/components/TextMessageDialog/index.js +1 -1
  22. package/Dialog/components/VariantSelectModal/index.js +1 -1
  23. package/Dialog/index.js +1 -1
  24. package/DiscountBadge/index.js +48 -15
  25. package/FavoritesButton/index.js +95 -100
  26. package/FavoritesButton/spec.js +5 -2
  27. package/Form/Builder/classes/ActionListener/index.js +1 -0
  28. package/Form/Checkbox/index.js +64 -56
  29. package/Form/InfoField/index.js +18 -6
  30. package/Form/Password/index.js +39 -52
  31. package/Form/RadioGroup/components/Item/index.js +72 -56
  32. package/Form/RadioGroup/index.js +79 -90
  33. package/Form/Select/index.js +108 -130
  34. package/Form/SelectContextChoices/index.js +30 -8
  35. package/Form/TextField/index.js +106 -82
  36. package/Form/TextField/spec.js +4 -3
  37. package/FormElement/components/ErrorText/index.js +32 -14
  38. package/FormElement/components/Label/index.js +56 -6
  39. package/FormElement/components/Placeholder/index.js +44 -11
  40. package/FormElement/components/Underline/index.js +63 -12
  41. package/FormElement/index.js +62 -85
  42. package/Glow/index.js +73 -83
  43. package/IndicatorCircle/index.js +73 -17
  44. package/IndicatorCircle/spec.js +2 -5
  45. package/LoadingIndicator/index.js +34 -12
  46. package/Manufacturer/index.js +21 -10
  47. package/MessageBar/index.js +12 -38
  48. package/NoResults/components/Icon/index.js +30 -14
  49. package/NoResults/index.js +35 -7
  50. package/Placeholder/index.js +34 -23
  51. package/PlaceholderLabel/index.js +17 -3
  52. package/Price/index.js +34 -21
  53. package/PriceInfo/index.js +23 -9
  54. package/PriceStriked/index.js +67 -77
  55. package/ProgressBar/index.js +112 -77
  56. package/RadioButton/index.js +29 -11
  57. package/RatingStars/index.js +122 -137
  58. package/Ripple/components/RippleAnimation/index.js +13 -3
  59. package/Ripple/index.js +158 -212
  60. package/RippleButton/index.js +63 -60
  61. package/RippleButton/spec.js +15 -9
  62. package/ScannerOverlay/components/CameraOverlay/index.js +54 -10
  63. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +53 -27
  64. package/ScannerOverlay/components/ScannerBar/index.js +50 -26
  65. package/Sheet/components/Header/components/SearchBar/index.js +54 -10
  66. package/Sheet/components/Header/index.js +96 -76
  67. package/Sheet/index.js +295 -157
  68. package/Sheet/spec.js +8 -6
  69. package/TaxDisclaimer/index.js +17 -4
  70. package/TaxDisclaimer/spec.js +16 -5
  71. package/TextField/components/ErrorText/index.js +35 -14
  72. package/TextField/components/FormElement/index.js +29 -4
  73. package/TextField/components/Hint/index.js +39 -10
  74. package/TextField/components/Label/index.js +43 -6
  75. package/TextField/components/Underline/index.js +64 -13
  76. package/TextField/index.js +157 -171
  77. package/TextField/spec.js +5 -3
  78. package/icons/AccountBoxIcon.d.ts +7 -0
  79. package/icons/AccountBoxIcon.d.ts.map +1 -0
  80. package/icons/AccountBoxIcon.js +1 -4
  81. package/icons/AddMoreIcon.d.ts +7 -0
  82. package/icons/AddMoreIcon.d.ts.map +1 -0
  83. package/icons/AddMoreIcon.js +0 -3
  84. package/icons/ArrowDropIcon.d.ts +7 -0
  85. package/icons/ArrowDropIcon.d.ts.map +1 -0
  86. package/icons/ArrowDropIcon.js +0 -3
  87. package/icons/ArrowIcon.d.ts +10 -0
  88. package/icons/ArrowIcon.d.ts.map +1 -0
  89. package/icons/ArrowIcon.js +2 -11
  90. package/icons/BarcodeScannerIcon.d.ts +7 -0
  91. package/icons/BarcodeScannerIcon.d.ts.map +1 -0
  92. package/icons/BarcodeScannerIcon.js +0 -3
  93. package/icons/BoxIcon.d.ts +7 -0
  94. package/icons/BoxIcon.d.ts.map +1 -0
  95. package/icons/BoxIcon.js +0 -3
  96. package/icons/BrowseIcon.d.ts +7 -0
  97. package/icons/BrowseIcon.d.ts.map +1 -0
  98. package/icons/BrowseIcon.js +1 -3
  99. package/icons/BurgerIcon.d.ts +7 -0
  100. package/icons/BurgerIcon.d.ts.map +1 -0
  101. package/icons/BurgerIcon.js +0 -3
  102. package/icons/CalendarIcon.d.ts +7 -0
  103. package/icons/CalendarIcon.d.ts.map +1 -0
  104. package/icons/CalendarIcon.js +0 -2
  105. package/icons/CartCouponIcon.d.ts +7 -0
  106. package/icons/CartCouponIcon.d.ts.map +1 -0
  107. package/icons/CartCouponIcon.js +0 -2
  108. package/icons/CartIcon.d.ts +7 -0
  109. package/icons/CartIcon.d.ts.map +1 -0
  110. package/icons/CartIcon.js +0 -2
  111. package/icons/CartPlusIcon.d.ts +7 -0
  112. package/icons/CartPlusIcon.d.ts.map +1 -0
  113. package/icons/CartPlusIcon.js +0 -2
  114. package/icons/CheckIcon.d.ts +7 -0
  115. package/icons/CheckIcon.d.ts.map +1 -0
  116. package/icons/CheckIcon.js +0 -2
  117. package/icons/CheckedIcon.d.ts +7 -0
  118. package/icons/CheckedIcon.d.ts.map +1 -0
  119. package/icons/CheckedIcon.js +0 -3
  120. package/icons/ChevronIcon.d.ts +7 -0
  121. package/icons/ChevronIcon.d.ts.map +1 -0
  122. package/icons/ChevronIcon.js +0 -2
  123. package/icons/CreditCardIcon.d.ts +7 -0
  124. package/icons/CreditCardIcon.d.ts.map +1 -0
  125. package/icons/CreditCardIcon.js +0 -2
  126. package/icons/CrossIcon.d.ts +7 -0
  127. package/icons/CrossIcon.d.ts.map +1 -0
  128. package/icons/CrossIcon.js +0 -2
  129. package/icons/DescriptionIcon.d.ts +7 -0
  130. package/icons/DescriptionIcon.d.ts.map +1 -0
  131. package/icons/DescriptionIcon.js +0 -2
  132. package/icons/FilterIcon.d.ts +7 -0
  133. package/icons/FilterIcon.d.ts.map +1 -0
  134. package/icons/FilterIcon.js +0 -2
  135. package/icons/FlashDisabledIcon.d.ts +7 -0
  136. package/icons/FlashDisabledIcon.d.ts.map +1 -0
  137. package/icons/FlashDisabledIcon.js +0 -2
  138. package/icons/FlashEnabledIcon.d.ts +7 -0
  139. package/icons/FlashEnabledIcon.d.ts.map +1 -0
  140. package/icons/FlashEnabledIcon.js +0 -2
  141. package/icons/GridIcon.d.ts +7 -0
  142. package/icons/GridIcon.d.ts.map +1 -0
  143. package/icons/GridIcon.js +1 -3
  144. package/icons/HeartIcon.d.ts +7 -0
  145. package/icons/HeartIcon.d.ts.map +1 -0
  146. package/icons/HeartIcon.js +0 -2
  147. package/icons/HeartOutlineIcon.d.ts +7 -0
  148. package/icons/HeartOutlineIcon.d.ts.map +1 -0
  149. package/icons/HeartOutlineIcon.js +1 -3
  150. package/icons/HeartPlusIcon.d.ts +7 -0
  151. package/icons/HeartPlusIcon.d.ts.map +1 -0
  152. package/icons/HeartPlusIcon.js +1 -3
  153. package/icons/HeartPlusOutlineIcon.d.ts +7 -0
  154. package/icons/HeartPlusOutlineIcon.d.ts.map +1 -0
  155. package/icons/HeartPlusOutlineIcon.js +1 -3
  156. package/icons/HomeIcon.d.ts +7 -0
  157. package/icons/HomeIcon.d.ts.map +1 -0
  158. package/icons/HomeIcon.js +0 -2
  159. package/icons/InfoIcon.d.ts +7 -0
  160. package/icons/InfoIcon.d.ts.map +1 -0
  161. package/icons/InfoIcon.js +0 -2
  162. package/icons/InfoOutlineIcon.d.ts +7 -0
  163. package/icons/InfoOutlineIcon.d.ts.map +1 -0
  164. package/icons/InfoOutlineIcon.js +0 -2
  165. package/icons/ListIcon.d.ts +7 -0
  166. package/icons/ListIcon.d.ts.map +1 -0
  167. package/icons/ListIcon.js +0 -2
  168. package/icons/LocalShippingIcon.d.ts +7 -0
  169. package/icons/LocalShippingIcon.d.ts.map +1 -0
  170. package/icons/LocalShippingIcon.js +0 -2
  171. package/icons/LocationIcon.d.ts +7 -0
  172. package/icons/LocationIcon.d.ts.map +1 -0
  173. package/icons/LocationIcon.js +1 -4
  174. package/icons/LocatorIcon.d.ts +7 -0
  175. package/icons/LocatorIcon.d.ts.map +1 -0
  176. package/icons/LocatorIcon.js +1 -3
  177. package/icons/LockIcon.d.ts +9 -0
  178. package/icons/LockIcon.d.ts.map +1 -0
  179. package/icons/LockIcon.js +1 -2
  180. package/icons/LogoutIcon.d.ts +7 -0
  181. package/icons/LogoutIcon.d.ts.map +1 -0
  182. package/icons/LogoutIcon.js +0 -2
  183. package/icons/MagnifierIcon.d.ts +7 -0
  184. package/icons/MagnifierIcon.d.ts.map +1 -0
  185. package/icons/MagnifierIcon.js +0 -2
  186. package/icons/MapMarkerIcon.d.ts +7 -0
  187. package/icons/MapMarkerIcon.d.ts.map +1 -0
  188. package/icons/MapMarkerIcon.js +1 -3
  189. package/icons/MoreIcon.d.ts +7 -0
  190. package/icons/MoreIcon.d.ts.map +1 -0
  191. package/icons/MoreIcon.js +1 -3
  192. package/icons/MoreVertIcon.d.ts +7 -0
  193. package/icons/MoreVertIcon.d.ts.map +1 -0
  194. package/icons/MoreVertIcon.js +1 -3
  195. package/icons/NotificationIcon.d.ts +7 -0
  196. package/icons/NotificationIcon.d.ts.map +1 -0
  197. package/icons/NotificationIcon.js +1 -3
  198. package/icons/PersonIcon.d.ts +9 -0
  199. package/icons/PersonIcon.d.ts.map +1 -0
  200. package/icons/PersonIcon.js +0 -3
  201. package/icons/PhoneIcon.d.ts +7 -0
  202. package/icons/PhoneIcon.d.ts.map +1 -0
  203. package/icons/PhoneIcon.js +1 -4
  204. package/icons/PlaceholderIcon.d.ts +7 -0
  205. package/icons/PlaceholderIcon.d.ts.map +1 -0
  206. package/icons/PlaceholderIcon.js +0 -2
  207. package/icons/RadioCheckedIcon.d.ts +10 -0
  208. package/icons/RadioCheckedIcon.d.ts.map +1 -0
  209. package/icons/RadioCheckedIcon.js +0 -2
  210. package/icons/RadioUncheckedIcon.d.ts +10 -0
  211. package/icons/RadioUncheckedIcon.d.ts.map +1 -0
  212. package/icons/RadioUncheckedIcon.js +0 -2
  213. package/icons/SecurityIcon.d.ts +7 -0
  214. package/icons/SecurityIcon.d.ts.map +1 -0
  215. package/icons/SecurityIcon.js +0 -2
  216. package/icons/ShippingMethodIcon.d.ts +7 -0
  217. package/icons/ShippingMethodIcon.d.ts.map +1 -0
  218. package/icons/ShippingMethodIcon.js +0 -2
  219. package/icons/ShoppingCartIcon.d.ts +7 -0
  220. package/icons/ShoppingCartIcon.d.ts.map +1 -0
  221. package/icons/ShoppingCartIcon.js +0 -2
  222. package/icons/SortIcon.d.ts +7 -0
  223. package/icons/SortIcon.d.ts.map +1 -0
  224. package/icons/SortIcon.js +0 -2
  225. package/icons/StarHalfIcon.d.ts +7 -0
  226. package/icons/StarHalfIcon.d.ts.map +1 -0
  227. package/icons/StarHalfIcon.js +0 -9
  228. package/icons/StarIcon.d.ts +7 -0
  229. package/icons/StarIcon.d.ts.map +1 -0
  230. package/icons/StarIcon.js +0 -9
  231. package/icons/StarOutlineIcon.d.ts +7 -0
  232. package/icons/StarOutlineIcon.d.ts.map +1 -0
  233. package/icons/StarOutlineIcon.js +0 -2
  234. package/icons/StopIcon.d.ts +7 -0
  235. package/icons/StopIcon.d.ts.map +1 -0
  236. package/icons/StopIcon.js +0 -2
  237. package/icons/TickIcon.d.ts +7 -0
  238. package/icons/TickIcon.d.ts.map +1 -0
  239. package/icons/TickIcon.js +0 -2
  240. package/icons/TimeIcon.d.ts +7 -0
  241. package/icons/TimeIcon.d.ts.map +1 -0
  242. package/icons/TimeIcon.js +0 -2
  243. package/icons/TrashIcon.d.ts +7 -0
  244. package/icons/TrashIcon.d.ts.map +1 -0
  245. package/icons/TrashIcon.js +0 -3
  246. package/icons/TrashOutlineIcon.d.ts +8 -0
  247. package/icons/TrashOutlineIcon.d.ts.map +1 -0
  248. package/icons/TrashOutlineIcon.js +0 -2
  249. package/icons/UncheckedIcon.d.ts +7 -0
  250. package/icons/UncheckedIcon.d.ts.map +1 -0
  251. package/icons/UncheckedIcon.js +0 -2
  252. package/icons/ViewListIcon.d.ts +7 -0
  253. package/icons/ViewListIcon.d.ts.map +1 -0
  254. package/icons/ViewListIcon.js +0 -2
  255. package/icons/VisibilityIcon.d.ts +8 -0
  256. package/icons/VisibilityIcon.d.ts.map +1 -0
  257. package/icons/VisibilityIcon.js +2 -4
  258. package/icons/VisibilityOffIcon.d.ts +8 -0
  259. package/icons/VisibilityOffIcon.d.ts.map +1 -0
  260. package/icons/VisibilityOffIcon.js +2 -4
  261. package/icons/WarningIcon.d.ts +7 -0
  262. package/icons/WarningIcon.d.ts.map +1 -0
  263. package/icons/WarningIcon.js +1 -3
  264. package/package.json +5 -5
  265. package/tsconfig.build.json +16 -0
  266. package/tsconfig.json +3 -0
  267. package/ActionButton/style.js +0 -22
  268. package/AddToCartButton/style.js +0 -148
  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,80 +1,78 @@
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, { useCallback } from 'react';
4
2
  import PropTypes from 'prop-types';
3
+ import { makeStyles, cx } from '@shopgate/engage/styles';
5
4
  import IndicatorCircle from "../IndicatorCircle";
6
5
  import RippleButton from "../RippleButton";
7
- import styles from "./style";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const useStyles = makeStyles()(theme => ({
8
+ withGap: {
9
+ textAlign: 'center',
10
+ margin: theme.spacing(1, 0)
11
+ },
12
+ noGap: {
13
+ textAlign: 'center'
14
+ },
15
+ containerCircle: {
16
+ textAlign: 'center',
17
+ margin: `${theme.spacing(1) + 5}px 0`
18
+ }
19
+ }));
20
+ const CLICK_DELAY = 300;
8
21
 
9
22
  /**
10
23
  * The action button component.
24
+ * @param {Object} props Props.
25
+ * @returns {JSX.Element}
11
26
  */
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- let ActionButton = /*#__PURE__*/function (_Component) {
14
- function ActionButton(...args) {
15
- var _this;
16
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
17
- /**
18
- * The click handler
19
- * @param {Object} event The event object for the click handler
20
- */
21
- _this.handleClick = event => {
22
- const {
23
- clickDelay
24
- } = _this.constructor;
25
- if (_this.props.disableClickDelay) {
26
- _this.props.onClick(event);
27
- return;
28
- }
29
- setTimeout(() => {
30
- _this.props.onClick(event);
31
- }, clickDelay);
32
- };
33
- return _this;
34
- }
35
- _inheritsLoose(ActionButton, _Component);
36
- var _proto = ActionButton.prototype;
37
- /**
38
- * The render function.
39
- * @returns {JSX}
40
- */
41
- _proto.render = function render() {
42
- const containerClass = this.props.noGap ? styles.noGapContainer : styles.container;
43
- if (this.props.loading) {
44
- return /*#__PURE__*/_jsx("div", {
45
- className: styles.containerCircle,
46
- children: /*#__PURE__*/_jsx(IndicatorCircle, {})
47
- });
27
+ const ActionButton = ({
28
+ children,
29
+ className,
30
+ disabled,
31
+ flat,
32
+ type,
33
+ onClick,
34
+ disableClickDelay,
35
+ loading,
36
+ noGap,
37
+ testId,
38
+ ...rest
39
+ }) => {
40
+ const {
41
+ classes
42
+ } = useStyles();
43
+ const handleClick = useCallback(event => {
44
+ if (disableClickDelay) {
45
+ onClick(event);
46
+ return;
48
47
  }
48
+ setTimeout(() => {
49
+ onClick(event);
50
+ }, CLICK_DELAY);
51
+ }, [disableClickDelay, onClick]);
52
+ const buttonProps = {
53
+ className,
54
+ disabled,
55
+ flat,
56
+ type
57
+ };
58
+ if (loading) {
49
59
  return /*#__PURE__*/_jsx("div", {
50
- className: `ui-shared__action-button ${containerClass}`,
51
- "data-test-id": this.props.testId,
52
- children: /*#__PURE__*/_jsx(RippleButton, {
53
- ...this.buttonProps,
54
- onClick: this.handleClick,
55
- children: this.props.children
56
- })
60
+ className: classes.containerCircle,
61
+ children: /*#__PURE__*/_jsx(IndicatorCircle, {})
57
62
  });
58
- };
59
- return _createClass(ActionButton, [{
60
- key: "buttonProps",
61
- get:
62
- /**
63
- * Getter for the calculated button props.
64
- * @returns {Object}
65
- */
66
- function () {
67
- const buttonProps = {
68
- className: this.props.className,
69
- disabled: this.props.disabled,
70
- flat: this.props.flat,
71
- type: this.props.type
72
- };
73
- return buttonProps;
74
- }
75
- }]);
76
- }(Component);
77
- ActionButton.clickDelay = 300;
63
+ }
64
+ const containerClass = noGap ? classes.noGap : classes.withGap;
65
+ return /*#__PURE__*/_jsx("div", {
66
+ className: cx('ui-shared__action-button', containerClass),
67
+ "data-test-id": testId,
68
+ children: /*#__PURE__*/_jsx(RippleButton, {
69
+ ...rest,
70
+ ...buttonProps,
71
+ onClick: handleClick,
72
+ children: children
73
+ })
74
+ });
75
+ };
78
76
  ActionButton.defaultProps = {
79
77
  ...RippleButton.defaultProps,
80
78
  loading: false,
@@ -84,4 +82,5 @@ ActionButton.defaultProps = {
84
82
  testId: null,
85
83
  disableClickDelay: false
86
84
  };
85
+ ActionButton.clickDelay = CLICK_DELAY;
87
86
  export default ActionButton;
@@ -1,212 +1,244 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { useCallback, useState } from 'react';
3
2
  import PropTypes from 'prop-types';
3
+ import spring from 'css-spring';
4
4
  import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
5
  import { withForwardedRef } from '@shopgate/engage/core';
6
+ import { keyframes, makeStyles } from '@shopgate/engage/styles';
6
7
  import CartPlusIcon from "../icons/CartPlusIcon";
7
8
  import TickIcon from "../icons/TickIcon";
8
9
  import IndicatorCircle from "../IndicatorCircle";
9
- import styles from "./style";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const DEFAULT_BUTTON_SIZE = 40;
12
+ const DEFAULT_ICON_SIZE = 20;
13
+ const springOptions = {
14
+ stiffness: 381.47,
15
+ damping: 15
16
+ };
17
+ const springFromTopKeyframes = keyframes(spring({
18
+ transform: 'translate3d(0, 300%, 0)'
19
+ }, {
20
+ transform: 'translate3d(0, -50%, 0)'
21
+ }, springOptions));
22
+ const springFromBottomKeyframes = keyframes(spring({
23
+ transform: 'translate3d(0, -300%, 0)'
24
+ }, {
25
+ transform: 'translate3d(0, -50%, 0)'
26
+ }, springOptions));
27
+ const springToTopKeyframes = keyframes(spring({
28
+ transform: 'translate3d(0, -50%, 0)'
29
+ }, {
30
+ transform: 'translate3d(0, 300%, 0)'
31
+ }, springOptions));
32
+ const springToBottomKeyframes = keyframes(spring({
33
+ transform: 'translate3d(0, -50%, 0)'
34
+ }, {
35
+ transform: 'translate3d(0, -300%, 0)'
36
+ }, springOptions));
37
+ const useStyles = makeStyles()({
38
+ springFromBottom: {
39
+ animation: `${springFromBottomKeyframes} 600ms`
40
+ },
41
+ springFromTop: {
42
+ animation: `${springFromTopKeyframes} 600ms`
43
+ },
44
+ springToTop: {
45
+ animation: `${springToTopKeyframes} 600ms`
46
+ },
47
+ springToBottom: {
48
+ animation: `${springToBottomKeyframes} 600ms`
49
+ },
50
+ icon: {
51
+ transition: 'opacity 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
52
+ opacity: 1,
53
+ position: 'absolute'
54
+ },
55
+ spinnerIcon: {
56
+ left: '50%',
57
+ top: '50%',
58
+ marginTop: -themeConfig.variables.loadingIndicator.size / 2,
59
+ marginLeft: -themeConfig.variables.loadingIndicator.size / 2
60
+ },
61
+ buttonReady: {
62
+ background: `var(--color-button-cta, ${themeConfig.colors.cta})`,
63
+ color: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`
64
+ },
65
+ buttonSuccess: {
66
+ background: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`,
67
+ color: `var(--color-button-cta, ${themeConfig.colors.cta})`
68
+ },
69
+ buttonDisabled: {
70
+ background: themeConfig.colors.shade5,
71
+ color: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`,
72
+ boxShadow: themeConfig.shadows.buttons.disabled
73
+ }
74
+ });
75
+
76
+ /**
77
+ * @param {number} bSize .
78
+ * @param {number} iSize .
79
+ * @returns {Object}
80
+ */
81
+ const getWrapperStyle = (bSize, iSize) => ({
82
+ transition: 'background 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
83
+ borderRadius: '50%',
84
+ width: bSize,
85
+ height: bSize,
86
+ position: 'relative',
87
+ fontSize: iSize,
88
+ outline: 0,
89
+ paddingLeft: (bSize - iSize) / 2,
90
+ paddingRight: (bSize - iSize) / 2,
91
+ zIndex: 2,
92
+ overflow: 'hidden',
93
+ flexShrink: 0
94
+ });
10
95
 
11
96
  /**
12
97
  * AddToCartButton component.
98
+ * @param {Object} props Props.
99
+ * @returns {JSX.Element}
13
100
  */
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- let AddToCartButton = /*#__PURE__*/function (_Component) {
16
- /**
17
- * Constructor for the AddToCartButton component.
18
- * @param {Object} props Props for the component.
19
- */
20
- function AddToCartButton(props) {
21
- var _this;
22
- _this = _Component.call(this, props) || this;
23
- /**
24
- * Handles the button click.
25
- * - Show checkmark.
26
- * - Add to cart.
27
- * - Wait 900ms.
28
- * - Show cart icon again.
29
- * @param {Event} e Event
30
- */
31
- _this.handleClick = e => {
32
- // Ignore clicks when check mark or loading spinner is shown or the button is disabled.
33
- if (_this.state.showCheckmark || _this.props.isLoading || _this.props.isDisabled) {
34
- return;
35
- }
101
+ const AddToCartButton = ({
102
+ 'aria-hidden': ariaHidden,
103
+ 'aria-label': ariaLabel,
104
+ buttonSize,
105
+ className,
106
+ forwardedRef,
107
+ iconSize,
108
+ isDisabled,
109
+ isLoading,
110
+ onClick,
111
+ onReset
112
+ }) => {
113
+ const {
114
+ classes,
115
+ cx
116
+ } = useStyles();
117
+ const [showCheckmark, setShowCheckmark] = useState(null);
36
118
 
37
- /** */
38
- const handleCompletion = () => {
39
- _this.setState({
40
- showCheckmark: true
41
- });
42
- setTimeout(() => {
43
- _this.setState({
44
- showCheckmark: false
45
- });
46
- }, 900);
47
- };
48
- const result = _this.props.onClick(e);
49
- if (result === false) {
50
- // Do not trigger animation when adding to cart was aborted by the parent component (PWA-2764)
51
- return;
52
- }
53
- if (result instanceof Promise) {
54
- (async () => {
55
- try {
56
- await result;
57
- handleCompletion();
58
- } catch (error) {
59
- // ignore error in button.
60
- }
61
- })();
62
- return;
63
- }
64
- handleCompletion();
65
- };
66
- /**
67
- * Handles the cart animation end event.
68
- * Resets the showCheckmark state to null in order to
69
- * prevent the icon from animating after changing visibility
70
- * of the view.
71
- * This is caused by CSS animations that get re-applied when
72
- * setting an element from hidden (display: none) to visible.
73
- */
74
- _this.handleCartAnimationEnd = () => {
75
- if (_this.state.showCheckmark === false) {
76
- _this.setState({
77
- showCheckmark: null
78
- });
79
- }
80
- _this.props.onReset();
81
- };
82
- _this.state = {
83
- showCheckmark: null
84
- };
85
- return _this;
86
- }
87
- _inheritsLoose(AddToCartButton, _Component);
88
- var _proto = AddToCartButton.prototype;
89
119
  /**
90
- * Renders the component
91
- * @returns {JSX}
120
+ * @param {Event} e Click event.
92
121
  */
93
- _proto.render = function render() {
94
- // Set initial base styles
95
- let buttonStyle = styles.buttonReady;
96
- let tickIconStyle = styles.icon;
97
- let cartPlusIconStyle = styles.icon;
122
+ const handleClick = useCallback(e => {
123
+ if (showCheckmark || isLoading || isDisabled) {
124
+ return;
125
+ }
98
126
 
99
- // Depending on the isLoading prop we only show the spinner or the other way around.
100
- const iconOpacity = this.props.isLoading ? {
101
- opacity: 0
102
- } : {
103
- opacity: 1
127
+ /** Completes the success checkmark animation cycle. */
128
+ const handleCompletion = () => {
129
+ setShowCheckmark(true);
130
+ setTimeout(() => {
131
+ setShowCheckmark(false);
132
+ }, 900);
104
133
  };
105
- const spinnerInlineStyle = this.props.isLoading ? {
106
- opacity: 1
107
- } : {
108
- opacity: 0
134
+ const result = onClick(e);
135
+ if (result === false) {
136
+ return;
137
+ }
138
+ if (result instanceof Promise) {
139
+ (async () => {
140
+ try {
141
+ await result;
142
+ handleCompletion();
143
+ } catch (error) {
144
+ // ignore error in button.
145
+ }
146
+ })();
147
+ return;
148
+ }
149
+ handleCompletion();
150
+ }, [showCheckmark, isLoading, isDisabled, onClick]);
151
+ const handleCartAnimationEnd = useCallback(() => {
152
+ if (showCheckmark === false) {
153
+ setShowCheckmark(null);
154
+ }
155
+ onReset();
156
+ }, [showCheckmark, onReset]);
157
+ let buttonStateClass = classes.buttonReady;
158
+ let tickIconClass = classes.icon;
159
+ let cartPlusIconClass = classes.icon;
160
+ const iconOpacity = isLoading ? {
161
+ opacity: 0
162
+ } : {
163
+ opacity: 1
164
+ };
165
+ const spinnerInlineStyle = isLoading ? {
166
+ opacity: 1
167
+ } : {
168
+ opacity: 0
169
+ };
170
+ let tickInlineStyle = showCheckmark === null ? {
171
+ transform: 'translate3d(0, 300%, 0)',
172
+ ...iconOpacity
173
+ } : null;
174
+ let cartInlineStyle = showCheckmark === null ? {
175
+ transform: 'translate3d(0, -50%, 0)',
176
+ ...iconOpacity
177
+ } : null;
178
+ if (isDisabled && !isLoading) {
179
+ buttonStateClass = classes.buttonDisabled;
180
+ } else if (showCheckmark) {
181
+ tickIconClass = cx(classes.icon, classes.springFromBottom);
182
+ cartPlusIconClass = cx(classes.icon, classes.springToTop);
183
+ buttonStateClass = classes.buttonSuccess;
184
+ tickInlineStyle = {
185
+ transform: 'translate3d(0, -50%, 0)',
186
+ ...iconOpacity
109
187
  };
110
-
111
- /**
112
- * The initial positions for the icons:
113
- * Tick icon stays hidden on top, Cart icon stays visibly at the center
114
- */
115
- let tickInlineStyle = this.state.showCheckmark === null ? {
116
- transform: 'translate3d(0, 300%, 0)',
188
+ cartInlineStyle = {
189
+ transform: 'translate3d(0, -300%, 0)',
117
190
  ...iconOpacity
118
- } : null;
119
- let cartInlineStyle = this.state.showCheckmark === null ? {
191
+ };
192
+ } else if (showCheckmark !== null) {
193
+ tickIconClass = cx(classes.icon, classes.springToBottom);
194
+ cartPlusIconClass = cx(classes.icon, classes.springFromTop);
195
+ cartInlineStyle = {
120
196
  transform: 'translate3d(0, -50%, 0)',
121
197
  ...iconOpacity
122
- } : null;
123
- if (this.props.isDisabled && !this.props.isLoading) {
124
- buttonStyle = styles.buttonDisabled;
125
- } else if (this.state.showCheckmark) {
126
- /**
127
- * When checkmark should be shown, we start the spring transition
128
- * Tick icon springs in, and cart icon springs out.
129
- */
130
- tickIconStyle += ` ${styles.springFromBottom}`;
131
- cartPlusIconStyle += ` ${styles.springToTop}`;
132
- buttonStyle = styles.buttonSuccess;
133
- /**
134
- * After the keyframe animation is done the transform values are reset
135
- * We add the inline style to make sure the icons stay where they are even after the animation
136
- */
137
- tickInlineStyle = {
138
- transform: 'translate3d(0, -50%, 0)',
139
- ...iconOpacity
140
- };
141
- cartInlineStyle = {
142
- transform: 'translate3d(0, -300%, 0)',
143
- ...iconOpacity
144
- };
145
- } else if (this.state.showCheckmark !== null) {
146
- /**
147
- * When checkmark should no longer be shown we start the spring out transition.
148
- * Tick icon springs out, cart icon spring in.
149
- * We don't want a animation when we initially go to the page therefore this only happens
150
- * after the user pressed the button.
151
- */
152
- tickIconStyle += ` ${styles.springToBottom}`;
153
- cartPlusIconStyle += ` ${styles.springFromTop}`;
154
- /**
155
- * After the keyframe animation is done the transform values are reset
156
- * We add the inline style to make sure the icons stay where they are even after the animation
157
- */
158
- cartInlineStyle = {
159
- transform: 'translate3d(0, -50%, 0)',
160
- ...iconOpacity
161
- };
162
- tickInlineStyle = {
163
- transform: 'translate3d(0, -300%, 0)',
164
- ...iconOpacity
165
- };
166
- }
167
- let className = styles.buttonWrapper(this.props.buttonSize, this.props.iconSize);
168
- if (this.props.noShadow) {
169
- className = styles.buttonWrapperNoShadow(this.props.buttonSize, this.props.iconSize);
170
- }
171
- return /*#__PURE__*/_jsxs("button", {
172
- "data-test-id": "addToCartButton",
173
- className: `ui-shared__add-to-cart-button ${this.props.className} ${className} ${buttonStyle}`,
174
- onClick: this.handleClick,
175
- "aria-hidden": this.props['aria-hidden'],
176
- "aria-label": this.props['aria-label'],
177
- "aria-disabled": this.props.isDisabled,
178
- ref: this.props.forwardedRef,
179
- type: "button",
180
- children: [this.props.isLoading && /*#__PURE__*/_jsx("div", {
181
- className: `${styles.icon} ${styles.spinnerIcon}`,
182
- style: spinnerInlineStyle,
183
- children: /*#__PURE__*/_jsx(IndicatorCircle, {
184
- color: themeConfig.colors.primaryContrast,
185
- strokeWidth: 5,
186
- paused: !this.props.isLoading
187
- })
188
- }), /*#__PURE__*/_jsx("div", {
189
- className: tickIconStyle,
190
- style: tickInlineStyle,
191
- children: /*#__PURE__*/_jsx(TickIcon, {})
192
- }), /*#__PURE__*/_jsx("div", {
193
- className: cartPlusIconStyle,
194
- style: cartInlineStyle,
195
- onAnimationEnd: this.handleCartAnimationEnd,
196
- children: /*#__PURE__*/_jsx(CartPlusIcon, {})
197
- })]
198
- });
199
- };
200
- return AddToCartButton;
201
- }(Component);
198
+ };
199
+ tickInlineStyle = {
200
+ transform: 'translate3d(0, -300%, 0)',
201
+ ...iconOpacity
202
+ };
203
+ }
204
+ const wrapperStyle = getWrapperStyle(buttonSize, iconSize);
205
+ return /*#__PURE__*/_jsxs("button", {
206
+ "data-test-id": "addToCartButton",
207
+ className: cx('ui-shared__add-to-cart-button', buttonStateClass, className),
208
+ style: wrapperStyle,
209
+ onClick: handleClick,
210
+ "aria-hidden": ariaHidden,
211
+ "aria-label": ariaLabel,
212
+ "aria-disabled": isDisabled,
213
+ ref: forwardedRef,
214
+ type: "button",
215
+ children: [isLoading && /*#__PURE__*/_jsx("div", {
216
+ className: cx(classes.icon, classes.spinnerIcon),
217
+ style: spinnerInlineStyle,
218
+ children: /*#__PURE__*/_jsx(IndicatorCircle, {
219
+ color: themeConfig.colors.primaryContrast,
220
+ strokeWidth: 5,
221
+ paused: !isLoading
222
+ })
223
+ }), /*#__PURE__*/_jsx("div", {
224
+ className: tickIconClass,
225
+ style: tickInlineStyle,
226
+ children: /*#__PURE__*/_jsx(TickIcon, {})
227
+ }), /*#__PURE__*/_jsx("div", {
228
+ className: cartPlusIconClass,
229
+ style: cartInlineStyle,
230
+ onAnimationEnd: handleCartAnimationEnd,
231
+ children: /*#__PURE__*/_jsx(CartPlusIcon, {})
232
+ })]
233
+ });
234
+ };
202
235
  AddToCartButton.defaultProps = {
203
236
  'aria-hidden': false,
204
237
  'aria-label': null,
205
- buttonSize: styles.buttonSize,
238
+ buttonSize: DEFAULT_BUTTON_SIZE,
206
239
  className: null,
207
240
  forwardedRef: null,
208
- iconSize: styles.iconSize,
209
- noShadow: false,
241
+ iconSize: DEFAULT_ICON_SIZE,
210
242
  onReset: () => {}
211
243
  };
212
244
  export default withForwardedRef(AddToCartButton);
@@ -1,7 +1,22 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { AVAILABILITY_STATE_OK, AVAILABILITY_STATE_WARNING, AVAILABILITY_STATE_ALERT } from '@shopgate/pwa-common-commerce/product/constants';
4
- import styles from "./style";
4
+ import { makeStyles } from '@shopgate/engage/styles';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const useStyles = makeStyles()(theme => ({
7
+ base: {
8
+ fontSize: '0.875rem'
9
+ },
10
+ stateOk: {
11
+ color: theme.palette.success.main
12
+ },
13
+ stateWarning: {
14
+ color: theme.palette.warning.main
15
+ },
16
+ stateAlert: {
17
+ color: theme.palette.error.main
18
+ }
19
+ }));
5
20
 
6
21
  /**
7
22
  * This component renders the availability text for a product
@@ -13,25 +28,28 @@ import styles from "./style";
13
28
  * @param {string} [props.className] CSS classes
14
29
  * @return {JSX}
15
30
  */
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
31
  const Availability = ({
18
32
  text,
19
33
  state,
20
34
  showWhenAvailable = false,
21
35
  className = null
22
36
  }) => {
37
+ const {
38
+ classes,
39
+ cx
40
+ } = useStyles();
23
41
  if (!text || state === AVAILABILITY_STATE_OK && !showWhenAvailable) {
24
42
  return null;
25
43
  }
26
- let style = styles.stateOk;
44
+ let stateClass = classes.stateOk;
27
45
  if (state === AVAILABILITY_STATE_WARNING) {
28
- style = styles.stateWarning;
46
+ stateClass = classes.stateWarning;
29
47
  }
30
48
  if (state === AVAILABILITY_STATE_ALERT) {
31
- style = styles.stateAlert;
49
+ stateClass = classes.stateAlert;
32
50
  }
33
51
  return /*#__PURE__*/_jsx("div", {
34
- className: `ui-shared__availability ${className} ${style}`,
52
+ className: cx('ui-shared__availability', classes.base, stateClass, className),
35
53
  "data-test-id": `availabilityText: ${text}`,
36
54
  children: text
37
55
  });