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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/AccordionContainer/index.js +17 -11
  2. package/AccordionContainer/spec.js +12 -3
  3. package/ActionButton/index.js +51 -32
  4. package/ActionButton/spec.js +13 -5
  5. package/AddToCartButton/index.js +44 -33
  6. package/AddToCartButton/mock.js +20 -8
  7. package/AddToCartButton/spec.js +29 -14
  8. package/Availability/index.js +5 -3
  9. package/Availability/spec.js +6 -5
  10. package/Button/index.js +73 -58
  11. package/Button/spec.js +16 -10
  12. package/ButtonLink/index.js +20 -12
  13. package/ButtonLink/spec.js +5 -3
  14. package/Card/index.js +5 -3
  15. package/CardList/components/Item/index.js +5 -3
  16. package/CardList/index.js +21 -12
  17. package/CartTotalLine/components/Amount/index.js +10 -8
  18. package/CartTotalLine/components/Hint/index.js +7 -5
  19. package/CartTotalLine/components/Label/index.js +12 -10
  20. package/CartTotalLine/components/Spacer/index.js +5 -3
  21. package/CartTotalLine/index.js +5 -3
  22. package/Checkbox/index.js +6 -5
  23. package/Chip/index.js +28 -22
  24. package/Chip/spec.js +9 -6
  25. package/ContextMenu/ContextMenuProvider.js +5 -3
  26. package/ContextMenu/components/Item/index.js +14 -11
  27. package/ContextMenu/components/Position/index.js +20 -12
  28. package/ContextMenu/index.js +54 -44
  29. package/ContextMenu/spec.js +31 -20
  30. package/Dialog/components/HtmlContentDialog/index.js +9 -7
  31. package/Dialog/components/HtmlContentDialog/spec.js +9 -6
  32. package/Dialog/components/PipelineErrorDialog/index.js +106 -47
  33. package/Dialog/components/PipelineErrorDialog/spec.js +5 -4
  34. package/Dialog/components/TextMessageDialog/index.js +9 -7
  35. package/Dialog/components/TextMessageDialog/spec.js +9 -6
  36. package/Dialog/components/VariantSelectModal/index.js +7 -5
  37. package/Dialog/components/VariantSelectModal/spec.js +6 -3
  38. package/Dialog/index.js +12 -8
  39. package/Dialog/spec.js +7 -6
  40. package/DiscountBadge/index.js +10 -8
  41. package/DiscountBadge/spec.js +3 -2
  42. package/FavoritesButton/index.js +40 -31
  43. package/FavoritesButton/spec.js +7 -3
  44. package/Form/Builder/classes/ActionListener/index.js +400 -401
  45. package/Form/Builder/components/CheckboxElement.js +13 -5
  46. package/Form/Builder/components/CountryElement.js +13 -5
  47. package/Form/Builder/components/ProvinceElement.js +13 -5
  48. package/Form/Builder/components/RadioElement.js +19 -11
  49. package/Form/Builder/components/SelectElement.js +26 -16
  50. package/Form/Builder/components/TextElement.js +13 -5
  51. package/Form/Builder/index.js +70 -60
  52. package/Form/Builder/spec.js +27 -18
  53. package/Form/Checkbox/index.js +31 -21
  54. package/Form/InfoField/index.js +19 -12
  55. package/Form/InfoField/spec.js +4 -1
  56. package/Form/Password/index.js +22 -15
  57. package/Form/Password/spec.js +10 -5
  58. package/Form/RadioGroup/components/Item/index.js +34 -25
  59. package/Form/RadioGroup/index.js +37 -28
  60. package/Form/RadioGroup/spec.js +45 -31
  61. package/Form/Select/index.js +52 -43
  62. package/Form/Select/spec.js +5 -2
  63. package/Form/SelectContextChoices/index.js +26 -22
  64. package/Form/SelectContextChoices/spec.js +4 -1
  65. package/Form/TextField/index.js +40 -27
  66. package/Form/TextField/spec.js +34 -21
  67. package/Form/index.js +23 -15
  68. package/FormElement/components/ErrorText/index.js +7 -5
  69. package/FormElement/components/Label/index.js +6 -4
  70. package/FormElement/components/Placeholder/index.js +7 -5
  71. package/FormElement/components/Underline/index.js +8 -6
  72. package/FormElement/index.js +62 -46
  73. package/FormElement/spec.js +10 -9
  74. package/Glow/index.js +30 -22
  75. package/Glow/spec.js +6 -1
  76. package/IndicatorCircle/index.js +10 -8
  77. package/IndicatorCircle/spec.js +3 -2
  78. package/LoadingIndicator/index.js +8 -6
  79. package/Manufacturer/index.js +9 -7
  80. package/MessageBar/index.js +20 -17
  81. package/MessageBar/spec.js +6 -5
  82. package/NoResults/components/Icon/index.js +134 -110
  83. package/NoResults/index.js +27 -21
  84. package/Placeholder/index.js +13 -5
  85. package/PlaceholderLabel/index.js +2 -1
  86. package/PlaceholderLabel/spec.js +13 -6
  87. package/PlaceholderParagraph/index.js +13 -12
  88. package/PlaceholderParagraph/spec.js +13 -6
  89. package/Price/index.js +46 -28
  90. package/PriceInfo/index.js +2 -1
  91. package/PriceStriked/index.js +41 -29
  92. package/ProductProperties/index.js +13 -10
  93. package/ProgressBar/index.js +28 -19
  94. package/ProgressBar/spec.js +2 -1
  95. package/RadioButton/index.js +6 -5
  96. package/RadioButton/spec.js +3 -2
  97. package/RatingNumber/index.js +2 -1
  98. package/RatingStars/index.js +50 -34
  99. package/RatingStars/spec.js +7 -6
  100. package/Ripple/components/RippleAnimation/index.js +48 -52
  101. package/Ripple/index.js +72 -62
  102. package/RippleButton/index.js +44 -27
  103. package/RippleButton/spec.js +20 -13
  104. package/ScannerOverlay/components/CameraOverlay/index.js +8 -5
  105. package/ScannerOverlay/components/CameraOverlay/style.js +0 -1
  106. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +25 -21
  107. package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +7 -5
  108. package/ScannerOverlay/components/ScannerBar/index.js +17 -12
  109. package/ScannerOverlay/index.js +24 -15
  110. package/Sheet/components/Header/components/SearchBar/index.js +35 -28
  111. package/Sheet/components/Header/components/SearchBar/spec.js +2 -1
  112. package/Sheet/components/Header/index.js +47 -34
  113. package/Sheet/components/Header/spec.js +2 -1
  114. package/Sheet/index.js +80 -65
  115. package/Sheet/spec.js +27 -14
  116. package/TaxDisclaimer/index.js +13 -10
  117. package/TaxDisclaimer/spec.js +3 -2
  118. package/TextField/components/ErrorText/index.js +7 -5
  119. package/TextField/components/FormElement/index.js +4 -3
  120. package/TextField/components/Hint/index.js +7 -5
  121. package/TextField/components/Label/index.js +6 -4
  122. package/TextField/components/Underline/index.js +8 -6
  123. package/TextField/index.js +102 -85
  124. package/TextField/spec.js +37 -23
  125. package/ToggleIcon/index.js +23 -15
  126. package/ToggleIcon/spec.js +12 -8
  127. package/icons/AccountBoxIcon.js +5 -4
  128. package/icons/AddMoreIcon.js +5 -4
  129. package/icons/ArrowDropIcon.js +5 -4
  130. package/icons/ArrowIcon.js +5 -4
  131. package/icons/BarcodeScannerIcon.js +5 -4
  132. package/icons/BoxIcon.js +5 -4
  133. package/icons/BrowseIcon.js +5 -4
  134. package/icons/BurgerIcon.js +5 -4
  135. package/icons/CalendarIcon.js +5 -5
  136. package/icons/CartCouponIcon.js +5 -4
  137. package/icons/CartIcon.js +5 -4
  138. package/icons/CartPlusIcon.js +5 -4
  139. package/icons/CheckIcon.js +5 -4
  140. package/icons/CheckedIcon.js +5 -4
  141. package/icons/ChevronIcon.js +5 -4
  142. package/icons/CreditCardIcon.js +5 -4
  143. package/icons/CrossIcon.js +5 -4
  144. package/icons/DescriptionIcon.js +5 -4
  145. package/icons/FilterIcon.js +5 -4
  146. package/icons/FlashDisabledIcon.js +5 -4
  147. package/icons/FlashEnabledIcon.js +5 -4
  148. package/icons/GridIcon.js +5 -4
  149. package/icons/HeartIcon.js +5 -4
  150. package/icons/HeartOutlineIcon.js +5 -4
  151. package/icons/HeartPlusIcon.js +5 -4
  152. package/icons/HeartPlusOutlineIcon.js +5 -4
  153. package/icons/HomeIcon.js +5 -4
  154. package/icons/InfoIcon.js +5 -4
  155. package/icons/InfoOutlineIcon.js +5 -4
  156. package/icons/ListIcon.js +5 -4
  157. package/icons/LocalShippingIcon.js +5 -4
  158. package/icons/LocationIcon.js +5 -4
  159. package/icons/LocatorIcon.js +5 -4
  160. package/icons/LockIcon.js +5 -4
  161. package/icons/LogoutIcon.js +5 -4
  162. package/icons/MagnifierIcon.js +5 -4
  163. package/icons/MapMarkerIcon.js +5 -4
  164. package/icons/MoreIcon.js +5 -4
  165. package/icons/MoreVertIcon.js +5 -4
  166. package/icons/NotificationIcon.js +5 -4
  167. package/icons/PersonIcon.js +5 -4
  168. package/icons/PhoneIcon.js +5 -4
  169. package/icons/PlaceholderIcon.js +5 -4
  170. package/icons/RadioCheckedIcon.js +5 -4
  171. package/icons/RadioUncheckedIcon.js +5 -4
  172. package/icons/SecurityIcon.js +5 -4
  173. package/icons/ShippingMethodIcon.js +5 -4
  174. package/icons/ShoppingCartIcon.js +5 -4
  175. package/icons/SortIcon.js +5 -4
  176. package/icons/StarHalfIcon.js +5 -4
  177. package/icons/StarIcon.js +5 -4
  178. package/icons/StarOutlineIcon.js +5 -4
  179. package/icons/StopIcon.js +5 -4
  180. package/icons/TickIcon.js +5 -4
  181. package/icons/TimeIcon.js +5 -4
  182. package/icons/TrashIcon.js +5 -4
  183. package/icons/TrashOutlineIcon.js +5 -4
  184. package/icons/UncheckedIcon.js +5 -4
  185. package/icons/ViewListIcon.js +5 -4
  186. package/icons/VisibilityIcon.js +5 -4
  187. package/icons/VisibilityOffIcon.js +5 -4
  188. package/icons/WarningIcon.js +5 -4
  189. package/package.json +7 -8
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { mount } from 'enzyme';
3
3
  import PipelineErrorDialog from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  jest.mock('@shopgate/engage/a11y/components');
