use-kbd 0.4.0 → 0.5.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.
- package/dist/index.cjs +812 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +254 -33
- package/dist/index.d.ts +254 -33
- package/dist/index.js +810 -165
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/styles.css +48 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as react from 'react';
|
|
3
2
|
import { ReactNode, ComponentType, RefObject, SVGProps, CSSProperties } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Modifier keys state
|
|
@@ -24,7 +24,6 @@ interface KeyCombination {
|
|
|
24
24
|
* Represents a hotkey - either a single key or a sequence of keys.
|
|
25
25
|
* Single key: [{ key: 'k', modifiers: {...} }]
|
|
26
26
|
* Sequence: [{ key: '2', ... }, { key: 'w', ... }]
|
|
27
|
-
* @deprecated Use KeySeq for new code
|
|
28
27
|
*/
|
|
29
28
|
type HotkeySequence = KeyCombination[];
|
|
30
29
|
/**
|
|
@@ -118,10 +117,6 @@ interface RecordHotkeyResult {
|
|
|
118
117
|
activeKeys: KeyCombination | null;
|
|
119
118
|
/** The timeout duration for sequences (ms) */
|
|
120
119
|
sequenceTimeout: number;
|
|
121
|
-
/**
|
|
122
|
-
* @deprecated Use `sequence` instead
|
|
123
|
-
*/
|
|
124
|
-
combination: KeyCombination | null;
|
|
125
120
|
}
|
|
126
121
|
/**
|
|
127
122
|
* Options for useRecordHotkey
|
|
@@ -160,6 +155,8 @@ interface ActionDefinition {
|
|
|
160
155
|
icon?: string;
|
|
161
156
|
/** Whether the action is currently enabled (default: true) */
|
|
162
157
|
enabled?: boolean;
|
|
158
|
+
/** Hide from ShortcutsModal (still searchable in omnibar) */
|
|
159
|
+
hideFromModal?: boolean;
|
|
163
160
|
}
|
|
164
161
|
/**
|
|
165
162
|
* Registry of all available actions
|
|
@@ -184,14 +181,102 @@ interface ActionSearchResult {
|
|
|
184
181
|
* A possible completion for a partially-typed sequence
|
|
185
182
|
*/
|
|
186
183
|
interface SequenceCompletion {
|
|
187
|
-
/** The next key(s) needed to complete this sequence */
|
|
184
|
+
/** The next key(s) needed to complete this sequence (empty string if complete) */
|
|
188
185
|
nextKeys: string;
|
|
186
|
+
/** Structured next keys for rendering with icons (undefined if complete) */
|
|
187
|
+
nextKeySeq?: KeySeq;
|
|
189
188
|
/** The full hotkey string */
|
|
190
189
|
fullSequence: string;
|
|
191
190
|
/** Display format for the full sequence */
|
|
192
191
|
display: KeyCombinationDisplay;
|
|
193
192
|
/** Actions triggered by this sequence */
|
|
194
193
|
actions: string[];
|
|
194
|
+
/** Whether the sequence is already complete (can be executed now with Enter) */
|
|
195
|
+
isComplete: boolean;
|
|
196
|
+
/** Captured digit values from \d and \d+ placeholders */
|
|
197
|
+
captures?: number[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Base fields for all omnibar entries
|
|
201
|
+
*/
|
|
202
|
+
interface OmnibarEntryBase {
|
|
203
|
+
/** Unique identifier for this entry */
|
|
204
|
+
id: string;
|
|
205
|
+
/** Display label */
|
|
206
|
+
label: string;
|
|
207
|
+
/** Optional description (shown below label) */
|
|
208
|
+
description?: string;
|
|
209
|
+
/** Group name for organizing results */
|
|
210
|
+
group?: string;
|
|
211
|
+
/** Additional search keywords */
|
|
212
|
+
keywords?: string[];
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Omnibar entry that navigates to a URL when selected
|
|
216
|
+
*/
|
|
217
|
+
interface OmnibarLinkEntry extends OmnibarEntryBase {
|
|
218
|
+
/** URL to navigate to */
|
|
219
|
+
href: string;
|
|
220
|
+
handler?: never;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Omnibar entry that executes a handler when selected
|
|
224
|
+
*/
|
|
225
|
+
interface OmnibarActionEntry extends OmnibarEntryBase {
|
|
226
|
+
/** Handler to execute (can close over data) */
|
|
227
|
+
handler: () => void;
|
|
228
|
+
href?: never;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* An entry returned from a remote omnibar endpoint.
|
|
232
|
+
* Must have either `href` (for navigation) or `handler` (for custom action).
|
|
233
|
+
*/
|
|
234
|
+
type OmnibarEntry = OmnibarLinkEntry | OmnibarActionEntry;
|
|
235
|
+
/**
|
|
236
|
+
* Pagination parameters passed to endpoint fetch function
|
|
237
|
+
*/
|
|
238
|
+
interface EndpointPagination {
|
|
239
|
+
/** Starting offset (0-indexed) */
|
|
240
|
+
offset: number;
|
|
241
|
+
/** Maximum number of entries to return */
|
|
242
|
+
limit: number;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Response from an endpoint fetch, including pagination metadata
|
|
246
|
+
*/
|
|
247
|
+
interface EndpointResponse {
|
|
248
|
+
/** Entries for this page */
|
|
249
|
+
entries: OmnibarEntry[];
|
|
250
|
+
/** Total count if known (enables "X of Y" display) */
|
|
251
|
+
total?: number;
|
|
252
|
+
/** Whether more results exist (fallback when total is expensive to compute) */
|
|
253
|
+
hasMore?: boolean;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Pagination mode for an endpoint
|
|
257
|
+
* - 'scroll': Fetch more when scrolling near bottom (IntersectionObserver)
|
|
258
|
+
* - 'buttons': Show pagination controls at bottom of endpoint's group
|
|
259
|
+
* - 'none': Single page, no pagination (default)
|
|
260
|
+
*/
|
|
261
|
+
type EndpointPaginationMode = 'scroll' | 'buttons' | 'none';
|
|
262
|
+
/**
|
|
263
|
+
* Configuration for a remote omnibar endpoint
|
|
264
|
+
*/
|
|
265
|
+
interface OmnibarEndpointConfig {
|
|
266
|
+
/** Fetch function that returns entries for a query */
|
|
267
|
+
fetch: (query: string, signal: AbortSignal, pagination: EndpointPagination) => Promise<EndpointResponse>;
|
|
268
|
+
/** Default group for entries from this endpoint */
|
|
269
|
+
group?: string;
|
|
270
|
+
/** Priority for result ordering (higher = shown first, default: 0, local actions: 100) */
|
|
271
|
+
priority?: number;
|
|
272
|
+
/** Minimum query length before fetching (default: 2) */
|
|
273
|
+
minQueryLength?: number;
|
|
274
|
+
/** Whether this endpoint is enabled (default: true) */
|
|
275
|
+
enabled?: boolean;
|
|
276
|
+
/** Number of results per page (default: 10) */
|
|
277
|
+
pageSize?: number;
|
|
278
|
+
/** Pagination mode (default: 'none') */
|
|
279
|
+
pagination?: EndpointPaginationMode;
|
|
195
280
|
}
|
|
196
281
|
|
|
197
282
|
/**
|
|
@@ -306,6 +391,70 @@ interface UseEditableHotkeysResult {
|
|
|
306
391
|
*/
|
|
307
392
|
declare function useEditableHotkeys(defaults: HotkeyMap, handlers: HandlerMap, options?: UseEditableHotkeysOptions): UseEditableHotkeysResult;
|
|
308
393
|
|
|
394
|
+
interface RegisteredEndpoint {
|
|
395
|
+
id: string;
|
|
396
|
+
config: OmnibarEndpointConfig;
|
|
397
|
+
registeredAt: number;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Result from querying an endpoint
|
|
401
|
+
*/
|
|
402
|
+
interface EndpointQueryResult {
|
|
403
|
+
endpointId: string;
|
|
404
|
+
entries: OmnibarEntry[];
|
|
405
|
+
/** Total count from endpoint (if provided) */
|
|
406
|
+
total?: number;
|
|
407
|
+
/** Whether endpoint has more results (if provided) */
|
|
408
|
+
hasMore?: boolean;
|
|
409
|
+
error?: Error;
|
|
410
|
+
}
|
|
411
|
+
interface OmnibarEndpointsRegistryValue {
|
|
412
|
+
/** Register an endpoint. Called by useOmnibarEndpoint on mount. */
|
|
413
|
+
register: (id: string, config: OmnibarEndpointConfig) => void;
|
|
414
|
+
/** Unregister an endpoint. Called by useOmnibarEndpoint on unmount. */
|
|
415
|
+
unregister: (id: string) => void;
|
|
416
|
+
/** Currently registered endpoints */
|
|
417
|
+
endpoints: Map<string, RegisteredEndpoint>;
|
|
418
|
+
/** Query all registered endpoints (initial page) */
|
|
419
|
+
queryAll: (query: string, signal: AbortSignal) => Promise<EndpointQueryResult[]>;
|
|
420
|
+
/** Query a single endpoint with specific pagination (for load-more) */
|
|
421
|
+
queryEndpoint: (endpointId: string, query: string, pagination: EndpointPagination, signal: AbortSignal) => Promise<EndpointQueryResult | null>;
|
|
422
|
+
}
|
|
423
|
+
declare const OmnibarEndpointsRegistryContext: react.Context<OmnibarEndpointsRegistryValue | null>;
|
|
424
|
+
/**
|
|
425
|
+
* Hook to create an omnibar endpoints registry.
|
|
426
|
+
* Used internally by HotkeysProvider.
|
|
427
|
+
*/
|
|
428
|
+
declare function useOmnibarEndpointsRegistry(): OmnibarEndpointsRegistryValue;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Result from remote endpoint, normalized for display
|
|
432
|
+
*/
|
|
433
|
+
interface RemoteOmnibarResult {
|
|
434
|
+
/** Unique ID (prefixed with endpoint ID) */
|
|
435
|
+
id: string;
|
|
436
|
+
/** Entry data from endpoint */
|
|
437
|
+
entry: OmnibarEntry;
|
|
438
|
+
/** Endpoint ID this came from */
|
|
439
|
+
endpointId: string;
|
|
440
|
+
/** Priority from endpoint config */
|
|
441
|
+
priority: number;
|
|
442
|
+
/** Fuzzy match score */
|
|
443
|
+
score: number;
|
|
444
|
+
/** Matched ranges in label for highlighting */
|
|
445
|
+
labelMatches: Array<[number, number]>;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Pagination info for an endpoint's results group
|
|
449
|
+
*/
|
|
450
|
+
interface EndpointPaginationInfo {
|
|
451
|
+
endpointId: string;
|
|
452
|
+
loaded: number;
|
|
453
|
+
total?: number;
|
|
454
|
+
hasMore: boolean;
|
|
455
|
+
isLoading: boolean;
|
|
456
|
+
mode: EndpointPaginationMode;
|
|
457
|
+
}
|
|
309
458
|
interface UseOmnibarOptions {
|
|
310
459
|
/** Registry of available actions */
|
|
311
460
|
actions: ActionRegistry;
|
|
@@ -319,12 +468,18 @@ interface UseOmnibarOptions {
|
|
|
319
468
|
enabled?: boolean;
|
|
320
469
|
/** Called when an action is executed (if handlers not provided, or in addition to) */
|
|
321
470
|
onExecute?: (actionId: string) => void;
|
|
471
|
+
/** Called when a remote entry is executed */
|
|
472
|
+
onExecuteRemote?: (entry: OmnibarEntry) => void;
|
|
322
473
|
/** Called when omnibar opens */
|
|
323
474
|
onOpen?: () => void;
|
|
324
475
|
/** Called when omnibar closes */
|
|
325
476
|
onClose?: () => void;
|
|
326
477
|
/** Maximum number of results to show (default: 10) */
|
|
327
478
|
maxResults?: number;
|
|
479
|
+
/** Remote endpoints registry (optional - enables remote search) */
|
|
480
|
+
endpointsRegistry?: OmnibarEndpointsRegistryValue;
|
|
481
|
+
/** Debounce time for remote queries in ms (default: 150) */
|
|
482
|
+
debounceMs?: number;
|
|
328
483
|
}
|
|
329
484
|
interface UseOmnibarResult {
|
|
330
485
|
/** Whether omnibar is open */
|
|
@@ -339,10 +494,20 @@ interface UseOmnibarResult {
|
|
|
339
494
|
query: string;
|
|
340
495
|
/** Set the search query */
|
|
341
496
|
setQuery: (query: string) => void;
|
|
342
|
-
/**
|
|
497
|
+
/** Local action search results (filtered and sorted) */
|
|
343
498
|
results: ActionSearchResult[];
|
|
344
|
-
/**
|
|
499
|
+
/** Remote endpoint results */
|
|
500
|
+
remoteResults: RemoteOmnibarResult[];
|
|
501
|
+
/** Whether any remote endpoint is loading (initial or more) */
|
|
502
|
+
isLoadingRemote: boolean;
|
|
503
|
+
/** Pagination info per endpoint */
|
|
504
|
+
endpointPagination: Map<string, EndpointPaginationInfo>;
|
|
505
|
+
/** Load more results for a specific endpoint */
|
|
506
|
+
loadMore: (endpointId: string) => void;
|
|
507
|
+
/** Currently selected result index (across local + remote) */
|
|
345
508
|
selectedIndex: number;
|
|
509
|
+
/** Total number of results (local + remote) */
|
|
510
|
+
totalResults: number;
|
|
346
511
|
/** Select the next result */
|
|
347
512
|
selectNext: () => void;
|
|
348
513
|
/** Select the previous result */
|
|
@@ -733,10 +898,15 @@ interface OmnibarProps {
|
|
|
733
898
|
*/
|
|
734
899
|
onClose?: () => void;
|
|
735
900
|
/**
|
|
736
|
-
* Called when
|
|
901
|
+
* Called when a local action is executed.
|
|
737
902
|
* If not provided, uses executeAction from HotkeysContext.
|
|
738
903
|
*/
|
|
739
904
|
onExecute?: (actionId: string) => void;
|
|
905
|
+
/**
|
|
906
|
+
* Called when a remote omnibar entry is executed.
|
|
907
|
+
* Use this to handle navigation for entries with `href`.
|
|
908
|
+
*/
|
|
909
|
+
onExecuteRemote?: (entry: OmnibarEntry) => void;
|
|
740
910
|
/** Maximum number of results to show (default: 10) */
|
|
741
911
|
maxResults?: number;
|
|
742
912
|
/** Placeholder text for input (default: 'Type a command...') */
|
|
@@ -751,8 +921,20 @@ interface OmnibarProps {
|
|
|
751
921
|
interface OmnibarRenderProps {
|
|
752
922
|
query: string;
|
|
753
923
|
setQuery: (query: string) => void;
|
|
924
|
+
/** Local action search results */
|
|
754
925
|
results: ActionSearchResult[];
|
|
926
|
+
/** Remote endpoint results */
|
|
927
|
+
remoteResults: RemoteOmnibarResult[];
|
|
928
|
+
/** Whether remote endpoints are being queried */
|
|
929
|
+
isLoadingRemote: boolean;
|
|
930
|
+
/** Pagination info per endpoint */
|
|
931
|
+
endpointPagination: Map<string, EndpointPaginationInfo>;
|
|
932
|
+
/** Load more results for a specific endpoint */
|
|
933
|
+
loadMore: (endpointId: string) => void;
|
|
934
|
+
/** Currently selected index (across local + remote) */
|
|
755
935
|
selectedIndex: number;
|
|
936
|
+
/** Total number of results (local + remote) */
|
|
937
|
+
totalResults: number;
|
|
756
938
|
selectNext: () => void;
|
|
757
939
|
selectPrev: () => void;
|
|
758
940
|
execute: (actionId?: string) => void;
|
|
@@ -796,7 +978,7 @@ interface OmnibarRenderProps {
|
|
|
796
978
|
* />
|
|
797
979
|
* ```
|
|
798
980
|
*/
|
|
799
|
-
declare function Omnibar({ actions: actionsProp, handlers: handlersProp, keymap: keymapProp, defaultBinding, isOpen: isOpenProp, onOpen: onOpenProp, onClose: onCloseProp, onExecute: onExecuteProp, maxResults, placeholder, children, backdropClassName, omnibarClassName, }: OmnibarProps): react_jsx_runtime.JSX.Element | null;
|
|
981
|
+
declare function Omnibar({ actions: actionsProp, handlers: handlersProp, keymap: keymapProp, defaultBinding, isOpen: isOpenProp, onOpen: onOpenProp, onClose: onCloseProp, onExecute: onExecuteProp, onExecuteRemote: onExecuteRemoteProp, maxResults, placeholder, children, backdropClassName, omnibarClassName, }: OmnibarProps): react_jsx_runtime.JSX.Element | null;
|
|
800
982
|
|
|
801
983
|
/**
|
|
802
984
|
* Check if a key is a shifted symbol (requires Shift on US keyboard).
|
|
@@ -804,7 +986,7 @@ declare function Omnibar({ actions: actionsProp, handlers: handlersProp, keymap:
|
|
|
804
986
|
*/
|
|
805
987
|
declare function isShiftedSymbol(key: string): boolean;
|
|
806
988
|
/**
|
|
807
|
-
* Detect if running on macOS
|
|
989
|
+
* Detect if running on macOS/iOS
|
|
808
990
|
*/
|
|
809
991
|
declare function isMac(): boolean;
|
|
810
992
|
/**
|
|
@@ -854,11 +1036,6 @@ declare function isSequence(hotkeyStr: string): boolean;
|
|
|
854
1036
|
* Handles both single keys ("ctrl+k") and sequences ("2 w", "ctrl+k ctrl+c")
|
|
855
1037
|
*/
|
|
856
1038
|
declare function parseHotkeyString(hotkeyStr: string): HotkeySequence;
|
|
857
|
-
/**
|
|
858
|
-
* Parse a combination ID back to a KeyCombination (single key only)
|
|
859
|
-
* @deprecated Use parseHotkeyString for sequence support
|
|
860
|
-
*/
|
|
861
|
-
declare function parseCombinationId(id: string): KeyCombination;
|
|
862
1039
|
/**
|
|
863
1040
|
* Parse a hotkey string to a KeySeq (new sequence type with digit placeholders).
|
|
864
1041
|
* Handles both single keys ("ctrl+k") and sequences ("2 w", "\\d+ d")
|
|
@@ -920,16 +1097,17 @@ declare function getConflictsArray(keymap: Record<string, string | string[]>): K
|
|
|
920
1097
|
|
|
921
1098
|
/**
|
|
922
1099
|
* Get possible completions for a partially-typed sequence.
|
|
1100
|
+
* Returns both exact matches (isComplete: true) and continuations (isComplete: false).
|
|
923
1101
|
*
|
|
924
1102
|
* @example
|
|
925
1103
|
* ```tsx
|
|
926
|
-
* const keymap = { '
|
|
927
|
-
* const pending = parseHotkeyString('
|
|
1104
|
+
* const keymap = { 'h': 'humidity', 'h \\d+': 'nHours', '2 w': 'twoWeeks' }
|
|
1105
|
+
* const pending = parseHotkeyString('h')
|
|
928
1106
|
* const completions = getSequenceCompletions(pending, keymap)
|
|
929
1107
|
* // Returns:
|
|
930
1108
|
* // [
|
|
931
|
-
* // { nextKeys: '
|
|
932
|
-
* // { nextKeys: '
|
|
1109
|
+
* // { nextKeys: '', fullSequence: 'h', actions: ['humidity'], isComplete: true },
|
|
1110
|
+
* // { nextKeys: '⟨##⟩', fullSequence: 'h \\d+', actions: ['nHours'], isComplete: false },
|
|
933
1111
|
* // ]
|
|
934
1112
|
* ```
|
|
935
1113
|
*/
|
|
@@ -1002,6 +1180,8 @@ interface ActionConfig {
|
|
|
1002
1180
|
enabled?: boolean;
|
|
1003
1181
|
/** Priority for conflict resolution (higher wins, default: 0) */
|
|
1004
1182
|
priority?: number;
|
|
1183
|
+
/** Hide from ShortcutsModal (still searchable in omnibar) */
|
|
1184
|
+
hideFromModal?: boolean;
|
|
1005
1185
|
}
|
|
1006
1186
|
/**
|
|
1007
1187
|
* Register an action with the hotkeys system.
|
|
@@ -1054,8 +1234,8 @@ interface ActionsRegistryValue {
|
|
|
1054
1234
|
register: (id: string, config: ActionConfig) => void;
|
|
1055
1235
|
/** Unregister an action. Called by useAction on unmount. */
|
|
1056
1236
|
unregister: (id: string) => void;
|
|
1057
|
-
/** Execute an action by ID */
|
|
1058
|
-
execute: (id: string) => void;
|
|
1237
|
+
/** Execute an action by ID, optionally with captured digit values */
|
|
1238
|
+
execute: (id: string, captures?: number[]) => void;
|
|
1059
1239
|
/** Currently registered actions */
|
|
1060
1240
|
actions: Map<string, RegisteredAction>;
|
|
1061
1241
|
/** Computed keymap from registered actions + user overrides */
|
|
@@ -1107,6 +1287,8 @@ interface HotkeysConfig {
|
|
|
1107
1287
|
interface HotkeysContextValue {
|
|
1108
1288
|
/** The actions registry */
|
|
1109
1289
|
registry: ActionsRegistryValue;
|
|
1290
|
+
/** The omnibar endpoints registry */
|
|
1291
|
+
endpointsRegistry: OmnibarEndpointsRegistryValue;
|
|
1110
1292
|
/** Whether hotkeys are enabled (based on viewport/touch) */
|
|
1111
1293
|
isEnabled: boolean;
|
|
1112
1294
|
/** Modal open state */
|
|
@@ -1138,7 +1320,7 @@ interface HotkeysContextValue {
|
|
|
1138
1320
|
/** Toggle the lookup modal */
|
|
1139
1321
|
toggleLookup: () => void;
|
|
1140
1322
|
/** Execute an action by ID */
|
|
1141
|
-
executeAction: (id: string) => void;
|
|
1323
|
+
executeAction: (id: string, captures?: number[]) => void;
|
|
1142
1324
|
/** Sequence state: pending key combinations */
|
|
1143
1325
|
pendingKeys: HotkeySequence;
|
|
1144
1326
|
/** Sequence state: whether waiting for more keys */
|
|
@@ -1205,6 +1387,44 @@ declare function useHotkeysContext(): HotkeysContextValue;
|
|
|
1205
1387
|
*/
|
|
1206
1388
|
declare function useMaybeHotkeysContext(): HotkeysContextValue | null;
|
|
1207
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* Register a remote omnibar endpoint.
|
|
1392
|
+
*
|
|
1393
|
+
* Endpoints are automatically unregistered when the component unmounts,
|
|
1394
|
+
* making this ideal for colocating search providers with their data context.
|
|
1395
|
+
*
|
|
1396
|
+
* @example
|
|
1397
|
+
* ```tsx
|
|
1398
|
+
* function UsersPage() {
|
|
1399
|
+
* const navigate = useNavigate()
|
|
1400
|
+
*
|
|
1401
|
+
* useOmnibarEndpoint('users', {
|
|
1402
|
+
* fetch: async (query, signal, pagination) => {
|
|
1403
|
+
* const res = await fetch(`/api/users?q=${query}&offset=${pagination.offset}&limit=${pagination.limit}`, { signal })
|
|
1404
|
+
* const { users, total } = await res.json()
|
|
1405
|
+
* return {
|
|
1406
|
+
* entries: users.map(u => ({
|
|
1407
|
+
* id: `user:${u.id}`,
|
|
1408
|
+
* label: u.name,
|
|
1409
|
+
* description: u.email,
|
|
1410
|
+
* handler: () => navigate(`/users/${u.id}`),
|
|
1411
|
+
* })),
|
|
1412
|
+
* total,
|
|
1413
|
+
* hasMore: pagination.offset + users.length < total,
|
|
1414
|
+
* }
|
|
1415
|
+
* },
|
|
1416
|
+
* group: 'Users',
|
|
1417
|
+
* priority: 10,
|
|
1418
|
+
* pageSize: 10,
|
|
1419
|
+
* pagination: 'scroll',
|
|
1420
|
+
* })
|
|
1421
|
+
*
|
|
1422
|
+
* return <UsersList />
|
|
1423
|
+
* }
|
|
1424
|
+
* ```
|
|
1425
|
+
*/
|
|
1426
|
+
declare function useOmnibarEndpoint(id: string, config: OmnibarEndpointConfig): void;
|
|
1427
|
+
|
|
1208
1428
|
/**
|
|
1209
1429
|
* Hook to record a keyboard shortcut (single key or sequence) from user input.
|
|
1210
1430
|
*
|
|
@@ -1335,14 +1555,15 @@ declare function LookupModal({ defaultBinding }?: LookupModalProps): react_jsx_r
|
|
|
1335
1555
|
* When a user presses a key that starts a sequence, this modal appears showing:
|
|
1336
1556
|
* - The keys pressed so far
|
|
1337
1557
|
* - Available completions (what keys can come next)
|
|
1338
|
-
* - A timeout indicator
|
|
1558
|
+
* - A timeout indicator (only shown when exactly one completion exists)
|
|
1339
1559
|
*
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1560
|
+
* Features:
|
|
1561
|
+
* - Arrow keys navigate between completions (cancels auto-timeout)
|
|
1562
|
+
* - Enter executes the selected completion (even for digit patterns - handler gets undefined captures)
|
|
1563
|
+
* - Escape cancels the sequence
|
|
1343
1564
|
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1565
|
+
* Unlike LookupModal (which requires explicit activation and lets you browse/search),
|
|
1566
|
+
* SequenceModal appears automatically when you start typing a sequence.
|
|
1346
1567
|
*
|
|
1347
1568
|
* @example
|
|
1348
1569
|
* ```tsx
|
|
@@ -1393,9 +1614,9 @@ declare function Right({ className, style }: KeyIconProps): react_jsx_runtime.JS
|
|
|
1393
1614
|
declare function Enter({ className, style }: KeyIconProps): react_jsx_runtime.JSX.Element;
|
|
1394
1615
|
/** Backspace icon (⌫) */
|
|
1395
1616
|
declare function Backspace({ className, style }: KeyIconProps): react_jsx_runtime.JSX.Element;
|
|
1396
|
-
type KeyIconType = 'arrowup' | 'arrowdown' | 'arrowleft' | 'arrowright' | 'enter' | 'backspace';
|
|
1617
|
+
type KeyIconType = 'arrowup' | 'arrowdown' | 'arrowleft' | 'arrowright' | 'enter' | 'backspace' | 'tab';
|
|
1397
1618
|
/** Get the icon component for a key, or null if no icon exists */
|
|
1398
|
-
declare function getKeyIcon(key: string):
|
|
1619
|
+
declare function getKeyIcon(key: string): ComponentType<KeyIconProps> | null;
|
|
1399
1620
|
|
|
1400
1621
|
/**
|
|
1401
1622
|
* Default timeout for key sequences (no timeout).
|
|
@@ -1410,4 +1631,4 @@ declare const ACTION_MODAL = "__hotkeys:modal";
|
|
|
1410
1631
|
declare const ACTION_OMNIBAR = "__hotkeys:omnibar";
|
|
1411
1632
|
declare const ACTION_LOOKUP = "__hotkeys:lookup";
|
|
1412
1633
|
|
|
1413
|
-
export { ACTION_LOOKUP, ACTION_MODAL, ACTION_OMNIBAR, type ActionConfig, type ActionDefinition, type ActionHandler, type ActionRegistry, type ActionSearchResult, ActionsRegistryContext, type ActionsRegistryValue, Alt, Backspace, type BindingInfo, Command, Ctrl, DEFAULT_SEQUENCE_TIMEOUT, DIGITS_PLACEHOLDER, DIGIT_PLACEHOLDER, Down, Enter, type FuzzyMatchResult, type GroupRenderer, type GroupRendererProps, type HandlerMap, type HotkeyHandler, type HotkeyMap, type HotkeySequence, type HotkeysConfig, type HotkeysContextValue, HotkeysProvider, type HotkeysProviderProps, Kbd, KbdLookup, KbdModal, KbdOmnibar, type KbdProps, Kbds, Key, type KeyCombination, type KeyCombinationDisplay, type KeyConflict, type KeyIconProps, type KeyIconType, type KeySeq, KeybindingEditor, type KeybindingEditorProps, type KeybindingEditorRenderProps, Left, LookupModal, ModifierIcon, type ModifierIconProps, type ModifierType, type Modifiers, Omnibar, type OmnibarProps, type OmnibarRenderProps, Option, type RecordHotkeyOptions, type RecordHotkeyResult, type RegisteredAction, Right, type SeqElem, type SeqElemState, type SeqMatchState, type SequenceCompletion, SequenceModal, Shift, type ShortcutGroup, ShortcutsModal, type ShortcutsModalProps, type ShortcutsModalRenderProps, type TooltipComponent, type TooltipProps, type TwoColumnConfig, type TwoColumnRow, Up, type UseEditableHotkeysOptions, type UseEditableHotkeysResult, type UseHotkeysOptions, type UseHotkeysResult, type UseOmnibarOptions, type UseOmnibarResult, countPlaceholders, createTwoColumnRenderer, extractCaptures, findConflicts, formatBinding, formatCombination, formatKeyForDisplay, formatKeySeq, fuzzyMatch, getActionBindings, getConflictsArray, getKeyIcon, getModifierIcon, getSequenceCompletions, hasConflicts, hasDigitPlaceholders, hotkeySequenceToKeySeq, isDigitPlaceholder, isMac, isModifierKey, isPlaceholderSentinel, isSequence, isShiftedSymbol, keySeqToHotkeySequence, normalizeKey,
|
|
1634
|
+
export { ACTION_LOOKUP, ACTION_MODAL, ACTION_OMNIBAR, type ActionConfig, type ActionDefinition, type ActionHandler, type ActionRegistry, type ActionSearchResult, ActionsRegistryContext, type ActionsRegistryValue, Alt, Backspace, type BindingInfo, Command, Ctrl, DEFAULT_SEQUENCE_TIMEOUT, DIGITS_PLACEHOLDER, DIGIT_PLACEHOLDER, Down, type EndpointPagination, type EndpointPaginationInfo, type EndpointPaginationMode, type EndpointQueryResult, type EndpointResponse, Enter, type FuzzyMatchResult, type GroupRenderer, type GroupRendererProps, type HandlerMap, type HotkeyHandler, type HotkeyMap, type HotkeySequence, type HotkeysConfig, type HotkeysContextValue, HotkeysProvider, type HotkeysProviderProps, Kbd, KbdLookup, KbdModal, KbdOmnibar, type KbdProps, Kbds, Key, type KeyCombination, type KeyCombinationDisplay, type KeyConflict, type KeyIconProps, type KeyIconType, type KeySeq, KeybindingEditor, type KeybindingEditorProps, type KeybindingEditorRenderProps, Left, LookupModal, ModifierIcon, type ModifierIconProps, type ModifierType, type Modifiers, Omnibar, type OmnibarActionEntry, type OmnibarEndpointConfig, OmnibarEndpointsRegistryContext, type OmnibarEndpointsRegistryValue, type OmnibarEntry, type OmnibarEntryBase, type OmnibarLinkEntry, type OmnibarProps, type OmnibarRenderProps, Option, type RecordHotkeyOptions, type RecordHotkeyResult, type RegisteredAction, type RegisteredEndpoint, type RemoteOmnibarResult, Right, type SeqElem, type SeqElemState, type SeqMatchState, type SequenceCompletion, SequenceModal, Shift, type ShortcutGroup, ShortcutsModal, type ShortcutsModalProps, type ShortcutsModalRenderProps, type TooltipComponent, type TooltipProps, type TwoColumnConfig, type TwoColumnRow, Up, type UseEditableHotkeysOptions, type UseEditableHotkeysResult, type UseHotkeysOptions, type UseHotkeysResult, type UseOmnibarOptions, type UseOmnibarResult, countPlaceholders, createTwoColumnRenderer, extractCaptures, findConflicts, formatBinding, formatCombination, formatKeyForDisplay, formatKeySeq, fuzzyMatch, getActionBindings, getConflictsArray, getKeyIcon, getModifierIcon, getSequenceCompletions, hasConflicts, hasDigitPlaceholders, hotkeySequenceToKeySeq, isDigitPlaceholder, isMac, isModifierKey, isPlaceholderSentinel, isSequence, isShiftedSymbol, keySeqToHotkeySequence, normalizeKey, parseHotkeyString, parseKeySeq, searchActions, useAction, useActions, useActionsRegistry, useEditableHotkeys, useHotkeys, useHotkeysContext, useMaybeHotkeysContext, useOmnibar, useOmnibarEndpoint, useOmnibarEndpointsRegistry, useRecordHotkey };
|