@shopgate/engage 6.20.0-beta.1 → 6.20.0-beta.4
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/a11y/components/LiveMessage/__tests__/index.spec.js +1 -1
- package/a11y/components/LiveMessage/index.js +1 -1
- package/a11y/components/LiveMessenger/__tests__/index.spec.js +1 -1
- package/a11y/components/LiveMessenger/helpers.js +1 -1
- package/a11y/components/LiveMessenger/index.js +2 -2
- package/a11y/components/Navigation/__tests__/index.spec.js +1 -1
- package/a11y/components/Navigation/index.js +1 -1
- package/a11y/components/Section/__tests__/index.spec.js +1 -1
- package/a11y/components/Section/index.js +2 -2
- package/a11y/index.spec.js +1 -1
- package/account/constants/index.js +1 -0
- package/account/constants/routes.js +1 -0
- package/account/index.js +1 -0
- package/app-rating/actions/showModal.js +2 -2
- package/cart/index.spec.js +1 -1
- package/category/components/CategoryList/index.js +1 -1
- package/category/index.spec.js +1 -1
- package/checkout/index.spec.js +1 -1
- package/components/ChipLayout/index.js +11 -11
- package/components/ChipLayout/spec.js +1 -1
- package/components/Footer/Footer.js +9 -9
- package/components/Footer/__tests__/Footer.spec.js +4 -4
- package/components/Form/Builder/Builder.js +10 -10
- package/components/Form/Builder/Builder.spec.js +4 -4
- package/components/Form/Builder/ElementCheckbox.js +1 -1
- package/components/Form/Builder/ElementRadio.js +1 -1
- package/components/Form/Builder/ElementSelect.js +1 -1
- package/components/Form/Builder/ElementText.js +1 -1
- package/components/Form/Builder/classes/ActionListener.js +3 -3
- package/components/Form/Builder/helpers/buildCountryList.js +1 -1
- package/components/Form/Builder/helpers/buildFormDefaults.js +1 -1
- package/components/Form/Builder/helpers/buildFormElements.js +2 -2
- package/components/Form/Builder/helpers/buildFormElements.spec.js +2 -2
- package/components/Form/Builder/helpers/buildProvinceList.js +1 -1
- package/components/Form/Form.js +8 -8
- package/components/IntersectionVisibility/index.js +5 -5
- package/components/Logo/index.js +1 -1
- package/components/Logo/spec.js +1 -1
- package/components/MessageBar/index.js +1 -1
- package/components/MessageBar/spec.js +1 -1
- package/components/NavigationHandler/index.js +5 -5
- package/components/NavigationHandler/spec.js +1 -1
- package/components/Picker/components/Button/index.js +1 -1
- package/components/Picker/components/List/index.js +1 -1
- package/components/Picker/components/Modal/index.js +5 -5
- package/components/Picker/index.js +9 -9
- package/components/Picker/spec.js +1 -1
- package/components/PickerUtilize/components/Button/index.js +1 -1
- package/components/PickerUtilize/index.js +6 -6
- package/components/PickerUtilize/spec.js +1 -1
- package/components/QuantityInput/QuantityInput.js +4 -4
- package/components/RangeSlider/components/Handle/index.js +1 -1
- package/components/RangeSlider/index.js +11 -11
- package/components/RangeSlider/spec.js +4 -4
- package/components/ScrollHeader/index.js +2 -2
- package/components/SheetDrawer/index.js +1 -1
- package/components/SheetList/components/Item/index.js +5 -5
- package/components/SheetList/components/Item/spec.js +2 -2
- package/components/SheetList/index.js +4 -4
- package/components/SheetList/spec.js +1 -1
- package/components/SnackBarContainer/index.js +1 -1
- package/components/TimeBoundary/index.js +5 -5
- package/components/TimeBoundary/spec.js +3 -3
- package/components/VideoPlayer/index.js +6 -6
- package/components/View/__mocks__/index.js +1 -1
- package/components/View/__tests__/index.spec.js +1 -1
- package/components/View/__tests__/provider.spec.js +1 -1
- package/components/View/components/Above/__tests__/index.spec.js +1 -1
- package/components/View/components/Above/index.js +1 -1
- package/components/View/components/Below/__tests__/index.spec.js +1 -1
- package/components/View/components/Below/index.js +1 -1
- package/components/View/components/Content/__tests__/index.spec.js +1 -1
- package/components/View/components/Content/index.js +9 -9
- package/components/View/context.js +1 -1
- package/components/View/index.js +2 -2
- package/components/View/provider.js +6 -4
- package/components/index.spec.js +1 -1
- package/core/actions/__tests__/getGeolocation.spec.js +2 -2
- package/core/actions/__tests__/grantPermissions.spec.js +1 -1
- package/core/actions/getGeolocation.js +1 -1
- package/core/actions/grantPermissions.js +3 -3
- package/core/classes/GeolocationRequest.js +3 -3
- package/core/config/ThemeConfigResolver.js +1 -1
- package/core/constants/shopSettings.js +2 -0
- package/core/contexts/AppContext.js +1 -1
- package/core/helpers/getFullImageSource.js +2 -2
- package/core/helpers/updateLegacyNavigationBar.js +1 -1
- package/core/hocs/__mocks__/withWidgetSettings.js +1 -1
- package/core/hocs/__tests__/withApp.spec.js +1 -1
- package/core/hocs/__tests__/withCurrentProduct.spec.js +1 -1
- package/core/hocs/__tests__/withForwardedRef.spec.js +1 -1
- package/core/hocs/__tests__/withNavigation.spec.js +1 -1
- package/core/hocs/__tests__/withRoute.spec.js +1 -1
- package/core/hocs/__tests__/withTheme.spec.js +2 -2
- package/core/hocs/__tests__/withWidgetSettings.spec.js +1 -1
- package/core/hocs/__tests__/withWidgetStyles.spec.js +1 -1
- package/core/hocs/withApp.js +1 -1
- package/core/hocs/withCurrentProduct.js +1 -1
- package/core/hocs/withForwardedRef.js +1 -1
- package/core/hocs/withNavigation.js +1 -1
- package/core/hocs/withRoute.js +1 -1
- package/core/hocs/withTheme.js +2 -2
- package/core/hocs/withWidgetSettings.js +1 -1
- package/core/hocs/withWidgetStyles.js +1 -1
- package/core/hooks/__tests__/useNavigation.spec.js +1 -1
- package/core/hooks/html/useLoadImage.js +1 -1
- package/core/hooks/useTheme.js +2 -2
- package/core/index.spec.js +1 -1
- package/core/providers/AppProvider.js +9 -7
- package/core/providers/__tests__/AppProvider.spec.js +2 -2
- package/core/selectors/index.js +1 -0
- package/core/selectors/shopSettings.js +14 -0
- package/favorites/components/FavoriteProvider/connector.js +5 -0
- package/favorites/components/FavoriteProvider/index.js +4 -0
- package/favorites/components/Item/Item.js +10 -0
- package/favorites/components/Item/ItemCharacteristics.js +4 -0
- package/favorites/components/Item/index.js +1 -0
- package/favorites/components/List/List.js +16 -0
- package/favorites/components/List/index.js +1 -0
- package/favorites/components/ListChooser/ListChooser.js +10 -0
- package/favorites/components/ListChooser/ListChooserItem.js +7 -0
- package/favorites/components/ListChooser/index.js +1 -0
- package/favorites/components/Lists/Lists.js +16 -0
- package/favorites/components/Lists/ListsModal.js +4 -0
- package/favorites/components/Lists/index.js +1 -0
- package/favorites/components/RemoveButton/RemoveButton.js +4 -0
- package/favorites/components/RemoveButton/index.js +1 -0
- package/favorites/constants/Portals.js +2 -0
- package/favorites/index.js +3 -4
- package/favorites/index.spec.js +1 -1
- package/filter/components/FilterItem/index.js +1 -1
- package/filter/components/FilterItem/spec.js +1 -1
- package/filter/components/PriceSlider/components/Label/index.js +2 -2
- package/filter/components/PriceSlider/components/Label/spec.js +1 -1
- package/filter/components/PriceSlider/index.js +6 -6
- package/filter/components/PriceSlider/spec.js +1 -1
- package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +1 -1
- package/filter/helpers/buildInitialFilters.js +1 -1
- package/filter/helpers/buildUpdatedFilters.js +2 -2
- package/filter/index.spec.js +1 -1
- package/index.spec.js +1 -1
- package/market/index.spec.js +1 -1
- package/orders/index.spec.js +1 -1
- package/package.json +7 -7
- package/page/index.spec.js +1 -1
- package/product/components/Characteristics/Characteristic/components/Sheet/index.js +4 -4
- package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +3 -3
- package/product/components/Characteristics/Characteristic/components/VariantAvailability/index.js +3 -3
- package/product/components/Characteristics/Characteristic/index.js +5 -5
- package/product/components/Characteristics/Swatch/index.js +5 -5
- package/product/components/Characteristics/index.js +3 -3
- package/product/components/Description/__tests__/Description.spec.js +1 -1
- package/product/components/Description/index.js +2 -2
- package/product/components/EffectivityDates/index.js +1 -1
- package/product/components/Header/PriceStriked/index.js +1 -1
- package/product/components/Header/Shipping/components/Label/index.js +2 -2
- package/product/components/Header/Shipping/index.js +1 -1
- package/product/components/Header/Shipping/spec.js +1 -1
- package/product/components/Header/Tiers/components/Tier/index.js +2 -2
- package/product/components/Header/Tiers/components/Tier/spec.js +1 -1
- package/product/components/Header/Tiers/index.js +1 -1
- package/product/components/Header/Tiers/spec.js +1 -1
- package/product/components/MapPriceHint/index.js +1 -1
- package/product/components/Media/FeaturedMedia.js +1 -1
- package/product/components/Media/MediaImage.js +2 -2
- package/product/components/Media/MediaPlaceholder.js +1 -1
- package/product/components/Media/helpers.js +2 -2
- package/product/components/MediaSlider/components/MediaImage/index.js +1 -1
- package/product/components/MediaSlider/components/MediaVideo/index.js +1 -1
- package/product/components/MediaSlider/index.js +1 -1
- package/product/components/Options/components/Content/index.js +6 -6
- package/product/components/Options/components/Content/spec.js +1 -1
- package/product/components/Options/components/Option/index.js +1 -1
- package/product/components/Options/components/TextOption/components/OptionInfo/index.js +2 -2
- package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +1 -1
- package/product/components/Options/components/TextOption/index.js +6 -6
- package/product/components/Options/index.js +1 -1
- package/product/components/OrderQuantityHint/index.js +1 -1
- package/product/components/PriceDifference/index.js +1 -1
- package/product/components/ProductBadges/index.js +2 -2
- package/product/components/ProductCard/index.js +2 -2
- package/product/components/ProductCharacteristics/context.js +1 -1
- package/product/components/ProductCharacteristics/index.js +9 -9
- package/product/components/ProductDiscountBadge/index.js +1 -1
- package/product/components/ProductDiscountBadge/spec.js +1 -1
- package/product/components/ProductGridPrice/index.js +1 -1
- package/product/components/ProductGridPrice/index.spec.js +1 -1
- package/product/components/ProductImage/index.js +7 -7
- package/product/components/ProductImage/spec.js +1 -1
- package/product/components/ProductList/components/Item/index.js +1 -1
- package/product/components/ProductList/components/Iterator/index.js +1 -1
- package/product/components/ProductList/components/Layout/index.js +1 -1
- package/product/components/ProductList/index.js +1 -1
- package/product/components/ProductProperties/Content.js +2 -2
- package/product/components/ProductProperties/Group.js +1 -1
- package/product/components/ProductProperties/GroupedProperties.js +1 -1
- package/product/components/ProductProperties/Lists.js +1 -1
- package/product/components/ProductProperties/ProductProperties.js +1 -1
- package/product/components/ProductProperties/Row.js +1 -1
- package/product/components/ProductProperties/Rows.js +1 -1
- package/product/components/ProductProperties/Wrapper.js +1 -1
- package/product/components/ProductProperties/__tests__/Content.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Group.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Lists.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Row.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Rows.spec.js +1 -1
- package/product/components/ProductProvider/index.js +1 -1
- package/product/components/ProductSlider/index.js +1 -1
- package/product/components/ProductSlider/spec.js +1 -1
- package/product/components/QuantityPicker/index.js +2 -2
- package/product/components/Rating/index.js +2 -2
- package/product/components/Rating/spec.js +1 -1
- package/product/components/RelationsSlider/RelationsSheet.js +2 -2
- package/product/components/RelationsSlider/RelationsSlider.js +1 -1
- package/product/components/RelationsSlider/RelationsSliderContent.js +1 -1
- package/product/components/Swatch/Swatch.js +1 -1
- package/product/components/Swatch/SwatchContent.js +1 -1
- package/product/components/Swatch/VariantSwatch.js +1 -1
- package/product/components/Swatches/Swatches.js +1 -1
- package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +1 -1
- package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +1 -1
- package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +1 -1
- package/product/components/__mocks__/context.js +1 -1
- package/product/components/context.js +1 -1
- package/product/helpers/index.js +1 -1
- package/product/hocs/withMapPricing.js +4 -4
- package/product/hocs/withPriceCalculation.js +2 -2
- package/product/hooks/useLoadProductImage.js +1 -1
- package/product/index.spec.js +1 -1
- package/reviews/components/Reviews/components/AllReviewsLink/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/AverageRating/index.js +2 -2
- package/reviews/components/Reviews/components/Header/components/NoReviews/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +1 -1
- package/reviews/components/Reviews/components/Header/index.js +1 -1
- package/reviews/components/Reviews/components/Header/spec.js +1 -1
- package/reviews/components/Reviews/components/List/components/Info/components/Author/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Info/components/ReviewDate/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Info/index.js +2 -2
- package/reviews/components/Reviews/components/List/components/Rating/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Review/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Text/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Title/index.js +1 -1
- package/reviews/components/Reviews/components/List/index.js +3 -3
- package/reviews/components/Reviews/components/List/spec.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/index.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/spec.js +1 -1
- package/reviews/components/Reviews/index.js +1 -1
- package/reviews/components/Reviews/spec.js +2 -2
- package/reviews/index.spec.js +1 -1
- package/scanner/index.spec.js +1 -1
- package/search/index.spec.js +1 -1
- package/user/index.spec.js +1 -1
- package/core/helpers/getImageFormat.js +0 -4
|
@@ -3,4 +3,4 @@ import React,{Fragment}from'react';import PropTypes from'prop-types';import{Grid
|
|
|
3
3
|
* renders a row with the current price and a strike price when present. As same as the price info.
|
|
4
4
|
* @param {Object} price The price object of a product entity.
|
|
5
5
|
* @return {JSX}
|
|
6
|
-
*/var ProductGridPrice=function ProductGridPrice(_ref){var price=_ref.price;return
|
|
6
|
+
*/var ProductGridPrice=function ProductGridPrice(_ref){var price=_ref.price;return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Grid,{className:"".concat(styles.priceWrapper," engage__product__product-grid-price"),wrap:true},/*#__PURE__*/React.createElement(Grid.Item,{grow:1},/*#__PURE__*/React.createElement(Price,{currency:price.currency,discounted:!!price.discount,unitPrice:price.unitPrice,unitPriceMin:price.unitPriceMin})),price.msrp>0&&price.unitPrice!==price.msrp&&/*#__PURE__*/React.createElement(Grid.Item,null,/*#__PURE__*/React.createElement(PriceStriked,{className:styles.strikedPrice,value:price.msrp,currency:price.currency})),!price.msrp&&price.unitPriceStriked>0&&/*#__PURE__*/React.createElement(Grid.Item,null,/*#__PURE__*/React.createElement(PriceStriked,{className:styles.strikedPrice,value:price.unitPriceStriked,currency:price.currency}))),price.info&&/*#__PURE__*/React.createElement(Grid,null,/*#__PURE__*/React.createElement(Grid.Item,null,/*#__PURE__*/React.createElement(PriceInfo,{className:styles.basicPrice,text:price.info}))));};export default withPriceCalculation(ProductGridPrice);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import PropTypes from'prop-types';import{mount}from'enzyme';import ProductGridPrice from"./index";jest.mock('@shopgate/engage/core/helpers/i18n',function(){return{i18n:{text:function text(input){return input;},price:function price(input){return input;},ready:true}};});var mockRenderOptions={context:{i18n:function i18n(){return{__:function __(input){return input;},_p:function _p(input){return input;}};}},childContextTypes:{i18n:PropTypes.func}};var mockPrice={currency:'EUR',msrp:0,discount:0,unitPrice:22.95,unitPriceMin:22.95,unitPriceStriked:0,info:'PriceInfoString'};var mockPriceStriked={currency:'EUR',msrp:0,discount:52,unitPrice:10.95,unitPriceMin:10.95,unitPriceStriked:22.95,info:''};var mockPriceMsrp={currency:'EUR',msrp:22.95,discount:52,unitPrice:10.95,unitPriceMin:10.95,unitPriceStriked:0,info:'PriceInfoString'};describe('<ProductGridPrice />',function(){it('should render without discounts',function(){var component=mount(React.createElement(ProductGridPrice,{price:mockPrice}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPrice.currency);expect(price.prop('unitPrice')).toBe(mockPrice.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPrice.unitPriceMin);expect(price.prop('discounted')).toBe(false);expect(priceStriked.exists()).toBe(false);expect(priceInfo.exists()).toBe(true);expect(priceInfo.prop('text')).toBe(mockPrice.info);});it('should render with strike price',function(){var component=mount(React.createElement(ProductGridPrice,{price:mockPriceStriked}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPriceStriked.currency);expect(price.prop('unitPrice')).toBe(mockPriceStriked.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPriceStriked.unitPriceMin);expect(price.prop('discounted')).toBe(true);expect(priceStriked.exists()).toBe(true);expect(priceStriked.prop('currency')).toBe(mockPriceStriked.currency);expect(priceStriked.prop('value')).toBe(mockPriceStriked.unitPriceStriked);expect(priceInfo.exists()).toBe(false);});it('should render with msrp',function(){var component=mount(React.createElement(ProductGridPrice,{price:mockPriceMsrp}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPriceMsrp.currency);expect(price.prop('unitPrice')).toBe(mockPriceMsrp.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPriceMsrp.unitPriceMin);expect(price.prop('discounted')).toBe(true);expect(priceStriked.exists()).toBe(true);expect(priceStriked.prop('currency')).toBe(mockPriceMsrp.currency);expect(priceStriked.prop('value')).toBe(mockPriceMsrp.msrp);expect(priceInfo.exists()).toBe(true);expect(priceInfo.prop('text')).toBe(mockPriceMsrp.info);});});
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import{mount}from'enzyme';import ProductGridPrice from"./index";jest.mock('@shopgate/engage/core/helpers/i18n',function(){return{i18n:{text:function text(input){return input;},price:function price(input){return input;},ready:true}};});var mockRenderOptions={context:{i18n:function i18n(){return{__:function __(input){return input;},_p:function _p(input){return input;}};}},childContextTypes:{i18n:PropTypes.func}};var mockPrice={currency:'EUR',msrp:0,discount:0,unitPrice:22.95,unitPriceMin:22.95,unitPriceStriked:0,info:'PriceInfoString'};var mockPriceStriked={currency:'EUR',msrp:0,discount:52,unitPrice:10.95,unitPriceMin:10.95,unitPriceStriked:22.95,info:''};var mockPriceMsrp={currency:'EUR',msrp:22.95,discount:52,unitPrice:10.95,unitPriceMin:10.95,unitPriceStriked:0,info:'PriceInfoString'};describe('<ProductGridPrice />',function(){it('should render without discounts',function(){var component=mount(/*#__PURE__*/React.createElement(ProductGridPrice,{price:mockPrice}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPrice.currency);expect(price.prop('unitPrice')).toBe(mockPrice.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPrice.unitPriceMin);expect(price.prop('discounted')).toBe(false);expect(priceStriked.exists()).toBe(false);expect(priceInfo.exists()).toBe(true);expect(priceInfo.prop('text')).toBe(mockPrice.info);});it('should render with strike price',function(){var component=mount(/*#__PURE__*/React.createElement(ProductGridPrice,{price:mockPriceStriked}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPriceStriked.currency);expect(price.prop('unitPrice')).toBe(mockPriceStriked.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPriceStriked.unitPriceMin);expect(price.prop('discounted')).toBe(true);expect(priceStriked.exists()).toBe(true);expect(priceStriked.prop('currency')).toBe(mockPriceStriked.currency);expect(priceStriked.prop('value')).toBe(mockPriceStriked.unitPriceStriked);expect(priceInfo.exists()).toBe(false);});it('should render with msrp',function(){var component=mount(/*#__PURE__*/React.createElement(ProductGridPrice,{price:mockPriceMsrp}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPriceMsrp.currency);expect(price.prop('unitPrice')).toBe(mockPriceMsrp.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPriceMsrp.unitPriceMin);expect(price.prop('discounted')).toBe(true);expect(priceStriked.exists()).toBe(true);expect(priceStriked.prop('currency')).toBe(mockPriceMsrp.currency);expect(priceStriked.prop('value')).toBe(mockPriceMsrp.msrp);expect(priceInfo.exists()).toBe(true);expect(priceInfo.prop('text')).toBe(mockPriceMsrp.info);});});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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 _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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 _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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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 isEqual from'lodash/isEqual';import classnames from'classnames';import{logger}from'@shopgate/pwa-core';import appConfig,{themeConfig}from'@shopgate/pwa-common/helpers/config';import Image from'@shopgate/pwa-common/components/Image';import PlaceholderIcon from'@shopgate/pwa-ui-shared/icons/PlaceholderIcon';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{withWidgetSettings}from"../../../core/hocs/withWidgetSettings";import{PORTAL_PRODUCT_IMAGE}from"../../../components/constants";import styles from"./style";var colors=themeConfig.colors;/**
|
|
2
2
|
* The product image component.
|
|
3
3
|
* This component will behave like the core Image component with the additional
|
|
4
4
|
* feature of showing a placeholder in case no src property has been passed
|
|
5
5
|
* or the given source image cannot be loaded.
|
|
6
|
-
*/var ProductImage=/*#__PURE__*/function(_Component){_inherits(ProductImage,_Component);/**
|
|
6
|
+
*/var ProductImage=/*#__PURE__*/function(_Component){_inherits(ProductImage,_Component);var _super=_createSuper(ProductImage);/**
|
|
7
7
|
* See Image component manual for detailed description about the component property types.
|
|
8
8
|
*/ /**
|
|
9
9
|
* Component constructor
|
|
10
10
|
* @param {Object} props The component properties
|
|
11
|
-
*/function ProductImage(props){var _this;_classCallCheck(this,ProductImage);_this=
|
|
11
|
+
*/function ProductImage(props){var _this;_classCallCheck(this,ProductImage);_this=_super.call(this,props);_defineProperty(_assertThisInitialized(_this),"imageLoadingFailed",function(){_this.setState({showPlaceholder:true});});_defineProperty(_assertThisInitialized(_this),"getImageRatio",function(){if(_this.props.ratio){var _this$props$ratio=_slicedToArray(_this.props.ratio,2),x=_this$props$ratio[0],y=_this$props$ratio[1];return(y/x).toFixed(3);}var _this$props$resolutio=_this.props.resolutions[_this.props.resolutions.length-1],width=_this$props$resolutio.width,height=_this$props$resolutio.height;return(height/width).toFixed(3);});logger.assert(!props.srcmap,'Use of srcmap prop is deprecated. Use resolutions instead');var showPlaceholder=!props.src&&(props.srcmap===null||props.srcmap.length===0);_this.state={showPlaceholder:showPlaceholder};return _this;}/**
|
|
12
12
|
* Called when the component props change.
|
|
13
13
|
* @param {Object} nextProps The new component properties
|
|
14
14
|
*/_createClass(ProductImage,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Disable the placeholder to give the real image a new chance to load.
|
|
@@ -19,9 +19,9 @@ var showPlaceholder=!nextProps.src&&(!nextProps.srcmap||nextProps.srcmap.length=
|
|
|
19
19
|
* @return {boolean} Update or not.
|
|
20
20
|
*/},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps){return!isEqual(this.props,nextProps);}/**
|
|
21
21
|
* Triggered when the image could not be loaded for some reason.
|
|
22
|
-
*/},{key:"render"
|
|
22
|
+
*/},{key:"render",value:/**
|
|
23
23
|
* Renders the component.
|
|
24
24
|
* @returns {JSX}
|
|
25
|
-
*/
|
|
26
|
-
return
|
|
27
|
-
return
|
|
25
|
+
*/function render(){var _this$props=this.props,noBackground=_this$props.noBackground,className=_this$props.className;var showInnerShadow=this.props.widgetSettings.showInnerShadow;if(typeof showInnerShadow==='undefined'){showInnerShadow=!appConfig.hideProductImageShadow;}if(this.state.showPlaceholder){var _classnames;// Image is not present or could not be loaded, show a placeholder.
|
|
26
|
+
return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PORTAL_PRODUCT_IMAGE},/*#__PURE__*/React.createElement("div",{className:classnames(styles.placeholderContainer(this.getImageRatio()),(_classnames={},_defineProperty(_classnames,styles.innerShadow,showInnerShadow),_defineProperty(_classnames,className,!!className),_classnames)),"aria-hidden":this.props['aria-hidden']},/*#__PURE__*/React.createElement("div",{className:styles.placeholderContent,"data-test-id":"placeHolder"},/*#__PURE__*/React.createElement(PlaceholderIcon,{className:styles.placeholder}))));}// Return the actual image.
|
|
27
|
+
return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PORTAL_PRODUCT_IMAGE},/*#__PURE__*/React.createElement("div",{"aria-hidden":this.props['aria-hidden'],className:"".concat(className," engage__product__product-image")},/*#__PURE__*/React.createElement(Image,_extends({},this.props,{className:showInnerShadow?styles.innerShadow:'',backgroundColor:noBackground?'transparent':colors.light,onError:this.imageLoadingFailed}))));}}]);return ProductImage;}(Component);_defineProperty(ProductImage,"defaultProps",{alt:null,animating:true,'aria-hidden':null,className:null,forcePlaceholder:false,highestResolutionLoaded:function highestResolutionLoaded(){},noBackground:false,ratio:null,resolutions:[{width:50,height:50,blur:2},{width:440,height:440}],src:null,srcmap:null,widgetSettings:{}});export{ProductImage as UnwrappedProductImage};export default withWidgetSettings(ProductImage,'@shopgate/engage/product/ProductImage');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Image from'@shopgate/pwa-common/components/Image';import appConfig from'@shopgate/pwa-common/helpers/config';import PlaceholderIcon from'@shopgate/pwa-ui-shared/icons/PlaceholderIcon';import styles from"./style";import ProductImage from"./index";jest.unmock('@shopgate/pwa-core');jest.mock("../../../core/hocs/withWidgetSettings");jest.mock('@shopgate/pwa-common/helpers/config');describe('<ProductImage />',function(){it('should render a placeholder if no src prop is provided',function(){var wrapper=shallow(React.createElement(ProductImage,null)).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(Image).length).toBe(0);expect(wrapper.find(PlaceholderIcon).length).toBe(1);});it('should render the image without a placeholder',function(){var wrapper=shallow(React.createElement(ProductImage,{src:"http://placehold.it/300x300"})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(Image).length).toBe(1);expect(wrapper.find(PlaceholderIcon).length).toBe(0);});it('should not apply an inner shadow to the placeholder if turned off via the app config',function(){jest.spyOn(appConfig,'hideProductImageShadow','get').mockReturnValue(true);var wrapper=shallow(React.createElement(ProductImage,null)).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should not apply an inner shadow to the image if turned off via the app config',function(){jest.spyOn(appConfig,'hideProductImageShadow','get').mockReturnValue(true);var wrapper=shallow(React.createElement(ProductImage,{src:"http://placehold.it/300x300"})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should not apply an inner shadow to the placeholder if turned off via the widget settings',function(){var wrapper=shallow(React.createElement(ProductImage,{widgetSettings:{showInnerShadow:false}})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should not apply an inner shadow to the image if turned off via the widget settings',function(){var wrapper=shallow(React.createElement(ProductImage,{src:"http://placehold.it/300x300",widgetSettings:{showInnerShadow:false}}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should apply an inner shadow to the placeholder if turned off via the widget settings',function(){var wrapper=shallow(React.createElement(ProductImage,{widgetSettings:{showInnerShadow:true}})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(1);});it('should apply an inner shadow to the image if turned off via the widget settings',function(){var wrapper=shallow(React.createElement(ProductImage,{src:"http://placehold.it/300x300",widgetSettings:{showInnerShadow:true}})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(1);});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Image from'@shopgate/pwa-common/components/Image';import appConfig from'@shopgate/pwa-common/helpers/config';import PlaceholderIcon from'@shopgate/pwa-ui-shared/icons/PlaceholderIcon';import styles from"./style";import ProductImage from"./index";jest.unmock('@shopgate/pwa-core');jest.mock("../../../core/hocs/withWidgetSettings");jest.mock('@shopgate/pwa-common/helpers/config');describe('<ProductImage />',function(){it('should render a placeholder if no src prop is provided',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,null)).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(Image).length).toBe(0);expect(wrapper.find(PlaceholderIcon).length).toBe(1);});it('should render the image without a placeholder',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,{src:"http://placehold.it/300x300"})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(Image).length).toBe(1);expect(wrapper.find(PlaceholderIcon).length).toBe(0);});it('should not apply an inner shadow to the placeholder if turned off via the app config',function(){jest.spyOn(appConfig,'hideProductImageShadow','get').mockReturnValue(true);var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,null)).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should not apply an inner shadow to the image if turned off via the app config',function(){jest.spyOn(appConfig,'hideProductImageShadow','get').mockReturnValue(true);var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,{src:"http://placehold.it/300x300"})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should not apply an inner shadow to the placeholder if turned off via the widget settings',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,{widgetSettings:{showInnerShadow:false}})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should not apply an inner shadow to the image if turned off via the widget settings',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,{src:"http://placehold.it/300x300",widgetSettings:{showInnerShadow:false}}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(0);});it('should apply an inner shadow to the placeholder if turned off via the widget settings',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,{widgetSettings:{showInnerShadow:true}})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(1);});it('should apply an inner shadow to the image if turned off via the widget settings',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductImage,{src:"http://placehold.it/300x300",widgetSettings:{showInnerShadow:true}})).dive();expect(wrapper).toMatchSnapshot();expect(wrapper.find(".".concat(styles.innerShadow)).length).toBe(1);});});
|
|
@@ -2,4 +2,4 @@ import React,{Fragment}from'react';import PropTypes from'prop-types';import Grid
|
|
|
2
2
|
* The Product List Item component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var Item=function Item(_ref){var display=_ref.display,product=_ref.product;return
|
|
5
|
+
*/var Item=function Item(_ref){var display=_ref.display,product=_ref.product;return/*#__PURE__*/React.createElement(Link,{tagName:"a",href:"".concat(ITEM_PATH,"/").concat(bin2hex(product.id)),className:"".concat(styles.container," engage__product__product-list__item"),itemProp:"item",itemScope:true,itemType:"http://schema.org/Product"},/*#__PURE__*/React.createElement(Grid,{className:styles.listItemContainer},/*#__PURE__*/React.createElement(Grid.Item,{shrink:0,className:styles.imageContainer},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_IMAGE_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_IMAGE,props:{productId:product.id}},/*#__PURE__*/React.createElement(Image,{itemProp:"image",src:product.featuredImageBaseUrl,alt:product.name})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_IMAGE_AFTER,props:{productId:product.id}}),/*#__PURE__*/React.createElement(ProductBadges,{location:"productList",productId:product.id},!!product.price.discount&&/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT,props:{productId:product.id}},/*#__PURE__*/React.createElement(DiscountBadge,{className:styles.discount,text:"-".concat(product.price.discount,"%")})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT_AFTER,props:{productId:product.id}})))),/*#__PURE__*/React.createElement(Grid.Item,{grow:4,className:styles.titleContainer},/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_NAME_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_NAME,props:{productId:product.id}},/*#__PURE__*/React.createElement("div",{itemProp:"name","data-test-id":"Productname: ".concat(product.name)},/*#__PURE__*/React.createElement(Ellipsis,null,product.name))),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_NAME_AFTER,props:{productId:product.id}})),(!display||display.manufacturer&&product.manufacturer)&&/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_MANUFACTURER_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_MANUFACTURER,props:{productId:product.id}},/*#__PURE__*/React.createElement(Manufacturer,{text:product.manufacturer,className:styles.manufacturer})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_MANUFACTURER_AFTER,props:{productId:product.id}})),product.availability&&/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_AVAILABILITY_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_AVAILABILITY,props:{productId:product.id}},/*#__PURE__*/React.createElement(Availability,{className:styles.availability,text:product.availability.text,state:product.availability.state})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_AVAILABILITY_AFTER,props:{productId:product.id}}))),(!display||display.price)&&/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_BEFORE,props:{productId:product.id,location:'productList'}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE,props:{productId:product.id,location:'productList'}},/*#__PURE__*/React.createElement(Grid.Item,{grow:1,className:styles.priceContainer},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_INSIDE_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Price,{className:styles.price,currency:product.price.currency,discounted:!!product.price.discount,unitPrice:product.price.unitPrice,unitPriceMin:product.price.unitPriceMin}),product.price.msrp>0&&product.price.unitPrice!==product.price.msrp&&/*#__PURE__*/React.createElement(PriceStriked,{value:product.price.msrp,currency:product.price.currency,className:styles.priceStriked}),!product.price.msrp&&product.price.unitPriceStriked>0&&/*#__PURE__*/React.createElement(PriceStriked,{value:product.price.unitPriceStriked,currency:product.price.currency,className:styles.priceStriked}),product.price.info&&/*#__PURE__*/React.createElement(PriceInfo,{text:product.price.info,className:styles.priceInfo}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_INSIDE_AFTER,props:{productId:product.id}}))),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_AFTER,props:{productId:product.id,location:'productList'}})),/*#__PURE__*/React.createElement(Grid.Item,{shrink:0,className:styles.favouriteContainer})));};Item.defaultProps={display:null};export default Item;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import List from'@sho
|
|
|
2
2
|
* The Product List Iterator component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var Iterator=function Iterator(props){return
|
|
5
|
+
*/var Iterator=function Iterator(props){return/*#__PURE__*/React.createElement(List.Item,{key:props.id,itemProp:"itemListElement",itemScope:true,itemType:"http://schema.org/ListItem",className:styles.item},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_BEFORE,props:{productId:props.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM,props:{productId:props.id}},/*#__PURE__*/React.createElement(Item,{product:props,display:props.display})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_AFTER,props:{productId:props.id}}));};Iterator.defaultProps={display:null};export default Iterator;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import List from'@sho
|
|
|
2
2
|
* The Product List Layout component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var Layout=function Layout(_ref){var children=_ref.children;return
|
|
5
|
+
*/var Layout=function Layout(_ref){var children=_ref.children;return/*#__PURE__*/React.createElement(List,{className:"".concat(styles.list," engage__product__product-list"),itemScope:true,itemType:"http://schema.org/ItemList","data-test-id":"productList"},children);};Layout.defaultProps={children:null};export default Layout;
|
|
@@ -2,4 +2,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
2
2
|
* The Product List component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var ProductList=function ProductList(_ref){var flags=_ref.flags,infiniteLoad=_ref.infiniteLoad,handleGetProducts=_ref.handleGetProducts,products=_ref.products,totalProductCount=_ref.totalProductCount,requestHash=_ref.requestHash;if(!infiniteLoad){return
|
|
5
|
+
*/var ProductList=function ProductList(_ref){var flags=_ref.flags,infiniteLoad=_ref.infiniteLoad,handleGetProducts=_ref.handleGetProducts,products=_ref.products,totalProductCount=_ref.totalProductCount,requestHash=_ref.requestHash;if(!infiniteLoad){return/*#__PURE__*/React.createElement(Layout,null,products.map(function(product){return/*#__PURE__*/React.createElement(Iterator,_extends({display:flags,id:product.id,key:product.id},product));}));}return/*#__PURE__*/React.createElement(ViewContext.Consumer,null,function(_ref2){var getContentRef=_ref2.getContentRef;return/*#__PURE__*/React.createElement(InfiniteContainer,{containerRef:getContentRef(),wrapper:Layout,iterator:Iterator,loader:handleGetProducts,items:products,loadingIndicator:/*#__PURE__*/React.createElement(LoadingIndicator,null),totalItems:totalProductCount,initialLimit:10,limit:ITEMS_PER_LOAD,requestHash:requestHash});});};ProductList.defaultProps={flags:null,handleGetProducts:function handleGetProducts(){},infiniteLoad:true,products:null,requestHash:null,totalProductCount:null};export default ProductList;
|
|
@@ -2,7 +2,7 @@ import React from'react';import PropTypes from'prop-types';import{isBeta}from"..
|
|
|
2
2
|
* @param {Object} props The component props.
|
|
3
3
|
* @returns {JSX}
|
|
4
4
|
*/var Content=function Content(_ref){var properties=_ref.properties;if(!properties){return null;}var groups=getGroupsFromProperties(properties);// Display the simple properties if no groups exist or if not in beta mode.
|
|
5
|
-
if(!isBeta()||!groups||groups.length===0){return
|
|
5
|
+
if(!isBeta()||!groups||groups.length===0){return/*#__PURE__*/React.createElement(Wrapper,null,/*#__PURE__*/React.createElement(Rows,{properties:properties}));}/*
|
|
6
6
|
This feature is currently in BETA testing.
|
|
7
7
|
It should only be used for approved BETA Client Projects
|
|
8
|
-
*/return
|
|
8
|
+
*/return/*#__PURE__*/React.createElement("div",{className:"".concat(groupsContainer," engage__product__product-properties")},/*#__PURE__*/React.createElement(GroupedProperties,{properties:properties,groups:groups}));};Content.defaultProps={properties:null};export default Content;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import{subgroup}from"
|
|
|
2
2
|
* Renders a product properties group header.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var Group=function Group(_ref){var group=_ref.group;return
|
|
5
|
+
*/var Group=function Group(_ref){var group=_ref.group;return/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",{colSpan:"2",className:subgroup},group));};export default/*#__PURE__*/React.memo(Group);
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import{Accordion}from
|
|
|
2
2
|
* Renders the properties as groups.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var GroupedProperties=function GroupedProperties(_ref){var properties=_ref.properties,groups=_ref.groups;return groups.map(function(group){return
|
|
5
|
+
*/var GroupedProperties=function GroupedProperties(_ref){var properties=_ref.properties,groups=_ref.groups;return groups.map(function(group){return/*#__PURE__*/React.createElement("div",{key:group,className:accordion},/*#__PURE__*/React.createElement(Accordion,{renderLabel:function renderLabel(){return i18n.text("product.displayGroups.".concat(group));},testId:"product-properties-group-".concat(group)},/*#__PURE__*/React.createElement(Wrapper,{dense:true},/*#__PURE__*/React.createElement(Lists,{properties:properties.filter(function(property){return property.displayGroup===group;})}))));});};export default GroupedProperties;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import{getSubgroupsFr
|
|
|
2
2
|
* Renders lists of properties that are eventually grouped.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var Lists=function Lists(_ref){var properties=_ref.properties;return
|
|
5
|
+
*/var Lists=function Lists(_ref){var properties=_ref.properties;return/*#__PURE__*/React.createElement(React.Fragment,null,/*#__PURE__*/React.createElement(Rows,{properties:getPropertiesWithoutSubgroup(properties)}),getSubgroupsFromProperties(properties).map(function(group){return/*#__PURE__*/React.createElement(React.Fragment,{key:group},/*#__PURE__*/React.createElement(Group,{group:group}),/*#__PURE__*/React.createElement(Rows,{properties:getPropertiesBySubgroup(properties,group)}));}));};export default Lists;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import{PRODUCT_PROPER
|
|
|
2
2
|
* Renders the product properties.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX.Element}
|
|
5
|
-
*/var ProductProperties=function ProductProperties(_ref){var properties=_ref.properties;return
|
|
5
|
+
*/var ProductProperties=function ProductProperties(_ref){var properties=_ref.properties;return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PRODUCT_PROPERTIES,portalProps:{properties:properties}},/*#__PURE__*/React.createElement(Content,{properties:properties}));};ProductProperties.defaultProps={properties:null};export default connect(ProductProperties);
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import{tableCell}from
|
|
|
2
2
|
* Renders a single properties row.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX.Element}
|
|
5
|
-
*/var Row=function Row(_ref){var label=_ref.label,value=_ref.value;return
|
|
5
|
+
*/var Row=function Row(_ref){var label=_ref.label,value=_ref.value;return/*#__PURE__*/React.createElement("tr",{key:"".concat(label).concat(value)},/*#__PURE__*/React.createElement("td",{className:tableCell},label),/*#__PURE__*/React.createElement("td",{className:tableCell,"data-test-id":"property: ".concat(value)},value));};export default/*#__PURE__*/React.memo(Row);
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import Row from"./Row
|
|
|
2
2
|
* Renders rows of product properties.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX.Element}
|
|
5
|
-
*/var Rows=function Rows(_ref){var properties=_ref.properties;return properties.map(function(_ref2){var value=_ref2.value,label=_ref2.label;return
|
|
5
|
+
*/var Rows=function Rows(_ref){var properties=_ref.properties;return properties.map(function(_ref2){var value=_ref2.value,label=_ref2.label;return/*#__PURE__*/React.createElement(Row,{key:"".concat(label,"-").concat(value),label:label,value:value});});};export default/*#__PURE__*/React.memo(Rows);
|
|
@@ -2,4 +2,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
2
2
|
* Renders the general properties wrapper table.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX.Element}
|
|
5
|
-
*/var Wrapper=function Wrapper(_ref){var _cxs;var children=_ref.children,dense=_ref.dense;return
|
|
5
|
+
*/var Wrapper=function Wrapper(_ref){var _cxs;var children=_ref.children,dense=_ref.dense;return/*#__PURE__*/React.createElement("div",{className:cxs('engage__product__product-properties',(_cxs={},_defineProperty(_cxs,container,!dense),_defineProperty(_cxs,containerDense,dense),_cxs))},/*#__PURE__*/React.createElement("table",null,/*#__PURE__*/React.createElement("thead",null),/*#__PURE__*/React.createElement("tbody",null,children)));};Wrapper.defaultProps={dense:false};export default/*#__PURE__*/React.memo(Wrapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import{isBeta}from"../../../../core";import Content from"../Content";jest.mock("../../../../core",function(){return{isBeta:jest.fn()};});jest.mock("../GroupedProperties",function(){return function GroupedProperties(){return'GroupedProperties';};});var properties=[{name:'test1',label:'Test 1',displayGroup:'Group 1'},{name:'test2',label:'Test 2',displayGroup:'Group 1'},{name:'test3',label:'Test 3',displayGroup:'Group 2'},{name:'test4',label:'Test 4',displayGroup:'Group 2'}];var propertiesSimple=[{name:'test1',label:'Test 1'}];describe('<Content />',function(){it('should not render if no props are passed',function(){var wrapper=shallow(React.createElement(Content,null));expect(wrapper.instance()).toEqual(null);expect(wrapper).toMatchSnapshot();});it('should render simple rows if not in beta',function(){isBeta.mockReturnValueOnce(false);var wrapper=shallow(React.createElement(Content,{properties:properties}));expect(wrapper.find('Wrapper').length).toEqual(1);expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper).toMatchSnapshot();});it('should render simple rows of no groups could be found',function(){isBeta.mockReturnValueOnce(true);var wrapper=shallow(React.createElement(Content,{properties:propertiesSimple}));expect(wrapper.find('Wrapper').length).toEqual(1);expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper).toMatchSnapshot();});it('should render grouped properties',function(){isBeta.mockReturnValueOnce(true);var wrapper=shallow(React.createElement(Content,{properties:properties}));expect(wrapper.find('GroupedProperties').length).toEqual(1);expect(wrapper.find('GroupedProperties').prop('groups')).toEqual(['Group 1','Group 2']);expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import{isBeta}from"../../../../core";import Content from"../Content";jest.mock("../../../../core",function(){return{isBeta:jest.fn()};});jest.mock("../GroupedProperties",function(){return function GroupedProperties(){return'GroupedProperties';};});var properties=[{name:'test1',label:'Test 1',displayGroup:'Group 1'},{name:'test2',label:'Test 2',displayGroup:'Group 1'},{name:'test3',label:'Test 3',displayGroup:'Group 2'},{name:'test4',label:'Test 4',displayGroup:'Group 2'}];var propertiesSimple=[{name:'test1',label:'Test 1'}];describe('<Content />',function(){it('should not render if no props are passed',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Content,null));expect(wrapper.instance()).toEqual(null);expect(wrapper).toMatchSnapshot();});it('should render simple rows if not in beta',function(){isBeta.mockReturnValueOnce(false);var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{properties:properties}));expect(wrapper.find('Wrapper').length).toEqual(1);expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper).toMatchSnapshot();});it('should render simple rows of no groups could be found',function(){isBeta.mockReturnValueOnce(true);var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{properties:propertiesSimple}));expect(wrapper.find('Wrapper').length).toEqual(1);expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper).toMatchSnapshot();});it('should render grouped properties',function(){isBeta.mockReturnValueOnce(true);var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{properties:properties}));expect(wrapper.find('GroupedProperties').length).toEqual(1);expect(wrapper.find('GroupedProperties').prop('groups')).toEqual(['Group 1','Group 2']);expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Group from"../Group";describe('<Group />',function(){it('should render a group title row',function(){var wrapper=shallow(React.createElement(Group,{group:"Test"}));expect(wrapper.find('tr').length).toEqual(1);expect(wrapper.find('td').length).toEqual(1);expect(wrapper.find('td').text()).toEqual('Test');expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Group from"../Group";describe('<Group />',function(){it('should render a group title row',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Group,{group:"Test"}));expect(wrapper.find('tr').length).toEqual(1);expect(wrapper.find('td').length).toEqual(1);expect(wrapper.find('td').text()).toEqual('Test');expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import GroupedProperties from"../GroupedProperties";var properties=[{name:'test1',label:'Test 1',displayGroup:'Group 1'},{name:'test2',label:'Test 2',displayGroup:'Group 1'},{name:'test3',label:'Test 3',displayGroup:'Group 2'},{name:'test4',label:'Test 4',displayGroup:'Group 2'}];var groups=['Group 1','Group 2'];describe('<GroupedProperties />',function(){it('should render as expected',function(){var wrapper=shallow(React.createElement(GroupedProperties,{properties:properties,groups:groups}));expect(wrapper.find('Wrapper').length).toEqual(2);expect(wrapper.find('Wrapper').at(0).prop('dense')).toEqual(true);expect(wrapper.find('Accordion').length).toEqual(2);expect(wrapper.find('Lists').length).toEqual(2);expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import GroupedProperties from"../GroupedProperties";var properties=[{name:'test1',label:'Test 1',displayGroup:'Group 1'},{name:'test2',label:'Test 2',displayGroup:'Group 1'},{name:'test3',label:'Test 3',displayGroup:'Group 2'},{name:'test4',label:'Test 4',displayGroup:'Group 2'}];var groups=['Group 1','Group 2'];describe('<GroupedProperties />',function(){it('should render as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(GroupedProperties,{properties:properties,groups:groups}));expect(wrapper.find('Wrapper').length).toEqual(2);expect(wrapper.find('Wrapper').at(0).prop('dense')).toEqual(true);expect(wrapper.find('Accordion').length).toEqual(2);expect(wrapper.find('Lists').length).toEqual(2);expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Lists from"../Lists";var propertiesNoSubs=[{name:'test1',label:'Test 1'},{name:'test2',label:'Test 2'}];var propertiesSubs=[{name:'test1',label:'Test 1',subDisplayGroup:'Test 1'},{name:'test2',label:'Test 2',subDisplayGroup:'Test 2'}];describe('<Lists />',function(){it('should only render simple rows',function(){var wrapper=shallow(React.createElement(Lists,{key:"1",properties:propertiesNoSubs}));expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper.find('Group').length).toEqual(0);expect(wrapper).toMatchSnapshot();});it('should render groups only',function(){var wrapper=shallow(React.createElement(Lists,{key:"2",properties:propertiesSubs}));expect(wrapper.find('Rows').length).toEqual(3);expect(wrapper.find('Rows').at(0).prop('properties')).toEqual([]);expect(wrapper.find('Rows').at(1).prop('properties')).toEqual([{name:'test1',label:'Test 1',subDisplayGroup:'Test 1'}]);expect(wrapper.find('Rows').at(2).prop('properties')).toEqual([{name:'test2',label:'Test 2',subDisplayGroup:'Test 2'}]);expect(wrapper.find('Group').length).toEqual(2);expect(wrapper.find('Group').at(0).prop('group')).toEqual('Test 1');expect(wrapper.find('Group').at(1).prop('group')).toEqual('Test 2');});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Lists from"../Lists";var propertiesNoSubs=[{name:'test1',label:'Test 1'},{name:'test2',label:'Test 2'}];var propertiesSubs=[{name:'test1',label:'Test 1',subDisplayGroup:'Test 1'},{name:'test2',label:'Test 2',subDisplayGroup:'Test 2'}];describe('<Lists />',function(){it('should only render simple rows',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Lists,{key:"1",properties:propertiesNoSubs}));expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper.find('Group').length).toEqual(0);expect(wrapper).toMatchSnapshot();});it('should render groups only',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Lists,{key:"2",properties:propertiesSubs}));expect(wrapper.find('Rows').length).toEqual(3);expect(wrapper.find('Rows').at(0).prop('properties')).toEqual([]);expect(wrapper.find('Rows').at(1).prop('properties')).toEqual([{name:'test1',label:'Test 1',subDisplayGroup:'Test 1'}]);expect(wrapper.find('Rows').at(2).prop('properties')).toEqual([{name:'test2',label:'Test 2',subDisplayGroup:'Test 2'}]);expect(wrapper.find('Group').length).toEqual(2);expect(wrapper.find('Group').at(0).prop('group')).toEqual('Test 1');expect(wrapper.find('Group').at(1).prop('group')).toEqual('Test 2');});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{mount}from'enzyme';import configureStore from'redux-mock-store';import mockConsole from'jest-mock-console';import ProductProperties from"../ProductProperties";import{makeGetProductProperties}from"../../../selectors/product";var mockStore=configureStore();var store=mockStore({});jest.mock("../../../selectors/product",function(){return{makeGetProductProperties:jest.fn(function(){return jest.fn();})};});var properties=[{displayGroup:'test'}];describe('<ProductProperties />',function(){var restoreConsole;beforeEach(function(){restoreConsole=mockConsole();});afterEach(function(){restoreConsole();});it('should not render if no properties where passed',function(){makeGetProductProperties.mockReturnValueOnce(function(){return null;});var wrapper=mount(React.createElement(ProductProperties,{key:"1",store:store}));expect(wrapper.find('ProductProperties').instance()).toEqual(null);expect(wrapper).toMatchSnapshot();});it('should render if properties are passed',function(){makeGetProductProperties.mockReturnValueOnce(function(){return properties;});var wrapper=mount(React.createElement(ProductProperties,{key:"2",store:store}));expect(wrapper.find('Content').length).toEqual(1);expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{mount}from'enzyme';import configureStore from'redux-mock-store';import mockConsole from'jest-mock-console';import ProductProperties from"../ProductProperties";import{makeGetProductProperties}from"../../../selectors/product";var mockStore=configureStore();var store=mockStore({});jest.mock("../../../selectors/product",function(){return{makeGetProductProperties:jest.fn(function(){return jest.fn();})};});var properties=[{displayGroup:'test'}];describe('<ProductProperties />',function(){var restoreConsole;beforeEach(function(){restoreConsole=mockConsole();});afterEach(function(){restoreConsole();});it('should not render if no properties where passed',function(){makeGetProductProperties.mockReturnValueOnce(function(){return null;});var wrapper=mount(/*#__PURE__*/React.createElement(ProductProperties,{key:"1",store:store}));expect(wrapper.find('ProductProperties').instance()).toEqual(null);expect(wrapper).toMatchSnapshot();});it('should render if properties are passed',function(){makeGetProductProperties.mockReturnValueOnce(function(){return properties;});var wrapper=mount(/*#__PURE__*/React.createElement(ProductProperties,{key:"2",store:store}));expect(wrapper.find('Content').length).toEqual(1);expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Row from"../Row";describe('<Row />',function(){it('should render as expected',function(){var wrapper=shallow(React.createElement(Row,{label:"TestLabel",value:"TestValue"}));expect(wrapper.find('td').at(0).text()).toEqual('TestLabel');expect(wrapper.find('td').at(1).text()).toEqual('TestValue');expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Row from"../Row";describe('<Row />',function(){it('should render as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Row,{label:"TestLabel",value:"TestValue"}));expect(wrapper.find('td').at(0).text()).toEqual('TestLabel');expect(wrapper.find('td').at(1).text()).toEqual('TestValue');expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Rows from"../Rows";var properties=[{label:'test1',value:'123'},{label:'test2',value:'456'},{label:'test3',value:'789'}];describe('<Rows />',function(){it('should render three rows of properties',function(){var wrapper=shallow(React.createElement(Rows,{properties:properties}));expect(wrapper.find('Row').length).toEqual(3);expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Rows from"../Rows";var properties=[{label:'test1',value:'123'},{label:'test2',value:'456'},{label:'test3',value:'789'}];describe('<Rows />',function(){it('should render three rows of properties',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Rows,{properties:properties}));expect(wrapper.find('Row').length).toEqual(3);expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
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 React,{useEffect}from'react';import PropTypes from'prop-types';import connect from"./connector";/**
|
|
2
2
|
* The ProductProvider component.
|
|
3
3
|
* @return {JSX}
|
|
4
|
-
*/var ProductProvider=function ProductProvider(_ref){var children=_ref.children,productId=_ref.productId,provideProduct=_ref.provideProduct,product=_ref.product;useEffect(function(){if(!product){provideProduct(productId);}},[provideProduct,product,productId]);var props={productId:productId,product:product};if(typeof children==='function'){return children(props);}return
|
|
4
|
+
*/var ProductProvider=function ProductProvider(_ref){var children=_ref.children,productId=_ref.productId,provideProduct=_ref.provideProduct,product=_ref.product;useEffect(function(){if(!product){provideProduct(productId);}},[provideProduct,product,productId]);var props={productId:productId,product:product};if(typeof children==='function'){return children(props);}return/*#__PURE__*/React.cloneElement(children,_extends({},props,children.props));};ProductProvider.defaultProps={product:null};export default connect(ProductProvider);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from'react';import PropTypes from'prop-types';import{useWidgetSettings}from'@shopgate/engage/core';import{Swiper}from'@shopgate/engage/components';import{Theme}from'@shopgate/pwa-common/context';import{container,items}from"./style";export var WIDGET_ID='@shopgate/engage/product/ProductSlider';/**
|
|
2
2
|
* @param {Object} props The component props.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/function ProductSlider(props){var autoplay=props.autoplay,className=props.className,delay=props.delay,productIds=props.productIds,snap=props.snap;var widgetSettings=useWidgetSettings(WIDGET_ID)||{};var _ref=props.slidesPerView?props:widgetSettings,_ref$slidesPerView=_ref.slidesPerView,slidesPerView=_ref$slidesPerView===void 0?2.3:_ref$slidesPerView;return
|
|
4
|
+
*/function ProductSlider(props){var autoplay=props.autoplay,className=props.className,delay=props.delay,productIds=props.productIds,snap=props.snap;var widgetSettings=useWidgetSettings(WIDGET_ID)||{};var _ref=props.slidesPerView?props:widgetSettings,_ref$slidesPerView=_ref.slidesPerView,slidesPerView=_ref$slidesPerView===void 0?2.3:_ref$slidesPerView;return/*#__PURE__*/React.createElement(Theme,null,function(_ref2){var ProductCard=_ref2.ProductCard;var Item=props.item||ProductCard;return/*#__PURE__*/React.createElement(Swiper,{autoPlay:autoplay,className:"".concat(className," engage__product__product-slider"),controls:false,indicators:false,interval:delay,loop:false,freeMode:!snap,slidesPerView:slidesPerView},productIds.map(function(id){return/*#__PURE__*/React.createElement(Swiper.Item,{key:id,className:container},/*#__PURE__*/React.createElement(Item,{productId:id,style:items}));}));});}ProductSlider.defaultProps={autoplay:false,className:null,delay:10,item:null,slidesPerView:null,snap:false};export default ProductSlider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* eslint-disable require-jsdoc */import React from'react';import{shallow}from'enzyme';import ProductSlider from"./index";jest.mock('@shopgate/engage/core',function(){return{useWidgetSettings:jest.fn()};});jest.mock('@shopgate/engage/components',function(){var Swiper=function Swiper(_ref){var children=_ref.children;return children;};Swiper.Item=function(_ref2){var children=_ref2.children;return children;};Swiper.Item.displayName='Swiper.Item';return{Swiper:Swiper};});jest.mock('@shopgate/pwa-common/context',function(){var ProductCard=function ProductCard(props){return
|
|
1
|
+
/* eslint-disable require-jsdoc */import React from'react';import{shallow}from'enzyme';import ProductSlider from"./index";jest.mock('@shopgate/engage/core',function(){return{useWidgetSettings:jest.fn()};});jest.mock('@shopgate/engage/components',function(){var Swiper=function Swiper(_ref){var children=_ref.children;return children;};Swiper.Item=function(_ref2){var children=_ref2.children;return children;};Swiper.Item.displayName='Swiper.Item';return{Swiper:Swiper};});jest.mock('@shopgate/pwa-common/context',function(){var ProductCard=function ProductCard(props){return/*#__PURE__*/React.createElement(ProductCard,props);};return{Theme:function Theme(_ref3){var children=_ref3.children;return children({ProductCard:ProductCard});}};});describe('<ProductSlider />',function(){it('should match snapshot',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductSlider,{productIds:['prod1']})).dive();expect(wrapper).toMatchSnapshot();});});/* eslint-enable require-jsdoc */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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;}import React,{useState,useEffect}from'react';import PropTypes from'prop-types';import{css}from'glamor';import{useWidgetStyles}from"../../../core";import{I18n,SheetDrawer,SheetList}from"../../../components";import{getQuantityRange}from"./helpers";/**
|
|
2
2
|
* The QuantityPicker component.
|
|
3
3
|
* @returns {JSX}
|
|
4
4
|
*/var QuantityPicker=function QuantityPicker(_ref){var conditioner=_ref.conditioner,setQuantity=_ref.setQuantity,stock=_ref.stock;if(!stock){return null;}var _useState=useState(false),_useState2=_slicedToArray(_useState,2),opened=_useState2[0],setOpened=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),resolveValue=_useState4[0],setResolveValue=_useState4[1];var _useState5=useState(null),_useState6=_slicedToArray(_useState5,2),promiseResolve=_useState6[0],setPromiseResolve=_useState6[1];/**
|
|
@@ -15,4 +15,4 @@ setPromiseResolve(function(){return resolve;});// Open sheet
|
|
|
15
15
|
setOpened(true);});};// Mount effect
|
|
16
16
|
useEffect(function(){// Add most late conditioner
|
|
17
17
|
conditioner.addConditioner('product-quantity',checkQuantity,100);},[conditioner]);// Update resolveValue effect
|
|
18
|
-
useEffect(function(){if(resolveValue===null){return;}if(promiseResolve){promiseResolve(resolveValue);}setResolveValue(null);},[promiseResolve,resolveValue]);var _getQuantityRange=getQuantityRange(stock),min=_getQuantityRange.min,max=_getQuantityRange.max;var items=Array(max-min+1).fill(min).map(function(v,index){return String(v+index);});var styles=useWidgetStyles('@shopgate/engage/product/QuantityPicker');return
|
|
18
|
+
useEffect(function(){if(resolveValue===null){return;}if(promiseResolve){promiseResolve(resolveValue);}setResolveValue(null);},[promiseResolve,resolveValue]);var _getQuantityRange=getQuantityRange(stock),min=_getQuantityRange.min,max=_getQuantityRange.max;var items=Array(max-min+1).fill(min).map(function(v,index){return String(v+index);});var styles=useWidgetStyles('@shopgate/engage/product/QuantityPicker');return/*#__PURE__*/React.createElement(SheetDrawer,{title:/*#__PURE__*/React.createElement(I18n.Text,{string:"product.quantity"}),isOpen:opened,onClose:handleCloseSheet,contentClassName:css(styles.sheet).toString()},/*#__PURE__*/React.createElement(SheetList,null,items.map(function(item){return/*#__PURE__*/React.createElement(SheetList.Item,{title:item,key:item,onClick:function onClick(){return handleSelectQuantity(parseInt(item,10));}});})));};QuantityPicker.defaultProps={stock:null};export default QuantityPicker;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import React,{Fragment,memo}from'react';import PropTypes from'prop-types';import Portal from'@shopgate/pwa-common/components/Portal';import{PRODUCT_RATING,PRODUCT_RATING_AFTER,PRODUCT_RATING_BEFORE}from'@shopgate/pwa-common-commerce/product/constants/Portals';import appConfig from'@shopgate/pwa-common/helpers/config';import RatingStars from'@shopgate/pwa-ui-shared/RatingStars';import RatingCount from'@shopgate/engage/reviews/components/Reviews/components/RatingCount';import{container}from"./style";import connect from"./connector";/**
|
|
2
2
|
* Scrolls page to reviews excerpt.
|
|
3
3
|
*/var scrollToRating=function scrollToRating(){var reviewsExcerpt=document.getElementById('reviewsExcerpt');if(_typeof(reviewsExcerpt)!=='object'||!reviewsExcerpt||!reviewsExcerpt.offsetTop||!reviewsExcerpt.closest||!reviewsExcerpt.closest('article')){return;}reviewsExcerpt.closest('article').scroll(0,reviewsExcerpt.offsetTop-30);};/**
|
|
4
4
|
* The Rating component.
|
|
5
5
|
* @param {Object} props The component props.
|
|
6
6
|
* @return {JSX}
|
|
7
|
-
*/var Rating=function Rating(_ref){var rating=_ref.rating;
|
|
7
|
+
*/var Rating=function Rating(_ref){var rating=_ref.rating;return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_RATING_BEFORE}),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_RATING},appConfig.hasReviews&&rating&&rating.count&&/*#__PURE__*/React.createElement("div",{className:"".concat(container," engage__product__rating"),onClick:scrollToRating,role:"link","aria-hidden":true},/*#__PURE__*/React.createElement(RatingStars,{value:rating.average,display:"big"}),/*#__PURE__*/React.createElement(RatingCount,{count:rating.count,prominent:true}))),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_RATING_AFTER}));};Rating.defaultProps={rating:null};export default connect(/*#__PURE__*/memo(Rating));
|
|
@@ -2,4 +2,4 @@ import React from'react';import{Provider}from'react-redux';import configureStore
|
|
|
2
2
|
* Makes component.
|
|
3
3
|
* @param {Object} state State
|
|
4
4
|
* @returns {Object}
|
|
5
|
-
*/var getComponent=function getComponent(state){return mount(React.createElement(Provider,{store:mockedStore(state)}
|
|
5
|
+
*/var getComponent=function getComponent(state){return mount(/*#__PURE__*/React.createElement(Provider,{store:mockedStore(state)},/*#__PURE__*/React.createElement(Rating,{productId:"foo"})),mockRenderOptions);};describe('Rendering',function(){it('should render rating when data is available',function(){var component=getComponent(mockedStateWithTwoReviews);expect(component).toMatchSnapshot();});it('should render nothing when data is not available',function(){var component=getComponent(mockedStateWithoutReview);expect(component.html()).toBe('');});});describe('Scroll on click',function(){var scrollSpy=jest.fn();it('should scroll to reviews when clicked',function(){jest.spyOn(document,'getElementById').mockImplementation(getElementById(scrollSpy));var component=getComponent(mockedStateWithTwoReviews);component.simulate('click');expect(scrollSpy.mock.calls[0][0]).toBe(0);expect(scrollSpy.mock.calls[0][1]).toBe(70);expect(scrollSpy).toHaveBeenCalled();document.getElementById.mockReset();document.getElementById.mockRestore();});it('should do nothing when clicked but no reviews excerpt element',function(){jest.spyOn(document,'getElementById').mockImplementation(function(){return null;});var component=getComponent(mockedStateWithTwoReviews);component.simulate('click');expect(scrollSpy.mock.calls.length).toBe(1);document.getElementById.mockReset();document.getElementById.mockRestore();});});});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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;}import React,{useState,useCallback,Fragment,memo}from'react';import PropTypes from'prop-types';import{useWidgetSettings,useTheme}from"../../../core";import{SheetDrawer,I18n,Button}from"../../../components";import{WIDGET_ID}from"./constants";import{showMore,sheet}from"./style";import connect from"./RelationsSheet.connector";/**
|
|
2
2
|
* Shows a Sheet Drawer with all related products.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var RelationsSheet
|
|
4
|
+
*/var RelationsSheet=/*#__PURE__*/memo(function(_ref){var products=_ref.products.products;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),show=_useState2[0],setShow=_useState2[1];var _useWidgetSettings=useWidgetSettings(WIDGET_ID),headline=_useWidgetSettings.headline;var _useTheme=useTheme(),ProductGrid=_useTheme.ProductGrid;var handleOpen=useCallback(function(event){event.preventDefault();setShow(true);},[]);var handleClose=useCallback(function(){setShow(false);},[]);return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Button,{onClick:handleOpen,flat:true,className:showMore},/*#__PURE__*/React.createElement(I18n.Text,{string:"product.relations.showMore"})),/*#__PURE__*/React.createElement(SheetDrawer,{isOpen:show,title:headline,onClose:handleClose},/*#__PURE__*/React.createElement("div",{className:sheet},/*#__PURE__*/React.createElement(ProductGrid,{products:products,infiniteLoad:false}))));});RelationsSheet.defaultProps={products:{products:[],productCount:0}};export default connect(RelationsSheet);
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import{useWidgetSetti
|
|
|
2
2
|
* Renders the relations slider in the desired position on the Product Detail Page.
|
|
3
3
|
* @param {string} desiredPosition The position the relations slider needs to render.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var RelationsSlider=function RelationsSlider(_ref){var desiredPosition=_ref.desiredPosition;var _useWidgetSettings=useWidgetSettings(WIDGET_ID),type=_useWidgetSettings.type,position=_useWidgetSettings.position;var _useCurrentProduct=useCurrentProduct(),productId=_useCurrentProduct.productId;if(!type||position!==desiredPosition){return null;}return
|
|
5
|
+
*/var RelationsSlider=function RelationsSlider(_ref){var desiredPosition=_ref.desiredPosition;var _useWidgetSettings=useWidgetSettings(WIDGET_ID),type=_useWidgetSettings.type,position=_useWidgetSettings.position;var _useCurrentProduct=useCurrentProduct(),productId=_useCurrentProduct.productId;if(!type||position!==desiredPosition){return null;}return/*#__PURE__*/React.createElement(RelationsSliderContent,{productId:productId,type:type,max:10,limit:100});};RelationsSlider.defaultProps={desiredPosition:'header'};export default RelationsSlider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React,{useEffect,memo}from'react';import PropTypes from'prop-types';import{Swiper,Card}from'@shopgate/engage/components';import ProductCard from"../ProductCard";import RelationsSheet from"./RelationsSheet";import{useWidgetSettings,useCurrentProduct}from"../../../core";import connect from"./RelationsSlider.connector";import{WIDGET_ID}from"./constants";import*as styles from"./style";/**
|
|
2
2
|
* @param {Object} props The component props.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var RelationsSliderContent
|
|
4
|
+
*/var RelationsSliderContent=/*#__PURE__*/memo(function(_ref){var _ref$products=_ref.products,products=_ref$products.products,productsCount=_ref$products.productsCount,getRelations=_ref.getRelations;var _useWidgetSettings=useWidgetSettings(WIDGET_ID),headline=_useWidgetSettings.headline,hidePrice=_useWidgetSettings.hidePrice,hideRating=_useWidgetSettings.hideRating,titleRows=_useWidgetSettings.titleRows,showMoreButton=_useWidgetSettings.showMoreButton,type=_useWidgetSettings.type,_useWidgetSettings$sl=_useWidgetSettings.slidesPerView,slidesPerView=_useWidgetSettings$sl===void 0?2.3:_useWidgetSettings$sl;var _useCurrentProduct=useCurrentProduct(),productId=_useCurrentProduct.productId;useEffect(function(){getRelations();},[getRelations]);if(products.length===0){return null;}return/*#__PURE__*/React.createElement("div",{className:styles.container},!!headline&&/*#__PURE__*/React.createElement("h3",{className:styles.headline},headline),!!showMoreButton&&productsCount>10&&/*#__PURE__*/React.createElement(RelationsSheet,{limit:100,productId:productId,type:type}),/*#__PURE__*/React.createElement(Swiper,{slidesPerView:slidesPerView,classNames:{container:styles.sliderContainer}},products.map(function(product){return/*#__PURE__*/React.createElement(Swiper.Item,{key:product.id},/*#__PURE__*/React.createElement(Card,{className:styles.card},/*#__PURE__*/React.createElement(ProductCard,{product:product,hidePrice:hidePrice,hideName:false,hideRating:hideRating,titleRows:titleRows})));})));});RelationsSliderContent.defaultProps={products:{products:[],productsCount:0}};export default connect(RelationsSliderContent);
|
|
@@ -2,4 +2,4 @@ import React,{memo}from'react';import PropTypes from'prop-types';import{css}from
|
|
|
2
2
|
* The swatch component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var Swatch=function Swatch(_ref){var swatch=_ref.swatch;if(!swatch){return null;}var styles=useWidgetStyles(WIDGET_ID);var classNames={swatch:styles&&styles.swatch?css(styles.swatch).toString():null,item:styles&&styles.item?css(styles.item).toString():null,itemSelected:styles&&styles.itemSelected?css(styles.itemSelected).toString():null};return
|
|
5
|
+
*/var Swatch=function Swatch(_ref){var swatch=_ref.swatch;if(!swatch){return null;}var styles=useWidgetStyles(WIDGET_ID);var classNames={swatch:styles&&styles.swatch?css(styles.swatch).toString():null,item:styles&&styles.item?css(styles.item).toString():null,itemSelected:styles&&styles.itemSelected?css(styles.itemSelected).toString():null};return/*#__PURE__*/React.createElement(SwatchContent,{swatch:swatch,classNames:classNames});};Swatch.defaultProps={swatch:null};export default/*#__PURE__*/memo(Swatch);
|
|
@@ -2,4 +2,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
2
2
|
* The swatch content component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var SwatchContent=function SwatchContent(_ref){var swatch=_ref.swatch,classNames=_ref.classNames,_onClick=_ref.onClick;if(!swatch){return null;}return
|
|
5
|
+
*/var SwatchContent=function SwatchContent(_ref){var swatch=_ref.swatch,classNames=_ref.classNames,_onClick=_ref.onClick;if(!swatch){return null;}return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PRODUCT_SWATCH,portalProps:{swatch:swatch}},/*#__PURE__*/React.createElement("ul",{className:cls(swatchClass,_defineProperty({},classNames.swatch,!!classNames.swatch))},swatch.values.map(function(value){var _cls2;return/*#__PURE__*/React.createElement("li",{"aria-hidden":true,key:value.id,onClick:function onClick(){return _onClick(value.id);},className:cls(itemClass,(_cls2={},_defineProperty(_cls2,classNames.item,!!classNames.item),_defineProperty(_cls2,itemSelectedClass,!!value.selected),_defineProperty(_cls2,classNames.itemSelected,!!value.selected),_cls2)),style:_extends({},value.swatch.color&&{backgroundColor:value.swatch.color},value.swatch.imageUrl&&{backgroundImage:"url(".concat(value.swatch.imageUrl,")")})});})));};SwatchContent.defaultProps={classNames:{},swatch:null,onClick:noop};export default/*#__PURE__*/memo(SwatchContent);
|
|
@@ -2,4 +2,4 @@ import React,{memo}from'react';import PropTypes from'prop-types';import noop fro
|
|
|
2
2
|
* The variant swatch component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var VariantSwatch=function VariantSwatch(_ref){var swatch=_ref.swatch,onClick=_ref.onClick;if(!swatch){return null;}var styles=useWidgetStyles(WIDGET_ID);var classNames={swatch:styles&&styles.swatch?css(styles.swatch).toString():null,item:styles&&styles.item?css(styles.item).toString():null,itemSelected:styles&&styles.itemSelected?css(styles.itemSelected).toString():null};return
|
|
5
|
+
*/var VariantSwatch=function VariantSwatch(_ref){var swatch=_ref.swatch,onClick=_ref.onClick;if(!swatch){return null;}var styles=useWidgetStyles(WIDGET_ID);var classNames={swatch:styles&&styles.swatch?css(styles.swatch).toString():null,item:styles&&styles.item?css(styles.item).toString():null,itemSelected:styles&&styles.itemSelected?css(styles.itemSelected).toString():null};return/*#__PURE__*/React.createElement(SwatchContent,{swatch:swatch,classNames:classNames,onClick:onClick});};VariantSwatch.defaultProps={swatch:null,onClick:noop};export default/*#__PURE__*/memo(VariantSwatch);
|
|
@@ -2,4 +2,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
2
2
|
* Renders only product swatches from a list of characteristics.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var Swatches=function Swatches(_ref){var productId=_ref.productId,characteristics=_ref.characteristics;if(!isBeta()){return null;}if(!characteristics){return null;}var settings=useWidgetSettings(WIDGET_ID);var swatches=characteristics.filter(function(c){return c.swatch===true;});if(settings.filter&&settings.filter.length){swatches=swatches.filter(function(swatch){return settings.filter.includes(swatch.id);});}if(!swatches){return null;}if(settings.maxItemCount){swatches=swatches.map(function(swatch){return _extends({},swatch,{values:swatch.values.slice(0,settings.maxItemCount)});});}return
|
|
5
|
+
*/var Swatches=function Swatches(_ref){var productId=_ref.productId,characteristics=_ref.characteristics;if(!isBeta()){return null;}if(!characteristics){return null;}var settings=useWidgetSettings(WIDGET_ID);var swatches=characteristics.filter(function(c){return c.swatch===true;});if(settings.filter&&settings.filter.length){swatches=swatches.filter(function(swatch){return settings.filter.includes(swatch.id);});}if(!swatches){return null;}if(settings.maxItemCount){swatches=swatches.map(function(swatch){return _extends({},swatch,{values:swatch.values.slice(0,settings.maxItemCount)});});}return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PRODUCT_SWATCHES,portalProps:{characteristics:characteristics}},/*#__PURE__*/React.createElement("div",{className:swatchesClass},swatches.map(function(swatch){return/*#__PURE__*/React.createElement(Swatch,{key:"".concat(productId,".").concat(swatch.id),swatch:swatch});})));};Swatches.defaultProps={characteristics:null};export default connect(/*#__PURE__*/memo(Swatches));
|
|
@@ -6,4 +6,4 @@ import React,{useContext,useEffect,useMemo}from'react';import PropTypes from'pro
|
|
|
6
6
|
* Validates an value based on minValue & maxValue and corrects it if necessary
|
|
7
7
|
* @param {number} val The value to be tested / adjusted
|
|
8
8
|
* @returns {number}
|
|
9
|
-
*/var validateQuantity=function validateQuantity(val){if(minValue&&val<minValue)return minValue;if(maxValue&&val>maxValue)return maxValue;return val;};useEffect(function(){var validatedQuantity=validateQuantity(quantity);if(validatedQuantity!==quantity){setQuantity(validatedQuantity);}},[quantity,minValue,maxValue,validateQuantity,setQuantity]);if(!product){return null;}var unit=product.unit,hasCatchWeight=product.hasCatchWeight;var hasUnitWithDecimals=unit&&hasCatchWeight||false;return
|
|
9
|
+
*/var validateQuantity=function validateQuantity(val){if(minValue&&val<minValue)return minValue;if(maxValue&&val>maxValue)return maxValue;return val;};useEffect(function(){var validatedQuantity=validateQuantity(quantity);if(validatedQuantity!==quantity){setQuantity(validatedQuantity);}},[quantity,minValue,maxValue,validateQuantity,setQuantity]);if(!product){return null;}var unit=product.unit,hasCatchWeight=product.hasCatchWeight;var hasUnitWithDecimals=unit&&hasCatchWeight||false;return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PRODUCT_UNIT_QUANTITY_PICKER},/*#__PURE__*/React.createElement("div",{className:classNames(styles.root,className)},/*#__PURE__*/React.createElement("div",{className:styles.qtyWrapper},/*#__PURE__*/React.createElement(UnitQuantityPicker,{className:styles.qtyContainer,unit:hasUnitWithDecimals?unit:null,maxDecimals:hasUnitWithDecimals?2:0,incrementStep:hasUnitWithDecimals?0.25:1,decrementStep:hasUnitWithDecimals?0.25:1,onChange:setQuantity,value:quantity,disabled:disabled,minValue:minValue,maxValue:maxValue})),children&&/*#__PURE__*/React.createElement("div",null,children)));};ProductUnitQuantityPicker.defaultProps={disabled:false,product:null,stockInfo:null,children:null,className:null};export default withCurrentProduct(connect(ProductUnitQuantityPicker));
|
|
@@ -6,7 +6,7 @@ var defaultDimension=36;var styles={root:css({display:'flex',flexDirection:'row'
|
|
|
6
6
|
fontSize:"".concat(Math.floor(defaultDimension/28*100),"%"),height:defaultDimension,lineHeight:"".concat(defaultDimension-1,"px")}).toString(),buttonNoRadiusLeft:css({' &&':{borderTopLeftRadius:0,borderBottomLeftRadius:0}}).toString(),buttonNoRadiusRight:css({' &&':{borderTopRightRadius:0,borderBottomRightRadius:0}}).toString(),disabled:css({' > div':{padding:0}}).toString(),quantityLabelWrapper:function quantityLabelWrapper(bgColor){return css({display:'flex',alignItems:'center',backgroundColor:bgColor,width:'100%',lineHeight:defaultDimension,height:defaultDimension}).toString();},quantityLabel:function quantityLabel(color){return css({fontSize:'16px',textAlign:'center',padding:'0',flex:1,marginRight:'8px',marginLeft:'-8px',color:color}).toString();}};/**
|
|
7
7
|
* A Quantity Picker with unit support.
|
|
8
8
|
* @returns {JSX}
|
|
9
|
-
*/var UnitQuantityPicker=function UnitQuantityPicker(_ref){var className=_ref.className,onChange=_ref.onChange,value=_ref.value,allowDecrement=_ref.allowDecrement,allowIncrement=_ref.allowIncrement,allowZero=_ref.allowZero,decrementStep=_ref.decrementStep,incrementStep=_ref.incrementStep,maxDecimals=_ref.maxDecimals,unit=_ref.unit,disabled=_ref.disabled,minValue=_ref.minValue,maxValue=_ref.maxValue,productProperty=_ref.productProperty;var _ref2=useWidgetSettings('@shopgate/engage/product/components/UnitQuantityPicker')||{},_ref2$buttonColor=_ref2.buttonColor,buttonColor=_ref2$buttonColor===void 0?colors.shade8:_ref2$buttonColor,_ref2$buttonBgColor=_ref2.buttonBgColor,buttonBgColor=_ref2$buttonBgColor===void 0?colors.primary:_ref2$buttonBgColor,_ref2$inputColor=_ref2.inputColor,inputColor=_ref2$inputColor===void 0?colors.dark:_ref2$inputColor,_ref2$inputBgColor=_ref2.inputBgColor,inputBgColor=_ref2$inputBgColor===void 0?colors.shade8:_ref2$inputBgColor,_ref2$showLabel=_ref2.showLabel,showLabel=_ref2$showLabel===void 0?true:_ref2$showLabel;var label
|
|
9
|
+
*/var UnitQuantityPicker=function UnitQuantityPicker(_ref){var className=_ref.className,onChange=_ref.onChange,value=_ref.value,allowDecrement=_ref.allowDecrement,allowIncrement=_ref.allowIncrement,allowZero=_ref.allowZero,decrementStep=_ref.decrementStep,incrementStep=_ref.incrementStep,maxDecimals=_ref.maxDecimals,unit=_ref.unit,disabled=_ref.disabled,minValue=_ref.minValue,maxValue=_ref.maxValue,productProperty=_ref.productProperty;var _ref2=useWidgetSettings('@shopgate/engage/product/components/UnitQuantityPicker')||{},_ref2$buttonColor=_ref2.buttonColor,buttonColor=_ref2$buttonColor===void 0?colors.shade8:_ref2$buttonColor,_ref2$buttonBgColor=_ref2.buttonBgColor,buttonBgColor=_ref2$buttonBgColor===void 0?colors.primary:_ref2$buttonBgColor,_ref2$inputColor=_ref2.inputColor,inputColor=_ref2$inputColor===void 0?colors.dark:_ref2$inputColor,_ref2$inputBgColor=_ref2.inputBgColor,inputBgColor=_ref2$inputBgColor===void 0?colors.shade8:_ref2$inputBgColor,_ref2$showLabel=_ref2.showLabel,showLabel=_ref2$showLabel===void 0?true:_ref2$showLabel;var label=/*#__PURE__*/React.createElement(I18n.Text,{string:"product.sections.quantity"});if(productProperty&&productProperty.value&&productProperty.value!==''){label=productProperty.value;}var handleDecrement=useCallback(function(){var newValue=value-decrementStep;if(newValue<=0&&!allowZero||minValue&&newValue<minValue){newValue=value;}onChange(newValue);},[allowZero,decrementStep,minValue,onChange,value]);var handleIncrement=useCallback(function(){var newValue=value+incrementStep;if(maxValue&&newValue>maxValue){newValue=value;}onChange(newValue);},[incrementStep,maxValue,onChange,value]);useEffect(function(){if(minValue&&value<minValue){onChange(minValue);}if(maxValue&&value>maxValue){onChange(maxValue);}/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */return/*#__PURE__*/React.createElement("div",{className:"".concat(styles.root," ").concat(className)},/*#__PURE__*/React.createElement(RippleButton,{rippleClassName:styles.buttonRipple,className:classNames(styles.button(buttonColor,buttonBgColor),styles.buttonNoRadiusRight,_defineProperty({},styles.disabled,disabled)),type:"secondary",disabled:!allowDecrement||disabled,onClick:handleDecrement,rippleSize:defaultDimension},"-"),/*#__PURE__*/React.createElement("div",{className:styles.quantityLabelWrapper(inputBgColor)},showLabel&&/*#__PURE__*/React.createElement("div",{"aria-hidden":true,className:styles.quantityLabel(inputColor)},label),/*#__PURE__*/React.createElement(QuantityInput,{className:styles.input(inputColor,inputBgColor,showLabel),value:value,onChange:onChange,maxDecimals:maxDecimals,unit:unit,disabled:disabled,minValue:minValue,maxValue:maxValue})),/*#__PURE__*/React.createElement(RippleButton,{type:"secondary",disabled:!allowIncrement||disabled,rippleClassName:styles.buttonRipple,className:classNames(styles.button(buttonColor,buttonBgColor),styles.buttonNoRadiusLeft,_defineProperty({},styles.disabled,disabled)),onClick:handleIncrement},"+"));};UnitQuantityPicker.defaultProps={className:'',allowZero:false,allowIncrement:true,allowDecrement:true,incrementStep:0.25,decrementStep:0.25,maxDecimals:2,unit:null,disabled:false,minValue:null,maxValue:null,productProperty:null};/**
|
|
10
10
|
* maps the state to props
|
|
11
11
|
* @param {Object} state state object
|
|
12
12
|
* @param {Object} props property object
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from'react';import{css}from'glamor';import PropTypes from'prop-types';import{themeConfig}from'@shopgate/engage';import{useWidgetSettings}from"../../../core";import{ProductUnitQuantityPicker}from"./index";import{OrderQuantityHint}from"../../index";import{Section}from"../../../a11y";var variables=themeConfig.variables;var styles={quantityPicker:css({display:'flex',flexDirection:'column',alignItems:'flex-start',padding:variables.gap.big}).toString(),quantityHint:css({marginBottom:-4,paddingLeft:16}).toString()};/**
|
|
2
2
|
* A Quantity Picker with unit support.
|
|
3
3
|
* @returns {JSX.Element}
|
|
4
|
-
*/var UnitQuantityPickerWithSection=function UnitQuantityPickerWithSection(_ref){var productId=_ref.productId,variantId=_ref.variantId;var _ref2=useWidgetSettings('@shopgate/engage/product/components/UnitQuantityPicker')||{},_ref2$show=_ref2.show,show=_ref2$show===void 0?false:_ref2$show;if(!show){return null;}return
|
|
4
|
+
*/var UnitQuantityPickerWithSection=function UnitQuantityPickerWithSection(_ref){var productId=_ref.productId,variantId=_ref.variantId;var _ref2=useWidgetSettings('@shopgate/engage/product/components/UnitQuantityPicker')||{},_ref2$show=_ref2.show,show=_ref2$show===void 0?false:_ref2$show;if(!show){return null;}return/*#__PURE__*/React.createElement(Section,{title:"product.sections.quantity"},/*#__PURE__*/React.createElement(ProductUnitQuantityPicker,{className:styles.quantityPicker},/*#__PURE__*/React.createElement(OrderQuantityHint,{productId:variantId||productId,className:styles.quantityHint})));};UnitQuantityPickerWithSection.defaultProps={productId:null,variantId:null};export default UnitQuantityPickerWithSection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{Conditioner}from'@shopgate/pwa-core';export var defaultContext={productId:null,variantId:null,options:{},characteristics:{},setCharacteristic:jest.fn(),conditioner:new Conditioner()};var context;export var ProductContext={Provider:function Provider(props){/* eslint-disable react/prop-types */context=props.value||defaultContext;return
|
|
1
|
+
import React from'react';import{Conditioner}from'@shopgate/pwa-core';export var defaultContext={productId:null,variantId:null,options:{},characteristics:{},setCharacteristic:jest.fn(),conditioner:new Conditioner()};var context;export var ProductContext={Provider:function Provider(props){/* eslint-disable react/prop-types */context=props.value||defaultContext;return/*#__PURE__*/React.createElement('div',null,props.children);/* eslint-enable react/prop-types */},Consumer:function Consumer(props){return props.children(context||defaultContext);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';export var ProductContext
|
|
1
|
+
import React from'react';export var ProductContext=/*#__PURE__*/React.createContext();
|