import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["span"]; type $Props = { /** * Specify the length of the countdown in seconds. With `until`, set it to * the full length so the slot's `fraction` is the share left. * @default 60 */ seconds?: number; /** * Specify when the countdown ends, as a `Date` or a timestamp in * milliseconds, such as a session timeout or a hold that the server set. * The time left then follows the clock, so it agrees across reloads and * tabs. Overrides `seconds` as the starting point. To extend the time, * set a later `until`; changing `remaining` does not move the deadline. */ until?: undefined | Date | number; /** * The seconds left. Starts at `seconds`, or the time to `until`; add to * it to extend the time, which also restarts a countdown that ended. * With `until`, the deadline decides the time left, so set a later * `until` instead. * @default until == null ? seconds : secondsUntil(until) */ remaining?: number; /** * Set to `false` to pause the countdown. * @default true */ running?: boolean; /** * Specify how the time is written: `"auto"` uses h:mm:ss from an hour * up and m:ss below it, and `"mm:ss"` pads the minutes, as on a timer. * @default "auto" */ format?: "auto" | "m:ss" | "mm:ss" | "h:mm:ss"; /** * Specify how many seconds before the end to warn screen reader users, * with `warnDescription`. The countdown is not announced every second. * @default 60 */ warnAt?: number; /** * Specify the text screen readers hear `warnAt` seconds before the end. * It is not shown. * @default "One minute left" */ warnDescription?: string; /** * Specify the text screen readers hear when the time runs out * @default "Time is up" */ expiredDescription?: string; /** Custom rendering, such as a ProgressBar. `fraction` is the share of `seconds` left, from 1 to 0. */ children?: (this: void, ...args: [{ remaining: number; formatted: string; fraction: number }]) => void; [key: `data-${string}`]: unknown; }; export type CountdownProps = Omit<$RestProps, keyof $Props> & $Props; export default class Countdown extends SvelteComponentTyped< CountdownProps, { end: CustomEvent }, { /** Custom rendering, such as a ProgressBar. `fraction` is the share of `seconds` left, from 1 to 0. */ default: { remaining: number; formatted: string; fraction: number }; } > {}