@melt-ui/svelte
Version:

50 lines (49 loc) • 2.65 kB
TypeScript
/// <reference types="svelte" />
import { noop } from '../../internal/helpers/index.js';
import type { MeltActionReturn } from '../../internal/types.js';
import type { ToastEvents } from './events.js';
import type { AddToastProps, CreateToasterProps, Toast } from './types.js';
export declare function createToaster<T = object>(props?: CreateToasterProps): {
elements: {
content: import("../../internal/helpers/index.js").MeltElement<import("svelte/store").Writable<Map<string, Toast<T>>>, (node: HTMLElement) => MeltActionReturn<ToastEvents['content']>, ($toasts: Map<string, Toast<T>>) => (id: string) => {
readonly id: string;
readonly role: "alert";
readonly 'aria-describedby': string;
readonly 'aria-labelledby': string;
readonly 'aria-live': "assertive" | "polite";
readonly tabindex: -1;
} | null, string>;
title: import("../../internal/helpers/index.js").MeltElement<import("svelte/store").Writable<Map<string, Toast<T>>>, import("svelte/action").Action<any, any, Record<never, any>>, ($toasts: Map<string, Toast<T>>) => (id: string) => {
readonly id: string;
} | null, string>;
description: import("../../internal/helpers/index.js").MeltElement<import("svelte/store").Writable<Map<string, Toast<T>>>, import("svelte/action").Action<any, any, Record<never, any>>, ($toasts: Map<string, Toast<T>>) => (id: string) => {
readonly id: string;
} | null, string>;
close: import("../../internal/helpers/index.js").MeltElement<import("svelte/store").Stores | undefined, (node: HTMLElement) => MeltActionReturn<ToastEvents['close']>, () => (id: string) => {
readonly type: "button";
readonly 'data-id': string;
}, string>;
};
states: {
toasts: import("svelte/store").Readable<Toast<T>[]>;
};
helpers: {
addToast: (props: AddToastProps<T>) => Toast<T>;
removeToast: (id: string) => void;
updateToast: (id: string, data: T) => void;
};
actions: {
portal: <Node_1 extends HTMLElement>(el: Node_1, target?: import("../../internal/actions/index.js").PortalConfig) => {
destroy: typeof noop;
update?: undefined;
} | {
update: (newTarget?: import("../../internal/actions/index.js").PortalConfig) => Promise<void>;
destroy: () => void;
};
};
options: import("../../internal/helpers/index.js").ToWritableStores<{
closeDelay: number;
type: "background" | "foreground";
hover: "pause" | "pause-all" | null;
}>;
};