@shopgate/pwa-ui-shared 7.12.3-beta.1 → 7.20.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 (83) hide show
  1. package/AccordionContainer/index.js +3 -3
  2. package/ActionButton/index.js +9 -9
  3. package/AddToCartButton/index.js +14 -7
  4. package/AddToCartButton/mock.js +3 -3
  5. package/AddToCartButton/spec.js +1 -1
  6. package/AddToCartButton/style.js +3 -3
  7. package/Availability/index.js +1 -1
  8. package/Availability/style.js +1 -1
  9. package/Button/index.js +7 -7
  10. package/Button/style.js +8 -2
  11. package/ButtonLink/index.js +6 -3
  12. package/Card/index.js +1 -1
  13. package/CardList/index.js +3 -3
  14. package/CartTotalLine/index.js +1 -1
  15. package/Checkbox/index.js +6 -5
  16. package/Chip/index.js +1 -1
  17. package/ClientInformation/index.js +10 -8
  18. package/ContextMenu/components/Position/index.js +5 -5
  19. package/ContextMenu/index.js +8 -8
  20. package/Dialog/components/PipelineErrorDialog/index.js +21 -13
  21. package/Dialog/components/PipelineErrorDialog/spec.js +1 -1
  22. package/Dialog/index.js +2 -2
  23. package/DiscountBadge/index.js +1 -1
  24. package/FavoritesButton/index.js +14 -14
  25. package/Footer/index.js +7 -7
  26. package/Form/Builder/builders/buildFormElements.js +2 -2
  27. package/Form/Builder/classes/ActionListener/constants.js +2 -2
  28. package/Form/Builder/classes/ActionListener/index.js +73 -16
  29. package/Form/Builder/classes/ActionListener/spec.js +2 -2
  30. package/Form/Builder/components/CheckboxElement.js +3 -3
  31. package/Form/Builder/components/CountryElement.js +3 -3
  32. package/Form/Builder/components/ProvinceElement.js +3 -3
  33. package/Form/Builder/components/RadioElement.js +3 -3
  34. package/Form/Builder/components/SelectElement.js +3 -3
  35. package/Form/Builder/components/TextElement.js +4 -4
  36. package/Form/Builder/index.js +39 -30
  37. package/Form/Checkbox/index.js +3 -3
  38. package/Form/Password/index.js +5 -5
  39. package/Form/RadioGroup/components/Item/index.js +2 -2
  40. package/Form/RadioGroup/index.js +6 -6
  41. package/Form/Select/index.js +10 -8
  42. package/Form/TextField/index.js +5 -5
  43. package/Form/index.js +8 -5
  44. package/FormElement/components/Label/style.js +1 -1
  45. package/FormElement/index.js +6 -6
  46. package/Glow/index.js +7 -7
  47. package/IndicatorCircle/index.js +1 -1
  48. package/LoadingIndicator/index.js +2 -2
  49. package/LoadingIndicator/style.js +1 -1
  50. package/Manufacturer/index.js +1 -1
  51. package/MessageBar/index.js +1 -1
  52. package/NoResults/index.js +1 -1
  53. package/Placeholder/index.js +3 -3
  54. package/PlaceholderLabel/index.js +1 -1
  55. package/PlaceholderParagraph/index.js +1 -1
  56. package/Price/index.js +4 -3
  57. package/PriceInfo/index.js +1 -1
  58. package/PriceStriked/index.js +9 -9
  59. package/ProductProperties/index.js +2 -2
  60. package/ProgressBar/index.js +12 -12
  61. package/RatingNumber/index.js +1 -1
  62. package/RatingStars/index.js +8 -8
  63. package/RatingStars/style.js +1 -1
  64. package/Ripple/components/RippleAnimation/index.js +3 -3
  65. package/Ripple/index.js +20 -17
  66. package/RippleButton/index.js +7 -7
  67. package/ScannerOverlay/components/ScannerBar/index.js +1 -1
  68. package/ScannerOverlay/index.js +4 -4
  69. package/Sheet/components/Header/components/SearchBar/index.js +3 -0
  70. package/Sheet/components/Header/components/SearchBar/spec.js +3 -0
  71. package/Sheet/components/Header/components/SearchBar/style.js +1 -0
  72. package/Sheet/components/Header/index.js +7 -7
  73. package/Sheet/index.js +19 -16
  74. package/Sheet/style.js +2 -1
  75. package/TaxDisclaimer/index.js +3 -2
  76. package/TaxDisclaimer/spec.js +1 -1
  77. package/TextField/components/Label/style.js +1 -1
  78. package/TextField/index.js +23 -14
  79. package/ToggleIcon/index.js +7 -7
  80. package/icons/ArrowIcon.js +2 -2
  81. package/icons/CartCouponIcon.js +5 -0
  82. package/icons/NotificationIcon.js +6 -0
  83. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import I18n from'@shopgate/pwa-common/components/I18n';import BasicDialog from"../BasicDialog";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import I18n from'@shopgate/pwa-common/components/I18n';import BasicDialog from"../BasicDialog";/**
2
2
  * The number of taps required until the dialog switches to/from developer mode.
3
3
  */var requiredTapsToSwitchModes=10;/**
4
4
  * The timeout between repeated tapping on the message (in ms).
@@ -6,23 +6,31 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
6
6
  * This component displays a pipeline error dialog.
7
7
  * The special behaviour of this message is that the user may tap the message body
8
8
  * ten times until it reveals additional information about the error that occurred.
9
- */var PipelineErrorDialog=/*#__PURE__*/function(_Component){_inherits(PipelineErrorDialog,_Component);/**
9
+ */var PipelineErrorDialog=/*#__PURE__*/function(_Component){/**
10
10
  * Creates the component.
11
11
  * @param {Object} props The component props.
12
- */function PipelineErrorDialog(props){var _this;_classCallCheck(this,PipelineErrorDialog);_this=_possibleConstructorReturn(this,_getPrototypeOf(PipelineErrorDialog).call(this,props));_defineProperty(_assertThisInitialized(_this),"handleTapTimeout",function(){_this.tapCounter=0;});_defineProperty(_assertThisInitialized(_this),"handleClick",function(){_this.tapCounter+=1;if(_this.tapTimeout){// Clear the timeout.
13
- clearTimeout(_this.tapTimeout);}if(_this.tapCounter>=requiredTapsToSwitchModes){// Switch modes and reset the tap counter.
14
- _this.tapCounter=0;_this.setState(function(_ref){var devMode=_ref.devMode;return{devMode:!devMode};});}else{_this.tapTimeout=setTimeout(_this.handleTapTimeout,switchModeTapTimeout);}});_defineProperty(_assertThisInitialized(_this),"renderDevErrorMessage",function(){/**
12
+ */function PipelineErrorDialog(props){var _this2;_classCallCheck(this,PipelineErrorDialog);_this2=_callSuper(this,PipelineErrorDialog,[props]);/**
13
+ * Clears the tap counter once the
14
+ */_defineProperty(_this2,"handleTapTimeout",function(){_this2.tapCounter=0;});/**
15
+ * User tapped the message, increase the tap counter and switch view modes if required.
16
+ */_defineProperty(_this2,"handleClick",function(){_this2.tapCounter+=1;if(_this2.tapTimeout){// Clear the timeout.
17
+ clearTimeout(_this2.tapTimeout);}if(_this2.tapCounter>=requiredTapsToSwitchModes){// Switch modes and reset the tap counter.
18
+ _this2.tapCounter=0;_this2.setState(function(_ref){var devMode=_ref.devMode;return{devMode:!devMode};});}else{_this2.tapTimeout=setTimeout(_this2.handleTapTimeout,switchModeTapTimeout);}});/**
19
+ * Renders the error message in developer mode.
20
+ * @returns {JSX}
21
+ */_defineProperty(_this2,"renderDevErrorMessage",function(){/**
15
22
  * Checks the input to be truthy, "0" or "false" and enables it to be rendered then.
16
23
  * @param {Object|string|number|boolean} value The value to be checked if it should be rendered.
17
24
  * @returns {boolean}
18
- */var checkValue=function checkValue(value){return!!value||value===0||value===false;};var params=_this.props.params;return React.createElement("div",{"aria-hidden":true},React.createElement("span",null,React.createElement("strong",null,"Pipeline:"),React.createElement("span",null," ".concat(params.pipeline)),React.createElement("br",null)),checkValue(params.entityId)&&React.createElement("span",null,React.createElement("strong",null,"Entity id:"),React.createElement("span",null," ".concat(params.entityId)),React.createElement("br",null)),checkValue(params.code)&&React.createElement("span",null,React.createElement("strong",null,"Code:"),React.createElement("span",null," ".concat(params.code)),React.createElement("br",null)),React.createElement("span",null,React.createElement("strong",null,"Message:"),React.createElement("span",null," ".concat(params.message)),React.createElement("br",null)),checkValue(params.translated)&&React.createElement("span",null,React.createElement("strong",null,"Message Translated:"),React.createElement("span",null," ".concat(params.translated.toString())),React.createElement("br",null)),checkValue(params.messageParams)&&React.createElement("p",null,React.createElement("strong",null,"Message Params:"),React.createElement("br",null),React.createElement("span",null,JSON.stringify(params.messageParams,null,' ')),React.createElement("br",null)),checkValue(params.request)&&React.createElement("p",null,React.createElement("strong",null,"Request Params:"),React.createElement("br",null),React.createElement("span",null,JSON.stringify(params.request,null,' ')),React.createElement("br",null)));});_defineProperty(_assertThisInitialized(_this),"renderUserErrorMessage",function(){var _this$props=_this.props,_this$props$message=_this$props.message,message=_this$props$message===void 0?'':_this$props$message,_this$props$params=_this$props.params,params=_this$props$params===void 0?{}:_this$props$params;return React.createElement(React.Fragment,null,!!params.translated&&(message||params.message||React.createElement(I18n.Text,{string:"modal.body_error"})),!params.translated&&React.createElement(I18n.Text,{string:message||params.message||'modal.body_error',params:params.messageParams||{}}));});_this.tapTimeout=null;_this.tapCounter=0;_this.state={devMode:false// Indicating whether we are in dev mode.
19
- };return _this;}/**
25
+ */var checkValue=function checkValue(value){return!!value||value===0||value===false;};var params=_this2.props.params;return React.createElement("div",{"aria-hidden":true},React.createElement("span",null,React.createElement("strong",null,"Pipeline:"),React.createElement("span",null," ".concat(params.pipeline)),React.createElement("br",null)),checkValue(params.entityId)&&React.createElement("span",null,React.createElement("strong",null,"Entity id:"),React.createElement("span",null," ".concat(params.entityId)),React.createElement("br",null)),checkValue(params.code)&&React.createElement("span",null,React.createElement("strong",null,"Code:"),React.createElement("span",null," ".concat(params.code)),React.createElement("br",null)),React.createElement("span",null,React.createElement("strong",null,"Message:"),React.createElement("span",null," ".concat(params.message)),React.createElement("br",null)),checkValue(params.translated)&&React.createElement("span",null,React.createElement("strong",null,"Message Translated:"),React.createElement("span",null," ".concat(params.translated.toString())),React.createElement("br",null)),checkValue(params.messageParams)&&React.createElement("p",null,React.createElement("strong",null,"Message Params:"),React.createElement("br",null),React.createElement("span",null,JSON.stringify(params.messageParams,null,' ')),React.createElement("br",null)),checkValue(params.request)&&React.createElement("p",null,React.createElement("strong",null,"Request Params:"),React.createElement("br",null),React.createElement("span",null,JSON.stringify(params.request,null,' ')),React.createElement("br",null)));});/**
26
+ * Renders the regular error message in user mode.
27
+ * @returns {JSX}
28
+ */_defineProperty(_this2,"renderUserErrorMessage",function(){var _this2$props=_this2.props,_this2$props$message=_this2$props.message,message=_this2$props$message===void 0?'':_this2$props$message,_this2$props$params=_this2$props.params,params=_this2$props$params===void 0?{}:_this2$props$params;return React.createElement(React.Fragment,null,!!params.translated&&(message||params.message||React.createElement(I18n.Text,{string:"modal.body_error"})),!params.translated&&React.createElement(I18n.Text,{string:message||params.message||'modal.body_error',params:params.messageParams||{}}));});_this2.tapTimeout=null;_this2.tapCounter=0;_this2.state={devMode:false// Indicating whether we are in dev mode.
29
+ };return _this2;}/**
20
30
  * @return {string} The title based on the current state of the dialog.
21
- */_createClass(PipelineErrorDialog,[{key:"render",/**
31
+ */_inherits(PipelineErrorDialog,_Component);return _createClass(PipelineErrorDialog,[{key:"title",get:function get(){return this.state.devMode?'Pipeline Error':'modal.title_error';}/**
32
+ * @return {JSX} The content component based on the the current state of the dialog.
33
+ */},{key:"content",get:function get(){return this.state.devMode?this.renderDevErrorMessage():this.renderUserErrorMessage();}},{key:"render",value:/**
22
34
  * Renders the error message depending on the current mode.
23
35
  * @return {JSX}
24
- */value:function render(){return React.createElement(BasicDialog,{title:this.title,actions:this.props.actions},React.createElement("div",{onClick:this.handleClick},this.content));}},{key:"title",get:function get(){return this.state.devMode?'Pipeline Error':'modal.title_error';}/**
25
- * @return {JSX} The content component based on the the current state of the dialog.
26
- */},{key:"content",get:function get(){return this.state.devMode?this.renderDevErrorMessage():this.renderUserErrorMessage();}/**
27
- * Clears the tap counter once the
28
- */}]);return PipelineErrorDialog;}(Component);_defineProperty(PipelineErrorDialog,"defaultProps",{message:''});export default PipelineErrorDialog;
36
+ */function render(){return React.createElement(BasicDialog,{title:this.title,actions:this.props.actions},React.createElement("div",{onClick:this.handleClick},this.content));}}]);}(Component);_defineProperty(PipelineErrorDialog,"defaultProps",{message:''});export default PipelineErrorDialog;
@@ -1,6 +1,6 @@
1
1
  import React from'react';import{mount}from'enzyme';import PipelineErrorDialog from"./index";describe('<PipelineErrorDialog />',function(){var defaultParams={code:'123',message:'Error message',pipeline:'fakePipeline',request:{}};it('should render with minimal props',function(){var wrapper=mount(React.createElement(PipelineErrorDialog,{actions:[],params:defaultParams}));expect(wrapper).toMatchSnapshot();});it('should show a custom message if a message is is provided',function(){var message='Custom message';var wrapper=mount(React.createElement(PipelineErrorDialog,{actions:[],message:message,params:defaultParams}));expect(wrapper).toMatchSnapshot();expect(wrapper.html()).toMatch(message);});it('should switch modes on tap',function(){var wrapper=mount(React.createElement(PipelineErrorDialog,{actions:[],params:defaultParams}));var numTaps=10;var clickElement=wrapper.find('div[onClick]');// Dev mode should be disabled.
2
2
  for(var i=0;i<numTaps;i+=1){expect(wrapper.state().devMode).toBe(false);clickElement.simulate('click');}// Dev mode should be enabled.
3
- for(var _i=0;_i<numTaps;_i+=1){expect(wrapper.state().devMode).toBe(true);clickElement.simulate('click');}// Dev mode should be disabled again.
3
+ for(var _i2=0;_i2<numTaps;_i2+=1){expect(wrapper.state().devMode).toBe(true);clickElement.simulate('click');}// Dev mode should be disabled again.
4
4
  expect(wrapper.state().devMode).toBe(false);});it('should not switch modes if tapped too slow',function(){jest.useFakeTimers();var wrapper=mount(React.createElement(PipelineErrorDialog,{actions:[],params:defaultParams}));var numTaps=10;var numTapsUntilTimeout=Math.round(numTaps/2);var clickElement=wrapper.find('div[onClick]');// Dev mode should be disabled.
5
5
  expect(wrapper.state().devMode).toBe(false);/**
6
6
  * Simulates multiple tap events.
package/Dialog/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var _dialogTypes;function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import Modal from'@shopgate/pwa-common/components/Modal';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import{MODAL_PIPELINE_ERROR}from'@shopgate/pwa-common/constants/ModalTypes';import I18n from'@shopgate/pwa-common/components/I18n';import{DIALOG_TEXT_MESSAGE,MODAL_VARIANT_SELECT,MODAL_ACTION_TYPE_PRIMARY,MODAL_ACTION_TYPE_NORMAL,DIALOG_HTML_CONTENT}from"./constants";import PipelineErrorDialog from"./components/PipelineErrorDialog";import TextMessageDialog from"./components/TextMessageDialog";import HtmlContentDialog from"./components/HtmlContentDialog";import BasicDialog from"./components/BasicDialog";import VariantSelectModal from"./components/VariantSelectModal";var dialogTypes=(_dialogTypes={},_defineProperty(_dialogTypes,DIALOG_TEXT_MESSAGE,TextMessageDialog),_defineProperty(_dialogTypes,DIALOG_HTML_CONTENT,HtmlContentDialog),_defineProperty(_dialogTypes,MODAL_PIPELINE_ERROR,PipelineErrorDialog),_defineProperty(_dialogTypes,MODAL_VARIANT_SELECT,VariantSelectModal),_dialogTypes);/**
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import Modal from'@shopgate/pwa-common/components/Modal';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import{MODAL_PIPELINE_ERROR}from'@shopgate/pwa-common/constants/ModalTypes';import I18n from'@shopgate/pwa-common/components/I18n';import{DIALOG_TEXT_MESSAGE,MODAL_VARIANT_SELECT,MODAL_ACTION_TYPE_PRIMARY,MODAL_ACTION_TYPE_NORMAL,DIALOG_HTML_CONTENT}from"./constants";import PipelineErrorDialog from"./components/PipelineErrorDialog";import TextMessageDialog from"./components/TextMessageDialog";import HtmlContentDialog from"./components/HtmlContentDialog";import BasicDialog from"./components/BasicDialog";import VariantSelectModal from"./components/VariantSelectModal";var dialogTypes=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},DIALOG_TEXT_MESSAGE,TextMessageDialog),DIALOG_HTML_CONTENT,HtmlContentDialog),MODAL_PIPELINE_ERROR,PipelineErrorDialog),MODAL_VARIANT_SELECT,VariantSelectModal);/**
2
2
  * The main component for rendering dialogs.
3
3
  * This component takes care of choosing the correct component body for the given type
4
4
  * and render it on a modal overlay.
@@ -8,4 +8,4 @@ var _dialogTypes;function _defineProperty(obj,key,value){if(key in obj){Object.d
8
8
  var actions=[];var confirm=modal.confirm,dismiss=modal.dismiss,title=modal.title,titleParams=modal.titleParams,message=modal.message,params=modal.params,type=modal.type,confirmDisabled=modal.confirmDisabled,dismissDisabled=modal.dismissDisabled;// Push dismiss action first so the button is rendered first
9
9
  if(dismiss){// We have a dismiss label, add a dismiss action.
10
10
  actions.push({label:modal.dismiss,action:onDismiss,type:MODAL_ACTION_TYPE_PRIMARY,disabled:dismissDisabled});}if(confirm){// We have a confirm label, add a confirm action.
11
- actions.push({label:modal.confirm,action:onConfirm,type:MODAL_ACTION_TYPE_NORMAL,disabled:confirmDisabled});}var dialogType=type;if(!dialogType&&message){dialogType=DIALOG_TEXT_MESSAGE;}var dialogTitle=title;if(titleParams){dialogTitle=React.createElement(I18n.Text,{string:title,params:titleParams});}var dialogProps={actions:actions,title:dialogTitle,params:params,message:message||undefined,children:children};var DialogComponent=dialogTypes[dialogType]||BasicDialog;return React.createElement(Modal,null,React.createElement(Backdrop,{isVisible:true,level:0}),React.createElement(DialogComponent,dialogProps));};Dialog.defaultProps={onConfirm:function onConfirm(){},onDismiss:function onDismiss(){},children:null};export default Dialog;
11
+ actions.push({label:modal.confirm,action:onConfirm,type:MODAL_ACTION_TYPE_NORMAL,disabled:confirmDisabled});}var dialogType=type;if(!dialogType&&message){dialogType=DIALOG_TEXT_MESSAGE;}var dialogTitle=title;if(titleParams){dialogTitle=React.createElement(I18n.Text,{string:title,params:titleParams});}var dialogProps={actions:actions,title:dialogTitle,params:params,message:message||undefined,children:children};var DialogComponent=dialogTypes[dialogType]||BasicDialog;return React.createElement(Modal,null,React.createElement(Backdrop,{isVisible:true,level:0,opacity:30}),React.createElement(DialogComponent,dialogProps));};Dialog.defaultProps={onConfirm:function onConfirm(){},onDismiss:function onDismiss(){},children:null};export default Dialog;
@@ -4,4 +4,4 @@ import React from'react';import PropTypes from'prop-types';import I18n from'@sho
4
4
  * @param {string} [props.className] Additional CSS style definitions
5
5
  * @param {string} props.text The text contents of the component.
6
6
  * @returns {JSX}
7
- */var DiscountBadge=function DiscountBadge(_ref){var text=_ref.text,className=_ref.className,display=_ref.display,discount=_ref.discount;return React.createElement("div",{"data-test-id":text},React.createElement(I18n.Text,{className:"".concat(styles[display]," ").concat(className),string:text,params:[discount]}));};DiscountBadge.defaultProps={className:'',discount:null,display:'small'};export default DiscountBadge;
7
+ */var DiscountBadge=function DiscountBadge(_ref){var text=_ref.text,className=_ref.className,display=_ref.display,discount=_ref.discount;return React.createElement("div",{"data-test-id":text,className:"ui-shared__discount-badge"},React.createElement(I18n.Text,{className:"".concat(styles[display]," ").concat(className),string:text,params:[discount]}));};DiscountBadge.defaultProps={className:'',discount:null,display:'small'};export default DiscountBadge;
@@ -1,24 +1,24 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import appConfig from'@shopgate/pwa-common/helpers/config';import HeartIcon from"../icons/HeartIcon";import HeartOutlineIcon from"../icons/HeartOutlineIcon";import HeartPlusOutlineIcon from"../icons/HeartPlusOutlineIcon";import HeartPlus from"../icons/HeartPlusIcon";import Ripple from"../Ripple";import styles from"./style";import connect from"./connector";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import appConfig from'@shopgate/pwa-common/helpers/config';import HeartIcon from"../icons/HeartIcon";import HeartOutlineIcon from"../icons/HeartOutlineIcon";import HeartPlusOutlineIcon from"../icons/HeartPlusOutlineIcon";import HeartPlus from"../icons/HeartPlusIcon";import Ripple from"../Ripple";import styles from"./style";import connect from"./connector";/**
2
2
  * The favorites button component.
3
- */var FavoritesButton=/*#__PURE__*/function(_Component){_inherits(FavoritesButton,_Component);/**
4
- * Context types definition.
5
- * @type {{i18n: shim}}
6
- */ /**
3
+ */var FavoritesButton=/*#__PURE__*/function(_Component){/**
7
4
  * Construct and init state
8
5
  * @param {Object} props Component props
9
- */function FavoritesButton(props){var _this;_classCallCheck(this,FavoritesButton);_this=_possibleConstructorReturn(this,_getPrototypeOf(FavoritesButton).call(this,props));_defineProperty(_assertThisInitialized(_this),"onRippleComplete",function(){_this.props.onRippleComplete(_this.props.active);});_defineProperty(_assertThisInitialized(_this),"handleClick",function(event){event.preventDefault();event.stopPropagation();if(_this.props.once&&_this.clickedOnce){return;}_this.clickedOnce=true;if(!_this.props.productId){return;}// When wishlist item quantity is active, items cannot be removed via the button
10
- if(!_this.props.active||_this.props.wishlistItemQuantityEnabled){_this.props.addFavorites(_this.props.productId);}else{setTimeout(function(){_this.props.removeFavorites(_this.props.productId,_this.props.removeWithRelatives);},_this.props.removeThrottle);}});_this.clickedOnce=false;return _this;}/**
6
+ */function FavoritesButton(props){var _this2;_classCallCheck(this,FavoritesButton);_this2=_callSuper(this,FavoritesButton,[props]);/**
11
7
  * Callback for the moment when the ripple animation is done.
12
- */_createClass(FavoritesButton,[{key:"getLabel",/**
13
- * Returns text for aria-label.
14
- * @returns {string}
15
- */value:function getLabel(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var lang=this.props.active?'favorites.remove':'favorites.add';return __(lang);}/**
8
+ */_defineProperty(_this2,"onRippleComplete",function(){_this2.props.onRippleComplete(_this2.props.active);});/**
16
9
  * Adds or removes a given product ID from the favorite list.
17
10
  * @param {Object} event The click event object.
18
- */},{key:"renderIcon",/**
11
+ */_defineProperty(_this2,"handleClick",function(event){event.preventDefault();event.stopPropagation();if(_this2.props.once&&_this2.clickedOnce){return;}_this2.clickedOnce=true;if(!_this2.props.productId){return;}// When wishlist item quantity is active, items cannot be removed via the button
12
+ if(!_this2.props.active||_this2.props.wishlistItemQuantityEnabled){_this2.props.addFavorites(_this2.props.productId);}else{setTimeout(function(){_this2.props.removeFavorites(_this2.props.productId,_this2.props.removeWithRelatives);},_this2.props.removeThrottle);}});_this2.clickedOnce=false;return _this2;}_inherits(FavoritesButton,_Component);return _createClass(FavoritesButton,[{key:"getLabel",value:/**
13
+ * Returns text for aria-label.
14
+ * @returns {string}
15
+ */function getLabel(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var lang=this.props.active?'favorites.remove':'favorites.add';return __(lang);}},{key:"renderIcon",value:/**
19
16
  * Renders the heart icon as filled or outlined, depending on the favorite button being active.
20
17
  * @returns {JSX}
21
- */value:function renderIcon(){if(!this.props.loadWishlistOnAppStartEnabled||this.props.wishlistItemQuantityEnabled&&!this.props.active){return React.createElement(HeartPlusOutlineIcon,null);}if(this.props.wishlistItemQuantityEnabled&&this.props.active){return React.createElement(HeartPlus,null);}if(this.props.active){return React.createElement(HeartIcon,null);}return React.createElement(HeartOutlineIcon,null);}/**
18
+ */function renderIcon(){if(!this.props.loadWishlistOnAppStartEnabled||this.props.wishlistItemQuantityEnabled&&!this.props.active){return React.createElement(HeartPlusOutlineIcon,null);}if(this.props.wishlistItemQuantityEnabled&&this.props.active){return React.createElement(HeartPlus,null);}if(this.props.active){return React.createElement(HeartIcon,null);}return React.createElement(HeartOutlineIcon,null);}/**
22
19
  * Renders the component.
23
20
  * @returns {JSX|null}
24
- */},{key:"render",value:function render(){if(!appConfig.hasFavorites){return null;}var className=this.props.noShadow?styles.buttonFlat:styles.button;return React.createElement("button",{"aria-label":this.getLabel(),"aria-hidden":this.props['aria-hidden'],className:"".concat(className," ").concat(this.props.className),onClick:this.handleClick,"data-test-id":"favoriteButton",type:"button"},React.createElement(Ripple,{className:"".concat(styles.ripple," ").concat(this.props.rippleClassName),onComplete:this.onRippleComplete},this.renderIcon()));}}]);return FavoritesButton;}(Component);_defineProperty(FavoritesButton,"contextTypes",{i18n:PropTypes.func});_defineProperty(FavoritesButton,"defaultProps",{active:false,addFavorites:function addFavorites(){},'aria-hidden':null,className:'',noShadow:false,once:false,onRippleComplete:function onRippleComplete(){},productId:null,removeFavorites:function removeFavorites(){},removeThrottle:0,removeWithRelatives:false,rippleClassName:'',wishlistItemQuantityEnabled:false,loadWishlistOnAppStartEnabled:true});export default connect(FavoritesButton);
21
+ */},{key:"render",value:function render(){if(!appConfig.hasFavorites){return null;}var className=this.props.noShadow?styles.buttonFlat:styles.button;return React.createElement("button",{"aria-label":this.getLabel(),"aria-hidden":this.props['aria-hidden'],className:"ui-shared__favorites-button ".concat(className," ").concat(this.props.className),onClick:this.handleClick,"data-test-id":"favoriteButton",type:"button"},React.createElement(Ripple,{className:"".concat(styles.ripple," ").concat(this.props.rippleClassName),onComplete:this.onRippleComplete},this.renderIcon()));}}]);}(Component);/**
22
+ * Context types definition.
23
+ * @type {{i18n: shim}}
24
+ */_defineProperty(FavoritesButton,"contextTypes",{i18n:PropTypes.func});_defineProperty(FavoritesButton,"defaultProps",{active:false,addFavorites:function addFavorites(){},'aria-hidden':null,className:'',noShadow:false,once:false,onRippleComplete:function onRippleComplete(){},productId:null,removeFavorites:function removeFavorites(){},removeThrottle:0,removeWithRelatives:false,rippleClassName:'',wishlistItemQuantityEnabled:false,loadWishlistOnAppStartEnabled:true});export default connect(FavoritesButton);
package/Footer/index.js CHANGED
@@ -1,25 +1,25 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import Portal from'@shopgate/pwa-common/components/Portal';import{logger}from'@shopgate/pwa-core/helpers';import UIEvents from'@shopgate/pwa-core/emitters/ui';import{APP_FOOTER_CONTENT_BEFORE,APP_FOOTER_CONTENT_AFTER}from'@shopgate/pwa-common/constants/Portals';import{getAbsoluteHeight,getStyle}from'@shopgate/pwa-common/helpers/dom';import{SHEET_EVENTS}from"../Sheet";import{footer,withInset,updateInsetBackgroundColor,updateFooterHeight}from"./style";var APP_FOOTER_ID='AppFooter';var DATA_IGNORED='data-footer-inset-update-ignore';/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import Portal from'@shopgate/pwa-common/components/Portal';import{logger}from'@shopgate/pwa-core/helpers';import UIEvents from'@shopgate/pwa-core/emitters/ui';import{APP_FOOTER_CONTENT_BEFORE,APP_FOOTER_CONTENT_AFTER}from'@shopgate/pwa-common/constants/Portals';import{getAbsoluteHeight,getStyle}from'@shopgate/pwa-common/helpers/dom';import{SHEET_EVENTS}from"../Sheet";import{footer,withInset,updateInsetBackgroundColor,updateFooterHeight}from"./style";var APP_FOOTER_ID='AppFooter';var DATA_IGNORED='data-footer-inset-update-ignore';/**
2
2
  * The Footer Component
3
3
  * @deprecated
4
- */var Footer=/*#__PURE__*/function(_Component){_inherits(Footer,_Component);function Footer(){var _getPrototypeOf2;var _this;_classCallCheck(this,Footer);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(Footer)).call.apply(_getPrototypeOf2,[this].concat(args)));_defineProperty(_assertThisInitialized(_this),"ref",React.createRef());_defineProperty(_assertThisInitialized(_this),"hide",function(){if(_this.ref.current){updateFooterHeight(0);}});_defineProperty(_assertThisInitialized(_this),"show",function(){if(_this.ref.current){updateFooterHeight(getAbsoluteHeight(_this.ref.current));}});return _this;}_createClass(Footer,[{key:"componentDidMount",value:function componentDidMount(){var _this2=this;logger.warn('DEPRECATED: @shopgate/pwa-ui-shared/Footer is deprecated. Please use: import { Footer } from \'@shopgate/engage/components.\'');this.performFooterUpdate();var observer=new MutationObserver(function(mutations){var update=mutations.filter(function(mutation){return mutation.target.getAttribute(DATA_IGNORED)!=='true';}).length>0;if(update){_this2.performFooterUpdate();}});observer.observe(this.ref.current,{attributes:true,childList:true,subtree:true});UIEvents.addListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.addListener(SHEET_EVENTS.CLOSE,this.show);}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.removeListener(SHEET_EVENTS.CLOSE,this.show);}},{key:"getInsetBackgroundColor",/**
4
+ */var Footer=/*#__PURE__*/function(_Component){function Footer(){var _this2;_classCallCheck(this,Footer);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,Footer,[].concat(args));_defineProperty(_this2,"ref",React.createRef());/** Perform hide action */_defineProperty(_this2,"hide",function(){if(_this2.ref.current){updateFooterHeight(0);}});/** Perform show action */_defineProperty(_this2,"show",function(){if(_this2.ref.current){updateFooterHeight(getAbsoluteHeight(_this2.ref.current));}});return _this2;}_inherits(Footer,_Component);return _createClass(Footer,[{key:"componentDidMount",value:function componentDidMount(){var _this3=this;logger.warn('DEPRECATED: @shopgate/pwa-ui-shared/Footer is deprecated. Please use: import { Footer } from \'@shopgate/engage/components.\'');this.performFooterUpdate();var observer=new MutationObserver(function(mutations){var update=mutations.filter(function(mutation){return mutation.target.getAttribute(DATA_IGNORED)!=='true';}).length>0;if(update){_this3.performFooterUpdate();}});observer.observe(this.ref.current,{attributes:true,childList:true,subtree:true});UIEvents.addListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.addListener(SHEET_EVENTS.CLOSE,this.show);}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.removeListener(SHEET_EVENTS.CLOSE,this.show);}},{key:"getInsetBackgroundColor",value:/**
5
5
  * Retrieves the background color for the footer inset.
6
6
  * @param {NodeList} elements The DOM elements to inspect.
7
7
  * @returns {string|null}
8
- */value:function getInsetBackgroundColor(elements){var _this3=this;/**
8
+ */function getInsetBackgroundColor(elements){var _this4=this;/**
9
9
  * The background color of the bottom inset needs to identical to the last entry of the footer.
10
10
  * So we loop backwards to the elements to find the first visible one.
11
11
  */var color=Array.from(elements).reverse().reduce(function(result,element){var ignore=element.getAttribute(DATA_IGNORED)==='true';if(result||ignore){// Nothing to do, since the color was already determined or the element can be ignored.
12
12
  return result;}if(element.id===APP_FOOTER_ID){// Inspect core portal.
13
- return _this3.getInsetBackgroundColor(element.children);}if(element.clientHeight){// Take the background color of the last visible element from the end of the footer.
13
+ return _this4.getInsetBackgroundColor(element.children);}if(element.clientHeight){// Take the background color of the last visible element from the end of the footer.
14
14
  return getStyle(element,'backgroundColor');}// Nothing happened within this loop - proceed with the next one.
15
- return result;},null);if(color==='rgba(0, 0, 0, 0)'||color==='transparent'){return null;}return color||null;}/** Perform hide action */},{key:"performFooterUpdate",/**
15
+ return result;},null);if(color==='rgba(0, 0, 0, 0)'||color==='transparent'){return null;}return color||null;}},{key:"performFooterUpdate",value:/**
16
16
  * Performs an update of the footer: background color, height.
17
- */value:function performFooterUpdate(){if(this.ref.current){this.ref.current.classList.toggle(withInset,this.hasVisibleContent());updateFooterHeight(getAbsoluteHeight(this.ref.current));updateInsetBackgroundColor(this.getInsetBackgroundColor(this.ref.current.children));}}/**
17
+ */function performFooterUpdate(){if(this.ref.current){this.ref.current.classList.toggle(withInset,this.hasVisibleContent());updateFooterHeight(getAbsoluteHeight(this.ref.current));updateInsetBackgroundColor(this.getInsetBackgroundColor(this.ref.current.children));}}/**
18
18
  * Checks if the footer has visible content.
19
19
  * @returns {boolean}
20
20
  */},{key:"hasVisibleContent",value:function hasVisibleContent(){if(this.ref.current){var elements=this.ref.current.parentElement.querySelectorAll("div.".concat(footer.toString()," > *:not(#").concat(APP_FOOTER_ID,"), #").concat(APP_FOOTER_ID," > *"));return Array.from(elements).filter(function(element){return element.getAttribute(DATA_IGNORED)!=='true'&&element.clientHeight>0;}).length>0;}return false;}/**
21
21
  * @returns {JSX}
22
- */},{key:"render",value:function render(){return React.createElement("div",{className:footer,ref:this.ref},React.createElement(Portal,{name:APP_FOOTER_CONTENT_BEFORE}),React.createElement("div",{id:APP_FOOTER_ID},this.props.children),React.createElement(Portal,{name:APP_FOOTER_CONTENT_AFTER}));}}]);return Footer;}(Component);_defineProperty(Footer,"defaultProps",{children:null/**
22
+ */},{key:"render",value:function render(){return React.createElement("div",{className:"".concat(footer," ui-shared__footer"),ref:this.ref},React.createElement(Portal,{name:APP_FOOTER_CONTENT_BEFORE}),React.createElement("div",{id:APP_FOOTER_ID},this.props.children),React.createElement(Portal,{name:APP_FOOTER_CONTENT_AFTER}));}}]);}(Component);_defineProperty(Footer,"defaultProps",{children:null/**
23
23
  * Sets up the DOM Mutation Observer to take care that the footer inset always has the correct
24
24
  * background color, which matches the background color of the last element within the footer.
25
25
  */});export default Footer;
@@ -1,4 +1,4 @@
1
- function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE}from"../elementTypes";/** Noop function */var noop=function noop(){};/**
1
+ var _excluded=["custom"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE}from"../elementTypes";/** Noop function */var noop=function noop(){};/**
2
2
  * @typedef {Object} FormElement
3
3
  * @property {string} id
4
4
  * @property {boolean} custom
@@ -26,6 +26,6 @@ function _objectWithoutProperties(source,excluded){if(source==null)return{};var
26
26
  */var addFormElement=function addFormElement(id,field){var custom=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;// The "custom" field is just a placeholder for more fields
27
27
  if(typeof field.type!=='string'){return;}// Make sure country and province elements are only added once
28
28
  if(field.type===ELEMENT_TYPE_COUNTRY){if(hasCountryElement){logger.error("Error: Can not add multiple elements of type '".concat(field.type,"'"));return;}hasCountryElement=true;}if(field.type===ELEMENT_TYPE_PROVINCE){if(hasProvinceElement){logger.error("Error: Can not add multiple elements of type '".concat(field.type,"'"));return;}hasProvinceElement=true;}elementList.push(_extends({id:id},field,{custom:custom,handleChange:function handleChange(value){return elementChangeHandler(id,value);}}));};// Extract custom fields, do not mix with normal fields
29
- var _formConfig$fields=formConfig.fields,custom=_formConfig$fields.custom,restFields=_objectWithoutProperties(_formConfig$fields,["custom"]);// Add all non-custom attributes and mark them as such
29
+ var _formConfig$fields=formConfig.fields,custom=_formConfig$fields.custom,restFields=_objectWithoutProperties(_formConfig$fields,_excluded);// Add all non-custom attributes and mark them as such
30
30
  Object.keys(restFields).forEach(function(id){addFormElement(id,formConfig.fields[id]);});// Add custom fields to the element list
31
31
  if(custom){Object.keys(custom).forEach(function(id){addFormElement(id,formConfig.fields.custom[id],true);});}return elementList;});
