@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
package/Sheet/index.js CHANGED
@@ -1,179 +1,317 @@
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, { useRef, useState, useEffect, useMemo, useCallback } from 'react';
4
2
  import PropTypes from 'prop-types';
5
3
  import throttle from 'lodash/throttle';
6
- import classNames from 'classnames';
7
4
  import UIEvents from '@shopgate/pwa-core/emitters/ui';
8
5
  import Backdrop from '@shopgate/pwa-common/components/Backdrop';
9
6
  import Drawer from '@shopgate/pwa-common/components/Drawer';
7
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
8
+ import { makeStyles, keyframes, responsiveMediaQuery } from '@shopgate/engage/styles';
10
9
  import ProgressBar from "../ProgressBar";
11
10
  import Header from "./components/Header";
12
- import styles from "./style";
13
11
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
12
  export const SHEET_EVENTS = {
15
13
  OPEN: 'Sheet.open',
16
14
  CLOSE: 'Sheet.close'
17
15
  };
16
+ const duration = 300;
17
+ const easing = 'cubic-bezier(0.25, 0.1, 0.25, 1)';
18
+ const slideInSheetDrawer = keyframes({
19
+ '0%': {
20
+ transform: 'translateY(100%)'
21
+ },
22
+ '100%': {
23
+ transform: 'translateY(0)'
24
+ }
25
+ });
26
+ const fadeInSheetDrawer = keyframes({
27
+ '0%': {
28
+ opacity: 0
29
+ },
30
+ '100%': {
31
+ opacity: 1
32
+ }
33
+ });
34
+ const slideOutSheetDrawer = keyframes({
35
+ '0%': {
36
+ transform: 'translateY(0)'
37
+ },
38
+ '100%': {
39
+ transform: 'translateY(100%)'
40
+ }
41
+ });
42
+ const fadeOutSheetDrawer = keyframes({
43
+ '0%': {
44
+ opacity: 1
45
+ },
46
+ '100%': {
47
+ opacity: 0
48
+ }
49
+ });
50
+ const useStyles = makeStyles()(theme => ({
51
+ section: {
52
+ [responsiveMediaQuery('>sm', {
53
+ webOnly: true
54
+ })]: {
55
+ display: 'flex',
56
+ justifyContent: 'center',
57
+ alignItems: 'center',
58
+ width: '80%',
59
+ position: 'fixed',
60
+ left: 0,
61
+ right: 0,
62
+ top: 0,
63
+ bottom: 0,
64
+ margin: 'auto',
65
+ zIndex: 100
66
+ }
67
+ },
68
+ container: {
69
+ bottom: 0,
70
+ background: themeConfig.colors.light,
71
+ width: '100vw',
72
+ [responsiveMediaQuery('<xl', {
73
+ appOnly: true
74
+ })]: {
75
+ maxWidth: 640
76
+ },
77
+ left: 0,
78
+ right: 0,
79
+ margin: '0 auto',
80
+ color: theme.palette.text.primary,
81
+ [responsiveMediaQuery('>sm', {
82
+ webOnly: true
83
+ })]: {
84
+ position: 'initial'
85
+ },
86
+ [responsiveMediaQuery('>md', {
87
+ webOnly: true
88
+ })]: {
89
+ width: '60%'
90
+ }
91
+ },
92
+ containerFullScreen: {
93
+ height: [`calc(100vh - ${themeConfig.variables.navigator.height}px - 51px)`, `calc(100vh - ${themeConfig.variables.navigator.height}px - 51px - var(--safe-area-inset-top))`]
94
+ },
95
+ progressBarContainer: {
96
+ position: 'relative'
97
+ },
98
+ sheetShadow: {
99
+ boxShadow: themeConfig.shadows.sheet
100
+ },
101
+ content: {
102
+ maxHeight: [`calc(var(--vh-100, 100vh) - ${themeConfig.variables.navigator.height}px)`, `calc(var(--vh-100, 100vh) - ${themeConfig.variables.navigator.height}px - var(--safe-area-inset-top))`],
103
+ [responsiveMediaQuery('>sm', {
104
+ webOnly: true
105
+ })]: {
106
+ maxHeight: [`calc(var(--vh-80, 80vh) - ${themeConfig.variables.navigator.height}px)`, `calc(var(--vh-80, 80vh) - ${themeConfig.variables.navigator.height}px - var(--safe-area-inset-top))`]
107
+ },
108
+ paddingBottom: ['var(--safe-area-inset-bottom)'],
109
+ overflowY: 'scroll',
110
+ WebkitOverflowScrolling: 'touch'
111
+ },
112
+ drawerAnimIn: {
113
+ [responsiveMediaQuery('<=sm', {
114
+ appAlways: true
115
+ })]: {
116
+ animation: `${slideInSheetDrawer} ${duration}ms 1 both ${easing}`
117
+ },
118
+ [responsiveMediaQuery('>sm', {
119
+ webOnly: true
120
+ })]: {
121
+ animation: `${fadeInSheetDrawer} ${duration}ms 1 both ${easing}`
122
+ }
123
+ },
124
+ drawerAnimOut: {
125
+ [responsiveMediaQuery('<=sm', {
126
+ appAlways: true
127
+ })]: {
128
+ animation: `${slideOutSheetDrawer} ${duration}ms 1 both ${easing}`
129
+ },
130
+ [responsiveMediaQuery('>sm', {
131
+ webOnly: true
132
+ })]: {
133
+ animation: `${fadeOutSheetDrawer} ${duration}ms 1 both ${easing}`
134
+ }
135
+ }
136
+ }));
18
137
 
