@progress/kendo-angular-inputs 13.2.1-develop.11 → 13.2.1-develop.13

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 (289) hide show
  1. package/LICENSE.md +11 -0
  2. package/NOTICE.txt +654 -0
  3. package/README.md +184 -0
  4. package/checkbox/checkbox.directive.d.ts +52 -0
  5. package/checkbox.module.d.ts +43 -0
  6. package/colorpicker/color-contrast-svg.component.d.ts +29 -0
  7. package/colorpicker/color-gradient-numeric-label.directive.d.ts +20 -0
  8. package/colorpicker/color-gradient.component.d.ts +281 -0
  9. package/colorpicker/color-input.component.d.ts +95 -0
  10. package/colorpicker/color-palette.component.d.ts +221 -0
  11. package/colorpicker/colorpicker.component.d.ts +383 -0
  12. package/colorpicker/constants.d.ts +41 -0
  13. package/colorpicker/contrast-validation.component.d.ts +24 -0
  14. package/colorpicker/contrast.component.d.ts +25 -0
  15. package/colorpicker/events/active-color-click-event.d.ts +53 -0
  16. package/colorpicker/events/cancel-event.d.ts +15 -0
  17. package/colorpicker/events/close-event.d.ts +10 -0
  18. package/colorpicker/events/kendo-drag-event.d.ts +21 -0
  19. package/colorpicker/events/open-event.d.ts +10 -0
  20. package/colorpicker/events.d.ts +8 -0
  21. package/colorpicker/flatcolorpicker-actions.component.d.ts +24 -0
  22. package/colorpicker/flatcolorpicker-header.component.d.ts +43 -0
  23. package/colorpicker/flatcolorpicker.component.d.ts +267 -0
  24. package/colorpicker/focus-on-dom-ready.directive.d.ts +18 -0
  25. package/colorpicker/localization/colorgradient-localization.service.d.ts +17 -0
  26. package/colorpicker/localization/colorpalette-localization.service.d.ts +17 -0
  27. package/colorpicker/localization/colorpicker-localization.service.d.ts +14 -0
  28. package/colorpicker/localization/custom-messages.component.d.ts +17 -0
  29. package/colorpicker/localization/flatcolorpicker-localization.service.d.ts +17 -0
  30. package/colorpicker/localization/localized-colorpicker-messages.directive.d.ts +16 -0
  31. package/colorpicker/localization/messages.d.ts +121 -0
  32. package/colorpicker/models/actions-layout.d.ts +8 -0
  33. package/colorpicker/models/colorpicker-view.d.ts +8 -0
  34. package/colorpicker/models/gradient-settings.d.ts +35 -0
  35. package/colorpicker/models/hsva.d.ts +13 -0
  36. package/colorpicker/models/output-format.d.ts +8 -0
  37. package/colorpicker/models/palette-presets.d.ts +61 -0
  38. package/colorpicker/models/palette-settings.d.ts +33 -0
  39. package/colorpicker/models/popup-settings.d.ts +18 -0
  40. package/colorpicker/models/rgb.d.ts +12 -0
  41. package/colorpicker/models/rgba.d.ts +13 -0
  42. package/colorpicker/models/table-cell.d.ts +11 -0
  43. package/colorpicker/models/tile-size.d.ts +11 -0
  44. package/colorpicker/models.d.ts +16 -0
  45. package/colorpicker/services/color-palette.service.d.ts +19 -0
  46. package/colorpicker/services/flatcolorpicker.service.d.ts +15 -0
  47. package/colorpicker/utils/color-parser.d.ts +77 -0
  48. package/colorpicker/utils/contrast-curve.d.ts +37 -0
  49. package/colorpicker/utils.d.ts +6 -0
  50. package/colorpicker.module.d.ts +35 -0
  51. package/common/dom-utils.d.ts +25 -0
  52. package/common/math.d.ts +36 -0
  53. package/common/models/fillmode.d.ts +9 -0
  54. package/common/models/rounded.d.ts +14 -0
  55. package/common/models/size.d.ts +9 -0
  56. package/common/models/styling-classes.d.ts +11 -0
  57. package/common/models.d.ts +8 -0
  58. package/common/utils.d.ts +56 -0
  59. package/esm2020/checkbox/checkbox.directive.mjs +94 -0
  60. package/esm2020/checkbox.module.mjs +52 -0
  61. package/esm2020/colorpicker/color-contrast-svg.component.mjs +97 -0
  62. package/esm2020/colorpicker/color-gradient-numeric-label.directive.mjs +31 -0
  63. package/esm2020/colorpicker/color-gradient.component.mjs +1003 -0
  64. package/esm2020/colorpicker/color-input.component.mjs +433 -0
  65. package/esm2020/colorpicker/color-palette.component.mjs +553 -0
  66. package/esm2020/colorpicker/colorpicker.component.mjs +1086 -0
  67. package/esm2020/colorpicker/constants.mjs +40 -0
  68. package/esm2020/colorpicker/contrast-validation.component.mjs +72 -0
  69. package/esm2020/colorpicker/contrast.component.mjs +100 -0
  70. package/esm2020/colorpicker/events/active-color-click-event.mjs +58 -0
  71. package/esm2020/colorpicker/events/cancel-event.mjs +14 -0
  72. package/esm2020/colorpicker/events/close-event.mjs +10 -0
  73. package/esm2020/colorpicker/events/kendo-drag-event.mjs +5 -0
  74. package/esm2020/colorpicker/events/open-event.mjs +10 -0
  75. package/esm2020/colorpicker/events.mjs +8 -0
  76. package/esm2020/colorpicker/flatcolorpicker-actions.component.mjs +93 -0
  77. package/esm2020/colorpicker/flatcolorpicker-header.component.mjs +217 -0
  78. package/esm2020/colorpicker/flatcolorpicker.component.mjs +829 -0
  79. package/esm2020/colorpicker/focus-on-dom-ready.directive.mjs +29 -0
  80. package/esm2020/colorpicker/localization/colorgradient-localization.service.mjs +45 -0
  81. package/esm2020/colorpicker/localization/colorpalette-localization.service.mjs +45 -0
  82. package/esm2020/colorpicker/localization/colorpicker-localization.service.mjs +31 -0
  83. package/esm2020/colorpicker/localization/custom-messages.component.mjs +41 -0
  84. package/esm2020/colorpicker/localization/flatcolorpicker-localization.service.mjs +45 -0
  85. package/esm2020/colorpicker/localization/localized-colorpicker-messages.directive.mjs +37 -0
  86. package/esm2020/colorpicker/localization/messages.mjs +75 -0
  87. package/esm2020/colorpicker/models/actions-layout.mjs +5 -0
  88. package/esm2020/colorpicker/models/colorpicker-view.mjs +5 -0
  89. package/esm2020/colorpicker/models/gradient-settings.mjs +5 -0
  90. package/esm2020/colorpicker/models/hsva.mjs +5 -0
  91. package/esm2020/colorpicker/models/output-format.mjs +5 -0
  92. package/esm2020/colorpicker/models/palette-presets.mjs +62 -0
  93. package/esm2020/colorpicker/models/palette-settings.mjs +5 -0
  94. package/esm2020/colorpicker/models/popup-settings.mjs +5 -0
  95. package/esm2020/colorpicker/models/rgb.mjs +5 -0
  96. package/esm2020/colorpicker/models/rgba.mjs +5 -0
  97. package/esm2020/colorpicker/models/table-cell.mjs +5 -0
  98. package/esm2020/colorpicker/models/tile-size.mjs +6 -0
  99. package/esm2020/colorpicker/models.mjs +16 -0
  100. package/esm2020/colorpicker/services/color-palette.service.mjs +67 -0
  101. package/esm2020/colorpicker/services/flatcolorpicker.service.mjs +39 -0
  102. package/esm2020/colorpicker/utils/color-parser.mjs +164 -0
  103. package/esm2020/colorpicker/utils/contrast-curve.mjs +85 -0
  104. package/esm2020/colorpicker/utils.mjs +6 -0
  105. package/esm2020/colorpicker.module.mjs +104 -0
  106. package/esm2020/common/dom-utils.mjs +36 -0
  107. package/esm2020/common/math.mjs +65 -0
  108. package/esm2020/common/models/fillmode.mjs +5 -0
  109. package/esm2020/common/models/rounded.mjs +5 -0
  110. package/esm2020/common/models/size.mjs +5 -0
  111. package/esm2020/common/models/styling-classes.mjs +5 -0
  112. package/esm2020/common/models.mjs +8 -0
  113. package/esm2020/common/utils.mjs +81 -0
  114. package/esm2020/formfield/error.component.mjs +68 -0
  115. package/esm2020/formfield/formfield.component.mjs +284 -0
  116. package/esm2020/formfield/hint.component.mjs +63 -0
  117. package/esm2020/formfield/models/message-align.mjs +5 -0
  118. package/esm2020/formfield/models/orientation.mjs +5 -0
  119. package/esm2020/formfield/models/show-options.mjs +5 -0
  120. package/esm2020/formfield.module.mjs +54 -0
  121. package/esm2020/index.mjs +66 -0
  122. package/esm2020/inputs.module.mjs +98 -0
  123. package/esm2020/maskedtextbox/maskedtextbox.component.mjs +711 -0
  124. package/esm2020/maskedtextbox/masking.service.mjs +191 -0
  125. package/esm2020/maskedtextbox/parsing/combinators.mjs +28 -0
  126. package/esm2020/maskedtextbox/parsing/parsers.mjs +147 -0
  127. package/esm2020/maskedtextbox/parsing/result.mjs +41 -0
  128. package/esm2020/maskedtextbox/parsing/stream.mjs +41 -0
  129. package/esm2020/maskedtextbox.module.mjs +53 -0
  130. package/esm2020/numerictextbox/arrow-direction.mjs +13 -0
  131. package/esm2020/numerictextbox/constants.mjs +28 -0
  132. package/esm2020/numerictextbox/localization/custom-messages.component.mjs +41 -0
  133. package/esm2020/numerictextbox/localization/localized-numerictextbox-messages.directive.mjs +37 -0
  134. package/esm2020/numerictextbox/localization/messages.mjs +25 -0
  135. package/esm2020/numerictextbox/numerictextbox.component.mjs +1105 -0
  136. package/esm2020/numerictextbox/utils.mjs +92 -0
  137. package/esm2020/numerictextbox.module.mjs +66 -0
  138. package/esm2020/package-metadata.mjs +15 -0
  139. package/esm2020/progress-kendo-angular-inputs.mjs +8 -0
  140. package/esm2020/radiobutton/radiobutton.directive.mjs +76 -0
  141. package/esm2020/radiobutton.module.mjs +52 -0
  142. package/esm2020/rangeslider/localization/custom-messages.component.mjs +41 -0
  143. package/esm2020/rangeslider/localization/localized-rangeslider-messages.directive.mjs +37 -0
  144. package/esm2020/rangeslider/localization/messages.mjs +25 -0
  145. package/esm2020/rangeslider/rangeslider-model.mjs +52 -0
  146. package/esm2020/rangeslider/rangeslider-value.type.mjs +5 -0
  147. package/esm2020/rangeslider/rangeslider.component.mjs +605 -0
  148. package/esm2020/rangeslider.module.mjs +71 -0
  149. package/esm2020/shared/input-separator.component.mjs +41 -0
  150. package/esm2020/shared/textarea.directive.mjs +260 -0
  151. package/esm2020/shared/utils.mjs +13 -0
  152. package/esm2020/shared.module.mjs +32 -0
  153. package/esm2020/signature/events/close-event.mjs +10 -0
  154. package/esm2020/signature/events/index.mjs +6 -0
  155. package/esm2020/signature/events/open-event.mjs +10 -0
  156. package/esm2020/signature/localization/custom-messages.component.mjs +41 -0
  157. package/esm2020/signature/localization/index.mjs +7 -0
  158. package/esm2020/signature/localization/localized-signature-messages.directive.mjs +37 -0
  159. package/esm2020/signature/localization/messages.mjs +29 -0
  160. package/esm2020/signature/signature.component.mjs +906 -0
  161. package/esm2020/signature.module.mjs +79 -0
  162. package/esm2020/slider/localization/custom-messages.component.mjs +41 -0
  163. package/esm2020/slider/localization/localized-slider-messages.directive.mjs +37 -0
  164. package/esm2020/slider/localization/messages.mjs +27 -0
  165. package/esm2020/slider/slider-model.mjs +34 -0
  166. package/esm2020/slider/slider.component.mjs +646 -0
  167. package/esm2020/slider.module.mjs +73 -0
  168. package/esm2020/sliders-common/label-template.directive.mjs +45 -0
  169. package/esm2020/sliders-common/slider-base.mjs +255 -0
  170. package/esm2020/sliders-common/slider-model.base.mjs +93 -0
  171. package/esm2020/sliders-common/slider-ticks.component.mjs +125 -0
  172. package/esm2020/sliders-common/sliders-common.module.mjs +42 -0
  173. package/esm2020/sliders-common/sliders-util.mjs +219 -0
  174. package/esm2020/sliders-common/title-callback.mjs +5 -0
  175. package/esm2020/switch/events/blur-event.mjs +9 -0
  176. package/esm2020/switch/events/focus-event.mjs +9 -0
  177. package/esm2020/switch/localization/custom-messages.component.mjs +41 -0
  178. package/esm2020/switch/localization/localized-switch-messages.directive.mjs +37 -0
  179. package/esm2020/switch/localization/messages.mjs +25 -0
  180. package/esm2020/switch/switch.component.mjs +577 -0
  181. package/esm2020/switch.module.mjs +68 -0
  182. package/esm2020/text-fields-common/text-fields-base.mjs +128 -0
  183. package/esm2020/textarea/models/flow.mjs +5 -0
  184. package/esm2020/textarea/models/resize.mjs +5 -0
  185. package/esm2020/textarea/textarea-suffix.component.mjs +40 -0
  186. package/esm2020/textarea/textarea.component.mjs +604 -0
  187. package/esm2020/textarea.module.mjs +68 -0
  188. package/esm2020/textbox/localization/custom-messages.component.mjs +41 -0
  189. package/esm2020/textbox/localization/localized-textbox-messages.directive.mjs +37 -0
  190. package/esm2020/textbox/localization/messages.mjs +23 -0
  191. package/esm2020/textbox/models/icon-show-options.mjs +5 -0
  192. package/esm2020/textbox/textbox-prefix.directive.mjs +38 -0
  193. package/esm2020/textbox/textbox-suffix.directive.mjs +37 -0
  194. package/esm2020/textbox/textbox.component.mjs +849 -0
  195. package/esm2020/textbox/textbox.directive.mjs +121 -0
  196. package/esm2020/textbox.module.mjs +89 -0
  197. package/esm2020/validators/max.validator.mjs +21 -0
  198. package/esm2020/validators/min.validator.mjs +21 -0
  199. package/fesm2015/progress-kendo-angular-inputs.mjs +15090 -0
  200. package/fesm2020/progress-kendo-angular-inputs.mjs +15055 -0
  201. package/formfield/error.component.d.ts +31 -0
  202. package/formfield/formfield.component.d.ts +98 -0
  203. package/formfield/hint.component.d.ts +29 -0
  204. package/formfield/models/message-align.d.ts +8 -0
  205. package/formfield/models/orientation.d.ts +9 -0
  206. package/formfield/models/show-options.d.ts +16 -0
  207. package/formfield.module.d.ts +45 -0
  208. package/index.d.ts +76 -0
  209. package/inputs.module.d.ts +55 -0
  210. package/maskedtextbox/maskedtextbox.component.d.ts +315 -0
  211. package/maskedtextbox/masking.service.d.ts +48 -0
  212. package/maskedtextbox/parsing/combinators.d.ts +13 -0
  213. package/maskedtextbox/parsing/parsers.d.ts +51 -0
  214. package/maskedtextbox/parsing/result.d.ts +27 -0
  215. package/maskedtextbox/parsing/stream.d.ts +26 -0
  216. package/maskedtextbox.module.d.ts +44 -0
  217. package/numerictextbox/arrow-direction.d.ts +12 -0
  218. package/numerictextbox/constants.d.ts +28 -0
  219. package/numerictextbox/localization/custom-messages.component.d.ts +17 -0
  220. package/numerictextbox/localization/localized-numerictextbox-messages.directive.d.ts +16 -0
  221. package/numerictextbox/localization/messages.d.ts +21 -0
  222. package/numerictextbox/numerictextbox.component.d.ts +364 -0
  223. package/numerictextbox/utils.d.ts +44 -0
  224. package/numerictextbox.module.d.ts +47 -0
  225. package/package-metadata.d.ts +9 -0
  226. package/package.json +74 -0
  227. package/progress-kendo-angular-inputs.d.ts +9 -0
  228. package/radiobutton/radiobutton.directive.d.ts +38 -0
  229. package/radiobutton.module.d.ts +43 -0
  230. package/rangeslider/localization/custom-messages.component.d.ts +17 -0
  231. package/rangeslider/localization/localized-rangeslider-messages.directive.d.ts +16 -0
  232. package/rangeslider/localization/messages.d.ts +21 -0
  233. package/rangeslider/rangeslider-model.d.ts +15 -0
  234. package/rangeslider/rangeslider-value.type.d.ts +9 -0
  235. package/rangeslider/rangeslider.component.d.ts +139 -0
  236. package/rangeslider.module.d.ts +48 -0
  237. package/schematics/collection.json +12 -0
  238. package/schematics/ngAdd/index.js +11 -0
  239. package/schematics/ngAdd/schema.json +28 -0
  240. package/shared/input-separator.component.d.ts +28 -0
  241. package/shared/textarea.directive.d.ts +99 -0
  242. package/shared/utils.d.ts +10 -0
  243. package/shared.module.d.ts +19 -0
  244. package/signature/events/close-event.d.ts +10 -0
  245. package/signature/events/index.d.ts +6 -0
  246. package/signature/events/open-event.d.ts +10 -0
  247. package/signature/localization/custom-messages.component.d.ts +17 -0
  248. package/signature/localization/index.d.ts +7 -0
  249. package/signature/localization/localized-signature-messages.directive.d.ts +16 -0
  250. package/signature/localization/messages.d.ts +29 -0
  251. package/signature/signature.component.d.ts +364 -0
  252. package/signature.module.d.ts +48 -0
  253. package/slider/localization/custom-messages.component.d.ts +17 -0
  254. package/slider/localization/localized-slider-messages.directive.d.ts +16 -0
  255. package/slider/localization/messages.d.ts +25 -0
  256. package/slider/slider-model.d.ts +14 -0
  257. package/slider/slider.component.d.ts +175 -0
  258. package/slider.module.d.ts +50 -0
  259. package/sliders-common/label-template.directive.d.ts +36 -0
  260. package/sliders-common/slider-base.d.ts +141 -0
  261. package/sliders-common/slider-model.base.d.ts +26 -0
  262. package/sliders-common/slider-ticks.component.d.ts +26 -0
  263. package/sliders-common/sliders-common.module.d.ts +17 -0
  264. package/sliders-common/sliders-util.d.ts +119 -0
  265. package/sliders-common/title-callback.d.ts +10 -0
  266. package/switch/events/blur-event.d.ts +13 -0
  267. package/switch/events/focus-event.d.ts +13 -0
  268. package/switch/localization/custom-messages.component.d.ts +17 -0
  269. package/switch/localization/localized-switch-messages.directive.d.ts +16 -0
  270. package/switch/localization/messages.d.ts +21 -0
  271. package/switch/switch.component.d.ts +216 -0
  272. package/switch.module.d.ts +46 -0
  273. package/text-fields-common/text-fields-base.d.ts +91 -0
  274. package/textarea/models/flow.d.ts +12 -0
  275. package/textarea/models/resize.d.ts +16 -0
  276. package/textarea/textarea-suffix.component.d.ts +26 -0
  277. package/textarea/textarea.component.d.ts +225 -0
  278. package/textarea.module.d.ts +48 -0
  279. package/textbox/localization/custom-messages.component.d.ts +17 -0
  280. package/textbox/localization/localized-textbox-messages.directive.d.ts +16 -0
  281. package/textbox/localization/messages.d.ts +17 -0
  282. package/textbox/models/icon-show-options.d.ts +13 -0
  283. package/textbox/textbox-prefix.directive.d.ts +29 -0
  284. package/textbox/textbox-suffix.directive.d.ts +28 -0
  285. package/textbox/textbox.component.d.ts +376 -0
  286. package/textbox/textbox.directive.d.ts +59 -0
  287. package/textbox.module.d.ts +53 -0
  288. package/validators/max.validator.d.ts +8 -0
  289. package/validators/min.validator.d.ts +8 -0
