ngwr 0.1.0 → 0.1.2
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/_core/types/index.d.ts +3 -0
- package/_core/types/input-autocomplete-type.d.ts +1 -0
- package/_core/types/input-mode-type.d.ts +1 -0
- package/_core/types/input-type.d.ts +1 -0
- package/esm2020/_core/types/index.mjs +1 -1
- package/esm2020/_core/types/input-autocomplete-type.mjs +2 -0
- package/esm2020/_core/types/input-mode-type.mjs +2 -0
- package/esm2020/_core/types/input-type.mjs +2 -0
- package/esm2020/input/input.component.mjs +137 -57
- package/fesm2015/ngwr.mjs +134 -56
- package/fesm2015/ngwr.mjs.map +1 -1
- package/fesm2020/ngwr.mjs +135 -56
- package/fesm2020/ngwr.mjs.map +1 -1
- package/input/input.component.d.ts +42 -21
- package/ngwr.min.css +1 -1
- package/package.json +1 -1
package/fesm2020/ngwr.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import * as i0 from '@angular/core';
|
|
|
3
3
|
import { Directive, Component, ViewEncapsulation, ChangeDetectionStrategy, HostBinding, Injectable, Optional, Inject, Input, NgModule, EventEmitter, forwardRef, ViewChild, Output } from '@angular/core';
|
|
4
4
|
import { Subject, fromEvent } from 'rxjs';
|
|
5
5
|
import { takeUntil } from 'rxjs/operators';
|
|
6
|
-
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
6
|
+
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
7
7
|
import * as i1 from '@angular/common';
|
|
8
8
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
9
9
|
import * as i2 from '@angular/forms';
|
|
10
|
-
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
10
|
+
import { NG_VALUE_ACCESSOR, FormsModule, NG_VALIDATORS } from '@angular/forms';
|
|
11
11
|
import * as i1$1 from '@angular/cdk/a11y';
|
|
12
12
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
13
13
|
|
|
@@ -1016,20 +1016,86 @@ class WrInputComponent extends BaseComponent {
|
|
|
1016
1016
|
this.elRef = elRef;
|
|
1017
1017
|
this.focusMonitor = focusMonitor;
|
|
1018
1018
|
this.ngZone = ngZone;
|
|
1019
|
-
this.
|
|
1020
|
-
this.type = 'text';
|
|
1021
|
-
this.autocomplete = 'on';
|
|
1022
|
-
this.inputmode = 'text';
|
|
1023
|
-
this.disabled = false;
|
|
1024
|
-
this.readonly = false;
|
|
1025
|
-
this.autofocus = false;
|
|
1026
|
-
this.passwordIcons = false;
|
|
1027
|
-
this.placeholder = undefined;
|
|
1019
|
+
this.placeholder = '';
|
|
1028
1020
|
this.prefix = null;
|
|
1029
1021
|
this.suffix = null;
|
|
1022
|
+
this.passwordIcons = false;
|
|
1030
1023
|
this.eyeOn = true;
|
|
1031
|
-
this.
|
|
1032
|
-
this.
|
|
1024
|
+
this._value = '';
|
|
1025
|
+
this._disabled = false;
|
|
1026
|
+
this._readonly = false;
|
|
1027
|
+
this._required = false;
|
|
1028
|
+
this._autofocus = false;
|
|
1029
|
+
this._focused = false;
|
|
1030
|
+
this._autocomplete = 'off';
|
|
1031
|
+
this._type = 'text';
|
|
1032
|
+
this._mode = 'text';
|
|
1033
|
+
this.onChangeCallback = () => { };
|
|
1034
|
+
this.onTouchedCallback = () => { };
|
|
1035
|
+
}
|
|
1036
|
+
get type() {
|
|
1037
|
+
return this._type;
|
|
1038
|
+
}
|
|
1039
|
+
set type(type) {
|
|
1040
|
+
this._type = type;
|
|
1041
|
+
}
|
|
1042
|
+
get inputmode() {
|
|
1043
|
+
return this._mode;
|
|
1044
|
+
}
|
|
1045
|
+
set inputmode(mode) {
|
|
1046
|
+
this._mode = mode;
|
|
1047
|
+
}
|
|
1048
|
+
get disabled() {
|
|
1049
|
+
return this._disabled;
|
|
1050
|
+
}
|
|
1051
|
+
set disabled(disabled) {
|
|
1052
|
+
this._disabled = coerceBooleanProperty(disabled);
|
|
1053
|
+
this.cdr.markForCheck();
|
|
1054
|
+
}
|
|
1055
|
+
get readonly() {
|
|
1056
|
+
return this._readonly;
|
|
1057
|
+
}
|
|
1058
|
+
set readonly(readonly) {
|
|
1059
|
+
this._readonly = coerceBooleanProperty(readonly);
|
|
1060
|
+
}
|
|
1061
|
+
get required() {
|
|
1062
|
+
return this._required;
|
|
1063
|
+
}
|
|
1064
|
+
set required(required) {
|
|
1065
|
+
this._required = coerceBooleanProperty(required);
|
|
1066
|
+
}
|
|
1067
|
+
get autofocus() {
|
|
1068
|
+
return this._autofocus;
|
|
1069
|
+
}
|
|
1070
|
+
set autofocus(autofocus) {
|
|
1071
|
+
this._autofocus = coerceBooleanProperty(autofocus);
|
|
1072
|
+
}
|
|
1073
|
+
get autocomplete() {
|
|
1074
|
+
return this._autocomplete;
|
|
1075
|
+
}
|
|
1076
|
+
set autocomplete(autofocus) {
|
|
1077
|
+
this._autocomplete = autofocus;
|
|
1078
|
+
}
|
|
1079
|
+
get value() {
|
|
1080
|
+
return this.type === 'number' ? this.valueAsNumber : this._value;
|
|
1081
|
+
}
|
|
1082
|
+
set value(val) {
|
|
1083
|
+
if (val !== this._value) {
|
|
1084
|
+
this._value = val;
|
|
1085
|
+
this.onChangeCallback(this.value);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
get valueAsString() {
|
|
1089
|
+
if (this._value == null || typeof this._value === 'undefined')
|
|
1090
|
+
return '';
|
|
1091
|
+
return String(this._value);
|
|
1092
|
+
}
|
|
1093
|
+
get valueAsNumber() {
|
|
1094
|
+
return coerceNumberProperty(this._value);
|
|
1095
|
+
}
|
|
1096
|
+
get isBadInput() {
|
|
1097
|
+
const validity = this.inputElement?.nativeElement?.validity;
|
|
1098
|
+
return validity && validity.badInput;
|
|
1033
1099
|
}
|
|
1034
1100
|
get elClasses() {
|
|
1035
1101
|
return {
|
|
@@ -1046,7 +1112,7 @@ class WrInputComponent extends BaseComponent {
|
|
|
1046
1112
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1047
1113
|
.subscribe(event => {
|
|
1048
1114
|
event.preventDefault();
|
|
1049
|
-
this.
|
|
1115
|
+
this.onFocus();
|
|
1050
1116
|
if (this.disabled) {
|
|
1051
1117
|
event.stopImmediatePropagation();
|
|
1052
1118
|
return;
|
|
@@ -1059,62 +1125,68 @@ class WrInputComponent extends BaseComponent {
|
|
|
1059
1125
|
}
|
|
1060
1126
|
ngAfterViewInit() {
|
|
1061
1127
|
if (this.autofocus) {
|
|
1062
|
-
this.
|
|
1128
|
+
this.onFocus();
|
|
1129
|
+
this.cdr.markForCheck();
|
|
1063
1130
|
}
|
|
1064
1131
|
}
|
|
1065
1132
|
ngOnDestroy() {
|
|
1066
1133
|
super.ngOnDestroy();
|
|
1067
1134
|
this.focusMonitor.stopMonitoring(this.elRef);
|
|
1068
1135
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1136
|
+
onFocus(event) {
|
|
1137
|
+
if (event) {
|
|
1138
|
+
event.stopPropagation();
|
|
1139
|
+
}
|
|
1140
|
+
this._focused = true;
|
|
1141
|
+
this.focusMonitor.focusVia(this.inputElement, 'keyboard');
|
|
1072
1142
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1143
|
+
onBlur(event) {
|
|
1144
|
+
if (event) {
|
|
1145
|
+
event.stopPropagation();
|
|
1146
|
+
}
|
|
1147
|
+
this._focused = false;
|
|
1148
|
+
// this.inputElement.nativeElement.blur();
|
|
1149
|
+
this.onTouchedCallback();
|
|
1075
1150
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1151
|
+
validate(control) {
|
|
1152
|
+
return {
|
|
1153
|
+
...(this.isBadInput ? { badInput: true } : null)
|
|
1154
|
+
};
|
|
1078
1155
|
}
|
|
1079
|
-
|
|
1080
|
-
this.
|
|
1156
|
+
writeValue(value) {
|
|
1157
|
+
if (value !== this._value) {
|
|
1158
|
+
this._value = value;
|
|
1159
|
+
}
|
|
1081
1160
|
this.cdr.markForCheck();
|
|
1082
1161
|
}
|
|
1083
|
-
|
|
1084
|
-
this.
|
|
1162
|
+
registerOnChange(fn) {
|
|
1163
|
+
this.onChangeCallback = fn;
|
|
1085
1164
|
}
|
|
1086
|
-
|
|
1087
|
-
this.
|
|
1165
|
+
registerOnTouched(fn) {
|
|
1166
|
+
this.onTouchedCallback = fn;
|
|
1088
1167
|
}
|
|
1089
|
-
onPasswordVisibilityChange(
|
|
1090
|
-
event.stopPropagation();
|
|
1168
|
+
onPasswordVisibilityChange() {
|
|
1091
1169
|
this.type === 'password' ? (this.type = 'text') : (this.type = 'password');
|
|
1092
1170
|
this.eyeOn = !this.eyeOn;
|
|
1171
|
+
this.onFocus();
|
|
1093
1172
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
this.value = value;
|
|
1097
|
-
this.onChange(this.value);
|
|
1098
|
-
}
|
|
1173
|
+
setDisabledState(isDisabled) {
|
|
1174
|
+
this.disabled = coerceBooleanProperty(isDisabled);
|
|
1099
1175
|
}
|
|
1100
1176
|
}
|
|
1101
1177
|
WrInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: WrInputComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i1$1.FocusMonitor }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
1102
|
-
WrInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.8", type: WrInputComponent, selector: "wr-input", inputs: {
|
|
1178
|
+
WrInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.8", type: WrInputComponent, selector: "wr-input", inputs: { placeholder: "placeholder", prefix: "prefix", suffix: "suffix", passwordIcons: "passwordIcons", type: "type", inputmode: "inputmode", disabled: "disabled", readonly: "readonly", required: "required", autofocus: "autofocus", autocomplete: "autocomplete", value: "value" }, host: { properties: { "class": "this.elClasses" } }, providers: [
|
|
1103
1179
|
{
|
|
1104
1180
|
provide: NG_VALUE_ACCESSOR,
|
|
1105
1181
|
useExisting: forwardRef(() => WrInputComponent),
|
|
1106
1182
|
multi: true
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
provide: NG_VALIDATORS,
|
|
1186
|
+
useExisting: forwardRef(() => WrInputComponent),
|
|
1187
|
+
multi: true
|
|
1107
1188
|
}
|
|
1108
|
-
], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true, static: true }], exportAs: ["wrInput"], usesInheritance: true, ngImport: i0, template: "<div class=\"wr-input-prefix\" *ngIf=\"prefix\">\n <span class=\"wr-input-prefix__text\">{{ prefix }}</span>\n</div>\n<div class=\"wr-input-el\">\n <div
|
|
1109
|
-
__decorate([
|
|
1110
|
-
InputBoolean()
|
|
1111
|
-
], WrInputComponent.prototype, "disabled", void 0);
|
|
1112
|
-
__decorate([
|
|
1113
|
-
InputBoolean()
|
|
1114
|
-
], WrInputComponent.prototype, "readonly", void 0);
|
|
1115
|
-
__decorate([
|
|
1116
|
-
InputBoolean()
|
|
1117
|
-
], WrInputComponent.prototype, "autofocus", void 0);
|
|
1189
|
+
], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true, static: true }], exportAs: ["wrInput"], usesInheritance: true, ngImport: i0, template: "<div class=\"wr-input-prefix\" *ngIf=\"prefix\">\n <span class=\"wr-input-prefix__text\">{{ prefix }}</span>\n</div>\n<div class=\"wr-input-el\">\n <div *ngIf=\"passwordIcons\" class=\"wr-input-el-icon\" (click)=\"onPasswordVisibilityChange()\">\n <wr-icon class=\"wr-input-el-icon__icon\" [name]=\"eyeOn ? 'eye' : 'eye-off'\"></wr-icon>\n </div>\n <input\n #inputElement\n class=\"wr-input-el__native\"\n [ngModel]=\"valueAsString\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly\"\n [type]=\"type\"\n [attr.autocomplete]=\"autocomplete\"\n [attr.inputmode]=\"inputmode\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (ngModelChange)=\"value = $event\"\n />\n</div>\n<div class=\"wr-input-suffix\" *ngIf=\"suffix\">\n <span class=\"wr-input-suffix__text\">{{ suffix }}</span>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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"] }, { kind: "component", type: WrIconComponent, selector: "wr-icon[name]", inputs: ["name"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1118
1190
|
__decorate([
|
|
1119
1191
|
InputBoolean()
|
|
1120
1192
|
], WrInputComponent.prototype, "passwordIcons", void 0);
|
|
@@ -1125,13 +1197,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
|
|
|
1125
1197
|
provide: NG_VALUE_ACCESSOR,
|
|
1126
1198
|
useExisting: forwardRef(() => WrInputComponent),
|
|
1127
1199
|
multi: true
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
provide: NG_VALIDATORS,
|
|
1203
|
+
useExisting: forwardRef(() => WrInputComponent),
|
|
1204
|
+
multi: true
|
|
1128
1205
|
}
|
|
1129
|
-
], template: "<div class=\"wr-input-prefix\" *ngIf=\"prefix\">\n <span class=\"wr-input-prefix__text\">{{ prefix }}</span>\n</div>\n<div class=\"wr-input-el\">\n <div
|
|
1130
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1$1.FocusMonitor }, { type: i0.NgZone }]; }, propDecorators: {
|
|
1206
|
+
], template: "<div class=\"wr-input-prefix\" *ngIf=\"prefix\">\n <span class=\"wr-input-prefix__text\">{{ prefix }}</span>\n</div>\n<div class=\"wr-input-el\">\n <div *ngIf=\"passwordIcons\" class=\"wr-input-el-icon\" (click)=\"onPasswordVisibilityChange()\">\n <wr-icon class=\"wr-input-el-icon__icon\" [name]=\"eyeOn ? 'eye' : 'eye-off'\"></wr-icon>\n </div>\n <input\n #inputElement\n class=\"wr-input-el__native\"\n [ngModel]=\"valueAsString\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly\"\n [type]=\"type\"\n [attr.autocomplete]=\"autocomplete\"\n [attr.inputmode]=\"inputmode\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (ngModelChange)=\"value = $event\"\n />\n</div>\n<div class=\"wr-input-suffix\" *ngIf=\"suffix\">\n <span class=\"wr-input-suffix__text\">{{ suffix }}</span>\n</div>\n" }]
|
|
1207
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1$1.FocusMonitor }, { type: i0.NgZone }]; }, propDecorators: { placeholder: [{
|
|
1131
1208
|
type: Input
|
|
1132
|
-
}],
|
|
1209
|
+
}], prefix: [{
|
|
1133
1210
|
type: Input
|
|
1134
|
-
}],
|
|
1211
|
+
}], suffix: [{
|
|
1212
|
+
type: Input
|
|
1213
|
+
}], passwordIcons: [{
|
|
1214
|
+
type: Input
|
|
1215
|
+
}], type: [{
|
|
1135
1216
|
type: Input
|
|
1136
1217
|
}], inputmode: [{
|
|
1137
1218
|
type: Input
|
|
@@ -1139,15 +1220,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
|
|
|
1139
1220
|
type: Input
|
|
1140
1221
|
}], readonly: [{
|
|
1141
1222
|
type: Input
|
|
1142
|
-
}],
|
|
1143
|
-
type: Input
|
|
1144
|
-
}], passwordIcons: [{
|
|
1223
|
+
}], required: [{
|
|
1145
1224
|
type: Input
|
|
1146
|
-
}],
|
|
1225
|
+
}], autofocus: [{
|
|
1147
1226
|
type: Input
|
|
1148
|
-
}],
|
|
1227
|
+
}], autocomplete: [{
|
|
1149
1228
|
type: Input
|
|
1150
|
-
}],
|
|
1229
|
+
}], value: [{
|
|
1151
1230
|
type: Input
|
|
1152
1231
|
}], inputElement: [{
|
|
1153
1232
|
type: ViewChild,
|