@koobiq/components 16.0.0-beta.6 → 16.0.0-beta.8

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 (331) hide show
  1. package/autocomplete/autocomplete-trigger.directive.d.ts +5 -15
  2. package/button-toggle/_button-toggle-theme.scss +26 -45
  3. package/button-toggle/button-toggle.component.d.ts +2 -2
  4. package/button-toggle/button-toggle.scss +40 -87
  5. package/card/_card-theme.scss +1 -1
  6. package/checkbox/_checkbox-theme.scss +10 -2
  7. package/checkbox/checkbox.d.ts +1 -1
  8. package/code-block/README.md +14 -14
  9. package/code-block/_code-block-theme.scss +8 -0
  10. package/code-block/code-block.component.d.ts +1 -1
  11. package/core/animation/index.d.ts +1 -1
  12. package/core/animation/select-animations.d.ts +1 -1
  13. package/core/formatters/index.d.ts +1 -1
  14. package/core/formatters/number/formatter.d.ts +56 -1
  15. package/core/forms/forms.directive.d.ts +2 -2
  16. package/core/locales/en-US.d.ts +19 -1
  17. package/core/locales/es-LA.d.ts +27 -0
  18. package/core/locales/fa-IR.d.ts +28 -0
  19. package/core/locales/locale-service.d.ts +148 -3
  20. package/core/locales/pt-BR.d.ts +27 -0
  21. package/core/locales/ru-RU.d.ts +20 -1
  22. package/core/locales/zh-CN.d.ts +26 -0
  23. package/core/option/_optgroup-theme.scss +1 -1
  24. package/core/option/_option-theme.scss +2 -2
  25. package/core/option/action.d.ts +1 -1
  26. package/core/option/optgroup.d.ts +1 -1
  27. package/core/option/option.d.ts +37 -8
  28. package/core/option/option.scss +4 -4
  29. package/core/overlay/overlay-position-map.d.ts +7 -1
  30. package/core/pop-up/constants.d.ts +2 -1
  31. package/core/public-api.d.ts +1 -0
  32. package/core/select/constants.d.ts +2 -2
  33. package/core/services/theme.service.d.ts +23 -0
  34. package/core/styles/_koobiq-theme.scss +6 -0
  35. package/core/styles/_variables.scss +1 -0
  36. package/core/styles/common/_animation.scss +10 -6
  37. package/core/styles/common/_overlay.scss +1 -1
  38. package/core/styles/common/_select.scss +79 -65
  39. package/core/styles/theming/_components-theming.scss +205 -23
  40. package/core/styles/theming/_theming.scss +2 -2
  41. package/datepicker/_datepicker-theme.scss +43 -57
  42. package/datepicker/calendar-body.component.d.ts +1 -1
  43. package/datepicker/calendar-body.scss +11 -26
  44. package/datepicker/calendar-header.component.d.ts +9 -3
  45. package/datepicker/calendar-header.scss +7 -31
  46. package/datepicker/calendar.component.d.ts +4 -5
  47. package/datepicker/calendar.scss +20 -25
  48. package/datepicker/datepicker-animations.d.ts +1 -1
  49. package/datepicker/datepicker-content.scss +17 -10
  50. package/datepicker/datepicker-input.directive.d.ts +4 -4
  51. package/datepicker/datepicker-input.scss +1 -1
  52. package/datepicker/datepicker-toggle.component.d.ts +3 -3
  53. package/datepicker/datepicker.component.d.ts +2 -2
  54. package/datepicker/month-view.component.d.ts +5 -6
  55. package/dl/_dl-theme.scss +2 -56
  56. package/dl/dl.component.d.ts +1 -2
  57. package/dl/dl.scss +10 -47
  58. package/dropdown/_dropdown-theme.scss +2 -2
  59. package/dropdown/dropdown-animations.d.ts +1 -1
  60. package/dropdown/dropdown-content.directive.d.ts +1 -1
  61. package/dropdown/dropdown-item.component.d.ts +1 -1
  62. package/dropdown/dropdown-item.scss +1 -1
  63. package/dropdown/dropdown-trigger.directive.d.ts +2 -2
  64. package/dropdown/dropdown.component.d.ts +1 -1
  65. package/dropdown/dropdown.types.d.ts +1 -1
  66. package/esm2022/alert/alert.component.mjs +2 -2
  67. package/esm2022/autocomplete/autocomplete-trigger.directive.mjs +27 -24
  68. package/esm2022/button/button.component.mjs +3 -2
  69. package/esm2022/button-toggle/button-toggle.component.mjs +15 -15
  70. package/esm2022/checkbox/checkbox.mjs +3 -3
  71. package/esm2022/code-block/actionbar.component.mjs +1 -1
  72. package/esm2022/code-block/code-block.component.mjs +3 -3
  73. package/esm2022/core/animation/index.mjs +2 -2
  74. package/esm2022/core/animation/select-animations.mjs +4 -4
  75. package/esm2022/core/formatters/index.mjs +10 -2
  76. package/esm2022/core/formatters/number/formatter.mjs +224 -3
  77. package/esm2022/core/forms/forms.directive.mjs +5 -5
  78. package/esm2022/core/locales/en-US.mjs +22 -4
  79. package/esm2022/core/locales/es-LA.mjs +31 -2
  80. package/esm2022/core/locales/fa-IR.mjs +30 -2
  81. package/esm2022/core/locales/locale-service.mjs +4 -4
  82. package/esm2022/core/locales/pt-BR.mjs +29 -2
  83. package/esm2022/core/locales/ru-RU.mjs +23 -2
  84. package/esm2022/core/locales/zh-CN.mjs +28 -2
  85. package/esm2022/core/option/action.mjs +3 -3
  86. package/esm2022/core/option/optgroup.mjs +3 -3
  87. package/esm2022/core/option/option.mjs +47 -10
  88. package/esm2022/core/overlay/overlay-position-map.mjs +7 -1
  89. package/esm2022/core/pop-up/constants.mjs +2 -1
  90. package/esm2022/core/pop-up/pop-up-trigger.mjs +12 -3
  91. package/esm2022/core/public-api.mjs +2 -1
  92. package/esm2022/core/select/constants.mjs +3 -3
  93. package/esm2022/core/services/theme.service.mjs +60 -0
  94. package/esm2022/core/version.mjs +2 -2
  95. package/esm2022/datepicker/calendar-body.component.mjs +7 -5
  96. package/esm2022/datepicker/calendar-header.component.mjs +9 -8
  97. package/esm2022/datepicker/calendar.component.mjs +8 -17
  98. package/esm2022/datepicker/datepicker-animations.mjs +2 -2
  99. package/esm2022/datepicker/datepicker-input.directive.mjs +29 -20
  100. package/esm2022/datepicker/datepicker-toggle.component.mjs +6 -6
  101. package/esm2022/datepicker/datepicker.component.mjs +12 -12
  102. package/esm2022/datepicker/month-view.component.mjs +9 -18
  103. package/esm2022/dl/dl.component.mjs +3 -7
  104. package/esm2022/dropdown/dropdown-animations.mjs +4 -4
  105. package/esm2022/dropdown/dropdown-content.directive.mjs +3 -3
  106. package/esm2022/dropdown/dropdown-errors.mjs +6 -6
  107. package/esm2022/dropdown/dropdown-item.component.mjs +5 -5
  108. package/esm2022/dropdown/dropdown-trigger.directive.mjs +10 -9
  109. package/esm2022/dropdown/dropdown.component.mjs +8 -8
  110. package/esm2022/dropdown/dropdown.types.mjs +1 -1
  111. package/esm2022/file-upload/file-drop.mjs +4 -4
  112. package/esm2022/file-upload/multiple-file-upload.component.mjs +13 -9
  113. package/esm2022/file-upload/single-file-upload.component.mjs +16 -13
  114. package/esm2022/form-field/cleaner.mjs +3 -3
  115. package/esm2022/form-field/form-field.mjs +7 -7
  116. package/esm2022/form-field/hint.mjs +4 -4
  117. package/esm2022/form-field/password-hint.mjs +11 -11
  118. package/esm2022/form-field/password-toggle.mjs +21 -8
  119. package/esm2022/form-field/suffix.mjs +3 -3
  120. package/esm2022/form-field/validate.directive.mjs +4 -4
  121. package/esm2022/input/input-number.mjs +259 -43
  122. package/esm2022/link/link.component.mjs +3 -3
  123. package/esm2022/list/list-selection.component.mjs +8 -8
  124. package/esm2022/list/list.component.mjs +2 -2
  125. package/esm2022/loader-overlay/loader-overlay.component.mjs +2 -2
  126. package/esm2022/modal/modal-control.service.mjs +5 -5
  127. package/esm2022/modal/modal-ref.class.mjs +1 -1
  128. package/esm2022/modal/modal.component.mjs +124 -111
  129. package/esm2022/modal/modal.service.mjs +23 -23
  130. package/esm2022/modal/modal.type.mjs +1 -3
  131. package/esm2022/navbar/navbar-item.component.mjs +6 -6
  132. package/esm2022/navbar/navbar.component.mjs +18 -9
  133. package/esm2022/navbar/vertical-navbar.component.mjs +9 -6
  134. package/esm2022/popover/popover-animations.mjs +2 -2
  135. package/esm2022/popover/popover-confirm.component.mjs +9 -9
  136. package/esm2022/popover/popover.component.mjs +24 -24
  137. package/esm2022/radio/radio.component.mjs +10 -8
  138. package/esm2022/select/select-option.directive.mjs +15 -3
  139. package/esm2022/select/select.component.mjs +37 -21
  140. package/esm2022/sidebar/sidebar-animations.mjs +2 -2
  141. package/esm2022/sidebar/sidebar.component.mjs +9 -9
  142. package/esm2022/sidepanel/sidepanel-container.component.mjs +3 -3
  143. package/esm2022/sidepanel/sidepanel-directives.mjs +2 -2
  144. package/esm2022/splitter/splitter.component.mjs +3 -3
  145. package/esm2022/table/table.component.mjs +3 -3
  146. package/esm2022/tabs/tab-body.component.mjs +7 -7
  147. package/esm2022/tabs/tab-content.directive.mjs +3 -3
  148. package/esm2022/tabs/tab-group.component.mjs +3 -3
  149. package/esm2022/tabs/tab-nav-bar/tab-nav-bar.mjs +6 -6
  150. package/esm2022/tabs/tab.component.mjs +14 -5
  151. package/esm2022/tabs/tabs-animations.mjs +2 -2
  152. package/esm2022/tags/tag-input.mjs +3 -3
  153. package/esm2022/tags/tag-list.component.mjs +5 -5
  154. package/esm2022/tags/tag.component.mjs +10 -10
  155. package/esm2022/timepicker/timepicker.directive.mjs +10 -10
  156. package/esm2022/timezone/timezone-option.component.mjs +4 -4
  157. package/esm2022/timezone/timezone-select.component.mjs +5 -5
  158. package/esm2022/title/title.directive.mjs +5 -5
  159. package/esm2022/toast/toast.module.mjs +10 -4
  160. package/esm2022/toggle/toggle.component.mjs +4 -4
  161. package/esm2022/tooltip/tooltip.component.mjs +18 -17
  162. package/esm2022/tree/control/base-tree-control.mjs +1 -1
  163. package/esm2022/tree/control/flat-tree-control.mjs +4 -4
  164. package/esm2022/tree/control/tree-control.mjs +1 -1
  165. package/esm2022/tree/node.mjs +5 -5
  166. package/esm2022/tree/outlet.mjs +3 -3
  167. package/esm2022/tree/padding.directive.mjs +7 -7
  168. package/esm2022/tree/toggle.mjs +9 -11
  169. package/esm2022/tree/tree-base.mjs +3 -3
  170. package/esm2022/tree/tree-option.component.mjs +8 -5
  171. package/esm2022/tree/tree-selection.component.mjs +8 -6
  172. package/esm2022/tree/tree.mjs +3 -3
  173. package/esm2022/tree-select/tree-select.component.mjs +14 -15
  174. package/fesm2022/koobiq-components-alert.mjs +2 -2
  175. package/fesm2022/koobiq-components-alert.mjs.map +1 -1
  176. package/fesm2022/koobiq-components-autocomplete.mjs +27 -24
  177. package/fesm2022/koobiq-components-autocomplete.mjs.map +1 -1
  178. package/fesm2022/koobiq-components-button-toggle.mjs +14 -14
  179. package/fesm2022/koobiq-components-button-toggle.mjs.map +1 -1
  180. package/fesm2022/koobiq-components-button.mjs +2 -1
  181. package/fesm2022/koobiq-components-button.mjs.map +1 -1
  182. package/fesm2022/koobiq-components-checkbox.mjs +2 -2
  183. package/fesm2022/koobiq-components-checkbox.mjs.map +1 -1
  184. package/fesm2022/koobiq-components-code-block.mjs +3 -3
  185. package/fesm2022/koobiq-components-code-block.mjs.map +1 -1
  186. package/fesm2022/koobiq-components-core.mjs +526 -39
  187. package/fesm2022/koobiq-components-core.mjs.map +1 -1
  188. package/fesm2022/koobiq-components-datepicker.mjs +72 -78
  189. package/fesm2022/koobiq-components-datepicker.mjs.map +1 -1
  190. package/fesm2022/koobiq-components-dl.mjs +2 -6
  191. package/fesm2022/koobiq-components-dl.mjs.map +1 -1
  192. package/fesm2022/koobiq-components-dropdown.mjs +30 -29
  193. package/fesm2022/koobiq-components-dropdown.mjs.map +1 -1
  194. package/fesm2022/koobiq-components-file-upload.mjs +26 -19
  195. package/fesm2022/koobiq-components-file-upload.mjs.map +1 -1
  196. package/fesm2022/koobiq-components-form-field.mjs +46 -34
  197. package/fesm2022/koobiq-components-form-field.mjs.map +1 -1
  198. package/fesm2022/koobiq-components-input.mjs +257 -43
  199. package/fesm2022/koobiq-components-input.mjs.map +1 -1
  200. package/fesm2022/koobiq-components-link.mjs +2 -2
  201. package/fesm2022/koobiq-components-link.mjs.map +1 -1
  202. package/fesm2022/koobiq-components-list.mjs +9 -9
  203. package/fesm2022/koobiq-components-list.mjs.map +1 -1
  204. package/fesm2022/koobiq-components-loader-overlay.mjs +2 -2
  205. package/fesm2022/koobiq-components-loader-overlay.mjs.map +1 -1
  206. package/fesm2022/koobiq-components-modal.mjs +149 -140
  207. package/fesm2022/koobiq-components-modal.mjs.map +1 -1
  208. package/fesm2022/koobiq-components-navbar.mjs +28 -20
  209. package/fesm2022/koobiq-components-navbar.mjs.map +1 -1
  210. package/fesm2022/koobiq-components-popover.mjs +31 -31
  211. package/fesm2022/koobiq-components-popover.mjs.map +1 -1
  212. package/fesm2022/koobiq-components-radio.mjs +9 -7
  213. package/fesm2022/koobiq-components-radio.mjs.map +1 -1
  214. package/fesm2022/koobiq-components-select.mjs +50 -22
  215. package/fesm2022/koobiq-components-select.mjs.map +1 -1
  216. package/fesm2022/koobiq-components-sidebar.mjs +8 -8
  217. package/fesm2022/koobiq-components-sidebar.mjs.map +1 -1
  218. package/fesm2022/koobiq-components-sidepanel.mjs +3 -3
  219. package/fesm2022/koobiq-components-sidepanel.mjs.map +1 -1
  220. package/fesm2022/koobiq-components-splitter.mjs +2 -2
  221. package/fesm2022/koobiq-components-splitter.mjs.map +1 -1
  222. package/fesm2022/koobiq-components-table.mjs +2 -2
  223. package/fesm2022/koobiq-components-table.mjs.map +1 -1
  224. package/fesm2022/koobiq-components-tabs.mjs +29 -20
  225. package/fesm2022/koobiq-components-tabs.mjs.map +1 -1
  226. package/fesm2022/koobiq-components-tags.mjs +15 -15
  227. package/fesm2022/koobiq-components-tags.mjs.map +1 -1
  228. package/fesm2022/koobiq-components-timepicker.mjs +9 -9
  229. package/fesm2022/koobiq-components-timepicker.mjs.map +1 -1
  230. package/fesm2022/koobiq-components-timezone.mjs +7 -7
  231. package/fesm2022/koobiq-components-timezone.mjs.map +1 -1
  232. package/fesm2022/koobiq-components-title.mjs +4 -4
  233. package/fesm2022/koobiq-components-title.mjs.map +1 -1
  234. package/fesm2022/koobiq-components-toast.mjs +8 -2
  235. package/fesm2022/koobiq-components-toast.mjs.map +1 -1
  236. package/fesm2022/koobiq-components-toggle.mjs +3 -3
  237. package/fesm2022/koobiq-components-toggle.mjs.map +1 -1
  238. package/fesm2022/koobiq-components-tooltip.mjs +17 -16
  239. package/fesm2022/koobiq-components-tooltip.mjs.map +1 -1
  240. package/fesm2022/koobiq-components-tree-select.mjs +13 -14
  241. package/fesm2022/koobiq-components-tree-select.mjs.map +1 -1
  242. package/fesm2022/koobiq-components-tree.mjs +42 -38
  243. package/fesm2022/koobiq-components-tree.mjs.map +1 -1
  244. package/file-upload/_file-upload-theme.scss +54 -40
  245. package/file-upload/file-drop.d.ts +1 -1
  246. package/file-upload/file-upload.scss +2 -9
  247. package/file-upload/multiple-file-upload.component.d.ts +4 -3
  248. package/file-upload/multiple-file-upload.component.scss +170 -59
  249. package/file-upload/single-file-upload.component.d.ts +4 -3
  250. package/file-upload/single-file-upload.component.scss +42 -22
  251. package/form-field/_hint-theme.scss +1 -1
  252. package/form-field/cleaner.d.ts +1 -1
  253. package/form-field/form-field.d.ts +2 -2
  254. package/form-field/form-field.scss +2 -2
  255. package/form-field/hint.d.ts +1 -1
  256. package/form-field/password-hint.d.ts +2 -1
  257. package/form-field/password-toggle.d.ts +11 -6
  258. package/form-field/suffix.d.ts +1 -1
  259. package/form-field/validate.directive.d.ts +1 -1
  260. package/icon/_icon-theme.scss +12 -22
  261. package/input/input-number.d.ts +61 -10
  262. package/link/_link-theme.scss +6 -2
  263. package/link/link.component.d.ts +1 -1
  264. package/list/_list-theme.scss +2 -2
  265. package/list/list-selection.component.d.ts +1 -1
  266. package/list/list.scss +1 -5
  267. package/loader-overlay/loader-overlay.scss +3 -0
  268. package/markdown/_markdown-theme.scss +2 -2
  269. package/modal/README.md +5 -5
  270. package/modal/_modal-theme.scss +10 -18
  271. package/modal/modal-ref.class.d.ts +2 -2
  272. package/modal/modal.component.d.ts +51 -47
  273. package/modal/modal.scss +0 -1
  274. package/modal/modal.type.d.ts +35 -36
  275. package/navbar/_navbar-theme.scss +1 -1
  276. package/navbar/navbar-item.component.d.ts +2 -2
  277. package/navbar/navbar.component.d.ts +5 -2
  278. package/navbar/vertical-navbar.component.d.ts +4 -2
  279. package/package.json +28 -30
  280. package/popover/README.md +14 -14
  281. package/popover/_popover-theme.scss +15 -78
  282. package/popover/popover-animations.d.ts +1 -1
  283. package/popover/popover-confirm.component.d.ts +1 -1
  284. package/popover/popover.component.d.ts +3 -3
  285. package/popover/popover.scss +60 -50
  286. package/prebuilt-themes/dark-theme.css +1 -1
  287. package/prebuilt-themes/light-theme.css +1 -1
  288. package/radio/_radio-theme.scss +17 -4
  289. package/radio/radio.component.d.ts +2 -2
  290. package/radio/radio.scss +13 -0
  291. package/select/_select-theme.scss +1 -1
  292. package/select/select-option.directive.d.ts +2 -0
  293. package/select/select.component.d.ts +14 -11
  294. package/sidebar/sidebar-animations.d.ts +1 -1
  295. package/sidebar/sidebar.component.d.ts +3 -3
  296. package/sidepanel/_sidepanel-theme.scss +5 -0
  297. package/splitter/splitter.component.d.ts +1 -1
  298. package/table/_table-theme.scss +1 -1
  299. package/table/table.component.d.ts +1 -1
  300. package/tabs/tab-body.component.d.ts +1 -1
  301. package/tabs/tab-content.directive.d.ts +1 -1
  302. package/tabs/tab-nav-bar/tab-nav-bar.d.ts +2 -2
  303. package/tabs/tab.component.d.ts +1 -1
  304. package/tabs/tabs-animations.d.ts +1 -1
  305. package/tags/_tag-theme.scss +1 -1
  306. package/tags/tag-input.d.ts +2 -2
  307. package/tags/tag-list.component.d.ts +2 -2
  308. package/tags/tag-list.scss +2 -0
  309. package/tags/tag.component.d.ts +3 -3
  310. package/timepicker/timepicker.directive.d.ts +2 -2
  311. package/timezone/timezone-option.component.d.ts +1 -1
  312. package/timezone/timezone-select.component.d.ts +1 -1
  313. package/title/title.directive.d.ts +1 -1
  314. package/toggle/_toggle-theme.scss +9 -1
  315. package/toggle/toggle.component.d.ts +1 -1
  316. package/toggle/toggle.scss +5 -2
  317. package/tooltip/tooltip.component.d.ts +3 -3
  318. package/tree/_tree-theme.scss +2 -2
  319. package/tree/control/base-tree-control.d.ts +1 -1
  320. package/tree/control/tree-control.d.ts +1 -1
  321. package/tree/node.d.ts +1 -1
  322. package/tree/outlet.d.ts +1 -1
  323. package/tree/padding.directive.d.ts +1 -1
  324. package/tree/toggle.d.ts +3 -3
  325. package/tree/tree-base.d.ts +1 -1
  326. package/tree/tree-option.component.d.ts +1 -1
  327. package/tree/tree-option.scss +2 -0
  328. package/tree/tree-selection.component.d.ts +1 -1
  329. package/tree/tree.d.ts +1 -1
  330. package/tree-select/_tree-select-theme.scss +1 -1
  331. package/tree-select/tree-select.component.d.ts +1 -1
