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

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 (101) hide show
  1. package/README.md +0 -1
  2. package/a11y/README.md +11 -5
  3. package/accordion/README.md +4 -2
  4. package/breadcrumb/README.md +262 -0
  5. package/collection/README.md +6 -0
  6. package/command-palette/README.md +227 -0
  7. package/data-grid-accordion/README.md +76 -2
  8. package/feedback/README.md +40 -0
  9. package/fesm2022/cngx-ui-a11y.mjs +189 -57
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +120 -36
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +121 -56
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +228 -108
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +180 -23
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +204 -62
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +395 -119
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +209 -40
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -101
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +16 -6
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +1074 -460
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-mat-accordion.mjs +76 -7
  32. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
  34. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
  36. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-tabs.mjs +555 -204
  38. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-overlay.mjs +69 -13
  40. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-paginator.mjs +553 -198
  42. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  43. package/fesm2022/cngx-ui-sidenav.mjs +344 -109
  44. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-skeleton.mjs +4 -16
  46. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-speak.mjs +107 -8
  48. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-stat-card.mjs +146 -46
  50. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-stepper.mjs +234 -99
  52. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-tabs.mjs +88 -25
  54. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-timeline.mjs +98 -23
  56. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-toc.mjs +101 -33
  58. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  59. package/fesm2022/cngx-ui.mjs +15 -20
  60. package/fesm2022/cngx-ui.mjs.map +1 -1
  61. package/mat-paginator/README.md +9 -2
  62. package/mat-tabs/README.md +30 -6
  63. package/mat-tabs/styles/mat-tabs.css +188 -42
  64. package/overlay/README.md +9 -4
  65. package/package.json +31 -7
  66. package/paginator/README.md +8 -4
  67. package/schematics/collection.json +9 -0
  68. package/schematics/ng-add/index.js +9 -0
  69. package/schematics/ng-add/schema.json +91 -0
  70. package/schematics/package.json +3 -0
  71. package/sidenav/README.md +33 -11
  72. package/speak/README.md +3 -2
  73. package/stepper/README.md +14 -2
  74. package/timeline/README.md +1 -1
  75. package/toc/README.md +4 -1
  76. package/types/cngx-ui-a11y.d.ts +121 -30
  77. package/types/cngx-ui-accordion.d.ts +100 -28
  78. package/types/cngx-ui-action-button.d.ts +44 -3
  79. package/types/cngx-ui-breadcrumb.d.ts +167 -60
  80. package/types/cngx-ui-chart-panel.d.ts +122 -18
  81. package/types/cngx-ui-collection.d.ts +157 -55
  82. package/types/cngx-ui-command-palette.d.ts +297 -183
  83. package/types/cngx-ui-context-menu.d.ts +140 -10
  84. package/types/cngx-ui-data-grid-accordion.d.ts +278 -39
  85. package/types/cngx-ui-empty-state.d.ts +9 -2
  86. package/types/cngx-ui-feedback.d.ts +605 -59
  87. package/types/cngx-ui-mat-accordion.d.ts +30 -1
  88. package/types/cngx-ui-mat-paginator.d.ts +37 -8
  89. package/types/cngx-ui-mat-stepper.d.ts +23 -11
  90. package/types/cngx-ui-mat-tabs.d.ts +250 -34
  91. package/types/cngx-ui-overlay.d.ts +56 -10
  92. package/types/cngx-ui-paginator.d.ts +425 -136
  93. package/types/cngx-ui-sidenav.d.ts +248 -74
  94. package/types/cngx-ui-skeleton.d.ts +6 -7
  95. package/types/cngx-ui-speak.d.ts +118 -5
  96. package/types/cngx-ui-stat-card.d.ts +117 -33
  97. package/types/cngx-ui-stepper.d.ts +88 -49
  98. package/types/cngx-ui-tabs.d.ts +6 -4
  99. package/types/cngx-ui-timeline.d.ts +35 -11
  100. package/types/cngx-ui-toc.d.ts +93 -16
  101. package/types/cngx-ui.d.ts +7 -4
@@ -1,47 +1,101 @@
1
1
  import { NgTemplateOutlet } from '@angular/common';
2
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';
3
+ import { InjectionToken, inject, makeEnvironmentProviders, SkipSelf, Optional, isSignal, computed, input, model, DestroyRef, viewChild, signal, untracked, afterNextRender, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, output, TemplateRef, Directive, contentChild } from '@angular/core';
4
4
  import { CngxDialog } from '@cngx/common/dialog';
