@cngx/ui 0.1.0-rc.9 → 0.3.0

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 (106) hide show
  1. package/README.md +118 -59
  2. package/action-button/README.md +170 -53
  3. package/breadcrumb/README.md +5 -6
  4. package/collection/README.md +1 -1
  5. package/command-palette/README.md +4 -3
  6. package/data-grid-accordion/README.md +1 -1
  7. package/empty-state/README.md +2 -3
  8. package/feedback/README.md +1 -1
  9. package/fesm2022/cngx-ui-a11y.mjs +13 -23
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +44 -66
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +213 -335
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +60 -80
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +18 -31
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +28 -44
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +29 -51
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +78 -83
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +52 -74
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +17 -44
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +589 -467
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-layout.mjs +17 -13
  32. package/fesm2022/cngx-ui-layout.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-accordion.mjs +3 -5
  34. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-paginator.mjs +5 -9
  36. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-stepper.mjs +6 -9
  38. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-mat-tabs.mjs +71 -68
  40. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-nav-rail.mjs +440 -0
  42. package/fesm2022/cngx-ui-nav-rail.mjs.map +1 -0
  43. package/fesm2022/cngx-ui-overlay.mjs +9 -10
  44. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-paginator.mjs +149 -171
  46. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-sidenav.mjs +858 -721
  48. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-skeleton.mjs +17 -19
  50. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-speak.mjs +21 -74
  52. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-stat-card.mjs +39 -62
  54. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-stepper.mjs +207 -90
  56. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-tabs.mjs +71 -32
  58. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  59. package/fesm2022/cngx-ui-timeline.mjs +21 -27
  60. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  61. package/fesm2022/cngx-ui-toc.mjs +27 -40
  62. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  63. package/fesm2022/cngx-ui.mjs +5 -5
  64. package/fesm2022/cngx-ui.mjs.map +1 -1
  65. package/mat-tabs/README.md +28 -14
  66. package/mat-tabs/styles/mat-tabs.css +233 -258
  67. package/nav-rail/README.md +325 -0
  68. package/package.json +10 -5
  69. package/paginator/README.md +10 -0
  70. package/schematics/ng-add/index.js +7 -7
  71. package/schematics/ng-add/schema.json +5 -0
  72. package/sidenav/README.md +150 -55
  73. package/skeleton/README.md +1 -1
  74. package/speak/README.md +1 -2
  75. package/stepper/README.md +20 -5
  76. package/tabs/README.md +13 -0
  77. package/timeline/README.md +1 -1
  78. package/toc/README.md +1 -1
  79. package/types/cngx-ui-a11y.d.ts +20 -38
  80. package/types/cngx-ui-accordion.d.ts +45 -77
  81. package/types/cngx-ui-action-button.d.ts +113 -151
  82. package/types/cngx-ui-breadcrumb.d.ts +58 -94
  83. package/types/cngx-ui-chart-panel.d.ts +22 -40
  84. package/types/cngx-ui-collection.d.ts +30 -53
  85. package/types/cngx-ui-command-palette.d.ts +40 -64
  86. package/types/cngx-ui-context-menu.d.ts +67 -44
  87. package/types/cngx-ui-data-grid-accordion.d.ts +49 -77
  88. package/types/cngx-ui-empty-state.d.ts +18 -8
  89. package/types/cngx-ui-feedback.d.ts +264 -289
  90. package/types/cngx-ui-layout.d.ts +4 -12
  91. package/types/cngx-ui-mat-accordion.d.ts +2 -3
  92. package/types/cngx-ui-mat-paginator.d.ts +4 -10
  93. package/types/cngx-ui-mat-stepper.d.ts +5 -10
  94. package/types/cngx-ui-mat-tabs.d.ts +43 -69
  95. package/types/cngx-ui-nav-rail.d.ts +416 -0
  96. package/types/cngx-ui-overlay.d.ts +4 -13
  97. package/types/cngx-ui-paginator.d.ts +164 -154
  98. package/types/cngx-ui-sidenav.d.ts +557 -437
  99. package/types/cngx-ui-skeleton.d.ts +7 -13
  100. package/types/cngx-ui-speak.d.ts +40 -24
  101. package/types/cngx-ui-stat-card.d.ts +45 -36
  102. package/types/cngx-ui-stepper.d.ts +183 -62
  103. package/types/cngx-ui-tabs.d.ts +101 -27
  104. package/types/cngx-ui-timeline.d.ts +20 -48
  105. package/types/cngx-ui-toc.d.ts +30 -51
  106. package/types/cngx-ui.d.ts +1 -1
@@ -13,6 +13,12 @@ const GAP_DEFAULTS = {
13
13
  lg: 'var(--cngx-gap-lg, var(--cngx-space-lg, 24px))',
14
14
  xl: 'var(--cngx-gap-xl, var(--cngx-space-xl, 32px))',
15
15
  };
16
+ const ALIGN_ITEMS = {
17
+ start: 'flex-start',
18
+ center: 'center',
19
+ end: 'flex-end',
20
+ stretch: 'stretch',
21
+ };
16
22
  /**
17
23
  * Composable flex-based stack layout component.
18
24
  *
@@ -26,11 +32,10 @@ const GAP_DEFAULTS = {
26
32
  * <div>Item 2</div>
27
33
  * </cngx-stack>
28
34
  *
29
- * @category ui/layout
30
- * @docsKind primary
31
35
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/stack.component.ts
32
- * @since 0.1.0
36
+ * @since 0.3.0
33
37
  * @relatedTo CngxGrid
38
+ * @axis level organism
34
39
  */
35
40
  class CngxStack {
36
41
  /** Flex direction of the stack. */
@@ -40,20 +45,20 @@ class CngxStack {
40
45
  /** Cross-axis alignment of stack items. */
41
46
  align = input('stretch', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
42
47
  /** @internal */
43
- alignItems = computed(() => {
44
- const alignValue = this.align();
45
- return alignValue === 'stretch' ? 'stretch' : `flex-${alignValue}`;
46
- }, ...(ngDevMode ? [{ debugName: "alignItems" }] : /* istanbul ignore next */ []));
48
+ alignItems = computed(() => ALIGN_ITEMS[this.align()], ...(ngDevMode ? [{ debugName: "alignItems" }] : /* istanbul ignore next */ []));
47
49
  /** @internal */
48
50
  gapValue = computed(() => GAP_DEFAULTS[this.gap()], ...(ngDevMode ? [{ debugName: "gapValue" }] : /* istanbul ignore next */ []));
49
51
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStack, deps: [], target: i0.ɵɵFactoryTarget.Component });
50
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxStack, isStandalone: true, selector: "cngx-stack", inputs: { direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.flex-direction": "direction()", "style.align-items": "alignItems()", "style.gap": "gapValue()" } }, ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host{display:flex}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
52
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxStack, isStandalone: true, selector: "cngx-stack", inputs: { direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.flex-direction": "direction()", "style.align-items": "alignItems()", "attr.align": "null", "style.gap": "gapValue()" } }, ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host{display:flex}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
51
53
  }
52
54
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStack, decorators: [{
53
55
  type: Component,
54
56
  args: [{ selector: 'cngx-stack', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content />', host: {
55
57
  '[style.flex-direction]': 'direction()',
56
58
  '[style.align-items]': 'alignItems()',
59
+ // A static align attribute would trigger the browser's legacy
60
+ // presentational hint (text-align) on the host; the input already took it.
61
+ '[attr.align]': 'null',
57
62
  '[style.gap]': 'gapValue()',
58
63
  }, styles: [":host{display:flex}\n"] }]
59
64
  }], propDecorators: { direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }], gap: [{ type: i0.Input, args: [{ isSignal: true, alias: "gap", required: false }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }] } });
@@ -72,11 +77,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
72
77
  * Bare attribute syntax works for both forms: `columns="3"` and
73
78
  * `[columns]="3"` produce identical output.
74
79
  *
75
- * @category ui/layout
76
- * @docsKind primary
77
80
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/grid.component.ts
78
- * @since 0.1.0
81
+ * @since 0.3.0
79
82
  * @relatedTo CngxStack
83
+ * @axis level organism
80
84
  */
