@ruc-lib/virtual-scroll 3.2.0 → 4.0.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 +50 -21
- package/fesm2022/ruc-lib-virtual-scroll.mjs +143 -0
- package/fesm2022/ruc-lib-virtual-scroll.mjs.map +1 -0
- package/index.d.ts +109 -2
- package/package.json +7 -21
- package/esm2020/index.mjs +0 -3
- package/esm2020/lib/ruclib-virtual-scroll/ruclib-virtual-scroll.component.mjs +0 -123
- package/esm2020/lib/ruclib-virtual-scroll.module.mjs +0 -20
- package/esm2020/model/ruclib-virtual-scroll.model.mjs +0 -2
- package/esm2020/ruc-lib-virtual-scroll.mjs +0 -5
- package/fesm2015/ruc-lib-virtual-scroll.mjs +0 -154
- package/fesm2015/ruc-lib-virtual-scroll.mjs.map +0 -1
- package/fesm2020/ruc-lib-virtual-scroll.mjs +0 -146
- package/fesm2020/ruc-lib-virtual-scroll.mjs.map +0 -1
- package/lib/ruclib-virtual-scroll/ruclib-virtual-scroll.component.d.ts +0 -62
- package/lib/ruclib-virtual-scroll.module.d.ts +0 -10
- package/model/ruclib-virtual-scroll.model.d.ts +0 -45
package/README.md
CHANGED
|
@@ -13,46 +13,75 @@ npm install @uxpractice/ruc-lib
|
|
|
13
13
|
|
|
14
14
|
### Install Individual Component
|
|
15
15
|
|
|
16
|
-
If you only need the
|
|
16
|
+
If you only need the VirtualScroll component:
|
|
17
|
+
|
|
18
|
+
**For Angular 15:**
|
|
19
|
+
```bash
|
|
20
|
+
npm install @ruc-lib/virtual-scroll@3.2.0 @angular/material@^15.0.0 @angular/cdk@^15.0.0
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**For Angular 16:**
|
|
24
|
+
```bash
|
|
25
|
+
npm install @ruc-lib/virtual-scroll@3.2.0 @angular/material@^16.0.0 @angular/cdk@^16.0.0
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**For Angular 17:**
|
|
29
|
+
```bash
|
|
30
|
+
npm install @ruc-lib/virtual-scroll@4.0.0 @angular/material@^17.0.0 @angular/cdk@^17.0.0
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**For Angular 18:**
|
|
34
|
+
```bash
|
|
35
|
+
npm install @ruc-lib/virtual-scroll@4.0.0 @angular/material@^18.0.0 @angular/cdk@^18.0.0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**For Angular 19:**
|
|
17
39
|
```bash
|
|
18
|
-
npm install @ruc-lib/virtual-scroll
|
|
40
|
+
npm install @ruc-lib/virtual-scroll@4.0.0 @angular/material@^19.0.0 @angular/cdk@^19.0.0
|
|
19
41
|
```
|
|
20
42
|
|
|
43
|
+
**For Angular 20:**
|
|
44
|
+
```bash
|
|
45
|
+
npm install @ruc-lib/virtual-scroll@4.0.0
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> **Note:** When installing in Angular 15-19 apps, you must specify the matching `@angular/material` and `@angular/cdk` versions to avoid peer dependency conflicts. Angular 20 will automatically use the correct versions.
|
|
49
|
+
|
|
21
50
|
## Version Compatibility
|
|
22
51
|
|
|
23
52
|
Please ensure you install the correct version of `@ruc-lib/virtual-scroll` based on your Angular version.
|
|
24
53
|
|
|
25
54
|
| Angular Version | Compatible `@ruc-lib/virtual-scroll` Version |
|
|
26
|
-
|
|
55
|
+
|--------------------|--------------------------------------------------|
|
|
27
56
|
| 15.x.x | `npm install @ruc-lib/virtual-scroll@^3.2.0` |
|
|
28
57
|
| 16.x.x | `npm install @ruc-lib/virtual-scroll@^3.2.0` |
|
|
58
|
+
| 17.x.x | `npm install @ruc-lib/virtual-scroll@^4.0.0` |
|
|
59
|
+
| 18.x.x | `npm install @ruc-lib/virtual-scroll@^4.0.0` |
|
|
60
|
+
| 19.x.x | `npm install @ruc-lib/virtual-scroll@^4.0.0` |
|
|
61
|
+
| 20.x.x | `npm install @ruc-lib/virtual-scroll@^4.0.0` |
|
|
29
62
|
|
|
30
63
|
|
|
31
64
|
## Usage
|
|
32
|
-
### 1. Import the
|
|
33
|
-
In your Angular
|
|
65
|
+
### 1. Import the Component
|
|
66
|
+
In your Angular component file (e.g., `app.component.ts`), import the `RuclibVirtualScrollComponent`:
|
|
34
67
|
|
|
35
68
|
```typescript
|
|
69
|
+
import { Component } from '@angular/core';
|
|
70
|
+
|
|
36
71
|
// For Complete Library
|
|
37
|
-
import {
|
|
72
|
+
import { RuclibVirtualScrollComponent } from '@uxpractice/ruc-lib/virtual-scroll';
|
|
38
73
|
|
|
39
74
|
// For Individual Package
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@NgModule({
|
|
47
|
-
declarations: [AppComponent],
|
|
48
|
-
imports: [
|
|
49
|
-
BrowserModule,
|
|
50
|
-
RuclibVirtualScrollModule
|
|
51
|
-
],
|
|
52
|
-
providers: [],
|
|
53
|
-
bootstrap: [AppComponent]
|
|
75
|
+
import { RuclibVirtualScrollComponent } from '@ruc-lib/virtual-scroll';
|
|
76
|
+
|
|
77
|
+
@Component({
|
|
78
|
+
selector: 'app-root',
|
|
79
|
+
imports: [RuclibVirtualScrollComponent],
|
|
80
|
+
templateUrl: './app.component.html',
|
|
54
81
|
})
|
|
55
|
-
export class
|
|
82
|
+
export class AppComponent {
|
|
83
|
+
// Component code here
|
|
84
|
+
}
|
|
56
85
|
```
|
|
57
86
|
|
|
58
87
|
### 2. Use the Component
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ViewChild, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/cdk/scrolling';
|
|
4
|
+
import { ScrollingModule, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
|
5
|
+
import * as i2 from '@angular/material/icon';
|
|
6
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
7
|
+
|
|
8
|
+
class RuclibVirtualScrollComponent {
|
|
9
|
+
constructor() {
|
|
10
|
+
// Configuration object, aligns with how other components might be fed data in your app
|
|
11
|
+
this.rucInputData = {};
|
|
12
|
+
this.itemSize = 10; // Default item size in pixels
|
|
13
|
+
this.viewportWidth = '100vw'; // Default viewport width
|
|
14
|
+
this.viewportHeight = '100vh'; // Default viewport height
|
|
15
|
+
this.clientHeight = 0;
|
|
16
|
+
// Optional: For theming, if your component needs to react to theme changes
|
|
17
|
+
this.customTheme = '';
|
|
18
|
+
}
|
|
19
|
+
ngOnInit() {
|
|
20
|
+
this.updateInternalState();
|
|
21
|
+
}
|
|
22
|
+
ngOnChanges(changes) {
|
|
23
|
+
// Re-process inputs if they change
|
|
24
|
+
if (changes['rucInputData']) {
|
|
25
|
+
this.updateInternalState();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
ngAfterViewChecked() {
|
|
29
|
+
const isDataLoading = this.rucInputData?.isLoad || false;
|
|
30
|
+
if (isDataLoading) {
|
|
31
|
+
this.scrollToIndex();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
updateInternalState() {
|
|
35
|
+
this.clientHeight = document.getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0].clientHeight;
|
|
36
|
+
// Update itemSize from rucInputData if provided, otherwise keep current or default
|
|
37
|
+
this.itemSize =
|
|
38
|
+
this.rucInputData?.itemSize !== undefined
|
|
39
|
+
? this.rucInputData.itemSize
|
|
40
|
+
: this.itemSize;
|
|
41
|
+
// Update viewportWidth from rucInputData if provided, otherwise keep current or default
|
|
42
|
+
this.viewportWidth =
|
|
43
|
+
this.rucInputData?.viewportWidth !== undefined
|
|
44
|
+
? this.rucInputData.viewportWidth
|
|
45
|
+
: this.viewportWidth;
|
|
46
|
+
// Update viewportHeight from rucInputData if provided, otherwise keep current or default
|
|
47
|
+
this.viewportHeight =
|
|
48
|
+
this.rucInputData?.viewportHeight !== undefined
|
|
49
|
+
? this.rucInputData.viewportHeight
|
|
50
|
+
: this.viewportHeight;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Example public method that can be called by a parent component.
|
|
54
|
+
* Scrolls the virtual scroll viewport to the specified index.
|
|
55
|
+
* @param index The index of the item to scroll to.
|
|
56
|
+
* @param behavior Optional scroll behavior ('auto', 'smooth').
|
|
57
|
+
*/
|
|
58
|
+
scrollToIndex() {
|
|
59
|
+
const newClientHeight = document.getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0].clientHeight;
|
|
60
|
+
if (this.virtualScrollViewport) {
|
|
61
|
+
if (newClientHeight !== this.clientHeight) {
|
|
62
|
+
this.clientHeight = document.getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0].clientHeight;
|
|
63
|
+
document
|
|
64
|
+
.getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0]
|
|
65
|
+
.scrollIntoView({ behavior: 'auto', block: 'end' });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.warn('RuclibVirtualScrollComponent: Viewport not available to scroll.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* To handle the scroll position on top by using back to top icon
|
|
74
|
+
* @returns scroll position at top
|
|
75
|
+
*/
|
|
76
|
+
handleScroll() {
|
|
77
|
+
document
|
|
78
|
+
.getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0]
|
|
79
|
+
.scrollIntoView({ behavior: 'auto', block: 'start' });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* To get the icon of back to top icon
|
|
83
|
+
* @returns default: 'arrow_upward'
|
|
84
|
+
*/
|
|
85
|
+
getBackToTopIcon() {
|
|
86
|
+
return this.rucInputData?.backToTopIcon || 'arrow_upward';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* To get the label of back to top icon
|
|
90
|
+
* @returns default: 'Back to Top'
|
|
91
|
+
*/
|
|
92
|
+
getBackToTopLabel() {
|
|
93
|
+
return this.rucInputData?.backToTopLabel || 'Back to Top';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* To get the color of icon
|
|
97
|
+
* @returns default: false
|
|
98
|
+
*/
|
|
99
|
+
getIconColor() {
|
|
100
|
+
return this.rucInputData?.iconColor || 'primary';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* To check wheteher back to top icon shold be there or not in view
|
|
104
|
+
* @returns default: false
|
|
105
|
+
*/
|
|
106
|
+
isBackToTopIcon() {
|
|
107
|
+
return this.rucInputData?.isBackToTopIcon || false;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* To get the thumb color of virtual scroll
|
|
111
|
+
* @returns default: '#888'
|
|
112
|
+
*/
|
|
113
|
+
getScrollbarThumbColor() {
|
|
114
|
+
return this.rucInputData?.thumbColor || '#888';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* To get the track color of virtual scroll
|
|
118
|
+
* @returns default: '#f1f1f1'
|
|
119
|
+
*/
|
|
120
|
+
getScrollbarTrackColor() {
|
|
121
|
+
return this.rucInputData?.trackColor || '#f1f1f1';
|
|
122
|
+
}
|
|
123
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibVirtualScrollComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
124
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: RuclibVirtualScrollComponent, isStandalone: true, selector: "uxp-ruclib-virtual-scroll", inputs: { rucInputData: "rucInputData", customTheme: "customTheme" }, viewQueries: [{ propertyName: "virtualScrollViewport", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<cdk-virtual-scroll-viewport\r\n [style.scrollbar-color]=\"getScrollbarThumbColor() + ' ' + getScrollbarTrackColor()\"\r\n class=\"virtual-scrollar-wrapper\" itemSize=\"itemSize\" [style.width]=\"viewportWidth\" [style.height]=\"viewportHeight\">\r\n <ng-content></ng-content>\r\n</cdk-virtual-scroll-viewport>\r\n\r\n@if (isBackToTopIcon()) {\r\n <div class=\"virtual-scrollar__back-to-top\">\r\n <button class=\"virtual-scrollar__back-to-top-btn\" mat-mini-fab aria-label=\"getBackToTopLabel()\" (click)=\"handleScroll()\">\r\n <mat-icon color=\"{{getIconColor()}}\">{{getBackToTopIcon()}}</mat-icon>\r\n </button>\r\n </div>\r\n}", styles: [".virtual-scrollar-wrapper{border:1px solid #ccc}.virtual-scrollar__back-to-top{margin:8px 0}.virtual-scrollar__back-to-top .virtual-scrollar__back-to-top-btn{cursor:pointer}::ng-deep .cdk-virtual-scroll-content-wrapper{contain:inline-size!important}\n"], dependencies: [{ kind: "ngmodule", type: ScrollingModule }, { kind: "directive", type: i1.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "component", type: i1.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
125
|
+
}
|
|
126
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibVirtualScrollComponent, decorators: [{
|
|
127
|
+
type: Component,
|
|
128
|
+
args: [{ selector: 'uxp-ruclib-virtual-scroll', imports: [ScrollingModule, MatIconModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<cdk-virtual-scroll-viewport\r\n [style.scrollbar-color]=\"getScrollbarThumbColor() + ' ' + getScrollbarTrackColor()\"\r\n class=\"virtual-scrollar-wrapper\" itemSize=\"itemSize\" [style.width]=\"viewportWidth\" [style.height]=\"viewportHeight\">\r\n <ng-content></ng-content>\r\n</cdk-virtual-scroll-viewport>\r\n\r\n@if (isBackToTopIcon()) {\r\n <div class=\"virtual-scrollar__back-to-top\">\r\n <button class=\"virtual-scrollar__back-to-top-btn\" mat-mini-fab aria-label=\"getBackToTopLabel()\" (click)=\"handleScroll()\">\r\n <mat-icon color=\"{{getIconColor()}}\">{{getBackToTopIcon()}}</mat-icon>\r\n </button>\r\n </div>\r\n}", styles: [".virtual-scrollar-wrapper{border:1px solid #ccc}.virtual-scrollar__back-to-top{margin:8px 0}.virtual-scrollar__back-to-top .virtual-scrollar__back-to-top-btn{cursor:pointer}::ng-deep .cdk-virtual-scroll-content-wrapper{contain:inline-size!important}\n"] }]
|
|
129
|
+
}], propDecorators: { rucInputData: [{
|
|
130
|
+
type: Input
|
|
131
|
+
}], customTheme: [{
|
|
132
|
+
type: Input
|
|
133
|
+
}], virtualScrollViewport: [{
|
|
134
|
+
type: ViewChild,
|
|
135
|
+
args: [CdkVirtualScrollViewport]
|
|
136
|
+
}] } });
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Generated bundle index. Do not edit.
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
export { RuclibVirtualScrollComponent };
|
|
143
|
+
//# sourceMappingURL=ruc-lib-virtual-scroll.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruc-lib-virtual-scroll.mjs","sources":["../../src/lib/ruclib-virtual-scroll/ruclib-virtual-scroll.component.ts","../../src/lib/ruclib-virtual-scroll/ruclib-virtual-scroll.component.html","../../src/ruc-lib-virtual-scroll.ts"],"sourcesContent":["import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n Input,\r\n OnChanges,\r\n OnInit,\r\n SimpleChanges,\r\n ViewChild,\r\n} from '@angular/core';\r\n\r\nimport { RucVirtualScrollInput } from '../../model/ruclib-virtual-scroll.model';\r\nimport {\r\n CdkVirtualScrollViewport,\r\n ScrollingModule,\r\n} from '@angular/cdk/scrolling';\r\nimport { MatIconModule } from '@angular/material/icon';\r\n\r\n@Component({\r\n selector: 'uxp-ruclib-virtual-scroll',\r\n imports: [ScrollingModule, MatIconModule],\r\n templateUrl: './ruclib-virtual-scroll.component.html',\r\n styleUrl: './ruclib-virtual-scroll.component.scss',\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class RuclibVirtualScrollComponent implements OnInit, OnChanges {\r\n // Configuration object, aligns with how other components might be fed data in your app\r\n @Input() rucInputData: RucVirtualScrollInput = {};\r\n itemSize = 10; // Default item size in pixels\r\n viewportWidth = '100vw'; // Default viewport width\r\n viewportHeight = '100vh'; // Default viewport height\r\n clientHeight = 0;\r\n\r\n // Optional: For theming, if your component needs to react to theme changes\r\n @Input() customTheme = '';\r\n\r\n @ViewChild(CdkVirtualScrollViewport) virtualScrollViewport:\r\n | CdkVirtualScrollViewport\r\n | undefined;\r\n\r\n ngOnInit(): void {\r\n this.updateInternalState();\r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n // Re-process inputs if they change\r\n if (changes['rucInputData']) {\r\n this.updateInternalState();\r\n }\r\n }\r\n\r\n ngAfterViewChecked() {\r\n const isDataLoading = this.rucInputData?.isLoad || false;\r\n if (isDataLoading) {\r\n this.scrollToIndex();\r\n }\r\n }\r\n\r\n private updateInternalState(): void {\r\n this.clientHeight = document.getElementsByClassName(\r\n 'cdk-virtual-scroll-content-wrapper'\r\n )[0].clientHeight;\r\n\r\n // Update itemSize from rucInputData if provided, otherwise keep current or default\r\n this.itemSize =\r\n this.rucInputData?.itemSize !== undefined\r\n ? this.rucInputData.itemSize\r\n : this.itemSize;\r\n\r\n // Update viewportWidth from rucInputData if provided, otherwise keep current or default\r\n this.viewportWidth =\r\n this.rucInputData?.viewportWidth !== undefined\r\n ? this.rucInputData.viewportWidth\r\n : this.viewportWidth;\r\n\r\n // Update viewportHeight from rucInputData if provided, otherwise keep current or default\r\n this.viewportHeight =\r\n this.rucInputData?.viewportHeight !== undefined\r\n ? this.rucInputData.viewportHeight\r\n : this.viewportHeight;\r\n }\r\n\r\n /**\r\n * Example public method that can be called by a parent component.\r\n * Scrolls the virtual scroll viewport to the specified index.\r\n * @param index The index of the item to scroll to.\r\n * @param behavior Optional scroll behavior ('auto', 'smooth').\r\n */\r\n public scrollToIndex(): void {\r\n const newClientHeight = document.getElementsByClassName(\r\n 'cdk-virtual-scroll-content-wrapper'\r\n )[0].clientHeight;\r\n if (this.virtualScrollViewport) {\r\n if (newClientHeight !== this.clientHeight) {\r\n this.clientHeight = document.getElementsByClassName(\r\n 'cdk-virtual-scroll-content-wrapper'\r\n )[0].clientHeight;\r\n document\r\n .getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0]\r\n .scrollIntoView({ behavior: 'auto', block: 'end' });\r\n }\r\n } else {\r\n console.warn(\r\n 'RuclibVirtualScrollComponent: Viewport not available to scroll.'\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * To handle the scroll position on top by using back to top icon\r\n * @returns scroll position at top\r\n */\r\n public handleScroll(): void {\r\n document\r\n .getElementsByClassName('cdk-virtual-scroll-content-wrapper')[0]\r\n .scrollIntoView({ behavior: 'auto', block: 'start' });\r\n }\r\n\r\n /**\r\n * To get the icon of back to top icon\r\n * @returns default: 'arrow_upward'\r\n */\r\n getBackToTopIcon(): string {\r\n return this.rucInputData?.backToTopIcon || 'arrow_upward';\r\n }\r\n\r\n /**\r\n * To get the label of back to top icon\r\n * @returns default: 'Back to Top'\r\n */\r\n getBackToTopLabel(): string {\r\n return this.rucInputData?.backToTopLabel || 'Back to Top';\r\n }\r\n\r\n /**\r\n * To get the color of icon\r\n * @returns default: false\r\n */\r\n getIconColor(): string {\r\n return this.rucInputData?.iconColor || 'primary';\r\n }\r\n\r\n /**\r\n * To check wheteher back to top icon shold be there or not in view\r\n * @returns default: false\r\n */\r\n isBackToTopIcon(): boolean {\r\n return this.rucInputData?.isBackToTopIcon || false;\r\n }\r\n\r\n /**\r\n * To get the thumb color of virtual scroll\r\n * @returns default: '#888'\r\n */\r\n getScrollbarThumbColor(): string {\r\n return this.rucInputData?.thumbColor || '#888';\r\n }\r\n\r\n /**\r\n * To get the track color of virtual scroll\r\n * @returns default: '#f1f1f1'\r\n */\r\n getScrollbarTrackColor(): string {\r\n return this.rucInputData?.trackColor || '#f1f1f1';\r\n }\r\n}\r\n","<cdk-virtual-scroll-viewport\r\n [style.scrollbar-color]=\"getScrollbarThumbColor() + ' ' + getScrollbarTrackColor()\"\r\n class=\"virtual-scrollar-wrapper\" itemSize=\"itemSize\" [style.width]=\"viewportWidth\" [style.height]=\"viewportHeight\">\r\n <ng-content></ng-content>\r\n</cdk-virtual-scroll-viewport>\r\n\r\n@if (isBackToTopIcon()) {\r\n <div class=\"virtual-scrollar__back-to-top\">\r\n <button class=\"virtual-scrollar__back-to-top-btn\" mat-mini-fab aria-label=\"getBackToTopLabel()\" (click)=\"handleScroll()\">\r\n <mat-icon color=\"{{getIconColor()}}\">{{getBackToTopIcon()}}</mat-icon>\r\n </button>\r\n </div>\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAwBa,4BAA4B,CAAA;AAPzC,IAAA,WAAA,GAAA;;QASW,IAAA,CAAA,YAAY,GAA0B,EAAE;AACjD,QAAA,IAAA,CAAA,QAAQ,GAAG,EAAE,CAAC;AACd,QAAA,IAAA,CAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,IAAA,CAAA,cAAc,GAAG,OAAO,CAAC;QACzB,IAAA,CAAA,YAAY,GAAG,CAAC;;QAGP,IAAA,CAAA,WAAW,GAAG,EAAE;AAmI1B,IAAA;IA7HC,QAAQ,GAAA;QACN,IAAI,CAAC,mBAAmB,EAAE;IAC5B;AAEA,IAAA,WAAW,CAAC,OAAsB,EAAA;;AAEhC,QAAA,IAAI,OAAO,CAAC,cAAc,CAAC,EAAE;YAC3B,IAAI,CAAC,mBAAmB,EAAE;QAC5B;IACF;IAEA,kBAAkB,GAAA;QAChB,MAAM,aAAa,GAAG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AA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDOa,eAAe,4WAAE,aAAa,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,OAAA,EAAA,QAAA,EAAA,UAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,QAAA,EAAA,SAAA,EAAA,SAAA,EAAA,UAAA,CAAA,EAAA,QAAA,EAAA,CAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAK/B,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAPxC,SAAS;+BACI,2BAA2B,EAAA,OAAA,EAC5B,CAAC,eAAe,EAAE,aAAa,CAAC,EAAA,eAAA,EAGxB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,0oBAAA,EAAA,MAAA,EAAA,CAAA,6PAAA,CAAA,EAAA;;sBAIhD;;sBAOA;;sBAEA,SAAS;uBAAC,wBAAwB;;;AEnCrC;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
3
|
+
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*Interface for defining the Virtual Scroll Input
|
|
7
|
+
*/
|
|
8
|
+
interface RucVirtualScrollInput {
|
|
9
|
+
/**
|
|
10
|
+
* The size of each item in the list in pixels.
|
|
11
|
+
*/
|
|
12
|
+
itemSize?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The width of the virtual scroll viewport. Can be a percentage, pixels, or other CSS unit.
|
|
15
|
+
*/
|
|
16
|
+
viewportWidth?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The height of the virtual scroll viewport. Can be a percentage, pixels, or other CSS unit.
|
|
19
|
+
*/
|
|
20
|
+
viewportHeight?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The name of the Material icon to use for the 'back to top' button.
|
|
23
|
+
*/
|
|
24
|
+
backToTopIcon?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The label text for the 'back to top' button.
|
|
27
|
+
*/
|
|
28
|
+
backToTopLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The color of the 'back to top' icon (e.g., 'primary', 'accent', 'warn').
|
|
31
|
+
*/
|
|
32
|
+
iconColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Determines whether to display the 'back to top' icon.
|
|
35
|
+
*/
|
|
36
|
+
isBackToTopIcon?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* A flag to indicate if the virtual scroll is currently loading data.
|
|
39
|
+
*/
|
|
40
|
+
isLoad?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The color of the scrollbar thumb.
|
|
43
|
+
*/
|
|
44
|
+
thumbColor?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The color of the scrollbar track.
|
|
47
|
+
*/
|
|
48
|
+
trackColor?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class RuclibVirtualScrollComponent implements OnInit, OnChanges {
|
|
52
|
+
rucInputData: RucVirtualScrollInput;
|
|
53
|
+
itemSize: number;
|
|
54
|
+
viewportWidth: string;
|
|
55
|
+
viewportHeight: string;
|
|
56
|
+
clientHeight: number;
|
|
57
|
+
customTheme: string;
|
|
58
|
+
virtualScrollViewport: CdkVirtualScrollViewport | undefined;
|
|
59
|
+
ngOnInit(): void;
|
|
60
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
61
|
+
ngAfterViewChecked(): void;
|
|
62
|
+
private updateInternalState;
|
|
63
|
+
/**
|
|
64
|
+
* Example public method that can be called by a parent component.
|
|
65
|
+
* Scrolls the virtual scroll viewport to the specified index.
|
|
66
|
+
* @param index The index of the item to scroll to.
|
|
67
|
+
* @param behavior Optional scroll behavior ('auto', 'smooth').
|
|
68
|
+
*/
|
|
69
|
+
scrollToIndex(): void;
|
|
70
|
+
/**
|
|
71
|
+
* To handle the scroll position on top by using back to top icon
|
|
72
|
+
* @returns scroll position at top
|
|
73
|
+
*/
|
|
74
|
+
handleScroll(): void;
|
|
75
|
+
/**
|
|
76
|
+
* To get the icon of back to top icon
|
|
77
|
+
* @returns default: 'arrow_upward'
|
|
78
|
+
*/
|
|
79
|
+
getBackToTopIcon(): string;
|
|
80
|
+
/**
|
|
81
|
+
* To get the label of back to top icon
|
|
82
|
+
* @returns default: 'Back to Top'
|
|
83
|
+
*/
|
|
84
|
+
getBackToTopLabel(): string;
|
|
85
|
+
/**
|
|
86
|
+
* To get the color of icon
|
|
87
|
+
* @returns default: false
|
|
88
|
+
*/
|
|
89
|
+
getIconColor(): string;
|
|
90
|
+
/**
|
|
91
|
+
* To check wheteher back to top icon shold be there or not in view
|
|
92
|
+
* @returns default: false
|
|
93
|
+
*/
|
|
94
|
+
isBackToTopIcon(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* To get the thumb color of virtual scroll
|
|
97
|
+
* @returns default: '#888'
|
|
98
|
+
*/
|
|
99
|
+
getScrollbarThumbColor(): string;
|
|
100
|
+
/**
|
|
101
|
+
* To get the track color of virtual scroll
|
|
102
|
+
* @returns default: '#f1f1f1'
|
|
103
|
+
*/
|
|
104
|
+
getScrollbarTrackColor(): string;
|
|
105
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RuclibVirtualScrollComponent, never>;
|
|
106
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RuclibVirtualScrollComponent, "uxp-ruclib-virtual-scroll", never, { "rucInputData": { "alias": "rucInputData"; "required": false; }; "customTheme": { "alias": "customTheme"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { RuclibVirtualScrollComponent };
|
package/package.json
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruc-lib/virtual-scroll",
|
|
3
|
-
"version": "
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "4.0.0",
|
|
5
4
|
"peerDependencies": {
|
|
6
|
-
"@angular/common": "^
|
|
7
|
-
"@angular/core": "^
|
|
8
|
-
"@angular/material": "^15.
|
|
9
|
-
"@angular/cdk": "15.2.9",
|
|
10
|
-
"@angular/platform-browser": "15.2.10"
|
|
5
|
+
"@angular/common": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
|
|
6
|
+
"@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
|
|
7
|
+
"@angular/material": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
|
|
11
8
|
},
|
|
12
9
|
"dependencies": {
|
|
13
10
|
"tslib": "^2.3.0"
|
|
14
11
|
},
|
|
15
|
-
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
-
},
|
|
18
12
|
"sideEffects": false,
|
|
19
|
-
"module": "
|
|
20
|
-
"es2020": "fesm2020/ruc-lib-virtual-scroll.mjs",
|
|
21
|
-
"esm2020": "esm2020/ruc-lib-virtual-scroll.mjs",
|
|
22
|
-
"fesm2020": "fesm2020/ruc-lib-virtual-scroll.mjs",
|
|
23
|
-
"fesm2015": "fesm2015/ruc-lib-virtual-scroll.mjs",
|
|
13
|
+
"module": "fesm2022/ruc-lib-virtual-scroll.mjs",
|
|
24
14
|
"typings": "index.d.ts",
|
|
25
15
|
"exports": {
|
|
26
16
|
"./package.json": {
|
|
@@ -28,11 +18,7 @@
|
|
|
28
18
|
},
|
|
29
19
|
".": {
|
|
30
20
|
"types": "./index.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"es2020": "./fesm2020/ruc-lib-virtual-scroll.mjs",
|
|
33
|
-
"es2015": "./fesm2015/ruc-lib-virtual-scroll.mjs",
|
|
34
|
-
"node": "./fesm2015/ruc-lib-virtual-scroll.mjs",
|
|
35
|
-
"default": "./fesm2020/ruc-lib-virtual-scroll.mjs"
|
|
21
|
+
"default": "./fesm2022/ruc-lib-virtual-scroll.mjs"
|
|
36
22
|
}
|
|
37
23
|
}
|
|
38
|
-
}
|
|
24
|
+
}
|
package/esm2020/index.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export * from './lib/ruclib-virtual-scroll.module';
|
|
2
|
-
export * from './lib/ruclib-virtual-scroll/ruclib-virtual-scroll.component';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxvQ0FBb0MsQ0FBQztBQUNuRCxjQUFjLDZEQUE2RCxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9saWIvcnVjbGliLXZpcnR1YWwtc2Nyb2xsLm1vZHVsZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3J1Y2xpYi12aXJ0dWFsLXNjcm9sbC9ydWNsaWItdmlydHVhbC1zY3JvbGwuY29tcG9uZW50JzsiXX0=
|