UNPKG

@lyonbot/interactive-blocks

Version:

Make interactive selectable, drag-and-drop, copy-and-paste ready, Block and Slot components easily! Works with Vue, React and any MV* framework.

45 lines (44 loc) 1.87 kB
/** * make a throttled function that actually executes with the last given arguments. */ export declare function throttle<T extends (...args: any) => void>(fn: T, wait: number): T & { cancel(): void; flush(): void; }; /** * wrap a function. in the following calls, if `input` didn't change, `fn` will not execute */ export declare function wrapAsTrigger<T>(fn: (input: T, lastInput?: T) => void, isEqual?: (a: T, b: T) => boolean): (input: T) => void; /** * extract and remove items from the array safely. * * this will mutate `arr` the input array. * * @returns removed items in `indexes` order */ export declare function removeItems<T>(arr: T[], indexes: number[]): T[]; /** * move items inside an array safely. * * this will mutate `arr` the input array. */ export declare function moveItemsInArray(arr: any[], fromIndexes: number[], toIndex: number): void; /** * move items between two arrays safely. * * this will mutate `fromArr` and `toArr` * * @param fromArr * @param fromIndexes * @param toArr * @param toIndex */ export declare function moveItemsBetweenArrays(fromArr: any[], fromIndexes: number[], toArr: any[], toIndex: number): void; export declare type FirstParameter<T> = T extends (arg: infer R) => any ? R : never; export declare type StyledEventLUT<T, S extends EventKeyStyle> = { [K in keyof T as ToStyledEventKey<S, K>]: T[K]; }; export declare type EventKeyStyle = "react" | "vue" | "lowercase" | "camelCase" | undefined | null; declare type ToStyledEventKey<S extends EventKeyStyle, KEY> = KEY extends string ? (S extends "react" ? `on${Capitalize<KEY>}` : S extends "vue" | "lowercase" | "" | undefined | null ? Lowercase<KEY> : KEY) : KEY; export declare function getStyledEventHandlersLUT<T, S extends EventKeyStyle>(o: T, style: S): StyledEventLUT<T, S>; export {};