modern-cmdk 1.2.2 → 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.
@@ -1,6 +1,5 @@
1
1
 
2
2
  import { Component, ComponentPropsWithRef, Context, ErrorInfo, ReactNode } from "react";
3
- //#region src/react/activity.d.ts
4
3
  /** Activity mode — maps directly to React's Activity API */
5
4
  type ActivityMode = "visible" | "hidden";
6
5
  /** Props for the CommandActivity wrapper that controls visibility via React's Activity API. */
@@ -10,13 +9,11 @@ interface CommandActivityProps {
10
9
  readonly children: ReactNode;
11
10
  }
12
11
  /**
13
- * Wraps content in React 19.3.0-canary Activity API.
12
+ * Wraps content in React's <Activity> API (React 19.2+).
14
13
  * When mode="hidden", the component tree is preserved in memory but not rendered.
15
14
  * Falls back to conditional rendering if Activity is unavailable.
16
15
  */
17
16
  export declare function CommandActivity({ mode, children }: CommandActivityProps): ReactNode;
18
- //#endregion
19
- //#region src/core/search/types.d.ts
20
17
  /** Result of scoring a single item against a query */
21
18
  interface SearchResult {
22
19
  readonly id: ItemId;
@@ -37,8 +34,6 @@ interface SearchEngine extends Disposable {
37
34
  /** Dispose resources */
38
35
  [Symbol.dispose](): void;
39
36
  }
40
- //#endregion
41
- //#region src/core/types.d.ts
42
37
  /**
43
38
  * Branded type for command item IDs.
44
39
  * Prevents accidental mixing with plain strings at the type level.
@@ -221,8 +216,6 @@ interface CommandMachineOptions {
221
216
  /** Item count threshold for automatic virtualization (default: 100) */
222
217
  readonly virtualizeThreshold?: number | undefined;
223
218
  }
224
- //#endregion
225
- //#region src/core/keyboard/parser.d.ts
226
219
  /**
227
220
  * Structured representation of a keyboard shortcut after parsing.
228
221
  * The `normalized` field provides a deterministic string for dedup and comparison.
@@ -236,8 +229,6 @@ interface ParsedShortcut {
236
229
  readonly raw: string;
237
230
  readonly normalized: string;
238
231
  }
239
- //#endregion
240
- //#region src/core/keyboard/index.d.ts
241
232
  interface ShortcutBinding {
242
233
  readonly shortcut: ParsedShortcut;
243
234
  readonly itemId: ItemId;
@@ -267,8 +258,6 @@ declare class KeyboardShortcutRegistry implements Disposable {
267
258
  getBindings(): ReadonlyMap<string, ShortcutBinding>;
268
259
  [Symbol.dispose](): void;
269
260
  }
270
- //#endregion
271
- //#region src/core/registry.d.ts
272
261
  /**
273
262
  * Manages registration and lookup of command items and groups.
274
263
  * Uses set operation helpers (union/intersection/difference) for efficient ID operations.
@@ -322,8 +311,6 @@ declare class CommandRegistry implements Disposable {
322
311
  clear(): void;
323
312
  [Symbol.dispose](): void;
324
313
  }
325
- //#endregion
326
- //#region src/core/machine.d.ts
327
314
  /** Command machine — explicit resource management via `using` */
