@syncfusion/ej2-inputs 31.1.17 → 31.1.20

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.
Files changed (106) hide show
  1. package/dist/ej2-inputs.min.js +2 -2
  2. package/dist/ej2-inputs.umd.min.js +2 -2
  3. package/dist/ej2-inputs.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-inputs.es2015.js +4 -3
  5. package/dist/es6/ej2-inputs.es2015.js.map +1 -1
  6. package/dist/es6/ej2-inputs.es5.js +4 -3
  7. package/dist/es6/ej2-inputs.es5.js.map +1 -1
  8. package/dist/global/ej2-inputs.min.js +2 -2
  9. package/dist/global/ej2-inputs.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +10 -60
  12. package/src/color-picker/color-picker.js +4 -3
  13. package/styles/bootstrap4-lite.css +2 -2
  14. package/styles/bootstrap4.css +2 -2
  15. package/styles/bootstrap5-dark-lite.css +2 -2
  16. package/styles/bootstrap5-dark.css +2 -2
  17. package/styles/bootstrap5-lite.css +2 -2
  18. package/styles/bootstrap5.css +2 -2
  19. package/styles/input/_bootstrap4-definition.scss +1 -1
  20. package/styles/input/_bootstrap5-definition.scss +1 -1
  21. package/styles/input/bootstrap4.css +2 -2
  22. package/styles/input/bootstrap5-dark.css +2 -2
  23. package/styles/input/bootstrap5.css +2 -2
  24. package/dist/ts/color-picker/color-picker-model.d.ts +0 -186
  25. package/dist/ts/color-picker/color-picker.d.ts +0 -398
  26. package/dist/ts/color-picker/color-picker.ts +0 -2209
  27. package/dist/ts/color-picker/index.d.ts +0 -5
  28. package/dist/ts/color-picker/index.ts +0 -5
  29. package/dist/ts/common/index.d.ts +0 -4
  30. package/dist/ts/common/index.ts +0 -4
  31. package/dist/ts/common/signature-base.d.ts +0 -340
  32. package/dist/ts/common/signature-base.ts +0 -1170
  33. package/dist/ts/form-validator/form-validator-model.d.ts +0 -121
  34. package/dist/ts/form-validator/form-validator.d.ts +0 -312
  35. package/dist/ts/form-validator/form-validator.ts +0 -1068
  36. package/dist/ts/form-validator/index.d.ts +0 -5
  37. package/dist/ts/form-validator/index.ts +0 -5
  38. package/dist/ts/index.d.ts +0 -18
  39. package/dist/ts/index.ts +0 -18
  40. package/dist/ts/input/index.d.ts +0 -4
  41. package/dist/ts/input/index.ts +0 -4
  42. package/dist/ts/input/input.d.ts +0 -345
  43. package/dist/ts/input/input.ts +0 -1277
  44. package/dist/ts/maskedtextbox/base/index.d.ts +0 -4
  45. package/dist/ts/maskedtextbox/base/index.ts +0 -4
  46. package/dist/ts/maskedtextbox/base/mask-base.d.ts +0 -134
  47. package/dist/ts/maskedtextbox/base/mask-base.ts +0 -1207
  48. package/dist/ts/maskedtextbox/index.d.ts +0 -5
  49. package/dist/ts/maskedtextbox/index.ts +0 -5
  50. package/dist/ts/maskedtextbox/maskedtextbox/index.d.ts +0 -5
  51. package/dist/ts/maskedtextbox/maskedtextbox/index.ts +0 -5
  52. package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox-model.d.ts +0 -167
  53. package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.d.ts +0 -307
  54. package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.ts +0 -709
  55. package/dist/ts/numerictextbox/index.d.ts +0 -5
  56. package/dist/ts/numerictextbox/index.ts +0 -5
  57. package/dist/ts/numerictextbox/numerictextbox-model.d.ts +0 -228
  58. package/dist/ts/numerictextbox/numerictextbox.d.ts +0 -431
  59. package/dist/ts/numerictextbox/numerictextbox.ts +0 -1672
  60. package/dist/ts/otp-input/index.d.ts +0 -5
  61. package/dist/ts/otp-input/index.ts +0 -5
  62. package/dist/ts/otp-input/otp-input-model.d.ts +0 -165
  63. package/dist/ts/otp-input/otp-input.d.ts +0 -365
  64. package/dist/ts/otp-input/otp-input.ts +0 -924
  65. package/dist/ts/rating/index.d.ts +0 -5
  66. package/dist/ts/rating/index.ts +0 -5
  67. package/dist/ts/rating/rating-model.d.ts +0 -239
  68. package/dist/ts/rating/rating.d.ts +0 -416
  69. package/dist/ts/rating/rating.ts +0 -1101
  70. package/dist/ts/signature/index.d.ts +0 -5
  71. package/dist/ts/signature/index.ts +0 -5
  72. package/dist/ts/signature/signature-model.d.ts +0 -131
  73. package/dist/ts/signature/signature.d.ts +0 -167
  74. package/dist/ts/signature/signature.ts +0 -266
  75. package/dist/ts/slider/index.d.ts +0 -5
  76. package/dist/ts/slider/index.ts +0 -5
  77. package/dist/ts/slider/slider-model.d.ts +0 -401
  78. package/dist/ts/slider/slider.d.ts +0 -721
  79. package/dist/ts/slider/slider.ts +0 -3497
  80. package/dist/ts/smart-textarea/caret-helper.d.ts +0 -17
  81. package/dist/ts/smart-textarea/caret-helper.ts +0 -95
  82. package/dist/ts/smart-textarea/index.d.ts +0 -5
  83. package/dist/ts/smart-textarea/index.ts +0 -5
  84. package/dist/ts/smart-textarea/smart-textarea-model.d.ts +0 -44
  85. package/dist/ts/smart-textarea/smart-textarea.d.ts +0 -80
  86. package/dist/ts/smart-textarea/smart-textarea.ts +0 -518
  87. package/dist/ts/speech-to-text/index.d.ts +0 -5
  88. package/dist/ts/speech-to-text/index.ts +0 -5
  89. package/dist/ts/speech-to-text/speech-to-text-model.d.ts +0 -270
  90. package/dist/ts/speech-to-text/speech-to-text.d.ts +0 -487
  91. package/dist/ts/speech-to-text/speech-to-text.ts +0 -1008
  92. package/dist/ts/textarea/index.d.ts +0 -5
  93. package/dist/ts/textarea/index.ts +0 -5
  94. package/dist/ts/textarea/textarea-model.d.ts +0 -161
  95. package/dist/ts/textarea/textarea.d.ts +0 -237
  96. package/dist/ts/textarea/textarea.ts +0 -812
  97. package/dist/ts/textbox/index.d.ts +0 -5
  98. package/dist/ts/textbox/index.ts +0 -5
  99. package/dist/ts/textbox/textbox-model.d.ts +0 -155
  100. package/dist/ts/textbox/textbox.d.ts +0 -288
  101. package/dist/ts/textbox/textbox.ts +0 -872
  102. package/dist/ts/uploader/index.d.ts +0 -5
  103. package/dist/ts/uploader/index.ts +0 -5
  104. package/dist/ts/uploader/uploader-model.d.ts +0 -555
  105. package/dist/ts/uploader/uploader.d.ts +0 -1216
  106. package/dist/ts/uploader/uploader.ts +0 -4391
