Askr documentation
Generated API snapshot

@askrjs/askr/foundations/structures

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

Exports

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

cloneElementtype

cloneElement: (element: JSXElement, props: Record<string, unknown>) => JSXElement

Clone a JSX element, shallow-merging `props` over its existing props.

Collectiontype

Collection: any

Ordered descendant registry returned by {@link createCollection}.

register
Register a node with optional metadata. Returns an unregister function.
items
Get all registered items in insertion order.
clear
Clear all registered items.
size
Get the count of registered items.

CollectionItemtype

CollectionItem: {
  node: TNode;
  metadata: TMetadata;
}

A registered node paired with its metadata inside a {@link Collection}.

createCollectiontype

createCollection: <TNode, TMetadata = unknown>() => Collection<TNode, TMetadata>

Create an empty, insertion-ordered {@link Collection} registry.

createLayertype

createLayer: () => LayerManager

Create a new, empty {@link LayerManager} for coordinating overlay stacking.

DefaultPortaltype

DefaultPortal: Portal<RenderableChild>

The implicit portal channel that {@link Portal} writes to and that any host rendered without an explicit portal falls back to.

definePortaltype

definePortal: <T extends RenderableChild = RenderableChild>() => Portal<T>

Create a new named {@link Portal} channel with its own host and content.

isElementtype

isElement: (value: unknown) => value is JSXElement

Check whether `value` is a JSX element vnode.

JSXElementtype

JSXElement: any

The vnode shape produced by JSX/`jsx()` calls.

$typeof
Internal element marker
type
Element type: string, component, Fragment, etc
props
Props bag
key
Optional key (normalized by runtime)

Layertype

Layer: any

A registered layer entry returned by {@link LayerManager.register}.

id
Unique layer ID
isTop
Check if this layer is the topmost
unregister
Remove this layer from the stack

LayerManagertype

LayerManager: any

Stacking coordinator returned by {@link createLayer}.

register
Register a new layer
layers
Get all active layers in order
handleEscape
Manually trigger escape handling on the top layer
handleOutsidePointer
Manually trigger outside pointer handling on the top layer

LayerOptionstype

LayerOptions: any

Options for registering a layer with {@link LayerManager.register}.

onEscape
Called when Escape is pressed and this is the top layer
onOutsidePointer
Called when pointer event occurs outside and this is the top layer
node
Optional node reference for outside pointer detection

layouttype

layout: <P = object>(Layout: LayoutComponent<P>) => (children?: RenderableChild, props?: P) => unknown

Wrap a {@link LayoutComponent} so it can be invoked as `(children, props)`, matching route layout conventions.

LayoutComponenttype

LayoutComponent: (props: P & {
  children?: RenderableChild;
}) => unknown

A component that receives its route children via `props.children`.

Portaltype

Portal: (props: PortalProps) => JSXElement | null

Write children to the {@link DefaultPortal} host wherever it is rendered. A named portal channel created by {@link definePortal}: call it as a component to render the host, and call `.render(props)` to write content.

PortalPropstype

PortalProps: any

Props for the {@link Portal} component.

children
children?: RenderableChild;

Presencetype

Presence: ({ present, children }: PresenceProps) => JSXElement | null

Presence Structural policy primitive for conditional mount/unmount. - No timers - No animation coupling - No DOM side-effects POLICY DECISIONS (LOCKED): 1. Present as Function Accepts boolean OR function to support lazy evaluation patterns. Function is called once per render. Use boolean form for static values. 2. Children Type Presence forwards normal renderable child content only. Imperative DOM nodes are not part of the public contract. 3. Immediate Mount/Unmount No exit animations or transitions. When `present` becomes false, children are removed immediately. Animation must be layered above this primitive.

PresencePropstype

PresenceProps: any

Props for {@link Presence}.

children
children?: RenderableChild;
present
Whether the children should be mounted, or a function returning it.

Slottype

Slot: (props: SlotProps) => JSXElement | null

Slot Structural primitive for prop forwarding patterns. POLICY DECISIONS (LOCKED): 1. asChild Pattern When asChild=true, merges props into the single child element. Child must be a valid JSXElement; non-element children return null. **Slot props override child props** (injection pattern). 2. Fallback Behavior When asChild=false, returns a Fragment (structural no-op). No DOM element is introduced. 3. Type Safety asChild=true requires exactly one JSXElement child (enforced by type). Runtime validates with isElement() check.

SlotPropstype

SlotProps: {
  asChild: true;
  children: JSXElement;
  [key: string]: unknown;
} | {
  asChild?: false;
  children?: RenderableChild;
}

Props for {@link Slot}: `asChild` selects prop-merging vs. fragment mode.

asChild
asChild?: boolean | undefined;
children
children?: RenderableChild;