@shopgate/pwa-ui-shared 7.29.9 → 7.30.0-alpha.11

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 +45 -5
  2. package/AccordionContainer/spec.js +34 -2
  3. package/ActionButton/index.js +84 -9
  4. package/ActionButton/spec.js +67 -2
  5. package/ActionButton/style.js +22 -1
  6. package/AddToCartButton/index.js +195 -27
  7. package/AddToCartButton/mock.js +30 -4
  8. package/AddToCartButton/spec.js +66 -2
  9. package/AddToCartButton/style.js +127 -11
  10. package/Availability/index.js +36 -2
  11. package/Availability/spec.js +42 -1
  12. package/Availability/style.js +19 -1
  13. package/Button/index.js +95 -9
  14. package/Button/spec.js +39 -1
  15. package/Button/style.js +130 -21
  16. package/ButtonLink/connector.js +11 -2
  17. package/ButtonLink/index.js +52 -6
  18. package/ButtonLink/spec.js +25 -1
  19. package/Card/index.js +21 -2
  20. package/Card/style.js +11 -1
  21. package/CardList/components/Item/index.js +28 -2
  22. package/CardList/components/Item/style.js +7 -1
  23. package/CardList/index.js +43 -3
  24. package/CartTotalLine/components/Amount/index.js +30 -2
  25. package/CartTotalLine/components/Amount/style.js +8 -1
  26. package/CartTotalLine/components/Hint/index.js +25 -2
  27. package/CartTotalLine/components/Hint/style.js +12 -1
  28. package/CartTotalLine/components/Label/index.js +38 -2
  29. package/CartTotalLine/components/Label/style.js +17 -1
  30. package/CartTotalLine/components/Spacer/index.js +18 -2
  31. package/CartTotalLine/index.js +41 -2
  32. package/CartTotalLine/style.js +31 -1
  33. package/Checkbox/index.js +32 -2
  34. package/Checkbox/style.js +18 -1
  35. package/Chip/index.js +67 -2
  36. package/Chip/spec.js +27 -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 +23 -2
  41. package/ContextMenu/components/Item/index.js +70 -5
  42. package/ContextMenu/components/Item/style.js +31 -2
  43. package/ContextMenu/components/Position/index.js +69 -10
  44. package/ContextMenu/components/Position/style.js +11 -1
  45. package/ContextMenu/index.js +134 -3
  46. package/ContextMenu/spec.js +112 -2
  47. package/ContextMenu/style.js +45 -1
  48. package/Dialog/components/BasicDialog/index.js +5 -1
  49. package/Dialog/components/HtmlContentDialog/index.js +24 -2
  50. package/Dialog/components/HtmlContentDialog/spec.js +62 -1
  51. package/Dialog/components/PipelineErrorDialog/index.js +174 -26
  52. package/Dialog/components/PipelineErrorDialog/spec.js +93 -12
  53. package/Dialog/components/TextMessageDialog/index.js +30 -2
  54. package/Dialog/components/TextMessageDialog/spec.js +62 -1
  55. package/Dialog/components/VariantSelectModal/connector.js +11 -2
  56. package/Dialog/components/VariantSelectModal/index.js +67 -6
  57. package/Dialog/components/VariantSelectModal/spec.js +54 -2
  58. package/Dialog/constants.js +6 -1
  59. package/Dialog/index.js +118 -7
  60. package/Dialog/spec.js +82 -3
  61. package/DiscountBadge/index.js +32 -2
  62. package/DiscountBadge/spec.js +20 -1
  63. package/DiscountBadge/style.js +34 -2
  64. package/FavoritesButton/connector.js +18 -3
  65. package/FavoritesButton/index.js +127 -15
  66. package/FavoritesButton/mock.js +50 -4
  67. package/FavoritesButton/spec.js +124 -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 +390 -43
  76. package/Form/Builder/classes/ActionListener/spec.js +321 -19
  77. package/Form/Builder/components/CheckboxElement.js +43 -3
  78. package/Form/Builder/components/CountryElement.js +48 -3
  79. package/Form/Builder/components/ProvinceElement.js +48 -3
  80. package/Form/Builder/components/RadioElement.js +49 -3
  81. package/Form/Builder/components/SelectElement.js +49 -3
  82. package/Form/Builder/components/TextElement.js +57 -4
  83. package/Form/Builder/elementTypes.js +11 -1
  84. package/Form/Builder/index.js +308 -52
  85. package/Form/Builder/iso-3166-2.js +4943 -1
  86. package/Form/Builder/spec.js +309 -16
  87. package/Form/Checkbox/index.js +76 -4
  88. package/Form/Checkbox/style.js +25 -2
  89. package/Form/InfoField/index.js +57 -2
  90. package/Form/InfoField/spec.js +12 -1
  91. package/Form/InfoField/style.js +11 -1
  92. package/Form/Password/index.js +58 -6
  93. package/Form/Password/spec.js +39 -1
  94. package/Form/Password/style.js +11 -1
  95. package/Form/RadioGroup/components/Item/index.js +68 -3
  96. package/Form/RadioGroup/components/Item/style.js +32 -2
  97. package/Form/RadioGroup/index.js +110 -9
  98. package/Form/RadioGroup/spec.js +97 -3
  99. package/Form/RadioGroup/style.js +18 -2
  100. package/Form/Select/index.js +167 -10
  101. package/Form/Select/spec.js +39 -5
  102. package/Form/Select/style.js +27 -1
  103. package/Form/SelectContextChoices/index.js +81 -3
  104. package/Form/SelectContextChoices/spec.js +36 -4
  105. package/Form/SelectContextChoices/style.js +23 -1
  106. package/Form/TextField/index.js +105 -8
  107. package/Form/TextField/spec.js +123 -1
  108. package/Form/TextField/style.js +66 -8
  109. package/Form/index.js +62 -13
  110. package/FormElement/components/ErrorText/index.js +33 -2
  111. package/FormElement/components/ErrorText/style.js +13 -1
  112. package/FormElement/components/Label/index.js +37 -2
  113. package/FormElement/components/Label/style.js +76 -8
  114. package/FormElement/components/Placeholder/index.js +28 -2
  115. package/FormElement/components/Placeholder/style.js +48 -6
  116. package/FormElement/components/Underline/index.js +20 -2
  117. package/FormElement/components/Underline/style.js +51 -4
  118. package/FormElement/index.js +110 -9
  119. package/FormElement/spec.js +68 -2
  120. package/FormElement/style.js +13 -2
  121. package/Glow/index.js +98 -7
  122. package/Glow/spec.js +14 -1
  123. package/Glow/style.js +18 -1
  124. package/IndicatorCircle/index.js +34 -2
  125. package/IndicatorCircle/spec.js +29 -1
  126. package/IndicatorCircle/style.js +57 -3
  127. package/LoadingIndicator/index.js +31 -2
  128. package/LoadingIndicator/style.js +20 -1
  129. package/Manufacturer/index.js +22 -2
  130. package/Manufacturer/style.js +5 -1
  131. package/MessageBar/index.js +39 -2
  132. package/MessageBar/spec.js +80 -1
  133. package/MessageBar/style.js +38 -1
  134. package/NoResults/components/Icon/index.js +154 -2
  135. package/NoResults/components/Icon/style.js +17 -1
  136. package/NoResults/index.js +52 -2
  137. package/NoResults/style.js +31 -1
  138. package/Placeholder/index.js +33 -3
  139. package/Placeholder/style.js +11 -1
  140. package/PlaceholderLabel/index.js +28 -2
  141. package/PlaceholderLabel/spec.js +26 -1
  142. package/PlaceholderLabel/style.js +12 -1
  143. package/PlaceholderParagraph/index.js +37 -2
  144. package/PlaceholderParagraph/spec.js +26 -1
  145. package/Price/index.js +106 -7
  146. package/Price/style.js +22 -1
  147. package/PriceInfo/index.js +21 -2
  148. package/PriceInfo/style.js +5 -1
  149. package/PriceStriked/index.js +95 -12
  150. package/PriceStriked/style.js +33 -3
  151. package/ProductProperties/index.js +35 -2
  152. package/ProgressBar/index.js +110 -13
  153. package/ProgressBar/spec.js +14 -1
  154. package/ProgressBar/style.js +83 -2
  155. package/RadioButton/index.js +19 -2
  156. package/RadioButton/spec.js +22 -1
  157. package/RadioButton/style.js +21 -1
  158. package/RatingNumber/index.js +30 -2
  159. package/RatingStars/constants.js +2 -1
  160. package/RatingStars/index.js +146 -12
  161. package/RatingStars/spec.js +91 -3
  162. package/RatingStars/style.js +51 -2
  163. package/Ripple/components/RippleAnimation/index.js +103 -6
  164. package/Ripple/index.js +231 -43
  165. package/Ripple/style.js +18 -1
  166. package/RippleButton/index.js +71 -7
  167. package/RippleButton/spec.js +52 -1
  168. package/ScannerOverlay/components/CameraOverlay/index.js +16 -2
  169. package/ScannerOverlay/components/CameraOverlay/style.js +40 -1
  170. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +38 -2
  171. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +28 -1
  172. package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +13 -2
  173. package/ScannerOverlay/components/ScannerBar/index.js +36 -2
  174. package/ScannerOverlay/components/ScannerBar/style.js +20 -1
  175. package/ScannerOverlay/index.js +56 -7
  176. package/Sheet/components/Header/components/SearchBar/index.js +53 -2
  177. package/Sheet/components/Header/components/SearchBar/spec.js +22 -3
  178. package/Sheet/components/Header/components/SearchBar/style.js +47 -1
  179. package/Sheet/components/Header/index.js +88 -7
  180. package/Sheet/components/Header/spec.js +15 -1
  181. package/Sheet/components/Header/style.js +50 -1
  182. package/Sheet/index.js +187 -19
  183. package/Sheet/spec.js +98 -5
  184. package/Sheet/style.js +143 -2
  185. package/TaxDisclaimer/index.js +37 -4
  186. package/TaxDisclaimer/spec.js +32 -3
  187. package/TaxDisclaimer/style.js +9 -1
  188. package/TextField/components/ErrorText/index.js +35 -2
  189. package/TextField/components/ErrorText/style.js +25 -3
  190. package/TextField/components/FormElement/index.js +20 -2
  191. package/TextField/components/FormElement/style.js +32 -4
  192. package/TextField/components/Hint/index.js +23 -2
  193. package/TextField/components/Hint/style.js +40 -5
  194. package/TextField/components/Label/index.js +34 -3
  195. package/TextField/components/Label/style.js +68 -8
  196. package/TextField/components/Underline/index.js +21 -2
  197. package/TextField/components/Underline/style.js +51 -4
  198. package/TextField/index.js +209 -30
  199. package/TextField/spec.js +142 -3
  200. package/TextField/style.js +34 -4
  201. package/ToggleIcon/index.js +66 -8
  202. package/ToggleIcon/spec.js +39 -1
  203. package/icons/AccountBoxIcon.js +12 -2
  204. package/icons/AddMoreIcon.js +12 -2
  205. package/icons/ArrowDropIcon.js +12 -2
  206. package/icons/ArrowIcon.js +22 -2
  207. package/icons/BarcodeScannerIcon.js +12 -2
  208. package/icons/BoxIcon.js +12 -2
  209. package/icons/BrowseIcon.js +12 -2
  210. package/icons/BurgerIcon.js +12 -2
  211. package/icons/CalendarIcon.js +15 -3
  212. package/icons/CartCouponIcon.js +73 -2
  213. package/icons/CartIcon.js +12 -2
  214. package/icons/CartPlusIcon.js +12 -2
  215. package/icons/CheckIcon.js +12 -2
  216. package/icons/CheckedIcon.js +12 -2
  217. package/icons/ChevronIcon.js +12 -2
  218. package/icons/CreditCardIcon.js +12 -2
  219. package/icons/CrossIcon.js +12 -2
  220. package/icons/DescriptionIcon.js +12 -2
  221. package/icons/FilterIcon.js +12 -2
  222. package/icons/FlashDisabledIcon.js +12 -2
  223. package/icons/FlashEnabledIcon.js +12 -2
  224. package/icons/GridIcon.js +12 -2
  225. package/icons/HeartIcon.js +12 -2
  226. package/icons/HeartOutlineIcon.js +12 -2
  227. package/icons/HeartPlusIcon.js +13 -2
  228. package/icons/HeartPlusOutlineIcon.js +13 -2
  229. package/icons/HomeIcon.js +12 -2
  230. package/icons/InfoIcon.js +12 -2
  231. package/icons/InfoOutlineIcon.js +12 -2
  232. package/icons/ListIcon.js +12 -2
  233. package/icons/LocalShippingIcon.js +12 -2
  234. package/icons/LocationIcon.js +14 -3
  235. package/icons/LocatorIcon.js +12 -2
  236. package/icons/LockIcon.js +12 -2
  237. package/icons/LogoutIcon.js +12 -2
  238. package/icons/MagnifierIcon.js +12 -2
  239. package/icons/MapMarkerIcon.js +25 -3
  240. package/icons/MoreIcon.js +12 -2
  241. package/icons/MoreVertIcon.js +12 -2
  242. package/icons/NotificationIcon.js +15 -3
  243. package/icons/PersonIcon.js +13 -2
  244. package/icons/PhoneIcon.js +14 -3
  245. package/icons/PlaceholderIcon.js +12 -2
  246. package/icons/RadioCheckedIcon.js +12 -2
  247. package/icons/RadioUncheckedIcon.js +12 -2
  248. package/icons/SecurityIcon.js +12 -2
  249. package/icons/ShippingMethodIcon.js +19 -3
  250. package/icons/ShoppingCartIcon.js +12 -2
  251. package/icons/SortIcon.js +12 -2
  252. package/icons/StarHalfIcon.js +19 -2
  253. package/icons/StarIcon.js +19 -2
  254. package/icons/StarOutlineIcon.js +12 -2
  255. package/icons/StopIcon.js +12 -2
  256. package/icons/TickIcon.js +12 -2
  257. package/icons/TimeIcon.js +15 -3
  258. package/icons/TrashIcon.js +12 -2
  259. package/icons/TrashOutlineIcon.js +13 -2
  260. package/icons/UncheckedIcon.js +12 -2
  261. package/icons/ViewListIcon.js +12 -2
  262. package/icons/VisibilityIcon.js +12 -2
  263. package/icons/VisibilityOffIcon.js +12 -2
  264. package/icons/WarningIcon.js +12 -2
  265. package/index.js +13 -1
  266. package/package.json +7 -8