@@ -0,0 +1,1105 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ import { Component, ElementRef, EventEmitter, HostBinding, Input, Output, Renderer2, ViewChild, forwardRef, isDevMode, NgZone, ChangeDetectorRef, Injector } from '@angular/core';
7
+ import { anyChanged, hasObservers, Keys, guid, KendoInput } from '@progress/kendo-angular-common';
8
+ import { areSame, getStylingClasses, requiresZoneOnBlur } from '../common/utils';
9
+ import { invokeElementMethod } from '../common/dom-utils';
10
+ import { add, toFixedPrecision, limitPrecision } from '../common/math';
11
+ import { createMaxValidator } from '../validators/max.validator';
12
+ import { createMinValidator } from '../validators/min.validator';
13
+ import { NG_VALUE_ACCESSOR, NG_VALIDATORS, NgControl } from '@angular/forms';
14
+ import { IntlService } from '@progress/kendo-angular-intl';
15
+ import { L10N_PREFIX, LocalizationService } from '@progress/kendo-angular-l10n';
16
+ import { validatePackage } from '@progress/kendo-licensing';
17
+ import { packageMetadata } from '../package-metadata';
18
+ import { MIN_DOC_LINK, MAX_DOC_LINK, POINT, INITIAL_SPIN_DELAY, SPIN_DELAY, EXPONENT_REGEX } from './constants';
19
+ import { defined, noop, numericRegex, isNumber, pad, decimalPart, getDeltaFromMouseWheel, getCaretPosition, extractSignificantNumericChars, isRightClick } from './utils';
20
+ import { ArrowDirection } from './arrow-direction';
21
+ import { mobileOS } from '@progress/kendo-common';
22
+ import { caretAltUpIcon, caretAltDownIcon } from '@progress/kendo-svg-icons';
23
+ import * as i0 from "@angular/core";
24
+ import * as i1 from "@progress/kendo-angular-intl";
25
+ import * as i2 from "@progress/kendo-angular-l10n";
26
+ import * as i3 from "@progress/kendo-angular-icons";
27
+ import * as i4 from "./localization/localized-numerictextbox-messages.directive";
28
+ import * as i5 from "@progress/kendo-angular-common";
29
+ import * as i6 from "@angular/common";
30
+ const PARSABLE_OPTIONS = ['min', 'max', 'step', 'decimals'];
31
+ const PARSABLE_DEFAULTS = {
32
+ decimals: null,
33
+ max: null,
34
+ min: null,
35
+ step: 1
36
+ };
37
+ const FOCUSED = 'k-focus';
38
+ const DEFAULT_SIZE = 'medium';
39
+ const DEFAULT_ROUNDED = 'medium';
40
+ const DEFAULT_FILL_MODE = 'solid';
41
+ /**
42
+ * Represents the [Kendo UI NumericTextBox component for Angular]({% slug overview_numerictextbox %}).
43
+ */
44
+ export class NumericTextBoxComponent {
45
+ constructor(intl, renderer, localizationService, injector, ngZone, changeDetector, hostElement) {
46
+ this.intl = intl;
47
+ this.renderer = renderer;
48
+ this.localizationService = localizationService;
49
+ this.injector = injector;
50
+ this.ngZone = ngZone;
51
+ this.changeDetector = changeDetector;
52
+ this.hostElement = hostElement;
53
+ /**
54
+ * @hidden
55
+ */
56
+ this.focusableId = `k-${guid()}`;
57
+ /**
58
+ * Determines whether the NumericTextBox is disabled ([see example]({% slug disabled_numerictextbox %})).
59
+ */
60
+ this.disabled = false;
61
+ /**
62
+ * Determines whether the NumericTextBox is in its read-only state ([see example]({% slug readonly_numerictextbox %})).
63
+ */
64
+ this.readonly = false;
65
+ /**
66
+ * Sets the title of the `input` element of the NumericTextBox.
67
+ */
68
+ this.title = '';
69
+ /**
70
+ * Specifies whether the value will be auto-corrected based on the minimum and maximum values
71
+ * ([see example]({% slug precision_numerictextbox %})).
72
+ */
73
+ this.autoCorrect = false;
74
+ /**
75
+ * Specifies the number of decimals that the user can enter when the input is focused
76
+ * ([see example]({% slug precision_numerictextbox %})).
77
+ */
78
+ this.decimals = null;
79
+ /**
80
+ * Specifies the value that is used to increment or decrement the component value
81
+ * ([see example]({% slug predefinedsteps_numerictextbox %})).
82
+ */
83
+ this.step = 1;
84
+ /**
85
+ * Specifies whether the **Up** and **Down** spin buttons will be rendered
86
+ * ([see example]({% slug spinbuttons_numerictextbox %})).
87
+ */
88
+ this.spinners = true;
89
+ /**
90
+ * Determines whether the built-in minimum or maximum validators are enforced when a form is validated.
91
+ *
92
+ * > The 4.2.0 Angular version introduces the `min` and `max` validation directives. As a result, even if you set `rangeValidation`
93
+ * to `false`, the built-in Angular validators will be executed.
94
+ */
95
+ this.rangeValidation = true;
96
+ /**
97
+ * Specifies the [tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of the component.
98
+ */
99
+ this.tabindex = 0;
100
+ /**
101
+ * Determines whether the value of the NumericTextBox will be changed via scrolling. Defaults to `true`.
102
+ *
103
+ * @default true
104
+ */
105
+ this.changeValueOnScroll = true;
106
+ /**
107
+ * Determines whether the whole value will be selected when the NumericTextBox is clicked. Defaults to `true`.
108
+ */
109
+ this.selectOnFocus = true;
110
+ /**
111
+ * Specifies the value of the NumericTextBox
112
+ * ([see example]({% slug formats_numerictextbox %})).
113
+ */
114
+ this.value = null;
115
+ /**
116
+ * Fires each time the user selects a new value ([see example]({% slug overview_numerictextbox %}#toc-events)).
117
+ */
118
+ this.valueChange = new EventEmitter();
119
+ /**
120
+ * Fires each time the user focuses the `input` element ([see example]({% slug overview_numerictextbox %}#toc-events)).
121
+ */
122
+ this.onFocus = new EventEmitter();
123
+ /**
124
+ * Fires each time the `input` element gets blurred ([see example]({% slug overview_numerictextbox %}#toc-events)).
125
+ */
126
+ this.onBlur = new EventEmitter();
127
+ /**
128
+ * @hidden
129
+ */
130
+ this.ArrowDirection = ArrowDirection;
131
+ /**
132
+ * @hidden
133
+ */
134
+ this.arrowDirection = ArrowDirection.None;
135
+ this.hostClasses = true;
136
+ /**
137
+ * @hidden
138
+ */
139
+ this.arrowUpIcon = caretAltUpIcon;
140
+ /**
141
+ * @hidden
142
+ */
143
+ this.arrowDownIcon = caretAltDownIcon;
144
+ this.inputValue = '';
145
+ this.minValidateFn = noop;
146
+ this.maxValidateFn = noop;
147
+ this._format = "n2";
148
+ this.isPasted = false;
149
+ this.mouseDown = false;
150
+ this._size = 'medium';
151
+ this._rounded = 'medium';
152
+ this._fillMode = 'solid';
153
+ this.ngChange = noop;
154
+ this.ngTouched = noop;
155
+ this.ngValidatorChange = noop;
156
+ this.domEvents = [];
157
+ /**
158
+ * @hidden
159
+ */
160
+ this.increasePress = (e) => {
161
+ this.arrowPress(ArrowDirection.Up, e);
162
+ };
163
+ /**
164
+ * @hidden
165
+ */
166
+ this.decreasePress = (e) => {
167
+ this.arrowPress(ArrowDirection.Down, e);
168
+ };
169
+ /**
170
+ * @hidden
171
+ */
172
+ this.releaseArrow = () => {
173
+ clearTimeout(this.spinTimeout);
174
+ if (this.arrowDirection !== ArrowDirection.None) {
175
+ this.arrowDirection = ArrowDirection.None;
176
+ this.changeDetector.detectChanges();
177
+ }
178
+ };
179
+ /**
180
+ * @hidden
181
+ */
182
+ this.handlePaste = () => {
183
+ this.isPasted = true;
184
+ };
185
+ /**
186
+ * @hidden
187
+ */
188
+ this.handleInput = () => {
189
+ const input = this.numericInput.nativeElement;
190
+ let { selectionStart, selectionEnd, value: inputValue } = input;
191
+ if (this.pressedKey === Keys.NumpadDecimal) {
192
+ inputValue = this.replaceNumpadDotValue();
193
+ }
194
+ if (this.isPasted) {
195
+ inputValue = this.formatInputValue(this.intl.parseNumber(inputValue));
196
+ }
197
+ if (!this.isValid(inputValue)) {
198
+ input.value = this.inputValue;
199
+ this.setSelection(selectionStart - 1, selectionEnd - 1);
200
+ return;
201
+ }
202
+ const parsedValue = this.intl.parseNumber(inputValue);
203
+ let value = this.restrictDecimals(parsedValue);
204
+ if (this.autoCorrect) {
205
+ const limited = this.limitInputValue(value);
206
+ value = limited.value;
207
+ selectionStart = limited.selectionStart;
208
+ selectionEnd = limited.selectionEnd;
209
+ }
210
+ if (parsedValue !== value || this.hasTrailingZeros(inputValue) || !this.focused) {
211
+ this.setInputValue(value);
212
+ this.setSelection(selectionStart, selectionEnd);
213
+ }
214
+ else {
215
+ this.inputValue = inputValue;
216
+ }
217
+ if (this.isPasted) {
218
+ input.value = this.inputValue;
219
+ }
220
+ this.updateValue(value);
221
+ this.previousSelection = null;
222
+ this.isPasted = false;
223
+ };
224
+ /**
225
+ * @hidden
226
+ */
227
+ this.handleDragEnter = () => {
228
+ if (!this.focused && !this.isDisabled) {
229
+ this.setInputValue(this.value, true);
230
+ }
231
+ };
232
+ /**
233
+ * @hidden
234
+ */
235
+ this.handleMouseDown = () => {
236
+ this.mouseDown = true;
237
+ };
238
+ /**
239
+ * @hidden
240
+ */
241
+ this.handleFocus = () => {
242
+ if (!this.focused) {
243
+ this.focused = true;
244
+ if (!this.isDisabled) {
245
+ const shouldSelectAll = this.selectOnFocus || !this.mouseDown;
246
+ this.ngZone.runOutsideAngular(() => {
247
+ setTimeout(() => {
248
+ if (shouldSelectAll) {
249
+ this.selectAll();
250
+ }
251
+ else {
252
+ this.selectCaret();
253
+ }
254
+ }, 0);
255
+ });
256
+ }
257
+ }
258
+ this.mouseDown = false;
259
+ if (hasObservers(this.onFocus)) {
260
+ this.ngZone.run(() => {
261
+ this.onFocus.emit();
262
+ });
263
+ }
264
+ };
265
+ /**
266
+ * @hidden
267
+ */
268
+ this.handleBlur = () => {
269
+ this.changeDetector.markForCheck();
270
+ this.focused = false;
271
+ //blur is thrown before input when dragging the input text in IE
272
+ if (this.inputValue !== this.elementValue) {
273
+ this.handleInput();
274
+ }
275
+ this.setInputValue();
276
+ if (hasObservers(this.onBlur) || requiresZoneOnBlur(this.control)) {
277
+ this.ngZone.run(() => {
278
+ this.ngTouched();
279
+ this.onBlur.emit();
280
+ });
281
+ }
282
+ };
283
+ /**
284
+ * @hidden
285
+ */
286
+ this.handleKeyDown = (e) => {
287
+ if (this.isDisabled) {
288
+ return;
289
+ }
290
+ let step;
291
+ if (e.keyCode === Keys.ArrowDown) {
292
+ step = -1;
293
+ }
294
+ else if (e.keyCode === Keys.ArrowUp) {
295
+ step = 1;
296
+ }
297
+ if (step && this.step) {
298
+ e.preventDefault();
299
+ this.addStep(step);
300
+ }
301
+ const input = this.numericInput.nativeElement;
302
+ this.previousSelection = {
303
+ end: input.selectionEnd,
304
+ start: input.selectionStart
305
+ };
306
+ this.pressedKey = e.keyCode;
307
+ };
308
+ /**
309
+ * @hidden
310
+ */
311
+ this.handleWheel = (e) => {
312
+ if (this.focused && !this.isDisabled && this.changeValueOnScroll) {
313
+ e.preventDefault();
314
+ const delta = getDeltaFromMouseWheel(e);
315
+ this.addStep(delta);
316
+ }
317
+ };
318
+ validatePackage(packageMetadata);
319
+ this.direction = localizationService.rtl ? 'rtl' : 'ltr';
320
+ }
321
+ /**
322
+ * Specifies the number format which is used when the NumericTextBox is not focused
323
+ * ([see example]({% slug formats_numerictextbox %})).
324
+ * If `format` is set to `null` or `undefined`, the default format will be used.
325
+ */
326
+ get format() {
327
+ const format = this._format;
328
+ return format !== null && format !== undefined ? format : 'n2';
329
+ }
330
+ set format(value) {
331
+ this._format = value;
332
+ }
333
+ /**
334
+ * @hidden
335
+ */
336
+ set tabIndex(tabIndex) {
337
+ this.tabindex = tabIndex;
338
+ }
339
+ get tabIndex() {
340
+ return this.tabindex;
341
+ }
342
+ /**
343
+ * The size property specifies padding of the NumericTextBox internal input element
344
+ * ([see example]({% slug appearance_numerictextbox %}#toc-size)).
345
+ * The possible values are:
346
+ * * `small`
347
+ * * `medium` (default)
348
+ * * `large`
349
+ * * `none`
350
+ */
351
+ set size(size) {
352
+ const newSize = size ? size : DEFAULT_SIZE;
353
+ this.handleClasses(newSize, 'size');
354
+ this._size = newSize;
355
+ }
356
+ get size() {
357
+ return this._size;
358
+ }
359
+ /**
360
+ * The rounded property specifies the border radius of the NumericTextBox
361
+ * ([see example]({% slug appearance_numerictextbox %}#toc-rounded)).
362
+ * The possible values are:
363
+ * * `small`
364
+ * * `medium` (default)
365
+ * * `large`
366
+ * * `none`
367
+ */
368
+ set rounded(rounded) {
369
+ const newRounded = rounded ? rounded : DEFAULT_ROUNDED;
370
+ this.handleClasses(newRounded, 'rounded');
371
+ this._rounded = newRounded;
372
+ }
373
+ get rounded() {
374
+ return this._rounded;
375
+ }
376
+ /**
377
+ * The fillMode property specifies the background and border styles of the NumericTextBox
378
+ * ([see example]({% slug appearance_numerictextbox %}#toc-fillMode)).
379
+ * The possible values are:
380
+ * * `flat`
381
+ * * `solid` (default)
382
+ * * `outline`
383
+ * * `none`
384
+ */
385
+ set fillMode(fillMode) {
386
+ const newFillMode = fillMode ? fillMode : DEFAULT_FILL_MODE;
387
+ this.handleClasses(newFillMode, 'fillMode');
388
+ this._fillMode = newFillMode;
389
+ }
390
+ get fillMode() {
391
+ return this._fillMode;
392
+ }
393
+ get disableClass() {
394
+ return this.disabled;
395
+ }
396
+ ngOnInit() {
397
+ this.subscriptions = this.localizationService
398
+ .changes
399
+ .subscribe(({ rtl }) => {
400
+ this.direction = rtl ? 'rtl' : 'ltr';
401
+ });
402
+ this.subscriptions.add(this.intl.changes.subscribe(this.intlChange.bind(this)));
403
+ if (this.hostElement) {
404
+ this.renderer.removeAttribute(this.hostElement.nativeElement, "tabindex");
405
+ }
406
+ this.control = this.injector.get(NgControl, null);
407
+ this.ngZone.runOutsideAngular(() => {
408
+ this.domEvents.push(this.renderer.listen(this.hostElement.nativeElement, 'mousewheel', this.handleWheel.bind(this)));
409
+ this.domEvents.push(this.renderer.listen(this.hostElement.nativeElement, 'DOMMouseScroll', this.handleWheel.bind(this)));
410
+ });
411
+ }
412
+ ngAfterViewInit() {
413
+ const stylingInputs = ['size', 'rounded', 'fillMode'];
414
+ stylingInputs.forEach(input => {
415
+ this.handleClasses(this[input], input);
416
+ });
417
+ }
418
+ /**
419
+ * @hidden
420
+ */
421
+ ngOnChanges(changes) {
422
+ if (anyChanged(PARSABLE_OPTIONS, changes, false)) {
423
+ this.parseOptions(PARSABLE_OPTIONS.filter(option => changes[option]));
424
+ }
425
+ this.verifySettings();
426
+ if (anyChanged(['min', 'max', 'rangeValidation'], changes, false)) {
427
+ this.minValidateFn = this.rangeValidation ? createMinValidator(this.min) : noop;
428
+ this.maxValidateFn = this.rangeValidation ? createMaxValidator(this.max) : noop;
429
+ this.ngValidatorChange();
430
+ }
431
+ if (anyChanged(['autoCorrect', 'decimals', 'min'], changes)) {
432
+ delete this.numericRegex;
433
+ }
434
+ if (anyChanged(['value', 'format'], changes, false)) {
435
+ this.verifyValue(this.value);
436
+ this.value = this.restrictModelValue(this.value);
437
+ if (!this.focused || (this.intl.parseNumber(this.elementValue) !== this.value)) {
438
+ this.setInputValue();
439
+ }
440
+ }
441
+ }
442
+ /**
443
+ * @hidden
444
+ */
445
+ ngOnDestroy() {
446
+ if (this.subscriptions) {
447
+ this.subscriptions.unsubscribe();
448
+ }
449
+ clearTimeout(this.spinTimeout);
450
+ this.domEvents.forEach(unbindHandler => unbindHandler());
451
+ }
452
+ /**
453
+ * @hidden
454
+ */
455
+ validate(control) {
456
+ return this.minValidateFn(control) || this.maxValidateFn(control);
457
+ }
458
+ /**
459
+ * @hidden
460
+ */
461
+ registerOnValidatorChange(fn) {
462
+ this.ngValidatorChange = fn;
463
+ }
464
+ /**
465
+ * @hidden
466
+ */
467
+ writeValue(value) {
468
+ this.verifyValue(value);
469
+ const restrictedValue = this.restrictModelValue(value);
470
+ this.value = restrictedValue;
471
+ this.setInputValue();
472
+ }
473
+ /**
474
+ * @hidden
475
+ */
476
+ registerOnChange(fn) {
477
+ this.ngChange = fn;
478
+ }
479
+ /**
480
+ * @hidden
481
+ */
482
+ registerOnTouched(fn) {
483
+ this.ngTouched = fn;
484
+ }
485
+ /**
486
+ * @hidden
487
+ * Called when the status of the component changes to or from `disabled`.
488
+ * Depending on the value, it enables or disables the appropriate DOM element.
489
+ *
490
+ * @param isDisabled
491
+ */
492
+ setDisabledState(isDisabled) {
493
+ this.changeDetector.markForCheck();
494
+ this.disabled = isDisabled;
495
+ }
496
+ /**
497
+ * Focuses the NumericTextBox.
498
+ *
499
+ * @example
500
+ * ```ts-no-run
501
+ * _@Component({
502
+ * selector: 'my-app',
503
+ * template: `
504
+ * <button (click)="numerictextbox.focus()">Focus NumericTextBox</button>
505
+ * <kendo-numerictextbox #numerictextbox></kendo-numerictextbox>
506
+ * `
507
+ * })
508
+ * class AppComponent { }
509
+ * ```
510
+ */
511
+ focus() {
512
+ invokeElementMethod(this.numericInput, 'focus');
513
+ }
514
+ /**
515
+ * Blurs the NumericTextBox.
516
+ */
517
+ blur() {
518
+ invokeElementMethod(this.numericInput, 'blur');
519
+ }
520
+ /**
521
+ * Notifies the `NumericTextBoxComponent` that the input value should be changed.
522
+ * Can be used to update the input after setting the component properties directly.
523
+ */
524
+ notifyValueChange() {
525
+ this.setInputValue();
526
+ }
527
+ /**
528
+ * @hidden
529
+ */
530
+ get incrementTitle() {
531
+ return this.localizationService.get('increment');
532
+ }
533
+ /**
534
+ * @hidden
535
+ */
536
+ get decrementTitle() {
537
+ return this.localizationService.get('decrement');
538
+ }
539
+ /**
540
+ * @hidden
541
+ */
542
+ get isControlInvalid() {
543
+ return this.control && this.control.touched && !this.control.valid;
544
+ }
545
+ get decimalSeparator() {
546
+ const numberSymbols = this.intl.numberSymbols();
547
+ return numberSymbols.decimal;
548
+ }
549
+ get elementValue() {
550
+ return this.numericInput.nativeElement.value;
551
+ }
552
+ set elementValue(value) {
553
+ this.renderer.setProperty(this.numericInput.nativeElement, 'value', value);
554
+ }
555
+ get focused() {
556
+ return this.isFocused;
557
+ }
558
+ set focused(value) {
559
+ if (this.isFocused !== value && this.hostElement) {
560
+ const wrap = this.hostElement.nativeElement;
561
+ if (value) {
562
+ this.renderer.addClass(wrap, FOCUSED);
563
+ }
564
+ else {
565
+ this.renderer.removeClass(wrap, FOCUSED);
566
+ }
567
+ this.isFocused = value;
568
+ }
569
+ }
570
+ get hasDecimals() {
571
+ return this.decimals !== null && this.decimals >= 0;
572
+ }
573
+ get isDisabled() {
574
+ return this.disabled || this.readonly;
575
+ }
576
+ arrowPress(direction, e) {
577
+ e.preventDefault();
578
+ if (this.isDisabled || isRightClick(e)) {
579
+ return;
580
+ }
581
+ if (!mobileOS) {
582
+ this.focused = true;
583
+ this.focus();
584
+ }
585
+ if (this.arrowDirection !== direction) {
586
+ this.arrowDirection = direction;
587
+ this.changeDetector.detectChanges();
588
+ }
589
+ if (this.step) {
590
+ this.spin(direction, INITIAL_SPIN_DELAY);
591
+ }
592
+ else {
593
+ this.setInputValue();
594
+ }
595
+ }
596
+ updateValue(value) {
597
+ if (!areSame(this.value, value)) {
598
+ this.ngZone.run(() => {
599
+ this.value = value;
600
+ this.ngChange(value);
601
+ this.valueChange.emit(value);
602
+ this.changeDetector.markForCheck();
603
+ });
604
+ }
605
+ }
606
+ replaceNumpadDotValue() {
607
+ let value = this.inputValue || "";
608
+ if (this.previousSelection) {
609
+ const input = this.numericInput.nativeElement;
610
+ const { selectionStart, selectionEnd } = input;
611
+ const { start, end } = this.previousSelection;
612
+ input.value = value = value.substring(0, start) + this.decimalSeparator + value.substring(end);
613
+ this.setSelection(selectionStart, selectionEnd);
614
+ }
615
+ return value;
616
+ }
617
+ isValid(value) {
618
+ if (!this.numericRegex) {
619
+ this.numericRegex = numericRegex({
620
+ autoCorrect: this.autoCorrect,
621
+ decimals: this.decimals,
622
+ min: this.min,
623
+ separator: this.decimalSeparator
624
+ });
625
+ }
626
+ return this.numericRegex.test(value);
627
+ }
628
+ spin(step, timeout) {
629
+ clearTimeout(this.spinTimeout);
630
+ this.spinTimeout = window.setTimeout(() => {
631
+ this.spin(step, SPIN_DELAY);
632
+ }, timeout);
633
+ this.addStep(step);
634
+ }
635
+ addStep(step) {
636
+ let value = add(this.value || 0, this.step * step);
637
+ value = this.limitValue(value);
638
+ value = this.restrictDecimals(value);
639
+ this.setInputValue(value);
640
+ this.updateValue(value);
641
+ }
642
+ setSelection(start, end) {
643
+ if (this.focused) {
644
+ invokeElementMethod(this.numericInput, 'setSelectionRange', start, end);
645
+ }
646
+ }
647
+ limitValue(value) {
648
+ let result = value;
649
+ if (!this.isInRange(value)) {
650
+ if (isNumber(this.max) && value > this.max) {
651
+ result = this.max;
652
+ }
653
+ if (isNumber(this.min) && value < this.min) {
654
+ result = this.min;
655
+ }
656
+ }
657
+ return result;
658
+ }
659
+ limitInputValue(value) {
660
+ const { selectionStart, selectionEnd, value: enteredValue } = this.numericInput.nativeElement;
661
+ let limitedValue = value;
662
+ let selectToEnd = false;
663
+ if (!this.isInRange(value)) {
664
+ const lengthChange = enteredValue.length - String(this.inputValue).length;
665
+ const { min, max } = this;
666
+ const hasMax = isNumber(max);
667
+ const hasMin = isNumber(min);
668
+ let padLimit, replaceNext;
669
+ let correctedValue = value;
670
+ if (selectionStart === 0 && this.inputValue.substr(1) === enteredValue) {
671
+ return {
672
+ selectionEnd: selectionEnd,
673
+ selectionStart: selectionStart,
674
+ value: null
675
+ };
676
+ }
677
+ if (hasMax && value > max) {
678
+ if (value > 0) {
679
+ replaceNext = true;
680
+ }
681
+ else {
682
+ padLimit = max;
683
+ }
684
+ }
685
+ else if (hasMin && value < min) {
686
+ if (value > 0) {
687
+ padLimit = min;
688
+ }
689
+ else {
690
+ replaceNext = true;
691
+ }
692
+ }
693
+ if (padLimit) {
694
+ const paddedValue = this.tryPadValue(value, padLimit);
695
+ if (paddedValue && decimalPart(value) !== decimalPart(padLimit)) {
696
+ correctedValue = paddedValue;
697
+ selectToEnd = true;
698
+ }
699
+ }
700
+ else if (replaceNext) {
701
+ if (this.inputValue && selectionStart !== enteredValue.length) {
702
+ correctedValue = parseFloat(enteredValue.substr(0, selectionStart) +
703
+ enteredValue.substr(selectionStart + lengthChange));
704
+ }
705
+ }
706
+ limitedValue = this.limitValue(correctedValue);
707
+ selectToEnd = (selectToEnd || limitedValue !== correctedValue) && this.previousSelection &&
708
+ (this.previousSelection.end - this.previousSelection.start + lengthChange) > 0;
709
+ }
710
+ return {
711
+ selectionEnd: selectToEnd ? String(limitedValue).length : selectionEnd,
712
+ selectionStart: selectionStart,
713
+ value: limitedValue
714
+ };
715
+ }
716
+ tryPadValue(value, limit) {
717
+ const limitLength = String(Math.floor(limit)).length;
718
+ const zeroPadded = pad(value, limitLength);
719
+ const zeroPaddedNext = pad(value, limitLength + 1);
720
+ let result;
721
+ if (this.isInRange(zeroPadded)) {
722
+ result = zeroPadded;
723
+ }
724
+ else if (this.isInRange(zeroPaddedNext)) {
725
+ result = zeroPaddedNext;
726
+ }
727
+ return result;
728
+ }
729
+ isInRange(value) {
730
+ return !isNumber(value) || ((!isNumber(this.min) || this.min <= value) && (!isNumber(this.max) || value <= this.max));
731
+ }
732
+ restrictModelValue(value) {
733
+ let result = this.restrictDecimals(value, true);
734
+ if (this.autoCorrect && this.limitValue(result) !== result) {
735
+ result = null;
736
+ }
737
+ return result;
738
+ }
739
+ restrictDecimals(value, round) {
740
+ let result = value;
741
+ if (value && this.hasDecimals) {
742
+ const decimals = this.decimals;
743
+ const stringValue = String(value);
744
+ if (round || EXPONENT_REGEX.test(stringValue)) {
745
+ result = toFixedPrecision(value, decimals);
746
+ }
747
+ else {
748
+ const parts = stringValue.split(POINT);
749
+ let fraction = parts[1];
750
+ if (fraction && fraction.length > decimals) {
751
+ fraction = fraction.substr(0, decimals);
752
+ result = parseFloat(`${parts[0]}${POINT}${fraction}`);
753
+ }
754
+ }
755
+ }
756
+ return result;
757
+ }
758
+ formatInputValue(value) {
759
+ let stringValue = Object.is(value, -0) ? '-0' : String(value);
760
+ const exponentMatch = EXPONENT_REGEX.exec(stringValue);
761
+ if (exponentMatch) {
762
+ stringValue = value.toFixed(limitPrecision(parseInt(exponentMatch[1], 10)));
763
+ }
764
+ return stringValue.replace(POINT, this.decimalSeparator);
765
+ }
766
+ formatValue(value, focused) {
767
+ let formattedValue;
768
+ if (value === null || !defined(value) || value === '') {
769
+ formattedValue = '';
770
+ }
771
+ else if (focused && !this.readonly) {
772
+ formattedValue = this.formatInputValue(value);
773
+ }
774
+ else {
775
+ formattedValue = this.intl.formatNumber(value, this.format);
776
+ }
777
+ return formattedValue;
778
+ }
779
+ setInputValue(value = this.value, focused = this.focused) {
780
+ const formattedValue = this.formatValue(value, focused);
781
+ this.elementValue = formattedValue;
782
+ this.inputValue = formattedValue;
783
+ }
784
+ verifySettings() {
785
+ if (!isDevMode()) {
786
+ return;
787
+ }
788
+ if (this.min !== null && this.max !== null && this.min > this.max) {
789
+ throw new Error(`The max value should be bigger than the min. See ${MIN_DOC_LINK} and ${MAX_DOC_LINK}.`);
790
+ }
791
+ }
792
+ verifyValue(value) {
793
+ if (isDevMode() && value && typeof value !== 'number') {
794
+ throw new Error(`The NumericTextBox component requires value of type Number and ${JSON.stringify(value)} was set.`);
795
+ }
796
+ }
797
+ parseOptions(options) {
798
+ for (let idx = 0; idx < options.length; idx++) {
799
+ const name = options[idx];
800
+ const value = this[name];
801
+ if (typeof value === 'string') {
802
+ const parsed = parseFloat(value);
803
+ const valid = !isNaN(parsed);
804
+ if (isDevMode() && !valid && value !== '') {
805
+ throw new Error('The NumericTextBox component requires value of type Number or a String representing ' +
806
+ `a number for the ${name} property and ${JSON.stringify(value)} was set.`);
807
+ }
808
+ this[name] = valid ? parsed : PARSABLE_DEFAULTS[name];
809
+ }
810
+ }
811
+ }
812
+ intlChange() {
813
+ delete this.numericRegex;
814
+ if (this.numericInput && (!this.focused || !this.isValid(this.elementValue))) {
815
+ this.setInputValue();
816
+ }
817
+ }
818
+ hasTrailingZeros(inputValue) {
819
+ if (this.hasDecimals && this.focused) {
820
+ const fraction = inputValue.split(this.decimalSeparator)[1];
821
+ return fraction && fraction.length > this.decimals && fraction.lastIndexOf('0') === fraction.length - 1;
822
+ }
823
+ }
824
+ selectAll() {
825
+ this.setInputValue();
826
+ this.setSelection(0, this.inputValue.length);
827
+ }
828
+ selectCaret() {
829
+ const caretPosition = getCaretPosition(this.numericInput.nativeElement);
830
+ const formattedValue = this.elementValue;
831
+ const partialValue = formattedValue.substring(0, caretPosition);
832
+ this.setInputValue();
833
+ if (partialValue.length) {
834
+ const significantCharsInFormattedValue = extractSignificantNumericChars(partialValue, this.decimalSeparator);
835
+ const adjustedSignificantChars = this.adjustSignificantChars(formattedValue, significantCharsInFormattedValue);
836
+ this.setSelection(adjustedSignificantChars, adjustedSignificantChars);
837
+ }
838
+ else {
839
+ this.setSelection(0, 0);
840
+ }
841
+ }
842
+ numberOfLeadingZeroes(formattedValue) {
843
+ const separatorIndex = formattedValue.indexOf(this.decimalSeparator);
844
+ const matchedLeadingZeroes = formattedValue.match(/^[^1-9]*?(0+)/);
845
+ if (matchedLeadingZeroes) {
846
+ const lengthOfMatch = matchedLeadingZeroes[0].length;
847
+ const lengthOfLeadingZeroesMatch = matchedLeadingZeroes[1].length;
848
+ return lengthOfMatch === separatorIndex ? lengthOfLeadingZeroesMatch - 1 : lengthOfLeadingZeroesMatch;
849
+ }
850
+ return 0;
851
+ }
852
+ adjustSignificantChars(formattedValue, significantChars) {
853
+ const leadingZeroes = this.numberOfLeadingZeroes(formattedValue);
854
+ if (leadingZeroes > 0) {
855
+ return Math.max(0, significantChars - leadingZeroes);
856
+ }
857
+ return significantChars;
858
+ }
859
+ handleClasses(value, input) {
860
+ const elem = this.hostElement.nativeElement;
861
+ const classes = getStylingClasses('input', input, this[input], value);
862
+ if (classes.toRemove) {
863
+ this.renderer.removeClass(elem, classes.toRemove);
864
+ }
865
+ if (classes.toAdd) {
866
+ this.renderer.addClass(elem, classes.toAdd);
867
+ }
868
+ }
869
+ }
870
+ NumericTextBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: NumericTextBoxComponent, deps: [{ token: i1.IntlService }, { token: i0.Renderer2 }, { token: i2.LocalizationService }, { token: i0.Injector }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
871
+ NumericTextBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: NumericTextBoxComponent, selector: "kendo-numerictextbox", inputs: { focusableId: "focusableId", disabled: "disabled", readonly: "readonly", title: "title", autoCorrect: "autoCorrect", format: "format", max: "max", min: "min", decimals: "decimals", placeholder: "placeholder", step: "step", spinners: "spinners", rangeValidation: "rangeValidation", tabindex: "tabindex", tabIndex: "tabIndex", changeValueOnScroll: "changeValueOnScroll", selectOnFocus: "selectOnFocus", value: "value", maxlength: "maxlength", size: "size", rounded: "rounded", fillMode: "fillMode" }, outputs: { valueChange: "valueChange", onFocus: "focus", onBlur: "blur" }, host: { properties: { "attr.dir": "this.direction", "class.k-disabled": "this.disableClass", "class.k-input": "this.hostClasses", "class.k-numerictextbox": "this.hostClasses" } }, providers: [
872
+ LocalizationService,
873
+ { provide: L10N_PREFIX, useValue: 'kendo.numerictextbox' },
874
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NumericTextBoxComponent), multi: true },
875
+ { provide: NG_VALIDATORS, useExisting: forwardRef(() => NumericTextBoxComponent), multi: true },
876
+ { provide: KendoInput, useExisting: forwardRef(() => NumericTextBoxComponent) }
877
+ ], viewQueries: [{ propertyName: "numericInput", first: true, predicate: ["numericInput"], descendants: true, static: true }], exportAs: ["kendoNumericTextBox"], usesOnChanges: true, ngImport: i0, template: `
878
+ <ng-container kendoNumericTextBoxLocalizedMessages
879
+ i18n-increment="kendo.numerictextbox.increment|The title for the **Increment** button in the NumericTextBox"
880
+ increment="Increase value"
881
+ i18n-decrement="kendo.numerictextbox.decrement|The title for the **Decrement** button in the NumericTextBox"
882
+ decrement="Decrease value"
883
+ >
884
+ </ng-container>
885
+ <input
886
+ role="spinbutton"
887
+ class="k-input-inner"
888
+ autocomplete="off"
889
+ autocorrect="off"
890
+ [id]="focusableId"
891
+ [attr.aria-valuemin]="min"
892
+ [attr.aria-valuemax]="max"
893
+ [attr.aria-valuenow]="value"
894
+ [attr.title]="title"
895
+ [attr.placeholder]="placeholder"
896
+ [attr.maxLength]="maxlength"
897
+ [attr.aria-invalid]="isControlInvalid"
898
+ [tabindex]="tabIndex"
899
+ [disabled]="disabled"
900
+ [readonly]="readonly"
901
+ [kendoEventsOutsideAngular]="{
902
+ mousedown: handleMouseDown,
903
+ dragenter: handleDragEnter,
904
+ keydown: handleKeyDown,
905
+ input: handleInput,
906
+ focus: handleFocus,
907
+ blur: handleBlur,
908
+ paste: handlePaste
909
+ }"
910
+ #numericInput />
911
+ <span
912
+ class="k-input-spinner k-spin-button" *ngIf="spinners"
913
+ [kendoEventsOutsideAngular]="{ mouseup: releaseArrow, mouseleave: releaseArrow }"
914
+ >
915
+ <button
916
+ type="button"
917
+ [kendoEventsOutsideAngular]="{ mousedown: increasePress }"
918
+ [attr.aria-hidden]="true"
919
+ [attr.aria-label]="incrementTitle"
920
+ [title]="incrementTitle"
921
+ class="k-spinner-increase k-button k-icon-button k-button-solid k-button-solid-base"
922
+ [class.k-active]="arrowDirection === ArrowDirection.Up"
923
+ tabindex="-1"
924
+ >
925
+ <kendo-icon-wrapper
926
+ name="caret-alt-up"
927
+ innerCssClass="k-button-icon"
928
+ [svgIcon]="arrowUpIcon"
929
+ >
930
+ </kendo-icon-wrapper>
931
+ </button>
932
+ <button
933
+ type="button"
934
+ [kendoEventsOutsideAngular]="{ mousedown: decreasePress }"
935
+ [attr.aria-hidden]="true"
936
+ [attr.aria-label]="decrementTitle"
937
+ [title]="decrementTitle"
938
+ [class.k-active]="arrowDirection === ArrowDirection.Down"
939
+ class="k-spinner-decrease k-button k-icon-button k-button-solid k-button-solid-base"
940
+ tabindex="-1"
941
+ >
942
+ <kendo-icon-wrapper
943
+ name="caret-alt-down"
944
+ innerCssClass="k-button-icon"
945
+ [svgIcon]="arrowDownIcon"
946
+ >
947
+ </kendo-icon-wrapper>
948
+ </button>
949
+ </span>
950
+ `, isInline: true, components: [{ type: i3.IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }], directives: [{ type: i4.LocalizedNumericTextBoxMessagesDirective, selector: "[kendoNumericTextBoxLocalizedMessages]" }, { type: i5.EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
951
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: NumericTextBoxComponent, decorators: [{
952
+ type: Component,
953
+ args: [{
954
+ exportAs: 'kendoNumericTextBox',
955
+ providers: [
956
+ LocalizationService,
957
+ { provide: L10N_PREFIX, useValue: 'kendo.numerictextbox' },
958
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NumericTextBoxComponent), multi: true },
959
+ { provide: NG_VALIDATORS, useExisting: forwardRef(() => NumericTextBoxComponent), multi: true },
960
+ { provide: KendoInput, useExisting: forwardRef(() => NumericTextBoxComponent) }
961
+ ],
962
+ selector: 'kendo-numerictextbox',
963
+ template: `
964
+ <ng-container kendoNumericTextBoxLocalizedMessages
965
+ i18n-increment="kendo.numerictextbox.increment|The title for the **Increment** button in the NumericTextBox"
966
+ increment="Increase value"
967
+ i18n-decrement="kendo.numerictextbox.decrement|The title for the **Decrement** button in the NumericTextBox"
968
+ decrement="Decrease value"
969
+ >
970
+ </ng-container>
971
+ <input
972
+ role="spinbutton"
973
+ class="k-input-inner"
974
+ autocomplete="off"
975
+ autocorrect="off"
976
+ [id]="focusableId"
977
+ [attr.aria-valuemin]="min"
978
+ [attr.aria-valuemax]="max"
979
+ [attr.aria-valuenow]="value"
980
+ [attr.title]="title"
981
+ [attr.placeholder]="placeholder"
982
+ [attr.maxLength]="maxlength"
983
+ [attr.aria-invalid]="isControlInvalid"
984
+ [tabindex]="tabIndex"
985
+ [disabled]="disabled"
986
+ [readonly]="readonly"
987
+ [kendoEventsOutsideAngular]="{
988
+ mousedown: handleMouseDown,
989
+ dragenter: handleDragEnter,
990
+ keydown: handleKeyDown,
991
+ input: handleInput,
992
+ focus: handleFocus,
993
+ blur: handleBlur,
994
+ paste: handlePaste
995
+ }"
996
+ #numericInput />
997
+ <span
998
+ class="k-input-spinner k-spin-button" *ngIf="spinners"
999
+ [kendoEventsOutsideAngular]="{ mouseup: releaseArrow, mouseleave: releaseArrow }"
1000
+ >
1001
+ <button
1002
+ type="button"
1003
+ [kendoEventsOutsideAngular]="{ mousedown: increasePress }"
1004
+ [attr.aria-hidden]="true"
1005
+ [attr.aria-label]="incrementTitle"
1006
+ [title]="incrementTitle"
1007
+ class="k-spinner-increase k-button k-icon-button k-button-solid k-button-solid-base"
1008
+ [class.k-active]="arrowDirection === ArrowDirection.Up"
1009
+ tabindex="-1"
1010
+ >
1011
+ <kendo-icon-wrapper
1012
+ name="caret-alt-up"
1013
+ innerCssClass="k-button-icon"
1014
+ [svgIcon]="arrowUpIcon"
1015
+ >
1016
+ </kendo-icon-wrapper>
1017
+ </button>
1018
+ <button
1019
+ type="button"
1020
+ [kendoEventsOutsideAngular]="{ mousedown: decreasePress }"
1021
+ [attr.aria-hidden]="true"
1022
+ [attr.aria-label]="decrementTitle"
1023
+ [title]="decrementTitle"
1024
+ [class.k-active]="arrowDirection === ArrowDirection.Down"
1025
+ class="k-spinner-decrease k-button k-icon-button k-button-solid k-button-solid-base"
1026
+ tabindex="-1"
1027
+ >
1028
+ <kendo-icon-wrapper
1029
+ name="caret-alt-down"
1030
+ innerCssClass="k-button-icon"
1031
+ [svgIcon]="arrowDownIcon"
1032
+ >
1033
+ </kendo-icon-wrapper>
1034
+ </button>
1035
+ </span>
1036
+ `
1037
+ }]
1038
+ }], ctorParameters: function () { return [{ type: i1.IntlService }, { type: i0.Renderer2 }, { type: i2.LocalizationService }, { type: i0.Injector }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { focusableId: [{
1039
+ type: Input
1040
+ }], disabled: [{
1041
+ type: Input
1042
+ }], readonly: [{
1043
+ type: Input
1044
+ }], title: [{
1045
+ type: Input
1046
+ }], autoCorrect: [{
1047
+ type: Input
1048
+ }], format: [{
1049
+ type: Input
1050
+ }], max: [{
1051
+ type: Input
1052
+ }], min: [{
1053
+ type: Input
1054
+ }], decimals: [{
1055
+ type: Input
1056
+ }], placeholder: [{
1057
+ type: Input
1058
+ }], step: [{
1059
+ type: Input
1060
+ }], spinners: [{
1061
+ type: Input
1062
+ }], rangeValidation: [{
1063
+ type: Input
1064
+ }], tabindex: [{
1065
+ type: Input
1066
+ }], tabIndex: [{
1067
+ type: Input
1068
+ }], changeValueOnScroll: [{
1069
+ type: Input
1070
+ }], selectOnFocus: [{
1071
+ type: Input
1072
+ }], value: [{
1073
+ type: Input
1074
+ }], maxlength: [{
1075
+ type: Input
1076
+ }], size: [{
1077
+ type: Input
1078
+ }], rounded: [{
1079
+ type: Input
1080
+ }], fillMode: [{
1081
+ type: Input
1082
+ }], valueChange: [{
1083
+ type: Output
1084
+ }], onFocus: [{
1085
+ type: Output,
1086
+ args: ['focus']
1087
+ }], onBlur: [{
1088
+ type: Output,
1089
+ args: ['blur']
1090
+ }], numericInput: [{
1091
+ type: ViewChild,
1092
+ args: ['numericInput', { static: true }]
1093
+ }], direction: [{
1094
+ type: HostBinding,
1095
+ args: ['attr.dir']
1096
+ }], disableClass: [{
1097
+ type: HostBinding,
1098
+ args: ['class.k-disabled']
1099
+ }], hostClasses: [{
1100
+ type: HostBinding,
1101
+ args: ['class.k-input']
1102
+ }, {
1103
+ type: HostBinding,
1104
+ args: ['class.k-numerictextbox']
1105
+ }] } });