import { forwardRef, type ReactNode } from 'react'; import { Text, View, type PressableProps, type TextProps, type ViewProps } from 'react-native'; import { ButtonRoot, dataAttributes, mergeDataAttributes, type IButtonProps, useButtonContext, } from '@cdx-ui/primitives'; import type { ForgeIcon } from '@cdx-ui/icons'; import { cn } from '@cdx-ui/utils'; import { Icon, type IconProps } from '../Icon'; import { quickActionButtonGlyphVariants, quickActionButtonIndicatorVariants, quickActionButtonLabelVariants, quickActionButtonRootVariants, type QuickActionButtonVariantProps, } from './styles'; // ============================================================================= // ROOT // ============================================================================= export interface QuickActionButtonProps extends PressableProps, IButtonProps { className?: string; children?: ReactNode; } const QuickActionButtonRoot = forwardRef( ({ className, style, children, accessibilityRole = 'button', ...props }, ref) => ( {children} ), ); QuickActionButtonRoot.displayName = 'QuickActionButton'; // ============================================================================= // INDICATOR // Circular container. Auto-rendered by `QuickActionButton.Icon` in standard usage. // Exposed as a compound member for Code Connect parity and custom compositions. // ============================================================================= export interface QuickActionButtonIndicatorProps extends ViewProps { className?: string; children?: ReactNode; } const QuickActionButtonIndicator = forwardRef( ({ className, style, children, ...props }, ref) => { const { hover, focus, active, disabled, focusVisible } = useButtonContext(); return ( {children} ); }, ); QuickActionButtonIndicator.displayName = 'QuickActionButton.Indicator'; // ============================================================================= // ICON // Renders the Indicator circle + icon glyph as one convenient sub-component. // This is the primary way consumers add the icon to a QuickActionButton. // ============================================================================= export interface QuickActionButtonIconProps { /** Forge icon component to render inside the circular indicator. */ as: ForgeIcon; /** Applied to the icon glyph, not the indicator circle. */ className?: IconProps['className']; /** Applied to the indicator circle wrapper. */ indicatorClassName?: string; } function QuickActionButtonIcon({ as: IconComponent, className, indicatorClassName, }: QuickActionButtonIconProps) { return ( ); } QuickActionButtonIcon.displayName = 'QuickActionButton.Icon'; // ============================================================================= // LABEL // ============================================================================= export interface QuickActionButtonLabelProps extends TextProps { className?: string; children?: ReactNode; } const QuickActionButtonLabel = forwardRef( ({ className, style, children, ...props }, ref) => { const { disabled } = useButtonContext(); return ( {children} ); }, ); QuickActionButtonLabel.displayName = 'QuickActionButton.Label'; // ============================================================================= // COMPOUND EXPORT // ============================================================================= type QuickActionButtonCompoundComponent = typeof QuickActionButtonRoot & { Indicator: typeof QuickActionButtonIndicator; Icon: typeof QuickActionButtonIcon; Label: typeof QuickActionButtonLabel; }; export const QuickActionButton = Object.assign(QuickActionButtonRoot, { Indicator: QuickActionButtonIndicator, Icon: QuickActionButtonIcon, Label: QuickActionButtonLabel, }) as QuickActionButtonCompoundComponent; export type { QuickActionButtonVariantProps };