@amsterdam/design-system-react 0.14.1 → 0.15.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/dist/Accordion/Accordion.d.ts +35 -0
- package/dist/Accordion/Accordion.js +19 -0
- package/dist/Accordion/Accordion.test.d.ts +1 -0
- package/dist/Accordion/Accordion.test.js +24 -0
- package/dist/Accordion/AccordionContext.d.ts +12 -0
- package/dist/Accordion/AccordionContext.js +11 -0
- package/dist/Accordion/AccordionSection.d.ts +19 -0
- package/dist/Accordion/AccordionSection.js +22 -0
- package/dist/Accordion/AccordionSection.test.d.ts +1 -0
- package/dist/Accordion/AccordionSection.test.js +83 -0
- package/dist/Accordion/index.d.ts +3 -0
- package/dist/Accordion/index.js +1 -0
- package/dist/ActionGroup/ActionGroup.d.ts +9 -0
- package/dist/ActionGroup/ActionGroup.js +9 -0
- package/dist/ActionGroup/ActionGroup.test.d.ts +1 -0
- package/dist/ActionGroup/ActionGroup.test.js +29 -0
- package/dist/ActionGroup/index.d.ts +2 -0
- package/dist/ActionGroup/index.js +1 -0
- package/dist/Alert/Alert.d.ts +46 -0
- package/dist/Alert/Alert.js +22 -0
- package/dist/Alert/Alert.test.d.ts +1 -0
- package/dist/Alert/Alert.test.js +59 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/index.js +1 -0
- package/dist/Avatar/Avatar.d.ts +24 -0
- package/dist/Avatar/Avatar.js +25 -0
- package/dist/Avatar/Avatar.test.d.ts +1 -0
- package/dist/Avatar/Avatar.test.js +58 -0
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Avatar/index.js +1 -0
- package/dist/Badge/Badge.d.ts +20 -0
- package/dist/Badge/Badge.js +10 -0
- package/dist/Badge/Badge.test.d.ts +1 -0
- package/dist/Badge/Badge.test.js +39 -0
- package/dist/Badge/index.d.ts +2 -0
- package/dist/Badge/index.js +1 -0
- package/dist/Blockquote/Blockquote.d.ts +15 -0
- package/dist/Blockquote/Blockquote.js +9 -0
- package/dist/Blockquote/Blockquote.test.d.ts +1 -0
- package/dist/Blockquote/Blockquote.test.js +43 -0
- package/dist/Blockquote/index.d.ts +2 -0
- package/dist/Blockquote/index.js +1 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +11 -0
- package/dist/Breadcrumb/Breadcrumb.js +11 -0
- package/dist/Breadcrumb/Breadcrumb.test.d.ts +1 -0
- package/dist/Breadcrumb/Breadcrumb.test.js +41 -0
- package/dist/Breadcrumb/BreadcrumbLink.d.ts +7 -0
- package/dist/Breadcrumb/BreadcrumbLink.js +9 -0
- package/dist/Breadcrumb/BreadcrumbLink.test.d.ts +1 -0
- package/dist/Breadcrumb/BreadcrumbLink.test.js +36 -0
- package/dist/Breadcrumb/index.d.ts +3 -0
- package/dist/Breadcrumb/index.js +1 -0
- package/dist/Breakout/Breakout.d.ts +15 -0
- package/dist/Breakout/Breakout.js +12 -0
- package/dist/Breakout/Breakout.test.d.ts +1 -0
- package/dist/Breakout/Breakout.test.js +66 -0
- package/dist/Breakout/BreakoutCell.d.ts +35 -0
- package/dist/Breakout/BreakoutCell.js +10 -0
- package/dist/Breakout/BreakoutCell.test.d.ts +1 -0
- package/dist/Breakout/BreakoutCell.test.js +120 -0
- package/dist/Breakout/breakoutCellClasses.d.ts +6 -0
- package/dist/Breakout/breakoutCellClasses.js +11 -0
- package/dist/Breakout/index.d.ts +3 -0
- package/dist/Breakout/index.js +1 -0
- package/dist/Button/Button.d.ts +31 -0
- package/dist/Button/Button.js +10 -0
- package/dist/Button/Button.test.d.ts +1 -0
- package/dist/Button/Button.test.js +103 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/index.js +1 -0
- package/dist/Card/Card.d.ts +18 -0
- package/dist/Card/Card.js +12 -0
- package/dist/Card/Card.test.d.ts +1 -0
- package/dist/Card/Card.test.js +29 -0
- package/dist/Card/CardHeadingGroup.d.ts +15 -0
- package/dist/Card/CardHeadingGroup.js +10 -0
- package/dist/Card/CardHeadingGroup.test.d.ts +1 -0
- package/dist/Card/CardHeadingGroup.test.js +34 -0
- package/dist/Card/CardLink.d.ts +9 -0
- package/dist/Card/CardLink.js +9 -0
- package/dist/Card/CardLink.test.d.ts +1 -0
- package/dist/Card/CardLink.test.js +29 -0
- package/dist/Card/index.d.ts +4 -0
- package/dist/Card/index.js +1 -0
- package/dist/CharacterCount/CharacterCount.d.ts +17 -0
- package/dist/CharacterCount/CharacterCount.js +9 -0
- package/dist/CharacterCount/CharacterCount.test.d.ts +1 -0
- package/dist/CharacterCount/CharacterCount.test.js +34 -0
- package/dist/CharacterCount/index.d.ts +2 -0
- package/dist/CharacterCount/index.js +1 -0
- package/dist/Checkbox/Checkbox.d.ts +19 -0
- package/dist/Checkbox/Checkbox.js +24 -0
- package/dist/Checkbox/Checkbox.test.d.ts +1 -0
- package/dist/Checkbox/Checkbox.test.js +124 -0
- package/dist/Checkbox/index.d.ts +2 -0
- package/dist/Checkbox/index.js +1 -0
- package/dist/Column/Column.d.ts +56 -0
- package/dist/Column/Column.js +10 -0
- package/dist/Column/Column.test.d.ts +1 -0
- package/dist/Column/Column.test.js +57 -0
- package/dist/Column/index.d.ts +2 -0
- package/dist/Column/index.js +1 -0
- package/dist/DateInput/DateInput.d.ts +20 -0
- package/dist/DateInput/DateInput.js +10 -0
- package/dist/DateInput/DateInput.test.d.ts +1 -0
- package/dist/DateInput/DateInput.test.js +54 -0
- package/dist/DateInput/index.d.ts +2 -0
- package/dist/DateInput/index.js +1 -0
- package/dist/DescriptionList/DescriptionList.d.ts +30 -0
- package/dist/DescriptionList/DescriptionList.js +18 -0
- package/dist/DescriptionList/DescriptionList.test.d.ts +1 -0
- package/dist/DescriptionList/DescriptionList.test.js +39 -0
- package/dist/DescriptionList/DescriptionListDescription.d.ts +9 -0
- package/dist/DescriptionList/DescriptionListDescription.js +9 -0
- package/dist/DescriptionList/DescriptionListDescription.test.d.ts +1 -0
- package/dist/DescriptionList/DescriptionListDescription.test.js +29 -0
- package/dist/DescriptionList/DescriptionListSection.d.ts +9 -0
- package/dist/DescriptionList/DescriptionListSection.js +9 -0
- package/dist/DescriptionList/DescriptionListSection.test.d.ts +1 -0
- package/dist/DescriptionList/DescriptionListSection.test.js +29 -0
- package/dist/DescriptionList/DescriptionListTerm.d.ts +9 -0
- package/dist/DescriptionList/DescriptionListTerm.js +9 -0
- package/dist/DescriptionList/DescriptionListTerm.test.d.ts +1 -0
- package/dist/DescriptionList/DescriptionListTerm.test.js +29 -0
- package/dist/DescriptionList/index.d.ts +4 -0
- package/dist/DescriptionList/index.js +1 -0
- package/dist/Dialog/Dialog.d.ts +27 -0
- package/dist/Dialog/Dialog.js +17 -0
- package/dist/Dialog/Dialog.test.d.ts +1 -0
- package/dist/Dialog/Dialog.test.js +78 -0
- package/dist/Dialog/index.d.ts +2 -0
- package/dist/Dialog/index.js +1 -0
- package/dist/ErrorMessage/ErrorMessage.d.ts +19 -0
- package/dist/ErrorMessage/ErrorMessage.js +11 -0
- package/dist/ErrorMessage/ErrorMessage.test.d.ts +1 -0
- package/dist/ErrorMessage/ErrorMessage.test.js +49 -0
- package/dist/ErrorMessage/index.d.ts +2 -0
- package/dist/ErrorMessage/index.js +1 -0
- package/dist/Field/Field.d.ts +15 -0
- package/dist/Field/Field.js +9 -0
- package/dist/Field/Field.test.d.ts +1 -0
- package/dist/Field/Field.test.js +34 -0
- package/dist/Field/index.d.ts +2 -0
- package/dist/Field/index.js +1 -0
- package/dist/FieldSet/FieldSet.d.ts +23 -0
- package/dist/FieldSet/FieldSet.js +12 -0
- package/dist/FieldSet/FieldSet.test.d.ts +1 -0
- package/dist/FieldSet/FieldSet.test.js +59 -0
- package/dist/FieldSet/index.d.ts +2 -0
- package/dist/FieldSet/index.js +1 -0
- package/dist/Figure/Figure.d.ts +15 -0
- package/dist/Figure/Figure.js +11 -0
- package/dist/Figure/Figure.test.d.ts +1 -0
- package/dist/Figure/Figure.test.js +29 -0
- package/dist/Figure/FigureCaption.d.ts +15 -0
- package/dist/Figure/FigureCaption.js +9 -0
- package/dist/Figure/FigureCaption.test.d.ts +1 -0
- package/dist/Figure/FigureCaption.test.js +34 -0
- package/dist/Figure/index.d.ts +2 -0
- package/dist/Figure/index.js +1 -0
- package/dist/FileInput/FileInput.d.ts +7 -0
- package/dist/FileInput/FileInput.js +9 -0
- package/dist/FileInput/FileInput.test.d.ts +1 -0
- package/dist/FileInput/FileInput.test.js +29 -0
- package/dist/FileInput/index.d.ts +2 -0
- package/dist/FileInput/index.js +1 -0
- package/dist/FileList/FileList.d.ts +17 -0
- package/dist/FileList/FileList.js +13 -0
- package/dist/FileList/FileList.test.d.ts +1 -0
- package/dist/FileList/FileList.test.js +29 -0
- package/dist/FileList/FileListItem.d.ts +13 -0
- package/dist/FileList/FileListItem.js +14 -0
- package/dist/FileList/FileListItem.test.d.ts +1 -0
- package/dist/FileList/FileListItem.test.js +40 -0
- package/dist/FileList/index.d.ts +2 -0
- package/dist/FileList/index.js +1 -0
- package/dist/Footer/Footer.d.ts +19 -0
- package/dist/Footer/Footer.js +17 -0
- package/dist/Footer/Footer.test.d.ts +1 -0
- package/dist/Footer/Footer.test.js +29 -0
- package/dist/Footer/FooterMenu.d.ts +9 -0
- package/dist/Footer/FooterMenu.js +9 -0
- package/dist/Footer/FooterMenu.test.d.ts +1 -0
- package/dist/Footer/FooterMenu.test.js +31 -0
- package/dist/Footer/FooterMenuLink.d.ts +9 -0
- package/dist/Footer/FooterMenuLink.js +9 -0
- package/dist/Footer/FooterMenuLink.test.d.ts +1 -0
- package/dist/Footer/FooterMenuLink.test.js +29 -0
- package/dist/Footer/FooterSpotlight.d.ts +9 -0
- package/dist/Footer/FooterSpotlight.js +9 -0
- package/dist/Footer/FooterSpotlight.test.d.ts +1 -0
- package/dist/Footer/FooterSpotlight.test.js +29 -0
- package/dist/Footer/index.d.ts +5 -0
- package/dist/Footer/index.js +1 -0
- package/dist/Grid/Grid.d.ts +37 -0
- package/dist/Grid/Grid.js +13 -0
- package/dist/Grid/Grid.test.d.ts +1 -0
- package/dist/Grid/Grid.test.js +81 -0
- package/dist/Grid/GridCell.d.ts +25 -0
- package/dist/Grid/GridCell.js +11 -0
- package/dist/Grid/GridCell.test.d.ts +1 -0
- package/dist/Grid/GridCell.test.js +86 -0
- package/dist/Grid/gridCellClasses.d.ts +8 -0
- package/dist/Grid/gridCellClasses.js +18 -0
- package/dist/Grid/index.d.ts +3 -0
- package/dist/Grid/index.js +1 -0
- package/dist/Grid/paddingClasses.d.ts +2 -0
- package/dist/Grid/paddingClasses.js +13 -0
- package/dist/Header/Header.d.ts +49 -0
- package/dist/Header/Header.js +31 -0
- package/dist/Header/Header.test.d.ts +2 -0
- package/dist/Header/Header.test.js +121 -0
- package/dist/Header/HeaderGridCellNarrowWindowOnly.d.ts +2 -0
- package/dist/Header/HeaderGridCellNarrowWindowOnly.js +6 -0
- package/dist/Header/HeaderGridCellNarrowWindowOnly.test.d.ts +1 -0
- package/dist/Header/HeaderGridCellNarrowWindowOnly.test.js +34 -0
- package/dist/Header/HeaderMenuIcon.d.ts +2 -0
- package/dist/Header/HeaderMenuIcon.js +2 -0
- package/dist/Header/HeaderMenuLink.d.ts +9 -0
- package/dist/Header/HeaderMenuLink.js +5 -0
- package/dist/Header/HeaderMenuLink.test.d.ts +1 -0
- package/dist/Header/HeaderMenuLink.test.js +41 -0
- package/dist/Header/index.d.ts +3 -0
- package/dist/Header/index.js +1 -0
- package/dist/Header/matchMedia.mock.d.ts +0 -0
- package/dist/Header/matchMedia.mock.js +15 -0
- package/dist/Heading/Heading.d.ts +24 -0
- package/dist/Heading/Heading.js +15 -0
- package/dist/Heading/Heading.test.d.ts +1 -0
- package/dist/Heading/Heading.test.js +62 -0
- package/dist/Heading/getHeadingTag.d.ts +2 -0
- package/dist/Heading/getHeadingTag.js +13 -0
- package/dist/Heading/index.d.ts +2 -0
- package/dist/Heading/index.js +1 -0
- package/dist/Hint/Hint.d.ts +16 -0
- package/dist/Hint/Hint.js +21 -0
- package/dist/Hint/Hint.test.d.ts +1 -0
- package/dist/Hint/Hint.test.js +49 -0
- package/dist/Hint/index.d.ts +2 -0
- package/dist/Hint/index.js +1 -0
- package/dist/Icon/Icon.d.ts +30 -0
- package/dist/Icon/Icon.js +12 -0
- package/dist/Icon/Icon.test.d.ts +1 -0
- package/dist/Icon/Icon.test.js +52 -0
- package/dist/Icon/index.d.ts +2 -0
- package/dist/Icon/index.js +1 -0
- package/dist/IconButton/IconButton.d.ts +26 -0
- package/dist/IconButton/IconButton.js +11 -0
- package/dist/IconButton/IconButton.test.d.ts +1 -0
- package/dist/IconButton/IconButton.test.js +44 -0
- package/dist/IconButton/index.d.ts +2 -0
- package/dist/IconButton/index.js +1 -0
- package/dist/Image/Image.d.ts +18 -0
- package/dist/Image/Image.js +10 -0
- package/dist/Image/Image.test.d.ts +1 -0
- package/dist/Image/Image.test.js +39 -0
- package/dist/Image/generateAspectRatioClass.d.ts +1 -0
- package/dist/Image/generateAspectRatioClass.js +1 -0
- package/dist/Image/index.d.ts +3 -0
- package/dist/Image/index.js +2 -0
- package/dist/ImageSlider/ImageSlider.d.ts +49 -0
- package/dist/ImageSlider/ImageSlider.js +98 -0
- package/dist/ImageSlider/ImageSlider.test.d.ts +1 -0
- package/dist/ImageSlider/ImageSlider.test.js +66 -0
- package/dist/ImageSlider/ImageSliderContext.d.ts +13 -0
- package/dist/ImageSlider/ImageSliderContext.js +14 -0
- package/dist/ImageSlider/ImageSliderControls.d.ts +17 -0
- package/dist/ImageSlider/ImageSliderControls.js +17 -0
- package/dist/ImageSlider/ImageSliderControls.test.d.ts +1 -0
- package/dist/ImageSlider/ImageSliderControls.test.js +21 -0
- package/dist/ImageSlider/ImageSliderItem.d.ts +15 -0
- package/dist/ImageSlider/ImageSliderItem.js +15 -0
- package/dist/ImageSlider/ImageSliderItem.test.d.ts +1 -0
- package/dist/ImageSlider/ImageSliderItem.test.js +33 -0
- package/dist/ImageSlider/ImageSliderScroller.d.ts +9 -0
- package/dist/ImageSlider/ImageSliderScroller.js +9 -0
- package/dist/ImageSlider/ImageSliderScroller.test.d.ts +1 -0
- package/dist/ImageSlider/ImageSliderScroller.test.js +33 -0
- package/dist/ImageSlider/ImageSliderThumbnails.d.ts +14 -0
- package/dist/ImageSlider/ImageSliderThumbnails.js +32 -0
- package/dist/ImageSlider/ImageSliderThumbnails.test.d.ts +1 -0
- package/dist/ImageSlider/ImageSliderThumbnails.test.js +48 -0
- package/dist/ImageSlider/index.d.ts +3 -0
- package/dist/ImageSlider/index.js +1 -0
- package/dist/InvalidFormAlert/InvalidFormAlert.d.ts +68 -0
- package/dist/InvalidFormAlert/InvalidFormAlert.js +20 -0
- package/dist/InvalidFormAlert/InvalidFormAlert.test.d.ts +1 -0
- package/dist/InvalidFormAlert/InvalidFormAlert.test.js +104 -0
- package/dist/InvalidFormAlert/InvalidFormAlertWithErrors.d.ts +12 -0
- package/dist/InvalidFormAlert/InvalidFormAlertWithErrors.js +22 -0
- package/dist/InvalidFormAlert/index.d.ts +2 -0
- package/dist/InvalidFormAlert/index.js +1 -0
- package/dist/InvalidFormAlert/useAddErrorCountToDocumentTitle.d.ts +11 -0
- package/dist/InvalidFormAlert/useAddErrorCountToDocumentTitle.js +26 -0
- package/dist/Label/Label.d.ts +14 -0
- package/dist/Label/Label.js +13 -0
- package/dist/Label/Label.test.d.ts +1 -0
- package/dist/Label/Label.test.js +74 -0
- package/dist/Label/index.d.ts +1 -0
- package/dist/Label/index.js +1 -0
- package/dist/Link/Link.d.ts +19 -0
- package/dist/Link/Link.js +9 -0
- package/dist/Link/Link.test.d.ts +1 -0
- package/dist/Link/Link.test.js +46 -0
- package/dist/Link/index.d.ts +2 -0
- package/dist/Link/index.js +1 -0
- package/dist/LinkList/LinkList.d.ts +17 -0
- package/dist/LinkList/LinkList.js +14 -0
- package/dist/LinkList/LinkList.test.d.ts +1 -0
- package/dist/LinkList/LinkList.test.js +29 -0
- package/dist/LinkList/LinkListLink.d.ts +24 -0
- package/dist/LinkList/LinkListLink.js +14 -0
- package/dist/LinkList/LinkListLink.test.d.ts +1 -0
- package/dist/LinkList/LinkListLink.test.js +50 -0
- package/dist/LinkList/index.d.ts +3 -0
- package/dist/LinkList/index.js +1 -0
- package/dist/Logo/Logo.d.ts +11 -0
- package/dist/Logo/Logo.js +21 -0
- package/dist/Logo/Logo.test.d.ts +1 -0
- package/dist/Logo/Logo.test.js +30 -0
- package/dist/Logo/brand/LogoAmsterdam.d.ts +3 -0
- package/dist/Logo/brand/LogoAmsterdam.js +5 -0
- package/dist/Logo/brand/LogoGgdAmsterdam.d.ts +3 -0
- package/dist/Logo/brand/LogoGgdAmsterdam.js +5 -0
- package/dist/Logo/brand/LogoMuseumWeesp.d.ts +3 -0
- package/dist/Logo/brand/LogoMuseumWeesp.js +5 -0
- package/dist/Logo/brand/LogoStadsarchief.d.ts +3 -0
- package/dist/Logo/brand/LogoStadsarchief.js +5 -0
- package/dist/Logo/brand/LogoStadsbankVanLening.d.ts +3 -0
- package/dist/Logo/brand/LogoStadsbankVanLening.js +5 -0
- package/dist/Logo/brand/LogoVgaVerzekeringen.d.ts +3 -0
- package/dist/Logo/brand/LogoVgaVerzekeringen.js +5 -0
- package/dist/Logo/brand/index.d.ts +6 -0
- package/dist/Logo/brand/index.js +6 -0
- package/dist/Logo/index.d.ts +2 -0
- package/dist/Logo/index.js +1 -0
- package/dist/Mark/Mark.d.ts +9 -0
- package/dist/Mark/Mark.js +9 -0
- package/dist/Mark/Mark.test.d.ts +1 -0
- package/dist/Mark/Mark.test.js +29 -0
- package/dist/Mark/index.d.ts +2 -0
- package/dist/Mark/index.js +1 -0
- package/dist/MegaMenu/MegaMenu.d.ts +14 -0
- package/dist/MegaMenu/MegaMenu.js +12 -0
- package/dist/MegaMenu/MegaMenu.test.d.ts +1 -0
- package/dist/MegaMenu/MegaMenu.test.js +29 -0
- package/dist/MegaMenu/MegaMenuListCategory.d.ts +9 -0
- package/dist/MegaMenu/MegaMenuListCategory.js +9 -0
- package/dist/MegaMenu/MegaMenuListCategory.test.d.ts +1 -0
- package/dist/MegaMenu/MegaMenuListCategory.test.js +29 -0
- package/dist/MegaMenu/index.d.ts +3 -0
- package/dist/MegaMenu/index.js +1 -0
- package/dist/OrderedList/OrderedList.d.ts +27 -0
- package/dist/OrderedList/OrderedList.js +11 -0
- package/dist/OrderedList/OrderedList.test.d.ts +1 -0
- package/dist/OrderedList/OrderedList.test.js +51 -0
- package/dist/OrderedList/OrderedListItem.d.ts +9 -0
- package/dist/OrderedList/OrderedListItem.js +9 -0
- package/dist/OrderedList/OrderedListItem.test.d.ts +1 -0
- package/dist/OrderedList/OrderedListItem.test.js +28 -0
- package/dist/OrderedList/index.d.ts +3 -0
- package/dist/OrderedList/index.js +1 -0
- package/dist/Overlap/Overlap.d.ts +9 -0
- package/dist/Overlap/Overlap.js +9 -0
- package/dist/Overlap/Overlap.test.d.ts +1 -0
- package/dist/Overlap/Overlap.test.js +34 -0
- package/dist/Overlap/index.d.ts +2 -0
- package/dist/Overlap/index.js +1 -0
- package/dist/PageHeading/PageHeading.d.ts +15 -0
- package/dist/PageHeading/PageHeading.js +9 -0
- package/dist/PageHeading/PageHeading.test.d.ts +1 -0
- package/dist/PageHeading/PageHeading.test.js +37 -0
- package/dist/PageHeading/index.d.ts +2 -0
- package/dist/PageHeading/index.js +1 -0
- package/dist/PageMenu/PageMenu.d.ts +25 -0
- package/dist/PageMenu/PageMenu.js +12 -0
- package/dist/PageMenu/PageMenu.test.d.ts +1 -0
- package/dist/PageMenu/PageMenu.test.js +45 -0
- package/dist/PageMenu/PageMenuLink.d.ts +13 -0
- package/dist/PageMenu/PageMenuLink.js +10 -0
- package/dist/PageMenu/PageMenuLink.test.d.ts +1 -0
- package/dist/PageMenu/PageMenuLink.test.js +40 -0
- package/dist/PageMenu/index.d.ts +3 -0
- package/dist/PageMenu/index.js +1 -0
- package/dist/Pagination/LinkItem.d.ts +7 -0
- package/dist/Pagination/LinkItem.js +7 -0
- package/dist/Pagination/Pagination.d.ts +59 -0
- package/dist/Pagination/Pagination.js +23 -0
- package/dist/Pagination/Pagination.test.d.ts +1 -0
- package/dist/Pagination/Pagination.test.js +120 -0
- package/dist/Pagination/Spacer.d.ts +1 -0
- package/dist/Pagination/Spacer.js +2 -0
- package/dist/Pagination/getRange.d.ts +16 -0
- package/dist/Pagination/getRange.js +41 -0
- package/dist/Pagination/index.d.ts +2 -0
- package/dist/Pagination/index.js +1 -0
- package/dist/Paragraph/Paragraph.d.ts +20 -0
- package/dist/Paragraph/Paragraph.js +10 -0
- package/dist/Paragraph/Paragraph.test.d.ts +1 -0
- package/dist/Paragraph/Paragraph.test.js +58 -0
- package/dist/Paragraph/index.d.ts +2 -0
- package/dist/Paragraph/index.js +1 -0
- package/dist/PasswordInput/PasswordInput.d.ts +13 -0
- package/dist/PasswordInput/PasswordInput.js +9 -0
- package/dist/PasswordInput/PasswordInput.test.d.ts +1 -0
- package/dist/PasswordInput/PasswordInput.test.js +85 -0
- package/dist/PasswordInput/index.d.ts +2 -0
- package/dist/PasswordInput/index.js +1 -0
- package/dist/Radio/Radio.d.ts +19 -0
- package/dist/Radio/Radio.js +16 -0
- package/dist/Radio/Radio.test.d.ts +1 -0
- package/dist/Radio/Radio.test.js +121 -0
- package/dist/Radio/RadioIcon.d.ts +3 -0
- package/dist/Radio/RadioIcon.js +3 -0
- package/dist/Radio/index.d.ts +2 -0
- package/dist/Radio/index.js +1 -0
- package/dist/Row/Row.d.ts +66 -0
- package/dist/Row/Row.js +10 -0
- package/dist/Row/Row.test.d.ts +1 -0
- package/dist/Row/Row.test.js +62 -0
- package/dist/Row/index.d.ts +2 -0
- package/dist/Row/index.js +1 -0
- package/dist/Screen/Screen.d.ts +21 -0
- package/dist/Screen/Screen.js +9 -0
- package/dist/Screen/Screen.test.d.ts +1 -0
- package/dist/Screen/Screen.test.js +40 -0
- package/dist/Screen/index.d.ts +2 -0
- package/dist/Screen/index.js +1 -0
- package/dist/SearchField/SearchField.d.ts +292 -0
- package/dist/SearchField/SearchField.js +14 -0
- package/dist/SearchField/SearchField.test.d.ts +1 -0
- package/dist/SearchField/SearchField.test.js +47 -0
- package/dist/SearchField/SearchFieldButton.d.ts +8 -0
- package/dist/SearchField/SearchFieldButton.js +10 -0
- package/dist/SearchField/SearchFieldInput.d.ts +11 -0
- package/dist/SearchField/SearchFieldInput.js +12 -0
- package/dist/SearchField/SearchFieldInput.test.d.ts +1 -0
- package/dist/SearchField/SearchFieldInput.test.js +62 -0
- package/dist/SearchField/index.d.ts +2 -0
- package/dist/SearchField/index.js +1 -0
- package/dist/Select/Select.d.ts +22 -0
- package/dist/Select/Select.js +12 -0
- package/dist/Select/Select.test.d.ts +1 -0
- package/dist/Select/Select.test.js +70 -0
- package/dist/Select/SelectOption.d.ts +9 -0
- package/dist/Select/SelectOption.js +9 -0
- package/dist/Select/SelectOption.test.d.ts +1 -0
- package/dist/Select/SelectOption.test.js +41 -0
- package/dist/Select/SelectOptionGroup.d.ts +9 -0
- package/dist/Select/SelectOptionGroup.js +9 -0
- package/dist/Select/SelectOptionGroup.test.d.ts +1 -0
- package/dist/Select/SelectOptionGroup.test.js +41 -0
- package/dist/Select/index.d.ts +3 -0
- package/dist/Select/index.js +1 -0
- package/dist/SkipLink/SkipLink.d.ts +9 -0
- package/dist/SkipLink/SkipLink.js +9 -0
- package/dist/SkipLink/SkipLink.test.d.ts +1 -0
- package/dist/SkipLink/SkipLink.test.js +29 -0
- package/dist/SkipLink/index.d.ts +2 -0
- package/dist/SkipLink/index.js +1 -0
- package/dist/Spotlight/Spotlight.d.ts +22 -0
- package/dist/Spotlight/Spotlight.js +10 -0
- package/dist/Spotlight/Spotlight.test.d.ts +1 -0
- package/dist/Spotlight/Spotlight.test.js +40 -0
- package/dist/Spotlight/index.d.ts +2 -0
- package/dist/Spotlight/index.js +1 -0
- package/dist/Switch/Switch.d.ts +9 -0
- package/dist/Switch/Switch.js +12 -0
- package/dist/Switch/Switch.test.d.ts +1 -0
- package/dist/Switch/Switch.test.js +65 -0
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Switch/index.js +1 -0
- package/dist/Table/Table.d.ts +31 -0
- package/dist/Table/Table.js +25 -0
- package/dist/Table/Table.test.d.ts +1 -0
- package/dist/Table/Table.test.js +29 -0
- package/dist/Table/TableBody.d.ts +9 -0
- package/dist/Table/TableBody.js +9 -0
- package/dist/Table/TableBody.test.d.ts +1 -0
- package/dist/Table/TableBody.test.js +30 -0
- package/dist/Table/TableCaption.d.ts +10 -0
- package/dist/Table/TableCaption.js +10 -0
- package/dist/Table/TableCaption.test.d.ts +1 -0
- package/dist/Table/TableCaption.test.js +41 -0
- package/dist/Table/TableCell.d.ts +9 -0
- package/dist/Table/TableCell.js +9 -0
- package/dist/Table/TableCell.test.d.ts +1 -0
- package/dist/Table/TableCell.test.js +32 -0
- package/dist/Table/TableFooter.d.ts +9 -0
- package/dist/Table/TableFooter.js +9 -0
- package/dist/Table/TableFooter.test.d.ts +1 -0
- package/dist/Table/TableFooter.test.js +30 -0
- package/dist/Table/TableHeader.d.ts +9 -0
- package/dist/Table/TableHeader.js +9 -0
- package/dist/Table/TableHeader.test.d.ts +1 -0
- package/dist/Table/TableHeader.test.js +30 -0
- package/dist/Table/TableHeaderCell.d.ts +9 -0
- package/dist/Table/TableHeaderCell.js +9 -0
- package/dist/Table/TableHeaderCell.test.d.ts +1 -0
- package/dist/Table/TableHeaderCell.test.js +38 -0
- package/dist/Table/TableRow.d.ts +9 -0
- package/dist/Table/TableRow.js +9 -0
- package/dist/Table/TableRow.test.d.ts +1 -0
- package/dist/Table/TableRow.test.js +31 -0
- package/dist/Table/index.d.ts +2 -0
- package/dist/Table/index.js +1 -0
- package/dist/TableOfContents/TableOfContents.d.ts +33 -0
- package/dist/TableOfContents/TableOfContents.js +18 -0
- package/dist/TableOfContents/TableOfContents.test.d.ts +1 -0
- package/dist/TableOfContents/TableOfContents.test.js +40 -0
- package/dist/TableOfContents/TableOfContentsLink.d.ts +13 -0
- package/dist/TableOfContents/TableOfContentsLink.js +9 -0
- package/dist/TableOfContents/TableOfContentsLink.test.d.ts +1 -0
- package/dist/TableOfContents/TableOfContentsLink.test.js +30 -0
- package/dist/TableOfContents/TableOfContentsList.d.ts +9 -0
- package/dist/TableOfContents/TableOfContentsList.js +11 -0
- package/dist/TableOfContents/TableOfContentsList.test.d.ts +1 -0
- package/dist/TableOfContents/TableOfContentsList.test.js +36 -0
- package/dist/TableOfContents/index.d.ts +4 -0
- package/dist/TableOfContents/index.js +1 -0
- package/dist/Tabs/Tabs.d.ts +31 -0
- package/dist/Tabs/Tabs.js +57 -0
- package/dist/Tabs/Tabs.test.d.ts +1 -0
- package/dist/Tabs/Tabs.test.js +85 -0
- package/dist/Tabs/TabsButton.d.ts +15 -0
- package/dist/Tabs/TabsButton.js +19 -0
- package/dist/Tabs/TabsButton.test.d.ts +1 -0
- package/dist/Tabs/TabsButton.test.js +43 -0
- package/dist/Tabs/TabsContext.d.ts +16 -0
- package/dist/Tabs/TabsContext.js +11 -0
- package/dist/Tabs/TabsList.d.ts +9 -0
- package/dist/Tabs/TabsList.js +20 -0
- package/dist/Tabs/TabsList.test.d.ts +1 -0
- package/dist/Tabs/TabsList.test.js +28 -0
- package/dist/Tabs/TabsPanel.d.ts +15 -0
- package/dist/Tabs/TabsPanel.js +16 -0
- package/dist/Tabs/TabsPanel.test.d.ts +1 -0
- package/dist/Tabs/TabsPanel.test.js +40 -0
- package/dist/Tabs/index.d.ts +5 -0
- package/dist/Tabs/index.js +1 -0
- package/dist/TextArea/TextArea.d.ts +17 -0
- package/dist/TextArea/TextArea.js +9 -0
- package/dist/TextArea/TextArea.test.d.ts +1 -0
- package/dist/TextArea/TextArea.test.js +101 -0
- package/dist/TextArea/index.d.ts +2 -0
- package/dist/TextArea/index.js +1 -0
- package/dist/TextInput/TextInput.d.ts +20 -0
- package/dist/TextInput/TextInput.js +10 -0
- package/dist/TextInput/TextInput.test.d.ts +1 -0
- package/dist/TextInput/TextInput.test.js +89 -0
- package/dist/TextInput/index.d.ts +2 -0
- package/dist/TextInput/index.js +1 -0
- package/dist/TimeInput/TimeInput.d.ts +13 -0
- package/dist/TimeInput/TimeInput.js +9 -0
- package/dist/TimeInput/TimeInput.test.d.ts +1 -0
- package/dist/TimeInput/TimeInput.test.js +47 -0
- package/dist/TimeInput/index.d.ts +2 -0
- package/dist/TimeInput/index.js +1 -0
- package/dist/TopTaskLink/TopTaskLink.d.ts +17 -0
- package/dist/TopTaskLink/TopTaskLink.js +9 -0
- package/dist/TopTaskLink/TopTaskLink.test.d.ts +1 -0
- package/dist/TopTaskLink/TopTaskLink.test.js +42 -0
- package/dist/TopTaskLink/index.d.ts +1 -0
- package/dist/TopTaskLink/index.js +1 -0
- package/dist/UnorderedList/UnorderedList.d.ts +27 -0
- package/dist/UnorderedList/UnorderedList.js +13 -0
- package/dist/UnorderedList/UnorderedList.test.d.ts +1 -0
- package/dist/UnorderedList/UnorderedList.test.js +51 -0
- package/dist/UnorderedList/UnorderedListItem.d.ts +9 -0
- package/dist/UnorderedList/UnorderedListItem.js +9 -0
- package/dist/UnorderedList/UnorderedListItem.test.d.ts +1 -0
- package/dist/UnorderedList/UnorderedListItem.test.js +28 -0
- package/dist/UnorderedList/index.d.ts +3 -0
- package/dist/UnorderedList/index.js +1 -0
- package/dist/common/accessibility.d.ts +5 -0
- package/dist/common/accessibility.js +13 -0
- package/dist/common/formatFileSize.d.ts +10 -0
- package/dist/common/formatFileSize.js +17 -0
- package/dist/common/formatFileSize.test.d.ts +1 -0
- package/dist/common/formatFileSize.test.js +18 -0
- package/dist/common/formatFileType.d.ts +10 -0
- package/dist/common/formatFileType.js +34 -0
- package/dist/common/formatFileType.test.d.ts +1 -0
- package/dist/common/formatFileType.test.js +23 -0
- package/dist/common/shortSize.d.ts +12 -0
- package/dist/common/shortSize.js +15 -0
- package/dist/common/types.d.ts +11 -0
- package/dist/common/types.js +9 -0
- package/dist/common/useIsAfterBreakpoint.d.ts +3 -0
- package/dist/common/useIsAfterBreakpoint.js +24 -0
- package/dist/common/useKeyboardFocus.d.ts +23 -0
- package/dist/common/useKeyboardFocus.js +56 -0
- package/dist/common/useKeyboardFocus.test.d.ts +1 -0
- package/dist/common/useKeyboardFocus.test.js +79 -0
- package/dist/index.cjs.js +1043 -1038
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +213 -189
- package/dist/index.esm.js +1043 -1039
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +66 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +20 -21
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { createRef } from 'react';
|
|
4
|
+
import { Pagination } from './Pagination';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
describe('Pagination', () => {
|
|
7
|
+
const linkTemplate = (page) => `#?pagina=${page}`;
|
|
8
|
+
it('renders', () => {
|
|
9
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, totalPages: 10 }));
|
|
10
|
+
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
11
|
+
expect(component).toBeInTheDocument();
|
|
12
|
+
expect(component).toBeVisible();
|
|
13
|
+
});
|
|
14
|
+
it('renders a design system BEM class name', () => {
|
|
15
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, totalPages: 10 }));
|
|
16
|
+
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
17
|
+
expect(component).toHaveClass('ams-pagination');
|
|
18
|
+
});
|
|
19
|
+
it('can have a additional class name', () => {
|
|
20
|
+
render(_jsx(Pagination, { className: "extra", linkTemplate: linkTemplate, totalPages: 10 }));
|
|
21
|
+
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
22
|
+
expect(component).toHaveClass('ams-pagination extra');
|
|
23
|
+
});
|
|
24
|
+
it('should render all the pages when totalPages < maxVisiblePages', () => {
|
|
25
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, maxVisiblePages: 7, totalPages: 6 }));
|
|
26
|
+
const listItem = screen.getAllByRole('listitem', { hidden: true });
|
|
27
|
+
const range = ['1', '2', '3', '4', '5', '6'];
|
|
28
|
+
range.forEach((item, index) => {
|
|
29
|
+
expect(listItem[index]).toHaveTextContent(item);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
it('should render the pages including one (last) spacer in the correct location when totalPages > maxVisiblePages', () => {
|
|
33
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, maxVisiblePages: 7, page: 1, totalPages: 10 }));
|
|
34
|
+
const listItem = screen.getAllByRole('listitem', { hidden: true });
|
|
35
|
+
const range = ['1', '2', '3', '4', '5', '…', '10'];
|
|
36
|
+
range.forEach((item, index) => {
|
|
37
|
+
expect(listItem[index]).toHaveTextContent(item);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
it('should render the pages including the two spacers in the correct location when totalPages > maxVisiblePages and current page > 4', () => {
|
|
41
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, maxVisiblePages: 7, page: 6, totalPages: 10 }));
|
|
42
|
+
const listItem = screen.getAllByRole('listitem', { hidden: true });
|
|
43
|
+
const range = ['1', '…', '5', '6', '7', '…', '10'];
|
|
44
|
+
range.forEach((item, index) => {
|
|
45
|
+
expect(listItem[index]).toHaveTextContent(item);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it('should render the pages including one (first) spacer in the correct location when totalPages > maxVisiblePages and page > maxVisiblePages', () => {
|
|
49
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, maxVisiblePages: 7, page: 8, totalPages: 10 }));
|
|
50
|
+
const listItem = screen.getAllByRole('listitem', { hidden: true });
|
|
51
|
+
const range = ['1', '…', '6', '7', '8', '9', '10'];
|
|
52
|
+
range.forEach((item, index) => {
|
|
53
|
+
expect(listItem[index]).toHaveTextContent(item);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
it('should set aria-current to true on the current page', () => {
|
|
57
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, page: 4, totalPages: 10 }));
|
|
58
|
+
const currentPageLink = screen.getByRole('link', { name: 'Pagina 4' });
|
|
59
|
+
expect(currentPageLink).toHaveAttribute('aria-current', 'page');
|
|
60
|
+
});
|
|
61
|
+
it('should set the correct href on the links', () => {
|
|
62
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, page: 4, totalPages: 10 }));
|
|
63
|
+
const previousPageLink = screen.getByRole('link', { name: 'Vorige pagina' });
|
|
64
|
+
const currentPageLink = screen.getByRole('link', { name: 'Pagina 4' });
|
|
65
|
+
const nextPageLink = screen.getByRole('link', { name: 'Volgende pagina' });
|
|
66
|
+
expect(previousPageLink).toHaveAttribute('href', '#?pagina=3');
|
|
67
|
+
expect(currentPageLink).toHaveAttribute('href', '#?pagina=4');
|
|
68
|
+
expect(nextPageLink).toHaveAttribute('href', '#?pagina=5');
|
|
69
|
+
});
|
|
70
|
+
it('sets a custom id for the accessible label', () => {
|
|
71
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, totalPages: 10, visuallyHiddenLabelId: "custom-id" }));
|
|
72
|
+
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
73
|
+
expect(component).toHaveAttribute('aria-labelledby', 'custom-id');
|
|
74
|
+
});
|
|
75
|
+
it('should not render when totalPages is 1 or less', () => {
|
|
76
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, totalPages: 1 }));
|
|
77
|
+
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
|
|
78
|
+
});
|
|
79
|
+
it('should not show the previous link on the first page', () => {
|
|
80
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, page: 1, totalPages: 10 }));
|
|
81
|
+
expect(screen.queryByRole('link', { name: 'Vorige pagina' })).not.toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
it('should not show the next link on the last page', () => {
|
|
84
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, page: 10, totalPages: 10 }));
|
|
85
|
+
expect(screen.queryByRole('link', { name: 'Volgende pagina' })).not.toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
it('renders custom labels for the ‘previous’ and ‘next’ links', () => {
|
|
88
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, nextLabel: "next", page: 4, previousLabel: "previous", totalPages: 10 }));
|
|
89
|
+
const previousLink = screen.getByRole('link', { name: 'Vorige pagina' });
|
|
90
|
+
const nextLink = screen.getByRole('link', { name: 'Volgende pagina' });
|
|
91
|
+
expect(previousLink).toHaveTextContent('previous');
|
|
92
|
+
expect(previousLink).toHaveAttribute('rel', 'prev');
|
|
93
|
+
expect(nextLink).toHaveTextContent('next');
|
|
94
|
+
expect(nextLink).toHaveAttribute('rel', 'next');
|
|
95
|
+
});
|
|
96
|
+
it('renders an accessible label for the navigation', () => {
|
|
97
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, totalPages: 10, visuallyHiddenLabel: "Pagination" }));
|
|
98
|
+
const component = screen.getByRole('navigation', { name: 'Pagination' });
|
|
99
|
+
expect(component).toBeInTheDocument();
|
|
100
|
+
});
|
|
101
|
+
it('renders accessible labels for the ‘previous’ and ‘next’ links', () => {
|
|
102
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, nextVisuallyHiddenLabel: "Next page", page: 4, previousVisuallyHiddenLabel: "Previous page", totalPages: 10 }));
|
|
103
|
+
const previousLink = screen.getByRole('link', { name: 'Previous page' });
|
|
104
|
+
const nextLink = screen.getByRole('link', { name: 'Next page' });
|
|
105
|
+
expect(previousLink).toBeInTheDocument();
|
|
106
|
+
expect(nextLink).toBeInTheDocument();
|
|
107
|
+
});
|
|
108
|
+
it('renders a custom link component', () => {
|
|
109
|
+
const CustomLink = (props) => _jsx("a", { "data-test": true, ...props });
|
|
110
|
+
render(_jsx(Pagination, { linkComponent: CustomLink, linkTemplate: linkTemplate, totalPages: 10 }));
|
|
111
|
+
const customLink = screen.getByRole('link', { name: 'Pagina 1' });
|
|
112
|
+
expect(customLink).toHaveAttribute('data-test');
|
|
113
|
+
});
|
|
114
|
+
it('supports ForwardRef in React', () => {
|
|
115
|
+
const ref = createRef();
|
|
116
|
+
render(_jsx(Pagination, { linkTemplate: linkTemplate, ref: ref, totalPages: 10 }));
|
|
117
|
+
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
118
|
+
expect(ref.current).toBe(component);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Spacer: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This returns an array of the range, including spacers
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* currentPage = 4, totalPages = 7, maxVisiblePages = 7
|
|
6
|
+
* // returns [1, 2, 3, 4, 5, 6, 7]
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* currentPage = 5, totalPages = 100, maxVisiblePages = 7
|
|
10
|
+
* // returns [1, 'firstSpacer', 4, 5, 6, 'lastSpacer', 100]
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* currentPage = 97, totalPages = 100, maxVisiblePages = 7
|
|
14
|
+
* // returns [1, 'firstSpacer', 96, 97, 98, 99, 100]
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRange(currentPage: number, totalPages: number, maxVisiblePages: number): Array<string | number>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This returns an array of the range, including spacers
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* currentPage = 4, totalPages = 7, maxVisiblePages = 7
|
|
6
|
+
* // returns [1, 2, 3, 4, 5, 6, 7]
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* currentPage = 5, totalPages = 100, maxVisiblePages = 7
|
|
10
|
+
* // returns [1, 'firstSpacer', 4, 5, 6, 'lastSpacer', 100]
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* currentPage = 97, totalPages = 100, maxVisiblePages = 7
|
|
14
|
+
* // returns [1, 'firstSpacer', 96, 97, 98, 99, 100]
|
|
15
|
+
*/
|
|
16
|
+
export function getRange(currentPage, totalPages, maxVisiblePages) {
|
|
17
|
+
// the total amount of visible pages is whatever's lower, totalPages or maxVisiblePages
|
|
18
|
+
// maxVisiblePages has a lower limit of 5
|
|
19
|
+
const visiblePages = Math.min(totalPages, Math.max(maxVisiblePages, 5));
|
|
20
|
+
const min = 1;
|
|
21
|
+
// the center part of the range starts with the current page minus half of the visible pages
|
|
22
|
+
let centerStartPage = currentPage - Math.floor(visiblePages / 2);
|
|
23
|
+
// centerStartPage has a lower limit of 1
|
|
24
|
+
centerStartPage = Math.max(centerStartPage, min);
|
|
25
|
+
// centerStartPage has an upper limit of 1 plus total pages minus visible pages
|
|
26
|
+
centerStartPage = Math.min(centerStartPage, min + totalPages - visiblePages);
|
|
27
|
+
const pages = Array.from({ length: visiblePages }, (_el, i) => centerStartPage + i).reduce((acc, pageNr, index) => {
|
|
28
|
+
if (index === 0 && pageNr !== 1) {
|
|
29
|
+
return [1, 'firstSpacer'];
|
|
30
|
+
}
|
|
31
|
+
if (totalPages > visiblePages && index === visiblePages - 2 && currentPage < totalPages - 2) {
|
|
32
|
+
return [...acc, 'lastSpacer', totalPages];
|
|
33
|
+
}
|
|
34
|
+
// Skip a number when spacer is already added
|
|
35
|
+
if ((acc.includes('firstSpacer') && index === 1) || (acc.includes('lastSpacer') && index === visiblePages - 1)) {
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
return [...acc, pageNr];
|
|
39
|
+
}, []);
|
|
40
|
+
return pages;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Pagination } from './Pagination';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license EUPL-1.2+
|
|
3
|
+
* Copyright (c) 2021 Robbert Broersma
|
|
4
|
+
* Copyright Gemeente Amsterdam
|
|
5
|
+
*/
|
|
6
|
+
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
7
|
+
export type ParagraphProps = {
|
|
8
|
+
/** Changes the text colour for readability on a dark background. */
|
|
9
|
+
color?: 'inverse';
|
|
10
|
+
/** The size of the text. */
|
|
11
|
+
size?: 'small' | 'large';
|
|
12
|
+
} & PropsWithChildren<HTMLAttributes<HTMLParagraphElement>>;
|
|
13
|
+
export declare const Paragraph: import("react").ForwardRefExoticComponent<{
|
|
14
|
+
/** Changes the text colour for readability on a dark background. */
|
|
15
|
+
color?: "inverse";
|
|
16
|
+
/** The size of the text. */
|
|
17
|
+
size?: "small" | "large";
|
|
18
|
+
} & HTMLAttributes<HTMLParagraphElement> & {
|
|
19
|
+
children?: import("react").ReactNode | undefined;
|
|
20
|
+
} & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license EUPL-1.2+
|
|
4
|
+
* Copyright (c) 2021 Robbert Broersma
|
|
5
|
+
* Copyright Gemeente Amsterdam
|
|
6
|
+
*/
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { forwardRef } from 'react';
|
|
9
|
+
export const Paragraph = forwardRef(({ children, className, color, size, ...restProps }, ref) => (_jsx("p", { className: clsx('ams-paragraph', color && `ams-paragraph--${color}`, size && `ams-paragraph--${size}`, className), ref: ref, ...restProps, children: children })));
|
|
10
|
+
Paragraph.displayName = 'Paragraph';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { createRef } from 'react';
|
|
4
|
+
import { Paragraph } from './Paragraph';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
describe('Paragraph', () => {
|
|
7
|
+
it('renders an HTML p element', () => {
|
|
8
|
+
const { container } = render(_jsx(Paragraph, {}));
|
|
9
|
+
const paragraph = container.querySelector('p:only-child');
|
|
10
|
+
expect(paragraph).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
it('renders a block element', () => {
|
|
13
|
+
const { container } = render(_jsx(Paragraph, {}));
|
|
14
|
+
const paragraph = container.querySelector(':only-child');
|
|
15
|
+
expect(paragraph).toHaveStyle({ display: 'block' });
|
|
16
|
+
});
|
|
17
|
+
it('renders a design system BEM class name', () => {
|
|
18
|
+
const { container } = render(_jsx(Paragraph, {}));
|
|
19
|
+
const paragraph = container.querySelector(':only-child');
|
|
20
|
+
expect(paragraph).toHaveClass('ams-paragraph');
|
|
21
|
+
});
|
|
22
|
+
it('renders rich text content', () => {
|
|
23
|
+
const { container } = render(_jsxs(Paragraph, { children: ["Hello, ", _jsx("strong", { children: "world" })] }));
|
|
24
|
+
const paragraph = container.querySelector(':only-child');
|
|
25
|
+
const richText = paragraph?.querySelector('strong');
|
|
26
|
+
expect(richText).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
it('is a default paragraph without specifying props', () => {
|
|
29
|
+
const { container } = render(_jsx(Paragraph, {}));
|
|
30
|
+
const paragraph = container.querySelector(':only-child');
|
|
31
|
+
expect(paragraph).not.toHaveClass('ams-paragraph--large');
|
|
32
|
+
expect(paragraph).not.toHaveClass('ams-paragraph--small');
|
|
33
|
+
});
|
|
34
|
+
it('renders the right size classes', () => {
|
|
35
|
+
render(_jsxs(_Fragment, { children: [_jsx(Paragraph, { size: "small", children: "Small paragraph" }), _jsx(Paragraph, { size: "large", children: "Large paragraph" })] }));
|
|
36
|
+
const smallParagraph = screen.getByText('Small paragraph');
|
|
37
|
+
const largeParagraph = screen.getByText('Large paragraph');
|
|
38
|
+
expect(smallParagraph).toHaveClass('ams-paragraph--small');
|
|
39
|
+
expect(largeParagraph).toHaveClass('ams-paragraph--large');
|
|
40
|
+
});
|
|
41
|
+
it('renders the class name for inverse color', () => {
|
|
42
|
+
render(_jsx(Paragraph, { color: "inverse", children: "Paragraph" }));
|
|
43
|
+
const paragraph = screen.getByText('Paragraph');
|
|
44
|
+
expect(paragraph).toHaveClass('ams-paragraph--inverse');
|
|
45
|
+
});
|
|
46
|
+
it('renders an additional class name', () => {
|
|
47
|
+
const { container } = render(_jsx(Paragraph, { className: "intro" }));
|
|
48
|
+
const paragraph = container.querySelector(':only-child');
|
|
49
|
+
expect(paragraph).toHaveClass('intro');
|
|
50
|
+
expect(paragraph).toHaveClass('ams-paragraph');
|
|
51
|
+
});
|
|
52
|
+
it('supports ForwardRef in React', () => {
|
|
53
|
+
const ref = createRef();
|
|
54
|
+
const { container } = render(_jsx(Paragraph, { ref: ref }));
|
|
55
|
+
const paragraph = container.querySelector(':only-child');
|
|
56
|
+
expect(ref.current).toBe(paragraph);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Paragraph } from './Paragraph';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license EUPL-1.2+
|
|
3
|
+
* Copyright Gemeente Amsterdam
|
|
4
|
+
*/
|
|
5
|
+
import type { InputHTMLAttributes } from 'react';
|
|
6
|
+
export type PasswordInputProps = {
|
|
7
|
+
/** Whether the value fails a validation rule. */
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'aria-invalid' | 'autoCapitalize' | 'autoCorrect' | 'spellCheck' | 'type'>;
|
|
10
|
+
export declare const PasswordInput: import("react").ForwardRefExoticComponent<{
|
|
11
|
+
/** Whether the value fails a validation rule. */
|
|
12
|
+
invalid?: boolean;
|
|
13
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "autoCapitalize" | "spellCheck" | "autoCorrect" | "aria-invalid" | "type"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license EUPL-1.2+
|
|
4
|
+
* Copyright Gemeente Amsterdam
|
|
5
|
+
*/
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
export const PasswordInput = forwardRef(({ className, dir, invalid, ...restProps }, ref) => (_jsx("input", { ...restProps, "aria-invalid": invalid || undefined, autoCorrect: "off", className: clsx('ams-password-input', className), dir: dir ?? 'auto', ref: ref, spellCheck: "false", type: "password" })));
|
|
9
|
+
PasswordInput.displayName = 'PasswordInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { createRef, useState } from 'react';
|
|
5
|
+
import { PasswordInput } from './PasswordInput';
|
|
6
|
+
import { Label } from '../Label';
|
|
7
|
+
import '@testing-library/jest-dom';
|
|
8
|
+
describe('Password input', () => {
|
|
9
|
+
it('renders', () => {
|
|
10
|
+
const { container } = render(_jsx(PasswordInput, {}));
|
|
11
|
+
const component = container.querySelector(':only-child');
|
|
12
|
+
expect(component).toBeInTheDocument();
|
|
13
|
+
expect(component).toBeVisible();
|
|
14
|
+
});
|
|
15
|
+
it('renders a design system BEM class name', () => {
|
|
16
|
+
const { container } = render(_jsx(PasswordInput, {}));
|
|
17
|
+
const component = container.querySelector(':only-child');
|
|
18
|
+
expect(component).toHaveClass('ams-password-input');
|
|
19
|
+
});
|
|
20
|
+
it('renders an additional class name', () => {
|
|
21
|
+
const { container } = render(_jsx(PasswordInput, { className: "extra" }));
|
|
22
|
+
const component = container.querySelector(':only-child');
|
|
23
|
+
expect(component).toHaveClass('ams-password-input extra');
|
|
24
|
+
});
|
|
25
|
+
it('renders two attributes for privacy', () => {
|
|
26
|
+
const { container } = render(_jsx(PasswordInput, {}));
|
|
27
|
+
const component = container.querySelector(':only-child');
|
|
28
|
+
expect(component).toHaveAttribute('autocorrect', 'off');
|
|
29
|
+
expect(component).toHaveAttribute('spellcheck', 'false');
|
|
30
|
+
});
|
|
31
|
+
it('should be working in a controlled state', async () => {
|
|
32
|
+
function ControlledComponent() {
|
|
33
|
+
const [value, setValue] = useState('Hello');
|
|
34
|
+
return _jsx(PasswordInput, { onChange: (e) => setValue(e.target.value), value: value });
|
|
35
|
+
}
|
|
36
|
+
const { container } = render(_jsx(ControlledComponent, {}));
|
|
37
|
+
const componentText = screen.getByDisplayValue('Hello');
|
|
38
|
+
expect(componentText).toBeInTheDocument();
|
|
39
|
+
const component = container.querySelector(':only-child');
|
|
40
|
+
if (component) {
|
|
41
|
+
await userEvent.type(component, ', World!');
|
|
42
|
+
}
|
|
43
|
+
const newComponentText = screen.getByDisplayValue('Hello, World!');
|
|
44
|
+
expect(newComponentText).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
it('should not update the value when disabled', async () => {
|
|
47
|
+
const { container } = render(_jsx(PasswordInput, { defaultValue: "Hello", disabled: true }));
|
|
48
|
+
const component = container.querySelector(':only-child');
|
|
49
|
+
if (component) {
|
|
50
|
+
await userEvent.type(component, ', World!');
|
|
51
|
+
}
|
|
52
|
+
expect(component).toHaveValue('Hello');
|
|
53
|
+
});
|
|
54
|
+
it('supports ForwardRef in React', () => {
|
|
55
|
+
const ref = createRef();
|
|
56
|
+
const { container } = render(_jsx(PasswordInput, { ref: ref }));
|
|
57
|
+
const component = container.querySelector(':only-child');
|
|
58
|
+
expect(ref.current).toBe(component);
|
|
59
|
+
});
|
|
60
|
+
describe('Invalid state', () => {
|
|
61
|
+
it('is not invalid by default', () => {
|
|
62
|
+
const { container } = render(_jsx(PasswordInput, {}));
|
|
63
|
+
const component = container.querySelector(':only-child');
|
|
64
|
+
expect(component).not.toBeInvalid();
|
|
65
|
+
});
|
|
66
|
+
it('can have an invalid state', () => {
|
|
67
|
+
const { container } = render(_jsx(PasswordInput, { invalid: true }));
|
|
68
|
+
const component = container.querySelector(':only-child');
|
|
69
|
+
expect(component).toHaveAttribute('aria-invalid');
|
|
70
|
+
expect(component).toBeInvalid();
|
|
71
|
+
});
|
|
72
|
+
it('omits non-essential invalid attributes when not invalid', () => {
|
|
73
|
+
const { container } = render(_jsx(PasswordInput, { invalid: false }));
|
|
74
|
+
const component = container.querySelector(':only-child');
|
|
75
|
+
expect(component).not.toHaveAttribute('aria-invalid');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('Type', () => {
|
|
79
|
+
it('sets the ‘password’ type', () => {
|
|
80
|
+
render(_jsxs(_Fragment, { children: [_jsx(Label, { htmlFor: "password-field", children: "Password" }), _jsx(PasswordInput, { id: "password-field" })] }));
|
|
81
|
+
const component = screen.getByLabelText(/password/i);
|
|
82
|
+
expect(component).toHaveAttribute('type', 'password');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PasswordInput } from './PasswordInput';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license EUPL-1.2+
|
|
3
|
+
* Copyright Gemeente Amsterdam
|
|
4
|
+
*/
|
|
5
|
+
import type { InputHTMLAttributes, PropsWithChildren, ReactNode } from 'react';
|
|
6
|
+
export type RadioProps = {
|
|
7
|
+
/** An icon to display instead of the default icon. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Whether the value fails a validation rule. */
|
|
10
|
+
invalid?: boolean;
|
|
11
|
+
} & PropsWithChildren<Omit<InputHTMLAttributes<HTMLInputElement>, 'aria-invalid' | 'type'>>;
|
|
12
|
+
export declare const Radio: import("react").ForwardRefExoticComponent<{
|
|
13
|
+
/** An icon to display instead of the default icon. */
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
/** Whether the value fails a validation rule. */
|
|
16
|
+
invalid?: boolean;
|
|
17
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "aria-invalid" | "type"> & {
|
|
18
|
+
children?: ReactNode | undefined;
|
|
19
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license EUPL-1.2+
|
|
4
|
+
* Copyright Gemeente Amsterdam
|
|
5
|
+
*/
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { forwardRef, useId } from 'react';
|
|
8
|
+
import RadioIcon from './RadioIcon';
|
|
9
|
+
export const Radio = forwardRef(({ children, className, icon, invalid, ...restProps }, ref) => {
|
|
10
|
+
const id = useId();
|
|
11
|
+
return (
|
|
12
|
+
// This div is here because NVDA doesn't match the input to the label
|
|
13
|
+
// without a containing element
|
|
14
|
+
_jsxs("div", { className: clsx('ams-radio', className), children: [_jsx("input", { ...restProps, "aria-invalid": invalid || undefined, className: "ams-radio__input", id: id, ref: ref, type: "radio" }), _jsxs("label", { className: "ams-radio__label", htmlFor: id, children: [_jsx("span", { className: "ams-radio__icon-container", children: icon ?? _jsx(RadioIcon, {}) }), children] })] }));
|
|
15
|
+
});
|
|
16
|
+
Radio.displayName = 'Radio';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FavouriteIcon } from '@amsterdam/design-system-react-icons';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { createRef } from 'react';
|
|
5
|
+
import { Radio } from './Radio';
|
|
6
|
+
import '@testing-library/jest-dom';
|
|
7
|
+
describe('Radio', () => {
|
|
8
|
+
it('renders', () => {
|
|
9
|
+
const { container } = render(_jsx(Radio, {}));
|
|
10
|
+
const wrapper = container.querySelector(':only-child');
|
|
11
|
+
const input = screen.getByRole('radio');
|
|
12
|
+
const label = container.querySelector('label');
|
|
13
|
+
expect(wrapper).toBeInTheDocument();
|
|
14
|
+
expect(wrapper).toBeVisible();
|
|
15
|
+
expect(input).toBeInTheDocument();
|
|
16
|
+
expect(input).toBeVisible();
|
|
17
|
+
expect(label).toBeInTheDocument();
|
|
18
|
+
expect(label).toBeVisible();
|
|
19
|
+
});
|
|
20
|
+
it('renders design system BEM class names', () => {
|
|
21
|
+
const { container } = render(_jsx(Radio, {}));
|
|
22
|
+
const wrapper = container.querySelector(':only-child');
|
|
23
|
+
const input = screen.getByRole('radio');
|
|
24
|
+
const label = container.querySelector('label');
|
|
25
|
+
const circle = container.querySelector('.ams-radio__circle');
|
|
26
|
+
const indicator = container.querySelector('.ams-radio__checked-indicator');
|
|
27
|
+
expect(wrapper).toHaveClass('ams-radio');
|
|
28
|
+
expect(input).toHaveClass('ams-radio__input');
|
|
29
|
+
expect(label).toHaveClass('ams-radio__label');
|
|
30
|
+
expect(circle).toBeInTheDocument();
|
|
31
|
+
expect(indicator).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('renders an additional class name', () => {
|
|
34
|
+
const { container } = render(_jsx(Radio, { className: "extra" }));
|
|
35
|
+
const wrapper = container.querySelector(':only-child');
|
|
36
|
+
expect(wrapper).toHaveClass('ams-radio extra');
|
|
37
|
+
});
|
|
38
|
+
describe('Checked state', () => {
|
|
39
|
+
it('is not checked by default', () => {
|
|
40
|
+
render(_jsx(Radio, {}));
|
|
41
|
+
const input = screen.getByRole('radio');
|
|
42
|
+
expect(input).not.toBeChecked();
|
|
43
|
+
});
|
|
44
|
+
it('can have a checked state', () => {
|
|
45
|
+
const handleChange = () => { };
|
|
46
|
+
render(_jsx(Radio, { checked: true, onChange: handleChange }));
|
|
47
|
+
const input = screen.getByRole('radio');
|
|
48
|
+
expect(input).toBeChecked();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('Invalid state', () => {
|
|
52
|
+
it('is not invalid by default', () => {
|
|
53
|
+
render(_jsx(Radio, {}));
|
|
54
|
+
const input = screen.getByRole('radio');
|
|
55
|
+
expect(input).not.toBeInvalid();
|
|
56
|
+
});
|
|
57
|
+
it('can have an invalid state', () => {
|
|
58
|
+
render(_jsx(Radio, { invalid: true }));
|
|
59
|
+
const input = screen.getByRole('radio');
|
|
60
|
+
expect(input).toHaveAttribute('aria-invalid');
|
|
61
|
+
expect(input).toBeInvalid();
|
|
62
|
+
});
|
|
63
|
+
it('omits non-essential invalid attributes when not invalid', () => {
|
|
64
|
+
render(_jsx(Radio, { invalid: false }));
|
|
65
|
+
const input = screen.getByRole('radio');
|
|
66
|
+
expect(input).not.toHaveAttribute('aria-invalid');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('Disabled state', () => {
|
|
70
|
+
it('is not disabled by default', () => {
|
|
71
|
+
render(_jsx(Radio, {}));
|
|
72
|
+
const input = screen.getByRole('radio');
|
|
73
|
+
expect(input).not.toBeDisabled();
|
|
74
|
+
});
|
|
75
|
+
it('can have a disabled state', () => {
|
|
76
|
+
render(_jsx(Radio, { disabled: true }));
|
|
77
|
+
const input = screen.getByRole('radio');
|
|
78
|
+
expect(input).toBeDisabled();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('Disabled invalid state', () => {
|
|
82
|
+
it('can have a disabled invalid state', () => {
|
|
83
|
+
render(_jsx(Radio, { disabled: true, invalid: true }));
|
|
84
|
+
const input = screen.getByRole('radio');
|
|
85
|
+
expect(input).toBeDisabled();
|
|
86
|
+
expect(input).toBeInvalid();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
it('can trigger a change event', () => {
|
|
90
|
+
const handleChange = jest.fn();
|
|
91
|
+
render(_jsx(Radio, { onChange: handleChange }));
|
|
92
|
+
const input = screen.getByRole('radio');
|
|
93
|
+
input?.click();
|
|
94
|
+
expect(handleChange).toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
it('does not trigger a change event when disabled', () => {
|
|
97
|
+
const handleChange = jest.fn();
|
|
98
|
+
render(_jsx(Radio, { disabled: true, onChange: handleChange }));
|
|
99
|
+
const input = screen.getByRole('radio');
|
|
100
|
+
input?.click();
|
|
101
|
+
expect(handleChange).not.toHaveBeenCalled();
|
|
102
|
+
});
|
|
103
|
+
it('can trigger a change event by clicking on label', () => {
|
|
104
|
+
const handleChange = jest.fn();
|
|
105
|
+
const { container } = render(_jsx(Radio, { onChange: handleChange }));
|
|
106
|
+
const label = container.querySelector('label');
|
|
107
|
+
label?.click();
|
|
108
|
+
expect(handleChange).toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
it('shows a custom icon', () => {
|
|
111
|
+
const { container } = render(_jsx(Radio, { icon: _jsx(FavouriteIcon, { className: "test-class" }) }));
|
|
112
|
+
const icon = container.querySelector('svg');
|
|
113
|
+
expect(icon).toHaveClass('test-class');
|
|
114
|
+
});
|
|
115
|
+
it('supports ForwardRef in React', () => {
|
|
116
|
+
const ref = createRef();
|
|
117
|
+
render(_jsx(Radio, { ref: ref }));
|
|
118
|
+
const input = screen.getByRole('radio');
|
|
119
|
+
expect(ref.current).toBe(input);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const SvgRadio = (props) => (_jsxs("svg", { "aria-hidden": "true", focusable: "false", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: [_jsx("circle", { className: "ams-radio__circle", cx: 12, cy: 12, r: 10 }), _jsx("circle", { className: "ams-radio__hover-indicator", cx: 12, cy: 12, r: 9.5 }), _jsx("circle", { className: "ams-radio__checked-indicator", cx: 12, cy: 12, r: 6 })] }));
|
|
3
|
+
export default SvgRadio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Radio } from './Radio';
|