5
- import { nextUid, matchesKeyCombo, parseKeyCombo } from '@cngx/core/utils';
5
+ import { coerceSignal, nextUid, matchesKeyCombo, parseKeyCombo } from '@cngx/core/utils';
6
+ import { recordEqual } from '@cngx/utils';
7
+ import { formatMessage, createLanguageSection, createSectionBundle } from '@cngx/core/i18n';
8
+ import { outputToObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
9
  import { injectCommands, CNGX_COMMAND_MATCH_FACTORY } from '@cngx/common/command';
7
10
  import { CngxListbox, CngxSearch, CngxOption } from '@cngx/common/interactive';
8
11
  import { CngxHighlight } from '@cngx/common/layout';
9
12
  import { resolveAsyncView } from '@cngx/common/data';
10
13
 
14
+ /**
15
+ * The English command-palette section: the single source of the palette's
16
+ * English copy. The `CNGX_COMMAND_PALETTE_CONFIG` copy keys default to it.
17
+ *
18
+ * @category ui/command-palette/i18n
19
+ * @since 0.1.0
20
+ * @relatedTo CNGX_COMMAND_PALETTE_CONFIG
21
+ */
22
+ const CNGX_COMMAND_PALETTE_LANGUAGE_EN = {
23
+ searchPlaceholder: 'Type a command or search…',
24
+ listboxLabel: 'Commands',
25
+ emptyLabel: 'No matching commands',
26
+ loadingLabel: 'Loading commands…',
27
+ errorLabel: 'Could not load commands',
28
+ retryLabel: 'Retry',
29
+ paletteLabel: 'Command palette',
30
+ resultCount: { one: '{count} result', other: '{count} results' },
31
+ navigateKeys: '↑ ↓',
32
+ navigateKeysSpoken: 'Up and Down arrows',
33
+ navigateLabel: 'Navigate',
34
+ runKeys: 'Enter',
35
+ runLabel: 'Run',
36
+ closeKeys: 'Esc',
37
+ closeLabel: 'Close',
38
+ legendEntry: '{keys} {label}',
39
+ };
40
+
41
+ /** @internal Turns a command-palette section into the config copy for a locale. Pure. */
42
+ function commandPaletteCopyFrom(section, locale) {
43
+ return {
44
+ searchPlaceholder: section.searchPlaceholder,
45
+ listboxLabel: section.listboxLabel,
46
+ emptyLabel: section.emptyLabel,
47
+ loadingLabel: section.loadingLabel,
48
+ errorLabel: section.errorLabel,
49
+ retryLabel: section.retryLabel,
50
+ paletteLabel: section.paletteLabel,
51
+ resultCount: (count) => formatMessage(section.resultCount, { count }, locale),
52
+ footerLegend: [
53
+ {
54
+ keys: section.navigateKeys,
55
+ spokenKeys: section.navigateKeysSpoken,
56
+ label: section.navigateLabel,
57
+ },
58
+ { keys: section.runKeys, label: section.runLabel },
59
+ { keys: section.closeKeys, label: section.closeLabel },
60
+ ],
61
+ legendEntry: (keys, label) => formatMessage(section.legendEntry, { keys, label }, locale),
62
+ };
63
+ }
64
+ /** @internal The command-palette section of the active pack over the English section. */
65
+ const injectCommandPaletteLanguage = createLanguageSection('commandPalette', CNGX_COMMAND_PALETTE_LANGUAGE_EN);
66
+ /** @internal Builds and reads the section copy, formatted for the reading locale. */
67
+ const commandPaletteBundle = createSectionBundle({
68
+ section: injectCommandPaletteLanguage,
69
+ toBundle: commandPaletteCopyFrom,
70
+ });
71
+ /**
72
+ * @internal The command-palette copy of the active pack, formatted for the app
73
+ * locale. Private: consumers override copy through the config features.
74
+ */
75
+ const COMMAND_PALETTE_SECTION_COPY = new InjectionToken('CngxCommandPaletteSectionCopy', { providedIn: 'root', factory: () => commandPaletteBundle.build() });
76
+ /**
77
+ * @internal The command-palette copy at the reading site: the active pack's
78
+ * section formatted for the locale of the injector that reads it. Injection
79
+ * context required.
80
+ */
81
+ function injectCommandPaletteSiteCopy() {
82
+ return commandPaletteBundle.resolve(inject(COMMAND_PALETTE_SECTION_COPY));
83
+ }
84
+
11
85
  /** @internal */
12
86
  const CNGX_COMMAND_PALETTE_DEFAULTS = {
13
87
  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
88
  };
27
89
 
28
90
  /**
29
- * Library-default palette configuration, built from the internal defaults
30
- * const. English-only.
91
+ * Library-default palette configuration. Carries no copy: the copy defaults
92
+ * are the `commandPalette` section of the language pack.
31
93
  *
32
94
  * @category ui/command-palette
33
95
  * @since 0.1.0
34
96
  */
35
97
  const DEFAULT_COMMAND_PALETTE_CONFIG = {
36
98
  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
99
  };
46
100
  /**
47
101
  * DI token carrying the resolved {@link CngxCommandPaletteConfig}. Defaults to
@@ -104,15 +158,79 @@ function provideCommandPaletteConfigAt(...features) {
104
158
  function injectCommandPaletteConfig() {
105
159
  return inject(CNGX_COMMAND_PALETTE_CONFIG);
106
160
  }
161
+ const valueOf = (source) => (isSignal(source) ? source() : source);
162
+ const RESOLVED_COPY = new WeakMap();
163
+ /**
164
+ * @internal - one Signal of the config's copy keys, each unwrapped, over the
165
+ * `commandPalette` section of the active pack at the reading site's locale, so
166
+ * a language switch reaches every reader. A key the config leaves unset reads
167
+ * the section. Memoized per site copy and config object: every palette part
168
+ * under one injector reads the same `computed()`. Injection context required;
169
+ * read the result inside a `computed()`, a template or a handler.
170
+ */
171
+ function resolveCommandPaletteCopy(config) {
172
+ const site = injectCommandPaletteSiteCopy();
173
+ let byConfig = RESOLVED_COPY.get(site);
174
+ if (!byConfig) {
175
+ byConfig = new WeakMap();
176
+ RESOLVED_COPY.set(site, byConfig);
177
+ }
178
+ const cached = byConfig.get(config);
179
+ if (cached) {
180
+ return cached;
181
+ }
182
+ const copy = computed(() => {
183
+ const defaults = site();
184
+ return {
185
+ ...config,
186
+ searchPlaceholder: valueOf(config.searchPlaceholder) ?? defaults.searchPlaceholder,
187
+ listboxLabel: valueOf(config.listboxLabel) ?? defaults.listboxLabel,
188
+ emptyLabel: valueOf(config.emptyLabel) ?? defaults.emptyLabel,
189
+ loadingLabel: valueOf(config.loadingLabel) ?? defaults.loadingLabel,
190
+ errorLabel: valueOf(config.errorLabel) ?? defaults.errorLabel,
191
+ retryLabel: valueOf(config.retryLabel) ?? defaults.retryLabel,
192
+ paletteLabel: valueOf(config.paletteLabel) ?? defaults.paletteLabel,
193
+ resultCount: valueOf(config.resultCount) ?? defaults.resultCount,
194
+ footerLegend: valueOf(config.footerLegend) ?? defaults.footerLegend,
195
+ legendEntry: defaults.legendEntry,
196
+ };
197
+ }, { ...(ngDevMode ? { debugName: "copy" } : /* istanbul ignore next */ {}), equal: recordEqual });
198
+ byConfig.set(config, copy);
199
+ return copy;
200
+ }
201
+ const LABEL_KEYS = [
202
+ 'searchPlaceholder',
203
+ 'listboxLabel',
204
+ 'emptyLabel',
205
+ 'loadingLabel',
206
+ 'errorLabel',
207
+ 'retryLabel',
208
+ 'paletteLabel',
209
+ ];
107
210
  /**
108
211
  * Override any subset of the palette's text labels. Unset labels keep the
109
- * English defaults.
212
+ * inherited value. Pass a `Signal` of the overrides to switch the language at
213
+ * runtime; a key the Signal sets wins over the inherited value, an unset key
214
+ * follows it.
110
215
  *
111
216
  * @category ui/command-palette
112
217
  * @since 0.1.0
113
218
  */
114
219
  function withCommandPaletteLabels(labels) {
115
- return (config) => ({ ...config, ...labels });
220
+ if (!isSignal(labels)) {
221
+ return (config) => ({ ...config, ...labels });
222
+ }
223
+ return (config) => {
224
+ const next = { ...config };
225
+ for (const key of LABEL_KEYS) {
226
+ const inherited = coerceSignal(config[key]);
227
+ next[key] = computed(() => {
228
+ const patch = labels();
229
+ return key in patch ? patch[key] : inherited();
230
+ });
231
+ }
232
+ return next;
233
+ };
116
234
  }
117
235
  /**
118
236
  * Set the combo that opens the palette (parsed via `parseKeyCombo`, e.g.
@@ -127,7 +245,8 @@ function withPaletteShortcut(combo) {
127
245
  return (config) => ({ ...config, openShortcut: combo });
128
246
  }
129
247
  /**
130
- * Replace the footer keyboard legend.
248
+ * Replace the footer keyboard legend. Pass a `Signal` to switch the language at
249
+ * runtime.
131
250
  *
132
251
  * @category ui/command-palette
133
252
  * @since 0.1.0
@@ -137,7 +256,8 @@ function withKeyboardLegend(entries) {
137
256
  }
138
257
  /**
139
258
  * Replace the `aria-live` result-count formatter (e.g. for pluralisation in
140
- * another locale).
259
+ * another locale). Pass a `Signal` of the formatter to switch the language at
260
+ * runtime; the live count speaks the new formatter on its next change.
141
261
  *
142
262
  * @category ui/command-palette
143
263
  * @since 0.1.0
@@ -192,56 +312,161 @@ class CngxCommandPanel {
192
312
  rowTpl = input(null, ...(ngDevMode ? [{ debugName: "rowTpl" }] : /* istanbul ignore next */ []));
