Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | /** * UI Component Types * * Central location for all UI component prop types. * Shared types for buttons, inputs, modals, cards, and other reusable components. * * @example * ```tsx * import { ButtonProps, ModalProps, InputProps } from '@/types/ui'; * * const MyButton: React.FC<ButtonProps> = (props) => { * // Component implementation * }; * ``` */ import * as React from 'react'; // ============================================================================= // BUTTON TYPES // ============================================================================= /** * Button component props */ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { /** Button visual variant */ variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'; /** Button size */ size?: 'sm' | 'md' | 'lg'; /** Full width button */ fullWidth?: boolean; /** * Loading state (standard prop) * Takes precedence over legacy `loading` prop */ isLoading?: boolean; /** * @deprecated Use `isLoading` instead * Loading state (legacy prop) */ loading?: boolean; /** * Disabled state (standard prop) * Takes precedence over native `disabled` prop */ isDisabled?: boolean; /** Icon before text */ leftIcon?: React.ReactNode; /** Icon after text */ rightIcon?: React.ReactNode; } /** * IconButton component props */ export interface IconButtonProps { onClick?: () => void; ariaLabel?: string; className?: string; children: React.ReactNode; icon?: string; } // ============================================================================= // MODAL & DIALOG TYPES // ============================================================================= /** * Modal component props */ export interface ModalProps { /** Control modal visibility */ open: boolean; /** Callback when modal should close */ onClose: () => void; /** Modal title */ title?: string; /** Modal size */ size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'; /** Show close button */ showCloseButton?: boolean; /** Close on backdrop click */ closeOnBackdrop?: boolean; /** Close on escape key */ closeOnEscape?: boolean; /** Modal content */ children: React.ReactNode; /** Footer content */ footer?: React.ReactNode; } /** * ConfirmDialog variant type */ export type ConfirmDialogVariant = 'info' | 'warning' | 'danger'; /** * ConfirmDialog component props */ export interface ConfirmDialogProps { isOpen: boolean; title: string; message: string; confirmText?: string; cancelText?: string; variant?: ConfirmDialogVariant; onConfirm: () => void; onCancel: () => void; } // ============================================================================= // INPUT & FORM TYPES // ============================================================================= /** * Base props shared by all input types */ interface BaseInputProps { /** Input size */ size?: 'sm' | 'md' | 'lg'; /** Validation state */ state?: 'default' | 'success' | 'error' | 'warning'; /** Label text */ label?: string; /** Helper text below input */ helperText?: string; /** Error message (sets state to 'error') */ error?: string; /** Icon before input */ leftIcon?: React.ReactNode; /** Icon after input */ rightIcon?: React.ReactNode; /** Full width input */ fullWidth?: boolean; /** Element type to render */ as?: 'input' | 'select' | 'textarea'; } /** * Props when as="input" (default) */ export interface InputInputProps extends BaseInputProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> { as?: 'input'; } /** * Props when as="select" */ export interface SelectInputProps extends BaseInputProps, Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'> { as: 'select'; children: React.ReactNode; } /** * Props when as="textarea" */ export interface TextareaInputProps extends BaseInputProps, Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'size'> { as: 'textarea'; } /** * Input component props (union type) */ export type InputProps = InputInputProps | SelectInputProps | TextareaInputProps; /** * TextField props */ export interface TextFieldProps extends Omit<InputInputProps, 'type' | 'as'> { type?: 'text' | 'email' | 'url' | 'tel' | 'date'; } // ============================================================================= // CHECKBOX & RADIO TYPES // ============================================================================= /** * Checkbox component props */ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size' | 'onChange'> { label?: string; checked?: boolean; onChange?: (checked: boolean) => void; disabled?: boolean; error?: string; helperText?: string; state?: 'default' | 'success' | 'error' | 'warning'; size?: 'sm' | 'md' | 'lg'; labelClassName?: string; } /** * Radio option */ export interface RadioOption { label: string; value: string; disabled?: boolean; helperText?: string; } /** * RadioGroup component props */ export interface RadioGroupProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size' | 'onChange'> { label?: string; options: RadioOption[]; value?: string; onChange?: (value: string) => void; disabled?: boolean; error?: string; helperText?: string; state?: 'default' | 'success' | 'error' | 'warning'; size?: 'sm' | 'md' | 'lg'; layout?: 'vertical' | 'horizontal'; required?: boolean; name: string; } // ============================================================================= // DROPDOWN TYPES // ============================================================================= /** * Dropdown item */ export interface DropdownItem { label: string; value: string; icon?: React.ReactNode; disabled?: boolean; } /** * Dropdown component props */ export interface DropdownProps { /** Dropdown items */ items: DropdownItem[]; /** Current selected value */ value?: string; /** Callback when item selected */ onChange?: (value: string) => void; /** Placeholder text */ placeholder?: string; /** Dropdown size */ size?: 'sm' | 'md' | 'lg'; /** Full width dropdown */ fullWidth?: boolean; /** Disabled state */ disabled?: boolean; /** Custom trigger button */ trigger?: React.ReactNode; } // ============================================================================= // CARD TYPES // ============================================================================= /** * Card component props */ export interface CardProps extends React.HTMLAttributes<HTMLDivElement> { /** Card visual variant */ variant?: 'default' | 'bordered' | 'elevated' | 'ghost' | 'shadow-1' | 'flat'; /** Enable hover effect */ hoverable?: boolean; /** Enable clickable cursor */ clickable?: boolean; /** Padding size */ padding?: 'none' | 'sm' | 'md' | 'lg'; /** Border radius */ rounded?: 'none' | 'sm' | 'md' | 'lg'; } // ============================================================================= // BADGE TYPES // ============================================================================= /** * Badge component props */ export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> { /** Badge visual variant */ variant?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'discount' | 'new' | 'featured'; /** Badge size */ size?: 'sm' | 'md' | 'lg'; /** Show dot indicator */ dot?: boolean; /** Rounded pill style */ pill?: boolean; } // ============================================================================= // STEPPER TYPES // ============================================================================= /** * Stepper step configuration */ export interface Step { id: string | number; label: string; description?: string; icon?: React.ReactNode; optional?: boolean; } /** * Stepper component props */ export interface StepperProps { steps: Step[]; currentStep: number; onStepClick?: (index: number) => void; clickable?: boolean; orientation?: 'horizontal' | 'vertical'; showDescription?: boolean; className?: string; } // ============================================================================= // RATING TYPES // ============================================================================= /** * StarRating component props */ export interface StarRatingProps { /** Rating value (0-5, supports decimals like 4.5) */ rating?: number; /** Maximum number of stars */ maxStars?: number; /** Number of reviews */ reviewCount?: number; /** Star size */ size?: 'sm' | 'md' | 'lg'; /** Show review count */ showCount?: boolean; /** Interactive mode for review submission */ interactive?: boolean; /** Callback for interactive mode */ onRatingChange?: (rating: number) => void; /** Product ID to link to reviews section (makes rating clickable) */ productId?: number; /** Additional CSS classes */ className?: string; } // ============================================================================= // PRICE DISPLAY TYPES // ============================================================================= /** * PriceDisplay component props */ export interface PriceDisplayProps { /** Regular price */ price: number; /** Discounted price (optional) */ discountedPrice?: number; /** Display size */ size?: 'sm' | 'md' | 'lg' | 'xl'; /** Layout direction */ layout?: 'horizontal' | 'vertical'; /** Show "Save $X" badge */ showSavings?: boolean; /** Show discount percentage */ showPercentage?: boolean; /** Currency symbol */ currency?: string; /** Additional CSS classes */ className?: string; } // ============================================================================= // SKELETON TYPES // ============================================================================= /** * Skeleton component props */ export interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> { /** Width (CSS value or tailwind class) */ width?: string | number; /** Height (CSS value or tailwind class) */ height?: string | number; /** Border radius */ rounded?: 'none' | 'sm' | 'md' | 'lg' | 'full'; /** Variant */ variant?: 'default' | 'text' | 'circular' | 'rectangular'; } /** * ProductListSkeleton component props */ export interface ProductListSkeletonProps { /** Number of skeleton cards to show */ count?: number; /** Grid columns */ columns?: number; } /** * TextSkeleton component props */ export interface TextSkeletonProps { /** Number of lines */ lines?: number; /** Gap between lines */ gap?: number; } /** * AvatarSkeleton component props */ export interface AvatarSkeletonProps { /** Avatar size */ size?: number; } // ============================================================================= // TOAST TYPES (Re-export from hooks for convenience) // ============================================================================= /** * Toast notification interface * * Note: The main useToast hook and these types are defined in @/hooks/useToast * These are re-exported here for convenience when importing UI types */ export interface Toast { id: string; title?: string; message: string; variant?: 'info' | 'success' | 'warning' | 'error'; duration?: number; } /** * Toast context value interface */ export interface ToastContextValue { toasts: Toast[]; addToast: (toast: Omit<Toast, 'id'>) => void; removeToast: (id: string) => void; } // ============================================================================= // ICON TYPES // ============================================================================= /** * Icon component props */ export interface IconProps { name: string; size?: number; className?: string; color?: string; } // ============================================================================= // COMMON UI PATTERNS // ============================================================================= /** * Common size variants */ export type SizeVariant = 'sm' | 'md' | 'lg' | 'xl'; /** * Common color variants */ export type ColorVariant = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error'; /** * Common state variants */ export type StateVariant = 'default' | 'success' | 'error' | 'warning' | 'info'; /** * Common orientation */ export type Orientation = 'horizontal' | 'vertical'; /** * Common alignment */ export type Alignment = 'start' | 'center' | 'end'; /** * Common spacing */ export type Spacing = 'none' | 'sm' | 'md' | 'lg' | 'xl'; |