keystra 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +177 -2
  4. package/dist/chunk-2BLQUBG7.js +816 -0
  5. package/dist/chunk-77GGU3AX.js +135 -0
  6. package/dist/chunk-KDOJARJD.js +29 -0
  7. package/dist/chunk-LYYUOTBP.js +125 -0
  8. package/dist/chunk-S5YVXIMA.js +61 -0
  9. package/dist/chunk-SSIKGDD4.js +255 -0
  10. package/dist/chunk-U7YK6PPT.js +1729 -0
  11. package/dist/chunk-XFNYIPOW.js +253 -0
  12. package/dist/chunk-ZOJRXXQN.js +308 -0
  13. package/dist/core.cjs +2861 -0
  14. package/dist/core.d.cts +41 -0
  15. package/dist/core.d.ts +41 -0
  16. package/dist/core.js +7 -0
  17. package/dist/engine-COPfXXTp.d.ts +229 -0
  18. package/dist/engine-DcbkGRgz.d.cts +229 -0
  19. package/dist/focus.cjs +374 -0
  20. package/dist/focus.d.cts +74 -0
  21. package/dist/focus.d.ts +74 -0
  22. package/dist/focus.js +2 -0
  23. package/dist/index-IZkcWAXP.d.cts +395 -0
  24. package/dist/index-IZkcWAXP.d.ts +395 -0
  25. package/dist/index.cjs +3745 -0
  26. package/dist/index.d.cts +9 -0
  27. package/dist/index.d.ts +9 -0
  28. package/dist/index.global.js +1 -0
  29. package/dist/index.js +9 -0
  30. package/dist/layout-C2-n8aUI.d.ts +17 -0
  31. package/dist/layout-CBzD-87D.d.cts +17 -0
  32. package/dist/navigation.cjs +293 -0
  33. package/dist/navigation.d.cts +33 -0
  34. package/dist/navigation.d.ts +33 -0
  35. package/dist/navigation.js +2 -0
  36. package/dist/patterns.cjs +3505 -0
  37. package/dist/patterns.d.cts +12 -0
  38. package/dist/patterns.d.ts +12 -0
  39. package/dist/patterns.js +7 -0
  40. package/dist/roving-focus-CT7Dm6di.d.ts +63 -0
  41. package/dist/roving-focus-ZQ0v7hLe.d.cts +63 -0
  42. package/dist/selection.cjs +266 -0
  43. package/dist/selection.d.cts +43 -0
  44. package/dist/selection.d.ts +43 -0
  45. package/dist/selection.js +2 -0
  46. package/dist/utils-CkveVeIJ.d.cts +18 -0
  47. package/dist/utils-JmPZTlys.d.ts +18 -0
  48. package/dist/utils.cjs +195 -0
  49. package/dist/utils.d.cts +3 -0
  50. package/dist/utils.d.ts +3 -0
  51. package/dist/utils.js +2 -0
  52. package/package.json +147 -4
