/** * Type definitions for the Switch component. * * @module @mks2508/mks-ui/react/ui/Switch/Switch.types */ import type { Switch as SwitchPrimitives } from '@base-ui/react/switch'; import type { HTMLMotionProps, LegacyAnimationControls, TargetAndTransition, VariantLabels } from 'motion/react'; import type { IBaseConfig, SlotOverrides } from '../../../core/types'; /** * Available style slot names for the Switch component. * Each slot maps to a visual region that can be customized via the `slots` prop. * * - `root` - The outer switch track/button element * - `thumb` - The sliding thumb indicator * - `icon` - Icons displayed at left/right/thumb positions * * @example * ```tsx * * ``` */ export type SwitchSlot = 'root' | 'thumb' | 'icon'; /** * Position of an icon within the Switch component. * * - `left` - Shown when the switch is ON (checked) * - `right` - Shown when the switch is OFF (unchecked) * - `thumb` - Always visible on the thumb */ export type SwitchIconPosition = 'left' | 'right' | 'thumb'; /** * Internal context type for Switch state management. * Shared between the Switch root and its child components via React context. */ export type SwitchContextType = { /** Whether the switch is currently checked (on). */ isChecked: boolean; /** Callback to update the checked state. */ setIsChecked: ISwitchProps['onCheckedChange']; /** Whether the switch is currently being pressed. */ isPressed: boolean; /** Callback to update the pressed state. */ setIsPressed: (isPressed: boolean) => void; }; /** * Configuration options for Switch behavior and animation. * Extends the base config with switch-specific settings. * * @example * ```tsx * * ``` */ export interface ISwitchConfig extends IBaseConfig { /** * Spring stiffness for the thumb animation. * @defaultValue 300 */ springStiffness?: number; /** * Spring damping for the thumb animation. * @defaultValue 25 */ springDamping?: number; } /** * Props for the Switch root component. * Combines Base UI Switch.Root props (without `render`) with Motion button props, * plus slot overrides and configuration. * * @example * ```tsx * * * * ``` */ export type ISwitchProps = Omit, 'render'> & HTMLMotionProps<'button'> & { /** Partial class overrides for each visual slot. */ slots?: SlotOverrides; /** Behavioral and animation configuration. */ config?: ISwitchConfig; }; /** * Props for the SwitchThumb sub-component. * Combines Base UI Switch.Thumb props (without `render`) with Motion div props, * plus an optional pressed animation target. * * @example * ```tsx * * ``` */ export type ISwitchThumbProps = Omit, 'render'> & HTMLMotionProps<'div'> & { /** * Animation target applied while the switch is being pressed. * Can be a motion target object, variant labels, or a boolean. */ pressedAnimation?: TargetAndTransition | VariantLabels | boolean | LegacyAnimationControls; /** Partial class overrides for each visual slot. */ slots?: SlotOverrides; }; /** * Props for the SwitchIcon sub-component. * Renders an icon at a specified position within the switch track or thumb. * * @example * ```tsx * * * * * * * ``` */ export type ISwitchIconProps = HTMLMotionProps<'div'> & { /** Where this icon is positioned within the switch. */ position: SwitchIconPosition; /** Partial class overrides for each visual slot. */ slots?: SlotOverrides; }; //# sourceMappingURL=Switch.types.d.ts.map