@dvcol/neo-svelte
Version:
Neomorphic ui library for svelte 5
84 lines (83 loc) • 2.4 kB
TypeScript
import type { Snippet } from 'svelte';
import type { HTMLButtonAttributes } from 'svelte/elements';
import type { NeoDividerProps } from '../../divider/neo-divider.model.js';
import type { NeoMovableOutside } from '../dialog/use-movable.svelte.js';
import type { HTMLNeoBaseElement } from '../../utils/html-element.utils.js';
export declare const NeoHandlePlacement: {
readonly Top: "top";
readonly Right: "right";
readonly Bottom: "bottom";
readonly Left: "left";
};
export type NeoHandlePlacements = (typeof NeoHandlePlacement)[keyof typeof NeoHandlePlacement];
export interface NeoHandleContext {
enabled: boolean;
placements: NeoHandlePlacements[];
axis?: 'x' | 'y';
outside?: NeoMovableOutside;
}
export type NeoHandleProps = {
/**
* children around which to render the handles.
*/
children?: Snippet<[NeoHandleContext]>;
/**
* Custom snippet for the handle content.
*/
handle?: Snippet<[NeoHandlePlacements]>;
/**
* Optional references to the handle buttons.
*/
refs?: Partial<Record<NeoHandlePlacements, HTMLButtonElement>>;
/**
* Whether to render the handles.
*/
enabled?: boolean;
/**
* Whether the handle content should be visible
*/
visible?: boolean;
/**
* The allowed axis for dragging the element.
*/
axis?: 'x' | 'y';
/**
* Whether the element is currently outside the viewport.
*
* @default false
*/
outside?: NeoMovableOutside;
/**
* Placement of the handle (or array of visible handles).
*
* @default 'top'
*/
placement?: NeoHandlePlacements | Partial<Record<NeoHandlePlacements, boolean>>;
/**
* Whether the handle should be inside or outside the element.
*
* @default inside
*/
position?: 'inside' | 'outside';
/**
* Element elevation (used when calculating the handle offset when outside).
*
* @default 0
* @see outside
*/
elevation?: number;
/**
* Minimum handle size (in px).
*
* @default 16
*/
minSize?: number;
/**
* Optional properties to pass to the default drag handle (divider).
*/
dividerProps?: NeoDividerProps;
/**
* Optional properties to pass to the handle group wrapper.
*/
groupProps?: HTMLNeoBaseElement;
} & Partial<HTMLButtonAttributes>;