"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); /*! * devextreme-angular * Version: 19.1.16 * Build date: Tue Oct 18 2022 * * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-angular */ Object.defineProperty(exports, "__esModule", { value: true }); var platform_browser_1 = require("@angular/platform-browser"); var platform_browser_2 = require("@angular/platform-browser"); var core_1 = require("@angular/core"); var text_box_1 = require("devextreme/ui/text_box"); var forms_1 = require("@angular/forms"); var component_1 = require("../core/component"); var template_host_1 = require("../core/template-host"); var integration_1 = require("../core/integration"); var template_1 = require("../core/template"); var nested_option_1 = require("../core/nested-option"); var watcher_helper_1 = require("../core/watcher-helper"); var iterable_differ_helper_1 = require("../core/iterable-differ-helper"); var button_dxi_1 = require("./nested/button-dxi"); var options_1 = require("./nested/options"); var button_dxi_2 = require("./nested/button-dxi"); var CUSTOM_VALUE_ACCESSOR_PROVIDER = { provide: forms_1.NG_VALUE_ACCESSOR, useExisting: core_1.forwardRef(function () { return DxTextBoxComponent; }), multi: true }; /** * The TextBox is a widget that enables a user to enter and edit a single line of text. */ var DxTextBoxComponent = (function (_super) { __extends(DxTextBoxComponent, _super); function DxTextBoxComponent(elementRef, ngZone, templateHost, _watcherHelper, _idh, optionHost, transferState, platformId) { var _this = _super.call(this, elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId) || this; _this._watcherHelper = _watcherHelper; _this._idh = _idh; _this.touched = function (_) { }; _this._createEventEmitters([ { subscribe: 'change', emit: 'onChange' }, { subscribe: 'contentReady', emit: 'onContentReady' }, { subscribe: 'copy', emit: 'onCopy' }, { subscribe: 'cut', emit: 'onCut' }, { subscribe: 'disposing', emit: 'onDisposing' }, { subscribe: 'enterKey', emit: 'onEnterKey' }, { subscribe: 'focusIn', emit: 'onFocusIn' }, { subscribe: 'focusOut', emit: 'onFocusOut' }, { subscribe: 'initialized', emit: 'onInitialized' }, { subscribe: 'input', emit: 'onInput' }, { subscribe: 'keyDown', emit: 'onKeyDown' }, { subscribe: 'keyPress', emit: 'onKeyPress' }, { subscribe: 'keyUp', emit: 'onKeyUp' }, { subscribe: 'optionChanged', emit: 'onOptionChanged' }, { subscribe: 'paste', emit: 'onPaste' }, { subscribe: 'valueChanged', emit: 'onValueChanged' }, { emit: 'accessKeyChange' }, { emit: 'activeStateEnabledChange' }, { emit: 'buttonsChange' }, { emit: 'disabledChange' }, { emit: 'elementAttrChange' }, { emit: 'focusStateEnabledChange' }, { emit: 'heightChange' }, { emit: 'hintChange' }, { emit: 'hoverStateEnabledChange' }, { emit: 'inputAttrChange' }, { emit: 'isValidChange' }, { emit: 'maskChange' }, { emit: 'maskCharChange' }, { emit: 'maskInvalidMessageChange' }, { emit: 'maskRulesChange' }, { emit: 'maxLengthChange' }, { emit: 'modeChange' }, { emit: 'nameChange' }, { emit: 'placeholderChange' }, { emit: 'readOnlyChange' }, { emit: 'rtlEnabledChange' }, { emit: 'showClearButtonChange' }, { emit: 'showMaskModeChange' }, { emit: 'spellcheckChange' }, { emit: 'stylingModeChange' }, { emit: 'tabIndexChange' }, { emit: 'textChange' }, { emit: 'useMaskedValueChange' }, { emit: 'validationErrorChange' }, { emit: 'validationMessageModeChange' }, { emit: 'valueChange' }, { emit: 'valueChangeEventChange' }, { emit: 'visibleChange' }, { emit: 'widthChange' }, { emit: 'onBlur' } ]); _this._idh.setHost(_this); optionHost.setHost(_this); return _this; } Object.defineProperty(DxTextBoxComponent.prototype, "accessKey", { get: /** * Specifies the shortcut key that sets focus on the widget. */ function () { return this._getOption('accessKey'); }, set: function (value) { this._setOption('accessKey', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "activeStateEnabled", { get: /** * Specifies whether or not the widget changes its state when interacting with a user. */ function () { return this._getOption('activeStateEnabled'); }, set: function (value) { this._setOption('activeStateEnabled', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "buttons", { get: /** * Allows you to add custom buttons to the input text field. */ function () { return this._getOption('buttons'); }, set: function (value) { this._setOption('buttons', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "disabled", { get: /** * Specifies whether the widget responds to user interaction. */ function () { return this._getOption('disabled'); }, set: function (value) { this._setOption('disabled', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "elementAttr", { get: /** * Specifies the attributes to be attached to the widget's root element. */ function () { return this._getOption('elementAttr'); }, set: function (value) { this._setOption('elementAttr', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "focusStateEnabled", { get: /** * Specifies whether the widget can be focused using keyboard navigation. */ function () { return this._getOption('focusStateEnabled'); }, set: function (value) { this._setOption('focusStateEnabled', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "height", { get: /** * Specifies the widget's height. */ function () { return this._getOption('height'); }, set: function (value) { this._setOption('height', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "hint", { get: /** * Specifies text for a hint that appears when a user pauses on the widget. */ function () { return this._getOption('hint'); }, set: function (value) { this._setOption('hint', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "hoverStateEnabled", { get: /** * Specifies whether the widget changes its state when a user pauses on it. */ function () { return this._getOption('hoverStateEnabled'); }, set: function (value) { this._setOption('hoverStateEnabled', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "inputAttr", { get: /** * Specifies the attributes to be passed on to the underlying HTML element. */ function () { return this._getOption('inputAttr'); }, set: function (value) { this._setOption('inputAttr', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "isValid", { get: /** * Specifies whether the editor's value is valid. */ function () { return this._getOption('isValid'); }, set: function (value) { this._setOption('isValid', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "mask", { get: /** * The editor mask that specifies the custom format of the entered string. */ function () { return this._getOption('mask'); }, set: function (value) { this._setOption('mask', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "maskChar", { get: /** * Specifies a mask placeholder character. */ function () { return this._getOption('maskChar'); }, set: function (value) { this._setOption('maskChar', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "maskInvalidMessage", { get: /** * A message displayed when the entered text does not match the specified pattern. */ function () { return this._getOption('maskInvalidMessage'); }, set: function (value) { this._setOption('maskInvalidMessage', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "maskRules", { get: /** * Specifies custom mask rules. */ function () { return this._getOption('maskRules'); }, set: function (value) { this._setOption('maskRules', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "maxLength", { get: /** * Specifies the maximum number of characters you can enter into the textbox. */ function () { return this._getOption('maxLength'); }, set: function (value) { this._setOption('maxLength', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "mode", { get: /** * The "mode" attribute value of the actual HTML input element representing the text box. */ function () { return this._getOption('mode'); }, set: function (value) { this._setOption('mode', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "name", { get: /** * The value to be assigned to the `name` attribute of the underlying HTML element. */ function () { return this._getOption('name'); }, set: function (value) { this._setOption('name', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "placeholder", { get: /** * The text displayed by the widget when the widget value is empty. */ function () { return this._getOption('placeholder'); }, set: function (value) { this._setOption('placeholder', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "readOnly", { get: /** * Specifies whether the editor is read-only. */ function () { return this._getOption('readOnly'); }, set: function (value) { this._setOption('readOnly', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "rtlEnabled", { get: /** * Switches the widget to a right-to-left representation. */ function () { return this._getOption('rtlEnabled'); }, set: function (value) { this._setOption('rtlEnabled', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "showClearButton", { get: /** * Specifies whether to display the Clear button in the widget. */ function () { return this._getOption('showClearButton'); }, set: function (value) { this._setOption('showClearButton', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "showMaskMode", { get: /** * Specifies when the widget shows the mask. Applies only if useMaskedValue is true. */ function () { return this._getOption('showMaskMode'); }, set: function (value) { this._setOption('showMaskMode', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "spellcheck", { get: /** * Specifies whether or not the widget checks the inner text for spelling mistakes. */ function () { return this._getOption('spellcheck'); }, set: function (value) { this._setOption('spellcheck', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "stylingMode", { get: /** * Specifies how the widget's text field is styled. */ function () { return this._getOption('stylingMode'); }, set: function (value) { this._setOption('stylingMode', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "tabIndex", { get: /** * Specifies the number of the element when the Tab key is used for navigating. */ function () { return this._getOption('tabIndex'); }, set: function (value) { this._setOption('tabIndex', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "text", { get: /** * The read-only option that holds the text displayed by the widget input element. */ function () { return this._getOption('text'); }, set: function (value) { this._setOption('text', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "useMaskedValue", { get: /** * Specifies whether the value should contain mask characters or not. */ function () { return this._getOption('useMaskedValue'); }, set: function (value) { this._setOption('useMaskedValue', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "validationError", { get: /** * Specifies information on the validation error when using a custom validation engine. Should be changed at runtime along with the isValid option. */ function () { return this._getOption('validationError'); }, set: function (value) { this._setOption('validationError', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "validationMessageMode", { get: /** * Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed. */ function () { return this._getOption('validationMessageMode'); }, set: function (value) { this._setOption('validationMessageMode', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "value", { get: /** * Specifies a value the widget displays. */ function () { return this._getOption('value'); }, set: function (value) { this._setOption('value', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "valueChangeEvent", { get: /** * Specifies the DOM events after which the widget's value should be updated. */ function () { return this._getOption('valueChangeEvent'); }, set: function (value) { this._setOption('valueChangeEvent', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "visible", { get: /** * Specifies whether the widget is visible. */ function () { return this._getOption('visible'); }, set: function (value) { this._setOption('visible', value); }, enumerable: true, configurable: true }); Object.defineProperty(DxTextBoxComponent.prototype, "width", { get: /** * Specifies the widget's width. */ function () { return this._getOption('width'); }, set: function (value) { this._setOption('width', value); }, enumerable: true, configurable: true }); DxTextBoxComponent.prototype.change = function (_) { }; Object.defineProperty(DxTextBoxComponent.prototype, "buttonsChildren", { get: function () { return this._getOption('buttons'); }, set: function (value) { this.setChildren('buttons', value); }, enumerable: true, configurable: true }); DxTextBoxComponent.prototype._createInstance = function (element, options) { return new text_box_1.default(element, options); }; DxTextBoxComponent.prototype.writeValue = function (value) { this.eventHelper.lockedValueChangeEvent = true; this.value = value; this.eventHelper.lockedValueChangeEvent = false; }; DxTextBoxComponent.prototype.setDisabledState = function (isDisabled) { this.disabled = isDisabled; }; DxTextBoxComponent.prototype.registerOnChange = function (fn) { this.change = fn; }; DxTextBoxComponent.prototype.registerOnTouched = function (fn) { this.touched = fn; }; DxTextBoxComponent.prototype._createWidget = function (element) { var _this = this; _super.prototype._createWidget.call(this, element); this.instance.on('focusOut', function (e) { _this.eventHelper.fireNgEvent('onBlur', [e]); }); }; DxTextBoxComponent.prototype.ngOnDestroy = function () { this._destroyWidget(); }; DxTextBoxComponent.prototype.ngOnChanges = function (changes) { _super.prototype.ngOnChanges.call(this, changes); this.setupChanges('buttons', changes); }; DxTextBoxComponent.prototype.setupChanges = function (prop, changes) { if (!(prop in this._optionsToUpdate)) { this._idh.setup(prop, changes); } }; DxTextBoxComponent.prototype.ngDoCheck = function () { this._idh.doCheck('buttons'); this._watcherHelper.checkWatchers(); _super.prototype.ngDoCheck.call(this); _super.prototype.clearChangedOptions.call(this); }; DxTextBoxComponent.prototype._setOption = function (name, value) { var isSetup = this._idh.setupSingle(name, value); var isChanged = this._idh.getChanges(name, value) !== null; if (isSetup || isChanged) { _super.prototype._setOption.call(this, name, value); } }; DxTextBoxComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'dx-text-box', template: '', providers: [ template_host_1.DxTemplateHost, watcher_helper_1.WatcherHelper, CUSTOM_VALUE_ACCESSOR_PROVIDER, nested_option_1.NestedOptionHost, iterable_differ_helper_1.IterableDifferHelper ] },] }, ]; /** @nocollapse */ DxTextBoxComponent.ctorParameters = function () { return [ { type: core_1.ElementRef, }, { type: core_1.NgZone, }, { type: template_host_1.DxTemplateHost, }, { type: watcher_helper_1.WatcherHelper, }, { type: iterable_differ_helper_1.IterableDifferHelper, }, { type: nested_option_1.NestedOptionHost, }, { type: platform_browser_2.TransferState, }, { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] }, ]; }; DxTextBoxComponent.propDecorators = { "accessKey": [{ type: core_1.Input },], "activeStateEnabled": [{ type: core_1.Input },], "buttons": [{ type: core_1.Input },], "disabled": [{ type: core_1.Input },], "elementAttr": [{ type: core_1.Input },], "focusStateEnabled": [{ type: core_1.Input },], "height": [{ type: core_1.Input },], "hint": [{ type: core_1.Input },], "hoverStateEnabled": [{ type: core_1.Input },], "inputAttr": [{ type: core_1.Input },], "isValid": [{ type: core_1.Input },], "mask": [{ type: core_1.Input },], "maskChar": [{ type: core_1.Input },], "maskInvalidMessage": [{ type: core_1.Input },], "maskRules": [{ type: core_1.Input },], "maxLength": [{ type: core_1.Input },], "mode": [{ type: core_1.Input },], "name": [{ type: core_1.Input },], "placeholder": [{ type: core_1.Input },], "readOnly": [{ type: core_1.Input },], "rtlEnabled": [{ type: core_1.Input },], "showClearButton": [{ type: core_1.Input },], "showMaskMode": [{ type: core_1.Input },], "spellcheck": [{ type: core_1.Input },], "stylingMode": [{ type: core_1.Input },], "tabIndex": [{ type: core_1.Input },], "text": [{ type: core_1.Input },], "useMaskedValue": [{ type: core_1.Input },], "validationError": [{ type: core_1.Input },], "validationMessageMode": [{ type: core_1.Input },], "value": [{ type: core_1.Input },], "valueChangeEvent": [{ type: core_1.Input },], "visible": [{ type: core_1.Input },], "width": [{ type: core_1.Input },], "onChange": [{ type: core_1.Output },], "onContentReady": [{ type: core_1.Output },], "onCopy": [{ type: core_1.Output },], "onCut": [{ type: core_1.Output },], "onDisposing": [{ type: core_1.Output },], "onEnterKey": [{ type: core_1.Output },], "onFocusIn": [{ type: core_1.Output },], "onFocusOut": [{ type: core_1.Output },], "onInitialized": [{ type: core_1.Output },], "onInput": [{ type: core_1.Output },], "onKeyDown": [{ type: core_1.Output },], "onKeyPress": [{ type: core_1.Output },], "onKeyUp": [{ type: core_1.Output },], "onOptionChanged": [{ type: core_1.Output },], "onPaste": [{ type: core_1.Output },], "onValueChanged": [{ type: core_1.Output },], "accessKeyChange": [{ type: core_1.Output },], "activeStateEnabledChange": [{ type: core_1.Output },], "buttonsChange": [{ type: core_1.Output },], "disabledChange": [{ type: core_1.Output },], "elementAttrChange": [{ type: core_1.Output },], "focusStateEnabledChange": [{ type: core_1.Output },], "heightChange": [{ type: core_1.Output },], "hintChange": [{ type: core_1.Output },], "hoverStateEnabledChange": [{ type: core_1.Output },], "inputAttrChange": [{ type: core_1.Output },], "isValidChange": [{ type: core_1.Output },], "maskChange": [{ type: core_1.Output },], "maskCharChange": [{ type: core_1.Output },], "maskInvalidMessageChange": [{ type: core_1.Output },], "maskRulesChange": [{ type: core_1.Output },], "maxLengthChange": [{ type: core_1.Output },], "modeChange": [{ type: core_1.Output },], "nameChange": [{ type: core_1.Output },], "placeholderChange": [{ type: core_1.Output },], "readOnlyChange": [{ type: core_1.Output },], "rtlEnabledChange": [{ type: core_1.Output },], "showClearButtonChange": [{ type: core_1.Output },], "showMaskModeChange": [{ type: core_1.Output },], "spellcheckChange": [{ type: core_1.Output },], "stylingModeChange": [{ type: core_1.Output },], "tabIndexChange": [{ type: core_1.Output },], "textChange": [{ type: core_1.Output },], "useMaskedValueChange": [{ type: core_1.Output },], "validationErrorChange": [{ type: core_1.Output },], "validationMessageModeChange": [{ type: core_1.Output },], "valueChange": [{ type: core_1.Output },], "valueChangeEventChange": [{ type: core_1.Output },], "visibleChange": [{ type: core_1.Output },], "widthChange": [{ type: core_1.Output },], "onBlur": [{ type: core_1.Output },], "change": [{ type: core_1.HostListener, args: ['valueChange', ['$event'],] },], "touched": [{ type: core_1.HostListener, args: ['onBlur', ['$event'],] },], "buttonsChildren": [{ type: core_1.ContentChildren, args: [button_dxi_2.DxiButtonComponent,] },], }; return DxTextBoxComponent; }(component_1.DxComponent)); exports.DxTextBoxComponent = DxTextBoxComponent; var DxTextBoxModule = (function () { function DxTextBoxModule() { } DxTextBoxModule.decorators = [ { type: core_1.NgModule, args: [{ imports: [ button_dxi_1.DxiButtonModule, options_1.DxoOptionsModule, integration_1.DxIntegrationModule, template_1.DxTemplateModule, platform_browser_1.BrowserTransferStateModule ], declarations: [ DxTextBoxComponent ], exports: [ DxTextBoxComponent, button_dxi_1.DxiButtonModule, options_1.DxoOptionsModule, template_1.DxTemplateModule ] },] }, ]; return DxTextBoxModule; }()); exports.DxTextBoxModule = DxTextBoxModule; //# sourceMappingURL=text-box.js.map