modern-cmdk 1.2.1 → 1.2.3
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/README.md +9 -5
- package/dist/codemod/cli.d.mts +1 -1
- package/dist/codemod/cli.mjs +14677 -61044
- package/dist/codemod/transforms/data-attrs.d.mts +4 -8
- package/dist/codemod/transforms/data-attrs.mjs +1 -2
- package/dist/codemod/transforms/forward-ref.d.mts +4 -8
- package/dist/codemod/transforms/forward-ref.mjs +1 -2
- package/dist/codemod/transforms/import-rewrite.d.mts +4 -8
- package/dist/codemod/transforms/import-rewrite.mjs +1 -2
- package/dist/codemod/transforms/should-filter.d.mts +3 -7
- package/dist/codemod/transforms/should-filter.mjs +1 -2
- package/dist/core/index.d.mts +149 -181
- package/dist/core/index.mjs +42 -47
- package/dist/react/index.d.mts +78 -217
- package/dist/react/index.mjs +141 -166
- package/package.json +8 -8
package/dist/react/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
import { Component, ComponentPropsWithRef, Context, ErrorInfo, ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/react/activity.d.ts
|
|
5
3
|
/** Activity mode — maps directly to React's Activity API */
|
|
6
4
|
type ActivityMode = "visible" | "hidden";
|
|
7
5
|
/** Props for the CommandActivity wrapper that controls visibility via React's Activity API. */
|
|
@@ -11,16 +9,11 @@ interface CommandActivityProps {
|
|
|
11
9
|
readonly children: ReactNode;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
|
-
* Wraps content in React
|
|
15
|
-
* When mode="hidden", the component tree is preserved in memory but not rendered.
|
|
16
|
-
* Falls back to conditional rendering if Activity is unavailable.
|
|
17
|
-
*/
|
|
18
|
-
declare function CommandActivity({
|
|
19
|
-
mode,
|
|
20
|
-
children
|
|
21
|
-
}: CommandActivityProps): ReactNode;
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/core/search/types.d.ts
|
|
12
|
+
* Wraps content in React's <Activity> API (React 19.2+).
|
|
13
|
+
* When mode="hidden", the component tree is preserved in memory but not rendered.
|
|
14
|
+
* Falls back to conditional rendering if Activity is unavailable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function CommandActivity({ mode, children }: CommandActivityProps): ReactNode;
|
|
24
17
|
/** Result of scoring a single item against a query */
|
|
25
18
|
interface SearchResult {
|
|
26
19
|
readonly id: ItemId;
|
|
@@ -41,34 +34,32 @@ interface SearchEngine extends Disposable {
|
|
|
41
34
|
/** Dispose resources */
|
|
42
35
|
[Symbol.dispose](): void;
|
|
43
36
|
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/core/types.d.ts
|
|
46
37
|
/**
|
|
47
|
-
* Branded type for command item IDs.
|
|
48
|
-
* Prevents accidental mixing with plain strings at the type level.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* const id = itemId('copy');
|
|
53
|
-
* // id has type ItemId, not string — catches type errors at compile time
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
38
|
+
* Branded type for command item IDs.
|
|
39
|
+
* Prevents accidental mixing with plain strings at the type level.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const id = itemId('copy');
|
|
44
|
+
* // id has type ItemId, not string — catches type errors at compile time
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
56
47
|
declare const __itemIdBrand: unique symbol;
|
|
57
48
|
type ItemId = string & {
|
|
58
49
|
readonly [__itemIdBrand]: never;
|
|
59
50
|
};
|
|
60
51
|
/**
|
|
61
|
-
* Branded type for group IDs.
|
|
62
|
-
* Prevents accidental mixing with plain strings or ItemId at the type level.
|
|
63
|
-
*/
|
|
52
|
+
* Branded type for group IDs.
|
|
53
|
+
* Prevents accidental mixing with plain strings or ItemId at the type level.
|
|
54
|
+
*/
|
|
64
55
|
declare const __groupIdBrand: unique symbol;
|
|
65
56
|
type GroupId = string & {
|
|
66
57
|
readonly [__groupIdBrand]: never;
|
|
67
58
|
};
|
|
68
59
|
/**
|
|
69
|
-
* A registered command item in the palette.
|
|
70
|
-
* All fields are readonly — state machine creates new items on update.
|
|
71
|
-
*/
|
|
60
|
+
* A registered command item in the palette.
|
|
61
|
+
* All fields are readonly — state machine creates new items on update.
|
|
62
|
+
*/
|
|
72
63
|
interface CommandItem$1 {
|
|
73
64
|
/** Unique identifier (branded type) */
|
|
74
65
|
readonly id: ItemId;
|
|
@@ -88,9 +79,9 @@ interface CommandItem$1 {
|
|
|
88
79
|
readonly data?: Readonly<Record<string, unknown>> | undefined;
|
|
89
80
|
}
|
|
90
81
|
/**
|
|
91
|
-
* A command group for categorizing items.
|
|
92
|
-
* Groups are rendered with headings and sorted by priority.
|
|
93
|
-
*/
|
|
82
|
+
* A command group for categorizing items.
|
|
83
|
+
* Groups are rendered with headings and sorted by priority.
|
|
84
|
+
*/
|
|
94
85
|
interface CommandGroup$1 {
|
|
95
86
|
/** Unique identifier (branded type) */
|
|
96
87
|
readonly id: GroupId;
|
|
@@ -100,10 +91,10 @@ interface CommandGroup$1 {
|
|
|
100
91
|
readonly priority?: number | undefined;
|
|
101
92
|
}
|
|
102
93
|
/**
|
|
103
|
-
* Immutable state snapshot of the command palette.
|
|
104
|
-
* Consumed by React via `useSyncExternalStore` — each mutation
|
|
105
|
-
* produces a new object reference for efficient re-render detection.
|
|
106
|
-
*/
|
|
94
|
+
* Immutable state snapshot of the command palette.
|
|
95
|
+
* Consumed by React via `useSyncExternalStore` — each mutation
|
|
96
|
+
* produces a new object reference for efficient re-render detection.
|
|
97
|
+
*/
|
|
107
98
|
interface CommandState {
|
|
108
99
|
/** Current search query string */
|
|
109
100
|
readonly search: string;
|
|
@@ -225,12 +216,10 @@ interface CommandMachineOptions {
|
|
|
225
216
|
/** Item count threshold for automatic virtualization (default: 100) */
|
|
226
217
|
readonly virtualizeThreshold?: number | undefined;
|
|
227
218
|
}
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region src/core/keyboard/parser.d.ts
|
|
230
219
|
/**
|
|
231
|
-
* Structured representation of a keyboard shortcut after parsing.
|
|
232
|
-
* The `normalized` field provides a deterministic string for dedup and comparison.
|
|
233
|
-
*/
|
|
220
|
+
* Structured representation of a keyboard shortcut after parsing.
|
|
221
|
+
* The `normalized` field provides a deterministic string for dedup and comparison.
|
|
222
|
+
*/
|
|
234
223
|
interface ParsedShortcut {
|
|
235
224
|
readonly key: string;
|
|
236
225
|
readonly meta: boolean;
|
|
@@ -240,18 +229,16 @@ interface ParsedShortcut {
|
|
|
240
229
|
readonly raw: string;
|
|
241
230
|
readonly normalized: string;
|
|
242
231
|
}
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/core/keyboard/index.d.ts
|
|
245
232
|
interface ShortcutBinding {
|
|
246
233
|
readonly shortcut: ParsedShortcut;
|
|
247
234
|
readonly itemId: ItemId;
|
|
248
235
|
readonly handler: () => void;
|
|
249
236
|
}
|
|
250
237
|
/**
|
|
251
|
-
* Manages keyboard shortcut bindings with global keydown listening.
|
|
252
|
-
* Supports `using` for automatic cleanup of both individual bindings and the
|
|
253
|
-
* global document listener. Detects conflicts via Map.groupBy (ES2026).
|
|
254
|
-
*/
|
|
238
|
+
* Manages keyboard shortcut bindings with global keydown listening.
|
|
239
|
+
* Supports `using` for automatic cleanup of both individual bindings and the
|
|
240
|
+
* global document listener. Detects conflicts via Map.groupBy (ES2026).
|
|
241
|
+
*/
|
|
255
242
|
declare class KeyboardShortcutRegistry implements Disposable {
|
|
256
243
|
#private;
|
|
257
244
|
constructor(options?: {
|
|
@@ -271,13 +258,11 @@ declare class KeyboardShortcutRegistry implements Disposable {
|
|
|
271
258
|
getBindings(): ReadonlyMap<string, ShortcutBinding>;
|
|
272
259
|
[Symbol.dispose](): void;
|
|
273
260
|
}
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/core/registry.d.ts
|
|
276
261
|
/**
|
|
277
|
-
* Manages registration and lookup of command items and groups.
|
|
278
|
-
* Uses set operation helpers (union/intersection/difference) for efficient ID operations.
|
|
279
|
-
* All registration methods return Disposable for automatic cleanup via `using`.
|
|
280
|
-
*/
|
|
262
|
+
* Manages registration and lookup of command items and groups.
|
|
263
|
+
* Uses set operation helpers (union/intersection/difference) for efficient ID operations.
|
|
264
|
+
* All registration methods return Disposable for automatic cleanup via `using`.
|
|
265
|
+
*/
|
|
281
266
|
declare class CommandRegistry implements Disposable {
|
|
282
267
|
#private;
|
|
283
268
|
/** Register an item — returns Disposable for `using` auto-deregister */
|
|
@@ -326,8 +311,6 @@ declare class CommandRegistry implements Disposable {
|
|
|
326
311
|
clear(): void;
|
|
327
312
|
[Symbol.dispose](): void;
|
|
328
313
|
}
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region src/core/machine.d.ts
|
|
331
314
|
/** Command machine — explicit resource management via `using` */
|
|
332
315
|
interface CommandMachine extends Disposable {
|
|
333
316
|
getState(): CommandState;
|
|
@@ -344,8 +327,6 @@ interface CommandMachine extends Disposable {
|
|
|
344
327
|
getFilteredIdIndex(): ReadonlyMap<ItemId, number>;
|
|
345
328
|
[Symbol.dispose](): void;
|
|
346
329
|
}
|
|
347
|
-
//#endregion
|
|
348
|
-
//#region src/react/async-items.d.ts
|
|
349
330
|
interface CommandAsyncItemsProps {
|
|
350
331
|
/** Promise that resolves to items */
|
|
351
332
|
readonly items: Promise<readonly CommandItem$1[]>;
|
|
@@ -355,22 +336,10 @@ interface CommandAsyncItemsProps {
|
|
|
355
336
|
readonly children: (items: readonly CommandItem$1[]) => ReactNode;
|
|
356
337
|
}
|
|
357
338
|
/** Suspense-based async item loader that resolves a promise of items using React 19 `use()`. */
|
|
358
|
-
declare function CommandAsyncItems({
|
|
359
|
-
items,
|
|
360
|
-
fallback,
|
|
361
|
-
children
|
|
362
|
-
}: CommandAsyncItemsProps): ReactNode;
|
|
363
|
-
//#endregion
|
|
364
|
-
//#region src/react/badge.d.ts
|
|
339
|
+
export declare function CommandAsyncItems({ items, fallback, children }: CommandAsyncItemsProps): ReactNode;
|
|
365
340
|
interface CommandBadgeProps extends ComponentPropsWithRef<"span"> {}
|
|
366
341
|
/** Inline badge for categorization or status indicators on command items. */
|
|
367
|
-
declare function CommandBadge({
|
|
368
|
-
ref,
|
|
369
|
-
children,
|
|
370
|
-
...props
|
|
371
|
-
}: CommandBadgeProps): ReactNode;
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region src/react/dialog.d.ts
|
|
342
|
+
export declare function CommandBadge({ ref, children, ...props }: CommandBadgeProps): ReactNode;
|
|
374
343
|
interface CommandDialogProps extends CommandMachineOptions {
|
|
375
344
|
readonly children?: ReactNode;
|
|
376
345
|
readonly className?: string;
|
|
@@ -385,29 +354,10 @@ interface CommandDialogProps extends CommandMachineOptions {
|
|
|
385
354
|
readonly container?: HTMLElement | null;
|
|
386
355
|
}
|
|
387
356
|
/** Dialog variant that wraps the command palette in a Radix UI Dialog with focus trap and overlay. */
|
|
388
|
-
declare function CommandDialog({
|
|
389
|
-
children,
|
|
390
|
-
className,
|
|
391
|
-
overlayClassName,
|
|
392
|
-
contentClassName,
|
|
393
|
-
label,
|
|
394
|
-
description,
|
|
395
|
-
open: controlledOpen,
|
|
396
|
-
onOpenChange,
|
|
397
|
-
container,
|
|
398
|
-
...machineOptions
|
|
399
|
-
}: CommandDialogProps): ReactNode;
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region src/react/empty.d.ts
|
|
357
|
+
export declare function CommandDialog({ children, className, overlayClassName, contentClassName, label, description, open: controlledOpen, onOpenChange, container, ...machineOptions }: CommandDialogProps): ReactNode;
|
|
402
358
|
interface CommandEmptyProps extends ComponentPropsWithRef<"div"> {}
|
|
403
359
|
/** Rendered when no items match the current search query. */
|
|
404
|
-
declare function CommandEmpty({
|
|
405
|
-
ref,
|
|
406
|
-
children,
|
|
407
|
-
...props
|
|
408
|
-
}: CommandEmptyProps): ReactNode;
|
|
409
|
-
//#endregion
|
|
410
|
-
//#region src/react/group.d.ts
|
|
360
|
+
export declare function CommandEmpty({ ref, children, ...props }: CommandEmptyProps): ReactNode;
|
|
411
361
|
interface CommandGroupProps extends ComponentPropsWithRef<"div"> {
|
|
412
362
|
/** Heading text displayed above the group */
|
|
413
363
|
readonly heading?: string;
|
|
@@ -417,16 +367,7 @@ interface CommandGroupProps extends ComponentPropsWithRef<"div"> {
|
|
|
417
367
|
readonly forceId?: string;
|
|
418
368
|
}
|
|
419
369
|
/** Visual grouping container with an optional heading that hides when no items match. */
|
|
420
|
-
declare function CommandGroup({
|
|
421
|
-
ref,
|
|
422
|
-
children,
|
|
423
|
-
heading,
|
|
424
|
-
priority,
|
|
425
|
-
forceId,
|
|
426
|
-
...props
|
|
427
|
-
}: CommandGroupProps): ReactNode;
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region src/react/highlight.d.ts
|
|
370
|
+
export declare function CommandGroup({ ref, children, heading, priority, forceId, ...props }: CommandGroupProps): ReactNode;
|
|
430
371
|
interface CommandHighlightProps {
|
|
431
372
|
/** The full text to display */
|
|
432
373
|
readonly text: string;
|
|
@@ -436,25 +377,12 @@ interface CommandHighlightProps {
|
|
|
436
377
|
readonly highlightClassName?: string;
|
|
437
378
|
}
|
|
438
379
|
/** Renders search match highlighting by splitting text at scored match ranges. */
|
|
439
|
-
declare function CommandHighlight({
|
|
440
|
-
text,
|
|
441
|
-
ranges,
|
|
442
|
-
highlightClassName
|
|
443
|
-
}: CommandHighlightProps): ReactNode;
|
|
444
|
-
//#endregion
|
|
445
|
-
//#region src/react/input.d.ts
|
|
380
|
+
export declare function CommandHighlight({ text, ranges, highlightClassName }: CommandHighlightProps): ReactNode;
|
|
446
381
|
interface CommandInputProps extends Omit<ComponentPropsWithRef<"input">, "value" | "onChange" | "type" | "role"> {
|
|
447
382
|
readonly onValueChange?: (value: string) => void;
|
|
448
383
|
}
|
|
449
384
|
/** Combobox input that drives the command palette search state. */
|
|
450
|
-
declare function CommandInput({
|
|
451
|
-
ref,
|
|
452
|
-
placeholder,
|
|
453
|
-
onValueChange,
|
|
454
|
-
...props
|
|
455
|
-
}: CommandInputProps): ReactNode;
|
|
456
|
-
//#endregion
|
|
457
|
-
//#region src/react/item.d.ts
|
|
385
|
+
export declare function CommandInput({ ref, placeholder, onValueChange, ...props }: CommandInputProps): ReactNode;
|
|
458
386
|
interface CommandItemProps extends Omit<ComponentPropsWithRef<"div">, "onSelect" | "value"> {
|
|
459
387
|
readonly value: string;
|
|
460
388
|
readonly keywords?: readonly string[];
|
|
@@ -464,19 +392,7 @@ interface CommandItemProps extends Omit<ComponentPropsWithRef<"div">, "onSelect"
|
|
|
464
392
|
readonly forceId?: string;
|
|
465
393
|
}
|
|
466
394
|
/** Individual selectable item in the command list with keyboard and pointer activation. */
|
|
467
|
-
declare function CommandItem({
|
|
468
|
-
ref,
|
|
469
|
-
children,
|
|
470
|
-
value,
|
|
471
|
-
keywords,
|
|
472
|
-
onSelect,
|
|
473
|
-
disabled,
|
|
474
|
-
shortcut,
|
|
475
|
-
forceId,
|
|
476
|
-
...props
|
|
477
|
-
}: CommandItemProps): ReactNode;
|
|
478
|
-
//#endregion
|
|
479
|
-
//#region src/react/list.d.ts
|
|
395
|
+
export declare function CommandItem({ ref, children, value, keywords, onSelect, disabled, shortcut, forceId, ...props }: CommandItemProps): ReactNode;
|
|
480
396
|
interface CommandListProps extends ComponentPropsWithRef<"div"> {
|
|
481
397
|
/** Override automatic virtualization (default: auto at >100 items, false to opt-out) */
|
|
482
398
|
readonly virtualize?: boolean;
|
|
@@ -488,31 +404,13 @@ interface CommandListProps extends ComponentPropsWithRef<"div"> {
|
|
|
488
404
|
readonly announceResults?: (count: number) => string;
|
|
489
405
|
}
|
|
490
406
|
/** Scrollable list container with auto-virtualization and aria-live announcements. */
|
|
491
|
-
declare function CommandList({
|
|
492
|
-
ref,
|
|
493
|
-
children,
|
|
494
|
-
virtualize,
|
|
495
|
-
estimateSize,
|
|
496
|
-
overscan,
|
|
497
|
-
announceResults,
|
|
498
|
-
style,
|
|
499
|
-
...props
|
|
500
|
-
}: CommandListProps): ReactNode;
|
|
501
|
-
//#endregion
|
|
502
|
-
//#region src/react/loading.d.ts
|
|
407
|
+
export declare function CommandList({ ref, children, virtualize, estimateSize, overscan, announceResults, style, ...props }: CommandListProps): ReactNode;
|
|
503
408
|
interface CommandLoadingProps extends ComponentPropsWithRef<"div"> {
|
|
504
409
|
/** Override the loading state detection */
|
|
505
410
|
readonly loading?: boolean;
|
|
506
411
|
}
|
|
507
412
|
/** Shown during async operations, with configurable loading state override. */
|
|
508
|
-
declare function CommandLoading({
|
|
509
|
-
ref,
|
|
510
|
-
children,
|
|
511
|
-
loading: loadingOverride,
|
|
512
|
-
...props
|
|
513
|
-
}: CommandLoadingProps): ReactNode;
|
|
514
|
-
//#endregion
|
|
515
|
-
//#region src/react/page.d.ts
|
|
413
|
+
export declare function CommandLoading({ ref, children, loading: loadingOverride, ...props }: CommandLoadingProps): ReactNode;
|
|
516
414
|
/** Branded page identifier */
|
|
517
415
|
type CommandPageId = string & {
|
|
518
416
|
readonly __brand: "CommandPageId";
|
|
@@ -523,47 +421,25 @@ interface CommandPageProps {
|
|
|
523
421
|
readonly children?: ReactNode;
|
|
524
422
|
}
|
|
525
423
|
/** Page navigation container that only renders when its ID matches the active page. */
|
|
526
|
-
declare function CommandPage({
|
|
527
|
-
id,
|
|
528
|
-
children
|
|
529
|
-
}: CommandPageProps): ReactNode;
|
|
530
|
-
//#endregion
|
|
531
|
-
//#region src/react/separator.d.ts
|
|
424
|
+
export declare function CommandPage({ id, children }: CommandPageProps): ReactNode;
|
|
532
425
|
interface CommandSeparatorProps extends ComponentPropsWithRef<"div"> {}
|
|
533
426
|
/** Visual divider between items or groups, rendered as a presentational element. */
|
|
534
|
-
declare function CommandSeparator({
|
|
535
|
-
ref,
|
|
536
|
-
...props
|
|
537
|
-
}: CommandSeparatorProps): ReactNode;
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region src/react/shortcut.d.ts
|
|
427
|
+
export declare function CommandSeparator({ ref, ...props }: CommandSeparatorProps): ReactNode;
|
|
540
428
|
interface CommandShortcutProps extends ComponentPropsWithRef<"kbd"> {
|
|
541
429
|
/** Shortcut string to display (e.g., "Mod+K"). If not provided, reads from nearest Command.Item. */
|
|
542
430
|
readonly shortcut?: string;
|
|
543
431
|
}
|
|
544
432
|
/** Keyboard shortcut display with platform-aware formatting (e.g., Cmd vs Ctrl). */
|
|
545
|
-
declare function CommandShortcut({
|
|
546
|
-
ref,
|
|
547
|
-
shortcut,
|
|
548
|
-
children,
|
|
549
|
-
...props
|
|
550
|
-
}: CommandShortcutProps): ReactNode;
|
|
551
|
-
//#endregion
|
|
552
|
-
//#region src/react/command.d.ts
|
|
433
|
+
export declare function CommandShortcut({ ref, shortcut, children, ...props }: CommandShortcutProps): ReactNode;
|
|
553
434
|
interface CommandRootProps extends CommandMachineOptions {
|
|
554
435
|
readonly children?: ReactNode;
|
|
555
436
|
readonly className?: string;
|
|
556
437
|
readonly label?: string;
|
|
557
438
|
}
|
|
558
439
|
/** Root compound component that provides the command state machine context to all children. */
|
|
559
|
-
declare function CommandRoot({
|
|
560
|
-
children,
|
|
561
|
-
className,
|
|
562
|
-
label,
|
|
563
|
-
...machineOptions
|
|
564
|
-
}: CommandRootProps): ReactNode;
|
|
440
|
+
declare function CommandRoot({ children, className, label, ...machineOptions }: CommandRootProps): ReactNode;
|
|
565
441
|
/** Compound component namespace */
|
|
566
|
-
declare const Command: typeof CommandRoot & {
|
|
442
|
+
export declare const Command: typeof CommandRoot & {
|
|
567
443
|
readonly Input: typeof CommandInput;
|
|
568
444
|
readonly List: typeof CommandList;
|
|
569
445
|
readonly Item: typeof CommandItem;
|
|
@@ -579,8 +455,6 @@ declare const Command: typeof CommandRoot & {
|
|
|
579
455
|
readonly AsyncItems: typeof CommandAsyncItems;
|
|
580
456
|
readonly Activity: typeof CommandActivity;
|
|
581
457
|
};
|
|
582
|
-
//#endregion
|
|
583
|
-
//#region src/react/context.d.ts
|
|
584
458
|
/** Branded newtype for the root instance ID */
|
|
585
459
|
type CommandRootId = string & {
|
|
586
460
|
readonly __brand: "CommandRootId";
|
|
@@ -623,14 +497,12 @@ interface CommandStateContextValue {
|
|
|
623
497
|
/** Map of visible item IDs to their translateY pixel offsets. null = not virtualizing. */
|
|
624
498
|
readonly virtualPositionMap: ReadonlyMap<ItemId, number> | null;
|
|
625
499
|
}
|
|
626
|
-
declare const CommandStableContext: Context<CommandStableContextValue | null>;
|
|
627
|
-
declare const CommandStateContext: Context<CommandStateContextValue | null>;
|
|
500
|
+
export declare const CommandStableContext: Context<CommandStableContextValue | null>;
|
|
501
|
+
export declare const CommandStateContext: Context<CommandStateContextValue | null>;
|
|
628
502
|
interface CommandGroupContextValue {
|
|
629
503
|
readonly groupId: string;
|
|
630
504
|
readonly headingId: string;
|
|
631
505
|
}
|
|
632
|
-
//#endregion
|
|
633
|
-
//#region src/react/error-boundary.d.ts
|
|
634
506
|
interface CommandErrorBoundaryProps {
|
|
635
507
|
readonly children: ReactNode;
|
|
636
508
|
readonly fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
@@ -640,14 +512,12 @@ interface CommandErrorBoundaryState {
|
|
|
640
512
|
readonly error: Error | null;
|
|
641
513
|
}
|
|
642
514
|
/** Error boundary for graceful failure recovery in command subtrees. */
|
|
643
|
-
declare class CommandErrorBoundary extends Component<CommandErrorBoundaryProps, CommandErrorBoundaryState> {
|
|
515
|
+
export declare class CommandErrorBoundary extends Component<CommandErrorBoundaryProps, CommandErrorBoundaryState> {
|
|
644
516
|
override state: CommandErrorBoundaryState;
|
|
645
517
|
static getDerivedStateFromError(error: Error): CommandErrorBoundaryState;
|
|
646
518
|
override componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
647
519
|
override render(): ReactNode;
|
|
648
520
|
}
|
|
649
|
-
//#endregion
|
|
650
|
-
//#region src/react/hooks/use-command.d.ts
|
|
651
521
|
interface UseCommandReturn {
|
|
652
522
|
readonly state: CommandState;
|
|
653
523
|
readonly isPending: boolean;
|
|
@@ -658,34 +528,28 @@ interface UseCommandReturn {
|
|
|
658
528
|
readonly id: CommandRootId;
|
|
659
529
|
}
|
|
660
530
|
/** Core hook that binds a CommandMachine to React via useSyncExternalStore, useTransition, and useOptimistic. */
|
|
661
|
-
declare function useCommand(machine: CommandMachine): UseCommandReturn;
|
|
662
|
-
//#endregion
|
|
663
|
-
//#region src/react/hooks/use-command-state.d.ts
|
|
531
|
+
export declare function useCommand(machine: CommandMachine): UseCommandReturn;
|
|
664
532
|
/** Get the full command state with proper subscription */
|
|
665
|
-
declare function useCommandState(): CommandState;
|
|
533
|
+
export declare function useCommandState(): CommandState;
|
|
666
534
|
/** Get a selected slice of command state — only re-renders when selected value changes */
|
|
667
|
-
declare function useCommandState<T>(selector: (state: CommandState) => T): T;
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region src/react/hooks/use-devtools.d.ts
|
|
535
|
+
export declare function useCommandState<T>(selector: (state: CommandState) => T): T;
|
|
670
536
|
/**
|
|
671
|
-
* Exposes command palette internals to browser devtools.
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
537
|
+
* Exposes command palette internals to browser devtools.
|
|
538
|
+
* Development only: the effect is gated on `process.env.NODE_ENV` and returns early in
|
|
539
|
+
* production builds (the hook itself still ships). Call it from a component rendered inside
|
|
540
|
+
* `<Command>`: outside one there is no machine to inspect and the hook does nothing.
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```tsx
|
|
544
|
+
* function DevtoolsBridge() {
|
|
545
|
+
* useCommandDevtools('main');
|
|
546
|
+
* return null;
|
|
547
|
+
* }
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
export declare function useCommandDevtools(label?: string): void;
|
|
685
551
|
/** Create a keydown handler for command palette keyboard navigation */
|
|
686
|
-
declare function createKeydownHandler(machine: CommandMachine, getState: () => CommandState): (event: KeyboardEvent) => void;
|
|
687
|
-
//#endregion
|
|
688
|
-
//#region src/react/hooks/use-register.d.ts
|
|
552
|
+
export declare function createKeydownHandler(machine: CommandMachine, getState: () => CommandState): (event: KeyboardEvent) => void;
|
|
689
553
|
/** Options for item registration */
|
|
690
554
|
interface RegisterItemOptions {
|
|
691
555
|
readonly keywords?: readonly string[];
|
|
@@ -697,16 +561,14 @@ interface RegisterItemOptions {
|
|
|
697
561
|
readonly forceId?: string;
|
|
698
562
|
}
|
|
699
563
|
/** Register a command item with the machine — auto-deregisters on unmount */
|
|
700
|
-
declare function useRegisterItem(value: string, options?: RegisterItemOptions): ItemId;
|
|
564
|
+
export declare function useRegisterItem(value: string, options?: RegisterItemOptions): ItemId;
|
|
701
565
|
/** Options for group registration */
|
|
702
566
|
interface RegisterGroupOptions {
|
|
703
567
|
readonly priority?: number;
|
|
704
568
|
readonly forceId?: string;
|
|
705
569
|
}
|
|
706
570
|
/** Register a command group with the machine — auto-deregisters on unmount */
|
|
707
|
-
declare function useRegisterGroup(heading?: string, options?: RegisterGroupOptions): GroupId;
|
|
708
|
-
//#endregion
|
|
709
|
-
//#region src/react/hooks/use-virtualizer.d.ts
|
|
571
|
+
export declare function useRegisterGroup(heading?: string, options?: RegisterGroupOptions): GroupId;
|
|
710
572
|
interface VirtualizerOptions {
|
|
711
573
|
readonly count: number;
|
|
712
574
|
readonly estimateSize: number;
|
|
@@ -727,6 +589,5 @@ interface VirtualizerReturn {
|
|
|
727
589
|
readonly measureElement: (element: HTMLElement | null) => void;
|
|
728
590
|
}
|
|
729
591
|
/** Lightweight virtualizer for large item lists using ResizeObserver and scroll tracking. */
|
|
730
|
-
declare function useVirtualizer(options: VirtualizerOptions): VirtualizerReturn;
|
|
731
|
-
|
|
732
|
-
export { type ActivityMode, Command, CommandActivity, type CommandActivityProps, CommandAsyncItems, type CommandAsyncItemsProps, CommandBadge, type CommandBadgeProps, type CommandContextValue, CommandDialog, type CommandDialogProps, CommandEmpty, type CommandEmptyProps, CommandErrorBoundary, type CommandErrorBoundaryProps, CommandGroup, type CommandGroupContextValue, type CommandGroupProps, CommandHighlight, type CommandHighlightProps, CommandInput, type CommandInputProps, CommandItem, type CommandItemProps, CommandList, type CommandListProps, CommandLoading, type CommandLoadingProps, CommandPage, type CommandPageId, type CommandPageProps, type CommandRootId, type CommandRootProps, CommandSeparator, type CommandSeparatorProps, CommandShortcut, type CommandShortcutProps, CommandStableContext, type CommandStableContextValue, CommandStateContext, type CommandStateContextValue, type RegisterGroupOptions, type RegisterItemOptions, type UseCommandReturn, type VirtualItem, type VirtualizerOptions, type VirtualizerReturn, createKeydownHandler, useCommand, useCommandDevtools, useCommandState, useRegisterGroup, useRegisterItem, useVirtualizer };
|
|
592
|
+
export declare function useVirtualizer(options: VirtualizerOptions): VirtualizerReturn;
|
|
593
|
+
export type { ActivityMode, CommandActivityProps, CommandAsyncItemsProps, CommandBadgeProps, CommandContextValue, CommandDialogProps, CommandEmptyProps, CommandErrorBoundaryProps, CommandGroupContextValue, CommandGroupProps, CommandHighlightProps, CommandInputProps, CommandItemProps, CommandListProps, CommandLoadingProps, CommandPageId, CommandPageProps, CommandRootId, CommandRootProps, CommandSeparatorProps, CommandShortcutProps, CommandStableContextValue, CommandStateContextValue, RegisterGroupOptions, RegisterItemOptions, UseCommandReturn, VirtualItem, VirtualizerOptions, VirtualizerReturn };
|