@dnd-block-tree/vanilla 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/index.d.mts +314 -0
- package/dist/index.d.ts +314 -0
- package/dist/index.js +1034 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +888 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @dnd-block-tree/vanilla
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@dnd-block-tree/vanilla)
|
|
4
|
+
|
|
5
|
+
Vanilla JS/TS adapter for [dnd-block-tree](https://github.com/thesandybridge/dnd-block-tree) — zero framework dependencies. A two-layer architecture with a headless controller for state management and an optional default renderer for automatic DOM updates.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @dnd-block-tree/vanilla
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Only dependency is `@dnd-block-tree/core`. No framework peer dependencies required.
|
|
14
|
+
|
|
15
|
+
## What's Included
|
|
16
|
+
|
|
17
|
+
- **Headless Controller** — `createBlockTreeController` manages all tree state, drag logic, sensors, and events without touching the DOM
|
|
18
|
+
- **Default Renderer** — `createDefaultRenderer` subscribes to controller events and automatically builds/updates the DOM
|
|
19
|
+
- **Sensors** — pointer (mouse), touch (long-press + haptic), and keyboard navigation
|
|
20
|
+
- **Collision Bridge** — DOM rect measurement and collision detection against snapshotted zones
|
|
21
|
+
- **History** — opt-in undo/redo via `controller.enableHistory()`
|
|
22
|
+
- **Layout Animation** — FLIP-based position animation for reorders
|
|
23
|
+
- **Virtual Scroller** — windowed rendering for large trees
|
|
24
|
+
|
|
25
|
+
## Quick Example
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
createBlockTreeController,
|
|
30
|
+
createDefaultRenderer,
|
|
31
|
+
createElement,
|
|
32
|
+
type BaseBlock,
|
|
33
|
+
} from '@dnd-block-tree/vanilla'
|
|
34
|
+
|
|
35
|
+
interface MyBlock extends BaseBlock {
|
|
36
|
+
type: 'folder' | 'file'
|
|
37
|
+
label: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const controller = createBlockTreeController<MyBlock>({
|
|
41
|
+
initialBlocks: [
|
|
42
|
+
{ id: '1', type: 'folder', label: 'Documents', parentId: null, order: 0 },
|
|
43
|
+
{ id: '2', type: 'file', label: 'readme.txt', parentId: '1', order: 0 },
|
|
44
|
+
],
|
|
45
|
+
containerTypes: ['folder'],
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const container = document.getElementById('tree')!
|
|
49
|
+
|
|
50
|
+
const renderer = createDefaultRenderer(controller, {
|
|
51
|
+
container,
|
|
52
|
+
renderBlock: (block, ctx) => {
|
|
53
|
+
const el = createElement('div', { class: 'block' })
|
|
54
|
+
el.textContent = block.label
|
|
55
|
+
if (ctx.children) el.appendChild(ctx.children)
|
|
56
|
+
return el
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
controller.mount(container)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Data Attributes
|
|
64
|
+
|
|
65
|
+
The renderer sets data attributes for CSS styling:
|
|
66
|
+
|
|
67
|
+
| Attribute | Element | Description |
|
|
68
|
+
|-----------|---------|-------------|
|
|
69
|
+
| `data-block-id` | Block | Block's unique ID |
|
|
70
|
+
| `data-block-type` | Block | Block's type string |
|
|
71
|
+
| `data-depth` | Block | Nesting depth (0-based) |
|
|
72
|
+
| `data-dragging` | Block | Present when being dragged |
|
|
73
|
+
| `data-selected` | Block | Present when selected |
|
|
74
|
+
| `data-zone-id` | Drop zone | Zone identifier |
|
|
75
|
+
| `data-zone-active` | Drop zone | Present on active hover zone |
|
|
76
|
+
| `data-drag-overlay` | Overlay | Floating drag ghost |
|
|
77
|
+
| `data-dnd-ghost` | Ghost | Semi-transparent preview |
|
|
78
|
+
|
|
79
|
+
## Documentation
|
|
80
|
+
|
|
81
|
+
Full docs at **[blocktree.sandybridge.io](https://blocktree.sandybridge.io/docs)**.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { BaseBlock, BlockRendererProps as BlockRendererProps$1, BlockRenderers as BlockRenderers$1, OrderingStrategy, CanDragFn, CanDropFn, IdGeneratorFn, SensorConfig, BlockTreeCallbacks, ContainerRendererProps as ContainerRendererProps$1, InternalRenderers as InternalRenderers$1, RendererPropsFor as RendererPropsFor$1, BlockTreeInstance, Rect, CollisionCandidate, CoreCollisionDetection } from '@dnd-block-tree/core';
|
|
2
|
+
export { AnimationConfig, AutoExpandConfig, BaseBlock, BlockAction, BlockAddEvent, BlockDeleteEvent, BlockIndex, BlockMoveEvent, BlockPosition, BlockStateContextValue, BlockTreeCallbacks, BlockTreeConfig, BlockTreeCustomization, BlockTreeEvents, BlockTreeInstance, BlockTreeOptions, CanDragFn, CanDropFn, CollisionCandidate, CollisionResult, CoreCollisionDetection, DragEndEvent, DragMoveEvent, DragStartEvent, DropZoneConfig, DropZoneType, EventEmitter, ExpandAction, ExpandChangeEvent, HistoryAction, HistoryState, HoverChangeEvent, IdGeneratorFn, MoveOperation, NestedBlock, OrderingStrategy, Rect, SensorConfig, SnapshotRectsRef, TreeValidationResult, blockReducer, buildOrderedBlocks, cloneMap, cloneParentMap, closestCenterCollision, compareFractionalKeys, computeNormalizedIndex, createBlockTree, createStickyCollision, debounce, deleteBlockAndDescendants, expandReducer, extractBlockId, extractUUID, flatToNested, generateId, generateInitialKeys, generateKeyBetween, generateNKeysBetween, getBlockDepth, getDescendantIds, getDropZoneType, getSubtreeDepth, historyReducer, initFractionalOrder, nestedToFlat, reparentBlockIndex, reparentMultipleBlocks, validateBlockTree, weightedVerticalCollision } from '@dnd-block-tree/core';
|
|
3
|
+
|
|
4
|
+
type BlockRendererProps<T extends BaseBlock = BaseBlock> = BlockRendererProps$1<T, HTMLElement>;
|
|
5
|
+
type ContainerRendererProps<T extends BaseBlock = BaseBlock> = ContainerRendererProps$1<T, HTMLElement>;
|
|
6
|
+
type RendererPropsFor<T extends BaseBlock, K extends T['type'], C extends readonly string[]> = RendererPropsFor$1<T, K, C, HTMLElement>;
|
|
7
|
+
type BlockRenderers<T extends BaseBlock = BaseBlock, C extends readonly string[] = readonly string[]> = BlockRenderers$1<T, C, HTMLElement>;
|
|
8
|
+
type InternalRenderers<T extends BaseBlock = BaseBlock> = InternalRenderers$1<T, HTMLElement>;
|
|
9
|
+
/** Controller configuration */
|
|
10
|
+
interface BlockTreeControllerOptions<T extends BaseBlock = BaseBlock> {
|
|
11
|
+
initialBlocks?: T[];
|
|
12
|
+
containerTypes?: readonly string[];
|
|
13
|
+
orderingStrategy?: OrderingStrategy;
|
|
14
|
+
maxDepth?: number;
|
|
15
|
+
previewDebounce?: number;
|
|
16
|
+
canDrag?: CanDragFn<T>;
|
|
17
|
+
canDrop?: CanDropFn<T>;
|
|
18
|
+
idGenerator?: IdGeneratorFn;
|
|
19
|
+
initialExpanded?: string[] | 'all' | 'none';
|
|
20
|
+
sensors?: VanillaSensorConfig;
|
|
21
|
+
onChange?: (blocks: T[]) => void;
|
|
22
|
+
callbacks?: Partial<BlockTreeCallbacks<T>>;
|
|
23
|
+
}
|
|
24
|
+
/** Vanilla sensor configuration */
|
|
25
|
+
interface VanillaSensorConfig extends SensorConfig {
|
|
26
|
+
/** Enable pointer sensor (default: true) */
|
|
27
|
+
pointer?: boolean;
|
|
28
|
+
/** Enable touch sensor (default: true) */
|
|
29
|
+
touch?: boolean;
|
|
30
|
+
/** Enable keyboard sensor (default: false) */
|
|
31
|
+
keyboard?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Drag state exposed to consumers */
|
|
34
|
+
interface DragState {
|
|
35
|
+
isDragging: boolean;
|
|
36
|
+
activeId: string | null;
|
|
37
|
+
hoverZone: string | null;
|
|
38
|
+
}
|
|
39
|
+
/** Controller event types */
|
|
40
|
+
interface ControllerEvents<T extends BaseBlock = BaseBlock> {
|
|
41
|
+
render: (blocks: T[], expandedMap: Record<string, boolean>) => void;
|
|
42
|
+
'drag:statechange': (state: DragState) => void;
|
|
43
|
+
'selection:change': (selectedIds: Set<string>) => void;
|
|
44
|
+
}
|
|
45
|
+
/** Render context passed to renderBlock in DefaultRenderer */
|
|
46
|
+
interface RenderBlockContext {
|
|
47
|
+
children: HTMLElement | null;
|
|
48
|
+
depth: number;
|
|
49
|
+
isExpanded: boolean;
|
|
50
|
+
isDragging: boolean;
|
|
51
|
+
isSelected: boolean;
|
|
52
|
+
onToggleExpand: (() => void) | null;
|
|
53
|
+
}
|
|
54
|
+
/** DefaultRenderer options */
|
|
55
|
+
interface DefaultRendererOptions<T extends BaseBlock = BaseBlock> {
|
|
56
|
+
container: HTMLElement;
|
|
57
|
+
renderBlock: (block: T, ctx: RenderBlockContext) => HTMLElement;
|
|
58
|
+
dropZoneHeight?: number;
|
|
59
|
+
animateExpand?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Cleanup function */
|
|
62
|
+
type Unsubscribe = () => void;
|
|
63
|
+
/** Disposable resource */
|
|
64
|
+
interface Disposable {
|
|
65
|
+
dispose(): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface BlockTreeController<T extends BaseBlock = BaseBlock> {
|
|
69
|
+
mount(container: HTMLElement): void;
|
|
70
|
+
unmount(): void;
|
|
71
|
+
registerDraggable(id: string, element: HTMLElement): Unsubscribe;
|
|
72
|
+
registerDropZone(id: string, element: HTMLElement): Unsubscribe;
|
|
73
|
+
getDragState(): DragState;
|
|
74
|
+
getBlocks(): T[];
|
|
75
|
+
getEffectiveBlocks(): T[];
|
|
76
|
+
getExpandedMap(): Record<string, boolean>;
|
|
77
|
+
getBlock(id: string): T | undefined;
|
|
78
|
+
toggleExpand(id: string): void;
|
|
79
|
+
setExpandAll(expanded: boolean): void;
|
|
80
|
+
addBlock(type: T['type'], parentId?: string | null): T;
|
|
81
|
+
deleteBlock(id: string): void;
|
|
82
|
+
setBlocks(blocks: T[]): void;
|
|
83
|
+
select(id: string, mode: 'single' | 'toggle' | 'range'): void;
|
|
84
|
+
clearSelection(): void;
|
|
85
|
+
getSelectedIds(): Set<string>;
|
|
86
|
+
enableHistory(maxSteps?: number): void;
|
|
87
|
+
undo(): T[] | null;
|
|
88
|
+
redo(): T[] | null;
|
|
89
|
+
canUndo(): boolean;
|
|
90
|
+
canRedo(): boolean;
|
|
91
|
+
on<K extends keyof ControllerEvents<T>>(event: K, handler: ControllerEvents<T>[K]): Unsubscribe;
|
|
92
|
+
setOverlayRenderer(render: (block: T) => HTMLElement): void;
|
|
93
|
+
getTree(): BlockTreeInstance<T>;
|
|
94
|
+
destroy(): void;
|
|
95
|
+
}
|
|
96
|
+
declare function createBlockTreeController<T extends BaseBlock>(options?: BlockTreeControllerOptions<T>): BlockTreeController<T>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Measure DOM rects for all registered drop zones and build CollisionCandidate[].
|
|
100
|
+
* Snapshots rects once at drag start to prevent feedback loops.
|
|
101
|
+
*/
|
|
102
|
+
declare function measureDropZoneRects(zones: Map<string, HTMLElement>): Map<string, Rect>;
|
|
103
|
+
/** Build collision candidates from a snapshot rect map */
|
|
104
|
+
declare function buildCandidates(snapshotRects: Map<string, Rect>): CollisionCandidate[];
|
|
105
|
+
/** Build a pointer rect from client coordinates */
|
|
106
|
+
declare function pointerToRect(x: number, y: number): Rect;
|
|
107
|
+
/** Run collision detection with snapshotted rects and pointer position */
|
|
108
|
+
declare function detectCollision(detector: CoreCollisionDetection, snapshotRects: Map<string, Rect>, pointerX: number, pointerY: number): string | null;
|
|
109
|
+
|
|
110
|
+
interface DragOverlayOptions {
|
|
111
|
+
/** Custom renderer for the overlay content */
|
|
112
|
+
renderOverlay?: (block: BaseBlock) => HTMLElement;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Floating drag overlay that follows the pointer during drag.
|
|
116
|
+
* Creates and manages a fixed-position overlay element.
|
|
117
|
+
*/
|
|
118
|
+
declare class DragOverlay {
|
|
119
|
+
private overlay;
|
|
120
|
+
private options;
|
|
121
|
+
constructor(options?: DragOverlayOptions);
|
|
122
|
+
show(block: BaseBlock, sourceEl: HTMLElement, x: number, y: number): void;
|
|
123
|
+
move(x: number, y: number): void;
|
|
124
|
+
hide(): void;
|
|
125
|
+
private setPosition;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface BlockHistoryOptions {
|
|
129
|
+
maxSteps?: number;
|
|
130
|
+
}
|
|
131
|
+
interface BlockHistory<T extends BaseBlock> {
|
|
132
|
+
push(blocks: T[]): void;
|
|
133
|
+
undo(): T[] | null;
|
|
134
|
+
redo(): T[] | null;
|
|
135
|
+
canUndo(): boolean;
|
|
136
|
+
canRedo(): boolean;
|
|
137
|
+
getPresent(): T[];
|
|
138
|
+
clear(blocks: T[]): void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Imperative undo/redo history wrapping core's historyReducer.
|
|
142
|
+
*/
|
|
143
|
+
declare function createBlockHistory<T extends BaseBlock>(initialBlocks: T[], options?: BlockHistoryOptions): BlockHistory<T>;
|
|
144
|
+
|
|
145
|
+
interface LayoutAnimationOptions {
|
|
146
|
+
duration?: number;
|
|
147
|
+
easing?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* FLIP animation for block layout changes.
|
|
151
|
+
* Records element positions before a DOM update, then animates from old to new.
|
|
152
|
+
*/
|
|
153
|
+
declare class LayoutAnimation {
|
|
154
|
+
private duration;
|
|
155
|
+
private easing;
|
|
156
|
+
private snapshots;
|
|
157
|
+
constructor(options?: LayoutAnimationOptions);
|
|
158
|
+
/** Record current positions of all block elements in a container */
|
|
159
|
+
snapshot(container: HTMLElement): void;
|
|
160
|
+
/** After DOM update, animate elements from old to new positions */
|
|
161
|
+
animate(container: HTMLElement): void;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface VirtualScrollerOptions {
|
|
165
|
+
itemHeight: number;
|
|
166
|
+
overscan?: number;
|
|
167
|
+
}
|
|
168
|
+
interface VirtualRange {
|
|
169
|
+
startIndex: number;
|
|
170
|
+
endIndex: number;
|
|
171
|
+
offsetY: number;
|
|
172
|
+
totalHeight: number;
|
|
173
|
+
visibleIds: Set<string>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Virtual scrolling for large trees.
|
|
177
|
+
* Calculates visible range based on scroll position and viewport height.
|
|
178
|
+
*/
|
|
179
|
+
declare class VirtualScroller {
|
|
180
|
+
private itemHeight;
|
|
181
|
+
private overscan;
|
|
182
|
+
constructor(options: VirtualScrollerOptions);
|
|
183
|
+
/** Calculate the visible range for a given scroll state */
|
|
184
|
+
calculate(scrollTop: number, viewportHeight: number, totalItems: number, blockIds: string[]): VirtualRange;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
interface SensorCallbacks {
|
|
188
|
+
onDragStart(blockId: string, x: number, y: number): void;
|
|
189
|
+
onDragMove(x: number, y: number): void;
|
|
190
|
+
onDragEnd(x: number, y: number): void;
|
|
191
|
+
onDragCancel(): void;
|
|
192
|
+
}
|
|
193
|
+
interface Sensor {
|
|
194
|
+
attach(container: HTMLElement): void;
|
|
195
|
+
detach(): void;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface PointerSensorOptions {
|
|
199
|
+
activationDistance?: number;
|
|
200
|
+
}
|
|
201
|
+
declare class PointerSensor implements Sensor {
|
|
202
|
+
private container;
|
|
203
|
+
private callbacks;
|
|
204
|
+
private activationDistance;
|
|
205
|
+
private isDragging;
|
|
206
|
+
private startX;
|
|
207
|
+
private startY;
|
|
208
|
+
private blockId;
|
|
209
|
+
private boundPointerDown;
|
|
210
|
+
private boundPointerMove;
|
|
211
|
+
private boundPointerUp;
|
|
212
|
+
constructor(callbacks: SensorCallbacks, options?: PointerSensorOptions);
|
|
213
|
+
attach(container: HTMLElement): void;
|
|
214
|
+
detach(): void;
|
|
215
|
+
private onPointerDown;
|
|
216
|
+
private onPointerMove;
|
|
217
|
+
private onPointerUp;
|
|
218
|
+
private cleanup;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface TouchSensorOptions {
|
|
222
|
+
longPressDelay?: number;
|
|
223
|
+
hapticFeedback?: boolean;
|
|
224
|
+
}
|
|
225
|
+
declare class TouchSensor implements Sensor {
|
|
226
|
+
private container;
|
|
227
|
+
private callbacks;
|
|
228
|
+
private longPressDelay;
|
|
229
|
+
private hapticFeedback;
|
|
230
|
+
private isDragging;
|
|
231
|
+
private pressTimer;
|
|
232
|
+
private blockId;
|
|
233
|
+
private boundTouchStart;
|
|
234
|
+
private boundTouchMove;
|
|
235
|
+
private boundTouchEnd;
|
|
236
|
+
constructor(callbacks: SensorCallbacks, options?: TouchSensorOptions);
|
|
237
|
+
attach(container: HTMLElement): void;
|
|
238
|
+
detach(): void;
|
|
239
|
+
private onTouchStart;
|
|
240
|
+
private onTouchMove;
|
|
241
|
+
private onTouchEnd;
|
|
242
|
+
private cleanup;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface KeyboardSensorCallbacks extends SensorCallbacks {
|
|
246
|
+
onFocusPrev(): void;
|
|
247
|
+
onFocusNext(): void;
|
|
248
|
+
onExpand(): void;
|
|
249
|
+
onCollapse(): void;
|
|
250
|
+
onFocusFirst(): void;
|
|
251
|
+
onFocusLast(): void;
|
|
252
|
+
onToggleExpand(): void;
|
|
253
|
+
onSelect(): void;
|
|
254
|
+
}
|
|
255
|
+
declare class KeyboardSensor implements Sensor {
|
|
256
|
+
private container;
|
|
257
|
+
private callbacks;
|
|
258
|
+
private boundKeyDown;
|
|
259
|
+
constructor(callbacks: KeyboardSensorCallbacks);
|
|
260
|
+
attach(container: HTMLElement): void;
|
|
261
|
+
detach(): void;
|
|
262
|
+
private onKeyDown;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface DefaultRenderer extends Unsubscribe {
|
|
266
|
+
/** Force a re-render */
|
|
267
|
+
refresh(): void;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* DefaultRenderer (Layer 2): Subscribes to controller events and
|
|
271
|
+
* automatically creates/updates DOM. User provides a renderBlock function.
|
|
272
|
+
*/
|
|
273
|
+
declare function createDefaultRenderer<T extends BaseBlock>(controller: BlockTreeController<T>, options: DefaultRendererOptions<T>): DefaultRenderer;
|
|
274
|
+
|
|
275
|
+
interface TreeRendererOptions<T extends BaseBlock> {
|
|
276
|
+
renderBlock: (block: T, ctx: RenderBlockContext) => HTMLElement;
|
|
277
|
+
containerTypes: readonly string[];
|
|
278
|
+
dropZoneHeight?: number;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Recursive DOM tree builder. Creates the full tree DOM from blocks.
|
|
282
|
+
* Keyed by data-block-id for efficient reconciliation.
|
|
283
|
+
*/
|
|
284
|
+
declare function renderTree<T extends BaseBlock>(blocks: T[], expandedMap: Record<string, boolean>, controller: BlockTreeController<T>, options: TreeRendererOptions<T>, parentId?: string | null, depth?: number): HTMLElement;
|
|
285
|
+
|
|
286
|
+
interface DropZoneOptions {
|
|
287
|
+
id: string;
|
|
288
|
+
height?: number;
|
|
289
|
+
}
|
|
290
|
+
declare function createDropZoneElement(options: DropZoneOptions): HTMLElement;
|
|
291
|
+
declare function setDropZoneActive(el: HTMLElement, active: boolean): void;
|
|
292
|
+
|
|
293
|
+
/** Create a semi-transparent in-flow preview of a block at its target position */
|
|
294
|
+
declare function createGhostPreview(sourceEl: HTMLElement): HTMLElement;
|
|
295
|
+
|
|
296
|
+
/** Create an element with attributes and optional children */
|
|
297
|
+
declare function createElement<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Record<string, string>, children?: (HTMLElement | string)[]): HTMLElementTagNameMap[K];
|
|
298
|
+
/** Set data attributes from an object */
|
|
299
|
+
declare function setDataAttributes(el: HTMLElement, data: Record<string, string | boolean | number>): void;
|
|
300
|
+
/** Find the closest ancestor with a given data attribute */
|
|
301
|
+
declare function closestWithData(el: Element, dataAttr: string): HTMLElement | null;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Trigger haptic feedback (vibration) on supported devices.
|
|
305
|
+
* Safe to call in any environment -- no-ops when `navigator.vibrate` is unavailable.
|
|
306
|
+
*/
|
|
307
|
+
declare function triggerHaptic(durationMs?: number): void;
|
|
308
|
+
|
|
309
|
+
/** Collect multiple cleanup functions into a single disposable */
|
|
310
|
+
declare function createDisposable(): Disposable & {
|
|
311
|
+
add(fn: () => void): void;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export { type BlockHistory, type BlockHistoryOptions, type BlockRendererProps, type BlockRenderers, type BlockTreeController, type BlockTreeControllerOptions, type ContainerRendererProps, type ControllerEvents, type DefaultRenderer, type DefaultRendererOptions, type Disposable, DragOverlay, type DragOverlayOptions, type DragState, type InternalRenderers, KeyboardSensor, type KeyboardSensorCallbacks, LayoutAnimation, type LayoutAnimationOptions, PointerSensor, type PointerSensorOptions, type RenderBlockContext, type RendererPropsFor, type Sensor, type SensorCallbacks, TouchSensor, type TouchSensorOptions, type TreeRendererOptions, type Unsubscribe, type VanillaSensorConfig, type VirtualRange, VirtualScroller, type VirtualScrollerOptions, buildCandidates, closestWithData, createBlockHistory, createBlockTreeController, createDefaultRenderer, createDisposable, createDropZoneElement, createElement, createGhostPreview, detectCollision, measureDropZoneRects, pointerToRect, renderTree, setDataAttributes, setDropZoneActive, triggerHaptic };
|