@cerberus-design/react 0.13.1 → 0.13.2

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.
Files changed (54) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +83 -40
  2. package/build/legacy/components/ModalHeader.cjs +0 -1
  3. package/build/legacy/components/ModalHeader.cjs.map +1 -1
  4. package/build/legacy/components/Portal.cjs +2 -6
  5. package/build/legacy/components/Portal.cjs.map +1 -1
  6. package/build/legacy/context/confirm-modal.cjs +58 -68
  7. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  8. package/build/legacy/context/cta-modal.cjs +54 -58
  9. package/build/legacy/context/cta-modal.cjs.map +1 -1
  10. package/build/legacy/context/notification-center.cjs +10 -13
  11. package/build/legacy/context/notification-center.cjs.map +1 -1
  12. package/build/legacy/context/prompt-modal.cjs +29 -33
  13. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  14. package/build/legacy/hooks/useRootColors.cjs +64 -0
  15. package/build/legacy/hooks/useRootColors.cjs.map +1 -0
  16. package/build/legacy/index.cjs +191 -164
  17. package/build/legacy/index.cjs.map +1 -1
  18. package/build/modern/_tsup-dts-rollup.d.ts +83 -40
  19. package/build/modern/{chunk-KUT2YEEQ.js → chunk-3XGLNXJJ.js} +7 -7
  20. package/build/modern/chunk-3XGLNXJJ.js.map +1 -0
  21. package/build/modern/{chunk-NCUHRVW2.js → chunk-FBSESDWJ.js} +8 -8
  22. package/build/modern/{chunk-KFGI37CO.js → chunk-GRUXP3NG.js} +44 -50
  23. package/build/modern/chunk-GRUXP3NG.js.map +1 -0
  24. package/build/modern/chunk-IQJDVFPP.js +10 -0
  25. package/build/modern/chunk-IQJDVFPP.js.map +1 -0
  26. package/build/modern/chunk-RMVJK26W.js +39 -0
  27. package/build/modern/chunk-RMVJK26W.js.map +1 -0
  28. package/build/modern/{chunk-J4LOSTEP.js → chunk-WFJWCZ7E.js} +45 -45
  29. package/build/modern/{chunk-J4LOSTEP.js.map → chunk-WFJWCZ7E.js.map} +1 -1
  30. package/build/modern/{chunk-ZFAIE47A.js → chunk-XY6WL55R.js} +1 -2
  31. package/build/modern/{chunk-ZFAIE47A.js.map → chunk-XY6WL55R.js.map} +1 -1
  32. package/build/modern/components/ModalHeader.js +1 -1
  33. package/build/modern/components/Portal.js +1 -2
  34. package/build/modern/context/confirm-modal.js +5 -5
  35. package/build/modern/context/cta-modal.js +6 -6
  36. package/build/modern/context/notification-center.js +4 -4
  37. package/build/modern/context/prompt-modal.js +5 -5
  38. package/build/modern/hooks/useRootColors.js +8 -0
  39. package/build/modern/hooks/useRootColors.js.map +1 -0
  40. package/build/modern/index.js +39 -35
  41. package/build/modern/index.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/components/ModalHeader.tsx +0 -1
  44. package/src/components/Portal.tsx +6 -19
  45. package/src/context/confirm-modal.tsx +89 -66
  46. package/src/context/cta-modal.tsx +38 -38
  47. package/src/context/notification-center.tsx +1 -0
  48. package/src/hooks/useRootColors.ts +73 -0
  49. package/src/index.ts +1 -0
  50. package/build/modern/chunk-K2PSHGS7.js +0 -11
  51. package/build/modern/chunk-K2PSHGS7.js.map +0 -1
  52. package/build/modern/chunk-KFGI37CO.js.map +0 -1
  53. package/build/modern/chunk-KUT2YEEQ.js.map +0 -1
  54. /package/build/modern/{chunk-NCUHRVW2.js.map → chunk-FBSESDWJ.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/cta-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Show } from '../components/Show'\nimport { Modal } from '../components/Modal'\nimport { useModal } from '../hooks/useModal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\nimport { Avatar } from '../components/Avatar'\nimport { HStack } from '@cerberus/styled-system/jsx'\nimport { IconButton } from '../components/IconButton'\nimport { css } from '@cerberus/styled-system/css'\nimport { VStack } from '@cerberus/styled-system/jsx'\n\n/**\n * This module provides a context and hook for the cta modal.\n * @module\n */\n\nexport interface ShowCTAModalOptions {\n /**\n * The heading of the cta modal.\n */\n heading: string\n /**\n * The description of the cta modal.\n */\n description?: string\n /**\n * The icon used for the modal Avatar.\n */\n icon?: ReactNode\n /**\n * The actions for the cta modal. Max of 2 actions.\n */\n actions: {\n text: string\n onClick: Required<ButtonHTMLAttributes<HTMLButtonElement>['onClick']>\n }[]\n}\n\nexport interface CTAModalValue {\n show: (options: ShowCTAModalOptions) => void\n}\n\nconst CTAModalContext = createContext<CTAModalValue | null>(null)\n\nexport interface CTAModalProviderProps {}\n\n/**\n * Provides a CTA modal to the app.\n * @see https://cerberus.digitalu.design/react/cta-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <CTAModal>\n * <SomeFeatureSection />\n * </CTAModal>\n *\n * // Use the hook to show the cta modal.\n * const cta = useCTAModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await cta.show({\n * heading: 'Create or copy a Cohort',\n * description:\n * 'Create a new cohort or copy and existing one.',\n * icon: <Copy size={24} />,\n * actions: [\n * {\n * text: 'Create Cohort',\n * onClick: () => {},\n * {\n * text: 'Copy Cohort',\n * onClick: () => {}\n * }\n * })\n * setConsent(userConsent)\n * }, [cta])\n * ```\n */\nexport function CTAModal(props: PropsWithChildren<CTAModalProviderProps>) {\n const { modalRef, show, close } = useModal()\n const [content, setContent] = useState<ShowCTAModalOptions | null>(null)\n const focusTrap = trapFocus(modalRef)\n const FallbackIcon = $cerberusIcons.confirmModal\n const confirmIcon = content?.icon as ReactNode\n const { close: CloseIcon } = $cerberusIcons\n\n const handleShow = useCallback(\n (options: ShowCTAModalOptions) => {\n const maxActions = 2\n if (options.actions.length > maxActions) {\n throw new Error(\n `CTA Modal only supports a maximum of ${maxActions} actions.`,\n )\n }\n setContent({ ...options })\n show()\n },\n [show],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = event.currentTarget.getAttribute('data-index')\n const action = content?.actions[Number(index)]\n if (typeof action?.onClick === 'function') {\n action.onClick(event)\n }\n close()\n },\n [content, close],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <CTAModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <span\n className={css({\n padding: 'md',\n position: 'absolute',\n right: 0,\n top: 0,\n zIndex: 'decorator',\n })}\n >\n <IconButton ariaLabel=\"Close modal\" onClick={close}>\n <CloseIcon />\n </IconButton>\n </span>\n\n <ModalHeader>\n <HStack justify=\"center\" w=\"full\">\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={\n <Show\n when={Boolean(confirmIcon)}\n fallback={<FallbackIcon size={24} />}\n >\n {confirmIcon}\n </Show>\n }\n src=\"\"\n />\n </HStack>\n <VStack gap=\"lg\" w=\"full\">\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </VStack>\n </ModalHeader>\n\n <HStack gap=\"md\" pt=\"sm\" w=\"full\">\n <Show when={Boolean(content?.actions?.length)}>\n {content?.actions?.map((action, index) => (\n <Button\n data-index={index}\n className={css({\n w: '1/2',\n })}\n key={index}\n onClick={handleActionClick}\n shape=\"rounded\"\n usage=\"outlined\"\n >\n {action.text}\n </Button>\n ))}\n </Show>\n </HStack>\n </Modal>\n </Portal>\n </CTAModalContext.Provider>\n )\n}\n\nexport function useCTAModal(): CTAModalValue {\n const context = useContext(CTAModalContext)\n if (context === null) {\n throw new Error('useCTAModal must be used within a CTAModal Provider')\n }\n return context\n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+ {"version":3,"sources":["../../src/context/cta-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Show } from '../components/Show'\nimport { Modal } from '../components/Modal'\nimport { useModal } from '../hooks/useModal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\nimport { Avatar } from '../components/Avatar'\nimport { HStack } from '@cerberus/styled-system/jsx'\nimport { IconButton } from '../components/IconButton'\nimport { css } from '@cerberus/styled-system/css'\nimport { VStack } from '@cerberus/styled-system/jsx'\n\n/**\n * This module provides a context and hook for the cta modal.\n * @module\n */\n\nexport interface ShowCTAModalOptions {\n /**\n * The heading of the cta modal.\n */\n heading: string\n /**\n * The description of the cta modal.\n */\n description?: string\n /**\n * The icon used for the modal Avatar.\n */\n icon?: ReactNode\n /**\n * The actions for the cta modal. Max of 2 actions.\n */\n actions: {\n text: string\n onClick: Required<ButtonHTMLAttributes<HTMLButtonElement>['onClick']>\n }[]\n}\n\nexport interface CTAModalValue {\n show: (options: ShowCTAModalOptions) => void\n}\n\nconst CTAModalContext = createContext<CTAModalValue | null>(null)\n\nexport interface CTAModalProviderProps {}\n\n/**\n * Provides a CTA modal to the app.\n * @see https://cerberus.digitalu.design/react/cta-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <CTAModal>\n * <SomeFeatureSection />\n * </CTAModal>\n *\n * // Use the hook to show the cta modal.\n * const cta = useCTAModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await cta.show({\n * heading: 'Create or copy a Cohort',\n * description:\n * 'Create a new cohort or copy and existing one.',\n * icon: <Copy size={24} />,\n * actions: [\n * {\n * text: 'Create Cohort',\n * onClick: () => {},\n * {\n * text: 'Copy Cohort',\n * onClick: () => {}\n * }\n * })\n * setConsent(userConsent)\n * }, [cta])\n * ```\n */\nexport function CTAModal(props: PropsWithChildren<CTAModalProviderProps>) {\n const { modalRef, show, close } = useModal()\n const [content, setContent] = useState<ShowCTAModalOptions | null>(null)\n const focusTrap = trapFocus(modalRef)\n const FallbackIcon = $cerberusIcons.confirmModal\n const confirmIcon = content?.icon as ReactNode\n const { close: CloseIcon } = $cerberusIcons\n\n const handleShow = useCallback(\n (options: ShowCTAModalOptions) => {\n const maxActions = 2\n if (options.actions.length > maxActions) {\n throw new Error(\n `CTA Modal only supports a maximum of ${maxActions} actions.`,\n )\n }\n setContent({ ...options })\n show()\n },\n [show],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = event.currentTarget.getAttribute('data-index')\n const action = content?.actions[Number(index)]\n if (typeof action?.onClick === 'function') {\n action.onClick(event)\n }\n close()\n },\n [content, close],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <CTAModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <span\n className={css({\n padding: 'md',\n position: 'absolute',\n right: 0,\n top: 0,\n zIndex: 'decorator',\n })}\n >\n <IconButton ariaLabel=\"Close modal\" onClick={close}>\n <CloseIcon />\n </IconButton>\n </span>\n\n <VStack gap=\"xl\" w=\"full\">\n <ModalHeader>\n <VStack gap=\"lg\" w=\"full\">\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={\n <Show\n when={Boolean(confirmIcon)}\n fallback={<FallbackIcon size={24} />}\n >\n {confirmIcon}\n </Show>\n }\n src=\"\"\n />\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </VStack>\n </ModalHeader>\n\n <HStack gap=\"md\" w=\"full\">\n <Show when={Boolean(content?.actions?.length)}>\n {content?.actions?.map((action, index) => (\n <Button\n data-index={index}\n className={css({\n w: '1/2',\n })}\n key={index}\n onClick={handleActionClick}\n shape=\"rounded\"\n usage=\"outlined\"\n >\n {action.text}\n </Button>\n ))}\n </Show>\n </HStack>\n </VStack>\n </Modal>\n </Portal>\n </CTAModalContext.Provider>\n )\n}\n\nexport function useCTAModal(): CTAModalValue {\n const context = useContext(CTAModalContext)\n if (context === null) {\n throw new Error('useCTAModal must be used within a CTAModal Provider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAYP,SAAS,cAAc;AAEvB,SAAS,WAAW;AACpB,SAAS,cAAc;AA8HT,cAMA,YANA;AA7Fd,IAAM,kBAAkB,cAAoC,IAAI;AAoCzD,SAAS,SAAS,OAAiD;AACxE,QAAM,EAAE,UAAU,MAAM,MAAM,IAAI,SAAS;AAC3C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAqC,IAAI;AACvE,QAAM,YAAY,UAAU,QAAQ;AACpC,QAAM,eAAe,eAAe;AACpC,QAAM,cAAc,SAAS;AAC7B,QAAM,EAAE,OAAO,UAAU,IAAI;AAE7B,QAAM,aAAa;AAAA,IACjB,CAAC,YAAiC;AAChC,YAAM,aAAa;AACnB,UAAI,QAAQ,QAAQ,SAAS,YAAY;AACvC,cAAM,IAAI;AAAA,UACR,wCAAwC,UAAU;AAAA,QACpD;AAAA,MACF;AACA,iBAAW,EAAE,GAAG,QAAQ,CAAC;AACzB,WAAK;AAAA,IACP;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,QAAM,oBAAoB;AAAA,IACxB,CAAC,UAAyC;AACxC,YAAM,QAAQ,MAAM,cAAc,aAAa,YAAY;AAC3D,YAAM,SAAS,SAAS,QAAQ,OAAO,KAAK,CAAC;AAC7C,UAAI,O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AAA,YACL,CAAC;AAAA,YAED,SAAS;AAAA,YACT,OAAM;AAAA,YACN,OAAM;AAAA,YAEL,iBAAO;AAAA;AAAA,UALH;AAAA,QAMP,CACD,GACH,GACF;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;AAEO,SAAS,cAA6B;AAC3C,QAAM,UAAU,WAAW,eAAe;AAC1C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
@@ -12,7 +12,6 @@ function ModalHeader(props) {
12
12
  vstack({
13
13
  alignItems: "flex-start",
14
14
  gap: "md",
15
- mb: "md",
16
15
  position: "relative"
17
16
  })
18
17
  )
@@ -23,4 +22,4 @@ function ModalHeader(props) {
23
22
  export {
24
23
  ModalHeader
25
24
  };
26
- //# sourceMappingURL=chunk-ZFAIE47A.js.map
25
+ //# sourceMappingURL=chunk-XY6WL55R.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/ModalHeader.tsx"],"sourcesContent":["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 * @see https://cerberus.digitalu.design/react/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: 'md',\n mb: 'md',\n position: 'relative',\n }),\n )}\n />\n )\n}\n"],"mappings":";AAAA,SAAS,UAAU;AACnB,SAAS,cAAc;AAwBnB;AAFG,SAAS,YAAY,OAAyB;AACnD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,UACL,YAAY;AAAA,UACZ,KAAK;AAAA,UACL,IAAI;AAAA,UACJ,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/ModalHeader.tsx"],"sourcesContent":["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 * @see https://cerberus.digitalu.design/react/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: 'md',\n position: 'relative',\n }),\n )}\n />\n )\n}\n"],"mappings":";AAAA,SAAS,UAAU;AACnB,SAAS,cAAc;AAwBnB;AAFG,SAAS,YAAY,OAAyB;AACnD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,UACL,YAAY;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ModalHeader
3
- } from "../chunk-ZFAIE47A.js";
3
+ } from "../chunk-XY6WL55R.js";
4
4
  export {
5
5
  ModalHeader
6
6
  };
