melt
Version:
The next generation of Melt UI. Built for Svelte 5.
26 lines (25 loc) • 1.32 kB
TypeScript
import type { HTMLAttributes } from "svelte/elements";
type TupleTypes<T> = {
[P in keyof T]: T[P];
} extends {
[key: number]: infer V;
} ? NullToObject<V> : never;
type NullToObject<T> = T extends null | undefined ? object : T;
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
/**
* Executes an array of callback functions with the same arguments.
* @template T The types of the arguments that the callback functions take.
* @param callbacks array of callback functions to execute.
* @returns A new function that executes all of the original callback functions with the same arguments.
*/
export declare function executeCallbacks<T extends unknown[]>(...callbacks: T): (...args: unknown[]) => void;
/**
* Given a list of attribute objects, merges them into a single object.
* - Automatically composes event handlers (e.g. `onclick`, `oninput`, etc.)
* - Chains regular functions with the same name so they are called in order
* - Handles a bug with Svelte where setting the `hidden` attribute to `false` doesn't remove it
* - Merges style attributes
* - Overrides other values with the last one
*/
export declare function mergeAttrs<T extends HTMLAttributes<HTMLElement>[]>(...args: T): UnionToIntersection<TupleTypes<T>>;
export {};