@syncfusion/ej2-dropdowns 24.1.43 → 24.1.45-12082

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 (327) hide show
  1. package/CHANGELOG.md +2101 -2058
  2. package/{README.md → ReadMe.md} +217 -217
  3. package/dist/ej2-dropdowns.min.js +1 -10
  4. package/dist/ej2-dropdowns.umd.min.js +1 -10
  5. package/dist/ej2-dropdowns.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-dropdowns.es2015.js +94 -74
  7. package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
  8. package/dist/es6/ej2-dropdowns.es5.js +236 -216
  9. package/dist/es6/ej2-dropdowns.es5.js.map +1 -1
  10. package/dist/global/ej2-dropdowns.min.js +1 -10
  11. package/dist/global/ej2-dropdowns.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/auto-complete/auto-complete.ts +623 -0
  14. package/dist/ts/combo-box/combo-box.ts +1099 -0
  15. package/dist/ts/common/highlight-search.ts +57 -0
  16. package/dist/ts/common/incremental-search.ts +172 -0
  17. package/dist/ts/common/interface.ts +74 -0
  18. package/dist/ts/common/virtual-scroll.ts +388 -0
  19. package/dist/ts/drop-down-base/drop-down-base.ts +1986 -0
  20. package/dist/ts/drop-down-list/drop-down-list.ts +4261 -0
  21. package/dist/ts/drop-down-tree/drop-down-tree.ts +3747 -0
  22. package/dist/ts/list-box/list-box.ts +2772 -0
  23. package/dist/ts/mention/mention.ts +1875 -0
  24. package/dist/ts/multi-select/checkbox-selection.ts +550 -0
  25. package/dist/ts/multi-select/float-label.ts +176 -0
  26. package/dist/ts/multi-select/interface.ts +70 -0
  27. package/dist/ts/multi-select/multi-select.ts +4882 -0
  28. package/helpers/e2e/autocomplete.js +13 -13
  29. package/helpers/e2e/combobox.js +13 -13
  30. package/helpers/e2e/dropdownlist.js +13 -13
  31. package/helpers/e2e/index.js +3 -3
  32. package/helpers/e2e/listboxHelper.js +13 -13
  33. package/helpers/e2e/multiselect.js +13 -13
  34. package/license +2 -2
  35. package/package.json +80 -80
  36. package/src/auto-complete/auto-complete-model.d.ts +188 -188
  37. package/src/auto-complete/auto-complete.d.ts +12 -12
  38. package/src/auto-complete/auto-complete.js +21 -21
  39. package/src/combo-box/combo-box-model.d.ts +224 -224
  40. package/src/combo-box/combo-box.d.ts +27 -27
  41. package/src/combo-box/combo-box.js +29 -29
  42. package/src/common/virtual-scroll.js +46 -46
  43. package/src/drop-down-base/drop-down-base-model.d.ts +200 -200
  44. package/src/drop-down-base/drop-down-base.d.ts +16 -16
  45. package/src/drop-down-base/drop-down-base.js +20 -20
  46. package/src/drop-down-list/drop-down-list-model.d.ts +202 -202
  47. package/src/drop-down-list/drop-down-list.d.ts +5 -4
  48. package/src/drop-down-list/drop-down-list.js +31 -22
  49. package/src/drop-down-tree/drop-down-tree-model.d.ts +468 -468
  50. package/src/drop-down-tree/drop-down-tree.d.ts +0 -1
  51. package/src/drop-down-tree/drop-down-tree.js +20 -28
  52. package/src/list-box/list-box-model.d.ts +193 -193
  53. package/src/list-box/list-box.d.ts +2 -2
  54. package/src/list-box/list-box.js +34 -22
  55. package/src/mention/mention-model.d.ts +261 -261
  56. package/src/mention/mention.js +29 -22
  57. package/src/multi-select/multi-select-model.d.ts +512 -512
  58. package/src/multi-select/multi-select.js +20 -20
  59. package/styles/auto-complete/_all.scss +1 -1
  60. package/styles/auto-complete/_bds-definition.scss +2 -0
  61. package/styles/auto-complete/_bootstrap-dark-definition.scss +3 -3
  62. package/styles/auto-complete/_bootstrap-definition.scss +2 -2
  63. package/styles/auto-complete/_bootstrap4-definition.scss +11 -11
  64. package/styles/auto-complete/_bootstrap5-definition.scss +2 -2
  65. package/styles/auto-complete/_fabric-dark-definition.scss +2 -2
  66. package/styles/auto-complete/_fabric-definition.scss +2 -2
  67. package/styles/auto-complete/_fluent-definition.scss +2 -2
  68. package/styles/auto-complete/_fusionnew-definition.scss +2 -2
  69. package/styles/auto-complete/_highcontrast-definition.scss +2 -2
  70. package/styles/auto-complete/_highcontrast-light-definition.scss +2 -2
  71. package/styles/auto-complete/_material-dark-definition.scss +2 -2
  72. package/styles/auto-complete/_material-definition.scss +2 -2
  73. package/styles/auto-complete/_material3-definition.scss +2 -2
  74. package/styles/auto-complete/_tailwind-definition.scss +2 -2
  75. package/styles/auto-complete/material3-dark.scss +1 -1
  76. package/styles/auto-complete/material3.scss +1 -1
  77. package/styles/bootstrap-dark.css +9 -0
  78. package/styles/bootstrap.css +9 -0
  79. package/styles/bootstrap4.css +9 -0
  80. package/styles/bootstrap5-dark.css +9 -0
  81. package/styles/bootstrap5.css +9 -0
  82. package/styles/combo-box/_all.scss +1 -1
  83. package/styles/combo-box/_bds-definition.scss +2 -0
  84. package/styles/combo-box/_bootstrap-dark-definition.scss +2 -2
  85. package/styles/combo-box/_bootstrap-definition.scss +2 -2
  86. package/styles/combo-box/_bootstrap4-definition.scss +11 -11
  87. package/styles/combo-box/_bootstrap5-definition.scss +2 -2
  88. package/styles/combo-box/_fabric-dark-definition.scss +2 -2
  89. package/styles/combo-box/_fabric-definition.scss +2 -2
  90. package/styles/combo-box/_fluent-definition.scss +2 -2
  91. package/styles/combo-box/_fusionnew-definition.scss +2 -2
  92. package/styles/combo-box/_highcontrast-definition.scss +2 -2
  93. package/styles/combo-box/_highcontrast-light-definition.scss +3 -3
  94. package/styles/combo-box/_material-dark-definition.scss +2 -2
  95. package/styles/combo-box/_material-definition.scss +2 -2
  96. package/styles/combo-box/_material3-definition.scss +2 -2
  97. package/styles/combo-box/_tailwind-definition.scss +2 -2
  98. package/styles/combo-box/material3-dark.scss +1 -1
  99. package/styles/combo-box/material3.scss +1 -1
  100. package/styles/drop-down-base/_all.scss +2 -2
  101. package/styles/drop-down-base/_bds-definition.scss +129 -0
  102. package/styles/drop-down-base/_bootstrap-dark-definition.scss +83 -83
  103. package/styles/drop-down-base/_bootstrap-definition.scss +83 -83
  104. package/styles/drop-down-base/_bootstrap4-definition.scss +90 -90
  105. package/styles/drop-down-base/_bootstrap5-definition.scss +117 -117
  106. package/styles/drop-down-base/_definition.scss +23 -23
  107. package/styles/drop-down-base/_fabric-dark-definition.scss +86 -86
  108. package/styles/drop-down-base/_fabric-definition.scss +84 -84
  109. package/styles/drop-down-base/_fluent-definition.scss +121 -121
  110. package/styles/drop-down-base/_fusionnew-definition.scss +117 -117
  111. package/styles/drop-down-base/_highcontrast-definition.scss +105 -105
  112. package/styles/drop-down-base/_highcontrast-light-definition.scss +105 -105
  113. package/styles/drop-down-base/_layout.scss +192 -192
  114. package/styles/drop-down-base/_material-dark-definition.scss +86 -86
  115. package/styles/drop-down-base/_material-definition.scss +85 -85
  116. package/styles/drop-down-base/_material3-definition.scss +87 -87
  117. package/styles/drop-down-base/_tailwind-definition.scss +129 -129
  118. package/styles/drop-down-base/_theme.scss +391 -391
  119. package/styles/drop-down-base/material3-dark.scss +1 -1
  120. package/styles/drop-down-base/material3.scss +1 -1
  121. package/styles/drop-down-list/_all.scss +3 -3
  122. package/styles/drop-down-list/_bds-definition.scss +134 -0
  123. package/styles/drop-down-list/_bootstrap-dark-definition.scss +157 -157
  124. package/styles/drop-down-list/_bootstrap-definition.scss +156 -156
  125. package/styles/drop-down-list/_bootstrap4-definition.scss +202 -202
  126. package/styles/drop-down-list/_bootstrap5-definition.scss +201 -201
  127. package/styles/drop-down-list/_fabric-dark-definition.scss +128 -128
  128. package/styles/drop-down-list/_fabric-definition.scss +124 -124
  129. package/styles/drop-down-list/_fluent-definition.scss +185 -185
  130. package/styles/drop-down-list/_fusionnew-definition.scss +201 -201
  131. package/styles/drop-down-list/_highcontrast-definition.scss +142 -142
  132. package/styles/drop-down-list/_highcontrast-light-definition.scss +144 -144
  133. package/styles/drop-down-list/_layout.scss +315 -310
  134. package/styles/drop-down-list/_material-dark-definition.scss +143 -143
  135. package/styles/drop-down-list/_material-definition.scss +167 -167
  136. package/styles/drop-down-list/_material3-definition.scss +180 -180
  137. package/styles/drop-down-list/_tailwind-definition.scss +134 -134
  138. package/styles/drop-down-list/_theme.scss +10 -10
  139. package/styles/drop-down-list/bootstrap-dark.css +5 -0
  140. package/styles/drop-down-list/bootstrap.css +5 -0
  141. package/styles/drop-down-list/bootstrap4.css +5 -0
  142. package/styles/drop-down-list/bootstrap5-dark.css +5 -0
  143. package/styles/drop-down-list/bootstrap5.css +5 -0
  144. package/styles/drop-down-list/fabric-dark.css +5 -0
  145. package/styles/drop-down-list/fabric.css +5 -0
  146. package/styles/drop-down-list/fluent-dark.css +5 -0
  147. package/styles/drop-down-list/fluent.css +5 -0
  148. package/styles/drop-down-list/highcontrast-light.css +5 -0
  149. package/styles/drop-down-list/highcontrast.css +5 -0
  150. package/styles/drop-down-list/icons/_bootstrap-dark.scss +14 -14
  151. package/styles/drop-down-list/icons/_bootstrap.scss +14 -14
  152. package/styles/drop-down-list/icons/_bootstrap4.scss +14 -14
  153. package/styles/drop-down-list/icons/_bootstrap5.scss +14 -14
  154. package/styles/drop-down-list/icons/_fabric-dark.scss +14 -14
  155. package/styles/drop-down-list/icons/_fabric.scss +14 -14
  156. package/styles/drop-down-list/icons/_fluent.scss +14 -14
  157. package/styles/drop-down-list/icons/_fusionnew.scss +14 -14
  158. package/styles/drop-down-list/icons/_highcontrast-light.scss +14 -14
  159. package/styles/drop-down-list/icons/_highcontrast.scss +14 -14
  160. package/styles/drop-down-list/icons/_material-dark.scss +14 -14
  161. package/styles/drop-down-list/icons/_material.scss +14 -14
  162. package/styles/drop-down-list/icons/_material3.scss +14 -14
  163. package/styles/drop-down-list/icons/_tailwind.scss +14 -14
  164. package/styles/drop-down-list/material-dark.css +5 -0
  165. package/styles/drop-down-list/material.css +5 -0
  166. package/styles/drop-down-list/material3-dark.css +5 -0
  167. package/styles/drop-down-list/material3-dark.scss +1 -1
  168. package/styles/drop-down-list/material3.css +5 -0
  169. package/styles/drop-down-list/material3.scss +1 -1
  170. package/styles/drop-down-list/tailwind-dark.css +5 -0
  171. package/styles/drop-down-list/tailwind.css +5 -0
  172. package/styles/drop-down-tree/_all.scss +2 -2
  173. package/styles/drop-down-tree/_bds-definition.scss +61 -0
  174. package/styles/drop-down-tree/_bootstrap-dark-definition.scss +71 -71
  175. package/styles/drop-down-tree/_bootstrap-definition.scss +70 -70
  176. package/styles/drop-down-tree/_bootstrap4-definition.scss +71 -71
  177. package/styles/drop-down-tree/_bootstrap5-definition.scss +59 -59
  178. package/styles/drop-down-tree/_fabric-dark-definition.scss +71 -71
  179. package/styles/drop-down-tree/_fabric-definition.scss +71 -71
  180. package/styles/drop-down-tree/_fluent-definition.scss +65 -65
  181. package/styles/drop-down-tree/_fusionnew-definition.scss +59 -59
  182. package/styles/drop-down-tree/_highcontrast-definition.scss +71 -71
  183. package/styles/drop-down-tree/_highcontrast-light-definition.scss +71 -71
  184. package/styles/drop-down-tree/_layout.scss +1423 -1418
  185. package/styles/drop-down-tree/_material-dark-definition.scss +72 -72
  186. package/styles/drop-down-tree/_material-definition.scss +72 -72
  187. package/styles/drop-down-tree/_material3-definition.scss +76 -76
  188. package/styles/drop-down-tree/_tailwind-definition.scss +61 -61
  189. package/styles/drop-down-tree/_theme.scss +132 -132
  190. package/styles/drop-down-tree/bootstrap-dark.css +4 -0
  191. package/styles/drop-down-tree/bootstrap.css +4 -0
  192. package/styles/drop-down-tree/bootstrap4.css +4 -0
  193. package/styles/drop-down-tree/bootstrap5-dark.css +4 -0
  194. package/styles/drop-down-tree/bootstrap5.css +4 -0
  195. package/styles/drop-down-tree/fabric-dark.css +4 -0
  196. package/styles/drop-down-tree/fabric.css +4 -0
  197. package/styles/drop-down-tree/fluent-dark.css +4 -0
  198. package/styles/drop-down-tree/fluent.css +4 -0
  199. package/styles/drop-down-tree/highcontrast-light.css +4 -0
  200. package/styles/drop-down-tree/highcontrast.css +4 -0
  201. package/styles/drop-down-tree/icons/_bootstrap-dark.scss +11 -11
  202. package/styles/drop-down-tree/icons/_bootstrap.scss +11 -11
  203. package/styles/drop-down-tree/icons/_bootstrap4.scss +11 -11
  204. package/styles/drop-down-tree/icons/_bootstrap5.scss +11 -11
  205. package/styles/drop-down-tree/icons/_fabric-dark.scss +11 -11
  206. package/styles/drop-down-tree/icons/_fabric.scss +11 -11
  207. package/styles/drop-down-tree/icons/_fluent.scss +11 -11
  208. package/styles/drop-down-tree/icons/_fusionnew.scss +11 -11
  209. package/styles/drop-down-tree/icons/_highcontrast-light.scss +11 -11
  210. package/styles/drop-down-tree/icons/_highcontrast.scss +11 -11
  211. package/styles/drop-down-tree/icons/_material-dark.scss +11 -11
  212. package/styles/drop-down-tree/icons/_material.scss +11 -11
  213. package/styles/drop-down-tree/icons/_material3.scss +11 -11
  214. package/styles/drop-down-tree/icons/_tailwind-dark.scss +11 -11
  215. package/styles/drop-down-tree/icons/_tailwind.scss +11 -11
  216. package/styles/drop-down-tree/material-dark.css +4 -0
  217. package/styles/drop-down-tree/material.css +4 -0
  218. package/styles/drop-down-tree/material3-dark.css +4 -0
  219. package/styles/drop-down-tree/material3-dark.scss +1 -1
  220. package/styles/drop-down-tree/material3.css +4 -0
  221. package/styles/drop-down-tree/material3.scss +1 -1
  222. package/styles/drop-down-tree/tailwind-dark.css +4 -0
  223. package/styles/drop-down-tree/tailwind.css +4 -0
  224. package/styles/fabric-dark.css +9 -0
  225. package/styles/fabric.css +9 -0
  226. package/styles/fluent-dark.css +9 -0
  227. package/styles/fluent.css +9 -0
  228. package/styles/highcontrast-light.css +9 -0
  229. package/styles/highcontrast.css +9 -0
  230. package/styles/list-box/_all.scss +2 -2
  231. package/styles/list-box/_bds-definition.scss +119 -0
  232. package/styles/list-box/_bootstrap-dark-definition.scss +126 -126
  233. package/styles/list-box/_bootstrap-definition.scss +119 -119
  234. package/styles/list-box/_bootstrap4-definition.scss +124 -124
  235. package/styles/list-box/_bootstrap5-definition.scss +120 -120
  236. package/styles/list-box/_fabric-dark-definition.scss +126 -126
  237. package/styles/list-box/_fabric-definition.scss +119 -119
  238. package/styles/list-box/_fluent-definition.scss +120 -120
  239. package/styles/list-box/_fusionnew-definition.scss +111 -111
  240. package/styles/list-box/_highcontrast-definition.scss +119 -119
  241. package/styles/list-box/_highcontrast-light-definition.scss +126 -126
  242. package/styles/list-box/_layout.scss +542 -542
  243. package/styles/list-box/_material-dark-definition.scss +126 -126
  244. package/styles/list-box/_material-definition.scss +119 -119
  245. package/styles/list-box/_material3-definition.scss +119 -119
  246. package/styles/list-box/_tailwind-definition.scss +119 -119
  247. package/styles/list-box/_theme.scss +382 -382
  248. package/styles/list-box/icons/_bootstrap-dark.scss +25 -25
  249. package/styles/list-box/icons/_bootstrap.scss +25 -25
  250. package/styles/list-box/icons/_bootstrap4.scss +25 -25
  251. package/styles/list-box/icons/_bootstrap5.scss +25 -25
  252. package/styles/list-box/icons/_fabric-dark.scss +25 -25
  253. package/styles/list-box/icons/_fabric.scss +25 -25
  254. package/styles/list-box/icons/_fluent.scss +25 -25
  255. package/styles/list-box/icons/_fusionnew.scss +25 -25
  256. package/styles/list-box/icons/_highcontrast-light.scss +25 -25
  257. package/styles/list-box/icons/_highcontrast.scss +25 -25
  258. package/styles/list-box/icons/_material-dark.scss +25 -25
  259. package/styles/list-box/icons/_material.scss +25 -25
  260. package/styles/list-box/icons/_material3.scss +25 -25
  261. package/styles/list-box/icons/_tailwind-dark.scss +25 -25
  262. package/styles/list-box/icons/_tailwind.scss +25 -25
  263. package/styles/list-box/material3-dark.scss +1 -1
  264. package/styles/list-box/material3.scss +1 -1
  265. package/styles/material-dark.css +9 -0
  266. package/styles/material.css +9 -0
  267. package/styles/material3-dark.css +9 -0
  268. package/styles/material3-dark.scss +1 -1
  269. package/styles/material3.css +9 -0
  270. package/styles/material3.scss +1 -1
  271. package/styles/mention/_all.scss +1 -1
  272. package/styles/mention/_bds-definition.scss +1 -0
  273. package/styles/mention/_bootstrap-dark-definition.scss +3 -3
  274. package/styles/mention/_bootstrap-definition.scss +3 -3
  275. package/styles/mention/_bootstrap4-definition.scss +3 -3
  276. package/styles/mention/_bootstrap5-definition.scss +1 -1
  277. package/styles/mention/_fabric-dark-definition.scss +2 -2
  278. package/styles/mention/_fabric-definition.scss +3 -3
  279. package/styles/mention/_fluent-definition.scss +1 -1
  280. package/styles/mention/_fusionnew-definition.scss +1 -1
  281. package/styles/mention/_highcontrast-definition.scss +3 -3
  282. package/styles/mention/_highcontrast-light-definition.scss +3 -3
  283. package/styles/mention/_layout.scss +6 -6
  284. package/styles/mention/_material-dark-definition.scss +3 -3
  285. package/styles/mention/_material-definition.scss +3 -3
  286. package/styles/mention/_material3-definition.scss +1 -1
  287. package/styles/mention/_tailwind-definition.scss +1 -1
  288. package/styles/mention/material3-dark.scss +1 -1
  289. package/styles/mention/material3.scss +1 -1
  290. package/styles/multi-select/_all.scss +2 -2
  291. package/styles/multi-select/_bds-definition.scss +235 -0
  292. package/styles/multi-select/_bootstrap-dark-definition.scss +203 -203
  293. package/styles/multi-select/_bootstrap-definition.scss +192 -192
  294. package/styles/multi-select/_bootstrap4-definition.scss +278 -278
  295. package/styles/multi-select/_bootstrap5-definition.scss +230 -230
  296. package/styles/multi-select/_fabric-dark-definition.scss +192 -192
  297. package/styles/multi-select/_fabric-definition.scss +183 -183
  298. package/styles/multi-select/_fluent-definition.scss +241 -241
  299. package/styles/multi-select/_fusionnew-definition.scss +227 -227
  300. package/styles/multi-select/_highcontrast-definition.scss +303 -303
  301. package/styles/multi-select/_highcontrast-light-definition.scss +297 -297
  302. package/styles/multi-select/_layout.scss +2199 -2199
  303. package/styles/multi-select/_material-dark-definition.scss +230 -230
  304. package/styles/multi-select/_material-definition.scss +223 -223
  305. package/styles/multi-select/_material3-definition.scss +246 -246
  306. package/styles/multi-select/_tailwind-definition.scss +235 -235
  307. package/styles/multi-select/_theme.scss +586 -586
  308. package/styles/multi-select/icons/_bootstrap-dark.scss +26 -26
  309. package/styles/multi-select/icons/_bootstrap.scss +26 -26
  310. package/styles/multi-select/icons/_bootstrap4.scss +37 -37
  311. package/styles/multi-select/icons/_bootstrap5.scss +26 -26
  312. package/styles/multi-select/icons/_fabric-dark.scss +26 -26
  313. package/styles/multi-select/icons/_fabric.scss +26 -26
  314. package/styles/multi-select/icons/_fluent.scss +55 -55
  315. package/styles/multi-select/icons/_fusionnew.scss +26 -26
  316. package/styles/multi-select/icons/_highcontrast-light.scss +26 -26
  317. package/styles/multi-select/icons/_highcontrast.scss +26 -26
  318. package/styles/multi-select/icons/_material-dark.scss +693 -693
  319. package/styles/multi-select/icons/_material.scss +693 -693
  320. package/styles/multi-select/icons/_material3.scss +692 -692
  321. package/styles/multi-select/icons/_tailwind.scss +26 -26
  322. package/styles/multi-select/material3-dark.scss +1 -1
  323. package/styles/multi-select/material3.scss +1 -1
  324. package/styles/tailwind-dark.css +9 -0
  325. package/styles/tailwind.css +9 -0
  326. package/.eslintrc.json +0 -260
  327. package/tslint.json +0 -111