@@ -1,7 +1,6 @@
1
- "use client";
2
1
  import {
3
2
  Portal
4
- } from "../chunk-K2PSHGS7.js";
3
+ } from "../chunk-IQJDVFPP.js";
5
4
  export {
6
5
  Portal
7
6
  };
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  ConfirmModal,
4
4
  useConfirmModal
5
- } from "../chunk-KFGI37CO.js";
6
- import "../chunk-K2PSHGS7.js";
7
- import "../chunk-ZFAIE47A.js";
5
+ } from "../chunk-GRUXP3NG.js";
6
+ import "../chunk-IQJDVFPP.js";
7
+ import "../chunk-Q7BRMIBR.js";
8
+ import "../chunk-XY6WL55R.js";
8
9
  import "../chunk-2UXE5PDG.js";
9
10
  import "../chunk-BE4EOU2P.js";
10
- import "../chunk-Q7BRMIBR.js";
11
+ import "../chunk-EXGKZGML.js";
11
12
  import "../chunk-KGQG5JGW.js";
12
13
  import "../chunk-SPZYPRZ6.js";
13
14
  import "../chunk-BUVVRQLZ.js";
14
- import "../chunk-EXGKZGML.js";
15
15
  import "../chunk-JIZQFTW6.js";
16
16
  import "../chunk-VERRHMW4.js";