@@ -1,17 +1,17 @@
1
1
  import { A11yModule } from '@angular/cdk/a11y';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { Directive, Optional, Self, Attribute, Input, InjectionToken, Inject, forwardRef, NgModule } from '@angular/core';
4
+ import { forwardRef, EventEmitter, Directive, Attribute, Optional, Inject, Input, InjectionToken, Self, NgModule } from '@angular/core';
5
5
  import * as i1 from '@angular/forms';
6
- import { NG_VALIDATORS, Validators, FormsModule } from '@angular/forms';
6
+ import { NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators, FormsModule } from '@angular/forms';
7
7
  import * as i3 from '@koobiq/components/core';
8
- import { mixinErrorState, KbqCommonModule } from '@koobiq/components/core';
8
+ import { KBQ_LOCALE_SERVICE, mixinErrorState, KbqCommonModule } from '@koobiq/components/core';
9
9
  import { KbqIconModule } from '@koobiq/components/icon';
10
10
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
11
11
  import { getSupportedInputTypes } from '@angular/cdk/platform';
12
12
  import { KbqFormFieldControl } from '@koobiq/components/form-field';
13
- import { Subject } from 'rxjs';
14
- import { A, C, V, X, Z, F1, F12, ZERO, NINE, NUMPAD_ZERO, NUMPAD_NINE, NUMPAD_MINUS, DASH, FF_MINUS, DELETE, BACKSPACE, TAB, ESCAPE, ENTER, LEFT_ARROW, RIGHT_ARROW, HOME, END, UP_ARROW, DOWN_ARROW } from '@koobiq/cdk/keycodes';
13
+ import { Subject, Subscription } from 'rxjs';
14
+ import { A, C, V, X, Z, NUMPAD_MINUS, DASH, FF_MINUS, DELETE, BACKSPACE, TAB, ESCAPE, ENTER, LEFT_ARROW, RIGHT_ARROW, HOME, END, isFunctionKey, isNumberKey, isNumpadKey, UP_ARROW, DOWN_ARROW } from '@koobiq/cdk/keycodes';
15
15
 
