| 20 | templateUrl: './app.component.html', |
| 21 | }) |
| 22 | export class AppComponent { |
| 23 | fd = (h: string) => formatForDisplay(h as Hotkey) |
| 24 | |
| 25 | // Basic demo |
| 26 | log = signal<string[]>([]) |
| 27 | saveCount = signal(0) |
| 28 | undoCount = signal(0) |
| 29 | redoCount = signal(0) |
| 30 | |
| 31 | // Common options demo |
| 32 | commonEnabled = signal(true) |
| 33 | counts = signal({ a: 0, b: 0, c: 0 }) |
| 34 | |
| 35 | // Dynamic demo |
| 36 | nextId = 0 |
| 37 | shortcuts = signal<DynamicShortcut[]>([ |
| 38 | { |
| 39 | id: this.nextId++, |
| 40 | hotkey: 'Shift+A', |
| 41 | label: 'Action A', |
| 42 | description: 'First dynamic action', |
| 43 | count: 0, |
| 44 | }, |
| 45 | { |
| 46 | id: this.nextId++, |
| 47 | hotkey: 'Shift+B', |
| 48 | label: 'Action B', |
| 49 | description: 'Second dynamic action', |
| 50 | count: 0, |
| 51 | }, |
| 52 | { |
| 53 | id: this.nextId++, |
| 54 | hotkey: 'Shift+C', |
| 55 | label: 'Action C', |
| 56 | description: 'Third dynamic action', |
| 57 | count: 0, |
| 58 | }, |
| 59 | ]) |
| 60 | newHotkey = signal('') |
| 61 | newLabel = signal('') |
| 62 | newDescription = signal('') |
| 63 | |
| 64 | // Registrations viewer |
| 65 | readonly registrations = injectHotkeyRegistrations() |
| 66 | |
| 67 | constructor() { |
| 68 | // Basic multi-hotkey with meta |
| 69 | injectHotkeys([ |
| 70 | { |
| 71 | hotkey: 'Shift+S', |
| 72 | callback: (_e, { hotkey }) => { |
| 73 | this.saveCount.update((c) => c + 1) |
| 74 | this.log.update((l) => [`${hotkey} pressed`, ...l].slice(0, 20)) |
| 75 | }, |
| 76 | options: { |
| 77 | meta: { name: 'Save', description: 'Save the current document' }, |
| 78 | }, |
| 79 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…