@@ -1,8 +1,48 @@
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{Component}from'react';import PropTypes from'prop-types';/**
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
+ import { Component } from 'react';
3
+ import PropTypes from 'prop-types';
4
+
5
+ /**
2
6
  * The Accordion container component.
3
- */var AccordionContainer=/*#__PURE__*/function(_Component){function AccordionContainer(props){var _this2;_classCallCheck(this,AccordionContainer);_this2=_callSuper(this,AccordionContainer,[props]);_defineProperty(_this2,"open",function(){_this2.setState({open:true});});_defineProperty(_this2,"close",function(){_this2.setState({open:false});});_this2.state={open:props.open};return _this2;}_inherits(AccordionContainer,_Component);return _createClass(AccordionContainer,[{key:"render",value:/**
4
- * @returns {JSX}
5
- */function render(){return this.props.children({handleClose:this.close,open:this.state.open,handleOpen:this.open});}}]);}(Component);_defineProperty(AccordionContainer,"defaultProps",{open:false/**
7
+ */
8
+ let AccordionContainer = /*#__PURE__*/function (_Component) {
9
+ /**
6
10
  * Init
7
11
  * @param {Object} props Props
8
- */});export default AccordionContainer;
12
+ */
13
+ function AccordionContainer(props) {
14
+ var _this;
15
+ _this = _Component.call(this, props) || this;
16
+ _this.open = () => {
17
+ _this.setState({
18
+ open: true
19
+ });
20
+ };
21
+ _this.close = () => {
22
+ _this.setState({
23
+ open: false
24
+ });
25
+ };
26
+ _this.state = {
27
+ open: props.open
28
+ };
29
+ return _this;
30
+ }
31
+ _inheritsLoose(AccordionContainer, _Component);
32
+ var _proto = AccordionContainer.prototype;
33
+ /**
34
+ * @returns {JSX}
35
+ */
36
+ _proto.render = function render() {
37
+ return this.props.children({
38
+ handleClose: this.close,
39
+ open: this.state.open,
40
+ handleOpen: this.open
41
+ });
42
+ };
43
+ return AccordionContainer;
44
+ }(Component);
45
+ AccordionContainer.defaultProps = {
46
+ open: false
47
+ };
48
+ export default AccordionContainer;
@@ -1,3 +1,35 @@
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);}import React from'react';import{shallow}from'enzyme';import AccordionContainer from"./index";/**
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import AccordionContainer from "./index";
4
+
5
+ /**
2
6
  * @returns {JSX}
3
- */var Child=function Child(){return React.createElement("div",null);};describe('<AccordionContainer />',function(){it('should render children with props',function(){var wrapper=shallow(React.createElement(AccordionContainer,null,function(props){return React.createElement(Child,props);}));var props=wrapper.find('Child').props();expect(wrapper).toMatchSnapshot();expect(props.open).toEqual(false);expect(_typeof(props.handleOpen)).toEqual('function');expect(_typeof(props.handleClose)).toEqual('function');});it('should update children props when state changes',function(){var wrapper=shallow(React.createElement(AccordionContainer,null,function(props){return React.createElement(Child,props);}));wrapper.setState({open:true});expect(wrapper).toMatchSnapshot();expect(wrapper.find('Child').props().open).toEqual(true);});});
7
+ */
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const Child = () => /*#__PURE__*/_jsx("div", {});
10
+ describe('<AccordionContainer />', () => {
11
+ it('should render children with props', () => {
12
+ const wrapper = shallow(/*#__PURE__*/_jsx(AccordionContainer, {
13
+ children: props => /*#__PURE__*/_jsx(Child, {
14
+ ...props
15
+ })
16
+ }));
17
+ const props = wrapper.find('Child').props();
18
+ expect(wrapper).toMatchSnapshot();
19
+ expect(props.open).toEqual(false);
20
+ expect(typeof props.handleOpen).toEqual('function');
21
+ expect(typeof props.handleClose).toEqual('function');
22
+ });
23
+ it('should update children props when state changes', () => {
24
+ const wrapper = shallow(/*#__PURE__*/_jsx(AccordionContainer, {
25
+ children: props => /*#__PURE__*/_jsx(Child, {
26
+ ...props
27
+ })
28
+ }));
29
+ wrapper.setState({
30
+ open: true
31
+ });
32
+ expect(wrapper).toMatchSnapshot();
33
+ expect(wrapper.find('Child').props().open).toEqual(true);
34
+ });
35
+ });
@@ -1,12 +1,87 @@
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 IndicatorCircle from"../IndicatorCircle";import RippleButton from"../RippleButton";import styles from"./style";/**
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
3
+ import React, { Component } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import IndicatorCircle from "../IndicatorCircle";
6
+ import RippleButton from "../RippleButton";
7
+ import styles from "./style";
8
+
9
+ /**
2
10
  * The action button component.
3
- */var ActionButton=/*#__PURE__*/function(_Component){function ActionButton(){var _this2;_classCallCheck(this,ActionButton);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,ActionButton,[].concat(args));/**
4
- * The click handler
5
- * @param {Object} event The event object for the click handler
6
- */_defineProperty(_this2,"handleClick",function(event){var clickDelay=_this2.constructor.clickDelay;if(_this2.props.disableClickDelay){_this2.props.onClick(event);return;}setTimeout(function(){_this2.props.onClick(event);},clickDelay);});return _this2;}_inherits(ActionButton,_Component);return _createClass(ActionButton,[{key:"buttonProps",get:/**
7
- * Getter for the calculated button props.
8
- * @returns {Object}
9
- */function get(){var buttonProps={className:this.props.className,disabled:this.props.disabled,flat:this.props.flat,type:this.props.type};return buttonProps;}},{key:"render",value:/**
11
+ */
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let ActionButton = /*#__PURE__*/function (_Component) {
14
+ function ActionButton(...args) {
15
+ var _this;
16
+ _this = _Component.call.apply(_Component, [this].concat(args)) || this;
17
+ /**
18
+ * The click handler
19
+ * @param {Object} event The event object for the click handler
20
+ */
21
+ _this.handleClick = event => {
22
+ const {
23
+ clickDelay
24
+ } = _this.constructor;
25
+ if (_this.props.disableClickDelay) {
26
+ _this.props.onClick(event);
27
+ return;
28
+ }
29
+ setTimeout(() => {
30
+ _this.props.onClick(event);
31
+ }, clickDelay);
32
+ };
33
+ return _this;
34
+ }
35
+ _inheritsLoose(ActionButton, _Component);
36
+ var _proto = ActionButton.prototype;
37
+ /**
10
38
  * The render function.
11
39
  * @returns {JSX}
12
- */function render(){var containerClass=this.props.noGap?styles.noGapContainer:styles.container;if(this.props.loading){return React.createElement("div",{className:styles.containerCircle},React.createElement(IndicatorCircle,null));}return React.createElement("div",{className:"ui-shared__action-button ".concat(containerClass),"data-test-id":this.props.testId},React.createElement(RippleButton,_extends({},this.buttonProps,{onClick:this.handleClick}),this.props.children));}}]);}(Component);_defineProperty(ActionButton,"clickDelay",300);_defineProperty(ActionButton,"defaultProps",_extends({},RippleButton.defaultProps,{loading:false,type:'primary',flat:true,noGap:false,testId:null,disableClickDelay:false}));export default ActionButton;
40
+ */
41
+ _proto.render = function render() {
42
+ const containerClass = this.props.noGap ? styles.noGapContainer : styles.container;
43
+ if (this.props.loading) {
44
+ return /*#__PURE__*/_jsx("div", {
45
+ className: styles.containerCircle,
46
+ children: /*#__PURE__*/_jsx(IndicatorCircle, {})
47
+ });
48
+ }
49
+ return /*#__PURE__*/_jsx("div", {
50
+ className: `ui-shared__action-button ${containerClass}`,
51
+ "data-test-id": this.props.testId,
52
+ children: /*#__PURE__*/_jsx(RippleButton, {
53
+ ...this.buttonProps,
54
+ onClick: this.handleClick,
55
+ children: this.props.children
56
+ })
57
+ });
58
+ };
59
+ return _createClass(ActionButton, [{
60
+ key: "buttonProps",
61
+ get:
62
+ /**
63
+ * Getter for the calculated button props.
64
+ * @returns {Object}
65
+ */
66
+ function () {
67
+ const buttonProps = {
68
+ className: this.props.className,
69
+ disabled: this.props.disabled,
70
+ flat: this.props.flat,
71
+ type: this.props.type
72
+ };
73
+ return buttonProps;
74
+ }
75
+ }]);
76
+ }(Component);
77
+ ActionButton.clickDelay = 300;
78
+ ActionButton.defaultProps = {
79
+ ...RippleButton.defaultProps,
80
+ loading: false,
81
+ type: 'primary',
82
+ flat: true,
83
+ noGap: false,
84
+ testId: null,
85
+ disableClickDelay: false
86
+ };
87
+ export default ActionButton;
@@ -1,4 +1,69 @@
1
- import React from'react';import{shallow}from'enzyme';import IndicatorCircle from"../IndicatorCircle";import RippleButton from"../RippleButton";import ActionButton from"./index";describe('<ActionButton />',function(){var renderedElement;var mockOnClick;jest.useFakeTimers();/**
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import IndicatorCircle from "../IndicatorCircle";
4
+ import RippleButton from "../RippleButton";
5
+ import ActionButton from "./index";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ describe('<ActionButton />', () => {
8
+ let renderedElement;
9
+ let mockOnClick;
10
+ jest.useFakeTimers();
11
+
12
+ /**
2
13
  * Renders the component.
3
14
  * @param {Object} props The component props.
4
- */var renderComponent=function renderComponent(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};renderedElement=shallow(React.createElement(ActionButton,props,"Action Button"));};describe('Given the component was mounted to the DOM',function(){beforeEach(function(){mockOnClick=jest.fn();renderComponent({onClick:mockOnClick});});it('should match snapshot',function(){expect(renderedElement).toMatchSnapshot();});it('should not show the loading indicator by default',function(){var indicator=renderedElement.find(IndicatorCircle);expect(indicator.length).toBe(0);});describe('Given the loading prop is set to true',function(){beforeEach(function(){renderedElement.setProps({loading:true});});it('should match snapshot',function(){expect(renderedElement).toMatchSnapshot();});it('should show the loading indicator',function(){var indicator=renderedElement.find(IndicatorCircle);expect(indicator.length).toBe(1);});});describe('Given the component gets clicked',function(){beforeEach(function(){renderedElement.find(RippleButton).simulate('click');});it('should use setTimeout for delaying the onClick handler',function(){expect(setTimeout.mock.calls.length).toBe(1);expect(setTimeout.mock.calls[0][1]).toBe(ActionButton.clickDelay);});it('should eventually call the onClick handler',function(){jest.runOnlyPendingTimers();expect(mockOnClick).toBeCalled();expect(mockOnClick.mock.calls.length).toBe(1);});});});});
15
+ */
16
+ const renderComponent = (props = {}) => {
17
+ renderedElement = shallow(/*#__PURE__*/_jsx(ActionButton, {
18
+ ...props,
19
+ children: "Action Button"
20
+ }));
21
+ };
22
+ describe('Given the component was mounted to the DOM', () => {
23
+ beforeEach(() => {
24
+ mockOnClick = jest.fn();
25
+ renderComponent({
26
+ onClick: mockOnClick
27
+ });
28
+ });
29
+ it('should match snapshot', () => {
30
+ expect(renderedElement).toMatchSnapshot();
31
+ });
32
+ it('should not show the loading indicator by default', () => {
33
+ const indicator = renderedElement.find(IndicatorCircle);
34
+ expect(indicator.length).toBe(0);
35
+ });
36
+ describe('Given the loading prop is set to true', () => {
37
+ beforeEach(() => {
38
+ renderedElement.setProps({
39
+ loading: true
40
+ });
41
+ });
42
+ it('should match snapshot', () => {
43
+ expect(renderedElement).toMatchSnapshot();
44
+ });
45
+ it('should show the loading indicator', () => {
46
+ const indicator = renderedElement.find(IndicatorCircle);
47
+ expect(indicator.length).toBe(1);
48
+ });
49
+ });
50
+ describe('Given the component gets clicked', () => {
51
+ let timeoutSpy;
52
+ beforeEach(() => {
53
+ timeoutSpy = jest.spyOn(global, 'setTimeout');
54
+ renderedElement.find(RippleButton).simulate('click');
55
+ });
56
+ afterEach(() => {
57
+ timeoutSpy.mockRestore();
58
+ });
59
+ it('should use setTimeout for delaying the onClick handler', () => {
60
+ expect(timeoutSpy).toHaveBeenCalledTimes(1);
61
+ expect(timeoutSpy.mock.calls[0][1]).toBe(ActionButton.clickDelay);
62
+ });
63
+ it('should eventually call the onClick handler', () => {
64
+ jest.runOnlyPendingTimers();
65
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
66
+ });
67
+ });
68
+ });
69
+ });
@@ -1 +1,22 @@
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{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var halfGapBig=themeConfig.variables.gap.big/2;var containerBase={textAlign:'center'};var container=css(_extends({},containerBase,{margin:"".concat(halfGapBig,"px 0")})).toString();var noGapContainer=css(_extends({},containerBase)).toString();var containerCircle=css(_extends({},containerBase,{margin:"".concat(halfGapBig+5,"px 0")})).toString();export default{container:container,containerCircle:containerCircle,noGapContainer:noGapContainer};
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ const halfGapBig = themeConfig.variables.gap.big / 2;
4
+ const containerBase = {
5
+ textAlign: 'center'
6
+ };
7
+ const container = css({
8
+ ...containerBase,
9
+ margin: `${halfGapBig}px 0`
10
+ }).toString();
11
+ const noGapContainer = css({
12
+ ...containerBase
13
+ }).toString();
14
+ const containerCircle = css({
15
+ ...containerBase,
16
+ margin: `${halfGapBig + 5}px 0`
17
+ }).toString();
18
+ export default {
19
+ container,
20
+ containerCircle,
21
+ noGapContainer
22
+ };
@@ -1,44 +1,212 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";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 asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}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{themeConfig}from'@shopgate/pwa-common/helpers/config';import{withForwardedRef}from'@shopgate/engage/core';import CartPlusIcon from"../icons/CartPlusIcon";import TickIcon from"../icons/TickIcon";import IndicatorCircle from"../IndicatorCircle";import styles from"./style";/**
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
+ import React, { Component } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
+ import { withForwardedRef } from '@shopgate/engage/core';
6
+ import CartPlusIcon from "../icons/CartPlusIcon";
7
+ import TickIcon from "../icons/TickIcon";
8
+ import IndicatorCircle from "../IndicatorCircle";
9
+ import styles from "./style";
10
+
11
+ /**
2
12
  * AddToCartButton component.
3
- */var AddToCartButton=/*#__PURE__*/function(_Component){/**
13
+ */
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ let AddToCartButton = /*#__PURE__*/function (_Component) {
16
+ /**
4
17
  * Constructor for the AddToCartButton component.
5
18
  * @param {Object} props Props for the component.
6
- */function AddToCartButton(props){var _this2;_classCallCheck(this,AddToCartButton);_this2=_callSuper(this,AddToCartButton,[props]);/**
7
- * Handles the button click.
8
- * - Show checkmark.
9
- * - Add to cart.
10
- * - Wait 900ms.
11
- * - Show cart icon again.
12
- * @param {Event} e Event
13
- */_defineProperty(_this2,"handleClick",function(e){// Ignore clicks when check mark or loading spinner is shown or the button is disabled.
14
- if(_this2.state.showCheckmark||_this2.props.isLoading||_this2.props.isDisabled){return;}/** */var handleCompletion=function handleCompletion(){_this2.setState({showCheckmark:true});setTimeout(function(){_this2.setState({showCheckmark:false});},900);};var result=_this2.props.onClick(e);if(result===false){// Do not trigger animation when adding to cart was aborted by the parent component (PWA-2764)
15
- return;}if(result instanceof Promise){_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return result;case 3:handleCompletion();_context.next=8;break;case 6:_context.prev=6;_context.t0=_context["catch"](0);case 8:case"end":return _context.stop();}},_callee,null,[[0,6]]);}))();return;}handleCompletion();});/**
16
- * Handles the cart animation end event.
17
- * Resets the showCheckmark state to null in order to
18
- * prevent the icon from animating after changing visibility
19
- * of the view.
20
- * This is caused by CSS animations that get re-applied when
21
- * setting an element from hidden (display: none) to visible.
22
- */_defineProperty(_this2,"handleCartAnimationEnd",function(){if(_this2.state.showCheckmark===false){_this2.setState({showCheckmark:null});}_this2.props.onReset();});_this2.state={showCheckmark:null};return _this2;}_inherits(AddToCartButton,_Component);return _createClass(AddToCartButton,[{key:"render",value:/**
19
+ */
20
+ function AddToCartButton(props) {
21
+ var _this;
22
+ _this = _Component.call(this, props) || this;
23
+ /**
24
+ * Handles the button click.
25
+ * - Show checkmark.
26
+ * - Add to cart.
27
+ * - Wait 900ms.
28
+ * - Show cart icon again.
29
+ * @param {Event} e Event
30
+ */
31
+ _this.handleClick = e => {
32
+ // Ignore clicks when check mark or loading spinner is shown or the button is disabled.
33
+ if (_this.state.showCheckmark || _this.props.isLoading || _this.props.isDisabled) {
34
+ return;
35
+ }
36
+
37
+ /** */
38
+ const handleCompletion = () => {
39
+ _this.setState({
40
+ showCheckmark: true
41
+ });
42
+ setTimeout(() => {
43
+ _this.setState({
44
+ showCheckmark: false
45
+ });
46
+ }, 900);
47
+ };
48
+ const result = _this.props.onClick(e);
49
+ if (result === false) {
50
+ // Do not trigger animation when adding to cart was aborted by the parent component (PWA-2764)
51
+ return;
52
+ }
53
+ if (result instanceof Promise) {
54
+ (async () => {
55
+ try {
56
+ await result;
57
+ handleCompletion();
58
+ } catch (error) {
59
+ // ignore error in button.
60
+ }
61
+ })();
62
+ return;
63
+ }
64
+ handleCompletion();
65
+ };
66
+ /**
67
+ * Handles the cart animation end event.
68
+ * Resets the showCheckmark state to null in order to
69
+ * prevent the icon from animating after changing visibility
70
+ * of the view.
71
+ * This is caused by CSS animations that get re-applied when
72
+ * setting an element from hidden (display: none) to visible.
73
+ */
74
+ _this.handleCartAnimationEnd = () => {
75
+ if (_this.state.showCheckmark === false) {
76
+ _this.setState({
77
+ showCheckmark: null
78
+ });
79
+ }
80
+ _this.props.onReset();
81
+ };
82
+ _this.state = {
83
+ showCheckmark: null
84
+ };
85
+ return _this;
86
+ }
87
+ _inheritsLoose(AddToCartButton, _Component);
88
+ var _proto = AddToCartButton.prototype;
89
+ /**
23
90
  * Renders the component
24
91
  * @returns {JSX}
25
- */function render(){// Set initial base styles
26
- var buttonStyle=styles.buttonReady;var tickIconStyle=styles.icon;var cartPlusIconStyle=styles.icon;// Depending on the isLoading prop we only show the spinner or the other way around.
27
- var iconOpacity=this.props.isLoading?{opacity:0}:{opacity:1};var spinnerInlineStyle=this.props.isLoading?{opacity:1}:{opacity:0};/**
92
+ */
93
+ _proto.render = function render() {
94
+ // Set initial base styles
95
+ let buttonStyle = styles.buttonReady;
96
+ let tickIconStyle = styles.icon;
97
+ let cartPlusIconStyle = styles.icon;
98
+
99
+ // Depending on the isLoading prop we only show the spinner or the other way around.
100
+ const iconOpacity = this.props.isLoading ? {
101
+ opacity: 0
102
+ } : {
103
+ opacity: 1
104
+ };
105
+ const spinnerInlineStyle = this.props.isLoading ? {
106
+ opacity: 1
107
+ } : {
108
+ opacity: 0
109
+ };
110
+
111
+ /**
28
112
  * The initial positions for the icons:
29
113
  * Tick icon stays hidden on top, Cart icon stays visibly at the center
30
- */var tickInlineStyle=this.state.showCheckmark===null?_extends({transform:'translate3d(0, 300%, 0)'},iconOpacity):null;var cartInlineStyle=this.state.showCheckmark===null?_extends({transform:'translate3d(0, -50%, 0)'},iconOpacity):null;if(this.props.isDisabled&&!this.props.isLoading){buttonStyle=styles.buttonDisabled;}else if(this.state.showCheckmark){/**
114
+ */
115
+ let tickInlineStyle = this.state.showCheckmark === null ? {
116
+ transform: 'translate3d(0, 300%, 0)',
117
+ ...iconOpacity
118
+ } : null;
119
+ let cartInlineStyle = this.state.showCheckmark === null ? {
120
+ transform: 'translate3d(0, -50%, 0)',
121
+ ...iconOpacity
122
+ } : null;
123
+ if (this.props.isDisabled && !this.props.isLoading) {
124
+ buttonStyle = styles.buttonDisabled;
125
+ } else if (this.state.showCheckmark) {
126
+ /**
31
127
  * When checkmark should be shown, we start the spring transition
32
128
  * Tick icon springs in, and cart icon springs out.
33
- */tickIconStyle+=" ".concat(styles.springFromBottom);cartPlusIconStyle+=" ".concat(styles.springToTop);buttonStyle=styles.buttonSuccess;/**
129
+ */
130
+ tickIconStyle += ` ${styles.springFromBottom}`;
131
+ cartPlusIconStyle += ` ${styles.springToTop}`;
132
+ buttonStyle = styles.buttonSuccess;
133
+ /**
34
134
  * After the keyframe animation is done the transform values are reset
35
135
  * We add the inline style to make sure the icons stay where they are even after the animation
36
- */tickInlineStyle=_extends({transform:'translate3d(0, -50%, 0)'},iconOpacity);cartInlineStyle=_extends({transform:'translate3d(0, -300%, 0)'},iconOpacity);}else if(this.state.showCheckmark!==null){/**
136
+ */
137
+ tickInlineStyle = {
138
+ transform: 'translate3d(0, -50%, 0)',
139
+ ...iconOpacity
140
+ };
141
+ cartInlineStyle = {
142
+ transform: 'translate3d(0, -300%, 0)',
143
+ ...iconOpacity
144
+ };
145
+ } else if (this.state.showCheckmark !== null) {
146
+ /**
37
147
  * When checkmark should no longer be shown we start the spring out transition.
38
148
  * Tick icon springs out, cart icon spring in.
39
149
  * We don't want a animation when we initially go to the page therefore this only happens
40
150
  * after the user pressed the button.
41
- */tickIconStyle+=" ".concat(styles.springToBottom);cartPlusIconStyle+=" ".concat(styles.springFromTop);/**
151
+ */
152
+ tickIconStyle += ` ${styles.springToBottom}`;
153
+ cartPlusIconStyle += ` ${styles.springFromTop}`;
154
+ /**
42
155
  * After the keyframe animation is done the transform values are reset
43
156
  * We add the inline style to make sure the icons stay where they are even after the animation
44
- */cartInlineStyle=_extends({transform:'translate3d(0, -50%, 0)'},iconOpacity);tickInlineStyle=_extends({transform:'translate3d(0, -300%, 0)'},iconOpacity);}var className=styles.buttonWrapper(this.props.buttonSize,this.props.iconSize);if(this.props.noShadow){className=styles.buttonWrapperNoShadow(this.props.buttonSize,this.props.iconSize);}return React.createElement("button",{"data-test-id":"addToCartButton",className:"ui-shared__add-to-cart-button ".concat(this.props.className," ").concat(className," ").concat(buttonStyle),onClick:this.handleClick,"aria-hidden":this.props['aria-hidden'],"aria-label":this.props['aria-label'],"aria-disabled":this.props.isDisabled,ref:this.props.forwardedRef,type:"button"},this.props.isLoading&&React.createElement("div",{className:"".concat(styles.icon," ").concat(styles.spinnerIcon),style:spinnerInlineStyle},React.createElement(IndicatorCircle,{color:themeConfig.colors.primaryContrast,strokeWidth:5,paused:!this.props.isLoading})),React.createElement("div",{className:tickIconStyle,style:tickInlineStyle},React.createElement(TickIcon,null)),React.createElement("div",{className:cartPlusIconStyle,style:cartInlineStyle,onAnimationEnd:this.handleCartAnimationEnd},React.createElement(CartPlusIcon,null)));}}]);}(Component);_defineProperty(AddToCartButton,"defaultProps",{'aria-hidden':false,'aria-label':null,buttonSize:styles.buttonSize,className:null,forwardedRef:null,iconSize:styles.iconSize,noShadow:false,onReset:function onReset(){}});export default withForwardedRef(AddToCartButton);
157
+ */
158
+ cartInlineStyle = {
159
+ transform: 'translate3d(0, -50%, 0)',
160
+ ...iconOpacity
161
+ };
162
+ tickInlineStyle = {
163
+ transform: 'translate3d(0, -300%, 0)',
164
+ ...iconOpacity
165
+ };
166
+ }
167
+ let className = styles.buttonWrapper(this.props.buttonSize, this.props.iconSize);
168
+ if (this.props.noShadow) {
169
+ className = styles.buttonWrapperNoShadow(this.props.buttonSize, this.props.iconSize);
170
+ }
171
+ return /*#__PURE__*/_jsxs("button", {
172
+ "data-test-id": "addToCartButton",
173
+ className: `ui-shared__add-to-cart-button ${this.props.className} ${className} ${buttonStyle}`,
174
+ onClick: this.handleClick,
175
+ "aria-hidden": this.props['aria-hidden'],
176
+ "aria-label": this.props['aria-label'],
177
+ "aria-disabled": this.props.isDisabled,
178
+ ref: this.props.forwardedRef,
179
+ type: "button",
180
+ children: [this.props.isLoading && /*#__PURE__*/_jsx("div", {
181
+ className: `${styles.icon} ${styles.spinnerIcon}`,
182
+ style: spinnerInlineStyle,
183
+ children: /*#__PURE__*/_jsx(IndicatorCircle, {
184
+ color: themeConfig.colors.primaryContrast,
185
+ strokeWidth: 5,
186
+ paused: !this.props.isLoading
187
+ })
188
+ }), /*#__PURE__*/_jsx("div", {
189
+ className: tickIconStyle,
190
+ style: tickInlineStyle,
191
+ children: /*#__PURE__*/_jsx(TickIcon, {})
192
+ }), /*#__PURE__*/_jsx("div", {
193
+ className: cartPlusIconStyle,
194
+ style: cartInlineStyle,
195
+ onAnimationEnd: this.handleCartAnimationEnd,
196
+ children: /*#__PURE__*/_jsx(CartPlusIcon, {})
197
+ })]
198
+ });
199
+ };
200
+ return AddToCartButton;
201
+ }(Component);
202
+ AddToCartButton.defaultProps = {
203
+ 'aria-hidden': false,
204
+ 'aria-label': null,
205
+ buttonSize: styles.buttonSize,
206
+ className: null,
207
+ forwardedRef: null,
208
+ iconSize: styles.iconSize,
209
+ noShadow: false,
210
+ onReset: () => {}
211
+ };
212
+ export default withForwardedRef(AddToCartButton);
@@ -1,9 +1,35 @@
1
- var _Class,_temp;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,{Component}from'react';import PropTypes from'prop-types';/**
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
+ var _Class;
3
+ import React, { Component } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ /**
2
6
  * Mocked AddToCartButton.
3
7
  * @type {MockedAddToCartButton}
4
8
  * @deprecated
5
- */ // eslint-disable-next-line react/prefer-stateless-function
6
- export var MockedAddToCartButton=(_temp=_Class=/*#__PURE__*/function(_Component){function MockedAddToCartButton(){_classCallCheck(this,MockedAddToCartButton);return _callSuper(this,MockedAddToCartButton,arguments);}_inherits(MockedAddToCartButton,_Component);return _createClass(MockedAddToCartButton,[{key:"render",value:/**
9
+ */
10
+ // eslint-disable-next-line react/prefer-stateless-function
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ export const MockedAddToCartButton = (_Class = /*#__PURE__*/function (_Component) {
13
+ function MockedAddToCartButton() {
14
+ return _Component.apply(this, arguments) || this;
15
+ }
16
+ _inheritsLoose(MockedAddToCartButton, _Component);
17
+ var _proto = MockedAddToCartButton.prototype;
18
+ /**
7
19
  * Renders mocked button.
8
20
  * @return {JSX}
9
- */function render(){return React.createElement("button",{onClick:this.props.onClick,type:"button"});}}]);}(Component),_defineProperty(_Class,"defaultProps",{onClick:function onClick(){}}),_temp);
21
+ */
22
+ _proto.render = function render() {
23
+ return (
24
+ /*#__PURE__*/
25
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
26
+ _jsx("button", {
27
+ onClick: this.props.onClick,
28
+ type: "button"
29
+ })
30
+ );
31
+ };
32
+ return MockedAddToCartButton;
33
+ }(Component), _Class.defaultProps = {
34
+ onClick: () => {}
35
+ }, _Class);