@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: anyOptions 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) => FocusableResultNormalize `tabIndex`/`aria-disabled` props for a focusable host.
FocusableOptionstype
FocusableOptions: anyOptions for {@link focusable}.
disabled- disabled?: boolean;
tabIndex- tabIndex?: number | undefined;
FocusableResulttype
FocusableResult: anyElement props returned by {@link focusable}.
tabIndex- tabIndex?: number;
hoverabletype
hoverable: ({ disabled, onEnter, onLeave }: HoverableOptions) => HoverableResultProduce pointer enter/leave props that call `onEnter`/`onLeave` unless disabled.
HoverableOptionstype
HoverableOptions: anyOptions for {@link hoverable}.
disabled- disabled?: boolean;
onEnter- onEnter?: (e: HoverEvent) => void;
onLeave- onLeave?: (e: HoverEvent) => void;
HoverableResulttype
HoverableResult: anyElement props returned by {@link hoverable}.
onPointerEnter- onPointerEnter?: (e: HoverEvent) => void;
onPointerLeave- onPointerLeave?: (e: HoverEvent) => void;
InteractionPolicyInputtype
InteractionPolicyInput: anyInput 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) => PressableResultProduce click/keyboard props implementing 'press' semantics for an element.
PressableOptionstype
PressableOptions: anyOptions for {@link pressable}.
disabled- disabled?: boolean;
onPress- onPress?: (e: PressEvent) => void;
isNativeButton- Whether the host is a native button. Defaults to false.
PressableResulttype
PressableResult: anyElement 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) => RovingFocusResultImplement arrow-key roving tabindex navigation over a set of items.
RovingFocusOptionstype
RovingFocusOptions: anyOptions 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: anyContainer 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)