17
17
  import "../chunk-F27AAKQ3.js";
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  CTAModal,
4
4
  useCTAModal
5
- } from "../chunk-J4LOSTEP.js";
6
- import "../chunk-K2PSHGS7.js";
7
- import "../chunk-ZFAIE47A.js";
8
- import "../chunk-2UXE5PDG.js";
9
- import "../chunk-BE4EOU2P.js";
5
+ } from "../chunk-WFJWCZ7E.js";
6
+ import "../chunk-IQJDVFPP.js";
10
7
  import "../chunk-Q7BRMIBR.js";
8
+ import "../chunk-XY6WL55R.js";
9
+ import "../chunk-2UXE5PDG.js";
11
10
  import "../chunk-APD6IX5R.js";
11
+ import "../chunk-BE4EOU2P.js";
12
+ import "../chunk-EXGKZGML.js";
12
13
  import "../chunk-KGQG5JGW.js";
13
14
  import "../chunk-SPZYPRZ6.js";
14
15
  import "../chunk-BUVVRQLZ.js";
15
- import "../chunk-EXGKZGML.js";
16
16
  import "../chunk-JIZQFTW6.js";
17
17
  import "../chunk-VERRHMW4.js";
18
18
  import "../chunk-F27AAKQ3.js";
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  NotificationCenter,
4
4
  useNotificationCenter
