@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
@@ -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 PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
@@ -9,54 +9,59 @@ import styles from "./style";
9
9
  /**
10
10
  * A component that provides a styled select for user input in material design.
11
11
  */
12
- class Select extends Component {
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ let Select = /*#__PURE__*/function (_Component) {
13
14
  /**
14
15
  * Creates a new text field component.
15
16
  * @param {Object} props The component properties.
16
17
  */
17
- constructor(props) {
18
- super(props);
18
+ function Select(props) {
19
+ var _this;
20
+ _this = _Component.call(this, props) || this;
19
21
  /**
20
22
  * @param {string} value The entered text.
21
23
  */
22
- this.handleChange = ({
24
+ _this.handleChange = ({
23
25
  target
24
26
  }) => {
25
27
  const {
26
28
  multiple
27
- } = this.props;
29
+ } = _this.props;
28
30
  let {
29
31
  value
30
32
  } = target;
31
33
  if (multiple) {
32
34
  value = Array.from(target.selectedOptions, option => option.value);
33
35
  }
34
- if (!this.props.isControlled) {
35
- this.setState({
36
+ if (!_this.props.isControlled) {
37
+ _this.setState({
36
38
  value
37
39
  });
38
40
  }
39
- this.props.onChange(value);
41
+ _this.props.onChange(value);
40
42
  };
41
43
  /**
42
44
  * @param {boolean} isFocused focused
43
45
  */
44
- this.handleFocusChange = isFocused => {
45
- this.setState({
46
+ _this.handleFocusChange = isFocused => {
47
+ _this.setState({
46
48
  isFocused
47
49
  });
48
50
  };
49
- this.state = {
51
+ _this.state = {
50
52
  value: props.value,
51
53
  isFocused: false
52
54
  };
55
+ return _this;
53
56
  }
54
57
 
55
58
  /**
56
59
  * Corrects the selected value to the first option when the initial value is not located within
57
60
  * the options.
58
61
  */
59
- componentDidMount() {
62
+ _inheritsLoose(Select, _Component);
63
+ var _proto = Select.prototype;
64
+ _proto.componentDidMount = function componentDidMount() {
60
65
  const {
61
66
  multiple,
62
67
  options
@@ -79,16 +84,16 @@ class Select extends Component {
79
84
  /**
80
85
  * Update state with new props.
81
86
  * @param {Object} nextProps The new props.
82
- */
83
- UNSAFE_componentWillReceiveProps(nextProps) {
87
+ */;
88
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
84
89
  this.setState({
85
90
  value: nextProps.value
86
91
  });
87
- }
92
+ };
88
93
  /**
89
94
  * @return {JSX.Element}
90
95
  */
91
- render() {
96
+ _proto.render = function render() {
92
97
  const {
93
98
  name,
94
99
  options,
@@ -109,7 +114,7 @@ class Select extends Component {
109
114
  value,
110
115
  isFocused
111
116
  } = this.state;
112
- return /*#__PURE__*/React.createElement(FormElement, {
117
+ return /*#__PURE__*/_jsxs(FormElement, {
113
118
  className: `${className} ui-shared__form__select`,
114
119
  placeholder: placeholder,
115
120
  htmlFor: name,
@@ -120,31 +125,35 @@ class Select extends Component {
120
125
  hasValue: !!value || !!options[''],
121
126
  hasPlaceholder: !disabled || value !== '',
122
127
  disabled: disabled,
123
- showErrorText: showErrorText
124
- }, /*#__PURE__*/React.createElement("select", _extends({
125
- id: name,
126
- name: name,
127
- onChange: this.handleChange,
128
- onFocus: () => this.handleFocusChange(true),
129
- onBlur: () => this.handleFocusChange(false),
130
- value: value,
131
- className: classNames(styles.select, 'select'),
132
- disabled: disabled,
133
- required: required,
134
- "aria-invalid": ariaInvalid,
135
- "aria-describedby": ariaDescribedBy
136
- }, multiple && {
137
- multiple,
138
- size
139
- }), Object.keys(options).map(key => /*#__PURE__*/React.createElement("option", {
140
- className: "option",
141
- value: key,
142
- key: `${name}_${key}`
143
- }, options[key]))), /*#__PURE__*/React.createElement(Chevron, {
144
- className: styles.chevron
145
- }));
146
- }
147
- }
128
+ showErrorText: showErrorText,
129
+ children: [/*#__PURE__*/_jsx("select", {
130
+ id: name,
131
+ name: name,
132
+ onChange: this.handleChange,
133
+ onFocus: () => this.handleFocusChange(true),
134
+ onBlur: () => this.handleFocusChange(false),
135
+ value: value,
136
+ className: classNames(styles.select, 'select'),
137
+ disabled: disabled,
138
+ required: required,
139
+ "aria-invalid": ariaInvalid,
140
+ "aria-describedby": ariaDescribedBy,
141
+ ...(multiple && {
142
+ multiple,
143
+ size
144
+ }),
145
+ children: Object.keys(options).map(key => /*#__PURE__*/_jsx("option", {
146
+ className: "option",
147
+ value: key,
148
+ children: options[key]
149
+ }, `${name}_${key}`))
150
+ }), /*#__PURE__*/_jsx(Chevron, {
151
+ className: styles.chevron
152
+ })]
153
+ });
154
+ };
155
+ return Select;
156
+ }(Component);
148
157
  Select.defaultProps = {
149
158
  'aria-invalid': false,
150
159
  'aria-describedby': null,
@@ -1,7 +1,7 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import { mount } from 'enzyme';
4
3
  import Select from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  const inputProps = {
6
6
  name: 'test-name'
7
7
  };
@@ -29,7 +29,10 @@ describe('<Select />', () => {
29
29
  it(test, () => {
30
30
  const testFixtures = tests[test];
31
31
  // eslint-disable-next-line extra-rules/no-single-line-objects
32
- const wrapper = mount(/*#__PURE__*/React.createElement(Select, _extends({}, inputProps, testFixtures)));
32
+ const wrapper = mount(/*#__PURE__*/_jsx(Select, {
33
+ ...inputProps,
34
+ ...testFixtures
35
+ }));
33
36
  expect(wrapper).toMatchSnapshot();
34
37
  });
35
38
  });
@@ -1,4 +1,4 @@
1
- import React, { useState, useCallback, Fragment } from 'react';
1
+ import React, { useState, useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import pick from 'lodash/pick';
4
4
  import { i18n } from '@shopgate/engage/core';
@@ -11,6 +11,7 @@ import styles from "./style";
11
11
  * @param {Object} props .
12
12
  * @returns {JSX}
13
13
  */
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
15
  const SelectContextChoices = ({
15
16
  options,
16
17
  onChange,
@@ -34,37 +35,40 @@ const SelectContextChoices = ({
34
35
  // Eliminate value
35
36
  onChange(value.filter(v => v !== key));
36
37
  } else {
37
- onChange([...value, key]);
38
+ onChange([].concat(value, [key]));
38
39
  }
39
40
  }, [onChange, value]);
40
41
  const hasValue = !!value && !!value.length;
41
42
  const values = hasValue ? Object.values(pick(options, value)) : [];
42
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(InfoField, {
43
+ return /*#__PURE__*/_jsxs(InfoField, {
43
44
  className: className,
44
45
  label: label,
45
46
  errorText: errorText,
46
47
  showErrorText: showErrorText,
47
48
  hasValue: true,
48
- rightElement: /*#__PURE__*/React.createElement(Chevron, {
49
+ rightElement: /*#__PURE__*/_jsx(Chevron, {
49
50
  className: styles.chevron
50
- })
51
- }, /*#__PURE__*/React.createElement("div", {
52
- role: "button",
53
- onClick: () => setOpened(true),
54
- "aria-hidden": true,
55
- tabIndex: "0",
56
- className: styles.toggle
57
- }, !hasValue && (placeholder || i18n.text('common.please_choose')), hasValue && values.join(', ')), /*#__PURE__*/React.createElement(ContextMenu, {
58
- isOpened: opened,
59
- onStateChange: onMenuChange,
60
- showToggle: false,
61
- scroll: true
62
- }, Object.keys(options).map(key => /*#__PURE__*/React.createElement(ContextMenu.Item, {
63
- key: key,
64
- autoClose: false,
65
- onClick: () => onItemClick(key),
66
- className: hasValue && value.includes(key) ? styles.itemSelected : ''
67
- }, options[key])))));
51
+ }),
52
+ children: [/*#__PURE__*/_jsxs("div", {
53
+ role: "button",
54
+ onClick: () => setOpened(true),
55
+ "aria-hidden": true,
56
+ tabIndex: "0",
57
+ className: styles.toggle,
58
+ children: [!hasValue && (placeholder || i18n.text('common.please_choose')), hasValue && values.join(', ')]
59
+ }), /*#__PURE__*/_jsx(ContextMenu, {
60
+ isOpened: opened,
61
+ onStateChange: onMenuChange,
62
+ showToggle: false,
63
+ scroll: true,
64
+ children: Object.keys(options).map(key => /*#__PURE__*/_jsx(ContextMenu.Item, {
65
+ autoClose: false,
66
+ onClick: () => onItemClick(key),
67
+ className: hasValue && value.includes(key) ? styles.itemSelected : '',
68
+ children: options[key]
69
+ }, key))
70
+ })]
71
+ });
68
72
  };
69
73
  SelectContextChoices.defaultProps = {
70
74
  className: '',
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import SelectContextChoices from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  jest.mock('@shopgate/engage/a11y/components');
5
6
  jest.mock('@shopgate/engage/components');
6
7
  describe('<SelectContextChoices />', () => {
@@ -26,7 +27,9 @@ describe('<SelectContextChoices />', () => {
26
27
  Object.keys(tests).forEach(test => {
27
28
  it(test, () => {
28
29
  const testFixtures = tests[test];
29
- const wrapper = shallow(/*#__PURE__*/React.createElement(SelectContextChoices, testFixtures));
30
+ const wrapper = shallow(/*#__PURE__*/_jsx(SelectContextChoices, {
31
+ ...testFixtures
32
+ }));
30
33
  expect(wrapper).toMatchSnapshot();
31
34
  });
32
35
  });
@@ -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 PropTypes from 'prop-types';
4
4
  import Input from '@shopgate/pwa-common/components/Input';
@@ -9,37 +9,42 @@ import style from "./style";
9
9
  /**
10
10
  * No operational
11
11
  */
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  const noop = () => {};
13
14
 
14
15
  /**
15
16
  * TextField component
16
17
  */
17
- class TextField extends Component {
18
+ let TextField = /*#__PURE__*/function (_Component) {
18
19
  /**
19
20
  * Creates a new text field component.
20
21
  * @param {Object} props The component properties.
21
22
  */
22
- constructor(props) {
23
- super(props);
23
+ function TextField(props) {
24
+ var _this;
25
+ _this = _Component.call(this, props) || this;
24
26
  /**
25
27
  * Internal focus event handler.
26
28
  * @param {boolean} isFocused Whether the input component is focused.
27
29
  */
28
- this.handleFocusChange = isFocused => {
29
- this.setState({
30
+ _this.handleFocusChange = isFocused => {
31
+ _this.setState({
30
32
  isFocused
31
33
  });
32
- this.props.onFocusChange(isFocused);
34
+ _this.props.onFocusChange(isFocused);
33
35
  };
34
- this.state = {
36
+ _this.state = {
35
37
  isFocused: false
36
38
  };
39
+ return _this;
37
40
  }
41
+ _inheritsLoose(TextField, _Component);
42
+ var _proto = TextField.prototype;
38
43
  /**
39
44
  * Renders the text field.
40
45
  * @return {JSX.Element}
41
46
  */
42
- render() {
47
+ _proto.render = function render() {
43
48
  const {
44
49
  className,
45
50
  placeholder,
@@ -50,7 +55,7 @@ class TextField extends Component {
50
55
  hasUnderline,
51
56
  ...props
52
57
  } = this.props;
53
- return /*#__PURE__*/React.createElement(FormElement, {
58
+ return /*#__PURE__*/_jsx(FormElement, {
54
59
  className: `${className} ui-shared__form__text-field`,
55
60
  htmlFor: props.name,
56
61
  placeholder: placeholder,
@@ -59,26 +64,34 @@ class TextField extends Component {
59
64
  hasLeftElement: !!leftElement,
60
65
  hasUnderline: hasUnderline,
61
66
  hasValue: !!props.value,
62
- isFocused: this.state.isFocused
63
- }, /*#__PURE__*/React.createElement(Grid, null, leftElement && /*#__PURE__*/React.createElement(Grid.Item, {
64
- grow: 0,
65
- className: style.element
66
- }, leftElement), /*#__PURE__*/React.createElement(Grid.Item, {
67
- grow: 1,
68
- className: style.container
69
- }, /*#__PURE__*/React.createElement(Input, _extends({}, props, {
70
- onFocusChange: this.handleFocusChange,
71
- className: `
67
+ isFocused: this.state.isFocused,
68
+ children: /*#__PURE__*/_jsxs(Grid, {
69
+ children: [leftElement && /*#__PURE__*/_jsx(Grid.Item, {
70
+ grow: 0,
71
+ className: style.element,
72
+ children: leftElement
73
+ }), /*#__PURE__*/_jsx(Grid.Item, {
74
+ grow: 1,
75
+ className: style.container,
76
+ children: /*#__PURE__*/_jsx(Input, {
77
+ ...props,
78
+ onFocusChange: this.handleFocusChange,
79
+ className: `
72
80
  ${style[props.multiLine ? 'multiLine' : 'input']}
73
81
  ${leftElement ? style.leftOffset : ''}
74
82
  `,
75
- validateOnBlur: true
76
- }))), rightElement && /*#__PURE__*/React.createElement(Grid.Item, {
77
- grow: 0,
78
- className: style.element
79
- }, rightElement)));
80
- }
81
- }
83
+ validateOnBlur: true
84
+ })
85
+ }), rightElement && /*#__PURE__*/_jsx(Grid.Item, {
86
+ grow: 0,
87
+ className: style.element,
88
+ children: rightElement
89
+ })]
90
+ })
91
+ });
92
+ };
93
+ return TextField;
94
+ }(Component);
82
95
  TextField.defaultProps = {
83
96
  attributes: null,
84
97
  className: '',
@@ -1,35 +1,40 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import { mount } from 'enzyme';
4
3
  import TextField 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('<TextField>', () => {
9
9
  it('should render a simple text field', () => {
10
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, inputProps));
10
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
11
+ ...inputProps
12
+ }));
11
13
  expect(wrapper).toMatchSnapshot();
12
14
  expect(wrapper.find('input').length).toBe(1);
13
15
  });
14
16
  it('should render the text field as password', () => {
15
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
17
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
18
+ ...inputProps,
16
19
  password: true
17
- })));
20
+ }));
18
21
  expect(wrapper).toMatchSnapshot();
19
22
  expect(wrapper.find('input[type="password"]').length).toBe(1);
20
23
  });
21
24
  it('should render the text field with a default value', () => {
22
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
25
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
26
+ ...inputProps,
23
27
  value: "FooBar"
24
- })));
28
+ }));
25
29
  expect(wrapper).toMatchSnapshot();
26
30
  expect(wrapper.find('input[value="FooBar"]').length).toBe(1);
27
31
  });
28
32
  it('should trigger the onChange callback', () => {
29
33
  const onChangeMock = jest.fn();
30
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
34
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
35
+ ...inputProps,
31
36
  onChange: onChangeMock
32
- })));
37
+ }));
33
38
  wrapper.find('input').simulate('change', {
34
39
  target: {
35
40
  value: 'a'
@@ -39,7 +44,9 @@ describe('<TextField>', () => {
39
44
  expect(wrapper.find('input').props().value).toEqual('a');
40
45
  });
41
46
  it('should receive the correct value while typing', () => {
42
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, inputProps));
47
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
48
+ ...inputProps
49
+ }));
43
50
  const input = wrapper.find('input');
44
51
  input.simulate('change', {
45
52
  target: {
@@ -50,9 +57,10 @@ describe('<TextField>', () => {
50
57
  expect(input.instance().value).toBe('foobar');
51
58
  });
52
59
  it('should sanitize the input', () => {
53
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
60
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
61
+ ...inputProps,
54
62
  onSanitize: value => value.toUpperCase()
55
- })));
63
+ }));
56
64
  const input = wrapper.find('input');
57
65
  input.simulate('change', {
58
66
  target: {
@@ -64,17 +72,19 @@ describe('<TextField>', () => {
64
72
  });
65
73
  it('should trigger the validation callback', () => {
66
74
  const onValidateMock = jest.fn();
67
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
75
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
76
+ ...inputProps,
68
77
  onValidate: onValidateMock
69
- })));
78
+ }));
70
79
  expect(wrapper).toMatchSnapshot();
71
80
  expect(onValidateMock).toHaveBeenCalled();
72
81
  });
73
82
  it('should focus the input', () => {
74
83
  const onFocusMock = jest.fn();
75
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
84
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
85
+ ...inputProps,
76
86
  onFocusChange: onFocusMock
77
- })));
87
+ }));
78
88
  const input = wrapper.find('SimpleInput');
79
89
  expect(wrapper).toMatchSnapshot();
80
90
  expect(input.instance().isFocused).toBe(false);
@@ -85,25 +95,28 @@ describe('<TextField>', () => {
85
95
  });
86
96
  it('should show the error message', () => {
87
97
  const errorText = 'This is an error here';
88
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
98
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
99
+ ...inputProps,
89
100
  errorText: errorText
90
- })));
101
+ }));
91
102
  expect(wrapper).toMatchSnapshot();
92
103
  expect(wrapper.find('ErrorText').find('Translate').at(0).props().string).toEqual(errorText);
93
104
  });
94
105
  it('should show the label', () => {
95
106
  const label = 'This is the label';
96
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
107
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
108
+ ...inputProps,
97
109
  label: label
98
- })));
110
+ }));
99
111
  expect(wrapper).toMatchSnapshot();
100
112
  expect(wrapper.find('Label').find('Translate').props().string).toEqual(label);
101
113
  });
102
114
  it('should show the placeholder text', () => {
103
115
  const placeholder = 'This is the placeholder text';
104
- const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
116
+ const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
117
+ ...inputProps,
105
118
  placeholder: placeholder
106
- })));
119
+ }));
107
120
  expect(wrapper).toMatchSnapshot();
108
121
  expect(wrapper.find('Placeholder').find('Translate').at(0).props().string).toEqual(placeholder);
109
122
  });
package/Form/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { PureComponent } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
 
@@ -5,53 +6,60 @@ import PropTypes from 'prop-types';
5
6
  * Form component that handles keyboard submit, next buttons, ...
6
7
  * @deprecated Use `@shopgate/engage/components/Form` instead.
7
8
  */
8
- class Form extends PureComponent {
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ let Form = /*#__PURE__*/function (_PureComponent) {
9
11
  /**
10
12
  * Initializes the form component.
11
13
  * @param {Object} props The components props.
12
14
  */
13
- constructor(props) {
14
- super(props);
15
+ function Form(props) {
16
+ var _this;
17
+ _this = _PureComponent.call(this, props) || this;
15
18
  /**
16
19
  * Handles the form submit.
17
20
  * @param {Object} event The event that caused the submit.
18
21
  */
19
- this.handleSubmit = event => {
22
+ _this.handleSubmit = event => {
20
23
  event.preventDefault();
21
- const inputFocused = [...this.formElement.current.querySelectorAll('input')].some(input => document.activeElement === input);
24
+ const inputFocused = [].concat(_this.formElement.current.querySelectorAll('input')).some(input => document.activeElement === input);
22
25
  if (inputFocused) {
23
26
  document.activeElement.blur();
24
27
  }
25
- this.props.onSubmit();
28
+ _this.props.onSubmit();
26
29
  };
27
30
  /**
28
31
  * Handles form submits by key.
29
32
  * @param {Object} event The event that caused the keypress.
30
33
  */
31
- this.handleKeyPress = event => {
34
+ _this.handleKeyPress = event => {
32
35
  // Enter key and on iOS also the "Done" button.
33
36
  if (event.which === 13) {
34
- this.handleSubmit(event);
37
+ _this.handleSubmit(event);
35
38
  }
36
39
  };
37
- this.formElement = /*#__PURE__*/React.createRef();
40
+ _this.formElement = /*#__PURE__*/React.createRef();
41
+ return _this;
38
42
  }
43
+ _inheritsLoose(Form, _PureComponent);
44
+ var _proto = Form.prototype;
39
45
  /**
40
46
  * Renders the component.
41
47
  * @returns {JSX}
42
48
  */
43
- render() {
49
+ _proto.render = function render() {
44
50
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
45
- return /*#__PURE__*/React.createElement("form", {
51
+ return /*#__PURE__*/_jsx("form", {
46
52
  action: "#",
47
53
  onSubmit: this.handleSubmit,
48
54
  onKeyPress: this.handleKeyPress,
49
55
  ref: this.formElement,
50
- className: "ui-shared__form"
51
- }, this.props.children);
56
+ className: "ui-shared__form",
57
+ children: this.props.children
58
+ });
52
59
  /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
53
- }
54
- }
60
+ };
61
+ return Form;
62
+ }(PureComponent);
55
63
  Form.defaultProps = {
56
64
  onSubmit: () => {}
57
65
  };
@@ -9,21 +9,23 @@ import styles from "./style";
9
9
  * @param {Object} props The component props.
10
10
  * @returns {JSX.Element}
11
11
  */
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  const ErrorText = ({
13
14
  className,
14
15
  errorText,
15
16
  translate,
16
17
  elementName,
17
18
  ariaHidden
18
- }) => /*#__PURE__*/React.createElement("div", {
19
+ }) => /*#__PURE__*/_jsxs("div", {
19
20
  id: `ariaError-${elementName}`,
20
21
  className: classNames(className, styles, 'errorText'),
21
22
  "aria-live": "assertive",
22
23
  "aria-atomic": "true",
23
- "aria-hidden": ariaHidden
24
- }, translate && /*#__PURE__*/React.createElement(I18n.Text, {
25
- string: errorText
26
- }), !translate && errorText);
24
+ "aria-hidden": ariaHidden,
25
+ children: [translate && /*#__PURE__*/_jsx(I18n.Text, {
26
+ string: errorText
27
+ }), !translate && errorText]
28
+ });
27
29
  ErrorText.defaultProps = {
28
30
  className: null,
29
31
  errorText: null,
@@ -9,6 +9,7 @@ import styles from "./style";
9
9
  * @param {Object} props The component props.
10
10
  * @return {JSX}
11
11
  */
12
+ import { jsx as _jsx } from "react/jsx-runtime";
12
13
  const Label = ({
13
14
  hasErrorMessage,
14
15
  htmlFor,
@@ -18,14 +19,15 @@ const Label = ({
18
19
  labelStatic
19
20
  }) => {
20
21
  const labelStyles = styles.labelStyles(isFocused, isFloating, hasErrorMessage, labelStatic);
21
- return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/label-has-associated-control */React.createElement("label", {
22
+ return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/label-has-associated-control */_jsx("label", {
22
23
  htmlFor: htmlFor,
23
24
  className: classNames(labelStyles, 'label', {
24
25
  floating: isFloating
26
+ }),
27
+ children: /*#__PURE__*/_jsx(I18n.Text, {
28
+ string: label
25
29
  })
26
- }, /*#__PURE__*/React.createElement(I18n.Text, {
27
- string: label
28
- }));
30
+ });
29
31
  };
30
32
  Label.defaultProps = {
31
33
  htmlFor: '',