Skip to content

ConstraintResult

@whittakertech/mosaic / ConstraintResult

Interface: ConstraintResult

Defined in: constraints.ts:16

The result of evaluating a drag-and-drop constraint.

A ConstraintResult represents a deterministic decision about whether a proposed drop operation is allowed.

Remarks

Constraint evaluation in MosaicJS is synchronous, pure, and side-effect free. A rejected result will trigger rollback behavior if a snapshot is present.

Consumers should treat reason as diagnostic metadata only.

Properties

allowed

allowed: boolean;

Defined in: constraints.ts:20

Whether the drop operation is permitted.


metadata?

optional metadata: Record<string, unknown>;

Defined in: constraints.ts:47

Optional structured diagnostic data describing the rejection (#22).

Remarks

Not interpreted by MosaicJS internally β€” purely for external observers (logs, analytics, debugging UIs). Built-in constraints populate this with a shape keyed to their reason:

  • "invalid-target": { targetSelector: string, actualElement: HTMLElement }
  • "group-boundary": { sourceGroupId: string | null, targetGroupId: string | null }
  • "circular-nesting": { ancestorChain: HTMLElement[] }
  • "nesting-depth-exceeded": { depth: number, maxNestingDepth: number }

User-defined constraints (MosaicOptions.constraints) may populate this with any shape they choose β€” it’s the same optional field, with no special-casing between built-in and user-provided results.


reason?

optional reason: string;

Defined in: constraints.ts:28

Optional machine-readable reason for rejection.

This value is not interpreted by MosaicJS internally, but may be surfaced through events or logs for debugging purposes.