@cngx/ui 0.1.0-rc.6 → 0.1.0-rc.7

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.
Files changed (79) hide show
  1. package/README.md +112 -0
  2. package/a11y/README.md +81 -0
  3. package/context-menu/README.md +98 -0
  4. package/data-grid-accordion/README.md +27 -0
  5. package/feedback/README.md +2 -0
  6. package/fesm2022/cngx-ui-a11y.mjs +320 -0
  7. package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
  8. package/fesm2022/cngx-ui-accordion.mjs +17 -6
  9. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  10. package/fesm2022/cngx-ui-action-button.mjs +5 -2
  11. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  12. package/fesm2022/cngx-ui-breadcrumb.mjs +11 -6
  13. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  14. package/fesm2022/cngx-ui-chart-panel.mjs +429 -0
  15. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
  16. package/fesm2022/cngx-ui-collection.mjs +15 -6
  17. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  18. package/fesm2022/cngx-ui-command-palette.mjs +1005 -0
  19. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
  20. package/fesm2022/cngx-ui-context-menu.mjs +742 -0
  21. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
  22. package/fesm2022/cngx-ui-data-grid-accordion.mjs +88 -18
  23. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  24. package/fesm2022/cngx-ui-feedback.mjs +97 -106
  25. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  26. package/fesm2022/cngx-ui-layout.mjs +18 -9
  27. package/fesm2022/cngx-ui-layout.mjs.map +1 -1
  28. package/fesm2022/cngx-ui-mat-accordion.mjs +9 -9
  29. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  30. package/fesm2022/cngx-ui-mat-tabs.mjs +64 -70
  31. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  32. package/fesm2022/cngx-ui-paginator.mjs +18 -8
  33. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  34. package/fesm2022/cngx-ui-sidenav.mjs +2 -2
  35. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  36. package/fesm2022/cngx-ui-skeleton.mjs +20 -7
  37. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  38. package/fesm2022/cngx-ui-speak.mjs +2 -2
  39. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  40. package/fesm2022/cngx-ui-stat-card.mjs +618 -0
  41. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
  42. package/fesm2022/cngx-ui-stepper.mjs +30 -12
  43. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  44. package/fesm2022/cngx-ui-tabs.mjs +36 -19
  45. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  46. package/fesm2022/cngx-ui-timeline.mjs +495 -0
  47. package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
  48. package/fesm2022/cngx-ui-toc.mjs +704 -0
  49. package/fesm2022/cngx-ui-toc.mjs.map +1 -0
  50. package/fesm2022/cngx-ui.mjs +2 -2
  51. package/fesm2022/cngx-ui.mjs.map +1 -1
  52. package/mat-accordion/README.md +1 -1
  53. package/mat-tabs/styles/mat-tabs.css +20 -17
  54. package/package.json +32 -1
  55. package/skeleton/README.md +2 -0
  56. package/stepper/README.md +2 -2
  57. package/timeline/README.md +350 -0
  58. package/toc/README.md +183 -0
  59. package/types/cngx-ui-a11y.d.ts +303 -0
  60. package/types/cngx-ui-accordion.d.ts +9 -4
  61. package/types/cngx-ui-action-button.d.ts +3 -0
  62. package/types/cngx-ui-breadcrumb.d.ts +5 -0
  63. package/types/cngx-ui-chart-panel.d.ts +278 -0
  64. package/types/cngx-ui-collection.d.ts +12 -3
  65. package/types/cngx-ui-command-palette.d.ts +451 -0
  66. package/types/cngx-ui-context-menu.d.ts +467 -0
  67. package/types/cngx-ui-data-grid-accordion.d.ts +72 -15
  68. package/types/cngx-ui-feedback.d.ts +71 -18
  69. package/types/cngx-ui-layout.d.ts +8 -3
  70. package/types/cngx-ui-mat-accordion.d.ts +3 -3
  71. package/types/cngx-ui-mat-tabs.d.ts +11 -9
  72. package/types/cngx-ui-paginator.d.ts +13 -3
  73. package/types/cngx-ui-skeleton.d.ts +13 -1
  74. package/types/cngx-ui-stat-card.d.ts +327 -0
  75. package/types/cngx-ui-stepper.d.ts +15 -2
  76. package/types/cngx-ui-tabs.d.ts +20 -4
  77. package/types/cngx-ui-timeline.d.ts +479 -0
  78. package/types/cngx-ui-toc.d.ts +514 -0
  79. package/types/cngx-ui.d.ts +1 -1
