/** * What Toranpu's custom elements share: a base class that is safe to define on * a server, the designs each element may name (the English pattern fetched * the first time one asks), the language an element speaks, one set of * sounds for the page, and the drawing of one card face up or face down. */ import { type Language } from "../strings.ts"; import { type CardBackOptions } from "./card-backs.ts"; import type { CardDesign } from "./card-faces.types.ts"; import { type CardSounds } from "./card-sounds.ts"; /** What the elements extend: HTMLElement, or on a server, where there is none, an empty class, so that importing them never throws. */ export declare const ElementBase: typeof HTMLElement; /** * A design as an element names it: `plain` and `four-colour` at once; one the * page registered at once; a drawn set (`english`, `realistic`) once it has * been fetched, and until then `null`, with `ready` settling when it arrives. */ export declare function designNamed(name: string | null): { design: "plain" | "four-colour" | CardDesign | null; ready: Promise | null; }; /** The language an element speaks: its own `lang`, or the nearest one above it, or the page's; Japanese for anything that starts `ja`. */ export declare function languageOf(element: Element): Language; /** One set of sounds for every element on the page, made the first time an element with `sound` makes one. */ export declare function pageSounds(): CardSounds; /** A back as an element names it: a built-in one or one the page registered, with the colour, words, picture and logo the element gives it. */ export declare function backOptions(element: Element): { name: string; options: CardBackOptions; }; /** One card's drawing: its face, or its back. A face-down card's face is never in the page. */ export declare function cardDrawing(card: string, faceDown: boolean, element: Element, design: "plain" | "four-colour" | CardDesign | null, language: Language): string; /** What a screen reader says for a card: its name, or that it is face down. */ export declare function cardLabel(card: string, faceDown: boolean, language: Language, design?: "plain" | "four-colour" | CardDesign | null): string; /** The sizes every element takes, as a card's width in pixels. * * @example * ```ts * import { ELEMENT_SIZES } from "@johnmorrisdotca/toranpu/element"; * console.log(ELEMENT_SIZES); * ``` */ export declare const ELEMENT_SIZES: { readonly small: 46; readonly medium: 70; readonly large: 104; }; /** An element's card width in CSS: its `width` in pixels, or its `size`, or the page's `--toranpu-card-width`, or medium. */ export declare function widthOf(element: Element): string; /** Whether the person has asked their device for less motion. */ export declare function lessMotion(): boolean; /** An attribute that is on when present, unless it says "false" or "off". */ export declare function isOn(element: Element, name: string): boolean; /** * Redraw an element when the page changes its language (``), as a * language chooser does, or registers a design or a back (so an element on the * page before the page's own branding is registered draws again with it), until * `forget` is called. One watcher serves every element on the page. */ export declare function followLanguage(redraw: () => void): () => void; /** Cards as an element's method is given them, one or several, in any spelling `readHand` reads, as ids. */ export declare function cardIds(cards: string | readonly string[]): string[]; /** The cards an element's `marked` attribute names. */ export declare function markedCards(element: Element): Set; /** * A MARK ON A CARD, to follow it while it is face down and moves about (John, 2026-10-01: in Solitaire, * "to visually track a hidden card in deck games where the cards move around and recycle"). A round dot * on the card's top left corner, where a fanned hand and a pile both leave it in sight, the same on the * face and on the back, since it is drawn on the card and not on either side. `--toranpu-marker` colours it. */ export declare function markerHtml(marked: boolean): string; /** The mark's look, for every element that draws one. */ export declare const MARKER_STYLE = ".marker { position: absolute; left: -6%; top: -4%; width: 22%; aspect-ratio: 1; border-radius: 50%; background: var(--toranpu-marker, #f2b134); box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,.45); pointer-events: none; }"; /** How a card is spun. * * @example * ```ts * import type { SpinOptions } from "@johnmorrisdotca/toranpu/element"; * * const value: SpinOptions = { direction: "clockwise", turns: 1, ms: 300 }; * console.log(value.turns); * ``` */ export type SpinOptions = { /** Which way it spins. Unless said, clockwise. */ direction?: "clockwise" | "anticlockwise"; /** How many whole turns before it comes to rest where it lay. Unless said, 3; at most 20. */ turns?: number; /** How long the spin takes, in milliseconds. Unless said, 700 and 420 a turn. */ ms?: number; }; /** * A CARD SPUN ON THE TABLE, as a flick sets a real one turning: fast at first, then slowed by the * cloth until it stops, a whole number of turns later, lying as it was. `delay` starts it a little * after the others where several spin. Settles at once on a device that asks for less motion, and * when the spin is cut short. */ export declare function spinElement(element: HTMLElement, options?: SpinOptions, delay?: number): Promise; /** * LET A FRAMEWORK SET AN ATTRIBUTE THAT IS ALSO A METHOD. React, Vue and Svelte set a property, not an attribute, on a * custom element that has one of the name (`` is `card.flip = true`), and `flip` is a method too, so * the assignment would replace the method and leave the attribute unset. This makes the name an accessor: reading it * still gives the method, so `card.flip()` goes on working, and writing it sets the attribute (`true` or `""` turns it * on, `false`, `null` and `undefined` take it away, any other value is the attribute's text). */ export declare function reflectMethod(element: { prototype: object; }, name: string): void; /** An attribute's new text from what a property was given: a list is joined with spaces, and nothing at all takes the attribute away (null). */ export declare function attributeText(value: unknown): string | null; /** Reflect a custom element's plain attributes without replacing its existing methods or structured getters. */ export declare function writeElementAttribute(element: Element, name: string, value: unknown, flag?: boolean): void; /** Apply the standard light/dark/auto preference without changing the artwork's own colours. */ export declare function elementTheme(element: HTMLElement): void;