16
16
  function getKbqInputUnsupportedTypeError(inputType) {
17
17
  return Error(`Input type "${inputType}" isn't supported by kbqInput.`);
@@ -42,19 +42,76 @@ function add(value1, value2) {
42
42
  const precision = Math.max(getPrecision(value1), getPrecision(value2));
43
43
  return (value1 * precision + value2 * precision) / precision;
44
44
  }
45
+ const KBQ_NUMBER_INPUT_VALUE_ACCESSOR = {
46
+ provide: NG_VALUE_ACCESSOR,
47
+ useExisting: forwardRef(() => KbqNumberInput),
48
+ multi: true
49
+ };
45
50
  class KbqNumberInput {
51
+ get value() {
52
+ return this._value;
53
+ }
54
+ set value(value) {
55
+ const oldValue = this.value;
56
+ this._value = value;
57
+ if (oldValue !== value) {
58
+ this.setViewValue(this.formatNumber(value));
59
+ this.valueChange.emit(value);
60
+ }
61
+ }
62
+ get disabled() {
63
+ return this._disabled;
64
+ }
65
+ set disabled(value) {
66
+ const newValue = coerceBooleanProperty(value);
67
+ const element = this.nativeElement;
68
+ if (this._disabled !== newValue) {
69
+ this._disabled = newValue;
70
+ this.disabledChange.emit(newValue);
71
+ }
72
+ // We need to null check the `blur` method, because it's undefined during SSR.
73
+ if (newValue && element.blur) {
74
+ // Normally, native input elements automatically blur if they turn disabled. This behavior
75
+ // is problematic, because it would mean that it triggers another change detection cycle,
76
+ // which then causes a changed after checked error if the input element was focused before.
77
+ element.blur();
78
+ }
79
+ }
46
80
  get nativeElement() {
47
81
  return this.elementRef.nativeElement;
48
82
  }
49
- constructor(elementRef, ngControl, step, bigStep, min, max) {
83
+ get viewValue() {
84
+ return this.nativeElement.value;
85
+ }
86
+ get ngControl() {
87
+ return this.control;
88
+ }
89
+ constructor(elementRef, renderer, step, bigStep, min, max, localeService) {
50
90
  this.elementRef = elementRef;
51
- this.ngControl = ngControl;
52
- this.focused = false;
91
+ this.renderer = renderer;
92
+ this.localeService = localeService;
93
+ /** Emits when the value changes (either due to user input or programmatic change). */
94
+ this.valueChange = new EventEmitter();
95
+ /** Emits when the disabled state has changed */
96
+ this.disabledChange = new EventEmitter();
53
97
  this.stateChanges = new Subject();
98
+ this.withThousandSeparator = true;
99
+ this._disabled = false;
100
+ this.focused = false;
101
+ this.localeSubscription = Subscription.EMPTY;
102
+ // tslint:disable-next-line:no-empty
103
+ this.onTouched = () => { };
104
+ // tslint:disable-next-line:no-empty
105
+ this.cvaOnChange = () => { };
106
+ this.updateLocaleParams = (id) => {
107
+ this.numberLocaleConfig = this.localeService.locales[id].input.number;
108
+ this.setViewValue(this.formatNumber(this.value));
109
+ };
54
110
  this.step = isDigit(step) ? parseFloat(step) : SMALL_STEP;
55
111
  this.bigStep = isDigit(bigStep) ? parseFloat(bigStep) : BIG_STEP;
56
112
  this.min = isDigit(min) ? parseFloat(min) : -Infinity;
57
113
  this.max = isDigit(max) ? parseFloat(max) : Infinity;
114
+ setTimeout(() => this.nativeElement.type = 'text', 0);
58
115
  if ('valueAsNumber' in this.nativeElement) {
59
116
  Object.defineProperty(Object.getPrototypeOf(this.nativeElement), 'valueAsNumber', {
60
117
  // tslint:disable-next-line:no-reserved-keywords
@@ -64,6 +121,38 @@ class KbqNumberInput {
64
121
  }
65
122
  });
66
123
  }
124
+ this.allNumberLocaleConfigs = this.localeService.locales.items
125
+ .map((localeItem) => {
126
+ return { id: localeItem.id, config: this.localeService.locales[localeItem.id].input.number };
127
+ });
128
+ this.localeSubscription = this.localeService.changes.subscribe(this.updateLocaleParams);
129
+ }
130
+ ngOnDestroy() {
131
+ this.localeSubscription.unsubscribe();
132
+ this.valueChange.complete();
133
+ this.disabledChange.complete();
134
+ }
135
+ onContainerClick() {
136
+ this.focus();
137
+ }
138
+ focus() {
139
+ this.nativeElement.focus();
140
+ }
141
+ // Implemented as part of ControlValueAccessor.
142
+ writeValue(value) {
143
+ this.value = value;
144
+ }
145
+ // Implemented as part of ControlValueAccessor.
146
+ registerOnChange(fn) {
147
+ this.cvaOnChange = fn;
148
+ }
149
+ // Implemented as part of ControlValueAccessor.
150
+ registerOnTouched(fn) {
151
+ this.onTouched = fn;
152
+ }
153
+ // Implemented as part of ControlValueAccessor.
154
+ setDisabledState(isDisabled) {
155
+ this.disabled = isDisabled;
67
156
  }
68
157
  focusChanged(isFocused) {
69
158
  if (isFocused !== this.focused) {
@@ -79,32 +168,39 @@ class KbqNumberInput {
79
168
  const isCtrlV = (e) => e.keyCode === V && (e.ctrlKey || e.metaKey);
80
169
  const isCtrlX = (e) => e.keyCode === X && (e.ctrlKey || e.metaKey);
81
170
  const isCtrlZ = (e) => e.keyCode === Z && (e.ctrlKey || e.metaKey);
82
- const isFKey = (e) => e.keyCode >= F1 && e.keyCode <= F12;
83
- const isNumber = (e) => (e.keyCode >= ZERO && e.keyCode <= NINE) ||
84
- (e.keyCode >= NUMPAD_ZERO && e.keyCode <= NUMPAD_NINE);
85
- const isPeriod = (e) => e.key === '.' || e.key === ',';
171
+ const isPeriod = (e) => this.numberLocaleConfig.groupSeparator.includes(e.key)
172
+ || [this.numberLocaleConfig.fractionSeparator, '.'].includes(e.key);
86
173
  const minuses = [NUMPAD_MINUS, DASH, FF_MINUS];
87
174
  const serviceKeys = [DELETE, BACKSPACE, TAB, ESCAPE, ENTER];
88
175
  const arrows = [LEFT_ARROW, RIGHT_ARROW];
89
176
  const allowedKeys = [HOME, END].concat(arrows).concat(serviceKeys).concat(minuses);
90
177
  if (minuses.includes(keyCode) &&
91
- (this.nativeElement.valueAsNumber || this.min >= 0 || this.nativeElement.validity?.badInput)) {
178
+ (this.viewValue.includes(event.key) || this.min >= 0)) {
92
179
  event.preventDefault();
93
180
  return;
94
181
  }
182
+ if (isPeriod(event)) {
183
+ if (event.key === this.numberLocaleConfig.fractionSeparator &&
184
+ this.viewValue.indexOf(this.numberLocaleConfig.fractionSeparator) !== -1) {
185
+ event.preventDefault();
186
+ return;
187
+ }
188
+ }
95
189
  if (allowedKeys.indexOf(keyCode) !== -1 ||
96
- isCtrlA(event) ||
97
- isCtrlC(event) ||
98
- isCtrlV(event) ||
99
- isCtrlX(event) ||
100
- isCtrlZ(event) ||
101
- isFKey(event) ||
102
- isPeriod(event)) {
190
+ [
191
+ isCtrlA,
192
+ isCtrlC,
193
+ isCtrlV,
194
+ isCtrlX,
195
+ isCtrlZ,
196
+ isFunctionKey,
197
+ isPeriod
198
+ ].some((fn) => fn(event))) {
103
199
  // let it happen, don't do anything
104
200
  return;
105
201
  }
106
202
  // Ensure that it is not a number and stop the keypress
107
- if (event.shiftKey || !isNumber(event)) {
203
+ if (event.shiftKey || !isNumberKey(event) && !isNumpadKey(event)) {
108
204
  event.preventDefault();
109
205
  // process steps
110
206
  const step = event.shiftKey ? this.bigStep : this.step;
@@ -116,48 +212,153 @@ class KbqNumberInput {
116
212
  }
117
213
  }
118
214
  }
215
+ onInput(event) {
216
+ const currentValueLength = this.formatNumber(this.value)?.length || 0;
217
+ setTimeout(() => {
218
+ const fromPaste = event.inputType === 'insertFromPaste';
219
+ let formattedValue;
220
+ if (fromPaste) {
221
+ formattedValue = this.formatNumber(this.valueFromPaste);
222
+ }
223
+ else {
224
+ /*this.viewValue is raw and should be reformatted to localized number */
225
+ formattedValue = this.formatViewValue();
226
+ const offsetWhenSeparatorAdded = 2;
227
+ Promise.resolve().then(() => {
228
+ if (Math.abs(this.viewValue.length - currentValueLength) === offsetWhenSeparatorAdded) {
229
+ const cursorPosition = Math.max(0, (this.nativeElement.selectionStart || 0) + Math.sign(this.viewValue.length - currentValueLength));
230
+ this.renderer.setProperty(this.nativeElement, 'selectionStart', cursorPosition);
231
+ this.renderer.setProperty(this.nativeElement, 'selectionEnd', cursorPosition);
232
+ }
233
+ });
234
+ }
235
+ this.setViewValue(formattedValue, !fromPaste);
236
+ this.viewToModelUpdate(formattedValue);
237
+ });
238
+ }
119
239
  onPaste(event) {
120
- if (!isDigit(normalizeSplitter(event.clipboardData.getData('text')))) {
240
+ this.valueFromPaste = this.checkAndNormalizeLocalizedNumber(event.clipboardData?.getData('text'));
241
+ if (this.valueFromPaste === null) {
121
242
  event.preventDefault();
122
243
  }
123
244
  }
124
245
  stepUp(step) {
125
- this.elementRef.nativeElement.focus();
126
- const res = Math.max(Math.min(add(this.nativeElement.valueAsNumber || 0, step), this.max), this.min);
127
- this.nativeElement.value = res.toString();
128
- this.viewToModelUpdate(this.nativeElement.valueAsNumber);
246
+ this.nativeElement.focus();
247
+ const res = Math.max(Math.min(add(this.value || 0, step), this.max), this.min);
248
+ this.setViewValue(this.formatNumber(res));
249
+ this._value = res;
250
+ this.cvaOnChange(res);
251
+ this.valueChange.emit(res);
129
252
  }
130
253
  stepDown(step) {
131
- this.elementRef.nativeElement.focus();
132
- const res = Math.min(Math.max(add(this.nativeElement.valueAsNumber || 0, -step), this.min), this.max);
133
- this.nativeElement.value = res.toString();
134
- this.viewToModelUpdate(this.nativeElement.valueAsNumber);
254
+ this.nativeElement.focus();
255
+ const res = Math.min(Math.max(add(this.value || 0, -step), this.min), this.max);
256
+ this.setViewValue(this.formatNumber(res));
257
+ this._value = res;
258
+ this.cvaOnChange(res);
259
+ this.valueChange.emit(res);
135
260
  }
136
- viewToModelUpdate(value) {
137
- if (this.ngControl) {
138
- this.ngControl.control.setValue(value);
261
+ setViewValue(value, savePosition = false) {
262
+ const cursorPosition = this.nativeElement.selectionStart;
263
+ this.renderer.setProperty(this.nativeElement, 'value', value);
264
+ if (savePosition) {
265
+ this.renderer.setProperty(this.nativeElement, 'selectionStart', cursorPosition);
266
+ this.renderer.setProperty(this.nativeElement, 'selectionEnd', cursorPosition);
267
+ }
268
+ }
269
+ viewToModelUpdate(newValue) {
270
+ const normalizedValue = newValue === null ? null : +this.normalizeNumber(newValue);
271
+ if (normalizedValue !== this.value) {
272
+ this._value = normalizedValue;
273
+ this.cvaOnChange(normalizedValue);
274
+ this.valueChange.emit(normalizedValue);
275
+ }
276
+ this.ngControl?.updateValueAndValidity({ emitEvent: false });
277
+ }
278
+ formatViewValue() {
279
+ if (this.viewValue === null || this.viewValue === '' || Number.isNaN(+this.normalizeNumber(this.viewValue))) {
280
+ return null;
139
281
  }
282
+ const separator = this.numberLocaleConfig.groupSeparator.includes(' ')
283
+ && this.numberLocaleConfig.fractionSeparator === ','
284
+ ? /[,.]/
285
+ : this.numberLocaleConfig.fractionSeparator;
286
+ const [intPart, fractionPart] = this.viewValue.split(separator)
287
+ .map((valuePart) => this.normalizeNumber(valuePart));
288
+ return this.createLocalizedNumberFromParts(+intPart, fractionPart);
140
289
  }
141
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: KbqNumberInput, deps: [{ token: i0.ElementRef }, { token: i1.NgControl, optional: true, self: true }, { token: 'step', attribute: true }, { token: 'big-step', attribute: true }, { token: 'min', attribute: true }, { token: 'max', attribute: true }], target: i0.ɵɵFactoryTarget.Directive }); }
142
- /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: KbqNumberInput, selector: "input[kbqInput][type=\"number\"]", inputs: { bigStep: "bigStep", step: "step", min: "min", max: "max" }, host: { listeners: { "blur": "focusChanged(false)", "focus": "focusChanged(true)", "paste": "onPaste($event)", "keydown": "onKeyDown($event)" } }, exportAs: ["mcNumericalInput"], ngImport: i0 }); }
290
+ formatNumber(value) {
291
+ if (value === null || value === undefined) {
292
+ return null;
293
+ }
294
+ const [intPart, fractionPart] = value.toString().split('.');
295
+ return this.createLocalizedNumberFromParts(+intPart, fractionPart);
296
+ }
297
+ createLocalizedNumberFromParts(intPart, fractionPart) {
298
+ const formatOptions = {
299
+ useGrouping: this.withThousandSeparator,
300
+ maximumFractionDigits: 20
301
+ };
302
+ if (this.withThousandSeparator && this.numberLocaleConfig.startFormattingFrom) {
303
+ formatOptions.useGrouping = intPart >= Math.pow(
304
+ // tslint:disable-next-line:no-magic-numbers
305
+ 10, this.numberLocaleConfig.startFormattingFrom);
306
+ }
307
+ const localeId = this.localeService.id === 'es-LA' ? 'ru-RU' : this.localeService.id;
308
+ const formatter = new Intl.NumberFormat(localeId, formatOptions);
309
+ const formattedFractionPart = fractionPart?.split('')
310
+ .map((numChar) => formatter.format(+numChar)).join('');
311
+ return formattedFractionPart === undefined
312
+ ? formatter.format(intPart)
313
+ : `${formatter.format(intPart)}${this.numberLocaleConfig.fractionSeparator}${formattedFractionPart}`;
314
+ }
315
+ /**
316
+ * Method that returns a string representation of a number without localized separators
317
+ */
318
+ normalizeNumber(value, customConfig) {
319
+ if (value === null || value === undefined) {
320
+ return '';
321
+ }
322
+ const { groupSeparator, fractionSeparator } = customConfig || this.numberLocaleConfig;
323
+ const groupSeparatorRegexp = new RegExp(`[${groupSeparator.join('')}]`, 'g');
324
+ const fractionSeparatorRegexp = new RegExp(`\\${fractionSeparator}`, 'g');
325
+ return value.toString()
326
+ .replace(groupSeparatorRegexp, '')
327
+ .replace(fractionSeparatorRegexp, '.');
328
+ }
329
+ checkAndNormalizeLocalizedNumber(num) {
330
+ if (num === null || num === undefined) {
331
+ return null;
332
+ }
333
+ /* if some locale input config satisfies pasted number, try to normalise with selected locale config */
334
+ let numberOutput = null;
335
+ for (const { config } of this.allNumberLocaleConfigs) {
336
+ const normalized = +this.normalizeNumber(num, config);
337
+ if (!Number.isNaN(normalized)) {
338
+ numberOutput = normalized;
339
+ break;
340
+ }
341
+ }
342
+ return numberOutput;
343
+ }
344
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: KbqNumberInput, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: 'step', attribute: true }, { token: 'big-step', attribute: true }, { token: 'min', attribute: true }, { token: 'max', attribute: true }, { token: KBQ_LOCALE_SERVICE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
345
+ /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: KbqNumberInput, selector: "input[kbqInput][type=\"number\"]", inputs: { bigStep: "bigStep", step: "step", min: "min", max: "max", withThousandSeparator: "withThousandSeparator", startFormattingFrom: "startFormattingFrom", value: "value", disabled: "disabled" }, host: { listeners: { "blur": "focusChanged(false)", "focus": "focusChanged(true)", "paste": "onPaste($event)", "keydown": "onKeyDown($event)", "input": "onInput($event)" } }, providers: [KBQ_NUMBER_INPUT_VALUE_ACCESSOR], exportAs: ["kbqNumericalInput"], ngImport: i0 }); }
143
346
  }
