ngwr 0.1.0 → 0.1.1
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 +136 -57
- package/fesm2015/ngwr.mjs +133 -56
- package/fesm2015/ngwr.mjs.map +1 -1
- package/fesm2020/ngwr.mjs +134 -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/fesm2015/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
|
|
|
@@ -1019,20 +1019,86 @@ class WrInputComponent extends BaseComponent {
|
|
|
1019
1019
|
this.elRef = elRef;
|
|
1020
1020
|
this.focusMonitor = focusMonitor;
|
|
1021
1021
|
this.ngZone = ngZone;
|
|
1022
|
-
this.
|
|
1023
|
-
this.type = 'text';
|
|
1024
|
-
this.autocomplete = 'on';
|
|
1025
|
-
this.inputmode = 'text';
|
|
1026
|
-
this.disabled = false;
|
|
1027
|
-
this.readonly = false;
|
|
1028
|
-
this.autofocus = false;
|
|
1029
|
-
this.passwordIcons = false;
|
|
1030
|
-
this.placeholder = undefined;
|
|
1022
|
+
this.placeholder = '';
|
|
1031
1023
|
this.prefix = null;
|
|
1032
1024
|
this.suffix = null;
|
|
1025
|
+
this.passwordIcons = false;
|
|
1033
1026
|
this.eyeOn = true;
|
|
1034
|
-
this.
|
|
1035
|
-
this.
|
|
1027
|
+
this._value = '';
|
|
1028
|
+
this._disabled = false;
|
|
1029
|
+
this._readonly = false;
|
|
1030
|
+
this._required = false;
|
|
1031
|
+
this._autofocus = false;
|
|
1032
|
+
this._focused = false;
|
|
1033
|
+
this._autocomplete = 'off';
|
|
1034
|
+
this._type = 'text';
|
|
1035
|
+
this._mode = 'text';
|
|
1036
|
+
this.onChangeCallback = () => { };
|
|
1037
|
+
this.onTouchedCallback = () => { };
|
|
1038
|
+
}
|
|
1039
|
+
get type() {
|
|
1040
|
+
return this._type;
|
|
1041
|
+
}
|
|
1042
|
+
set type(type) {
|
|
1043
|
+
this._type = type;
|
|
1044
|
+
}
|
|
1045
|
+
get inputmode() {
|
|
1046
|
+
return this._mode;
|
|
1047
|
+
}
|
|
1048
|
+
set inputmode(mode) {
|
|
1049
|
+
this._mode = mode;
|
|
1050
|
+
}
|
|
1051
|
+
get disabled() {
|
|
1052
|
+
return this._disabled;
|
|
1053
|
+
}
|
|
1054
|
+
set disabled(disabled) {
|
|
1055
|
+
this._disabled = coerceBooleanProperty(disabled);
|
|
1056
|
+
}
|
|
1057
|
+
get readonly() {
|
|
1058
|
+
return this._readonly;
|
|
1059
|
+
}
|
|
1060
|
+
set readonly(readonly) {
|
|
1061
|
+
this._readonly = coerceBooleanProperty(readonly);
|
|
1062
|
+
}
|
|
1063
|
+
get required() {
|
|
1064
|
+
return this._required;
|
|
1065
|
+
}
|
|
1066
|
+
set required(required) {
|
|
1067
|
+
this._required = coerceBooleanProperty(required);
|
|
1068
|
+
}
|
|
1069
|
+
get autofocus() {
|
|
1070
|
+
return this._autofocus;
|
|
1071
|
+
}
|
|
1072
|
+
set autofocus(autofocus) {
|
|
1073
|
+
this._autofocus = coerceBooleanProperty(autofocus);
|
|
1074
|
+
}
|
|
1075
|
+
get autocomplete() {
|
|
1076
|
+
return this._autocomplete;
|
|
1077
|
+
}
|
|
1078
|
+
set autocomplete(autofocus) {
|
|
1079
|
+
this._autocomplete = autofocus;
|
|
1080
|
+
}
|
|
1081
|
+
get value() {
|
|
1082
|
+
return this.type === 'number' ? this.valueAsNumber : this._value;
|
|
1083
|
+
}
|
|
1084
|
+
set value(val) {
|
|
1085
|
+
if (val !== this._value) {
|
|
1086
|
+
this._value = val;
|
|
1087
|
+
this.onChangeCallback(this.value);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
get valueAsString() {
|
|
1091
|
+
if (this._value == null || typeof this._value === 'undefined')
|
|
1092
|
+
return '';
|
|
1093
|
+
return String(this._value);
|
|
1094
|
+
}
|
|
1095
|
+
get valueAsNumber() {
|
|
1096
|
+
return coerceNumberProperty(this._value);
|
|
1097
|
+
}
|
|
1098
|
+
get isBadInput() {
|
|
1099
|
+
var _a, _b;
|
|
1100
|
+
const validity = (_b = (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.validity;
|
|
1101
|
+
return validity && validity.badInput;
|
|
1036
1102
|
}
|
|
1037
1103
|
get elClasses() {
|
|
1038
1104
|
return {
|
|
@@ -1049,7 +1115,7 @@ class WrInputComponent extends BaseComponent {
|
|
|
1049
1115
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1050
1116
|
.subscribe(event => {
|
|
1051
1117
|
event.preventDefault();
|
|
1052
|
-
this.
|
|
1118
|
+
this.onFocus();
|
|
1053
1119
|
if (this.disabled) {
|
|
1054
1120
|
event.stopImmediatePropagation();
|
|
1055
1121
|
return;
|
|
@@ -1062,62 +1128,66 @@ class WrInputComponent extends BaseComponent {
|
|
|
1062
1128
|
}
|
|
1063
1129
|
ngAfterViewInit() {
|
|
1064
1130
|
if (this.autofocus) {
|
|
1065
|
-
this.
|
|
1131
|
+
this.onFocus();
|
|
1132
|
+
this.cdr.markForCheck();
|
|
1066
1133
|
}
|
|
1067
1134
|
}
|
|
1068
1135
|
ngOnDestroy() {
|
|
1069
1136
|
super.ngOnDestroy();
|
|
1070
1137
|
this.focusMonitor.stopMonitoring(this.elRef);
|
|
1071
1138
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1139
|
+
onFocus(event) {
|
|
1140
|
+
if (event) {
|
|
1141
|
+
event.stopPropagation();
|
|
1142
|
+
}
|
|
1143
|
+
this._focused = true;
|
|
1144
|
+
this.focusMonitor.focusVia(this.inputElement, 'keyboard');
|
|
1075
1145
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1146
|
+
onBlur(event) {
|
|
1147
|
+
if (event) {
|
|
1148
|
+
event.stopPropagation();
|
|
1149
|
+
}
|
|
1150
|
+
this._focused = false;
|
|
1151
|
+
// this.inputElement.nativeElement.blur();
|
|
1152
|
+
this.onTouchedCallback();
|
|
1078
1153
|
}
|
|
1079
|
-
|
|
1080
|
-
this.
|
|
1154
|
+
validate(control) {
|
|
1155
|
+
return Object.assign({}, (this.isBadInput ? { badInput: true } : null));
|
|
1081
1156
|
}
|
|
1082
|
-
|
|
1083
|
-
this.
|
|
1157
|
+
writeValue(value) {
|
|
1158
|
+
if (value !== this._value) {
|
|
1159
|
+
this._value = value;
|
|
1160
|
+
}
|
|
1084
1161
|
this.cdr.markForCheck();
|
|
1085
1162
|
}
|
|
1086
|
-
|
|
1087
|
-
this.
|
|
1163
|
+
registerOnChange(fn) {
|
|
1164
|
+
this.onChangeCallback = fn;
|
|
1088
1165
|
}
|
|
1089
|
-
|
|
1090
|
-
this.
|
|
1166
|
+
registerOnTouched(fn) {
|
|
1167
|
+
this.onTouchedCallback = fn;
|
|
1091
1168
|
}
|
|
1092
|
-
onPasswordVisibilityChange(
|
|
1093
|
-
event.stopPropagation();
|
|
1169
|
+
onPasswordVisibilityChange() {
|
|
1094
1170
|
this.type === 'password' ? (this.type = 'text') : (this.type = 'password');
|
|
1095
1171
|
this.eyeOn = !this.eyeOn;
|
|
1172
|
+
this.onFocus();
|
|
1096
1173
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
this.value = value;
|
|
1100
|
-
this.onChange(this.value);
|
|
1101
|
-
}
|
|
1174
|
+
setDisabledState(isDisabled) {
|
|
1175
|
+
this.disabled = coerceBooleanProperty(isDisabled);
|
|
1102
1176
|
}
|
|
1103
1177
|
}
|
|
1104
1178
|
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 });
|
|
1105
|
-
WrInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.8", type: WrInputComponent, selector: "wr-input", inputs: {
|
|
1179
|
+
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: [
|
|
1106
1180
|
{
|
|
1107
1181
|
provide: NG_VALUE_ACCESSOR,
|
|
1108
1182
|
useExisting: forwardRef(() => WrInputComponent),
|
|
1109
1183
|
multi: true
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
provide: NG_VALIDATORS,
|
|
1187
|
+
useExisting: forwardRef(() => WrInputComponent),
|
|
1188
|
+
multi: true
|
|
1110
1189
|
}
|
|
1111
|
-
], 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
|
|
1112
|
-
__decorate([
|
|
1113
|
-
InputBoolean()
|
|
1114
|
-
], WrInputComponent.prototype, "disabled", void 0);
|
|
1115
|
-
__decorate([
|
|
1116
|
-
InputBoolean()
|
|
1117
|
-
], WrInputComponent.prototype, "readonly", void 0);
|
|
1118
|
-
__decorate([
|
|
1119
|
-
InputBoolean()
|
|
1120
|
-
], WrInputComponent.prototype, "autofocus", void 0);
|
|
1190
|
+
], 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 });
|
|
1121
1191
|
__decorate([
|
|
1122
1192
|
InputBoolean()
|
|
1123
1193
|
], WrInputComponent.prototype, "passwordIcons", void 0);
|
|
@@ -1128,13 +1198,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
|
|
|
1128
1198
|
provide: NG_VALUE_ACCESSOR,
|
|
1129
1199
|
useExisting: forwardRef(() => WrInputComponent),
|
|
1130
1200
|
multi: true
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
provide: NG_VALIDATORS,
|
|
1204
|
+
useExisting: forwardRef(() => WrInputComponent),
|
|
1205
|
+
multi: true
|
|
1131
1206
|
}
|
|
1132
|
-
], 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
|
|
1133
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1$1.FocusMonitor }, { type: i0.NgZone }]; }, propDecorators: {
|
|
1207
|
+
], 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" }]
|
|
1208
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1$1.FocusMonitor }, { type: i0.NgZone }]; }, propDecorators: { placeholder: [{
|
|
1134
1209
|
type: Input
|
|
1135
|
-
}],
|
|
1210
|
+
}], prefix: [{
|
|
1136
1211
|
type: Input
|
|
1137
|
-
}],
|
|
1212
|
+
}], suffix: [{
|
|
1213
|
+
type: Input
|
|
1214
|
+
}], passwordIcons: [{
|
|
1215
|
+
type: Input
|
|
1216
|
+
}], type: [{
|
|
1138
1217
|
type: Input
|
|
1139
1218
|
}], inputmode: [{
|
|
1140
1219
|
type: Input
|
|
@@ -1142,15 +1221,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
|
|
|
1142
1221
|
type: Input
|
|
1143
1222
|
}], readonly: [{
|
|
1144
1223
|
type: Input
|
|
1145
|
-
}],
|
|
1146
|
-
type: Input
|
|
1147
|
-
}], passwordIcons: [{
|
|
1224
|
+
}], required: [{
|
|
1148
1225
|
type: Input
|
|
1149
|
-
}],
|
|
1226
|
+
}], autofocus: [{
|
|
1150
1227
|
type: Input
|
|
1151
|
-
}],
|
|
1228
|
+
}], autocomplete: [{
|
|
1152
1229
|
type: Input
|
|
1153
|
-
}],
|
|
1230
|
+
}], value: [{
|
|
1154
1231
|
type: Input
|
|
1155
1232
|
}], inputElement: [{
|
|
1156
1233
|
type: ViewChild,
|