modern-cmdk 1.0.2 → 1.1.1
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/codemod/cli.mjs +1 -3
- package/dist/codemod/transforms/data-attrs.d.mts +1 -2
- package/dist/codemod/transforms/data-attrs.mjs +0 -2
- package/dist/codemod/transforms/forward-ref.d.mts +1 -2
- package/dist/codemod/transforms/forward-ref.mjs +0 -2
- package/dist/codemod/transforms/import-rewrite.d.mts +1 -2
- package/dist/codemod/transforms/import-rewrite.mjs +0 -2
- package/dist/codemod/transforms/should-filter.d.mts +1 -2
- package/dist/codemod/transforms/should-filter.mjs +0 -2
- package/dist/core/index.d.mts +568 -2
- package/dist/core/index.mjs +1268 -1
- package/dist/react/index.d.mts +349 -3
- package/dist/react/index.mjs +1292 -209
- package/package.json +26 -12
- package/dist/codemod/cli.mjs.map +0 -1
- package/dist/codemod/transforms/data-attrs.d.mts.map +0 -1
- package/dist/codemod/transforms/data-attrs.mjs.map +0 -1
- package/dist/codemod/transforms/forward-ref.d.mts.map +0 -1
- package/dist/codemod/transforms/forward-ref.mjs.map +0 -1
- package/dist/codemod/transforms/import-rewrite.d.mts.map +0 -1
- package/dist/codemod/transforms/import-rewrite.mjs.map +0 -1
- package/dist/codemod/transforms/should-filter.d.mts.map +0 -1
- package/dist/codemod/transforms/should-filter.mjs.map +0 -1
- package/dist/core-CgQYpHK3.mjs +0 -1235
- package/dist/core-CgQYpHK3.mjs.map +0 -1
- package/dist/index-C6g94P7V.d.mts +0 -563
- package/dist/index-C6g94P7V.d.mts.map +0 -1
- package/dist/react/index.d.mts.map +0 -1
- package/dist/react/index.mjs.map +0 -1
- /package/{src → dist}/react/styles.css +0 -0
package/dist/react/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { Component, ComponentPropsWithRef, Context, ErrorInfo, ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/react/activity.d.ts
|
|
@@ -20,6 +20,330 @@ declare function CommandActivity({
|
|
|
20
20
|
children
|
|
21
21
|
}: CommandActivityProps): ReactNode;
|
|
22
22
|
//#endregion
|
|
23
|
+
//#region src/core/search/types.d.ts
|
|
24
|
+
/** Result of scoring a single item against a query */
|
|
25
|
+
interface SearchResult {
|
|
26
|
+
readonly id: ItemId;
|
|
27
|
+
readonly score: number;
|
|
28
|
+
/** Character ranges that matched (for highlighting) — [start, end] tuples */
|
|
29
|
+
readonly matches: ReadonlyArray<readonly [start: number, end: number]>;
|
|
30
|
+
}
|
|
31
|
+
/** Search engine interface — pluggable into the state machine */
|
|
32
|
+
interface SearchEngine extends Disposable {
|
|
33
|
+
/** Index items for fast lookup (call on registration) */
|
|
34
|
+
index(items: readonly CommandItem$1[]): void;
|
|
35
|
+
/** Search items by query, return ordered results — uses Iterator pipeline */
|
|
36
|
+
search(query: string, items: readonly CommandItem$1[]): IteratorObject<SearchResult>;
|
|
37
|
+
/** Remove items from index — uses Set.difference for efficient bulk removal */
|
|
38
|
+
remove(ids: ReadonlySet<ItemId>): void;
|
|
39
|
+
/** Clear the entire index */
|
|
40
|
+
clear(): void;
|
|
41
|
+
/** Dispose resources */
|
|
42
|
+
[Symbol.dispose](): void;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/core/types.d.ts
|
|
46
|
+
/**
|
|
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
|
+
*/
|
|
56
|
+
declare const __itemIdBrand: unique symbol;
|
|
57
|
+
type ItemId = string & {
|
|
58
|
+
readonly [__itemIdBrand]: never;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Branded type for group IDs.
|
|
62
|
+
* Prevents accidental mixing with plain strings or ItemId at the type level.
|
|
63
|
+
*/
|
|
64
|
+
declare const __groupIdBrand: unique symbol;
|
|
65
|
+
type GroupId = string & {
|
|
66
|
+
readonly [__groupIdBrand]: never;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A registered command item in the palette.
|
|
70
|
+
* All fields are readonly — state machine creates new items on update.
|
|
71
|
+
*/
|
|
72
|
+
interface CommandItem$1 {
|
|
73
|
+
/** Unique identifier (branded type) */
|
|
74
|
+
readonly id: ItemId;
|
|
75
|
+
/** Display text — also used as the primary search target */
|
|
76
|
+
readonly value: string;
|
|
77
|
+
/** Additional searchable terms (matched but not displayed) */
|
|
78
|
+
readonly keywords?: readonly string[] | undefined;
|
|
79
|
+
/** Group this item belongs to (items without groupId are ungrouped) */
|
|
80
|
+
readonly groupId?: GroupId | undefined;
|
|
81
|
+
/** Keyboard shortcut string (e.g., "Ctrl+C", "Mod+K") */
|
|
82
|
+
readonly shortcut?: string | undefined;
|
|
83
|
+
/** Whether this item is disabled (excluded from filtering and selection) */
|
|
84
|
+
readonly disabled?: boolean | undefined;
|
|
85
|
+
/** Callback fired when this item is selected */
|
|
86
|
+
readonly onSelect?: (() => void) | undefined;
|
|
87
|
+
/** Arbitrary metadata attached to the item */
|
|
88
|
+
readonly data?: Readonly<Record<string, unknown>> | undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A command group for categorizing items.
|
|
92
|
+
* Groups are rendered with headings and sorted by priority.
|
|
93
|
+
*/
|
|
94
|
+
interface CommandGroup$1 {
|
|
95
|
+
/** Unique identifier (branded type) */
|
|
96
|
+
readonly id: GroupId;
|
|
97
|
+
/** Display heading text (rendered above the group's items) */
|
|
98
|
+
readonly heading?: string | undefined;
|
|
99
|
+
/** Sort priority — lower values appear first (default: 0) */
|
|
100
|
+
readonly priority?: number | undefined;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
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
|
+
*/
|
|
107
|
+
interface CommandState {
|
|
108
|
+
/** Current search query string */
|
|
109
|
+
readonly search: string;
|
|
110
|
+
/** Currently active (highlighted) item ID, or null if none */
|
|
111
|
+
readonly activeId: ItemId | null;
|
|
112
|
+
/** Ordered list of item IDs that pass the current filter */
|
|
113
|
+
readonly filteredIds: readonly ItemId[];
|
|
114
|
+
/** Map of group IDs to their visible item IDs */
|
|
115
|
+
readonly groupedIds: ReadonlyMap<GroupId, readonly ItemId[]>;
|
|
116
|
+
/** Count of visible items (shortcut for `filteredIds.length`) */
|
|
117
|
+
readonly filteredCount: number;
|
|
118
|
+
/** Whether async items are currently loading */
|
|
119
|
+
readonly loading: boolean;
|
|
120
|
+
/** Current page identifier (for multi-page navigation) */
|
|
121
|
+
readonly page: string;
|
|
122
|
+
/** Stack of previous pages for back-navigation */
|
|
123
|
+
readonly pageStack: readonly string[];
|
|
124
|
+
/** Whether the command palette dialog is open */
|
|
125
|
+
readonly open: boolean;
|
|
126
|
+
/** Temporal.Instant of the last state mutation (ES2026) */
|
|
127
|
+
readonly lastUpdated: Temporal.Instant;
|
|
128
|
+
}
|
|
129
|
+
/** All possible events the state machine accepts */
|
|
130
|
+
type CommandEvent = {
|
|
131
|
+
readonly type: "SEARCH_CHANGE";
|
|
132
|
+
readonly query: string;
|
|
133
|
+
} | {
|
|
134
|
+
readonly type: "ITEM_SELECT";
|
|
135
|
+
readonly id: ItemId;
|
|
136
|
+
} | {
|
|
137
|
+
readonly type: "ITEM_ACTIVATE";
|
|
138
|
+
readonly id: ItemId;
|
|
139
|
+
} | {
|
|
140
|
+
readonly type: "NAVIGATE";
|
|
141
|
+
readonly direction: "next" | "prev" | "first" | "last";
|
|
142
|
+
} | {
|
|
143
|
+
readonly type: "PAGE_PUSH";
|
|
144
|
+
readonly page: string;
|
|
145
|
+
} | {
|
|
146
|
+
readonly type: "PAGE_POP";
|
|
147
|
+
} | {
|
|
148
|
+
readonly type: "OPEN";
|
|
149
|
+
} | {
|
|
150
|
+
readonly type: "CLOSE";
|
|
151
|
+
} | {
|
|
152
|
+
readonly type: "TOGGLE";
|
|
153
|
+
} | {
|
|
154
|
+
readonly type: "ITEMS_LOADED";
|
|
155
|
+
readonly items: readonly CommandItem$1[];
|
|
156
|
+
} | {
|
|
157
|
+
readonly type: "REGISTER_ITEM";
|
|
158
|
+
readonly item: CommandItem$1;
|
|
159
|
+
} | {
|
|
160
|
+
readonly type: "UNREGISTER_ITEM";
|
|
161
|
+
readonly id: ItemId;
|
|
162
|
+
} | {
|
|
163
|
+
readonly type: "REGISTER_GROUP";
|
|
164
|
+
readonly group: CommandGroup$1;
|
|
165
|
+
} | {
|
|
166
|
+
readonly type: "UNREGISTER_GROUP";
|
|
167
|
+
readonly id: GroupId;
|
|
168
|
+
};
|
|
169
|
+
/** Frecency record for a single item */
|
|
170
|
+
interface FrecencyRecord {
|
|
171
|
+
readonly frequency: number;
|
|
172
|
+
readonly lastUsed: Temporal.Instant;
|
|
173
|
+
}
|
|
174
|
+
/** Complete frecency data for persistence */
|
|
175
|
+
interface FrecencyData {
|
|
176
|
+
readonly records: ReadonlyMap<ItemId, FrecencyRecord>;
|
|
177
|
+
}
|
|
178
|
+
/** Pluggable frecency storage interface */
|
|
179
|
+
interface FrecencyStorage extends Disposable {
|
|
180
|
+
load(namespace: string): FrecencyData | Promise<FrecencyData>;
|
|
181
|
+
save(namespace: string, data: FrecencyData): void | Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
/** Frecency exponential decay bucket configuration */
|
|
184
|
+
interface FrecencyDecayConfig {
|
|
185
|
+
readonly hourWeight?: number | undefined;
|
|
186
|
+
readonly dayWeight?: number | undefined;
|
|
187
|
+
readonly weekWeight?: number | undefined;
|
|
188
|
+
readonly monthWeight?: number | undefined;
|
|
189
|
+
readonly olderWeight?: number | undefined;
|
|
190
|
+
}
|
|
191
|
+
/** Frecency configuration options */
|
|
192
|
+
interface FrecencyOptions {
|
|
193
|
+
readonly enabled: boolean;
|
|
194
|
+
readonly storage?: FrecencyStorage | undefined;
|
|
195
|
+
readonly namespace?: string | undefined;
|
|
196
|
+
readonly decayConfig?: FrecencyDecayConfig | undefined;
|
|
197
|
+
}
|
|
198
|
+
/** Options for creating a command machine — const type param for narrowed option inference */
|
|
199
|
+
interface CommandMachineOptions {
|
|
200
|
+
/** Pre-registered items to populate on creation */
|
|
201
|
+
readonly items?: readonly CommandItem$1[] | undefined;
|
|
202
|
+
/** Pre-registered groups for item categorization */
|
|
203
|
+
readonly groups?: readonly CommandGroup$1[] | undefined;
|
|
204
|
+
/** Custom filter function, or `false` to disable filtering entirely */
|
|
205
|
+
readonly filter?: ((item: CommandItem$1, query: string) => number | false) | false | undefined;
|
|
206
|
+
/** Accessible label for the command palette */
|
|
207
|
+
readonly label?: string | undefined;
|
|
208
|
+
/** Initial open state */
|
|
209
|
+
readonly open?: boolean | undefined;
|
|
210
|
+
/** Frecency configuration for usage-aware ranking */
|
|
211
|
+
readonly frecency?: FrecencyOptions | undefined;
|
|
212
|
+
/** Pluggable search engine — drop-in replacement for the default scorer (e.g., WASM engine) */
|
|
213
|
+
readonly search?: SearchEngine | undefined;
|
|
214
|
+
/** Callback fired when an item is selected */
|
|
215
|
+
readonly onSelect?: ((id: ItemId) => void) | undefined;
|
|
216
|
+
/** Callback fired when the active (highlighted) item changes */
|
|
217
|
+
readonly onActiveChange?: ((id: ItemId | null) => void) | undefined;
|
|
218
|
+
/** Callback fired when the dialog open state changes */
|
|
219
|
+
readonly onOpenChange?: ((open: boolean) => void) | undefined;
|
|
220
|
+
/** Callback fired when the search query changes */
|
|
221
|
+
readonly onSearchChange?: ((query: string) => void) | undefined;
|
|
222
|
+
/** Whether keyboard navigation loops from last to first item (default: true) */
|
|
223
|
+
readonly loop?: boolean | undefined;
|
|
224
|
+
/** Item count threshold for automatic virtualization (default: 100) */
|
|
225
|
+
readonly virtualizeThreshold?: number | undefined;
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/core/keyboard/parser.d.ts
|
|
229
|
+
/**
|
|
230
|
+
* Structured representation of a keyboard shortcut after parsing.
|
|
231
|
+
* The `normalized` field provides a deterministic string for dedup and comparison.
|
|
232
|
+
*/
|
|
233
|
+
interface ParsedShortcut {
|
|
234
|
+
readonly key: string;
|
|
235
|
+
readonly meta: boolean;
|
|
236
|
+
readonly ctrl: boolean;
|
|
237
|
+
readonly shift: boolean;
|
|
238
|
+
readonly alt: boolean;
|
|
239
|
+
readonly raw: string;
|
|
240
|
+
readonly normalized: string;
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/core/keyboard/index.d.ts
|
|
244
|
+
interface ShortcutBinding {
|
|
245
|
+
readonly shortcut: ParsedShortcut;
|
|
246
|
+
readonly itemId: ItemId;
|
|
247
|
+
readonly handler: () => void;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Manages keyboard shortcut bindings with global keydown listening.
|
|
251
|
+
* Supports `using` for automatic cleanup of both individual bindings and the
|
|
252
|
+
* global document listener. Detects conflicts via Map.groupBy (ES2026).
|
|
253
|
+
*/
|
|
254
|
+
declare class KeyboardShortcutRegistry implements Disposable {
|
|
255
|
+
#private;
|
|
256
|
+
constructor(options?: {
|
|
257
|
+
enabled?: boolean;
|
|
258
|
+
});
|
|
259
|
+
/** Register a shortcut binding — returns Disposable for `using` auto-deregister */
|
|
260
|
+
register(shortcutStr: string, itemId: ItemId, handler: () => void): Disposable;
|
|
261
|
+
/** Unregister a shortcut by its string representation */
|
|
262
|
+
unregister(shortcutStr: string): void;
|
|
263
|
+
/** Unregister all shortcuts for a given item — Map spec allows deletion during iteration */
|
|
264
|
+
unregisterByItem(itemId: ItemId): void;
|
|
265
|
+
/** Check for conflicting shortcuts */
|
|
266
|
+
getConflicts(): ReadonlyMap<string, readonly ParsedShortcut[]>;
|
|
267
|
+
/** Enable or disable global shortcut listening */
|
|
268
|
+
setEnabled(enabled: boolean): void;
|
|
269
|
+
/** Get all registered bindings */
|
|
270
|
+
getBindings(): ReadonlyMap<string, ShortcutBinding>;
|
|
271
|
+
[Symbol.dispose](): void;
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/core/registry.d.ts
|
|
275
|
+
/**
|
|
276
|
+
* Manages registration and lookup of command items and groups.
|
|
277
|
+
* Uses ES2026 Set methods (union/intersection/difference) for efficient ID operations.
|
|
278
|
+
* All registration methods return Disposable for automatic cleanup via `using`.
|
|
279
|
+
*/
|
|
280
|
+
declare class CommandRegistry implements Disposable {
|
|
281
|
+
#private;
|
|
282
|
+
/** Register an item — returns Disposable for `using` auto-deregister */
|
|
283
|
+
registerItem(item: CommandItem$1): Disposable;
|
|
284
|
+
/** Register multiple items at once — single Disposable for batch cleanup. for...of for hot path. */
|
|
285
|
+
registerItems(items: readonly CommandItem$1[]): Disposable;
|
|
286
|
+
/** Unregister a single item — O(1) Map/Set delete, indexOf+toSpliced for order */
|
|
287
|
+
unregisterItem(id: ItemId): void;
|
|
288
|
+
/** Bulk unregister using Set.difference (ES2026) — for...of for hot path */
|
|
289
|
+
unregisterItems(ids: ReadonlySet<ItemId>): void;
|
|
290
|
+
/** Register a group */
|
|
291
|
+
registerGroup(group: CommandGroup$1): Disposable;
|
|
292
|
+
/** Unregister a group */
|
|
293
|
+
unregisterGroup(id: GroupId): void;
|
|
294
|
+
/** Get an item by ID — O(1) */
|
|
295
|
+
getItem(id: ItemId): CommandItem$1 | undefined;
|
|
296
|
+
/** Get a group by ID — O(1) */
|
|
297
|
+
getGroup(id: GroupId): CommandGroup$1 | undefined;
|
|
298
|
+
/** Get all registered items in insertion order — cached between mutations */
|
|
299
|
+
getItems(): readonly CommandItem$1[];
|
|
300
|
+
/** Get all registered groups sorted by priority — cached between group mutations */
|
|
301
|
+
getGroups(): readonly CommandGroup$1[];
|
|
302
|
+
/** Get items grouped by groupId using Map.groupBy (ES2026) — direct Map, no Object.entries conversion */
|
|
303
|
+
getGroupedItems(): ReadonlyMap<GroupId, readonly CommandItem$1[]>;
|
|
304
|
+
/** Get item IDs as a Set — returns internal set (O(1), no allocation) */
|
|
305
|
+
getItemIds(): ReadonlySet<ItemId>;
|
|
306
|
+
/** Find intersection of registered items with a candidate set (ES2026 Set.intersection) */
|
|
307
|
+
intersectWith(candidateIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
308
|
+
/** Find items registered but not in a given set (ES2026 Set.difference) */
|
|
309
|
+
differenceFrom(otherIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
310
|
+
/** Union of registered IDs with another set (ES2026 Set.union) */
|
|
311
|
+
unionWith(otherIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
312
|
+
/** Check if registered items are a subset of the given set (ES2026 Set.isSubsetOf) */
|
|
313
|
+
isSubsetOf(otherIds: ReadonlySet<ItemId>): boolean;
|
|
314
|
+
/** Check if registered items are a superset of the given set (ES2026 Set.isSupersetOf) */
|
|
315
|
+
isSupersetOf(otherIds: ReadonlySet<ItemId>): boolean;
|
|
316
|
+
/** Check if registered items share no IDs with the given set (ES2026 Set.isDisjointFrom) */
|
|
317
|
+
isDisjointFrom(otherIds: ReadonlySet<ItemId>): boolean;
|
|
318
|
+
/** Symmetric difference between registered IDs and another set (ES2026 Set.symmetricDifference) */
|
|
319
|
+
symmetricDifferenceWith(otherIds: ReadonlySet<ItemId>): ReadonlySet<ItemId>;
|
|
320
|
+
/** Total number of registered items */
|
|
321
|
+
get size(): number;
|
|
322
|
+
/** Total number of registered groups */
|
|
323
|
+
get groupCount(): number;
|
|
324
|
+
/** Clear all items and groups */
|
|
325
|
+
clear(): void;
|
|
326
|
+
[Symbol.dispose](): void;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/core/machine.d.ts
|
|
330
|
+
/** Command machine — explicit resource management via `using` */
|
|
331
|
+
interface CommandMachine extends Disposable {
|
|
332
|
+
getState(): CommandState;
|
|
333
|
+
send(event: CommandEvent): void;
|
|
334
|
+
/** Subscribe to state changes — useSyncExternalStore-compatible (returns cleanup function) */
|
|
335
|
+
subscribe(listener: () => void): () => void;
|
|
336
|
+
/** Subscribe to full state changes — returns Disposable for `using` pattern */
|
|
337
|
+
subscribeState(listener: (state: CommandState) => void): Disposable;
|
|
338
|
+
getRegistry(): CommandRegistry;
|
|
339
|
+
getKeyboardRegistry(): KeyboardShortcutRegistry;
|
|
340
|
+
/** Get the current set of filtered item IDs — O(1) membership checks */
|
|
341
|
+
getFilteredIdSet(): ReadonlySet<ItemId>;
|
|
342
|
+
/** Get the index map for filtered IDs — O(1) positional lookup */
|
|
343
|
+
getFilteredIdIndex(): ReadonlyMap<ItemId, number>;
|
|
344
|
+
[Symbol.dispose](): void;
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
23
347
|
//#region src/react/async-items.d.ts
|
|
24
348
|
interface CommandAsyncItemsProps {
|
|
25
349
|
/** Promise that resolves to items */
|
|
@@ -29,6 +353,7 @@ interface CommandAsyncItemsProps {
|
|
|
29
353
|
/** Render function for resolved items */
|
|
30
354
|
readonly children: (items: readonly CommandItem$1[]) => ReactNode;
|
|
31
355
|
}
|
|
356
|
+
/** Suspense-based async item loader that resolves a promise of items using React 19 `use()`. */
|
|
32
357
|
declare function CommandAsyncItems({
|
|
33
358
|
items,
|
|
34
359
|
fallback,
|
|
@@ -37,6 +362,7 @@ declare function CommandAsyncItems({
|
|
|
37
362
|
//#endregion
|
|
38
363
|
//#region src/react/badge.d.ts
|
|
39
364
|
interface CommandBadgeProps extends ComponentPropsWithRef<"span"> {}
|
|
365
|
+
/** Inline badge for categorization or status indicators on command items. */
|
|
40
366
|
declare function CommandBadge({
|
|
41
367
|
ref,
|
|
42
368
|
children,
|
|
@@ -52,15 +378,19 @@ interface CommandDialogProps extends CommandMachineOptions {
|
|
|
52
378
|
readonly label?: string;
|
|
53
379
|
readonly open?: boolean;
|
|
54
380
|
readonly onOpenChange?: (open: boolean) => void;
|
|
381
|
+
/** Accessible description for screen readers (default: 'Type a command or search...') */
|
|
382
|
+
readonly description?: string;
|
|
55
383
|
/** Container element for the portal (default: document.body) */
|
|
56
384
|
readonly container?: HTMLElement | null;
|
|
57
385
|
}
|
|
386
|
+
/** Dialog variant that wraps the command palette in a Radix UI Dialog with focus trap and overlay. */
|
|
58
387
|
declare function CommandDialog({
|
|
59
388
|
children,
|
|
60
389
|
className,
|
|
61
390
|
overlayClassName,
|
|
62
391
|
contentClassName,
|
|
63
392
|
label,
|
|
393
|
+
description,
|
|
64
394
|
open: controlledOpen,
|
|
65
395
|
onOpenChange,
|
|
66
396
|
container,
|
|
@@ -69,6 +399,7 @@ declare function CommandDialog({
|
|
|
69
399
|
//#endregion
|
|
70
400
|
//#region src/react/empty.d.ts
|
|
71
401
|
interface CommandEmptyProps extends ComponentPropsWithRef<"div"> {}
|
|
402
|
+
/** Rendered when no items match the current search query. */
|
|
72
403
|
declare function CommandEmpty({
|
|
73
404
|
ref,
|
|
74
405
|
children,
|
|
@@ -84,6 +415,7 @@ interface CommandGroupProps extends ComponentPropsWithRef<"div"> {
|
|
|
84
415
|
/** Force a specific ID */
|
|
85
416
|
readonly forceId?: string;
|
|
86
417
|
}
|
|
418
|
+
/** Visual grouping container with an optional heading that hides when no items match. */
|
|
87
419
|
declare function CommandGroup({
|
|
88
420
|
ref,
|
|
89
421
|
children,
|
|
@@ -102,6 +434,7 @@ interface CommandHighlightProps {
|
|
|
102
434
|
/** Custom className for highlighted segments */
|
|
103
435
|
readonly highlightClassName?: string;
|
|
104
436
|
}
|
|
437
|
+
/** Renders search match highlighting by splitting text at scored match ranges. */
|
|
105
438
|
declare function CommandHighlight({
|
|
106
439
|
text,
|
|
107
440
|
ranges,
|
|
@@ -112,6 +445,7 @@ declare function CommandHighlight({
|
|
|
112
445
|
interface CommandInputProps extends Omit<ComponentPropsWithRef<"input">, "value" | "onChange" | "type" | "role"> {
|
|
113
446
|
readonly onValueChange?: (value: string) => void;
|
|
114
447
|
}
|
|
448
|
+
/** Combobox input that drives the command palette search state. */
|
|
115
449
|
declare function CommandInput({
|
|
116
450
|
ref,
|
|
117
451
|
placeholder,
|
|
@@ -128,6 +462,7 @@ interface CommandItemProps extends Omit<ComponentPropsWithRef<"div">, "onSelect"
|
|
|
128
462
|
readonly shortcut?: string;
|
|
129
463
|
readonly forceId?: string;
|
|
130
464
|
}
|
|
465
|
+
/** Individual selectable item in the command list with keyboard and pointer activation. */
|
|
131
466
|
declare function CommandItem({
|
|
132
467
|
ref,
|
|
133
468
|
children,
|
|
@@ -148,13 +483,17 @@ interface CommandListProps extends ComponentPropsWithRef<"div"> {
|
|
|
148
483
|
readonly estimateSize?: number;
|
|
149
484
|
/** Overscan count for virtualization (default: 8) */
|
|
150
485
|
readonly overscan?: number;
|
|
486
|
+
/** Custom aria-live announcement formatter for i18n (receives filtered count, returns announcement text) */
|
|
487
|
+
readonly announceResults?: (count: number) => string;
|
|
151
488
|
}
|
|
489
|
+
/** Scrollable list container with auto-virtualization and aria-live announcements. */
|
|
152
490
|
declare function CommandList({
|
|
153
491
|
ref,
|
|
154
492
|
children,
|
|
155
493
|
virtualize,
|
|
156
494
|
estimateSize,
|
|
157
495
|
overscan,
|
|
496
|
+
announceResults,
|
|
158
497
|
style,
|
|
159
498
|
...props
|
|
160
499
|
}: CommandListProps): ReactNode;
|
|
@@ -164,6 +503,7 @@ interface CommandLoadingProps extends ComponentPropsWithRef<"div"> {
|
|
|
164
503
|
/** Override the loading state detection */
|
|
165
504
|
readonly loading?: boolean;
|
|
166
505
|
}
|
|
506
|
+
/** Shown during async operations, with configurable loading state override. */
|
|
167
507
|
declare function CommandLoading({
|
|
168
508
|
ref,
|
|
169
509
|
children,
|
|
@@ -181,6 +521,7 @@ interface CommandPageProps {
|
|
|
181
521
|
readonly id: CommandPageId | string;
|
|
182
522
|
readonly children?: ReactNode;
|
|
183
523
|
}
|
|
524
|
+
/** Page navigation container that only renders when its ID matches the active page. */
|
|
184
525
|
declare function CommandPage({
|
|
185
526
|
id,
|
|
186
527
|
children
|
|
@@ -188,6 +529,7 @@ declare function CommandPage({
|
|
|
188
529
|
//#endregion
|
|
189
530
|
//#region src/react/separator.d.ts
|
|
190
531
|
interface CommandSeparatorProps extends ComponentPropsWithRef<"div"> {}
|
|
532
|
+
/** Visual divider between items or groups, rendered as a presentational element. */
|
|
191
533
|
declare function CommandSeparator({
|
|
192
534
|
ref,
|
|
193
535
|
...props
|
|
@@ -198,6 +540,7 @@ interface CommandShortcutProps extends ComponentPropsWithRef<"kbd"> {
|
|
|
198
540
|
/** Shortcut string to display (e.g., "Mod+K"). If not provided, reads from nearest Command.Item. */
|
|
199
541
|
readonly shortcut?: string;
|
|
200
542
|
}
|
|
543
|
+
/** Keyboard shortcut display with platform-aware formatting (e.g., Cmd vs Ctrl). */
|
|
201
544
|
declare function CommandShortcut({
|
|
202
545
|
ref,
|
|
203
546
|
shortcut,
|
|
@@ -211,6 +554,7 @@ interface CommandRootProps extends CommandMachineOptions {
|
|
|
211
554
|
readonly className?: string;
|
|
212
555
|
readonly label?: string;
|
|
213
556
|
}
|
|
557
|
+
/** Root compound component that provides the command state machine context to all children. */
|
|
214
558
|
declare function CommandRoot({
|
|
215
559
|
children,
|
|
216
560
|
className,
|
|
@@ -286,6 +630,7 @@ interface CommandErrorBoundaryProps {
|
|
|
286
630
|
interface CommandErrorBoundaryState {
|
|
287
631
|
readonly error: Error | null;
|
|
288
632
|
}
|
|
633
|
+
/** Error boundary for graceful failure recovery in command subtrees. */
|
|
289
634
|
declare class CommandErrorBoundary extends Component<CommandErrorBoundaryProps, CommandErrorBoundaryState> {
|
|
290
635
|
state: CommandErrorBoundaryState;
|
|
291
636
|
static getDerivedStateFromError(error: Error): CommandErrorBoundaryState;
|
|
@@ -303,6 +648,7 @@ interface UseCommandReturn {
|
|
|
303
648
|
readonly filteredIdSet: ReadonlySet<ItemId>;
|
|
304
649
|
readonly id: CommandRootId;
|
|
305
650
|
}
|
|
651
|
+
/** Core hook that binds a CommandMachine to React via useSyncExternalStore, useTransition, and useOptimistic. */
|
|
306
652
|
declare function useCommand(machine: CommandMachine): UseCommandReturn;
|
|
307
653
|
//#endregion
|
|
308
654
|
//#region src/react/hooks/use-command-state.d.ts
|
|
@@ -371,7 +717,7 @@ interface VirtualizerReturn {
|
|
|
371
717
|
readonly scrollToIndex: (index: number) => void;
|
|
372
718
|
readonly measureElement: (element: HTMLElement | null) => void;
|
|
373
719
|
}
|
|
720
|
+
/** Lightweight virtualizer for large item lists using ResizeObserver and scroll tracking. */
|
|
374
721
|
declare function useVirtualizer(options: VirtualizerOptions): VirtualizerReturn;
|
|
375
722
|
//#endregion
|
|
376
|
-
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 };
|
|
377
|
-
//# sourceMappingURL=index.d.mts.map
|
|
723
|
+
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 };
|