193
313
  /** Resolved group-header slot template. Built-in default when null. */
194
314
  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();
315
+ /**
316
+ * Resolved empty slot template. Rendered by the panel itself (below the
317
+ * listbox, input stays mounted) whenever the result count is zero - this
318
+ * covers both the static-registry mode, where the shell has no async state
319
+ * to switch on, and an empty async success.
320
+ */
321
+ emptyTpl = input(null, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
322
+ copy = resolveCommandPaletteCopy(injectCommandPaletteConfig());
198
323
  listboxId = nextUid('cngx-command-listbox');
199
324
  commands = injectCommands();
200
325
  matcher = inject(CNGX_COMMAND_MATCH_FACTORY)();
201
326
  host = inject(CNGX_COMMAND_PALETTE_HOST, { optional: true });
202
327
  destroyRef = inject(DestroyRef);
203
- listbox = viewChild.required(CngxListbox);
328
+ listbox = viewChild(CngxListbox, ...(ngDevMode ? [{ debugName: "listbox" }] : /* istanbul ignore next */ []));
329
+ search = viewChild(CngxSearch, ...(ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []));
204
330
  termState = signal('', ...(ngDevMode ? [{ debugName: "termState" }] : /* istanbul ignore next */ []));
205
331
  /** Current debounced search term. Exposed for the consumer's result derivation. */
206
332
  term = this.termState.asReadonly();
333
+ /** Stable dedupe-key to DOM-id map behind {@link domGroupId}. */
334
+ groupDomIds = new Map();
335
+ /** Stable command-id to reason-DOM-id map behind {@link reasonId}. */
336
+ reasonDomIds = new Map();
207
337
  /** Grouped, ranked results: consumer async groups first, then the ranked registry. */
208
338
  groups = computed(() => {
209
339
  const ranked = this.matcher(this.commands(), this.term(), this.scope());
210
340
  const asyncState = this.results();
211
- const asyncGroups = asyncState ? toRenderGroups(asyncState.data() ?? []) : [];
212
- return [...asyncGroups, ...groupRanked(ranked)];
341
+ const asyncGroups = asyncState ? toRawGroups(asyncState.data() ?? []) : [];
342
+ const raws = [...asyncGroups, ...groupRanked(ranked)];
343
+ this.pruneDomIds(raws);
344
+ return raws.map((raw) => ({
345
+ id: this.domGroupId(raw.key),
346
+ label: raw.label,
347
+ items: raw.items,
348
+ slot: {
349
+ id: raw.slotId,
350
+ label: raw.label ?? '',
351
+ commands: raw.items.map((entry) => entry.command),
352
+ },
353
+ }));
213
354
  }, { ...(ngDevMode ? { debugName: "groups" } : /* istanbul ignore next */ {}), equal: renderGroupsEqual });
355
+ /**
356
+ * Drop id-map entries whose group key / command id left the result set, so
357
+ * the memoized maps stay bounded when a long-lived palette streams rotating
358
+ * async group ids. Ids remain stable while their key is present; a key that
359
+ * leaves and returns simply gets a fresh id.
360
+ */
361
+ pruneDomIds(raws) {
362
+ const groupKeys = new Set(raws.map((raw) => raw.key));
363
+ for (const key of this.groupDomIds.keys()) {
364
+ if (!groupKeys.has(key)) {
365
+ this.groupDomIds.delete(key);
366
+ }
367
+ }
368
+ const commandIds = new Set(raws.flatMap((raw) => raw.items.map((entry) => entry.command.id)));
369
+ for (const key of this.reasonDomIds.keys()) {
370
+ if (!commandIds.has(key)) {
371
+ this.reasonDomIds.delete(key);
372
+ }
373
+ }
374
+ }
214
375
  /** Flat ranked list in render order, for count + command lookup. */
215
376
  flatItems = computed(() => this.groups().flatMap((group) => group.items), { ...(ngDevMode ? { debugName: "flatItems" } : /* istanbul ignore next */ {}), equal: rankedListEqual });
216
377
  /** Number of results across every group. Exposed for the consumer. */
217
378
  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 */ []));