19
138
  /**
20
- * Sheet component.
139
+ * @param {Object} props Props.
140
+ * @returns {JSX.Element}
21
141
  */
22
- let Sheet = /*#__PURE__*/function (_Component) {
23
- /**
24
- * The constructor.
25
- * @param {Object} props The component props.
26
- */
27
- function Sheet(props) {
28
- var _this;
29
- _this = _Component.call(this, props) || this;
30
- /**
31
- * Close the Sheet.
32
- */
33
- _this.handleScroll = throttle(() => {
34
- const scrolled = _this.content.current.scrollTop !== 0;
35
- if (_this.state.scrolled !== scrolled) {
36
- _this.setState({
37
- scrolled
38
- });
39
- }
40
- }, 10);
41
- /**
42
- * Close the Sheet.
43
- */
44
- _this.handleClose = () => {
45
- _this.props.onClose();
46
- _this.setState({
47
- isOpen: false,
48
- scrolled: false
49
- });
50
- };
51
- /** The Sheet is opened */
52
- _this.handleDidOpen = () => {
53
- UIEvents.emit(SHEET_EVENTS.OPEN);
54
- _this.props.onDidOpen();
55
- };
56
- /** The Sheet is closed */
57
- _this.handleDidClose = () => {
58
- UIEvents.emit(SHEET_EVENTS.CLOSE);
59
- _this.props.onDidClose();
60
- };
61
- /**
62
- * New value from SearchBar
63
- * @param {string} value .
64
- */
65
- _this.handleSearchInput = value => {
66
- _this.setState({
67
- query: value
68
- });
69
- };
70
- _this.content = /*#__PURE__*/React.createRef();
71
- _this.state = {
72
- isOpen: props.isOpen,
73
- scrolled: false,
74
- query: ''
75
- };
76
- return _this;
77
- }
142
+ const SheetView = ({
143
+ allowClose,
144
+ animationFromParent,
145
+ backdrop,
146
+ children,
147
+ className,
148
+ contentClassName,
149
+ contentRef,
150
+ duration: durationProp,
151
+ isLoading,
152
+ isOpen,
153
+ onClose,
154
+ onDidClose,
155
+ onDidOpen,
156
+ onOpen,
157
+ onScroll,
158
+ scrolled,
159
+ showSearch,
160
+ title,
161
+ handleSearchInput
162
+ }) => {
163
+ const {
164
+ classes,
165
+ cx
166
+ } = useStyles();
167
+ const animation = useMemo(() => ({
168
+ duration: durationProp,
169
+ in: classes.drawerAnimIn,
170
+ out: classes.drawerAnimOut,
171
+ ...animationFromParent
172
+ }), [durationProp, classes.drawerAnimIn, classes.drawerAnimOut, animationFromParent]);
173
+ const drawerClassNames = cx(classes.container, {
174
+ [className]: className
175
+ });
176
+ const contentClassNames = cx(classes.content, {
177
+ [classes.containerFullScreen]: showSearch
178
+ }, {
179
+ [contentClassName]: contentClassName
180
+ }, {
181
+ [classes.sheetShadow]: !backdrop
182
+ });
183
+ return /*#__PURE__*/_jsxs("section", {
184
+ className: cx('ui-shared__sheet', {
185
+ [classes.section]: isOpen
186
+ }),
187
+ children: [/*#__PURE__*/_jsxs(Drawer, {
188
+ className: drawerClassNames,
189
+ isOpen: isOpen,
190
+ onDidOpen: onDidOpen,
191
+ onDidClose: onDidClose,
192
+ onOpen: onOpen,
193
+ onClose: onClose,
194
+ animation: animation,
195
+ children: [title && /*#__PURE__*/_jsx(Header, {
196
+ showSearch: showSearch,
197
+ handleChange: handleSearchInput,
198
+ onToggleClose: onClose,
199
+ shadow: scrolled,
200
+ title: title,
201
+ allowClose: allowClose
202
+ }), /*#__PURE__*/_jsx("div", {
203
+ className: classes.progressBarContainer,
204
+ children: /*#__PURE__*/_jsx(ProgressBar, {
205
+ isVisible: isLoading
206
+ })
207
+ }), /*#__PURE__*/_jsx("div", {
208
+ ref: contentRef,
209
+ onScroll: onScroll,
210
+ className: contentClassNames,
211
+ children: children
212
+ })]
213
+ }), backdrop && /*#__PURE__*/_jsx(Backdrop, {
214
+ isVisible: isOpen,
215
+ level: 4,
216
+ onClick: allowClose ? onClose : () => {},
217
+ opacity: 20
218
+ })]
219
+ });
220
+ };
221
+ SheetView.defaultProps = {
222
+ children: null,
223
+ className: null,
224
+ contentClassName: null,
225
+ title: ''
226
+ };
78
227
 
79
- /**
80
- * Change isOpen state for new incoming props.
81
- * @param {Object} nextProps The next component props.
82
- */
83
- _inheritsLoose(Sheet, _Component);
84
- var _proto = Sheet.prototype;
85
- _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps({
86
- isOpen
87
- }) {
88
- if (this.state.isOpen !== isOpen) {
89
- this.setState({
90
- isOpen
91
- });
228
+ /**
229
+ * Sheet component.
230
+ * @param {Object} props Props.
231
+ * @returns {JSX.Element}
232
+ */
233
+ const Sheet = ({
234
+ allowClose,
235
+ animation,
236
+ backdrop,
237
+ children: childrenProp,
238
+ className,
239
+ contentClassName,
240
+ duration: sheetDuration,
241
+ isLoading,
242
+ isOpen: isOpenFromProps,
243
+ onClose,
244
+ onDidClose,
245
+ onDidOpen,
246
+ onOpen,
247
+ showSearch,
248
+ title
249
+ }) => {
250
+ const contentRef = useRef(null);
251
+ const [isOpen, setIsOpen] = useState(isOpenFromProps);
252
+ const prevIsOpenPropRef = useRef(isOpenFromProps);
253
+ if (prevIsOpenPropRef.current !== isOpenFromProps) {
254
+ prevIsOpenPropRef.current = isOpenFromProps;
255
+ if (isOpen !== isOpenFromProps) {
256
+ setIsOpen(isOpenFromProps);
92
257
  }
93
- };
94
- /**
95
- * Renders the component.
96
- * @returns {JSX}
97
- */
98
- _proto.render = function render() {
99
- const {
100
- allowClose
101
- } = this.props;
102
- const children = React.Children.map(this.props.children, child => (/*#__PURE__*/React.cloneElement(child,
103
- // Only add onClose prop to other components
104
- typeof child.type === 'function' && this.props.onClose !== null ? {
105
- onClose: this.props.onClose,
106
- query: this.state.query
107
- } : {})));
108
- const drawerClassNames = classNames(styles.container, {
109
- [this.props.className]: this.props.className
110
- });
111
- const contentClassNames = classNames(styles.content, {
112
- [styles.containerFullScreen]: this.props.showSearch
113
- }, {
114
- [this.props.contentClassName]: this.props.contentClassName
115
- }, {
116
- [styles.shadow]: !this.props.backdrop
117
- });
118
- return /*#__PURE__*/_jsxs("section", {
119
- className: classNames('ui-shared__sheet', {
120
- [styles.section]: this.state.isOpen
121
- }),
122
- children: [/*#__PURE__*/_jsxs(Drawer, {
123
- className: drawerClassNames,
124
- isOpen: this.state.isOpen,
125
- onDidOpen: this.handleDidOpen,
126
- onDidClose: this.handleDidClose,
127
- onOpen: this.props.onOpen,
128
- onClose: this.handleClose,
129
- animation: this.animationProps,
130
- children: [this.props.title && /*#__PURE__*/_jsx(Sheet.Header, {
131
- showSearch: this.props.showSearch,
132
- handleChange: this.handleSearchInput,
133
- onToggleClose: this.handleClose,
134
- shadow: this.state.scrolled,
135
- title: this.props.title,
136
- allowClose: allowClose
137
- }), /*#__PURE__*/_jsx("div", {
138
- className: styles.progressBarContainer,
139
- children: /*#__PURE__*/_jsx(ProgressBar, {
140
- isVisible: this.props.isLoading
141
- })
142
- }), /*#__PURE__*/_jsx("div", {
143
- ref: this.content,
144
- onScroll: this.handleScroll,
145
- className: contentClassNames,
146
- children: children
147
- })]
148
- }), this.props.backdrop && /*#__PURE__*/_jsx(Backdrop, {
149
- isVisible: this.state.isOpen,
150
- level: 4,
151
- onClick: allowClose ? this.handleClose : () => {},
152
- opacity: 20
153
- })]
154
- });
155
- };
156
- return _createClass(Sheet, [{
157
- key: "animationProps",
158
- get:
159
- /**
160
- * Getter for the animation props of the Sheet.
161
- * @returns {Object}
162
- */
163
- function () {
164
- return {
165
- duration: this.props.duration,
166
- ...styles.drawerAnimation,
167
- ...this.props.animation
168
- };
258
+ }
259
+ const [scrolled, setScrolled] = useState(false);
260
+ const [query, setQuery] = useState('');
261
+ const handleScroll = useMemo(() => throttle(() => {
262
+ const node = contentRef.current;
263
+ if (!node) {
264
+ return;
169
265
  }
170
- }]);
171
- }(Component);
266
+ const nextScrolled = node.scrollTop !== 0;
267
+ setScrolled(prev => prev === nextScrolled ? prev : nextScrolled);
268
+ }, 10), []);
269
+ useEffect(() => () => {
270
+ handleScroll.cancel();
271
+ }, [handleScroll]);
272
+ const handleClose = useCallback(() => {
273
+ onClose();
274
+ setIsOpen(false);
275
+ setScrolled(false);
276
+ }, [onClose]);
277
+ const handleDidOpen = useCallback(() => {
278
+ UIEvents.emit(SHEET_EVENTS.OPEN);
279
+ onDidOpen();
280
+ }, [onDidOpen]);
281
+ const handleDidClose = useCallback(() => {
282
+ UIEvents.emit(SHEET_EVENTS.CLOSE);
283
+ onDidClose();
284
+ }, [onDidClose]);
285
+ const handleSearchInput = useCallback(value => {
286
+ setQuery(value);
287
+ }, []);
288
+ const children = React.Children.map(childrenProp, child => (/*#__PURE__*/React.cloneElement(child, typeof child.type === 'function' && onClose !== null ? {
289
+ onClose,
290
+ query
291
+ } : {})));
292
+ return /*#__PURE__*/_jsx(SheetView, {
293
+ allowClose: allowClose,
294
+ animationFromParent: animation,
295
+ backdrop: backdrop,
296
+ className: className,
297
+ contentClassName: contentClassName,
298
+ contentRef: contentRef,
299
+ duration: sheetDuration,
300
+ handleSearchInput: handleSearchInput,
301
+ isLoading: isLoading,
302
+ isOpen: isOpen,
303
+ onClose: handleClose,
304
+ onDidClose: handleDidClose,
305
+ onDidOpen: handleDidOpen,
306
+ onOpen: onOpen,
307
+ onScroll: handleScroll,
308
+ scrolled: scrolled,
309
+ showSearch: showSearch,
310
+ title: title,
311
+ children: children
312
+ });
313
+ };
172
314
  Sheet.Header = Header;
173
- /**
174
- * The component default props.
175
- * @type {Object}
176
- */
177
315
  Sheet.defaultProps = {
178
316
  animation: {},
179
317
  backdrop: true,
package/Sheet/spec.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { shallow, mount } from 'enzyme';
3
+ import Drawer from '@shopgate/pwa-common/components/Drawer';
3
4
  import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
4
5
  import UIEvents from '@shopgate/pwa-core/emitters/ui';
5
6
  import Sheet, { SHEET_EVENTS } from "./index";
@@ -46,8 +47,9 @@ describe('<Sheet />', () => {
46
47
  wrapper.setProps({
47
48
  isOpen: true
48
49
  });
50
+ wrapper.update();
49
51
  expect(onOpen).toHaveBeenCalled();
50
- wrapper.find('Drawer').simulate('animationEnd');
52
+ wrapper.find(Drawer).simulate('animationEnd');
51
53
  expect(onDidOpen).toHaveBeenCalled();
52
54
  expect(UIEvents.emit).nthCalledWith(1, SHEET_EVENTS.OPEN);
53
55
  });
@@ -68,16 +70,16 @@ describe('<Sheet />', () => {
68
70
  // Wait until the drawer is closed and has updated it's state.
69
71
  setTimeout(() => {
70
72
  resolve();
71
- }, wrapper.find('Drawer').prop('animation').duration);
73
+ }, wrapper.find(Drawer).prop('animation').duration);
72
74
  }).then(() => {
73
75
  // Check if onClose callback was called.
74
76
  expect(onCloseSpy).toHaveBeenCalled();
75
77
 
76
78
  // Check if the Drawer component was closed.
77
- expect(wrapper.find('Drawer').prop('isOpen')).not.toBeTruthy();
79
+ expect(wrapper.find(Drawer).prop('isOpen')).not.toBeTruthy();
78
80
  expect(wrapper).toMatchSnapshot();
79
- wrapper.find('Drawer').simulate('animationEnd');
80
- expect(UIEvents.emit).nthCalledWith(2, SHEET_EVENTS.CLOSE);
81
+ wrapper.find(Drawer).simulate('animationEnd');
82
+ expect(UIEvents.emit).lastCalledWith(SHEET_EVENTS.CLOSE);
81
83
  });
82
84
  });
