@webilix/ngx-form-m3 0.0.24 → 0.0.25

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.
@@ -1288,6 +1288,75 @@ class InputPasswordMethods extends InputMethods {
1288
1288
  }
1289
1289
  }
1290
1290
 
1291
+ class InputPriceComponent {
1292
+ formControl = inject(INPUT_CONTROL);
1293
+ input = inject(INPUT_TYPE);
1294
+ config = inject(INPUT_CONFIG);
1295
+ values;
1296
+ isButtonDisabled;
1297
+ maxLength = 15;
1298
+ hintText;
1299
+ isFocused = false;
1300
+ inputTransformFn = (value) => Helper.STRING.changeNumbers(value.toString(), 'EN');
1301
+ ngOnInit() {
1302
+ if (!this.input.fractionDigits && this.input.maximum)
1303
+ this.maxLength = Helper.NUMBER.format(this.input.maximum, 'EN').length;
1304
+ this.updateHint();
1305
+ }
1306
+ setValue(input) {
1307
+ const value = input.length === 0 ? null : +input.replace(/,/gi, '');
1308
+ this.formControl.setValue(Helper.IS.number(value) ? value : null);
1309
+ this.formControl.markAllAsTouched();
1310
+ }
1311
+ updateHint() {
1312
+ const value = this.formControl.value;
1313
+ this.hintText =
1314
+ this.input.hideText || !Helper.IS.number(value)
1315
+ ? undefined
1316
+ : Helper.NUMBER.getTitle(Math.abs(value)) + (this.input.currency ? ` ${this.input.currency}` : '');
1317
+ }
1318
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: InputPriceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1319
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.4", type: InputPriceComponent, isStandalone: true, selector: "ng-component", inputs: { values: "values", isButtonDisabled: "isButtonDisabled" }, host: { attributes: { "selector": "input-price" } }, providers: [provideNgxMask()], ngImport: i0, template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0642\u06CC\u0645\u062A' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (input.hint|| (isFocused && hintText)) { <mat-hint>{{ isFocused && hintText ? hintText : input.hint }}</mat-hint> }\n\n <!-- CURRENCY -->\n @if (input.currency) {\n <span matTextSuffix class=\"ngx-form-m3-input-suffix\" [class.ngx-form-m3-disabled-input]=\"formControl.disabled\">\n <span>{{ input.currency }}</span>\n </span>\n }\n\n <!-- BUTTON -->\n @if (input.button) {\n <span matIconSuffix>\n <button\n mat-icon-button\n type=\"button\"\n [disabled]=\"isButtonDisabled\"\n (click)=\"input.button.onClick(values)\"\n [tabIndex]=\"-1\"\n >\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 <input\n matInput\n type=\"text\"\n inputmode=\"numeric\"\n class=\"ngx-form-m3-en\"\n [ngModel]=\"formControl.value?.toString() || ''\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n [mask]=\"\n input.fractionDigits === true\n ? 'separator.3'\n : !!input.fractionDigits && input.fractionDigits > 0\n ? 'separator.' + input.fractionDigits.toString()\n : 'separator.0'\n \"\n thousandSeparator=\",\"\n decimalMarker=\".\"\n [allowNegativeNumbers]=\"false\"\n [inputTransformFn]=\"inputTransformFn\"\n [maxlength]=\"maxLength\"\n (input)=\"setValue(numberInput.value); updateHint()\"\n [disabled]=\"formControl.disabled\"\n (focus)=\"isFocused = true; updateHint()\"\n (blur)=\"isFocused = false\"\n #numberInput\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: [".ngx-form-m3-input-suffix{padding-right:.5rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { 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.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { 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$1.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: i2$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i2$1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i2$1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i2$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { 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", "instantPrefix"], 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" }] });
1320
+ }
1321
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: InputPriceComponent, decorators: [{
1322
+ type: Component,
1323
+ args: [{ host: { selector: 'input-price' }, imports: [
1324
+ FormsModule,
1325
+ ReactiveFormsModule,
1326
+ MatFormField,
1327
+ MatIcon,
1328
+ MatIconButton,
1329
+ MatInputModule,
1330
+ NgxMaskDirective,
1331
+ AutoCompleteDirective,
1332
+ AutoFocusDirective,
1333
+ InputErrorPipe,
1334
+ MultiLinePipe,
1335
+ ], providers: [provideNgxMask()], template: "<mat-form-field [appearance]=\"input.appearance || config.appearance\">\n <mat-label>{{ input.title || '\u0642\u06CC\u0645\u062A' }}</mat-label>\n @if (formControl.invalid) { <mat-error>{{ formControl.errors | InputErrorPipe : input.type }}</mat-error> }\n\n <!-- HINT -->\n @if (input.hint|| (isFocused && hintText)) { <mat-hint>{{ isFocused && hintText ? hintText : input.hint }}</mat-hint> }\n\n <!-- CURRENCY -->\n @if (input.currency) {\n <span matTextSuffix class=\"ngx-form-m3-input-suffix\" [class.ngx-form-m3-disabled-input]=\"formControl.disabled\">\n <span>{{ input.currency }}</span>\n </span>\n }\n\n <!-- BUTTON -->\n @if (input.button) {\n <span matIconSuffix>\n <button\n mat-icon-button\n type=\"button\"\n [disabled]=\"isButtonDisabled\"\n (click)=\"input.button.onClick(values)\"\n [tabIndex]=\"-1\"\n >\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 <input\n matInput\n type=\"text\"\n inputmode=\"numeric\"\n class=\"ngx-form-m3-en\"\n [ngModel]=\"formControl.value?.toString() || ''\"\n [AutoFocusDirective]=\"config.autoFocus === input.name\"\n [mask]=\"\n input.fractionDigits === true\n ? 'separator.3'\n : !!input.fractionDigits && input.fractionDigits > 0\n ? 'separator.' + input.fractionDigits.toString()\n : 'separator.0'\n \"\n thousandSeparator=\",\"\n decimalMarker=\".\"\n [allowNegativeNumbers]=\"false\"\n [inputTransformFn]=\"inputTransformFn\"\n [maxlength]=\"maxLength\"\n (input)=\"setValue(numberInput.value); updateHint()\"\n [disabled]=\"formControl.disabled\"\n (focus)=\"isFocused = true; updateHint()\"\n (blur)=\"isFocused = false\"\n #numberInput\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: [".ngx-form-m3-input-suffix{padding-right:.5rem}\n"] }]
1336
+ }], propDecorators: { values: [{
1337
+ type: Input,
1338
+ args: [{ required: true }]
1339
+ }], isButtonDisabled: [{
1340
+ type: Input,
1341
+ args: [{ required: true }]
1342
+ }] } });
1343
+
1344
+ class InputPriceMethods extends InputMethods {
1345
+ control(input, validators) {
1346
+ if (input.minimum)
1347
+ validators.push(MinNumberValidator(input.minimum));
1348
+ if (input.maximum)
1349
+ validators.push(MaxNumberValidator(input.maximum));
1350
+ if (input.multiplyOf)
1351
+ validators.push(MultiplyOfNumberValidator(input.multiplyOf));
1352
+ const value = input.value !== undefined && Helper.IS.number(input.value) ? input.value : null;
1353
+ return new FormControl(value, validators);
1354
+ }
1355
+ value(value, input) {
1356
+ return Helper.IS.number(value) ? value : null;
1357
+ }
1358
+ }
1359
+
1291
1360
  class InputSelectComponent {
1292
1361
  formControl = inject(INPUT_CONTROL);
1293
1362
  input = inject(INPUT_TYPE);
@@ -1540,6 +1609,7 @@ const InputInfo = {
1540
1609
  NAME: { title: 'نام و نام خانوادگی', methods: new InputNameMethods(), component: InputNameComponent },
1541
1610
  NUMBER: { title: 'مقدار عددی', methods: new InputNumberMethods(), component: InputNumberComponent },
1542
1611
  PASSWORD: { title: 'کلمه عبور', methods: new InputPasswordMethods(), component: InputPasswordComponent },
1612
+ PRICE: { title: 'قیمت', methods: new InputPriceMethods(), component: InputPriceComponent },
1543
1613
  SELECT: { title: 'لیست کشویی', methods: new InputSelectMethods(), component: InputSelectComponent },
1544
1614
  TEXT: { title: 'متن یک خطی', methods: new InputTextMethods(), component: InputTextComponent },
1545
1615
  TEXTAREA: { title: 'متن چند خطی', methods: new InputTextareaMethods(), component: InputTextareaComponent },