@webilix/ngx-form-m3 0.0.10 → 0.0.12

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.
@@ -252,6 +252,40 @@ const INPUT_CONTROL = new InjectionToken('NGX-FORM-INPUT-CONTROL');
252
252
  const INPUT_TYPE = new InjectionToken('NGX-FORM-INPUT-TYPE');
253
253
  const INPUT_CONFIG = new InjectionToken('NGX-FORM-INPUT-CONFIG');
254
254
 
255
+ class InputCheckboxComponent {
256
+ formControl = inject(INPUT_CONTROL);
257
+ input = inject(INPUT_TYPE);
258
+ config = inject(INPUT_CONFIG);
259
+ values;
260
+ isButtonDisabled;
261
+ toggleValue() {
262
+ const value = !!this.formControl.value;
263
+ this.formControl.setValue(!value);
264
+ this.formControl.markAsTouched();
265
+ }
266
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: InputCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
267
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: InputCheckboxComponent, isStandalone: true, selector: "ng-component", inputs: { values: "values", isButtonDisabled: "isButtonDisabled" }, host: { attributes: { "selector": "input-checkbox" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\" [floatLabel]=\"formControl.value ? 'always' : 'auto'\">\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- BUTTON -->\n @if (input.button) {\n <span matIconSuffix>\n <button mat-icon-button type=\"button\" [disabled]=\"isButtonDisabled\" (click)=\"input.button.onClick(values)\">\n <mat-icon [style.color]=\"isButtonDisabled ? undefined : input.button.color\">\n {{ input.button.icon }}\n </mat-icon>\n </button>\n </span>\n }\n\n <!-- INPUT -->\n <input matInput type=\"text\" [name]=\"input.name\" [formControl]=\"formControl\" [style.display]=\"'none !important'\" />\n <div\n class=\"ngx-helper-form-m3-checkbox-input\"\n [class.ngx-form-m3-disabled-input]=\"formControl.disabled\"\n (click)=\"toggleValue()\"\n >\n <mat-icon>{{ !!formControl.value ? 'check_box' : 'check_box_outline_blank' }}</mat-icon>\n <div class=\"message\" [class.ngx-form-m3-en]=\"!!input.english\">{{ input.message }}</div>\n </div>\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n class=\"ngx-form-m3-input-description\"\n [class.ngx-form-m3-disabled-input]=\"formControl.disabled\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [":host ::ng-deep .mat-mdc-form-field-infix{display:flex;flex-direction:column;justify-content:center}\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: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { 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.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: "pipe", type: InputErrorPipe, name: "InputErrorPipe" }, { kind: "pipe", type: MultiLinePipe, name: "MultiLinePipe" }] });
268
+ }
269
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: InputCheckboxComponent, decorators: [{
270
+ type: Component,
271
+ args: [{ host: { selector: 'input-checkbox' }, imports: [ReactiveFormsModule, MatFormField, MatIcon, MatIconButton, MatInputModule, InputErrorPipe, MultiLinePipe], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\" [floatLabel]=\"formControl.value ? 'always' : 'auto'\">\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- BUTTON -->\n @if (input.button) {\n <span matIconSuffix>\n <button mat-icon-button type=\"button\" [disabled]=\"isButtonDisabled\" (click)=\"input.button.onClick(values)\">\n <mat-icon [style.color]=\"isButtonDisabled ? undefined : input.button.color\">\n {{ input.button.icon }}\n </mat-icon>\n </button>\n </span>\n }\n\n <!-- INPUT -->\n <input matInput type=\"text\" [name]=\"input.name\" [formControl]=\"formControl\" [style.display]=\"'none !important'\" />\n <div\n class=\"ngx-helper-form-m3-checkbox-input\"\n [class.ngx-form-m3-disabled-input]=\"formControl.disabled\"\n (click)=\"toggleValue()\"\n >\n <mat-icon>{{ !!formControl.value ? 'check_box' : 'check_box_outline_blank' }}</mat-icon>\n <div class=\"message\" [class.ngx-form-m3-en]=\"!!input.english\">{{ input.message }}</div>\n </div>\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n class=\"ngx-form-m3-input-description\"\n [class.ngx-form-m3-disabled-input]=\"formControl.disabled\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [":host ::ng-deep .mat-mdc-form-field-infix{display:flex;flex-direction:column;justify-content:center}\n"] }]
272
+ }], propDecorators: { values: [{
273
+ type: Input,
274
+ args: [{ required: true }]
275
+ }], isButtonDisabled: [{
276
+ type: Input,
277
+ args: [{ required: true }]
278
+ }] } });
279
+
280
+ class InputCheckboxMethods extends InputMethods {
281
+ control(input, validators) {
282
+ return new FormControl(!!input.value, validators);
283
+ }
284
+ value(value, input) {
285
+ return !!value;
286
+ }
287
+ }
288
+
255
289
  class InputColorComponent {
256
290
  formControl = inject(INPUT_CONTROL);
257
291
  input = inject(INPUT_TYPE);
@@ -565,6 +599,47 @@ class InputFileMethods extends InputMethods {
565
599
  }
566
600
  }
567
601
 