5
- } from "../chunk-KUT2YEEQ.js";
6
- import "../chunk-K2PSHGS7.js";
5
+ } from "../chunk-3XGLNXJJ.js";
6
+ import "../chunk-SXIXDXG3.js";
7
+ import "../chunk-IQJDVFPP.js";
7
8
  import "../chunk-7SGPJM66.js";
8
9
  import "../chunk-XEW6TJJ4.js";
9
- import "../chunk-SXIXDXG3.js";
10
- import "../chunk-BUVVRQLZ.js";
11
10
  import "../chunk-EXGKZGML.js";
11
+ import "../chunk-BUVVRQLZ.js";
12
12
  import "../chunk-JIZQFTW6.js";
13
13
  import "../chunk-VERRHMW4.js";
14
14
  import "../chunk-F27AAKQ3.js";
@@ -2,19 +2,19 @@
2
2
  import {
3
3
  PromptModal,
4
4
  usePromptModal
5
- } from "../chunk-NCUHRVW2.js";
6
- import "../chunk-K2PSHGS7.js";
7
- import "../chunk-ZFAIE47A.js";
5
+ } from "../chunk-FBSESDWJ.js";
6
+ import "../chunk-IQJDVFPP.js";
7
+ import "../chunk-Q7BRMIBR.js";
8
+ import "../chunk-XY6WL55R.js";
8
9
  import "../chunk-2UXE5PDG.js";
