On this pageFunctions
Ui/DragAndDrop/test
/**
* Returns Story steps that resolve a pending `ResolveKeyboardMove` to the
* supplied container and index, then resolve `FocusItem` for `itemId`.
*
* The steps fail if either Command is missing or multiple keyboard moves are
* pending. Unrelated Commands stay pending. Pass the DragAndDrop Binding,
* plus its key when keyed, to select one embedded occurrence and verify the
* pending move belongs to `itemId`. Binding selection matches the composed
* path suffix. When an enclosing Binding repeats that path, isolate one
* ancestor occurrence in the Story; the helper rejects the ambiguity.
*/
<BindingValue extends DragAndDropBinding | undefined = undefined>(__namedParameters: ResolveKeyboardMoveInput<BindingValue>): StoryTransform/**
* Returns a Story step that resolves `FocusItem({ itemId })` after a keyboard
* drop, cancellation, or move. The step fails if no matching Command is pending
* and leaves unrelated Commands pending. Pass the DragAndDrop Binding, plus
* its key when keyed, to select one embedded occurrence.
*/
<BindingValue extends DragAndDropBinding | undefined = undefined>(__namedParameters: SettleFocusInput<BindingValue>): (simulation: StorySimulation<Model, Message, OutMessage>) => StorySimulation<Model, Message, OutMessage>/**
* The dragged item and target position supplied to
* resolveKeyboardMove. Pass `binding` when testing an embedded
* DragAndDrop Block. A keyed Binding also requires its exact occurrence
* `key`.
*/
type ResolveKeyboardMoveInput = Readonly<{
itemId: string
targetContainerId: string
targetIndex: number
}> & BindingSelection<BindingValue>/**
* Identifies the item whose focus Command settleFocus resolves.
* Pass `binding` when testing an embedded DragAndDrop Block. A keyed Binding
* also requires its exact occurrence `key`.
*/
type SettleFocusInput = Readonly<{
itemId: string
}> & BindingSelection<BindingValue>/** Focuses a draggable item by ID after a keyboard move, drop, or cancel. */
const FocusItem: LayeredCommandDefinitionWithArgs<"DragAndDrop/FocusItem", {
itemId: String
}, {
_tag: "CompletedFocusItem"
}> | DefinitionWithArgsNameKeyed<"DragAndDrop/FocusItem", {
itemId: String
}, Effect<{
_tag: "CompletedFocusItem"
}, never, Handler<"DragAndDrop/FocusItem", {
itemId: string
}, {
_tag: "CompletedFocusItem"
}>>> | DefinitionWithArgs<"DragAndDrop/FocusItem", {
itemId: String
}, Pick<{
itemId: string
}, "itemId">, Effect<{
_tag: "CompletedFocusItem"
}, never, Handler<"DragAndDrop/FocusItem", {
itemId: string
}, {
_tag: "CompletedFocusItem"
}>>> & Readonly<{
layer: Layer<Handler<"DragAndDrop/FocusItem", {
itemId: string
}, {
_tag: "CompletedFocusItem"
}>, never, never>
}> & Readonly<{
toLayer: ToLayer<"DragAndDrop/FocusItem", {
itemId: string
}, {
_tag: "CompletedFocusItem"
}>
}>/** Resolves the next keyboard drag position by querying the DOM for adjacent sortable items and containers. */
const ResolveKeyboardMove: LayeredCommandDefinitionWithArgs<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: String
currentIndex: Number
direction: Literals<readonly ["Up", "Down", "Left", "Right", "NextContainer", "PreviousContainer"]>
itemId: String
}, {
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}> | DefinitionWithArgsNameKeyed<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: String
currentIndex: Number
direction: Literals<readonly ["Up", "Down", "Left", "Right", "NextContainer", "PreviousContainer"]>
itemId: String
}, Effect<{
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}, never, Handler<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: string
currentIndex: number
direction: "Up" | "Down" | "Left" | "Right" | "NextContainer" | "PreviousContainer"
itemId: string
}, {
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}>>> | DefinitionWithArgs<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: String
currentIndex: Number
direction: Literals<readonly ["Up", "Down", "Left", "Right", "NextContainer", "PreviousContainer"]>
itemId: String
}, Pick<{
currentContainerId: string
currentIndex: number
direction: "Up" | "Down" | "Left" | "Right" | "NextContainer" | "PreviousContainer"
itemId: string
}, "direction" | "itemId" | "currentContainerId" | "currentIndex">, Effect<{
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}, never, Handler<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: string
currentIndex: number
direction: "Up" | "Down" | "Left" | "Right" | "NextContainer" | "PreviousContainer"
itemId: string
}, {
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}>>> & Readonly<{
layer: Layer<Handler<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: string
currentIndex: number
direction: "Up" | "Down" | "Left" | "Right" | "NextContainer" | "PreviousContainer"
itemId: string
}, {
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}>, never, never>
}> & Readonly<{
toLayer: ToLayer<"DragAndDrop/ResolveKeyboardMove", {
currentContainerId: string
currentIndex: number
direction: "Up" | "Down" | "Left" | "Right" | "NextContainer" | "PreviousContainer"
itemId: string
}, {
_tag: "CompletedResolveKeyboardMove"
targetContainerId: string
targetIndex: number
}>
}>