328
315
  interface CommandMachine extends Disposable {
329
316
  getState(): CommandState;
@@ -340,8 +327,6 @@ interface CommandMachine extends Disposable {
340
327
  getFilteredIdIndex(): ReadonlyMap<ItemId, number>;
341
328
  [Symbol.dispose](): void;
342
329
  }
343
- //#endregion
344
- //#region src/react/async-items.d.ts
345
330
  interface CommandAsyncItemsProps {
346
331
  /** Promise that resolves to items */
347
332
  readonly items: Promise<readonly CommandItem$1[]>;
@@ -352,13 +337,9 @@ interface CommandAsyncItemsProps {
352
337
  }
353
338
  /** Suspense-based async item loader that resolves a promise of items using React 19 `use()`. */
354
339
  export declare function CommandAsyncItems({ items, fallback, children }: CommandAsyncItemsProps): ReactNode;
355
- //#endregion
356
- //#region src/react/badge.d.ts
357
340
  interface CommandBadgeProps extends ComponentPropsWithRef<"span"> {}
358
341
  /** Inline badge for categorization or status indicators on command items. */
359
342
  export declare function CommandBadge({ ref, children, ...props }: CommandBadgeProps): ReactNode;
360
- //#endregion
361
- //#region src/react/dialog.d.ts
362
343
  interface CommandDialogProps extends CommandMachineOptions {
363
344
  readonly children?: ReactNode;
364
345
  readonly className?: string;
@@ -374,13 +355,9 @@ interface CommandDialogProps extends CommandMachineOptions {
374
355
  }
375
356
  /** Dialog variant that wraps the command palette in a Radix UI Dialog with focus trap and overlay. */
376
357
  export declare function CommandDialog({ children, className, overlayClassName, contentClassName, label, description, open: controlledOpen, onOpenChange, container, ...machineOptions }: CommandDialogProps): ReactNode;
377
- //#endregion
378
- //#region src/react/empty.d.ts
379
358
  interface CommandEmptyProps extends ComponentPropsWithRef<"div"> {}
380
359
  /** Rendered when no items match the current search query. */
381
360
  export declare function CommandEmpty({ ref, children, ...props }: CommandEmptyProps): ReactNode;
382
- //#endregion
383
- //#region src/react/group.d.ts
384
361
  interface CommandGroupProps extends ComponentPropsWithRef<"div"> {
385
362
  /** Heading text displayed above the group */
386
363
  readonly heading?: string;
@@ -391,8 +368,6 @@ interface CommandGroupProps extends ComponentPropsWithRef<"div"> {
391
368
  }
392
369
  /** Visual grouping container with an optional heading that hides when no items match. */
393
370
  export declare function CommandGroup({ ref, children, heading, priority, forceId, ...props }: CommandGroupProps): ReactNode;
394
- //#endregion
395
- //#region src/react/highlight.d.ts
396
371
  interface CommandHighlightProps {
397
372
  /** The full text to display */
398
373
  readonly text: string;
@@ -403,15 +378,11 @@ interface CommandHighlightProps {
403
378
  }
404
379
  /** Renders search match highlighting by splitting text at scored match ranges. */
405
380
  export declare function CommandHighlight({ text, ranges, highlightClassName }: CommandHighlightProps): ReactNode;
406
- //#endregion
407
- //#region src/react/input.d.ts
408
381
  interface CommandInputProps extends Omit<ComponentPropsWithRef<"input">, "value" | "onChange" | "type" | "role"> {
409
382
  readonly onValueChange?: (value: string) => void;
410
383
  }
411
384
  /** Combobox input that drives the command palette search state. */
412
385
  export declare function CommandInput({ ref, placeholder, onValueChange, ...props }: CommandInputProps): ReactNode;
413
- //#endregion
414
- //#region src/react/item.d.ts
415
386
  interface CommandItemProps extends Omit<ComponentPropsWithRef<"div">, "onSelect" | "value"> {
416
387
  readonly value: string;
417
388
  readonly keywords?: readonly string[];
@@ -422,8 +393,6 @@ interface CommandItemProps extends Omit<ComponentPropsWithRef<"div">, "onSelect"
422
393
  }
423
394
  /** Individual selectable item in the command list with keyboard and pointer activation. */
424
395
  export declare function CommandItem({ ref, children, value, keywords, onSelect, disabled, shortcut, forceId, ...props }: CommandItemProps): ReactNode;
425
- //#endregion
426
- //#region src/react/list.d.ts
427
396
  interface CommandListProps extends ComponentPropsWithRef<"div"> {
428
397
  /** Override automatic virtualization (default: auto at >100 items, false to opt-out) */
429
398
  readonly virtualize?: boolean;
@@ -436,16 +405,12 @@ interface CommandListProps extends ComponentPropsWithRef<"div"> {
436
405
  }
437
406
  /** Scrollable list container with auto-virtualization and aria-live announcements. */
438
407
  export declare function CommandList({ ref, children, virtualize, estimateSize, overscan, announceResults, style, ...props }: CommandListProps): ReactNode;
439
- //#endregion
440
- //#region src/react/loading.d.ts
441
408
  interface CommandLoadingProps extends ComponentPropsWithRef<"div"> {
442
409
  /** Override the loading state detection */
443
410
  readonly loading?: boolean;
444
411
  }
445
412
  /** Shown during async operations, with configurable loading state override. */
446
413
  export declare function CommandLoading({ ref, children, loading: loadingOverride, ...props }: CommandLoadingProps): ReactNode;
447
- //#endregion
448
- //#region src/react/page.d.ts
449
414
  /** Branded page identifier */
450
415
  type CommandPageId = string & {
451
416
  readonly __brand: "CommandPageId";
@@ -457,21 +422,15 @@ interface CommandPageProps {
457
422
  }
458
423
  /** Page navigation container that only renders when its ID matches the active page. */
459
424
  export declare function CommandPage({ id, children }: CommandPageProps): ReactNode;
460
- //#endregion
461
- //#region src/react/separator.d.ts
462
425
  interface CommandSeparatorProps extends ComponentPropsWithRef<"div"> {}
463
426
  /** Visual divider between items or groups, rendered as a presentational element. */
464
427
  export declare function CommandSeparator({ ref, ...props }: CommandSeparatorProps): ReactNode;
465
- //#endregion
466
- //#region src/react/shortcut.d.ts
467
428
  interface CommandShortcutProps extends ComponentPropsWithRef<"kbd"> {
468
429
  /** Shortcut string to display (e.g., "Mod+K"). If not provided, reads from nearest Command.Item. */
469
430
  readonly shortcut?: string;
470
431
  }
471
432
  /** Keyboard shortcut display with platform-aware formatting (e.g., Cmd vs Ctrl). */
472
433
  export declare function CommandShortcut({ ref, shortcut, children, ...props }: CommandShortcutProps): ReactNode;
473
- //#endregion
474
- //#region src/react/command.d.ts
475
434
  interface CommandRootProps extends CommandMachineOptions {
476
435
  readonly children?: ReactNode;
477
436
  readonly className?: string;
@@ -496,8 +455,6 @@ export declare const Command: typeof CommandRoot & {
496
455
  readonly AsyncItems: typeof CommandAsyncItems;
497
456
  readonly Activity: typeof CommandActivity;
498
457
  };
499
- //#endregion
500
- //#region src/react/context.d.ts
501
458
  /** Branded newtype for the root instance ID */
502
459
  type CommandRootId = string & {
503
460
  readonly __brand: "CommandRootId";
@@ -546,8 +503,6 @@ interface CommandGroupContextValue {
546
503
  readonly groupId: string;
547
504
  readonly headingId: string;
548
505
  }
549
- //#endregion
550
- //#region src/react/error-boundary.d.ts
551
506
  interface CommandErrorBoundaryProps {
552
507
  readonly children: ReactNode;
553
508
  readonly fallback?: ReactNode | ((error: Error) => ReactNode);
@@ -563,8 +518,6 @@ export declare class CommandErrorBoundary extends Component<CommandErrorBoundary
563
518
  override componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
564
519
  override render(): ReactNode;
565
520
  }
566
- //#endregion
567
- //#region src/react/hooks/use-command.d.ts
568
521
  interface UseCommandReturn {
569
522
  readonly state: CommandState;
570
523
  readonly isPending: boolean;
@@ -576,33 +529,27 @@ interface UseCommandReturn {
576
529
  }
577
530
  /** Core hook that binds a CommandMachine to React via useSyncExternalStore, useTransition, and useOptimistic. */
578
531
  export declare function useCommand(machine: CommandMachine): UseCommandReturn;
579
- //#endregion
580
- //#region src/react/hooks/use-command-state.d.ts
581
532
  /** Get the full command state with proper subscription */
582
533
  export declare function useCommandState(): CommandState;
583
534
  /** Get a selected slice of command state — only re-renders when selected value changes */
584
535
  export declare function useCommandState<T>(selector: (state: CommandState) => T): T;
585
- //#endregion
586
- //#region src/react/hooks/use-devtools.d.ts
587
536
  /**
588
537
  * Exposes command palette internals to browser devtools.
589
- * Only active in development — completely tree-shaken in production builds.
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.
590
541
  *
591
542
  * @example
592
543
  * ```tsx
593
- * function MyPalette() {
544
+ * function DevtoolsBridge() {
594
545
  * useCommandDevtools('main');
595
- * return <Command>...</Command>;
546
+ * return null;
596
547
  * }
597
548
  * ```
598
549
  */
599
550
  export declare function useCommandDevtools(label?: string): void;
600
- //#endregion
601
- //#region src/react/hooks/use-keyboard.d.ts
602
551
  /** Create a keydown handler for command palette keyboard navigation */
603
552
  export declare function createKeydownHandler(machine: CommandMachine, getState: () => CommandState): (event: KeyboardEvent) => void;
604
- //#endregion
605
- //#region src/react/hooks/use-register.d.ts
606
553
  /** Options for item registration */
607
554
  interface RegisterItemOptions {
608
555
  readonly keywords?: readonly string[];
@@ -622,8 +569,6 @@ interface RegisterGroupOptions {
622
569
  }
623
570
  /** Register a command group with the machine — auto-deregisters on unmount */
624
571
  export declare function useRegisterGroup(heading?: string, options?: RegisterGroupOptions): GroupId;
625
- //#endregion
626
- //#region src/react/hooks/use-virtualizer.d.ts
627
572
  interface VirtualizerOptions {
628
573
  readonly count: number;
629
574
  readonly estimateSize: number;
@@ -645,5 +590,4 @@ interface VirtualizerReturn {
645
590
  }
646
591
  /** Lightweight virtualizer for large item lists using ResizeObserver and scroll tracking. */
647
592
  export declare function useVirtualizer(options: VirtualizerOptions): VirtualizerReturn;
648
- //#endregion
649
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 };