@shopgate/pwa-ui-shared 7.30.0-alpha.6 → 7.30.0-alpha.8

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 +59 -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 +51 -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 +300 -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 +41 -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
package/Sheet/index.js CHANGED
@@ -1,26 +1,179 @@
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 throttle from'lodash/throttle';import classNames from'classnames';import UIEvents from'@shopgate/pwa-core/emitters/ui';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import Drawer from'@shopgate/pwa-common/components/Drawer';import ProgressBar from"../ProgressBar";import Header from"./components/Header";import styles from"./style";export var SHEET_EVENTS={OPEN:'Sheet.open',CLOSE:'Sheet.close'};/**
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import throttle from 'lodash/throttle';
4
+ import classNames from 'classnames';
5
+ import UIEvents from '@shopgate/pwa-core/emitters/ui';
6
+ import Backdrop from '@shopgate/pwa-common/components/Backdrop';
7
+ import Drawer from '@shopgate/pwa-common/components/Drawer';
8
+ import ProgressBar from "../ProgressBar";
9
+ import Header from "./components/Header";
10
+ import styles from "./style";
11
+ export const SHEET_EVENTS = {
12
+ OPEN: 'Sheet.open',
13
+ CLOSE: 'Sheet.close'
14
+ };
15
+
16
+ /**
2
17
  * Sheet component.
3
- */var Sheet=/*#__PURE__*/function(_Component){/**
18
+ */
19
+ class Sheet extends Component {
20
+ /**
4
21
  * The constructor.
5
22
  * @param {Object} props The component props.
6
- */function Sheet(props){var _this2;_classCallCheck(this,Sheet);_this2=_callSuper(this,Sheet,[props]);/**
7
- * Close the Sheet.
8
- */_defineProperty(_this2,"handleScroll",throttle(function(){var scrolled=_this2.content.current.scrollTop!==0;if(_this2.state.scrolled!==scrolled){_this2.setState({scrolled:scrolled});}},10));/**
9
- * Close the Sheet.
10
- */_defineProperty(_this2,"handleClose",function(){_this2.props.onClose();_this2.setState({isOpen:false,scrolled:false});});/** The Sheet is opened */_defineProperty(_this2,"handleDidOpen",function(){UIEvents.emit(SHEET_EVENTS.OPEN);_this2.props.onDidOpen();});/** The Sheet is closed */_defineProperty(_this2,"handleDidClose",function(){UIEvents.emit(SHEET_EVENTS.CLOSE);_this2.props.onDidClose();});/**
11
- * New value from SearchBar
12
- * @param {string} value .
13
- */_defineProperty(_this2,"handleSearchInput",function(value){_this2.setState({query:value});});_this2.content=React.createRef();_this2.state={isOpen:props.isOpen,scrolled:false,query:''};return _this2;}/**
23
+ */
24
+ constructor(props) {
25
+ super(props);
26
+ /**
27
+ * Close the Sheet.
28
+ */
29
+ this.handleScroll = throttle(() => {
30
+ const scrolled = this.content.current.scrollTop !== 0;
31
+ if (this.state.scrolled !== scrolled) {
32
+ this.setState({
33
+ scrolled
34
+ });
35
+ }
36
+ }, 10);
37
+ /**
38
+ * Close the Sheet.
39
+ */
40
+ this.handleClose = () => {
41
+ this.props.onClose();
42
+ this.setState({
43
+ isOpen: false,
44
+ scrolled: false
45
+ });
46
+ };
47
+ /** The Sheet is opened */
48
+ this.handleDidOpen = () => {
49
+ UIEvents.emit(SHEET_EVENTS.OPEN);
50
+ this.props.onDidOpen();
51
+ };
52
+ /** The Sheet is closed */
53
+ this.handleDidClose = () => {
54
+ UIEvents.emit(SHEET_EVENTS.CLOSE);
55
+ this.props.onDidClose();
56
+ };
57
+ /**
58
+ * New value from SearchBar
59
+ * @param {string} value .
60
+ */
61
+ this.handleSearchInput = value => {
62
+ this.setState({
63
+ query: value
64
+ });
65
+ };
66
+ this.content = /*#__PURE__*/React.createRef();
67
+ this.state = {
68
+ isOpen: props.isOpen,
69
+ scrolled: false,
70
+ query: ''
71
+ };
72
+ }
73
+
74
+ /**
14
75
  * Change isOpen state for new incoming props.
15
76
  * @param {Object} nextProps The next component props.
16
- */_inherits(Sheet,_Component);return _createClass(Sheet,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(_ref){var isOpen=_ref.isOpen;if(this.state.isOpen!==isOpen){this.setState({isOpen:isOpen});}}},{key:"animationProps",get:/**
77
+ */
78
+ UNSAFE_componentWillReceiveProps({
79
+ isOpen
80
+ }) {
81
+ if (this.state.isOpen !== isOpen) {
82
+ this.setState({
83
+ isOpen
84
+ });
85
+ }
86
+ }
87
+ /**
17
88
  * Getter for the animation props of the Sheet.
18
89
  * @returns {Object}
19
- */function get(){return _extends({duration:this.props.duration},styles.drawerAnimation,{},this.props.animation);}},{key:"render",value:/**
90
+ */
91
+ get animationProps() {
92
+ return {
93
+ duration: this.props.duration,
94
+ ...styles.drawerAnimation,
95
+ ...this.props.animation
96
+ };
97
+ }
98
+ /**
20
99
  * Renders the component.
21
100
  * @returns {JSX}
22
- */function render(){var _this3=this;var allowClose=this.props.allowClose;var children=React.Children.map(this.props.children,function(child){return React.cloneElement(child,// Only add onClose prop to other components
23
- typeof child.type==='function'&&_this3.props.onClose!==null?{onClose:_this3.props.onClose,query:_this3.state.query}:{});});var drawerClassNames=classNames(styles.container,_defineProperty({},this.props.className,this.props.className));var contentClassNames=classNames(styles.content,_defineProperty({},styles.containerFullScreen,this.props.showSearch),_defineProperty({},this.props.contentClassName,this.props.contentClassName),_defineProperty({},styles.shadow,!this.props.backdrop));return React.createElement("section",{className:classNames('ui-shared__sheet',_defineProperty({},styles.section,this.state.isOpen))},React.createElement(Drawer,{className:drawerClassNames,isOpen:this.state.isOpen,onDidOpen:this.handleDidOpen,onDidClose:this.handleDidClose,onOpen:this.props.onOpen,onClose:this.handleClose,animation:this.animationProps},this.props.title&&React.createElement(Sheet.Header,{showSearch:this.props.showSearch,handleChange:this.handleSearchInput,onToggleClose:this.handleClose,shadow:this.state.scrolled,title:this.props.title,allowClose:allowClose}),React.createElement("div",{className:styles.progressBarContainer},React.createElement(ProgressBar,{isVisible:this.props.isLoading})),React.createElement("div",{ref:this.content,onScroll:this.handleScroll,className:contentClassNames},children)),this.props.backdrop&&React.createElement(Backdrop,{isVisible:this.state.isOpen,level:4,onClick:allowClose?this.handleClose:function(){},opacity:20}));}}]);}(Component);_defineProperty(Sheet,"Header",Header);/**
24
- * The component default props.
25
- * @type {Object}
26
- */_defineProperty(Sheet,"defaultProps",{animation:{},backdrop:true,children:null,className:null,contentClassName:null,duration:300,isOpen:false,isLoading:false,onClose:function onClose(){},onDidClose:function onDidClose(){},onDidOpen:function onDidOpen(){},onOpen:function onOpen(){},title:'',showSearch:false,allowClose:true});export default Sheet;
101
+ */
102
+ render() {
103
+ const {
104
+ allowClose
105
+ } = this.props;
106
+ const children = React.Children.map(this.props.children, child => (/*#__PURE__*/React.cloneElement(child,
107
+ // Only add onClose prop to other components
108
+ typeof child.type === 'function' && this.props.onClose !== null ? {
109
+ onClose: this.props.onClose,
110
+ query: this.state.query
111
+ } : {})));
112
+ const drawerClassNames = classNames(styles.container, {
113
+ [this.props.className]: this.props.className
114
+ });
115
+ const contentClassNames = classNames(styles.content, {
116
+ [styles.containerFullScreen]: this.props.showSearch
117
+ }, {
118
+ [this.props.contentClassName]: this.props.contentClassName
119
+ }, {
120
+ [styles.shadow]: !this.props.backdrop
121
+ });
122
+ return /*#__PURE__*/React.createElement("section", {
123
+ className: classNames('ui-shared__sheet', {
124
+ [styles.section]: this.state.isOpen
125
+ })
126
+ }, /*#__PURE__*/React.createElement(Drawer, {
127
+ className: drawerClassNames,
128
+ isOpen: this.state.isOpen,
129
+ onDidOpen: this.handleDidOpen,
130
+ onDidClose: this.handleDidClose,
131
+ onOpen: this.props.onOpen,
132
+ onClose: this.handleClose,
133
+ animation: this.animationProps
134
+ }, this.props.title && /*#__PURE__*/React.createElement(Sheet.Header, {
135
+ showSearch: this.props.showSearch,
136
+ handleChange: this.handleSearchInput,
137
+ onToggleClose: this.handleClose,
138
+ shadow: this.state.scrolled,
139
+ title: this.props.title,
140
+ allowClose: allowClose
141
+ }), /*#__PURE__*/React.createElement("div", {
142
+ className: styles.progressBarContainer
143
+ }, /*#__PURE__*/React.createElement(ProgressBar, {
144
+ isVisible: this.props.isLoading
145
+ })), /*#__PURE__*/React.createElement("div", {
146
+ ref: this.content,
147
+ onScroll: this.handleScroll,
148
+ className: contentClassNames
149
+ }, children)), this.props.backdrop && /*#__PURE__*/React.createElement(Backdrop, {
150
+ isVisible: this.state.isOpen,
151
+ level: 4,
152
+ onClick: allowClose ? this.handleClose : () => {},
153
+ opacity: 20
154
+ }));
155
+ }
156
+ }
157
+ Sheet.Header = Header;
158
+ /**
159
+ * The component default props.
160
+ * @type {Object}
161
+ */
162
+ Sheet.defaultProps = {
163
+ animation: {},
164
+ backdrop: true,
165
+ children: null,
166
+ className: null,
167
+ contentClassName: null,
168
+ duration: 300,
169
+ isOpen: false,
170
+ isLoading: false,
171
+ onClose: () => {},
172
+ onDidClose: () => {},
173
+ onDidOpen: () => {},
174
+ onOpen: () => {},
175
+ title: '',
176
+ showSearch: false,
177
+ allowClose: true
178
+ };
179
+ export default Sheet;
package/Sheet/spec.js CHANGED
@@ -1,5 +1,85 @@
1
- import React from'react';import{shallow,mount}from'enzyme';import mockRenderOptions from'@shopgate/pwa-common/helpers/mocks/mockRenderOptions';import UIEvents from'@shopgate/pwa-core/emitters/ui';import Sheet,{SHEET_EVENTS}from"./index";window.requestAnimationFrame=function(){};jest.mock('@shopgate/pwa-core/emitters/ui',function(){return{emit:jest.fn()};});jest.mock('@shopgate/engage/a11y/components');describe('<Sheet />',function(){it('should render closed without content',function(){var wrapper=shallow(React.createElement(Sheet,null));expect(wrapper).toMatchSnapshot();});it('should render opened without content',function(){var wrapper=shallow(React.createElement(Sheet,{isOpen:true}));expect(wrapper).toMatchSnapshot();});it('should render with content and title',function(){var wrapper=shallow(React.createElement(Sheet,{isOpen:true,title:"Test-Title"},React.createElement("div",null,"Test")));expect(wrapper).toMatchSnapshot();});it('should call onDidOpen callback when the Sheet was opened',function(){var onOpen=jest.fn();var onDidOpen=jest.fn();var wrapper=mount(React.createElement(Sheet,{isOpen:false,onOpen:onOpen,onDidOpen:onDidOpen},React.createElement("div",null,"Test")),mockRenderOptions);expect(onOpen).not.toHaveBeenCalled();expect(onDidOpen).not.toHaveBeenCalled();wrapper.setProps({isOpen:true});expect(onOpen).toHaveBeenCalled();wrapper.find('Drawer').simulate('animationEnd');expect(onDidOpen).toHaveBeenCalled();expect(UIEvents.emit).nthCalledWith(1,SHEET_EVENTS.OPEN);});it('should trigger onClose callback and close the Sheet',function(){var onCloseSpy=jest.fn();var wrapper=mount(React.createElement(Sheet,{isOpen:true,title:"Test-Title",onClose:onCloseSpy},React.createElement("div",null,"Test")),mockRenderOptions);// Trigger a click on the close button of the Sheet.
2
- wrapper.find('button').first().simulate('click');return new Promise(function(resolve){// Wait until the drawer is closed and has updated it's state.
3
- setTimeout(function(){resolve();},wrapper.find('Drawer').prop('animation').duration);}).then(function(){// Check if onClose callback was called.
4
- expect(onCloseSpy).toHaveBeenCalled();// Check if the Drawer component was closed.
5
- expect(wrapper.find('Drawer').prop('isOpen')).not.toBeTruthy();expect(wrapper).toMatchSnapshot();wrapper.find('Drawer').simulate('animationEnd');expect(UIEvents.emit).nthCalledWith(2,SHEET_EVENTS.CLOSE);});});it('should open',function(){var wrapper=mount(React.createElement(Sheet,{isOpen:false,title:"Test-Title"},React.createElement("div",null,"Test")),mockRenderOptions);wrapper.setProps({isOpen:true});wrapper.update();expect(wrapper.find('Drawer').prop('isOpen')).toBeTruthy();expect(wrapper).toMatchSnapshot();});});
1
+ import React from 'react';
2
+ import { shallow, mount } from 'enzyme';
3
+ import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
4
+ import UIEvents from '@shopgate/pwa-core/emitters/ui';
5
+ import Sheet, { SHEET_EVENTS } from "./index";
6
+ window.requestAnimationFrame = () => {};
7
+ jest.mock('@shopgate/pwa-core/emitters/ui', () => ({
8
+ emit: jest.fn()
9
+ }));
10
+ jest.mock('@shopgate/engage/a11y/components');
11
+ describe('<Sheet />', () => {
12
+ it('should render closed without content', () => {
13
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Sheet, null));
14
+ expect(wrapper).toMatchSnapshot();
15
+ });
16
+ it('should render opened without content', () => {
17
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Sheet, {
18
+ isOpen: true
19
+ }));
20
+ expect(wrapper).toMatchSnapshot();
21
+ });
22
+ it('should render with content and title', () => {
23
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Sheet, {
24
+ isOpen: true,
25
+ title: "Test-Title"
26
+ }, /*#__PURE__*/React.createElement("div", null, "Test")));
27
+ expect(wrapper).toMatchSnapshot();
28
+ });
29
+ it('should call onDidOpen callback when the Sheet was opened', () => {
30
+ const onOpen = jest.fn();
31
+ const onDidOpen = jest.fn();
32
+ const wrapper = mount(/*#__PURE__*/React.createElement(Sheet, {
33
+ isOpen: false,
34
+ onOpen: onOpen,
35
+ onDidOpen: onDidOpen
36
+ }, /*#__PURE__*/React.createElement("div", null, "Test")), mockRenderOptions);
37
+ expect(onOpen).not.toHaveBeenCalled();
38
+ expect(onDidOpen).not.toHaveBeenCalled();
39
+ wrapper.setProps({
40
+ isOpen: true
41
+ });
42
+ expect(onOpen).toHaveBeenCalled();
43
+ wrapper.find('Drawer').simulate('animationEnd');
44
+ expect(onDidOpen).toHaveBeenCalled();
45
+ expect(UIEvents.emit).nthCalledWith(1, SHEET_EVENTS.OPEN);
46
+ });
47
+ it('should trigger onClose callback and close the Sheet', () => {
48
+ const onCloseSpy = jest.fn();
49
+ const wrapper = mount(/*#__PURE__*/React.createElement(Sheet, {
50
+ isOpen: true,
51
+ title: "Test-Title",
52
+ onClose: onCloseSpy
53
+ }, /*#__PURE__*/React.createElement("div", null, "Test")), mockRenderOptions);
54
+
55
+ // Trigger a click on the close button of the Sheet.
56
+ wrapper.find('button').first().simulate('click');
57
+ return new Promise(resolve => {
58
+ // Wait until the drawer is closed and has updated it's state.
59
+ setTimeout(() => {
60
+ resolve();
61
+ }, wrapper.find('Drawer').prop('animation').duration);
62
+ }).then(() => {
63
+ // Check if onClose callback was called.
64
+ expect(onCloseSpy).toHaveBeenCalled();
65
+
66
+ // Check if the Drawer component was closed.
67
+ expect(wrapper.find('Drawer').prop('isOpen')).not.toBeTruthy();
68
+ expect(wrapper).toMatchSnapshot();
69
+ wrapper.find('Drawer').simulate('animationEnd');
70
+ expect(UIEvents.emit).nthCalledWith(2, SHEET_EVENTS.CLOSE);
71
+ });
72
+ });
73
+ it('should open', () => {
74
+ const wrapper = mount(/*#__PURE__*/React.createElement(Sheet, {
75
+ isOpen: false,
76
+ title: "Test-Title"
77
+ }, /*#__PURE__*/React.createElement("div", null, "Test")), mockRenderOptions);
78
+ wrapper.setProps({
79
+ isOpen: true
80
+ });
81
+ wrapper.update();
82
+ expect(wrapper.find('Drawer').prop('isOpen')).toBeTruthy();
83
+ expect(wrapper).toMatchSnapshot();
84
+ });
85
+ });
package/Sheet/style.js CHANGED
@@ -1,2 +1,143 @@
1
- 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{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{responsiveMediaQuery}from'@shopgate/engage/styles';var duration=300;var easing='cubic-bezier(0.25, 0.1, 0.25, 1)';var section=css(_defineProperty({},responsiveMediaQuery('>sm',{webOnly:true}),{display:'flex',justifyContent:'center',alignItems:'center',width:'80%',position:'fixed',left:0,right:0,top:0,bottom:0,margin:'auto',zIndex:100})).toString();var container=css(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({bottom:0,background:themeConfig.colors.light,width:'100vw'},responsiveMediaQuery('<xl',{appOnly:true}),{// Max width was introduced in PWA6 CCP-2496
2
- maxWidth:640}),"left",0),"right",0),"margin",'0 auto'),"color","var(--color-text-high-emphasis, ".concat(themeConfig.colors.dark,")")),responsiveMediaQuery('>sm',{webOnly:true}),{position:'initial'}),responsiveMediaQuery('>md',{webOnly:true}),{width:'60%'})).toString();var containerFullScreen=css({height:["calc(100vh - ".concat(themeConfig.variables.navigator.height,"px - 51px)"),"calc(100vh - ".concat(themeConfig.variables.navigator.height,"px - 51px - var(--safe-area-inset-top))")]});var searchBarWrapper=css({backgroundColor:'white',height:52,position:'sticky',width:'100%',top:0,zIndex:2});var progressBarContainer=css({position:'relative'}).toString();var shadow=css({boxShadow:themeConfig.shadows.sheet}).toString();var content=css(_defineProperty(_defineProperty(_defineProperty(_defineProperty({maxHeight:["calc(var(--vh-100, 100vh) - ".concat(themeConfig.variables.navigator.height,"px)"),"calc(var(--vh-100, 100vh) - ".concat(themeConfig.variables.navigator.height,"px - var(--safe-area-inset-top))")]},responsiveMediaQuery('>sm',{webOnly:true}),{maxHeight:["calc(var(--vh-80, 80vh) - ".concat(themeConfig.variables.navigator.height,"px)"),"calc(var(--vh-80, 80vh) - ".concat(themeConfig.variables.navigator.height,"px - var(--safe-area-inset-top))")]}),"paddingBottom",['var(--safe-area-inset-bottom)']),"overflowY",'scroll'),"WebkitOverflowScrolling",'touch')).toString();var slideInSheetDrawer=css.keyframes({'0%':{transform:'translateY(100%)'},'100%':{transform:'translateY(0)'}});var fadeInSheetDrawer=css.keyframes({'0%':{opacity:0},'100%':{opacity:1}});var slideOutSheetDrawer=css.keyframes({'0%':{transform:'translateY(0)'},'100%':{transform:'translateY(100%)'}});var fadeOutSheetDrawer=css.keyframes({'0%':{opacity:1},'100%':{opacity:0}});var drawerAnimation={"in":css(_defineProperty(_defineProperty({},responsiveMediaQuery('<=sm',{appAlways:true}),{animation:"".concat(slideInSheetDrawer," ").concat(duration,"ms 1 both ").concat(easing)}),responsiveMediaQuery('>sm',{webOnly:true}),{animation:"".concat(fadeInSheetDrawer," ").concat(duration,"ms 1 both ").concat(easing)})).toString(),out:css(_defineProperty(_defineProperty({},responsiveMediaQuery('<=sm',{appAlways:true}),{animation:"".concat(slideOutSheetDrawer," ").concat(duration,"ms 1 both ").concat(easing)}),responsiveMediaQuery('>sm',{webOnly:true}),{animation:"".concat(fadeOutSheetDrawer," ").concat(duration,"ms 1 both ").concat(easing)})).toString()};export default{section:section,container:container,containerFullScreen:containerFullScreen,searchBarWrapper:searchBarWrapper,progressBarContainer:progressBarContainer,shadow:shadow,content:content,drawerAnimation:drawerAnimation};
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ import { responsiveMediaQuery } from '@shopgate/engage/styles';
4
+ const duration = 300;
5
+ const easing = 'cubic-bezier(0.25, 0.1, 0.25, 1)';
6
+ const section = css({
7
+ [responsiveMediaQuery('>sm', {
8
+ webOnly: true
9
+ })]: {
10
+ display: 'flex',
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ width: '80%',
14
+ position: 'fixed',
15
+ left: 0,
16
+ right: 0,
17
+ top: 0,
18
+ bottom: 0,
19
+ margin: 'auto',
20
+ zIndex: 100
21
+ }
22
+ }).toString();
23
+ const container = css({
24
+ bottom: 0,
25
+ background: themeConfig.colors.light,
26
+ width: '100vw',
27
+ [responsiveMediaQuery('<xl', {
28
+ appOnly: true
29
+ })]: {
30
+ // Max width was introduced in PWA6 CCP-2496
31
+ maxWidth: 640
32
+ },
33
+ left: 0,
34
+ right: 0,
35
+ margin: '0 auto',
36
+ color: `var(--color-text-high-emphasis, ${themeConfig.colors.dark})`,
37
+ [responsiveMediaQuery('>sm', {
38
+ webOnly: true
39
+ })]: {
40
+ position: 'initial'
41
+ },
42
+ [responsiveMediaQuery('>md', {
43
+ webOnly: true
44
+ })]: {
45
+ width: '60%'
46
+ }
47
+ }).toString();
48
+ const containerFullScreen = css({
49
+ height: [`calc(100vh - ${themeConfig.variables.navigator.height}px - 51px)`, `calc(100vh - ${themeConfig.variables.navigator.height}px - 51px - var(--safe-area-inset-top))`]
50
+ });
51
+ const searchBarWrapper = css({
52
+ backgroundColor: 'white',
53
+ height: 52,
54
+ position: 'sticky',
55
+ width: '100%',
56
+ top: 0,
57
+ zIndex: 2
58
+ });
59
+ const progressBarContainer = css({
60
+ position: 'relative'
61
+ }).toString();
62
+ const shadow = css({
63
+ boxShadow: themeConfig.shadows.sheet
64
+ }).toString();
65
+ const content = css({
66
+ maxHeight: [`calc(var(--vh-100, 100vh) - ${themeConfig.variables.navigator.height}px)`, `calc(var(--vh-100, 100vh) - ${themeConfig.variables.navigator.height}px - var(--safe-area-inset-top))`],
67
+ [responsiveMediaQuery('>sm', {
68
+ webOnly: true
69
+ })]: {
70
+ maxHeight: [`calc(var(--vh-80, 80vh) - ${themeConfig.variables.navigator.height}px)`, `calc(var(--vh-80, 80vh) - ${themeConfig.variables.navigator.height}px - var(--safe-area-inset-top))`]
71
+ },
72
+ paddingBottom: ['var(--safe-area-inset-bottom)'],
73
+ overflowY: 'scroll',
74
+ WebkitOverflowScrolling: 'touch'
75
+ }).toString();
76
+ const slideInSheetDrawer = css.keyframes({
77
+ '0%': {
78
+ transform: 'translateY(100%)'
79
+ },
80
+ '100%': {
81
+ transform: 'translateY(0)'
82
+ }
83
+ });
84
+ const fadeInSheetDrawer = css.keyframes({
85
+ '0%': {
86
+ opacity: 0
87
+ },
88
+ '100%': {
89
+ opacity: 1
90
+ }
91
+ });
92
+ const slideOutSheetDrawer = css.keyframes({
93
+ '0%': {
94
+ transform: 'translateY(0)'
95
+ },
96
+ '100%': {
97
+ transform: 'translateY(100%)'
98
+ }
99
+ });
100
+ const fadeOutSheetDrawer = css.keyframes({
101
+ '0%': {
102
+ opacity: 1
103
+ },
104
+ '100%': {
105
+ opacity: 0
106
+ }
107
+ });
108
+ const drawerAnimation = {
109
+ in: css({
110
+ [responsiveMediaQuery('<=sm', {
111
+ appAlways: true
112
+ })]: {
113
+ animation: `${slideInSheetDrawer} ${duration}ms 1 both ${easing}`
114
+ },
115
+ [responsiveMediaQuery('>sm', {
116
+ webOnly: true
117
+ })]: {
118
+ animation: `${fadeInSheetDrawer} ${duration}ms 1 both ${easing}`
119
+ }
120
+ }).toString(),
121
+ out: css({
122
+ [responsiveMediaQuery('<=sm', {
123
+ appAlways: true
124
+ })]: {
125
+ animation: `${slideOutSheetDrawer} ${duration}ms 1 both ${easing}`
126
+ },
127
+ [responsiveMediaQuery('>sm', {
128
+ webOnly: true
129
+ })]: {
130
+ animation: `${fadeOutSheetDrawer} ${duration}ms 1 both ${easing}`
131
+ }
132
+ }).toString()
133
+ };
134
+ export default {
135
+ section,
136
+ container,
137
+ containerFullScreen,
138
+ searchBarWrapper,
139
+ progressBarContainer,
140
+ shadow,
141
+ content,
142
+ drawerAnimation
143
+ };
@@ -1,6 +1,36 @@
1
- import React from'react';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{PRODUCT_TAX_DISCLAIMER}from'@shopgate/pwa-common-commerce/product/constants/Portals';import I18n from'@shopgate/pwa-common/components/I18n';import showTaxDisclaimer from'@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';import{useWidgetSettings}from'@shopgate/engage/core/hooks/useWidgetSettings';import styles from"./style";/**
1
+ import React from 'react';
2
+ import SurroundPortals from '@shopgate/pwa-common/components/SurroundPortals';
3
+ import { PRODUCT_TAX_DISCLAIMER } from '@shopgate/pwa-common-commerce/product/constants/Portals';
4
+ import I18n from '@shopgate/pwa-common/components/I18n';
5
+ import showTaxDisclaimer from '@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';
6
+ import { useWidgetSettings } from '@shopgate/engage/core/hooks/useWidgetSettings';
7
+ import styles from "./style";
8
+
9
+ /**
2
10
  * TaxDisclaimer component.
3
11
  * @returns {Function}
4
- */var TaxDisclaimer=function TaxDisclaimer(){// Added with PWA 6 - CCP-2372
5
- var _useWidgetSettings=useWidgetSettings('@shopgate/engage/components/TaxDisclaimer'),show=_useWidgetSettings.show,text=_useWidgetSettings.text;// use widget setting if set to true/false, otherwise use market logic
6
- var showDisclaimer=typeof show==='boolean'?show:showTaxDisclaimer;return React.createElement(SurroundPortals,{portalName:PRODUCT_TAX_DISCLAIMER,portalProps:{showTaxDisclaimer:showDisclaimer}},showDisclaimer&&React.createElement("div",{"data-test-id":"taxDisclaimer","aria-hidden":true,className:"ui-shared__tax-disclaimer"},React.createElement(I18n.Text,{className:styles,string:text||'product.tax_disclaimer'})));};export default TaxDisclaimer;
12
+ */
13
+ const TaxDisclaimer = () => {
14
+ // Added with PWA 6 - CCP-2372
15
+ const {
16
+ show,
17
+ text
18
+ } = useWidgetSettings('@shopgate/engage/components/TaxDisclaimer');
19
+
20
+ // use widget setting if set to true/false, otherwise use market logic
21
+ const showDisclaimer = typeof show === 'boolean' ? show : showTaxDisclaimer;
22
+ return /*#__PURE__*/React.createElement(SurroundPortals, {
23
+ portalName: PRODUCT_TAX_DISCLAIMER,
24
+ portalProps: {
25
+ showTaxDisclaimer: showDisclaimer
26
+ }
27
+ }, showDisclaimer && /*#__PURE__*/React.createElement("div", {
28
+ "data-test-id": "taxDisclaimer",
29
+ "aria-hidden": true,
30
+ className: "ui-shared__tax-disclaimer"
31
+ }, /*#__PURE__*/React.createElement(I18n.Text, {
32
+ className: styles,
33
+ string: text || 'product.tax_disclaimer'
34
+ })));
35
+ };
36
+ export default TaxDisclaimer;
@@ -1,3 +1,31 @@
1
- import React from'react';import{shallow}from'enzyme';import I18n from'@shopgate/pwa-common/components/I18n';jest.mock('@shopgate/engage/core/hooks/useWidgetSettings',function(){return{useWidgetSettings:jest.fn().mockReturnValue({show:null,hint:'*',text:null})};});describe('<TaxDisclaimer />',function(){afterEach(function(){jest.resetModules();});it('should display the component',function(){jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer',function(){return true;});// eslint-disable-next-line global-require
2
- var TaxDisclaimer=require("./index")["default"];var wrapper=shallow(React.createElement(TaxDisclaimer,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(I18n.Text).exists()).toBe(true);});it('should display null',function(){jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer',function(){return false;});// eslint-disable-next-line global-require
3
- var TaxDisclaimer=require("./index")["default"];var wrapper=shallow(React.createElement(TaxDisclaimer,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(I18n.Text).exists()).toBe(false);});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import I18n from '@shopgate/pwa-common/components/I18n';
4
+ jest.mock('@shopgate/engage/core/hooks/useWidgetSettings', () => ({
5
+ useWidgetSettings: jest.fn().mockReturnValue({
6
+ show: null,
7
+ hint: '*',
8
+ text: null
9
+ })
10
+ }));
11
+ describe('<TaxDisclaimer />', () => {
12
+ afterEach(() => {
13
+ jest.resetModules();
14
+ });
15
+ it('should display the component', () => {
16
+ jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer', () => true);
17
+ // eslint-disable-next-line global-require
18
+ const TaxDisclaimer = require("./index").default;
19
+ const wrapper = shallow(/*#__PURE__*/React.createElement(TaxDisclaimer, null));
20
+ expect(wrapper).toMatchSnapshot();
21
+ expect(wrapper.find(I18n.Text).exists()).toBe(true);
22
+ });
23
+ it('should display null', () => {
24
+ jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer', () => false);
25
+ // eslint-disable-next-line global-require
26
+ const TaxDisclaimer = require("./index").default;
27
+ const wrapper = shallow(/*#__PURE__*/React.createElement(TaxDisclaimer, null));
28
+ expect(wrapper).toMatchSnapshot();
29
+ expect(wrapper.find(I18n.Text).exists()).toBe(false);
30
+ });
31
+ });
@@ -1 +1,9 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';export default css({background:themeConfig.colors.background,display:'block',fontSize:12,padding:"20px ".concat(themeConfig.variables.gap.big,"px"),textAlign:'left'}).toString();
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ export default css({
4
+ background: themeConfig.colors.background,
5
+ display: 'block',
6
+ fontSize: 12,
7
+ padding: `20px ${themeConfig.variables.gap.big}px`,
8
+ textAlign: 'left'
9
+ }).toString();
@@ -1,5 +1,36 @@
1
- import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import I18n from'@shopgate/pwa-common/components/I18n';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import I18n from '@shopgate/pwa-common/components/I18n';
5
+ import styles from "./style";
6
+
7
+ /**
2
8
  * Error message component.
3
9
  * @param {Object} props The component props.
4
10
  * @returns {JSX.Element}
5
- */var ErrorText=function ErrorText(_ref){var elementName=_ref.elementName,validationError=_ref.validationError,errorText=_ref.errorText,ariaHidden=_ref.ariaHidden,translate=_ref.translate,className=_ref.className;return React.createElement("div",{id:"ariaError-".concat(elementName),className:classNames(className,styles.error,'errorText'),"aria-live":"assertive","aria-atomic":"true","aria-hidden":ariaHidden},translate&&React.createElement(I18n.Text,{string:validationError||errorText}),!translate&&(validationError||errorText));};ErrorText.defaultProps={className:'',errorText:null,elementName:null,translate:true,ariaHidden:false,validationError:null};export default ErrorText;
11
+ */
12
+ const ErrorText = ({
13
+ elementName,
14
+ validationError,
15
+ errorText,
16
+ ariaHidden,
17
+ translate,
18
+ className
19
+ }) => /*#__PURE__*/React.createElement("div", {
20
+ id: `ariaError-${elementName}`,
21
+ className: classNames(className, styles.error, 'errorText'),
22
+ "aria-live": "assertive",
23
+ "aria-atomic": "true",
24
+ "aria-hidden": ariaHidden
25
+ }, translate && /*#__PURE__*/React.createElement(I18n.Text, {
26
+ string: validationError || errorText
27
+ }), !translate && (validationError || errorText));
28
+ ErrorText.defaultProps = {
29
+ className: '',
30
+ errorText: null,
31
+ elementName: null,
32
+ translate: true,
33
+ ariaHidden: false,
34
+ validationError: null
35
+ };
36
+ export default ErrorText;
@@ -1,5 +1,27 @@
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';/**
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+
4
+ /**
2
5
  * The style object for a one line text element with an ellipsis on overflow.
3
- */var ellipsisLine={overflow:'hidden',width:'100%',whiteSpace:'nowrap',textOverflow:'ellipsis'};/**
6
+ */
7
+ const ellipsisLine = {
8
+ overflow: 'hidden',
9
+ width: '100%',
10
+ whiteSpace: 'nowrap',
11
+ textOverflow: 'ellipsis'
12
+ };
13
+
14
+ /**
4
15
  * The styles for the error message.
5
- */var error=css(_extends({position:'absolute',bottom:2,fontSize:12,lineHeight:'14px',color:"var(--color-state-alert, ".concat(themeConfig.colors.error,")")},ellipsisLine)).toString();export default{error:error};
16
+ */
17
+ const error = css({
18
+ position: 'absolute',
19
+ bottom: 2,
20
+ fontSize: 12,
21
+ lineHeight: '14px',
22
+ color: `var(--color-state-alert, ${themeConfig.colors.error})`,
23
+ ...ellipsisLine
24
+ }).toString();
25
+ export default {
26
+ error
27
+ };
@@ -1,5 +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 React from'react';import PropTypes from'prop-types';import Input from'@shopgate/pwa-common/components/Input';import styles from"./style";/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import Input from '@shopgate/pwa-common/components/Input';
5
+ import styles from "./style";
6
+
7
+ /**
2
8
  * Creates an input or a multiLine based on the type prop.
3
9
  * @param {Object} props The props.
4
10
  * @returns {JSX.Element}
5
- */var FormElement=function FormElement(props){var styleType=props.multiLine?'multiLine':'input';return React.createElement(Input,_extends({},props,{className:styles[styleType],validateOnBlur:true}));};FormElement.defaultProps={multiLine:false};export default FormElement;
11
+ */
12
+ const FormElement = props => {
13
+ const styleType = props.multiLine ? 'multiLine' : 'input';
14
+ return /*#__PURE__*/React.createElement(Input, _extends({}, props, {
15
+ className: styles[styleType],
16
+ validateOnBlur: true
17
+ }));
18
+ };
19
+ FormElement.defaultProps = {
20
+ multiLine: false
21
+ };
22
+ export default FormElement;