import type { ForwardedEventPayload } from "../../core/dom/index.js"; import type { TouchEvents } from "../../core/utils/mobile.js"; import type { ButtonConfig as BaseButtonConfig } from "../button/types.js"; /** * Creates a new Card component following Material Design 3 principles. * @param config */ declare const createCard: (config?: CardConfig) => CardComponent; declare const CARD_CONTENT_PADDING = true; /** * Creates a card content component * @param config */ declare const createCardContent: (config?: CardContentConfig) => HTMLElement; /** * Creates a card header component * @param config */ declare const createCardHeader: (config?: CardHeaderConfig) => HTMLElement; /** * Creates a card actions component * @param config */ declare const createCardActions: (config?: CardActionsConfig) => HTMLElement; declare const NESTED_ACTION_SELECTOR = "button,a[href],input,select,textarea,m-button,m-icon-button,[role=button],[role=link],slot[name=actions],slot[name=header-action]"; /** * Creates a card media component * @param config */ declare const createCardMedia: (config?: CardMediaConfig) => HTMLElement; /** Card variant types following Material Design 3 guidelines. */ type CardVariant = 'elevated' | 'filled' | 'outlined'; /** Card elevation levels in Material Design 3. */ type CardElevationLevel = 0 | 1 | 2 | 4; /** Button configuration interface for buttons shorthand. */ interface ButtonConfig extends Omit { /** Button text content */ text?: string; /** Button variant (text, outlined, filled, etc.) */ variant?: string; /** Button icon HTML content */ icon?: string; } /** Card configuration interface defining all possible card options. */ interface CardConfig { /** Card variant type (elevated, filled, outlined) */ variant?: CardVariant | string; /** The hover and press states and their elevation, for a card the app makes interactive itself. */ interactive?: boolean; /** Whether the card should take full width */ fullWidth?: boolean; /** A card that acts on activation: a button (role, tab stop, Enter and Space click it) with the ripple. */ clickable?: boolean; /** Opt in so a clickable card with nested actions is an article container, not a button. */ promoteChildActions?: boolean; /** Whether the card is draggable */ draggable?: boolean; /** Additional CSS class(es) */ class?: string; /** Header configuration */ headerConfig?: CardHeaderConfig; /** Content configuration */ contentConfig?: CardContentConfig; /** Actions configuration */ actionsConfig?: CardActionsConfig; /** Media configuration */ mediaConfig?: CardMediaConfig; /** ARIA attributes for accessibility */ aria?: CardAriaAttributes; /** Inline header configuration (alternative to headerConfig) */ header?: CardHeaderConfig; /** Inline content configuration (alternative to contentConfig) */ content?: CardContentConfig; /** Inline media configuration (alternative to mediaConfig) */ media?: CardMediaConfig; /** Inline actions configuration (alternative to actionsConfig) */ actions?: CardActionsConfig; /** Simple buttons array for actions (will be converted to actionsConfig) */ buttons?: ButtonConfig[]; /** Internal component name */ componentName?: string; /** CSS class prefix */ prefix?: string; /** Callback executed after component creation */ afterCreation?: (component: BaseComponent) => void; } /** ARIA attributes for card accessibility. */ interface CardAriaAttributes { /** ARIA label */ label?: string; /** ARIA labelledby */ labelledby?: string; /** ARIA describedby */ describedby?: string; /** ARIA role (default: 'button' for a clickable card, 'article' for any other) */ role?: string; /** Additional ARIA attributes as key-value pairs */ [key: string]: string | undefined; } /** Card header configuration. */ interface CardHeaderConfig { /** Header title text */ title?: string; /** Header subtitle text */ subtitle?: string; /** Avatar element or HTML string */ avatar?: HTMLElement | string; /** Action element or HTML string */ action?: HTMLElement | string; /** Additional CSS class(es) */ class?: string; } /** Card content configuration. */ interface CardContentConfig { /** Text content */ text?: string; /** HTML content */ html?: string; /** Child elements */ children?: HTMLElement[]; /** Whether to add padding (true by default) */ padding?: boolean; /** Additional CSS class(es) */ class?: string; } /** Card actions configuration. */ interface CardActionsConfig { /** Action elements */ actions?: HTMLElement[]; /** Whether actions should be full-bleed */ fullBleed?: boolean; /** Whether actions should be stacked vertically */ vertical?: boolean; /** Horizontal alignment */ align?: 'start' | 'center' | 'end' | 'space-between'; /** Additional CSS class(es) */ class?: string; } /** Card media configuration. */ interface CardMediaConfig { /** Image source URL */ src?: string; /** Image alt text (required for accessibility) */ alt?: string; /** Custom element instead of image */ element?: HTMLElement; /** Aspect ratio */ aspectRatio?: '16:9' | '4:3' | '1:1' | string; /** Whether media should use object-fit: contain */ contain?: boolean; /** Additional CSS class(es) */ class?: string; /** Position of the media in the card */ position?: 'top' | 'bottom'; } /** Base component interface. */ interface BaseComponent { /** The DOM element */ element: HTMLElement; /** Get class name with prefix */ getClass: (name: string) => string; /** Get modifier class */ getModifierClass: (base: string, modifier: string) => string; /** Get element class */ getElementClass: (base: string, element: string) => string; /** Add CSS class(es) */ addClass: (...classes: string[]) => BaseComponent; /** Emit one of the card's own events ({@link CardEvents}), with its payload: the names and payloads `on` and `off` accept. */ emit?: (event: K, payload: Parameters[0]) => void; /** Component configuration */ config: CardComponentConfig; /** Touch state for touch interactions */ touchState?: TouchState; /** Update touch state */ updateTouchState?: (event: TouchEvent | MouseEvent, status: 'start' | 'end') => void; /** Component lifecycle methods */ lifecycle?: ComponentLifecycle; } /** Touch state interface for touch interactions. */ interface TouchState { /** Timestamp when touch started */ startTime: number; /** Starting position */ startPosition: { x: number; y: number; }; /** Whether touch is active */ isTouching: boolean; /** Current touch target */ activeTarget: EventTarget | null; } /** Component lifecycle interface. */ interface ComponentLifecycle { /** Called when component is mounted to DOM */ mount?: () => void; /** Called when component is updated */ update?: () => void; /** Called when component is destroyed */ destroy: () => void; } /** Card component configuration. */ interface CardComponentConfig extends CardConfig { /** Component name */ componentName: string; /** CSS class prefix */ prefix: string; } /** The card's events. */ interface CardEvents extends TouchEvents { /** Presentation state after expanding or collapsing. */ expandedChanged: (payload: { expanded: boolean; }) => void; click: (payload: ForwardedEventPayload) => void; mouseenter: (payload: ForwardedEventPayload) => void; mouseleave: (payload: ForwardedEventPayload) => void; keydown: (payload: ForwardedEventPayload) => void; focus: (payload: ForwardedEventPayload) => void; blur: (payload: ForwardedEventPayload) => void; dragstart: (payload: { event: DragEvent; }) => void; dragend: (payload: { event: DragEvent; }) => void; } /** Card component interface with methods. */ interface CardComponent extends BaseComponent { /** Subscribes to one of the card's events */ on: (event: K, handler: CardEvents[K]) => CardComponent; /** Removes a handler added with `on` */ off: (event: K, handler: CardEvents[K]) => CardComponent; /** * Adds content to the card. * @param contentElement */ addContent: (contentElement: HTMLElement) => CardComponent; /** * Sets the card header. * @param headerElement */ setHeader: (headerElement: HTMLElement) => CardComponent; /** * Adds media to the card. * @param mediaElement * @param position */ addMedia: (mediaElement: HTMLElement, position?: 'top' | 'bottom') => CardComponent; /** * Sets the card actions section. * @param actionsElement */ setActions: (actionsElement: HTMLElement) => CardComponent; /** * Makes the card draggable. * @param dragStartCallback */ makeDraggable: (dragStartCallback?: (event: DragEvent) => void) => CardComponent; /** Sets focus to the card. */ focus: () => CardComponent; /** Destroys the card component and removes event listeners. */ destroy: () => void; } interface LoadingFeature { isLoading: () => boolean; setLoading: (loading: boolean) => void; } interface ExpandableFeature { isExpanded: () => boolean; setExpanded: (expanded: boolean) => void; toggleExpanded: () => void; } interface SwipeableFeature { reset: () => void; } interface ApiOptions { lifecycle: { destroy: () => void; }; config: CardComponentConfig; } /** Registers CardConfig with the global defaults map, so `setComponentDefaults("card", ...)` is typed without core importing anything from this component. */ declare module "../../core/config/global" { interface ComponentConfigMap { card?: Partial; } } export type { CardActionsConfig, CardAriaAttributes, CardComponent, CardConfig, CardContentConfig, CardElevationLevel, CardEvents, CardHeaderConfig, CardMediaConfig, CardVariant }; export { createCard, createCard as default, createCardActions, createCardContent, createCardHeader, createCardMedia };