81
85
  class CngxGrid {
82
86
  /** Number of equal columns, or a custom `grid-template-columns` value. */
@@ -113,8 +117,8 @@ function coerceColumns(value) {
113
117
  }
114
118
 
115
119
  /**
116
- * Public API Surface of @cngx/ui/layout
117
- * @module @cngx/ui/layout
120
+ * Public API Surface of `@cngx/ui/layout`
121
+ * @module `@cngx/ui/layout`
118
122
  */
119
123
 
120
124
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cngx-ui-layout.mjs","sources":["../../../projects/ui/layout/stack.component.ts","../../../projects/ui/layout/grid.component.ts","../../../projects/ui/layout/public-api.ts","../../../projects/ui/layout/cngx-ui-layout.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\n/**\n * Main-axis direction for {@link CngxStack}.\n *\n * @category ui/layout\n */\nexport type StackDirection = 'row' | 'column';\n/**\n * Cross-axis alignment for {@link CngxStack}.\n *\n * @category ui/layout\n */\nexport type StackAlign = 'start' | 'center' | 'end' | 'stretch';\n/**\n * Spacing scale for {@link CngxStack}. Maps to `--cngx-gap-*` tokens.\n *\n * @category ui/layout\n */\nexport type StackGap = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n// Chain per rung: consumer override hook (--cngx-gap-*, set nowhere by the\n// library) -> density scale (--cngx-space-*, registered inherits: true, so a\n// root [data-density] swap rescales the stack) -> literal for token-less\n// environments.\nconst GAP_DEFAULTS: Record<StackGap, string> = {\n none: '0',\n xs: 'var(--cngx-gap-xs, var(--cngx-space-xs, 4px))',\n sm: 'var(--cngx-gap-sm, var(--cngx-space-sm, 8px))',\n md: 'var(--cngx-gap-md, var(--cngx-space-md, 16px))',\n lg: 'var(--cngx-gap-lg, var(--cngx-space-lg, 24px))',\n xl: 'var(--cngx-gap-xl, var(--cngx-space-xl, 32px))',\n};\n\n/**\n * Composable flex-based stack layout component.\n *\n * Gap tokens use CSS custom properties (`--cngx-gap-xs` through `--cngx-gap-xl`)\n * that fall back to the density scale (`--cngx-space-*`), so a root\n * `[data-density]` swap rescales the stack. Override the `--cngx-gap-*`\n * hooks at any scope to detach a stack from the scale.\n *\n * <cngx-stack direction=\"row\" gap=\"md\" align=\"center\">\n * <div>Item 1</div>\n * <div>Item 2</div>\n * </cngx-stack>\n *\n * @category ui/layout\n * @docsKind primary\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/stack.component.ts\n * @since 0.1.0\n * @relatedTo CngxGrid\n */\n@Component({\n selector: 'cngx-stack',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: '<ng-content />',\n styles: [\n `\n :host {\n display: flex;\n }\n `,\n ],\n host: {\n '[style.flex-direction]': 'direction()',\n '[style.align-items]': 'alignItems()',\n '[style.gap]': 'gapValue()',\n },\n})\nexport class CngxStack {\n /** Flex direction of the stack. */\n readonly direction = input<StackDirection>('column');\n /** Named spacing token between stack items. Resolves via `--cngx-gap-*` CSS custom properties. */\n readonly gap = input<StackGap>('md');\n /** Cross-axis alignment of stack items. */\n readonly align = input<StackAlign>('stretch');\n\n /** @internal */\n protected readonly alignItems = computed(() => {\n const alignValue = this.align();\n return alignValue === 'stretch' ? 'stretch' : `flex-${alignValue}`;\n });\n\n /** @internal */\n protected readonly gapValue = computed(() => GAP_DEFAULTS[this.gap()]);\n}\n","import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\n/**\n * Composable CSS grid layout component.\n ``` html\n <cngx-grid columns=\"3\" gap=\"16px\">\n <div>Cell 1</div>\n <div>Cell 2</div>\n </cngx-grid>\n ```\n * `columns` accepts either a positive integer for the\n * `repeat(N, 1fr)` shortcut or any `grid-template-columns` value\n * (`\"200px 1fr\"`, `\"repeat(auto-fit, minmax(120px, 1fr))\"`).\n * Bare attribute syntax works for both forms: `columns=\"3\"` and\n * `[columns]=\"3\"` produce identical output.\n *\n * @category ui/layout\n * @docsKind primary\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/grid.component.ts\n * @since 0.1.0\n * @relatedTo CngxStack\n */\n@Component({\n selector: 'cngx-grid',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: '<ng-content />',\n styles: [\n `\n :host {\n display: grid;\n }\n `,\n ],\n host: {\n '[style.grid-template-columns]': 'gridTemplateColumns()',\n '[style.gap]': 'gap()',\n },\n})\nexport class CngxGrid {\n /** Number of equal columns, or a custom `grid-template-columns` value. */\n readonly columns = input<number | string, number | string>(1, {\n transform: coerceColumns,\n });\n /**\n * CSS gap between cells. The default reads the `--cngx-gap-md` override\n * hook and falls back to the density scale (`--cngx-space-md`), so a root\n * `[data-density]` swap rescales the grid; any CSS gap value is accepted.\n */\n readonly gap = input('var(--cngx-gap-md, var(--cngx-space-md, 16px))');\n\n /** @internal */\n protected readonly gridTemplateColumns = computed(() => {\n const cols = this.columns();\n return typeof cols === 'number' ? `repeat(${cols}, 1fr)` : cols;\n });\n}\n\n// Bare integer attribute (`columns=\"3\"`) coerces to a number so the\n// `repeat(N, 1fr)` branch fires; anything else is a track-list string\n// (`\"200px 1fr\"`) and passes through to `grid-template-columns`.\nfunction coerceColumns(value: number | string): number | string {\n if (typeof value === 'number') {\n return value;\n }\n return /^\\d+$/.test(value) ? Number(value) : value;\n}\n","/**\n * Public API Surface of @cngx/ui/layout\n * @module @cngx/ui/layout\n */\n\nexport * from './stack.component';\nexport * from './grid.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAqBA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAA6B;AAC7C,IAAA,IAAI,EAAE,GAAG;AACT,IAAA,EAAE,EAAE,+CAA+C;AACnD,IAAA,EAAE,EAAE,+CAA+C;AACnD,IAAA,EAAE,EAAE,gDAAgD;AACpD,IAAA,EAAE,EAAE,gDAAgD;AACpD,IAAA,EAAE,EAAE,gDAAgD;CACrD;AAED;;;;;;;;;;;;;;;;;;AAkBG;MAmBU,SAAS,CAAA;;AAEX,IAAA,SAAS,GAAG,KAAK,CAAiB,QAAQ,gFAAC;;AAE3C,IAAA,GAAG,GAAG,KAAK,CAAW,IAAI,0EAAC;;AAE3B,IAAA,KAAK,GAAG,KAAK,CAAa,SAAS,4EAAC;;AAG1B,IAAA,UAAU,GAAG,QAAQ,CAAC,MAAK;AAC5C,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,EAAE;AAC/B,QAAA,OAAO,UAAU,KAAK,SAAS,GAAG,SAAS,GAAG,CAAA,KAAA,EAAQ,UAAU,EAAE;AACpE,IAAA,CAAC,iFAAC;;AAGiB,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,+EAAC;uGAf3D,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAT,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,SAAS,ikBAdV,gBAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,uBAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAA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T,IAAI,EAAA,eAAA,EACC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EACrC,gBAAgB,EAAA,IAAA,EAQpB;AACJ,wBAAA,+BAA+B,EAAE,uBAAuB;AACxD,wBAAA,aAAa,EAAE,OAAO;AACvB,qBAAA,EAAA,MAAA,EAAA,CAAA,uBAAA,CAAA,EAAA;;AAqBH;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAsB,EAAA;AAC3C,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK;AACpD;;AClEA;;;AAGG;;ACHH;;AAEG;;;;"}
1
+ {"version":3,"file":"cngx-ui-layout.mjs","sources":["../../../projects/ui/layout/stack.component.ts","../../../projects/ui/layout/grid.component.ts","../../../projects/ui/layout/public-api.ts","../../../projects/ui/layout/cngx-ui-layout.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\n/**\n * Main-axis direction for {@link CngxStack}.\n */\nexport type StackDirection = 'row' | 'column';\n/**\n * Cross-axis alignment for {@link CngxStack}.\n */\nexport type StackAlign = 'start' | 'center' | 'end' | 'stretch';\n/**\n * Spacing scale for {@link CngxStack}. Maps to `--cngx-gap-*` tokens.\n */\nexport type StackGap = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n// Chain per rung: consumer override hook (--cngx-gap-*, set nowhere by the\n// library) -> density scale (--cngx-space-*, registered inherits: true, so a\n// root [data-density] swap rescales the stack) -> literal for token-less\n// environments.\nconst GAP_DEFAULTS: Record<StackGap, string> = {\n none: '0',\n xs: 'var(--cngx-gap-xs, var(--cngx-space-xs, 4px))',\n sm: 'var(--cngx-gap-sm, var(--cngx-space-sm, 8px))',\n md: 'var(--cngx-gap-md, var(--cngx-space-md, 16px))',\n lg: 'var(--cngx-gap-lg, var(--cngx-space-lg, 24px))',\n xl: 'var(--cngx-gap-xl, var(--cngx-space-xl, 32px))',\n};\n\nconst ALIGN_ITEMS: Record<StackAlign, string> = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n stretch: 'stretch',\n};\n\n/**\n * Composable flex-based stack layout component.\n *\n * Gap tokens use CSS custom properties (`--cngx-gap-xs` through `--cngx-gap-xl`)\n * that fall back to the density scale (`--cngx-space-*`), so a root\n * `[data-density]` swap rescales the stack. Override the `--cngx-gap-*`\n * hooks at any scope to detach a stack from the scale.\n *\n * <cngx-stack direction=\"row\" gap=\"md\" align=\"center\">\n * <div>Item 1</div>\n * <div>Item 2</div>\n * </cngx-stack>\n *\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/stack.component.ts\n * @since 0.3.0\n * @relatedTo CngxGrid\n * @axis level organism\n */\n@Component({\n selector: 'cngx-stack',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: '<ng-content />',\n styles: [\n `\n :host {\n display: flex;\n }\n `,\n ],\n host: {\n '[style.flex-direction]': 'direction()',\n '[style.align-items]': 'alignItems()',\n // A static align attribute would trigger the browser's legacy\n // presentational hint (text-align) on the host; the input already took it.\n '[attr.align]': 'null',\n '[style.gap]': 'gapValue()',\n },\n})\nexport class CngxStack {\n /** Flex direction of the stack. */\n readonly direction = input<StackDirection>('column');\n /** Named spacing token between stack items. Resolves via `--cngx-gap-*` CSS custom properties. */\n readonly gap = input<StackGap>('md');\n /** Cross-axis alignment of stack items. */\n readonly align = input<StackAlign>('stretch');\n\n /** @internal */\n protected readonly alignItems = computed(() => ALIGN_ITEMS[this.align()]);\n\n /** @internal */\n protected readonly gapValue = computed(() => GAP_DEFAULTS[this.gap()]);\n}\n","import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\n/**\n * Composable CSS grid layout component.\n ``` html\n <cngx-grid columns=\"3\" gap=\"16px\">\n <div>Cell 1</div>\n <div>Cell 2</div>\n </cngx-grid>\n ```\n * `columns` accepts either a positive integer for the\n * `repeat(N, 1fr)` shortcut or any `grid-template-columns` value\n * (`\"200px 1fr\"`, `\"repeat(auto-fit, minmax(120px, 1fr))\"`).\n * Bare attribute syntax works for both forms: `columns=\"3\"` and\n * `[columns]=\"3\"` produce identical output.\n *\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/grid.component.ts\n * @since 0.3.0\n * @relatedTo CngxStack\n * @axis level organism\n */\n@Component({\n selector: 'cngx-grid',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: '<ng-content />',\n styles: [\n `\n :host {\n display: grid;\n }\n `,\n ],\n host: {\n '[style.grid-template-columns]': 'gridTemplateColumns()',\n '[style.gap]': 'gap()',\n },\n})\nexport class CngxGrid {\n /** Number of equal columns, or a custom `grid-template-columns` value. */\n readonly columns = input<number | string, number | string>(1, {\n transform: coerceColumns,\n });\n /**\n * CSS gap between cells. The default reads the `--cngx-gap-md` override\n * hook and falls back to the density scale (`--cngx-space-md`), so a root\n * `[data-density]` swap rescales the grid; any CSS gap value is accepted.\n */\n readonly gap = input('var(--cngx-gap-md, var(--cngx-space-md, 16px))');\n\n /** @internal */\n protected readonly gridTemplateColumns = computed(() => {\n const cols = this.columns();\n return typeof cols === 'number' ? `repeat(${cols}, 1fr)` : cols;\n });\n}\n\n// Bare integer attribute (`columns=\"3\"`) coerces to a number so the\n// `repeat(N, 1fr)` branch fires; anything else is a track-list string\n// (`\"200px 1fr\"`) and passes through to `grid-template-columns`.\nfunction coerceColumns(value: number | string): number | string {\n if (typeof value === 'number') {\n return value;\n }\n return /^\\d+$/.test(value) ? Number(value) : value;\n}\n","/**\n * Public API Surface of `@cngx/ui/layout`\n * @module `@cngx/ui/layout`\n */\n\nexport * from './stack.component';\nexport * from './grid.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAeA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAA6B;AAC7C,IAAA,IA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,uBAAuB;AACxD,wBAAA,aAAa,EAAE,OAAO;AACvB,qBAAA,EAAA,MAAA,EAAA,CAAA,uBAAA,CAAA,EAAA;;AAqBH;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAsB,EAAA;AAC3C,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK;AACpD;;ACjEA;;;AAGG;;ACHH;;AAEG;;;;"}
@@ -47,7 +47,6 @@ import { nextUid } from '@cngx/core/utils';
47
47
  * membership check drops any Material emit that already agrees with the
48
48
  * brain.
49
49
  *
50
- * @category ui/mat-accordion/material-bridge
51
50
  * @internal
52
51
  */
53
52
  function createMatExpansionSetSync(opts) {
@@ -185,12 +184,11 @@ function createMatExpansionSetSync(opts) {
185
184
  * ```
186
185
  *
187
186
  * @playground Controlled open-set ./examples/bridge/bridge-example.component.ts
188
- * @category ui/mat-accordion
189
- * @docsKind primary
190
187
  * @wcag AA
191
188
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-accordion/mat-accordion.directive.ts
192
- * @since 0.1.0
189
+ * @since 0.3.0
193
190
  * @relatedTo CngxAccordion, CngxAccordionItem, CngxMatStepper, CngxMatTabs
191
+ * @axis level molecule
194
192
  */
195
193
  class CngxMatAccordion {
196
194
  matAccordion = inject(MatAccordion, { self: true });
@@ -280,7 +278,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
280
278
  }], ctorParameters: () => [], propDecorators: { panels: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => MatExpansionPanel), { ...{ descendants: true }, isSignal: true }] }], panelIdFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelIdFn", required: false }] }] } });
281
279
 
282
280
  /**
283
- * @module @cngx/ui/mat-accordion
281
+ * @module `@cngx/ui/mat-accordion`
284
282
  *
285
283
  * Material instrumentation directive for `<mat-accordion>`: attach
286
284
  * `[cngxMatAccordion]` and it composes the same {@link CngxAccordion}
@@ -1 +1 @@
1
- {"version":3,"file":"cngx-ui-mat-accordion.mjs","sources":["../../../projects/ui/mat-accordion/material-bridge/set-sync.ts","../../../projects/ui/mat-accordion/mat-accordion.directive.ts","../../../projects/ui/mat-accordion/public-api.ts","../../../projects/ui/mat-accordion/cngx-ui-mat-accordion.ts"],"sourcesContent":["import { type DestroyRef, effect, type Injector, runInInjectionContext, type Signal, untracked } from '@angular/core';\n\n/**\n * Minimal structural view of a `MatExpansionPanel` the set-sync needs:\n * a read/write `expanded` boolean and an `expandedChange` stream. Kept\n * host-agnostic (no `@angular/material` type in the signature) so the\n * helper is unit-testable with plain fakes, mirroring the Material-\n * agnostic shape of `createMaterialBidirectionalSync` in\n * `@cngx/common/data`. `MatExpansionPanel` satisfies it structurally\n * (`expanded` getter/setter from `CdkAccordionItem`, `expandedChange`\n * is an `EventEmitter<boolean>` whose `.subscribe` matches).\n *\n * @category ui/mat-accordion/material-bridge\n * @internal\n */\nexport interface CngxExpansionPanelLike {\n /** Current expanded state; assigning it drives the Material panel open/closed. */\n expanded: boolean;\n /** Emits the new expanded state on every Material-driven or programmatic change. */\n readonly expandedChange: {\n subscribe(next: (expanded: boolean) => void): { unsubscribe(): void };\n };\n}\n\n/**\n * Minimal structural view of the accordion brain the sync drives:\n * a reactive membership read plus the same `toggle` the native\n * `CngxAccordionPanel` calls. `CngxAccordion` satisfies it - `isOpen`\n * reads the clamped `effectiveOpenIds` computed and `toggle` mutates\n * from that clamped view, so single-open arbitration stays authoritative\n * and the exposed `openIds` model never retains a clamped-out id. The\n * sync writes membership exclusively through `toggle`, never a raw\n * set-write, so it can never diverge from the brain's own DOM path.\n *\n * @category ui/mat-accordion/material-bridge\n * @internal\n */\nexport interface CngxAccordionOpenSet {\n /** Reactive membership read - reflects single-mode arbitration. Tracked inside the sync effect. */\n isOpen(panelId: string): boolean;\n /** Flip a panel's open state, arbitrated by the brain (clamps siblings in single mode). */\n toggle(panelId: string): void;\n}\n\n/**\n * Options for {@link createMatExpansionSetSync}.\n *\n * @category ui/mat-accordion/material-bridge\n * @internal\n */\nexport interface CngxMatExpansionSetSyncOptions<P extends CngxExpansionPanelLike> {\n /** Reactive list of projected expansion panels (a `contentChildren` signal). */\n readonly panels: Signal<readonly P[]>;\n /** Stable id for a panel - the key the brain's open-set stores. */\n readonly panelId: (panel: P) => string;\n /** The accordion brain's open-set (membership read + settable model). */\n readonly accordion: CngxAccordionOpenSet;\n /** Injection context for the underlying `effect()`s. */\n readonly injector: Injector;\n /** Same lifetime as the host directive; tears down the `expandedChange` listeners. */\n readonly destroyRef: DestroyRef;\n}\n\n/**\n * Set-based bidirectional sync between a `<mat-accordion>`'s projected\n * `<mat-expansion-panel>` tree and the headless {@link CngxAccordion}\n * open-set. The accordion open-set is a multi-membership\n * `Set<string>`, so the index-based `createMaterialBidirectionalSync`\n * (`@cngx/common/data`) does not fit - this helper syncs per-panel\n * `expanded` against set membership instead.\n *\n * Installs two effects and one listener-set:\n *\n * 1. **brain→Material** - an `effect()` tracking `panels()` and, per\n * panel, `accordion.isOpen(id)`. When the open-set (or the panel\n * list) changes it writes `panel.expanded` to match, guarded by a\n * re-entrancy flag so the resulting synchronous `expandedChange`\n * echo does not loop back. The Material writes run inside\n * `untracked()` per the signal-architecture rules. Before the\n * first write for a freshly-sighted panel, its authored\n * `[expanded]` state SEEDS the brain: a panel that arrives\n * already expanded toggles its id into the open-set instead of\n * being closed by the (initially empty) membership write.\n * Membership still flows through `toggle`, so single-open\n * arbitration applies to seeded panels exactly as it does to a\n * user click - two panels authored expanded clamp to one in\n * single mode.\n * 2. **subscription reconcile** - an `effect()` tracking only\n * `panels()`; inside `untracked()` it subscribes freshly-added\n * panels' `expandedChange` and drops removed ones (diff-only churn,\n * a `Map<P, subscription>`).\n * 3. **Material→brain** - each `expandedChange` listener flips the\n * brain via `accordion.toggle(id)`, but only when the incoming\n * `expanded` differs from the brain's current (clamped) membership,\n * so a programmatic echo (or a redundant Material emit) is a no-op.\n * Routing through `toggle` (not a raw set-write) means single-mode\n * arbitration and the exposed `openIds` model stay identical to the\n * native `CngxAccordionPanel` DOM path.\n *\n * The idempotent membership check plus the re-entrancy flag together\n * close the loop: the flag drops the synchronous echo `CdkAccordionItem`\n * emits from its `expanded` setter during our own write, and the\n * membership check drops any Material emit that already agrees with the\n * brain.\n *\n * @category ui/mat-accordion/material-bridge\n * @internal\n */\nexport function createMatExpansionSetSync<P extends CngxExpansionPanelLike>(\n opts: CngxMatExpansionSetSyncOptions<P>,\n): void {\n const { panels, panelId, accordion, injector, destroyRef } = opts;\n\n // True while effect 1 is writing Material. `CdkAccordionItem` emits\n // `expandedChange` synchronously from its `expanded` setter, so the\n // Material→brain listener fires re-entrantly during our own write -\n // the flag drops that echo before the idempotent check even runs.\n let writingToMaterial = false;\n\n const subscriptions = new Map<P, { unsubscribe(): void }>();\n // Panels whose authored `expanded` state has already been folded\n // into the brain - seeding happens exactly once per panel lifetime.\n const seeded = new WeakSet<P>();\n\n const writeBackFromMaterial = (id: string, expanded: boolean): void => {\n if (writingToMaterial) {\n return;\n }\n if (accordion.isOpen(id) === expanded) {\n return;\n }\n accordion.toggle(id);\n };\n\n runInInjectionContext(injector, () => {\n // brain→Material.\n effect(() => {\n const list = panels();\n // Seed first: a freshly-sighted panel authored `[expanded]`\n // flows Material→brain BEFORE the membership write below runs,\n // otherwise the initially-empty open-set would close it. Runs\n // inside untracked() - `toggle` is a service call writing\n // signals; the tracked `isOpen` reads below pick up the\n // seeded membership synchronously.\n untracked(() => {\n for (const panel of list) {\n if (seeded.has(panel)) {\n continue;\n }\n seeded.add(panel);\n if (panel.expanded && !accordion.isOpen(panelId(panel))) {\n accordion.toggle(panelId(panel));\n }\n }\n });\n const desired = list.map((panel) => accordion.isOpen(panelId(panel)));\n untracked(() => {\n writingToMaterial = true;\n try {\n list.forEach((panel, index) => {\n if (panel.expanded !== desired[index]) {\n panel.expanded = desired[index];\n }\n });\n } finally {\n writingToMaterial = false;\n }\n });\n });\n\n // Subscription reconcile.\n effect(() => {\n const live = new Set(panels());\n untracked(() => {\n for (const panel of live) {\n if (subscriptions.has(panel)) {\n continue;\n }\n // Resolve the id per event, not at subscribe time - a\n // consumer-swapped panelId fn would otherwise leave this\n // listener toggling the stale key forever.\n subscriptions.set(\n panel,\n panel.expandedChange.subscribe((expanded) =>\n writeBackFromMaterial(panelId(panel), expanded),\n ),\n );\n }\n for (const [panel, subscription] of Array.from(subscriptions.entries())) {\n if (live.has(panel)) {\n continue;\n }\n subscription.unsubscribe();\n subscriptions.delete(panel);\n }\n });\n });\n });\n\n destroyRef.onDestroy(() => {\n for (const subscription of subscriptions.values()) {\n subscription.unsubscribe();\n }\n subscriptions.clear();\n });\n}\n","import {\n computed,\n contentChildren,\n DestroyRef,\n Directive,\n effect,\n inject,\n Injector,\n input,\n untracked,\n} from '@angular/core';\nimport { MatAccordion, MatExpansionPanel } from '@angular/material/expansion';\n\nimport { CngxAccordion } from '@cngx/common/interactive';\nimport { nextUid } from '@cngx/core/utils';\n\nimport { createMatExpansionSetSync } from './material-bridge/set-sync';\n\n/**\n * The Material twin of the cngx accordion: attach `cngxMatAccordion` to\n * a vanilla `<mat-accordion>` and it is driven by the headless\n * {@link CngxAccordion} brain. Consumers gain the controlled\n * `[(openIds)]` group model and single-open arbitration on Material\n * markup - neither of which `<mat-accordion>` exposes (Material has only\n * per-panel `[expanded]`). Mirrors `[cngxMatStepper]` / `[cngxMatTabs]`.\n *\n * This is the instrumentation pattern: Material owns rendering and the\n * consumer authors native `<mat-expansion-panel>` markup; cngx is the\n * behaviour layer. `[multi]` and the two-way `[(openIds)]` are forwarded\n * from {@link CngxAccordion} via `hostDirectives`.\n *\n * ```html\n * <mat-accordion cngxMatAccordion [(openIds)]=\"openIds\" [multi]=\"false\">\n * <mat-expansion-panel>\n * <mat-expansion-panel-header>Personal info</mat-expansion-panel-header>\n * <p>Tell us who you are.</p>\n * </mat-expansion-panel>\n * <mat-expansion-panel>\n * <mat-expansion-panel-header>Account</mat-expansion-panel-header>\n * <p>Choose your sign-in method.</p>\n * </mat-expansion-panel>\n * </mat-accordion>\n * ```\n *\n * `multi` is authoritative on the cngx side. `MatAccordion` inherits its\n * own `multi` input from `CdkAccordion`, and both directives sit on the\n * same host element, so a single `[multi]` binding feeds both - the\n * directive therefore pins `matAccordion.multi = true` (via an `effect`\n * that re-asserts on every `multi` change) so Material never runs its own\n * single-open close while the cngx `effectiveOpenIds` clamp arbitrates.\n *\n * Panels authored `[expanded]=\"true\"` seed the open-set at first\n * registration (Material→brain), so an initially-open Material panel\n * is not closed by the initially-empty membership model. To make a\n * pre-populated `[(openIds)]` addressable, bind `[panelIdFn]` - the\n * hook replaces the generated per-panel ids with consumer-known keys:\n *\n * ```html\n * <mat-accordion\n * cngxMatAccordion\n * [(openIds)]=\"openIds\"\n * [panelIdFn]=\"idFromPanel\"\n * >\n * ```\n *\n * @playground Controlled open-set ./examples/bridge/bridge-example.component.ts\n * @category ui/mat-accordion\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-accordion/mat-accordion.directive.ts\n * @since 0.1.0\n * @relatedTo CngxAccordion, CngxAccordionItem, CngxMatStepper, CngxMatTabs\n */\n@Directive({\n selector: '[cngxMatAccordion]',\n exportAs: 'cngxMatAccordion',\n standalone: true,\n hostDirectives: [\n {\n directive: CngxAccordion,\n inputs: ['multi', 'openIds'],\n outputs: ['openIdsChange'],\n },\n ],\n})\nexport class CngxMatAccordion {\n private readonly matAccordion = inject(MatAccordion, { self: true });\n /**\n * The accordion brain on this host element (declared in\n * `hostDirectives`). Same-host ownership - not a child→parent inject -\n * so it stays decompose-safe.\n */\n private readonly accordion = inject(CngxAccordion, { self: true });\n private readonly injector = inject(Injector);\n private readonly destroyRef = inject(DestroyRef);\n\n private readonly panels = contentChildren(MatExpansionPanel, { descendants: true });\n\n // Ownership filter: `descendants: true` also surfaces panels of an\n // accordion nested inside one of OUR panels' bodies. Each panel\n // carries its owning `accordion` (public on CdkAccordionItem), so\n // foreign panels never enter the set-sync - the nested accordion\n // arbitrates its own children. Element-wise equal keeps downstream\n // effects quiet on identity-preserving query re-emissions.\n private readonly ownPanels = computed(\n () => this.panels().filter((panel) => panel.accordion === this.matAccordion),\n {\n equal: (a, b) => a.length === b.length && a.every((panel, i) => panel === b[i]),\n },\n );\n\n /**\n * Per-panel id hook. When bound, the returned key is what the\n * open-set stores for that panel - making a pre-populated\n * `[(openIds)]` model addressable (the generated\n * `cngx-mat-panel-N` ids are unknowable to consumers). The\n * function must return a stable, unique id per panel instance.\n * `MatExpansionPanel.id` is a readonly id the CDK generates, so it is\n * not known up front; key panels from your own data instead.\n * Unbound, ids fall back to generated `nextUid` values. Swapping\n * the bound function at runtime re-keys future events but does not\n * migrate ids already stored in `openIds` - bind it once.\n */\n readonly panelIdFn = input<((panel: MatExpansionPanel) => string) | undefined>(undefined);\n\n // Stable id per panel - the key the brain's open-set stores. A WeakMap:\n // the id is assigned first-seen and never needs enumeration, so a removed\n // panel's entry drops with the panel instead of accumulating over churn.\n private readonly idByPanel = new WeakMap<MatExpansionPanel, string>();\n\n constructor() {\n // Pin Material's own `multi` so it never arbitrates single-open: the\n // brain's `effectiveOpenIds` clamp is the sole arbiter. A single\n // `[multi]` binding on the host also sets `MatAccordion.multi`\n // (inherited from `CdkAccordion`); Angular applies that input during\n // change detection, so re-assert from an `effect` that flushes after\n // CD and re-runs whenever the consumer's `multi` changes.\n effect(() => {\n this.accordion.multi();\n untracked(() => {\n this.matAccordion.multi = true;\n });\n });\n\n createMatExpansionSetSync<MatExpansionPanel>({\n panels: this.ownPanels,\n panelId: (panel) => this.panelId(panel),\n accordion: this.accordion,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n }\n\n private panelId(panel: MatExpansionPanel): string {\n const idFn = this.panelIdFn();\n if (idFn !== undefined) {\n return idFn(panel);\n }\n let id = this.idByPanel.get(panel);\n if (id === undefined) {\n id = nextUid('cngx-mat-panel-');\n this.idByPanel.set(panel, id);\n }\n return id;\n }\n}\n","/**\n * @module @cngx/ui/mat-accordion\n *\n * Material instrumentation directive for `<mat-accordion>`: attach\n * `[cngxMatAccordion]` and it composes the same {@link CngxAccordion}\n * brain as `<cngx-accordion-group>` (in `@cngx/ui/accordion`) via\n * `hostDirectives`, so the controlled `[(openIds)]` group model and\n * single-open arbitration work against Material's own markup. Mirrors\n * `[cngxMatStepper]` / `[cngxMatTabs]`.\n */\nexport { CngxMatAccordion } from './mat-accordion.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AA+DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;AACG,SAAU,yBAAyB,CACvC,IAAuC,EAAA;AAEvC,IAAA,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI;;;;;IAMjE,IAAI,iBAAiB,GAAG,KAAK;AAE7B,IAAA,MAAM,aAAa,GAAG,IAAI,GAAG,EAA8B;;;AAG3D,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAK;AAE/B,IAAA,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,QAAiB,KAAU;QACpE,IAAI,iBAAiB,EAAE;YACrB;QACF;QACA,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,QAAQ,EAAE;YACrC;QACF;AACA,QAAA,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;AACtB,IAAA,CAAC;AAED,IAAA,qBAAqB,CAAC,QAAQ,EAAE,MAAK;;QAEnC,MAAM,CAAC,MAAK;AACV,YAAA,MAAM,IAAI,GAAG,MAAM,EAAE;;;;;;;YAOrB,SAAS,CAAC,MAAK;AACb,gBAAA,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE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AA,EAAA,GAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,WAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AChGpF;;;;;;;;;AASG;;ACTH;;AAEG;;;;"}
1
+ {"version":3,"file":"cngx-ui-mat-accordion.mjs","sources":["../../../projects/ui/mat-accordion/material-bridge/set-sync.ts","../../../projects/ui/mat-accordion/mat-accordion.directive.ts","../../../projects/ui/mat-accordion/public-api.ts","../../../projects/ui/mat-accordion/cngx-ui-mat-accordion.ts"],"sourcesContent":["import { type DestroyRef, effect, type Injector, runInInjectionContext, type Signal, untracked } from '@angular/core';\n\n/**\n * Minimal structural view of a `MatExpansionPanel` the set-sync needs:\n * a read/write `expanded` boolean and an `expandedChange` stream. Kept\n * host-agnostic (no `@angular/material` type in the signature) so the\n * helper is unit-testable with plain fakes, mirroring the Material-\n * agnostic shape of `createMaterialBidirectionalSync` in\n * `@cngx/common/data`. `MatExpansionPanel` satisfies it structurally\n * (`expanded` getter/setter from `CdkAccordionItem`, `expandedChange`\n * is an `EventEmitter<boolean>` whose `.subscribe` matches).\n *\n * @internal\n */\nexport interface CngxExpansionPanelLike {\n /** Current expanded state; assigning it drives the Material panel open/closed. */\n expanded: boolean;\n /** Emits the new expanded state on every Material-driven or programmatic change. */\n readonly expandedChange: {\n subscribe(next: (expanded: boolean) => void): { unsubscribe(): void };\n };\n}\n\n/**\n * Minimal structural view of the accordion brain the sync drives:\n * a reactive membership read plus the same `toggle` the native\n * `CngxAccordionPanel` calls. `CngxAccordion` satisfies it - `isOpen`\n * reads the clamped `effectiveOpenIds` computed and `toggle` mutates\n * from that clamped view, so single-open arbitration stays authoritative\n * and the exposed `openIds` model never retains a clamped-out id. The\n * sync writes membership exclusively through `toggle`, never a raw\n * set-write, so it can never diverge from the brain's own DOM path.\n *\n * @internal\n */\nexport interface CngxAccordionOpenSet {\n /** Reactive membership read - reflects single-mode arbitration. Tracked inside the sync effect. */\n isOpen(panelId: string): boolean;\n /** Flip a panel's open state, arbitrated by the brain (clamps siblings in single mode). */\n toggle(panelId: string): void;\n}\n\n/**\n * Options for {@link createMatExpansionSetSync}.\n *\n * @internal\n */\nexport interface CngxMatExpansionSetSyncOptions<P extends CngxExpansionPanelLike> {\n /** Reactive list of projected expansion panels (a `contentChildren` signal). */\n readonly panels: Signal<readonly P[]>;\n /** Stable id for a panel - the key the brain's open-set stores. */\n readonly panelId: (panel: P) => string;\n /** The accordion brain's open-set (membership read + settable model). */\n readonly accordion: CngxAccordionOpenSet;\n /** Injection context for the underlying `effect()`s. */\n readonly injector: Injector;\n /** Same lifetime as the host directive; tears down the `expandedChange` listeners. */\n readonly destroyRef: DestroyRef;\n}\n\n/**\n * Set-based bidirectional sync between a `<mat-accordion>`'s projected\n * `<mat-expansion-panel>` tree and the headless {@link CngxAccordion}\n * open-set. The accordion open-set is a multi-membership\n * `Set<string>`, so the index-based `createMaterialBidirectionalSync`\n * (`@cngx/common/data`) does not fit - this helper syncs per-panel\n * `expanded` against set membership instead.\n *\n * Installs two effects and one listener-set:\n *\n * 1. **brain→Material** - an `effect()` tracking `panels()` and, per\n * panel, `accordion.isOpen(id)`. When the open-set (or the panel\n * list) changes it writes `panel.expanded` to match, guarded by a\n * re-entrancy flag so the resulting synchronous `expandedChange`\n * echo does not loop back. The Material writes run inside\n * `untracked()` per the signal-architecture rules. Before the\n * first write for a freshly-sighted panel, its authored\n * `[expanded]` state SEEDS the brain: a panel that arrives\n * already expanded toggles its id into the open-set instead of\n * being closed by the (initially empty) membership write.\n * Membership still flows through `toggle`, so single-open\n * arbitration applies to seeded panels exactly as it does to a\n * user click - two panels authored expanded clamp to one in\n * single mode.\n * 2. **subscription reconcile** - an `effect()` tracking only\n * `panels()`; inside `untracked()` it subscribes freshly-added\n * panels' `expandedChange` and drops removed ones (diff-only churn,\n * a `Map<P, subscription>`).\n * 3. **Material→brain** - each `expandedChange` listener flips the\n * brain via `accordion.toggle(id)`, but only when the incoming\n * `expanded` differs from the brain's current (clamped) membership,\n * so a programmatic echo (or a redundant Material emit) is a no-op.\n * Routing through `toggle` (not a raw set-write) means single-mode\n * arbitration and the exposed `openIds` model stay identical to the\n * native `CngxAccordionPanel` DOM path.\n *\n * The idempotent membership check plus the re-entrancy flag together\n * close the loop: the flag drops the synchronous echo `CdkAccordionItem`\n * emits from its `expanded` setter during our own write, and the\n * membership check drops any Material emit that already agrees with the\n * brain.\n *\n * @internal\n */\nexport function createMatExpansionSetSync<P extends CngxExpansionPanelLike>(\n opts: CngxMatExpansionSetSyncOptions<P>,\n): void {\n const { panels, panelId, accordion, injector, destroyRef } = opts;\n\n // True while effect 1 is writing Material. `CdkAccordionItem` emits\n // `expandedChange` synchronously from its `expanded` setter, so the\n // Material→brain listener fires re-entrantly during our own write -\n // the flag drops that echo before the idempotent check even runs.\n let writingToMaterial = false;\n\n const subscriptions = new Map<P, { unsubscribe(): void }>();\n // Panels whose authored `expanded` state has already been folded\n // into the brain - seeding happens exactly once per panel lifetime.\n const seeded = new WeakSet<P>();\n\n const writeBackFromMaterial = (id: string, expanded: boolean): void => {\n if (writingToMaterial) {\n return;\n }\n if (accordion.isOpen(id) === expanded) {\n return;\n }\n accordion.toggle(id);\n };\n\n runInInjectionContext(injector, () => {\n // brain→Material.\n effect(() => {\n const list = panels();\n // Seed first: a freshly-sighted panel authored `[expanded]`\n // flows Material→brain BEFORE the membership write below runs,\n // otherwise the initially-empty open-set would close it. Runs\n // inside untracked() - `toggle` is a service call writing\n // signals; the tracked `isOpen` reads below pick up the\n // seeded membership synchronously.\n untracked(() => {\n for (const panel of list) {\n if (seeded.has(panel)) {\n continue;\n }\n seeded.add(panel);\n if (panel.expanded && !accordion.isOpen(panelId(panel))) {\n accordion.toggle(panelId(panel));\n }\n }\n });\n const desired = list.map((panel) => accordion.isOpen(panelId(panel)));\n untracked(() => {\n writingToMaterial = true;\n try {\n list.forEach((panel, index) => {\n if (panel.expanded !== desired[index]) {\n panel.expanded = desired[index];\n }\n });\n } finally {\n writingToMaterial = false;\n }\n });\n });\n\n // Subscription reconcile.\n effect(() => {\n const live = new Set(panels());\n untracked(() => {\n for (const panel of live) {\n if (subscriptions.has(panel)) {\n continue;\n }\n // Resolve the id per event, not at subscribe time - a\n // consumer-swapped panelId fn would otherwise leave this\n // listener toggling the stale key forever.\n subscriptions.set(\n panel,\n panel.expandedChange.subscribe((expanded) =>\n writeBackFromMaterial(panelId(panel), expanded),\n ),\n );\n }\n for (const [panel, subscription] of Array.from(subscriptions.entries())) {\n if (live.has(panel)) {\n continue;\n }\n subscription.unsubscribe();\n subscriptions.delete(panel);\n }\n });\n });\n });\n\n destroyRef.onDestroy(() => {\n for (const subscription of subscriptions.values()) {\n subscription.unsubscribe();\n }\n subscriptions.clear();\n });\n}\n","import {\n computed,\n contentChildren,\n DestroyRef,\n Directive,\n effect,\n inject,\n Injector,\n input,\n untracked,\n} from '@angular/core';\nimport { MatAccordion, MatExpansionPanel } from '@angular/material/expansion';\n\nimport { CngxAccordion } from '@cngx/common/interactive';\nimport { nextUid } from '@cngx/core/utils';\n\nimport { createMatExpansionSetSync } from './material-bridge/set-sync';\n\n/**\n * The Material twin of the cngx accordion: attach `cngxMatAccordion` to\n * a vanilla `<mat-accordion>` and it is driven by the headless\n * {@link CngxAccordion} brain. Consumers gain the controlled\n * `[(openIds)]` group model and single-open arbitration on Material\n * markup - neither of which `<mat-accordion>` exposes (Material has only\n * per-panel `[expanded]`). Mirrors `[cngxMatStepper]` / `[cngxMatTabs]`.\n *\n * This is the instrumentation pattern: Material owns rendering and the\n * consumer authors native `<mat-expansion-panel>` markup; cngx is the\n * behaviour layer. `[multi]` and the two-way `[(openIds)]` are forwarded\n * from {@link CngxAccordion} via `hostDirectives`.\n *\n * ```html\n * <mat-accordion cngxMatAccordion [(openIds)]=\"openIds\" [multi]=\"false\">\n * <mat-expansion-panel>\n * <mat-expansion-panel-header>Personal info</mat-expansion-panel-header>\n * <p>Tell us who you are.</p>\n * </mat-expansion-panel>\n * <mat-expansion-panel>\n * <mat-expansion-panel-header>Account</mat-expansion-panel-header>\n * <p>Choose your sign-in method.</p>\n * </mat-expansion-panel>\n * </mat-accordion>\n * ```\n *\n * `multi` is authoritative on the cngx side. `MatAccordion` inherits its\n * own `multi` input from `CdkAccordion`, and both directives sit on the\n * same host element, so a single `[multi]` binding feeds both - the\n * directive therefore pins `matAccordion.multi = true` (via an `effect`\n * that re-asserts on every `multi` change) so Material never runs its own\n * single-open close while the cngx `effectiveOpenIds` clamp arbitrates.\n *\n * Panels authored `[expanded]=\"true\"` seed the open-set at first\n * registration (Material→brain), so an initially-open Material panel\n * is not closed by the initially-empty membership model. To make a\n * pre-populated `[(openIds)]` addressable, bind `[panelIdFn]` - the\n * hook replaces the generated per-panel ids with consumer-known keys:\n *\n * ```html\n * <mat-accordion\n * cngxMatAccordion\n * [(openIds)]=\"openIds\"\n * [panelIdFn]=\"idFromPanel\"\n * >\n * ```\n *\n * @playground Controlled open-set ./examples/bridge/bridge-example.component.ts\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-accordion/mat-accordion.directive.ts\n * @since 0.3.0\n * @relatedTo CngxAccordion, CngxAccordionItem, CngxMatStepper, CngxMatTabs\n * @axis level molecule\n */\n@Directive({\n selector: '[cngxMatAccordion]',\n exportAs: 'cngxMatAccordion',\n standalone: true,\n hostDirectives: [\n {\n directive: CngxAccordion,\n inputs: ['multi', 'openIds'],\n outputs: ['openIdsChange'],\n },\n ],\n})\nexport class CngxMatAccordion {\n private readonly matAccordion = inject(MatAccordion, { self: true });\n /**\n * The accordion brain on this host element (declared in\n * `hostDirectives`). Same-host ownership - not a child→parent inject -\n * so it stays decompose-safe.\n */\n private readonly accordion = inject(CngxAccordion, { self: true });\n private readonly injector = inject(Injector);\n private readonly destroyRef = inject(DestroyRef);\n\n private readonly panels = contentChildren(MatExpansionPanel, { descendants: true });\n\n // Ownership filter: `descendants: true` also surfaces panels of an\n // accordion nested inside one of OUR panels' bodies. Each panel\n // carries its owning `accordion` (public on CdkAccordionItem), so\n // foreign panels never enter the set-sync - the nested accordion\n // arbitrates its own children. Element-wise equal keeps downstream\n // effects quiet on identity-preserving query re-emissions.\n private readonly ownPanels = computed(\n () => this.panels().filter((panel) => panel.accordion === this.matAccordion),\n {\n equal: (a, b) => a.length === b.length && a.every((panel, i) => panel === b[i]),\n },\n );\n\n /**\n * Per-panel id hook. When bound, the returned key is what the\n * open-set stores for that panel - making a pre-populated\n * `[(openIds)]` model addressable (the generated\n * `cngx-mat-panel-N` ids are unknowable to consumers). The\n * function must return a stable, unique id per panel instance.\n * `MatExpansionPanel.id` is a readonly id the CDK generates, so it is\n * not known up front; key panels from your own data instead.\n * Unbound, ids fall back to generated `nextUid` values. Swapping\n * the bound function at runtime re-keys future events but does not\n * migrate ids already stored in `openIds` - bind it once.\n */\n readonly panelIdFn = input<((panel: MatExpansionPanel) => string) | undefined>(undefined);\n\n // Stable id per panel - the key the brain's open-set stores. A WeakMap:\n // the id is assigned first-seen and never needs enumeration, so a removed\n // panel's entry drops with the panel instead of accumulating over churn.\n private readonly idByPanel = new WeakMap<MatExpansionPanel, string>();\n\n constructor() {\n // Pin Material's own `multi` so it never arbitrates single-open: the\n // brain's `effectiveOpenIds` clamp is the sole arbiter. A single\n // `[multi]` binding on the host also sets `MatAccordion.multi`\n // (inherited from `CdkAccordion`); Angular applies that input during\n // change detection, so re-assert from an `effect` that flushes after\n // CD and re-runs whenever the consumer's `multi` changes.\n effect(() => {\n this.accordion.multi();\n untracked(() => {\n this.matAccordion.multi = true;\n });\n });\n\n createMatExpansionSetSync<MatExpansionPanel>({\n panels: this.ownPanels,\n panelId: (panel) => this.panelId(panel),\n accordion: this.accordion,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n }\n\n private panelId(panel: MatExpansionPanel): string {\n const idFn = this.panelIdFn();\n if (idFn !== undefined) {\n return idFn(panel);\n }\n let id = this.idByPanel.get(panel);\n if (id === undefined) {\n id = nextUid('cngx-mat-panel-');\n this.idByPanel.set(panel, id);\n }\n return id;\n }\n}\n","/**\n * @module `@cngx/ui/mat-accordion`\n *\n * Material instrumentation directive for `<mat-accordion>`: attach\n * `[cngxMatAccordion]` and it composes the same {@link CngxAccordion}\n * brain as `<cngx-accordion-group>` (in `@cngx/ui/accordion`) via\n * `hostDirectives`, so the controlled `[(openIds)]` group model and\n * single-open arbitration work against Material's own markup. Mirrors\n * `[cngxMatStepper]` / `[cngxMatTabs]`.\n */\nexport { CngxMatAccordion } from './mat-accordion.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;AACG,SAAU,yBAAyB,CACvC,IAAuC,EAAA;AAEvC,IAAA,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI;;;;;IAMjE,IAAI,iBAAiB,GAAG,KAAK;AAE7B,IAAA,MAAM,aAAa,GAAG,IAAI,GAAG,EAA8B;;;AAG3D,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAK;AAE/B,IAAA,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,QAAiB,KAAU;QACpE,IAAI,iBAAiB,EAAE;YACrB;QACF;QACA,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,QAAQ,EAAE;YACrC;QACF;AACA,QAAA,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;AACtB,IAAA,CAAC;AAED,IAAA,qBAAqB,CAAC,QAAQ,EAAE,MAAK;;QAEnC,MAAM,CAAC,MAAK;AACV,YA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AAA,EAAA,IAAA,EAAA,EAAA,CAAA,eAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA,iBAAiB,CAAA,EAAA,EAAA,GAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,WAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AC/FpF;;;;;;;;;AASG;;ACTH;;AAEG;;;;"}
@@ -48,17 +48,13 @@ import { injectPaginatorAnnouncements } from '@cngx/ui/paginator';
48
48
  * </ul>
49
49
  * ```
50
50
  *
51
- * @category ui/mat-paginator
52
- * @docsKind primary
53
51
  * @wcag AA
54
52
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-paginator/mat-paginator-bridge.directive.ts
55
- * @since 0.1.0
53
+ * @since 0.3.0
56
54
  * @relatedTo CngxPaginate, CngxMatStepper, CngxPaginator
57
- * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
58
- * <example-url>http://localhost:4200/#/common/data/paginate-list/bridge-announce-page-changes</example-url>
59
- * <example-url>http://localhost:4200/#/common/data/paginate-list/instrumentation-bridge-cngxmatpaginator</example-url>
60
- * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
61
- * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
55
+ * <example-url>/#/ui/mat-paginator/bridge-announce-page-changes</example-url>
56
+ * <example-url>/#/ui/mat-paginator/instrumentation-bridge-cngxmatpaginator</example-url>
57
+ * @axis level molecule
62
58
  */
63
59
  class CngxMatPaginator {
64
60
  matPaginator = inject(MatPaginator, { self: true });
@@ -236,7 +232,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
236
232
  }], ctorParameters: () => [], propDecorators: { pageSizeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSizeOptions", required: false }] }], resetOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "resetOn", required: false }] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], pageSizeChange: [{ type: i0.Output, args: ["pageSizeChange"] }], announce: [{ type: i0.Input, args: [{ isSignal: true, alias: "announce", required: false }] }], announceLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "announceLabel", required: false }] }] } });
237
233
 
238
234
  /**
239
- * @module @cngx/ui/mat-paginator
235
+ * @module `@cngx/ui/mat-paginator`
240
236
  *
241
237
  * Material instrumentation for `<mat-paginator>`: the `[cngxMatPaginator]` bridge
242
238
  * `CngxMatPaginator` adopts an existing `<mat-paginator>` in place, letting the
@@ -1 +1 @@
1
- {"version":3,"file":"cngx-ui-mat-paginator.mjs","sources":["../../../projects/ui/mat-paginator/mat-paginator-bridge.directive.ts","../../../projects/ui/mat-paginator/public-api.ts","../../../projects/ui/mat-paginator/cngx-ui-mat-paginator.ts"],"sourcesContent":["import {\n booleanAttribute,\n computed,\n DestroyRef,\n Directive,\n effect,\n ElementRef,\n inject,\n input,\n output,\n Renderer2,\n untracked,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { MatPaginator, type PageEvent } from '@angular/material/paginator';\nimport { CngxPaginate, connectPaginateEmit, connectPaginateResetOn } from '@cngx/common/data';\nimport { injectPaginatorAnnouncements } from '@cngx/ui/paginator';\n\n/**\n * Context handed to {@link CngxMatPaginator.announceLabel} to build the\n * screen-reader announcement after each page / page-size change.\n *\n * @category ui/mat-paginator\n */\nexport interface CngxMatPaginatorAnnounceContext {\n /** 1-based current page. */\n readonly page: number;\n /** Total page count (minimum 1). */\n readonly totalPages: number;\n /** 1-based index of the first item on the page. */\n readonly start: number;\n /** 1-based index of the last item on the page, capped at `total`. */\n readonly end: number;\n /** Total item count before pagination. */\n readonly total: number;\n}\n\n/**\n * The in-place adoption half of the Material paginator instrumentation: add\n * `cngxMatPaginator` to an existing `<mat-paginator>` and the signal-native\n * {@link CngxPaginate} brain takes over its state with no DOM rewrite, mirroring\n * `[cngxMatStepper]` / `[cngxMatTabs]`.\n *\n * The bridge composes the untouched brain via `hostDirectives`, injects the\n * consumer's own `MatPaginator` with `{ self: true }`, and syncs the four\n * Material properties (`length` / `pageIndex` / `pageSize` / `disabled`) plus\n * `pageSizeOptions` against the brain's `computed()` graph, forwarding `(page)`\n * back into the brain.\n *\n * Beyond plain `<mat-paginator>`, the bridge adds:\n * - `[resetOn]` - jump to the first page whenever a bound key (a sort / filter /\n * search value) changes, so a filtered result set never strands the user on a\n * now-empty page. Pass a primitive (or a `computed` string key); an inline\n * array literal recomputes every change-detection pass and would reset on each.\n * - `[announce]` - mount a visually-hidden `aria-live` region that speaks the\n * page after every change; `<mat-paginator>` only relabels its own range\n * text, which AT does not announce. Phrasing resolves from the shared\n * `CNGX_PAGINATOR_CONFIG` cascade (`announcements.pageChange`), so app-wide\n * localisation covers the bridge and the organism together; bind\n * `[announceLabel]` for a richer per-instance message with the visible range.\n * - `[cngxPaginateRouting]` (generic companion directive from `@cngx/common/data`)\n * - persist the page / size in the URL query string for deep-linkable,\n * back-button-safe pagination.\n *\n * ```html\n * <mat-paginator\n * cngxMatPaginator\n * #pg=\"cngxMatPaginator\"\n * [total]=\"items.length\"\n * [pageSizeOptions]=\"[5, 10, 25]\"\n * />\n * <ul>\n * @for (item of items.slice(pg.paginate.range()[0], pg.paginate.range()[1]); track item.id) {\n * <li>{{ item.label }}</li>\n * }\n * </ul>\n * ```\n *\n * @category ui/mat-paginator\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-paginator/mat-paginator-bridge.directive.ts\n * @since 0.1.0\n * @relatedTo CngxPaginate, CngxMatStepper, CngxPaginator\n * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>\n * <example-url>http://localhost:4200/#/common/data/paginate-list/bridge-announce-page-changes</example-url>\n * <example-url>http://localhost:4200/#/common/data/paginate-list/instrumentation-bridge-cngxmatpaginator</example-url>\n * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>\n * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>\n */\n@Directive({\n selector: '[cngxMatPaginator]',\n exportAs: 'cngxMatPaginator',\n standalone: true,\n host: {\n // MatPaginator disables its nav buttons on busy but says nothing about why;\n // aria-busy on the host communicates the updating state to AT, reactively.\n '[attr.aria-busy]': 'paginate.isBusy()',\n },\n hostDirectives: [\n {\n directive: CngxPaginate,\n inputs: ['cngxPageIndex', 'cngxPageSize', 'total', 'state'],\n },\n ],\n})\nexport class CngxMatPaginator {\n private readonly matPaginator = inject(MatPaginator, { self: true });\n /**\n * The composed {@link CngxPaginate} brain. Public so a sibling list or table\n * outside the `<mat-paginator>` reads `range()` via `#ref=\"cngxMatPaginator\"`.\n */\n readonly paginate = inject(CngxPaginate);\n\n /** Options for the page-size selector. A Material-render concern, owned here. */\n readonly pageSizeOptions = input<number[]>([5, 10, 25]);\n\n /**\n * Reset key. When its value changes (after the initial render) the brain jumps\n * to the first page. Bind the sort / filter / search value a result set\n * depends on. Pass a primitive or a `computed` - an inline array / object\n * literal recomputes every change-detection pass and would reset every time.\n */\n readonly resetOn = input<unknown>(undefined, { alias: 'resetOn' });\n\n /**\n * Emits the effective page index on every change - navigation or a\n * `total`-shrink clamp - exactly once per change, through the shared\n * `connectPaginateEmit` guard. Clamp emits are held back while the brain is\n * busy or `total` is 0, matching the `CngxPaginator` shell.\n */\n readonly pageChange = output<number>();\n /** Emits the effective page size exactly once per change. */\n readonly pageSizeChange = output<number>();\n\n /**\n * Speak page changes through a visually-hidden `aria-live` region when set.\n * `booleanAttribute` transform, so static `announce` markup enables it.\n */\n readonly announce = input(false, { alias: 'announce', transform: booleanAttribute });\n\n /**\n * Builds the announcement string from the page/range context. When unbound,\n * the message resolves from the `CNGX_PAGINATOR_CONFIG` cascade\n * (`announcements.pageChange`, \"Page N of M\" in the EN defaults), so\n * `withPaginatorAnnouncements(...)` localises the bridge together with the\n * `CngxPaginator` organism. Bind this for a richer per-instance message\n * (the context also carries the visible item range).\n */\n readonly announceLabel = input<\n ((context: CngxMatPaginatorAnnounceContext) => string) | undefined\n >(undefined, { alias: 'announceLabel' });\n\n /**\n * Paginator config cascade - shared with the `CngxPaginator` organism, so\n * one `provideCngxPaginatorConfig(...)` localises both surfaces. Busy /\n * settle phrases stay unspoken here: the bridge communicates the updating\n * state via `aria-busy` on the host instead of a spoken transition.\n */\n private readonly announcements = injectPaginatorAnnouncements();\n\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly renderer = inject(Renderer2);\n private readonly destroyRef = inject(DestroyRef);\n\n /** The live-region message - derived, so it never drifts from brain state. */\n private readonly announceMessage = computed(() => {\n const page = this.paginate.pageIndex() + 1;\n const totalPages = this.paginate.totalPages();\n const custom = this.announceLabel();\n if (!custom) {\n return untracked(() => this.announcements().pageChange(page, totalPages));\n }\n const total = this.paginate.total();\n const start = total === 0 ? 0 : this.paginate.clampedRange()[0] + 1;\n const end = this.paginate.clampedRange()[1];\n return untracked(() => custom({ page, totalPages, start, end, total }));\n });\n\n private liveRegion: HTMLElement | null = null;\n\n constructor() {\n effect(() => {\n const length = this.paginate.total();\n const pageIndex = this.paginate.pageIndex();\n const pageSize = this.paginate.pageSize();\n const busy = this.paginate.isBusy();\n const options = this.pageSizeOptions();\n untracked(() => {\n // `length` and `pageIndex` setters self-call markForCheck on\n // MatPaginator's OnPush view; writing them every run dirties the view\n // so the non-self-dirtying writes below flush in the same re-render -\n // including the disabled-only case where busy flips while page and\n // total hold. `pageSize` is written before `pageSizeOptions` so the\n // displayed-options merge keeps the active size selectable.\n this.matPaginator.length = length;\n this.matPaginator.pageSize = pageSize;\n this.matPaginator.pageSizeOptions = options;\n this.matPaginator.pageIndex = pageIndex;\n this.matPaginator.disabled = busy;\n });\n });\n\n this.matPaginator.page.pipe(takeUntilDestroyed()).subscribe((event: PageEvent) => {\n // setPageSize(..., false) suppresses the implicit page reset so the\n // explicit setPage below lands the index mat-paginator already computed.\n // No property setter emits `page`, so these brain writes never re-enter\n // through this subscription; the path is loop-free without an echo guard.\n this.paginate.setPageSize(event.pageSize, false);\n this.paginate.setPage(event.pageIndex);\n });\n\n // Exactly-once output wiring, shared verbatim with the CngxPaginator shell\n // and CngxIncrementalList. A raw hostDirectives alias of the brain outputs\n // would bypass the shared last-emitted guard: setPageSize fires on every\n // PageEvent, so each page click would also emit a spurious pageSizeChange,\n // and a total-shrink clamp would move the page with no emission at all.\n connectPaginateEmit(this.paginate, {\n onIndex: (index) => this.pageChange.emit(index),\n onSize: (size) => this.pageSizeChange.emit(size),\n });\n\n // Reset-on-change, shared verbatim with the shell input and the generic\n // [cngxPaginateResetOn] directive.\n connectPaginateResetOn(this.paginate, this.resetOn);\n\n // AT announcement. The region is created lazily on first opt-in, then its\n // text tracks the derived message. textContent is written through the\n // renderer so it stays SSR-safe. Flipping [announce] off empties the\n // mounted region - a stale last message would otherwise linger in the\n // accessibility tree.\n effect(() => {\n if (!this.announce()) {\n untracked(() => {\n if (this.liveRegion) {\n this.renderer.setProperty(this.liveRegion, 'textContent', '');\n }\n });\n return;\n }\n const message = this.announceMessage();\n untracked(() => {\n this.liveRegion ??= this.createLiveRegion();\n this.renderer.setProperty(this.liveRegion, 'textContent', message);\n });\n });\n\n this.destroyRef.onDestroy(() => this.liveRegion?.remove());\n }\n\n /** A visually-hidden polite live region appended to the host paginator. */\n private createLiveRegion(): HTMLElement {\n const span = this.renderer.createElement('span') as HTMLElement;\n this.renderer.addClass(span, 'cngx-mat-paginator-live');\n this.renderer.setAttribute(span, 'aria-live', 'polite');\n this.renderer.setAttribute(span, 'aria-atomic', 'true');\n this.renderer.setAttribute(span, 'role', 'status');\n // Inline sr-only - the bridge ships no stylesheet, so it cannot rely on a\n // visually-hidden class being present in the consumer's CSS.\n for (const [prop, value] of [\n ['position', 'absolute'],\n ['width', '1px'],\n ['height', '1px'],\n ['margin', '-1px'],\n ['padding', '0'],\n ['overflow', 'hidden'],\n ['clip', 'rect(0 0 0 0)'],\n ['clip-path', 'inset(50%)'],\n ['white-space', 'nowrap'],\n ['border', '0'],\n ]) {\n this.renderer.setStyle(span, prop, value);\n }\n this.renderer.appendChild(this.elementRef.nativeElement, span);\n return span;\n }\n}\n","/**\n * @module @cngx/ui/mat-paginator\n *\n * Material instrumentation for `<mat-paginator>`: the `[cngxMatPaginator]` bridge\n * `CngxMatPaginator` adopts an existing `<mat-paginator>` in place, letting the\n * signal-native `CngxPaginate` brain drive its state with no DOM rewrite. It adds\n * `[resetOn]` (reset to first on upstream change) and `[announce]` (live-region\n * page announcements).\n *\n * The brain-level `CngxPaginateResetOn` / `CngxPaginateRouting` companion\n * directives (deep-link / reset for any `cngxPaginate` host) live in\n * `@cngx/common/data`; they are re-exported here for discoverability alongside\n * the bridge.\n */\nexport {\n CngxMatPaginator,\n type CngxMatPaginatorAnnounceContext,\n} from './mat-paginator-bridge.directive';\nexport { CngxPaginateResetOn, CngxPaginateRouting } from '@cngx/common/data';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDG;MAiBU,gBAAgB,CAAA;IACV,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACpE;;;AAGG;AACM,IAAA,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC;;IAG/B,eAAe,GAAG,KAAK,CAAW,CAAC,CAAC,EAAE,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AA,cAAc,EAAE;AACd,wBAAA;AACE,4BAAA,SAAS,EAAE,YAAY;4BACvB,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC;AAC5D,yBAAA;AACF,qBAAA;AACF,iBAAA;;;ACzGD;;;;;;;;;;;;;AAaG;;ACbH;;AAEG;;;;"}
1
+ {"version":3,"file":"cngx-ui-mat-paginator.mjs","sources":["../../../projects/ui/mat-paginator/mat-paginator-bridge.directive.ts","../../../projects/ui/mat-paginator/public-api.ts","../../../projects/ui/mat-paginator/cngx-ui-mat-paginator.ts"],"sourcesContent":["import {\n booleanAttribute,\n computed,\n DestroyRef,\n Directive,\n effect,\n ElementRef,\n inject,\n input,\n output,\n Renderer2,\n untracked,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { MatPaginator, type PageEvent } from '@angular/material/paginator';\nimport { CngxPaginate, connectPaginateEmit, connectPaginateResetOn } from '@cngx/common/data';\nimport { injectPaginatorAnnouncements } from '@cngx/ui/paginator';\n\n/**\n * Context handed to {@link CngxMatPaginator.announceLabel} to build the\n * screen-reader announcement after each page / page-size change.\n */\nexport interface CngxMatPaginatorAnnounceContext {\n /** 1-based current page. */\n readonly page: number;\n /** Total page count (minimum 1). */\n readonly totalPages: number;\n /** 1-based index of the first item on the page. */\n readonly start: number;\n /** 1-based index of the last item on the page, capped at `total`. */\n readonly end: number;\n /** Total item count before pagination. */\n readonly total: number;\n}\n\n/**\n * The in-place adoption half of the Material paginator instrumentation: add\n * `cngxMatPaginator` to an existing `<mat-paginator>` and the signal-native\n * {@link CngxPaginate} brain takes over its state with no DOM rewrite, mirroring\n * `[cngxMatStepper]` / `[cngxMatTabs]`.\n *\n * The bridge composes the untouched brain via `hostDirectives`, injects the\n * consumer's own `MatPaginator` with `{ self: true }`, and syncs the four\n * Material properties (`length` / `pageIndex` / `pageSize` / `disabled`) plus\n * `pageSizeOptions` against the brain's `computed()` graph, forwarding `(page)`\n * back into the brain.\n *\n * Beyond plain `<mat-paginator>`, the bridge adds:\n * - `[resetOn]` - jump to the first page whenever a bound key (a sort / filter /\n * search value) changes, so a filtered result set never strands the user on a\n * now-empty page. Pass a primitive (or a `computed` string key); an inline\n * array literal recomputes every change-detection pass and would reset on each.\n * - `[announce]` - mount a visually-hidden `aria-live` region that speaks the\n * page after every change; `<mat-paginator>` only relabels its own range\n * text, which AT does not announce. Phrasing resolves from the shared\n * `CNGX_PAGINATOR_CONFIG` cascade (`announcements.pageChange`), so app-wide\n * localisation covers the bridge and the organism together; bind\n * `[announceLabel]` for a richer per-instance message with the visible range.\n * - `[cngxPaginateRouting]` (generic companion directive from `@cngx/common/data`)\n * - persist the page / size in the URL query string for deep-linkable,\n * back-button-safe pagination.\n *\n * ```html\n * <mat-paginator\n * cngxMatPaginator\n * #pg=\"cngxMatPaginator\"\n * [total]=\"items.length\"\n * [pageSizeOptions]=\"[5, 10, 25]\"\n * />\n * <ul>\n * @for (item of items.slice(pg.paginate.range()[0], pg.paginate.range()[1]); track item.id) {\n * <li>{{ item.label }}</li>\n * }\n * </ul>\n * ```\n *\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-paginator/mat-paginator-bridge.directive.ts\n * @since 0.3.0\n * @relatedTo CngxPaginate, CngxMatStepper, CngxPaginator\n * <example-url>/#/ui/mat-paginator/bridge-announce-page-changes</example-url>\n * <example-url>/#/ui/mat-paginator/instrumentation-bridge-cngxmatpaginator</example-url>\n * @axis level molecule\n */\n@Directive({\n selector: '[cngxMatPaginator]',\n exportAs: 'cngxMatPaginator',\n standalone: true,\n host: {\n // MatPaginator disables its nav buttons on busy but says nothing about why;\n // aria-busy on the host communicates the updating state to AT, reactively.\n '[attr.aria-busy]': 'paginate.isBusy()',\n },\n hostDirectives: [\n {\n directive: CngxPaginate,\n inputs: ['cngxPageIndex', 'cngxPageSize', 'total', 'state'],\n },\n ],\n})\nexport class CngxMatPaginator {\n private readonly matPaginator = inject(MatPaginator, { self: true });\n /**\n * The composed {@link CngxPaginate} brain. Public so a sibling list or table\n * outside the `<mat-paginator>` reads `range()` via `#ref=\"cngxMatPaginator\"`.\n */\n readonly paginate = inject(CngxPaginate);\n\n /** Options for the page-size selector. A Material-render concern, owned here. */\n readonly pageSizeOptions = input<number[]>([5, 10, 25]);\n\n /**\n * Reset key. When its value changes (after the initial render) the brain jumps\n * to the first page. Bind the sort / filter / search value a result set\n * depends on. Pass a primitive or a `computed` - an inline array / object\n * literal recomputes every change-detection pass and would reset every time.\n */\n readonly resetOn = input<unknown>(undefined, { alias: 'resetOn' });\n\n /**\n * Emits the effective page index on every change - navigation or a\n * `total`-shrink clamp - exactly once per change, through the shared\n * `connectPaginateEmit` guard. Clamp emits are held back while the brain is\n * busy or `total` is 0, matching the `CngxPaginator` shell.\n */\n readonly pageChange = output<number>();\n /** Emits the effective page size exactly once per change. */\n readonly pageSizeChange = output<number>();\n\n /**\n * Speak page changes through a visually-hidden `aria-live` region when set.\n * `booleanAttribute` transform, so static `announce` markup enables it.\n */\n readonly announce = input(false, { alias: 'announce', transform: booleanAttribute });\n\n /**\n * Builds the announcement string from the page/range context. When unbound,\n * the message resolves from the `CNGX_PAGINATOR_CONFIG` cascade\n * (`announcements.pageChange`, \"Page N of M\" in the EN defaults), so\n * `withPaginatorAnnouncements(...)` localises the bridge together with the\n * `CngxPaginator` organism. Bind this for a richer per-instance message\n * (the context also carries the visible item range).\n */\n readonly announceLabel = input<\n ((context: CngxMatPaginatorAnnounceContext) => string) | undefined\n >(undefined, { alias: 'announceLabel' });\n\n /**\n * Paginator config cascade - shared with the `CngxPaginator` organism, so\n * one `provideCngxPaginatorConfig(...)` localises both surfaces. Busy /\n * settle phrases stay unspoken here: the bridge communicates the updating\n * state via `aria-busy` on the host instead of a spoken transition.\n */\n private readonly announcements = injectPaginatorAnnouncements();\n\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly renderer = inject(Renderer2);\n private readonly destroyRef = inject(DestroyRef);\n\n /** The live-region message - derived, so it never drifts from brain state. */\n private readonly announceMessage = computed(() => {\n const page = this.paginate.pageIndex() + 1;\n const totalPages = this.paginate.totalPages();\n const custom = this.announceLabel();\n if (!custom) {\n return untracked(() => this.announcements().pageChange(page, totalPages));\n }\n const total = this.paginate.total();\n const start = total === 0 ? 0 : this.paginate.clampedRange()[0] + 1;\n const end = this.paginate.clampedRange()[1];\n return untracked(() => custom({ page, totalPages, start, end, total }));\n });\n\n private liveRegion: HTMLElement | null = null;\n\n constructor() {\n effect(() => {\n const length = this.paginate.total();\n const pageIndex = this.paginate.pageIndex();\n const pageSize = this.paginate.pageSize();\n const busy = this.paginate.isBusy();\n const options = this.pageSizeOptions();\n untracked(() => {\n // `length` and `pageIndex` setters self-call markForCheck on\n // MatPaginator's OnPush view; writing them every run dirties the view\n // so the non-self-dirtying writes below flush in the same re-render -\n // including the disabled-only case where busy flips while page and\n // total hold. `pageSize` is written before `pageSizeOptions` so the\n // displayed-options merge keeps the active size selectable.\n this.matPaginator.length = length;\n this.matPaginator.pageSize = pageSize;\n this.matPaginator.pageSizeOptions = options;\n this.matPaginator.pageIndex = pageIndex;\n this.matPaginator.disabled = busy;\n });\n });\n\n this.matPaginator.page.pipe(takeUntilDestroyed()).subscribe((event: PageEvent) => {\n // setPageSize(..., false) suppresses the implicit page reset so the\n // explicit setPage below lands the index mat-paginator already computed.\n // No property setter emits `page`, so these brain writes never re-enter\n // through this subscription; the path is loop-free without an echo guard.\n this.paginate.setPageSize(event.pageSize, false);\n this.paginate.setPage(event.pageIndex);\n });\n\n // Exactly-once output wiring, shared verbatim with the CngxPaginator shell\n // and CngxIncrementalList. A raw hostDirectives alias of the brain outputs\n // would bypass the shared last-emitted guard: setPageSize fires on every\n // PageEvent, so each page click would also emit a spurious pageSizeChange,\n // and a total-shrink clamp would move the page with no emission at all.\n connectPaginateEmit(this.paginate, {\n onIndex: (index) => this.pageChange.emit(index),\n onSize: (size) => this.pageSizeChange.emit(size),\n });\n\n // Reset-on-change, shared verbatim with the shell input and the generic\n // [cngxPaginateResetOn] directive.\n connectPaginateResetOn(this.paginate, this.resetOn);\n\n // AT announcement. The region is created lazily on first opt-in, then its\n // text tracks the derived message. textContent is written through the\n // renderer so it stays SSR-safe. Flipping [announce] off empties the\n // mounted region - a stale last message would otherwise linger in the\n // accessibility tree.\n effect(() => {\n if (!this.announce()) {\n untracked(() => {\n if (this.liveRegion) {\n this.renderer.setProperty(this.liveRegion, 'textContent', '');\n }\n });\n return;\n }\n const message = this.announceMessage();\n untracked(() => {\n this.liveRegion ??= this.createLiveRegion();\n this.renderer.setProperty(this.liveRegion, 'textContent', message);\n });\n });\n\n this.destroyRef.onDestroy(() => this.liveRegion?.remove());\n }\n\n /** A visually-hidden polite live region appended to the host paginator. */\n private createLiveRegion(): HTMLElement {\n const span = this.renderer.createElement('span') as HTMLElement;\n this.renderer.addClass(span, 'cngx-mat-paginator-live');\n this.renderer.setAttribute(span, 'aria-live', 'polite');\n this.renderer.setAttribute(span, 'aria-atomic', 'true');\n this.renderer.setAttribute(span, 'role', 'status');\n // Inline sr-only - the bridge ships no stylesheet, so it cannot rely on a\n // visually-hidden class being present in the consumer's CSS.\n for (const [prop, value] of [\n ['position', 'absolute'],\n ['width', '1px'],\n ['height', '1px'],\n ['margin', '-1px'],\n ['padding', '0'],\n ['overflow', 'hidden'],\n ['clip', 'rect(0 0 0 0)'],\n ['clip-path', 'inset(50%)'],\n ['white-space', 'nowrap'],\n ['border', '0'],\n ]) {\n this.renderer.setStyle(span, prop, value);\n }\n this.renderer.appendChild(this.elementRef.nativeElement, span);\n return span;\n }\n}\n","/**\n * @module `@cngx/ui/mat-paginator`\n *\n * Material instrumentation for `<mat-paginator>`: the `[cngxMatPaginator]` bridge\n * `CngxMatPaginator` adopts an existing `<mat-paginator>` in place, letting the\n * signal-native `CngxPaginate` brain drive its state with no DOM rewrite. It adds\n * `[resetOn]` (reset to first on upstream change) and `[announce]` (live-region\n * page announcements).\n *\n * The brain-level `CngxPaginateResetOn` / `CngxPaginateRouting` companion\n * directives (deep-link / reset for any `cngxPaginate` host) live in\n * `@cngx/common/data`; they are re-exported here for discoverability alongside\n * the bridge.\n */\nexport {\n CngxMatPaginator,\n type CngxMatPaginatorAnnounceContext,\n} from './mat-paginator-bridge.directive';\nexport { CngxPaginateResetOn, CngxPaginateRouting } from '@cngx/common/data';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDG;MAiBU,gBAAgB,CAAA;IACV,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACpE;;;AAGG;AACM,IAAA,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC;;IAG/B,eAAe,GAAG,KAAK,CAAW,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,iBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAEvD;;;;;AAKG;IACM,OAAO,GAAG,KAAK,CAAU,SAAS,+EAAI,KAAK,EAAE,SAAS,EAAA,CAAG;AAElE;;;;;AAKG;IACM,UAAU,GAAG,MAAM,EAAU;;IAE7B,cAAc,GAAG,MAAM,EAAU;AAE1C;;;AAGG;AACM,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,UAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,GAAG;AAEpF;;;;;;;AAOG;IACM,aAAa,GAAG,KAAK,CAE5B,SAAS,qFAAI,KAAK,EAAE,eAAe,EAAA,CAAG;AAExC;;;;;AAKG;IACc,aAAa,GAAG,4BAA4B,EAAE;AAE9C,IAAA,UAAU,G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AA,EAAA,EAAA,gBAAA,EAAA,mBAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,YAAA,EAAA,MAAA,EAAA,CAAA,eAAA,EAAA,eAAA,EAAA,cAAA,EAAA,cAAA,EAAA,OAAA,EAAA,OAAA,EAAA,OAAA,EAAA,OAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAhB5B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE;;;AAGJ,wBAAA,kBAAkB,EAAE,mBAAmB;AACxC,qBAAA;AACD,oBAAA,cAAc,EAAE;AACd,wBAAA;AACE,4BAAA,SAAS,EAAE,YAAY;4BACvB,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC;AAC5D,yBAAA;AACF,qBAAA;AACF,iBAAA;;;ACnGD;;;;;;;;;;;;;AAaG;;ACbH;;AAEG;;;;"}
@@ -147,8 +147,6 @@ function readMatStepLabelTemplateText(template) {
147
147
  * pattern.
148
148
  * - `errorAggregator` - points at the shared
149
149
  * {@link NO_ERROR_AGGREGATOR} constant.
150
- *
151
- * @category ui/mat-stepper
152
150
  */
153
151
  function createMatStepHandle(matStep, idSeed, i18n) {
154
152
  const id = idSeed();
@@ -236,10 +234,9 @@ function resolveMaterialStepLabel(matStep) {
236
234
  * ]
237
235
  * ```
238
236
  *
239
- * @category ui/mat-stepper
240
237
  * @wcag AA
241
238
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/material-bridge/handle.ts
242
- * @since 0.1.0
239
+ * @since 0.3.0
243
240
  */
244
241
  const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FACTORY', {
245
242
  providedIn: 'root',
@@ -265,7 +262,7 @@ const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FA
265
262
  * Commit-lifecycle transitions speak: the shared announcement builder
266
263
  * feeds the root live announcer (pending / landed / rolled-back
267
264
  * phrases, identical to `<cngx-stepper>`), and the host carries
268
- * `aria-busy="true"` while a commit is in flight.
265
+ * `aria-busy="true"` while a commit or the finish run is in flight.
269
266
  *
270
267
  * Inputs/outputs are forwarded from {@link CngxStepperPresenter}:
271
268
  * - `activeStepIndex` (two-way, with `activeStepIndexChange`),
@@ -305,12 +302,12 @@ const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FA
305
302
  * ```
306
303
  * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
307
304
  *
308
- * @category ui/mat-stepper
309
- * @docsKind primary
310
305
  * @wcag AA
311
306
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts
312
- * @since 0.1.0
307
+ * @since 0.3.0
313
308
  * @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter
309
+ * <example-url>/#/ui/mat-stepper/stepper-footer/mat-stepper-footer</example-url>
310
+ * @axis level organism
314
311
  */
315
312
  class CngxMatStepper {
316
313
  matStepper = inject(MatStepper, { self: true });
@@ -403,7 +400,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
403
400
  * commit-action lifecycle, router sync, and error aggregation all work
404
401
  * against Material's own markup. Mirrors `[cngxMatTabs]`.
405
402
  *
406
- * @module @cngx/ui/mat-stepper
403
+ * @module `@cngx/ui/mat-stepper`
407
404
  */
408
405
 
409
406
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cngx-ui-mat-stepper.mjs","sources":["../../../projects/ui/mat-stepper/material-bridge/bidirectional-sync.ts","../../../projects/ui/mat-stepper/material-bridge/handle.ts","../../../projects/ui/mat-stepper/mat-stepper.directive.ts","../../../projects/ui/mat-stepper/public-api.ts","../../../projects/ui/mat-stepper/cngx-ui-mat-stepper.ts"],"sourcesContent":["import type { DestroyRef, Injector } from '@angular/core';\nimport type { MatStepper } from '@angular/material/stepper';\n\nimport { createMaterialBidirectionalSync } from '@cngx/common/data';\nimport type { CngxStepperHost } from '@cngx/common/stepper';\n\n/**\n * Options for {@link createMatStepperBidirectionalSync}.\n *\n * @internal\n */\nexport interface CngxMatStepperBidirectionalSyncOptions {\n /** Material stepper the helper bridges against. */\n readonly matStepper: MatStepper;\n /** cngx stepper presenter - write target for Material→presenter. */\n readonly presenter: CngxStepperHost;\n /** Injection context for the underlying `effect()` in `@cngx/common/data`. */\n readonly injector: Injector;\n /**\n * Destroy ref the underlying subscriber teardown attaches to.\n * Same lifetime as the host directive / component.\n */\n readonly destroyRef: DestroyRef;\n}\n\n/**\n * Stepper-specific glue over {@link createMaterialBidirectionalSync}\n * (`@cngx/common/data`). Both `<cngx-mat-stepper>` (Component) and\n * `[cngxMatStepper]` (Directive) need to install the same\n * presenter↔Material `selectedIndex` sync; the option-mapping body\n * was identical at both call sites - same `presenterIndex`, same\n * `readSelectedIndex` / `writeSelectedIndex` shape, same\n * `selectedIndexChange.asObservable()` source, same\n * `onMaterialSelection` write-back. This helper is the single entry\n * point: each call site reduces to one line.\n *\n * Behaviour stays identical to the prior inline blocks - the helper\n * is a pure shape-adapter, no policy. The underlying generic factory\n * owns:\n * - presenter→Material `effect()` with read-equality guard.\n * - Material→presenter subscription with re-entrancy guard.\n * - Material-eager-advance reconciliation (Material's MDC click\n * handler advances `selectedIndex` synchronously before the\n * bidirectional sync sees the event).\n * - `destroyRef` cleanup of both directions.\n *\n * @internal\n */\nexport function createMatStepperBidirectionalSync(\n opts: CngxMatStepperBidirectionalSyncOptions,\n): void {\n createMaterialBidirectionalSync({\n presenterIndex: opts.presenter.activeStepIndex,\n readSelectedIndex: () => opts.matStepper.selectedIndex,\n writeSelectedIndex: (i) => {\n opts.matStepper.selectedIndex = i;\n },\n // `MatStepper.selectedIndexChange` emits a plain index - no adapter needed,\n // unlike `MatTabGroup.selectedIndexChange`.\n selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),\n onMaterialSelection: (i) => opts.presenter.select(i),\n injector: opts.injector,\n destroyRef: opts.destroyRef,\n });\n}\n","import { computed, InjectionToken, signal, type Signal, type TemplateRef } from '@angular/core';\nimport type { MatStep } from '@angular/material/stepper';\n\nimport type { CngxErrorAggregatorContract } from '@cngx/common/interactive';\nimport {\n type CngxStepperI18n,\n type CngxStepRegistration,\n type CngxStepStatus,\n} from '@cngx/common/stepper';\n\n/**\n * Shared `signal(undefined)` constant used as the `errorAggregator`\n * slot for every Material-instrumented step handle. The\n * instrumentation path does not bind cngx error-aggregation per\n * `MatStep` - Material's own visual error surface (driven by\n * `MatStep.hasError` / `MatStep.optional`) stays authoritative - so\n * per-step allocation of a writable signal would be dead capacity.\n *\n * @internal\n */\nconst NO_ERROR_AGGREGATOR: Signal<CngxErrorAggregatorContract | undefined> = signal<\n CngxErrorAggregatorContract | undefined\n>(undefined).asReadonly();\n\n/**\n * Wiring bundle returned from {@link createMatStepHandle}. The\n * instrumentation directive holds the bundle in a `Map<MatStep,\n * Setup>` for diff-only registry churn; only `handle` is exposed to\n * the presenter.\n */\nexport interface CngxMatStepHandleSetup {\n readonly handle: CngxStepRegistration;\n}\n\n/**\n * Best-effort static-text extraction from a `<ng-template matStepLabel>`\n * `TemplateRef`. Used as a label fallback when consumers project a\n * template label without setting `MatStep.label` or\n * `MatStep.ariaLabel` - without it the cngx-side label slot would\n * be empty, leaving aria-label phrases that include the step label\n * with a measurable gap on the Material variant. Static markup\n * (`<ng-template matStepLabel>Review</ng-template>`) extracts cleanly\n * via a detached embedded view; templates with dynamic interpolation\n * fall through (the detached view's CD has no consumer-context\n * bindings) and the caller's deterministic id-based fallback wins.\n *\n * Idempotent: never mutates the source template; the embedded view is\n * created and destroyed inside one frame's worth of synchronous work.\n *\n * @internal\n */\nfunction readMatStepLabelTemplateText(template: TemplateRef<unknown>): string | undefined {\n try {\n const view = template.createEmbeddedView({});\n try {\n view.detectChanges();\n const text = view.rootNodes\n .map((node: Node) => node.textContent ?? '')\n .join('')\n .trim();\n return text || undefined;\n } finally {\n view.destroy();\n }\n } catch {\n return undefined;\n }\n}\n\n/**\n * Translates a Material `MatStep` into a cngx\n * {@link CngxStepRegistration}.\n *\n * - `id` - always a fresh `idSeed()` value. Mirrors the tabs\n * instrumentation handle: a label-keyed id would collide when\n * two steps share a label.\n * - `kind` - fixed at `'step'`. The instrumentation path does not\n * project nested `<mat-step>` groups (Material's stepper has no\n * group-of-steps concept; group-aware semantics belong to the\n * `<cngx-stepper>` thin-wrapper organism).\n * - `label` - snapshot signal resolved through a four-tier fallback at\n * registration time so cngx-side phrases (announcements,\n * `aria-label` composition, telemetry) never read empty when\n * Material consumers project a `<ng-template matStepLabel>`:\n * 1. `MatStep.label` when it is a plain string - the canonical\n * shape and the only one that emits a runtime change Material\n * itself observes.\n * 2. `MatStep.ariaLabel` when the consumer set the input -\n * designed exactly as the substitute for template labels.\n * 3. Static-text read from `MatStep.stepLabel.template` via a\n * throwaway detached `EmbeddedViewRef` ({@link readMatStepLabelTemplateText}).\n * Captures literal `matStepLabel` markup; dynamic interpolation\n * bails through to (4).\n * 4. `CNGX_STEPPER_I18N.stepFallbackLabel(id)` (English default\n * `Step <id>`) - deterministic, derived from the cngx handle id.\n * Always non-empty. The `[cngxMatStepper]` directive passes its\n * injected bundle Signal as `i18n`. This tier follows a runtime\n * language switch.\n * Documented limitation: runtime changes of tiers 1-3 do not propagate.\n * CDK's `CdkStep` does not expose a `_stateChanges` Subject\n * analogous to `MatTab._stateChanges`, so cngx cannot re-trigger\n * the snapshot when Material flips the input later. Surface the\n * same Material-internal coupling family typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`.\n * - `disabled` - fixed `false`. Material owns step gating via\n * `linear` + `editable` + `completed`; surfacing a cngx-side\n * `disabled` would duplicate Material's own click-time enforcement\n * and is ignored by `<mat-stepper>` itself.\n * - `state` - `computed()` over `MatStep.hasError` / `MatStep.completed`.\n * `CdkStep.completed`'s getter reads `_completedOverride()` - a\n * `WritableSignal<boolean | null>` typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`. The cngx\n * computed transitively tracks that signal through the getter and\n * re-fires whenever Material flips completion. `hasError` is a\n * plain property setter on `CdkStep`, NOT a Signal - a `hasError`\n * write that is not paired with a `completed` change does not\n * re-trigger this computed. In practice Material wizards write the\n * two together (`step.hasError = true; step.completed = false` in\n * error-handler patterns and inside Material's own error-state\n * matchers) so the limitation is benign for the documented usage\n * pattern.\n * - `errorAggregator` - points at the shared\n * {@link NO_ERROR_AGGREGATOR} constant.\n *\n * @category ui/mat-stepper\n */\nexport function createMatStepHandle(\n matStep: MatStep,\n idSeed: () => string,\n i18n: Signal<CngxStepperI18n>,\n): CngxMatStepHandleSetup {\n const id = idSeed();\n const labelText = resolveMaterialStepLabel(matStep);\n const label =\n labelText !== null\n ? signal<string>(labelText).asReadonly()\n : computed<string>(() => i18n().stepFallbackLabel(id));\n const disabled = signal<boolean>(false).asReadonly();\n const state = computed<CngxStepStatus>(() => {\n if (matStep.hasError) {\n return 'error';\n }\n if (matStep.completed) {\n return 'success';\n }\n return 'idle';\n });\n return {\n handle: {\n id,\n kind: 'step',\n label,\n disabled,\n state,\n errorAggregator: NO_ERROR_AGGREGATOR,\n },\n };\n}\n\n/**\n * Tiers 1-3 of the label fallback, walked once at registration time, or\n * `null` when tier 4 (the i18n fallback) applies. See the\n * {@link createMatStepHandle} JSDoc for the full ladder rationale.\n *\n * @internal\n */\nfunction resolveMaterialStepLabel(matStep: MatStep): string | null {\n const labelInput = matStep.label;\n if (typeof labelInput === 'string' && labelInput.length > 0) {\n return labelInput;\n }\n const ariaLabel = matStep.ariaLabel;\n if (typeof ariaLabel === 'string' && ariaLabel.length > 0) {\n return ariaLabel;\n }\n const tpl = matStep.stepLabel?.template;\n if (!tpl) {\n return null;\n }\n const text = readMatStepLabelTemplateText(tpl);\n if (!text) {\n return null;\n }\n return text;\n}\n\n/**\n * Factory signature for {@link createMatStepHandle}. The DI token\n * {@link CNGX_MAT_STEP_HANDLE_FACTORY} resolves to a function with\n * this exact shape - overrides match it identically.\n *\n * The third argument is the stepper i18n Signal the directive injected;\n * it carries the last-resort label (`stepFallbackLabel`). Forward it when\n * delegating to {@link createMatStepHandle}.\n *\n * @category ui/mat-stepper\n */\nexport type CngxMatStepHandleFactory = typeof createMatStepHandle;\n\n/**\n * DI token fronting the per-step handle factory used by the\n * `[cngxMatStepper]` instrumentation directive. Default is\n * {@link createMatStepHandle}.\n *\n * Symmetric with the tabs sibling\n * `CNGX_MAT_TAB_HANDLE_FACTORY` and with `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`\n * - every Material-bridge logic block ships the same swap surface so\n * consumers can layer telemetry, alternate id strategies, or\n * test-environment id keying via `providers` / `viewProviders`\n * without forking the directive.\n *\n * Override capability - the swap surface separates **handle shape**\n * (factory body) from **id keying** (the supplied `idSeed` closure).\n * The directive constructs `idSeed` as `() => nextUid('cngx-mat-step-')`\n * and hands it to the factory as a default suggestion; an override is\n * free to call it, ignore it, or replace it with a server-synced /\n * deterministic-test / consumer-domain id strategy. Both axes are\n * independently swappable from one DI seam.\n *\n * ```ts\n * providers: [\n * {\n * provide: CNGX_MAT_STEP_HANDLE_FACTORY,\n * useValue: ((step, idSeed, i18n) => {\n * const setup = createMatStepHandle(step, idSeed, i18n);\n * reportStepRegistered(setup.handle.id);\n * return setup;\n * }) satisfies CngxMatStepHandleFactory,\n * },\n * ]\n * ```\n *\n * @category ui/mat-stepper\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/material-bridge/handle.ts\n * @since 0.1.0\n */\nexport const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken<CngxMatStepHandleFactory>(\n 'CNGX_MAT_STEP_HANDLE_FACTORY',\n {\n providedIn: 'root',\n factory: () => createMatStepHandle,\n },\n);\n","import {\n contentChildren,\n type DestroyRef,\n Directive,\n effect,\n inject,\n type Injector,\n untracked,\n DestroyRef as InjectableDestroyRef,\n Injector as InjectableInjector,\n} from '@angular/core';\nimport { MatStep, MatStepper } from '@angular/material/stepper';\n\nimport {\n CNGX_STEPPER_HOST,\n CngxStepperPresenter,\n createStepperAnnouncementBuilders,\n injectStepperI18n,\n} from '@cngx/common/stepper';\nimport { nextUid } from '@cngx/core/utils';\n\nimport { createOrderedRegistrationSeam, mountLiveRegionAnnouncer } from '@cngx/ui/mat-tabs';\nimport { createMatStepperBidirectionalSync } from './material-bridge/bidirectional-sync';\nimport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n type CngxMatStepHandleSetup,\n} from './material-bridge/handle';\n\n/**\n * The Material twin of the CNGX stepper: attach `cngxMatStepper` to a\n * vanilla `<mat-stepper>` and it is bridged to a\n * {@link CngxStepperPresenter}. \\\n * Consumers gain the commit-action\n * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /\n * `<cngx-banner-on />` compose as children), the shared\n * `CNGX_STEPPER_HOST` contract (so a `<cngx-stepper-footer>` can drive\n * Back / Next instead of Material's own buttons via\n * `[host]=\"ref.presenter\"`), and the step-handle registry - all from\n * one attribute.\n *\n * This is the instrumentation pattern: Material owns the rendering and\n * the consumer authors native `<mat-step>` markup; CNGX is the\n * behaviour layer. Topology mirrors `[cngxMatTabs]`.\n *\n * Commit-lifecycle transitions speak: the shared announcement builder\n * feeds the root live announcer (pending / landed / rolled-back\n * phrases, identical to `<cngx-stepper>`), and the host carries\n * `aria-busy=\"true\"` while a commit is in flight.\n *\n * Inputs/outputs are forwarded from {@link CngxStepperPresenter}:\n * - `activeStepIndex` (two-way, with `activeStepIndexChange`),\n * - `linear`,\n * - `orientation`,\n * - `commitAction`,\n * - `commitMode`. \\\n * See the presenter for their semantics.\n * ```html\n * <mat-stepper\n * cngxMatStepper\n * #s=\"cngxMatStepper\"\n * [(activeStepIndex)]=\"active\"\n * [commitAction]=\"commitAction\"\n * [commitMode]=\"mode()\"\n * cngxToastOn\n * [toastError]=\"'Step transition failed'\"\n * cngxBannerOn\n * bannerId=\"stepper:commit-error\"\n * [bannerError]=\"'The server rejected the step change.'\"\n * aria-label=\"Account setup\"\n * >\n * <mat-step label=\"Personal info\">\n * <p>Tell us who you are.</p>\n * </mat-step>\n * <mat-step\n * label=\"Account\"\n * [hasError]=\"!accepted()\"\n * errorMessage=\"Accept the terms to continue\"\n * >\n * <p>Choose your sign-in method.</p>\n * </mat-step>\n * <mat-step label=\"Confirm\">\n * <p>Review everything, then finish.</p>\n * </mat-step>\n * </mat-stepper>\n * ```\n * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts\n *\n * @category ui/mat-stepper\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts\n * @since 0.1.0\n * @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter\n */\n@Directive({\n selector: '[cngxMatStepper]',\n exportAs: 'cngxMatStepper',\n standalone: true,\n hostDirectives: [\n {\n directive: CngxStepperPresenter,\n inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],\n outputs: ['activeStepIndexChange'],\n },\n ],\n host: {\n // Communicated busy-state while a commit is in flight - same\n // strict 'pending' gate the cngx-native organism uses per step.\n '[attr.aria-busy]': \"presenter.busy() ? 'true' : null\",\n },\n})\nexport class CngxMatStepper {\n private readonly matStepper = inject(MatStepper, { self: true });\n /**\n * Shared host contract. Public so a `<cngx-stepper-footer>` placed\n * outside the `<mat-stepper>` can bind `[host]=\"ref.presenter\"` (via\n * `#ref=\"cngxMatStepper\"`) and drive navigation.\n */\n readonly presenter = inject(CNGX_STEPPER_HOST);\n private readonly destroyRef: DestroyRef = inject(InjectableDestroyRef);\n private readonly injector: Injector = inject(InjectableInjector);\n\n private readonly matSteps = contentChildren(MatStep, { descendants: true });\n private readonly createHandle = inject(CNGX_MAT_STEP_HANDLE_FACTORY);\n private readonly i18n = injectStepperI18n();\n\n // Shared with [cngxMatTabsRegistry]: the presenter registry appends\n // new registrations, but Material renders steps at their DOM\n // position - a mid-list <mat-step> insert must land at its query\n // index, not at the tail. The seam re-registers the diverging\n // suffix in query order while keeping surviving handle instances.\n private readonly seam = createOrderedRegistrationSeam<MatStep, CngxMatStepHandleSetup>({\n create: (step) => this.createHandle(step, () => nextUid('cngx-mat-step-'), this.i18n),\n register: (setup) => this.presenter.register(setup.handle),\n unregister: (setup) => this.presenter.unregister(setup.handle.id, setup.handle),\n dispose: () => {\n // Step setups carry no per-entry resources (no child injector).\n },\n });\n\n constructor() {\n effect(() => {\n // Ownership filter: `descendants: true` also surfaces MatSteps of\n // a stepper nested inside one of OUR steps' content. Each CdkStep\n // carries its owning `_stepper` (public in the CDK typings), so\n // foreign steps are dropped before they can register with this\n // presenter.\n const steps = this.matSteps().filter((step) => step._stepper === this.matStepper);\n untracked(() => this.seam.sync(steps));\n });\n\n this.destroyRef.onDestroy(() => this.seam.clear());\n\n // Commit-lifecycle announcements (pending / landed / rolled-back).\n // The shared builder computes the phrase; the shared announcer\n // renders it - an attribute directive owns no template, so the\n // polite region lives on the root CngxLiveAnnouncer, mirroring\n // [cngxMatTabs].\n mountLiveRegionAnnouncer({\n announcement: createStepperAnnouncementBuilders({\n presenter: this.presenter,\n stepsOnly: this.presenter.stepsOnly,\n i18n: this.i18n,\n }).liveAnnouncement,\n injector: this.injector,\n });\n\n createMatStepperBidirectionalSync({\n matStepper: this.matStepper,\n presenter: this.presenter,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n }\n}\n","/**\n * Public API surface of `@cngx/ui/mat-stepper`.\n *\n * The Material twin of the cngx stepper family, shipped as the\n * instrumentation directive `[cngxMatStepper]`: attach it to a vanilla\n * `<mat-stepper>` and it composes the same `CngxStepperPresenter` brain\n * as `<cngx-stepper>` (in `@cngx/ui/stepper`) via `hostDirectives`, so\n * commit-action lifecycle, router sync, and error aggregation all work\n * against Material's own markup. Mirrors `[cngxMatTabs]`.\n *\n * @module @cngx/ui/mat-stepper\n */\nexport { CngxMatStepper } from './mat-stepper.directive';\nexport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n createMatStepHandle,\n type CngxMatStepHandleFactory,\n type CngxMatStepHandleSetup,\n} from './material-bridge/handle';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["InjectableDestroyRef","InjectableInjector"],"mappings":";;;;;;;;;AAyBA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,iCAAiC,CAC/C,IAA4C,EAAA;AAE5C,IAAA,+BAA+B,CAAC;AAC9B,QAAA,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe;QAC9C,iBAAiB,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa;AACtD,QAAA,kBAAkB,EAAE,CAAC,CAAC,KAAI;AACxB,YAAA,IAAI,CAAC,UAAU,CAAC,aAAa,GAAG,CAAC;QACnC,CAAC;;;QAGD,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,YAAY,EAAE;AACpE,QAAA,mBAAmB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC5B,KAAA,CAAC;AACJ;;ACtDA;;;;;;;;;AASG;AACH,MAAM,mBAAmB,GAAoD,MAAM,CAEjF,SAAS,CAAC,CAAC,UAAU,EAAE;AAYzB;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,4BAA4B,CAAC,QAA8B,EAAA;AAClE,IAAA,IAAI;QACF,MAAM,IAAI,GAAG,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YAAY,CAAC;4BAClF,OAAO,EAAE,CAAC,uBAAuB,CAAC;AACnC,yBAAA;AACF,qBAAA;AACD,oBAAA,IAAI,EAAE;;;AAGJ,wBAAA,kBAAkB,EAAE,kCAAkC;AACvD,qBAAA;AACF,iBAAA;AAY6C,SAAA,CAAA,EAAA,cAAA,EAAA,MAAA,EAAA,EAAA,cAAA,EAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,eAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA,OAAO,CAAA,EAAA,EAAA,GAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AC1H5E;;;;;;;;;;;AAWG;;ACXH;;AAEG;;;;"}
1
+ {"version":3,"file":"cngx-ui-mat-stepper.mjs","sources":["../../../projects/ui/mat-stepper/material-bridge/bidirectional-sync.ts","../../../projects/ui/mat-stepper/material-bridge/handle.ts","../../../projects/ui/mat-stepper/mat-stepper.directive.ts","../../../projects/ui/mat-stepper/public-api.ts","../../../projects/ui/mat-stepper/cngx-ui-mat-stepper.ts"],"sourcesContent":["import type { DestroyRef, Injector } from '@angular/core';\nimport type { MatStepper } from '@angular/material/stepper';\n\nimport { createMaterialBidirectionalSync } from '@cngx/common/data';\nimport type { CngxStepperHost } from '@cngx/common/stepper';\n\n/**\n * Options for {@link createMatStepperBidirectionalSync}.\n *\n * @internal\n */\nexport interface CngxMatStepperBidirectionalSyncOptions {\n /** Material stepper the helper bridges against. */\n readonly matStepper: MatStepper;\n /** cngx stepper presenter - write target for Material→presenter. */\n readonly presenter: CngxStepperHost;\n /** Injection context for the underlying `effect()` in `@cngx/common/data`. */\n readonly injector: Injector;\n /**\n * Destroy ref the underlying subscriber teardown attaches to.\n * Same lifetime as the host directive / component.\n */\n readonly destroyRef: DestroyRef;\n}\n\n/**\n * Stepper-specific glue over {@link createMaterialBidirectionalSync}\n * (`@cngx/common/data`). Both `<cngx-mat-stepper>` (Component) and\n * `[cngxMatStepper]` (Directive) need to install the same\n * presenter↔Material `selectedIndex` sync; the option-mapping body\n * was identical at both call sites - same `presenterIndex`, same\n * `readSelectedIndex` / `writeSelectedIndex` shape, same\n * `selectedIndexChange.asObservable()` source, same\n * `onMaterialSelection` write-back. This helper is the single entry\n * point: each call site reduces to one line.\n *\n * Behaviour stays identical to the prior inline blocks - the helper\n * is a pure shape-adapter, no policy. The underlying generic factory\n * owns:\n * - presenter→Material `effect()` with read-equality guard.\n * - Material→presenter subscription with re-entrancy guard.\n * - Material-eager-advance reconciliation (Material's MDC click\n * handler advances `selectedIndex` synchronously before the\n * bidirectional sync sees the event).\n * - `destroyRef` cleanup of both directions.\n *\n * @internal\n */\nexport function createMatStepperBidirectionalSync(\n opts: CngxMatStepperBidirectionalSyncOptions,\n): void {\n createMaterialBidirectionalSync({\n presenterIndex: opts.presenter.activeStepIndex,\n readSelectedIndex: () => opts.matStepper.selectedIndex,\n writeSelectedIndex: (i) => {\n opts.matStepper.selectedIndex = i;\n },\n // `MatStepper.selectedIndexChange` emits a plain index - no adapter needed,\n // unlike `MatTabGroup.selectedIndexChange`.\n selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),\n onMaterialSelection: (i) => opts.presenter.select(i),\n injector: opts.injector,\n destroyRef: opts.destroyRef,\n });\n}\n","import { computed, InjectionToken, signal, type Signal, type TemplateRef } from '@angular/core';\nimport type { MatStep } from '@angular/material/stepper';\n\nimport type { CngxErrorAggregatorContract } from '@cngx/common/interactive';\nimport {\n type CngxStepperI18n,\n type CngxStepRegistration,\n type CngxStepStatus,\n} from '@cngx/common/stepper';\n\n/**\n * Shared `signal(undefined)` constant used as the `errorAggregator`\n * slot for every Material-instrumented step handle. The\n * instrumentation path does not bind cngx error-aggregation per\n * `MatStep` - Material's own visual error surface (driven by\n * `MatStep.hasError` / `MatStep.optional`) stays authoritative - so\n * per-step allocation of a writable signal would be dead capacity.\n *\n * @internal\n */\nconst NO_ERROR_AGGREGATOR: Signal<CngxErrorAggregatorContract | undefined> = signal<\n CngxErrorAggregatorContract | undefined\n>(undefined).asReadonly();\n\n/**\n * Wiring bundle returned from {@link createMatStepHandle}. The\n * instrumentation directive holds the bundle in a `Map<MatStep,\n * Setup>` for diff-only registry churn; only `handle` is exposed to\n * the presenter.\n */\nexport interface CngxMatStepHandleSetup {\n readonly handle: CngxStepRegistration;\n}\n\n/**\n * Best-effort static-text extraction from a `<ng-template matStepLabel>`\n * `TemplateRef`. Used as a label fallback when consumers project a\n * template label without setting `MatStep.label` or\n * `MatStep.ariaLabel` - without it the cngx-side label slot would\n * be empty, leaving aria-label phrases that include the step label\n * with a measurable gap on the Material variant. Static markup\n * (`<ng-template matStepLabel>Review</ng-template>`) extracts cleanly\n * via a detached embedded view; templates with dynamic interpolation\n * fall through (the detached view's CD has no consumer-context\n * bindings) and the caller's deterministic id-based fallback wins.\n *\n * Idempotent: never mutates the source template; the embedded view is\n * created and destroyed inside one frame's worth of synchronous work.\n *\n * @internal\n */\nfunction readMatStepLabelTemplateText(template: TemplateRef<unknown>): string | undefined {\n try {\n const view = template.createEmbeddedView({});\n try {\n view.detectChanges();\n const text = view.rootNodes\n .map((node: Node) => node.textContent ?? '')\n .join('')\n .trim();\n return text || undefined;\n } finally {\n view.destroy();\n }\n } catch {\n return undefined;\n }\n}\n\n/**\n * Translates a Material `MatStep` into a cngx\n * {@link CngxStepRegistration}.\n *\n * - `id` - always a fresh `idSeed()` value. Mirrors the tabs\n * instrumentation handle: a label-keyed id would collide when\n * two steps share a label.\n * - `kind` - fixed at `'step'`. The instrumentation path does not\n * project nested `<mat-step>` groups (Material's stepper has no\n * group-of-steps concept; group-aware semantics belong to the\n * `<cngx-stepper>` thin-wrapper organism).\n * - `label` - snapshot signal resolved through a four-tier fallback at\n * registration time so cngx-side phrases (announcements,\n * `aria-label` composition, telemetry) never read empty when\n * Material consumers project a `<ng-template matStepLabel>`:\n * 1. `MatStep.label` when it is a plain string - the canonical\n * shape and the only one that emits a runtime change Material\n * itself observes.\n * 2. `MatStep.ariaLabel` when the consumer set the input -\n * designed exactly as the substitute for template labels.\n * 3. Static-text read from `MatStep.stepLabel.template` via a\n * throwaway detached `EmbeddedViewRef` ({@link readMatStepLabelTemplateText}).\n * Captures literal `matStepLabel` markup; dynamic interpolation\n * bails through to (4).\n * 4. `CNGX_STEPPER_I18N.stepFallbackLabel(id)` (English default\n * `Step <id>`) - deterministic, derived from the cngx handle id.\n * Always non-empty. The `[cngxMatStepper]` directive passes its\n * injected bundle Signal as `i18n`. This tier follows a runtime\n * language switch.\n * Documented limitation: runtime changes of tiers 1-3 do not propagate.\n * CDK's `CdkStep` does not expose a `_stateChanges` Subject\n * analogous to `MatTab._stateChanges`, so cngx cannot re-trigger\n * the snapshot when Material flips the input later. Surface the\n * same Material-internal coupling family typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`.\n * - `disabled` - fixed `false`. Material owns step gating via\n * `linear` + `editable` + `completed`; surfacing a cngx-side\n * `disabled` would duplicate Material's own click-time enforcement\n * and is ignored by `<mat-stepper>` itself.\n * - `state` - `computed()` over `MatStep.hasError` / `MatStep.completed`.\n * `CdkStep.completed`'s getter reads `_completedOverride()` - a\n * `WritableSignal<boolean | null>` typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`. The cngx\n * computed transitively tracks that signal through the getter and\n * re-fires whenever Material flips completion. `hasError` is a\n * plain property setter on `CdkStep`, NOT a Signal - a `hasError`\n * write that is not paired with a `completed` change does not\n * re-trigger this computed. In practice Material wizards write the\n * two together (`step.hasError = true; step.completed = false` in\n * error-handler patterns and inside Material's own error-state\n * matchers) so the limitation is benign for the documented usage\n * pattern.\n * - `errorAggregator` - points at the shared\n * {@link NO_ERROR_AGGREGATOR} constant.\n */\nexport function createMatStepHandle(\n matStep: MatStep,\n idSeed: () => string,\n i18n: Signal<CngxStepperI18n>,\n): CngxMatStepHandleSetup {\n const id = idSeed();\n const labelText = resolveMaterialStepLabel(matStep);\n const label =\n labelText !== null\n ? signal<string>(labelText).asReadonly()\n : computed<string>(() => i18n().stepFallbackLabel(id));\n const disabled = signal<boolean>(false).asReadonly();\n const state = computed<CngxStepStatus>(() => {\n if (matStep.hasError) {\n return 'error';\n }\n if (matStep.completed) {\n return 'success';\n }\n return 'idle';\n });\n return {\n handle: {\n id,\n kind: 'step',\n label,\n disabled,\n state,\n errorAggregator: NO_ERROR_AGGREGATOR,\n },\n };\n}\n\n/**\n * Tiers 1-3 of the label fallback, walked once at registration time, or\n * `null` when tier 4 (the i18n fallback) applies. See the\n * {@link createMatStepHandle} JSDoc for the full ladder rationale.\n *\n * @internal\n */\nfunction resolveMaterialStepLabel(matStep: MatStep): string | null {\n const labelInput = matStep.label;\n if (typeof labelInput === 'string' && labelInput.length > 0) {\n return labelInput;\n }\n const ariaLabel = matStep.ariaLabel;\n if (typeof ariaLabel === 'string' && ariaLabel.length > 0) {\n return ariaLabel;\n }\n const tpl = matStep.stepLabel?.template;\n if (!tpl) {\n return null;\n }\n const text = readMatStepLabelTemplateText(tpl);\n if (!text) {\n return null;\n }\n return text;\n}\n\n/**\n * Factory signature for {@link createMatStepHandle}. The DI token\n * {@link CNGX_MAT_STEP_HANDLE_FACTORY} resolves to a function with\n * this exact shape - overrides match it identically.\n *\n * The third argument is the stepper i18n Signal the directive injected;\n * it carries the last-resort label (`stepFallbackLabel`). Forward it when\n * delegating to {@link createMatStepHandle}.\n */\nexport type CngxMatStepHandleFactory = typeof createMatStepHandle;\n\n/**\n * DI token fronting the per-step handle factory used by the\n * `[cngxMatStepper]` instrumentation directive. Default is\n * {@link createMatStepHandle}.\n *\n * Symmetric with the tabs sibling\n * `CNGX_MAT_TAB_HANDLE_FACTORY` and with `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`\n * - every Material-bridge logic block ships the same swap surface so\n * consumers can layer telemetry, alternate id strategies, or\n * test-environment id keying via `providers` / `viewProviders`\n * without forking the directive.\n *\n * Override capability - the swap surface separates **handle shape**\n * (factory body) from **id keying** (the supplied `idSeed` closure).\n * The directive constructs `idSeed` as `() => nextUid('cngx-mat-step-')`\n * and hands it to the factory as a default suggestion; an override is\n * free to call it, ignore it, or replace it with a server-synced /\n * deterministic-test / consumer-domain id strategy. Both axes are\n * independently swappable from one DI seam.\n *\n * ```ts\n * providers: [\n * {\n * provide: CNGX_MAT_STEP_HANDLE_FACTORY,\n * useValue: ((step, idSeed, i18n) => {\n * const setup = createMatStepHandle(step, idSeed, i18n);\n * reportStepRegistered(setup.handle.id);\n * return setup;\n * }) satisfies CngxMatStepHandleFactory,\n * },\n * ]\n * ```\n *\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/material-bridge/handle.ts\n * @since 0.3.0\n */\nexport const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken<CngxMatStepHandleFactory>(\n 'CNGX_MAT_STEP_HANDLE_FACTORY',\n {\n providedIn: 'root',\n factory: () => createMatStepHandle,\n },\n);\n","import {\n contentChildren,\n type DestroyRef,\n Directive,\n effect,\n inject,\n type Injector,\n untracked,\n DestroyRef as InjectableDestroyRef,\n Injector as InjectableInjector,\n} from '@angular/core';\nimport { MatStep, MatStepper } from '@angular/material/stepper';\n\nimport {\n CNGX_STEPPER_HOST,\n CngxStepperPresenter,\n createStepperAnnouncementBuilders,\n injectStepperI18n,\n} from '@cngx/common/stepper';\nimport { nextUid } from '@cngx/core/utils';\n\nimport { createOrderedRegistrationSeam, mountLiveRegionAnnouncer } from '@cngx/ui/mat-tabs';\nimport { createMatStepperBidirectionalSync } from './material-bridge/bidirectional-sync';\nimport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n type CngxMatStepHandleSetup,\n} from './material-bridge/handle';\n\n/**\n * The Material twin of the CNGX stepper: attach `cngxMatStepper` to a\n * vanilla `<mat-stepper>` and it is bridged to a\n * {@link CngxStepperPresenter}. \\\n * Consumers gain the commit-action\n * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /\n * `<cngx-banner-on />` compose as children), the shared\n * `CNGX_STEPPER_HOST` contract (so a `<cngx-stepper-footer>` can drive\n * Back / Next instead of Material's own buttons via\n * `[host]=\"ref.presenter\"`), and the step-handle registry - all from\n * one attribute.\n *\n * This is the instrumentation pattern: Material owns the rendering and\n * the consumer authors native `<mat-step>` markup; CNGX is the\n * behaviour layer. Topology mirrors `[cngxMatTabs]`.\n *\n * Commit-lifecycle transitions speak: the shared announcement builder\n * feeds the root live announcer (pending / landed / rolled-back\n * phrases, identical to `<cngx-stepper>`), and the host carries\n * `aria-busy=\"true\"` while a commit or the finish run is in flight.\n *\n * Inputs/outputs are forwarded from {@link CngxStepperPresenter}:\n * - `activeStepIndex` (two-way, with `activeStepIndexChange`),\n * - `linear`,\n * - `orientation`,\n * - `commitAction`,\n * - `commitMode`. \\\n * See the presenter for their semantics.\n * ```html\n * <mat-stepper\n * cngxMatStepper\n * #s=\"cngxMatStepper\"\n * [(activeStepIndex)]=\"active\"\n * [commitAction]=\"commitAction\"\n * [commitMode]=\"mode()\"\n * cngxToastOn\n * [toastError]=\"'Step transition failed'\"\n * cngxBannerOn\n * bannerId=\"stepper:commit-error\"\n * [bannerError]=\"'The server rejected the step change.'\"\n * aria-label=\"Account setup\"\n * >\n * <mat-step label=\"Personal info\">\n * <p>Tell us who you are.</p>\n * </mat-step>\n * <mat-step\n * label=\"Account\"\n * [hasError]=\"!accepted()\"\n * errorMessage=\"Accept the terms to continue\"\n * >\n * <p>Choose your sign-in method.</p>\n * </mat-step>\n * <mat-step label=\"Confirm\">\n * <p>Review everything, then finish.</p>\n * </mat-step>\n * </mat-stepper>\n * ```\n * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts\n *\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts\n * @since 0.3.0\n * @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter\n * <example-url>/#/ui/mat-stepper/stepper-footer/mat-stepper-footer</example-url>\n * @axis level organism\n */\n@Directive({\n selector: '[cngxMatStepper]',\n exportAs: 'cngxMatStepper',\n standalone: true,\n hostDirectives: [\n {\n directive: CngxStepperPresenter,\n inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],\n outputs: ['activeStepIndexChange'],\n },\n ],\n host: {\n // Communicated busy-state while a commit is in flight - same\n // strict 'pending' gate the cngx-native organism uses per step.\n '[attr.aria-busy]': \"presenter.busy() ? 'true' : null\",\n },\n})\nexport class CngxMatStepper {\n private readonly matStepper = inject(MatStepper, { self: true });\n /**\n * Shared host contract. Public so a `<cngx-stepper-footer>` placed\n * outside the `<mat-stepper>` can bind `[host]=\"ref.presenter\"` (via\n * `#ref=\"cngxMatStepper\"`) and drive navigation.\n */\n readonly presenter = inject(CNGX_STEPPER_HOST);\n private readonly destroyRef: DestroyRef = inject(InjectableDestroyRef);\n private readonly injector: Injector = inject(InjectableInjector);\n\n private readonly matSteps = contentChildren(MatStep, { descendants: true });\n private readonly createHandle = inject(CNGX_MAT_STEP_HANDLE_FACTORY);\n private readonly i18n = injectStepperI18n();\n\n // Shared with [cngxMatTabsRegistry]: the presenter registry appends\n // new registrations, but Material renders steps at their DOM\n // position - a mid-list <mat-step> insert must land at its query\n // index, not at the tail. The seam re-registers the diverging\n // suffix in query order while keeping surviving handle instances.\n private readonly seam = createOrderedRegistrationSeam<MatStep, CngxMatStepHandleSetup>({\n create: (step) => this.createHandle(step, () => nextUid('cngx-mat-step-'), this.i18n),\n register: (setup) => this.presenter.register(setup.handle),\n unregister: (setup) => this.presenter.unregister(setup.handle.id, setup.handle),\n dispose: () => {\n // Step setups carry no per-entry resources (no child injector).\n },\n });\n\n constructor() {\n effect(() => {\n // Ownership filter: `descendants: true` also surfaces MatSteps of\n // a stepper nested inside one of OUR steps' content. Each CdkStep\n // carries its owning `_stepper` (public in the CDK typings), so\n // foreign steps are dropped before they can register with this\n // presenter.\n const steps = this.matSteps().filter((step) => step._stepper === this.matStepper);\n untracked(() => this.seam.sync(steps));\n });\n\n this.destroyRef.onDestroy(() => this.seam.clear());\n\n // Commit-lifecycle announcements (pending / landed / rolled-back).\n // The shared builder computes the phrase; the shared announcer\n // renders it - an attribute directive owns no template, so the\n // polite region lives on the root CngxLiveAnnouncer, mirroring\n // [cngxMatTabs].\n mountLiveRegionAnnouncer({\n announcement: createStepperAnnouncementBuilders({\n presenter: this.presenter,\n stepsOnly: this.presenter.stepsOnly,\n i18n: this.i18n,\n }).liveAnnouncement,\n injector: this.injector,\n });\n\n createMatStepperBidirectionalSync({\n matStepper: this.matStepper,\n presenter: this.presenter,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n }\n}\n","/**\n * Public API surface of `@cngx/ui/mat-stepper`.\n *\n * The Material twin of the cngx stepper family, shipped as the\n * instrumentation directive `[cngxMatStepper]`: attach it to a vanilla\n * `<mat-stepper>` and it composes the same `CngxStepperPresenter` brain\n * as `<cngx-stepper>` (in `@cngx/ui/stepper`) via `hostDirectives`, so\n * commit-action lifecycle, router sync, and error aggregation all work\n * against Material's own markup. Mirrors `[cngxMatTabs]`.\n *\n * @module `@cngx/ui/mat-stepper`\n */\nexport { CngxMatStepper } from './mat-stepper.directive';\nexport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n createMatStepHandle,\n type CngxMatStepHandleFactory,\n type CngxMatStepHandleSetup,\n} from './material-bridge/handle';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["InjectableDestroyRef","InjectableInjector"],"mappings":";;;;;;;;;AAyBA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,iCAAiC,CAC/C,IAA4C,EAAA;AAE5C,IAAA,+BAA+B,CAAC;AAC9B,QAAA,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe;QAC9C,iBAAiB,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa;AACtD,QAAA,kBAAkB,EAAE,CA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