@shopgate/pwa-ui-shared 7.28.0 → 7.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/Price/index.js +5 -3
  2. package/package.json +5 -5
package/Price/index.js CHANGED
@@ -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;}import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import{I18n}from'@shopgate/engage/components';import showTaxDisclaimer from'@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';import{useWidgetSettings}from'@shopgate/engage/core/hooks/useWidgetSettings';import styles from"./style";/**
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 classNames from'classnames';import{I18n}from'@shopgate/engage/components';import showTaxDisclaimer from'@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';import{useWidgetSettings}from'@shopgate/engage/core/hooks/useWidgetSettings';import styles from"./style";/**
2
2
  * The Price component
3
3
  * @param {Object} props The component props
4
4
  * @param {string} [props.className] CSS classes
@@ -10,8 +10,10 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
10
10
  * @return {JSX.Element}
11
11
  */var Price=function Price(props,context){// Added with PWA 6 - CCP-2372
12
12
  var _useWidgetSettings=useWidgetSettings('@shopgate/engage/components/TaxDisclaimer'),show=_useWidgetSettings.show,hint=_useWidgetSettings.hint;// use widget setting if set to true/false, otherwise use market logic
13
- var showDisclaimer=typeof show==='boolean'?show:showTaxDisclaimer;var containerClasses=classNames(styles.container,props.className,_defineProperty({},styles.discounted,props.discounted),'price',props.discounted?'ui-shared__price-discounted':'ui-shared__price');var _context$i18n=context.i18n(),__=_context$i18n.__,_p=_context$i18n._p;var ariaPrice;if(props.unitPriceMin){ariaPrice=__('price.from',{price:_p(props.unitPriceMin,props.currency,props.fractions)});}else{ariaPrice=_p(props.unitPrice,props.currency,props.fractions);}ariaPrice=ariaPrice.replace('-',"\u2212");/**
13
+ var showDisclaimer=typeof show==='boolean'?show:showTaxDisclaimer;var containerClasses=classNames(styles.container,props.className,_defineProperty({},styles.discounted,props.discounted),'price',props.discounted?'ui-shared__price-discounted':'ui-shared__price');var _context$i18n=context.i18n(),__=_context$i18n.__,_p=_context$i18n._p;var ariaPrice;var showFromPrice=useMemo(function(){// unitPriceMin is falsy so we don't have a price range
14
+ if(!props.unitPriceMin)return false;// Only show 'from' if we have a price range (both prices are available and different)
15
+ return props.unitPriceMin!==props.unitPriceMax;},[props.unitPriceMax,props.unitPriceMin]);if(showFromPrice){ariaPrice=__('price.from',{price:_p(props.unitPriceMin,props.currency,props.fractions)});}else{ariaPrice=_p(props.unitPrice,props.currency,props.fractions);}ariaPrice=ariaPrice.replace('-',"\u2212");/**
14
16
  * A unitPriceMin > 0 means, that the product has child products with different prices.
15
17
  * The unitPriceMin contains the lowest of these prices and will be
16
18
  * displayed with a 'From' prefix.
17
- */return React.createElement("div",{className:containerClasses,"data-test-id":"minPrice: ".concat(props.unitPriceMin," price: ").concat(props.unitPrice," currency: ").concat(props.currency)},React.createElement("span",{"aria-label":__('price.label',{price:ariaPrice})},props.unitPriceMin?React.createElement(I18n.Text,{"aria-hidden":true,string:"price.from"},React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,forKey:"price",price:props.unitPriceMin})):React.createElement(React.Fragment,null,props.allowFree&&props.unitPrice===0?React.createElement(I18n.Text,{string:"price.free"}):React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,price:props.unitPrice}))),props.taxDisclaimer&&showDisclaimer?React.createElement("div",{className:styles.disclaimer},React.createElement("span",{"aria-hidden":true},hint||'*'),React.createElement("span",{className:"sr-only","aria-label":hint||__('product.tax_disclaimer_aria')},__('product.tax_disclaimer_aria'))):null);};Price.defaultProps={className:'',unitPriceMin:0,discounted:false,fractions:true,taxDisclaimer:false,allowFree:false};Price.contextTypes={i18n:PropTypes.func};export default Price;
19
+ */return React.createElement("div",{className:containerClasses,"data-test-id":"minPrice: ".concat(props.unitPriceMin," price: ").concat(props.unitPrice," currency: ").concat(props.currency)},React.createElement("span",{"aria-label":__('price.label',{price:ariaPrice})},showFromPrice?React.createElement(I18n.Text,{"aria-hidden":true,string:"price.from"},React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,forKey:"price",price:props.unitPriceMin})):React.createElement(React.Fragment,null,props.allowFree&&props.unitPrice===0?React.createElement(I18n.Text,{string:"price.free"}):React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,price:props.unitPrice}))),props.taxDisclaimer&&showDisclaimer?React.createElement("div",{className:styles.disclaimer},React.createElement("span",{"aria-hidden":true},hint||'*'),React.createElement("span",{className:"sr-only","aria-label":hint||__('product.tax_disclaimer_aria')},__('product.tax_disclaimer_aria'))):null);};Price.defaultProps={className:'',unitPriceMin:0,unitPriceMax:undefined,discounted:false,fractions:true,taxDisclaimer:false,allowFree:false};Price.contextTypes={i18n:PropTypes.func};export default Price;
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-ui-shared",
3
- "version": "7.28.0",
3
+ "version": "7.28.2",
4
4
  "description": "Shopgate's shared UI components.",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
- "@shopgate/pwa-ui-ios": "7.28.0",
9
- "@shopgate/pwa-ui-material": "7.28.0",
8
+ "@shopgate/pwa-ui-ios": "7.28.2",
9
+ "@shopgate/pwa-ui-material": "7.28.2",
10
10
  "react-day-picker": "^7.4.8"
11
11
  },
12
12
  "devDependencies": {
13
- "@shopgate/pwa-common": "7.28.0",
14
- "@shopgate/pwa-common-commerce": "7.28.0",
13
+ "@shopgate/pwa-common": "7.28.2",
14
+ "@shopgate/pwa-common-commerce": "7.28.2",
15
15
  "classnames": "2.5.1",
16
16
  "react": "~16.14.0"
17
17
  },