UNPKG

igniteui-webcomponents

Version:

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.

159 lines 5.67 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { live } from 'lit/directives/live.js'; import { watch } from '../common/decorators/watch.js'; import { registerComponent } from '../common/definitions/register.js'; import { partNameMap } from '../common/util.js'; import { IgcInputBaseComponent } from './input-base.js'; import { numberValidators, stringValidators } from './validators.js'; class IgcInputComponent extends IgcInputBaseComponent { constructor() { super(...arguments); this._value = ''; this.type = 'text'; this.validateOnly = false; this.tabIndex = 0; } static register() { registerComponent(IgcInputComponent); } get isStringType() { return this.type !== 'number'; } get __validators() { return this.isStringType ? stringValidators : numberValidators; } set value(value) { this._value = value ?? ''; this.setFormValue(value ? value : null); this.updateValidity(); this.setInvalidState(); } get value() { return this._value; } constraintsChanged() { this.updateValidity(); } connectedCallback() { super.connectedCallback(); this.setFormValue(this._value ? this._value : null); this.updateValidity(); } setRangeText(replacement, start, end, selectMode = 'preserve') { super.setRangeText(replacement, start, end, selectMode); this.value = this.input.value; } select() { return this.input.select(); } stepUp(n) { this.input.stepUp(n); this.value = this.input.value; } stepDown(n) { this.input.stepDown(n); this.value = this.input.value; } handleInput() { this.value = this.input.value; this.emitEvent('igcInput', { detail: this.value }); } handleChange() { this.value = this.input.value; this.emitEvent('igcChange', { detail: this.value }); } handleFocus() { this._dirty = true; } handleBlur() { this.checkValidity(); } renderInput() { return html ` <input id=${this.inputId} part=${partNameMap(this.resolvePartNames('input'))} name=${ifDefined(this.name)} type=${ifDefined(this.type)} pattern=${ifDefined(this.pattern)} placeholder=${ifDefined(this.placeholder)} .value=${live(this.value)} ?readonly=${this.readOnly} ?disabled=${this.disabled} ?required=${this.required} ?autofocus=${this.autofocus} tabindex=${this.tabIndex} autocomplete=${ifDefined(this.autocomplete)} inputmode=${ifDefined(this.inputMode)} min=${ifDefined(this.validateOnly ? undefined : this.min)} max=${ifDefined(this.validateOnly ? undefined : this.max)} minlength=${ifDefined(this.minLength)} maxlength=${ifDefined(this.validateOnly ? undefined : this.maxLength)} step=${ifDefined(this.step)} aria-invalid=${this.invalid ? 'true' : 'false'} @change=${this.handleChange} @input=${this.handleInput} @focus=${this.handleFocus} @blur=${this.handleBlur} /> `; } } IgcInputComponent.tagName = 'igc-input'; export default IgcInputComponent; __decorate([ property() ], IgcInputComponent.prototype, "value", null); __decorate([ property({ reflect: true }) ], IgcInputComponent.prototype, "type", void 0); __decorate([ property({ attribute: 'inputmode' }) ], IgcInputComponent.prototype, "inputMode", void 0); __decorate([ property() ], IgcInputComponent.prototype, "pattern", void 0); __decorate([ property({ type: Number, attribute: 'minlength' }) ], IgcInputComponent.prototype, "minLength", void 0); __decorate([ property({ type: Number, attribute: 'maxlength' }) ], IgcInputComponent.prototype, "maxLength", void 0); __decorate([ property() ], IgcInputComponent.prototype, "min", void 0); __decorate([ property() ], IgcInputComponent.prototype, "max", void 0); __decorate([ property({ type: Number }) ], IgcInputComponent.prototype, "step", void 0); __decorate([ property({ type: Boolean }) ], IgcInputComponent.prototype, "autofocus", void 0); __decorate([ property() ], IgcInputComponent.prototype, "autocomplete", void 0); __decorate([ property({ type: Boolean, reflect: true, attribute: 'validate-only' }) ], IgcInputComponent.prototype, "validateOnly", void 0); __decorate([ property({ type: Number }) ], IgcInputComponent.prototype, "tabIndex", void 0); __decorate([ watch('min', { waitUntilFirstUpdate: true }), watch('max', { waitUntilFirstUpdate: true }), watch('minLength', { waitUntilFirstUpdate: true }), watch('maxLength', { waitUntilFirstUpdate: true }), watch('pattern', { waitUntilFirstUpdate: true }), watch('step', { waitUntilFirstUpdate: true }) ], IgcInputComponent.prototype, "constraintsChanged", null); //# sourceMappingURL=input.js.map