ngx-paginated-select 0.0.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.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # NgxPaginatedSelect
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
12
+
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
+
15
+ ```bash
16
+ ng generate --help
17
+ ```
18
+
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build ngx-paginated-select
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+ ```bash
35
+ cd dist/ngx-paginated-select
36
+ ```
37
+
38
+ 2. Run the `npm publish` command to publish your library to the npm registry:
39
+ ```bash
40
+ npm publish
41
+ ```
42
+
43
+ ## Running unit tests
44
+
45
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46
+
47
+ ```bash
48
+ ng test
49
+ ```
50
+
51
+ ## Running end-to-end tests
52
+
53
+ For end-to-end (e2e) testing, run:
54
+
55
+ ```bash
56
+ ng e2e
57
+ ```
58
+
59
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
60
+
61
+ ## Additional Resources
62
+
63
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -0,0 +1,151 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, ViewChild, Output, Input, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i2 from '@angular/forms';
6
+ import { FormsModule } from '@angular/forms';
7
+ import { Subject, debounceTime, distinctUntilChanged } from 'rxjs';
8
+
9
+ class NgxPaginatedSelectService {
10
+ constructor() { }
11
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxPaginatedSelectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
12
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxPaginatedSelectService, providedIn: 'root' });
13
+ }
14
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxPaginatedSelectService, decorators: [{
15
+ type: Injectable,
16
+ args: [{
17
+ providedIn: 'root'
18
+ }]
19
+ }], ctorParameters: () => [] });
20
+
21
+ class PaginatedSelectComponent {
22
+ fetcher;
23
+ labelKey;
24
+ placeholder = 'Select item...';
25
+ selectionChange = new EventEmitter();
26
+ scrollContainer;
27
+ items = [];
28
+ searchQuery = '';
29
+ page = 1;
30
+ hasMore = true;
31
+ loading = false;
32
+ searchSubject = new Subject();
33
+ ngOnInit() {
34
+ this.searchSubject
35
+ .pipe(debounceTime(300), distinctUntilChanged())
36
+ .subscribe((query) => {
37
+ this.resetAndFetch(query);
38
+ });
39
+ this.resetAndFetch('');
40
+ }
41
+ onSearchChange(query) {
42
+ this.searchSubject.next(query);
43
+ }
44
+ async resetAndFetch(query) {
45
+ this.page = 1;
46
+ this.items = [];
47
+ this.hasMore = true;
48
+ await this.loadData(query, this.page, true);
49
+ }
50
+ async loadData(query, page, isReset) {
51
+ if (this.loading || !this.fetcher)
52
+ return;
53
+ this.loading = true;
54
+ try {
55
+ const res = await this.fetcher({ search: query, page });
56
+ this.items = isReset ? res.data : [...this.items, ...res.data];
57
+ this.hasMore = res.hasMore;
58
+ }
59
+ catch (err) {
60
+ console.error('Failed to load paginated data', err);
61
+ }
62
+ finally {
63
+ this.loading = false;
64
+ }
65
+ }
66
+ onScroll() {
67
+ if (!this.scrollContainer)
68
+ return;
69
+ const el = this.scrollContainer.nativeElement;
70
+ const isAtBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 20;
71
+ if (isAtBottom && this.hasMore && !this.loading) {
72
+ this.page++;
73
+ this.loadData(this.searchQuery, this.page, false);
74
+ }
75
+ }
76
+ selectItem(item) {
77
+ this.selectionChange.emit(item);
78
+ }
79
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PaginatedSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
80
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.25", type: PaginatedSelectComponent, isStandalone: true, selector: "lib-paginated-select", inputs: { fetcher: "fetcher", labelKey: "labelKey", placeholder: "placeholder" }, outputs: { selectionChange: "selectionChange" }, viewQueries: [{ propertyName: "scrollContainer", first: true, predicate: ["scrollContainer"], descendants: true }], ngImport: i0, template: `
81
+ <div class="paginated-select">
82
+ <input
83
+ type="text"
84
+ [placeholder]="placeholder"
85
+ [(ngModel)]="searchQuery"
86
+ (ngModelChange)="onSearchChange($event)"
87
+ />
88
+
89
+ <div class="dropdown-list" #scrollContainer (scroll)="onScroll()">
90
+ <div
91
+ *ngFor="let item of items"
92
+ class="option-item"
93
+ (click)="selectItem(item)"
94
+ >
95
+ {{ labelKey ? ($any(item)[labelKey]) : item }}
96
+ </div>
97
+
98
+ <div *ngIf="loading" class="loading-indicator">Loading...</div>
99
+ <div *ngIf="!loading && items.length === 0" class="no-data">No results found</div>
100
+ </div>
101
+ </div>
102
+ `, isInline: true, styles: [".paginated-select{position:relative;width:100%}.dropdown-list{max-height:200px;overflow-y:auto;border:1px solid #ccc}.option-item{padding:8px 12px;cursor:pointer}.option-item:hover{background-color:#f0f0f0}.loading-indicator,.no-data{padding:8px;text-align:center;color:#888}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
103
+ }
104
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PaginatedSelectComponent, decorators: [{
105
+ type: Component,
106
+ args: [{ selector: 'lib-paginated-select', standalone: true, imports: [CommonModule, FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
107
+ <div class="paginated-select">
108
+ <input
109
+ type="text"
110
+ [placeholder]="placeholder"
111
+ [(ngModel)]="searchQuery"
112
+ (ngModelChange)="onSearchChange($event)"
113
+ />
114
+
115
+ <div class="dropdown-list" #scrollContainer (scroll)="onScroll()">
116
+ <div
117
+ *ngFor="let item of items"
118
+ class="option-item"
119
+ (click)="selectItem(item)"
120
+ >
121
+ {{ labelKey ? ($any(item)[labelKey]) : item }}
122
+ </div>
123
+
124
+ <div *ngIf="loading" class="loading-indicator">Loading...</div>
125
+ <div *ngIf="!loading && items.length === 0" class="no-data">No results found</div>
126
+ </div>
127
+ </div>
128
+ `, styles: [".paginated-select{position:relative;width:100%}.dropdown-list{max-height:200px;overflow-y:auto;border:1px solid #ccc}.option-item{padding:8px 12px;cursor:pointer}.option-item:hover{background-color:#f0f0f0}.loading-indicator,.no-data{padding:8px;text-align:center;color:#888}\n"] }]
129
+ }], propDecorators: { fetcher: [{
130
+ type: Input
131
+ }], labelKey: [{
132
+ type: Input
133
+ }], placeholder: [{
134
+ type: Input
135
+ }], selectionChange: [{
136
+ type: Output
137
+ }], scrollContainer: [{
138
+ type: ViewChild,
139
+ args: ['scrollContainer']
140
+ }] } });
141
+
142
+ /*
143
+ * Public API Surface of ngx-paginated-select
144
+ */
145
+
146
+ /**
147
+ * Generated bundle index. Do not edit.
148
+ */
149
+
150
+ export { NgxPaginatedSelectService, PaginatedSelectComponent };
151
+ //# sourceMappingURL=ngx-paginated-select.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-paginated-select.mjs","sources":["../../../projects/ngx-paginated-select/src/lib/ngx-paginated-select.service.ts","../../../projects/ngx-paginated-select/src/lib/ngx-paginated-select.component.ts","../../../projects/ngx-paginated-select/src/public-api.ts","../../../projects/ngx-paginated-select/src/ngx-paginated-select.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NgxPaginatedSelectService {\n\n constructor() { }\n}\n","import { \n Component, Input, Output, EventEmitter, \n ElementRef, ViewChild, ChangeDetectionStrategy \n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { Subject, debounceTime, distinctUntilChanged } from 'rxjs';\n\nexport interface FetcherParams {\n search: string;\n page: number;\n}\n\nexport interface FetcherResponse<T> {\n data: T[];\n hasMore: boolean;\n}\n\n@Component({\n selector: 'lib-paginated-select',\n standalone: true,\n imports: [CommonModule, FormsModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"paginated-select\">\n <input \n type=\"text\" \n [placeholder]=\"placeholder\" \n [(ngModel)]=\"searchQuery\" \n (ngModelChange)=\"onSearchChange($event)\" \n />\n \n <div class=\"dropdown-list\" #scrollContainer (scroll)=\"onScroll()\">\n <div \n *ngFor=\"let item of items\" \n class=\"option-item\" \n (click)=\"selectItem(item)\"\n >\n {{ labelKey ? ($any(item)[labelKey]) : item }}\n </div>\n\n <div *ngIf=\"loading\" class=\"loading-indicator\">Loading...</div>\n <div *ngIf=\"!loading && items.length === 0\" class=\"no-data\">No results found</div>\n </div>\n </div>\n `,\n styles: [`\n .paginated-select { position: relative; width: 100%; }\n .dropdown-list { max-height: 200px; overflow-y: auto; border: 1px solid #ccc; }\n .option-item { padding: 8px 12px; cursor: pointer; }\n .option-item:hover { background-color: #f0f0f0; }\n .loading-indicator, .no-data { padding: 8px; text-align: center; color: #888; }\n `]\n})\nexport class PaginatedSelectComponent<T = any> {\n @Input() fetcher!: (params: FetcherParams) => Promise<FetcherResponse<T>>;\n @Input() labelKey?: string;\n @Input() placeholder: string = 'Select item...';\n @Output() selectionChange = new EventEmitter<T>();\n\n @ViewChild('scrollContainer') scrollContainer!: ElementRef<HTMLDivElement>;\n\n items: T[] = [];\n searchQuery: string = '';\n page: number = 1;\n hasMore: boolean = true;\n loading: boolean = false;\n\n private searchSubject = new Subject<string>();\n\n ngOnInit() {\n this.searchSubject\n .pipe(debounceTime(300), distinctUntilChanged())\n .subscribe((query) => {\n this.resetAndFetch(query);\n });\n\n this.resetAndFetch('');\n }\n\n onSearchChange(query: string) {\n this.searchSubject.next(query);\n }\n\n async resetAndFetch(query: string) {\n this.page = 1;\n this.items = [];\n this.hasMore = true;\n await this.loadData(query, this.page, true);\n }\n\n async loadData(query: string, page: number, isReset: boolean) {\n if (this.loading || !this.fetcher) return;\n\n this.loading = true;\n try {\n const res = await this.fetcher({ search: query, page });\n this.items = isReset ? res.data : [...this.items, ...res.data];\n this.hasMore = res.hasMore;\n } catch (err) {\n console.error('Failed to load paginated data', err);\n } finally {\n this.loading = false;\n }\n }\n\n onScroll() {\n if (!this.scrollContainer) return;\n const el = this.scrollContainer.nativeElement;\n const isAtBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 20;\n\n if (isAtBottom && this.hasMore && !this.loading) {\n this.page++;\n this.loadData(this.searchQuery, this.page, false);\n }\n }\n\n selectItem(item: T) {\n this.selectionChange.emit(item);\n }\n}","/*\n * Public API Surface of ngx-paginated-select\n */\n\nexport * from './lib/ngx-paginated-select.service';\nexport * from './lib/ngx-paginated-select.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAKa,yBAAyB,CAAA;AAEpC,IAAA,WAAA,GAAA,EAAgB;wGAFL,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,cAFxB,MAAM,EAAA,CAAA;;4FAEP,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAHrC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;MCkDY,wBAAwB,CAAA;AAC1B,IAAA,OAAO;AACP,IAAA,QAAQ;IACR,WAAW,GAAW,gBAAgB;AACrC,IAAA,eAAe,GAAG,IAAI,YAAY,EAAK;AAEnB,IAAA,eAAe;IAE7C,KAAK,GAAQ,EAAE;IACf,WAAW,GAAW,EAAE;IACxB,IAAI,GAAW,CAAC;IAChB,OAAO,GAAY,IAAI;IACvB,OAAO,GAAY,KAAK;AAEhB,IAAA,aAAa,GAAG,IAAI,OAAO,EAAU;IAE7C,QAAQ,GAAA;AACN,QAAA,IAAI,CAAC;aACF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,oBAAoB,EAAE;AAC9C,aAAA,SAAS,CAAC,CAAC,KAAK,KAAI;AACnB,YAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;AAC3B,QAAA,CAAC,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A,EAAA,IAAA,EAAA,EAAA,CAAA,oBAAA,EAAA,QAAA,EAAA,8MAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,eAAA,EAAA,QAAA,EAAA,2CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,OAAA,EAAA,QAAA,EAAA,qDAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,UAAA,EAAA,SAAA,EAAA,gBAAA,CAAA,EAAA,OAAA,EAAA,CAAA,eAAA,CAAA,EAAA,QAAA,EAAA,CAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FAiCxB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBApCpC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,sBAAsB,EAAA,UAAA,EACpB,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,EAAE,WAAW,CAAC,EAAA,eAAA,EACpB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EACpC;;;;;;;;;;;;;;;;;;;;;;AAsBT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,uRAAA,CAAA,EAAA;8BAUQ,OAAO,EAAA,CAAA;sBAAf;gBACQ,QAAQ,EAAA,CAAA;sBAAhB;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACS,eAAe,EAAA,CAAA;sBAAxB;gBAE6B,eAAe,EAAA,CAAA;sBAA5C,SAAS;uBAAC,iBAAiB;;;AC5D9B;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="ngx-paginated-select" />
5
+ export * from './public-api';
@@ -0,0 +1,31 @@
1
+ import { EventEmitter, ElementRef } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export interface FetcherParams {
4
+ search: string;
5
+ page: number;
6
+ }
7
+ export interface FetcherResponse<T> {
8
+ data: T[];
9
+ hasMore: boolean;
10
+ }
11
+ export declare class PaginatedSelectComponent<T = any> {
12
+ fetcher: (params: FetcherParams) => Promise<FetcherResponse<T>>;
13
+ labelKey?: string;
14
+ placeholder: string;
15
+ selectionChange: EventEmitter<T>;
16
+ scrollContainer: ElementRef<HTMLDivElement>;
17
+ items: T[];
18
+ searchQuery: string;
19
+ page: number;
20
+ hasMore: boolean;
21
+ loading: boolean;
22
+ private searchSubject;
23
+ ngOnInit(): void;
24
+ onSearchChange(query: string): void;
25
+ resetAndFetch(query: string): Promise<void>;
26
+ loadData(query: string, page: number, isReset: boolean): Promise<void>;
27
+ onScroll(): void;
28
+ selectItem(item: T): void;
29
+ static ɵfac: i0.ɵɵFactoryDeclaration<PaginatedSelectComponent<any>, never>;
30
+ static ɵcmp: i0.ɵɵComponentDeclaration<PaginatedSelectComponent<any>, "lib-paginated-select", never, { "fetcher": { "alias": "fetcher"; "required": false; }; "labelKey": { "alias": "labelKey"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; }, { "selectionChange": "selectionChange"; }, never, never, true, never>;
31
+ }
@@ -0,0 +1,6 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class NgxPaginatedSelectService {
3
+ constructor();
4
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxPaginatedSelectService, never>;
5
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxPaginatedSelectService>;
6
+ }
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "ngx-paginated-select",
3
+ "version": "0.0.1",
4
+ "peerDependencies": {
5
+ "@angular/common": "^19.2.0",
6
+ "@angular/core": "^19.2.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false,
12
+ "module": "fesm2022/ngx-paginated-select.mjs",
13
+ "typings": "index.d.ts",
14
+ "exports": {
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ },
18
+ ".": {
19
+ "types": "./index.d.ts",
20
+ "default": "./fesm2022/ngx-paginated-select.mjs"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from './lib/ngx-paginated-select.service';
2
+ export * from './lib/ngx-paginated-select.component';