@principal-ade/panel-layouts 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -3,7 +3,9 @@ import { EditableConfigurablePanelLayout } from '@principal-ade/panels';
3
3
  import { EditableConfigurablePanelLayoutProps } from '@principal-ade/panels';
4
4
  import { mapThemeToPanelVars } from '@principal-ade/panels';
5
5
  import { mapThemeToTabVars } from '@principal-ade/panels';
6
+ import { PanelActions } from '@principal-ade/panel-framework-core';
6
7
  import { PanelBlurEventPayload } from '@principal-ade/panel-framework-core';
8
+ import { PanelContextValue } from '@principal-ade/panel-framework-core';
7
9
  import { PanelDefinition } from '@principal-ade/panels';
8
10
  import { PanelDefinitionWithContent } from '@principal-ade/panels';
9
11
  import { PanelEventEmitter } from '@principal-ade/panel-framework-core';
@@ -22,6 +24,241 @@ import { TilesConfig } from '@principal-ade/panels';
22
24
  */
23
25
  export declare type BuiltInWorkspaceId = 'project-management' | 'code-review' | 'documentation' | 'agent-work' | 'quality-check' | 'drawing' | 'old-school' | 'principal-office';
24
26
 
27
+ /**
28
+ * Command definition for the command palette
29
+ */
30
+ export declare interface Command {
31
+ /** Unique identifier for the command */
32
+ id: string;
33
+ /** Display label shown in the command list */
34
+ label: string;
35
+ /** Optional description shown below the label */
36
+ description?: string;
37
+ /** Optional icon (string or React element) */
38
+ icon?: string | React.ReactNode;
39
+ /** Keywords for fuzzy search matching */
40
+ keywords?: string[];
41
+ /** Category for grouping commands */
42
+ category?: string;
43
+ /** Optional keyboard shortcut hint (e.g., "Alt+1") */
44
+ shortcut?: string;
45
+ /** Command execution function */
46
+ execute: (context: CommandContext) => void | Promise<void>;
47
+ /** Optional function to determine if command is available */
48
+ isAvailable?: (context: CommandContext) => boolean;
49
+ /** Priority for ordering (higher = appears first) */
50
+ priority?: number;
51
+ }
52
+
53
+ /**
54
+ * Command category definition
55
+ */
56
+ export declare interface CommandCategory {
57
+ /** Category identifier */
58
+ id: string;
59
+ /** Display label */
60
+ label: string;
61
+ /** Display priority (higher = shown first) */
62
+ priority?: number;
63
+ /** Optional icon */
64
+ icon?: string | React.ReactNode;
65
+ }
66
+
67
+ /**
68
+ * Context provided to command execution functions
69
+ */
70
+ export declare interface CommandContext {
71
+ /** Panel framework context */
72
+ panelContext: PanelContextValue;
73
+ /** Panel actions for navigation, file operations, etc. */
74
+ actions: PanelActions;
75
+ /** Event bus for inter-panel communication */
76
+ events: PanelEventEmitter;
77
+ /** Currently focused panel */
78
+ focusedPanel: PanelSlotId | null;
79
+ /** Function to set panel focus */
80
+ setFocus: (panel: PanelSlotId) => void;
81
+ /** Workspace management service */
82
+ workspaceService?: WorkspaceLayoutService;
83
+ /** Close the command palette */
84
+ closeCommandPalette: () => void;
85
+ }
86
+
87
+ /**
88
+ * CommandInput - Input field for the command palette
89
+ * Auto-focuses on mount and handles input changes
90
+ */
91
+ export declare const CommandInput: default_2.FC<CommandInputProps>;
92
+
93
+ declare interface CommandInputProps {
94
+ value: string;
95
+ onChange: (value: string) => void;
96
+ placeholder?: string;
97
+ onClose: () => void;
98
+ onEnter?: () => void;
99
+ }
100
+
101
+ /**
102
+ * CommandItem - Individual command item in the list
103
+ * Displays command label, description, icon, and keyboard shortcut
104
+ */
105
+ export declare const CommandItem: default_2.ForwardRefExoticComponent<CommandItemProps & default_2.RefAttributes<HTMLDivElement>>;
106
+
107
+ declare interface CommandItemProps {
108
+ command: Command;
109
+ isSelected: boolean;
110
+ onClick: () => void;
111
+ onMouseEnter: () => void;
112
+ }
113
+
114
+ /**
115
+ * CommandList - List of filtered commands
116
+ * Displays commands grouped by category with keyboard navigation support
117
+ */
118
+ export declare const CommandList: default_2.FC<CommandListProps>;
119
+
120
+ declare interface CommandListProps {
121
+ commands: Command[];
122
+ selectedIndex: number;
123
+ onSelect: (command: Command) => void;
124
+ onHover: (index: number) => void;
125
+ maxResults?: number;
126
+ }
127
+
128
+ /**
129
+ * CommandPalette - Vim-style command palette component
130
+ * Displays at the bottom of the screen with an input field and command list
131
+ */
132
+ export declare const CommandPalette: default_2.FC<CommandPaletteProps>;
133
+
134
+ /**
135
+ * Configuration options for the command palette
136
+ */
137
+ export declare interface CommandPaletteConfig {
138
+ /** Custom keyboard shortcut configuration */
139
+ keyboard?: CommandPaletteKeyboardConfig;
140
+ /** Maximum number of results to show */
141
+ maxResults?: number;
142
+ /** Placeholder text for the input field */
143
+ placeholder?: string;
144
+ /** Custom CSS class for the container */
145
+ className?: string;
146
+ /** Custom styles for the container */
147
+ style?: React.CSSProperties;
148
+ /** Maximum height of the results list */
149
+ maxHeight?: string;
150
+ /** Enable fuzzy search (default: true) */
151
+ fuzzySearch?: boolean;
152
+ /** Threshold for fuzzy search matching (0-1, default: 0.3) */
153
+ fuzzyThreshold?: number;
154
+ }
155
+
156
+ /**
157
+ * Keyboard shortcut configuration for triggering the command palette
158
+ */
159
+ export declare interface CommandPaletteKeyboardConfig {
160
+ /** Key to trigger the command palette (default: ' ' for Space) */
161
+ key?: string;
162
+ /** Require Alt key (default: true) */
163
+ altKey?: boolean;
164
+ /** Require Ctrl key (default: false) */
165
+ ctrlKey?: boolean;
166
+ /** Require Meta/Cmd key (default: false) */
167
+ metaKey?: boolean;
168
+ /** Require Shift key (default: false) */
169
+ shiftKey?: boolean;
170
+ }
171
+
172
+ /**
173
+ * Props for the CommandPalette component
174
+ */
175
+ export declare interface CommandPaletteProps {
176
+ /** Command palette hook return value */
177
+ commandPalette: UseCommandPaletteReturn;
178
+ /** Configuration options */
179
+ config?: CommandPaletteConfig;
180
+ /** Panel context for command execution */
181
+ context: CommandContext;
182
+ }
183
+
184
+ /**
185
+ * Service for managing command registration and execution
186
+ * Provides a centralized registry for commands that can be accessed via the command palette
187
+ */
188
+ export declare class CommandRegistryService {
189
+ private commands;
190
+ private listeners;
191
+ /**
192
+ * Register one or more commands
193
+ * @param commands - Array of commands to register
194
+ */
195
+ registerCommands(commands: Command[]): void;
196
+ /**
197
+ * Register a single command
198
+ * @param command - Command to register
199
+ */
200
+ registerCommand(command: Command): void;
201
+ /**
202
+ * Unregister commands by ID
203
+ * @param commandIds - Array of command IDs to unregister
204
+ */
205
+ unregisterCommands(commandIds: string[]): void;
206
+ /**
207
+ * Unregister a single command
208
+ * @param commandId - Command ID to unregister
209
+ */
210
+ unregisterCommand(commandId: string): void;
211
+ /**
212
+ * Get all registered commands
213
+ * @param context - Command context for availability checks
214
+ * @returns Array of available commands
215
+ */
216
+ getCommands(context?: CommandContext): Command[];
217
+ /**
218
+ * Get a command by ID
219
+ * @param commandId - Command ID
220
+ * @returns Command if found, undefined otherwise
221
+ */
222
+ getCommand(commandId: string): Command | undefined;
223
+ /**
224
+ * Execute a command by ID
225
+ * @param commandId - Command ID to execute
226
+ * @param context - Command context
227
+ */
228
+ executeCommand(commandId: string, context: CommandContext): Promise<void>;
229
+ /**
230
+ * Search commands by query
231
+ * @param query - Search query
232
+ * @param context - Command context for availability checks
233
+ * @returns Filtered and sorted commands
234
+ */
235
+ searchCommands(query: string, context?: CommandContext): Command[];
236
+ /**
237
+ * Sort commands by priority and label
238
+ * @param commands - Commands to sort
239
+ * @returns Sorted commands
240
+ */
241
+ private sortCommands;
242
+ /**
243
+ * Subscribe to registry changes
244
+ * @param listener - Callback function called when registry changes
245
+ * @returns Unsubscribe function
246
+ */
247
+ subscribe(listener: () => void): () => void;
248
+ /**
249
+ * Clear all commands
250
+ */
251
+ clear(): void;
252
+ /**
253
+ * Get count of registered commands
254
+ */
255
+ get size(): number;
256
+ /**
257
+ * Notify all listeners of registry changes
258
+ */
259
+ private notifyListeners;
260
+ }
261
+
25
262
  /**
26
263
  * Options for creating a new workspace
27
264
  */