379
+ /**
380
+ * @internal - polite live-region text. The count is the only tracked source; the
381
+ * formatter is read and called untracked, so a language switch never re-speaks
382
+ * the shown count and the next count change speaks the new language.
383
+ */
384
+ countMessage = computed(() => {
385
+ const count = this.resultCount();
386
+ return untracked(() => this.copy().resultCount(count));
387
+ }, ...(ngDevMode ? [{ debugName: "countMessage" }] : /* istanbul ignore next */ []));
388
+ /** The command id the user last saw highlighted; `null` after a term reset. */
389
+ lastHighlightedId = null;
390
+ /** The AD item registry the highlight bookkeeping last saw (identity). */
391
+ lastRegistry = null;
219
392
  constructor() {
220
393
  // Click on an option routes through the listbox's active-descendant, which
221
394
  // emits `activated`; Enter forwards through the same `activateCurrent` path.
222
395
  // One subscription runs the matching command for both. externalActivation
223
396
  // stops the listbox writing its own value on activation.
224
397
  afterNextRender(() => {
225
- const subscription = this.listbox().ad.activated.subscribe((value) => this.runById(value));
226
- this.destroyRef.onDestroy(() => subscription.unsubscribe());
398
+ const lb = this.listbox();
399
+ if (lb) {
400
+ outputToObservable(lb.ad.activated)
401
+ .pipe(takeUntilDestroyed(this.destroyRef))
402
+ .subscribe((value) => this.runById(value));
403
+ }
404
+ });
405
+ // Async groups PREPEND above the static results, and the highlight is
406
+ // index-based - a prepend would silently move it onto a different command.
407
+ // Re-resolve by VALUE whenever the AD item registry changes (the registry,
408
+ // not the data list: options only register during change detection, and
409
+ // the index goes stale exactly when the registry re-orders) so Enter runs
410
+ // the item the user saw; when that item left the result set, reset so
411
+ // autoHighlightFirst re-fires on the fresh list.
412
+ effect(() => {
413
+ const lb = this.listbox();
414
+ if (!lb) {
415
+ return;
416
+ }
417
+ const registry = lb.ad.resolvedItems();
418
+ // Tracked so navigation keeps the bookkeeping current between registry changes.
419
+ const active = lb.ad.activeValue();
420
+ untracked(() => {
421
+ const wanted = this.lastHighlightedId;
422
+ const registryChanged = registry !== this.lastRegistry;
423
+ if (registryChanged && wanted !== null && active !== wanted) {
424
+ if (registry.some((item) => item.value === wanted)) {
425
+ lb.ad.highlightByValue(wanted);
426
+ }
427
+ else {
428
+ lb.ad.resetHighlight();
429
+ }
430
+ }
431
+ this.lastRegistry = registry;
432
+ const current = lb.ad.activeValue();
433
+ this.lastHighlightedId = typeof current === 'string' ? current : null;
434
+ });
435
+ });
436
+ // The palette dialog keeps its content mounted across close, so term and
437
+ // highlight would leak into the next open. Reset when the host closes;
438
+ // clear() feeds searchChange, which routes through onTerm.
439
+ effect(() => {
440
+ const open = this.host?.isOpen() ?? true;
441
+ if (!open) {
442
+ untracked(() => this.search()?.clear());
443
+ }
227
444
  });
228
445
  }
229
446
  onTerm(term, lb) {
230
447
  this.termState.set(term);
231
- this.termChange.emit(term);
232
448
  // Reset the highlight so autoHighlightFirst re-fires the top result after a
233
- // re-rank shrinks the list below the previously active index.
449
+ // re-rank shrinks the list below the previously active index. The value
450
+ // bookkeeping resets too - a new term means the old highlight is void.
451
+ this.lastHighlightedId = null;
234
452
  lb.ad.resetHighlight();
235
453
  }
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
- };
454
+ /** Panel-unique DOM id for a group dedupe key. Stable per key for the panel's lifetime. */
455
+ domGroupId(key) {
456
+ let id = this.groupDomIds.get(key);
457
+ if (!id) {
458
+ id = `${this.listboxId}-g${this.groupDomIds.size}`;
459
+ this.groupDomIds.set(key, id);
460
+ }
461
+ return id;
243
462
  }
