UNPKG

devextreme-angular

Version:

Angular UI and visualization components based on DevExtreme widgets

804 lines (761 loc) 28.9 kB
import * as i2 from '@angular/platform-browser'; import { BrowserTransferStateModule } from '@angular/platform-browser'; import * as i0 from '@angular/core'; import { forwardRef, PLATFORM_ID, Component, Inject, Input, Output, HostListener, ContentChildren, NgModule } from '@angular/core'; import DxTextBox from 'devextreme/ui/text_box'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import * as i1 from 'devextreme-angular/core'; import { DxComponent, DxTemplateHost, WatcherHelper, NestedOptionHost, IterableDifferHelper, DxIntegrationModule, DxTemplateModule } from 'devextreme-angular/core'; import { DxiButtonComponent, DxiButtonModule, DxoOptionsModule } from 'devextreme-angular/ui/nested'; /*! * devextreme-angular * Version: 22.1.14 * Build date: Mon Apr 29 2024 * * Copyright (c) 2012 - 2024 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 */ const CUSTOM_VALUE_ACCESSOR_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DxTextBoxComponent), multi: true }; /** * The TextBox is a UI component that enables a user to enter and edit a single line of text. */ class DxTextBoxComponent extends DxComponent { constructor(elementRef, ngZone, templateHost, _watcherHelper, _idh, optionHost, transferState, platformId) { super(elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId); this._watcherHelper = _watcherHelper; this._idh = _idh; this.touched = (_) => { }; 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: '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: 'labelChange' }, { emit: 'labelModeChange' }, { 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: 'validationErrorsChange' }, { emit: 'validationMessageModeChange' }, { emit: 'validationStatusChange' }, { emit: 'valueChange' }, { emit: 'valueChangeEventChange' }, { emit: 'visibleChange' }, { emit: 'widthChange' }, { emit: 'onBlur' } ]); this._idh.setHost(this); optionHost.setHost(this); } /** * Specifies the shortcut key that sets focus on the UI component. */ get accessKey() { return this._getOption('accessKey'); } set accessKey(value) { this._setOption('accessKey', value); } /** * Specifies whether the UI component changes its visual state as a result of user interaction. */ get activeStateEnabled() { return this._getOption('activeStateEnabled'); } set activeStateEnabled(value) { this._setOption('activeStateEnabled', value); } /** * Allows you to add custom buttons to the input text field. */ get buttons() { return this._getOption('buttons'); } set buttons(value) { this._setOption('buttons', value); } /** * Specifies whether the UI component responds to user interaction. */ get disabled() { return this._getOption('disabled'); } set disabled(value) { this._setOption('disabled', value); } /** * Specifies the global attributes to be attached to the UI component's container element. */ get elementAttr() { return this._getOption('elementAttr'); } set elementAttr(value) { this._setOption('elementAttr', value); } /** * Specifies whether the UI component can be focused using keyboard navigation. */ get focusStateEnabled() { return this._getOption('focusStateEnabled'); } set focusStateEnabled(value) { this._setOption('focusStateEnabled', value); } /** * Specifies the UI component's height. */ get height() { return this._getOption('height'); } set height(value) { this._setOption('height', value); } /** * Specifies text for a hint that appears when a user pauses on the UI component. */ get hint() { return this._getOption('hint'); } set hint(value) { this._setOption('hint', value); } /** * Specifies whether the UI component changes its state when a user pauses on it. */ get hoverStateEnabled() { return this._getOption('hoverStateEnabled'); } set hoverStateEnabled(value) { this._setOption('hoverStateEnabled', value); } /** * Specifies the attributes to be passed on to the underlying HTML element. */ get inputAttr() { return this._getOption('inputAttr'); } set inputAttr(value) { this._setOption('inputAttr', value); } /** * Specifies or indicates whether the editor's value is valid. */ get isValid() { return this._getOption('isValid'); } set isValid(value) { this._setOption('isValid', value); } /** * Specifies a text string used to annotate the editor's value. */ get label() { return this._getOption('label'); } set label(value) { this._setOption('label', value); } /** * Specifies the label's display mode. */ get labelMode() { return this._getOption('labelMode'); } set labelMode(value) { this._setOption('labelMode', value); } /** * The editor mask that specifies the custom format of the entered string. */ get mask() { return this._getOption('mask'); } set mask(value) { this._setOption('mask', value); } /** * Specifies a mask placeholder. A single character is recommended. */ get maskChar() { return this._getOption('maskChar'); } set maskChar(value) { this._setOption('maskChar', value); } /** * A message displayed when the entered text does not match the specified pattern. */ get maskInvalidMessage() { return this._getOption('maskInvalidMessage'); } set maskInvalidMessage(value) { this._setOption('maskInvalidMessage', value); } /** * Specifies custom mask rules. */ get maskRules() { return this._getOption('maskRules'); } set maskRules(value) { this._setOption('maskRules', value); } /** * Specifies the maximum number of characters you can enter into the textbox. */ get maxLength() { return this._getOption('maxLength'); } set maxLength(value) { this._setOption('maxLength', value); } /** * The 'mode' attribute value of the actual HTML input element representing the text box. */ get mode() { return this._getOption('mode'); } set mode(value) { this._setOption('mode', value); } /** * The value to be assigned to the `name` attribute of the underlying HTML element. */ get name() { return this._getOption('name'); } set name(value) { this._setOption('name', value); } /** * Specifies a text string displayed when the editor's value is empty. */ get placeholder() { return this._getOption('placeholder'); } set placeholder(value) { this._setOption('placeholder', value); } /** * Specifies whether the editor is read-only. */ get readOnly() { return this._getOption('readOnly'); } set readOnly(value) { this._setOption('readOnly', value); } /** * Switches the UI component to a right-to-left representation. */ get rtlEnabled() { return this._getOption('rtlEnabled'); } set rtlEnabled(value) { this._setOption('rtlEnabled', value); } /** * Specifies whether to display the Clear button in the UI component. */ get showClearButton() { return this._getOption('showClearButton'); } set showClearButton(value) { this._setOption('showClearButton', value); } /** * Specifies when the UI component shows the mask. Applies only if useMaskedValue is true. */ get showMaskMode() { return this._getOption('showMaskMode'); } set showMaskMode(value) { this._setOption('showMaskMode', value); } /** * Specifies whether or not the UI component checks the inner text for spelling mistakes. */ get spellcheck() { return this._getOption('spellcheck'); } set spellcheck(value) { this._setOption('spellcheck', value); } /** * Specifies how the UI component's text field is styled. */ get stylingMode() { return this._getOption('stylingMode'); } set stylingMode(value) { this._setOption('stylingMode', value); } /** * Specifies the number of the element when the Tab key is used for navigating. */ get tabIndex() { return this._getOption('tabIndex'); } set tabIndex(value) { this._setOption('tabIndex', value); } /** * The read-only property that holds the text displayed by the UI component input element. */ get text() { return this._getOption('text'); } set text(value) { this._setOption('text', value); } /** * Specifies whether the value should contain mask characters or not. */ get useMaskedValue() { return this._getOption('useMaskedValue'); } set useMaskedValue(value) { this._setOption('useMaskedValue', value); } /** * Information on the broken validation rule. Contains the first item from the validationErrors array. */ get validationError() { return this._getOption('validationError'); } set validationError(value) { this._setOption('validationError', value); } /** * An array of the validation rules that failed. */ get validationErrors() { return this._getOption('validationErrors'); } set validationErrors(value) { this._setOption('validationErrors', value); } /** * Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed. */ get validationMessageMode() { return this._getOption('validationMessageMode'); } set validationMessageMode(value) { this._setOption('validationMessageMode', value); } /** * Indicates or specifies the current validation status. */ get validationStatus() { return this._getOption('validationStatus'); } set validationStatus(value) { this._setOption('validationStatus', value); } /** * Specifies a value the UI component displays. */ get value() { return this._getOption('value'); } set value(value) { this._setOption('value', value); } /** * Specifies the DOM events after which the UI component's value should be updated. */ get valueChangeEvent() { return this._getOption('valueChangeEvent'); } set valueChangeEvent(value) { this._setOption('valueChangeEvent', value); } /** * Specifies whether the UI component is visible. */ get visible() { return this._getOption('visible'); } set visible(value) { this._setOption('visible', value); } /** * Specifies the UI component's width. */ get width() { return this._getOption('width'); } set width(value) { this._setOption('width', value); } change(_) { } get buttonsChildren() { return this._getOption('buttons'); } set buttonsChildren(value) { this.setChildren('buttons', value); } _createInstance(element, options) { return new DxTextBox(element, options); } writeValue(value) { this.eventHelper.lockedValueChangeEvent = true; this.value = value; this.eventHelper.lockedValueChangeEvent = false; } setDisabledState(isDisabled) { this.disabled = isDisabled; } registerOnChange(fn) { this.change = fn; } registerOnTouched(fn) { this.touched = fn; } _createWidget(element) { super._createWidget(element); this.instance.on('focusOut', (e) => { this.eventHelper.fireNgEvent('onBlur', [e]); }); } ngOnDestroy() { this._destroyWidget(); } ngOnChanges(changes) { super.ngOnChanges(changes); this.setupChanges('buttons', changes); this.setupChanges('validationErrors', changes); } setupChanges(prop, changes) { if (!(prop in this._optionsToUpdate)) { this._idh.setup(prop, changes); } } ngDoCheck() { this._idh.doCheck('buttons'); this._idh.doCheck('validationErrors'); this._watcherHelper.checkWatchers(); super.ngDoCheck(); super.clearChangedOptions(); } _setOption(name, value) { let isSetup = this._idh.setupSingle(name, value); let isChanged = this._idh.getChanges(name, value) !== null; if (isSetup || isChanged) { super._setOption(name, value); } } } /** @nocollapse */ DxTextBoxComponent.ɵfac = function DxTextBoxComponent_Factory(t) { return new (t || DxTextBoxComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(i1.DxTemplateHost), i0.ɵɵdirectiveInject(i1.WatcherHelper), i0.ɵɵdirectiveInject(i1.IterableDifferHelper), i0.ɵɵdirectiveInject(i1.NestedOptionHost), i0.ɵɵdirectiveInject(i2.TransferState), i0.ɵɵdirectiveInject(PLATFORM_ID)); }; /** @nocollapse */ DxTextBoxComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: DxTextBoxComponent, selectors: [["dx-text-box"]], contentQueries: function DxTextBoxComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) { i0.ɵɵcontentQuery(dirIndex, DxiButtonComponent, 4); } if (rf & 2) { let _t; i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.buttonsChildren = _t); } }, hostBindings: function DxTextBoxComponent_HostBindings(rf, ctx) { if (rf & 1) { i0.ɵɵlistener("valueChange", function DxTextBoxComponent_valueChange_HostBindingHandler($event) { return ctx.change($event); })("onBlur", function DxTextBoxComponent_onBlur_HostBindingHandler($event) { return ctx.touched($event); }); } }, inputs: { accessKey: "accessKey", activeStateEnabled: "activeStateEnabled", buttons: "buttons", disabled: "disabled", elementAttr: "elementAttr", focusStateEnabled: "focusStateEnabled", height: "height", hint: "hint", hoverStateEnabled: "hoverStateEnabled", inputAttr: "inputAttr", isValid: "isValid", label: "label", labelMode: "labelMode", mask: "mask", maskChar: "maskChar", maskInvalidMessage: "maskInvalidMessage", maskRules: "maskRules", maxLength: "maxLength", mode: "mode", name: "name", placeholder: "placeholder", readOnly: "readOnly", rtlEnabled: "rtlEnabled", showClearButton: "showClearButton", showMaskMode: "showMaskMode", spellcheck: "spellcheck", stylingMode: "stylingMode", tabIndex: "tabIndex", text: "text", useMaskedValue: "useMaskedValue", validationError: "validationError", validationErrors: "validationErrors", validationMessageMode: "validationMessageMode", validationStatus: "validationStatus", value: "value", valueChangeEvent: "valueChangeEvent", visible: "visible", width: "width" }, outputs: { onChange: "onChange", onContentReady: "onContentReady", onCopy: "onCopy", onCut: "onCut", onDisposing: "onDisposing", onEnterKey: "onEnterKey", onFocusIn: "onFocusIn", onFocusOut: "onFocusOut", onInitialized: "onInitialized", onInput: "onInput", onKeyDown: "onKeyDown", onKeyUp: "onKeyUp", onOptionChanged: "onOptionChanged", onPaste: "onPaste", onValueChanged: "onValueChanged", accessKeyChange: "accessKeyChange", activeStateEnabledChange: "activeStateEnabledChange", buttonsChange: "buttonsChange", disabledChange: "disabledChange", elementAttrChange: "elementAttrChange", focusStateEnabledChange: "focusStateEnabledChange", heightChange: "heightChange", hintChange: "hintChange", hoverStateEnabledChange: "hoverStateEnabledChange", inputAttrChange: "inputAttrChange", isValidChange: "isValidChange", labelChange: "labelChange", labelModeChange: "labelModeChange", maskChange: "maskChange", maskCharChange: "maskCharChange", maskInvalidMessageChange: "maskInvalidMessageChange", maskRulesChange: "maskRulesChange", maxLengthChange: "maxLengthChange", modeChange: "modeChange", nameChange: "nameChange", placeholderChange: "placeholderChange", readOnlyChange: "readOnlyChange", rtlEnabledChange: "rtlEnabledChange", showClearButtonChange: "showClearButtonChange", showMaskModeChange: "showMaskModeChange", spellcheckChange: "spellcheckChange", stylingModeChange: "stylingModeChange", tabIndexChange: "tabIndexChange", textChange: "textChange", useMaskedValueChange: "useMaskedValueChange", validationErrorChange: "validationErrorChange", validationErrorsChange: "validationErrorsChange", validationMessageModeChange: "validationMessageModeChange", validationStatusChange: "validationStatusChange", valueChange: "valueChange", valueChangeEventChange: "valueChangeEventChange", visibleChange: "visibleChange", widthChange: "widthChange", onBlur: "onBlur" }, features: [i0.ɵɵProvidersFeature([ DxTemplateHost, WatcherHelper, CUSTOM_VALUE_ACCESSOR_PROVIDER, NestedOptionHost, IterableDifferHelper ]), i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 0, vars: 0, template: function DxTextBoxComponent_Template(rf, ctx) { }, encapsulation: 2 }); (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DxTextBoxComponent, [{ type: Component, args: [{ selector: 'dx-text-box', template: '', providers: [ DxTemplateHost, WatcherHelper, CUSTOM_VALUE_ACCESSOR_PROVIDER, NestedOptionHost, IterableDifferHelper ] }] }], function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.DxTemplateHost }, { type: i1.WatcherHelper }, { type: i1.IterableDifferHelper }, { type: i1.NestedOptionHost }, { type: i2.TransferState }, { type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID] }] }]; }, { accessKey: [{ type: Input }], activeStateEnabled: [{ type: Input }], buttons: [{ type: Input }], disabled: [{ type: Input }], elementAttr: [{ type: Input }], focusStateEnabled: [{ type: Input }], height: [{ type: Input }], hint: [{ type: Input }], hoverStateEnabled: [{ type: Input }], inputAttr: [{ type: Input }], isValid: [{ type: Input }], label: [{ type: Input }], labelMode: [{ type: Input }], mask: [{ type: Input }], maskChar: [{ type: Input }], maskInvalidMessage: [{ type: Input }], maskRules: [{ type: Input }], maxLength: [{ type: Input }], mode: [{ type: Input }], name: [{ type: Input }], placeholder: [{ type: Input }], readOnly: [{ type: Input }], rtlEnabled: [{ type: Input }], showClearButton: [{ type: Input }], showMaskMode: [{ type: Input }], spellcheck: [{ type: Input }], stylingMode: [{ type: Input }], tabIndex: [{ type: Input }], text: [{ type: Input }], useMaskedValue: [{ type: Input }], validationError: [{ type: Input }], validationErrors: [{ type: Input }], validationMessageMode: [{ type: Input }], validationStatus: [{ type: Input }], value: [{ type: Input }], valueChangeEvent: [{ type: Input }], visible: [{ type: Input }], width: [{ type: Input }], onChange: [{ type: Output }], onContentReady: [{ type: Output }], onCopy: [{ type: Output }], onCut: [{ type: Output }], onDisposing: [{ type: Output }], onEnterKey: [{ type: Output }], onFocusIn: [{ type: Output }], onFocusOut: [{ type: Output }], onInitialized: [{ type: Output }], onInput: [{ type: Output }], onKeyDown: [{ type: Output }], onKeyUp: [{ type: Output }], onOptionChanged: [{ type: Output }], onPaste: [{ type: Output }], onValueChanged: [{ type: Output }], accessKeyChange: [{ type: Output }], activeStateEnabledChange: [{ type: Output }], buttonsChange: [{ type: Output }], disabledChange: [{ type: Output }], elementAttrChange: [{ type: Output }], focusStateEnabledChange: [{ type: Output }], heightChange: [{ type: Output }], hintChange: [{ type: Output }], hoverStateEnabledChange: [{ type: Output }], inputAttrChange: [{ type: Output }], isValidChange: [{ type: Output }], labelChange: [{ type: Output }], labelModeChange: [{ type: Output }], maskChange: [{ type: Output }], maskCharChange: [{ type: Output }], maskInvalidMessageChange: [{ type: Output }], maskRulesChange: [{ type: Output }], maxLengthChange: [{ type: Output }], modeChange: [{ type: Output }], nameChange: [{ type: Output }], placeholderChange: [{ type: Output }], readOnlyChange: [{ type: Output }], rtlEnabledChange: [{ type: Output }], showClearButtonChange: [{ type: Output }], showMaskModeChange: [{ type: Output }], spellcheckChange: [{ type: Output }], stylingModeChange: [{ type: Output }], tabIndexChange: [{ type: Output }], textChange: [{ type: Output }], useMaskedValueChange: [{ type: Output }], validationErrorChange: [{ type: Output }], validationErrorsChange: [{ type: Output }], validationMessageModeChange: [{ type: Output }], validationStatusChange: [{ type: Output }], valueChange: [{ type: Output }], valueChangeEventChange: [{ type: Output }], visibleChange: [{ type: Output }], widthChange: [{ type: Output }], onBlur: [{ type: Output }], change: [{ type: HostListener, args: ['valueChange', ['$event']] }], touched: [{ type: HostListener, args: ['onBlur', ['$event']] }], buttonsChildren: [{ type: ContentChildren, args: [DxiButtonComponent] }] }); })(); class DxTextBoxModule { } /** @nocollapse */ DxTextBoxModule.ɵfac = function DxTextBoxModule_Factory(t) { return new (t || DxTextBoxModule)(); }; /** @nocollapse */ DxTextBoxModule.ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: DxTextBoxModule }); /** @nocollapse */ DxTextBoxModule.ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ imports: [[ DxiButtonModule, DxoOptionsModule, DxIntegrationModule, DxTemplateModule, BrowserTransferStateModule ], DxiButtonModule, DxoOptionsModule, DxTemplateModule] }); (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DxTextBoxModule, [{ type: NgModule, args: [{ imports: [ DxiButtonModule, DxoOptionsModule, DxIntegrationModule, DxTemplateModule, BrowserTransferStateModule ], declarations: [ DxTextBoxComponent ], exports: [ DxTextBoxComponent, DxiButtonModule, DxoOptionsModule, DxTemplateModule ] }] }], null, null); })(); (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DxTextBoxModule, { declarations: [DxTextBoxComponent], imports: [DxiButtonModule, DxoOptionsModule, DxIntegrationModule, DxTemplateModule, BrowserTransferStateModule], exports: [DxTextBoxComponent, DxiButtonModule, DxoOptionsModule, DxTemplateModule] }); })(); /** * Generated bundle index. Do not edit. */ export { DxTextBoxComponent, DxTextBoxModule }; //# sourceMappingURL=devextreme-angular-ui-text-box.js.map