@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,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
  import Checkbox from "../../Checkbox";
@@ -7,11 +8,17 @@ import Checkbox from "../../Checkbox";
7
8
  * @param {Object} element The data of the element to be rendered
8
9
  * @returns {JSX}
9
10
  */
10
- class CheckboxElement extends PureComponent {
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ let CheckboxElement = /*#__PURE__*/function (_PureComponent) {
13
+ function CheckboxElement() {
14
+ return _PureComponent.apply(this, arguments) || this;
15
+ }
16
+ _inheritsLoose(CheckboxElement, _PureComponent);
17
+ var _proto = CheckboxElement.prototype;
11
18
  /**
12
19
  * @returns {JSX}
13
20
  */
14
- render() {
21
+ _proto.render = function render() {
15
22
  const {
16
23
  element,
17
24
  style,
@@ -19,7 +26,7 @@ class CheckboxElement extends PureComponent {
19
26
  value,
20
27
  name
21
28
  } = this.props;
22
- return /*#__PURE__*/React.createElement(Checkbox, {
29
+ return /*#__PURE__*/_jsx(Checkbox, {
23
30
  name: name,
24
31
  errorText: errorText,
25
32
  checked: value,
@@ -28,8 +35,9 @@ class CheckboxElement extends PureComponent {
28
35
  onChange: element.handleChange,
29
36
  translateErrorText: false
30
37
  });
31
- }
32
- }
38
+ };
39
+ return CheckboxElement;
40
+ }(PureComponent);
33
41
  CheckboxElement.defaultProps = {
34
42
  value: false,
35
43
  style: {
@@ -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
  import Select from "../../Select";
@@ -7,11 +8,17 @@ import Select from "../../Select";
7
8
  * with a list of countries to select from.
8
9
  * @returns {JSX}
9
10
  */
10
- class CountryElement extends PureComponent {
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ let CountryElement = /*#__PURE__*/function (_PureComponent) {
13
+ function CountryElement() {
14
+ return _PureComponent.apply(this, arguments) || this;
15
+ }
16
+ _inheritsLoose(CountryElement, _PureComponent);
17
+ var _proto = CountryElement.prototype;
11
18
  /**
12
19
  * @returns {JSX}
13
20
  */
14
- render() {
21
+ _proto.render = function render() {
15
22
  const {
16
23
  countryList,
17
24
  element,
@@ -20,7 +27,7 @@ class CountryElement extends PureComponent {
20
27
  style,
21
28
  value
22
29
  } = this.props;
23
- return /*#__PURE__*/React.createElement(Select, {
30
+ return /*#__PURE__*/_jsx(Select, {
24
31
  name: name,
25
32
  className: style.fields,
26
33
  label: element.label,
@@ -32,8 +39,9 @@ class CountryElement extends PureComponent {
32
39
  isControlled: true,
33
40
  translateErrorText: false
34
41
  });
35
- }
36
- }
42
+ };
43
+ return CountryElement;
44
+ }(PureComponent);
37
45
  CountryElement.defaultProps = {
38
46
  countryList: {},
39
47
  value: '',
@@ -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
  import Select from "../../Select";
@@ -7,11 +8,17 @@ import Select from "../../Select";
7
8
  * with a list of provinces to select from.
8
9
  * @returns {JSX}
9
10
  */
10
- class ProvinceElement extends PureComponent {
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ let ProvinceElement = /*#__PURE__*/function (_PureComponent) {
13
+ function ProvinceElement() {
14
+ return _PureComponent.apply(this, arguments) || this;
15
+ }
16
+ _inheritsLoose(ProvinceElement, _PureComponent);
17
+ var _proto = ProvinceElement.prototype;
11
18
  /**
12
19
  * @returns {JSX}
13
20
  */
14
- render() {
21
+ _proto.render = function render() {
15
22
  const {
16
23
  provincesList,
17
24
  element,
@@ -20,7 +27,7 @@ class ProvinceElement extends PureComponent {
20
27
  style,
21
28
  value
22
29
  } = this.props;
23
- return /*#__PURE__*/React.createElement(Select, {
30
+ return /*#__PURE__*/_jsx(Select, {
24
31
  name: name,
25
32
  className: style.fields,
26
33
  label: element.label,
@@ -32,8 +39,9 @@ class ProvinceElement extends PureComponent {
32
39
  isControlled: true,
33
40
  translateErrorText: false
34
41
  });
35
- }
36
- }
42
+ };
43
+ return ProvinceElement;
44
+ }(PureComponent);
37
45
  ProvinceElement.defaultProps = {
38
46
  provincesList: {},
39
47
  value: '',
@@ -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
  import RadioGroup from "../../RadioGroup";
@@ -8,11 +9,17 @@ import RadioItem from "../../RadioGroup/components/Item";
8
9
  * with a list of radio items.
9
10
  * @returns {JSX}
10
11
  */
11
- class RadioElement extends PureComponent {
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let RadioElement = /*#__PURE__*/function (_PureComponent) {
14
+ function RadioElement() {
15
+ return _PureComponent.apply(this, arguments) || this;
16
+ }
17
+ _inheritsLoose(RadioElement, _PureComponent);
18
+ var _proto = RadioElement.prototype;
12
19
  /**
13
20
  * @returns {JSX}
14
21
  */
15
- render() {
22
+ _proto.render = function render() {
16
23
  const {
17
24
  element,
18
25
  errorText,
@@ -20,7 +27,7 @@ class RadioElement extends PureComponent {
20
27
  style,
21
28
  value
22
29
  } = this.props;
23
- return /*#__PURE__*/React.createElement(RadioGroup, {
30
+ return /*#__PURE__*/_jsx(RadioGroup, {
24
31
  name: name,
25
32
  className: style.fields,
26
33
  label: element.label,
@@ -28,14 +35,15 @@ class RadioElement extends PureComponent {
28
35
  onChange: element.handleChange,
29
36
  errorText: errorText,
30
37
  isControlled: true,
31
- translateErrorText: false
32
- }, Object.keys(element.options).map(itemName => /*#__PURE__*/React.createElement(RadioItem, {
33
- key: itemName,
34
- name: itemName,
35
- label: element.options[itemName]
36
- })));
37
- }
38
- }
38
+ translateErrorText: false,
39
+ children: Object.keys(element.options).map(itemName => /*#__PURE__*/_jsx(RadioItem, {
40
+ name: itemName,
41
+ label: element.options[itemName]
42
+ }, itemName))
43
+ });
44
+ };
45
+ return RadioElement;
46
+ }(PureComponent);
39
47
  RadioElement.defaultProps = {
40
48
  value: '',
41
49
  style: {
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { PureComponent, Fragment } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import Chevron from "../../../icons/CheckIcon";
@@ -7,11 +8,17 @@ import Select from "../../Select";
7
8
  * React component that takes the element and additional data and renders a configured select box.
8
9
  * @returns {JSX}
9
10
  */
10
- class SelectElement extends PureComponent {
11
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
+ let SelectElement = /*#__PURE__*/function (_PureComponent) {
13
+ function SelectElement() {
14
+ return _PureComponent.apply(this, arguments) || this;
15
+ }
16
+ _inheritsLoose(SelectElement, _PureComponent);
17
+ var _proto = SelectElement.prototype;
11
18
  /**
12
19
  * @returns {JSX}
13
20
  */
14
- render() {
21
+ _proto.render = function render() {
15
22
  const {
16
23
  element,
17
24
  errorText,
@@ -19,20 +26,23 @@ class SelectElement extends PureComponent {
19
26
  style,
20
27
  value
21
28
  } = this.props;
22
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Select, {
23
- name: name,
24
- className: style.fields,
25
- label: element.label,
26
- placeholder: element.placeholder,
27
- value: value,
28
- options: element.options,
29
- onChange: element.handleChange,
30
- errorText: errorText,
31
- isControlled: true,
32
- translateErrorText: false
33
- }), /*#__PURE__*/React.createElement(Chevron, null));
34
- }
35
- }
29
+ return /*#__PURE__*/_jsxs(_Fragment, {
30
+ children: [/*#__PURE__*/_jsx(Select, {
31
+ name: name,
32
+ className: style.fields,
33
+ label: element.label,
34
+ placeholder: element.placeholder,
35
+ value: value,
36
+ options: element.options,
37
+ onChange: element.handleChange,
38
+ errorText: errorText,
39
+ isControlled: true,
40
+ translateErrorText: false
41
+ }), /*#__PURE__*/_jsx(Chevron, {})]
42
+ });
43
+ };
44
+ return SelectElement;
45
+ }(PureComponent);
36
46
  SelectElement.defaultProps = {
37
47
  value: '',
38
48
  style: {
@@ -1,9 +1,11 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { PureComponent } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import TextField from "../../../TextField";
4
5
  import { ELEMENT_TYPE_TEXT, ELEMENT_TYPE_NUMBER, ELEMENT_TYPE_EMAIL, ELEMENT_TYPE_PASSWORD, ELEMENT_TYPE_DATE, ELEMENT_TYPE_PHONE } from "../elementTypes";
5
6
 
6
7
  // Map element type to input type
8
+ import { jsx as _jsx } from "react/jsx-runtime";
7
9
  const mapping = {
8
10
  [ELEMENT_TYPE_TEXT]: 'text',
9
11
  [ELEMENT_TYPE_NUMBER]: 'number',
@@ -16,11 +18,16 @@ const mapping = {
16
18
  /**
17
19
  * React component that takes the element and additional data and renders a configured text input.
18
20
  */
19
- class TextElement extends PureComponent {
21
+ let TextElement = /*#__PURE__*/function (_PureComponent) {
22
+ function TextElement() {
23
+ return _PureComponent.apply(this, arguments) || this;
24
+ }
25
+ _inheritsLoose(TextElement, _PureComponent);
26
+ var _proto = TextElement.prototype;
20
27
  /**
21
28
  * @returns {JSX}
22
29
  */
23
- render() {
30
+ _proto.render = function render() {
24
31
  const {
25
32
  element,
26
33
  errorText,
@@ -29,7 +36,7 @@ class TextElement extends PureComponent {
29
36
  value
30
37
  } = this.props;
31
38
  const type = mapping[element.type];
32
- return /*#__PURE__*/React.createElement(TextField, {
39
+ return /*#__PURE__*/_jsx(TextField, {
33
40
  type: type,
34
41
  name: name,
35
42
  className: style.fields,
@@ -40,8 +47,9 @@ class TextElement extends PureComponent {
40
47
  isControlled: true,
41
48
  translateErrorText: false
42
49
  });
43
- }
44
- }
50
+ };
51
+ return TextElement;
52
+ }(PureComponent);
45
53
  TextElement.defaultProps = {
46
54
  value: '',
47
55
  style: {
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import _isEqual from "lodash/isEqual";
2
3
  import "core-js/modules/es.string.replace.js";
3
4
  import React, { Component, Fragment } from 'react';
@@ -26,6 +27,7 @@ import buildValidationErrorList from "./builders/buildValidationErrorList";
26
27
  * @param {string} s The string to be sanitized
27
28
  * @return {string}
28
29
  */
30
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
31
  const sanitize = s => s.replace(/[\\._]/, '-');
30
32
  /**
31
33
  * Optional select element
@@ -39,13 +41,14 @@ const emptySelectOption = {
39
41
  * Takes a form configuration and handles rendering and updates of the form fields.
40
42
  * Note: Only one country and one province element is supported per FormBuilder instance.
41
43
  */
42
- class Builder extends Component {
44
+ let Builder = /*#__PURE__*/function (_Component) {
43
45
  /**
44
46
  * Initializes the component.
45
47
  * @param {Object} props The components props.
46
48
  */
47
- constructor(props) {
48
- super(props);
49
+ function Builder(props) {
50
+ var _this;
51
+ _this = _Component.call(this, props) || this;
49
52
 
50
53
  // Prepare internal state
51
54
  /**
@@ -58,7 +61,7 @@ class Builder extends Component {
58
61
  * @param {FormElement} element2 Second element
59
62
  * @returns {number}
60
63
  */
61
- this.elementSortFunc = (element1, element2) => {
64
+ _this.elementSortFunc = (element1, element2) => {
62
65
  // Keep current sort order when no specific sort order was set for both
63
66
  if (element1.sortOrder === undefined || element2.sortOrder === undefined) {
64
67
  return 0;
@@ -72,12 +75,12 @@ class Builder extends Component {
72
75
  * @param {string} elementId Element to create the handler for
73
76
  * @param {string} value Element value
74
77
  */
75
- this.elementChangeHandler = (elementId, value) => {
78
+ _this.elementChangeHandler = (elementId, value) => {
76
79
  // Apply value change to new state
77
80
  const newState = {
78
- ...this.state,
81
+ ..._this.state,
79
82
  formData: {
80
- ...this.state.formData,
83
+ ..._this.state.formData,
81
84
  [elementId]: value
82
85
  }
83
86
  };
@@ -85,20 +88,20 @@ class Builder extends Component {
85
88
  // Remove validation error message on first change of the element
86
89
  Object.keys(newState.errors).forEach(key => {
87
90
  // Action listeners might add some again
88
- if (this.state.formData[key] !== newState.formData[key]) {
91
+ if (_this.state.formData[key] !== newState.formData[key]) {
89
92
  delete newState.errors[key];
90
93
  }
91
94
  });
92
95
  const hasBackendValidationErrors = Object.keys(newState.errors).length > 0;
93
96
 
94
97
  // Handle context sensitive functionality by via "action" listener and use the "new" state
95
- const updatedState = this.actionListener.notify(elementId, this.state, newState);
98
+ const updatedState = _this.actionListener.notify(elementId, _this.state, newState);
96
99
 
97
100
  // TODO: handle frontend validation errors and set "hasErrors" accordingly
98
101
  let hasErrors = false;
99
102
 
100
103
  // Check "required" fields for all visible elements and enable rendering on changes
101
- this.formElements.forEach(formElement => {
104
+ _this.formElements.forEach(formElement => {
102
105
  if (!updatedState.elementVisibility[formElement.id] || !formElement.required) {
103
106
  return;
104
107
  }
@@ -110,11 +113,11 @@ class Builder extends Component {
110
113
  const hasValidationErrors = hasBackendValidationErrors && hasFrontendValidationErrors;
111
114
 
112
115
  // Handle state internally and send an "onChange" event to parent if this finished
113
- this.setState(updatedState);
116
+ _this.setState(updatedState);
114
117
 
115
118
  // Transform to external structure (unavailable ones will be set undefined)
116
119
  const updateData = {};
117
- this.formElements.forEach(el => {
120
+ _this.formElements.forEach(el => {
118
121
  if (el.custom) {
119
122
  if (updateData.customAttributes === undefined) {
120
123
  updateData.customAttributes = {};
@@ -126,7 +129,7 @@ class Builder extends Component {
126
129
  });
127
130
 
128
131
  // Trigger the given update action
129
- this.props.handleUpdate(updateData, hasErrors || hasValidationErrors);
132
+ _this.props.handleUpdate(updateData, hasErrors || hasValidationErrors);
130
133
  };
131
134
  /**
132
135
  * Takes an element of any type and renders it depending on type.
@@ -134,11 +137,11 @@ class Builder extends Component {
134
137
  * @param {Object} element The data of the element to be rendered
135
138
  * @returns {JSX}
136
139
  */
137
- this.renderElement = element => {
138
- const elementName = `${this.props.name}.${element.id}`;
139
- const elementErrorText = this.state.errors[element.id] || '';
140
- const elementValue = this.state.formData[element.id];
141
- const elementVisible = this.state.elementVisibility[element.id] || false;
140
+ _this.renderElement = element => {
141
+ const elementName = `${_this.props.name}.${element.id}`;
142
+ const elementErrorText = _this.state.errors[element.id] || '';
143
+ const elementValue = _this.state.formData[element.id];
144
+ const elementVisible = _this.state.elementVisibility[element.id] || false;
142
145
  if (!elementVisible) {
143
146
  return null;
144
147
  }
@@ -155,7 +158,7 @@ class Builder extends Component {
155
158
  case ELEMENT_TYPE_DATE:
156
159
  case ELEMENT_TYPE_PHONE:
157
160
  {
158
- return /*#__PURE__*/React.createElement(TextElement, {
161
+ return /*#__PURE__*/_jsx(TextElement, {
159
162
  name: elementName,
160
163
  element: element,
161
164
  errorText: elementErrorText,
@@ -164,7 +167,7 @@ class Builder extends Component {
164
167
  });
165
168
  }
166
169
  case ELEMENT_TYPE_SELECT:
167
- return /*#__PURE__*/React.createElement(SelectElement, {
170
+ return /*#__PURE__*/_jsx(SelectElement, {
168
171
  name: elementName,
169
172
  element: element,
170
173
  errorText: elementErrorText,
@@ -172,19 +175,19 @@ class Builder extends Component {
172
175
  visible: elementVisible
173
176
  });
174
177
  case ELEMENT_TYPE_COUNTRY:
175
- return /*#__PURE__*/React.createElement(CountryElement, {
178
+ return /*#__PURE__*/_jsx(CountryElement, {
176
179
  name: elementName,
177
180
  element: element,
178
181
  errorText: elementErrorText,
179
182
  value: elementValue,
180
183
  visible: elementVisible,
181
- countryList: this.countryList
184
+ countryList: _this.countryList
182
185
  });
183
186
  case ELEMENT_TYPE_PROVINCE:
184
187
  {
185
- const countryElement = this.formElements.find(el => el.type === ELEMENT_TYPE_COUNTRY);
186
- const provincesList = countryElement && this.state.formData[countryElement.id] ? buildProvinceList(this.state.formData[countryElement.id], element.required ? null : emptySelectOption) : {};
187
- return /*#__PURE__*/React.createElement(ProvinceElement, {
188
+ const countryElement = _this.formElements.find(el => el.type === ELEMENT_TYPE_COUNTRY);
189
+ const provincesList = countryElement && _this.state.formData[countryElement.id] ? buildProvinceList(_this.state.formData[countryElement.id], element.required ? null : emptySelectOption) : {};
190
+ return /*#__PURE__*/_jsx(ProvinceElement, {
188
191
  name: elementName,
189
192
  element: element,
190
193
  errorText: elementErrorText,
@@ -195,7 +198,7 @@ class Builder extends Component {
195
198
  }
196
199
  case ELEMENT_TYPE_RADIO:
197
200
  {
198
- return /*#__PURE__*/React.createElement(RadioElement, {
201
+ return /*#__PURE__*/_jsx(RadioElement, {
199
202
  name: elementName,
200
203
  element: element,
201
204
  errorText: elementErrorText,
@@ -205,7 +208,7 @@ class Builder extends Component {
205
208
  }
206
209
  case ELEMENT_TYPE_CHECKBOX:
207
210
  {
208
- return /*#__PURE__*/React.createElement(CheckboxElement, {
211
+ return /*#__PURE__*/_jsx(CheckboxElement, {
209
212
  name: elementName,
210
213
  element: element,
211
214
  errorText: elementErrorText,
@@ -221,7 +224,7 @@ class Builder extends Component {
221
224
  }
222
225
  return null;
223
226
  };
224
- this.state = {
227
+ _this.state = {
225
228
  elementVisibility: {},
226
229
  formData: {},
227
230
  // Convert errors structure to direct access errors
@@ -229,50 +232,53 @@ class Builder extends Component {
229
232
  };
230
233
 
231
234
  // Reorganize form elements into a structure that can be easily rendered
232
- const formElements = buildFormElements(props.config, this.elementChangeHandler);
235
+ const formElements = buildFormElements(props.config, _this.elementChangeHandler);
233
236
  // Compute defaults
234
237
  const formDefaults = buildFormDefaults(formElements, props.defaults);
235
238
  // Assign defaults to state
236
- this.state.formData = formDefaults;
239
+ _this.state.formData = formDefaults;
237
240
 
238
241
  // Handle fixed visibilities
239
242
  formElements.forEach(element => {
240
243
  // Assume as visible except it's explicitly set to "false"
241
- this.state.elementVisibility[element.id] = element.visible !== false;
244
+ _this.state.elementVisibility[element.id] = element.visible !== false;
242
245
  });
243
- this.actionListener = new ActionListener(buildProvinceList, formDefaults);
244
- this.actionListener.attachAll(formElements);
246
+ _this.actionListener = new ActionListener(buildProvinceList, formDefaults);
247
+ _this.actionListener.attachAll(formElements);
245
248
 
246
249
  // Sort the elements after attaching action listeners to keep action hierarchy same as creation
247
- this.formElements = formElements.sort(this.elementSortFunc);
250
+ _this.formElements = formElements.sort(_this.elementSortFunc);
248
251
 
249
252
  // Assemble combined country/province list based on the config element
250
- const _countryElement = this.formElements.find(el => el.type === ELEMENT_TYPE_COUNTRY);
253
+ const _countryElement = _this.formElements.find(el => el.type === ELEMENT_TYPE_COUNTRY);
251
254
  if (_countryElement) {
252
- this.countryList = buildCountryList(_countryElement, emptySelectOption);
253
- const provinceElement = this.formElements.find(el => el.type === ELEMENT_TYPE_PROVINCE);
255
+ _this.countryList = buildCountryList(_countryElement, emptySelectOption);
256
+ const provinceElement = _this.formElements.find(el => el.type === ELEMENT_TYPE_PROVINCE);
254
257
  if (provinceElement && provinceElement.required && !!formDefaults[_countryElement.id] && !formDefaults[provinceElement.id]) {
255
258
  // Set default for province field for given country
256
259
  const [first] = Object.values(buildProvinceList(formDefaults[_countryElement.id]));
257
260
  if (first) {
258
- this.state.formData[provinceElement.id] = first;
261
+ _this.state.formData[provinceElement.id] = first;
259
262
  }
260
263
  }
261
264
  }
262
265
 
263
266
  // Final form initialization, by triggering actionListeners and enable rendering for elements
264
- let _newState = this.state;
265
- this.formElements.forEach(element => {
266
- _newState = this.actionListener.notify(element.id, this.state, _newState);
267
+ let _newState = _this.state;
268
+ _this.formElements.forEach(element => {
269
+ _newState = _this.actionListener.notify(element.id, _this.state, _newState);
267
270
  });
268
- this.state = _newState;
271
+ _this.state = _newState;
272
+ return _this;
269
273
  }
270
274
 
271
275
  /**
272
276
  * Handles response of validation errors
273
277
  * @param {Object} nextProps The new props object with changed data
274
278
  */
275
- UNSAFE_componentWillReceiveProps(nextProps) {
279
+ _inheritsLoose(Builder, _Component);
280
+ var _proto = Builder.prototype;
281
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
276
282
  const oldValidationErrors = buildValidationErrorList(this.props.validationErrors);
277
283
  const newValidationErrors = buildValidationErrorList(nextProps.validationErrors);
278
284
  if (!_isEqual(oldValidationErrors, newValidationErrors)) {
@@ -280,27 +286,31 @@ class Builder extends Component {
280
286
  errors: newValidationErrors
281
287
  });
282
288
  }
283
- }
289
+ };
284
290
  /**
285
291
  * Renders the component based on the given config
286
292
  * @return {JSX}
287
293
  */
288
- render() {
289
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Form, {
290
- onSubmit: this.props.onSubmit
291
- }, /*#__PURE__*/React.createElement("div", {
292
- className: this.props.className
293
- }, this.formElements.map(element => /*#__PURE__*/React.createElement(Fragment, {
294
- key: `${this.props.name}.${element.id}`
295
- }, /*#__PURE__*/React.createElement(Portal, {
296
- name: `${sanitize(this.props.name)}.${sanitize(element.id)}.${BEFORE}`
297
- }), /*#__PURE__*/React.createElement(Portal, {
298
- name: `${sanitize(this.props.name)}.${sanitize(element.id)}`
299
- }, this.renderElement(element)), /*#__PURE__*/React.createElement(Portal, {
300
- name: `${sanitize(this.props.name)}.${sanitize(element.id)}.${AFTER}`
301
- }))))));
302
- }
303
- }
294
+ _proto.render = function render() {
295
+ return /*#__PURE__*/_jsx(Form, {
296
+ onSubmit: this.props.onSubmit,
297
+ children: /*#__PURE__*/_jsx("div", {
298
+ className: this.props.className,
299
+ children: this.formElements.map(element => /*#__PURE__*/_jsxs(Fragment, {
300
+ children: [/*#__PURE__*/_jsx(Portal, {
301
+ name: `${sanitize(this.props.name)}.${sanitize(element.id)}.${BEFORE}`
302
+ }), /*#__PURE__*/_jsx(Portal, {
303
+ name: `${sanitize(this.props.name)}.${sanitize(element.id)}`,
304
+ children: this.renderElement(element)
305
+ }), /*#__PURE__*/_jsx(Portal, {
306
+ name: `${sanitize(this.props.name)}.${sanitize(element.id)}.${AFTER}`
307
+ })]
308
+ }, `${this.props.name}.${element.id}`))
309
+ })
310
+ });
311
+ };
312
+ return Builder;
313
+ }(Component);
304
314
  Builder.defaultProps = {
305
315
  className: '',
306
316
  defaults: {},