244
463
  onKeydown(event, lb) {
464
+ // Never hijack browser/app shortcuts: modified combos pass through
465
+ // untouched - the same guard the nav strategies apply. Without it,
466
+ // Ctrl+ArrowDown in the input would navigate and swallow the event.
467
+ if (event.ctrlKey || event.metaKey || event.altKey) {
468
+ return;
469
+ }
245
470
  const ad = lb.ad;
246
471
  switch (event.key) {
247
472
  case 'ArrowDown':
@@ -274,7 +499,14 @@ class CngxCommandPanel {
274
499
  return command.disabled?.() ?? false;
275
500
  }
276
501
  reasonId(command) {
277
- return `${this.listboxId}-reason-${command.id}`;
502
+ // Minted, never derived from the raw command id - user strings can carry
503
+ // characters that break DOM ids and aria-describedby references.
504
+ let id = this.reasonDomIds.get(command.id);
505
+ if (!id) {
506
+ id = `${this.listboxId}-reason-${this.reasonDomIds.size}`;
507
+ this.reasonDomIds.set(command.id, id);
508
+ }
509
+ return id;
278
510
  }
279
511
  describedBy(command) {
280
512
  return this.isDisabled(command) && command.disabledReason ? this.reasonId(command) : null;
@@ -288,7 +520,7 @@ class CngxCommandPanel {
288
520
  this.host?.dismiss();
289
521
  }
290
522
  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: `
523
+ 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 }, emptyTpl: { classPropertyName: "emptyTpl", publicName: "emptyTpl", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { scope: "scopeChange" }, host: { classAttribute: "cngx-command-panel" }, viewQueries: [{ propertyName: "listbox", first: true, predicate: CngxListbox, descendants: true, isSignal: true }, { propertyName: "search", first: true, predicate: CngxSearch, descendants: true, isSignal: true }], ngImport: i0, template: `
292
524
  <div class="cngx-command-panel-input-row">
293
525
  @if (scope(); as activeScope) {
294
526
  <span class="cngx-command-scope-chip">{{ activeScope }}</span>
@@ -303,8 +535,8 @@ class CngxCommandPanel {
303
535
  [attr.aria-expanded]="true"
304
536
  [attr.aria-controls]="listboxId"
305
537
  [attr.aria-activedescendant]="lb.ad.activeId()"
306
- [attr.aria-label]="config.searchPlaceholder"
307
- [placeholder]="config.searchPlaceholder"
538
+ [attr.aria-label]="copy().searchPlaceholder"
539
+ [placeholder]="copy().searchPlaceholder"
308
540
  [debounceMs]="debounceMs()"
309
541
  (searchChange)="onTerm($event, lb)"
310
542
  (keydown)="onKeydown($event, lb)"
@@ -316,7 +548,7 @@ class CngxCommandPanel {
316
548
  #lb="cngxListbox"
317
549
  [id]="listboxId"
318
550
  class="cngx-command-panel-listbox"
319
- [label]="config.listboxLabel"
551
+ [label]="copy().listboxLabel"
320
552
  [autoHighlightFirst]="true"
321
553
  [externalActivation]="true"
322
554
  >
@@ -327,7 +559,7 @@ class CngxCommandPanel {
327
559
  @if (groupHeaderTpl(); as tpl) {
328
560
  <ng-container
329
561
  [ngTemplateOutlet]="tpl"
330
- [ngTemplateOutletContext]="{ $implicit: toCommandGroup(group) }"
562
+ [ngTemplateOutletContext]="{ $implicit: group.slot }"
331
563
  />
332
564
  } @else {
333
565
  {{ header }}
@@ -370,8 +602,16 @@ class CngxCommandPanel {
370
602
  }
371
603
  </div>
372
604
 
605
+ @if (resultCount() === 0) {
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">{{ copy().emptyLabel }}</div>
610
+ }
611
+ }
612
+
373
613
  <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 });
614
+ `, 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, oklch(.66 .19 50 / .1));color:var(--cngx-command-row-active-color, inherit)}.cngx-command-row.cngx-option--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}@media(forced-colors:active){.cngx-command-row.cngx-option--highlighted{background:Highlight;color:HighlightText;forced-color-adjust:none}.cngx-command-row.cngx-option--highlighted :is(mark,kbd){background:transparent;color:inherit;border-color:currentColor}.cngx-command-row.cngx-option--highlighted mark{text-decoration:underline}.cngx-command-row.cngx-option--disabled{color:GrayText}.cngx-command-row.cngx-option--disabled mark{background:transparent;color:inherit;text-decoration:underline}}.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
615
  }
376
616
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPanel, decorators: [{
377
617
  type: Component,
@@ -390,8 +630,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
390
630
  [attr.aria-expanded]="true"
391
631
  [attr.aria-controls]="listboxId"
392
632
  [attr.aria-activedescendant]="lb.ad.activeId()"
393
- [attr.aria-label]="config.searchPlaceholder"
394
- [placeholder]="config.searchPlaceholder"
633
+ [attr.aria-label]="copy().searchPlaceholder"
634
+ [placeholder]="copy().searchPlaceholder"
395
635
  [debounceMs]="debounceMs()"
396
636
  (searchChange)="onTerm($event, lb)"
397
637
  (keydown)="onKeydown($event, lb)"
@@ -403,7 +643,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
403
643
  #lb="cngxListbox"
404
644
  [id]="listboxId"
405
645
  class="cngx-command-panel-listbox"
406
- [label]="config.listboxLabel"
646
+ [label]="copy().listboxLabel"
407
647
  [autoHighlightFirst]="true"
408
648
  [externalActivation]="true"
409
649
  >
@@ -414,7 +654,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
414
654
  @if (groupHeaderTpl(); as tpl) {
415
655
  <ng-container
416
656
  [ngTemplateOutlet]="tpl"
417
- [ngTemplateOutletContext]="{ $implicit: toCommandGroup(group) }"
657
+ [ngTemplateOutletContext]="{ $implicit: group.slot }"
418
658
  />
419
659
  } @else {
420
660
  {{ header }}
@@ -457,9 +697,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
457
697
  }
458
698
  </div>
459
699
 
700
+ @if (resultCount() === 0) {
701
+ @if (emptyTpl(); as tpl) {
702
+ <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{ term: term() }" />
703
+ } @else {
704
+ <div class="cngx-command-state cngx-command-state--empty">{{ copy().emptyLabel }}</div>
705
+ }
706
+ }
707
+
460
708
  <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 }] }] } });
709
+ `, 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, oklch(.66 .19 50 / .1));color:var(--cngx-command-row-active-color, inherit)}.cngx-command-row.cngx-option--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}@media(forced-colors:active){.cngx-command-row.cngx-option--highlighted{background:Highlight;color:HighlightText;forced-color-adjust:none}.cngx-command-row.cngx-option--highlighted :is(mark,kbd){background:transparent;color:inherit;border-color:currentColor}.cngx-command-row.cngx-option--highlighted mark{text-decoration:underline}.cngx-command-row.cngx-option--disabled{color:GrayText}.cngx-command-row.cngx-option--disabled mark{background:transparent;color:inherit;text-decoration:underline}}.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"] }]
710
+ }], 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 }] }], emptyTpl: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyTpl", required: false }] }], listbox: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxListbox), { isSignal: true }] }], search: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxSearch), { isSignal: true }] }] } });
463
711
  /** @internal Groups ranked results by their `group` key, preserving rank order. */
