Reference core
primitives
# CollectionItem
The minimal shape an item must satisfy.
Members
disabled?readonly optional disabled?: booleanidreadonly id: stringlabel?readonly optional label?: string
# Dismissable
Members
activereadonly active: booleanactivate()activate(): void###### Returns
voiddeactivate()deactivate(): void###### Returns
void
# DismissableOptions
Members
ignore?optional ignore?: readonly ElementTarget[]Elements outside
containerthat 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) => voidCalled when Escape is pressed while active.
###### Parameters
###### event
KeyboardEvent###### Returns
voidonOutsideClick?optional onOutsideClick?: (event) => voidCalled when a pointerdown occurs outside the container + ignore list.
###### Parameters
###### event
Event###### Returns
void
# FocusTrap
Members
activereadonly active: booleanactivate()activate(): void###### Returns
voiddeactivate()deactivate(): void###### Returns
void
# FocusTrapOptions
Members
initialFocus?optional initialFocus?: FocusTargetElement 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 | FocusTargetElement to return focus to on deactivation. Default: the element that was
document.activeElementwhen activate() was called. Passfalseto skip return-focus, or a specific element to override.
# NavigateOptions
Members
# 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.
# FocusTarget
FocusTarget = HTMLElement | (() => HTMLElement | null) | null | undefined# NavigateDirection
NavigateDirection = "next" | "prev" | "first" | "last" | "page-next" | "page-prev"Direction for keyboard navigation.
# createDismissable ( )
createDismissable(container, options?): DismissableCreate a dismissable handler bound to container. Inert until activate().
Parameters
containerHTMLElementoptions?DismissableOptions = {}
Returns
Dismissable# createFocusTrap ( )
createFocusTrap(container, options?): FocusTrapCreate a focus trap bound to container. Inert until activate().
Parameters
containerHTMLElementoptions?FocusTrapOptions = {}
Returns
FocusTrap# createIdScope ( )
createIdScope(scope): objectCreate an id scope for deterministic id generation within a request / component mount. The counter resets per scope instance.
Parameters
scopestring
Returns
object
##### next()
> next(suffix?): string
###### Parameters
###### suffix?
string
###### Returns
string# findByTypeAhead ( )
findByTypeAhead<T>(items, query, fromId?): string | nullType-ahead match: find the next item whose label starts with query, starting after fromId and wrapping.
Type Parameters
T
Parameters
itemsreadonly T[]querystringfromId?string | null
Returns
string | null# getNextEnabledId ( )
getNextEnabledId<T>(items, fromId, direction, options?): string | nullFind the id of the next enabled item from fromId in direction. Returns null if the collection has no enabled items.
Type Parameters
T
Parameters
itemsreadonly T[]fromIdstring | nulldirectionNavigateDirectionoptions?NavigateOptions = {}
Returns
string | null# inferDirection ( )
inferDirection(localeCode): DirectionInfer the layout direction for a BCP-47 locale tag.
Strips any region / script / variant subtags (ar-EG → ar, zh-Hans-CN → zh) and consults a small RTL-language allow-list. Unknown locales default to 'ltr' — the safer fallback for v1.0.
Parameters
localeCodestring
Returns
Direction# tabindexFor ( )
tabindexFor<T>(items, itemId, focusedId): -1 | 0Compute 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
itemsreadonly T[]itemIdstringfocusedIdstring | null
Returns
-1 | 0# uid ( )
uid(scope?): stringGenerate an id using the best available source of entropy. Output is always prefixed with kumiki-, optionally followed by <scope>-.
Parameters
scope?string
Returns
string# LOCALE\_CONTEXT\_KEY
const LOCALE_CONTEXT_KEY: unique symbolSymbol key used by <LocaleProvider> and useLocale() to share their Svelte context value. Stable across the entire @kumiki/* surface.