UNPKG

@dvcol/neo-svelte

Version:

Neomorphic ui library for svelte 5

48 lines (47 loc) 2 kB
import type { NeoProgressContext, NeoProgressStart } from './neo-progress.model.js'; export interface NeoProgressServiceOptions { /** * Delay in milliseconds before the progress bar starts. * This is useful to debounce multiple calls to the progress bar. */ delay?: number; /** * Function to generate a unique ID for the progress bar. * If not provided, a UUID will be generated. */ uuid?: () => string; } /** * Queuing service to keep track of concurrent call to progress bar */ export declare class NeoProgressService { #private; get context(): NeoProgressContext; get value(): number | undefined; get buffer(): number | undefined; get status(): import("./neo-progress.model.js").NeoProgressStatuses | undefined; get active(): Set<string>; constructor(context: NeoProgressContext, options?: NeoProgressServiceOptions); /** * Synchronizes the progress state working with the current active IDs set. */ sync(): Set<string> | undefined; /** * Starts a new progress bar with the given options. * If an ID is provided, it will be used to track the progress bar. * If no ID is provided, a new UUID will be generated. * If a delay is provided, the progress bar will start after the specified delay. */ start(opts?: NeoProgressStart, { id, delay }?: { id?: string; delay?: number; }): string | undefined; cancel(id?: string, force?: boolean): string | undefined; complete(id?: string, force?: boolean): string | undefined; error(id?: string, force?: boolean): string | undefined; success(id?: string, force?: boolean): string | undefined; warning(id?: string, force?: boolean): string | undefined; } export declare function getProgressContext(): NeoProgressContext; export declare function setProgressContext(context: NeoProgressContext): NeoProgressContext | undefined; export declare function useNeoProgressService(): NeoProgressService;