UNPKG

@ionic/angular

Version:

Angular specific wrappers for @ionic/core

112 lines 4.92 kB
import { __decorate } from "tslib"; import { ChangeDetectionStrategy, Component, HostListener, forwardRef, } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { ValueAccessor } from '@ionic/angular/common'; import { defineCustomElement } from '@ionic/core/components/ion-input.js'; import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils'; import * as i0 from "@angular/core"; const INPUT_INPUTS = [ 'accept', 'autocapitalize', 'autocomplete', 'autocorrect', 'autofocus', 'clearInput', 'clearOnEdit', 'color', 'counter', 'counterFormatter', 'debounce', 'disabled', 'enterkeyhint', 'errorText', 'fill', 'helperText', 'inputmode', 'label', 'labelPlacement', 'max', 'maxlength', 'min', 'minlength', 'mode', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'shape', 'size', 'spellcheck', 'step', 'type', 'value', ]; let IonInput = class IonInput extends ValueAccessor { z; el; constructor(c, r, z, injector) { super(injector, r); this.z = z; c.detach(); this.el = r.nativeElement; proxyOutputs(this, this.el, ['ionInput', 'ionChange', 'ionBlur', 'ionFocus']); } handleIonInput(el) { this.handleValueChange(el, el.value); } registerOnChange(fn) { super.registerOnChange((value) => { if (this.type === 'number') { /** * If the input type is `number`, we need to convert the value to a number * when the value is not empty. If the value is empty, we want to treat * the value as null. */ fn(value === '' ? null : parseFloat(value)); } else { fn(value); } }); } /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: IonInput, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: IonInput, isStandalone: true, selector: "ion-input", inputs: { accept: "accept", autocapitalize: "autocapitalize", autocomplete: "autocomplete", autocorrect: "autocorrect", autofocus: "autofocus", clearInput: "clearInput", clearOnEdit: "clearOnEdit", color: "color", counter: "counter", counterFormatter: "counterFormatter", debounce: "debounce", disabled: "disabled", enterkeyhint: "enterkeyhint", errorText: "errorText", fill: "fill", helperText: "helperText", inputmode: "inputmode", label: "label", labelPlacement: "labelPlacement", max: "max", maxlength: "maxlength", min: "min", minlength: "minlength", mode: "mode", multiple: "multiple", name: "name", pattern: "pattern", placeholder: "placeholder", readonly: "readonly", required: "required", shape: "shape", size: "size", spellcheck: "spellcheck", step: "step", type: "type", value: "value" }, host: { listeners: { "ionInput": "handleIonInput($event.target)" } }, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((() => IonInput)), multi: true, }, ], usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }; IonInput = __decorate([ ProxyCmp({ defineCustomElementFn: defineCustomElement, inputs: INPUT_INPUTS, methods: ['setFocus', 'getInputElement'], }) ], IonInput); export { IonInput }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: IonInput, decorators: [{ type: Component, args: [{ selector: 'ion-input', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property inputs: INPUT_INPUTS, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((() => IonInput)), multi: true, }, ], standalone: true, }] }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.Injector }], propDecorators: { handleIonInput: [{ type: HostListener, args: ['ionInput', ['$event.target']] }] } }); //# sourceMappingURL=input.js.map