83
85
  it('should open', () => {
@@ -92,7 +94,7 @@ describe('<Sheet />', () => {
92
94
  isOpen: true
93
95
  });
94
96
  wrapper.update();
95
- expect(wrapper.find('Drawer').prop('isOpen')).toBeTruthy();
97
+ expect(wrapper.find(Drawer).prop('isOpen')).toBeTruthy();
96
98
  expect(wrapper).toMatchSnapshot();
97
99
  });
98
100
  });
@@ -1,17 +1,30 @@
1
1
  import React from 'react';
2
2
  import SurroundPortals from '@shopgate/pwa-common/components/SurroundPortals';
3
3
  import { PRODUCT_TAX_DISCLAIMER } from '@shopgate/pwa-common-commerce/product/constants/Portals';
4
- import I18n from '@shopgate/pwa-common/components/I18n';
4
+ import { I18n } from '@shopgate/engage/components';
5
5
  import showTaxDisclaimer from '@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';
6
6
  import { useWidgetSettings } from '@shopgate/engage/core/hooks/useWidgetSettings';
7
- import styles from "./style";
7
+ import { makeStyles } from '@shopgate/engage/styles';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const useStyles = makeStyles()(theme => ({
10
+ text: {
11
+ background: theme.palette.background.default,
12
+ display: 'block',
13
+ fontSize: 12,
14
+ padding: theme.spacing(2.5, 2),
15
+ textAlign: 'left'
16
+ }
17
+ }));
8
18
 
