@scottish-government/designsystem-react 0.12.1 → 1.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/.storybook/main.ts +6 -6
- package/.storybook/sgdsArgTypes.ts +107 -43
- package/CHANGELOG.md +49 -0
- package/LICENSE.txt +21 -0
- package/README.md +3 -0
- package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.d.ts +3 -2
- package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.jsx +8 -7
- package/dist/common/AbstractNotificationBanner/types.d.ts +13 -0
- package/dist/common/AbstractNotificationBanner/types.js +2 -0
- package/dist/common/ActionLink/ActionLink.d.ts +2 -1
- package/dist/common/ActionLink/types.d.ts +7 -0
- package/dist/common/ActionLink/types.js +2 -0
- package/dist/common/ConditionalWrapper/ConditionalWrapper.d.ts +2 -1
- package/dist/common/ConditionalWrapper/ConditionalWrapper.jsx +4 -2
- package/dist/common/ConditionalWrapper/types.d.ts +4 -0
- package/dist/common/ConditionalWrapper/types.js +2 -0
- package/dist/common/FileIcon/FileIcon.d.ts +2 -1
- package/dist/common/FileIcon/types.d.ts +6 -0
- package/dist/common/FileIcon/types.js +2 -0
- package/dist/common/HintText/HintText.d.ts +2 -1
- package/dist/common/HintText/HintText.jsx +3 -3
- package/dist/common/HintText/types.d.ts +4 -0
- package/dist/common/HintText/types.js +2 -0
- package/dist/common/Icon/Icon.d.ts +2 -1
- package/dist/common/Icon/Icon.jsx +3 -2
- package/dist/common/Icon/types.d.ts +8 -0
- package/dist/common/Icon/types.js +2 -0
- package/dist/common/ScreenReaderText/ScreenReaderText.d.ts +1 -1
- package/dist/common/WrapperTag/WrapperTag.d.ts +385 -1
- package/dist/common/WrapperTag/WrapperTag.jsx +5 -2
- package/dist/common/WrapperTag/types.d.ts +3 -0
- package/dist/common/WrapperTag/types.js +2 -0
- package/dist/components/Accordion/Accordion.d.ts +3 -2
- package/dist/components/Accordion/Accordion.jsx +12 -11
- package/dist/components/Accordion/types.d.ts +11 -0
- package/dist/components/Accordion/types.js +2 -0
- package/dist/components/AspectBox/AspectBox.d.ts +2 -1
- package/dist/components/AspectBox/AspectBox.jsx +3 -9
- package/dist/components/AspectBox/types.d.ts +3 -0
- package/dist/components/AspectBox/types.js +2 -0
- package/dist/components/BackToTop/BackToTop.d.ts +2 -1
- package/dist/components/BackToTop/BackToTop.jsx +4 -3
- package/dist/components/BackToTop/types.d.ts +3 -0
- package/dist/components/BackToTop/types.js +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +6 -2
- package/dist/components/Breadcrumbs/types.d.ts +5 -0
- package/dist/components/Breadcrumbs/types.js +2 -0
- package/dist/components/Button/Button.d.ts +2 -1
- package/dist/components/Button/Button.jsx +4 -3
- package/dist/components/Button/ButtonGroup.d.ts +2 -1
- package/dist/components/Button/ButtonGroup.jsx +9 -4
- package/dist/components/Button/types.d.ts +20 -0
- package/dist/components/Button/types.js +2 -0
- package/dist/components/Card/Card.d.ts +34 -0
- package/dist/components/Card/Card.jsx +118 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Card/index.js +8 -0
- package/dist/components/Card/types.d.ts +26 -0
- package/dist/components/Card/types.js +2 -0
- package/dist/components/CategoryItem/CategoryItem.d.ts +2 -1
- package/dist/components/CategoryItem/CategoryItem.jsx +8 -5
- package/dist/components/CategoryItem/types.d.ts +9 -0
- package/dist/components/CategoryItem/types.js +2 -0
- package/dist/components/CategoryList/CategoryList.d.ts +2 -1
- package/dist/components/CategoryList/CategoryList.jsx +3 -2
- package/dist/components/CategoryList/types.d.ts +5 -0
- package/dist/components/CategoryList/types.js +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +2 -1
- package/dist/components/Checkbox/Checkbox.jsx +4 -3
- package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/components/Checkbox/CheckboxGroup.jsx +5 -4
- package/dist/components/Checkbox/types.d.ts +7 -0
- package/dist/components/Checkbox/types.js +2 -0
- package/dist/components/ConfirmationMessage/ConfirmationMessage.d.ts +2 -1
- package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +3 -2
- package/dist/components/ConfirmationMessage/types.d.ts +6 -0
- package/dist/components/ConfirmationMessage/types.js +2 -0
- package/dist/components/ContentsNav/ContentsNav.d.ts +3 -2
- package/dist/components/ContentsNav/ContentsNav.jsx +7 -5
- package/dist/components/ContentsNav/types.d.ts +9 -0
- package/dist/components/ContentsNav/types.js +2 -0
- package/dist/components/CookieBanner/CookieBanner.d.ts +3 -2
- package/dist/components/CookieBanner/CookieBanner.jsx +13 -3
- package/dist/components/DatePicker/DatePicker.d.ts +2 -1
- package/dist/components/DatePicker/DatePicker.jsx +7 -7
- package/dist/components/DatePicker/types.d.ts +18 -0
- package/dist/components/DatePicker/types.js +2 -0
- package/dist/components/Details/Details.d.ts +2 -1
- package/dist/components/Details/Details.jsx +6 -2
- package/dist/components/Details/types.d.ts +4 -0
- package/dist/components/Details/types.js +2 -0
- package/dist/components/ErrorMessage/ErrorMessage.d.ts +2 -1
- package/dist/components/ErrorMessage/ErrorMessage.jsx +6 -2
- package/dist/components/ErrorMessage/types.d.ts +3 -0
- package/dist/components/ErrorMessage/types.js +2 -0
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +3 -2
- package/dist/components/ErrorSummary/ErrorSummary.jsx +6 -2
- package/dist/components/ErrorSummary/types.d.ts +8 -0
- package/dist/components/ErrorSummary/types.js +2 -0
- package/dist/components/FeatureHeader/FeatureHeader.d.ts +7 -5
- package/dist/components/FeatureHeader/FeatureHeader.jsx +87 -50
- package/dist/components/FeatureHeader/types.d.ts +12 -0
- package/dist/components/FeatureHeader/types.js +2 -0
- package/dist/components/FileDownload/FileDownload.d.ts +2 -1
- package/dist/components/FileDownload/FileDownload.jsx +4 -3
- package/dist/components/FileDownload/types.d.ts +10 -0
- package/dist/components/FileDownload/types.js +2 -0
- package/dist/components/HideThisPage/HideThisPage.d.ts +2 -1
- package/dist/components/HideThisPage/HideThisPage.jsx +5 -4
- package/dist/components/HideThisPage/types.d.ts +3 -0
- package/dist/components/HideThisPage/types.js +2 -0
- package/dist/components/InsetText/InsetText.d.ts +1 -1
- package/dist/components/InsetText/InsetText.jsx +6 -2
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +3 -2
- package/dist/components/NotificationBanner/NotificationBanner.jsx +5 -4
- package/dist/components/NotificationPanel/NotificationPanel.d.ts +2 -1
- package/dist/components/NotificationPanel/NotificationPanel.jsx +3 -2
- package/dist/components/NotificationPanel/types.d.ts +6 -0
- package/dist/components/NotificationPanel/types.js +2 -0
- package/dist/components/NotificationTag/NotificationTag.d.ts +6 -0
- package/dist/components/NotificationTag/NotificationTag.jsx +20 -0
- package/dist/components/NotificationTag/index.d.ts +1 -0
- package/dist/components/NotificationTag/index.js +8 -0
- package/dist/components/NotificationTag/types.d.ts +5 -0
- package/dist/components/NotificationTag/types.js +2 -0
- package/dist/components/PageHeader/PageHeader.d.ts +2 -1
- package/dist/components/PageHeader/PageHeader.jsx +6 -2
- package/dist/components/PageHeader/types.d.ts +5 -0
- package/dist/components/PageHeader/types.js +2 -0
- package/dist/components/PageMetadata/PageMetadata.d.ts +3 -2
- package/dist/components/PageMetadata/PageMetadata.jsx +8 -4
- package/dist/components/PageMetadata/types.d.ts +6 -0
- package/dist/components/PageMetadata/types.js +2 -0
- package/dist/components/Pagination/Pagination.d.ts +3 -2
- package/dist/components/Pagination/Pagination.jsx +7 -5
- package/dist/components/Pagination/types.d.ts +18 -0
- package/dist/components/Pagination/types.js +2 -0
- package/dist/components/PhaseBanner/PhaseBanner.d.ts +2 -1
- package/dist/components/PhaseBanner/PhaseBanner.jsx +3 -2
- package/dist/components/PhaseBanner/types.d.ts +3 -0
- package/dist/components/PhaseBanner/types.js +2 -0
- package/dist/components/Question/Question.d.ts +2 -1
- package/dist/components/Question/Question.jsx +4 -3
- package/dist/components/Question/types.d.ts +9 -0
- package/dist/components/Question/types.js +2 -0
- package/dist/components/RadioButton/RadioButton.d.ts +2 -1
- package/dist/components/RadioButton/RadioButton.jsx +4 -3
- package/dist/components/RadioButton/RadioGroup.d.ts +2 -1
- package/dist/components/RadioButton/RadioGroup.jsx +3 -2
- package/dist/components/RadioButton/types.d.ts +10 -0
- package/dist/components/RadioButton/types.js +2 -0
- package/dist/components/SearchFacets/SearchFacets.d.ts +4 -3
- package/dist/components/SearchFacets/SearchFacets.jsx +3 -2
- package/dist/components/SearchFacets/types.d.ts +12 -0
- package/dist/components/SearchFacets/types.js +2 -0
- package/dist/components/SearchFilters/SearchFilters.d.ts +5 -4
- package/dist/components/SearchFilters/types.d.ts +12 -0
- package/dist/components/SearchFilters/types.js +2 -0
- package/dist/components/SearchResult/SearchResult.d.ts +8 -11
- package/dist/components/SearchResult/SearchResult.jsx +6 -7
- package/dist/components/SearchResult/types.d.ts +11 -0
- package/dist/components/SearchResult/types.js +2 -0
- package/dist/components/SearchSort/SearchSort.d.ts +2 -1
- package/dist/components/SearchSort/SearchSort.jsx +3 -2
- package/dist/components/SearchSort/types.d.ts +7 -0
- package/dist/components/SearchSort/types.js +2 -0
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.jsx +4 -3
- package/dist/components/Select/types.d.ts +6 -0
- package/dist/components/Select/types.js +2 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.d.ts +4 -3
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +10 -6
- package/dist/components/SequentialNavigation/types.d.ts +10 -0
- package/dist/components/SequentialNavigation/types.js +2 -0
- package/dist/components/SideNavigation/SideNavigation.d.ts +4 -3
- package/dist/components/SideNavigation/SideNavigation.jsx +10 -7
- package/dist/components/SideNavigation/types.d.ts +13 -0
- package/dist/components/SideNavigation/types.js +2 -0
- package/dist/components/SiteFooter/SiteFooter.d.ts +6 -5
- package/dist/components/SiteFooter/SiteFooter.jsx +4 -3
- package/dist/components/SiteFooter/types.d.ts +16 -0
- package/dist/components/SiteFooter/types.js +2 -0
- package/dist/components/SiteHeader/SiteHeader.d.ts +6 -5
- package/dist/components/SiteHeader/SiteHeader.jsx +1 -1
- package/dist/components/SiteHeader/types.d.ts +20 -0
- package/dist/components/SiteHeader/types.js +2 -0
- package/dist/components/SiteNavigation/SiteNavigation.d.ts +3 -2
- package/dist/components/SiteNavigation/SiteNavigation.jsx +12 -4
- package/dist/components/SiteNavigation/types.d.ts +9 -0
- package/dist/components/SiteNavigation/types.js +2 -0
- package/dist/components/SiteSearch/SiteSearch.d.ts +2 -1
- package/dist/components/SiteSearch/SiteSearch.jsx +12 -11
- package/dist/components/SiteSearch/types.d.ts +17 -0
- package/dist/components/SiteSearch/types.js +2 -0
- package/dist/components/SkipLinks/SkipLinks.d.ts +3 -2
- package/dist/components/SkipLinks/SkipLinks.jsx +4 -4
- package/dist/components/SkipLinks/types.d.ts +8 -0
- package/dist/components/SkipLinks/types.js +2 -0
- package/dist/components/SummaryCard/SummaryCard.d.ts +4 -2
- package/dist/components/SummaryCard/SummaryCard.jsx +5 -4
- package/dist/components/SummaryCard/types.d.ts +5 -0
- package/dist/components/SummaryCard/types.js +2 -0
- package/dist/components/SummaryList/SummaryList.d.ts +6 -4
- package/dist/components/SummaryList/SummaryList.jsx +5 -4
- package/dist/components/SummaryList/types.d.ts +6 -0
- package/dist/components/SummaryList/types.js +2 -0
- package/dist/components/Table/Table.d.ts +2 -1
- package/dist/components/Table/Table.jsx +5 -4
- package/dist/components/Table/types.d.ts +6 -0
- package/dist/components/Table/types.js +2 -0
- package/dist/components/Tabs/Tabs.d.ts +3 -2
- package/dist/components/Tabs/Tabs.jsx +6 -5
- package/dist/components/Tabs/types.d.ts +16 -0
- package/dist/components/Tabs/types.js +2 -0
- package/dist/components/Tag/Tag.d.ts +2 -1
- package/dist/components/Tag/Tag.jsx +7 -3
- package/dist/components/Tag/types.d.ts +4 -0
- package/dist/components/Tag/types.js +2 -0
- package/dist/components/TaskList/TaskList.d.ts +4 -3
- package/dist/components/TaskList/TaskList.jsx +11 -8
- package/dist/components/TaskList/types.d.ts +17 -0
- package/dist/components/TaskList/types.js +2 -0
- package/dist/components/TextInput/TextInput.d.ts +2 -1
- package/dist/components/TextInput/TextInput.jsx +10 -9
- package/dist/components/TextInput/types.d.ts +11 -0
- package/dist/components/TextInput/types.js +2 -0
- package/dist/components/Textarea/Textarea.d.ts +2 -1
- package/dist/components/Textarea/Textarea.jsx +6 -5
- package/dist/components/WarningText/WarningText.d.ts +1 -1
- package/dist/components/WarningText/WarningText.jsx +6 -2
- package/dist/hooks/useTracking/useTracking.js +0 -1
- package/eslint.config.mjs +32 -0
- package/package.json +12 -5
- package/src/common/AbstractNotificationBanner/AbstractNotificationBanner.tsx +13 -10
- package/src/common/AbstractNotificationBanner/types.ts +15 -0
- package/src/common/ActionLink/ActionLink.tsx +3 -1
- package/src/common/ActionLink/types.ts +8 -0
- package/src/common/ConditionalWrapper/ConditionalWrapper.tsx +10 -2
- package/src/common/ConditionalWrapper/types.ts +4 -0
- package/src/common/FileIcon/FileIcon.tsx +2 -1
- package/src/common/FileIcon/types.ts +7 -0
- package/src/common/HintText/HintText.test.tsx +3 -15
- package/src/common/HintText/HintText.tsx +4 -4
- package/src/common/HintText/types.ts +4 -0
- package/src/common/Icon/Icon.tsx +5 -3
- package/src/common/Icon/types.ts +9 -0
- package/src/common/ScreenReaderText/ScreenReaderText.tsx +1 -1
- package/src/common/WrapperTag/WrapperTag.tsx +5 -3
- package/src/common/WrapperTag/types.ts +3 -0
- package/src/components/Accordion/Accordion.Item.stories.tsx +1 -5
- package/src/components/Accordion/Accordion.stories.tsx +5 -5
- package/src/components/Accordion/Accordion.test.tsx +11 -0
- package/src/components/Accordion/Accordion.tsx +15 -13
- package/src/components/Accordion/types.ts +13 -0
- package/src/components/AspectBox/AspectBox.stories.tsx +1 -2
- package/src/components/AspectBox/AspectBox.tsx +8 -14
- package/src/components/AspectBox/types.ts +3 -0
- package/src/components/BackToTop/BackToTop.test.tsx +21 -1
- package/src/components/BackToTop/BackToTop.tsx +6 -4
- package/src/components/BackToTop/types.ts +3 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +7 -4
- package/src/components/Breadcrumbs/types.ts +6 -0
- package/src/components/Button/Button.tsx +6 -4
- package/src/components/Button/ButtonGroup.stories.tsx +22 -0
- package/src/components/Button/ButtonGroup.test.tsx +21 -0
- package/src/components/Button/ButtonGroup.tsx +9 -4
- package/src/components/Button/types.ts +22 -0
- package/src/components/Card/Card.stories.tsx +446 -0
- package/src/components/Card/Card.test.tsx +282 -0
- package/src/components/Card/Card.tsx +208 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Card/types.ts +30 -0
- package/src/components/CategoryItem/CategoryItem.tsx +10 -6
- package/src/components/CategoryItem/types.ts +10 -0
- package/src/components/CategoryList/CategoryList.tsx +7 -4
- package/src/components/CategoryList/types.ts +5 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +3 -3
- package/src/components/Checkbox/Checkbox.test.tsx +30 -0
- package/src/components/Checkbox/Checkbox.tsx +8 -7
- package/src/components/Checkbox/CheckboxGroup.test.tsx +10 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +7 -6
- package/src/components/Checkbox/types.ts +9 -0
- package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +5 -3
- package/src/components/ConfirmationMessage/types.ts +7 -0
- package/src/components/ContentsNav/ContentsNav.stories.tsx +5 -1
- package/src/components/ContentsNav/ContentsNav.tsx +11 -7
- package/src/components/ContentsNav/types.ts +11 -0
- package/src/components/CookieBanner/CookieBanner.Buttons.stories.tsx +3 -3
- package/src/components/CookieBanner/CookieBanner.stories.tsx +6 -6
- package/src/components/CookieBanner/CookieBanner.test.tsx +24 -1
- package/src/components/CookieBanner/CookieBanner.tsx +16 -5
- package/src/components/DatePicker/DatePicker.test.tsx +52 -19
- package/src/components/DatePicker/DatePicker.tsx +8 -8
- package/src/components/DatePicker/types.ts +19 -0
- package/src/components/Details/Details.stories.tsx +1 -1
- package/src/components/Details/Details.tsx +6 -3
- package/src/components/Details/types.ts +4 -0
- package/src/components/ErrorMessage/ErrorMessage.tsx +6 -3
- package/src/components/ErrorMessage/types.ts +3 -0
- package/src/components/ErrorSummary/ErrorSummary.test.tsx +1 -1
- package/src/components/ErrorSummary/ErrorSummary.tsx +6 -4
- package/src/components/ErrorSummary/types.ts +11 -0
- package/src/components/FeatureHeader/FeatureHeader.stories.tsx +186 -23
- package/src/components/FeatureHeader/FeatureHeader.test.tsx +298 -0
- package/src/components/FeatureHeader/FeatureHeader.tsx +83 -58
- package/src/components/FeatureHeader/types.ts +13 -0
- package/src/components/FileDownload/FileDownload.test.tsx +1 -5
- package/src/components/FileDownload/FileDownload.tsx +6 -4
- package/src/components/FileDownload/types.ts +11 -0
- package/src/components/HideThisPage/HideThisPage.test.tsx +12 -1
- package/src/components/HideThisPage/HideThisPage.tsx +7 -5
- package/src/components/HideThisPage/types.ts +3 -0
- package/src/components/InsetText/InsetText.tsx +5 -3
- package/src/components/NotificationBanner/NotificationBanner.stories.tsx +2 -2
- package/src/components/NotificationBanner/NotificationBanner.test.tsx +10 -0
- package/src/components/NotificationBanner/NotificationBanner.tsx +8 -6
- package/src/components/NotificationPanel/NotificationPanel.tsx +5 -3
- package/src/components/NotificationPanel/types.ts +7 -0
- package/src/components/NotificationTag/NotificationTag.stories.tsx +68 -0
- package/src/components/NotificationTag/NotificationTag.test.tsx +70 -0
- package/src/components/NotificationTag/NotificationTag.tsx +32 -0
- package/src/components/NotificationTag/index.ts +1 -0
- package/src/components/NotificationTag/types.ts +5 -0
- package/src/components/PageHeader/PageHeader.tsx +6 -3
- package/src/components/PageHeader/types.ts +5 -0
- package/src/components/PageMetadata/PageMetadata.stories.tsx +1 -1
- package/src/components/PageMetadata/PageMetadata.tsx +10 -7
- package/src/components/PageMetadata/types.ts +7 -0
- package/src/components/Pagination/Pagination.test.tsx +20 -0
- package/src/components/Pagination/Pagination.tsx +12 -8
- package/src/components/Pagination/types.ts +20 -0
- package/src/components/PhaseBanner/PhaseBanner.stories.tsx +1 -4
- package/src/components/PhaseBanner/PhaseBanner.tsx +5 -3
- package/src/components/PhaseBanner/types.ts +3 -0
- package/src/components/Question/Question.tsx +6 -4
- package/src/components/Question/types.ts +9 -0
- package/src/components/RadioButton/RadioButton.test.tsx +30 -0
- package/src/components/RadioButton/RadioButton.tsx +8 -7
- package/src/components/RadioButton/RadioGroup.tsx +5 -3
- package/src/components/RadioButton/types.ts +12 -0
- package/src/components/SearchFacets/SearchFacets.Group.stories.tsx +2 -3
- package/src/components/SearchFacets/SearchFacets.stories.tsx +2 -2
- package/src/components/SearchFacets/SearchFacets.tsx +10 -8
- package/src/components/SearchFacets/types.ts +14 -0
- package/src/components/SearchFilters/SearchFilters.Panel.stories.tsx +18 -7
- package/src/components/SearchFilters/SearchFilters.stories.tsx +1 -1
- package/src/components/SearchFilters/SearchFilters.tsx +4 -3
- package/src/components/SearchFilters/types.ts +14 -0
- package/src/components/SearchResult/SearchResult.stories.tsx +23 -23
- package/src/components/SearchResult/SearchResult.test.tsx +5 -4
- package/src/components/SearchResult/SearchResult.tsx +15 -15
- package/src/components/SearchResult/types.ts +13 -0
- package/src/components/SearchSort/SearchSort.stories.tsx +2 -1
- package/src/components/SearchSort/SearchSort.tsx +5 -3
- package/src/components/SearchSort/types.ts +7 -0
- package/src/components/Select/Select.test.tsx +42 -0
- package/src/components/Select/Select.tsx +8 -6
- package/src/components/Select/types.ts +7 -0
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +13 -10
- package/src/components/SequentialNavigation/types.ts +12 -0
- package/src/components/SideNavigation/SideNavigation.test.tsx +24 -0
- package/src/components/SideNavigation/SideNavigation.tsx +14 -10
- package/src/components/SideNavigation/types.ts +16 -0
- package/src/components/SiteFooter/SiteFooter.tsx +10 -8
- package/src/components/SiteFooter/types.ts +20 -0
- package/src/components/SiteHeader/SiteHeader.stories.tsx +4 -3
- package/src/components/SiteHeader/SiteHeader.test.tsx +29 -16
- package/src/components/SiteHeader/SiteHeader.tsx +10 -9
- package/src/components/SiteHeader/types.ts +22 -0
- package/src/components/SiteNavigation/SiteNavigation.test.tsx +16 -1
- package/src/components/SiteNavigation/SiteNavigation.tsx +13 -6
- package/src/components/SiteNavigation/types.ts +11 -0
- package/src/components/SiteSearch/SiteSearch.stories.tsx +4 -2
- package/src/components/SiteSearch/SiteSearch.test.tsx +22 -0
- package/src/components/SiteSearch/SiteSearch.tsx +15 -13
- package/src/components/SiteSearch/types.ts +19 -0
- package/src/components/SkipLinks/SkipLinks.stories.tsx +3 -3
- package/src/components/SkipLinks/SkipLinks.tsx +7 -7
- package/src/components/SkipLinks/types.ts +9 -0
- package/src/components/SummaryCard/SummaryCard.test.tsx +0 -11
- package/src/components/SummaryCard/SummaryCard.tsx +9 -6
- package/src/components/SummaryCard/types.ts +6 -0
- package/src/components/SummaryList/SummaryList.Item.stories.tsx +5 -5
- package/src/components/SummaryList/SummaryList.stories.tsx +1 -1
- package/src/components/SummaryList/SummaryList.test.tsx +1 -6
- package/src/components/SummaryList/SummaryList.tsx +11 -9
- package/src/components/SummaryList/types.ts +7 -0
- package/src/components/Table/Table.test.tsx +36 -0
- package/src/components/Table/Table.tsx +7 -5
- package/src/components/Table/types.ts +6 -0
- package/src/components/Tabs/Tabs.Item.stories.tsx +7 -7
- package/src/components/Tabs/Tabs.stories.tsx +3 -3
- package/src/components/Tabs/Tabs.test.tsx +14 -0
- package/src/components/Tabs/Tabs.tsx +12 -9
- package/src/components/Tabs/types.ts +19 -0
- package/src/components/Tag/Tag.tsx +7 -4
- package/src/components/Tag/types.ts +5 -0
- package/src/components/TaskList/TaskList.Group.stories.tsx +0 -5
- package/src/components/TaskList/TaskList.stories.tsx +0 -1
- package/src/components/TaskList/TaskList.tsx +17 -13
- package/src/components/TaskList/types.ts +20 -0
- package/src/components/TextInput/TextInput.test.tsx +53 -1
- package/src/components/TextInput/TextInput.tsx +17 -12
- package/src/components/TextInput/types.ts +12 -0
- package/src/components/Textarea/Textarea.test.tsx +53 -1
- package/src/components/Textarea/Textarea.tsx +10 -8
- package/src/components/WarningText/WarningText.tsx +5 -3
- package/src/hooks/useTracking/useTracking.test.tsx +5 -7
- package/src/hooks/useTracking/useTracking.ts +0 -1
- package/src/images/icons/arrow_upward.tsx +10 -10
- package/src/images/icons/calendar_today.tsx +10 -10
- package/src/images/icons/cancel.tsx +8 -8
- package/src/images/icons/check_circle.tsx +10 -10
- package/src/images/icons/chevron_left.tsx +10 -10
- package/src/images/icons/chevron_right.tsx +10 -10
- package/src/images/icons/close.tsx +10 -10
- package/src/images/icons/description.tsx +10 -10
- package/src/images/icons/double_chevron_left.tsx +8 -8
- package/src/images/icons/double_chevron_right.tsx +8 -8
- package/src/images/icons/error.tsx +10 -10
- package/src/images/icons/expand_less.tsx +10 -10
- package/src/images/icons/expand_more.tsx +10 -10
- package/src/images/icons/list.tsx +13 -13
- package/src/images/icons/menu.tsx +10 -10
- package/src/images/icons/priority_high.tsx +11 -11
- package/src/images/icons/search.tsx +10 -10
- package/src/shared-types.ts +40 -0
- package/static/images/illustration.svg +502 -0
- package/tsconfig.json +0 -3
- package/vite.config.ts +6 -1
- package/@types/common/AbstractNotificationBanner.d.ts +0 -17
- package/@types/common/ActionLink.d.ts +0 -8
- package/@types/common/ConditionalWrapper.d.ts +0 -6
- package/@types/common/FileIcon.d.ts +0 -7
- package/@types/common/HintText.d.ts +0 -6
- package/@types/common/Icon.d.ts +0 -9
- package/@types/common/ScreenReaderText.d.ts +0 -4
- package/@types/common/WrapperTag.d.ts +0 -5
- package/@types/components/Accordion.d.ts +0 -15
- package/@types/components/AspectBox.d.ts +0 -5
- package/@types/components/BackToTop.d.ts +0 -5
- package/@types/components/Breadcrumbs.d.ts +0 -11
- package/@types/components/Button.d.ts +0 -17
- package/@types/components/ButtonGroup.d.ts +0 -5
- package/@types/components/CategoryItem.d.ts +0 -10
- package/@types/components/CategoryList.d.ts +0 -7
- package/@types/components/Checkbox.d.ts +0 -11
- package/@types/components/ConfirmationMessage.d.ts +0 -7
- package/@types/components/ContentsNav.d.ts +0 -13
- package/@types/components/DatePicker.d.ts +0 -20
- package/@types/components/Details.d.ts +0 -6
- package/@types/components/ErrorMessage.d.ts +0 -5
- package/@types/components/ErrorSummary.d.ts +0 -12
- package/@types/components/FileDownload.d.ts +0 -11
- package/@types/components/HideThisPage.d.ts +0 -5
- package/@types/components/InsetText.d.ts +0 -5
- package/@types/components/Metadata.d.ts +0 -11
- package/@types/components/NotificationPanel.d.ts +0 -7
- package/@types/components/PageHeader.d.ts +0 -7
- package/@types/components/Pagination.d.ts +0 -22
- package/@types/components/PhaseBanner.d.ts +0 -5
- package/@types/components/Question.d.ts +0 -11
- package/@types/components/RadioButton.d.ts +0 -14
- package/@types/components/SearchFacets.d.ts +0 -18
- package/@types/components/SearchFilters.d.ts +0 -14
- package/@types/components/SearchResult.d.ts +0 -30
- package/@types/components/SearchSort.d.ts +0 -9
- package/@types/components/Select.d.ts +0 -7
- package/@types/components/SequentialNavigation.d.ts +0 -14
- package/@types/components/SideNavigation.d.ts +0 -18
- package/@types/components/SiteFooter.d.ts +0 -25
- package/@types/components/SiteHeader.d.ts +0 -20
- package/@types/components/SiteNavigation.d.ts +0 -13
- package/@types/components/SiteSearch.d.ts +0 -14
- package/@types/components/SkipLinks.d.ts +0 -13
- package/@types/components/SummaryCard.d.ts +0 -6
- package/@types/components/SummaryList.d.ts +0 -14
- package/@types/components/Table.d.ts +0 -8
- package/@types/components/Tabs.d.ts +0 -21
- package/@types/components/Tag.d.ts +0 -5
- package/@types/components/TaskList.d.ts +0 -22
- package/@types/components/TextInput.d.ts +0 -12
- package/@types/components/Textarea.d.ts +0 -4
- package/@types/components/WarningText.d.ts +0 -5
- package/@types/global.d.ts +0 -1
- package/@types/sgds.d.ts +0 -49
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -40
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React, { Children, useId } from 'react';
|
|
2
|
-
|
|
3
2
|
import ActionLink from '../../common/ActionLink';
|
|
4
3
|
import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
4
|
+
import { SummaryListItemProps, SummaryListProps } from './types';
|
|
5
|
+
import { ActionLinkProps } from '@/src/common/ActionLink/types';
|
|
6
|
+
import clsx from 'clsx';
|
|
5
7
|
|
|
6
8
|
const Item = ({
|
|
7
9
|
children,
|
|
8
10
|
title
|
|
9
|
-
}:
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}: SummaryListItemProps) => {
|
|
12
|
+
const values: React.ReactElement[] = [];
|
|
13
|
+
const actions: React.ReactElement[] = [];
|
|
12
14
|
|
|
13
15
|
const describedById = useId();
|
|
14
16
|
|
|
15
17
|
Children.forEach(children, (child: React.ReactNode) => {
|
|
16
|
-
const thisChild = child as React.ReactElement<
|
|
18
|
+
const thisChild = child as React.ReactElement<ActionLinkProps>;
|
|
17
19
|
if (thisChild && thisChild.type === Value) {
|
|
18
20
|
values.push(thisChild);
|
|
19
21
|
} else if (thisChild && thisChild.type === ActionLink) {
|
|
@@ -64,7 +66,7 @@ const Item = ({
|
|
|
64
66
|
|
|
65
67
|
const Value = ({
|
|
66
68
|
children
|
|
67
|
-
}:
|
|
69
|
+
}: React.AllHTMLAttributes<HTMLElement>) => {
|
|
68
70
|
return (
|
|
69
71
|
<q className="ds_summary-list__answer">{children}</q>
|
|
70
72
|
);
|
|
@@ -75,14 +77,14 @@ const SummaryList = ({
|
|
|
75
77
|
className,
|
|
76
78
|
isBorderless,
|
|
77
79
|
...props
|
|
78
|
-
}:
|
|
80
|
+
}: SummaryListProps) => {
|
|
79
81
|
return (
|
|
80
82
|
<ol
|
|
81
|
-
className={[
|
|
83
|
+
className={clsx([
|
|
82
84
|
'ds_summary-list',
|
|
83
85
|
isBorderless && 'ds_summary-list--no-border',
|
|
84
86
|
className
|
|
85
|
-
]
|
|
87
|
+
])}
|
|
86
88
|
{...props}
|
|
87
89
|
>
|
|
88
90
|
{children}
|
|
@@ -58,6 +58,42 @@ test('table with smallscreen behaviour', () => {
|
|
|
58
58
|
expect(table.nodeName).toEqual('TABLE');
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
test('instantiating/initialising DS component script: smallscreen', () => {
|
|
62
|
+
render(
|
|
63
|
+
<Table smallscreen="scrolling">
|
|
64
|
+
<caption>Public holidays in 2020</caption>
|
|
65
|
+
<thead>
|
|
66
|
+
<tr>
|
|
67
|
+
<th scope="col">Date</th>
|
|
68
|
+
<th scope="col">Day</th>
|
|
69
|
+
<th scope="col">Holiday</th>
|
|
70
|
+
</tr>
|
|
71
|
+
</thead>
|
|
72
|
+
<tbody>
|
|
73
|
+
<tr>
|
|
74
|
+
<td>10 April</td>
|
|
75
|
+
<td>Friday</td>
|
|
76
|
+
<td>Good Friday</td>
|
|
77
|
+
</tr>
|
|
78
|
+
</tbody>
|
|
79
|
+
</Table>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const table = screen.getByRole('table');
|
|
83
|
+
expect(table).toHaveClass('js-initialised');
|
|
84
|
+
expect(table).toHaveClass('js-instantiated');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('instantiating/initialising DS component script: not smallscreen', () => {
|
|
88
|
+
render(
|
|
89
|
+
<Table />
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const table = screen.getByRole('table');
|
|
93
|
+
expect(table).not.toHaveClass('js-initialised');
|
|
94
|
+
expect(table).not.toHaveClass('js-instantiated');
|
|
95
|
+
});
|
|
96
|
+
|
|
61
97
|
test('passing additional props', () => {
|
|
62
98
|
render(
|
|
63
99
|
<Table data-test="foo"/>
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
// @ts-ignore
|
|
3
2
|
import DSTable from '@scottish-government/design-system/src/components/table/table';
|
|
3
|
+
import { TableProps } from './types';
|
|
4
|
+
import clsx from 'clsx';
|
|
4
5
|
|
|
5
6
|
const Table = ({
|
|
6
7
|
children,
|
|
7
8
|
className,
|
|
8
9
|
smallscreen,
|
|
9
10
|
...props
|
|
10
|
-
}:
|
|
11
|
+
}: TableProps) => {
|
|
11
12
|
const ref = useRef(null);
|
|
12
13
|
|
|
13
14
|
useEffect(() => {
|
|
15
|
+
/* istanbul ignore else */
|
|
14
16
|
if (ref.current) {
|
|
15
|
-
new DSTable().init();
|
|
17
|
+
new DSTable(ref.current).init();
|
|
16
18
|
}
|
|
17
19
|
}, [ref]);
|
|
18
20
|
|
|
19
21
|
return (
|
|
20
22
|
<table
|
|
21
|
-
className={[
|
|
23
|
+
className={clsx([
|
|
22
24
|
'ds_table',
|
|
23
25
|
className
|
|
24
|
-
]
|
|
26
|
+
])}
|
|
25
27
|
data-smallscreen={smallscreen}
|
|
26
28
|
ref={ref}
|
|
27
29
|
{...props}
|
|
@@ -17,15 +17,15 @@ const meta = {
|
|
|
17
17
|
children: argTypes.children()
|
|
18
18
|
},
|
|
19
19
|
args: {
|
|
20
|
-
baseId: 'my-tabs',
|
|
21
20
|
children: [
|
|
22
|
-
<h3>Search for training courses and funding</h3>,
|
|
23
|
-
<p>A wide range of training courses for your employees are available.</p>,
|
|
24
|
-
<p>Opportunities include distance learning, short courses and vocational training.</p>,
|
|
25
|
-
<p><a href="#">Visit My World of Work to search for training courses</a>.</p>,
|
|
26
|
-
<p>You can also <a href="#">search for training courses, and funding towards training</a>.</p>
|
|
21
|
+
<h3 key="1">Search for training courses and funding</h3>,
|
|
22
|
+
<p key="2">A wide range of training courses for your employees are available.</p>,
|
|
23
|
+
<p key="3">Opportunities include distance learning, short courses and vocational training.</p>,
|
|
24
|
+
<p key="4"><a href="#">Visit My World of Work to search for training courses</a>.</p>,
|
|
25
|
+
<p key="5">You can also <a href="#">search for training courses, and funding towards training</a>.</p>
|
|
27
26
|
],
|
|
28
|
-
tabLabel: 'Courses and funding'
|
|
27
|
+
tabLabel: 'Courses and funding',
|
|
28
|
+
id: 'my-tab'
|
|
29
29
|
}
|
|
30
30
|
} satisfies Meta<typeof Tabs.Item>;
|
|
31
31
|
|
|
@@ -35,14 +35,14 @@ const meta = {
|
|
|
35
35
|
args: {
|
|
36
36
|
baseId: 'my-tabs',
|
|
37
37
|
children: [
|
|
38
|
-
<Tabs.Item key="foo" tabLabel="Courses and funding">
|
|
38
|
+
<Tabs.Item id="foo" key="foo" tabLabel="Courses and funding">
|
|
39
39
|
<h3>Search for training courses and funding</h3>
|
|
40
40
|
<p>A wide range of training courses for your employees are available.</p>
|
|
41
41
|
<p>Opportunities include distance learning, short courses and vocational training.</p>
|
|
42
42
|
<p><a href="#">Visit My World of Work to search for training courses</a>.</p>
|
|
43
43
|
<p>You can also <a href="#">search for training courses, and funding towards training</a>.</p>
|
|
44
44
|
</Tabs.Item>,
|
|
45
|
-
<Tabs.Item key="bar" tabLabel="Choosing apprenticeships">
|
|
45
|
+
<Tabs.Item id="bar" key="bar" tabLabel="Choosing apprenticeships">
|
|
46
46
|
<h3>Choosing an apprenticeship for your business</h3>
|
|
47
47
|
<p>Apprenticeships can help you address skills gaps in your business. The government provides help with the cost of training an apprentice.</p>
|
|
48
48
|
<p>There are 3 different types of apprenticeship:</p>
|
|
@@ -53,7 +53,7 @@ const meta = {
|
|
|
53
53
|
</ul>
|
|
54
54
|
<p>You can find more information on the <a href="#">apprenticeships.scot</a> website.</p>
|
|
55
55
|
</Tabs.Item>,
|
|
56
|
-
<Tabs.Item key="baz" tabLabel="Extra skills support">
|
|
56
|
+
<Tabs.Item id="baz" key="baz" tabLabel="Extra skills support">
|
|
57
57
|
<h3>Extra skills support</h3>
|
|
58
58
|
<p>The <a href="#">Skills for Growth</a> service can offer skills advice to businesses with fewer than 250 employees.</p>
|
|
59
59
|
<p>Businesses of any size can get skills advice by completing a <a href="#">skills support request form</a>.</p>
|
|
@@ -187,6 +187,20 @@ test('with manual activation', () => {
|
|
|
187
187
|
expect(tabContainer).toHaveClass('ds_tabs--manual');
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
+
test('instantiating/initialising DS component script', () => {
|
|
191
|
+
render(
|
|
192
|
+
<Tabs data-testid="tabcontainer" data-test="foo">
|
|
193
|
+
<Tabs.Item tabLabel="Tab 1" data-testid="tabpanel1">
|
|
194
|
+
<div data-testid="tabpanel1content">Content one</div>
|
|
195
|
+
</Tabs.Item>
|
|
196
|
+
</Tabs>
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const tabContainer = screen.getByTestId('tabcontainer');
|
|
200
|
+
expect(tabContainer).toHaveClass('js-initialised');
|
|
201
|
+
expect(tabContainer).toHaveClass('js-instantiated');
|
|
202
|
+
});
|
|
203
|
+
|
|
190
204
|
test('passing additional props to tab container', () => {
|
|
191
205
|
render(
|
|
192
206
|
<Tabs data-testid="tabcontainer" data-test="foo">
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { Children, useEffect, useRef, useId } from 'react';
|
|
2
2
|
import WrapperTag from '../../common/WrapperTag';
|
|
3
|
-
// @ts-ignore
|
|
4
3
|
import DSTabs from '@scottish-government/design-system/src/components/tabs/tabs';
|
|
4
|
+
import { TabListItemProps, TabsItemProps, TabsProps } from './types';
|
|
5
|
+
import clsx from 'clsx';
|
|
5
6
|
|
|
6
7
|
const TabItem = ({
|
|
7
8
|
isBorderless,
|
|
@@ -10,14 +11,15 @@ const TabItem = ({
|
|
|
10
11
|
id,
|
|
11
12
|
tabLabel,
|
|
12
13
|
...props
|
|
13
|
-
}:
|
|
14
|
+
}: TabsItemProps) => {
|
|
14
15
|
return (
|
|
15
16
|
<div
|
|
16
|
-
className={[
|
|
17
|
+
className={clsx([
|
|
17
18
|
'ds_tabs__content',
|
|
18
19
|
!isBorderless && 'ds_tabs__content--bordered',
|
|
19
20
|
className
|
|
20
|
-
]
|
|
21
|
+
])}
|
|
22
|
+
data-label={tabLabel}
|
|
21
23
|
id={id}
|
|
22
24
|
{...props}
|
|
23
25
|
>
|
|
@@ -29,7 +31,7 @@ const TabItem = ({
|
|
|
29
31
|
const TabListItem = ({
|
|
30
32
|
children,
|
|
31
33
|
href
|
|
32
|
-
}:
|
|
34
|
+
}: TabListItemProps) => {
|
|
33
35
|
return (
|
|
34
36
|
<li className="ds_tabs__tab">
|
|
35
37
|
<a className="ds_tabs__tab-link" href={href}>{children}</a>
|
|
@@ -46,19 +48,20 @@ const Tabs = ({
|
|
|
46
48
|
isManual = false,
|
|
47
49
|
title = 'Contents',
|
|
48
50
|
...props
|
|
49
|
-
}:
|
|
51
|
+
}: TabsProps) => {
|
|
50
52
|
const ref = useRef(null);
|
|
51
53
|
|
|
52
54
|
const headingId = `${baseId}-heading`;
|
|
53
55
|
|
|
54
56
|
useEffect(() => {
|
|
57
|
+
/* istanbul ignore else */
|
|
55
58
|
if (ref.current) {
|
|
56
59
|
new DSTabs(ref.current).init();
|
|
57
60
|
}
|
|
58
61
|
}, [ref]);
|
|
59
62
|
|
|
60
63
|
const processedItems = Children.map(children, child => {
|
|
61
|
-
const thisChild = child as React.ReactElement<
|
|
64
|
+
const thisChild = child as React.ReactElement<TabsItemProps>;
|
|
62
65
|
|
|
63
66
|
if (thisChild && thisChild.type === TabItem) {
|
|
64
67
|
return React.cloneElement(thisChild, {
|
|
@@ -76,11 +79,11 @@ const Tabs = ({
|
|
|
76
79
|
|
|
77
80
|
return (
|
|
78
81
|
<div
|
|
79
|
-
className={[
|
|
82
|
+
className={clsx([
|
|
80
83
|
'ds_tabs',
|
|
81
84
|
isManual && 'ds_tabs--manual',
|
|
82
85
|
className
|
|
83
|
-
]
|
|
86
|
+
])}
|
|
84
87
|
ref={ref}
|
|
85
88
|
{...props}
|
|
86
89
|
>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HeadingLevel } from '../../shared-types';
|
|
2
|
+
|
|
3
|
+
export interface TabsItemProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
+
isBorderless?: boolean;
|
|
5
|
+
id: string;
|
|
6
|
+
tabLabel: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TabListItemProps extends React.AllHTMLAttributes<HTMLLIElement> {
|
|
10
|
+
href: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TabsProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
14
|
+
baseId: string;
|
|
15
|
+
isBorderless?: boolean;
|
|
16
|
+
headingLevel?: HeadingLevel;
|
|
17
|
+
isManual?: boolean;
|
|
18
|
+
title: string;
|
|
19
|
+
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { TagProps } from "./types";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
|
|
1
4
|
const Tag = ({
|
|
2
5
|
children,
|
|
3
6
|
className,
|
|
4
7
|
colour,
|
|
5
8
|
...props
|
|
6
|
-
}:
|
|
9
|
+
}: TagProps) => {
|
|
7
10
|
return (
|
|
8
11
|
<span
|
|
9
|
-
className={[
|
|
12
|
+
className={clsx([
|
|
10
13
|
'ds_tag',
|
|
11
14
|
className,
|
|
12
|
-
colour && `ds_tag--${colour}
|
|
13
|
-
]
|
|
15
|
+
colour && `ds_tag--${colour}`
|
|
16
|
+
])}
|
|
14
17
|
{...props}
|
|
15
18
|
>
|
|
16
19
|
{children}
|
|
@@ -3,6 +3,8 @@ import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
|
3
3
|
import HintText from '../../common/HintText';
|
|
4
4
|
import ScreenReaderText from '../../common/ScreenReaderText';
|
|
5
5
|
import Tag from '../Tag';
|
|
6
|
+
import { TaskListGroupProps, TaskListItemProps, TaskListProps } from './types';
|
|
7
|
+
import clsx from 'clsx';
|
|
6
8
|
|
|
7
9
|
const TaskItem = ({
|
|
8
10
|
children,
|
|
@@ -15,7 +17,7 @@ const TaskItem = ({
|
|
|
15
17
|
tagColour = 'grey',
|
|
16
18
|
title,
|
|
17
19
|
...props
|
|
18
|
-
}:
|
|
20
|
+
}: TaskListItemProps) => {
|
|
19
21
|
if (isComplete) {
|
|
20
22
|
tagColour = 'green';
|
|
21
23
|
statusText = statusText || 'Completed'
|
|
@@ -24,19 +26,21 @@ const TaskItem = ({
|
|
|
24
26
|
const LINK_CLASS = 'ds_task-list__task-link';
|
|
25
27
|
|
|
26
28
|
function getLinkElement(children: React.ReactNode) {
|
|
29
|
+
let linkElement;
|
|
27
30
|
if (linkComponent) {
|
|
28
|
-
|
|
29
|
-
} else
|
|
30
|
-
|
|
31
|
+
linkElement = linkComponent({ className: LINK_CLASS, href, children });
|
|
32
|
+
} else {
|
|
33
|
+
linkElement = <a href={href} className={LINK_CLASS}>{children}</a>;
|
|
31
34
|
}
|
|
35
|
+
return linkElement as React.JSX.Element;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
return (
|
|
35
39
|
<li
|
|
36
|
-
className={[
|
|
40
|
+
className={clsx([
|
|
37
41
|
'ds_task-list__task',
|
|
38
42
|
className
|
|
39
|
-
]
|
|
43
|
+
])}
|
|
40
44
|
id={id}
|
|
41
45
|
{...props}
|
|
42
46
|
>
|
|
@@ -77,13 +81,13 @@ const TaskGroup = ({
|
|
|
77
81
|
intro,
|
|
78
82
|
title,
|
|
79
83
|
...props
|
|
80
|
-
}:
|
|
84
|
+
}: TaskListGroupProps) => {
|
|
81
85
|
return (
|
|
82
86
|
<li
|
|
83
|
-
className={[
|
|
87
|
+
className={clsx([
|
|
84
88
|
'ds_task-list-group__section',
|
|
85
89
|
className
|
|
86
|
-
]
|
|
90
|
+
])}
|
|
87
91
|
{...props}
|
|
88
92
|
>
|
|
89
93
|
<h2 className="ds_task-list-heading">{title}</h2>
|
|
@@ -101,12 +105,12 @@ const TaskList = ({
|
|
|
101
105
|
headingId = 'task-list',
|
|
102
106
|
title,
|
|
103
107
|
...props
|
|
104
|
-
}:
|
|
108
|
+
}: TaskListProps) => {
|
|
105
109
|
let taskCount = 0;
|
|
106
|
-
|
|
110
|
+
const incompleteTaskIds: string[] = [];
|
|
107
111
|
let completedTasksCount = 0;
|
|
108
112
|
|
|
109
|
-
function processChild(item:
|
|
113
|
+
function processChild(item: React.JSX.Element) {
|
|
110
114
|
if (item.type.displayName === 'TaskList.Item') {
|
|
111
115
|
taskCount = taskCount + 1;
|
|
112
116
|
|
|
@@ -131,7 +135,7 @@ const TaskList = ({
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
Children.forEach(children, child => {
|
|
134
|
-
processChild(child);
|
|
138
|
+
processChild(child as React.JSX.Element);
|
|
135
139
|
});
|
|
136
140
|
|
|
137
141
|
return (
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LinkComponent, TagColour } from '../../shared-types';
|
|
2
|
+
|
|
3
|
+
export interface TaskListGroupProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
+
intro?: string;
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TaskListItemProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
9
|
+
href?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
isComplete?: boolean;
|
|
12
|
+
linkComponent?: LinkComponent;
|
|
13
|
+
statusText?: string;
|
|
14
|
+
tagColour?: TagColour;
|
|
15
|
+
title: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TaskListProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
19
|
+
headingId?: string;
|
|
20
|
+
}
|
|
@@ -58,7 +58,6 @@ test('text input with character count', () => {
|
|
|
58
58
|
const textInput = screen.getByRole('textbox');
|
|
59
59
|
const textInputWrapper = textInput.parentElement;
|
|
60
60
|
|
|
61
|
-
expect(textInputWrapper).toHaveAttribute('data-maxlength', MAX_LENGTH.toString());
|
|
62
61
|
expect(textInputWrapper).toHaveAttribute('data-module', 'ds-character-count');
|
|
63
62
|
});
|
|
64
63
|
|
|
@@ -232,6 +231,44 @@ test('text input with change function', () => {
|
|
|
232
231
|
expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
|
|
233
232
|
});
|
|
234
233
|
|
|
234
|
+
test('text input with onBlur that is not a function', () => {
|
|
235
|
+
render(
|
|
236
|
+
<TextInput
|
|
237
|
+
id={INPUT_ID}
|
|
238
|
+
label={LABEL_TEXT}
|
|
239
|
+
// @ts-expect-error onBlur is not a function
|
|
240
|
+
onBlur='foo'
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
const textInput = screen.getByRole('textbox');
|
|
245
|
+
|
|
246
|
+
fireEvent.blur(textInput);
|
|
247
|
+
|
|
248
|
+
// todo: assertion
|
|
249
|
+
// success indicated by no errors thrown
|
|
250
|
+
// error would be thrown on an untestable thread
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('text input with onChange that is not a function', () => {
|
|
254
|
+
render(
|
|
255
|
+
<TextInput
|
|
256
|
+
id={INPUT_ID}
|
|
257
|
+
label={LABEL_TEXT}
|
|
258
|
+
// @ts-expect-error onChange is not a function
|
|
259
|
+
onChange='foo'
|
|
260
|
+
/>
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
const textInput = screen.getByRole('textbox');
|
|
264
|
+
|
|
265
|
+
fireEvent.change(textInput, {target: {value: 'foo'}});
|
|
266
|
+
|
|
267
|
+
// todo: assertion
|
|
268
|
+
// success indicated by no errors thrown
|
|
269
|
+
// error would be thrown on an untestable thread
|
|
270
|
+
});
|
|
271
|
+
|
|
235
272
|
test('text input with placeholder text', () => {
|
|
236
273
|
const PLACEHOLDER_TEXT = 'foo';
|
|
237
274
|
|
|
@@ -299,6 +336,21 @@ test('text input with error message', () => {
|
|
|
299
336
|
expect(errorMessageElement).toHaveClass('ds_question__error-message');
|
|
300
337
|
});
|
|
301
338
|
|
|
339
|
+
test('instantiating/initialising DS component script', () => {
|
|
340
|
+
render(
|
|
341
|
+
<TextInput
|
|
342
|
+
id={INPUT_ID}
|
|
343
|
+
label={LABEL_TEXT}
|
|
344
|
+
maxlength={200}
|
|
345
|
+
/>
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
const textInput = screen.getByRole('textbox');
|
|
349
|
+
const textInputContainer = textInput.parentElement;
|
|
350
|
+
expect(textInputContainer).toHaveClass('js-initialised');
|
|
351
|
+
expect(textInputContainer).toHaveClass('js-instantiated');
|
|
352
|
+
});
|
|
353
|
+
|
|
302
354
|
test('passing additional props', () => {
|
|
303
355
|
render(
|
|
304
356
|
<TextInput
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import DSCharacterCount from '@scottish-government/design-system/src/forms/character-count/character-count';
|
|
2
|
+
import DSCharacterCount from '@scottish-government/design-system/src/components/character-count/character-count';
|
|
4
3
|
import Button from '../Button';
|
|
5
4
|
import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
6
5
|
import ErrorMessage from '../ErrorMessage';
|
|
7
6
|
import HintText from '../../common/HintText';
|
|
7
|
+
import { TextInputProps } from './types';
|
|
8
|
+
import clsx from 'clsx';
|
|
8
9
|
|
|
9
10
|
const TextInput = ({
|
|
10
11
|
buttonIcon,
|
|
11
12
|
buttonText,
|
|
12
|
-
children,
|
|
13
13
|
className,
|
|
14
14
|
countThreshold,
|
|
15
15
|
width,
|
|
@@ -29,29 +29,34 @@ const TextInput = ({
|
|
|
29
29
|
type = 'text',
|
|
30
30
|
value,
|
|
31
31
|
...props
|
|
32
|
-
}:
|
|
32
|
+
}: TextInputProps) => {
|
|
33
33
|
const errorMessageId = `error-message-${id}`;
|
|
34
34
|
const hintTextId = `hint-text-${id}`;
|
|
35
35
|
const ref = useRef(null);
|
|
36
|
-
const inputWrapperClasses =
|
|
36
|
+
const inputWrapperClasses = clsx(
|
|
37
|
+
hasButton && 'ds_input__wrapper',
|
|
38
|
+
hasButton && 'ds_input__wrapper--has-icon',
|
|
39
|
+
isCurrency && 'ds_currency-wrapper'
|
|
40
|
+
);
|
|
37
41
|
const describedbys: string[] = [];
|
|
38
42
|
|
|
39
43
|
if (hintText) { describedbys.push(hintTextId) };
|
|
40
44
|
if (errorMessage) { describedbys.push(errorMessageId) };
|
|
41
45
|
|
|
42
46
|
useEffect(() => {
|
|
47
|
+
/* istanbul ignore else */
|
|
43
48
|
if (ref.current) {
|
|
44
49
|
new DSCharacterCount(ref.current).init();
|
|
45
50
|
}
|
|
46
51
|
}, [ref]);
|
|
47
52
|
|
|
48
|
-
function handleBlur(event: React.FocusEvent) {
|
|
53
|
+
function handleBlur(event: React.FocusEvent<HTMLInputElement>) {
|
|
49
54
|
if (typeof onBlur === 'function') {
|
|
50
55
|
onBlur(event);
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
function handleChange(event: React.ChangeEvent) {
|
|
59
|
+
function handleChange(event: React.ChangeEvent<HTMLInputElement>) {
|
|
55
60
|
if (typeof onChange === 'function') {
|
|
56
61
|
onChange(event);
|
|
57
62
|
}
|
|
@@ -63,7 +68,7 @@ const TextInput = ({
|
|
|
63
68
|
wrapper={(children: React.JSX.Element) => <div ref={ref} data-threshold={countThreshold} data-module="ds-character-count">{children}</div>}
|
|
64
69
|
>
|
|
65
70
|
<label className="ds_label" htmlFor={id}>{label}</label>
|
|
66
|
-
{hintText && <HintText id={hintTextId}
|
|
71
|
+
{hintText && <HintText id={hintTextId}>{hintText}</HintText>}
|
|
67
72
|
{errorMessage && <ErrorMessage id={errorMessageId}>{errorMessage}</ErrorMessage>}
|
|
68
73
|
<ConditionalWrapper
|
|
69
74
|
condition={hasButton || typeof isCurrency !== 'undefined' && isCurrency}
|
|
@@ -72,12 +77,12 @@ const TextInput = ({
|
|
|
72
77
|
<input
|
|
73
78
|
aria-describedby={describedbys.join(' ')}
|
|
74
79
|
aria-invalid={hasError}
|
|
75
|
-
className={[
|
|
80
|
+
className={clsx([
|
|
76
81
|
'ds_input',
|
|
77
82
|
className,
|
|
78
|
-
hasError
|
|
79
|
-
width
|
|
80
|
-
]
|
|
83
|
+
hasError && 'ds_input--error',
|
|
84
|
+
width && `ds_input--${width}`,
|
|
85
|
+
])}
|
|
81
86
|
defaultValue={value}
|
|
82
87
|
id={id}
|
|
83
88
|
maxLength={maxlength}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IconName, InputWidth, TextInputBase } from '../../shared-types';
|
|
2
|
+
|
|
3
|
+
export interface TextInputProps extends TextInputBase<HTMLInputElement> {
|
|
4
|
+
buttonIcon?: IconName;
|
|
5
|
+
buttonText?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
currencySymbol?: string;
|
|
8
|
+
hasButton?: boolean;
|
|
9
|
+
isCurrency?: boolean;
|
|
10
|
+
type?: string;
|
|
11
|
+
width?: InputWidth;
|
|
12
|
+
}
|