@4alldigital/foundation-ui--core 3.0.0
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/LICENSE.txt +21 -0
- package/package.json +35 -0
- package/src/__mocks__/_examples/cnbc.ts +146 -0
- package/src/__mocks__/_examples/nrg.ts +222 -0
- package/src/__mocks__/empty-module.js +0 -0
- package/src/__mocks__/fileMock.js +3 -0
- package/src/__mocks__/fileTransformer.js +8 -0
- package/src/__mocks__/mockSearchData.js +511 -0
- package/src/__mocks__/nrglogo.svg +74 -0
- package/src/__mocks__/styleMock.js +3 -0
- package/src/__mocks__/tempPolyFills.js +5 -0
- package/src/components/Accordion/Accordion.stories.tsx +33 -0
- package/src/components/Accordion/Accordion.tsx +53 -0
- package/src/components/Accordion/Accordion.types.ts +8 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/AnimationCounter/AnimationCounter.stories.tsx +22 -0
- package/src/components/AnimationCounter/AnimationCounter.tsx +51 -0
- package/src/components/AnimationCounter/AnimationCounter.types.ts +10 -0
- package/src/components/AnimationCounter/index.ts +1 -0
- package/src/components/AnimationSet1/AnimationSet1.stories.tsx +36 -0
- package/src/components/AnimationSet1/AnimationSet1.tsx +107 -0
- package/src/components/AnimationSet1/AnimationSet1.types.ts +12 -0
- package/src/components/AnimationSet1/index.ts +1 -0
- package/src/components/Authenticator/Authenticator.stories.tsx +37 -0
- package/src/components/Authenticator/Authenticator.tsx +84 -0
- package/src/components/Authenticator/Authenticator.types.ts +7 -0
- package/src/components/Authenticator/index.ts +1 -0
- package/src/components/Avatar/Avatar.stories.tsx +26 -0
- package/src/components/Avatar/Avatar.tsx +88 -0
- package/src/components/Avatar/Avatar.types.ts +8 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Banner/Banner.stories.tsx +59 -0
- package/src/components/Banner/Banner.tsx +60 -0
- package/src/components/Banner/Banner.types.ts +9 -0
- package/src/components/Banner/index.ts +1 -0
- package/src/components/Blockquote/Blockquote.stories.tsx +20 -0
- package/src/components/Blockquote/Blockquote.tsx +32 -0
- package/src/components/Blockquote/Blockquote.types.ts +8 -0
- package/src/components/Blockquote/index.ts +1 -0
- package/src/components/Button/Button.stories.tsx +50 -0
- package/src/components/Button/Button.tsx +117 -0
- package/src/components/Button/Button.types.ts +43 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +59 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +35 -0
- package/src/components/ButtonGroup/ButtonGroup.types.ts +5 -0
- package/src/components/ButtonGroup/index.ts +1 -0
- package/src/components/Calendar/Calendar.stories.tsx +100 -0
- package/src/components/Calendar/Calendar.tsx +91 -0
- package/src/components/Calendar/Calendar.types.ts +10 -0
- package/src/components/Calendar/index.ts +2 -0
- package/src/components/Card/Card.stories.tsx +487 -0
- package/src/components/Card/Card.tsx +32 -0
- package/src/components/Card/Card.types.ts +79 -0
- package/src/components/Card/constants/index.ts +8 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Card/types/CardBasic/CardBasic.tsx +262 -0
- package/src/components/Card/types/CardBasic/CardBasic.types.ts +7 -0
- package/src/components/Card/types/CardBasic/index.ts +1 -0
- package/src/components/Card/types/CardData/CardData.tsx +68 -0
- package/src/components/Card/types/CardData/CardData.types.ts +21 -0
- package/src/components/Card/types/CardData/index.ts +1 -0
- package/src/components/Card/types/CardHorz/CardHorz.tsx +80 -0
- package/src/components/Card/types/CardHorz/CardHorz.types.ts +8 -0
- package/src/components/Card/types/CardHorz/index.ts +1 -0
- package/src/components/Card/types/CardIcon/CardIcon.tsx +76 -0
- package/src/components/Card/types/CardIcon/CardIcon.types.ts +8 -0
- package/src/components/Card/types/CardIcon/index.ts +1 -0
- package/src/components/Card/types/CardMedia/CardMedia.tsx +277 -0
- package/src/components/Card/types/CardMedia/CardMedia.types.ts +5 -0
- package/src/components/Card/types/CardMedia/index.ts +1 -0
- package/src/components/Card/types/CardVideo/CardVideo.tsx +262 -0
- package/src/components/Card/types/CardVideo/CardVideo.types.ts +11 -0
- package/src/components/Card/types/CardVideo/index.ts +1 -0
- package/src/components/CardGrid/CardGrid.stories.tsx +122 -0
- package/src/components/CardGrid/CardGrid.tsx +25 -0
- package/src/components/CardGrid/CardGrid.types.ts +7 -0
- package/src/components/CardGrid/index.ts +1 -0
- package/src/components/Carousel/Carousel.stories.tsx +351 -0
- package/src/components/Carousel/Carousel.tsx +174 -0
- package/src/components/Carousel/Carousel.types.ts +32 -0
- package/src/components/Carousel/MIGRATION.md +156 -0
- package/src/components/Carousel/index.ts +1 -0
- package/src/components/Cart/Cart.stories.tsx +92 -0
- package/src/components/Cart/Cart.tsx +194 -0
- package/src/components/Cart/Cart.types.ts +4 -0
- package/src/components/Cart/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +18 -0
- package/src/components/Checkbox/Checkbox.tsx +38 -0
- package/src/components/Checkbox/Checkbox.types.ts +15 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Chip/Chip.stories.tsx +37 -0
- package/src/components/Chip/Chip.tsx +104 -0
- package/src/components/Chip/Chip.types.ts +13 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Collapsible/Collapsible.stories.tsx +139 -0
- package/src/components/Collapsible/Collapsible.tsx +75 -0
- package/src/components/Collapsible/Collapsible.types.ts +14 -0
- package/src/components/Collapsible/index.ts +3 -0
- package/src/components/Container/Container.stories.tsx +17 -0
- package/src/components/Container/Container.tsx +51 -0
- package/src/components/Container/Container.types.ts +17 -0
- package/src/components/Container/index.ts +1 -0
- package/src/components/ContentPageLayout/ContentPageLayout.stories.tsx +17 -0
- package/src/components/ContentPageLayout/ContentPageLayout.tsx +38 -0
- package/src/components/ContentPageLayout/ContentPageLayout.types.ts +17 -0
- package/src/components/ContentPageLayout/index.ts +1 -0
- package/src/components/ContentRowsLayout/ContentRowsLayout.stories.tsx +19 -0
- package/src/components/ContentRowsLayout/ContentRowsLayout.tsx +30 -0
- package/src/components/ContentRowsLayout/ContentRowsLayout.types.ts +15 -0
- package/src/components/ContentRowsLayout/index.ts +1 -0
- package/src/components/Copy/Copy.stories.tsx +28 -0
- package/src/components/Copy/Copy.tsx +43 -0
- package/src/components/Copy/Copy.types.tsx +53 -0
- package/src/components/Copy/index.tsx +1 -0
- package/src/components/DisplayHeading/DisplayHeading.stories.tsx +17 -0
- package/src/components/DisplayHeading/DisplayHeading.tsx +43 -0
- package/src/components/DisplayHeading/DisplayHeading.types.ts +8 -0
- package/src/components/DisplayHeading/index.ts +1 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +18 -0
- package/src/components/FileUpload/FileUpload.tsx +41 -0
- package/src/components/FileUpload/FileUpload.types.ts +9 -0
- package/src/components/FileUpload/index.ts +1 -0
- package/src/components/Footer/Footer.stories.tsx +17 -0
- package/src/components/Footer/Footer.tsx +78 -0
- package/src/components/Footer/Footer.types.ts +4 -0
- package/src/components/Footer/index.ts +1 -0
- package/src/components/Form/Form.stories.tsx +81 -0
- package/src/components/Form/Form.tsx +98 -0
- package/src/components/Form/Form.types.ts +34 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/FormField/FormField.stories.tsx +205 -0
- package/src/components/FormField/FormField.tsx +258 -0
- package/src/components/FormField/FormField.types.ts +89 -0
- package/src/components/FormField/index.ts +1 -0
- package/src/components/FormSelect/FormSelect.stories.tsx +27 -0
- package/src/components/FormSelect/FormSelect.tsx +46 -0
- package/src/components/FormSelect/FormSelect.types.ts +45 -0
- package/src/components/FormSelect/index.ts +1 -0
- package/src/components/FullContentBackgroundImage/FullContentBackgroundImage.stories.tsx +18 -0
- package/src/components/FullContentBackgroundImage/FullContentBackgroundImage.tsx +26 -0
- package/src/components/FullContentBackgroundImage/FullContentBackgroundImage.types.ts +6 -0
- package/src/components/FullContentBackgroundImage/index.ts +1 -0
- package/src/components/FullScreenVideoModal/FullScreenVideoModal.stories.tsx +34 -0
- package/src/components/FullScreenVideoModal/FullScreenVideoModal.tsx +41 -0
- package/src/components/FullScreenVideoModal/FullScreenVideoModal.types.ts +9 -0
- package/src/components/FullScreenVideoModal/index.ts +1 -0
- package/src/components/Header/Header.stories.tsx +51 -0
- package/src/components/Header/Header.tsx +170 -0
- package/src/components/Header/Header.types.ts +11 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/Heading/Heading.stories.tsx +57 -0
- package/src/components/Heading/Heading.tsx +47 -0
- package/src/components/Heading/Heading.types.ts +35 -0
- package/src/components/Heading/index.ts +1 -0
- package/src/components/Hero/Hero.stories.tsx +17 -0
- package/src/components/Hero/Hero.tsx +28 -0
- package/src/components/Hero/Hero.types.ts +17 -0
- package/src/components/Hero/index.ts +1 -0
- package/src/components/Hr/Hr.stories.tsx +13 -0
- package/src/components/Hr/Hr.tsx +16 -0
- package/src/components/Hr/Hr.types.ts +3 -0
- package/src/components/Hr/index.ts +1 -0
- package/src/components/HtmlContent/HtmlContent.stories.tsx +29 -0
- package/src/components/HtmlContent/HtmlContent.tsx +36 -0
- package/src/components/HtmlContent/HtmlContent.types.ts +6 -0
- package/src/components/HtmlContent/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +26 -0
- package/src/components/Icon/Icon.tsx +24 -0
- package/src/components/Icon/Icon.types.ts +8 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Image/Image.stories.tsx +32 -0
- package/src/components/Image/Image.tsx +71 -0
- package/src/components/Image/Image.types.ts +20 -0
- package/src/components/Image/index.ts +1 -0
- package/src/components/Label/Label.stories.tsx +18 -0
- package/src/components/Label/Label.tsx +17 -0
- package/src/components/Label/Label.types.ts +9 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Link/Link.stories.tsx +25 -0
- package/src/components/Link/Link.tsx +85 -0
- package/src/components/Link/Link.types.ts +14 -0
- package/src/components/Link/index.ts +1 -0
- package/src/components/List/List.stories.tsx +38 -0
- package/src/components/List/List.tsx +17 -0
- package/src/components/List/List.types.ts +27 -0
- package/src/components/List/index.ts +1 -0
- package/src/components/ListItem/ListItem.stories.tsx +61 -0
- package/src/components/ListItem/ListItem.tsx +53 -0
- package/src/components/ListItem/ListItem.types.ts +10 -0
- package/src/components/ListItem/index.ts +1 -0
- package/src/components/Loader/Loader.stories.tsx +17 -0
- package/src/components/Loader/Loader.tsx +34 -0
- package/src/components/Loader/Loader.types.ts +5 -0
- package/src/components/Loader/index.ts +1 -0
- package/src/components/Logo/Logo.stories.tsx +17 -0
- package/src/components/Logo/Logo.tsx +17 -0
- package/src/components/Logo/Logo.types.ts +6 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menu/Menu.stories.tsx +37 -0
- package/src/components/Menu/Menu.tsx +45 -0
- package/src/components/Menu/Menu.types.ts +15 -0
- package/src/components/Menu/index.ts +1 -0
- package/src/components/Notice/Notice.stories.tsx +49 -0
- package/src/components/Notice/Notice.tsx +63 -0
- package/src/components/Notice/Notice.types.ts +11 -0
- package/src/components/Notice/index.ts +1 -0
- package/src/components/OTPInput/OTPInput.stories.tsx +18 -0
- package/src/components/OTPInput/OTPInput.tsx +80 -0
- package/src/components/OTPInput/OTPInput.types.ts +8 -0
- package/src/components/OTPInput/index.ts +1 -0
- package/src/components/PanelCards/PanelCards.stories.tsx +125 -0
- package/src/components/PanelCards/PanelCards.tsx +81 -0
- package/src/components/PanelCards/PanelCards.types.ts +11 -0
- package/src/components/PanelCards/index.ts +1 -0
- package/src/components/PanelCustom/PanelCustom.stories.tsx +18 -0
- package/src/components/PanelCustom/PanelCustom.tsx +39 -0
- package/src/components/PanelCustom/PanelCustom.types.ts +20 -0
- package/src/components/PanelCustom/index.ts +1 -0
- package/src/components/PanelFeature/PanelFeature.stories.tsx +46 -0
- package/src/components/PanelFeature/PanelFeature.tsx +83 -0
- package/src/components/PanelFeature/PanelFeature.types.ts +27 -0
- package/src/components/PanelFeature/index.ts +1 -0
- package/src/components/PanelHero/PanelHero.stories.tsx +126 -0
- package/src/components/PanelHero/PanelHero.tsx +184 -0
- package/src/components/PanelHero/PanelHero.types.ts +19 -0
- package/src/components/PanelHero/index.ts +1 -0
- package/src/components/PanelIntro/PanelIntro.stories.tsx +38 -0
- package/src/components/PanelIntro/PanelIntro.tsx +139 -0
- package/src/components/PanelIntro/PanelIntro.types.ts +19 -0
- package/src/components/PanelIntro/index.ts +1 -0
- package/src/components/PanelProduct/PanelProduct.stories.tsx +24 -0
- package/src/components/PanelProduct/PanelProduct.tsx +87 -0
- package/src/components/PanelProduct/PanelProduct.types.ts +14 -0
- package/src/components/PanelProduct/index.ts +1 -0
- package/src/components/PanelScroller/PanelScroller.stories.tsx +81 -0
- package/src/components/PanelScroller/PanelScroller.tsx +58 -0
- package/src/components/PanelScroller/PanelScroller.types.ts +8 -0
- package/src/components/PanelScroller/index.ts +1 -0
- package/src/components/PanelVideo/PanelVideo.stories.tsx +42 -0
- package/src/components/PanelVideo/PanelVideo.tsx +81 -0
- package/src/components/PanelVideo/PanelVideo.types.ts +11 -0
- package/src/components/PanelVideo/index.ts +1 -0
- package/src/components/Radio/Radio.stories.tsx +24 -0
- package/src/components/Radio/Radio.tsx +44 -0
- package/src/components/Radio/Radio.types.ts +13 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/Schedule/Schedule.stories.tsx +96 -0
- package/src/components/Schedule/Schedule.tsx +118 -0
- package/src/components/Schedule/Schedule.types.ts +64 -0
- package/src/components/Schedule/index.ts +1 -0
- package/src/components/ScheduleItem/ScheduleItem.stories.tsx +21 -0
- package/src/components/ScheduleItem/ScheduleItem.tsx +77 -0
- package/src/components/ScheduleItem/ScheduleItem.types.ts +8 -0
- package/src/components/ScheduleItem/index.ts +1 -0
- package/src/components/Screen/Screen.stories.tsx +27 -0
- package/src/components/Screen/Screen.tsx +63 -0
- package/src/components/Screen/Screen.types.ts +16 -0
- package/src/components/Screen/index.ts +1 -0
- package/src/components/ShadcnButton/ShadcnButton.tsx +57 -0
- package/src/components/ShadcnButton/index.ts +2 -0
- package/src/components/ShadcnCarousel/ShadcnCarousel.tsx +261 -0
- package/src/components/ShadcnCarousel/index.ts +9 -0
- package/src/components/Share/Share.stories.tsx +17 -0
- package/src/components/Share/Share.tsx +60 -0
- package/src/components/Share/Share.types.ts +12 -0
- package/src/components/Share/index.ts +1 -0
- package/src/components/SubscriptionManager/SubscriptionManager.stories.tsx +177 -0
- package/src/components/SubscriptionManager/SubscriptionManager.tsx +369 -0
- package/src/components/SubscriptionManager/SubscriptionManager.types.ts +36 -0
- package/src/components/SubscriptionManager/index.ts +1 -0
- package/src/components/Switch/Switch.stories.tsx +20 -0
- package/src/components/Switch/Switch.tsx +30 -0
- package/src/components/Switch/Switch.types.ts +7 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Tabs/Tabs.stories.tsx +34 -0
- package/src/components/Tabs/Tabs.tsx +42 -0
- package/src/components/Tabs/Tabs.types.ts +8 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/TextInput/TextInput.stories.tsx +18 -0
- package/src/components/TextInput/TextInput.tsx +78 -0
- package/src/components/TextInput/TextInput.types.ts +81 -0
- package/src/components/TextInput/index.ts +1 -0
- package/src/components/Video/Video.stories.tsx +75 -0
- package/src/components/Video/Video.tsx +280 -0
- package/src/components/Video/Video.types.ts +147 -0
- package/src/components/Video/index.ts +1 -0
- package/src/components/VisitUs/VisitUs.stories.tsx +32 -0
- package/src/components/VisitUs/VisitUs.tsx +56 -0
- package/src/components/VisitUs/VisitUs.types.ts +13 -0
- package/src/components/VisitUs/index.ts +1 -0
- package/src/components/index.ts +143 -0
- package/src/constants/index.ts +6 -0
- package/src/context/Amplify/index.tsx +65 -0
- package/src/context/App/index.tsx +93 -0
- package/src/context/Cart/index.tsx +64 -0
- package/src/context/ExampleContext/index.tsx +34 -0
- package/src/context/Theme/index.tsx +37 -0
- package/src/context/index.ts +18 -0
- package/src/features/Search/Search.stories.tsx +395 -0
- package/src/features/Search/Search.tsx +204 -0
- package/src/features/Search/Search.types.ts +41 -0
- package/src/features/Search/config/config-helper.ts +219 -0
- package/src/features/Search/index.ts +1 -0
- package/src/features/Search/view-helpers/appendClassName.ts +14 -0
- package/src/features/Search/view-helpers/formatResult.ts +97 -0
- package/src/features/Search/view-helpers/getFilterValueDisplay.ts +10 -0
- package/src/features/Search/view-helpers/getUrlSanitizer.ts +23 -0
- package/src/features/Search/view-helpers/index.ts +4 -0
- package/src/features/Search/views/Layout/Layout.tsx +50 -0
- package/src/features/Search/views/Layout/Layout.types.ts +13 -0
- package/src/features/Search/views/Layout/index.ts +1 -0
- package/src/features/Search/views/MultiCheckboxFacet/MultiCheckboxFacet.tsx +85 -0
- package/src/features/Search/views/MultiCheckboxFacet/MultiCheckboxFacet.types.ts +5 -0
- package/src/features/Search/views/MultiCheckboxFacet/index.ts +1 -0
- package/src/features/Search/views/Paging/Paging.tsx +35 -0
- package/src/features/Search/views/Paging/Paging.types.ts +24 -0
- package/src/features/Search/views/Paging/index.ts +1 -0
- package/src/features/Search/views/PagingInfo/PagingInfo.tsx +34 -0
- package/src/features/Search/views/PagingInfo/PagingInfo.types.ts +26 -0
- package/src/features/Search/views/PagingInfo/index.ts +1 -0
- package/src/features/Search/views/Result/Result.tsx +84 -0
- package/src/features/Search/views/Result/Result.types.ts +47 -0
- package/src/features/Search/views/Result/index.ts +1 -0
- package/src/features/Search/views/Results/Results.tsx +16 -0
- package/src/features/Search/views/Results/Results.types.ts +24 -0
- package/src/features/Search/views/Results/index.ts +1 -0
- package/src/features/Search/views/ResultsPerPage/ResultsPerPage.tsx +32 -0
- package/src/features/Search/views/ResultsPerPage/ResultsPerPage.types.ts +26 -0
- package/src/features/Search/views/ResultsPerPage/index.ts +1 -0
- package/src/features/Search/views/SearchBox/SearchBox.tsx +51 -0
- package/src/features/Search/views/SearchBox/SearchBox.types.ts +10 -0
- package/src/features/Search/views/SearchBox/index.ts +1 -0
- package/src/features/Search/views/Sidebar/Sidebar.tsx +14 -0
- package/src/features/Search/views/Sidebar/Sidebar.types.ts +3 -0
- package/src/features/Search/views/Sidebar/index.ts +1 -0
- package/src/features/Search/views/SingleLinksFacet/SingleLinksFacet.tsx +62 -0
- package/src/features/Search/views/SingleLinksFacet/SingleLinksFacet.types.ts +5 -0
- package/src/features/Search/views/SingleLinksFacet/index.ts +1 -0
- package/src/features/Search/views/SingleSelectFacet/SingleSelectFacet.tsx +34 -0
- package/src/features/Search/views/SingleSelectFacet/SingleSelectFacet.types.ts +5 -0
- package/src/features/Search/views/SingleSelectFacet/index.ts +1 -0
- package/src/features/Search/views/Sorting/Sorting.tsx +24 -0
- package/src/features/Search/views/Sorting/Sorting.types.ts +25 -0
- package/src/features/Search/views/Sorting/index.ts +1 -0
- package/src/features/index.ts +11 -0
- package/src/forms/ForgotPasswordForm/ForgotPasswordForm.stories.tsx +19 -0
- package/src/forms/ForgotPasswordForm/ForgotPasswordForm.tsx +28 -0
- package/src/forms/ForgotPasswordForm/ForgotPasswordForm.types.ts +3 -0
- package/src/forms/ForgotPasswordForm/index.ts +1 -0
- package/src/forms/LoginForm/LoginForm.stories.tsx +67 -0
- package/src/forms/LoginForm/LoginForm.tsx +112 -0
- package/src/forms/LoginForm/LoginForm.types.ts +7 -0
- package/src/forms/LoginForm/index.ts +1 -0
- package/src/forms/ProfileForm/ProfileForm.stories.tsx +23 -0
- package/src/forms/ProfileForm/ProfileForm.tsx +40 -0
- package/src/forms/ProfileForm/ProfileForm.types.ts +6 -0
- package/src/forms/ProfileForm/index.ts +1 -0
- package/src/forms/PromoCodeForm/PromoCodeForm.stories.tsx +19 -0
- package/src/forms/PromoCodeForm/PromoCodeForm.tsx +22 -0
- package/src/forms/PromoCodeForm/PromoCodeForm.types.ts +4 -0
- package/src/forms/PromoCodeForm/index.ts +1 -0
- package/src/forms/RegisterForm/RegisterForm.stories.tsx +85 -0
- package/src/forms/RegisterForm/RegisterForm.tsx +108 -0
- package/src/forms/RegisterForm/RegisterForm.types.ts +6 -0
- package/src/forms/RegisterForm/index.ts +1 -0
- package/src/forms/ResetPasswordAuthForm/ResetPasswordAuthForm.stories.tsx +23 -0
- package/src/forms/ResetPasswordAuthForm/ResetPasswordAuthForm.tsx +39 -0
- package/src/forms/ResetPasswordAuthForm/ResetPasswordAuthForm.types.ts +3 -0
- package/src/forms/ResetPasswordAuthForm/index.ts +1 -0
- package/src/forms/ResetPasswordForm/ResetPasswordForm.stories.tsx +23 -0
- package/src/forms/ResetPasswordForm/ResetPasswordForm.tsx +30 -0
- package/src/forms/ResetPasswordForm/ResetPasswordForm.types.ts +3 -0
- package/src/forms/ResetPasswordForm/index.ts +1 -0
- package/src/forms/SubscriptionForm/SubscriptionForm.stories.tsx +31 -0
- package/src/forms/SubscriptionForm/SubscriptionForm.tsx +46 -0
- package/src/forms/SubscriptionForm/SubscriptionForm.types.ts +6 -0
- package/src/forms/SubscriptionForm/index.ts +1 -0
- package/src/forms/constants/index.ts +13 -0
- package/src/forms/index.ts +17 -0
- package/src/forms/validations/index.ts +39 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useLanguage.ts +18 -0
- package/src/hooks/useTheme.ts +6 -0
- package/src/index.ts +8 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/setupTests.ts +5 -0
- package/src/templates/AccountScreen/AccountScreen.stories.tsx +67 -0
- package/src/templates/AccountScreen/AccountScreen.tsx +78 -0
- package/src/templates/AccountScreen/AccountScreen.types.ts +31 -0
- package/src/templates/AccountScreen/index.ts +1 -0
- package/src/templates/AuthScreen/AuthScreen.stories.tsx +33 -0
- package/src/templates/AuthScreen/AuthScreen.tsx +21 -0
- package/src/templates/AuthScreen/AuthScreen.types.ts +8 -0
- package/src/templates/AuthScreen/index.ts +1 -0
- package/src/templates/CardGridScreen/CardGridScreen.stories.tsx +95 -0
- package/src/templates/CardGridScreen/CardGridScreen.tsx +43 -0
- package/src/templates/CardGridScreen/CardGridScreen.types.ts +11 -0
- package/src/templates/CardGridScreen/index.ts +1 -0
- package/src/templates/CatalogueScreen/CatalogueScreen.stories.tsx +31 -0
- package/src/templates/CatalogueScreen/CatalogueScreen.tsx +21 -0
- package/src/templates/CatalogueScreen/CatalogueScreen.types.ts +8 -0
- package/src/templates/CatalogueScreen/index.ts +1 -0
- package/src/templates/ChallengeLibraryScreen/ChallengeLibraryScreen.stories.tsx +171 -0
- package/src/templates/ChallengeLibraryScreen/ChallengeLibraryScreen.tsx +36 -0
- package/src/templates/ChallengeLibraryScreen/ChallengeLibraryScreen.types.ts +9 -0
- package/src/templates/ChallengeLibraryScreen/index.ts +1 -0
- package/src/templates/ChallengeScreen/ChallengeScreen.stories.tsx +65 -0
- package/src/templates/ChallengeScreen/ChallengeScreen.tsx +88 -0
- package/src/templates/ChallengeScreen/ChallengeScreen.types.ts +22 -0
- package/src/templates/ChallengeScreen/index.ts +1 -0
- package/src/templates/ContentScreen/ContentScreen.stories.tsx +71 -0
- package/src/templates/ContentScreen/ContentScreen.tsx +55 -0
- package/src/templates/ContentScreen/ContentScreen.types.ts +9 -0
- package/src/templates/ContentScreen/index.ts +1 -0
- package/src/templates/DashboardScreen/DashboardScreen.stories.tsx +490 -0
- package/src/templates/DashboardScreen/DashboardScreen.tsx +156 -0
- package/src/templates/DashboardScreen/DashboardScreen.types.ts +28 -0
- package/src/templates/DashboardScreen/index.ts +1 -0
- package/src/templates/FAQScreen/FAQScreen.stories.tsx +278 -0
- package/src/templates/FAQScreen/FAQScreen.tsx +32 -0
- package/src/templates/FAQScreen/FAQScreen.types.ts +14 -0
- package/src/templates/FAQScreen/index.ts +1 -0
- package/src/templates/HomeScreen/HomeScreen.stories.tsx +315 -0
- package/src/templates/HomeScreen/HomeScreen.tsx +50 -0
- package/src/templates/HomeScreen/HomeScreen.types.ts +23 -0
- package/src/templates/HomeScreen/index.ts +1 -0
- package/src/templates/LogoutScreen/LogoutScreen.stories.tsx +20 -0
- package/src/templates/LogoutScreen/LogoutScreen.tsx +25 -0
- package/src/templates/LogoutScreen/LogoutScreen.types.ts +4 -0
- package/src/templates/LogoutScreen/index.ts +1 -0
- package/src/templates/MenuScreen/MenuScreen.stories.tsx +36 -0
- package/src/templates/MenuScreen/MenuScreen.tsx +32 -0
- package/src/templates/MenuScreen/MenuScreen.types.ts +11 -0
- package/src/templates/MenuScreen/index.ts +1 -0
- package/src/templates/NotFoundScreen/NotFoundScreen.stories.tsx +20 -0
- package/src/templates/NotFoundScreen/NotFoundScreen.tsx +31 -0
- package/src/templates/NotFoundScreen/NotFoundScreen.types.ts +5 -0
- package/src/templates/NotFoundScreen/index.ts +1 -0
- package/src/templates/PasswordResetAuthScreen/PasswordResetAuthScreen.stories.tsx +27 -0
- package/src/templates/PasswordResetAuthScreen/PasswordResetAuthScreen.tsx +20 -0
- package/src/templates/PasswordResetAuthScreen/PasswordResetAuthScreen.types.ts +6 -0
- package/src/templates/PasswordResetAuthScreen/index.ts +1 -0
- package/src/templates/PasswordResetScreen/PasswordResetScreen.stories.tsx +22 -0
- package/src/templates/PasswordResetScreen/PasswordResetScreen.tsx +19 -0
- package/src/templates/PasswordResetScreen/PasswordResetScreen.types.ts +6 -0
- package/src/templates/PasswordResetScreen/index.ts +1 -0
- package/src/templates/ProfileScreen/ProfileScreen.stories.tsx +41 -0
- package/src/templates/ProfileScreen/ProfileScreen.tsx +30 -0
- package/src/templates/ProfileScreen/ProfileScreen.types.ts +24 -0
- package/src/templates/ProfileScreen/index.ts +1 -0
- package/src/templates/ScheduleScreen/ScheduleScreen.stories.tsx +174 -0
- package/src/templates/ScheduleScreen/ScheduleScreen.tsx +29 -0
- package/src/templates/ScheduleScreen/ScheduleScreen.types.ts +9 -0
- package/src/templates/ScheduleScreen/index.ts +1 -0
- package/src/templates/SubscriptionScreen/SubscriptionScreen.stories.tsx +98 -0
- package/src/templates/SubscriptionScreen/SubscriptionScreen.tsx +49 -0
- package/src/templates/SubscriptionScreen/SubscriptionScreen.types.ts +28 -0
- package/src/templates/SubscriptionScreen/index.ts +1 -0
- package/src/templates/WorkoutScreen/WorkoutScreen.stories.tsx +173 -0
- package/src/templates/WorkoutScreen/WorkoutScreen.tsx +230 -0
- package/src/templates/WorkoutScreen/WorkoutScreen.types.ts +34 -0
- package/src/templates/WorkoutScreen/index.ts +1 -0
- package/src/templates/index.ts +40 -0
- package/src/translations/en.ts +777 -0
- package/src/translations/fr.ts +182 -0
- package/src/translations/index.ts +2 -0
- package/src/utils/htmlParser/index.tsx +22 -0
- package/src/utils/index.ts +38 -0
- package/src/utils/parseDuration/index.ts +94 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// import config from "../config/engine.json";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file abstracts most logic around the configuration of the Reference UI.
|
|
5
|
+
*
|
|
6
|
+
* Configuration is an important part of the "reusability" and "generic-ness" of
|
|
7
|
+
* the Reference UI, but if you are using this app as a starting point for own
|
|
8
|
+
* project, everything related to configuration can largely be thrown away. To
|
|
9
|
+
* that end, this file attempts to contain most of that logic to one place.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export function getConfig(): any {
|
|
13
|
+
if (process.env.NODE_ENV === 'test') {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// if (config.engineName) return config;
|
|
18
|
+
|
|
19
|
+
// if (
|
|
20
|
+
// typeof window !== "undefined" &&
|
|
21
|
+
// window.appConfig &&
|
|
22
|
+
// window.appConfig.engineName
|
|
23
|
+
// ) {
|
|
24
|
+
// return window.appConfig;
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function toLowerCase(string) {
|
|
31
|
+
if (string) return string.toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function capitalizeFirstLetter(string) {
|
|
35
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getTitleField() {
|
|
39
|
+
// If no title field configuration has been provided, we attempt
|
|
40
|
+
// to use a "title" field, if one exists
|
|
41
|
+
return getConfig().titleField || 'title';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getUrlField() {
|
|
45
|
+
return getConfig().urlField;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getThumbnailField() {
|
|
49
|
+
return getConfig().thumbnailField;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getFacetFields() {
|
|
53
|
+
return getConfig().facets || [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getSortFields() {
|
|
57
|
+
return getConfig().sortFields || [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getResultTitle(result) {
|
|
61
|
+
const titleField = getTitleField();
|
|
62
|
+
|
|
63
|
+
return result.getSnippet(titleField);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Because if a field is configured to display as a "title", we don't want
|
|
67
|
+
// to display it again in the fields list
|
|
68
|
+
export function stripUnnecessaryResultFields(resultFields) {
|
|
69
|
+
return Object.keys(resultFields).reduce((acc, n) => {
|
|
70
|
+
if (
|
|
71
|
+
[
|
|
72
|
+
'_meta',
|
|
73
|
+
'id',
|
|
74
|
+
toLowerCase(getTitleField()),
|
|
75
|
+
toLowerCase(getUrlField()),
|
|
76
|
+
toLowerCase(getThumbnailField()),
|
|
77
|
+
].includes(toLowerCase(n))
|
|
78
|
+
) {
|
|
79
|
+
return acc;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
acc[n] = resultFields[n];
|
|
83
|
+
return acc;
|
|
84
|
+
}, {});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function buildSearchOptionsFromConfig() {
|
|
88
|
+
const config = getConfig();
|
|
89
|
+
const searchFields = (config.searchFields || config.fields || []).reduce((acc, n) => {
|
|
90
|
+
acc = acc || {};
|
|
91
|
+
acc[n] = {};
|
|
92
|
+
return acc;
|
|
93
|
+
}, undefined);
|
|
94
|
+
|
|
95
|
+
const resultFields = (config.resultFields || config.fields || []).reduce((acc, n) => {
|
|
96
|
+
acc = acc || {};
|
|
97
|
+
acc[n] = {
|
|
98
|
+
raw: {},
|
|
99
|
+
snippet: {
|
|
100
|
+
size: 100,
|
|
101
|
+
fallback: true,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
return acc;
|
|
105
|
+
}, undefined);
|
|
106
|
+
|
|
107
|
+
// We can't use url, thumbnail, or title fields unless they're actually
|
|
108
|
+
// in the reuslts.
|
|
109
|
+
if (config.urlField) {
|
|
110
|
+
resultFields[config.urlField] = {
|
|
111
|
+
raw: {},
|
|
112
|
+
snippet: {
|
|
113
|
+
size: 100,
|
|
114
|
+
fallback: true,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (config.thumbnailField) {
|
|
120
|
+
resultFields[config.thumbnailField] = {
|
|
121
|
+
raw: {},
|
|
122
|
+
snippet: {
|
|
123
|
+
size: 100,
|
|
124
|
+
fallback: true,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (config.titleField) {
|
|
130
|
+
resultFields[config.titleField] = {
|
|
131
|
+
raw: {},
|
|
132
|
+
snippet: {
|
|
133
|
+
size: 100,
|
|
134
|
+
fallback: true,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const searchOptions: any = {};
|
|
140
|
+
searchOptions.result_fields = resultFields;
|
|
141
|
+
searchOptions.search_fields = searchFields;
|
|
142
|
+
return searchOptions;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function buildFacetConfigFromConfig() {
|
|
146
|
+
const config = getConfig();
|
|
147
|
+
|
|
148
|
+
const facets = (config.facets || []).reduce((acc, n) => {
|
|
149
|
+
acc = acc || {};
|
|
150
|
+
acc[n] = {
|
|
151
|
+
type: 'value',
|
|
152
|
+
size: 100,
|
|
153
|
+
};
|
|
154
|
+
return acc;
|
|
155
|
+
}, undefined);
|
|
156
|
+
|
|
157
|
+
return facets;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function buildSortOptionsFromConfig() {
|
|
161
|
+
const config = getConfig();
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
name: 'Relevance',
|
|
165
|
+
value: '',
|
|
166
|
+
direction: '',
|
|
167
|
+
},
|
|
168
|
+
...(config.sortFields || []).reduce((acc, sortField) => {
|
|
169
|
+
acc.push({
|
|
170
|
+
name: `${capitalizeFirstLetter(sortField)} ASC`,
|
|
171
|
+
value: sortField,
|
|
172
|
+
direction: 'asc',
|
|
173
|
+
});
|
|
174
|
+
acc.push({
|
|
175
|
+
name: `${capitalizeFirstLetter(sortField)} DESC`,
|
|
176
|
+
value: sortField,
|
|
177
|
+
direction: 'desc',
|
|
178
|
+
});
|
|
179
|
+
return acc;
|
|
180
|
+
}, []),
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function buildAutocompleteQueryConfig() {
|
|
185
|
+
const querySuggestFields = getConfig().querySuggestFields;
|
|
186
|
+
if (!querySuggestFields || !Array.isArray(querySuggestFields) || querySuggestFields.length === 0) {
|
|
187
|
+
return {};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
suggestions: {
|
|
192
|
+
types: {
|
|
193
|
+
documents: {
|
|
194
|
+
fields: getConfig().querySuggestFields,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function getDefaultConnectConfig() {
|
|
202
|
+
return {
|
|
203
|
+
host:
|
|
204
|
+
process.env.NEXT_PUBLIC_ELASTICSEARCH_HOST ||
|
|
205
|
+
process.env.REACT_APP_ELASTICSEARCH_HOST ||
|
|
206
|
+
process.env.STORYBOOK_ELASTICSEARCH_HOST ||
|
|
207
|
+
'http://localhost:9200',
|
|
208
|
+
index:
|
|
209
|
+
process.env.NEXT_PUBLIC_ELASTICSEARCH_INDEX ||
|
|
210
|
+
process.env.REACT_APP_ELASTICSEARCH_INDEX ||
|
|
211
|
+
process.env.STORYBOOK_ELASTICSEARCH_INDEX ||
|
|
212
|
+
'',
|
|
213
|
+
apiKey:
|
|
214
|
+
process.env.NEXT_PUBLIC_ELASTICSEARCH_API_KEY ||
|
|
215
|
+
process.env.REACT_APP_ELASTICSEARCH_API_KEY ||
|
|
216
|
+
process.env.STORYBOOK_ELASTICSEARCH_API_KEY ||
|
|
217
|
+
'',
|
|
218
|
+
};
|
|
219
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Search';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function getNewClassName(newClassName: string | string[]) {
|
|
2
|
+
if (!Array.isArray(newClassName)) return newClassName;
|
|
3
|
+
|
|
4
|
+
return newClassName.filter((name) => name).join(' ');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default function appendClassName(
|
|
8
|
+
baseClassName?: string | string[] | undefined,
|
|
9
|
+
newClassName?: string | string[] | undefined,
|
|
10
|
+
): string {
|
|
11
|
+
if (!newClassName) return (Array.isArray(baseClassName) ? baseClassName.join(' ') : baseClassName) || '';
|
|
12
|
+
if (!baseClassName) return getNewClassName(newClassName) || '';
|
|
13
|
+
return `${baseClassName} ${getNewClassName(newClassName)}`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
function isFieldValueWrapper(object: any) {
|
|
2
|
+
return (
|
|
3
|
+
object &&
|
|
4
|
+
(Object.prototype.hasOwnProperty.call(object, 'raw') || Object.prototype.hasOwnProperty.call(object, 'snippet'))
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Returns true for objects like this:
|
|
9
|
+
// objectField: {
|
|
10
|
+
// objectSubField1: { raw: "one" },
|
|
11
|
+
// objectSubField2: { raw: "two" }
|
|
12
|
+
// }
|
|
13
|
+
// And false for objects like this:
|
|
14
|
+
// objectField: { raw: "one" }
|
|
15
|
+
function isNestedField(result: any, field: any) {
|
|
16
|
+
return (
|
|
17
|
+
result &&
|
|
18
|
+
result[field] &&
|
|
19
|
+
field !== '_meta' &&
|
|
20
|
+
typeof result[field] === 'object' &&
|
|
21
|
+
!isFieldValueWrapper(result[field])
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Takes any value and removes the wrapper around deepest values
|
|
26
|
+
// (removes the wrapper Object with "raw" and/or "snippet" fields)
|
|
27
|
+
// See tests for examples
|
|
28
|
+
function cleanValueWrappers(value: any): any {
|
|
29
|
+
if (isFieldValueWrapper(value)) {
|
|
30
|
+
return getEscapedField(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
return value.map(cleanValueWrappers);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof value === 'object') {
|
|
38
|
+
return Object.entries(value).reduce((acc: any, [key, value]) => {
|
|
39
|
+
acc[key] = cleanValueWrappers(value);
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getFieldType(object: any, type: any) {
|
|
48
|
+
if (object) return object[type];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getRaw(object: any) {
|
|
52
|
+
return getFieldType(object, 'raw');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getSnippet(object: any) {
|
|
56
|
+
return getFieldType(object, 'snippet');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function htmlEscape(str: string) {
|
|
60
|
+
if (!str) return '';
|
|
61
|
+
|
|
62
|
+
return String(str)
|
|
63
|
+
.replace(/&/g, '&')
|
|
64
|
+
.replace(/"/g, '"')
|
|
65
|
+
.replace(/'/g, ''')
|
|
66
|
+
.replace(/</g, '<')
|
|
67
|
+
.replace(/>/g, '>');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getEscapedField(maybeObject: any) {
|
|
71
|
+
// Fallback to raw values here, because non-string fields
|
|
72
|
+
// will not have a snippet fallback. Raw values MUST be html escaped.
|
|
73
|
+
const safeField = getSnippet(maybeObject) || htmlEscape(getRaw(maybeObject));
|
|
74
|
+
return Array.isArray(safeField) ? safeField.join(', ') : safeField;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function formatResult(result: any) {
|
|
78
|
+
return Object.keys(result).reduce((acc, field) => {
|
|
79
|
+
if (isNestedField(result, field)) {
|
|
80
|
+
return {
|
|
81
|
+
...acc,
|
|
82
|
+
[field]: JSON.stringify(cleanValueWrappers(result[field])),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// If we receive an arbitrary value from the response, we may not properly
|
|
87
|
+
// handle it, so we should filter out arbitrary values here.
|
|
88
|
+
//
|
|
89
|
+
// I.e.,
|
|
90
|
+
// Arbitrary value: "_metaField: '1939191'"
|
|
91
|
+
// vs.
|
|
92
|
+
// FieldValueWrapper: "_metaField: {raw: '1939191'}"
|
|
93
|
+
if (!isFieldValueWrapper(result[field])) return acc;
|
|
94
|
+
|
|
95
|
+
return { ...acc, [field]: getEscapedField(result[field]) };
|
|
96
|
+
}, {});
|
|
97
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Since Filter Values come in many different varieties, this helper
|
|
3
|
+
encapsulates the logic for determining how to show the label of that
|
|
4
|
+
filter in the UI.
|
|
5
|
+
*/
|
|
6
|
+
export default function getFilterValueDisplay(filterValue: any): string {
|
|
7
|
+
if (filterValue === undefined || filterValue === null) return '';
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(filterValue, 'name')) return filterValue.name;
|
|
9
|
+
return String(filterValue);
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const VALID_PROTOCOLS = ['http:', 'https:'];
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {URL} URLParser URL interface provided by browser https://developer.mozilla.org/en-US/docs/Web/API/URL
|
|
6
|
+
* @param {String} currentLocation String representation of the browser's current location
|
|
7
|
+
*/
|
|
8
|
+
export default function getUrlSanitizer(URLParser: typeof URL, currentLocation: string) {
|
|
9
|
+
// This function is curried so that dependencies can be injected and don't need to be mocked in tests.
|
|
10
|
+
return (url: string) => {
|
|
11
|
+
let parsedUrl;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
// Attempts to parse a URL as relative
|
|
15
|
+
parsedUrl = new URLParser(url, currentLocation);
|
|
16
|
+
} catch {
|
|
17
|
+
// If it fails, it means the URL is invalid or not relative
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return parsedUrl && VALID_PROTOCOLS.includes(parsedUrl.protocol) ? url : '';
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as getFilterValueDisplay } from './getFilterValueDisplay';
|
|
2
|
+
export { default as appendClassName } from './appendClassName';
|
|
3
|
+
export { default as getUrlSanitizer } from './getUrlSanitizer';
|
|
4
|
+
export { formatResult, getEscapedField, getRaw } from './formatResult';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { isMobileOnly } from 'react-device-detect';
|
|
4
|
+
import { Props } from './Layout.types';
|
|
5
|
+
// import Sidebar from "../Sidebar";
|
|
6
|
+
|
|
7
|
+
function Layout({
|
|
8
|
+
className,
|
|
9
|
+
children,
|
|
10
|
+
header,
|
|
11
|
+
bodyContent,
|
|
12
|
+
bodyFooter,
|
|
13
|
+
bodyHeader,
|
|
14
|
+
sideContent,
|
|
15
|
+
showSidebar,
|
|
16
|
+
}: Props) {
|
|
17
|
+
const sidebarClasses = cx(
|
|
18
|
+
'hidden md:block fixed md:relative w-full h-full left-0 md:left-auto top-0 md:top-auto px-2 pb-4 md:pt-6 md:px-6 md:pb-auto md:pl-0',
|
|
19
|
+
{ 'hidden md:hidden': !sideContent },
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<div className={cx('w-full flex flex-col', className)}>
|
|
25
|
+
<div className="m-auto md:py-0 w-full">{header}</div>
|
|
26
|
+
<div
|
|
27
|
+
className={cx('md:grid m-auto md:py-0 w-full', {
|
|
28
|
+
'md:grid-cols-1': !sideContent,
|
|
29
|
+
'md:grid-cols-[1fr_3fr]': sideContent,
|
|
30
|
+
})}>
|
|
31
|
+
{!isMobileOnly && <div className={sidebarClasses}>{sideContent}</div>}
|
|
32
|
+
<div
|
|
33
|
+
className={cx('p-0 pt-2 md:p-6 md:pr-0', {
|
|
34
|
+
'md:pl-0': !sideContent,
|
|
35
|
+
})}>
|
|
36
|
+
<div className="flex flex-row gap-8 items-center justify-end">{bodyHeader}</div>
|
|
37
|
+
<div className="relative">{children || bodyContent}</div>
|
|
38
|
+
<div className="flex items-center justify-around">{bodyFooter}</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
{isMobileOnly && showSidebar && <div className="fixed z-10 w-full top-0 left-0 right-0 bottom-0 bg-body-bg px-4 overflow-scroll">{sideContent}</div>}
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Layout.displayName = 'Layout';
|
|
48
|
+
|
|
49
|
+
export default Layout;
|
|
50
|
+
export type { Props };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
header?: ReactNode;
|
|
7
|
+
bodyContent?: ReactNode;
|
|
8
|
+
bodyFooter?: ReactNode;
|
|
9
|
+
bodyHeader?: ReactNode;
|
|
10
|
+
sideContent?: ReactNode;
|
|
11
|
+
noSidebar?: boolean;
|
|
12
|
+
showSidebar?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Layout';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { FieldValue } from '@elastic/search-ui';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { getFilterValueDisplay } from '../../view-helpers';
|
|
4
|
+
import { Props } from './MultiCheckboxFacet.types';
|
|
5
|
+
import Copy from '../../../../components/Copy';
|
|
6
|
+
import { COPY_SIZE, COPY_TAG, COPY_TRANSFORM } from '../../../../components/Copy/Copy.types';
|
|
7
|
+
import Button from '../../../../components/Button';
|
|
8
|
+
import { BTN_SIZES, BTN_VARIANTS } from '../../../../components/Button/Button.types';
|
|
9
|
+
import Checkbox from '../../../../components/Checkbox';
|
|
10
|
+
import TextInput from '../../../../components/TextInput';
|
|
11
|
+
import { InputType } from '../../../../components/TextInput/TextInput.types';
|
|
12
|
+
import Label from '../../../../components/Label';
|
|
13
|
+
|
|
14
|
+
function MultiCheckboxFacet({
|
|
15
|
+
className,
|
|
16
|
+
label,
|
|
17
|
+
onMoreClick,
|
|
18
|
+
onRemove,
|
|
19
|
+
onSelect,
|
|
20
|
+
options,
|
|
21
|
+
showMore,
|
|
22
|
+
showSearch,
|
|
23
|
+
onSearch,
|
|
24
|
+
searchPlaceholder,
|
|
25
|
+
}: Props) {
|
|
26
|
+
if (!options) {
|
|
27
|
+
return <>Options required</>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<fieldset className={cx('m-0 p-0 mt-4 mb-2 border-none', className)}>
|
|
32
|
+
<Label className="text-sm" transform={COPY_TRANSFORM.UPPERCASE}>
|
|
33
|
+
{label}
|
|
34
|
+
</Label>
|
|
35
|
+
|
|
36
|
+
{showSearch && (
|
|
37
|
+
<div className="mt-1">
|
|
38
|
+
<TextInput
|
|
39
|
+
type={InputType.SEARCH}
|
|
40
|
+
placeholder={searchPlaceholder || 'Search'}
|
|
41
|
+
onChange={(e) => {
|
|
42
|
+
onSearch(e.target.value);
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
47
|
+
|
|
48
|
+
<div className="my-4">
|
|
49
|
+
{options?.length < 1 && <div>No matching options</div>}
|
|
50
|
+
{options?.map((option) => {
|
|
51
|
+
const checked = option.selected;
|
|
52
|
+
const value = option.value as FieldValue;
|
|
53
|
+
const filterDisplayValue = getFilterValueDisplay(value);
|
|
54
|
+
return (
|
|
55
|
+
<div key={filterDisplayValue} className="flex justify-between pb-2">
|
|
56
|
+
<Checkbox
|
|
57
|
+
id={`facet_${label}${filterDisplayValue}`}
|
|
58
|
+
data-transaction-name={`facet - ${label}`}
|
|
59
|
+
checked={checked}
|
|
60
|
+
onChange={() => (checked ? onRemove(value) : onSelect(value))}
|
|
61
|
+
label={filterDisplayValue}
|
|
62
|
+
/>
|
|
63
|
+
<Copy as={COPY_TAG.SPAN} size={COPY_SIZE.SMALL}>{option.count.toLocaleString('en')}</Copy>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
})}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
{showMore && (
|
|
70
|
+
<Button
|
|
71
|
+
size={BTN_SIZES.SMALL}
|
|
72
|
+
variant={BTN_VARIANTS.TERTIARY}
|
|
73
|
+
onClick={onMoreClick}
|
|
74
|
+
aria-label="Show more options">
|
|
75
|
+
+ More
|
|
76
|
+
</Button>
|
|
77
|
+
)}
|
|
78
|
+
</fieldset>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
MultiCheckboxFacet.displayName = 'MultiCheckboxFacet';
|
|
83
|
+
|
|
84
|
+
export default MultiCheckboxFacet;
|
|
85
|
+
export type { Props };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './MultiCheckboxFacet';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import RCPagination from 'rc-pagination';
|
|
3
|
+
import enUsLocale from 'rc-pagination/lib/locale/en_US';
|
|
4
|
+
import { Props } from './Paging.types';
|
|
5
|
+
import Icon from '../../../../components/Icon';
|
|
6
|
+
|
|
7
|
+
function Paging({ className, current, resultsPerPage = 10, onChange, totalPages, ...rest }: Props) {
|
|
8
|
+
return (
|
|
9
|
+
<RCPagination
|
|
10
|
+
current={current}
|
|
11
|
+
onChange={onChange}
|
|
12
|
+
simple
|
|
13
|
+
pageSize={resultsPerPage}
|
|
14
|
+
total={totalPages * resultsPerPage}
|
|
15
|
+
className={cx('m-0 p-0 list-none text-body-text flex gap-2 text-center items-center [&>li>span]:px-2 [&>li>input]:text-black [&>li>input]:rounded [&>li>input]:text-center', className)}
|
|
16
|
+
locale={enUsLocale}
|
|
17
|
+
prevIcon={
|
|
18
|
+
<div className="text-body-text">
|
|
19
|
+
<Icon name="mdi:chevron-left" />
|
|
20
|
+
</div>
|
|
21
|
+
}
|
|
22
|
+
nextIcon={
|
|
23
|
+
<div className="text-body-text">
|
|
24
|
+
<Icon name="mdi:chevron-right" />
|
|
25
|
+
</div>
|
|
26
|
+
}
|
|
27
|
+
{...rest}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Paging.displayName = 'Paging';
|
|
33
|
+
|
|
34
|
+
export default Paging;
|
|
35
|
+
export type { Props };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Rename } from '@elastic/react-search-ui-views';
|
|
2
|
+
import { BaseContainerProps } from '@elastic/react-search-ui/lib/esm/types';
|
|
3
|
+
import { SearchContextState } from '@elastic/search-ui';
|
|
4
|
+
|
|
5
|
+
export type PagingContainerContext = Pick<
|
|
6
|
+
SearchContextState,
|
|
7
|
+
'current' | 'resultsPerPage' | 'totalPages' | 'setCurrent'
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export type PagingContainerProps = BaseContainerProps &
|
|
11
|
+
PagingContainerContext & {
|
|
12
|
+
view?: React.ComponentType<PagingViewProps>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type PagingViewProps = Rename<
|
|
16
|
+
BaseContainerProps & PagingContainerContext,
|
|
17
|
+
{
|
|
18
|
+
setCurrent: 'onChange';
|
|
19
|
+
}
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export interface Props extends PagingViewProps {
|
|
23
|
+
custom?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Paging';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { Props } from './PagingInfo.types';
|
|
4
|
+
|
|
5
|
+
function PagingInfo({
|
|
6
|
+
className,
|
|
7
|
+
end,
|
|
8
|
+
searchTerm,
|
|
9
|
+
start,
|
|
10
|
+
totalResults,
|
|
11
|
+
...rest
|
|
12
|
+
}: Props & React.HTMLAttributes<HTMLDivElement>) {
|
|
13
|
+
return (
|
|
14
|
+
<div className={cx("m-0 p-0 flex-1", className)} {...rest}>
|
|
15
|
+
Showing{" "}
|
|
16
|
+
<strong>
|
|
17
|
+
{start} - {end}
|
|
18
|
+
</strong>{" "}
|
|
19
|
+
out of <strong>{totalResults}</strong>
|
|
20
|
+
{searchTerm && (
|
|
21
|
+
<>
|
|
22
|
+
{" "}
|
|
23
|
+
for: <em>{searchTerm}</em>
|
|
24
|
+
</>
|
|
25
|
+
)}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
PagingInfo.displayName = 'PagingInfo';
|
|
31
|
+
|
|
32
|
+
export default PagingInfo;
|
|
33
|
+
export type { Props };
|
|
34
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Rename } from '@elastic/react-search-ui-views';
|
|
2
|
+
import { BaseContainerProps } from '@elastic/react-search-ui/lib/esm/types';
|
|
3
|
+
import { SearchContextState } from '@elastic/search-ui';
|
|
4
|
+
|
|
5
|
+
export type PagingInfoContainerContext = Pick<
|
|
6
|
+
SearchContextState,
|
|
7
|
+
'pagingStart' | 'pagingEnd' | 'resultSearchTerm' | 'totalResults'
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export type PagingInfoContainerProps = BaseContainerProps &
|
|
11
|
+
PagingInfoContainerContext & {
|
|
12
|
+
view?: React.ComponentType<PagingInfoViewProps>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type PagingInfoViewProps = Rename<
|
|
16
|
+
BaseContainerProps & PagingInfoContainerContext,
|
|
17
|
+
{
|
|
18
|
+
pagingStart: 'start';
|
|
19
|
+
resultSearchTerm: 'searchTerm';
|
|
20
|
+
pagingEnd: 'end';
|
|
21
|
+
}
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export interface Props extends PagingInfoViewProps {
|
|
25
|
+
custom?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PagingInfo';
|