/** * Keyboard constants, direction helpers, and a small attribute name used by the * composite primitives. * * Mirrors `packages/react/src/internals/composite/composite.ts` + * `constants.ts` in Base UI React, adapted to Solid. Keep the naming identical * so downstream consumers can port keyboard-handling logic straight across. */ export const ARROW_UP = "ArrowUp"; export const ARROW_DOWN = "ArrowDown"; export const ARROW_LEFT = "ArrowLeft"; export const ARROW_RIGHT = "ArrowRight"; export const HOME = "Home"; export const END = "End"; export const HORIZONTAL_KEYS = new Set([ARROW_LEFT, ARROW_RIGHT]); export const HORIZONTAL_KEYS_WITH_EXTRA_KEYS = new Set([ ARROW_LEFT, ARROW_RIGHT, HOME, END, ]); export const VERTICAL_KEYS = new Set([ARROW_UP, ARROW_DOWN]); export const VERTICAL_KEYS_WITH_EXTRA_KEYS = new Set([ ARROW_UP, ARROW_DOWN, HOME, END, ]); export const ARROW_KEYS = new Set([ ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ]); export const ALL_KEYS = new Set([ ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END, ]); const SHIFT = "Shift" as const; const CONTROL = "Control" as const; const ALT = "Alt" as const; const META = "Meta" as const; export const MODIFIER_KEYS = new Set([SHIFT, CONTROL, ALT, META] as const); export type ModifierKey = typeof MODIFIER_KEYS extends Set ? Keys : never; /** * Data attribute that marks an element as the "initially active" composite * item. On first non-empty map update, `useCompositeRoot` picks up this marker * and moves `highlightedIndex` to the matching item. */ export const ACTIVE_COMPOSITE_ITEM = "data-composite-item-active"; /** * `orientation` value accepted by the composite root. */ export type CompositeOrientation = "horizontal" | "vertical" | "both"; /** * Text direction. Matches the shape used throughout Base UI; we don't depend on * a DirectionContext here — the composite root takes it as a plain prop so * consumers can thread in whatever source of truth they want. */ export type TextDirection = "ltr" | "rtl";