govuk-react 1.0.0-alpha.0 → 1.0.0-alpha.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/dist/components/accordion/index.d.ts +68 -0
- package/dist/components/accordion/index.js +104 -0
- package/dist/components/accordion/index.js.map +1 -0
- package/dist/components/back-link/index.d.ts +1 -0
- package/dist/components/back-link/index.js +2 -0
- package/dist/components/back-link/index.js.map +1 -0
- package/dist/components/body/index.d.ts +1 -0
- package/dist/components/body/index.js +2 -0
- package/dist/components/body/index.js.map +1 -0
- package/dist/components/breadcrumbs/index.js +2 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/button/index.d.ts +24 -0
- package/dist/components/button/index.js +17 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/caption/index.d.ts +1 -0
- package/dist/components/caption/index.js +2 -0
- package/dist/components/caption/index.js.map +1 -0
- package/dist/components/character-count/index.d.ts +36 -0
- package/dist/components/character-count/index.js +82 -0
- package/dist/components/character-count/index.js.map +1 -0
- package/dist/components/checkboxes/index.d.ts +49 -0
- package/dist/components/checkboxes/index.js +73 -0
- package/dist/components/checkboxes/index.js.map +1 -0
- package/dist/components/cookie-banner/index.js +2 -0
- package/dist/components/cookie-banner/index.js.map +1 -0
- package/dist/components/date-input/index.js +2 -0
- package/dist/components/date-input/index.js.map +1 -0
- package/dist/components/details/index.js +2 -0
- package/dist/components/details/index.js.map +1 -0
- package/dist/components/document-footer-metadata/index.d.ts +35 -0
- package/dist/components/document-footer-metadata/index.js +36 -0
- package/dist/components/document-footer-metadata/index.js.map +1 -0
- package/dist/components/error-message/index.d.ts +1 -0
- package/dist/components/error-message/index.js +2 -0
- package/dist/components/error-message/index.js.map +1 -0
- package/dist/components/error-summary/index.d.ts +22 -0
- package/dist/components/error-summary/index.js +49 -0
- package/dist/components/error-summary/index.js.map +1 -0
- package/dist/components/exit-this-page/index.d.ts +33 -0
- package/dist/components/exit-this-page/index.js +66 -0
- package/dist/components/exit-this-page/index.js.map +1 -0
- package/dist/components/feedback/index.js +2 -0
- package/dist/components/feedback/index.js.map +1 -0
- package/dist/components/fieldset/index.js +2 -0
- package/dist/components/fieldset/index.js.map +1 -0
- package/dist/components/file-upload/control.d.ts +6 -0
- package/dist/components/file-upload/control.js +9 -0
- package/dist/components/file-upload/control.js.map +1 -0
- package/dist/components/file-upload/enhanced.d.ts +45 -0
- package/dist/components/file-upload/enhanced.js +84 -0
- package/dist/components/file-upload/enhanced.js.map +1 -0
- package/dist/components/file-upload/index.d.ts +12 -0
- package/dist/components/file-upload/index.js +18 -0
- package/dist/components/file-upload/index.js.map +1 -0
- package/dist/components/footer/index.js +2 -0
- package/dist/components/footer/index.js.map +1 -0
- package/dist/components/form-group/index.d.ts +1 -0
- package/dist/components/form-group/index.js +2 -0
- package/dist/components/form-group/index.js.map +1 -0
- package/dist/components/generic-header/index.js +2 -0
- package/dist/components/generic-header/index.js.map +1 -0
- package/dist/components/grid-column/index.d.ts +1 -0
- package/dist/components/grid-column/index.js +2 -0
- package/dist/components/grid-column/index.js.map +1 -0
- package/dist/components/grid-row/index.d.ts +1 -0
- package/dist/components/grid-row/index.js +2 -0
- package/dist/components/grid-row/index.js.map +1 -0
- package/dist/components/header/index.js +2 -0
- package/dist/components/header/index.js.map +1 -0
- package/dist/components/heading/index.d.ts +1 -0
- package/dist/components/heading/index.js +2 -0
- package/dist/components/heading/index.js.map +1 -0
- package/dist/components/hint/index.d.ts +1 -0
- package/dist/components/hint/index.js +2 -0
- package/dist/components/hint/index.js.map +1 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/inset-text/index.d.ts +1 -0
- package/dist/components/inset-text/index.js +2 -0
- package/dist/components/inset-text/index.js.map +1 -0
- package/dist/components/label/index.d.ts +1 -0
- package/dist/components/label/index.js +2 -0
- package/dist/components/label/index.js.map +1 -0
- package/dist/components/language-navigation/index.js +2 -0
- package/dist/components/language-navigation/index.js.map +1 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +2 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/index.js +2 -0
- package/dist/components/list/index.js.map +1 -0
- package/dist/components/loading-box/index.d.ts +35 -0
- package/dist/components/loading-box/index.js +45 -0
- package/dist/components/loading-box/index.js.map +1 -0
- package/dist/components/main-wrapper/index.d.ts +1 -0
- package/dist/components/main-wrapper/index.js +2 -0
- package/dist/components/main-wrapper/index.js.map +1 -0
- package/dist/components/modal/index.d.ts +33 -0
- package/dist/components/modal/index.js +55 -0
- package/dist/components/modal/index.js.map +1 -0
- package/dist/components/notification-banner/index.d.ts +17 -0
- package/dist/components/notification-banner/index.js +44 -0
- package/dist/components/notification-banner/index.js.map +1 -0
- package/dist/{page.d.ts → components/page/index.d.ts} +2 -6
- package/dist/components/page/index.js +22 -0
- package/dist/components/page/index.js.map +1 -0
- package/dist/components/pagination/index.js +2 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/panel/index.js +2 -0
- package/dist/components/panel/index.js.map +1 -0
- package/dist/components/password-input/index.d.ts +26 -0
- package/dist/components/password-input/index.js +60 -0
- package/dist/components/password-input/index.js.map +1 -0
- package/dist/components/phase-banner/index.js +2 -0
- package/dist/components/phase-banner/index.js.map +1 -0
- package/dist/components/radios/index.d.ts +33 -0
- package/dist/components/radios/index.js +70 -0
- package/dist/components/radios/index.js.map +1 -0
- package/dist/components/related-items/index.d.ts +33 -0
- package/dist/components/related-items/index.js +45 -0
- package/dist/components/related-items/index.js.map +1 -0
- package/dist/components/search-box/index.d.ts +89 -0
- package/dist/components/search-box/index.js +136 -0
- package/dist/components/search-box/index.js.map +1 -0
- package/dist/components/section-break/index.d.ts +1 -0
- package/dist/components/section-break/index.js +2 -0
- package/dist/components/section-break/index.js.map +1 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/service-navigation/index.d.ts +64 -0
- package/dist/components/service-navigation/index.js +131 -0
- package/dist/components/service-navigation/index.js.map +1 -0
- package/dist/{skip-link.d.ts → components/skip-link/index.d.ts} +2 -6
- package/dist/components/skip-link/index.js +16 -0
- package/dist/components/skip-link/index.js.map +1 -0
- package/dist/components/summary-list/index.js +2 -0
- package/dist/components/summary-list/index.js.map +1 -0
- package/dist/components/table/index.js +2 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +98 -0
- package/dist/components/tabs/index.js +105 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/index.js +2 -0
- package/dist/components/tag/index.js.map +1 -0
- package/dist/components/task-list/index.js +2 -0
- package/dist/components/task-list/index.js.map +1 -0
- package/dist/components/textarea/index.js +2 -0
- package/dist/components/textarea/index.js.map +1 -0
- package/dist/components/visually-hidden/index.d.ts +1 -0
- package/dist/components/visually-hidden/index.js +2 -0
- package/dist/components/visually-hidden/index.js.map +1 -0
- package/dist/components/warning-text/index.js +2 -0
- package/dist/components/warning-text/index.js.map +1 -0
- package/dist/components/width-container/index.d.ts +1 -0
- package/dist/components/width-container/index.js +2 -0
- package/dist/components/width-container/index.js.map +1 -0
- package/dist/index.d.ts +58 -94
- package/dist/index.js +59 -59
- package/dist/index.js.map +1 -1
- package/dist/utils/join-ids.d.ts +2 -0
- package/dist/utils/join-ids.js +6 -0
- package/dist/utils/join-ids.js.map +1 -0
- package/package.json +6 -6
- package/dist/accordion.d.ts +0 -4
- package/dist/accordion.js +0 -4
- package/dist/accordion.js.map +0 -1
- package/dist/back-link.d.ts +0 -21
- package/dist/back-link.js +0 -4
- package/dist/back-link.js.map +0 -1
- package/dist/body.d.ts +0 -1
- package/dist/body.js +0 -4
- package/dist/body.js.map +0 -1
- package/dist/breadcrumbs.js +0 -3
- package/dist/breadcrumbs.js.map +0 -1
- package/dist/button.d.ts +0 -26
- package/dist/button.js +0 -4
- package/dist/button.js.map +0 -1
- package/dist/caption.d.ts +0 -1
- package/dist/caption.js +0 -4
- package/dist/caption.js.map +0 -1
- package/dist/character-count.d.ts +0 -4
- package/dist/character-count.js +0 -4
- package/dist/character-count.js.map +0 -1
- package/dist/checkboxes.d.ts +0 -3
- package/dist/checkboxes.js +0 -4
- package/dist/checkboxes.js.map +0 -1
- package/dist/chunk-2KPHO7N2.js +0 -3
- package/dist/chunk-2KPHO7N2.js.map +0 -1
- package/dist/chunk-2W35PR6E.js +0 -3
- package/dist/chunk-2W35PR6E.js.map +0 -1
- package/dist/chunk-57K6B6V2.js +0 -38
- package/dist/chunk-57K6B6V2.js.map +0 -1
- package/dist/chunk-5RYJUAI3.js +0 -3
- package/dist/chunk-5RYJUAI3.js.map +0 -1
- package/dist/chunk-5YT2PQAF.js +0 -3
- package/dist/chunk-5YT2PQAF.js.map +0 -1
- package/dist/chunk-B33BQUXM.js +0 -8
- package/dist/chunk-B33BQUXM.js.map +0 -1
- package/dist/chunk-BAXFWXMR.js +0 -41
- package/dist/chunk-BAXFWXMR.js.map +0 -1
- package/dist/chunk-BDIDAVNV.js +0 -22
- package/dist/chunk-BDIDAVNV.js.map +0 -1
- package/dist/chunk-D6TMELAY.js +0 -3
- package/dist/chunk-D6TMELAY.js.map +0 -1
- package/dist/chunk-DHTWPFZO.js +0 -8
- package/dist/chunk-DHTWPFZO.js.map +0 -1
- package/dist/chunk-DK2FZF7U.js +0 -3
- package/dist/chunk-DK2FZF7U.js.map +0 -1
- package/dist/chunk-EMM6RZT7.js +0 -3
- package/dist/chunk-EMM6RZT7.js.map +0 -1
- package/dist/chunk-EMNBPB3L.js +0 -8
- package/dist/chunk-EMNBPB3L.js.map +0 -1
- package/dist/chunk-FE2OFAA5.js +0 -8
- package/dist/chunk-FE2OFAA5.js.map +0 -1
- package/dist/chunk-FNDQEOKW.js +0 -20
- package/dist/chunk-FNDQEOKW.js.map +0 -1
- package/dist/chunk-HHH5BEO6.js +0 -3
- package/dist/chunk-HHH5BEO6.js.map +0 -1
- package/dist/chunk-HRURRTAU.js +0 -83
- package/dist/chunk-HRURRTAU.js.map +0 -1
- package/dist/chunk-IFETUZ4S.js +0 -3
- package/dist/chunk-IFETUZ4S.js.map +0 -1
- package/dist/chunk-JLNRFYFI.js +0 -3
- package/dist/chunk-JLNRFYFI.js.map +0 -1
- package/dist/chunk-K7VSNNQD.js +0 -8
- package/dist/chunk-K7VSNNQD.js.map +0 -1
- package/dist/chunk-KFWTQTVJ.js +0 -3
- package/dist/chunk-KFWTQTVJ.js.map +0 -1
- package/dist/chunk-L4GCVMBX.js +0 -3
- package/dist/chunk-L4GCVMBX.js.map +0 -1
- package/dist/chunk-L4O7OXGY.js +0 -151
- package/dist/chunk-L4O7OXGY.js.map +0 -1
- package/dist/chunk-LG7D7X4T.js +0 -8
- package/dist/chunk-LG7D7X4T.js.map +0 -1
- package/dist/chunk-M5BQAPSC.js +0 -8
- package/dist/chunk-M5BQAPSC.js.map +0 -1
- package/dist/chunk-NN44HUS7.js +0 -64
- package/dist/chunk-NN44HUS7.js.map +0 -1
- package/dist/chunk-NV2BSK6G.js +0 -3
- package/dist/chunk-NV2BSK6G.js.map +0 -1
- package/dist/chunk-OCGJIH5X.js +0 -159
- package/dist/chunk-OCGJIH5X.js.map +0 -1
- package/dist/chunk-OQVOKH2T.js +0 -8
- package/dist/chunk-OQVOKH2T.js.map +0 -1
- package/dist/chunk-OWBD4KZC.js +0 -115
- package/dist/chunk-OWBD4KZC.js.map +0 -1
- package/dist/chunk-PM2AAFY4.js +0 -35
- package/dist/chunk-PM2AAFY4.js.map +0 -1
- package/dist/chunk-PNMADTQQ.js +0 -3
- package/dist/chunk-PNMADTQQ.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-QOWZLJK4.js +0 -3
- package/dist/chunk-QOWZLJK4.js.map +0 -1
- package/dist/chunk-QV7AS734.js +0 -98
- package/dist/chunk-QV7AS734.js.map +0 -1
- package/dist/chunk-RC24GP47.js +0 -8
- package/dist/chunk-RC24GP47.js.map +0 -1
- package/dist/chunk-RIB3ADHK.js +0 -8
- package/dist/chunk-RIB3ADHK.js.map +0 -1
- package/dist/chunk-RODK5NYM.js +0 -3
- package/dist/chunk-RODK5NYM.js.map +0 -1
- package/dist/chunk-SKQVJZMM.js +0 -79
- package/dist/chunk-SKQVJZMM.js.map +0 -1
- package/dist/chunk-SMUQZFJ7.js +0 -179
- package/dist/chunk-SMUQZFJ7.js.map +0 -1
- package/dist/chunk-SVIOO5V5.js +0 -109
- package/dist/chunk-SVIOO5V5.js.map +0 -1
- package/dist/chunk-SYW45KJ5.js +0 -3
- package/dist/chunk-SYW45KJ5.js.map +0 -1
- package/dist/chunk-T56AQZA4.js +0 -3
- package/dist/chunk-T56AQZA4.js.map +0 -1
- package/dist/chunk-TK6FAARU.js +0 -12
- package/dist/chunk-TK6FAARU.js.map +0 -1
- package/dist/chunk-TQOVKJLU.js +0 -78
- package/dist/chunk-TQOVKJLU.js.map +0 -1
- package/dist/chunk-U2FEV65D.js +0 -8
- package/dist/chunk-U2FEV65D.js.map +0 -1
- package/dist/chunk-UHX5TMH6.js +0 -49
- package/dist/chunk-UHX5TMH6.js.map +0 -1
- package/dist/chunk-VB3GA2KO.js +0 -3
- package/dist/chunk-VB3GA2KO.js.map +0 -1
- package/dist/chunk-VGZUAGCQ.js +0 -8
- package/dist/chunk-VGZUAGCQ.js.map +0 -1
- package/dist/chunk-VKUBJY23.js +0 -8
- package/dist/chunk-VKUBJY23.js.map +0 -1
- package/dist/chunk-VQ4FRNV3.js +0 -8
- package/dist/chunk-VQ4FRNV3.js.map +0 -1
- package/dist/chunk-W7RN6ITL.js +0 -8
- package/dist/chunk-W7RN6ITL.js.map +0 -1
- package/dist/chunk-WFHQPUFE.js +0 -3
- package/dist/chunk-WFHQPUFE.js.map +0 -1
- package/dist/chunk-XO7OW5TM.js +0 -3
- package/dist/chunk-XO7OW5TM.js.map +0 -1
- package/dist/chunk-YOBXV2EG.js +0 -101
- package/dist/chunk-YOBXV2EG.js.map +0 -1
- package/dist/chunk-YYDYVLVS.js +0 -47
- package/dist/chunk-YYDYVLVS.js.map +0 -1
- package/dist/chunk-Z4J4DQCF.js +0 -8
- package/dist/chunk-Z4J4DQCF.js.map +0 -1
- package/dist/chunk-ZHHORZMC.js +0 -3
- package/dist/chunk-ZHHORZMC.js.map +0 -1
- package/dist/cookie-banner.js +0 -3
- package/dist/cookie-banner.js.map +0 -1
- package/dist/date-input.js +0 -3
- package/dist/date-input.js.map +0 -1
- package/dist/details.js +0 -3
- package/dist/details.js.map +0 -1
- package/dist/document-footer-metadata.d.ts +0 -2
- package/dist/document-footer-metadata.js +0 -4
- package/dist/document-footer-metadata.js.map +0 -1
- package/dist/error-message.d.ts +0 -1
- package/dist/error-message.js +0 -4
- package/dist/error-message.js.map +0 -1
- package/dist/error-summary.d.ts +0 -3
- package/dist/error-summary.js +0 -4
- package/dist/error-summary.js.map +0 -1
- package/dist/exit-this-page.d.ts +0 -4
- package/dist/exit-this-page.js +0 -4
- package/dist/exit-this-page.js.map +0 -1
- package/dist/feedback.js +0 -3
- package/dist/feedback.js.map +0 -1
- package/dist/fieldset.js +0 -3
- package/dist/fieldset.js.map +0 -1
- package/dist/file-upload.d.ts +0 -90
- package/dist/file-upload.js +0 -4
- package/dist/file-upload.js.map +0 -1
- package/dist/footer.js +0 -3
- package/dist/footer.js.map +0 -1
- package/dist/form-group.d.ts +0 -1
- package/dist/form-group.js +0 -4
- package/dist/form-group.js.map +0 -1
- package/dist/generic-header.js +0 -3
- package/dist/generic-header.js.map +0 -1
- package/dist/grid-column.d.ts +0 -1
- package/dist/grid-column.js +0 -4
- package/dist/grid-column.js.map +0 -1
- package/dist/grid-row.d.ts +0 -1
- package/dist/grid-row.js +0 -4
- package/dist/grid-row.js.map +0 -1
- package/dist/header.js +0 -3
- package/dist/header.js.map +0 -1
- package/dist/heading.d.ts +0 -1
- package/dist/heading.js +0 -4
- package/dist/heading.js.map +0 -1
- package/dist/hint.d.ts +0 -1
- package/dist/hint.js +0 -4
- package/dist/hint.js.map +0 -1
- package/dist/index-7cuUiEo3.d.ts +0 -98
- package/dist/index-B8fw-F9t.d.ts +0 -22
- package/dist/index-BBckYYWt.d.ts +0 -131
- package/dist/index-BOPiKua4.d.ts +0 -61
- package/dist/index-BOfUYry5.d.ts +0 -22
- package/dist/index-BP18qbj1.d.ts +0 -22
- package/dist/index-BQaNJq4d.d.ts +0 -22
- package/dist/index-BnYaP7AC.d.ts +0 -57
- package/dist/index-C-c5LroN.d.ts +0 -22
- package/dist/index-CAxOsfPr.d.ts +0 -22
- package/dist/index-CHKQTetM.d.ts +0 -52
- package/dist/index-CWRQhs3p.d.ts +0 -55
- package/dist/index-CidkuScr.d.ts +0 -22
- package/dist/index-D-5h70y_.d.ts +0 -22
- package/dist/index-DDvVZ8mX.d.ts +0 -22
- package/dist/index-DQaFKwpy.d.ts +0 -106
- package/dist/index-DWibEGiF.d.ts +0 -22
- package/dist/index-D_wOwhn9.d.ts +0 -127
- package/dist/index-DhPVSZNZ.d.ts +0 -40
- package/dist/index-DhjWVeDK.d.ts +0 -22
- package/dist/index-DnvlWvry.d.ts +0 -54
- package/dist/index-Dr0S9iUZ.d.ts +0 -22
- package/dist/index-Dw9RbQVO.d.ts +0 -22
- package/dist/index-MxQB65RM.d.ts +0 -48
- package/dist/index-RZtIJBvk.d.ts +0 -22
- package/dist/index-TgEbRgDh.d.ts +0 -22
- package/dist/index-a8sYZpTj.d.ts +0 -77
- package/dist/index-rQaOtoWF.d.ts +0 -59
- package/dist/index-trAlT6HP.d.ts +0 -22
- package/dist/index-vBukON0x.d.ts +0 -50
- package/dist/input.js +0 -3
- package/dist/input.js.map +0 -1
- package/dist/inset-text.d.ts +0 -1
- package/dist/inset-text.js +0 -4
- package/dist/inset-text.js.map +0 -1
- package/dist/label.d.ts +0 -1
- package/dist/label.js +0 -4
- package/dist/label.js.map +0 -1
- package/dist/language-navigation.js +0 -3
- package/dist/language-navigation.js.map +0 -1
- package/dist/link.d.ts +0 -1
- package/dist/link.js +0 -4
- package/dist/link.js.map +0 -1
- package/dist/list.d.ts +0 -1
- package/dist/list.js +0 -4
- package/dist/list.js.map +0 -1
- package/dist/loading-box.d.ts +0 -39
- package/dist/loading-box.js +0 -4
- package/dist/loading-box.js.map +0 -1
- package/dist/main-wrapper.d.ts +0 -1
- package/dist/main-wrapper.js +0 -4
- package/dist/main-wrapper.js.map +0 -1
- package/dist/modal.d.ts +0 -4
- package/dist/modal.js +0 -4
- package/dist/modal.js.map +0 -1
- package/dist/notification-banner.d.ts +0 -3
- package/dist/notification-banner.js +0 -4
- package/dist/notification-banner.js.map +0 -1
- package/dist/page.js +0 -7
- package/dist/page.js.map +0 -1
- package/dist/pagination.js +0 -3
- package/dist/pagination.js.map +0 -1
- package/dist/panel.js +0 -3
- package/dist/panel.js.map +0 -1
- package/dist/password-input.d.ts +0 -4
- package/dist/password-input.js +0 -4
- package/dist/password-input.js.map +0 -1
- package/dist/phase-banner.js +0 -3
- package/dist/phase-banner.js.map +0 -1
- package/dist/radios.d.ts +0 -3
- package/dist/radios.js +0 -4
- package/dist/radios.js.map +0 -1
- package/dist/related-items.d.ts +0 -2
- package/dist/related-items.js +0 -4
- package/dist/related-items.js.map +0 -1
- package/dist/search-box.d.ts +0 -3
- package/dist/search-box.js +0 -4
- package/dist/search-box.js.map +0 -1
- package/dist/section-break.d.ts +0 -1
- package/dist/section-break.js +0 -4
- package/dist/section-break.js.map +0 -1
- package/dist/select.js +0 -3
- package/dist/select.js.map +0 -1
- package/dist/service-navigation.d.ts +0 -4
- package/dist/service-navigation.js +0 -4
- package/dist/service-navigation.js.map +0 -1
- package/dist/skip-link.js +0 -4
- package/dist/skip-link.js.map +0 -1
- package/dist/summary-list.js +0 -3
- package/dist/summary-list.js.map +0 -1
- package/dist/table.js +0 -3
- package/dist/table.js.map +0 -1
- package/dist/tabs.d.ts +0 -3
- package/dist/tabs.js +0 -4
- package/dist/tabs.js.map +0 -1
- package/dist/tag.d.ts +0 -1
- package/dist/tag.js +0 -4
- package/dist/tag.js.map +0 -1
- package/dist/task-list.js +0 -3
- package/dist/task-list.js.map +0 -1
- package/dist/textarea.js +0 -3
- package/dist/textarea.js.map +0 -1
- package/dist/visually-hidden.d.ts +0 -1
- package/dist/visually-hidden.js +0 -4
- package/dist/visually-hidden.js.map +0 -1
- package/dist/warning-text.js +0 -3
- package/dist/warning-text.js.map +0 -1
- package/dist/width-container.d.ts +0 -1
- package/dist/width-container.js +0 -4
- package/dist/width-container.js.map +0 -1
- /package/dist/{breadcrumbs.d.ts → components/breadcrumbs/index.d.ts} +0 -0
- /package/dist/{cookie-banner.d.ts → components/cookie-banner/index.d.ts} +0 -0
- /package/dist/{date-input.d.ts → components/date-input/index.d.ts} +0 -0
- /package/dist/{details.d.ts → components/details/index.d.ts} +0 -0
- /package/dist/{feedback.d.ts → components/feedback/index.d.ts} +0 -0
- /package/dist/{fieldset.d.ts → components/fieldset/index.d.ts} +0 -0
- /package/dist/{footer.d.ts → components/footer/index.d.ts} +0 -0
- /package/dist/{generic-header.d.ts → components/generic-header/index.d.ts} +0 -0
- /package/dist/{header.d.ts → components/header/index.d.ts} +0 -0
- /package/dist/{input.d.ts → components/input/index.d.ts} +0 -0
- /package/dist/{language-navigation.d.ts → components/language-navigation/index.d.ts} +0 -0
- /package/dist/{pagination.d.ts → components/pagination/index.d.ts} +0 -0
- /package/dist/{panel.d.ts → components/panel/index.d.ts} +0 -0
- /package/dist/{phase-banner.d.ts → components/phase-banner/index.d.ts} +0 -0
- /package/dist/{select.d.ts → components/select/index.d.ts} +0 -0
- /package/dist/{summary-list.d.ts → components/summary-list/index.d.ts} +0 -0
- /package/dist/{table.d.ts → components/table/index.d.ts} +0 -0
- /package/dist/{task-list.d.ts → components/task-list/index.d.ts} +0 -0
- /package/dist/{textarea.d.ts → components/textarea/index.d.ts} +0 -0
- /package/dist/{warning-text.d.ts → components/warning-text/index.d.ts} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/accordion';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/accordion';
|
|
5
|
+
export type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {
|
|
6
|
+
/** The open sections' values, to control them once hydrated. */
|
|
7
|
+
value?: string[];
|
|
8
|
+
/** The sections open at first. */
|
|
9
|
+
defaultValue?: string[];
|
|
10
|
+
/** Called with the open sections' values when the user opens or closes a section. */
|
|
11
|
+
onValueChange?: (value: string[]) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The accordion component lets users show and hide sections of related content on a page.
|
|
15
|
+
*
|
|
16
|
+
* @see https://design-system.service.gov.uk/components/accordion/
|
|
17
|
+
*/
|
|
18
|
+
export declare function Root({ value, defaultValue, onValueChange, rememberExpanded, hideAllSectionsText, hideSectionText, hideSectionAriaLabelText, showAllSectionsText, showSectionText, showSectionAriaLabelText, ...props }: RootProps): React.JSX.Element;
|
|
19
|
+
export type ControlsProps = Omit<Primitives.ControlsProps, 'asChild' | 'children'>;
|
|
20
|
+
/** The "Show all sections" button, at the top of the accordion. Hidden until JavaScript runs. */
|
|
21
|
+
export declare function Controls({ className, ...props }: ControlsProps): React.JSX.Element;
|
|
22
|
+
export type SectionProps = Markup.SectionProps & {
|
|
23
|
+
/** Identifies the section in the accordion's `value`. */
|
|
24
|
+
value: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function Section({ value, expanded, ...props }: SectionProps): React.JSX.Element;
|
|
27
|
+
export { SectionHeader, SectionHeading, type SectionHeaderProps, type SectionHeadingProps, } from 'govuk-frontend-react/accordion';
|
|
28
|
+
export type SectionButtonProps = Markup.SectionButtonProps & {
|
|
29
|
+
/** The section's summary line, which the button also shows once JavaScript runs. */
|
|
30
|
+
summary?: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a
|
|
34
|
+
* button that shows and hides the section, holding the heading and `summary`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function SectionButton({ summary, children, ...props }: SectionButtonProps): React.JSX.Element;
|
|
37
|
+
export type SectionSummaryProps = Markup.SectionSummaryProps;
|
|
38
|
+
/** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */
|
|
39
|
+
export declare function SectionSummary(props: SectionSummaryProps): React.JSX.Element;
|
|
40
|
+
export type SectionContentProps = Markup.SectionContentProps;
|
|
41
|
+
/** The section's content. Give it an id, which the button's `aria-controls` names. */
|
|
42
|
+
export declare function SectionContent(props: SectionContentProps): React.JSX.Element;
|
|
43
|
+
export type SectionCompositeProps = Omit<Markup.SectionCompositeProps, 'expanded'> & {
|
|
44
|
+
/** Identifies the section in the accordion's `value`. Defaults to its content's id. */
|
|
45
|
+
value?: string;
|
|
46
|
+
/** Sets whether the section should be expanded when the page loads for the first time. Defaults to whether the accordion's value includes it. */
|
|
47
|
+
expanded?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export declare function SectionComposite({ accordionId, index, heading, summary, headingLevel, value, children, ...props }: SectionCompositeProps): React.JSX.Element;
|
|
50
|
+
export type CompositeProps = Omit<RootProps, 'id' | 'children'> & Pick<Markup.SectionHeadingProps, 'headingLevel'> & {
|
|
51
|
+
/** Must be unique across the domain of your service if `rememberExpanded` is `true` (as the expanded state of individual instances of the component persists across page loads using [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-control` attributes. */
|
|
52
|
+
id: string;
|
|
53
|
+
} & ({
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
sections?: never;
|
|
56
|
+
} | {
|
|
57
|
+
children?: never;
|
|
58
|
+
/** Prefer children, which memoise and re-render better. */
|
|
59
|
+
sections: Omit<SectionCompositeProps, 'accordionId' | 'index' | 'headingLevel'>[];
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* The accordion component lets users show and hide sections of related content on a page.
|
|
63
|
+
*
|
|
64
|
+
* Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.
|
|
65
|
+
*
|
|
66
|
+
* @see https://design-system.service.gov.uk/components/accordion/
|
|
67
|
+
*/
|
|
68
|
+
export declare function Composite({ id, headingLevel, sections, children, ...props }: CompositeProps): React.JSX.Element;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import * as Primitives from '@govuk-react/primitives/accordion';
|
|
5
|
+
import * as Markup from 'govuk-frontend-react/accordion';
|
|
6
|
+
/*
|
|
7
|
+
* govuk-frontend-react's Accordion markup, with the behaviour from @govuk-react/primitives. As in
|
|
8
|
+
* govuk-frontend, every section is open without JavaScript. Each section also renders the button
|
|
9
|
+
* govuk-frontend's script would build, hidden until the element upgrades, so React never has its
|
|
10
|
+
* markup moved.
|
|
11
|
+
*/
|
|
12
|
+
// Fills in defaults only: in an island without a Root, pass `defaultExpanded` to Section.
|
|
13
|
+
const AccordionContext = createContext({});
|
|
14
|
+
/**
|
|
15
|
+
* The accordion component lets users show and hide sections of related content on a page.
|
|
16
|
+
*
|
|
17
|
+
* @see https://design-system.service.gov.uk/components/accordion/
|
|
18
|
+
*/
|
|
19
|
+
export function Root({ value, defaultValue, onValueChange, rememberExpanded, hideAllSectionsText, hideSectionText, hideSectionAriaLabelText, showAllSectionsText, showSectionText, showSectionAriaLabelText, ...props }) {
|
|
20
|
+
return (React.createElement(AccordionContext.Provider, { value: { open: value !== null && value !== void 0 ? value : defaultValue } },
|
|
21
|
+
React.createElement(Primitives.Root, { value: value, defaultValue: defaultValue, onValueChange: onValueChange, rememberExpanded: rememberExpanded, hideAllSectionsText: hideAllSectionsText, hideSectionText: hideSectionText, hideSectionLabel: hideSectionAriaLabelText, showAllSectionsText: showAllSectionsText, showSectionText: showSectionText, showSectionLabel: showSectionAriaLabelText,
|
|
22
|
+
// govuk-frontend styles the accordion under `govuk-frontend-supported`, which its JavaScript adds to the body.
|
|
23
|
+
upgradedClass: "govuk-frontend-supported", expandedSectionClass: "govuk-accordion__section--expanded", collapsedIconClass: "govuk-accordion-nav__chevron--down" },
|
|
24
|
+
React.createElement(Markup.Root, { ...props }))));
|
|
25
|
+
}
|
|
26
|
+
/** The "Show all sections" button, at the top of the accordion. Hidden until JavaScript runs. */
|
|
27
|
+
export function Controls({ className, ...props }) {
|
|
28
|
+
return (React.createElement(Primitives.Controls, { className: clsx('govuk-accordion__controls', className), ...props },
|
|
29
|
+
React.createElement(Primitives.ShowAll, { className: "govuk-accordion__show-all", "aria-expanded": "false" },
|
|
30
|
+
React.createElement(Primitives.Icon, { className: "govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down" }),
|
|
31
|
+
React.createElement(Primitives.ShowAllText, { className: "govuk-accordion__show-all-text" }, "Show all sections"))));
|
|
32
|
+
}
|
|
33
|
+
export function Section({ value, expanded, ...props }) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const context = useContext(AccordionContext);
|
|
36
|
+
const isExpanded = (_b = expanded !== null && expanded !== void 0 ? expanded : (_a = context.open) === null || _a === void 0 ? void 0 : _a.includes(value)) !== null && _b !== void 0 ? _b : false;
|
|
37
|
+
return (React.createElement(Primitives.Section, { value: value, defaultExpanded: isExpanded, asChild: true },
|
|
38
|
+
React.createElement(Markup.Section, { expanded: isExpanded, ...props })));
|
|
39
|
+
}
|
|
40
|
+
export { SectionHeader, SectionHeading, } from 'govuk-frontend-react/accordion';
|
|
41
|
+
const divider = React.createElement("span", { className: "govuk-visually-hidden govuk-accordion__section-heading-divider" }, ", ");
|
|
42
|
+
/**
|
|
43
|
+
* The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a
|
|
44
|
+
* button that shows and hides the section, holding the heading and `summary`.
|
|
45
|
+
*/
|
|
46
|
+
export function SectionButton({ summary, children, ...props }) {
|
|
47
|
+
return (React.createElement(React.Fragment, null,
|
|
48
|
+
React.createElement(Primitives.Fallback, { asChild: true },
|
|
49
|
+
React.createElement(Markup.SectionButton, { ...props }, children)),
|
|
50
|
+
React.createElement(Primitives.Trigger, { className: "govuk-accordion__section-button" },
|
|
51
|
+
React.createElement("span", { className: "govuk-accordion__section-heading-text" },
|
|
52
|
+
React.createElement(Primitives.Label, { className: "govuk-accordion__section-heading-text-focus" }, children)),
|
|
53
|
+
divider,
|
|
54
|
+
hasContent(summary) && (React.createElement(React.Fragment, null,
|
|
55
|
+
React.createElement("span", { className: "govuk-accordion__section-summary govuk-body" },
|
|
56
|
+
React.createElement(Primitives.Label, { className: "govuk-accordion__section-summary-focus" }, summary)),
|
|
57
|
+
divider)),
|
|
58
|
+
React.createElement("span", { className: "govuk-accordion__section-toggle", "data-nosnippet": "" },
|
|
59
|
+
React.createElement("span", { className: "govuk-accordion__section-toggle-focus" },
|
|
60
|
+
React.createElement(Primitives.Icon, { className: "govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down" }),
|
|
61
|
+
React.createElement(Primitives.ToggleText, { className: "govuk-accordion__section-toggle-text" }, "Show"))))));
|
|
62
|
+
}
|
|
63
|
+
/** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */
|
|
64
|
+
export function SectionSummary(props) {
|
|
65
|
+
return (React.createElement(Primitives.Fallback, { asChild: true },
|
|
66
|
+
React.createElement(Markup.SectionSummary, { ...props })));
|
|
67
|
+
}
|
|
68
|
+
/** The section's content. Give it an id, which the button's `aria-controls` names. */
|
|
69
|
+
export function SectionContent(props) {
|
|
70
|
+
return (React.createElement(Primitives.Content, { asChild: true },
|
|
71
|
+
React.createElement(Markup.SectionContent, { ...props })));
|
|
72
|
+
}
|
|
73
|
+
export function SectionComposite({ accordionId, index, heading, summary, headingLevel, value, children, ...props }) {
|
|
74
|
+
const contentId = `${accordionId}-content-${index}`;
|
|
75
|
+
return (React.createElement(Section, { value: value !== null && value !== void 0 ? value : contentId, ...props },
|
|
76
|
+
React.createElement(Markup.SectionHeader, null,
|
|
77
|
+
React.createElement(Markup.SectionHeading, { headingLevel: headingLevel },
|
|
78
|
+
React.createElement(SectionButton, { id: `${accordionId}-heading-${index}`, summary: summary }, heading)),
|
|
79
|
+
hasContent(summary) && React.createElement(SectionSummary, { id: `${accordionId}-summary-${index}` }, summary)),
|
|
80
|
+
React.createElement(SectionContent, { id: contentId }, children)));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The accordion component lets users show and hide sections of related content on a page.
|
|
84
|
+
*
|
|
85
|
+
* Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.
|
|
86
|
+
*
|
|
87
|
+
* @see https://design-system.service.gov.uk/components/accordion/
|
|
88
|
+
*/
|
|
89
|
+
export function Composite({ id, headingLevel, sections, children, ...props }) {
|
|
90
|
+
return (React.createElement(Root, { id: id, ...props },
|
|
91
|
+
React.createElement(Controls, null),
|
|
92
|
+
sections
|
|
93
|
+
? sections.map((section, index) => (React.createElement(SectionComposite, { key: index, accordionId: id, index: index + 1, headingLevel: headingLevel, ...section })))
|
|
94
|
+
: children));
|
|
95
|
+
}
|
|
96
|
+
// As govuk-frontend-react decides whether there is a summary.
|
|
97
|
+
function hasContent(node) {
|
|
98
|
+
if (node === null || node === undefined || node === false || node === true || node === '')
|
|
99
|
+
return false;
|
|
100
|
+
if (Array.isArray(node))
|
|
101
|
+
return node.some(hasContent);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/accordion/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,O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from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/accordion';\nimport * as Markup from 'govuk-frontend-react/accordion';\n\n/*\n * govuk-frontend-react's Accordion markup, with the behaviour from @govuk-react/primitives. As in\n * govuk-frontend, every section is open without JavaScript. Each section also renders the button\n * govuk-frontend's script would build, hidden until the element upgrades, so React never has its\n * markup moved.\n */\n\n// Fills in defaults only: in an island without a Root, pass `defaultExpanded` to Section.\nconst AccordionContext = createContext<{ open?: string[] }>({});\n\nexport type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {\n /** The open sections' values, to control them once hydrated. */\n value?: string[];\n /** The sections open at first. */\n defaultValue?: string[];\n /** Called with the open sections' values when the user opens or closes a section. */\n onValueChange?: (value: string[]) => void;\n};\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Root({\n value,\n defaultValue,\n onValueChange,\n rememberExpanded,\n hideAllSectionsText,\n hideSectionText,\n hideSectionAriaLabelText,\n showAllSectionsText,\n showSectionText,\n showSectionAriaLabelText,\n ...props\n}: RootProps) {\n return (\n <AccordionContext.Provider value={{ open: value ?? defaultValue }}>\n <Primitives.Root\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n rememberExpanded={rememberExpanded}\n hideAllSectionsText={hideAllSectionsText}\n hideSectionText={hideSectionText}\n hideSectionLabel={hideSectionAriaLabelText}\n showAllSectionsText={showAllSectionsText}\n showSectionText={showSectionText}\n showSectionLabel={showSectionAriaLabelText}\n // govuk-frontend styles the accordion under `govuk-frontend-supported`, which its JavaScript adds to the body.\n upgradedClass=\"govuk-frontend-supported\"\n expandedSectionClass=\"govuk-accordion__section--expanded\"\n collapsedIconClass=\"govuk-accordion-nav__chevron--down\"\n >\n <Markup.Root {...props} />\n </Primitives.Root>\n </AccordionContext.Provider>\n );\n}\n\nexport type ControlsProps = Omit<Primitives.ControlsProps, 'asChild' | 'children'>;\n\n/** The \"Show all sections\" button, at the top of the accordion. Hidden until JavaScript runs. */\nexport function Controls({ className, ...props }: ControlsProps) {\n return (\n <Primitives.Controls className={clsx('govuk-accordion__controls', className)} {...props}>\n <Primitives.ShowAll className=\"govuk-accordion__show-all\" aria-expanded=\"false\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ShowAllText className=\"govuk-accordion__show-all-text\">Show all sections</Primitives.ShowAllText>\n </Primitives.ShowAll>\n </Primitives.Controls>\n );\n}\n\nexport type SectionProps = Markup.SectionProps & {\n /** Identifies the section in the accordion's `value`. */\n value: string;\n};\n\nexport function Section({ value, expanded, ...props }: SectionProps) {\n const context = useContext(AccordionContext);\n const isExpanded = expanded ?? context.open?.includes(value) ?? false;\n return (\n <Primitives.Section value={value} defaultExpanded={isExpanded} asChild>\n <Markup.Section expanded={isExpanded} {...props} />\n </Primitives.Section>\n );\n}\n\nexport {\n SectionHeader,\n SectionHeading,\n type SectionHeaderProps,\n type SectionHeadingProps,\n} from 'govuk-frontend-react/accordion';\n\nconst divider = <span className=\"govuk-visually-hidden govuk-accordion__section-heading-divider\">, </span>;\n\nexport type SectionButtonProps = Markup.SectionButtonProps & {\n /** The section's summary line, which the button also shows once JavaScript runs. */\n summary?: ReactNode;\n};\n\n/**\n * The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a\n * button that shows and hides the section, holding the heading and `summary`.\n */\nexport function SectionButton({ summary, children, ...props }: SectionButtonProps) {\n return (\n <>\n <Primitives.Fallback asChild>\n <Markup.SectionButton {...props}>{children}</Markup.SectionButton>\n </Primitives.Fallback>\n <Primitives.Trigger className=\"govuk-accordion__section-button\">\n <span className=\"govuk-accordion__section-heading-text\">\n <Primitives.Label className=\"govuk-accordion__section-heading-text-focus\">{children}</Primitives.Label>\n </span>\n {divider}\n {hasContent(summary) && (\n <>\n <span className=\"govuk-accordion__section-summary govuk-body\">\n <Primitives.Label className=\"govuk-accordion__section-summary-focus\">{summary}</Primitives.Label>\n </span>\n {divider}\n </>\n )}\n <span className=\"govuk-accordion__section-toggle\" data-nosnippet=\"\">\n <span className=\"govuk-accordion__section-toggle-focus\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ToggleText className=\"govuk-accordion__section-toggle-text\">Show</Primitives.ToggleText>\n </span>\n </span>\n </Primitives.Trigger>\n </>\n );\n}\n\nexport type SectionSummaryProps = Markup.SectionSummaryProps;\n\n/** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */\nexport function SectionSummary(props: SectionSummaryProps) {\n return (\n <Primitives.Fallback asChild>\n <Markup.SectionSummary {...props} />\n </Primitives.Fallback>\n );\n}\n\nexport type SectionContentProps = Markup.SectionContentProps;\n\n/** The section's content. Give it an id, which the button's `aria-controls` names. */\nexport function SectionContent(props: SectionContentProps) {\n return (\n <Primitives.Content asChild>\n <Markup.SectionContent {...props} />\n </Primitives.Content>\n );\n}\n\nexport type SectionCompositeProps = Omit<Markup.SectionCompositeProps, 'expanded'> & {\n /** Identifies the section in the accordion's `value`. Defaults to its content's id. */\n value?: string;\n /** Sets whether the section should be expanded when the page loads for the first time. Defaults to whether the accordion's value includes it. */\n expanded?: boolean;\n};\n\nexport function SectionComposite({\n accordionId,\n index,\n heading,\n summary,\n headingLevel,\n value,\n children,\n ...props\n}: SectionCompositeProps) {\n const contentId = `${accordionId}-content-${index}`;\n return (\n <Section value={value ?? contentId} {...props}>\n <Markup.SectionHeader>\n <Markup.SectionHeading headingLevel={headingLevel}>\n <SectionButton id={`${accordionId}-heading-${index}`} summary={summary}>\n {heading}\n </SectionButton>\n </Markup.SectionHeading>\n {hasContent(summary) && <SectionSummary id={`${accordionId}-summary-${index}`}>{summary}</SectionSummary>}\n </Markup.SectionHeader>\n <SectionContent id={contentId}>{children}</SectionContent>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'id' | 'children'> &\n Pick<Markup.SectionHeadingProps, 'headingLevel'> & {\n /** Must be unique across the domain of your service if `rememberExpanded` is `true` (as the expanded state of individual instances of the component persists across page loads using [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-control` attributes. */\n id: string;\n } & (\n | { children?: ReactNode; sections?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n sections: Omit<SectionCompositeProps, 'accordionId' | 'index' | 'headingLevel'>[];\n }\n );\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Composite({ id, headingLevel, sections, children, ...props }: CompositeProps) {\n return (\n <Root id={id} {...props}>\n <Controls />\n {sections\n ? sections.map((section, index) => (\n <SectionComposite key={index} accordionId={id} index={index + 1} headingLevel={headingLevel} {...section} />\n ))\n : children}\n </Root>\n );\n}\n\n// As govuk-frontend-react decides whether there is a summary.\nfunction hasContent(node: ReactNode): boolean {\n if (node === null || node === undefined || node === false || node === true || node === '') return false;\n if (Array.isArray(node)) return node.some(hasContent);\n return true;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BackLink, type BackLinkProps } from 'govuk-frontend-react/back-link';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/back-link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,gCAAgC,CAAC","sourcesContent":["export { BackLink, type BackLinkProps } from 'govuk-frontend-react/back-link';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Body, type BodyProps } from 'govuk-frontend-react/body';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/body/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,2BAA2B,CAAC","sourcesContent":["export { Body, type BodyProps } from 'govuk-frontend-react/body';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/breadcrumbs/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/breadcrumbs';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { type ButtonLinkProps, type ButtonProps } from 'govuk-frontend-react/button';
|
|
3
|
+
export { StartButtonContent, StartButtonIcon } from 'govuk-frontend-react/button';
|
|
4
|
+
export type { ButtonLinkProps, ButtonProps, ButtonVariant, StartButtonIconProps } from 'govuk-frontend-react/button';
|
|
5
|
+
/**
|
|
6
|
+
* Use the button component to help users carry out an action.
|
|
7
|
+
*
|
|
8
|
+
* As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and
|
|
9
|
+
* Space activates a link button.
|
|
10
|
+
*
|
|
11
|
+
* @see https://design-system.service.gov.uk/components/button/
|
|
12
|
+
*/
|
|
13
|
+
export declare function Button(props: ButtonLinkProps): ReactNode;
|
|
14
|
+
export declare function Button<As extends ElementType = 'button'>(props: ButtonProps<As>): ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Use a start button for the main call to action on your service's start page.
|
|
17
|
+
*
|
|
18
|
+
* As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and
|
|
19
|
+
* Space activates a link button.
|
|
20
|
+
*
|
|
21
|
+
* @see https://design-system.service.gov.uk/components/button/#start-buttons
|
|
22
|
+
*/
|
|
23
|
+
export declare function StartButton(props: Omit<ButtonLinkProps, 'start'>): ReactNode;
|
|
24
|
+
export declare function StartButton<As extends ElementType = 'button'>(props: Omit<ButtonProps<As>, 'start'>): ReactNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Primitives from '@govuk-react/primitives/button';
|
|
3
|
+
import { Button as MarkupButton, StartButton as MarkupStartButton, } from 'govuk-frontend-react/button';
|
|
4
|
+
export { StartButtonContent, StartButtonIcon } from 'govuk-frontend-react/button';
|
|
5
|
+
export function Button(props) {
|
|
6
|
+
return (
|
|
7
|
+
// Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.
|
|
8
|
+
React.createElement(Primitives.Root, { asChild: true, preventDoubleClick: props.href ? undefined : props.preventDoubleClick },
|
|
9
|
+
React.createElement(MarkupButton, { ...props })));
|
|
10
|
+
}
|
|
11
|
+
export function StartButton(props) {
|
|
12
|
+
return (
|
|
13
|
+
// Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.
|
|
14
|
+
React.createElement(Primitives.Root, { asChild: true, preventDoubleClick: props.href ? undefined : props.preventDoubleClick },
|
|
15
|
+
React.createElement(MarkupStartButton, { ...props })));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,WAAW,IAAI,iBAAiB,GAGjC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAalF,MAAM,UAAU,MAAM,CAAC,KAA+B;IACpD,OAAO;IACL,wGAAwG;IACxG,oBAAC,UAAU,CAAC,IAAI,IAAC,OAAO,QAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB;QAC5F,oBAAC,YAAY,OAAK,KAAK,GAAI,CACX,CACnB,CAAC;AACJ,CAAC;AAYD,MAAM,UAAU,WAAW,CAAC,KAA8C;IACxE,OAAO;IACL,wGAAwG;IACxG,oBAAC,UAAU,CAAC,IAAI,IAAC,OAAO,QAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB;QAC5F,oBAAC,iBAAiB,OAAK,KAAK,GAAI,CAChB,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ElementType, ReactNode } from 'react';\nimport * as Primitives from '@govuk-react/primitives/button';\nimport {\n Button as MarkupButton,\n StartButton as MarkupStartButton,\n type ButtonLinkProps,\n type ButtonProps,\n} from 'govuk-frontend-react/button';\n\nexport { StartButtonContent, StartButtonIcon } from 'govuk-frontend-react/button';\nexport type { ButtonLinkProps, ButtonProps, ButtonVariant, StartButtonIconProps } from 'govuk-frontend-react/button';\n\n/**\n * Use the button component to help users carry out an action.\n *\n * As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and\n * Space activates a link button.\n *\n * @see https://design-system.service.gov.uk/components/button/\n */\nexport function Button(props: ButtonLinkProps): ReactNode;\nexport function Button<As extends ElementType = 'button'>(props: ButtonProps<As>): ReactNode;\nexport function Button(props: ButtonProps<ElementType>) {\n return (\n // Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.\n <Primitives.Root asChild preventDoubleClick={props.href ? undefined : props.preventDoubleClick}>\n <MarkupButton {...props} />\n </Primitives.Root>\n );\n}\n\n/**\n * Use a start button for the main call to action on your service's start page.\n *\n * As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and\n * Space activates a link button.\n *\n * @see https://design-system.service.gov.uk/components/button/#start-buttons\n */\nexport function StartButton(props: Omit<ButtonLinkProps, 'start'>): ReactNode;\nexport function StartButton<As extends ElementType = 'button'>(props: Omit<ButtonProps<As>, 'start'>): ReactNode;\nexport function StartButton(props: Omit<ButtonProps<ElementType>, 'start'>) {\n return (\n // Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.\n <Primitives.Root asChild preventDoubleClick={props.href ? undefined : props.preventDoubleClick}>\n <MarkupStartButton {...props} />\n </Primitives.Root>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Caption, type CaptionProps } from 'govuk-frontend-react/caption';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/caption/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAqB,MAAM,8BAA8B,CAAC","sourcesContent":["export { Caption, type CaptionProps } from 'govuk-frontend-react/caption';\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Primitives from '@govuk-react/primitives/character-count';
|
|
3
|
+
import * as Markup from 'govuk-frontend-react/character-count';
|
|
4
|
+
export type RootProps = Markup.RootProps;
|
|
5
|
+
/**
|
|
6
|
+
* Tell users how many characters or words they can enter into a textarea.
|
|
7
|
+
*
|
|
8
|
+
* Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error
|
|
9
|
+
* message.
|
|
10
|
+
*
|
|
11
|
+
* @see https://design-system.service.gov.uk/components/character-count/
|
|
12
|
+
*/
|
|
13
|
+
export declare function Root({ maxLength, maxWords, threshold, countType, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, error, ...props }: RootProps): React.JSX.Element;
|
|
14
|
+
export type TextareaProps = Markup.TextareaProps;
|
|
15
|
+
/** The field. */
|
|
16
|
+
export declare function Textarea(props: TextareaProps): React.JSX.Element;
|
|
17
|
+
export type MessageProps = Markup.MessageProps;
|
|
18
|
+
/**
|
|
19
|
+
* The description, such as "You can enter up to 200 characters". Shown without JavaScript, and
|
|
20
|
+
* visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to
|
|
21
|
+
* the field's `aria-describedby`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Message(props: MessageProps): React.JSX.Element;
|
|
24
|
+
export type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;
|
|
25
|
+
/** The visible count, after `Message`. Shown once JavaScript runs. */
|
|
26
|
+
export declare function Status({ className, ...props }: StatusProps): React.JSX.Element;
|
|
27
|
+
export type ScreenReaderStatusProps = Omit<Primitives.ScreenReaderStatusProps, 'asChild'>;
|
|
28
|
+
/** The count for screen readers, after `Status`, once the user pauses typing. */
|
|
29
|
+
export declare function ScreenReaderStatus({ className, ...props }: ScreenReaderStatusProps): React.JSX.Element;
|
|
30
|
+
export type FieldProps = Markup.FieldProps;
|
|
31
|
+
/**
|
|
32
|
+
* Tell users how many characters or words they can enter into a textarea.
|
|
33
|
+
*
|
|
34
|
+
* @see https://design-system.service.gov.uk/components/character-count/
|
|
35
|
+
*/
|
|
36
|
+
export declare function Field({ id: idProp, name, label, labelSize, labelIsPageHeading, hint, errorMessage, maxLength, maxWords, threshold, countType, textareaDescriptionText, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, 'aria-describedby': describedBy, ...props }: FieldProps): React.JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/character-count';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/character-count';
|
|
5
|
+
import { ErrorMessageComposite } from 'govuk-frontend-react/error-message';
|
|
6
|
+
import { Hint } from 'govuk-frontend-react/hint';
|
|
7
|
+
import { LabelComposite } from 'govuk-frontend-react/label';
|
|
8
|
+
import { joinIds } from '../../utils/join-ids.js';
|
|
9
|
+
/**
|
|
10
|
+
* Tell users how many characters or words they can enter into a textarea.
|
|
11
|
+
*
|
|
12
|
+
* Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error
|
|
13
|
+
* message.
|
|
14
|
+
*
|
|
15
|
+
* @see https://design-system.service.gov.uk/components/character-count/
|
|
16
|
+
*/
|
|
17
|
+
export function Root({ maxLength, maxWords, threshold, countType, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, error, ...props }) {
|
|
18
|
+
const text = {
|
|
19
|
+
charactersUnderLimitText,
|
|
20
|
+
charactersAtLimitText,
|
|
21
|
+
charactersOverLimitText,
|
|
22
|
+
wordsUnderLimitText,
|
|
23
|
+
wordsAtLimitText,
|
|
24
|
+
wordsOverLimitText,
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement(Primitives.Root
|
|
27
|
+
// As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.
|
|
28
|
+
, {
|
|
29
|
+
// As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.
|
|
30
|
+
maxLength: maxLength !== null && maxLength !== void 0 ? maxLength : maxWords, countType: countType !== null && countType !== void 0 ? countType : (maxWords && maxLength === undefined ? 'words' : 'length'), threshold: threshold, charactersUnderLimit: charactersUnderLimitText, charactersAtLimit: charactersAtLimitText, charactersOverLimit: charactersOverLimitText, wordsUnderLimit: wordsUnderLimitText, wordsAtLimit: wordsAtLimitText, wordsOverLimit: wordsOverLimitText, hiddenDescriptionClass: "govuk-visually-hidden", withinLimitClass: "govuk-hint", overLimitClass: "govuk-error-message", belowThresholdClass: "govuk-character-count__message--disabled",
|
|
31
|
+
// An error message already marks the field.
|
|
32
|
+
inputOverLimitClass: error ? undefined : 'govuk-textarea--error' },
|
|
33
|
+
React.createElement(Markup.Root, { maxLength: maxLength, maxWords: maxWords, threshold: threshold, countType: countType, error: error, ...text, ...props })));
|
|
34
|
+
}
|
|
35
|
+
/** The field. */
|
|
36
|
+
export function Textarea(props) {
|
|
37
|
+
return (React.createElement(Primitives.Input, { asChild: true },
|
|
38
|
+
React.createElement(Markup.Textarea, { ...props })));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The description, such as "You can enter up to 200 characters". Shown without JavaScript, and
|
|
42
|
+
* visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to
|
|
43
|
+
* the field's `aria-describedby`.
|
|
44
|
+
*/
|
|
45
|
+
export function Message(props) {
|
|
46
|
+
return (React.createElement(Primitives.Description, { asChild: true },
|
|
47
|
+
React.createElement(Markup.Message, { ...props })));
|
|
48
|
+
}
|
|
49
|
+
/** The visible count, after `Message`. Shown once JavaScript runs. */
|
|
50
|
+
export function Status({ className, ...props }) {
|
|
51
|
+
return (React.createElement(Primitives.Status, { className: clsx('govuk-hint', 'govuk-character-count__message', 'govuk-character-count__status', className), ...props }));
|
|
52
|
+
}
|
|
53
|
+
/** The count for screen readers, after `Status`, once the user pauses typing. */
|
|
54
|
+
export function ScreenReaderStatus({ className, ...props }) {
|
|
55
|
+
return (React.createElement(Primitives.ScreenReaderStatus, { className: clsx('govuk-character-count__sr-status', 'govuk-visually-hidden', className), ...props }));
|
|
56
|
+
}
|
|
57
|
+
const isSet = (node) => node !== undefined && node !== null && node !== false && node !== '';
|
|
58
|
+
/**
|
|
59
|
+
* Tell users how many characters or words they can enter into a textarea.
|
|
60
|
+
*
|
|
61
|
+
* @see https://design-system.service.gov.uk/components/character-count/
|
|
62
|
+
*/
|
|
63
|
+
export function Field({ id: idProp, name, label, labelSize, labelIsPageHeading, hint, errorMessage, maxLength, maxWords, threshold, countType, textareaDescriptionText, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, 'aria-describedby': describedBy, ...props }) {
|
|
64
|
+
const id = idProp || name;
|
|
65
|
+
const infoId = `${id}-info`;
|
|
66
|
+
const hintId = isSet(hint) ? `${id}-hint` : undefined;
|
|
67
|
+
const errorId = isSet(errorMessage) ? `${id}-error` : undefined;
|
|
68
|
+
const limit = maxWords || maxLength;
|
|
69
|
+
const words = (countType !== null && countType !== void 0 ? countType : (maxWords ? 'words' : undefined)) === 'words';
|
|
70
|
+
const ariaDescribedBy = joinIds(describedBy, infoId, hintId, errorId);
|
|
71
|
+
return (React.createElement(Root, { error: Boolean(errorId), maxLength: maxLength, maxWords: maxWords, threshold: threshold, countType: countType, textareaDescriptionText: textareaDescriptionText, charactersUnderLimitText: charactersUnderLimitText, charactersAtLimitText: charactersAtLimitText, charactersOverLimitText: charactersOverLimitText, wordsUnderLimitText: wordsUnderLimitText, wordsAtLimitText: wordsAtLimitText, wordsOverLimitText: wordsOverLimitText },
|
|
72
|
+
React.createElement(LabelComposite, { htmlFor: id, size: labelSize, isPageHeading: labelIsPageHeading }, label),
|
|
73
|
+
hintId && React.createElement(Hint, { id: hintId }, hint),
|
|
74
|
+
errorId && React.createElement(ErrorMessageComposite, { id: errorId }, errorMessage),
|
|
75
|
+
React.createElement(Textarea, { id: id, name: name, error: Boolean(errorId), "aria-describedby": ariaDescribedBy, ...props }),
|
|
76
|
+
React.createElement(Message, { id: infoId }, limit
|
|
77
|
+
? (textareaDescriptionText || `You can enter up to %{count} ${words ? 'words' : 'characters'}`).replaceAll('%{count}', String(limit))
|
|
78
|
+
: null),
|
|
79
|
+
React.createElement(Status, null),
|
|
80
|
+
React.createElement(ScreenReaderStatus, null)));
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/character-count/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CA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AC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,IAC5E,KAAK,CACS;QAChB,MAAM,IAAI,oBAAC,IAAI,IAAC,EAAE,EAAE,MAAM,IAAG,IAAI,CAAQ;QACzC,OAAO,IAAI,oBAAC,qBAAqB,IAAC,EAAE,EAAE,OAAO,IAAG,YAAY,CAAyB;QACtF,oBAAC,QAAQ,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI;QACvG,oBAAC,OAAO,IAAC,EAAE,EAAE,MAAM,IAChB,KAAK;YACJ,CAAC,CAAC,CAAC,uBAAuB,IAAI,gCAAgC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,UAAU,CACtG,UAAU,EACV,MAAM,CAAC,KAAK,CAAC,CACd;YACH,CAAC,CAAC,IAAI,CACA;QACV,oBAAC,MAAM,OAAG;QACV,oBAAC,kBAAkB,OAAG,CACjB,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/character-count';\nimport * as Markup from 'govuk-frontend-react/character-count';\nimport { ErrorMessageComposite } from 'govuk-frontend-react/error-message';\nimport { Hint } from 'govuk-frontend-react/hint';\nimport { LabelComposite } from 'govuk-frontend-react/label';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's CharacterCount markup, with the count from @govuk-react/primitives.\n * Without JavaScript the field shows its description, such as \"You can enter up to 200\n * characters\", and keeps its `maxlength`, if you give it one.\n */\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Tell users how many characters or words they can enter into a textarea.\n *\n * Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error\n * message.\n *\n * @see https://design-system.service.gov.uk/components/character-count/\n */\nexport function Root({\n maxLength,\n maxWords,\n threshold,\n countType,\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n error,\n ...props\n}: RootProps) {\n const text = {\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n };\n return (\n <Primitives.Root\n // As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.\n maxLength={maxLength ?? maxWords}\n countType={countType ?? (maxWords && maxLength === undefined ? 'words' : 'length')}\n threshold={threshold}\n charactersUnderLimit={charactersUnderLimitText}\n charactersAtLimit={charactersAtLimitText}\n charactersOverLimit={charactersOverLimitText}\n wordsUnderLimit={wordsUnderLimitText}\n wordsAtLimit={wordsAtLimitText}\n wordsOverLimit={wordsOverLimitText}\n hiddenDescriptionClass=\"govuk-visually-hidden\"\n withinLimitClass=\"govuk-hint\"\n overLimitClass=\"govuk-error-message\"\n belowThresholdClass=\"govuk-character-count__message--disabled\"\n // An error message already marks the field.\n inputOverLimitClass={error ? undefined : 'govuk-textarea--error'}\n >\n <Markup.Root\n maxLength={maxLength}\n maxWords={maxWords}\n threshold={threshold}\n countType={countType}\n error={error}\n {...text}\n {...props}\n />\n </Primitives.Root>\n );\n}\n\nexport type TextareaProps = Markup.TextareaProps;\n\n/** The field. */\nexport function Textarea(props: TextareaProps) {\n return (\n <Primitives.Input asChild>\n <Markup.Textarea {...props} />\n </Primitives.Input>\n );\n}\n\nexport type MessageProps = Markup.MessageProps;\n\n/**\n * The description, such as \"You can enter up to 200 characters\". Shown without JavaScript, and\n * visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to\n * the field's `aria-describedby`.\n */\nexport function Message(props: MessageProps) {\n return (\n <Primitives.Description asChild>\n <Markup.Message {...props} />\n </Primitives.Description>\n );\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** The visible count, after `Message`. Shown once JavaScript runs. */\nexport function Status({ className, ...props }: StatusProps) {\n return (\n <Primitives.Status\n className={clsx('govuk-hint', 'govuk-character-count__message', 'govuk-character-count__status', className)}\n {...props}\n />\n );\n}\n\nexport type ScreenReaderStatusProps = Omit<Primitives.ScreenReaderStatusProps, 'asChild'>;\n\n/** The count for screen readers, after `Status`, once the user pauses typing. */\nexport function ScreenReaderStatus({ className, ...props }: ScreenReaderStatusProps) {\n return (\n <Primitives.ScreenReaderStatus\n className={clsx('govuk-character-count__sr-status', 'govuk-visually-hidden', className)}\n {...props}\n />\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\n/**\n * Tell users how many characters or words they can enter into a textarea.\n *\n * @see https://design-system.service.gov.uk/components/character-count/\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\n maxLength,\n maxWords,\n threshold,\n countType,\n textareaDescriptionText,\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n 'aria-describedby': describedBy,\n ...props\n}: FieldProps) {\n const id = idProp || name;\n const infoId = `${id}-info`;\n const hintId = isSet(hint) ? `${id}-hint` : undefined;\n const errorId = isSet(errorMessage) ? `${id}-error` : undefined;\n const limit = maxWords || maxLength;\n const words = (countType ?? (maxWords ? 'words' : undefined)) === 'words';\n const ariaDescribedBy = joinIds(describedBy, infoId, hintId, errorId);\n\n return (\n <Root\n error={Boolean(errorId)}\n maxLength={maxLength}\n maxWords={maxWords}\n threshold={threshold}\n countType={countType}\n textareaDescriptionText={textareaDescriptionText}\n charactersUnderLimitText={charactersUnderLimitText}\n charactersAtLimitText={charactersAtLimitText}\n charactersOverLimitText={charactersOverLimitText}\n wordsUnderLimitText={wordsUnderLimitText}\n wordsAtLimitText={wordsAtLimitText}\n wordsOverLimitText={wordsOverLimitText}\n >\n <LabelComposite htmlFor={id} size={labelSize} isPageHeading={labelIsPageHeading}>\n {label}\n </LabelComposite>\n {hintId && <Hint id={hintId}>{hint}</Hint>}\n {errorId && <ErrorMessageComposite id={errorId}>{errorMessage}</ErrorMessageComposite>}\n <Textarea id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n <Message id={infoId}>\n {limit\n ? (textareaDescriptionText || `You can enter up to %{count} ${words ? 'words' : 'characters'}`).replaceAll(\n '%{count}',\n String(limit)\n )\n : null}\n </Message>\n <Status />\n <ScreenReaderStatus />\n </Root>\n );\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Markup from 'govuk-frontend-react/checkboxes';
|
|
3
|
+
export { Item, Label, Hint, Divider, type ItemProps, type LabelProps, type HintProps, type DividerProps, } from 'govuk-frontend-react/checkboxes';
|
|
4
|
+
/** Shows a reveal only while its checkbox is checked, before or without JavaScript. */
|
|
5
|
+
export declare const checkboxesCss: string;
|
|
6
|
+
export type RootProps = Markup.RootProps;
|
|
7
|
+
/**
|
|
8
|
+
* Let users select one or more options by using the checkboxes component.
|
|
9
|
+
*
|
|
10
|
+
* Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.
|
|
11
|
+
*
|
|
12
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
13
|
+
*/
|
|
14
|
+
export declare function Root(props: RootProps): React.JSX.Element;
|
|
15
|
+
export type InputProps = Markup.InputProps & {
|
|
16
|
+
/** The id of the `Conditional` this checkbox reveals. */
|
|
17
|
+
controls?: string;
|
|
18
|
+
/**
|
|
19
|
+
* For an option such as "None of these": once JavaScript runs, checking it unchecks the other
|
|
20
|
+
* checkboxes with its name, and checking one of them unchecks it.
|
|
21
|
+
*/
|
|
22
|
+
exclusive?: boolean;
|
|
23
|
+
/** govuk-frontend's way to make it exclusive: "exclusive". */
|
|
24
|
+
'data-behaviour'?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }: InputProps): React.JSX.Element;
|
|
27
|
+
export type ConditionalProps = Markup.ConditionalProps;
|
|
28
|
+
/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox's `checked` or `defaultChecked` as `checked`. */
|
|
29
|
+
export declare function Conditional(props: ConditionalProps): React.JSX.Element;
|
|
30
|
+
export type ItemCompositeProps = Markup.ItemCompositeProps & Pick<InputProps, 'exclusive'>;
|
|
31
|
+
export declare function ItemComposite({ id, label, hint, conditional, 'aria-describedby': describedBy, ...props }: ItemCompositeProps): React.JSX.Element;
|
|
32
|
+
export type FieldProps = Omit<Markup.FieldProps, 'items' | 'children'> & ({
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
items?: never;
|
|
35
|
+
} | {
|
|
36
|
+
children?: never;
|
|
37
|
+
/** Prefer children, which memoise and re-render better. */
|
|
38
|
+
items: (ItemCompositeProps | {
|
|
39
|
+
divider: React.ReactNode;
|
|
40
|
+
})[];
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Let users select one or more options by using the checkboxes component.
|
|
44
|
+
*
|
|
45
|
+
* Children are `ItemComposite`s and `Divider`s.
|
|
46
|
+
*
|
|
47
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
48
|
+
*/
|
|
49
|
+
export declare function Field({ items, children, ...props }: FieldProps): React.JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Children } from 'react';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/choices';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/checkboxes';
|
|
5
|
+
import { joinIds } from '../../utils/join-ids.js';
|
|
6
|
+
/*
|
|
7
|
+
* govuk-frontend-react's Checkboxes markup, with conditional reveals from @govuk-react/primitives.
|
|
8
|
+
* Without JavaScript, a reveal shows only while its checkbox is checked, where the browser supports
|
|
9
|
+
* `:has()`, and always where it doesn't, as in govuk-frontend.
|
|
10
|
+
*/
|
|
11
|
+
export { Item, Label, Hint, Divider, } from 'govuk-frontend-react/checkboxes';
|
|
12
|
+
/** Shows a reveal only while its checkbox is checked, before or without JavaScript. */
|
|
13
|
+
export const checkboxesCss = [
|
|
14
|
+
// Hides a reveal whose checkbox isn't checked.
|
|
15
|
+
'.govuk-checkboxes__item:has(>.govuk-checkboxes__input:not(:checked))+.govuk-checkboxes__conditional{display:none}',
|
|
16
|
+
// Shows one whose checkbox is, over govuk-frontend's hidden class, until the element upgrades.
|
|
17
|
+
'.govuk-checkboxes__item:has(>.govuk-checkboxes__input:checked)+.govuk-checkboxes__conditional{display:block}',
|
|
18
|
+
].join('');
|
|
19
|
+
/** The element and styles around the checkboxes, for `Root` and `Field`. */
|
|
20
|
+
function Behaviour({ children }) {
|
|
21
|
+
return (React.createElement(Primitives.Root, { upgradedClass: "govuk-frontend-supported", hiddenConditionalClass: "govuk-checkboxes__conditional--hidden" },
|
|
22
|
+
React.createElement("style", { href: "govuk-react-checkboxes", precedence: "default" }, checkboxesCss),
|
|
23
|
+
children));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Let users select one or more options by using the checkboxes component.
|
|
27
|
+
*
|
|
28
|
+
* Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.
|
|
29
|
+
*
|
|
30
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
31
|
+
*/
|
|
32
|
+
export function Root(props) {
|
|
33
|
+
return (React.createElement(Behaviour, null,
|
|
34
|
+
React.createElement(Markup.Root, { ...props })));
|
|
35
|
+
}
|
|
36
|
+
export function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }) {
|
|
37
|
+
return (
|
|
38
|
+
// govuk-frontend's `data-behaviour="exclusive"` works too. It isn't rendered, so govuk-frontend's
|
|
39
|
+
// own script doesn't handle it as well.
|
|
40
|
+
React.createElement(Primitives.Input, { asChild: true, controls: controls, exclusive: exclusive !== null && exclusive !== void 0 ? exclusive : behaviour === 'exclusive' },
|
|
41
|
+
React.createElement(Markup.Input, { ...props })));
|
|
42
|
+
}
|
|
43
|
+
/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox's `checked` or `defaultChecked` as `checked`. */
|
|
44
|
+
export function Conditional(props) {
|
|
45
|
+
return (React.createElement(Primitives.Conditional, { asChild: true },
|
|
46
|
+
React.createElement(Markup.Conditional, { ...props })));
|
|
47
|
+
}
|
|
48
|
+
const isSet = (node) => node !== undefined && node !== null && node !== false && node !== '';
|
|
49
|
+
export function ItemComposite({ id, label, hint, conditional, 'aria-describedby': describedBy, ...props }) {
|
|
50
|
+
var _a;
|
|
51
|
+
const hintId = isSet(hint) ? `${id}-item-hint` : undefined;
|
|
52
|
+
const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;
|
|
53
|
+
return (React.createElement(React.Fragment, null,
|
|
54
|
+
React.createElement(Markup.Item, null,
|
|
55
|
+
React.createElement(Input, { id: id, controls: conditionalId, "aria-describedby": joinIds(describedBy, hintId), ...props }),
|
|
56
|
+
React.createElement(Markup.Label, { htmlFor: id }, label),
|
|
57
|
+
hintId && React.createElement(Markup.Hint, { id: hintId }, hint)),
|
|
58
|
+
conditionalId && (React.createElement(Conditional, { id: conditionalId, checked: Boolean((_a = props.checked) !== null && _a !== void 0 ? _a : props.defaultChecked) }, conditional))));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Let users select one or more options by using the checkboxes component.
|
|
62
|
+
*
|
|
63
|
+
* Children are `ItemComposite`s and `Divider`s.
|
|
64
|
+
*
|
|
65
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
66
|
+
*/
|
|
67
|
+
export function Field({ items, children, ...props }) {
|
|
68
|
+
return (React.createElement(Behaviour, null,
|
|
69
|
+
React.createElement(Markup.Field, { ...props }, items
|
|
70
|
+
? items.map((item, index) => 'divider' in item ? (React.createElement(Markup.Divider, { key: index }, item.divider)) : (React.createElement(ItemComposite, { key: index, ...item })))
|
|
71
|
+
: Children.toArray(children))));
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/checkboxes/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,MAAM,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,GAKR,MAAM,iCAAiC,CAAC;AAEzC,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,+CAA+C;IAC/C,mHAAmH;IACnH,+FAA+F;IAC/F,8GAA8G;CAC/G,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEX,4EAA4E;AAC5E,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAiC;IAC5D,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,aAAa,EAAC,0BAA0B,EACxC,sBAAsB,EAAC,uCAAuC;QAE9D,+BAAO,IAAI,EAAC,wBAAwB,EAAC,UAAU,EAAC,SAAS,IACtD,aAAa,CACR;QACP,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC;AAID;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,OAAO,CACL,oBAAC,SAAS;QACR,oBAAC,MAAM,CAAC,IAAI,OAAK,KAAK,GAAI,CAChB,CACb,CAAC;AACJ,CAAC;AAcD,MAAM,UAAU,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAc;IAC9F,OAAO;IAC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,IAAI,IAAC,EAAE,EAAE,MAAM,IAAG,IAAI,CAAe,CAC5C;QACb,aAAa,IAAI,CAChB,oBAAC,WAAW,IAAC,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,cAAc,CAAC,IACpF,WAAW,CACA,CACf,CACA,CACJ,CAAC;AACJ,CAAC;AAYD;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IAC7D,OAAO,CACL,oBAAC,SAAS;QACR,oBAAC,MAAM,CAAC,KAAK,OAAK,KAAK,IACpB,KAAK;YACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACxB,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,CAClB,oBAAC,MAAM,CAAC,OAAO,IAAC,GAAG,EAAE,KAAK,IAAG,IAAI,CAAC,OAAO,CAAkB,CAC5D,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IAAC,GAAG,EAAE,KAAK,KAAM,IAAI,GAAI,CACxC,CACF;YACH,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CACjB,CACL,CACb,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { Children } from 'react';\nimport * as Primitives from '@govuk-react/primitives/choices';\nimport * as Markup from 'govuk-frontend-react/checkboxes';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's Checkboxes markup, with conditional reveals from @govuk-react/primitives.\n * Without JavaScript, a reveal shows only while its checkbox is checked, where the browser supports\n * `:has()`, and always where it doesn't, as in govuk-frontend.\n */\n\nexport {\n Item,\n Label,\n Hint,\n Divider,\n type ItemProps,\n type LabelProps,\n type HintProps,\n type DividerProps,\n} from 'govuk-frontend-react/checkboxes';\n\n/** Shows a reveal only while its checkbox is checked, before or without JavaScript. */\nexport const checkboxesCss = [\n // Hides a reveal whose checkbox isn't checked.\n '.govuk-checkboxes__item:has(>.govuk-checkboxes__input:not(:checked))+.govuk-checkboxes__conditional{display:none}',\n // Shows one whose checkbox is, over govuk-frontend's hidden class, until the element upgrades.\n '.govuk-checkboxes__item:has(>.govuk-checkboxes__input:checked)+.govuk-checkboxes__conditional{display:block}',\n].join('');\n\n/** The element and styles around the checkboxes, for `Root` and `Field`. */\nfunction Behaviour({ children }: { children: React.ReactNode }) {\n return (\n <Primitives.Root\n upgradedClass=\"govuk-frontend-supported\"\n hiddenConditionalClass=\"govuk-checkboxes__conditional--hidden\"\n >\n <style href=\"govuk-react-checkboxes\" precedence=\"default\">\n {checkboxesCss}\n </style>\n {children}\n </Primitives.Root>\n );\n}\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Let users select one or more options by using the checkboxes component.\n *\n * Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.\n *\n * @see https://design-system.service.gov.uk/components/checkboxes/\n */\nexport function Root(props: RootProps) {\n return (\n <Behaviour>\n <Markup.Root {...props} />\n </Behaviour>\n );\n}\n\nexport type InputProps = Markup.InputProps & {\n /** The id of the `Conditional` this checkbox reveals. */\n controls?: string;\n /**\n * For an option such as \"None of these\": once JavaScript runs, checking it unchecks the other\n * checkboxes with its name, and checking one of them unchecks it.\n */\n exclusive?: boolean;\n /** govuk-frontend's way to make it exclusive: \"exclusive\". */\n 'data-behaviour'?: string;\n};\n\nexport function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }: InputProps) {\n return (\n // govuk-frontend's `data-behaviour=\"exclusive\"` works too. It isn't rendered, so govuk-frontend's\n // own script doesn't handle it as well.\n <Primitives.Input asChild controls={controls} exclusive={exclusive ?? behaviour === 'exclusive'}>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ConditionalProps = Markup.ConditionalProps;\n\n/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox's `checked` or `defaultChecked` as `checked`. */\nexport function Conditional(props: ConditionalProps) {\n return (\n <Primitives.Conditional asChild>\n <Markup.Conditional {...props} />\n </Primitives.Conditional>\n );\n}\n\nexport type ItemCompositeProps = Markup.ItemCompositeProps & Pick<InputProps, 'exclusive'>;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\nexport function ItemComposite({\n id,\n label,\n hint,\n conditional,\n 'aria-describedby': describedBy,\n ...props\n}: ItemCompositeProps) {\n const hintId = isSet(hint) ? `${id}-item-hint` : undefined;\n const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;\n return (\n <>\n <Markup.Item>\n <Input id={id} controls={conditionalId} aria-describedby={joinIds(describedBy, hintId)} {...props} />\n <Markup.Label htmlFor={id}>{label}</Markup.Label>\n {hintId && <Markup.Hint id={hintId}>{hint}</Markup.Hint>}\n </Markup.Item>\n {conditionalId && (\n <Conditional id={conditionalId} checked={Boolean(props.checked ?? props.defaultChecked)}>\n {conditional}\n </Conditional>\n )}\n </>\n );\n}\n\nexport type FieldProps = Omit<Markup.FieldProps, 'items' | 'children'> &\n (\n | { children?: React.ReactNode; items?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n items: (ItemCompositeProps | { divider: React.ReactNode })[];\n }\n );\n\n/**\n * Let users select one or more options by using the checkboxes component.\n *\n * Children are `ItemComposite`s and `Divider`s.\n *\n * @see https://design-system.service.gov.uk/components/checkboxes/\n */\nexport function Field({ items, children, ...props }: FieldProps) {\n return (\n <Behaviour>\n <Markup.Field {...props}>\n {items\n ? items.map((item, index) =>\n 'divider' in item ? (\n <Markup.Divider key={index}>{item.divider}</Markup.Divider>\n ) : (\n <ItemComposite key={index} {...item} />\n )\n )\n : Children.toArray(children)}\n </Markup.Field>\n </Behaviour>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/cookie-banner/index.tsx"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/cookie-banner';\n"]}
|