@shopgate/engage 7.6.1-beta.2 → 7.6.1-beta.3

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.
@@ -1,8 +1,8 @@
1
- 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,{useRef,useState,useCallback,useLayoutEffect,useEffect,forwardRef}from'react';import PropTypes from'prop-types';import MobileDetect from'mobile-detect';import{parseFloatString,formatFloat}from"./helper";var md=new MobileDetect(navigator.userAgent);/**
1
+ 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,{useRef,useState,useCallback,useLayoutEffect,useEffect,forwardRef}from'react';import PropTypes from'prop-types';import{isIOs}from'@shopgate/pwa-core';import{parseFloatString,formatFloat}from"./helper";/**
2
2
  * A Quantity Input with unit support.
3
3
  * @returns {JSX}
4
4
  */var QuantityInput=forwardRef(function(_ref,outerInputRef){var className=_ref.className,onChange=_ref.onChange,customOnFocus=_ref.onFocus,customOnBlur=_ref.onBlur,value=_ref.value,maxDecimals=_ref.maxDecimals,unit=_ref.unit,minValue=_ref.minValue,maxValue=_ref.maxValue,inputProps=_objectWithoutProperties(_ref,["className","onChange","onFocus","onBlur","value","maxDecimals","unit","minValue","maxValue"]);var inputRef=outerInputRef||useRef();var _useState=useState(formatFloat(value,maxDecimals)),_useState2=_slicedToArray(_useState,2),inputValue=_useState2[0],setInputValue=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isFocused=_useState4[0],setIsFocused=_useState4[1];var onFocus=useCallback(function(event){customOnFocus(event);setIsFocused(true);},[customOnFocus]);var onBlur=useCallback(function(event){var newValue=parseFloatString(inputValue,maxDecimals);setIsFocused(false);// If invalid switch to old value.
5
5
  if(Number.isNaN(parseFloat(inputValue))){setInputValue(formatFloat(value,maxDecimals));return;}onChange(newValue);customOnBlur(event,newValue);},[customOnBlur,inputValue,maxDecimals,onChange,value]);var handleChange=useCallback(function(event){var newValue=event.target.value;if(newValue!==''){if(minValue&&newValue<minValue){newValue="".concat(minValue);}if(maxValue&&newValue>maxValue){newValue="".concat(maxValue);}}setInputValue(newValue);},[maxValue,minValue]);// Select the current input value after focus.
6
- useLayoutEffect(function(){if(isFocused&&md.os()!=='iOS'){inputRef.current.select();}},[inputRef,isFocused]);// Sync actual float value with displayed content.
6
+ useLayoutEffect(function(){if(isFocused&&isIOs){inputRef.current.select();}},[inputRef,isFocused]);// Sync actual float value with displayed content.
7
7
  useEffect(function(){setInputValue(formatFloat(value,maxDecimals));},[maxDecimals,value]);// Stop the context menu from opening.
8
8
  useLayoutEffect(function(){inputRef.current.addEventListener('contextmenu',function(event){event.preventDefault();event.stopPropagation();return false;});},[inputRef]);var displayedValue=!isFocused&&unit?"".concat(inputValue," ").concat(unit):inputValue;return React.createElement("input",_extends({ref:inputRef},inputProps,{inputMode:"decimal"/* Pattern signals some browsers to use specialized keyboard (if inputmode not supported */,pattern:"[0-9.,]*",onFocus:onFocus,onBlur:onBlur,className:className,value:displayedValue,onChange:handleChange}));});QuantityInput.defaultProps={className:'',maxDecimals:2,unit:null,minValue:null,maxValue:null,onFocus:function onFocus(){},onChange:function onChange(){},onBlur:function onBlur(){}};export default QuantityInput;
