UNPKG

@synergy-design-system/components

Version:

This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define

43 lines (42 loc) 1.45 kB
import { type ElementPart, noChange, nothing } from 'lit'; import { AsyncDirective, type DirectiveParameters, type Part } from 'lit/async-directive.js'; type Callbacks = { start: () => void; end: () => void; }; /** * A directive that determines,if a HTMLButtonElement is long pressed or only clicked. * Depending on the state it executes the callback once or repeating. * * Usage: * * <button * ${longPress({ start: () => this.handleStepUp(), end: () => this.handleChange()})} * > * my button * </button> */ declare class LongPressDirective extends AsyncDirective { host: HTMLButtonElement; observer: MutationObserver; callbacks: Callbacks; interval: NodeJS.Timeout; timeout: NodeJS.Timeout; constructor(part: Part); render(_callback: Callbacks): typeof nothing; update(part: ElementPart, [callbacks]: DirectiveParameters<this>): typeof noChange; reconnected(): void; protected disconnected(): void; private handlePointerDown; /** * Start spinning on long press clicks otherwise handle as single click event */ private spinOnLongPressCallback; private handlePointerUp; /** * Stop the spinning and clean up all timer and observer */ private stopSpinningAndCleanUp; } export declare const longPress: (_callback: Callbacks) => import("lit/async-directive.js").DirectiveResult<typeof LongPressDirective>; export type { LongPressDirective };