@cngx/common 0.1.0-rc.8 → 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 (52) hide show
  1. package/command/README.md +29 -0
  2. package/data/README.md +5 -2
  3. package/fesm2022/cngx-common-a11y.mjs +403 -84
  4. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  5. package/fesm2022/cngx-common-audio.mjs +16 -13
  6. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  7. package/fesm2022/cngx-common-card.mjs +4 -3
  8. package/fesm2022/cngx-common-card.mjs.map +1 -1
  9. package/fesm2022/cngx-common-chart.mjs +55 -36
  10. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  11. package/fesm2022/cngx-common-command.mjs +60 -6
  12. package/fesm2022/cngx-common-command.mjs.map +1 -1
  13. package/fesm2022/cngx-common-data.mjs +185 -37
  14. package/fesm2022/cngx-common-data.mjs.map +1 -1
  15. package/fesm2022/cngx-common-dialog.mjs +86 -48
  16. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  17. package/fesm2022/cngx-common-display.mjs +27 -23
  18. package/fesm2022/cngx-common-display.mjs.map +1 -1
  19. package/fesm2022/cngx-common-interactive.mjs +324 -122
  20. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  21. package/fesm2022/cngx-common-layout.mjs +129 -26
  22. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  23. package/fesm2022/cngx-common-popover.mjs +947 -33
  24. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  25. package/fesm2022/cngx-common-stepper.mjs +300 -166
  26. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  27. package/fesm2022/cngx-common-tabs.mjs +251 -80
  28. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  29. package/fesm2022/cngx-common-timeline.mjs +16 -10
  30. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  31. package/fesm2022/cngx-common.mjs +1 -1
  32. package/layout/README.md +16 -0
  33. package/package.json +20 -7
  34. package/popover/README.md +40 -0
  35. package/schematics/collection.json +9 -0
  36. package/schematics/ng-add/index.js +9 -0
  37. package/schematics/ng-add/schema.json +91 -0
  38. package/schematics/package.json +3 -0
  39. package/stepper/README.md +5 -4
  40. package/theming/components/cngx-popover-sheet.css +402 -0
  41. package/theming/components/cngx-popover.css +10 -6
  42. package/types/cngx-common-a11y.d.ts +167 -14
  43. package/types/cngx-common-chart.d.ts +8 -7
  44. package/types/cngx-common-command.d.ts +19 -2
  45. package/types/cngx-common-data.d.ts +164 -26
  46. package/types/cngx-common-dialog.d.ts +3 -7
  47. package/types/cngx-common-interactive.d.ts +52 -17
  48. package/types/cngx-common-layout.d.ts +37 -5
  49. package/types/cngx-common-popover.d.ts +353 -13
  50. package/types/cngx-common-stepper.d.ts +168 -129
  51. package/types/cngx-common-tabs.d.ts +149 -30
  52. package/types/cngx-common-timeline.d.ts +27 -7
@@ -1,10 +1,10 @@
1
1
  import { isPlatformBrowser, DOCUMENT, NgTemplateOutlet, NgComponentOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, inject, ElementRef, DestroyRef, input, signal, PLATFORM_ID, Renderer2, effect, untracked, computed, Directive, TemplateRef, isDevMode, contentChild, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable, afterNextRender, makeEnvironmentProviders, SkipSelf, Optional, model, booleanAttribute, linkedSignal, contentChildren, Injector, provideEnvironmentInitializer } from '@angular/core';
4
- import { createOverrideMerge, buildAsyncStateView, createMediaQuerySignal, memoize, injectLocale, numberFormatterFor, CNGX_STATEFUL, nextUid, coerceSignal, CNGX_SELECTION_CONTROLLER_FACTORY, matchesKeyCombo, parseKeyCombo, CNGX_LOCALE, createLabelMatcher } from '@cngx/core/utils';
5
- import { isObservable, firstValueFrom, timer, take, fromEvent, filter, switchMap, merge, tap, takeUntil, map } from 'rxjs';
3
+ import { InjectionToken, inject, ElementRef, DestroyRef, input, signal, PLATFORM_ID, Renderer2, effect, untracked, computed, Directive, TemplateRef, contentChild, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable, afterNextRender, makeEnvironmentProviders, SkipSelf, Optional, model, booleanAttribute, linkedSignal, contentChildren, Injector, provideEnvironmentInitializer } from '@angular/core';
4
+ import { createOverrideMerge, buildAsyncStateView, createMediaQuerySignal, memoize, injectLocale, numberFormatterFor, CNGX_STATEFUL, nextUid, coerceSignal, CNGX_SELECTION_CONTROLLER_FACTORY, CNGX_DEV_DESCRIPTORS, matchesKeyCombo, parseKeyCombo, CNGX_LOCALE, createLabelMatcher } from '@cngx/core/utils';
5
+ import { isObservable, firstValueFrom, timer, take, fromEvent, filter, switchMap, merge, tap, takeUntil, map, Subject, EMPTY } from 'rxjs';
6
6
  import { formatMessage, createLanguageSection, createSectionBundle } from '@cngx/core/i18n';
7
- import { decimalPlaces, arrayEqual, setEqual, flattenTree, isNodeVisible, collectDescendantValues, clamp as clamp$1 } from '@cngx/utils';
7
+ import { cngxDevWarn, decimalPlaces, arrayEqual, CngxRuntimeError, setEqual, flattenTree, cngxDevError, isNodeVisible, collectDescendantValues, clamp as clamp$1 } from '@cngx/utils';
8
8
  import { CNGX_FORM_FIELD_HOST, CNGX_FORM_FIELD_CONTROL } from '@cngx/core/tokens';
9
9
  import * as i1 from '@cngx/common/a11y';
10
10
  import { CngxLiveAnnouncer, CngxActiveDescendant, CngxRovingTabindex, CngxRovingItem, CNGX_AD_ITEM } from '@cngx/common/a11y';
