import { type Language } from "../strings.ts"; import type { CardDesign } from "./card-faces.types.ts"; import { ElementBase, type SpinOptions } from "./element-kit.ts"; /** What a card's `face` function is told: the language the card speaks, and the design it names. * * @example * ```ts * import type { CardFaceContext } from "@johnmorrisdotca/toranpu/element"; * * const value: CardFaceContext = { language: "en", design: "plain" }; * console.log(value.language); * ``` */ export type CardFaceContext = { language: Language; design: "plain" | "four-colour" | CardDesign | null; }; /** * A function that draws a card's face: given the card's id and its context, SVG markup (drawn on the card's paper in a box * 100 by 140, or a whole `` document), or an element, or null to draw the card as its design does. * * @example * ```ts * import type { CardFaceRenderer } from "@johnmorrisdotca/toranpu/element"; * import { cardFaceSvg } from "@johnmorrisdotca/toranpu/card-faces"; * * const card = { suit: "spades", rank: 1 } as const; * const value: CardFaceRenderer = (card) => cardFaceSvg(card); * console.log(typeof value); * ``` */ export type CardFaceRenderer = (card: string, context: CardFaceContext) => string | Node | null; /** * ONE CARD ON ANY PAGE: ``, in any design and with any * back, face up or face down, turned over by a tap when it has `flip`. * * ```html * * ``` * * Attributes, all optional but `card`: * card the card: `QS`, `TD`, `RJ`, `BJ`; or the id of a card of a design the page registered * design `plain` (unless said), `four-colour` or `english`, which is fetched the first time it is asked for; or the name of a design the page registered * back `classic-red` (unless said), `classic-blue` or `ink-dots`, or the name of a back the page registered; `back-colour`, `back-image`, `back-logo` and `mark` as `cardBackSvg` takes them * label what a screen reader says for a card of your own, which has no name in any deck * face-down shows the back; the face is not in the page while it is down * flip a tap, Enter or Space turns it over, with a turn that a device asking for less motion skips * marked a mark on its corner, seen face up and face down, to follow it as it moves * size `small`, `medium` (unless said) or `large`; or `width` in pixels; or the page's `--toranpu-card-width` * sound the turn makes a sound * lang `ja` for Japanese names; the page's language unless said * * Your own face and back: put an element in the card with `slot="face"` (or `slot="back"`), and it is drawn * as the face (or the back) in place of the card's own, in the box of the card. A `face` property that is a function draws * the face from the card's id (`CardFaceRenderer`). Neither is in the page while the card lies the other way up. * * Each turn is a `toranpu-flip` event that bubbles, with `{ card, faceDown }` as its detail. `spin(options?)` * spins it where it lies, slowing to a stop as it was. * @example * ```ts * import { ToranpuCard } from "@johnmorrisdotca/toranpu/element"; * console.log(ToranpuCard.observedAttributes.includes("lang")); // true * ``` */ export declare class ToranpuCard extends ElementBase { #private; get card(): string | null; set card(value: string | number | readonly string[] | null | undefined); get design(): string | null; set design(value: string | number | readonly string[] | null | undefined); get back(): string | null; set back(value: string | number | readonly string[] | null | undefined); get backColour(): string | null; set backColour(value: string | number | readonly string[] | null | undefined); get "back-colour"(): string | null; set "back-colour"(value: string | number | readonly string[] | null | undefined); get backImage(): string | null; set backImage(value: string | number | readonly string[] | null | undefined); get "back-image"(): string | null; set "back-image"(value: string | number | readonly string[] | null | undefined); get backLogo(): string | null; set backLogo(value: string | number | readonly string[] | null | undefined); get "back-logo"(): string | null; set "back-logo"(value: string | number | readonly string[] | null | undefined); get mark(): string | null; set mark(value: string | number | readonly string[] | null | undefined); get label(): string | null; set label(value: string | number | readonly string[] | null | undefined); get marked(): boolean; set marked(value: boolean | string | null | undefined); get size(): string | null; set size(value: string | number | readonly string[] | null | undefined); get width(): string | null; set width(value: string | number | readonly string[] | null | undefined); get theme(): string | null; set theme(value: string | number | readonly string[] | null | undefined); get sound(): boolean; set sound(value: boolean | string | null | undefined); static get observedAttributes(): readonly string[]; /** Whether the card shows its back. Setting it turns the card over, as a tap would, but with no event and no sound. */ get faceDown(): boolean; set faceDown(down: boolean | string | null | undefined); /** A function that draws this card's face from its id, in place of its design's (`CardFaceRenderer`); null for none. Setting it draws the card afresh. */ get face(): CardFaceRenderer | null; set face(renderer: CardFaceRenderer | null); /** Turn the card over, as a tap does: the turn, the sound if it has `sound`, and the `toranpu-flip` event. */ flip(): void; /** Spin the card where it lies, as a flick sets a card turning on a table: fast, then slowing to a stop as it was (`SpinOptions`). */ spin(options?: SpinOptions): Promise; connectedCallback(): void; disconnectedCallback(): void; attributeChangedCallback(): void; }