ngx-kit 7.2.0 → 7.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/angle-selector/README.md +34 -34
  2. package/box-shadow/README.md +33 -33
  3. package/color-picker/README.md +52 -52
  4. package/{shared → core}/README.md +117 -117
  5. package/data-table/README.md +120 -120
  6. package/date-picker/README.md +74 -74
  7. package/dialog/README.md +122 -92
  8. package/drag-resize/README.md +53 -55
  9. package/fesm2022/ngx-kit-angle-selector.mjs +9 -26
  10. package/fesm2022/ngx-kit-angle-selector.mjs.map +1 -1
  11. package/fesm2022/ngx-kit-box-shadow.mjs +330 -356
  12. package/fesm2022/ngx-kit-box-shadow.mjs.map +1 -1
  13. package/fesm2022/ngx-kit-color-picker.mjs +132 -272
  14. package/fesm2022/ngx-kit-color-picker.mjs.map +1 -1
  15. package/fesm2022/{ngx-kit-shared.mjs → ngx-kit-core.mjs} +845 -277
  16. package/fesm2022/ngx-kit-core.mjs.map +1 -0
  17. package/fesm2022/ngx-kit-data-table.mjs +3 -3
  18. package/fesm2022/ngx-kit-data-table.mjs.map +1 -1
  19. package/fesm2022/ngx-kit-date-picker.mjs +153 -147
  20. package/fesm2022/ngx-kit-date-picker.mjs.map +1 -1
  21. package/fesm2022/ngx-kit-dialog.mjs +430 -331
  22. package/fesm2022/ngx-kit-dialog.mjs.map +1 -1
  23. package/fesm2022/ngx-kit-drag-resize.mjs +126 -45
  24. package/fesm2022/ngx-kit-drag-resize.mjs.map +1 -1
  25. package/fesm2022/ngx-kit-drawer-menu.mjs +2 -2
  26. package/fesm2022/ngx-kit-drawer-menu.mjs.map +1 -1
  27. package/fesm2022/ngx-kit-dropzone.mjs.map +1 -1
  28. package/fesm2022/ngx-kit-form-field.mjs.map +1 -1
  29. package/fesm2022/ngx-kit-gallery.mjs +3 -3
  30. package/fesm2022/ngx-kit-gallery.mjs.map +1 -1
  31. package/fesm2022/ngx-kit-gradient-picker.mjs +20 -38
  32. package/fesm2022/ngx-kit-gradient-picker.mjs.map +1 -1
  33. package/fesm2022/ngx-kit-grid-layout.mjs +19 -18
  34. package/fesm2022/ngx-kit-grid-layout.mjs.map +1 -1
  35. package/fesm2022/ngx-kit-image-editor.mjs +3 -3
  36. package/fesm2022/ngx-kit-image-editor.mjs.map +1 -1
  37. package/fesm2022/ngx-kit-menu.mjs +1 -1
  38. package/fesm2022/ngx-kit-menu.mjs.map +1 -1
  39. package/fesm2022/ngx-kit-message.mjs +1 -1
  40. package/fesm2022/ngx-kit-message.mjs.map +1 -1
  41. package/fesm2022/ngx-kit-notify.mjs +1 -1
  42. package/fesm2022/ngx-kit-notify.mjs.map +1 -1
  43. package/fesm2022/ngx-kit-time-picker.mjs +1 -1
  44. package/fesm2022/ngx-kit-time-picker.mjs.map +1 -1
  45. package/fesm2022/ngx-kit-virtual-scroll.mjs +2 -2
  46. package/fesm2022/ngx-kit-virtual-scroll.mjs.map +1 -1
  47. package/gallery/README.md +71 -71
  48. package/gradient-picker/README.md +41 -41
  49. package/grid-layout/README.md +64 -64
  50. package/image-editor/README.md +44 -44
  51. package/menu/README.md +85 -85
  52. package/message/README.md +70 -70
  53. package/notify/README.md +56 -56
  54. package/package.json +5 -9
  55. package/time-picker/README.md +89 -89
  56. package/types/ngx-kit-angle-selector.d.ts +13 -16
  57. package/types/ngx-kit-box-shadow.d.ts +37 -95
  58. package/types/ngx-kit-color-picker.d.ts +61 -58
  59. package/types/{ngx-kit-shared.d.ts → ngx-kit-core.d.ts} +156 -34
  60. package/types/ngx-kit-data-table.d.ts +2 -2
  61. package/types/ngx-kit-date-picker.d.ts +30 -29
  62. package/types/ngx-kit-dialog.d.ts +208 -107
  63. package/types/ngx-kit-drag-resize.d.ts +33 -6
  64. package/types/ngx-kit-gradient-picker.d.ts +4 -7
  65. package/types/ngx-kit-grid-layout.d.ts +0 -1
  66. package/types/ngx-kit-menu.d.ts +1 -1
  67. package/types/ngx-kit-time-picker.d.ts +1 -1
  68. package/virtual-scroll/README.md +199 -199
  69. package/fesm2022/ngx-kit-shared.mjs.map +0 -1
  70. package/fesm2022/ngx-kit-webflow.mjs +0 -709
  71. package/fesm2022/ngx-kit-webflow.mjs.map +0 -1
  72. package/types/ngx-kit-webflow.d.ts +0 -286
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { OnInit, OnDestroy, EventEmitter, ChangeDetectorRef, AfterViewInit, ElementRef, Renderer2, ViewContainerRef } from '@angular/core';
3
3
  import { ControlValueAccessor, Validator, AbstractControl, ValidationErrors } from '@angular/forms';