@@ -1,1672 +0,0 @@
1
- import { Component, EventHandler, Property, Event, Browser, L10n, EmitType, getUniqueID } from '@syncfusion/ej2-base';
2
- import { NotifyPropertyChanges, INotifyPropertyChanged, BaseEventArgs } from '@syncfusion/ej2-base';
3
- import { attributes, addClass, removeClass, detach, closest } from '@syncfusion/ej2-base';
4
- import { isNullOrUndefined, getValue, formatUnit, setValue, merge } from '@syncfusion/ej2-base';
5
- import { Internationalization, NumberFormatOptions, getNumericObject } from '@syncfusion/ej2-base';
6
- import { NumericTextBoxModel } from './numerictextbox-model';
7
- import { Input, InputObject, FloatLabelType } from '../input/input';
8
-
9
-
10
- const ROOT: string = 'e-control-wrapper e-numeric';
11
- const SPINICON: string = 'e-input-group-icon';
12
- const SPINUP: string = 'e-spin-up';
13
- const SPINDOWN: string = 'e-spin-down';
14
- const ERROR: string = 'e-error';
15
- const INCREMENT: string = 'increment';
16
- const DECREMENT: string = 'decrement';
17
- const INTREGEXP: RegExp = new RegExp('^(-)?(\\d*)$');
18
- const DECIMALSEPARATOR: string = '.';
19
- const COMPONENT: string = 'e-numerictextbox';
20
- const CONTROL: string = 'e-control';
21
- const NUMERIC_FOCUS: string = 'e-input-focus';
22
- const HIDDENELEMENT: string = 'e-numeric-hidden';
23
- const wrapperAttributes: string[] = ['title', 'style', 'class'];
24
- let selectionTimeOut: number = 0;
25
-
26
- /**
27
- * Represents the NumericTextBox component that allows the user to enter only numeric values.
28
- * ```html
29
- * <input type='text' id="numeric"/>
30
- * ```
31
- * ```typescript
32
- * <script>
33
- * var numericObj = new NumericTextBox({ value: 10 });
34
- * numericObj.appendTo("#numeric");
35
- * </script>
36
- * ```
37
- */
38
-
39
- @NotifyPropertyChanges
40
- export class NumericTextBox extends Component<HTMLInputElement> implements INotifyPropertyChanged {
41
-
42
- /* Internal variables */
43
- private container: HTMLElement;
44
- private inputWrapper: InputObject;
45
- private cloneElement: HTMLElement;
46
- private hiddenInput: HTMLInputElement;
47
- private spinUp: HTMLElement;
48
- private spinDown: HTMLElement;
49
- private formEle: HTMLElement;
50
- private inputEleValue: number;
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
- private timeOut: any;
53
- private prevValue: number;
54
- private isValidState: boolean;
55
- private isFocused: boolean;
56
- private isPrevFocused: boolean;
57
- private instance: Internationalization;
58
- private cultureInfo: NumberFormatOptions;
59
- private inputStyle: string;
60
- private inputName: string;
61
- private decimalSeparator: string;
62
- private angularTagName: string;
63
- private intRegExp: RegExp;
64
- private l10n: L10n;
65
- private isCalled: boolean;
66
- private prevVal: string;
67
- private nextEle: string;
68
- private cursorPosChanged: boolean;
69
- private changeEventArgs: ChangeEventArgs;
70
- private focusEventArgs: NumericFocusEventArgs;
71
- private blurEventArgs: NumericBlurEventArgs;
72
- private numericOptions: NumericTextBoxModel;
73
- private isInteract: boolean;
74
- private serverDecimalSeparator: string;
75
- private preventChange: boolean = false;
76
- private elementPrevValue: string;
77
- private isDynamicChange: boolean = false;
78
- private inputValue: number;
79
- private clearButton: HTMLElement;
80
-
81
- /*NumericTextBox Options */
82
-
83
- /**
84
- * Gets or Sets the CSS classes to root element of the NumericTextBox which helps to customize the
85
- * complete UI styles for the NumericTextBox component.
86
- *
87
- * @default null
88
- */
89
- @Property('')
90
- public cssClass: string;
91
-
92
- /**
93
- * Sets the value of the NumericTextBox.
94
- *
95
- * @default null
96
- * @aspType object
97
- * @isGenericType true
98
- */
99
- @Property(null)
100
- public value: number;
101
-
102
- /**
103
- * Specifies a minimum value that is allowed a user can enter.
104
- * For more information on min, refer to
105
- * [min](../../numerictextbox/getting-started/#range-validation).
106
- *
107
- * @default null
108
- * @aspType object
109
- * @isGenericType true
110
- * @deprecated
111
- */
112
- @Property(-(Number.MAX_VALUE))
113
- public min: number;
114
-
115
- /**
116
- * Specifies a maximum value that is allowed a user can enter.
117
- * For more information on max, refer to
118
- * [max](../../numerictextbox/getting-started/#range-validation).
119
- *
120
- * @default null
121
- * @aspType object
122
- * @isGenericType true
123
- * @deprecated
124
- */
125
- @Property(Number.MAX_VALUE)
126
- public max: number;
127
-
128
- /**
129
- * Specifies the incremental or decremental step size for the NumericTextBox.
130
- * For more information on step, refer to
131
- * [step](../../numerictextbox/getting-started/#range-validation).
132
- *
133
- * @default 1
134
- * @isGenericType true
135
- */
136
- @Property(1)
137
- public step: number;
138
-
139
- /**
140
- * Specifies the width of the NumericTextBox.
141
- *
142
- * @default null
143
- */
144
- @Property(null)
145
- public width: number | string;
146
-
147
- /**
148
- * Gets or sets the string shown as a hint/placeholder when the NumericTextBox is empty.
149
- * It acts as a label and floats above the NumericTextBox based on the
150
- * <b><a href="#floatlabeltype" target="_blank">floatLabelType.</a></b>
151
- *
152
- * @default null
153
- */
154
- @Property(null)
155
- public placeholder: string;
156
-
157
- /**
158
- * You can add the additional html attributes such as disabled, value etc., to the element.
159
- * If you configured both property and equivalent html attribute then the component considers the property value.
160
- * {% codeBlock src='numerictextbox/htmlAttributes/index.md' %}{% endcodeBlock %}
161
- *
162
- * @default {}
163
- */
164
- @Property({})
165
- public htmlAttributes: { [key: string]: string };
166
-
167
- /**
168
- * Specifies whether the up and down spin buttons should be displayed in NumericTextBox.
169
- *
170
- * @default true
171
- */
172
- @Property(true)
173
- public showSpinButton: boolean;
174
-
175
- /**
176
- * Sets a value that enables or disables the readonly state on the NumericTextBox. If it is true,
177
- * NumericTextBox will not allow your input.
178
- *
179
- * @default false
180
- */
181
- @Property(false)
182
- public readonly: boolean;
183
-
184
- /**
185
- * Sets a value that enables or disables the NumericTextBox control.
186
- *
187
- * @default true
188
- */
189
- @Property(true)
190
- public enabled: boolean;
191
-
192
- /**
193
- * Specifies whether to show or hide the clear icon.
194
- *
195
- * @default false
196
- */
197
- @Property(false)
198
- public showClearButton: boolean;
199
-
200
- /**
201
- * Enable or disable persisting NumericTextBox state between page reloads. If enabled, the `value` state will be persisted.
202
- *
203
- * @default false
204
- */
205
- @Property(false)
206
- public enablePersistence: boolean;
207
-
208
- /**
209
- * Specifies the number format that indicates the display format for the value of the NumericTextBox.
210
- * For more information on formats, refer to
211
- * [formats](../../numerictextbox/formats/#standard-formats).
212
- *
213
- * @default 'n2'
214
- */
215
- @Property('n2')
216
- public format: string;
217
-
218
- /**
219
- * Specifies the number precision applied to the textbox value when the NumericTextBox is focused.
220
- * For more information on decimals, refer to
221
- * [decimals](../../numerictextbox/formats/#precision-of-numbers).
222
- *
223
- * @default null
224
- */
225
- @Property(null)
226
- public decimals: number;
227
-
228
- /**
229
- * Specifies the currency code to use in currency formatting.
230
- * Possible values are the ISO 4217 currency codes, such as 'USD' for the US dollar,'EUR' for the euro.
231
- *
232
- * @default null
233
- */
234
- @Property(null)
235
- public currency: string;
236
-
237
- /**
238
- * Specifies the currency code to use in currency formatting.
239
- * Possible values are the ISO 4217 currency codes, such as 'USD' for the US dollar,'EUR' for the euro.
240
- *
241
- * @default null
242
- * @private
243
- */
244
- @Property(null)
245
- private currencyCode: string;
246
-
247
- /**
248
- * Specifies a value that indicates whether the NumericTextBox control allows the value for the specified range.
249
- * If it is true, the input value will be restricted between the min and max range.
250
- * The typed value gets modified to fit the range on focused out state.
251
- * Else, it allows any value even out of range value,
252
- * At that time of wrong value entered, the error class will be added to the component to highlight the error.
253
- * {% codeBlock src='numerictextbox/strictMode/index.md' %}{% endcodeBlock %}
254
- *
255
- * @default true
256
- */
257
- @Property(true)
258
- public strictMode: boolean;
259
-
260
- /**
261
- * Specifies whether the decimals length should be restricted during typing.
262
- *
263
- * @default false
264
- */
265
- @Property(false)
266
- public validateDecimalOnType: boolean;
267
-
268
- /**
269
- * The <b><a href="#placeholder" target="_blank">placeholder</a></b> acts as a label
270
- * and floats above the NumericTextBox based on the below values.
271
- * Possible values are:
272
- * * `Never` - Never floats the label in the NumericTextBox when the placeholder is available.
273
- * * `Always` - The floating label always floats above the NumericTextBox.
274
- * * `Auto` - The floating label floats above the NumericTextBox after focusing it or when enters the value in it.
275
- *
276
- * @default Never
277
- */
278
- @Property('Never')
279
- public floatLabelType: FloatLabelType;
280
-
281
- /**
282
- * Triggers when the NumericTextBox component is created.
283
- *
284
- * @event created
285
- */
286
- @Event()
287
- public created: EmitType<Object>;
288
-
289
- /**
290
- * Triggers when the NumericTextBox component is destroyed.
291
- *
292
- * @event destroyed
293
- */
294
- @Event()
295
- public destroyed: EmitType<Object>;
296
-
297
- /**
298
- * Triggers when the value of the NumericTextBox changes.
299
- * The change event of the NumericTextBox component will be triggered in the following scenarios:
300
- * * Changing the previous value using keyboard interaction and then focusing out of the component.
301
- * * Focusing on the component and scrolling within the input.
302
- * * Changing the value using the spin buttons.
303
- * * Programmatically changing the value using the value property.
304
- *
305
- * @event change
306
- */
307
- @Event()
308
- public change: EmitType<ChangeEventArgs>;
309
-
310
- /**
311
- * Triggers when the NumericTextBox got focus in.
312
- *
313
- * @event focus
314
- */
315
- @Event()
316
- public focus: EmitType<NumericFocusEventArgs>;
317
-
318
- /**
319
- * Triggers when the NumericTextBox got focus out.
320
- *
321
- * @event blur
322
- */
323
- @Event()
324
- public blur: EmitType<NumericBlurEventArgs>;
325
-
326
- /**
327
- *
328
- * @param {NumericTextBoxModel} options - Specifies the NumericTextBox model.
329
- * @param {string | HTMLInputElement} element - Specifies the element to render as component.
330
- * @private
331
- */
332
- public constructor(options?: NumericTextBoxModel, element?: string | HTMLInputElement) {
333
- super(options, <HTMLInputElement | string>element);
334
- this.numericOptions = options;
335
- }
336
-
337
- protected preRender(): void {
338
- this.isPrevFocused = false;
339
- this.decimalSeparator = '.';
340
- // eslint-disable-next-line no-useless-escape
341
- this.intRegExp = new RegExp('/^(-)?(\d*)$/');
342
- this.isCalled = false;
343
- const ejInstance: Object = getValue('ej2_instances', this.element);
344
- this.cloneElement = <HTMLElement>this.element.cloneNode(true);
345
- removeClass([this.cloneElement], [CONTROL, COMPONENT, 'e-lib']);
346
- this.angularTagName = null;
347
- this.formEle = <HTMLFormElement>closest(this.element, 'form');
348
- if (this.element.tagName === 'EJS-NUMERICTEXTBOX') {
349
- this.angularTagName = this.element.tagName;
350
- const input: HTMLElement = this.createElement('input');
351
- let index: number = 0;
352
- for (index; index < this.element.attributes.length; index++) {
353
- const attributeName: string = this.element.attributes[index as number].nodeName;
354
- if (attributeName !== 'id' && attributeName !== 'class') {
355
- input.setAttribute(this.element.attributes[index as number].nodeName,
356
- this.element.attributes[index as number].nodeValue);
357
- input.innerHTML = this.element.innerHTML;
358
- }
359
- else if (attributeName === 'class') {
360
- input.setAttribute(attributeName, this.element.className.split(' ').filter((item: string) => item.indexOf('ng-') !== 0).join(' '));
361
- }
362
- }
363
- if (this.element.hasAttribute('name')) {
364
- this.element.removeAttribute('name');
365
- }
366
- this.element.classList.remove('e-control', 'e-numerictextbox');
367
- this.element.appendChild(input);
368
- this.element = <HTMLInputElement>input;
369
- setValue('ej2_instances', ejInstance, this.element);
370
-
371
- }
372
- attributes(this.element, { 'role': 'spinbutton', 'tabindex': '0', 'autocomplete': 'off'});
373
- const localeText: object = {
374
- incrementTitle: 'Increment value', decrementTitle: 'Decrement value', placeholder: this.placeholder
375
- };
376
- this.l10n = new L10n('numerictextbox', localeText, this.locale);
377
- if (this.l10n.getConstant('placeholder') !== '') {
378
- this.setProperties({ placeholder: this.placeholder || this.l10n.getConstant('placeholder') }, true);
379
- }
380
- if (!this.element.hasAttribute('id')) {
381
- this.element.setAttribute('id', getUniqueID('numerictextbox'));
382
- }
383
- this.isValidState = true;
384
- this.inputStyle = null;
385
- this.inputName = null;
386
- this.cultureInfo = {};
387
- this.initCultureInfo();
388
- this.initCultureFunc();
389
- this.prevValue = this.value;
390
- this.updateHTMLAttrToElement();
391
- this.checkAttributes(false);
392
- if (this.formEle) {
393
- this.inputEleValue = this.value;
394
- }
395
- this.validateMinMax();
396
- this.validateStep();
397
- if (this.placeholder === null) {
398
- this.updatePlaceholder();
399
- }
400
- }
401
-
402
- /**
403
- * To Initialize the control rendering
404
- *
405
- * @returns {void}
406
- * @private
407
- */
408
- public render(): void {
409
- if (this.element.tagName.toLowerCase() === 'input') {
410
- this.createWrapper();
411
- if (this.showSpinButton) {
412
- this.spinBtnCreation();
413
- }
414
- this.setElementWidth(this.width);
415
- if (!this.container.classList.contains('e-input-group')) {
416
- this.container.classList.add('e-input-group');
417
- }
418
- this.changeValue(this.value === null || isNaN(this.value) ?
419
- null : this.strictMode ? this.trimValue(this.value) : this.value);
420
- this.wireEvents();
421
- if (this.value !== null && !isNaN(this.value)) {
422
- if (this.decimals) {
423
- this.setProperties({ value: this.roundNumber(this.value, this.decimals) }, true);
424
- }
425
- }
426
- if (this.element.getAttribute('value') || this.value) {
427
- this.element.setAttribute('value', this.element.value);
428
- this.hiddenInput.setAttribute('value', this.hiddenInput.value);
429
- }
430
- this.elementPrevValue = this.element.value;
431
- if (this.element.hasAttribute('data-val')) {
432
- this.element.setAttribute('data-val', 'false');
433
- }
434
- if (!this.element.hasAttribute('aria-labelledby') && !this.element.hasAttribute('placeholder') && !this.element.hasAttribute('aria-label')) {
435
- this.element.setAttribute('aria-label', 'numerictextbox');
436
- }
437
- if (!isNullOrUndefined(closest(this.element, 'fieldset') as HTMLFieldSetElement) && (closest(this.element, 'fieldset') as HTMLFieldSetElement).disabled) {
438
- this.enabled = false;
439
- }
440
- this.renderComplete();
441
- }
442
- }
443
-
444
- private checkAttributes(isDynamic: boolean): void {
445
- const attributes: string[] = isDynamic ? isNullOrUndefined(this.htmlAttributes) ? [] : Object.keys(this.htmlAttributes) :
446
- ['value', 'min', 'max', 'step', 'disabled', 'readonly', 'style', 'name', 'placeholder'];
447
- for (const prop of attributes) {
448
- if (!isNullOrUndefined(this.element.getAttribute(prop))) {
449
- switch (prop) {
450
- case 'disabled':
451
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['enabled'] === undefined)) || isDynamic) {
452
- const enabled: boolean = this.element.getAttribute(prop) === 'disabled' || this.element.getAttribute(prop) === ''
453
- || this.element.getAttribute(prop) === 'true' ? false : true;
454
- this.setProperties({ enabled: enabled }, !isDynamic);
455
- }
456
- break;
457
- case 'readonly':
458
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['readonly'] === undefined)) || isDynamic) {
459
- const readonly: boolean = this.element.getAttribute(prop) === 'readonly' || this.element.getAttribute(prop) === ''
460
- || this.element.getAttribute(prop) === 'true' ? true : false;
461
- this.setProperties({ readonly: readonly }, !isDynamic);
462
- }
463
- break;
464
- case 'placeholder':
465
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['placeholder'] === undefined)) || isDynamic) {
466
- this.setProperties({placeholder: this.element.placeholder}, !isDynamic);
467
- }
468
- break;
469
- case 'value':
470
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['value'] === undefined)) || isDynamic){
471
- const setNumber: number = this.instance.getNumberParser({ format: 'n' })(this.element.getAttribute(prop));
472
- this.setProperties(setValue(prop, setNumber, {}), !isDynamic);
473
- }
474
- break;
475
- case 'min':
476
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['min'] === undefined)) || isDynamic) {
477
- const minValue: number = this.instance.getNumberParser({ format: 'n' })(this.element.getAttribute(prop));
478
- if (minValue !== null && !isNaN(minValue)) {
479
- this.setProperties(setValue(prop, minValue, {}), !isDynamic);
480
- }
481
- }
482
- break;
483
- case 'max':
484
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['max'] === undefined)) || isDynamic) {
485
- const maxValue: number = this.instance.getNumberParser({ format: 'n' })(this.element.getAttribute(prop));
486
- if (maxValue !== null && !isNaN(maxValue)) {
487
- this.setProperties(setValue(prop, maxValue, {}), !isDynamic);
488
- }
489
- }
490
- break;
491
- case 'step':
492
- if (( isNullOrUndefined(this.numericOptions) || (this.numericOptions['step'] === undefined)) || isDynamic) {
493
- const stepValue: number = this.instance.getNumberParser({ format: 'n' })(this.element.getAttribute(prop));
494
- if (stepValue !== null && !isNaN(stepValue)) {
495
- this.setProperties(setValue(prop, stepValue, {}), !isDynamic);
496
- }
497
- }
498
- break;
499
- case 'style':
500
- this.inputStyle = this.element.getAttribute(prop);
501
- break;
502
- case 'name':
503
- this.inputName = this.element.getAttribute(prop);
504
- break;
505
- default: {
506
- const value: number = this.instance.getNumberParser({ format: 'n' })(this.element.getAttribute(prop));
507
- if ((value !== null && !isNaN(value)) || (prop === 'value')) {
508
- this.setProperties(setValue(prop, value, {}), true);
509
- }
510
- }
511
- break;
512
- }
513
- }
514
- }
515
- }
516
-
517
- private updatePlaceholder(): void {
518
- this.setProperties({ placeholder: this.l10n.getConstant('placeholder') }, true);
519
- }
520
-
521
- private initCultureFunc(): void {
522
- this.instance = new Internationalization(this.locale);
523
- }
524
-
525
- private initCultureInfo(): void {
526
- this.cultureInfo.format = this.format;
527
- if (getValue('currency', this) !== null) {
528
- setValue('currency', this.currency, this.cultureInfo);
529
- this.setProperties({ currencyCode: this.currency }, true);
530
- }
531
- }
532
-
533
- /* Wrapper creation */
534
- private createWrapper(): void {
535
- let updatedCssClassValue: string = this.cssClass;
536
- if (!isNullOrUndefined(this.cssClass) && this.cssClass !== '') {
537
- updatedCssClassValue = this.getNumericValidClassList(this.cssClass);
538
- }
539
- const inputObj: InputObject = Input.createInput(
540
- {
541
- element: this.element,
542
- floatLabelType: this.floatLabelType,
543
- properties: {
544
- readonly: this.readonly,
545
- placeholder: this.placeholder,
546
- cssClass: updatedCssClassValue,
547
- enableRtl: this.enableRtl,
548
- showClearButton: this.showClearButton,
549
- enabled: this.enabled
550
- }
551
- },
552
- this.createElement
553
- );
554
- this.inputWrapper = inputObj;
555
- this.container = inputObj.container;
556
- this.container.setAttribute('class', ROOT + ' ' + this.container.getAttribute('class'));
557
- this.updateHTMLAttrToWrapper();
558
- if (this.readonly) {
559
- attributes(this.element, { 'aria-readonly': 'true' });
560
- }
561
- this.hiddenInput = <HTMLInputElement>(this.createElement('input', { attrs: { type: 'text',
562
- 'data-validateHidden': 'true', 'aria-label': 'hidden', 'class': HIDDENELEMENT } }));
563
- this.inputName = this.inputName !== null ? this.inputName : this.element.id;
564
- this.element.removeAttribute('name');
565
- if (this.isAngular && this.angularTagName === 'EJS-NUMERICTEXTBOX' && this.cloneElement.id.length > 0) {
566
- attributes(this.hiddenInput, { 'name': this.cloneElement.id });
567
- } else {
568
- attributes(this.hiddenInput, { 'name': this.inputName });
569
- }
570
- this.container.insertBefore(this.hiddenInput, this.container.childNodes[1]);
571
- this.updateDataAttribute(false);
572
- if (this.inputStyle !== null) {
573
- attributes(this.container, { 'style': this.inputStyle });
574
- }
575
- }
576
- private updateDataAttribute(isDynamic: boolean) : void {
577
- let attr: { [key: string]: string } = {};
578
- if (!isDynamic) {
579
- for (let a: number = 0; a < this.element.attributes.length; a++) {
580
- attr[this.element.attributes[a as number].name] = this.element.getAttribute(this.element.attributes[a as number].name);
581
- }
582
- } else {
583
- attr = this.htmlAttributes;
584
- }
585
- for (const key of Object.keys(attr)) {
586
- if (key.indexOf('data') === 0 ) {
587
- this.hiddenInput.setAttribute(key, attr[`${key}`]);
588
- }
589
- }
590
- }
591
- private updateHTMLAttrToElement(): void {
592
- if ( !isNullOrUndefined(this.htmlAttributes)) {
593
- for (const pro of Object.keys(this.htmlAttributes)) {
594
- if (wrapperAttributes.indexOf(pro) < 0 ) {
595
- this.element.setAttribute(pro, this.htmlAttributes[`${pro}`]);
596
- }
597
- }
598
- }
599
- }
600
- private updateCssClass(newClass : string, oldClass : string) : void {
601
- Input.setCssClass(this.getNumericValidClassList(newClass), [this.container], this.getNumericValidClassList(oldClass));
602
- }
603
- private getNumericValidClassList(numericClassName: string): string {
604
- let result: string = numericClassName;
605
- if (!isNullOrUndefined(numericClassName) && numericClassName !== '') {
606
- result = (numericClassName.replace(/\s+/g, ' ')).trim();
607
- }
608
- return result;
609
- }
610
- private updateHTMLAttrToWrapper(): void {
611
- if ( !isNullOrUndefined(this.htmlAttributes)) {
612
- for (const pro of Object.keys(this.htmlAttributes)) {
613
- if (wrapperAttributes.indexOf(pro) > -1 ) {
614
- if (pro === 'class') {
615
- const updatedClassValue : string = this.getNumericValidClassList(this.htmlAttributes[`${pro}`]);
616
- if (updatedClassValue !== '') {
617
- addClass([this.container], updatedClassValue.split(' '));
618
- }
619
- } else if (pro === 'style') {
620
- let numericStyle: string = this.container.getAttribute(pro);
621
- numericStyle = !isNullOrUndefined(numericStyle) ? (numericStyle + this.htmlAttributes[`${pro}`]) :
622
- this.htmlAttributes[`${pro}`];
623
- this.container.setAttribute(pro, numericStyle);
624
- } else {
625
- this.container.setAttribute(pro, this.htmlAttributes[`${pro}`]);
626
- }
627
- }
628
- }
629
- }
630
- }
631
-
632
- private setElementWidth(width: number | string): void {
633
- if (!isNullOrUndefined(width)) {
634
- if (typeof width === 'number') {
635
- this.container.style.width = formatUnit(width);
636
- } else if (typeof width === 'string') {
637
- this.container.style.width = (width.match(/px|%|em/)) ? <string>(width) : <string>(formatUnit(width));
638
- }
639
- }
640
- }
641
-
642
- /* Spinner creation */
643
- private spinBtnCreation(): void {
644
- this.spinDown = Input.appendSpan(SPINICON + ' ' + SPINDOWN, this.container, this.createElement);
645
- attributes(this.spinDown, {
646
- 'title': this.l10n.getConstant('decrementTitle')
647
- });
648
- this.spinUp = Input.appendSpan(SPINICON + ' ' + SPINUP, this.container, this.createElement);
649
- attributes(this.spinUp, {
650
- 'title': this.l10n.getConstant('incrementTitle')
651
- });
652
- this.wireSpinBtnEvents();
653
- }
654
-
655
- private validateMinMax(): void {
656
- if (!(typeof (this.min) === 'number' && !isNaN(this.min))) {
657
- this.setProperties({ min: -(Number.MAX_VALUE) }, true);
658
- }
659
- if (!(typeof (this.max) === 'number' && !isNaN(this.max))) {
660
- this.setProperties({ max: Number.MAX_VALUE }, true);
661
- }
662
- if (this.decimals !== null) {
663
- if (this.min !== -(Number.MAX_VALUE)) {
664
- this.setProperties(
665
- { min: this.instance.getNumberParser({ format: 'n' })(this.formattedValue(this.decimals, this.min)) }, true);
666
- }
667
- if (this.max !== (Number.MAX_VALUE)) {
668
- this.setProperties(
669
- { max: this.instance.getNumberParser({ format: 'n' })(this.formattedValue(this.decimals, this.max)) }, true);
670
- }
671
- }
672
- this.setProperties({ min: this.min > this.max ? this.max : this.min }, true);
673
- if (this.min !== -(Number.MAX_VALUE)){
674
- attributes(this.element, { 'aria-valuemin': this.min.toString()});
675
- }
676
- if (this.max !== (Number.MAX_VALUE)) {
677
- attributes(this.element, { 'aria-valuemax': this.max.toString() });
678
- }
679
- }
680
-
681
- private formattedValue(decimals: number, value: number): string {
682
- return this.instance.getNumberFormat({
683
- maximumFractionDigits: decimals,
684
- minimumFractionDigits: decimals, useGrouping: false
685
- })(value);
686
- }
687
-
688
- private validateStep(): void {
689
- if (this.decimals !== null) {
690
- this.setProperties({ step: this.instance.getNumberParser({ format: 'n' })(this.formattedValue(this.decimals, this.step)) }, true);
691
- }
692
- }
693
-
694
- private action(operation: string, event: Event): void {
695
- this.isInteract = true;
696
- const value: number = this.isFocused ? this.instance.getNumberParser({ format: 'n' })(this.element.value) : this.value;
697
- this.changeValue(this.performAction(value, this.step, operation));
698
- this.raiseChangeEvent(event);
699
- }
700
-
701
- private checkErrorClass(): void {
702
- if (this.isValidState) {
703
- removeClass([this.container], ERROR);
704
- } else {
705
- addClass([this.container], ERROR);
706
- }
707
- attributes(this.element, { 'aria-invalid': this.isValidState ? 'false' : 'true' });
708
- }
709
-
710
- private bindClearEvent(): void {
711
- if (this.showClearButton) {
712
- EventHandler.add(this.inputWrapper.clearButton, 'mousedown touchstart', this.resetHandler, this);
713
- }
714
- }
715
- protected resetHandler(e?: MouseEvent): void {
716
- e.preventDefault();
717
- if (!(this.inputWrapper.clearButton.classList.contains('e-clear-icon-hide')) || this.inputWrapper.container.classList.contains('e-static-clear')) {
718
- this.clear(e);
719
- }
720
- this.isInteract = true;
721
- this.raiseChangeEvent(e);
722
- }
723
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
724
- private clear(event: MouseEvent): void {
725
- this.setProperties({ value: null }, true);
726
- this.setElementValue('');
727
- this.hiddenInput.value = '';
728
- const formElement: Element = closest(this.element, 'form');
729
- if (formElement) {
730
- const element: Element = this.element.nextElementSibling;
731
- const keyupEvent: KeyboardEvent = document.createEvent('KeyboardEvent');
732
- keyupEvent.initEvent('keyup', false, true);
733
- element.dispatchEvent(keyupEvent);
734
- }
735
- }
736
-
737
- protected resetFormHandler(): void {
738
- if (this.element.tagName === 'EJS-NUMERICTEXTBOX') {
739
- this.updateValue(null);
740
- } else {
741
- this.updateValue(this.inputEleValue);
742
- }
743
- }
744
-
745
- private setSpinButton(): void {
746
- if (!isNullOrUndefined(this.spinDown)) {
747
- attributes(this.spinDown, {
748
- 'title': this.l10n.getConstant('decrementTitle'),
749
- 'aria-label': this.l10n.getConstant('decrementTitle')
750
- });
751
- }
752
- if (!isNullOrUndefined(this.spinUp)) {
753
- attributes(this.spinUp, {
754
- 'title': this.l10n.getConstant('incrementTitle'),
755
- 'aria-label': this.l10n.getConstant('incrementTitle')
756
- });
757
- }
758
- }
759
-
760
- private wireEvents(): void {
761
- EventHandler.add(this.element, 'focus', this.focusHandler, this);
762
- EventHandler.add(this.element, 'blur', this.focusOutHandler, this);
763
- EventHandler.add(this.element, 'keydown', this.keyDownHandler, this);
764
- EventHandler.add(this.element, 'keyup', this.keyUpHandler, this);
765
- EventHandler.add(this.element, 'input', this.inputHandler, this);
766
- EventHandler.add(this.element, 'keypress', this.keyPressHandler, this);
767
- EventHandler.add(this.element, 'change', this.changeHandler, this);
768
- EventHandler.add(this.element, 'paste', this.pasteHandler, this);
769
- if (this.enabled) {
770
- this.bindClearEvent();
771
- if (this.formEle) {
772
- EventHandler.add(this.formEle, 'reset', this.resetFormHandler, this);
773
- }
774
- }
775
- }
776
-
777
- private wireSpinBtnEvents(): void {
778
- /* bind spin button events */
779
- EventHandler.add(this.spinUp, Browser.touchStartEvent, this.mouseDownOnSpinner, this);
780
- EventHandler.add(this.spinDown, Browser.touchStartEvent, this.mouseDownOnSpinner, this);
781
- EventHandler.add(this.spinUp, Browser.touchEndEvent, this.mouseUpOnSpinner, this);
782
- EventHandler.add(this.spinDown, Browser.touchEndEvent, this.mouseUpOnSpinner, this);
783
- EventHandler.add(this.spinUp, Browser.touchMoveEvent, this.touchMoveOnSpinner, this);
784
- EventHandler.add(this.spinDown, Browser.touchMoveEvent, this.touchMoveOnSpinner, this);
785
- }
786
-
787
- private unwireEvents(): void {
788
- EventHandler.remove(this.element, 'focus', this.focusHandler);
789
- EventHandler.remove(this.element, 'blur', this.focusOutHandler);
790
- EventHandler.remove(this.element, 'keyup', this.keyUpHandler);
791
- EventHandler.remove(this.element, 'input', this.inputHandler);
792
- EventHandler.remove(this.element, 'keydown', this.keyDownHandler);
793
- EventHandler.remove(this.element, 'keypress', this.keyPressHandler);
794
- EventHandler.remove(this.element, 'change', this.changeHandler);
795
- EventHandler.remove(this.element, 'paste', this.pasteHandler);
796
- if (this.formEle) {
797
- EventHandler.remove(this.formEle, 'reset', this.resetFormHandler);
798
- }
799
- }
800
-
801
- private unwireSpinBtnEvents(): void {
802
- /* unbind spin button events */
803
- EventHandler.remove(this.spinUp, Browser.touchStartEvent, this.mouseDownOnSpinner);
804
- EventHandler.remove(this.spinDown, Browser.touchStartEvent, this.mouseDownOnSpinner);
805
- EventHandler.remove(this.spinUp, Browser.touchEndEvent, this.mouseUpOnSpinner);
806
- EventHandler.remove(this.spinDown, Browser.touchEndEvent, this.mouseUpOnSpinner);
807
- EventHandler.remove(this.spinUp, Browser.touchMoveEvent, this.touchMoveOnSpinner);
808
- EventHandler.remove(this.spinDown, Browser.touchMoveEvent, this.touchMoveOnSpinner);
809
- }
810
-
811
- private changeHandler(event: Event): void {
812
- event.stopPropagation();
813
- if (!this.element.value.length) {
814
- this.setProperties({ value: null }, true);
815
- }
816
- const parsedInput: number = this.instance.getNumberParser({ format: 'n' })(this.element.value);
817
- this.updateValue(parsedInput, event);
818
- }
819
-
820
- private raiseChangeEvent(event?: Event): void {
821
- this.inputValue = (isNullOrUndefined(this.inputValue) || isNaN(this.inputValue)) ? null : this.inputValue;
822
- if (this.prevValue !== this.value || this.prevValue !== this.inputValue) {
823
- const eventArgs: Object = {};
824
- this.changeEventArgs = { value: this.value, previousValue: this.prevValue, isInteracted: this.isInteract,
825
- isInteraction: this.isInteract, event: event };
826
- if (event) {
827
- this.changeEventArgs.event = event;
828
- }
829
- if (this.changeEventArgs.event === undefined) {
830
- this.changeEventArgs.isInteracted = false;
831
- this.changeEventArgs.isInteraction = false;
832
- }
833
- merge(eventArgs, this.changeEventArgs);
834
- this.prevValue = this.value;
835
- this.isInteract = false;
836
- this.elementPrevValue = this.element.value;
837
- this.preventChange = false;
838
- this.trigger('change', eventArgs);
839
- }
840
- }
841
-
842
- private pasteHandler(): void {
843
- if (!this.enabled || this.readonly) {
844
- return;
845
- }
846
- const beforeUpdate: string = this.element.value;
847
- setTimeout(() => {
848
- if (!this.numericRegex().test(this.element.value)) {
849
- this.setElementValue(beforeUpdate);
850
- }
851
- });
852
- }
853
-
854
- private preventHandler(): void {
855
- const iOS: boolean = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
856
- setTimeout(() => {
857
- if (this.element.selectionStart > 0) {
858
- const currentPos: number = this.element.selectionStart;
859
- const prevPos: number = this.element.selectionStart - 1;
860
- const start: number = 0;
861
- const valArray: string[] = this.element.value.split('');
862
- const numericObject: Object = getNumericObject(this.locale);
863
- const decimalSeparator: string = getValue('decimal', numericObject);
864
- const ignoreKeyCode: number = decimalSeparator.charCodeAt(0);
865
- if (this.element.value[prevPos as number] === ' ' && this.element.selectionStart > 0 && !iOS) {
866
- if (isNullOrUndefined(this.prevVal)) {
867
- this.element.value = this.element.value.trim();
868
- } else if (prevPos !== 0) {
869
- this.element.value = this.prevVal;
870
- } else if (prevPos === 0) {
871
- this.element.value = this.element.value.trim();
872
- }
873
- this.element.setSelectionRange(prevPos, prevPos);
874
- } else if (isNaN(parseFloat(this.element.value[this.element.selectionStart - 1])) &&
875
- this.element.value[this.element.selectionStart - 1].charCodeAt(0) !== 45) {
876
- if ((valArray.indexOf(this.element.value[this.element.selectionStart - 1]) !==
877
- valArray.lastIndexOf(this.element.value[this.element.selectionStart - 1]) &&
878
- this.element.value[this.element.selectionStart - 1].charCodeAt(0) === ignoreKeyCode) ||
879
- this.element.value[this.element.selectionStart - 1].charCodeAt(0) !== ignoreKeyCode) {
880
- this.element.value = this.element.value.substring(0, prevPos) +
881
- this.element.value.substring(currentPos, this.element.value.length);
882
- this.element.setSelectionRange(prevPos, prevPos);
883
- if (isNaN(parseFloat(this.element.value[this.element.selectionStart - 1])) && this.element.selectionStart > 0
884
- && this.element.value.length) {
885
- this.preventHandler();
886
- }
887
- }
888
- } else if (isNaN(parseFloat(this.element.value[this.element.selectionStart - 2])) && this.element.selectionStart > 1 &&
889
- this.element.value[this.element.selectionStart - 2].charCodeAt(0) !== 45) {
890
- if ((valArray.indexOf(this.element.value[this.element.selectionStart - 2]) !==
891
- valArray.lastIndexOf(this.element.value[this.element.selectionStart - 2]) &&
892
- this.element.value[this.element.selectionStart - 2].charCodeAt(0) === ignoreKeyCode) ||
893
- this.element.value[this.element.selectionStart - 2].charCodeAt(0) !== ignoreKeyCode) {
894
- this.element.setSelectionRange(prevPos, prevPos);
895
- this.nextEle = this.element.value[this.element.selectionStart];
896
- this.cursorPosChanged = true;
897
- this.preventHandler();
898
- }
899
- }
900
- if (this.cursorPosChanged === true && this.element.value[this.element.selectionStart] === this.nextEle &&
901
- isNaN(parseFloat(this.element.value[this.element.selectionStart - 1]))) {
902
- this.element.setSelectionRange(this.element.selectionStart + 1, this.element.selectionStart + 1);
903
- this.cursorPosChanged = false;
904
- this.nextEle = null;
905
- }
906
- if (this.element.value.trim() === '') {
907
- this.element.setSelectionRange(start, start);
908
- }
909
- if (this.element.selectionStart > 0) {
910
- if ((this.element.value[this.element.selectionStart - 1].charCodeAt(0) === 45) && this.element.selectionStart > 1) {
911
- if (!isNullOrUndefined(this.prevVal)) {
912
- this.element.value = this.prevVal;
913
- }
914
- this.element.setSelectionRange(this.element.selectionStart, this.element.selectionStart);
915
- }
916
- if (this.element.value[this.element.selectionStart - 1] === decimalSeparator &&
917
- this.decimals === 0 &&
918
- this.validateDecimalOnType) {
919
- this.element.value = this.element.value.substring(0, prevPos) +
920
- this.element.value.substring(currentPos, this.element.value.length);
921
- }
922
- }
923
- this.prevVal = this.element.value;
924
- }
925
- });
926
- }
927
- private keyUpHandler(): void {
928
- if (!this.enabled || this.readonly) {
929
- return;
930
- }
931
- const iOS: boolean = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
932
- if (!iOS && Browser.isDevice) {
933
- this.preventHandler();
934
- }
935
- let parseValue: number = this.instance.getNumberParser({ format: 'n' })(this.element.value);
936
- parseValue = parseValue === null || isNaN(parseValue) ? null : parseValue;
937
- this.hiddenInput.value = parseValue || parseValue === 0 ? parseValue.toString() : null;
938
- const formElement: Element = closest(this.element, 'form');
939
- if (formElement) {
940
- const element: Element = this.element.nextElementSibling;
941
- const keyupEvent: KeyboardEvent = document.createEvent('KeyboardEvent');
942
- keyupEvent.initEvent('keyup', false, true);
943
- element.dispatchEvent(keyupEvent);
944
- }
945
- }
946
- private inputHandler(event: KeyboardEvent): void {
947
- const numerictextboxObj: any = null || this;
948
- if (!this.enabled || this.readonly) {
949
- return;
950
- }
951
- const iOS: boolean = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
952
- const fireFox: boolean = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
953
- if ((fireFox || iOS) && Browser.isDevice) {
954
- this.preventHandler();
955
- }
956
- /* istanbul ignore next */
957
- if ( this.isAngular
958
- && this.element.value !== getValue('decimal', getNumericObject(this.locale))
959
- && this.element.value !== getValue('minusSign', getNumericObject(this.locale))
960
- && this.numericRegex().test(this.element.value)) {
961
- let parsedValue: number = this.instance.getNumberParser({ format: 'n' })(this.element.value);
962
- parsedValue = isNaN(parsedValue) ? null : parsedValue;
963
- numerictextboxObj.localChange({value: parsedValue});
964
- this.preventChange = true;
965
- }
966
- if (this.isVue) {
967
- let current: number = this.instance.getNumberParser({ format: 'n' })(this.element.value);
968
- const previous: number = this.instance.getNumberParser({ format: 'n' })(this.elementPrevValue);
969
- //EJ2-54963-if type "." or ".0" or "-.0" it converts to "0" automatically when binding v-model
970
- const nonZeroRegex: RegExp = new RegExp('[^0-9]+$');
971
- if (nonZeroRegex.test(this.element.value) ||
972
- ((this.elementPrevValue.indexOf('.') !== -1 || this.elementPrevValue.indexOf('-') !== -1) &&
973
- this.element.value[this.element.value.length - 1] === '0')) {
974
- current = this.value;
975
- }
976
- const eventArgs: object = {
977
- event: event,
978
- value: (current === null || isNaN(current) ? null : current),
979
- previousValue: (previous === null || isNaN(previous) ? null : previous)
980
- };
981
- this.preventChange = true;
982
- this.elementPrevValue = this.element.value;
983
- this.trigger('input', eventArgs);
984
- }
985
- }
986
-
987
- private keyDownHandler(event: KeyboardEvent): void {
988
- if (!this.readonly) {
989
- switch (event.keyCode) {
990
- case 38:
991
- event.preventDefault();
992
- this.action(INCREMENT, event);
993
- break;
994
- case 40:
995
- event.preventDefault();
996
- this.action(DECREMENT, event);
997
- break;
998
- default: break;
999
- }
1000
- }
1001
- }
1002
-
1003
- private performAction(value: number, step: number, operation: string): number {
1004
- if (value === null || isNaN(value)) {
1005
- value = 0;
1006
- }
1007
- let updatedValue: number = operation === INCREMENT ? value + step : value - step;
1008
- updatedValue = this.correctRounding(value, step, updatedValue);
1009
- return this.strictMode ? this.trimValue(updatedValue) : updatedValue;
1010
- }
1011
-
1012
- private correctRounding(value: number, step: number, result: number): number {
1013
- const floatExp: RegExp = new RegExp('[,.](.*)');
1014
- const floatValue: boolean = floatExp.test(value.toString());
1015
- const floatStep: boolean = floatExp.test(step.toString());
1016
- if (floatValue || floatStep) {
1017
- const valueCount: number = floatValue ? floatExp.exec(value.toString())[0].length : 0;
1018
- const stepCount: number = floatStep ? floatExp.exec(step.toString())[0].length : 0;
1019
- const max: number = Math.max(valueCount, stepCount);
1020
- return value = this.roundValue(result, max);
1021
- }
1022
- return result;
1023
- }
1024
-
1025
- private roundValue(result: number, precision: number): number {
1026
- precision = precision || 0;
1027
- const divide: number = Math.pow(10, precision);
1028
- return result *= divide, result = Math.round(result) / divide;
1029
- }
1030
-
1031
- private updateValue(value: number, event?: Event): void {
1032
- if (event) {
1033
- this.isInteract = true;
1034
- }
1035
- if (value !== null && !isNaN(value)) {
1036
- if (this.decimals) {
1037
- value = this.roundNumber(value, this.decimals);
1038
- }
1039
- }
1040
- this.inputValue = value;
1041
- if (!(this.isVue && this.element && this.element.hasAttribute('modelvalue') && this.isDynamicChange)) {
1042
- this.changeValue(value === null || isNaN(value) ? null : this.strictMode ? this.trimValue(value) : value);
1043
- }
1044
- /* istanbul ignore next */
1045
- if (!this.isDynamicChange) {
1046
- this.raiseChangeEvent(event);
1047
- }
1048
- }
1049
-
1050
- private updateCurrency(prop: string, propVal: string): void {
1051
- setValue(prop, propVal, this.cultureInfo);
1052
- this.updateValue(this.value);
1053
- }
1054
-
1055
- private changeValue(value: number): void {
1056
- if (!(value || value === 0)) {
1057
- value = null;
1058
- this.setProperties({ value: value }, true);
1059
- } else {
1060
- const numberOfDecimals: number = this.getNumberOfDecimals(value);
1061
- this.setProperties({ value: this.roundNumber(value, numberOfDecimals) }, true);
1062
- }
1063
- this.modifyText();
1064
- if (!this.strictMode) {
1065
- this.validateState();
1066
- }
1067
- }
1068
-
1069
- private modifyText(): void {
1070
- if (this.value || this.value === 0) {
1071
- const value: string = this.formatNumber();
1072
- const elementValue: string = this.isFocused ? value : this.instance.getNumberFormat(this.cultureInfo)(this.value);
1073
- this.setElementValue(elementValue);
1074
- attributes(this.element, { 'aria-valuenow': value });
1075
- if (!isNullOrUndefined(this.hiddenInput)) {
1076
- this.hiddenInput.value = this.value.toString();
1077
- if (this.value !== null && this.serverDecimalSeparator) {
1078
- this.hiddenInput.value = this.hiddenInput.value.replace('.', this.serverDecimalSeparator);
1079
- }
1080
- }
1081
- } else {
1082
- this.setElementValue('');
1083
- this.element.removeAttribute('aria-valuenow');
1084
- this.hiddenInput.value = null;
1085
- }
1086
- }
1087
- private setElementValue(val: string, element ? : HTMLInputElement): void {
1088
- Input.setValue(val, (element ? element : this.element), this.floatLabelType, this.showClearButton);
1089
- }
1090
-
1091
- private validateState(): void {
1092
- this.isValidState = true;
1093
- if (this.value || this.value === 0) {
1094
- this.isValidState = !(this.value > this.max || this.value < this.min);
1095
- }
1096
- this.checkErrorClass();
1097
- }
1098
-
1099
- private getNumberOfDecimals(value: number): number {
1100
- let numberOfDecimals: number;
1101
- // eslint-disable-next-line no-useless-escape
1102
- const EXPREGEXP: RegExp = new RegExp('[eE][\-+]?([0-9]+)');
1103
- let valueString: string = value.toString();
1104
- if (EXPREGEXP.test(valueString)) {
1105
- const result: RegExpExecArray = EXPREGEXP.exec(valueString);
1106
- if (!isNullOrUndefined(result)) {
1107
- valueString = value.toFixed(Math.min(parseInt(result[1], 10), 20));
1108
- }
1109
- }
1110
- const decimalPart: string = valueString.split('.')[1];
1111
- numberOfDecimals = !decimalPart || !decimalPart.length ? 0 : decimalPart.length;
1112
- if (this.decimals !== null) {
1113
- numberOfDecimals = numberOfDecimals < this.decimals ? numberOfDecimals : this.decimals;
1114
- }
1115
- return numberOfDecimals;
1116
- }
1117
-
1118
- private formatNumber(): string {
1119
- const numberOfDecimals: number = this.getNumberOfDecimals(this.value);
1120
- return this.instance.getNumberFormat({
1121
- maximumFractionDigits: numberOfDecimals,
1122
- minimumFractionDigits: numberOfDecimals, useGrouping: false
1123
- })(this.value);
1124
- }
1125
-
1126
- private trimValue(value: number): number {
1127
- if (value > this.max) {
1128
- return this.max;
1129
- }
1130
- if (value < this.min) {
1131
- return this.min;
1132
- }
1133
- return value;
1134
- }
1135
- private roundNumber(value: number, precision: number): number {
1136
- let result: number = value;
1137
- const decimals: number = precision || 0;
1138
- const result1: string[] = result.toString().split('e');
1139
- result = Math.round(Number(result1[0] + 'e' + (result1[1] ? (Number(result1[1]) + decimals) : decimals)));
1140
- const result2: string[] = result.toString().split('e');
1141
- result = Number(result2[0] + 'e' + (result2[1] ? (Number(result2[1]) - decimals) : -decimals));
1142
- return Number(result.toFixed(decimals));
1143
- }
1144
- private cancelEvent(event: Event): boolean {
1145
- event.preventDefault();
1146
- return false;
1147
- }
1148
-
1149
- private keyPressHandler(event: KeyboardEvent): boolean {
1150
- if (!this.enabled || this.readonly) {
1151
- return true;
1152
- }
1153
- if (!Browser.isDevice && Browser.info.version === '11.0' && event.keyCode === 13) {
1154
- const parsedInput: number = this.instance.getNumberParser({ format: 'n' })(this.element.value);
1155
- this.updateValue(parsedInput, event);
1156
- return true;
1157
- }
1158
- if (event.which === 0 || event.metaKey || event.ctrlKey || event.keyCode === 8 || event.keyCode === 13) {
1159
- return true;
1160
- }
1161
- let currentChar: string = String.fromCharCode(event.which);
1162
- const decimalSeparator: string = getValue('decimal', getNumericObject(this.locale));
1163
- const isAlterNumPadDecimalChar: boolean = event.code === 'NumpadDecimal' && currentChar !== decimalSeparator;
1164
- //EJ2-59813-replace the culture decimal separator value with numberpad decimal separator value when culture decimal separator and numberpad decimal separator are different
1165
- if (isAlterNumPadDecimalChar) {
1166
- currentChar = decimalSeparator;
1167
- }
1168
- let text: string = this.element.value;
1169
- text = text.substring(0, this.element.selectionStart) + currentChar + text.substring(this.element.selectionEnd);
1170
- if (!this.numericRegex().test(text)) {
1171
- event.preventDefault();
1172
- event.stopPropagation();
1173
- return false;
1174
- } else {
1175
- //EJ2-59813-update the numberpad decimal separator and update the cursor position
1176
- if (isAlterNumPadDecimalChar) {
1177
- const start : number = this.element.selectionStart + 1;
1178
- this.element.value = text;
1179
- this.element.setSelectionRange(start, start);
1180
- event.preventDefault();
1181
- event.stopPropagation();
1182
- }
1183
- return true;
1184
- }
1185
- }
1186
-
1187
- private numericRegex(): RegExp {
1188
- const numericObject: Object = getNumericObject(this.locale);
1189
- let decimalSeparator: string = getValue('decimal', numericObject);
1190
- let fractionRule: string = '*';
1191
- if (decimalSeparator === DECIMALSEPARATOR) {
1192
- decimalSeparator = '\\' + decimalSeparator;
1193
- }
1194
- if (this.decimals === 0 && this.validateDecimalOnType ) {
1195
- return INTREGEXP;
1196
- }
1197
- if (this.decimals && this.validateDecimalOnType) {
1198
- fractionRule = '{0,' + this.decimals + '}';
1199
- }
1200
- /* eslint-disable-next-line security/detect-non-literal-regexp */
1201
- return new RegExp('^\\s*(-)?(((\\d+(' + decimalSeparator + '\\d' + fractionRule +
1202
- ')?)|(' + decimalSeparator + '\\d' + fractionRule + ')))?$');
1203
- }
1204
-
1205
- private mouseWheel(event: MouseWheelEvent): void {
1206
- event.preventDefault();
1207
- let delta: number;
1208
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1209
- const rawEvent: any = event;
1210
- if (rawEvent.wheelDelta) {
1211
- delta = rawEvent.wheelDelta / 120;
1212
- } else if (rawEvent.detail) {
1213
- delta = -rawEvent.detail / 3;
1214
- }
1215
- if (delta > 0) {
1216
- this.action(INCREMENT, event);
1217
- } else if (delta < 0) {
1218
- this.action(DECREMENT, event);
1219
- }
1220
- this.cancelEvent(event);
1221
- }
1222
-
1223
- private focusHandler(event: MouseEvent | FocusEvent | TouchEvent | KeyboardEvent): void {
1224
- clearTimeout(selectionTimeOut);
1225
- this.focusEventArgs = {event: event, value: this.value, container: this.container };
1226
- this.trigger('focus', this.focusEventArgs);
1227
- if (!this.enabled || this.readonly) {
1228
- return;
1229
- }
1230
- this.isFocused = true;
1231
- this.prevValue = this.value;
1232
- if ((this.value || this.value === 0)) {
1233
- const formatValue: string = this.formatNumber();
1234
- this.setElementValue(formatValue);
1235
- if (!this.isPrevFocused) {
1236
- if (!Browser.isDevice && Browser.info.version === '11.0') {
1237
- this.element.setSelectionRange(0, formatValue.length);
1238
- } else {
1239
- const delay: number = (Browser.isDevice && Browser.isIos) ? 600 : 0;
1240
- selectionTimeOut = setTimeout(
1241
- () => {
1242
- this.element.setSelectionRange(0, formatValue.length);
1243
- },
1244
- delay);
1245
- }
1246
- }
1247
- }
1248
- if (!Browser.isDevice) {
1249
- EventHandler.add(this.element, 'mousewheel DOMMouseScroll', this.mouseWheel, this);
1250
- }
1251
- }
1252
-
1253
- private focusOutHandler(event: MouseEvent | FocusEvent | TouchEvent | KeyboardEvent): void {
1254
- this.blurEventArgs = {event: event, value: this.value, container: this.container };
1255
- this.trigger('blur', this.blurEventArgs);
1256
- if (!this.enabled || this.readonly) {
1257
- return;
1258
- }
1259
- if (this.isPrevFocused) {
1260
- event.preventDefault();
1261
- if (Browser.isDevice) {
1262
- const value: string = this.element.value;
1263
- this.element.focus();
1264
- this.isPrevFocused = false;
1265
- const ele: HTMLInputElement = this.element;
1266
- setTimeout(
1267
- () => {
1268
- this.setElementValue(value, ele);
1269
- },
1270
- 200);
1271
- }
1272
- } else {
1273
- this.isFocused = false;
1274
- if (!this.element.value.length) {
1275
- this.setProperties({ value: null }, true);
1276
- }
1277
- const parsedInput: number = this.instance.getNumberParser({ format: 'n' })(this.element.value);
1278
- this.updateValue(parsedInput);
1279
- if (!Browser.isDevice) {
1280
- EventHandler.remove(this.element, 'mousewheel DOMMouseScroll', this.mouseWheel);
1281
- }
1282
- }
1283
- const formElement: Element = closest(this.element, 'form');
1284
- if (formElement) {
1285
- const element: Element = this.element.nextElementSibling;
1286
- const focusEvent: FocusEvent = document.createEvent('FocusEvent');
1287
- focusEvent.initEvent('focusout', false, true);
1288
- element.dispatchEvent(focusEvent);
1289
- }
1290
- }
1291
-
1292
- private mouseDownOnSpinner(event: MouseEvent): void {
1293
- if (this.isFocused) {
1294
- this.isPrevFocused = true;
1295
- event.preventDefault();
1296
- }
1297
- if (!this.getElementData(event)) {
1298
- return;
1299
- }
1300
- this.getElementData(event);
1301
- const target: HTMLElement = <HTMLElement>event.currentTarget;
1302
- const action: string = (target.classList.contains(SPINUP)) ? INCREMENT : DECREMENT;
1303
- EventHandler.add(target, 'mouseleave', this.mouseUpClick, this);
1304
- this.timeOut = setInterval(() => {
1305
- this.isCalled = true; this.action(action, event);
1306
- }, 150);
1307
- EventHandler.add(document, 'mouseup', this.mouseUpClick, this);
1308
- }
1309
-
1310
- private touchMoveOnSpinner(event: MouseEvent | TouchEvent): void {
1311
- let target: Element;
1312
- if (event.type === 'touchmove') {
1313
- const touchEvent: TouchList = (event as TouchEvent).touches;
1314
- target = touchEvent.length && document.elementFromPoint(touchEvent[0].pageX, touchEvent[0].pageY);
1315
- } else {
1316
- target = document.elementFromPoint((event as MouseEvent).clientX, (event as MouseEvent).clientY);
1317
- }
1318
- if (!(target.classList.contains(SPINICON))) {
1319
- clearInterval(this.timeOut);
1320
- }
1321
- }
1322
-
1323
- private mouseUpOnSpinner(event: MouseEvent): void {
1324
- this.prevValue = this.value;
1325
- if (this.isPrevFocused) {
1326
- this.element.focus();
1327
- if (!Browser.isDevice) {
1328
- this.isPrevFocused = false;
1329
- }
1330
- }
1331
- if (!Browser.isDevice) {
1332
- event.preventDefault();
1333
- }
1334
- if (!this.getElementData(event)) {
1335
- return;
1336
- }
1337
- const target: HTMLElement = <HTMLElement>event.currentTarget;
1338
- const action: string = (target.classList.contains(SPINUP)) ? INCREMENT : DECREMENT;
1339
- EventHandler.remove(target, 'mouseleave', this.mouseUpClick);
1340
- if (!this.isCalled) {
1341
- this.action(action, event);
1342
- }
1343
- this.isCalled = false;
1344
- EventHandler.remove(document, 'mouseup', this.mouseUpClick);
1345
- const formElement: Element = closest(this.element, 'form');
1346
- if (formElement) {
1347
- const element: Element = this.element.nextElementSibling;
1348
- const keyupEvent: KeyboardEvent = document.createEvent('KeyboardEvent');
1349
- keyupEvent.initEvent('keyup', false, true);
1350
- element.dispatchEvent(keyupEvent);
1351
- }
1352
- }
1353
-
1354
- private getElementData(event: MouseEvent): boolean {
1355
- if ((event.which && event.which === 3) || (event.button && event.button === 2)
1356
- || !this.enabled || this.readonly) {
1357
- return false;
1358
- }
1359
- clearInterval(this.timeOut);
1360
- return true;
1361
- }
1362
-
1363
- private floatLabelTypeUpdate(): void {
1364
- Input.removeFloating(this.inputWrapper);
1365
- const hiddenInput : HTMLElement = this.hiddenInput;
1366
- this.hiddenInput.remove();
1367
- Input.addFloating(this.element, this.floatLabelType, this.placeholder, this.createElement);
1368
- this.container.insertBefore(hiddenInput, this.container.childNodes[1]);
1369
- }
1370
-
1371
- private mouseUpClick(event: MouseEvent): void {
1372
- event.stopPropagation();
1373
- clearInterval(this.timeOut);
1374
- this.isCalled = false;
1375
- if (this.spinUp) {
1376
- EventHandler.remove(this.spinUp, 'mouseleave', this.mouseUpClick);
1377
- }
1378
- if (this.spinDown) {
1379
- EventHandler.remove(this.spinDown, 'mouseleave', this.mouseUpClick);
1380
- }
1381
- }
1382
-
1383
- /**
1384
- * Increments the NumericTextBox value with the specified step value.
1385
- *
1386
- * @param {number} step - Specifies the value used to increment the NumericTextBox value.
1387
- * if its not given then numeric value will be incremented based on the step property value.
1388
- * @returns {void}
1389
- */
1390
- public increment(step: number = this.step): void {
1391
- this.isInteract = false;
1392
- this.changeValue(this.performAction(this.value, step, INCREMENT));
1393
- this.raiseChangeEvent();
1394
- }
1395
- /**
1396
- * Decrements the NumericTextBox value with specified step value.
1397
- *
1398
- * @param {number} step - Specifies the value used to decrement the NumericTextBox value.
1399
- * if its not given then numeric value will be decremented based on the step property value.
1400
- * @returns {void}
1401
- */
1402
- public decrement(step: number = this.step): void {
1403
- this.isInteract = false;
1404
- this.changeValue(this.performAction(this.value, step, DECREMENT));
1405
- this.raiseChangeEvent();
1406
- }
1407
-
1408
- /**
1409
- * Removes the component from the DOM and detaches all its related event handlers.
1410
- * Also it maintains the initial input element from the DOM.
1411
- *
1412
- * @method destroy
1413
- * @returns {void}
1414
- */
1415
- public destroy(): void {
1416
- this.unwireEvents();
1417
- if (this.showClearButton) {
1418
- this.clearButton = document.getElementsByClassName('e-clear-icon')[0] as HTMLElement;
1419
- }
1420
- detach(this.hiddenInput);
1421
- if (this.showSpinButton) {
1422
- this.unwireSpinBtnEvents();
1423
- detach(this.spinUp);
1424
- detach(this.spinDown);
1425
- }
1426
- const attrArray: string[] = ['aria-labelledby', 'role', 'autocomplete', 'aria-readonly',
1427
- 'aria-disabled', 'autocapitalize', 'spellcheck', 'aria-autocomplete', 'tabindex',
1428
- 'aria-valuemin', 'aria-valuemax', 'aria-valuenow', 'aria-invalid'];
1429
- for (let i: number = 0; i < attrArray.length; i++) {
1430
- this.element.removeAttribute(attrArray[i as number]);
1431
- }
1432
- this.element.classList.remove('e-input');
1433
- this.container.insertAdjacentElement('afterend', this.element);
1434
- detach(this.container);
1435
- this.spinUp = null;
1436
- this.spinDown = null;
1437
- this.container = null;
1438
- this.hiddenInput = null;
1439
- this.changeEventArgs = null;
1440
- this.blurEventArgs = null;
1441
- this.focusEventArgs = null;
1442
- this.inputWrapper = null;
1443
- Input.destroy({
1444
- element: this.element,
1445
- floatLabelType: this.floatLabelType,
1446
- properties: this.properties
1447
- }, this.clearButton);
1448
- super.destroy();
1449
- }
1450
-
1451
- /**
1452
- * Returns the value of NumericTextBox with the format applied to the NumericTextBox.
1453
- *
1454
- * @returns {string} - Returns the formatted value of the NumericTextBox.
1455
- */
1456
- public getText(): string {
1457
- return this.element.value;
1458
- }
1459
-
1460
- /**
1461
- * Sets the focus to widget for interaction.
1462
- *
1463
- * @returns {void}
1464
- */
1465
- public focusIn(): void {
1466
- if (document.activeElement !== this.element && this.enabled) {
1467
- this.element.focus();
1468
- addClass([this.container], [NUMERIC_FOCUS]);
1469
- }
1470
- }
1471
-
1472
- /**
1473
- * Remove the focus from widget, if the widget is in focus state.
1474
- *
1475
- * @returns {void}
1476
- */
1477
- public focusOut(): void {
1478
- if (document.activeElement === this.element && this.enabled) {
1479
- this.element.blur();
1480
- removeClass([this.container], [NUMERIC_FOCUS]);
1481
- }
1482
- }
1483
-
1484
- /**
1485
- * Gets the properties to be maintained in the persisted state.
1486
- *
1487
- * @returns {string} - Returns the persisted data.
1488
- */
1489
- public getPersistData(): string {
1490
- const keyEntity: string[] = ['value'];
1491
- return this.addOnPersist(keyEntity);
1492
- }
1493
-
1494
- /**
1495
- * Calls internally if any of the property value is changed.
1496
- *
1497
- * @param {NumericTextBoxModel} newProp - Returns the dynamic property value of the component.
1498
- * @param {NumericTextBoxModel} oldProp - Returns the previous property value of the component.
1499
- * @returns {void}
1500
- * @private
1501
- */
1502
- public onPropertyChanged(newProp: NumericTextBoxModel, oldProp: NumericTextBoxModel): void {
1503
- for (const prop of Object.keys(newProp)) {
1504
- switch (prop) {
1505
- case 'width':
1506
- this.setElementWidth(newProp.width);
1507
- Input.calculateWidth(this.element, this.container);
1508
- break;
1509
- case 'cssClass':
1510
- this.updateCssClass(newProp.cssClass, oldProp.cssClass);
1511
- break;
1512
- case 'enabled':
1513
- Input.setEnabled(newProp.enabled, this.element);
1514
- this.bindClearEvent();
1515
- break;
1516
- case 'enableRtl':
1517
- Input.setEnableRtl(newProp.enableRtl, [this.container]);
1518
- break;
1519
- case 'readonly':
1520
- Input.setReadonly(newProp.readonly, this.element);
1521
- if (this.readonly) {
1522
- attributes(this.element, { 'aria-readonly': 'true' });
1523
- } else {
1524
- this.element.removeAttribute('aria-readonly');
1525
- }
1526
- break;
1527
- case 'htmlAttributes':
1528
- this.updateHTMLAttrToElement();
1529
- this.updateHTMLAttrToWrapper();
1530
- this.updateDataAttribute(true);
1531
- this.checkAttributes(true);
1532
- Input.validateInputType(this.container, this.element);
1533
- break;
1534
- case 'placeholder':
1535
- Input.setPlaceholder(newProp.placeholder, this.element);
1536
- Input.calculateWidth(this.element, this.container);
1537
- break;
1538
- case 'step':
1539
- this.step = newProp.step;
1540
- this.validateStep();
1541
- break;
1542
- case 'showSpinButton':
1543
- this.updateSpinButton(newProp);
1544
- break;
1545
- case 'showClearButton':
1546
- this.updateClearButton(newProp);
1547
- break;
1548
- case 'floatLabelType':
1549
- this.floatLabelType = newProp.floatLabelType;
1550
- this.floatLabelTypeUpdate();
1551
- break;
1552
- case 'value':
1553
- this.isDynamicChange = (this.isAngular || this.isVue) && this.preventChange;
1554
- this.updateValue(newProp.value);
1555
- if (this.isDynamicChange) {
1556
- this.preventChange = false;
1557
- this.isDynamicChange = false;
1558
- }
1559
- break;
1560
- case 'min':
1561
- case 'max':
1562
- setValue(prop, getValue(prop, newProp), this);
1563
- this.validateMinMax();
1564
- this.updateValue(this.value);
1565
- break;
1566
- case 'strictMode':
1567
- this.strictMode = newProp.strictMode;
1568
- this.updateValue(this.value);
1569
- this.validateState();
1570
- break;
1571
- case 'locale':
1572
- this.initCultureFunc();
1573
- this.l10n.setLocale(this.locale);
1574
- this.setSpinButton();
1575
- this.updatePlaceholder();
1576
- Input.setPlaceholder(this.placeholder, this.element);
1577
- this.updateValue(this.value);
1578
- break;
1579
- case 'currency': {
1580
- const propVal: string = getValue(prop, newProp);
1581
- this.setProperties({ currencyCode: propVal }, true);
1582
- this.updateCurrency(prop, propVal);
1583
- }
1584
- break;
1585
- case 'currencyCode': {
1586
- const propValue: string = getValue(prop, newProp);
1587
- this.setProperties({ currency: propValue }, true);
1588
- this.updateCurrency('currency', propValue);
1589
- }
1590
- break;
1591
- case 'format':
1592
- setValue(prop, getValue(prop, newProp), this);
1593
- this.initCultureInfo();
1594
- this.updateValue(this.value);
1595
- break;
1596
- case 'decimals':
1597
- this.decimals = newProp.decimals;
1598
- this.updateValue(this.value);
1599
- }
1600
- }
1601
- }
1602
-
1603
- private updateClearButton(newProp: NumericTextBoxModel): void {
1604
- Input.setClearButton(newProp.showClearButton, this.element, this.inputWrapper, undefined, this.createElement);
1605
- this.bindClearEvent();
1606
- }
1607
-
1608
- private updateSpinButton(newProp: NumericTextBoxModel): void {
1609
- if (newProp.showSpinButton) {
1610
- this.spinBtnCreation();
1611
- } else {
1612
- detach(this.spinUp);
1613
- detach(this.spinDown);
1614
- }
1615
- }
1616
-
1617
- /**
1618
- * Gets the component name
1619
- *
1620
- * @returns {string} Returns the component name.
1621
- * @private
1622
- */
1623
- public getModuleName(): string {
1624
- return 'numerictextbox';
1625
- }
1626
- }
1627
-
1628
- export interface ChangeEventArgs extends BaseEventArgs {
1629
- /** Returns the entered value of the NumericTextBox.
1630
- *
1631
- * @isGenericType true
1632
- */
1633
- value?: number
1634
- /** Returns the previously entered value of the NumericTextBox.
1635
- *
1636
- * @isGenericType true
1637
- */
1638
- previousValue?: number
1639
- /** Returns the event parameters from NumericTextBox. */
1640
- event?: Event
1641
- /** Returns true when the value of NumericTextBox is changed by user interaction. Otherwise, it returns false
1642
- *
1643
- * @private
1644
- */
1645
- isInteraction?: boolean
1646
- /** Returns true when the value of NumericTextBox is changed by user interaction. Otherwise, it returns false */
1647
- isInteracted?: boolean
1648
- }
1649
-
1650
- export interface NumericFocusEventArgs extends BaseEventArgs {
1651
- /** Returns the original event arguments. */
1652
- event?: MouseEvent | FocusEvent | TouchEvent | KeyboardEvent
1653
- /** Returns the value of the NumericTextBox.
1654
- *
1655
- * @isGenericType true
1656
- */
1657
- value: number
1658
- /** Returns the NumericTextBox container element */
1659
- container?: HTMLElement
1660
- }
1661
-
1662
- export interface NumericBlurEventArgs extends BaseEventArgs {
1663
- /** Returns the original event arguments. */
1664
- event?: MouseEvent | FocusEvent | TouchEvent | KeyboardEvent
1665
- /** Returns the value of the NumericTextBox.
1666
- *
1667
- * @isGenericType true
1668
- */
1669
- value: number
1670
- /** Returns the NumericTextBox container element */
1671
- container?: HTMLElement
1672
- }