@shopgate/pwa-ui-shared 7.30.3 → 7.31.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,10 +1,10 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- var _ProgressBar;
3
- import React, { Component } from 'react';
1
+ import React, { useEffect, useState, memo } from 'react';
4
2
  import PropTypes from 'prop-types';
3
+ import Color from 'color';
5
4
  import Transition from 'react-transition-group/Transition';
6
5
  import UIEvents from '@shopgate/pwa-core/emitters/ui';
7
- import styles from "./style";
6
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
7
+ import { getCSSCustomProp, makeStyles, keyframes } from '@shopgate/engage/styles';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  const duration = 150;
10
10
  const transitionStyles = {
@@ -21,102 +21,137 @@ const transitionStyles = {
21
21
  transform: 'scale(1, 0)'
22
22
  }
23
23
  };
24
+ const {
25
+ colors
26
+ } = themeConfig;
27
+ const progressBarHeight = 4;
28
+ const indeterminateLong = keyframes({
29
+ '0%': {
30
+ left: '-35%',
31
+ right: '100%'
32
+ },
33
+ '60%': {
34
+ left: '100%',
35
+ right: '-90%'
36
+ },
37
+ '100%': {
38
+ left: '100%',
39
+ right: '-90%'
40
+ }
41
+ });
42
+ const indeterminateShort = keyframes({
43
+ '0%': {
44
+ left: '-200%',
45
+ right: '100%'
46
+ },
47
+ '60%': {
48
+ left: '107%',
49
+ right: '-8%'
50
+ },
51
+ '100%': {
52
+ left: '107%',
53
+ right: '-8%'
54
+ }
55
+ });
56
+ const useStyles = makeStyles()({
57
+ innerElement: {
58
+ ':before': {
59
+ content: '""',
60
+ position: 'absolute',
61
+ background: 'var(--color-secondary)',
62
+ top: 0,
63
+ left: 0,
64
+ bottom: 0,
65
+ willChange: 'left, right'
66
+ },
67
+ ':after': {
68
+ content: '""',
69
+ position: 'absolute',
70
+ background: 'var(--color-secondary)',
71
+ top: 0,
72
+ left: 0,
73
+ bottom: 0,
74
+ willChange: 'left, right'
75
+ }
76
+ },
77
+ animating: {
78
+ ':before': {
79
+ animation: `${indeterminateLong} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite`
80
+ },
81
+ ':after': {
82
+ animation: `${indeterminateShort} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite`,
83
+ animationDelay: '1.15s'
84
+ }
85
+ }
86
+ });
24
87
 
25
88
  /**
26
89
  * A component for visualizing any kind of progress.
27
90
  * This component will show the current progress in a linear bar.
28
91
  */
