UNPKG

m3-svelte

Version:

M3 Svelte implements the Material 3 design system in Svelte. See the [website](https://kendell.dev/m3-svelte/) for demos and usage instructions.

24 lines (23 loc) 968 B
import type { HTMLLabelAttributes, HTMLAnchorAttributes, HTMLButtonAttributes, HTMLAttributes } from "svelte/elements"; type MakeRequired<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]>; }; export type NotButton<T> = Omit<T, "onclick"> & { onclick?: undefined; }; export type NotLink<T> = T & { href?: undefined; }; export type ButtonAttrs = MakeRequired<NotLink<HTMLButtonAttributes>, "onclick">; export type LabelAttrs = MakeRequired<NotLink<NotButton<HTMLLabelAttributes>>, "for">; export type AnchorAttrs = MakeRequired<NotButton<HTMLAnchorAttributes>, "href">; export type DivAttrs = NotLink<NotButton<HTMLAttributes<HTMLDivElement>>>; export type OneOf<T, TKey extends keyof T = keyof T> = TKey extends keyof T ? { [P in TKey]-?: T[TKey]; } & Partial<Record<Exclude<keyof T, TKey>, never>> : never; export type LabelledAria = OneOf<{ title: string; "aria-label": string; "aria-labelledby": string; }>; export {};