@shopgate/engage 7.29.0-alpha.2 → 7.29.0-alpha.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.
- package/core/actions/grantCameraPermissions.js +1 -1
- package/package.json +7 -7
- package/page/widgets/Image/Image.js +4 -0
- package/page/widgets/Image/hooks.js +24 -0
- package/page/widgets/Image/index.js +1 -0
- package/page/widgets/index.js +1 -1
- package/page/widgets/widgets.json +3 -0
- package/product/components/PriceInfo/PriceInfo.connector.js +1 -1
- package/product/components/PriceInfo/PriceInfo.js +2 -1
|
@@ -12,4 +12,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
12
12
|
* @param {string} options.modal.dismiss Label for the dismiss button.
|
|
13
13
|
* @param {Object} options.modal.params Additional parameters for i18n strings.
|
|
14
14
|
* @return { Function } A redux thunk.
|
|
15
|
-
*/var grantCameraPermissions=function grantCameraPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal;return dispatch(grantPermissions({permissionId:PERMISSION_ID_CAMERA,useSettingsModal:useSettingsModal,modal:_extends({title:null,message:'permissions.access_denied.camera_message',confirm:'permissions.access_denied.settings_button'},modal)}));};};export default grantCameraPermissions;
|
|
15
|
+
*/var grantCameraPermissions=function grantCameraPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal;return dispatch(grantPermissions({permissionId:PERMISSION_ID_CAMERA,useSettingsModal:useSettingsModal,modal:_extends({title:null,message:'permissions.access_denied.camera_message',confirm:'permissions.access_denied.settings_button',dismiss:'common.close'},modal)}));};};export default grantCameraPermissions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.29.0-alpha.
|
|
3
|
+
"version": "7.29.0-alpha.3",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@emotion/react": "^11.14.0",
|
|
19
19
|
"@shopgate/native-modules": "1.0.0-beta.25",
|
|
20
|
-
"@shopgate/pwa-common": "7.29.0-alpha.
|
|
21
|
-
"@shopgate/pwa-common-commerce": "7.29.0-alpha.
|
|
22
|
-
"@shopgate/pwa-core": "7.29.0-alpha.
|
|
23
|
-
"@shopgate/pwa-ui-ios": "7.29.0-alpha.
|
|
24
|
-
"@shopgate/pwa-ui-material": "7.29.0-alpha.
|
|
25
|
-
"@shopgate/pwa-ui-shared": "7.29.0-alpha.
|
|
20
|
+
"@shopgate/pwa-common": "7.29.0-alpha.3",
|
|
21
|
+
"@shopgate/pwa-common-commerce": "7.29.0-alpha.3",
|
|
22
|
+
"@shopgate/pwa-core": "7.29.0-alpha.3",
|
|
23
|
+
"@shopgate/pwa-ui-ios": "7.29.0-alpha.3",
|
|
24
|
+
"@shopgate/pwa-ui-material": "7.29.0-alpha.3",
|
|
25
|
+
"@shopgate/pwa-ui-shared": "7.29.0-alpha.3",
|
|
26
26
|
"@stripe/react-stripe-js": "^1.16.5",
|
|
27
27
|
"@stripe/stripe-js": "^1.3.1",
|
|
28
28
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from'react';import{makeStyles}from'@shopgate/engage/styles';import{Link,ConditionalWrapper}from'@shopgate/engage/components';import{useImageWidget}from"./hooks";var useStyles=makeStyles()(function(){return{link:{},image:{width:'100%'}};});/**
|
|
2
|
+
* The ImageWidget is used to display a image.
|
|
3
|
+
* @returns {JSX.Element}
|
|
4
|
+
*/var Image=function Image(){var _useStyles=useStyles(),cx=_useStyles.cx,classes=_useStyles.classes;var _useImageWidget=useImageWidget(),link=_useImageWidget.link,altText=_useImageWidget.altText,url=_useImageWidget.url;if(!url)return null;return React.createElement(ConditionalWrapper,{condition:!!link,wrapper:function wrapper(children){return React.createElement(Link,{href:link,className:cx(classes.link)},children);}},React.createElement("img",{loading:"lazy",src:url,alt:altText,className:cx(classes.image)}));};export default Image;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{useWidget}from'@shopgate/engage/page/hooks';import{useResponsiveValue}from'@shopgate/engage/styles';/**
|
|
2
|
+
* Parses the image URL to return a high resolution version if required.
|
|
3
|
+
* @param {string} url The original image URL.
|
|
4
|
+
* @param {boolean} useHighRes Whether to return a high resolution version.
|
|
5
|
+
* @returns {string} The parsed image URL.
|
|
6
|
+
*/var parseImageUrl=function parseImageUrl(url,useHighRes){if(!url||!useHighRes){return url;}var match=url.match(/^(.*)\.([^./]+)$/);return!match?url:"".concat(match[1],"@2x.").concat(match[2]);};/**
|
|
7
|
+
* @typedef {Object} ImageWidgetConfig
|
|
8
|
+
* @property {Object} image The image object.
|
|
9
|
+
* @property {string} image.url The image URL.
|
|
10
|
+
* @property {string} [image.altText] The image alt text.
|
|
11
|
+
* @property {Object} imageWide The wide image object.
|
|
12
|
+
* @property {string} imageWide.url The wide image URL.
|
|
13
|
+
* @property {string} [imageWide.altText] The wide image alt text.
|
|
14
|
+
* @property {boolean} [useImageWide] Whether to use the wide image on
|
|
15
|
+
* medium and larger screens.
|
|
16
|
+
* @property {string} [link] The link URL.
|
|
17
|
+
*/ /**
|
|
18
|
+
* @typedef {ReturnType< typeof import('@shopgate/engage/page/hooks')
|
|
19
|
+
* .useWidget<ImageWidgetConfig> >} UseWidgetReturnType
|
|
20
|
+
*/ // eslint-disable-next-line valid-jsdoc
|
|
21
|
+
/**
|
|
22
|
+
* Hook to access the Image widget configuration and data.
|
|
23
|
+
* Handles responsive image URLs and alt texts.
|
|
24
|
+
*/export var useImageWidget=function useImageWidget(){/** @type {UseWidgetReturnType} */var _useWidget=useWidget(),config=_useWidget.config;var _ref=config||{},image=_ref.image,imageWide=_ref.imageWide,link=_ref.link,useImageWide=_ref.useImageWide;var url=useResponsiveValue({xs:image===null||image===void 0?void 0:image.url,md:useImageWide&&(imageWide===null||imageWide===void 0?void 0:imageWide.url)?parseImageUrl(imageWide.url,true):parseImageUrl(image===null||image===void 0?void 0:image.url,true)});var altText=useResponsiveValue({xs:image===null||image===void 0?void 0:image.altText,md:useImageWide&&(imageWide===null||imageWide===void 0?void 0:imageWide.altText)?imageWide.altText:image===null||image===void 0?void 0:image.altText});return{url:url,altText:altText,link:link};};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default}from"./Image";
|
package/page/widgets/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as PlaceholderWidget}from"./Placeholder";export{default as ProductListWidget}from"./ProductList";export{default as CategoryListWidget}from"./CategoryList";export{default as HtmlWidget}from"./HTML";export{default as ProductSliderWidget}from"./ProductSlider";export{default as HeadlineWidget}from"./Headline";
|
|
1
|
+
export{default as PlaceholderWidget}from"./Placeholder";export{default as ProductListWidget}from"./ProductList";export{default as CategoryListWidget}from"./CategoryList";export{default as HtmlWidget}from"./HTML";export{default as ProductSliderWidget}from"./ProductSlider";export{default as HeadlineWidget}from"./Headline";export{default as ImageWidget}from"./Image";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{connect}from'react-redux';import{makeGetShopSettingByKey}from"../../../core/selectors/shopSettings";import{SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT}from"../../../core/constants";/**
|
|
2
2
|
* Creates the mapStateToProps connector function.
|
|
3
3
|
* @returns {Function}
|
|
4
|
-
*/var makeMapStateToProps=function makeMapStateToProps(){var getShopSetting=makeGetShopSettingByKey(SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,
|
|
4
|
+
*/var makeMapStateToProps=function makeMapStateToProps(){var getShopSetting=makeGetShopSettingByKey(SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,true);return function(state,props){return{displayPricePerMeasureUnit:getShopSetting(state,props)};};};export default connect(makeMapStateToProps);
|
|
@@ -1,4 +1,5 @@
|
|
|
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,{useMemo}from'react';import PropTypes from'prop-types';import{css}from'glamor';import classNames from'classnames';import{i18n}from'@shopgate/engage/core';import{ConditionalWrapper}from'@shopgate/engage/components';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import connect from"./PriceInfo.connector";var styles={container:css({color:themeConfig.colors.shade3}).toString(),noWrap:css({whiteSpace:'nowrap'}).toString()};/**
|
|
2
2
|
* The price info component
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var PriceInfo=function PriceInfo(_ref){var product=_ref.product,className=_ref.className,wrapper=_ref.wrapper,displayPricePerMeasureUnit=_ref.displayPricePerMeasureUnit,externalCurrency=_ref.currency;var _ref2=product||{},_ref2$price=_ref2.price,price=_ref2$price===void 0?{}:_ref2$price,unitPriceRefValue=_ref2.unitPriceRefValue,unitPriceRefUom=_ref2.unitPriceRefUom;var pricePerMeasureUnit=price.pricePerMeasureUnit,info=price.info,currency=price.currency;var content=useMemo(function(){if(!displayPricePerMeasureUnit){return info;}if(!pricePerMeasureUnit){return null;}var unitKey="formats.unitOfMeasurement.".concat(unitPriceRefUom);var unit=i18n.text(unitKey);if(unit===unitKey){unit=unitPriceRefUom;}return i18n.text('price.pricePerMeasurementFormat',{price:i18n.price(pricePerMeasureUnit,currency||externalCurrency,2)
|
|
4
|
+
*/var PriceInfo=function PriceInfo(_ref){var product=_ref.product,className=_ref.className,wrapper=_ref.wrapper,displayPricePerMeasureUnit=_ref.displayPricePerMeasureUnit,externalCurrency=_ref.currency;var _ref2=product||{},_ref2$price=_ref2.price,price=_ref2$price===void 0?{}:_ref2$price,unitPriceRefValue=_ref2.unitPriceRefValue,unitPriceRefUom=_ref2.unitPriceRefUom;var pricePerMeasureUnit=price.pricePerMeasureUnit,info=price.info,currency=price.currency;var content=useMemo(function(){if(!displayPricePerMeasureUnit||!pricePerMeasureUnit){return info;}if(!pricePerMeasureUnit){return null;}var unitKey="formats.unitOfMeasurement.".concat(unitPriceRefUom);var unit=i18n.text(unitKey);if(unit===unitKey){unit=unitPriceRefUom;}return i18n.text('price.pricePerMeasurementFormat',{price:i18n.price(pricePerMeasureUnit,currency||externalCurrency,2),// Don't show base prices like 1.99€/1kg, but show 1.99€/kg instead
|
|
5
|
+
refValue:!!unitPriceRefValue&&unitPriceRefValue!==1?unitPriceRefValue:'',refUom:unit});},[currency,displayPricePerMeasureUnit,externalCurrency,info,pricePerMeasureUnit,unitPriceRefUom,unitPriceRefValue]);if(!content){return null;}return React.createElement(ConditionalWrapper,{condition:!!wrapper,wrapper:wrapper},React.createElement("div",{className:classNames(styles.container,className,'engage__product__price-info',_defineProperty({},styles.noWrap,content!==info)),dangerouslySetInnerHTML:{__html:content},"data-test-id":"priceInfo: ".concat(content)}));};PriceInfo.defaultProps={product:null,className:null,currency:null,wrapper:null,displayPricePerMeasureUnit:false};export default connect(PriceInfo);
|