@@ -0,0 +1,1099 @@
1
+ // eslint-disable-next-line @typescript-eslint/triple-slash-reference
2
+ /// <reference path='../drop-down-list/drop-down-list-model.d.ts'/>
3
+ import { EventHandler, Property, Event, EmitType, addClass, Browser, KeyboardEventArgs, removeClass, detach } from '@syncfusion/ej2-base';
4
+ import { isNullOrUndefined, NotifyPropertyChanges, getValue, setValue } from '@syncfusion/ej2-base';
5
+ import { DropDownList, dropDownListClasses } from '../drop-down-list/drop-down-list';
6
+ import { FilteringEventArgs } from '../drop-down-base/drop-down-base';
7
+ import { FieldSettingsModel } from '../drop-down-base/drop-down-base-model';
8
+ import { ComboBoxModel } from '../combo-box/combo-box-model';
9
+ import { Search } from '../common/incremental-search';
10
+ import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
11
+ import { Input, InputObject, FloatLabelType } from '@syncfusion/ej2-inputs';
12
+ import { DataManager, Query } from '@syncfusion/ej2-data';
13
+
14
+ const SPINNER_CLASS: string = 'e-atc-spinner-icon';
15
+
16
+ dropDownListClasses.root = 'e-combobox';
17
+ const inputObject: InputObject = {
18
+ container: null,
19
+ buttons: []
20
+ };
21
+ /**
22
+ * The ComboBox component allows the user to type a value or choose an option from the list of predefined options.
23
+ * ```html
24
+ * <select id="list">
25
+ * <option value='1'>Badminton</option>
26
+ * <option value='2'>Basketball</option>
27
+ * <option value='3'>Cricket</option>
28
+ * <option value='4'>Football</option>
29
+ * <option value='5'>Tennis</option>
30
+ * </select>
31
+ * ```
32
+ * ```typescript
33
+ * let games:ComboBox = new ComboBox();
34
+ * games.appendTo("#list");
35
+ * ```
36
+ */
37
+ @NotifyPropertyChanges
38
+ export class ComboBox extends DropDownList {
39
+ /**
40
+ * Specifies whether suggest a first matched item in input when searching. No action happens when no matches found.
41
+ *
42
+ * @default false
43
+ */
44
+ @Property(false)
45
+ public autofill: boolean;
46
+ /**
47
+ * Specifies whether the component allows user defined value which does not exist in data source.
48
+ *
49
+ * @default true
50
+ */
51
+ @Property(true)
52
+ public allowCustom: boolean;
53
+ /**
54
+ * Allows additional HTML attributes such as title, name, etc., and
55
+ * accepts n number of attributes in a key-value pair format.
56
+ *
57
+ * {% codeBlock src='combobox/htmlAttributes/index.md' %}{% endcodeBlock %}
58
+ *
59
+ * @default {}
60
+ * @deprecated
61
+ */
62
+ @Property({})
63
+ public htmlAttributes: { [key: string]: string };
64
+ /**
65
+ * When allowFiltering is set to true, show the filter bar (search box) of the component.
66
+ * The filter action retrieves matched items through the `filtering` event based on
67
+ * the characters typed in the search TextBox.
68
+ * If no match is found, the value of the `noRecordsTemplate` property will be displayed.
69
+ *
70
+ * {% codeBlock src="combobox/allow-filtering-api/index.ts" %}{% endcodeBlock %}
71
+ *
72
+ * {% codeBlock src="combobox/allow-filtering-api/index.html" %}{% endcodeBlock %}
73
+ *
74
+ * @default false
75
+ * @deprecated
76
+ */
77
+ @Property(false)
78
+ public allowFiltering: boolean;
79
+ /**
80
+ * Accepts the external `Query`
81
+ * that execute along with [`data processing`](../../combo-box/data-binding).
82
+ *
83
+ * {% codeBlock src='combobox/query/index.md' %}{% endcodeBlock %}
84
+ *
85
+ * @default null
86
+ * @deprecated
87
+ */
88
+ @Property(null)
89
+ public query: Query;
90
+ /**
91
+ * Gets or sets the index of the selected item in the component.
92
+ *
93
+ * {% codeBlock src="combobox/index-api/index.ts" %}{% endcodeBlock %}
94
+ *
95
+ * {% codeBlock src="combobox/index-api/index.html" %}{% endcodeBlock %}
96
+ *
97
+ * @default null
98
+ * @deprecated
99
+ */
100
+ @Property(null)
101
+ public index: number;
102
+ /**
103
+ * Specifies whether to show or hide the clear button.
104
+ * When the clear button is clicked, `value`, `text`, and `index` properties are reset to null.
105
+ *
106
+ * @default true
107
+ */
108
+ @Property(true)
109
+ public showClearButton: boolean;
110
+ /**
111
+ * Enable or disable rendering component in right to left direction.
112
+ *
113
+ * @default false
114
+ * @deprecated
115
+ */
116
+ @Property(false)
117
+ public enableRtl: boolean;
118
+ /**
119
+ * Triggers on set a
120
+ * [`custom value`](../../combo-box/getting-started#custom-values) to this component.
121
+ *
122
+ * @event customValueSpecifier
123
+ */
124
+ @Event()
125
+ public customValueSpecifier: EmitType<CustomValueSpecifierEventArgs>;
126
+
127
+ /**
128
+ * Triggers on typing a character in the component.
129
+ * > For more details about the filtering refer to [`Filtering`](../../combo-box/filtering) documentation.
130
+ *
131
+ * @event filtering
132
+ */
133
+ @Event()
134
+ public filtering: EmitType<FilteringEventArgs>;
135
+
136
+ /**
137
+ * Not applicable to this component.
138
+ *
139
+ * @default null
140
+ * @aspType string
141
+ * @private
142
+ */
143
+ @Property(null)
144
+ public valueTemplate: string | Function;
145
+ /**
146
+ * Specifies whether to display the floating label above the input element.
147
+ * Possible values are:
148
+ * * Never: The label will never float in the input when the placeholder is available.
149
+ * * Always: The floating label will always float above the input.
150
+ * * Auto: The floating label will float above the input after focusing or entering a value in the input.
151
+ *
152
+ * {% codeBlock src="combobox/float-label-type-api/index.ts" %}{% endcodeBlock %}
153
+ *
154
+ * {% codeBlock src="combobox/float-label-type-api/index.html" %}{% endcodeBlock %}
155
+ *
156
+ * @default Syncfusion.EJ2.Inputs.FloatLabelType.Never
157
+ * @aspType Syncfusion.EJ2.Inputs.FloatLabelType
158
+ * @isEnumeration true
159
+ * @deprecated
160
+ */
161
+ @Property('Never')
162
+ public floatLabelType: FloatLabelType;
163
+ /**
164
+ * Not applicable to this component.
165
+ *
166
+ * @default null
167
+ * @private
168
+ * @deprecated
169
+ */
170
+ @Property(null)
171
+ public filterBarPlaceholder: string;
172
+ /**
173
+ * Sets CSS classes to the root element of the component that allows customization of appearance.
174
+ *
175
+ * @default null
176
+ * @deprecated
177
+ */
178
+ @Property(null)
179
+ public cssClass: string;
180
+ /**
181
+ * Accepts the template design and assigns it to the header container of the popup list.
182
+ * > For more details about the available template options refer to [`Template`](../../drop-down-list/templates) documentation.
183
+ *
184
+ * @default null
185
+ * @aspType string
186
+ * @deprecated
187
+ */
188
+ @Property(null)
189
+ public headerTemplate: string | Function;
190
+ /**
191
+ * Accepts the template design and assigns it to the footer container of the popup list.
192
+ * > For more details about the available template options refer to [`Template`](../../drop-down-list/templates) documentation.
193
+ *
194
+ * @default null
195
+ * @aspType string
196
+ * @deprecated
197
+ */
198
+ @Property(null)
199
+ public footerTemplate: string | Function;
200
+ /**
201
+ * Specifies a short hint that describes the expected value of the DropDownList component.
202
+ *
203
+ * @default null
204
+ * @deprecated
205
+ */
206
+ @Property(null)
207
+ public placeholder: string;
208
+ /**
209
+ * Specifies the width of the component. By default, the component width sets based on the width of
210
+ * its parent container. You can also set the width in pixel values.
211
+ *
212
+ * @default '100%'
213
+ * @aspType string
214
+ * @deprecated
215
+ */
216
+ @Property('100%')
217
+ public width: string | number;
218
+ /**
219
+ * Specifies the height of the popup list.
220
+ * > For more details about the popup configuration refer to
221
+ * [`Popup Configuration`](../../drop-down-list/getting-started#configure-the-popup-list) documentation.
222
+ *
223
+ * @default '300px'
224
+ * @aspType string
225
+ * @deprecated
226
+ */
227
+ @Property('300px')
228
+ public popupHeight: string | number;
229
+ /**
230
+ * Specifies the width of the popup list. By default, the popup width sets based on the width of
231
+ * the component.
232
+ * > For more details about the popup configuration refer to
233
+ * [`Popup Configuration`](../../drop-down-list/getting-started#configure-the-popup-list) documentation.
234
+ *
235
+ * @default '100%'
236
+ * @aspType string
237
+ * @deprecated
238
+ */
239
+ @Property('100%')
240
+ public popupWidth: string | number;
241
+ /**
242
+ * When set to true, the user interactions on the component are disabled.
243
+ *
244
+ * @default false
245
+ * @deprecated
246
+ */
247
+ @Property(false)
248
+ public readonly: boolean;
249
+ /**
250
+ * Gets or sets the display text of the selected item in the component.
251
+ *
252
+ * @default null
253
+ * @deprecated
254
+ */
255
+ @Property(null)
256
+ public text: string;
257
+ /**
258
+ * Gets or sets the value of the selected item in the component.
259
+ *
260
+ * @default null
261
+ * @isGenericType true
262
+ * @deprecated
263
+ */
264
+ @Property(null)
265
+ public value: number | string | boolean;
266
+ /**
267
+ * *Constructor for creating the component
268
+ *
269
+ * @param {ComboBoxModel} options - Specifies the ComboBox model.
270
+ * @param {string | HTMLElement} element - Specifies the element to render as component.
271
+ * @private
272
+ */
273
+ public constructor(options?: ComboBoxModel, element?: string | HTMLElement) {
274
+ super(options, element);
275
+ }
276
+ /**
277
+ * Initialize the event handler
278
+ *
279
+ * @private
280
+ * @returns {void}
281
+ */
282
+ protected preRender(): void {
283
+ super.preRender();
284
+ }
285
+
286
+ protected getLocaleName(): string {
287
+ return 'combo-box';
288
+ }
289
+
290
+ protected wireEvent(): void {
291
+ if (this.getModuleName() === 'combobox') {
292
+ EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.preventBlur, this);
293
+ EventHandler.add(this.inputWrapper.container, 'blur', this.onBlurHandler, this);
294
+ }
295
+ if (!isNullOrUndefined(this.inputWrapper.buttons[0])) {
296
+ EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick, this);
297
+ }
298
+ EventHandler.add(this.inputElement, 'focus', this.targetFocus, this);
299
+ if (!this.readonly) {
300
+ EventHandler.add(this.inputElement, 'input', this.onInput, this);
301
+ EventHandler.add(this.inputElement, 'keyup', this.onFilterUp, this);
302
+ EventHandler.add(this.inputElement, 'keydown', this.onFilterDown, this);
303
+ EventHandler.add(this.inputElement, 'paste', this.pasteHandler, this);
304
+ EventHandler.add(<HTMLElement & Window>window, 'resize',this.windowResize, this);
305
+ }
306
+ this.bindCommonEvent();
307
+ }
308
+
309
+ private preventBlur(e: MouseEvent): void {
310
+ if ((!this.allowFiltering && document.activeElement !== this.inputElement &&
311
+ !document.activeElement.classList.contains(dropDownListClasses.input) && Browser.isDevice || !Browser.isDevice)) {
312
+ e.preventDefault();
313
+ }
314
+ }
315
+
316
+ protected onBlurHandler(e: MouseEvent): void {
317
+ const inputValue: string = this.inputElement && this.inputElement.value === '' ?
318
+ null : this.inputElement && this.inputElement.value;
319
+ if (!isNullOrUndefined(this.listData) && !isNullOrUndefined(inputValue) && inputValue !== this.text) {
320
+ this.customValue(e);
321
+ }
322
+ super.onBlurHandler(e);
323
+ }
324
+
325
+ protected targetElement(): HTMLElement | HTMLInputElement {
326
+ return this.inputElement;
327
+ }
328
+
329
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
330
+ protected setOldText(text: string): void {
331
+ Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
332
+ this.customValue();
333
+ this.removeSelection();
334
+ }
335
+
336
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
337
+ protected setOldValue(value: string | number): void {
338
+ if (this.allowCustom) {
339
+ this.valueMuteChange(this.value);
340
+ } else {
341
+ this.valueMuteChange(null);
342
+ }
343
+ this.removeSelection();
344
+ this.setHiddenValue();
345
+ }
346
+ private valueMuteChange(value: string | number | boolean): void {
347
+ const inputValue: string = isNullOrUndefined(value) ? null : value.toString();
348
+ Input.setValue(inputValue, this.inputElement, this.floatLabelType, this.showClearButton);
349
+ this.setProperties({ value: value, text: value, index: null }, true);
350
+ this.activeIndex = this.index;
351
+ const fields: FieldSettingsModel = this.fields;
352
+ const dataItem: { [key: string]: string | Object } = {};
353
+ dataItem[fields.text] = isNullOrUndefined(value) ? null : value.toString();
354
+ dataItem[fields.value] = isNullOrUndefined(value) ? null : value.toString();
355
+ this.itemData = <{ [key: string]: Object }>dataItem;
356
+ this.item = null;
357
+ if (this.previousValue !== this.value) {
358
+ this.detachChangeEvent(null);
359
+ }
360
+ }
361
+ protected updateValues(): void {
362
+ if (!isNullOrUndefined(this.value)) {
363
+ const li: Element = this.getElementByValue(this.value);
364
+ if (li) {
365
+ this.setSelection(li, null);
366
+ } else if (this.allowCustom) {
367
+ this.valueMuteChange(this.value);
368
+ } else {
369
+ this.valueMuteChange(null);
370
+ }
371
+ } else if (this.text && isNullOrUndefined(this.value)) {
372
+ const li: Element = this.getElementByText(this.text);
373
+ if (li) {
374
+ this.setSelection(li, null);
375
+ } else {
376
+ Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
377
+ this.customValue();
378
+ }
379
+ } else {
380
+ this.setSelection(this.liCollections[this.activeIndex], null);
381
+ }
382
+ this.setHiddenValue();
383
+ Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
384
+ }
385
+
386
+ protected updateIconState(): void {
387
+ if (this.showClearButton) {
388
+ if (this.inputElement && this.inputElement.value !== '' && !this.readonly) {
389
+ removeClass([this.inputWrapper.clearButton], dropDownListClasses.clearIconHide);
390
+ } else {
391
+ addClass([this.inputWrapper.clearButton], dropDownListClasses.clearIconHide);
392
+ }
393
+ }
394
+ }
395
+
396
+ protected getAriaAttributes(): { [key: string]: string } {
397
+ const ariaAttributes: { [key: string]: string } = {
398
+ 'role': 'combobox',
399
+ 'aria-autocomplete': 'both',
400
+ 'aria-labelledby': this.hiddenElement.id,
401
+ 'aria-expanded': 'false',
402
+ 'aria-readonly': this.readonly.toString(),
403
+ 'autocomplete': 'off',
404
+ 'autocapitalize': 'off',
405
+ 'spellcheck': 'false'
406
+ };
407
+ return ariaAttributes;
408
+ }
409
+
410
+ protected searchLists(e: KeyboardEventArgs | MouseEvent): void {
411
+ this.isTyped = true;
412
+ if (this.isFiltering()) {
413
+ super.searchLists(e);
414
+ if (this.ulElement && this.filterInput.value.trim() === '') {
415
+ this.setHoverList(this.ulElement.querySelector('.' + dropDownListClasses.li));
416
+ }
417
+ } else {
418
+ if (this.ulElement && this.inputElement.value === '' && this.preventAutoFill) {
419
+ this.setHoverList(this.ulElement.querySelector('.' + dropDownListClasses.li));
420
+ }
421
+ this.incrementalSearch(e as KeyboardEventArgs);
422
+ }
423
+ }
424
+
425
+ protected getNgDirective(): string {
426
+ return 'EJS-COMBOBOX';
427
+ }
428
+
429
+ protected setSearchBox(): InputObject {
430
+ this.filterInput = this.inputElement;
431
+ let searchBoxContainer = (this.isFiltering() || ((this as any).isReact && this.getModuleName() === 'combobox'))? this.inputWrapper : inputObject;
432
+ return searchBoxContainer;
433
+ }
434
+
435
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
436
+ protected onActionComplete(ulElement: HTMLElement, list: { [key: string]: Object }[], e?: Object, isUpdated?: boolean): void {
437
+ super.onActionComplete(ulElement, list, e);
438
+ if (this.isSelectCustom) {
439
+ this.removeSelection();
440
+ }
441
+ if (!this.preventAutoFill && this.getModuleName() === 'combobox' && this.isTyped && !this.enableVirtualization) {
442
+ setTimeout(() => {
443
+ this.inlineSearch();
444
+ });
445
+ }
446
+ }
447
+
448
+ protected getFocusElement(): Element {
449
+ const dataItem: { [key: string]: string } = this.isSelectCustom ? { text: '' } : this.getItemData();
450
+ const selected: HTMLElement = !isNullOrUndefined(this.list) ? <HTMLElement>this.list.querySelector('.' + dropDownListClasses.selected) : this.list;
451
+ const isSelected: boolean = dataItem.text && dataItem.text.toString() === this.inputElement.value && !isNullOrUndefined(selected);
452
+ if (isSelected) {
453
+ return selected;
454
+ }
455
+ if ((Browser.isDevice && !this.isDropDownClick || !Browser.isDevice) &&
456
+ !isNullOrUndefined(this.liCollections) && this.liCollections.length > 0) {
457
+ const inputValue: string = this.inputElement.value;
458
+ const dataSource: { [key: string]: Object }[] = this.sortedData as { [key: string]: Object }[];
459
+ const type: string = this.typeOfData(dataSource).typeof as string;
460
+ let activeItem: { [key: string]: Element | number } =
461
+ Search(inputValue, this.liCollections, this.filterType, true, dataSource, this.fields, type);
462
+ if (this.enableVirtualization && inputValue !== '' && this.getModuleName() !== 'autocomplete' && this.isTyped && !this.allowFiltering) {
463
+ var updatingincrementalindex = false;
464
+ if ((this.viewPortInfo.endIndex >= this.incrementalEndIndex && this.incrementalEndIndex <= this.totalItemCount) || this.incrementalEndIndex == 0) {
465
+ updatingincrementalindex = true;
466
+ this.incrementalStartIndex = this.incrementalEndIndex;
467
+ if (this.incrementalEndIndex == 0) {
468
+ this.incrementalEndIndex = 100 > this.totalItemCount ? this.totalItemCount : 100;
469
+ }
470
+ else {
471
+ this.incrementalEndIndex = this.incrementalEndIndex + 100 > this.totalItemCount ? this.totalItemCount : this.incrementalEndIndex + 100;
472
+ }
473
+ this.updateIncrementalInfo(this.incrementalStartIndex, this.incrementalEndIndex);
474
+ updatingincrementalindex = true;
475
+ }
476
+ if (this.viewPortInfo.startIndex !== 0 || updatingincrementalindex) {
477
+ this.updateIncrementalView(0, this.itemCount);
478
+ }
479
+ activeItem = Search(inputValue, this.incrementalLiCollections, this.filterType, true, dataSource, this.fields, type);
480
+ while (isNullOrUndefined(activeItem) && this.incrementalEndIndex < this.totalItemCount) {
481
+ this.incrementalStartIndex = this.incrementalEndIndex;
482
+ this.incrementalEndIndex = this.incrementalEndIndex + 100 > this.totalItemCount ? this.totalItemCount : this.incrementalEndIndex + 100;
483
+ this.updateIncrementalInfo(this.incrementalStartIndex, this.incrementalEndIndex);
484
+ updatingincrementalindex = true;
485
+ if (this.viewPortInfo.startIndex !== 0 || updatingincrementalindex) {
486
+ this.updateIncrementalView(0, this.itemCount);
487
+ }
488
+ activeItem = Search(inputValue, this.incrementalLiCollections, this.filterType, true, dataSource, this.fields, type);
489
+ if (!isNullOrUndefined(activeItem)) {
490
+ break;
491
+ }
492
+ if (isNullOrUndefined(activeItem) && this.incrementalEndIndex >= this.totalItemCount) {
493
+ this.incrementalStartIndex = 0;
494
+ this.incrementalEndIndex = 100 > this.totalItemCount ? this.totalItemCount : 100;
495
+ break;
496
+ }
497
+ }
498
+ if (activeItem.index) {
499
+ if ((!(this.viewPortInfo.startIndex >= (activeItem.index as number))) || (!((activeItem.index as number) >= this.viewPortInfo.endIndex))) {
500
+ var startIndex = (activeItem.index as number) - ((this.itemCount / 2) - 2) > 0 ? (activeItem.index as number) - ((this.itemCount / 2) - 2) : 0;
501
+ var endIndex = this.viewPortInfo.startIndex + this.itemCount > this.totalItemCount ? this.totalItemCount : this.viewPortInfo.startIndex + this.itemCount;
502
+ if(startIndex != this.viewPortInfo.startIndex) {
503
+ this.updateIncrementalView(startIndex, endIndex);
504
+ }
505
+ }
506
+ }
507
+ if (!isNullOrUndefined(activeItem.item)) {
508
+ var index_1 = this.getIndexByValue((activeItem.item as Element).getAttribute('data-value')) - this.skeletonCount;
509
+ if (index_1 > this.itemCount / 2) {
510
+ var startIndex = this.viewPortInfo.startIndex + ((this.itemCount / 2) - 2) < this.totalItemCount ? this.viewPortInfo.startIndex + ((this.itemCount / 2) - 2) : this.totalItemCount;
511
+ var endIndex = this.viewPortInfo.startIndex + this.itemCount > this.totalItemCount ? this.totalItemCount : this.viewPortInfo.startIndex + this.itemCount;
512
+ this.updateIncrementalView(startIndex, endIndex);
513
+ }
514
+ activeItem.item = this.getElementByValue((activeItem.item as Element).getAttribute('data-value'));
515
+ }
516
+ else {
517
+ this.updateIncrementalView(0, this.itemCount);
518
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
519
+ (this.list.getElementsByClassName('e-virtual-ddl-content')[0] as any).style = this.getTransformValues();
520
+ this.list.scrollTop = 0;
521
+ }
522
+ if(activeItem && activeItem.item){
523
+ activeItem.item = this.getElementByValue((activeItem.item as Element).getAttribute('data-value'));
524
+ }
525
+ }
526
+ const activeElement: Element = activeItem.item as Element;
527
+ if (!isNullOrUndefined(activeElement)) {
528
+ const count: number = this.getIndexByValue(activeElement.getAttribute('data-value')) - 1;
529
+ const height: number = parseInt(getComputedStyle(this.liCollections[0], null).getPropertyValue('height'), 10);
530
+ if (!isNaN(height) && this.getModuleName() !== 'autocomplete') {
531
+ this.removeFocus();
532
+ const fixedHead: number = this.fields.groupBy ? this.liCollections[0].offsetHeight : 0;
533
+ if (!this.enableVirtualization) {
534
+ this.list.scrollTop = count * height + fixedHead;
535
+ } else {
536
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
537
+ (this.list.getElementsByClassName('e-virtual-ddl-content')[0] as any).style = this.getTransformValues();
538
+ if (this.enableVirtualization && !this.fields.groupBy) {
539
+ var selectedLiOffsetTop = this.virtualListInfo && this.virtualListInfo.startIndex ? (activeElement as HTMLElement).offsetTop + (this.virtualListInfo.startIndex * (activeElement as HTMLElement).offsetHeight) : (activeElement as HTMLElement).offsetTop;
540
+ this.list.scrollTop = selectedLiOffsetTop - (this.list.querySelectorAll('.e-virtual-list').length * (activeElement as HTMLElement).offsetHeight);
541
+ }
542
+ }
543
+ addClass([activeElement], dropDownListClasses.focus);
544
+ }
545
+ } else {
546
+ if (this.isSelectCustom && this.inputElement.value.trim() !== '') {
547
+ this.removeFocus();
548
+ if (!this.enableVirtualization) {
549
+ this.list.scrollTop = 0;
550
+ }
551
+ }
552
+ }
553
+ return activeElement;
554
+ } else {
555
+ return null;
556
+ }
557
+ }
558
+
559
+ protected setValue(e?: KeyboardEventArgs): boolean {
560
+ if (e && e.type === 'keydown' && e.action === 'enter') {
561
+ this.removeFillSelection();
562
+ }
563
+ if (this.autofill && this.getModuleName() === 'combobox' && e && e.type === 'keydown' && e.action !== 'enter') {
564
+ this.preventAutoFill = false;
565
+ this.inlineSearch(e);
566
+ return false;
567
+ } else {
568
+ return super.setValue(e);
569
+ }
570
+ }
571
+ protected checkCustomValue(): void {
572
+ this.itemData = this.getDataByValue(this.value);
573
+ const dataItem: { [key: string]: string } = this.getItemData();
574
+ if (!(this.allowCustom && isNullOrUndefined(dataItem.value) && isNullOrUndefined(dataItem.text))) {
575
+ this.setProperties({ 'value': dataItem.value }, !this.allowCustom);
576
+ }
577
+ }
578
+ /**
579
+ * Shows the spinner loader.
580
+ *
581
+ * @returns {void}
582
+ * @deprecated
583
+ */
584
+ public showSpinner(): void {
585
+ if (isNullOrUndefined(this.spinnerElement)) {
586
+ this.spinnerElement = (this.getModuleName() === 'autocomplete') ? (this.inputWrapper.buttons[0] ||
587
+ this.inputWrapper.clearButton ||
588
+ Input.appendSpan('e-input-group-icon ' + SPINNER_CLASS, this.inputWrapper.container, this.createElement)) :
589
+ (this.inputWrapper.buttons[0] || this.inputWrapper.clearButton);
590
+ addClass([this.spinnerElement], dropDownListClasses.disableIcon);
591
+ createSpinner(
592
+ {
593
+ target: this.spinnerElement,
594
+ width: Browser.isDevice ? '16px' : '14px'
595
+ },
596
+ this.createElement);
597
+ showSpinner(this.spinnerElement);
598
+ }
599
+ }
600
+ /**
601
+ * Hides the spinner loader.
602
+ *
603
+ * @returns {void}
604
+ * @deprecated
605
+ */
606
+ public hideSpinner(): void {
607
+ if (!isNullOrUndefined(this.spinnerElement)) {
608
+ hideSpinner(this.spinnerElement);
609
+ removeClass([this.spinnerElement], dropDownListClasses.disableIcon);
610
+ if (this.spinnerElement.classList.contains(SPINNER_CLASS)) {
611
+ detach(this.spinnerElement);
612
+ } else {
613
+ this.spinnerElement.innerHTML = '';
614
+ }
615
+ this.spinnerElement = null;
616
+ }
617
+ }
618
+
619
+ protected setAutoFill(activeElement: Element, isHover?: boolean): void {
620
+ if (!isHover) {
621
+ this.setHoverList(activeElement);
622
+ }
623
+ if (this.autofill && !this.preventAutoFill) {
624
+ const currentValue: string = <string>this.getTextByValue(activeElement.getAttribute('data-value')).toString();
625
+ const currentFillValue: string | number | boolean = this.getFormattedValue(activeElement.getAttribute('data-value'));
626
+ if (this.getModuleName() === 'combobox') {
627
+ if (!this.isSelected && this.previousValue !== currentFillValue) {
628
+ this.updateSelectedItem(activeElement, null);
629
+ this.isSelected = true;
630
+ this.previousValue = this.getFormattedValue(activeElement.getAttribute('data-value'));
631
+ } else {
632
+ this.updateSelectedItem(activeElement, null, true);
633
+ }
634
+ }
635
+ if (!this.isAndroidAutoFill(currentValue)) {
636
+ this.setAutoFillSelection(currentValue, isHover);
637
+ }
638
+ }
639
+ }
640
+
641
+ private isAndroidAutoFill(value: string): boolean {
642
+ if (Browser.isAndroid) {
643
+ const currentPoints: { [key: string]: number } = this.getSelectionPoints();
644
+ const prevEnd: number = this.prevSelectPoints.end;
645
+ const curEnd: number = currentPoints.end;
646
+ const prevStart: number = this.prevSelectPoints.start;
647
+ const curStart: number = currentPoints.start;
648
+ if (prevEnd !== 0 && ((prevEnd === value.length && prevStart === value.length) ||
649
+ (prevStart > curStart && prevEnd > curEnd) || (prevEnd === curEnd && prevStart === curStart))) {
650
+ return true;
651
+ } else {
652
+ return false;
653
+ }
654
+ } else {
655
+ return false;
656
+ }
657
+ }
658
+
659
+ protected clearAll(e?: MouseEvent | KeyboardEventArgs, property?: ComboBoxModel): void {
660
+ if (isNullOrUndefined(property) || (!isNullOrUndefined(property) && isNullOrUndefined(property.dataSource))) {
661
+ super.clearAll(e);
662
+ }
663
+ if (this.isFiltering() && !isNullOrUndefined(e) && e.target === this.inputWrapper.clearButton) {
664
+ this.searchLists(e);
665
+ }
666
+ }
667
+
668
+ protected isSelectFocusItem(element: Element): boolean {
669
+ return !isNullOrUndefined(element);
670
+ }
671
+
672
+ private inlineSearch(e?: KeyboardEventArgs): void {
673
+ const isKeyNavigate: boolean = (e && (e.action === 'down' || e.action === 'up' ||
674
+ e.action === 'home' || e.action === 'end' || e.action === 'pageUp' || e.action === 'pageDown'));
675
+ const activeElement: Element = isKeyNavigate ? this.liCollections[this.activeIndex] : this.getFocusElement();
676
+ if (!isNullOrUndefined(activeElement)) {
677
+ if (!isKeyNavigate) {
678
+ const value: string | number | boolean = this.getFormattedValue(activeElement.getAttribute('data-value'));
679
+ this.activeIndex = this.getIndexByValue(value);
680
+ this.activeIndex = !isNullOrUndefined(this.activeIndex) ? this.activeIndex : null;
681
+ }
682
+ this.preventAutoFill = this.inputElement.value === '' ? false : this.preventAutoFill;
683
+ this.setAutoFill(activeElement, isKeyNavigate);
684
+ } else if (this.inputElement.value === '') {
685
+ this.activeIndex = null;
686
+ if (!isNullOrUndefined(this.list)) {
687
+ if (!this.enableVirtualization) {
688
+ this.list.scrollTop = 0;
689
+ }
690
+ const focusItem: Element = this.list.querySelector('.' + dropDownListClasses.li);
691
+ this.setHoverList(focusItem);
692
+ }
693
+ } else {
694
+ this.activeIndex = null;
695
+ this.removeSelection();
696
+ if (this.liCollections && this.liCollections.length > 0 && !this.isCustomFilter) {
697
+ this.removeFocus();
698
+ }
699
+ }
700
+ }
701
+
702
+ protected incrementalSearch(e: KeyboardEventArgs): void {
703
+ this.showPopup(e);
704
+ if (!isNullOrUndefined(this.listData)) {
705
+ this.inlineSearch(e);
706
+ e.preventDefault();
707
+ }
708
+ }
709
+
710
+ private setAutoFillSelection(currentValue: string, isKeyNavigate: boolean = false): void {
711
+ const selection: { [key: string]: number } = this.getSelectionPoints();
712
+ const value: string = this.inputElement.value.substr(0, selection.start);
713
+ if (value && (value.toLowerCase() === currentValue.substr(0, selection.start).toLowerCase())) {
714
+ const inputValue: string = value + currentValue.substr(value.length, currentValue.length);
715
+ Input.setValue(inputValue, this.inputElement, this.floatLabelType, this.showClearButton);
716
+ this.inputElement.setSelectionRange(selection.start, this.inputElement.value.length);
717
+ } else if (isKeyNavigate) {
718
+ Input.setValue(currentValue, this.inputElement, this.floatLabelType, this.showClearButton);
719
+ this.inputElement.setSelectionRange(0, this.inputElement.value.length);
720
+ }
721
+ }
722
+
723
+ protected getValueByText(text: string): string | number | boolean {
724
+ return super.getValueByText(text, true, this.ignoreAccent);
725
+ }
726
+
727
+ protected unWireEvent(): void {
728
+ if (this.getModuleName() === 'combobox') {
729
+ EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.preventBlur);
730
+ EventHandler.remove(this.inputWrapper.container, 'blur', this.onBlurHandler);
731
+ }
732
+ if (!isNullOrUndefined(this.inputWrapper.buttons[0])) {
733
+ EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick);
734
+ }
735
+ if (this.inputElement) {
736
+ EventHandler.remove(this.inputElement, 'focus', this.targetFocus);
737
+ if (!this.readonly) {
738
+ EventHandler.remove(this.inputElement, 'input', this.onInput);
739
+ EventHandler.remove(this.inputElement, 'keyup', this.onFilterUp);
740
+ EventHandler.remove(this.inputElement, 'keydown', this.onFilterDown);
741
+ EventHandler.remove(this.inputElement, 'paste', this.pasteHandler);
742
+ EventHandler.remove(<HTMLElement & Window>window, 'resize', this.windowResize);
743
+ }
744
+ }
745
+ this.unBindCommonEvent();
746
+ }
747
+
748
+ protected setSelection(li: Element, e: MouseEvent | KeyboardEventArgs | TouchEvent): void {
749
+ super.setSelection(li, e);
750
+ if (!isNullOrUndefined(li) && !this.autofill && !this.isDropDownClick) {
751
+ this.removeFocus();
752
+ }
753
+ }
754
+ protected selectCurrentItem(e: KeyboardEventArgs): void {
755
+ let li: Element;
756
+ if (this.isPopupOpen) {
757
+ if (this.isSelected) {
758
+ li = this.list.querySelector('.' + dropDownListClasses.selected);
759
+ } else {
760
+ li = this.list.querySelector('.' + dropDownListClasses.focus);
761
+ }
762
+ if (li) {
763
+ this.setSelection(li, e);
764
+ this.isTyped = false;
765
+ }
766
+ if (this.isSelected) {
767
+ this.isSelectCustom = false;
768
+ this.onChangeEvent(e);
769
+ }
770
+ }
771
+ if (e.action === 'enter' && this.inputElement.value.trim() === '') {
772
+ this.clearAll(e);
773
+ } else if (this.isTyped && !this.isSelected && isNullOrUndefined(li)) {
774
+ this.customValue(e);
775
+ }
776
+ this.hidePopup(e);
777
+ }
778
+
779
+ protected setHoverList(li: Element): void {
780
+ this.removeSelection();
781
+ if (this.isValidLI(li) && !li.classList.contains(dropDownListClasses.selected)) {
782
+ this.removeFocus();
783
+ li.classList.add(dropDownListClasses.focus);
784
+ }
785
+ }
786
+ private targetFocus(e: MouseEvent): void {
787
+ if (Browser.isDevice && !this.allowFiltering) {
788
+ this.preventFocus = false;
789
+ }
790
+ this.onFocus(e);
791
+ Input.calculateWidth(this.inputElement, this.inputWrapper.container);
792
+ }
793
+ protected dropDownClick(e: MouseEvent): void {
794
+ e.preventDefault();
795
+ if (Browser.isDevice && !this.isFiltering()) {
796
+ this.preventFocus = true;
797
+ }
798
+ super.dropDownClick(e);
799
+ }
800
+ private customValue(e?: MouseEvent | KeyboardEventArgs | TouchEvent): void {
801
+ const value: string | number | boolean = this.getValueByText(this.inputElement.value);
802
+ if (!this.allowCustom && this.inputElement.value !== '') {
803
+ const previousValue: string | number | boolean = this.previousValue;
804
+ const currentValue: string | number | boolean = this.value;
805
+ this.setProperties({ value: value });
806
+ if (isNullOrUndefined(this.value)) {
807
+ Input.setValue('', this.inputElement, this.floatLabelType, this.showClearButton);
808
+ }
809
+ if (this.autofill && previousValue === this.value && currentValue !== this.value) {
810
+ this.onChangeEvent(null);
811
+ }
812
+ } else if (this.inputElement.value.trim() !== '') {
813
+ const previousValue: string | number | boolean = this.value;
814
+ if (isNullOrUndefined(value)) {
815
+ const value: string | Object = this.inputElement.value === '' ? null : this.inputElement.value;
816
+ // eslint-disable-next-line max-len
817
+ const eventArgs: { [key: string]: Object | string | number } = <{ [key: string]: Object | string | number }>{ text: value, item: {} };
818
+ if (!this.initial) {
819
+ this.trigger('customValueSpecifier', eventArgs, (eventArgs: { [key: string]: Object | string | number }) => {
820
+ this.updateCustomValueCallback(value, eventArgs, previousValue, e);
821
+ });
822
+ } else {
823
+ this.updateCustomValueCallback(value, eventArgs, previousValue);
824
+ }
825
+ } else {
826
+ this.isSelectCustom = false;
827
+ this.setProperties({ value: value });
828
+ if (previousValue !== this.value) {
829
+ this.onChangeEvent(e);
830
+ }
831
+ }
832
+ } else if (this.allowCustom) {
833
+ this.isSelectCustom = true;
834
+ }
835
+ }
836
+ private updateCustomValueCallback(
837
+ value: string | Object,
838
+ eventArgs: { [key: string]: Object | string | number },
839
+ previousValue: string | number | boolean,
840
+ e?: MouseEvent | KeyboardEventArgs | TouchEvent): void {
841
+ const fields: FieldSettingsModel = this.fields;
842
+ const item: { [key: string]: string | Object } = <{ [key: string]: string | Object }>eventArgs.item;
843
+ let dataItem: { [key: string]: string | Object } = {};
844
+ if (item && getValue(fields.text, item) && getValue(fields.value, item)) {
845
+ dataItem = item;
846
+ } else {
847
+ setValue(fields.text, value, dataItem);
848
+ setValue(fields.value, value, dataItem);
849
+ }
850
+ this.itemData = <{ [key: string]: Object }>dataItem;
851
+ const changeData: { [key: string]: Object } = {
852
+ text: getValue(fields.text, this.itemData),
853
+ value: getValue(fields.value, this.itemData),
854
+ index: null
855
+ };
856
+ this.setProperties(changeData, true);
857
+ this.setSelection(null, null);
858
+ this.isSelectCustom = true;
859
+ if (previousValue !== this.value) {
860
+ this.onChangeEvent(e);
861
+ }
862
+ }
863
+ /**
864
+ * Dynamically change the value of properties.
865
+ *
866
+ * @param {ComboBoxModel} newProp - Returns the dynamic property value of the component.
867
+ * @param {ComboBoxModel} oldProp - Returns the previous property value of the component.
868
+ * @private
869
+ * @returns {void}
870
+ */
871
+ public onPropertyChanged(newProp: ComboBoxModel, oldProp: ComboBoxModel): void {
872
+ if (this.getModuleName() === 'combobox') {
873
+ this.checkData(newProp);
874
+ this.setUpdateInitial(['fields', 'query', 'dataSource'], newProp as { [key: string]: string });
875
+ }
876
+ for (const prop of Object.keys(newProp)) {
877
+ switch (prop) {
878
+ case 'readonly':
879
+ Input.setReadonly(this.readonly, this.inputElement as HTMLInputElement);
880
+ if (this.readonly) {
881
+ EventHandler.remove(this.inputElement, 'input', this.onInput);
882
+ EventHandler.remove(this.inputElement, 'keyup', this.onFilterUp);
883
+ EventHandler.remove(this.inputElement, 'keydown', this.onFilterDown);
884
+ } else {
885
+ EventHandler.add(this.inputElement, 'input', this.onInput, this);
886
+ EventHandler.add(this.inputElement, 'keyup', this.onFilterUp, this);
887
+ EventHandler.add(this.inputElement, 'keydown', this.onFilterDown, this);
888
+ }
889
+ this.setReadOnly();
890
+ break;
891
+ case 'allowFiltering':
892
+ this.setSearchBox();
893
+ if (this.isFiltering() && this.getModuleName() === 'combobox' && isNullOrUndefined(this.list)) {
894
+ super.renderList();
895
+ }
896
+ break;
897
+ case 'allowCustom':
898
+ break;
899
+ default: {
900
+ // eslint-disable-next-line max-len
901
+ const comboProps: { [key: string]: Object } = this.getPropObject(prop, <{ [key: string]: string }>newProp, <{ [key: string]: string }>oldProp);
902
+ super.onPropertyChanged(comboProps.newProperty, comboProps.oldProperty);
903
+ if (this.isFiltering() && prop === 'dataSource' && isNullOrUndefined(this.list) && this.itemTemplate &&
904
+ this.getModuleName() === 'combobox') {
905
+ super.renderList();
906
+ }
907
+ break;
908
+ }
909
+ }
910
+ }
911
+ }
912
+ /**
913
+ * To initialize the control rendering.
914
+ *
915
+ * @private
916
+ * @returns {void}
917
+ */
918
+ public render(): void {
919
+ super.render();
920
+ this.setSearchBox();
921
+ if (this.isFiltering() && this.getModuleName() === 'combobox' && isNullOrUndefined(this.list)) {
922
+ super.renderList();
923
+ }
924
+ this.renderComplete();
925
+ }
926
+ /**
927
+ * Return the module name of this component.
928
+ *
929
+ * @private
930
+ * @returns {string} Return the module name of this component.
931
+ */
932
+ public getModuleName(): string {
933
+ return 'combobox';
934
+ }
935
+ /**
936
+ * Adds a new item to the combobox popup list. By default, new item appends to the list as the last item,
937
+ * but you can insert based on the index parameter.
938
+ *
939
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
940
+ * @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
941
+ * @returns {void}
942
+ * @deprecated
943
+ */
944
+ public addItem(
945
+ items: { [key: string]: Object }[] | { [key: string]: Object } | string | boolean | number | string[] | boolean[] | number[],
946
+ itemIndex?: number): void {
947
+ super.addItem(items, itemIndex);
948
+ }
949
+ /**
950
+ * To filter the data from given data source by using query
951
+ *
952
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
953
+ * @param {Query} query - Specify the query to filter the data.
954
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
955
+ * @returns {void}
956
+ * @deprecated
957
+ */
958
+ public filter(
959
+ dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
960
+ query?: Query, fields?: FieldSettingsModel): void {
961
+ super.filter(dataSource, query, fields);
962
+ }
963
+ /* eslint-disable valid-jsdoc, jsdoc/require-param */
964
+ /**
965
+ * Opens the popup that displays the list of items.
966
+ *
967
+ * @returns {void}
968
+ * @deprecated
969
+ */
970
+ public showPopup(e?: MouseEvent | KeyboardEventArgs | TouchEvent): void {
971
+ /* eslint-enable valid-jsdoc, jsdoc/require-param */
972
+ super.showPopup(e);
973
+ }
974
+ /* eslint-disable valid-jsdoc, jsdoc/require-param */
975
+ /**
976
+ * Hides the popup if it is in open state.
977
+ *
978
+ * @returns {void}
979
+ * @deprecated
980
+ */
981
+ public hidePopup(e?: MouseEvent | KeyboardEventArgs | TouchEvent): void {
982
+ /* eslint-enable valid-jsdoc, jsdoc/require-param */
983
+ const inputValue: string | Object = this.inputElement && this.inputElement.value === '' ? null
984
+ : this.inputElement && this.inputElement.value;
985
+ if (!isNullOrUndefined(this.listData)) {
986
+ const isEscape: boolean = this.isEscapeKey;
987
+ if (this.isEscapeKey) {
988
+ Input.setValue(this.typedString, this.inputElement, this.floatLabelType, this.showClearButton);
989
+ this.isEscapeKey = false;
990
+ }
991
+ if (this.autofill) {
992
+ this.removeFillSelection();
993
+ }
994
+ const dataItem: { [key: string]: string } = this.isSelectCustom ? { text: '' } : this.getItemData();
995
+ const selected: HTMLElement = !isNullOrUndefined(this.list) ? <HTMLElement>this.list.querySelector('.' + dropDownListClasses.selected) : null;
996
+ if (this.inputElement && dataItem.text === this.inputElement.value && !isNullOrUndefined(selected)) {
997
+ if (this.isSelected) {
998
+ this.onChangeEvent(e);
999
+ this.isSelectCustom = false;
1000
+ }
1001
+ super.hidePopup(e);
1002
+ return;
1003
+ }
1004
+ if (this.getModuleName() === 'combobox' && this.inputElement.value.trim() !== '') {
1005
+ const dataSource: { [key: string]: Object }[] = this.sortedData as { [key: string]: Object }[];
1006
+ const type: string = this.typeOfData(dataSource).typeof as string;
1007
+ const searchItem: { [key: string]: number | Element } = Search(this.inputElement.value, this.liCollections, 'Equal', true, dataSource, this.fields, type);
1008
+ this.selectedLI = searchItem.item as HTMLElement;
1009
+ if (isNullOrUndefined(searchItem.index)) {
1010
+ searchItem.index = Search(this.inputElement.value, this.liCollections, 'StartsWith', true, dataSource, this.fields, type).index as number;
1011
+ }
1012
+ this.activeIndex = searchItem.index as number;
1013
+ if (!isNullOrUndefined(this.selectedLI)) {
1014
+ this.updateSelectedItem(this.selectedLI, null, true);
1015
+ } else if (isEscape) {
1016
+ this.isSelectCustom = true;
1017
+ this.removeSelection();
1018
+ }
1019
+ }
1020
+ if (!this.isEscapeKey && this.isTyped && !this.isInteracted) {
1021
+ this.customValue(e);
1022
+ }
1023
+ }
1024
+ if (isNullOrUndefined(this.listData) && this.allowCustom && !isNullOrUndefined(inputValue) && inputValue !== this.value) {
1025
+ this.customValue();
1026
+ }
1027
+ super.hidePopup(e);
1028
+ }
1029
+ /**
1030
+ * Sets the focus to the component for interaction.
1031
+ *
1032
+ * @returns {void}
1033
+ */
1034
+ public focusIn(): void {
1035
+ if (!this.enabled) {
1036
+ return;
1037
+ }
1038
+ if (Browser.isDevice && !this.isFiltering()) {
1039
+ this.preventFocus = true;
1040
+ }
1041
+ super.focusIn();
1042
+ }
1043
+ /**
1044
+ * Allows you to clear the selected values from the component.
1045
+ *
1046
+ * @returns {void}
1047
+ * @deprecated
1048
+ */
1049
+ public clear(): void {
1050
+ this.value = null;
1051
+ }
1052
+ /* eslint-disable valid-jsdoc, jsdoc/require-param */
1053
+ /**
1054
+ * Moves the focus from the component if the component is already focused.
1055
+ *
1056
+ * @returns {void}
1057
+ * @deprecated
1058
+ */
1059
+ public focusOut(e?: MouseEvent | KeyboardEventArgs): void {
1060
+ /* eslint-enable valid-jsdoc, jsdoc/require-param */
1061
+ super.focusOut(e);
1062
+ }
1063
+ /* eslint-disable valid-jsdoc, jsdoc/require-returns-description */
1064
+ /**
1065
+ * Gets all the list items bound on this component.
1066
+ *
1067
+ * @returns {Element[]}
1068
+ * @deprecated
1069
+ */
1070
+ public getItems(): Element[] {
1071
+ return super.getItems();
1072
+ }
1073
+ /**
1074
+ * Gets the data Object that matches the given value.
1075
+ *
1076
+ * @param { string | number } value - Specifies the value of the list item.
1077
+ * @returns {Object}
1078
+ * @deprecated
1079
+ */
1080
+ public getDataByValue(value: string | number | boolean)
1081
+ : { [key: string]: Object } | string | number | boolean {
1082
+ return super.getDataByValue(value);
1083
+ }
1084
+ /* eslint-enable valid-jsdoc, jsdoc/require-returns-description */
1085
+ protected renderHightSearch(): void {
1086
+ // update high light search
1087
+ }
1088
+ }
1089
+ export interface CustomValueSpecifierEventArgs {
1090
+ /**
1091
+ * Gets the typed custom text to make a own text format and assign it to `item` argument.
1092
+ */
1093
+ text: string
1094
+ /**
1095
+ * Sets the text custom format data for set a `value` and `text`.
1096
+ *
1097
+ */
1098
+ item: { [key: string]: string | Object }
1099
+ }