@cerberus-design/react 0.16.0-next-4f6c716 → 0.16.0-next-feeb186

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 (64) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +82 -25
  2. package/build/legacy/components/cta-dialog/context.cjs +33 -0
  3. package/build/legacy/components/cta-dialog/context.cjs.map +1 -0
  4. package/build/legacy/components/cta-dialog/index.cjs +433 -0
  5. package/build/legacy/components/cta-dialog/index.cjs.map +1 -0
  6. package/build/legacy/{context/cta-modal.cjs → components/cta-dialog/provider.cjs} +187 -150
  7. package/build/legacy/components/cta-dialog/provider.cjs.map +1 -0
  8. package/build/legacy/components/cta-dialog/trigger-item.cjs +99 -0
  9. package/build/legacy/components/cta-dialog/trigger-item.cjs.map +1 -0
  10. package/build/legacy/components/cta-dialog/utils.cjs +47 -0
  11. package/build/legacy/components/cta-dialog/utils.cjs.map +1 -0
  12. package/build/legacy/components/for.cjs +3 -4
  13. package/build/legacy/components/for.cjs.map +1 -1
  14. package/build/legacy/index.cjs +771 -715
  15. package/build/legacy/index.cjs.map +1 -1
  16. package/build/modern/_tsup-dts-rollup.d.ts +82 -25
  17. package/build/modern/chunk-4LSTU6WU.js +8 -0
  18. package/build/modern/chunk-4LSTU6WU.js.map +1 -0
  19. package/build/modern/{chunk-P3SF56LT.js → chunk-6ICNCCPD.js} +4 -4
  20. package/build/modern/chunk-DXOKSZVQ.js +12 -0
  21. package/build/modern/chunk-DXOKSZVQ.js.map +1 -0
  22. package/build/modern/chunk-IKDXADLX.js +1 -0
  23. package/build/modern/chunk-MVO2GNUA.js +47 -0
  24. package/build/modern/chunk-MVO2GNUA.js.map +1 -0
  25. package/build/modern/{chunk-CMYD5KWA.js → chunk-O542MPR7.js} +4 -4
  26. package/build/modern/chunk-PLHYOCY3.js +23 -0
  27. package/build/modern/chunk-PLHYOCY3.js.map +1 -0
  28. package/build/modern/{chunk-ZDANBCM3.js → chunk-QEM3M4N3.js} +22 -31
  29. package/build/modern/chunk-QEM3M4N3.js.map +1 -0
  30. package/build/modern/{chunk-FMRWRVUS.js → chunk-Z4342DRO.js} +4 -4
  31. package/build/modern/components/cta-dialog/context.js +8 -0
  32. package/build/modern/components/cta-dialog/context.js.map +1 -0
  33. package/build/modern/components/cta-dialog/index.js +26 -0
  34. package/build/modern/components/cta-dialog/index.js.map +1 -0
  35. package/build/modern/components/cta-dialog/provider.js +22 -0
  36. package/build/modern/components/cta-dialog/provider.js.map +1 -0
  37. package/build/modern/components/cta-dialog/trigger-item.js +10 -0
  38. package/build/modern/components/cta-dialog/trigger-item.js.map +1 -0
  39. package/build/modern/components/cta-dialog/utils.js +7 -0
  40. package/build/modern/components/cta-dialog/utils.js.map +1 -0
  41. package/build/modern/components/for.js +1 -1
  42. package/build/modern/components/select/index.js +2 -2
  43. package/build/modern/components/select/select.js +2 -2
  44. package/build/modern/context/notification-center.js +2 -2
  45. package/build/modern/context/prompt-modal.js +2 -2
  46. package/build/modern/index.js +83 -76
  47. package/build/modern/index.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/components/cta-dialog/context.tsx +34 -0
  50. package/src/components/cta-dialog/index.ts +2 -0
  51. package/src/{context/cta-modal.tsx → components/cta-dialog/provider.tsx} +34 -68
  52. package/src/components/cta-dialog/trigger-item.tsx +53 -0
  53. package/src/components/cta-dialog/utils.ts +57 -0
  54. package/src/components/for.tsx +13 -18
  55. package/src/index.ts +1 -1
  56. package/build/legacy/context/cta-modal.cjs.map +0 -1
  57. package/build/modern/chunk-IIH363FO.js +0 -13
  58. package/build/modern/chunk-IIH363FO.js.map +0 -1
  59. package/build/modern/chunk-ZDANBCM3.js.map +0 -1
  60. package/build/modern/context/cta-modal.js +0 -19
  61. /package/build/modern/{chunk-P3SF56LT.js.map → chunk-6ICNCCPD.js.map} +0 -0
  62. /package/build/modern/{context/cta-modal.js.map → chunk-IKDXADLX.js.map} +0 -0
  63. /package/build/modern/{chunk-CMYD5KWA.js.map → chunk-O542MPR7.js.map} +0 -0
  64. /package/build/modern/{chunk-FMRWRVUS.js.map → chunk-Z4342DRO.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/cta-dialog/index.ts","../../../../src/components/cta-dialog/provider.tsx","../../../../src/context/cerberus.tsx","../../../../src/components/Show.tsx","../../../../src/components/for.tsx","../../../../src/components/Avatar.tsx","../../../../src/components/Dialog.tsx","../../../../src/components/Portal.tsx","../../../../src/components/Dialog.client.tsx","../../../../src/components/IconButton.tsx","../../../../src/components/cta-dialog/context.tsx","../../../../src/components/cta-dialog/trigger-item.tsx","../../../../src/components/button/button.tsx","../../../../src/components/cta-dialog/utils.ts"],"sourcesContent":["export * from './provider'\nexport * from './utils'\n","'use client'\n\nimport {\n useCallback,\n useContext,\n useMemo,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { HStack, VStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from '../../context/cerberus'\nimport { Show } from '../Show'\nimport { For } from '../for'\nimport { Avatar } from '../Avatar'\nimport {\n Dialog,\n DialogDescription,\n DialogHeading,\n DialogProvider,\n} from '../Dialog'\nimport { DialogCloseIconTrigger } from '../Dialog.client'\nimport type { CTAButtonAction, CTAModalActionReturn } from './utils'\nimport {\n CTAModalContext,\n type CTAModalValue,\n type ShowCTAModalOptions,\n} from './context'\nimport { TriggerItem } from './trigger-item'\n\n/**\n * This module provides the provider and hook for the cta modal.\n * @module 'react/cta-modal/provider'\n */\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<object>) {\n const [open, setOpen] = useState<boolean>(false)\n const [content, setContent] = useState<ShowCTAModalOptions | null>(null)\n const confirmIcon = content?.icon\n\n const { icons } = useCerberusContext()\n const { confirmModal: FallbackIcon } = icons\n\n const handleShow = useCallback(\n (options: ShowCTAModalOptions) => {\n setContent({ ...options })\n setOpen(true)\n },\n [setOpen],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = Number(event.currentTarget.getAttribute('data-index'))\n const contentActions = content?.actions as CTAModalActionReturn\n const action = contentActions._actions[index] as CTAButtonAction\n action?.handleClick?.(event)\n setOpen(false)\n },\n [content, setOpen],\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 <DialogProvider open={open} onOpenChange={(e) => setOpen(e.open)}>\n <Dialog size=\"sm\">\n <DialogCloseIconTrigger />\n\n <VStack gap=\"xl\" w=\"full\">\n <VStack alignItems=\"flex-start\" gap=\"md\" w=\"full\">\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 <DialogHeading>{content?.heading}</DialogHeading>\n <DialogDescription>{content?.description}</DialogDescription>\n </VStack>\n </VStack>\n\n <HStack gap=\"md\" w=\"full\">\n <For each={content?.actions._actions}>\n {(action, index) => (\n <Show\n key={index}\n when={content?.actions?.type === 'btnAction'}\n fallback={\n <TriggerItem asChild>{action as ReactNode}</TriggerItem>\n }\n >\n <TriggerItem data-index={index} onClick={handleActionClick}>\n {(action as CTAButtonAction)?.text}\n </TriggerItem>\n </Show>\n )}\n </For>\n </HStack>\n </VStack>\n </Dialog>\n </DialogProvider>\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","'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport type { SystemConfig } from '../config'\n\n/**\n * This module contains the Cerberus configuration context and helpers.\n * @module context/cerberus\n */\n\ntype CerberusContextValue = SystemConfig\n\nconst CerberusContext = createContext<CerberusContextValue | null>(null)\n\ninterface CerberusProviderProps {\n config: SystemConfig\n}\n\n/**\n * Cerberus configuration provider.\n * @param props.config The Cerberus configuration created with\n * `makeSystemConfig` helper.\n */\nexport function CerberusProvider(\n props: PropsWithChildren<CerberusProviderProps>,\n) {\n return (\n <CerberusContext.Provider value={props.config}>\n {props.children}\n </CerberusContext.Provider>\n )\n}\n\n/**\n * Returns the Cerberus configuration context.\n * @returns The Cerberus configuration context.\n */\nexport function useCerberusContext() {\n const context = useContext(CerberusContext)\n if (!context) {\n throw new Error('useCerberus must be used within a CerberusProvider')\n }\n return context\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\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","import type { ReactNode, JSX } from 'react'\n\nexport interface ForProps<T extends readonly unknown[], U extends JSX.Element> {\n /**\n * The array to iterate over.\n */\n each: T | undefined | null | false\n /**\n * The fallback to render when the array is empty.\n */\n fallback?: JSX.Element\n /**\n * The children to render for each item in the array.\n */\n children: (item: T[number], index: number) => U\n}\n\n/**\n * The For component is used to iterate over an array and render a list of\n * components or display a fallback when the array is empty.\n * Inspired by the `<For>` component from SolidJS.\n *\n * @example\n * ```tsx\n * <For each={['a', 'b', 'c']}>\n * {(item, index) => <div key={index}>{item}</div>}\n * </For>\n * ```\n */\nexport function For<T extends readonly unknown[], U extends JSX.Element>(\n props: ForProps<T, U>,\n) {\n if (!props.each || !props.each.length) {\n return props.fallback || null\n }\n\n return props.each?.map(props.children) as ReactNode\n}\n","'use client'\n\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type SharedAvatarProps = {\n /**\n * An optional icon to show when no src or ariaLabel is provided.\n */\n icon?: ReactNode\n /**\n * The size of the avatar.\n */\n width?: number\n /**\n * The size of the avatar.\n */\n height?: number\n}\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> &\n SharedAvatarProps & {\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel: string\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as?: never\n /**\n * The source of the image.\n */\n src: string\n }\nexport type AvatarAsProps = SharedAvatarProps & {\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as: ReactNode\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel?: never\n /**\n * The source of the image.\n */\n src?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @see https://cerberus.digitalu.design/react/avatar\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const {\n ariaLabel,\n as,\n gradient,\n size,\n src,\n width,\n height,\n icon,\n ...nativeProps\n } = props\n const { icons } = useCerberusContext()\n const { avatar: AvatarIcon } = icons\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <Show\n when={Boolean(icon)}\n fallback={\n <AvatarIcon\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n {icon}\n </Show>\n }\n >\n {initials}\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n","import {\n Dialog as ArkDialog,\n type DialogContentProps as ArkDialogContentProps,\n type DialogRootProps,\n type DialogTitleProps,\n} from '@ark-ui/react'\nimport {\n dialog,\n type DialogVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { Portal } from './Portal'\nimport { cx } from '@cerberus/styled-system/css'\n\nexport type DialogProviderProps = DialogRootProps\n\n/**\n * The provider that controls the dialog components.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @example\n * ```tsx\n * <DialogProvider>\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * <Dialog>\n * <Text>Dialog Content</Text>\n * <DialogCloseTrigger>Close</DialogCloseTrigger>\n * </Dialog>\n * </DialogProvider>\n * ```\n */\nexport function DialogProvider(props: DialogProviderProps) {\n return <ArkDialog.Root {...props} />\n}\n\nexport interface DialogProps\n extends Omit<ArkDialogContentProps, 'size'>,\n DialogVariantProps {}\n\n/**\n * The content of the dialog. Must be used within the `DialogProvider` component.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @example\n * ```tsx\n * <DialogProvider>\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * <Dialog>\n * <Text>Dialog Content</Text>\n * </Dialog>\n * </DialogProvider>\n * ```\n */\nexport function Dialog(props: DialogProps) {\n const { size, ...contentProps } = props\n const styles = dialog({ size })\n return (\n <Portal>\n <DialogBackdrop className={styles.backdrop} />\n <DialogPositioner className={styles.positioner}>\n <DialogContent className={styles.content} {...contentProps} />\n </DialogPositioner>\n </Portal>\n )\n}\n\n/**\n * The heading of the dialog. Must be used within the `DialogContent` component.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @example\n * ```tsx\n * <DialogProvider>\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * <Dialog>\n * <DialogHeading>Dialog Title</DialogHeading>\n * <Text>Dialog Content</Text>\n * </Dialog>\n * </DialogProvider>\n * ```\n */\nexport function DialogHeading(props: DialogTitleProps) {\n const styles = dialog()\n return (\n <ArkDialog.Title {...props} className={cx(props.className, styles.title)} />\n )\n}\n\n/**\n * The description of the dialog. Must be used within the `DialogContent` component.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @example\n * ```tsx\n * <DialogProvider>\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * <Dialog>\n * <DialogHeading>Dialog Title</DialogHeading>\n * <DialogDescription>Dialog Description</DialogDescription>\n * </Dialog>\n * </DialogProvider>\n * ```\n */\nexport function DialogDescription(props: DialogTitleProps) {\n const styles = dialog()\n return (\n <ArkDialog.Description\n {...props}\n className={cx(props.className, styles.description)}\n />\n )\n}\n\n/**\n * The trigger that opens the dialog. Must be used within the `DialogProvider`\n * component.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @example\n * ```tsx\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * ```\n */\nexport const DialogTrigger = ArkDialog.Trigger\n\n/**\n * The trigger that closes the dialog. Must be used within the `DialogProvider`\n * component.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @example\n * ```tsx\n * <DialogProvider>\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * <Dialog>\n * <Text>Dialog Content</Text>\n * <DialogCloseTrigger>Close</DialogCloseTrigger>\n * </Dialog>\n * </DialogProvider>\n * ```\n */\nexport const DialogCloseTrigger = ArkDialog.CloseTrigger\n\n/**\n * The backdrop of the dialog. Must be used within the `DialogProvider`\n * component.\n */\nexport const DialogBackdrop = ArkDialog.Backdrop\n\n/**\n * The positioner of the dialog. Must be used within the `DialogProvider`\n * component.\n */\nexport const DialogPositioner = ArkDialog.Positioner\n\n/**\n * The content of the dialog. Must be used within the `DialogProvider`\n * component.\n */\nexport const DialogContent = ArkDialog.Content\n","import {\n Portal as ArkPortal,\n type PortalProps as ArkPortalProps,\n} from '@ark-ui/react'\n\n/**\n * This module is the Portal component.\n * @module\n */\n\nexport type PortalProps = ArkPortalProps\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 * @see https://cerberus.digitalu.design/react/portal\n * @definition [React Portal Docs](https://react.dev/reference/react-dom/createPortal)\n * @example\n * ```tsx\n * 'use client'\n *\n * import { Portal } from '@cerberus/react'\n *\n * function SomeFeatureWithinSSRPage() {\n * return (\n * <Portal>\n * <div>Portal Content outside of the React VDom tree</div>\n * </Portal>\n * )\n * }\n */\nexport const Portal = ArkPortal\n","'use client'\n\nimport {\n Dialog as ArkDialog,\n type DialogCloseTriggerProps,\n} from '@ark-ui/react'\nimport { dialog } from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { IconButton } from './IconButton'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains client-side components for the Dialog family.\n * @module @cerberus-design/react/dialog\n */\n\nexport function DialogCloseIconTrigger(props: DialogCloseTriggerProps) {\n const { icons } = useCerberusContext()\n const { close: CloseIcon } = icons\n\n const styles = dialog()\n\n return (\n <ArkDialog.CloseTrigger\n {...props}\n className={cx(props.className, styles.closeTrigger)}\n asChild\n >\n <IconButton\n ariaLabel=\"Close dialog\"\n palette=\"action\"\n size=\"lg\"\n usage=\"ghost\"\n >\n <CloseIcon />\n </IconButton>\n </ArkDialog.CloseTrigger>\n )\n}\n","import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n iconButton,\n type IconButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the Icon Button component.\n * @module\n */\n\nexport interface IconButtonRawProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * The aria-label attribute for the icon button.\n */\n ariaLabel: string\n}\nexport type IconButtonProps = IconButtonRawProps & IconButtonVariantProps\n\n/**\n * A component that allows the user to perform actions using an icon\n * @see https://cerberus.digitalu.design/react/icon-button\n */\nexport function IconButton(props: IconButtonProps): JSX.Element {\n const { ariaLabel, palette, usage, size, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n aria-label={ariaLabel ?? 'Icon Button'}\n className={cx(\n nativeProps.className,\n iconButton({\n palette,\n usage,\n size,\n }),\n )}\n />\n )\n}\n","'use client'\n\nimport { createContext, type ReactNode } from 'react'\nimport type { CTAModalActionReturn } from './utils'\n\n/**\n * This module provides the context 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. Requires 2 actions.\n */\n actions: CTAModalActionReturn\n}\n\nexport interface CTAModalValue {\n show: (options: ShowCTAModalOptions) => void\n}\n\nexport const CTAModalContext = createContext<CTAModalValue | null>(null)\n","import { css, cx } from '@cerberus/styled-system/css'\nimport { Button, type ButtonProps } from '../button/button'\nimport { ark } from '@ark-ui/react/factory'\nimport { button } from '@cerberus/styled-system/recipes'\n\n/**\n * This module provides the trigger item for the cta modal.\n * @module 'react/cta-modal/trigger-item'\n */\n\nexport interface TriggerItemProps extends ButtonProps {\n asChild?: boolean\n}\n\n/**\n * Trigger item for the cta modal which renders content based on the actions.\n * type.\n */\nexport function TriggerItem(props: TriggerItemProps) {\n const { asChild, children, ...buttonProps } = props\n\n if (asChild) {\n return (\n <ark.div\n className={cx(\n button({\n shape: 'rounded',\n usage: 'ghost',\n }),\n css({\n w: '1/2',\n }),\n )}\n asChild\n >\n {children}\n </ark.div>\n )\n }\n\n return (\n <Button\n {...buttonProps}\n className={css({\n w: '1/2',\n })}\n shape=\"rounded\"\n usage=\"outlined\"\n >\n {children}\n </Button>\n )\n}\n","'use client'\n\nimport {\n type ButtonHTMLAttributes,\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n button,\n type ButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { Box } from '@cerberus/styled-system/jsx'\nimport { Show } from '../Show'\nimport { Spinner } from '../Spinner'\n\n/**\n * This module contains the Button component.\n * @module\n */\n\ninterface ButtonContextValue {\n pending: boolean\n}\n\nconst ButtonContext = createContext<ButtonContextValue>({\n pending: false,\n})\n\nexport type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n ButtonVariantProps & {\n pending?: boolean\n }\n\n/**\n * A component that allows the user to perform actions\n * @see https://cerberus.digitalu.design/react/button\n */\nexport function Button(props: ButtonProps): JSX.Element {\n const { palette, usage, shape, size, pending = false, ...nativeProps } = props\n const value = useMemo(() => ({ pending }), [pending])\n\n return (\n <ButtonContext.Provider value={value}>\n <button\n {...nativeProps}\n disabled={pending || nativeProps.disabled}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n size,\n }),\n )}\n />\n </ButtonContext.Provider>\n )\n}\n\n/**\n * An icon to display in a button that utilizes the pending state to display\n * a loading spinner.\n */\nexport function ButtonIcon(props: PropsWithChildren<object>) {\n const { pending } = useContext(ButtonContext)\n return (\n <Show when={pending} fallback={<>{props.children}</>}>\n <Box w=\"4\">\n <Spinner />\n </Box>\n </Show>\n )\n}\n","import type { MouseEventHandler, ReactNode } from 'react'\n\n/**\n * This module provide utility functions for the cta modal.\n * @module 'react/cta-modal/utils'\n */\n\nexport type CTAButtonAction = {\n /**\n * The text of the button.\n */\n text: string\n /**\n * The onClick handler for the button.\n */\n handleClick: MouseEventHandler<HTMLButtonElement>\n}\n\nexport type CTAModalAction = (CTAButtonAction | ReactNode)[]\n\nexport interface CTAModalActionReturn {\n /**\n * The type of the action content.\n */\n type: 'reactNode' | 'btnAction'\n /**\n * The actions for the cta modal. Max of 2 actions.\n */\n _actions: CTAModalAction\n}\n\n/**\n * Creates the action data to pass to the cta modal `show` method.\n */\nexport function createCTAModalActions(\n providedActions: CTAModalAction,\n): CTAModalActionReturn {\n if (providedActions.length !== 2) {\n throw new Error('CTAModal must include 2 actions')\n }\n\n if (\n providedActions.every(\n (action) => (action as unknown as CTAButtonAction)?.handleClick,\n )\n ) {\n return {\n type: 'btnAction',\n _actions: providedActions as CTAButtonAction[],\n }\n }\n\n return {\n type: 'reactNode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,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;;;AY/HO,SAAS,sBACd,iBACsB;AACtB,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,MACE,gBAAgB;AAAA,IACd,CAAC,WAAY,iCAAuC;AAAA,EACtD,GACA;AACA,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;","names":["import_react","import_jsx","import_react","import_jsx_runtime","import_react","import_recipes","import_react","ArkPortal","import_css","import_jsx_runtime","ArkDialog","import_react","import_recipes","import_css","import_css","import_recipes","import_jsx_runtime","import_jsx_runtime","ArkDialog","import_react","import_css","import_react","import_css","import_recipes","import_jsx_runtime","import_recipes","import_jsx_runtime","import_jsx_runtime"]}
@@ -18,77 +18,53 @@ var __copyProps = (to, from, except, desc) => {
18
18
  };
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
 
21
- // src/context/cta-modal.tsx
22
- var cta_modal_exports = {};
23
- __export(cta_modal_exports, {
21
+ // src/components/cta-dialog/provider.tsx
22
+ var provider_exports = {};
23
+ __export(provider_exports, {
24
24
  CTAModal: () => CTAModal,
25
25
  useCTAModal: () => useCTAModal
26
26
  });
27
- module.exports = __toCommonJS(cta_modal_exports);
28
- var import_react7 = require("react");
27
+ module.exports = __toCommonJS(provider_exports);
28
+ var import_react8 = require("react");
29
+ var import_jsx2 = require("@cerberus/styled-system/jsx");
29
30
 
30
- // src/components/button/button.tsx
31
- var import_react2 = require("react");
32
- var import_css = require("@cerberus/styled-system/css");
33
- var import_recipes = require("@cerberus/styled-system/recipes");
34
- var import_jsx = require("@cerberus/styled-system/jsx");
31
+ // src/context/cerberus.tsx
32
+ var import_react = require("react");
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var CerberusContext = (0, import_react.createContext)(null);
35
+ function useCerberusContext() {
36
+ const context = (0, import_react.useContext)(CerberusContext);
37
+ if (!context) {
38
+ throw new Error("useCerberus must be used within a CerberusProvider");
39
+ }
40
+ return context;
41
+ }
35
42
 
36
43
  // src/components/Show.tsx
37
- var import_react = require("react");
44
+ var import_react2 = require("react");
38
45
  function Show(props) {
39
46
  const { when, children, fallback } = props;
40
- const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
41
- return (0, import_react.useMemo)(() => {
47
+ const condition = (0, import_react2.useMemo)(() => when ?? false, [when]);
48
+ return (0, import_react2.useMemo)(() => {
42
49
  if (condition) return children;
43
50
  return fallback ?? null;
44
51
  }, [condition, children, fallback]);
45
52
  }
46
53
 
47
- // src/components/button/button.tsx
48
- var import_jsx_runtime = require("react/jsx-runtime");
49
- var ButtonContext = (0, import_react2.createContext)({
50
- pending: false
51
- });
52
- function Button(props) {
53
- const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
54
- const value = (0, import_react2.useMemo)(() => ({ pending }), [pending]);
55
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
- "button",
57
- {
58
- ...nativeProps,
59
- disabled: pending || nativeProps.disabled,
60
- className: (0, import_css.cx)(
61
- nativeProps.className,
62
- (0, import_recipes.button)({
63
- palette,
64
- usage,
65
- shape,
66
- size
67
- })
68
- )
69
- }
70
- ) });
54
+ // src/components/for.tsx
55
+ function For(props) {
56
+ var _a;
57
+ if (!props.each || !props.each.length) {
58
+ return props.fallback || null;
59
+ }
60
+ return (_a = props.each) == null ? void 0 : _a.map(props.children);
71
61
  }
72
62
 
73
63
  // src/components/Avatar.tsx
74
- var import_css2 = require("@cerberus/styled-system/css");
64
+ var import_css = require("@cerberus/styled-system/css");
75
65
  var import_patterns = require("@cerberus/styled-system/patterns");
76
- var import_recipes2 = require("@cerberus/styled-system/recipes");
77
-
78
- // src/context/cerberus.tsx
79
- var import_react3 = require("react");
66
+ var import_recipes = require("@cerberus/styled-system/recipes");
80
67
  var import_jsx_runtime2 = require("react/jsx-runtime");
81
- var CerberusContext = (0, import_react3.createContext)(null);
82
- function useCerberusContext() {
83
- const context = (0, import_react3.useContext)(CerberusContext);
84
- if (!context) {
85
- throw new Error("useCerberus must be used within a CerberusProvider");
86
- }
87
- return context;
88
- }
89
-
90
- // src/components/Avatar.tsx
91
- var import_jsx_runtime3 = require("react/jsx-runtime");
92
68
  function Avatar(props) {
93
69
  const {
94
70
  ariaLabel,
@@ -104,28 +80,28 @@ function Avatar(props) {
104
80
  const { icons } = useCerberusContext();
105
81
  const { avatar: AvatarIcon } = icons;
106
82
  const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
107
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
83
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
108
84
  "div",
109
85
  {
110
86
  ...nativeProps,
111
- className: (0, import_css2.cx)(
87
+ className: (0, import_css.cx)(
112
88
  nativeProps.className,
113
- (0, import_recipes2.avatar)({ gradient, size }),
89
+ (0, import_recipes.avatar)({ gradient, size }),
114
90
  (0, import_patterns.circle)()
115
91
  ),
116
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
92
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
117
93
  Show,
118
94
  {
119
95
  when: Boolean(src) || Boolean(as),
120
- fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
96
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
121
97
  Show,
122
98
  {
123
99
  when: Boolean(initials),
124
- fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
100
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
125
101
  Show,
126
102
  {
127
103
  when: Boolean(icon),
128
- fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
104
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
129
105
  AvatarIcon,
130
106
  {
131
107
  size: iconSizeMap[size]
@@ -137,15 +113,15 @@ function Avatar(props) {
137
113
  children: initials
138
114
  }
139
115
  ),
140
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
116
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
141
117
  Show,
142
118
  {
143
119
  when: Boolean(as),
144
- fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
120
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
145
121
  "img",
146
122
  {
147
123
  alt: props.ariaLabel,
148
- className: (0, import_css2.css)({
124
+ className: (0, import_css.css)({
149
125
  h: "full",
150
126
  objectFit: "cover",
151
127
  w: "full"
@@ -176,72 +152,67 @@ var iconSizeMap = {
176
152
  "4xl": 32
177
153
  };
178
154
 
179
- // src/context/cta-modal.tsx
180
- var import_jsx2 = require("@cerberus/styled-system/jsx");
181
- var import_css6 = require("@cerberus/styled-system/css");
182
- var import_jsx3 = require("@cerberus/styled-system/jsx");
183
-
184
155
  // src/components/Dialog.tsx
185
- var import_react5 = require("@ark-ui/react");
186
- var import_recipes3 = require("@cerberus/styled-system/recipes");
156
+ var import_react4 = require("@ark-ui/react");
157
+ var import_recipes2 = require("@cerberus/styled-system/recipes");
187
158
 
188
159
  // src/components/Portal.tsx
189
- var import_react4 = require("@ark-ui/react");
190
- var Portal = import_react4.Portal;
160
+ var import_react3 = require("@ark-ui/react");
161
+ var Portal = import_react3.Portal;
191
162
 
192
163
  // src/components/Dialog.tsx
193
- var import_css3 = require("@cerberus/styled-system/css");
194
- var import_jsx_runtime4 = require("react/jsx-runtime");
164
+ var import_css2 = require("@cerberus/styled-system/css");
165
+ var import_jsx_runtime3 = require("react/jsx-runtime");
195
166
  function DialogProvider(props) {
196
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Dialog.Root, { ...props });
167
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Dialog.Root, { ...props });
197
168
  }
198
169
  function Dialog(props) {
199
170
  const { size, ...contentProps } = props;
200
- const styles = (0, import_recipes3.dialog)({ size });
201
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Portal, { children: [
202
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DialogBackdrop, { className: styles.backdrop }),
203
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DialogPositioner, { className: styles.positioner, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DialogContent, { className: styles.content, ...contentProps }) })
171
+ const styles = (0, import_recipes2.dialog)({ size });
172
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Portal, { children: [
173
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogBackdrop, { className: styles.backdrop }),
174
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogPositioner, { className: styles.positioner, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogContent, { className: styles.content, ...contentProps }) })
204
175
  ] });
205
176
  }
206
177
  function DialogHeading(props) {
207
- const styles = (0, import_recipes3.dialog)();
208
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Dialog.Title, { ...props, className: (0, import_css3.cx)(props.className, styles.title) });
178
+ const styles = (0, import_recipes2.dialog)();
179
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Dialog.Title, { ...props, className: (0, import_css2.cx)(props.className, styles.title) });
209
180
  }
210
181
  function DialogDescription(props) {
211
- const styles = (0, import_recipes3.dialog)();
212
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
213
- import_react5.Dialog.Description,
182
+ const styles = (0, import_recipes2.dialog)();
183
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
184
+ import_react4.Dialog.Description,
214
185
  {
215
186
  ...props,
216
- className: (0, import_css3.cx)(props.className, styles.description)
187
+ className: (0, import_css2.cx)(props.className, styles.description)
217
188
  }
218
189
  );
219
190
  }
220
- var DialogTrigger = import_react5.Dialog.Trigger;
221
- var DialogCloseTrigger = import_react5.Dialog.CloseTrigger;
222
- var DialogBackdrop = import_react5.Dialog.Backdrop;
223
- var DialogPositioner = import_react5.Dialog.Positioner;
224
- var DialogContent = import_react5.Dialog.Content;
191
+ var DialogTrigger = import_react4.Dialog.Trigger;
192
+ var DialogCloseTrigger = import_react4.Dialog.CloseTrigger;
193
+ var DialogBackdrop = import_react4.Dialog.Backdrop;
194
+ var DialogPositioner = import_react4.Dialog.Positioner;
195
+ var DialogContent = import_react4.Dialog.Content;
225
196
 
226
197
  // src/components/Dialog.client.tsx
227
- var import_react6 = require("@ark-ui/react");
228
- var import_recipes5 = require("@cerberus/styled-system/recipes");
229
- var import_css5 = require("@cerberus/styled-system/css");
198
+ var import_react5 = require("@ark-ui/react");
199
+ var import_recipes4 = require("@cerberus/styled-system/recipes");
200
+ var import_css4 = require("@cerberus/styled-system/css");
230
201
 
231
202
  // src/components/IconButton.tsx
232
- var import_css4 = require("@cerberus/styled-system/css");
233
- var import_recipes4 = require("@cerberus/styled-system/recipes");
234
- var import_jsx_runtime5 = require("react/jsx-runtime");
203
+ var import_css3 = require("@cerberus/styled-system/css");
204
+ var import_recipes3 = require("@cerberus/styled-system/recipes");
205
+ var import_jsx_runtime4 = require("react/jsx-runtime");
235
206
  function IconButton(props) {
236
207
  const { ariaLabel, palette, usage, size, ...nativeProps } = props;
237
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
208
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
238
209
  "button",
239
210
  {
240
211
  ...nativeProps,
241
212
  "aria-label": ariaLabel ?? "Icon Button",
242
- className: (0, import_css4.cx)(
213
+ className: (0, import_css3.cx)(
243
214
  nativeProps.className,
244
- (0, import_recipes4.iconButton)({
215
+ (0, import_recipes3.iconButton)({
245
216
  palette,
246
217
  usage,
247
218
  size
@@ -252,115 +223,181 @@ function IconButton(props) {
252
223
  }
253
224
 
254
225
  // src/components/Dialog.client.tsx
255
- var import_jsx_runtime6 = require("react/jsx-runtime");
226
+ var import_jsx_runtime5 = require("react/jsx-runtime");
256
227
  function DialogCloseIconTrigger(props) {
257
228
  const { icons } = useCerberusContext();
258
229
  const { close: CloseIcon } = icons;
259
- const styles = (0, import_recipes5.dialog)();
260
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
261
- import_react6.Dialog.CloseTrigger,
230
+ const styles = (0, import_recipes4.dialog)();
231
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
232
+ import_react5.Dialog.CloseTrigger,
262
233
  {
263
234
  ...props,
264
- className: (0, import_css5.cx)(props.className, styles.closeTrigger),
235
+ className: (0, import_css4.cx)(props.className, styles.closeTrigger),
265
236
  asChild: true,
266
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
237
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
267
238
  IconButton,
268
239
  {
269
240
  ariaLabel: "Close dialog",
270
241
  palette: "action",
271
242
  size: "lg",
272
243
  usage: "ghost",
273
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CloseIcon, {})
244
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseIcon, {})
274
245
  }
275
246
  )
276
247
  }
277
248
  );
278
249
  }
279
250
 
280
- // src/context/cta-modal.tsx
251
+ // src/components/cta-dialog/context.tsx
252
+ var import_react6 = require("react");
253
+ var CTAModalContext = (0, import_react6.createContext)(null);
254
+
255
+ // src/components/cta-dialog/trigger-item.tsx
256
+ var import_css6 = require("@cerberus/styled-system/css");
257
+
258
+ // src/components/button/button.tsx
259
+ var import_react7 = require("react");
260
+ var import_css5 = require("@cerberus/styled-system/css");
261
+ var import_recipes5 = require("@cerberus/styled-system/recipes");
262
+ var import_jsx = require("@cerberus/styled-system/jsx");
263
+ var import_jsx_runtime6 = require("react/jsx-runtime");
264
+ var ButtonContext = (0, import_react7.createContext)({
265
+ pending: false
266
+ });
267
+ function Button(props) {
268
+ const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
269
+ const value = (0, import_react7.useMemo)(() => ({ pending }), [pending]);
270
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
271
+ "button",
272
+ {
273
+ ...nativeProps,
274
+ disabled: pending || nativeProps.disabled,
275
+ className: (0, import_css5.cx)(
276
+ nativeProps.className,
277
+ (0, import_recipes5.button)({
278
+ palette,
279
+ usage,
280
+ shape,
281
+ size
282
+ })
283
+ )
284
+ }
285
+ ) });
286
+ }
287
+
288
+ // src/components/cta-dialog/trigger-item.tsx
289
+ var import_factory = require("@ark-ui/react/factory");
290
+ var import_recipes6 = require("@cerberus/styled-system/recipes");
281
291
  var import_jsx_runtime7 = require("react/jsx-runtime");
282
- var CTAModalContext = (0, import_react7.createContext)(null);
292
+ function TriggerItem(props) {
293
+ const { asChild, children, ...buttonProps } = props;
294
+ if (asChild) {
295
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
296
+ import_factory.ark.div,
297
+ {
298
+ className: (0, import_css6.cx)(
299
+ (0, import_recipes6.button)({
300
+ shape: "rounded",
301
+ usage: "ghost"
302
+ }),
303
+ (0, import_css6.css)({
304
+ w: "1/2"
305
+ })
306
+ ),
307
+ asChild: true,
308
+ children
309
+ }
310
+ );
311
+ }
312
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
313
+ Button,
314
+ {
315
+ ...buttonProps,
316
+ className: (0, import_css6.css)({
317
+ w: "1/2"
318
+ }),
319
+ shape: "rounded",
320
+ usage: "outlined",
321
+ children
322
+ }
323
+ );
324
+ }
325
+
326
+ // src/components/cta-dialog/provider.tsx
327
+ var import_jsx_runtime8 = require("react/jsx-runtime");
283
328
  function CTAModal(props) {
284
- var _a, _b;
285
- const [open, setOpen] = (0, import_react7.useState)(false);
286
- const [content, setContent] = (0, import_react7.useState)(null);
329
+ const [open, setOpen] = (0, import_react8.useState)(false);
330
+ const [content, setContent] = (0, import_react8.useState)(null);
287
331
  const confirmIcon = content == null ? void 0 : content.icon;
288
332
  const { icons } = useCerberusContext();
289
333
  const { confirmModal: FallbackIcon } = icons;
290
- const handleShow = (0, import_react7.useCallback)(
334
+ const handleShow = (0, import_react8.useCallback)(
291
335
  (options) => {
292
- const maxActions = 2;
293
- if (options.actions.length > maxActions) {
294
- throw new Error(
295
- `CTA Modal only supports a maximum of ${maxActions} actions.`
296
- );
297
- }
298
336
  setContent({ ...options });
299
337
  setOpen(true);
300
338
  },
301
339
  [setOpen]
302
340
  );
303
- const handleActionClick = (0, import_react7.useCallback)(
341
+ const handleActionClick = (0, import_react8.useCallback)(
304
342
  (event) => {
305
- const index = event.currentTarget.getAttribute("data-index");
306
- const action = content == null ? void 0 : content.actions[Number(index)];
307
- const { onClick } = action || {};
308
- onClick == null ? void 0 : onClick(event);
343
+ var _a;
344
+ const index = Number(event.currentTarget.getAttribute("data-index"));
345
+ const contentActions = content == null ? void 0 : content.actions;
346
+ const action = contentActions._actions[index];
347
+ (_a = action == null ? void 0 : action.handleClick) == null ? void 0 : _a.call(action, event);
309
348
  setOpen(false);
310
349
  },
311
350
  [content, setOpen]
312
351
  );
313
- const value = (0, import_react7.useMemo)(
352
+ const value = (0, import_react8.useMemo)(
314
353
  () => ({
315
354
  show: handleShow
316
355
  }),
317
356
  [handleShow]
318
357
  );
319
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(CTAModalContext.Provider, { value, children: [
358
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(CTAModalContext.Provider, { value, children: [
320
359
  props.children,
321
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogProvider, { open, onOpenChange: (e) => setOpen(e.open), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Dialog, { size: "sm", children: [
322
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogCloseIconTrigger, {}),
323
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx3.VStack, { gap: "xl", w: "full", children: [
324
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx3.VStack, { alignItems: "flex-start", gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx3.VStack, { gap: "lg", w: "full", children: [
325
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
360
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogProvider, { open, onOpenChange: (e) => setOpen(e.open), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Dialog, { size: "sm", children: [
361
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogCloseIconTrigger, {}),
362
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx2.VStack, { gap: "xl", w: "full", children: [
363
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx2.VStack, { alignItems: "flex-start", gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx2.VStack, { gap: "lg", w: "full", children: [
364
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
326
365
  Avatar,
327
366
  {
328
367
  ariaLabel: "",
329
368
  gradient: "charon-light",
330
- icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
369
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
331
370
  Show,
332
371
  {
333
372
  when: Boolean(confirmIcon),
334
- fallback: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FallbackIcon, { size: 24 }),
373
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FallbackIcon, { size: 24 }),
335
374
  children: confirmIcon
336
375
  }
337
376
  ),
338
377
  src: ""
339
378
  }
340
379
  ),
341
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogHeading, { children: content == null ? void 0 : content.heading }),
342
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogDescription, { children: content == null ? void 0 : content.description })
380
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogHeading, { children: content == null ? void 0 : content.heading }),
381
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogDescription, { children: content == null ? void 0 : content.description })
343
382
  ] }) }),
344
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx2.HStack, { gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Show, { when: Boolean((_a = content == null ? void 0 : content.actions) == null ? void 0 : _a.length), children: (_b = content == null ? void 0 : content.actions) == null ? void 0 : _b.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
345
- Button,
346
- {
347
- "data-index": index,
348
- className: (0, import_css6.css)({
349
- w: "1/2"
350
- }),
351
- onClick: handleActionClick,
352
- shape: "rounded",
353
- usage: "outlined",
354
- children: action.text
355
- },
356
- index
357
- )) }) })
383
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx2.HStack, { gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(For, { each: content == null ? void 0 : content.actions._actions, children: (action, index) => {
384
+ var _a;
385
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
386
+ Show,
387
+ {
388
+ when: ((_a = content == null ? void 0 : content.actions) == null ? void 0 : _a.type) === "btnAction",
389
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TriggerItem, { asChild: true, children: action }),
390
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TriggerItem, { "data-index": index, onClick: handleActionClick, children: action == null ? void 0 : action.text })
391
+ },
392
+ index
393
+ );
394
+ } }) })
358
395
  ] })
359
396
  ] }) })
360
397
  ] });
361
398
  }
362
399
  function useCTAModal() {
363
- const context = (0, import_react7.useContext)(CTAModalContext);
400
+ const context = (0, import_react8.useContext)(CTAModalContext);
364
401
  if (context === null) {
365
402
  throw new Error("useCTAModal must be used within a CTAModal Provider");
366
403
  }
@@ -371,4 +408,4 @@ function useCTAModal() {
371
408
  CTAModal,
372
409
  useCTAModal
373
410
  });
374
- //# sourceMappingURL=cta-modal.cjs.map
411
+ //# sourceMappingURL=provider.cjs.map