@@ -553,8 +553,8 @@ function reflectAsyncDisplayStatus(state) {
553
553
  class CngxAsyncStatus {
554
554
  coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
555
555
  constructor() {
556
- if (isDevMode() && this.coPlacedAsyncClick) {
557
- console.warn('CngxAsyncStatus: [cngxAsyncStatus] and [cngxAsyncClick] on the same element ' +
556
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && this.coPlacedAsyncClick) {
557
+ cngxDevWarn('CNGX1019', '[cngxAsyncStatus] and [cngxAsyncClick] on the same element ' +
558
558
  'both bind aria-busy. Use one or the other.');
559
559
  }
560
560
  }
@@ -2330,6 +2330,10 @@ function injectMenuConfig() {
2330
2330
  function injectMenuItemCore(options) {
2331
2331
  const elementRef = inject((ElementRef));
2332
2332
  const ad = inject(CngxActiveDescendant, { optional: true });
2333
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !ad) {
2334
+ cngxDevWarn('CNGX1058', 'injectMenuItemCore(): the menu item has no surrounding [cngxMenu], so a click does ' +
2335
+ 'nothing. Place the item inside an element with [cngxMenu].');
2336
+ }
2333
2337
  const announcer = inject(CNGX_MENU_ANNOUNCER_FACTORY)();
2334
2338
  const ariaLabels = coerceSignal(injectMenuConfig().ariaLabels);
2335
2339
  const id = nextUid('cngx-menu-item');
@@ -2896,6 +2900,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2896
2900
  * @relatedTo CngxRangeSlider, CngxSliderThumb
2897
2901
  */
2898
2902
  const CNGX_SLIDER_RANGE = new InjectionToken('CNGX_SLIDER_RANGE');
2903
+ /**
2904
+ * Inject the {@link CNGX_SLIDER_RANGE} of the surrounding range track from a
2905
+ * {@link CngxSliderThumb}. Throws a `CngxRuntimeError` with code `CNGX1062`
2906
+ * when no range track is above it, in development and production alike.
2907
+ *
2908
+ * @internal
2909
+ */
2910
+ function injectSliderRange() {
2911
+ const range = inject(CNGX_SLIDER_RANGE, { optional: true });
2912
+ if (!range) {
2913
+ throw new CngxRuntimeError('CNGX1062', typeof ngDevMode !== 'undefined' &&
2914
+ ngDevMode &&
2915
+ '[cngxSliderThumb] must be placed inside an element with [cngxRangeSliderTrack], such as <cngx-range-slider>.');
2916
+ }
2917
+ return range;
2918
+ }
2899
2919
 
2900
2920
  /**
2901
2921
  * Headless dual-thumb (range) slider brain. Put `cngxRangeSliderTrack` on your
@@ -3070,7 +3090,7 @@ function createThumbValue(range, position) {
3070
3090
  class CngxSliderThumb {
3071
3091
  /** Which end of the range this thumb drives. Bound from the selector. */
3072
3092
  position = input.required({ ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), alias: 'cngxSliderThumb' });
3073
- range = inject(CNGX_SLIDER_RANGE);
3093
+ range = injectSliderRange();
3074
3094
  el = inject((ElementRef)).nativeElement;
3075
3095
  locale = injectLocale();
3076
3096
  /** Sibling-clamped bounds for this thumb, selected reactively by position. */
@@ -3431,6 +3451,23 @@ function createAccordionKeyboardNav(opts) {
3431
3451
  * @relatedTo CngxAccordion, CngxAccordionPanel
3432
3452
  */
3433
3453
  const CNGX_ACCORDION = new InjectionToken('CNGX_ACCORDION');
3454
+ /**
3455
+ * Inject the {@link CNGX_ACCORDION} of the surrounding accordion from a
3456
+ * {@link CngxAccordionPanel}. Throws a `CngxRuntimeError` with code
3457
+ * `CNGX1060` when no accordion is above it, in development and production
3458
+ * alike.
3459
+ *
3460
+ * @internal
3461
+ */
3462
+ function injectAccordionHost() {
3463
+ const accordion = inject(CNGX_ACCORDION, { optional: true });
3464
+ if (!accordion) {
3465
+ throw new CngxRuntimeError('CNGX1060', typeof ngDevMode !== 'undefined' &&
3466
+ ngDevMode &&
3467
+ '[cngxAccordionPanel] must be placed inside an element with [cngxAccordion], such as <cngx-accordion-group>.');
3468
+ }
3469
+ return accordion;
3470
+ }
3434
3471
 
3435
3472
  /**
3436
3473
  * Coordinating directive for an accordion. Put `cngxAccordion` on the
@@ -3596,7 +3633,7 @@ class CngxAccordionPanel {
3596
3633
  * by the organism, not this brain directive.
3597
3634
  */
3598
3635
  disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
3599
- accordion = inject(CNGX_ACCORDION);
3636
+ accordion = injectAccordionHost();
3600
3637
  element = inject(ElementRef).nativeElement;
3601
3638
  destroyRef = inject(DestroyRef);
3602
3639
  // Set once in ngOnInit. A signal (not a plain field) so the tabindex computed
@@ -3664,6 +3701,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3664
3701
  * @relatedTo CngxBreadcrumb, CngxBreadcrumbItem
3665
3702
  */
3666
3703
  const CNGX_BREADCRUMB = new InjectionToken('CNGX_BREADCRUMB');
3704
+ /**
3705
+ * Inject the {@link CNGX_BREADCRUMB} of the surrounding breadcrumb from a
3706
+ * {@link CngxBreadcrumbItem}. Throws a `CngxRuntimeError` with code
3707
+ * `CNGX1061` when no breadcrumb is above it, in development and production
3708
+ * alike.
3709
+ *
3710
+ * @internal
3711
+ */
3712
+ function injectBreadcrumbHost() {
3713
+ const breadcrumb = inject(CNGX_BREADCRUMB, { optional: true });
3714
+ if (!breadcrumb) {
3715
+ throw new CngxRuntimeError('CNGX1061', typeof ngDevMode !== 'undefined' &&
3716
+ ngDevMode &&
3717
+ '[cngxBreadcrumbItem] must be placed inside an element with [cngxBreadcrumb].');
3718
+ }
3719
+ return breadcrumb;
3720
+ }
3667
3721
 
3668
3722
  /**
3669
3723
  * A single crumb. Put `cngxBreadcrumbItem` on the crumb element. Intermediate
@@ -3680,7 +3734,7 @@ const CNGX_BREADCRUMB = new InjectionToken('CNGX_BREADCRUMB');
3680
3734
  * <example-url>http://localhost:4200/#/common/interactive/breadcrumb/basic-trail</example-url>
3681
3735
  */
3682
3736
  class CngxBreadcrumbItem {
3683
- breadcrumb = inject(CNGX_BREADCRUMB);
3737
+ breadcrumb = injectBreadcrumbHost();
3684
3738
  host = inject(ElementRef);
3685
3739
  /**
3686
3740
  * Explicit accessible label for the overflow menu, when the crumb's rendered
@@ -4890,8 +4944,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4890
4944
  * `CNGX_BUTTON_MULTI_TOGGLE_GROUP` (multi, toolbar) - never the
4891
4945
  * concrete group class - both with `{ optional: true }`.
4892
4946
  *
4893
- * Exactly one parent must be present; the constructor throws when both or
4894
- * neither resolve. The resolved parent is stored as a discriminated
4947
+ * Exactly one parent must be present; the constructor throws a
4948
+ * `CngxRuntimeError` when both (`CNGX1052`) or neither (`CNGX1053`) resolve. The resolved parent is stored as a discriminated
4895
4949
  * union (`{ mode: 'single' | 'multi'; group }`) so every downstream
4896
4950
  * branch narrows without non-null assertions.
4897
4951
  *
@@ -5040,10 +5094,11 @@ function resolveParent() {
5040
5094
  optional: true,
5041
5095
  });
5042
5096
  if (single && multi) {
5043
- throw new Error('CngxButtonToggle: both CngxButtonToggleGroup and ' +
5044
- 'CngxButtonMultiToggleGroup parents are present in the injector ' +
5045
- 'tree. Exactly one is required - single + multi semantics are ' +
5046
- 'incompatible.');
5097
+ throw new CngxRuntimeError('CNGX1052', typeof ngDevMode !== 'undefined' &&
5098
+ ngDevMode &&
5099
+ '[cngxButtonToggle] both a single and a multi toggle group are present in the ' +
5100
+ 'injector tree. Exactly one is required - single + multi semantics are ' +
5101
+ 'incompatible.');
5047
5102
  }
5048
5103
  if (single) {
5049
5104
  return { mode: 'single', group: single };
@@ -5051,8 +5106,10 @@ function resolveParent() {
5051
5106
  if (multi) {
5052
5107
  return { mode: 'multi', group: multi };
5053
5108
  }
5054
- throw new Error('CngxButtonToggle requires a parent CngxButtonToggleGroup or ' +
5055
- 'CngxButtonMultiToggleGroup to provide the value contract.');
5109
+ throw new CngxRuntimeError('CNGX1053', typeof ngDevMode !== 'undefined' &&
5110
+ ngDevMode &&
5111
+ '[cngxButtonToggle] must be placed inside <cngx-button-toggle-group> or ' +
5112
+ '<cngx-button-multi-toggle-group>.');
5056
5113
  }
5057
5114
 
5058
5115
  /**
@@ -5395,10 +5452,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
5395
5452
  * DI token a `CngxChipInGroup` leaf injects to find its parent chip
5396
5453
  * group. Always provided via
5397
5454
  * `{ provide: CNGX_CHIP_GROUP_HOST, useExisting: <Self> }` - never
5398
- * via concrete-class injection. Required (NOT optional) on the leaf
5399
- * side: a leaf without a parent throws `NullInjectorError` at
5400
- * construction (fail-fast - silent dual-source-of-truth would be
5401
- * worse).
5455
+ * via concrete-class injection. Required on the leaf side: a leaf
5456
+ * without a parent throws `CNGX1068` at construction (fail-fast -
5457
+ * silent dual-source-of-truth would be worse).
5402
5458
  *
5403
5459
  * Standalone chips outside any group use `[cngxChipInteraction]`
5404
5460
  * instead, which provides `CNGX_CONTROL_VALUE` directly without ever
@@ -5410,6 +5466,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
5410
5466
  * @since 0.1.0
5411
5467
  */
5412
5468
  const CNGX_CHIP_GROUP_HOST = new InjectionToken('CngxChipGroupHost');
5469
+ /**
5470
+ * Inject the {@link CNGX_CHIP_GROUP_HOST} of the surrounding chip group
5471
+ * from a `CngxChipInGroup` leaf, resolved with `host: true`. Throws a
5472
+ * `CngxRuntimeError` with code `CNGX1068` when no group is above it, in
5473
+ * development and production alike.
5474
+ *
5475
+ * @internal
5476
+ */
5477
+ function injectChipGroupHost() {
5478
+ const host = inject(CNGX_CHIP_GROUP_HOST, { host: true, optional: true });
5479
+ if (!host) {
5480
+ throw new CngxRuntimeError('CNGX1068', typeof ngDevMode !== 'undefined' &&
5481
+ ngDevMode &&
5482
+ '[cngxChipInGroup] must be placed inside <cngx-chip-group> or <cngx-multi-chip-group>.');
5483
+ }
5484
+ return host;
5485
+ }
5413
5486
 
5414
5487
  /**
5415
5488
  * Standalone interactive chip - applies onto `<cngx-chip>` from
@@ -5602,7 +5675,7 @@ class CngxChipInteraction {
5602
5675
  }
5603
5676
  });
5604
5677
  });
5605
- if (!isDevMode()) {
5678
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
5606
5679
  return;
5607
5680
  }
5608
5681
  const ancestor = inject(CNGX_CHIP_GROUP_HOST, {
@@ -5611,7 +5684,7 @@ class CngxChipInteraction {
5611
5684
  });
5612
5685
  afterNextRender(() => {
5613
5686
  if (ancestor !== null) {
5614
- throw new Error('CngxChipInteraction must NOT be used inside <cngx-chip-group> / <cngx-multi-chip-group>; use [cngxChipInGroup] instead.');
5687
+ throw new CngxRuntimeError('CNGX1044', '[cngxChipInteraction] must not be used inside <cngx-chip-group> / <cngx-multi-chip-group>; use [cngxChipInGroup] instead.');
5615
5688
  }
5616
5689
  });
5617
5690
  }
@@ -5693,7 +5766,7 @@ function isCloseButtonClick$1(event) {
5693
5766
  * `@cngx/common/display` and wires `role="option"` semantics that
5694
5767
  * defer all selection mutations to the surrounding chip-group via
5695
5768
  * `CNGX_CHIP_GROUP_HOST`. Required parent (NOT optional): a
5696
- * `[cngxChipInGroup]` outside any group throws `NullInjectorError`
5769
+ * `[cngxChipInGroup]` outside any group throws `CNGX1068`
5697
5770
  * at construction. Standalone interactive chips use
5698
5771
  * `[cngxChipInteraction]` instead.
5699
5772
  *
@@ -5765,7 +5838,7 @@ function isCloseButtonClick$1(event) {
5765
5838
  * <example-url>http://localhost:4200/#/forms/field/form-primitives/signal-forms-drop-the-atom-into-cngx-form-field</example-url>
5766
5839
  */
5767
5840
  class CngxChipInGroup {
5768
- parent = inject(CNGX_CHIP_GROUP_HOST, { host: true });
5841
+ parent = injectChipGroupHost();
5769
5842
  value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
5770
5843
  disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
5771
5844
  describedBy = input(null, { ...(ngDevMode ? { debugName: "describedBy" } : /* istanbul ignore next */ {}), alias: 'cngxDescribedBy' });
@@ -6541,7 +6614,21 @@ const CNGX_TREE_CONTROLLER_FACTORY = new InjectionToken('CngxTreeControllerFacto
6541
6614
  *
6542
6615
  * @internal
6543
6616
  */
6544
- const POST_DESTROY_FALSE = signal(false).asReadonly();
6617
+ const POST_DESTROY_FALSE = signal(false, typeof ngDevMode !== 'undefined' && ngDevMode
6618
+ ? { debugName: 'treeController.destroyed' }
6619
+ : undefined).asReadonly();
6620
+ /**
6621
+ * `String(key)` for the CNGX1030 report, or the `[object X]` tag when the key
6622
+ * cannot be converted (a null-prototype object has no `toString`).
6623
+ */
6624
+ function describeKey(key) {
6625
+ try {
6626
+ return String(key);
6627
+ }
6628
+ catch {
6629
+ return Object.prototype.toString.call(key);
6630
+ }
6631
+ }
6545
6632
  /** @internal */
6546
6633
  function flatEq(a, b) {
6547
6634
  if (a === b) {
@@ -6583,9 +6670,11 @@ function createTreeController(opts) {
6583
6670
  const resolvedNodeIdFn = opts.nodeIdFn ??
6584
6671
  config.defaultNodeIdFn;
6585
6672
  if (!resolvedNodeIdFn) {
6586
- throw new Error('createTreeController: `nodeIdFn` is required. Provide it via ' +
6587
- 'CngxTreeControllerOptions.nodeIdFn or app-wide through ' +
6588
- '`provideTreeConfig(withDefaultNodeIdFn(...))`.');
6673
+ throw new CngxRuntimeError('CNGX1051', typeof ngDevMode !== 'undefined' &&
6674
+ ngDevMode &&
6675
+ 'createTreeController(): `nodeIdFn` is required. Provide it via ' +
6676
+ 'CngxTreeControllerOptions.nodeIdFn or app-wide through ' +
6677
+ '`provideTreeConfig(withDefaultNodeIdFn(...))`.');
6589
6678
  }
6590
6679
  const resolvedLabelFn = opts.labelFn ?? config.defaultLabelFn;
6591
6680
  const resolvedKeyFn = opts.keyFn ??
@@ -6608,19 +6697,19 @@ function createTreeController(opts) {
6608
6697
  const byValue = new Map();
6609
6698
  const firstChildById = new Map();
6610
6699
  for (const n of flatNodes()) {
6611
- if (isDevMode()) {
6700
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
6612
6701
  // A colliding id/key silently shadows the earlier node in every
6613
6702
  // O(1) lookup (expansion, selection, focus) - surface the
6614
6703
  // authoring error instead of dropping nodes.
6615
6704
  if (byId.has(n.id) && !reportedDuplicates.has(`id:${n.id}`)) {
6616
6705
  reportedDuplicates.add(`id:${n.id}`);
6617
- console.error(`createTreeController: duplicate node id "${n.id}" from nodeIdFn - ` +
6706
+ cngxDevError('CNGX1029', `createTreeController(): duplicate node id "${n.id}" from nodeIdFn - ` +
6618
6707
  'the earlier node is shadowed in id lookups. Ids must be unique.');
6619
6708
  }
6620
6709
  const key = keyFn(n.value);
6621
- if (byValue.has(key) && !reportedDuplicates.has(`key:${String(key)}`)) {
6622
- reportedDuplicates.add(`key:${String(key)}`);
6623
- console.error(`createTreeController: duplicate selection key "${String(key)}" from keyFn - ` +
6710
+ if (byValue.has(key) && !reportedDuplicates.has(`key:${describeKey(key)}`)) {
6711
+ reportedDuplicates.add(`key:${describeKey(key)}`);
6712
+ cngxDevError('CNGX1030', `createTreeController(): duplicate selection key "${describeKey(key)}" from keyFn - ` +
6624
6713
  'the earlier node is shadowed in selection lookups. Keys must be unique.');
6625
6714
  }
6626
6715
  }
@@ -6686,7 +6775,9 @@ function createTreeController(opts) {
6686
6775
  }
6687
6776
  let sig = expandedCache.get(id);
6688
6777
  if (!sig) {
6689
- sig = computed(() => expandedIds().has(id));
6778
+ sig = computed(() => expandedIds().has(id), typeof ngDevMode !== 'undefined' && ngDevMode
6779
+ ? { debugName: 'treeController.isExpanded' }
6780
+ : undefined);
6690
6781
  expandedCache.set(id, sig);
6691
6782
  evictOldestIfOverLimit();
6692
6783
  }
@@ -6800,7 +6891,7 @@ function createTreeController(opts) {
6800
6891
  destroyed = true;
6801
6892
  expandedCache.clear();
6802
6893
  };
6803
- return {
6894
+ const controller = {
6804
6895
  flatNodes,
6805
6896
  visibleNodes,
6806
6897
  expandedIds,
@@ -6819,6 +6910,14 @@ function createTreeController(opts) {
6819
6910
  firstChildOf,
6820
6911
  destroy,
6821
6912
  };
6913
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
6914
+ CNGX_DEV_DESCRIPTORS.tag(controller, {
6915
+ kind: 'cngx-dev:factory',
6916
+ factory: 'createTreeController',
6917
+ inputs: { opts },
6918
+ });
6919
+ }
6920
+ return controller;
6822
6921
  }
6823
6922
 
6824
6923
  /** @internal */
@@ -7728,6 +7827,52 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
7728
7827
  }]
7729
7828
  }], ctorParameters: () => [], propDecorators: { direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxSwipeDismiss", required: true }] }], threshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "threshold", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], swiped: [{ type: i0.Output, args: ["swiped"] }] } });
7730
7829
 
7830
+ /**
7831
+ * The item's `data-reorder-index` as a non-negative integer, or `-1`. The
7832
+ * gesture handlers and the CNGX1028 check read indexes the same way.
7833
+ */
7834
+ function parseReorderIndex(el) {
7835
+ const raw = el.dataset['reorderIndex'];
7836
+ if (raw == null) {
7837
+ return -1;
7838
+ }
7839
+ const n = Number.parseInt(raw, 10);
7840
+ if (!Number.isFinite(n) || n < 0) {
7841
+ return -1;
7842
+ }
7843
+ return n;
7844
+ }
7845
+ /**
7846
+ * Dev only: after the first render, warns when elements match
7847
+ * `itemSelector` but carry no valid `data-reorder-index`. Registers its
7848
+ * own `afterNextRender`, so call it in the injection context. A module
7849
+ * function, not a method: a class keeps its methods in the bundle, and an
7850
+ * emptied method still pulls `cngxDevWarn` into the production build.
7851
+ */
7852
+ function wireDevModeCheck(hostEl, itemSelector) {
7853
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
7854
+ return;
7855
+ }
7856
+ afterNextRender(() => {
7857
+ const items = hostEl.querySelectorAll(itemSelector());
7858
+ if (items.length === 0) {
7859
+ // Not an error - an empty strip is a legitimate idle state.
7860
+ // Only warn when the consumer probably forgot to wire the attr.
7861
+ return;
7862
+ }
7863
+ let misconfigured = 0;
7864
+ items.forEach((el) => {
7865
+ if (parseReorderIndex(el) < 0) {
7866
+ misconfigured += 1;
7867
+ }
7868
+ });
7869
+ if (misconfigured > 0) {
7870
+ cngxDevWarn('CNGX1028', `[cngxReorder] ${misconfigured} element(s) match itemSelector ` +
7871
+ `"${itemSelector()}" but carry no non-negative integer data-reorder-index. ` +
7872
+ 'Pointer / keyboard moves targeting them will be ignored.');
7873
+ }
7874
+ });
7875
+ }
7731
7876
  /**
7732
7877
  * Level-2 atom that turns any flat container into a reorderable list.
7733
7878
  *
@@ -7855,7 +8000,9 @@ class CngxReorder {
7855
8000
  constructor() {
7856
8001
  this.wirePointer();
7857
8002
  this.wireKeyboard();
7858
- this.wireDevModeCheck();
8003
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
8004
+ wireDevModeCheck(this.hostEl, this.itemSelector);
8005
+ }
7859
8006
  this.destroyRef.onDestroy(() => {
7860
8007
  for (const cleanup of [...this.pendingSuppressorCleanups]) {
7861
8008
  cleanup();
@@ -7886,7 +8033,7 @@ class CngxReorder {
7886
8033
  if (!itemEl || !this.hostEl.contains(itemEl)) {
7887
8034
  return null;
7888
8035
  }
7889
- const fromIndex = this.parseIndex(itemEl);
8036
+ const fromIndex = parseReorderIndex(itemEl);
7890
8037
  if (fromIndex < 0) {
7891
8038
  return null;
7892
8039
  }
@@ -7914,7 +8061,7 @@ class CngxReorder {
7914
8061
  if (!itemEl || !this.hostEl.contains(itemEl)) {
7915
8062
  return;
7916
8063
  }
7917
- const overIndex = this.parseIndex(itemEl);
8064
+ const overIndex = parseReorderIndex(itemEl);
7918
8065
  if (overIndex < 0) {
7919
8066
  return;
7920
8067
  }
@@ -7961,7 +8108,7 @@ class CngxReorder {
7961
8108
  if (!itemEl || !this.hostEl.contains(itemEl)) {
7962
8109
  return;
7963
8110
  }
7964
- const fromIndex = this.parseIndex(itemEl);
8111
+ const fromIndex = parseReorderIndex(itemEl);
7965
8112
  if (fromIndex < 0) {
7966
8113
  return;
7967
8114
  }
@@ -8005,42 +8152,6 @@ class CngxReorder {
8005
8152
  }), takeUntilDestroyed())
8006
8153
  .subscribe();
8007
8154
  }
8008
- wireDevModeCheck() {
8009
- if (!isDevMode()) {
8010
- return;
8011
- }
8012
- afterNextRender(() => {
8013
- const items = this.hostEl.querySelectorAll(this.itemSelector());
8014
- if (items.length === 0) {
8015
- // Not an error - an empty strip is a legitimate idle state.
8016
- // Only warn when the consumer probably forgot to wire the attr.
8017
- return;
8018
- }
8019
- let misconfigured = 0;
8020
- items.forEach((el) => {
8021
- const idx = el.dataset['reorderIndex'];
8022
- if (idx == null || !Number.isFinite(Number(idx))) {
8023
- misconfigured += 1;
8024
- }
8025
- });
8026
- if (misconfigured > 0) {
8027
- console.warn(`[CngxReorder] ${misconfigured} element(s) match itemSelector ` +
8028
- `"${this.itemSelector()}" but carry no numeric data-reorder-index. ` +
8029
- 'Pointer / keyboard moves targeting them will be ignored.');
8030
- }
8031
- });
8032
- }
8033
- parseIndex(el) {
8034
- const raw = el.dataset['reorderIndex'];
8035
- if (raw == null) {
8036
- return -1;
8037
- }
8038
- const n = Number.parseInt(raw, 10);
8039
- if (!Number.isFinite(n) || n < 0) {
8040
- return -1;
8041
- }
8042
- return n;
8043
- }
8044
8155
  modifierMatches(event) {
8045
8156
  switch (this.keyboardModifier()) {
8046
8157
  case 'ctrl':
@@ -8399,9 +8510,12 @@ class CngxSearch {
8399
8510
  el = inject((ElementRef));
8400
8511
  renderer = inject(Renderer2);
8401
8512
  destroyRef = inject(DestroyRef);
8513
+ /** `clear()` notifier: switches the pipeline away from a pending debounce. */
8514
+ cleared = new Subject();
8402
8515
  constructor() {
8403
- fromEvent(this.el.nativeElement, 'input')
8404
- .pipe(map((e) => e.target.value), switchMap((value) => timer(this.debounceMs()).pipe(map(() => value))), takeUntilDestroyed(this.destroyRef))
8516
+ const typed = fromEvent(this.el.nativeElement, 'input').pipe(map((e) => e.target.value));
8517
+ merge(typed, this.cleared.pipe(map(() => null)))
8518
+ .pipe(switchMap((value) => value === null ? EMPTY : timer(this.debounceMs()).pipe(map(() => value))), takeUntilDestroyed(this.destroyRef))
8405
8519
  .subscribe((term) => {
8406
8520
  this.termState.set(term);
8407
8521
  this.searchChange.emit(term);
@@ -8409,6 +8523,7 @@ class CngxSearch {
8409
8523
  }
8410
8524
  /** Clears the search term and resets the input element value. */
8411
8525
  clear() {
8526
+ this.cleared.next();
8412
8527
  this.termState.set('');
8413
8528
  this.renderer.setProperty(this.el.nativeElement, 'value', '');
8414
8529
  this.searchChange.emit('');
@@ -9030,6 +9145,13 @@ const CNGX_OPTION_STATUS_HOST = new InjectionToken('CNGX_OPTION_STATUS_HOST');
9030
9145
  * Click highlights + activates, `pointerenter` highlights only. Provides a stable
9031
9146
  * unique id on the host element for `aria-activedescendant` resolution.
9032
9147
  *
9148
+ * An option never takes DOM focus. A mouse press keeps focus where it is: on
9149
+ * the external owner (a select trigger, a combobox or search input), or on the
9150
+ * enclosing `role="listbox"` when that listbox is its own tab stop
9151
+ * (`tabindex="0"`), which the press focuses if focus is elsewhere. Focusable
9152
+ * content inside an option, or a `tabindex` placed on the option itself, does
9153
+ * not receive focus from a click.
9154
+ *
9033
9155
  * Selection state (`isSelected`) is driven externally by the enclosing listbox.
9034
9156
  * In V1 of the stack, `CngxListbox` reads `value()` via the AD item list and
9035
9157
  * exposes its own selection through `CngxOption.isSelected()`.
@@ -9152,8 +9274,8 @@ class CngxOption {
9152
9274
  afterNextRender(() => {
9153
9275
  const el = this.elementRef.nativeElement;
9154
9276
  this.textContentSnapshot.set((el.textContent ?? '').trim());
9155
- if (isDevMode() && !this.label()) {
9156
- console.error(`<cngx-option> at ${this.id} has no label and no textContent. ` +
9277
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !this.label()) {
9278
+ cngxDevError('CNGX1023', `[cngxOption] option ${this.id} has no label and no textContent. ` +
9157
9279
  `Label is required for AT and trigger display.`);
9158
9280
  }
9159
9281
  });
@@ -9174,6 +9296,20 @@ class CngxOption {
9174
9296
  }
9175
9297
  this.interactionHost?.activate(this.value());
9176
9298
  }
9299
+ // The focus default of mousedown would pull focus off the owner (a select
9300
+ // trigger, a search input) and the owner reads that blur as "left the field".
9301
+ // A listbox that is its own tab stop still gets the focus the click gave it.
9302
+ handleMouseDown(event) {
9303
+ event.preventDefault();
9304
+ const host = this.elementRef.nativeElement;
9305
+ const listbox = host.closest('[role="listbox"]');
9306
+ if (!listbox?.hasAttribute('tabindex') || listbox.tabIndex < 0) {
9307
+ return;
9308
+ }
9309
+ if (!listbox.contains(host.ownerDocument.activeElement)) {
9310
+ listbox.focus();
9311
+ }
9312
+ }
9177
9313
  handlePointerEnter() {
9178
9314
  if (this.disabled()) {
9179
9315
  return;
@@ -9185,7 +9321,7 @@ class CngxOption {
9185
9321
  this.interactionHost?.highlight(this.value());
9186
9322
  }
9187
9323
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxOption, deps: [], target: i0.ɵɵFactoryTarget.Directive });
9188
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxOption, isStandalone: true, selector: "[cngxOption]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, labelInput: { classPropertyName: "labelInput", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "handleClick()", "pointerenter": "handlePointerEnter()" }, properties: { "id": "id", "class.cngx-option--selected": "isSelected()", "class.cngx-option--highlighted": "isHighlighted()", "class.cngx-option--disabled": "disabled()", "attr.aria-selected": "isSelected()", "attr.aria-disabled": "disabled() || null", "attr.data-status": "statusSignal()?.kind ?? null", "class.cngx-option--hidden": "hidden()", "attr.hidden": "hidden() || null" } }, providers: [
9324
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxOption, isStandalone: true, selector: "[cngxOption]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, labelInput: { classPropertyName: "labelInput", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "mousedown": "handleMouseDown($event)", "click": "handleClick()", "pointerenter": "handlePointerEnter()" }, properties: { "id": "id", "class.cngx-option--selected": "isSelected()", "class.cngx-option--highlighted": "isHighlighted()", "class.cngx-option--disabled": "disabled()", "attr.aria-selected": "isSelected()", "attr.aria-disabled": "disabled() || null", "attr.data-status": "statusSignal()?.kind ?? null", "class.cngx-option--hidden": "hidden()", "attr.hidden": "hidden() || null" } }, providers: [
9189
9325
  { provide: CNGX_AD_ITEM, useExisting: CngxOption },
9190
9326
  { provide: CNGX_OPTION_CONTAINER, useExisting: CngxOption },
9191
9327
  ], exportAs: ["cngxOption"], ngImport: i0 });
@@ -9211,6 +9347,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
9211
9347
  '[attr.data-status]': 'statusSignal()?.kind ?? null',
9212
9348
  '[class.cngx-option--hidden]': 'hidden()',
9213
9349
  '[attr.hidden]': 'hidden() || null',
9350
+ '(mousedown)': 'handleMouseDown($event)',
9214
9351
  '(click)': 'handleClick()',
9215
9352
  '(pointerenter)': 'handlePointerEnter()',
9216
9353
  },
@@ -9251,12 +9388,14 @@ class CngxOptionGroup {
9251
9388
  */
9252
9389
  options = computed(() => this.optionsQuery(), { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), equal: (a, b) => a.length === b.length && a.every((v, i) => v === b[i]) });
9253
9390
  constructor() {
9254
- afterNextRender(() => {
9255
- if (isDevMode() && this.nestedGroupsQuery().length > 0) {
9256
- console.error('[cngxOptionGroup] Nested option groups are unsupported. ' +
9257
- 'Use CngxTreeSelect for arbitrary tree shapes.');
9258
- }
9259
- });
9391
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
9392
+ afterNextRender(() => {
9393
+ if (this.nestedGroupsQuery().length > 0) {
9394
+ cngxDevError('CNGX1022', '[cngxOptionGroup] Nested option groups are unsupported. ' +
9395
+ 'Use CngxTreeSelect for arbitrary tree shapes.');
9396
+ }
9397
+ });
9398
+ }
9260
9399
  }
9261
9400
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxOptionGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
9262
9401
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxOptionGroup, isStandalone: true, selector: "[cngxOptionGroup]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "attr.aria-label": "label()" } }, providers: [{ provide: CNGX_OPTION_CONTAINER, useExisting: CngxOptionGroup }], queries: [{ propertyName: "optionsQuery", predicate: CngxOption, isSignal: true }, { propertyName: "nestedGroupsQuery", predicate: CngxOptionGroup, descendants: true, isSignal: true }], exportAs: ["cngxOptionGroup"], ngImport: i0 });
@@ -9535,7 +9674,7 @@ class CngxListbox {
9535
9674
  }
9536
9675
  }
9537
9676
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListbox, deps: [], target: i0.ɵɵFactoryTarget.Directive });
9538
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxListbox, isStandalone: true, selector: "[cngxListbox]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null }, cngxSearchRef: { classPropertyName: "cngxSearchRef", publicName: "cngxSearchRef", isSignal: true, isRequired: false, transformFunction: null }, externalActivation: { classPropertyName: "externalActivation", publicName: "externalActivation", isSignal: true, isRequired: false, transformFunction: null }, explicitOptions: { classPropertyName: "explicitOptions", publicName: "explicitOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", selectedValues: "selectedValuesChange" }, host: { attributes: { "role": "listbox" }, properties: { "attr.aria-label": "label()", "attr.aria-multiselectable": "multiple() ? \"true\" : null" } }, queries: [{ propertyName: "contentOptions", predicate: CngxOption, descendants: true, isSignal: true }], exportAs: ["cngxListbox"], hostDirectives: [{ directive: i1.CngxActiveDescendant, inputs: ["items", "items", "orientation", "orientation", "loop", "loop", "typeahead", "typeahead", "autoHighlightFirst", "autoHighlightFirst", "virtualCount", "virtualCount", "windowStart", "windowStart"], outputs: ["activated", "activated"] }], ngImport: i0 });
9677
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxListbox, isStandalone: true, selector: "[cngxListbox]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null }, cngxSearchRef: { classPropertyName: "cngxSearchRef", publicName: "cngxSearchRef", isSignal: true, isRequired: false, transformFunction: null }, externalActivation: { classPropertyName: "externalActivation", publicName: "externalActivation", isSignal: true, isRequired: false, transformFunction: null }, explicitOptions: { classPropertyName: "explicitOptions", publicName: "explicitOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", selectedValues: "selectedValuesChange" }, host: { attributes: { "role": "listbox" }, properties: { "attr.aria-label": "label()", "attr.aria-multiselectable": "multiple() ? \"true\" : null" } }, queries: [{ propertyName: "contentOptions", predicate: CngxOption, descendants: true, isSignal: true }], exportAs: ["cngxListbox"], hostDirectives: [{ directive: i1.CngxActiveDescendant, inputs: ["items", "items", "orientation", "orientation", "loop", "loop", "typeahead", "typeahead", "autoHighlightFirst", "autoHighlightFirst", "virtualCount", "virtualCount", "windowStart", "windowStart", "compareWith", "compareWith"], outputs: ["activated", "activated"] }], ngImport: i0 });
9539
9678
  }