@@ -1,2 +1,2 @@
1
- var _ACTION_RULE_DATA_TYP;function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}export var ACTION_TYPE_UPDATE_PROVINCE_ELEMENT='updateProvinceElement';export var ACTION_TYPE_SET_VISIBILITY='setVisibility';export var ACTION_TYPE_SET_VALUE='setValue';export var ACTION_TYPE_TRANSFORM='transform';export var ACTION_SET_VALUE_FIXED='fixed';export var ACTION_SET_VALUE_COPY_FROM='copyFrom';export var ACTION_SET_VALUE_LENGTH_OF='lengthOf';export var ACTION_RULE_TYPE_NOT_IN='notIn';export var ACTION_RULE_TYPE_ONE_OF='oneOf';export var ACTION_RULE_TYPE_BOOLEAN='boolean';export var ACTION_RULE_TYPE_REGEX='regex';// Rule data is formatted as array
2
- export var ACTION_RULE_DATA_TYPES=(_ACTION_RULE_DATA_TYP={},_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_NOT_IN,'array'),_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_ONE_OF,'array'),_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_BOOLEAN,'boolean'),_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_REGEX,'string'),_ACTION_RULE_DATA_TYP);export var ACTION_RULES_CONCAT_METHOD_ALL='all';export var ACTION_RULES_CONCAT_METHOD_ANY='any';export var ACTION_RULES_CONCAT_METHOD_NONE='none';
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}export var ACTION_TYPE_UPDATE_PROVINCE_ELEMENT='updateProvinceElement';export var ACTION_TYPE_SET_VISIBILITY='setVisibility';export var ACTION_TYPE_SET_VALUE='setValue';export var ACTION_TYPE_TRANSFORM='transform';export var ACTION_SET_VALUE_FIXED='fixed';export var ACTION_SET_VALUE_COPY_FROM='copyFrom';export var ACTION_SET_VALUE_LENGTH_OF='lengthOf';export var ACTION_RULE_TYPE_NOT_IN='notIn';export var ACTION_RULE_TYPE_ONE_OF='oneOf';export var ACTION_RULE_TYPE_BOOLEAN='boolean';export var ACTION_RULE_TYPE_REGEX='regex';// Rule data is formatted as array
2
+ export var ACTION_RULE_DATA_TYPES=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},ACTION_RULE_TYPE_NOT_IN,'array'),ACTION_RULE_TYPE_ONE_OF,'array'),ACTION_RULE_TYPE_BOOLEAN,'boolean'),ACTION_RULE_TYPE_REGEX,'string');export var ACTION_RULES_CONCAT_METHOD_ALL='all';export var ACTION_RULES_CONCAT_METHOD_ANY='any';export var ACTION_RULES_CONCAT_METHOD_NONE='none';
@@ -1,10 +1,14 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX}from"../../elementTypes";import{ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,ACTION_TYPE_SET_VISIBILITY,ACTION_TYPE_SET_VALUE,ACTION_TYPE_TRANSFORM,ACTION_SET_VALUE_FIXED,ACTION_SET_VALUE_COPY_FROM,ACTION_SET_VALUE_LENGTH_OF,ACTION_RULE_TYPE_NOT_IN,ACTION_RULE_TYPE_ONE_OF,ACTION_RULE_TYPE_BOOLEAN,ACTION_RULE_TYPE_REGEX,ACTION_RULE_DATA_TYPES,ACTION_RULES_CONCAT_METHOD_ALL,ACTION_RULES_CONCAT_METHOD_ANY,ACTION_RULES_CONCAT_METHOD_NONE}from"./constants";/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX}from"../../elementTypes";import{ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,ACTION_TYPE_SET_VISIBILITY,ACTION_TYPE_SET_VALUE,ACTION_TYPE_TRANSFORM,ACTION_SET_VALUE_FIXED,ACTION_SET_VALUE_COPY_FROM,ACTION_SET_VALUE_LENGTH_OF,ACTION_RULE_TYPE_NOT_IN,ACTION_RULE_TYPE_ONE_OF,ACTION_RULE_TYPE_BOOLEAN,ACTION_RULE_TYPE_REGEX,ACTION_RULE_DATA_TYPES,ACTION_RULES_CONCAT_METHOD_ALL,ACTION_RULES_CONCAT_METHOD_ANY,ACTION_RULES_CONCAT_METHOD_NONE}from"./constants";/**
2
2
  * ActionListener and handler for the FormBuilder component
3
- */var ActionListener=/**
3
+ */var ActionListener=/*#__PURE__*/_createClass(/**
4
4
  * Constructor
5
5
  * @param {function(string)} getProvincesList Takes a country code and returns a list of provinces
6
6
  * @param {Object} defaults Form defaults
7
- */function ActionListener(getProvincesList,defaults){var _this=this;_classCallCheck(this,ActionListener);_defineProperty(this,"attachAll",function(elementList){// Attach action listeners for element (context) actions
7
+ */function ActionListener(getProvincesList,defaults){var _this=this;_classCallCheck(this,ActionListener);/**
8
+ * Takes the elements to be rendered by the FormBuilder and attaches available action listeners
9
+ * to the component.
10
+ * @param {FormElement[]} elementList List of all elements
11
+ */_defineProperty(this,"attachAll",function(elementList){// Attach action listeners for element (context) actions
8
12
  elementList.forEach(function(element){var elementActions=element.actions;if(element.type===ELEMENT_TYPE_PROVINCE){elementActions=elementActions||[];// Requires a country element to create a "update provinces" action
9
13
  var countryElement=elementList.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});if(countryElement){// Attach new action, which is always triggered, when the (only) country element changes
10
14
  elementActions.push({type:ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,rules:[{context:countryElement.id}]});}}if(elementActions===undefined){return;}// Create listeners for all supported actions
@@ -12,29 +16,82 @@ elementActions.forEach(function(action){var actionRules=action.rules||[];// Alwa
12
16
  if(actionRules.length===0){// Define a basic rule if no rules given
13
17
  actionRules.push({context:element.id});}// Actions do have a fixed structure which needs to be fulfilled
14
18
  var normalizedAction=_extends({},action,{rules:actionRules});// Assign the action listeners to all contexts of the current element
15
- actionRules.forEach(function(rule){_this.attach(element,normalizedAction,rule);});});});});_defineProperty(this,"attach",function(element,action,rule){var actionListener;switch(action.type){case ACTION_TYPE_UPDATE_PROVINCE_ELEMENT:{actionListener=_this.createUpdateProvinceElementHandler(element,action);break;}case ACTION_TYPE_SET_VISIBILITY:{// Visibility is special and uses the result of the evaluation itself
16
- actionListener=_this.createSetVisibilityHandler(element,action);break;}case ACTION_TYPE_SET_VALUE:{actionListener=_this.createEvaluatedHandler(element,action,_this.createSetValueHandler(element,action));break;}case ACTION_TYPE_TRANSFORM:{actionListener=_this.createEvaluatedHandler(element,action,_this.createTransformHandler(element,action));break;}default:return;}_this.register(rule.context,actionListener);});_defineProperty(this,"createEvaluatedHandler",function(element,action,actionListener){return function(prevState,nextState){// Apply rules before accepting any changes
17
- if(!_this.evaluateRules(element,action,nextState)){return nextState;}return actionListener(prevState,nextState);};});_defineProperty(this,"createUpdateProvinceElementHandler",function(provinceEl,action){return function(prevState,nextState){var countryElementId=action.rules[0].context;var countryValue=nextState.formData[countryElementId];var countryDefault=_this.defaults[countryElementId];var newState=_extends({},nextState);// Overwrite province with the form's default, if country matches the default as well
19
+ actionRules.forEach(function(rule){_this.attach(element,normalizedAction,rule);});});});});/**
20
+ * Attaches one or possibly multiple action listeners for the given rule
21
+ * @param {FormElement} element The current element that is modified by the action
22
+ * @param {FormFieldAction} action The action and it's params
23
+ * @param {FormFieldActionRule} rule The rule to check in case the action listener is triggered
24
+ */_defineProperty(this,"attach",function(element,action,rule){var actionListener;switch(action.type){case ACTION_TYPE_UPDATE_PROVINCE_ELEMENT:{actionListener=_this.createUpdateProvinceElementHandler(element,action);break;}case ACTION_TYPE_SET_VISIBILITY:{// Visibility is special and uses the result of the evaluation itself
25
+ actionListener=_this.createSetVisibilityHandler(element,action);break;}case ACTION_TYPE_SET_VALUE:{actionListener=_this.createEvaluatedHandler(element,action,_this.createSetValueHandler(element,action));break;}case ACTION_TYPE_TRANSFORM:{actionListener=_this.createEvaluatedHandler(element,action,_this.createTransformHandler(element,action));break;}default:return;}_this.register(rule.context,actionListener);});/**
26
+ * Action listener creator to check all related rules before calling any further action listeners
27
+ * @param {FormElement} element The element for which the listener should be created for
28
+ * @param {FormFieldAction} action The action to be create a listener for
29
+ * @param {Function} actionListener The action listener to call if the rule applies
30
+ * @returns {Function} Returns a function to modify and return the modified state.
31
+ */_defineProperty(this,"createEvaluatedHandler",function(element,action,actionListener){return function(prevState,nextState){// Apply rules before accepting any changes
32
+ if(!_this.evaluateRules(element,action,nextState)){return nextState;}return actionListener(prevState,nextState);};});/**
33
+ * Action listener creator to handle "updateCountryChange" action
34
+ * @param {FormElement} provinceEl The element for which the listener should be created for
35
+ * @param {FormFieldAction} action The action to be create a listener for
36
+ * @returns {Function} Returns a function to modify and return the modified state.
37
+ */_defineProperty(this,"createUpdateProvinceElementHandler",function(provinceEl,action){return function(prevState,nextState){var countryElementId=action.rules[0].context;var countryValue=nextState.formData[countryElementId];var countryDefault=_this.defaults[countryElementId];var newState=_extends({},nextState);// Overwrite province with the form's default, if country matches the default as well
18
38
  if(countryValue===countryDefault){newState.formData[provinceEl.id]=_this.defaults[provinceEl.id];}else{// Update province to first or no selection, based on "required" attribute
19
- newState.formData[provinceEl.id]=!provinceEl.required?'':Object.keys(_this.getProvincesList(countryValue))[0];}return newState;};});_defineProperty(this,"createSetVisibilityHandler",function(element,action){return function(prevState,nextState){var newState=_extends({},nextState,{elementVisibility:_extends({},nextState.elementVisibility,_defineProperty({},element.id,_this.evaluateRules(element,action,nextState))),// Copy form data to be able to check changes and all follow up actions
39
+ newState.formData[provinceEl.id]=!provinceEl.required?'':Object.keys(_this.getProvincesList(countryValue))[0];}return newState;};});/**
40
+ * Action listener creator to handle "setVisibility" actions
41
+ * @param {FormElement} element The element for which the listener should be created for
42
+ * @param {FormFieldAction} action The action to be create a listener for
43
+ * @returns {Function} Returns a function to modify and return the modified state.
44
+ */_defineProperty(this,"createSetVisibilityHandler",function(element,action){return function(prevState,nextState){var newState=_extends({},nextState,{elementVisibility:_extends({},nextState.elementVisibility,_defineProperty({},element.id,_this.evaluateRules(element,action,nextState))),// Copy form data to be able to check changes and all follow up actions
20
45
  formData:_extends({},nextState.formData)});if(newState.formData[element.id]===undefined&&newState.elementVisibility[element.id]){newState.formData[element.id]=_this.defaults[element.id];}else if(!newState.elementVisibility[element.id]&&newState.formData[element.id]!==undefined){delete newState.formData[element.id];}// Notify follow up listeners about the current change
21
- if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});_defineProperty(this,"createSetValueHandler",function(element,action){return function(prevState,nextState){if(_typeof(action.params)!=='object'||Array.isArray(action.params)){logger.error("Error: Invalid or missing form action in element '".concat(element.id,"'. ")+'Params must be in the format: { "type": string, "value": string }');return nextState;}var value=action.params.value;// Check correctness of value data type
46
+ if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
47
+ * Action listener creator to handle "setValue" actions
48
+ * @param {FormElement} element The element for which the listener should be created for
49
+ * @param {FormFieldAction} action The action to be create a listener for
50
+ * @returns {Function} Returns the modified state.
51
+ */_defineProperty(this,"createSetValueHandler",function(element,action){return function(prevState,nextState){if(_typeof(action.params)!=='object'||Array.isArray(action.params)){logger.error("Error: Invalid or missing form action in element '".concat(element.id,"'. ")+'Params must be in the format: { "type": string, "value": string }');return nextState;}var value=action.params.value;// Check correctness of value data type
22
52
  switch(_typeof(value)){case'boolean':if(element.type!==ELEMENT_TYPE_CHECKBOX){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_CHECKBOX,"' data type for 'params.value' is: 'boolean'"));return nextState;}break;case'number':if(element.type!==ELEMENT_TYPE_NUMBER){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_NUMBER,"' data types for 'params.value' are: ")+"'number' and 'string'");return nextState;}break;case'string':if(element.type===ELEMENT_TYPE_CHECKBOX){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_CHECKBOX,"' data type for 'params.value' is: 'boolean'"));return nextState;}break;default:logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Can not use '".concat(_typeof(value),"' data for elements of type '").concat(element.type,"'"));return nextState;}// Perform action based on "setValue" type, defined in params
23
53
  switch(action.params.type){case ACTION_SET_VALUE_LENGTH_OF:value="".concat(nextState.formData[action.params.value].length);break;case ACTION_SET_VALUE_COPY_FROM:value=nextState.formData[action.params.value];break;case undefined:case ACTION_SET_VALUE_FIXED:break;default:logger.error("Error: Invalid form action param 'type' in element '".concat(element.id,"'. ")+"Allowed param types are: '".concat(ACTION_SET_VALUE_LENGTH_OF,"', ")+"'".concat(ACTION_SET_VALUE_COPY_FROM,"', '").concat(ACTION_SET_VALUE_FIXED,"'"));return nextState;}var newState=_extends({},nextState,{formData:_extends({},nextState.formData,_defineProperty({},element.id,value))});// Notify follow up listeners about the current change, if there are any changes
24
- if(nextState.formData[element.id]!==value){newState=_this.notify(element.id,prevState,newState);}return newState;};});_defineProperty(this,"createTransformHandler",function(element,action){return function(prevState,nextState){/**
54
+ if(nextState.formData[element.id]!==value){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
55
+ * Action listener creator to handle "transform" actions
56
+ * @param {FormElement} element The element for which the listener should be created for
57
+ * @param {FormFieldAction} action The action to be create a listener for
58
+ * @returns {Function} Returns a function to modify and return the modified state.
59
+ */_defineProperty(this,"createTransformHandler",function(element,action){return function(prevState,nextState){/**
25
60
  * Takes a string and applies a case function on it
26
61
  * @param {string|boolean|number} subject The subject to be transformed
27
62
  * @returns {string|boolean|number}
28
63
  */var transform=function transform(subject){// Get optional params to be applied in the transformation process
29
64
  var args=action.params.value||[];if(Array.isArray(action.params.value)){args=action.params.value;}switch(_typeof(subject)){case'string':{if(typeof String.prototype[action.params.type]!=='function'&&typeof String[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof String.prototype[action.params.type]==='function'){return String.prototype[action.params.type].apply(subject,args);}return String[action.params.type](subject);}case'boolean':{if(typeof Boolean.prototype[action.params.type]!=='function'&&typeof Boolean[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof Boolean.prototype[action.params.type]==='function'){return Boolean.prototype[action.params.type].apply(subject,args);}return Boolean[action.params.type](subject);}case'number':{if(typeof Number.prototype[action.params.type]!=='function'&&typeof Number[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof Number.prototype[action.params.type]==='function'){return Number.prototype[action.params.type].apply(subject,args);}return Number[action.params.type](subject);}default:logger.error("Error: The given data can not be transformed. Must be of type 'string', "+"'boolean' or 'number'");return subject;}};var newState=_extends({},nextState,{formData:_extends({},nextState.formData,_defineProperty({},element.id,transform(nextState.formData[element.id])))});// Notify follow up listeners about the current change
30
- if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});_defineProperty(this,"evaluateRules",function(element,action,nextState){var concatRules=_this.createConcatMethod(action.ruleConcatMethod);var resultInitValue=action.ruleConcatMethod!==ACTION_RULES_CONCAT_METHOD_ANY;var result=resultInitValue;action.rules.forEach(function(rule){var tmpResult=resultInitValue;var ruleType=rule.type;var ruleData=rule.data;// Default to rule type "boolean" and data true when type not given
65
+ if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
66
+ * Evaluates all action rules of a given element action
67
+ *
68
+ * @param {FormElement} element The element of which the action rules should be evaluated
69
+ * @param {FormFieldAction} action The current action to be evaluate rules for
70
+ * @param {Object} nextState The state at the time before the "action" event finished
71
+ * @returns {boolean}
72
+ */_defineProperty(this,"evaluateRules",function(element,action,nextState){var concatRules=_this.createConcatMethod(action.ruleConcatMethod);var resultInitValue=action.ruleConcatMethod!==ACTION_RULES_CONCAT_METHOD_ANY;var result=resultInitValue;action.rules.forEach(function(rule){var tmpResult=resultInitValue;var ruleType=rule.type;var ruleData=rule.data;// Default to rule type "boolean" and data true when type not given
31
73
  if(ruleType===undefined){ruleType=ACTION_RULE_TYPE_BOOLEAN;ruleData=true;}// Check rule validity
32
74
  if(!ACTION_RULE_DATA_TYPES[ruleType]){logger.error("Error: Unknown action rule type '".concat(ruleType,"'in element '").concat(element.id,"'"));return;}// Check type of ruleData
33
75
  var ruleDataType=ACTION_RULE_DATA_TYPES[ruleType];if(ruleDataType==='array'&&!Array.isArray(ruleData)){logger.error("Error: Invalid FormBuilder action rule in element '".concat(element.id,"': ")+"data must be an 'array' for rule type '".concat(ruleType,"'"));return;}// eslint-disable-next-line valid-typeof
34
76
  if(ruleDataType!=='array'&&_typeof(ruleData)!==ruleDataType){logger.error("Error: Invalid FormBuilder action rule in element '".concat(element.id,"': ")+"data must be '".concat(ruleDataType,"' for rule type '").concat(ruleType,"'"));return;}switch(ruleType){case ACTION_RULE_TYPE_ONE_OF:{tmpResult=ruleData.includes(nextState.formData[rule.context]);break;}case ACTION_RULE_TYPE_NOT_IN:{tmpResult=!ruleData.includes(nextState.formData[rule.context]);break;}case ACTION_RULE_TYPE_BOOLEAN:{tmpResult=ruleData;break;}case ACTION_RULE_TYPE_REGEX:{var regexParts=ruleData.split('/');var regexPattern='';var regexParam='';if(regexParts.length===1){var _regexParts=_slicedToArray(regexParts,1);regexPattern=_regexParts[0];}else if(regexParts.length===3){regexParts.shift();var _regexParts2=_slicedToArray(regexParts,2);regexPattern=_regexParts2[0];var _regexParts2$=_regexParts2[1];regexParam=_regexParts2$===void 0?'':_regexParts2$;}else{logger.error("Error: Invalid regex string in action rule in element ".concat(element.id));break;}var regex=new RegExp(regexPattern,regexParam);tmpResult=regex.test(nextState.formData[rule.context]);break;}default:break;}// Concat rules based on the rule concat method of the action
35
- result=concatRules(result,tmpResult);});return result;});_defineProperty(this,"createConcatMethod",function(method){return function(prev,next){switch(method){case ACTION_RULES_CONCAT_METHOD_NONE:return prev&&!next;case ACTION_RULES_CONCAT_METHOD_ANY:return prev||next;case ACTION_RULES_CONCAT_METHOD_ALL:default:return prev&&next;}};});_defineProperty(this,"register",function(elementId,handler){if(!_this.actionListeners[elementId]){_this.actionListeners[elementId]=[];}_this.actionListeners[elementId].push(handler);});_defineProperty(this,"notify",function(elementId,prevState,nextState){var newState=nextState;if(_this.actionListeners[elementId]){_this.actionListeners[elementId].forEach(function(notifyListener){// Note: The order of state changes is applied in the same order of listener registration
36
- newState=notifyListener(prevState,newState);});}return newState;});this.defaults=defaults;this.getProvincesList=getProvincesList;this.actionListeners={};}/**
37
- * Takes the elements to be rendered by the FormBuilder and attaches available action listeners
38
- * to the component.
39
- * @param {FormElement[]} elementList List of all elements
40
- */;export default ActionListener;
77
+ result=concatRules(result,tmpResult);});return result;});/**
78
+ * Creates a concat function that defines how to concatenate action rule results
79
+ *
80
+ * @param {string} method The method defined by the action
81
+ * @returns {Function}
82
+ */_defineProperty(this,"createConcatMethod",function(method){return function(prev,next){switch(method){case ACTION_RULES_CONCAT_METHOD_NONE:return prev&&!next;case ACTION_RULES_CONCAT_METHOD_ANY:return prev||next;case ACTION_RULES_CONCAT_METHOD_ALL:default:return prev&&next;}};});/**
83
+ * Adds a "action" listener to a given context element
84
+ *
85
+ * @param {string} elementId the element to listen for
86
+ * @param {Function} handler The listener to call when something has changed
87
+ */_defineProperty(this,"register",function(elementId,handler){if(!_this.actionListeners[elementId]){_this.actionListeners[elementId]=[];}_this.actionListeners[elementId].push(handler);});/**
88
+ * Takes an element id, the state to work with and optional data and notifies all "action"
89
+ * listeners about the change. Every listener can manipulate the state.
90
+ * Returns the new state.
91
+ *
92
+ * @param {string} elementId The id of the element that was changed
93
+ * @param {Object} prevState The state before any changes took place
94
+ * @param {Object} nextState The state containing all updates before the listeners are executed
95
+ * @returns {Object} The new state after all handlers have been executed.
96
+ */_defineProperty(this,"notify",function(elementId,prevState,nextState){var newState=nextState;if(_this.actionListeners[elementId]){_this.actionListeners[elementId].forEach(function(notifyListener){// Note: The order of state changes is applied in the same order of listener registration
97
+ newState=notifyListener(prevState,newState);});}return newState;});this.defaults=defaults;this.getProvincesList=getProvincesList;this.actionListeners={};});export default ActionListener;
@@ -8,8 +8,8 @@ nextState={formData:{country:''}};expected={formData:{country:''},elementVisibil
8
8
  var element={id:'province'};var action={type:ACTION_TYPE_SET_VISIBILITY,rules:[{context:'country',type:ACTION_RULE_TYPE_ONE_OF,data:['US']}]};var actionListener=new ActionListener(mockGetProvincesList,{});var handleVisibility=actionListener.createSetVisibilityHandler(element,action);// Province element is supposed to be hidden and therefore the follow up
9
9
  var followUpHandler=jest.fn();actionListener.register('province',followUpHandler);var prevState={formData:{province:'to be changed'}};var nextStateBeforeVisibilityChange={formData:{country:'',province:'to be changed'}};var nextStateAfterVisibilityChange={elementVisibility:{province:false},formData:{country:''}};handleVisibility(prevState,nextStateBeforeVisibilityChange);expect(followUpHandler).toHaveBeenCalledWith(prevState,nextStateAfterVisibilityChange);});});describe('updateProvinceElementHandler',function(){it('should select the first province in the list, when country changes and no default is '+'available',function(){// -------------------------------------------------------------------------------------------
10
10
  var element={id:'province',required:true};var action={type:'update',rules:[{context:'country'}]};var actionListener=new ActionListener(mockGetProvincesList,{});var handler=actionListener.createUpdateProvinceElementHandler(element,action);var prevState={formData:{province:''}};var nextState={formData:{country:'US'}};// eslint-disable-next-line extra-rules/no-single-line-objects
11
- var expected={formData:{country:'US',province:'ST'}};expect(handler(prevState,nextState)).toEqual(expected);});it('should select the default province in the list on country changes when a match with '+'default is available',function(){var _formData2;// -------------------------------------------------------------------------------------------
12
- var provinceElement={id:'province',"default":'DF',required:true};var countryElement={id:'country',"default":'US'};var action={type:'update',rules:[{context:countryElement.id}]};var prevState={};var nextState={formData:_defineProperty({},countryElement.id,countryElement["default"])};var expected={formData:(_formData2={},_defineProperty(_formData2,provinceElement.id,provinceElement["default"]),_defineProperty(_formData2,countryElement.id,countryElement["default"]),_formData2)};// Defaults matches the same object structure as 'formData'
11
+ var expected={formData:{country:'US',province:'ST'}};expect(handler(prevState,nextState)).toEqual(expected);});it('should select the default province in the list on country changes when a match with '+'default is available',function(){// -------------------------------------------------------------------------------------------
12
+ var provinceElement={id:'province',"default":'DF',required:true};var countryElement={id:'country',"default":'US'};var action={type:'update',rules:[{context:countryElement.id}]};var prevState={};var nextState={formData:_defineProperty({},countryElement.id,countryElement["default"])};var expected={formData:_defineProperty(_defineProperty({},provinceElement.id,provinceElement["default"]),countryElement.id,countryElement["default"])};// Defaults matches the same object structure as 'formData'
13
13
  var actionListener=new ActionListener(mockGetProvincesList,expected.formData);var handler=actionListener.createUpdateProvinceElementHandler(provinceElement,action);// Expects the handler to take over the defaults in this test
14
14
  expect(handler(prevState,nextState)).toEqual(expected);});});describe('setValueHandler',function(){it('should create copy the referenced element value into the current element',function(){// -------------------------------------------------------------------------------------------
15
15
  var element={id:'street2'};var action={type:ACTION_TYPE_SET_VALUE,params:{type:ACTION_SET_VALUE_COPY_FROM,value:'street'}};var actionListener=new ActionListener(mockGetProvincesList,{});var handler=actionListener.createSetValueHandler(element,action);// eslint-disable-next-line extra-rules/no-single-line-objects
@@ -1,7 +1,7 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import Checkbox from"../../Checkbox";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import Checkbox from"../../Checkbox";/**
2
2
  * Takes an element and renders it, if the type matches
3
3
  * @param {Object} element The data of the element to be rendered
4
4
  * @returns {JSX}
5
- */var CheckboxElement=/*#__PURE__*/function(_PureComponent){_inherits(CheckboxElement,_PureComponent);function CheckboxElement(){_classCallCheck(this,CheckboxElement);return _possibleConstructorReturn(this,_getPrototypeOf(CheckboxElement).apply(this,arguments));}_createClass(CheckboxElement,[{key:"render",/**
5
+ */var CheckboxElement=/*#__PURE__*/function(_PureComponent){function CheckboxElement(){_classCallCheck(this,CheckboxElement);return _callSuper(this,CheckboxElement,arguments);}_inherits(CheckboxElement,_PureComponent);return _createClass(CheckboxElement,[{key:"render",value:/**
6
6
  * @returns {JSX}
7
- */value:function render(){var _this$props=this.props,element=_this$props.element,style=_this$props.style,errorText=_this$props.errorText,value=_this$props.value,name=_this$props.name;return React.createElement(Checkbox,{name:name,errorText:errorText,checked:value,className:style.fields,label:element.label,onChange:element.handleChange,translateErrorText:false});}}]);return CheckboxElement;}(PureComponent);_defineProperty(CheckboxElement,"defaultProps",{value:false,style:{fields:''}});export default CheckboxElement;
7
+ */function render(){var _this$props=this.props,element=_this$props.element,style=_this$props.style,errorText=_this$props.errorText,value=_this$props.value,name=_this$props.name;return React.createElement(Checkbox,{name:name,errorText:errorText,checked:value,className:style.fields,label:element.label,onChange:element.handleChange,translateErrorText:false});}}]);}(PureComponent);_defineProperty(CheckboxElement,"defaultProps",{value:false,style:{fields:''}});export default CheckboxElement;
@@ -1,7 +1,7 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import Select from"../../Select";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import Select from"../../Select";/**
2
2
  * React component that takes the element and additional data and renders a select box
3
3
  * with a list of countries to select from.
4
4
  * @returns {JSX}
5
- */var CountryElement=/*#__PURE__*/function(_PureComponent){_inherits(CountryElement,_PureComponent);function CountryElement(){_classCallCheck(this,CountryElement);return _possibleConstructorReturn(this,_getPrototypeOf(CountryElement).apply(this,arguments));}_createClass(CountryElement,[{key:"render",/**
5
+ */var CountryElement=/*#__PURE__*/function(_PureComponent){function CountryElement(){_classCallCheck(this,CountryElement);return _callSuper(this,CountryElement,arguments);}_inherits(CountryElement,_PureComponent);return _createClass(CountryElement,[{key:"render",value:/**
6
6
  * @returns {JSX}
7
- */value:function render(){var _this$props=this.props,countryList=_this$props.countryList,element=_this$props.element,errorText=_this$props.errorText,name=_this$props.name,style=_this$props.style,value=_this$props.value;return React.createElement(Select,{name:name,className:style.fields,label:element.label,placeholder:element.placeholder,value:value,options:countryList,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false});}}]);return CountryElement;}(PureComponent);_defineProperty(CountryElement,"defaultProps",{countryList:{},value:'',style:{fields:''}});export default CountryElement;
7
+ */function render(){var _this$props=this.props,countryList=_this$props.countryList,element=_this$props.element,errorText=_this$props.errorText,name=_this$props.name,style=_this$props.style,value=_this$props.value;return React.createElement(Select,{name:name,className:style.fields,label:element.label,placeholder:element.placeholder,value:value,options:countryList,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false});}}]);}(PureComponent);_defineProperty(CountryElement,"defaultProps",{countryList:{},value:'',style:{fields:''}});export default CountryElement;
@@ -1,7 +1,7 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import Select from"../../Select";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import Select from"../../Select";/**
2
2
  * React component that takes the element and additional data and renders a select box
3
3
  * with a list of provinces to select from.
4
4
  * @returns {JSX}
5
- */var ProvinceElement=/*#__PURE__*/function(_PureComponent){_inherits(ProvinceElement,_PureComponent);function ProvinceElement(){_classCallCheck(this,ProvinceElement);return _possibleConstructorReturn(this,_getPrototypeOf(ProvinceElement).apply(this,arguments));}_createClass(ProvinceElement,[{key:"render",/**
5
+ */var ProvinceElement=/*#__PURE__*/function(_PureComponent){function ProvinceElement(){_classCallCheck(this,ProvinceElement);return _callSuper(this,ProvinceElement,arguments);}_inherits(ProvinceElement,_PureComponent);return _createClass(ProvinceElement,[{key:"render",value:/**
6
6
  * @returns {JSX}
7
- */value:function render(){var _this$props=this.props,provincesList=_this$props.provincesList,element=_this$props.element,errorText=_this$props.errorText,name=_this$props.name,style=_this$props.style,value=_this$props.value;return React.createElement(Select,{name:name,className:style.fields,label:element.label,placeholder:element.placeholder,value:value,options:provincesList,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false});}}]);return ProvinceElement;}(PureComponent);_defineProperty(ProvinceElement,"defaultProps",{provincesList:{},value:'',style:{fields:''}});export default ProvinceElement;
7
+ */function render(){var _this$props=this.props,provincesList=_this$props.provincesList,element=_this$props.element,errorText=_this$props.errorText,name=_this$props.name,style=_this$props.style,value=_this$props.value;return React.createElement(Select,{name:name,className:style.fields,label:element.label,placeholder:element.placeholder,value:value,options:provincesList,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false});}}]);}(PureComponent);_defineProperty(ProvinceElement,"defaultProps",{provincesList:{},value:'',style:{fields:''}});export default ProvinceElement;
@@ -1,7 +1,7 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import RadioGroup from"../../RadioGroup";import RadioItem from"../../RadioGroup/components/Item";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import RadioGroup from"../../RadioGroup";import RadioItem from"../../RadioGroup/components/Item";/**
2
2
  * React component that takes the element and additional data and renders a radio group
3
3
  * with a list of radio items.
4
4
  * @returns {JSX}
5
- */var RadioElement=/*#__PURE__*/function(_PureComponent){_inherits(RadioElement,_PureComponent);function RadioElement(){_classCallCheck(this,RadioElement);return _possibleConstructorReturn(this,_getPrototypeOf(RadioElement).apply(this,arguments));}_createClass(RadioElement,[{key:"render",/**
5
+ */var RadioElement=/*#__PURE__*/function(_PureComponent){function RadioElement(){_classCallCheck(this,RadioElement);return _callSuper(this,RadioElement,arguments);}_inherits(RadioElement,_PureComponent);return _createClass(RadioElement,[{key:"render",value:/**
6
6
  * @returns {JSX}
7
- */value:function render(){var _this$props=this.props,element=_this$props.element,errorText=_this$props.errorText,name=_this$props.name,style=_this$props.style,value=_this$props.value;return React.createElement(RadioGroup,{name:name,className:style.fields,label:element.label,value:value,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false},Object.keys(element.options).map(function(itemName){return React.createElement(RadioItem,{key:itemName,name:itemName,label:element.options[itemName]});}));}}]);return RadioElement;}(PureComponent);_defineProperty(RadioElement,"defaultProps",{value:'',style:{fields:''}});export default RadioElement;
7
+ */function render(){var _this$props=this.props,element=_this$props.element,errorText=_this$props.errorText,name=_this$props.name,style=_this$props.style,value=_this$props.value;return React.createElement(RadioGroup,{name:name,className:style.fields,label:element.label,value:value,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false},Object.keys(element.options).map(function(itemName){return React.createElement(RadioItem,{key:itemName,name:itemName,label:element.options[itemName]});}));}}]);}(PureComponent);_defineProperty(RadioElement,"defaultProps",{value:'',style:{fields:''}});export default RadioElement;