@jetshop/ui 0.0.11
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/Accordion/Accordion.d.ts +33 -0
- package/Accordion/Accordion.js +59 -0
- package/Accordion/Accordion.js.map +1 -0
- package/Accordion/__doc_utils__/AccordionHeader.js +12 -0
- package/Auth/FormFields/CountriesInput.d.ts +16 -0
- package/Auth/FormFields/CountriesInput.js +28 -0
- package/Auth/FormFields/CountriesInput.js.map +1 -0
- package/Auth/LogInBehavior.d.ts +22 -0
- package/Auth/LogInBehavior.js +24 -0
- package/Auth/LogInBehavior.js.map +1 -0
- package/Auth/LogInFormProvider.d.ts +7 -0
- package/Auth/LogInFormProvider.js +70 -0
- package/Auth/LogInFormProvider.js.map +1 -0
- package/Auth/LogOut.d.ts +10 -0
- package/Auth/LogOut.js +24 -0
- package/Auth/LogOut.js.map +1 -0
- package/Auth/logInValidator.d.ts +10 -0
- package/Auth/logInValidator.js +16 -0
- package/Auth/logInValidator.js.map +1 -0
- package/Breadcrumbs/Breadcrumbs.d.ts +14 -0
- package/Breadcrumbs/Breadcrumbs.js +84 -0
- package/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/Breadcrumbs/getParentsOrCanonicalRoute.d.ts +3 -0
- package/Breadcrumbs/getParentsOrCanonicalRoute.js +14 -0
- package/Breadcrumbs/getParentsOrCanonicalRoute.js.map +1 -0
- package/Breadcrumbs/index.d.ts +1 -0
- package/Breadcrumbs/index.js +2 -0
- package/Breadcrumbs/index.js.map +1 -0
- package/Breakpoints.d.ts +12 -0
- package/Breakpoints.js +36 -0
- package/Breakpoints.js.map +1 -0
- package/Button/Button.d.ts +14 -0
- package/Button/Button.js +60 -0
- package/Button/Button.js.map +1 -0
- package/Button/SecondaryButton.d.ts +2 -0
- package/Button/SecondaryButton.js +9 -0
- package/Button/SecondaryButton.js.map +1 -0
- package/Button/TrendButton.d.ts +2 -0
- package/Button/TrendButton.js +8 -0
- package/Button/TrendButton.js.map +1 -0
- package/Button/index.d.ts +4 -0
- package/Button/index.js +5 -0
- package/Button/index.js.map +1 -0
- package/CategoryLink.d.ts +11 -0
- package/CategoryLink.js +49 -0
- package/CategoryLink.js.map +1 -0
- package/ChannelSelector/ChannelListItem.d.ts +10 -0
- package/ChannelSelector/ChannelListItem.js +51 -0
- package/ChannelSelector/ChannelListItem.js.map +1 -0
- package/ChannelSelector/ChannelListItem.test.js +85 -0
- package/ChannelSelector/ChannelSelector.d.ts +63 -0
- package/ChannelSelector/ChannelSelector.js +80 -0
- package/ChannelSelector/ChannelSelector.js.map +1 -0
- package/ChannelSelector/ChannelSelector.test.js +167 -0
- package/ChannelSelector/ChannelSelectorButtons.d.ts +2 -0
- package/ChannelSelector/ChannelSelectorButtons.js +20 -0
- package/ChannelSelector/ChannelSelectorButtons.js.map +1 -0
- package/ChannelSelector/Channels.d.ts +17 -0
- package/ChannelSelector/Channels.js +12 -0
- package/ChannelSelector/Channels.js.map +1 -0
- package/ChannelSelector/Channels.test.js +90 -0
- package/ChannelSelector/LargeSelector.d.ts +3 -0
- package/ChannelSelector/LargeSelector.js +67 -0
- package/ChannelSelector/LargeSelector.js.map +1 -0
- package/ChannelSelector/MiniSelector.d.ts +4 -0
- package/ChannelSelector/MiniSelector.js +58 -0
- package/ChannelSelector/MiniSelector.js.map +1 -0
- package/ChannelSelector/Region.d.ts +28 -0
- package/ChannelSelector/Region.js +21 -0
- package/ChannelSelector/Region.js.map +1 -0
- package/ChannelSelector/Region.test.js +37 -0
- package/ChannelSelector/exampleChannels.js +577 -0
- package/ChannelSelector/groupBy.d.ts +7 -0
- package/ChannelSelector/groupBy.js +16 -0
- package/ChannelSelector/groupBy.js.map +1 -0
- package/ChannelSelector/groupBy.test.js +42 -0
- package/Checkbox/Checkbox.d.ts +14 -0
- package/Checkbox/Checkbox.js +70 -0
- package/Checkbox/Checkbox.js.map +1 -0
- package/Checkbox/CheckboxGroup.d.ts +27 -0
- package/Checkbox/CheckboxGroup.js +22 -0
- package/Checkbox/CheckboxGroup.js.map +1 -0
- package/Checkbox/index.d.ts +2 -0
- package/Checkbox/index.js +3 -0
- package/Checkbox/index.js.map +1 -0
- package/CloudflareImage/BaseImage.d.ts +40 -0
- package/CloudflareImage/BaseImage.js +192 -0
- package/CloudflareImage/BaseImage.js.map +1 -0
- package/CloudflareImage/Fallback.d.ts +5 -0
- package/CloudflareImage/Fallback.js +4 -0
- package/CloudflareImage/Fallback.js.map +1 -0
- package/CloudflareImage/FlightImage.d.ts +51 -0
- package/CloudflareImage/FlightImage.js +61 -0
- package/CloudflareImage/FlightImage.js.map +1 -0
- package/CloudflareImage/FlightImage.test.js +277 -0
- package/CloudflareImage/Image.d.ts +2 -0
- package/CloudflareImage/Image.js +3 -0
- package/CloudflareImage/Image.js.map +1 -0
- package/CloudflareImage/index.d.ts +1 -0
- package/CloudflareImage/index.js +2 -0
- package/CloudflareImage/index.js.map +1 -0
- package/CloudflareImage/useConstructImage.d.ts +49 -0
- package/CloudflareImage/useConstructImage.js +122 -0
- package/CloudflareImage/useConstructImage.js.map +1 -0
- package/CloudflareImage/utils/aspectRatioToFraction.d.ts +2 -0
- package/CloudflareImage/utils/aspectRatioToFraction.js +11 -0
- package/CloudflareImage/utils/aspectRatioToFraction.js.map +1 -0
- package/CloudflareImage/utils/getFullUrl.d.ts +6 -0
- package/CloudflareImage/utils/getFullUrl.js +18 -0
- package/CloudflareImage/utils/getFullUrl.js.map +1 -0
- package/CloudflareImage/utils/getImageWidth.d.ts +1 -0
- package/CloudflareImage/utils/getImageWidth.js +12 -0
- package/CloudflareImage/utils/getImageWidth.js.map +1 -0
- package/CloudflareImage/utils/getImageWidths.d.ts +2 -0
- package/CloudflareImage/utils/getImageWidths.js +21 -0
- package/CloudflareImage/utils/getImageWidths.js.map +1 -0
- package/CloudflareImage/utils/getLQIP.d.ts +8 -0
- package/CloudflareImage/utils/getLQIP.js +21 -0
- package/CloudflareImage/utils/getLQIP.js.map +1 -0
- package/CloudflareImage/utils/getLargestSize.d.ts +7 -0
- package/CloudflareImage/utils/getLargestSize.js +17 -0
- package/CloudflareImage/utils/getLargestSize.js.map +1 -0
- package/CloudflareImage/utils/getSizeForBreakpoint.d.ts +2 -0
- package/CloudflareImage/utils/getSizeForBreakpoint.js +16 -0
- package/CloudflareImage/utils/getSizeForBreakpoint.js.map +1 -0
- package/CloudflareImage/utils/getSizesMap.d.ts +2 -0
- package/CloudflareImage/utils/getSizesMap.js +35 -0
- package/CloudflareImage/utils/getSizesMap.js.map +1 -0
- package/CloudflareImage/utils/getSmallestSize.d.ts +2 -0
- package/CloudflareImage/utils/getSmallestSize.js +12 -0
- package/CloudflareImage/utils/getSmallestSize.js.map +1 -0
- package/CloudflareImage/utils/getSrcSetFromWidths.d.ts +10 -0
- package/CloudflareImage/utils/getSrcSetFromWidths.js +10 -0
- package/CloudflareImage/utils/getSrcSetFromWidths.js.map +1 -0
- package/CloudflareImage/utils/getSrcWithParams.d.ts +3 -0
- package/CloudflareImage/utils/getSrcWithParams.js +33 -0
- package/CloudflareImage/utils/getSrcWithParams.js.map +1 -0
- package/CloudflareImage/utils/paddingForAspectRatio.d.ts +1 -0
- package/CloudflareImage/utils/paddingForAspectRatio.js +6 -0
- package/CloudflareImage/utils/paddingForAspectRatio.js.map +1 -0
- package/CloudflareImage/utils/remToPx.d.ts +1 -0
- package/CloudflareImage/utils/remToPx.js +2 -0
- package/CloudflareImage/utils/remToPx.js.map +1 -0
- package/CloudflareImage/utils/sizeToNumber.d.ts +2 -0
- package/CloudflareImage/utils/sizeToNumber.js +27 -0
- package/CloudflareImage/utils/sizeToNumber.js.map +1 -0
- package/ContentPageLink.d.ts +11 -0
- package/ContentPageLink.js +46 -0
- package/ContentPageLink.js.map +1 -0
- package/ContentRenderer.d.ts +9 -0
- package/ContentRenderer.js +36 -0
- package/ContentRenderer.js.map +1 -0
- package/DropdownMenu/Button.d.ts +7 -0
- package/DropdownMenu/Button.js +33 -0
- package/DropdownMenu/Button.js.map +1 -0
- package/DropdownMenu/DropdownMenu.d.ts +21 -0
- package/DropdownMenu/DropdownMenu.js +72 -0
- package/DropdownMenu/DropdownMenu.js.map +1 -0
- package/DropdownMenu/Item.d.ts +13 -0
- package/DropdownMenu/Item.js +48 -0
- package/DropdownMenu/Item.js.map +1 -0
- package/DropdownMenu/Items.d.ts +16 -0
- package/DropdownMenu/Items.js +53 -0
- package/DropdownMenu/Items.js.map +1 -0
- package/DropdownMenu/index.d.ts +4 -0
- package/DropdownMenu/index.js +5 -0
- package/DropdownMenu/index.js.map +1 -0
- package/ErrorBoundary/Generic.d.ts +18 -0
- package/ErrorBoundary/Generic.js +65 -0
- package/ErrorBoundary/Generic.js.map +1 -0
- package/ErrorBoundary/PassThrough.d.ts +3 -0
- package/ErrorBoundary/PassThrough.js +7 -0
- package/ErrorBoundary/PassThrough.js.map +1 -0
- package/Gallery/Gallery.d.ts +39 -0
- package/Gallery/Gallery.js +121 -0
- package/Gallery/Gallery.js.map +1 -0
- package/Gallery/constructGallery.d.ts +15 -0
- package/Gallery/constructGallery.js +40 -0
- package/Gallery/constructGallery.js.map +1 -0
- package/Image/BaseImage.d.ts +39 -0
- package/Image/BaseImage.js +192 -0
- package/Image/BaseImage.js.map +1 -0
- package/Image/Fallback.d.ts +5 -0
- package/Image/Fallback.js +4 -0
- package/Image/Fallback.js.map +1 -0
- package/Image/FlightImage.d.ts +51 -0
- package/Image/FlightImage.js +59 -0
- package/Image/FlightImage.js.map +1 -0
- package/Image/FlightImage.test.js +277 -0
- package/Image/Image.d.ts +2 -0
- package/Image/Image.js +3 -0
- package/Image/Image.js.map +1 -0
- package/Image/index.d.ts +1 -0
- package/Image/index.js +2 -0
- package/Image/index.js.map +1 -0
- package/Image/useConstructImage.d.ts +49 -0
- package/Image/useConstructImage.js +122 -0
- package/Image/useConstructImage.js.map +1 -0
- package/Image/utils/aspectRatioToFraction.d.ts +2 -0
- package/Image/utils/aspectRatioToFraction.js +11 -0
- package/Image/utils/aspectRatioToFraction.js.map +1 -0
- package/Image/utils/getFullUrl.d.ts +6 -0
- package/Image/utils/getFullUrl.js +18 -0
- package/Image/utils/getFullUrl.js.map +1 -0
- package/Image/utils/getImageWidth.d.ts +1 -0
- package/Image/utils/getImageWidth.js +12 -0
- package/Image/utils/getImageWidth.js.map +1 -0
- package/Image/utils/getImageWidths.d.ts +2 -0
- package/Image/utils/getImageWidths.js +21 -0
- package/Image/utils/getImageWidths.js.map +1 -0
- package/Image/utils/getLQIP.d.ts +8 -0
- package/Image/utils/getLQIP.js +20 -0
- package/Image/utils/getLQIP.js.map +1 -0
- package/Image/utils/getLargestSize.d.ts +7 -0
- package/Image/utils/getLargestSize.js +17 -0
- package/Image/utils/getLargestSize.js.map +1 -0
- package/Image/utils/getSizeForBreakpoint.d.ts +2 -0
- package/Image/utils/getSizeForBreakpoint.js +16 -0
- package/Image/utils/getSizeForBreakpoint.js.map +1 -0
- package/Image/utils/getSizesMap.d.ts +2 -0
- package/Image/utils/getSizesMap.js +35 -0
- package/Image/utils/getSizesMap.js.map +1 -0
- package/Image/utils/getSmallestSize.d.ts +2 -0
- package/Image/utils/getSmallestSize.js +12 -0
- package/Image/utils/getSmallestSize.js.map +1 -0
- package/Image/utils/getSrcSetFromWidths.d.ts +10 -0
- package/Image/utils/getSrcSetFromWidths.js +9 -0
- package/Image/utils/getSrcSetFromWidths.js.map +1 -0
- package/Image/utils/getSrcWithParams.d.ts +3 -0
- package/Image/utils/getSrcWithParams.js +29 -0
- package/Image/utils/getSrcWithParams.js.map +1 -0
- package/Image/utils/paddingForAspectRatio.d.ts +1 -0
- package/Image/utils/paddingForAspectRatio.js +6 -0
- package/Image/utils/paddingForAspectRatio.js.map +1 -0
- package/Image/utils/remToPx.d.ts +1 -0
- package/Image/utils/remToPx.js +2 -0
- package/Image/utils/remToPx.js.map +1 -0
- package/Image/utils/sizeToNumber.d.ts +2 -0
- package/Image/utils/sizeToNumber.js +27 -0
- package/Image/utils/sizeToNumber.js.map +1 -0
- package/Input/Input.d.ts +6 -0
- package/Input/Input.js +45 -0
- package/Input/Input.js.map +1 -0
- package/Input/index.d.ts +3 -0
- package/Input/index.js +4 -0
- package/Input/index.js.map +1 -0
- package/JetshopText.d.ts +3 -0
- package/JetshopText.js +13 -0
- package/JetshopText.js.map +1 -0
- package/Loading/LoadingBar.d.ts +8 -0
- package/Loading/LoadingBar.js +58 -0
- package/Loading/LoadingBar.js.map +1 -0
- package/Loading/LoadingLine.d.ts +31 -0
- package/Loading/LoadingLine.js +26 -0
- package/Loading/LoadingLine.js.map +1 -0
- package/Loading/LoadingLine.test.js +18 -0
- package/Loading/NetworkStatusNotifier.d.ts +6 -0
- package/Loading/NetworkStatusNotifier.js +8 -0
- package/Loading/NetworkStatusNotifier.js.map +1 -0
- package/Menu/GetMoreSubcategoriesQuery.gql +25 -0
- package/Menu/MenuContainer.d.ts +28 -0
- package/Menu/MenuContainer.js +46 -0
- package/Menu/MenuContainer.js.map +1 -0
- package/Menu/MenuContainer.test.js +245 -0
- package/Menu/RecursiveTree.d.ts +28 -0
- package/Menu/RecursiveTree.js +91 -0
- package/Menu/RecursiveTree.js.map +1 -0
- package/Menu/RecursiveTree.test.js +417 -0
- package/Modal/Drawer/Drawer.d.ts +12 -0
- package/Modal/Drawer/Drawer.js +31 -0
- package/Modal/Drawer/Drawer.js.map +1 -0
- package/Modal/Drawer/DrawerTarget.d.ts +6 -0
- package/Modal/Drawer/DrawerTarget.js +12 -0
- package/Modal/Drawer/DrawerTarget.js.map +1 -0
- package/Modal/Drawer/DrawerTarget.test.js +92 -0
- package/Modal/Drawer/DrawerTrigger.d.ts +11 -0
- package/Modal/Drawer/DrawerTrigger.js +16 -0
- package/Modal/Drawer/DrawerTrigger.js.map +1 -0
- package/Modal/Drawer/DrawerTrigger.test.js +51 -0
- package/Modal/Drawer/index.d.ts +3 -0
- package/Modal/Drawer/index.js +4 -0
- package/Modal/Drawer/index.js.map +1 -0
- package/Modal/Flyout/FlyoutTarget.d.ts +10 -0
- package/Modal/Flyout/FlyoutTarget.js +15 -0
- package/Modal/Flyout/FlyoutTarget.js.map +1 -0
- package/Modal/Flyout/FlyoutTarget.test.js +84 -0
- package/Modal/Flyout/FlyoutTrigger.d.ts +15 -0
- package/Modal/Flyout/FlyoutTrigger.js +18 -0
- package/Modal/Flyout/FlyoutTrigger.js.map +1 -0
- package/Modal/Flyout/FlyoutTrigger.test.js +72 -0
- package/Modal/Flyout/index.d.ts +2 -0
- package/Modal/Flyout/index.js +3 -0
- package/Modal/Flyout/index.js.map +1 -0
- package/Modal/ModalContext.d.ts +26 -0
- package/Modal/ModalContext.js +9 -0
- package/Modal/ModalContext.js.map +1 -0
- package/Modal/ModalProvider.d.ts +5 -0
- package/Modal/ModalProvider.js +83 -0
- package/Modal/ModalProvider.js.map +1 -0
- package/Modal/ModalProvider.test.js +26 -0
- package/Modal/ModalRoot.d.ts +3 -0
- package/Modal/ModalRoot.js +44 -0
- package/Modal/ModalRoot.js.map +1 -0
- package/Modal/ModalRoot.test.js +80 -0
- package/Modal/ModalTrigger.d.ts +9 -0
- package/Modal/ModalTrigger.js +9 -0
- package/Modal/ModalTrigger.js.map +1 -0
- package/Modal/__test_utils__/getComponentWithModalContext.js +29 -0
- package/Pagination/Pagination.d.ts +7 -0
- package/Pagination/Pagination.js +23 -0
- package/Pagination/Pagination.js.map +1 -0
- package/Pagination/PaginationBehaviour.d.ts +52 -0
- package/Pagination/PaginationBehaviour.js +68 -0
- package/Pagination/PaginationBehaviour.js.map +1 -0
- package/Pagination/index.d.ts +2 -0
- package/Pagination/index.js +3 -0
- package/Pagination/index.js.map +1 -0
- package/Pagination/usePagination.d.ts +15 -0
- package/Pagination/usePagination.js +46 -0
- package/Pagination/usePagination.js.map +1 -0
- package/PreOrderDateSelector/PreOrderDateSelector.d.ts +23 -0
- package/PreOrderDateSelector/PreOrderDateSelector.js +74 -0
- package/PreOrderDateSelector/PreOrderDateSelector.js.map +1 -0
- package/PreOrderDateSelector/index.d.ts +2 -0
- package/PreOrderDateSelector/index.js +3 -0
- package/PreOrderDateSelector/index.js.map +1 -0
- package/Price/Currency.d.ts +9 -0
- package/Price/Currency.js +11 -0
- package/Price/Currency.js.map +1 -0
- package/Price/Price.d.ts +44 -0
- package/Price/Price.js +74 -0
- package/Price/Price.js.map +1 -0
- package/Price/index.d.ts +1 -0
- package/Price/index.js +2 -0
- package/Price/index.js.map +1 -0
- package/ProductLink.d.ts +23 -0
- package/ProductLink.js +88 -0
- package/ProductLink.js.map +1 -0
- package/ProductList/Badges.d.ts +6 -0
- package/ProductList/Badges.js +56 -0
- package/ProductList/Badges.js.map +1 -0
- package/ProductList/GridProduct.d.ts +24 -0
- package/ProductList/GridProduct.js +58 -0
- package/ProductList/GridProduct.js.map +1 -0
- package/ProductList/ProductGrid.d.ts +16 -0
- package/ProductList/ProductGrid.js +30 -0
- package/ProductList/ProductGrid.js.map +1 -0
- package/ProductList/ProductImage.d.ts +12 -0
- package/ProductList/ProductImage.js +21 -0
- package/ProductList/ProductImage.js.map +1 -0
- package/ProductSpecifications/ProductSpecifications.d.ts +8 -0
- package/ProductSpecifications/ProductSpecifications.js +78 -0
- package/ProductSpecifications/ProductSpecifications.js.map +1 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.d.ts +8 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.js +17 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.js.map +1 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.test.js +75 -0
- package/ScrollRestorationHandler/index.d.ts +1 -0
- package/ScrollRestorationHandler/index.js +2 -0
- package/ScrollRestorationHandler/index.js.map +1 -0
- package/ScrollRestorationHandler/isInIgnoredRouteTypes.d.ts +8 -0
- package/ScrollRestorationHandler/isInIgnoredRouteTypes.js +8 -0
- package/ScrollRestorationHandler/isInIgnoredRouteTypes.js.map +1 -0
- package/ScrollRestorationHandler/useScrollRestore.d.ts +9 -0
- package/ScrollRestorationHandler/useScrollRestore.js +20 -0
- package/ScrollRestorationHandler/useScrollRestore.js.map +1 -0
- package/Search/AutocompleteQuery.gql +10 -0
- package/Search/SearchAutoCompleteContainer.d.ts +45 -0
- package/Search/SearchAutoCompleteContainer.js +172 -0
- package/Search/SearchAutoCompleteContainer.js.map +1 -0
- package/Search/SearchAutoCompleteContainer.test.js +460 -0
- package/Search/SearchField.d.ts +26 -0
- package/Search/SearchField.js +98 -0
- package/Search/SearchField.js.map +1 -0
- package/Search/SearchPage/PageOf.d.ts +5 -0
- package/Search/SearchPage/PageOf.js +7 -0
- package/Search/SearchPage/PageOf.js.map +1 -0
- package/Search/SearchPage/SearchMeta.d.ts +16 -0
- package/Search/SearchPage/SearchMeta.js +20 -0
- package/Search/SearchPage/SearchMeta.js.map +1 -0
- package/Search/SearchPage/SearchPageBehaviour.d.ts +19 -0
- package/Search/SearchPage/SearchPageBehaviour.js +75 -0
- package/Search/SearchPage/SearchPageBehaviour.js.map +1 -0
- package/Search/SuggestedTerm.d.ts +16 -0
- package/Search/SuggestedTerm.js +35 -0
- package/Search/SuggestedTerm.js.map +1 -0
- package/Search/index.d.ts +1 -0
- package/Search/index.js +2 -0
- package/Search/index.js.map +1 -0
- package/Select/Components.d.ts +28 -0
- package/Select/Components.js +91 -0
- package/Select/Components.js.map +1 -0
- package/Select/SelectComponents/Quantity.d.ts +5 -0
- package/Select/SelectComponents/Quantity.js +8 -0
- package/Select/SelectComponents/Quantity.js.map +1 -0
- package/Select/index.d.ts +5 -0
- package/Select/index.js +2 -0
- package/Select/index.js.map +1 -0
- package/SortOrder/SortOrder.d.ts +16 -0
- package/SortOrder/SortOrder.js +33 -0
- package/SortOrder/SortOrder.js.map +1 -0
- package/SortOrder/SortOrderDropdown.d.ts +9 -0
- package/SortOrder/SortOrderDropdown.js +25 -0
- package/SortOrder/SortOrderDropdown.js.map +1 -0
- package/SortOrder/SortOrderList.d.ts +7 -0
- package/SortOrder/SortOrderList.js +17 -0
- package/SortOrder/SortOrderList.js.map +1 -0
- package/StartPageRenderer/StartPageRenderer.d.ts +17 -0
- package/StartPageRenderer/StartPageRenderer.js +52 -0
- package/StartPageRenderer/StartPageRenderer.js.map +1 -0
- package/StartPageRenderer/index.d.ts +1 -0
- package/StartPageRenderer/index.js +2 -0
- package/StartPageRenderer/index.js.map +1 -0
- package/Stock/StockStatusContainer.d.ts +21 -0
- package/Stock/StockStatusContainer.js +45 -0
- package/Stock/StockStatusContainer.js.map +1 -0
- package/Stock/__tests__/StockStatusContainer.test.js +65 -0
- package/Text/Text.d.ts +11 -0
- package/Text/Text.js +22 -0
- package/Text/Text.js.map +1 -0
- package/Text/index.d.ts +3 -0
- package/Text/index.js +4 -0
- package/Text/index.js.map +1 -0
- package/Theme/createTheme.d.ts +16 -0
- package/Theme/createTheme.js +5 -0
- package/Theme/createTheme.js.map +1 -0
- package/Theme/cssReset.d.ts +1 -0
- package/Theme/cssReset.js +160 -0
- package/Theme/cssReset.js.map +1 -0
- package/Theme/normalizeCss.d.ts +1 -0
- package/Theme/normalizeCss.js +357 -0
- package/Theme/normalizeCss.js.map +1 -0
- package/Theme/sanitizeCss.d.ts +1 -0
- package/Theme/sanitizeCss.js +572 -0
- package/Theme/sanitizeCss.js.map +1 -0
- package/WindowGrid/WindowGrid.d.ts +11 -0
- package/WindowGrid/WindowGrid.js +58 -0
- package/WindowGrid/WindowGrid.js.map +1 -0
- package/WindowGrid/index.d.ts +1 -0
- package/WindowGrid/index.js +2 -0
- package/WindowGrid/index.js.map +1 -0
- package/WindowGrid/useResizeObserver.d.ts +3 -0
- package/WindowGrid/useResizeObserver.js +14 -0
- package/WindowGrid/useResizeObserver.js.map +1 -0
- package/WindowGrid/useScrollWithWindow.d.ts +12 -0
- package/WindowGrid/useScrollWithWindow.js +39 -0
- package/WindowGrid/useScrollWithWindow.js.map +1 -0
- package/dependencies.d.ts +98 -0
- package/fuzzySearch/fuzzySearch.d.ts +8 -0
- package/fuzzySearch/fuzzySearch.js +43 -0
- package/fuzzySearch/fuzzySearch.js.map +1 -0
- package/fuzzySearch/index.d.ts +1 -0
- package/fuzzySearch/index.js +2 -0
- package/fuzzySearch/index.js.map +1 -0
- package/global.d.ts +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useOnClickOutside.d.ts +6 -0
- package/hooks/useOnClickOutside.js +17 -0
- package/hooks/useOnClickOutside.js.map +1 -0
- package/hooks/useOnEsc.d.ts +4 -0
- package/hooks/useOnEsc.js +17 -0
- package/hooks/useOnEsc.js.map +1 -0
- package/package.json +64 -0
- package/setupTests.js +2 -0
- package/svg/Carrot.svg +1 -0
- package/svg/Check.svg +1 -0
- package/svg/Cross.svg +1 -0
- package/svg/facebook.svg +1 -0
- package/svg/flags/ad.svg +150 -0
- package/svg/flags/ae.svg +6 -0
- package/svg/flags/af.svg +81 -0
- package/svg/flags/ag.svg +14 -0
- package/svg/flags/ai.svg +767 -0
- package/svg/flags/al.svg +5 -0
- package/svg/flags/am.svg +5 -0
- package/svg/flags/ao.svg +13 -0
- package/svg/flags/aq.svg +6 -0
- package/svg/flags/ar.svg +31 -0
- package/svg/flags/as.svg +33 -0
- package/svg/flags/at.svg +6 -0
- package/svg/flags/au.svg +9 -0
- package/svg/flags/aw.svg +186 -0
- package/svg/flags/ax.svg +18 -0
- package/svg/flags/az.svg +8 -0
- package/svg/flags/ba.svg +12 -0
- package/svg/flags/bb.svg +6 -0
- package/svg/flags/bd.svg +4 -0
- package/svg/flags/be.svg +7 -0
- package/svg/flags/bf.svg +7 -0
- package/svg/flags/bg.svg +7 -0
- package/svg/flags/bh.svg +11 -0
- package/svg/flags/bi.svg +15 -0
- package/svg/flags/bj.svg +14 -0
- package/svg/flags/bl.svg +7 -0
- package/svg/flags/bm.svg +98 -0
- package/svg/flags/bn.svg +36 -0
- package/svg/flags/bo.svg +676 -0
- package/svg/flags/bq.svg +5 -0
- package/svg/flags/br.svg +45 -0
- package/svg/flags/bs.svg +13 -0
- package/svg/flags/bt.svg +89 -0
- package/svg/flags/bv.svg +13 -0
- package/svg/flags/bw.svg +7 -0
- package/svg/flags/by.svg +20 -0
- package/svg/flags/bz.svg +145 -0
- package/svg/flags/ca.svg +4 -0
- package/svg/flags/cc.svg +19 -0
- package/svg/flags/cd.svg +5 -0
- package/svg/flags/cf.svg +15 -0
- package/svg/flags/cg.svg +12 -0
- package/svg/flags/ch.svg +9 -0
- package/svg/flags/ci.svg +7 -0
- package/svg/flags/ck.svg +9 -0
- package/svg/flags/cl.svg +13 -0
- package/svg/flags/cm.svg +15 -0
- package/svg/flags/cn.svg +11 -0
- package/svg/flags/co.svg +7 -0
- package/svg/flags/cr.svg +7 -0
- package/svg/flags/cu.svg +13 -0
- package/svg/flags/cv.svg +13 -0
- package/svg/flags/cw.svg +14 -0
- package/svg/flags/cx.svg +15 -0
- package/svg/flags/cy.svg +6 -0
- package/svg/flags/cz.svg +12 -0
- package/svg/flags/de.svg +5 -0
- package/svg/flags/dj.svg +13 -0
- package/svg/flags/dk.svg +5 -0
- package/svg/flags/dm.svg +152 -0
- package/svg/flags/do.svg +6745 -0
- package/svg/flags/dz.svg +5 -0
- package/svg/flags/ec.svg +138 -0
- package/svg/flags/ee.svg +7 -0
- package/svg/flags/eg.svg +38 -0
- package/svg/flags/eh.svg +15 -0
- package/svg/flags/er.svg +8 -0
- package/svg/flags/es-ct.svg +4 -0
- package/svg/flags/es.svg +544 -0
- package/svg/flags/et.svg +14 -0
- package/svg/flags/eu.svg +28 -0
- package/svg/flags/fi.svg +5 -0
- package/svg/flags/fj.svg +120 -0
- package/svg/flags/fk.svg +89 -0
- package/svg/flags/fm.svg +11 -0
- package/svg/flags/fo.svg +12 -0
- package/svg/flags/fr.svg +7 -0
- package/svg/flags/ga.svg +7 -0
- package/svg/flags/gb-eng.svg +5 -0
- package/svg/flags/gb-nir.svg +131 -0
- package/svg/flags/gb-sct.svg +4 -0
- package/svg/flags/gb-wls.svg +9 -0
- package/svg/flags/gb.svg +15 -0
- package/svg/flags/gd.svg +27 -0
- package/svg/flags/ge.svg +6 -0
- package/svg/flags/gf.svg +5 -0
- package/svg/flags/gg.svg +9 -0
- package/svg/flags/gh.svg +6 -0
- package/svg/flags/gi.svg +32 -0
- package/svg/flags/gl.svg +4 -0
- package/svg/flags/gm.svg +14 -0
- package/svg/flags/gn.svg +7 -0
- package/svg/flags/gp.svg +7 -0
- package/svg/flags/gq.svg +23 -0
- package/svg/flags/gr.svg +22 -0
- package/svg/flags/gs.svg +201 -0
- package/svg/flags/gt.svg +204 -0
- package/svg/flags/gu.svg +39 -0
- package/svg/flags/gw.svg +13 -0
- package/svg/flags/gy.svg +9 -0
- package/svg/flags/hk.svg +30 -0
- package/svg/flags/hm.svg +9 -0
- package/svg/flags/hn.svg +18 -0
- package/svg/flags/hr.svg +58 -0
- package/svg/flags/ht.svg +116 -0
- package/svg/flags/hu.svg +7 -0
- package/svg/flags/id.svg +6 -0
- package/svg/flags/ie.svg +7 -0
- package/svg/flags/il.svg +14 -0
- package/svg/flags/im.svg +36 -0
- package/svg/flags/in.svg +25 -0
- package/svg/flags/io.svg +138 -0
- package/svg/flags/iq.svg +10 -0
- package/svg/flags/ir.svg +219 -0
- package/svg/flags/is.svg +12 -0
- package/svg/flags/it.svg +7 -0
- package/svg/flags/je.svg +31 -0
- package/svg/flags/jm.svg +8 -0
- package/svg/flags/jo.svg +16 -0
- package/svg/flags/jp.svg +11 -0
- package/svg/flags/ke.svg +23 -0
- package/svg/flags/kg.svg +15 -0
- package/svg/flags/kh.svg +61 -0
- package/svg/flags/ki.svg +36 -0
- package/svg/flags/km.svg +16 -0
- package/svg/flags/kn.svg +14 -0
- package/svg/flags/kp.svg +15 -0
- package/svg/flags/kr.svg +24 -0
- package/svg/flags/kw.svg +13 -0
- package/svg/flags/ky.svg +63 -0
- package/svg/flags/kz.svg +23 -0
- package/svg/flags/la.svg +12 -0
- package/svg/flags/lb.svg +15 -0
- package/svg/flags/lc.svg +8 -0
- package/svg/flags/li.svg +43 -0
- package/svg/flags/lk.svg +22 -0
- package/svg/flags/lr.svg +14 -0
- package/svg/flags/ls.svg +8 -0
- package/svg/flags/lt.svg +7 -0
- package/svg/flags/lu.svg +5 -0
- package/svg/flags/lv.svg +6 -0
- package/svg/flags/ly.svg +13 -0
- package/svg/flags/ma.svg +4 -0
- package/svg/flags/mc.svg +6 -0
- package/svg/flags/md.svg +70 -0
- package/svg/flags/me.svg +116 -0
- package/svg/flags/mf.svg +7 -0
- package/svg/flags/mg.svg +7 -0
- package/svg/flags/mh.svg +7 -0
- package/svg/flags/mk.svg +5 -0
- package/svg/flags/ml.svg +7 -0
- package/svg/flags/mm.svg +16 -0
- package/svg/flags/mn.svg +13 -0
- package/svg/flags/mo.svg +9 -0
- package/svg/flags/mp.svg +86 -0
- package/svg/flags/mq.svg +7 -0
- package/svg/flags/mr.svg +6 -0
- package/svg/flags/ms.svg +39 -0
- package/svg/flags/mt.svg +49 -0
- package/svg/flags/mu.svg +8 -0
- package/svg/flags/mv.svg +6 -0
- package/svg/flags/mw.svg +10 -0
- package/svg/flags/mx.svg +382 -0
- package/svg/flags/my.svg +15 -0
- package/svg/flags/mz.svg +21 -0
- package/svg/flags/na.svg +16 -0
- package/svg/flags/nc.svg +7 -0
- package/svg/flags/ne.svg +6 -0
- package/svg/flags/nf.svg +9 -0
- package/svg/flags/ng.svg +6 -0
- package/svg/flags/ni.svg +129 -0
- package/svg/flags/nl.svg +7 -0
- package/svg/flags/no.svg +7 -0
- package/svg/flags/np.svg +14 -0
- package/svg/flags/nr.svg +12 -0
- package/svg/flags/nu.svg +26 -0
- package/svg/flags/nz.svg +41 -0
- package/svg/flags/om.svg +115 -0
- package/svg/flags/pa.svg +14 -0
- package/svg/flags/pe.svg +244 -0
- package/svg/flags/pf.svg +19 -0
- package/svg/flags/pg.svg +9 -0
- package/svg/flags/ph.svg +13 -0
- package/svg/flags/pk.svg +15 -0
- package/svg/flags/pl.svg +6 -0
- package/svg/flags/pm.svg +7 -0
- package/svg/flags/pn.svg +62 -0
- package/svg/flags/pr.svg +13 -0
- package/svg/flags/ps.svg +15 -0
- package/svg/flags/pt.svg +57 -0
- package/svg/flags/pw.svg +11 -0
- package/svg/flags/py.svg +157 -0
- package/svg/flags/qa.svg +4 -0
- package/svg/flags/re.svg +7 -0
- package/svg/flags/ro.svg +7 -0
- package/svg/flags/rs.svg +292 -0
- package/svg/flags/ru.svg +7 -0
- package/svg/flags/rw.svg +13 -0
- package/svg/flags/sa.svg +26 -0
- package/svg/flags/sb.svg +13 -0
- package/svg/flags/sc.svg +14 -0
- package/svg/flags/sd.svg +13 -0
- package/svg/flags/se.svg +16 -0
- package/svg/flags/sg.svg +13 -0
- package/svg/flags/sh.svg +74 -0
- package/svg/flags/si.svg +18 -0
- package/svg/flags/sj.svg +7 -0
- package/svg/flags/sk.svg +9 -0
- package/svg/flags/sl.svg +7 -0
- package/svg/flags/sm.svg +91 -0
- package/svg/flags/sn.svg +8 -0
- package/svg/flags/so.svg +11 -0
- package/svg/flags/sr.svg +6 -0
- package/svg/flags/ss.svg +8 -0
- package/svg/flags/st.svg +16 -0
- package/svg/flags/sv.svg +606 -0
- package/svg/flags/sx.svg +56 -0
- package/svg/flags/sy.svg +6 -0
- package/svg/flags/sz.svg +45 -0
- package/svg/flags/tc.svg +67 -0
- package/svg/flags/td.svg +7 -0
- package/svg/flags/tf.svg +15 -0
- package/svg/flags/tg.svg +14 -0
- package/svg/flags/th.svg +7 -0
- package/svg/flags/tj.svg +22 -0
- package/svg/flags/tk.svg +5 -0
- package/svg/flags/tl.svg +13 -0
- package/svg/flags/tm.svg +206 -0
- package/svg/flags/tn.svg +13 -0
- package/svg/flags/to.svg +10 -0
- package/svg/flags/tr.svg +8 -0
- package/svg/flags/tt.svg +5 -0
- package/svg/flags/tv.svg +27 -0
- package/svg/flags/tw.svg +14 -0
- package/svg/flags/tz.svg +13 -0
- package/svg/flags/ua.svg +6 -0
- package/svg/flags/ug.svg +30 -0
- package/svg/flags/um.svg +15 -0
- package/svg/flags/un.svg +16 -0
- package/svg/flags/us.svg +10 -0
- package/svg/flags/uy.svg +28 -0
- package/svg/flags/uz.svg +30 -0
- package/svg/flags/va.svg +479 -0
- package/svg/flags/vc.svg +8 -0
- package/svg/flags/ve.svg +26 -0
- package/svg/flags/vg.svg +127 -0
- package/svg/flags/vi.svg +28 -0
- package/svg/flags/vn.svg +11 -0
- package/svg/flags/vu.svg +18 -0
- package/svg/flags/wf.svg +7 -0
- package/svg/flags/ws.svg +7 -0
- package/svg/flags/ye.svg +7 -0
- package/svg/flags/yt.svg +7 -0
- package/svg/flags/za.svg +17 -0
- package/svg/flags/zm.svg +27 -0
- package/svg/flags/zw.svg +21 -0
- package/svg/instagram.svg +1 -0
- package/test-utils/mock-response/product-status.js +44 -0
- package/utils/breakpoints.d.ts +23 -0
- package/utils/breakpoints.js +94 -0
- package/utils/breakpoints.js.map +1 -0
- package/utils/callAllEventHandlers.d.ts +5 -0
- package/utils/callAllEventHandlers.js +9 -0
- package/utils/callAllEventHandlers.js.map +1 -0
- package/utils/text.d.ts +1 -0
- package/utils/text.js +23 -0
- package/utils/text.js.map +1 -0
- package/utils/theme.d.ts +3 -0
- package/utils/theme.js +5 -0
- package/utils/theme.js.map +1 -0
- package/utils/useHoverIntent.d.ts +10 -0
- package/utils/useHoverIntent.js +78 -0
- package/utils/useHoverIntent.js.map +1 -0
- package/utils/usePropsOfType.d.ts +11 -0
- package/utils/usePropsOfType.js +18 -0
- package/utils/usePropsOfType.js.map +1 -0
- package/withFlightUI.d.ts +17 -0
- package/withFlightUI.js +20 -0
- package/withFlightUI.js.map +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ModalContext from '../ModalContext';
|
|
3
|
+
export class FlyoutTarget extends React.Component {
|
|
4
|
+
render() {
|
|
5
|
+
const { id, children } = this.props;
|
|
6
|
+
return (React.createElement(ModalContext.Consumer, null, ({ modals }) => {
|
|
7
|
+
const { modalId, isOpen, modalType, hideTarget } = modals.find(({ modalId }) => modalId === id) || {};
|
|
8
|
+
return isOpen && modalId === id && modalType === 'flyout'
|
|
9
|
+
? children({ hideTarget, isOpen })
|
|
10
|
+
: null;
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default FlyoutTarget;
|
|
15
|
+
//# sourceMappingURL=FlyoutTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlyoutTarget.js","sourceRoot":"","sources":["FlyoutTarget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,YAA4B,MAAM,iBAAiB,CAAC;AAO3D,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAAiC;IACvE,MAAM;QACJ,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACpC,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACd,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAC9C,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YACrD,OAAO,MAAM,IAAI,OAAO,KAAK,EAAE,IAAI,SAAS,KAAK,QAAQ;gBACvD,CAAC,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;gBAClC,CAAC,CAAC,IAAI,CAAC;QACX,CAAC,CACqB,CACzB,CAAC;IACJ,CAAC;CACF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getComponentWithModalContext, {
|
|
3
|
+
defaultContext
|
|
4
|
+
} from '../__test_utils__/getComponentWithModalContext';
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.resetModules();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const target = getComponentWithModalContext('Flyout/FlyoutTarget');
|
|
11
|
+
|
|
12
|
+
xdescribe('FlyoutTarget', () => {
|
|
13
|
+
describe('renders null', () => {
|
|
14
|
+
let wrapper;
|
|
15
|
+
let unreachableChild = jest
|
|
16
|
+
.fn()
|
|
17
|
+
.mockReturnValue('This should never render');
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
expect(wrapper.children().children()).toHaveLength(0);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('when isOpen is false', () => {
|
|
24
|
+
const FlyoutTarget = target();
|
|
25
|
+
wrapper = mount(<FlyoutTarget>{unreachableChild}</FlyoutTarget>);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('when isOpen is true but ID prop does not match modalId', () => {
|
|
29
|
+
const FlyoutTarget = target({
|
|
30
|
+
...defaultContext,
|
|
31
|
+
modals: [
|
|
32
|
+
{
|
|
33
|
+
isOpen: true,
|
|
34
|
+
modalId: 'bar'
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
wrapper = mount(<FlyoutTarget id="foo">{unreachableChild}</FlyoutTarget>);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('when isOpen is true and ID matches, but `modalType` is not `flyout`', () => {
|
|
42
|
+
const FlyoutTarget = target({
|
|
43
|
+
...defaultContext,
|
|
44
|
+
modals: [{ isOpen: true, modalId: 'foo', modalType: 'modal' }]
|
|
45
|
+
});
|
|
46
|
+
wrapper = mount(<FlyoutTarget id="foo">{unreachableChild}</FlyoutTarget>);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('renders a child component', () => {
|
|
51
|
+
let wrapper;
|
|
52
|
+
let FlyoutTarget;
|
|
53
|
+
let reachableChild = jest.fn().mockReturnValue('Hello from the inside!');
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
FlyoutTarget = target({
|
|
57
|
+
...defaultContext,
|
|
58
|
+
modals: [{ isOpen: true, modalId: 'foo', modalType: 'flyout' }]
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
afterEach(() => {
|
|
63
|
+
expect(wrapper.children().children()).toHaveLength(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('when isOpen is true, `modalId` and `id` prop match, and `modalType` is `flyout`', () => {
|
|
67
|
+
wrapper = mount(<FlyoutTarget id="foo">{reachableChild}</FlyoutTarget>);
|
|
68
|
+
expect(wrapper.children().text()).toBe('Hello from the inside!');
|
|
69
|
+
});
|
|
70
|
+
it('with `isOpen` prop passed', () => {
|
|
71
|
+
expect(wrapper.children().children().props().modals[0].isOpen).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
it('with `modalType` prop passed', () => {
|
|
74
|
+
expect(wrapper.children().children().props().modals[0].modalType).toBe(
|
|
75
|
+
'flyout'
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
it('with `hideTarget` func passed', () => {
|
|
79
|
+
expect(wrapper.children().children().props().hideTarget).toBe(
|
|
80
|
+
defaultContext.hideTarget
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ModalState } from '../ModalContext';
|
|
3
|
+
export declare const FlyoutTrigger: React.SFC<{
|
|
4
|
+
id: string;
|
|
5
|
+
/** Whether to show a clickable semi-opaque Cover behind the flyout */
|
|
6
|
+
showCover?: boolean;
|
|
7
|
+
/** Whether to prevent the body from scrolling when flyout is open */
|
|
8
|
+
preventOverflow?: boolean;
|
|
9
|
+
/** Whether to able to close modal via Escape button */
|
|
10
|
+
canCloseOnEsc?: boolean;
|
|
11
|
+
coverStyles?: {};
|
|
12
|
+
children: (args: Pick<ModalState, 'hideTarget' | 'isOpen'> & {
|
|
13
|
+
showTarget: () => void;
|
|
14
|
+
}) => React.ReactNode;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ModalContext from '../ModalContext';
|
|
3
|
+
export const FlyoutTrigger = ({ id, children, showCover = true, preventOverflow = false, canCloseOnEsc = true, coverStyles }) => {
|
|
4
|
+
return (React.createElement(ModalContext.Consumer, null, ({ showTarget, hideTarget, modals }) => {
|
|
5
|
+
const open = () => showTarget(null, 'flyout', id, {
|
|
6
|
+
showCover,
|
|
7
|
+
coverStyles,
|
|
8
|
+
preventOverflow,
|
|
9
|
+
canCloseOnEsc
|
|
10
|
+
});
|
|
11
|
+
return children({
|
|
12
|
+
showTarget: open,
|
|
13
|
+
hideTarget,
|
|
14
|
+
isOpen: modals.some(({ modalId }) => modalId === id)
|
|
15
|
+
});
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=FlyoutTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlyoutTrigger.js","sourceRoot":"","sources":["FlyoutTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,YAA4B,MAAM,iBAAiB,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAYrB,CAAC,EACJ,EAAE,EACF,QAAQ,EACR,SAAS,GAAG,IAAI,EAChB,eAAe,GAAG,KAAK,EACvB,aAAa,GAAG,IAAI,EACpB,WAAW,EACZ,EAAE,EAAE;IACH,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;QACtC,MAAM,IAAI,GAAG,GAAG,EAAE,CAChB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC7B,SAAS;YACT,WAAW;YACX,eAAe;YACf,aAAa;SACd,CAAC,CAAC;QACL,OAAO,QAAQ,CAAC;YACd,UAAU,EAAE,IAAI;YAChB,UAAU;YACV,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC;SACrD,CAAC,CAAC;IACL,CAAC,CACqB,CACzB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getComponentWithModalContext, {
|
|
3
|
+
defaultContext
|
|
4
|
+
} from '../__test_utils__/getComponentWithModalContext';
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.resetModules();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const trigger = getComponentWithModalContext(
|
|
11
|
+
'Flyout/FlyoutTrigger',
|
|
12
|
+
'FlyoutTrigger'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
xdescribe('DrawerTrigger', () => {
|
|
16
|
+
let funcAsChild = jest.fn().mockReturnValue(<div>Rendered child</div>);
|
|
17
|
+
|
|
18
|
+
it('renders a Consumer', () => {
|
|
19
|
+
const DrawerTrigger = trigger();
|
|
20
|
+
const wrapper = mount(<DrawerTrigger>{funcAsChild}</DrawerTrigger>);
|
|
21
|
+
expect(wrapper.find('Consumer')).toHaveLength(1);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('takes a func as child prop', () => {
|
|
25
|
+
it('calls it with `showTarget`, `hideTarget`, and `isOpen`', () => {
|
|
26
|
+
const DrawerTrigger = trigger();
|
|
27
|
+
|
|
28
|
+
mount(<DrawerTrigger id="foo">{funcAsChild}</DrawerTrigger>);
|
|
29
|
+
expect(funcAsChild).toHaveBeenCalledWith(
|
|
30
|
+
expect.objectContaining({
|
|
31
|
+
showTarget: expect.any(Function),
|
|
32
|
+
hideTarget: defaultContext.hideTarget,
|
|
33
|
+
isOpen: defaultContext.isOpen
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('calls `showTarget`', () => {
|
|
40
|
+
it('with `id` passed via prop', () => {
|
|
41
|
+
const TRIGGER_ID = 'foo';
|
|
42
|
+
const DrawerTrigger = trigger();
|
|
43
|
+
const wrapper = mount(
|
|
44
|
+
<DrawerTrigger id={TRIGGER_ID}>
|
|
45
|
+
{({ showTarget }) => <div onClick={showTarget}>hello</div>}
|
|
46
|
+
</DrawerTrigger>
|
|
47
|
+
);
|
|
48
|
+
wrapper.find('div').simulate('click');
|
|
49
|
+
expect(defaultContext.showTarget).toHaveBeenLastCalledWith(
|
|
50
|
+
null,
|
|
51
|
+
'flyout',
|
|
52
|
+
TRIGGER_ID,
|
|
53
|
+
expect.any(Object)
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
it('with `showCover` passed via prop', () => {
|
|
57
|
+
const DrawerTrigger = trigger();
|
|
58
|
+
const wrapper = mount(
|
|
59
|
+
<DrawerTrigger id="foo" showCover={false}>
|
|
60
|
+
{({ showTarget }) => <div onClick={showTarget}>hello</div>}
|
|
61
|
+
</DrawerTrigger>
|
|
62
|
+
);
|
|
63
|
+
wrapper.find('div').simulate('click');
|
|
64
|
+
expect(defaultContext.showTarget).toHaveBeenLastCalledWith(
|
|
65
|
+
null,
|
|
66
|
+
'flyout',
|
|
67
|
+
'foo',
|
|
68
|
+
expect.objectContaining({ showCover: false })
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ModalState {
|
|
3
|
+
/** If modalType is modal, render this component at the modalRoot */
|
|
4
|
+
modalComponent?: React.ReactNode;
|
|
5
|
+
/** The type of modal to display */
|
|
6
|
+
modalType: 'modal' | 'flyout' | 'drawer';
|
|
7
|
+
/** An ID used to identify which flyout to display */
|
|
8
|
+
modalId?: string;
|
|
9
|
+
/** Called when a modal is requested */
|
|
10
|
+
showTarget(...args: any[]): void;
|
|
11
|
+
/** Called when a modal is dismissed */
|
|
12
|
+
hideTarget(...args: any[]): void;
|
|
13
|
+
/** Whether a modal is open */
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
/** props to be passed on to the displayed modalComponent */
|
|
16
|
+
props?: any;
|
|
17
|
+
}
|
|
18
|
+
export interface ModalContextProps {
|
|
19
|
+
/** Called when a modal is requested */
|
|
20
|
+
showTarget(...args: any[]): void;
|
|
21
|
+
/** Called when a modal is dismissed */
|
|
22
|
+
hideTarget(...args: any[]): void;
|
|
23
|
+
modals: ModalState[];
|
|
24
|
+
}
|
|
25
|
+
declare const ModalContext: React.Context<ModalContextProps>;
|
|
26
|
+
export default ModalContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sourceRoot":"","sources":["ModalContext.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA2B7C,MAAM,iBAAiB,GAAsB;IAC3C,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,MAAM,YAAY,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAEtD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useEffect, useState, useCallback } from 'react';
|
|
2
|
+
import ModalContext from './ModalContext';
|
|
3
|
+
import ReactModal from 'react-modal';
|
|
4
|
+
import { css } from 'linaria';
|
|
5
|
+
const preventBodyScrollStyle = css `
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
`;
|
|
8
|
+
const ModalProvider = ({ children }) => {
|
|
9
|
+
const [modals, setModals] = useState([]);
|
|
10
|
+
function showTarget(modalComponent, modalType, modalId, props = {}) {
|
|
11
|
+
setModals((prevModals) => {
|
|
12
|
+
const newModals = [...prevModals];
|
|
13
|
+
const modalProps = {
|
|
14
|
+
modalComponent,
|
|
15
|
+
modalId,
|
|
16
|
+
modalType,
|
|
17
|
+
isOpen: true,
|
|
18
|
+
props,
|
|
19
|
+
showTarget,
|
|
20
|
+
hideTarget: () => hideTarget(modalId)
|
|
21
|
+
};
|
|
22
|
+
// Check if modal with same id already exists
|
|
23
|
+
const matchIndex = newModals.findIndex((modal) => modal.modalId === modalId);
|
|
24
|
+
if (matchIndex >= 0)
|
|
25
|
+
newModals[matchIndex] = modalProps;
|
|
26
|
+
else
|
|
27
|
+
newModals.push(modalProps);
|
|
28
|
+
return newModals;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function hideTarget(modalId) {
|
|
32
|
+
setModals((prevModals) => {
|
|
33
|
+
const newModals = [...prevModals];
|
|
34
|
+
// Calling hideTarget directly from a MouseEvent passes down an event
|
|
35
|
+
// object. Therefore we have to check if the passed prop is a string.
|
|
36
|
+
if (modalId && typeof modalId === 'string') {
|
|
37
|
+
// Removing the modal based on modalId if opened
|
|
38
|
+
const matchIndex = newModals.findIndex((modal) => modal.modalId === modalId);
|
|
39
|
+
if (matchIndex >= 0)
|
|
40
|
+
newModals.splice(matchIndex, 1);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Removing the last opened modal
|
|
44
|
+
newModals.pop();
|
|
45
|
+
}
|
|
46
|
+
return newModals;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// Handling modal close on Escape button
|
|
50
|
+
const handleKeydown = useCallback((e) => {
|
|
51
|
+
if (e.key !== 'Escape' || modals.length === 0)
|
|
52
|
+
return;
|
|
53
|
+
const lastModal = modals[modals.length - 1];
|
|
54
|
+
if (!lastModal.props.canCloseOnEsc)
|
|
55
|
+
return;
|
|
56
|
+
hideTarget();
|
|
57
|
+
}, [modals]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
ReactModal.setAppElement('#root');
|
|
60
|
+
}, []);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
document.addEventListener('keydown', handleKeydown);
|
|
63
|
+
return () => document.removeEventListener('keydown', handleKeydown);
|
|
64
|
+
}, [handleKeydown]);
|
|
65
|
+
// Disabling scrolling when relevant
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const preventOverflow = modals.some((modal) => modal.props.preventOverflow ||
|
|
68
|
+
(modal.modalType === 'drawer' && modal.isOpen));
|
|
69
|
+
if (preventOverflow)
|
|
70
|
+
document.body.classList.add(preventBodyScrollStyle);
|
|
71
|
+
else
|
|
72
|
+
document.body.classList.remove(preventBodyScrollStyle);
|
|
73
|
+
return () => document.body.classList.remove(preventBodyScrollStyle);
|
|
74
|
+
}, [modals]);
|
|
75
|
+
const initialState = {
|
|
76
|
+
showTarget,
|
|
77
|
+
hideTarget,
|
|
78
|
+
modals
|
|
79
|
+
};
|
|
80
|
+
return (React.createElement(ModalContext.Provider, { value: initialState }, children));
|
|
81
|
+
};
|
|
82
|
+
export default ModalProvider;
|
|
83
|
+
//# sourceMappingURL=ModalProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalProvider.js","sourceRoot":"","sources":["ModalProvider.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ModalProvider from './ModalProvider';
|
|
3
|
+
|
|
4
|
+
xdescribe('ModalProvider', () => {
|
|
5
|
+
it('renders', () => {
|
|
6
|
+
const wrapper = shallow(<ModalProvider />);
|
|
7
|
+
expect(wrapper).toBeDefined();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('renders its children', () => {
|
|
11
|
+
const Child = jest.fn().mockReturnValue(<div />);
|
|
12
|
+
const wrapper = shallow(
|
|
13
|
+
<ModalProvider>
|
|
14
|
+
<Child />
|
|
15
|
+
</ModalProvider>
|
|
16
|
+
);
|
|
17
|
+
expect(wrapper.find(Child).length).toBe(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("rendered Provider's `value` prop", () => {
|
|
21
|
+
it('mirrors the component state', () => {
|
|
22
|
+
const wrapper = shallow(<ModalProvider />);
|
|
23
|
+
expect(wrapper.prop('value')).toEqual(wrapper.instance().initialState);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ModalContext from './ModalContext';
|
|
3
|
+
import ReactModal from 'react-modal';
|
|
4
|
+
import { styled } from 'linaria/react';
|
|
5
|
+
const Cover = styled('div') `
|
|
6
|
+
position: fixed;
|
|
7
|
+
z-index: 3;
|
|
8
|
+
top: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
bottom: 0;
|
|
11
|
+
right: 0;
|
|
12
|
+
background: rgba(0, 0, 0, 0.2);
|
|
13
|
+
`;
|
|
14
|
+
Cover.displayName = 'Cover';
|
|
15
|
+
const Modal = ({ modalComponent, isOpen, modalType, hideTarget, props }) => {
|
|
16
|
+
/** Do not render anything if there is no active modal */
|
|
17
|
+
if (!isOpen)
|
|
18
|
+
return null;
|
|
19
|
+
const Component = modalComponent;
|
|
20
|
+
if (Component && isOpen && modalType === 'modal') {
|
|
21
|
+
/** A modal has been requested, from somewhere in the app */
|
|
22
|
+
return (React.createElement(ReactModal, Object.assign({ style: { overlay: { zIndex: 999 } }, className: props.modalStyles }, props.modalProps, {
|
|
23
|
+
/** isOpen should always be true here, since this is only rendered when a modal is requested */
|
|
24
|
+
isOpen: true,
|
|
25
|
+
/**
|
|
26
|
+
* react-modal requires an onRequestClose prop that takes a func to call when the modal is closed
|
|
27
|
+
* We use this to make sure the context is updated
|
|
28
|
+
*/
|
|
29
|
+
onRequestClose: hideTarget }),
|
|
30
|
+
React.createElement(Component, Object.assign({ hideTarget: hideTarget }, props))));
|
|
31
|
+
}
|
|
32
|
+
if (isOpen && props.showCover) {
|
|
33
|
+
const coverStyles = props === null || props === void 0 ? void 0 : props.coverStyles;
|
|
34
|
+
/** Inject a clickable 'cover' behind flyouts */
|
|
35
|
+
return React.createElement(Cover, { onClick: hideTarget, style: coverStyles });
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
const ModalRoot = () => {
|
|
40
|
+
const { modals } = React.useContext(ModalContext);
|
|
41
|
+
return (React.createElement(React.Fragment, null, modals.map((modalProps) => (React.createElement(Modal, Object.assign({ key: modalProps.modalId }, modalProps))))));
|
|
42
|
+
};
|
|
43
|
+
export default ModalRoot;
|
|
44
|
+
//# sourceMappingURL=ModalRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalRoot.js","sourceRoot":"","sources":["ModalRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,YAA4B,MAAM,gBAAgB,CAAC;AAC1D,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;;;;;;;;CAQ1B,CAAC;AAEF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAM,KAAK,GAAG,CAAC,EACb,cAAc,EACd,MAAM,EACN,SAAS,EACT,UAAU,EACV,KAAK,EACM,EAAE,EAAE;IACf,yDAAyD;IACzD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,MAAM,SAAS,GAAG,cAAmC,CAAC;IAEtD,IAAI,SAAS,IAAI,MAAM,IAAI,SAAS,KAAK,OAAO,EAAE;QAChD,6DAA6D;QAC7D,OAAO,CACL,oBAAC,UAAU,kBACT,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EACnC,SAAS,EAAE,KAAK,CAAC,WAAW,IACxB,KAAK,CAAC,UAAU;YACpB,+FAA+F;YAC/F,MAAM;YACN;;;eAGG;YACH,cAAc,EAAE,UAAU;YAE1B,oBAAC,SAAS,kBAAC,UAAU,EAAE,UAAU,IAAM,KAAK,EAAI,CACrC,CACd,CAAC;KACH;IAED,IAAI,MAAM,IAAI,KAAK,CAAC,SAAS,EAAE;QAC7B,MAAM,WAAW,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,CAAC;QAEvC,gDAAgD;QAChD,OAAO,oBAAC,KAAK,IAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAI,CAAC;KAC3D;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAClD,OAAO,CACL,0CACG,MAAM,CAAC,GAAG,CAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,CACtC,oBAAC,KAAK,kBAAC,GAAG,EAAE,UAAU,CAAC,OAAO,IAAM,UAAU,EAAI,CACnD,CAAC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getComponentWithModalContext, {
|
|
3
|
+
defaultContext
|
|
4
|
+
} from './__test_utils__/getComponentWithModalContext';
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.resetModules();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const modalRoot = getComponentWithModalContext('ModalRoot');
|
|
11
|
+
|
|
12
|
+
xdescribe('ModalRoot', () => {
|
|
13
|
+
let funcAsChild = jest.fn().mockReturnValue(<div />);
|
|
14
|
+
|
|
15
|
+
it('always renders a Consumer with no children', () => {
|
|
16
|
+
const ModalRoot = modalRoot();
|
|
17
|
+
const wrapper = mount(<ModalRoot>{funcAsChild}</ModalRoot>);
|
|
18
|
+
expect(wrapper.find('Consumer')).toHaveLength(1);
|
|
19
|
+
expect(wrapper.find('Consumer').children()).toHaveLength(0);
|
|
20
|
+
expect(wrapper.find('Modal')).toHaveLength(0);
|
|
21
|
+
expect(wrapper.find('Cover')).toHaveLength(0);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders a `Modal` when Component, isOpen and modalType is `modal`', () => {
|
|
25
|
+
const Comp = () => <div>Component being rendered inside Modal</div>;
|
|
26
|
+
const ModalRoot = modalRoot({
|
|
27
|
+
modals: [
|
|
28
|
+
{
|
|
29
|
+
modalComponent: Comp,
|
|
30
|
+
isOpen: true,
|
|
31
|
+
modalType: 'modal'
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
const wrapper = mount(<ModalRoot>{funcAsChild}</ModalRoot>);
|
|
36
|
+
expect(wrapper.find('Modal')).toHaveLength(1);
|
|
37
|
+
expect(wrapper.text()).toContain('Component being rendered');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('renders a `Cover` when isOpen is true, modalType is `flyout` and props.showCover is true', () => {
|
|
41
|
+
const hideTarget = jest.fn();
|
|
42
|
+
|
|
43
|
+
const ModalRoot = modalRoot({
|
|
44
|
+
modals: [
|
|
45
|
+
{
|
|
46
|
+
hideTarget: hideTarget,
|
|
47
|
+
isOpen: true,
|
|
48
|
+
modalType: 'flyout',
|
|
49
|
+
props: { showCover: true }
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
const wrapper = mount(<ModalRoot>{funcAsChild}</ModalRoot>);
|
|
54
|
+
const Cover = wrapper.find('Cover');
|
|
55
|
+
|
|
56
|
+
expect(Cover).toHaveLength(1);
|
|
57
|
+
expect(Cover.prop('onClick')).toBe(hideTarget);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders multiple `Modal` when Component, isOpen and modalType is `modal`', () => {
|
|
61
|
+
const Comp = () => <div>Component being rendered inside Modal</div>;
|
|
62
|
+
const ModalRoot = modalRoot({
|
|
63
|
+
modals: [
|
|
64
|
+
{
|
|
65
|
+
modalComponent: Comp,
|
|
66
|
+
isOpen: true,
|
|
67
|
+
modalType: 'modal'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
modalComponent: Comp,
|
|
71
|
+
isOpen: true,
|
|
72
|
+
modalType: 'modal'
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
const wrapper = mount(<ModalRoot>{funcAsChild}</ModalRoot>);
|
|
77
|
+
expect(wrapper.find('Modal')).toHaveLength(2);
|
|
78
|
+
expect(wrapper.text()).toContain('Component being rendered');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ModalState } from './ModalContext';
|
|
3
|
+
export declare const ModalTrigger: React.SFC<{
|
|
4
|
+
/** The React component that you would like to display inside the modal */
|
|
5
|
+
target: React.ReactNode;
|
|
6
|
+
/** Style to apply to the modal itself */
|
|
7
|
+
modalStyles?: {};
|
|
8
|
+
children: (args: Partial<ModalState>) => React.ReactNode;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ModalContext from './ModalContext';
|
|
3
|
+
export const ModalTrigger = ({ target, children, modalStyles }) => {
|
|
4
|
+
return (React.createElement(ModalContext.Consumer, null, ({ showTarget, hideTarget }) => {
|
|
5
|
+
const show = () => showTarget(target, 'modal', null, { hideTarget, modalStyles });
|
|
6
|
+
return children({ showTarget: show });
|
|
7
|
+
}));
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=ModalTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalTrigger.js","sourceRoot":"","sources":["ModalTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,YAA4B,MAAM,gBAAgB,CAAC;AAE1D,MAAM,CAAC,MAAM,YAAY,GAMpB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE;IACzC,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,GAAG,EAAE,CAChB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QACjE,OAAO,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC,CACqB,CACzB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const defaultContext = {
|
|
2
|
+
modals: [],
|
|
3
|
+
showTarget: jest.fn(),
|
|
4
|
+
hideTarget: jest.fn()
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} targetPath Path to the component that uses the Consumer, relative to `/Modal`
|
|
9
|
+
* @param {string} moduleToExport The named module to export. Assumes default if not provided.
|
|
10
|
+
*/
|
|
11
|
+
const getComponentWithModalContext = (targetPath, moduleToExport = null) => {
|
|
12
|
+
return (context = defaultContext) => {
|
|
13
|
+
// Mock out ModalContext Consumer (used by all modals)
|
|
14
|
+
jest.doMock('../ModalContext', () => {
|
|
15
|
+
return {
|
|
16
|
+
Consumer: (props) => props.children(context)
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// return the updated target module that now includes the mocked context
|
|
21
|
+
if (moduleToExport) {
|
|
22
|
+
return require(`../${targetPath}`)[moduleToExport];
|
|
23
|
+
} else {
|
|
24
|
+
return require(`../${targetPath}`).default;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default getComponentWithModalContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PaginationBehaviourRenderProps } from '@jetshop/flyght-ui/Pagination/PaginationBehaviour';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare const PaginationWrapper: import("linaria/lib/StyledMeta").StyledMeta & React.FunctionComponent<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
as?: React.ElementType<any>;
|
|
5
|
+
}>;
|
|
6
|
+
declare const Pagination: React.SFC<PaginationBehaviourRenderProps>;
|
|
7
|
+
export default Pagination;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import formatMessage from '@jetshop/flyght-intl';
|
|
2
|
+
import { styled } from 'linaria/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import usePagination from './usePagination';
|
|
5
|
+
export const PaginationWrapper = styled('div') `
|
|
6
|
+
display: flex;
|
|
7
|
+
width: 100%;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
align-items: center;
|
|
10
|
+
`;
|
|
11
|
+
const Pagination = (props) => {
|
|
12
|
+
const { hasPages, totalPages, className, currentPage } = props;
|
|
13
|
+
const { prevHref, nextHref, prevOnClick, nextOnClick, isPrevDisabled, isNextDisabled } = usePagination(props);
|
|
14
|
+
return hasPages && !isNaN(totalPages) ? (React.createElement(PaginationWrapper, { className: className },
|
|
15
|
+
React.createElement("a", { href: prevHref, onClick: prevOnClick, "data-disabled": isPrevDisabled }, formatMessage('Prev')),
|
|
16
|
+
React.createElement("div", null, formatMessage(`Page {currentPage} of {totalPages}`, {
|
|
17
|
+
currentPage,
|
|
18
|
+
totalPages
|
|
19
|
+
})),
|
|
20
|
+
React.createElement("a", { href: nextHref, onClick: nextOnClick, "data-disabled": isNextDisabled }, formatMessage('Next')))) : null;
|
|
21
|
+
};
|
|
22
|
+
export default Pagination;
|
|
23
|
+
//# sourceMappingURL=Pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["Pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;;;;;CAK7C,CAAC;AAEF,MAAM,UAAU,GAA8C,CAAC,KAAK,EAAE,EAAE;IACtE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAE/D,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,EACX,cAAc,EACd,cAAc,EACf,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAEzB,OAAO,QAAQ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACtC,oBAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS;QACrC,2BAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,mBAAiB,cAAc,IACnE,aAAa,CAAC,MAAM,CAAC,CACpB;QACJ,iCACG,aAAa,CAAC,oCAAoC,EAAE;YACnD,WAAW;YACX,UAAU;SACX,CAAC,CACE;QACN,2BAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,mBAAiB,cAAc,IACnE,aAAa,CAAC,MAAM,CAAC,CACpB,CACc,CACrB,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|