@shopgate/engage 7.12.7-beta.1 → 7.20.0-beta.10
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 +2 -2
- package/account/actions/deleteContact.js +2 -2
- package/account/actions/deleteCustomer.js +2 -2
- package/account/actions/fetchContacts.js +2 -2
- package/account/actions/fetchCustomer.js +2 -2
- package/account/actions/updateContact.js +2 -2
- package/account/actions/updateCustomer.js +2 -2
- package/account/components/Account/Account.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/account/reducers/index.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.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 +9 -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 +4 -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 +3 -2
- package/cart/streams/index.js +1 -0
- 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/CheckoutPickupContactForm.config.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/GuestCheckout/GuestCheckoutPickupNotes.config.js +1 -1
- package/checkout/components/PaymentMethodButton/PaymentMethodButton.js +1 -1
- package/checkout/components/ShippingMethods/ShippingMethods.js +4 -4
- package/checkout/components/index.js +1 -1
- package/checkout/constants/index.js +1 -1
- package/checkout/index.js +3 -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 +3 -2
- 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/ConditionalWrapper/ConditionalWrapper.js +7 -2
- 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 +5 -4
- 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/ResponsiveContainer/ResponsiveContainer.js +2 -6
- package/components/ResponsiveContainer/breakpoints.js +2 -1
- package/components/ResponsiveContainer/hooks.js +20 -0
- package/components/ScrollHeader/index.js +2 -2
- package/components/ScrollHeader/style.js +1 -1
- 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 +15 -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 +7 -7
- package/favorites/components/List/List.js +18 -7
- package/favorites/components/List/ListAccordionLabel.js +4 -0
- package/favorites/components/List/ListContent.js +8 -0
- package/favorites/components/List/ListItemWrapper.js +6 -0
- package/favorites/components/List/styles.js +1 -0
- package/favorites/components/Lists/Lists.js +5 -5
- package/favorites/components/Lists/ListsModal.js +3 -2
- package/favorites/constants/index.js +1 -0
- package/filter/actions/index.js +1 -0
- package/filter/components/PriceSlider/index.js +9 -9
- package/filter/components/PriceSlider/style.js +1 -3
- package/filter/components/index.js +1 -0
- package/filter/constants/index.js +1 -1
- package/filter/helpers/buildFilterParamsForFetchFiltersRequest.js +9 -0
- package/filter/helpers/buildInitialFilters.js +1 -1
- 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 +2 -7
- package/filter/providers/SortProvider.helpers.js +1 -1
- package/filter/selectors/index.js +1 -1
- package/filter/streams/index.js +1 -0
- package/i18n/locale/cs-cz/countries.json +255 -0
- package/i18n/locale/de-de/countries.json +26 -28
- package/i18n/locale/el-gr/countries.json +255 -0
- package/i18n/locale/en-us/countries.json +12 -14
- package/i18n/locale/es-es/countries.json +65 -67
- package/i18n/locale/fi-fi/countries.json +255 -0
- package/i18n/locale/fr-fr/countries.json +85 -87
- package/i18n/locale/hu-hu/countries.json +255 -0
- package/i18n/locale/it-it/countries.json +11 -13
- package/i18n/locale/nl-nl/countries.json +42 -44
- package/i18n/locale/pl-pl/countries.json +255 -0
- package/i18n/locale/pt-pt/countries.json +128 -130
- package/i18n/locale/ro-ro/countries.json +255 -0
- package/i18n/locale/sv-se/countries.json +255 -0
- package/locations/action-creators/receiveInventories.js +3 -5
- package/locations/actions/fetchFulfillmentSlots.js +1 -1
- package/locations/actions/fetchProductLocations.js +2 -2
- package/locations/actions/setUserGeolocation.js +1 -1
- package/locations/actions/setUserSearchGeolocation.js +1 -1
- 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 +5 -3
- 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/index.js +1 -1
- 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 +7 -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/ProductSlider/index.js +4 -0
- package/product/components/ProductSlider/spec.js +1 -0
- package/product/components/ProductSlider/style.js +1 -0
- package/product/components/QuantityPicker/hooks.js +5 -0
- package/product/components/QuantityPicker/index.js +2 -2
- 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/UnitQuantityPicker/CartUnitQuantityPicker.js +2 -2
- package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +3 -2
- package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +6 -3
- package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +7 -0
- package/product/components/UnitQuantityPicker/index.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/hooks/index.js +1 -0
- package/product/index.js +4 -11
- package/product/providers/Product/connector.js +5 -0
- package/product/providers/Product/index.js +4 -0
- package/product/providers/index.js +1 -0
- package/product/selectors/product.js +24 -3
- 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 +9 -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 +12 -0
- package/registration/components/index.js +1 -0
- package/registration/index.js +1 -1
- 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/Header/components/ReviewsExcerpt/style.js +1 -2
- package/reviews/components/Reviews/components/List/index.js +3 -3
- package/reviews/components/Reviews/components/List/spec.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/index.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/style.js +1 -2
- 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 +3 -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/loadCustomStyles.js +2 -2
- package/styles/helpers/setPageBackgroundColor.js +2 -1
- package/styles/helpers/setPageContentWidth.js +2 -1
- package/styles/index.js +1 -1
- package/tracking/action-creators/cookieConsent.js +24 -0
- package/tracking/action-creators/index.js +1 -4
- package/tracking/actions/cookieConsent.js +21 -0
- package/tracking/actions/index.js +1 -0
- package/tracking/components/CookieConsentModal/connector.js +6 -0
- package/tracking/components/CookieConsentModal/index.js +9 -0
- package/tracking/components/CookieConsentModal/style.js +1 -0
- package/tracking/components/CookieConsentModal/tracking-opt-in.svg +18 -0
- package/tracking/components/PrivacySettings/connector.js +6 -0
- package/tracking/components/PrivacySettings/index.js +4 -0
- package/tracking/components/PrivacySettings/style.js +1 -0
- package/tracking/components/index.js +1 -1
- package/tracking/constants/index.js +1 -1
- package/tracking/reducers/cookieConsentModal.js +6 -0
- package/tracking/reducers/cookieSettings.js +6 -0
- package/tracking/reducers/index.js +1 -0
- package/tracking/selectors/cookieConsent.js +35 -0
- package/tracking/selectors/index.js +1 -4
- package/tracking/streams/cookieConsent.js +46 -0
- package/tracking/streams/index.js +1 -1
- package/tracking/subscriptions/analytics.js +11 -0
- package/tracking/subscriptions/cookieConsent.js +13 -0
- package/tracking/subscriptions/index.js +1 -4
- package/components/MessageBar/MessageBar.types.js +0 -0
- package/components/MessageBar/style.js +0 -1
- package/i18n/locale/ru-ru/countries.json +0 -251
- package/product/components/Availability/Availability.types.js +0 -1
- package/product/components/QuantityPicker/helpers.js +0 -5
- package/tracking/components/CookieConsent/CookieConsent.connector.js +0 -4
- package/tracking/components/CookieConsent/CookieConsent.js +0 -4
- package/tracking/components/CookieConsent/CookieConsentButtons.js +0 -3
- package/tracking/components/CookieConsent/CookieConsentCheckboxes.js +0 -3
- package/tracking/components/CookieConsent/CookieConsentContent.js +0 -4
- package/tracking/components/CookieConsent/CookieConsentMessage.js +0 -4
- package/tracking/components/CookieConsent/index.js +0 -1
- package/tracking/helpers/index.js +0 -7
- package/tracking/hooks/index.js +0 -4
- package/tracking/index.js +0 -1
- package/tracking/providers/CookieConsentProvider.connector.js +0 -4
- package/tracking/providers/CookieConsentProvider.js +0 -8
- /package/{tracking/providers/CookieConsentProvider.context.js → back-in-stock/providers/BackInStockSubscriptionsProvider.context.js} +0 -0
- /package/page/{NotFound.js → components/NotFound.js} +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
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 _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 _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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}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{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX}from"../Builder.constants";import{ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,ACTION_TYPE_SET_VISIBILITY,ACTION_TYPE_SET_VALUE,ACTION_TYPE_TRANSFORM,ACTION_SET_VALUE_FIXED,ACTION_SET_VALUE_COPY_FROM,ACTION_SET_VALUE_LENGTH_OF,ACTION_RULE_TYPE_NOT_IN,ACTION_RULE_TYPE_ONE_OF,ACTION_RULE_TYPE_BOOLEAN,ACTION_RULE_TYPE_REGEX,ACTION_RULE_DATA_TYPES,ACTION_RULES_CONCAT_METHOD_ALL,ACTION_RULES_CONCAT_METHOD_ANY,ACTION_RULES_CONCAT_METHOD_NONE}from"./ActionListener.constants";/**
|
|
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 _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 _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 _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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}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{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX}from"../Builder.constants";import{ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,ACTION_TYPE_SET_VISIBILITY,ACTION_TYPE_SET_VALUE,ACTION_TYPE_TRANSFORM,ACTION_SET_VALUE_FIXED,ACTION_SET_VALUE_COPY_FROM,ACTION_SET_VALUE_LENGTH_OF,ACTION_RULE_TYPE_NOT_IN,ACTION_RULE_TYPE_ONE_OF,ACTION_RULE_TYPE_BOOLEAN,ACTION_RULE_TYPE_REGEX,ACTION_RULE_DATA_TYPES,ACTION_RULES_CONCAT_METHOD_ALL,ACTION_RULES_CONCAT_METHOD_ANY,ACTION_RULES_CONCAT_METHOD_NONE}from"./ActionListener.constants";/**
|
|
2
2
|
* ActionListener and handler for the FormBuilder component
|
|
3
|
-
*/var ActionListener
|
|
3
|
+
*/var ActionListener=/*#__PURE__*/_createClass(/**
|
|
4
4
|
* Constructor
|
|
5
5
|
* @param {function(string)} getProvincesList Takes a country code and returns a list of provinces
|
|
6
6
|
* @param {Object} defaults Form defaults
|
|
7
|
-
*/function ActionListener(getProvincesList,defaults){var _this=this;_classCallCheck(this,ActionListener)
|
|
7
|
+
*/function ActionListener(getProvincesList,defaults){var _this=this;_classCallCheck(this,ActionListener);/**
|
|
8
|
+
* Takes the elements to be rendered by the FormBuilder and attaches available action listeners
|
|
9
|
+
* to the component.
|
|
10
|
+
* @param {FormElement[]} elementList List of all elements
|
|
11
|
+
*/_defineProperty(this,"attachAll",function(elementList){// Attach action listeners for element (context) actions
|
|
8
12
|
elementList.forEach(function(element){var elementActions=element.actions;if(element.type===ELEMENT_TYPE_PROVINCE){elementActions=elementActions||[];// Requires a country element to create a "update provinces" action
|
|
9
13
|
var countryElement=elementList.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});if(countryElement){// Attach new action, which is always triggered, when the (only) country element changes
|
|
10
14
|
elementActions.push({type:ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,rules:[{context:countryElement.id}]});}}if(elementActions===undefined){return;}// Create listeners for all supported actions
|
|
@@ -12,29 +16,82 @@ elementActions.forEach(function(action){var actionRules=action.rules||[];// Alwa
|
|
|
12
16
|
if(actionRules.length===0){// Define a basic rule if no rules given
|
|
13
17
|
actionRules.push({context:element.id});}// Actions do have a fixed structure which needs to be fulfilled
|
|
14
18
|
var normalizedAction=_extends({},action,{rules:actionRules});// Assign the action listeners to all contexts of the current element
|
|
15
|
-
actionRules.forEach(function(rule){_this.attach(element,normalizedAction,rule);});});});})
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
actionRules.forEach(function(rule){_this.attach(element,normalizedAction,rule);});});});});/**
|
|
20
|
+
* Attaches one or possibly multiple action listeners for the given rule
|
|
21
|
+
* @param {FormElement} element The current element that is modified by the action
|
|
22
|
+
* @param {FormFieldAction} action The action and it's params
|
|
23
|
+
* @param {FormFieldActionRule} rule The rule to check in case the action listener is triggered
|
|
24
|
+
*/_defineProperty(this,"attach",function(element,action,rule){var actionListener;switch(action.type){case ACTION_TYPE_UPDATE_PROVINCE_ELEMENT:{actionListener=_this.createUpdateProvinceElementHandler(element,action);break;}case ACTION_TYPE_SET_VISIBILITY:{// Visibility is special and uses the result of the evaluation itself
|
|
25
|
+
actionListener=_this.createSetVisibilityHandler(element,action);break;}case ACTION_TYPE_SET_VALUE:{actionListener=_this.createEvaluatedHandler(element,action,_this.createSetValueHandler(element,action));break;}case ACTION_TYPE_TRANSFORM:{actionListener=_this.createEvaluatedHandler(element,action,_this.createTransformHandler(element,action));break;}default:return;}_this.register(rule.context,actionListener);});/**
|
|
26
|
+
* Action listener creator to check all related rules before calling any further action listeners
|
|
27
|
+
* @param {FormElement} element The element for which the listener should be created for
|
|
28
|
+
* @param {FormFieldAction} action The action to be create a listener for
|
|
29
|
+
* @param {Function} actionListener The action listener to call if the rule applies
|
|
30
|
+
* @returns {Function} Returns a function to modify and return the modified state.
|
|
31
|
+
*/_defineProperty(this,"createEvaluatedHandler",function(element,action,actionListener){return function(prevState,nextState){// Apply rules before accepting any changes
|
|
32
|
+
if(!_this.evaluateRules(element,action,nextState)){return nextState;}return actionListener(prevState,nextState);};});/**
|
|
33
|
+
* Action listener creator to handle "updateCountryChange" action
|
|
34
|
+
* @param {FormElement} provinceEl The element for which the listener should be created for
|
|
35
|
+
* @param {FormFieldAction} action The action to be create a listener for
|
|
36
|
+
* @returns {Function} Returns a function to modify and return the modified state.
|
|
37
|
+
*/_defineProperty(this,"createUpdateProvinceElementHandler",function(provinceEl,action){return function(prevState,nextState){var countryElementId=action.rules[0].context;var countryValue=nextState.formData[countryElementId];var countryDefault=_this.defaults[countryElementId];var newState=_extends({},nextState);// Overwrite province with the form's default, if country matches the default as well
|
|
18
38
|
if(countryValue===countryDefault){newState.formData[provinceEl.id]=_this.defaults[provinceEl.id];}else{// Update province to first or no selection, based on "required" attribute
|
|
19
|
-
newState.formData[provinceEl.id]=!provinceEl.required?'':Object.keys(_this.getProvincesList(countryValue))[0];}return newState;};})
|
|
39
|
+
newState.formData[provinceEl.id]=!provinceEl.required?'':Object.keys(_this.getProvincesList(countryValue))[0];}return newState;};});/**
|
|
40
|
+
* Action listener creator to handle "setVisibility" actions
|
|
41
|
+
* @param {FormElement} element The element for which the listener should be created for
|
|
42
|
+
* @param {FormFieldAction} action The action to be create a listener for
|
|
43
|
+
* @returns {Function} Returns a function to modify and return the modified state.
|
|
44
|
+
*/_defineProperty(this,"createSetVisibilityHandler",function(element,action){return function(prevState,nextState){var newState=_extends({},nextState,{elementVisibility:_extends({},nextState.elementVisibility,_defineProperty({},element.id,_this.evaluateRules(element,action,nextState))),// Copy form data to be able to check changes and all follow up actions
|
|
20
45
|
formData:_extends({},nextState.formData)});if(newState.formData[element.id]===undefined&&newState.elementVisibility[element.id]){newState.formData[element.id]=_this.defaults[element.id];}else if(!newState.elementVisibility[element.id]&&newState.formData[element.id]!==undefined){delete newState.formData[element.id];}// Notify follow up listeners about the current change
|
|
21
|
-
if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};})
|
|
46
|
+
if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
|
|
47
|
+
* Action listener creator to handle "setValue" actions
|
|
48
|
+
* @param {FormElement} element The element for which the listener should be created for
|
|
49
|
+
* @param {FormFieldAction} action The action to be create a listener for
|
|
50
|
+
* @returns {Function} Returns the modified state.
|
|
51
|
+
*/_defineProperty(this,"createSetValueHandler",function(element,action){return function(prevState,nextState){if(_typeof(action.params)!=='object'||Array.isArray(action.params)){logger.error("Error: Invalid or missing form action in element '".concat(element.id,"'. ")+'Params must be in the format: { "type": string, "value": string }');return nextState;}var value=action.params.value;// Check correctness of value data type
|
|
22
52
|
switch(_typeof(value)){case'boolean':if(element.type!==ELEMENT_TYPE_CHECKBOX){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_CHECKBOX,"' data type for 'params.value' is: 'boolean'"));return nextState;}break;case'number':if(element.type!==ELEMENT_TYPE_NUMBER){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_NUMBER,"' data types for 'params.value' are: ")+"'number' and 'string'");return nextState;}break;case'string':if(element.type===ELEMENT_TYPE_CHECKBOX){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_CHECKBOX,"' data type for 'params.value' is: 'boolean'"));return nextState;}break;default:logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Can not use '".concat(_typeof(value),"' data for elements of type '").concat(element.type,"'"));return nextState;}// Perform action based on "setValue" type, defined in params
|
|
23
53
|
switch(action.params.type){case ACTION_SET_VALUE_LENGTH_OF:value="".concat(nextState.formData[action.params.value].length);break;case ACTION_SET_VALUE_COPY_FROM:value=nextState.formData[action.params.value];break;case undefined:case ACTION_SET_VALUE_FIXED:break;default:logger.error("Error: Invalid form action param 'type' in element '".concat(element.id,"'. ")+"Allowed param types are: '".concat(ACTION_SET_VALUE_LENGTH_OF,"', ")+"'".concat(ACTION_SET_VALUE_COPY_FROM,"', '").concat(ACTION_SET_VALUE_FIXED,"'"));return nextState;}var newState=_extends({},nextState,{formData:_extends({},nextState.formData,_defineProperty({},element.id,value))});// Notify follow up listeners about the current change, if there are any changes
|
|
24
|
-
if(nextState.formData[element.id]!==value){newState=_this.notify(element.id,prevState,newState);}return newState;};})
|
|
54
|
+
if(nextState.formData[element.id]!==value){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
|
|
55
|
+
* Action listener creator to handle "transform" actions
|
|
56
|
+
* @param {FormElement} element The element for which the listener should be created for
|
|
57
|
+
* @param {FormFieldAction} action The action to be create a listener for
|
|
58
|
+
* @returns {Function} Returns a function to modify and return the modified state.
|
|
59
|
+
*/_defineProperty(this,"createTransformHandler",function(element,action){return function(prevState,nextState){/**
|
|
25
60
|
* Takes a string and applies a case function on it
|
|
26
61
|
* @param {string|boolean|number} subject The subject to be transformed
|
|
27
62
|
* @returns {string|boolean|number}
|
|
28
63
|
*/var transform=function transform(subject){// Get optional params to be applied in the transformation process
|
|
29
64
|
var args=action.params.value||[];if(Array.isArray(action.params.value)){args=action.params.value;}switch(_typeof(subject)){case'string':{if(typeof String.prototype[action.params.type]!=='function'&&typeof String[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof String.prototype[action.params.type]==='function'){return String.prototype[action.params.type].apply(subject,args);}return String[action.params.type](subject);}case'boolean':{if(typeof Boolean.prototype[action.params.type]!=='function'&&typeof Boolean[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof Boolean.prototype[action.params.type]==='function'){return Boolean.prototype[action.params.type].apply(subject,args);}return Boolean[action.params.type](subject);}case'number':{if(typeof Number.prototype[action.params.type]!=='function'&&typeof Number[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof Number.prototype[action.params.type]==='function'){return Number.prototype[action.params.type].apply(subject,args);}return Number[action.params.type](subject);}default:logger.error("Error: The given data can not be transformed. Must be of type 'string', "+"'boolean' or 'number'");return subject;}};var newState=_extends({},nextState,{formData:_extends({},nextState.formData,_defineProperty({},element.id,transform(nextState.formData[element.id])))});// Notify follow up listeners about the current change
|
|
30
|
-
if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};})
|
|
65
|
+
if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
|
|
66
|
+
* Evaluates all action rules of a given element action
|
|
67
|
+
*
|
|
68
|
+
* @param {FormElement} element The element of which the action rules should be evaluated
|
|
69
|
+
* @param {FormFieldAction} action The current action to be evaluate rules for
|
|
70
|
+
* @param {Object} nextState The state at the time before the "action" event finished
|
|
71
|
+
* @returns {boolean}
|
|
72
|
+
*/_defineProperty(this,"evaluateRules",function(element,action,nextState){var concatRules=_this.createConcatMethod(action.ruleConcatMethod);var resultInitValue=action.ruleConcatMethod!==ACTION_RULES_CONCAT_METHOD_ANY;var result=resultInitValue;action.rules.forEach(function(rule){var tmpResult=resultInitValue;var ruleType=rule.type;var ruleData=rule.data;// Default to rule type "boolean" and data true when type not given
|
|
31
73
|
if(ruleType===undefined){ruleType=ACTION_RULE_TYPE_BOOLEAN;ruleData=true;}// Check rule validity
|
|
32
74
|
if(!ACTION_RULE_DATA_TYPES[ruleType]){logger.error("Error: Unknown action rule type '".concat(ruleType,"'in element '").concat(element.id,"'"));return;}// Check type of ruleData
|
|
33
75
|
var ruleDataType=ACTION_RULE_DATA_TYPES[ruleType];if(ruleDataType==='array'&&!Array.isArray(ruleData)){logger.error("Error: Invalid FormBuilder action rule in element '".concat(element.id,"': ")+"data must be an 'array' for rule type '".concat(ruleType,"'"));return;}// eslint-disable-next-line valid-typeof
|
|
34
76
|
if(ruleDataType!=='array'&&_typeof(ruleData)!==ruleDataType){logger.error("Error: Invalid FormBuilder action rule in element '".concat(element.id,"': ")+"data must be '".concat(ruleDataType,"' for rule type '").concat(ruleType,"'"));return;}switch(ruleType){case ACTION_RULE_TYPE_ONE_OF:{tmpResult=ruleData.includes(nextState.formData[rule.context]);break;}case ACTION_RULE_TYPE_NOT_IN:{tmpResult=!ruleData.includes(nextState.formData[rule.context]);break;}case ACTION_RULE_TYPE_BOOLEAN:{tmpResult=ruleData;break;}case ACTION_RULE_TYPE_REGEX:{var regexParts=ruleData.split('/');var regexPattern='';var regexParam='';if(regexParts.length===1){var _regexParts=_slicedToArray(regexParts,1);regexPattern=_regexParts[0];}else if(regexParts.length===3){regexParts.shift();var _regexParts2=_slicedToArray(regexParts,2);regexPattern=_regexParts2[0];var _regexParts2$=_regexParts2[1];regexParam=_regexParts2$===void 0?'':_regexParts2$;}else{logger.error("Error: Invalid regex string in action rule in element ".concat(element.id));break;}var regex=new RegExp(regexPattern,regexParam);tmpResult=regex.test(nextState.formData[rule.context]);break;}default:break;}// Concat rules based on the rule concat method of the action
|
|
35
|
-
result=concatRules(result,tmpResult);});return result;})
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
|
|
77
|
+
result=concatRules(result,tmpResult);});return result;});/**
|
|
78
|
+
* Creates a concat function that defines how to concatenate action rule results
|
|
79
|
+
*
|
|
80
|
+
* @param {string} method The method defined by the action
|
|
81
|
+
* @returns {Function}
|
|
82
|
+
*/_defineProperty(this,"createConcatMethod",function(method){return function(prev,next){switch(method){case ACTION_RULES_CONCAT_METHOD_NONE:return prev&&!next;case ACTION_RULES_CONCAT_METHOD_ANY:return prev||next;case ACTION_RULES_CONCAT_METHOD_ALL:default:return prev&&next;}};});/**
|
|
83
|
+
* Adds a "action" listener to a given context element
|
|
84
|
+
*
|
|
85
|
+
* @param {string} elementId the element to listen for
|
|
86
|
+
* @param {Function} handler The listener to call when something has changed
|
|
87
|
+
*/_defineProperty(this,"register",function(elementId,handler){if(!_this.actionListeners[elementId]){_this.actionListeners[elementId]=[];}_this.actionListeners[elementId].push(handler);});/**
|
|
88
|
+
* Takes an element id, the state to work with and optional data and notifies all "action"
|
|
89
|
+
* listeners about the change. Every listener can manipulate the state.
|
|
90
|
+
* Returns the new state.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} elementId The id of the element that was changed
|
|
93
|
+
* @param {Object} prevState The state before any changes took place
|
|
94
|
+
* @param {Object} nextState The state containing all updates before the listeners are executed
|
|
95
|
+
* @returns {Object} The new state after all handlers have been executed.
|
|
96
|
+
*/_defineProperty(this,"notify",function(elementId,prevState,nextState){var newState=nextState;if(_this.actionListeners[elementId]){_this.actionListeners[elementId].forEach(function(notifyListener){// Note: The order of state changes is applied in the same order of listener registration
|
|
97
|
+
newState=notifyListener(prevState,newState);});}return newState;});this.defaults=defaults;this.getProvincesList=getProvincesList;this.actionListeners={};});export default ActionListener;
|
|
@@ -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 _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{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE}from"../Builder.constants";/** Noop function */var noop=function noop(){};/**
|
|
1
|
+
var _excluded=["custom"];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 _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{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE}from"../Builder.constants";/** Noop function */var noop=function noop(){};/**
|
|
2
2
|
* @typedef {Object} FormElement
|
|
3
3
|
* @property {string} id
|
|
4
4
|
* @property {boolean} custom
|
|
@@ -26,6 +26,6 @@ function _objectWithoutProperties(source,excluded){if(source==null)return{};var
|
|
|
26
26
|
*/var addFormElement=function addFormElement(id,field){var custom=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;// The "custom" field is just a placeholder for more fields
|
|
27
27
|
if(typeof field.type!=='string'){return;}// Make sure country and province elements are only added once
|
|
28
28
|
if(field.type===ELEMENT_TYPE_COUNTRY){if(hasCountryElement){logger.error("Error: Can not add multiple elements of type '".concat(field.type,"'"));return;}hasCountryElement=true;}if(field.type===ELEMENT_TYPE_PROVINCE){if(hasProvinceElement){logger.error("Error: Can not add multiple elements of type '".concat(field.type,"'"));return;}hasProvinceElement=true;}elementList.push(_extends({id:id},field,{custom:custom,handleChange:function handleChange(value){return elementChangeHandler(id,value);}}));};// Extract custom fields, do not mix with normal fields
|
|
29
|
-
var _formConfig$fields=formConfig.fields,custom=_formConfig$fields.custom,restFields=_objectWithoutProperties(_formConfig$fields,
|
|
29
|
+
var _formConfig$fields=formConfig.fields,custom=_formConfig$fields.custom,restFields=_objectWithoutProperties(_formConfig$fields,_excluded);// Add all non-custom attributes and mark them as such
|
|
30
30
|
Object.keys(restFields).forEach(function(id){addFormElement(id,formConfig.fields[id]);});// Add custom fields to the element list
|
|
31
31
|
if(custom){Object.keys(custom).forEach(function(id){addFormElement(id,formConfig.fields.custom[id],true);});}return elementList;});
|
package/components/Form/Form.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
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,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';/**
|
|
2
2
|
* Form component that handles keyboard submit, next buttons, ...
|
|
3
|
-
*/var Form=/*#__PURE__*/function(_PureComponent){
|
|
4
|
-
if(event.which===13){_this.handleSubmit(event);}});_this.formElement=React.createRef();return _this;}/**
|
|
3
|
+
*/var Form=/*#__PURE__*/function(_PureComponent){function Form(props){var _this2;_classCallCheck(this,Form);_this2=_callSuper(this,Form,[props]);/**
|
|
5
4
|
* Handles the form submit.
|
|
6
5
|
* @param {Object} event The event that caused the submit.
|
|
7
|
-
*/
|
|
6
|
+
*/_defineProperty(_this2,"handleSubmit",function(event){event.preventDefault();var inputFocused=[].concat(_this2.formElement.current.querySelectorAll('input')).some(function(input){return document.activeElement===input;});if(inputFocused){document.activeElement.blur();}_this2.props.onSubmit();});/**
|
|
7
|
+
* Handles form submits by key.
|
|
8
|
+
* @param {Object} event The event that caused the keypress.
|
|
9
|
+
*/_defineProperty(_this2,"handleKeyPress",function(event){// Enter key and on iOS also the "Done" button.
|
|
10
|
+
if(event.which===13){_this2.handleSubmit(event);}});_this2.formElement=React.createRef();return _this2;}_inherits(Form,_PureComponent);return _createClass(Form,[{key:"render",value:/**
|
|
8
11
|
* Renders the component.
|
|
9
12
|
* @returns {JSX}
|
|
10
|
-
*/
|
|
13
|
+
*/function render(){/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */return React.createElement("form",{action:"#",className:classNames(this.props.className,'form','engage__form'),onSubmit:this.handleSubmit,onKeyPress:this.handleKeyPress,ref:this.formElement},this.props.children);/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */}}]);}(PureComponent);_defineProperty(Form,"defaultProps",{className:null,onSubmit:function onSubmit(){}/**
|
|
11
14
|
* Initializes the form component.
|
|
12
15
|
* @param {Object} props The components props.
|
|
13
16
|
*/});export default Form;
|
|
@@ -1,4 +1,4 @@
|
|
|
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 _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _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
|
+
var _IntersectionVisibility;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 _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _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{Component}from'react';import PropTypes from'prop-types';import'intersection-observer';/**
|
|
2
2
|
* The IntersectionVisibility component.
|
|
3
3
|
* @example
|
|
4
4
|
* <IntersectionVisibility>
|
|
@@ -6,12 +6,19 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
|
|
|
6
6
|
<Video autoPlay={visible && ratio > 0.8} ref={setRef} />}
|
|
7
7
|
)}
|
|
8
8
|
* </IntersectionVisibility>
|
|
9
|
-
*/var IntersectionVisibility=/*#__PURE__*/function(_Component){
|
|
9
|
+
*/var IntersectionVisibility=/*#__PURE__*/function(_Component){function IntersectionVisibility(){var _this2;_classCallCheck(this,IntersectionVisibility);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,IntersectionVisibility,[].concat(args));_defineProperty(_this2,"state",{visible:true,ratio:1,entries:null});/**
|
|
10
|
+
* @param {Object} ref ref
|
|
11
|
+
*/_defineProperty(_this2,"setRef",function(ref){if(!ref){return;}_this2.node=ref;if(_this2.io){_this2.io.observe(_this2.node);}});/**
|
|
12
|
+
* @param {IntersectionObserverEntry[]} entries first entry
|
|
13
|
+
*/_defineProperty(_this2,"handleIntersectionEvent",function(entries){var _entries=_slicedToArray(entries,1),intersectionRatio=_entries[0].intersectionRatio;_this2.setState({visible:intersectionRatio>0,ratio:intersectionRatio,entries:entries});});return _this2;}_inherits(IntersectionVisibility,_Component);return _createClass(IntersectionVisibility,[{key:"componentDidMount",value:/**
|
|
10
14
|
* Start the observer when the component is mounted
|
|
11
|
-
*/
|
|
15
|
+
*/function componentDidMount(){this.io=new IntersectionObserver(this.handleIntersectionEvent,{threshold:this.props.thresholds});if(this.node){this.io.observe(this.node);}}/**
|
|
12
16
|
* @inheritDoc
|
|
13
|
-
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){if(this.io){this.io.disconnect();}}
|
|
14
|
-
* @param {Object} ref ref
|
|
15
|
-
*/},{key:"render",/**
|
|
17
|
+
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){if(this.io){this.io.disconnect();}}},{key:"render",value:/**
|
|
16
18
|
* @returns {JSX.Element}
|
|
17
|
-
*/
|
|
19
|
+
*/function render(){return this.props.children(_extends({},this.state,{setRef:this.setRef}));}}]);}(Component);_IntersectionVisibility=IntersectionVisibility;/**
|
|
20
|
+
* Calculate threshold by number of steps
|
|
21
|
+
* Ex: 5 steps will be [0.20, 0.40, 0.60, 0.80, 1.00]
|
|
22
|
+
* @param {number} steps .
|
|
23
|
+
* @returns {number[]}
|
|
24
|
+
*/_defineProperty(IntersectionVisibility,"buildThresholdList",function(steps){return Array(steps).fill(0).map(function(v,i){return(i+1)/steps;});});_defineProperty(IntersectionVisibility,"defaultProps",{thresholds:_IntersectionVisibility.buildThresholdList(10)});export default IntersectionVisibility;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{connect}from'react-redux';import{hasWebBridge,makeGetShopSettingByKey,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB}from'@shopgate/engage/core';/**
|
|
2
|
+
* Creates the mapStateToProps connector function.
|
|
3
|
+
* @returns {Function}
|
|
4
|
+
*/var makeMapStateToProps=function makeMapStateToProps(){var getShowShopLogoInApp=makeGetShopSettingByKey(SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP);var getShowShopLogoInWeb=makeGetShopSettingByKey(SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB);return function(state){return{showLogo:hasWebBridge()?getShowShopLogoInWeb(state):getShowShopLogoInApp(state)};};};export default connect(makeMapStateToProps);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import appConfig from'@shopgate/pwa-common/helpers/config';import noop from'lodash/noop';import styles from"./style";import connect from"./connector";/**
|
|
2
|
+
* The Logo component.
|
|
3
|
+
* @return {JSX}
|
|
4
|
+
*/var Logo=function Logo(_ref){var className=_ref.className,onClick=_ref.onClick,showLogo=_ref.showLogo;if(!showLogo){return null;}return(/* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */React.createElement("div",{onClick:onClick,className:classNames(styles.container,className,'engage__logo')},React.createElement("img",{className:styles.image,src:appConfig.logo||appConfig.logoFallback,alt:appConfig.shopName}))/* eslint-enable jsx-a11y/no-static-element-interactions */ /* eslint-enable jsx-a11y/click-events-have-key-events */);};Logo.defaultProps={className:'',onClick:noop,showLogo:true};export default connect(Logo);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Logo from"./index";jest.mock("./connector",function(){return function(Component){return Component;};});describe('<Logo />',function(){it('should render an image',function(){var wrapper=shallow(React.createElement(Logo,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find('img').exists()).toBe(true);});});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;var container=css({alignItems:'center',display:'flex',flexGrow:1});var image=css({margin:'0 auto',maxHeight:variables.navigator.height,maxWidth:"calc(var(--page-content-width) - ".concat(variables.navigator.height*3+variables.gap.xbig,"px)"),overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap'});export default{container:container,image:image};
|
|
@@ -1,11 +1,11 @@
|
|
|
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 _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 _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 _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 clamp from'lodash/clamp';import styles from"./style";/**
|
|
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 _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 _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 clamp from'lodash/clamp';import styles from"./style";/**
|
|
2
2
|
* The Context Menu Position component.
|
|
3
|
-
*/var Position=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var Position=/*#__PURE__*/function(_Component){/**
|
|
4
4
|
* The Constructor.
|
|
5
5
|
* @param {Object} props The component props.
|
|
6
|
-
*/function Position(props){var
|
|
6
|
+
*/function Position(props){var _this2;_classCallCheck(this,Position);_this2=_callSuper(this,Position,[props]);_this2.elementRef=null;return _this2;}/**
|
|
7
7
|
* Calculate and apply the correct menu position after mounting.
|
|
8
|
-
*/_createClass(Position,[{key:"componentDidMount",value:function componentDidMount(){var offset=this.props.offset;// Get ref to the actual child DOM element and calculate bounding rect.
|
|
8
|
+
*/_inherits(Position,_Component);return _createClass(Position,[{key:"componentDidMount",value:function componentDidMount(){var offset=this.props.offset;// Get ref to the actual child DOM element and calculate bounding rect.
|
|
9
9
|
var _this$elementRef$chil=_slicedToArray(this.elementRef.childNodes,1),child=_this$elementRef$chil[0];var bounds=child.getBoundingClientRect();// Get window dimensions
|
|
10
10
|
var width=window.innerWidth;var height=window.innerHeight;// Get the outer gap from styles
|
|
11
11
|
var gap=styles.outerGap;// Calculate clamped menu position
|
|
@@ -13,4 +13,4 @@ var left=clamp(offset.left,0,width-bounds.width-gap*2);var top=clamp(offset.top-
|
|
|
13
13
|
this.elementRef.style.left="".concat(left,"px");this.elementRef.style.top="".concat(top,"px");}/**
|
|
14
14
|
* Renders the component.
|
|
15
15
|
* @returns {JSX}
|
|
16
|
-
*/},{key:"render",value:function render(){var
|
|
16
|
+
*/},{key:"render",value:function render(){var _this3=this;return React.createElement("div",{ref:function ref(_ref){_this3.elementRef=_ref;},className:styles.container},this.props.children);}}]);}(Component);_defineProperty(Position,"defaultProps",{children:null,offset:{top:0,left:0}});export default Position;
|
package/components/Menu/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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,Children}from'react';import PropTypes from'prop-types';import Portal from'react-portal';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import Position from"./components/Position";import Item from"./components/Item";import styles from"./style";/**
|
|
2
2
|
* The Menu component.
|
|
3
|
-
*/var Menu=/*#__PURE__*/function(_Component){
|
|
4
|
-
* Renders the component.
|
|
5
|
-
* @returns {JSX}
|
|
6
|
-
*/value:function render(){var _this$props=this.props,children=_this$props.children,isOpen=_this$props.isOpen,onClose=_this$props.onClose;return React.createElement(Portal,{isOpened:isOpen},React.createElement("div",{className:styles.overlay},React.createElement(Backdrop,{isVisible:true,level:0,opacity:0,onClick:onClose}),React.createElement(Position,{offset:this.offset},React.createElement("div",{className:styles.menu},Children.map(children,function(child){if(!child){return null;}return React.cloneElement(child,{closeMenu:onClose});})))));}},{key:"offset",/**
|
|
7
|
-
* Gets the offset of the DOM element.
|
|
8
|
-
* @returns {Object}
|
|
9
|
-
*/get:function get(){var _this$props$contextRe2;if((_this$props$contextRe2=this.props.contextRef)===null||_this$props$contextRe2===void 0?void 0:_this$props$contextRe2.current){var bounds=this.props.contextRef.current.getBoundingClientRect();return{height:bounds.height,width:bounds.width,left:bounds.left,right:bounds.right,bottom:bounds.bottom,top:bounds.top+bounds.height};}return{top:0,left:0};}/**
|
|
3
|
+
*/var Menu=/*#__PURE__*/function(_Component){function Menu(){var _this2;_classCallCheck(this,Menu);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,Menu,[].concat(args));/**
|
|
10
4
|
* Handles any menu toggling interactions.
|
|
11
5
|
* @param {Object} [e] Event
|
|
12
|
-
*/
|
|
6
|
+
*/_defineProperty(_this2,"handleMenuToggle",function(e){var _this2$props$contextR;if(e){e.preventDefault();e.stopPropagation();}if((_this2$props$contextR=_this2.props.contextRef)===null||_this2$props$contextR===void 0?void 0:_this2$props$contextR.current){_this2.props.onClose();}});return _this2;}_inherits(Menu,_Component);return _createClass(Menu,[{key:"offset",get:/**
|
|
7
|
+
* Gets the offset of the DOM element.
|
|
8
|
+
* @returns {Object}
|
|
9
|
+
*/function get(){var _this$props$contextRe;if((_this$props$contextRe=this.props.contextRef)===null||_this$props$contextRe===void 0?void 0:_this$props$contextRe.current){var bounds=this.props.contextRef.current.getBoundingClientRect();return{height:bounds.height,width:bounds.width,left:bounds.left,right:bounds.right,bottom:bounds.bottom,top:bounds.top+bounds.height};}return{top:0,left:0};}},{key:"render",value:/**
|
|
10
|
+
* Renders the component.
|
|
11
|
+
* @returns {JSX}
|
|
12
|
+
*/function render(){var _this$props=this.props,children=_this$props.children,isOpen=_this$props.isOpen,onClose=_this$props.onClose;return React.createElement(Portal,{isOpened:isOpen},React.createElement("div",{className:styles.overlay},React.createElement(Backdrop,{isVisible:true,level:0,opacity:0,onClick:onClose}),React.createElement(Position,{offset:this.offset},React.createElement("div",{className:styles.menu},Children.map(children,function(child){if(!child){return null;}return React.cloneElement(child,{closeMenu:onClose});})))));}}]);}(Component);_defineProperty(Menu,"Item",Item);_defineProperty(Menu,"defaultProps",{children:null,contextRef:null,isOpen:false,onClose:function onClose(){}});export default Menu;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{hot}from'react-hot-loader/root';import*as React from'react';import classnames from'classnames';import{i18n,errorBehavior}from'@shopgate/engage/core';import StopIcon from'@shopgate/pwa-ui-shared/icons/StopIcon';import InfoIcon from'@shopgate/pwa-ui-shared/icons/InfoIcon';import WarningIcon from'@shopgate/pwa-ui-shared/icons/WarningIcon';import*as styles from"./MessageBar.style";var iconMapping={info:InfoIcon,warning:WarningIcon,error:StopIcon};/**
|
|
1
|
+
import{hot}from'react-hot-loader/root';import*as React from'react';import PropTypes from'prop-types';import classnames from'classnames';import{i18n,errorBehavior}from'@shopgate/engage/core';import StopIcon from'@shopgate/pwa-ui-shared/icons/StopIcon';import InfoIcon from'@shopgate/pwa-ui-shared/icons/InfoIcon';import WarningIcon from'@shopgate/pwa-ui-shared/icons/WarningIcon';import*as styles from"./MessageBar.style";var iconMapping={info:InfoIcon,warning:WarningIcon,error:StopIcon};/**
|
|
2
2
|
* The MessageBar component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @property {Array} props.messages The message content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as MessageBar}from"./MessageBar"
|
|
1
|
+
export{default as MessageBar}from"./MessageBar";
|
|
@@ -1,9 +1,9 @@
|
|
|
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 _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 from'react';import PropTypes from'prop-types';import{UIEvents}from'@shopgate/pwa-core';import{NAVIGATION_PUSH,NAVIGATION_POP,NAVIGATION_REPLACE,NAVIGATION_RESET}from"../../core/router/helpers";import connect from"./connector";/**
|
|
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 from'react';import PropTypes from'prop-types';import{UIEvents}from'@shopgate/pwa-core';import{NAVIGATION_PUSH,NAVIGATION_POP,NAVIGATION_REPLACE,NAVIGATION_RESET}from"../../core/router/helpers";import connect from"./connector";/**
|
|
2
2
|
* Handles
|
|
3
|
-
*/var NavigationHandler=/*#__PURE__*/function(_React$PureComponent){
|
|
3
|
+
*/var NavigationHandler=/*#__PURE__*/function(_React$PureComponent){function NavigationHandler(props){var _this2;_classCallCheck(this,NavigationHandler);_this2=_callSuper(this,NavigationHandler,[props]);UIEvents.addListener(NAVIGATION_PUSH,props.push);UIEvents.addListener(NAVIGATION_POP,props.pop);UIEvents.addListener(NAVIGATION_REPLACE,props.replace);UIEvents.addListener(NAVIGATION_RESET,props.reset);return _this2;}/**
|
|
4
4
|
* Removes the event listeners.
|
|
5
|
-
*/_createClass(NavigationHandler,[{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(NAVIGATION_PUSH,this.props.push);UIEvents.removeListener(NAVIGATION_POP,this.props.pop);UIEvents.removeListener(NAVIGATION_REPLACE,this.props.replace);UIEvents.removeListener(NAVIGATION_RESET,this.props.reset);}/**
|
|
5
|
+
*/_inherits(NavigationHandler,_React$PureComponent);return _createClass(NavigationHandler,[{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(NAVIGATION_PUSH,this.props.push);UIEvents.removeListener(NAVIGATION_POP,this.props.pop);UIEvents.removeListener(NAVIGATION_REPLACE,this.props.replace);UIEvents.removeListener(NAVIGATION_RESET,this.props.reset);}/**
|
|
6
6
|
* @returns {null}
|
|
7
|
-
*/},{key:"render",value:function render(){return this.props.children;}}]);
|
|
7
|
+
*/},{key:"render",value:function render(){return this.props.children;}}]);}(React.PureComponent);_defineProperty(NavigationHandler,"defaultProps",{pop:function pop(){},push:function push(){},replace:function replace(){},reset:function reset(){}/**
|
|
8
8
|
* @param {Object} props The component props.
|
|
9
9
|
*/});export default connect(NavigationHandler);
|
|
@@ -1 +1 @@
|
|
|
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 React from'react';import{Provider}from'react-redux';import{mount}from'enzyme';import{UIEvents}from'@shopgate/pwa-core';import{createMockStore}from'@shopgate/pwa-common/store';import NavigationHandler from"./index";import{NAVIGATION_PUSH,NAVIGATION_POP,NAVIGATION_REPLACE,NAVIGATION_RESET,push,pop,replace,reset}from"../../core/router/helpers";jest.mock('@shopgate/pwa-core',function(){var map={};return{UIEvents:{addListener:jest.fn(function(event,cb){map[event]=cb;}),removeListener:jest.fn(),emit:jest.fn(function(event,params){map[event](params);})}};});describe('<NavigationHandler />',function(){var store=createMockStore();var wrapper=mount(React.createElement(Provider,{store:store},React.createElement(NavigationHandler,null,React.createElement("div",null,"Some content"))));it('should render as expected',function(){expect(wrapper).toMatchSnapshot();});it('should trigger the push() callbacks on navigation.push event',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
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 React from'react';import{Provider}from'react-redux';import{mount}from'enzyme';import{UIEvents}from'@shopgate/pwa-core';import{createMockStore}from'@shopgate/pwa-common/store';import NavigationHandler from"./index";import{NAVIGATION_PUSH,NAVIGATION_POP,NAVIGATION_REPLACE,NAVIGATION_RESET,push,pop,replace,reset}from"../../core/router/helpers";jest.mock('@shopgate/pwa-core',function(){var map={};return{UIEvents:{addListener:jest.fn(function(event,cb){map[event]=cb;}),removeListener:jest.fn(),emit:jest.fn(function(event,params){map[event](params);})}};});describe('<NavigationHandler />',function(){var store=createMockStore();var wrapper=mount(React.createElement(Provider,{store:store},React.createElement(NavigationHandler,null,React.createElement("div",null,"Some content"))));it('should render as expected',function(){expect(wrapper).toMatchSnapshot();});it('should trigger the push() callbacks on navigation.push event',/*#__PURE__*/_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 push({pathname:'/test'});case 2:expect(UIEvents.emit).toBeCalledWith(NAVIGATION_PUSH,{pathname:'/test'});UIEvents.emit.mockClear();case 4:case"end":return _context.stop();}},_callee);})));it('should trigger the pop() callbacks on navigation.pop event',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return pop();case 2:expect(UIEvents.emit).toBeCalledWith(NAVIGATION_POP);UIEvents.emit.mockClear();case 4:case"end":return _context2.stop();}},_callee2);})));it('should trigger the replace() callbacks on navigation.replace event',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return replace({pathname:'/test'});case 2:expect(UIEvents.emit).toBeCalledWith(NAVIGATION_REPLACE,{pathname:'/test'});UIEvents.emit.mockClear();case 4:case"end":return _context3.stop();}},_callee3);})));it('should trigger the reset() callbacks on navigation.reset event',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(){return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return reset();case 2:expect(UIEvents.emit).toBeCalledWith(NAVIGATION_RESET);UIEvents.emit.mockClear();case 4:case"end":return _context4.stop();}},_callee4);})));it('should register the navigation event listener',function(){var props=wrapper.find('NavigationHandler').props();expect(UIEvents.addListener.mock.calls.length).toBe(4);expect(UIEvents.addListener.mock.calls[0][0]).toEqual(NAVIGATION_PUSH,props.push);expect(UIEvents.addListener.mock.calls[1][0]).toEqual(NAVIGATION_POP,props.pop);expect(UIEvents.addListener.mock.calls[2][0]).toEqual(NAVIGATION_REPLACE,props.replace);expect(UIEvents.addListener.mock.calls[3][0]).toEqual(NAVIGATION_RESET,props.reset);UIEvents.addListener.mockClear();});it('should unregister the navigation event listener when the component unmounts',function(){var props=wrapper.find('NavigationHandler').props();wrapper.unmount();expect(UIEvents.removeListener.mock.calls.length).toBe(4);expect(UIEvents.removeListener.mock.calls[0][0]).toEqual(NAVIGATION_PUSH,props.push);expect(UIEvents.removeListener.mock.calls[1][0]).toEqual(NAVIGATION_POP,props.pop);expect(UIEvents.removeListener.mock.calls[2][0]).toEqual(NAVIGATION_REPLACE,props.replace);expect(UIEvents.removeListener.mock.calls[3][0]).toEqual(NAVIGATION_RESET,props.reset);UIEvents.removeListener.mockClear();});});
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import styles from"./
|
|
|
2
2
|
* The default button for the Picker component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX} The button component.
|
|
5
|
-
*/var PickerButton=function PickerButton(_ref){var value=_ref.value,label=_ref.label,openList=_ref.openList;return React.createElement("button",{className:styles.button,onClick:openList,type:"button"},React.createElement("span",{className:styles.label},label),value!==null&&React.createElement("span",{className:styles.value},value));};PickerButton.defaultProps={value:null};export default PickerButton;
|
|
5
|
+
*/var PickerButton=function PickerButton(_ref){var value=_ref.value,label=_ref.label,openList=_ref.openList;return React.createElement("button",{className:"".concat(styles.button," engage__picker__button"),onClick:openList,type:"button"},React.createElement("span",{className:styles.label},label),value!==null&&React.createElement("span",{className:styles.value},value));};PickerButton.defaultProps={value:null};export default PickerButton;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React
|
|
1
|
+
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{useMemo}from'react';import PropTypes from'prop-types';import classNames from'classnames';import styles from"./style";/**
|
|
2
2
|
* The default button for the Picker component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX} The button component.
|
|
5
|
-
*/var PickerList=function PickerList(props){var items=props.items,onClose=props.onClose,onSelect=props.onSelect,selectedIndex=props.selectedIndex;return React.createElement("ul",
|
|
5
|
+
*/var PickerList=function PickerList(props){var items=props.items,onClose=props.onClose,onSelect=props.onSelect,selectedIndex=props.selectedIndex,query=props.query;var filteredItems=useMemo(function(){if(!query||!query.length){return items;}return items.filter(function(_ref){var _ref$label=_ref.label,label=_ref$label===void 0?'':_ref$label;var searchLabel=label.replaceAll(' ','').toLowerCase();var searchValue=query.replaceAll(' ','').toLowerCase();return searchLabel.includes(searchValue);});},[items,query]);return React.createElement("ul",{className:"engage__picker_list"},filteredItems.map(function(item,currentIndex){return React.createElement("li",{key:item.value,className:classNames(_defineProperty({},styles.active,currentIndex===selectedIndex))},React.createElement("button",{className:styles.button,disabled:item.disabled,onClick:function onClick(){onSelect(item.value);onClose();},type:"button"},item.label));}));};PickerList.defaultProps={onClose:function onClose(){},selectedIndex:null,query:''};export default PickerList;
|
|
@@ -1,14 +1,14 @@
|
|
|
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 classNames from'classnames';import styles from"./style";/**
|
|
2
2
|
* The picker modal.
|
|
3
|
-
*/var PickerModal=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var PickerModal=/*#__PURE__*/function(_Component){/**
|
|
4
4
|
* The constructor.
|
|
5
5
|
* @param {Object} props The props.
|
|
6
|
-
*/function PickerModal(props){var
|
|
6
|
+
*/function PickerModal(props){var _this2;_classCallCheck(this,PickerModal);_this2=_callSuper(this,PickerModal,[props]);/**
|
|
7
|
+
* Closes the modal after the closing animations have finished.
|
|
8
|
+
*/_defineProperty(_this2,"closeModal",function(){_this2.setState({active:false});clearTimeout(_this2.timeout);_this2.timeout=setTimeout(_this2.props.onClose,styles.duration);});_this2.timeout=null;_this2.state={active:true};return _this2;}/**
|
|
7
9
|
* Update state when isOpen changes.
|
|
8
10
|
* @param {Object} nextProps The next component props.
|
|
9
|
-
*/_createClass(PickerModal,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){this.setState({active:nextProps.isOpen});}}
|
|
10
|
-
* Closes the modal after the closing animations have finished.
|
|
11
|
-
*/},{key:"render",/**
|
|
11
|
+
*/_inherits(PickerModal,_Component);return _createClass(PickerModal,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){this.setState({active:nextProps.isOpen});}}},{key:"render",value:/**
|
|
12
12
|
* Render all the things!
|
|
13
13
|
* @returns {JSX} The picker modal with the picker list inside.
|
|
14
|
-
*/
|
|
14
|
+
*/function render(){var backgroundClassName=classNames(styles.background.base,_defineProperty({},styles.background.inactive,!this.state.active));var containerClassName=classNames(styles.container.base,_defineProperty({},styles.container.inactive,!this.state.active));if(!this.props.isOpen){return null;}return React.createElement("div",{className:"".concat(styles.wrapper," engage__picker_modal")},React.createElement("div",{"aria-hidden":true,className:backgroundClassName,onClick:this.closeModal}),React.createElement("div",{className:containerClassName},React.cloneElement(this.props.children,{onClose:this.closeModal})));}}]);}(Component);export default PickerModal;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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 _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;}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 _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);}import React,{Component}from'react';import PropTypes from'prop-types';import Portal from'react-portal';import{withForwardedRef}from"../../core";import PickerModal from"./components/Modal";import PickerButton from"./components/Button";import PickerList from"./components/List";/**
|
|
2
2
|
* Converts an item of any type (e.g. string or number)
|
|
3
3
|
* to an object representation containing value and label properties.
|
|
4
4
|
* @param {*} item - An item of any type.
|
|
@@ -10,19 +10,28 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
10
10
|
* @returns {number} The found item index or undefined.
|
|
11
11
|
*/var findItemIndexByValue=function findItemIndexByValue(items,value){return items.map(normalizeItem).findIndex(function(item){return item.value===value;});};/**
|
|
12
12
|
* The picker component (acts like a selectbox).
|
|
13
|
-
*/var Picker=/*#__PURE__*/function(_Component){
|
|
13
|
+
*/var Picker=/*#__PURE__*/function(_Component){/**
|
|
14
14
|
* The constructor.
|
|
15
15
|
* @param {Object} props - The component props.
|
|
16
|
-
*/function Picker(props){var
|
|
16
|
+
*/function Picker(props){var _this2;_classCallCheck(this,Picker);_this2=_callSuper(this,Picker,[props]);/**
|
|
17
|
+
* Triggers the onChange callback if the selected value has changed.
|
|
18
|
+
* @param {Object} nextValue - The value the user picked.
|
|
19
|
+
*/_defineProperty(_this2,"triggerChangeCallback",function(nextValue){var nextSelectedIndex=findItemIndexByValue(_this2.props.items,nextValue);if(nextSelectedIndex>-1&&_this2.state.selectedIndex!==nextSelectedIndex){_this2.props.onChange(nextValue);}_this2.props.onSelect(nextValue);});/**
|
|
20
|
+
* Triggers the onChange callback if the selected value has changed.
|
|
21
|
+
* @param {Object} nextOpenState - The value the user picked.
|
|
22
|
+
*/_defineProperty(_this2,"triggerCloseCallback",function(nextOpenState){if(_this2.state.isOpen&&!nextOpenState){_this2.props.onClose();}});/**
|
|
23
|
+
* Gets called when a new item is selected
|
|
24
|
+
* @param {string} value - The selected value.
|
|
25
|
+
*/_defineProperty(_this2,"handleItemSelect",function(value){_this2.triggerChangeCallback(value);_this2.setState({selectedIndex:findItemIndexByValue(_this2.props.items,value)});});/**
|
|
26
|
+
* Sets or toggles the open state of the component.
|
|
27
|
+
* @param {boolean} [open] New open state.
|
|
28
|
+
*/_defineProperty(_this2,"toggleOpenState",function(open){_this2.setState(function(_ref){var isOpen=_ref.isOpen;var nextIsOpen=typeof open==='boolean'?open:!isOpen;_this2.triggerCloseCallback(nextIsOpen);return{isOpen:nextIsOpen};});});_this2.state={selectedIndex:findItemIndexByValue(props.items,props.value),isOpen:props.isOpen};return _this2;}/**
|
|
17
29
|
* Updates the selected item when the value prop changes.
|
|
18
30
|
* @param {Object} nextProps - The next props.
|
|
19
|
-
*/_createClass(Picker,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Only update if a value is present and also changed.
|
|
31
|
+
*/_inherits(Picker,_Component);return _createClass(Picker,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Only update if a value is present and also changed.
|
|
20
32
|
if(!this.selectedItem||nextProps.value!==this.selectedItem.value){this.setState({selectedIndex:findItemIndexByValue(nextProps.items,nextProps.value)});}if(this.props.isOpen!==nextProps.isOpen&&nextProps.isOpen!==this.state.isOpen){this.setState({isOpen:nextProps.isOpen});}}/**
|
|
21
33
|
* Getter for the selected item.
|
|
22
|
-
*/},{key:"render"
|
|
34
|
+
*/},{key:"selectedItem",get:function get(){return normalizeItem(this.props.items[this.state.selectedIndex]);}},{key:"render",value:/**
|
|
23
35
|
* Renders the component.
|
|
24
36
|
* @returns {JSX}
|
|
25
|
-
*/
|
|
26
|
-
* Triggers the onChange callback if the selected value has changed.
|
|
27
|
-
* @param {Object} nextValue - The value the user picked.
|
|
28
|
-
*/}]);return Picker;}(Component);_defineProperty(Picker,"defaultProps",{buttonComponent:PickerButton,buttonProps:{},duration:300,disabled:false,forwardedRef:null,label:'',listComponent:PickerList,modalComponent:PickerModal,className:'',isOpen:false,items:[],onChange:function onChange(){},onClose:function onClose(){},onSelect:function onSelect(){},placeholder:'Pick ...',value:null});export default withForwardedRef(Picker);
|
|
37
|
+
*/function render(){var _this3=this;var hasSelection=!!this.selectedItem;var buttonValue=hasSelection?this.selectedItem.label:'';var buttonLabel=hasSelection?this.props.label:this.props.placeholder;var buttonProps=_extends({},this.props.buttonProps,{label:buttonLabel,value:buttonValue,disabled:this.props.disabled,openList:this.props.disabled?null:function(){_this3.toggleOpenState(true);}});var modalProps={isOpen:this.state.isOpen,duration:this.props.duration,onClose:function onClose(){return _this3.toggleOpenState(false);}};var listProps={items:this.props.items.map(normalizeItem),selectedIndex:this.state.selectedIndex,onSelect:this.handleItemSelect};return React.createElement("div",{role:"button",className:"".concat(this.props.className," engage__picker"),ref:this.props.forwardedRef,tabIndex:0,"aria-haspopup":true},React.createElement(this.props.buttonComponent,buttonProps),React.createElement(Portal,{onClose:function onClose(){return _this3.toggleOpenState(false);},isOpened:true},React.createElement(this.props.modalComponent,modalProps,React.createElement(this.props.listComponent,listProps))));}}]);}(Component);_defineProperty(Picker,"defaultProps",{buttonComponent:PickerButton,buttonProps:{},duration:300,disabled:false,forwardedRef:null,label:'',listComponent:PickerList,modalComponent:PickerModal,className:'',isOpen:false,items:[],onChange:function onChange(){},onClose:function onClose(){},onSelect:function onSelect(){},placeholder:'Pick ...',value:null});export default withForwardedRef(Picker);
|