weasel API - v0.8.0
    Preparing search index...

    Interface ArrayAdapterConfig<TNode, TPose>

    Configuration for arrayAdapter.

    interface ArrayAdapterConfig<TNode extends { id: string }, TPose> {
        createDefault?: (bounds: Bounds) => TNode | null;
        fromPose?: (obj: TNode, pose: TPose) => TNode;
        getChildren?: (id: string) => string[] | undefined;
        getParent?: (id: string) => string | null;
        intersectsRect?: (pose: TPose, rect: Bounds) => boolean;
        nextId?: () => string;
        poseBounds?: (pose: TPose) => Bounds;
        ref: MutableRefObject<TNode[]>;
        selectionRef?: MutableRefObject<string[]>;
        setItems: (updater: (items: TNode[]) => TNode[]) => void;
        setParent?: (id: string, parentId: string | null) => void;
        setSelection?: (ids: string[]) => void;
        toPose: (obj: TNode) => TPose;
        translatePose?: (pose: TPose, dx: number, dy: number) => TPose;
    }

    Type Parameters

    • TNode extends { id: string }
    • TPose
    Index

    Properties

    createDefault?: (bounds: Bounds) => TNode | null

    Factory for commitInsert — invoked at the end of an insert drag. Consumers own id generation and any palette/payload fields. Returning null aborts the insert. When omitted, commitInsert returns null.

    fromPose?: (obj: TNode, pose: TPose) => TNode

    Merge a new pose back into an object. Default: shallow spread.

    getChildren?: (id: string) => string[] | undefined

    Optional children lookup. Default omits the method.

    getParent?: (id: string) => string | null

    Optional parent lookup. Default returns null.

    intersectsRect?: (pose: TPose, rect: Bounds) => boolean

    Tight intersection test against a pose. Default: AABB-vs-AABB using poseBounds. Override for non-rect poses (e.g. polygons via pathPoseDescriptor.intersectsRect).

    nextId?: () => string

    Factory for fresh node ids in commitPaste. Default: crypto.randomUUID() when available, otherwise a monotonic paste-<n> counter. Override when consumers want stable id schemes (e.g. clip-${n++}).

    poseBounds?: (pose: TPose) => Bounds

    Project a pose to an AABB for hitTestArea. Default: identity (works when TPose carries top-level x/y/width/height).

    ref: MutableRefObject<TNode[]>

    Live ref to the current array.

    selectionRef?: MutableRefObject<string[]>

    Live ref to the current selection. Default: empty array.

    setItems: (updater: (items: TNode[]) => TNode[]) => void

    Functional setter (typically the second value from useState).

    setParent?: (id: string, parentId: string | null) => void

    Optional reparent mutator. Default is a noop.

    setSelection?: (ids: string[]) => void

    Selection setter. Default: noop.

    toPose: (obj: TNode) => TPose

    Project an object to its pose. Required.

    translatePose?: (pose: TPose, dx: number, dy: number) => TPose

    Translate a pose by (dx, dy). Default: shallow-spread { x, y }, which matches the canonical axis-aligned rect pose. Override for non-rect poses whose translation isn't a top-level x/y bump.