@shopgate/pwa-ui-shared 7.30.0-alpha.7 → 7.30.0-alpha.9

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 (266) hide show
  1. package/AccordionContainer/index.js +39 -5
  2. package/AccordionContainer/spec.js +25 -2
  3. package/ActionButton/index.js +63 -7
  4. package/ActionButton/spec.js +63 -2
  5. package/ActionButton/style.js +22 -1
  6. package/AddToCartButton/index.js +184 -27
  7. package/AddToCartButton/mock.js +18 -4
  8. package/AddToCartButton/spec.js +65 -2
  9. package/AddToCartButton/style.js +127 -11
  10. package/Availability/index.js +34 -2
  11. package/Availability/spec.js +41 -1
  12. package/Availability/style.js +19 -1
  13. package/Button/index.js +76 -5
  14. package/Button/spec.js +33 -1
  15. package/Button/style.js +130 -21
  16. package/ButtonLink/connector.js +11 -2
  17. package/ButtonLink/index.js +44 -6
  18. package/ButtonLink/spec.js +23 -1
  19. package/Card/index.js +19 -2
  20. package/Card/style.js +11 -1
  21. package/CardList/components/Item/index.js +26 -2
  22. package/CardList/components/Item/style.js +7 -1
  23. package/CardList/index.js +34 -3
  24. package/CartTotalLine/components/Amount/index.js +28 -2
  25. package/CartTotalLine/components/Amount/style.js +8 -1
  26. package/CartTotalLine/components/Hint/index.js +23 -2
  27. package/CartTotalLine/components/Hint/style.js +12 -1
  28. package/CartTotalLine/components/Label/index.js +36 -2
  29. package/CartTotalLine/components/Label/style.js +17 -1
  30. package/CartTotalLine/components/Spacer/index.js +16 -2
  31. package/CartTotalLine/index.js +39 -2
  32. package/CartTotalLine/style.js +31 -1
  33. package/Checkbox/index.js +31 -2
  34. package/Checkbox/style.js +18 -1
  35. package/Chip/index.js +61 -2
  36. package/Chip/spec.js +24 -1
  37. package/Chip/style.js +71 -3
  38. package/ContextMenu/ContextMenu.hooks.js +6 -2
  39. package/ContextMenu/ContextMenuProvider.context.js +9 -3
  40. package/ContextMenu/ContextMenuProvider.js +21 -2
  41. package/ContextMenu/components/Item/index.js +67 -5
  42. package/ContextMenu/components/Item/style.js +32 -3
  43. package/ContextMenu/components/Position/index.js +61 -10
  44. package/ContextMenu/components/Position/style.js +11 -1
  45. package/ContextMenu/index.js +124 -3
  46. package/ContextMenu/spec.js +101 -2
  47. package/ContextMenu/style.js +45 -1
  48. package/Dialog/components/BasicDialog/index.js +5 -1
  49. package/Dialog/components/HtmlContentDialog/index.js +22 -2
  50. package/Dialog/components/HtmlContentDialog/spec.js +59 -1
  51. package/Dialog/components/PipelineErrorDialog/index.js +114 -25
  52. package/Dialog/components/PipelineErrorDialog/spec.js +92 -12
  53. package/Dialog/components/TextMessageDialog/index.js +28 -2
  54. package/Dialog/components/TextMessageDialog/spec.js +59 -1
  55. package/Dialog/components/VariantSelectModal/connector.js +11 -2
  56. package/Dialog/components/VariantSelectModal/index.js +65 -6
  57. package/Dialog/components/VariantSelectModal/spec.js +51 -2
  58. package/Dialog/constants.js +6 -1
  59. package/Dialog/index.js +114 -7
  60. package/Dialog/spec.js +81 -3
  61. package/DiscountBadge/index.js +30 -2
  62. package/DiscountBadge/spec.js +19 -1
  63. package/DiscountBadge/style.js +34 -2
  64. package/FavoritesButton/connector.js +18 -3
  65. package/FavoritesButton/index.js +118 -15
  66. package/FavoritesButton/mock.js +50 -4
  67. package/FavoritesButton/spec.js +120 -2
  68. package/FavoritesButton/style.js +26 -1
  69. package/Form/Builder/builders/buildCountryList.js +40 -6
  70. package/Form/Builder/builders/buildFormDefaults.js +35 -6
  71. package/Form/Builder/builders/buildFormElements.js +68 -10
  72. package/Form/Builder/builders/buildProvinceList.js +19 -2
  73. package/Form/Builder/builders/buildValidationErrorList.js +7 -2
  74. package/Form/Builder/classes/ActionListener/constants.js +22 -2
  75. package/Form/Builder/classes/ActionListener/index.js +441 -93
  76. package/Form/Builder/classes/ActionListener/spec.js +321 -19
  77. package/Form/Builder/components/CheckboxElement.js +35 -3
  78. package/Form/Builder/components/CountryElement.js +40 -3
  79. package/Form/Builder/components/ProvinceElement.js +40 -3
  80. package/Form/Builder/components/RadioElement.js +41 -3
  81. package/Form/Builder/components/SelectElement.js +39 -3
  82. package/Form/Builder/components/TextElement.js +49 -4
  83. package/Form/Builder/elementTypes.js +11 -1
  84. package/Form/Builder/index.js +298 -52
  85. package/Form/Builder/iso-3166-2.js +4943 -1
  86. package/Form/Builder/spec.js +308 -16
  87. package/Form/Checkbox/index.js +66 -4
  88. package/Form/Checkbox/style.js +25 -2
  89. package/Form/InfoField/index.js +50 -2
  90. package/Form/InfoField/spec.js +9 -1
  91. package/Form/InfoField/style.js +11 -1
  92. package/Form/Password/index.js +51 -6
  93. package/Form/Password/spec.js +34 -1
  94. package/Form/Password/style.js +11 -1
  95. package/Form/RadioGroup/components/Item/index.js +59 -3
  96. package/Form/RadioGroup/components/Item/style.js +32 -2
  97. package/Form/RadioGroup/index.js +101 -9
  98. package/Form/RadioGroup/spec.js +83 -3
  99. package/Form/RadioGroup/style.js +18 -2
  100. package/Form/Select/index.js +158 -10
  101. package/Form/Select/spec.js +36 -5
  102. package/Form/Select/style.js +27 -1
  103. package/Form/SelectContextChoices/index.js +77 -3
  104. package/Form/SelectContextChoices/spec.js +33 -4
  105. package/Form/SelectContextChoices/style.js +23 -1
  106. package/Form/TextField/index.js +92 -8
  107. package/Form/TextField/spec.js +110 -1
  108. package/Form/TextField/style.js +66 -8
  109. package/Form/index.js +54 -13
  110. package/FormElement/components/ErrorText/index.js +31 -2
  111. package/FormElement/components/ErrorText/style.js +13 -1
  112. package/FormElement/components/Label/index.js +35 -2
  113. package/FormElement/components/Label/style.js +76 -8
  114. package/FormElement/components/Placeholder/index.js +26 -2
  115. package/FormElement/components/Placeholder/style.js +48 -6
  116. package/FormElement/components/Underline/index.js +18 -2
  117. package/FormElement/components/Underline/style.js +51 -4
  118. package/FormElement/index.js +91 -6
  119. package/FormElement/spec.js +67 -2
  120. package/FormElement/style.js +13 -2
  121. package/Glow/index.js +90 -7
  122. package/Glow/spec.js +9 -1
  123. package/Glow/style.js +18 -1
  124. package/IndicatorCircle/index.js +33 -3
  125. package/IndicatorCircle/spec.js +28 -1
  126. package/IndicatorCircle/style.js +57 -3
  127. package/LoadingIndicator/index.js +29 -2
  128. package/LoadingIndicator/style.js +20 -1
  129. package/Manufacturer/index.js +20 -2
  130. package/Manufacturer/style.js +5 -1
  131. package/MessageBar/index.js +36 -2
  132. package/MessageBar/spec.js +79 -1
  133. package/MessageBar/style.js +38 -1
  134. package/NoResults/components/Icon/index.js +130 -2
  135. package/NoResults/components/Icon/style.js +17 -1
  136. package/NoResults/index.js +46 -2
  137. package/NoResults/style.js +31 -1
  138. package/Placeholder/index.js +25 -3
  139. package/Placeholder/style.js +11 -1
  140. package/PlaceholderLabel/index.js +27 -2
  141. package/PlaceholderLabel/spec.js +19 -1
  142. package/PlaceholderLabel/style.js +12 -1
  143. package/PlaceholderParagraph/index.js +36 -2
  144. package/PlaceholderParagraph/spec.js +19 -1
  145. package/Price/index.js +88 -7
  146. package/Price/style.js +22 -1
  147. package/PriceInfo/index.js +20 -2
  148. package/PriceInfo/style.js +5 -1
  149. package/PriceStriked/index.js +83 -12
  150. package/PriceStriked/style.js +33 -3
  151. package/ProductProperties/index.js +32 -2
  152. package/ProgressBar/index.js +101 -13
  153. package/ProgressBar/spec.js +13 -1
  154. package/ProgressBar/style.js +83 -2
  155. package/RadioButton/index.js +18 -2
  156. package/RadioButton/spec.js +21 -1
  157. package/RadioButton/style.js +21 -1
  158. package/RatingNumber/index.js +29 -2
  159. package/RatingStars/constants.js +2 -1
  160. package/RatingStars/index.js +130 -12
  161. package/RatingStars/spec.js +90 -3
  162. package/RatingStars/style.js +51 -2
  163. package/Ripple/components/RippleAnimation/index.js +88 -6
  164. package/Ripple/index.js +218 -40
  165. package/Ripple/style.js +18 -1
  166. package/RippleButton/index.js +52 -5
  167. package/RippleButton/spec.js +45 -1
  168. package/ScannerOverlay/components/CameraOverlay/index.js +13 -2
  169. package/ScannerOverlay/components/CameraOverlay/style.js +40 -1
  170. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +34 -2
  171. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +28 -1
  172. package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +11 -2
  173. package/ScannerOverlay/components/ScannerBar/index.js +31 -2
  174. package/ScannerOverlay/components/ScannerBar/style.js +20 -1
  175. package/ScannerOverlay/index.js +47 -7
  176. package/Sheet/components/Header/components/SearchBar/index.js +46 -2
  177. package/Sheet/components/Header/components/SearchBar/spec.js +21 -3
  178. package/Sheet/components/Header/components/SearchBar/style.js +47 -1
  179. package/Sheet/components/Header/index.js +75 -7
  180. package/Sheet/components/Header/spec.js +14 -1
  181. package/Sheet/components/Header/style.js +50 -1
  182. package/Sheet/index.js +170 -17
  183. package/Sheet/spec.js +85 -5
  184. package/Sheet/style.js +143 -2
  185. package/TaxDisclaimer/index.js +34 -4
  186. package/TaxDisclaimer/spec.js +31 -3
  187. package/TaxDisclaimer/style.js +9 -1
  188. package/TextField/components/ErrorText/index.js +33 -2
  189. package/TextField/components/ErrorText/style.js +25 -3
  190. package/TextField/components/FormElement/index.js +19 -2
  191. package/TextField/components/FormElement/style.js +32 -4
  192. package/TextField/components/Hint/index.js +21 -2
  193. package/TextField/components/Hint/style.js +40 -5
  194. package/TextField/components/Label/index.js +32 -3
  195. package/TextField/components/Label/style.js +68 -8
  196. package/TextField/components/Underline/index.js +19 -2
  197. package/TextField/components/Underline/style.js +51 -4
  198. package/TextField/index.js +189 -27
  199. package/TextField/spec.js +128 -3
  200. package/TextField/style.js +34 -4
  201. package/ToggleIcon/index.js +58 -8
  202. package/ToggleIcon/spec.js +35 -1
  203. package/icons/AccountBoxIcon.js +11 -2
  204. package/icons/AddMoreIcon.js +11 -2
  205. package/icons/ArrowDropIcon.js +11 -2
  206. package/icons/ArrowIcon.js +21 -2
  207. package/icons/BarcodeScannerIcon.js +11 -2
  208. package/icons/BoxIcon.js +11 -2
  209. package/icons/BrowseIcon.js +11 -2
  210. package/icons/BurgerIcon.js +11 -2
  211. package/icons/CalendarIcon.js +15 -3
  212. package/icons/CartCouponIcon.js +72 -2
  213. package/icons/CartIcon.js +11 -2
  214. package/icons/CartPlusIcon.js +11 -2
  215. package/icons/CheckIcon.js +11 -2
  216. package/icons/CheckedIcon.js +11 -2
  217. package/icons/ChevronIcon.js +11 -2
  218. package/icons/CreditCardIcon.js +11 -2
  219. package/icons/CrossIcon.js +11 -2
  220. package/icons/DescriptionIcon.js +11 -2
  221. package/icons/FilterIcon.js +11 -2
  222. package/icons/FlashDisabledIcon.js +11 -2
  223. package/icons/FlashEnabledIcon.js +11 -2
  224. package/icons/GridIcon.js +11 -2
  225. package/icons/HeartIcon.js +11 -2
  226. package/icons/HeartOutlineIcon.js +11 -2
  227. package/icons/HeartPlusIcon.js +12 -2
  228. package/icons/HeartPlusOutlineIcon.js +12 -2
  229. package/icons/HomeIcon.js +11 -2
  230. package/icons/InfoIcon.js +11 -2
  231. package/icons/InfoOutlineIcon.js +11 -2
  232. package/icons/ListIcon.js +11 -2
  233. package/icons/LocalShippingIcon.js +11 -2
  234. package/icons/LocationIcon.js +13 -3
  235. package/icons/LocatorIcon.js +11 -2
  236. package/icons/LockIcon.js +11 -2
  237. package/icons/LogoutIcon.js +11 -2
  238. package/icons/MagnifierIcon.js +11 -2
  239. package/icons/MapMarkerIcon.js +24 -3
  240. package/icons/MoreIcon.js +11 -2
  241. package/icons/MoreVertIcon.js +11 -2
  242. package/icons/NotificationIcon.js +14 -3
  243. package/icons/PersonIcon.js +12 -2
  244. package/icons/PhoneIcon.js +13 -3
  245. package/icons/PlaceholderIcon.js +11 -2
  246. package/icons/RadioCheckedIcon.js +11 -2
  247. package/icons/RadioUncheckedIcon.js +11 -2
  248. package/icons/SecurityIcon.js +11 -2
  249. package/icons/ShippingMethodIcon.js +18 -3
  250. package/icons/ShoppingCartIcon.js +11 -2
  251. package/icons/SortIcon.js +11 -2
  252. package/icons/StarHalfIcon.js +18 -2
  253. package/icons/StarIcon.js +18 -2
  254. package/icons/StarOutlineIcon.js +11 -2
  255. package/icons/StopIcon.js +11 -2
  256. package/icons/TickIcon.js +11 -2
  257. package/icons/TimeIcon.js +14 -3
  258. package/icons/TrashIcon.js +11 -2
  259. package/icons/TrashOutlineIcon.js +12 -2
  260. package/icons/UncheckedIcon.js +11 -2
  261. package/icons/ViewListIcon.js +11 -2
  262. package/icons/VisibilityIcon.js +11 -2
  263. package/icons/VisibilityOffIcon.js +11 -2
  264. package/icons/WarningIcon.js +11 -2
  265. package/index.js +13 -1
  266. package/package.json +5 -5
