@dnd-block-tree/react 2.0.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 +61 -0
- package/dist/index.d.mts +337 -0
- package/dist/index.d.ts +337 -0
- package/dist/index.js +2500 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2360 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @dnd-block-tree/react
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@dnd-block-tree/react)
|
|
4
|
+
|
|
5
|
+
React adapter for [dnd-block-tree](https://github.com/thesandybridge/dnd-block-tree) — components, hooks, and [@dnd-kit](https://dndkit.com/) integration for building hierarchical drag-and-drop interfaces.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @dnd-block-tree/react @dnd-kit/core @dnd-kit/utilities
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires **React 18+** and **@dnd-kit/core 6+**.
|
|
14
|
+
|
|
15
|
+
## What's Included
|
|
16
|
+
|
|
17
|
+
- **Components** — `BlockTree`, `BlockTreeSSR`, `TreeRenderer`, `DropZone`, `DragOverlay`
|
|
18
|
+
- **Hooks** — `useBlockHistory`, `useLayoutAnimation`, `useVirtualTree`, `useConfiguredSensors`
|
|
19
|
+
- **Collision Bridge** — `adaptCollisionDetection` to bridge core's `CoreCollisionDetection` to @dnd-kit's `CollisionDetection`
|
|
20
|
+
- **Re-exports** — all types and utilities from `@dnd-block-tree/core`
|
|
21
|
+
|
|
22
|
+
## Quick Example
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { BlockTree, type BaseBlock, type BlockRenderers } from '@dnd-block-tree/react'
|
|
26
|
+
|
|
27
|
+
interface MyBlock extends BaseBlock {
|
|
28
|
+
type: 'section' | 'task'
|
|
29
|
+
title: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const renderers: BlockRenderers<MyBlock, ['section']> = {
|
|
33
|
+
section: ({ block, children, isExpanded, onToggleExpand }) => (
|
|
34
|
+
<div>
|
|
35
|
+
<button onClick={onToggleExpand}>{isExpanded ? '▼' : '▶'} {block.title}</button>
|
|
36
|
+
{isExpanded && <div className="ml-4">{children}</div>}
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
task: ({ block }) => <div>{block.title}</div>,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function App() {
|
|
43
|
+
const [blocks, setBlocks] = useState<MyBlock[]>(initialBlocks)
|
|
44
|
+
return (
|
|
45
|
+
<BlockTree
|
|
46
|
+
blocks={blocks}
|
|
47
|
+
renderers={renderers}
|
|
48
|
+
containerTypes={['section']}
|
|
49
|
+
onChange={setBlocks}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
Full docs at **[blocktree.sandybridge.io](https://blocktree.sandybridge.io/docs)**.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { BaseBlock, BlockRendererProps as BlockRendererProps$1, BlockRenderers as BlockRenderers$1, OrderingStrategy, BlockAddEvent, BlockDeleteEvent, CanDragFn, CanDropFn, SensorConfig, DropZoneConfig, AnimationConfig, AutoExpandConfig, IdGeneratorFn, ContainerRendererProps as ContainerRendererProps$1, InternalRenderers as InternalRenderers$1, RendererPropsFor as RendererPropsFor$1, CoreCollisionDetection, BlockTreeCallbacks, BlockStateContextValue } from '@dnd-block-tree/core';
|
|
2
|
+
export { AnimationConfig, AutoExpandConfig, BaseBlock, BlockAction, BlockAddEvent, BlockDeleteEvent, BlockIndex, BlockMoveEvent, BlockPosition, BlockStateContextValue, BlockTreeCallbacks, BlockTreeConfig, BlockTreeEvents, BlockTreeInstance, BlockTreeOptions, CanDragFn, CanDropFn, CollisionCandidate, CollisionResult, BlockTreeCustomization as CoreBlockTreeCustomization, CoreCollisionDetection, DragOverlayProps as CoreDragOverlayProps, 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
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import * as _dnd_kit_core from '@dnd-kit/core';
|
|
6
|
+
import { CollisionDetection, PointerActivationConstraint } from '@dnd-kit/core';
|
|
7
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
type BlockRendererProps<T extends BaseBlock = BaseBlock> = BlockRendererProps$1<T, ReactNode>;
|
|
10
|
+
type ContainerRendererProps<T extends BaseBlock = BaseBlock> = ContainerRendererProps$1<T, ReactNode>;
|
|
11
|
+
type RendererPropsFor<T extends BaseBlock, K extends T['type'], C extends readonly string[]> = RendererPropsFor$1<T, K, C, ReactNode>;
|
|
12
|
+
type BlockRenderers<T extends BaseBlock = BaseBlock, C extends readonly string[] = readonly string[]> = BlockRenderers$1<T, C, ReactNode>;
|
|
13
|
+
type InternalRenderers<T extends BaseBlock = BaseBlock> = InternalRenderers$1<T, ReactNode>;
|
|
14
|
+
/**
|
|
15
|
+
* Block state provider props
|
|
16
|
+
*/
|
|
17
|
+
interface BlockStateProviderProps<T extends BaseBlock = BaseBlock> {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
initialBlocks?: T[];
|
|
20
|
+
containerTypes?: readonly string[];
|
|
21
|
+
onChange?: (blocks: T[]) => void;
|
|
22
|
+
orderingStrategy?: OrderingStrategy;
|
|
23
|
+
maxDepth?: number;
|
|
24
|
+
onBlockAdd?: (event: BlockAddEvent<T>) => void;
|
|
25
|
+
onBlockDelete?: (event: BlockDeleteEvent<T>) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Tree state provider props
|
|
29
|
+
*/
|
|
30
|
+
interface TreeStateProviderProps<T extends BaseBlock = BaseBlock> {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
blocks: T[];
|
|
33
|
+
blockMap: Map<string, T>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Tree state context value (UI state)
|
|
37
|
+
*/
|
|
38
|
+
interface TreeStateContextValue<T extends BaseBlock = BaseBlock> {
|
|
39
|
+
activeId: string | null;
|
|
40
|
+
activeBlock: T | null;
|
|
41
|
+
hoverZone: string | null;
|
|
42
|
+
expandedMap: Record<string, boolean>;
|
|
43
|
+
effectiveBlocks: T[];
|
|
44
|
+
blocksByParent: Map<string | null, T[]>;
|
|
45
|
+
setActiveId: (id: string | null) => void;
|
|
46
|
+
setHoverZone: (zone: string | null) => void;
|
|
47
|
+
toggleExpand: (id: string) => void;
|
|
48
|
+
setExpandAll: (expanded: boolean) => void;
|
|
49
|
+
handleHover: (zoneId: string, parentId: string | null) => void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Full customization options for BlockTree (React version).
|
|
53
|
+
* Uses dnd-kit's CollisionDetection instead of core's CoreCollisionDetection.
|
|
54
|
+
*/
|
|
55
|
+
interface BlockTreeCustomization<T extends BaseBlock = BaseBlock> {
|
|
56
|
+
canDrag?: CanDragFn<T>;
|
|
57
|
+
canDrop?: CanDropFn<T>;
|
|
58
|
+
collisionDetection?: CollisionDetection;
|
|
59
|
+
sensors?: SensorConfig;
|
|
60
|
+
dropZones?: DropZoneConfig;
|
|
61
|
+
animation?: AnimationConfig;
|
|
62
|
+
autoExpand?: AutoExpandConfig;
|
|
63
|
+
idGenerator?: IdGeneratorFn;
|
|
64
|
+
initialExpanded?: string[] | 'all' | 'none';
|
|
65
|
+
orderingStrategy?: OrderingStrategy;
|
|
66
|
+
maxDepth?: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Adapt a framework-agnostic CoreCollisionDetection into a dnd-kit CollisionDetection.
|
|
71
|
+
*
|
|
72
|
+
* Converts:
|
|
73
|
+
* droppableContainers → CollisionCandidate[]
|
|
74
|
+
* Calls coreDetector
|
|
75
|
+
* CollisionResult[] → CollisionDescriptor[]
|
|
76
|
+
*/
|
|
77
|
+
declare function adaptCollisionDetection(coreDetector: CoreCollisionDetection): CollisionDetection;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Trigger haptic feedback (vibration) on supported devices.
|
|
81
|
+
* Safe to call in any environment -- no-ops when `navigator.vibrate` is unavailable.
|
|
82
|
+
*/
|
|
83
|
+
declare function triggerHaptic(durationMs?: number): void;
|
|
84
|
+
|
|
85
|
+
interface SensorConfigResult {
|
|
86
|
+
pointer: {
|
|
87
|
+
activationConstraint: PointerActivationConstraint;
|
|
88
|
+
};
|
|
89
|
+
touch: {
|
|
90
|
+
activationConstraint: PointerActivationConstraint;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
declare function useConfiguredSensors(config?: SensorConfig): _dnd_kit_core.SensorDescriptor<_dnd_kit_core.SensorOptions>[];
|
|
94
|
+
declare function getSensorConfig(config?: SensorConfig): SensorConfigResult;
|
|
95
|
+
|
|
96
|
+
interface BlockTreeProps<T extends BaseBlock, C extends readonly T['type'][] = readonly T['type'][]> extends BlockTreeCallbacks<T>, BlockTreeCustomization<T> {
|
|
97
|
+
/** Current blocks array */
|
|
98
|
+
blocks: T[];
|
|
99
|
+
/** Block renderers for each type */
|
|
100
|
+
renderers: BlockRenderers<T, C>;
|
|
101
|
+
/** Block types that can have children */
|
|
102
|
+
containerTypes?: C;
|
|
103
|
+
/** Called when blocks are reordered */
|
|
104
|
+
onChange?: (blocks: T[]) => void;
|
|
105
|
+
/** Custom drag overlay renderer */
|
|
106
|
+
dragOverlay?: (block: T) => ReactNode;
|
|
107
|
+
/** Activation distance in pixels (default: 8) */
|
|
108
|
+
activationDistance?: number;
|
|
109
|
+
/** Preview debounce in ms (default: 150) */
|
|
110
|
+
previewDebounce?: number;
|
|
111
|
+
/** Root container className */
|
|
112
|
+
className?: string;
|
|
113
|
+
/** Drop zone className */
|
|
114
|
+
dropZoneClassName?: string;
|
|
115
|
+
/** Active drop zone className */
|
|
116
|
+
dropZoneActiveClassName?: string;
|
|
117
|
+
/** Indent className for nested items */
|
|
118
|
+
indentClassName?: string;
|
|
119
|
+
/** Show live preview of drop position during drag (default: true) */
|
|
120
|
+
showDropPreview?: boolean;
|
|
121
|
+
/** Enable keyboard navigation with arrow keys (default: false) */
|
|
122
|
+
keyboardNavigation?: boolean;
|
|
123
|
+
/** Enable multi-select with Cmd/Ctrl+Click and Shift+Click (default: false) */
|
|
124
|
+
multiSelect?: boolean;
|
|
125
|
+
/** Externally-controlled selected IDs (for multi-select) */
|
|
126
|
+
selectedIds?: Set<string>;
|
|
127
|
+
/** Called when selection changes (for multi-select) */
|
|
128
|
+
onSelectionChange?: (selectedIds: Set<string>) => void;
|
|
129
|
+
/** Enable virtual scrolling for large trees (fixed item height only) */
|
|
130
|
+
virtualize?: {
|
|
131
|
+
/** Fixed height of each item in pixels */
|
|
132
|
+
itemHeight: number;
|
|
133
|
+
/** Number of extra items to render outside the visible range (default: 5) */
|
|
134
|
+
overscan?: number;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
declare function BlockTree<T extends BaseBlock, C extends readonly T['type'][] = readonly T['type'][]>({ blocks, renderers, containerTypes, onChange, dragOverlay, activationDistance, previewDebounce, className, dropZoneClassName, dropZoneActiveClassName, indentClassName, showDropPreview, onDragStart, onDragMove, onDragEnd, onDragCancel, onBeforeMove, onBlockMove, onExpandChange, onHoverChange, canDrag, canDrop, collisionDetection, sensors: sensorConfig, animation, initialExpanded, orderingStrategy, maxDepth, keyboardNavigation, multiSelect, selectedIds: externalSelectedIds, onSelectionChange, virtualize, }: BlockTreeProps<T, C>): react_jsx_runtime.JSX.Element;
|
|
138
|
+
|
|
139
|
+
interface TreeRendererProps<T extends BaseBlock> {
|
|
140
|
+
blocks: T[];
|
|
141
|
+
blocksByParent: Map<string | null, T[]>;
|
|
142
|
+
parentId: string | null;
|
|
143
|
+
activeId: string | null;
|
|
144
|
+
expandedMap: Record<string, boolean>;
|
|
145
|
+
renderers: InternalRenderers<T>;
|
|
146
|
+
containerTypes: readonly string[];
|
|
147
|
+
onHover: (zoneId: string, parentId: string | null) => void;
|
|
148
|
+
onToggleExpand: (id: string) => void;
|
|
149
|
+
depth?: number;
|
|
150
|
+
dropZoneClassName?: string;
|
|
151
|
+
dropZoneActiveClassName?: string;
|
|
152
|
+
indentClassName?: string;
|
|
153
|
+
rootClassName?: string;
|
|
154
|
+
canDrag?: CanDragFn<T>;
|
|
155
|
+
/** Preview position info - where to show the ghost */
|
|
156
|
+
previewPosition?: {
|
|
157
|
+
parentId: string | null;
|
|
158
|
+
index: number;
|
|
159
|
+
} | null;
|
|
160
|
+
/** The dragged block for rendering preview ghost */
|
|
161
|
+
draggedBlock?: T | null;
|
|
162
|
+
/** Currently focused block ID for keyboard navigation */
|
|
163
|
+
focusedId?: string | null;
|
|
164
|
+
/** Currently selected block IDs for multi-select */
|
|
165
|
+
selectedIds?: Set<string>;
|
|
166
|
+
/** Click handler for multi-select */
|
|
167
|
+
onBlockClick?: (blockId: string, event: React.MouseEvent) => void;
|
|
168
|
+
/** Animation configuration */
|
|
169
|
+
animation?: AnimationConfig;
|
|
170
|
+
/** When virtual scrolling is active, only render blocks in this set */
|
|
171
|
+
virtualVisibleIds?: Set<string> | null;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Recursive tree renderer with smart drop zones
|
|
175
|
+
*/
|
|
176
|
+
declare function TreeRendererInner<T extends BaseBlock>({ blocks, blocksByParent, parentId, activeId, expandedMap, renderers, containerTypes, onHover, onToggleExpand, depth, dropZoneClassName, dropZoneActiveClassName, indentClassName, rootClassName, canDrag, previewPosition, draggedBlock, focusedId, selectedIds, onBlockClick, animation, virtualVisibleIds, }: TreeRendererProps<T>): react_jsx_runtime.JSX.Element;
|
|
177
|
+
declare const TreeRenderer: typeof TreeRendererInner;
|
|
178
|
+
|
|
179
|
+
interface DropZoneProps {
|
|
180
|
+
id: string;
|
|
181
|
+
parentId: string | null;
|
|
182
|
+
onHover: (zoneId: string, parentId: string | null) => void;
|
|
183
|
+
activeId: string | null;
|
|
184
|
+
className?: string;
|
|
185
|
+
activeClassName?: string;
|
|
186
|
+
height?: number;
|
|
187
|
+
}
|
|
188
|
+
declare function DropZoneComponent({ id, parentId, onHover, activeId, className, activeClassName, height, }: DropZoneProps): react_jsx_runtime.JSX.Element | null;
|
|
189
|
+
declare const DropZone: react.MemoExoticComponent<typeof DropZoneComponent>;
|
|
190
|
+
|
|
191
|
+
interface DragOverlayProps<T extends BaseBlock> {
|
|
192
|
+
activeBlock: T | null;
|
|
193
|
+
children?: (block: T) => ReactNode;
|
|
194
|
+
/** Number of selected items being dragged (for multi-select badge) */
|
|
195
|
+
selectedCount?: number;
|
|
196
|
+
}
|
|
197
|
+
declare function DragOverlay<T extends BaseBlock>({ activeBlock, children, selectedCount, }: DragOverlayProps<T>): react_jsx_runtime.JSX.Element;
|
|
198
|
+
|
|
199
|
+
interface BlockTreeSSRProps<T extends BaseBlock, C extends readonly T['type'][] = readonly T['type'][]> extends BlockTreeProps<T, C> {
|
|
200
|
+
/** Content to render before hydration completes (default: null) */
|
|
201
|
+
fallback?: ReactNode;
|
|
202
|
+
}
|
|
203
|
+
declare function BlockTreeSSR<T extends BaseBlock, C extends readonly T['type'][] = readonly T['type'][]>({ fallback, ...props }: BlockTreeSSRProps<T, C>): react_jsx_runtime.JSX.Element;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Create block state context and hooks
|
|
207
|
+
*/
|
|
208
|
+
declare function createBlockState<T extends BaseBlock>(): {
|
|
209
|
+
BlockStateProvider: ({ children, initialBlocks, containerTypes, onChange, orderingStrategy, maxDepth, onBlockAdd, onBlockDelete, }: BlockStateProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
|
210
|
+
useBlockState: () => BlockStateContextValue<T>;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
interface CreateTreeStateOptions<T extends BaseBlock> {
|
|
214
|
+
previewDebounce?: number;
|
|
215
|
+
containerTypes?: string[];
|
|
216
|
+
}
|
|
217
|
+
declare function createTreeState<T extends BaseBlock>(options?: CreateTreeStateOptions<T>): {
|
|
218
|
+
TreeStateProvider: ({ children, blocks, blockMap }: TreeStateProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
|
219
|
+
useTreeState: () => TreeStateContextValue<T>;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
interface UseBlockHistoryOptions {
|
|
223
|
+
/** Maximum number of undo steps to retain (default: 50) */
|
|
224
|
+
maxSteps?: number;
|
|
225
|
+
}
|
|
226
|
+
interface UseBlockHistoryResult<T extends BaseBlock> {
|
|
227
|
+
/** Current blocks state */
|
|
228
|
+
blocks: T[];
|
|
229
|
+
/** Set new blocks state (pushes current to undo stack) */
|
|
230
|
+
set: (blocks: T[]) => void;
|
|
231
|
+
/** Undo the last change */
|
|
232
|
+
undo: () => void;
|
|
233
|
+
/** Redo the last undone change */
|
|
234
|
+
redo: () => void;
|
|
235
|
+
/** Whether undo is available */
|
|
236
|
+
canUndo: boolean;
|
|
237
|
+
/** Whether redo is available */
|
|
238
|
+
canRedo: boolean;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Composable hook for undo/redo support with BlockTree.
|
|
242
|
+
*
|
|
243
|
+
* Usage:
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const { blocks, set, undo, redo, canUndo, canRedo } = useBlockHistory(initialBlocks)
|
|
246
|
+
* <BlockTree blocks={blocks} onChange={set} />
|
|
247
|
+
* <button onClick={undo} disabled={!canUndo}>Undo</button>
|
|
248
|
+
* <button onClick={redo} disabled={!canRedo}>Redo</button>
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
declare function useBlockHistory<T extends BaseBlock>(initialBlocks: T[], options?: UseBlockHistoryOptions): UseBlockHistoryResult<T>;
|
|
252
|
+
|
|
253
|
+
interface UseLayoutAnimationOptions {
|
|
254
|
+
/** Duration of the transition in ms (default: 200) */
|
|
255
|
+
duration?: number;
|
|
256
|
+
/** CSS easing function (default: 'ease') */
|
|
257
|
+
easing?: string;
|
|
258
|
+
/** CSS selector for animated children (default: '[data-block-id]') */
|
|
259
|
+
selector?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* FLIP-based layout animation hook for reorder transitions.
|
|
263
|
+
*
|
|
264
|
+
* Captures block positions before render (layout effect cleanup),
|
|
265
|
+
* computes the delta after render, and applies a CSS transform transition.
|
|
266
|
+
*
|
|
267
|
+
* Usage:
|
|
268
|
+
* ```tsx
|
|
269
|
+
* const containerRef = useRef<HTMLDivElement>(null)
|
|
270
|
+
* useLayoutAnimation(containerRef, { duration: 200 })
|
|
271
|
+
* return <div ref={containerRef}>...</div>
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
declare function useLayoutAnimation(containerRef: React.RefObject<HTMLElement | null>, options?: UseLayoutAnimationOptions): void;
|
|
275
|
+
|
|
276
|
+
interface UseVirtualTreeOptions {
|
|
277
|
+
/** Ref to the scrollable container element */
|
|
278
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
279
|
+
/** Total number of items in the tree */
|
|
280
|
+
itemCount: number;
|
|
281
|
+
/** Fixed height of each item in pixels */
|
|
282
|
+
itemHeight: number;
|
|
283
|
+
/** Number of extra items to render outside the visible range (default: 5) */
|
|
284
|
+
overscan?: number;
|
|
285
|
+
}
|
|
286
|
+
interface UseVirtualTreeResult {
|
|
287
|
+
/** Start and end indices of the visible range (inclusive) */
|
|
288
|
+
visibleRange: {
|
|
289
|
+
start: number;
|
|
290
|
+
end: number;
|
|
291
|
+
};
|
|
292
|
+
/** Total height of all items for the spacer div */
|
|
293
|
+
totalHeight: number;
|
|
294
|
+
/** Offset from top for the first rendered item */
|
|
295
|
+
offsetY: number;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Lightweight fixed-height virtual scrolling hook for tree lists.
|
|
299
|
+
*
|
|
300
|
+
* Tracks scroll position on the container and computes which items
|
|
301
|
+
* should be rendered based on the viewport and overscan.
|
|
302
|
+
*/
|
|
303
|
+
declare function useVirtualTree({ containerRef, itemCount, itemHeight, overscan, }: UseVirtualTreeOptions): UseVirtualTreeResult;
|
|
304
|
+
|
|
305
|
+
interface DevToolsEventEntry {
|
|
306
|
+
id: number;
|
|
307
|
+
timestamp: number;
|
|
308
|
+
type: 'dragStart' | 'dragEnd' | 'blockMove' | 'expandChange' | 'hoverChange';
|
|
309
|
+
summary: string;
|
|
310
|
+
}
|
|
311
|
+
interface DevToolsCallbacks<T extends BaseBlock = BaseBlock> {
|
|
312
|
+
onDragStart: NonNullable<BlockTreeCallbacks<T>['onDragStart']>;
|
|
313
|
+
onDragEnd: NonNullable<BlockTreeCallbacks<T>['onDragEnd']>;
|
|
314
|
+
onBlockMove: NonNullable<BlockTreeCallbacks<T>['onBlockMove']>;
|
|
315
|
+
onExpandChange: NonNullable<BlockTreeCallbacks<T>['onExpandChange']>;
|
|
316
|
+
onHoverChange: NonNullable<BlockTreeCallbacks<T>['onHoverChange']>;
|
|
317
|
+
}
|
|
318
|
+
interface BlockTreeDevToolsProps<T extends BaseBlock = BaseBlock> {
|
|
319
|
+
blocks: T[];
|
|
320
|
+
containerTypes?: readonly string[];
|
|
321
|
+
events: DevToolsEventEntry[];
|
|
322
|
+
onClearEvents: () => void;
|
|
323
|
+
getLabel?: (block: T) => string;
|
|
324
|
+
initialOpen?: boolean;
|
|
325
|
+
position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
|
|
326
|
+
buttonStyle?: React.CSSProperties;
|
|
327
|
+
panelStyle?: React.CSSProperties;
|
|
328
|
+
forceMount?: boolean;
|
|
329
|
+
}
|
|
330
|
+
declare function useDevToolsCallbacks<T extends BaseBlock = BaseBlock>(): {
|
|
331
|
+
callbacks: DevToolsCallbacks<T>;
|
|
332
|
+
events: DevToolsEventEntry[];
|
|
333
|
+
clearEvents: () => void;
|
|
334
|
+
};
|
|
335
|
+
declare function BlockTreeDevTools<T extends BaseBlock = BaseBlock>({ blocks, containerTypes, events, onClearEvents, getLabel, initialOpen, position, buttonStyle, panelStyle, forceMount, }: BlockTreeDevToolsProps<T>): react_jsx_runtime.JSX.Element | null;
|
|
336
|
+
|
|
337
|
+
export { type BlockRendererProps, type BlockRenderers, type BlockStateProviderProps, BlockTree, type BlockTreeCustomization, BlockTreeDevTools, type BlockTreeDevToolsProps, type BlockTreeProps, BlockTreeSSR, type BlockTreeSSRProps, type ContainerRendererProps, type DevToolsCallbacks, type DevToolsEventEntry, DragOverlay, type DragOverlayProps, DropZone, type DropZoneProps, type InternalRenderers, type RendererPropsFor, type SensorConfigResult, TreeRenderer, type TreeRendererProps, type TreeStateContextValue, type TreeStateProviderProps, type UseBlockHistoryOptions, type UseBlockHistoryResult, type UseLayoutAnimationOptions, type UseVirtualTreeOptions, type UseVirtualTreeResult, adaptCollisionDetection, createBlockState, createTreeState, getSensorConfig, triggerHaptic, useBlockHistory, useConfiguredSensors, useDevToolsCallbacks, useLayoutAnimation, useVirtualTree };
|