@@ -0,0 +1,41 @@
1
+ export { E as EventManager, I as ItemCollection, a as ItemCollectionOptions, K as KeyMatcher, M as MatchResult, N as NavigationController, R as ResolvedOptions, T as TypeaheadController, c as createKeyMatcher, b as createKeystra, d as createRafThrottle, e as createRectOf, f as createTypeahead, k as keyEquals, p as parseKeyBinding, r as resolveOptions } from './engine-DcbkGRgz.cjs';
2
+ import { y as NormalizedKeyEvent, K as KeyAction, k as KeyBindingInput, m as KeyBindingOptions, j as KeyBindingHandle, H as HookOptions, s as KeystraHandle, n as KeyMap, N as NavigationMode } from './index-IZkcWAXP.cjs';
3
+ export { A as AutoFocusOptions, B as BaseOptions, C as CommandPaletteInstance, a as CommandPaletteOptions, D as DefaultKeyMap, b as Direction, c as DropdownInstance, d as DropdownOptions, E as ElementTarget, e as EventHandler, f as EventName, g as EventPayload, G as GridInstance, h as GridOptions, I as ItemSelector, i as KeyBinding, l as KeyBindingObject, o as KeySequenceBinding, p as KeySequenceInput, q as KeySequenceOptions, r as KeystraEventMap, t as KeystraInstance, u as KeystraOptions, L as ListOptions, M as MenuInstance, v as MenuOptions, w as NavigationStrategy, x as NavigationStrategyContext, P as ParsedKeyBinding, R as RovingFocusOptions, z as RovingOptions, S as SelectionController, F as SelectionMode, J as SelectionOptions, T as TabsInstance, O as TabsOptions, Q as TreeInstance, U as TreeOptions, V as TypeaheadOptions, W as Unsubscribe } from './index-IZkcWAXP.cjs';
4
+ import './focus.cjs';
5
+ import './selection.cjs';
6
+ import './layout-CBzD-87D.cjs';
7
+
8
+ declare function normalizeKeyName(key: string): string;
9
+ declare function isPrintableKey(key: string): boolean;
10
+ declare function isModifierKey(key: string): boolean;
11
+ declare function normalizeKeyEvent(event: KeyboardEvent): NormalizedKeyEvent;
12
+ declare function codeToKey(code: string): string;
13
+ declare function formatKeyCombo(key: string, modifiers?: {
14
+ ctrl?: boolean;
15
+ alt?: boolean;
16
+ shift?: boolean;
17
+ meta?: boolean;
18
+ }): string;
19
+ declare function describeEvent(event: KeyboardEvent): string;
20
+
21
+ declare function useKeystra(options?: HookOptions): KeystraHandle;
22
+ interface KeyBindingInfo {
23
+ readonly action: KeyAction;
24
+ readonly fromSequence: boolean;
25
+ }
26
+ type KeyBindingHandler = (event: KeyboardEvent, info: KeyBindingInfo) => void;
27
+ declare function createKeyBinding(binding: KeyBindingInput, handler: KeyBindingHandler, options?: KeyBindingOptions): KeyBindingHandle;
28
+
29
+ declare const VERTICAL_KEYS: KeyMap;
30
+ declare const HORIZONTAL_KEYS: KeyMap;
31
+ declare const TABS_KEYS_HORIZONTAL: KeyMap;
32
+ declare const TABS_KEYS_VERTICAL: KeyMap;
33
+ declare const GRID_KEYS: KeyMap;
34
+ declare const MENU_KEYS: KeyMap;
35
+ declare const TREE_KEYS: KeyMap;
36
+ declare const LIST_KEYS: KeyMap;
37
+ declare const COMMAND_PALETTE_KEYS: KeyMap;
38
+ declare function defaultKeysFor(mode: NavigationMode): KeyMap;
39
+ declare function mergeKeys(defaults: KeyMap, user: KeyMap | undefined | null, useDefaults: boolean): KeyMap;
40
+
41
+ export { COMMAND_PALETTE_KEYS, GRID_KEYS, HORIZONTAL_KEYS, HookOptions, KeyAction, KeyBindingHandle, type KeyBindingHandler, type KeyBindingInfo, KeyBindingInput, KeyBindingOptions, KeyMap, KeystraHandle, LIST_KEYS, MENU_KEYS, NavigationMode, NormalizedKeyEvent, TABS_KEYS_HORIZONTAL, TABS_KEYS_VERTICAL, TREE_KEYS, VERTICAL_KEYS, codeToKey, createKeyBinding, defaultKeysFor, describeEvent, formatKeyCombo, isModifierKey, isPrintableKey, mergeKeys, normalizeKeyEvent, normalizeKeyName, useKeystra };
package/dist/core.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ export { E as EventManager, I as ItemCollection, a as ItemCollectionOptions, K as KeyMatcher, M as MatchResult, N as NavigationController, R as ResolvedOptions, T as TypeaheadController, c as createKeyMatcher, b as createKeystra, d as createRafThrottle, e as createRectOf, f as createTypeahead, k as keyEquals, p as parseKeyBinding, r as resolveOptions } from './engine-COPfXXTp.js';
2
+ import { y as NormalizedKeyEvent, K as KeyAction, k as KeyBindingInput, m as KeyBindingOptions, j as KeyBindingHandle, H as HookOptions, s as KeystraHandle, n as KeyMap, N as NavigationMode } from './index-IZkcWAXP.js';
3
+ export { A as AutoFocusOptions, B as BaseOptions, C as CommandPaletteInstance, a as CommandPaletteOptions, D as DefaultKeyMap, b as Direction, c as DropdownInstance, d as DropdownOptions, E as ElementTarget, e as EventHandler, f as EventName, g as EventPayload, G as GridInstance, h as GridOptions, I as ItemSelector, i as KeyBinding, l as KeyBindingObject, o as KeySequenceBinding, p as KeySequenceInput, q as KeySequenceOptions, r as KeystraEventMap, t as KeystraInstance, u as KeystraOptions, L as ListOptions, M as MenuInstance, v as MenuOptions, w as NavigationStrategy, x as NavigationStrategyContext, P as ParsedKeyBinding, R as RovingFocusOptions, z as RovingOptions, S as SelectionController, F as SelectionMode, J as SelectionOptions, T as TabsInstance, O as TabsOptions, Q as TreeInstance, U as TreeOptions, V as TypeaheadOptions, W as Unsubscribe } from './index-IZkcWAXP.js';
4
+ import './focus.js';
5
+ import './selection.js';
6
+ import './layout-C2-n8aUI.js';
7
+
8
+ declare function normalizeKeyName(key: string): string;
9
+ declare function isPrintableKey(key: string): boolean;
10
+ declare function isModifierKey(key: string): boolean;
11
+ declare function normalizeKeyEvent(event: KeyboardEvent): NormalizedKeyEvent;
12
+ declare function codeToKey(code: string): string;
13
+ declare function formatKeyCombo(key: string, modifiers?: {
14
+ ctrl?: boolean;
15
+ alt?: boolean;
16
+ shift?: boolean;
17
+ meta?: boolean;
18
+ }): string;
19
+ declare function describeEvent(event: KeyboardEvent): string;
20
+
21
+ declare function useKeystra(options?: HookOptions): KeystraHandle;
22
+ interface KeyBindingInfo {
23
+ readonly action: KeyAction;
24
+ readonly fromSequence: boolean;
25
+ }
26
+ type KeyBindingHandler = (event: KeyboardEvent, info: KeyBindingInfo) => void;
27
+ declare function createKeyBinding(binding: KeyBindingInput, handler: KeyBindingHandler, options?: KeyBindingOptions): KeyBindingHandle;
28
+
29
+ declare const VERTICAL_KEYS: KeyMap;
30
+ declare const HORIZONTAL_KEYS: KeyMap;
31
+ declare const TABS_KEYS_HORIZONTAL: KeyMap;
32
+ declare const TABS_KEYS_VERTICAL: KeyMap;
33
+ declare const GRID_KEYS: KeyMap;
34
+ declare const MENU_KEYS: KeyMap;
35
+ declare const TREE_KEYS: KeyMap;
36
+ declare const LIST_KEYS: KeyMap;
37
+ declare const COMMAND_PALETTE_KEYS: KeyMap;
38
+ declare function defaultKeysFor(mode: NavigationMode): KeyMap;
39
+ declare function mergeKeys(defaults: KeyMap, user: KeyMap | undefined | null, useDefaults: boolean): KeyMap;
40
+
41
+ export { COMMAND_PALETTE_KEYS, GRID_KEYS, HORIZONTAL_KEYS, HookOptions, KeyAction, KeyBindingHandle, type KeyBindingHandler, type KeyBindingInfo, KeyBindingInput, KeyBindingOptions, KeyMap, KeystraHandle, LIST_KEYS, MENU_KEYS, NavigationMode, NormalizedKeyEvent, TABS_KEYS_HORIZONTAL, TABS_KEYS_VERTICAL, TREE_KEYS, VERTICAL_KEYS, codeToKey, createKeyBinding, defaultKeysFor, describeEvent, formatKeyCombo, isModifierKey, isPrintableKey, mergeKeys, normalizeKeyEvent, normalizeKeyName, useKeystra };
package/dist/core.js ADDED
@@ -0,0 +1,7 @@
1
+ export { createKeyBinding, useKeystra } from './chunk-LYYUOTBP.js';
2
+ export { COMMAND_PALETTE_KEYS, EventManager, GRID_KEYS, HORIZONTAL_KEYS, ItemCollection, KeyMatcher, LIST_KEYS, MENU_KEYS, NavigationController, TABS_KEYS_HORIZONTAL, TABS_KEYS_VERTICAL, TREE_KEYS, VERTICAL_KEYS, codeToKey, createKeyMatcher, createKeystra, createRafThrottle, createRectOf, createTypeahead, defaultKeysFor, describeEvent, formatKeyCombo, isModifierKey, isPrintableKey, keyEquals, mergeKeys, normalizeKeyEvent, normalizeKeyName, parseKeyBinding, resolveOptions } from './chunk-U7YK6PPT.js';
3
+ import './chunk-XFNYIPOW.js';
4
+ import './chunk-ZOJRXXQN.js';
5
+ import './chunk-SSIKGDD4.js';
6
+ import './chunk-S5YVXIMA.js';
7
+ import './chunk-77GGU3AX.js';
@@ -0,0 +1,229 @@
1
+ import { I as ItemSelector, x as NavigationStrategyContext, n as KeyMap, p as KeySequenceInput, K as KeyAction, y as NormalizedKeyEvent, P as ParsedKeyBinding, i as KeyBinding, V as TypeaheadOptions, t as KeystraInstance, N as NavigationMode, w as NavigationStrategy, u as KeystraOptions, z as RovingOptions, A as AutoFocusOptions, J as SelectionOptions, S as SelectionController, b as Direction, E as ElementTarget, f as EventName, e as EventHandler, W as Unsubscribe } from './index-IZkcWAXP.js';
2
+ import { FocusManager } from './focus.js';
3
+ import { SelectionManager } from './selection.js';
4
+ import { L as LayoutCache, E as Emitter } from './layout-C2-n8aUI.js';
5
+
6
+ type Listener = (event: Event) => void;
7
+ declare class EventManager {
8
+ private records;
9
+ add(target: EventTarget | null | undefined, type: string, listener: Listener, options?: AddEventListenerOptions | boolean): () => void;
10
+ private removeRecord;
11
+ dispose(): void;
12
+ get count(): number;
13
+ }
14
+ declare function createRafThrottle(callback: () => void): {
15
+ schedule: () => void;
16
+ cancel: () => void;
17
+ };
18
+
19
+ interface ItemCollectionOptions<T extends Element> {
20
+ selector: ItemSelector<T>;
21
+ disabledSelector: string | null;
22
+ skipHidden: boolean;
23
+ filter?: ((element: T, index: number) => boolean) | null;
24
+ observe: boolean | MutationObserverInit;
25
+ }
26
+ declare class ItemCollection<T extends Element = HTMLElement> {
27
+ private container;
28
+ private options;
29
+ private onInvalidate?;
30
+ private list;
31
+ private extra;
32
+ private removed;
33
+ private explicit;
34
+ private built;
35
+ private observer;
36
+ private observerKey;
37
+ readonly layout: LayoutCache;
38
+ private _version;
39
+ constructor(container: Element | null, options: ItemCollectionOptions<T>, onInvalidate?: (() => void) | undefined);
40
+ get version(): number;
41
+ get items(): readonly T[];
42
+ get size(): number;
43
+ setContainer(container: Element | null): void;
44
+ setItems(elements: readonly T[] | null): void;
45
+ add(element: T | readonly T[]): void;
46
+ remove(element: T | readonly T[]): void;
47
+ invalidate(): void;
48
+ refresh(): readonly T[];
49
+ revalidate(): void;
50
+ indexOf(element: T | null | undefined): number;
51
+ at(index: number): T | null;
52
+ startObserving(): void;
53
+ stopObserving(): void;
54
+ dispose(): void;
55
+ private build;
56
+ }
57
+ declare function createRectOf<T extends Element>(collection: ItemCollection<T>): NavigationStrategyContext<T>["rectOf"];
58
+
59
+ declare function parseKeyBinding(binding: KeyBinding): ParsedKeyBinding | null;
60
+ interface MatchResult {
61
+ readonly actions: readonly KeyAction[];
62
+ readonly binding: ParsedKeyBinding;
63
+ readonly fromSequence: boolean;
64
+ readonly complete: boolean;
65
+ readonly preventDefault: boolean;
66
+ }
67
+ declare class KeyMatcher {
68
+ private readonly byId;
69
+ private readonly loose;
70
+ private readonly actions;
71
+ private readonly sequences;
72
+ private sequenceIndex;
73
+ private sequenceOwner;
74
+ private sequenceTimer;
75
+ private sequenceCandidates;
76
+ constructor(map?: KeyMap, sequences?: readonly KeySequenceInput[]);
77
+ loadMap(map: KeyMap): void;
78
+ loadSequences(sequences: readonly KeySequenceInput[]): void;
79
+ has(action: KeyAction): boolean;
80
+ get boundActions(): readonly KeyAction[];
81
+ get size(): number;
82
+ match(event: NormalizedKeyEvent, owner?: object): MatchResult | null;
83
+ resetSequence(): void;
84
+ dispose(): void;
85
+ private matchSequence;
86
+ private armSequenceTimer;
87
+ private clearSequenceTimer;
88
+ }
89
+ declare function keyEquals(bindingKey: string, eventKey: string): boolean;
90
+ declare function createKeyMatcher(map?: KeyMap, sequences?: readonly KeySequenceInput[]): KeyMatcher;
91
+
92
+ interface TypeaheadController<T extends Element = HTMLElement> {
93
+ handle(character: string, items: readonly T[], currentIndex: number): T | null;
94
+ readonly query: string;
95
+ reset(): void;
96
+ dispose(): void;
97
+ }
98
+ declare function createTypeahead<T extends Element = HTMLElement>(options?: TypeaheadOptions<T>): TypeaheadController<T>;
99
+
100
+ interface ResolvedOptions<T extends Element> {
101
+ container: Element | null;
102
+ listenTarget: EventTarget | null;
103
+ pinnedTarget: boolean;
104
+ selector: ItemSelector<T>;
105
+ disabledSelector: string | null;
106
+ skipHidden: boolean;
107
+ filter: ((element: T, index: number) => boolean) | null;
108
+ mode: NavigationMode;
109
+ loop: boolean;
110
+ columns: number;
111
+ pageSize: number;
112
+ strategy: NavigationStrategy<T>;
113
+ userStrategy: NavigationStrategy<T> | null;
114
+ onBeforeNavigate: NavigationStrategy<T> | null;
115
+ keys: KeyMap;
116
+ defaultKeys: KeyMap | null;
117
+ userKeys: KeyMap | null;
118
+ useDefaultKeys: boolean;
119
+ sequences: KeystraOptions<T>["sequences"];
120
+ typeahead: (TypeaheadOptions<T> & {
121
+ enabled: true;
122
+ }) | null;
123
+ roving: RovingOptions;
124
+ activeDescendant: boolean;
125
+ descendantOwner: (() => Element | null) | null;
126
+ autoFocus: AutoFocusOptions<T>;
127
+ selectionOptions: SelectionOptions<T> | null;
128
+ observe: boolean | MutationObserverInit;
129
+ onlyWhenFocusedInside: boolean;
130
+ when: (() => boolean) | null;
131
+ ignoreEditable: boolean;
132
+ editableSelector: string | null;
133
+ stopPropagation: boolean;
134
+ preventDefault: boolean;
135
+ capture: boolean;
136
+ pointerSync: boolean;
137
+ handlers: {
138
+ onFocus?: (element: T, index: number) => void;
139
+ onBlur?: (element: T, index: number) => void;
140
+ onSelect?: (element: T, index: number) => void;
141
+ onAction?: (action: KeyAction, event: KeyboardEvent | null, element: T | null, index: number) => void;
142
+ onEscape?: (event: KeyboardEvent | null) => void;
143
+ onRefresh?: (items: readonly T[]) => void;
144
+ };
145
+ }
146
+ declare function resolveOptions<T extends Element = HTMLElement>(options?: KeystraOptions<T>, overrides?: Partial<ResolvedOptions<T>>): ResolvedOptions<T>;
147
+ declare class NavigationController<T extends Element = HTMLElement> implements KeystraInstance<T> {
148
+ protected resolved: ResolvedOptions<T>;
149
+ protected readonly collection: ItemCollection<T>;
150
+ protected readonly focus: FocusManager<T>;
151
+ protected readonly events: EventManager;
152
+ protected readonly emitter: Emitter<T>;
153
+ protected readonly matcher: KeyMatcher;
154
+ protected typeaheadController: TypeaheadController<T> | null;
155
+ protected selectionManager: SelectionManager<T> | null;
156
+ protected keydownDisposer: (() => void) | null;
157
+ protected auxDisposers: (() => void)[];
158
+ protected syncPending: boolean;
159
+ protected destroyed: boolean;
160
+ constructor(options?: KeystraOptions<T>, overrides?: Partial<ResolvedOptions<T>>);
161
+ get container(): Element | null;
162
+ get items(): readonly T[];
163
+ get activeElement(): T | null;
164
+ get activeIndex(): number;
165
+ get currentIndex(): number;
166
+ get mode(): NavigationMode;
167
+ get loop(): boolean;
168
+ get enabled(): boolean;
169
+ get selection(): SelectionController<T> | null;
170
+ next(count?: number): T | null;
171
+ previous(count?: number): T | null;
172
+ up(): T | null;
173
+ down(): T | null;
174
+ left(): T | null;
175
+ right(): T | null;
176
+ move(direction: Direction): T | null;
177
+ first(): T | null;
178
+ last(): T | null;
179
+ focusFirst(): T | null;
180
+ focusLast(): T | null;
181
+ pageUp(): T | null;
182
+ pageDown(): T | null;
183
+ focusIndex(index: number): T | null;
184
+ setActiveIndex(index: number, options?: {
185
+ focus?: boolean;
186
+ }): T | null;
187
+ focusElement(element: T | null | undefined): boolean;
188
+ restoreFocus(): boolean;
189
+ protected rememberFocus(): void;
190
+ select(elementOrIndex?: T | number): void;
191
+ perform(action: KeyAction, event?: KeyboardEvent | null): boolean;
192
+ setContainer(container: ElementTarget<Element> | null): void;
193
+ refresh(): readonly T[];
194
+ add(element: T | readonly T[]): void;
195
+ remove(element: T | readonly T[]): void;
196
+ setItems(elements: readonly T[] | null): void;
197
+ enable(): void;
198
+ disable(): void;
199
+ update(options: Partial<Pick<KeystraOptions<T>, "keys" | "loop" | "mode" | "columns" | "enabled" | "pageSize" | "container">>): void;
200
+ on<E extends EventName>(event: E, handler: EventHandler<E, T>): Unsubscribe;
201
+ off<E extends EventName>(event: E, handler?: EventHandler<E, T>): void;
202
+ destroy(): void;
203
+ protected attach(): void;
204
+ protected detach(): void;
205
+ protected applyAutoFocus(): void;
206
+ protected onKeydown(event: KeyboardEvent): void;
207
+ protected reservedTarget(event: KeyboardEvent): boolean;
208
+ protected focusIsInside(): boolean;
209
+ protected handleTypeahead(normalized: NormalizedKeyEvent, event: KeyboardEvent): boolean;
210
+ protected runAction(action: KeyAction, event: KeyboardEvent | null, match: MatchResult | null): boolean;
211
+ protected runMovement(action: KeyAction, event: KeyboardEvent | null, items: readonly T[], fromSequence?: boolean): boolean;
212
+ protected isHeard(action: KeyAction): boolean;
213
+ protected ownsAction(_action: KeyAction): boolean;
214
+ protected emitAction(action: KeyAction, event: KeyboardEvent | null, element: T | null, index: number, fromSequence?: boolean): void;
215
+ protected afterMove(index: number, action: KeyAction, event: KeyboardEvent | null, fromSequence?: boolean): void;
216
+ protected resolveNavigation(action: KeyAction, direction: Direction | null, event: KeyboardEvent | null): number | null;
217
+ protected createContext(action: KeyAction, direction: Direction | null, event: KeyboardEvent | null): NavigationStrategyContext<T>;
218
+ protected step(delta: number, action: KeyAction | null): T | null;
219
+ protected resolveIndex(elementOrIndex?: T | number): number;
220
+ protected applySelection(index: number, extend?: boolean): void;
221
+ protected extendRangeTo(index: number): void;
222
+ protected onPointer(event: MouseEvent): void;
223
+ protected onPointerOver(event: Event): void;
224
+ protected itemFromEvent(event: Event): T | null;
225
+ protected sync(force?: boolean): void;
226
+ }
227
+ declare function createKeystra<T extends Element = HTMLElement>(options?: KeystraOptions<T>): KeystraInstance<T>;
228
+
229
+ export { EventManager as E, ItemCollection as I, KeyMatcher as K, type MatchResult as M, NavigationController as N, type ResolvedOptions as R, type TypeaheadController as T, type ItemCollectionOptions as a, createKeystra as b, createKeyMatcher as c, createRafThrottle as d, createRectOf as e, createTypeahead as f, keyEquals as k, parseKeyBinding as p, resolveOptions as r };
@@ -0,0 +1,229 @@
1
+ import { I as ItemSelector, x as NavigationStrategyContext, n as KeyMap, p as KeySequenceInput, K as KeyAction, y as NormalizedKeyEvent, P as ParsedKeyBinding, i as KeyBinding, V as TypeaheadOptions, t as KeystraInstance, N as NavigationMode, w as NavigationStrategy, u as KeystraOptions, z as RovingOptions, A as AutoFocusOptions, J as SelectionOptions, S as SelectionController, b as Direction, E as ElementTarget, f as EventName, e as EventHandler, W as Unsubscribe } from './index-IZkcWAXP.cjs';
2
+ import { FocusManager } from './focus.cjs';
3
+ import { SelectionManager } from './selection.cjs';
4
+ import { L as LayoutCache, E as Emitter } from './layout-CBzD-87D.cjs';
5
+
6
+ type Listener = (event: Event) => void;
7
+ declare class EventManager {
8
+ private records;
9
+ add(target: EventTarget | null | undefined, type: string, listener: Listener, options?: AddEventListenerOptions | boolean): () => void;
10
+ private removeRecord;
11
+ dispose(): void;
12
+ get count(): number;
13
+ }
14
+ declare function createRafThrottle(callback: () => void): {
15
+ schedule: () => void;
16
+ cancel: () => void;
17
+ };
18
+
19
+ interface ItemCollectionOptions<T extends Element> {
20
+ selector: ItemSelector<T>;
21
+ disabledSelector: string | null;
22
+ skipHidden: boolean;
23
+ filter?: ((element: T, index: number) => boolean) | null;
24
+ observe: boolean | MutationObserverInit;
25
+ }
26
+ declare class ItemCollection<T extends Element = HTMLElement> {
27
+ private container;
28
+ private options;
29
+ private onInvalidate?;
30
+ private list;
31
+ private extra;
32
+ private removed;
33
+ private explicit;
34
+ private built;
35
+ private observer;
36
+ private observerKey;
37
+ readonly layout: LayoutCache;
38
+ private _version;
39
+ constructor(container: Element | null, options: ItemCollectionOptions<T>, onInvalidate?: (() => void) | undefined);
40
+ get version(): number;
41
+ get items(): readonly T[];
42
+ get size(): number;
43
+ setContainer(container: Element | null): void;
44
+ setItems(elements: readonly T[] | null): void;
45
+ add(element: T | readonly T[]): void;
46
+ remove(element: T | readonly T[]): void;
47
+ invalidate(): void;
48
+ refresh(): readonly T[];
49
+ revalidate(): void;
50
+ indexOf(element: T | null | undefined): number;
51
+ at(index: number): T | null;
52
+ startObserving(): void;
53
+ stopObserving(): void;
54
+ dispose(): void;
55
+ private build;
56
+ }
57
+ declare function createRectOf<T extends Element>(collection: ItemCollection<T>): NavigationStrategyContext<T>["rectOf"];
58
+
59
+ declare function parseKeyBinding(binding: KeyBinding): ParsedKeyBinding | null;
60
+ interface MatchResult {
61
+ readonly actions: readonly KeyAction[];
62
+ readonly binding: ParsedKeyBinding;
63
+ readonly fromSequence: boolean;
64
+ readonly complete: boolean;
65
+ readonly preventDefault: boolean;
66
+ }
67
+ declare class KeyMatcher {
68
+ private readonly byId;
69
+ private readonly loose;
70
+ private readonly actions;
71
+ private readonly sequences;
72
+ private sequenceIndex;
73
+ private sequenceOwner;
74
+ private sequenceTimer;
75
+ private sequenceCandidates;
76
+ constructor(map?: KeyMap, sequences?: readonly KeySequenceInput[]);
77
+ loadMap(map: KeyMap): void;
78
+ loadSequences(sequences: readonly KeySequenceInput[]): void;
79
+ has(action: KeyAction): boolean;
80
+ get boundActions(): readonly KeyAction[];
81
+ get size(): number;
82
+ match(event: NormalizedKeyEvent, owner?: object): MatchResult | null;
83
+ resetSequence(): void;
84
+ dispose(): void;
85
+ private matchSequence;
86
+ private armSequenceTimer;
87
+ private clearSequenceTimer;
88
+ }
89
+ declare function keyEquals(bindingKey: string, eventKey: string): boolean;
90
+ declare function createKeyMatcher(map?: KeyMap, sequences?: readonly KeySequenceInput[]): KeyMatcher;
91
+
92
+ interface TypeaheadController<T extends Element = HTMLElement> {
93
+ handle(character: string, items: readonly T[], currentIndex: number): T | null;
94
+ readonly query: string;
95
+ reset(): void;
96
+ dispose(): void;
97
+ }
98
+ declare function createTypeahead<T extends Element = HTMLElement>(options?: TypeaheadOptions<T>): TypeaheadController<T>;
99
+
100
+ interface ResolvedOptions<T extends Element> {
101
+ container: Element | null;
102
+ listenTarget: EventTarget | null;
103
+ pinnedTarget: boolean;
104
+ selector: ItemSelector<T>;
105
+ disabledSelector: string | null;
106
+ skipHidden: boolean;
107
+ filter: ((element: T, index: number) => boolean) | null;
108
+ mode: NavigationMode;
109
+ loop: boolean;
110
+ columns: number;
111
+ pageSize: number;
112
+ strategy: NavigationStrategy<T>;
113
+ userStrategy: NavigationStrategy<T> | null;
114
+ onBeforeNavigate: NavigationStrategy<T> | null;
115
+ keys: KeyMap;
116
+ defaultKeys: KeyMap | null;
117
+ userKeys: KeyMap | null;
118
+ useDefaultKeys: boolean;
119
+ sequences: KeystraOptions<T>["sequences"];
120
+ typeahead: (TypeaheadOptions<T> & {
121
+ enabled: true;
122
+ }) | null;
123
+ roving: RovingOptions;
124
+ activeDescendant: boolean;
125
+ descendantOwner: (() => Element | null) | null;
126
+ autoFocus: AutoFocusOptions<T>;
127
+ selectionOptions: SelectionOptions<T> | null;
128
+ observe: boolean | MutationObserverInit;
129
+ onlyWhenFocusedInside: boolean;
130
+ when: (() => boolean) | null;
131
+ ignoreEditable: boolean;
132
+ editableSelector: string | null;
133
+ stopPropagation: boolean;
134
+ preventDefault: boolean;
135
+ capture: boolean;
136
+ pointerSync: boolean;
137
+ handlers: {
138
+ onFocus?: (element: T, index: number) => void;
139
+ onBlur?: (element: T, index: number) => void;
140
+ onSelect?: (element: T, index: number) => void;
141
+ onAction?: (action: KeyAction, event: KeyboardEvent | null, element: T | null, index: number) => void;
142
+ onEscape?: (event: KeyboardEvent | null) => void;
143
+ onRefresh?: (items: readonly T[]) => void;
144
+ };
145
+ }
146
+ declare function resolveOptions<T extends Element = HTMLElement>(options?: KeystraOptions<T>, overrides?: Partial<ResolvedOptions<T>>): ResolvedOptions<T>;
147
+ declare class NavigationController<T extends Element = HTMLElement> implements KeystraInstance<T> {
148
+ protected resolved: ResolvedOptions<T>;
149
+ protected readonly collection: ItemCollection<T>;
150
+ protected readonly focus: FocusManager<T>;
151
+ protected readonly events: EventManager;
152
+ protected readonly emitter: Emitter<T>;
153
+ protected readonly matcher: KeyMatcher;
154
+ protected typeaheadController: TypeaheadController<T> | null;
155
+ protected selectionManager: SelectionManager<T> | null;
156
+ protected keydownDisposer: (() => void) | null;
157
+ protected auxDisposers: (() => void)[];
158
+ protected syncPending: boolean;
159
+ protected destroyed: boolean;
160
+ constructor(options?: KeystraOptions<T>, overrides?: Partial<ResolvedOptions<T>>);
161
+ get container(): Element | null;
162
+ get items(): readonly T[];
163
+ get activeElement(): T | null;
164
+ get activeIndex(): number;
165
+ get currentIndex(): number;
166
+ get mode(): NavigationMode;
167
+ get loop(): boolean;
168
+ get enabled(): boolean;
169
+ get selection(): SelectionController<T> | null;
170
+ next(count?: number): T | null;
171
+ previous(count?: number): T | null;
172
+ up(): T | null;
173
+ down(): T | null;
174
+ left(): T | null;
175
+ right(): T | null;
176
+ move(direction: Direction): T | null;
177
+ first(): T | null;
178
+ last(): T | null;
179
+ focusFirst(): T | null;
180
+ focusLast(): T | null;
181
+ pageUp(): T | null;
182
+ pageDown(): T | null;
183
+ focusIndex(index: number): T | null;
184
+ setActiveIndex(index: number, options?: {
185
+ focus?: boolean;
186
+ }): T | null;
187
+ focusElement(element: T | null | undefined): boolean;
188
+ restoreFocus(): boolean;
189
+ protected rememberFocus(): void;
190
+ select(elementOrIndex?: T | number): void;
191
+ perform(action: KeyAction, event?: KeyboardEvent | null): boolean;
192
+ setContainer(container: ElementTarget<Element> | null): void;
193
+ refresh(): readonly T[];
194
+ add(element: T | readonly T[]): void;
195
+ remove(element: T | readonly T[]): void;
196
+ setItems(elements: readonly T[] | null): void;
197
+ enable(): void;
198
+ disable(): void;
199
+ update(options: Partial<Pick<KeystraOptions<T>, "keys" | "loop" | "mode" | "columns" | "enabled" | "pageSize" | "container">>): void;
200
+ on<E extends EventName>(event: E, handler: EventHandler<E, T>): Unsubscribe;
201
+ off<E extends EventName>(event: E, handler?: EventHandler<E, T>): void;
202
+ destroy(): void;
203
+ protected attach(): void;
204
+ protected detach(): void;
205
+ protected applyAutoFocus(): void;
206
+ protected onKeydown(event: KeyboardEvent): void;
207
+ protected reservedTarget(event: KeyboardEvent): boolean;
208
+ protected focusIsInside(): boolean;
209
+ protected handleTypeahead(normalized: NormalizedKeyEvent, event: KeyboardEvent): boolean;
210
+ protected runAction(action: KeyAction, event: KeyboardEvent | null, match: MatchResult | null): boolean;
211
+ protected runMovement(action: KeyAction, event: KeyboardEvent | null, items: readonly T[], fromSequence?: boolean): boolean;
212
+ protected isHeard(action: KeyAction): boolean;
213
+ protected ownsAction(_action: KeyAction): boolean;
214
+ protected emitAction(action: KeyAction, event: KeyboardEvent | null, element: T | null, index: number, fromSequence?: boolean): void;
215
+ protected afterMove(index: number, action: KeyAction, event: KeyboardEvent | null, fromSequence?: boolean): void;
216
+ protected resolveNavigation(action: KeyAction, direction: Direction | null, event: KeyboardEvent | null): number | null;
217
+ protected createContext(action: KeyAction, direction: Direction | null, event: KeyboardEvent | null): NavigationStrategyContext<T>;
218
+ protected step(delta: number, action: KeyAction | null): T | null;
219
+ protected resolveIndex(elementOrIndex?: T | number): number;
220
+ protected applySelection(index: number, extend?: boolean): void;
221
+ protected extendRangeTo(index: number): void;
222
+ protected onPointer(event: MouseEvent): void;
223
+ protected onPointerOver(event: Event): void;
224
+ protected itemFromEvent(event: Event): T | null;
225
+ protected sync(force?: boolean): void;
226
+ }
227
+ declare function createKeystra<T extends Element = HTMLElement>(options?: KeystraOptions<T>): KeystraInstance<T>;
228
+
229
+ export { EventManager as E, ItemCollection as I, KeyMatcher as K, type MatchResult as M, NavigationController as N, type ResolvedOptions as R, type TypeaheadController as T, type ItemCollectionOptions as a, createKeystra as b, createKeyMatcher as c, createRafThrottle as d, createRectOf as e, createTypeahead as f, keyEquals as k, parseKeyBinding as p, resolveOptions as r };