@cngx/ui 0.1.0-rc.3 → 0.1.0-rc.5
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/accordion/README.md +86 -0
- package/collection/README.md +167 -0
- package/data-grid-accordion/README.md +137 -0
- package/fesm2022/cngx-ui-accordion.mjs +853 -0
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -0
- package/fesm2022/cngx-ui-action-button.mjs +2 -2
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +1044 -0
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -0
- package/fesm2022/cngx-ui-collection.mjs +645 -0
- package/fesm2022/cngx-ui-collection.mjs.map +1 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +1135 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -0
- package/fesm2022/cngx-ui-empty-state.mjs +2 -2
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +10 -10
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +229 -0
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -0
- package/fesm2022/cngx-ui-paginator.mjs +324 -255
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +547 -65
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +6 -6
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +1 -1
- package/mat-accordion/README.md +48 -0
- package/package.json +21 -1
- package/paginator/README.md +9 -6
- package/sidenav/README.md +89 -3
- package/types/cngx-ui-accordion.d.ts +801 -0
- package/types/cngx-ui-breadcrumb.d.ts +890 -0
- package/types/cngx-ui-collection.d.ts +396 -0
- package/types/cngx-ui-data-grid-accordion.d.ts +912 -0
- package/types/cngx-ui-mat-accordion.d.ts +63 -0
- package/types/cngx-ui-paginator.d.ts +258 -146
- package/types/cngx-ui-sidenav.d.ts +429 -21
|
@@ -0,0 +1,1135 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, ElementRef, Directive, contentChildren, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, computed, contentChild, model, Renderer2, effect, DestroyRef, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { coerceBooleanProperty, nextUid, coerceNumberProperty } from '@cngx/core/utils';
|
|
4
|
+
import * as i1 from '@cngx/common/interactive';
|
|
5
|
+
import { CNGX_ACCORDION, CngxAccordionPanel, CngxAccordion } from '@cngx/common/interactive';
|
|
6
|
+
import * as i2 from '@cngx/common/data';
|
|
7
|
+
import { CngxSort, CngxFilter, createSortHeaderState } from '@cngx/common/data';
|
|
8
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
9
|
+
import { CngxLiveAnnouncer } from '@cngx/common/a11y';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* DI token for the {@link CngxDataGridAccordionContext}.
|
|
13
|
+
* {@link CngxDataGridAccordion} provides it via `useExisting`; each
|
|
14
|
+
* {@link CngxDataGridRow} injects it.
|
|
15
|
+
*
|
|
16
|
+
* @category ui/data-grid-accordion
|
|
17
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-accordion.token.ts
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @relatedTo CngxDataGridAccordion, CngxDataGridRow
|
|
20
|
+
*/
|
|
21
|
+
const CNGX_DATA_GRID_ACCORDION = new InjectionToken('CNGX_DATA_GRID_ACCORDION');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Library defaults for the data-grid-accordion configuration cascade. The base
|
|
25
|
+
* default leaves `skin` unset (the flat grid look); consumers move the default
|
|
26
|
+
* via {@link withDataGridSkin}.
|
|
27
|
+
*
|
|
28
|
+
* Exported for intra-lib consumers (`provideDataGridAccordionConfig` merges with
|
|
29
|
+
* this base) but **NOT** re-exported from `public-api.ts` - downstream consumers
|
|
30
|
+
* reach the defaults via `inject(CNGX_DATA_GRID_ACCORDION_CONFIG)` so
|
|
31
|
+
* `provideDataGridAccordionConfig` / `provideDataGridAccordionConfigAt` overrides
|
|
32
|
+
* take precedence.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
const CNGX_DATA_GRID_ACCORDION_DEFAULTS = {};
|
|
37
|
+
/**
|
|
38
|
+
* App-wide configuration cascade for the data-grid-accordion organism. Resolves
|
|
39
|
+
* in priority order:
|
|
40
|
+
*
|
|
41
|
+
* 1. Per-instance `[skin]` Input binding.
|
|
42
|
+
* 2. `provideDataGridAccordionConfigAt(...)` in a parent component's
|
|
43
|
+
* `viewProviders`.
|
|
44
|
+
* 3. `provideDataGridAccordionConfig(...)` at the application root.
|
|
45
|
+
* 4. Library default (this token's `factory`).
|
|
46
|
+
*
|
|
47
|
+
* `providedIn: 'root'` with a default factory means consumers never need to
|
|
48
|
+
* provide the token explicitly - `inject(CNGX_DATA_GRID_ACCORDION_CONFIG)` always
|
|
49
|
+
* resolves.
|
|
50
|
+
*
|
|
51
|
+
* @category ui/data-grid-accordion
|
|
52
|
+
* @since 0.1.0
|
|
53
|
+
*/
|
|
54
|
+
const CNGX_DATA_GRID_ACCORDION_CONFIG = new InjectionToken('CNGX_DATA_GRID_ACCORDION_CONFIG', {
|
|
55
|
+
providedIn: 'root',
|
|
56
|
+
factory: () => CNGX_DATA_GRID_ACCORDION_DEFAULTS,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Convenience accessor for the data-grid-accordion configuration cascade. Runs in
|
|
61
|
+
* injection context; resolves through the priority chain (per-instance Input
|
|
62
|
+
* -> `provideDataGridAccordionConfigAt` -> `provideDataGridAccordionConfig` ->
|
|
63
|
+
* library defaults). Equivalent to `inject(CNGX_DATA_GRID_ACCORDION_CONFIG)` -
|
|
64
|
+
* the helper exists so consumers don't import the token directly. Mirrors
|
|
65
|
+
* `injectAccordionConfig` in `@cngx/ui/accordion`.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* export class CngxDataGridAccordion {
|
|
69
|
+
* private readonly config = injectDataGridAccordionConfig();
|
|
70
|
+
* readonly skin = input<CngxDataGridSkin | undefined>(undefined);
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @category ui/data-grid-accordion
|
|
75
|
+
* @since 0.1.0
|
|
76
|
+
*/
|
|
77
|
+
function injectDataGridAccordionConfig() {
|
|
78
|
+
return inject(CNGX_DATA_GRID_ACCORDION_CONFIG);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A single cell in a {@link CngxDataGridRow}, {@link CngxDataGridHeader}, or
|
|
83
|
+
* {@link CngxDataGridFooter}. Each cell occupies one track of the shared
|
|
84
|
+
* `grid-template-columns` contract; `[align]` sets its inline alignment and
|
|
85
|
+
* `[primary]` marks the one cell that names the row.
|
|
86
|
+
*
|
|
87
|
+
* The cell is visual: the row stays a single `cngxAccordionPanel` button and one
|
|
88
|
+
* `role="region"`, so marking a cell `primary` only points the row's
|
|
89
|
+
* `aria-labelledby` at it - it adds no interactive semantics. Exactly one cell
|
|
90
|
+
* per row should carry `primary`, so the row's accessible name is that cell's
|
|
91
|
+
* text alone rather than every cell concatenated.
|
|
92
|
+
*
|
|
93
|
+
* @category ui/data-grid-accordion
|
|
94
|
+
* @wcag AA
|
|
95
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-cell.directive.ts
|
|
96
|
+
* @since 0.1.0
|
|
97
|
+
* @relatedTo CngxDataGridRow
|
|
98
|
+
*/
|
|
99
|
+
class CngxDgCell {
|
|
100
|
+
/** Inline alignment within the column track: `start` (default), `center`, `end`. */
|
|
101
|
+
align = input('start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
102
|
+
/**
|
|
103
|
+
* Column-sizing intent read off the header cells to derive the shared grid
|
|
104
|
+
* template ({@link CngxDgCellTrack}: `grow` / `fit` / `sm` / `md` / `lg`).
|
|
105
|
+
* Authored on the {@link CngxDataGridHeader} cells; row and footer cells inherit
|
|
106
|
+
* the derived track by position and can leave it unset. Unset falls back to the
|
|
107
|
+
* default (primary column grows, the rest fit). Purely a sizing hint - no host
|
|
108
|
+
* binding, the group reads the signal directly.
|
|
109
|
+
*/
|
|
110
|
+
col = input(undefined, ...(ngDevMode ? [{ debugName: "col" }] : /* istanbul ignore next */ []));
|
|
111
|
+
/**
|
|
112
|
+
* Marks this cell as the row's accessible name. The row's `cngxAccordionPanel`
|
|
113
|
+
* button and its `role="region"` both point `aria-labelledby` at the primary
|
|
114
|
+
* cell, so a screen reader announces one meaningful label per row instead of
|
|
115
|
+
* the concatenated text of every cell.
|
|
116
|
+
*/
|
|
117
|
+
primary = input(false, { ...(ngDevMode ? { debugName: "primary" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
|
|
118
|
+
element = inject(ElementRef).nativeElement;
|
|
119
|
+
/**
|
|
120
|
+
* Stable id the row's `aria-labelledby` references. Reuses a consumer-supplied
|
|
121
|
+
* `id` when present (so the IDREF stays what the consumer expects), otherwise
|
|
122
|
+
* generates one. Read by {@link CngxDataGridRow} to resolve the primary cell.
|
|
123
|
+
*/
|
|
124
|
+
cellId = this.element.id || nextUid('cngx-dga-cell-');
|
|
125
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
126
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxDgCell, isStandalone: true, selector: "[cngxDgaCell]", inputs: { align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, col: { classPropertyName: "col", publicName: "col", isSignal: true, isRequired: false, transformFunction: null }, primary: { classPropertyName: "primary", publicName: "primary", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "id": "cellId", "attr.data-align": "align()", "attr.data-primary": "primary() ? '' : null" }, classAttribute: "cngx-dga-cell" }, exportAs: ["cngxDgaCell"], ngImport: i0 });
|
|
127
|
+
}
|
|
128
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgCell, decorators: [{
|
|
129
|
+
type: Directive,
|
|
130
|
+
args: [{
|
|
131
|
+
selector: '[cngxDgaCell]',
|
|
132
|
+
exportAs: 'cngxDgaCell',
|
|
133
|
+
standalone: true,
|
|
134
|
+
host: {
|
|
135
|
+
class: 'cngx-dga-cell',
|
|
136
|
+
'[id]': 'cellId',
|
|
137
|
+
'[attr.data-align]': 'align()',
|
|
138
|
+
'[attr.data-primary]': "primary() ? '' : null",
|
|
139
|
+
},
|
|
140
|
+
}]
|
|
141
|
+
}], propDecorators: { align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }], col: [{ type: i0.Input, args: [{ isSignal: true, alias: "col", required: false }] }], primary: [{ type: i0.Input, args: [{ isSignal: true, alias: "primary", required: false }] }] } });
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The column-header row of a {@link CngxDataGridAccordion}. Lays its projected
|
|
145
|
+
* `cngxDgaCell`s out on the shared `--cngx-dga-columns` grid so the labels align with
|
|
146
|
+
* the data columns below. It is exposed to assistive tech (no `aria-hidden`) so a
|
|
147
|
+
* `cngxDgaSortHeader` cell is reachable: a focusable sort control inside an
|
|
148
|
+
* `aria-hidden` subtree would be pruned from the accessibility tree and fail
|
|
149
|
+
* `aria-hidden-focus`, and `aria-hidden` cannot be undone by a descendant. The plain
|
|
150
|
+
* label cells now read like a table header row - a small, acceptable trade for keeping
|
|
151
|
+
* the sort controls operable. Each data row still announces its own name through its
|
|
152
|
+
* primary cell, so the disclosure list stays legible.
|
|
153
|
+
*
|
|
154
|
+
* It is also the single **column source**: the group reads these header cells and
|
|
155
|
+
* derives the shared `grid-template-columns` from each cell's `col` track intent
|
|
156
|
+
* (`grow` / `fit` / `sm` / `md` / `lg`), so the columns are defined where they are
|
|
157
|
+
* labelled rather than in a separate template string.
|
|
158
|
+
*
|
|
159
|
+
* @category ui/data-grid-accordion
|
|
160
|
+
* @wcag AA
|
|
161
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-header.component.ts
|
|
162
|
+
* @since 0.1.0
|
|
163
|
+
* @relatedTo CngxDataGridAccordion, CngxDgCell
|
|
164
|
+
*/
|
|
165
|
+
class CngxDataGridHeader {
|
|
166
|
+
/**
|
|
167
|
+
* The projected header cells, in column order. Read by
|
|
168
|
+
* {@link CngxDataGridAccordion} to derive the shared grid template from each
|
|
169
|
+
* cell's `col` track intent.
|
|
170
|
+
*/
|
|
171
|
+
cells = contentChildren(CngxDgCell, ...(ngDevMode ? [{ debugName: "cells" }] : /* istanbul ignore next */ []));
|
|
172
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridHeader, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
173
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxDataGridHeader, isStandalone: true, selector: "cngx-dga-header", host: { classAttribute: "cngx-dga-header" }, queries: [{ propertyName: "cells", predicate: CngxDgCell, isSignal: true }], exportAs: ["cngxDgaHeader"], ngImport: i0, template: '<ng-content />', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
174
|
+
}
|
|
175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridHeader, decorators: [{
|
|
176
|
+
type: Component,
|
|
177
|
+
args: [{
|
|
178
|
+
selector: 'cngx-dga-header',
|
|
179
|
+
exportAs: 'cngxDgaHeader',
|
|
180
|
+
standalone: true,
|
|
181
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
182
|
+
encapsulation: ViewEncapsulation.None,
|
|
183
|
+
template: '<ng-content />',
|
|
184
|
+
host: {
|
|
185
|
+
class: 'cngx-dga-header',
|
|
186
|
+
},
|
|
187
|
+
}]
|
|
188
|
+
}], propDecorators: { cells: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxDgCell), { isSignal: true }] }] } });
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Structural slot for a {@link CngxDataGridRow}'s busy state. The row renders it
|
|
192
|
+
* inside the detail region while the row's `[state]` is `loading` (a first-load
|
|
193
|
+
* skeleton that replaces the body) or `refreshing` (a subtle overlay with the body
|
|
194
|
+
* kept mounted). Absent, the row falls back to its CSS skeleton default.
|
|
195
|
+
*
|
|
196
|
+
* The region already carries `aria-busy` as a `computed()`, so the busy visual is
|
|
197
|
+
* decorative (`aria-hidden`); assistive tech learns the busy state from `aria-busy`,
|
|
198
|
+
* not from this template. The template receives a {@link CngxDgaRowStateContext}
|
|
199
|
+
* whose `$implicit` is the current status (`loading` / `refreshing`), so one
|
|
200
|
+
* override can distinguish the two.
|
|
201
|
+
*
|
|
202
|
+
* ```html
|
|
203
|
+
* <cngx-dga-row [state]="report.status()">
|
|
204
|
+
* <span cngxDgaCell primary>Report</span>
|
|
205
|
+
* <ng-template cngxDgaRowBusy let-status><my-skeleton [dim]="status === 'refreshing'" /></ng-template>
|
|
206
|
+
* {{ report.data() }}
|
|
207
|
+
* </cngx-dga-row>
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @category ui/data-grid-accordion
|
|
211
|
+
* @wcag AA
|
|
212
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-row-busy.directive.ts
|
|
213
|
+
* @since 0.1.0
|
|
214
|
+
* @relatedTo CngxDataGridRow, CngxDgaRowError
|
|
215
|
+
*/
|
|
216
|
+
class CngxDgaRowBusy {
|
|
217
|
+
templateRef = inject((TemplateRef));
|
|
218
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaRowBusy, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
222
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxDgaRowBusy, isStandalone: true, selector: "ng-template[cngxDgaRowBusy]", exportAs: ["cngxDgaRowBusy"], ngImport: i0 });
|
|
223
|
+
}
|
|
224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaRowBusy, decorators: [{
|
|
225
|
+
type: Directive,
|
|
226
|
+
args: [{
|
|
227
|
+
selector: 'ng-template[cngxDgaRowBusy]',
|
|
228
|
+
exportAs: 'cngxDgaRowBusy',
|
|
229
|
+
standalone: true,
|
|
230
|
+
}]
|
|
231
|
+
}] });
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Structural slot for a {@link CngxDataGridRow}'s error state. The row renders it
|
|
235
|
+
* inside the detail region, in a `role="alert"` container, when the row's `[state]`
|
|
236
|
+
* is `error` - so the error body is announced to assistive tech the moment it
|
|
237
|
+
* appears, even if the row was never expanded. Absent, the row renders a minimal
|
|
238
|
+
* CSS error affordance with the resolved `errorMessage`.
|
|
239
|
+
*
|
|
240
|
+
* The template receives a {@link CngxDgaRowStateContext} whose `message` is the
|
|
241
|
+
* resolved error string, so the override can render the announced text (and a
|
|
242
|
+
* retry) without re-deriving it.
|
|
243
|
+
*
|
|
244
|
+
* ```html
|
|
245
|
+
* <cngx-dga-row [state]="report.status()">
|
|
246
|
+
* <span cngxDgaCell primary>Report</span>
|
|
247
|
+
* <ng-template cngxDgaRowError let-message="message">
|
|
248
|
+
* {{ message }} <button type="button" (click)="retry()">Retry</button>
|
|
249
|
+
* </ng-template>
|
|
250
|
+
* </cngx-dga-row>
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @category ui/data-grid-accordion
|
|
254
|
+
* @wcag AA
|
|
255
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-row-error.directive.ts
|
|
256
|
+
* @since 0.1.0
|
|
257
|
+
* @relatedTo CngxDataGridRow, CngxDgaRowBusy
|
|
258
|
+
*/
|
|
259
|
+
class CngxDgaRowError {
|
|
260
|
+
templateRef = inject((TemplateRef));
|
|
261
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaRowError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
265
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxDgaRowError, isStandalone: true, selector: "ng-template[cngxDgaRowError]", exportAs: ["cngxDgaRowError"], ngImport: i0 });
|
|
266
|
+
}
|
|
267
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaRowError, decorators: [{
|
|
268
|
+
type: Directive,
|
|
269
|
+
args: [{
|
|
270
|
+
selector: 'ng-template[cngxDgaRowError]',
|
|
271
|
+
exportAs: 'cngxDgaRowError',
|
|
272
|
+
standalone: true,
|
|
273
|
+
}]
|
|
274
|
+
}] });
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* A disclosure row in a {@link CngxDataGridAccordion}. Renders the APG-correct
|
|
278
|
+
* trio: a `role="heading"` wrapper carrying the group's `aria-level`, a
|
|
279
|
+
* `cngxAccordionPanel` summary `<button>` laid out on the shared
|
|
280
|
+
* `--cngx-dga-columns` grid, and a `role="region"` detail zone named back at the
|
|
281
|
+
* primary cell via `aria-labelledby`. Expansion is derived from the coordinator
|
|
282
|
+
* (Pillar 1); the button self-wires keyboard nav through the registration brain,
|
|
283
|
+
* so arrow keys rove across rows even though each summary lives in its own
|
|
284
|
+
* component view.
|
|
285
|
+
*
|
|
286
|
+
* The projected `cngxDgaCell`s fill the summary grid; the one marked `primary`
|
|
287
|
+
* supplies the row's accessible name, so a screen reader hears a list of
|
|
288
|
+
* expandable sections rather than a wall of cell text.
|
|
289
|
+
*
|
|
290
|
+
* @category ui/data-grid-accordion
|
|
291
|
+
* @docsKind primary
|
|
292
|
+
* @wcag AA
|
|
293
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-row.component.ts
|
|
294
|
+
* @since 0.1.0
|
|
295
|
+
* @relatedTo CngxDataGridAccordion, CngxDgCell, CngxAccordionPanel
|
|
296
|
+
*
|
|
297
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/master-detail</example-url>
|
|
298
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/report</example-url>
|
|
299
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/lazy-row</example-url>
|
|
300
|
+
*/
|
|
301
|
+
class CngxDataGridRow {
|
|
302
|
+
/**
|
|
303
|
+
* Stable id this row registers under in the coordinator's open-set. Defaults to
|
|
304
|
+
* a generated id; bind `[panelId]` to a stable row value to address the row
|
|
305
|
+
* through the group's `[(openIds)]` model - so a sorted row stays open while it
|
|
306
|
+
* moves. Mirrors `CngxAccordionItem.panelId`.
|
|
307
|
+
*/
|
|
308
|
+
panelId = input(nextUid('cngx-dga-row-'), ...(ngDevMode ? [{ debugName: "panelId" }] : /* istanbul ignore next */ []));
|
|
309
|
+
/**
|
|
310
|
+
* Semantic severity reflected onto the `[data-severity]` host attribute for
|
|
311
|
+
* skins that render it (the `log-stream` skin fills a coloured left edge from
|
|
312
|
+
* the matching `--cngx-color-danger` / `-warning` / `-info` token). Purely
|
|
313
|
+
* visual, no ARIA impact.
|
|
314
|
+
*/
|
|
315
|
+
severity = input(undefined, ...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
|
|
316
|
+
/**
|
|
317
|
+
* The row's async lifecycle, communicated to assistive tech. Accepts a raw
|
|
318
|
+
* {@link AsyncStatus} or a {@link CngxAsyncState} the consumer already owns - the
|
|
319
|
+
* row reads only the status discriminator, never the payload, so it stays
|
|
320
|
+
* non-generic. A pure data input (the row injects no `CNGX_STATEFUL`), so no
|
|
321
|
+
* empty-string transform: a bare string status must survive untouched. Mirrors
|
|
322
|
+
* `CngxAccordionItem.state`; the consumer wires the fetch, the row only
|
|
323
|
+
* communicates the state it is handed.
|
|
324
|
+
*/
|
|
325
|
+
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
326
|
+
/** Error message announced in the error state. English default; override per locale. */
|
|
327
|
+
errorMessage = input('Failed to load', ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
328
|
+
accordion = inject(CNGX_ACCORDION);
|
|
329
|
+
grid = inject(CNGX_DATA_GRID_ACCORDION);
|
|
330
|
+
regionId = nextUid('cngx-dga-region-');
|
|
331
|
+
headerId = nextUid('cngx-dga-header-');
|
|
332
|
+
/**
|
|
333
|
+
* Projected cells; the `primary` one supplies the row's accessible name. Public
|
|
334
|
+
* so {@link CngxDataGridAccordion} can read the primary-column index (for the
|
|
335
|
+
* grow default) and use the first row as the column source when no header exists.
|
|
336
|
+
*/
|
|
337
|
+
cells = contentChildren(CngxDgCell, ...(ngDevMode ? [{ debugName: "cells" }] : /* istanbul ignore next */ []));
|
|
338
|
+
/**
|
|
339
|
+
* IDREF of the primary cell, bound to the summary button's and the region's
|
|
340
|
+
* `aria-labelledby`. `null` when no cell is marked `primary` - then the button
|
|
341
|
+
* names itself from its projected content. A primitive, so `Object.is` dedupes.
|
|
342
|
+
*/
|
|
343
|
+
primaryId = computed(() => this.cells().find((cell) => cell.primary())?.cellId ?? null, ...(ngDevMode ? [{ debugName: "primaryId" }] : /* istanbul ignore next */ []));
|
|
344
|
+
/** Whether this row's region is open, derived from the coordinator's open-set. */
|
|
345
|
+
expanded = computed(() => this.accordion.isOpen(this.panelId()), ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
346
|
+
/** Per-instance busy slot; absent means the CSS skeleton default renders. */
|
|
347
|
+
busySlot = contentChild(CngxDgaRowBusy, ...(ngDevMode ? [{ debugName: "busySlot" }] : /* istanbul ignore next */ []));
|
|
348
|
+
/** Per-instance error slot; absent means the CSS error affordance default renders. */
|
|
349
|
+
errorSlot = contentChild(CngxDgaRowError, ...(ngDevMode ? [{ debugName: "errorSlot" }] : /* istanbul ignore next */ []));
|
|
350
|
+
/** Resolved busy template: per-instance slot -> null (CSS skeleton default). */
|
|
351
|
+
busyTemplate = computed(() => this.busySlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "busyTemplate" }] : /* istanbul ignore next */ []));
|
|
352
|
+
/** Resolved error template: per-instance slot -> null (CSS error default). */
|
|
353
|
+
errorTemplate = computed(() => this.errorSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "errorTemplate" }] : /* istanbul ignore next */ []));
|
|
354
|
+
/**
|
|
355
|
+
* Row async status, normalised to an {@link AsyncStatus} from either the raw enum
|
|
356
|
+
* or a {@link CngxAsyncState} object form (reads its `status()` signal). A
|
|
357
|
+
* primitive, so `Object.is` dedupes - no `equal`. Mirrors `CngxAccordionItem`.
|
|
358
|
+
*/
|
|
359
|
+
status = computed(() => {
|
|
360
|
+
const state = this.state();
|
|
361
|
+
if (state == null) {
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
return typeof state === 'string' ? state : state.status();
|
|
365
|
+
}, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
366
|
+
/**
|
|
367
|
+
* `aria-busy` driver. Mirrors `CngxAsyncState.isBusy` (loading|refreshing|pending)
|
|
368
|
+
* so the string and object input forms agree. Boolean, no `equal`.
|
|
369
|
+
*/
|
|
370
|
+
busy = computed(() => {
|
|
371
|
+
const status = this.status();
|
|
372
|
+
return status === 'loading' || status === 'refreshing' || status === 'pending';
|
|
373
|
+
}, ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
|
|
374
|
+
/**
|
|
375
|
+
* Region visibility. Hidden while collapsed, EXCEPT in the error state: an errored
|
|
376
|
+
* row un-hides its region so the `role="alert"` mounts into the live a11y tree and
|
|
377
|
+
* is announced even when the row was never opened (Pillar 2 - an error is never
|
|
378
|
+
* silenced by a collapsed row).
|
|
379
|
+
*/
|
|
380
|
+
regionHidden = computed(() => !this.expanded() && this.status() !== 'error', ...(ngDevMode ? [{ debugName: "regionHidden" }] : /* istanbul ignore next */ []));
|
|
381
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridRow, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
382
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxDataGridRow, isStandalone: true, selector: "cngx-dga-row", inputs: { panelId: { classPropertyName: "panelId", publicName: "panelId", isSignal: true, isRequired: false, transformFunction: null }, severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-expanded": "expanded() ? '' : null", "attr.data-severity": "severity() ?? null" }, classAttribute: "cngx-dga-row" }, queries: [{ propertyName: "cells", predicate: CngxDgCell, isSignal: true }, { propertyName: "busySlot", first: true, predicate: CngxDgaRowBusy, descendants: true, isSignal: true }, { propertyName: "errorSlot", first: true, predicate: CngxDgaRowError, descendants: true, isSignal: true }], exportAs: ["cngxDgaRow"], ngImport: i0, template: "<div role=\"heading\" [attr.aria-level]=\"grid.headingLevel()\" class=\"cngx-dga-row__heading\">\n <button\n type=\"button\"\n cngxAccordionPanel\n class=\"cngx-dga-row__summary\"\n [panelId]=\"panelId()\"\n [controls]=\"regionId\"\n [id]=\"headerId\"\n [attr.aria-labelledby]=\"primaryId()\"\n >\n <span class=\"cngx-dga-row__chevron-slot\" aria-hidden=\"true\">\n <span class=\"cngx-dga-row__chevron\"></span>\n </span>\n <ng-content select=\"[cngxDgaCell]\" />\n </button>\n</div>\n\n<div\n role=\"region\"\n class=\"cngx-dga-row__region\"\n [id]=\"regionId\"\n [attr.aria-labelledby]=\"primaryId()\"\n [attr.aria-busy]=\"busy() ? 'true' : null\"\n [hidden]=\"regionHidden()\"\n>\n @switch (status()) {\n @case ('error') {\n <div class=\"cngx-dga-row__error\" role=\"alert\">\n @if (errorTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: 'error', message: errorMessage() }\"\n />\n } @else {\n <span class=\"cngx-dga-row__error-default\">{{ errorMessage() }}</span>\n }\n </div>\n }\n @case ('loading') {\n <div class=\"cngx-dga-row__busy\" aria-hidden=\"true\">\n @if (busyTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: 'loading', message: '' }\"\n />\n } @else {\n <span class=\"cngx-dga-row__skeleton\"></span>\n }\n </div>\n }\n @default {\n <ng-content />\n @if (status() === 'refreshing') {\n <div class=\"cngx-dga-row__refreshing\" aria-hidden=\"true\">\n @if (busyTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: 'refreshing', message: '' }\"\n />\n } @else {\n <span class=\"cngx-dga-row__refresh-indicator\"></span>\n }\n </div>\n }\n }\n }\n</div>\n", styles: [".cngx-dga-row{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;grid-template-rows:auto auto;border-block-end:var( --cngx-dga-row-divider, 1px solid var(--cngx-dga-border-color, #d1d5db) )}.cngx-dga-row__heading{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;margin:0}.cngx-dga-row__summary{--cngx-accordion-twisty-display: none;grid-column:1 / -1;display:grid;grid-template-columns:subgrid;column-gap:var(--cngx-dga-col-gap, .5rem);align-items:center;inline-size:100%;padding-block:var(--cngx-dga-row-py, .5rem);padding-inline:0;border:0;background:var(--cngx-dga-row-bg, transparent);color:var(--cngx-dga-row-color, inherit);font:inherit;font-size:var(--cngx-dga-fs, inherit);text-align:start;cursor:pointer}.cngx-dga-row__summary:focus-visible{outline:var( --cngx-dga-focus-ring, 2px solid var(--cngx-dga-focus-color, var(--cngx-color-primary, #1d4ed8)) );outline-offset:var(--cngx-dga-focus-offset, -2px)}.cngx-dga-cell{min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cngx-dga-cell:last-child{padding-inline-end:var(--cngx-dga-row-px, .75rem)}.cngx-dga-cell[data-align=center]{justify-self:center;text-align:center}.cngx-dga-cell[data-align=end]{justify-self:end;text-align:end}.cngx-dga-row__chevron-slot{display:inline-flex;align-items:center;justify-content:flex-start;padding-inline-start:var(--cngx-dga-row-px, .75rem)}.cngx-dga-row__chevron{display:block;inline-size:var(--cngx-dga-chevron-size, .6em);block-size:var(--cngx-dga-chevron-size, .6em);border-inline-end:var(--cngx-dga-chevron-stroke, 2px solid currentcolor);border-block-end:var(--cngx-dga-chevron-stroke, 2px solid currentcolor);transform:rotate(45deg);transition:transform var(--cngx-dga-chevron-transition, .15s ease)}.cngx-dga-row[data-expanded] .cngx-dga-row__chevron{transform:rotate(225deg)}.cngx-dga-row__region{grid-column:1 / -1;padding:var(--cngx-dga-region-padding, .75rem 1rem)}.cngx-dga-row__error{color:var(--cngx-color-danger, #b42318)}.cngx-dga-row__error-default{font:inherit}.cngx-dga-row__skeleton{display:block;block-size:var(--cngx-dga-skeleton-height, 1.25rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-dga-skeleton-color, var(--cngx-color-border, #e5e7eb))}.cngx-dga-row__refreshing{block-size:var(--cngx-dga-refresh-height, 2px);margin-block-start:var(--cngx-dga-refresh-gap, .5rem);background:var(--cngx-dga-refresh-color, var(--cngx-color-primary, #1d4ed8));opacity:var(--cngx-dga-refresh-opacity, .6)}@media(prefers-reduced-motion:reduce){.cngx-dga-row__chevron{transition:none}}\n"], dependencies: [{ kind: "directive", type: CngxAccordionPanel, selector: "[cngxAccordionPanel]", inputs: ["panelId", "controls", "disabled"], exportAs: ["cngxAccordionPanel"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
383
|
+
}
|
|
384
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridRow, decorators: [{
|
|
385
|
+
type: Component,
|
|
386
|
+
args: [{ selector: 'cngx-dga-row', exportAs: 'cngxDgaRow', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxAccordionPanel, NgTemplateOutlet], host: {
|
|
387
|
+
class: 'cngx-dga-row',
|
|
388
|
+
'[attr.data-expanded]': "expanded() ? '' : null",
|
|
389
|
+
'[attr.data-severity]': 'severity() ?? null',
|
|
390
|
+
}, template: "<div role=\"heading\" [attr.aria-level]=\"grid.headingLevel()\" class=\"cngx-dga-row__heading\">\n <button\n type=\"button\"\n cngxAccordionPanel\n class=\"cngx-dga-row__summary\"\n [panelId]=\"panelId()\"\n [controls]=\"regionId\"\n [id]=\"headerId\"\n [attr.aria-labelledby]=\"primaryId()\"\n >\n <span class=\"cngx-dga-row__chevron-slot\" aria-hidden=\"true\">\n <span class=\"cngx-dga-row__chevron\"></span>\n </span>\n <ng-content select=\"[cngxDgaCell]\" />\n </button>\n</div>\n\n<div\n role=\"region\"\n class=\"cngx-dga-row__region\"\n [id]=\"regionId\"\n [attr.aria-labelledby]=\"primaryId()\"\n [attr.aria-busy]=\"busy() ? 'true' : null\"\n [hidden]=\"regionHidden()\"\n>\n @switch (status()) {\n @case ('error') {\n <div class=\"cngx-dga-row__error\" role=\"alert\">\n @if (errorTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: 'error', message: errorMessage() }\"\n />\n } @else {\n <span class=\"cngx-dga-row__error-default\">{{ errorMessage() }}</span>\n }\n </div>\n }\n @case ('loading') {\n <div class=\"cngx-dga-row__busy\" aria-hidden=\"true\">\n @if (busyTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: 'loading', message: '' }\"\n />\n } @else {\n <span class=\"cngx-dga-row__skeleton\"></span>\n }\n </div>\n }\n @default {\n <ng-content />\n @if (status() === 'refreshing') {\n <div class=\"cngx-dga-row__refreshing\" aria-hidden=\"true\">\n @if (busyTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: 'refreshing', message: '' }\"\n />\n } @else {\n <span class=\"cngx-dga-row__refresh-indicator\"></span>\n }\n </div>\n }\n }\n }\n</div>\n", styles: [".cngx-dga-row{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;grid-template-rows:auto auto;border-block-end:var( --cngx-dga-row-divider, 1px solid var(--cngx-dga-border-color, #d1d5db) )}.cngx-dga-row__heading{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;margin:0}.cngx-dga-row__summary{--cngx-accordion-twisty-display: none;grid-column:1 / -1;display:grid;grid-template-columns:subgrid;column-gap:var(--cngx-dga-col-gap, .5rem);align-items:center;inline-size:100%;padding-block:var(--cngx-dga-row-py, .5rem);padding-inline:0;border:0;background:var(--cngx-dga-row-bg, transparent);color:var(--cngx-dga-row-color, inherit);font:inherit;font-size:var(--cngx-dga-fs, inherit);text-align:start;cursor:pointer}.cngx-dga-row__summary:focus-visible{outline:var( --cngx-dga-focus-ring, 2px solid var(--cngx-dga-focus-color, var(--cngx-color-primary, #1d4ed8)) );outline-offset:var(--cngx-dga-focus-offset, -2px)}.cngx-dga-cell{min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cngx-dga-cell:last-child{padding-inline-end:var(--cngx-dga-row-px, .75rem)}.cngx-dga-cell[data-align=center]{justify-self:center;text-align:center}.cngx-dga-cell[data-align=end]{justify-self:end;text-align:end}.cngx-dga-row__chevron-slot{display:inline-flex;align-items:center;justify-content:flex-start;padding-inline-start:var(--cngx-dga-row-px, .75rem)}.cngx-dga-row__chevron{display:block;inline-size:var(--cngx-dga-chevron-size, .6em);block-size:var(--cngx-dga-chevron-size, .6em);border-inline-end:var(--cngx-dga-chevron-stroke, 2px solid currentcolor);border-block-end:var(--cngx-dga-chevron-stroke, 2px solid currentcolor);transform:rotate(45deg);transition:transform var(--cngx-dga-chevron-transition, .15s ease)}.cngx-dga-row[data-expanded] .cngx-dga-row__chevron{transform:rotate(225deg)}.cngx-dga-row__region{grid-column:1 / -1;padding:var(--cngx-dga-region-padding, .75rem 1rem)}.cngx-dga-row__error{color:var(--cngx-color-danger, #b42318)}.cngx-dga-row__error-default{font:inherit}.cngx-dga-row__skeleton{display:block;block-size:var(--cngx-dga-skeleton-height, 1.25rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-dga-skeleton-color, var(--cngx-color-border, #e5e7eb))}.cngx-dga-row__refreshing{block-size:var(--cngx-dga-refresh-height, 2px);margin-block-start:var(--cngx-dga-refresh-gap, .5rem);background:var(--cngx-dga-refresh-color, var(--cngx-color-primary, #1d4ed8));opacity:var(--cngx-dga-refresh-opacity, .6)}@media(prefers-reduced-motion:reduce){.cngx-dga-row__chevron{transition:none}}\n"] }]
|
|
391
|
+
}], propDecorators: { panelId: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelId", required: false }] }], severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], cells: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxDgCell), { isSignal: true }] }], busySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxDgaRowBusy), { isSignal: true }] }], errorSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxDgaRowError), { isSignal: true }] }] } });
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Data-grid accordion group. A disclosure accordion whose header, rows, and
|
|
395
|
+
* footer all share one `grid-template-columns` contract, so N arbitrary cells
|
|
396
|
+
* align down the grid - the ceiling the accordion `data-grid` skin could never
|
|
397
|
+
* reach with its fixed three slots. Hosts the headless {@link CngxAccordion}
|
|
398
|
+
* brain via `hostDirectives` (so `CNGX_ACCORDION` and roving keyboard nav come
|
|
399
|
+
* with it), forwards `[multi]` and the controlled `[(openIds)]` model, publishes
|
|
400
|
+
* the column template onto the inherited `--cngx-dga-columns` property, and
|
|
401
|
+
* reflects `[skin]` onto `[data-skin]`. Projects its {@link CngxDataGridHeader},
|
|
402
|
+
* {@link CngxDataGridRow}s, and {@link CngxDataGridFooter} through a single
|
|
403
|
+
* `<ng-content />`; it owns no rendering beyond providing
|
|
404
|
+
* {@link CNGX_DATA_GRID_ACCORDION} so rows read the shared heading level.
|
|
405
|
+
*
|
|
406
|
+
* It is a disclosure accordion, not a data grid: no `role="grid"`, no cell edit,
|
|
407
|
+
* no selection model, no keyboard grid navigation. It hosts the orthogonal
|
|
408
|
+
* {@link CngxSort} atom as a second `hostDirective` and exposes it on
|
|
409
|
+
* {@link CNGX_DATA_GRID_ACCORDION} as `sort`, so header cells become sortable with
|
|
410
|
+
* one `cngxDgaSortHeader` attribute (no `[cngxSortRef]` plumbing) and a consumer can
|
|
411
|
+
* bind the controlled `[sortActive]` / `[sortDirection]` inputs and read `(sortChange)`.
|
|
412
|
+
* For an uncontrolled grid that just needs a starting order, `[initialSort]="{ active,
|
|
413
|
+
* direction }"` seeds the sort once and then yields to header clicks.
|
|
414
|
+
* It hosts the orthogonal {@link CngxFilter} atom the same way, exposed as `filter`:
|
|
415
|
+
* `[filterPredicate]` forwards to its controlled predicate, `(filterChange)` re-emits,
|
|
416
|
+
* and a projected `cngxDgaFilter` input two-way-binds the simple `[(filterTerm)]`.
|
|
417
|
+
* The group only publishes sort/filter state - the consumer still derives the
|
|
418
|
+
* visible + ordered rows via a `computed()` and owns the `@for`; the open set is keyed
|
|
419
|
+
* by row value so a sorted or filtered row stays open while it moves.
|
|
420
|
+
*
|
|
421
|
+
* The column widths are declared on the header cells via `col`
|
|
422
|
+
* (`grow` / `fit` / `sm` / `md` / `lg`); the group derives the shared template from
|
|
423
|
+
* them, so no `grid-template-columns` string is needed for the common case.
|
|
424
|
+
*
|
|
425
|
+
* ```html
|
|
426
|
+
* <cngx-data-grid-accordion [multi]="true">
|
|
427
|
+
* <cngx-dga-header>
|
|
428
|
+
* <span cngxDgaCell col="sm">ID</span>
|
|
429
|
+
* <span cngxDgaCell col="grow">Name</span>
|
|
430
|
+
* <span cngxDgaCell col="md" align="end">Amount</span>
|
|
431
|
+
* </cngx-dga-header>
|
|
432
|
+
* <cngx-dga-row panelId="1">
|
|
433
|
+
* <span cngxDgaCell>1</span>
|
|
434
|
+
* <span cngxDgaCell primary>Alpha</span>
|
|
435
|
+
* <span cngxDgaCell align="end">120.00</span>
|
|
436
|
+
* Detail for row 1
|
|
437
|
+
* </cngx-dga-row>
|
|
438
|
+
* <cngx-dga-footer>
|
|
439
|
+
* <span cngxDgaCell>Total</span>
|
|
440
|
+
* </cngx-dga-footer>
|
|
441
|
+
* </cngx-data-grid-accordion>
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @category ui/data-grid-accordion
|
|
445
|
+
* @docsKind primary
|
|
446
|
+
* @wcag AA
|
|
447
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-accordion.component.ts
|
|
448
|
+
* @since 0.1.0
|
|
449
|
+
* @relatedTo CngxDataGridRow, CngxDgCell, CngxDataGridHeader, CngxDataGridFooter, CngxAccordion, CngxSort, CngxFilter, CngxDgaSortHeader, CngxDgaFilter, CngxDgaCount
|
|
450
|
+
*
|
|
451
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/sortable-ledger</example-url>
|
|
452
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/bound-sort-filter</example-url>
|
|
453
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/master-detail</example-url>
|
|
454
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/spreadsheet</example-url>
|
|
455
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/density</example-url>
|
|
456
|
+
*/
|
|
457
|
+
class CngxDataGridAccordion {
|
|
458
|
+
// Config cascade source. Declared first so the resolvedSkin computed below can
|
|
459
|
+
// read it (field initialisers run top-to-bottom).
|
|
460
|
+
config = injectDataGridAccordionConfig();
|
|
461
|
+
/**
|
|
462
|
+
* The hosted {@link CngxSort} instance, exposed on {@link CNGX_DATA_GRID_ACCORDION}
|
|
463
|
+
* so `cngxDgaSortHeader` cells read the shared sort with no `[cngxSortRef]`. It is a
|
|
464
|
+
* `hostDirective`, so it lives on this element's injector; `{ self: true }` resolves
|
|
465
|
+
* that instance rather than an ancestor's. The group publishes it as state - the
|
|
466
|
+
* consumer's `computed()` still derives the ordered rows (Ableitung preserved).
|
|
467
|
+
*/
|
|
468
|
+
sort = inject(CngxSort, { self: true });
|
|
469
|
+
/**
|
|
470
|
+
* The hosted {@link CngxFilter} instance, exposed on {@link CNGX_DATA_GRID_ACCORDION}
|
|
471
|
+
* as `filter`. `[filterPredicate]` forwards to its controlled predicate; consumers
|
|
472
|
+
* read `filter.predicate()` (or drive `addPredicate` for facet filtering) and derive
|
|
473
|
+
* the visible rows themselves. State only - the group never hides projected rows.
|
|
474
|
+
*/
|
|
475
|
+
filter = inject(CngxFilter, { self: true });
|
|
476
|
+
/**
|
|
477
|
+
* The simple text filter term, two-way bindable as `[(filterTerm)]`. A `model()`
|
|
478
|
+
* because it is a two-way primary value the projected `cngxDgaFilter` input writes
|
|
479
|
+
* (a plain `input()` could not be set from the slot). The group publishes it on the
|
|
480
|
+
* context so the consumer's `computed()` matches it against its own row fields - the
|
|
481
|
+
* group holds no field knowledge and does no matching (Pillar 3).
|
|
482
|
+
*/
|
|
483
|
+
filterTerm = model('', ...(ngDevMode ? [{ debugName: "filterTerm" }] : /* istanbul ignore next */ []));
|
|
484
|
+
/**
|
|
485
|
+
* Raw `grid-template-columns` escape hatch. Leave it unset for the common case:
|
|
486
|
+
* the group derives the shared template from the header cells' `col` intents
|
|
487
|
+
* (see {@link resolvedColumns}). Set it only when a skin needs track syntax the
|
|
488
|
+
* `col` vocabulary cannot express - `ch` tracks, `subgrid`, `minmax` - such as the
|
|
489
|
+
* `spreadsheet` skin. When set, it wins over the derived value. It holds content
|
|
490
|
+
* columns only: the disclosure chevron rides a leading gutter outside the grid, so
|
|
491
|
+
* it never consumes a track. Per-instance only - no app-wide config default
|
|
492
|
+
* (unlike `[skin]`).
|
|
493
|
+
*/
|
|
494
|
+
columns = input(undefined, ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
495
|
+
/**
|
|
496
|
+
* Heading level (2-6) every row's `role="heading"` wrapper reflects via
|
|
497
|
+
* `aria-level`. Clamped into the valid ARIA range so a stray `0`/`9` can never
|
|
498
|
+
* emit an invalid `aria-level`; the default is clamped explicitly because
|
|
499
|
+
* Angular runs `transform` only on bound values, not the initial default.
|
|
500
|
+
* Coerced from string via `coerceNumberProperty` for attribute binding.
|
|
501
|
+
*/
|
|
502
|
+
headingLevel = input(clampHeadingLevel(3), { ...(ngDevMode ? { debugName: "headingLevel" } : /* istanbul ignore next */ {}), transform: (value) => clampHeadingLevel(value) });
|
|
503
|
+
/**
|
|
504
|
+
* Visual skin reflected onto the `[data-skin]` host attribute. Resolves
|
|
505
|
+
* `input ?? CNGX_DATA_GRID_ACCORDION_CONFIG.skin`: an unbound `[skin]` falls
|
|
506
|
+
* back to the app-wide config default (`withDataGridSkin`); unset on both
|
|
507
|
+
* leaves the base flat grid look. The skin only redirects CSS - structure,
|
|
508
|
+
* cells, ARIA, and keyboard behaviour are identical across skins.
|
|
509
|
+
*/
|
|
510
|
+
skin = input(undefined, ...(ngDevMode ? [{ debugName: "skin" }] : /* istanbul ignore next */ []));
|
|
511
|
+
/** `[skin]` input over the config default. `null` host binding when unset. */
|
|
512
|
+
resolvedSkin = computed(() => this.skin() ?? this.config.skin, ...(ngDevMode ? [{ debugName: "resolvedSkin" }] : /* istanbul ignore next */ []));
|
|
513
|
+
// The header is the single column source; the first row provides the primary
|
|
514
|
+
// index (for the grow default) and doubles as the source when no header exists.
|
|
515
|
+
header = contentChild(CngxDataGridHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
516
|
+
firstRow = contentChild(CngxDataGridRow, ...(ngDevMode ? [{ debugName: "firstRow" }] : /* istanbul ignore next */ []));
|
|
517
|
+
/** Index of the primary column, read from the first row's `primary` cell (-1 = none). */
|
|
518
|
+
primaryIndex = computed(() => this.firstRow()?.cells().findIndex((cell) => cell.primary()) ?? -1, ...(ngDevMode ? [{ debugName: "primaryIndex" }] : /* istanbul ignore next */ []));
|
|
519
|
+
/** Column source: the header cells, or the first row's cells when no header exists. */
|
|
520
|
+
sourceCells = computed(() => this.header()?.cells() ?? this.firstRow()?.cells() ?? [], ...(ngDevMode ? [{ debugName: "sourceCells" }] : /* istanbul ignore next */ []));
|
|
521
|
+
/**
|
|
522
|
+
* `grid-template-columns` derived from the column intents: each source cell's
|
|
523
|
+
* `col` track maps to a CSS track; unset falls back to the default (the primary
|
|
524
|
+
* column grows, every other column fits). `null` until a source cell exists.
|
|
525
|
+
*/
|
|
526
|
+
derivedColumns = computed(() => {
|
|
527
|
+
const cells = this.sourceCells();
|
|
528
|
+
if (cells.length === 0) {
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
const primary = this.primaryIndex();
|
|
532
|
+
return cells.map((cell, index) => trackFor(cell.col(), index === primary)).join(' ');
|
|
533
|
+
}, ...(ngDevMode ? [{ debugName: "derivedColumns" }] : /* istanbul ignore next */ []));
|
|
534
|
+
/**
|
|
535
|
+
* The shared column template published onto `--cngx-dga-columns`. Derivation over
|
|
536
|
+
* management (Pillar 1): a single `computed()` from one source (the header), not a
|
|
537
|
+
* hand-synced string. Precedence: an explicit `[columns]` escape hatch wins, else
|
|
538
|
+
* the header-derived template, else a single `1fr`. Primitive string, so
|
|
539
|
+
* `Object.is` dedupes with no `equal` fn.
|
|
540
|
+
*/
|
|
541
|
+
resolvedColumns = computed(() => this.columns() ?? this.derivedColumns() ?? '1fr', ...(ngDevMode ? [{ debugName: "resolvedColumns" }] : /* istanbul ignore next */ []));
|
|
542
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridAccordion, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
543
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxDataGridAccordion, isStandalone: true, selector: "cngx-data-grid-accordion", inputs: { filterTerm: { classPropertyName: "filterTerm", publicName: "filterTerm", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null }, skin: { classPropertyName: "skin", publicName: "skin", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filterTerm: "filterTermChange" }, host: { properties: { "attr.data-skin": "resolvedSkin() ?? null", "style.--cngx-dga-columns": "resolvedColumns()" }, classAttribute: "cngx-data-grid-accordion" }, providers: [{ provide: CNGX_DATA_GRID_ACCORDION, useExisting: CngxDataGridAccordion }], queries: [{ propertyName: "header", first: true, predicate: CngxDataGridHeader, descendants: true, isSignal: true }, { propertyName: "firstRow", first: true, predicate: CngxDataGridRow, descendants: true, isSignal: true }], exportAs: ["cngxDataGridAccordion"], hostDirectives: [{ directive: i1.CngxAccordion, inputs: ["multi", "multi", "openIds", "openIds"], outputs: ["openIdsChange", "openIdsChange"] }, { directive: i2.CngxSort, inputs: ["cngxSortActive", "sortActive", "cngxSortDirection", "sortDirection", "cngxSortInitial", "initialSort", "multiSort", "multiSort"], outputs: ["sortChange", "sortChange"] }, { directive: i2.CngxFilter, inputs: ["cngxFilter", "filterPredicate"], outputs: ["filterChange", "filterChange"] }], ngImport: i0, template: '<div class="cngx-data-grid-accordion__grid"><ng-content /></div>', isInline: true, styles: [".cngx-data-grid-accordion{display:block;inline-size:100%;overflow-x:auto}.cngx-data-grid-accordion__grid{display:grid;grid-template-columns:var(--cngx-dga-lead, 2rem) var(--cngx-dga-columns, 1fr);column-gap:var(--cngx-dga-col-gap, .5rem);min-inline-size:var(--cngx-dga-min-width, 0)}.cngx-dga-header,.cngx-dga-footer{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;align-items:center;padding-block:var(--cngx-dga-row-py, .5rem);font-size:var(--cngx-dga-fs, inherit)}.cngx-dga-header>.cngx-dga-cell:first-child,.cngx-dga-footer>.cngx-dga-cell:first-child{grid-column-start:2}.cngx-dga-header{font-weight:var(--cngx-dga-head-weight, 600);color:var(--cngx-dga-head-color, var(--cngx-color-text-muted, #6b7280));border-block-end:var( --cngx-dga-head-border, 1px solid var(--cngx-dga-border-color, #d1d5db) )}.cngx-dga-footer{border-block-start:var( --cngx-dga-foot-border, 1px solid var(--cngx-dga-border-color, #d1d5db) )}.cngx-data-grid-accordion:not([data-skin]){--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: var(--cngx-space-md, 16px);--cngx-dga-region-padding: var(--cngx-space-sm, 8px) var(--cngx-space-md, 16px);--cngx-dga-col-gap: var(--cngx-space-sm, 8px);--cngx-dga-border-color: var(--cngx-color-border, #d1d5db)}.cngx-data-grid-accordion:not([data-skin]) .cngx-data-grid-accordion__grid{border-block:1px solid var(--cngx-dga-border-color, #d1d5db)}.cngx-data-grid-accordion:not([data-skin]) .cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}.cngx-data-grid-accordion:not([data-skin]) .cngx-dga-row__summary:hover{background:color-mix(in oklab,var(--cngx-color-text, #0f1320) 4%,transparent)}.cngx-dga-sort-header{cursor:pointer;-webkit-user-select:none;user-select:none}.cngx-dga-sort-header:focus-visible{outline:var( --cngx-dga-focus-ring, 2px solid var(--cngx-dga-focus-color, var(--cngx-color-primary, #1d4ed8)) );outline-offset:var(--cngx-dga-focus-offset, 2px)}.cngx-dga-sort-header--active:after{margin-inline-start:var(--cngx-dga-sort-indicator-gap, .35em);font-size:var(--cngx-dga-sort-indicator-size, .7em);color:var(--cngx-dga-sort-indicator-color, var(--cngx-color-primary, #1d4ed8))}.cngx-dga-sort-header--asc:after{content:\"\\25b2\"}.cngx-dga-sort-header--desc:after{content:\"\\25bc\"}.cngx-dga-sort-header__sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}\n", "@scope(.cngx-data-grid-accordion[data-skin=ledger]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);--cngx-dga-min-width: 38rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 1rem;--cngx-dga-fs: .875rem;--cngx-dga-region-padding: 1rem 1.25rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row:nth-of-type(2n) .cngx-dga-row__summary{background:var(--cngx-dga-surface-alt)}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}.cngx-dga-row__summary:hover{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row__region{background:var(--cngx-dga-surface-alt);border-block-start:1px solid var(--cngx-color-border, #d1d5db);box-shadow:inset 3px 0 0 var(--cngx-color-primary, #1d4ed8)}.cngx-dga-footer{background:var(--cngx-dga-surface-strong);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}}@scope(.cngx-data-grid-accordion[data-skin=spreadsheet]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 35rem;counter-reset:cngx-dga-row;--cngx-dga-col-gap: 0;--cngx-dga-row-py: 0;--cngx-dga-row-px: 0px;--cngx-dga-lead: 1.5rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) );--cngx-dga-region-padding: 1.4rem 1rem 1rem 3rem}.cngx-dga-header,.cngx-dga-row__summary,.cngx-dga-footer{align-items:stretch}.cngx-dga-cell{display:flex;align-items:center;justify-self:stretch;padding:.45rem .7rem;border-inline-end:1px solid var(--cngx-dga-border-color, #d1d5db)}:scope .cngx-dga-cell:last-child{padding-inline-end:.7rem}:scope .cngx-dga-cell[data-align=center]{justify-self:stretch;justify-content:center}:scope .cngx-dga-cell[data-align=end]{justify-self:stretch;justify-content:flex-end}.cngx-dga-header,.cngx-dga-row,.cngx-dga-footer{counter-increment:cngx-dga-row}.cngx-dga-header:before,.cngx-dga-row__summary:before,.cngx-dga-footer:before{content:counter(cngx-dga-row);display:flex;align-items:center;justify-content:flex-end;padding:.45rem .5rem;background:var(--cngx-dga-surface-strong);border-inline-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-header:before{padding-block-start:calc(.45rem + var(--cngx-dga-letter-band, 1.15rem))}:scope .cngx-data-grid-accordion__grid{grid-template-columns:var(--cngx-dga-columns, 1fr);padding-inline-start:var(--cngx-dga-lead, 1.5rem);position:relative}.cngx-data-grid-accordion__grid:before{content:\"\";position:absolute;inset-block:0;inset-inline-start:0;inline-size:var(--cngx-dga-lead, 1.5rem);background:var(--cngx-dga-surface-strong)}.cngx-dga-row__summary{position:relative}.cngx-dga-row__chevron-slot{position:absolute;inset-inline-start:calc(-1 * var(--cngx-dga-lead, 1.5rem));inset-block:0;inline-size:var(--cngx-dga-lead, 1.5rem);justify-content:center;padding-inline-start:0}:scope .cngx-dga-header>.cngx-dga-cell:first-child,:scope .cngx-dga-footer>.cngx-dga-cell:first-child{grid-column-start:auto}.cngx-dga-header{background:var(--cngx-dga-surface-alt);color:var(--cngx-color-text, #0f1320);font-weight:400;counter-reset:cngx-dga-col}.cngx-dga-header .cngx-dga-cell{position:relative;padding-block-start:calc(.45rem + var(--cngx-dga-letter-band, 1.15rem));font-weight:650}.cngx-dga-header .cngx-dga-cell:before{content:\"\";position:absolute;inset-block-start:0;inset-inline:0;block-size:var(--cngx-dga-letter-band, 1.15rem);display:flex;align-items:center;justify-content:flex-start;padding-inline:.7rem;background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}:scope .cngx-dga-header .cngx-dga-cell[data-align=center]:before{justify-content:center}:scope .cngx-dga-header .cngx-dga-cell[data-align=end]:before{justify-content:flex-end}.cngx-dga-header .cngx-dga-cell{counter-increment:cngx-dga-col}.cngx-dga-header .cngx-dga-cell:before{content:counter(cngx-dga-col,upper-alpha)}.cngx-dga-row__summary:hover .cngx-dga-cell,.cngx-dga-row[data-expanded] .cngx-dga-row__summary .cngx-dga-cell{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row[data-expanded] .cngx-dga-row__summary:before{background:var(--cngx-color-primary, #1d4ed8);color:var(--cngx-color-on-primary, #fff)}.cngx-dga-row__region{position:relative;background:color-mix(in oklab,var(--cngx-color-warning, #f59e0b) 9%,var(--cngx-color-surface, #fff));border-block-end:1px solid var(--cngx-dga-border-color, #d1d5db)}.cngx-dga-row__region:before{content:\"NOTE\";position:absolute;inset-block-start:.4rem;inset-inline-start:3rem;font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:.625rem;letter-spacing:.1em;color:color-mix(in oklab,var(--cngx-color-warning, #f59e0b) 80%,var(--cngx-color-text, #0f1320))}.cngx-dga-footer{background:var(--cngx-dga-surface-alt);color:var(--cngx-color-text, #0f1320)}.cngx-dga-footer .cngx-dga-cell{font-weight:650}}@scope(.cngx-data-grid-accordion[data-skin=log-stream]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-fs, .75rem);--cngx-dga-min-width: 33rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 1rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary{position:relative}.cngx-dga-row__summary:before{content:\"\";position:absolute;inset-block:0;inset-inline-start:0;inline-size:3px;background:transparent}.cngx-dga-row[data-severity=error] .cngx-dga-row__summary:before{background:var(--cngx-color-danger, #dc2626)}.cngx-dga-row[data-severity=warning] .cngx-dga-row__summary:before{background:var(--cngx-color-warning, #f59e0b)}.cngx-dga-row[data-severity=info] .cngx-dga-row__summary:before{background:var(--cngx-color-info, #2563eb)}.cngx-dga-row__summary .cngx-dga-cell:first-child{color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary:hover,.cngx-dga-row[data-expanded] .cngx-dga-row__summary{background:var(--cngx-dga-surface-alt)}.cngx-dga-row__region{background:var(--cngx-dga-surface-strong);border-block-start:1px solid var(--cngx-color-border, #d1d5db)}.cngx-dga-row__region pre{margin:0;overflow-x:auto;color:var(--cngx-color-text-muted, #6b7280);line-height:1.55;font-size:var(--cngx-dga-fs, .75rem)}.cngx-dga-footer{display:flex;justify-content:space-between;align-items:center;gap:1rem;padding-inline:var(--cngx-dga-row-px, 1rem);background:var(--cngx-dga-surface-strong);border-block-start:1px solid var(--cngx-color-border, #d1d5db);color:var(--cngx-color-text-muted, #6b7280)}}@scope(.cngx-data-grid-accordion[data-skin=master-detail]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 35rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 1rem;--cngx-dga-region-padding: .75rem 1rem 1rem 1.25rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);font-weight:400;text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary .cngx-dga-cell:first-child{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary .cngx-dga-cell[data-primary]{font-weight:620;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary .cngx-dga-cell[data-align=end]{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace)}.cngx-dga-row__summary:hover,.cngx-dga-row[data-expanded] .cngx-dga-row__summary{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row__region{background:var(--cngx-dga-surface-alt);border-block-start:1px solid var(--cngx-color-border, #d1d5db);box-shadow:inset 3px 0 0 var(--cngx-color-primary, #1d4ed8)}.cngx-dga-row__region table{inline-size:100%;border-collapse:collapse;font-size:var(--cngx-dga-fs, .875rem)}.cngx-dga-row__region th,.cngx-dga-row__region td{padding:.45rem .5rem;border-block-end:1px solid var(--cngx-dga-border-color, #d1d5db);text-align:start;white-space:nowrap}.cngx-dga-row__region th{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);font-weight:500;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__region td{color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__region th.r,.cngx-dga-row__region td.r{text-align:end;font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace)}.cngx-dga-row__region tfoot td{border-block-end:none;font-weight:700;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__region tfoot td:first-child{font-weight:600;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-footer{background:var(--cngx-dga-surface-strong);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-footer .cngx-dga-cell[data-align=end]{font-weight:700;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}}@scope(.cngx-data-grid-accordion[data-skin=report]){:scope{background:transparent;font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 40rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 0;--cngx-dga-fs: .875rem;--cngx-dga-head-fs: .75rem;--cngx-dga-region-padding: .1rem 0 .85rem calc(var(--cngx-dga-lead, 2rem) + var(--cngx-dga-col-sm, 5rem) + var(--cngx-dga-col-gap, .75rem));--cngx-dga-border-color: var(--cngx-color-border, #d1d5db)}.cngx-dga-header{border-block-end:3px double color-mix(in oklab,var(--cngx-color-text, #0f1320) 45%,transparent);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);font-weight:400;text-transform:uppercase;letter-spacing:.1em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary:hover{background:color-mix(in oklab,var(--cngx-color-text, #0f1320) 5%,transparent)}.cngx-dga-row__summary .cngx-dga-cell:first-child{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary .cngx-dga-cell[data-primary]{font-weight:620;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary .cngx-dga-cell[data-align=end]{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary .cngx-dga-cell[data-over]{color:var(--cngx-color-danger, #dc2626);font-weight:700}.cngx-dga-row__region{font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280);max-inline-size:60ch}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}.cngx-dga-footer{border-block-start:3px double color-mix(in oklab,var(--cngx-color-text, #0f1320) 45%,transparent);color:var(--cngx-color-text, #0f1320)}.cngx-dga-footer .cngx-dga-cell[data-primary]{font-weight:700}.cngx-dga-footer .cngx-dga-cell[data-align=end]{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-weight:700;color:var(--cngx-color-text, #0f1320)}}@scope(.cngx-data-grid-accordion[data-skin=density]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 32rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: .6rem;--cngx-dga-row-px: 1rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header,.cngx-dga-row__summary{transition:padding var(--cngx-dga-transition, .3s cubic-bezier(.22, 1, .36, 1))}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary:hover,.cngx-dga-row[data-expanded] .cngx-dga-row__summary{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row__summary .cngx-dga-cell[data-primary]{font-weight:620;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary>.cngx-dga-cell:nth-child(3){font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__region{background:var(--cngx-dga-surface-alt);border-block-start:1px solid var(--cngx-color-border, #d1d5db);box-shadow:inset 3px 0 0 var(--cngx-color-primary, #1d4ed8)}.cngx-dga-footer{display:flex;justify-content:space-between;align-items:center;gap:1rem;padding-inline:var(--cngx-dga-row-px, 1rem);background:var(--cngx-dga-surface-strong);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
544
|
+
}
|
|
545
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridAccordion, decorators: [{
|
|
546
|
+
type: Component,
|
|
547
|
+
args: [{ selector: 'cngx-data-grid-accordion', exportAs: 'cngxDataGridAccordion', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, hostDirectives: [
|
|
548
|
+
{ directive: CngxAccordion, inputs: ['multi', 'openIds'], outputs: ['openIdsChange'] },
|
|
549
|
+
// Sort is the orthogonal `@cngx/common/data` atom, hosted here so header cells reach
|
|
550
|
+
// it through the context token with no `[cngxSortRef]`. Its controlled inputs are
|
|
551
|
+
// re-exposed as `[sortActive]` / `[sortDirection]`; the primary change re-emits as
|
|
552
|
+
// `(sortChange)`. The group publishes state only - derivation stays with the consumer.
|
|
553
|
+
{
|
|
554
|
+
directive: CngxSort,
|
|
555
|
+
inputs: [
|
|
556
|
+
'cngxSortActive: sortActive',
|
|
557
|
+
'cngxSortDirection: sortDirection',
|
|
558
|
+
'cngxSortInitial: initialSort',
|
|
559
|
+
'multiSort',
|
|
560
|
+
],
|
|
561
|
+
outputs: ['sortChange'],
|
|
562
|
+
},
|
|
563
|
+
// Filter mirrors sort: the `CngxFilter` predicate atom hosted here, its controlled
|
|
564
|
+
// predicate re-exposed as `[filterPredicate]` and its change re-emitted as
|
|
565
|
+
// `(filterChange)`. Consumers reach its combined predicate (and the multi-predicate
|
|
566
|
+
// `addPredicate` API for facet filtering) through the context. The simple text path
|
|
567
|
+
// is the separate `[(filterTerm)]` model below, which the `cngxDgaFilter` slot writes.
|
|
568
|
+
{
|
|
569
|
+
directive: CngxFilter,
|
|
570
|
+
inputs: ['cngxFilter: filterPredicate'],
|
|
571
|
+
outputs: ['filterChange'],
|
|
572
|
+
},
|
|
573
|
+
], providers: [{ provide: CNGX_DATA_GRID_ACCORDION, useExisting: CngxDataGridAccordion }], template: '<div class="cngx-data-grid-accordion__grid"><ng-content /></div>', host: {
|
|
574
|
+
class: 'cngx-data-grid-accordion',
|
|
575
|
+
'[attr.data-skin]': 'resolvedSkin() ?? null',
|
|
576
|
+
'[style.--cngx-dga-columns]': 'resolvedColumns()',
|
|
577
|
+
}, styles: [".cngx-data-grid-accordion{display:block;inline-size:100%;overflow-x:auto}.cngx-data-grid-accordion__grid{display:grid;grid-template-columns:var(--cngx-dga-lead, 2rem) var(--cngx-dga-columns, 1fr);column-gap:var(--cngx-dga-col-gap, .5rem);min-inline-size:var(--cngx-dga-min-width, 0)}.cngx-dga-header,.cngx-dga-footer{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;align-items:center;padding-block:var(--cngx-dga-row-py, .5rem);font-size:var(--cngx-dga-fs, inherit)}.cngx-dga-header>.cngx-dga-cell:first-child,.cngx-dga-footer>.cngx-dga-cell:first-child{grid-column-start:2}.cngx-dga-header{font-weight:var(--cngx-dga-head-weight, 600);color:var(--cngx-dga-head-color, var(--cngx-color-text-muted, #6b7280));border-block-end:var( --cngx-dga-head-border, 1px solid var(--cngx-dga-border-color, #d1d5db) )}.cngx-dga-footer{border-block-start:var( --cngx-dga-foot-border, 1px solid var(--cngx-dga-border-color, #d1d5db) )}.cngx-data-grid-accordion:not([data-skin]){--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: var(--cngx-space-md, 16px);--cngx-dga-region-padding: var(--cngx-space-sm, 8px) var(--cngx-space-md, 16px);--cngx-dga-col-gap: var(--cngx-space-sm, 8px);--cngx-dga-border-color: var(--cngx-color-border, #d1d5db)}.cngx-data-grid-accordion:not([data-skin]) .cngx-data-grid-accordion__grid{border-block:1px solid var(--cngx-dga-border-color, #d1d5db)}.cngx-data-grid-accordion:not([data-skin]) .cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}.cngx-data-grid-accordion:not([data-skin]) .cngx-dga-row__summary:hover{background:color-mix(in oklab,var(--cngx-color-text, #0f1320) 4%,transparent)}.cngx-dga-sort-header{cursor:pointer;-webkit-user-select:none;user-select:none}.cngx-dga-sort-header:focus-visible{outline:var( --cngx-dga-focus-ring, 2px solid var(--cngx-dga-focus-color, var(--cngx-color-primary, #1d4ed8)) );outline-offset:var(--cngx-dga-focus-offset, 2px)}.cngx-dga-sort-header--active:after{margin-inline-start:var(--cngx-dga-sort-indicator-gap, .35em);font-size:var(--cngx-dga-sort-indicator-size, .7em);color:var(--cngx-dga-sort-indicator-color, var(--cngx-color-primary, #1d4ed8))}.cngx-dga-sort-header--asc:after{content:\"\\25b2\"}.cngx-dga-sort-header--desc:after{content:\"\\25bc\"}.cngx-dga-sort-header__sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}\n", "@scope(.cngx-data-grid-accordion[data-skin=ledger]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);--cngx-dga-min-width: 38rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 1rem;--cngx-dga-fs: .875rem;--cngx-dga-region-padding: 1rem 1.25rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row:nth-of-type(2n) .cngx-dga-row__summary{background:var(--cngx-dga-surface-alt)}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}.cngx-dga-row__summary:hover{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row__region{background:var(--cngx-dga-surface-alt);border-block-start:1px solid var(--cngx-color-border, #d1d5db);box-shadow:inset 3px 0 0 var(--cngx-color-primary, #1d4ed8)}.cngx-dga-footer{background:var(--cngx-dga-surface-strong);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}}@scope(.cngx-data-grid-accordion[data-skin=spreadsheet]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 35rem;counter-reset:cngx-dga-row;--cngx-dga-col-gap: 0;--cngx-dga-row-py: 0;--cngx-dga-row-px: 0px;--cngx-dga-lead: 1.5rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) );--cngx-dga-region-padding: 1.4rem 1rem 1rem 3rem}.cngx-dga-header,.cngx-dga-row__summary,.cngx-dga-footer{align-items:stretch}.cngx-dga-cell{display:flex;align-items:center;justify-self:stretch;padding:.45rem .7rem;border-inline-end:1px solid var(--cngx-dga-border-color, #d1d5db)}:scope .cngx-dga-cell:last-child{padding-inline-end:.7rem}:scope .cngx-dga-cell[data-align=center]{justify-self:stretch;justify-content:center}:scope .cngx-dga-cell[data-align=end]{justify-self:stretch;justify-content:flex-end}.cngx-dga-header,.cngx-dga-row,.cngx-dga-footer{counter-increment:cngx-dga-row}.cngx-dga-header:before,.cngx-dga-row__summary:before,.cngx-dga-footer:before{content:counter(cngx-dga-row);display:flex;align-items:center;justify-content:flex-end;padding:.45rem .5rem;background:var(--cngx-dga-surface-strong);border-inline-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-header:before{padding-block-start:calc(.45rem + var(--cngx-dga-letter-band, 1.15rem))}:scope .cngx-data-grid-accordion__grid{grid-template-columns:var(--cngx-dga-columns, 1fr);padding-inline-start:var(--cngx-dga-lead, 1.5rem);position:relative}.cngx-data-grid-accordion__grid:before{content:\"\";position:absolute;inset-block:0;inset-inline-start:0;inline-size:var(--cngx-dga-lead, 1.5rem);background:var(--cngx-dga-surface-strong)}.cngx-dga-row__summary{position:relative}.cngx-dga-row__chevron-slot{position:absolute;inset-inline-start:calc(-1 * var(--cngx-dga-lead, 1.5rem));inset-block:0;inline-size:var(--cngx-dga-lead, 1.5rem);justify-content:center;padding-inline-start:0}:scope .cngx-dga-header>.cngx-dga-cell:first-child,:scope .cngx-dga-footer>.cngx-dga-cell:first-child{grid-column-start:auto}.cngx-dga-header{background:var(--cngx-dga-surface-alt);color:var(--cngx-color-text, #0f1320);font-weight:400;counter-reset:cngx-dga-col}.cngx-dga-header .cngx-dga-cell{position:relative;padding-block-start:calc(.45rem + var(--cngx-dga-letter-band, 1.15rem));font-weight:650}.cngx-dga-header .cngx-dga-cell:before{content:\"\";position:absolute;inset-block-start:0;inset-inline:0;block-size:var(--cngx-dga-letter-band, 1.15rem);display:flex;align-items:center;justify-content:flex-start;padding-inline:.7rem;background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}:scope .cngx-dga-header .cngx-dga-cell[data-align=center]:before{justify-content:center}:scope .cngx-dga-header .cngx-dga-cell[data-align=end]:before{justify-content:flex-end}.cngx-dga-header .cngx-dga-cell{counter-increment:cngx-dga-col}.cngx-dga-header .cngx-dga-cell:before{content:counter(cngx-dga-col,upper-alpha)}.cngx-dga-row__summary:hover .cngx-dga-cell,.cngx-dga-row[data-expanded] .cngx-dga-row__summary .cngx-dga-cell{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row[data-expanded] .cngx-dga-row__summary:before{background:var(--cngx-color-primary, #1d4ed8);color:var(--cngx-color-on-primary, #fff)}.cngx-dga-row__region{position:relative;background:color-mix(in oklab,var(--cngx-color-warning, #f59e0b) 9%,var(--cngx-color-surface, #fff));border-block-end:1px solid var(--cngx-dga-border-color, #d1d5db)}.cngx-dga-row__region:before{content:\"NOTE\";position:absolute;inset-block-start:.4rem;inset-inline-start:3rem;font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:.625rem;letter-spacing:.1em;color:color-mix(in oklab,var(--cngx-color-warning, #f59e0b) 80%,var(--cngx-color-text, #0f1320))}.cngx-dga-footer{background:var(--cngx-dga-surface-alt);color:var(--cngx-color-text, #0f1320)}.cngx-dga-footer .cngx-dga-cell{font-weight:650}}@scope(.cngx-data-grid-accordion[data-skin=log-stream]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-fs, .75rem);--cngx-dga-min-width: 33rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 1rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary{position:relative}.cngx-dga-row__summary:before{content:\"\";position:absolute;inset-block:0;inset-inline-start:0;inline-size:3px;background:transparent}.cngx-dga-row[data-severity=error] .cngx-dga-row__summary:before{background:var(--cngx-color-danger, #dc2626)}.cngx-dga-row[data-severity=warning] .cngx-dga-row__summary:before{background:var(--cngx-color-warning, #f59e0b)}.cngx-dga-row[data-severity=info] .cngx-dga-row__summary:before{background:var(--cngx-color-info, #2563eb)}.cngx-dga-row__summary .cngx-dga-cell:first-child{color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary:hover,.cngx-dga-row[data-expanded] .cngx-dga-row__summary{background:var(--cngx-dga-surface-alt)}.cngx-dga-row__region{background:var(--cngx-dga-surface-strong);border-block-start:1px solid var(--cngx-color-border, #d1d5db)}.cngx-dga-row__region pre{margin:0;overflow-x:auto;color:var(--cngx-color-text-muted, #6b7280);line-height:1.55;font-size:var(--cngx-dga-fs, .75rem)}.cngx-dga-footer{display:flex;justify-content:space-between;align-items:center;gap:1rem;padding-inline:var(--cngx-dga-row-px, 1rem);background:var(--cngx-dga-surface-strong);border-block-start:1px solid var(--cngx-color-border, #d1d5db);color:var(--cngx-color-text-muted, #6b7280)}}@scope(.cngx-data-grid-accordion[data-skin=master-detail]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 35rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 1rem;--cngx-dga-region-padding: .75rem 1rem 1rem 1.25rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);font-weight:400;text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary .cngx-dga-cell:first-child{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary .cngx-dga-cell[data-primary]{font-weight:620;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary .cngx-dga-cell[data-align=end]{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace)}.cngx-dga-row__summary:hover,.cngx-dga-row[data-expanded] .cngx-dga-row__summary{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row__region{background:var(--cngx-dga-surface-alt);border-block-start:1px solid var(--cngx-color-border, #d1d5db);box-shadow:inset 3px 0 0 var(--cngx-color-primary, #1d4ed8)}.cngx-dga-row__region table{inline-size:100%;border-collapse:collapse;font-size:var(--cngx-dga-fs, .875rem)}.cngx-dga-row__region th,.cngx-dga-row__region td{padding:.45rem .5rem;border-block-end:1px solid var(--cngx-dga-border-color, #d1d5db);text-align:start;white-space:nowrap}.cngx-dga-row__region th{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);font-weight:500;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__region td{color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__region th.r,.cngx-dga-row__region td.r{text-align:end;font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace)}.cngx-dga-row__region tfoot td{border-block-end:none;font-weight:700;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__region tfoot td:first-child{font-weight:600;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-footer{background:var(--cngx-dga-surface-strong);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-footer .cngx-dga-cell[data-align=end]{font-weight:700;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}}@scope(.cngx-data-grid-accordion[data-skin=report]){:scope{background:transparent;font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 40rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: var(--cngx-space-sm, 8px);--cngx-dga-row-px: 0;--cngx-dga-fs: .875rem;--cngx-dga-head-fs: .75rem;--cngx-dga-region-padding: .1rem 0 .85rem calc(var(--cngx-dga-lead, 2rem) + var(--cngx-dga-col-sm, 5rem) + var(--cngx-dga-col-gap, .75rem));--cngx-dga-border-color: var(--cngx-color-border, #d1d5db)}.cngx-dga-header{border-block-end:3px double color-mix(in oklab,var(--cngx-color-text, #0f1320) 45%,transparent);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);font-weight:400;text-transform:uppercase;letter-spacing:.1em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary:hover{background:color-mix(in oklab,var(--cngx-color-text, #0f1320) 5%,transparent)}.cngx-dga-row__summary .cngx-dga-cell:first-child{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary .cngx-dga-cell[data-primary]{font-weight:620;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary .cngx-dga-cell[data-align=end]{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary .cngx-dga-cell[data-over]{color:var(--cngx-color-danger, #dc2626);font-weight:700}.cngx-dga-row__region{font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280);max-inline-size:60ch}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}.cngx-dga-footer{border-block-start:3px double color-mix(in oklab,var(--cngx-color-text, #0f1320) 45%,transparent);color:var(--cngx-color-text, #0f1320)}.cngx-dga-footer .cngx-dga-cell[data-primary]{font-weight:700}.cngx-dga-footer .cngx-dga-cell[data-align=end]{font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-weight:700;color:var(--cngx-color-text, #0f1320)}}@scope(.cngx-data-grid-accordion[data-skin=density]){:scope{border:1px solid var(--cngx-color-border, #d1d5db);border-radius:var(--cngx-dga-radius, .5rem);background:var(--cngx-color-surface, #fff);font-size:var(--cngx-dga-fs, .875rem);--cngx-dga-min-width: 32rem;--cngx-dga-col-gap: .75rem;--cngx-dga-row-py: .6rem;--cngx-dga-row-px: 1rem;--cngx-dga-border-color: var(--cngx-color-border, #d1d5db);--cngx-dga-surface-alt: var( --cngx-dga-surface-alt-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 96%, var(--cngx-color-text, #0f1320)) );--cngx-dga-surface-strong: var( --cngx-dga-surface-strong-mat, color-mix(in oklab, var(--cngx-color-surface, #fff) 90%, var(--cngx-color-text, #0f1320)) )}.cngx-dga-header,.cngx-dga-row__summary{transition:padding var(--cngx-dga-transition, .3s cubic-bezier(.22, 1, .36, 1))}.cngx-dga-header{background:var(--cngx-dga-surface-strong);border-block-end:1px solid var(--cngx-color-border, #d1d5db);font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);text-transform:uppercase;letter-spacing:.06em;color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__summary:hover,.cngx-dga-row[data-expanded] .cngx-dga-row__summary{background:color-mix(in oklab,var(--cngx-color-primary, #1d4ed8) 8%,transparent)}.cngx-dga-row__summary .cngx-dga-cell[data-primary]{font-weight:620;color:var(--cngx-color-text, #0f1320)}.cngx-dga-row__summary>.cngx-dga-cell:nth-child(3){font-family:var(--cngx-font-mono, ui-monospace, \"SF Mono\", Menlo, monospace);font-size:var(--cngx-dga-head-fs, .75rem);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row__region{background:var(--cngx-dga-surface-alt);border-block-start:1px solid var(--cngx-color-border, #d1d5db);box-shadow:inset 3px 0 0 var(--cngx-color-primary, #1d4ed8)}.cngx-dga-footer{display:flex;justify-content:space-between;align-items:center;gap:1rem;padding-inline:var(--cngx-dga-row-px, 1rem);background:var(--cngx-dga-surface-strong);color:var(--cngx-color-text-muted, #6b7280)}.cngx-dga-row:last-of-type{--cngx-dga-row-divider: none}}\n"] }]
|
|
578
|
+
}], propDecorators: { filterTerm: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterTerm", required: false }] }, { type: i0.Output, args: ["filterTermChange"] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }], skin: [{ type: i0.Input, args: [{ isSignal: true, alias: "skin", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxDataGridHeader), { isSignal: true }] }], firstRow: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxDataGridRow), { isSignal: true }] }] } });
|
|
579
|
+
/**
|
|
580
|
+
* Map a cell's `col` track intent to one CSS `grid-template-columns` track. Unset
|
|
581
|
+
* (`undefined`) falls back to the derived default: the primary column grows
|
|
582
|
+
* (`minmax(0, 1fr)`), every other column fits its content (`auto`). The named sizes
|
|
583
|
+
* resolve against the registered `--cngx-dga-col-sm|-md|-lg` tokens, each with a rem
|
|
584
|
+
* fallback so the track stays valid even before the token surface loads (an invalid
|
|
585
|
+
* `var()` would collapse the whole `grid-template-columns` to one column).
|
|
586
|
+
*/
|
|
587
|
+
function trackFor(track, isPrimary) {
|
|
588
|
+
switch (track) {
|
|
589
|
+
case 'grow':
|
|
590
|
+
return 'minmax(0, 1fr)';
|
|
591
|
+
case 'fit':
|
|
592
|
+
return 'auto';
|
|
593
|
+
case 'sm':
|
|
594
|
+
return 'var(--cngx-dga-col-sm, 5rem)';
|
|
595
|
+
case 'md':
|
|
596
|
+
return 'var(--cngx-dga-col-md, 7rem)';
|
|
597
|
+
case 'lg':
|
|
598
|
+
return 'var(--cngx-dga-col-lg, 10rem)';
|
|
599
|
+
default:
|
|
600
|
+
return isPrimary ? 'minmax(0, 1fr)' : 'auto';
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Coerce a bound value to a number (via `coerceNumberProperty`, falling back to
|
|
605
|
+
* `fallback`) and clamp it into the ARIA heading-level range 2-6.
|
|
606
|
+
*/
|
|
607
|
+
function clampHeadingLevel(value, fallback = 3) {
|
|
608
|
+
return Math.min(6, Math.max(2, coerceNumberProperty(value, fallback)));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// EN default status text. Each string describes the primary (non-additive) click
|
|
612
|
+
// outcome so a screen reader hears both the current sort and what activating does.
|
|
613
|
+
// English by default, per the library-defaults-are-English rule.
|
|
614
|
+
const NOT_SORTED = 'not sorted, activate to sort ascending';
|
|
615
|
+
const SORTED_ASCENDING = 'sorted ascending, activate to sort descending';
|
|
616
|
+
const SORTED_DESCENDING = 'sorted descending, activate to sort ascending';
|
|
617
|
+
/**
|
|
618
|
+
* Makes a {@link CngxDataGridHeader} cell sort the grid it lives in with a single
|
|
619
|
+
* attribute - `cngxDgaSortHeader="field"` - and no `[cngxSortRef]` plumbing. It reads
|
|
620
|
+
* the group's hosted {@link CngxSort} off {@link CNGX_DATA_GRID_ACCORDION} (the seam),
|
|
621
|
+
* so the header cell needs no reference to the sort instance; the group provides it.
|
|
622
|
+
*
|
|
623
|
+
* The cell becomes an operable control: `role="button"`, `tabindex="0"`, and
|
|
624
|
+
* click / Enter / Space all toggle the column's sort through `CngxSort.setSort`. When
|
|
625
|
+
* the owning group has `[multiSort]`, Shift-activating adds this column to the sort
|
|
626
|
+
* stack instead of replacing it (mirrors {@link CngxSortHeader}). The field/direction
|
|
627
|
+
* logic is not re-implemented: both headers compose the shared `createSortHeaderState`
|
|
628
|
+
* factory from `@cngx/common/data`, so the derivation lives in one place. `CngxSortHeader`
|
|
629
|
+
* cannot be reused as a sibling here (its `cngxSortRef` is `input.required` and only
|
|
630
|
+
* template-bindable), so this header composes the same factory and feeds it the sort it
|
|
631
|
+
* reads off the context token.
|
|
632
|
+
*
|
|
633
|
+
* The component is a disclosure accordion, not a table, so it carries no
|
|
634
|
+
* `role="grid"` / `role="table"` and thus no valid context for `aria-sort` /
|
|
635
|
+
* `role="columnheader"`. The sort state is instead communicated to assistive tech
|
|
636
|
+
* through a visually-hidden description (always in the DOM, content reactive - Pillar 2)
|
|
637
|
+
* referenced by `aria-describedby`: the accessible name stays the stable column label,
|
|
638
|
+
* the description carries the live sort state. A tinted direction arrow is a CSS
|
|
639
|
+
* `::after` cue (pseudo content, so it never doubles the announcement or shifts a
|
|
640
|
+
* `ch`-based track). On activation the new sort state is also spoken once through the
|
|
641
|
+
* shared {@link CngxLiveAnnouncer} polite region - a change announcement worded
|
|
642
|
+
* distinctly from the on-focus description, for SR/browser pairs that do not re-read a
|
|
643
|
+
* mutated `aria-describedby` on an already-focused control.
|
|
644
|
+
*
|
|
645
|
+
* ```html
|
|
646
|
+
* <cngx-data-grid-accordion [multiSort]="true">
|
|
647
|
+
* <cngx-dga-header>
|
|
648
|
+
* <span cngxDgaCell col="sm" cngxDgaSortHeader="id">ID</span>
|
|
649
|
+
* <span cngxDgaCell col="grow" cngxDgaSortHeader="name">Name</span>
|
|
650
|
+
* <span cngxDgaCell col="md" align="end" cngxDgaSortHeader="amount">Amount</span>
|
|
651
|
+
* </cngx-dga-header>
|
|
652
|
+
* <!-- rows rendered by the consumer's @for over its own sorted array -->
|
|
653
|
+
* </cngx-data-grid-accordion>
|
|
654
|
+
* ```
|
|
655
|
+
*
|
|
656
|
+
* @category ui/data-grid-accordion
|
|
657
|
+
* @wcag AA
|
|
658
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-sort-header.directive.ts
|
|
659
|
+
* @since 0.1.0
|
|
660
|
+
* @relatedTo CngxDataGridAccordion, CngxSort, CngxSortHeader, CngxDgCell
|
|
661
|
+
*
|
|
662
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/sortable-ledger</example-url>
|
|
663
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/bound-sort-filter</example-url>
|
|
664
|
+
*/
|
|
665
|
+
class CngxDgaSortHeader {
|
|
666
|
+
/** The field key this header cell sorts by. */
|
|
667
|
+
field = input.required({ ...(ngDevMode ? { debugName: "field" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortHeader' });
|
|
668
|
+
/** SR status while unsorted. English default; override for other locales. */
|
|
669
|
+
notSortedLabel = input(NOT_SORTED, { ...(ngDevMode ? { debugName: "notSortedLabel" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortStatusNotSorted' });
|
|
670
|
+
/** SR status while sorted ascending. English default; override for other locales. */
|
|
671
|
+
ascendingLabel = input(SORTED_ASCENDING, { ...(ngDevMode ? { debugName: "ascendingLabel" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortStatusAscending' });
|
|
672
|
+
/** SR status while sorted descending. English default; override for other locales. */
|
|
673
|
+
descendingLabel = input(SORTED_DESCENDING, { ...(ngDevMode ? { debugName: "descendingLabel" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortStatusDescending' });
|
|
674
|
+
/**
|
|
675
|
+
* Human column name spoken in the live sort announcement (`{label}` placeholder
|
|
676
|
+
* of the announcement templates). Defaults to the field key.
|
|
677
|
+
*/
|
|
678
|
+
label = input(undefined, { ...(ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortLabel' });
|
|
679
|
+
/** Live announcement fired when this column becomes sorted ascending. `{label}` is replaced. */
|
|
680
|
+
ascendingAnnouncement = input('Sorted by {label} ascending', { ...(ngDevMode ? { debugName: "ascendingAnnouncement" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortAnnounceAscending' });
|
|
681
|
+
/** Live announcement fired when this column becomes sorted descending. `{label}` is replaced. */
|
|
682
|
+
descendingAnnouncement = input('Sorted by {label} descending', { ...(ngDevMode ? { debugName: "descendingAnnouncement" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortAnnounceDescending' });
|
|
683
|
+
/** Live announcement fired when this column's sort is cleared. `{label}` is replaced. */
|
|
684
|
+
clearedAnnouncement = input('Sorting by {label} cleared', { ...(ngDevMode ? { debugName: "clearedAnnouncement" } : /* istanbul ignore next */ {}), alias: 'cngxDgaSortAnnounceCleared' });
|
|
685
|
+
grid = inject(CNGX_DATA_GRID_ACCORDION);
|
|
686
|
+
announcer = inject(CngxLiveAnnouncer);
|
|
687
|
+
host = inject(ElementRef).nativeElement;
|
|
688
|
+
renderer = inject(Renderer2);
|
|
689
|
+
/** Stable id of the visually-hidden status element the host `aria-describedby` names. */
|
|
690
|
+
statusId = nextUid('cngx-dga-sort-status-');
|
|
691
|
+
state = createSortHeaderState(() => this.grid.sort, this.field);
|
|
692
|
+
/** `true` when this column is part of the active sort (primary or secondary). */
|
|
693
|
+
isActive = this.state.isActive;
|
|
694
|
+
/** `true` when this column is active and sorted ascending. */
|
|
695
|
+
isAsc = this.state.isAsc;
|
|
696
|
+
/** `true` when this column is active and sorted descending. */
|
|
697
|
+
isDesc = this.state.isDesc;
|
|
698
|
+
/**
|
|
699
|
+
* 1-based position of this column in the sort stack, or `0` when it is not active.
|
|
700
|
+
* Only meaningful when the owning group has `[multiSort]` (for sort-order badges).
|
|
701
|
+
*/
|
|
702
|
+
priority = this.state.priority;
|
|
703
|
+
statusText = computed(() => {
|
|
704
|
+
if (this.isAsc()) {
|
|
705
|
+
return this.ascendingLabel();
|
|
706
|
+
}
|
|
707
|
+
if (this.isDesc()) {
|
|
708
|
+
return this.descendingLabel();
|
|
709
|
+
}
|
|
710
|
+
return this.notSortedLabel();
|
|
711
|
+
}, ...(ngDevMode ? [{ debugName: "statusText" }] : /* istanbul ignore next */ []));
|
|
712
|
+
// A visually-hidden, aria-hidden description node the host `aria-describedby` names.
|
|
713
|
+
// aria-hidden keeps it out of the name-from-contents walk (so the accessible name
|
|
714
|
+
// stays the plain column label), while aria-describedby still reads it for the
|
|
715
|
+
// description - the standard "stable name + live description" split.
|
|
716
|
+
statusElement = this.createStatusElement();
|
|
717
|
+
constructor() {
|
|
718
|
+
// Imperative DOM sync: keep the description text tracking the sort state. No signal
|
|
719
|
+
// writes, so this is a pure side effect (permitted in an effect).
|
|
720
|
+
effect(() => {
|
|
721
|
+
this.renderer.setProperty(this.statusElement, 'textContent', this.statusText());
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
createStatusElement() {
|
|
725
|
+
const element = this.renderer.createElement('span');
|
|
726
|
+
this.renderer.setAttribute(element, 'id', this.statusId);
|
|
727
|
+
this.renderer.setAttribute(element, 'aria-hidden', 'true');
|
|
728
|
+
this.renderer.addClass(element, 'cngx-dga-sort-header__sr');
|
|
729
|
+
this.renderer.appendChild(this.host, element);
|
|
730
|
+
return element;
|
|
731
|
+
}
|
|
732
|
+
handleSort(event) {
|
|
733
|
+
this.state.toggle(event?.shiftKey ?? false);
|
|
734
|
+
// Announce the transition through the shared polite live region. Fired from the
|
|
735
|
+
// handler (not an effect) so it speaks exactly once per user activation and stays
|
|
736
|
+
// silent on init and on external sort changes. The always-present aria-describedby
|
|
737
|
+
// node keeps the on-focus description; this is the change announcement some SR /
|
|
738
|
+
// browser pairs miss when only a describedby text mutates on a focused control.
|
|
739
|
+
this.announcer.announce(this.announcementText());
|
|
740
|
+
}
|
|
741
|
+
announcementText() {
|
|
742
|
+
const label = this.label() ?? this.field();
|
|
743
|
+
const template = this.isAsc()
|
|
744
|
+
? this.ascendingAnnouncement()
|
|
745
|
+
: this.isDesc()
|
|
746
|
+
? this.descendingAnnouncement()
|
|
747
|
+
: this.clearedAnnouncement();
|
|
748
|
+
return template.replace('{label}', label);
|
|
749
|
+
}
|
|
750
|
+
handleActivateKey(event) {
|
|
751
|
+
// Space would scroll the grid's overflow container; suppress it and activate.
|
|
752
|
+
event.preventDefault();
|
|
753
|
+
this.handleSort(event);
|
|
754
|
+
}
|
|
755
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaSortHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
756
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxDgaSortHeader, isStandalone: true, selector: "[cngxDgaSortHeader]", inputs: { field: { classPropertyName: "field", publicName: "cngxDgaSortHeader", isSignal: true, isRequired: true, transformFunction: null }, notSortedLabel: { classPropertyName: "notSortedLabel", publicName: "cngxDgaSortStatusNotSorted", isSignal: true, isRequired: false, transformFunction: null }, ascendingLabel: { classPropertyName: "ascendingLabel", publicName: "cngxDgaSortStatusAscending", isSignal: true, isRequired: false, transformFunction: null }, descendingLabel: { classPropertyName: "descendingLabel", publicName: "cngxDgaSortStatusDescending", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "cngxDgaSortLabel", isSignal: true, isRequired: false, transformFunction: null }, ascendingAnnouncement: { classPropertyName: "ascendingAnnouncement", publicName: "cngxDgaSortAnnounceAscending", isSignal: true, isRequired: false, transformFunction: null }, descendingAnnouncement: { classPropertyName: "descendingAnnouncement", publicName: "cngxDgaSortAnnounceDescending", isSignal: true, isRequired: false, transformFunction: null }, clearedAnnouncement: { classPropertyName: "clearedAnnouncement", publicName: "cngxDgaSortAnnounceCleared", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "button", "tabindex": "0" }, listeners: { "click": "handleSort($event)", "keydown.enter": "handleSort($event)", "keydown.space": "handleActivateKey($event)" }, properties: { "attr.aria-describedby": "statusId", "class.cngx-dga-sort-header--active": "isActive()", "class.cngx-dga-sort-header--asc": "isAsc()", "class.cngx-dga-sort-header--desc": "isDesc()" }, classAttribute: "cngx-dga-sort-header" }, exportAs: ["cngxDgaSortHeader"], ngImport: i0 });
|
|
757
|
+
}
|
|
758
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaSortHeader, decorators: [{
|
|
759
|
+
type: Directive,
|
|
760
|
+
args: [{
|
|
761
|
+
selector: '[cngxDgaSortHeader]',
|
|
762
|
+
exportAs: 'cngxDgaSortHeader',
|
|
763
|
+
standalone: true,
|
|
764
|
+
host: {
|
|
765
|
+
role: 'button',
|
|
766
|
+
tabindex: '0',
|
|
767
|
+
class: 'cngx-dga-sort-header',
|
|
768
|
+
'[attr.aria-describedby]': 'statusId',
|
|
769
|
+
'[class.cngx-dga-sort-header--active]': 'isActive()',
|
|
770
|
+
'[class.cngx-dga-sort-header--asc]': 'isAsc()',
|
|
771
|
+
'[class.cngx-dga-sort-header--desc]': 'isDesc()',
|
|
772
|
+
'(click)': 'handleSort($event)',
|
|
773
|
+
'(keydown.enter)': 'handleSort($event)',
|
|
774
|
+
'(keydown.space)': 'handleActivateKey($event)',
|
|
775
|
+
},
|
|
776
|
+
}]
|
|
777
|
+
}], ctorParameters: () => [], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortHeader", required: true }] }], notSortedLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortStatusNotSorted", required: false }] }], ascendingLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortStatusAscending", required: false }] }], descendingLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortStatusDescending", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortLabel", required: false }] }], ascendingAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortAnnounceAscending", required: false }] }], descendingAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortAnnounceDescending", required: false }] }], clearedAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaSortAnnounceCleared", required: false }] }] } });
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Turns a projected `<input>` into the filter box for the {@link CngxDataGridAccordion}
|
|
781
|
+
* it lives in: it two-way-binds the group's `filterTerm` with no wiring. On each
|
|
782
|
+
* keystroke it writes the value into `grid.filterTerm` after a debounce (owned here -
|
|
783
|
+
* {@link CngxFilter} has none), so the consumer's `computed()` re-derives the visible
|
|
784
|
+
* rows only once typing settles. An external term change (a programmatic clear) reflects
|
|
785
|
+
* back into the box, but never while it is focused - that would fight the caret.
|
|
786
|
+
*
|
|
787
|
+
* The debounce lives in this slot, not in the group, because it is an input-UX concern;
|
|
788
|
+
* a consumer driving the term programmatically writes `grid.filterTerm` directly with no
|
|
789
|
+
* debounce. The default `aria-label` is English (a consumer overrides via
|
|
790
|
+
* `cngxDgaFilterLabel`).
|
|
791
|
+
*
|
|
792
|
+
* ```html
|
|
793
|
+
* <cngx-data-grid-accordion>
|
|
794
|
+
* <cngx-dga-header>
|
|
795
|
+
* <input cngxDgaFilter cngxDgaFilterLabel="Filter invoices" />
|
|
796
|
+
* </cngx-dga-header>
|
|
797
|
+
* <!-- rows rendered by the consumer's @for over its filtered array -->
|
|
798
|
+
* </cngx-data-grid-accordion>
|
|
799
|
+
* ```
|
|
800
|
+
*
|
|
801
|
+
* @category ui/data-grid-accordion
|
|
802
|
+
* @wcag AA
|
|
803
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-filter.directive.ts
|
|
804
|
+
* @since 0.1.0
|
|
805
|
+
* @relatedTo CngxDataGridAccordion, CngxFilter, CngxDgaCount
|
|
806
|
+
*
|
|
807
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/bound-sort-filter</example-url>
|
|
808
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/sortable-ledger</example-url>
|
|
809
|
+
*/
|
|
810
|
+
class CngxDgaFilter {
|
|
811
|
+
/** Accessible name for the filter box. English default; override for other locales. */
|
|
812
|
+
ariaLabel = input('Filter rows', { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'cngxDgaFilterLabel' });
|
|
813
|
+
/** Debounce in ms between the last keystroke and writing `grid.filterTerm`. */
|
|
814
|
+
debounce = input(200, { ...(ngDevMode ? { debugName: "debounce" } : /* istanbul ignore next */ {}), alias: 'cngxDgaFilterDebounce' });
|
|
815
|
+
grid = inject(CNGX_DATA_GRID_ACCORDION);
|
|
816
|
+
element = inject(ElementRef).nativeElement;
|
|
817
|
+
timer;
|
|
818
|
+
constructor() {
|
|
819
|
+
inject(DestroyRef).onDestroy(() => clearTimeout(this.timer));
|
|
820
|
+
// Reflect an external term change (e.g. a programmatic clear) back into the box, but
|
|
821
|
+
// never while the user is typing into it - overwriting `value` there resets the caret.
|
|
822
|
+
effect(() => {
|
|
823
|
+
const term = this.grid.filterTerm();
|
|
824
|
+
if (document.activeElement !== this.element && this.element.value !== term) {
|
|
825
|
+
this.element.value = term;
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
handleInput(event) {
|
|
830
|
+
const value = event.target.value;
|
|
831
|
+
clearTimeout(this.timer);
|
|
832
|
+
this.timer = setTimeout(() => this.grid.filterTerm.set(value), this.debounce());
|
|
833
|
+
}
|
|
834
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaFilter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
835
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxDgaFilter, isStandalone: true, selector: "input[cngxDgaFilter]", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "cngxDgaFilterLabel", isSignal: true, isRequired: false, transformFunction: null }, debounce: { classPropertyName: "debounce", publicName: "cngxDgaFilterDebounce", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "searchbox" }, listeners: { "input": "handleInput($event)" }, properties: { "attr.aria-label": "ariaLabel()" }, classAttribute: "cngx-dga-filter" }, exportAs: ["cngxDgaFilter"], ngImport: i0 });
|
|
836
|
+
}
|
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaFilter, decorators: [{
|
|
838
|
+
type: Directive,
|
|
839
|
+
args: [{
|
|
840
|
+
selector: 'input[cngxDgaFilter]',
|
|
841
|
+
exportAs: 'cngxDgaFilter',
|
|
842
|
+
standalone: true,
|
|
843
|
+
host: {
|
|
844
|
+
role: 'searchbox',
|
|
845
|
+
class: 'cngx-dga-filter',
|
|
846
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
847
|
+
'(input)': 'handleInput($event)',
|
|
848
|
+
},
|
|
849
|
+
}]
|
|
850
|
+
}], ctorParameters: () => [], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaFilterLabel", required: false }] }], debounce: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaFilterDebounce", required: false }] }] } });
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* A ready-made filter row for a {@link CngxDataGridAccordion}: a full-width
|
|
854
|
+
* `grid-column: 1 / -1` band with a visible `<label>` and a search input, so a
|
|
855
|
+
* consumer drops `<cngx-dga-filter label="Filter invoices" />` instead of
|
|
856
|
+
* hand-styling a `<div>` around a bare `<input cngxDgaFilter>`.
|
|
857
|
+
*
|
|
858
|
+
* It is a thin structural shell over the {@link CngxDgaFilter} brain, not a new
|
|
859
|
+
* behaviour: the directive still owns the debounce, the two-way `filterTerm`
|
|
860
|
+
* write, and the focused-caret guard. The shell adds only the chrome (span +
|
|
861
|
+
* padding via `--cngx-dga-*` tokens) and a real `<label>` whose `for` binds the
|
|
862
|
+
* input id, so the searchbox has a **visible** accessible name (WCAG 3.3.2)
|
|
863
|
+
* rather than an invisible `aria-label` alone. The label text is mirrored onto
|
|
864
|
+
* the directive's `cngxDgaFilterLabel` so the accessible name is the label, not
|
|
865
|
+
* the directive's `'Filter rows'` default.
|
|
866
|
+
*
|
|
867
|
+
* ```html
|
|
868
|
+
* <cngx-data-grid-accordion>
|
|
869
|
+
* <cngx-dga-filter label="Filter invoices" placeholder="Customer or invoice number" />
|
|
870
|
+
* <cngx-dga-header>…</cngx-dga-header>
|
|
871
|
+
* <!-- rows -->
|
|
872
|
+
* </cngx-data-grid-accordion>
|
|
873
|
+
* ```
|
|
874
|
+
*
|
|
875
|
+
* @category ui/data-grid-accordion
|
|
876
|
+
* @wcag AA
|
|
877
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-filter-field.component.ts
|
|
878
|
+
* @since 0.1.0
|
|
879
|
+
* @relatedTo CngxDataGridAccordion, CngxDgaFilter, CngxDgaCount
|
|
880
|
+
*
|
|
881
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/sortable-ledger</example-url>
|
|
882
|
+
*/
|
|
883
|
+
class CngxDgaFilterField {
|
|
884
|
+
/** Visible label text; also drives the input's accessible name. English default. */
|
|
885
|
+
label = input('Filter', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
886
|
+
/** Optional placeholder shown inside the input. */
|
|
887
|
+
placeholder = input(undefined, ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
888
|
+
/** Debounce in ms forwarded to the hosted `cngxDgaFilter`. */
|
|
889
|
+
debounce = input(200, ...(ngDevMode ? [{ debugName: "debounce" }] : /* istanbul ignore next */ []));
|
|
890
|
+
/** Stable id linking the visible `<label for>` to the input. */
|
|
891
|
+
inputId = nextUid('cngx-dga-filter-');
|
|
892
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaFilterField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
893
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxDgaFilterField, isStandalone: true, selector: "cngx-dga-filter", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, debounce: { classPropertyName: "debounce", publicName: "debounce", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-dga-filter-field" }, exportAs: ["cngxDgaFilterField"], ngImport: i0, template: "<label class=\"cngx-dga-filter-field__label\" [attr.for]=\"inputId\">{{ label() }}</label>\n<input\n class=\"cngx-dga-filter-field__input\"\n [id]=\"inputId\"\n cngxDgaFilter\n [cngxDgaFilterLabel]=\"label()\"\n [cngxDgaFilterDebounce]=\"debounce()\"\n [attr.placeholder]=\"placeholder()\"\n/>\n", styles: [".cngx-dga-filter-field{grid-column:1 / -1;display:block;padding:var(--cngx-dga-filter-py, .6rem) var(--cngx-dga-filter-px, 1rem)}.cngx-dga-filter-field__label{display:block;margin-block-end:var(--cngx-dga-filter-label-gap, .25rem);font-size:var(--cngx-dga-filter-label-fs, .8125rem);color:var(--cngx-dga-filter-label-color, var(--cngx-color-text-muted, #6b7280))}.cngx-dga-filter-field__input{inline-size:100%;box-sizing:border-box;padding:var(--cngx-dga-filter-input-py, .4rem) var(--cngx-dga-filter-input-px, .6rem);font:inherit;color:var(--cngx-color-text, #0f1320);background:var(--cngx-color-surface, #fff);border:1px solid var(--cngx-dga-border-color, var(--cngx-color-border, #d1d5db));border-radius:var(--cngx-radius-sm, .25rem)}.cngx-dga-filter-field__input:focus-visible{outline:2px solid var(--cngx-dga-focus-color, var(--cngx-color-primary, #1d4ed8));outline-offset:1px}\n"], dependencies: [{ kind: "directive", type: CngxDgaFilter, selector: "input[cngxDgaFilter]", inputs: ["cngxDgaFilterLabel", "cngxDgaFilterDebounce"], exportAs: ["cngxDgaFilter"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
894
|
+
}
|
|
895
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaFilterField, decorators: [{
|
|
896
|
+
type: Component,
|
|
897
|
+
args: [{ selector: 'cngx-dga-filter', exportAs: 'cngxDgaFilterField', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxDgaFilter], host: {
|
|
898
|
+
class: 'cngx-dga-filter-field',
|
|
899
|
+
}, template: "<label class=\"cngx-dga-filter-field__label\" [attr.for]=\"inputId\">{{ label() }}</label>\n<input\n class=\"cngx-dga-filter-field__input\"\n [id]=\"inputId\"\n cngxDgaFilter\n [cngxDgaFilterLabel]=\"label()\"\n [cngxDgaFilterDebounce]=\"debounce()\"\n [attr.placeholder]=\"placeholder()\"\n/>\n", styles: [".cngx-dga-filter-field{grid-column:1 / -1;display:block;padding:var(--cngx-dga-filter-py, .6rem) var(--cngx-dga-filter-px, 1rem)}.cngx-dga-filter-field__label{display:block;margin-block-end:var(--cngx-dga-filter-label-gap, .25rem);font-size:var(--cngx-dga-filter-label-fs, .8125rem);color:var(--cngx-dga-filter-label-color, var(--cngx-color-text-muted, #6b7280))}.cngx-dga-filter-field__input{inline-size:100%;box-sizing:border-box;padding:var(--cngx-dga-filter-input-py, .4rem) var(--cngx-dga-filter-input-px, .6rem);font:inherit;color:var(--cngx-color-text, #0f1320);background:var(--cngx-color-surface, #fff);border:1px solid var(--cngx-dga-border-color, var(--cngx-color-border, #d1d5db));border-radius:var(--cngx-radius-sm, .25rem)}.cngx-dga-filter-field__input:focus-visible{outline:2px solid var(--cngx-dga-focus-color, var(--cngx-color-primary, #1d4ed8));outline-offset:1px}\n"] }]
|
|
900
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], debounce: [{ type: i0.Input, args: [{ isSignal: true, alias: "debounce", required: false }] }] } });
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* A polite `aria-live` region for the visible-row count of a
|
|
904
|
+
* {@link CngxDataGridAccordion}. The consumer feeds the count it already derived
|
|
905
|
+
* (`[cngxDgaCount]="visibleRows().length"`); the directive makes its host a
|
|
906
|
+
* `role="status"` / `aria-live="polite"` / `aria-atomic="true"` region and writes the
|
|
907
|
+
* count text into it, so a filter that changes the count is announced to assistive tech
|
|
908
|
+
* without the consumer wiring a live region by hand (Pillar 2 - the count change is
|
|
909
|
+
* communicated, always in the DOM, content reactive).
|
|
910
|
+
*
|
|
911
|
+
* The host owns its text, so give it an empty element:
|
|
912
|
+
*
|
|
913
|
+
* ```html
|
|
914
|
+
* <cngx-dga-footer>
|
|
915
|
+
* <span [cngxDgaCount]="visibleRows().length"></span>
|
|
916
|
+
* </cngx-dga-footer>
|
|
917
|
+
* ```
|
|
918
|
+
*
|
|
919
|
+
* The noun is English by default (`result` / `results`); a consumer localises via
|
|
920
|
+
* `cngxDgaCountSingular` / `cngxDgaCountPlural`.
|
|
921
|
+
*
|
|
922
|
+
* @category ui/data-grid-accordion
|
|
923
|
+
* @wcag AA
|
|
924
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-count.directive.ts
|
|
925
|
+
* @since 0.1.0
|
|
926
|
+
* @relatedTo CngxDataGridAccordion, CngxDgaFilter
|
|
927
|
+
*
|
|
928
|
+
* <example-url>http://localhost:4200/#/ui/data-grid-accordion/sortable-ledger</example-url>
|
|
929
|
+
*/
|
|
930
|
+
class CngxDgaCount {
|
|
931
|
+
/** The visible-row count the consumer derived. */
|
|
932
|
+
count = input.required({ ...(ngDevMode ? { debugName: "count" } : /* istanbul ignore next */ {}), alias: 'cngxDgaCount' });
|
|
933
|
+
/** Singular noun for a count of 1. English default. */
|
|
934
|
+
singular = input('result', { ...(ngDevMode ? { debugName: "singular" } : /* istanbul ignore next */ {}), alias: 'cngxDgaCountSingular' });
|
|
935
|
+
/** Plural noun for any other count. English default. */
|
|
936
|
+
plural = input('results', { ...(ngDevMode ? { debugName: "plural" } : /* istanbul ignore next */ {}), alias: 'cngxDgaCountPlural' });
|
|
937
|
+
element = inject(ElementRef).nativeElement;
|
|
938
|
+
renderer = inject(Renderer2);
|
|
939
|
+
constructor() {
|
|
940
|
+
// Imperative DOM sync of the announced text - a side effect, no signal write.
|
|
941
|
+
effect(() => {
|
|
942
|
+
const count = this.count();
|
|
943
|
+
const noun = count === 1 ? this.singular() : this.plural();
|
|
944
|
+
this.renderer.setProperty(this.element, 'textContent', `${count} ${noun}`);
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaCount, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
948
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxDgaCount, isStandalone: true, selector: "[cngxDgaCount]", inputs: { count: { classPropertyName: "count", publicName: "cngxDgaCount", isSignal: true, isRequired: true, transformFunction: null }, singular: { classPropertyName: "singular", publicName: "cngxDgaCountSingular", isSignal: true, isRequired: false, transformFunction: null }, plural: { classPropertyName: "plural", publicName: "cngxDgaCountPlural", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "status", "aria-live": "polite", "aria-atomic": "true" }, classAttribute: "cngx-dga-count" }, exportAs: ["cngxDgaCount"], ngImport: i0 });
|
|
949
|
+
}
|
|
950
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDgaCount, decorators: [{
|
|
951
|
+
type: Directive,
|
|
952
|
+
args: [{
|
|
953
|
+
selector: '[cngxDgaCount]',
|
|
954
|
+
exportAs: 'cngxDgaCount',
|
|
955
|
+
standalone: true,
|
|
956
|
+
host: {
|
|
957
|
+
role: 'status',
|
|
958
|
+
'aria-live': 'polite',
|
|
959
|
+
'aria-atomic': 'true',
|
|
960
|
+
class: 'cngx-dga-count',
|
|
961
|
+
},
|
|
962
|
+
}]
|
|
963
|
+
}], ctorParameters: () => [], propDecorators: { count: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaCount", required: true }] }], singular: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaCountSingular", required: false }] }], plural: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDgaCountPlural", required: false }] }] } });
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* The footer row of a {@link CngxDataGridAccordion}. Lays its projected
|
|
967
|
+
* `cngxDgaCell`s out on the shared `--cngx-dga-columns` grid, so a sum or count
|
|
968
|
+
* cell lines up with the column it totals. It is the designated host for a
|
|
969
|
+
* consumer-supplied `aria-live` region (row count, running totals, load status). The
|
|
970
|
+
* component ships no live producer - the region element and its content are the
|
|
971
|
+
* consumer's, so any state it announces stays owned outside this structural shell.
|
|
972
|
+
*
|
|
973
|
+
* @category ui/data-grid-accordion
|
|
974
|
+
* @wcag AA
|
|
975
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/data-grid-accordion/data-grid-footer.component.ts
|
|
976
|
+
* @since 0.1.0
|
|
977
|
+
* @relatedTo CngxDataGridAccordion, CngxDgCell
|
|
978
|
+
*/
|
|
979
|
+
class CngxDataGridFooter {
|
|
980
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridFooter, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
981
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.4", type: CngxDataGridFooter, isStandalone: true, selector: "cngx-dga-footer", host: { classAttribute: "cngx-dga-footer" }, exportAs: ["cngxDgaFooter"], ngImport: i0, template: '<ng-content />', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
982
|
+
}
|
|
983
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDataGridFooter, decorators: [{
|
|
984
|
+
type: Component,
|
|
985
|
+
args: [{
|
|
986
|
+
selector: 'cngx-dga-footer',
|
|
987
|
+
exportAs: 'cngxDgaFooter',
|
|
988
|
+
standalone: true,
|
|
989
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
990
|
+
encapsulation: ViewEncapsulation.None,
|
|
991
|
+
template: '<ng-content />',
|
|
992
|
+
host: {
|
|
993
|
+
class: 'cngx-dga-footer',
|
|
994
|
+
},
|
|
995
|
+
}]
|
|
996
|
+
}] });
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Reduces a list of feature objects into a partial config - last write wins per
|
|
1000
|
+
* key.
|
|
1001
|
+
*
|
|
1002
|
+
* @internal
|
|
1003
|
+
*/
|
|
1004
|
+
function reduceFeatures(features) {
|
|
1005
|
+
const out = {};
|
|
1006
|
+
for (const f of features) {
|
|
1007
|
+
switch (f.kind) {
|
|
1008
|
+
case 'skin':
|
|
1009
|
+
out.skin = f.payload.skin;
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return out;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Merges a partial config onto a base. Scalars take the partial when present.
|
|
1017
|
+
*
|
|
1018
|
+
* @internal
|
|
1019
|
+
*/
|
|
1020
|
+
function mergeConfig(base, partial) {
|
|
1021
|
+
return {
|
|
1022
|
+
skin: partial.skin ?? base.skin,
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Application-root configuration cascade for the data-grid-accordion. Pass a
|
|
1027
|
+
* `withDataGridSkin` feature in `bootstrapApplication`'s providers array to move
|
|
1028
|
+
* the app-wide default skin.
|
|
1029
|
+
*
|
|
1030
|
+
* Resolution priority (high -> low):
|
|
1031
|
+
* 1. Per-instance `[skin]` Input binding.
|
|
1032
|
+
* 2. `provideDataGridAccordionConfigAt(...)` in a parent component's
|
|
1033
|
+
* `viewProviders`.
|
|
1034
|
+
* 3. `provideDataGridAccordionConfig(...)` at the application root.
|
|
1035
|
+
* 4. Library defaults (`CNGX_DATA_GRID_ACCORDION_DEFAULTS`).
|
|
1036
|
+
*
|
|
1037
|
+
* ```ts
|
|
1038
|
+
* bootstrapApplication(AppComponent, {
|
|
1039
|
+
* providers: [provideDataGridAccordionConfig(withDataGridSkin('ledger'))],
|
|
1040
|
+
* });
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
* @category ui/data-grid-accordion
|
|
1044
|
+
* @since 0.1.0
|
|
1045
|
+
*/
|
|
1046
|
+
function provideDataGridAccordionConfig(...features) {
|
|
1047
|
+
// Empty-features: skip the override so the root factory's
|
|
1048
|
+
// CNGX_DATA_GRID_ACCORDION_DEFAULTS reference flows through untouched. A fresh
|
|
1049
|
+
// merge would allocate identical content under a new reference and bust
|
|
1050
|
+
// downstream identity comparisons.
|
|
1051
|
+
if (features.length === 0) {
|
|
1052
|
+
return makeEnvironmentProviders([]);
|
|
1053
|
+
}
|
|
1054
|
+
const partial = reduceFeatures(features);
|
|
1055
|
+
return makeEnvironmentProviders([
|
|
1056
|
+
{
|
|
1057
|
+
provide: CNGX_DATA_GRID_ACCORDION_CONFIG,
|
|
1058
|
+
useValue: mergeConfig(CNGX_DATA_GRID_ACCORDION_DEFAULTS, partial),
|
|
1059
|
+
},
|
|
1060
|
+
]);
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Component-scoped configuration cascade for the data-grid-accordion. Pass a
|
|
1064
|
+
* `withDataGridSkin` feature in a parent component's `viewProviders` array.
|
|
1065
|
+
*
|
|
1066
|
+
* Unlike `provideDataGridAccordionConfig` (root-only),
|
|
1067
|
+
* `provideDataGridAccordionConfigAt` injects the parent injector's
|
|
1068
|
+
* `CNGX_DATA_GRID_ACCORDION_CONFIG` value (resolves through the priority chain)
|
|
1069
|
+
* and merges the supplied features on top. Descendant grid instances see the
|
|
1070
|
+
* merged config; sibling sub-trees keep the inherited value untouched.
|
|
1071
|
+
*
|
|
1072
|
+
* ```ts
|
|
1073
|
+
* @Component({
|
|
1074
|
+
* viewProviders: [provideDataGridAccordionConfigAt(withDataGridSkin('report'))],
|
|
1075
|
+
* template: '<cngx-data-grid-accordion>...</cngx-data-grid-accordion>',
|
|
1076
|
+
* })
|
|
1077
|
+
* class Ledger {}
|
|
1078
|
+
* ```
|
|
1079
|
+
*
|
|
1080
|
+
* @category ui/data-grid-accordion
|
|
1081
|
+
* @since 0.1.0
|
|
1082
|
+
*/
|
|
1083
|
+
function provideDataGridAccordionConfigAt(...features) {
|
|
1084
|
+
// Empty-features call: parent value flows through untouched. Skipping the
|
|
1085
|
+
// factory preserves reference identity through the sub-tree.
|
|
1086
|
+
if (features.length === 0) {
|
|
1087
|
+
return [];
|
|
1088
|
+
}
|
|
1089
|
+
const partial = reduceFeatures(features);
|
|
1090
|
+
return [
|
|
1091
|
+
{
|
|
1092
|
+
provide: CNGX_DATA_GRID_ACCORDION_CONFIG,
|
|
1093
|
+
useFactory: () => {
|
|
1094
|
+
const parent = inject(CNGX_DATA_GRID_ACCORDION_CONFIG, { skipSelf: true });
|
|
1095
|
+
return mergeConfig(parent, partial);
|
|
1096
|
+
},
|
|
1097
|
+
},
|
|
1098
|
+
];
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// Sort and filter ship NO config feature (no `withDataGridSort` / `withDataGridFilter`).
|
|
1102
|
+
// They are per-instance state - each grid sorts and filters its own data - so there is
|
|
1103
|
+
// no plausible app-wide default to move onto the cascade, mirroring the deliberate
|
|
1104
|
+
// absence of `withDataGridColumns`. `[skin]` earns `withDataGridSkin` because a design
|
|
1105
|
+
// system does pick one skin org-wide; sort/filter never would. A `with*` is added only
|
|
1106
|
+
// if a genuine app-wide default surfaces later (e.g. an org-wide multi-sort toggle),
|
|
1107
|
+
// never speculatively.
|
|
1108
|
+
/**
|
|
1109
|
+
* Set the app-wide default visual skin for `<cngx-data-grid-accordion>`. Unset by
|
|
1110
|
+
* default (the base flat grid look). Per-instance `[skin]` Input still wins; this
|
|
1111
|
+
* moves the cascade default. Structure, cells, ARIA, and keyboard behaviour are
|
|
1112
|
+
* identical across skins - only the `[data-skin]` host attribute changes the CSS.
|
|
1113
|
+
* Typed class-sugar, not a mode flag.
|
|
1114
|
+
*
|
|
1115
|
+
* ```ts
|
|
1116
|
+
* provideDataGridAccordionConfig(withDataGridSkin('ledger'));
|
|
1117
|
+
* ```
|
|
1118
|
+
*
|
|
1119
|
+
* @category ui/data-grid-accordion
|
|
1120
|
+
* @since 0.1.0
|
|
1121
|
+
*/
|
|
1122
|
+
function withDataGridSkin(skin) {
|
|
1123
|
+
return { kind: 'skin', payload: { skin } };
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* @module @cngx/ui/data-grid-accordion
|
|
1128
|
+
*/
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Generated bundle index. Do not edit.
|
|
1132
|
+
*/
|
|
1133
|
+
|
|
1134
|
+
export { CNGX_DATA_GRID_ACCORDION, CNGX_DATA_GRID_ACCORDION_CONFIG, CngxDataGridAccordion, CngxDataGridFooter, CngxDataGridHeader, CngxDataGridRow, CngxDgCell, CngxDgaCount, CngxDgaFilter, CngxDgaFilterField, CngxDgaRowBusy, CngxDgaRowError, CngxDgaSortHeader, injectDataGridAccordionConfig, provideDataGridAccordionConfig, provideDataGridAccordionConfigAt, withDataGridSkin };
|
|
1135
|
+
//# sourceMappingURL=cngx-ui-data-grid-accordion.mjs.map
|