29
- let ProgressBar = /*#__PURE__*/function (_Component) {
30
- /**
31
- * The constructor
32
- * @param {Object} props The component props.
33
- */
34
- function ProgressBar(props) {
35
- var _this;
36
- _this = _Component.call(this, props) || this;
37
- _this.state = {
38
- isAnimating: props.isVisible,
39
- isVisible: props.isVisible
40
- };
41
- return _this;
42
- }
43
-
44
- /**
45
- * Update the state based on props.
46
- * @param {Object} nextProps The next set of props.
47
- */
48
- _inheritsLoose(ProgressBar, _Component);
49
- var _proto = ProgressBar.prototype;
50
- _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
51
- if (this.props.isVisible === nextProps.isVisible) {
52
- return;
53
- }
54
- this.setState({
55
- ...(nextProps.isVisible && {
56
- isAnimating: true
57
- }),
58
- isVisible: nextProps.isVisible
59
- });
60
- }
61
-
62
- /**
63
- * Only update when certain state changes are made.
64
- * @param {Object} nextProps The next set of props.
65
- * @param {Object} nextState The next component state.
66
- * @returns {boolean}
67
- */;
68
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
69
- return this.state.isAnimating !== nextState.isAnimating || this.state.isVisible !== nextState.isVisible;
70
- }
71
-
72
- /**
73
- * Renders the component.
74
- * @return {JSX}
75
- */;
76
- _proto.render = function render() {
77
- const animationClasses = [styles.innerElement];
78
-
79
- // Add the animation if we need it.
80
- if (this.state.isAnimating) {
81
- animationClasses.push(styles.animating);
92
+ const ProgressBar = /*#__PURE__*/memo(({
93
+ isVisible
94
+ }) => {
95
+ const {
96
+ classes,
97
+ cx
98
+ } = useStyles();
99
+ const [isAnimating, setIsAnimating] = useState(isVisible);
100
+ const [visible, setVisible] = useState(isVisible);
101
+ useEffect(() => {
102
+ if (isVisible) {
103
+ setIsAnimating(true);
104
+ setVisible(true);
105
+ } else {
106
+ setVisible(false);
82
107
  }
83
- return /*#__PURE__*/_jsx(Transition, {
84
- in: this.state.isVisible,
85
- timeout: duration,
86
- onExited: () => {
87
- this.setState({
88
- isAnimating: false
89
- });
108
+ }, [isVisible]);
109
+ const wrapperBackground = Color(getCSSCustomProp('--color-secondary') || colors.accent).fade(0.6);
110
+ return /*#__PURE__*/_jsx(Transition, {
111
+ in: visible,
112
+ timeout: duration,
113
+ onExited: () => {
114
+ setIsAnimating(false);
115
+ },
116
+ children: state => /*#__PURE__*/_jsx("div", {
117
+ className: "ui-shared__progress-bar",
118
+ style: {
119
+ position: 'absolute',
120
+ bottom: 0,
121
+ background: wrapperBackground,
122
+ width: '100%',
123
+ height: progressBarHeight,
124
+ overflow: 'hidden',
125
+ transition: 'transform 150ms cubic-bezier(0.25, 0.1, 0.25, 1)',
126
+ zIndex: 10,
127
+ ...transitionStyles[state]
90
128
  },
91
- children: state => /*#__PURE__*/_jsx("div", {
92
- className: `${styles.wrapper()} ui-shared__progress-bar`,
93
- style: transitionStyles[state],
94
- children: /*#__PURE__*/_jsx("div", {
95
- className: animationClasses.join(' ')
96
- })
129
+ children: /*#__PURE__*/_jsx("div", {
130
+ className: cx(classes.innerElement, isAnimating && classes.animating)
97
131
  })
98
- });
99
- };
100
- return ProgressBar;
101
- }(Component);
102
- _ProgressBar = ProgressBar;
132
+ })
133
+ });
134
+ });
103
135
  ProgressBar.PROGRESS_BAR_SHOW = 'PROGRESS_BAR_SHOW';
104
136
  ProgressBar.PROGRESS_BAR_HIDE = 'PROGRESS_BAR_HIDE';
137
+
105
138
  /**
106
139
  * Shows the progress bar.
107
140
  * @param {string} pattern The router pattern to show the bar for.
108
141
  */
109
142
  ProgressBar.show = pattern => {
110
- UIEvents.emit(_ProgressBar.PROGRESS_BAR_SHOW, pattern);
143
+ UIEvents.emit(ProgressBar.PROGRESS_BAR_SHOW, pattern);
111
144
  };
145
+
112
146
  /**
113
147
  * Hides the progress bar.
114
148
  * @param {string} pattern The router pattern to hide the bar from.
115
149
  */
116
150
  ProgressBar.hide = pattern => {
117
- UIEvents.emit(_ProgressBar.PROGRESS_BAR_HIDE, pattern);
151
+ UIEvents.emit(ProgressBar.PROGRESS_BAR_HIDE, pattern);
118
152
  };
119
153
  ProgressBar.defaultProps = {
120
154
  isVisible: true
121
155
  };
156
+ ProgressBar.displayName = 'ProgressBar';
122
157
  export default ProgressBar;
@@ -1,22 +1,40 @@
1
1
  import React from 'react';
2
+ import { makeStyles } from '@shopgate/engage/styles';
3
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
2
4
  import BaseCheckbox from '@shopgate/pwa-common/components/Checkbox';
3
5
  import CheckedIcon from "../icons/RadioCheckedIcon";
4
6
  import UncheckedIcon from "../icons/RadioUncheckedIcon";
5
- import styles from "./style";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const useStyles = makeStyles()(() => ({
9
+ checkedIcon: {
10
+ width: 24,
11
+ height: 24,
12
+ color: 'var(--color-secondary)'
13
+ },
14
+ uncheckedIcon: {
15
+ width: 24,
16
+ height: 24,
17
+ color: themeConfig.colors.shade6
18
+ }
19
+ }));
6
20
 
7
21
  /**
8
22
  * The RadioButton template component.
9
23
  * @param {Object} props The component properties.
10
24
  * @returns {JSX}
11
25
  */
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const RadioButton = props => /*#__PURE__*/_jsx(BaseCheckbox, {
14
- ...props,
15
- checkedIcon: /*#__PURE__*/_jsx(CheckedIcon, {
16
- className: styles.checkedIcon
17
- }),
18
- uncheckedIcon: /*#__PURE__*/_jsx(UncheckedIcon, {
19
- className: styles.uncheckedIcon
20
- })
21
- });
26
+ const RadioButton = props => {
27
+ const {
28
+ classes
29
+ } = useStyles();
30
+ return /*#__PURE__*/_jsx(BaseCheckbox, {
31
+ ...props,
32
+ checkedIcon: /*#__PURE__*/_jsx(CheckedIcon, {
33
+ className: classes.checkedIcon
34
+ }),
35
+ uncheckedIcon: /*#__PURE__*/_jsx(UncheckedIcon, {
36
+ className: classes.uncheckedIcon
37
+ })
38
+ });
39
+ };
22
40
  export default RadioButton;
@@ -1,16 +1,55 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { useCallback } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import times from 'lodash/times';
4
+ import { i18n } from '@shopgate/engage/core/helpers';
5
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
6
+ import { makeStyles } from '@shopgate/engage/styles';
5
7
  import StarIcon from "../icons/StarIcon";
6
8
  import StarHalfIcon from "../icons/StarHalfIcon";
7
- import styles from "./style";
8
9
  import { RATING_SCALE_DIVISOR } from "./constants";
9
-
10
- /**
11
- * The available style keys for the rating stars.
12
- */
13
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const ICON_SIZES = {
12
+ small: '1em',
13
+ big: '1.24em',
14
+ large: '2.3em'
15
+ };
16
+ const useStyles = makeStyles()({
17
+ container: {
18
+ position: 'relative',
19
+ display: 'inline-block',
20
+ verticalAlign: 'middle',
21
+ maxWidth: '100%'
22
+ },
23
+ icon: {
24
+ display: 'inline-block',
25
+ verticalAlign: 'middle',
26
+ outline: 0
27
+ },
28
+ iconGapSmall: {
29
+ marginRight: '0.1em'
30
+ },
31
+ iconGapBig: {
32
+ marginRight: '0.12em'
33
+ },
34
+ iconGapLarge: {
35
+ marginRight: '0.23em'
36
+ },
37
+ emptyStars: {
38
+ color: themeConfig.colors.shade7,
39
+ display: 'inline-flex',
40
+ alignItems: 'center',
41
+ flexWrap: 'nowrap'
42
+ },
43
+ filledStars: {
44
+ position: 'absolute',
45
+ left: 0,
46
+ top: 0,
47
+ color: 'var(--color-primary)',
48
+ display: 'inline-flex',
49
+ alignItems: 'center',
50
+ flexWrap: 'nowrap'
51
+ }
52
+ });
14
53
  const numStars = 5;
15
54
 
16
55
  /**
@@ -18,142 +57,88 @@ const numStars = 5;
18
57
  * @param {Object} props The component props.
19
58
  * @returns {JSX}
20
59
  */
21
- let RatingStars = /*#__PURE__*/function (_Component) {
22
- function RatingStars() {
23
- return _Component.apply(this, arguments) || this;
24
- }
25
- _inheritsLoose(RatingStars, _Component);
26
- var _proto = RatingStars.prototype;
27
- /**
28
- * Only update the component if the star rating changed.
29
- * @param {Object} nextProps The next component props.
30
- * @returns {boolean}
31
- */
32
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
33
- return nextProps.value !== this.props.value;
34
- }
35
-
36
- /**
37
- * Returns textual version of stars for screen readers.
38
- * @param {number} stars Number of stars.
39
- * @returns {string}
40
- */;
41
- _proto.getTextualFinal = function getTextualFinal(stars) {
42
- const {
43
- __
44
- } = this.context.i18n();
45
- return __('reviews.rating_stars', {
46
- rate: stars,
47
- maxRate: numStars
48
- });
49
- }
50
-
51
- /**
52
- * Returns text for call to a
53
- * @param {number} stars Number of stars.
54
- * @returns {string}
55
- */;
56
- _proto.getTextualCTA = function getTextualCTA(stars) {
57
- const {
58
- __
59
- } = this.context.i18n();
60
- return __('reviews.press_to_rate_with_x_stars', {
61
- rate: stars
62
- });
63
- }
64
-
65
- /**
66
- * Handles click on RatingStars.
67
- * @param {Object} e SyntheticEvent.
68
- * @param {number} pos Position/Index of clicked RatingStar.
69
- */;
70
- _proto.handleSelection = function handleSelection(e, pos) {
71
- const {
72
- onSelection
73
- } = this.props;
60
+ const RatingStars = ({
61
+ value,
62
+ className,
63
+ display,
64
+ isSelectable,
65
+ onSelection
66
+ }) => {
67
+ const {
68
+ classes,
69
+ cx
70
+ } = useStyles();
71
+ const ratedStars = value / RATING_SCALE_DIVISOR;
72
+ const numFullStars = Math.floor(ratedStars);
73
+ const numHalfStars = Math.ceil(ratedStars - numFullStars);
74
+ const size = ICON_SIZES[display];
75
+ const getTextualFinal = useCallback(stars => i18n.text('reviews.rating_stars', {
76
+ rate: stars,
77
+ maxRate: numStars
78
+ }), []);
79
+ const getTextualCTA = useCallback(stars => i18n.text('reviews.press_to_rate_with_x_stars', {
80
+ rate: stars
81
+ }), []);
82
+ const handleSelection = useCallback((e, pos) => {
74
83
  e.target.value = pos * RATING_SCALE_DIVISOR;
75
84
  onSelection(e);
76
- }
77
-
78
- /**
79
- * Renders the component.
80
- * @returns {JSX.Element}
81
- */;
82
- _proto.render = function render() {
83
- const {
84
- value,
85
- isSelectable
86
- } = this.props;
87
- const ratedStars = value / RATING_SCALE_DIVISOR;
88
- const numFullStars = Math.floor(ratedStars);
89
- const numHalfStars = Math.ceil(ratedStars - numFullStars);
90
- const size = styles.iconStyles[this.props.display].iconSize;
91
- const className = [styles.container, this.props.className, 'ui-shared__rating-stars'].join(' ');
92
- const iconClassName = [styles.iconStyles[this.props.display].iconStyle, styles.icon].join(' ');
93
- const emptyStars = [].concat(times(numStars, i => {
94
- const pos = i + 1;
95
- const starProps = {
96
- className: iconClassName,
97
- key: pos,
98
- ...(isSelectable && {
99
- 'aria-label': this.getTextualCTA(pos),
100
- role: 'button',
101
- onClick: e => this.handleSelection(e, pos)
102
- })
103
- };
104
- return /*#__PURE__*/_jsx("div", {
105
- ...starProps,
106
- children: /*#__PURE__*/_jsx(StarIcon, {
107
- size: size
108
- })
109
- });
110
- }));
111
- const filledStars = [].concat(times(numFullStars, i => {
112
- const pos = i + 1;
113
- const starProps = {
114
- className: iconClassName,
115
- key: numStars + pos,
116
- ...(isSelectable && {
117
- 'aria-hidden': true,
118
- // Aria hidden since it's basically a duplicate for a screen reader.
119
- role: 'button',
120
- onClick: e => this.handleSelection(e, pos)
121
- })
122
- };
123
- return /*#__PURE__*/_jsx("div", {
124
- ...starProps,
125
- children: /*#__PURE__*/_jsx(StarIcon, {
126
- size: size
127
- })
128
- });
129
- }), times(numHalfStars, i => /*#__PURE__*/_jsx("div", {
85
+ }, [onSelection]);
86
+ const iconClassName = cx(classes.icon, display === 'small' && classes.iconGapSmall, display === 'big' && classes.iconGapBig, display === 'large' && classes.iconGapLarge);
87
+ const rootClassName = cx(classes.container, className, 'ui-shared__rating-stars');
88
+ const emptyStars = [].concat(times(numStars, i => {
89
+ const pos = i + 1;
90
+ const starProps = {
130
91
  className: iconClassName,
131
- children: /*#__PURE__*/_jsx(StarHalfIcon, {
92
+ key: pos,
93
+ ...(isSelectable && {
94
+ 'aria-label': getTextualCTA(pos),
95
+ role: 'button',
96
+ onClick: e => handleSelection(e, pos)
97
+ })
98
+ };
99
+ return /*#__PURE__*/_jsx("div", {
100
+ ...starProps,
101
+ children: /*#__PURE__*/_jsx(StarIcon, {
132
102
  size: size
133
103
  })
134
- }, i + numFullStars)));
135
- return /*#__PURE__*/_jsxs("div", {
136
- role: isSelectable ? undefined : 'img',
137
- className: className,
138
- "aria-label": this.getTextualFinal(ratedStars),
139
- "data-test-id": `ratedStars: ${ratedStars}`,
140
- children: [/*#__PURE__*/_jsx("div", {
141
- className: `${styles.emptyStars} rating-stars-empty`,
142
- children: emptyStars
143
- }), /*#__PURE__*/_jsx("div", {
144
- className: `${styles.filledStars} rating-stars-filled`,
145
- children: filledStars
146
- })]
147
104
  });
148
- };
149
- return RatingStars;
150
- }(Component);
151
- /**
152
- * Context types definition.
153
- * @type {{i18n: function}}
154
- */
155
- RatingStars.contextTypes = {
156
- i18n: PropTypes.func
105
+ }));
106
+ const filledStars = [].concat(times(numFullStars, i => {
107
+ const pos = i + 1;
108
+ const starProps = {
109
+ className: iconClassName,
110
+ key: numStars + pos,
111
+ ...(isSelectable && {
112
+ 'aria-hidden': true,
113
+ role: 'button',
114
+ onClick: e => handleSelection(e, pos)
115
+ })
116
+ };
117
+ return /*#__PURE__*/_jsx("div", {
118
+ ...starProps,
119
+ children: /*#__PURE__*/_jsx(StarIcon, {
120
+ size: size
121
+ })
122
+ });
123
+ }), times(numHalfStars, i => /*#__PURE__*/_jsx("div", {
124
+ className: iconClassName,
125
+ children: /*#__PURE__*/_jsx(StarHalfIcon, {
126
+ size: size
127
+ })
128
+ }, i + numFullStars)));
129
+ return /*#__PURE__*/_jsxs("div", {
130
+ role: isSelectable ? undefined : 'img',
131
+ className: rootClassName,
132
+ "aria-label": getTextualFinal(ratedStars),
133
+ "data-test-id": `ratedStars: ${ratedStars}`,
134
+ children: [/*#__PURE__*/_jsx("div", {
135
+ className: cx(classes.emptyStars, 'rating-stars-empty'),
136
+ children: emptyStars
137
+ }), /*#__PURE__*/_jsx("div", {
138
+ className: cx(classes.filledStars, 'rating-stars-filled'),
139
+ children: filledStars
140
+ })]
141
+ });
157
142
  };
158
143
  RatingStars.defaultProps = {
159
144
  className: '',
@@ -2,7 +2,15 @@ import React, { memo, useRef, useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Transition } from 'react-transition-group';
4
4
  import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
- import style from "../../style";
5
+ import { makeStyles } from '@shopgate/engage/styles';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const useStyles = makeStyles()(() => ({
8
+ ripple: {
9
+ position: 'absolute',
10
+ borderRadius: '50%',
11
+ transformOrigin: '50% 50% 0'
12
+ }
13
+ }));
6
14
 
7
15
  /**
8
16
  * The RippleAnimation component
@@ -17,7 +25,6 @@ import style from "../../style";
17
25
  * @param {number} props.y The y coordinate of the ripple center.
18
26
  * @returns {JSX.Element}
19
27
  */
20
- import { jsx as _jsx } from "react/jsx-runtime";
21
28
  function RippleAnimation({
22
29
  color,
23
30
  duration,
@@ -26,6 +33,9 @@ function RippleAnimation({
26
33
  x,
27
34
  y
28
35
  }) {
36
+ const {
37
+ classes
38
+ } = useStyles();
29
39
  const nodeRef = useRef(null);
30
40
  const baseStyle = useMemo(() => ({
31
41
  backgroundColor: color,
@@ -81,7 +91,7 @@ function RippleAnimation({
81
91
  onEntered: onComplete,
82
92
  children: state => /*#__PURE__*/_jsx("div", {
83
93
  ref: nodeRef,
84
- className: style.ripple,
94
+ className: classes.ripple,
85
95
  style: getStyleForState(state)
86
96
  })
87
97
  });