Skip to content

Commit b53fde6

Browse files
committed
Migrate to Angular 14
1 parent 50a4157 commit b53fde6

16 files changed

+6953
-12305
lines changed

ngx-numeric-range-form-field/README.md

+84-42
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ npm install ngx-numeric-range-form-field
2929

3030
# Usage
3131

32-
In component HTML:
32+
Template:
3333

3434
```html
35-
<ngx-numeric-range-form-field
36-
[formControl]="rangeControl"
37-
label="Numeric range"
38-
(blurred)="onBlur()"
39-
(enterPressed)="onEnter()"
40-
(numericRangeChanged)="onValueChange($event)"
41-
></ngx-numeric-range-form-field>
35+
<form [formGroup]="form">
36+
<ngx-numeric-range-form-field
37+
formControlName="range"
38+
label="Numeric range"
39+
(blurred)="onBlur()"
40+
(enterPressed)="onEnter()"
41+
(numericRangeChanged)="onNumericRangeChanged($event)"
42+
></ngx-numeric-range-form-field>
43+
</form>
4244
```
4345

44-
In component.ts:
45-
4646
```typescript
4747
form: FormGroup;
4848

@@ -59,10 +59,6 @@ form: FormGroup;
5959
});
6060
}
6161

62-
get rangeControl(): FormControl {
63-
return this.form.get('range') as FormControl;
64-
}
65-
6662
onBlur(): void {
6763
console.log('Value', this.rangeControl.value);
6864
}
@@ -71,45 +67,91 @@ form: FormGroup;
7167
console.log('Enter pressed!');
7268
}
7369

74-
onValueChange(value: INumericRange): void {
70+
onNumericRangeChanged(value: INumericRange): void {
7571
console.log('Changed value: ', value);
7672
}
7773
```
7874

79-
Customizable input and output decorators:
75+
It is based on following type:
8076

8177
```typescript
82-
@Input() label: string; // Label of the control
83-
@Input() appearance: 'legacy' | 'standard' | 'fill' | 'outline' = 'outline';
84-
@Input() floatLabel: 'always' | 'never' | 'auto' = 'always';
85-
@Input() minPlaceholder = 'From'; // Placeholder of the minimum value control
86-
@Input() maxPlaceholder = 'To'; // Placeholder of the maximum value control
87-
@Input() readonly = false; // Flag for readonly both controls
88-
@Input() minReadonly = false; // Flag for readonly minimum control
89-
@Input() maxReadonly = false; // Flag for readonly maximum control
90-
@Input() resettable = true; // Flag for resetting controls value
91-
@Input() requiredErrorMessage = 'Field is required!'; // Customizable error message when field is required
92-
@Input() minimumErrorMessage = 'Minimum has been reached!'; // Customizable error message when field has min validation
93-
@Input() maximumErrorMessage = 'Maximum has exceeded!'; // Customizable error message when field has max validation
94-
@Input() invalidRangeErrorMessage = 'Inserted range is not valid!'; // Customizable error message when field has invalid numeric range
95-
@Input() dynamicSyncValidators: ValidatorFn | ValidatorFn[]; // Dynamic change of sync validators
96-
97-
@Output() blurred = new EventEmitter<void>(); // Event which emits where user leaves control (focus out)
98-
@Output() enterPressed = new EventEmitter<void>(); // Event which emits when enter is pressed
99-
@Output() numericRangeChanged = new EventEmitter<INumericRange>(); // Event which emits when one of range value is changed
100-
```
101-
102-
It is based on following interface:
103-
104-
```typescript
105-
export interface INumericRange {
78+
type INumericRange = {
10679
minimum: number;
10780
maximum: number;
108-
}
81+
};
10982
```
11083

84+
### Input property decorators:
85+
86+
- #### label
87+
88+
Set label of the field.
89+
90+
- #### appearance
91+
92+
Set MatFormFieldAppearance.
93+
94+
- #### floatLabel
95+
96+
Set FloatLabelType.
97+
98+
- #### minPlaceholder & maxPlaceholder
99+
100+
Set placeholder of the minimum value control. Defaulted to 'From'.
101+
Set placeholder of the maximum value control. Defaulted to 'To'.
102+
103+
- #### readonly
104+
105+
Set field value as readonly.
106+
107+
- #### minReadonly & maxReadonly
108+
109+
Set flag for separated readonly value.
110+
111+
- #### resettable
112+
113+
Set showing icon for resetting value in field.
114+
115+
- #### requiredErrorMessage
116+
117+
Set error message on required validation.
118+
119+
- #### minimumErrorMessage & maximumErrorMessage
120+
121+
Set error message on min & max value validation.
122+
123+
- #### maximumErrorMessage
124+
125+
Set error message on min value validation.
126+
127+
- #### invalidRangeErrorMessage
128+
129+
Set error message on invalid numeric range.
130+
131+
- #### dynamicSyncValidators
132+
133+
Set sync validators on runtime.
134+
135+
### Output property decorators:
136+
137+
- #### blurred
138+
139+
Emit on blur out.
140+
141+
- #### enterPressed
142+
143+
Emit on enter press.
144+
145+
- #### numericRangeChanged
146+
147+
Emit on value change.
148+
149+
# Contributing
150+
151+
Contributions are more than welcome!
152+
111153
# License
112154

113-
Apache License
155+
MIT License
114156

115157
Copyright (c) 2022 Dino Klicek

ngx-numeric-range-form-field/angular.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,5 @@
168168
}
169169
}
170170
}
171-
},
172-
"defaultProject": "ngx-numeric-range-form-field"
171+
}
173172
}

0 commit comments

Comments
 (0)