464
712
  function groupRanked(ranked) {
465
713
  const groups = [];
@@ -470,16 +718,22 @@ function groupRanked(ranked) {
470
718
  if (!bucket) {
471
719
  bucket = [];
472
720
  index.set(key, bucket);
473
- groups.push({ id: `g-${key || 'ungrouped'}`, label: entry.command.group ?? null, items: bucket });
721
+ groups.push({
722
+ key: `s:${key}`,
723
+ slotId: key,
724
+ label: entry.command.group ?? null,
725
+ items: bucket,
726
+ });
474
727
  }
475
728
  bucket.push(entry);
476
729
  }
477
730
  return groups;
478
731
  }
479
- /** @internal Maps consumer async command groups into render groups (score 0). */
480
- function toRenderGroups(source) {
732
+ /** @internal Maps consumer async command groups into raw render groups (score 0). */
733
+ function toRawGroups(source) {
481
734
  return source.map((group) => ({
482
- id: `a-${group.id}`,
735
+ key: `a:${group.id}`,
736
+ slotId: group.id,
483
737
  label: group.label,
484
738
  items: group.commands.map((command) => ({ command, score: 0 })),
485
739
  }));
@@ -511,11 +765,13 @@ function rankedListEqual(a, b) {
511
765
  /**
512
766
  * @internal
513
767
  * Async-state view switch that wraps {@link CngxCommandPanel}. Maps the
514
- * consumer's `CngxAsyncState<CommandGroup[]>` through `resolveAsyncView()` to
768
+ * consumer's `CngxAsyncState<CngxCommandGroup[]>` through `resolveAsyncView()` to
515
769
  * 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.
770
+ * `error` on a first-load failure, and the projected panel for everything
771
+ * else. `content+error` keeps the stale results visible while a re-query on
772
+ * the next keystroke errors. An empty success maps to `content` too: the
773
+ * search input must stay mounted (the user keeps typing to refine the term),
774
+ * so the panel itself renders the empty slot keyed on its own result count.
519
775
  *
520
776
  * Each state resolves its slot template (instance > config > built-in default),
521
777
  * passed down from the palette. With no `[results]` bound (static registry
@@ -524,41 +780,48 @@ function rankedListEqual(a, b) {
524
780
  class CngxCommandPanelShell {
525
781
  /** Consumer-derived async result state driving the view switch. */
526
782
  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
783
  /** Resolved slot templates (instance > config > null). Built-in default when null. */
530
- emptyTpl = input(null, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
531
784
  loadingTpl = input(null, ...(ngDevMode ? [{ debugName: "loadingTpl" }] : /* istanbul ignore next */ []));
532
785
  errorTpl = input(null, ...(ngDevMode ? [{ debugName: "errorTpl" }] : /* istanbul ignore next */ []));
533
786
  /** Fired when the user clicks Retry in the error state. */
534
787
  retry = output();
535
- config = injectCommandPaletteConfig();
788
+ copy = resolveCommandPaletteCopy(injectCommandPaletteConfig());
536
789
  /** The resolved view. `content` when no async source is bound. */
537
790
  view = computed(() => {
538
791
  const state = this.results();
539
792
  if (!state) {
540
793
  return 'content';
541
794
  }
542
- return resolveAsyncView(state.status(), state.isFirstLoad(), state.isEmpty());
795
+ const view = resolveAsyncView(state.status(), state.isFirstLoad(), state.isEmpty());
796
+ // An empty success keeps the panel (and its search input) mounted; the
797
+ // panel renders the empty slot off its own result count instead.
798
+ return view === 'empty' ? 'content' : view;
543
799
  }, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
544
800
  errorValue = computed(() => this.results()?.error(), ...(ngDevMode ? [{ debugName: "errorValue" }] : /* istanbul ignore next */ []));
801
+ /**
802
+ * @internal - copy of the `role="alert"` error regions, keyed on the view. Read
803
+ * untracked, so a language switch never re-speaks a shown error; the next error
804
+ * speaks the new language.
805
+ */
806
+ errorText = computed(() => {
807
+ this.view();
808
+ return untracked(() => this.copy().errorLabel);
809
+ }, ...(ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []));
810
+ /** @internal - retry-button copy inside the error region, keyed like {@link errorText}. */
811
+ retryText = computed(() => {
812
+ this.view();
813
+ return untracked(() => this.copy().retryLabel);
814
+ }, ...(ngDevMode ? [{ debugName: "retryText" }] : /* istanbul ignore next */ []));
545
815
  /** Stable bound callback for the error slot's `retry`. */
546
816
  emitRetry = () => this.retry.emit();
547
817
  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: `
818
+ 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 }, 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
819
  @switch (view()) {
550
820
  @case ('skeleton') {
551
821
  @if (loadingTpl(); as tpl) {
552
822
  <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
553
823
  } @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>
824
+ <div class="cngx-command-state" aria-busy="true">{{ copy().loadingLabel }}</div>
562
825
  }
563
826
  }
564
827
  @case ('error') {
@@ -569,16 +832,16 @@ class CngxCommandPanelShell {
569
832
  />
570
833
  } @else {
571
834
  <div class="cngx-command-state cngx-command-state--error" role="alert">
572
- <span>{{ config.errorLabel }}</span>
835
+ <span>{{ errorText() }}</span>
573
836
  <button type="button" class="cngx-command-retry" (click)="retry.emit()">
574
- {{ config.retryLabel }}
837
+ {{ retryText() }}
575
838
  </button>
576
839
  </div>
577
840
  }
578
841
  }
579
842
  @default {
580
843
  @if (view() === 'content+error') {
581
- <div class="cngx-command-state--error-banner" role="alert">{{ config.errorLabel }}</div>
844
+ <div class="cngx-command-state--error-banner" role="alert">{{ errorText() }}</div>
582
845
  }
583
846
  <ng-content />
584
847
  }
@@ -599,14 +862,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
599
862
  @if (loadingTpl(); as tpl) {
600
863
  <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
601
864
  } @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>
865
+ <div class="cngx-command-state" aria-busy="true">{{ copy().loadingLabel }}</div>
610
866
  }
611
867
  }
612
868
  @case ('error') {
@@ -617,23 +873,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
617
873
  />
618
874
  } @else {
619
875
  <div class="cngx-command-state cngx-command-state--error" role="alert">
620
- <span>{{ config.errorLabel }}</span>
876
+ <span>{{ errorText() }}</span>
621
877
  <button type="button" class="cngx-command-retry" (click)="retry.emit()">
622
- {{ config.retryLabel }}
878
+ {{ retryText() }}
623
879
  </button>
624
880
  </div>
625
881
  }
626
882
  }
627
883
  @default {
628
884
  @if (view() === 'content+error') {
629
- <div class="cngx-command-state--error-banner" role="alert">{{ config.errorLabel }}</div>
885
+ <div class="cngx-command-state--error-banner" role="alert">{{ errorText() }}</div>
630
886
  }
631
887
  <ng-content />
632
888
  }
633
889
  }
634
890
  `,
635
891
  }]
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"] }] } });
892
+ }], propDecorators: { results: [{ type: i0.Input, args: [{ isSignal: true, alias: "results", 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
893
 
638
894
  /**
639
895
  * Overrides the default command row. Project as content of
@@ -767,6 +1023,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
767
1023
  * @since 0.1.0
768
1024
  */
769
1025
  function createPaletteKeybinding(combo, onOpen, isMac = detectMac()) {
1026
+ // SSR: no document, no global listener - an inert handle keeps the
1027
+ // palette's effect/teardown cycle uniform across platforms.
1028
+ if (typeof document === 'undefined') {
1029
+ return { teardown: () => undefined };
1030
+ }
770
1031
  const handler = (event) => {
771
1032
  if (matchesKeyCombo(event, combo, isMac)) {
772
1033
  event.preventDefault();
@@ -824,8 +1085,15 @@ class CngxCommandPalette {
824
1085
  scope = model(undefined, ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
825
1086
  /** Debounce for the search input. */
826
1087
  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 */ []));
1088
+ config = injectCommandPaletteConfig();
1089
+ copy = resolveCommandPaletteCopy(this.config);
1090
+ /**
1091
+ * Accessible name for the dialog. Unbound, `paletteLabel` from
1092
+ * `CNGX_COMMAND_PALETTE_CONFIG` (`withCommandPaletteLabels`) applies.
1093
+ */
1094
+ ariaLabel = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
1095
+ /** @internal */
1096
+ resolvedAriaLabel = computed(() => this.ariaLabel() ?? this.copy().paletteLabel, ...(ngDevMode ? [{ debugName: "resolvedAriaLabel" }] : /* istanbul ignore next */ []));
829
1097
  /**
830
1098
  * Per-instance open combo (parsed via `parseKeyCombo`, e.g. `'mod+shift+p'`).
831
1099
  * Wins over `CNGX_COMMAND_PALETTE_CONFIG.openShortcut` (`withPaletteShortcut`),
@@ -835,9 +1103,6 @@ class CngxCommandPalette {
835
1103
  openShortcut = input(undefined, ...(ngDevMode ? [{ debugName: "openShortcut" }] : /* istanbul ignore next */ []));
836
1104
  /** Fired when the user asks to retry a failed result load. */
837
1105
  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
1106
  // Instance slot directives (content-projected). contentChild must be a direct
842
1107
  // field initializer (AOT NG8110). Each resolves instance > config > null.
843
1108
  rowSlot = contentChild(CngxCommandRow, ...(ngDevMode ? [{ debugName: "rowSlot" }] : /* istanbul ignore next */ []));
@@ -882,12 +1147,10 @@ class CngxCommandPalette {
882
1147
  cngxDialog
883
1148
  #dialog="cngxDialog"
884
1149
  class="cngx-command-palette"
885
- [attr.aria-label]="ariaLabel()"
1150
+ [attr.aria-label]="resolvedAriaLabel()"
886
1151
  >
887
1152
  <cngx-command-panel-shell
888
1153
  [results]="results()"
889
- [term]="term()"
890
- [emptyTpl]="emptyTpl()"
891
1154
  [loadingTpl]="loadingTpl()"
892
1155
  [errorTpl]="errorTpl()"
893
1156
  (retry)="retry.emit()"
@@ -898,20 +1161,26 @@ class CngxCommandPalette {
898
1161
  [debounceMs]="debounceMs()"
899
1162
  [rowTpl]="rowTpl()"
900
1163
  [groupHeaderTpl]="groupHeaderTpl()"
901
- (termChange)="term.set($event)"
1164
+ [emptyTpl]="emptyTpl()"
902
1165
  />
903
1166
  </cngx-command-panel-shell>
904
1167
  <footer class="cngx-command-footer">
905
1168
  @if (footerTpl(); as tpl) {
906
1169
  <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
907
1170
  } @else {
908
- @for (entry of config.footerLegend; track entry.label) {
909
- <span class="cngx-command-legend"><kbd>{{ entry.keys }}</kbd> {{ entry.label }}</span>
1171
+ @for (entry of copy().footerLegend; track entry.label) {
1172
+ <span class="cngx-command-legend">
1173
+ <kbd aria-hidden="true">{{ entry.keys }}</kbd>
1174
+ <span aria-hidden="true">{{ entry.label }}</span>
1175
+ <span class="cngx-sr-only">{{
1176
+ copy().legendEntry(entry.spokenKeys ?? entry.keys, entry.label)
1177
+ }}</span>
1178
+ </span>
910
1179
  }
911
1180
  }
912
1181
  </footer>
913
1182
  </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 });
1183
+ `, 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", "loadingTpl", "errorTpl"], outputs: ["retry"] }, { kind: "component", type: CngxCommandPanel, selector: "cngx-command-panel", inputs: ["results", "scope", "debounceMs", "rowTpl", "groupHeaderTpl", "emptyTpl"], outputs: ["scopeChange"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
915
1184
  }
916
1185
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPalette, decorators: [{
917
1186
  type: Component,
@@ -920,12 +1189,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
920
1189
  cngxDialog
921
1190
  #dialog="cngxDialog"
922
1191
  class="cngx-command-palette"
923
- [attr.aria-label]="ariaLabel()"
1192
+ [attr.aria-label]="resolvedAriaLabel()"
924
1193
  >
925
1194
  <cngx-command-panel-shell
926
1195
  [results]="results()"
927
- [term]="term()"
928
- [emptyTpl]="emptyTpl()"
929
1196
  [loadingTpl]="loadingTpl()"
930
1197
  [errorTpl]="errorTpl()"
931
1198
  (retry)="retry.emit()"
@@ -936,15 +1203,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
936
1203
  [debounceMs]="debounceMs()"
937
1204
  [rowTpl]="rowTpl()"
938
1205
  [groupHeaderTpl]="groupHeaderTpl()"
939
- (termChange)="term.set($event)"
1206
+ [emptyTpl]="emptyTpl()"
940
1207
  />
941
1208
  </cngx-command-panel-shell>
942
1209
  <footer class="cngx-command-footer">
943
1210
  @if (footerTpl(); as tpl) {
944
1211
  <ng-container [ngTemplateOutlet]="tpl" [ngTemplateOutletContext]="{}" />
945
1212
  } @else {
946
- @for (entry of config.footerLegend; track entry.label) {
947
- <span class="cngx-command-legend"><kbd>{{ entry.keys }}</kbd> {{ entry.label }}</span>
1213
+ @for (entry of copy().footerLegend; track entry.label) {
1214
+ <span class="cngx-command-legend">
1215
+ <kbd aria-hidden="true">{{ entry.keys }}</kbd>
1216
+ <span aria-hidden="true">{{ entry.label }}</span>
1217
+ <span class="cngx-sr-only">{{
1218
+ copy().legendEntry(entry.spokenKeys ?? entry.keys, entry.label)
1219
+ }}</span>
1220
+ </span>
948
1221
  }
949
1222
  }
950
1223
  </footer>
@@ -954,9 +1227,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
954
1227
 
955
1228
  /**
956
1229
  * 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.
1230
+ * on click and advertises the popup relationship to assistive tech:
1231
+ * `aria-haspopup="dialog"` plus `aria-expanded` derived from the palette's
1232
+ * `isOpen()` host seam, so the trigger communicates the open state without any
1233
+ * synced local flag. Pass the palette by template reference - orthogonal
1234
+ * composition, no ancestor injection.
960
1235
  *
961
1236
  * ```html
962
1237
  * <button [cngxCommandPaletteTrigger]="palette">
@@ -978,7 +1253,7 @@ class CngxCommandPaletteTrigger {
978
1253
  this.palette().open();
979
1254
  }
980
1255
  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 });
1256
+ 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\"", "attr.aria-expanded": "palette().isOpen()" } }, exportAs: ["cngxCommandPaletteTrigger"], ngImport: i0 });
982
1257
  }
983
1258
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCommandPaletteTrigger, decorators: [{
984
1259
  type: Directive,
@@ -988,6 +1263,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
988
1263
  standalone: true,
989
1264
  host: {
990
1265
  '[attr.aria-haspopup]': '"dialog"',
1266
+ '[attr.aria-expanded]': 'palette().isOpen()',
991
1267
  '(click)': 'open()',
992
1268
  },
993
1269
  }]
@@ -1001,5 +1277,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1001
1277
  * Generated bundle index. Do not edit.
1002
1278
  */
1003
1279
 
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 };
1280
+ export { CNGX_COMMAND_PALETTE_CONFIG, CNGX_COMMAND_PALETTE_HOST, CNGX_COMMAND_PALETTE_LANGUAGE_EN, CNGX_PALETTE_KEYBINDING_FACTORY, CngxCommandGroupHeader, CngxCommandPalette, CngxCommandPaletteEmpty, CngxCommandPaletteError, CngxCommandPaletteFooter, CngxCommandPaletteLoading, CngxCommandPaletteTrigger, CngxCommandRow, createPaletteKeybinding, injectCommandPaletteConfig, provideCommandPaletteConfig, provideCommandPaletteConfigAt, withCommandPaletteLabels, withCommandPaletteTemplates, withKeyboardLegend, withPaletteShortcut, withResultCountFormatter };
1005
1281
  //# sourceMappingURL=cngx-ui-command-palette.mjs.map