144
347
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: KbqNumberInput, decorators: [{
145
348
  type: Directive,
146
349
  args: [{
147
350
  selector: `input[kbqInput][type="number"]`,
148
- exportAs: 'mcNumericalInput',
351
+ exportAs: 'kbqNumericalInput',
352
+ providers: [KBQ_NUMBER_INPUT_VALUE_ACCESSOR],
149
353
  host: {
150
354
  '(blur)': 'focusChanged(false)',
151
355
  '(focus)': 'focusChanged(true)',
152
356
  '(paste)': 'onPaste($event)',
153
- '(keydown)': 'onKeyDown($event)'
357
+ '(keydown)': 'onKeyDown($event)',
358
+ '(input)': 'onInput($event)'
154
359
  }
155
360
  }]
156
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.NgControl, decorators: [{
157
- type: Optional
158
- }, {
159
- type: Self
160
- }] }, { type: undefined, decorators: [{
361
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: undefined, decorators: [{
161
362
  type: Attribute,
162
363
  args: ['step']
163
364
  }] }, { type: undefined, decorators: [{
@@ -169,6 +370,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImpor
169
370
  }] }, { type: undefined, decorators: [{
170
371
  type: Attribute,
171
372
  args: ['max']
373
+ }] }, { type: i3.KbqLocaleService, decorators: [{
374
+ type: Optional
375
+ }, {
376
+ type: Inject,
377
+ args: [KBQ_LOCALE_SERVICE]
172
378
  }] }]; }, propDecorators: { bigStep: [{
173
379
  type: Input
174
380
  }], step: [{
@@ -177,6 +383,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImpor
177
383
  type: Input
178
384
  }], max: [{
179
385
  type: Input
386
+ }], withThousandSeparator: [{
387
+ type: Input
388
+ }], startFormattingFrom: [{
389
+ type: Input
390
+ }], value: [{
391
+ type: Input
392
+ }], disabled: [{
393
+ type: Input
180
394
  }] } });