9540
9679
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListbox, decorators: [{
9541
9680
  type: Directive,
@@ -9554,6 +9693,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
9554
9693
  'autoHighlightFirst',
9555
9694
  'virtualCount',
9556
9695
  'windowStart',
9696
+ // Same name as the listbox input: one binding feeds selection matching
9697
+ // and the AD's value lookup after an items change.
9698
+ 'compareWith',
9557
9699
  ],
9558
9700
  // `activated` fires on EVERY pick (click / Enter / Space), including a
9559
9701
  // re-pick of the already-selected value - unlike `valueChange`, which
@@ -9665,6 +9807,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
9665
9807
  * | open | Enter / Space | activate; close if `closeOnSelect()` |
9666
9808
  * | any | Escape | close and restore focus to trigger |
9667
9809
  *
9810
+ * On an `<input>` host with a co-located `CngxListboxSearch` (a combobox),
9811
+ * Space, Home and End are text-editing keys: they reach the input, open or
9812
+ * closed. Enter still activates and the arrows still navigate.
9813
+ *
9814
+ * Keys from an interactive descendant of the host (a chip remove button)
9815
+ * are left to that element.
9816
+ *
9817
+ * Pair it with `CngxPopoverTrigger` on the same element: that directive is
9818
+ * the one writer of `aria-haspopup`, `aria-expanded` and `aria-controls`.
9819
+ * This trigger writes none of them.
9820
+ *
9821
+ * The trigger keeps DOM focus, so it carries `aria-activedescendant`: the
9822
+ * listbox's active option id while the popover is open, no attribute while
9823
+ * closed (ARIA 1.2 combobox). It is the only writer of the attribute on
9824
+ * the trigger host; the listbox keeps its own for focus-in-listbox setups.
9825
+ *
9668
9826
  * @category common/interactive/listbox
9669
9827
  * @docsKind primary
9670
9828
  * @wcag AA
@@ -9680,8 +9838,10 @@ class CngxListboxTrigger {
9680
9838
  popover = input.required(...(ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []));
9681
9839
  /** Whether activating an option closes the popover. */
9682
9840
  closeOnSelect = input(true, ...(ngDevMode ? [{ debugName: "closeOnSelect" }] : /* istanbul ignore next */ []));
9683
- /** Mirrors `CngxPopover.isVisible()` for host binding and external read. */
9841
+ /** Mirrors `CngxPopover.isVisible()` for external read. */
9684
9842
  isOpen = computed(() => this.popover().isVisible(), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
9843
+ /** Active option id while open, `null` while closed. */
9844
+ activeDescendant = computed(() => this.isOpen() ? this.listbox().ad.activeId() : null, ...(ngDevMode ? [{ debugName: "activeDescendant" }] : /* istanbul ignore next */ []));
9685
9845
  /**
9686
9846
  * Fires when the user presses Backspace on an empty input. Only
9687
9847
  * emitted when the host element is an `<input>` with a co-located
@@ -9712,6 +9872,15 @@ class CngxListboxTrigger {
9712
9872
  if (event.ctrlKey || event.metaKey || event.altKey) {
9713
9873
  return;
9714
9874
  }
9875
+ // Keys from an interactive descendant (a chip remove button, a clear
9876
+ // button) belong to that element. No preventDefault, so Enter / Space
9877
+ // still run the native button activation instead of opening the panel.
9878
+ const host = this.el.nativeElement;
9879
+ const target = event.target;
9880
+ const interactive = target?.closest('button, a[href], input, [role="button"]');
9881
+ if (interactive && interactive !== host && host.contains(interactive)) {
9882
+ return;
9883
+ }
9715
9884
  const key = event.key;
9716
9885
  const ad = this.listbox().ad;
9717
9886
  // Tag-input convention: Backspace on an empty co-located search input
@@ -9719,13 +9888,19 @@ class CngxListboxTrigger {
9719
9888
  // to delete the trailing chip. Consolidated here so the trigger owns
9720
9889
  // the only keydown handler on the element. Non-input triggers skip
9721
9890
  // this path via the co-located-search guard.
9722
- if (key === 'Backspace' && this.search) {
9723
- const host = this.el.nativeElement;
9891
+ // A held key repeats: only the first press may strip a chip.
9892
+ if (key === 'Backspace' && this.search && !event.repeat) {
9724
9893
  if (host instanceof HTMLInputElement && host.value === '') {
9725
9894
  this.backspaceOnEmpty.emit();
9726
9895
  // No preventDefault - the consumer's chip-remove path owns DOM impact.
9727
9896
  }
9728
9897
  }
9898
+ // A combobox input keeps its text-editing keys: Space types a space,
9899
+ // Home / End move the caret.
9900
+ const editingKey = this.search !== null && (key === ' ' || key === 'Home' || key === 'End');
9901
+ if (editingKey) {
9902
+ return;
9903
+ }
9729
9904
  if (!this.isOpen()) {
9730
9905
  if (key === 'ArrowDown' || key === 'Enter' || key === ' ') {
9731
9906
  event.preventDefault();
@@ -9743,6 +9918,9 @@ class CngxListboxTrigger {
9743
9918
  }
9744
9919
  switch (key) {
9745
9920
  case 'Escape':
9921
+ if (this.popover().closeOnEscape?.() === false) {
9922
+ return;
9923
+ }
9746
9924
  event.preventDefault();
9747
9925
  this.popover().hide();
9748
9926
  return;
@@ -9786,7 +9964,7 @@ class CngxListboxTrigger {
9786
9964
  }
9787
9965
  }
9788
9966
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListboxTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
9789
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxListboxTrigger, isStandalone: true, selector: "[cngxListboxTrigger]", inputs: { listbox: { classPropertyName: "listbox", publicName: "cngxListboxTrigger", isSignal: true, isRequired: true, transformFunction: null }, popover: { classPropertyName: "popover", publicName: "popover", isSignal: true, isRequired: true, transformFunction: null }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { backspaceOnEmpty: "backspaceOnEmpty" }, host: { listeners: { "keydown": "handleKeydown($event)" }, properties: { "attr.aria-haspopup": "\"listbox\"", "attr.aria-expanded": "isOpen()" } }, exportAs: ["cngxListboxTrigger"], ngImport: i0 });
9967
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxListboxTrigger, isStandalone: true, selector: "[cngxListboxTrigger]", inputs: { listbox: { classPropertyName: "listbox", publicName: "cngxListboxTrigger", isSignal: true, isRequired: true, transformFunction: null }, popover: { classPropertyName: "popover", publicName: "popover", isSignal: true, isRequired: true, transformFunction: null }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { backspaceOnEmpty: "backspaceOnEmpty" }, host: { listeners: { "keydown": "handleKeydown($event)" }, properties: { "attr.aria-activedescendant": "activeDescendant()" } }, exportAs: ["cngxListboxTrigger"], ngImport: i0 });
9790
9968
  }
9791
9969
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListboxTrigger, decorators: [{
9792
9970
  type: Directive,
@@ -9795,8 +9973,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
9795
9973
  exportAs: 'cngxListboxTrigger',
9796
9974
  standalone: true,
9797
9975
  host: {
9798
- '[attr.aria-haspopup]': '"listbox"',
9799
- '[attr.aria-expanded]': 'isOpen()',
9976
+ '[attr.aria-activedescendant]': 'activeDescendant()',
9800
9977
  '(keydown)': 'handleKeydown($event)',
9801
9978
  },
9802
9979
  }]
@@ -9892,9 +10069,13 @@ class CngxMenu {
9892
10069
  */
9893
10070
  focus() {
9894
10071
  const el = this.elementRef.nativeElement;
9895
- if (isDevMode() && el.tabIndex < 0 && !warnedFocusHosts.has(el)) {
10072
+ if (typeof ngDevMode !== 'undefined' &&
10073
+ ngDevMode &&
10074
+ el.tabIndex < 0 &&
10075
+ !warnedFocusHosts.has(el)) {
9896
10076
  warnedFocusHosts.add(el);
9897
- console.warn('CngxMenu.focus(): host element has tabindex < 0; focus() will silently no-op. ' +
10077
+ cngxDevWarn('CNGX1027', '[cngxMenu] focus(): host element has tabindex < 0; with tabindex="-1" focus() still lands ' +
10078
+ 'but the menu drops out of the Tab sequence, without a tabindex focus() does nothing. ' +
9898
10079
  'Add tabindex="0" to the cngxMenu host so the menu container receives keyboard focus.');
9899
10080
  }
9900
10081
  el.focus({ preventScroll: true });
@@ -10297,20 +10478,23 @@ class CngxMenuItemSubmenu {
10297
10478
  popoverEl.removeEventListener('pointerleave', onLeave);
10298
10479
  });
10299
10480
  });
10300
- if (isDevMode()) {
10481
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
10301
10482
  afterNextRender(() => {
10302
10483
  if (this.menuItem === null) {
10303
- console.warn('[cngxMenuItemSubmenu] applied without a sibling [cngxMenuItem] on the same host element. ' +
10484
+ cngxDevWarn('CNGX1024', '[cngxMenuItemSubmenu] applied without a sibling [cngxMenuItem] on the same host element. ' +
10304
10485
  'The surrounding CngxMenuTrigger cannot route ArrowRight / activation to this submenu ' +
10305
10486
  'because CngxActiveDescendant only highlights CngxMenuItem nodes. ' +
10306
10487
  'Add [cngxMenuItem] alongside [cngxMenuItemSubmenu] on the same element.');
10307
10488
  }
10308
10489
  if (!this.wired() && !this.wiring) {
10309
- console.warn('[cngxMenuItemSubmenu] has no popover/menu source. Bind [cngxMenuItemSubmenu] and ' +
10490
+ cngxDevWarn('CNGX1025', '[cngxMenuItemSubmenu] has no popover/menu source. Bind [cngxMenuItemSubmenu] and ' +
10310
10491
  '[submenuMenu], or provide CNGX_MENU_SUBMENU_WIRING from a wrapping component. ' +
10311
10492
  'The brain stays inert (no aria-haspopup / aria-expanded) until one is present.');
10312
10493
  }
10313
- const popover = this.resolvedPopover();
10494
+ // Only a popover bound through the input is the consumer's to configure.
10495
+ // A CNGX_MENU_SUBMENU_WIRING provider owns the placement policy and
10496
+ // installs its fallbacks when it opens the submenu.
10497
+ const popover = this.popover();
10314
10498
  if (popover) {
10315
10499
  warnMissingSubmenuFallbacks(popover.elementRef.nativeElement);
10316
10500
  }
@@ -10376,20 +10560,28 @@ function __resetSubmenuFallbackWarnings(doc) {
10376
10560
  }
10377
10561
  /** @internal */
10378
10562
  function warnMissingSubmenuFallbacks(popoverEl) {
10563
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
10564
+ return;
10565
+ }
10379
10566
  const doc = popoverEl.ownerDocument;
10380
10567
  if (submenuFallbackWarnedDocs.has(doc)) {
10381
10568
  return;
10382
10569
  }
10570
+ // A browser without the property reports '' whatever is bound, and flips nothing anyway.
10571
+ if (typeof CSS === 'undefined' || !CSS.supports?.('position-try-fallbacks', 'flip-block')) {
10572
+ return;
10573
+ }
10383
10574
  const resolved = getComputedStyle(popoverEl).getPropertyValue('position-try-fallbacks').trim();
10384
- if (resolved !== '') {
10575
+ if (resolved !== '' && resolved !== 'none') {
10385
10576
  return;
10386
10577
  }
10387
10578
  submenuFallbackWarnedDocs.add(doc);
10388
- console.warn('CngxMenuItemSubmenu: the companion popover ships without [positionTryFallbacks]. ' +
10579
+ cngxDevWarn('CNGX1026', '[cngxMenuItemSubmenu] the companion popover ships without [positionTryFallbacks]. ' +
10389
10580
  'Submenus that clip the viewport edge will not flip without a try-fallback chain. ' +
10390
- 'Wire the recommended default:\n\n' +
10391
- " import { CNGX_SUBMENU_TRY_FALLBACKS } from '@cngx/common/interactive';\n\n" +
10392
- ' <div cngxPopover [positionTryFallbacks]="CNGX_SUBMENU_TRY_FALLBACKS">\n' +
10581
+ 'Expose the recommended default as a component field and bind it:\n\n' +
10582
+ " import { CNGX_SUBMENU_TRY_FALLBACKS } from '@cngx/common/interactive';\n" +
10583
+ ' protected readonly submenuFallbacks = CNGX_SUBMENU_TRY_FALLBACKS;\n\n' +
10584
+ ' <div cngxPopover [positionTryFallbacks]="submenuFallbacks">\n' +
10393
10585
  ' <!-- submenu items -->\n' +
10394
10586
  ' </div>\n');
10395
10587
  }
@@ -10397,9 +10589,13 @@ function warnMissingSubmenuFallbacks(popoverEl) {
10397
10589
  /**
10398
10590
  * Recommended `position-try-fallbacks` chain for menu submenu popovers.
10399
10591
  *
10400
- * Consumers wire the const on the submenu's `cngxPopover` element:
10592
+ * A template cannot read a module constant, so expose it as a component
10593
+ * field and bind that field on the submenu's `cngxPopover` element:
10594
+ * ```ts
10595
+ * protected readonly submenuFallbacks = CNGX_SUBMENU_TRY_FALLBACKS;
10596
+ * ```
10401
10597
  * ```html
10402
- * <div cngxPopover [positionTryFallbacks]="CNGX_SUBMENU_TRY_FALLBACKS">
10598
+ * <div cngxPopover [positionTryFallbacks]="submenuFallbacks">
10403
10599
  * <!-- submenu items -->
10404
10600
  * </div>
10405
10601
  * ```
@@ -10534,23 +10730,17 @@ class CngxMenuItemRadio {
10534
10730
  value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
10535
10731
  disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
10536
10732
  labelInput = input(undefined, { ...(ngDevMode ? { debugName: "labelInput" } : /* istanbul ignore next */ {}), alias: 'label' });
10537
- group = inject(CNGX_MENU_RADIO_GROUP, { optional: true });
10733
+ group = injectMenuRadioGroup();
10538
10734
  core = injectMenuItemCore({
10539
10735
  value: this.value,
10540
10736
  disabled: this.disabled,
10541
10737
  labelInput: this.labelInput,
10542
- onActivate: () => this.group?.select(this.value()),
10738
+ onActivate: () => this.group.select(this.value()),
10543
10739
  });
10544
10740
  id = this.core.id;
10545
10741
  isHighlighted = this.core.isHighlighted;
10546
10742
  /** Whether this radio is the currently selected value in its group. */
10547
- checked = computed(() => {
10548
- const group = this.group;
10549
- if (!group) {
10550
- return false;
10551
- }
10552
- return Object.is(group.selectedValue(), this.value());
10553
- }, ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
10743
+ checked = computed(() => Object.is(this.group.selectedValue(), this.value()), ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
10554
10744
  label = () => this.core.label();
10555
10745
  handleClick() {
10556
10746
  this.core.handleClick();
@@ -10582,6 +10772,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
10582
10772
  },
10583
10773
  }]
10584
10774
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], labelInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
10775
+ function injectMenuRadioGroup() {
10776
+ const group = inject(CNGX_MENU_RADIO_GROUP, { optional: true });
10777
+ if (!group) {
10778
+ throw new CngxRuntimeError('CNGX1057', typeof ngDevMode !== 'undefined' &&
10779
+ ngDevMode &&
10780
+ '[cngxMenuItemRadio] must be placed inside an element with [cngxMenuGroup].');
10781
+ }
10782
+ return group;
10783
+ }
10585
10784
 
10586
10785
  /**
10587
10786
  * Logical grouping for menu items. Renders `role="group"` with an accessible
@@ -11995,8 +12194,8 @@ class CngxErrorRegistry {
11995
12194
  if (current.get(name) === scope) {
11996
12195
  return;
11997
12196
  }
11998
- if (isDevMode() && current.has(name)) {
11999
- console.warn(`CngxErrorRegistry: a scope named "${name}" is already registered. ` +
12197
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && current.has(name)) {
12198
+ cngxDevWarn('CNGX1021', `registerScope(): a scope named "${name}" is already registered. ` +
12000
12199
  'The existing instance stays live (swap-is-noop); unregister it first for a true swap.');
12001
12200
  }
12002
12201
  const next = new Map(current);
@@ -12037,8 +12236,8 @@ class CngxErrorRegistry {
12037
12236
  if (current.get(name) === aggregator) {
12038
12237
  return;
12039
12238
  }
12040
- if (isDevMode() && current.has(name)) {
12041
- console.warn(`CngxErrorRegistry: an aggregator named "${name}" is already registered. ` +
12239
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && current.has(name)) {
12240
+ cngxDevWarn('CNGX1021', `registerAggregator(): an aggregator named "${name}" is already registered. ` +
12042
12241
  'The existing instance stays live (swap-is-noop); unregister it first for a true swap.');
12043
12242
  }
12044
12243
  const next = new Map(current);
@@ -12348,8 +12547,11 @@ function createErrorAggregatorContract(deps) {
12348
12547
  announcement,
12349
12548
  addSource(entry) {
12350
12549
  const current = sourcesState();
12351
- if (isDevMode() && current.has(entry.key) && current.get(entry.key) !== entry) {
12352
- console.warn(`CngxErrorAggregator: an error source with key "${entry.key}" is already ` +
12550
+ if (typeof ngDevMode !== 'undefined' &&
12551
+ ngDevMode &&
12552
+ current.has(entry.key) &&
12553
+ current.get(entry.key) !== entry) {
12554
+ cngxDevWarn('CNGX1020', `addSource(): an error source with key "${entry.key}" is already ` +
12353
12555
  'registered; the new entry replaces it (last-wins). Use unique keys per source.');
12354
12556
  }
12355
12557
  const next = new Map(current);