@cngx/ui 0.1.0-rc.6 → 0.1.0-rc.8
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.
- package/README.md +112 -1
- package/a11y/README.md +87 -0
- package/accordion/README.md +4 -2
- package/breadcrumb/README.md +262 -0
- package/collection/README.md +6 -0
- package/command-palette/README.md +224 -0
- package/context-menu/README.md +98 -0
- package/data-grid-accordion/README.md +103 -2
- package/feedback/README.md +42 -0
- package/fesm2022/cngx-ui-a11y.mjs +452 -0
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
- package/fesm2022/cngx-ui-accordion.mjs +116 -38
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +115 -50
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +181 -96
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +586 -0
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
- package/fesm2022/cngx-ui-collection.mjs +207 -66
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +1281 -0
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
- package/fesm2022/cngx-ui-context-menu.mjs +857 -0
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -111
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +16 -6
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +1095 -521
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +18 -9
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +84 -16
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +370 -203
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-overlay.mjs +69 -13
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +501 -182
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +327 -106
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +22 -21
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +107 -8
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +718 -0
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +217 -76
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +40 -19
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +548 -0
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
- package/fesm2022/cngx-ui-toc.mjs +748 -0
- package/fesm2022/cngx-ui-toc.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +16 -21
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-accordion/README.md +1 -1
- package/mat-paginator/README.md +9 -2
- package/mat-tabs/styles/mat-tabs.css +29 -27
- package/overlay/README.md +9 -4
- package/package.json +32 -1
- package/paginator/README.md +8 -4
- package/sidenav/README.md +33 -11
- package/skeleton/README.md +2 -0
- package/speak/README.md +3 -2
- package/stepper/README.md +15 -3
- package/timeline/README.md +350 -0
- package/toc/README.md +186 -0
- package/types/cngx-ui-a11y.d.ts +394 -0
- package/types/cngx-ui-accordion.d.ts +100 -30
- package/types/cngx-ui-action-button.d.ts +47 -3
- package/types/cngx-ui-breadcrumb.d.ts +159 -58
- package/types/cngx-ui-chart-panel.d.ts +382 -0
- package/types/cngx-ui-collection.d.ts +159 -58
- package/types/cngx-ui-command-palette.d.ts +565 -0
- package/types/cngx-ui-context-menu.d.ts +559 -0
- package/types/cngx-ui-data-grid-accordion.d.ts +344 -51
- package/types/cngx-ui-empty-state.d.ts +9 -2
- package/types/cngx-ui-feedback.d.ts +664 -73
- package/types/cngx-ui-layout.d.ts +8 -3
- package/types/cngx-ui-mat-accordion.d.ts +32 -4
- package/types/cngx-ui-mat-paginator.d.ts +37 -8
- package/types/cngx-ui-mat-stepper.d.ts +23 -11
- package/types/cngx-ui-mat-tabs.d.ts +218 -23
- package/types/cngx-ui-overlay.d.ts +56 -10
- package/types/cngx-ui-paginator.d.ts +416 -132
- package/types/cngx-ui-sidenav.d.ts +248 -74
- package/types/cngx-ui-skeleton.d.ts +18 -7
- package/types/cngx-ui-speak.d.ts +118 -5
- package/types/cngx-ui-stat-card.d.ts +411 -0
- package/types/cngx-ui-stepper.d.ts +81 -29
- package/types/cngx-ui-tabs.d.ts +22 -6
- package/types/cngx-ui-timeline.d.ts +495 -0
- package/types/cngx-ui-toc.d.ts +581 -0
- package/types/cngx-ui.d.ts +8 -5
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
|
|
4
|
+
// Chain per rung: consumer override hook (--cngx-gap-*, set nowhere by the
|
|
5
|
+
// library) -> density scale (--cngx-space-*, registered inherits: true, so a
|
|
6
|
+
// root [data-density] swap rescales the stack) -> literal for token-less
|
|
7
|
+
// environments.
|
|
4
8
|
const GAP_DEFAULTS = {
|
|
5
9
|
none: '0',
|
|
6
|
-
xs: 'var(--cngx-gap-xs, 4px)',
|
|
7
|
-
sm: 'var(--cngx-gap-sm, 8px)',
|
|
8
|
-
md: 'var(--cngx-gap-md, 16px)',
|
|
9
|
-
lg: 'var(--cngx-gap-lg, 24px)',
|
|
10
|
-
xl: 'var(--cngx-gap-xl, 32px)',
|
|
10
|
+
xs: 'var(--cngx-gap-xs, var(--cngx-space-xs, 4px))',
|
|
11
|
+
sm: 'var(--cngx-gap-sm, var(--cngx-space-sm, 8px))',
|
|
12
|
+
md: 'var(--cngx-gap-md, var(--cngx-space-md, 16px))',
|
|
13
|
+
lg: 'var(--cngx-gap-lg, var(--cngx-space-lg, 24px))',
|
|
14
|
+
xl: 'var(--cngx-gap-xl, var(--cngx-space-xl, 32px))',
|
|
11
15
|
};
|
|
12
16
|
/**
|
|
13
17
|
* Composable flex-based stack layout component.
|
|
14
18
|
*
|
|
15
19
|
* Gap tokens use CSS custom properties (`--cngx-gap-xs` through `--cngx-gap-xl`)
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* that fall back to the density scale (`--cngx-space-*`), so a root
|
|
21
|
+
* `[data-density]` swap rescales the stack. Override the `--cngx-gap-*`
|
|
22
|
+
* hooks at any scope to detach a stack from the scale.
|
|
18
23
|
*
|
|
19
24
|
* <cngx-stack direction="row" gap="md" align="center">
|
|
20
25
|
* <div>Item 1</div>
|
|
@@ -76,8 +81,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
76
81
|
class CngxGrid {
|
|
77
82
|
/** Number of equal columns, or a custom `grid-template-columns` value. */
|
|
78
83
|
columns = input(1, { ...(ngDevMode ? { debugName: "columns" } : /* istanbul ignore next */ {}), transform: coerceColumns });
|
|
79
|
-
/**
|
|
80
|
-
|
|
84
|
+
/**
|
|
85
|
+
* CSS gap between cells. The default reads the `--cngx-gap-md` override
|
|
86
|
+
* hook and falls back to the density scale (`--cngx-space-md`), so a root
|
|
87
|
+
* `[data-density]` swap rescales the grid; any CSS gap value is accepted.
|
|
88
|
+
*/
|
|
89
|
+
gap = input('var(--cngx-gap-md, var(--cngx-space-md, 16px))', ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
|
|
81
90
|
/** @internal */
|
|
82
91
|
gridTemplateColumns = computed(() => {
|
|
83
92
|
const cols = this.columns();
|
|
@@ -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\nconst GAP_DEFAULTS: Record<StackGap, string> = {\n none: '0',\n xs: 'var(--cngx-gap-xs, 4px)',\n sm: 'var(--cngx-gap-sm, 8px)',\n md: 'var(--cngx-gap-md, 16px)',\n lg: 'var(--cngx-gap-lg, 24px)',\n xl: 'var(--cngx-gap-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 *
|
|
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;u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,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,QAAQ,yaAbT,gBAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,uBAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAaf,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAjBpB,SAAS;+BACE,WAAW,EAAA,UAAA,EACT,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,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { runInInjectionContext, effect, untracked, inject, Injector, DestroyRef, contentChildren, Directive } from '@angular/core';
|
|
2
|
+
import { runInInjectionContext, effect, untracked, inject, Injector, DestroyRef, contentChildren, computed, input, Directive } from '@angular/core';
|
|
3
3
|
import { MatAccordion, MatExpansionPanel } from '@angular/material/expansion';
|
|
4
4
|
import * as i1 from '@cngx/common/interactive';
|
|
5
5
|
import { CngxAccordion } from '@cngx/common/interactive';
|
|
@@ -10,22 +10,30 @@ import { nextUid } from '@cngx/core/utils';
|
|
|
10
10
|
* `<mat-expansion-panel>` tree and the headless {@link CngxAccordion}
|
|
11
11
|
* open-set. The accordion open-set is a multi-membership
|
|
12
12
|
* `Set<string>`, so the index-based `createMaterialBidirectionalSync`
|
|
13
|
-
* (`@cngx/common/data`) does not fit
|
|
13
|
+
* (`@cngx/common/data`) does not fit - this helper syncs per-panel
|
|
14
14
|
* `expanded` against set membership instead.
|
|
15
15
|
*
|
|
16
16
|
* Installs two effects and one listener-set:
|
|
17
17
|
*
|
|
18
|
-
* 1. **brain→Material**
|
|
18
|
+
* 1. **brain→Material** - an `effect()` tracking `panels()` and, per
|
|
19
19
|
* panel, `accordion.isOpen(id)`. When the open-set (or the panel
|
|
20
20
|
* list) changes it writes `panel.expanded` to match, guarded by a
|
|
21
21
|
* re-entrancy flag so the resulting synchronous `expandedChange`
|
|
22
22
|
* echo does not loop back. The Material writes run inside
|
|
23
|
-
* `untracked()` per
|
|
24
|
-
*
|
|
23
|
+
* `untracked()` per the signal-architecture rules. Before the
|
|
24
|
+
* first write for a freshly-sighted panel, its authored
|
|
25
|
+
* `[expanded]` state SEEDS the brain: a panel that arrives
|
|
26
|
+
* already expanded toggles its id into the open-set instead of
|
|
27
|
+
* being closed by the (initially empty) membership write.
|
|
28
|
+
* Membership still flows through `toggle`, so single-open
|
|
29
|
+
* arbitration applies to seeded panels exactly as it does to a
|
|
30
|
+
* user click - two panels authored expanded clamp to one in
|
|
31
|
+
* single mode.
|
|
32
|
+
* 2. **subscription reconcile** - an `effect()` tracking only
|
|
25
33
|
* `panels()`; inside `untracked()` it subscribes freshly-added
|
|
26
34
|
* panels' `expandedChange` and drops removed ones (diff-only churn,
|
|
27
35
|
* a `Map<P, subscription>`).
|
|
28
|
-
* 3. **Material→brain**
|
|
36
|
+
* 3. **Material→brain** - each `expandedChange` listener flips the
|
|
29
37
|
* brain via `accordion.toggle(id)`, but only when the incoming
|
|
30
38
|
* `expanded` differs from the brain's current (clamped) membership,
|
|
31
39
|
* so a programmatic echo (or a redundant Material emit) is a no-op.
|
|
@@ -40,15 +48,19 @@ import { nextUid } from '@cngx/core/utils';
|
|
|
40
48
|
* brain.
|
|
41
49
|
*
|
|
42
50
|
* @category ui/mat-accordion/material-bridge
|
|
51
|
+
* @internal
|
|
43
52
|
*/
|
|
44
53
|
function createMatExpansionSetSync(opts) {
|
|
45
54
|
const { panels, panelId, accordion, injector, destroyRef } = opts;
|
|
46
55
|
// True while effect 1 is writing Material. `CdkAccordionItem` emits
|
|
47
56
|
// `expandedChange` synchronously from its `expanded` setter, so the
|
|
48
|
-
// Material→brain listener fires re-entrantly during our own write
|
|
57
|
+
// Material→brain listener fires re-entrantly during our own write -
|
|
49
58
|
// the flag drops that echo before the idempotent check even runs.
|
|
50
59
|
let writingToMaterial = false;
|
|
51
60
|
const subscriptions = new Map();
|
|
61
|
+
// Panels whose authored `expanded` state has already been folded
|
|
62
|
+
// into the brain - seeding happens exactly once per panel lifetime.
|
|
63
|
+
const seeded = new WeakSet();
|
|
52
64
|
const writeBackFromMaterial = (id, expanded) => {
|
|
53
65
|
if (writingToMaterial) {
|
|
54
66
|
return;
|
|
@@ -62,6 +74,23 @@ function createMatExpansionSetSync(opts) {
|
|
|
62
74
|
// brain→Material.
|
|
63
75
|
effect(() => {
|
|
64
76
|
const list = panels();
|
|
77
|
+
// Seed first: a freshly-sighted panel authored `[expanded]`
|
|
78
|
+
// flows Material→brain BEFORE the membership write below runs,
|
|
79
|
+
// otherwise the initially-empty open-set would close it. Runs
|
|
80
|
+
// inside untracked() - `toggle` is a service call writing
|
|
81
|
+
// signals; the tracked `isOpen` reads below pick up the
|
|
82
|
+
// seeded membership synchronously.
|
|
83
|
+
untracked(() => {
|
|
84
|
+
for (const panel of list) {
|
|
85
|
+
if (seeded.has(panel)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
seeded.add(panel);
|
|
89
|
+
if (panel.expanded && !accordion.isOpen(panelId(panel))) {
|
|
90
|
+
accordion.toggle(panelId(panel));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
65
94
|
const desired = list.map((panel) => accordion.isOpen(panelId(panel)));
|
|
66
95
|
untracked(() => {
|
|
67
96
|
writingToMaterial = true;
|
|
@@ -85,8 +114,10 @@ function createMatExpansionSetSync(opts) {
|
|
|
85
114
|
if (subscriptions.has(panel)) {
|
|
86
115
|
continue;
|
|
87
116
|
}
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
// Resolve the id per event, not at subscribe time - a
|
|
118
|
+
// consumer-swapped panelId fn would otherwise leave this
|
|
119
|
+
// listener toggling the stale key forever.
|
|
120
|
+
subscriptions.set(panel, panel.expandedChange.subscribe((expanded) => writeBackFromMaterial(panelId(panel), expanded)));
|
|
90
121
|
}
|
|
91
122
|
for (const [panel, subscription] of Array.from(subscriptions.entries())) {
|
|
92
123
|
if (live.has(panel)) {
|
|
@@ -111,7 +142,7 @@ function createMatExpansionSetSync(opts) {
|
|
|
111
142
|
* a vanilla `<mat-accordion>` and it is driven by the headless
|
|
112
143
|
* {@link CngxAccordion} brain. Consumers gain the controlled
|
|
113
144
|
* `[(openIds)]` group model and single-open arbitration on Material
|
|
114
|
-
* markup
|
|
145
|
+
* markup - neither of which `<mat-accordion>` exposes (Material has only
|
|
115
146
|
* per-panel `[expanded]`). Mirrors `[cngxMatStepper]` / `[cngxMatTabs]`.
|
|
116
147
|
*
|
|
117
148
|
* This is the instrumentation pattern: Material owns rendering and the
|
|
@@ -134,11 +165,25 @@ function createMatExpansionSetSync(opts) {
|
|
|
134
165
|
*
|
|
135
166
|
* `multi` is authoritative on the cngx side. `MatAccordion` inherits its
|
|
136
167
|
* own `multi` input from `CdkAccordion`, and both directives sit on the
|
|
137
|
-
* same host element, so a single `[multi]` binding feeds both
|
|
168
|
+
* same host element, so a single `[multi]` binding feeds both - the
|
|
138
169
|
* directive therefore pins `matAccordion.multi = true` (via an `effect`
|
|
139
170
|
* that re-asserts on every `multi` change) so Material never runs its own
|
|
140
171
|
* single-open close while the cngx `effectiveOpenIds` clamp arbitrates.
|
|
141
172
|
*
|
|
173
|
+
* Panels authored `[expanded]="true"` seed the open-set at first
|
|
174
|
+
* registration (Material→brain), so an initially-open Material panel
|
|
175
|
+
* is not closed by the initially-empty membership model. To make a
|
|
176
|
+
* pre-populated `[(openIds)]` addressable, bind `[panelIdFn]` - the
|
|
177
|
+
* hook replaces the generated per-panel ids with consumer-known keys:
|
|
178
|
+
*
|
|
179
|
+
* ```html
|
|
180
|
+
* <mat-accordion
|
|
181
|
+
* cngxMatAccordion
|
|
182
|
+
* [(openIds)]="openIds"
|
|
183
|
+
* [panelIdFn]="idFromPanel"
|
|
184
|
+
* >
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
142
187
|
* @playground Controlled open-set ./examples/bridge/bridge-example.component.ts
|
|
143
188
|
* @category ui/mat-accordion
|
|
144
189
|
* @docsKind primary
|
|
@@ -151,14 +196,33 @@ class CngxMatAccordion {
|
|
|
151
196
|
matAccordion = inject(MatAccordion, { self: true });
|
|
152
197
|
/**
|
|
153
198
|
* The accordion brain on this host element (declared in
|
|
154
|
-
* `hostDirectives`). Same-host ownership
|
|
199
|
+
* `hostDirectives`). Same-host ownership - not a child→parent inject -
|
|
155
200
|
* so it stays decompose-safe.
|
|
156
201
|
*/
|
|
157
202
|
accordion = inject(CngxAccordion, { self: true });
|
|
158
203
|
injector = inject(Injector);
|
|
159
204
|
destroyRef = inject(DestroyRef);
|
|
160
205
|
panels = contentChildren(MatExpansionPanel, { ...(ngDevMode ? { debugName: "panels" } : /* istanbul ignore next */ {}), descendants: true });
|
|
161
|
-
//
|
|
206
|
+
// Ownership filter: `descendants: true` also surfaces panels of an
|
|
207
|
+
// accordion nested inside one of OUR panels' bodies. Each panel
|
|
208
|
+
// carries its owning `accordion` (public on CdkAccordionItem), so
|
|
209
|
+
// foreign panels never enter the set-sync - the nested accordion
|
|
210
|
+
// arbitrates its own children. Element-wise equal keeps downstream
|
|
211
|
+
// effects quiet on identity-preserving query re-emissions.
|
|
212
|
+
ownPanels = computed(() => this.panels().filter((panel) => panel.accordion === this.matAccordion), { ...(ngDevMode ? { debugName: "ownPanels" } : /* istanbul ignore next */ {}), equal: (a, b) => a.length === b.length && a.every((panel, i) => panel === b[i]) });
|
|
213
|
+
/**
|
|
214
|
+
* Per-panel id hook. When bound, the returned key is what the
|
|
215
|
+
* open-set stores for that panel - making a pre-populated
|
|
216
|
+
* `[(openIds)]` model addressable (the generated
|
|
217
|
+
* `cngx-mat-panel-N` ids are unknowable to consumers). The
|
|
218
|
+
* function must return a stable, unique id per panel instance;
|
|
219
|
+
* `MatExpansionPanel.id` (consumer-assignable) is a natural key.
|
|
220
|
+
* Unbound, ids fall back to generated `nextUid` values. Swapping
|
|
221
|
+
* the bound function at runtime re-keys future events but does not
|
|
222
|
+
* migrate ids already stored in `openIds` - bind it once.
|
|
223
|
+
*/
|
|
224
|
+
panelIdFn = input(undefined, ...(ngDevMode ? [{ debugName: "panelIdFn" }] : /* istanbul ignore next */ []));
|
|
225
|
+
// Stable id per panel - the key the brain's open-set stores. A WeakMap:
|
|
162
226
|
// the id is assigned first-seen and never needs enumeration, so a removed
|
|
163
227
|
// panel's entry drops with the panel instead of accumulating over churn.
|
|
164
228
|
idByPanel = new WeakMap();
|
|
@@ -176,7 +240,7 @@ class CngxMatAccordion {
|
|
|
176
240
|
});
|
|
177
241
|
});
|
|
178
242
|
createMatExpansionSetSync({
|
|
179
|
-
panels: this.
|
|
243
|
+
panels: this.ownPanels,
|
|
180
244
|
panelId: (panel) => this.panelId(panel),
|
|
181
245
|
accordion: this.accordion,
|
|
182
246
|
injector: this.injector,
|
|
@@ -184,6 +248,10 @@ class CngxMatAccordion {
|
|
|
184
248
|
});
|
|
185
249
|
}
|
|
186
250
|
panelId(panel) {
|
|
251
|
+
const idFn = this.panelIdFn();
|
|
252
|
+
if (idFn !== undefined) {
|
|
253
|
+
return idFn(panel);
|
|
254
|
+
}
|
|
187
255
|
let id = this.idByPanel.get(panel);
|
|
188
256
|
if (id === undefined) {
|
|
189
257
|
id = nextUid('cngx-mat-panel-');
|
|
@@ -192,7 +260,7 @@ class CngxMatAccordion {
|
|
|
192
260
|
return id;
|
|
193
261
|
}
|
|
194
262
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatAccordion, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
195
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxMatAccordion, isStandalone: true, selector: "[cngxMatAccordion]", queries: [{ propertyName: "panels", predicate: MatExpansionPanel, descendants: true, isSignal: true }], exportAs: ["cngxMatAccordion"], hostDirectives: [{ directive: i1.CngxAccordion, inputs: ["multi", "multi", "openIds", "openIds"], outputs: ["openIdsChange", "openIdsChange"] }], ngImport: i0 });
|
|
263
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxMatAccordion, isStandalone: true, selector: "[cngxMatAccordion]", inputs: { panelIdFn: { classPropertyName: "panelIdFn", publicName: "panelIdFn", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "panels", predicate: MatExpansionPanel, descendants: true, isSignal: true }], exportAs: ["cngxMatAccordion"], hostDirectives: [{ directive: i1.CngxAccordion, inputs: ["multi", "multi", "openIds", "openIds"], outputs: ["openIdsChange", "openIdsChange"] }], ngImport: i0 });
|
|
196
264
|
}
|
|
197
265
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatAccordion, decorators: [{
|
|
198
266
|
type: Directive,
|
|
@@ -208,7 +276,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
208
276
|
},
|
|
209
277
|
],
|
|
210
278
|
}]
|
|
211
|
-
}], ctorParameters: () => [], propDecorators: { panels: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => MatExpansionPanel), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
279
|
+
}], 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 }] }] } });
|
|
212
280
|
|
|
213
281
|
/**
|
|
214
282
|
* @module @cngx/ui/mat-accordion
|
|
@@ -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 */\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 */\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 */\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 `reference_signal_architecture` rule 2.\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 */\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\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 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 const id = panelId(panel);\n subscriptions.set(\n panel,\n panel.expandedChange.subscribe((expanded) => writeBackFromMaterial(id, expanded)),\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 contentChildren,\n DestroyRef,\n Directive,\n effect,\n inject,\n Injector,\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 * @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 // 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.panels,\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 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;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;AAE3D,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;YACrB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,SAAS,CAAC,MAAK;gBACb,iBAAiB,GAAG,IAAI;AACxB,gBAAA,IAAI;oBACF,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAI;wBAC5B,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE;AACrC,4BAA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,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AChFpF;;;;;;;;;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 * @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` (consumer-assignable) is a natural key.\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;AACxB,oBAAA,IAAI,MAAM,CAAC,GAAG,CAAC,K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AAA,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,13 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, ElementRef, Renderer2, DestroyRef, computed,
|
|
2
|
+
import { inject, input, output, booleanAttribute, ElementRef, Renderer2, DestroyRef, computed, untracked, effect, Directive } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { MatPaginator } from '@angular/material/paginator';
|
|
5
5
|
import * as i1 from '@cngx/common/data';
|
|
6
|
-
import { CngxPaginate, connectPaginateResetOn } from '@cngx/common/data';
|
|
6
|
+
import { CngxPaginate, connectPaginateEmit, connectPaginateResetOn } from '@cngx/common/data';
|
|
7
7
|
export { CngxPaginateResetOn, CngxPaginateRouting } from '@cngx/common/data';
|
|
8
|
+
import { injectPaginatorAnnouncements } from '@cngx/ui/paginator';
|
|
8
9
|
|
|
9
|
-
/** English default announcement. Localise via `[announceLabel]`. */
|
|
10
|
-
const defaultAnnounceLabel = (c) => `Page ${c.page} of ${c.totalPages}, showing items ${c.start} to ${c.end} of ${c.total}`;
|
|
11
10
|
/**
|
|
12
11
|
* The in-place adoption half of the Material paginator instrumentation: add
|
|
13
12
|
* `cngxMatPaginator` to an existing `<mat-paginator>` and the signal-native
|
|
@@ -25,9 +24,12 @@ const defaultAnnounceLabel = (c) => `Page ${c.page} of ${c.totalPages}, showing
|
|
|
25
24
|
* search value) changes, so a filtered result set never strands the user on a
|
|
26
25
|
* now-empty page. Pass a primitive (or a `computed` string key); an inline
|
|
27
26
|
* array literal recomputes every change-detection pass and would reset on each.
|
|
28
|
-
* - `[announce]` - mount a visually-hidden `aria-live` region that speaks the
|
|
29
|
-
* page
|
|
30
|
-
*
|
|
27
|
+
* - `[announce]` - mount a visually-hidden `aria-live` region that speaks the
|
|
28
|
+
* page after every change; `<mat-paginator>` only relabels its own range
|
|
29
|
+
* text, which AT does not announce. Phrasing resolves from the shared
|
|
30
|
+
* `CNGX_PAGINATOR_CONFIG` cascade (`announcements.pageChange`), so app-wide
|
|
31
|
+
* localisation covers the bridge and the organism together; bind
|
|
32
|
+
* `[announceLabel]` for a richer per-instance message with the visible range.
|
|
31
33
|
* - `[cngxPaginateRouting]` (generic companion directive from `@cngx/common/data`)
|
|
32
34
|
* - persist the page / size in the URL query string for deep-linkable,
|
|
33
35
|
* back-button-safe pagination.
|
|
@@ -74,25 +76,51 @@ class CngxMatPaginator {
|
|
|
74
76
|
* literal recomputes every change-detection pass and would reset every time.
|
|
75
77
|
*/
|
|
76
78
|
resetOn = input(undefined, { ...(ngDevMode ? { debugName: "resetOn" } : /* istanbul ignore next */ {}), alias: 'resetOn' });
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Emits the effective page index on every change - navigation or a
|
|
81
|
+
* `total`-shrink clamp - exactly once per change, through the shared
|
|
82
|
+
* `connectPaginateEmit` guard. Clamp emits are held back while the brain is
|
|
83
|
+
* busy or `total` is 0, matching the `CngxPaginator` shell.
|
|
84
|
+
*/
|
|
85
|
+
pageChange = output();
|
|
86
|
+
/** Emits the effective page size exactly once per change. */
|
|
87
|
+
pageSizeChange = output();
|
|
88
|
+
/**
|
|
89
|
+
* Speak page changes through a visually-hidden `aria-live` region when set.
|
|
90
|
+
* `booleanAttribute` transform, so static `announce` markup enables it.
|
|
91
|
+
*/
|
|
92
|
+
announce = input(false, { ...(ngDevMode ? { debugName: "announce" } : /* istanbul ignore next */ {}), alias: 'announce', transform: booleanAttribute });
|
|
93
|
+
/**
|
|
94
|
+
* Builds the announcement string from the page/range context. When unbound,
|
|
95
|
+
* the message resolves from the `CNGX_PAGINATOR_CONFIG` cascade
|
|
96
|
+
* (`announcements.pageChange`, "Page N of M" in the EN defaults), so
|
|
97
|
+
* `withPaginatorAnnouncements(...)` localises the bridge together with the
|
|
98
|
+
* `CngxPaginator` organism. Bind this for a richer per-instance message
|
|
99
|
+
* (the context also carries the visible item range).
|
|
100
|
+
*/
|
|
101
|
+
announceLabel = input(undefined, { ...(ngDevMode ? { debugName: "announceLabel" } : /* istanbul ignore next */ {}), alias: 'announceLabel' });
|
|
102
|
+
/**
|
|
103
|
+
* Paginator config cascade - shared with the `CngxPaginator` organism, so
|
|
104
|
+
* one `provideCngxPaginatorConfig(...)` localises both surfaces. Busy /
|
|
105
|
+
* settle phrases stay unspoken here: the bridge communicates the updating
|
|
106
|
+
* state via `aria-busy` on the host instead of a spoken transition.
|
|
107
|
+
*/
|
|
108
|
+
announcements = injectPaginatorAnnouncements();
|
|
81
109
|
elementRef = inject(ElementRef);
|
|
82
110
|
renderer = inject(Renderer2);
|
|
83
111
|
destroyRef = inject(DestroyRef);
|
|
84
112
|
/** The live-region message - derived, so it never drifts from brain state. */
|
|
85
113
|
announceMessage = computed(() => {
|
|
114
|
+
const page = this.paginate.pageIndex() + 1;
|
|
115
|
+
const totalPages = this.paginate.totalPages();
|
|
116
|
+
const custom = this.announceLabel();
|
|
117
|
+
if (!custom) {
|
|
118
|
+
return untracked(() => this.announcements().pageChange(page, totalPages));
|
|
119
|
+
}
|
|
86
120
|
const total = this.paginate.total();
|
|
87
|
-
const start = total === 0 ? 0 : this.paginate.
|
|
88
|
-
const end =
|
|
89
|
-
return
|
|
90
|
-
page: this.paginate.pageIndex() + 1,
|
|
91
|
-
totalPages: this.paginate.totalPages(),
|
|
92
|
-
start,
|
|
93
|
-
end,
|
|
94
|
-
total,
|
|
95
|
-
});
|
|
121
|
+
const start = total === 0 ? 0 : this.paginate.clampedRange()[0] + 1;
|
|
122
|
+
const end = this.paginate.clampedRange()[1];
|
|
123
|
+
return untracked(() => custom({ page, totalPages, start, end, total }));
|
|
96
124
|
}, ...(ngDevMode ? [{ debugName: "announceMessage" }] : /* istanbul ignore next */ []));
|
|
97
125
|
liveRegion = null;
|
|
98
126
|
constructor() {
|
|
@@ -124,14 +152,30 @@ class CngxMatPaginator {
|
|
|
124
152
|
this.paginate.setPageSize(event.pageSize, false);
|
|
125
153
|
this.paginate.setPage(event.pageIndex);
|
|
126
154
|
});
|
|
155
|
+
// Exactly-once output wiring, shared verbatim with the CngxPaginator shell
|
|
156
|
+
// and CngxIncrementalList. A raw hostDirectives alias of the brain outputs
|
|
157
|
+
// would bypass the shared last-emitted guard: setPageSize fires on every
|
|
158
|
+
// PageEvent, so each page click would also emit a spurious pageSizeChange,
|
|
159
|
+
// and a total-shrink clamp would move the page with no emission at all.
|
|
160
|
+
connectPaginateEmit(this.paginate, {
|
|
161
|
+
onIndex: (index) => this.pageChange.emit(index),
|
|
162
|
+
onSize: (size) => this.pageSizeChange.emit(size),
|
|
163
|
+
});
|
|
127
164
|
// Reset-on-change, shared verbatim with the shell input and the generic
|
|
128
165
|
// [cngxPaginateResetOn] directive.
|
|
129
166
|
connectPaginateResetOn(this.paginate, this.resetOn);
|
|
130
167
|
// AT announcement. The region is created lazily on first opt-in, then its
|
|
131
168
|
// text tracks the derived message. textContent is written through the
|
|
132
|
-
// renderer so it stays SSR-safe.
|
|
169
|
+
// renderer so it stays SSR-safe. Flipping [announce] off empties the
|
|
170
|
+
// mounted region - a stale last message would otherwise linger in the
|
|
171
|
+
// accessibility tree.
|
|
133
172
|
effect(() => {
|
|
134
173
|
if (!this.announce()) {
|
|
174
|
+
untracked(() => {
|
|
175
|
+
if (this.liveRegion) {
|
|
176
|
+
this.renderer.setProperty(this.liveRegion, 'textContent', '');
|
|
177
|
+
}
|
|
178
|
+
});
|
|
135
179
|
return;
|
|
136
180
|
}
|
|
137
181
|
const message = this.announceMessage();
|
|
@@ -169,7 +213,7 @@ class CngxMatPaginator {
|
|
|
169
213
|
return span;
|
|
170
214
|
}
|
|
171
215
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatPaginator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
172
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMatPaginator, isStandalone: true, selector: "[cngxMatPaginator]", inputs: { pageSizeOptions: { classPropertyName: "pageSizeOptions", publicName: "pageSizeOptions", isSignal: true, isRequired: false, transformFunction: null }, resetOn: { classPropertyName: "resetOn", publicName: "resetOn", isSignal: true, isRequired: false, transformFunction: null }, announce: { classPropertyName: "announce", publicName: "announce", isSignal: true, isRequired: false, transformFunction: null }, announceLabel: { classPropertyName: "announceLabel", publicName: "announceLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-busy": "paginate.isBusy()" } }, exportAs: ["cngxMatPaginator"], hostDirectives: [{ directive: i1.CngxPaginate, inputs: ["cngxPageIndex", "cngxPageIndex", "cngxPageSize", "cngxPageSize", "total", "total", "state", "state"]
|
|
216
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMatPaginator, isStandalone: true, selector: "[cngxMatPaginator]", inputs: { pageSizeOptions: { classPropertyName: "pageSizeOptions", publicName: "pageSizeOptions", isSignal: true, isRequired: false, transformFunction: null }, resetOn: { classPropertyName: "resetOn", publicName: "resetOn", isSignal: true, isRequired: false, transformFunction: null }, announce: { classPropertyName: "announce", publicName: "announce", isSignal: true, isRequired: false, transformFunction: null }, announceLabel: { classPropertyName: "announceLabel", publicName: "announceLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageChange: "pageChange", pageSizeChange: "pageSizeChange" }, host: { properties: { "attr.aria-busy": "paginate.isBusy()" } }, exportAs: ["cngxMatPaginator"], hostDirectives: [{ directive: i1.CngxPaginate, inputs: ["cngxPageIndex", "cngxPageIndex", "cngxPageSize", "cngxPageSize", "total", "total", "state", "state"] }], ngImport: i0 });
|
|
173
217
|
}
|
|
174
218
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatPaginator, decorators: [{
|
|
175
219
|
type: Directive,
|
|
@@ -186,11 +230,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
186
230
|
{
|
|
187
231
|
directive: CngxPaginate,
|
|
188
232
|
inputs: ['cngxPageIndex', 'cngxPageSize', 'total', 'state'],
|
|
189
|
-
outputs: ['pageChange', 'pageSizeChange'],
|
|
190
233
|
},
|
|
191
234
|
],
|
|
192
235
|
}]
|
|
193
|
-
}], ctorParameters: () => [], propDecorators: { pageSizeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSizeOptions", required: false }] }], resetOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "resetOn", required: false }] }], announce: [{ type: i0.Input, args: [{ isSignal: true, alias: "announce", required: false }] }], announceLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "announceLabel", required: false }] }] } });
|
|
236
|
+
}], 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 }] }] } });
|
|
194
237
|
|
|
195
238
|
/**
|
|
196
239
|
* @module @cngx/ui/mat-paginator
|