@webilix/ngx-form-m3 0.0.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.
Files changed (37) hide show
  1. package/README.md +6 -0
  2. package/fesm2022/webilix-ngx-form-m3.mjs +964 -0
  3. package/fesm2022/webilix-ngx-form-m3.mjs.map +1 -0
  4. package/index.d.ts +5 -0
  5. package/lib/directives/auto-complete.directive.d.ts +6 -0
  6. package/lib/directives/auto-focus.directive.d.ts +10 -0
  7. package/lib/directives/auto-height.directive.d.ts +18 -0
  8. package/lib/directives/form-error.directive.d.ts +12 -0
  9. package/lib/directives/index.d.ts +4 -0
  10. package/lib/inputs/email/input-email.component.d.ts +13 -0
  11. package/lib/inputs/email/input-email.interface.d.ts +10 -0
  12. package/lib/inputs/index.d.ts +17 -0
  13. package/lib/inputs/input.component.d.ts +51 -0
  14. package/lib/inputs/input.info.d.ts +10 -0
  15. package/lib/inputs/input.interface.d.ts +26 -0
  16. package/lib/inputs/mobile/input-mobile.component.d.ts +14 -0
  17. package/lib/inputs/mobile/input-mobile.interface.d.ts +10 -0
  18. package/lib/inputs/name/input-name.component.d.ts +17 -0
  19. package/lib/inputs/name/input-name.interface.d.ts +15 -0
  20. package/lib/inputs/password/input-password.component.d.ts +14 -0
  21. package/lib/inputs/password/input-password.interface.d.ts +15 -0
  22. package/lib/inputs/select/input-select.component.d.ts +14 -0
  23. package/lib/inputs/select/input-select.interface.d.ts +14 -0
  24. package/lib/inputs/text/input-text.component.d.ts +13 -0
  25. package/lib/inputs/text/input-text.interface.d.ts +12 -0
  26. package/lib/inputs/textarea/input-textarea.component.d.ts +13 -0
  27. package/lib/inputs/textarea/input-textarea.interface.d.ts +15 -0
  28. package/lib/ngx-form.component.d.ts +57 -0
  29. package/lib/ngx-form.config.d.ts +10 -0
  30. package/lib/ngx-form.interface.d.ts +42 -0
  31. package/lib/pipes/index.d.ts +2 -0
  32. package/lib/pipes/input-error.pipe.d.ts +8 -0
  33. package/lib/pipes/multi-line.pipe.d.ts +12 -0
  34. package/lib/validators/index.d.ts +1 -0
  35. package/lib/validators/length.validator.d.ts +2 -0
  36. package/package.json +45 -0
  37. package/public-api.d.ts +3 -0
