@simplybusiness/mobius 10.2.0 → 10.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/components/AddressLookup/AddressLookup.js +426 -343
- package/dist/cjs/components/AddressLookup/AddressLookup.js.map +4 -4
- package/dist/cjs/components/AddressLookup/index.js +426 -343
- package/dist/cjs/components/AddressLookup/index.js.map +4 -4
- package/dist/cjs/components/Alert/Alert.js +47 -18
- package/dist/cjs/components/Alert/Alert.js.map +3 -3
- package/dist/cjs/components/Alert/index.js +47 -18
- package/dist/cjs/components/Alert/index.js.map +3 -3
- package/dist/cjs/components/Box/Box.js +18 -3
- package/dist/cjs/components/Box/Box.js.map +3 -3
- package/dist/cjs/components/Box/index.js +18 -3
- package/dist/cjs/components/Box/index.js.map +3 -3
- package/dist/cjs/components/Breadcrumbs/BreadcrumbItem.js +18 -3
- package/dist/cjs/components/Breadcrumbs/BreadcrumbItem.js.map +3 -3
- package/dist/cjs/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/cjs/components/Breadcrumbs/index.js +18 -3
- package/dist/cjs/components/Breadcrumbs/index.js.map +3 -3
- package/dist/cjs/components/Checkbox/Checkbox.js +370 -287
- package/dist/cjs/components/Checkbox/Checkbox.js.map +4 -4
- package/dist/cjs/components/Checkbox/CheckboxGroup.js +375 -292
- package/dist/cjs/components/Checkbox/CheckboxGroup.js.map +4 -4
- package/dist/cjs/components/Checkbox/index.js +382 -299
- package/dist/cjs/components/Checkbox/index.js.map +4 -4
- package/dist/cjs/components/Combobox/Combobox.js +421 -338
- package/dist/cjs/components/Combobox/Combobox.js.map +4 -4
- package/dist/cjs/components/Combobox/index.js +421 -338
- package/dist/cjs/components/Combobox/index.js.map +4 -4
- package/dist/cjs/components/DateField/DateField.js +386 -303
- package/dist/cjs/components/DateField/DateField.js.map +4 -4
- package/dist/cjs/components/DateField/index.js +386 -303
- package/dist/cjs/components/DateField/index.js.map +4 -4
- package/dist/cjs/components/ErrorMessage/ErrorMessage.js +363 -280
- package/dist/cjs/components/ErrorMessage/ErrorMessage.js.map +4 -4
- package/dist/cjs/components/ErrorMessage/index.js +363 -280
- package/dist/cjs/components/ErrorMessage/index.js.map +4 -4
- package/dist/cjs/components/ExpandableText/ExpandableText.js +360 -277
- package/dist/cjs/components/ExpandableText/ExpandableText.js.map +4 -4
- package/dist/cjs/components/ExpandableText/index.js +360 -277
- package/dist/cjs/components/ExpandableText/index.js.map +4 -4
- package/dist/cjs/components/Grid/Grid.js +2 -2
- package/dist/cjs/components/Grid/Grid.js.map +2 -2
- package/dist/cjs/components/Grid/Item.js +3 -3
- package/dist/cjs/components/Grid/Item.js.map +2 -2
- package/dist/cjs/components/Grid/index.js +5 -5
- package/dist/cjs/components/Grid/index.js.map +2 -2
- package/dist/cjs/components/List/List.js +15 -7
- package/dist/cjs/components/List/List.js.map +2 -2
- package/dist/cjs/components/List/index.js +15 -7
- package/dist/cjs/components/List/index.js.map +2 -2
- package/dist/cjs/components/Logo/Logo.js.map +2 -2
- package/dist/cjs/components/Logo/index.js.map +2 -2
- package/dist/cjs/components/MaskedField/MaskedField.js +381 -298
- package/dist/cjs/components/MaskedField/MaskedField.js.map +4 -4
- package/dist/cjs/components/MaskedField/index.js +381 -298
- package/dist/cjs/components/MaskedField/index.js.map +4 -4
- package/dist/cjs/components/Modal/Header.js +38 -21
- package/dist/cjs/components/Modal/Header.js.map +3 -3
- package/dist/cjs/components/Modal/Modal.js +13 -3
- package/dist/cjs/components/Modal/Modal.js.map +2 -2
- package/dist/cjs/components/Modal/ModalContext.js +4 -1
- package/dist/cjs/components/Modal/ModalContext.js.map +2 -2
- package/dist/cjs/components/Modal/index.js +63 -39
- package/dist/cjs/components/Modal/index.js.map +3 -3
- package/dist/cjs/components/Modal/types.js.map +1 -1
- package/dist/cjs/components/Modal/useModal.js +6 -3
- package/dist/cjs/components/Modal/useModal.js.map +2 -2
- package/dist/cjs/components/NumberField/NumberField.js +381 -298
- package/dist/cjs/components/NumberField/NumberField.js.map +4 -4
- package/dist/cjs/components/NumberField/index.js +381 -298
- package/dist/cjs/components/NumberField/index.js.map +4 -4
- package/dist/cjs/components/PasswordField/PasswordField.js +381 -298
- package/dist/cjs/components/PasswordField/PasswordField.js.map +4 -4
- package/dist/cjs/components/PasswordField/ShowHideButton.js +360 -277
- package/dist/cjs/components/PasswordField/ShowHideButton.js.map +4 -4
- package/dist/cjs/components/PasswordField/index.js +381 -298
- package/dist/cjs/components/PasswordField/index.js.map +4 -4
- package/dist/cjs/components/Radio/Radio.js +363 -280
- package/dist/cjs/components/Radio/Radio.js.map +4 -4
- package/dist/cjs/components/Radio/RadioGroup.js +363 -280
- package/dist/cjs/components/Radio/RadioGroup.js.map +4 -4
- package/dist/cjs/components/Radio/index.js +363 -280
- package/dist/cjs/components/Radio/index.js.map +4 -4
- package/dist/cjs/components/SVG/SVG.js.map +2 -2
- package/dist/cjs/components/SVG/index.js.map +2 -2
- package/dist/cjs/components/Segment/Segment.js +2 -2
- package/dist/cjs/components/Segment/Segment.js.map +2 -2
- package/dist/cjs/components/Segment/index.js +2 -2
- package/dist/cjs/components/Segment/index.js.map +2 -2
- package/dist/cjs/components/Select/Select.js +363 -280
- package/dist/cjs/components/Select/Select.js.map +4 -4
- package/dist/cjs/components/Select/index.js +363 -280
- package/dist/cjs/components/Select/index.js.map +4 -4
- package/dist/cjs/components/Table/HeaderCell.js +2 -2
- package/dist/cjs/components/Table/HeaderCell.js.map +2 -2
- package/dist/cjs/components/Table/index.js +2 -2
- package/dist/cjs/components/Table/index.js.map +2 -2
- package/dist/cjs/components/Text/Text.js +12 -8
- package/dist/cjs/components/Text/Text.js.map +2 -2
- package/dist/cjs/components/Text/index.js +12 -8
- package/dist/cjs/components/Text/index.js.map +2 -2
- package/dist/cjs/components/TextArea/TextArea.js +363 -280
- package/dist/cjs/components/TextArea/TextArea.js.map +4 -4
- package/dist/cjs/components/TextArea/index.js +363 -280
- package/dist/cjs/components/TextArea/index.js.map +4 -4
- package/dist/cjs/components/TextField/TextField.js +381 -298
- package/dist/cjs/components/TextField/TextField.js.map +4 -4
- package/dist/cjs/components/TextField/index.js +381 -298
- package/dist/cjs/components/TextField/index.js.map +4 -4
- package/dist/cjs/components/TextOrHTML/TextOrHTML.js +42 -13
- package/dist/cjs/components/TextOrHTML/TextOrHTML.js.map +3 -3
- package/dist/cjs/components/TextOrHTML/index.js +42 -13
- package/dist/cjs/components/TextOrHTML/index.js.map +3 -3
- package/dist/cjs/components/index.js +396 -312
- package/dist/cjs/components/index.js.map +4 -4
- package/dist/cjs/index.js +396 -312
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/meta.json +1063 -578
- package/dist/cjs/utils/filterUnsetValues.js +36 -0
- package/dist/cjs/utils/filterUnsetValues.js.map +7 -0
- package/dist/cjs/utils/index.js +13 -0
- package/dist/cjs/utils/index.js.map +3 -3
- package/dist/esm/{chunk-NYFCN7EA.js → chunk-6GGDGE7D.js} +4 -4
- package/dist/esm/{chunk-OUKMP3DO.js → chunk-7JT4DKQA.js} +2 -2
- package/dist/esm/{chunk-SNRPWCHL.js → chunk-A66R42LG.js} +12 -8
- package/dist/esm/chunk-A66R42LG.js.map +7 -0
- package/dist/esm/chunk-CZWEMAKZ.js +16 -0
- package/dist/esm/chunk-CZWEMAKZ.js.map +7 -0
- package/dist/esm/{chunk-Q5YY6HPF.js → chunk-DZVBN6ZI.js} +5 -5
- package/dist/esm/{chunk-OC6ULO4M.js → chunk-EJLNC5X5.js} +2 -2
- package/dist/esm/{chunk-LVZ2T6AY.js → chunk-EZ4S7XVZ.js} +16 -8
- package/dist/esm/chunk-EZ4S7XVZ.js.map +7 -0
- package/dist/esm/chunk-FIAL4HTE.js +1 -0
- package/dist/esm/{chunk-YLL2DKVF.js → chunk-FQ6P6JB5.js} +3 -3
- package/dist/esm/chunk-FQ6P6JB5.js.map +7 -0
- package/dist/esm/{chunk-OZ2IUZIJ.js → chunk-HP2NRM7T.js} +2 -2
- package/dist/esm/chunk-HPUPB75I.js +67 -0
- package/dist/esm/chunk-HPUPB75I.js.map +7 -0
- package/dist/esm/{chunk-3IMYDZRT.js → chunk-JFDDW3IV.js} +1 -1
- package/dist/esm/chunk-JFDDW3IV.js.map +7 -0
- package/dist/esm/{chunk-4IB5ROL6.js → chunk-KXLTGNKF.js} +12 -5
- package/dist/esm/chunk-KXLTGNKF.js.map +7 -0
- package/dist/esm/{chunk-TL4OCKNP.js → chunk-LWRY3VIB.js} +2 -2
- package/dist/esm/{chunk-RR4UQSOZ.js → chunk-M7LTJZQU.js} +11 -11
- package/dist/esm/chunk-MPB5F6QL.js +53 -0
- package/dist/esm/chunk-MPB5F6QL.js.map +7 -0
- package/dist/esm/{chunk-N5WGQAHM.js → chunk-NRU3WNV7.js} +4 -4
- package/dist/esm/{chunk-DNMS6KEY.js → chunk-PARKMZYZ.js} +4 -4
- package/dist/esm/{chunk-DNMS6KEY.js.map → chunk-PARKMZYZ.js.map} +2 -2
- package/dist/esm/chunk-Q5MIALGZ.js +15 -0
- package/dist/esm/{chunk-ZHX7Z5IU.js.map → chunk-Q5MIALGZ.js.map} +2 -2
- package/dist/esm/{chunk-KLXMVFIR.js → chunk-TBKQA5ZF.js} +5 -2
- package/dist/esm/{chunk-KLXMVFIR.js.map → chunk-TBKQA5ZF.js.map} +2 -2
- package/dist/esm/{chunk-B243ELKZ.js → chunk-TJCUKTFX.js} +10 -4
- package/dist/esm/chunk-TJCUKTFX.js.map +7 -0
- package/dist/esm/{chunk-P5ZPHAQT.js → chunk-UCNWPF7R.js} +3 -3
- package/dist/esm/chunk-UCNWPF7R.js.map +7 -0
- package/dist/esm/{chunk-S37ULE57.js → chunk-VASDBM4Z.js} +1 -1
- package/dist/esm/{chunk-S37ULE57.js.map → chunk-VASDBM4Z.js.map} +2 -2
- package/dist/esm/{chunk-SDGIWQ3R.js → chunk-WP5OEMNG.js} +3 -3
- package/dist/esm/{chunk-SDGIWQ3R.js.map → chunk-WP5OEMNG.js.map} +2 -2
- package/dist/esm/{chunk-MLN5ELQR.js → chunk-WXRQIMMM.js} +1 -1
- package/dist/esm/chunk-WXRQIMMM.js.map +7 -0
- package/dist/esm/{chunk-O47IW7HD.js → chunk-YCE2KOB2.js} +5 -5
- package/dist/esm/components/Accordion/Accordion.js +7 -6
- package/dist/esm/components/Accordion/AccordionLink.js +6 -5
- package/dist/esm/components/Accordion/AccordionList.js +8 -7
- package/dist/esm/components/Accordion/index.js +8 -7
- package/dist/esm/components/AddressLookup/AddressLookup.js +41 -40
- package/dist/esm/components/AddressLookup/__mocks__/LoqateAddressLookupService.js +2 -1
- package/dist/esm/components/AddressLookup/__mocks__/LoqateAddressLookupService.js.map +1 -1
- package/dist/esm/components/AddressLookup/index.js +41 -40
- package/dist/esm/components/Alert/Alert.js +4 -4
- package/dist/esm/components/Alert/index.js +4 -4
- package/dist/esm/components/Box/Box.js +3 -2
- package/dist/esm/components/Box/index.js +3 -2
- package/dist/esm/components/Breadcrumbs/BreadcrumbItem.js +4 -3
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/esm/components/Breadcrumbs/index.js +7 -6
- package/dist/esm/components/Checkbox/Checkbox.js +41 -40
- package/dist/esm/components/Checkbox/CheckboxGroup.js +41 -40
- package/dist/esm/components/Checkbox/index.js +41 -40
- package/dist/esm/components/Combobox/Combobox.js +41 -40
- package/dist/esm/components/Combobox/index.js +41 -40
- package/dist/esm/components/Container/Container.js +2 -1
- package/dist/esm/components/Container/index.js +2 -1
- package/dist/esm/components/DateField/DateField.js +41 -40
- package/dist/esm/components/DateField/index.js +41 -40
- package/dist/esm/components/Drawer/Drawer.js +4 -3
- package/dist/esm/components/Drawer/index.js +4 -3
- package/dist/esm/components/ErrorMessage/ErrorMessage.js +41 -40
- package/dist/esm/components/ErrorMessage/index.js +41 -40
- package/dist/esm/components/ExpandableText/ExpandableText.js +41 -40
- package/dist/esm/components/ExpandableText/index.js +41 -40
- package/dist/esm/components/Fieldset/Fieldset.js +2 -1
- package/dist/esm/components/Fieldset/index.js +2 -1
- package/dist/esm/components/Flex/Flex.js +2 -1
- package/dist/esm/components/Flex/index.js +2 -1
- package/dist/esm/components/Flex/propUtils.js +2 -1
- package/dist/esm/components/Grid/Grid.js +3 -2
- package/dist/esm/components/Grid/Item.js +5 -4
- package/dist/esm/components/Grid/index.js +7 -6
- package/dist/esm/components/List/List.js +1 -1
- package/dist/esm/components/List/index.js +1 -1
- package/dist/esm/components/Logo/Logo.js +1 -1
- package/dist/esm/components/Logo/index.js +1 -1
- package/dist/esm/components/MaskedField/MaskedField.js +41 -40
- package/dist/esm/components/MaskedField/MaskedField.js.map +1 -1
- package/dist/esm/components/MaskedField/index.js +41 -40
- package/dist/esm/components/Modal/Header.js +3 -3
- package/dist/esm/components/Modal/Modal.js +6 -5
- package/dist/esm/components/Modal/ModalContext.js +1 -1
- package/dist/esm/components/Modal/index.js +10 -9
- package/dist/esm/components/Modal/useModal.js +2 -2
- package/dist/esm/components/NumberField/NumberField.js +41 -40
- package/dist/esm/components/NumberField/index.js +41 -40
- package/dist/esm/components/PasswordField/PasswordField.js +41 -40
- package/dist/esm/components/PasswordField/ShowHideButton.js +41 -40
- package/dist/esm/components/PasswordField/index.js +41 -40
- package/dist/esm/components/Radio/Radio.js +41 -40
- package/dist/esm/components/Radio/RadioGroup.js +41 -40
- package/dist/esm/components/Radio/index.js +41 -40
- package/dist/esm/components/SVG/SVG.js +1 -1
- package/dist/esm/components/SVG/index.js +1 -1
- package/dist/esm/components/Segment/Segment.js +1 -1
- package/dist/esm/components/Segment/index.js +1 -1
- package/dist/esm/components/Select/Select.js +41 -40
- package/dist/esm/components/Select/index.js +41 -40
- package/dist/esm/components/Slider/Slider.js +4 -3
- package/dist/esm/components/Slider/index.js +4 -3
- package/dist/esm/components/Table/HeaderCell.js +1 -1
- package/dist/esm/components/Table/index.js +2 -2
- package/dist/esm/components/Text/Text.js +5 -3
- package/dist/esm/components/Text/index.js +5 -3
- package/dist/esm/components/TextArea/TextArea.js +41 -40
- package/dist/esm/components/TextArea/index.js +41 -40
- package/dist/esm/components/TextField/TextField.js +41 -40
- package/dist/esm/components/TextField/index.js +41 -40
- package/dist/esm/components/TextOrHTML/TextOrHTML.js +2 -2
- package/dist/esm/components/TextOrHTML/index.js +2 -2
- package/dist/esm/components/Title/Title.js +2 -1
- package/dist/esm/components/Title/index.js +2 -1
- package/dist/esm/components/Toast/index.js +3 -3
- package/dist/esm/components/Trust/Trust.js +2 -1
- package/dist/esm/components/Trust/index.js +2 -1
- package/dist/esm/components/index.js +57 -54
- package/dist/esm/hooks/index.js +6 -5
- package/dist/esm/hooks/useDialog/index.js +2 -1
- package/dist/esm/hooks/useDialog/useDialog.js +2 -1
- package/dist/esm/hooks/useDialogPolyfill/index.js +2 -1
- package/dist/esm/hooks/useDialogPolyfill/useDialogPolyfill.js +2 -1
- package/dist/esm/index.js +59 -56
- package/dist/esm/meta.json +5712 -5366
- package/dist/esm/utils/filterUnsetValues.js +8 -0
- package/dist/esm/utils/filterUnsetValues.js.map +7 -0
- package/dist/esm/utils/index.js +5 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/types/components/Grid/Grid.d.ts +1 -1
- package/dist/types/components/Grid/Item.d.ts +1 -1
- package/dist/types/components/List/List.d.ts +1 -1
- package/dist/types/components/Logo/Logo.d.ts +8 -0
- package/dist/types/components/Modal/types.d.ts +2 -0
- package/dist/types/components/Modal/useModal.d.ts +2 -0
- package/dist/types/components/SVG/SVG.d.ts +4 -0
- package/dist/types/components/Segment/Segment.d.ts +4 -3
- package/dist/types/components/Table/HeaderCell.d.ts +2 -1
- package/dist/types/components/Text/Text.d.ts +2 -1
- package/dist/types/utils/filterUnsetValues.d.ts +6 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +4 -4
- package/src/components/Accordion/Accordion.test.tsx +7 -0
- package/src/components/Box/Box.test.tsx +24 -0
- package/src/components/Box/Box.tsx +11 -3
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +130 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/Button/Button.test.tsx +77 -0
- package/src/components/Container/Container.test.tsx +19 -0
- package/src/components/Divider/Divider.test.tsx +18 -0
- package/src/components/Flex/Flex.test.tsx +7 -0
- package/src/components/Grid/Grid.test.tsx +30 -0
- package/src/components/Grid/Grid.tsx +2 -2
- package/src/components/Grid/Item.tsx +3 -3
- package/src/components/Icon/Icon.test.tsx +33 -0
- package/src/components/Image/Image.test.tsx +7 -0
- package/src/components/Label/Label.test.tsx +7 -0
- package/src/components/Link/Link.test.tsx +44 -0
- package/src/components/List/List.test.tsx +11 -0
- package/src/components/List/List.tsx +6 -2
- package/src/components/Logo/Logo.test.tsx +36 -0
- package/src/components/Logo/Logo.tsx +8 -0
- package/src/components/Modal/Header.tsx +13 -2
- package/src/components/Modal/Modal.test.tsx +19 -1
- package/src/components/Modal/Modal.tsx +11 -2
- package/src/components/Modal/ModalContext.tsx +2 -0
- package/src/components/Modal/types.ts +2 -0
- package/src/components/Modal/useModal.ts +2 -2
- package/src/components/Option/Option.test.tsx +67 -0
- package/src/components/Progress/Progress.test.tsx +7 -0
- package/src/components/SVG/SVG.test.tsx +40 -0
- package/src/components/SVG/SVG.tsx +4 -0
- package/src/components/Segment/Segment.test.tsx +72 -0
- package/src/components/Segment/Segment.tsx +7 -4
- package/src/components/Stack/Stack.test.tsx +41 -1
- package/src/components/Table/HeaderCell.tsx +3 -2
- package/src/components/Table/Table.test.tsx +177 -0
- package/src/components/Text/Text.test.tsx +79 -0
- package/src/components/Text/Text.tsx +14 -9
- package/src/components/TextAreaInput/TextAreaInput.test.tsx +51 -0
- package/src/components/TextOrHTML/TextOrHTML.test.tsx +36 -3
- package/src/components/TextOrHTML/TextOrHTML.tsx +45 -9
- package/src/components/Trust/Trust.test.tsx +52 -1
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +66 -0
- package/src/utils/filterUndefinedProps.test.ts +11 -0
- package/src/utils/filterUnsetValues.test.ts +16 -0
- package/src/utils/filterUnsetValues.ts +17 -0
- package/src/utils/index.ts +1 -0
- package/dist/esm/chunk-3IMYDZRT.js.map +0 -7
- package/dist/esm/chunk-4IB5ROL6.js.map +0 -7
- package/dist/esm/chunk-B243ELKZ.js.map +0 -7
- package/dist/esm/chunk-DSYPZETD.js +0 -1
- package/dist/esm/chunk-LVZ2T6AY.js.map +0 -7
- package/dist/esm/chunk-MLN5ELQR.js.map +0 -7
- package/dist/esm/chunk-P5ZPHAQT.js.map +0 -7
- package/dist/esm/chunk-QRHDVVRK.js +0 -40
- package/dist/esm/chunk-QRHDVVRK.js.map +0 -7
- package/dist/esm/chunk-SNRPWCHL.js.map +0 -7
- package/dist/esm/chunk-XNVA7FCA.js +0 -39
- package/dist/esm/chunk-XNVA7FCA.js.map +0 -7
- package/dist/esm/chunk-YLL2DKVF.js.map +0 -7
- package/dist/esm/chunk-ZHX7Z5IU.js +0 -15
- /package/dist/esm/{chunk-NYFCN7EA.js.map → chunk-6GGDGE7D.js.map} +0 -0
- /package/dist/esm/{chunk-OUKMP3DO.js.map → chunk-7JT4DKQA.js.map} +0 -0
- /package/dist/esm/{chunk-Q5YY6HPF.js.map → chunk-DZVBN6ZI.js.map} +0 -0
- /package/dist/esm/{chunk-OC6ULO4M.js.map → chunk-EJLNC5X5.js.map} +0 -0
- /package/dist/esm/{chunk-DSYPZETD.js.map → chunk-FIAL4HTE.js.map} +0 -0
- /package/dist/esm/{chunk-OZ2IUZIJ.js.map → chunk-HP2NRM7T.js.map} +0 -0
- /package/dist/esm/{chunk-TL4OCKNP.js.map → chunk-LWRY3VIB.js.map} +0 -0
- /package/dist/esm/{chunk-RR4UQSOZ.js.map → chunk-M7LTJZQU.js.map} +0 -0
- /package/dist/esm/{chunk-N5WGQAHM.js.map → chunk-NRU3WNV7.js.map} +0 -0
- /package/dist/esm/{chunk-O47IW7HD.js.map → chunk-YCE2KOB2.js.map} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
import { chevronLeft } from "@simplybusiness/icons";
|
|
3
4
|
import { Icon } from ".";
|
|
@@ -34,6 +35,32 @@ describe("Test for Icon", () => {
|
|
|
34
35
|
render(<Icon icon={chevronLeft} data-testid="test" />);
|
|
35
36
|
expect(screen.getByTestId("test")).toHaveClass(XS_SIZE_CLASS_NAME);
|
|
36
37
|
});
|
|
38
|
+
|
|
39
|
+
it.each(["xs", "sm", "md", "lg"] as const)(
|
|
40
|
+
"applies --size-%s class",
|
|
41
|
+
size => {
|
|
42
|
+
render(<Icon icon={chevronLeft} size={size} data-testid="test" />);
|
|
43
|
+
expect(screen.getByTestId("test")).toHaveClass(`--size-${size}`);
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
it("applies mobius-icon-fw class when fixedWidth is true", () => {
|
|
48
|
+
render(<Icon icon={chevronLeft} fixedWidth data-testid="test" />);
|
|
49
|
+
expect(screen.getByTestId("test")).toHaveClass("mobius-icon-fw");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("applies mobius-icon-spin class when spin is true", () => {
|
|
53
|
+
render(<Icon icon={chevronLeft} spin data-testid="test" />);
|
|
54
|
+
expect(screen.getByTestId("test")).toHaveClass("mobius-icon-spin");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("applies mobius-icon-spin-reverse class when spinReverse is true", () => {
|
|
58
|
+
render(<Icon icon={chevronLeft} spinReverse data-testid="test" />);
|
|
59
|
+
expect(screen.getByTestId("test")).toHaveClass(
|
|
60
|
+
"mobius-icon-spin-reverse",
|
|
61
|
+
);
|
|
62
|
+
expect(screen.getByTestId("test")).toHaveClass("mobius-icon-spin");
|
|
63
|
+
});
|
|
37
64
|
});
|
|
38
65
|
|
|
39
66
|
describe("SVG title attribute", () => {
|
|
@@ -55,4 +82,10 @@ describe("Test for Icon", () => {
|
|
|
55
82
|
expect(svgTitleTag).toBeInTheDocument();
|
|
56
83
|
});
|
|
57
84
|
});
|
|
85
|
+
|
|
86
|
+
it("forwards ref", () => {
|
|
87
|
+
const ref = createRef<SVGSVGElement>();
|
|
88
|
+
render(<Icon ref={ref} icon={chevronLeft} />);
|
|
89
|
+
expect(ref.current).toBeInstanceOf(SVGSVGElement);
|
|
90
|
+
});
|
|
58
91
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
import { Image } from ".";
|
|
3
4
|
|
|
@@ -41,4 +42,10 @@ describe("Test for Image", () => {
|
|
|
41
42
|
expect(screen.getByTestId("test")).toHaveClass(CLASS_NAME);
|
|
42
43
|
});
|
|
43
44
|
});
|
|
45
|
+
|
|
46
|
+
it("forwards ref", () => {
|
|
47
|
+
const ref = createRef<HTMLImageElement>();
|
|
48
|
+
render(<Image ref={ref} alt="test" src="test.png" />);
|
|
49
|
+
expect(ref.current).toBeInstanceOf(HTMLImageElement);
|
|
50
|
+
});
|
|
44
51
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
import { Label } from ".";
|
|
3
4
|
|
|
@@ -47,4 +48,10 @@ describe("Test for Label", () => {
|
|
|
47
48
|
expect(screen.getByTestId("test")).toHaveClass(CLASS_NAME);
|
|
48
49
|
});
|
|
49
50
|
});
|
|
51
|
+
|
|
52
|
+
it("forwards ref", () => {
|
|
53
|
+
const ref = createRef<HTMLLabelElement>();
|
|
54
|
+
render(<Label ref={ref}>Text</Label>);
|
|
55
|
+
expect(ref.current).toBeInstanceOf(HTMLLabelElement);
|
|
56
|
+
});
|
|
50
57
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
import userEvent from "@testing-library/user-event";
|
|
3
4
|
import { Link } from ".";
|
|
@@ -43,6 +44,25 @@ describe("Test for Link", () => {
|
|
|
43
44
|
});
|
|
44
45
|
});
|
|
45
46
|
|
|
47
|
+
describe("when disabled", () => {
|
|
48
|
+
it("has aria-disabled attribute", () => {
|
|
49
|
+
render(
|
|
50
|
+
<Link href="#" isDisabled>
|
|
51
|
+
Click
|
|
52
|
+
</Link>,
|
|
53
|
+
);
|
|
54
|
+
expect(screen.getByRole("link")).toHaveAttribute("aria-disabled", "true");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("focus", () => {
|
|
59
|
+
it("is focusable via Tab", async () => {
|
|
60
|
+
render(<Link href="#">Click</Link>);
|
|
61
|
+
await userEvent.tab();
|
|
62
|
+
expect(screen.getByRole("link")).toHaveFocus();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
46
66
|
describe("uses correct class names", () => {
|
|
47
67
|
it("uses Mobius class", () => {
|
|
48
68
|
render(
|
|
@@ -81,6 +101,20 @@ describe("Test for Link", () => {
|
|
|
81
101
|
await userEvent.tab();
|
|
82
102
|
expect(screen.getByTestId("test")).toHaveClass("--is-disabled");
|
|
83
103
|
});
|
|
104
|
+
|
|
105
|
+
it.each(["primary", "secondary"] as const)(
|
|
106
|
+
"applies mobius-link--%s class",
|
|
107
|
+
variant => {
|
|
108
|
+
render(
|
|
109
|
+
<Link href="#test" data-testid="test" variant={variant}>
|
|
110
|
+
Sample text
|
|
111
|
+
</Link>,
|
|
112
|
+
);
|
|
113
|
+
expect(screen.getByTestId("test")).toHaveClass(
|
|
114
|
+
`mobius-link--${variant}`,
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
);
|
|
84
118
|
});
|
|
85
119
|
|
|
86
120
|
describe("given the the link has disabled prop", () => {
|
|
@@ -94,4 +128,14 @@ describe("Test for Link", () => {
|
|
|
94
128
|
expect(screen.getByTestId("test")).toBeEnabled();
|
|
95
129
|
});
|
|
96
130
|
});
|
|
131
|
+
|
|
132
|
+
it("forwards ref", () => {
|
|
133
|
+
const ref = createRef<HTMLAnchorElement>();
|
|
134
|
+
render(
|
|
135
|
+
<Link ref={ref} href="#">
|
|
136
|
+
Text
|
|
137
|
+
</Link>,
|
|
138
|
+
);
|
|
139
|
+
expect(ref.current).toBeInstanceOf(HTMLAnchorElement);
|
|
140
|
+
});
|
|
97
141
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
import type { ListStyleType } from ".";
|
|
3
4
|
import { List, ListItem } from ".";
|
|
@@ -167,4 +168,14 @@ describe("List", () => {
|
|
|
167
168
|
expect(screen.getByText("✅")).toHaveClass(LIST_ICON_CLASS_NAME);
|
|
168
169
|
});
|
|
169
170
|
});
|
|
171
|
+
|
|
172
|
+
it("forwards ref", () => {
|
|
173
|
+
const ref = createRef<HTMLOListElement & HTMLUListElement>();
|
|
174
|
+
render(
|
|
175
|
+
<List ref={ref}>
|
|
176
|
+
<ListItem>item</ListItem>
|
|
177
|
+
</List>,
|
|
178
|
+
);
|
|
179
|
+
expect(ref.current).toBeInstanceOf(HTMLUListElement);
|
|
180
|
+
});
|
|
170
181
|
});
|
|
@@ -21,7 +21,7 @@ export interface ListProps extends DOMProps {
|
|
|
21
21
|
liststyletype?: ListStyleType;
|
|
22
22
|
icon?: ReactNode;
|
|
23
23
|
className?: string;
|
|
24
|
-
ref?: Ref<
|
|
24
|
+
ref?: Ref<HTMLElement>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const List = ({ ref, ...props }: ListProps) => {
|
|
@@ -48,7 +48,11 @@ const List = ({ ref, ...props }: ListProps) => {
|
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
|
-
<Component
|
|
51
|
+
<Component
|
|
52
|
+
ref={ref as React.Ref<HTMLOListElement & HTMLUListElement>}
|
|
53
|
+
{...mappedProps}
|
|
54
|
+
className={classes}
|
|
55
|
+
>
|
|
52
56
|
{Children.map(children, child => {
|
|
53
57
|
if (isValidElement(child)) {
|
|
54
58
|
// List items accept a parentIcon prop which is not part of standard HTML
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render } from "@testing-library/react";
|
|
2
3
|
import { Logo } from ".";
|
|
3
4
|
|
|
@@ -25,4 +26,39 @@ describe("Logo", () => {
|
|
|
25
26
|
expect(container.firstChild).toHaveClass(customClassName);
|
|
26
27
|
});
|
|
27
28
|
});
|
|
29
|
+
|
|
30
|
+
describe("semantic HTML and accessibility", () => {
|
|
31
|
+
it("renders an <svg> element", () => {
|
|
32
|
+
const { container } = render(<Logo />);
|
|
33
|
+
expect(container.firstChild?.nodeName).toBe("svg");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("has a viewBox attribute for proper scaling", () => {
|
|
37
|
+
const { container } = render(<Logo />);
|
|
38
|
+
expect(container.firstChild).toHaveAttribute("viewBox", "0 0 144 37");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("applies custom width and height", () => {
|
|
42
|
+
const { container } = render(<Logo width="200" height="50" />);
|
|
43
|
+
expect(container.firstChild).toHaveAttribute("width", "200");
|
|
44
|
+
expect(container.firstChild).toHaveAttribute("height", "50");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Note: Logo does not set role="img", aria-label, or <title> by default.
|
|
48
|
+
// Screen readers may not announce this SVG meaningfully. Consider adding
|
|
49
|
+
// role="img" and aria-label="Simply Business" for better accessibility.
|
|
50
|
+
// The component's type interface (LogoProps) also does not accept role or
|
|
51
|
+
// aria-label, so consumers cannot pass these props without a type error.
|
|
52
|
+
it("does not set an accessible label by default", () => {
|
|
53
|
+
const { container } = render(<Logo />);
|
|
54
|
+
expect(container.firstChild).not.toHaveAttribute("role");
|
|
55
|
+
expect(container.firstChild).not.toHaveAttribute("aria-label");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("forwards ref", () => {
|
|
60
|
+
const ref = createRef<SVGSVGElement>();
|
|
61
|
+
render(<Logo ref={ref} />);
|
|
62
|
+
expect(ref.current).toBeInstanceOf(SVGSVGElement);
|
|
63
|
+
});
|
|
28
64
|
});
|
|
@@ -11,6 +11,14 @@ export interface LogoProps extends DOMProps, RefAttributes<LogoElementType> {
|
|
|
11
11
|
width?: string;
|
|
12
12
|
/** Custom height. When defined along with width, it will scale proportionally */
|
|
13
13
|
height?: string;
|
|
14
|
+
/** ARIA role for the SVG element */
|
|
15
|
+
role?: React.AriaRole;
|
|
16
|
+
/** Accessible label for the logo */
|
|
17
|
+
"aria-label"?: string;
|
|
18
|
+
/** Whether the logo is hidden from screen readers */
|
|
19
|
+
"aria-hidden"?: boolean | "true" | "false";
|
|
20
|
+
/** ID of an element that labels the logo */
|
|
21
|
+
"aria-labelledby"?: string;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
export const Logo = ({ ref, ...props }: LogoProps) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PropsWithChildren, RefAttributes } from "react";
|
|
2
|
+
import { useEffect, useId } from "react";
|
|
2
3
|
|
|
3
4
|
import { cross } from "@simplybusiness/icons";
|
|
4
5
|
import type { DOMProps } from "../../types/dom";
|
|
@@ -12,10 +13,20 @@ export interface HeaderProps
|
|
|
12
13
|
extends DOMProps, RefAttributes<HeaderElementType>, PropsWithChildren {}
|
|
13
14
|
|
|
14
15
|
const Header = ({ ref, children, ...otherProps }: HeaderProps) => {
|
|
15
|
-
const { onClose, closeLabel } = useModal();
|
|
16
|
+
const { onClose, closeLabel, setTitleId } = useModal();
|
|
17
|
+
const titleId = useId();
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setTitleId(titleId);
|
|
21
|
+
}, [titleId, setTitleId]);
|
|
16
22
|
|
|
17
23
|
return (
|
|
18
|
-
<header
|
|
24
|
+
<header
|
|
25
|
+
ref={ref}
|
|
26
|
+
{...otherProps}
|
|
27
|
+
className="mobius-modal__header"
|
|
28
|
+
id={titleId}
|
|
29
|
+
>
|
|
19
30
|
{children}
|
|
20
31
|
<Button
|
|
21
32
|
aria-label="Close"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { createRef, useState } from "react";
|
|
2
2
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import { Modal } from ".";
|
|
@@ -96,6 +96,17 @@ describe("Modal", () => {
|
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
it("has open attribute when isOpen is true", async () => {
|
|
100
|
+
render(
|
|
101
|
+
<Modal isOpen onClose={vi.fn()}>
|
|
102
|
+
<Modal.Header>Title</Modal.Header>
|
|
103
|
+
<Modal.Content>Content</Modal.Content>
|
|
104
|
+
</Modal>,
|
|
105
|
+
);
|
|
106
|
+
const dialog = await screen.findByRole("dialog");
|
|
107
|
+
expect(dialog).toHaveAttribute("open");
|
|
108
|
+
});
|
|
109
|
+
|
|
99
110
|
describe("pressing close button", () => {
|
|
100
111
|
it("should close the modal", async () => {
|
|
101
112
|
const App = () => {
|
|
@@ -190,4 +201,11 @@ describe("Modal", () => {
|
|
|
190
201
|
expect(onOpen).toHaveBeenCalled();
|
|
191
202
|
});
|
|
192
203
|
});
|
|
204
|
+
|
|
205
|
+
it("forwards ref", async () => {
|
|
206
|
+
const ref = createRef<HTMLDialogElement>();
|
|
207
|
+
render(<Modal ref={ref} isOpen />);
|
|
208
|
+
await screen.findByRole("dialog");
|
|
209
|
+
expect(ref.current).toBeInstanceOf(HTMLDialogElement);
|
|
210
|
+
});
|
|
193
211
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import classNames from "classnames/dedupe";
|
|
4
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { useDialog } from "../../hooks";
|
|
6
6
|
import { mergeRefs } from "../../utils";
|
|
7
7
|
import { supportsDialog } from "../../utils/polyfill-tests";
|
|
@@ -56,12 +56,20 @@ const Modal = ({ ref, ...props }: ModalProps) => {
|
|
|
56
56
|
className,
|
|
57
57
|
);
|
|
58
58
|
|
|
59
|
+
const [titleId, setTitleId] = useState<string | undefined>(undefined);
|
|
60
|
+
|
|
61
|
+
const handleSetTitleId = useCallback((id: string) => {
|
|
62
|
+
setTitleId(id);
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
59
65
|
const contextValue = useMemo(
|
|
60
66
|
() => ({
|
|
61
67
|
onClose: close,
|
|
62
68
|
closeLabel,
|
|
69
|
+
titleId,
|
|
70
|
+
setTitleId: handleSetTitleId,
|
|
63
71
|
}),
|
|
64
|
-
[close, closeLabel],
|
|
72
|
+
[close, closeLabel, titleId, handleSetTitleId],
|
|
65
73
|
);
|
|
66
74
|
|
|
67
75
|
return (
|
|
@@ -69,6 +77,7 @@ const Modal = ({ ref, ...props }: ModalProps) => {
|
|
|
69
77
|
ref={mergeRefs([dialogRef, ref])}
|
|
70
78
|
onCancel={close}
|
|
71
79
|
className={modalClasses}
|
|
80
|
+
aria-labelledby={titleId}
|
|
72
81
|
{...rest}
|
|
73
82
|
>
|
|
74
83
|
<ModalContext.Provider value={contextValue}>
|
|
@@ -15,4 +15,6 @@ export interface ModalProps extends RefAttributes<ModalElementType> {
|
|
|
15
15
|
export type ModalContextProps = {
|
|
16
16
|
onClose: (event?: SyntheticEvent<HTMLElement, Event>) => void;
|
|
17
17
|
closeLabel: string | undefined;
|
|
18
|
+
titleId: string | undefined;
|
|
19
|
+
setTitleId: (id: string) => void;
|
|
18
20
|
};
|
|
@@ -2,7 +2,7 @@ import { useContext } from "react";
|
|
|
2
2
|
import { ModalContext } from "./ModalContext";
|
|
3
3
|
|
|
4
4
|
export const useModal = () => {
|
|
5
|
-
const { onClose, closeLabel } = useContext(ModalContext);
|
|
5
|
+
const { onClose, closeLabel, titleId, setTitleId } = useContext(ModalContext);
|
|
6
6
|
|
|
7
|
-
return { onClose, closeLabel };
|
|
7
|
+
return { onClose, closeLabel, titleId, setTitleId };
|
|
8
8
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Option } from "./Option";
|
|
4
|
+
|
|
5
|
+
describe("Option", () => {
|
|
6
|
+
it("renders an <option> element", () => {
|
|
7
|
+
render(
|
|
8
|
+
<select>
|
|
9
|
+
<Option>Test</Option>
|
|
10
|
+
</select>,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
expect(screen.getByRole("option")).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("passes value prop", () => {
|
|
17
|
+
render(
|
|
18
|
+
<select>
|
|
19
|
+
<Option value="foo">Foo</Option>
|
|
20
|
+
</select>,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByRole("option")).toHaveValue("foo");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("renders children as text content", () => {
|
|
27
|
+
render(
|
|
28
|
+
<select>
|
|
29
|
+
<Option>Hello world</Option>
|
|
30
|
+
</select>,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(screen.getByRole("option")).toHaveTextContent("Hello world");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("maps isDisabled to disabled attribute", () => {
|
|
37
|
+
render(
|
|
38
|
+
<select>
|
|
39
|
+
<Option isDisabled>Disabled</Option>
|
|
40
|
+
</select>,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
expect(screen.getByRole("option")).toBeDisabled();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("does not have disabled attribute when not disabled", () => {
|
|
47
|
+
render(
|
|
48
|
+
<select>
|
|
49
|
+
<Option>Enabled</Option>
|
|
50
|
+
</select>,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(screen.getByRole("option")).toBeEnabled();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("forwards ref", () => {
|
|
57
|
+
const ref = createRef<HTMLOptionElement>();
|
|
58
|
+
|
|
59
|
+
render(
|
|
60
|
+
<select>
|
|
61
|
+
<Option ref={ref}>With ref</Option>
|
|
62
|
+
</select>,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(ref.current).toBeInstanceOf(HTMLOptionElement);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render } from "@testing-library/react";
|
|
2
3
|
import { Progress } from ".";
|
|
3
4
|
|
|
@@ -141,4 +142,10 @@ describe("Progress", () => {
|
|
|
141
142
|
);
|
|
142
143
|
});
|
|
143
144
|
});
|
|
145
|
+
|
|
146
|
+
it("forwards ref", () => {
|
|
147
|
+
const ref = createRef<HTMLDivElement>();
|
|
148
|
+
render(<Progress ref={ref} label="Progress" value={50} />);
|
|
149
|
+
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
150
|
+
});
|
|
144
151
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
import { SVG } from ".";
|
|
3
4
|
|
|
@@ -35,4 +36,43 @@ describe("Test for SVG", () => {
|
|
|
35
36
|
expect(screen.getByTestId("test")).toHaveClass(CLASS_NAME);
|
|
36
37
|
});
|
|
37
38
|
});
|
|
39
|
+
|
|
40
|
+
describe("semantic HTML and accessibility", () => {
|
|
41
|
+
it("renders an <svg> element", () => {
|
|
42
|
+
const { container } = render(<SVG>{SvgImage}</SVG>);
|
|
43
|
+
expect(container.firstChild?.nodeName).toBe("svg");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("preserves the viewBox attribute from the child SVG", () => {
|
|
47
|
+
render(<SVG data-testid="test">{SvgImage}</SVG>);
|
|
48
|
+
expect(screen.getByTestId("test")).toHaveAttribute(
|
|
49
|
+
"viewBox",
|
|
50
|
+
"0 0 299.8 85",
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("preserves the xmlns attribute from the child SVG", () => {
|
|
55
|
+
render(<SVG data-testid="test">{SvgImage}</SVG>);
|
|
56
|
+
expect(screen.getByTestId("test")).toHaveAttribute(
|
|
57
|
+
"xmlns",
|
|
58
|
+
"http://www.w3.org/2000/svg",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Note: SVG component does not set role="img" or support a title prop.
|
|
63
|
+
// For decorative SVGs this is acceptable, but meaningful SVGs should
|
|
64
|
+
// have role="img" and an accessible label (aria-label or <title>).
|
|
65
|
+
// The component's type interface (SVGProps) also does not accept role or
|
|
66
|
+
// aria-label, so consumers cannot pass these props without a type error.
|
|
67
|
+
it("does not set role='img' by default", () => {
|
|
68
|
+
render(<SVG data-testid="test">{SvgImage}</SVG>);
|
|
69
|
+
expect(screen.getByTestId("test")).not.toHaveAttribute("role");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("forwards ref", () => {
|
|
74
|
+
const ref = createRef<SVGSVGElement>();
|
|
75
|
+
render(<SVG ref={ref}>{SvgImage}</SVG>);
|
|
76
|
+
expect(ref.current).toBeInstanceOf(SVGSVGElement);
|
|
77
|
+
});
|
|
38
78
|
});
|
|
@@ -7,6 +7,10 @@ export interface SVGProps extends DOMProps, RefAttributes<SVGSVGElement> {
|
|
|
7
7
|
children: React.ReactElement<React.SVGProps<SVGSVGElement>>;
|
|
8
8
|
className?: string;
|
|
9
9
|
style?: React.CSSProperties;
|
|
10
|
+
role?: React.AriaRole;
|
|
11
|
+
"aria-label"?: string;
|
|
12
|
+
"aria-hidden"?: boolean | "true" | "false";
|
|
13
|
+
"aria-labelledby"?: string;
|
|
10
14
|
}
|
|
11
15
|
const SVG = ({ ref, ...props }: SVGProps) => {
|
|
12
16
|
const { children, className, ...otherProps } = props;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Segment } from "./Segment";
|
|
4
|
+
|
|
5
|
+
describe("Segment", () => {
|
|
6
|
+
it("applies mobius and mobius-segment classes", () => {
|
|
7
|
+
render(<Segment data-testid="segment" />);
|
|
8
|
+
|
|
9
|
+
const el = screen.getByTestId("segment");
|
|
10
|
+
expect(el).toHaveClass("mobius");
|
|
11
|
+
expect(el).toHaveClass("mobius-segment");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("forwards custom className", () => {
|
|
15
|
+
render(<Segment data-testid="segment" className="custom" />);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByTestId("segment")).toHaveClass("custom");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("applies subtle colour class", () => {
|
|
21
|
+
render(<Segment data-testid="segment" colour="subtle" />);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByTestId("segment")).toHaveClass("subtle");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("applies primary colour class", () => {
|
|
27
|
+
render(<Segment data-testid="segment" colour="primary" />);
|
|
28
|
+
|
|
29
|
+
expect(screen.getByTestId("segment")).toHaveClass("primary");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("applies secondary colour class", () => {
|
|
33
|
+
render(<Segment data-testid="segment" colour="secondary" />);
|
|
34
|
+
|
|
35
|
+
expect(screen.getByTestId("segment")).toHaveClass("secondary");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("applies inverted class when prop is true", () => {
|
|
39
|
+
render(<Segment data-testid="segment" inverted />);
|
|
40
|
+
|
|
41
|
+
expect(screen.getByTestId("segment")).toHaveClass("inverted");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("renders heading when provided", () => {
|
|
45
|
+
render(<Segment heading="My Heading" />);
|
|
46
|
+
|
|
47
|
+
const heading = screen.getByText("My Heading");
|
|
48
|
+
expect(heading).toBeInTheDocument();
|
|
49
|
+
expect(heading).toHaveClass("mobius-segment__heading");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("does not render heading when not provided", () => {
|
|
53
|
+
const { container } = render(<Segment>Content</Segment>);
|
|
54
|
+
|
|
55
|
+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access -- no role/text to query when heading is absent
|
|
56
|
+
expect(container.querySelector(".mobius-segment__heading")).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("renders children", () => {
|
|
60
|
+
render(<Segment>Child content</Segment>);
|
|
61
|
+
|
|
62
|
+
expect(screen.getByText("Child content")).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("forwards ref", () => {
|
|
66
|
+
const ref = createRef<HTMLDivElement>();
|
|
67
|
+
|
|
68
|
+
render(<Segment ref={ref}>With ref</Segment>);
|
|
69
|
+
|
|
70
|
+
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import type { ReactNode, RefAttributes } from "react";
|
|
2
2
|
import classNames from "classnames/dedupe";
|
|
3
3
|
import type { DOMProps } from "../../types/dom";
|
|
4
4
|
import "./Segment.css";
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export type SegmentElementType = HTMLDivElement;
|
|
7
|
+
|
|
8
|
+
export interface SegmentProps
|
|
9
|
+
extends DOMProps, RefAttributes<SegmentElementType> {
|
|
7
10
|
className?: string;
|
|
8
11
|
heading?: string;
|
|
9
12
|
/** Background colour for Segment */
|
|
@@ -13,7 +16,7 @@ export interface SegmentProps extends DOMProps {
|
|
|
13
16
|
children?: ReactNode;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
const Segment = (props: SegmentProps) => {
|
|
19
|
+
const Segment = ({ ref, ...props }: SegmentProps) => {
|
|
17
20
|
const { heading, children, colour, inverted, className, ...rest } = props;
|
|
18
21
|
|
|
19
22
|
const classes = classNames(
|
|
@@ -25,7 +28,7 @@ const Segment = (props: SegmentProps) => {
|
|
|
25
28
|
);
|
|
26
29
|
|
|
27
30
|
return (
|
|
28
|
-
<div className={classes} {...rest}>
|
|
31
|
+
<div ref={ref} className={classes} {...rest}>
|
|
29
32
|
{heading && <div className="mobius-segment__heading">{heading}</div>}
|
|
30
33
|
{children}
|
|
31
34
|
</div>
|