GitHub

Reference core

primitives

interface 6 type 4 function 8 const 1
interface Interfaces 6

# CollectionItem

The minimal shape an item must satisfy.

Members

disabled?
readonly optional disabled?: boolean
id
readonly id: string
label?
readonly optional label?: string

# Dismissable

Members

active
readonly active: boolean
activate()
activate(): void

###### Returns

void

deactivate()
deactivate(): void

###### Returns

void

# DismissableOptions

Members

ignore?
optional ignore?: readonly ElementTarget[]

Elements outside container that should NOT count as "outside". Each may be an element or a thunk that resolves at call time (so consumers can pass a ref that may not yet be mounted at activate()).

onEscape?
optional onEscape?: (event) => void

Called when Escape is pressed while active.

###### Parameters

###### event

KeyboardEvent

###### Returns

void

onOutsideClick?
optional onOutsideClick?: (event) => void

Called when a pointerdown occurs outside the container + ignore list.

###### Parameters

###### event

Event

###### Returns

void

# FocusTrap

Members

active
readonly active: boolean
activate()
activate(): void

###### Returns

void

deactivate()
deactivate(): void

###### Returns

void

# FocusTrapOptions

Members

initialFocus?
optional initialFocus?: FocusTarget

Element to focus on activation. Default: first focusable descendant. If the container has no focusable descendant, focus stays where it is — pass an explicit element if you need a guaranteed landing target.

returnFocus?
optional returnFocus?: false | FocusTarget

Element to return focus to on deactivation. Default: the element that was document.activeElement when activate() was called. Pass false to skip return-focus, or a specific element to override.

type Type Aliases 4

# Direction

Direction = "ltr" | "rtl"

Layout direction tag. Mirrors @kumiki/locale's Direction re-declared locally so primitives stays at Layer 1 with zero @kumiki/* dependencies.

# ElementTarget

ElementTarget = HTMLElement | (() => HTMLElement | null) | null | undefined

@kumiki/primitives/dismissable — outside-click + Escape signal handlers.

The primitive does not close anything itself — it just calls back. The consumer wires onOutsideClick and onEscape to whatever state mutation is appropriate (controller.close(), dispatch({ type: 'CLOSE' }), etc.).

"Outside" is defined as: not inside container, and not inside any element listed in ignore. The ignore list covers cases where a related element lives outside the container's DOM subtree (e.g. a popover whose trigger is visually adjacent but not a descendant).

Pointer events: we listen on pointerdown because it fires before focus shifts and works consistently across mouse, touch, and pen. Listening on click would miss cases where the user mousedowns inside and mouseups outside, and mousedown ignores touch.

function Functions 8

# createDismissable ( )

createDismissable(container, options?): Dismissable

Create a dismissable handler bound to container. Inert until activate().

Parameters

container
HTMLElement
options?
DismissableOptions = {}

Returns

Dismissable

# createFocusTrap ( )

createFocusTrap(container, options?): FocusTrap

Create a focus trap bound to container. Inert until activate().

Parameters

container
HTMLElement
options?
FocusTrapOptions = {}

Returns

FocusTrap

# createIdScope ( )

createIdScope(scope): object

Create an id scope for deterministic id generation within a request / component mount. The counter resets per scope instance.

Parameters

scope
string

Returns

object ##### next() > next(suffix?): string ###### Parameters ###### suffix? string ###### Returns string

# findByTypeAhead ( )

findByTypeAhead<T>(items, query, fromId?): string | null

Type-ahead match: find the next item whose label starts with query, starting after fromId and wrapping.

Type Parameters

T

Parameters

items
readonly T[]
query
string
fromId?
string | null

Returns

string | null

# getNextEnabledId ( )

getNextEnabledId<T>(items, fromId, direction, options?): string | null

Find the id of the next enabled item from fromId in direction. Returns null if the collection has no enabled items.

Type Parameters

T

Parameters

items
readonly T[]
fromId
string | null
options?
NavigateOptions = {}

Returns

string | null

# inferDirection ( )

inferDirection(localeCode): Direction

Infer the layout direction for a BCP-47 locale tag.

Strips any region / script / variant subtags (ar-EGar, zh-Hans-CNzh) and consults a small RTL-language allow-list. Unknown locales default to 'ltr' — the safer fallback for v1.0.

Parameters

localeCode
string

Returns

Direction

# tabindexFor ( )

tabindexFor<T>(items, itemId, focusedId): -1 | 0

Compute the tabindex value for an item under roving-tabindex semantics: only the focused (or first enabled, if none focused) item gets 0; every other item gets -1.

Type Parameters

T

Parameters

items
readonly T[]
itemId
string
focusedId
string | null

Returns

-1 | 0

# uid ( )

uid(scope?): string

Generate an id using the best available source of entropy. Output is always prefixed with kumiki-, optionally followed by <scope>-.

Parameters

scope?
string

Returns

string
const Variables 1

# LOCALE\_CONTEXT\_KEY

const LOCALE_CONTEXT_KEY: unique symbol

Symbol key used by <LocaleProvider> and useLocale() to share their Svelte context value. Stable across the entire @kumiki/* surface.