@scottish-government/designsystem-react 0.10.2 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/components/Accordion.d.ts +3 -2
- package/@types/components/ButtonGroup.d.ts +5 -0
- package/@types/components/PageHeader.d.ts +2 -1
- package/@types/components/RadioButton.d.ts +2 -2
- package/@types/components/SearchFacets.d.ts +18 -0
- package/@types/components/SearchFilters.d.ts +14 -0
- package/@types/components/SearchResult.d.ts +30 -0
- package/@types/components/SearchSort.d.ts +9 -0
- package/@types/components/SideNavigation.d.ts +1 -1
- package/CHANGELOG.md +39 -5
- package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.d.ts +9 -0
- package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.jsx +62 -0
- package/dist/common/AbstractNotificationBanner/index.d.ts +1 -0
- package/dist/common/AbstractNotificationBanner/index.js +8 -0
- package/dist/common/ActionLink/ActionLink.d.ts +5 -0
- package/dist/common/ActionLink/ActionLink.jsx +19 -0
- package/dist/common/ActionLink/index.d.ts +1 -0
- package/dist/common/ActionLink/index.js +8 -0
- package/dist/common/ConditionalWrapper/ConditionalWrapper.d.ts +8 -0
- package/dist/common/ConditionalWrapper/ConditionalWrapper.jsx +8 -0
- package/dist/common/ConditionalWrapper/index.d.ts +1 -0
- package/dist/common/ConditionalWrapper/index.js +8 -0
- package/dist/common/FileIcon/FileIcon.d.ts +6 -0
- package/dist/common/FileIcon/FileIcon.jsx +46 -0
- package/dist/common/FileIcon/index.d.ts +1 -0
- package/dist/common/FileIcon/index.js +8 -0
- package/dist/common/HintText/HintText.d.ts +5 -0
- package/dist/common/HintText/HintText.jsx +9 -0
- package/dist/common/HintText/index.d.ts +1 -0
- package/dist/common/HintText/index.js +8 -0
- package/dist/common/Icon/Icon.d.ts +6 -0
- package/dist/common/Icon/Icon.jsx +51 -0
- package/dist/common/Icon/index.d.ts +1 -0
- package/dist/common/Icon/index.js +8 -0
- package/dist/common/ScreenReaderText/ScreenReaderText.d.ts +5 -0
- package/dist/common/ScreenReaderText/ScreenReaderText.jsx +9 -0
- package/dist/common/ScreenReaderText/index.d.ts +1 -0
- package/dist/common/ScreenReaderText/index.js +8 -0
- package/dist/common/WrapperTag/WrapperTag.d.ts +8 -0
- package/dist/common/WrapperTag/WrapperTag.jsx +11 -0
- package/dist/common/WrapperTag/index.d.ts +1 -0
- package/dist/common/WrapperTag/index.js +8 -0
- package/dist/common/index.d.ts +8 -0
- package/dist/common/index.js +22 -0
- package/dist/components/Accordion/Accordion.d.ts +10 -0
- package/dist/components/Accordion/Accordion.jsx +8 -3
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Accordion/index.js +8 -0
- package/dist/components/AspectBox/AspectBox.d.ts +6 -0
- package/dist/components/AspectBox/index.d.ts +1 -0
- package/dist/components/AspectBox/index.js +8 -0
- package/dist/components/BackToTop/BackToTop.d.ts +5 -0
- package/dist/components/BackToTop/index.d.ts +1 -0
- package/dist/components/BackToTop/index.js +8 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +9 -0
- package/dist/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/components/Breadcrumbs/index.js +8 -0
- package/dist/components/Button/Button.d.ts +5 -0
- package/dist/components/Button/ButtonGroup.d.ts +5 -0
- package/dist/components/Button/ButtonGroup.jsx +13 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.js +10 -0
- package/dist/components/ButtonGroup/ButtonGroup.jsx +13 -0
- package/dist/components/CategoryItem/CategoryItem.d.ts +5 -0
- package/dist/components/CategoryItem/index.d.ts +1 -0
- package/dist/components/CategoryItem/index.js +8 -0
- package/dist/components/CategoryList/CategoryList.d.ts +6 -0
- package/dist/components/CategoryList/index.d.ts +1 -0
- package/dist/components/CategoryList/index.js +8 -0
- package/dist/components/Checkbox/Checkbox.d.ts +5 -0
- package/dist/components/Checkbox/CheckboxGroup.d.ts +6 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox/index.js +10 -0
- package/dist/components/ConfirmationMessage/ConfirmationMessage.d.ts +5 -0
- package/dist/components/ConfirmationMessage/index.d.ts +1 -0
- package/dist/components/ConfirmationMessage/index.js +8 -0
- package/dist/components/ContentsNav/ContentsNav.d.ts +10 -0
- package/dist/components/ContentsNav/index.d.ts +1 -0
- package/dist/components/ContentsNav/index.js +8 -0
- package/dist/components/CookieBanner/CookieBanner.d.ts +9 -0
- package/dist/components/CookieBanner/index.d.ts +1 -0
- package/dist/components/CookieBanner/index.js +8 -0
- package/dist/components/DatePicker/DatePicker.d.ts +5 -0
- package/dist/components/DatePicker/DatePicker.jsx +2 -2
- package/dist/components/DatePicker/index.d.ts +1 -0
- package/dist/components/DatePicker/index.js +8 -0
- package/dist/components/Details/Details.d.ts +5 -0
- package/dist/components/Details/index.d.ts +1 -0
- package/dist/components/Details/index.js +8 -0
- package/dist/components/ErrorMessage/ErrorMessage.d.ts +5 -0
- package/dist/components/ErrorMessage/index.d.ts +1 -0
- package/dist/components/ErrorMessage/index.js +8 -0
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +9 -0
- package/dist/components/ErrorSummary/index.d.ts +1 -0
- package/dist/components/ErrorSummary/index.js +8 -0
- package/dist/components/FeatureHeader/FeatureHeader.d.ts +13 -0
- package/dist/components/FeatureHeader/FeatureHeader.jsx +70 -0
- package/dist/components/FeatureHeader/index.d.ts +1 -0
- package/dist/components/FeatureHeader/index.js +8 -0
- package/dist/components/FileDownload/FileDownload.d.ts +5 -0
- package/dist/components/FileDownload/index.d.ts +1 -0
- package/dist/components/FileDownload/index.js +8 -0
- package/dist/components/HideThisPage/HideThisPage.d.ts +6 -0
- package/dist/components/HideThisPage/index.d.ts +1 -0
- package/dist/components/HideThisPage/index.js +8 -0
- package/dist/components/InsetText/InsetText.d.ts +5 -0
- package/dist/components/InsetText/index.d.ts +1 -0
- package/dist/components/InsetText/index.js +8 -0
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +9 -0
- package/dist/components/NotificationBanner/index.d.ts +1 -0
- package/dist/components/NotificationBanner/index.js +8 -0
- package/dist/components/NotificationPanel/NotificationPanel.d.ts +5 -0
- package/dist/components/NotificationPanel/index.d.ts +1 -0
- package/dist/components/NotificationPanel/index.js +8 -0
- package/dist/components/PageHeader/PageHeader.d.ts +5 -0
- package/dist/components/PageHeader/PageHeader.jsx +2 -2
- package/dist/components/PageHeader/index.d.ts +1 -0
- package/dist/components/PageHeader/index.js +8 -0
- package/dist/components/PageMetadata/PageMetadata.d.ts +9 -0
- package/dist/components/PageMetadata/index.d.ts +1 -0
- package/dist/components/PageMetadata/index.js +8 -0
- package/dist/components/Pagination/Pagination.d.ts +7 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Pagination/index.js +8 -0
- package/dist/components/PhaseBanner/PhaseBanner.d.ts +5 -0
- package/dist/components/PhaseBanner/index.d.ts +1 -0
- package/dist/components/PhaseBanner/index.js +8 -0
- package/dist/components/Question/Question.d.ts +5 -0
- package/dist/components/Question/Question.jsx +1 -1
- package/dist/components/Question/index.d.ts +1 -0
- package/dist/components/Question/index.js +8 -0
- package/dist/components/RadioButton/RadioButton.d.ts +5 -0
- package/dist/components/RadioButton/RadioGroup.d.ts +6 -0
- package/dist/components/RadioButton/RadioGroup.jsx +1 -1
- package/dist/components/RadioButton/index.d.ts +2 -0
- package/dist/components/RadioButton/index.js +10 -0
- package/dist/components/SearchFacets/SearchFacets.d.ts +14 -0
- package/dist/components/SearchFacets/SearchFacets.jsx +101 -0
- package/dist/components/SearchFacets/index.d.ts +1 -0
- package/dist/components/SearchFacets/index.js +8 -0
- package/dist/components/SearchFilters/SearchFilters.d.ts +16 -0
- package/dist/components/SearchFilters/SearchFilters.jsx +63 -0
- package/dist/components/SearchFilters/index.d.ts +1 -0
- package/dist/components/SearchFilters/index.js +8 -0
- package/dist/components/SearchResult/SearchResult.d.ts +28 -0
- package/dist/components/SearchResult/SearchResult.jsx +93 -0
- package/dist/components/SearchResult/index.d.ts +1 -0
- package/dist/components/SearchResult/index.js +8 -0
- package/dist/components/SearchSort/SearchSort.d.ts +10 -0
- package/dist/components/SearchSort/SearchSort.jsx +28 -0
- package/dist/components/SearchSort/index.d.ts +1 -0
- package/dist/components/SearchSort/index.js +8 -0
- package/dist/components/Select/Select.d.ts +5 -0
- package/dist/components/Select/Select.jsx +1 -1
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Select/index.js +8 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.d.ts +13 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +0 -1
- package/dist/components/SequentialNavigation/index.d.ts +1 -0
- package/dist/components/SequentialNavigation/index.js +8 -0
- package/dist/components/SideNavigation/SideNavigation.d.ts +13 -0
- package/dist/components/SideNavigation/SideNavigation.jsx +2 -2
- package/dist/components/SideNavigation/index.d.ts +1 -0
- package/dist/components/SideNavigation/index.js +8 -0
- package/dist/components/SiteFooter/SiteFooter.d.ts +22 -0
- package/dist/components/SiteFooter/index.d.ts +1 -0
- package/dist/components/SiteFooter/index.js +8 -0
- package/dist/components/SiteHeader/SiteHeader.d.ts +22 -0
- package/dist/components/SiteHeader/SiteHeader.jsx +1 -2
- package/dist/components/SiteHeader/index.d.ts +1 -0
- package/dist/components/SiteHeader/index.js +8 -0
- package/dist/components/SiteNavigation/SiteNavigation.d.ts +9 -0
- package/dist/components/SiteNavigation/index.d.ts +1 -0
- package/dist/components/SiteNavigation/index.js +8 -0
- package/dist/components/SiteSearch/SiteSearch.d.ts +5 -0
- package/dist/components/SiteSearch/SiteSearch.jsx +1 -1
- package/dist/components/SiteSearch/index.d.ts +1 -0
- package/dist/components/SiteSearch/index.js +8 -0
- package/dist/components/SkipLinks/SkipLinks.d.ts +10 -0
- package/dist/components/SkipLinks/SkipLinks.jsx +42 -0
- package/dist/components/SkipLinks/index.d.ts +1 -0
- package/dist/components/SkipLinks/index.js +8 -0
- package/dist/components/SummaryCard/SummaryCard.d.ts +10 -0
- package/dist/components/SummaryCard/index.d.ts +1 -0
- package/dist/components/SummaryCard/index.js +8 -0
- package/dist/components/SummaryList/SummaryList.d.ts +18 -0
- package/dist/components/SummaryList/index.d.ts +1 -0
- package/dist/components/SummaryList/index.js +8 -0
- package/dist/components/Table/Table.d.ts +5 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +8 -0
- package/dist/components/Tabs/Tabs.d.ts +10 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Tabs/index.js +8 -0
- package/dist/components/Tag/Tag.d.ts +5 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/Tag/index.js +8 -0
- package/dist/components/TaskList/TaskList.d.ts +13 -0
- package/dist/components/TaskList/TaskList.jsx +1 -1
- package/dist/components/TaskList/index.d.ts +1 -0
- package/dist/components/TaskList/index.js +8 -0
- package/dist/components/TextInput/TextInput.d.ts +5 -0
- package/dist/components/TextInput/TextInput.jsx +2 -2
- package/dist/components/TextInput/index.d.ts +1 -0
- package/dist/components/TextInput/index.js +8 -0
- package/dist/components/Textarea/Textarea.d.ts +5 -0
- package/dist/components/Textarea/Textarea.jsx +1 -1
- package/dist/components/Textarea/index.d.ts +1 -0
- package/dist/components/Textarea/index.js +8 -0
- package/dist/components/WarningText/WarningText.d.ts +5 -0
- package/dist/components/WarningText/index.d.ts +1 -0
- package/dist/components/WarningText/index.js +8 -0
- package/dist/components/index.d.ts +46 -0
- package/dist/components/index.js +101 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useTracking/index.d.ts +1 -0
- package/dist/hooks/useTracking/index.js +8 -0
- package/dist/hooks/useTracking/useTracking.d.ts +1 -0
- package/dist/hooks/useTracking/useTracking.js +21 -0
- package/dist/images/documents/audio.d.ts +4 -0
- package/dist/images/documents/csv.d.ts +4 -0
- package/dist/images/documents/excel.d.ts +4 -0
- package/dist/images/documents/file.d.ts +4 -0
- package/dist/images/documents/generic.d.ts +4 -0
- package/dist/images/documents/geodata.d.ts +4 -0
- package/dist/images/documents/ical.d.ts +4 -0
- package/dist/images/documents/ico.d.ts +4 -0
- package/dist/images/documents/image.d.ts +4 -0
- package/dist/images/documents/index.d.ts +22 -0
- package/dist/images/documents/odf.d.ts +4 -0
- package/dist/images/documents/odg.d.ts +4 -0
- package/dist/images/documents/odp.d.ts +4 -0
- package/dist/images/documents/ods.d.ts +4 -0
- package/dist/images/documents/odt.d.ts +4 -0
- package/dist/images/documents/pdf.d.ts +4 -0
- package/dist/images/documents/ppt.d.ts +4 -0
- package/dist/images/documents/rtf.d.ts +4 -0
- package/dist/images/documents/text.d.ts +4 -0
- package/dist/images/documents/video.d.ts +4 -0
- package/dist/images/documents/word.d.ts +4 -0
- package/dist/images/documents/xml.d.ts +4 -0
- package/dist/images/documents/zip.d.ts +4 -0
- package/dist/images/icons/arrow_upward.d.ts +4 -0
- package/dist/images/icons/calendar_today.d.ts +4 -0
- package/dist/images/icons/cancel.d.ts +4 -0
- package/dist/images/icons/check_circle.d.ts +4 -0
- package/dist/images/icons/chevron_left.d.ts +4 -0
- package/dist/images/icons/chevron_right.d.ts +4 -0
- package/dist/images/icons/close.d.ts +4 -0
- package/dist/images/icons/description.d.ts +4 -0
- package/dist/images/icons/double_chevron_left.d.ts +4 -0
- package/dist/images/icons/double_chevron_right.d.ts +4 -0
- package/dist/images/icons/error.d.ts +4 -0
- package/dist/images/icons/expand_less.d.ts +4 -0
- package/dist/images/icons/expand_more.d.ts +4 -0
- package/dist/images/icons/index.d.ts +17 -0
- package/dist/images/icons/list.d.ts +4 -0
- package/dist/images/icons/menu.d.ts +4 -0
- package/dist/images/icons/priority_high.d.ts +4 -0
- package/dist/images/icons/search.d.ts +4 -0
- package/dist/images/index.d.ts +2 -0
- package/dist/images/index.js +38 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +40 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context.d.ts +4 -0
- package/package.json +25 -23
- package/src/common/{AbstractNotificationBanner.test.tsx → AbstractNotificationBanner/AbstractNotificationBanner.test.tsx} +1 -1
- package/src/common/{AbstractNotificationBanner.tsx → AbstractNotificationBanner/AbstractNotificationBanner.tsx} +2 -2
- package/src/common/AbstractNotificationBanner/index.ts +1 -0
- package/src/common/ActionLink/index.ts +1 -0
- package/src/common/ConditionalWrapper/index.ts +1 -0
- package/src/common/{FileIcon.tsx → FileIcon/FileIcon.tsx} +1 -1
- package/src/common/FileIcon/index.ts +1 -0
- package/src/common/HintText/index.ts +1 -0
- package/src/common/{Icon.tsx → Icon/Icon.tsx} +1 -1
- package/src/common/Icon/index.ts +1 -0
- package/src/common/ScreenReaderText/index.ts +1 -0
- package/src/common/WrapperTag/index.ts +1 -0
- package/src/common/index.ts +8 -0
- package/src/components/Accordion/Accordion.Item.stories.tsx +10 -9
- package/src/components/Accordion/Accordion.stories.tsx +4 -4
- package/src/components/Accordion/Accordion.test.tsx +48 -14
- package/src/components/Accordion/Accordion.tsx +12 -1
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/AspectBox/index.ts +1 -0
- package/src/components/BackToTop/index.ts +1 -0
- package/src/components/Breadcrumbs/Breadcrumbs.Item.stories.tsx +8 -1
- package/src/components/Breadcrumbs/index.ts +1 -0
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/Button/ButtonGroup.stories.tsx +41 -0
- package/src/components/Button/ButtonGroup.test.tsx +45 -0
- package/src/components/Button/ButtonGroup.tsx +20 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/CategoryItem/index.ts +1 -0
- package/src/components/CategoryList/CategoryList.stories.tsx +1 -1
- package/src/components/CategoryList/CategoryList.test.tsx +1 -1
- package/src/components/CategoryList/index.ts +1 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/ConfirmationMessage/index.ts +1 -0
- package/src/components/ContentsNav/ContentsNav.Item.stories.tsx +8 -0
- package/src/components/ContentsNav/index.ts +1 -0
- package/src/components/CookieBanner/CookieBanner.Buttons.stories.tsx +1 -1
- package/src/components/CookieBanner/CookieBanner.stories.tsx +1 -1
- package/src/components/CookieBanner/index.ts +1 -0
- package/src/components/DatePicker/DatePicker.tsx +2 -2
- package/src/components/DatePicker/index.ts +1 -0
- package/src/components/Details/index.ts +1 -0
- package/src/components/ErrorMessage/index.ts +1 -0
- package/src/components/ErrorSummary/ErrorSummary.Item.stories.tsx +7 -0
- package/src/components/ErrorSummary/index.ts +1 -0
- package/src/components/FeatureHeader/FeatureHeader.stories.tsx +60 -0
- package/src/components/FeatureHeader/FeatureHeader.tsx +94 -0
- package/src/components/FeatureHeader/index.ts +1 -0
- package/src/components/FileDownload/index.ts +1 -0
- package/src/components/HideThisPage/index.ts +1 -0
- package/src/components/InsetText/index.ts +1 -0
- package/src/components/NotificationBanner/index.ts +1 -0
- package/src/components/NotificationPanel/index.ts +1 -0
- package/src/components/PageHeader/PageHeader.stories.tsx +1 -1
- package/src/components/PageHeader/PageHeader.tsx +2 -1
- package/src/components/PageHeader/index.ts +1 -0
- package/src/components/PageMetadata/PageMetadata.Item.stories.tsx +9 -0
- package/src/components/PageMetadata/index.ts +1 -0
- package/src/components/Pagination/index.ts +1 -0
- package/src/components/PhaseBanner/index.ts +1 -0
- package/src/components/Question/Question.stories.tsx +2 -3
- package/src/components/Question/Question.tsx +2 -2
- package/src/components/Question/index.ts +1 -0
- package/src/components/RadioButton/RadioGroup.stories.tsx +1 -2
- package/src/components/RadioButton/RadioGroup.test.tsx +1 -2
- package/src/components/RadioButton/RadioGroup.tsx +2 -2
- package/src/components/RadioButton/index.ts +2 -0
- package/src/components/SearchFacets/SearchFacets.Group.stories.tsx +56 -0
- package/src/components/SearchFacets/SearchFacets.Item.stories.tsx +53 -0
- package/src/components/SearchFacets/SearchFacets.stories.tsx +38 -0
- package/src/components/SearchFacets/SearchFacets.test.tsx +214 -0
- package/src/components/SearchFacets/SearchFacets.tsx +99 -0
- package/src/components/SearchFacets/index.ts +1 -0
- package/src/components/SearchFilters/SearchFilters.Panel.stories.tsx +201 -0
- package/src/components/SearchFilters/SearchFilters.stories.tsx +137 -0
- package/src/components/SearchFilters/SearchFilters.test.tsx +161 -0
- package/src/components/SearchFilters/SearchFilters.tsx +89 -0
- package/src/components/SearchFilters/index.ts +1 -0
- package/src/components/SearchResult/SearchResult.stories.tsx +111 -0
- package/src/components/SearchResult/SearchResult.test.tsx +215 -0
- package/src/components/SearchResult/SearchResult.tsx +137 -0
- package/src/components/SearchResult/index.ts +1 -0
- package/src/components/SearchSort/SearchSort.stories.tsx +32 -0
- package/src/components/SearchSort/SearchSort.test.tsx +129 -0
- package/src/components/SearchSort/SearchSort.tsx +45 -0
- package/src/components/SearchSort/index.ts +1 -0
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Select/index.ts +1 -0
- package/src/components/SequentialNavigation/SequentialNavigation.Next.stories.tsx +1 -1
- package/src/components/SequentialNavigation/SequentialNavigation.Previous.stories.tsx +1 -1
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +0 -1
- package/src/components/SequentialNavigation/index.ts +1 -0
- package/src/components/SideNavigation/SideNavigation.Item.stories.tsx +9 -0
- package/src/components/SideNavigation/SideNavigation.List.stories.tsx +7 -0
- package/src/components/SideNavigation/SideNavigation.tsx +2 -1
- package/src/components/SideNavigation/index.ts +1 -0
- package/src/components/SiteFooter/SiteFooter.License.stories.tsx +7 -0
- package/src/components/SiteFooter/SiteFooter.Link.stories.tsx +9 -0
- package/src/components/SiteFooter/SiteFooter.Org.stories.tsx +7 -0
- package/src/components/SiteFooter/index.ts +1 -0
- package/src/components/SiteHeader/SiteHeader.stories.tsx +3 -3
- package/src/components/SiteHeader/SiteHeader.test.tsx +3 -3
- package/src/components/SiteHeader/SiteHeader.tsx +1 -3
- package/src/components/SiteHeader/index.ts +1 -0
- package/src/components/SiteNavigation/SiteNavigation.Item.stories.tsx +10 -0
- package/src/components/SiteNavigation/index.ts +1 -0
- package/src/components/SiteSearch/SiteSearch.tsx +1 -1
- package/src/components/SiteSearch/index.ts +1 -0
- package/src/components/SkipLinks/SkipLinks.Item.stories.tsx +11 -1
- package/src/components/SkipLinks/SkipLinks.tsx +10 -0
- package/src/components/SkipLinks/index.ts +1 -0
- package/src/components/SummaryCard/SummaryCard.Action.stories.tsx +7 -0
- package/src/components/SummaryCard/SummaryCard.stories.tsx +8 -1
- package/src/components/SummaryCard/SummaryCard.test.tsx +2 -2
- package/src/components/SummaryCard/index.ts +1 -0
- package/src/components/SummaryList/SummaryList.Item.stories.tsx +15 -0
- package/src/components/SummaryList/SummaryList.Value.stories.tsx +5 -2
- package/src/components/SummaryList/index.ts +1 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Tabs/Tabs.Item.stories.tsx +4 -1
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tag/index.ts +1 -0
- package/src/components/TaskList/TaskList.Group.stories.tsx +9 -0
- package/src/components/TaskList/TaskList.Item.stories.tsx +7 -0
- package/src/components/TaskList/TaskList.tsx +1 -1
- package/src/components/TaskList/index.ts +1 -0
- package/src/components/TextInput/TextInput.tsx +2 -2
- package/src/components/TextInput/index.ts +1 -0
- package/src/components/Textarea/Textarea.tsx +1 -1
- package/src/components/Textarea/index.ts +1 -0
- package/src/components/WarningText/index.ts +1 -0
- package/src/components/index.ts +46 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useTracking/index.ts +1 -0
- package/src/images/index.ts +2 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +14 -14
- package/vite.config.ts +2 -1
- /package/src/common/{ActionLink.test.tsx → ActionLink/ActionLink.test.tsx} +0 -0
- /package/src/common/{ActionLink.tsx → ActionLink/ActionLink.tsx} +0 -0
- /package/src/common/{ConditionalWrapper.test.tsx → ConditionalWrapper/ConditionalWrapper.test.tsx} +0 -0
- /package/src/common/{ConditionalWrapper.tsx → ConditionalWrapper/ConditionalWrapper.tsx} +0 -0
- /package/src/common/{FileIcon.test.tsx → FileIcon/FileIcon.test.tsx} +0 -0
- /package/src/common/{HintText.test.tsx → HintText/HintText.test.tsx} +0 -0
- /package/src/common/{HintText.tsx → HintText/HintText.tsx} +0 -0
- /package/src/common/{Icon.test.tsx → Icon/Icon.test.tsx} +0 -0
- /package/src/common/{ScreenReaderText.test.tsx → ScreenReaderText/ScreenReaderText.test.tsx} +0 -0
- /package/src/common/{ScreenReaderText.tsx → ScreenReaderText/ScreenReaderText.tsx} +0 -0
- /package/src/common/{WrapperTag.test.tsx → WrapperTag/WrapperTag.test.tsx} +0 -0
- /package/src/common/{WrapperTag.tsx → WrapperTag/WrapperTag.tsx} +0 -0
- /package/src/hooks/{useTracking.test.tsx → useTracking/useTracking.test.tsx} +0 -0
- /package/src/hooks/{useTracking.ts → useTracking/useTracking.ts} +0 -0
|
@@ -3,6 +3,7 @@ const PageHeader = ({
|
|
|
3
3
|
className,
|
|
4
4
|
label,
|
|
5
5
|
title,
|
|
6
|
+
titleId,
|
|
6
7
|
...props
|
|
7
8
|
}: SGDS.Component.PageHeader) => {
|
|
8
9
|
return (
|
|
@@ -14,7 +15,7 @@ const PageHeader = ({
|
|
|
14
15
|
{...props}
|
|
15
16
|
>
|
|
16
17
|
{label && <span className="ds_page-header__label ds_content-label">{label}</span>}
|
|
17
|
-
<h1 className="ds_page-header__title">{title}</h1>
|
|
18
|
+
<h1 id={titleId} className="ds_page-header__title">{title}</h1>
|
|
18
19
|
|
|
19
20
|
{children}
|
|
20
21
|
</header>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PageHeader';
|
|
@@ -6,6 +6,15 @@ import Metadata from './PageMetadata';
|
|
|
6
6
|
const meta = {
|
|
7
7
|
title: 'Components/PageMetadata/PageMetadata.Item',
|
|
8
8
|
component: Metadata.Item,
|
|
9
|
+
decorators: [
|
|
10
|
+
Story => (
|
|
11
|
+
<Metadata>
|
|
12
|
+
<dl className="ds_page-metadata__list">
|
|
13
|
+
<Story />
|
|
14
|
+
</dl>
|
|
15
|
+
</Metadata>
|
|
16
|
+
)
|
|
17
|
+
],
|
|
9
18
|
argTypes: {
|
|
10
19
|
children: argTypes.children(),
|
|
11
20
|
name: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PageMetadata';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Pagination';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PhaseBanner';
|
|
@@ -2,9 +2,8 @@ import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import argTypes from '../../../.storybook/sgdsArgTypes';
|
|
3
3
|
|
|
4
4
|
import Question from './Question';
|
|
5
|
-
import TextInput from '../TextInput
|
|
6
|
-
import Checkbox from '../Checkbox
|
|
7
|
-
import CheckboxGroup from '../Checkbox/CheckboxGroup';
|
|
5
|
+
import TextInput from '../TextInput';
|
|
6
|
+
import Checkbox, { CheckboxGroup } from '../Checkbox';
|
|
8
7
|
|
|
9
8
|
const meta = {
|
|
10
9
|
title: 'Components/Question',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ErrorMessage from '../ErrorMessage
|
|
2
|
-
import HintText from '../../common/HintText'
|
|
1
|
+
import ErrorMessage from '../ErrorMessage';
|
|
2
|
+
import HintText from '../../common/HintText'
|
|
3
3
|
import WrapperTag from '../../common/WrapperTag';
|
|
4
4
|
|
|
5
5
|
const Question = function ({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Question';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import argTypes from '../../../.storybook/sgdsArgTypes';
|
|
3
3
|
|
|
4
|
-
import RadioButton from '../RadioButton
|
|
5
|
-
import RadioGroup from './RadioGroup';
|
|
4
|
+
import RadioButton, { RadioGroup } from '../RadioButton';
|
|
6
5
|
|
|
7
6
|
const meta = {
|
|
8
7
|
title: 'Components/Radio/Radio group',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import RadioButton from '
|
|
4
|
-
import RadioGroup from './RadioGroup';
|
|
3
|
+
import RadioButton, { RadioGroup } from '../RadioButton';
|
|
5
4
|
|
|
6
5
|
test('radio group renders correctly', () => {
|
|
7
6
|
render(
|
|
@@ -6,7 +6,7 @@ const RadioGroup = ({
|
|
|
6
6
|
className,
|
|
7
7
|
isInline,
|
|
8
8
|
isSmall,
|
|
9
|
-
name,
|
|
9
|
+
name = '',
|
|
10
10
|
...props
|
|
11
11
|
}: SGDS.Component.RadioButton.Group) => {
|
|
12
12
|
return (
|
|
@@ -19,7 +19,7 @@ const RadioGroup = ({
|
|
|
19
19
|
].join(' ')}
|
|
20
20
|
{...props}
|
|
21
21
|
>
|
|
22
|
-
<CheckboxRadioContext value={{ isSmall: !!isSmall, name
|
|
22
|
+
<CheckboxRadioContext value={{ isSmall: !!isSmall, name}}>
|
|
23
23
|
{children}
|
|
24
24
|
</CheckboxRadioContext>
|
|
25
25
|
</div>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import argTypes from '../../../.storybook/sgdsArgTypes';
|
|
3
|
+
|
|
4
|
+
import Facets from './SearchFacets';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Components/Search results/Facets/Group',
|
|
9
|
+
component: Facets.Group,
|
|
10
|
+
decorators: [
|
|
11
|
+
(Story) => (
|
|
12
|
+
<div className="ds_facets">
|
|
13
|
+
<Story />
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
],
|
|
17
|
+
argTypes: {
|
|
18
|
+
children: argTypes.children(),
|
|
19
|
+
joinContent: {
|
|
20
|
+
description: 'Content to display between the facet items when there are multiple items in the group',
|
|
21
|
+
type: 'string'
|
|
22
|
+
},
|
|
23
|
+
title: {
|
|
24
|
+
description: 'Title of the facet group',
|
|
25
|
+
type: {
|
|
26
|
+
name: 'string',
|
|
27
|
+
required: true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
args: {
|
|
32
|
+
title: 'Content type'
|
|
33
|
+
}
|
|
34
|
+
} satisfies Meta<typeof Facets.Group>;
|
|
35
|
+
|
|
36
|
+
export default meta;
|
|
37
|
+
type Story = StoryObj<typeof meta>;
|
|
38
|
+
|
|
39
|
+
export const Default: Story = {
|
|
40
|
+
render: (args: any) => (
|
|
41
|
+
<Facets.Group {...args}>
|
|
42
|
+
<Facets.Item title="Advice and guidance" />
|
|
43
|
+
<Facets.Item title="Factsheet"/>
|
|
44
|
+
<Facets.Item title="Statistics" />
|
|
45
|
+
</Facets.Group>
|
|
46
|
+
)
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const CustomJoinContent: Story = {
|
|
50
|
+
render: (args: any) => (
|
|
51
|
+
<Facets.Group joinContent="and" title="Updated between">
|
|
52
|
+
<Facets.Item accessibleName="Updated after 01/10/2025" title="01/10/2025" />
|
|
53
|
+
<Facets.Item accessibleName="Updated before 31/10/2025" title="31/10/2025"/>
|
|
54
|
+
</Facets.Group>
|
|
55
|
+
)
|
|
56
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import Facets from './SearchFacets';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Search results/Facets/Item',
|
|
7
|
+
component: Facets.Item,
|
|
8
|
+
decorators: [
|
|
9
|
+
(Story) => (
|
|
10
|
+
<div className="ds_facets">
|
|
11
|
+
<Story />
|
|
12
|
+
</div>
|
|
13
|
+
)
|
|
14
|
+
],
|
|
15
|
+
argTypes: {
|
|
16
|
+
accessibleName: {
|
|
17
|
+
description: 'Accessible name for the facet button. If not provided, the title will be used. This content becomes part of the facet button\'s aria-label attribute.',
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
joinContent: {
|
|
21
|
+
description: 'Content to display before the facet button when there are multiple facets in a group. This should be provided to the parent Group instead.',
|
|
22
|
+
type: 'string'
|
|
23
|
+
},
|
|
24
|
+
onClick: {
|
|
25
|
+
description: 'Callback for when the facet button is clicked',
|
|
26
|
+
control: false
|
|
27
|
+
},
|
|
28
|
+
title: {
|
|
29
|
+
description: 'Text content of the facet button.',
|
|
30
|
+
type: {
|
|
31
|
+
name: 'string',
|
|
32
|
+
required: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
args: {
|
|
37
|
+
title: 'Advice and guidance'
|
|
38
|
+
}
|
|
39
|
+
} satisfies Meta<typeof Facets.Item>;
|
|
40
|
+
|
|
41
|
+
export default meta;
|
|
42
|
+
type Story = StoryObj<typeof meta>;
|
|
43
|
+
|
|
44
|
+
export const Default: Story = {
|
|
45
|
+
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const CustomAccessibleText: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
accessibleName: 'Updated before 31st October 2025',
|
|
51
|
+
title: '31/10/2025'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import argTypes from '../../../.storybook/sgdsArgTypes';
|
|
3
|
+
|
|
4
|
+
import Facets from './SearchFacets';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Search results/Facets',
|
|
8
|
+
component: Facets,
|
|
9
|
+
argTypes: {
|
|
10
|
+
children: argTypes.children()
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
title: 'Application incomplete'
|
|
14
|
+
}
|
|
15
|
+
} satisfies Meta<typeof Facets>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: (args: any) => (
|
|
22
|
+
<Facets {...args}>
|
|
23
|
+
<Facets.Group title="Content type">
|
|
24
|
+
<Facets.Item title="Advice and guidance" />
|
|
25
|
+
<Facets.Item title="Factsheet"/>
|
|
26
|
+
<Facets.Item title="Statistics" />
|
|
27
|
+
</Facets.Group>
|
|
28
|
+
<Facets.Group title="Topic">
|
|
29
|
+
<Facets.Item title="Children and families"/>
|
|
30
|
+
<Facets.Item title="Education"/>
|
|
31
|
+
</Facets.Group>
|
|
32
|
+
<Facets.Group title="Updated between" joinContent="and">
|
|
33
|
+
<Facets.Item accessibleName="Updated after 20/11/2023" title="20/11/2023"/>
|
|
34
|
+
<Facets.Item accessibleName="Updated before 02/04/2024" title="02/04/2024"/>
|
|
35
|
+
</Facets.Group>
|
|
36
|
+
</Facets>
|
|
37
|
+
)
|
|
38
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { test, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import Facets from './SearchFacets';
|
|
4
|
+
|
|
5
|
+
test('search facets boilerplate renders correctly', () => {
|
|
6
|
+
render(
|
|
7
|
+
<Facets data-testid="searchfacets"/>
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const facets = screen.getByTestId('searchfacets');
|
|
11
|
+
|
|
12
|
+
expect(facets).toBeInTheDocument();
|
|
13
|
+
expect(facets).toHaveClass('ds_facets');
|
|
14
|
+
expect(facets.tagName).toEqual('DIV');
|
|
15
|
+
|
|
16
|
+
const status = facets.querySelector('p');
|
|
17
|
+
expect(status).toBeInTheDocument();
|
|
18
|
+
expect(status).toHaveClass('visually-hidden');
|
|
19
|
+
expect(status?.textContent).toEqual('There are 0 search filters applied');
|
|
20
|
+
expect(status?.parentElement).toEqual(facets);
|
|
21
|
+
|
|
22
|
+
const list = facets.querySelector('dl');
|
|
23
|
+
expect(list).toBeInTheDocument();
|
|
24
|
+
expect(list).toHaveClass('ds_facets__list');
|
|
25
|
+
expect(list?.parentElement).toEqual(facets);
|
|
26
|
+
expect(list?.previousElementSibling).toEqual(status);
|
|
27
|
+
|
|
28
|
+
// clear button is not present if there are no facets
|
|
29
|
+
const clearButton = within(facets).queryByRole('button', { name: /clear all filters/i });
|
|
30
|
+
expect(clearButton).not.toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('search facets count with one facet', () => {
|
|
34
|
+
render(
|
|
35
|
+
<Facets data-testid="searchfacets">
|
|
36
|
+
<Facets.Item title="Facet 1" />
|
|
37
|
+
</Facets>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const facets = screen.getByTestId('searchfacets');
|
|
41
|
+
const status = within(facets).getByText('There is 1 search filter applied');
|
|
42
|
+
expect(status).toBeInTheDocument();
|
|
43
|
+
|
|
44
|
+
const clearButton = within(facets).getByRole('button', { name: /clear all filters/i });
|
|
45
|
+
expect(clearButton).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('search facets count with multiple facets', () => {
|
|
49
|
+
render(
|
|
50
|
+
<Facets data-testid="searchfacets">
|
|
51
|
+
<Facets.Item title="Facet 1" />
|
|
52
|
+
<Facets.Item title="Facet 2" />
|
|
53
|
+
</Facets>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const facets = screen.getByTestId('searchfacets');
|
|
57
|
+
const facetItems = facets.querySelectorAll('.ds_facet');
|
|
58
|
+
const status = within(facets).getByText(`There are ${facetItems.length} search filters applied`);
|
|
59
|
+
expect(status).toBeInTheDocument();
|
|
60
|
+
|
|
61
|
+
const clearButton = within(facets).getByRole('button', { name: /clear all filters/i });
|
|
62
|
+
expect(clearButton).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('search filters count with facet groups', () => {
|
|
66
|
+
render(
|
|
67
|
+
<Facets data-testid="searchfacets">
|
|
68
|
+
<Facets.Group title="Group 1">
|
|
69
|
+
<Facets.Item title="Facet 1" />
|
|
70
|
+
<Facets.Item title="Facet 2" />
|
|
71
|
+
</Facets.Group>
|
|
72
|
+
<Facets.Group title="Group 2">
|
|
73
|
+
<Facets.Item title="Facet 3" />
|
|
74
|
+
</Facets.Group>
|
|
75
|
+
</Facets>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const facets = screen.getByTestId('searchfacets');
|
|
79
|
+
const facetItems = facets.querySelectorAll('.ds_facet');
|
|
80
|
+
const status = within(facets).getByText(`There are ${facetItems.length} search filters applied`);
|
|
81
|
+
expect(status).toBeInTheDocument();
|
|
82
|
+
|
|
83
|
+
const clearButton = within(facets).getByRole('button', { name: /clear all filters/i });
|
|
84
|
+
expect(clearButton).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('search facet renders correctly', () => {
|
|
88
|
+
const FACET_TITLE = 'Facet 1';
|
|
89
|
+
|
|
90
|
+
render(
|
|
91
|
+
<Facets.Item title={FACET_TITLE} data-testid="searchfacet" />
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const facetWrapper = screen.getByTestId('searchfacet');
|
|
95
|
+
expect(facetWrapper).toBeInTheDocument();
|
|
96
|
+
expect(facetWrapper).toHaveClass('ds_facet-wrapper');
|
|
97
|
+
expect(facetWrapper.tagName).toEqual('DD');
|
|
98
|
+
|
|
99
|
+
const facetButton = within(facetWrapper).getByRole('button');
|
|
100
|
+
expect(facetButton).toHaveClass('ds_facet__button');
|
|
101
|
+
expect(facetButton).toHaveAttribute('aria-label', `Remove '${FACET_TITLE}' filter`);
|
|
102
|
+
|
|
103
|
+
const facet = facetButton.parentElement;
|
|
104
|
+
expect(facet).toHaveClass('ds_facet');
|
|
105
|
+
expect(facet?.textContent).toEqual(FACET_TITLE);
|
|
106
|
+
|
|
107
|
+
const facetIcon = within(facetButton).getByRole('img', { hidden: true });
|
|
108
|
+
expect(facetIcon).toHaveClass('ds_facet__button-icon');
|
|
109
|
+
expect(facetIcon).toHaveAttribute('aria-hidden', 'true');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('search facet with accessible name', () => {
|
|
113
|
+
const FACET_TITLE = 'Facet 1';
|
|
114
|
+
const ACCESSIBLE_NAME = 'Custom facet name';
|
|
115
|
+
|
|
116
|
+
render(
|
|
117
|
+
<Facets.Item title={FACET_TITLE} accessibleName={ACCESSIBLE_NAME} data-testid="searchfacet" />
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const facetWrapper = screen.getByTestId('searchfacet');
|
|
121
|
+
const facetButton = within(facetWrapper).getByRole('button');
|
|
122
|
+
expect(facetButton).toHaveAttribute('aria-label', `Remove '${ACCESSIBLE_NAME}' filter`);
|
|
123
|
+
|
|
124
|
+
const facet = facetButton.parentElement;
|
|
125
|
+
expect(facet).toHaveClass('ds_facet');
|
|
126
|
+
expect(facet?.textContent).toEqual(FACET_TITLE);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('facet button onClick works', async () => {
|
|
130
|
+
const FACET_TITLE = 'Facet 1';
|
|
131
|
+
const handleClick = vi.fn();
|
|
132
|
+
|
|
133
|
+
render(
|
|
134
|
+
<Facets.Item title={FACET_TITLE} onClick={handleClick} data-testid="searchfacet" />
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const facetWrapper = screen.getByTestId('searchfacet');
|
|
138
|
+
const facetButton = within(facetWrapper).getByRole('button');
|
|
139
|
+
|
|
140
|
+
await facetButton.click();
|
|
141
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('facet group renders correctly', () => {
|
|
145
|
+
const GROUP_TITLE = 'Group 1';
|
|
146
|
+
|
|
147
|
+
render(
|
|
148
|
+
<Facets.Group title={GROUP_TITLE} data-testid="searchfacetgroup">
|
|
149
|
+
<Facets.Item title="Facet 1" />
|
|
150
|
+
<Facets.Item title="Facet 2" />
|
|
151
|
+
</Facets.Group>
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const facetGroup = screen.getByTestId('searchfacetgroup');
|
|
155
|
+
expect(facetGroup).toBeInTheDocument();
|
|
156
|
+
expect(facetGroup).toHaveClass('ds_facet-group');
|
|
157
|
+
expect(facetGroup.tagName).toEqual('DIV');
|
|
158
|
+
|
|
159
|
+
const groupTitle = within(facetGroup).getByText(`${GROUP_TITLE}:`);
|
|
160
|
+
expect(groupTitle).toBeInTheDocument();
|
|
161
|
+
expect(groupTitle).toHaveClass('ds_facet__group-title');
|
|
162
|
+
|
|
163
|
+
const facetWrappers = facetGroup.querySelectorAll('.ds_facet-wrapper');
|
|
164
|
+
expect(facetWrappers.length).toEqual(2);
|
|
165
|
+
|
|
166
|
+
const firstFacet = facetWrappers[0];
|
|
167
|
+
expect(firstFacet?.textContent).toContain('Facet 1');
|
|
168
|
+
expect(firstFacet?.textContent).not.toContain('or');
|
|
169
|
+
|
|
170
|
+
const secondFacet = facetWrappers[1];
|
|
171
|
+
expect(secondFacet?.textContent).toContain('Facet 2');
|
|
172
|
+
expect(secondFacet?.textContent).toContain('or');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('facet group with custom join content', () => {
|
|
176
|
+
const GROUP_TITLE = 'Group 1';
|
|
177
|
+
const JOIN_CONTENT = 'and';
|
|
178
|
+
|
|
179
|
+
render(
|
|
180
|
+
<Facets.Group title={GROUP_TITLE} joinContent={JOIN_CONTENT} data-testid="searchfacetgroup">
|
|
181
|
+
<Facets.Item title="Facet 1" />
|
|
182
|
+
<Facets.Item title="Facet 2" />
|
|
183
|
+
</Facets.Group>
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const facetGroup = screen.getByTestId('searchfacetgroup');
|
|
187
|
+
const facetWrappers = facetGroup.querySelectorAll('.ds_facet-wrapper');
|
|
188
|
+
|
|
189
|
+
const firstFacet = facetWrappers[0];
|
|
190
|
+
expect(firstFacet?.textContent).toContain('Facet 1');
|
|
191
|
+
expect(firstFacet?.textContent).not.toContain(JOIN_CONTENT);
|
|
192
|
+
|
|
193
|
+
const secondFacet = facetWrappers[1];
|
|
194
|
+
expect(secondFacet?.textContent).toContain('Facet 2');
|
|
195
|
+
expect(secondFacet?.textContent).toContain(JOIN_CONTENT);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('passing additional props', () => {
|
|
199
|
+
render(
|
|
200
|
+
<Facets data-test="foo" data-testid="searchfacets"/>
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const searchFacets = screen.getByTestId('searchfacets');
|
|
204
|
+
expect(searchFacets?.dataset.test).toEqual('foo');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('passing additional CSS classes', () => {
|
|
208
|
+
render(
|
|
209
|
+
<Facets className="foo" data-testid="searchfacets"/>
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
const searchFacets = screen.getByTestId('searchfacets');
|
|
213
|
+
expect(searchFacets).toHaveClass('foo');
|
|
214
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { Children } from 'react';
|
|
2
|
+
import Icon from "../../common/Icon";
|
|
3
|
+
import { Cancel } from '../../../src/images/icons';
|
|
4
|
+
|
|
5
|
+
const FacetsItem = ({
|
|
6
|
+
accessibleName,
|
|
7
|
+
joinContent,
|
|
8
|
+
onClick,
|
|
9
|
+
title,
|
|
10
|
+
...props
|
|
11
|
+
}: SGDS.Component.SearchFacets.Item) => {
|
|
12
|
+
accessibleName = accessibleName ? accessibleName : title;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<dd className="ds_facet-wrapper" {...props}>
|
|
16
|
+
{joinContent &&
|
|
17
|
+
<span aria-hidden="true">{joinContent}</span>
|
|
18
|
+
}
|
|
19
|
+
<span className="ds_facet">
|
|
20
|
+
{title}
|
|
21
|
+
<button type="button" onClick={onClick} aria-label={`Remove '${accessibleName}' filter`} className="ds_facet__button">
|
|
22
|
+
<Icon className="ds_facet__button-icon" aria-hidden="true" role="img" icon="Cancel"/>
|
|
23
|
+
</button>
|
|
24
|
+
</span>
|
|
25
|
+
</dd>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const FacetsGroup = ({
|
|
30
|
+
children,
|
|
31
|
+
joinContent = 'or',
|
|
32
|
+
title,
|
|
33
|
+
...props
|
|
34
|
+
}: SGDS.Component.SearchFacets.Group) => {
|
|
35
|
+
return (
|
|
36
|
+
<div className="ds_facet-group" {...props}>
|
|
37
|
+
<dt className="ds_facet__group-title">
|
|
38
|
+
{title.trim()}:
|
|
39
|
+
</dt>
|
|
40
|
+
{
|
|
41
|
+
Children.map(children, (child, index) => {
|
|
42
|
+
const thisChild = child as React.ReactElement<SGDS.Component.SearchFacets.Item>
|
|
43
|
+
return React.cloneElement(thisChild, { joinContent: index > 0 ? joinContent : undefined, key: 'facet' + index });
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const Facets = ({
|
|
51
|
+
children,
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
}: SGDS.Component.SearchFacets) => {
|
|
55
|
+
let facetCount = 0;
|
|
56
|
+
|
|
57
|
+
function processChild(item: any) {
|
|
58
|
+
if (item.type.displayName === 'Facets.Item') {
|
|
59
|
+
facetCount = facetCount + 1;
|
|
60
|
+
|
|
61
|
+
} else if (item.type.displayName === 'Facets.Group') {
|
|
62
|
+
Children.forEach(item.props.children, child => {
|
|
63
|
+
processChild(child);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Children.forEach(children, child => {
|
|
69
|
+
processChild(child);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div className={[
|
|
74
|
+
"ds_facets",
|
|
75
|
+
className
|
|
76
|
+
].join(' ')}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
<p className="visually-hidden">There {facetCount === 1 ? 'is' : 'are'} {facetCount} search {facetCount === 1 ? 'filter' : 'filters'} applied</p>
|
|
80
|
+
<dl className="ds_facets__list">
|
|
81
|
+
{children}
|
|
82
|
+
</dl>
|
|
83
|
+
{facetCount > 0 &&
|
|
84
|
+
<button className="ds_button ds_button--secondary ds_button--has-icon ds_facets__clear-button" type="button">
|
|
85
|
+
Clear all filters
|
|
86
|
+
<Cancel className="ds_facet__button-icon"/>
|
|
87
|
+
</button>
|
|
88
|
+
}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Facets.displayName = 'Facets';
|
|
94
|
+
FacetsItem.displayName = 'Facets.Item';
|
|
95
|
+
FacetsGroup.displayName = 'Facets.Group';
|
|
96
|
+
Facets.Item = FacetsItem;
|
|
97
|
+
Facets.Group = FacetsGroup;
|
|
98
|
+
|
|
99
|
+
export default Facets;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SearchFacets';
|