@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
@@ -2,9 +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";
6
+ jest.mock('@shopgate/engage/components');
5
7
  describe('<FormBuilder />', () => {
6
8
  it('should render empty form', () => {
7
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
9
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
8
10
  config: {
9
11
  fields: {}
10
12
  },
@@ -14,7 +16,7 @@ describe('<FormBuilder />', () => {
14
16
  expect(wrapper).toMatchSnapshot();
15
17
  });
16
18
  it('should render two text fields', () => {
17
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
19
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
18
20
  config: {
19
21
  fields: {
20
22
  firstName: {
@@ -36,7 +38,7 @@ describe('<FormBuilder />', () => {
36
38
  expect(wrapper.find('TextField').length).toEqual(2);
37
39
  });
38
40
  it('should not render invisible field', () => {
39
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
41
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
40
42
  config: {
41
43
  fields: {
42
44
  firstName: {
@@ -53,7 +55,7 @@ describe('<FormBuilder />', () => {
53
55
  expect(wrapper.find('TextField').length).toEqual(0);
54
56
  });
55
57
  it('should hide element if setVisibilty rule applies', () => {
56
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
58
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
57
59
  config: {
58
60
  fields: {
59
61
  foo: {
@@ -95,7 +97,7 @@ describe('<FormBuilder />', () => {
95
97
  expect(wrapper.find('TextField').length).toEqual(1);
96
98
  });
97
99
  it('should reset value when rule applies', () => {
98
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
100
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
99
101
  config: {
100
102
  fields: {
101
103
  foo: {
@@ -149,7 +151,7 @@ describe('<FormBuilder />', () => {
149
151
  });
150
152
  it('should call onChange callback when input is changed', () => {
151
153
  const handleUpdate = jest.fn();
152
- const wrapper = mount(/*#__PURE__*/React.createElement(FormBuilder, {
154
+ const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
153
155
  config: {
154
156
  fields: {
155
157
  foo: {
@@ -186,9 +188,10 @@ describe('<FormBuilder />', () => {
186
188
  });
187
189
  describe('FormBuilder::elementChangeHandler', () => {
188
190
  it('should take the updated state from action listener', () => {
189
- // Create mocked Form builder.
190
191
  const handleUpdate = jest.fn();
191
- const builder = new FormBuilder({
192
+ const ref = /*#__PURE__*/React.createRef();
193
+ mount(/*#__PURE__*/_jsx(FormBuilder, {
194
+ ref: ref,
192
195
  validationErrors: [],
193
196
  config: {
194
197
  fields: {
@@ -200,9 +203,11 @@ describe('<FormBuilder />', () => {
200
203
  }
201
204
  }
202
205
  },
203
- handleUpdate
204
- });
205
- builder.actionListener.notify = () => ({
206
+ name: "foo",
207
+ id: "foo",
208
+ handleUpdate: handleUpdate
209
+ }));
210
+ ref.current.actionListener.notify = () => ({
206
211
  formData: {
207
212
  foo: 'bar'
208
213
  },
@@ -213,7 +218,7 @@ describe('<FormBuilder />', () => {
213
218
  });
214
219
 
215
220
  // Trigger update
216
- builder.elementChangeHandler('foo', 'bar');
221
+ ref.current.elementChangeHandler('foo', 'bar');
217
222
 
218
223
  // Test
219
224
  expect(handleUpdate).toHaveBeenCalledWith({
@@ -223,7 +228,9 @@ describe('<FormBuilder />', () => {
223
228
  it('should consider backend validations', () => {
224
229
  // Create mocked Form builder.
225
230
  const handleUpdate = jest.fn();
226
- const builder = new FormBuilder({
231
+ const ref = /*#__PURE__*/React.createRef();
232
+ mount(/*#__PURE__*/_jsx(FormBuilder, {
233
+ ref: ref,
227
234
  validationErrors: [{}],
228
235
  config: {
229
236
  fields: {
@@ -235,9 +242,11 @@ describe('<FormBuilder />', () => {
235
242
  }
236
243
  }
237
244
  },
238
- handleUpdate
239
- });
240
- builder.actionListener.notify = () => ({
245
+ name: "foo",
246
+ id: "foo",
247
+ handleUpdate: handleUpdate
248
+ }));
249
+ ref.current.actionListener.notify = () => ({
241
250
  formData: {
242
251
  foo: 'bar'
243
252
  },
@@ -248,7 +257,7 @@ describe('<FormBuilder />', () => {
248
257
  });
249
258
 
250
259
  // Trigger update
251
- builder.elementChangeHandler('foo', 'bar');
260
+ ref.current.elementChangeHandler('foo', 'bar');
252
261
 
253
262
  // Test
254
263
  expect(handleUpdate).toHaveBeenCalledWith({
@@ -293,7 +302,7 @@ describe('<FormBuilder />', () => {
293
302
  ...field1,
294
303
  sortOrder: 2
295
304
  }];
296
- expect(fields.sort(builder.elementSortFunc)).toEqual([...fields]);
305
+ expect(fields.sort(builder.elementSortFunc)).toEqual([].concat(fields));
297
306
  });
298
307
  });
299
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,