5
6
  describe('<PipelineErrorDialog />', () => {
6
7
  const defaultParams = {
@@ -10,7 +11,7 @@ describe('<PipelineErrorDialog />', () => {
10
11
  request: {}
11
12
  };
12
13
  it('should render with minimal props', () => {
13
- const wrapper = mount(/*#__PURE__*/React.createElement(PipelineErrorDialog, {
14
+ const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
14
15
  actions: [],
15
16
  params: defaultParams
16
17
  }));
@@ -18,7 +19,7 @@ describe('<PipelineErrorDialog />', () => {
18
19
  });
19
20
  it('should show a custom message if a message is is provided', () => {
20
21
  const message = 'Custom message';
21
- const wrapper = mount(/*#__PURE__*/React.createElement(PipelineErrorDialog, {
22
+ const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
22
23
  actions: [],
23
24
  message: message,
24
25
  params: defaultParams
@@ -27,7 +28,7 @@ describe('<PipelineErrorDialog />', () => {
27
28
  expect(wrapper.html()).toMatch(message);
28
29
  });
29
30
  it('should switch modes on tap', () => {
30
- const wrapper = mount(/*#__PURE__*/React.createElement(PipelineErrorDialog, {
31
+ const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
31
32
  actions: [],
32
33
  params: defaultParams
33
34
  }));
@@ -51,7 +52,7 @@ describe('<PipelineErrorDialog />', () => {
51
52
  });
52
53
  it('should not switch modes if tapped too slow', () => {
53
54
  jest.useFakeTimers();
54
- const wrapper = mount(/*#__PURE__*/React.createElement(PipelineErrorDialog, {
55
+ const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
55
56
  actions: [],
56
57
  params: defaultParams
57
58
  }));
@@ -10,20 +10,22 @@ import BasicDialog from "../BasicDialog";
10
10
  * @param {Object} props The component properties.
11
11
  * @returns {JSX} The rendered component.
12
12
  */
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const TextMessageDialog = ({
14
15
  actions,
15
16
  message,
16
17
  title,
17
18
  params,
18
19
  children
19
- }) => /*#__PURE__*/React.createElement(BasicDialog, {
20
+ }) => /*#__PURE__*/_jsxs(BasicDialog, {
20
21
  title: title,
21
- actions: actions
22
- }, /*#__PURE__*/React.createElement("span", {
23
- dangerouslySetInnerHTML: {
24
- __html: nl2br(i18n.text(message, params))
25
- }
26
- }), children);
22
+ actions: actions,
23
+ children: [/*#__PURE__*/_jsx("span", {
24
+ dangerouslySetInnerHTML: {
25
+ __html: nl2br(i18n.text(message, params))
26
+ }
27
+ }), children]
28
+ });
27
29
  TextMessageDialog.defaultProps = {
28
30
  title: BasicDialog.defaultProps.title,
29
31
  params: I18n.Text.defaultProps.params,
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import TextMessageDialog from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  const message = 'This is the message.';
5
6
  const title = 'This is the title.';
6
7
  jest.mock('@shopgate/engage/a11y/components');
7
8
  describe('<TextMessageDialog />', () => {
8
9
  it('should render with minimal props', () => {
9
- const wrapper = shallow(/*#__PURE__*/React.createElement(TextMessageDialog, {
10
+ const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
10
11
  message: message,
11
12
  actions: []
12
13
  }));
@@ -14,7 +15,7 @@ describe('<TextMessageDialog />', () => {
14
15
  expect(wrapper.html()).toMatch(message);
15
16
  });
16
17
  it('should render with title and message', () => {
17
- const wrapper = shallow(/*#__PURE__*/React.createElement(TextMessageDialog, {
18
+ const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
18
19
  title: title,
19
20
  message: message,
20
21
  actions: []
@@ -23,7 +24,7 @@ describe('<TextMessageDialog />', () => {
23
24
  expect(wrapper.html()).toMatch(title);
24
25
  });
25
26
  it('should render with title, message and messageParams', () => {
26
- const wrapper = shallow(/*#__PURE__*/React.createElement(TextMessageDialog, {
27
+ const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
27
28
  title: title,
28
29
  message: "Message with {name}",
29
30
  params: {
@@ -38,7 +39,7 @@ describe('<TextMessageDialog />', () => {
38
39
  label: 'fooAction',
39
40
  action: () => {}
40
41
  }];
41
- const wrapper = shallow(/*#__PURE__*/React.createElement(TextMessageDialog, {
42
+ const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
42
43
  title: title,
43
44
  message: message,
44
45
  actions: actions
@@ -47,8 +48,10 @@ describe('<TextMessageDialog />', () => {
47
48
  expect(wrapper.html()).toMatch(actions[0].label);
48
49
  });
49
50
  it('should pass title through', () => {
50
- const customTitle = /*#__PURE__*/React.createElement("div", null, "Title");
51
- const wrapper = shallow(/*#__PURE__*/React.createElement(TextMessageDialog, {
51
+ const customTitle = /*#__PURE__*/_jsx("div", {
52
+ children: "Title"
53
+ });
54
+ const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
52
55
  title: customTitle,
53
56
  message: message,
54
57
  params: {},
@@ -14,6 +14,7 @@ import connect from "./connector";
14
14
  * @param {string} navigate The navigate action.
15
15
  * @return {Array} Reordered and extended actions.
16
16
  */
17
+ import { jsx as _jsx } from "react/jsx-runtime";
17
18
  const reorderActions = (actions, {
18
19
  productId
19
20
  }, navigate) => {
@@ -61,12 +62,13 @@ const VariantSelectModal = ({
61
62
  params
62
63
  }) => {
63
64
  const parsedActions = reorderActions(actions, params, navigate);
64
- return /*#__PURE__*/React.createElement(BasicDialog, {
65
+ return /*#__PURE__*/_jsx(BasicDialog, {
65
66
  title: title,
66
- actions: parsedActions
67
- }, /*#__PURE__*/React.createElement(I18n.Text, {
68
- string: message
69
- }));
67
+ actions: parsedActions,
68
+ children: /*#__PURE__*/_jsx(I18n.Text, {
69
+ string: message
70
+ })
71
+ });
70
72
  };
71
73
  VariantSelectModal.defaultProps = {
72
74
  params: {
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import { UnwrappedVariantSelectModal as VariantSelectModal } from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  const message = 'This is the message.';
5
6
  const title = 'This is the title.';
6
7
  jest.mock('@shopgate/engage/a11y/components');
7
8
  describe('<VariantSelectModal />', () => {
8
9
  it('should render with minimal props', () => {
9
- const wrapper = shallow(/*#__PURE__*/React.createElement(VariantSelectModal, {
10
+ const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
10
11
  message: message,
11
12
  actions: [],
12
13
  navigate: () => {}
@@ -37,10 +38,12 @@ describe('<VariantSelectModal />', () => {
37
38
  message,
38
39
  title,
39
40
  params,
40
- actions: [...actions],
41
+ actions: [].concat(actions),
41
42
  navigate: mockNavigate
42
43
  };
43
- const wrapper = shallow(/*#__PURE__*/React.createElement(VariantSelectModal, mockedProps));
44
+ const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
45
+ ...mockedProps
46
+ }));
44
47
  expect(wrapper).toMatchSnapshot();
45
48
  const reordered = wrapper.find('BasicDialog').props().actions;
46
49
  const last = reordered.slice(-1)[0];
package/Dialog/index.js CHANGED
@@ -10,6 +10,7 @@ import TextMessageDialog from "./components/TextMessageDialog";
10
10
  import HtmlContentDialog from "./components/HtmlContentDialog";
11
11
  import BasicDialog from "./components/BasicDialog";
12
12
  import VariantSelectModal from "./components/VariantSelectModal";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const dialogTypes = {
14
15
  [DIALOG_TEXT_MESSAGE]: TextMessageDialog,
15
16
  [DIALOG_HTML_CONTENT]: HtmlContentDialog,
@@ -74,7 +75,7 @@ const Dialog = ({
74
75
  }
75
76
  let dialogTitle = title;
76
77
  if (titleParams) {
77
- dialogTitle = /*#__PURE__*/React.createElement(I18n.Text, {
78
+ dialogTitle = /*#__PURE__*/_jsx(I18n.Text, {
78
79
  string: title,
79
80
  params: titleParams
80
81
  });
@@ -105,15 +106,18 @@ const Dialog = ({
105
106
  });
106
107
  };
107
108
  }, []);
108
- return /*#__PURE__*/React.createElement(Modal, {
109
+ return /*#__PURE__*/_jsxs(Modal, {
109
110
  classes: {
110
111
  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));
112
+ },
113
+ children: [/*#__PURE__*/_jsx(Backdrop, {
114
+ isVisible: true,
115
+ level: 0,
116
+ opacity: 30
117
+ }), /*#__PURE__*/_jsx(DialogComponent, {
118
+ ...dialogProps
119
+ })]
120
+ });
117
121
  };
118
122
  Dialog.defaultProps = {
119
123
  onConfirm: () => {},
package/Dialog/spec.js CHANGED
@@ -3,18 +3,19 @@ import { shallow, ReactWrapper } from 'enzyme';
3
3
  import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
4
4
  import { MODAL_VARIANT_SELECT } from "./constants";
5
5
  import Dialog from "./index";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
6
7
  jest.mock("./components/VariantSelectModal", () => {
7
8
  /**
8
9
  * VariantSelectModal mock.
9
10
  * @return {JSX}
10
11
  */
11
- const VariantSelectModal = () => /*#__PURE__*/React.createElement("div", null);
12
+ const VariantSelectModal = () => /*#__PURE__*/_jsx("div", {});
12
13
  return VariantSelectModal;
13
14
  });
14
15
  jest.mock('@shopgate/engage/components');
15
16
  describe('<Dialog />', () => {
16
17
  it('should render without props', () => {
17
- const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
18
+ const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
18
19
  modal: {
19
20
  message: 'msg'
20
21
  }
@@ -23,7 +24,7 @@ describe('<Dialog />', () => {
23
24
  expect(wrapper.find('TextMessageDialog').length).toBe(1);
24
25
  });
25
26
  it('should render BasicDialog when no message given', () => {
26
- const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
27
+ const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
27
28
  modal: {
28
29
  message: null
29
30
  }
@@ -38,7 +39,7 @@ describe('<Dialog />', () => {
38
39
  pipeline: '',
39
40
  request: {}
40
41
  };
41
- const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
42
+ const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
42
43
  modal: {
43
44
  type: MODAL_PIPELINE_ERROR,
44
45
  params
@@ -52,7 +53,7 @@ describe('<Dialog />', () => {
52
53
  const params = {
53
54
  productId: 'product_1'
54
55
  };
55
- const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
56
+ const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
56
57
  modal: {
57
58
  message: 'Test',
58
59
  type: MODAL_VARIANT_SELECT,
@@ -70,7 +71,7 @@ describe('<Dialog />', () => {
70
71
  };
71
72
 
72
73
  // eslint-disable-next-line extra-rules/no-single-line-objects
73
- const wrapper = shallow(/*#__PURE__*/React.createElement(Dialog, {
74
+ const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
74
75
  modal: {
75
76
  title,
76
77
  titleParams
@@ -11,22 +11,24 @@ import styles from "./style";
11
11
  * @param {string} props.text The text contents of the component.
12
12
  * @returns {JSX.Element}
13
13
  */
14
+ import { jsx as _jsx } from "react/jsx-runtime";
14
15
  const DiscountBadge = ({
15
16
  text,
16
17
  className,
17
18
  display,
18
19
  discount
19
- }) => /*#__PURE__*/React.createElement("div", {
20
+ }) => /*#__PURE__*/_jsx("div", {
20
21
  "data-test-id": text,
21
22
  className: "ui-shared__discount-badge",
22
23
  "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
- }));
24
+ tabIndex: -1,
25
+ children: /*#__PURE__*/_jsx(I18n.Text, {
26
+ className: `${styles[display]} ${className} theme__discount-badge`,
27
+ string: text,
28
+ params: [discount],
29
+ "aria-hidden": true
30
+ })
31
+ });
30
32
  DiscountBadge.defaultProps = {
31
33
  className: '',
32
34
  discount: null,
@@ -1,16 +1,17 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import DiscountBadge from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  jest.mock('@shopgate/engage/components');
5
6
  describe('<DiscountBadge />', () => {
6
7
  it('should render the text', () => {
7
- const wrapper = shallow(/*#__PURE__*/React.createElement(DiscountBadge, {
8
+ const wrapper = shallow(/*#__PURE__*/_jsx(DiscountBadge, {
8
9
  text: "foo"
9
10
  }));
10
11
  expect(wrapper).toMatchSnapshot();
11
12
  });
12
13
  it('should render the text and discount', () => {
13
- const wrapper = shallow(/*#__PURE__*/React.createElement(DiscountBadge, {
14
+ const wrapper = shallow(/*#__PURE__*/_jsx(DiscountBadge, {
14
15
  text: "SAVE {0}%",
15
16
  discount: 20
16
17
  }));
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { Component } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import appConfig from '@shopgate/pwa-common/helpers/config';
@@ -12,95 +13,103 @@ import connect from "./connector";
12
13
  /**
13
14
  * The favorites button component.
14
15
  */
15
- class FavoritesButton extends Component {
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ let FavoritesButton = /*#__PURE__*/function (_Component) {
16
18
  /**
17
19
  * Construct and init state
18
20
  * @param {Object} props Component props
19
21
  */
20
- constructor(props) {
21
- super(props);
22
+ function FavoritesButton(props) {
23
+ var _this;
24
+ _this = _Component.call(this, props) || this;
22
25
  /**
23
26
  * Callback for the moment when the ripple animation is done.
24
27
  */
25
- this.onRippleComplete = () => {
26
- this.props.onRippleComplete(this.props.active);
28
+ _this.onRippleComplete = () => {
29
+ _this.props.onRippleComplete(_this.props.active);
27
30
  };
28
31
  /**
29
32
  * Adds or removes a given product ID from the favorite list.
30
33
  * @param {Object} event The click event object.
31
34
  */
32
- this.handleClick = event => {
35
+ _this.handleClick = event => {
33
36
  event.preventDefault();
34
37
  event.stopPropagation();
35
- if (this.props.once && this.clickedOnce) {
38
+ if (_this.props.once && _this.clickedOnce) {
36
39
  return;
37
40
  }
38
- this.clickedOnce = true;
39
- if (!this.props.productId) {
41
+ _this.clickedOnce = true;
42
+ if (!_this.props.productId) {
40
43
  return;
41
44
  }
42
45
 
43
46
  // 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);
47
+ if (!_this.props.active || _this.props.wishlistItemQuantityEnabled) {
48
+ _this.props.addFavorites(_this.props.productId);
46
49
  } else {
47
50
  setTimeout(() => {
48
- this.props.removeFavorites(this.props.productId, this.props.removeWithRelatives);
49
- }, this.props.removeThrottle);
51
+ _this.props.removeFavorites(_this.props.productId, _this.props.removeWithRelatives);
52
+ }, _this.props.removeThrottle);
50
53
  }
51
54
  };
52
- this.clickedOnce = false;
55
+ _this.clickedOnce = false;
56
+ return _this;
53
57
  }
58
+ _inheritsLoose(FavoritesButton, _Component);
59
+ var _proto = FavoritesButton.prototype;
54
60
  /**
55
61
  * Returns text for aria-label.
56
62
  * @returns {string}
57
63
  */
58
- getLabel() {
64
+ _proto.getLabel = function getLabel() {
59
65
  const {
60
66
  __
61
67
  } = this.context.i18n();
62
68
  const lang = this.props.active ? 'favorites.remove' : 'favorites.add';
63
69
  return __(lang);
64
- }
70
+ };
65
71
  /**
66
72
  * Renders the heart icon as filled or outlined, depending on the favorite button being active.
67
73
  * @returns {JSX}
68
74
  */
69
- renderIcon() {
75
+ _proto.renderIcon = function renderIcon() {
70
76
  if (!this.props.loadWishlistOnAppStartEnabled || this.props.wishlistItemQuantityEnabled && !this.props.active) {
71
- return /*#__PURE__*/React.createElement(HeartPlusOutlineIcon, null);
77
+ return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
72
78
  }
73
79
  if (this.props.wishlistItemQuantityEnabled && this.props.active) {
74
- return /*#__PURE__*/React.createElement(HeartPlus, null);
80
+ return /*#__PURE__*/_jsx(HeartPlus, {});
75
81
  }
76
82
  if (this.props.active) {
77
- return /*#__PURE__*/React.createElement(HeartIcon, null);
83
+ return /*#__PURE__*/_jsx(HeartIcon, {});
78
84
  }
79
- return /*#__PURE__*/React.createElement(HeartOutlineIcon, null);
85
+ return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
80
86
  }
81
87
 
82
88
  /**
83
89
  * Renders the component.
84
90
  * @returns {JSX|null}
85
- */
86
- render() {
91
+ */;
92
+ _proto.render = function render() {
87
93
  if (!appConfig.hasFavorites) {
88
94
  return null;
89
95
  }
90
96
  const className = this.props.noShadow ? styles.buttonFlat : styles.button;
91
- return /*#__PURE__*/React.createElement("button", {
97
+ return /*#__PURE__*/_jsx("button", {
92
98
  "aria-label": this.getLabel(),
93
99
  "aria-hidden": this.props['aria-hidden'],
94
100
  className: `ui-shared__favorites-button ${className} ${this.props.className}`,
95
101
  onClick: this.handleClick,
96
102
  "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
- }
103
+ type: "button",
104
+ children: /*#__PURE__*/_jsx(Ripple, {
105
+ className: `${styles.ripple} ${this.props.rippleClassName}`,
106
+ onComplete: this.onRippleComplete,
107
+ children: this.renderIcon()
108
+ })
109
+ });
110
+ };
111
+ return FavoritesButton;
112
+ }(Component);
104
113
  /**
105
114
  * Context types definition.
106
115
  * @type {{i18n: shim}}
@@ -6,6 +6,7 @@ import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOpti
6
6
  import appConfig from '@shopgate/pwa-common/helpers/config';
7
7
  import FavoritesButton from "./index";
8
8
  import { mockedStateEmpty, mockedStateOnList, mockedStateNotOnList } from "./mock";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
9
10
  const mockedStore = configureStore();
10
11
  const dispatcher = jest.fn();
11
12
  jest.mock('@shopgate/pwa-common/helpers/config');
@@ -29,9 +30,12 @@ describe('<FavoritesButton />', () => {
29
30
  }) => {
30
31
  const store = mockedStore(mockedState);
31
32
  store.dispatch = dispatcher;
32
- return mount(/*#__PURE__*/React.createElement(Provider, {
33
- store: store
34
- }, /*#__PURE__*/React.createElement(FavoritesButton, props)), mockRenderOptions);
33
+ return mount(/*#__PURE__*/_jsx(Provider, {
34
+ store: store,
35
+ children: /*#__PURE__*/_jsx(FavoritesButton, {
36
+ ...props
37
+ })
38
+ }), mockRenderOptions);
35
39
  };
36
40
  beforeEach(() => {
37
41
  dispatcher.mockReset();