@@ -60,6 +297,18 @@ export declare interface FocusIndicatorProps {
60
297
  style?: default_2.CSSProperties;
61
298
  }
62
299
 
300
+ /**
301
+ * Get the global command registry instance
302
+ * @returns Global CommandRegistryService instance
303
+ */
304
+ export declare function getGlobalCommandRegistry(): CommandRegistryService;
305
+
306
+ /**
307
+ * Get panel commands
308
+ * @returns Array of panel-related commands
309
+ */
310
+ export declare function getPanelCommands(): Command[];
311
+
63
312
  /**
64
313
  * Default localStorage-based persistence adapter for web applications
65
314
  */
@@ -110,6 +359,11 @@ export declare interface PanelCollapsed {
110
359
  right?: boolean;
111
360
  }
112
361
 
362
+ /**
363
+ * Built-in commands for panel navigation and control
364
+ */
365
+ export declare const panelCommands: Command[];
366
+
113
367
  export { PanelDefinition }
114
368
 
115
369
  export { PanelDefinitionWithContent }
@@ -219,6 +473,11 @@ export declare interface RepositoryWorkspaceState {
219
473
  };
220
474
  }
221
475
 
476
+ /**
477
+ * Reset the global command registry (useful for testing)
478
+ */
479
+ export declare function resetGlobalCommandRegistry(): void;
480
+
222
481
  export { ResponsiveConfigurablePanelLayout }