4
- import { BrowserService, RangeSliderComponent, OverlayService } from 'ngx-kit/shared';
4
+ import { BrowserService, RangeSliderComponent, OverlayService } from 'ngx-kit/core';
5
5
 
6
6
  interface GradientStop {
7
7
  id: string;
@@ -13,8 +13,6 @@ type GradientType = 'linear' | 'radial';
13
13
  declare class NgxInputGradientComponent implements OnInit, OnDestroy, ControlValueAccessor, Validator {
14
14
  private cd;
15
15
  browserService: BrowserService;
16
- theme: 'light' | 'dark';
17
- set setTheme(val: 'light' | 'dark' | 'auto');
18
16
  change: EventEmitter<string>;
19
17
  defaultGradients: string[];
20
18
  resultGradient: string;
@@ -46,7 +44,7 @@ declare class NgxInputGradientComponent implements OnInit, OnDestroy, ControlVal
46
44
  setDefaultGradients(): void;
47
45
  onSelectDefault(item: string, i: number): void;
48
46
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxInputGradientComponent, never>;
49
- static ɵcmp: i0.ɵɵComponentDeclaration<NgxInputGradientComponent, "ngx-input-gradient", never, { "setTheme": { "alias": "theme"; "required": false; }; }, { "change": "change"; }, never, never, true, never>;
47
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxInputGradientComponent, "ngx-input-gradient", never, {}, { "change": "change"; }, never, never, true, never>;
50
48
  }
51
49
 
52
50
  declare class NgxInputGradient implements AfterViewInit, OnDestroy, ControlValueAccessor, Validator {
@@ -55,7 +53,6 @@ declare class NgxInputGradient implements AfterViewInit, OnDestroy, ControlValue
55
53
  private viewContainerRef;
56
54
  private overlayService;
57
55
  setInputBackground: boolean;
58
- theme: 'light' | 'dark' | 'auto';
59
56
  private _targetInput?;
60
57
  set ngxInputColor(el: HTMLInputElement | ElementRef<HTMLInputElement> | null | undefined | '');
61
58
  change: EventEmitter<string>;
@@ -76,11 +73,11 @@ declare class NgxInputGradient implements AfterViewInit, OnDestroy, ControlValue
76
73
  validate(control: AbstractControl): ValidationErrors | null;
77
74
  ngOnDestroy(): void;
78
75
  writeValue(val: any): void;
79
- toggleColorPicker(): void;
76
+ toggle(): void;
80
77
  destroyPicker(): void;
81
78
  private emitChange;
82
79
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxInputGradient, never>;
83
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgxInputGradient, "[ngxInputGradient]", never, { "setInputBackground": { "alias": "setInputBackground"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; "ngxInputColor": { "alias": "ngxInputColor"; "required": false; }; }, { "change": "change"; }, never, never, true, never>;
80
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxInputGradient, "[ngxInputGradient]", never, { "setInputBackground": { "alias": "setInputBackground"; "required": false; }; "ngxInputColor": { "alias": "ngxInputColor"; "required": false; }; }, { "change": "change"; }, never, never, true, never>;
84
81
  }
85
82
 
86
83
  export { NgxInputGradient, NgxInputGradientComponent };
@@ -189,7 +189,6 @@ declare class GridLayoutService {
189
189
  readonly activeId: _angular_core.WritableSignal<string | null>;
190
190
  readonly isInteracting: _angular_core.Signal<boolean>;
191
191
  readonly height: _angular_core.Signal<number>;
192
- readonly layout: _angular_core.Signal<LayoutOutput[]>;
193
192
  readonly columns: _angular_core.Signal<number>;
194
193
  readonly rtl: _angular_core.Signal<boolean>;
195
194
  private rtlTick;
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { TemplateRef, OnDestroy, ElementRef, ApplicationRef } from '@angular/core';
3
- import { OverlayRef, Placement, Alignment, OverlayService } from 'ngx-kit/shared';
3
+ import { OverlayRef, Placement, Alignment, OverlayService } from 'ngx-kit/core';
4
4
 
5
5
  interface MenuContext {
6
6
  close(): void;
@@ -1,7 +1,7 @@
1
1
  import * as ngx_kit_time_picker from 'ngx-kit/time-picker';
2
2
  import * as _angular_core from '@angular/core';
3
3
  import { OnInit, ElementRef, InjectionToken, Provider } from '@angular/core';
4
- import { BrowserService } from 'ngx-kit/shared';
4
+ import { BrowserService } from 'ngx-kit/core';
5
5
  import { ControlValueAccessor, Validator, AbstractControl, ValidationErrors } from '@angular/forms';
6
6
 
7
7
  declare type NgxTimePickerMode = 'hour' | 'minute';
@@ -1,199 +1,199 @@
1
- # @ngx-kit/virtual-scroll
2
-
3
- A zoneless, signal-based virtual scroll viewport for Angular. No `@angular/material`
4
- or `@angular/cdk` dependency, no `NgZone`, no `ngOnChanges`, no `@Input() itemSize`,
5
- no `@Input() orientation` — everything that can be derived from the real DOM is
6
- derived from the real DOM.
7
-
8
- ## Why this rewrite
9
-
10
- | Old design | This design |
11
- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
12
- | `NgZone` injected, `zone.run` everywhere | No `NgZone` at all — works natively under `provideZonelessChangeDetection()` |
13
- | `ngOnChanges` + `SimpleChanges` | `input()` signals + `computed()` / `effect()` |
14
- | `@Input() itemSize` (broke as soon as your item had margin/border/box-shadow) | Real item size is **measured** from `getBoundingClientRect()` deltas between actually rendered siblings, so margins/borders/shadows are always accounted for |
15
- | `@Input() orientation` | Axis is **auto-detected** from the real layout of your own item markup |
16
- | Custom `*ngxVirtualFor` structural directive | Plain native `@for` over a `visibleItems()` signal — you keep full control of `track`, `@empty`, etc. |
17
-
18
- ## Install & import
19
-
20
- ```ts
21
- import { NgxVirtualScrollViewport } from '@ngx-kit/virtual-scroll';
22
-
23
- @Component({
24
- standalone: true,
25
- imports: [NgxVirtualScrollViewport],
26
- ...
27
- })
28
- ```
29
-
30
- ## Basic usage — vertical list (auto-detected)
31
-
32
- ```html
33
- <ngx-virtual-scroll-viewport #vs="ngxVirtualScrollViewport" [items]="items" style="height: 400px">
34
- @for (item of vs.visibleItems(); track $index; let i = $index) {
35
- <div class="row">{{ vs.baseIndex() + i | number }} - {{ item.name }}</div>
36
- }
37
- </ngx-virtual-scroll-viewport>
38
- ```
39
-
40
- This is exactly the case that used to break: `.row` can have `margin`, `border`,
41
- `box-shadow`, `padding` — anything. The viewport measures the real distance between
42
- two consecutively rendered rows and uses that, not a number you have to keep in sync
43
- with your CSS.
44
-
45
- ```css
46
- .row {
47
- height: 48px;
48
- border: 1px rgb(166 166 166 / 51%) solid;
49
- box-shadow: 0px 0px 20px rgb(122 122 122 / 20%);
50
- border-radius: 5px;
51
- display: flex;
52
- align-items: center;
53
- margin: 10px;
54
- padding: 15px;
55
- }
56
- ```
57
-
58
- ## Horizontal lists & wrapping grids (auto-detected)
59
-
60
- The axis is inferred purely from how your own items lay out:
61
-
62
- - Items stack top-to-bottom (default block flow) → **vertical** list.
63
- - Items lay out left-to-right in a single line (e.g. `display: inline-flex` on the
64
- item, or a `flex-wrap: nowrap` row) → **horizontal** list.
65
- - Items lay out left-to-right and _wrap_ to a new line (e.g. cards with
66
- `display: flex; flex-wrap: wrap`) → treated as a **vertical** list of "lines",
67
- where each line holds N items. This is how mixed horizontal + vertical layouts
68
- (a card grid that scrolls vertically) are supported without a separate 2D data
69
- model — the cross axis (row width) lays out and scrolls natively, only the line
70
- axis is virtualized.
71
-
72
- You don't configure any of this — you only make sure your `.item` CSS actually lays
73
- out the way you want, and the viewport detects it.
74
-
75
- ## Mixed content (e.g. wide, virtualized table)
76
-
77
- Both axes of the scroll container are always natively scrollable
78
- (`overflow: auto` on both). Only the detected axis is virtualized; the cross axis
79
- (for example, a table wider than its container) scrolls with the browser's native
80
- scrollbar, so wide tables with virtualized rows work out of the box:
81
-
82
- ```html
83
- <div class="table-shell">
84
- <table><thead>...</thead></table>
85
- <!-- kept outside, sticky/fixed header -->
86
-
87
- <ngx-virtual-scroll-viewport #vs="ngxVirtualScrollViewport" [items]="rows" style="height: 480px">
88
- <table>
89
- <tbody>
90
- @for (row of vs.visibleItems(); track row.id; let i = $index) {
91
- <tr>
92
- <td>{{ vs.baseIndex() + i }}</td>
93
- ...
94
- </tr>
95
- }
96
- </tbody>
97
- </table>
98
- </ngx-virtual-scroll-viewport>
99
- </div>
100
- ```
101
-
102
- ## Very large data sets (1M+ rows)
103
-
104
- Browsers clamp any element's real CSS `height`/`width` to a hard maximum
105
- (~33.5M px in Chromium, far less in older WebKit/Gecko). Once a naive
106
- "spacer" element crosses that ceiling, the browser silently clamps it,
107
- `scrollHeight` stops growing, and everything past that point becomes
108
- unreachable — the classic "scroll gets stuck around ~500k rows" symptom.
109
-
110
- This viewport handles it automatically: the spacer's real DOM size is capped
111
- at `maxAxisSizePx` (6,000,000px by default — safely under every known
112
- browser limit), and the DOM scrollbar operates in a _compressed_ coordinate
113
- space via `scaleFactor()`. All range/index math is done against the real,
114
- uncompressed content size (`naturalTotalSize()`), so scrolling the
115
- (compressed) native scrollbar all the way to the end still lands you exactly
116
- on the last item, no matter how many millions of rows you have. The only
117
- user-visible trade-off for truly massive lists is that the scrollbar thumb's
118
- motion is no longer perfectly 1:1 with "one row per pixel" — an unavoidable
119
- consequence of representing an arbitrarily large data set inside a bounded
120
- native scrollbar, and the same trade-off every large-scale virtual scroll
121
- implementation makes.
122
-
123
- You don't need to configure anything for this — it only engages once
124
- `naturalTotalSize()` actually exceeds `maxAxisSizePx`, and is a no-op
125
- (`scaleFactor() === 1`) for the vast majority of real-world lists.
126
-
127
- ## API
128
-
129
- ### Inputs
130
-
131
- | Input | Type | Default | Notes |
132
- | --------------- | --------------------------- | ----------- | ---------------------------------------------------------------------------- |
133
- | `items` | `readonly T[]` | `[]` | Full data set |
134
- | `minBufferPx` | `number` | `150` | Buffer left before recomputing the range |
135
- | `maxBufferPx` | `number` | `300` | Extra px rendered outside the viewport |
136
- | `measureFn` | `NgxVirtualScrollMeasureFn` | `undefined` | Advanced override for the built-in layout probe |
137
- | `maxAxisSizePx` | `number` | `6_000_000` | Safe ceiling for the real DOM scroll size — see "Very large data sets" below |
138
-
139
- ### Outputs
140
-
141
- | Output | Type |
142
- | --------------------- | ----------------------------------------- |
143
- | `scrolledIndexChange` | `OutputEmitterRef<number>` |
144
- | `rangeChange` | `OutputEmitterRef<NgxVirtualScrollRange>` |
145
-
146
- ### Public signals (via `#vs="ngxVirtualScrollViewport"`)
147
-
148
- | Signal | Type | Meaning |
149
- | -------------------- | ---------------------------- | ------------------------------------------------------------------------------ |
150
- | `visibleItems()` | `readonly T[]` | Slice of `items()` to render right now |
151
- | `range()` | `{ start, end }` | Currently rendered line range |
152
- | `baseIndex()` | `number` | Absolute index of `visibleItems()[0]` |
153
- | `axis()` | `'vertical' \| 'horizontal'` | Auto-detected scroll axis |
154
- | `crossCount()` | `number` | Items per line (1 for a plain list) |
155
- | `lineSize()` | `number` | Measured px size of one line |
156
- | `isMeasured()` | `boolean` | Whether the initial layout probe has completed |
157
- | `isScrolling()` | `boolean` | True while an active scroll gesture is in progress |
158
- | `naturalTotalSize()` | `number` | Real, uncompressed total size along the scroll axis |
159
- | `totalSize()` | `number` | Size actually applied to the spacer (capped at `maxAxisSizePx`) |
160
- | `scaleFactor()` | `number` | `totalSize() / naturalTotalSize()`; `1` unless the data set is extremely large |
161
-
162
- ### Methods
163
-
164
- | Method | Description |
165
- | ------------------------------------- | ----------------------------------------------------------------------------------------- |
166
- | `scrollToIndex(index, behavior?)` | Scroll to a given item index |
167
- | `scrollToOffset(offsetPx, behavior?)` | Scroll to a given pixel offset |
168
- | `checkViewportSize()` | Force a re-measure (rarely needed — a `ResizeObserver` already handles container resizes) |
169
-
170
- ## Performance notes
171
-
172
- - Fully `ChangeDetectionStrategy.OnPush` and zoneless-compatible — no `NgZone`
173
- import anywhere; signal writes are what schedule change detection.
174
- - Scroll handling is `requestAnimationFrame`-throttled and the listener is
175
- registered with `{ passive: true }`.
176
- - The range is only recomputed once the scroll offset gets within
177
- `minBufferPx` of the current range's edge — not on every scroll event.
178
- - Layout is only ever **read** (`getBoundingClientRect`) inside an
179
- `afterRenderEffect({ read: ... })` block, so DOM measurement never
180
- interleaves with — and never forces — a layout/style write.
181
- - `will-change: transform` is only applied to the content wrapper while
182
- `isScrolling()` is true, and removed ~150ms after the last scroll event, to
183
- avoid holding a compositor layer alive for the component's entire lifetime.
184
- - `contain: strict` / `contain: layout style` isolate the viewport's layout
185
- and paint from the rest of the page.
186
-
187
- ## How auto-measurement works
188
-
189
- On first render, up to 24 items are rendered "in the open" (un-transformed) purely
190
- to be measured — see `measure-layout.ts`. Their real `getBoundingClientRect()`
191
- deltas are used to infer axis, items-per-line, and line size in one pass, all pure
192
- functions with no Angular dependency (so they are trivially unit-testable). Once
193
- measured, the real virtualized range replaces the probe range and rendering
194
- proceeds normally. If your rows can change size at runtime (e.g. responsive
195
- breakpoints), a `ResizeObserver` on the scroll container triggers `checkViewportSize()`
196
- automatically to re-fit the viewport dimension; if the _line size itself_ changes at
197
- runtime you can force a full re-measure by re-creating the component (e.g. keyed with
198
- `@if`/`*ngIf` + a changing key), which is the same limitation `cdk-virtual-scroll-viewport`
199
- has with its own `FixedSizeVirtualScrollStrategy`.
1
+ # @ngx-kit/virtual-scroll
2
+
3
+ A zoneless, signal-based virtual scroll viewport for Angular. No `@angular/material`
4
+ or `@angular/cdk` dependency, no `NgZone`, no `ngOnChanges`, no `@Input() itemSize`,
5
+ no `@Input() orientation` — everything that can be derived from the real DOM is
6
+ derived from the real DOM.
7
+
8
+ ## Why this rewrite
9
+
10
+ | Old design | This design |
11
+ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
12
+ | `NgZone` injected, `zone.run` everywhere | No `NgZone` at all — works natively under `provideZonelessChangeDetection()` |
13
+ | `ngOnChanges` + `SimpleChanges` | `input()` signals + `computed()` / `effect()` |
14
+ | `@Input() itemSize` (broke as soon as your item had margin/border/box-shadow) | Real item size is **measured** from `getBoundingClientRect()` deltas between actually rendered siblings, so margins/borders/shadows are always accounted for |
15
+ | `@Input() orientation` | Axis is **auto-detected** from the real layout of your own item markup |
16
+ | Custom `*ngxVirtualFor` structural directive | Plain native `@for` over a `visibleItems()` signal — you keep full control of `track`, `@empty`, etc. |
17
+
18
+ ## Install & import
19
+
20
+ ```ts
21
+ import { NgxVirtualScrollViewport } from '@ngx-kit/virtual-scroll';
22
+
23
+ @Component({
24
+ standalone: true,
25
+ imports: [NgxVirtualScrollViewport],
26
+ ...
27
+ })
28
+ ```
29
+
30
+ ## Basic usage — vertical list (auto-detected)
31
+
32
+ ```html
33
+ <ngx-virtual-scroll-viewport #vs="ngxVirtualScrollViewport" [items]="items" style="height: 400px">
34
+ @for (item of vs.visibleItems(); track $index; let i = $index) {
35
+ <div class="row">{{ vs.baseIndex() + i | number }} - {{ item.name }}</div>
36
+ }
37
+ </ngx-virtual-scroll-viewport>
38
+ ```
39
+
40
+ This is exactly the case that used to break: `.row` can have `margin`, `border`,
41
+ `box-shadow`, `padding` — anything. The viewport measures the real distance between
42
+ two consecutively rendered rows and uses that, not a number you have to keep in sync
43
+ with your CSS.
44
+
45
+ ```css
46
+ .row {
47
+ height: 48px;
48
+ border: 1px rgb(166 166 166 / 51%) solid;
49
+ box-shadow: 0px 0px 20px rgb(122 122 122 / 20%);
50
+ border-radius: 5px;
51
+ display: flex;
52
+ align-items: center;
53
+ margin: 10px;
54
+ padding: 15px;
55
+ }
56
+ ```
57
+
58
+ ## Horizontal lists & wrapping grids (auto-detected)
59
+
60
+ The axis is inferred purely from how your own items lay out:
61
+
62
+ - Items stack top-to-bottom (default block flow) → **vertical** list.
63
+ - Items lay out left-to-right in a single line (e.g. `display: inline-flex` on the
64
+ item, or a `flex-wrap: nowrap` row) → **horizontal** list.
65
+ - Items lay out left-to-right and _wrap_ to a new line (e.g. cards with
66
+ `display: flex; flex-wrap: wrap`) → treated as a **vertical** list of "lines",
67
+ where each line holds N items. This is how mixed horizontal + vertical layouts
68
+ (a card grid that scrolls vertically) are supported without a separate 2D data
69
+ model — the cross axis (row width) lays out and scrolls natively, only the line
70
+ axis is virtualized.
71
+
72
+ You don't configure any of this — you only make sure your `.item` CSS actually lays
73
+ out the way you want, and the viewport detects it.
74
+
75
+ ## Mixed content (e.g. wide, virtualized table)
76
+
77
+ Both axes of the scroll container are always natively scrollable
78
+ (`overflow: auto` on both). Only the detected axis is virtualized; the cross axis
79
+ (for example, a table wider than its container) scrolls with the browser's native
80
+ scrollbar, so wide tables with virtualized rows work out of the box:
81
+
82
+ ```html
83
+ <div class="table-shell">
84
+ <table><thead>...</thead></table>
85
+ <!-- kept outside, sticky/fixed header -->
86
+
87
+ <ngx-virtual-scroll-viewport #vs="ngxVirtualScrollViewport" [items]="rows" style="height: 480px">
88
+ <table>
89
+ <tbody>
90
+ @for (row of vs.visibleItems(); track row.id; let i = $index) {
91
+ <tr>
92
+ <td>{{ vs.baseIndex() + i }}</td>
93
+ ...
94
+ </tr>
95
+ }
96
+ </tbody>
97
+ </table>
98
+ </ngx-virtual-scroll-viewport>
99
+ </div>
100
+ ```
101
+
102
+ ## Very large data sets (1M+ rows)
103
+
104
+ Browsers clamp any element's real CSS `height`/`width` to a hard maximum
105
+ (~33.5M px in Chromium, far less in older WebKit/Gecko). Once a naive
106
+ "spacer" element crosses that ceiling, the browser silently clamps it,
107
+ `scrollHeight` stops growing, and everything past that point becomes
108
+ unreachable — the classic "scroll gets stuck around ~500k rows" symptom.
109
+
110
+ This viewport handles it automatically: the spacer's real DOM size is capped
111
+ at `maxAxisSizePx` (6,000,000px by default — safely under every known
112
+ browser limit), and the DOM scrollbar operates in a _compressed_ coordinate
113
+ space via `scaleFactor()`. All range/index math is done against the real,
114
+ uncompressed content size (`naturalTotalSize()`), so scrolling the
115
+ (compressed) native scrollbar all the way to the end still lands you exactly
116
+ on the last item, no matter how many millions of rows you have. The only
117
+ user-visible trade-off for truly massive lists is that the scrollbar thumb's
118
+ motion is no longer perfectly 1:1 with "one row per pixel" — an unavoidable
119
+ consequence of representing an arbitrarily large data set inside a bounded
120
+ native scrollbar, and the same trade-off every large-scale virtual scroll
121
+ implementation makes.
122
+
123
+ You don't need to configure anything for this — it only engages once
124
+ `naturalTotalSize()` actually exceeds `maxAxisSizePx`, and is a no-op
125
+ (`scaleFactor() === 1`) for the vast majority of real-world lists.
126
+
127
+ ## API
128
+
129
+ ### Inputs
130
+
131
+ | Input | Type | Default | Notes |
132
+ | --------------- | --------------------------- | ----------- | ---------------------------------------------------------------------------- |
133
+ | `items` | `readonly T[]` | `[]` | Full data set |
134
+ | `minBufferPx` | `number` | `150` | Buffer left before recomputing the range |
135
+ | `maxBufferPx` | `number` | `300` | Extra px rendered outside the viewport |
136
+ | `measureFn` | `NgxVirtualScrollMeasureFn` | `undefined` | Advanced override for the built-in layout probe |
137
+ | `maxAxisSizePx` | `number` | `6_000_000` | Safe ceiling for the real DOM scroll size — see "Very large data sets" below |
138
+
139
+ ### Outputs
140
+
141
+ | Output | Type |
142
+ | --------------------- | ----------------------------------------- |
143
+ | `scrolledIndexChange` | `OutputEmitterRef<number>` |
144
+ | `rangeChange` | `OutputEmitterRef<NgxVirtualScrollRange>` |
145
+
146
+ ### Public signals (via `#vs="ngxVirtualScrollViewport"`)
147
+
148
+ | Signal | Type | Meaning |
149
+ | -------------------- | ---------------------------- | ------------------------------------------------------------------------------ |
150
+ | `visibleItems()` | `readonly T[]` | Slice of `items()` to render right now |
151
+ | `range()` | `{ start, end }` | Currently rendered line range |
152
+ | `baseIndex()` | `number` | Absolute index of `visibleItems()[0]` |
153
+ | `axis()` | `'vertical' \| 'horizontal'` | Auto-detected scroll axis |
154
+ | `crossCount()` | `number` | Items per line (1 for a plain list) |
155
+ | `lineSize()` | `number` | Measured px size of one line |
156
+ | `isMeasured()` | `boolean` | Whether the initial layout probe has completed |
157
+ | `isScrolling()` | `boolean` | True while an active scroll gesture is in progress |
158
+ | `naturalTotalSize()` | `number` | Real, uncompressed total size along the scroll axis |
159
+ | `totalSize()` | `number` | Size actually applied to the spacer (capped at `maxAxisSizePx`) |
160
+ | `scaleFactor()` | `number` | `totalSize() / naturalTotalSize()`; `1` unless the data set is extremely large |
161
+
162
+ ### Methods
163
+
164
+ | Method | Description |
165
+ | ------------------------------------- | ----------------------------------------------------------------------------------------- |
166
+ | `scrollToIndex(index, behavior?)` | Scroll to a given item index |
167
+ | `scrollToOffset(offsetPx, behavior?)` | Scroll to a given pixel offset |
168
+ | `checkViewportSize()` | Force a re-measure (rarely needed — a `ResizeObserver` already handles container resizes) |
169
+
170
+ ## Performance notes
171
+
172
+ - Fully `ChangeDetectionStrategy.OnPush` and zoneless-compatible — no `NgZone`
173
+ import anywhere; signal writes are what schedule change detection.
174
+ - Scroll handling is `requestAnimationFrame`-throttled and the listener is
175
+ registered with `{ passive: true }`.
176
+ - The range is only recomputed once the scroll offset gets within
177
+ `minBufferPx` of the current range's edge — not on every scroll event.
178
+ - Layout is only ever **read** (`getBoundingClientRect`) inside an
179
+ `afterRenderEffect({ read: ... })` block, so DOM measurement never
180
+ interleaves with — and never forces — a layout/style write.
181
+ - `will-change: transform` is only applied to the content wrapper while
182
+ `isScrolling()` is true, and removed ~150ms after the last scroll event, to
183
+ avoid holding a compositor layer alive for the component's entire lifetime.
184
+ - `contain: strict` / `contain: layout style` isolate the viewport's layout
185
+ and paint from the rest of the page.
186
+
187
+ ## How auto-measurement works
188
+
189
+ On first render, up to 24 items are rendered "in the open" (un-transformed) purely
190
+ to be measured — see `measure-layout.ts`. Their real `getBoundingClientRect()`
191
+ deltas are used to infer axis, items-per-line, and line size in one pass, all pure
192
+ functions with no Angular dependency (so they are trivially unit-testable). Once
193
+ measured, the real virtualized range replaces the probe range and rendering
194
+ proceeds normally. If your rows can change size at runtime (e.g. responsive
195
+ breakpoints), a `ResizeObserver` on the scroll container triggers `checkViewportSize()`
196
+ automatically to re-fit the viewport dimension; if the _line size itself_ changes at
197
+ runtime you can force a full re-measure by re-creating the component (e.g. keyed with
198
+ `@if`/`*ngIf` + a changing key), which is the same limitation `cdk-virtual-scroll-viewport`
199
+ has with its own `FixedSizeVirtualScrollStrategy`.