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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/AccordionContainer/index.js +17 -11
  2. package/AccordionContainer/spec.js +12 -3
  3. package/ActionButton/index.js +47 -33
  4. package/ActionButton/spec.js +5 -1
  5. package/AddToCartButton/index.js +44 -33
  6. package/AddToCartButton/mock.js +20 -8
  7. package/AddToCartButton/spec.js +4 -3
  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 +10 -9
  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 +12 -10
  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/ScannerBar/components/FlashlightButton/index.js +25 -21
  106. package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +7 -5
  107. package/ScannerOverlay/components/ScannerBar/index.js +17 -12
  108. package/ScannerOverlay/index.js +24 -15
  109. package/Sheet/components/Header/components/SearchBar/index.js +35 -28
  110. package/Sheet/components/Header/components/SearchBar/spec.js +2 -1
  111. package/Sheet/components/Header/index.js +47 -34
  112. package/Sheet/components/Header/spec.js +2 -1
  113. package/Sheet/index.js +80 -65
  114. package/Sheet/spec.js +27 -14
  115. package/TaxDisclaimer/index.js +13 -10
  116. package/TaxDisclaimer/spec.js +3 -2
  117. package/TextField/components/ErrorText/index.js +7 -5
  118. package/TextField/components/FormElement/index.js +4 -3
  119. package/TextField/components/Hint/index.js +7 -5
  120. package/TextField/components/Label/index.js +6 -4
  121. package/TextField/components/Underline/index.js +8 -6
  122. package/TextField/index.js +102 -85
  123. package/TextField/spec.js +37 -23
  124. package/ToggleIcon/index.js +23 -15
  125. package/ToggleIcon/spec.js +12 -8
  126. package/icons/AccountBoxIcon.js +5 -4
  127. package/icons/AddMoreIcon.js +5 -4
  128. package/icons/ArrowDropIcon.js +5 -4
  129. package/icons/ArrowIcon.js +5 -4
  130. package/icons/BarcodeScannerIcon.js +5 -4
  131. package/icons/BoxIcon.js +5 -4
  132. package/icons/BrowseIcon.js +5 -4
  133. package/icons/BurgerIcon.js +5 -4
  134. package/icons/CalendarIcon.js +5 -5
  135. package/icons/CartCouponIcon.js +5 -4
  136. package/icons/CartIcon.js +5 -4
  137. package/icons/CartPlusIcon.js +5 -4
  138. package/icons/CheckIcon.js +5 -4
  139. package/icons/CheckedIcon.js +5 -4
  140. package/icons/ChevronIcon.js +5 -4
  141. package/icons/CreditCardIcon.js +5 -4
  142. package/icons/CrossIcon.js +5 -4
  143. package/icons/DescriptionIcon.js +5 -4
  144. package/icons/FilterIcon.js +5 -4
  145. package/icons/FlashDisabledIcon.js +5 -4
  146. package/icons/FlashEnabledIcon.js +5 -4
  147. package/icons/GridIcon.js +5 -4
  148. package/icons/HeartIcon.js +5 -4
  149. package/icons/HeartOutlineIcon.js +5 -4
  150. package/icons/HeartPlusIcon.js +5 -4
  151. package/icons/HeartPlusOutlineIcon.js +5 -4
  152. package/icons/HomeIcon.js +5 -4
  153. package/icons/InfoIcon.js +5 -4
  154. package/icons/InfoOutlineIcon.js +5 -4
  155. package/icons/ListIcon.js +5 -4
  156. package/icons/LocalShippingIcon.js +5 -4
  157. package/icons/LocationIcon.js +5 -4
  158. package/icons/LocatorIcon.js +5 -4
  159. package/icons/LockIcon.js +5 -4
  160. package/icons/LogoutIcon.js +5 -4
  161. package/icons/MagnifierIcon.js +5 -4
  162. package/icons/MapMarkerIcon.js +5 -4
  163. package/icons/MoreIcon.js +5 -4
  164. package/icons/MoreVertIcon.js +5 -4
  165. package/icons/NotificationIcon.js +5 -4
  166. package/icons/PersonIcon.js +5 -4
  167. package/icons/PhoneIcon.js +5 -4
  168. package/icons/PlaceholderIcon.js +5 -4
  169. package/icons/RadioCheckedIcon.js +5 -4
  170. package/icons/RadioUncheckedIcon.js +5 -4
  171. package/icons/SecurityIcon.js +5 -4
  172. package/icons/ShippingMethodIcon.js +5 -4
  173. package/icons/ShoppingCartIcon.js +5 -4
  174. package/icons/SortIcon.js +5 -4
  175. package/icons/StarHalfIcon.js +5 -4
  176. package/icons/StarIcon.js +5 -4
  177. package/icons/StarOutlineIcon.js +5 -4
  178. package/icons/StopIcon.js +5 -4
  179. package/icons/TickIcon.js +5 -4
  180. package/icons/TimeIcon.js +5 -4
  181. package/icons/TrashIcon.js +5 -4
  182. package/icons/TrashOutlineIcon.js +5 -4
  183. package/icons/UncheckedIcon.js +5 -4
  184. package/icons/ViewListIcon.js +5 -4
  185. package/icons/VisibilityIcon.js +5 -4
  186. package/icons/VisibilityOffIcon.js +5 -4
  187. package/icons/WarningIcon.js +5 -4
  188. package/package.json +7 -8
