@shopgate/pwa-ui-shared 7.30.0-alpha.7 → 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
@@ -1,3 +1,52 @@
1
- import React from'react';import{shallow}from'enzyme';import{UnwrappedVariantSelectModal as VariantSelectModal}from"./index";var message='This is the message.';var title='This is the title.';jest.mock('@shopgate/engage/a11y/components');describe('<VariantSelectModal />',function(){it('should render with minimal props',function(){var wrapper=shallow(React.createElement(VariantSelectModal,{message:message,actions:[],navigate:function navigate(){}}));expect(wrapper).toMatchSnapshot();expect(wrapper.html()).toMatch(message);});it('should render the actions',function(){var mockConfirm=jest.fn();var mockNavigate=jest.fn();/**
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import { UnwrappedVariantSelectModal as VariantSelectModal } from "./index";
4
+ const message = 'This is the message.';
5
+ const title = 'This is the title.';
6
+ jest.mock('@shopgate/engage/a11y/components');
7
+ describe('<VariantSelectModal />', () => {
8
+ it('should render with minimal props', () => {
9
+ const wrapper = shallow(/*#__PURE__*/React.createElement(VariantSelectModal, {
10
+ message: message,
11
+ actions: [],
12
+ navigate: () => {}
13
+ }));
14
+ expect(wrapper).toMatchSnapshot();
15
+ expect(wrapper.html()).toMatch(message);
16
+ });
17
+ it('should render the actions', () => {
18
+ const mockConfirm = jest.fn();
19
+ const mockNavigate = jest.fn();
20
+ /**
2
21
  * Mocks named function
3
- */var onConfirm=function onConfirm(){mockConfirm();};var actions=[{label:'confirm',action:onConfirm},{label:'dismiss',action:function action(){}}];var params={productId:'product_1'};var mockedProps={message:message,title:title,params:params,actions:[].concat(actions),navigate:mockNavigate};var wrapper=shallow(React.createElement(VariantSelectModal,mockedProps));expect(wrapper).toMatchSnapshot();var reordered=wrapper.find('BasicDialog').props().actions;var last=reordered.slice(-1)[0];expect(last.label).toEqual(actions[0].label);last.action();expect(mockConfirm).toHaveBeenCalledTimes(1);expect(mockNavigate).toHaveBeenCalledTimes(1);});});
22
+ */
23
+ const onConfirm = () => {
24
+ mockConfirm();
25
+ };
26
+ const actions = [{
27
+ label: 'confirm',
28
+ action: onConfirm
29
+ }, {
30
+ label: 'dismiss',
31
+ action: () => {}
32
+ }];
33
+ const params = {
34
+ productId: 'product_1'
35
+ };
36
+ const mockedProps = {
37
+ message,
38
+ title,
39
+ params,
40
+ actions: [...actions],
41
+ navigate: mockNavigate
42
+ };
43
+ const wrapper = shallow(/*#__PURE__*/React.createElement(VariantSelectModal, mockedProps));
44
+ expect(wrapper).toMatchSnapshot();
45
+ const reordered = wrapper.find('BasicDialog').props().actions;
46
+ const last = reordered.slice(-1)[0];
47
+ expect(last.label).toEqual(actions[0].label);
48
+ last.action();
49
+ expect(mockConfirm).toHaveBeenCalledTimes(1);
50
+ expect(mockNavigate).toHaveBeenCalledTimes(1);
51
+ });
52
+ });
@@ -1 +1,6 @@
1
- export var DIALOG_TEXT_MESSAGE='DIALOG_TEXT_MESSAGE';export var DIALOG_HTML_CONTENT='DIALOG_HTML_CONTENT';export var MODAL_VARIANT_SELECT='MODAL_VARIANT_SELECT';export var MODAL_ACTION_TYPE_NORMAL='normal';export var MODAL_ACTION_TYPE_PRIMARY='primary';export var MODAL_ACTION_TYPE_DANGER='danger';
1
+ export const DIALOG_TEXT_MESSAGE = 'DIALOG_TEXT_MESSAGE';
2
+ export const DIALOG_HTML_CONTENT = 'DIALOG_HTML_CONTENT';
3
+ export const MODAL_VARIANT_SELECT = 'MODAL_VARIANT_SELECT';
4
+ export const MODAL_ACTION_TYPE_NORMAL = 'normal';
5
+ export const MODAL_ACTION_TYPE_PRIMARY = 'primary';
6
+ export const MODAL_ACTION_TYPE_DANGER = 'danger';
package/Dialog/index.js CHANGED
@@ -1,4 +1,24 @@
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 React,{useEffect}from'react';import PropTypes from'prop-types';import Modal from'@shopgate/pwa-common/components/Modal';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import{MODAL_PIPELINE_ERROR}from'@shopgate/pwa-common/constants/ModalTypes';import I18n from'@shopgate/pwa-common/components/I18n';import{DIALOG_TEXT_MESSAGE,MODAL_VARIANT_SELECT,MODAL_ACTION_TYPE_PRIMARY,MODAL_ACTION_TYPE_NORMAL,DIALOG_HTML_CONTENT}from"./constants";import PipelineErrorDialog from"./components/PipelineErrorDialog";import TextMessageDialog from"./components/TextMessageDialog";import HtmlContentDialog from"./components/HtmlContentDialog";import BasicDialog from"./components/BasicDialog";import VariantSelectModal from"./components/VariantSelectModal";var dialogTypes=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},DIALOG_TEXT_MESSAGE,TextMessageDialog),DIALOG_HTML_CONTENT,HtmlContentDialog),MODAL_PIPELINE_ERROR,PipelineErrorDialog),MODAL_VARIANT_SELECT,VariantSelectModal);var supportsInert='inert'in HTMLElement.prototype;/**
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Modal from '@shopgate/pwa-common/components/Modal';
4
+ import Backdrop from '@shopgate/pwa-common/components/Backdrop';
5
+ import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
6
+ import I18n from '@shopgate/pwa-common/components/I18n';
7
+ import { DIALOG_TEXT_MESSAGE, MODAL_VARIANT_SELECT, MODAL_ACTION_TYPE_PRIMARY, MODAL_ACTION_TYPE_NORMAL, DIALOG_HTML_CONTENT } from "./constants";
8
+ import PipelineErrorDialog from "./components/PipelineErrorDialog";
9
+ import TextMessageDialog from "./components/TextMessageDialog";
10
+ import HtmlContentDialog from "./components/HtmlContentDialog";
11
+ import BasicDialog from "./components/BasicDialog";
12
+ import VariantSelectModal from "./components/VariantSelectModal";
13
+ const dialogTypes = {
14
+ [DIALOG_TEXT_MESSAGE]: TextMessageDialog,
15
+ [DIALOG_HTML_CONTENT]: HtmlContentDialog,
16
+ [MODAL_PIPELINE_ERROR]: PipelineErrorDialog,
17
+ [MODAL_VARIANT_SELECT]: VariantSelectModal
18
+ };
19
+ const supportsInert = 'inert' in HTMLElement.prototype;
20
+
21
+ /**
2
22
  * The main component for rendering dialogs.
3
23
  * This component takes care of choosing the correct component body for the given type
4
24
  * and render it on a modal overlay.
@@ -8,9 +28,96 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
8
28
  * @param {Function} props.onDismiss The function to call when the dismiss button is clicked.
9
29
  * @param {NodeList} props.children The children to render inside the modal.
10
30
  * @returns {JSX.Element}
11
- */var Dialog=function Dialog(_ref){var modal=_ref.modal,onConfirm=_ref.onConfirm,onDismiss=_ref.onDismiss,children=_ref.children;// Assemble the actions.
12
- var actions=[];var confirm=modal.confirm,dismiss=modal.dismiss,title=modal.title,titleParams=modal.titleParams,message=modal.message,params=modal.params,type=modal.type,confirmDisabled=modal.confirmDisabled,dismissDisabled=modal.dismissDisabled;// Push dismiss action first so the button is rendered first
13
- if(dismiss){// We have a dismiss label, add a dismiss action.
14
- actions.push({label:modal.dismiss,action:onDismiss,type:MODAL_ACTION_TYPE_PRIMARY,disabled:dismissDisabled});}if(confirm){// We have a confirm label, add a confirm action.
15
- actions.push({label:modal.confirm,action:onConfirm,type:MODAL_ACTION_TYPE_NORMAL,disabled:confirmDisabled});}var dialogType=type;if(!dialogType&&message){dialogType=DIALOG_TEXT_MESSAGE;}var dialogTitle=title;if(titleParams){dialogTitle=React.createElement(I18n.Text,{string:title,params:titleParams});}var dialogProps={actions:actions,title:dialogTitle,params:params,message:message||undefined,children:children};var DialogComponent=dialogTypes[dialogType]||BasicDialog;// Effect to toggle aria-hidden on all other modals when the dialog is open.
16
- useEffect(function(){var otherModals=document.querySelectorAll('.common__modal:not(.ui-shared__dialog-modal), .engage__sheet-drawer');otherModals.forEach(function(entry){if(supportsInert){entry.setAttribute('inert','');}else{entry.setAttribute('aria-hidden','true');}});return function(){otherModals.forEach(function(entry){entry.removeAttribute('inert');entry.removeAttribute('aria-hidden');});};},[]);return React.createElement(Modal,{classes:{container:'ui-shared__dialog-modal'}},React.createElement(Backdrop,{isVisible:true,level:0,opacity:30}),React.createElement(DialogComponent,dialogProps));};Dialog.defaultProps={onConfirm:function onConfirm(){},onDismiss:function onDismiss(){},children:null};export default Dialog;
31
+ */
32
+ const Dialog = ({
33
+ modal,
34
+ onConfirm,
35
+ onDismiss,
36
+ children
37
+ }) => {
38
+ // Assemble the actions.
39
+ const actions = [];
40
+ const {
41
+ confirm,
42
+ dismiss,
43
+ title,
44
+ titleParams,
45
+ message,
46
+ params,
47
+ type,
48
+ confirmDisabled,
49
+ dismissDisabled
50
+ } = modal;
51
+
52
+ // Push dismiss action first so the button is rendered first
53
+ if (dismiss) {
54
+ // We have a dismiss label, add a dismiss action.
55
+ actions.push({
56
+ label: modal.dismiss,
57
+ action: onDismiss,
58
+ type: MODAL_ACTION_TYPE_PRIMARY,
59
+ disabled: dismissDisabled
60
+ });
61
+ }
62
+ if (confirm) {
63
+ // We have a confirm label, add a confirm action.
64
+ actions.push({
65
+ label: modal.confirm,
66
+ action: onConfirm,
67
+ type: MODAL_ACTION_TYPE_NORMAL,
68
+ disabled: confirmDisabled
69
+ });
70
+ }
71
+ let dialogType = type;
72
+ if (!dialogType && message) {
73
+ dialogType = DIALOG_TEXT_MESSAGE;
74
+ }
75
+ let dialogTitle = title;
76
+ if (titleParams) {
77
+ dialogTitle = /*#__PURE__*/React.createElement(I18n.Text, {
78
+ string: title,
79
+ params: titleParams
80
+ });
81
+ }
82
+ const dialogProps = {
83
+ actions,
84
+ title: dialogTitle,
85
+ params,
86
+ message: message || undefined,
87
+ children
88
+ };
89
+ const DialogComponent = dialogTypes[dialogType] || BasicDialog;
90
+
91
+ // Effect to toggle aria-hidden on all other modals when the dialog is open.
92
+ useEffect(() => {
93
+ const otherModals = document.querySelectorAll('.common__modal:not(.ui-shared__dialog-modal), .engage__sheet-drawer');
94
+ otherModals.forEach(entry => {
95
+ if (supportsInert) {
96
+ entry.setAttribute('inert', '');
97
+ } else {
98
+ entry.setAttribute('aria-hidden', 'true');
99
+ }
100
+ });
101
+ return () => {
102
+ otherModals.forEach(entry => {
103
+ entry.removeAttribute('inert');
104
+ entry.removeAttribute('aria-hidden');
105
+ });
106
+ };
107
+ }, []);
108
+ return /*#__PURE__*/React.createElement(Modal, {
109
+ classes: {
110
+ container: 'ui-shared__dialog-modal'
111
+ }
112
+ }, /*#__PURE__*/React.createElement(Backdrop, {
113
+ isVisible: true,
114
+ level: 0,
115
+ opacity: 30
116
+ }), /*#__PURE__*/React.createElement(DialogComponent, dialogProps));
117
+ };
118
+ Dialog.defaultProps = {
119
+ onConfirm: () => {},
120
+ onDismiss: () => {},
121
+ children: null
122
+ };
123
+ export default Dialog;
package/Dialog/spec.js CHANGED
@@ -1,5 +1,83 @@
1
- import React from'react';import{shallow,ReactWrapper}from'enzyme';import{MODAL_PIPELINE_ERROR}from'@shopgate/pwa-common/constants/ModalTypes';import{MODAL_VARIANT_SELECT}from"./constants";import Dialog from"./index";jest.mock("./components/VariantSelectModal",function(){/**
1
+ import React from 'react';
2
+ import { shallow, ReactWrapper } from 'enzyme';
3
+ import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
4
+ import { MODAL_VARIANT_SELECT } from "./constants";
5
+ import Dialog from "./index";
6
+ jest.mock("./components/VariantSelectModal", () => {
7
+ /**
2
8
  * VariantSelectModal mock.
3
9
  * @return {JSX}
4
- */var VariantSelectModal=function VariantSelectModal(){return React.createElement("div",null);};return VariantSelectModal;});jest.mock('@shopgate/engage/components');describe('<Dialog />',function(){it('should render without props',function(){var wrapper=shallow(React.createElement(Dialog,{modal:{message:'msg'}}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('TextMessageDialog').length).toBe(1);});it('should render BasicDialog when no message given',function(){var wrapper=shallow(React.createElement(Dialog,{modal:{message:null}}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('BasicDialog').length).toBe(1);});it('should render a special dialog',function(){var params={errorCode:'',message:'',pipeline:'',request:{}};var wrapper=shallow(React.createElement(Dialog,{modal:{type:MODAL_PIPELINE_ERROR,params:params}}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('DefaultDialog').length).toBe(0);expect(wrapper.find('PipelineErrorDialog').length).toBe(1);});it('should render variant select dialog',function(){var params={productId:'product_1'};var wrapper=shallow(React.createElement(Dialog,{modal:{message:'Test',type:MODAL_VARIANT_SELECT,params:params}}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('DefaultDialog').length).toBe(0);expect(wrapper.find('VariantSelectModal').length).toBe(1);});it('should convert title into translatable element',function(){var title='translate.me';var titleParams={foo:'bar'};// eslint-disable-next-line extra-rules/no-single-line-objects
5
- var wrapper=shallow(React.createElement(Dialog,{modal:{title:title,titleParams:titleParams}}));var i18n=new ReactWrapper(wrapper.find('BasicDialog').prop('title'));expect(i18n.prop('string')).toEqual(title);expect(i18n.prop('params')).toEqual(titleParams);});});
10
+ */
11
+ const VariantSelectModal = () => /*#__PURE__*/React.createElement("div", null);
12
+ return VariantSelectModal;
13
+ });
14
+ jest.mock('@shopgate/engage/components');
15
+ describe('<Dialog />', () => {
16
+ it('should render without props', () => {
17
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
18
+ modal: {
19
+ message: 'msg'
20
+ }
21
+ }));
22
+ expect(wrapper).toMatchSnapshot();
23
+ expect(wrapper.find('TextMessageDialog').length).toBe(1);
24
+ });
25
+ it('should render BasicDialog when no message given', () => {
26
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
27
+ modal: {
28
+ message: null
29
+ }
30
+ }));
31
+ expect(wrapper).toMatchSnapshot();
32
+ expect(wrapper.find('BasicDialog').length).toBe(1);
33
+ });
34
+ it('should render a special dialog', () => {
35
+ const params = {
36
+ errorCode: '',
37
+ message: '',
38
+ pipeline: '',
39
+ request: {}
40
+ };
41
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
42
+ modal: {
43
+ type: MODAL_PIPELINE_ERROR,
44
+ params
45
+ }
46
+ }));
47
+ expect(wrapper).toMatchSnapshot();
48
+ expect(wrapper.find('DefaultDialog').length).toBe(0);
49
+ expect(wrapper.find('PipelineErrorDialog').length).toBe(1);
50
+ });
51
+ it('should render variant select dialog', () => {
52
+ const params = {
53
+ productId: 'product_1'
54
+ };
55
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
56
+ modal: {
57
+ message: 'Test',
58
+ type: MODAL_VARIANT_SELECT,
59
+ params
60
+ }
61
+ }));
62
+ expect(wrapper).toMatchSnapshot();
63
+ expect(wrapper.find('DefaultDialog').length).toBe(0);
64
+ expect(wrapper.find('VariantSelectModal').length).toBe(1);
65
+ });
66
+ it('should convert title into translatable element', () => {
67
+ const title = 'translate.me';
68
+ const titleParams = {
69
+ foo: 'bar'
70
+ };
71
+
72
+ // eslint-disable-next-line extra-rules/no-single-line-objects
73
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
74
+ modal: {
75
+ title,
76
+ titleParams
77
+ }
78
+ }));
79
+ const i18n = new ReactWrapper(wrapper.find('BasicDialog').prop('title'));
80
+ expect(i18n.prop('string')).toEqual(title);
81
+ expect(i18n.prop('params')).toEqual(titleParams);
82
+ });
83
+ });
@@ -1,7 +1,35 @@
1
- import React from'react';import PropTypes from'prop-types';import{I18n}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core/helpers';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { I18n } from '@shopgate/engage/components';
4
+ import { i18n } from '@shopgate/engage/core/helpers';
5
+ import styles from "./style";
6
+
7
+ /**
2
8
  * The discount badge component.
3
9
  * @param {Object} props The component props
4
10
  * @param {string} [props.className] Additional CSS style definitions
5
11
  * @param {string} props.text The text contents of the component.
6
12
  * @returns {JSX.Element}
7
- */var DiscountBadge=function DiscountBadge(_ref){var text=_ref.text,className=_ref.className,display=_ref.display,discount=_ref.discount;return React.createElement("div",{"data-test-id":text,className:"ui-shared__discount-badge","aria-label":"".concat(i18n.text('cart.discount'),": ").concat(text),tabIndex:-1},React.createElement(I18n.Text,{className:"".concat(styles[display]," ").concat(className," theme__discount-badge"),string:text,params:[discount],"aria-hidden":true}));};DiscountBadge.defaultProps={className:'',discount:null,display:'small'};export default DiscountBadge;
13
+ */
14
+ const DiscountBadge = ({
15
+ text,
16
+ className,
17
+ display,
18
+ discount
19
+ }) => /*#__PURE__*/React.createElement("div", {
20
+ "data-test-id": text,
21
+ className: "ui-shared__discount-badge",
22
+ "aria-label": `${i18n.text('cart.discount')}: ${text}`,
23
+ tabIndex: -1
24
+ }, /*#__PURE__*/React.createElement(I18n.Text, {
25
+ className: `${styles[display]} ${className} theme__discount-badge`,
26
+ string: text,
27
+ params: [discount],
28
+ "aria-hidden": true
29
+ }));
30
+ DiscountBadge.defaultProps = {
31
+ className: '',
32
+ discount: null,
33
+ display: 'small'
34
+ };
35
+ export default DiscountBadge;
@@ -1 +1,19 @@
1
- import React from'react';import{shallow}from'enzyme';import DiscountBadge from"./index";jest.mock('@shopgate/engage/components');describe('<DiscountBadge />',function(){it('should render the text',function(){var wrapper=shallow(React.createElement(DiscountBadge,{text:"foo"}));expect(wrapper).toMatchSnapshot();});it('should render the text and discount',function(){var wrapper=shallow(React.createElement(DiscountBadge,{text:"SAVE {0}%",discount:20}));expect(wrapper).toMatchSnapshot();});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import DiscountBadge from "./index";
4
+ jest.mock('@shopgate/engage/components');
5
+ describe('<DiscountBadge />', () => {
6
+ it('should render the text', () => {
7
+ const wrapper = shallow(/*#__PURE__*/React.createElement(DiscountBadge, {
8
+ text: "foo"
9
+ }));
10
+ expect(wrapper).toMatchSnapshot();
11
+ });
12
+ it('should render the text and discount', () => {
13
+ const wrapper = shallow(/*#__PURE__*/React.createElement(DiscountBadge, {
14
+ text: "SAVE {0}%",
15
+ discount: 20
16
+ }));
17
+ expect(wrapper).toMatchSnapshot();
18
+ });
19
+ });
@@ -1,4 +1,36 @@
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 colors=themeConfig.colors;var badge=_extends({background:"var(--color-primary, ".concat(colors.primary,")"),borderRadius:2,color:"var(--color-primary-contrast, ".concat(colors.primaryContrast,")"),padding:5,width:'100%',fontWeight:700,textAlign:'center',display:'flex',justifyContent:'center',alignItems:'center',lineHeight:1,whiteSpace:'nowrap'},themeConfig.variables.discountBadgeBase);/**
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ const {
4
+ colors
5
+ } = themeConfig;
6
+ const badge = {
7
+ background: `var(--color-primary, ${colors.primary})`,
8
+ borderRadius: 2,
9
+ color: `var(--color-primary-contrast, ${colors.primaryContrast})`,
10
+ padding: 5,
11
+ width: '100%',
12
+ fontWeight: 700,
13
+ textAlign: 'center',
14
+ display: 'flex',
15
+ justifyContent: 'center',
16
+ alignItems: 'center',
17
+ lineHeight: 1,
18
+ whiteSpace: 'nowrap',
19
+ ...themeConfig.variables.discountBadgeBase
20
+ };
21
+
22
+ /**
2
23
  * The discount badge styles that can be selected by passing the style key.
3
24
  * @type {Object}
4
- */export default{small:css(_extends({},badge)).toString(),big:css(_extends({},badge,{paddingTop:5,paddingLeft:5,paddingRight:5})).toString()};
25
+ */
26
+ export default {
27
+ small: css({
28
+ ...badge
29
+ }).toString(),
30
+ big: css({
31
+ ...badge,
32
+ paddingTop: 5,
33
+ paddingLeft: 5,
34
+ paddingRight: 5
35
+ }).toString()
36
+ };
@@ -1,8 +1,23 @@
1
- import{connect}from'react-redux';import{toggleFavoriteWithListChooser}from'@shopgate/pwa-common-commerce/favorites/actions/toggleFavorites';import{getLoadWishlistOnAppStartEnabled,getWishlistItemQuantityEnabled}from'@shopgate/engage/core/selectors/shopSettings';/**
1
+ import { connect } from 'react-redux';
2
+ import { toggleFavoriteWithListChooser } from '@shopgate/pwa-common-commerce/favorites/actions/toggleFavorites';
3
+ import { getLoadWishlistOnAppStartEnabled, getWishlistItemQuantityEnabled } from '@shopgate/engage/core/selectors/shopSettings';
4
+
5
+ /**
2
6
  * Creates the mapStateToProps connector function.
3
7
  * @returns {Function}
4
- */var makeMapStateToProps=function makeMapStateToProps(){return function(state){return{wishlistItemQuantityEnabled:getWishlistItemQuantityEnabled(state),loadWishlistOnAppStartEnabled:getLoadWishlistOnAppStartEnabled(state)};};};/**
8
+ */
9
+ const makeMapStateToProps = () => state => ({
10
+ wishlistItemQuantityEnabled: getWishlistItemQuantityEnabled(state),
11
+ loadWishlistOnAppStartEnabled: getLoadWishlistOnAppStartEnabled(state)
12
+ });
13
+
14
+ /**
5
15
  * Connects the dispatch function to a callable function in the props.
6
16
  * @param {Function} dispatch The redux dispatch function.
7
17
  * @return {Object} The extended component props.
8
- */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{addFavorites:function addFavorites(productId){return dispatch(toggleFavoriteWithListChooser(productId));},removeFavorites:function removeFavorites(productId,withRelatives){return dispatch(toggleFavoriteWithListChooser(productId,withRelatives));}};};export default connect(makeMapStateToProps,mapDispatchToProps);
18
+ */
19
+ const mapDispatchToProps = dispatch => ({
20
+ addFavorites: productId => dispatch(toggleFavoriteWithListChooser(productId)),
21
+ removeFavorites: (productId, withRelatives) => dispatch(toggleFavoriteWithListChooser(productId, withRelatives))
22
+ });
23
+ export default connect(makeMapStateToProps, mapDispatchToProps);
@@ -1,24 +1,127 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import appConfig from'@shopgate/pwa-common/helpers/config';import HeartIcon from"../icons/HeartIcon";import HeartOutlineIcon from"../icons/HeartOutlineIcon";import HeartPlusOutlineIcon from"../icons/HeartPlusOutlineIcon";import HeartPlus from"../icons/HeartPlusIcon";import Ripple from"../Ripple";import styles from"./style";import connect from"./connector";/**
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import appConfig from '@shopgate/pwa-common/helpers/config';
4
+ import HeartIcon from "../icons/HeartIcon";
5
+ import HeartOutlineIcon from "../icons/HeartOutlineIcon";
6
+ import HeartPlusOutlineIcon from "../icons/HeartPlusOutlineIcon";
7
+ import HeartPlus from "../icons/HeartPlusIcon";
8
+ import Ripple from "../Ripple";
9
+ import styles from "./style";
10
+ import connect from "./connector";
11
+
12
+ /**
2
13
  * The favorites button component.
3
- */var FavoritesButton=/*#__PURE__*/function(_Component){/**
14
+ */
15
+ class FavoritesButton extends Component {
16
+ /**
4
17
  * Construct and init state
5
18
  * @param {Object} props Component props
6
- */function FavoritesButton(props){var _this2;_classCallCheck(this,FavoritesButton);_this2=_callSuper(this,FavoritesButton,[props]);/**
7
- * Callback for the moment when the ripple animation is done.
8
- */_defineProperty(_this2,"onRippleComplete",function(){_this2.props.onRippleComplete(_this2.props.active);});/**
9
- * Adds or removes a given product ID from the favorite list.
10
- * @param {Object} event The click event object.
11
- */_defineProperty(_this2,"handleClick",function(event){event.preventDefault();event.stopPropagation();if(_this2.props.once&&_this2.clickedOnce){return;}_this2.clickedOnce=true;if(!_this2.props.productId){return;}// When wishlist item quantity is active, items cannot be removed via the button
12
- if(!_this2.props.active||_this2.props.wishlistItemQuantityEnabled){_this2.props.addFavorites(_this2.props.productId);}else{setTimeout(function(){_this2.props.removeFavorites(_this2.props.productId,_this2.props.removeWithRelatives);},_this2.props.removeThrottle);}});_this2.clickedOnce=false;return _this2;}_inherits(FavoritesButton,_Component);return _createClass(FavoritesButton,[{key:"getLabel",value:/**
19
+ */
20
+ constructor(props) {
21
+ super(props);
22
+ /**
23
+ * Callback for the moment when the ripple animation is done.
24
+ */
25
+ this.onRippleComplete = () => {
26
+ this.props.onRippleComplete(this.props.active);
27
+ };
28
+ /**
29
+ * Adds or removes a given product ID from the favorite list.
30
+ * @param {Object} event The click event object.
31
+ */
32
+ this.handleClick = event => {
33
+ event.preventDefault();
34
+ event.stopPropagation();
35
+ if (this.props.once && this.clickedOnce) {
36
+ return;
37
+ }
38
+ this.clickedOnce = true;
39
+ if (!this.props.productId) {
40
+ return;
41
+ }
42
+
43
+ // When wishlist item quantity is active, items cannot be removed via the button
44
+ if (!this.props.active || this.props.wishlistItemQuantityEnabled) {
45
+ this.props.addFavorites(this.props.productId);
46
+ } else {
47
+ setTimeout(() => {
48
+ this.props.removeFavorites(this.props.productId, this.props.removeWithRelatives);
49
+ }, this.props.removeThrottle);
50
+ }
51
+ };
52
+ this.clickedOnce = false;
53
+ }
54
+ /**
13
55
  * Returns text for aria-label.
14
56
  * @returns {string}
15
- */function getLabel(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var lang=this.props.active?'favorites.remove':'favorites.add';return __(lang);}},{key:"renderIcon",value:/**
57
+ */
58
+ getLabel() {
59
+ const {
60
+ __
61
+ } = this.context.i18n();
62
+ const lang = this.props.active ? 'favorites.remove' : 'favorites.add';
63
+ return __(lang);
64
+ }
65
+ /**
16
66
  * Renders the heart icon as filled or outlined, depending on the favorite button being active.
17
67
  * @returns {JSX}
18
- */function renderIcon(){if(!this.props.loadWishlistOnAppStartEnabled||this.props.wishlistItemQuantityEnabled&&!this.props.active){return React.createElement(HeartPlusOutlineIcon,null);}if(this.props.wishlistItemQuantityEnabled&&this.props.active){return React.createElement(HeartPlus,null);}if(this.props.active){return React.createElement(HeartIcon,null);}return React.createElement(HeartOutlineIcon,null);}/**
68
+ */
69
+ renderIcon() {
70
+ if (!this.props.loadWishlistOnAppStartEnabled || this.props.wishlistItemQuantityEnabled && !this.props.active) {
71
+ return /*#__PURE__*/React.createElement(HeartPlusOutlineIcon, null);
72
+ }
73
+ if (this.props.wishlistItemQuantityEnabled && this.props.active) {
74
+ return /*#__PURE__*/React.createElement(HeartPlus, null);
75
+ }
76
+ if (this.props.active) {
77
+ return /*#__PURE__*/React.createElement(HeartIcon, null);
78
+ }
79
+ return /*#__PURE__*/React.createElement(HeartOutlineIcon, null);
80
+ }
81
+
82
+ /**
19
83
  * Renders the component.
20
84
  * @returns {JSX|null}
21
- */},{key:"render",value:function render(){if(!appConfig.hasFavorites){return null;}var className=this.props.noShadow?styles.buttonFlat:styles.button;return React.createElement("button",{"aria-label":this.getLabel(),"aria-hidden":this.props['aria-hidden'],className:"ui-shared__favorites-button ".concat(className," ").concat(this.props.className),onClick:this.handleClick,"data-test-id":"favoriteButton",type:"button"},React.createElement(Ripple,{className:"".concat(styles.ripple," ").concat(this.props.rippleClassName),onComplete:this.onRippleComplete},this.renderIcon()));}}]);}(Component);/**
22
- * Context types definition.
23
- * @type {{i18n: shim}}
24
- */_defineProperty(FavoritesButton,"contextTypes",{i18n:PropTypes.func});_defineProperty(FavoritesButton,"defaultProps",{active:false,addFavorites:function addFavorites(){},'aria-hidden':null,className:'',noShadow:false,once:false,onRippleComplete:function onRippleComplete(){},productId:null,removeFavorites:function removeFavorites(){},removeThrottle:0,removeWithRelatives:false,rippleClassName:'',wishlistItemQuantityEnabled:false,loadWishlistOnAppStartEnabled:true});export default connect(FavoritesButton);
85
+ */
86
+ render() {
87
+ if (!appConfig.hasFavorites) {
88
+ return null;
89
+ }
90
+ const className = this.props.noShadow ? styles.buttonFlat : styles.button;
91
+ return /*#__PURE__*/React.createElement("button", {
92
+ "aria-label": this.getLabel(),
93
+ "aria-hidden": this.props['aria-hidden'],
94
+ className: `ui-shared__favorites-button ${className} ${this.props.className}`,
95
+ onClick: this.handleClick,
96
+ "data-test-id": "favoriteButton",
97
+ type: "button"
98
+ }, /*#__PURE__*/React.createElement(Ripple, {
99
+ className: `${styles.ripple} ${this.props.rippleClassName}`,
100
+ onComplete: this.onRippleComplete
101
+ }, this.renderIcon()));
102
+ }
103
+ }
104
+ /**
105
+ * Context types definition.
106
+ * @type {{i18n: shim}}
107
+ */
108
+ FavoritesButton.contextTypes = {
109
+ i18n: PropTypes.func
110
+ };
111
+ FavoritesButton.defaultProps = {
112
+ active: false,
113
+ addFavorites: () => {},
114
+ 'aria-hidden': null,
115
+ className: '',
116
+ noShadow: false,
117
+ once: false,
118
+ onRippleComplete: () => {},
119
+ productId: null,
120
+ removeFavorites: () => {},
121
+ removeThrottle: 0,
122
+ removeWithRelatives: false,
123
+ rippleClassName: '',
124
+ wishlistItemQuantityEnabled: false,
125
+ loadWishlistOnAppStartEnabled: true
126
+ };
127
+ export default connect(FavoritesButton);
@@ -1,10 +1,56 @@
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;}var mockedProduct1={productId:'foo'};/**
1
+ const mockedProduct1 = {
2
+ productId: 'foo'
3
+ };
4
+
5
+ /**
2
6
  * Mocked state with product only. Favorites not set.
3
7
  * @type {Object}
4
- */export var mockedStateNotOnList={product:{productsById:_defineProperty({},mockedProduct1.productId,{productData:mockedProduct1})},favorites:{products:{ids:[mockedProduct1.productId]}}};/**
8
+ */
9
+ export const mockedStateNotOnList = {
10
+ product: {
11
+ productsById: {
12
+ [mockedProduct1.productId]: {
13
+ productData: mockedProduct1
14
+ }
15
+ }
16
+ },
17
+ favorites: {
18
+ products: {
19
+ ids: [mockedProduct1.productId]
20
+ }
21
+ }
22
+ };
23
+
24
+ /**
5
25
  * Mocked state with product only. Favorites not set.
6
26
  * @type {Object}
7
- */export var mockedStateOnList={product:{productsById:_defineProperty({},mockedProduct1.productId,{productData:mockedProduct1})},favorites:{products:{ids:[mockedProduct1.productId]}}};/**
27
+ */
28
+ export const mockedStateOnList = {
29
+ product: {
30
+ productsById: {
31
+ [mockedProduct1.productId]: {
32
+ productData: mockedProduct1
33
+ }
34
+ }
35
+ },
36
+ favorites: {
37
+ products: {
38
+ ids: [mockedProduct1.productId]
39
+ }
40
+ }
41
+ };
42
+
43
+ /**
8
44
  * Mocked state without data.
9
45
  * @type {{product: {, favorites: {}}}}
10
- */export var mockedStateEmpty={product:{productsById:{}},favorites:{products:{ids:[]}}};
46
+ */
47
+ export const mockedStateEmpty = {
48
+ product: {
49
+ productsById: {}
50
+ },
51
+ favorites: {
52
+ products: {
53
+ ids: []
54
+ }
55
+ }
56
+ };