@whittakertech/mosaic
Enumerations
| Enumeration | Description |
|---|---|
|
Represents the current interaction lifecycle state of a MosaicJS instance. States are mutually exclusive and transition deterministically. |
Classes
| Class | Description |
|---|---|
|
Mosaic is the public controller for an event-driven drag-and-drop system. It manages:
Consumers should:
Direct state manipulation is intentionally restricted. Example |
Interfaces
| Interface | Description |
|---|---|
|
The input to a drag-and-drop constraint evaluation. Passed as a single object so the constraint surface can grow across the v0.3 milestone (drop-target kind here in #11; ancestor chain and group options in #12/#13) without churning call sites. |
|
|
The result of evaluating a drag-and-drop constraint. A 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 |
|
|
Defines the semantic CSS class contract used by MosaicJS. Each property represents a stable, meaning-based styling hook that may be applied during the drag lifecycle. Remarks MosaicJS does not impose visual styles. These class names are intended to integrate with external design systems or utility frameworks. |
|
|
Immutable context object describing the current drag operation. A It is passed to lifecycle hooks and emitted with relevant events to allow external systems to observe drag behavior safely. Remarks
The shape of DragContext is considered part of MosaicJS’s stable public API. |
|
|
Lifecycle hooks for observing MosaicJS drag behavior. Each hook is invoked at a specific point in the drag lifecycle and receives an immutable drag context. Remarks Hooks are invoked in strict alignment with the internal deterministic state machine. Invoking a hook in an unexpected state will throw an error. |
|
|
Configuration options used to construct a Mosaic instance. MosaicOptions define the DOM scope, selector semantics, styling hooks, and lifecycle observation points for a Mosaic drag session. Remarks Options are read once at construction time. Changing values after initialization has no effect. |
|
|
A structural snapshot of the DOM captured at drag start. Snapshots allow MosaicJS to restore the DOM to a known-good state when a drop operation is rejected. Remarks Snapshots capture node identity, parent relationships, and ordering. They do not clone DOM nodes or capture visual state. |
|
|
The outcome of resolving a drop destination at a point in the DOM. A Remarks Resolution is pure and side-effect free. The returned object describes where a drop would land; it does not mutate the DOM. |
|
|
Payload for the |
Type Aliases
| Type Alias | Description |
|---|---|
|
Whether a resolved target is a draggable node acting as a drop target, or an element declared explicitly as a drop destination. |
Variables
| Variable | Description |
|---|---|
|
The default semantic CSS class contract used by MosaicJS. This object defines the canonical set of CSS class names applied during the drag lifecycle when no user overrides are provided. Remarks MosaicJS does not ship with visual styles. These class names are intended to be consumed by external design systems, utility frameworks, or application stylesheets. Consumers may override individual entries via MosaicOptions.cssClasses. |
|
|
Mapping of drag lifecycle hooks to their required Mosaic state. This object defines the invariant relationship between each lifecycle hook and the internal drag state in which it may fire. Remarks This mapping is used to validate hook invocation at runtime. If a hook is invoked while the Mosaic instance is in an unexpected state, an error will be thrown. This object is intentionally static and non-extensible. |
|
|
The complete set of valid state transitions for MosaicJS. This object defines the deterministic finite state machine governing the drag lifecycle. Remarks This map is intentionally static and non-extensible. All state transitions must be explicit, observable, and testable. |
Functions
| Function | Description |
|---|---|
|
Constructs an immutable DragContext from internal drag state. This function is used by MosaicJS to create the context object passed to lifecycle hooks and emitted with drag-related events. Remarks
While exported as part of the public API, this function is primarily intended for internal use and advanced tooling. |
|
|
Determines whether a transition between two lifecycle states is valid. This function enforces MosaicJS’s deterministic state machine. Remarks Invalid transitions are rejected by |
|
|
Evaluates whether a drop operation is permitted. Applies MosaicJS’s built-in, deterministic constraints to a proposed drag-and-drop interaction. A drop is permitted when the target is the dragged element itself (a no-op
self-drop), when it matches Remarks Constraint evaluation is synchronous and side-effect free. This function
covers MosaicJS’s built-in constraints only. As of v0.4, custom
user-defined constraints are also supported — see
MosaicOptions.constraints — and are evaluated by
|
|
|
Captures a structural snapshot of the current DOM state. The snapshot is used to guarantee rollback safety if a drop operation is rejected. Remarks Snapshots are captured automatically by MosaicJS at drag start. Manual usage is intended for advanced or diagnostic scenarios. |
|
|
Emits a MosaicJS lifecycle event. Events are dispatched on the global Remarks Event emission is synchronous. MosaicJS does not catch or suppress listener errors. |
|
|
Resolves the nearest group-container ancestor of an element, bounded by the Mosaic root. Populates ResolvedTarget.group (#13). Returns |
|
|
Resolves the innermost valid drop destination at a position in the DOM. Walks upward from |
|
|
Restores the DOM to a previously captured snapshot state. This function reorders existing DOM nodes to match the snapshot. Remarks If the snapshot is invalid or incomplete, restoration is a no-op. This function does not recreate or remove DOM nodes. |