modern-cmdk 1.2.3 → 1.4.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/LICENSE +1 -1
- package/README.md +109 -154
- package/dist/codemod/cli.mjs +205 -120
- package/dist/codemod/transforms/data-attrs.mjs +1 -1
- package/dist/core/index.d.mts +10 -10
- package/dist/core/index.mjs +9 -8
- package/dist/react/chunk-dialog.mjs +237 -0
- package/dist/react/dialog.d.mts +18 -0
- package/dist/react/dialog.mjs +3 -0
- package/dist/react/index.d.mts +11 -333
- package/dist/react/index.mjs +34 -1373
- package/dist/react/styles.css +18 -9
- package/package.json +8 -12
- package/dist/codemod/cli.d.mts +0 -1
- package/dist/codemod/transforms/data-attrs.d.mts +0 -6
- package/dist/codemod/transforms/forward-ref.d.mts +0 -6
- package/dist/codemod/transforms/import-rewrite.d.mts +0 -6
- package/dist/codemod/transforms/should-filter.d.mts +0 -5
package/dist/react/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
+
import { CommandDialog, CommandDialogProps } from "./dialog.mjs";
|
|
2
3
|
import { Component, ComponentPropsWithRef, Context, ErrorInfo, ReactNode } from "react";
|
|
4
|
+
import { CommandItem as CommandItem$1, CommandMachine, CommandMachineOptions, CommandState, GroupId, ItemId } from "modern-cmdk";
|
|
3
5
|
/** Activity mode — maps directly to React's Activity API */
|
|
4
6
|
type ActivityMode = "visible" | "hidden";
|
|
5
7
|
/** Props for the CommandActivity wrapper that controls visibility via React's Activity API. */
|
|
@@ -14,319 +16,6 @@ interface CommandActivityProps {
|
|
|
14
16
|
* Falls back to conditional rendering if Activity is unavailable.
|
|
15
17
|
*/
|
|
16
18
|
export declare function CommandActivity({ mode, children }: CommandActivityProps): ReactNode;
|
|
17
|
-
/** Result of scoring a single item against a query */
|
|
18
|
-
interface SearchResult {
|
|
19
|
-
readonly id: ItemId;
|
|
20
|
-
readonly score: number;
|
|
21
|
-
/** Character ranges that matched (for highlighting) — [start, end] tuples */
|
|
22
|
-
readonly matches: ReadonlyArray<readonly [start: number, end: number]>;
|
|
23
|
-
}
|
|
24
|
-
/** Search engine interface — pluggable into the state machine */
|
|
25
|
-
interface SearchEngine extends Disposable {
|
|
26
|
-
/** Index items for fast lookup (call on registration) */
|
|
27
|
-
index(items: readonly CommandItem$1[]): void;
|
|
28
|
-
/** Search items by query, return ordered results — uses Iterator pipeline */
|
|
29
|
-
search(query: string, items: readonly CommandItem$1[]): IteratorObject<SearchResult>;
|
|
30
|
-
/** Remove items from index — uses Set.difference for efficient bulk removal */
|
|
31
|
-
remove(ids: ReadonlySet<ItemId>): void;
|
|
32
|
-
/** Clear the entire index */
|
|
33
|
-
clear(): void;
|
|
34
|
-
/** Dispose resources */
|
|
35
|
-
[Symbol.dispose](): void;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
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
|
-
*/
|
|
47
|
-
declare const __itemIdBrand: unique symbol;
|
|
48
|
-
type ItemId = string & {
|
|
49
|
-
readonly [__itemIdBrand]: never;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Branded type for group IDs.
|
|
53
|
-
* Prevents accidental mixing with plain strings or ItemId at the type level.
|
|
54
|
-
*/
|
|
55
|
-
declare const __groupIdBrand: unique symbol;
|
|
56
|
-
type GroupId = string & {
|
|
57
|
-
readonly [__groupIdBrand]: never;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* A registered command item in the palette.
|
|
61
|
-
* All fields are readonly — state machine creates new items on update.
|
|
62
|
-
*/
|
|
63
|
-
interface CommandItem$1 {
|
|
64
|
-
/** Unique identifier (branded type) */
|
|
65
|
-
readonly id: ItemId;
|
|
66
|
-
/** Display text — also used as the primary search target */
|
|
67
|
-
readonly value: string;
|
|
68
|
-
/** Additional searchable terms (matched but not displayed) */
|
|
69
|
-
readonly keywords?: readonly string[] | undefined;
|
|
70
|
-
/** Group this item belongs to (items without groupId are ungrouped) */
|
|
71
|
-
readonly groupId?: GroupId | undefined;
|
|
72
|
-
/** Keyboard shortcut string (e.g., "Ctrl+C", "Mod+K") */
|
|
73
|
-
readonly shortcut?: string | undefined;
|
|
74
|
-
/** Whether this item is disabled (excluded from filtering and selection) */
|
|
75
|
-
readonly disabled?: boolean | undefined;
|
|
76
|
-
/** Callback fired when this item is selected */
|
|
77
|
-
readonly onSelect?: (() => void) | undefined;
|
|
78
|
-
/** Arbitrary metadata attached to the item */
|
|
79
|
-
readonly data?: Readonly<Record<string, unknown>> | undefined;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* A command group for categorizing items.
|
|
83
|
-
* Groups are rendered with headings and sorted by priority.
|
|
84
|
-
*/
|
|
85
|
-
interface CommandGroup$1 {
|
|
86
|
-
/** Unique identifier (branded type) */
|
|
87
|
-
readonly id: GroupId;
|
|
88
|
-
/** Display heading text (rendered above the group's items) */
|
|
89
|
-
readonly heading?: string | undefined;
|
|
90
|
-
/** Sort priority — lower values appear first (default: 0) */
|
|
91
|
-
readonly priority?: number | undefined;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
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
|
-
*/
|
|
98
|
-
interface CommandState {
|
|
99
|
-
/** Current search query string */
|
|
100
|
-
readonly search: string;
|
|
101
|
-
/** Currently active (highlighted) item ID, or null if none */
|
|
102
|
-
readonly activeId: ItemId | null;
|
|
103
|
-
/** Ordered list of item IDs that pass the current filter */
|
|
104
|
-
readonly filteredIds: readonly ItemId[];
|
|
105
|
-
/** Map of group IDs to their visible item IDs */
|
|
106
|
-
readonly groupedIds: ReadonlyMap<GroupId, readonly ItemId[]>;
|
|
107
|
-
/** Count of visible items (shortcut for `filteredIds.length`) */
|
|
108
|
-
readonly filteredCount: number;
|
|
109
|
-
/** Whether async items are currently loading */
|
|
110
|
-
readonly loading: boolean;
|
|
111
|
-
/** Current page identifier (for multi-page navigation) */
|
|
112
|
-
readonly page: string;
|
|
113
|
-
/** Stack of previous pages for back-navigation */
|
|
114
|
-
readonly pageStack: readonly string[];
|
|
115
|
-
/** Whether the command palette dialog is open */
|
|
116
|
-
readonly open: boolean;
|
|
117
|
-
/** Epoch-millisecond timestamp of the last state mutation */
|
|
118
|
-
readonly lastUpdated: number;
|
|
119
|
-
}
|
|
120
|
-
/** All possible events the state machine accepts */
|
|
121
|
-
type CommandEvent = {
|
|
122
|
-
readonly type: "SEARCH_CHANGE";
|
|
123
|
-
readonly query: string;
|
|
124
|
-
} | {
|
|
125
|
-
readonly type: "ITEM_SELECT";
|
|
126
|
-
readonly id: ItemId;
|
|
127
|
-
} | {
|
|
128
|
-
readonly type: "ITEM_ACTIVATE";
|
|
129
|
-
readonly id: ItemId;
|
|
130
|
-
} | {
|
|
131
|
-
readonly type: "NAVIGATE";
|
|
132
|
-
readonly direction: "next" | "prev" | "first" | "last";
|
|
133
|
-
} | {
|
|
134
|
-
readonly type: "PAGE_PUSH";
|
|
135
|
-
readonly page: string;
|
|
136
|
-
} | {
|
|
137
|
-
readonly type: "PAGE_POP";
|
|
138
|
-
} | {
|
|
139
|
-
readonly type: "OPEN";
|
|
140
|
-
} | {
|
|
141
|
-
readonly type: "CLOSE";
|
|
142
|
-
} | {
|
|
143
|
-
readonly type: "TOGGLE";
|
|
144
|
-
} | {
|
|
145
|
-
readonly type: "ITEMS_LOADED";
|
|
146
|
-
readonly items: readonly CommandItem$1[];
|
|
147
|
-
} | {
|
|
148
|
-
readonly type: "REGISTER_ITEM";
|
|
149
|
-
readonly item: CommandItem$1;
|
|
150
|
-
} | {
|
|
151
|
-
readonly type: "UNREGISTER_ITEM";
|
|
152
|
-
readonly id: ItemId;
|
|
153
|
-
} | {
|
|
154
|
-
readonly type: "REGISTER_GROUP";
|
|
155
|
-
readonly group: CommandGroup$1;
|
|
156
|
-
} | {
|
|
157
|
-
readonly type: "UNREGISTER_GROUP";
|
|
158
|
-
readonly id: GroupId;
|
|
159
|
-
};
|
|
160
|
-
/** Frecency record for a single item */
|
|
161
|
-
interface FrecencyRecord {
|
|
162
|
-
readonly frequency: number;
|
|
163
|
-
/** Epoch-millisecond timestamp of last usage */
|
|
164
|
-
readonly lastUsed: number;
|
|
165
|
-
}
|
|
166
|
-
/** Complete frecency data for persistence */
|
|
167
|
-
interface FrecencyData {
|
|
168
|
-
readonly records: ReadonlyMap<ItemId, FrecencyRecord>;
|
|
169
|
-
}
|
|
170
|
-
/** Pluggable frecency storage interface */
|
|
171
|
-
interface FrecencyStorage extends Disposable {
|
|
172
|
-
load(namespace: string): FrecencyData | Promise<FrecencyData>;
|
|
173
|
-
save(namespace: string, data: FrecencyData): void | Promise<void>;
|
|
174
|
-
}
|
|
175
|
-
/** Frecency exponential decay bucket configuration */
|
|
176
|
-
interface FrecencyDecayConfig {
|
|
177
|
-
readonly hourWeight?: number | undefined;
|
|
178
|
-
readonly dayWeight?: number | undefined;
|
|
179
|
-
readonly weekWeight?: number | undefined;
|
|
180
|
-
readonly monthWeight?: number | undefined;
|
|
181
|
-
readonly olderWeight?: number | undefined;
|
|
182
|
-
}
|
|
183
|
-
/** Frecency configuration options */
|
|
184
|
-
interface FrecencyOptions {
|
|
185
|
-
readonly enabled: boolean;
|
|
186
|
-
readonly storage?: FrecencyStorage | undefined;
|
|
187
|
-
readonly namespace?: string | undefined;
|
|
188
|
-
readonly decayConfig?: FrecencyDecayConfig | undefined;
|
|
189
|
-
}
|
|
190
|
-
/** Options for creating a command machine — const type param for narrowed option inference */
|
|
191
|
-
interface CommandMachineOptions {
|
|
192
|
-
/** Pre-registered items to populate on creation */
|
|
193
|
-
readonly items?: readonly CommandItem$1[] | undefined;
|
|
194
|
-
/** Pre-registered groups for item categorization */
|
|
195
|
-
readonly groups?: readonly CommandGroup$1[] | undefined;
|
|
196
|
-
/** Custom filter function, or `false` to disable filtering entirely */
|
|
197
|
-
readonly filter?: ((item: CommandItem$1, query: string) => number | false) | false | undefined;
|
|
198
|
-
/** Accessible label for the command palette */
|
|
199
|
-
readonly label?: string | undefined;
|
|
200
|
-
/** Initial open state */
|
|
201
|
-
readonly open?: boolean | undefined;
|
|
202
|
-
/** Frecency configuration for usage-aware ranking */
|
|
203
|
-
readonly frecency?: FrecencyOptions | undefined;
|
|
204
|
-
/** Pluggable search engine — drop-in replacement for the default scorer (e.g., WASM engine) */
|
|
205
|
-
readonly search?: SearchEngine | undefined;
|
|
206
|
-
/** Callback fired when an item is selected */
|
|
207
|
-
readonly onSelect?: ((id: ItemId) => void) | undefined;
|
|
208
|
-
/** Callback fired when the active (highlighted) item changes */
|
|
209
|
-
readonly onActiveChange?: ((id: ItemId | null) => void) | undefined;
|
|
210
|
-
/** Callback fired when the dialog open state changes */
|
|
211
|
-
readonly onOpenChange?: ((open: boolean) => void) | undefined;
|
|
212
|
-
/** Callback fired when the search query changes */
|
|
213
|
-
readonly onSearchChange?: ((query: string) => void) | undefined;
|
|
214
|
-
/** Whether keyboard navigation loops from last to first item (default: true) */
|
|
215
|
-
readonly loop?: boolean | undefined;
|
|
216
|
-
/** Item count threshold for automatic virtualization (default: 100) */
|
|
217
|
-
readonly virtualizeThreshold?: number | undefined;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Structured representation of a keyboard shortcut after parsing.
|
|
221
|
-
* The `normalized` field provides a deterministic string for dedup and comparison.
|
|
222
|
-
*/
|
|
223
|
-
interface ParsedShortcut {
|
|
224
|
-
readonly key: string;
|
|
225
|
-
readonly meta: boolean;
|
|
226
|
-
readonly ctrl: boolean;
|
|
227
|
-
readonly shift: boolean;
|
|
228
|
-
readonly alt: boolean;
|
|
229
|
-
readonly raw: string;
|
|
230
|
-
readonly normalized: string;
|
|
231
|
-
}
|
|
232
|
-
interface ShortcutBinding {
|
|
233
|
-
readonly shortcut: ParsedShortcut;
|
|
234
|
-
readonly itemId: ItemId;
|
|
235
|
-
readonly handler: () => void;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
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
|
-
*/
|
|
242
|
-
declare class KeyboardShortcutRegistry implements Disposable {
|
|
243
|
-
#private;
|
|
244
|
-
constructor(options?: {
|
|
245
|
-
enabled?: boolean;
|
|
246
|
-
});
|
|
247
|
-
/** Register a shortcut binding — returns Disposable for `using` auto-deregister */
|
|
248
|
-
register(shortcutStr: string, itemId: ItemId, handler: () => void): Disposable;
|
|
249
|
-
/** Unregister a shortcut by its string representation */
|
|
250
|
-
unregister(shortcutStr: string): void;
|
|
251
|
-
/** Unregister all shortcuts for a given item — Map spec allows deletion during iteration */
|
|
252
|
-
unregisterByItem(itemId: ItemId): void;
|
|
253
|
-
/** Check for conflicting shortcuts */
|
|
254
|
-
getConflicts(): ReadonlyMap<string, readonly ParsedShortcut[]>;
|
|
255
|
-
/** Enable or disable global shortcut listening */
|
|
256
|
-
setEnabled(enabled: boolean): void;
|
|
257
|
-
/** Get all registered bindings */
|
|
258
|
-
getBindings(): ReadonlyMap<string, ShortcutBinding>;
|
|
259
|
-
[Symbol.dispose](): void;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
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
|
-
*/
|
|
266
|
-
declare class CommandRegistry implements Disposable {
|
|
267
|
-
#private;
|
|
268
|
-
/** Register an item — returns Disposable for `using` auto-deregister */
|
|
269
|
-
registerItem(item: CommandItem$1): Disposable;
|
|
270
|
-
/** Register multiple items at once — single Disposable for batch cleanup. for...of for hot path. */
|
|
271
|
-
registerItems(items: readonly CommandItem$1[]): Disposable;
|
|
272
|
-
/** Unregister a single item — O(1) Map/Set delete, indexOf+toSpliced for order */
|
|
273
|
-
unregisterItem(id: ItemId): void;
|
|
274
|
-
/** Bulk unregister — for...of for hot path */
|
|
275
|
-
unregisterItems(ids: ReadonlySet<ItemId>): void;
|
|
276
|
-
/** Register a group */
|
|
277
|
-
registerGroup(group: CommandGroup$1): Disposable;
|
|
278
|
-
/** Unregister a group */
|
|
279
|
-
unregisterGroup(id: GroupId): void;
|
|
280
|
-
/** Get an item by ID — O(1) */
|
|
281
|
-
getItem(id: ItemId): CommandItem$1 | undefined;
|
|
282
|
-
/** Get a group by ID — O(1) */
|
|
283
|
-
getGroup(id: GroupId): CommandGroup$1 | undefined;
|
|
284
|
-
/** Get all registered items in insertion order — cached between mutations */
|
|
285
|
-
getItems(): readonly CommandItem$1[];
|
|
286
|
-
/** Get all registered groups sorted by priority — cached between group mutations */
|
|
287
|
-
getGroups(): readonly CommandGroup$1[];
|
|
288
|
-
/** Get items grouped by groupId — direct Map, no Object.entries conversion */
|
|
289
|
-
getGroupedItems(): ReadonlyMap<GroupId, readonly CommandItem$1[]>;
|
|
290
|
-
/** Get item IDs as a Set — returns internal set (O(1), no allocation) */
|
|
291
|
-
getItemIds(): ReadonlySet<ItemId>;
|
|
292
|
-
/** Find intersection of registered items with a candidate set */
|
|
293
|
-
intersectWith(candidateIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
294
|
-
/** Find items registered but not in a given set */
|
|
295
|
-
differenceFrom(otherIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
296
|
-
/** Union of registered IDs with another set */
|
|
297
|
-
unionWith(otherIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
298
|
-
/** Check if registered items are a subset of the given set */
|
|
299
|
-
isSubsetOf(otherIds: ReadonlySet<ItemId>): boolean;
|
|
300
|
-
/** Check if registered items are a superset of the given set */
|
|
301
|
-
isSupersetOf(otherIds: ReadonlySet<ItemId>): boolean;
|
|
302
|
-
/** Check if registered items share no IDs with the given set */
|
|
303
|
-
isDisjointFrom(otherIds: ReadonlySet<ItemId>): boolean;
|
|
304
|
-
/** Symmetric difference between registered IDs and another set */
|
|
305
|
-
symmetricDifferenceWith(otherIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
306
|
-
/** Total number of registered items */
|
|
307
|
-
get size(): number;
|
|
308
|
-
/** Total number of registered groups */
|
|
309
|
-
get groupCount(): number;
|
|
310
|
-
/** Clear all items and groups */
|
|
311
|
-
clear(): void;
|
|
312
|
-
[Symbol.dispose](): void;
|
|
313
|
-
}
|
|
314
|
-
/** Command machine — explicit resource management via `using` */
|
|
315
|
-
interface CommandMachine extends Disposable {
|
|
316
|
-
getState(): CommandState;
|
|
317
|
-
send(event: CommandEvent): void;
|
|
318
|
-
/** Subscribe to state changes — useSyncExternalStore-compatible (returns cleanup function) */
|
|
319
|
-
subscribe(listener: () => void): () => void;
|
|
320
|
-
/** Subscribe to full state changes — returns Disposable for `using` pattern */
|
|
321
|
-
subscribeState(listener: (state: CommandState) => void): Disposable;
|
|
322
|
-
getRegistry(): CommandRegistry;
|
|
323
|
-
getKeyboardRegistry(): KeyboardShortcutRegistry;
|
|
324
|
-
/** Get the current set of filtered item IDs — O(1) membership checks */
|
|
325
|
-
getFilteredIdSet(): ReadonlySet<ItemId>;
|
|
326
|
-
/** Get the index map for filtered IDs — O(1) positional lookup */
|
|
327
|
-
getFilteredIdIndex(): ReadonlyMap<ItemId, number>;
|
|
328
|
-
[Symbol.dispose](): void;
|
|
329
|
-
}
|
|
330
19
|
interface CommandAsyncItemsProps {
|
|
331
20
|
/** Promise that resolves to items */
|
|
332
21
|
readonly items: Promise<readonly CommandItem$1[]>;
|
|
@@ -340,21 +29,6 @@ export declare function CommandAsyncItems({ items, fallback, children }: Command
|
|
|
340
29
|
interface CommandBadgeProps extends ComponentPropsWithRef<"span"> {}
|
|
341
30
|
/** Inline badge for categorization or status indicators on command items. */
|
|
342
31
|
export declare function CommandBadge({ ref, children, ...props }: CommandBadgeProps): ReactNode;
|
|
343
|
-
interface CommandDialogProps extends CommandMachineOptions {
|
|
344
|
-
readonly children?: ReactNode;
|
|
345
|
-
readonly className?: string;
|
|
346
|
-
readonly overlayClassName?: string;
|
|
347
|
-
readonly contentClassName?: string;
|
|
348
|
-
readonly label?: string;
|
|
349
|
-
readonly open?: boolean;
|
|
350
|
-
readonly onOpenChange?: (open: boolean) => void;
|
|
351
|
-
/** Accessible description for screen readers (default: 'Type a command or search...') */
|
|
352
|
-
readonly description?: string;
|
|
353
|
-
/** Container element for the portal (default: document.body) */
|
|
354
|
-
readonly container?: HTMLElement | null;
|
|
355
|
-
}
|
|
356
|
-
/** Dialog variant that wraps the command palette in a Radix UI Dialog with focus trap and overlay. */
|
|
357
|
-
export declare function CommandDialog({ children, className, overlayClassName, contentClassName, label, description, open: controlledOpen, onOpenChange, container, ...machineOptions }: CommandDialogProps): ReactNode;
|
|
358
32
|
interface CommandEmptyProps extends ComponentPropsWithRef<"div"> {}
|
|
359
33
|
/** Rendered when no items match the current search query. */
|
|
360
34
|
export declare function CommandEmpty({ ref, children, ...props }: CommandEmptyProps): ReactNode;
|
|
@@ -371,7 +45,7 @@ export declare function CommandGroup({ ref, children, heading, priority, forceId
|
|
|
371
45
|
interface CommandHighlightProps {
|
|
372
46
|
/** The full text to display */
|
|
373
47
|
readonly text: string;
|
|
374
|
-
/** Match ranges from search scorer — [start, end
|
|
48
|
+
/** Match ranges from the search scorer — half-open [start, end) tuples, end exclusive */
|
|
375
49
|
readonly ranges: ReadonlyArray<readonly [start: number, end: number]>;
|
|
376
50
|
/** Custom className for highlighted segments */
|
|
377
51
|
readonly highlightClassName?: string;
|
|
@@ -463,6 +137,7 @@ type CommandRootId = string & {
|
|
|
463
137
|
interface CommandContextValue {
|
|
464
138
|
readonly machine: CommandMachine;
|
|
465
139
|
readonly state: CommandState;
|
|
140
|
+
/** True while an optimistic active-item transition is in flight (search updates never set it). */
|
|
466
141
|
readonly isPending: boolean;
|
|
467
142
|
readonly updateSearch: (query: string) => void;
|
|
468
143
|
readonly setOptimisticActiveId: (id: ItemId | null) => void;
|
|
@@ -470,7 +145,7 @@ interface CommandContextValue {
|
|
|
470
145
|
readonly filteredIdSet: ReadonlySet<ItemId>;
|
|
471
146
|
/** IDs currently visible in virtual viewport + overscan. null = not virtualizing (render all filtered). */
|
|
472
147
|
readonly visibleIdSet: ReadonlySet<ItemId> | null;
|
|
473
|
-
/** Map of visible item IDs to their
|
|
148
|
+
/** Map of visible item IDs to their translate offsets in px. null = not virtualizing. */
|
|
474
149
|
readonly virtualPositionMap: ReadonlyMap<ItemId, number> | null;
|
|
475
150
|
readonly rootId: CommandRootId;
|
|
476
151
|
readonly listId: string;
|
|
@@ -490,11 +165,12 @@ interface CommandStableContextValue {
|
|
|
490
165
|
/** State context — values that change on every search/navigation */
|
|
491
166
|
interface CommandStateContextValue {
|
|
492
167
|
readonly state: CommandState;
|
|
168
|
+
/** True while an optimistic active-item transition is in flight (search updates never set it). */
|
|
493
169
|
readonly isPending: boolean;
|
|
494
170
|
readonly filteredIdSet: ReadonlySet<ItemId>;
|
|
495
171
|
/** IDs currently visible in virtual viewport + overscan. null = not virtualizing (render all filtered). */
|
|
496
172
|
readonly visibleIdSet: ReadonlySet<ItemId> | null;
|
|
497
|
-
/** Map of visible item IDs to their
|
|
173
|
+
/** Map of visible item IDs to their translate offsets in px. null = not virtualizing. */
|
|
498
174
|
readonly virtualPositionMap: ReadonlyMap<ItemId, number> | null;
|
|
499
175
|
}
|
|
500
176
|
export declare const CommandStableContext: Context<CommandStableContextValue | null>;
|
|
@@ -520,14 +196,16 @@ export declare class CommandErrorBoundary extends Component<CommandErrorBoundary
|
|
|
520
196
|
}
|
|
521
197
|
interface UseCommandReturn {
|
|
522
198
|
readonly state: CommandState;
|
|
199
|
+
/** True while an optimistic active-item transition is in flight. Search updates never set it: the machine applies them on its own scheduler tick, outside React. */
|
|
523
200
|
readonly isPending: boolean;
|
|
201
|
+
/** Queue a search query on the machine. Not a React update: Command.Input owns the urgent input value. */
|
|
524
202
|
readonly updateSearch: (query: string) => void;
|
|
525
203
|
readonly setOptimisticActiveId: (id: ItemId | null) => void;
|
|
526
204
|
/** O(1) membership set for filtered items — used by Item component */
|
|
527
205
|
readonly filteredIdSet: ReadonlySet<ItemId>;
|
|
528
206
|
readonly id: CommandRootId;
|
|
529
207
|
}
|
|
530
|
-
/** Core hook that binds a CommandMachine to React via useSyncExternalStore,
|
|
208
|
+
/** Core hook that binds a CommandMachine to React via useSyncExternalStore, useOptimistic, and a transition for optimistic active-item updates. */
|
|
531
209
|
export declare function useCommand(machine: CommandMachine): UseCommandReturn;
|
|
532
210
|
/** Get the full command state with proper subscription */
|
|
533
211
|
export declare function useCommandState(): CommandState;
|
|
@@ -590,4 +268,4 @@ interface VirtualizerReturn {
|
|
|
590
268
|
}
|
|
591
269
|
/** Lightweight virtualizer for large item lists using ResizeObserver and scroll tracking. */
|
|
592
270
|
export declare function useVirtualizer(options: VirtualizerOptions): VirtualizerReturn;
|
|
593
|
-
export type
|
|
271
|
+
export { type ActivityMode, type CommandActivityProps, type CommandAsyncItemsProps, type CommandBadgeProps, type CommandContextValue, CommandDialog, type CommandDialogProps, type CommandEmptyProps, type CommandErrorBoundaryProps, type CommandGroupContextValue, type CommandGroupProps, type CommandHighlightProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandLoadingProps, type CommandPageId, type CommandPageProps, type CommandRootId, type CommandRootProps, type CommandSeparatorProps, type CommandShortcutProps, type CommandStableContextValue, type CommandStateContextValue, type RegisterGroupOptions, type RegisterItemOptions, type UseCommandReturn, type VirtualItem, type VirtualizerOptions, type VirtualizerReturn };
|