@ng-desktop/platform 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/fesm2022/bridge.d.ts +5 -0
- package/fesm2022/bridge.js +1 -0
- package/fesm2022/css-style-parser.d.ts +16 -3
- package/fesm2022/css-style-parser.js +534 -104
- package/fesm2022/ecosystem-compat.d.ts +3 -5
- package/fesm2022/ecosystem-compat.js +16 -25
- package/fesm2022/index.d.ts +3 -1
- package/fesm2022/index.js +3 -1
- package/fesm2022/native-directives.d.ts +5 -2
- package/fesm2022/native-directives.js +17 -11
- package/fesm2022/native-element.d.ts +2 -0
- package/fesm2022/native-element.js +2 -0
- package/fesm2022/native-renderer.d.ts +4 -1
- package/fesm2022/native-renderer.js +88 -6
- package/fesm2022/system-providers.js +2 -1
- package/fesm2022/virtual-grid.component.d.ts +68 -0
- package/fesm2022/virtual-grid.component.js +324 -0
- package/fesm2022/virtual-layout.d.ts +71 -0
- package/fesm2022/virtual-layout.js +279 -0
- package/fesm2022/virtual-list.component.d.ts +25 -13
- package/fesm2022/virtual-list.component.js +156 -73
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TemplateRef } from '@angular/core';
|
|
2
|
+
import { type VirtualGridSliceRange } from './virtual-layout';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/** Template context provided to each rendered cell inside `<ng-virtual-grid>`. */
|
|
5
|
+
export interface NativeVirtualGridItemContext<T> {
|
|
6
|
+
$implicit: T;
|
|
7
|
+
index: number;
|
|
8
|
+
row: number;
|
|
9
|
+
col: number;
|
|
10
|
+
}
|
|
11
|
+
/** Internal materialized 2D cell entry with row/column placement and tracking key. */
|
|
12
|
+
export interface NativeVirtualGridEntry<T> {
|
|
13
|
+
item: T;
|
|
14
|
+
index: number;
|
|
15
|
+
row: number;
|
|
16
|
+
col: number;
|
|
17
|
+
key: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 2D virtualized native grid rendering only visible rows + overscan inside `<ng-scroll>` + `<ng-grid>`.
|
|
21
|
+
* Supports responsive column sizing from viewport width as well as variable row heights via `FenwickOffsetTree`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class NativeVirtualGridComponent<T = unknown> {
|
|
24
|
+
readonly items: import("@angular/core").InputSignal<readonly T[]>;
|
|
25
|
+
readonly rowHeight: import("@angular/core").InputSignal<number>;
|
|
26
|
+
readonly minColumnWidth: import("@angular/core").InputSignal<number>;
|
|
27
|
+
readonly columns: import("@angular/core").InputSignal<number | null>;
|
|
28
|
+
readonly viewportHeight: import("@angular/core").InputSignal<number>;
|
|
29
|
+
readonly viewportWidth: import("@angular/core").InputSignal<number>;
|
|
30
|
+
readonly rowGap: import("@angular/core").InputSignal<number>;
|
|
31
|
+
readonly columnGap: import("@angular/core").InputSignal<number>;
|
|
32
|
+
readonly overscanRows: import("@angular/core").InputSignal<number>;
|
|
33
|
+
readonly gridClass: import("@angular/core").InputSignal<string>;
|
|
34
|
+
readonly gridId: import("@angular/core").InputSignal<string>;
|
|
35
|
+
readonly rowHeightResolver: import("@angular/core").InputSignal<((rowIndex: number) => number) | null>;
|
|
36
|
+
readonly trackBy: import("@angular/core").InputSignal<(index: number, item: T) => unknown>;
|
|
37
|
+
readonly itemTemplateInput: import("@angular/core").InputSignal<TemplateRef<NativeVirtualGridItemContext<T>> | null>;
|
|
38
|
+
readonly projectedTemplate: import("@angular/core").Signal<TemplateRef<NativeVirtualGridItemContext<T>> | undefined>;
|
|
39
|
+
readonly rangeChange: import("@angular/core").OutputEmitterRef<VirtualGridSliceRange>;
|
|
40
|
+
readonly scrollBottom: import("@angular/core").OutputEmitterRef<void>;
|
|
41
|
+
private readonly renderer;
|
|
42
|
+
private readonly scrollHost;
|
|
43
|
+
readonly scrollTop: import("@angular/core").WritableSignal<number>;
|
|
44
|
+
readonly measuredWidth: import("@angular/core").WritableSignal<number | null>;
|
|
45
|
+
readonly measuredHeight: import("@angular/core").WritableSignal<number | null>;
|
|
46
|
+
readonly scrollToAttr: import("@angular/core").WritableSignal<string | undefined>;
|
|
47
|
+
private readonly rowTree;
|
|
48
|
+
private readonly rowOverrides;
|
|
49
|
+
private readonly measureRevision;
|
|
50
|
+
readonly resolvedTemplate: import("@angular/core").Signal<TemplateRef<NativeVirtualGridItemContext<T>> | null>;
|
|
51
|
+
readonly effectiveWidth: import("@angular/core").Signal<number>;
|
|
52
|
+
readonly effectiveHeight: import("@angular/core").Signal<number>;
|
|
53
|
+
/** Builds/updates the Fenwick row-offset tree only when layout geometry or items change, not on scroll. */
|
|
54
|
+
private readonly rowHeightTreeState;
|
|
55
|
+
readonly range: import("@angular/core").Signal<VirtualGridSliceRange>;
|
|
56
|
+
readonly visibleEntries: import("@angular/core").Signal<readonly NativeVirtualGridEntry<T>[]>;
|
|
57
|
+
private lastEmittedRangeKey;
|
|
58
|
+
constructor();
|
|
59
|
+
/** Overrides the height of grid row `rowIndex` in O(log R). */
|
|
60
|
+
measureRowHeight(rowIndex: number, height: number): void;
|
|
61
|
+
/** Clears all dynamically measured row height overrides. */
|
|
62
|
+
resetMeasuredRows(): void;
|
|
63
|
+
/** Scrolls the native grid viewport to bring item `index` into view. */
|
|
64
|
+
scrollToIndex(index: number): void;
|
|
65
|
+
onNativeScroll(event: unknown): void;
|
|
66
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NativeVirtualGridComponent<any>, never>;
|
|
67
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NativeVirtualGridComponent<any>, "ng-virtual-grid", never, { "items": { "alias": "items"; "required": false; "isSignal": true; }; "rowHeight": { "alias": "rowHeight"; "required": false; "isSignal": true; }; "minColumnWidth": { "alias": "minColumnWidth"; "required": false; "isSignal": true; }; "columns": { "alias": "columns"; "required": false; "isSignal": true; }; "viewportHeight": { "alias": "viewportHeight"; "required": false; "isSignal": true; }; "viewportWidth": { "alias": "viewportWidth"; "required": false; "isSignal": true; }; "rowGap": { "alias": "rowGap"; "required": false; "isSignal": true; }; "columnGap": { "alias": "columnGap"; "required": false; "isSignal": true; }; "overscanRows": { "alias": "overscanRows"; "required": false; "isSignal": true; }; "gridClass": { "alias": "gridClass"; "required": false; "isSignal": true; }; "gridId": { "alias": "gridId"; "required": false; "isSignal": true; }; "rowHeightResolver": { "alias": "rowHeightResolver"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; "itemTemplateInput": { "alias": "itemTemplate"; "required": false; "isSignal": true; }; }, { "rangeChange": "rangeChange"; "scrollBottom": "scrollBottom"; }, ["projectedTemplate"], ["[ngVirtualEmpty]"], true, never>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import { Component, computed, contentChild, effect, inject, input, output, Renderer2, signal, TemplateRef, viewChild, } from '@angular/core';
|
|
3
|
+
import { NativeContainerDirective, NativeElementDirective, NativeTextWidgetDirective, } from './native-directives.js';
|
|
4
|
+
import { computeVirtualGridSliceRange, FenwickOffsetTree, } from './virtual-layout.js';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* 2D virtualized native grid rendering only visible rows + overscan inside `<ng-scroll>` + `<ng-grid>`.
|
|
8
|
+
* Supports responsive column sizing from viewport width as well as variable row heights via `FenwickOffsetTree`.
|
|
9
|
+
*/
|
|
10
|
+
export class NativeVirtualGridComponent {
|
|
11
|
+
items = input([], /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
13
|
+
rowHeight = input(200, /* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [{ debugName: "rowHeight" }] : /* istanbul ignore next */ []));
|
|
15
|
+
minColumnWidth = input(200, /* @ts-ignore */
|
|
16
|
+
...(ngDevMode ? [{ debugName: "minColumnWidth" }] : /* istanbul ignore next */ []));
|
|
17
|
+
columns = input(null, /* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
19
|
+
viewportHeight = input(480, /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "viewportHeight" }] : /* istanbul ignore next */ []));
|
|
21
|
+
viewportWidth = input(960, /* @ts-ignore */
|
|
22
|
+
...(ngDevMode ? [{ debugName: "viewportWidth" }] : /* istanbul ignore next */ []));
|
|
23
|
+
rowGap = input(12, /* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [{ debugName: "rowGap" }] : /* istanbul ignore next */ []));
|
|
25
|
+
columnGap = input(12, /* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "columnGap" }] : /* istanbul ignore next */ []));
|
|
27
|
+
overscanRows = input(2, /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "overscanRows" }] : /* istanbul ignore next */ []));
|
|
29
|
+
gridClass = input('', /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "gridClass" }] : /* istanbul ignore next */ []));
|
|
31
|
+
gridId = input('', /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "gridId" }] : /* istanbul ignore next */ []));
|
|
33
|
+
rowHeightResolver = input(null, /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "rowHeightResolver" }] : /* istanbul ignore next */ []));
|
|
35
|
+
trackBy = input((index, _item) => index, /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "trackBy" }] : /* istanbul ignore next */ []));
|
|
37
|
+
itemTemplateInput = input(null, { ...(ngDevMode ? { debugName: "itemTemplateInput" } : /* istanbul ignore next */ {}), alias: 'itemTemplate' });
|
|
38
|
+
projectedTemplate = contentChild(TemplateRef, /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "projectedTemplate" }] : /* istanbul ignore next */ []));
|
|
40
|
+
rangeChange = output();
|
|
41
|
+
scrollBottom = output();
|
|
42
|
+
renderer = inject(Renderer2);
|
|
43
|
+
scrollHost = viewChild('scrollHost', /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "scrollHost" }] : /* istanbul ignore next */ []));
|
|
45
|
+
scrollTop = signal(0, /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "scrollTop" }] : /* istanbul ignore next */ []));
|
|
47
|
+
measuredWidth = signal(null, /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "measuredWidth" }] : /* istanbul ignore next */ []));
|
|
49
|
+
measuredHeight = signal(null, /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "measuredHeight" }] : /* istanbul ignore next */ []));
|
|
51
|
+
scrollToAttr = signal(undefined, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "scrollToAttr" }] : /* istanbul ignore next */ []));
|
|
53
|
+
rowTree = new FenwickOffsetTree(0, 200);
|
|
54
|
+
rowOverrides = new Map();
|
|
55
|
+
measureRevision = signal(0, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "measureRevision" }] : /* istanbul ignore next */ []));
|
|
57
|
+
resolvedTemplate = computed(() => this.itemTemplateInput() ?? this.projectedTemplate() ?? null, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "resolvedTemplate" }] : /* istanbul ignore next */ []));
|
|
59
|
+
effectiveWidth = computed(() => this.measuredWidth() ?? this.viewportWidth(), /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "effectiveWidth" }] : /* istanbul ignore next */ []));
|
|
61
|
+
effectiveHeight = computed(() => this.measuredHeight() ?? this.viewportHeight(), /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "effectiveHeight" }] : /* istanbul ignore next */ []));
|
|
63
|
+
/** Builds/updates the Fenwick row-offset tree only when layout geometry or items change, not on scroll. */
|
|
64
|
+
rowHeightTreeState = computed(() => {
|
|
65
|
+
const source = this.items();
|
|
66
|
+
const resolver = this.rowHeightResolver();
|
|
67
|
+
this.measureRevision();
|
|
68
|
+
const baseRowHeight = Math.max(1, this.rowHeight());
|
|
69
|
+
const effWidth = this.effectiveWidth();
|
|
70
|
+
const effHeight = this.effectiveHeight();
|
|
71
|
+
const geometrySlice = computeVirtualGridSliceRange({
|
|
72
|
+
totalItems: source.length,
|
|
73
|
+
scrollTop: 0,
|
|
74
|
+
viewportHeight: effHeight,
|
|
75
|
+
viewportWidth: effWidth,
|
|
76
|
+
rowHeight: baseRowHeight,
|
|
77
|
+
minColumnWidth: this.minColumnWidth(),
|
|
78
|
+
columns: this.columns(),
|
|
79
|
+
rowGap: this.rowGap(),
|
|
80
|
+
columnGap: this.columnGap(),
|
|
81
|
+
overscanRows: this.overscanRows(),
|
|
82
|
+
});
|
|
83
|
+
if (resolver === null && this.rowOverrides.size === 0) {
|
|
84
|
+
return {
|
|
85
|
+
tree: null,
|
|
86
|
+
baseRowHeight,
|
|
87
|
+
columns: geometrySlice.columns,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const totalRows = geometrySlice.totalRows;
|
|
91
|
+
const overrides = new Map();
|
|
92
|
+
if (resolver !== null) {
|
|
93
|
+
for (let r = 0; r < totalRows; r += 1) {
|
|
94
|
+
overrides.set(r, resolver(r));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const [r, h] of this.rowOverrides) {
|
|
98
|
+
if (r >= 0 && r < totalRows) {
|
|
99
|
+
overrides.set(r, h);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
this.rowTree.reset(totalRows, baseRowHeight, overrides);
|
|
103
|
+
return { tree: this.rowTree, baseRowHeight, columns: geometrySlice.columns };
|
|
104
|
+
}, /* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [{ debugName: "rowHeightTreeState" }] : /* istanbul ignore next */ []));
|
|
106
|
+
range = computed(() => {
|
|
107
|
+
const source = this.items();
|
|
108
|
+
const { tree, baseRowHeight, columns } = this.rowHeightTreeState();
|
|
109
|
+
return computeVirtualGridSliceRange({
|
|
110
|
+
totalItems: source.length,
|
|
111
|
+
scrollTop: this.scrollTop(),
|
|
112
|
+
viewportHeight: this.effectiveHeight(),
|
|
113
|
+
viewportWidth: this.effectiveWidth(),
|
|
114
|
+
rowHeight: baseRowHeight,
|
|
115
|
+
minColumnWidth: this.minColumnWidth(),
|
|
116
|
+
columns,
|
|
117
|
+
rowGap: this.rowGap(),
|
|
118
|
+
columnGap: this.columnGap(),
|
|
119
|
+
overscanRows: this.overscanRows(),
|
|
120
|
+
rowHeights: tree ?? undefined,
|
|
121
|
+
});
|
|
122
|
+
}, /* @ts-ignore */
|
|
123
|
+
...(ngDevMode ? [{ debugName: "range" }] : /* istanbul ignore next */ []));
|
|
124
|
+
visibleEntries = computed(() => {
|
|
125
|
+
const source = this.items();
|
|
126
|
+
const { startIndex, endIndex, columns } = this.range();
|
|
127
|
+
const trackFn = this.trackBy();
|
|
128
|
+
const entries = [];
|
|
129
|
+
for (let idx = startIndex; idx < endIndex; idx += 1) {
|
|
130
|
+
const item = source[idx];
|
|
131
|
+
const localIdx = idx - startIndex;
|
|
132
|
+
const row = Math.floor(localIdx / columns);
|
|
133
|
+
const col = localIdx % columns;
|
|
134
|
+
entries.push({ item, index: idx, row, col, key: trackFn(idx, item) });
|
|
135
|
+
}
|
|
136
|
+
return entries;
|
|
137
|
+
}, /* @ts-ignore */
|
|
138
|
+
...(ngDevMode ? [{ debugName: "visibleEntries" }] : /* istanbul ignore next */ []));
|
|
139
|
+
lastEmittedRangeKey = '';
|
|
140
|
+
constructor() {
|
|
141
|
+
effect(() => {
|
|
142
|
+
const next = this.range();
|
|
143
|
+
const key = `${next.startIndex}:${next.endIndex}:${next.columns}:${next.totalItems}:${next.topSpacerHeight}:${next.bottomSpacerHeight}`;
|
|
144
|
+
if (key !== this.lastEmittedRangeKey) {
|
|
145
|
+
this.lastEmittedRangeKey = key;
|
|
146
|
+
this.rangeChange.emit(next);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/** Overrides the height of grid row `rowIndex` in O(log R). */
|
|
151
|
+
measureRowHeight(rowIndex, height) {
|
|
152
|
+
const row = Math.floor(rowIndex);
|
|
153
|
+
if (!Number.isFinite(rowIndex) || row < 0 || !Number.isFinite(height)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const clamped = Math.max(1, height);
|
|
157
|
+
if (this.rowOverrides.get(row) !== clamped) {
|
|
158
|
+
this.rowOverrides.set(row, clamped);
|
|
159
|
+
this.measureRevision.update((rev) => rev + 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Clears all dynamically measured row height overrides. */
|
|
163
|
+
resetMeasuredRows() {
|
|
164
|
+
if (this.rowOverrides.size === 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.rowOverrides.clear();
|
|
168
|
+
this.measureRevision.update((rev) => rev + 1);
|
|
169
|
+
}
|
|
170
|
+
/** Scrolls the native grid viewport to bring item `index` into view. */
|
|
171
|
+
scrollToIndex(index) {
|
|
172
|
+
const safeTotal = this.items().length;
|
|
173
|
+
if (safeTotal === 0) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const clampedIdx = Math.max(0, Math.min(safeTotal - 1, Math.floor(index)));
|
|
177
|
+
const slice = this.range();
|
|
178
|
+
const targetRow = Math.floor(clampedIdx / Math.max(1, slice.columns));
|
|
179
|
+
const rowGap = Math.max(0, this.rowGap());
|
|
180
|
+
const y = this.rowHeightResolver() !== null || this.rowOverrides.size > 0
|
|
181
|
+
? Math.round(this.rowTree.offsetOf(targetRow) + targetRow * rowGap)
|
|
182
|
+
: Math.round(targetRow * (Math.max(1, this.rowHeight()) + rowGap));
|
|
183
|
+
const coords = `0,${y}`;
|
|
184
|
+
const sameCoords = this.scrollToAttr() === coords;
|
|
185
|
+
this.scrollTop.set(y);
|
|
186
|
+
this.scrollToAttr.set(coords);
|
|
187
|
+
if (sameCoords) {
|
|
188
|
+
const hostEl = this.scrollHost()?.nativeElement;
|
|
189
|
+
if (hostEl) {
|
|
190
|
+
this.renderer.setAttribute(hostEl, 'scroll-to', coords);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
onNativeScroll(event) {
|
|
195
|
+
if (!event || typeof event !== 'object') {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const obj = event;
|
|
199
|
+
const target = obj['target'] && typeof obj['target'] === 'object'
|
|
200
|
+
? obj['target']
|
|
201
|
+
: undefined;
|
|
202
|
+
const top = typeof obj['scrollTop'] === 'number' ? obj['scrollTop'] : target?.['scrollTop'];
|
|
203
|
+
if (typeof top === 'number' && Number.isFinite(top)) {
|
|
204
|
+
this.scrollTop.set(Math.max(0, top));
|
|
205
|
+
}
|
|
206
|
+
const width = typeof obj['clientWidth'] === 'number' ? obj['clientWidth'] : target?.['clientWidth'];
|
|
207
|
+
if (typeof width === 'number' && Number.isFinite(width) && width > 0) {
|
|
208
|
+
this.measuredWidth.set(width);
|
|
209
|
+
}
|
|
210
|
+
const height = typeof obj['clientHeight'] === 'number' ? obj['clientHeight'] : target?.['clientHeight'];
|
|
211
|
+
if (typeof height === 'number' && Number.isFinite(height) && height > 0) {
|
|
212
|
+
this.measuredHeight.set(height);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeVirtualGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
216
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.0", type: NativeVirtualGridComponent, isStandalone: true, selector: "ng-virtual-grid", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, rowHeight: { classPropertyName: "rowHeight", publicName: "rowHeight", isSignal: true, isRequired: false, transformFunction: null }, minColumnWidth: { classPropertyName: "minColumnWidth", publicName: "minColumnWidth", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, viewportHeight: { classPropertyName: "viewportHeight", publicName: "viewportHeight", isSignal: true, isRequired: false, transformFunction: null }, viewportWidth: { classPropertyName: "viewportWidth", publicName: "viewportWidth", isSignal: true, isRequired: false, transformFunction: null }, rowGap: { classPropertyName: "rowGap", publicName: "rowGap", isSignal: true, isRequired: false, transformFunction: null }, columnGap: { classPropertyName: "columnGap", publicName: "columnGap", isSignal: true, isRequired: false, transformFunction: null }, overscanRows: { classPropertyName: "overscanRows", publicName: "overscanRows", isSignal: true, isRequired: false, transformFunction: null }, gridClass: { classPropertyName: "gridClass", publicName: "gridClass", isSignal: true, isRequired: false, transformFunction: null }, gridId: { classPropertyName: "gridId", publicName: "gridId", isSignal: true, isRequired: false, transformFunction: null }, rowHeightResolver: { classPropertyName: "rowHeightResolver", publicName: "rowHeightResolver", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null }, itemTemplateInput: { classPropertyName: "itemTemplateInput", publicName: "itemTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { rangeChange: "rangeChange", scrollBottom: "scrollBottom" }, queries: [{ propertyName: "projectedTemplate", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "scrollHost", first: true, predicate: ["scrollHost"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
217
|
+
<ng-scroll
|
|
218
|
+
#scrollHost
|
|
219
|
+
[hexpand]="true"
|
|
220
|
+
[vexpand]="true"
|
|
221
|
+
[min-height]="viewportHeight()"
|
|
222
|
+
[scroll-to]="scrollToAttr()"
|
|
223
|
+
(scroll)="onNativeScroll($event)"
|
|
224
|
+
(scrollBottom)="scrollBottom.emit()"
|
|
225
|
+
>
|
|
226
|
+
<ng-box orientation="vertical" [spacing]="0" [hexpand]="true">
|
|
227
|
+
@if (range().topSpacerHeight > 0) {
|
|
228
|
+
<ng-box [height]="range().topSpacerHeight"></ng-box>
|
|
229
|
+
}
|
|
230
|
+
@if (items().length === 0) {
|
|
231
|
+
<ng-content select="[ngVirtualEmpty]"></ng-content>
|
|
232
|
+
} @else {
|
|
233
|
+
<ng-grid
|
|
234
|
+
[attr.id]="gridId() || null"
|
|
235
|
+
[class]="gridClass()"
|
|
236
|
+
[columns]="range().columns"
|
|
237
|
+
[row-spacing]="rowGap()"
|
|
238
|
+
[column-spacing]="columnGap()"
|
|
239
|
+
[hexpand]="true"
|
|
240
|
+
>
|
|
241
|
+
@for (entry of visibleEntries(); track entry.key) {
|
|
242
|
+
@if (resolvedTemplate(); as tpl) {
|
|
243
|
+
<ng-container
|
|
244
|
+
[ngTemplateOutlet]="tpl"
|
|
245
|
+
[ngTemplateOutletContext]="{
|
|
246
|
+
$implicit: entry.item,
|
|
247
|
+
index: entry.index,
|
|
248
|
+
row: entry.row,
|
|
249
|
+
col: entry.col,
|
|
250
|
+
}"
|
|
251
|
+
></ng-container>
|
|
252
|
+
} @else {
|
|
253
|
+
<ng-label [text]="'' + entry.item"></ng-label>
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
</ng-grid>
|
|
257
|
+
}
|
|
258
|
+
@if (range().bottomSpacerHeight > 0) {
|
|
259
|
+
<ng-box [height]="range().bottomSpacerHeight"></ng-box>
|
|
260
|
+
}
|
|
261
|
+
</ng-box>
|
|
262
|
+
</ng-scroll>
|
|
263
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NativeElementDirective, selector: "ng-window,adw-window,ng-dialog,gtk-dialog,adw-dialog,ng-header-bar,adw-header-bar,gtk-header-bar,ng-scroll,gtk-scrolled-window,ng-box,gtk-box,ng-grid,gtk-grid,ng-separator,gtk-separator,ng-button,gtk-button,ng-label,gtk-label,ng-entry,gtk-entry,ng-switch,gtk-switch,ng-checkbox,ng-check,ng-check-button,gtk-check-button,ng-slider,ng-scale,gtk-scale,ng-select,ng-dropdown,gtk-dropdown,gtk-drop-down,ng-image,adw-image,gtk-picture,ng-picture,ng-level-bar,gtk-level-bar,ng-flow,ng-flow-box,gtk-flow-box,ng-spinner,gtk-spinner,ng-progress-bar,gtk-progress-bar,ng-paned,gtk-paned,ng-stack,gtk-stack,adw-navigation-view,ng-expander,gtk-expander,ng-text-view,gtk-text-view,ng-password-entry,gtk-password-entry,ng-spin-button,gtk-spin-button,ng-search-entry,gtk-search-entry,ng-clamp,adw-clamp,ng-list,ng-table,gtk-list-box,gtk-list-view,ng-popover,gtk-popover,ng-menu,adw-entry-row,adw-password-entry-row,adw-switch-row,adw-combo-row,adw-spin-row", inputs: ["hexpand", "vexpand", "halign", "valign", "width", "height", "min-width", "min-height", "margin", "margin-top", "margin-bottom", "margin-start", "margin-end", "visible", "sensitive", "disabled", "tooltip", "event-mask", "drop-target", "col", "row"] }, { kind: "directive", type: NativeContainerDirective, selector: "ng-box,gtk-box,ng-grid,gtk-grid,ng-flow,ng-flow-box,gtk-flow-box,ng-paned,gtk-paned,ng-scroll,gtk-scrolled-window,ng-stack,gtk-stack,adw-navigation-view,ng-expander,gtk-expander,ng-clamp,adw-clamp,ng-separator,gtk-separator", inputs: ["orientation", "spacing", "gap", "row-spacing", "column-spacing", "min-children", "max-children", "min-per-row", "max-per-row", "columns", "homogeneous", "position", "visible-child", "active-page", "transition", "transition-type", "label", "title", "expanded", "open", "max-size", "maximum-size", "scroll-to", "scroll-anchor"] }, { kind: "directive", type: NativeTextWidgetDirective, selector: "ng-button,gtk-button,ng-label,gtk-label", inputs: ["label", "text", "wrap", "selectable", "ellipsize"] }] });
|
|
264
|
+
}
|
|
265
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeVirtualGridComponent, decorators: [{
|
|
266
|
+
type: Component,
|
|
267
|
+
args: [{
|
|
268
|
+
selector: 'ng-virtual-grid',
|
|
269
|
+
imports: [
|
|
270
|
+
NgTemplateOutlet,
|
|
271
|
+
NativeElementDirective,
|
|
272
|
+
NativeContainerDirective,
|
|
273
|
+
NativeTextWidgetDirective,
|
|
274
|
+
],
|
|
275
|
+
template: `
|
|
276
|
+
<ng-scroll
|
|
277
|
+
#scrollHost
|
|
278
|
+
[hexpand]="true"
|
|
279
|
+
[vexpand]="true"
|
|
280
|
+
[min-height]="viewportHeight()"
|
|
281
|
+
[scroll-to]="scrollToAttr()"
|
|
282
|
+
(scroll)="onNativeScroll($event)"
|
|
283
|
+
(scrollBottom)="scrollBottom.emit()"
|
|
284
|
+
>
|
|
285
|
+
<ng-box orientation="vertical" [spacing]="0" [hexpand]="true">
|
|
286
|
+
@if (range().topSpacerHeight > 0) {
|
|
287
|
+
<ng-box [height]="range().topSpacerHeight"></ng-box>
|
|
288
|
+
}
|
|
289
|
+
@if (items().length === 0) {
|
|
290
|
+
<ng-content select="[ngVirtualEmpty]"></ng-content>
|
|
291
|
+
} @else {
|
|
292
|
+
<ng-grid
|
|
293
|
+
[attr.id]="gridId() || null"
|
|
294
|
+
[class]="gridClass()"
|
|
295
|
+
[columns]="range().columns"
|
|
296
|
+
[row-spacing]="rowGap()"
|
|
297
|
+
[column-spacing]="columnGap()"
|
|
298
|
+
[hexpand]="true"
|
|
299
|
+
>
|
|
300
|
+
@for (entry of visibleEntries(); track entry.key) {
|
|
301
|
+
@if (resolvedTemplate(); as tpl) {
|
|
302
|
+
<ng-container
|
|
303
|
+
[ngTemplateOutlet]="tpl"
|
|
304
|
+
[ngTemplateOutletContext]="{
|
|
305
|
+
$implicit: entry.item,
|
|
306
|
+
index: entry.index,
|
|
307
|
+
row: entry.row,
|
|
308
|
+
col: entry.col,
|
|
309
|
+
}"
|
|
310
|
+
></ng-container>
|
|
311
|
+
} @else {
|
|
312
|
+
<ng-label [text]="'' + entry.item"></ng-label>
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
</ng-grid>
|
|
316
|
+
}
|
|
317
|
+
@if (range().bottomSpacerHeight > 0) {
|
|
318
|
+
<ng-box [height]="range().bottomSpacerHeight"></ng-box>
|
|
319
|
+
}
|
|
320
|
+
</ng-box>
|
|
321
|
+
</ng-scroll>
|
|
322
|
+
`,
|
|
323
|
+
}]
|
|
324
|
+
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], rowHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowHeight", required: false }] }], minColumnWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minColumnWidth", required: false }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], viewportHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewportHeight", required: false }] }], viewportWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewportWidth", required: false }] }], rowGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowGap", required: false }] }], columnGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnGap", required: false }] }], overscanRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "overscanRows", required: false }] }], gridClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "gridClass", required: false }] }], gridId: [{ type: i0.Input, args: [{ isSignal: true, alias: "gridId", required: false }] }], rowHeightResolver: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowHeightResolver", required: false }] }], trackBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBy", required: false }] }], itemTemplateInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemTemplate", required: false }] }], projectedTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], rangeChange: [{ type: i0.Output, args: ["rangeChange"] }], scrollBottom: [{ type: i0.Output, args: ["scrollBottom"] }], scrollHost: [{ type: i0.ViewChild, args: ['scrollHost', { isSignal: true }] }] } });
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Inclusive start / exclusive end index range and spacer heights for a virtualized viewport. */
|
|
2
|
+
export interface VirtualSliceRange {
|
|
3
|
+
startIndex: number;
|
|
4
|
+
endIndex: number;
|
|
5
|
+
totalItems: number;
|
|
6
|
+
topSpacerHeight: number;
|
|
7
|
+
bottomSpacerHeight: number;
|
|
8
|
+
}
|
|
9
|
+
/** Input parameters for 2D responsive virtualized grid slicing. */
|
|
10
|
+
export interface VirtualGridSliceOptions {
|
|
11
|
+
totalItems: number;
|
|
12
|
+
scrollTop: number;
|
|
13
|
+
viewportHeight: number;
|
|
14
|
+
viewportWidth: number;
|
|
15
|
+
rowHeight: number;
|
|
16
|
+
minColumnWidth?: number;
|
|
17
|
+
columns?: number | null;
|
|
18
|
+
rowGap?: number;
|
|
19
|
+
columnGap?: number;
|
|
20
|
+
overscanRows?: number;
|
|
21
|
+
rowHeights?: FenwickOffsetTree | null;
|
|
22
|
+
}
|
|
23
|
+
/** Inclusive start / exclusive end slice metadata for a 2D virtualized grid viewport. */
|
|
24
|
+
export interface VirtualGridSliceRange {
|
|
25
|
+
startIndex: number;
|
|
26
|
+
endIndex: number;
|
|
27
|
+
startRow: number;
|
|
28
|
+
endRow: number;
|
|
29
|
+
totalRows: number;
|
|
30
|
+
columns: number;
|
|
31
|
+
totalItems: number;
|
|
32
|
+
topSpacerHeight: number;
|
|
33
|
+
bottomSpacerHeight: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Binary Indexed Tree (Fenwick tree) supporting O(log n) updates, prefix sums, and offset lookups
|
|
37
|
+
* for variable-height virtualized lists and grids.
|
|
38
|
+
*/
|
|
39
|
+
export declare class FenwickOffsetTree {
|
|
40
|
+
private sizes;
|
|
41
|
+
private tree;
|
|
42
|
+
private itemCount;
|
|
43
|
+
private fallbackSize;
|
|
44
|
+
private cachedTotal;
|
|
45
|
+
constructor(count?: number, defaultSize?: number);
|
|
46
|
+
get length(): number;
|
|
47
|
+
/** Rebuilds the tree in O(n) time from `count`, `defaultSize`, and optional per-index overrides. */
|
|
48
|
+
reset(count: number, defaultSize: number, overrides?: ReadonlyMap<number, number>): void;
|
|
49
|
+
/** Returns the height/size recorded for `index` in O(1). */
|
|
50
|
+
sizeOf(index: number): number;
|
|
51
|
+
/** Updates the height/size at `index` in O(log n); returns `true` when it changed. */
|
|
52
|
+
setSize(index: number, size: number): boolean;
|
|
53
|
+
/** Returns the exclusive prefix sum covering `[0, index)` in O(log n). */
|
|
54
|
+
offsetOf(index: number): number;
|
|
55
|
+
/** Returns total size of all items in O(1). */
|
|
56
|
+
totalSize(): number;
|
|
57
|
+
/** Returns the first 0-based index covering `offset` via O(log n) binary lifting. */
|
|
58
|
+
indexAtOffset(offset: number): number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Computes the visible item slice and spacer heights for a fixed-row-height viewport.
|
|
62
|
+
*/
|
|
63
|
+
export declare function computeVirtualSliceRange(totalItems: number, scrollTop: number, viewportHeight: number, itemHeight: number, overscan?: number): VirtualSliceRange;
|
|
64
|
+
/**
|
|
65
|
+
* Computes the visible item slice and exact top/bottom spacer heights from a variable-height `FenwickOffsetTree`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function computeVariableVirtualSliceRange(tree: FenwickOffsetTree, scrollTop: number, viewportHeight: number, overscan?: number): VirtualSliceRange;
|
|
68
|
+
/**
|
|
69
|
+
* Computes the visible 2D item range, row span, responsive column count, and spacer heights for `<ng-virtual-grid>`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function computeVirtualGridSliceRange(options: VirtualGridSliceOptions): VirtualGridSliceRange;
|