keys/changelog
Changelog
Release notes for @diffgazer/keys.
0.3.0
Minor changes
- Added
hasModifierKey(event)to the public entry:truewhenaltKey,ctrlKey,metaKey, orshiftKeyis held. Use it as the "this key is unmodified, so the widget owns it" guard, not for letter hotkeys, which already encode Shift inevent.key. - Added the
moveHighlightlist-navigation helper, with theHighlightNavigationItemandMoveHighlightResulttypes, to the public entry. isListNavigationKeynow returnstrueforjandk, andgetVerticalArrowDirectionmapskto"up"andjto"down". UppercaseJ/Kare unaffected. A suppression guard of the shapeif (isListNavigationKey(event.key)) event.preventDefault()now swallows those two characters too; re-check any that sit near text entry.- Copy targets are described as
@hooks/...alias tokens instead of hardcodedsrc/paths, so a copied hook lands under the consumer's configured source root. Thenavigationitem also copies thehotkeyhelper it depends on. - Focus restoration and focus traps work across owner documents and shadow roots, and action-row focus repair no longer steals focus.
- Correctness and accessibility fixes across the hooks and utilities.
- Hotkey strings are checked at compile time.
ValidateHotkey<S>andHotkeyModifier("ctrl" | "meta" | "shift" | "alt" | "mod") are exported, andkeys(),canonicalizeHotkey, everyuseKeyoverload, andKeyboardContextValue.registervalidate string literals through them. A literal whose+-delimited modifier segment is outside that vocabulary no longer type-checks; the final key segment is unconstrained, and a non-literalstringpasses through. Spell modifiers from the vocabulary ("Cmd+K"->"mod+k") and keep computed hotkeys typed asstring.keys()takes and returnsKeyHandlerin place of(event) => void. KeyHandleris declared as(event: KeyboardEvent) => unknown. The former| Declinewas already absorbed byunknown, so nothing stops compiling and returningDECLINEstill declines the event.DeclineandDECLINEstay exported.useActionRowNavigationandUseActionRowNavigationOptionsare no longer generic over an actions tuple:actionCount,defaultIndex, and theonAction/onNavigateindex arenumber, anddisabledActionsisreadonly boolean[]. Drop the type argument and widen any callback parameter narrowed to a tuple index union.useActionRowNavigationacceptsscope(an explicit keyboard scope) andactionIds(stable per-index control identities, so a rebuild at the focused index is repaired onto the new element), and returnsisRegisteredActionFocused(), which reports whether DOM focus rests on the registered action atfocusedIndex.useFocusZoneacceptstabCycleScope("containers"or"document") andtabCycleBoundaryto control where Tab/Shift+Tab cycling claims the Tab key.- Added
composedContains,composedClosest,isReachable, andisInsideDisabledFieldsetto the public entry: containment and ancestor lookup that cross shadow boundaries, the hidden/inert/aria-hidden/closed-<details>reachability check shared byisFocusableand item discovery, and thefieldset[disabled]check that exempts descendants of the first<legend>. - Exported the
ZoneTransition<T>type, addeditemSelectortoNavigationItemQueryandUseNavigationOptions, and addedallowInInputtoUseScopedNavigationOptions. focusNavigationItemno longer acceptsfallback: "none"; omitfallbackfor the same behavior.- New
@diffgazer/keys/testing/navigation-behaviorentry exportingtestNavigationBehavior,NavigationCase, andTestNavigationBehaviorOptions, with@testing-library/react,@testing-library/user-event, andvitestas optional peer dependencies. - Requires Node
>=22.0.0and resolves throughexportsonly: the top-levelmainandtypesfields are gone, so TypeScript consumers onmoduleResolution: "node"must move tobundler,node16, ornodenext.
Patch changes
- The npm tarball ships
distplus the readme, license, and policy files:registry/,public/r/, andinternal-docs-manifest.jsonare no longer packed,CHANGELOG.mdis, anddist/**/*.mapis excluded.
0.2.0
Minor changes
- Removed pre-release keyboard alias props before public handoff:
targetRef->containerRef,requireFocusWithin->focusWithinOnly,onBoundaryReached->onNavigationBoundaryReached, and the old focus-zone helpersZoneProps,inZone,forZone, andzoneProps->getZoneProps.
Patch changes
- Regenerated package artifacts from source during verification instead of tracking deterministic generated docs and CLI bundles.
- Documented install paths, shadcn namespace setup, and keyboard integration.