223
482
 
224
483
  export { ResponsiveConfigurablePanelLayoutProps }
@@ -283,6 +542,63 @@ export declare interface UpdateWorkspaceOptions {
283
542
  };
284
543
  }
285
544
 
545
+ /**
546
+ * Hook for managing command palette state and behavior
547
+ * Handles command registration, filtering, keyboard navigation, and execution
548
+ */
549
+ export declare function useCommandPalette({ context, commands: initialCommands, keyboard, config, registry: providedRegistry, }: UseCommandPaletteProps): UseCommandPaletteReturn;
550
+
551
+ declare interface UseCommandPaletteProps {
552
+ /** Command context */
553
+ context: CommandContext;
554
+ /** Initial commands to register */
555
+ commands?: Command[];
556
+ /** Keyboard configuration */
557
+ keyboard?: CommandPaletteKeyboardConfig;
558
+ /** Command palette configuration */
559
+ config?: CommandPaletteConfig;
560
+ /** Command registry service (optional, uses global if not provided) */
561
+ registry?: CommandRegistryService;
562
+ }
563
+
564
+ /**
565
+ * Command palette state and actions hook return type
566
+ */
567
+ export declare interface UseCommandPaletteReturn {
568
+ /** Whether the command palette is open */
569
+ isOpen: boolean;
570
+ /** Open the command palette */
571
+ open: () => void;
572
+ /** Close the command palette */
573
+ close: () => void;
574
+ /** Toggle the command palette */
575
+ toggle: () => void;
576
+ /** Search query */
577
+ query: string;
578
+ /** Set search query */
579
+ setQuery: (query: string) => void;
580
+ /** Filtered and sorted commands */
581
+ filteredCommands: Command[];
582
+ /** Execute a command by ID */
583
+ executeCommand: (commandId: string) => Promise<void>;
584
+ /** Selected command index (for keyboard navigation) */
585
+ selectedIndex: number;
586
+ /** Set selected index */
587
+ setSelectedIndex: (index: number) => void;
588
+ /** Navigate to next command */
589
+ selectNext: () => void;
590
+ /** Navigate to previous command */
591
+ selectPrevious: () => void;
592
+ /** Execute the currently selected command */
593
+ executeSelected: () => Promise<void>;
594
+ /** All registered commands */
595
+ commands: Command[];
596
+ /** Register new commands */
597
+ registerCommands: (commands: Command[]) => void;
598
+ /** Unregister commands by ID */
599
+ unregisterCommands: (commandIds: string[]) => void;
600
+ }
601
+
286
602
  /**
287
603
  * Hook for managing panel focus state with keyboard shortcuts
288
604
  */