@shopgate/pwa-common 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.
- package/App.js +6 -6
- package/actions/app/handleLink.js +7 -5
- package/actions/client/fetchClientInformation.js +1 -1
- package/actions/page/fetchPageConfig.js +2 -2
- package/actions/user/login.js +2 -2
- package/collections/AuthRoutes.js +3 -3
- package/collections/Configuration.js +3 -3
- package/collections/EmbeddedMedia.js +2 -2
- package/collections/PersistedReducers.js +2 -2
- package/collections/Redirects.js +3 -3
- package/collections/media-providers/MediaProvider.js +2 -2
- package/collections/media-providers/Vimeo.js +7 -7
- package/collections/media-providers/YouTube.js +5 -5
- package/components/Backdrop/index.js +11 -11
- package/components/Button/index.js +7 -7
- package/components/Checkbox/index.js +27 -14
- package/components/CountdownTimer/index.js +7 -7
- package/components/Drawer/index.js +13 -13
- package/components/Dropdown/index.js +5 -5
- package/components/Ellipsis/index.js +1 -1
- package/components/ErrorBoundary/index.js +5 -5
- package/components/Grid/components/Item/index.js +4 -4
- package/components/Grid/index.js +4 -4
- package/components/HtmlSanitizer/connector.js +5 -0
- package/components/HtmlSanitizer/index.js +10 -10
- package/components/HtmlSanitizer/spec.js +3 -3
- package/components/I18n/components/FormatPrice/index.js +2 -2
- package/components/I18n/components/I18nProvider/index.js +9 -9
- package/components/I18n/components/Translate/index.js +11 -7
- package/components/Icon/index.js +1 -1
- package/components/Image/index.js +9 -9
- package/components/Image/spec.js +2 -2
- package/components/InfiniteContainer/index.js +21 -21
- package/components/Input/components/DateInput.js +2 -2
- package/components/Input/components/MultiLineInput.js +10 -10
- package/components/Input/components/SimpleInput.js +27 -21
- package/components/KeyboardConsumer/index.js +7 -7
- package/components/Link/index.js +8 -5
- package/components/List/components/Item/index.js +1 -1
- package/components/List/index.js +1 -1
- package/components/Modal/index.js +1 -1
- package/components/Modal/style.js +1 -1
- package/components/Picker/components/List/index.js +1 -1
- package/components/Picker/components/Modal/index.js +7 -7
- package/components/Picker/index.js +19 -9
- package/components/Portal/index.js +15 -11
- package/components/ProductCharacteristics/helpers/index.js +1 -1
- package/components/ProductCharacteristics/index.js +27 -12
- package/components/RangeSlider/index.js +33 -24
- package/components/Route/RouteNotFound.js +3 -3
- package/components/Route/index.js +5 -5
- package/components/Router/index.js +18 -10
- package/components/ScannerContainer/index.js +3 -3
- package/components/Select/index.js +25 -15
- package/components/SelectBox/components/Item/index.js +5 -3
- package/components/SelectBox/index.js +17 -8
- package/components/Swiper/components/SwiperItem/spec.js +1 -1
- package/components/Swiper/index.js +3 -3
- package/components/Swiper/styles.js +4 -1
- package/components/Transition/index.js +4 -4
- package/components/Widgets/components/Widget/index.js +4 -4
- package/components/Widgets/components/WidgetGrid/index.js +5 -5
- package/components/Widgets/index.js +7 -7
- package/components/index.js +1 -2
- package/constants/Configuration.js +1 -1
- package/constants/Device.js +2 -2
- package/constants/Portals.js +2 -2
- package/helpers/config/mock.js +2 -2
- package/helpers/config/theme.js +2 -2
- package/helpers/i18n/getTranslator.js +10 -4
- package/helpers/portals/portalCollection.js +3 -3
- package/helpers/redux/mutable.js +3 -2
- package/helpers/redux/shouldFetchData.js +1 -1
- package/helpers/style/index.js +2 -2
- package/package.json +4 -4
- package/providers/loading/index.js +24 -14
- package/providers/toast/index.js +10 -8
- package/reducers/page/index.js +1 -1
- package/reducers/router/index.js +1 -1
- package/selectors/client.js +9 -7
- package/streams/app.js +8 -2
- package/streams/main.js +1 -1
- package/streams/view.js +12 -0
- package/subscriptions/error.js +4 -4
- package/subscriptions/helpers/handleLinks.js +2 -2
- package/subscriptions/menu.js +4 -2
- package/subscriptions/router.js +6 -6
- package/subscriptions/user.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
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;}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 _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 _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;}import React,{useCallback,useState,useEffect,useRef}from'react';import PropTypes from'prop-types';import DayPicker from'react-day-picker';import MomentLocaleUtils from'react-day-picker/moment';import'react-day-picker/lib/style.css';import{css}from'glamor';import classNames from'classnames';import moment from'moment';import CalendarIcon from'@shopgate/pwa-ui-shared/icons/CalendarIcon';import appConfig,{themeConfig}from'@shopgate/pwa-common/helpers/config';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import{i18n}from'@shopgate/engage/core';import SimpleInput from"./SimpleInput";var variables=themeConfig.variables;var locale=appConfig.language.substring(0,2);/**
|
|
1
|
+
var _excluded=["onFocusChange","onChange","type","value"];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;}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 _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 _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;}import React,{useCallback,useState,useEffect,useRef}from'react';import PropTypes from'prop-types';import DayPicker from'react-day-picker';import MomentLocaleUtils from'react-day-picker/moment';import'react-day-picker/lib/style.css';import{css}from'glamor';import classNames from'classnames';import moment from'moment';import CalendarIcon from'@shopgate/pwa-ui-shared/icons/CalendarIcon';import appConfig,{themeConfig}from'@shopgate/pwa-common/helpers/config';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import{i18n}from'@shopgate/engage/core';import SimpleInput from"./SimpleInput";var variables=themeConfig.variables;var locale=appConfig.language.substring(0,2);/**
|
|
2
2
|
* @param {Object|string} date The input date
|
|
3
3
|
* @returns {string}
|
|
4
4
|
*/var getDateFromISO=function getDateFromISO(date){var result=moment(date);if(!result.isValid()){return null;}return result.toDate();};/**
|
|
@@ -14,4 +14,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
14
14
|
*/var Caption=function Caption(_ref){var date=_ref.date,localeUtils=_ref.localeUtils,onChange=_ref.onChange;var months=localeUtils.getMonths(locale);var years=[];for(var i=fromMonth.getFullYear();i<=toMonth.getFullYear();i+=1){years.push(i);}var handleChange=function handleChange(e){var _e$target$form=e.target.form,year=_e$target$form.year,month=_e$target$form.month;onChange(new Date(year.value,month.value));};return React.createElement("div",{className:"DayPicker-Caption"},React.createElement("select",{name:"month",onChange:handleChange,value:date.getMonth(),className:styles.selectBox},months.map(function(month,i){return React.createElement("option",{key:month,value:i},month);})),React.createElement("select",{name:"year",onChange:handleChange,value:date.getFullYear(),className:styles.selectBox},years.map(function(year){return React.createElement("option",{key:year,value:year},year);})));};/**
|
|
15
15
|
* @param {Object} props The components props
|
|
16
16
|
* @returns {JSX}
|
|
17
|
-
*/var DateInput=function DateInput(_ref2){var onFocusChange=_ref2.onFocusChange,onChange=_ref2.onChange,type=_ref2.type,value=_ref2.value,rest=_objectWithoutProperties(_ref2,
|
|
17
|
+
*/var DateInput=function DateInput(_ref2){var onFocusChange=_ref2.onFocusChange,onChange=_ref2.onChange,type=_ref2.type,value=_ref2.value,rest=_objectWithoutProperties(_ref2,_excluded);var wrapperRef=useRef(null);var _useState=useState(getLocaleFormattedDate(value)),_useState2=_slicedToArray(_useState,2),inputValue=_useState2[0],setInputValue=_useState2[1];var _useState3=useState(getDateFromISO(value)),_useState4=_slicedToArray(_useState3,2),pickerValue=_useState4[0],setPickerValue=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isFocused=_useState6[0],setIsFocused=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),pickerVisible=_useState8[0],setPickerVisible=_useState8[1];useEffect(function(){var updated=getLocaleFormattedDate(value);if(updated){setInputValue(updated);setPickerValue(getDateFromISO(value));}},[value]);var needsPositionTop=useCallback(function(){var element=wrapperRef.current;if(!element){return false;}var _element$getBoundingC=element.getBoundingClientRect(),top=_element$getBoundingC.top,height=_element$getBoundingC.height;var distToBottom=document.body.offsetHeight-(top+height);return distToBottom<=300;},[wrapperRef]);var handleInputValueChange=useCallback(function(val){setInputValue(val);},[]);var handleFocusChange=useCallback(function(focused,e){if(!focused){setPickerValue(getDateFromISO(getISOFormattedDate(inputValue)));onChange(inputValue.length!==0?getISOFormattedDate(inputValue,false):null);}setIsFocused(focused);onFocusChange(focused,e);},[inputValue,onChange,onFocusChange]);var handlePickerChange=useCallback(function(date){setPickerVisible(false);setPickerValue(date);setInputValue(getLocaleFormattedDate(date));onChange(getISOFormattedDate(date));},[onChange]);var handleMonthChange=useCallback(function(date){setPickerValue(date);},[]);var handleIconClick=useCallback(function(){setPickerVisible(!pickerVisible);},[pickerVisible]);var handleBackdropClick=useCallback(function(){setPickerVisible(false);},[]);return React.createElement(React.Fragment,null,React.createElement("div",{ref:wrapperRef},React.createElement(SimpleInput,_extends({},rest,{attributes:{placeholder:isFocused?i18n.text('formats.date.pattern'):null},value:inputValue,type:"text",onFocusChange:handleFocusChange,onChange:handleInputValueChange})),React.createElement("div",{className:styles.iconWrapper,onClick:handleIconClick,role:"button",tabIndex:"0",onKeyDown:handleIconClick},React.createElement(CalendarIcon,null))),React.createElement("div",{className:classNames(styles.pickerWrapper,_defineProperty({},styles.hidden,!pickerVisible))},React.createElement(DayPicker,{className:classNames('DayPickerInput-Overlay',styles.picker,_defineProperty({},styles.pickerTop,needsPositionTop())),onDayClick:handlePickerChange,selectedDays:pickerValue,localeUtils:MomentLocaleUtils,locale:locale,todayButton:i18n.text('locations.your_current_timeslot.today'),onTodayButtonClick:handlePickerChange,month:pickerValue,showOutsideDays:true,captionElement:function captionElement(_ref3){var date=_ref3.date,localeUtils=_ref3.localeUtils;return React.createElement(Caption,{date:date,localeUtils:localeUtils,onChange:handleMonthChange});}})),pickerVisible&&React.createElement(Backdrop,{isVisible:true,level:11,opacity:0,onClick:handleBackdropClick}));};DateInput.defaultProps={onFocusChange:function onFocusChange(){},onChange:function onChange(){},type:null,value:null};export default DateInput;
|
|
@@ -1,26 +1,26 @@
|
|
|
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 _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 _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 _get(target,property,receiver){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get;}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(receiver);}return desc.value;};}return _get(target,property,receiver||target);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}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 from'react';import classNames from'classnames';import{logger}from'@shopgate/pwa-core';import SimpleInput from"./SimpleInput";/**
|
|
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 _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 _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 _get(target,property,receiver){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get;}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(receiver);}return desc.value;};}return _get(target,property,receiver||target);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}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 from'react';import classNames from'classnames';import{logger}from'@shopgate/pwa-core';import SimpleInput from"./SimpleInput";/**
|
|
2
2
|
* A component that takes care of rendering and validation of input fields.
|
|
3
3
|
* This component has no styling and should not be used directly.
|
|
4
4
|
* You may want to use an appropriate form field component from the template instead.
|
|
5
|
-
*/var MultiLineInput=/*#__PURE__*/function(_SimpleInput){
|
|
5
|
+
*/var MultiLineInput=/*#__PURE__*/function(_SimpleInput){/**
|
|
6
6
|
* Creates a new input component.
|
|
7
7
|
* @param {Object} props The component properties.
|
|
8
|
-
*/function MultiLineInput(props){var
|
|
9
|
-
|
|
8
|
+
*/function MultiLineInput(props){var _this2;_classCallCheck(this,MultiLineInput);_this2=_callSuper(this,MultiLineInput,[props]);/**
|
|
9
|
+
* Sets an initial height of the multiline HTMLElement.
|
|
10
|
+
*/_defineProperty(_this2,"setBaseHeight",function(){if(_this2.baseHeight!==null){return;}_this2.baseHeight=_this2.ref.clientHeight;});_this2.baseHeight=null;// First render must be empty.
|
|
11
|
+
var sanitizedValue=_this2.props.onSanitize('');_this2.state={value:sanitizedValue,isValid:_this2.props.onValidate(sanitizedValue,true),isFocused:false};return _this2;}/**
|
|
10
12
|
* Additional function to make avoid .setState use in componentDidMount
|
|
11
13
|
* usage violation.
|
|
12
|
-
*/_createClass(MultiLineInput,[{key:"doComponentDidMount",value:function doComponentDidMount(){var sanitizedValue=this.props.onSanitize(this.props.value||'');this.props.onChange(sanitizedValue);this.setState({value:sanitizedValue,isValid:this.props.onValidate(sanitizedValue,true),isFocused:false});}/**
|
|
14
|
+
*/_inherits(MultiLineInput,_SimpleInput);return _createClass(MultiLineInput,[{key:"doComponentDidMount",value:function doComponentDidMount(){var sanitizedValue=this.props.onSanitize(this.props.value||'');this.props.onChange(sanitizedValue);this.setState({value:sanitizedValue,isValid:this.props.onValidate(sanitizedValue,true),isFocused:false});}/**
|
|
13
15
|
* Set real value and trigger second render.
|
|
14
16
|
* Initially trigger onChange() to set the initial value.
|
|
15
17
|
*/},{key:"componentDidMount",value:function componentDidMount(){// No super, would have to sanitize anyway.
|
|
16
18
|
this.doComponentDidMount();}/**
|
|
17
19
|
* Adjusts the element height.
|
|
18
|
-
*/},{key:"componentDidUpdate",value:function componentDidUpdate(){if(!(this.ref instanceof HTMLElement)){logger.error('Ref is not an HTMLElement');return;}this.ref.style.height="".concat(this.baseHeight,"px");this.ref.style.height="".concat(this.ref.scrollHeight,"px");}
|
|
19
|
-
* Sets an initial height of the multiline HTMLElement.
|
|
20
|
-
*/},{key:"handleRef",/**
|
|
20
|
+
*/},{key:"componentDidUpdate",value:function componentDidUpdate(){if(!(this.ref instanceof HTMLElement)){logger.error('Ref is not an HTMLElement');return;}this.ref.style.height="".concat(this.baseHeight,"px");this.ref.style.height="".concat(this.ref.scrollHeight,"px");}},{key:"handleRef",value:/**
|
|
21
21
|
* Handles reference passing to callback and assignation.
|
|
22
22
|
* @param {HTMLElement} ref The element
|
|
23
|
-
*/
|
|
23
|
+
*/function handleRef(ref){_get(_getPrototypeOf(MultiLineInput.prototype),"handleRef",this).call(this,ref);this.setBaseHeight();}/**
|
|
24
24
|
* Renders the component.
|
|
25
25
|
* @returns {JSX}
|
|
26
|
-
*/},{key:"render",value:function render(){var
|
|
26
|
+
*/},{key:"render",value:function render(){var _this3=this;var _this$props=this.props,className=_this$props.className,password=_this$props.password,attributes=_this$props.attributes;var type=password?'password':this.props.type;var value=this.state.value;return React.createElement("textarea",_extends({id:this.props.id,name:this.props.name,ref:function ref(_ref){return _this3.handleRef(_ref);},className:classNames(className,'multiLineInput','common__multi-line-input'),type:type,value:value,onChange:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,disabled:this.props.disabled},attributes));}}]);}(SimpleInput);export default MultiLineInput;
|
|
@@ -1,19 +1,28 @@
|
|
|
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 _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 _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
|
|
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 _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 _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 classNames from'classnames';/**
|
|
2
2
|
* A component that takes care of rendering and validation of input fields.
|
|
3
3
|
* This component has no styling and should not be used directly.
|
|
4
4
|
* You may want to use an appropriate form field component from the template instead.
|
|
5
|
-
*/var SimpleInput=/*#__PURE__*/function(_Component){
|
|
5
|
+
*/var SimpleInput=/*#__PURE__*/function(_Component){/**
|
|
6
6
|
* Creates a new input component.
|
|
7
7
|
* @param {Object} props The component properties.
|
|
8
|
-
*/function SimpleInput(props){var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
8
|
+
*/function SimpleInput(props){var _this2;_classCallCheck(this,SimpleInput);_this2=_callSuper(this,SimpleInput,[props]);/**
|
|
9
|
+
* Internal focus event handler.
|
|
10
|
+
* @param {Object} e The event object.
|
|
11
|
+
*/_defineProperty(_this2,"handleFocus",function(e){_this2.setState({isFocused:true});_this2.props.onFocusChange(true,e);});/**
|
|
12
|
+
* Internal blur event handler.
|
|
13
|
+
* @param {Object} e The event object.
|
|
14
|
+
*/_defineProperty(_this2,"handleBlur",function(e){var newState={isFocused:false};if(_this2.props.validateOnBlur){// Validate the value.
|
|
15
|
+
newState.isValid=_this2.props.onValidate(_this2.value,false);}_this2.setState(newState);_this2.props.onFocusChange(false,e);});/**
|
|
16
|
+
* Internal change event handler.
|
|
17
|
+
* @param {Object} event The event object.
|
|
18
|
+
*/_defineProperty(_this2,"handleChange",function(event){var _event$target,_event$target$validit;var value=_this2.state.value;var type=_this2.props.type;// Special handling to prevent invalid characters within number inputs on Firefox / Safari
|
|
19
|
+
if(type==='number'&&(event===null||event===void 0?void 0:(_event$target=event.target)===null||_event$target===void 0?void 0:(_event$target$validit=_event$target.validity)===null||_event$target$validit===void 0?void 0:_event$target$validit.badInput)){event.preventDefault();event.stopPropagation();_this2.ref.value=value;return;}// Sanitize the input value.
|
|
20
|
+
var sanitizedValue=_this2.props.onSanitize(event.target.value||'');// Update the state.
|
|
21
|
+
_this2.updateValue(sanitizedValue,!_this2.props.isControlled);// Emit an event.
|
|
22
|
+
_this2.props.onChange(sanitizedValue,event);});_this2.ref=null;// Initially sanitize the value.
|
|
23
|
+
var _sanitizedValue=_this2.props.onSanitize(_this2.props.value||'');_this2.state={value:_sanitizedValue,isValid:_this2.props.onValidate(_sanitizedValue,true),isFocused:false};return _this2;}/**
|
|
15
24
|
* Initially trigger onChange() to set the initial value.
|
|
16
|
-
*/_createClass(SimpleInput,[{key:"componentDidMount",value:function componentDidMount(){var sanitizedValue=this.props.onSanitize(this.props.value||'');this.props.onChange(sanitizedValue);}/**
|
|
25
|
+
*/_inherits(SimpleInput,_Component);return _createClass(SimpleInput,[{key:"componentDidMount",value:function componentDidMount(){var sanitizedValue=this.props.onSanitize(this.props.value||'');this.props.onChange(sanitizedValue);}/**
|
|
17
26
|
* Updates the value of the input field if the props has been modified.
|
|
18
27
|
* @param {Object} nextProps The new properties.
|
|
19
28
|
*/},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){/**
|
|
@@ -21,10 +30,14 @@ var _sanitizedValue=_this.props.onSanitize(_this.props.value||'');_this.state={v
|
|
|
21
30
|
* otherwise use the current input state.
|
|
22
31
|
*/var sanitizedValue=this.props.onSanitize(nextProps.value||'');if(sanitizedValue!==this.state.value){this.updateValue(sanitizedValue,true);}}/**
|
|
23
32
|
* @returns {boolean} Whether the current value of the input field is valid.
|
|
24
|
-
*/},{key:"
|
|
33
|
+
*/},{key:"isValid",get:function get(){return this.state.isValid;}/**
|
|
34
|
+
* @return {boolean} Whether the input field is focused.
|
|
35
|
+
*/},{key:"isFocused",get:function get(){return this.state.isFocused;}/**
|
|
36
|
+
* @returns {string} The current value of the input field.
|
|
37
|
+
*/},{key:"value",get:function get(){return this.state.value;}},{key:"handleRef",value:/**
|
|
25
38
|
* Handles reference passing to callback and assignation.
|
|
26
39
|
* @param {HTMLElement} ref The element
|
|
27
|
-
*/
|
|
40
|
+
*/function handleRef(ref){this.ref=ref;this.props.setRef(ref);}/**
|
|
28
41
|
* Updates and validates the internal state value of the input field.
|
|
29
42
|
* @param {string} newValue The new value.
|
|
30
43
|
* @param {boolean} setOwnState Specifies whether or not to update the internal state.
|
|
@@ -33,13 +46,6 @@ newState.isValid=this.props.onValidate(newValue,false);}// Uncontrolled when set
|
|
|
33
46
|
if(setOwnState){this.setState(newState);}}/**
|
|
34
47
|
* Renders the component.
|
|
35
48
|
* @returns {JSX}
|
|
36
|
-
*/},{key:"render",value:function render(){var
|
|
49
|
+
*/},{key:"render",value:function render(){var _this3=this;var _this$props=this.props,attributes=_this$props.attributes,className=_this$props.className,password=_this$props.password,onKeyPress=_this$props.onKeyPress,maxlength=_this$props.maxlength;var type=password?'password':this.props.type;var value=this.state.value;var autoComplete=this.props.autoComplete?'on':'off';var autoCorrect=this.props.autoCorrect?'on':'off';var InputComponent=this.props.inputComponent;return React.createElement(InputComponent,_extends({id:this.props.id,name:this.props.name,ref:function ref(_ref){return _this3.handleRef(_ref);},className:classNames(className,'simpleInput','common__simple-input'),type:type,inputMode:type==='number'?'decimal':null,pattern:type==='number'?'[0-9]*':null,min:type==='number'?0:null,step:type==='number'?'any':null,value:value,onKeyPress:onKeyPress// Use onInput for number fields to enable handling for invalid values
|
|
37
50
|
// (onChange might to be triggered when the input is invalid)
|
|
38
|
-
,onInput:type==='number'?this.handleChange:null,onChange:type!=='number'?this.handleChange:function(){},onFocus:this.handleFocus,onBlur:this.handleBlur,disabled:this.props.disabled,autoCorrect:autoCorrect,autoComplete:autoComplete},attributes));}},
|
|
39
|
-
* @return {boolean} Whether the input field is focused.
|
|
40
|
-
*/},{key:"isFocused",get:function get(){return this.state.isFocused;}/**
|
|
41
|
-
* @returns {string} The current value of the input field.
|
|
42
|
-
*/},{key:"value",get:function get(){return this.state.value;}/**
|
|
43
|
-
* Internal focus event handler.
|
|
44
|
-
* @param {Object} e The event object.
|
|
45
|
-
*/}]);return SimpleInput;}(Component);_defineProperty(SimpleInput,"defaultProps",{attributes:null,autoComplete:false,autoCorrect:false,className:'',disabled:false,id:null,isControlled:false,name:null,onChange:function onChange(){},onFocusChange:function onFocusChange(){},onKeyPress:function onKeyPress(){},onSanitize:function onSanitize(value){return value;},onValidate:function onValidate(){return true;},password:false,setRef:function setRef(){},type:'text',validateOnBlur:true,value:'',inputComponent:'input'});export default SimpleInput;
|
|
51
|
+
,onInput:type==='number'?this.handleChange:null,onChange:type!=='number'?this.handleChange:function(){},onFocus:this.handleFocus,onBlur:this.handleBlur,disabled:this.props.disabled,autoCorrect:autoCorrect,autoComplete:autoComplete,maxLength:maxlength},attributes));}}]);}(Component);_defineProperty(SimpleInput,"defaultProps",{attributes:null,autoComplete:false,autoCorrect:false,className:'',disabled:false,id:null,isControlled:false,maxlength:'',name:null,onChange:function onChange(){},onFocusChange:function onFocusChange(){},onKeyPress:function onKeyPress(){},onSanitize:function onSanitize(value){return value;},onValidate:function onValidate(){return true;},password:false,setRef:function setRef(){},type:'text',validateOnBlur:true,value:'',inputComponent:'input'});export default SimpleInput;
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
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{PureComponent}from'react';import PropTypes from'prop-types';import Event from'@shopgate/pwa-core/classes/Event';import{EVENT_KEYBOARD_WILL_CHANGE}from'@shopgate/pwa-core/constants/AppEvents';/**
|
|
2
2
|
* Keyboard state consumer.
|
|
3
|
-
*/var KeyboardConsumer=/*#__PURE__*/function(_PureComponent){
|
|
3
|
+
*/var KeyboardConsumer=/*#__PURE__*/function(_PureComponent){function KeyboardConsumer(){var _this2;_classCallCheck(this,KeyboardConsumer);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,KeyboardConsumer,[].concat(args));_defineProperty(_this2,"state",{open:false,overlap:0,duration:0});/**
|
|
4
|
+
* Stores current keyboard state.
|
|
5
|
+
*/_defineProperty(_this2,"handleKeyboardChange",function(_ref){var open=_ref.open,overlap=_ref.overlap,duration=_ref.duration;_this2.setState({open:open,overlap:overlap,duration:duration});});return _this2;}_inherits(KeyboardConsumer,_PureComponent);return _createClass(KeyboardConsumer,[{key:"componentDidMount",value:/**
|
|
4
6
|
* Listen to keyboard changes as soon as the component mounts.
|
|
5
|
-
*/
|
|
7
|
+
*/function componentDidMount(){Event.addCallback(EVENT_KEYBOARD_WILL_CHANGE,this.handleKeyboardChange);}/**
|
|
6
8
|
* Remove listener when component will unmount.
|
|
7
|
-
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){Event.removeCallback(EVENT_KEYBOARD_WILL_CHANGE,this.handleKeyboardChange);}
|
|
8
|
-
* Stores current keyboard state.
|
|
9
|
-
*/},{key:"render",/**
|
|
9
|
+
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){Event.removeCallback(EVENT_KEYBOARD_WILL_CHANGE,this.handleKeyboardChange);}},{key:"render",value:/**
|
|
10
10
|
* @returns {JSX}
|
|
11
|
-
*/
|
|
11
|
+
*/function render(){return this.props.children(this.state);}}]);}(PureComponent);export default KeyboardConsumer;
|
package/components/Link/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
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 _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 _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
|
|
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 _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 _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{hasWebBridge}from'@shopgate/engage/core';import connect from"./connector";import styles from"./style";/**
|
|
2
2
|
* Link component.
|
|
3
3
|
* @param {Object} props Props for the component.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var Link=/*#__PURE__*/function(_Component){
|
|
6
|
-
|
|
5
|
+
*/var Link=/*#__PURE__*/function(_Component){function Link(){var _this2;_classCallCheck(this,Link);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,Link,[].concat(args));/**
|
|
6
|
+
* Opens the link.
|
|
7
|
+
* @param {Event} e An event object.
|
|
8
|
+
*/_defineProperty(_this2,"handleOpenLink",function(e){e.preventDefault();if(_this2.props.disabled){return;}var params={pathname:_this2.props.href,state:_extends({},_this2.props.state||{},{},_this2.props.target?{target:_this2.props.target}:{})};// setTimeout prevents double click while VoiceOver is active
|
|
9
|
+
setTimeout(function(){if(_this2.props.replace){_this2.props.historyReplace(params);}else{_this2.props.historyPush(params);}},0);});return _this2;}_inherits(Link,_Component);return _createClass(Link,[{key:"render",value:/**
|
|
7
10
|
* Renders the component.
|
|
8
11
|
* @returns {JSX}
|
|
9
|
-
*/
|
|
12
|
+
*/function render(){var _this$props=this.props,tag=_this$props.tag,className=_this$props.className,href=_this$props.href,children=_this$props.children,role=_this$props.role,ariaLabel=_this$props['aria-label'],ariaHidden=_this$props['aria-hidden'],tabIndex=_this$props.tabIndex;var Tag=tag;if(!hasWebBridge()&&tag==='a'){/**
|
|
10
13
|
* Don't use link tags on apps. Sometimes links are really opened since the preventDefault
|
|
11
14
|
* doesn't work as expected which results in white pages.
|
|
12
|
-
*/Tag='span';}return React.createElement(Tag,{className:"".concat(styles," ").concat(className),onClick:this.handleOpenLink,role:role,"data-test-id":"link: ".concat(href),"aria-label":ariaLabel,tabIndex:tabIndex,"aria-hidden":ariaHidden,href:href&&Tag==='a'?href:null},children);}}]);
|
|
15
|
+
*/Tag='span';}return React.createElement(Tag,{className:"".concat(styles," ").concat(className," common__link"),onClick:this.handleOpenLink,role:role,"data-test-id":"link: ".concat(href),"aria-label":ariaLabel,tabIndex:tabIndex,"aria-hidden":ariaHidden,href:href&&Tag==='a'?href:null},children);}}]);}(Component);_defineProperty(Link,"defaultProps",{'aria-hidden':null,'aria-label':null,className:'',disabled:false,replace:false,role:'link',tag:'div',tabIndex:null,target:null,state:{}});export var Disconnected=Link;export default connect(Link);
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import styles from"./
|
|
|
2
2
|
* The ListItem component.
|
|
3
3
|
* @returns {JSX}
|
|
4
4
|
*/var ListItem=function ListItem(_ref){var children=_ref.children,className=_ref.className,isSelected=_ref.isSelected,role=_ref.role;if(!React.Children.count(children)){return null;}var classes=styles.item;if(className){classes+=" ".concat(className);}// Add selected or unselected styling.
|
|
5
|
-
classes+=" ".concat(isSelected?styles.selected:styles.unselected);return React.createElement("li",{className:classes,"data-test-id":"listItem",role:role},children);};ListItem.defaultProps={className:null,children:null,isSelected:false,role:null};export default ListItem;
|
|
5
|
+
classes+=" common__list__list-item ".concat(isSelected?styles.selected:styles.unselected);return React.createElement("li",{className:classes,"data-test-id":"listItem",role:role},children);};ListItem.defaultProps={className:null,children:null,isSelected:false,role:null};export default ListItem;
|
package/components/List/index.js
CHANGED
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import ListItem from"
|
|
|
2
2
|
* The List component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var List=function List(_ref){var children=_ref.children,className=_ref.className,role=_ref.role;return React.createElement("ul",{className:className,role:role},children);};List.Item=ListItem;List.defaultProps={className:'',role:null};export default List;
|
|
5
|
+
*/var List=function List(_ref){var children=_ref.children,className=_ref.className,role=_ref.role;return React.createElement("ul",{className:"".concat(className," common_list"),role:role},children);};List.Item=ListItem;List.defaultProps={className:'',role:null};export default List;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from'react';import PropTypes from'prop-types';import Portal from'react-portal';import classNames from'classnames';import styles from"./style";/**
|
|
2
2
|
* The Modal component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
|
-
* @returns {JSX}
|
|
4
|
+
* @returns {JSX.Element}
|
|
5
5
|
*/var Modal=function Modal(_ref){var children=_ref.children,classes=_ref.classes;return React.createElement(Portal,{isOpened:true},React.createElement("div",{className:classNames(styles.container,classes===null||classes===void 0?void 0:classes.container,'common__modal')},React.createElement("div",{className:classNames(styles.layout,classes===null||classes===void 0?void 0:classes.layout)},React.createElement("div",{className:classNames(styles.content,classes===null||classes===void 0?void 0:classes.content)},children))));};Modal.defaultProps={children:null,classes:{container:'',layout:'',content:''}};export default Modal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from'glamor';var container=css({position:'fixed',top:0,bottom:0,left:0,right:0,overflow:'hidden',zIndex:2000}).toString();var layout=css({display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',height:'100%'}).toString();var content=css({position:'relative',maxWidth:'100vw',maxHeight:'100vh'}).toString();export default{container:container,layout:layout,content:content};
|
|
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{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';var container=css({position:'fixed',top:0,bottom:0,left:0,right:0,overflow:'hidden',zIndex:2000}).toString();var layout=css({display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',height:'100%'}).toString();var content=css(_defineProperty({position:'relative',maxWidth:'100vw',maxHeight:'100vh',paddingTop:'var(--safe-area-inset-top)',paddingBottom:'var(--safe-area-inset-bottom)',overflowY:'scroll'},responsiveMediaQuery('>xs',{webOnly:true}),{overflowY:'initial'})).toString();export default{container:container,layout:layout,content:content};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
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 classNames from'classnames';import styles from"./style";/**
|
|
2
2
|
* The default button for the Picker component.
|
|
3
3
|
* @returns {JSX} The button component.
|
|
4
|
-
*/var PickerList=function PickerList(_ref){var items=_ref.items,onClose=_ref.onClose,onSelect=_ref.onSelect,selectedIndex=_ref.selectedIndex;return React.createElement("ul",
|
|
4
|
+
*/var PickerList=function PickerList(_ref){var items=_ref.items,onClose=_ref.onClose,onSelect=_ref.onSelect,selectedIndex=_ref.selectedIndex;return React.createElement("ul",{className:"common__picker__list"},items.map(function(item,currentIndex){return React.createElement("li",{key:item.value,className:classNames(_defineProperty({},styles.active,currentIndex===selectedIndex))},React.createElement("button",{className:styles.button,disabled:item.disabled,onClick:function onClick(){onSelect(item.value);onClose();},type:"button"},item.label));}));};PickerList.defaultProps={onClose:function onClose(){},selectedIndex:null};export default PickerList;
|
|
@@ -1,14 +1,14 @@
|
|
|
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
|
|
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 classNames from'classnames';import styles from"./style";/**
|
|
2
2
|
* The picker modal.
|
|
3
|
-
*/var PickerModal=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var PickerModal=/*#__PURE__*/function(_Component){/**
|
|
4
4
|
* The constructor.
|
|
5
5
|
* @param {Object} props The props.
|
|
6
|
-
*/function PickerModal(props){var
|
|
6
|
+
*/function PickerModal(props){var _this2;_classCallCheck(this,PickerModal);_this2=_callSuper(this,PickerModal,[props]);/**
|
|
7
|
+
* Closes the modal after the closing animations have finished.
|
|
8
|
+
*/_defineProperty(_this2,"closeModal",function(){_this2.setState({active:false});clearTimeout(_this2.timeout);_this2.timeout=setTimeout(_this2.props.onClose,styles.duration);});_this2.timeout=null;_this2.state={active:true};return _this2;}/**
|
|
7
9
|
* Update state when isOpen changes.
|
|
8
10
|
* @param {Object} nextProps The next component props.
|
|
9
|
-
*/_createClass(PickerModal,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){this.setState({active:nextProps.isOpen});}}
|
|
10
|
-
* Closes the modal after the closing animations have finished.
|
|
11
|
-
*/},{key:"render",/**
|
|
11
|
+
*/_inherits(PickerModal,_Component);return _createClass(PickerModal,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){this.setState({active:nextProps.isOpen});}}},{key:"render",value:/**
|
|
12
12
|
* Render all the things!
|
|
13
13
|
* @returns {JSX} The picker modal with the picker list inside.
|
|
14
|
-
*/
|
|
14
|
+
*/function render(){var backgroundClassName=classNames(styles.background.base,_defineProperty({},styles.background.inactive,!this.state.active));var containerClassName=classNames(styles.container.base,_defineProperty({},styles.container.inactive,!this.state.active));return this.props.isOpen?React.createElement("div",{className:"".concat(styles.wrapper," common__picker__modal")},React.createElement("div",{"aria-hidden":true,className:backgroundClassName,onClick:this.closeModal}),React.createElement("div",{className:containerClassName},React.cloneElement(this.props.children,{onClose:this.closeModal}))):null;}}]);}(Component);export default PickerModal;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
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
|
|
1
|
+
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;}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 _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);}import React,{Component}from'react';import PropTypes from'prop-types';import Portal from'react-portal';import{withForwardedRef}from'@shopgate/engage/core';import PickerModal from"./components/Modal";import PickerButton from"./components/Button";import PickerList from"./components/List";/**
|
|
2
2
|
* Converts an item of any type (e.g. string or number)
|
|
3
3
|
* to an object representation containing value and label properties.
|
|
4
4
|
* @param {*} item - An item of any type.
|
|
5
5
|
* @returns {Object} An object representation of the item.
|
|
6
|
+
* @deprecated Use Picker from engage instead
|
|
6
7
|
*/var normalizeItem=function normalizeItem(item){if(item!==null&&typeof item!=='undefined'){var itemDefaults={value:item.value||item,label:item.label||item.value||item,disabled:item.disabled||false};if(_typeof(item)==='object'){return _extends({},itemDefaults,{},item);}return itemDefaults;}return null;};/**
|
|
7
8
|
* Finds an item index in a list of items by value.
|
|
8
9
|
* @param {Array} items - The list of items.
|
|
@@ -12,19 +13,28 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
12
13
|
* The picker component (acts like a selectbox).
|
|
13
14
|
* @deprecated Will be remove in Engage v7.0.0.
|
|
14
15
|
* Please use `import { Picker } from '@shopgate/engage/components'` instead.
|
|
15
|
-
*/var Picker=/*#__PURE__*/function(_Component){
|
|
16
|
+
*/var Picker=/*#__PURE__*/function(_Component){/**
|
|
16
17
|
* The constructor.
|
|
17
18
|
* @param {Object} props - The component props.
|
|
18
|
-
*/function Picker(props){var
|
|
19
|
+
*/function Picker(props){var _this2;_classCallCheck(this,Picker);_this2=_callSuper(this,Picker,[props]);/**
|
|
20
|
+
* Triggers the onChange callback if the selected value has changed.
|
|
21
|
+
* @param {Object} nextValue - The value the user picked.
|
|
22
|
+
*/_defineProperty(_this2,"triggerChangeCallback",function(nextValue){var nextSelectedIndex=findItemIndexByValue(_this2.props.items,nextValue);if(nextSelectedIndex>-1&&_this2.state.selectedIndex!==nextSelectedIndex){_this2.props.onChange(nextValue);}_this2.props.onSelect(nextValue);});/**
|
|
23
|
+
* Triggers the onChange callback if the selected value has changed.
|
|
24
|
+
* @param {Object} nextOpenState - The value the user picked.
|
|
25
|
+
*/_defineProperty(_this2,"triggerCloseCallback",function(nextOpenState){if(_this2.state.isOpen&&!nextOpenState){_this2.props.onClose();}});/**
|
|
26
|
+
* Gets called when a new item is selected
|
|
27
|
+
* @param {string} value - The selected value.
|
|
28
|
+
*/_defineProperty(_this2,"handleItemSelect",function(value){_this2.triggerChangeCallback(value);_this2.setState({selectedIndex:findItemIndexByValue(_this2.props.items,value)});});/**
|
|
29
|
+
* Sets or toggles the open state of the component.
|
|
30
|
+
* @param {boolean} [open] New open state.
|
|
31
|
+
*/_defineProperty(_this2,"toggleOpenState",function(open){_this2.setState(function(_ref){var isOpen=_ref.isOpen;var nextIsOpen=typeof open==='boolean'?open:!isOpen;_this2.triggerCloseCallback(nextIsOpen);return{isOpen:nextIsOpen};});});_this2.state={selectedIndex:findItemIndexByValue(props.items,props.value),isOpen:props.isOpen};return _this2;}/**
|
|
19
32
|
* Updates the selected item when the value prop changes.
|
|
20
33
|
* @param {Object} nextProps - The next props.
|
|
21
|
-
*/_createClass(Picker,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Only update if a value is present and also changed.
|
|
34
|
+
*/_inherits(Picker,_Component);return _createClass(Picker,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Only update if a value is present and also changed.
|
|
22
35
|
if(!this.selectedItem||nextProps.value!==this.selectedItem.value){this.setState({selectedIndex:findItemIndexByValue(nextProps.items,nextProps.value)});}if(this.props.isOpen!==nextProps.isOpen&&nextProps.isOpen!==this.state.isOpen){this.setState({isOpen:nextProps.isOpen});}}/**
|
|
23
36
|
* Getter for the selected item.
|
|
24
|
-
*/},{key:"render"
|
|
37
|
+
*/},{key:"selectedItem",get:function get(){return normalizeItem(this.props.items[this.state.selectedIndex]);}},{key:"render",value:/**
|
|
25
38
|
* Renders the component.
|
|
26
39
|
* @returns {JSX}
|
|
27
|
-
*/
|
|
28
|
-
* Triggers the onChange callback if the selected value has changed.
|
|
29
|
-
* @param {Object} nextValue - The value the user picked.
|
|
30
|
-
*/}]);return Picker;}(Component);_defineProperty(Picker,"defaultProps",{buttonComponent:PickerButton,buttonProps:{},duration:300,disabled:false,forwardedRef:null,label:'',listComponent:PickerList,modalComponent:PickerModal,className:'',isOpen:false,items:[],onChange:function onChange(){},onClose:function onClose(){},onSelect:function onSelect(){},placeholder:'Pick ...',value:null});export default withForwardedRef(Picker);
|
|
40
|
+
*/function render(){var _this3=this;var hasSelection=!!this.selectedItem;var buttonValue=hasSelection?this.selectedItem.label:'';var buttonLabel=hasSelection?this.props.label:this.props.placeholder;var buttonProps=_extends({},this.props.buttonProps,{label:buttonLabel,value:buttonValue,disabled:this.props.disabled,openList:this.props.disabled?null:function(){_this3.toggleOpenState(true);}});var modalProps={isOpen:this.state.isOpen,duration:this.props.duration,onClose:function onClose(){return _this3.toggleOpenState(false);}};var listProps={items:this.props.items.map(normalizeItem),selectedIndex:this.state.selectedIndex,onSelect:this.handleItemSelect};return React.createElement("div",{role:"button",className:"".concat(this.props.className," common__picker"),ref:this.props.forwardedRef,tabIndex:0,"aria-haspopup":true},React.createElement(this.props.buttonComponent,buttonProps),React.createElement(Portal,{onClose:function onClose(){return _this3.toggleOpenState(false);},isOpened:true},React.createElement(this.props.modalComponent,modalProps,React.createElement(this.props.listComponent,listProps))));}}]);}(Component);_defineProperty(Picker,"defaultProps",{buttonComponent:PickerButton,buttonProps:{},duration:300,disabled:false,forwardedRef:null,label:'',listComponent:PickerList,modalComponent:PickerModal,className:'',isOpen:false,items:[],onChange:function onChange(){},onClose:function onClose(){},onSelect:function onSelect(){},placeholder:'Pick ...',value:null});export default withForwardedRef(Picker);
|
|
@@ -1,23 +1,27 @@
|
|
|
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 _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 _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 _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
|
|
1
|
+
var _excluded=["props"];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 _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 _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,Suspense}from'react';import PropTypes from'prop-types';import{logger}from'@shopgate/pwa-core/helpers';import Loading from"../Loading";import portalCollection from"../../helpers/portals/portalCollection";import{componentsConfig}from"../../helpers/config";/**
|
|
2
2
|
* The Portal component.
|
|
3
|
-
*/var Portal=/*#__PURE__*/function(_PureComponent){
|
|
3
|
+
*/var Portal=/*#__PURE__*/function(_PureComponent){/**
|
|
4
4
|
* Constructor.
|
|
5
5
|
* @param {Object} props The component props.
|
|
6
|
-
*/function Portal(_props){var
|
|
6
|
+
*/function Portal(_props){var _this2;_classCallCheck(this,Portal);_this2=_callSuper(this,Portal,[_props]);/**
|
|
7
|
+
* Returns the portal components.
|
|
8
|
+
* @param {Object} props - The props to pass to the component.
|
|
9
|
+
* @return {Array}
|
|
10
|
+
*/_defineProperty(_this2,"getRenderedComponents",function(props){var propsFromProps=props.props,reducedProps=_objectWithoutProperties(props,_excluded);var componentProps=_extends({},propsFromProps,{},reducedProps);return _this2.components.map(function(_ref){var PortalComponent=_ref.PortalComponent,key=_ref.key;return React.createElement(Suspense,{fallback:React.createElement(Loading,null),key:key},React.createElement(PortalComponent,componentProps));});});/**
|
|
11
|
+
* Returns the portal components.
|
|
12
|
+
* @param {string} name Name of the portal position
|
|
13
|
+
* @return {Array}
|
|
14
|
+
*/_defineProperty(_this2,"getPortalComponents",function(name){var components=[];var portals=portalCollection.getPortals();if(!portals){return components;}var config=portalCollection.getConfig();if(!config){config=componentsConfig.portals;}// Loop over the portal keys.
|
|
7
15
|
Object.keys(config).forEach(function(key,index){var sourceTarget=config[key].target;var portalTarget=Array.isArray(sourceTarget)?sourceTarget:[sourceTarget];if(portalTarget.length===0){return;}portalTarget.forEach(function(target){// Stop if there is no key that matches the given name (prop).
|
|
8
16
|
if(target!==name){return;}var PortalComponent=portals[key];// Check that the component is valid.
|
|
9
|
-
if(PortalComponent){var componentKey="".concat(key,"-").concat(index);components.push({key:componentKey,PortalComponent:PortalComponent});}});});return components;});
|
|
17
|
+
if(PortalComponent){var componentKey="".concat(key,"-").concat(index);components.push({key:componentKey,PortalComponent:PortalComponent});}});});return components;});_this2.state={hasError:false};_this2.components=_this2.getPortalComponents(_props.name);return _this2;}/**
|
|
10
18
|
* Catches errors.
|
|
11
19
|
* @param {Error} error The caught error.
|
|
12
20
|
* @param {Object} info The stacktrace info.
|
|
13
|
-
*/_createClass(Portal,[{key:"componentDidCatch",value:function componentDidCatch(error,info){this.setState({hasError:true});logger.error(error,info);}
|
|
14
|
-
* Returns the portal components.
|
|
15
|
-
* @param {Object} props - The props to pass to the component.
|
|
16
|
-
* @return {Array}
|
|
17
|
-
*/},{key:"render",/**
|
|
21
|
+
*/_inherits(Portal,_PureComponent);return _createClass(Portal,[{key:"componentDidCatch",value:function componentDidCatch(error,info){this.setState({hasError:true});logger.error(error,info);}},{key:"render",value:/**
|
|
18
22
|
* Renders the component.
|
|
19
23
|
* @return {JSX}
|
|
20
|
-
*/
|
|
24
|
+
*/function render(){var children=this.props.children;var hasError=this.state.hasError;var renderedComponents=this.getRenderedComponents(this.props);var hasComponents=renderedComponents.length>0;/**
|
|
21
25
|
* Render nothing if there are no children, matching components
|
|
22
26
|
* via name or an error occurred.
|
|
23
27
|
*/if(hasError||!(hasComponents||children)){return null;}/**
|
|
@@ -26,4 +30,4 @@ if(PortalComponent){var componentKey="".concat(key,"-").concat(index);components
|
|
|
26
30
|
*/if(hasComponents){/**
|
|
27
31
|
* If there is a child component then we treat the match as an override
|
|
28
32
|
* and we render the last match only.
|
|
29
|
-
*/if(children){return renderedComponents[renderedComponents.length-1];}return renderedComponents;}return children;}}]);
|
|
33
|
+
*/if(children){return renderedComponents[renderedComponents.length-1];}return renderedComponents;}return children;}}]);}(PureComponent);_defineProperty(Portal,"defaultProps",{children:null,props:null});export default Portal;
|
|
@@ -1,4 +1,4 @@
|
|
|
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;}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 isMatch from'lodash/isMatch';import appConfig from'@shopgate/pwa-common/helpers/config';var variantSelectionMode=appConfig.variantSelectionMode,_appConfig$product=appConfig.product
|
|
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;}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 isMatch from'lodash/isMatch';import appConfig from'@shopgate/pwa-common/helpers/config';var variantSelectionMode=appConfig.variantSelectionMode,_appConfig$product=appConfig.product,_appConfig$product2=_appConfig$product===void 0?{}:_appConfig$product,variantPreselect=_appConfig$product2.variantPreselect;var preselectVariant=variantPreselect||parseInt(variantSelectionMode,10)===1;/**
|
|
2
2
|
* Returns the index of a particular characteristic from a set of characteristics.
|
|
3
3
|
* @param {Array} characteristics The characteristics of a product.
|
|
4
4
|
* @param {number} characteristicId The id of the characteristic to find.
|