@cerberus-design/react 0.8.0 → 0.8.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/build/legacy/{_tsup-dts-rollup.d.ts → _tsup-dts-rollup.d.cts} +207 -5
- package/build/legacy/aria-helpers/nav-menu.aria.cjs +36 -0
- package/build/legacy/aria-helpers/nav-menu.aria.cjs.map +1 -0
- package/build/legacy/aria-helpers/tabs.aria.cjs +100 -0
- package/build/legacy/aria-helpers/tabs.aria.cjs.map +1 -0
- package/build/legacy/aria-helpers/trap-focus.aria.cjs +54 -0
- package/build/legacy/aria-helpers/trap-focus.aria.cjs.map +1 -0
- package/build/legacy/components/Button.cjs +50 -0
- package/build/legacy/components/Button.cjs.map +1 -0
- package/build/legacy/components/Checkbox.cjs +157 -0
- package/build/legacy/components/Checkbox.cjs.map +1 -0
- package/build/legacy/components/Droppable.cjs +54 -0
- package/build/legacy/components/Droppable.cjs.map +1 -0
- package/build/legacy/components/FeatureFlag.cjs +63 -0
- package/build/legacy/components/FeatureFlag.cjs.map +1 -0
- package/build/legacy/components/FieldMessage.cjs +59 -0
- package/build/legacy/components/FieldMessage.cjs.map +1 -0
- package/build/legacy/components/FileStatus.cjs +390 -0
- package/build/legacy/components/FileStatus.cjs.map +1 -0
- package/build/legacy/components/FileUploader.cjs +159 -0
- package/build/legacy/components/FileUploader.cjs.map +1 -0
- package/build/legacy/components/IconButton.cjs +53 -0
- package/build/legacy/components/IconButton.cjs.map +1 -0
- package/build/legacy/components/Input.cjs +145 -0
- package/build/legacy/components/Input.cjs.map +1 -0
- package/build/legacy/components/Label.cjs +93 -0
- package/build/legacy/components/Label.cjs.map +1 -0
- package/build/legacy/components/Modal.cjs +45 -0
- package/build/legacy/components/Modal.cjs.map +1 -0
- package/build/legacy/components/ModalDescription.cjs +36 -0
- package/build/legacy/components/ModalDescription.cjs.map +1 -0
- package/build/legacy/components/ModalHeader.cjs +49 -0
- package/build/legacy/components/ModalHeader.cjs.map +1 -0
- package/build/legacy/components/ModalHeading.cjs +36 -0
- package/build/legacy/components/ModalHeading.cjs.map +1 -0
- package/build/legacy/components/ModalIcon.cjs +51 -0
- package/build/legacy/components/ModalIcon.cjs.map +1 -0
- package/build/legacy/components/NavMenuLink.cjs +81 -0
- package/build/legacy/components/NavMenuLink.cjs.map +1 -0
- package/build/legacy/components/NavMenuList.cjs +131 -0
- package/build/legacy/components/NavMenuList.cjs.map +1 -0
- package/build/legacy/components/NavMenuTrigger.cjs +128 -0
- package/build/legacy/components/NavMenuTrigger.cjs.map +1 -0
- package/build/legacy/components/Notification.cjs +181 -0
- package/build/legacy/components/Notification.cjs.map +1 -0
- package/build/legacy/components/NotificationDescription.cjs +44 -0
- package/build/legacy/components/NotificationDescription.cjs.map +1 -0
- package/build/legacy/components/NotificationHeading.cjs +38 -0
- package/build/legacy/components/NotificationHeading.cjs.map +1 -0
- package/build/legacy/components/Portal.cjs +35 -0
- package/build/legacy/components/Portal.cjs.map +1 -0
- package/build/legacy/components/ProgressBar.cjs +61 -0
- package/build/legacy/components/ProgressBar.cjs.map +1 -0
- package/build/legacy/components/Radio.cjs +68 -0
- package/build/legacy/components/Radio.cjs.map +1 -0
- package/build/legacy/components/Select.cjs +170 -0
- package/build/legacy/components/Select.cjs.map +1 -0
- package/build/legacy/components/Show.cjs +40 -0
- package/build/legacy/components/Show.cjs.map +1 -0
- package/build/legacy/components/Tab.cjs +135 -0
- package/build/legacy/components/Tab.cjs.map +1 -0
- package/build/legacy/components/TabList.cjs +68 -0
- package/build/legacy/components/TabList.cjs.map +1 -0
- package/build/legacy/components/TabPanel.cjs +76 -0
- package/build/legacy/components/TabPanel.cjs.map +1 -0
- package/build/legacy/components/Table.cjs +53 -0
- package/build/legacy/components/Table.cjs.map +1 -0
- package/build/legacy/components/Tag.cjs +91 -0
- package/build/legacy/components/Tag.cjs.map +1 -0
- package/build/legacy/components/Tbody.cjs +48 -0
- package/build/legacy/components/Tbody.cjs.map +1 -0
- package/build/legacy/components/Td.cjs +48 -0
- package/build/legacy/components/Td.cjs.map +1 -0
- package/build/legacy/components/Textarea.cjs +71 -0
- package/build/legacy/components/Textarea.cjs.map +1 -0
- package/build/legacy/components/Th.cjs +80 -0
- package/build/legacy/components/Th.cjs.map +1 -0
- package/build/legacy/components/Thead.cjs +36 -0
- package/build/legacy/components/Thead.cjs.map +1 -0
- package/build/legacy/components/Toggle.cjs +151 -0
- package/build/legacy/components/Toggle.cjs.map +1 -0
- package/build/legacy/config/cerbIcons.cjs +88 -0
- package/build/legacy/config/cerbIcons.cjs.map +1 -0
- package/build/legacy/config/defineIcons.cjs +110 -0
- package/build/legacy/config/defineIcons.cjs.map +1 -0
- package/build/legacy/config/icons/checkbox.icons.cjs +67 -0
- package/build/legacy/config/icons/checkbox.icons.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +371 -0
- package/build/legacy/context/confirm-modal.cjs.map +1 -0
- package/build/legacy/context/feature-flags.cjs +48 -0
- package/build/legacy/context/feature-flags.cjs.map +1 -0
- package/build/legacy/context/field.cjs +55 -0
- package/build/legacy/context/field.cjs.map +1 -0
- package/build/legacy/context/navMenu.cjs +70 -0
- package/build/legacy/context/navMenu.cjs.map +1 -0
- package/build/legacy/context/notification-center.cjs +347 -0
- package/build/legacy/context/notification-center.cjs.map +1 -0
- package/build/legacy/context/prompt-modal.cjs +508 -0
- package/build/legacy/context/prompt-modal.cjs.map +1 -0
- package/build/legacy/context/tabs.cjs +78 -0
- package/build/legacy/context/tabs.cjs.map +1 -0
- package/build/legacy/context/theme.cjs +104 -0
- package/build/legacy/context/theme.cjs.map +1 -0
- package/build/legacy/hooks/useModal.cjs +50 -0
- package/build/legacy/hooks/useModal.cjs.map +1 -0
- package/build/legacy/hooks/useTheme.cjs +87 -0
- package/build/legacy/hooks/useTheme.cjs.map +1 -0
- package/build/legacy/hooks/useToggle.cjs +47 -0
- package/build/legacy/hooks/useToggle.cjs.map +1 -0
- package/build/legacy/index.cjs +2165 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/types.cjs +19 -0
- package/build/legacy/types.cjs.map +1 -0
- package/build/modern/_tsup-dts-rollup.d.ts +207 -5
- package/build/{legacy/chunk-JJGZRBIR.js → modern/chunk-2FK7NR7Y.js} +8 -7
- package/build/{legacy/chunk-JJGZRBIR.js.map → modern/chunk-2FK7NR7Y.js.map} +1 -1
- package/build/modern/chunk-4FD33RTW.js +56 -0
- package/build/modern/chunk-4FD33RTW.js.map +1 -0
- package/build/modern/{chunk-XB4ZRAH4.js → chunk-53QBTZZF.js} +5 -5
- package/build/modern/{chunk-BEYPMC73.js → chunk-5WVXIAG2.js} +2 -2
- package/build/modern/chunk-7NX4RGDB.js +218 -0
- package/build/modern/chunk-7NX4RGDB.js.map +1 -0
- package/build/modern/chunk-CP7OUC2Q.js +42 -0
- package/build/modern/chunk-CP7OUC2Q.js.map +1 -0
- package/build/modern/{chunk-4N2L357B.js → chunk-EJIMJWPB.js} +2 -2
- package/build/{legacy/chunk-GVNPFXKL.js → modern/chunk-GUECLKHY.js} +18 -1
- package/build/modern/chunk-GUECLKHY.js.map +1 -0
- package/build/modern/{chunk-Y5IY7O23.js → chunk-GZY6CH7D.js} +5 -5
- package/build/{legacy/chunk-IL5ELPTT.js → modern/chunk-ID3XWGLY.js} +2 -2
- package/build/modern/chunk-RHG26FYL.js +68 -0
- package/build/modern/chunk-RHG26FYL.js.map +1 -0
- package/build/modern/{chunk-LTDNZRUY.js → chunk-S6CMAXQF.js} +10 -10
- package/build/modern/{chunk-IOG6XIR5.js → chunk-TF3HRELU.js} +3 -3
- package/build/modern/{chunk-IOG6XIR5.js.map → chunk-TF3HRELU.js.map} +1 -1
- package/build/modern/chunk-TYTEREKZ.js +39 -0
- package/build/modern/chunk-TYTEREKZ.js.map +1 -0
- package/build/{legacy/chunk-JJP2TFTU.js → modern/chunk-VCR5C6Q3.js} +1 -1
- package/build/modern/chunk-VCR5C6Q3.js.map +1 -0
- package/build/modern/{chunk-QO2UXGW4.js → chunk-VPWBSZAR.js} +2 -2
- package/build/modern/components/Checkbox.js +13 -0
- package/build/modern/components/FileStatus.js +17 -0
- package/build/modern/components/FileUploader.js +4 -3
- package/build/modern/components/Input.js +5 -4
- package/build/modern/components/Label.js +2 -2
- package/build/modern/components/ModalIcon.js +1 -1
- package/build/modern/components/Notification.js +4 -3
- package/build/modern/components/ProgressBar.js +7 -0
- package/build/modern/components/Select.js +15 -0
- package/build/modern/components/Toggle.js +4 -3
- package/build/modern/config/cerbIcons.js +2 -1
- package/build/modern/config/defineIcons.js +3 -2
- package/build/modern/config/icons/checkbox.icons.js +9 -0
- package/build/modern/context/confirm-modal.js +5 -4
- package/build/modern/context/notification-center.js +5 -4
- package/build/modern/context/prompt-modal.js +8 -7
- package/build/modern/index.js +59 -38
- package/build/modern/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Checkbox.tsx +76 -0
- package/src/components/FileStatus.tsx +246 -0
- package/src/components/FileUploader.tsx +1 -1
- package/src/components/Label.tsx +3 -2
- package/src/components/ModalIcon.tsx +2 -2
- package/src/components/ProgressBar.tsx +61 -0
- package/src/components/Select.tsx +96 -0
- package/src/config/cerbIcons.ts +20 -0
- package/src/config/icons/checkbox.icons.tsx +49 -0
- package/src/index.ts +4 -0
- package/build/legacy/aria-helpers/nav-menu.aria.js +0 -7
- package/build/legacy/aria-helpers/tabs.aria.js +0 -9
- package/build/legacy/aria-helpers/trap-focus.aria.js +0 -7
- package/build/legacy/chunk-2UFNQM55.js +0 -21
- package/build/legacy/chunk-2UFNQM55.js.map +0 -1
- package/build/legacy/chunk-2VPKILZ6.js +0 -122
- package/build/legacy/chunk-2VPKILZ6.js.map +0 -1
- package/build/legacy/chunk-3C2DJSEE.js +0 -16
- package/build/legacy/chunk-3C2DJSEE.js.map +0 -1
- package/build/legacy/chunk-3GXISGPS.js +0 -47
- package/build/legacy/chunk-3GXISGPS.js.map +0 -1
- package/build/legacy/chunk-4CAT3FHV.js +0 -11
- package/build/legacy/chunk-4CAT3FHV.js.map +0 -1
- package/build/legacy/chunk-4M3EUP57.js +0 -22
- package/build/legacy/chunk-4M3EUP57.js.map +0 -1
- package/build/legacy/chunk-4M4LCQ43.js +0 -12
- package/build/legacy/chunk-4M4LCQ43.js.map +0 -1
- package/build/legacy/chunk-4O4QFF4S.js +0 -15
- package/build/legacy/chunk-4O4QFF4S.js.map +0 -1
- package/build/legacy/chunk-55J6XMHW.js +0 -1
- package/build/legacy/chunk-6DIGPXAD.js +0 -48
- package/build/legacy/chunk-6DIGPXAD.js.map +0 -1
- package/build/legacy/chunk-6F34A7NZ.js +0 -28
- package/build/legacy/chunk-6F34A7NZ.js.map +0 -1
- package/build/legacy/chunk-7VJOPJVX.js +0 -29
- package/build/legacy/chunk-7VJOPJVX.js.map +0 -1
- package/build/legacy/chunk-A5WYZVUR.js +0 -28
- package/build/legacy/chunk-A5WYZVUR.js.map +0 -1
- package/build/legacy/chunk-AAKIOHAX.js +0 -155
- package/build/legacy/chunk-AAKIOHAX.js.map +0 -1
- package/build/legacy/chunk-BEYPMC73.js +0 -27
- package/build/legacy/chunk-EVEEQRH6.js +0 -58
- package/build/legacy/chunk-EVEEQRH6.js.map +0 -1
- package/build/legacy/chunk-GKUDLVOV.js +0 -64
- package/build/legacy/chunk-GKUDLVOV.js.map +0 -1
- package/build/legacy/chunk-GVNPFXKL.js.map +0 -1
- package/build/legacy/chunk-HW76XVA3.js +0 -22
- package/build/legacy/chunk-HW76XVA3.js.map +0 -1
- package/build/legacy/chunk-ISPTI4GC.js +0 -32
- package/build/legacy/chunk-ISPTI4GC.js.map +0 -1
- package/build/legacy/chunk-JB7IQ2BM.js +0 -12
- package/build/legacy/chunk-JB7IQ2BM.js.map +0 -1
- package/build/legacy/chunk-JF76VIL3.js +0 -12
- package/build/legacy/chunk-JF76VIL3.js.map +0 -1
- package/build/legacy/chunk-JJP2TFTU.js.map +0 -1
- package/build/legacy/chunk-KESKDLX6.js +0 -30
- package/build/legacy/chunk-KESKDLX6.js.map +0 -1
- package/build/legacy/chunk-KF24CS4S.js +0 -58
- package/build/legacy/chunk-KF24CS4S.js.map +0 -1
- package/build/legacy/chunk-KJUCHZHV.js +0 -51
- package/build/legacy/chunk-KJUCHZHV.js.map +0 -1
- package/build/legacy/chunk-L46XIE3D.js +0 -208
- package/build/legacy/chunk-L46XIE3D.js.map +0 -1
- package/build/legacy/chunk-LF2QFS5S.js +0 -76
- package/build/legacy/chunk-N3FUF4TB.js +0 -12
- package/build/legacy/chunk-N3FUF4TB.js.map +0 -1
- package/build/legacy/chunk-NE5NHILF.js +0 -47
- package/build/legacy/chunk-NE5NHILF.js.map +0 -1
- package/build/legacy/chunk-PH64POOB.js +0 -33
- package/build/legacy/chunk-PH64POOB.js.map +0 -1
- package/build/legacy/chunk-PJ3744I6.js +0 -24
- package/build/legacy/chunk-PJ3744I6.js.map +0 -1
- package/build/legacy/chunk-PMCYXRAH.js +0 -86
- package/build/legacy/chunk-PMCYXRAH.js.map +0 -1
- package/build/legacy/chunk-QU7UV5DB.js +0 -25
- package/build/legacy/chunk-QU7UV5DB.js.map +0 -1
- package/build/legacy/chunk-RPZAPUCF.js +0 -81
- package/build/legacy/chunk-RPZAPUCF.js.map +0 -1
- package/build/legacy/chunk-SCQVXJBT.js +0 -22
- package/build/legacy/chunk-SCQVXJBT.js.map +0 -1
- package/build/legacy/chunk-SLHX5K6I.js +0 -29
- package/build/legacy/chunk-SLHX5K6I.js.map +0 -1
- package/build/legacy/chunk-SMCEFK6Q.js +0 -63
- package/build/legacy/chunk-SMCEFK6Q.js.map +0 -1
- package/build/legacy/chunk-SXXWC6UD.js +0 -83
- package/build/legacy/chunk-SXXWC6UD.js.map +0 -1
- package/build/legacy/chunk-TCO46FK7.js +0 -36
- package/build/legacy/chunk-TCO46FK7.js.map +0 -1
- package/build/legacy/chunk-TZNYJ3G7.js +0 -25
- package/build/legacy/chunk-TZNYJ3G7.js.map +0 -1
- package/build/legacy/chunk-U72VPIZA.js +0 -32
- package/build/legacy/chunk-U72VPIZA.js.map +0 -1
- package/build/legacy/chunk-VGHVH2T3.js +0 -24
- package/build/legacy/chunk-VGHVH2T3.js.map +0 -1
- package/build/legacy/chunk-VULPMZUW.js +0 -18
- package/build/legacy/chunk-VULPMZUW.js.map +0 -1
- package/build/legacy/chunk-XB4ZRAH4.js +0 -42
- package/build/legacy/chunk-XREC5IJE.js +0 -24
- package/build/legacy/chunk-XREC5IJE.js.map +0 -1
- package/build/legacy/chunk-ZAU4JVLL.js +0 -33
- package/build/legacy/chunk-ZAU4JVLL.js.map +0 -1
- package/build/legacy/components/Button.js +0 -7
- package/build/legacy/components/Droppable.js +0 -8
- package/build/legacy/components/Droppable.js.map +0 -1
- package/build/legacy/components/FeatureFlag.js +0 -10
- package/build/legacy/components/FeatureFlag.js.map +0 -1
- package/build/legacy/components/FieldMessage.js +0 -9
- package/build/legacy/components/FieldMessage.js.map +0 -1
- package/build/legacy/components/FileUploader.js +0 -11
- package/build/legacy/components/FileUploader.js.map +0 -1
- package/build/legacy/components/IconButton.js +0 -7
- package/build/legacy/components/IconButton.js.map +0 -1
- package/build/legacy/components/Input.js +0 -12
- package/build/legacy/components/Input.js.map +0 -1
- package/build/legacy/components/Label.js +0 -10
- package/build/legacy/components/Label.js.map +0 -1
- package/build/legacy/components/Modal.js +0 -7
- package/build/legacy/components/Modal.js.map +0 -1
- package/build/legacy/components/ModalDescription.js +0 -7
- package/build/legacy/components/ModalDescription.js.map +0 -1
- package/build/legacy/components/ModalHeader.js +0 -7
- package/build/legacy/components/ModalHeader.js.map +0 -1
- package/build/legacy/components/ModalHeading.js +0 -7
- package/build/legacy/components/ModalHeading.js.map +0 -1
- package/build/legacy/components/ModalIcon.js +0 -7
- package/build/legacy/components/ModalIcon.js.map +0 -1
- package/build/legacy/components/NavMenuLink.js +0 -8
- package/build/legacy/components/NavMenuLink.js.map +0 -1
- package/build/legacy/components/NavMenuList.js +0 -12
- package/build/legacy/components/NavMenuList.js.map +0 -1
- package/build/legacy/components/NavMenuTrigger.js +0 -11
- package/build/legacy/components/NavMenuTrigger.js.map +0 -1
- package/build/legacy/components/Notification.js +0 -11
- package/build/legacy/components/Notification.js.map +0 -1
- package/build/legacy/components/NotificationDescription.js +0 -7
- package/build/legacy/components/NotificationDescription.js.map +0 -1
- package/build/legacy/components/NotificationHeading.js +0 -7
- package/build/legacy/components/NotificationHeading.js.map +0 -1
- package/build/legacy/components/Portal.js +0 -7
- package/build/legacy/components/Portal.js.map +0 -1
- package/build/legacy/components/Radio.js +0 -9
- package/build/legacy/components/Radio.js.map +0 -1
- package/build/legacy/components/Show.js +0 -8
- package/build/legacy/components/Show.js.map +0 -1
- package/build/legacy/components/Tab.js +0 -10
- package/build/legacy/components/Tab.js.map +0 -1
- package/build/legacy/components/TabList.js +0 -9
- package/build/legacy/components/TabList.js.map +0 -1
- package/build/legacy/components/TabPanel.js +0 -10
- package/build/legacy/components/TabPanel.js.map +0 -1
- package/build/legacy/components/Table.js +0 -9
- package/build/legacy/components/Table.js.map +0 -1
- package/build/legacy/components/Tag.js +0 -8
- package/build/legacy/components/Tag.js.map +0 -1
- package/build/legacy/components/Tbody.js +0 -7
- package/build/legacy/components/Tbody.js.map +0 -1
- package/build/legacy/components/Td.js +0 -7
- package/build/legacy/components/Td.js.map +0 -1
- package/build/legacy/components/Textarea.js +0 -9
- package/build/legacy/components/Textarea.js.map +0 -1
- package/build/legacy/components/Th.js +0 -8
- package/build/legacy/components/Th.js.map +0 -1
- package/build/legacy/components/Thead.js +0 -7
- package/build/legacy/components/Thead.js.map +0 -1
- package/build/legacy/components/Toggle.js +0 -11
- package/build/legacy/components/Toggle.js.map +0 -1
- package/build/legacy/config/cerbIcons.js +0 -7
- package/build/legacy/config/cerbIcons.js.map +0 -1
- package/build/legacy/config/defineIcons.js +0 -10
- package/build/legacy/config/defineIcons.js.map +0 -1
- package/build/legacy/context/confirm-modal.js +0 -22
- package/build/legacy/context/confirm-modal.js.map +0 -1
- package/build/legacy/context/feature-flags.js +0 -10
- package/build/legacy/context/feature-flags.js.map +0 -1
- package/build/legacy/context/field.js +0 -10
- package/build/legacy/context/field.js.map +0 -1
- package/build/legacy/context/navMenu.js +0 -10
- package/build/legacy/context/navMenu.js.map +0 -1
- package/build/legacy/context/notification-center.js +0 -19
- package/build/legacy/context/notification-center.js.map +0 -1
- package/build/legacy/context/prompt-modal.js +0 -25
- package/build/legacy/context/prompt-modal.js.map +0 -1
- package/build/legacy/context/tabs.js +0 -12
- package/build/legacy/context/tabs.js.map +0 -1
- package/build/legacy/context/theme.js +0 -14
- package/build/legacy/context/theme.js.map +0 -1
- package/build/legacy/hooks/useModal.js +0 -8
- package/build/legacy/hooks/useModal.js.map +0 -1
- package/build/legacy/hooks/useTheme.js +0 -8
- package/build/legacy/hooks/useTheme.js.map +0 -1
- package/build/legacy/hooks/useToggle.js +0 -8
- package/build/legacy/hooks/useToggle.js.map +0 -1
- package/build/legacy/index.js +0 -226
- package/build/legacy/index.js.map +0 -1
- package/build/legacy/types.js +0 -2
- package/build/legacy/types.js.map +0 -1
- package/build/modern/chunk-4N2L357B.js.map +0 -1
- package/build/modern/chunk-BEYPMC73.js.map +0 -1
- package/build/modern/chunk-GVNPFXKL.js +0 -26
- package/build/modern/chunk-GVNPFXKL.js.map +0 -1
- package/build/modern/chunk-IL5ELPTT.js +0 -58
- package/build/modern/chunk-IL5ELPTT.js.map +0 -1
- package/build/modern/chunk-JJGZRBIR.js +0 -49
- package/build/modern/chunk-JJGZRBIR.js.map +0 -1
- package/build/modern/chunk-JJP2TFTU.js +0 -29
- package/build/modern/chunk-JJP2TFTU.js.map +0 -1
- package/build/modern/chunk-XB4ZRAH4.js.map +0 -1
- /package/build/legacy/{noExternals.d.ts → noExternals.d.cts} +0 -0
- /package/build/{legacy/chunk-XB4ZRAH4.js.map → modern/chunk-53QBTZZF.js.map} +0 -0
- /package/build/{legacy/chunk-BEYPMC73.js.map → modern/chunk-5WVXIAG2.js.map} +0 -0
- /package/build/{legacy/chunk-LF2QFS5S.js.map → modern/chunk-EJIMJWPB.js.map} +0 -0
- /package/build/modern/{chunk-Y5IY7O23.js.map → chunk-GZY6CH7D.js.map} +0 -0
- /package/build/{legacy/chunk-IL5ELPTT.js.map → modern/chunk-ID3XWGLY.js.map} +0 -0
- /package/build/modern/{chunk-LTDNZRUY.js.map → chunk-S6CMAXQF.js.map} +0 -0
- /package/build/modern/{chunk-QO2UXGW4.js.map → chunk-VPWBSZAR.js.map} +0 -0
- /package/build/{legacy/aria-helpers/nav-menu.aria.js.map → modern/components/Checkbox.js.map} +0 -0
- /package/build/{legacy/aria-helpers/tabs.aria.js.map → modern/components/FileStatus.js.map} +0 -0
- /package/build/{legacy/aria-helpers/trap-focus.aria.js.map → modern/components/ProgressBar.js.map} +0 -0
- /package/build/{legacy/chunk-55J6XMHW.js.map → modern/components/Select.js.map} +0 -0
- /package/build/{legacy/components/Button.js.map → modern/config/icons/checkbox.icons.js.map} +0 -0
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/context/prompt-modal.tsx
|
|
22
|
+
var prompt_modal_exports = {};
|
|
23
|
+
__export(prompt_modal_exports, {
|
|
24
|
+
PromptModal: () => PromptModal,
|
|
25
|
+
usePromptModal: () => usePromptModal
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(prompt_modal_exports);
|
|
28
|
+
var import_react5 = require("react");
|
|
29
|
+
|
|
30
|
+
// src/components/Portal.tsx
|
|
31
|
+
var import_react_dom = require("react-dom");
|
|
32
|
+
function Portal(props) {
|
|
33
|
+
const container = props.container || document.body;
|
|
34
|
+
return (0, import_react_dom.createPortal)(props.children, container, props.key);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/components/Button.tsx
|
|
38
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
39
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
40
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
function Button(props) {
|
|
42
|
+
const { palette, usage, shape, ...nativeProps } = props;
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
...nativeProps,
|
|
47
|
+
className: (0, import_css.cx)(
|
|
48
|
+
nativeProps.className,
|
|
49
|
+
(0, import_recipes.button)({
|
|
50
|
+
palette,
|
|
51
|
+
usage,
|
|
52
|
+
shape
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/context/prompt-modal.tsx
|
|
60
|
+
var import_css9 = require("@cerberus/styled-system/css");
|
|
61
|
+
var import_patterns4 = require("@cerberus/styled-system/patterns");
|
|
62
|
+
|
|
63
|
+
// src/aria-helpers/trap-focus.aria.ts
|
|
64
|
+
function trapFocus(modalRef) {
|
|
65
|
+
var _a;
|
|
66
|
+
const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
67
|
+
const focusable = Array.from(
|
|
68
|
+
((_a = modalRef.current) == null ? void 0 : _a.querySelectorAll(focusableElements)) ?? []
|
|
69
|
+
);
|
|
70
|
+
const firstFocusable = focusable[0];
|
|
71
|
+
const lastFocusable = focusable[focusable.length - 1];
|
|
72
|
+
return function handleKeyDown(event) {
|
|
73
|
+
if (event.key === "Tab") {
|
|
74
|
+
if (event.shiftKey) {
|
|
75
|
+
if (document.activeElement === firstFocusable) {
|
|
76
|
+
lastFocusable.focus();
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
if (document.activeElement === lastFocusable) {
|
|
81
|
+
firstFocusable.focus();
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/components/Input.tsx
|
|
90
|
+
var import_recipes2 = require("@cerberus/styled-system/recipes");
|
|
91
|
+
var import_css2 = require("@cerberus/styled-system/css");
|
|
92
|
+
|
|
93
|
+
// src/context/field.tsx
|
|
94
|
+
var import_react = require("react");
|
|
95
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
96
|
+
var FieldContext = (0, import_react.createContext)(null);
|
|
97
|
+
function Field(props) {
|
|
98
|
+
const value = (0, import_react.useMemo)(
|
|
99
|
+
() => ({
|
|
100
|
+
disabled: props.disabled,
|
|
101
|
+
readOnly: props.readOnly,
|
|
102
|
+
required: props.required,
|
|
103
|
+
invalid: props.invalid
|
|
104
|
+
}),
|
|
105
|
+
[props.disabled, props.readOnly, props.required, props.invalid]
|
|
106
|
+
);
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FieldContext.Provider, { value, children: props.children });
|
|
108
|
+
}
|
|
109
|
+
function useFieldContext() {
|
|
110
|
+
const context = (0, import_react.useContext)(FieldContext);
|
|
111
|
+
if (!context) {
|
|
112
|
+
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
113
|
+
}
|
|
114
|
+
return context;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/config/cerbIcons.ts
|
|
118
|
+
var import_icons = require("@cerberus/icons");
|
|
119
|
+
|
|
120
|
+
// src/config/icons/checkbox.icons.tsx
|
|
121
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
122
|
+
function CheckmarkIcon(props) {
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
124
|
+
"svg",
|
|
125
|
+
{
|
|
126
|
+
"aria-hidden": "true",
|
|
127
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
128
|
+
fill: "none",
|
|
129
|
+
role: "img",
|
|
130
|
+
viewBox: "0 0 24 24",
|
|
131
|
+
...props,
|
|
132
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
133
|
+
"path",
|
|
134
|
+
{
|
|
135
|
+
fill: "currentColor",
|
|
136
|
+
d: "M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z"
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function IndeterminateIcon(props) {
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
144
|
+
"svg",
|
|
145
|
+
{
|
|
146
|
+
"aria-hidden": "true",
|
|
147
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
148
|
+
role: "img",
|
|
149
|
+
fill: "none",
|
|
150
|
+
viewBox: "0 0 24 24",
|
|
151
|
+
...props,
|
|
152
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/config/cerbIcons.ts
|
|
158
|
+
var defaultIcons = {
|
|
159
|
+
checkbox: CheckmarkIcon,
|
|
160
|
+
close: import_icons.CloseFilled,
|
|
161
|
+
confirmModal: import_icons.Information,
|
|
162
|
+
delete: import_icons.TrashCan,
|
|
163
|
+
promptModal: import_icons.Information,
|
|
164
|
+
fileUploader: import_icons.CloudUpload,
|
|
165
|
+
indeterminate: IndeterminateIcon,
|
|
166
|
+
infoNotification: import_icons.InformationFilled,
|
|
167
|
+
successNotification: import_icons.CheckmarkFilled,
|
|
168
|
+
warningNotification: import_icons.WarningFilled,
|
|
169
|
+
dangerNotification: import_icons.ErrorFilled,
|
|
170
|
+
invalid: import_icons.WarningFilled,
|
|
171
|
+
invalidAlt: import_icons.Warning,
|
|
172
|
+
redo: import_icons.Restart,
|
|
173
|
+
selectArrow: import_icons.ChevronDown,
|
|
174
|
+
toggleChecked: import_icons.Checkmark
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/config/defineIcons.ts
|
|
178
|
+
var $cerberusIcons = defaultIcons;
|
|
179
|
+
|
|
180
|
+
// src/components/Show.tsx
|
|
181
|
+
var import_react2 = require("react");
|
|
182
|
+
function Show(props) {
|
|
183
|
+
const { when, children, fallback } = props;
|
|
184
|
+
const condition = (0, import_react2.useMemo)(() => when ?? false, [when]);
|
|
185
|
+
return (0, import_react2.useMemo)(() => {
|
|
186
|
+
if (condition) return children;
|
|
187
|
+
return fallback ?? null;
|
|
188
|
+
}, [condition, children, fallback]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/components/Input.tsx
|
|
192
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
193
|
+
function Input(props) {
|
|
194
|
+
const { describedBy, size, startIcon, endIcon, ...nativeProps } = props;
|
|
195
|
+
const inputStyles = (0, import_recipes2.input)({ size });
|
|
196
|
+
const { invalid, ...fieldStates } = useFieldContext();
|
|
197
|
+
const hasEndIcon = Boolean(endIcon);
|
|
198
|
+
const { invalid: InvalidIcon } = $cerberusIcons;
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: inputStyles.root, children: [
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Show, { when: Boolean(startIcon), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: inputStyles.startIcon, children: startIcon }) }),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
202
|
+
"input",
|
|
203
|
+
{
|
|
204
|
+
...nativeProps,
|
|
205
|
+
...fieldStates,
|
|
206
|
+
...describedBy && { "aria-describedby": describedBy },
|
|
207
|
+
...invalid && { "aria-invalid": true },
|
|
208
|
+
"data-start-icon": Boolean(startIcon),
|
|
209
|
+
className: (0, import_css2.cx)("peer", nativeProps.className, inputStyles.input)
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Show, { when: invalid, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InvalidIcon, { className: inputStyles.icon }) }),
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Show, { when: hasEndIcon && !invalid, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: inputStyles.icon, children: endIcon }) })
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/components/Label.tsx
|
|
218
|
+
var import_recipes3 = require("@cerberus/styled-system/recipes");
|
|
219
|
+
var import_css3 = require("@cerberus/styled-system/css");
|
|
220
|
+
var import_patterns = require("@cerberus/styled-system/patterns");
|
|
221
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
222
|
+
function Label(props) {
|
|
223
|
+
const { hidden, size, ...nativeProps } = props;
|
|
224
|
+
const { required, disabled } = useFieldContext();
|
|
225
|
+
const usage = hidden ? "hidden" : "visible";
|
|
226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
227
|
+
"label",
|
|
228
|
+
{
|
|
229
|
+
...nativeProps,
|
|
230
|
+
...disabled && { "data-disabled": true },
|
|
231
|
+
className: (0, import_css3.cx)(
|
|
232
|
+
nativeProps.className,
|
|
233
|
+
(0, import_recipes3.label)({ size, usage }),
|
|
234
|
+
(0, import_patterns.hstack)({
|
|
235
|
+
justify: "space-between",
|
|
236
|
+
w: "full"
|
|
237
|
+
})
|
|
238
|
+
),
|
|
239
|
+
children: [
|
|
240
|
+
props.children,
|
|
241
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Show, { when: required, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
242
|
+
"span",
|
|
243
|
+
{
|
|
244
|
+
className: (0, import_css3.css)({
|
|
245
|
+
color: "inherit",
|
|
246
|
+
fontSize: "inherit"
|
|
247
|
+
}),
|
|
248
|
+
children: "(required)"
|
|
249
|
+
}
|
|
250
|
+
) })
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/components/ModalIcon.tsx
|
|
257
|
+
var import_css4 = require("@cerberus/styled-system/css");
|
|
258
|
+
var import_patterns2 = require("@cerberus/styled-system/patterns");
|
|
259
|
+
var import_recipes4 = require("@cerberus/styled-system/recipes");
|
|
260
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
261
|
+
function ModalIcon(props) {
|
|
262
|
+
const { palette, ...nativeProps } = props;
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
264
|
+
"div",
|
|
265
|
+
{
|
|
266
|
+
...nativeProps,
|
|
267
|
+
className: (0, import_css4.cx)(
|
|
268
|
+
nativeProps.className,
|
|
269
|
+
(0, import_recipes4.modalIcon)({
|
|
270
|
+
palette
|
|
271
|
+
}),
|
|
272
|
+
(0, import_patterns2.circle)()
|
|
273
|
+
),
|
|
274
|
+
children: props.children
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/hooks/useModal.ts
|
|
280
|
+
var import_react3 = require("react");
|
|
281
|
+
function useModal() {
|
|
282
|
+
const modalRef = (0, import_react3.useRef)(null);
|
|
283
|
+
const show = (0, import_react3.useCallback)(() => {
|
|
284
|
+
var _a;
|
|
285
|
+
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
286
|
+
}, []);
|
|
287
|
+
const close = (0, import_react3.useCallback)(() => {
|
|
288
|
+
var _a;
|
|
289
|
+
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
290
|
+
}, []);
|
|
291
|
+
return (0, import_react3.useMemo)(() => {
|
|
292
|
+
return {
|
|
293
|
+
modalRef,
|
|
294
|
+
show,
|
|
295
|
+
close
|
|
296
|
+
};
|
|
297
|
+
}, [modalRef, show, close]);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/components/Modal.tsx
|
|
301
|
+
var import_css5 = require("@cerberus/styled-system/css");
|
|
302
|
+
var import_recipes5 = require("@cerberus/styled-system/recipes");
|
|
303
|
+
var import_react4 = require("react");
|
|
304
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
305
|
+
function ModalEl(props, ref) {
|
|
306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
307
|
+
"dialog",
|
|
308
|
+
{
|
|
309
|
+
...props,
|
|
310
|
+
className: (0, import_css5.cx)(props.className, (0, import_recipes5.modal)().dialog),
|
|
311
|
+
ref
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
var Modal = (0, import_react4.forwardRef)(ModalEl);
|
|
316
|
+
|
|
317
|
+
// src/components/ModalHeader.tsx
|
|
318
|
+
var import_css6 = require("@cerberus/styled-system/css");
|
|
319
|
+
var import_patterns3 = require("@cerberus/styled-system/patterns");
|
|
320
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
321
|
+
function ModalHeader(props) {
|
|
322
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
323
|
+
"div",
|
|
324
|
+
{
|
|
325
|
+
...props,
|
|
326
|
+
className: (0, import_css6.cx)(
|
|
327
|
+
props.className,
|
|
328
|
+
(0, import_patterns3.vstack)({
|
|
329
|
+
alignItems: "flex-start",
|
|
330
|
+
gap: "4",
|
|
331
|
+
mb: "8"
|
|
332
|
+
})
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/components/ModalHeading.tsx
|
|
339
|
+
var import_css7 = require("@cerberus/styled-system/css");
|
|
340
|
+
var import_recipes6 = require("@cerberus/styled-system/recipes");
|
|
341
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
342
|
+
function ModalHeading(props) {
|
|
343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { ...props, className: (0, import_css7.cx)(props.className, (0, import_recipes6.modal)().heading) });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/components/ModalDescription.tsx
|
|
347
|
+
var import_css8 = require("@cerberus/styled-system/css");
|
|
348
|
+
var import_recipes7 = require("@cerberus/styled-system/recipes");
|
|
349
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
350
|
+
function ModalDescription(props) {
|
|
351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { ...props, className: (0, import_css8.cx)(props.className, (0, import_recipes7.modal)().description) });
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/context/prompt-modal.tsx
|
|
355
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
356
|
+
var PromptModalContext = (0, import_react5.createContext)(null);
|
|
357
|
+
function PromptModal(props) {
|
|
358
|
+
const { modalRef, show, close } = useModal();
|
|
359
|
+
const resolveRef = (0, import_react5.useRef)(null);
|
|
360
|
+
const [content, setContent] = (0, import_react5.useState)(null);
|
|
361
|
+
const [inputValue, setInputValue] = (0, import_react5.useState)("");
|
|
362
|
+
const focusTrap = trapFocus(modalRef);
|
|
363
|
+
const PromptIcon = $cerberusIcons.promptModal;
|
|
364
|
+
const isValid = (0, import_react5.useMemo)(
|
|
365
|
+
() => inputValue === (content == null ? void 0 : content.key),
|
|
366
|
+
[inputValue, content]
|
|
367
|
+
);
|
|
368
|
+
const palette = (0, import_react5.useMemo)(
|
|
369
|
+
() => (content == null ? void 0 : content.kind) === "destructive" ? "danger" : "action",
|
|
370
|
+
[content]
|
|
371
|
+
);
|
|
372
|
+
const handleChange = (0, import_react5.useCallback)(
|
|
373
|
+
(e) => {
|
|
374
|
+
setInputValue(e.currentTarget.value);
|
|
375
|
+
},
|
|
376
|
+
[content]
|
|
377
|
+
);
|
|
378
|
+
const handleChoice = (0, import_react5.useCallback)(
|
|
379
|
+
(e) => {
|
|
380
|
+
var _a;
|
|
381
|
+
const target = e.currentTarget;
|
|
382
|
+
if (target.value === "true") {
|
|
383
|
+
(_a = resolveRef.current) == null ? void 0 : _a.call(resolveRef, inputValue);
|
|
384
|
+
}
|
|
385
|
+
close();
|
|
386
|
+
},
|
|
387
|
+
[inputValue, close]
|
|
388
|
+
);
|
|
389
|
+
const handleShow = (0, import_react5.useCallback)(
|
|
390
|
+
(options) => {
|
|
391
|
+
return new Promise((resolve) => {
|
|
392
|
+
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
393
|
+
show();
|
|
394
|
+
resolveRef.current = resolve;
|
|
395
|
+
});
|
|
396
|
+
},
|
|
397
|
+
[show]
|
|
398
|
+
);
|
|
399
|
+
const value = (0, import_react5.useMemo)(
|
|
400
|
+
() => ({
|
|
401
|
+
show: handleShow
|
|
402
|
+
}),
|
|
403
|
+
[handleShow]
|
|
404
|
+
);
|
|
405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(PromptModalContext.Provider, { value, children: [
|
|
406
|
+
props.children,
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ModalHeader, { children: [
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
410
|
+
Show,
|
|
411
|
+
{
|
|
412
|
+
when: palette === "danger",
|
|
413
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ModalIcon, { palette: "action", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PromptIcon, { size: 24 }) }),
|
|
414
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ModalIcon, { palette: "danger", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PromptIcon, { size: 24 }) })
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ModalHeading, { children: content == null ? void 0 : content.heading }),
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ModalDescription, { children: content == null ? void 0 : content.description })
|
|
419
|
+
] }),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
421
|
+
"div",
|
|
422
|
+
{
|
|
423
|
+
className: (0, import_patterns4.vstack)({
|
|
424
|
+
alignItems: "flex-start",
|
|
425
|
+
mt: "4",
|
|
426
|
+
mb: "8"
|
|
427
|
+
}),
|
|
428
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Field, { invalid: !isValid, children: [
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Label, { htmlFor: "confirm", size: "md", children: [
|
|
430
|
+
"Type",
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
432
|
+
"strong",
|
|
433
|
+
{
|
|
434
|
+
className: (0, import_css9.css)({
|
|
435
|
+
textTransform: "uppercase"
|
|
436
|
+
}),
|
|
437
|
+
children: content == null ? void 0 : content.key
|
|
438
|
+
}
|
|
439
|
+
),
|
|
440
|
+
"to confirm"
|
|
441
|
+
] }),
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
443
|
+
Input,
|
|
444
|
+
{
|
|
445
|
+
id: "confirm",
|
|
446
|
+
name: "confirm",
|
|
447
|
+
onChange: handleChange,
|
|
448
|
+
type: "text"
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
] })
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
455
|
+
"div",
|
|
456
|
+
{
|
|
457
|
+
className: (0, import_patterns4.hstack)({
|
|
458
|
+
justifyContent: "stretch",
|
|
459
|
+
gap: "4"
|
|
460
|
+
}),
|
|
461
|
+
children: [
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
463
|
+
Button,
|
|
464
|
+
{
|
|
465
|
+
autoFocus: true,
|
|
466
|
+
className: (0, import_css9.css)({
|
|
467
|
+
w: "1/2"
|
|
468
|
+
}),
|
|
469
|
+
disabled: !isValid,
|
|
470
|
+
name: "confirm",
|
|
471
|
+
onClick: handleChoice,
|
|
472
|
+
palette,
|
|
473
|
+
value: "true",
|
|
474
|
+
children: content == null ? void 0 : content.actionText
|
|
475
|
+
}
|
|
476
|
+
),
|
|
477
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
478
|
+
Button,
|
|
479
|
+
{
|
|
480
|
+
className: (0, import_css9.css)({
|
|
481
|
+
w: "1/2"
|
|
482
|
+
}),
|
|
483
|
+
name: "cancel",
|
|
484
|
+
onClick: handleChoice,
|
|
485
|
+
usage: "outlined",
|
|
486
|
+
value: "false",
|
|
487
|
+
children: content == null ? void 0 : content.cancelText
|
|
488
|
+
}
|
|
489
|
+
)
|
|
490
|
+
]
|
|
491
|
+
}
|
|
492
|
+
)
|
|
493
|
+
] }) })
|
|
494
|
+
] });
|
|
495
|
+
}
|
|
496
|
+
function usePromptModal() {
|
|
497
|
+
const context = (0, import_react5.useContext)(PromptModalContext);
|
|
498
|
+
if (context === null) {
|
|
499
|
+
throw new Error("usePromptModal must be used within a PromptModal Provider");
|
|
500
|
+
}
|
|
501
|
+
return context;
|
|
502
|
+
}
|
|
503
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
504
|
+
0 && (module.exports = {
|
|
505
|
+
PromptModal,
|
|
506
|
+
usePromptModal
|
|
507
|
+
});
|
|
508
|
+
//# sourceMappingURL=prompt-modal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/prompt-modal.tsx","../../../src/components/Portal.tsx","../../../src/components/Button.tsx","../../../src/aria-helpers/trap-focus.aria.ts","../../../src/components/Input.tsx","../../../src/context/field.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/config/defineIcons.ts","../../../src/components/Show.tsx","../../../src/components/Label.tsx","../../../src/components/ModalIcon.tsx","../../../src/hooks/useModal.ts","../../../src/components/Modal.tsx","../../../src/components/ModalHeader.tsx","../../../src/components/ModalHeading.tsx","../../../src/components/ModalDescription.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type MouseEvent,\n type PropsWithChildren,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { css } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Input } from '../components/Input'\nimport { Field } from './field'\nimport { Label } from '../components/Label'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { ModalIcon } from '../components/ModalIcon'\nimport { Show } from '../components/Show'\nimport { useModal } from '../hooks/useModal'\nimport { Modal } from '../components/Modal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\n\n/**\n * This module provides a context and hook for the prompt modal.\n * @module\n */\n\nexport interface ShowPromptModalOptions {\n kind?: 'destructive' | 'non-destructive'\n heading: string\n description?: string\n key: string\n actionText: string\n cancelText: string\n}\nexport type PromptShowResult =\n | ((value: string | PromiseLike<string>) => void)\n | null\n\nexport interface PromptModalValue {\n show: (options: ShowPromptModalOptions) => Promise<string>\n}\n\nconst PromptModalContext = createContext<PromptModalValue | null>(null)\n\nexport interface PromptModalProviderProps {}\n\n/**\n * Provides a prompt modal to the app.\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <PromptModal>\n * <SomeFeatureSection />\n * </PromptModal>\n *\n * // Use the hook to show the prompt modal.\n * const prompt = usePromptModal()\n *\n * const handleClick = useCallback(async () => {\n * const accepted = await prompt.show({\n * kind: 'destructive',\n * heading: 'Delete channel?',\n * description:\n * 'This will permanently delete a channel on your account. There is no going back.',\n * key: CHANNEL_NAME,\n * actionText: 'Yes, delete channel',\n * cancelText: 'No, cancel',\n * })\n * // do something with accepted\n * }, [prompt])\n * ```\n */\nexport function PromptModal(\n props: PropsWithChildren<PromptModalProviderProps>,\n) {\n const { modalRef, show, close } = useModal()\n const resolveRef = useRef<PromptShowResult>(null)\n const [content, setContent] = useState<ShowPromptModalOptions | null>(null)\n const [inputValue, setInputValue] = useState<string>('')\n const focusTrap = trapFocus(modalRef)\n const PromptIcon = $cerberusIcons.promptModal\n\n const isValid = useMemo(\n () => inputValue === content?.key,\n [inputValue, content],\n )\n\n const palette = useMemo(\n () => (content?.kind === 'destructive' ? 'danger' : 'action'),\n [content],\n )\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setInputValue(e.currentTarget.value)\n },\n [content],\n )\n\n const handleChoice = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n if (target.value === 'true') {\n resolveRef.current?.(inputValue)\n }\n close()\n },\n [inputValue, close],\n )\n\n const handleShow = useCallback(\n (options: ShowPromptModalOptions) => {\n return new Promise<string>((resolve) => {\n setContent({ ...options, kind: options.kind || 'non-destructive' })\n show()\n resolveRef.current = resolve\n })\n },\n [show],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <PromptModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <ModalHeader>\n <Show\n when={palette === 'danger'}\n fallback={\n <ModalIcon palette=\"action\">\n <PromptIcon size={24} />\n </ModalIcon>\n }\n >\n <ModalIcon palette=\"danger\">\n <PromptIcon size={24} />\n </ModalIcon>\n </Show>\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </ModalHeader>\n\n <div\n className={vstack({\n alignItems: 'flex-start',\n mt: '4',\n mb: '8',\n })}\n >\n <Field invalid={!isValid}>\n <Label htmlFor=\"confirm\" size=\"md\">\n Type\n <strong\n className={css({\n textTransform: 'uppercase',\n })}\n >\n {content?.key}\n </strong>\n to confirm\n </Label>\n <Input\n id=\"confirm\"\n name=\"confirm\"\n onChange={handleChange}\n type=\"text\"\n />\n </Field>\n </div>\n\n <div\n className={hstack({\n justifyContent: 'stretch',\n gap: '4',\n })}\n >\n <Button\n autoFocus\n className={css({\n w: '1/2',\n })}\n disabled={!isValid}\n name=\"confirm\"\n onClick={handleChoice}\n palette={palette}\n value=\"true\"\n >\n {content?.actionText}\n </Button>\n <Button\n className={css({\n w: '1/2',\n })}\n name=\"cancel\"\n onClick={handleChoice}\n usage=\"outlined\"\n value=\"false\"\n >\n {content?.cancelText}\n </Button>\n </div>\n </Modal>\n </Portal>\n </PromptModalContext.Provider>\n )\n}\n\nexport function usePromptModal(): PromptModalValue {\n const context = useContext(PromptModalContext)\n if (context === null) {\n throw new Error('usePromptModal must be used within a PromptModal Provider')\n }\n return context\n}\n","import type { PropsWithChildren } from 'react'\nimport { createPortal } from 'react-dom'\n\n/**\n * This module is the Portal component.\n * @module\n */\n\nexport interface PortalProps {\n container?: Element | DocumentFragment\n key?: null | string\n}\n\n/**\n * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.\n * @param container - The props for the Portal component.\n * @returns ReactPortal\n */\nexport function Portal(props: PropsWithChildren<PortalProps>) {\n const container = props.container || document.body\n return createPortal(props.children, container, props.key)\n}\n","import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n button,\n type ButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the Button component.\n * @module\n */\n\nexport type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n ButtonVariantProps\n\n/**\n * A component that allows the user to perform actions\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Button.tsx\n */\nexport function Button(props: ButtonProps): JSX.Element {\n const { palette, usage, shape, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n />\n )\n}\n","import type { KeyboardEvent, KeyboardEventHandler, RefObject } from 'react'\n\nexport function trapFocus(\n modalRef: RefObject<HTMLDialogElement>,\n): KeyboardEventHandler<HTMLDialogElement> {\n const focusableElements =\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n const focusable = Array.from(\n modalRef.current?.querySelectorAll(focusableElements) ?? [],\n )\n const firstFocusable = focusable[0] as HTMLElement\n const lastFocusable = focusable[focusable.length - 1] as HTMLElement\n\n return function handleKeyDown(event: KeyboardEvent<HTMLDialogElement>) {\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n if (document.activeElement === firstFocusable) {\n lastFocusable.focus()\n event.preventDefault()\n }\n } else {\n if (document.activeElement === lastFocusable) {\n firstFocusable.focus()\n event.preventDefault()\n }\n }\n }\n }\n}\n","'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Show } from './Show'\n\nexport type InputRecipeProps = RecipeVariantProps<typeof input>\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n startIcon?: ReactNode\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputRecipeProps\n\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n const { invalid: InvalidIcon } = $cerberusIcons\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <InvalidIcon className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n","'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\nexport interface FieldContextValue {\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n invalid?: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\nexport function Field(\n props: PropsWithChildren<FieldContextValue>,\n): JSX.Element {\n const value = useMemo(\n () => ({\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n invalid: props.invalid,\n }),\n [props.disabled, props.readOnly, props.required, props.invalid],\n )\n\n return (\n <FieldContext.Provider value={value}>\n {props.children}\n </FieldContext.Provider>\n )\n}\n\nexport function useFieldContext(): FieldContextValue {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useFieldContext must be used within a Field Provider.')\n }\n return context\n}\n","import {\n Checkmark,\n CheckmarkFilled,\n ChevronDown,\n CloseFilled,\n CloudUpload,\n ErrorFilled,\n Information,\n InformationFilled,\n Restart,\n TrashCan,\n Warning,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: IconType\n fileUploader?: IconType\n indeterminate?: IconType\n infoNotification?: IconType\n successNotification?: IconType\n warningNotification?: IconType\n dangerNotification?: IconType\n invalid: IconType\n invalidAlt?: IconType\n redo?: IconType\n selectArrow?: IconType\n toggleChecked?: IconType\n}\n\nexport const defaultIcons: DefinedIcons = {\n checkbox: CheckmarkIcon,\n close: CloseFilled,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n fileUploader: CloudUpload,\n indeterminate: IndeterminateIcon,\n infoNotification: InformationFilled,\n successNotification: CheckmarkFilled,\n warningNotification: WarningFilled,\n dangerNotification: ErrorFilled,\n invalid: WarningFilled,\n invalidAlt: Warning,\n redo: Restart,\n selectArrow: ChevronDown,\n toggleChecked: Checkmark,\n}\n","import type { SVGProps } from 'react'\n\n/**\n * This module contains substitute icons for the Checkbox component.\n * @module\n */\n\ninterface CheckboxIconProps extends SVGProps<SVGSVGElement> {}\n\n/**\n * Checkmark icon for Checkbox component\n */\nexport function CheckmarkIcon(props: CheckboxIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n role=\"img\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path\n fill=\"currentColor\"\n d=\"M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z\"\n />\n </svg>\n )\n}\n\ninterface IndeterminateIconProps extends SVGProps<SVGSVGElement> {}\n\n/**\n * Indeterminate icon for Checkbox component\n */\nexport function IndeterminateIcon(props: IndeterminateIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n role=\"img\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path fill=\"currentColor\" d=\"M4 11h16v2.667H4z\" />\n </svg>\n )\n}\n","import { defaultIcons, type DefinedIcons } from './cerbIcons'\n\nfunction _validateIconsProperties(icons: DefinedIcons) {\n if (!icons.invalid) {\n throw new Error(\n 'The an invalid property must be defined in your custom icons library.',\n )\n }\n}\n\nexport function defineIcons(icons: DefinedIcons): Required<DefinedIcons> {\n _validateIconsProperties(icons)\n $cerberusIcons = {\n ...defaultIcons,\n ...icons,\n } as Required<DefinedIcons>\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons = defaultIcons as Required<DefinedIcons>\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\nexport interface ShowProps {\n when: boolean | null | undefined\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render its children or an optional fallback component\n * based on the SolidJS component.\n * @definition [Show docs](https://cerberus.digitalu.design/react/show)\n * @example\n * ```tsx\n * <Show when={condition}>\n * <div>Content</div>\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n","'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n {...(disabled && { 'data-disabled': true })}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n w: 'full',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: 'inherit',\n fontSize: 'inherit',\n })}\n >\n (required)\n </span>\n </Show>\n </label>\n )\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n modalIcon,\n type ModalIconVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\n\nexport type ModalIconProps = HTMLAttributes<HTMLDivElement> &\n ModalIconVariantProps\n\nexport function ModalIcon(props: PropsWithChildren<ModalIconProps>) {\n const { palette, ...nativeProps } = props\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n modalIcon({\n palette,\n }),\n circle(),\n )}\n >\n {props.children}\n </div>\n )\n}\n","'use client'\n\nimport { useCallback, useMemo, useRef, type RefObject } from 'react'\n\n/**\n * This module provides a hook for using a custom modal.\n * @module\n */\n\ninterface UseModalReturnValue {\n modalRef: RefObject<HTMLDialogElement>\n show: () => void\n close: () => void\n}\n\nexport function useModal(): UseModalReturnValue {\n const modalRef = useRef<HTMLDialogElement | null>(null)\n\n const show = useCallback(() => {\n modalRef.current?.showModal()\n }, [])\n\n const close = useCallback(() => {\n modalRef.current?.close()\n }, [])\n\n return useMemo(() => {\n return {\n modalRef,\n show,\n close,\n }\n }, [modalRef, show, close])\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport { forwardRef, type ForwardedRef, type HTMLAttributes } from 'react'\n\n/**\n * This module contains the Modal root component for a customizable modal.\n * @module\n */\n\n// Modal\n\nexport type ModalProps = HTMLAttributes<HTMLDialogElement>\n\nfunction ModalEl(props: ModalProps, ref: ForwardedRef<HTMLDialogElement>) {\n return (\n <dialog\n {...props}\n className={cx(props.className, modal().dialog)}\n ref={ref}\n />\n )\n}\n\n/**\n * The Modal component is the root element for a customizable modal.\n * @example\n * ```tsx\n * const { modalRef } = useModal()\n *\n * <Modal ref={modalRef}>\n * <ModalIcon icon={$cerberusIcons.alert} />\n * <h2>Modal Heading</h2>\n * <p>Modal description</p>\n * </Modal>\n * ```\n */\nexport const Modal = forwardRef(ModalEl)\n","import { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeader component for a customizable modal.\n * @module\n */\n\nexport type ModalHeaderProps = HTMLAttributes<HTMLDivElement>\n\n/**\n * The ModalHeader component is a header element for a customizable modal.\n * @example\n * ```tsx\n * <Modal>\n * <ModalHeader>\n * <h2>Modal Heading</h2>\n * </ModalHeader>\n * </Modal>\n * ```\n */\nexport function ModalHeader(props: ModalHeaderProps) {\n return (\n <div\n {...props}\n className={cx(\n props.className,\n vstack({\n alignItems: 'flex-start',\n gap: '4',\n mb: '8',\n }),\n )}\n />\n )\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeading component for a customizable modal.\n * @module\n */\n\nexport type ModalHeadingProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * The ModalHeading component is a heading element for a customizable modal.\n * @example\n * ```tsx\n * <Modal>\n * <ModalHeading>Modal Heading</ModalHeading>\n * </Modal>\n * ```\n */\nexport function ModalHeading(props: ModalHeadingProps) {\n return <p {...props} className={cx(props.className, modal().heading)} />\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalDescription component for a customizable modal.\n * @module\n */\n\nexport type ModalDescriptionProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * The ModalDescription component is a heading element for a customizable modal.\n * @example\n * ```tsx\n * <Modal>\n * <ModalDescription>Modal Heading</ModalDescription>\n * </Modal>\n * ```\n */\nexport function ModalDescription(props: ModalDescriptionProps) {\n return <p {...props} className={cx(props.className, modal().description)} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAUO;;;ACXP,uBAA6B;AAiBtB,SAAS,OAAO,OAAuC;AAC5D,QAAM,YAAY,MAAM,aAAa,SAAS;AAC9C,aAAO,+BAAa,MAAM,UAAU,WAAW,MAAM,GAAG;AAC1D;;;ACpBA,iBAAmB;AACnB,qBAGO;AAiBH;AAHG,SAAS,OAAO,OAAiC;AACtD,QAAM,EAAE,SAAS,OAAO,OAAO,GAAG,YAAY,IAAI;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,uBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;;;AFnBA,IAAAC,cAAoB;AACpB,IAAAC,mBAA+B;;;AGdxB,SAAS,UACd,UACyC;AAJ3C;AAKE,QAAM,oBACJ;AACF,QAAM,YAAY,MAAM;AAAA,MACtB,cAAS,YAAT,mBAAkB,iBAAiB,uBAAsB,CAAC;AAAA,EAC5D;AACA,QAAM,iBAAiB,UAAU,CAAC;AAClC,QAAM,gBAAgB,UAAU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AAG;AAAA,gBACH,MAAK;AAAA,gBACL,UAAU;AAAA,gBACV,MAAK;AAAA;AAAA,YACP;AAAA,aACF;AAAA;AAAA,MACF;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,eAAW,yBAAO;AAAA,YAChB,gBAAgB;AAAA,YAChB,KAAK;AAAA,UACP,CAAC;AAAA,UAED;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAS;AAAA,gBACT,eAAW,iBAAI;AAAA,kBACb,GAAG;AAAA,gBACL,CAAC;AAAA,gBACD,UAAU,CAAC;AAAA,gBACX,MAAK;AAAA,gBACL,SAAS;AAAA,gBACT;AAAA,gBACA,OAAM;AAAA,gBAEL,6CAAS;AAAA;AAAA,YACZ;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,eAAW,iBAAI;AAAA,kBACb,GAAG;AAAA,gBACL,CAAC;AAAA,gBACD,MAAK;AAAA,gBACL,SAAS;AAAA,gBACT,OAAM;AAAA,gBACN,OAAM;AAAA,gBAEL,6CAAS;AAAA;AAAA,YACZ;AAAA;AAAA;AAAA,MACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;AAEO,SAAS,iBAAmC;AACjD,QAAM,cAAU,0BAAW,kBAAkB;AAC7C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO;AACT;","names":["import_react","import_css","import_patterns","import_recipes","import_css","import_jsx_runtime","import_jsx_runtime","import_react","import_jsx_runtime","import_recipes","import_css","import_jsx_runtime","import_css","import_patterns","import_recipes","import_jsx_runtime","import_react","import_css","import_recipes","import_react","import_jsx_runtime","import_css","import_patterns","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/context/tabs.tsx
|
|
22
|
+
var tabs_exports = {};
|
|
23
|
+
__export(tabs_exports, {
|
|
24
|
+
Tabs: () => Tabs,
|
|
25
|
+
TabsContext: () => TabsContext,
|
|
26
|
+
useTabsContext: () => useTabsContext
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(tabs_exports);
|
|
29
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var TabsContext = (0, import_react.createContext)(null);
|
|
33
|
+
function Tabs(props) {
|
|
34
|
+
const { cache, active, id, palette } = props;
|
|
35
|
+
const [activeTab, setActiveTab] = (0, import_react.useState)(() => cache ? "" : active ?? "");
|
|
36
|
+
const tabsList = (0, import_react.useRef)([]);
|
|
37
|
+
const uuid = (0, import_react.useMemo)(() => {
|
|
38
|
+
return id ? `cerberus-tabs-${id}` : "cerberus-tabs";
|
|
39
|
+
}, [id]);
|
|
40
|
+
const value = (0, import_react.useMemo)(
|
|
41
|
+
() => ({
|
|
42
|
+
tabs: tabsList,
|
|
43
|
+
id: uuid,
|
|
44
|
+
active: activeTab,
|
|
45
|
+
styles: (0, import_recipes.tabs)({ palette }),
|
|
46
|
+
onTabUpdate: setActiveTab
|
|
47
|
+
}),
|
|
48
|
+
[activeTab, setActiveTab, palette, uuid, tabsList]
|
|
49
|
+
);
|
|
50
|
+
(0, import_react.useEffect)(() => {
|
|
51
|
+
if (cache) {
|
|
52
|
+
const cachedTab = window.localStorage.getItem(uuid);
|
|
53
|
+
setActiveTab(
|
|
54
|
+
cache ? cachedTab || (props.active ?? "") : props.active ?? ""
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}, [cache, active, uuid]);
|
|
58
|
+
(0, import_react.useEffect)(() => {
|
|
59
|
+
if (cache && activeTab) {
|
|
60
|
+
window.localStorage.setItem(uuid, activeTab);
|
|
61
|
+
}
|
|
62
|
+
}, [activeTab, cache]);
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabsContext.Provider, { value, children: props.children });
|
|
64
|
+
}
|
|
65
|
+
function useTabsContext() {
|
|
66
|
+
const context = (0, import_react.useContext)(TabsContext);
|
|
67
|
+
if (!context) {
|
|
68
|
+
throw new Error("useTabsContext must be used within a Tabs Provider.");
|
|
69
|
+
}
|
|
70
|
+
return context;
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
Tabs,
|
|
75
|
+
TabsContext,
|
|
76
|
+
useTabsContext
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=tabs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/tabs.tsx"],"sourcesContent":["'use client'\n\nimport { tabs, type TabsVariantProps } from '@cerberus/styled-system/recipes'\nimport type { Pretty } from '@cerberus/styled-system/types'\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type MutableRefObject,\n type PropsWithChildren,\n} from 'react'\n\n/**\n * This module provides a Tabs component and a hook to access its context.\n * @module\n */\n\nexport interface TabsContextValue {\n tabs: MutableRefObject<HTMLButtonElement[]>\n id: string\n active: string\n styles: Pretty<Record<'tabList' | 'tab' | 'tabPanel', string>>\n onTabUpdate: (active: string) => void\n}\n\nexport const TabsContext = createContext<TabsContextValue | null>(null)\n\nexport interface TabsProps {\n id?: string\n active?: string\n cache?: boolean\n}\n\n/**\n * The Tabs component provides a context to manage tab state.\n * @param id - the id of the tabs component,\n * @param active - the default active tab id,\n * @param cache - whether to cache the active tab state in local storage\n * @example\n * ```tsx\n * <Tabs cache>\n * <TabList description=\"Button details\">\n * <Tab id=\"overview\">Overview</Tab>\n * <Tab id=\"guidelines\">Guidelines</Tab>\n * </TabList>\n * <TabPanels>\n * <TabPanel id=\"overview\">Overview content</TabPanel>\n * <TabPanel id=\"guidelines\">Guidelines content</TabPanel>\n * </TabPanels>\n * </Tabs>\n * ```\n */\nexport function Tabs(\n props: PropsWithChildren<TabsProps & TabsVariantProps>,\n): JSX.Element {\n const { cache, active, id, palette } = props\n const [activeTab, setActiveTab] = useState(() => (cache ? '' : active ?? ''))\n const tabsList = useRef<HTMLButtonElement[]>([])\n const uuid = useMemo(() => {\n return id ? `cerberus-tabs-${id}` : 'cerberus-tabs'\n }, [id])\n\n const value = useMemo(\n () => ({\n tabs: tabsList,\n id: uuid,\n active: activeTab,\n styles: tabs({ palette }),\n onTabUpdate: setActiveTab,\n }),\n [activeTab, setActiveTab, palette, uuid, tabsList],\n )\n\n // Get the active tab from local storage\n useEffect(() => {\n if (cache) {\n const cachedTab = window.localStorage.getItem(uuid)\n setActiveTab(\n cache ? cachedTab || (props.active ?? '') : props.active ?? '',\n )\n }\n }, [cache, active, uuid])\n\n // Update the active tab in local storage\n useEffect(() => {\n if (cache && activeTab) {\n window.localStorage.setItem(uuid, activeTab)\n }\n }, [activeTab, cache])\n\n return (\n <TabsContext.Provider value={value}>{props.children}</TabsContext.Provider>\n )\n}\n\nexport function useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext)\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs Provider.')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAA4C;AAE5C,mBASO;AAiFH;AAlEG,IAAM,kBAAc,4BAAuC,IAAI;AA2B/D,SAAS,KACd,OACa;AACb,QAAM,EAAE,OAAO,QAAQ,IAAI,QAAQ,IAAI;AACvC,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,MAAO,QAAQ,KAAK,UAAU,EAAG;AAC5E,QAAM,eAAW,qBAA4B,CAAC,CAAC;AAC/C,QAAM,WAAO,sBAAQ,MAAM;AACzB,WAAO,KAAK,iBAAiB,EAAE,KAAK;AAAA,EACtC,GAAG,CAAC,EAAE,CAAC;AAEP,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,YAAQ,qBAAK,EAAE,QAAQ,CAAC;AAAA,MACxB,aAAa;AAAA,IACf;AAAA,IACA,CAAC,WAAW,cAAc,SAAS,MAAM,QAAQ;AAAA,EACnD;AAGA,8BAAU,MAAM;AACd,QAAI,OAAO;AACT,YAAM,YAAY,OAAO,aAAa,QAAQ,IAAI;AAClD;AAAA,QACE,QAAQ,cAAc,MAAM,UAAU,MAAM,MAAM,UAAU;AAAA,MAC9D;AAAA,IACF;AAAA,EACF,GAAG,CAAC,OAAO,QAAQ,IAAI,CAAC;AAGxB,8BAAU,MAAM;AACd,QAAI,SAAS,WAAW;AACtB,aAAO,aAAa,QAAQ,MAAM,SAAS;AAAA,IAC7C;AAAA,EACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAErB,SACE,4CAAC,YAAY,UAAZ,EAAqB,OAAe,gBAAM,UAAS;AAExD;AAEO,SAAS,iBAAmC;AACjD,QAAM,cAAU,yB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