@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,395 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
3
|
+
import Search from '.';
|
|
4
|
+
// import { parseDuration } from '../../utils/parseDuration';
|
|
5
|
+
// import { formatDuration } from 'date-fns';
|
|
6
|
+
import { formatDate, subDays } from 'date-fns';
|
|
7
|
+
import SingleSelectFacet from './views/SingleSelectFacet';
|
|
8
|
+
import SingleLinksFacet from './views/SingleLinksFacet';
|
|
9
|
+
import MultiCheckboxFacet from './views/MultiCheckboxFacet';
|
|
10
|
+
import { ResultAsTypes } from './Search.types';
|
|
11
|
+
import Container from '../../components/Container';
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof Search> = {
|
|
14
|
+
title: 'FEATURES/Search',
|
|
15
|
+
component: Search,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof Search>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: args => {
|
|
22
|
+
return (
|
|
23
|
+
<Container>
|
|
24
|
+
<Search {...args} />
|
|
25
|
+
</Container>
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const now = Math.floor(new Date().getTime()) / 1000;
|
|
31
|
+
const oneDayAgo = Math.floor(subDays(new Date(), 1).getTime()) / 1000;
|
|
32
|
+
const oneWeekAgo = Math.floor(subDays(new Date(), 7).getTime()) / 1000;
|
|
33
|
+
const oneMonthAgo = Math.floor(subDays(new Date(), 30).getTime()) / 1000;
|
|
34
|
+
const oneYearAgo = Math.floor(subDays(new Date(), 365).getTime()) / 1000;
|
|
35
|
+
const tenYearsAgo = Math.floor(subDays(new Date(), 365 * 10).getTime()) / 1000;
|
|
36
|
+
|
|
37
|
+
const lessThan15Mins = 60 * 15;
|
|
38
|
+
const lessThan30Mins = 60 * 30;
|
|
39
|
+
const lessThan45Mins = 60 * 45;
|
|
40
|
+
const lessThan60Mins = 60 * 60;
|
|
41
|
+
const moreThan60Mins = 60 * 60;
|
|
42
|
+
|
|
43
|
+
const NRG_CONFIG = {
|
|
44
|
+
filters: [],
|
|
45
|
+
searchFields: {
|
|
46
|
+
title: {
|
|
47
|
+
weight: 3,
|
|
48
|
+
},
|
|
49
|
+
description: {},
|
|
50
|
+
workout_type: {},
|
|
51
|
+
},
|
|
52
|
+
facets: {
|
|
53
|
+
['workout_type.keyword']: { type: 'value' },
|
|
54
|
+
['livestream_section.keyword']: { type: 'value' },
|
|
55
|
+
['targeted_section.keyword']: { type: 'value' },
|
|
56
|
+
['level.keyword']: { type: 'value' },
|
|
57
|
+
duration_filter: {
|
|
58
|
+
type: 'range',
|
|
59
|
+
ranges: [
|
|
60
|
+
{ from: 0, to: lessThan15Mins, name: 'Less than 15 minutes' },
|
|
61
|
+
{ from: lessThan15Mins, to: lessThan30Mins, name: '15-30 minutes' },
|
|
62
|
+
{ from: lessThan30Mins, to: lessThan45Mins, name: '30-45 minutes' },
|
|
63
|
+
{ from: lessThan45Mins, to: lessThan60Mins, name: '45-60 minutes' },
|
|
64
|
+
{ from: lessThan60Mins, to: moreThan60Mins, name: 'More than 60 minutes' },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
created: {
|
|
68
|
+
type: 'range',
|
|
69
|
+
ranges: [
|
|
70
|
+
{ from: oneDayAgo, to: now, name: 'Past 24 hours' },
|
|
71
|
+
{ from: oneWeekAgo, to: now, name: 'Past week' },
|
|
72
|
+
{ from: oneMonthAgo, to: now, name: 'Past month' },
|
|
73
|
+
{ from: oneYearAgo, to: now, name: 'Past year' },
|
|
74
|
+
{ from: tenYearsAgo, to: now, name: 'Past decade' },
|
|
75
|
+
{ from: tenYearsAgo, name: 'Older' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
resultsFields: {
|
|
80
|
+
uuid: { raw: {} },
|
|
81
|
+
updated: { raw: {} },
|
|
82
|
+
created: { raw: {} },
|
|
83
|
+
title: { raw: {} },
|
|
84
|
+
duration: { raw: {} },
|
|
85
|
+
duration_filter: { raw: {} },
|
|
86
|
+
image_16_9: { raw: {} },
|
|
87
|
+
image: { raw: {} },
|
|
88
|
+
livestream_section: { raw: {} },
|
|
89
|
+
video_poster: { raw: {} },
|
|
90
|
+
video_url: { raw: {} },
|
|
91
|
+
workout_type: { raw: {} },
|
|
92
|
+
description: {
|
|
93
|
+
snippet: {
|
|
94
|
+
size: 100,
|
|
95
|
+
fallback: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
alwaysSearchOnInitialLoad: true,
|
|
100
|
+
initialPlaceholder: 'Search for workouts...',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const NRG_FACETS = [
|
|
104
|
+
{
|
|
105
|
+
field: 'workout_type.keyword',
|
|
106
|
+
label: 'Workout type',
|
|
107
|
+
view: SingleSelectFacet,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
field: 'livestream_section.keyword',
|
|
111
|
+
label: 'Live stream',
|
|
112
|
+
view: SingleLinksFacet,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
field: 'targeted_section.keyword',
|
|
116
|
+
label: 'Targeted Workouts',
|
|
117
|
+
view: MultiCheckboxFacet,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
field: 'created',
|
|
121
|
+
label: 'Date created',
|
|
122
|
+
view: MultiCheckboxFacet,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
field: 'duration_filter',
|
|
126
|
+
label: 'Duration',
|
|
127
|
+
view: MultiCheckboxFacet,
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
const NRG_FIELD_MAP = {
|
|
132
|
+
idField: {
|
|
133
|
+
fieldName: 'uuid',
|
|
134
|
+
},
|
|
135
|
+
titleField: {
|
|
136
|
+
fieldName: 'title',
|
|
137
|
+
},
|
|
138
|
+
imageField: {
|
|
139
|
+
fieldName: 'image_16_9',
|
|
140
|
+
},
|
|
141
|
+
onClickLink: (event: any) => {
|
|
142
|
+
console.log('onClickLink', event);
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
const item = event.currentTarget;
|
|
145
|
+
const itemId = item.getAttribute('data-id');
|
|
146
|
+
console.log('onClickLink', itemId);
|
|
147
|
+
},
|
|
148
|
+
// metaDataFields: [
|
|
149
|
+
// {
|
|
150
|
+
// fieldName: 'workout_type',
|
|
151
|
+
// // Get first value from CSV list
|
|
152
|
+
// formatter: (value: string) => value.split(',')[0],
|
|
153
|
+
// },
|
|
154
|
+
// {
|
|
155
|
+
// fieldName: 'duration',
|
|
156
|
+
// // Convert ISO duration to human readable format
|
|
157
|
+
// formatter: (value: string) => {
|
|
158
|
+
// const duration = parseDuration(value);
|
|
159
|
+
// const formatedDuration = formatDuration(duration);
|
|
160
|
+
// return formatedDuration;
|
|
161
|
+
// },
|
|
162
|
+
// },
|
|
163
|
+
// ],
|
|
164
|
+
actionsData: {
|
|
165
|
+
// like: {
|
|
166
|
+
// isActive: true,
|
|
167
|
+
// onClick: (data: any) => {
|
|
168
|
+
// console.log('actionsData like triggered', data);
|
|
169
|
+
// },
|
|
170
|
+
// },
|
|
171
|
+
// share: {
|
|
172
|
+
// isActive: false,
|
|
173
|
+
// onClick: (data: any) => {
|
|
174
|
+
// console.log('actionsData like triggered', data);
|
|
175
|
+
// },
|
|
176
|
+
// },
|
|
177
|
+
// save: {
|
|
178
|
+
// isActive: false,
|
|
179
|
+
// onClick: (data: any) => {
|
|
180
|
+
// console.log('actionsData like triggered', data);
|
|
181
|
+
// },
|
|
182
|
+
// },
|
|
183
|
+
// comment: {
|
|
184
|
+
// isActive: true,
|
|
185
|
+
// onClick: (data: any) => {
|
|
186
|
+
// console.log('actionsData like triggered', data);
|
|
187
|
+
// },
|
|
188
|
+
// },
|
|
189
|
+
// bookmark: {
|
|
190
|
+
// isActive: false,
|
|
191
|
+
// onClick: (data: any) => {
|
|
192
|
+
// console.log('actionsData like triggered', data);
|
|
193
|
+
// },
|
|
194
|
+
// },
|
|
195
|
+
// report: {
|
|
196
|
+
// isActive: false,
|
|
197
|
+
// onClick: (data: any) => {
|
|
198
|
+
// console.log('actionsData like triggered', data);
|
|
199
|
+
// },
|
|
200
|
+
// },
|
|
201
|
+
// follow: {
|
|
202
|
+
// isActive: false,
|
|
203
|
+
// onClick: (data: any) => {
|
|
204
|
+
// console.log('actionsData like triggered', data);
|
|
205
|
+
// },
|
|
206
|
+
// },
|
|
207
|
+
// download: {
|
|
208
|
+
// isActive: false,
|
|
209
|
+
// onClick: (data: any) => {
|
|
210
|
+
// console.log('actionsData like triggered', data);
|
|
211
|
+
// },
|
|
212
|
+
// },
|
|
213
|
+
// edit: {
|
|
214
|
+
// isActive: false,
|
|
215
|
+
// onClick: (data: any) => {
|
|
216
|
+
// console.log('actionsData like triggered', data);
|
|
217
|
+
// },
|
|
218
|
+
// },
|
|
219
|
+
// delete: {
|
|
220
|
+
// isActive: false,
|
|
221
|
+
// onClick: (data: any) => {
|
|
222
|
+
// console.log('actionsData like triggered', data);
|
|
223
|
+
// },
|
|
224
|
+
// },
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// const CNBC_CONFIG = {
|
|
229
|
+
// filters: [],
|
|
230
|
+
// searchFields: {
|
|
231
|
+
// generated_title: {
|
|
232
|
+
// weight: 3,
|
|
233
|
+
// },
|
|
234
|
+
// transcript: {},
|
|
235
|
+
// description: {},
|
|
236
|
+
// },
|
|
237
|
+
// facets: {
|
|
238
|
+
// // entities: { type: 'value' },
|
|
239
|
+
// // phrases: { type: 'value' },
|
|
240
|
+
// created: {
|
|
241
|
+
// type: 'range',
|
|
242
|
+
// ranges: [
|
|
243
|
+
// { from: oneDayAgo, to: now, name: 'Past 24 hours' },
|
|
244
|
+
// { from: oneWeekAgo, to: now, name: 'Past week' },
|
|
245
|
+
// { from: oneMonthAgo, to: now, name: 'Past month' },
|
|
246
|
+
// { from: oneYearAgo, to: now, name: 'Past year' },
|
|
247
|
+
// { from: tenYearsAgo, to: now, name: 'Past decade' },
|
|
248
|
+
// { from: tenYearsAgo, name: 'Older' },
|
|
249
|
+
// ],
|
|
250
|
+
// },
|
|
251
|
+
// },
|
|
252
|
+
// resultsFields: {
|
|
253
|
+
// uuid: { raw: {} },
|
|
254
|
+
// changed: { raw: {} },
|
|
255
|
+
// created: { raw: {} },
|
|
256
|
+
// generated_title: { raw: {} },
|
|
257
|
+
// image: { raw: {} },
|
|
258
|
+
// entities: { raw: {} },
|
|
259
|
+
// phrases: { raw: {} },
|
|
260
|
+
// transcript: {
|
|
261
|
+
// snippet: {
|
|
262
|
+
// size: 100,
|
|
263
|
+
// fallback: true,
|
|
264
|
+
// },
|
|
265
|
+
// },
|
|
266
|
+
// video: { raw: {} },
|
|
267
|
+
// description: {
|
|
268
|
+
// snippet: {
|
|
269
|
+
// size: 100,
|
|
270
|
+
// fallback: true,
|
|
271
|
+
// },
|
|
272
|
+
// },
|
|
273
|
+
// },
|
|
274
|
+
// alwaysSearchOnInitialLoad: false,
|
|
275
|
+
// initialPlaceholder: 'Search by name, company, subject...',
|
|
276
|
+
// };
|
|
277
|
+
|
|
278
|
+
// const CNBC_FACETS = [
|
|
279
|
+
// {
|
|
280
|
+
// field: 'created',
|
|
281
|
+
// label: 'Date created',
|
|
282
|
+
// view: MultiCheckboxFacet,
|
|
283
|
+
// },
|
|
284
|
+
// {
|
|
285
|
+
// field: 'duration_filter',
|
|
286
|
+
// label: 'Duration',
|
|
287
|
+
// view: MultiCheckboxFacet,
|
|
288
|
+
// },
|
|
289
|
+
// ];
|
|
290
|
+
|
|
291
|
+
// const CNBC_FIELD_MAP = {
|
|
292
|
+
// idField: {
|
|
293
|
+
// fieldName: 'uuid',
|
|
294
|
+
// },
|
|
295
|
+
// titleField: {
|
|
296
|
+
// fieldName: 'generated_title',
|
|
297
|
+
// },
|
|
298
|
+
// imageField: {
|
|
299
|
+
// fieldName: 'image',
|
|
300
|
+
// },
|
|
301
|
+
// videoField: {
|
|
302
|
+
// fieldName: 'video',
|
|
303
|
+
// formatter: (value: string) => {
|
|
304
|
+
// // console.log('videoField', value);
|
|
305
|
+
// const mp4Video = value
|
|
306
|
+
// ? value.replace('hls', 'mp4').replace('.m3u8', '_Mp4_Avc_Aac_16x9_1920x1080p_24Hz_8.5Mbps_qvbr.mp4')
|
|
307
|
+
// : null;
|
|
308
|
+
// return mp4Video;
|
|
309
|
+
// },
|
|
310
|
+
// },
|
|
311
|
+
// cardProps: {
|
|
312
|
+
// isMuted: false,
|
|
313
|
+
// },
|
|
314
|
+
// onClickLink: (event: any) => {
|
|
315
|
+
// console.log('onClickLink', event);
|
|
316
|
+
// event.preventDefault();
|
|
317
|
+
// const item = event.currentTarget;
|
|
318
|
+
// const itemId = item.getAttribute('data-id');
|
|
319
|
+
// console.log('onClickLink', itemId);
|
|
320
|
+
// },
|
|
321
|
+
// metaDataFields: [
|
|
322
|
+
// {
|
|
323
|
+
// fieldName: 'uuid',
|
|
324
|
+
// // Get first value from CSV list
|
|
325
|
+
// formatter: () => '$1300',
|
|
326
|
+
// },
|
|
327
|
+
// {
|
|
328
|
+
// fieldName: 'created',
|
|
329
|
+
// // Convert ISO duration to human readable format
|
|
330
|
+
// formatter: (value: number) => {
|
|
331
|
+
// // const duration = parseDuration(value);
|
|
332
|
+
// // const formatedDuration = formatDuration(duration);
|
|
333
|
+
// const date = new Date(value * 1000);
|
|
334
|
+
// // console.log('date', date);
|
|
335
|
+
// const fomattedDate = formatDate(date, 'MM/dd/yyyy');
|
|
336
|
+
// return fomattedDate;
|
|
337
|
+
// },
|
|
338
|
+
// },
|
|
339
|
+
// ],
|
|
340
|
+
// actionsData: {
|
|
341
|
+
// bookmark: {
|
|
342
|
+
// isActive: false,
|
|
343
|
+
// onClick: (data: any) => {
|
|
344
|
+
// console.log('actionsData like triggered', data);
|
|
345
|
+
// },
|
|
346
|
+
// },
|
|
347
|
+
// },
|
|
348
|
+
// };
|
|
349
|
+
|
|
350
|
+
const SORT_OPTIONS = [
|
|
351
|
+
{
|
|
352
|
+
name: 'Created',
|
|
353
|
+
value: [
|
|
354
|
+
{
|
|
355
|
+
field: 'created',
|
|
356
|
+
direction: 'desc',
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: 'Relevance',
|
|
362
|
+
value: [],
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
name: 'Title',
|
|
366
|
+
value: [
|
|
367
|
+
{
|
|
368
|
+
field: 'title.keyword',
|
|
369
|
+
direction: 'asc',
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
];
|
|
374
|
+
|
|
375
|
+
Default.args = {
|
|
376
|
+
showOptions: [16, 24, 32],
|
|
377
|
+
config: NRG_CONFIG,
|
|
378
|
+
ResultFieldMap: NRG_FIELD_MAP,
|
|
379
|
+
facetDisplay: NRG_FACETS,
|
|
380
|
+
// config: NRG_CONFIG,
|
|
381
|
+
// ResultFieldMap: NRG_FIELD_MAP,
|
|
382
|
+
// facetDisplay: NRG_FACETS,
|
|
383
|
+
// noSidebar: true,
|
|
384
|
+
// resultAs: ResultAsTypes.cardVideo,
|
|
385
|
+
resultAs: ResultAsTypes.cardBasic,
|
|
386
|
+
sortOptions: SORT_OPTIONS,
|
|
387
|
+
gridClasses: 'grid-cols-1 md:grid-cols-4 lg:grid-cols-4',
|
|
388
|
+
showPagingInfo: true,
|
|
389
|
+
// initialState: {
|
|
390
|
+
// searchTerm: 'barre',
|
|
391
|
+
// },
|
|
392
|
+
showTextSearch: true,
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
export default meta;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import ElasticSearchAPIConnector from '@elastic/search-ui-elasticsearch-connector';
|
|
3
|
+
import {
|
|
4
|
+
ErrorBoundary,
|
|
5
|
+
Facet,
|
|
6
|
+
SearchProvider,
|
|
7
|
+
SearchBox,
|
|
8
|
+
Results,
|
|
9
|
+
PagingInfo,
|
|
10
|
+
ResultsPerPage,
|
|
11
|
+
Paging,
|
|
12
|
+
Sorting,
|
|
13
|
+
WithSearch,
|
|
14
|
+
} from '@elastic/react-search-ui';
|
|
15
|
+
import { Props, ResultAsTypes } from './Search.types';
|
|
16
|
+
// Views
|
|
17
|
+
import SortingView from './views/Sorting';
|
|
18
|
+
import PagingView from './views/Paging';
|
|
19
|
+
import ResultsPerPageView from './views/ResultsPerPage';
|
|
20
|
+
import PagingInfoView from './views/PagingInfo';
|
|
21
|
+
import SearchBoxView from './views/SearchBox';
|
|
22
|
+
import LayoutView from './views/Layout';
|
|
23
|
+
import ResultsView from './views/Results';
|
|
24
|
+
import ResultView from './views/Result';
|
|
25
|
+
import { getDefaultConnectConfig } from './config/config-helper';
|
|
26
|
+
import Button from '../../components/Button';
|
|
27
|
+
import { useLanguage } from '../../hooks';
|
|
28
|
+
|
|
29
|
+
export default function Search({
|
|
30
|
+
showOptions,
|
|
31
|
+
sortOptions,
|
|
32
|
+
resultAs = ResultAsTypes.cardBasic,
|
|
33
|
+
ResultFieldMap,
|
|
34
|
+
config = {
|
|
35
|
+
filters: [],
|
|
36
|
+
facets: {},
|
|
37
|
+
searchFields: {},
|
|
38
|
+
resultsFields: {},
|
|
39
|
+
alwaysSearchOnInitialLoad: true,
|
|
40
|
+
initialPlaceholder: 'Search...',
|
|
41
|
+
},
|
|
42
|
+
facetDisplay = [],
|
|
43
|
+
noSidebar = false,
|
|
44
|
+
customConnector,
|
|
45
|
+
showPagingInfo,
|
|
46
|
+
gridClasses,
|
|
47
|
+
initialState = {},
|
|
48
|
+
showTextSearch = true,
|
|
49
|
+
}: Props) {
|
|
50
|
+
const T = useLanguage();
|
|
51
|
+
const connector = useMemo(() => {
|
|
52
|
+
const defaultConnector = getDefaultConnectConfig();
|
|
53
|
+
|
|
54
|
+
return new ElasticSearchAPIConnector(customConnector || defaultConnector);
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
const searchConfig = useMemo(() => {
|
|
58
|
+
return {
|
|
59
|
+
debug: process.env.NODE_ENV === 'development',
|
|
60
|
+
alwaysSearchOnInitialLoad: true, //config.alwaysSearchOnInitialLoad,
|
|
61
|
+
apiConnector: connector,
|
|
62
|
+
hasA11yNotifications: true,
|
|
63
|
+
searchQuery: {
|
|
64
|
+
filters: config.filters || [],
|
|
65
|
+
search_fields: config.searchFields || {},
|
|
66
|
+
result_fields: config.resultsFields || {},
|
|
67
|
+
// disjunctiveFacets: ['created'], // Make certain Facets into OR instead of AND
|
|
68
|
+
facets: config.facets,
|
|
69
|
+
sortList: [],
|
|
70
|
+
},
|
|
71
|
+
autocompleteQuery: {
|
|
72
|
+
results: {
|
|
73
|
+
search_fields: {
|
|
74
|
+
title: {},
|
|
75
|
+
description: {},
|
|
76
|
+
},
|
|
77
|
+
resultsPerPage: 5,
|
|
78
|
+
result_fields: {
|
|
79
|
+
title: {
|
|
80
|
+
snippet: {
|
|
81
|
+
size: 100,
|
|
82
|
+
fallback: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
// TODO: Implement suggestions
|
|
88
|
+
// suggestions: {
|
|
89
|
+
// types: {
|
|
90
|
+
// documents: {
|
|
91
|
+
// fields: ['title'],
|
|
92
|
+
// },
|
|
93
|
+
// },
|
|
94
|
+
// size: 4,
|
|
95
|
+
// },
|
|
96
|
+
},
|
|
97
|
+
onSearch: (requestState, queryConfig, next) => {
|
|
98
|
+
let updatedState = requestState;
|
|
99
|
+
if (
|
|
100
|
+
requestState.searchTerm === '' &&
|
|
101
|
+
requestState.sortList.length === 0 &&
|
|
102
|
+
sortOptions &&
|
|
103
|
+
sortOptions.length > 0
|
|
104
|
+
) {
|
|
105
|
+
const initOption = sortOptions[0];
|
|
106
|
+
updatedState = {
|
|
107
|
+
...requestState,
|
|
108
|
+
sortList: [{ field: initOption?.value?.[0]?.field, direction: initOption?.value?.[0]?.direction }],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return Promise.resolve(next(updatedState, queryConfig));
|
|
112
|
+
},
|
|
113
|
+
initialState: {
|
|
114
|
+
resultsPerPage: showOptions?.[0] || 8,
|
|
115
|
+
...initialState,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}, [config]);
|
|
119
|
+
|
|
120
|
+
const [showSidebar, setShowSidebar] = useState(false);
|
|
121
|
+
|
|
122
|
+
const handleShowFilters = () => {
|
|
123
|
+
setShowSidebar(toggleSidebar => !toggleSidebar);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<SearchProvider config={searchConfig}>
|
|
128
|
+
<WithSearch
|
|
129
|
+
mapContextToProps={({ wasSearched, setSearchTerm }) => ({
|
|
130
|
+
wasSearched,
|
|
131
|
+
setSearchTerm,
|
|
132
|
+
})}>
|
|
133
|
+
{({ wasSearched, setSearchTerm }) => {
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
<ErrorBoundary>
|
|
137
|
+
<LayoutView
|
|
138
|
+
noSidebar={noSidebar}
|
|
139
|
+
showSidebar={showSidebar}
|
|
140
|
+
header={
|
|
141
|
+
showTextSearch && (
|
|
142
|
+
<SearchBox
|
|
143
|
+
view={props => (
|
|
144
|
+
<SearchBoxView
|
|
145
|
+
{...props}
|
|
146
|
+
wasSearched={wasSearched}
|
|
147
|
+
placeholder={config.initialPlaceholder}
|
|
148
|
+
allowReset
|
|
149
|
+
resetTrigger={setSearchTerm}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
/>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
sideContent={
|
|
156
|
+
!noSidebar &&
|
|
157
|
+
facetDisplay && (
|
|
158
|
+
<div>
|
|
159
|
+
<div className="md:hidden flex justify-end pt-2 -mb-2">
|
|
160
|
+
<Button onClick={handleShowFilters} icon="mdi:close">
|
|
161
|
+
{T?.UI?.HIDE_FILTERS}
|
|
162
|
+
</Button>
|
|
163
|
+
</div>
|
|
164
|
+
{wasSearched && sortOptions && (
|
|
165
|
+
<Sorting label={'Sort by'} sortOptions={sortOptions} view={SortingView} />
|
|
166
|
+
)}
|
|
167
|
+
{facetDisplay?.map(({ field, label, view }) => (
|
|
168
|
+
<Facet key={field} field={field} label={label} view={view} />
|
|
169
|
+
))}
|
|
170
|
+
</div>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
bodyContent={
|
|
174
|
+
<Results
|
|
175
|
+
shouldTrackClickThrough={false}
|
|
176
|
+
resultView={props => <ResultView {...props} as={resultAs} cardMap={ResultFieldMap} />}
|
|
177
|
+
className="list-none p-0 m-0"
|
|
178
|
+
view={props => <ResultsView {...props} gridClasses={gridClasses} />}
|
|
179
|
+
/>
|
|
180
|
+
}
|
|
181
|
+
bodyHeader={
|
|
182
|
+
<>
|
|
183
|
+
{wasSearched && showPagingInfo && <PagingInfo view={PagingInfoView} />}
|
|
184
|
+
{wasSearched && showOptions && <ResultsPerPage view={ResultsPerPageView} options={showOptions} />}
|
|
185
|
+
{wasSearched && sortOptions && noSidebar && (
|
|
186
|
+
<Sorting label={'Sort by'} sortOptions={sortOptions} view={SortingView} />
|
|
187
|
+
)}
|
|
188
|
+
{wasSearched && !noSidebar && (
|
|
189
|
+
<div className="block md:hidden">
|
|
190
|
+
<Button rounded onClick={handleShowFilters} icon="mdi:filter-variant-plus" />
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
</>
|
|
194
|
+
}
|
|
195
|
+
bodyFooter={<Paging view={PagingView} />}
|
|
196
|
+
/>
|
|
197
|
+
</ErrorBoundary>
|
|
198
|
+
</>
|
|
199
|
+
);
|
|
200
|
+
}}
|
|
201
|
+
</WithSearch>
|
|
202
|
+
</SearchProvider>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RequestState } from '@elastic/search-ui';
|
|
2
|
+
import { cardMap } from './views/Result/Result.types';
|
|
3
|
+
|
|
4
|
+
export enum ResultAsTypes {
|
|
5
|
+
cardBasic = 'cardBasic',
|
|
6
|
+
cardMedia = 'cardMedia',
|
|
7
|
+
cardVideo = 'cardVideo',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface FacetDisplay {
|
|
11
|
+
field: string;
|
|
12
|
+
label: string;
|
|
13
|
+
view: React.FC<any>;
|
|
14
|
+
}
|
|
15
|
+
export interface Props {
|
|
16
|
+
custom?: string;
|
|
17
|
+
showOptions?: number[];
|
|
18
|
+
sortOptions?: any[];
|
|
19
|
+
resultAs: ResultAsTypes;
|
|
20
|
+
ResultFieldMap?: cardMap;
|
|
21
|
+
config: {
|
|
22
|
+
searchFields: any;
|
|
23
|
+
filters: any[];
|
|
24
|
+
facets: any;
|
|
25
|
+
resultsFields: any;
|
|
26
|
+
alwaysSearchOnInitialLoad?: boolean;
|
|
27
|
+
initialPlaceholder?: string;
|
|
28
|
+
};
|
|
29
|
+
facetDisplay?: FacetDisplay[];
|
|
30
|
+
noSidebar?: boolean;
|
|
31
|
+
customConnector?: {
|
|
32
|
+
host: string;
|
|
33
|
+
index: string;
|
|
34
|
+
apiKey: string;
|
|
35
|
+
};
|
|
36
|
+
showPagingInfo?: boolean;
|
|
37
|
+
gridClasses?: string;
|
|
38
|
+
initialState?: RequestState;
|
|
39
|
+
showTextSearch?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|