9
19
  /**
10
20
  * TaxDisclaimer component.
11
21
  * @returns {Function}
12
22
  */
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
23
  const TaxDisclaimer = () => {
24
+ const {
25
+ classes
26
+ } = useStyles();
27
+
15
28
  // Added with PWA 6 - CCP-2372
16
29
  const {
17
30
  show,
@@ -30,7 +43,7 @@ const TaxDisclaimer = () => {
30
43
  "aria-hidden": true,
31
44
  className: "ui-shared__tax-disclaimer",
32
45
  children: /*#__PURE__*/_jsx(I18n.Text, {
33
- className: styles,
46
+ className: classes.text,
34
47
  string: text || 'product.tax_disclaimer'
35
48
  })
36
49
  })
@@ -1,7 +1,20 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
- import I18n from '@shopgate/pwa-common/components/I18n';
3
+ import { I18n } from '@shopgate/engage/components';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
+ jest.mock('@shopgate/engage/components');
6
+ jest.mock('@shopgate/engage/styles', () => ({
7
+ makeStyles: () => function mockUseStylesFactory() {
8
+ return function useStylesMock() {
9
+ return {
10
+ classes: {
11
+ text: 'mock-class-text'
12
+ }
13
+ };
14
+ };
15
+ },
16
+ keyframes: () => ({})
17
+ }));
5
18
  jest.mock('@shopgate/engage/core/hooks/useWidgetSettings', () => ({
6
19
  useWidgetSettings: jest.fn().mockReturnValue({
7
20
  show: null,
@@ -15,16 +28,14 @@ describe('<TaxDisclaimer />', () => {
15
28
  });
16
29
  it('should display the component', () => {
17
30
  jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer', () => true);
18
- // eslint-disable-next-line global-require
19
- const TaxDisclaimer = require("./index").default;
31
+ const TaxDisclaimer = jest.requireActual("./index").default;
20
32
  const wrapper = shallow(/*#__PURE__*/_jsx(TaxDisclaimer, {}));
21
33
  expect(wrapper).toMatchSnapshot();
22
34
  expect(wrapper.find(I18n.Text).exists()).toBe(true);
23
35
  });
24
36
  it('should display null', () => {
25
37
  jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer', () => false);
26
- // eslint-disable-next-line global-require
27
- const TaxDisclaimer = require("./index").default;
38
+ const TaxDisclaimer = jest.requireActual("./index").default;
28
39
  const wrapper = shallow(/*#__PURE__*/_jsx(TaxDisclaimer, {}));
29
40
  expect(wrapper).toMatchSnapshot();
30
41
  expect(wrapper.find(I18n.Text).exists()).toBe(false);
@@ -1,15 +1,30 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import I18n from '@shopgate/pwa-common/components/I18n';
5
- import styles from "./style";
3
+ import { I18n } from '@shopgate/engage/components';
4
+ import { makeStyles } from '@shopgate/engage/styles';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ const ellipsisLine = {
7
+ overflow: 'hidden',
8
+ width: '100%',
9
+ whiteSpace: 'nowrap',
10
+ textOverflow: 'ellipsis'
11
+ };
12
+ const useStyles = makeStyles()(theme => ({
13
+ error: {
14
+ position: 'absolute',
15
+ bottom: 2,
16
+ fontSize: 12,
17
+ lineHeight: '14px',
18
+ color: theme.palette.error.main,
19
+ ...ellipsisLine
20
+ }
21
+ }));
6
22
 
7
23
  /**
8
24
  * Error message component.
9
25
  * @param {Object} props The component props.
10
26
  * @returns {JSX.Element}
11
27
  */
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
28
  const ErrorText = ({
14
29
  elementName,
15
30
  validationError,
@@ -17,16 +32,22 @@ const ErrorText = ({
17
32
  ariaHidden,
18
33
  translate,
19
34
  className
20
- }) => /*#__PURE__*/_jsxs("div", {
21
- id: `ariaError-${elementName}`,
22
- className: classNames(className, styles.error, 'errorText'),
23
- "aria-live": "assertive",
24
- "aria-atomic": "true",
25
- "aria-hidden": ariaHidden,
26
- children: [translate && /*#__PURE__*/_jsx(I18n.Text, {
27
- string: validationError || errorText
28
- }), !translate && (validationError || errorText)]
29
- });
35
+ }) => {
36
+ const {
37
+ classes,
38
+ cx
39
+ } = useStyles();
40
+ return /*#__PURE__*/_jsxs("div", {
41
+ id: `ariaError-${elementName}`,
42
+ className: cx(classes.error, className, 'errorText'),
43
+ "aria-live": "assertive",
44
+ "aria-atomic": "true",
45
+ "aria-hidden": ariaHidden,
46
+ children: [translate && /*#__PURE__*/_jsx(I18n.Text, {
47
+ string: validationError || errorText
48
+ }), !translate && (validationError || errorText)]
49
+ });
50
+ };
30
51
  ErrorText.defaultProps = {
31
52
  className: '',
32
53
  errorText: null,