@@ -1,8 +1,8 @@
1
- import{isAndroidOs}from'@shopgate/pwa-core';import{getProductImageSettings}from"../../product/helpers";/**
1
+ import{getProductImageSettings}from"../../product/helpers";import{getImageFormat}from"./getImageFormat";/**
2
2
  * Returns the actual url to the image, by adding url parameters with the dimensions for img-cdn
3
3
  * @param {string} src Source to the image.
4
4
  * @param {Object} dimension Dimension of the requested image.
5
5
  * @param {number} dimension.width Width in pixels.
6
6
  * @param {number} dimension.height Height in pixels.
7
7
  * @returns {string}
8
- */export var getFullImageSource=function getFullImageSource(src,_ref){var width=_ref.width,height=_ref.height;if(src&&src.includes('images.shopgate.services/v2/images')){var _getProductImageSetti=getProductImageSettings(),fillColor=_getProductImageSetti.fillColor,quality=_getProductImageSetti.quality;var format=isAndroidOs?'webp':'jpeg';return"".concat(src,"&format=").concat(format,"&width=").concat(width,"&height=").concat(height,"&quality=").concat(quality,"&fill=").concat(fillColor.replace('#',''));}if(src&&src.startsWith('https://img-cdn.shopgate.com')&&!src.includes('?')){return"".concat(src,"?w=").concat(width,"&h=").concat(height,"&q=70&zc=resize&fillc=FFFFFF");}return src;};
8
+ */export var getFullImageSource=function getFullImageSource(src,_ref){var width=_ref.width,height=_ref.height;if(src&&src.includes('images.shopgate.services/v2/images')){var _getProductImageSetti=getProductImageSettings(),fillColor=_getProductImageSetti.fillColor,quality=_getProductImageSetti.quality;var format=getImageFormat();return"".concat(src,"&format=").concat(format,"&width=").concat(width,"&height=").concat(height,"&quality=").concat(quality,"&fill=").concat(fillColor.replace('#',''));}if(src&&src.startsWith('https://img-cdn.shopgate.com')&&!src.includes('?')){return"".concat(src,"?w=").concat(width,"&h=").concat(height,"&q=70&zc=resize&fillc=FFFFFF");}return src;};
@@ -0,0 +1,4 @@
1
+ import{isAndroidOs,isIOs}from'@shopgate/pwa-core';import detector from'detector';/**
2
+ * Gets the image format, which should be used
3
+ * @returns {string} webp OR jpeg
4
+ */export var getImageFormat=function getImageFormat(){var format=isAndroidOs||isIOs&&detector.os.version>=14?'webp':'jpeg';return format;};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.6.1-beta.2",
3
+ "version": "7.6.1-beta.3",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,12 +16,12 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@shopgate/native-modules": "1.0.0-beta.18",
19
- "@shopgate/pwa-common": "7.6.1-beta.2",
20
- "@shopgate/pwa-common-commerce": "7.6.1-beta.2",
21
- "@shopgate/pwa-core": "7.6.1-beta.2",
22
- "@shopgate/pwa-ui-ios": "7.6.1-beta.2",
23
- "@shopgate/pwa-ui-material": "7.6.1-beta.2",
24
- "@shopgate/pwa-ui-shared": "7.6.1-beta.2",
19
+ "@shopgate/pwa-common": "7.6.1-beta.3",
20
+ "@shopgate/pwa-common-commerce": "7.6.1-beta.3",
21
+ "@shopgate/pwa-core": "7.6.1-beta.3",
22
+ "@shopgate/pwa-ui-ios": "7.6.1-beta.3",
23
+ "@shopgate/pwa-ui-material": "7.6.1-beta.3",
24
+ "@shopgate/pwa-ui-shared": "7.6.1-beta.3",
25
25
  "@stripe/react-stripe-js": "^1.1.2",
26
26
  "@stripe/stripe-js": "^1.3.1",
27
27
  "@virtuous/conductor": "~2.5.0",
@@ -1,6 +1,6 @@
1
- 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{APP_PLATFORM}from'@shopgate/pwa-common/constants/Configuration';import{OS_ANDROID}from'@shopgate/pwa-common/constants/Device';import configuration from'@shopgate/pwa-common/collections/Configuration';var qualities={jpeg:75,png:100,webp:70};var defaultParams={width:440,height:440,quality:qualities.jpeg,fill:'fff',format:'jpeg'};/**
1
+ 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{getImageFormat}from"../../../core/helpers/getImageFormat";var qualities={jpeg:75,png:100,webp:70};var defaultParams={width:440,height:440,quality:qualities.jpeg,fill:'fff',format:'jpeg'};/**
2
2
  * Append platform dimensions and quality to image url.
3
3
  * @param {string} url image url
4
4
  * @param {Object} [params=undefined] params
5
5
  * @returns {string}
6
- */export var buildMediaImageUrl=function buildMediaImageUrl(url,params){var parsedUrl=new URL(url);var isAndroid=configuration.get(APP_PLATFORM)===OS_ANDROID;var format=isAndroid?'webp':defaultParams.format;var merged=_extends({},defaultParams,{format:format,quality:qualities[format]},params);Object.keys(merged).forEach(function(k){return parsedUrl.searchParams.set(k,merged[k]);});return parsedUrl.toString();};
6
+ */export var buildMediaImageUrl=function buildMediaImageUrl(url,params){var parsedUrl=new URL(url);var format=getImageFormat();var merged=_extends({},defaultParams,{format:format,quality:qualities[format]},params);Object.keys(merged).forEach(function(k){return parsedUrl.searchParams.set(k,merged[k]);});return parsedUrl.toString();};