181
395
 
182
396
  const KBQ_INPUT_VALUE_ACCESSOR = new InjectionToken('KBQ_INPUT_VALUE_ACCESSOR');
@@ -827,5 +1041,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImpor
827
1041
  * Generated bundle index. Do not edit.
828
1042
  */
829
1043
 
830
- export { BIG_STEP, KBQ_INPUT_VALUE_ACCESSOR, KbqInput, KbqInputBase, KbqInputMixinBase, KbqInputModule, KbqInputMono, KbqInputPassword, KbqNumberInput, MAX_VALIDATOR, MIN_VALIDATOR, MaxValidator, MinValidator, SMALL_STEP, add, getPrecision, isDigit, isFloat, isInt, normalizeSplitter };
1044
+ export { BIG_STEP, KBQ_INPUT_VALUE_ACCESSOR, KBQ_NUMBER_INPUT_VALUE_ACCESSOR, KbqInput, KbqInputBase, KbqInputMixinBase, KbqInputModule, KbqInputMono, KbqInputPassword, KbqNumberInput, MAX_VALIDATOR, MIN_VALIDATOR, MaxValidator, MinValidator, SMALL_STEP, add, getPrecision, isDigit, isFloat, isInt, normalizeSplitter };
831
1045
  //# sourceMappingURL=koobiq-components-input.mjs.map