Askr documentation
Generated API snapshot

@askrjs/askr/foundations/interactions

Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.

Exports

This entrypoint publishes 18 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

applyInteractionPolicytype

applyInteractionPolicy: ({ isNative, disabled, onPress, ref }: InteractionPolicyInput) => { disabled: true | undefined; onClick: (e: Event) => void; ref: Ref<unknown>; } | { tabIndex: number; ref: Ref<unknown>; "aria-disabled"?: "true"; onClick: (e: DefaultPreventable & PropagationStoppable) => void; disabled?: true; role?: "button"; onKeyDown?: (e: KeyboardLikeEvent) => void; onKeyUp?: (e: KeyboardLikeEvent) => void; }

THE interaction policy. Components MUST use this, NEVER implement interaction logic directly.

dismissabletype

dismissable: ({ node, additionalInsideNodes, disabled, onDismiss }: DismissableOptions) => { onKeyDown: (e: KeyboardLikeEvent) => void; onPointerDownCapture: (e: PointerLikeEvent) => void; }

Produce keydown/outside-click props that invoke `onDismiss` on Escape or an outside click.

DismissableOptionstype

DismissableOptions: any

Options for {@link dismissable}.

node
Reference to the protected element for outside click detection. Attach the returned capture props to a surface that encloses this node.
additionalInsideNodes
Additional roots that are logically inside the protected surface even when a portal places them outside `node` in the DOM tree.
disabled
Whether dismiss is disabled
onDismiss
Called when dismiss is triggered (Escape or outside click)

focusabletype

focusable: ({ disabled, tabIndex }: FocusableOptions) => FocusableResult

Normalize `tabIndex`/`aria-disabled` props for a focusable host.

FocusableOptionstype

FocusableOptions: any

Options for {@link focusable}.

disabled
disabled?: boolean;
tabIndex
tabIndex?: number | undefined;

FocusableResulttype

FocusableResult: any

Element props returned by {@link focusable}.

tabIndex
tabIndex?: number;

hoverabletype

hoverable: ({ disabled, onEnter, onLeave }: HoverableOptions) => HoverableResult

Produce pointer enter/leave props that call `onEnter`/`onLeave` unless disabled.

HoverableOptionstype

HoverableOptions: any

Options for {@link hoverable}.

disabled
disabled?: boolean;
onEnter
onEnter?: (e: HoverEvent) => void;
onLeave
onLeave?: (e: HoverEvent) => void;

HoverableResulttype

HoverableResult: any

Element props returned by {@link hoverable}.

onPointerEnter
onPointerEnter?: (e: HoverEvent) => void;
onPointerLeave
onPointerLeave?: (e: HoverEvent) => void;

InteractionPolicyInputtype

InteractionPolicyInput: any

Input to {@link applyInteractionPolicy}.

isNative
Whether the host element is a native interactive element (button, a, etc)
disabled
Disabled state - checked ONLY here, never in components
onPress
User-provided press handler - semantic action, not DOM event
ref
Optional ref to compose

mergeInteractionPropstype

mergeInteractionProps: (childProps: Record<string, unknown>, policyProps: Record<string, unknown>, userProps?: Record<string, unknown>) => Record<string, unknown>

Merge rule for Slot / asChild Precedence: policy → user → child Event handlers are composed (policy first). Refs are always composed. Policy props MUST take precedence to enforce invariants.

Orientationtype

Orientation: 'horizontal' | 'vertical' | 'both'

Arrow-key axis for {@link rovingFocus}.

pressabletype

pressable: ({ disabled, onPress, isNativeButton }: PressableOptions) => PressableResult

Produce click/keyboard props implementing 'press' semantics for an element.

PressableOptionstype

PressableOptions: any

Options for {@link pressable}.

disabled
disabled?: boolean;
onPress
onPress?: (e: PressEvent) => void;
isNativeButton
Whether the host is a native button. Defaults to false.

PressableResulttype

PressableResult: any

Element props returned by {@link pressable}.

onClick
onClick: (e: PressEvent) => void;
disabled
disabled?: true;
role
role?: 'button';
tabIndex
tabIndex?: number;
onKeyDown
onKeyDown?: (e: KeyboardLikeEvent) => void;
onKeyUp
onKeyUp?: (e: KeyboardLikeEvent) => void;

rovingFocustype

rovingFocus: (options: RovingFocusOptions) => RovingFocusResult

Implement arrow-key roving tabindex navigation over a set of items.

RovingFocusOptionstype

RovingFocusOptions: any

Options for {@link rovingFocus}.

currentIndex
Current focused index
itemCount
Total number of items
orientation
Navigation orientation - horizontal: ArrowLeft/ArrowRight - vertical: ArrowUp/ArrowDown - both: all arrow keys
loop
Whether to loop when reaching the end
onNavigate
Callback when navigation occurs
isDisabled
Optional disabled state check per index

RovingFocusResulttype

RovingFocusResult: any

Container and per-item props returned by {@link rovingFocus}.

container
Props for the container element (composes via mergeProps)
item
Generate props for an item at the given index (composes via mergeProps)