@@ -2,10 +2,11 @@
2
2
  import React from 'react';
3
3
  import { mount } from 'enzyme';
4
4
  import FormBuilder from '.';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
5
6
  jest.mock('@shopgate/engage/components');
6
7
  describe('<FormBuilder />', () => {
7
8
  it('should render empty form', () => {
8
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
9
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
9
10
  config: {
10
11
  fields: {}
11
12
  },
@@ -15,7 +16,7 @@ describe('<FormBuilder />', () => {
15
16
  expect(wrapper).toMatchSnapshot();
16
17
  });
17
18
  it('should render two text fields', () => {
18
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
19
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
19
20
  config: {
20
21
  fields: {
21
22
  firstName: {
@@ -37,7 +38,7 @@ describe('<FormBuilder />', () => {
37
38
  expect(wrapper.find('TextField').length).toEqual(2);
38
39
  });
39
40
  it('should not render invisible field', () => {
40
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
41
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
41
42
  config: {
42
43
  fields: {
43
44
  firstName: {
@@ -54,7 +55,7 @@ describe('<FormBuilder />', () => {
54
55
  expect(wrapper.find('TextField').length).toEqual(0);
55
56
  });
56
57
  it('should hide element if setVisibilty rule applies', () => {
57
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
58
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
58
59
  config: {
59
60
  fields: {
60
61
  foo: {
@@ -96,7 +97,7 @@ describe('<FormBuilder />', () => {
96
97
  expect(wrapper.find('TextField').length).toEqual(1);
97
98
  });
98
99
  it('should reset value when rule applies', () => {
99
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
100
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
100
101
  config: {
101
102
  fields: {
102
103
  foo: {
@@ -150,7 +151,7 @@ describe('<FormBuilder />', () => {
150
151
  });
151
152
  it('should call onChange callback when input is changed', () => {
152
153
  const handleUpdate = jest.fn();
153
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
154
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
154
155
  config: {
155
156
  fields: {
156
157
  foo: {
@@ -189,7 +190,7 @@ describe('<FormBuilder />', () => {
189
190
  it('should take the updated state from action listener', () => {
190
191
  const handleUpdate = jest.fn();
191
192
  const ref = /*#__PURE__*/React.createRef();
192
- mount(/*#__PURE__*/React.createElement(FormBuilder, {
193
+ mount(/*#__PURE__*/_jsx(FormBuilder, {
193
194
  ref: ref,
194
195
  validationErrors: [],
195
196
  config: {
@@ -228,7 +229,7 @@ describe('<FormBuilder />', () => {
228
229
  // Create mocked Form builder.
229
230
  const handleUpdate = jest.fn();
230
231
  const ref = /*#__PURE__*/React.createRef();
231
- mount(/*#__PURE__*/React.createElement(FormBuilder, {
232
+ mount(/*#__PURE__*/_jsx(FormBuilder, {
232
233
  ref: ref,
233
234
  validationErrors: [{}],
234
235
  config: {
@@ -301,7 +302,7 @@ describe('<FormBuilder />', () => {
301
302
  ...field1,
302
303
  sortOrder: 2
303
304
  }];
304
- expect(fields.sort(builder.elementSortFunc)).toEqual([...fields]);
305
+ expect(fields.sort(builder.elementSortFunc)).toEqual([].concat(fields));
305
306
  });
306
307
  });
307
308
  });
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import React, { PureComponent } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
@@ -27,11 +27,17 @@ import style from "./style";
27
27
  * @extends {React.Component<Props>}
28
28
  * @returns {JSX.Element}
29
29
  */
30
- class Checkbox extends PureComponent {
30
+ import { jsx as _jsx } from "react/jsx-runtime";
31
+ let Checkbox = /*#__PURE__*/function (_PureComponent) {
32
+ function Checkbox() {
33
+ return _PureComponent.apply(this, arguments) || this;
34
+ }
35
+ _inheritsLoose(Checkbox, _PureComponent);
36
+ var _proto = Checkbox.prototype;
31
37
  /**
32
38
  * @return {JSX}
33
39
  */
34
- render() {
40
+ _proto.render = function render() {
35
41
  const {
36
42
  name,
37
43
  label,
@@ -43,7 +49,7 @@ class Checkbox extends PureComponent {
43
49
  checkboxClassName,
44
50
  ...restProps
45
51
  } = this.props;
46
- return /*#__PURE__*/React.createElement(FormElement, {
52
+ return /*#__PURE__*/_jsx(FormElement, {
47
53
  className: classNames(className, style.root, 'checkbox', 'ui-shared__form__checkbox'),
48
54
  htmlFor: name,
49
55
  errorText: errorText,
@@ -51,23 +57,27 @@ class Checkbox extends PureComponent {
51
57
  hasUnderline: false,
52
58
  hasPlaceholder: false,
53
59
  disabled: restProps.disabled,
54
- showErrorText: showErrorText
55
- }, /*#__PURE__*/React.createElement(UICheckbox, _extends({}, restProps, {
56
- className: checkboxClassName,
57
- name: name,
58
- onCheck: onChange,
59
- checkedClassName: `${className} ${style.checked}`,
60
- unCheckedClassName: className,
61
- labelPosition: "right",
62
- label: typeof label === 'string' ? /*#__PURE__*/React.createElement("div", {
63
- className: classNames(style.labelWrapper, 'label')
64
- }, /*#__PURE__*/React.createElement(I18n.Text, {
65
- className: style.label,
66
- string: label
67
- })) : label
68
- })));
69
- }
70
- }
60
+ showErrorText: showErrorText,
61
+ children: /*#__PURE__*/_jsx(UICheckbox, {
62
+ ...restProps,
63
+ className: checkboxClassName,
64
+ name: name,
65
+ onCheck: onChange,
66
+ checkedClassName: `${className} ${style.checked}`,
67
+ unCheckedClassName: className,
68
+ labelPosition: "right",
69
+ label: typeof label === 'string' ? /*#__PURE__*/_jsx("div", {
70
+ className: classNames(style.labelWrapper, 'label'),
71
+ children: /*#__PURE__*/_jsx(I18n.Text, {
72
+ className: style.label,
73
+ string: label
74
+ })
75
+ }) : label
76
+ })
77
+ });
78
+ };
79
+ return Checkbox;
80
+ }(PureComponent);
71
81
  Checkbox.defaultProps = {
72
82
  className: '',
73
83
  checkboxClassName: undefined,
@@ -8,6 +8,7 @@ import style from "./style";
8
8
  * @param {Object} props .
9
9
  * @returns {JSX}
10
10
  */
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const InfoField = props => {
12
13
  const {
13
14
  className,
@@ -20,24 +21,30 @@ const InfoField = props => {
20
21
  hasValue,
21
22
  showErrorText
22
23
  } = props;
23
- return /*#__PURE__*/React.createElement(FormElement, {
24
+ return /*#__PURE__*/_jsx(FormElement, {
24
25
  className: className,
25
26
  label: label,
26
27
  errorText: errorText,
27
28
  hasUnderline: hasUnderline,
28
29
  isFocused: false,
29
30
  hasValue: hasValue,
30
- showErrorText: showErrorText
31
- }, /*#__PURE__*/React.createElement(Grid, null, leftElement && /*#__PURE__*/React.createElement(Grid.Item, {
32
- grow: 0,
33
- className: style.element
34
- }, leftElement), /*#__PURE__*/React.createElement(Grid.Item, {
35
- grow: 1,
36
- className: `${style.info} info-field`
37
- }, children), rightElement && /*#__PURE__*/React.createElement(Grid.Item, {
38
- grow: 0,
39
- className: style.element
40
- }, rightElement)));
31
+ showErrorText: showErrorText,
32
+ children: /*#__PURE__*/_jsxs(Grid, {
33
+ children: [leftElement && /*#__PURE__*/_jsx(Grid.Item, {
34
+ grow: 0,
35
+ className: style.element,
36
+ children: leftElement
37
+ }), /*#__PURE__*/_jsx(Grid.Item, {
38
+ grow: 1,
39
+ className: `${style.info} info-field`,
40
+ children: children
41
+ }), rightElement && /*#__PURE__*/_jsx(Grid.Item, {
42
+ grow: 0,
43
+ className: style.element,
44
+ children: rightElement
45
+ })]
46
+ })
47
+ });
41
48
  };
42
49
  InfoField.defaultProps = {
43
50
  className: '',
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import InfoField from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  describe('<InfoField>', () => {
5
6
  it('should render info field', () => {
6
- const wrapper = shallow(/*#__PURE__*/React.createElement(InfoField, null, 'Some info text'));
7
+ const wrapper = shallow(/*#__PURE__*/_jsx(InfoField, {
8
+ children: "Some info text"
9
+ }));
7
10
  expect(wrapper).toMatchSnapshot();
8
11
  });
9
12
  });
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import React, { Component } from 'react';
3
3
  import ToggleIcon from "../../ToggleIcon";
4
4
  import VisibilityIcon from "../../icons/VisibilityIcon";
@@ -9,47 +9,54 @@ import style from "./style";
9
9
  /**
10
10
  * A component that provides a password field with visibility toggle.
11
11
  */
12
- class Password extends Component {
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let Password = /*#__PURE__*/function (_Component) {
13
14
  /**
14
15
  * Initializes the component.
15
16
  * @param {Object} props The components props.
16
17
  */
17
- constructor(props) {
18
- super(props);
18
+ function Password(props) {
19
+ var _this;
20
+ _this = _Component.call(this, props) || this;
19
21
  /**
20
22
  * @param {boolean} isVisible The next isVisible state.
21
23
  */
22
- this.togglePasswordVisibility = isVisible => {
23
- this.setState({
24
+ _this.togglePasswordVisibility = isVisible => {
25
+ _this.setState({
24
26
  isVisible
25
27
  });
26
28
  };
27
- this.state = {
29
+ _this.state = {
28
30
  isVisible: false
29
31
  };
32
+ return _this;
30
33
  }
34
+ _inheritsLoose(Password, _Component);
35
+ var _proto = Password.prototype;
31
36
  /**
32
37
  * @return {*}
33
38
  */
34
- render() {
39
+ _proto.render = function render() {
35
40
  const {
36
41
  isVisible
37
42
  } = this.state;
38
- return /*#__PURE__*/React.createElement(TextField, _extends({}, this.props, {
43
+ return /*#__PURE__*/_jsx(TextField, {
44
+ ...this.props,
39
45
  className: `ui-shared__form__password ${this.props.className}`,
40
- rightElement: /*#__PURE__*/React.createElement(ToggleIcon, {
46
+ rightElement: /*#__PURE__*/_jsx(ToggleIcon, {
41
47
  on: isVisible,
42
- onIcon: /*#__PURE__*/React.createElement(VisibilityIcon, {
48
+ onIcon: /*#__PURE__*/_jsx(VisibilityIcon, {
43
49
  size: 24
44
50
  }),
45
- offIcon: /*#__PURE__*/React.createElement(VisibilityOffIcon, {
51
+ offIcon: /*#__PURE__*/_jsx(VisibilityOffIcon, {
46
52
  size: 24,
47
53
  className: style.visOff
48
54
  }),
49
55
  toggleHandler: this.togglePasswordVisibility
50
56
  }),
51
57
  type: isVisible ? 'text' : 'password'
52
- }));
53
- }
54
- }
58
+ });
59
+ };
60
+ return Password;
61
+ }(Component);
55
62
  export default Password;
@@ -1,21 +1,24 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import { mount } from 'enzyme';
4
3
  import Password from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  const inputProps = {
6
6
  name: 'test-input'
7
7
  };
8
8
  describe('<Password>', () => {
9
9
  it('should render a password field', () => {
10
- const wrapper = mount(/*#__PURE__*/React.createElement(Password, inputProps));
10
+ const wrapper = mount(/*#__PURE__*/_jsx(Password, {
11
+ ...inputProps
12
+ }));
11
13
  expect(wrapper).toMatchSnapshot();
12
14
  expect(wrapper.find('input[type="password"]').length).toBe(1);
13
15
  });
14
16
  it('should trigger the onChange callback', () => {
15
17
  const onChangeMock = jest.fn();
16
- const wrapper = mount(/*#__PURE__*/React.createElement(Password, _extends({}, inputProps, {
18
+ const wrapper = mount(/*#__PURE__*/_jsx(Password, {
19
+ ...inputProps,
17
20
  onChange: onChangeMock
18
- })));
21
+ }));
19
22
  wrapper.find('input').simulate('change', {
20
23
  target: {
21
24
  value: 'a'
@@ -25,7 +28,9 @@ describe('<Password>', () => {
25
28
  expect(wrapper.find('input').props().value).toEqual('a');
26
29
  });
27
30
  it('should toggle password visibility', () => {
28
- const wrapper = mount(/*#__PURE__*/React.createElement(Password, inputProps));
31
+ const wrapper = mount(/*#__PURE__*/_jsx(Password, {
32
+ ...inputProps
33
+ }));
29
34
  const input = wrapper.find('ToggleIcon');
30
35
  expect(wrapper.find('input[type="password"]').length).toBe(1);
31
36
  input.simulate('click');
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import _camelCase from "lodash/camelCase";
3
3
  import React, { PureComponent } from 'react';
4
4
  import PropTypes from 'prop-types';
@@ -9,12 +9,18 @@ import style from "./style";
9
9
  /**
10
10
  * RadioItem component.
11
11
  */
12
- class RadioItem extends PureComponent {
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ let RadioItem = /*#__PURE__*/function (_PureComponent) {
14
+ function RadioItem() {
15
+ return _PureComponent.apply(this, arguments) || this;
16
+ }
17
+ _inheritsLoose(RadioItem, _PureComponent);
18
+ var _proto = RadioItem.prototype;
13
19
  /**
14
20
  * Renders the component.
15
21
  * @returns {JSX.Element}
16
22
  */
17
- render() {
23
+ _proto.render = function render() {
18
24
  const {
19
25
  label: ItemLabel,
20
26
  name,
@@ -27,31 +33,34 @@ class RadioItem extends PureComponent {
27
33
  const {
28
34
  disabled
29
35
  } = attributes || {};
30
- return /*#__PURE__*/React.createElement("label", {
36
+ return /*#__PURE__*/_jsxs("label", {
31
37
  className: classNames(style.container, className, {
32
38
  [style.disabled]: !!disabled
33
39
  }, _camelCase(name), 'radioItem'),
34
- htmlFor: id || name
35
- }, checked && /*#__PURE__*/React.createElement(CheckedIcon, {
36
- className: classNames(style.active, style.icon, 'checkedIcon')
37
- }), !checked && /*#__PURE__*/React.createElement(UncheckedIcon, {
38
- className: classNames(style.icon, 'uncheckedIcon')
39
- }), /*#__PURE__*/React.createElement("input", _extends({
40
- className: classNames('sr-only', 'input'),
41
- checked: checked,
42
- id: id || name,
43
- type: "radio",
44
- name: name,
45
- onChange: onChange,
46
- "aria-labelledby": `${id || name}-label`
47
- }, attributes)), /*#__PURE__*/React.createElement(I18n.Text, {
48
- string: ItemLabel,
49
- "aria-hidden": true,
50
- id: `${id || name}-label`,
51
- className: classNames(style.label, 'label')
52
- }));
53
- }
54
- }
40
+ htmlFor: id || name,
41
+ children: [checked && /*#__PURE__*/_jsx(CheckedIcon, {
42
+ className: classNames(style.active, style.icon, 'checkedIcon')
43
+ }), !checked && /*#__PURE__*/_jsx(UncheckedIcon, {
44
+ className: classNames(style.icon, 'uncheckedIcon')
45
+ }), /*#__PURE__*/_jsx("input", {
46
+ className: classNames('sr-only', 'input'),
47
+ checked: checked,
48
+ id: id || name,
49
+ type: "radio",
50
+ name: name,
51
+ onChange: onChange,
52
+ "aria-labelledby": `${id || name}-label`,
53
+ ...attributes
54
+ }), /*#__PURE__*/_jsx(I18n.Text, {
55
+ string: ItemLabel,
56
+ "aria-hidden": true,
57
+ id: `${id || name}-label`,
58
+ className: classNames(style.label, 'label')
59
+ })]
60
+ });
61
+ };
62
+ return RadioItem;
63
+ }(PureComponent);
55
64
  RadioItem.defaultProps = {
56
65
  attributes: null,
57
66
  id: null,
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { Component, Children, cloneElement } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import classNames from 'classnames';
@@ -7,51 +8,56 @@ import style from "./style";
7
8
  /**
8
9
  * RadioGroup component.
9
10
  */
10
- class RadioGroup extends Component {
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ let RadioGroup = /*#__PURE__*/function (_Component) {
11
13
  /**
12
14
  * Initializes the component.
13
15
  * @param {Object} props The components props.
14
16
  */
15
- constructor(props) {
16
- super(props);
17
+ function RadioGroup(props) {
18
+ var _this;
19
+ _this = _Component.call(this, props) || this;
17
20
  /**
18
21
  * @param {string} event click from radio element
19
22
  */
20
- this.handleChange = ({
23
+ _this.handleChange = ({
21
24
  target: {
22
25
  name
23
26
  }
24
27
  }) => {
25
- if (this.props.disabled) {
28
+ if (_this.props.disabled) {
26
29
  return;
27
30
  }
28
- if (!this.props.isControlled) {
29
- this.setState({
31
+ if (!_this.props.isControlled) {
32
+ _this.setState({
30
33
  value: name
31
34
  });
32
35
  }
33
- this.props.onChange(name);
36
+ _this.props.onChange(name);
34
37
  };
35
- this.state = {
38
+ _this.state = {
36
39
  value: props.value
37
40
  };
41
+ return _this;
38
42
  }
39
43
 
40
44
  /**
41
45
  * @param {Object} nextProps props
42
46
  */
43
- UNSAFE_componentWillReceiveProps(nextProps) {
47
+ _inheritsLoose(RadioGroup, _Component);
48
+ var _proto = RadioGroup.prototype;
49
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
44
50
  if (this.props.isControlled && this.state.value !== nextProps.value) {
45
51
  this.setState({
46
52
  value: nextProps.value
47
53
  });
48
54
  }
49
- }
55
+ };
50
56
  /**
51
57
  * Renders the component.
52
58
  * @returns {JSX}
53
59
  */
54
- render() {
60
+ _proto.render = function render() {
55
61
  const {
56
62
  children,
57
63
  className,
@@ -63,7 +69,7 @@ class RadioGroup extends Component {
63
69
  disabled,
64
70
  showErrorText
65
71
  } = this.props;
66
- return /*#__PURE__*/React.createElement(FormElement, {
72
+ return /*#__PURE__*/_jsx(FormElement, {
67
73
  className: classNames(className, 'radioGroup', 'ui-shared__form__radio-group', {
68
74
  disabled
69
75
  }),
@@ -74,21 +80,24 @@ class RadioGroup extends Component {
74
80
  showErrorText: showErrorText,
75
81
  htmlFor: "none",
76
82
  hasUnderline: false,
77
- hasValue: true
78
- }, /*#__PURE__*/React.createElement("div", {
79
- className: classNames(style.container(direction), 'radioGroup')
80
- }, Children.map(children, child => {
81
- if (!child) {
82
- return null;
83
- }
84
- return /*#__PURE__*/cloneElement(child, {
85
- key: `${name}_${child.props.name}`,
86
- checked: this.state.value === child.props.name,
87
- onChange: this.handleChange
88
- });
89
- })));
90
- }
91
- }
83
+ hasValue: true,
84
+ children: /*#__PURE__*/_jsx("div", {
85
+ className: classNames(style.container(direction), 'radioGroup'),
86
+ children: Children.map(children, child => {
87
+ if (!child) {
88
+ return null;
89
+ }
90
+ return /*#__PURE__*/cloneElement(child, {
91
+ key: `${name}_${child.props.name}`,
92
+ checked: this.state.value === child.props.name,
93
+ onChange: this.handleChange
94
+ });
95
+ })
96
+ })
97
+ });
98
+ };
99
+ return RadioGroup;
100
+ }(Component);
92
101
  RadioGroup.defaultProps = {
93
102
  onChange: () => {},
94
103
  children: null,
@@ -1,54 +1,66 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import { mount } from 'enzyme';
4
3
  import RadioItem from "./components/Item";
5
4
  import RadioGroup from '.';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  const defProps = {
7
7
  name: 'radio'
8
8
  };
9
9
  jest.mock('@shopgate/engage/components');
10
10
  describe('<RadioGroup />', () => {
11
11
  it('should render empty group', () => {
12
- const wrapper = mount(/*#__PURE__*/React.createElement(RadioGroup, defProps));
12
+ const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
13
+ ...defProps
14
+ }));
13
15
  expect(wrapper).toMatchSnapshot();
14
16
  });
15
17
  it('should render column group with items', () => {
16
- const wrapper = mount(/*#__PURE__*/React.createElement(RadioGroup, defProps, /*#__PURE__*/React.createElement(RadioItem, {
17
- name: "foo",
18
- label: "foo"
19
- })));
18
+ const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
19
+ ...defProps,
20
+ children: /*#__PURE__*/_jsx(RadioItem, {
21
+ name: "foo",
22
+ label: "foo"
23
+ })
24
+ }));
20
25
  expect(wrapper).toMatchSnapshot();
21
26
  expect(wrapper.find(RadioItem).length).toEqual(1);
22
27
  expect(typeof wrapper.find(RadioItem).prop('onChange')).toEqual('function');
23
28
  });
24
29
  it('should render rows group with items', () => {
25
- const wrapper = mount(/*#__PURE__*/React.createElement(RadioGroup, _extends({}, defProps, {
26
- direction: "rows"
27
- }), /*#__PURE__*/React.createElement(RadioItem, {
28
- name: "foo",
29
- label: "foo"
30
- })));
30
+ const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
31
+ ...defProps,
32
+ direction: "rows",
33
+ children: /*#__PURE__*/_jsx(RadioItem, {
34
+ name: "foo",
35
+ label: "foo"
36
+ })
37
+ }));
31
38
  expect(wrapper).toMatchSnapshot();
32
39
  });
33
40
  it('should use default value', () => {
34
- const wrapper = mount(/*#__PURE__*/React.createElement(RadioGroup, _extends({}, defProps, {
35
- value: "foo"
36
- }), /*#__PURE__*/React.createElement(RadioItem, {
37
- name: "foo",
38
- label: "foo"
39
- })));
41
+ const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
42
+ ...defProps,
43
+ value: "foo",
44
+ children: /*#__PURE__*/_jsx(RadioItem, {
45
+ name: "foo",
46
+ label: "foo"
47
+ })
48
+ }));
40
49
  expect(wrapper).toMatchSnapshot();
41
50
  expect(wrapper.find(RadioItem).length).toEqual(1);
42
51
  expect(wrapper.find(RadioItem).prop('checked')).toEqual(true);
43
52
  });
44
53
  it('should have on value at a time', () => {
45
- const wrapper = mount(/*#__PURE__*/React.createElement(RadioGroup, defProps, /*#__PURE__*/React.createElement(RadioItem, {
46
- name: "foo",
47
- label: "foo"
48
- }), /*#__PURE__*/React.createElement(RadioItem, {
49
- name: "bar",
50
- label: "bar"
51
- })));
54
+ const wrapper = mount(/*#__PURE__*/_jsxs(RadioGroup, {
55
+ ...defProps,
56
+ children: [/*#__PURE__*/_jsx(RadioItem, {
57
+ name: "foo",
58
+ label: "foo"
59
+ }), /*#__PURE__*/_jsx(RadioItem, {
60
+ name: "bar",
61
+ label: "bar"
62
+ })]
63
+ }));
52
64
  expect(wrapper).toMatchSnapshot();
53
65
  expect(wrapper.find(RadioItem).length).toEqual(2);
54
66
  const radio1 = wrapper.find(RadioItem).at(0).find('input');
@@ -68,12 +80,14 @@ describe('<RadioGroup />', () => {
68
80
  });
69
81
  it('should call onChange callback', () => {
70
82
  const onChange = jest.fn();
71
- const wrapper = mount(/*#__PURE__*/React.createElement(RadioGroup, _extends({}, defProps, {
72
- onChange: onChange
73
- }), /*#__PURE__*/React.createElement(RadioItem, {
74
- name: "foo",
75
- label: "foo"
76
- })));
83
+ const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
84
+ ...defProps,
85
+ onChange: onChange,
86
+ children: /*#__PURE__*/_jsx(RadioItem, {
87
+ name: "foo",
88
+ label: "foo"
89
+ })
90
+ }));
77
91
  expect(wrapper).toMatchSnapshot();
78
92
  expect(wrapper.find(RadioItem).length).toEqual(1);
79
93
  const radio = wrapper.find(RadioItem).at(0).find('input');