9
10
  import "../chunk-NKM6PISB.js";
10
11
  import "../chunk-NMF2HYWO.js";
11
12
  import "../chunk-BE4EOU2P.js";
12
- import "../chunk-Q7BRMIBR.js";
13
+ import "../chunk-EXGKZGML.js";
13
14
  import "../chunk-UZDVOIW5.js";
14
15
  import "../chunk-KGQG5JGW.js";
15
16
  import "../chunk-SPZYPRZ6.js";
16
17
  import "../chunk-BUVVRQLZ.js";
17
- import "../chunk-EXGKZGML.js";
18
18
  import "../chunk-JIZQFTW6.js";
19
19
  import "../chunk-VERRHMW4.js";
20
20
  import "../chunk-F27AAKQ3.js";
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import {
3
+ useRootColors
4
+ } from "../chunk-RMVJK26W.js";
5
+ export {
6
+ useRootColors
7
+ };
8
+ //# sourceMappingURL=useRootColors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,11 +1,18 @@
1
+ import {
2
+ NotificationCenter,
3
+ useNotificationCenter
4
+ } from "./chunk-3XGLNXJJ.js";
1
5
  import {
2
6
  PromptModal,
3
7
  usePromptModal
4
- } from "./chunk-NCUHRVW2.js";
8
+ } from "./chunk-FBSESDWJ.js";
5
9
  import {
6
10
  ThemeProvider,
7
11
  useThemeContext
8
12
  } from "./chunk-EB37HRCN.js";
13
+ import {
14
+ Thead
15
+ } from "./chunk-Y6QQCRQV.js";
9
16
  import {
10
17
  Toggle
11
18
  } from "./chunk-NMNONSHU.js";
@@ -15,15 +22,14 @@ import {
15
22
  import {
16
23
  ConfirmModal,
17
24
  useConfirmModal
18
- } from "./chunk-KFGI37CO.js";
25
+ } from "./chunk-GRUXP3NG.js";
19
26
  import {
20
27
  CTAModal,
21
28
  useCTAModal
22
- } from "./chunk-J4LOSTEP.js";
29
+ } from "./chunk-WFJWCZ7E.js";
23
30
  import {
24
- NotificationCenter,
25
- useNotificationCenter
26
- } from "./chunk-KUT2YEEQ.js";
31
+ TabList
32
+ } from "./chunk-UKPF7JOB.js";
27
33
  import {
28
34
  TabPanel
29
35
  } from "./chunk-AYIRV5CL.js";