@@ -1,4 +1,53 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var colors=themeConfig.colors;var container=css({position:'relative'}).toString();var icon=css({display:'inline-block',verticalAlign:'top',outline:0}).toString();var emptyStars=css({color:themeConfig.colors.shade7}).toString();var filledStars=css({position:'absolute',color:"var(--color-primary, ".concat(colors.primary,")"),top:0}).toString();/**
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ const {
4
+ colors
5
+ } = themeConfig;
6
+ const container = css({
7
+ position: 'relative'
8
+ }).toString();
9
+ const icon = css({
10
+ display: 'inline-block',
11
+ verticalAlign: 'top',
12
+ outline: 0
13
+ }).toString();
14
+ const emptyStars = css({
15
+ color: themeConfig.colors.shade7
16
+ }).toString();
17
+ const filledStars = css({
18
+ position: 'absolute',
19
+ color: `var(--color-primary, ${colors.primary})`,
20
+ top: 0
21
+ }).toString();
22
+
23
+ /**
2
24
  * The rating stars styles that can be selected by passing the style key to the
3
25
  * @type {Object}
4
- */var iconStyles={small:{iconSize:'1em',iconStyle:css({marginRight:'0.1em'}).toString()},big:{iconSize:'1.24em',iconStyle:css({marginRight:'0.12em'}).toString()},large:{iconSize:'2.3em',iconStyle:css({marginRight:'0.23em'}).toString()}};export default{container:container,icon:icon,iconStyles:iconStyles,emptyStars:emptyStars,filledStars:filledStars};
26
+ */
27
+ const iconStyles = {
28
+ small: {
29
+ iconSize: '1em',
30
+ iconStyle: css({
31
+ marginRight: '0.1em'
32
+ }).toString()
33
+ },
34
+ big: {
35
+ iconSize: '1.24em',
36
+ iconStyle: css({
37
+ marginRight: '0.12em'
38
+ }).toString()
39
+ },
40
+ large: {
41
+ iconSize: '2.3em',
42
+ iconStyle: css({
43
+ marginRight: '0.23em'
44
+ }).toString()
45
+ }
46
+ };
47
+ export default {
48
+ container,
49
+ icon,
50
+ iconStyles,
51
+ emptyStars,
52
+ filledStars
53
+ };
@@ -1,4 +1,10 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useEffect,useRef,useMemo}from'react';import PropTypes from'prop-types';import{Transition}from'react-transition-group';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import style from"../../style";/**
1
+ import React, { useEffect, useRef, useMemo } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Transition } from 'react-transition-group';
4
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
+ import style from "../../style";
6
+
7
+ /**
2
8
  * The RippleAnimation component
3
9
  *
4
10
  * Plays a one-shot ripple animation and calls `onComplete` when finished.
@@ -10,10 +16,86 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
10
16
  * @param {number} props.x The x coordinate of the ripple center.
11
17
  * @param {number} props.y The y coordinate of the ripple center.
12
18
  * @returns {JSX.Element}
13
- */function RippleAnimation(_ref){var color=_ref.color,duration=_ref.duration,onComplete=_ref.onComplete,size=_ref.size,x=_ref.x,y=_ref.y;var nodeRef=useRef(null);// Trigger the animation immediately
14
- var inProp=true;var baseStyle=useMemo(function(){return{position:'absolute',backgroundColor:color,height:size,width:size,left:x,top:y,borderRadius:'50%',transform:'translate3d(-50%, -50%, 0) scale3d(0, 0, 1)',opacity:0.25,transition:"opacity ".concat(duration,"ms cubic-bezier(0.25, 0.1, 0.25, 1), transform ").concat(duration,"ms cubic-bezier(0.25, 0.1, 0.25, 1)"),pointerEvents:'none'};},[color,duration,size,x,y]);var transitionStyles=useMemo(function(){return{entering:{transform:'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)',opacity:0},entered:{transform:'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)',opacity:0},exiting:{},exited:{},unmounted:{}};},[]);// Run callback when transition ends
15
- useEffect(function(){var el=nodeRef.current;if(!el)return undefined;/**
19
+ */
20
+ function RippleAnimation({
21
+ color,
22
+ duration,
23
+ onComplete,
24
+ size,
25
+ x,
26
+ y
27
+ }) {
28
+ const nodeRef = useRef(null);
29
+
30
+ // Trigger the animation immediately
31
+ const inProp = true;
32
+ const baseStyle = useMemo(() => ({
33
+ position: 'absolute',
34
+ backgroundColor: color,
35
+ height: size,
36
+ width: size,
37
+ left: x,
38
+ top: y,
39
+ borderRadius: '50%',
40
+ transform: 'translate3d(-50%, -50%, 0) scale3d(0, 0, 1)',
41
+ opacity: 0.25,
42
+ transition: `opacity ${duration}ms cubic-bezier(0.25, 0.1, 0.25, 1), transform ${duration}ms cubic-bezier(0.25, 0.1, 0.25, 1)`,
43
+ pointerEvents: 'none'
44
+ }), [color, duration, size, x, y]);
45
+ const transitionStyles = useMemo(() => ({
46
+ entering: {
47
+ transform: 'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)',
48
+ opacity: 0
49
+ },
50
+ entered: {
51
+ transform: 'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)',
52
+ opacity: 0
53
+ },
54
+ exiting: {},
55
+ exited: {},
56
+ unmounted: {}
57
+ }), []);
58
+
59
+ // Run callback when transition ends
60
+ useEffect(() => {
61
+ const el = nodeRef.current;
62
+ if (!el) return undefined;
63
+
64
+ /**
16
65
  * Handles the transition end event and calls onComplete for relevant properties.
17
66
  * @param {TransitionEvent} e - The transition event object
18
- */var handleEnd=function handleEnd(e){// Only handle transform or opacity transitions
19
- if(e.propertyName==='transform'||e.propertyName==='opacity'){onComplete();}};el.addEventListener('transitionend',handleEnd);return function(){return el.removeEventListener('transitionend',handleEnd);};},[onComplete]);return React.createElement(Transition,{"in":inProp,timeout:duration,appear:true,mountOnEnter:true,unmountOnExit:true,nodeRef:nodeRef},function(state){return React.createElement("div",{ref:nodeRef,className:style.ripple,style:_extends({},baseStyle,{},transitionStyles[state])});});}RippleAnimation.defaultProps={color:themeConfig.colors.dark,duration:300,onComplete:function onComplete(){},size:48,x:0,y:0};export default React.memo(RippleAnimation);
67
+ */
68
+ const handleEnd = e => {
69
+ // Only handle transform or opacity transitions
70
+ if (e.propertyName === 'transform' || e.propertyName === 'opacity') {
71
+ onComplete();
72
+ }
73
+ };
74
+ el.addEventListener('transitionend', handleEnd);
75
+ return () => el.removeEventListener('transitionend', handleEnd);
76
+ }, [onComplete]);
77
+ return /*#__PURE__*/React.createElement(Transition, {
78
+ in: inProp,
79
+ timeout: duration,
80
+ appear: true,
81
+ mountOnEnter: true,
82
+ unmountOnExit: true,
83
+ nodeRef: nodeRef
84
+ }, state => /*#__PURE__*/React.createElement("div", {
85
+ ref: nodeRef,
86
+ className: style.ripple,
87
+ style: {
88
+ ...baseStyle,
89
+ ...transitionStyles[state]
90
+ }
91
+ }));
92
+ }
93
+ RippleAnimation.defaultProps = {
94
+ color: themeConfig.colors.dark,
95
+ duration: 300,
96
+ onComplete: () => {},
97
+ size: 48,
98
+ x: 0,
99
+ y: 0
100
+ };
101
+ export default /*#__PURE__*/React.memo(RippleAnimation);
package/Ripple/index.js CHANGED
@@ -1,60 +1,238 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import{findDOMNode}from'react-dom';import clamp from'lodash/clamp';import{shift}from'@shopgate/pwa-common/helpers/data';import{getOffset}from'@shopgate/pwa-common/helpers/dom';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import RippleAnimation from"./components/RippleAnimation";import style from"./style";/**
1
+ import React, { PureComponent } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { findDOMNode } from 'react-dom';
4
+ import clamp from 'lodash/clamp';
5
+ import { shift } from '@shopgate/pwa-common/helpers/data';
6
+ import { getOffset } from '@shopgate/pwa-common/helpers/dom';
7
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
8
+ import RippleAnimation from "./components/RippleAnimation";
9
+ import style from "./style";
10
+
11
+ /**
2
12
  * The ripple component.
3
- */var Ripple=/*#__PURE__*/function(_PureComponent){/**
13
+ */
14
+ class Ripple extends PureComponent {
15
+ /**
4
16
  * Constructor.
5
17
  * @param {Object} props The component props.
6
- */function Ripple(props){var _this2;_classCallCheck(this,Ripple);_this2=_callSuper(this,Ripple,[props]);/**
7
- * Triggers adding of a new ripple on touch start event.
8
- * @param {Object} event The even object.
9
- */_defineProperty(_this2,"handleClick",function(event){if(_this2.props.disabled){return;}_this2.addRipple(event,true);_this2.props.onClick();});/**
10
- * Will be triggered from the ripple animation component, when the
11
- * ripple animation is over. It removes the ripple from the queue again.
12
- */_defineProperty(_this2,"removeRipple",function(){if(!_this2.mounted){return;}_this2.setState(function(prevState){var ripples=shift(prevState.ripples);_this2.props.onComplete();return{ripples:ripples,hasRipples:!!ripples.length};});});_this2.state={ripples:[],nextKey:0,hasRipples:false};_this2.duration=500;_this2.ignoreNextMouseDown=false;_this2.mounted=false;_this2.offset=null;_this2.position=null;_this2.rootNode=null;_this2.style=null;return _this2;}/**
18
+ */
19
+ constructor(props) {
20
+ super(props);
21
+ /**
22
+ * Triggers adding of a new ripple on touch start event.
23
+ * @param {Object} event The even object.
24
+ */
25
+ this.handleClick = event => {
26
+ if (this.props.disabled) {
27
+ return;
28
+ }
29
+ this.addRipple(event, true);
30
+ this.props.onClick();
31
+ };
32
+ /**
33
+ * Will be triggered from the ripple animation component, when the
34
+ * ripple animation is over. It removes the ripple from the queue again.
35
+ */
36
+ this.removeRipple = () => {
37
+ if (!this.mounted) {
38
+ return;
39
+ }
40
+ this.setState(prevState => {
41
+ const ripples = shift(prevState.ripples);
42
+ this.props.onComplete();
43
+ return {
44
+ ripples,
45
+ hasRipples: !!ripples.length
46
+ };
47
+ });
48
+ };
49
+ this.state = {
50
+ ripples: [],
51
+ nextKey: 0,
52
+ hasRipples: false
53
+ };
54
+ this.duration = 500;
55
+ this.ignoreNextMouseDown = false;
56
+ this.mounted = false;
57
+ this.offset = null;
58
+ this.position = null;
59
+ this.rootNode = null;
60
+ this.style = null;
61
+ }
62
+
63
+ /**
13
64
  * Sets the `mounted` flag to true.
14
- */_inherits(Ripple,_PureComponent);return _createClass(Ripple,[{key:"componentDidMount",value:function componentDidMount(){var fill=this.props.fill;// Reference to Ripple container (for now and later).
15
- this.rootNode=findDOMNode(this);// eslint-disable-line react/no-find-dom-node
16
- // Initially set the position values to be in the middle of the element.
17
- // If the Ripple's starting point has to follow the user's touch
18
- // Location then this is checked later.
19
- this.position={x:this.rootNode.offsetWidth/2,y:this.rootNode.offsetHeight/2};// Determine the duration based on the size of the ripple.
20
- this.duration=clamp(Math.round(Math.log(this.rippleSize)*100-(fill?-75:50)),0,10000);// Set the `mounted` flag to true.
21
- this.mounted=true;// If the Ripple is not allowed to overflow then apply some styles to the parent container.
22
- this.style=!this.props.overflow?{overflow:'hidden',position:'relative'}:null;}/**
65
+ */
66
+ componentDidMount() {
67
+ const {
68
+ fill
69
+ } = this.props;
70
+
71
+ // Reference to Ripple container (for now and later).
72
+ this.rootNode = findDOMNode(this); // eslint-disable-line react/no-find-dom-node
73
+
74
+ // Initially set the position values to be in the middle of the element.
75
+ // If the Ripple's starting point has to follow the user's touch
76
+ // Location then this is checked later.
77
+ this.position = {
78
+ x: this.rootNode.offsetWidth / 2,
79
+ y: this.rootNode.offsetHeight / 2
80
+ };
81
+
82
+ // Determine the duration based on the size of the ripple.
83
+ this.duration = clamp(Math.round(Math.log(this.rippleSize) * 100 - (fill ? -75 : 50)), 0, 10000);
84
+
85
+ // Set the `mounted` flag to true.
86
+ this.mounted = true;
87
+
88
+ // If the Ripple is not allowed to overflow then apply some styles to the parent container.
89
+ this.style = !this.props.overflow ? {
90
+ overflow: 'hidden',
91
+ position: 'relative'
92
+ } : null;
93
+ }
94
+
95
+ /**
23
96
  * Sets the `mounted` flag to false
24
- */},{key:"componentWillUnmount",value:function componentWillUnmount(){this.mounted=false;}/**
97
+ */
98
+ componentWillUnmount() {
99
+ this.mounted = false;
100
+ }
101
+
102
+ /**
25
103
  * Calculate the size of the ripple.
26
104
  * @returns {number}
27
- */},{key:"rippleSize",get:function get(){if(this.props.size){if(this.props.fill){return this.props.size*2;}return this.props.size;}/**
105
+ */
106
+ get rippleSize() {
107
+ if (this.props.size) {
108
+ if (this.props.fill) {
109
+ return this.props.size * 2;
110
+ }
111
+ return this.props.size;
112
+ }
113
+
114
+ /**
28
115
  * We want the Ripple to fill the element. We set the diameter of the Ripple
29
116
  * to double the distance of the opposing corners of the node. That way the Ripple
30
117
  * will reach the furthest away corner if you click at a corner.
31
- */if(this.props.fill){return Math.sqrt(Math.pow(this.rootNode.offsetWidth,2)+Math.pow(this.rootNode.offsetHeight,2))*2;}// Otherwise we set the size to be the smaller of the element's height and width.
32
- return Math.min(this.rootNode.offsetWidth,this.rootNode.offsetHeight);}/**
118
+ */
119
+ if (this.props.fill) {
120
+ return Math.sqrt(this.rootNode.offsetWidth ** 2 + this.rootNode.offsetHeight ** 2) * 2;
121
+ }
122
+
123
+ // Otherwise we set the size to be the smaller of the element's height and width.
124
+ return Math.min(this.rootNode.offsetWidth, this.rootNode.offsetHeight);
125
+ }
126
+
127
+ /**
33
128
  * Calculates the ripple position from the event.
34
129
  * @param {Object} event The event object.
35
130
  * @returns {Object} An object containing x and y values for the ripple.
36
- */},{key:"getRipplePosition",value:function getRipplePosition(event){// If the Ripple is to fill the element then we should set the
37
- // Starting position to be where the user clicked within that element.
38
- if(this.props.fill){// Determine if event is a touch event.
39
- var isTouchEvent=event.touches&&event.touches.length;// Find the center points of the event.
40
- var pageX=isTouchEvent?event.touches[0].pageX:event.pageX;var pageY=isTouchEvent?event.touches[0].pageY:event.pageY;// The pointer location is relative to the element offset.
41
- this.position.x=pageX-this.offset.left;this.position.y=pageY-this.offset.top;}return this.position;}},{key:"addRipple",value:/**
131
+ */
132
+ getRipplePosition(event) {
133
+ // If the Ripple is to fill the element then we should set the
134
+ // Starting position to be where the user clicked within that element.
135
+ if (this.props.fill) {
136
+ // Determine if event is a touch event.
137
+ const isTouchEvent = event.touches && event.touches.length;
138
+
139
+ // Find the center points of the event.
140
+ const pageX = isTouchEvent ? event.touches[0].pageX : event.pageX;
141
+ const pageY = isTouchEvent ? event.touches[0].pageY : event.pageY;
142
+
143
+ // The pointer location is relative to the element offset.
144
+ this.position.x = pageX - this.offset.left;
145
+ this.position.y = pageY - this.offset.top;
146
+ }
147
+ return this.position;
148
+ }
149
+ /**
42
150
  * Adds a new Ripple to the queue.
43
151
  * @param {Object} event The event object.
44
152
  * @param {boolean} isTouchGenerated Whether the action was triggered by a touch or click.
45
- */function addRipple(event,isTouchGenerated){// If the adding of the Ripple was already triggered
46
- // By a touch start event, no further action will be done.
47
- if(this.ignoreNextMouseDown&&!isTouchGenerated){this.ignoreNextMouseDown=false;return;}// Get the position of the element and store it.
48
- this.offset=getOffset(this.rootNode);// Receive the x and y position for the new Ripple.
49
- var _this$getRipplePositi=this.getRipplePosition(event),x=_this$getRipplePositi.x,y=_this$getRipplePositi.y;var ripples=this.state.ripples;// Append the new ripple to the ripples array.
50
- ripples.push(React.createElement(RippleAnimation,{color:this.props.color,duration:this.duration,fill:this.props.fill,key:this.state.nextKey,onComplete:this.removeRipple,size:this.rippleSize,x:x,y:y}));this.ignoreNextMouseDown=isTouchGenerated;// Update the state.
51
- this.setState(function(_ref){var nextKey=_ref.nextKey;return{ripples:ripples,nextKey:nextKey+1,hasRipples:true};});}/**
153
+ */
154
+ addRipple(event, isTouchGenerated) {
155
+ // If the adding of the Ripple was already triggered
156
+ // By a touch start event, no further action will be done.
157
+ if (this.ignoreNextMouseDown && !isTouchGenerated) {
158
+ this.ignoreNextMouseDown = false;
159
+ return;
160
+ }
161
+
162
+ // Get the position of the element and store it.
163
+ this.offset = getOffset(this.rootNode);
164
+
165
+ // Receive the x and y position for the new Ripple.
166
+ const {
167
+ x,
168
+ y
169
+ } = this.getRipplePosition(event);
170
+ const {
171
+ ripples
172
+ } = this.state;
173
+
174
+ // Append the new ripple to the ripples array.
175
+ ripples.push(/*#__PURE__*/React.createElement(RippleAnimation, {
176
+ color: this.props.color,
177
+ duration: this.duration,
178
+ fill: this.props.fill,
179
+ key: this.state.nextKey,
180
+ onComplete: this.removeRipple,
181
+ size: this.rippleSize,
182
+ x: x,
183
+ y: y
184
+ }));
185
+ this.ignoreNextMouseDown = isTouchGenerated;
186
+
187
+ // Update the state.
188
+ this.setState(({
189
+ nextKey
190
+ }) => ({
191
+ ripples,
192
+ nextKey: nextKey + 1,
193
+ hasRipples: true
194
+ }));
195
+ }
196
+
197
+ /**
52
198
  * Renders all the ripples in the queue.
53
199
  * @returns {JSX|null}
54
- */},{key:"renderRipples",value:function renderRipples(){// It only needs to render, if there is at least one ripple in the queue.
55
- if(!this.state.hasRipples){return null;}return React.createElement("div",{className:style.container},this.state.ripples);}/**
200
+ */
201
+ renderRipples() {
202
+ // It only needs to render, if there is at least one ripple in the queue.
203
+ if (!this.state.hasRipples) {
204
+ return null;
205
+ }
206
+ return /*#__PURE__*/React.createElement("div", {
207
+ className: style.container
208
+ }, this.state.ripples);
209
+ }
210
+
211
+ /**
56
212
  * Renders the final ripple component including it's contents.
57
213
  * @returns {JSX}
58
- */},{key:"render",value:function render(){/* eslint-disable jsx-a11y/click-events-have-key-events,
59
- jsx-a11y/no-static-element-interactions */return React.createElement("div",{className:"ui-shared__ripple ".concat(this.props.className),"data-test-id":"Ripple",onClick:this.handleClick,style:this.style},this.renderRipples(),this.props.children);/* eslint-enable jsx-a11y/click-events-have-key-events,
60
- jsx-a11y/no-static-element-interactions */}}]);}(PureComponent);_defineProperty(Ripple,"defaultProps",{className:'',color:themeConfig.colors.dark,disabled:false,fill:false,onClick:function onClick(){},onComplete:function onComplete(){},overflow:false,size:null});export default Ripple;
214
+ */
215
+ render() {
216
+ /* eslint-disable jsx-a11y/click-events-have-key-events,
217
+ jsx-a11y/no-static-element-interactions */
218
+ return /*#__PURE__*/React.createElement("div", {
219
+ className: `ui-shared__ripple ${this.props.className}`,
220
+ "data-test-id": "Ripple",
221
+ onClick: this.handleClick,
222
+ style: this.style
223
+ }, this.renderRipples(), this.props.children);
224
+ /* eslint-enable jsx-a11y/click-events-have-key-events,
225
+ jsx-a11y/no-static-element-interactions */
226
+ }
227
+ }
228
+ Ripple.defaultProps = {
229
+ className: '',
230
+ color: themeConfig.colors.dark,
231
+ disabled: false,
232
+ fill: false,
233
+ onClick: () => {},
234
+ onComplete: () => {},
235
+ overflow: false,
236
+ size: null
237
+ };
238
+ export default Ripple;
package/Ripple/style.js CHANGED
@@ -1 +1,18 @@
1
- import{css}from'glamor';var ripple=css({position:'absolute',borderRadius:'50%',transformOrigin:'50% 50% 0'}).toString();var container=css({position:'absolute',zIndex:0,top:0,left:0,width:'100%',height:'100%'}).toString();export default{ripple:ripple,container:container};
1
+ import { css } from 'glamor';
2
+ const ripple = css({
3
+ position: 'absolute',
4
+ borderRadius: '50%',
5
+ transformOrigin: '50% 50% 0'
6
+ }).toString();
7
+ const container = css({
8
+ position: 'absolute',
9
+ zIndex: 0,
10
+ top: 0,
11
+ left: 0,
12
+ width: '100%',
13
+ height: '100%'
14
+ }).toString();
15
+ export default {
16
+ ripple,
17
+ container
18
+ };
@@ -1,11 +1,58 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import Ripple from"../Ripple";import Button from"../Button";import style from"../Button/style";/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { Component } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import Ripple from "../Ripple";
5
+ import Button from "../Button";
6
+ import style from "../Button/style";
7
+
8
+ /**
2
9
  * The ripple button component is a special derivation of the basic button component
3
10
  * that adds a ripple effect when clicked.
4
- */var RippleButton=/*#__PURE__*/function(_Component){function RippleButton(){_classCallCheck(this,RippleButton);return _callSuper(this,RippleButton,arguments);}_inherits(RippleButton,_Component);return _createClass(RippleButton,[{key:"buttonProps",get:/**
11
+ */
12
+ class RippleButton extends Component {
13
+ /**
5
14
  * Getter for the calculated button props.
6
15
  * @returns {Object}
7
- */function get(){return{className:"".concat(this.props.className," ui-shared__ripple-button"),disabled:this.props.disabled,onClick:this.props.onClick,flat:this.props.flat,type:this.props.type,wrapContent:false,'aria-label':this.props['aria-label'],'aria-haspopup':this.props['aria-haspopup']};}/**
16
+ */
17
+ get buttonProps() {
18
+ return {
19
+ className: `${this.props.className} ui-shared__ripple-button`,
20
+ disabled: this.props.disabled,
21
+ onClick: this.props.onClick,
22
+ flat: this.props.flat,
23
+ type: this.props.type,
24
+ wrapContent: false,
25
+ 'aria-label': this.props['aria-label'],
26
+ 'aria-haspopup': this.props['aria-haspopup']
27
+ };
28
+ }
29
+
30
+ /**
8
31
  * Renders the component.
9
32
  * @returns {JSX}
10
- */},{key:"render",value:function render(){if(this.props.disabled){// Don't show the ripple effect when the button is disabled.
11
- return React.createElement(Button,_extends({},this.buttonProps,{wrapContent:true}),this.props.children);}var rippleProps={className:"".concat(style.contentWrapper," ").concat(this.props.rippleClassName),fill:true,size:this.props.rippleSize,overflow:true};return React.createElement(Button,_extends({},this.buttonProps,{testId:this.props.testId}),React.createElement(Ripple,rippleProps,this.props.children));}}]);}(Component);_defineProperty(RippleButton,"defaultProps",_extends({},Button.defaultProps,{rippleClassName:'',rippleSize:null,testId:'Button'}));export default RippleButton;
33
+ */
34
+ render() {
35
+ if (this.props.disabled) {
36
+ // Don't show the ripple effect when the button is disabled.
37
+ return /*#__PURE__*/React.createElement(Button, _extends({}, this.buttonProps, {
38
+ wrapContent: true
39
+ }), this.props.children);
40
+ }
41
+ const rippleProps = {
42
+ className: `${style.contentWrapper} ${this.props.rippleClassName}`,
43
+ fill: true,
44
+ size: this.props.rippleSize,
45
+ overflow: true
46
+ };
47
+ return /*#__PURE__*/React.createElement(Button, _extends({}, this.buttonProps, {
48
+ testId: this.props.testId
49
+ }), /*#__PURE__*/React.createElement(Ripple, rippleProps, this.props.children));
50
+ }
51
+ }
52
+ RippleButton.defaultProps = {
53
+ ...Button.defaultProps,
54
+ rippleClassName: '',
55
+ rippleSize: null,
56
+ testId: 'Button'
57
+ };
58
+ export default RippleButton;
@@ -1 +1,45 @@
1
- import trim from'lodash/trim';import React from'react';import{shallow,mount}from'enzyme';import Button from'@shopgate/pwa-common/components/Button';import Ripple from"../Ripple";import styles from"../Button/style";import RippleButton from"./index";describe('<RippleButton />',function(){it('should render as a regular ripple button effect if type is omitted',function(){var wrapper=shallow(React.createElement(RippleButton,null,"Press me"));expect(wrapper).toMatchSnapshot();expect(wrapper.find(Ripple).render().text()).toEqual('Press me');});it('should render as a regular ripple button if type is explicitly defined',function(){var wrapper=mount(React.createElement(RippleButton,{type:"regular"},"Press me"));expect(trim(wrapper.find(Button).props().className)).toEqual("ui-shared__button ".concat(styles.regular(false).button," ui-shared__ripple-button"));expect(wrapper.find(Ripple).render().text()).toEqual('Press me');expect(wrapper).toMatchSnapshot();});it('should render as a primary ripple button',function(){var wrapper=mount(React.createElement(RippleButton,{type:"primary"},"Press me"));expect(trim(wrapper.find(Button).props().className)).toEqual("ui-shared__button ".concat(styles.primary(false).button," ui-shared__ripple-button"));expect(wrapper.find(Ripple).render().text()).toEqual('Press me');expect(wrapper).toMatchSnapshot();});it('should render as a secondary ripple button',function(){var wrapper=mount(React.createElement(RippleButton,{type:"secondary"},"Press me"));expect(trim(wrapper.find(Button).props().className)).toEqual("ui-shared__button ".concat(styles.secondary(false).button," ui-shared__ripple-button"));expect(wrapper.find(Ripple).render().text()).toEqual('Press me');expect(wrapper).toMatchSnapshot();});it('should render as a disabled ripple button',function(){var wrapper=mount(React.createElement(RippleButton,{disabled:true},"Press me"));expect(wrapper.find(Button).props().disabled).toBe(true);expect(wrapper).toMatchSnapshot();});});
1
+ import trim from 'lodash/trim';
2
+ import React from 'react';
3
+ import { shallow, mount } from 'enzyme';
4
+ import Button from '@shopgate/pwa-common/components/Button';
5
+ import Ripple from "../Ripple";
6
+ import styles from "../Button/style";
7
+ import RippleButton from "./index";
8
+ describe('<RippleButton />', () => {
9
+ it('should render as a regular ripple button effect if type is omitted', () => {
10
+ const wrapper = shallow(/*#__PURE__*/React.createElement(RippleButton, null, "Press me"));
11
+ expect(wrapper).toMatchSnapshot();
12
+ expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
13
+ });
14
+ it('should render as a regular ripple button if type is explicitly defined', () => {
15
+ const wrapper = mount(/*#__PURE__*/React.createElement(RippleButton, {
16
+ type: "regular"
17
+ }, "Press me"));
18
+ expect(trim(wrapper.find(Button).props().className)).toEqual(`ui-shared__button ${styles.regular(false).button} ui-shared__ripple-button`);
19
+ expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
20
+ expect(wrapper).toMatchSnapshot();
21
+ });
22
+ it('should render as a primary ripple button', () => {
23
+ const wrapper = mount(/*#__PURE__*/React.createElement(RippleButton, {
24
+ type: "primary"
25
+ }, "Press me"));
26
+ expect(trim(wrapper.find(Button).props().className)).toEqual(`ui-shared__button ${styles.primary(false).button} ui-shared__ripple-button`);
27
+ expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
28
+ expect(wrapper).toMatchSnapshot();
29
+ });
30
+ it('should render as a secondary ripple button', () => {
31
+ const wrapper = mount(/*#__PURE__*/React.createElement(RippleButton, {
32
+ type: "secondary"
33
+ }, "Press me"));
34
+ expect(trim(wrapper.find(Button).props().className)).toEqual(`ui-shared__button ${styles.secondary(false).button} ui-shared__ripple-button`);
35
+ expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
36
+ expect(wrapper).toMatchSnapshot();
37
+ });
38
+ it('should render as a disabled ripple button', () => {
39
+ const wrapper = mount(/*#__PURE__*/React.createElement(RippleButton, {
40
+ disabled: true
41
+ }, "Press me"));
42
+ expect(wrapper.find(Button).props().disabled).toBe(true);
43
+ expect(wrapper).toMatchSnapshot();
44
+ });
45
+ });
@@ -1,3 +1,14 @@
1
- import React from'react';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{SCANNER_CAMERA}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';import styles from"./style";/**
1
+ import React from 'react';
2
+ import SurroundPortals from '@shopgate/pwa-common/components/SurroundPortals';
3
+ import { SCANNER_CAMERA } from '@shopgate/pwa-common-commerce/scanner/constants/Portals';
4
+ import styles from "./style";
5
+
6
+ /**
2
7
  * @returns {JSX}
3
- */var CameraOverlay=function CameraOverlay(){return React.createElement(SurroundPortals,{portalName:SCANNER_CAMERA},React.createElement("div",{className:styles},React.createElement("div",null)));};export default CameraOverlay;
8
+ */
9
+ const CameraOverlay = () => /*#__PURE__*/React.createElement(SurroundPortals, {
10
+ portalName: SCANNER_CAMERA
11
+ }, /*#__PURE__*/React.createElement("div", {
12
+ className: styles
13
+ }, /*#__PURE__*/React.createElement("div", null)));
14
+ export default CameraOverlay;
@@ -1 +1,40 @@
1
- import{css}from'glamor';import{themeVariables,themeColors}from'@shopgate/pwa-common/helpers/config';var edgeHeight=45;var edgeWidth=35;var edgeBorderWidth=3;var edgeOffsetHorizontal=themeVariables.gap.xbig;var edgeOffsetVertical=themeVariables.gap.xxbig;export default css({position:'relative',height:'90%',width:'100%',':before,:after,>:before,>:after':{display:'block',content:' ',width:edgeWidth,height:edgeHeight,position:'absolute',borderStyle:'solid',borderColor:themeColors.light},':before':{top:edgeOffsetVertical,left:edgeOffsetHorizontal,borderWidth:"".concat(edgeBorderWidth,"px 0 0 ").concat(edgeBorderWidth,"px")},':after':{top:edgeOffsetVertical,right:edgeOffsetHorizontal,borderWidth:"".concat(edgeBorderWidth,"px ").concat(edgeBorderWidth,"px 0 0")},'>:before':{bottom:edgeOffsetVertical,left:edgeOffsetHorizontal,borderWidth:"0 0 ".concat(edgeBorderWidth,"px ").concat(edgeBorderWidth,"px")},'>:after':{bottom:edgeOffsetVertical,right:edgeOffsetHorizontal,borderWidth:"0 ".concat(edgeBorderWidth,"px ").concat(edgeBorderWidth,"px 0")}}).toString();
1
+ import { css } from 'glamor';
2
+ import { themeVariables, themeColors } from '@shopgate/pwa-common/helpers/config';
3
+ const edgeHeight = 45;
4
+ const edgeWidth = 35;
5
+ const edgeBorderWidth = 3;
6
+ const edgeOffsetHorizontal = themeVariables.gap.xbig;
7
+ const edgeOffsetVertical = themeVariables.gap.xxbig;
8
+ export default css({
9
+ height: '90%',
10
+ width: '100%',
11
+ ':before,:after,>:before,>:after': {
12
+ display: 'block',
13
+ content: ' ',
14
+ width: edgeWidth,
15
+ height: edgeHeight,
16
+ position: 'absolute',
17
+ borderStyle: 'solid',
18
+ borderColor: themeColors.light
19
+ },
20
+ ':before': {
21
+ top: edgeOffsetVertical,
22
+ left: edgeOffsetHorizontal,
23
+ borderWidth: `${edgeBorderWidth}px 0 0 ${edgeBorderWidth}px`
24
+ },
25
+ ':after': {
26
+ top: edgeOffsetVertical,
27
+ right: edgeOffsetHorizontal,
28
+ borderWidth: `${edgeBorderWidth}px ${edgeBorderWidth}px 0 0`
29
+ },
30
+ '>:before': {
31
+ bottom: edgeOffsetVertical,
32
+ left: edgeOffsetHorizontal,
33
+ borderWidth: `0 0 ${edgeBorderWidth}px ${edgeBorderWidth}px`
34
+ },
35
+ '>:after': {
36
+ bottom: edgeOffsetVertical,
37
+ right: edgeOffsetHorizontal,
38
+ borderWidth: `0 ${edgeBorderWidth}px ${edgeBorderWidth}px 0`
39
+ }
40
+ }).toString();