ghocomps 0.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/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+ ij_typescript_use_double_quotes = false
14
+
15
+ [*.md]
16
+ max_line_length = off
17
+ trim_trailing_whitespace = false
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+ "version": "0.2.0",
4
+ "configurations": [
5
+ {
6
+ "name": "ng serve",
7
+ "type": "chrome",
8
+ "request": "launch",
9
+ "preLaunchTask": "npm: start",
10
+ "url": "http://localhost:4200/"
11
+ },
12
+ {
13
+ "name": "ng test",
14
+ "type": "chrome",
15
+ "request": "launch",
16
+ "preLaunchTask": "npm: test",
17
+ "url": "http://localhost:9876/debug.html"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+ "version": "2.0.0",
4
+ "tasks": [
5
+ {
6
+ "type": "npm",
7
+ "script": "start",
8
+ "isBackground": true,
9
+ "problemMatcher": {
10
+ "owner": "typescript",
11
+ "pattern": "$tsc",
12
+ "background": {
13
+ "activeOnStart": true,
14
+ "beginsPattern": {
15
+ "regexp": "(.*?)"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation complete"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "type": "npm",
25
+ "script": "test",
26
+ "isBackground": true,
27
+ "problemMatcher": {
28
+ "owner": "typescript",
29
+ "pattern": "$tsc",
30
+ "background": {
31
+ "activeOnStart": true,
32
+ "beginsPattern": {
33
+ "regexp": "(.*?)"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation complete"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # GHOComps
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.5.
4
+
5
+ ## Development server
6
+
7
+ To start a local development server, run:
8
+
9
+ ```bash
10
+ ng serve
11
+ ```
12
+
13
+ Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14
+
15
+ ## Code scaffolding
16
+
17
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18
+
19
+ ```bash
20
+ ng generate component component-name
21
+ ```
22
+
23
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24
+
25
+ ```bash
26
+ ng generate --help
27
+ ```
28
+
29
+ ## Building
30
+
31
+ To build the project run:
32
+
33
+ ```bash
34
+ ng build
35
+ ```
36
+
37
+ This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38
+
39
+ ## Running unit tests
40
+
41
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
42
+
43
+ ```bash
44
+ ng test
45
+ ```
46
+
47
+ ## Running end-to-end tests
48
+
49
+ For end-to-end (e2e) testing, run:
50
+
51
+ ```bash
52
+ ng e2e
53
+ ```
54
+
55
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56
+
57
+ ## Additional Resources
58
+
59
+ 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.
package/angular.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "newProjectRoot": "projects",
5
+ "projects": {
6
+ "GHOComps": {
7
+ "projectType": "library",
8
+ "root": "projects/ghocomps",
9
+ "sourceRoot": "projects/ghocomps/src",
10
+ "prefix": "lib",
11
+ "architect": {
12
+ "build": {
13
+ "builder": "@angular/build:ng-packagr",
14
+ "configurations": {
15
+ "production": {
16
+ "tsConfig": "projects/ghocomps/tsconfig.lib.prod.json"
17
+ },
18
+ "development": {
19
+ "tsConfig": "projects/ghocomps/tsconfig.lib.json"
20
+ }
21
+ },
22
+ "defaultConfiguration": "production"
23
+ },
24
+ "test": {
25
+ "builder": "@angular/build:karma",
26
+ "options": {
27
+ "tsConfig": "projects/ghocomps/tsconfig.spec.json"
28
+ }
29
+ }
30
+ }
31
+ }
32
+ },
33
+ "cli": {
34
+ "analytics": false
35
+ }
36
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "ghocomps",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "watch": "ng build --watch --configuration development",
9
+ "test": "ng test"
10
+ },
11
+ "prettier": {
12
+ "printWidth": 100,
13
+ "singleQuote": true,
14
+ "overrides": [
15
+ {
16
+ "files": "*.html",
17
+ "options": {
18
+ "parser": "angular"
19
+ }
20
+ }
21
+ ]
22
+ },
23
+ "private": false,
24
+ "dependencies": {
25
+ "@angular/cdk": "^20.2.14",
26
+ "@angular/common": "^20.3.0",
27
+ "@angular/compiler": "^20.3.0",
28
+ "@angular/core": "^20.3.0",
29
+ "@angular/forms": "^20.3.0",
30
+ "@angular/material": "^20.2.14",
31
+ "@angular/platform-browser": "^20.3.0",
32
+ "@angular/router": "^20.3.0",
33
+ "rxjs": "~7.8.0",
34
+ "tslib": "^2.3.0"
35
+ },
36
+ "devDependencies": {
37
+ "@angular/build": "^20.3.13",
38
+ "@angular/cli": "^20.3.5",
39
+ "@angular/compiler-cli": "^20.3.0",
40
+ "@types/jasmine": "~5.1.0",
41
+ "jasmine-core": "~5.9.0",
42
+ "karma": "~6.4.0",
43
+ "karma-chrome-launcher": "~3.2.0",
44
+ "karma-coverage": "~2.2.0",
45
+ "karma-jasmine": "~5.1.0",
46
+ "karma-jasmine-html-reporter": "~2.1.0",
47
+ "ng-packagr": "^20.3.0",
48
+ "typescript": "~5.9.2"
49
+ }
50
+ }
@@ -0,0 +1,63 @@
1
+ # GHOComps
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.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 GHOComps
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/ghocomps
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,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ghocomps",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "ghocomps",
3
+ "version": "0.0.1",
4
+ "peerDependencies": {
5
+ "@angular/common": "^20.3.0",
6
+ "@angular/core": "^20.3.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false
12
+ }
@@ -0,0 +1,298 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import {
3
+ ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, HostListener,
4
+ Input, OnInit, SimpleChanges
5
+ } from '@angular/core';
6
+ import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
7
+ import { GHOdropdown } from "./dropdown";
8
+ import { MatCardModule } from "@angular/material/card";
9
+ import { MatCalendar } from "@angular/material/datepicker";
10
+ import { provideNativeDateAdapter } from '@angular/material/core';
11
+ import { MatDatepickerModule } from '@angular/material/datepicker';
12
+ import { DatePipe } from '@angular/common';
13
+
14
+ @Component({
15
+ selector: 'gho-date',
16
+ standalone: true,
17
+ imports: [CommonModule, FormsModule, GHOdropdown, MatCalendar, MatDatepickerModule,
18
+ MatCardModule, DatePipe],
19
+ template:`
20
+ <div style="height: 55px !important;">
21
+ <div style="height: 18px !important;">
22
+ @if(datavalid())
23
+ {
24
+ <div [ngStyle]="{ margin: '-3px 5px' }" class="input-label">{{label}}
25
+ </div>
26
+ }
27
+ </div>
28
+ <table>
29
+ <tr>
30
+ <td>
31
+ <div (click)="toggleDropdown()" [ngClass]="getclass()">
32
+ <span>{{ gettxt()}}</span>
33
+ <i class="bi bi-caret-down-fill arrow-icon" [class.rotate]="isOpen"></i>
34
+ </div>
35
+ </td>
36
+ @if(filter && datavalid() )
37
+ {
38
+ <td>
39
+ <div (click)="clear()" [ngClass]="getclearclass()">
40
+ <i class="bi bi-x-lg "></i>
41
+ </div>
42
+ </td> }
43
+
44
+
45
+ </tr>
46
+ </table>
47
+ </div>
48
+ @if(isOpen){
49
+ <div class="dropdown-menu show">
50
+ <table>
51
+ <tr class="bb">
52
+ <td class="pl10">
53
+ <gho-dropdown [options]="months" [(sharedValue)]="m" (selectionchange)="onmodelchange($event,'m')" [filter]=false
54
+ label="Month"></gho-dropdown>
55
+ </td>
56
+ <td class="">
57
+ <gho-dropdown [options]="days" [(sharedValue)]="d" (selectionchange)="onmodelchange($event,'d')" [filter]=false
58
+ label="Day"></gho-dropdown>
59
+ </td>
60
+ <td class="pr10">
61
+ <gho-dropdown [options]="years" [(sharedValue)]="y" (selectionchange)="onmodelchange($event,'y')" [filter]=false
62
+ label="Year"></gho-dropdown>
63
+
64
+ </td>
65
+
66
+ <td class="pr10 pointer" style="width: 30px; padding-top: 10px;">
67
+ <div (click)="isOpen=false" >
68
+ <i class="bi bi-check2 bold"></i>
69
+ </div>
70
+ </td>
71
+ </tr>
72
+
73
+ <tr>
74
+ <td colspan="5">
75
+ <mat-calendar (selectedChange)="onDateChangeFromCalender($event)">
76
+ </mat-calendar>
77
+ </td>
78
+ </tr>
79
+
80
+ </table>
81
+
82
+ </div>
83
+ }
84
+ `,
85
+ styleUrl: './input.css',
86
+ providers: [provideNativeDateAdapter(), DatePipe,
87
+ {
88
+ provide: NG_VALUE_ACCESSOR,
89
+ useExisting: forwardRef(() => GHODate),
90
+ multi: true
91
+ }],
92
+ changeDetection: ChangeDetectionStrategy.OnPush,
93
+ })
94
+ export class GHODate implements ControlValueAccessor, OnInit {
95
+ constructor(private el: ElementRef, private cdr: ChangeDetectorRef,
96
+ private datePipe: DatePipe) { }
97
+ @Input() options: any[] = [];
98
+ @Input() placeholder: string = 'Select an option';
99
+ @Input() showclear: boolean = true;
100
+ @Input() appearance: string = "outline"
101
+ @Input() label: string = "";
102
+ @Input() filter: boolean = true;
103
+ public value: string = "";
104
+ public disabled: boolean = false;
105
+ listdata: { label: string; value: string }[] = [];
106
+ isOpen = false;
107
+ selectedtxt: string = "";
108
+ days: { value: string }[] = []
109
+ years: { value: string }[] = [];
110
+ months: { value: string, name: string }[] = [];
111
+ currentYear: number = new Date().getFullYear();
112
+ d: any;
113
+ m: any;
114
+ y: any;
115
+
116
+
117
+ // Writes a new value to the element
118
+ writeValue(value: any): void {
119
+ this.value = value;
120
+ if (this.value !== undefined && this.value !== null) {
121
+ const date = new Date(value);
122
+ if (!date) {
123
+ this.d = null;
124
+ this.m = null;
125
+ this.y = null;
126
+ }
127
+ else {
128
+ const formatted = this.datePipe.transform(date, 'MM/dd/yyyy');
129
+ if (formatted !== undefined && formatted !== null) {
130
+ const [month, day, year] = formatted.split('/').map(Number);
131
+ this.m = month,
132
+ this.y = year;
133
+ this.d = day
134
+ }
135
+ }
136
+ }
137
+ }
138
+
139
+ onmodelchange(e: any, t: any) {
140
+ if (t == "d") { this.d = e.value }
141
+ if (t == "m") { this.m = e.value }
142
+ if (t == "y") { this.y = e.value }
143
+ this.setdt();
144
+ }
145
+
146
+ ngOnInit(): void {
147
+ this.populateYears();
148
+ this.populateMonths();
149
+ this.populateDays(31);
150
+ }
151
+
152
+
153
+ setdt() {
154
+ if (this.d == 0 || this.m == 0 || this.y == 0) { this.value = "" }
155
+ else {
156
+ this.value = this.m + " - " + this.d + " - " + this.y
157
+ }
158
+ this.onChange(this.value);
159
+ this.onTouched();
160
+ }
161
+
162
+ onDateChangeFromCalender(date: Date | null) {
163
+ if (!date) return;
164
+ const formatted = this.datePipe.transform(date, 'MM/dd/yyyy');
165
+ if (formatted !== undefined && formatted !== null) {
166
+ const [month, day, year] = formatted.split('/').map(Number);
167
+ this.m = month,
168
+ this.y = year;
169
+ this.d = day
170
+ }
171
+ this.setdt()
172
+ this.isOpen = false;
173
+ this.cdr.detectChanges();
174
+ }
175
+
176
+ populateMonths() {
177
+ this.months = [
178
+ { value: "1", name: 'January' },
179
+ { value: "2", name: 'February' },
180
+ { value: "3", name: 'March' },
181
+ { value: "4", name: 'April' },
182
+ { value: "5", name: 'May' },
183
+ { value: "6", name: 'June' },
184
+ { value: "7", name: 'July' },
185
+ { value: "8", name: 'August' },
186
+ { value: "9", name: 'September' },
187
+ { value: "10", name: 'October' },
188
+ { value: "11", name: 'November' },
189
+ { value: "12", name: 'December' }
190
+ ];
191
+ }
192
+ populateYears(start = (this.currentYear - 95), end = 1 + new Date().getFullYear()) {
193
+ for (let year = end; year >= start; year--) {
194
+ this.years.push({ value: year.toString() });
195
+ }
196
+ }
197
+
198
+ populateDays(start = 1, end = 31) {
199
+ for (let i: number = 1; i < 32; i++) {
200
+ this.days.push({ value: i.toString() });
201
+ }
202
+ }
203
+
204
+ gettxt() {
205
+ if (this.datavalid()) { return this.value }
206
+ else { return this.label }
207
+ }
208
+
209
+ toggleDropdown(): void {
210
+ this.isOpen = !this.isOpen;
211
+ }
212
+
213
+ clear() {
214
+ this.value = "";
215
+ this.onChange(this.value);
216
+ this.onTouched();
217
+ }
218
+
219
+ closeDropdown(): void {
220
+ this.isOpen = false;
221
+ }
222
+
223
+ datavalid() {
224
+ if (this.value === undefined || this.value == null || this.value == "" || this.value == "0") {
225
+ return false;
226
+ }
227
+ else { return true; }
228
+ }
229
+
230
+
231
+ // Functions to call when the value changes or the control is touched
232
+ onChange: any = () => { };
233
+ onTouched: any = () => { };
234
+
235
+ // Registers a callback function that is called when the control's value changes in the UI
236
+ registerOnChange(fn: any): void {
237
+ this.isOpen = false;
238
+ this.onChange = fn;
239
+ }
240
+
241
+ // Registers a callback function that is called whenever the control receives a touch event
242
+ registerOnTouched(fn: any): void {
243
+ this.onTouched = fn;
244
+ }
245
+
246
+
247
+
248
+ // Sets the disabled state of the control
249
+ setDisabledState?(isDisabled: boolean): void {
250
+ this.disabled = isDisabled;
251
+ }
252
+
253
+
254
+ onSelectionChange(v: any) {
255
+ this.isOpen = false;
256
+ this.selectedtxt = v.label;
257
+ const newValue = v.value;
258
+ this.value = newValue;
259
+ this.onChange(newValue); // Notify Angular forms about the change
260
+ this.onTouched(); // Mark the control as touched
261
+ }
262
+
263
+
264
+
265
+ @HostListener('document:click', ['$event'])
266
+ onOutsideClick(event: Event): void {
267
+ if (!this.el.nativeElement.contains(event.target)) {
268
+ this.isOpen = false;
269
+ }
270
+ }
271
+
272
+
273
+ getclearclass() {
274
+ if (this.appearance == "outline") {
275
+ if (this.datavalid() && this.showclear) { return "input-outline-filter-img"; }
276
+ }
277
+ else { return "input-mat-img "; }
278
+ return "input-mat";
279
+ }
280
+ getclass() {
281
+ if (this.appearance == "outline") {
282
+ let css = " d-flex gap-3"
283
+ if (!this.filter) { css = "input-outline" }
284
+
285
+ if (this.filter) { if (!this.datavalid()) { css = "input-outline" } }
286
+
287
+ if (this.filter) { if (this.datavalid()) { css = "input-outline-filter " } }
288
+
289
+ if (!this.showclear) { css = "input-outline" }
290
+
291
+ return css + " input d-flex gap-3 "
292
+ }
293
+ else {
294
+ return "input-mat d-flex gap-3 "
295
+ }
296
+ }
297
+
298
+ }
@@ -0,0 +1,189 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ ChangeDetectorRef, Component, ElementRef, EventEmitter, HostListener, Input,
5
+ NgZone, Output, SimpleChanges,
6
+ OnChanges
7
+ } from '@angular/core';
8
+ import { FormsModule } from '@angular/forms';
9
+
10
+ @Component({
11
+ selector: 'gho-dropdown',
12
+ changeDetection: ChangeDetectionStrategy.OnPush,
13
+ imports: [CommonModule, FormsModule],
14
+ template: `
15
+ <div style="height: 55px !important;">
16
+ <div style="height: 18px !important;">
17
+ @if(datavalid())
18
+ {
19
+ <div [ngStyle]="{ margin: '-3px 5px' }" class="input-label">{{label}}
20
+ </div>
21
+ }
22
+ </div>
23
+ <table>
24
+ <tr>
25
+ <td>
26
+ <div (click)="toggleDropdown()" [ngClass]="getclass()">
27
+ <span>{{selectedtxt}}</span>
28
+ <i class="bi bi-caret-down-fill arrow-icon" [class.rotate]="isOpen"></i>
29
+ </div>
30
+ </td>
31
+ @if(filter && datavalid() )
32
+ {
33
+ <td>
34
+ <div (click)="clear()" [ngClass]="getclearclass()">
35
+ <i class="bi bi-x-lg "></i>
36
+ </div>
37
+ </td> }
38
+ </tr>
39
+ </table>
40
+ </div>
41
+ @if(isOpen){
42
+ <div class="dropdown-menu show ">
43
+ <div class="list-panel">
44
+ @for (dlitem of listdata; track dlitem) {
45
+ <div class="list-item " (click)="onSelectionChange(dlitem)" [class.list-item-selected]="dlitem.value == sharedValue">
46
+ <table class="w100">
47
+ <tr>
48
+ <td>
49
+ {{ dlitem.label }}
50
+ </td>
51
+ @if(dlitem.value == sharedValue){
52
+ <td class="right" style="width:30px;"> <i class="bi bi-check2"></i> </td>}
53
+ </tr>
54
+ </table>
55
+ </div>
56
+ }
57
+ </div>
58
+ <table class=w100>
59
+ <tr class="bt ">
60
+ <td class="p10" (click)="clear()"><span matButton class="ghoddl-btn "> Clear </span> </td>
61
+ <td class="p10" (click)="closeDropdown()"><span matButton class="ghoddl-btn "> Cancel </span> </td>
62
+ </tr>
63
+ </table>
64
+ </div>
65
+ }
66
+ `,
67
+ styleUrl: './input.css',
68
+ })
69
+ export class GHOdropdown implements OnChanges {
70
+ constructor(private el: ElementRef, private cdr: ChangeDetectorRef, private ngZone: NgZone) { }
71
+ @Input() options: any[] = [];
72
+ @Input() placeholder: string = 'Select an option';
73
+ @Input() showclear: boolean = true;
74
+ @Input() appearance: string = "outline"
75
+ @Input() label: string = "";
76
+ @Input() filter: boolean = true;
77
+ listdata: { label: string; value: string }[] = [];
78
+ isOpen = false;
79
+ selectedtxt: string = "";
80
+
81
+ @Input() sharedValue: string = '';
82
+ @Output() sharedValueChange = new EventEmitter<string>();
83
+ @Output() selectionchange = new EventEmitter<([])>();
84
+
85
+
86
+
87
+ onModelChange(v: string): void {
88
+ this.sharedValue = v;
89
+ this.sharedValueChange.emit(v);
90
+ this.setlabel();
91
+ }
92
+ setlabel() {
93
+ if (this.listdata.length > 0) {
94
+ for (let i: number = 0; i < this.listdata.length; i++) {
95
+
96
+ if (this.sharedValue &&this.listdata[i].value.toString() == this.sharedValue.toString()) {
97
+ this.selectedtxt = this.listdata[i].label
98
+ break;
99
+ }
100
+ else {
101
+ this.selectedtxt = this.label
102
+ }
103
+ }
104
+ }
105
+ else { this.selectedtxt = this.label }
106
+ }
107
+
108
+
109
+ ngOnChanges(changes: SimpleChanges) {
110
+ if (changes['options']) {
111
+ this.listdata = []; debugger;
112
+ const allKeys = Array.from(
113
+ new Set(this.options.flatMap(item => Object.keys(item)))
114
+ );
115
+ for (let i: number = 0; i < this.options.length; i++) {
116
+ if (allKeys.length == 1) {
117
+ this.listdata.push({ label: this.options[i][allKeys[0]], value: this.options[i][allKeys[0]] })
118
+ }
119
+ else {
120
+ this.listdata.push({ label: this.options[i][allKeys[1]], value: this.options[i][allKeys[0]] })
121
+ }
122
+ }
123
+ this.setlabel();
124
+ }
125
+ if (changes['sharedValue']) {
126
+ this.setlabel();
127
+ }
128
+ }
129
+
130
+
131
+ toggleDropdown(): void {
132
+ this.isOpen = !this.isOpen;
133
+ }
134
+
135
+ clear() {
136
+ this.onModelChange("")
137
+ this.isOpen = false;
138
+ }
139
+
140
+ closeDropdown(): void {
141
+ this.isOpen = false;
142
+ }
143
+
144
+ onSelectionChange(v: any) {
145
+ this.isOpen = false;
146
+ this.onModelChange(v.value);
147
+ this.selectionchange.emit(v);
148
+ }
149
+
150
+ datavalid() {
151
+ if (this.label != this.selectedtxt) { return true }
152
+ if (this.label == this.selectedtxt) { return false }
153
+ return false;
154
+ }
155
+
156
+ @HostListener('document:click', ['$event'])
157
+ onOutsideClick(event: Event): void {
158
+ if (!this.el.nativeElement.contains(event.target)) {
159
+ this.isOpen = false;
160
+ }
161
+ }
162
+
163
+
164
+ getclearclass() {
165
+ if (this.appearance == "outline") {
166
+ if (this.datavalid() && this.showclear) { return "input-outline-filter-img"; }
167
+ }
168
+ else { return "input-mat-img "; }
169
+ return "input-mat";
170
+ }
171
+ getclass() {
172
+ if (this.appearance == "outline") {
173
+ let css = " d-flex gap-3"
174
+ if (!this.filter) { css = "input-outline" }
175
+
176
+ if (this.filter) { if (!this.datavalid()) { css = "input-outline" } }
177
+
178
+ if (this.filter) { if (this.datavalid()) { css = "input-outline-filter " } }
179
+
180
+ if (!this.showclear) { css = "input-outline" }
181
+
182
+ return css + " input d-flex gap-3 "
183
+ }
184
+ else {
185
+ return "input-mat d-flex gap-3 "
186
+ }
187
+ }
188
+
189
+ }
@@ -0,0 +1,160 @@
1
+ .input {
2
+ cursor: pointer;
3
+ border: 1px solid #7c7b7bdf;
4
+ padding: 5px !important;
5
+ }
6
+
7
+ .input-label {
8
+ background-color: transparent; position:inherit;
9
+ color: #202020;
10
+ font-size: 12px;
11
+ padding-left: 5px;
12
+ }
13
+
14
+
15
+ input:focus {
16
+ border: 1px solid #7c7b7bdf;
17
+ outline: none;
18
+ }
19
+
20
+ .input:hover {
21
+ background: var(--hover);
22
+ }
23
+
24
+ .input-outline {
25
+ border-radius: 5px !important;
26
+ }
27
+
28
+ .input-outline-filter {
29
+ border-top-left-radius: 5px !important;
30
+ border-bottom-left-radius: 5px !important;
31
+ background: var(--filter);
32
+ }
33
+
34
+ .input-filter {
35
+ background: var(--filter);
36
+ }
37
+
38
+ .input-outline-filter-img {
39
+ padding: 5px !important;
40
+ border-top-right-radius: 5px !important;
41
+ border-bottom-right-radius: 5px !important;
42
+ background: var(--filter);
43
+ border: 1px solid #7c7b7bdf;
44
+ cursor: pointer;
45
+ }
46
+
47
+ .input-mat {
48
+ border-bottom: 1px solid #7c7b7bdf;
49
+ padding: 5px !important;
50
+ cursor: pointer;
51
+ }
52
+
53
+ .input-mat-img {
54
+ border-bottom: 1px solid #7c7b7bdf;
55
+ padding: 5px !important;
56
+ cursor: pointer;
57
+ }
58
+
59
+
60
+ .list-item {
61
+ padding: 5px 12px;
62
+ cursor: pointer;
63
+ font-size: 14px;
64
+ }
65
+
66
+ .filterd {
67
+ background-color: var(--selected);
68
+ font-weight: 400;
69
+ cursor: pointer;
70
+ }
71
+
72
+ .list-item-selected {
73
+
74
+ color: var(--primary);
75
+ font-weight: 500;
76
+ }
77
+
78
+ .list-item:hover {
79
+ background: var(--hover);
80
+ }
81
+
82
+
83
+ .list-panel {
84
+ background-color: white;
85
+ max-height: 400px !important;
86
+ overflow-y: auto;
87
+ }
88
+
89
+ /***********************************************************/
90
+
91
+
92
+ .arrow-icon {
93
+ transition: transform 0.2s ease;
94
+ }
95
+
96
+ .arrow-icon.rotate {
97
+ transform: rotate(180deg);
98
+ }
99
+
100
+ .date-dropdown {
101
+ min-width: 280px;
102
+ padding: 0;
103
+ border: none;
104
+ border-radius: 10px;
105
+ transition: min-width 0.25s ease;
106
+ overflow: hidden;
107
+ }
108
+
109
+ .date-dropdown.custom-open {
110
+ min-width: 560px;
111
+ }
112
+
113
+ .preset-panel {
114
+ display: flex;
115
+ flex-direction: column;
116
+ background-color: #fff;
117
+ }
118
+
119
+ .preset-item {
120
+ background: transparent;
121
+ border: none;
122
+ text-align: left;
123
+ padding: 10px 14px;
124
+ font-size: 14px;
125
+ cursor: pointer;
126
+ border-radius: 6px;
127
+ transition: background-color 0.15s ease;
128
+ }
129
+
130
+ .preset-item:hover {
131
+ background-color: #f1f3f5;
132
+ }
133
+
134
+ .clear-item {
135
+ color: #e63f3f;
136
+ margin-top: 6px;
137
+ }
138
+
139
+ .custom-panel {
140
+ background-color: #fff;
141
+ border-top: 1px solid #dee2e6;
142
+ }
143
+
144
+ @media (min-width: 992px) {
145
+ .custom-panel {
146
+ border-top: none;
147
+ border-left: 1px solid #dee2e6;
148
+ }
149
+ }
150
+
151
+ .form-label {
152
+ font-size: 12px;
153
+ font-weight: 500;
154
+ color: #6c757d;
155
+ }
156
+
157
+ .form-control {
158
+ font-size: 14px;
159
+ padding: 6px 10px;
160
+ }
@@ -0,0 +1,119 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, model, ElementRef, EventEmitter, Input, OnInit, Output, SimpleChanges }
3
+ from '@angular/core';
4
+ import { FormsModule } from '@angular/forms';
5
+ import { DatePipe } from '@angular/common';
6
+
7
+
8
+ @Component({
9
+ selector: 'gho-input',
10
+ standalone: true,
11
+ imports: [CommonModule, FormsModule, ],
12
+ template: `<div style="height: 55px !important;">
13
+ <div style="height: 18px !important;">
14
+ @if(datavalid())
15
+ {
16
+ <div [ngStyle]="{ margin: '-2px 5px' }" class="input-label">{{label}}
17
+ </div>
18
+ }
19
+
20
+ </div>
21
+ <div >
22
+ <table>
23
+ <tr>
24
+ <td> <input type="text" [placeholder]="placeholder" [ngModel]="sharedValue" (input)="onInput($event)"
25
+ [ngClass]="getclass()"></td>
26
+ @if(filter && datavalid() )
27
+ {
28
+ <td>
29
+ <div (click)="clear()" [ngClass]="getclearclass()">
30
+ <i class="bi bi-x-lg "></i>
31
+ </div>
32
+ </td> }
33
+ </tr>
34
+ </table>
35
+ </div>
36
+ </div>`,
37
+ styleUrl: './input.css',
38
+ providers: [DatePipe],
39
+ changeDetection: ChangeDetectionStrategy.OnPush,
40
+ })
41
+ export class GHOInput implements OnInit {
42
+ constructor(private el: ElementRef, private cdr: ChangeDetectorRef, private datePipe: DatePipe) { }
43
+ @Input() list: [] = [];
44
+ @Input() label: string = "";
45
+ @Input() appearance: string = "outline"
46
+ @Input() filter: boolean = false;
47
+ @Input() showclear: boolean = false;
48
+ placeholder: string = "";
49
+ @Input() sharedValue: string = '';
50
+ @Output() sharedValueChange = new EventEmitter<string>();
51
+
52
+
53
+ onInput(event: Event): void {
54
+ this.sharedValue = (event.target as HTMLInputElement).value
55
+ this.sharedValueChange.emit(this.sharedValue);
56
+ this.setlabel();
57
+ }
58
+
59
+ clear()
60
+ {
61
+ this.sharedValue = ""
62
+ this.sharedValueChange.emit(this.sharedValue);
63
+ this.setlabel();
64
+ }
65
+
66
+ setlabel() {
67
+ if (this.sharedValue.length > 0) {
68
+ this.placeholder = ""
69
+ }
70
+ else { this.placeholder = this.label }
71
+ }
72
+
73
+ ngOnChanges(changes: SimpleChanges) {
74
+ if (changes['sharedValue']) {
75
+ this.setlabel();
76
+ }
77
+ }
78
+
79
+ getclass() {
80
+ if (this.appearance == "outline") {
81
+ let css = " d-flex gap-3"
82
+ if (!this.filter) { css = "input-outline" }
83
+
84
+ if (this.filter) { if (!this.datavalid()) { css = "input-outline" } }
85
+
86
+ if (this.filter) { if (this.datavalid() && this.showclear) { css = "input-outline-filter input-filter" } }
87
+
88
+ if (this.filter) { if (this.datavalid() && !this.showclear) { css = "input-outline input-filter " } }
89
+
90
+
91
+ if (!this.showclear) { css = "input-outline" }
92
+
93
+ return css + " input"
94
+ }
95
+ else {
96
+ return "input-mat d-flex gap-3 "
97
+ }
98
+ }
99
+
100
+ getclearclass() {
101
+ if (this.appearance == "outline") {
102
+ if (this.datavalid() && this.showclear) { return "input-outline-filter-img"; }
103
+ }
104
+ else { return "input-mat-img "; }
105
+ return "input-mat";
106
+ }
107
+
108
+ datavalid() {
109
+ if (this.placeholder==this.label) {
110
+ return false;
111
+ }
112
+ else { return true; }
113
+ }
114
+
115
+
116
+ ngOnInit(): void {
117
+ }
118
+
119
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Public API Surface of ghocomps
3
+ */
4
+
5
+ export * from './lib/dropdown';
6
+ export * from './lib/input';
7
+ export * from './lib/date';
@@ -0,0 +1,18 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/lib",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "inlineSources": true,
10
+ "types": []
11
+ },
12
+ "include": [
13
+ "src/**/*.ts"
14
+ ],
15
+ "exclude": [
16
+ "**/*.spec.ts"
17
+ ]
18
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.lib.json",
5
+ "compilerOptions": {
6
+ "declarationMap": false
7
+ },
8
+ "angularCompilerOptions": {
9
+ "compilationMode": "partial"
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/spec",
7
+ "types": [
8
+ "jasmine"
9
+ ]
10
+ },
11
+ "include": [
12
+ "src/**/*.d.ts",
13
+ "src/**/*.spec.ts"
14
+ ]
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,45 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "compileOnSave": false,
5
+ "compilerOptions": {
6
+ "inlineSourceMap": true,
7
+ "inlineSources": true,
8
+ "paths": {
9
+ "GHOComps": [
10
+ "./dist/ghocomps"
11
+ ]
12
+ },
13
+ "strict": true,
14
+ "allowJs": true,
15
+ "noImplicitAny": false,
16
+ "noImplicitOverride": true,
17
+ "noPropertyAccessFromIndexSignature": true,
18
+ "noImplicitReturns": true,
19
+ "noFallthroughCasesInSwitch": true,
20
+ "skipLibCheck": true,
21
+ "isolatedModules": true,
22
+ "experimentalDecorators": true,
23
+ "importHelpers": true,
24
+ "target": "ES2022",
25
+ "module": "preserve",
26
+ "strictNullChecks": false,
27
+ "strictPropertyInitialization": false,
28
+ },
29
+ "angularCompilerOptions": {
30
+ "enableI18nLegacyMessageIdFormat": false,
31
+ "strictInjectionParameters": true,
32
+ "strictInputAccessModifiers": true,
33
+ "typeCheckHostBindings": true,
34
+ "strictTemplates": true,
35
+ },
36
+ "files": [],
37
+ "references": [
38
+ {
39
+ "path": "./projects/ghocomps/tsconfig.lib.json"
40
+ },
41
+ {
42
+ "path": "./projects/ghocomps/tsconfig.spec.json"
43
+ }
44
+ ]
45
+ }