import type { Snippet } from "svelte"; import type * as CSS from "csstype"; import type { ReadableBox, WritableBox } from "./box/box.svelte.js"; export type FunctionArgs = (...args: Args) => Return; export type Getter = () => T; export type MaybeGetter = T | Getter; export type MaybeBoxOrGetter = T | Getter | ReadableBox; export type BoxOrGetter = Getter | ReadableBox; export type Box = ReadableBox | WritableBox; export type Expand = T extends infer U ? { [K in keyof U]: U[K]; } : never; /** * Given a Record type T, returns a type that represents the same type, but with * all values wrapped in a `ReadableBox`. */ export type ReadableBoxedValues = { [K in keyof T]: ReadableBox; }; /** * Given a Record type T, returns a type that represents the same type, but with * all values wrapped in a `WritableBox`. */ export type WritableBoxedValues = { [K in keyof T]: WritableBox; }; export type WithChild< /** * The props that the component accepts. */ Props extends Record = {}, /** * The props that are passed to the `child` and `children` snippets. The `ElementProps` are * merged with these props for the `child` snippet. */ SnippetProps extends Record = { _default: never; }, /** * The underlying DOM element being rendered. You can bind to this prop to * programatically interact with the element. */ Ref = HTMLElement> = Omit & { child?: SnippetProps extends { _default: never; } ? Snippet<[{ props: Record; }]> : Snippet<[SnippetProps & { props: Record; }]>; children?: SnippetProps extends { _default: never; } ? Snippet : Snippet<[SnippetProps]>; style?: string | null | undefined; ref?: Ref | null | undefined; }; export type WithChildren = Props & { children?: Snippet | undefined; }; /** * Constructs a new type by omitting properties from type * 'T' that exist in type 'U'. * * @template T - The base object type from which properties will be omitted. * @template U - The object type whose properties will be omitted from 'T'. * @example * type Result = Without<{ a: number; b: string; }, { b: string; }>; * // Result type will be { a: number; } */ export type Without = Omit; export type WithRefProps = T & ReadableBoxedValues<{ id: string; }> & WritableBoxedValues<{ ref: HTMLElement | null; }>; export type WithoutChild = T extends { child?: any; } ? Omit : T; export type WithoutChildrenOrChild = WithoutChildren>; export type WithoutChildren = T extends { children?: any; } ? Omit : T; export type WithElementRef = T & { ref?: U | null; }; export type StyleProperties = CSS.Properties & { [str: `--${string}`]: any; }; export type AnyFn = (...args: any[]) => any;