@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,645 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, makeEnvironmentProviders, SkipSelf, Optional, inject, input, output, ElementRef, computed, afterRenderEffect, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, booleanAttribute, contentChild } from '@angular/core';
|
|
4
|
+
import { CngxLiveRegion } from '@cngx/common/a11y';
|
|
5
|
+
import * as i1 from '@cngx/common/data';
|
|
6
|
+
import { injectRecycler, CngxVirtualItem, CngxMeasure, CngxRecyclerAnnouncer, CngxPaginate, resolveAsyncView, connectPaginateEmit, CNGX_RECYCLER_I18N } from '@cngx/common/data';
|
|
7
|
+
import { CngxEmptyState } from '@cngx/ui/empty-state';
|
|
8
|
+
import { CngxProgress } from '@cngx/ui/feedback';
|
|
9
|
+
import { CNGX_PAGINATOR_HOST } from '@cngx/ui/paginator';
|
|
10
|
+
export { CNGX_PAGINATOR_HOST, CngxPaginatorInfinite, CngxPaginatorLoadMore } from '@cngx/ui/paginator';
|
|
11
|
+
|
|
12
|
+
/** Library defaults - English. Override via {@link provideIncrementalListConfig}. */
|
|
13
|
+
const CNGX_INCREMENTAL_LIST_DEFAULTS = {
|
|
14
|
+
ariaLabels: {
|
|
15
|
+
loading: 'Loading',
|
|
16
|
+
empty: 'Nothing here yet',
|
|
17
|
+
error: 'Failed to load',
|
|
18
|
+
pageError: 'Failed to load more',
|
|
19
|
+
retry: 'Retry',
|
|
20
|
+
endReached: (total) => `All ${total} loaded`,
|
|
21
|
+
loadedMore: (count, total) => `${count} more loaded. ${total} total.`,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Configuration cascade token. Resolution priority (high to low):
|
|
26
|
+
* per-instance projected slot, then `provideIncrementalListConfigAt(...)` at
|
|
27
|
+
* component scope, then `provideIncrementalListConfig(...)` at the application
|
|
28
|
+
* root, then the library defaults.
|
|
29
|
+
*
|
|
30
|
+
* @category ui/collection
|
|
31
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list-config.ts
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
*/
|
|
34
|
+
const CNGX_INCREMENTAL_LIST_CONFIG = new InjectionToken('CngxIncrementalListConfig', {
|
|
35
|
+
providedIn: 'root',
|
|
36
|
+
factory: () => CNGX_INCREMENTAL_LIST_DEFAULTS,
|
|
37
|
+
});
|
|
38
|
+
/** Reduce a feature list onto a base config, merging each sub-tree in isolation. */
|
|
39
|
+
function applyFeatures(base, features) {
|
|
40
|
+
let ariaLabels = base.ariaLabels;
|
|
41
|
+
let templates = base.templates;
|
|
42
|
+
for (const feature of features) {
|
|
43
|
+
if (feature.kind === 'ariaLabels') {
|
|
44
|
+
ariaLabels = { ...ariaLabels, ...feature.payload };
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
templates = { ...templates, ...feature.payload };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { ariaLabels, templates };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Override any subset of the incremental-list labels. The override applies to
|
|
54
|
+
* both the visible built-in views and the live-region announcements.
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* provideIncrementalListConfig(
|
|
58
|
+
* withIncrementalListAriaLabels({
|
|
59
|
+
* empty: 'Noch nichts hier',
|
|
60
|
+
* endReached: (total) => `Alle ${total} geladen`,
|
|
61
|
+
* }),
|
|
62
|
+
* );
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @category ui/collection
|
|
66
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list-config.ts
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
*/
|
|
69
|
+
function withIncrementalListAriaLabels(payload) {
|
|
70
|
+
return { kind: 'ariaLabels', payload };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Supply application-wide template-slot defaults. A per-instance projected slot
|
|
74
|
+
* still wins over this tier; it only applies where no instance slot is present.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* provideIncrementalListConfig(
|
|
78
|
+
* withIncrementalListTemplates({ empty: myBrandedEmptyTemplate }),
|
|
79
|
+
* );
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @category ui/collection
|
|
83
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list-config.ts
|
|
84
|
+
* @since 0.1.0
|
|
85
|
+
*/
|
|
86
|
+
function withIncrementalListTemplates(payload) {
|
|
87
|
+
return { kind: 'templates', payload };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Application-root configuration cascade for the incremental list. Pass any
|
|
91
|
+
* combination of `with*` features in `bootstrapApplication`'s providers.
|
|
92
|
+
* Supplied features merge with the library defaults, so consumers only declare
|
|
93
|
+
* the keys they override.
|
|
94
|
+
*
|
|
95
|
+
* @category ui/collection
|
|
96
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list-config.ts
|
|
97
|
+
* @since 0.1.0
|
|
98
|
+
*/
|
|
99
|
+
function provideIncrementalListConfig(...features) {
|
|
100
|
+
// Empty-features: leave the root default reference untouched so downstream
|
|
101
|
+
// identity comparisons stay stable.
|
|
102
|
+
if (features.length === 0) {
|
|
103
|
+
return makeEnvironmentProviders([]);
|
|
104
|
+
}
|
|
105
|
+
return makeEnvironmentProviders([
|
|
106
|
+
{
|
|
107
|
+
provide: CNGX_INCREMENTAL_LIST_CONFIG,
|
|
108
|
+
useValue: applyFeatures(CNGX_INCREMENTAL_LIST_DEFAULTS, features),
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Component-scoped incremental-list configuration override. Pass into a
|
|
114
|
+
* component's or directive's `viewProviders`; features merge on top of the
|
|
115
|
+
* parent config (an enclosing scope or the application root), so a region can
|
|
116
|
+
* re-phrase its labels without disturbing the rest of the app.
|
|
117
|
+
*
|
|
118
|
+
* @category ui/collection
|
|
119
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list-config.ts
|
|
120
|
+
* @since 0.1.0
|
|
121
|
+
*/
|
|
122
|
+
function provideIncrementalListConfigAt(...features) {
|
|
123
|
+
return [
|
|
124
|
+
{
|
|
125
|
+
provide: CNGX_INCREMENTAL_LIST_CONFIG,
|
|
126
|
+
useFactory: (parent) => applyFeatures(parent ?? CNGX_INCREMENTAL_LIST_DEFAULTS, features),
|
|
127
|
+
deps: [[new SkipSelf(), new Optional(), CNGX_INCREMENTAL_LIST_CONFIG]],
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Convenience accessor for the incremental-list configuration. Runs in
|
|
133
|
+
* injection context; resolves through the cascade. Equivalent to
|
|
134
|
+
* `inject(CNGX_INCREMENTAL_LIST_CONFIG)`.
|
|
135
|
+
*
|
|
136
|
+
* @category ui/collection
|
|
137
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list-config.ts
|
|
138
|
+
* @since 0.1.0
|
|
139
|
+
*/
|
|
140
|
+
function injectIncrementalListConfig() {
|
|
141
|
+
return inject(CNGX_INCREMENTAL_LIST_CONFIG);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The collection organism reuses the paginator's read-mostly host contract
|
|
146
|
+
* verbatim. `CngxIncrementalList` hosts the same `CngxPaginate` brain and
|
|
147
|
+
* provides `CNGX_PAGINATOR_HOST` via `useExisting`, so a projected trigger atom
|
|
148
|
+
* (`cngx-pgn-load-more`, `cngx-pgn-infinite`) injects the identical token and
|
|
149
|
+
* needs only `next()` / `isBusy()` / `isLast()` / `cumulativeRange()`.
|
|
150
|
+
*
|
|
151
|
+
* This alias gives `@cngx/ui/collection` consumers a local import surface
|
|
152
|
+
* without redefining the contract: one token, one shape, no new trigger context
|
|
153
|
+
* type. The re-exported symbol is the same `InjectionToken` instance, so a
|
|
154
|
+
* trigger imported from either entry resolves to the same provider.
|
|
155
|
+
*
|
|
156
|
+
* @category ui/collection
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Virtualized content body for `CngxIncrementalList`. Instantiated only under
|
|
161
|
+
* the organism's `@if (virtualize())`, so the recycler (scroll observer, four
|
|
162
|
+
* effects, and focus listeners installed unconditionally at construction) never
|
|
163
|
+
* runs for a render-all list - the opt-in cost is real, not nominal.
|
|
164
|
+
*
|
|
165
|
+
* A private composition unit in the shape of the `CngxSelectPanel` /
|
|
166
|
+
* `CngxSelectPanelShell` split: it owns `injectRecycler`, the equal'd window,
|
|
167
|
+
* and renders the windowed rows with the existing `CngxVirtualItem` /
|
|
168
|
+
* `CngxMeasure` atoms. The host element IS the scroll viewport - the
|
|
169
|
+
* `.cngx-incremental-list__viewport` overflow + bounded-height rule and the
|
|
170
|
+
* recycler's `scrollElement` resolve to this one node.
|
|
171
|
+
*
|
|
172
|
+
* @internal Not exported from `@cngx/ui/collection` public API.
|
|
173
|
+
*/
|
|
174
|
+
class CngxIncrementalVirtualizedBody {
|
|
175
|
+
/**
|
|
176
|
+
* The full accumulated slice to virtualize. Defaults to `[]` (not
|
|
177
|
+
* `required`) because `injectRecycler` reads `totalCount()` at construction to
|
|
178
|
+
* seed its announcement bookkeeping - a required input would throw NG0950
|
|
179
|
+
* before the organism binds. The organism always binds it.
|
|
180
|
+
*/
|
|
181
|
+
items = input([], ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
182
|
+
/** Initial per-row height estimate (px); forwarded to the recycler. */
|
|
183
|
+
estimateSize = input(48, ...(ngDevMode ? [{ debugName: "estimateSize" }] : /* istanbul ignore next */ []));
|
|
184
|
+
/**
|
|
185
|
+
* Item slot template resolved by the organism, or `null` for the built-in
|
|
186
|
+
* text row. Rendered per windowed row with the same context the render-all
|
|
187
|
+
* path uses, but keyed on the absolute index.
|
|
188
|
+
*/
|
|
189
|
+
itemTemplate = input(null, ...(ngDevMode ? [{ debugName: "itemTemplate" }] : /* istanbul ignore next */ []));
|
|
190
|
+
/** `@for` track fn from the organism - keyed on the absolute row index. */
|
|
191
|
+
trackItem = input.required(...(ngDevMode ? [{ debugName: "trackItem" }] : /* istanbul ignore next */ []));
|
|
192
|
+
/**
|
|
193
|
+
* Emitted when the row holding focus recycles out of the window and no
|
|
194
|
+
* rendered row remains to catch it. The organism owns the projected trigger,
|
|
195
|
+
* so the escape-fallback target is the organism's, not this component's - it
|
|
196
|
+
* hands focus back rather than reaching outside its own host.
|
|
197
|
+
*/
|
|
198
|
+
focusEscaped = output();
|
|
199
|
+
host = inject((ElementRef));
|
|
200
|
+
/**
|
|
201
|
+
* The recycler. Constructed here, never in the organism, so its scroll
|
|
202
|
+
* observer + effects install only when virtualized. `estimateSize` is passed
|
|
203
|
+
* as the signal reference so it reads reactively after binding rather than the
|
|
204
|
+
* construction-time default; `state` is intentionally not forwarded - the
|
|
205
|
+
* recycler reads `config.state` once at construction when the input is still
|
|
206
|
+
* unbound, and its no-state branch already announces load-count from
|
|
207
|
+
* `totalCount` growth, which is the append-feed semantics the announcer wants.
|
|
208
|
+
*/
|
|
209
|
+
recycler = injectRecycler({
|
|
210
|
+
scrollElement: this.host.nativeElement,
|
|
211
|
+
totalCount: () => this.items().length,
|
|
212
|
+
estimateSize: this.estimateSize,
|
|
213
|
+
});
|
|
214
|
+
/**
|
|
215
|
+
* The visible window, sliced to `[recycler.start(), recycler.end())` with an
|
|
216
|
+
* explicit structural `equal` (mirrors the select family's recycler panel
|
|
217
|
+
* renderer): length + per-entry `Object.is`, so a window that does not move
|
|
218
|
+
* keeps its reference and the row `@for` does not thrash. Returns the source
|
|
219
|
+
* verbatim when the window covers the whole list, so upstream identity stays
|
|
220
|
+
* stable for small opt-in lists.
|
|
221
|
+
*/
|
|
222
|
+
windowItems = computed(() => {
|
|
223
|
+
const all = this.items();
|
|
224
|
+
const start = this.recycler.start();
|
|
225
|
+
const end = this.recycler.end();
|
|
226
|
+
if (start === 0 && end >= all.length) {
|
|
227
|
+
return all;
|
|
228
|
+
}
|
|
229
|
+
return all.slice(start, Math.min(end, all.length));
|
|
230
|
+
}, { ...(ngDevMode ? { debugName: "windowItems" } : /* istanbul ignore next */ {}), equal: (a, b) => {
|
|
231
|
+
if (a === b) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
if (a.length !== b.length) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
for (let i = 0; i < a.length; i++) {
|
|
238
|
+
if (!Object.is(a[i], b[i])) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
} });
|
|
244
|
+
constructor() {
|
|
245
|
+
// Focus continuity under recycling: when the row that held focus scrolls out
|
|
246
|
+
// of the window, move focus to the nearest still-rendered row so keyboard
|
|
247
|
+
// focus is never stranded on a detached node (Pillar 2 - a recycled-out
|
|
248
|
+
// focus is a silent failure). afterRenderEffect (not effect) so the restore
|
|
249
|
+
// reads the DOM AFTER the recycled window has painted its new rows - a plain
|
|
250
|
+
// effect races the @for re-render and would target an about-to-be-removed
|
|
251
|
+
// row. Reads `lostFocus` (the recycler owns the focusin/focusout tracking);
|
|
252
|
+
// writes no signal it owns and calls no service, so no `untracked` guard is
|
|
253
|
+
// needed. Landing focus on an in-window row re-enters the recycler's focusin
|
|
254
|
+
// handler, which pulls `focusedIndex` back into `[start, end)` and nulls
|
|
255
|
+
// `lostFocus` - the next run early-returns, so there is no re-fire loop.
|
|
256
|
+
afterRenderEffect(() => {
|
|
257
|
+
const lost = this.recycler.lostFocus();
|
|
258
|
+
if (!lost) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
this.restoreFocus(lost.index);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Move focus to the rendered row nearest the recycled-out index, or emit
|
|
266
|
+
* `focusEscaped` when the window has no row to receive it.
|
|
267
|
+
*/
|
|
268
|
+
restoreFocus(lostIndex) {
|
|
269
|
+
const rows = Array.from(this.host.nativeElement.querySelectorAll('[data-cngx-recycle-index]'));
|
|
270
|
+
if (rows.length === 0) {
|
|
271
|
+
this.focusEscaped.emit();
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const indexOf = (row) => Number(row.getAttribute('data-cngx-recycle-index'));
|
|
275
|
+
const target = rows.reduce((nearest, row) => Math.abs(indexOf(row) - lostIndex) < Math.abs(indexOf(nearest) - lostIndex) ? row : nearest);
|
|
276
|
+
// Content rows are not natively focusable; make the target programmatically
|
|
277
|
+
// focusable without adding it to the tab order.
|
|
278
|
+
target.tabIndex = -1;
|
|
279
|
+
target.focus({ preventScroll: true });
|
|
280
|
+
}
|
|
281
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalVirtualizedBody, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
282
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxIncrementalVirtualizedBody, isStandalone: true, selector: "cngx-incremental-virtualized-body", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, estimateSize: { classPropertyName: "estimateSize", publicName: "estimateSize", isSignal: true, isRequired: false, transformFunction: null }, itemTemplate: { classPropertyName: "itemTemplate", publicName: "itemTemplate", isSignal: true, isRequired: false, transformFunction: null }, trackItem: { classPropertyName: "trackItem", publicName: "trackItem", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { focusEscaped: "focusEscaped" }, host: { classAttribute: "cngx-incremental-list__viewport" }, ngImport: i0, template: "<ul\n class=\"cngx-incremental-list__items\"\n role=\"list\"\n [style.padding-block-start.px]=\"recycler.offsetBefore()\"\n [style.padding-block-end.px]=\"recycler.offsetAfter()\"\n>\n @for (item of windowItems(); track trackItem()(recycler.start() + $index, item)) {\n <li\n class=\"cngx-incremental-list__item\"\n [cngxVirtualItem]=\"recycler\"\n [cngxVirtualItemIndex]=\"recycler.start() + $index\"\n [cngxMeasure]=\"recycler\"\n [cngxMeasureIndex]=\"recycler.start() + $index\"\n >\n @if (itemTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: recycler.start() + $index }\"\n />\n } @else {\n {{ item }}\n }\n </li>\n }\n</ul>\n\n<cngx-recycler-announcer [cngxRecyclerAnnouncer]=\"recycler\" />\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxVirtualItem, selector: "[cngxVirtualItem]", inputs: ["cngxVirtualItem", "cngxVirtualItemIndex"] }, { kind: "directive", type: CngxMeasure, selector: "[cngxMeasure]", inputs: ["cngxMeasure", "cngxMeasureIndex"] }, { kind: "component", type: CngxRecyclerAnnouncer, selector: "cngx-recycler-announcer", inputs: ["cngxRecyclerAnnouncer"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
283
|
+
}
|
|
284
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalVirtualizedBody, decorators: [{
|
|
285
|
+
type: Component,
|
|
286
|
+
args: [{ selector: 'cngx-incremental-virtualized-body', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet, CngxVirtualItem, CngxMeasure, CngxRecyclerAnnouncer], host: { class: 'cngx-incremental-list__viewport' }, template: "<ul\n class=\"cngx-incremental-list__items\"\n role=\"list\"\n [style.padding-block-start.px]=\"recycler.offsetBefore()\"\n [style.padding-block-end.px]=\"recycler.offsetAfter()\"\n>\n @for (item of windowItems(); track trackItem()(recycler.start() + $index, item)) {\n <li\n class=\"cngx-incremental-list__item\"\n [cngxVirtualItem]=\"recycler\"\n [cngxVirtualItemIndex]=\"recycler.start() + $index\"\n [cngxMeasure]=\"recycler\"\n [cngxMeasureIndex]=\"recycler.start() + $index\"\n >\n @if (itemTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: recycler.start() + $index }\"\n />\n } @else {\n {{ item }}\n }\n </li>\n }\n</ul>\n\n<cngx-recycler-announcer [cngxRecyclerAnnouncer]=\"recycler\" />\n" }]
|
|
287
|
+
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], estimateSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "estimateSize", required: false }] }], itemTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemTemplate", required: false }] }], trackItem: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackItem", required: true }] }], focusEscaped: [{ type: i0.Output, args: ["focusEscaped"] }] } });
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Item slot. Project `<ng-template cngxIncrementalItem let-item let-i="index">`
|
|
291
|
+
* inside `<cngx-incremental-list>` to render each accumulated row; the organism
|
|
292
|
+
* renders it per item in the revealed slice. Resolution cascades instance slot
|
|
293
|
+
* -> `CngxIncrementalListConfig.templates.item` -> the built-in text row.
|
|
294
|
+
*
|
|
295
|
+
* @category ui/collection
|
|
296
|
+
* @since 0.1.0
|
|
297
|
+
*/
|
|
298
|
+
class CngxIncrementalItem {
|
|
299
|
+
templateRef = inject(TemplateRef);
|
|
300
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
304
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxIncrementalItem, isStandalone: true, selector: "ng-template[cngxIncrementalItem]", exportAs: ["cngxIncrementalItem"], ngImport: i0 });
|
|
305
|
+
}
|
|
306
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalItem, decorators: [{
|
|
307
|
+
type: Directive,
|
|
308
|
+
args: [{
|
|
309
|
+
selector: 'ng-template[cngxIncrementalItem]',
|
|
310
|
+
standalone: true,
|
|
311
|
+
exportAs: 'cngxIncrementalItem',
|
|
312
|
+
}]
|
|
313
|
+
}] });
|
|
314
|
+
/**
|
|
315
|
+
* Empty slot. Project `<ng-template cngxIncrementalEmpty>` to replace the
|
|
316
|
+
* built-in empty view shown when the bound state settles with no data.
|
|
317
|
+
*
|
|
318
|
+
* @category ui/collection
|
|
319
|
+
* @since 0.1.0
|
|
320
|
+
*/
|
|
321
|
+
class CngxIncrementalEmpty {
|
|
322
|
+
templateRef = inject(TemplateRef);
|
|
323
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
324
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxIncrementalEmpty, isStandalone: true, selector: "ng-template[cngxIncrementalEmpty]", exportAs: ["cngxIncrementalEmpty"], ngImport: i0 });
|
|
325
|
+
}
|
|
326
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalEmpty, decorators: [{
|
|
327
|
+
type: Directive,
|
|
328
|
+
args: [{
|
|
329
|
+
selector: 'ng-template[cngxIncrementalEmpty]',
|
|
330
|
+
standalone: true,
|
|
331
|
+
exportAs: 'cngxIncrementalEmpty',
|
|
332
|
+
}]
|
|
333
|
+
}] });
|
|
334
|
+
/**
|
|
335
|
+
* Error slot. Project `<ng-template cngxIncrementalError let-retry="retry">` to
|
|
336
|
+
* replace the built-in error + retry view. Resolution cascades instance slot ->
|
|
337
|
+
* `CngxIncrementalListConfig.templates.error` -> the built-in message + button.
|
|
338
|
+
*
|
|
339
|
+
* @category ui/collection
|
|
340
|
+
* @since 0.1.0
|
|
341
|
+
*/
|
|
342
|
+
class CngxIncrementalError {
|
|
343
|
+
templateRef = inject(TemplateRef);
|
|
344
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
348
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxIncrementalError, isStandalone: true, selector: "ng-template[cngxIncrementalError]", exportAs: ["cngxIncrementalError"], ngImport: i0 });
|
|
349
|
+
}
|
|
350
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalError, decorators: [{
|
|
351
|
+
type: Directive,
|
|
352
|
+
args: [{
|
|
353
|
+
selector: 'ng-template[cngxIncrementalError]',
|
|
354
|
+
standalone: true,
|
|
355
|
+
exportAs: 'cngxIncrementalError',
|
|
356
|
+
}]
|
|
357
|
+
}] });
|
|
358
|
+
/**
|
|
359
|
+
* End-reached slot. Project `<ng-template cngxIncrementalEnd>` to replace the
|
|
360
|
+
* built-in "all loaded" label shown once every page has been revealed.
|
|
361
|
+
*
|
|
362
|
+
* @category ui/collection
|
|
363
|
+
* @since 0.1.0
|
|
364
|
+
*/
|
|
365
|
+
class CngxIncrementalEnd {
|
|
366
|
+
templateRef = inject(TemplateRef);
|
|
367
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalEnd, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
368
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxIncrementalEnd, isStandalone: true, selector: "ng-template[cngxIncrementalEnd]", exportAs: ["cngxIncrementalEnd"], ngImport: i0 });
|
|
369
|
+
}
|
|
370
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalEnd, decorators: [{
|
|
371
|
+
type: Directive,
|
|
372
|
+
args: [{
|
|
373
|
+
selector: 'ng-template[cngxIncrementalEnd]',
|
|
374
|
+
standalone: true,
|
|
375
|
+
exportAs: 'cngxIncrementalEnd',
|
|
376
|
+
}]
|
|
377
|
+
}] });
|
|
378
|
+
/**
|
|
379
|
+
* Loading slot. Project `<ng-template cngxIncrementalLoading>` to replace the
|
|
380
|
+
* built-in first-load progress indicator. Resolution cascades instance slot ->
|
|
381
|
+
* `CngxIncrementalListConfig.templates.loading` -> the built-in `CngxProgress`.
|
|
382
|
+
*
|
|
383
|
+
* @category ui/collection
|
|
384
|
+
* @since 0.1.0
|
|
385
|
+
*/
|
|
386
|
+
class CngxIncrementalLoading {
|
|
387
|
+
templateRef = inject(TemplateRef);
|
|
388
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalLoading, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
389
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxIncrementalLoading, isStandalone: true, selector: "ng-template[cngxIncrementalLoading]", exportAs: ["cngxIncrementalLoading"], ngImport: i0 });
|
|
390
|
+
}
|
|
391
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalLoading, decorators: [{
|
|
392
|
+
type: Directive,
|
|
393
|
+
args: [{
|
|
394
|
+
selector: 'ng-template[cngxIncrementalLoading]',
|
|
395
|
+
standalone: true,
|
|
396
|
+
exportAs: 'cngxIncrementalLoading',
|
|
397
|
+
}]
|
|
398
|
+
}] });
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Append-style collection organism. \
|
|
402
|
+
* Accumulates rows across pages (append, don't replace) and switches its view
|
|
403
|
+
* by async status - loading / content / empty / error / end-reached - from a
|
|
404
|
+
* single `[state]` source. A thin shell over the `CngxPaginate` brain (applied
|
|
405
|
+
* as a `hostDirective`): the accumulated slice is read from the brain's
|
|
406
|
+
* `cumulativeRange()`, the end-reached branch from `isLast()`, and the loading
|
|
407
|
+
* gate from the bound state's `isBusy()`. It owns no `[mode]` flag and no
|
|
408
|
+
* accumulation state of its own.
|
|
409
|
+
*
|
|
410
|
+
* The brain is provided as `CNGX_PAGINATOR_HOST` via `useExisting`, so an
|
|
411
|
+
* existing trigger atom (`cngx-pgn-load-more`, `cngx-pgn-infinite`) injects the
|
|
412
|
+
* same contract when projected - the trigger stays a swappable terminal unit,
|
|
413
|
+
* the rich async experience lives here.
|
|
414
|
+
*
|
|
415
|
+
* Two-way `[(pageIndex)]` / `[(pageSize)]` mirror the paginator shell: the
|
|
416
|
+
* brain's controlled inputs are aliased through `hostDirectives` and this
|
|
417
|
+
* component is the single emitter of the matching outputs.
|
|
418
|
+
*
|
|
419
|
+
* All ARIA is signal-driven: `aria-busy` reflects the brain busy signal and a
|
|
420
|
+
* polite live region communicates every settle (empty / error / end-reached).
|
|
421
|
+
*
|
|
422
|
+
* @category ui/collection
|
|
423
|
+
* @docsKind primary
|
|
424
|
+
* @wcag AA
|
|
425
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/collection/incremental-list.component.ts
|
|
426
|
+
* @since 0.1.0
|
|
427
|
+
* @relatedTo CngxPaginate, CngxPaginator, CngxAsyncState
|
|
428
|
+
*/
|
|
429
|
+
class CngxIncrementalList {
|
|
430
|
+
/** Visual skin; reflected onto `[data-skin]`. Paint-only. */
|
|
431
|
+
skin = input('plain', ...(ngDevMode ? [{ debugName: "skin" }] : /* istanbul ignore next */ []));
|
|
432
|
+
/**
|
|
433
|
+
* Opt into DOM recycling. When set, the accumulated content branch renders
|
|
434
|
+
* only the visible window of rows through an internal virtualized body inside
|
|
435
|
+
* a bounded scroll viewport; every off-window row is a pixel spacer. Unset
|
|
436
|
+
* (default) keeps the render-all path - the recycler never constructs, so a
|
|
437
|
+
* small list pays nothing. Reflected onto `[data-virtualize]`.
|
|
438
|
+
*/
|
|
439
|
+
virtualize = input(false, { ...(ngDevMode ? { debugName: "virtualize" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
440
|
+
/**
|
|
441
|
+
* Initial per-row height estimate (px) for the virtualized window - the first
|
|
442
|
+
* guess before a row is measured. Ignored unless `[virtualize]` is set.
|
|
443
|
+
*/
|
|
444
|
+
estimateSize = input(48, ...(ngDevMode ? [{ debugName: "estimateSize" }] : /* istanbul ignore next */ []));
|
|
445
|
+
/** Emits the effective page index on every change - navigation or `total`-shrink clamp. */
|
|
446
|
+
pageIndexChange = output();
|
|
447
|
+
/** Emits the effective page size on every change. */
|
|
448
|
+
pageSizeChange = output();
|
|
449
|
+
/**
|
|
450
|
+
* Emits when the error view's retry affordance is activated (the built-in
|
|
451
|
+
* button or a projected error slot's `retry()` context). The consumer re-runs
|
|
452
|
+
* its data source; the organism owns no fetch of its own.
|
|
453
|
+
*/
|
|
454
|
+
retry = output();
|
|
455
|
+
/**
|
|
456
|
+
* Item identity for the accumulated `@for`. Defaults to the row index
|
|
457
|
+
* (append-safe: appended rows keep their position). Supply a key fn when the
|
|
458
|
+
* bound `[state]` data can be replaced or reordered, so a projected item
|
|
459
|
+
* template keeps its per-row state instead of being reused by position.
|
|
460
|
+
*/
|
|
461
|
+
trackBy = input((index) => index, ...(ngDevMode ? [{ debugName: "trackBy" }] : /* istanbul ignore next */ []));
|
|
462
|
+
paginate = inject(CngxPaginate);
|
|
463
|
+
host = inject((ElementRef));
|
|
464
|
+
config = injectIncrementalListConfig();
|
|
465
|
+
// View slot resolvers. Direct contentChild field initialisers (AOT NG8110
|
|
466
|
+
// rejects them from a helper); read as TemplateRef so the cascade computeds
|
|
467
|
+
// return a renderable reference or null.
|
|
468
|
+
itemSlot = contentChild(CngxIncrementalItem, { ...(ngDevMode ? { debugName: "itemSlot" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
469
|
+
emptySlot = contentChild(CngxIncrementalEmpty, { ...(ngDevMode ? { debugName: "emptySlot" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
470
|
+
errorSlot = contentChild(CngxIncrementalError, { ...(ngDevMode ? { debugName: "errorSlot" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
471
|
+
endSlot = contentChild(CngxIncrementalEnd, { ...(ngDevMode ? { debugName: "endSlot" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
472
|
+
loadingSlot = contentChild(CngxIncrementalLoading, { ...(ngDevMode ? { debugName: "loadingSlot" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
473
|
+
// Three-stage slot cascade: instance slot -> config.templates.<key> ->
|
|
474
|
+
// built-in default. Returns existing TemplateRef refs or null -
|
|
475
|
+
// reference-stable, so no explicit equal fn is needed.
|
|
476
|
+
itemTemplate = computed(() => this.itemSlot() ?? this.config.templates?.item ?? null, ...(ngDevMode ? [{ debugName: "itemTemplate" }] : /* istanbul ignore next */ []));
|
|
477
|
+
emptyTemplate = computed(() => this.emptySlot() ?? this.config.templates?.empty ?? null, ...(ngDevMode ? [{ debugName: "emptyTemplate" }] : /* istanbul ignore next */ []));
|
|
478
|
+
errorTemplate = computed(() => this.errorSlot() ?? this.config.templates?.error ?? null, ...(ngDevMode ? [{ debugName: "errorTemplate" }] : /* istanbul ignore next */ []));
|
|
479
|
+
endTemplate = computed(() => this.endSlot() ?? this.config.templates?.end ?? null, ...(ngDevMode ? [{ debugName: "endTemplate" }] : /* istanbul ignore next */ []));
|
|
480
|
+
loadingTemplate = computed(() => this.loadingSlot() ?? this.config.templates?.loading ?? null, ...(ngDevMode ? [{ debugName: "loadingTemplate" }] : /* istanbul ignore next */ []));
|
|
481
|
+
/**
|
|
482
|
+
* Which region renders, resolved from the single `[state]` source through the
|
|
483
|
+
* shared `resolveAsyncView` switch - no local state machine. With no bound
|
|
484
|
+
* state the organism is a plain content list.
|
|
485
|
+
*/
|
|
486
|
+
view = computed(() => {
|
|
487
|
+
const state = this.paginate.state();
|
|
488
|
+
if (!state) {
|
|
489
|
+
return 'content';
|
|
490
|
+
}
|
|
491
|
+
return resolveAsyncView(state.status(), state.isFirstLoad(), state.isEmpty());
|
|
492
|
+
}, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
|
|
493
|
+
/** `true` on the last page - every accumulated item has been revealed. */
|
|
494
|
+
exhausted = computed(() => this.paginate.isLast(), ...(ngDevMode ? [{ debugName: "exhausted" }] : /* istanbul ignore next */ []));
|
|
495
|
+
/**
|
|
496
|
+
* The accumulated slice: every page revealed so far, sliced from the top of
|
|
497
|
+
* the bound data. Pure derivation of the brain `cumulativeRange()` and the
|
|
498
|
+
* state's `data()`; the explicit `equal` stops a fresh-array identity from
|
|
499
|
+
* cascading downstream.
|
|
500
|
+
*/
|
|
501
|
+
items = computed(() => {
|
|
502
|
+
const data = this.paginate.state()?.data();
|
|
503
|
+
if (!Array.isArray(data)) {
|
|
504
|
+
return [];
|
|
505
|
+
}
|
|
506
|
+
const [start, end] = this.paginate.cumulativeRange();
|
|
507
|
+
return data.slice(start, end);
|
|
508
|
+
}, { ...(ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {}), equal: (a, b) => a.length === b.length && a.every((item, i) => Object.is(item, b[i])) });
|
|
509
|
+
// Built-in view labels, resolved through the config cascade (EN library
|
|
510
|
+
// defaults). Consumers re-phrase or localise via provideIncrementalListConfig.
|
|
511
|
+
loadingLabel = computed(() => this.config.ariaLabels.loading, ...(ngDevMode ? [{ debugName: "loadingLabel" }] : /* istanbul ignore next */ []));
|
|
512
|
+
emptyLabel = computed(() => this.config.ariaLabels.empty, ...(ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []));
|
|
513
|
+
errorLabel = computed(() => this.config.ariaLabels.error, ...(ngDevMode ? [{ debugName: "errorLabel" }] : /* istanbul ignore next */ []));
|
|
514
|
+
pageErrorLabel = computed(() => this.config.ariaLabels.pageError, ...(ngDevMode ? [{ debugName: "pageErrorLabel" }] : /* istanbul ignore next */ []));
|
|
515
|
+
retryLabel = computed(() => this.config.ariaLabels.retry, ...(ngDevMode ? [{ debugName: "retryLabel" }] : /* istanbul ignore next */ []));
|
|
516
|
+
endLabel = computed(() => this.config.ariaLabels.endReached(this.paginate.total()), ...(ngDevMode ? [{ debugName: "endLabel" }] : /* istanbul ignore next */ []));
|
|
517
|
+
/**
|
|
518
|
+
* Error text for the active error view - the distinct `pageError` phrasing
|
|
519
|
+
* when a subsequent page failed with the list still visible (`content+error`),
|
|
520
|
+
* the first-load `error` phrasing otherwise. Drives both the built-in visible
|
|
521
|
+
* text and the live-region announcement so the two never diverge.
|
|
522
|
+
*/
|
|
523
|
+
errorViewLabel = computed(() => this.view() === 'content+error' ? this.pageErrorLabel() : this.errorLabel(), ...(ngDevMode ? [{ debugName: "errorViewLabel" }] : /* istanbul ignore next */ []));
|
|
524
|
+
/**
|
|
525
|
+
* Polite live-region message - communicated on every settle through the same
|
|
526
|
+
* labels the visible views use, so a config or slot override stays in sync.
|
|
527
|
+
*/
|
|
528
|
+
statusMessage = computed(() => {
|
|
529
|
+
if (this.paginate.isBusy()) {
|
|
530
|
+
return this.loadingLabel();
|
|
531
|
+
}
|
|
532
|
+
const view = this.view();
|
|
533
|
+
if (view === 'empty') {
|
|
534
|
+
return this.emptyLabel();
|
|
535
|
+
}
|
|
536
|
+
if (view === 'error' || view === 'content+error') {
|
|
537
|
+
return this.errorViewLabel();
|
|
538
|
+
}
|
|
539
|
+
return this.exhausted() ? this.endLabel() : '';
|
|
540
|
+
}, ...(ngDevMode ? [{ debugName: "statusMessage" }] : /* istanbul ignore next */ []));
|
|
541
|
+
/** Stable retry callback - emits the `retry` output; shared by the built-in button and the error slot context. */
|
|
542
|
+
retryFn = () => this.retry.emit();
|
|
543
|
+
/**
|
|
544
|
+
* Focus fallback for the virtualized body: when a focused row recycles out and
|
|
545
|
+
* the window has no row left to catch focus, restore it to the projected
|
|
546
|
+
* trigger. The organism owns the trigger `ng-content`, so the escape target is
|
|
547
|
+
* the organism's, not the body's.
|
|
548
|
+
*/
|
|
549
|
+
handleFocusEscaped() {
|
|
550
|
+
const root = this.host.nativeElement;
|
|
551
|
+
const trigger = root.querySelector('[cngxIncrementalTrigger]');
|
|
552
|
+
if (!trigger) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const focusable = trigger.querySelector('button, [tabindex]') ?? trigger;
|
|
556
|
+
focusable.focus();
|
|
557
|
+
}
|
|
558
|
+
/** Context handed to a projected error slot: the retry callback and the raw error. */
|
|
559
|
+
errorContext = computed(() => ({ retry: this.retryFn, error: this.paginate.state()?.error() }), { ...(ngDevMode ? { debugName: "errorContext" } : /* istanbul ignore next */ {}), equal: (a, b) => a.retry === b.retry && a.error === b.error });
|
|
560
|
+
/** `@for` track expression - delegates to the `trackBy` input (index by default). */
|
|
561
|
+
trackItem = (index, item) => this.trackBy()(index, item);
|
|
562
|
+
constructor() {
|
|
563
|
+
// Two-way [(pageIndex)] / [(pageSize)] emit, shared verbatim with
|
|
564
|
+
// CngxPaginator through the connectPaginateEmit bridge.
|
|
565
|
+
connectPaginateEmit(this.paginate, {
|
|
566
|
+
onIndex: (index) => this.pageIndexChange.emit(index),
|
|
567
|
+
onSize: (size) => this.pageSizeChange.emit(size),
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
571
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxIncrementalList, isStandalone: true, selector: "cngx-incremental-list", inputs: { skin: { classPropertyName: "skin", publicName: "skin", isSignal: true, isRequired: false, transformFunction: null }, virtualize: { classPropertyName: "virtualize", publicName: "virtualize", isSignal: true, isRequired: false, transformFunction: null }, estimateSize: { classPropertyName: "estimateSize", publicName: "estimateSize", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageIndexChange: "pageIndexChange", pageSizeChange: "pageSizeChange", retry: "retry" }, host: { properties: { "attr.aria-busy": "paginate.isBusy()", "attr.data-skin": "skin()", "attr.data-virtualize": "virtualize() ? '' : null" }, classAttribute: "cngx-incremental-list" }, providers: [
|
|
572
|
+
{ provide: CNGX_PAGINATOR_HOST, useExisting: CngxPaginate },
|
|
573
|
+
{
|
|
574
|
+
// Route the recycler's SR i18n through the same config cascade the
|
|
575
|
+
// organism uses, so a consumer localises the load-count announcement via
|
|
576
|
+
// withIncrementalListAriaLabels alongside the view-state labels. Owner
|
|
577
|
+
// split: only loaded() carries text; empty()/error()/filtered() stay
|
|
578
|
+
// silent so the organism's statusMessage live region remains the sole
|
|
579
|
+
// owner of view-state (no double-announce). The no-state recycler branch
|
|
580
|
+
// never calls filtered()/error() anyway.
|
|
581
|
+
provide: CNGX_RECYCLER_I18N,
|
|
582
|
+
useFactory: () => {
|
|
583
|
+
const config = injectIncrementalListConfig();
|
|
584
|
+
return {
|
|
585
|
+
loaded: (count, total) => config.ariaLabels.loadedMore(count, total),
|
|
586
|
+
filtered: () => '',
|
|
587
|
+
empty: () => '',
|
|
588
|
+
error: () => '',
|
|
589
|
+
};
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
], queries: [{ propertyName: "itemSlot", first: true, predicate: CngxIncrementalItem, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "emptySlot", first: true, predicate: CngxIncrementalEmpty, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "errorSlot", first: true, predicate: CngxIncrementalError, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "endSlot", first: true, predicate: CngxIncrementalEnd, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "loadingSlot", first: true, predicate: CngxIncrementalLoading, descendants: true, read: TemplateRef, isSignal: true }], exportAs: ["cngxIncrementalList"], hostDirectives: [{ directive: i1.CngxPaginate, inputs: ["cngxPageIndex", "pageIndex", "cngxPageSize", "pageSize", "total", "total", "state", "state"] }], ngImport: i0, template: "@switch (view()) {\n @case ('skeleton') {\n @if (loadingTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" />\n } @else {\n <cngx-progress\n class=\"cngx-incremental-list__progress\"\n variant=\"linear\"\n [state]=\"paginate.state()\"\n [label]=\"loadingLabel()\"\n />\n }\n }\n @case ('empty') {\n @if (emptyTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" />\n } @else {\n <cngx-empty-state class=\"cngx-incremental-list__empty\" [title]=\"emptyLabel()\" />\n }\n }\n @case ('error') {\n @if (errorTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"errorContext()\" />\n } @else {\n <div class=\"cngx-incremental-list__error\">\n <ng-container [ngTemplateOutlet]=\"builtinError\" />\n </div>\n }\n }\n @default {\n @if (virtualize()) {\n <cngx-incremental-virtualized-body\n [items]=\"items()\"\n [estimateSize]=\"estimateSize()\"\n [itemTemplate]=\"itemTemplate()\"\n [trackItem]=\"trackItem\"\n (focusEscaped)=\"handleFocusEscaped()\"\n />\n } @else {\n <ul class=\"cngx-incremental-list__items\" role=\"list\">\n @for (item of items(); track trackItem($index, item)) {\n <li class=\"cngx-incremental-list__item\">\n @if (itemTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: $index }\"\n />\n } @else {\n {{ item }}\n }\n </li>\n }\n </ul>\n }\n @if (view() === 'content+error') {\n <!-- Subsequent-page failure: keep the accumulated list above visible and\n render a reachable retry, rather than silently swallowing the error. -->\n @if (errorTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"errorContext()\" />\n } @else {\n <div class=\"cngx-incremental-list__inline-error\">\n <ng-container [ngTemplateOutlet]=\"builtinError\" />\n </div>\n }\n } @else if (exhausted()) {\n @if (endTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" />\n } @else {\n <p class=\"cngx-incremental-list__message cngx-incremental-list__end\">{{ endLabel() }}</p>\n }\n } @else {\n <ng-content select=\"[cngxIncrementalTrigger]\" />\n }\n }\n}\n\n<ng-template #builtinError>\n <p class=\"cngx-incremental-list__error-text\">{{ errorViewLabel() }}</p>\n <button type=\"button\" class=\"cngx-incremental-list__retry\" (click)=\"retryFn()\">\n {{ retryLabel() }}\n </button>\n</ng-template>\n\n<span cngxLiveRegion class=\"cngx-incremental-list__sr\">{{ statusMessage() }}</span>\n", styles: ["@layer cngx.tokens{.cngx-incremental-list{display:block;--cngx-incremental-list-item-padding: var(--cngx-space-sm, .5rem);--cngx-incremental-list-message-padding: var(--cngx-space-md, 1rem);--cngx-incremental-list-error-gap: var(--cngx-space-sm, .5rem);--cngx-incremental-list-card-padding: var(--cngx-space-md, 1rem);--cngx-incremental-list-button-padding: var(--cngx-space-xs, .25rem) var(--cngx-space-md, 1rem);color:var(--cngx-incremental-list-text, var(--cngx-color-text, oklch(.2 .01 250)))}}@layer cngx.components{@scope(.cngx-incremental-list){.cngx-incremental-list__viewport{overflow-y:auto;max-block-size:var(--cngx-incremental-list-viewport-height, 60vh)}.cngx-incremental-list__items{margin:0;padding:0;list-style:none}.cngx-incremental-list__item{padding-block:var(--cngx-incremental-list-item-padding)}.cngx-incremental-list__message{margin:0;padding:var(--cngx-incremental-list-message-padding);text-align:center;color:var( --cngx-incremental-list-message-color, var(--cngx-color-text-muted, oklch(.5 .01 250)) )}.cngx-incremental-list__error,.cngx-incremental-list__inline-error{display:flex;flex-direction:column;align-items:center;gap:var(--cngx-incremental-list-error-gap);padding:var(--cngx-incremental-list-message-padding)}.cngx-incremental-list__inline-error{border-top:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}.cngx-incremental-list__error-text{margin:0;text-align:center;color:var(--cngx-incremental-list-error-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-incremental-list__retry{font:inherit;color:var(--cngx-incremental-list-button-fg, var(--cngx-color-primary, oklch(.66 .19 50)));background:transparent;padding:var(--cngx-incremental-list-button-padding);border:1px solid var(--cngx-incremental-list-button-border, var(--cngx-color-border, oklch(.88 .005 250)));border-radius:var(--cngx-incremental-list-button-radius, var(--cngx-radius-sm, 6px));cursor:pointer}.cngx-incremental-list__retry:hover{background:color-mix(in oklch,var(--cngx-incremental-list-button-fg, var(--cngx-color-primary, oklch(.66 .19 50))) 8%,transparent)}.cngx-incremental-list__retry:focus-visible{outline:2px solid var(--cngx-incremental-list-button-fg, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-incremental-list__sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}}@scope(.cngx-incremental-list[data-skin=divided]){.cngx-incremental-list__item:not(:last-child){border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}@scope(.cngx-incremental-list[data-skin=card]){:scope{background:var(--cngx-incremental-list-surface, var(--cngx-color-surface, oklch(1 0 0)));border:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)));border-radius:var(--cngx-incremental-list-radius, var(--cngx-radius-md, 8px));padding-inline:var(--cngx-incremental-list-card-padding);overflow:hidden}.cngx-incremental-list__item:not(:last-child){border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}@scope(.cngx-incremental-list[data-skin=divided][data-virtualize]){.cngx-incremental-list__item{border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}@scope(.cngx-incremental-list[data-skin=card][data-virtualize]){.cngx-incremental-list__item{border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}}\n"], dependencies: [{ kind: "component", type: CngxProgress, selector: "cngx-progress", inputs: ["state", "progress", "variant", "showLabel", "label"] }, { kind: "component", type: CngxEmptyState, selector: "cngx-empty-state", inputs: ["title", "description", "state"] }, { kind: "directive", type: CngxLiveRegion, selector: "[cngxLiveRegion]", inputs: ["politeness", "atomic", "relevant"], exportAs: ["cngxLiveRegion"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CngxIncrementalVirtualizedBody, selector: "cngx-incremental-virtualized-body", inputs: ["items", "estimateSize", "itemTemplate", "trackItem"], outputs: ["focusEscaped"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
593
|
+
}
|
|
594
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIncrementalList, decorators: [{
|
|
595
|
+
type: Component,
|
|
596
|
+
args: [{ selector: 'cngx-incremental-list', exportAs: 'cngxIncrementalList', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [
|
|
597
|
+
CngxProgress,
|
|
598
|
+
CngxEmptyState,
|
|
599
|
+
CngxLiveRegion,
|
|
600
|
+
NgTemplateOutlet,
|
|
601
|
+
CngxIncrementalVirtualizedBody,
|
|
602
|
+
], hostDirectives: [
|
|
603
|
+
{
|
|
604
|
+
directive: CngxPaginate,
|
|
605
|
+
inputs: ['cngxPageIndex: pageIndex', 'cngxPageSize: pageSize', 'total', 'state'],
|
|
606
|
+
},
|
|
607
|
+
], providers: [
|
|
608
|
+
{ provide: CNGX_PAGINATOR_HOST, useExisting: CngxPaginate },
|
|
609
|
+
{
|
|
610
|
+
// Route the recycler's SR i18n through the same config cascade the
|
|
611
|
+
// organism uses, so a consumer localises the load-count announcement via
|
|
612
|
+
// withIncrementalListAriaLabels alongside the view-state labels. Owner
|
|
613
|
+
// split: only loaded() carries text; empty()/error()/filtered() stay
|
|
614
|
+
// silent so the organism's statusMessage live region remains the sole
|
|
615
|
+
// owner of view-state (no double-announce). The no-state recycler branch
|
|
616
|
+
// never calls filtered()/error() anyway.
|
|
617
|
+
provide: CNGX_RECYCLER_I18N,
|
|
618
|
+
useFactory: () => {
|
|
619
|
+
const config = injectIncrementalListConfig();
|
|
620
|
+
return {
|
|
621
|
+
loaded: (count, total) => config.ariaLabels.loadedMore(count, total),
|
|
622
|
+
filtered: () => '',
|
|
623
|
+
empty: () => '',
|
|
624
|
+
error: () => '',
|
|
625
|
+
};
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
], host: {
|
|
629
|
+
class: 'cngx-incremental-list',
|
|
630
|
+
'[attr.aria-busy]': 'paginate.isBusy()',
|
|
631
|
+
'[attr.data-skin]': 'skin()',
|
|
632
|
+
'[attr.data-virtualize]': "virtualize() ? '' : null",
|
|
633
|
+
}, template: "@switch (view()) {\n @case ('skeleton') {\n @if (loadingTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" />\n } @else {\n <cngx-progress\n class=\"cngx-incremental-list__progress\"\n variant=\"linear\"\n [state]=\"paginate.state()\"\n [label]=\"loadingLabel()\"\n />\n }\n }\n @case ('empty') {\n @if (emptyTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" />\n } @else {\n <cngx-empty-state class=\"cngx-incremental-list__empty\" [title]=\"emptyLabel()\" />\n }\n }\n @case ('error') {\n @if (errorTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"errorContext()\" />\n } @else {\n <div class=\"cngx-incremental-list__error\">\n <ng-container [ngTemplateOutlet]=\"builtinError\" />\n </div>\n }\n }\n @default {\n @if (virtualize()) {\n <cngx-incremental-virtualized-body\n [items]=\"items()\"\n [estimateSize]=\"estimateSize()\"\n [itemTemplate]=\"itemTemplate()\"\n [trackItem]=\"trackItem\"\n (focusEscaped)=\"handleFocusEscaped()\"\n />\n } @else {\n <ul class=\"cngx-incremental-list__items\" role=\"list\">\n @for (item of items(); track trackItem($index, item)) {\n <li class=\"cngx-incremental-list__item\">\n @if (itemTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: $index }\"\n />\n } @else {\n {{ item }}\n }\n </li>\n }\n </ul>\n }\n @if (view() === 'content+error') {\n <!-- Subsequent-page failure: keep the accumulated list above visible and\n render a reachable retry, rather than silently swallowing the error. -->\n @if (errorTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"errorContext()\" />\n } @else {\n <div class=\"cngx-incremental-list__inline-error\">\n <ng-container [ngTemplateOutlet]=\"builtinError\" />\n </div>\n }\n } @else if (exhausted()) {\n @if (endTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" />\n } @else {\n <p class=\"cngx-incremental-list__message cngx-incremental-list__end\">{{ endLabel() }}</p>\n }\n } @else {\n <ng-content select=\"[cngxIncrementalTrigger]\" />\n }\n }\n}\n\n<ng-template #builtinError>\n <p class=\"cngx-incremental-list__error-text\">{{ errorViewLabel() }}</p>\n <button type=\"button\" class=\"cngx-incremental-list__retry\" (click)=\"retryFn()\">\n {{ retryLabel() }}\n </button>\n</ng-template>\n\n<span cngxLiveRegion class=\"cngx-incremental-list__sr\">{{ statusMessage() }}</span>\n", styles: ["@layer cngx.tokens{.cngx-incremental-list{display:block;--cngx-incremental-list-item-padding: var(--cngx-space-sm, .5rem);--cngx-incremental-list-message-padding: var(--cngx-space-md, 1rem);--cngx-incremental-list-error-gap: var(--cngx-space-sm, .5rem);--cngx-incremental-list-card-padding: var(--cngx-space-md, 1rem);--cngx-incremental-list-button-padding: var(--cngx-space-xs, .25rem) var(--cngx-space-md, 1rem);color:var(--cngx-incremental-list-text, var(--cngx-color-text, oklch(.2 .01 250)))}}@layer cngx.components{@scope(.cngx-incremental-list){.cngx-incremental-list__viewport{overflow-y:auto;max-block-size:var(--cngx-incremental-list-viewport-height, 60vh)}.cngx-incremental-list__items{margin:0;padding:0;list-style:none}.cngx-incremental-list__item{padding-block:var(--cngx-incremental-list-item-padding)}.cngx-incremental-list__message{margin:0;padding:var(--cngx-incremental-list-message-padding);text-align:center;color:var( --cngx-incremental-list-message-color, var(--cngx-color-text-muted, oklch(.5 .01 250)) )}.cngx-incremental-list__error,.cngx-incremental-list__inline-error{display:flex;flex-direction:column;align-items:center;gap:var(--cngx-incremental-list-error-gap);padding:var(--cngx-incremental-list-message-padding)}.cngx-incremental-list__inline-error{border-top:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}.cngx-incremental-list__error-text{margin:0;text-align:center;color:var(--cngx-incremental-list-error-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-incremental-list__retry{font:inherit;color:var(--cngx-incremental-list-button-fg, var(--cngx-color-primary, oklch(.66 .19 50)));background:transparent;padding:var(--cngx-incremental-list-button-padding);border:1px solid var(--cngx-incremental-list-button-border, var(--cngx-color-border, oklch(.88 .005 250)));border-radius:var(--cngx-incremental-list-button-radius, var(--cngx-radius-sm, 6px));cursor:pointer}.cngx-incremental-list__retry:hover{background:color-mix(in oklch,var(--cngx-incremental-list-button-fg, var(--cngx-color-primary, oklch(.66 .19 50))) 8%,transparent)}.cngx-incremental-list__retry:focus-visible{outline:2px solid var(--cngx-incremental-list-button-fg, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-incremental-list__sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}}@scope(.cngx-incremental-list[data-skin=divided]){.cngx-incremental-list__item:not(:last-child){border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}@scope(.cngx-incremental-list[data-skin=card]){:scope{background:var(--cngx-incremental-list-surface, var(--cngx-color-surface, oklch(1 0 0)));border:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)));border-radius:var(--cngx-incremental-list-radius, var(--cngx-radius-md, 8px));padding-inline:var(--cngx-incremental-list-card-padding);overflow:hidden}.cngx-incremental-list__item:not(:last-child){border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}@scope(.cngx-incremental-list[data-skin=divided][data-virtualize]){.cngx-incremental-list__item{border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}@scope(.cngx-incremental-list[data-skin=card][data-virtualize]){.cngx-incremental-list__item{border-bottom:1px solid var(--cngx-incremental-list-divider, var(--cngx-color-border, oklch(.88 .005 250)))}}}\n"] }]
|
|
634
|
+
}], ctorParameters: () => [], propDecorators: { skin: [{ type: i0.Input, args: [{ isSignal: true, alias: "skin", required: false }] }], virtualize: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualize", required: false }] }], estimateSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "estimateSize", required: false }] }], pageIndexChange: [{ type: i0.Output, args: ["pageIndexChange"] }], pageSizeChange: [{ type: i0.Output, args: ["pageSizeChange"] }], retry: [{ type: i0.Output, args: ["retry"] }], trackBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBy", required: false }] }], itemSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxIncrementalItem), { ...{ read: TemplateRef }, isSignal: true }] }], emptySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxIncrementalEmpty), { ...{ read: TemplateRef }, isSignal: true }] }], errorSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxIncrementalError), { ...{ read: TemplateRef }, isSignal: true }] }], endSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxIncrementalEnd), { ...{ read: TemplateRef }, isSignal: true }] }], loadingSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxIncrementalLoading), { ...{ read: TemplateRef }, isSignal: true }] }] } });
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @module @cngx/ui/collection
|
|
638
|
+
*/
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Generated bundle index. Do not edit.
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
export { CNGX_INCREMENTAL_LIST_CONFIG, CNGX_INCREMENTAL_LIST_DEFAULTS, CngxIncrementalEmpty, CngxIncrementalEnd, CngxIncrementalError, CngxIncrementalItem, CngxIncrementalList, CngxIncrementalLoading, injectIncrementalListConfig, provideIncrementalListConfig, provideIncrementalListConfigAt, withIncrementalListAriaLabels, withIncrementalListTemplates };
|
|
645
|
+
//# sourceMappingURL=cngx-ui-collection.mjs.map
|