@syncfusion/ej2-inputs 30.2.4 → 31.1.17
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.
- package/dist/ej2-inputs.min.js +2 -2
- package/dist/ej2-inputs.umd.min.js +2 -2
- package/dist/ej2-inputs.umd.min.js.map +1 -1
- package/dist/es6/ej2-inputs.es2015.js +1 -1
- package/dist/es6/ej2-inputs.es2015.js.map +1 -1
- package/dist/es6/ej2-inputs.es5.js +1 -1
- package/dist/es6/ej2-inputs.es5.js.map +1 -1
- package/dist/global/ej2-inputs.min.js +2 -2
- package/dist/global/ej2-inputs.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/color-picker/color-picker-model.d.ts +186 -0
- package/dist/ts/color-picker/color-picker.d.ts +398 -0
- package/dist/ts/color-picker/color-picker.ts +2209 -0
- package/dist/ts/color-picker/index.d.ts +5 -0
- package/dist/ts/color-picker/index.ts +5 -0
- package/dist/ts/common/index.d.ts +4 -0
- package/dist/ts/common/index.ts +4 -0
- package/dist/ts/common/signature-base.d.ts +340 -0
- package/dist/ts/common/signature-base.ts +1170 -0
- package/dist/ts/form-validator/form-validator-model.d.ts +121 -0
- package/dist/ts/form-validator/form-validator.d.ts +312 -0
- package/dist/ts/form-validator/form-validator.ts +1068 -0
- package/dist/ts/form-validator/index.d.ts +5 -0
- package/dist/ts/form-validator/index.ts +5 -0
- package/dist/ts/index.d.ts +18 -0
- package/dist/ts/index.ts +18 -0
- package/dist/ts/input/index.d.ts +4 -0
- package/dist/ts/input/index.ts +4 -0
- package/dist/ts/input/input.d.ts +345 -0
- package/dist/ts/input/input.ts +1277 -0
- package/dist/ts/maskedtextbox/base/index.d.ts +4 -0
- package/dist/ts/maskedtextbox/base/index.ts +4 -0
- package/dist/ts/maskedtextbox/base/mask-base.d.ts +134 -0
- package/dist/ts/maskedtextbox/base/mask-base.ts +1207 -0
- package/dist/ts/maskedtextbox/index.d.ts +5 -0
- package/dist/ts/maskedtextbox/index.ts +5 -0
- package/dist/ts/maskedtextbox/maskedtextbox/index.d.ts +5 -0
- package/dist/ts/maskedtextbox/maskedtextbox/index.ts +5 -0
- package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox-model.d.ts +167 -0
- package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.d.ts +307 -0
- package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.ts +709 -0
- package/dist/ts/numerictextbox/index.d.ts +5 -0
- package/dist/ts/numerictextbox/index.ts +5 -0
- package/dist/ts/numerictextbox/numerictextbox-model.d.ts +228 -0
- package/dist/ts/numerictextbox/numerictextbox.d.ts +431 -0
- package/dist/ts/numerictextbox/numerictextbox.ts +1672 -0
- package/dist/ts/otp-input/index.d.ts +5 -0
- package/dist/ts/otp-input/index.ts +5 -0
- package/dist/ts/otp-input/otp-input-model.d.ts +165 -0
- package/dist/ts/otp-input/otp-input.d.ts +365 -0
- package/dist/ts/otp-input/otp-input.ts +924 -0
- package/dist/ts/rating/index.d.ts +5 -0
- package/dist/ts/rating/index.ts +5 -0
- package/dist/ts/rating/rating-model.d.ts +239 -0
- package/dist/ts/rating/rating.d.ts +416 -0
- package/dist/ts/rating/rating.ts +1101 -0
- package/dist/ts/signature/index.d.ts +5 -0
- package/dist/ts/signature/index.ts +5 -0
- package/dist/ts/signature/signature-model.d.ts +131 -0
- package/dist/ts/signature/signature.d.ts +167 -0
- package/dist/ts/signature/signature.ts +266 -0
- package/dist/ts/slider/index.d.ts +5 -0
- package/dist/ts/slider/index.ts +5 -0
- package/dist/ts/slider/slider-model.d.ts +401 -0
- package/dist/ts/slider/slider.d.ts +721 -0
- package/dist/ts/slider/slider.ts +3497 -0
- package/dist/ts/smart-textarea/caret-helper.d.ts +17 -0
- package/dist/ts/smart-textarea/caret-helper.ts +95 -0
- package/dist/ts/smart-textarea/index.d.ts +5 -0
- package/dist/ts/smart-textarea/index.ts +5 -0
- package/dist/ts/smart-textarea/smart-textarea-model.d.ts +44 -0
- package/dist/ts/smart-textarea/smart-textarea.d.ts +80 -0
- package/dist/ts/smart-textarea/smart-textarea.ts +518 -0
- package/dist/ts/speech-to-text/index.d.ts +5 -0
- package/dist/ts/speech-to-text/index.ts +5 -0
- package/dist/ts/speech-to-text/speech-to-text-model.d.ts +270 -0
- package/dist/ts/speech-to-text/speech-to-text.d.ts +487 -0
- package/dist/ts/speech-to-text/speech-to-text.ts +1008 -0
- package/dist/ts/textarea/index.d.ts +5 -0
- package/dist/ts/textarea/index.ts +5 -0
- package/dist/ts/textarea/textarea-model.d.ts +161 -0
- package/dist/ts/textarea/textarea.d.ts +237 -0
- package/dist/ts/textarea/textarea.ts +812 -0
- package/dist/ts/textbox/index.d.ts +5 -0
- package/dist/ts/textbox/index.ts +5 -0
- package/dist/ts/textbox/textbox-model.d.ts +155 -0
- package/dist/ts/textbox/textbox.d.ts +288 -0
- package/dist/ts/textbox/textbox.ts +872 -0
- package/dist/ts/uploader/index.d.ts +5 -0
- package/dist/ts/uploader/index.ts +5 -0
- package/dist/ts/uploader/uploader-model.d.ts +555 -0
- package/dist/ts/uploader/uploader.d.ts +1216 -0
- package/dist/ts/uploader/uploader.ts +4391 -0
- package/package.json +62 -12
- package/src/input/input.js +1 -1
- package/styles/bootstrap5.3-lite.css +3 -3
- package/styles/bootstrap5.3.css +5 -5
- package/styles/input/_layout.scss +0 -1
- package/styles/input/tailwind3.css +0 -1
- package/styles/tailwind-dark-lite.css +3 -3
- package/styles/tailwind-dark.css +5 -5
- package/styles/tailwind-lite.css +3 -3
- package/styles/tailwind.css +5 -5
- package/styles/tailwind3-lite.css +0 -1
- package/styles/tailwind3.css +0 -1
- package/styles/uploader/_bootstrap5.3-definition.scss +1 -1
- package/styles/uploader/_tailwind-definition.scss +1 -1
- package/styles/uploader/bootstrap5.3.css +5 -5
- package/styles/uploader/tailwind-dark.css +5 -5
- package/styles/uploader/tailwind.css +5 -5
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
import { Component, Property, NotifyPropertyChanges, INotifyPropertyChanged, isNullOrUndefined, setValue, getValue } from '@syncfusion/ej2-base';
|
|
2
|
+
import { detach, getUniqueID, Event, EventHandler, EmitType, Internationalization, L10n, addClass, removeClass, closest, formatUnit } from '@syncfusion/ej2-base';
|
|
3
|
+
import { FloatLabelType, Input, InputObject, TEXTBOX_FOCUS } from '../input/input';
|
|
4
|
+
import { FocusInEventArgs, FocusOutEventArgs, InputEventArgs, ChangedEventArgs } from '../textbox/textbox';
|
|
5
|
+
import { TextAreaModel } from './textarea-model';
|
|
6
|
+
|
|
7
|
+
const HIDE_CLEAR: string = 'e-clear-icon-hide';
|
|
8
|
+
const AUTO_WIDTH: string = 'e-auto-width';
|
|
9
|
+
const RESIZE_X: string = 'e-resize-x';
|
|
10
|
+
const RESIZE_Y: string = 'e-resize-y';
|
|
11
|
+
const RESIZE_XY: string = 'e-resize-xy';
|
|
12
|
+
const RESIZE_NONE: string = 'e-resize-none';
|
|
13
|
+
export type Resize = 'Vertical' | 'Horizontal' | 'Both' | 'None';
|
|
14
|
+
|
|
15
|
+
@NotifyPropertyChanges
|
|
16
|
+
export class TextArea extends Component<HTMLTextAreaElement> implements INotifyPropertyChanged {
|
|
17
|
+
private textareaWrapper: InputObject;
|
|
18
|
+
private textareaOptions: TextAreaModel;
|
|
19
|
+
private globalize: Internationalization;
|
|
20
|
+
private l10n: L10n;
|
|
21
|
+
private previousValue: string = null;
|
|
22
|
+
private formElement: HTMLElement;
|
|
23
|
+
private isForm: boolean = false;
|
|
24
|
+
private initialValue: string;
|
|
25
|
+
private inputPreviousValue: string = null;
|
|
26
|
+
private preventChange: boolean;
|
|
27
|
+
private clearButton: HTMLElement;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Specifies the boolean value whether the TextArea allows user to change the text.
|
|
31
|
+
*
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
@Property(false)
|
|
35
|
+
public readonly: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Sets the content of the TextArea.
|
|
39
|
+
*
|
|
40
|
+
* @default null
|
|
41
|
+
*/
|
|
42
|
+
@Property(null)
|
|
43
|
+
public value: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Specifies the floating label behavior of the TextArea that the placeholder text floats above the TextArea based on the below values.
|
|
47
|
+
* Possible values are:
|
|
48
|
+
* * `Never` - The placeholder text should not be float ever.
|
|
49
|
+
* * `Always` - The placeholder text floats above the TextArea always.
|
|
50
|
+
* * `Auto` - The placeholder text floats above the TextArea while focusing or enter a value in TextArea.
|
|
51
|
+
*
|
|
52
|
+
* @default Never
|
|
53
|
+
*/
|
|
54
|
+
@Property('Never')
|
|
55
|
+
public floatLabelType: FloatLabelType;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Specifies the CSS class value that is appended to wrapper of Textbox.
|
|
59
|
+
*
|
|
60
|
+
* @default ''
|
|
61
|
+
*/
|
|
62
|
+
@Property('')
|
|
63
|
+
public cssClass: string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Specifies the text that is shown as a hint/placeholder until the user focus or enter a value in TextArea.
|
|
67
|
+
* The property is depending on the floatLabelType property.
|
|
68
|
+
*
|
|
69
|
+
* @default null
|
|
70
|
+
*/
|
|
71
|
+
@Property(null)
|
|
72
|
+
public placeholder: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* You can add the additional html attributes such as disabled, value etc., to the element.
|
|
76
|
+
* If you configured both property and equivalent html attribute then the component considers the property value.
|
|
77
|
+
*
|
|
78
|
+
* @default {}
|
|
79
|
+
*/
|
|
80
|
+
@Property({})
|
|
81
|
+
public htmlAttributes: { [key: string]: string };
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Specifies a Boolean value that indicates whether the TextArea allow user to interact with it.
|
|
85
|
+
*
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
@Property(true)
|
|
89
|
+
public enabled: boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Specifies a Boolean value that indicates whether the clear button is displayed in TextArea.
|
|
93
|
+
*
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
@Property(false)
|
|
97
|
+
public showClearButton: boolean;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Enable or disable persisting TextArea state between page reloads. If enabled, the `value` state will be persisted.
|
|
101
|
+
*
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
@Property(false)
|
|
105
|
+
public enablePersistence: boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Specifies the width of the TextArea component.
|
|
109
|
+
*
|
|
110
|
+
* @default null
|
|
111
|
+
*/
|
|
112
|
+
@Property(null)
|
|
113
|
+
public width: number | string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Specifies the resize mode of textarea.
|
|
117
|
+
* possible values are:
|
|
118
|
+
* * `Vertical` - The textarea element can be resized vertically.
|
|
119
|
+
* * `Horizontal` - The textarea element can be resized horizontally.
|
|
120
|
+
* * `Both` - The textarea element can be resized both vertically and horizontally.
|
|
121
|
+
* * `None` - The textarea element cannot be resized.
|
|
122
|
+
*
|
|
123
|
+
* @default Both
|
|
124
|
+
*/
|
|
125
|
+
@Property('Both')
|
|
126
|
+
public resizeMode: Resize;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Specifies the maximum number of characters allowed in TextArea.
|
|
130
|
+
*
|
|
131
|
+
* @aspType int?
|
|
132
|
+
*/
|
|
133
|
+
@Property(null)
|
|
134
|
+
public maxLength: number;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* specifies the visible width of the textarea, measured in average character widths.
|
|
138
|
+
*
|
|
139
|
+
* @aspType int?
|
|
140
|
+
*/
|
|
141
|
+
@Property(null)
|
|
142
|
+
public cols: number;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* specifies the visible height of the textarea, measured in lines
|
|
146
|
+
*
|
|
147
|
+
* @aspType int?
|
|
148
|
+
*/
|
|
149
|
+
@Property(null)
|
|
150
|
+
public rows: number;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Triggers when the TextArea component is created.
|
|
154
|
+
*
|
|
155
|
+
* @event created
|
|
156
|
+
*/
|
|
157
|
+
@Event()
|
|
158
|
+
public created: EmitType<Object>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Triggers when the TextArea component is destroyed.
|
|
162
|
+
*
|
|
163
|
+
* @event destroyed
|
|
164
|
+
*/
|
|
165
|
+
@Event()
|
|
166
|
+
public destroyed: EmitType<Object>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Triggers when the content of TextArea has changed and gets focus-out.
|
|
170
|
+
*
|
|
171
|
+
* @event change
|
|
172
|
+
*/
|
|
173
|
+
@Event()
|
|
174
|
+
public change: EmitType<ChangedEventArgs>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Triggers when the TextArea has focus-out.
|
|
178
|
+
*
|
|
179
|
+
* @event blur
|
|
180
|
+
*/
|
|
181
|
+
@Event()
|
|
182
|
+
public blur: EmitType<FocusOutEventArgs>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Triggers when the TextArea gets focus.
|
|
186
|
+
*
|
|
187
|
+
* @event focus
|
|
188
|
+
*/
|
|
189
|
+
@Event()
|
|
190
|
+
public focus: EmitType<FocusInEventArgs>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Triggers each time when the value of TextArea has changed.
|
|
194
|
+
*
|
|
195
|
+
* @event input
|
|
196
|
+
*/
|
|
197
|
+
@Event()
|
|
198
|
+
public input: EmitType<InputEventArgs>;
|
|
199
|
+
|
|
200
|
+
public constructor(options?: TextAreaModel, element?: string | HTMLTextAreaElement ) {
|
|
201
|
+
super(options, <string | HTMLTextAreaElement> element);
|
|
202
|
+
this.textareaOptions = options;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Calls internally if any of the property value is changed.
|
|
207
|
+
*
|
|
208
|
+
* @param {TextAreaModel} newProp - Returns the dynamic property value of the component.
|
|
209
|
+
* @param {TextAreaModel} oldProp - Returns the previous property value of the component.
|
|
210
|
+
* @returns {void}
|
|
211
|
+
* @private
|
|
212
|
+
*/
|
|
213
|
+
public onPropertyChanged(newProp: TextAreaModel, oldProp: TextAreaModel): void {
|
|
214
|
+
for (const prop of Object.keys(newProp)) {
|
|
215
|
+
switch (prop) {
|
|
216
|
+
case 'floatLabelType':
|
|
217
|
+
Input.removeFloating(this.textareaWrapper);
|
|
218
|
+
Input.addFloating(this.element, this.floatLabelType, this.placeholder);
|
|
219
|
+
if (this.floatLabelType === 'Never') {
|
|
220
|
+
this.element.removeAttribute('aria-labelledby');
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
case 'enabled':
|
|
224
|
+
Input.setEnabled(this.enabled, this.element, this.floatLabelType, this.textareaWrapper.container);
|
|
225
|
+
this.bindClearEvent();
|
|
226
|
+
if (!this.enabled && this.resizeMode !== 'None') {
|
|
227
|
+
this.element.classList.remove(this.getCurrentResizeClass(this.resizeMode));
|
|
228
|
+
this.element.classList.add(RESIZE_NONE);
|
|
229
|
+
} else {
|
|
230
|
+
this.element.classList.add(this.getCurrentResizeClass(this.resizeMode));
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case 'width':
|
|
234
|
+
if (this.resizeMode !== 'None' && this.resizeMode !== 'Vertical') {
|
|
235
|
+
this.setElementWidth(newProp.width);
|
|
236
|
+
this.textareaWrapper.container.classList.add(AUTO_WIDTH);
|
|
237
|
+
} else {
|
|
238
|
+
if (this.textareaWrapper.container.classList.contains(AUTO_WIDTH)) {
|
|
239
|
+
this.textareaWrapper.container.classList.remove(AUTO_WIDTH);
|
|
240
|
+
}
|
|
241
|
+
Input.setWidth(newProp.width, this.textareaWrapper.container);
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
case 'value': {
|
|
245
|
+
const prevOnChange: boolean = this.isProtectedOnChange;
|
|
246
|
+
this.isProtectedOnChange = true;
|
|
247
|
+
if (!Input.isBlank(this.value)) {
|
|
248
|
+
this.value = this.value.toString();
|
|
249
|
+
}
|
|
250
|
+
this.isProtectedOnChange = prevOnChange;
|
|
251
|
+
Input.setValue(this.value, this.element, this.floatLabelType, this.showClearButton);
|
|
252
|
+
this.inputPreviousValue = this.element.value;
|
|
253
|
+
/* istanbul ignore next */
|
|
254
|
+
if ((this.isAngular || this.isVue) && this.preventChange === true) {
|
|
255
|
+
this.previousValue = this.isAngular ? this.value : this.previousValue;
|
|
256
|
+
this.preventChange = false;
|
|
257
|
+
} else if (isNullOrUndefined(this.isAngular) || !this.isAngular
|
|
258
|
+
|| (this.isAngular && !this.preventChange) || (this.isAngular && isNullOrUndefined(this.preventChange))) {
|
|
259
|
+
this.raiseChangeEvent();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
case 'htmlAttributes': {
|
|
264
|
+
this.updateHTMLAttributesToElement();
|
|
265
|
+
this.updateHTMLAttributesToWrapper();
|
|
266
|
+
this.checkAttributes(true);
|
|
267
|
+
Input.validateInputType(this.textareaWrapper.container, this.element);
|
|
268
|
+
}
|
|
269
|
+
break;
|
|
270
|
+
case 'readonly':
|
|
271
|
+
Input.setReadonly(this.readonly, this.element);
|
|
272
|
+
if (this.readonly) {
|
|
273
|
+
this.element.setAttribute('aria-readonly', 'true');
|
|
274
|
+
} else {
|
|
275
|
+
this.element.removeAttribute('aria-readonly');
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case 'showClearButton':
|
|
279
|
+
Input.setClearButton(this.showClearButton, this.element, this.textareaWrapper);
|
|
280
|
+
this.bindClearEvent();
|
|
281
|
+
break;
|
|
282
|
+
case 'enableRtl':
|
|
283
|
+
Input.setEnableRtl(this.enableRtl, [this.textareaWrapper.container]);
|
|
284
|
+
break;
|
|
285
|
+
case 'placeholder':
|
|
286
|
+
Input.setPlaceholder(this.placeholder, this.element);
|
|
287
|
+
Input.calculateWidth(this.element, this.textareaWrapper.container);
|
|
288
|
+
break;
|
|
289
|
+
case 'cssClass':
|
|
290
|
+
Input.updateCssClass(newProp.cssClass, oldProp.cssClass, this.textareaWrapper.container);
|
|
291
|
+
break;
|
|
292
|
+
case 'locale':
|
|
293
|
+
this.globalize = new Internationalization(this.locale);
|
|
294
|
+
this.l10n.setLocale(this.locale);
|
|
295
|
+
this.setProperties({ placeholder: this.l10n.getConstant('placeholder') }, true);
|
|
296
|
+
Input.setPlaceholder(this.placeholder, this.element);
|
|
297
|
+
break;
|
|
298
|
+
case 'rows':
|
|
299
|
+
if (this.rows) {
|
|
300
|
+
this.element.setAttribute('rows', this.rows.toString());
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
case 'cols':
|
|
304
|
+
if (this.cols) {
|
|
305
|
+
this.element.setAttribute('cols', this.cols.toString());
|
|
306
|
+
if (this.width == null) {
|
|
307
|
+
this.textareaWrapper.container.classList.add(AUTO_WIDTH);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
case 'maxLength':
|
|
312
|
+
if (this.maxLength) {
|
|
313
|
+
this.element.setAttribute('maxlength', this.maxLength.toString());
|
|
314
|
+
}
|
|
315
|
+
break;
|
|
316
|
+
case 'resizeMode':
|
|
317
|
+
if (this.enabled) {
|
|
318
|
+
if (this.element.classList.contains(this.getCurrentResizeClass(oldProp.resizeMode))) {
|
|
319
|
+
this.element.classList.remove(this.getCurrentResizeClass(oldProp.resizeMode));
|
|
320
|
+
}
|
|
321
|
+
this.element.classList.add(this.getCurrentResizeClass(this.resizeMode));
|
|
322
|
+
if (this.element.style.width && (this.resizeMode === 'None' || this.resizeMode === 'Vertical')) {
|
|
323
|
+
Input.setWidth(this.element.style.width, this.textareaWrapper.container);
|
|
324
|
+
} else {
|
|
325
|
+
const currentWidth: number = this.element.offsetWidth;
|
|
326
|
+
this.element.style.width = currentWidth + 'px';
|
|
327
|
+
if (this.textareaWrapper.container.style.width) {
|
|
328
|
+
this.textareaWrapper.container.style.width = '';
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
this.setWrapperWidth();
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
protected preRender(): void {
|
|
339
|
+
this.formElement = closest(this.element, 'form') as HTMLFormElement;
|
|
340
|
+
if (!isNullOrUndefined(this.formElement)) {
|
|
341
|
+
this.isForm = true;
|
|
342
|
+
}
|
|
343
|
+
/* istanbul ignore next */
|
|
344
|
+
if (this.element.tagName === 'EJS-TEXTAREA' || this.element.tagName === 'EJS-SMARTTEXTAREA') {
|
|
345
|
+
const ejInstance: Object = getValue('ej2_instances', this.element);
|
|
346
|
+
const inputElement: string | HTMLTextAreaElement = <HTMLTextAreaElement>this.createElement('textarea');
|
|
347
|
+
let index: number = 0;
|
|
348
|
+
for (index; index < this.element.attributes.length; index++) {
|
|
349
|
+
const attributeName: string = this.element.attributes[index as number].nodeName;
|
|
350
|
+
if (attributeName !== 'id' && attributeName !== 'class') {
|
|
351
|
+
inputElement.setAttribute(attributeName, this.element.attributes[index as number].nodeValue);
|
|
352
|
+
inputElement.innerHTML = this.element.innerHTML;
|
|
353
|
+
if (attributeName === 'name') {
|
|
354
|
+
this.element.removeAttribute('name');
|
|
355
|
+
}
|
|
356
|
+
} else if (attributeName === 'class') {
|
|
357
|
+
inputElement.setAttribute(attributeName, this.element.className.split(' ').filter((item: string) => item.indexOf('ng-') !== 0).join(' '));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
this.element.appendChild(inputElement);
|
|
361
|
+
this.element = inputElement;
|
|
362
|
+
setValue('ej2_instances', ejInstance, this.element);
|
|
363
|
+
}
|
|
364
|
+
this.updateHTMLAttributesToElement();
|
|
365
|
+
this.checkAttributes(false);
|
|
366
|
+
if (( isNullOrUndefined(this.textareaOptions) || (this.textareaOptions['value'] === undefined)) && this.element.value !== '') {
|
|
367
|
+
this.setProperties({value: this.element.value}, true);
|
|
368
|
+
}
|
|
369
|
+
this.globalize = new Internationalization(this.locale);
|
|
370
|
+
const localeText: { placeholder: string } = { placeholder: this.placeholder };
|
|
371
|
+
this.l10n = new L10n('textarea', localeText, this.locale);
|
|
372
|
+
if (this.l10n.getConstant('placeholder') !== '') {
|
|
373
|
+
this.setProperties({ placeholder: this.placeholder || this.l10n.getConstant('placeholder') }, true);
|
|
374
|
+
}
|
|
375
|
+
if (!this.element.hasAttribute('id')) {
|
|
376
|
+
this.element.setAttribute('id', getUniqueID('textbox'));
|
|
377
|
+
}
|
|
378
|
+
if (!this.element.hasAttribute('name')) {
|
|
379
|
+
this.element.setAttribute('name', this.element.getAttribute('id'));
|
|
380
|
+
}
|
|
381
|
+
if (this.rows) {
|
|
382
|
+
this.element.setAttribute('rows', this.rows.toString());
|
|
383
|
+
}
|
|
384
|
+
if (this.cols) {
|
|
385
|
+
this.element.setAttribute('cols', this.cols.toString());
|
|
386
|
+
}
|
|
387
|
+
if (this.maxLength) {
|
|
388
|
+
this.element.setAttribute('maxlength', this.maxLength.toString());
|
|
389
|
+
}
|
|
390
|
+
if (!this.element.style.resize && this.enabled) {
|
|
391
|
+
this.element.classList.add(this.getCurrentResizeClass(this.resizeMode));
|
|
392
|
+
}
|
|
393
|
+
if (this.enabled) {
|
|
394
|
+
this.element.setAttribute('aria-multiline', 'true');
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* To Initialize the control rendering
|
|
400
|
+
*
|
|
401
|
+
* @returns {void}
|
|
402
|
+
* @private
|
|
403
|
+
*/
|
|
404
|
+
public render(): void {
|
|
405
|
+
let updatedCssClassValue: string = this.cssClass;
|
|
406
|
+
if (!isNullOrUndefined(this.cssClass) && this.cssClass !== '') {
|
|
407
|
+
updatedCssClassValue = Input.getInputValidClassList(this.cssClass);
|
|
408
|
+
}
|
|
409
|
+
this.textareaWrapper = Input.createInput({
|
|
410
|
+
element: this.element,
|
|
411
|
+
floatLabelType: this.floatLabelType,
|
|
412
|
+
properties: {
|
|
413
|
+
enabled: this.enabled,
|
|
414
|
+
enableRtl: this.enableRtl,
|
|
415
|
+
cssClass: updatedCssClassValue,
|
|
416
|
+
readonly: this.readonly,
|
|
417
|
+
placeholder: this.placeholder,
|
|
418
|
+
showClearButton: this.showClearButton
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
this.updateHTMLAttributesToWrapper();
|
|
422
|
+
this.wireEvents();
|
|
423
|
+
if (!isNullOrUndefined(this.value)) {
|
|
424
|
+
Input.setValue(this.value, this.element, this.floatLabelType, this.showClearButton);
|
|
425
|
+
}
|
|
426
|
+
if (!isNullOrUndefined(this.value)) {
|
|
427
|
+
this.initialValue = this.value;
|
|
428
|
+
if (!this.isAngular) {
|
|
429
|
+
this.element.setAttribute('value', this.initialValue);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
this.previousValue = this.value;
|
|
433
|
+
this.inputPreviousValue = this.value;
|
|
434
|
+
this.element.defaultValue = this.element.value;
|
|
435
|
+
Input.setWidth(this.width, this.textareaWrapper.container);
|
|
436
|
+
this.setWrapperWidth();
|
|
437
|
+
this.renderComplete();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
public getModuleName(): string {
|
|
441
|
+
return 'textarea';
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Gets the properties to be maintained in the persisted state.
|
|
446
|
+
*
|
|
447
|
+
* @returns {string} - Returns the string value.
|
|
448
|
+
*/
|
|
449
|
+
public getPersistData(): string {
|
|
450
|
+
const keyEntity: string[] = ['value'];
|
|
451
|
+
return this.addOnPersist(keyEntity);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
private checkAttributes(isDynamic: boolean): void {
|
|
455
|
+
const attrs: string[] = isDynamic ? isNullOrUndefined(this.htmlAttributes) ? [] : Object.keys(this.htmlAttributes) :
|
|
456
|
+
['placeholder', 'disabled', 'value', 'readonly'];
|
|
457
|
+
for (const key of attrs) {
|
|
458
|
+
if (!isNullOrUndefined(this.element.getAttribute(key))) {
|
|
459
|
+
switch (key) {
|
|
460
|
+
case 'disabled':
|
|
461
|
+
if (( isNullOrUndefined(this.textareaOptions) || (this.textareaOptions['enabled'] === undefined)) || isDynamic) {
|
|
462
|
+
const enabled: boolean = this.element.getAttribute(key) === 'disabled' || this.element.getAttribute(key) === '' ||
|
|
463
|
+
this.element.getAttribute(key) === 'true' ? false : true;
|
|
464
|
+
this.setProperties({enabled: enabled}, !isDynamic);
|
|
465
|
+
}
|
|
466
|
+
break;
|
|
467
|
+
case 'readonly':
|
|
468
|
+
if (( isNullOrUndefined(this.textareaOptions) || (this.textareaOptions['readonly'] === undefined)) || isDynamic) {
|
|
469
|
+
const readonly: boolean = this.element.getAttribute(key) === 'readonly' || this.element.getAttribute(key) === ''
|
|
470
|
+
|| this.element.getAttribute(key) === 'true' ? true : false;
|
|
471
|
+
this.setProperties({readonly: readonly}, !isDynamic);
|
|
472
|
+
}
|
|
473
|
+
break;
|
|
474
|
+
case 'placeholder':
|
|
475
|
+
if (( isNullOrUndefined(this.textareaOptions) || (this.textareaOptions['placeholder'] === undefined)) || isDynamic) {
|
|
476
|
+
this.setProperties({placeholder: this.element.placeholder}, !isDynamic);
|
|
477
|
+
}
|
|
478
|
+
break;
|
|
479
|
+
case 'value':
|
|
480
|
+
if ((( isNullOrUndefined(this.textareaOptions) || (this.textareaOptions['value'] === undefined)) || isDynamic) && this.element.value !== '') {
|
|
481
|
+
this.setProperties({value: this.element.value}, !isDynamic);
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
protected wireEvents(): void {
|
|
490
|
+
EventHandler.add(this.element, 'focus', this.focusHandler, this);
|
|
491
|
+
EventHandler.add(this.element, 'blur', this.focusOutHandler, this);
|
|
492
|
+
EventHandler.add(this.element, 'keydown', this.keydownHandler, this);
|
|
493
|
+
EventHandler.add(this.element, 'input', this.inputHandler, this);
|
|
494
|
+
EventHandler.add(this.element, 'change', this.changeHandler, this);
|
|
495
|
+
if (this.isForm) {
|
|
496
|
+
EventHandler.add(this.formElement, 'reset', this.resetForm, this);
|
|
497
|
+
}
|
|
498
|
+
this.bindClearEvent();
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
protected unWireEvents(): void {
|
|
502
|
+
EventHandler.remove(this.element, 'focus', this.focusHandler);
|
|
503
|
+
EventHandler.remove(this.element, 'blur', this.focusOutHandler);
|
|
504
|
+
EventHandler.remove(this.element, 'keydown', this.keydownHandler);
|
|
505
|
+
EventHandler.remove(this.element, 'input', this.inputHandler);
|
|
506
|
+
EventHandler.remove(this.element, 'change', this.changeHandler);
|
|
507
|
+
if (this.isForm) {
|
|
508
|
+
EventHandler.remove(this.formElement, 'reset', this.resetForm);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Removes the component from the DOM and detaches all its related event handlers.
|
|
514
|
+
* Also, it maintains the initial TextArea element from the DOM.
|
|
515
|
+
*
|
|
516
|
+
* @method destroy
|
|
517
|
+
* @returns {void}
|
|
518
|
+
*/
|
|
519
|
+
|
|
520
|
+
public destroy(): void {
|
|
521
|
+
this.unWireEvents();
|
|
522
|
+
if (this.showClearButton) {
|
|
523
|
+
this.clearButton = document.getElementsByClassName('e-clear-icon')[0] as HTMLElement;
|
|
524
|
+
}
|
|
525
|
+
this.element.value = this.element.defaultValue;
|
|
526
|
+
this.element.classList.remove('e-input', RESIZE_X, RESIZE_Y, RESIZE_XY, RESIZE_NONE);
|
|
527
|
+
if (this.textareaWrapper.container.style.width.includes('%')) {
|
|
528
|
+
EventHandler.remove(this.element, 'mousemove', this.onMouseMove);
|
|
529
|
+
}
|
|
530
|
+
this.removeAttributes(['aria-disabled', 'aria-readonly', 'aria-labelledby', 'aria-multiline']);
|
|
531
|
+
if (!isNullOrUndefined(this.textareaWrapper)) {
|
|
532
|
+
this.textareaWrapper.container.insertAdjacentElement('afterend', this.element);
|
|
533
|
+
detach(this.textareaWrapper.container);
|
|
534
|
+
}
|
|
535
|
+
this.textareaWrapper = null;
|
|
536
|
+
Input.destroy({
|
|
537
|
+
element: this.element,
|
|
538
|
+
floatLabelType: this.floatLabelType,
|
|
539
|
+
properties: this.properties
|
|
540
|
+
}, this.clearButton);
|
|
541
|
+
this.formElement = null;
|
|
542
|
+
super.destroy();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
private focusHandler(args: MouseEvent | TouchEvent | KeyboardEvent): void {
|
|
546
|
+
const eventArgs: FocusInEventArgs = {
|
|
547
|
+
container: this.textareaWrapper.container,
|
|
548
|
+
event: args,
|
|
549
|
+
value: this.value
|
|
550
|
+
};
|
|
551
|
+
this.trigger('focus', eventArgs);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
private focusOutHandler(args: MouseEvent | TouchEvent | KeyboardEvent): void {
|
|
555
|
+
if (!(this.previousValue === null && this.value === null) &&
|
|
556
|
+
(this.previousValue !== this.value)) {
|
|
557
|
+
this.raiseChangeEvent(args, true);
|
|
558
|
+
}
|
|
559
|
+
const eventArgs: FocusOutEventArgs = {
|
|
560
|
+
container: this.textareaWrapper.container,
|
|
561
|
+
event: args,
|
|
562
|
+
value: this.value
|
|
563
|
+
};
|
|
564
|
+
this.trigger('blur', eventArgs);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
protected keydownHandler (args: KeyboardEvent): void {
|
|
568
|
+
if ((args.keyCode === 13 || args.keyCode === 9) && !((this.previousValue === null || this.previousValue === '') && (this.value === null || this.value === '') && this.element.value === '')) {
|
|
569
|
+
this.setProperties({ value: this.element.value }, true);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
private inputHandler(args: KeyboardEvent): void {
|
|
574
|
+
const textareaObj: any = null || this;
|
|
575
|
+
const eventArgs: InputEventArgs = {
|
|
576
|
+
event: args,
|
|
577
|
+
value: this.element.value,
|
|
578
|
+
previousValue: this.inputPreviousValue,
|
|
579
|
+
container: this.textareaWrapper.container
|
|
580
|
+
};
|
|
581
|
+
this.inputPreviousValue = this.element.value;
|
|
582
|
+
/* istanbul ignore next */
|
|
583
|
+
if (this.isAngular) {
|
|
584
|
+
textareaObj.localChange({ value: this.element.value });
|
|
585
|
+
this.preventChange = true;
|
|
586
|
+
}
|
|
587
|
+
if (this.isVue) {
|
|
588
|
+
this.preventChange = true;
|
|
589
|
+
}
|
|
590
|
+
this.trigger('input', eventArgs);
|
|
591
|
+
args.stopPropagation();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
private changeHandler(args: Event): void {
|
|
595
|
+
this.setProperties({value: this.element.value}, true);
|
|
596
|
+
if (this.previousValue !== this.value) {
|
|
597
|
+
this.raiseChangeEvent(args, true);
|
|
598
|
+
}
|
|
599
|
+
args.stopPropagation();
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
private raiseChangeEvent(event?: Event, interaction?: boolean): void {
|
|
603
|
+
const eventArgs: ChangedEventArgs = {
|
|
604
|
+
event: event,
|
|
605
|
+
value: this.value,
|
|
606
|
+
previousValue: this.previousValue,
|
|
607
|
+
container: this.textareaWrapper.container,
|
|
608
|
+
isInteraction: interaction ? interaction : false,
|
|
609
|
+
isInteracted: interaction ? interaction : false
|
|
610
|
+
};
|
|
611
|
+
this.preventChange = false;
|
|
612
|
+
this.trigger('change', eventArgs);
|
|
613
|
+
this.previousValue = this.value;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
private updateHTMLAttributesToWrapper(): void {
|
|
617
|
+
Input.updateHTMLAttributesToWrapper(this.htmlAttributes, this.textareaWrapper.container);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
private updateHTMLAttributesToElement(): void {
|
|
621
|
+
Input.updateHTMLAttributesToElement(this.htmlAttributes, this.element);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
private bindClearEvent(): void {
|
|
625
|
+
if (this.showClearButton) {
|
|
626
|
+
if (this.enabled) {
|
|
627
|
+
EventHandler.add(this.textareaWrapper.clearButton, 'mousedown touchstart', this.resetInputHandler, this);
|
|
628
|
+
} else {
|
|
629
|
+
EventHandler.remove(this.textareaWrapper.clearButton, 'mousedown touchstart', this.resetInputHandler);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
private resetInputHandler(event?: MouseEvent): void {
|
|
635
|
+
event.preventDefault();
|
|
636
|
+
if (!(this.textareaWrapper.clearButton.classList.contains(HIDE_CLEAR)) || this.textareaWrapper.container.classList.contains('e-static-clear')) {
|
|
637
|
+
Input.setValue('', this.element, this.floatLabelType, this.showClearButton);
|
|
638
|
+
this.setProperties({value: this.element.value}, true);
|
|
639
|
+
}
|
|
640
|
+
const eventArgs: InputEventArgs = {
|
|
641
|
+
event: event,
|
|
642
|
+
value: this.element.value,
|
|
643
|
+
previousValue: this.inputPreviousValue,
|
|
644
|
+
container: this.textareaWrapper.container
|
|
645
|
+
};
|
|
646
|
+
this.trigger('input', eventArgs);
|
|
647
|
+
this.inputPreviousValue = this.element.value;
|
|
648
|
+
this.raiseChangeEvent(event, true);
|
|
649
|
+
if (closest(this.element, 'form')) {
|
|
650
|
+
const element: Element = this.element;
|
|
651
|
+
const keyupEvent: KeyboardEvent = document.createEvent('KeyboardEvent');
|
|
652
|
+
keyupEvent.initEvent('keyup', false, true);
|
|
653
|
+
element.dispatchEvent(keyupEvent);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Adding the multiple attributes as key-value pair to the TextArea element.
|
|
659
|
+
*
|
|
660
|
+
* @param {string} attributes - Specifies the attributes to be add to TextArea element.
|
|
661
|
+
* @returns {void}
|
|
662
|
+
*/
|
|
663
|
+
public addAttributes(attributes: { [key: string]: string }): void {
|
|
664
|
+
for (const key of Object.keys(attributes)) {
|
|
665
|
+
if (key === 'disabled') {
|
|
666
|
+
this.setProperties({ enabled: false }, true);
|
|
667
|
+
Input.setEnabled(this.enabled, this.element, this.floatLabelType, this.textareaWrapper.container);
|
|
668
|
+
} else if (key === 'readonly') {
|
|
669
|
+
this.setProperties({ readonly: true }, true);
|
|
670
|
+
Input.setReadonly(this.readonly, this.element);
|
|
671
|
+
} else if (key === 'class') {
|
|
672
|
+
this.element.classList.add(attributes[`${key}`]);
|
|
673
|
+
} else if (key === 'placeholder') {
|
|
674
|
+
this.setProperties({ placeholder: attributes[`${key}`] }, true);
|
|
675
|
+
Input.setPlaceholder(this.placeholder, this.element);
|
|
676
|
+
} else {
|
|
677
|
+
this.element.setAttribute(key, attributes[`${key}`]);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Removing the multiple attributes as key-value pair to the TextArea element.
|
|
684
|
+
*
|
|
685
|
+
* @param { string[] } attributes - Specifies the attributes name to be removed from TextArea element.
|
|
686
|
+
* @returns {void}
|
|
687
|
+
*/
|
|
688
|
+
public removeAttributes(attributes: string[]): void {
|
|
689
|
+
for (const key of attributes) {
|
|
690
|
+
if (key === 'disabled') {
|
|
691
|
+
this.setProperties({ enabled: true }, true);
|
|
692
|
+
Input.setEnabled(this.enabled, this.element, this.floatLabelType, this.textareaWrapper.container);
|
|
693
|
+
} else if (key === 'readonly') {
|
|
694
|
+
this.setProperties({ readonly: false }, true);
|
|
695
|
+
Input.setReadonly(this.readonly, this.element);
|
|
696
|
+
} else if (key === 'placeholder') {
|
|
697
|
+
this.setProperties({ placeholder: null }, true);
|
|
698
|
+
Input.setPlaceholder(this.placeholder, this.element);
|
|
699
|
+
} else {
|
|
700
|
+
this.element.removeAttribute(key);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Sets the focus to widget for interaction.
|
|
707
|
+
*
|
|
708
|
+
* @returns {void}
|
|
709
|
+
*/
|
|
710
|
+
public focusIn(): void {
|
|
711
|
+
if (document.activeElement !== this.element && this.enabled) {
|
|
712
|
+
this.element.focus();
|
|
713
|
+
if (this.textareaWrapper.container.classList.contains('e-input-group')
|
|
714
|
+
|| this.textareaWrapper.container.classList.contains('e-outline')
|
|
715
|
+
|| this.textareaWrapper.container.classList.contains('e-filled')) {
|
|
716
|
+
addClass([this.textareaWrapper.container], [TEXTBOX_FOCUS]);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Remove the focus from widget, if the widget is in focus state.
|
|
723
|
+
*
|
|
724
|
+
* @returns {void}
|
|
725
|
+
*/
|
|
726
|
+
public focusOut(): void {
|
|
727
|
+
if (document.activeElement === this.element && this.enabled) {
|
|
728
|
+
this.element.blur();
|
|
729
|
+
if (this.textareaWrapper.container.classList.contains('e-input-group')
|
|
730
|
+
|| this.textareaWrapper.container.classList.contains('e-outline')
|
|
731
|
+
|| this.textareaWrapper.container.classList.contains('e-filled')) {
|
|
732
|
+
removeClass([this.textareaWrapper.container], [TEXTBOX_FOCUS]);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Sets up the width for the textarea wrapper.
|
|
739
|
+
*
|
|
740
|
+
* @returns {void}
|
|
741
|
+
*/
|
|
742
|
+
private setWrapperWidth(): void {
|
|
743
|
+
if (this.enabled && ((this.resizeMode !== 'None' && this.resizeMode !== 'Vertical') || (this.cols || this.element.getAttribute('cols')))) {
|
|
744
|
+
if (this.resizeMode !== 'None' && this.resizeMode !== 'Vertical' && !this.textareaWrapper.container.style.width.includes('%')) {
|
|
745
|
+
this.setElementWidth(this.textareaWrapper.container.style.width);
|
|
746
|
+
}
|
|
747
|
+
if (!this.textareaWrapper.container.style.width.includes('%')) {
|
|
748
|
+
this.textareaWrapper.container.classList.add(AUTO_WIDTH);
|
|
749
|
+
this.textareaWrapper.container.style.width = '';
|
|
750
|
+
}
|
|
751
|
+
if (this.textareaWrapper.container.style.width.includes('%')) {
|
|
752
|
+
EventHandler.add(this.element, 'mousemove', this.onMouseMove, this);
|
|
753
|
+
}
|
|
754
|
+
} else {
|
|
755
|
+
if (this.textareaWrapper.container.classList.contains(AUTO_WIDTH)) {
|
|
756
|
+
this.textareaWrapper.container.classList.remove(AUTO_WIDTH);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
private onMouseMove(): void {
|
|
762
|
+
if (this.textareaWrapper.container.style.width !== 'auto') {
|
|
763
|
+
const initialWidth: string = this.element.style.width;
|
|
764
|
+
setTimeout(() => {
|
|
765
|
+
const currentWidth: string = this.element.style.width;
|
|
766
|
+
if (initialWidth !== currentWidth) {
|
|
767
|
+
this.textareaWrapper.container.style.width = 'auto';
|
|
768
|
+
}
|
|
769
|
+
}, 5);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
private resetForm() : void {
|
|
774
|
+
if (this.isAngular) {
|
|
775
|
+
this.resetValue('');
|
|
776
|
+
} else {
|
|
777
|
+
this.resetValue(this.initialValue);
|
|
778
|
+
}
|
|
779
|
+
if (!isNullOrUndefined(this.textareaWrapper)) {
|
|
780
|
+
const label: HTMLElement = this.textareaWrapper.container.querySelector('.e-float-text');
|
|
781
|
+
if (!isNullOrUndefined(label) && this.floatLabelType !== 'Always') {
|
|
782
|
+
if ((isNullOrUndefined(this.initialValue) || this.initialValue === '')) {
|
|
783
|
+
label.classList.add('e-label-bottom');
|
|
784
|
+
label.classList.remove('e-label-top');
|
|
785
|
+
} else if (this.initialValue !== '') {
|
|
786
|
+
label.classList.add('e-label-top');
|
|
787
|
+
label.classList.remove('e-label-bottom');
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
private resetValue(value: string) : void {
|
|
793
|
+
const prevOnChange: boolean = this.isProtectedOnChange;
|
|
794
|
+
this.isProtectedOnChange = true;
|
|
795
|
+
this.value = value;
|
|
796
|
+
if (value == null && this.textareaWrapper.container.classList.contains('e-valid-input') && !(this.floatLabelType === 'Always' && this.textareaWrapper.container.classList.contains('e-outline'))) {
|
|
797
|
+
this.textareaWrapper.container.classList.remove('e-valid-input');
|
|
798
|
+
}
|
|
799
|
+
this.isProtectedOnChange = prevOnChange;
|
|
800
|
+
}
|
|
801
|
+
private setElementWidth(width: number | string): void {
|
|
802
|
+
if (typeof width === 'number') {
|
|
803
|
+
this.element.style.width = formatUnit(width);
|
|
804
|
+
} else if (typeof width === 'string') {
|
|
805
|
+
this.element.style.width = (width.match(/px|%|em/)) ? <string>(width) : <string>(formatUnit(width));
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
private getCurrentResizeClass(resizeMode: string): string {
|
|
810
|
+
return resizeMode === 'None' ? RESIZE_NONE : (resizeMode === 'Both' ? RESIZE_XY : resizeMode === 'Horizontal' ? RESIZE_X : RESIZE_Y );
|
|
811
|
+
}
|
|
812
|
+
}
|