/** * Sortable Component — reorder a container's element children, or move them * into another ty-sortable of the same `group`, by pointer (mouse, touch, * pen), keyboard, or the move() method. * * Controlled: ty-sortable never moves, inserts or removes light-DOM nodes. * During a drag it draws a ghost and a drop indicator in the top layer; on * drop it fires one `ty-sortable-change` on the destination and the app, * framework or server renders the new order. Until that render lands the * result is held on screen ("hold until morph"), so a server round trip * doesn't snap the item back. A render that doesn't change the order (a * rejected move) snaps it back. */ /** Where an item is (from) or will be (to). prev/next exclude the item itself. */ export interface TySortablePos { list: string | null; index: number; prev: string | null; next: string | null; } export interface TySortableValue { key: string | null; group: string | null; source: 'pointer' | 'keyboard' | 'api'; from: TySortablePos; to: TySortablePos; /** Resulting key order of every list the move touches, by container id. */ order: Record; } /** `ty-sortable-change`, on the destination list. */ export interface TySortableChangeDetail { value: TySortableValue; item: HTMLElement; fromContainer: TySortable; toContainer: TySortable; } /** What a drag knows before it has a destination. */ export interface TySortableDragValue { key: string | null; group: string | null; source: 'pointer' | 'keyboard' | 'api'; from: TySortablePos; } /** `ty-sortable-start`, on the source list. */ export interface TySortableStartDetail { value: TySortableDragValue; item: HTMLElement; } export type TySortableCancelReason = 'escape' | 'spill' | 'blocked' | 'pointercancel' | 'gone' | 'disabled' | 'blur'; /** `ty-sortable-cancel`, on the source list. */ export interface TySortableCancelDetail { value: TySortableDragValue; item: HTMLElement; reason: TySortableCancelReason; } /** * accepted: rendered where it was dropped. rejected: the order didn't * change (preventDefault, or a request ended without a render). * reconciled: rendered somewhere else, or removed. unknown: nothing * answered before hold-timeout. */ export type TySortableOutcome = 'accepted' | 'rejected' | 'reconciled' | 'unknown'; /** `ty-sortable-settle`, on the destination list, when a hold ends. */ export interface TySortableSettleDetail { value: TySortableValue; outcome: TySortableOutcome; } export interface TySortableDropContext { item: HTMLElement; key: string | null; from: TySortable; to: TySortable; index: number; } export interface TySortableAttributes { group?: string; axis?: 'vertical' | 'horizontal'; handle?: string; accepts?: string; disabled?: boolean; 'key-attr'?: string; 'hold-timeout'?: number; label?: string; 'drop-line'?: boolean; flash?: boolean; } /** Announcement templates: {item}, {position}, {total}, {list}. */ export interface TySortableStrings { pickedUp: string; moved: string; blocked: string; dropped: string; rejected: string; reconciled: string; removed: string; unknown: string; cancelled: string; pending: string; } export declare class TySortable extends HTMLElement { static get observedAttributes(): string[]; /** @internal */ _states: CustomStateSet | null; private _live; private _press; private _canDrop; private _labels; private _childObserver; constructor(); get group(): string | null; set group(v: string | null); get axis(): 'vertical' | 'horizontal'; set axis(v: 'vertical' | 'horizontal'); get disabled(): boolean; set disabled(v: boolean); /** A drop line marks the slot and nothing moves. Off: siblings move aside while dragging. */ get dropLine(): boolean; set dropLine(v: boolean); /** Outline the item briefly where it lands. */ get flash(): boolean; set flash(v: boolean); get handleSelector(): string; get accepts(): string | null; set accepts(v: string | null); get holdTimeout(): number; /** Extra drop rule, per candidate slot: return false to block it. */ get canDrop(): ((ctx: TySortableDropContext) => boolean) | null; set canDrop(fn: ((ctx: TySortableDropContext) => boolean) | null); /** Announcement overrides (i18n). */ get labels(): Partial; set labels(v: Partial); /** The items, in order: element children except