//#region src/tiny-emitter.d.ts /** * @fileoverview copy of `tiny-emitter` on npm, but converted to ESM */ declare class TinyEmitter { handlers?: Record; on(event: string, callback: Function, ctx?: any): this; once(event: string, callback: Function, ctx?: any): this; emit(event: string, ...args: any[]): this; off(event: string, callback?: Function): this; } //#endregion //#region src/grid-lanes-item.d.ts declare class GridLanesItem { #private; id: string; defaultOrder: number; element: HTMLElement; isVisible: boolean; get isHidden(): boolean; constructor(element: HTMLElement, id: string, defaultOrder: number); init(): void; show(): void; hide(): void; dispose(): void; } //#endregion //#region src/core/types.d.ts interface JqueryLike { [index: number]: HTMLElement; length: number; jquery: string; } interface SortableElement { element: HTMLElement; } type ElementOption = Element | HTMLElement | string | JqueryLike; type FilterModeOptions = "any" | "all"; type FilterFunction = (this: HTMLElement, element: HTMLElement, shuffle: Instance) => boolean; type FilterArg = string | string[] | FilterFunction; interface SortOptions { reverse?: boolean; by?: ((element: HTMLElement) => any) | null; compare?: ((itemA: Item, itemB: Item) => number) | null; randomize?: boolean; key?: keyof Item; } //#endregion //#region src/grid-lanes.d.ts interface GridLanesOptions { /** * e.g. '.picture-item'. */ itemSelector?: string; /** * Initial filter group. */ group?: string | string[]; /** * Affects using an array with filter. e.g. `filter(['one', 'two'])`. With "any", * the element passes the test if any of its groups are in the array. With "all", * the element only passes if all groups are in the array. */ filterMode?: FilterModeOptions; /** * Shuffle can be initialized with a sort object. It is the same object * given to the sort method. */ initialSort?: SortOptions | null; /** * Transition/animation speed (milliseconds). */ speed?: number; /** * CSS easing function to use. */ easing?: string; /** * Transition delay offset for each item in milliseconds. */ staggerAmount?: number; /** * Maximum stagger delay in milliseconds. */ staggerAmountMax?: number; } type GridLanesSortOptions = SortOptions; type GridLanesFilterFunction = FilterFunction; type GridLanesFilterArg = FilterArg; interface ResolvedGridLanesOptions { itemSelector: string; group: string | string[]; filterMode: FilterModeOptions; initialSort: SortOptions | null; speed: number; easing: string; staggerAmount: number; staggerAmountMax: number; } declare class GridLanes extends TinyEmitter { #private; element: HTMLElement; options: ResolvedGridLanesOptions; items: Map; sortedItems: GridLanesItem[]; group: GridLanesFilterArg; lastFilter: GridLanesFilterArg; lastSort: GridLanesSortOptions | null; id: string; isEnabled: boolean; isInitialized: boolean; isTransitioning: boolean; /** * Categorize and sort a grid of items using native grid-lanes behavior. * * @param element An element which is the parent container for the grid items. * @param options Options object. * @constructor */ constructor(element: ElementOption, options?: Partial); /** * The magic. This is what makes the plugin 'shuffle'. * @param category Category to filter by. Can be a function, string, or array of strings. * @param sortOptions A sort object which can sort the visible set. */ filter(category?: GridLanesFilterArg, sortOptions?: GridLanesSortOptions | null): void; /** * Gets the visible elements, sorts them, and commits a re-render. * @param sortOptions The options object to pass to `sorter`. */ sort(sortOptions?: GridLanesSortOptions | null): void; /** * Recalculate filter/sort state and re-render items. */ update({ force }?: { force?: boolean; }): void; /** * Keep for API compatibility and layout lifecycle events. * Browser layout is native, so this method only emits `shuffle:layout`. */ layout(): void; /** * Add new items to the container and reconcile them with the current state. * @param newItems Collection of new items. */ add(newItems: HTMLElement[]): void; /** * Disables filtering, sorting, and update/layout calls. */ disable(): void; /** * Re-enables filtering, sorting, and updates. * @param isUpdateLayout Whether to commit the current state immediately. */ enable(isUpdateLayout?: boolean): void; /** * Remove items from the current collection. * @param elements Elements to remove. */ remove(elements: HTMLElement[]): void; /** * Retrieve a grid-lanes item by its element. * @param element Element to look for. * @return A grid-lanes item or undefined if it's not found. */ getItemByElement(element: HTMLElement): GridLanesItem | undefined; /** * Re-query items and preserve metadata for surviving elements. */ resetItems(): void; /** * Destroys GridLanes and removes item state and transition properties. */ destroy(): void; } //#endregion export { type GridLanesFilterArg, type GridLanesFilterFunction, type GridLanesOptions, type GridLanesSortOptions, GridLanes as default };