ghocomps 1.1.25 → 1.3.25

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.
@@ -1,298 +0,0 @@
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
- }
@@ -1,189 +0,0 @@
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
- }
@@ -1,160 +0,0 @@
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
- }