Skip to content

Commit f643259

Browse files
Merge pull request #10 from RandomSoftwareSL/feature/disable-warning-fixes
Update primeNG version and resolving the console warning form disable…
2 parents f29c2a2 + f2d99c7 commit f643259

File tree

6 files changed

+52
-25
lines changed

6 files changed

+52
-25
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
"@angular/platform-browser-dynamic": "^17.2.3",
2121
"@angular/router": "^17.2.3",
2222
"primeflex": "^3.3.1",
23-
"primeicons": "^6.0.1",
24-
"primeng": "^17.11.0",
23+
"primeicons": "^7.0.0",
24+
"primeng": "^17.18.0",
2525
"rxjs": "~7.8.1",
2626
"tslib": "^2.3.0",
2727
"zone.js": "^0.14.0"
2828
},
2929
"peerDependencies": {
3030
"primeflex": "^3.3.1",
31-
"primeicons": "^6.0.1",
32-
"primeng": "^17.11.0"
31+
"primeicons": "^7.0.0",
32+
"primeng": "^17.18.0"
3333
},
3434
"devDependencies": {
3535
"@angular-devkit/build-angular": "^17.2.2",

projects/consumer/src/app/app.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
placeholder="Year"
1818
></typeHeadInput>
1919
</form>
20+
21+
<button (click)="disabled()">disabled</button>
22+
<button (click)="enable()">enable</button>

projects/consumer/src/app/app.component.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class AppComponent {
1919
customSelectInputClass = "w-full text-sm h-3rem";
2020
typeHeadYearDataSet!: SelectItem[];
2121

22-
yearSource = new BehaviorSubject<any>(null!);
22+
yearSource = new BehaviorSubject<string[]>(null!);
2323
yearObs$ = this.yearSource.asObservable();
2424

2525
constructor(private formBuilder: UntypedFormBuilder) {
@@ -76,27 +76,31 @@ export class AppComponent {
7676
if (!this.typeHeadYearDataSet) {
7777
return this.yearObs$.pipe(
7878
map((years) => {
79-
const yearsArray: any = [];
80-
years.forEach((yearValue: any) => {
81-
let year = { year: yearValue };
79+
const yearsArray: { year: string }[] = [];
80+
years.forEach((yearValue: string) => {
81+
const year = { year: yearValue };
8282
yearsArray.push(year);
8383
});
84-
this.typeHeadYearDataSet = yearsArray.map((years: { year: any }) => {
85-
return {
86-
label: years.year,
87-
value: years.year,
88-
};
89-
});
84+
this.typeHeadYearDataSet = yearsArray.map(
85+
(years: { year: string }) => {
86+
return {
87+
label: years.year,
88+
value: years.year,
89+
};
90+
}
91+
);
9092
return this.typeHeadYearDataSet;
9193
})
9294
);
9395
}
9496
return of();
9597
};
9698

97-
changeSelectedText(event: any) {
98-
this.consumerForm.patchValue({
99-
year: event?.addedValue,
100-
});
101-
}
99+
disabled = () => {
100+
this.getFormControl["year"].disable();
101+
};
102+
103+
enable = () => {
104+
this.getFormControl["year"].enable();
105+
};
102106
}

projects/type-head-input/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@randomsoftwareltd/type-head-input",
3-
"version": "2.0.8",
3+
"version": "2.1.0",
44
"peerDependencies": {
55
"@angular/common": "^17.2.3",
66
"@angular/core": "^17.2.3",
77
"primeflex": "^3.3.1",
8-
"primeicons": "^6.0.1",
9-
"primeng": "^17.11.0"
8+
"primeicons": "^7.0.0",
9+
"primeng": "^17.18.0"
1010
},
1111
"dependencies": {
1212
"tslib": "^2.3.0"

projects/type-head-input/src/lib/type-head-input.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
[showClear]="showClear"
2020
[styleClass]="dropDownStyleClass"
2121
[panelStyleClass]="panelStyleClass"
22-
[disabled]="disabled"
2322
[name]="name"
2423
class="{{ typeHeadStyleClass }} {{
2524
control.touched && control.invalid ? 'ng-invalid ng-dirty' : ''

projects/type-head-input/src/lib/type-head-input.component.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
EventEmitter,
55
Input,
66
Output,
7+
SimpleChanges,
78
TemplateRef,
89
ViewChild,
910
} from "@angular/core";
@@ -24,7 +25,7 @@ import {
2425
} from "./directive/form-template.directive";
2526
import { SelectItem } from "primeng/api";
2627
import { UntypedFormControl } from "@angular/forms";
27-
import { Dropdown } from "primeng/dropdown";
28+
import { Dropdown, DropdownChangeEvent } from "primeng/dropdown";
2829

2930
@Component({
3031
selector: "typeHeadInput",
@@ -58,6 +59,7 @@ export class TypeHeadInputComponent {
5859
@Input() isFormLabel = true;
5960
@Input() typeHeadStyleClass!: string;
6061
@Input() labelText!: string;
62+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6163
selectedTypeHeadSource = new BehaviorSubject<any>(null);
6264
selectedTypeHead$ = this.selectedTypeHeadSource.asObservable();
6365
loading = false;
@@ -66,14 +68,17 @@ export class TypeHeadInputComponent {
6668

6769
// custom templates
6870
@ContentChild(NgTypeHeadInputItemTemplateDirective, { read: TemplateRef })
71+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6972
itemTemplate: TemplateRef<any> | undefined;
7073
@ContentChild(NgTypeHeadInputFilterTemplateDirective, { read: TemplateRef })
74+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7175
filterTemplate: TemplateRef<any> | undefined;
7276

7377
//Extract label data
7478
optionLabels!: (string | undefined)[];
7579

7680
newCreatedValue!: string;
81+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7782
newValueSource = new BehaviorSubject<any>(null);
7883
newValueObs$ = this.newValueSource.asObservable();
7984
isAvailability: boolean = false;
@@ -82,6 +87,9 @@ export class TypeHeadInputComponent {
8287
constructor() {}
8388

8489
ngOnInit(): void {
90+
if (this.disabled) {
91+
this.control.disable();
92+
}
8593
if (this.isNumberInput) {
8694
this.allowNumberInput();
8795
}
@@ -130,10 +138,12 @@ export class TypeHeadInputComponent {
130138
}
131139
}
132140

141+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
133142
onShowDropdown(event: any) {
134143
if (this.enableServerSideData) this.selectedTypeHeadSource.next(event);
135144
}
136145

146+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
137147
addNewValue(inputValue?: any) {
138148
if (inputValue) {
139149
if (this.enableServerSideData) {
@@ -177,14 +187,15 @@ export class TypeHeadInputComponent {
177187
this.optionLabels = this.items?.map((item) => item.label);
178188
}
179189

190+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
180191
checkInitialData(select: any) {
181192
return (
182193
select?.value?.length > 0 &&
183194
!this.items?.map((item) => item.label)?.includes(select?.value)
184195
);
185196
}
186197

187-
onFilterEmitter(event: any) {
198+
onFilterEmitter(event: DropdownChangeEvent) {
188199
this.setEmptyHandler();
189200
this.searchValue =
190201
typeof this.select?.value === "object" &&
@@ -224,4 +235,14 @@ export class TypeHeadInputComponent {
224235
this.control.patchValue(null);
225236
}
226237
};
238+
239+
ngOnChanges(changes: SimpleChanges) {
240+
if (changes["disabled"] && !changes["disabled"].isFirstChange()) {
241+
if (this.disabled) {
242+
this.control.disable();
243+
} else {
244+
this.control.enable();
245+
}
246+
}
247+
}
227248
}

0 commit comments

Comments
 (0)