@@ -0,0 +1,1005 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, makeEnvironmentProviders, SkipSelf, Optional, inject, input, model, output, DestroyRef, viewChild, signal, computed, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, contentChild, effect } from '@angular/core';
4
+ import { CngxDialog } from '@cngx/common/dialog';
5
+ import { nextUid, matchesKeyCombo, parseKeyCombo } from '@cngx/core/utils';
6
+ import { injectCommands, CNGX_COMMAND_MATCH_FACTORY } from '@cngx/common/command';
7
+ import { CngxListbox, CngxSearch, CngxOption } from '@cngx/common/interactive';
8
+ import { CngxHighlight } from '@cngx/common/layout';
9
+ import { resolveAsyncView } from '@cngx/common/data';
10
+
11
+ /** @internal */
12
+ const CNGX_COMMAND_PALETTE_DEFAULTS = {
13
+ openShortcut: 'mod+k',
14
+ searchPlaceholder: 'Type a command or search...',
15
+ listboxLabel: 'Commands',
16
+ emptyLabel: 'No matching commands.',
17
+ loadingLabel: 'Loading commands...',
18
+ errorLabel: 'Could not load commands.',
19
+ retryLabel: 'Retry',
20
+ resultCount: (count) => (count === 1 ? '1 result' : `${count} results`),
21
+ footerLegend: [
22
+ { keys: 'up down', label: 'Navigate' },
23
+ { keys: 'enter', label: 'Run' },
24
+ { keys: 'esc', label: 'Close' },
25
+ ],
26
+ };
27
+
28
+ /**
29
+ * Library-default palette configuration, built from the internal defaults
30
+ * const. English-only.
31
+ *
32
+ * @category ui/command-palette
33
+ * @since 0.1.0
34
+ */
35
+ const DEFAULT_COMMAND_PALETTE_CONFIG = {
36
+ openShortcut: CNGX_COMMAND_PALETTE_DEFAULTS.openShortcut,
37
+ searchPlaceholder: CNGX_COMMAND_PALETTE_DEFAULTS.searchPlaceholder,
38
+ listboxLabel: CNGX_COMMAND_PALETTE_DEFAULTS.listboxLabel,
39
+ emptyLabel: CNGX_COMMAND_PALETTE_DEFAULTS.emptyLabel,
40
+ loadingLabel: CNGX_COMMAND_PALETTE_DEFAULTS.loadingLabel,
41
+ errorLabel: CNGX_COMMAND_PALETTE_DEFAULTS.errorLabel,
42
+ retryLabel: CNGX_COMMAND_PALETTE_DEFAULTS.retryLabel,
43
+ resultCount: CNGX_COMMAND_PALETTE_DEFAULTS.resultCount,
44
+ footerLegend: CNGX_COMMAND_PALETTE_DEFAULTS.footerLegend,
45
+ };
46
+ /**
47
+ * DI token carrying the resolved {@link CngxCommandPaletteConfig}. Defaults to
48
+ * {@link DEFAULT_COMMAND_PALETTE_CONFIG} at root; override app-wide via
49
+ * {@link provideCommandPaletteConfig} or per-scope via
50
+ * {@link provideCommandPaletteConfigAt}.
51
+ *
52
+ * @category ui/command-palette
53
+ * @since 0.1.0
54
+ */
55
+ const CNGX_COMMAND_PALETTE_CONFIG = new InjectionToken('CngxCommandPaletteConfig', { providedIn: 'root', factory: () => DEFAULT_COMMAND_PALETTE_CONFIG });
56
+ /** @internal */
57
+ function applyFeatures(base, features) {
58
+ return features.reduce((config, feature) => feature(config), base);
59
+ }
60
+ /**
61
+ * Provide a palette configuration at app root.
62
+ *
63
+ * ```ts
64
+ * provideCommandPaletteConfig(
65
+ * withCommandPaletteLabels({ emptyLabel: 'Keine Treffer.' }),
66
+ * withKeyboardLegend([{ keys: 'enter', label: 'Ausführen' }]),
67
+ * )
68
+ * ```
69
+ *
70
+ * @category ui/command-palette
71
+ * @since 0.1.0
72
+ */
73
+ function provideCommandPaletteConfig(...features) {
74
+ return makeEnvironmentProviders([
75
+ {
76
+ provide: CNGX_COMMAND_PALETTE_CONFIG,
77
+ useFactory: () => applyFeatures(DEFAULT_COMMAND_PALETTE_CONFIG, features),
78
+ },
79
+ ]);
80
+ }
81
+ /**
82
+ * Component-scoped palette configuration override. Features merge on top of the
83
+ * enclosing scope (root or a parent `viewProviders`).
84
+ *
85
+ * @category ui/command-palette
86
+ * @since 0.1.0
87
+ */
88
+ function provideCommandPaletteConfigAt(...features) {
89
+ return [
90
+ {
91
+ provide: CNGX_COMMAND_PALETTE_CONFIG,
92
+ useFactory: (parent) => applyFeatures(parent ?? DEFAULT_COMMAND_PALETTE_CONFIG, features),
93
+ deps: [[new SkipSelf(), new Optional(), CNGX_COMMAND_PALETTE_CONFIG]],
94
+ },
95
+ ];
96
+ }
97
+ /**
98
+ * Resolves the {@link CngxCommandPaletteConfig} from the current injection
99
+ * scope. Must run in an injection context.
100
+ *
101
+ * @category ui/command-palette
102
+ * @since 0.1.0
103
+ */
104
+ function injectCommandPaletteConfig() {
105
+ return inject(CNGX_COMMAND_PALETTE_CONFIG);
106
+ }
107
+ /**
108
+ * Override any subset of the palette's text labels. Unset labels keep the
109
+ * English defaults.
110
+ *
111
+ * @category ui/command-palette
112
+ * @since 0.1.0
113
+ */
114
+ function withCommandPaletteLabels(labels) {
115
+ return (config) => ({ ...config, ...labels });
116
+ }
117
+ /**
118
+ * Set the combo that opens the palette (parsed via `parseKeyCombo`, e.g.
119
+ * `'mod+k'`, `'mod+shift+p'`). Applies app-wide via `provideCommandPaletteConfig`
120
+ * or per-scope via `provideCommandPaletteConfigAt`. A per-instance
121
+ * `[openShortcut]` input still wins over this.
122
+ *
123
+ * @category ui/command-palette
124
+ * @since 0.1.0
125
+ */
126
+ function withPaletteShortcut(combo) {
127
+ return (config) => ({ ...config, openShortcut: combo });
128
+ }
129
+ /**
130
+ * Replace the footer keyboard legend.
131
+ *
132
+ * @category ui/command-palette
133
+ * @since 0.1.0
134
+ */
135
+ function withKeyboardLegend(entries) {
136
+ return (config) => ({ ...config, footerLegend: entries });
137
+ }
138
+ /**
139
+ * Replace the `aria-live` result-count formatter (e.g. for pluralisation in
140
+ * another locale).
141
+ *
142
+ * @category ui/command-palette
143
+ * @since 0.1.0
144
+ */
145
+ function withResultCountFormatter(formatter) {
146
+ return (config) => ({ ...config, resultCount: formatter });
147
+ }
148
+ /**
149
+ * Register global default slot templates. Merged over any already set; a
150
+ * per-instance `*cngxCommand*` slot still wins over these.
151
+ *
152
+ * @category ui/command-palette
153
+ * @since 0.1.0
154
+ */
155
+ function withCommandPaletteTemplates(templates) {
156
+ return (config) => ({
157
+ ...config,
158
+ templates: { ...config.templates, ...templates },
159
+ });
160
+ }
161
+
162
+ /**
163
+ * DI token the panel injects (optional) to reach its hosting palette surface.
164
+ *
165
+ * @category ui/command-palette
166
+ * @since 0.1.0
167
+ */
168
+ const CNGX_COMMAND_PALETTE_HOST = new InjectionToken('CNGX_COMMAND_PALETTE_HOST');
169
+
170
+ /**
171
+ * @internal
172
+ * The command-palette result body: a `role=combobox` search input driving a
173
+ * `role=listbox` of ranked commands with `aria-activedescendant`, grouped
174
+ * results, match highlighting, a bound scope chip, and a polite result-count
175
+ * live region. Composes existing atoms - `CngxSearch` (debounced term),
176
+ * `CngxListbox` + `CngxOption` (navigation over the ranked list in final DOM
177
+ * order via the listbox's own `CngxActiveDescendant`), `CngxHighlight` (match
178
+ * marking) - with no reinvented debounce, navigation, or ranking engine.
179
+ *
180
+ * The ranked list is a `computed()` over the `equal`-guarded registry, the
181
+ * swappable matcher, `term`, `scope`, and the consumer's async result source;
182
+ * the per-option `matchFn` never runs, so there is no double-filter.
183
+ */
184
+ class CngxCommandPanel {
185
+ /** Consumer-derived async result source, merged in with the static registry. */
186
+ results = input(undefined, ...(ngDevMode ? [{ debugName: "results" }] : /* istanbul ignore next */ []));
187
+ /** Persistent scope; feeds the matcher's scope filter and renders as a chip. */
188
+ scope = model(undefined, ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
189
+ /** Debounce for the search input (proxied to `CngxSearch`). */
190
+ debounceMs = input(150, ...(ngDevMode ? [{ debugName: "debounceMs" }] : /* istanbul ignore next */ []));
191
+ /** Resolved row slot template (instance > config > null). Built-in default when null. */
192
+ rowTpl = input(null, ...(ngDevMode ? [{ debugName: "rowTpl" }] : /* istanbul ignore next */ []));
193
+ /** Resolved group-header slot template. Built-in default when null. */
194
+ groupHeaderTpl = input(null, ...(ngDevMode ? [{ debugName: "groupHeaderTpl" }] : /* istanbul ignore next */ []));
195
+ /** Emits the debounced term so the surface can mirror it (e.g. for the empty slot). */
196
+ termChange = output();
197
+ config = injectCommandPaletteConfig();
198
+ listboxId = nextUid('cngx-command-listbox');
199
+ commands = injectCommands();
200
+ matcher = inject(CNGX_COMMAND_MATCH_FACTORY)();
201
+ host = inject(CNGX_COMMAND_PALETTE_HOST, { optional: true });
202
+ destroyRef = inject(DestroyRef);
203
+ listbox = viewChild.required(CngxListbox);
204
+ termState = signal('', ...(ngDevMode ? [{ debugName: "termState" }] : /* istanbul ignore next */ []));
205
+ /** Current debounced search term. Exposed for the consumer's result derivation. */
206
+ term = this.termState.asReadonly();
207
+ /** Grouped, ranked results: consumer async groups first, then the ranked registry. */
208
+ groups = computed(() => {
209
+ const ranked = this.matcher(this.commands(), this.term(), this.scope());
210
+ const asyncState = this.results();
211
+ const asyncGroups = asyncState ? toRenderGroups(asyncState.data() ?? []) : [];
212
+ return [...asyncGroups, ...groupRanked(ranked)];
213
+ }, { ...(ngDevMode ? { debugName: "groups" } : /* istanbul ignore next */ {}), equal: renderGroupsEqual });
214
+ /** Flat ranked list in render order, for count + command lookup. */
215
+ flatItems = computed(() => this.groups().flatMap((group) => group.items), { ...(ngDevMode ? { debugName: "flatItems" } : /* istanbul ignore next */ {}), equal: rankedListEqual });
216
+ /** Number of results across every group. Exposed for the consumer. */
217
+ resultCount = computed(() => this.flatItems().length, ...(ngDevMode ? [{ debugName: "resultCount" }] : /* istanbul ignore next */ []));
218
+ countMessage = computed(() => this.config.resultCount(this.resultCount()), ...(ngDevMode ? [{ debugName: "countMessage" }] : /* istanbul ignore next */ []));
219
+ constructor() {
220
+ // Click on an option routes through the listbox's active-descendant, which
221
+ // emits `activated`; Enter forwards through the same `activateCurrent` path.
222
+ // One subscription runs the matching command for both. externalActivation
223
+ // stops the listbox writing its own value on activation.
224
+ afterNextRender(() => {
225
+ const subscription = this.listbox().ad.activated.subscribe((value) => this.runById(value));
226
+ this.destroyRef.onDestroy(() => subscription.unsubscribe());
227
+ });
228
+ }
229
+ onTerm(term, lb) {
230
+ this.termState.set(term);
231
+ this.termChange.emit(term);
232
+ // Reset the highlight so autoHighlightFirst re-fires the top result after a
233
+ // re-rank shrinks the list below the previously active index.
234
+ lb.ad.resetHighlight();
235
+ }
236
+ /** Maps an internal render group to the public `CommandGroup` slot context. */
237
+ toCommandGroup(group) {
238
+ return {
239
+ id: group.id,
240
+ label: group.label ?? '',
241
+ commands: group.items.map((entry) => entry.command),
242
+ };
243
+ }
244
+ onKeydown(event, lb) {
245
+ const ad = lb.ad;
246
+ switch (event.key) {
247
+ case 'ArrowDown':
248
+ event.preventDefault();
249
+ ad.highlightNext();
250
+ return;
251
+ case 'ArrowUp':
252
+ event.preventDefault();
253
+ ad.highlightPrev();
254
+ return;
255
+ case 'Home':
256
+ event.preventDefault();
257
+ ad.highlightFirst();
258
+ return;
259
+ case 'End':
260
+ event.preventDefault();
261
+ ad.highlightLast();
262
+ return;
263
+ case 'Enter':
264
+ if (ad.activeItem()) {
265
+ event.preventDefault();
266
+ ad.activateCurrent();
267
+ }
268
+ return;
269
+ }
270
+ // Space, printable characters, and Backspace fall through to the input so
271
+ // the search term picks them up.
272
+ }
273
+ isDisabled(command) {
274
+ return command.disabled?.() ?? false;
275
+ }
276
+ reasonId(command) {
277
+ return `${this.listboxId}-reason-${command.id}`;
278
+ }
279
+ describedBy(command) {
280
+ return this.isDisabled(command) && command.disabledReason ? this.reasonId(command) : null;
281
+ }
282
+ runById(value) {
283
+ const command = this.flatItems().find((entry) => entry.command.id === value)?.command;
284
+ if (!command || this.isDisabled(command)) {
285
+ return;
286
+ }
287
+ void command.run();
288
+ this.host?.dismiss();
289
+ }
290
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPanel, deps: [], target: i0.ɵɵFactoryTarget.Component });
291
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxCommandPanel, isStandalone: true, selector: "cngx-command-panel", inputs: { results: { classPropertyName: "results", publicName: "results", isSignal: true, isRequired: false, transformFunction: null }, scope: { classPropertyName: "scope", publicName: "scope", isSignal: true, isRequired: false, transformFunction: null }, debounceMs: { classPropertyName: "debounceMs", publicName: "debounceMs", isSignal: true, isRequired: false, transformFunction: null }, rowTpl: { classPropertyName: "rowTpl", publicName: "rowTpl", isSignal: true, isRequired: false, transformFunction: null }, groupHeaderTpl: { classPropertyName: "groupHeaderTpl", publicName: "groupHeaderTpl", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { scope: "scopeChange", termChange: "termChange" }, host: { classAttribute: "cngx-command-panel" }, viewQueries: [{ propertyName: "listbox", first: true, predicate: CngxListbox, descendants: true, isSignal: true }], ngImport: i0, template: `
292
+ <div class="cngx-command-panel-input-row">
293
+ @if (scope(); as activeScope) {
294
+ <span class="cngx-command-scope-chip">{{ activeScope }}</span>
295
+ }
296
+ <input
297
+ cngxSearch
298
+ class="cngx-command-panel-input"
299
+ type="text"
300
+ role="combobox"
301
+ autocomplete="off"
302
+ aria-autocomplete="list"
303
+ [attr.aria-expanded]="true"
304
+ [attr.aria-controls]="listboxId"
305
+ [attr.aria-activedescendant]="lb.ad.activeId()"
306
+ [attr.aria-label]="config.searchPlaceholder"
307
+ [placeholder]="config.searchPlaceholder"
308
+ [debounceMs]="debounceMs()"
309
+ (searchChange)="onTerm($event, lb)"
310
+ (keydown)="onKeydown($event, lb)"
311
+ />
312
+ </div>
313
+
314
+ <div
315
+ cngxListbox
316
+ #lb="cngxListbox"
317
+ [id]="listboxId"
318
+ class="cngx-command-panel-listbox"
319
+ [label]="config.listboxLabel"
320
+ [autoHighlightFirst]="true"
321
+ [externalActivation]="true"
322
+ >
323
+ @for (group of groups(); track group.id) {
324
+ <div role="group" [attr.aria-labelledby]="group.label ? group.id + '-h' : null">
325
+ @if (group.label; as header) {
326
+ <div class="cngx-command-group-header" [id]="group.id + '-h'">
327
+ @if (groupHeaderTpl(); as tpl) {
328
+ <ng-container
329
+ [ngTemplateOutlet]="tpl"
330
+ [ngTemplateOutletContext]="{ $implicit: toCommandGroup(group) }"
331
+ />
332
+ } @else {
333
+ {{ header }}
334
+ }
335
+ </div>
336
+ }
337
+ @for (entry of group.items; track entry.command.id) {
338
+ <div
339
+ cngxOption
340
+ class="cngx-command-row"
341
+ [value]="entry.command.id"
342
+ [label]="entry.command.label"
343
+ [disabled]="isDisabled(entry.command)"
344
+ [attr.aria-describedby]="describedBy(entry.command)"
345
+ >
346
+ @if (rowTpl(); as tpl) {
347
+ <ng-container
348
+ [ngTemplateOutlet]="tpl"
349
+ [ngTemplateOutletContext]="{
350
+ $implicit: entry,
351
+ term: term(),
352
+ data: entry.command.data,
353
+ active: lb.ad.activeValue() === entry.command.id,
354
+ }"
355
+ />
356
+ } @else {
357
+ <span class="cngx-command-row-label" [cngxHighlight]="term()">{{
358
+ entry.command.label
359
+ }}</span>
360
+ }
361
+ @if (entry.command.disabledReason; as reason) {
362
+ <!-- Target stays in the DOM whenever a reason exists; only the
363
+ aria-describedby reference (describedBy) is gated on disabled
364
+ state, so no referenced node ever appears/disappears mid-interaction. -->
365
+ <span class="cngx-sr-only" [id]="reasonId(entry.command)">{{ reason }}</span>
366
+ }
367
+ </div>
368
+ }
369
+ </div>
370
+ }
371
+ </div>
372
+
373
+ <span class="cngx-sr-only" aria-live="polite">{{ countMessage() }}</span>
374
+ `, isInline: true, styles: [".cngx-command-panel{display:block;--cngx-command-input-gap: var(--cngx-space-sm, .5rem);--cngx-command-input-pad: var(--cngx-space-md, 1rem);--cngx-command-row-gap: var(--cngx-space-sm, .5rem);--cngx-command-row-pad: var(--cngx-space-sm, .5rem);--cngx-command-listbox-pad: var(--cngx-space-xs, .25rem);--cngx-command-chip-pad: var(--cngx-space-sm, .5rem)}.cngx-command-panel-input-row{display:flex;align-items:center;gap:var(--cngx-command-input-gap, var(--cngx-space-sm, .5rem));padding:var(--cngx-command-input-pad, var(--cngx-space-md, 1rem));border-block-end:var(--cngx-command-border-width, 1px) solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb))}.cngx-command-panel-input{flex:1 1 auto;min-inline-size:0;font:inherit;color:var(--cngx-command-input-color, inherit);background:transparent;border:0;outline:none}.cngx-command-panel-input::placeholder{color:var(--cngx-command-placeholder-color, var(--cngx-color-muted-foreground, #9ca3af))}.cngx-command-scope-chip{display:inline-flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-inline:var(--cngx-command-chip-pad, var(--cngx-space-sm, .5rem));border-radius:var(--cngx-command-chip-radius, var(--cngx-radius-sm, .25rem));background:var(--cngx-command-chip-bg, var(--cngx-color-muted, #f3f4f6));color:var(--cngx-command-chip-color, inherit);font-size:var(--cngx-command-chip-size, .8125rem)}.cngx-command-panel-listbox{display:block;max-block-size:var(--cngx-command-listbox-max-h, 22rem);overflow-y:auto;padding:var(--cngx-command-listbox-pad, var(--cngx-space-xs, .25rem))}.cngx-command-group-header{padding-block:var(--cngx-command-header-pad-y, var(--cngx-space-xs, .25rem));padding-inline:var(--cngx-command-header-pad-x, var(--cngx-space-sm, .5rem));font-size:var(--cngx-command-header-size, .75rem);font-weight:var(--cngx-command-header-weight, 600);color:var(--cngx-command-header-color, var(--cngx-color-muted-foreground, #6b7280));text-transform:uppercase;letter-spacing:.04em}.cngx-command-row{display:flex;align-items:center;gap:var(--cngx-command-row-gap, var(--cngx-space-sm, .5rem));min-block-size:var(--cngx-target-min, 0px);padding:var(--cngx-command-row-pad, var(--cngx-space-sm, .5rem));border-radius:var(--cngx-command-row-radius, var(--cngx-radius-sm, .25rem));cursor:pointer;color:var(--cngx-command-row-color, inherit)}.cngx-command-row.cngx-option--highlighted{background:var(--cngx-command-row-active-bg, var(--cngx-color-accent, #eef2ff));color:var(--cngx-command-row-active-color, inherit)}@media(forced-colors:active){.cngx-command-row.cngx-option--highlighted{background:Highlight;color:HighlightText}}.cngx-command-row.cngx-option--disabled{cursor:not-allowed;opacity:var(--cngx-command-row-disabled-opacity, .5)}.cngx-command-row-label mark{background:var(--cngx-command-mark-bg, var(--cngx-color-highlight, #fde68a));color:inherit}.cngx-command-panel-input:focus-visible,.cngx-command-row:focus-visible{outline:var(--cngx-command-focus-outline, 2px solid var(--cngx-color-focus, #2563eb));outline-offset:var(--cngx-command-focus-offset, 2px)}.cngx-sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n"], dependencies: [{ kind: "directive", type: CngxSearch, selector: "input[cngxSearch]", inputs: ["debounceMs"], outputs: ["searchChange"], exportAs: ["cngxSearch"] }, { kind: "directive", type: CngxListbox, selector: "[cngxListbox]", inputs: ["label", "value", "selectedValues", "multiple", "compareWith", "cngxSearchRef", "externalActivation", "explicitOptions"], outputs: ["valueChange", "selectedValuesChange"], exportAs: ["cngxListbox"] }, { kind: "directive", type: CngxOption, selector: "[cngxOption]", inputs: ["value", "disabled", "label"], exportAs: ["cngxOption"] }, { kind: "directive", type: CngxHighlight, selector: "[cngxHighlight]", inputs: ["cngxHighlight", "highlightCaseSensitive"], exportAs: ["cngxHighlight"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
375
+ }
376
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPanel, decorators: [{
377
+ type: Component,
378
+ args: [{ selector: 'cngx-command-panel', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxSearch, CngxListbox, CngxOption, CngxHighlight, NgTemplateOutlet], host: { class: 'cngx-command-panel' }, template: `
379
+ <div class="cngx-command-panel-input-row">
380
+ @if (scope(); as activeScope) {
381
+ <span class="cngx-command-scope-chip">{{ activeScope }}</span>
382
+ }
383
+ <input
384
+ cngxSearch
385
+ class="cngx-command-panel-input"
386
+ type="text"
387
+ role="combobox"
388
+ autocomplete="off"
389
+ aria-autocomplete="list"
390
+ [attr.aria-expanded]="true"
391
+ [attr.aria-controls]="listboxId"
392
+ [attr.aria-activedescendant]="lb.ad.activeId()"
393
+ [attr.aria-label]="config.searchPlaceholder"
394
+ [placeholder]="config.searchPlaceholder"
395
+ [debounceMs]="debounceMs()"
396
+ (searchChange)="onTerm($event, lb)"
397
+ (keydown)="onKeydown($event, lb)"
398
+ />
399
+ </div>
400
+
401
+ <div
402
+ cngxListbox
403
+ #lb="cngxListbox"
404
+ [id]="listboxId"
405
+ class="cngx-command-panel-listbox"
406
+ [label]="config.listboxLabel"
407
+ [autoHighlightFirst]="true"
408
+ [externalActivation]="true"
409
+ >
410
+ @for (group of groups(); track group.id) {
411
+ <div role="group" [attr.aria-labelledby]="group.label ? group.id + '-h' : null">
412
+ @if (group.label; as header) {
413
+ <div class="cngx-command-group-header" [id]="group.id + '-h'">
414
+ @if (groupHeaderTpl(); as tpl) {
415
+ <ng-container
416
+ [ngTemplateOutlet]="tpl"
417
+ [ngTemplateOutletContext]="{ $implicit: toCommandGroup(group) }"
418
+ />
419
+ } @else {
420
+ {{ header }}
421
+ }
422
+ </div>
423
+ }
424
+ @for (entry of group.items; track entry.command.id) {
425
+ <div
426
+ cngxOption
427
+ class="cngx-command-row"
428
+ [value]="entry.command.id"
429
+ [label]="entry.command.label"
430
+ [disabled]="isDisabled(entry.command)"
431
+ [attr.aria-describedby]="describedBy(entry.command)"
432
+ >
433
+ @if (rowTpl(); as tpl) {
434
+ <ng-container
435
+ [ngTemplateOutlet]="tpl"
436
+ [ngTemplateOutletContext]="{
437
+ $implicit: entry,
438
+ term: term(),
439
+ data: entry.command.data,
440
+ active: lb.ad.activeValue() === entry.command.id,
441
+ }"
442
+ />
443
+ } @else {
444
+ <span class="cngx-command-row-label" [cngxHighlight]="term()">{{
445
+ entry.command.label
446
+ }}</span>
447
+ }
448
+ @if (entry.command.disabledReason; as reason) {
449
+ <!-- Target stays in the DOM whenever a reason exists; only the
450
+ aria-describedby reference (describedBy) is gated on disabled
451
+ state, so no referenced node ever appears/disappears mid-interaction. -->
452
+ <span class="cngx-sr-only" [id]="reasonId(entry.command)">{{ reason }}</span>
453
+ }
454
+ </div>
455
+ }
456
+ </div>
457
+ }
458
+ </div>
459
+
460
+ <span class="cngx-sr-only" aria-live="polite">{{ countMessage() }}</span>
461
+ `, styles: [".cngx-command-panel{display:block;--cngx-command-input-gap: var(--cngx-space-sm, .5rem);--cngx-command-input-pad: var(--cngx-space-md, 1rem);--cngx-command-row-gap: var(--cngx-space-sm, .5rem);--cngx-command-row-pad: var(--cngx-space-sm, .5rem);--cngx-command-listbox-pad: var(--cngx-space-xs, .25rem);--cngx-command-chip-pad: var(--cngx-space-sm, .5rem)}.cngx-command-panel-input-row{display:flex;align-items:center;gap:var(--cngx-command-input-gap, var(--cngx-space-sm, .5rem));padding:var(--cngx-command-input-pad, var(--cngx-space-md, 1rem));border-block-end:var(--cngx-command-border-width, 1px) solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb))}.cngx-command-panel-input{flex:1 1 auto;min-inline-size:0;font:inherit;color:var(--cngx-command-input-color, inherit);background:transparent;border:0;outline:none}.cngx-command-panel-input::placeholder{color:var(--cngx-command-placeholder-color, var(--cngx-color-muted-foreground, #9ca3af))}.cngx-command-scope-chip{display:inline-flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-inline:var(--cngx-command-chip-pad, var(--cngx-space-sm, .5rem));border-radius:var(--cngx-command-chip-radius, var(--cngx-radius-sm, .25rem));background:var(--cngx-command-chip-bg, var(--cngx-color-muted, #f3f4f6));color:var(--cngx-command-chip-color, inherit);font-size:var(--cngx-command-chip-size, .8125rem)}.cngx-command-panel-listbox{display:block;max-block-size:var(--cngx-command-listbox-max-h, 22rem);overflow-y:auto;padding:var(--cngx-command-listbox-pad, var(--cngx-space-xs, .25rem))}.cngx-command-group-header{padding-block:var(--cngx-command-header-pad-y, var(--cngx-space-xs, .25rem));padding-inline:var(--cngx-command-header-pad-x, var(--cngx-space-sm, .5rem));font-size:var(--cngx-command-header-size, .75rem);font-weight:var(--cngx-command-header-weight, 600);color:var(--cngx-command-header-color, var(--cngx-color-muted-foreground, #6b7280));text-transform:uppercase;letter-spacing:.04em}.cngx-command-row{display:flex;align-items:center;gap:var(--cngx-command-row-gap, var(--cngx-space-sm, .5rem));min-block-size:var(--cngx-target-min, 0px);padding:var(--cngx-command-row-pad, var(--cngx-space-sm, .5rem));border-radius:var(--cngx-command-row-radius, var(--cngx-radius-sm, .25rem));cursor:pointer;color:var(--cngx-command-row-color, inherit)}.cngx-command-row.cngx-option--highlighted{background:var(--cngx-command-row-active-bg, var(--cngx-color-accent, #eef2ff));color:var(--cngx-command-row-active-color, inherit)}@media(forced-colors:active){.cngx-command-row.cngx-option--highlighted{background:Highlight;color:HighlightText}}.cngx-command-row.cngx-option--disabled{cursor:not-allowed;opacity:var(--cngx-command-row-disabled-opacity, .5)}.cngx-command-row-label mark{background:var(--cngx-command-mark-bg, var(--cngx-color-highlight, #fde68a));color:inherit}.cngx-command-panel-input:focus-visible,.cngx-command-row:focus-visible{outline:var(--cngx-command-focus-outline, 2px solid var(--cngx-color-focus, #2563eb));outline-offset:var(--cngx-command-focus-offset, 2px)}.cngx-sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n"] }]
462
+ }], ctorParameters: () => [], propDecorators: { results: [{ type: i0.Input, args: [{ isSignal: true, alias: "results", required: false }] }], scope: [{ type: i0.Input, args: [{ isSignal: true, alias: "scope", required: false }] }, { type: i0.Output, args: ["scopeChange"] }], debounceMs: [{ type: i0.Input, args: [{ isSignal: true, alias: "debounceMs", required: false }] }], rowTpl: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowTpl", required: false }] }], groupHeaderTpl: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupHeaderTpl", required: false }] }], termChange: [{ type: i0.Output, args: ["termChange"] }], listbox: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxListbox), { isSignal: true }] }] } });
463
+ /** @internal Groups ranked results by their `group` key, preserving rank order. */
464
+ function groupRanked(ranked) {
465
+ const groups = [];
466
+ const index = new Map();
467
+ for (const entry of ranked) {
468
+ const key = entry.command.group ?? '';
469
+ let bucket = index.get(key);
470
+ if (!bucket) {
471
+ bucket = [];
472
+ index.set(key, bucket);
473
+ groups.push({ id: `g-${key || 'ungrouped'}`, label: entry.command.group ?? null, items: bucket });
474
+ }
475
+ bucket.push(entry);
476
+ }
477
+ return groups;
478
+ }
479
+ /** @internal Maps consumer async command groups into render groups (score 0). */
480
+ function toRenderGroups(source) {
481
+ return source.map((group) => ({
482
+ id: `a-${group.id}`,
483
+ label: group.label,
484
+ items: group.commands.map((command) => ({ command, score: 0 })),
485
+ }));
486
+ }
487
+ /** @internal Length + id + per-command identity across groups. */
488
+ function renderGroupsEqual(a, b) {
489
+ if (a === b) {
490
+ return true;
491
+ }
492
+ if (a.length !== b.length) {
493
+ return false;
494
+ }
495
+ return a.every((group, i) => {
496
+ const other = b[i];
497
+ return group.id === other.id && group.label === other.label && rankedListEqual(group.items, other.items);
498
+ });
499
+ }
500
+ /** @internal Length + per-command identity. */
501
+ function rankedListEqual(a, b) {
502
+ if (a === b) {
503
+ return true;
504
+ }
505
+ if (a.length !== b.length) {
506
+ return false;
507
+ }
508
+ return a.every((entry, i) => entry.command === b[i].command && entry.score === b[i].score);
509
+ }
510
+
511
+ /**
512
+ * @internal
513
+ * Async-state view switch that wraps {@link CngxCommandPanel}. Maps the
514
+ * consumer's `CngxAsyncState<CommandGroup[]>` through `resolveAsyncView()` to
515
+ * the six-state enum and renders the matching state: `skeleton` on first load,
516
+ * `empty` on an empty success, `error` on a first-load failure, and the
517
+ * projected panel for `content` / `content+error` / `none`. `content+error`
518
+ * keeps the stale results visible while a re-query on the next keystroke errors.
519
+ *
520
+ * Each state resolves its slot template (instance > config > built-in default),
521
+ * passed down from the palette. With no `[results]` bound (static registry
522
+ * only) the view is always `content`, so the panel renders unconditionally.
523
+ */
524
+ class CngxCommandPanelShell {
525
+ /** Consumer-derived async result state driving the view switch. */
526
+ results = input(undefined, ...(ngDevMode ? [{ debugName: "results" }] : /* istanbul ignore next */ []));
527
+ /** Current term, mirrored from the panel - the empty slot's context. */
528
+ term = input('', ...(ngDevMode ? [{ debugName: "term" }] : /* istanbul ignore next */ []));
529
+ /** Resolved slot templates (instance > config > null). Built-in default when null. */
530
+ emptyTpl = input(null, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
531
+ loadingTpl = input(null, ...(ngDevMode ? [{ debugName: "loadingTpl" }] : /* istanbul ignore next */ []));
532
+ errorTpl = input(null, ...(ngDevMode ? [{ debugName: "errorTpl" }] : /* istanbul ignore next */ []));
533
+ /** Fired when the user clicks Retry in the error state. */
534
+ retry = output();
535
+ config = injectCommandPaletteConfig();
536
+ /** The resolved view. `content` when no async source is bound. */
537
+ view = computed(() => {
538
+ const state = this.results();
539
+ if (!state) {
540
+ return 'content';
541
+ }
542
+ return resolveAsyncView(state.status(), state.isFirstLoad(), state.isEmpty());
543
+ }, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
544
+ errorValue = computed(() => this.results()?.error(), ...(ngDevMode ? [{ debugName: "errorValue" }] : /* istanbul ignore next */ []));
545
+ /** Stable bound callback for the error slot's `retry`. */
546
+ emitRetry = () => this.retry.emit();
547
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPanelShell, deps: [], target: i0.ɵɵFactoryTarget.Component });
548
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxCommandPanelShell, isStandalone: true, selector: "cngx-command-panel-shell", inputs: { results: { classPropertyName: "results", publicName: "results", isSignal: true, isRequired: false, transformFunction: null }, term: { classPropertyName: "term", publicName: "term", isSignal: true, isRequired: false, transformFunction: null }, emptyTpl: { classPropertyName: "emptyTpl", publicName: "emptyTpl", isSignal: true, isRequired: false, transformFunction: null }, loadingTpl: { classPropertyName: "loadingTpl", publicName: "loadingTpl", isSignal: true, isRequired: false, transformFunction: null }, errorTpl: { classPropertyName: "errorTpl", publicName: "errorTpl", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { retry: "retry" }, ngImport: i0, template: `
549
+ @switch (view()) {
550
+ @case ('skeleton') {
551
+ @if (loadingTpl(); as tpl) {
552
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
553
+ } @else {
554
+ <div class="cngx-command-state" aria-busy="true">{{ config.loadingLabel }}</div>
555
+ }
556
+ }
557
+ @case ('empty') {
558
+ @if (emptyTpl(); as tpl) {
559
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{ term: term() }" />
560
+ } @else {
561
+ <div class="cngx-command-state cngx-command-state--empty">{{ config.emptyLabel }}</div>
562
+ }
563
+ }
564
+ @case ('error') {
565
+ @if (errorTpl(); as tpl) {
566
+ <ng-container
567
+ [ngTemplateOutlet]="tpl"
568
+ [ngTemplateOutletContext]="{ error: errorValue(), retry: emitRetry }"
569
+ />
570
+ } @else {
571
+ <div class="cngx-command-state cngx-command-state--error" role="alert">
572
+ <span>{{ config.errorLabel }}</span>
573
+ <button type="button" class="cngx-command-retry" (click)="retry.emit()">
574
+ {{ config.retryLabel }}
575
+ </button>
576
+ </div>
577
+ }
578
+ }
579
+ @default {
580
+ @if (view() === 'content+error') {
581
+ <div class="cngx-command-state--error-banner" role="alert">{{ config.errorLabel }}</div>
582
+ }
583
+ <ng-content />
584
+ }
585
+ }
586
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
587
+ }
588
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPanelShell, decorators: [{
589
+ type: Component,
590
+ args: [{
591
+ selector: 'cngx-command-panel-shell',
592
+ standalone: true,
593
+ changeDetection: ChangeDetectionStrategy.OnPush,
594
+ encapsulation: ViewEncapsulation.None,
595
+ imports: [NgTemplateOutlet],
596
+ template: `
597
+ @switch (view()) {
598
+ @case ('skeleton') {
599
+ @if (loadingTpl(); as tpl) {
600
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
601
+ } @else {
602
+ <div class="cngx-command-state" aria-busy="true">{{ config.loadingLabel }}</div>
603
+ }
604
+ }
605
+ @case ('empty') {
606
+ @if (emptyTpl(); as tpl) {
607
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{ term: term() }" />
608
+ } @else {
609
+ <div class="cngx-command-state cngx-command-state--empty">{{ config.emptyLabel }}</div>
610
+ }
611
+ }
612
+ @case ('error') {
613
+ @if (errorTpl(); as tpl) {
614
+ <ng-container
615
+ [ngTemplateOutlet]="tpl"
616
+ [ngTemplateOutletContext]="{ error: errorValue(), retry: emitRetry }"
617
+ />
618
+ } @else {
619
+ <div class="cngx-command-state cngx-command-state--error" role="alert">
620
+ <span>{{ config.errorLabel }}</span>
621
+ <button type="button" class="cngx-command-retry" (click)="retry.emit()">
622
+ {{ config.retryLabel }}
623
+ </button>
624
+ </div>
625
+ }
626
+ }
627
+ @default {
628
+ @if (view() === 'content+error') {
629
+ <div class="cngx-command-state--error-banner" role="alert">{{ config.errorLabel }}</div>
630
+ }
631
+ <ng-content />
632
+ }
633
+ }
634
+ `,
635
+ }]
636
+ }], propDecorators: { results: [{ type: i0.Input, args: [{ isSignal: true, alias: "results", required: false }] }], term: [{ type: i0.Input, args: [{ isSignal: true, alias: "term", required: false }] }], emptyTpl: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyTpl", required: false }] }], loadingTpl: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingTpl", required: false }] }], errorTpl: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorTpl", required: false }] }], retry: [{ type: i0.Output, args: ["retry"] }] } });
637
+
638
+ /**
639
+ * Overrides the default command row. Project as content of
640
+ * `<cngx-command-palette>`:
641
+ *
642
+ * ```html
643
+ * <cngx-command-palette>
644
+ * <ng-template cngxCommandRow let-entry let-active="active">
645
+ * <my-icon [name]="entry.command.icon" />
646
+ * <span>{{ entry.command.label }}</span>
647
+ * </ng-template>
648
+ * </cngx-command-palette>
649
+ * ```
650
+ *
651
+ * @category ui/command-palette
652
+ * @since 0.1.0
653
+ */
654
+ class CngxCommandRow {
655
+ templateRef = inject(TemplateRef);
656
+ static ngTemplateContextGuard(_dir, ctx) {
657
+ return true;
658
+ }
659
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandRow, deps: [], target: i0.ɵɵFactoryTarget.Directive });
660
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxCommandRow, isStandalone: true, selector: "[cngxCommandRow]", ngImport: i0 });
661
+ }
662
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandRow, decorators: [{
663
+ type: Directive,
664
+ args: [{ selector: '[cngxCommandRow]', standalone: true }]
665
+ }] });
666
+ /**
667
+ * Overrides the default group header.
668
+ *
669
+ * @category ui/command-palette
670
+ * @since 0.1.0
671
+ */
672
+ class CngxCommandGroupHeader {
673
+ templateRef = inject(TemplateRef);
674
+ static ngTemplateContextGuard(_dir, ctx) {
675
+ return true;
676
+ }
677
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandGroupHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
678
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxCommandGroupHeader, isStandalone: true, selector: "[cngxCommandGroupHeader]", ngImport: i0 });
679
+ }
680
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandGroupHeader, decorators: [{
681
+ type: Directive,
682
+ args: [{ selector: '[cngxCommandGroupHeader]', standalone: true }]
683
+ }] });
684
+ /**
685
+ * Overrides the default empty state.
686
+ *
687
+ * @category ui/command-palette
688
+ * @since 0.1.0
689
+ */
690
+ class CngxCommandPaletteEmpty {
691
+ templateRef = inject(TemplateRef);
692
+ static ngTemplateContextGuard(_dir, ctx) {
693
+ return true;
694
+ }
695
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
696
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxCommandPaletteEmpty, isStandalone: true, selector: "[cngxCommandPaletteEmpty]", ngImport: i0 });
697
+ }
698
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteEmpty, decorators: [{
699
+ type: Directive,
700
+ args: [{ selector: '[cngxCommandPaletteEmpty]', standalone: true }]
701
+ }] });
702
+ /**
703
+ * Overrides the default first-load skeleton.
704
+ *
705
+ * @category ui/command-palette
706
+ * @since 0.1.0
707
+ */
708
+ class CngxCommandPaletteLoading {
709
+ templateRef = inject(TemplateRef);
710
+ static ngTemplateContextGuard(_dir, ctx) {
711
+ return true;
712
+ }
713
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteLoading, deps: [], target: i0.ɵɵFactoryTarget.Directive });
714
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxCommandPaletteLoading, isStandalone: true, selector: "[cngxCommandPaletteLoading]", ngImport: i0 });
715
+ }
716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteLoading, decorators: [{
717
+ type: Directive,
718
+ args: [{ selector: '[cngxCommandPaletteLoading]', standalone: true }]
719
+ }] });
720
+ /**
721
+ * Overrides the default error state. Wire `retry` to your reload path.
722
+ *
723
+ * @category ui/command-palette
724
+ * @since 0.1.0
725
+ */
726
+ class CngxCommandPaletteError {
727
+ templateRef = inject(TemplateRef);
728
+ static ngTemplateContextGuard(_dir, ctx) {
729
+ return true;
730
+ }
731
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
732
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxCommandPaletteError, isStandalone: true, selector: "[cngxCommandPaletteError]", ngImport: i0 });
733
+ }
734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteError, decorators: [{
735
+ type: Directive,
736
+ args: [{ selector: '[cngxCommandPaletteError]', standalone: true }]
737
+ }] });
738
+ /**
739
+ * Overrides the default keyboard-legend footer.
740
+ *
741
+ * @category ui/command-palette
742
+ * @since 0.1.0
743
+ */
744
+ class CngxCommandPaletteFooter {
745
+ templateRef = inject(TemplateRef);
746
+ static ngTemplateContextGuard(_dir, ctx) {
747
+ return true;
748
+ }
749
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
750
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxCommandPaletteFooter, isStandalone: true, selector: "[cngxCommandPaletteFooter]", ngImport: i0 });
751
+ }
752
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteFooter, decorators: [{
753
+ type: Directive,
754
+ args: [{ selector: '[cngxCommandPaletteFooter]', standalone: true }]
755
+ }] });
756
+
757
+ /**
758
+ * Default palette keybinding: installs a document keydown listener that calls
759
+ * `onOpen` whenever the combo is pressed (matched via `matchesKeyCombo`).
760
+ * Side-effectful by design - it owns the global listener - so its `teardown`
761
+ * must be called on destroy.
762
+ *
763
+ * `isMac` defaults to platform detection; pass it explicitly for deterministic
764
+ * tests.
765
+ *
766
+ * @category ui/command-palette
767
+ * @since 0.1.0
768
+ */
769
+ function createPaletteKeybinding(combo, onOpen, isMac = detectMac()) {
770
+ const handler = (event) => {
771
+ if (matchesKeyCombo(event, combo, isMac)) {
772
+ event.preventDefault();
773
+ onOpen();
774
+ }
775
+ };
776
+ document.addEventListener('keydown', handler);
777
+ return { teardown: () => document.removeEventListener('keydown', handler) };
778
+ }
779
+ /**
780
+ * Swappable open-trigger seam. Defaults to {@link createPaletteKeybinding}.
781
+ * Override it to install an enterprise key-capture policy without touching the
782
+ * palette. To only change the *combo*, prefer `withPaletteShortcut(...)` or the
783
+ * `[openShortcut]` input - this token is for replacing the whole listener.
784
+ *
785
+ * @category ui/command-palette
786
+ * @since 0.1.0
787
+ */
788
+ const CNGX_PALETTE_KEYBINDING_FACTORY = new InjectionToken('CNGX_PALETTE_KEYBINDING_FACTORY', { providedIn: 'root', factory: () => createPaletteKeybinding });
789
+ /** @internal Best-effort macOS detection; overridable via the `isMac` argument. */
790
+ function detectMac() {
791
+ return typeof navigator !== 'undefined' && /mac/i.test(navigator.platform);
792
+ }
793
+
794
+ /**
795
+ * The opinionated Cmd/Ctrl+K command palette preset. Renders the panel body +
796
+ * async-state shell inside a native modal `<dialog cngxDialog>`, so focus
797
+ * trapping, trigger storage at open, and focus restore after the close
798
+ * transition are handled by `CngxDialog` and the platform - no hand-rolled
799
+ * focus machinery. The palette provides `CNGX_COMMAND_PALETTE_HOST` so the
800
+ * panel can dismiss it when a command runs.
801
+ *
802
+ * Type-to-filter runs over the merged command registry (`injectCommands`) plus
803
+ * the consumer's async `[results]`; the palette commits no form value - it
804
+ * fires `command.run()`, the locked demarcation from `CngxCombobox`. The global
805
+ * Cmd/Ctrl+K open combo is wired by the keybinding factory, not here.
806
+ *
807
+ * ```html
808
+ * <cngx-command-palette #palette [results]="results()" />
809
+ * <button [cngxCommandPaletteTrigger]="palette">Search commands</button>
810
+ * ```
811
+ *
812
+ * @category ui/command-palette
813
+ * @docsKind primary
814
+ * @wcag AA
815
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/command-palette/palette/command-palette.component.ts
816
+ * @selector cngx-command-palette
817
+ * @since 0.1.0
818
+ * @relatedTo CngxCommandPaletteTrigger, provideCommands, CngxDialog
819
+ */
820
+ class CngxCommandPalette {
821
+ /** Consumer-derived async result source. */
822
+ results = input(undefined, ...(ngDevMode ? [{ debugName: "results" }] : /* istanbul ignore next */ []));
823
+ /** Two-way scope; feeds the matcher's scope filter and the panel chip. */
824
+ scope = model(undefined, ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
825
+ /** Debounce for the search input. */
826
+ debounceMs = input(150, ...(ngDevMode ? [{ debugName: "debounceMs" }] : /* istanbul ignore next */ []));
827
+ /** Accessible name for the dialog. */
828
+ ariaLabel = input('Command palette', ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
829
+ /**
830
+ * Per-instance open combo (parsed via `parseKeyCombo`, e.g. `'mod+shift+p'`).
831
+ * Wins over `CNGX_COMMAND_PALETTE_CONFIG.openShortcut` (`withPaletteShortcut`),
832
+ * which wins over the `'mod+k'` default. Changing it live re-installs the
833
+ * listener. For a full listener swap, override `CNGX_PALETTE_KEYBINDING_FACTORY`.
834
+ */
835
+ openShortcut = input(undefined, ...(ngDevMode ? [{ debugName: "openShortcut" }] : /* istanbul ignore next */ []));
836
+ /** Fired when the user asks to retry a failed result load. */
837
+ retry = output();
838
+ config = injectCommandPaletteConfig();
839
+ /** Mirror of the panel's debounced term, so the empty slot can read it. */
840
+ term = signal('', ...(ngDevMode ? [{ debugName: "term" }] : /* istanbul ignore next */ []));
841
+ // Instance slot directives (content-projected). contentChild must be a direct
842
+ // field initializer (AOT NG8110). Each resolves instance > config > null.
843
+ rowSlot = contentChild(CngxCommandRow, ...(ngDevMode ? [{ debugName: "rowSlot" }] : /* istanbul ignore next */ []));
844
+ groupHeaderSlot = contentChild(CngxCommandGroupHeader, ...(ngDevMode ? [{ debugName: "groupHeaderSlot" }] : /* istanbul ignore next */ []));
845
+ emptySlot = contentChild(CngxCommandPaletteEmpty, ...(ngDevMode ? [{ debugName: "emptySlot" }] : /* istanbul ignore next */ []));
846
+ loadingSlot = contentChild(CngxCommandPaletteLoading, ...(ngDevMode ? [{ debugName: "loadingSlot" }] : /* istanbul ignore next */ []));
847
+ errorSlot = contentChild(CngxCommandPaletteError, ...(ngDevMode ? [{ debugName: "errorSlot" }] : /* istanbul ignore next */ []));
848
+ footerSlot = contentChild(CngxCommandPaletteFooter, ...(ngDevMode ? [{ debugName: "footerSlot" }] : /* istanbul ignore next */ []));
849
+ rowTpl = computed(() => this.rowSlot()?.templateRef ?? this.config.templates?.row ?? null, ...(ngDevMode ? [{ debugName: "rowTpl" }] : /* istanbul ignore next */ []));
850
+ groupHeaderTpl = computed(() => this.groupHeaderSlot()?.templateRef ?? this.config.templates?.groupHeader ?? null, ...(ngDevMode ? [{ debugName: "groupHeaderTpl" }] : /* istanbul ignore next */ []));
851
+ emptyTpl = computed(() => this.emptySlot()?.templateRef ?? this.config.templates?.empty ?? null, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
852
+ loadingTpl = computed(() => this.loadingSlot()?.templateRef ?? this.config.templates?.loading ?? null, ...(ngDevMode ? [{ debugName: "loadingTpl" }] : /* istanbul ignore next */ []));
853
+ errorTpl = computed(() => this.errorSlot()?.templateRef ?? this.config.templates?.error ?? null, ...(ngDevMode ? [{ debugName: "errorTpl" }] : /* istanbul ignore next */ []));
854
+ footerTpl = computed(() => this.footerSlot()?.templateRef ?? this.config.templates?.footer ?? null, ...(ngDevMode ? [{ debugName: "footerTpl" }] : /* istanbul ignore next */ []));
855
+ dialog = viewChild(CngxDialog, ...(ngDevMode ? [{ debugName: "dialog" }] : /* istanbul ignore next */ []));
856
+ /** Whether the palette is open. Part of the {@link CngxCommandPaletteHost} contract. */
857
+ isOpen = computed(() => (this.dialog()?.lifecycle() ?? 'closed') !== 'closed', ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
858
+ /** Resolved open combo: instance input > config > `'mod+k'` default. */
859
+ resolvedShortcut = computed(() => this.openShortcut() ?? this.config.openShortcut, ...(ngDevMode ? [{ debugName: "resolvedShortcut" }] : /* istanbul ignore next */ []));
860
+ constructor() {
861
+ // The swappable factory installs the global open combo and calls back to
862
+ // open the palette. The effect re-installs the listener whenever the
863
+ // resolved combo changes; onCleanup tears down the previous listener (and
864
+ // the last one on destroy), so nothing leaks document-wide.
865
+ const factory = inject(CNGX_PALETTE_KEYBINDING_FACTORY);
866
+ effect((onCleanup) => {
867
+ const keybinding = factory(parseKeyCombo(this.resolvedShortcut()), () => this.open());
868
+ onCleanup(() => keybinding.teardown());
869
+ });
870
+ }
871
+ /** Open the palette. */
872
+ open() {
873
+ this.dialog()?.open();
874
+ }
875
+ /** Dismiss the palette. Focus returns to the trigger via `CngxDialog`. */
876
+ dismiss() {
877
+ this.dialog()?.dismiss();
878
+ }
879
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPalette, deps: [], target: i0.ɵɵFactoryTarget.Component });
880
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxCommandPalette, isStandalone: true, selector: "cngx-command-palette", inputs: { results: { classPropertyName: "results", publicName: "results", isSignal: true, isRequired: false, transformFunction: null }, scope: { classPropertyName: "scope", publicName: "scope", isSignal: true, isRequired: false, transformFunction: null }, debounceMs: { classPropertyName: "debounceMs", publicName: "debounceMs", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, openShortcut: { classPropertyName: "openShortcut", publicName: "openShortcut", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { scope: "scopeChange", retry: "retry" }, providers: [{ provide: CNGX_COMMAND_PALETTE_HOST, useExisting: CngxCommandPalette }], queries: [{ propertyName: "rowSlot", first: true, predicate: CngxCommandRow, descendants: true, isSignal: true }, { propertyName: "groupHeaderSlot", first: true, predicate: CngxCommandGroupHeader, descendants: true, isSignal: true }, { propertyName: "emptySlot", first: true, predicate: CngxCommandPaletteEmpty, descendants: true, isSignal: true }, { propertyName: "loadingSlot", first: true, predicate: CngxCommandPaletteLoading, descendants: true, isSignal: true }, { propertyName: "errorSlot", first: true, predicate: CngxCommandPaletteError, descendants: true, isSignal: true }, { propertyName: "footerSlot", first: true, predicate: CngxCommandPaletteFooter, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "dialog", first: true, predicate: CngxDialog, descendants: true, isSignal: true }], ngImport: i0, template: `
881
+ <dialog
882
+ cngxDialog
883
+ #dialog="cngxDialog"
884
+ class="cngx-command-palette"
885
+ [attr.aria-label]="ariaLabel()"
886
+ >
887
+ <cngx-command-panel-shell
888
+ [results]="results()"
889
+ [term]="term()"
890
+ [emptyTpl]="emptyTpl()"
891
+ [loadingTpl]="loadingTpl()"
892
+ [errorTpl]="errorTpl()"
893
+ (retry)="retry.emit()"
894
+ >
895
+ <cngx-command-panel
896
+ [results]="results()"
897
+ [(scope)]="scope"
898
+ [debounceMs]="debounceMs()"
899
+ [rowTpl]="rowTpl()"
900
+ [groupHeaderTpl]="groupHeaderTpl()"
901
+ (termChange)="term.set($event)"
902
+ />
903
+ </cngx-command-panel-shell>
904
+ <footer class="cngx-command-footer">
905
+ @if (footerTpl(); as tpl) {
906
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
907
+ } @else {
908
+ @for (entry of config.footerLegend; track entry.label) {
909
+ <span class="cngx-command-legend"><kbd>{{ entry.keys }}</kbd> {{ entry.label }}</span>
910
+ }
911
+ }
912
+ </footer>
913
+ </dialog>
914
+ `, isInline: true, styles: [".cngx-command-palette{--cngx-command-footer-gap: var(--cngx-space-md, 1rem);--cngx-command-footer-pad-y: var(--cngx-space-sm, .5rem);--cngx-command-footer-pad-x: var(--cngx-space-md, 1rem);--cngx-command-state-pad: var(--cngx-space-lg, 1.5rem);padding:0;inline-size:var(--cngx-command-width, min(40rem, calc(100vw - 2rem) ));max-block-size:var(--cngx-command-max-h, min(32rem, calc(100vh - 6rem) ));overflow:hidden;border:var(--cngx-command-border-width, 1px) solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb));border-radius:var(--cngx-command-radius, var(--cngx-radius-lg, .75rem));background:var(--cngx-command-bg, var(--cngx-color-surface, #ffffff));color:var(--cngx-command-color, inherit);box-shadow:var(--cngx-command-shadow, 0 10px 40px rgb(0 0 0 / .2))}.cngx-command-palette[open]{display:flex;flex-direction:column}.cngx-command-palette::backdrop{background:var(--cngx-command-backdrop, rgb(0 0 0 / .4))}@media(forced-colors:active){.cngx-command-palette{border-color:CanvasText}}.cngx-command-state{padding:var(--cngx-command-state-pad, var(--cngx-space-lg, 1.5rem));text-align:center;color:var(--cngx-command-state-color, var(--cngx-color-muted-foreground, #6b7280))}.cngx-command-state--error{color:var(--cngx-command-error-color, var(--cngx-color-danger, #dc2626))}.cngx-command-state--error-banner{padding:var(--cngx-space-sm, .5rem) var(--cngx-space-md, 1rem);color:var(--cngx-command-error-color, var(--cngx-color-danger, #dc2626))}.cngx-command-retry{min-block-size:var(--cngx-target-min, 0px);margin-inline-start:var(--cngx-space-sm, .5rem);padding-inline:var(--cngx-space-md, 1rem);font:inherit;color:inherit;cursor:pointer;background:var(--cngx-command-retry-bg, transparent);border:1px solid currentColor;border-radius:var(--cngx-radius-sm, .25rem)}.cngx-command-retry:focus-visible{outline:var(--cngx-command-focus-outline, 2px solid var(--cngx-color-focus, #2563eb));outline-offset:2px}.cngx-command-footer{display:flex;flex-wrap:wrap;gap:var(--cngx-command-footer-gap, var(--cngx-space-md, 1rem));padding:var(--cngx-command-footer-pad-y, var(--cngx-space-sm, .5rem)) var(--cngx-command-footer-pad-x, var(--cngx-space-md, 1rem));border-block-start:var(--cngx-command-border-width, 1px) solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb));font-size:var(--cngx-command-footer-size, .75rem);color:var(--cngx-command-footer-color, var(--cngx-color-muted-foreground, #6b7280))}.cngx-command-legend{display:inline-flex;align-items:center;gap:var(--cngx-space-xs, .25rem)}.cngx-command-legend kbd{padding:.1em .4em;font-family:inherit;font-size:.9em;color:var(--cngx-command-kbd-color, inherit);background:var(--cngx-command-kbd-bg, var(--cngx-color-muted, #f3f4f6));border:1px solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb));border-radius:var(--cngx-radius-xs, .1875rem)}\n"], dependencies: [{ kind: "directive", type: CngxDialog, selector: "dialog[cngxDialog]", inputs: ["modal", "closeOnBackdropClick", "closeOnEscape", "autoFocus", "focusFallback", "state", "submitAction", "error"], exportAs: ["cngxDialog"] }, { kind: "component", type: CngxCommandPanelShell, selector: "cngx-command-panel-shell", inputs: ["results", "term", "emptyTpl", "loadingTpl", "errorTpl"], outputs: ["retry"] }, { kind: "component", type: CngxCommandPanel, selector: "cngx-command-panel", inputs: ["results", "scope", "debounceMs", "rowTpl", "groupHeaderTpl"], outputs: ["scopeChange", "termChange"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
915
+ }
916
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPalette, decorators: [{
917
+ type: Component,
918
+ args: [{ selector: 'cngx-command-palette', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxDialog, CngxCommandPanelShell, CngxCommandPanel, NgTemplateOutlet], providers: [{ provide: CNGX_COMMAND_PALETTE_HOST, useExisting: CngxCommandPalette }], template: `
919
+ <dialog
920
+ cngxDialog
921
+ #dialog="cngxDialog"
922
+ class="cngx-command-palette"
923
+ [attr.aria-label]="ariaLabel()"
924
+ >
925
+ <cngx-command-panel-shell
926
+ [results]="results()"
927
+ [term]="term()"
928
+ [emptyTpl]="emptyTpl()"
929
+ [loadingTpl]="loadingTpl()"
930
+ [errorTpl]="errorTpl()"
931
+ (retry)="retry.emit()"
932
+ >
933
+ <cngx-command-panel
934
+ [results]="results()"
935
+ [(scope)]="scope"
936
+ [debounceMs]="debounceMs()"
937
+ [rowTpl]="rowTpl()"
938
+ [groupHeaderTpl]="groupHeaderTpl()"
939
+ (termChange)="term.set($event)"
940
+ />
941
+ </cngx-command-panel-shell>
942
+ <footer class="cngx-command-footer">
943
+ @if (footerTpl(); as tpl) {
944
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
945
+ } @else {
946
+ @for (entry of config.footerLegend; track entry.label) {
947
+ <span class="cngx-command-legend"><kbd>{{ entry.keys }}</kbd> {{ entry.label }}</span>
948
+ }
949
+ }
950
+ </footer>
951
+ </dialog>
952
+ `, styles: [".cngx-command-palette{--cngx-command-footer-gap: var(--cngx-space-md, 1rem);--cngx-command-footer-pad-y: var(--cngx-space-sm, .5rem);--cngx-command-footer-pad-x: var(--cngx-space-md, 1rem);--cngx-command-state-pad: var(--cngx-space-lg, 1.5rem);padding:0;inline-size:var(--cngx-command-width, min(40rem, calc(100vw - 2rem) ));max-block-size:var(--cngx-command-max-h, min(32rem, calc(100vh - 6rem) ));overflow:hidden;border:var(--cngx-command-border-width, 1px) solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb));border-radius:var(--cngx-command-radius, var(--cngx-radius-lg, .75rem));background:var(--cngx-command-bg, var(--cngx-color-surface, #ffffff));color:var(--cngx-command-color, inherit);box-shadow:var(--cngx-command-shadow, 0 10px 40px rgb(0 0 0 / .2))}.cngx-command-palette[open]{display:flex;flex-direction:column}.cngx-command-palette::backdrop{background:var(--cngx-command-backdrop, rgb(0 0 0 / .4))}@media(forced-colors:active){.cngx-command-palette{border-color:CanvasText}}.cngx-command-state{padding:var(--cngx-command-state-pad, var(--cngx-space-lg, 1.5rem));text-align:center;color:var(--cngx-command-state-color, var(--cngx-color-muted-foreground, #6b7280))}.cngx-command-state--error{color:var(--cngx-command-error-color, var(--cngx-color-danger, #dc2626))}.cngx-command-state--error-banner{padding:var(--cngx-space-sm, .5rem) var(--cngx-space-md, 1rem);color:var(--cngx-command-error-color, var(--cngx-color-danger, #dc2626))}.cngx-command-retry{min-block-size:var(--cngx-target-min, 0px);margin-inline-start:var(--cngx-space-sm, .5rem);padding-inline:var(--cngx-space-md, 1rem);font:inherit;color:inherit;cursor:pointer;background:var(--cngx-command-retry-bg, transparent);border:1px solid currentColor;border-radius:var(--cngx-radius-sm, .25rem)}.cngx-command-retry:focus-visible{outline:var(--cngx-command-focus-outline, 2px solid var(--cngx-color-focus, #2563eb));outline-offset:2px}.cngx-command-footer{display:flex;flex-wrap:wrap;gap:var(--cngx-command-footer-gap, var(--cngx-space-md, 1rem));padding:var(--cngx-command-footer-pad-y, var(--cngx-space-sm, .5rem)) var(--cngx-command-footer-pad-x, var(--cngx-space-md, 1rem));border-block-start:var(--cngx-command-border-width, 1px) solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb));font-size:var(--cngx-command-footer-size, .75rem);color:var(--cngx-command-footer-color, var(--cngx-color-muted-foreground, #6b7280))}.cngx-command-legend{display:inline-flex;align-items:center;gap:var(--cngx-space-xs, .25rem)}.cngx-command-legend kbd{padding:.1em .4em;font-family:inherit;font-size:.9em;color:var(--cngx-command-kbd-color, inherit);background:var(--cngx-command-kbd-bg, var(--cngx-color-muted, #f3f4f6));border:1px solid var(--cngx-command-border, var(--cngx-color-border, #e5e7eb));border-radius:var(--cngx-radius-xs, .1875rem)}\n"] }]
953
+ }], ctorParameters: () => [], propDecorators: { results: [{ type: i0.Input, args: [{ isSignal: true, alias: "results", required: false }] }], scope: [{ type: i0.Input, args: [{ isSignal: true, alias: "scope", required: false }] }, { type: i0.Output, args: ["scopeChange"] }], debounceMs: [{ type: i0.Input, args: [{ isSignal: true, alias: "debounceMs", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], openShortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "openShortcut", required: false }] }], retry: [{ type: i0.Output, args: ["retry"] }], rowSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxCommandRow), { isSignal: true }] }], groupHeaderSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxCommandGroupHeader), { isSignal: true }] }], emptySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxCommandPaletteEmpty), { isSignal: true }] }], loadingSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxCommandPaletteLoading), { isSignal: true }] }], errorSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxCommandPaletteError), { isSignal: true }] }], footerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxCommandPaletteFooter), { isSignal: true }] }], dialog: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxDialog), { isSignal: true }] }] } });
954
+
955
+ /**
956
+ * Optional explicit trigger for a {@link CngxCommandPalette}. Opens the palette
957
+ * on click and advertises the popup relationship to assistive tech. Pass the
958
+ * palette by template reference - orthogonal composition, no ancestor
959
+ * injection.
960
+ *
961
+ * ```html
962
+ * <button [cngxCommandPaletteTrigger]="palette">
963
+ * Search <kbd>Cmd K</kbd>
964
+ * </button>
965
+ * <cngx-command-palette #palette />
966
+ * ```
967
+ *
968
+ * @category ui/command-palette
969
+ * @wcag AA
970
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/command-palette/palette/command-palette-trigger.directive.ts
971
+ * @since 0.1.0
972
+ * @relatedTo CngxCommandPalette
973
+ */
974
+ class CngxCommandPaletteTrigger {
975
+ /** The palette this trigger opens. */
976
+ palette = input.required({ ...(ngDevMode ? { debugName: "palette" } : /* istanbul ignore next */ {}), alias: 'cngxCommandPaletteTrigger' });
977
+ open() {
978
+ this.palette().open();
979
+ }
980
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
981
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxCommandPaletteTrigger, isStandalone: true, selector: "[cngxCommandPaletteTrigger]", inputs: { palette: { classPropertyName: "palette", publicName: "cngxCommandPaletteTrigger", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "open()" }, properties: { "attr.aria-haspopup": "\"dialog\"" } }, exportAs: ["cngxCommandPaletteTrigger"], ngImport: i0 });
982
+ }
983
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteTrigger, decorators: [{
984
+ type: Directive,
985
+ args: [{
986
+ selector: '[cngxCommandPaletteTrigger]',
987
+ exportAs: 'cngxCommandPaletteTrigger',
988
+ standalone: true,
989
+ host: {
990
+ '[attr.aria-haspopup]': '"dialog"',
991
+ '(click)': 'open()',
992
+ },
993
+ }]
994
+ }], propDecorators: { palette: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxCommandPaletteTrigger", required: true }] }] } });
995
+
996
+ /**
997
+ * @module @cngx/ui/command-palette
998
+ */
999
+
1000
+ /**
1001
+ * Generated bundle index. Do not edit.
1002
+ */
1003
+
1004
+ export { CNGX_COMMAND_PALETTE_CONFIG, CNGX_COMMAND_PALETTE_HOST, CNGX_PALETTE_KEYBINDING_FACTORY, CngxCommandGroupHeader, CngxCommandPalette, CngxCommandPaletteEmpty, CngxCommandPaletteError, CngxCommandPaletteFooter, CngxCommandPaletteLoading, CngxCommandPaletteTrigger, CngxCommandRow, createPaletteKeybinding, injectCommandPaletteConfig, provideCommandPaletteConfig, provideCommandPaletteConfigAt, withCommandPaletteLabels, withCommandPaletteTemplates, withKeyboardLegend, withPaletteShortcut, withResultCountFormatter };
1005
+ //# sourceMappingURL=cngx-ui-command-palette.mjs.map