@dfinity/gix-components
Version:
A UI kit developed by the GIX team
25 lines (24 loc) • 1.5 kB
TypeScript
/**
* In Svelte 5, event modifiers are no longer part of the framework.
* This module contains wrapper functions that replicate modifier behavior for Svelte 5.
*
* @see {@link https://svelte.dev/docs/svelte/v5-migration-guide#Event-changes-Event-modifiers}
*/
import type { OnEventCallback } from "../types/event-modifiers";
import type { MouseEventHandler } from "svelte/elements";
/**
* A wrapper function to stop event propagation of a mouse event before executing a callback function.
*
* @param {OnEventCallback<T extends EventTarget>} fn - The function to be executed after stopping the event propagation. It can be a synchronous or asynchronous function.
*
* @returns {MouseEventHandler<T extends EventTarget>} - A function that takes an event and stop its propagation, before executing the provided function.
*/
export declare const stopPropagation: <T extends EventTarget>(fn: OnEventCallback<T>) => MouseEventHandler<T>;
/**
* A wrapper function to prevent the default action of a mouse event before executing a callback function.
*
* @param {OnEventCallback<T extends EventTarget>} fn - The function to be executed after preventing the default action. It can be a synchronous or asynchronous function.
*
* @returns {MouseEventHandler<T extends EventTarget>} - A function that takes an event and prevents its default action, before executing the provided function.
*/
export declare const preventDefault: <T extends EventTarget>(fn: OnEventCallback<T>) => MouseEventHandler<T>;