@@ -0,0 +1,964 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, HostBinding, Input, HostListener, Optional, Pipe, Component, Inject, Injector, InjectionToken, makeEnvironmentProviders, EventEmitter, ViewChild, Output } from '@angular/core';
3
+ import { NgClass, DecimalPipe, NgComponentOutlet } from '@angular/common';
4
+ import * as i1 from '@angular/forms';
5
+ import { ReactiveFormsModule, Validators, FormControl, FormGroup } from '@angular/forms';
6
+ import { MatButton } from '@angular/material/button';
7
+ import * as i3 from '@angular/material/form-field';
8
+ import { MatFormField } from '@angular/material/form-field';
9
+ import { MatIcon } from '@angular/material/icon';
10
+ import * as i2 from '@angular/material/input';
11
+ import { MatInputModule } from '@angular/material/input';
12
+ import { Helper } from '@webilix/helper-library';
13
+ import * as i1$1 from '@angular/platform-browser';
14
+ import * as i4 from '@angular/cdk/bidi';
15
+ import { provideNgxMask, NgxMaskDirective } from 'ngx-mask';
16
+ import * as i4$1 from '@angular/material/select';
17
+ import { MatSelectModule } from '@angular/material/select';
18
+ import * as i5 from '@angular/material/core';
19
+ import * as i1$2 from '@angular/router';
20
+
21
+ class AutoCompleteDirective {
22
+ autocomplete = 'one-time-code';
23
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AutoCompleteDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
24
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.3", type: AutoCompleteDirective, isStandalone: true, selector: "input[type=\"text\"]", host: { properties: { "attr.autocomplete": "this.autocomplete" } }, ngImport: i0 });
25
+ }
26
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AutoCompleteDirective, decorators: [{
27
+ type: Directive,
28
+ args: [{ selector: 'input[type="text"]' }]
29
+ }], propDecorators: { autocomplete: [{
30
+ type: HostBinding,
31
+ args: ['attr.autocomplete']
32
+ }] } });
33
+
34
+ class AutoFocusDirective {
35
+ elementRef;
36
+ AutoFocusDirective;
37
+ constructor(elementRef) {
38
+ this.elementRef = elementRef;
39
+ }
40
+ ngAfterViewInit() {
41
+ if (!this.AutoFocusDirective || !this.elementRef)
42
+ return;
43
+ const input = this.elementRef.nativeElement;
44
+ if (!input)
45
+ return;
46
+ setTimeout(() => {
47
+ if (input.focus)
48
+ input.focus();
49
+ if (input.select)
50
+ input.select();
51
+ }, 0);
52
+ }
53
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AutoFocusDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
54
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.3", type: AutoFocusDirective, isStandalone: true, selector: "[AutoFocusDirective]", inputs: { AutoFocusDirective: "AutoFocusDirective" }, ngImport: i0 });
55
+ }
56
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AutoFocusDirective, decorators: [{
57
+ type: Directive,
58
+ args: [{ selector: '[AutoFocusDirective]' }]
59
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { AutoFocusDirective: [{
60
+ type: Input,
61
+ args: [{ required: true }]
62
+ }] } });
63
+
64
+ class AutoHeightDirective {
65
+ elementRef;
66
+ renderer2;
67
+ AutoHeightDirective;
68
+ minHeight;
69
+ maxHeight = 0;
70
+ _focused = false;
71
+ focus() {
72
+ this._focused = true;
73
+ }
74
+ blur() {
75
+ this._focused = false;
76
+ }
77
+ constructor(elementRef, renderer2) {
78
+ this.elementRef = elementRef;
79
+ this.renderer2 = renderer2;
80
+ }
81
+ ngAfterViewInit() {
82
+ this.resize(true);
83
+ }
84
+ resize(forced) {
85
+ if (this.AutoHeightDirective !== true || (!forced && !this._focused))
86
+ return;
87
+ const textarea = this.elementRef.nativeElement;
88
+ const borderHeight = textarea.offsetHeight - textarea.clientHeight;
89
+ this.setHeight('auto');
90
+ let height = textarea.scrollHeight + borderHeight;
91
+ if (this.minHeight && this.minHeight > height)
92
+ height = this.minHeight;
93
+ if (this.maxHeight && this.maxHeight < height)
94
+ height = this.maxHeight;
95
+ this.setHeight(`${height}px`);
96
+ }
97
+ setHeight(value) {
98
+ this.renderer2.setStyle(this.elementRef.nativeElement, 'height', value);
99
+ this.renderer2.setStyle(this.elementRef.nativeElement, 'overflow', 'auto');
100
+ }
101
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AutoHeightDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
102
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.3", type: AutoHeightDirective, isStandalone: true, selector: "[AutoHeightDirective]", inputs: { AutoHeightDirective: "AutoHeightDirective", minHeight: "minHeight", maxHeight: "maxHeight" }, host: { listeners: { "focus": "focus()", "blur": "blur()", "input": "resize()" } }, ngImport: i0 });
103
+ }
104
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AutoHeightDirective, decorators: [{
105
+ type: Directive,
106
+ args: [{ selector: '[AutoHeightDirective]' }]
107
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { AutoHeightDirective: [{
108
+ type: Input,
109
+ args: [{ required: true }]
110
+ }], minHeight: [{
111
+ type: Input,
112
+ args: [{ required: true }]
113
+ }], maxHeight: [{
114
+ type: Input,
115
+ args: [{ required: false }]
116
+ }], focus: [{
117
+ type: HostListener,
118
+ args: ['focus']
119
+ }], blur: [{
120
+ type: HostListener,
121
+ args: ['blur']
122
+ }], resize: [{
123
+ type: HostListener,
124
+ args: ['input']
125
+ }] } });
126
+
127
+ class FormErrorDirective {
128
+ elementRef;
129
+ formGroupDirective;
130
+ onSubmit() {
131
+ if (this.formGroupDirective && this.formGroupDirective.control.invalid) {
132
+ const invalidControl = this.elementRef.nativeElement.querySelector('.ng-invalid');
133
+ if (invalidControl)
134
+ return this.scrollToElement(invalidControl);
135
+ }
136
+ const invalidControl = this.elementRef.nativeElement.querySelector('.ngx-form-invalid');
137
+ if (invalidControl)
138
+ this.scrollToElement(invalidControl);
139
+ }
140
+ constructor(elementRef, formGroupDirective) {
141
+ this.elementRef = elementRef;
142
+ this.formGroupDirective = formGroupDirective;
143
+ }
144
+ scrollToElement(element) {
145
+ const labelOffset = 150;
146
+ const top = element.getBoundingClientRect().top + window.scrollY - labelOffset;
147
+ window.scroll({ top, left: 0, behavior: 'smooth' });
148
+ }
149
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FormErrorDirective, deps: [{ token: i0.ElementRef }, { token: i1.FormGroupDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
150
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.3", type: FormErrorDirective, isStandalone: true, selector: "form.ngx-form", host: { listeners: { "submit": "onSubmit()" } }, ngImport: i0 });
151
+ }
152
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: FormErrorDirective, decorators: [{
153
+ type: Directive,
154
+ args: [{ selector: 'form.ngx-form' }]
155
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.FormGroupDirective, decorators: [{
156
+ type: Optional
157
+ }] }], propDecorators: { onSubmit: [{
158
+ type: HostListener,
159
+ args: ['submit']
160
+ }] } });
161
+
162
+ class InputErrorPipe {
163
+ transform(errors, type) {
164
+ if (errors === null || errors === undefined)
165
+ return '';
166
+ const keys = Object.keys(errors);
167
+ if (keys.length === 0)
168
+ return '';
169
+ const error = keys[0];
170
+ const value = errors[error];
171
+ switch (error) {
172
+ case 'required':
173
+ return 'مقدار الزامی است.';
174
+ case 'length':
175
+ return `مقدار باید داری ${Helper.NUMBER.format(value)} کاراکتر باشد.`;
176
+ case 'minlength':
177
+ return `مقدار باید حداقل داری ${Helper.NUMBER.format(value.requiredLength)} کاراکتر باشد.`;
178
+ case 'maxlength':
179
+ return `مقدار می‌تواند حداکثر داری ${Helper.NUMBER.format(value.requiredLength)} کاراکتر باشد.`;
180
+ case 'pattern':
181
+ switch (type) {
182
+ case 'EMAIL':
183
+ return 'فرمت استاندارد ایمیل رعایت نشده است.';
184
+ case 'PASSWORD':
185
+ switch (true) {
186
+ case value.requiredPattern.includes('[0-9]'):
187
+ return 'مقدار باید شامل اعداد انگلیسی باشد.';
188
+ case value.requiredPattern.includes('[a-z]'):
189
+ return 'مقدار باید شامل حروف انگلیسی کوچک باشد.';
190
+ case value.requiredPattern.includes('[A-Z]'):
191
+ return 'مقدار باید شامل حروف انگلیسی بزرگ باشد.';
192
+ }
193
+ return 'کاراکترهای الزامی در کلمه عبور استفاده نشده‌اند.';
194
+ }
195
+ break;
196
+ case 'mask':
197
+ switch (type) {
198
+ case 'MOBILE':
199
+ return 'شماره موبایل دارای ۱۱ رقم است.';
200
+ }
201
+ break;
202
+ }
203
+ return 'مقدار وارد شده صحیح نیست.';
204
+ }
205
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputErrorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
206
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: InputErrorPipe, isStandalone: true, name: "InputErrorPipe" });
207
+ }
208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputErrorPipe, decorators: [{
209
+ type: Pipe,
210
+ args: [{ name: 'InputErrorPipe' }]
211
+ }] });
212
+
213
+ class MultiLinePipe {
214
+ sanitizer;
215
+ constructor(sanitizer) {
216
+ this.sanitizer = sanitizer;
217
+ }
218
+ transform(value, config) {
219
+ if (!Helper.IS.string(value) || value === '')
220
+ return '';
221
+ return config?.html
222
+ ? this.sanitizer.bypassSecurityTrustHtml(value.replace(/(?:\r\n|\r|\n)/g, '<br />'))
223
+ : Helper.STRING.escapeHTML(value).replace(/(?:\r\n|\r|\n)/g, '<br />');
224
+ }
225
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: MultiLinePipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
226
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: MultiLinePipe, isStandalone: true, name: "MultiLinePipe" });
227
+ }
228
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: MultiLinePipe, decorators: [{
229
+ type: Pipe,
230
+ args: [{ name: 'MultiLinePipe' }]
231
+ }], ctorParameters: () => [{ type: i1$1.DomSanitizer }] });
232
+
233
+ class InputEmailComponent {
234
+ formControl;
235
+ input;
236
+ config;
237
+ focused = false;
238
+ constructor(formControl, input, config) {
239
+ this.formControl = formControl;
240
+ this.input = input;
241
+ this.config = config;
242
+ }
243
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputEmailComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
244
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputEmailComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-email" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0627\u06CC\u0645\u06CC\u0644' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- ICON -->\n\n @if (input.showIcon) {\n <span matTextSuffix class=\"suffix\" [style.opacity]=\"formControl.disabled ? '0.4' : 1\">\n <span [ngClass]=\"config.enClass\">&nbsp;</span>\n <mat-icon>alternate_email</mat-icon>\n </span>\n }\n\n <input\n matInput\n type=\"text\"\n inputmode=\"email\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"config.enClass\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".suffix{display:inline-flex}.suffix mat-icon{padding-right:.5rem}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "directive", type: AutoCompleteDirective, selector: "input[type=\"text\"]" }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
245
+ }
246
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputEmailComponent, decorators: [{
247
+ type: Component,
248
+ args: [{ host: { selector: 'input-email' }, imports: [
249
+ NgClass,
250
+ ReactiveFormsModule,
251
+ MatFormField,
252
+ MatIcon,
253
+ MatInputModule,
254
+ AutoCompleteDirective,
255
+ AutoFocusDirective,
256
+ InputErrorPipe,
257
+ MultiLinePipe,
258
+ ], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0627\u06CC\u0645\u06CC\u0644' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- ICON -->\n\n @if (input.showIcon) {\n <span matTextSuffix class=\"suffix\" [style.opacity]=\"formControl.disabled ? '0.4' : 1\">\n <span [ngClass]=\"config.enClass\">&nbsp;</span>\n <mat-icon>alternate_email</mat-icon>\n </span>\n }\n\n <input\n matInput\n type=\"text\"\n inputmode=\"email\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"config.enClass\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".suffix{display:inline-flex}.suffix mat-icon{padding-right:.5rem}\n"] }]
259
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
260
+ type: Inject,
261
+ args: ['formControl']
262
+ }] }, { type: undefined, decorators: [{
263
+ type: Inject,
264
+ args: ['input']
265
+ }] }, { type: undefined, decorators: [{
266
+ type: Inject,
267
+ args: ['config']
268
+ }] }] });
269
+
270
+ class InputMethods {
271
+ }
272
+
273
+ class InputEmailMethods extends InputMethods {
274
+ control(input, validators) {
275
+ validators.push(Validators.pattern(Helper.RE.EMAIL.get()));
276
+ const value = input.value === undefined ? null : Helper.RE.EMAIL.verify(input.value) ? input.value.toLowerCase() : null;
277
+ return new FormControl(value, validators);
278
+ }
279
+ value(value, input) {
280
+ return typeof value === 'string' && Helper.RE.EMAIL.verify(value) ? value.toLowerCase() : null;
281
+ }
282
+ }
283
+
284
+ class InputMobileComponent {
285
+ formControl;
286
+ input;
287
+ config;
288
+ focused = false;
289
+ inputTransformFn = (value) => Helper.STRING.changeNumbers(value.toString(), 'EN');
290
+ constructor(formControl, input, config) {
291
+ this.formControl = formControl;
292
+ this.input = input;
293
+ this.config = config;
294
+ }
295
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputMobileComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
296
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputMobileComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-mobile" } }, providers: [provideNgxMask()], ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0645\u0648\u0628\u0627\u06CC\u0644' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- ICON & SUFFIX -->\n <span matTextSuffix class=\"suffix\" [style.opacity]=\"formControl.disabled ? '0.4' : 1\">\n <span [ngClass]=\"config.enClass\">09</span>\n @if (input.showIcon) { <mat-icon>smartphone</mat-icon> }\n </span>\n\n <input\n matInput\n type=\"text\"\n inputmode=\"numeric\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"config.enClass\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n [mask]=\"'00-000-0000'\"\n [inputTransformFn]=\"inputTransformFn\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".suffix{display:inline-flex}.suffix mat-icon{padding-right:.5rem}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "directive", type: NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: ["mask", "specialCharacters", "patterns", "prefix", "suffix", "thousandSeparator", "decimalMarker", "dropSpecialCharacters", "hiddenInput", "showMaskTyped", "placeHolderCharacter", "shownMaskExpression", "clearIfNotMatch", "validation", "separatorLimit", "allowNegativeNumbers", "leadZeroDateTime", "leadZero", "triggerOnMaskChange", "apm", "inputTransformFn", "outputTransformFn", "keepCharacterPositions"], outputs: ["maskFilled"], exportAs: ["mask", "ngxMask"] }, { kind: "directive", type: AutoCompleteDirective, selector: "input[type=\"text\"]" }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
297
+ }
298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputMobileComponent, decorators: [{
299
+ type: Component,
300
+ args: [{ host: { selector: 'input-mobile' }, imports: [
301
+ NgClass,
302
+ ReactiveFormsModule,
303
+ MatFormField,
304
+ MatIcon,
305
+ MatInputModule,
306
+ NgxMaskDirective,
307
+ AutoCompleteDirective,
308
+ AutoFocusDirective,
309
+ InputErrorPipe,
310
+ MultiLinePipe,
311
+ ], providers: [provideNgxMask()], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0645\u0648\u0628\u0627\u06CC\u0644' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- ICON & SUFFIX -->\n <span matTextSuffix class=\"suffix\" [style.opacity]=\"formControl.disabled ? '0.4' : 1\">\n <span [ngClass]=\"config.enClass\">09</span>\n @if (input.showIcon) { <mat-icon>smartphone</mat-icon> }\n </span>\n\n <input\n matInput\n type=\"text\"\n inputmode=\"numeric\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"config.enClass\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n [mask]=\"'00-000-0000'\"\n [inputTransformFn]=\"inputTransformFn\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".suffix{display:inline-flex}.suffix mat-icon{padding-right:.5rem}\n"] }]
312
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
313
+ type: Inject,
314
+ args: ['formControl']
315
+ }] }, { type: undefined, decorators: [{
316
+ type: Inject,
317
+ args: ['input']
318
+ }] }, { type: undefined, decorators: [{
319
+ type: Inject,
320
+ args: ['config']
321
+ }] }] });
322
+
323
+ class InputMobileMethods extends InputMethods {
324
+ control(input, validators) {
325
+ const value = input.value === undefined ? null : Helper.RE.MOBILE.verify(input.value) ? input.value.substring(2) : null;
326
+ return new FormControl(value, validators);
327
+ }
328
+ value(value, input) {
329
+ return typeof value === 'string' && Helper.RE.MOBILE.verify(`09${value}`) ? `09${value}` : null;
330
+ }
331
+ }
332
+
333
+ class InputNameComponent {
334
+ formControl;
335
+ input;
336
+ config;
337
+ firstFormControl;
338
+ lastFormControl;
339
+ constructor(formControl, input, config) {
340
+ this.formControl = formControl;
341
+ this.input = input;
342
+ this.config = config;
343
+ }
344
+ ngOnInit() {
345
+ const value = this.formControl.value;
346
+ const first = value?.first || null;
347
+ const last = value?.last || null;
348
+ this.firstFormControl = new FormControl(first, this.input.optional ? [] : [Validators.required]);
349
+ this.lastFormControl = new FormControl(last, this.input.optional ? [] : [Validators.required]);
350
+ this.formControl.statusChanges.subscribe({
351
+ next: () => {
352
+ if (this.formControl.disabled) {
353
+ this.firstFormControl.disable();
354
+ this.lastFormControl.disable();
355
+ }
356
+ else {
357
+ this.firstFormControl.enable();
358
+ this.lastFormControl.enable();
359
+ }
360
+ },
361
+ });
362
+ }
363
+ setName() {
364
+ const first = (this.firstFormControl.value || '').trim();
365
+ const last = (this.lastFormControl.value || '').trim();
366
+ const value = first !== '' && last !== '' ? { first, last } : null;
367
+ this.formControl.setValue(value);
368
+ }
369
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputNameComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
370
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputNameComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-name" } }, ngImport: i0, template: "<!-- INPUT -->\n<input matInput type=\"text\" [name]=\"input.name\" [formControl]=\"formControl\" [style.display]=\"'none !important'\" />\n\n<div class=\"columns\">\n <!-- FIRST NAME -->\n <mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>\u0646\u0627\u0645 {{ input.title || '' }}</mat-label>\n @if (firstFormControl.invalid) { <mat-error>{{ firstFormControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <input\n matInput\n type=\"text\"\n [name]=\"input.name + '-first'\"\n [formControl]=\"firstFormControl\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (input)=\"setName()\"\n />\n </mat-form-field>\n <!-- LAST NAME -->\n <mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>\u0646\u0627\u0645 \u062E\u0627\u0646\u0648\u0627\u062F\u06AF\u06CC {{ input.title || '' }}</mat-label>\n @if (lastFormControl.invalid) { <mat-error>{{ lastFormControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <input matInput type=\"text\" [name]=\"input.name + '-last'\" [formControl]=\"lastFormControl\" (input)=\"setName()\" />\n </mat-form-field>\n</div>\n", styles: [".columns{display:flex;column-gap:1rem}.columns mat-form-field{flex:1}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: AutoCompleteDirective, selector: "input[type=\"text\"]" }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }] });
371
+ }
372
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputNameComponent, decorators: [{
373
+ type: Component,
374
+ args: [{ host: { selector: 'input-name' }, imports: [ReactiveFormsModule, MatFormField, MatInputModule, AutoCompleteDirective, AutoFocusDirective, InputErrorPipe], template: "<!-- INPUT -->\n<input matInput type=\"text\" [name]=\"input.name\" [formControl]=\"formControl\" [style.display]=\"'none !important'\" />\n\n<div class=\"columns\">\n <!-- FIRST NAME -->\n <mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>\u0646\u0627\u0645 {{ input.title || '' }}</mat-label>\n @if (firstFormControl.invalid) { <mat-error>{{ firstFormControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <input\n matInput\n type=\"text\"\n [name]=\"input.name + '-first'\"\n [formControl]=\"firstFormControl\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (input)=\"setName()\"\n />\n </mat-form-field>\n <!-- LAST NAME -->\n <mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>\u0646\u0627\u0645 \u062E\u0627\u0646\u0648\u0627\u062F\u06AF\u06CC {{ input.title || '' }}</mat-label>\n @if (lastFormControl.invalid) { <mat-error>{{ lastFormControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <input matInput type=\"text\" [name]=\"input.name + '-last'\" [formControl]=\"lastFormControl\" (input)=\"setName()\" />\n </mat-form-field>\n</div>\n", styles: [".columns{display:flex;column-gap:1rem}.columns mat-form-field{flex:1}\n"] }]
375
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
376
+ type: Inject,
377
+ args: ['formControl']
378
+ }] }, { type: undefined, decorators: [{
379
+ type: Inject,
380
+ args: ['input']
381
+ }] }, { type: undefined, decorators: [{
382
+ type: Inject,
383
+ args: ['config']
384
+ }] }] });
385
+
386
+ class InputNameMethods extends InputMethods {
387
+ control(input, validators) {
388
+ const value = input.value && Helper.IS.object(input.value) && !!input.value.first && !!input.value.last ? input.value : null;
389
+ return new FormControl(value, validators);
390
+ }
391
+ value(value, input) {
392
+ return Helper.IS.object(value) ? value : null;
393
+ }
394
+ }
395
+
396
+ class InputPasswordComponent {
397
+ formControl;
398
+ input;
399
+ config;
400
+ focused = false;
401
+ showPassword = false;
402
+ constructor(formControl, input, config) {
403
+ this.formControl = formControl;
404
+ this.input = input;
405
+ this.config = config;
406
+ }
407
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputPasswordComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
408
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputPasswordComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-password" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u06A9\u0644\u0645\u0647 \u0639\u0628\u0648\u0631' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- SHOW PASSWORD -->\n <span\n matTextSuffix\n class=\"suffix\"\n (click)=\"showPassword = !showPassword\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n >\n <span [ngClass]=\"config.enClass\">&nbsp;</span>\n <mat-icon>{{ showPassword ? 'visibility_off' : 'visibility' }}</mat-icon>\n </span>\n\n <input\n matInput\n [type]=\"showPassword ? 'text' : 'password'\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"config.enClass\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".suffix{display:inline-flex}.suffix mat-icon{cursor:pointer;padding-right:.5rem}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
409
+ }
410
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputPasswordComponent, decorators: [{
411
+ type: Component,
412
+ args: [{ host: { selector: 'input-password' }, imports: [
413
+ NgClass,
414
+ ReactiveFormsModule,
415
+ MatFormField,
416
+ MatIcon,
417
+ MatInputModule,
418
+ AutoFocusDirective,
419
+ InputErrorPipe,
420
+ MultiLinePipe,
421
+ ], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u06A9\u0644\u0645\u0647 \u0639\u0628\u0648\u0631' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- SHOW PASSWORD -->\n <span\n matTextSuffix\n class=\"suffix\"\n (click)=\"showPassword = !showPassword\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n >\n <span [ngClass]=\"config.enClass\">&nbsp;</span>\n <mat-icon>{{ showPassword ? 'visibility_off' : 'visibility' }}</mat-icon>\n </span>\n\n <input\n matInput\n [type]=\"showPassword ? 'text' : 'password'\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"config.enClass\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".suffix{display:inline-flex}.suffix mat-icon{cursor:pointer;padding-right:.5rem}\n"] }]
422
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
423
+ type: Inject,
424
+ args: ['formControl']
425
+ }] }, { type: undefined, decorators: [{
426
+ type: Inject,
427
+ args: ['input']
428
+ }] }, { type: undefined, decorators: [{
429
+ type: Inject,
430
+ args: ['config']
431
+ }] }] });
432
+
433
+ class InputPasswordMethods extends InputMethods {
434
+ control(input, validators) {
435
+ if (input.verify) {
436
+ validators.push(Validators.minLength(input.verify.minLength));
437
+ if (input.verify.forceLowerCase)
438
+ validators.push(Validators.pattern(Helper.RE.PASSWORD.get(input.verify.minLength, true, false, false)));
439
+ if (input.verify.forceUpperCase)
440
+ validators.push(Validators.pattern(Helper.RE.PASSWORD.get(input.verify.minLength, false, true, false)));
441
+ if (input.verify.forceNumber)
442
+ validators.push(Validators.pattern(Helper.RE.PASSWORD.get(input.verify.minLength, false, false, true)));
443
+ }
444
+ return new FormControl(null, validators);
445
+ }
446
+ value(value, input) {
447
+ return Helper.IS.string(value) && value !== '' ? value : null;
448
+ }
449
+ }
450
+
451
+ class InputSelectComponent {
452
+ formControl;
453
+ input;
454
+ config;
455
+ focused = false;
456
+ constructor(formControl, input, config) {
457
+ this.formControl = formControl;
458
+ this.input = input;
459
+ this.config = config;
460
+ }
461
+ getTitle() {
462
+ return this.input.options.find((option) => option.id === this.formControl.value)?.title || '';
463
+ }
464
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputSelectComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
465
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputSelectComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-select" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <mat-select\n [formControl]=\"formControl\"\n [ngClass]=\"input.english ? config.enClass : ''\"\n [dir]=\"'rtl'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n >\n <!-- OPTIONAL -->\n @if (!!input.optional) { <mat-option></mat-option> }\n\n <!-- TRIGGER -->\n <mat-select-trigger>\n <div [ngClass]=\"input.english ? ['english', config.enClass] : ''\">{{ getTitle() }}</div>\n </mat-select-trigger>\n\n <!-- OPTIONS -->\n @for (option of input.options; track $index) {\n <mat-option [value]=\"option.id\">\n <div [ngClass]=\"input.english ? ['english', config.enClass] : ''\">{{ option.title }}</div>\n </mat-option>\n }\n </mat-select>\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".english{display:inline-block;direction:ltr}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4$1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i4$1.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i5.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
466
+ }
467
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputSelectComponent, decorators: [{
468
+ type: Component,
469
+ args: [{ host: { selector: 'input-select' }, imports: [
470
+ NgClass,
471
+ ReactiveFormsModule,
472
+ MatFormField,
473
+ MatInputModule,
474
+ MatSelectModule,
475
+ AutoFocusDirective,
476
+ InputErrorPipe,
477
+ MultiLinePipe,
478
+ ], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <mat-select\n [formControl]=\"formControl\"\n [ngClass]=\"input.english ? config.enClass : ''\"\n [dir]=\"'rtl'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n >\n <!-- OPTIONAL -->\n @if (!!input.optional) { <mat-option></mat-option> }\n\n <!-- TRIGGER -->\n <mat-select-trigger>\n <div [ngClass]=\"input.english ? ['english', config.enClass] : ''\">{{ getTitle() }}</div>\n </mat-select-trigger>\n\n <!-- OPTIONS -->\n @for (option of input.options; track $index) {\n <mat-option [value]=\"option.id\">\n <div [ngClass]=\"input.english ? ['english', config.enClass] : ''\">{{ option.title }}</div>\n </mat-option>\n }\n </mat-select>\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [".english{display:inline-block;direction:ltr}\n"] }]
479
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
480
+ type: Inject,
481
+ args: ['formControl']
482
+ }] }, { type: undefined, decorators: [{
483
+ type: Inject,
484
+ args: ['input']
485
+ }] }, { type: undefined, decorators: [{
486
+ type: Inject,
487
+ args: ['config']
488
+ }] }] });
489
+
490
+ class InputSelectMethods extends InputMethods {
491
+ control(input, validators) {
492
+ const ids = input.options.map((option) => option.id);
493
+ const value = input.value && ids.includes(input.value) ? input.value : null;
494
+ return new FormControl(value, validators);
495
+ }
496
+ value(value, input) {
497
+ return value && input.options.find((option) => option.id === value) ? value : null;
498
+ }
499
+ }
500
+
501
+ class InputTextComponent {
502
+ formControl;
503
+ input;
504
+ config;
505
+ focused = false;
506
+ constructor(formControl, input, config) {
507
+ this.formControl = formControl;
508
+ this.input = input;
509
+ this.config = config;
510
+ }
511
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputTextComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
512
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputTextComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-text" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <input\n matInput\n type=\"text\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"input.english ? config.enClass : ''\"\n [maxLength]=\"input.maxLength || 524288\"\n [dir]=\"input.english ? 'ltr' : 'rtl'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [""], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "directive", type: AutoCompleteDirective, selector: "input[type=\"text\"]" }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
513
+ }
514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputTextComponent, decorators: [{
515
+ type: Component,
516
+ args: [{ host: { selector: 'input-text' }, imports: [
517
+ NgClass,
518
+ ReactiveFormsModule,
519
+ MatFormField,
520
+ MatInputModule,
521
+ AutoCompleteDirective,
522
+ AutoFocusDirective,
523
+ InputErrorPipe,
524
+ MultiLinePipe,
525
+ ], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <input\n matInput\n type=\"text\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"input.english ? config.enClass : ''\"\n [maxLength]=\"input.maxLength || 524288\"\n [dir]=\"input.english ? 'ltr' : 'rtl'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n" }]
526
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
527
+ type: Inject,
528
+ args: ['formControl']
529
+ }] }, { type: undefined, decorators: [{
530
+ type: Inject,
531
+ args: ['input']
532
+ }] }, { type: undefined, decorators: [{
533
+ type: Inject,
534
+ args: ['config']
535
+ }] }] });
536
+
537
+ const LengthValidator = (length) => {
538
+ return (formControl) => {
539
+ const value = formControl.value;
540
+ if (Helper.IS.empty(value) || !Helper.IS.string(value))
541
+ return null;
542
+ return value.length !== length ? { length } : null;
543
+ };
544
+ };
545
+
546
+ class InputTextMethods extends InputMethods {
547
+ control(input, validators) {
548
+ const minLength = input.minLength && input.minLength > 0 ? input.minLength : null;
549
+ const maxLength = input.maxLength && input.maxLength > 0 ? input.maxLength : null;
550
+ if (minLength && maxLength && minLength === maxLength)
551
+ validators.push(LengthValidator(minLength));
552
+ else {
553
+ if (minLength && minLength > 0)
554
+ validators.push(Validators.minLength(minLength));
555
+ if (maxLength && maxLength > 0)
556
+ validators.push(Validators.maxLength(maxLength));
557
+ }
558
+ return new FormControl(input.value || null, validators);
559
+ }
560
+ value(value, input) {
561
+ return Helper.IS.string(value) && value !== '' ? value : null;
562
+ }
563
+ }
564
+
565
+ class InputTextareaComponent {
566
+ formControl;
567
+ input;
568
+ config;
569
+ focused = false;
570
+ constructor(formControl, input, config) {
571
+ this.formControl = formControl;
572
+ this.input = input;
573
+ this.config = config;
574
+ }
575
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputTextareaComponent, deps: [{ token: 'formControl' }, { token: 'input' }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Component });
576
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: InputTextareaComponent, isStandalone: true, selector: "ng-component", host: { attributes: { "selector": "input-textarea" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- COUNTER -->\n @if (focused && input.counter) {\n <mat-hint [align]=\"'end'\">\n {{ formControl.value?.length || 0 | number }}{{ input.maxLength ? ' \u0627\u0632 ' + (input.maxLength | number) : '' }}\n </mat-hint>\n }\n\n <textarea\n matInput\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"input.english ? config.enClass : ''\"\n [dir]=\"input.english ? 'ltr' : 'rtl'\"\n [style.height]=\"input.height ? input.height.toString() + 'px' : '75px'\"\n [style.resize]=\"'none'\"\n [maxLength]=\"input.maxLength || 524288\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n [AutoHeightDirective]=\"!!input.autoHeight\"\n [minHeight]=\"input.height || 75\"\n [maxHeight]=\"input.maxHeight || 0\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n ></textarea>\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [""], dependencies: [{ kind: "pipe", type: DecimalPipe, name: "number" }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "directive", type: AutoFocusDirective, selector: "[AutoFocusDirective]", inputs: ["AutoFocusDirective"] }, { kind: "directive", type: AutoHeightDirective, selector: "[AutoHeightDirective]", inputs: ["AutoHeightDirective", "minHeight", "maxHeight"] }, { kind: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
577
+ }
578
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputTextareaComponent, decorators: [{
579
+ type: Component,
580
+ args: [{ host: { selector: 'input-textarea' }, imports: [
581
+ DecimalPipe,
582
+ NgClass,
583
+ ReactiveFormsModule,
584
+ MatFormField,
585
+ MatInputModule,
586
+ AutoFocusDirective,
587
+ AutoHeightDirective,
588
+ InputErrorPipe,
589
+ MultiLinePipe,
590
+ ], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (focused && input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- COUNTER -->\n @if (focused && input.counter) {\n <mat-hint [align]=\"'end'\">\n {{ formControl.value?.length || 0 | number }}{{ input.maxLength ? ' \u0627\u0632 ' + (input.maxLength | number) : '' }}\n </mat-hint>\n }\n\n <textarea\n matInput\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n [ngClass]=\"input.english ? config.enClass : ''\"\n [dir]=\"input.english ? 'ltr' : 'rtl'\"\n [style.height]=\"input.height ? input.height.toString() + 'px' : '75px'\"\n [style.resize]=\"'none'\"\n [maxLength]=\"input.maxLength || 524288\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n [AutoHeightDirective]=\"!!input.autoHeight\"\n [minHeight]=\"input.height || 75\"\n [maxHeight]=\"input.maxHeight || 0\"\n (focus)=\"focused = true\"\n (blur)=\"focused = false\"\n ></textarea>\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n [ngClass]=\"config.descriptionClass\"\n [style.opacity]=\"formControl.disabled ? '0.4' : 1\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n" }]
591
+ }], ctorParameters: () => [{ type: i1.FormControl, decorators: [{
592
+ type: Inject,
593
+ args: ['formControl']
594
+ }] }, { type: undefined, decorators: [{
595
+ type: Inject,
596
+ args: ['input']
597
+ }] }, { type: undefined, decorators: [{
598
+ type: Inject,
599
+ args: ['config']
600
+ }] }] });
601
+
602
+ class InputTextareaMethods extends InputMethods {
603
+ control(input, validators) {
604
+ const maxLength = input.maxLength && input.maxLength > 0 ? input.maxLength : null;
605
+ if (maxLength && maxLength > 0)
606
+ validators.push(Validators.maxLength(maxLength));
607
+ return new FormControl(input.value || null, validators);
608
+ }
609
+ value(value, input) {
610
+ return Helper.IS.string(value) && value !== '' ? value : null;
611
+ }
612
+ }
613
+
614
+ class InputComponent {
615
+ formGroup;
616
+ input;
617
+ config;
618
+ inputInfo = InputInfo;
619
+ injector;
620
+ ngOnInit() {
621
+ const formControl = this.formGroup.get(this.input.name);
622
+ this.injector = Injector.create({
623
+ providers: [
624
+ { provide: 'formControl', useValue: formControl },
625
+ { provide: 'input', useValue: this.input },
626
+ { provide: 'config', useValue: this.config },
627
+ ],
628
+ });
629
+ }
630
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
631
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: InputComponent, isStandalone: true, selector: "form-input", inputs: { formGroup: "formGroup", input: "input", config: "config" }, ngImport: i0, template: "<ng-container *ngComponentOutlet=\"inputInfo[input.type].component; injector: injector\"></ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"] }] });
632
+ }
633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: InputComponent, decorators: [{
634
+ type: Component,
635
+ args: [{ selector: 'form-input', imports: [NgComponentOutlet], template: "<ng-container *ngComponentOutlet=\"inputInfo[input.type].component; injector: injector\"></ng-container>\n" }]
636
+ }], propDecorators: { formGroup: [{
637
+ type: Input,
638
+ args: [{ required: true }]
639
+ }], input: [{
640
+ type: Input,
641
+ args: [{ required: true }]
642
+ }], config: [{
643
+ type: Input,
644
+ args: [{ required: true }]
645
+ }] } });
646
+
647
+ const InputInfo = {
648
+ EMAIL: { title: 'ایمیل', methods: new InputEmailMethods(), component: InputEmailComponent },
649
+ MOBILE: { title: 'موبایل', methods: new InputMobileMethods(), component: InputMobileComponent },
650
+ NAME: { title: 'نام و نام خانوادگی', methods: new InputNameMethods(), component: InputNameComponent },
651
+ PASSWORD: { title: 'کلمه عبور', methods: new InputPasswordMethods(), component: InputPasswordComponent },
652
+ SELECT: { title: 'لیست کشویی', methods: new InputSelectMethods(), component: InputSelectComponent },
653
+ TEXT: { title: 'متن یک خطی', methods: new InputTextMethods(), component: InputTextComponent },
654
+ TEXTAREA: { title: 'متن چند خطی', methods: new InputTextareaMethods(), component: InputTextareaComponent },
655
+ };
656
+
657
+ const NGX_FORM_CONFIG = new InjectionToken('NGX-FORM-CONFIG');
658
+ const provideNgxFormConfig = (config) => {
659
+ const providers = [{ provide: NGX_FORM_CONFIG, useValue: config }];
660
+ return makeEnvironmentProviders(providers);
661
+ };
662
+
663
+ class NgxFormComponent {
664
+ router;
665
+ config;
666
+ ngForm;
667
+ onResize = (event) => this.setSize();
668
+ ngxForm;
669
+ onInit = new EventEmitter();
670
+ onSubmit = new EventEmitter();
671
+ onChange = new EventEmitter();
672
+ formGroup;
673
+ sections = [];
674
+ hiddenInputs = [];
675
+ lastValues = {};
676
+ lastSubmit;
677
+ isMobile = false;
678
+ headerClass;
679
+ inputConfig;
680
+ constructor(router, config) {
681
+ this.router = router;
682
+ this.config = config;
683
+ }
684
+ ngOnInit() {
685
+ this.headerClass = this.config?.headerClass || 'ngx-form-header';
686
+ this.inputConfig = {
687
+ appearance: this.ngxForm.appearance || 'fill',
688
+ enClass: this.config?.enClass || 'ngx-form-en',
689
+ descriptionClass: this.config?.descriptionClass || 'ngx-form-description',
690
+ };
691
+ this.formGroup = new FormGroup({});
692
+ const inputs = this.getInputs();
693
+ // SET FORM GROUP INPUTS
694
+ inputs.forEach((input) => this.setInput(input));
695
+ // CHECK AUTO FOCUS
696
+ let autoFocus = undefined;
697
+ inputs.forEach((input) => {
698
+ if (!('autoFocus' in input) || !input.autoFocus || autoFocus)
699
+ return;
700
+ if (!input.disableOn && !input.hideOn)
701
+ autoFocus = input.name;
702
+ });
703
+ this.inputConfig = { ...this.inputConfig, autoFocus };
704
+ // REGISTER VALUE CHANGE
705
+ this.formGroup.valueChanges.subscribe({
706
+ next: () => {
707
+ const changedInputs = [];
708
+ [...Object.keys(this.lastValues), ...Object.keys(this.formGroup.value)]
709
+ .filter((key, index, arr) => arr.indexOf(key) === index)
710
+ .forEach((key) => {
711
+ if (this.formGroup.value[key] !== this.lastValues[key])
712
+ changedInputs.push(key);
713
+ });
714
+ if (changedInputs.length === 0)
715
+ return;
716
+ this.lastValues = { ...this.formGroup.value };
717
+ this.checkInputs();
718
+ if (this.ngxForm.updateValues) {
719
+ const values = this.getValues();
720
+ const changes = this.ngxForm.updateValues(values);
721
+ Object.keys(changes)
722
+ .filter((key) => !changedInputs.includes(key))
723
+ .forEach((key) => {
724
+ const input = this.getInputs().find((i) => i.name === key);
725
+ if (!input)
726
+ return;
727
+ const formInput = this.formGroup.get(key);
728
+ if (!formInput)
729
+ return;
730
+ const value = InputInfo[input.type].methods.value(changes[key], input);
731
+ formInput.setValue(value);
732
+ });
733
+ this.lastValues = { ...this.formGroup.value };
734
+ }
735
+ this.onChange.next(this.getValues());
736
+ },
737
+ });
738
+ this.checkInputs();
739
+ this.setSize();
740
+ }
741
+ ngOnChanges(changes) {
742
+ this.sections = [];
743
+ this.ngxForm.inputs.forEach((inputs) => {
744
+ // SECTION
745
+ if ('columns' in inputs) {
746
+ this.sections.push({
747
+ header: inputs.header || '',
748
+ columns: inputs.columns.map((column) => {
749
+ return {
750
+ header: column.header || '',
751
+ rows: column.rows.map((row) => 'inputs' in row
752
+ ? {
753
+ header: row.header || '',
754
+ inputs: row.inputs,
755
+ flex: row.inputs.map((_, i) => row.flex?.[i] || 1),
756
+ }
757
+ : 'input' in row
758
+ ? { header: row.header, inputs: [row.input], flex: [1] }
759
+ : { header: '', inputs: [row], flex: [1] }),
760
+ flex: [],
761
+ };
762
+ }),
763
+ flex: inputs.columns.map((_, c) => inputs.flex?.[c] || 1),
764
+ });
765
+ return;
766
+ }
767
+ // INPUTS
768
+ if ('inputs' in inputs) {
769
+ this.sections.push({
770
+ header: inputs.header || '',
771
+ columns: [
772
+ {
773
+ header: '',
774
+ rows: [
775
+ {
776
+ header: '',
777
+ inputs: inputs.inputs,
778
+ flex: inputs.inputs.map((_, i) => inputs.flex?.[i] || 1),
779
+ },
780
+ ],
781
+ },
782
+ ],
783
+ flex: [1],
784
+ });
785
+ return;
786
+ }
787
+ // HEADER
788
+ if ('input' in inputs) {
789
+ this.sections.push({
790
+ header: inputs.header || '',
791
+ columns: [{ header: '', rows: [{ header: '', inputs: [inputs.input], flex: [1] }] }],
792
+ flex: [1],
793
+ });
794
+ return;
795
+ }
796
+ // INPUT
797
+ this.sections.push({
798
+ header: '',
799
+ columns: [{ header: '', rows: [{ header: '', inputs: [inputs], flex: [1] }] }],
800
+ flex: [1],
801
+ });
802
+ });
803
+ }
804
+ ngAfterViewInit() {
805
+ this.onInit.next({ formGroup: this.formGroup, ngForm: this.ngForm });
806
+ }
807
+ getInputs() {
808
+ const list = [];
809
+ this.ngxForm.inputs.forEach((inputs) => {
810
+ // SECTION
811
+ if ('columns' in inputs) {
812
+ inputs.columns.forEach((column) => {
813
+ column.rows.forEach((row) => {
814
+ if ('inputs' in row)
815
+ list.push(...row.inputs);
816
+ else
817
+ list.push('input' in row ? row.input : row);
818
+ });
819
+ });
820
+ return;
821
+ }
822
+ // INPUTS
823
+ if ('inputs' in inputs)
824
+ list.push(...inputs.inputs);
825
+ else
826
+ list.push('input' in inputs ? inputs.input : inputs);
827
+ });
828
+ return list;
829
+ }
830
+ getValues() {
831
+ const inputs = this.getInputs();
832
+ const values = {};
833
+ const getValue = (input) => {
834
+ if (this.hiddenInputs.includes(input.name))
835
+ return null;
836
+ const formInput = this.formGroup.get(input.name);
837
+ if (!formInput || formInput.disabled || formInput.errors !== null)
838
+ return null;
839
+ const value = InputInfo[input.type].methods.value(formInput.value, input);
840
+ return value;
841
+ };
842
+ inputs.forEach((input) => {
843
+ values[input.name] = getValue(input);
844
+ });
845
+ return values;
846
+ }
847
+ setInput(input) {
848
+ const name = input.name;
849
+ const validators = input.optional ? [] : [Validators.required];
850
+ this.formGroup.setControl(name, InputInfo[input.type].methods.control(input, validators));
851
+ }
852
+ checkInputs() {
853
+ const inputs = this.getInputs();
854
+ const values = this.getValues();
855
+ // CHECK DISABLED INPUTS
856
+ inputs.forEach((input) => {
857
+ if (!('disableOn' in input) || !input.disableOn)
858
+ return;
859
+ const formInput = this.formGroup.get(input.name);
860
+ if (!formInput)
861
+ return;
862
+ const disabled = input.disableOn(values);
863
+ disabled ? formInput.disable() : formInput.enable();
864
+ });
865
+ // CHECK HIDDEN INPUTS
866
+ this.hiddenInputs = [];
867
+ inputs.forEach((input) => {
868
+ if (!('hideOn' in input) || !input.hideOn)
869
+ return;
870
+ const formInput = this.formGroup.get(input.name);
871
+ if (!formInput)
872
+ return;
873
+ const hidden = input.hideOn(values);
874
+ hidden ? formInput.disable() : formInput.enable();
875
+ if (hidden)
876
+ this.hiddenInputs.push(input.name);
877
+ });
878
+ }
879
+ checkSubmit() {
880
+ this.formGroup.markAllAsTouched();
881
+ if (this.formGroup.invalid)
882
+ return;
883
+ const submitTimeout = this.config?.submitTimeout;
884
+ if (!!submitTimeout && this.lastSubmit) {
885
+ const timeout = submitTimeout * 1000;
886
+ const duration = new Date().getTime() - this.lastSubmit.getTime();
887
+ if (duration < timeout)
888
+ return;
889
+ }
890
+ this.onSubmit.next(this.getValues());
891
+ this.lastSubmit = new Date();
892
+ }
893
+ setSize() {
894
+ const mobileWidth = this.config?.mobileWidth || 600;
895
+ this.isMobile = this.ngxForm.mobileView || window.innerWidth <= mobileWidth;
896
+ }
897
+ showSection(section) {
898
+ for (let c = 0; c < section.columns.length; c++) {
899
+ if (this.showColumn(section.columns[c]))
900
+ return true;
901
+ }
902
+ return false;
903
+ }
904
+ showColumn(column) {
905
+ for (let r = 0; r < column.rows.length; r++) {
906
+ if (this.showRow(column.rows[r]))
907
+ return true;
908
+ }
909
+ return false;
910
+ }
911
+ showRow(row) {
912
+ for (let i = 0; i < row.inputs.length; i++) {
913
+ if (this.showInput(row.inputs[i]))
914
+ return true;
915
+ }
916
+ return false;
917
+ }
918
+ showInput(input) {
919
+ return !this.hiddenInputs.includes(input.name);
920
+ }
921
+ onClick(action) {
922
+ if (typeof action === 'function')
923
+ action();
924
+ else
925
+ this.router.navigate(action);
926
+ }
927
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxFormComponent, deps: [{ token: i1$2.Router }, { token: NGX_FORM_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Component });
928
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: NgxFormComponent, isStandalone: true, selector: "ngx-form", inputs: { ngxForm: "ngxForm" }, outputs: { onInit: "onInit", onSubmit: "onSubmit", onChange: "onChange" }, host: { listeners: { "window:resize": "onResize($event)" } }, viewQueries: [{ propertyName: "ngForm", first: true, predicate: ["formObject"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<form [formGroup]=\"formGroup\" (ngSubmit)=\"checkSubmit()\" dir=\"rtl\" class=\"ngx-form\" #formObject=\"ngForm\">\n <div class=\"sections\">\n @for (section of sections; track $index) {\n <!-- CHECK SECTION VIEW -->\n @if (showSection(section)) {\n <!-- SECTION HEADER -->\n @if (section.header) {\n <div [ngClass]=\"[headerClass, 'section-header']\">{{ section.header }}</div>\n }\n\n <div class=\"section\" [class.section-mobile]=\"isMobile\">\n <!-- SECTIONS -->\n @for (column of section.columns; track $index) {\n <!-- CHECK COLUMN VIEW -->\n @if (showColumn(column)) {\n <div class=\"column\" [style.flex]=\"section.flex[$index]\">\n <!-- COLUMN HEADER -->\n @if (column.header) {\n <div [ngClass]=\"[headerClass, 'column-header']\">{{ column.header }}</div>\n }\n\n <!-- ROWS -->\n @for (row of column.rows; track $index) {\n <!-- CHECK Row VIEW -->\n @if (showRow(row)) {\n <!-- ROW HEADER -->\n @if (row.header) {\n <div [ngClass]=\"[headerClass, 'row-header']\">{{ row.header }}</div>\n }\n\n <div class=\"inputs\">\n <!-- INPUTS -->\n @for (input of row.inputs; track $index) {\n <!-- CHECK Row VIEW -->\n @if (showInput(input)) {\n <div class=\"input\" [style.flex]=\"row.flex[$index]\">\n <form-input [formGroup]=\"formGroup\" [input]=\"input\" [config]=\"inputConfig\"></form-input>\n </div>\n } }\n </div>\n } }\n </div>\n } }\n </div>\n } }\n </div>\n\n <div class=\"buttons\" [class.buttons-mobile]=\"isMobile\">\n <!-- EXTRA BUTTONS -->\n @for (item of (ngxForm.buttons || []); track $index) {\n <button type=\"button\" mat-stroked-button (click)=\"onClick(item.action)\">{{ item.title }}</button>\n }\n <!-- SUBMIT BUTTON -->\n <button type=\"submit\" mat-flat-button>{{ ngxForm.submit }}</button>\n </div>\n</form>\n", styles: [".sections{display:flex;flex-direction:column}.sections .column-header,.sections .section-header{margin-bottom:1rem}.sections .row-header{margin:1rem 0}.sections .section,.sections .section .column .inputs{display:flex;align-items:flex-start;column-gap:1rem}.sections .section-mobile{display:block}.buttons{display:flex;align-items:center;justify-content:flex-end;column-gap:1rem;margin-top:1rem}.buttons-mobile button[type=submit]{flex:1}:host ::ng-deep mat-form-field{width:100%;margin-bottom:.5rem}:host ::ng-deep .mat-mdc-form-field-infix{width:100%!important}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: InputComponent, selector: "form-input", inputs: ["formGroup", "input", "config"] }, { kind: "directive", type: FormErrorDirective, selector: "form.ngx-form" }] });
929
+ }
930
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxFormComponent, decorators: [{
931
+ type: Component,
932
+ args: [{ selector: 'ngx-form', imports: [NgClass, ReactiveFormsModule, MatButton, InputComponent, FormErrorDirective], template: "<form [formGroup]=\"formGroup\" (ngSubmit)=\"checkSubmit()\" dir=\"rtl\" class=\"ngx-form\" #formObject=\"ngForm\">\n <div class=\"sections\">\n @for (section of sections; track $index) {\n <!-- CHECK SECTION VIEW -->\n @if (showSection(section)) {\n <!-- SECTION HEADER -->\n @if (section.header) {\n <div [ngClass]=\"[headerClass, 'section-header']\">{{ section.header }}</div>\n }\n\n <div class=\"section\" [class.section-mobile]=\"isMobile\">\n <!-- SECTIONS -->\n @for (column of section.columns; track $index) {\n <!-- CHECK COLUMN VIEW -->\n @if (showColumn(column)) {\n <div class=\"column\" [style.flex]=\"section.flex[$index]\">\n <!-- COLUMN HEADER -->\n @if (column.header) {\n <div [ngClass]=\"[headerClass, 'column-header']\">{{ column.header }}</div>\n }\n\n <!-- ROWS -->\n @for (row of column.rows; track $index) {\n <!-- CHECK Row VIEW -->\n @if (showRow(row)) {\n <!-- ROW HEADER -->\n @if (row.header) {\n <div [ngClass]=\"[headerClass, 'row-header']\">{{ row.header }}</div>\n }\n\n <div class=\"inputs\">\n <!-- INPUTS -->\n @for (input of row.inputs; track $index) {\n <!-- CHECK Row VIEW -->\n @if (showInput(input)) {\n <div class=\"input\" [style.flex]=\"row.flex[$index]\">\n <form-input [formGroup]=\"formGroup\" [input]=\"input\" [config]=\"inputConfig\"></form-input>\n </div>\n } }\n </div>\n } }\n </div>\n } }\n </div>\n } }\n </div>\n\n <div class=\"buttons\" [class.buttons-mobile]=\"isMobile\">\n <!-- EXTRA BUTTONS -->\n @for (item of (ngxForm.buttons || []); track $index) {\n <button type=\"button\" mat-stroked-button (click)=\"onClick(item.action)\">{{ item.title }}</button>\n }\n <!-- SUBMIT BUTTON -->\n <button type=\"submit\" mat-flat-button>{{ ngxForm.submit }}</button>\n </div>\n</form>\n", styles: [".sections{display:flex;flex-direction:column}.sections .column-header,.sections .section-header{margin-bottom:1rem}.sections .row-header{margin:1rem 0}.sections .section,.sections .section .column .inputs{display:flex;align-items:flex-start;column-gap:1rem}.sections .section-mobile{display:block}.buttons{display:flex;align-items:center;justify-content:flex-end;column-gap:1rem;margin-top:1rem}.buttons-mobile button[type=submit]{flex:1}:host ::ng-deep mat-form-field{width:100%;margin-bottom:.5rem}:host ::ng-deep .mat-mdc-form-field-infix{width:100%!important}\n"] }]
933
+ }], ctorParameters: () => [{ type: i1$2.Router }, { type: undefined, decorators: [{
934
+ type: Optional
935
+ }, {
936
+ type: Inject,
937
+ args: [NGX_FORM_CONFIG]
938
+ }] }], propDecorators: { ngForm: [{
939
+ type: ViewChild,
940
+ args: ['formObject']
941
+ }], onResize: [{
942
+ type: HostListener,
943
+ args: ['window:resize', ['$event']]
944
+ }], ngxForm: [{
945
+ type: Input,
946
+ args: [{ required: true }]
947
+ }], onInit: [{
948
+ type: Output
949
+ }], onSubmit: [{
950
+ type: Output
951
+ }], onChange: [{
952
+ type: Output
953
+ }] } });
954
+
955
+ /*
956
+ * Public API Surface of ngx-form-m3
957
+ */
958
+
959
+ /**
960
+ * Generated bundle index. Do not edit.
961
+ */
962
+
963
+ export { NGX_FORM_CONFIG, NgxFormComponent, provideNgxFormConfig };
964
+ //# sourceMappingURL=webilix-ngx-form-m3.mjs.map