@@ -47,11 +53,11 @@ import {
47
53
  Th
48
54
  } from "./chunk-SGKHA4EB.js";
49
55
  import {
50
- Thead
51
- } from "./chunk-Y6QQCRQV.js";
56
+ NotificationHeading
57
+ } from "./chunk-SXIXDXG3.js";
52
58
  import {
53
59
  Portal
54
- } from "./chunk-K2PSHGS7.js";
60
+ } from "./chunk-IQJDVFPP.js";
55
61
  import {
56
62
  Radio
57
63
  } from "./chunk-FTPZHG6J.js";
@@ -66,11 +72,11 @@ import {
66
72
  Tab
67
73
  } from "./chunk-SLF6SIPB.js";
68
74
  import {
69
- TabList
70
- } from "./chunk-UKPF7JOB.js";
75
+ ModalDescription
76
+ } from "./chunk-Q7BRMIBR.js";
71
77
  import {
72
78
  ModalHeader
73
- } from "./chunk-ZFAIE47A.js";
79
+ } from "./chunk-XY6WL55R.js";
74
80
  import {
75
81
  ModalHeading
76
82
  } from "./chunk-2UXE5PDG.js";
@@ -95,11 +101,18 @@ import {
95
101
  NotificationDescription
96
102
  } from "./chunk-XEW6TJJ4.js";
97
103
  import {
98
- NotificationHeading
99
- } from "./chunk-SXIXDXG3.js";
104
+ FileStatus,
105
+ processStatus
106
+ } from "./chunk-7MM5KYEX.js";
107
+ import {
108
+ ProgressBar
109
+ } from "./chunk-KCANMM64.js";
100
110
  import {
101
111
  FileUploader
102
112
  } from "./chunk-W4DXACNV.js";
113
+ import {
114
+ IconButton
115
+ } from "./chunk-APD6IX5R.js";
103
116
  import {
104
117
  Input
105
118
  } from "./chunk-NKM6PISB.js";
@@ -122,8 +135,8 @@ import {
122
135
  Modal
123
136
  } from "./chunk-BE4EOU2P.js";
124
137
  import {
125
- ModalDescription
126
- } from "./chunk-Q7BRMIBR.js";
138
+ Button
139
+ } from "./chunk-EXGKZGML.js";
127
140
  import {
128
141
  Checkbox
129
142
  } from "./chunk-NB6DV4VA.js";
@@ -140,32 +153,25 @@ import {
140
153
  FeatureFlags,
141
154
  useFeatureFlags
142
155
  } from "./chunk-CJFW36DZ.js";
143
- import {
144
- Fieldset
145
- } from "./chunk-3ZDFQO25.js";
146
- import {
147
- FieldsetLabel
148
- } from "./chunk-PZAZKQMO.js";
149
- import {
150
- FileStatus,
151
- processStatus
152
- } from "./chunk-7MM5KYEX.js";
153
- import {
154
- ProgressBar
155
- } from "./chunk-KCANMM64.js";
156
- import {
157
- IconButton
158
- } from "./chunk-APD6IX5R.js";
159
156
  import {
160
157
  FieldMessage
161
158
  } from "./chunk-JWIJHSI6.js";
159
+ import {
160
+ Fieldset
161
+ } from "./chunk-3ZDFQO25.js";
162
162
  import {
163
163
  Field,
164
164
  useFieldContext
165
165
  } from "./chunk-UZDVOIW5.js";
166
+ import {
167
+ FieldsetLabel
168
+ } from "./chunk-PZAZKQMO.js";
166
169
  import {
167
170
  useModal
168
171
  } from "./chunk-KGQG5JGW.js";
