import type { Snippet } from "svelte"; import type { attachRef, Box, ReadableBoxedValues, WritableBoxedValues } from "svelte-toolbelt"; import type { StyleProperties } from "../shared/index.js"; export type OnChangeFn = (value: T) => void; export type ElementRef = Box; 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 * programmatically 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?: StyleProperties | string | null | undefined; ref?: Ref | null | undefined; }; export type WithChildNoChildrenSnippetProps< /** * 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 * programmatically interact with the element. */ Ref = HTMLElement> = Omit & { child?: SnippetProps extends { _default: never; } ? Snippet<[{ props: Record; }]> : Snippet<[SnippetProps & { props: Record; }]>; children?: Snippet; style?: StyleProperties | 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 Arrayable = T[] | T; export type Fn = () => void; export type AnyFn = (...args: any[]) => any; export type WithRefOpts = T & ReadableBoxedValues<{ id: string; }> & WritableBoxedValues<{ ref: HTMLElement | null; }>; export type BitsEvent = T & { currentTarget: U; }; export type BitsPointerEvent = BitsEvent; export type BitsKeyboardEvent = BitsEvent; export type BitsMouseEvent = BitsEvent; export type BitsFocusEvent = BitsEvent; export type BitsInputEvent = BitsEvent; export type RefAttachment = ReturnType>;