602
+ class InputIpComponent {
603
+ formControl = inject(INPUT_CONTROL);
604
+ input = inject(INPUT_TYPE);
605
+ config = inject(INPUT_CONFIG);
606
+ values;
607
+ isButtonDisabled;
608
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: InputIpComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
609
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: InputIpComponent, isStandalone: true, selector: "ng-component", inputs: { values: "values", isButtonDisabled: "isButtonDisabled" }, host: { attributes: { "selector": "input-ip" } }, ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0622\u062F\u0631\u0633 \u0622\u06CC\u200C\u067E\u06CC' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- ICON -->\n @if (input.showIcon) {\n <span matTextSuffix class=\"ngx-form-m3-input-suffix\" [class.ngx-form-m3-disabled-input]=\"formControl.disabled\">\n <span>&nbsp;</span>\n <mat-icon>language</mat-icon>\n </span>\n }\n\n <!-- BUTTON -->\n @if (input.button) {\n <span matIconSuffix>\n <button mat-icon-button type=\"button\" [disabled]=\"isButtonDisabled\" (click)=\"input.button.onClick(values)\">\n <mat-icon [style.color]=\"isButtonDisabled ? undefined : input.button.color\">\n {{ input.button.icon }}\n </mat-icon>\n </button>\n </span>\n }\n\n <input\n matInput\n type=\"text\"\n inputmode=\"url\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n class=\"ngx-form-m3-en\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n class=\"ngx-form-m3-input-description\"\n [class.ngx-form-m3-disabled-input]=\"formControl.disabled\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n", styles: [""], 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: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { 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" }] });
610
+ }
611
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: InputIpComponent, decorators: [{
612
+ type: Component,
613
+ args: [{ host: { selector: 'input-ip' }, imports: [
614
+ ReactiveFormsModule,
615
+ MatFormField,
616
+ MatIcon,
617
+ MatIconButton,
618
+ MatInputModule,
619
+ AutoCompleteDirective,
620
+ AutoFocusDirective,
621
+ InputErrorPipe,
622
+ MultiLinePipe,
623
+ ], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0622\u062F\u0631\u0633 \u0622\u06CC\u200C\u067E\u06CC' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (input.hint) { <mat-hint>{{ input.hint }}</mat-hint> }\n\n <!-- ICON -->\n @if (input.showIcon) {\n <span matTextSuffix class=\"ngx-form-m3-input-suffix\" [class.ngx-form-m3-disabled-input]=\"formControl.disabled\">\n <span>&nbsp;</span>\n <mat-icon>language</mat-icon>\n </span>\n }\n\n <!-- BUTTON -->\n @if (input.button) {\n <span matIconSuffix>\n <button mat-icon-button type=\"button\" [disabled]=\"isButtonDisabled\" (click)=\"input.button.onClick(values)\">\n <mat-icon [style.color]=\"isButtonDisabled ? undefined : input.button.color\">\n {{ input.button.icon }}\n </mat-icon>\n </button>\n </span>\n }\n\n <input\n matInput\n type=\"text\"\n inputmode=\"url\"\n [name]=\"input.name\"\n [formControl]=\"formControl\"\n class=\"ngx-form-m3-en\"\n [dir]=\"'ltr'\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n />\n\n <!-- DESCRIPTION -->\n @if (input.description) {\n <div\n class=\"ngx-form-m3-input-description\"\n [class.ngx-form-m3-disabled-input]=\"formControl.disabled\"\n [innerHTML]=\"input.description | MultiLinePipe\"\n ></div>\n }\n</mat-form-field>\n" }]
624
+ }], propDecorators: { values: [{
625
+ type: Input,
626
+ args: [{ required: true }]
627
+ }], isButtonDisabled: [{
628
+ type: Input,
629
+ args: [{ required: true }]
630
+ }] } });
631
+
632
+ class InputIpMethods extends InputMethods {
633
+ control(input, validators) {
634
+ validators.push(Validators.pattern(Helper.RE.IP4.get(true)));
635
+ const value = input.value && Helper.RE.IP4.verify(input.value) ? input.value : null;
636
+ return new FormControl(value, validators);
637
+ }
638
+ value(value, input) {
639
+ return typeof value === 'string' && Helper.RE.IP4.verify(value) ? value : null;
640
+ }
641
+ }
642
+
568
643
  class InputMobileComponent {
569
644
  formControl = inject(INPUT_CONTROL);
570
645
  input = inject(INPUT_TYPE);
@@ -1071,11 +1146,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
1071
1146
  }] } });
1072
1147
 
1073
1148
  const InputInfo = {
1149
+ CHECKBOX: { title: 'یک انتخابی', methods: new InputCheckboxMethods(), component: InputCheckboxComponent },
1074
1150
  COLOR: { title: 'رنگ', methods: new InputColorMethods(), component: InputColorComponent },
1075
1151
  COMPONENT: { title: 'کامپوننت', methods: new InputComponentMethods(), component: InputComponentComponent },
1076
1152
  DATE: { title: 'تاریخ', methods: new InputDateMethods(), component: InputDateComponent },
1077
1153
  EMAIL: { title: 'ایمیل', methods: new InputEmailMethods(), component: InputEmailComponent },
1078
1154
  FILE: { title: 'فایل', methods: new InputFileMethods(), component: InputFileComponent },
1155
+ IP: { title: 'آدرس آی‌پی', methods: new InputIpMethods(), component: InputIpComponent },
1079
1156
  MOBILE: { title: 'موبایل', methods: new InputMobileMethods(), component: InputMobileComponent },
1080
1157
  MOMENT: { title: 'زمان', methods: new InputMomentMethods(), component: InputMomentComponent },
1081
1158
  NAME: { title: 'نام و نام خانوادگی', methods: new InputNameMethods(), component: InputNameComponent },
@@ -1164,7 +1241,6 @@ class NgxFormComponent {
1164
1241
  this.lastValues = { ...this.formGroup.value };
1165
1242
  }
1166
1243
  this.values = this.getValues();
1167
- console.log(this.values);
1168
1244
  this.onChange.next(this.values);
1169
1245
  },
1170
1246
  });