@shopgate/engage 7.12.3 → 7.20.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/components/Section/index.js +2 -2
- package/a11y/components/VisuallyHidden/index.js +8 -0
- package/a11y/components/index.js +1 -0
- package/a11y/constants/index.js +1 -0
- package/a11y/helpers/index.js +1 -0
- package/a11y/index.js +1 -4
- package/account/actions/addContacts.js +1 -1
- package/account/actions/deleteContact.js +1 -1
- package/account/actions/deleteCustomer.js +1 -1
- package/account/actions/fetchContacts.js +1 -1
- package/account/actions/fetchCustomer.js +1 -1
- package/account/actions/updateContact.js +1 -1
- package/account/actions/updateCustomer.js +1 -1
- package/account/components/Account/Account.style.js +1 -1
- package/account/components/Profile/Profile.provider.js +3 -3
- package/account/components/ProfileContact/ProfileContact.js +1 -1
- package/app-rating/action-creators/appStart.js +3 -3
- package/app-rating/action-creators/ordersPlaced.js +3 -3
- package/app-rating/action-creators/popup.js +4 -4
- package/app-rating/action-creators/timer.js +3 -3
- package/app-rating/actions/showModal.js +6 -6
- package/app-rating/constants/index.js +2 -2
- package/app-rating/reducers/index.js +2 -2
- package/app-rating/subscriptions/index.js +4 -4
- package/back-in-stock/actions/index.js +14 -0
- package/back-in-stock/components/BackInStockButton/connector.js +1 -0
- package/back-in-stock/components/BackInStockButton/index.js +14 -0
- package/back-in-stock/components/BackInStockButton/style.js +1 -0
- package/back-in-stock/components/CharacteristicsButton/connector.js +3 -0
- package/back-in-stock/components/CharacteristicsButton/index.js +8 -0
- package/back-in-stock/components/ProductInfoBackInStockButton/connector.js +3 -0
- package/back-in-stock/components/ProductInfoBackInStockButton/index.js +10 -0
- package/back-in-stock/components/Subscriptions/components/List/index.js +4 -0
- package/back-in-stock/components/Subscriptions/components/Subscription/index.js +7 -0
- package/back-in-stock/components/Subscriptions/index.js +4 -0
- package/back-in-stock/components/index.js +1 -0
- package/back-in-stock/constants/Actions.js +1 -0
- package/back-in-stock/constants/Common.js +1 -0
- package/back-in-stock/constants/Pipelines.js +1 -0
- package/back-in-stock/constants/Portals.js +9 -0
- package/back-in-stock/constants/index.js +1 -0
- package/back-in-stock/hooks/index.js +4 -0
- package/back-in-stock/providers/BackInStockSubscriptionsProvider.connector.js +7 -0
- package/back-in-stock/providers/BackInStockSubscriptionsProvider.context.js +1 -0
- package/back-in-stock/providers/BackInStockSubscriptionsProvider.js +5 -0
- package/back-in-stock/providers/index.js +1 -0
- package/back-in-stock/reducers/index.js +5 -0
- package/back-in-stock/selectors/index.js +43 -0
- package/back-in-stock/streams/index.js +1 -0
- package/back-in-stock/subscriptions/index.js +11 -0
- package/cart/cart.helpers.js +2 -2
- package/cart/components/CartItem/CartItemCoupon.js +10 -6
- package/cart/components/CartItem/CartItemCouponCode.js +2 -2
- package/cart/components/CartItem/CartItemCouponDelete.js +1 -1
- package/cart/components/CartItem/CartItemCouponFreeShipping.js +1 -1
- package/cart/components/CartItem/CartItemCouponIcon.js +2 -2
- package/cart/components/CartItem/CartItemCouponLayout.style.js +5 -1
- package/cart/components/CartItem/CartItemCouponTitle.js +2 -2
- package/cart/components/CartItem/CartItemProductLayout.js +3 -2
- package/cart/components/CartItem/CartItemProductLayoutWide.style.js +1 -1
- package/cart/components/CartItem/CartItemProductTitle.js +2 -2
- package/cart/components/CartItem/CartItemQuantityPicker.js +26 -14
- package/cart/components/CartItem/CartItemSubstitution.js +1 -1
- package/cart/components/CartItems/CartItemCardReservation.js +1 -1
- package/cart/components/CartItems/CartItemGroupReservation.js +1 -1
- package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.style.js +1 -1
- package/cart/components/PaymentBar/PaymentBar.js +1 -1
- package/cart/components/PaymentBar/PaymentBarCheckoutButton.style.js +1 -1
- package/cart/components/PaymentBar/PaymentBarPromotionCouponMessages.js +1 -1
- package/cart/index.js +1 -1
- package/category/actions/index.js +1 -0
- package/category/components/CategoryList/index.js +7 -0
- package/category/components/CategoryList/style.js +1 -0
- package/category/components/index.js +1 -1
- package/category/constants/index.js +1 -0
- package/category/helpers/index.js +1 -0
- package/category/index.js +1 -6
- package/category/selectors/index.js +2 -0
- package/category/streams/index.js +1 -1
- package/checkout/actions/errorCheckout.js +1 -1
- package/checkout/actions/fetchCheckoutOrder.js +1 -1
- package/checkout/actions/fetchPaymentMethods.js +1 -1
- package/checkout/actions/initializeCheckout.js +1 -1
- package/checkout/actions/prepareCheckout.js +2 -2
- package/checkout/actions/submitCheckoutOrder.js +1 -1
- package/checkout/actions/updateCheckoutOrder.js +1 -1
- package/checkout/components/Checkout/CheckoutSectionMessages.js +1 -1
- package/checkout/components/CheckoutConfirmation/CheckoutConfirmation.js +1 -1
- package/checkout/components/CheckoutConfirmation/CheckoutConfirmationBilledTo.js +1 -1
- package/checkout/components/PaymentMethodButton/PaymentMethodButton.js +1 -1
- package/checkout/components/ShippingMethods/ShippingMethods.js +4 -4
- package/checkout/paymentMethods/index.js +2 -2
- package/checkout/paymentMethods/paypal/PaypalButtonApp.js +1 -1
- package/checkout/paymentMethods/paypal/PaypalButtonWeb.js +1 -1
- package/checkout/paymentMethods/paypal/PaypalPayButton.js +1 -1
- package/checkout/paymentMethods/paypal/PaypalProvider.js +1 -1
- package/checkout/paymentMethods/stripe/StripeButton.js +2 -2
- package/checkout/paymentMethods/stripe/StripeCreditCard.js +3 -3
- package/checkout/paymentMethods/stripe/StripeProvider.js +8 -8
- package/checkout/paymentMethods/stripe/sdk.js +1 -1
- package/checkout/providers/AddressBookProvider.js +1 -1
- package/checkout/providers/CheckoutProvider.js +8 -8
- package/components/ChipLayout/index.js +38 -0
- package/components/ChipLayout/spec.js +5 -0
- package/components/ChipLayout/style.js +5 -0
- package/components/Footer/Footer.js +7 -7
- package/components/Form/Builder/Builder.js +50 -29
- package/components/Form/Builder/ElementCheckbox.js +1 -1
- package/components/Form/Builder/ElementMultiSelect.js +1 -1
- package/components/Form/Builder/ElementPhoneNumber.js +3 -3
- package/components/Form/Builder/ElementRadio.js +1 -1
- package/components/Form/Builder/ElementSelect.js +1 -1
- package/components/Form/Builder/ElementText.js +3 -3
- package/components/Form/Builder/classes/ActionListener.constants.js +2 -2
- package/components/Form/Builder/classes/ActionListener.js +73 -16
- package/components/Form/Builder/helpers/buildFormElements.js +2 -2
- package/components/Form/Form.js +8 -5
- package/components/IntersectionVisibility/index.js +14 -7
- package/components/Logo/connector.js +4 -0
- package/components/Logo/index.js +4 -0
- package/components/Logo/spec.js +1 -0
- package/components/Logo/style.js +1 -0
- package/components/Menu/components/Position/index.js +5 -5
- package/components/Menu/index.js +9 -9
- package/components/MessageBar/MessageBar.js +1 -1
- package/components/MessageBar/index.js +1 -1
- package/components/NavigationHandler/index.js +4 -4
- package/components/NavigationHandler/spec.js +1 -1
- package/components/Picker/components/Button/index.js +1 -1
- package/components/Picker/components/List/index.js +2 -2
- package/components/Picker/components/Modal/index.js +7 -7
- package/components/Picker/index.js +18 -9
- package/components/PickerUtilize/components/Button/index.js +5 -0
- package/components/PickerUtilize/components/Button/style.js +1 -0
- package/components/PickerUtilize/index.js +17 -0
- package/components/PickerUtilize/spec.js +1 -0
- package/components/PickerUtilize/style.js +1 -0
- package/components/QuantityInput/QuantityInput.js +2 -2
- package/components/Radio/Radio.js +1 -1
- package/components/RadioCard/RadioCard.js +1 -1
- package/components/RangeSlider/components/Handle/index.js +1 -1
- package/components/RangeSlider/index.js +36 -24
- package/components/SheetList/components/Item/index.js +5 -5
- package/components/SheetList/index.js +4 -4
- package/components/SideNavigation/SideNavigationCategories.connector.js +2 -2
- package/components/SnackBarContainer/index.js +5 -0
- package/components/Switch/index.js +12 -0
- package/components/Switch/style.js +1 -0
- package/components/Tabs/components/TabIndicator.js +2 -2
- package/components/Tabs/components/Tabs.js +1 -1
- package/components/TimeBoundary/index.js +8 -6
- package/components/VideoPlayer/index.js +9 -6
- package/components/View/components/Above/index.js +1 -1
- package/components/View/components/Below/index.js +1 -1
- package/components/View/components/Content/index.js +18 -11
- package/components/View/index.js +1 -1
- package/components/View/provider.js +22 -5
- package/components/index.js +2 -2
- package/core/action-creators/app.js +5 -0
- package/core/action-creators/appPermissions.js +9 -0
- package/core/action-creators/index.js +1 -1
- package/core/actions/getGeolocation.js +2 -2
- package/core/actions/grantAppTrackingTransparencyPermission.js +6 -0
- package/core/actions/grantCameraPermissions.js +1 -1
- package/core/actions/grantGeolocationPermissions.js +1 -1
- package/core/actions/grantPermissions.js +13 -6
- package/core/actions/grantPushPermissions.js +22 -0
- package/core/actions/index.js +7 -0
- package/core/actions/requestAppPermission.js +12 -0
- package/core/actions/requestAppPermissionStatus.js +12 -0
- package/core/classes/GeolocationRequest.js +2 -3
- package/core/classes/GeolocationRequestApp.js +6 -6
- package/core/classes/GeolocationRequestBrowser.js +2 -2
- package/core/classes/index.js +1 -0
- package/core/collections/AppInitialization.js +49 -0
- package/core/collections/index.js +1 -0
- package/core/commands/analyticsSetConsent.js +11 -0
- package/core/commands/index.js +1 -0
- package/core/config/ThemeConfigResolver.js +2 -2
- package/core/config/config.action-creators.js +1 -1
- package/core/config/config.actions.js +1 -1
- package/core/config/config.reducers.js +1 -1
- package/core/config/config.subscriptions.js +2 -2
- package/core/config/index.js +1 -1
- package/core/constants/actionTypes.js +1 -0
- package/core/constants/appFeatures.js +1 -0
- package/core/constants/index.js +6 -1
- package/core/contexts/index.js +1 -0
- package/core/helpers/appFeatures.js +14 -0
- package/core/helpers/appPermissions.js +43 -6
- package/core/helpers/baseUrl.js +14 -0
- package/core/helpers/environment.js +4 -0
- package/core/helpers/getFullImageSource.js +1 -1
- package/core/helpers/i18n.js +5 -3
- package/core/helpers/index.js +7 -0
- package/core/hocs/index.js +1 -0
- package/core/hocs/withCurrentProduct.js +6 -6
- package/core/hocs/withTheme.js +2 -2
- package/core/hooks/index.js +1 -0
- package/core/hooks/useAsyncMemo.js +1 -1
- package/core/hooks/useFormState.js +1 -1
- package/core/hooks/useScrollTo.js +1 -1
- package/core/hooks/useTheme.js +2 -2
- package/core/index.js +5 -52
- package/core/initialization/index.js +4 -2
- package/core/providers/AppProvider.js +10 -8
- package/core/providers/index.js +1 -0
- package/core/reducers/app.js +6 -0
- package/core/reducers/index.js +1 -1
- package/core/reducers/merchantSettings.js +1 -1
- package/core/reducers/shopSettings.js +1 -1
- package/core/selectors/app.js +9 -0
- package/core/selectors/index.js +6 -1
- package/core/streams/app.js +8 -0
- package/core/streams/appPermissions.js +19 -0
- package/core/streams/index.js +4 -0
- package/core/subscriptions/app.js +7 -0
- package/favorites/components/Item/Item.js +5 -5
- package/favorites/components/List/List.js +1 -1
- package/favorites/components/Lists/Lists.js +4 -4
- package/filter/components/PriceSlider/index.js +9 -9
- package/filter/helpers/buildFilterParamsForFetchFiltersRequest.js +9 -0
- package/filter/helpers/buildUpdatedFilters.js +1 -1
- package/filter/helpers/index.js +1 -0
- package/filter/helpers/translateFilterLabel.js +6 -0
- package/filter/index.js +1 -1
- package/filter/providers/SortProvider.helpers.js +1 -1
- package/locations/actions/fetchFulfillmentSlots.js +5 -3
- package/locations/actions/fetchInventories.js +5 -4
- package/locations/actions/fetchLocations.js +18 -3
- package/locations/actions/fetchProductInventories.js +4 -2
- package/locations/actions/fetchProductLocations.js +9 -2
- package/locations/actions/index.js +1 -1
- package/locations/actions/setUserGeolocation.js +1 -1
- package/locations/actions/setUserSearchGeolocation.js +1 -1
- package/locations/actions/submitReservation.js +2 -2
- package/locations/components/Cart/CartContextMenuChangeFulfillmentContent.js +1 -1
- package/locations/components/FulfillmentPath/FulfillmentPath.js +1 -1
- package/locations/components/FulfillmentPath/FulfillmentPathItem.js +2 -2
- package/locations/components/FulfillmentSelector/FulfillmentSelectorAddToCart.js +2 -2
- package/locations/components/FulfillmentSelector/FulfillmentSelectorAlternativeLocation.js +1 -1
- package/locations/components/FulfillmentSheet/FulfillmentSheet.js +2 -2
- package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotDialog.js +1 -1
- package/locations/components/ReserveForm/ReserveForm.js +1 -1
- package/locations/components/ReserveForm/ReserveFormPhone.js +1 -1
- package/locations/components/StockInfo/StockInfo.defaultSettings.js +1 -1
- package/locations/components/StoreFinder/StoreFinderMap.style.js +2 -2
- package/locations/components/StoreList/StoreListSearch.js +2 -2
- package/locations/locations.streams.js +1 -1
- package/locations/providers/FulfillmentProvider.js +4 -4
- package/locations/providers/StoreFinderProvider.js +1 -1
- package/locations/reducers/storage.js +3 -3
- package/locations/selectors/index.js +2 -2
- package/locations/subscriptions.js +13 -13
- package/login/components/ForgotPassword/ForgotPassword.js +1 -1
- package/orders/actions/cancelOrder.js +1 -1
- package/orders/actions/fetchOrderDetails.js +1 -1
- package/orders/constants/status.js +2 -2
- package/orders/providers/OrderDetailsPrivateProvider.js +1 -1
- package/orders/providers/OrderDetailsProvider.js +3 -3
- package/package.json +8 -8
- package/page/actions/index.js +1 -0
- package/page/components/index.js +1 -0
- package/page/constants/index.js +1 -0
- package/page/index.js +2 -4
- package/page/selectors/index.js +1 -0
- package/product/collections/index.js +1 -0
- package/product/components/Availability/Availability.connector.js +4 -5
- package/product/components/Availability/Availability.js +3 -3
- package/product/components/Characteristics/Characteristic/components/Sheet/index.js +20 -0
- package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +10 -0
- package/product/components/Characteristics/Characteristic/components/SheetItem/style.js +1 -0
- package/product/components/Characteristics/Characteristic/index.js +18 -0
- package/product/components/Characteristics/Characteristic/style.js +1 -0
- package/product/components/Characteristics/Swatch/index.js +12 -0
- package/product/components/Characteristics/Swatch/style.js +1 -0
- package/product/components/Characteristics/index.js +12 -0
- package/product/components/Characteristics/transition.js +1 -0
- package/product/components/Description/index.js +2 -2
- package/product/components/EffectivityDates/helpers.js +3 -3
- package/product/components/EffectivityDates/index.js +1 -1
- package/product/components/Header/PriceStriked/connector.js +9 -0
- package/product/components/Header/PriceStriked/index.js +5 -0
- package/product/components/Header/PriceStriked/style.js +1 -0
- package/product/components/Header/Shipping/components/Label/index.js +6 -0
- package/product/components/Header/Shipping/components/Label/style.js +1 -0
- package/product/components/Header/Shipping/connector.js +9 -0
- package/product/components/Header/Shipping/index.js +5 -0
- package/product/components/Header/Shipping/mock.js +1 -0
- package/product/components/Header/Shipping/spec.js +5 -0
- package/product/components/Header/Shipping/style.js +1 -0
- package/product/components/Header/Tiers/components/Tier/index.js +6 -0
- package/product/components/Header/Tiers/components/Tier/spec.js +1 -0
- package/product/components/Header/Tiers/connector.js +10 -0
- package/product/components/Header/Tiers/index.js +5 -0
- package/product/components/Header/Tiers/spec.js +1 -0
- package/product/components/Header/Tiers/style.js +1 -0
- package/product/components/Header/index.js +1 -0
- package/product/components/MapPriceHint/index.js +1 -1
- package/product/components/Media/FeaturedMedia.js +1 -1
- package/product/components/MediaSlider/index.js +1 -1
- package/product/components/Options/components/Content/connector.js +10 -0
- package/product/components/Options/components/Content/index.js +16 -0
- package/product/components/Options/components/Content/spec.js +2 -0
- package/product/components/Options/components/Option/index.js +4 -0
- package/product/components/Options/components/TextOption/components/OptionInfo/index.js +9 -0
- package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +1 -0
- package/product/components/Options/components/TextOption/components/OptionInfo/style.js +1 -0
- package/product/components/Options/components/TextOption/index.js +22 -0
- package/product/components/Options/components/TextOption/style.js +1 -0
- package/product/components/Options/index.js +5 -0
- package/product/components/OrderQuantityHint/index.js +3 -2
- package/product/components/OrderQuantityHint/style.js +1 -1
- package/product/components/PriceDifference/index.js +1 -1
- package/product/components/ProductCard/index.js +2 -2
- package/product/components/ProductCharacteristics/helpers/index.js +1 -1
- package/product/components/ProductCharacteristics/index.js +28 -12
- package/product/components/ProductDiscountBadge/spec.js +1 -1
- package/product/components/ProductGridPrice/index.js +2 -2
- package/product/components/ProductImage/index.js +15 -12
- package/product/components/ProductList/components/Item/index.js +5 -0
- package/product/components/ProductList/components/Item/style.js +2 -0
- package/product/components/ProductList/components/Iterator/index.js +5 -0
- package/product/components/ProductList/components/Iterator/style.js +1 -0
- package/product/components/ProductList/components/Layout/index.js +5 -0
- package/product/components/ProductList/components/Layout/style.js +1 -0
- package/product/components/ProductList/index.js +5 -0
- package/product/components/ProductProperties/Content.js +1 -1
- package/product/components/ProductProperties/GroupedProperties.js +1 -1
- package/product/components/ProductProperties/ListsHTML.js +1 -1
- package/product/components/ProductProperties/ProductProperties.js +1 -1
- package/product/components/ProductProperties/RowHTML.js +1 -1
- package/product/components/ProductProperties/Wrapper.js +1 -1
- package/product/components/ProductProperties/style.js +1 -1
- package/product/components/ProductProvider/connector.js +5 -0
- package/product/components/ProductProvider/index.js +4 -0
- package/product/components/ProductSlider/index.js +4 -0
- package/product/components/ProductSlider/spec.js +1 -0
- package/product/components/ProductSlider/style.js +1 -0
- package/product/components/Rating/connector.js +9 -0
- package/product/components/Rating/index.js +7 -0
- package/product/components/Rating/mock.js +5 -0
- package/product/components/Rating/spec.js +5 -0
- package/product/components/Rating/style.js +1 -0
- package/product/components/Swatch/SwatchContent.js +1 -1
- package/product/components/index.js +1 -0
- package/product/constants/index.js +1 -1
- package/product/contexts/index.js +1 -0
- package/product/helpers/index.js +2 -2
- package/product/helpers/redirects.js +1 -1
- package/product/hocs/index.js +1 -0
- package/product/hocs/withProductListEntryProduct.js +12 -0
- package/product/hooks/index.js +1 -0
- package/product/index.js +4 -11
- package/product/providers/index.js +1 -0
- package/product/selectors/product.js +13 -2
- package/product/selectors/variants.js +2 -2
- package/product/streams/index.js +1 -0
- package/push-opt-in/action-creators/index.js +1 -0
- package/push-opt-in/action-creators/optInTrigger.js +23 -0
- package/push-opt-in/action-creators/pushOptIn.js +7 -0
- package/push-opt-in/actions/index.js +1 -0
- package/push-opt-in/actions/pushOptInModal.js +8 -0
- package/push-opt-in/components/PushOptInModal/connector.js +9 -0
- package/push-opt-in/components/PushOptInModal/index.js +10 -0
- package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
- package/push-opt-in/components/PushOptInModal/style.js +1 -0
- package/push-opt-in/components/index.js +1 -0
- package/push-opt-in/constants/index.js +1 -0
- package/push-opt-in/constants/optInModal.js +1 -0
- package/push-opt-in/constants/optInTrigger.js +1 -0
- package/push-opt-in/reducers/index.js +1 -0
- package/push-opt-in/reducers/optInModal.js +6 -0
- package/push-opt-in/reducers/optInTrigger.js +6 -0
- package/push-opt-in/selectors/index.js +1 -0
- package/push-opt-in/selectors/optInModal.js +8 -0
- package/push-opt-in/selectors/optInTrigger.js +5 -0
- package/push-opt-in/subscriptions/index.js +1 -0
- package/push-opt-in/subscriptions/optInTrigger.js +14 -0
- package/registration/providers/GuestRegistrationProvider.actions.js +2 -2
- package/registration/providers/GuestRegistrationProvider.js +3 -3
- package/registration/providers/RegistrationProvider.actions.js +3 -3
- package/registration/providers/RegistrationProvider.js +2 -2
- package/registration/subscriptions/index.js +1 -1
- package/reviews/actions/index.js +1 -0
- package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/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/ReviewsInfo/index.js +1 -2
- package/reviews/components/Reviews/spec.js +1 -1
- package/reviews/components/index.js +1 -0
- package/reviews/constants/index.js +1 -0
- package/reviews/index.js +1 -7
- package/reviews/selectors/index.js +1 -0
- package/reviews/streams/index.js +1 -0
- package/scanner/action-creators/index.js +1 -0
- package/scanner/actions/index.js +1 -0
- package/scanner/classes/index.js +1 -0
- package/scanner/constants/index.js +1 -0
- package/scanner/helpers/index.js +1 -0
- package/scanner/index.js +1 -6
- package/scanner/streams/index.js +1 -0
- package/search/actions/index.js +1 -0
- package/search/constants/index.js +1 -0
- package/search/helpers/index.js +1 -0
- package/search/index.js +1 -6
- package/search/selectors/index.js +1 -0
- package/search/streams/index.js +1 -0
- package/styles/helpers/index.js +1 -0
- package/styles/helpers/initCSSCustomProperties.js +3 -3
- package/styles/helpers/setPageContentWidth.js +2 -1
- package/styles/index.js +1 -1
- package/tracking/components/CookieConsent/CookieConsentContent.js +1 -1
- package/tracking/constants/index.js +2 -1
- package/components/MessageBar/MessageBar.types.js +0 -0
- package/components/MessageBar/style.js +0 -1
- package/product/components/Availability/Availability.types.js +0 -1
- /package/page/{NotFound.js → components/NotFound.js} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{configuration}from'@shopgate/pwa-common/collections';import{IS_CONNECT_EXTENSION_ATTACHED}from'@shopgate/pwa-common/constants/Configuration';/**
|
|
2
|
+
* Determines if the PWA uses the new backend services
|
|
3
|
+
* @returns {boolean}
|
|
4
|
+
*/export var hasNewServices=function hasNewServices(){return!!configuration.get(IS_CONNECT_EXTENSION_ATTACHED);};
|
|
@@ -22,4 +22,4 @@ import{getProductImageSettings}from"../../product/helpers";import{getImageFormat
|
|
|
22
22
|
* @param {number} dimension.width Width in pixels.
|
|
23
23
|
* @param {number} dimension.height Height in pixels.
|
|
24
24
|
* @returns {string}
|
|
25
|
-
*/export var getFullImageSource=function getFullImageSource(src){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},width=_ref.width,height=_ref.height;if(src&&src.includes('images.shopgate.services/v2/images')){var
|
|
25
|
+
*/export var getFullImageSource=function getFullImageSource(src){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},width=_ref.width,height=_ref.height;if(src&&src.includes('images.shopgate.services/v2/images')){var _getProductImageSetti2=getProductImageSettings(),fillColor=_getProductImageSetti2.fillColor,quality=_getProductImageSetti2.quality;var format=getImageFormat();return buildUrl(src,{format:format,width:width,height:height,quality:quality,fill:fillColor.replace('#','')});}if(src&&src.startsWith('https://img-cdn.shopgate.com')&&!src.includes('?')){return buildUrl(src,{w:width,h:height,q:70,zd:'resize',fillc:'FFFFFF'});}return src;};
|
package/core/helpers/i18n.js
CHANGED
|
@@ -2,9 +2,11 @@ import get from'lodash/get';import{getTranslator,getPriceFormatter,getDateFormat
|
|
|
2
2
|
* @typedef {Object} I18nHelpers
|
|
3
3
|
* @property {Function} init - Inits locales.
|
|
4
4
|
* @property {Function} text - Text translator.
|
|
5
|
+
* @property {Function} textWithDefault - Text translator with default supplier.
|
|
5
6
|
* @property {Function} price - Price translator.
|
|
6
7
|
* @property {Function} date - Date translator.
|
|
7
8
|
* @property {Function} time - Time translator.
|
|
9
|
+
* @property {Function} number - Number translator
|
|
8
10
|
* @property {Function} getSupplementalData - Get Supplemental Data
|
|
9
11
|
* @property {Function} getPath - Get locale data by path
|
|
10
12
|
* @property {Function} getLang - Get locale lang code, eg de-DE
|
|
@@ -14,10 +16,10 @@ import get from'lodash/get';import{getTranslator,getPriceFormatter,getDateFormat
|
|
|
14
16
|
*/var I18n=function I18n(){var didInit=false;/**
|
|
15
17
|
* Function that throws when called. Used in a default instance of i18n to notify developer
|
|
16
18
|
* when the module is used without initialization.
|
|
17
|
-
*/var notReadyCb=function notReadyCb(){logger.error('i18n is not yet ready. Please postpone translations until App is bootstrapped.');};return{init:function init(_ref){var locales=_ref.locales,lang=_ref.lang,_ref$currencyLocale=_ref.currencyLocale,currencyLocale=_ref$currencyLocale===void 0?null:_ref$currencyLocale;if(didInit){logger.warn('Looks like i18n locales are already inited. Changing locales now may lead to inconsistent translations.');}didInit=true;this.text=getTranslator(locales,lang);this.price=getPriceFormatter(currencyLocale||lang);this.date=getDateFormatter(lang);this.time=getTimeFormatter(lang);this.number=getNumberFormatter(lang);this.getSupplementalData=function(){return locales.supplementalData||{};};this.getPath=function(path){return get(locales,path);};this.getLang=function(){return lang;};// If component decides to act accordingly this information should be exposed.
|
|
18
|
-
this.ready=true;},text:notReadyCb,price:notReadyCb,date:notReadyCb,time:notReadyCb,number:notReadyCb,getSupplementalData:notReadyCb,getPath:notReadyCb,getLang:notReadyCb,ready:false};};/**
|
|
19
|
+
*/var notReadyCb=function notReadyCb(){logger.error('i18n is not yet ready. Please postpone translations until App is bootstrapped.');};return{init:function init(_ref){var _this=this;var locales=_ref.locales,lang=_ref.lang,_ref$currencyLocale=_ref.currencyLocale,currencyLocale=_ref$currencyLocale===void 0?null:_ref$currencyLocale;if(didInit){logger.warn('Looks like i18n locales are already inited. Changing locales now may lead to inconsistent translations.');}didInit=true;this.text=getTranslator(locales,lang);this.textWithDefault=function(key,defaultText){var text=_this.text(key);return text===key?defaultText:text;};this.price=getPriceFormatter(currencyLocale||lang);this.date=getDateFormatter(lang);this.time=getTimeFormatter(lang);this.number=getNumberFormatter(lang);this.getSupplementalData=function(){return locales.supplementalData||{};};this.getPath=function(path){return get(locales,path);};this.getLang=function(){return lang;};// If component decides to act accordingly this information should be exposed.
|
|
20
|
+
this.ready=true;},text:notReadyCb,textWithDefault:notReadyCb,price:notReadyCb,date:notReadyCb,time:notReadyCb,number:notReadyCb,getSupplementalData:notReadyCb,getPath:notReadyCb,getLang:notReadyCb,ready:false};};/**
|
|
19
21
|
* @type {I18nHelpers}
|
|
20
22
|
*/export var i18n=I18n();/**
|
|
21
23
|
* Return order of week days, based on firstDay of week locale settings
|
|
22
24
|
* @returns {string[]}
|
|
23
|
-
*/export var getWeekDaysOrder=function getWeekDaysOrder(){var _i18n$getSupplemental=i18n.getSupplementalData(),_i18n$getSupplemental2=_i18n$getSupplemental.weekData
|
|
25
|
+
*/export var getWeekDaysOrder=function getWeekDaysOrder(){var _i18n$getSupplemental=i18n.getSupplementalData(),_i18n$getSupplemental2=_i18n$getSupplemental.weekData,_i18n$getSupplemental3=_i18n$getSupplemental2===void 0?{}:_i18n$getSupplemental2,_i18n$getSupplemental4=_i18n$getSupplemental3.firstDay,firstDay=_i18n$getSupplemental4===void 0?'sun':_i18n$getSupplemental4;var days=['sun','mon','tue','wed','thu','fri','sat'];var dayIndex=days.findIndex(function(d){return d===firstDay;});return days.slice(dayIndex).concat(days.slice(0,dayIndex));};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @module core */import{getCurrentRoute as getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString}from'@shopgate/pwa-common/helpers/router';export*from"./environment";export*from"./appFeatures";export*from"./appPermissions";export*from"./baseUrl";export*from"./bridge";export{isBeta}from"../config/isBeta";export{getFullImageSource}from"./getFullImageSource";export{getImageFormat}from"./getImageFormat";export{i18n,getWeekDaysOrder}from"./i18n";export{updateLegacyNavigationBar}from"./updateLegacyNavigationBar";export{default as nl2br}from"./nl2br";export*from"./string";export{isIOSTheme}from"./isIOSTheme";export{isTouchDevice}from"./isTouchDevice";export{generateGoogleMapsDirectionsUrl}from"./googleMaps";export{useScrollContainer}from"./scrollContainer";export{getDeviceTypeForCms}from"./deviceType";export*from"./featureFlag";// --------------- CORE --------------- //
|
|
2
|
+
export*from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export*from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
3
|
+
/*
|
|
4
|
+
export { default as portalCollection } from '@shopgate/pwa-common/helpers/portals/portalCollection';
|
|
5
|
+
export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/routePortals';
|
|
6
|
+
*/export*from'@shopgate/pwa-common/helpers/redux';export*from'@shopgate/pwa-common/helpers/style';export*from'@shopgate/pwa-common/helpers/tracking';export*from'@shopgate/pwa-common/helpers/validation';export{default as errorBehavior}from"./errorBehavior";// --------------- ROUTER --------------- //
|
|
7
|
+
export{getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString};export{push,pop,replace,reset}from"../router/helpers";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as withShowModal}from'@shopgate/pwa-common/helpers/modal/withShowModal';export{withTheme}from"./withTheme";export{withRoute}from"./withRoute";export{withCurrentProduct}from"./withCurrentProduct";export{withForwardedRef}from"./withForwardedRef";export{withNavigation}from"./withNavigation";export{withWidgetSettings}from"./withWidgetSettings";export{withWidgetStyles}from"./withWidgetStyles";export{withApp}from"./withApp";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import
|
|
1
|
+
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useContext}from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
|
|
2
2
|
* Gets the context props for the wrapped component.
|
|
3
3
|
* @param {Object} context The context.
|
|
4
4
|
* @param {string|null} prop The optional prop name.
|
|
@@ -7,10 +7,10 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
7
7
|
* Injects the current Product Context information into the desired component.
|
|
8
8
|
* @param {Function} WrappedComponent The react component to wrap.
|
|
9
9
|
* @param {Object} [options] A optional prop name to inject the current product properties.
|
|
10
|
-
* @
|
|
10
|
+
* @param {string} [options.prop] An optional prop name to inject the current product properties.
|
|
11
11
|
* @returns {JSX}
|
|
12
12
|
*/export function withCurrentProduct(WrappedComponent){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
* The actual HOC.
|
|
14
|
+
* @param {Object} props The component props.
|
|
15
|
+
* @returns {JSX}
|
|
16
|
+
*/function WithCurrentProduct(props){var _useContext=useContext(ThemeContext),ProductContext=_useContext.contexts.ProductContext;var productProps=useContext(ProductContext);return React.createElement(WrappedComponent,_extends({},getInjectedProps(productProps,options.prop),props));}var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithCurrentProduct.displayName="WithCurrentProduct(".concat(displayName,")");return WithCurrentProduct;}
|
package/core/hocs/withTheme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
|
|
1
|
+
var _excluded=["contexts"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
|
|
2
2
|
* Gets the context props for the wrapped component.
|
|
3
3
|
* @param {Object} context The context.
|
|
4
4
|
* @param {string|null} prop The optional prop name.
|
|
@@ -13,5 +13,5 @@ function _objectWithoutProperties(source,excluded){if(source==null)return{};var
|
|
|
13
13
|
* The actual HOC.
|
|
14
14
|
* @param {Object} props The component props.
|
|
15
15
|
* @returns {JSX}
|
|
16
|
-
*/var WithTheme=function WithTheme(props){return React.createElement(ThemeContext.Consumer,null,function(_ref2){var contexts=_ref2.contexts,themeContext=_objectWithoutProperties(_ref2,
|
|
16
|
+
*/var WithTheme=function WithTheme(props){return React.createElement(ThemeContext.Consumer,null,function(_ref2){var contexts=_ref2.contexts,themeContext=_objectWithoutProperties(_ref2,_excluded);return(// The contexts are left out in favor of other HOCs.
|
|
17
17
|
React.createElement(WrappedComponent,_extends({},getInjectedProps(themeContext,options.prop),props)));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithTheme.displayName="WithTheme(".concat(displayName,")");return WithTheme;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{useAsyncMemo}from"./useAsyncMemo";export{useRoute}from"./useRoute";export{useTheme}from"./useTheme";export{useApp}from"./useApp";export{useCurrentProduct}from"./useCurrentProduct";export{useNavigation}from"./useNavigation";export{usePageConfig}from"./usePageConfig";export{usePageSettings}from"./usePageSettings";export{useWidgetConfig}from"./useWidgetConfig";export{useWidgetSettings}from"./useWidgetSettings";export{useWidgetStyles}from"./useWidgetStyles";export*from"./html";export{useScroll}from"./useScroll";export{usePrevious}from"./usePrevious";
|
|
@@ -9,4 +9,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
9
9
|
* @returns {Array}
|
|
10
10
|
*/export function useAsyncMemo(asyncFunction){var asyncFunctionDependencies=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var initialValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var _React$useState=React.useState(initialValue),_React$useState2=_slicedToArray(_React$useState,2),value=_React$useState2[0],setValue=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),error=_React$useState4[0],setError=_React$useState4[1];/* eslint-disable react-hooks/exhaustive-deps */React.useEffect(function(){/**
|
|
11
11
|
* Wraps the async function as React doesn't allow direct async usage.
|
|
12
|
-
*/var fn=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var output;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
12
|
+
*/var fn=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var output;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return asyncFunction();case 3:output=_context.sent;setValue(output);_context.next=10;break;case 7:_context.prev=7;_context.t0=_context["catch"](0);setError(_context.t0);case 10:case"end":return _context.stop();}},_callee,null,[[0,7]]);}));return function fn(){return _ref.apply(this,arguments);};}();fn();},asyncFunctionDependencies);/* eslint-enable react-hooks/exhaustive-deps */return[value,error];}
|
|
@@ -15,7 +15,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";import _debounce fro
|
|
|
15
15
|
*/export function useFormState(initialState,complete){var validationConstraints=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var formContainerRef=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var validationErrorScrollOffset=arguments.length>4&&arguments[4]!==undefined?arguments[4]:10;var _useScrollTo=useScrollTo(formContainerRef,validationErrorScrollOffset),scrollTo=_useScrollTo.scrollTo;// Submit lock prevents the form from being submitted multiple times
|
|
16
16
|
var submitLock=useRef(false);var _useState=useState(initialState),_useState2=_slicedToArray(_useState,2),values=_useState2[0],setValues=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isSubmitting=_useState4[0],setSubmitting=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),changed=_useState6[0],setChanged=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),ignoreErrors=_useState8[0],setIgnoreErrors=_useState8[1];var _useValidation=useValidation(validationConstraints),valid=_useValidation.valid,validationErrors=_useValidation.validationErrors,validate=_useValidation.validate,reset=_useValidation.reset;var scrollToError=useCallback(function(){scrollTo('.validationError');},[scrollTo]);// -- CHANGED ---------------
|
|
17
17
|
useEffect(function(){var isEqual=JSON.stringify(values)===JSON.stringify(initialState);if(!isEqual&&!changed){setChanged(true);}else if(isEqual&&changed){setChanged(false);}},[changed,initialState,values]);// -- IS_SUBMITTING ---------
|
|
18
|
-
/* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){if(!isSubmitting){return;}var mounted=true;if((valid===true||ignoreErrors)&&!submitLock.current){submitLock.current=true;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
18
|
+
/* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){if(!isSubmitting){return;}var mounted=true;if((valid===true||ignoreErrors)&&!submitLock.current){submitLock.current=true;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return complete(values);case 2:if(mounted){setSubmitting(false);setChanged(false);submitLock.current=false;}case 3:case"end":return _context.stop();}},_callee);}))();}// eslint-disable-next-line consistent-return
|
|
19
19
|
return function(){mounted=false;};},[isSubmitting,valid,ignoreErrors]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){scrollToError();},[isSubmitting,scrollToError]);useEffect(function(){return function(){submitLock.current=false;};},[]);// -- VALIDATION ON SUBMIT ---------
|
|
20
20
|
useEffect(function(){if(ignoreErrors){return;}// Yest no validation on submit
|
|
21
21
|
if(changed&&valid!==null){validate(values);}if(isSubmitting&&valid===null){validate(values);}if(isSubmitting&&valid===false){setSubmitting(false);}},[changed,validate,values,isSubmitting,valid,ignoreErrors]);var handleSetIgnoreErrors=useCallback(function(value){setIgnoreErrors(value);if(ignoreErrors===true){reset();}},[ignoreErrors,reset]);/**
|
|
@@ -2,4 +2,4 @@ import{useCallback}from'react';import{getCSSCustomProp}from'@shopgate/engage/sty
|
|
|
2
2
|
* @param {Object} ref A ref to the scroll container
|
|
3
3
|
* @param {number} [offset=10] Optional offset for the scroll operation
|
|
4
4
|
* @returns {Object}
|
|
5
|
-
*/export var useScrollTo=function useScrollTo(ref){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var scrollTo=useCallback(function(selector){if(!(ref===null||ref===void 0?void 0:ref.current)){return;}var firstElement=ref.current.querySelector(selector);if(firstElement){if(hasWebBridge()){var scrollOffset=offset;var appBarHeight=getCSSCustomProp('--app-bar-height')||0;var _firstElement$
|
|
5
|
+
*/export var useScrollTo=function useScrollTo(ref){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var scrollTo=useCallback(function(selector){if(!(ref===null||ref===void 0?void 0:ref.current)){return;}var firstElement=ref.current.querySelector(selector);if(firstElement){if(hasWebBridge()){var scrollOffset=offset;var appBarHeight=getCSSCustomProp('--app-bar-height')||0;var _firstElement$getBoun2=firstElement.getBoundingClientRect(),top=_firstElement$getBoun2.top;var scrollTop=top+window.pageYOffset-parseInt(appBarHeight,10)-scrollOffset;window.scroll({top:scrollTop,behavior:'smooth'});}else{firstElement.scrollIntoView({behavior:'smooth'});}}},[offset,ref]);return{scrollTo:scrollTo};};
|
package/core/hooks/useTheme.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{useContext}from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
|
|
1
|
+
var _excluded=["contexts"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{useContext}from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
|
|
2
2
|
* Provides the theme API. This does not include the contexts.
|
|
3
3
|
* @returns {Object}
|
|
4
4
|
*/export function useTheme(){// The contexts are left out in favor of other hooks.
|
|
5
|
-
var _useContext=useContext(ThemeContext),contexts=_useContext.contexts,themeContext=_objectWithoutProperties(_useContext,
|
|
5
|
+
var _useContext=useContext(ThemeContext),contexts=_useContext.contexts,themeContext=_objectWithoutProperties(_useContext,_excluded);return themeContext;}
|
package/core/index.js
CHANGED
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
/** @module core */
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export{
|
|
6
|
-
export{default as analyticsSetCustomValues}from'@shopgate/pwa-core/commands/analyticsSetCustomValues';export*from'@shopgate/pwa-core/commands/appPermissions';export*from'@shopgate/pwa-core/commands/brightness';export{default as broadcastEvent}from'@shopgate/pwa-core/commands/broadcastEvent';export{default as cleanTab,cleanTabCmd}from'@shopgate/pwa-core/commands/cleanTab';export{default as closeInAppBrowser}from'@shopgate/pwa-core/commands/closeInAppBrowser';export{default as flushTab}from'@shopgate/pwa-core/commands/flushTab';export{default as hideMenuBar}from'@shopgate/pwa-core/commands/hideMenuBar';export{default as hideNavigationBar}from'@shopgate/pwa-core/commands/hideNavigationBar';export{default as hideSplashScreen}from'@shopgate/pwa-core/commands/hideSplashScreen';export{default as onload}from'@shopgate/pwa-core/commands/onload';export{default as openAppSettings}from'@shopgate/pwa-core/commands/openAppSettings';export{default as openPage}from'@shopgate/pwa-core/commands/openPage';export{default as openPageExtern}from'@shopgate/pwa-core/commands/openPageExtern';export{default as performCommandsAfterDelay,performCommandsAfterDelayCmd}from'@shopgate/pwa-core/commands/performCommandsAfterDelay';export*from'@shopgate/pwa-core/commands/plotProjects';export{default as popTabToRoot,popTabToRootCmd}from'@shopgate/pwa-core/commands/popTabToRoot';export{default as registerEvents}from'@shopgate/pwa-core/commands/registerEvents';export*from'@shopgate/pwa-core/commands/scanner';export{default as setCookie}from'@shopgate/pwa-core/commands/setCookie';export{default as setDebugLoggingEnabled}from'@shopgate/pwa-core/commands/setDebugLoggingEnabled';export{default as setScrollingEnabled}from'@shopgate/pwa-core/commands/setScrollingEnabled';export{default as showNavigationBar}from'@shopgate/pwa-core/commands/showNavigationBar';export{default as showTab}from'@shopgate/pwa-core/commands/showTab';export*from'@shopgate/pwa-core/commands/unifiedTracking';// TODO: Contains circular dependency!
|
|
7
|
-
// export * from '@shopgate/pwa-core/commands/webStorage';
|
|
8
|
-
// Core Constants
|
|
9
|
-
export*from'@shopgate/pwa-core/constants/AppEvents';export*from'@shopgate/pwa-core/constants/AppPermissions';export*from'@shopgate/pwa-core/constants/ErrorHandleTypes';export*from'@shopgate/pwa-core/constants/Pipeline';export*from'@shopgate/pwa-core/constants/ProcessTypes';export*from'@shopgate/pwa-core/constants/Scanner';// Common Constants
|
|
10
|
-
export*from'@shopgate/pwa-common/constants/ActionTypes';export*from'@shopgate/pwa-common/constants/Configuration';export*from'@shopgate/pwa-common/constants/Device';export*from'@shopgate/pwa-common/constants/DisplayOptions';export*from'@shopgate/pwa-common/constants/Pipelines';export*from'@shopgate/pwa-common/constants/Portals';export{INDEX_PATH,INDEX_PATH_DEEPLINK,LOGIN_PATH};export*from"./constants/geolocationRequest";// Emitters
|
|
11
|
-
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';// Helpers
|
|
12
|
-
export{logger,ajaxUrl,hasSGJavaScriptBridge,useBrowserConnector,logDeprecationMessage}from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export*from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
13
|
-
/*
|
|
14
|
-
export { default as portalCollection } from '@shopgate/pwa-common/helpers/portals/portalCollection';
|
|
15
|
-
export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/routePortals';
|
|
16
|
-
*/export*from'@shopgate/pwa-common/helpers/redux';export*from'@shopgate/pwa-common/helpers/style';export*from'@shopgate/pwa-common/helpers/tracking';export*from'@shopgate/pwa-common/helpers/validation';// STREAMS
|
|
17
|
-
export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';// --------------- APP --------------- //
|
|
18
|
-
// ACTIONS
|
|
19
|
-
export{default as handleDeepLink}from'@shopgate/pwa-common/actions/app/handleDeepLink';export{default as handleUniversalLink}from'@shopgate/pwa-common/actions/app/handleUniversalLink';export{default as handleLink}from'@shopgate/pwa-common/actions/app/handleLink';export{default as handlePushNotification}from'@shopgate/pwa-common/actions/app/handlePushNotification';export{default as registerLinkEvents}from'@shopgate/pwa-common/actions/app/registerLinkEvents';export{default as updateStatusBarBackground}from"./actions/updateStatusBarBackground";export{default as grantPermissions}from"./actions/grantPermissions";export{default as grantCameraPermissions}from"./actions/grantCameraPermissions";export{default as grantGeolocationPermissions}from"./actions/grantGeolocationPermissions";export{default as getGeolocation}from"./actions/getGeolocation";// STREAMS
|
|
20
|
-
export*from'@shopgate/pwa-common/streams/app';// --------------- STORE --------------- //
|
|
21
|
-
export*from'@shopgate/pwa-common/store';// --------------- CLIENT --------------- //
|
|
22
|
-
// ACTIONS
|
|
23
|
-
export{default as fetchClientInformation}from'@shopgate/pwa-common/actions/client/fetchClientInformation';// CONSTANTS
|
|
24
|
-
export*from'@shopgate/pwa-common/constants/client';// SELECTORS
|
|
25
|
-
export*from'@shopgate/pwa-common/selectors/client';// STREAMS
|
|
26
|
-
export*from'@shopgate/pwa-common/streams/client';// --------------- COLLECTIONS --------------- //
|
|
27
|
-
export{default as authRoutes}from'@shopgate/pwa-common/collections/AuthRoutes';export{default as redirects}from'@shopgate/pwa-common/collections/Redirects';export{default as configuration}from'@shopgate/pwa-common/collections/Configuration';export{default as embeddedMedia}from'@shopgate/pwa-common/collections/EmbeddedMedia';export{default as persistedReducers}from'@shopgate/pwa-common/collections/PersistedReducers';export{default as Vimeo}from'@shopgate/pwa-common/collections/media-providers/Vimeo';export{default as YouTube}from'@shopgate/pwa-common/collections/media-providers/YouTube';// --------------- CONTEXTS --------------- //
|
|
28
|
-
export*from'@shopgate/pwa-common/context';export{default as AppContext}from"./contexts/AppContext";// --------------- PROVIDERS --------------- //
|
|
29
|
-
export{default as LoadingProvider}from'@shopgate/pwa-common/providers/loading';export{default as LoadingContext}from'@shopgate/pwa-common/providers/loading/context';export{default as ToastProvider}from'@shopgate/pwa-common/providers/toast';export{default as ToastContext}from'@shopgate/pwa-common/providers/toast/context';export{default as AppProvider}from"./providers/AppProvider";// --------------- ROUTER --------------- //
|
|
30
|
-
// ACTIONS
|
|
31
|
-
export{historyPop}from'@shopgate/pwa-common/actions/router/historyPop';export{historyPopToRoute}from'@shopgate/pwa-common/actions/router/historyPopToRoute';export{historyPush}from'@shopgate/pwa-common/actions/router/historyPush';export{historyRedirect}from'@shopgate/pwa-common/actions/router/historyRedirect';export{historyReplace}from'@shopgate/pwa-common/actions/router/historyReplace';export{historyReset}from'@shopgate/pwa-common/actions/router/historyReset';export{historyResetTo}from'@shopgate/pwa-common/actions/router/historyResetTo';// HELPERS
|
|
32
|
-
export{getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString};export{push,pop,replace,reset}from"./router/helpers";// SELECTORS
|
|
33
|
-
export*from'@shopgate/pwa-common/selectors/router';export*from'@shopgate/pwa-common/selectors/history';// STREAMS
|
|
34
|
-
export*from'@shopgate/pwa-common/streams/router';// --------------- URL --------------- //
|
|
35
|
-
// ACTIONS
|
|
36
|
-
export{resetApp}from'@shopgate/pwa-common/action-creators/app';export*from'@shopgate/pwa-common/action-creators/url';// SELECTORS
|
|
37
|
-
export*from'@shopgate/pwa-common/selectors/url';// --------------- MENU --------------- //
|
|
38
|
-
// ACTIONS
|
|
39
|
-
export{default as fetchMenu}from'@shopgate/pwa-common/actions/menu/fetchMenu';// CONSTANTS
|
|
40
|
-
export*from'@shopgate/pwa-common/constants/MenuIDs';// SELECTORS
|
|
41
|
-
export*from'@shopgate/pwa-common/selectors/menu';// --------------- MODAL --------------- //
|
|
42
|
-
// ACTIONS
|
|
43
|
-
export{default as closeModal}from'@shopgate/pwa-common/actions/modal/closeModal';export{default as promiseMap}from'@shopgate/pwa-common/actions/modal/promiseMap';export{default as showModal}from'@shopgate/pwa-common/actions/modal/showModal';// CONSTANTS
|
|
44
|
-
export*from'@shopgate/pwa-common/constants/ModalTypes';// HELPERS
|
|
45
|
-
export{default as withShowModal}from'@shopgate/pwa-common/helpers/modal/withShowModal';// SELECTORS
|
|
46
|
-
export*from'@shopgate/pwa-common/selectors/modal';// --------------- HOOKS --------------- //
|
|
47
|
-
export{useAsyncMemo}from"./hooks/useAsyncMemo";export{useRoute}from"./hooks/useRoute";export{useTheme}from"./hooks/useTheme";export{useApp}from"./hooks/useApp";export{useCurrentProduct}from"./hooks/useCurrentProduct";export{useNavigation}from"./hooks/useNavigation";export{usePageConfig}from"./hooks/usePageConfig";export{usePageSettings}from"./hooks/usePageSettings";export{useWidgetConfig}from"./hooks/useWidgetConfig";export{useWidgetSettings}from"./hooks/useWidgetSettings";export{useWidgetStyles}from"./hooks/useWidgetStyles";export*from"./hooks/html";export{useScroll}from"./hooks/useScroll";export{usePrevious}from"./hooks/usePrevious";// --------------- HOCs --------------- //
|
|
48
|
-
export{withTheme}from"./hocs/withTheme";export{withRoute}from"./hocs/withRoute";export{withCurrentProduct}from"./hocs/withCurrentProduct";export{withForwardedRef}from"./hocs/withForwardedRef";export{withNavigation}from"./hocs/withNavigation";export{withWidgetSettings}from"./hocs/withWidgetSettings";export{withWidgetStyles}from"./hocs/withWidgetStyles";export{withApp}from"./hocs/withApp";// --------------- CONFIG --------------- //
|
|
49
|
-
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{isBeta}from"./config/isBeta";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";// -------------- HELPERS -------------- //
|
|
50
|
-
export{i18n,getWeekDaysOrder}from"./helpers/i18n";export{default as nl2br}from"./helpers/nl2br";export*from"./helpers/string";export{updateLegacyNavigationBar}from"./helpers/updateLegacyNavigationBar";export{getFullImageSource}from"./helpers/getFullImageSource";export{isIOSTheme}from"./helpers/isIOSTheme";export{isTouchDevice}from"./helpers/isTouchDevice";export{generateGoogleMapsDirectionsUrl}from"./helpers/googleMaps";export{hasWebBridge}from"./helpers/bridge";export{useScrollContainer}from"./helpers/scrollContainer";export{getDeviceTypeForCms}from"./helpers/deviceType";export*from"./helpers/featureFlag";// -------------- CONFIG -------------- //
|
|
51
|
-
export*from"./config/config.actions";export*from"./config/config.selectors";export*from"./config/config.streams";export*from"./initialization";// -------------- VALIDATION -------------- //
|
|
52
|
-
export*from"./validation";export{default as errorBehavior}from"./helpers/errorBehavior";export{makeGetShopSettingByKey,makeGetShopSettings,getIsLocationBasedShopping,getRestrictMultiLocationOrders,getFulfillmentSchedulingEnabled,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getDefaultCurrency,getEnableWebIndexing,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode,getWishlistItemQuantityEnabled,getWishlistItemNotesEnabled,getShowWishlistItemsCountBadge,getLoadWishlistOnAppStartEnabled}from"./selectors";export{SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED,EUNAUTHORIZED,EAUTHENTICATION}from"./constants";
|
|
1
|
+
/** @module core */ // --------------- CORE --------------- //
|
|
2
|
+
// Emitters
|
|
3
|
+
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';// --------------- STORE --------------- //
|
|
4
|
+
export*from'@shopgate/pwa-common/store';// --------------- CONFIG --------------- //
|
|
5
|
+
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";export*from"./actions";export*from"./action-creators";export*from"./classes";export*from"./collections";export*from"./commands";export*from"./constants";export*from"./contexts";export*from"./helpers";export*from"./hocs";export*from"./hooks";export*from"./initialization";export*from"./providers";export*from"./selectors";export*from"./streams";export*from"./validation";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{withScope,captureMessage,Severity as SentrySeverity}from'@sentry/browser';import moment from'moment';import{configureStore}from'@shopgate/pwa-common/store';import{appWillInit,appWillStart}from'@shopgate/pwa-common/action-creators/app';import{i18n}from'@shopgate/engage/core';import fetchClientInformation from'@shopgate/pwa-common/actions/client/fetchClientInformation';import appConfig from'@shopgate/pwa-common/helpers/config';import{receiveShopSettings,receiveMerchantSettings,errorShopSettings}from"../action-creators";var _appConfig$locales=appConfig.locales
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{withScope,captureMessage,Severity as SentrySeverity}from'@sentry/browser';import moment from'moment';import{configureStore}from'@shopgate/pwa-common/store';import{appWillInit,appWillStart}from'@shopgate/pwa-common/action-creators/app';import{i18n}from'@shopgate/engage/core';import fetchClientInformation from'@shopgate/pwa-common/actions/client/fetchClientInformation';import appConfig from'@shopgate/pwa-common/helpers/config';import{appInitialization,configuration}from'@shopgate/engage/core/collections';import{CONFIGURATION_COLLECTION_KEY_BASE_URL}from'@shopgate/engage/core/constants';import{getAppBaseUrl}from'@shopgate/engage/core/helpers';import{receiveShopSettings,receiveMerchantSettings,errorShopSettings}from"../action-creators";var _appConfig$locales=appConfig.locales,_appConfig$locales2=_appConfig$locales===void 0?{}:_appConfig$locales,_appConfig$locales2$c=_appConfig$locales2.currency,currencyLocale=_appConfig$locales2$c===void 0?null:_appConfig$locales2$c,settingsUrl=appConfig.settingsUrl,merchantSettingsUrl=appConfig.merchantSettingsUrl;var REQUEST_TIMEOUT=3000;/**
|
|
2
2
|
* Injects a script tag to fetch the shop settings JSONP.
|
|
3
3
|
* @param {string} id The script id
|
|
4
4
|
* @param {string} src The script url
|
|
@@ -16,4 +16,6 @@ injectScript('shop-settings-jsonp',settingsUrl,function(error){withScope(functio
|
|
|
16
16
|
* @param {Object} locales An object with locales.
|
|
17
17
|
* @param {Function} reducers The reducers from the theme.
|
|
18
18
|
* @param {Array} subscribers The subscribers to the streams middleware.
|
|
19
|
-
*/export var initialize=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locales,reducers,subscribers){var store;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
19
|
+
*/export var initialize=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locales,reducers,subscribers){var store;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:moment.locale(process.env.LOCALE);i18n.init({locales:locales,lang:process.env.LOCALE,currencyLocale:currencyLocale});store=configureStore(reducers,subscribers);_context.prev=3;_context.next=6;return store.dispatch(fetchClientInformation());case 6:_context.next=10;break;case 8:_context.prev=8;_context.t0=_context["catch"](3);case 10:// Save the base url inside the configuration collection before any other code can apply
|
|
20
|
+
// url manipulations.
|
|
21
|
+
configuration.set(CONFIGURATION_COLLECTION_KEY_BASE_URL,getAppBaseUrl());store.dispatch(appWillInit("".concat(window.location.pathname).concat(window.location.search)));_context.prev=12;_context.next=15;return fetchSettings(store);case 15:_context.next=19;break;case 17:_context.prev=17;_context.t1=_context["catch"](12);case 19:_context.next=21;return appInitialization.initialize({dispatch:store.dispatch,getState:store.getState});case 21:store.dispatch(appWillStart("".concat(window.location.pathname).concat(window.location.search)));return _context.abrupt("return",{store:store});case 23:case"end":return _context.stop();}},_callee,null,[[3,8],[12,17]]);}));return function initialize(_x,_x2,_x3){return _ref.apply(this,arguments);};}();
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import appConfig from'@shopgate/pwa-common/helpers/config';import{APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import event from'@shopgate/pwa-core/classes/Event';import AppContext from"../contexts/AppContext";/**
|
|
2
2
|
* The AppProvider component.
|
|
3
|
-
*/var AppProvider=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var AppProvider=/*#__PURE__*/function(_Component){function AppProvider(props){var _this2;_classCallCheck(this,AppProvider);_this2=_callSuper(this,AppProvider,[props]);/**
|
|
4
|
+
* Sets the isVisible state to TRUE.
|
|
5
|
+
*/_defineProperty(_this2,"setVisible",function(){_this2.setIsVisible(true);});/**
|
|
6
|
+
* Sets the isVisible state to TRUE.
|
|
7
|
+
*/_defineProperty(_this2,"setHidden",function(){_this2.setIsVisible(false);});_this2.state={isVisible:true};event.addCallback(APP_EVENT_VIEW_WILL_APPEAR,_this2.setVisible);event.addCallback(APP_EVENT_VIEW_WILL_DISAPPEAR,_this2.setHidden);return _this2;}/**
|
|
4
8
|
* Removes the event listeners when the component unmounts.
|
|
5
|
-
*/_createClass(AppProvider,[{key:"componentWillUnmount",value:function componentWillUnmount(){event.removeCallback(APP_EVENT_VIEW_WILL_APPEAR,this.setVisible);event.removeCallback(APP_EVENT_VIEW_WILL_DISAPPEAR,this.setHidden);}/**
|
|
9
|
+
*/_inherits(AppProvider,_Component);return _createClass(AppProvider,[{key:"componentWillUnmount",value:function componentWillUnmount(){event.removeCallback(APP_EVENT_VIEW_WILL_APPEAR,this.setVisible);event.removeCallback(APP_EVENT_VIEW_WILL_DISAPPEAR,this.setHidden);}/**
|
|
6
10
|
* Returns the context value to be passed to consumers.
|
|
7
11
|
* @returns {Object}
|
|
8
|
-
*/},{key:"setIsVisible"
|
|
12
|
+
*/},{key:"provided",get:function get(){return{appConfig:appConfig,isVisible:this.state.isVisible,setIsVisible:this.setIsVisible};}},{key:"setIsVisible",value:/**
|
|
9
13
|
* Sets the isVisible state. It indicates if Engage is visible,
|
|
10
14
|
* or another WebView is presented to the user.
|
|
11
15
|
* @param {boolean} value The new value
|
|
12
|
-
*/
|
|
16
|
+
*/function setIsVisible(value){this.setState({isVisible:value});}/**
|
|
13
17
|
* @returns {JSX}
|
|
14
|
-
*/},{key:"render",value:function render(){return React.createElement(AppContext.Provider,{value:this.provided},this.props.children);}}
|
|
15
|
-
* Sets the isVisible state to TRUE.
|
|
16
|
-
*/}]);return AppProvider;}(Component);export default AppProvider;
|
|
18
|
+
*/},{key:"render",value:function render(){return React.createElement(AppContext.Provider,{value:this.provided},this.props.children);}}]);}(Component);export default AppProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as LoadingProvider}from'@shopgate/pwa-common/providers/loading';export{default as LoadingContext}from'@shopgate/pwa-common/providers/loading/context';export{default as ToastProvider}from'@shopgate/pwa-common/providers/toast';export{default as ToastContext}from'@shopgate/pwa-common/providers/toast/context';export{default as AppProvider}from"./AppProvider";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{produce}from'immer';import{PWA_DID_APPEAR,PWA_DID_DISAPPEAR}from'@shopgate/pwa-common/constants/ActionTypes';var defaultState={webViewVisible:true};/**
|
|
2
|
+
* Stores app state
|
|
3
|
+
* @param {Object} [state={}] The current state.
|
|
4
|
+
* @param {Object} action The action object.
|
|
5
|
+
* @returns {Object} The new state.
|
|
6
|
+
*/export default function app(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case PWA_DID_APPEAR:{draft.webViewVisible=true;break;}case PWA_DID_DISAPPEAR:{draft.webViewVisible=false;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}
|
package/core/reducers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{combineReducers}from'redux';import config from"../config/config.reducers";import shopSettings from"./shopSettings";import merchantSettings from"./merchantSettings";export var settings=combineReducers({config:config,shopSettings:shopSettings,merchantSettings:merchantSettings});
|
|
1
|
+
import{combineReducers}from'redux';import config from"../config/config.reducers";import shopSettings from"./shopSettings";import merchantSettings from"./merchantSettings";export{default as app}from"./app";export var settings=combineReducers({config:config,shopSettings:shopSettings,merchantSettings:merchantSettings});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{produce}from'immer';import appConfig from'@shopgate/pwa-common/helpers/config';import{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING}from"../constants";var _appConfig$locales=appConfig.locales,_appConfig$locales2=_appConfig$locales===void 0?{}:_appConfig$locales,_appConfig$locales2$c=_appConfig$locales2.currency,currency=_appConfig$locales2$c===void 0?null:_appConfig$locales2$c;var defaultState=_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,false),MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,false),MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,false),MERCHANT_SETTINGS_DEFAULT_CURRENCY,currency),MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,false);/**
|
|
2
2
|
* Stores the merchant settings.
|
|
3
3
|
* @param {Object} [state={}] The current state.
|
|
4
4
|
* @param {Object} action The action object.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _defaultState;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 _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{produce}from'immer';import{SORT_RELEVANCE}from'@shopgate/pwa-common/constants/DisplayOptions';import{RECEIVE_SHOP_SETTINGS,ERROR_SHOP_SETTINGS,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_WISHLIST_ITEM_QUANTITY_ENABLED,SHOP_SETTING_WISHLIST_ITEM_NOTES_ENABLED,SHOP_SETTING_LOAD_WISHLIST_ON_APP_START_ENABLED,SHOP_SETTING_SHOW_WISHLIST_ITEMS_COUNT_BADGE}from"../constants";var defaultState=(_defaultState={},_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defaultState,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,null),SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,null),SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,null),SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,true),SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,true),SHOP_SETTING_PRODUCTS_SORT_ORDER,SORT_RELEVANCE),SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,2),SHOP_SETTING_IMAGES,_defineProperty(_defineProperty(_defineProperty({},SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,null),SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,null),SHOP_SETTING_IMAGES_FAVICON,null)),SHOP_SETTING_WISHLIST_ITEM_QUANTITY_ENABLED,false),SHOP_SETTING_WISHLIST_ITEM_NOTES_ENABLED,false),_defineProperty(_defineProperty(_defaultState,SHOP_SETTING_LOAD_WISHLIST_ON_APP_START_ENABLED,true),SHOP_SETTING_SHOW_WISHLIST_ITEMS_COUNT_BADGE,true));/**
|
|
2
2
|
* Stores the product locations by the location code.
|
|
3
3
|
* @param {Object} [state={}] The current state.
|
|
4
4
|
* @param {Object} action The action object.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{createSelector}from'reselect';/**
|
|
2
|
+
* Retrieves the app state from the store.
|
|
3
|
+
* @param {Object} state The current application state.
|
|
4
|
+
* @return {Object} The locations state.
|
|
5
|
+
*/var getState=function getState(state){return state.app;};/**
|
|
6
|
+
* Checks if the app webview is currently visible
|
|
7
|
+
* @param {Object} state The application state.
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/export var getIsAppWebViewVisible=createSelector(getState,function(app){return app.webViewVisible;});
|
package/core/selectors/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode,getWishlistItemQuantityEnabled,getWishlistItemNotesEnabled,getShowWishlistItemsCountBadge,getLoadWishlistOnAppStartEnabled}from"./shopSettings";export{getIsLocationBasedShopping,getFulfillmentSchedulingEnabled,getRestrictMultiLocationOrders,getDefaultCurrency,getEnableWebIndexing,getProductShowAlternativeLocation,getProductListShowInventory}from"./merchantSettings";
|
|
1
|
+
export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode,getWishlistItemQuantityEnabled,getWishlistItemNotesEnabled,getShowWishlistItemsCountBadge,getLoadWishlistOnAppStartEnabled}from"./shopSettings";export{getIsLocationBasedShopping,getFulfillmentSchedulingEnabled,getRestrictMultiLocationOrders,getDefaultCurrency,getEnableWebIndexing,getProductShowAlternativeLocation,getProductListShowInventory}from"./merchantSettings";export*from"../config/config.selectors";export*from"./app";// --------------- CLIENT --------------- //
|
|
2
|
+
export*from'@shopgate/pwa-common/selectors/client';// --------------- ROUTER --------------- //
|
|
3
|
+
export*from'@shopgate/pwa-common/selectors/router';export*from'@shopgate/pwa-common/selectors/history';// --------------- URL --------------- //
|
|
4
|
+
export*from'@shopgate/pwa-common/selectors/url';// --------------- MENU --------------- //
|
|
5
|
+
export*from'@shopgate/pwa-common/selectors/menu';// --------------- MODAL --------------- //
|
|
6
|
+
export*from'@shopgate/pwa-common/selectors/modal';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _toArray(arr){return _arrayWithHoles(arr)||_iterableToArray(arr)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArray(iter){if(Symbol.iterator in Object(iter)||Object.prototype.toString.call(iter)==="[object Arguments]")return Array.from(iter);}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{Observable}from'rxjs/Observable';import{ACTION_RESET}from'@virtuous/conductor';import{main$}from'@shopgate/pwa-common/streams/main';import{routeDidEnter$}from'@shopgate/pwa-common/streams';import{routeDidEnter}from'@shopgate/pwa-common/action-creators';import{getRouterStack}from'@shopgate/engage/core/selectors';import{RELOAD_APP}from"../constants";import{historyReset}from"../actions";/**
|
|
2
|
+
* Gets triggered when the app is supposed to be reloaded
|
|
3
|
+
* @type {Observable}
|
|
4
|
+
*/export var reloadApp$=main$.filter(function(_ref){var action=_ref.action;return action.type===RELOAD_APP;}).switchMap(function(params){var dispatch=params.dispatch,getState=params.getState;var _getRouterStack=getRouterStack(getState()),_getRouterStack2=_toArray(_getRouterStack),initialRoute=_getRouterStack2[0],otherRoutes=_getRouterStack2.slice(1);if(!otherRoutes.length){// When the initial route is the only route inside the router stack, routeDidEnter$ will
|
|
5
|
+
// not always be triggered, so just simulate it here.
|
|
6
|
+
return Observable.of(_extends({},params,{action:routeDidEnter(initialRoute,ACTION_RESET)}));}// The PWA can't be reloaded on any route, so we first need to reset to the first history entry
|
|
7
|
+
dispatch(historyReset());return routeDidEnter$// Emit when initial route is reached
|
|
8
|
+
.filter(function(_ref2){var action=_ref2.action;return action.route.id===(initialRoute===null||initialRoute===void 0?void 0:initialRoute.id);});});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{main$}from'@shopgate/pwa-common/streams/main';import{PERMISSION_ID_PUSH,PERMISSION_ID_CAMERA,PERMISSION_ID_LOCATION,PERMISSION_ID_PHONE,PERMISSION_ID_BACKGROUND_APP_REFRESH,APP_PERMISSION_STATUS_RECEIVED}from'@shopgate/engage/core/constants';/**
|
|
2
|
+
* Gets triggered when a permission status was received from the app.
|
|
3
|
+
* @type {Observable}
|
|
4
|
+
*/export var appPermissionStatusReceived$=main$.filter(function(_ref){var action=_ref.action;return action.type===APP_PERMISSION_STATUS_RECEIVED;});/**
|
|
5
|
+
* Gets triggered when a push permission status was received from the app.
|
|
6
|
+
* @type {Observable}
|
|
7
|
+
*/export var appPermissionStatusPushReceived$=appPermissionStatusReceived$.filter(function(_ref2){var action=_ref2.action;return action.permissionId===PERMISSION_ID_PUSH;});/**
|
|
8
|
+
* Gets triggered when a camera permission status was received from the app.
|
|
9
|
+
* @type {Observable}
|
|
10
|
+
*/export var appPermissionStatusCameraReceived$=appPermissionStatusReceived$.filter(function(_ref3){var action=_ref3.action;return action.permissionId===PERMISSION_ID_CAMERA;});/**
|
|
11
|
+
* Gets triggered when a location permission status was received from the app.
|
|
12
|
+
* @type {Observable}
|
|
13
|
+
*/export var appPermissionStatusLocationReceived$=appPermissionStatusReceived$.filter(function(_ref4){var action=_ref4.action;return action.permissionId===PERMISSION_ID_LOCATION;});/**
|
|
14
|
+
* Gets triggered when a phone permission status was received from the app.
|
|
15
|
+
* @type {Observable}
|
|
16
|
+
*/export var appPermissionStatusPhoneReceived$=appPermissionStatusReceived$.filter(function(_ref5){var action=_ref5.action;return action.permissionId===PERMISSION_ID_PHONE;});/**
|
|
17
|
+
* Gets triggered when a backgroundAppRefresh permission status was received from the app.
|
|
18
|
+
* @type {Observable}
|
|
19
|
+
*/export var appPermissionStatusBackgroundAppRefreshReceived$=appPermissionStatusReceived$.filter(function(_ref6){var action=_ref6.action;return action.permissionId===PERMISSION_ID_BACKGROUND_APP_REFRESH;});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export*from"./app";export*from"./appPermissions";export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';// --------------- APP --------------- //
|
|
2
|
+
export*from'@shopgate/pwa-common/streams/app';// --------------- CLIENT --------------- //
|
|
3
|
+
export*from'@shopgate/pwa-common/streams/client';// --------------- ROUTER --------------- //
|
|
4
|
+
export*from'@shopgate/pwa-common/streams/router';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{appWillStart$}from'@shopgate/pwa-common/streams';import{configuration}from'@shopgate/engage/core/collections';import{CONFIGURATION_COLLECTION_KEY_BASE_URL}from'@shopgate/engage/core/constants';import{reloadApp$}from"../streams";import{reloadApp}from"../action-creators";/**
|
|
2
|
+
* App subscriptions
|
|
3
|
+
* @param {Function} subscribe The subscribe function
|
|
4
|
+
*/export default function app(subscribe){subscribe(appWillStart$,function(_ref){var dispatch=_ref.dispatch;// Add global function to enable PWA reload from the console
|
|
5
|
+
window.reloadSGApp=function(){dispatch(reloadApp());};});subscribe(reloadApp$,function(){// A deployed app can only be reloaded on the base url. So we first set this as current route
|
|
6
|
+
// before the reload happens.
|
|
7
|
+
window.history.replaceState({},null,configuration.get(CONFIGURATION_COLLECTION_KEY_BASE_URL));window.location.reload();});}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
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=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _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,{useCallback,useMemo,useLayoutEffect,useState,useEffect,useRef}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{MODAL_VARIANT_SELECT}from'@shopgate/pwa-ui-shared/Dialog/constants';import{ProductImage,ITEM_PATH,PriceInfo,isBaseProduct as isBaseProductSelector,isProductOrderable,hasProductVariants,ProductListEntryProvider}from'@shopgate/engage/product';import{bin2hex,showModal as showModalAction,historyPush as historyPushAction,getThemeSettings,i18n}from'@shopgate/engage/core';import{hasNewServices}from'@shopgate/engage/core/helpers';import{Link,TextLink,SurroundPortals}from'@shopgate/engage/components';import{makeIsRopeProductOrderable,getPreferredLocation,StockInfoLists}from'@shopgate/engage/locations';import{FAVORITES_PRODUCT_NAME,FAVORITES_PRODUCT_PRICE,FAVORITES_ADD_TO_CART,FAVORITES_AVAILABILITY_TEXT}from'@shopgate/engage/favorites';import{broadcastLiveMessage}from'@shopgate/engage/a11y';import{responsiveMediaQuery}from'@shopgate/engage/styles';import Price from'@shopgate/pwa-ui-shared/Price';import PriceStriked from'@shopgate/pwa-ui-shared/PriceStriked';import AddToCart from'@shopgate/pwa-ui-shared/AddToCartButton';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{updateFavorite}from'@shopgate/pwa-common-commerce/favorites/actions/toggleFavorites';import{openFavoritesCommentDialog}from'@shopgate/pwa-common-commerce/favorites/action-creators';import AvailableText from'@shopgate/pwa-ui-shared/Availability';import classNames from'classnames';import Remove from"../RemoveButton";import ItemCharacteristics from"./ItemCharacteristics";import ItemQuantity from"./ItemQuantity";import ItemNotes from"./ItemNotes";import{FAVORITES_LIST_ITEM,FAVORITES_NOTES,FAVORITES_QUANTITY}from"../../constants/Portals";var variables=themeConfig.variables;/**
|
|
2
2
|
* @return {Function} The extended component props.
|
|
3
3
|
*/var makeMapStateToProps=function makeMapStateToProps(){var isRopeProductOrderable=makeIsRopeProductOrderable(function(state,props){var _getPreferredLocation;return(_getPreferredLocation=getPreferredLocation(state,props))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code;},function(state,props){return props.variantId||props.productId||null;});return function(state,props){return{isBaseProduct:isBaseProductSelector(state,props),hasVariants:hasProductVariants(state,props),isOrderable:isProductOrderable(state,props),isRopeProductOrderable:isRopeProductOrderable(state,props)};};};/**
|
|
4
4
|
* @param {Function} dispatch Dispatch.
|
|
5
5
|
* @returns {Object}
|
|
6
|
-
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{showModal:function showModal(){return dispatch(showModalAction.apply(void 0,arguments));},historyPush:function historyPush(){return dispatch(historyPushAction.apply(void 0,arguments));},updateFavoriteItem:function updateFavoriteItem(productId,listId,quantity,notes){dispatch(updateFavorite(productId,listId,quantity,notes));},openCommentDialog:function openCommentDialog(productId,listId){return dispatch(openFavoritesCommentDialog(productId,listId));}};};var styles={root:css({display:'flex',position:'relative','&:not(:last-child)':{marginBottom:16}}).toString(),imageContainer:css((
|
|
6
|
+
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{showModal:function showModal(){return dispatch(showModalAction.apply(void 0,arguments));},historyPush:function historyPush(){return dispatch(historyPushAction.apply(void 0,arguments));},updateFavoriteItem:function updateFavoriteItem(productId,listId,quantity,notes){dispatch(updateFavorite(productId,listId,quantity,notes));},openCommentDialog:function openCommentDialog(productId,listId){return dispatch(openFavoritesCommentDialog(productId,listId));}};};var styles={root:css({display:'flex',position:'relative','&:not(:last-child)':{marginBottom:16}}).toString(),imageContainer:css(_defineProperty(_defineProperty(_defineProperty({flex:0.4,marginRight:18},responsiveMediaQuery('>=xs',{appAlways:true}),{maxWidth:120,minWidth:80}),responsiveMediaQuery('>=md',{webOnly:true}),{maxWidth:120,minWidth:80}),responsiveMediaQuery('>=md',{webOnly:true}),{width:120,flex:'none'})).toString(),infoContainer:css({flex:1,display:'flex',flexDirection:'column',flexWrap:'wrap',gap:8}).toString(),infoContainerRow:css({flexDirection:'row',display:'flex',justifyContent:'space-between'}).toString(),quantityContainer:css({flexDirection:'row',display:'flex',alignItems:'center',flexWrap:'wrap',gap:16}).toString(),priceContainer:css({minWidth:100}).toString(),priceInfo:css({wordBreak:'break-word',fontSize:'0.875rem',lineHeight:'0.875rem',color:'var(--color-text-low-emphasis)',padding:"".concat(variables.gap.xsmall,"px 0")}).toString(),titleWrapper:css({display:'flex',flexDirection:'column',gap:8}).toString(),titleContainer:css({marginRight:10,flex:1}).toString(),title:css({fontSize:17,fontWeight:600}).toString(),removeContainer:css({display:'flex',flexShrink:0,alignItems:'flex-start'})};/**
|
|
7
7
|
* Favorite Item component
|
|
8
8
|
* @return {JSX}
|
|
9
|
-
*/var FavoriteItem=function FavoriteItem(_ref){var _product$price,_product$price2,_product$price3;var listId=_ref.listId,product=_ref.product,notes=_ref.notes,quantity=_ref.quantity,remove=_ref.remove,addToCart=_ref.addToCart,isBaseProduct=_ref.isBaseProduct,isOrderable=_ref.isOrderable,isRopeProductOrderable=_ref.isRopeProductOrderable,hasVariants=_ref.hasVariants,showModal=_ref.showModal,historyPush=_ref.historyPush,updateFavoriteItem=_ref.updateFavoriteItem,openCommentDialog=_ref.openCommentDialog;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var _useState=useState(!isOrderable&&!hasVariants),_useState2=_slicedToArray(_useState,2),isDisabled=_useState2[0],setIsDisabled=_useState2[1];var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=typeof specialPrice==='number'&&specialPrice
|
|
10
|
-
showModal({title:null,type:MODAL_VARIANT_SELECT,message:'favorites.modal.message',confirm:'favorites.modal.confirm',dismiss:'common.cancel',params:{productId:product.id}});return false;}if(
|
|
9
|
+
*/var FavoriteItem=function FavoriteItem(_ref){var _product$price,_product$price2,_product$price3;var listId=_ref.listId,product=_ref.product,notes=_ref.notes,quantity=_ref.quantity,remove=_ref.remove,addToCart=_ref.addToCart,isBaseProduct=_ref.isBaseProduct,isOrderable=_ref.isOrderable,isRopeProductOrderable=_ref.isRopeProductOrderable,hasVariants=_ref.hasVariants,showModal=_ref.showModal,historyPush=_ref.historyPush,updateFavoriteItem=_ref.updateFavoriteItem,openCommentDialog=_ref.openCommentDialog;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var _useState=useState(!isOrderable&&!hasVariants),_useState2=_slicedToArray(_useState,2),isDisabled=_useState2[0],setIsDisabled=_useState2[1];var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=typeof specialPrice==='number'&&specialPrice>0&&specialPrice>defaultPrice;var price=hasStrikePrice?specialPrice:defaultPrice;var characteristics=(product===null||product===void 0?void 0:product.characteristics)||[];var productLink="".concat(ITEM_PATH,"/").concat(bin2hex(product.id));var notesButtonRef=useRef();var _useState3=useState(quantity),_useState4=_slicedToArray(_useState3,2),internalQuantity=_useState4[0],setInternalQuantity=_useState4[1];useEffect(function(){setInternalQuantity(quantity);},[quantity]);useLayoutEffect(function(){setIsDisabled(!isOrderable&&!hasVariants);},[hasVariants,isOrderable]);var handleOpenComment=useCallback(function(e){e.preventDefault();e.stopPropagation();openCommentDialog(product.id,listId);},[listId,openCommentDialog,product.id]);var handleAddToCart=useCallback(function(e){e.preventDefault();e.stopPropagation();if(isBaseProduct&&hasVariants){// Called for a parent product. User needs to confirm the navigation to the PDP
|
|
10
|
+
showModal({title:null,type:MODAL_VARIANT_SELECT,message:'favorites.modal.message',confirm:'favorites.modal.confirm',dismiss:'common.cancel',params:{productId:product.id}});return false;}if(hasNewServices()&&!isRopeProductOrderable){// Product is not orderable for ROPE. So users need to do some corrections. Just redirect.
|
|
11
11
|
historyPush({pathname:productLink});return false;}broadcastLiveMessage('product.adding_item',{params:{count:1}});return addToCart(e);},[addToCart,hasVariants,historyPush,isBaseProduct,isRopeProductOrderable,product.id,productLink,showModal]);var commonPortalProps=useMemo(function(){var availability=product.availability,id=product.id,name=product.name;return{availability:availability,characteristics:characteristics,id:id,name:name,price:price,listId:listId};},[characteristics,listId,price,product]);var ctaPortalProps=useMemo(function(){return{isLoading:false,noShadow:false,listId:listId,isBaseProduct:isBaseProduct,isDisabled:isDisabled,productId:product.id,handleRemoveFromCart:remove,handleAddToCart:handleAddToCart};},[handleAddToCart,isBaseProduct,isDisabled,listId,product.id,remove]);var handleChangeQuantity=useCallback(function(newQuantity){// Do nothing when quantity didn't change
|
|
12
12
|
if(newQuantity===quantity)return;updateFavoriteItem(product.id,listId,newQuantity,notes);},[listId,notes,product.id,quantity,updateFavoriteItem]);var handleDeleteComment=useCallback(function(event){event.preventDefault();event.stopPropagation();updateFavoriteItem(product.id,listId,quantity,'');setTimeout(function(){if(notesButtonRef===null||notesButtonRef===void 0?void 0:notesButtonRef.current){// Focus the add button after item deletion to improve a11y
|
|
13
13
|
notesButtonRef.current.focus();}broadcastLiveMessage('favorites.comments.removed');},300);},[listId,product.id,quantity,updateFavoriteItem]);return React.createElement(ProductListEntryProvider,{productId:product.id},React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM,portalProps:product},React.createElement("div",{className:styles.root},React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink,"aria-hidden":true},React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),React.createElement("div",{className:styles.infoContainer},React.createElement("div",{className:classNames(styles.infoContainerRow)},React.createElement("div",{className:styles.titleWrapper},React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_NAME,portalProps:commonPortalProps},React.createElement(TextLink,{href:productLink,tag:"span",className:styles.titleContainer},React.createElement("span",{className:styles.title// eslint-disable-next-line react/no-danger
|
|
14
|
-
,dangerouslySetInnerHTML:{__html:"".concat(product.name)}})))),React.createElement("div",{className:styles.removeContainer},React.createElement(Remove,{onClick:remove}))),React.createElement(ItemCharacteristics,{characteristics:characteristics}),React.createElement(StockInfoLists,{product:product}),React.createElement("div",{className:styles.infoContainerRow},React.createElement("div",{className:styles.quantityContainer},React.createElement(SurroundPortals,{portalName:FAVORITES_QUANTITY,portalProps:commonPortalProps},React.createElement(ItemQuantity,{quantity:internalQuantity,onChange:handleChangeQuantity})),React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},React.createElement("div",{className:styles.priceContainer},hasStrikePrice?React.createElement(PriceStriked,{value:defaultPrice,currency:currency}):null,React.createElement(Price,{currency:currency,discounted:hasStrikePrice,
|
|
14
|
+
,dangerouslySetInnerHTML:{__html:"".concat(product.name)}})))),React.createElement("div",{className:styles.removeContainer},React.createElement(Remove,{onClick:remove}))),React.createElement(ItemCharacteristics,{characteristics:characteristics}),!hasNewServices()?React.createElement(SurroundPortals,{portalName:FAVORITES_AVAILABILITY_TEXT,portalProps:commonPortalProps},React.createElement(AvailableText,{text:commonPortalProps.availability.text,state:commonPortalProps.availability.state,showWhenAvailable:true,className:styles.availability})):React.createElement(StockInfoLists,{product:product}),React.createElement("div",{className:styles.infoContainerRow},React.createElement("div",{className:styles.quantityContainer},React.createElement(SurroundPortals,{portalName:FAVORITES_QUANTITY,portalProps:commonPortalProps},React.createElement(ItemQuantity,{quantity:internalQuantity,onChange:handleChangeQuantity})),React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},React.createElement("div",{className:styles.priceContainer},hasStrikePrice?React.createElement(PriceStriked,{value:defaultPrice,currency:currency}):null,React.createElement(Price,{currency:currency,discounted:hasStrikePrice,unitPrice:price}),React.createElement(PriceInfo,{product:product,currency:currency,className:styles.priceInfo})))),React.createElement(SurroundPortals,{portalName:FAVORITES_ADD_TO_CART,portalProps:ctaPortalProps},React.createElement(AddToCart,{onClick:handleAddToCart,isLoading:false,isDisabled:isDisabled,"aria-label":i18n.text('product.add_to_cart')}))),React.createElement(SurroundPortals,{portalName:FAVORITES_NOTES,portalProps:commonPortalProps},React.createElement(ItemNotes,{notes:notes,onClickDeleteComment:handleDeleteComment,onClickOpenComment:handleOpenComment,notesButtonRef:notesButtonRef}))))));};FavoriteItem.defaultProps={isBaseProduct:true,isOrderable:true,isRopeProductOrderable:true,hasVariants:false,notes:undefined,quantity:1};export default connect(makeMapStateToProps,mapDispatchToProps)(FavoriteItem);
|
|
@@ -9,7 +9,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
9
9
|
* @param {Object} dispatch Dispatch
|
|
10
10
|
* @param {Object} props The component props
|
|
11
11
|
* @returns {Object}
|
|
12
|
-
*/var mapDispatchToProps=function mapDispatchToProps(dispatch,props){return{remove:function(){var _remove=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(id){var confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
12
|
+
*/var mapDispatchToProps=function mapDispatchToProps(dispatch,props){return{remove:function(){var _remove=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(id){var confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(showModal({message:'favorites.delete_list_modal.message',title:'favorites.delete_list_modal.title',params:{name:props.name}}));case 2:confirmed=_context.sent;if(confirmed){props.remove(id);}case 4:case"end":return _context.stop();}},_callee);}));function remove(_x){return _remove.apply(this,arguments);}return remove;}()};};/**
|
|
13
13
|
* Favorite List component
|
|
14
14
|
* @return {JSX}
|
|
15
15
|
*/var FavoriteList=function FavoriteList(_ref3){var id=_ref3.id,name=_ref3.name,items=_ref3.items,_rename=_ref3.rename,remove=_ref3.remove,removeItem=_ref3.removeItem,_addToCart=_ref3.addToCart;return React.createElement(Card,{className:styles.root},React.createElement(Accordion,{className:"",openWithChevron:true,renderLabel:function renderLabel(){return React.createElement(FavoriteListLabel,{id:id,title:name,rename:function rename(newName){return _rename(id,newName);},remove:remove});},chevronPosition:"left",startOpened:true},React.createElement("div",{className:styles.divider}),items.length===0?React.createElement("span",null,i18n.text('favorites.empty')):null,React.createElement(ProductListTypeProvider,{type:"favoritesList"},items.filter(function(_ref4){var product=_ref4.product;return product;}).map(function(_ref5,index){var product=_ref5.product,notes=_ref5.notes,quantity=_ref5.quantity;return React.createElement("div",{key:product.id},React.createElement(Item,{product:product,notes:notes,quantity:quantity,listId:id,productId:product.id,addToCart:function addToCart(e){e.preventDefault();e.stopPropagation();return _addToCart(product,quantity);},remove:function remove(e){e.preventDefault();e.stopPropagation();removeItem(product.id);}}),index===items.length-1?null:React.createElement("div",{className:styles.divider}));}))));};export default connect(makeMapStateToProps,mapDispatchToProps)(FavoriteList);
|