172
+ import {
173
+ useRootColors
174
+ } from "./chunk-RMVJK26W.js";
169
175
  import {
170
176
  MODE_KEY,
171
177
  THEME_KEY,
@@ -188,9 +194,6 @@ import {
188
194
  import {
189
195
  Show
190
196
  } from "./chunk-BUVVRQLZ.js";
191
- import {
192
- Button
193
- } from "./chunk-EXGKZGML.js";
194
197
  import "./chunk-55J6XMHW.js";
195
198
  import {
196
199
  createNavTriggerProps
@@ -309,6 +312,7 @@ export {
309
312
  useNavMenuContext,
310
313
  useNotificationCenter,
311
314
  usePromptModal,
315
+ useRootColors,
312
316
  useTabsContext,
313
317
  useTabsKeyboardNavigation,
314
318
  useTheme,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Spinner'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Tooltip'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useDate'\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Spinner'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Tooltip'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useDate'\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\nexport * from './hooks/useRootColors'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerberus-design/react",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "The Cerberus Design React component library.",
5
5
  "browserslist": "> 0.25%, not dead",
6
6
  "sideEffects": false,
@@ -27,7 +27,7 @@
27
27
  "react-dom": "^18",
28
28
  "tsup": "^8.1.0",
29
29
  "@cerberus-design/configs": "0.0.0",
30
- "@cerberus-design/styled-system": "0.13.1"
30
+ "@cerberus-design/styled-system": "0.13.2"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
@@ -30,7 +30,6 @@ export function ModalHeader(props: ModalHeaderProps) {
30
30
  vstack({
31
31
  alignItems: 'flex-start',
32
32
  gap: 'md',
33
- mb: 'md',
34
33
  position: 'relative',
35
34
  }),
36
35
  )}
@@ -1,24 +1,14 @@
1
- 'use client'
2
-
3
- import type { PropsWithChildren } from 'react'
4
- import { createPortal } from 'react-dom'
1
+ import {
2
+ Portal as ArkPortal,
3
+ type PortalProps as ArkPortalProps,
4
+ } from '@ark-ui/react'
5
5
 
6
6
  /**
7
7
  * This module is the Portal component.
8
8
  * @module
9
9
  */
10
10
 
11
- export interface PortalProps {
12
- /**
13
- * The root container to render the children into.
14
- * @default document.body
15
- */
16
- container?: Element | DocumentFragment
17
- /**
18
- * An optional key to use for the Portal component.
19
- */
20
- key?: null | string
21
- }
11
+ export type PortalProps = ArkPortalProps
22
12
 
23
13
  /**
24
14
  * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
@@ -38,7 +28,4 @@ export interface PortalProps {
38
28
  * )
39
29
  * }
40
30
  */
41
- export function Portal(props: PropsWithChildren<PortalProps>) {
42
- const container = props.container || document.body
43
- return createPortal(props.children, container, props.key)
44
- }
31
+ export const Portal = ArkPortal
@@ -9,6 +9,7 @@ import {
9
9
  useState,
10
10
  type MouseEvent,
11
11
  type PropsWithChildren,
12
+ type ReactNode,
12
13
  } from 'react'
13
14
  import { Portal } from '../components/Portal'
14
15
  import { Button } from '../components/Button'
@@ -23,26 +24,18 @@ import { ModalHeader } from '../components/ModalHeader'
23
24
  import { ModalHeading } from '../components/ModalHeading'
24
25
  import { ModalDescription } from '../components/ModalDescription'
25
26
  import { Avatar } from '../components/Avatar'
27
+ import { HStack, VStack } from '@cerberus/styled-system/jsx'
26
28
 
27
29
  /**
28
30
  * This module provides a context and hook for the confirm modal.
29
31
  * @module
30
32
  */
31
33
 
32
- export interface ShowConfirmModalOptions {
33
- /**
34
- * The kind of confirm modal to show.
35
- * @default 'non-destructive'
36
- */
37
- kind?: 'destructive' | 'non-destructive'
34
+ export interface BaseConfirmOptions {
38
35
  /**
39
36
  * The heading of the confirm modal.
40
37
  */
41
38
  heading: string
42
- /**
43
- * The description of the confirm modal.
44
- */
45
- description?: string
46
39
  /**
47
40
  * The text for the action button.
48
41
  */
@@ -52,6 +45,37 @@ export interface ShowConfirmModalOptions {
52
45
  */
53
46
  cancelText: string
54
47
  }
48
+
49
+ export interface DestructiveConfirmOptions extends BaseConfirmOptions {
50
+ /**
51
+ * The kind of confirm modal to show.
52
+ */
53
+ kind?: 'destructive'
54
+ /**
55
+ * The description of the confirm modal. Can only be a string for destructive confirm modals.
56
+ */
57
+ description?: string
58
+ }
59
+
60
+ export interface NonDestructiveConfirmModalOptions extends BaseConfirmOptions {
61
+ /**
62
+ * The kind of confirm modal to show.
63
+ * @default 'non-destructive'
64
+ */
65
+ kind?: 'non-destructive'
66
+ /**
67
+ * The description of the confirm modal. Can be a ReactNode for non-destructive kind if you need to display text links.
68
+ * @example
69
+ * ```tsx
70
+ * description: <>Use a Fragment because we put the content within a Paragraph tag.</>
71
+ */
72
+ description?: ReactNode
73
+ }
74
+
75
+ export type ShowConfirmModalOptions =
76
+ | NonDestructiveConfirmModalOptions
77
+ | DestructiveConfirmOptions
78
+
55
79
  export type ShowResult =
56
80
  | ((value: boolean | PromiseLike<boolean>) => void)
57
81
  | null
@@ -97,10 +121,11 @@ export function ConfirmModal(
97
121
  const [content, setContent] = useState<ShowConfirmModalOptions | null>(null)
98
122
  const focusTrap = trapFocus(modalRef)
99
123
  const ConfirmIcon = $cerberusIcons.confirmModal
124
+ const kind = content?.kind ?? 'non-destructive'
100
125
 
101
126
  const palette = useMemo(
102
- () => (content?.kind === 'destructive' ? 'danger' : 'action'),
103
- [content],
127
+ () => (kind === 'destructive' ? 'danger' : 'action'),
128
+ [kind],
104
129
  )
105
130
 
106
131
  const handleChoice = useCallback(
@@ -118,7 +143,7 @@ export function ConfirmModal(
118
143
  const handleShow = useCallback(
119
144
  (options: ShowConfirmModalOptions) => {
120
145
  return new Promise<boolean>((resolve) => {
121
- setContent({ ...options, kind: options.kind || 'non-destructive' })
146
+ setContent({ ...options })
122
147
  show()
123
148
  resolveRef.current = resolve
124
149
  })
@@ -139,65 +164,63 @@ export function ConfirmModal(
139
164
 
140
165
  <Portal>
141
166
  <Modal onKeyDown={focusTrap} ref={modalRef}>
142
- <ModalHeader>
143
- <div
144
- className={hstack({
145
- justify: 'center',
146
- w: 'full',
147
- })}
148
- >
149
- <Show
150
- when={palette === 'danger'}
151
- fallback={
167
+ <VStack gap="xl" w="full">
168
+ <ModalHeader>
169
+ <div
170
+ className={hstack({
171
+ justify: 'center',
172
+ w: 'full',
173
+ })}
174
+ >
175
+ <Show
176
+ when={palette === 'danger'}
177
+ fallback={
178
+ <Avatar
179
+ ariaLabel=""
180
+ gradient="charon-light"
181
+ icon={<ConfirmIcon size={24} />}
182
+ src=""
183
+ />
184
+ }
185
+ >
152
186
  <Avatar
153
187
  ariaLabel=""
154
- gradient="charon-light"
188
+ gradient="hades-dark"
155
189
  icon={<ConfirmIcon size={24} />}
156
190
  src=""
157
191
  />
158
- }
192
+ </Show>
193
+ </div>
194
+ <ModalHeading>{content?.heading}</ModalHeading>
195
+ <ModalDescription>{content?.description}</ModalDescription>
196
+ </ModalHeader>
197
+
198
+ <HStack gap="4" w="full">
199
+ <Button
200
+ autoFocus
201
+ className={css({
202
+ w: '1/2',
203
+ })}
204
+ name="confirm"
205
+ onClick={handleChoice}
206
+ palette={palette}
207
+ value="true"
208
+ >
209
+ {content?.actionText}
210
+ </Button>
211
+ <Button
212
+ className={css({
213
+ w: '1/2',
214
+ })}
215
+ name="cancel"
216
+ onClick={handleChoice}
217
+ usage="outlined"
218
+ value="false"
159
219
  >
160
- <Avatar
161
- ariaLabel=""
162
- gradient="hades-dark"
163
- icon={<ConfirmIcon size={24} />}
164
- src=""
165
- />
166
- </Show>
167
- </div>
168
- <ModalHeading>{content?.heading}</ModalHeading>
169
- <ModalDescription>{content?.description}</ModalDescription>
170
- </ModalHeader>
171
-
172
- <div
173
- className={hstack({
174
- gap: '4',
175
- })}
176
- >
177
- <Button
178
- autoFocus
179
- className={css({
180
- w: '1/2',
181
- })}
182
- name="confirm"
183
- onClick={handleChoice}
184
- palette={palette}
185
- value="true"
186
- >
187
- {content?.actionText}
188
- </Button>
189
- <Button
190
- className={css({
191
- w: '1/2',
192
- })}
193
- name="cancel"
194
- onClick={handleChoice}
195
- usage="outlined"
196
- value="false"
197
- >
198
- {content?.cancelText}
199
- </Button>
200
- </div>
220
+ {content?.cancelText}
221
+ </Button>
222
+ </HStack>
223
+ </VStack>
201
224
  </Modal>
202
225
  </Portal>
203
226
  </ConfirmModalContext.Provider>