import { ZenskarElementInstance } from '.'; /** * Type mapping from element type string to element instance type * Enables type-safe getElement() with automatic type narrowing * * This uses Extract to pull out the specific element instance type * from the ZenskarElementInstance union based on the 'type' discriminator */ export type ElementTypeMap = { 'add-payment-method': Extract; 'manage-billing-information': Extract; }; /** * Base props that all Zenskar elements share * Following Stripe Elements pattern for consistency */ export type ZenskarElementProps = { /** * Passes through to the Element's container. */ id?: string; /** * Passes through to the Element's container. */ className?: string; }; /** * All supported element types * New element types should be added here as they're implemented */ export type ZenskarElementType = ZenskarElementInstance['type']; /** * Base error type for all elements * Provides consistent error structure across all elements */ export type ZenskarError = { type: 'validation_error' | 'api_error' | 'network_error' | 'initialization_error' | 'provider_error'; code: string; message: string; field?: string; }; /** * Base element instance interface * All element instances must implement these core methods */ export type BaseZenskarElementInstance = { /** * Internal unique identifier for this element instance * This is used for element registration and is separate from the DOM id prop * Generated automatically using React's useId() hook */ id?: string; /** Whether the element has finished loading and is ready for interaction */ isReady: boolean; /** Whether the element's current data is valid */ isValid: boolean; /** Clear all data in the element and reset to initial state */ clear: () => void; };