@syncfusion/ej2-dropdowns 20.2.48 → 20.3.47

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 (362) hide show
  1. package/CHANGELOG.md +14 -28
  2. package/dist/ej2-dropdowns.min.js +10 -0
  3. package/dist/ej2-dropdowns.umd.min.js +2 -2
  4. package/dist/ej2-dropdowns.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-dropdowns.es2015.js +1437 -47
  6. package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
  7. package/dist/es6/ej2-dropdowns.es5.js +1463 -51
  8. package/dist/es6/ej2-dropdowns.es5.js.map +1 -1
  9. package/dist/global/ej2-dropdowns.min.js +2 -2
  10. package/dist/global/ej2-dropdowns.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/mention.d.ts +4 -0
  13. package/mention.js +4 -0
  14. package/package.json +12 -12
  15. package/src/auto-complete/auto-complete.js +6 -2
  16. package/src/combo-box/combo-box.js +1 -3
  17. package/src/drop-down-base/drop-down-base.d.ts +2 -0
  18. package/src/drop-down-base/drop-down-base.js +6 -1
  19. package/src/drop-down-list/drop-down-list.d.ts +1 -0
  20. package/src/drop-down-list/drop-down-list.js +33 -21
  21. package/src/index.d.ts +1 -0
  22. package/src/index.js +1 -0
  23. package/src/list-box/list-box.js +16 -11
  24. package/src/mention/index.d.ts +5 -0
  25. package/src/mention/index.js +4 -0
  26. package/src/mention/mention-model.d.ts +285 -0
  27. package/src/mention/mention.d.ts +451 -0
  28. package/src/mention/mention.js +1369 -0
  29. package/src/multi-select/checkbox-selection.js +1 -4
  30. package/src/multi-select/multi-select-model.d.ts +1 -1
  31. package/src/multi-select/multi-select.d.ts +1 -0
  32. package/src/multi-select/multi-select.js +35 -9
  33. package/styles/auto-complete/_all.scss +1 -1
  34. package/styles/auto-complete/_bootstrap-dark-definition.scss +1 -1
  35. package/styles/auto-complete/_bootstrap-definition.scss +1 -1
  36. package/styles/auto-complete/_bootstrap4-definition.scss +2 -2
  37. package/styles/auto-complete/_bootstrap5-definition.scss +1 -1
  38. package/styles/auto-complete/_fabric-dark-definition.scss +1 -1
  39. package/styles/auto-complete/_fabric-definition.scss +1 -1
  40. package/styles/auto-complete/_fluent-definition.scss +1 -1
  41. package/styles/auto-complete/_fusionnew-definition.scss +1 -1
  42. package/styles/auto-complete/_highcontrast-definition.scss +1 -1
  43. package/styles/auto-complete/_highcontrast-light-definition.scss +1 -1
  44. package/styles/auto-complete/_material-dark-definition.scss +1 -1
  45. package/styles/auto-complete/_material-definition.scss +1 -1
  46. package/styles/auto-complete/_material3-definition.scss +1 -1
  47. package/styles/auto-complete/_tailwind-definition.scss +1 -1
  48. package/styles/auto-complete/bootstrap-dark.css +3 -1
  49. package/styles/auto-complete/bootstrap.css +3 -1
  50. package/styles/auto-complete/bootstrap4.css +3 -1
  51. package/styles/auto-complete/bootstrap5-dark.css +3 -1
  52. package/styles/auto-complete/bootstrap5.css +3 -1
  53. package/styles/auto-complete/fabric-dark.css +3 -1
  54. package/styles/auto-complete/fabric.css +3 -1
  55. package/styles/auto-complete/fluent-dark.css +3 -1
  56. package/styles/auto-complete/fluent.css +3 -1
  57. package/styles/auto-complete/highcontrast-light.css +3 -1
  58. package/styles/auto-complete/highcontrast.css +3 -1
  59. package/styles/auto-complete/material-dark.css +3 -1
  60. package/styles/auto-complete/material.css +3 -1
  61. package/styles/auto-complete/tailwind-dark.css +3 -1
  62. package/styles/auto-complete/tailwind.css +3 -1
  63. package/styles/bootstrap-dark.css +94 -42
  64. package/styles/bootstrap-dark.scss +1 -0
  65. package/styles/bootstrap.css +94 -42
  66. package/styles/bootstrap.scss +1 -0
  67. package/styles/bootstrap4.css +95 -42
  68. package/styles/bootstrap4.scss +1 -0
  69. package/styles/bootstrap5-dark.css +101 -44
  70. package/styles/bootstrap5-dark.scss +1 -0
  71. package/styles/bootstrap5.css +101 -44
  72. package/styles/bootstrap5.scss +1 -0
  73. package/styles/combo-box/_all.scss +1 -1
  74. package/styles/combo-box/_bootstrap-dark-definition.scss +1 -1
  75. package/styles/combo-box/_bootstrap-definition.scss +1 -1
  76. package/styles/combo-box/_bootstrap4-definition.scss +2 -2
  77. package/styles/combo-box/_bootstrap5-definition.scss +1 -1
  78. package/styles/combo-box/_fabric-dark-definition.scss +1 -1
  79. package/styles/combo-box/_fabric-definition.scss +1 -1
  80. package/styles/combo-box/_fluent-definition.scss +1 -1
  81. package/styles/combo-box/_fusionnew-definition.scss +1 -1
  82. package/styles/combo-box/_highcontrast-definition.scss +1 -1
  83. package/styles/combo-box/_highcontrast-light-definition.scss +1 -1
  84. package/styles/combo-box/_material-dark-definition.scss +1 -1
  85. package/styles/combo-box/_material-definition.scss +1 -1
  86. package/styles/combo-box/_material3-definition.scss +1 -1
  87. package/styles/combo-box/_tailwind-definition.scss +1 -1
  88. package/styles/combo-box/bootstrap-dark.css +3 -1
  89. package/styles/combo-box/bootstrap.css +3 -1
  90. package/styles/combo-box/bootstrap4.css +3 -1
  91. package/styles/combo-box/bootstrap5-dark.css +3 -1
  92. package/styles/combo-box/bootstrap5.css +3 -1
  93. package/styles/combo-box/fabric-dark.css +3 -1
  94. package/styles/combo-box/fabric.css +3 -1
  95. package/styles/combo-box/fluent-dark.css +3 -1
  96. package/styles/combo-box/fluent.css +3 -1
  97. package/styles/combo-box/highcontrast-light.css +3 -1
  98. package/styles/combo-box/highcontrast.css +3 -1
  99. package/styles/combo-box/material-dark.css +3 -1
  100. package/styles/combo-box/material.css +3 -1
  101. package/styles/combo-box/tailwind-dark.css +3 -1
  102. package/styles/combo-box/tailwind.css +3 -1
  103. package/styles/drop-down-base/_all.scss +1 -1
  104. package/styles/drop-down-base/_bootstrap-dark-definition.scss +8 -2
  105. package/styles/drop-down-base/_bootstrap-definition.scss +6 -1
  106. package/styles/drop-down-base/_bootstrap4-definition.scss +6 -1
  107. package/styles/drop-down-base/_bootstrap5-definition.scss +8 -3
  108. package/styles/drop-down-base/_fabric-dark-definition.scss +6 -1
  109. package/styles/drop-down-base/_fabric-definition.scss +6 -1
  110. package/styles/drop-down-base/_fluent-definition.scss +8 -2
  111. package/styles/drop-down-base/_fusionnew-definition.scss +8 -3
  112. package/styles/drop-down-base/_highcontrast-definition.scss +16 -6
  113. package/styles/drop-down-base/_highcontrast-light-definition.scss +18 -7
  114. package/styles/drop-down-base/_layout.scss +44 -3
  115. package/styles/drop-down-base/_material-dark-definition.scss +7 -1
  116. package/styles/drop-down-base/_material-definition.scss +6 -0
  117. package/styles/drop-down-base/_material3-definition.scss +8 -3
  118. package/styles/drop-down-base/_tailwind-definition.scss +8 -3
  119. package/styles/drop-down-base/_theme.scss +4 -4
  120. package/styles/drop-down-base/bootstrap-dark.css +42 -1
  121. package/styles/drop-down-base/bootstrap.css +42 -1
  122. package/styles/drop-down-base/bootstrap4.css +42 -1
  123. package/styles/drop-down-base/bootstrap5-dark.css +42 -1
  124. package/styles/drop-down-base/bootstrap5.css +42 -1
  125. package/styles/drop-down-base/fabric-dark.css +42 -1
  126. package/styles/drop-down-base/fabric.css +42 -1
  127. package/styles/drop-down-base/fluent-dark.css +42 -1
  128. package/styles/drop-down-base/fluent.css +42 -1
  129. package/styles/drop-down-base/highcontrast-light.css +42 -1
  130. package/styles/drop-down-base/highcontrast.css +42 -1
  131. package/styles/drop-down-base/material-dark.css +42 -1
  132. package/styles/drop-down-base/material.css +42 -1
  133. package/styles/drop-down-base/tailwind-dark.css +42 -1
  134. package/styles/drop-down-base/tailwind.css +42 -1
  135. package/styles/drop-down-list/_all.scss +2 -1
  136. package/styles/drop-down-list/_bootstrap-dark-definition.scss +2 -1
  137. package/styles/drop-down-list/_bootstrap-definition.scss +2 -1
  138. package/styles/drop-down-list/_bootstrap4-definition.scss +3 -1
  139. package/styles/drop-down-list/_bootstrap5-definition.scss +3 -3
  140. package/styles/drop-down-list/_fabric-dark-definition.scss +2 -1
  141. package/styles/drop-down-list/_fabric-definition.scss +2 -0
  142. package/styles/drop-down-list/_fluent-definition.scss +2 -1
  143. package/styles/drop-down-list/_fusionnew-definition.scss +3 -3
  144. package/styles/drop-down-list/_highcontrast-definition.scss +21 -10
  145. package/styles/drop-down-list/_highcontrast-light-definition.scss +22 -11
  146. package/styles/drop-down-list/_layout.scss +8 -9
  147. package/styles/drop-down-list/_material-dark-definition.scss +2 -2
  148. package/styles/drop-down-list/_material-definition.scss +1 -0
  149. package/styles/drop-down-list/_material3-definition.scss +3 -3
  150. package/styles/drop-down-list/_tailwind-definition.scss +1 -0
  151. package/styles/drop-down-list/_theme.scss +3 -3
  152. package/styles/drop-down-list/bootstrap-dark.css +5 -0
  153. package/styles/drop-down-list/bootstrap.css +5 -0
  154. package/styles/drop-down-list/bootstrap4.css +5 -0
  155. package/styles/drop-down-list/bootstrap5-dark.css +6 -0
  156. package/styles/drop-down-list/bootstrap5.css +6 -0
  157. package/styles/drop-down-list/fabric-dark.css +5 -0
  158. package/styles/drop-down-list/fabric.css +5 -0
  159. package/styles/drop-down-list/fluent-dark.css +6 -0
  160. package/styles/drop-down-list/fluent.css +6 -0
  161. package/styles/drop-down-list/highcontrast-light.css +5 -0
  162. package/styles/drop-down-list/highcontrast.css +5 -0
  163. package/styles/drop-down-list/icons/_bootstrap.scss +0 -1
  164. package/styles/drop-down-list/icons/_fabric.scss +0 -1
  165. package/styles/drop-down-list/icons/_material.scss +0 -1
  166. package/styles/drop-down-list/material-dark.css +5 -0
  167. package/styles/drop-down-list/material.css +5 -0
  168. package/styles/drop-down-list/tailwind-dark.css +6 -0
  169. package/styles/drop-down-list/tailwind.css +6 -0
  170. package/styles/drop-down-tree/_all.scss +1 -1
  171. package/styles/drop-down-tree/_bootstrap-dark-definition.scss +1 -1
  172. package/styles/drop-down-tree/_bootstrap-definition.scss +1 -1
  173. package/styles/drop-down-tree/_bootstrap4-definition.scss +1 -1
  174. package/styles/drop-down-tree/_bootstrap5-definition.scss +2 -2
  175. package/styles/drop-down-tree/_fabric-dark-definition.scss +1 -1
  176. package/styles/drop-down-tree/_fabric-definition.scss +2 -2
  177. package/styles/drop-down-tree/_fluent-definition.scss +2 -2
  178. package/styles/drop-down-tree/_fusionnew-definition.scss +2 -2
  179. package/styles/drop-down-tree/_highcontrast-definition.scss +1 -1
  180. package/styles/drop-down-tree/_highcontrast-light-definition.scss +1 -1
  181. package/styles/drop-down-tree/_layout.scss +1 -2
  182. package/styles/drop-down-tree/_material-dark-definition.scss +2 -2
  183. package/styles/drop-down-tree/_material-definition.scss +2 -2
  184. package/styles/drop-down-tree/_material3-definition.scss +2 -2
  185. package/styles/drop-down-tree/_tailwind-definition.scss +2 -2
  186. package/styles/drop-down-tree/bootstrap-dark.css +4 -0
  187. package/styles/drop-down-tree/bootstrap.css +4 -0
  188. package/styles/drop-down-tree/bootstrap4.css +4 -0
  189. package/styles/drop-down-tree/bootstrap5-dark.css +5 -0
  190. package/styles/drop-down-tree/bootstrap5.css +5 -0
  191. package/styles/drop-down-tree/fabric-dark.css +4 -0
  192. package/styles/drop-down-tree/fabric.css +4 -0
  193. package/styles/drop-down-tree/fluent-dark.css +5 -0
  194. package/styles/drop-down-tree/fluent.css +5 -0
  195. package/styles/drop-down-tree/highcontrast-light.css +4 -0
  196. package/styles/drop-down-tree/highcontrast.css +4 -0
  197. package/styles/drop-down-tree/icons/_bootstrap.scss +0 -1
  198. package/styles/drop-down-tree/icons/_bootstrap4.scss +0 -1
  199. package/styles/drop-down-tree/icons/_fabric.scss +0 -1
  200. package/styles/drop-down-tree/icons/_highcontrast-light.scss +0 -1
  201. package/styles/drop-down-tree/icons/_highcontrast.scss +0 -1
  202. package/styles/drop-down-tree/icons/_material-dark.scss +0 -1
  203. package/styles/drop-down-tree/icons/_material.scss +0 -1
  204. package/styles/drop-down-tree/material-dark.css +4 -0
  205. package/styles/drop-down-tree/material.css +4 -0
  206. package/styles/drop-down-tree/tailwind-dark.css +5 -0
  207. package/styles/drop-down-tree/tailwind.css +5 -0
  208. package/styles/fabric-dark.css +94 -42
  209. package/styles/fabric-dark.scss +1 -0
  210. package/styles/fabric.css +94 -42
  211. package/styles/fabric.scss +1 -0
  212. package/styles/fluent-dark.css +101 -44
  213. package/styles/fluent-dark.scss +1 -0
  214. package/styles/fluent.css +101 -44
  215. package/styles/fluent.scss +1 -0
  216. package/styles/highcontrast-light.css +97 -42
  217. package/styles/highcontrast-light.scss +1 -0
  218. package/styles/highcontrast.css +97 -42
  219. package/styles/highcontrast.scss +1 -0
  220. package/styles/list-box/_all.scss +1 -1
  221. package/styles/list-box/_bootstrap-dark-definition.scss +2 -0
  222. package/styles/list-box/_bootstrap-definition.scss +1 -0
  223. package/styles/list-box/_bootstrap4-definition.scss +1 -0
  224. package/styles/list-box/_bootstrap5-definition.scss +3 -0
  225. package/styles/list-box/_fabric-dark-definition.scss +3 -1
  226. package/styles/list-box/_fabric-definition.scss +1 -0
  227. package/styles/list-box/_fluent-definition.scss +3 -0
  228. package/styles/list-box/_fusionnew-definition.scss +1 -0
  229. package/styles/list-box/_highcontrast-definition.scss +1 -0
  230. package/styles/list-box/_highcontrast-light-definition.scss +3 -1
  231. package/styles/list-box/_layout.scss +8 -17
  232. package/styles/list-box/_material-dark-definition.scss +2 -0
  233. package/styles/list-box/_material-definition.scss +1 -0
  234. package/styles/list-box/_material3-definition.scss +1 -0
  235. package/styles/list-box/_tailwind-definition.scss +3 -0
  236. package/styles/list-box/_theme.scss +11 -25
  237. package/styles/list-box/bootstrap-dark.css +12 -33
  238. package/styles/list-box/bootstrap.css +14 -35
  239. package/styles/list-box/bootstrap4.css +14 -35
  240. package/styles/list-box/bootstrap5-dark.css +15 -36
  241. package/styles/list-box/bootstrap5.css +15 -36
  242. package/styles/list-box/fabric-dark.css +12 -33
  243. package/styles/list-box/fabric.css +14 -35
  244. package/styles/list-box/fluent-dark.css +15 -36
  245. package/styles/list-box/fluent.css +15 -36
  246. package/styles/list-box/highcontrast-light.css +12 -33
  247. package/styles/list-box/highcontrast.css +14 -35
  248. package/styles/list-box/icons/_bootstrap-dark.scss +2 -2
  249. package/styles/list-box/icons/_bootstrap.scss +1 -1
  250. package/styles/list-box/icons/_bootstrap4.scss +1 -1
  251. package/styles/list-box/icons/_bootstrap5.scss +1 -1
  252. package/styles/list-box/icons/_fabric-dark.scss +1 -1
  253. package/styles/list-box/icons/_fabric.scss +1 -1
  254. package/styles/list-box/icons/_fluent.scss +1 -1
  255. package/styles/list-box/icons/_fusionnew.scss +1 -1
  256. package/styles/list-box/icons/_highcontrast-light.scss +1 -1
  257. package/styles/list-box/icons/_highcontrast.scss +1 -1
  258. package/styles/list-box/icons/_material-dark.scss +1 -1
  259. package/styles/list-box/icons/_material.scss +2 -2
  260. package/styles/list-box/icons/_material3.scss +1 -1
  261. package/styles/list-box/icons/_tailwind-dark.scss +1 -1
  262. package/styles/list-box/icons/_tailwind.scss +1 -1
  263. package/styles/list-box/material-dark.css +12 -33
  264. package/styles/list-box/material.css +14 -35
  265. package/styles/list-box/tailwind-dark.css +15 -36
  266. package/styles/list-box/tailwind.css +15 -36
  267. package/styles/material-dark.css +94 -42
  268. package/styles/material-dark.scss +1 -0
  269. package/styles/material.css +94 -42
  270. package/styles/material.scss +1 -0
  271. package/styles/mention/_all.scss +1 -0
  272. package/styles/mention/_bootstrap-dark-definition.scss +3 -0
  273. package/styles/mention/_bootstrap-definition.scss +3 -0
  274. package/styles/mention/_bootstrap4-definition.scss +3 -0
  275. package/styles/mention/_bootstrap5-dark-definition.scss +1 -0
  276. package/styles/mention/_bootstrap5-definition.scss +1 -0
  277. package/styles/mention/_fabric-dark-definition.scss +2 -0
  278. package/styles/mention/_fabric-definition.scss +3 -0
  279. package/styles/mention/_fluent-dark-definition.scss +1 -0
  280. package/styles/mention/_fluent-definition.scss +1 -0
  281. package/styles/mention/_fusionnew-definition.scss +1 -0
  282. package/styles/mention/_highcontrast-definition.scss +3 -0
  283. package/styles/mention/_highcontrast-light-definition.scss +3 -0
  284. package/styles/mention/_layout.scss +6 -0
  285. package/styles/mention/_material-dark-definition.scss +3 -0
  286. package/styles/mention/_material-definition.scss +3 -0
  287. package/styles/mention/_material3-definition.scss +1 -0
  288. package/styles/mention/_tailwind-dark-definition.scss +1 -0
  289. package/styles/mention/_tailwind-definition.scss +1 -0
  290. package/styles/mention/bootstrap-dark.css +29 -0
  291. package/styles/mention/bootstrap-dark.scss +6 -0
  292. package/styles/mention/bootstrap.css +29 -0
  293. package/styles/mention/bootstrap.scss +6 -0
  294. package/styles/mention/bootstrap4.css +47 -0
  295. package/styles/mention/bootstrap4.scss +6 -0
  296. package/styles/mention/bootstrap5-dark.css +58 -0
  297. package/styles/mention/bootstrap5-dark.scss +6 -0
  298. package/styles/mention/bootstrap5.css +58 -0
  299. package/styles/mention/bootstrap5.scss +6 -0
  300. package/styles/mention/fabric-dark.css +29 -0
  301. package/styles/mention/fabric-dark.scss +6 -0
  302. package/styles/mention/fabric.css +29 -0
  303. package/styles/mention/fabric.scss +6 -0
  304. package/styles/mention/fluent-dark.css +58 -0
  305. package/styles/mention/fluent-dark.scss +6 -0
  306. package/styles/mention/fluent.css +58 -0
  307. package/styles/mention/fluent.scss +6 -0
  308. package/styles/mention/highcontrast-light.css +43 -0
  309. package/styles/mention/highcontrast-light.scss +6 -0
  310. package/styles/mention/highcontrast.css +43 -0
  311. package/styles/mention/highcontrast.scss +6 -0
  312. package/styles/mention/material-dark.css +29 -0
  313. package/styles/mention/material-dark.scss +6 -0
  314. package/styles/mention/material.css +29 -0
  315. package/styles/mention/material.scss +6 -0
  316. package/styles/mention/tailwind-dark.css +68 -0
  317. package/styles/mention/tailwind-dark.scss +6 -0
  318. package/styles/mention/tailwind.css +68 -0
  319. package/styles/mention/tailwind.scss +6 -0
  320. package/styles/multi-select/_all.scss +1 -1
  321. package/styles/multi-select/_bootstrap-dark-definition.scss +4 -1
  322. package/styles/multi-select/_bootstrap-definition.scss +2 -0
  323. package/styles/multi-select/_bootstrap4-definition.scss +5 -2
  324. package/styles/multi-select/_bootstrap5-definition.scss +2 -2
  325. package/styles/multi-select/_fabric-dark-definition.scss +5 -3
  326. package/styles/multi-select/_fabric-definition.scss +4 -2
  327. package/styles/multi-select/_fluent-definition.scss +2 -1
  328. package/styles/multi-select/_fusionnew-definition.scss +2 -2
  329. package/styles/multi-select/_highcontrast-definition.scss +47 -24
  330. package/styles/multi-select/_highcontrast-light-definition.scss +48 -25
  331. package/styles/multi-select/_layout.scss +59 -71
  332. package/styles/multi-select/_material-dark-definition.scss +3 -1
  333. package/styles/multi-select/_material-definition.scss +1 -0
  334. package/styles/multi-select/_material3-definition.scss +2 -2
  335. package/styles/multi-select/_tailwind-definition.scss +2 -3
  336. package/styles/multi-select/_theme.scss +16 -21
  337. package/styles/multi-select/bootstrap-dark.css +10 -6
  338. package/styles/multi-select/bootstrap.css +10 -6
  339. package/styles/multi-select/bootstrap4.css +10 -6
  340. package/styles/multi-select/bootstrap5-dark.css +11 -6
  341. package/styles/multi-select/bootstrap5.css +11 -6
  342. package/styles/multi-select/fabric-dark.css +10 -6
  343. package/styles/multi-select/fabric.css +10 -6
  344. package/styles/multi-select/fluent-dark.css +11 -6
  345. package/styles/multi-select/fluent.css +11 -6
  346. package/styles/multi-select/highcontrast-light.css +13 -6
  347. package/styles/multi-select/highcontrast.css +13 -6
  348. package/styles/multi-select/icons/_bootstrap5.scss +0 -1
  349. package/styles/multi-select/icons/_fluent.scss +0 -1
  350. package/styles/multi-select/icons/_fusionnew.scss +0 -1
  351. package/styles/multi-select/icons/_material-dark.scss +53 -54
  352. package/styles/multi-select/icons/_material.scss +53 -54
  353. package/styles/multi-select/icons/_material3.scss +0 -1
  354. package/styles/multi-select/icons/_tailwind.scss +0 -1
  355. package/styles/multi-select/material-dark.css +10 -6
  356. package/styles/multi-select/material.css +10 -6
  357. package/styles/multi-select/tailwind-dark.css +11 -6
  358. package/styles/multi-select/tailwind.css +11 -6
  359. package/styles/tailwind-dark.css +102 -44
  360. package/styles/tailwind-dark.scss +1 -0
  361. package/styles/tailwind.css +102 -44
  362. package/styles/tailwind.scss +1 -0
@@ -0,0 +1,1369 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ import { KeyboardEvents, compile, Property, EventHandler, Animation, formatUnit, append } from '@syncfusion/ej2-base';
21
+ import { isNullOrUndefined, detach, Event, Complex, addClass, removeClass, closest, isUndefined, getValue, NotifyPropertyChanges, Browser } from '@syncfusion/ej2-base';
22
+ import { FieldSettings } from '../drop-down-base/drop-down-base';
23
+ import { DropDownBase, dropDownBaseClasses } from '../drop-down-base/drop-down-base';
24
+ import { DataManager, Query } from '@syncfusion/ej2-data';
25
+ import { Popup, isCollide, createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
26
+ import { highlightSearch, revertHighlightSearch } from '../common/highlight-search';
27
+ /**
28
+ * The Mention component is used to list someone or something based on user input in textarea, input,
29
+ * or any other editable element from which the user can select.
30
+ */
31
+ var Mention = /** @class */ (function (_super) {
32
+ __extends(Mention, _super);
33
+ /**
34
+ * * Constructor for creating the widget
35
+ *
36
+ * @param {MentionModel} options - Specifies the MentionComponent model.
37
+ * @param {string | HTMLElement} element - Specifies the element to render as component.
38
+ * @private
39
+ */
40
+ function Mention(options, element) {
41
+ return _super.call(this, options, element) || this;
42
+ }
43
+ /**
44
+ * When property value changes happened, then onPropertyChanged method will execute the respective changes in this component.
45
+ *
46
+ * @param {MentionModel} newProp - Returns the dynamic property value of the component.
47
+ * @param {MentionModel} oldProp - Returns the previous property value of the component.
48
+ * @private
49
+ * @returns {void}
50
+ */
51
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
+ Mention.prototype.onPropertyChanged = function (newProp, oldProp) {
53
+ for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
54
+ var prop = _a[_i];
55
+ switch (prop) {
56
+ case 'minLength':
57
+ this.minLength = newProp.minLength;
58
+ break;
59
+ case 'suffixText':
60
+ this.suffixText = newProp.suffixText;
61
+ break;
62
+ case 'allowSpaces':
63
+ this.allowSpaces = newProp.allowSpaces;
64
+ break;
65
+ case 'mentionChar':
66
+ this.mentionChar = newProp.mentionChar;
67
+ break;
68
+ case 'showMentionChar':
69
+ this.showMentionChar = newProp.showMentionChar;
70
+ break;
71
+ case 'cssClass':
72
+ this.updateCssClass(newProp.cssClass, oldProp.cssClass);
73
+ break;
74
+ }
75
+ }
76
+ };
77
+ Mention.prototype.updateCssClass = function (newClass, oldClass) {
78
+ if (!isNullOrUndefined(oldClass)) {
79
+ oldClass = (oldClass.replace(/\s+/g, ' ')).trim();
80
+ }
81
+ if (!isNullOrUndefined(newClass)) {
82
+ newClass = (newClass.replace(/\s+/g, ' ')).trim();
83
+ }
84
+ this.setCssClass(newClass, [this.inputElement], oldClass);
85
+ if (this.popupObj) {
86
+ this.setCssClass(newClass, [this.popupObj.element], oldClass);
87
+ }
88
+ };
89
+ Mention.prototype.setCssClass = function (cssClass, elements, oldClass) {
90
+ if (!isNullOrUndefined(oldClass) && oldClass !== '') {
91
+ removeClass(elements, oldClass.split(' '));
92
+ }
93
+ if (!isNullOrUndefined(cssClass) && cssClass !== '') {
94
+ addClass(elements, cssClass.split(' '));
95
+ }
96
+ };
97
+ Mention.prototype.initializeData = function () {
98
+ this.isSelected = false;
99
+ this.isFiltered = false;
100
+ this.beforePopupOpen = false;
101
+ this.initRemoteRender = false;
102
+ this.isPopupOpen = false;
103
+ this.isCollided = false;
104
+ this.lineBreak = false;
105
+ this.keyConfigure = {
106
+ tab: 'tab',
107
+ enter: '13',
108
+ escape: '27',
109
+ end: '35',
110
+ home: '36',
111
+ down: '40',
112
+ up: '38',
113
+ pageUp: '33',
114
+ pageDown: '34',
115
+ open: 'alt+40',
116
+ close: 'shift+tab',
117
+ hide: 'alt+38',
118
+ space: '32'
119
+ };
120
+ };
121
+ /**
122
+ * Execute before render the list items
123
+ *
124
+ * @private
125
+ * @returns {void}
126
+ */
127
+ Mention.prototype.preRender = function () {
128
+ this.initializeData();
129
+ _super.prototype.preRender.call(this);
130
+ };
131
+ /**
132
+ * To Initialize the control rendering
133
+ *
134
+ * @private
135
+ * @returns {void}
136
+ */
137
+ Mention.prototype.render = function () {
138
+ this.inputElement = !isNullOrUndefined(this.target) ? ((typeof this.target) === 'string') ?
139
+ document.querySelector(this.target) : this.target : this.element;
140
+ if (this.isContentEditable(this.inputElement)) {
141
+ this.inputElement.setAttribute('contenteditable', 'true');
142
+ addClass([this.inputElement], ['e-mention']);
143
+ if (isNullOrUndefined(this.target)) {
144
+ addClass([this.inputElement], ['e-editable-element']);
145
+ }
146
+ }
147
+ this.queryString = this.elementValue();
148
+ this.wireEvent();
149
+ };
150
+ Mention.prototype.wireEvent = function () {
151
+ EventHandler.add(this.inputElement, 'keyup', this.onKeyUp, this);
152
+ this.bindCommonEvent();
153
+ };
154
+ Mention.prototype.unWireEvent = function () {
155
+ EventHandler.remove(this.inputElement, 'keyup', this.onKeyUp);
156
+ this.unBindCommonEvent();
157
+ };
158
+ Mention.prototype.bindCommonEvent = function () {
159
+ if (!Browser.isDevice) {
160
+ this.keyboardModule = new KeyboardEvents(this.inputElement, {
161
+ keyAction: this.keyActionHandler.bind(this), keyConfigs: this.keyConfigure, eventName: 'keydown'
162
+ });
163
+ }
164
+ };
165
+ /**
166
+ * Hides the spinner loader.
167
+ *
168
+ * @returns {void}
169
+ */
170
+ Mention.prototype.hideSpinner = function () {
171
+ this.hideWaitingSpinner();
172
+ };
173
+ Mention.prototype.hideWaitingSpinner = function () {
174
+ if (!isNullOrUndefined(this.spinnerElement)) {
175
+ hideSpinner(this.spinnerElement);
176
+ }
177
+ if (!isNullOrUndefined(this.spinnerTemplate)) {
178
+ detach(this.spinnerTemplateElement);
179
+ }
180
+ };
181
+ /**
182
+ * Shows the spinner loader.
183
+ *
184
+ * @returns {void}
185
+ */
186
+ Mention.prototype.showWaitingSpinner = function () {
187
+ if (!isNullOrUndefined(this.popupObj)) {
188
+ if (isNullOrUndefined(this.spinnerTemplate) && isNullOrUndefined(this.spinnerElement)) {
189
+ this.spinnerElement = this.popupObj.element;
190
+ createSpinner({
191
+ target: this.spinnerElement,
192
+ width: Browser.isDevice ? '16px' : '14px'
193
+ }, this.createElement);
194
+ showSpinner(this.spinnerElement);
195
+ }
196
+ if (!isNullOrUndefined(this.spinnerTemplate)) {
197
+ this.setSpinnerTemplate();
198
+ this.popupObj.element.appendChild(this.spinnerTemplateElement);
199
+ }
200
+ }
201
+ };
202
+ Mention.prototype.keyActionHandler = function (e) {
203
+ var isNavigation = (e.action === 'down' || e.action === 'up' || e.action === 'pageUp' || e.action === 'pageDown'
204
+ || e.action === 'home' || e.action === 'end');
205
+ var isTabAction = e.action === 'tab' || e.action === 'close';
206
+ if (this.list === undefined && !this.isRequested && !isTabAction && e.action !== 'escape') {
207
+ this.renderList();
208
+ }
209
+ if (isNullOrUndefined(this.list) || (!isNullOrUndefined(this.liCollections) &&
210
+ isNavigation && this.liCollections.length === 0) || this.isRequested) {
211
+ return;
212
+ }
213
+ if (e.action === 'escape') {
214
+ e.preventDefault();
215
+ }
216
+ this.isSelected = e.action === 'escape' ? false : this.isSelected;
217
+ switch (e.action) {
218
+ case 'down':
219
+ case 'up':
220
+ this.updateUpDownAction(e);
221
+ break;
222
+ case 'tab':
223
+ if (this.isPopupOpen) {
224
+ var li = this.list.querySelector('.' + dropDownBaseClasses.selected);
225
+ if (li) {
226
+ this.setSelection(li, e);
227
+ }
228
+ if (this.isPopupOpen) {
229
+ this.hidePopup(e);
230
+ }
231
+ }
232
+ break;
233
+ case 'enter':
234
+ if (this.isPopupOpen) {
235
+ e.preventDefault();
236
+ if (this.popupObj && this.popupObj.element.contains(this.selectedLI)) {
237
+ this.setValue(e);
238
+ }
239
+ }
240
+ break;
241
+ case 'escape':
242
+ if (this.isPopupOpen) {
243
+ this.hidePopup(e);
244
+ }
245
+ break;
246
+ }
247
+ };
248
+ Mention.prototype.updateUpDownAction = function (e) {
249
+ var focusEle = this.list.querySelector('.' + dropDownBaseClasses.focus);
250
+ if (this.isSelectFocusItem(focusEle)) {
251
+ this.setSelection(focusEle, e);
252
+ }
253
+ else if (!isNullOrUndefined(this.liCollections)) {
254
+ var li = this.list.querySelector('.' + dropDownBaseClasses.selected);
255
+ if (!isNullOrUndefined(li)) {
256
+ var value = this.getFormattedValue(li.getAttribute('data-value'));
257
+ this.activeIndex = this.getIndexByValue(value);
258
+ }
259
+ var index = e.action === 'down' ? this.activeIndex + 1 : this.activeIndex - 1;
260
+ var startIndex = 0;
261
+ startIndex = e.action === 'down' && isNullOrUndefined(this.activeIndex) ? 0 : this.liCollections.length - 1;
262
+ index = index < 0 ? this.liCollections.length - 1 : index === this.liCollections.length ? 0 : index;
263
+ var nextItem = isNullOrUndefined(this.activeIndex) ? this.liCollections[startIndex] : this.liCollections[index];
264
+ if (!isNullOrUndefined(nextItem)) {
265
+ this.setSelection(nextItem, e);
266
+ }
267
+ }
268
+ if (this.isPopupOpen) {
269
+ e.preventDefault();
270
+ }
271
+ };
272
+ Mention.prototype.isSelectFocusItem = function (element) {
273
+ return !isNullOrUndefined(element);
274
+ };
275
+ Mention.prototype.unBindCommonEvent = function () {
276
+ if (!Browser.isDevice) {
277
+ this.keyboardModule.destroy();
278
+ }
279
+ };
280
+ Mention.prototype.onKeyUp = function (e) {
281
+ var rangetextContent;
282
+ if (this.isContentEditable(this.inputElement)) {
283
+ this.range = this.getCurrentRange();
284
+ rangetextContent = this.range.startContainer.textContent.split('');
285
+ }
286
+ var currentRange = this.getTextRange();
287
+ var lastWordRange = this.getLastLetter(currentRange);
288
+ var Regex = new RegExp(this.mentionChar, 'g');
289
+ var charRegex = new RegExp('[a-zA-Z]', 'g');
290
+ if (e.key === 'Shift' || e.keyCode === 37 || e.keyCode === 39) {
291
+ return;
292
+ }
293
+ if ((!currentRange || !lastWordRange) || e.code === 'Enter' || e.keyCode === 27 ||
294
+ (lastWordRange.match(Regex) && lastWordRange.match(Regex).length > 1) ||
295
+ (this.isContentEditable(this.inputElement) && this.range.startContainer &&
296
+ this.range.startContainer.previousElementSibling && this.range.startContainer.textContent.split('').length > 0 &&
297
+ (rangetextContent.length === 1 || rangetextContent[rangetextContent.length - 2].indexOf('') === -1 ||
298
+ this.range.startContainer.nodeType === 1))) {
299
+ if (this.allowSpaces && currentRange && currentRange.trim() !== '' && charRegex.test(currentRange) && currentRange.indexOf(this.mentionChar) !== -1
300
+ && !this.isMatchedText() && (currentRange.length > 1 && currentRange.replace(/\u00A0/g, ' ').charAt(currentRange.length - 2) !== ' ') &&
301
+ (this.list && this.list.querySelectorAll('ul').length > 0)) {
302
+ this.queryString = currentRange.substring(currentRange.lastIndexOf(this.mentionChar) + 1).replace('\u00a0', ' ');
303
+ this.searchLists(e);
304
+ }
305
+ else if (this.isPopupOpen && (!this.allowSpaces || !lastWordRange)) {
306
+ this.hidePopup();
307
+ this.lineBreak = true;
308
+ }
309
+ return;
310
+ }
311
+ this.queryString = lastWordRange.replace(this.mentionChar, '');
312
+ if (this.mentionChar.charCodeAt(0) === lastWordRange.charCodeAt(0) &&
313
+ this.queryString !== '' && e.keyCode !== 38 && e.keyCode !== 40 && !this.lineBreak) {
314
+ this.searchLists(e);
315
+ if (!this.isPopupOpen && this.queryString.length >= this.minLength) {
316
+ if (!this.isContentEditable(this.inputElement)) {
317
+ this.showPopup();
318
+ }
319
+ else if (this.isContentEditable(this.inputElement) && this.range && this.range.startContainer !== this.inputElement) {
320
+ this.showPopup();
321
+ }
322
+ }
323
+ }
324
+ else if (lastWordRange.indexOf(this.mentionChar) === 0 && !this.isPopupOpen && e.keyCode !== 8 && (!this.popupObj ||
325
+ (isNullOrUndefined(this.target) && !document.body.contains(this.popupObj.element) ||
326
+ !isNullOrUndefined(this.target) && document.body.contains(this.popupObj.element)))) {
327
+ if (this.initRemoteRender && this.list && this.list.classList.contains('e-nodata')) {
328
+ this.searchLists(e);
329
+ }
330
+ this.resetList(this.dataSource, this.fields);
331
+ if (isNullOrUndefined(this.list)) {
332
+ this.initValue();
333
+ }
334
+ if (!this.isPopupOpen && e.keyCode !== 38 && e.keyCode !== 40) {
335
+ this.showPopup();
336
+ if (this.initRemoteRender && this.list.querySelectorAll('li').length === 0) {
337
+ this.showWaitingSpinner();
338
+ }
339
+ this.lineBreak = false;
340
+ }
341
+ }
342
+ else if (this.allowSpaces && this.queryString !== '' && currentRange && currentRange.trim() !== '' && currentRange.replace('\u00a0', ' ').lastIndexOf(' ') < currentRange.length - 1 &&
343
+ e.keyCode !== 38 && e.keyCode !== 40 && e.keyCode !== 8) {
344
+ this.queryString = currentRange.substring(currentRange.lastIndexOf(this.mentionChar) + 1).replace('\u00a0', ' ');
345
+ this.searchLists(e);
346
+ }
347
+ else if (this.queryString === '' && this.isPopupOpen && e.keyCode !== 38 && e.keyCode !== 40) {
348
+ this.resetList(this.dataSource, this.fields);
349
+ }
350
+ };
351
+ Mention.prototype.isMatchedText = function () {
352
+ var isMatched = false;
353
+ for (var i = 0; i < (this.liCollections && this.liCollections.length); i++) {
354
+ if (this.getTextRange() &&
355
+ this.getTextRange().substring(this.getTextRange().lastIndexOf(this.mentionChar) + 1).replace('\u00a0', ' ').trim() === this.liCollections[i].getAttribute('data-value').toLowerCase()) {
356
+ isMatched = true;
357
+ }
358
+ }
359
+ return isMatched;
360
+ };
361
+ Mention.prototype.getCurrentRange = function () {
362
+ this.range = this.inputElement.ownerDocument.getSelection().getRangeAt(0);
363
+ return this.range;
364
+ };
365
+ Mention.prototype.searchLists = function (e) {
366
+ var _this = this;
367
+ this.isDataFetched = false;
368
+ if (isNullOrUndefined(this.list)) {
369
+ _super.prototype.render.call(this);
370
+ this.unWireListEvents();
371
+ this.wireListEvents();
372
+ }
373
+ if (e.type !== 'mousedown' && (e.keyCode === 40 || e.keyCode === 38)) {
374
+ this.queryString = this.queryString === '' ? null : this.queryString;
375
+ this.beforePopupOpen = true;
376
+ this.resetList(this.dataSource, this.fields);
377
+ return;
378
+ }
379
+ this.isSelected = false;
380
+ this.activeIndex = null;
381
+ var eventArgs = {
382
+ preventDefaultAction: false,
383
+ text: this.elementValue(),
384
+ updateData: function (dataSource, query, fields) {
385
+ if (eventArgs.cancel) {
386
+ return;
387
+ }
388
+ _this.isFiltered = true;
389
+ _this.filterAction(dataSource, query, fields);
390
+ },
391
+ cancel: false
392
+ };
393
+ this.trigger('filtering', eventArgs, function (eventArgs) {
394
+ if (!eventArgs.cancel && !_this.isFiltered && !eventArgs.preventDefaultAction) {
395
+ _this.filterAction(_this.dataSource, null, _this.fields);
396
+ }
397
+ });
398
+ };
399
+ Mention.prototype.filterAction = function (dataSource, query, fields) {
400
+ this.beforePopupOpen = true;
401
+ if (this.queryString !== '' && (this.queryString.length >= this.minLength)) {
402
+ this.resetList(dataSource, fields, query);
403
+ }
404
+ else {
405
+ if (this.isPopupOpen) {
406
+ this.hidePopup();
407
+ }
408
+ this.beforePopupOpen = false;
409
+ }
410
+ this.setDataIndex();
411
+ this.renderReactTemplates();
412
+ };
413
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
414
+ Mention.prototype.onActionComplete = function (ulElement, list, e, isUpdated) {
415
+ _super.prototype.onActionComplete.call(this, ulElement, list, e);
416
+ if (this.isActive) {
417
+ var focusItem = ulElement.querySelector('.' + dropDownBaseClasses.li);
418
+ if (focusItem) {
419
+ focusItem.classList.add(dropDownBaseClasses.selected);
420
+ this.selectedLI = focusItem;
421
+ var value = this.getFormattedValue(focusItem.getAttribute('data-value'));
422
+ this.selectEventCallback(focusItem, this.getDataByValue(value), value, true);
423
+ }
424
+ }
425
+ };
426
+ Mention.prototype.setDataIndex = function () {
427
+ for (var i = 0; this.liCollections && i < this.liCollections.length; i++) {
428
+ this.liCollections[i].setAttribute('data-index', i.toString());
429
+ }
430
+ };
431
+ Mention.prototype.listOption = function (dataSource, fieldsSettings) {
432
+ var _this = this;
433
+ var fields = _super.prototype.listOption.call(this, dataSource, fieldsSettings);
434
+ if (isNullOrUndefined(fields.itemCreated)) {
435
+ fields.itemCreated = function (e) {
436
+ if (_this.highlight) {
437
+ if (_this.inputElement.tagName === _this.getNgDirective() && _this.itemTemplate) {
438
+ setTimeout(function () {
439
+ highlightSearch(e.item, _this.queryString, _this.ignoreCase, _this.filterType);
440
+ }, 0);
441
+ }
442
+ else {
443
+ highlightSearch(e.item, _this.queryString, _this.ignoreCase, _this.filterType);
444
+ }
445
+ }
446
+ };
447
+ }
448
+ else {
449
+ var itemCreated_1 = fields.itemCreated;
450
+ fields.itemCreated = function (e) {
451
+ if (_this.highlight) {
452
+ highlightSearch(e.item, _this.queryString, _this.ignoreCase, _this.filterType);
453
+ }
454
+ itemCreated_1.apply(_this, [e]);
455
+ };
456
+ }
457
+ return fields;
458
+ };
459
+ Mention.prototype.elementValue = function () {
460
+ if (!this.isContentEditable(this.inputElement)) {
461
+ return this.inputElement.value.replace(this.mentionChar, '');
462
+ }
463
+ else {
464
+ return this.inputElement.textContent.replace(this.mentionChar, '');
465
+ }
466
+ };
467
+ Mention.prototype.getQuery = function (query) {
468
+ var filterQuery = query ? query.clone() : this.query ? this.query.clone() : new Query();
469
+ var filterType = (this.queryString === '' && !isNullOrUndefined(this.elementValue())) ? 'equal' : this.filterType;
470
+ var queryString = (this.queryString === '' && !isNullOrUndefined(this.elementValue())) ?
471
+ this.elementValue() : this.queryString;
472
+ if (this.isFiltered) {
473
+ return filterQuery;
474
+ }
475
+ if (this.queryString !== null && this.queryString !== '') {
476
+ var dataType = this.typeOfData(this.dataSource).typeof;
477
+ if (!(this.dataSource instanceof DataManager) && dataType === 'string' || dataType === 'number') {
478
+ filterQuery.where('', filterType, queryString, this.ignoreCase, this.ignoreAccent);
479
+ }
480
+ else {
481
+ var mapping = !isNullOrUndefined(this.fields.text) ? this.fields.text : '';
482
+ filterQuery.where(mapping, filterType, queryString, this.ignoreCase, this.ignoreAccent);
483
+ }
484
+ }
485
+ if (!isNullOrUndefined(this.suggestionCount)) {
486
+ // Since defualt value of suggestioncount is 25, checked the condition
487
+ if (this.suggestionCount !== 25) {
488
+ for (var queryElements = 0; queryElements < filterQuery.queries.length; queryElements++) {
489
+ if (filterQuery.queries[queryElements].fn === 'onTake') {
490
+ filterQuery.queries.splice(queryElements, 1);
491
+ }
492
+ }
493
+ }
494
+ filterQuery.take(this.suggestionCount);
495
+ }
496
+ return filterQuery;
497
+ };
498
+ Mention.prototype.renderHightSearch = function () {
499
+ if (this.highlight) {
500
+ for (var i = 0; i < this.liCollections.length; i++) {
501
+ var isHighlight = this.ulElement.querySelector('.e-active');
502
+ if (!isHighlight) {
503
+ revertHighlightSearch(this.liCollections[i]);
504
+ highlightSearch(this.liCollections[i], this.queryString, this.ignoreCase, this.filterType);
505
+ }
506
+ }
507
+ }
508
+ };
509
+ Mention.prototype.getTextRange = function () {
510
+ var text;
511
+ if (!this.isContentEditable(this.inputElement)) {
512
+ var component = this.inputElement;
513
+ if (!isNullOrUndefined(component)) {
514
+ var startPos = component.selectionStart;
515
+ if (component.value && startPos >= 0) {
516
+ text = component.value.substring(0, startPos);
517
+ }
518
+ }
519
+ }
520
+ else {
521
+ var selectedElem = this.range.startContainer;
522
+ if (!isNullOrUndefined(selectedElem)) {
523
+ var workingNodeContent = selectedElem.textContent;
524
+ var selectStartOffset = this.range.startOffset;
525
+ if (workingNodeContent && selectStartOffset >= 0) {
526
+ text = workingNodeContent.substring(0, selectStartOffset);
527
+ }
528
+ }
529
+ }
530
+ return text;
531
+ };
532
+ Mention.prototype.getLastLetter = function (text) {
533
+ if (isNullOrUndefined(text)) {
534
+ return '';
535
+ }
536
+ var textValue = text.replace(/\u00A0/g, ' ');
537
+ var words = textValue.split(/\s+/);
538
+ var wordCnt = words.length - 1;
539
+ return words[wordCnt].trim();
540
+ };
541
+ Mention.prototype.isContentEditable = function (element) {
542
+ return element && element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA';
543
+ };
544
+ /**
545
+ * Opens the popup that displays the list of items.
546
+ *
547
+ * @returns {void}
548
+ */
549
+ Mention.prototype.showPopup = function () {
550
+ this.renderPopup();
551
+ };
552
+ /* eslint-disable valid-jsdoc, jsdoc/require-param */
553
+ /**
554
+ * Hides the popup if it is in an open state.
555
+ *
556
+ * @returns {void}
557
+ */
558
+ Mention.prototype.hidePopup = function (e) {
559
+ this.removeSelection();
560
+ this.closePopup(0, e);
561
+ };
562
+ Mention.prototype.closePopup = function (delay, e) {
563
+ var _this = this;
564
+ if (!(this.popupObj && document.body.contains(this.popupObj.element) && this.beforePopupOpen)) {
565
+ return;
566
+ }
567
+ EventHandler.remove(document, 'mousedown', this.onDocumentClick);
568
+ this.beforePopupOpen = false;
569
+ var animModel = {
570
+ name: 'FadeOut',
571
+ duration: 100,
572
+ delay: delay ? delay : 0
573
+ };
574
+ var popupInstance = this.popupObj;
575
+ var eventArgs = { popup: popupInstance, cancel: false, animation: animModel, event: e || null };
576
+ this.trigger('closed', eventArgs, function (eventArgs) {
577
+ if (!eventArgs.cancel && _this.popupObj) {
578
+ if (_this.isPopupOpen) {
579
+ _this.popupObj.hide(new Animation(eventArgs.animation));
580
+ }
581
+ else {
582
+ _this.destroyPopup();
583
+ }
584
+ }
585
+ });
586
+ };
587
+ Mention.prototype.renderPopup = function () {
588
+ var _this = this;
589
+ var args = { cancel: false };
590
+ this.trigger('beforeOpen', args, function (args) {
591
+ if (!args.cancel) {
592
+ var popupEle_1 = isNullOrUndefined(_this.target) ? _this.createElement('div', {
593
+ id: _this.inputElement.id + '_popup', className: 'e-mention e-popup ' + (_this.cssClass != null ? _this.cssClass : '')
594
+ }) : _this.element;
595
+ if (!isNullOrUndefined(_this.target)) {
596
+ popupEle_1.id = _this.inputElement.id + '_popup';
597
+ addClass([popupEle_1], ['e-mention', 'e-popup', 'e-popup-close']);
598
+ }
599
+ _this.listHeight = formatUnit(_this.popupHeight);
600
+ if (!isNullOrUndefined(_this.list.querySelector('li')) && !_this.initRemoteRender) {
601
+ var li = _this.list.querySelector('.' + dropDownBaseClasses.focus);
602
+ if (!isNullOrUndefined(li)) {
603
+ _this.selectedLI = li;
604
+ var value = _this.getFormattedValue(li.getAttribute('data-value'));
605
+ _this.selectEventCallback(li, _this.getDataByValue(value), value, true);
606
+ }
607
+ }
608
+ append([_this.list], popupEle_1);
609
+ if ((!_this.popupObj || !document.body.contains(_this.popupObj.element)) || !document.contains(popupEle_1) && isNullOrUndefined(_this.target)) {
610
+ document.body.appendChild(popupEle_1);
611
+ }
612
+ var coordinates_1;
613
+ popupEle_1.style.visibility = 'hidden';
614
+ if (_this.popupHeight !== 'auto') {
615
+ _this.list.style.maxHeight = (parseInt(_this.listHeight, 10) - 2).toString() + 'px'; // due to box-sizing property
616
+ popupEle_1.style.maxHeight = formatUnit(_this.popupHeight);
617
+ }
618
+ else {
619
+ popupEle_1.style.height = 'auto';
620
+ }
621
+ var offsetValue = 0;
622
+ var left = 0;
623
+ _this.initializePopup(popupEle_1, offsetValue, left);
624
+ _this.checkCollision(popupEle_1);
625
+ popupEle_1.style.visibility = 'visible';
626
+ if (!isNullOrUndefined(_this.list)) {
627
+ _this.unWireListEvents();
628
+ _this.wireListEvents();
629
+ }
630
+ var animModel = { name: 'FadeIn', duration: 100 };
631
+ _this.beforePopupOpen = true;
632
+ var popupInstance = _this.popupObj;
633
+ var eventArgs = { popup: popupInstance, cancel: false, animation: animModel };
634
+ _this.trigger('opened', eventArgs, function (eventArgs) {
635
+ if (!eventArgs.cancel) {
636
+ _this.renderReactTemplates();
637
+ _this.popupObj.show(new Animation(eventArgs.animation), (_this.zIndex === 1000) ? _this.inputElement : null);
638
+ coordinates_1 = _this.getCoordinates(_this.inputElement, _this.getTriggerCharPosition());
639
+ if (!_this.isCollided) {
640
+ popupEle_1.style.cssText = 'top: '.concat(coordinates_1.top.toString(), 'px;\n left: ').concat(coordinates_1.left.toString(), 'px;\nposition: absolute;\n display: block;');
641
+ }
642
+ else {
643
+ popupEle_1.style.left = formatUnit(coordinates_1.left);
644
+ _this.isCollided = false;
645
+ }
646
+ popupEle_1.style.width = _this.popupWidth !== '100%' && !isNullOrUndefined(_this.popupWidth) ? formatUnit(_this.popupWidth) : 'auto';
647
+ }
648
+ else {
649
+ _this.beforePopupOpen = false;
650
+ _this.destroyPopup();
651
+ }
652
+ });
653
+ }
654
+ else {
655
+ _this.beforePopupOpen = false;
656
+ }
657
+ });
658
+ };
659
+ Mention.prototype.checkCollision = function (popupEle) {
660
+ if (!Browser.isDevice || (Browser.isDevice && !(this.getModuleName() === 'mention'))) {
661
+ var collision = isCollide(popupEle);
662
+ if (collision.length > 0) {
663
+ popupEle.style.marginTop = -parseInt(getComputedStyle(popupEle).marginTop, 10) + 'px';
664
+ this.isCollided = true;
665
+ }
666
+ this.popupObj.resolveCollision();
667
+ }
668
+ };
669
+ Mention.prototype.getTriggerCharPosition = function () {
670
+ var mostRecentTriggerCharPos;
671
+ var currentRange = this.getTextRange();
672
+ if (currentRange !== undefined && currentRange !== null) {
673
+ mostRecentTriggerCharPos = 0;
674
+ var idx = currentRange.lastIndexOf(this.mentionChar);
675
+ if (idx >= mostRecentTriggerCharPos) {
676
+ mostRecentTriggerCharPos = idx;
677
+ }
678
+ }
679
+ return mostRecentTriggerCharPos;
680
+ };
681
+ Mention.prototype.initializePopup = function (element, offsetValue, left) {
682
+ var _this = this;
683
+ this.popupObj = new Popup(element, {
684
+ width: this.setWidth(), targetType: 'relative',
685
+ relateTo: this.inputElement, collision: { X: 'flip', Y: 'flip' }, offsetY: offsetValue,
686
+ enableRtl: this.enableRtl, offsetX: left, position: { X: 'top', Y: 'left' }, actionOnScroll: 'hide',
687
+ zIndex: this.zIndex,
688
+ close: function () {
689
+ _this.destroyPopup();
690
+ },
691
+ open: function () {
692
+ EventHandler.add(document, 'mousedown', _this.onDocumentClick, _this);
693
+ _this.isPopupOpen = true;
694
+ _this.setDataIndex();
695
+ }
696
+ });
697
+ };
698
+ Mention.prototype.setWidth = function () {
699
+ var width = formatUnit(this.popupWidth);
700
+ if (width.indexOf('%') > -1) {
701
+ var inputWidth = this.inputElement.offsetWidth * parseFloat(width) / 100;
702
+ width = inputWidth.toString() + 'px';
703
+ }
704
+ return width;
705
+ };
706
+ Mention.prototype.destroyPopup = function () {
707
+ this.isPopupOpen = false;
708
+ this.popupObj.destroy();
709
+ if (isNullOrUndefined(this.target)) {
710
+ detach(this.popupObj.element);
711
+ }
712
+ else {
713
+ this.popupObj.element.innerHTML = '';
714
+ this.popupObj.element.removeAttribute('style');
715
+ this.popupObj.element.removeAttribute('aria-disabled');
716
+ }
717
+ };
718
+ Mention.prototype.onDocumentClick = function (e) {
719
+ var target = e.target;
720
+ if (!(!isNullOrUndefined(this.popupObj) && closest(target, '#' + this.popupObj.element.id))) {
721
+ this.hidePopup(e);
722
+ }
723
+ };
724
+ Mention.prototype.getCoordinates = function (element, position) {
725
+ var properties = ['direction', 'boxSizing', 'width', 'height', 'overflowX', 'overflowY', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', 'letterSpacing', 'wordSpacing'];
726
+ var div;
727
+ var span;
728
+ var range;
729
+ var globalRange;
730
+ var coordinates;
731
+ var computed;
732
+ var rect;
733
+ if (!this.isContentEditable(this.inputElement)) {
734
+ div = this.createElement('div', { className: 'e-form-mirror-div' });
735
+ document.body.appendChild(div);
736
+ computed = getComputedStyle(element);
737
+ div.style.position = 'absolute';
738
+ div.style.visibility = 'hidden';
739
+ properties.forEach(function (prop) {
740
+ div.style[prop] = computed[prop];
741
+ });
742
+ div.textContent = element.value.substring(0, position);
743
+ if (this.inputElement.nodeName === 'INPUT') {
744
+ div.textContent = div.textContent.replace(/\s/g, '\u00a0');
745
+ }
746
+ span = this.createElement('span');
747
+ span.textContent = element.value.substring(position) || '.';
748
+ div.appendChild(span);
749
+ rect = element.getBoundingClientRect();
750
+ }
751
+ else {
752
+ var selectedNodePosition = this.getTriggerCharPosition();
753
+ globalRange = this.range;
754
+ range = document.createRange();
755
+ range.setStart(globalRange.startContainer, selectedNodePosition);
756
+ range.setEnd(globalRange.startContainer, selectedNodePosition);
757
+ range.collapse(false);
758
+ rect = range.getBoundingClientRect();
759
+ }
760
+ var doc = document.documentElement;
761
+ var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
762
+ var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
763
+ if (!this.isContentEditable(this.inputElement)) {
764
+ coordinates = {
765
+ top: rect.top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth, 10) +
766
+ parseInt(computed.fontSize, 10) + 3 - element.scrollTop,
767
+ left: rect.left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth, 10)
768
+ };
769
+ document.body.removeChild(div);
770
+ }
771
+ else {
772
+ coordinates = {
773
+ top: rect.top + windowTop + parseInt(getComputedStyle(this.inputElement).fontSize),
774
+ left: rect.left + windowLeft
775
+ };
776
+ }
777
+ return coordinates;
778
+ };
779
+ ;
780
+ Mention.prototype.initValue = function () {
781
+ this.renderList();
782
+ if (this.dataSource instanceof DataManager) {
783
+ this.initRemoteRender = true;
784
+ }
785
+ else {
786
+ this.updateValues();
787
+ }
788
+ };
789
+ Mention.prototype.updateValues = function () {
790
+ var li = this.list.querySelector('.' + dropDownBaseClasses.focus);
791
+ if (!isNullOrUndefined(li)) {
792
+ this.setSelection(li, null);
793
+ }
794
+ };
795
+ Mention.prototype.renderList = function () {
796
+ _super.prototype.render.call(this);
797
+ this.unWireListEvents();
798
+ this.wireListEvents();
799
+ };
800
+ /**
801
+ * Event binding for list
802
+ *
803
+ * @returns {void}
804
+ */
805
+ Mention.prototype.wireListEvents = function () {
806
+ EventHandler.add(this.list, 'click', this.onMouseClick, this);
807
+ EventHandler.add(this.list, 'mouseover', this.onMouseOver, this);
808
+ EventHandler.add(this.list, 'mouseout', this.onMouseLeave, this);
809
+ };
810
+ /**
811
+ * Event un binding for list items.
812
+ *
813
+ * @returns {void}
814
+ */
815
+ Mention.prototype.unWireListEvents = function () {
816
+ EventHandler.remove(this.list, 'click', this.onMouseClick);
817
+ EventHandler.remove(this.list, 'mouseover', this.onMouseOver);
818
+ EventHandler.remove(this.list, 'mouseout', this.onMouseLeave);
819
+ };
820
+ Mention.prototype.onMouseClick = function (e) {
821
+ var target = e.target;
822
+ var li = closest(target, '.' + dropDownBaseClasses.li);
823
+ if (!this.isValidLI(li)) {
824
+ return;
825
+ }
826
+ this.setSelection(li, e);
827
+ var delay = 100;
828
+ this.closePopup(delay, e);
829
+ this.inputElement.focus();
830
+ };
831
+ Mention.prototype.updateSelectedItem = function (li, e, preventSelect, isSelection) {
832
+ var _this = this;
833
+ this.removeSelection();
834
+ li.classList.add(dropDownBaseClasses.selected);
835
+ this.removeHover();
836
+ var value = this.getFormattedValue(li.getAttribute('data-value'));
837
+ var selectedData = this.getDataByValue(value);
838
+ if (!preventSelect && !isNullOrUndefined(e)) {
839
+ var items = this.detachChanges(selectedData);
840
+ this.isSelected = true;
841
+ var eventArgs = {
842
+ e: e,
843
+ item: li,
844
+ itemData: items,
845
+ isInteracted: e ? true : false,
846
+ cancel: false
847
+ };
848
+ this.trigger('select', eventArgs, function (eventArgs) {
849
+ if (eventArgs.cancel) {
850
+ li.classList.remove(dropDownBaseClasses.selected);
851
+ }
852
+ else {
853
+ _this.selectEventCallback(li, selectedData, value);
854
+ if (isSelection) {
855
+ _this.setSelectOptions(li, e);
856
+ }
857
+ }
858
+ });
859
+ }
860
+ else {
861
+ this.selectEventCallback(li, selectedData, value);
862
+ if (isSelection) {
863
+ this.setSelectOptions(li, e);
864
+ }
865
+ }
866
+ };
867
+ Mention.prototype.setSelection = function (li, e) {
868
+ if (this.isValidLI(li) && (!li.classList.contains(dropDownBaseClasses.selected) || (this.isPopupOpen && this.isSelected
869
+ && li.classList.contains(dropDownBaseClasses.selected)))) {
870
+ this.updateSelectedItem(li, e, false, true);
871
+ }
872
+ else {
873
+ this.setSelectOptions(li, e);
874
+ }
875
+ };
876
+ Mention.prototype.setSelectOptions = function (li, e) {
877
+ if (this.list) {
878
+ this.removeHover();
879
+ }
880
+ this.previousSelectedLI = (!isNullOrUndefined(this.selectedLI)) ? this.selectedLI : null;
881
+ this.selectedLI = li;
882
+ if (this.isPopupOpen && !isNullOrUndefined(this.selectedLI)) {
883
+ this.setScrollPosition(e);
884
+ }
885
+ if (e && (e.keyCode === 38 || e.keyCode === 40)) {
886
+ return;
887
+ }
888
+ if (isNullOrUndefined(e) || this.setValue(e)) {
889
+ return;
890
+ }
891
+ };
892
+ Mention.prototype.setScrollPosition = function (e) {
893
+ if (!isNullOrUndefined(e)) {
894
+ switch (e.action) {
895
+ case 'pageDown':
896
+ case 'down':
897
+ case 'end':
898
+ this.scrollBottom();
899
+ break;
900
+ default:
901
+ this.scrollTop();
902
+ break;
903
+ }
904
+ }
905
+ else {
906
+ this.scrollBottom(true);
907
+ }
908
+ };
909
+ Mention.prototype.scrollBottom = function (isInitial) {
910
+ if (!isNullOrUndefined(this.selectedLI)) {
911
+ var currentOffset = this.list.offsetHeight;
912
+ var nextBottom = this.selectedLI.offsetTop + this.selectedLI.offsetHeight - this.list.scrollTop;
913
+ var nextOffset = this.list.scrollTop + nextBottom - currentOffset;
914
+ nextOffset = isInitial ? nextOffset + parseInt(getComputedStyle(this.list).paddingTop, 10) * 2 : nextOffset;
915
+ var boxRange = this.selectedLI.offsetTop + this.selectedLI.offsetHeight - this.list.scrollTop;
916
+ if (this.activeIndex === 0) {
917
+ this.list.scrollTop = 0;
918
+ }
919
+ else if (nextBottom > currentOffset || !(boxRange > 0 && this.list.offsetHeight > boxRange)) {
920
+ this.list.scrollTop = nextOffset;
921
+ }
922
+ }
923
+ };
924
+ Mention.prototype.scrollTop = function () {
925
+ if (!isNullOrUndefined(this.selectedLI)) {
926
+ var nextOffset = this.selectedLI.offsetTop - this.list.scrollTop;
927
+ nextOffset = this.fields.groupBy && nextOffset;
928
+ var boxRange = (this.selectedLI.offsetTop + this.selectedLI.offsetHeight - this.list.scrollTop);
929
+ if (this.activeIndex === 0) {
930
+ this.list.scrollTop = 0;
931
+ }
932
+ else if (nextOffset < 0) {
933
+ this.list.scrollTop = this.list.scrollTop + nextOffset;
934
+ }
935
+ else if (!(boxRange > 0 && this.list.offsetHeight > boxRange)) {
936
+ this.list.scrollTop = this.selectedLI.offsetTop;
937
+ }
938
+ }
939
+ };
940
+ Mention.prototype.selectEventCallback = function (li, selectedData, value, selectLi) {
941
+ this.previousItemData = (!isNullOrUndefined(this.itemData)) ? this.itemData : null;
942
+ this.item = li;
943
+ this.itemData = selectedData;
944
+ var focusedItem = this.list.querySelector('.' + dropDownBaseClasses.focus);
945
+ if (focusedItem) {
946
+ removeClass([focusedItem], dropDownBaseClasses.focus);
947
+ }
948
+ if (selectLi) {
949
+ addClass([li], dropDownBaseClasses.selected);
950
+ }
951
+ li.setAttribute('aria-selected', 'true');
952
+ this.activeIndex = this.getIndexByValue(value);
953
+ };
954
+ Mention.prototype.detachChanges = function (value) {
955
+ var items;
956
+ if (typeof value === 'string' ||
957
+ typeof value === 'boolean' ||
958
+ typeof value === 'number') {
959
+ items = Object.defineProperties({}, {
960
+ value: {
961
+ value: value,
962
+ enumerable: true
963
+ },
964
+ text: {
965
+ value: value,
966
+ enumerable: true
967
+ }
968
+ });
969
+ }
970
+ else {
971
+ items = value;
972
+ }
973
+ return items;
974
+ };
975
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
976
+ Mention.prototype.setValue = function (e) {
977
+ var dataItem = this.getItemData();
978
+ var textSuffix;
979
+ var value;
980
+ var endPos;
981
+ var range;
982
+ var globalRange;
983
+ var selection = this.inputElement.ownerDocument.getSelection();
984
+ var startPos = this.getTriggerCharPosition();
985
+ textSuffix = typeof this.suffixText === 'string' ? this.suffixText : '';
986
+ if (dataItem.value !== null) {
987
+ value = this.mentionVal(dataItem.text);
988
+ }
989
+ if (!this.isContentEditable(this.inputElement)) {
990
+ var myField = this.inputElement;
991
+ var currentTriggerSnippet = this.getTextRange().substring(startPos + this.mentionChar.length, this.getTextRange().length);
992
+ value += textSuffix;
993
+ endPos = startPos + this.mentionChar.length;
994
+ endPos += currentTriggerSnippet.length;
995
+ myField.value = myField.value.substring(0, startPos) + value + myField.value.substring(endPos, myField.value.length);
996
+ myField.selectionStart = startPos + value.length;
997
+ myField.selectionEnd = startPos + value.length;
998
+ if (this.isPopupOpen) {
999
+ this.hidePopup();
1000
+ }
1001
+ this.onChangeEvent(e);
1002
+ return true;
1003
+ }
1004
+ else {
1005
+ endPos = this.getTriggerCharPosition() + this.mentionChar.length;
1006
+ if (this.range && (this.range.startContainer.textContent.trim() !== this.mentionChar)) {
1007
+ endPos = this.range.endOffset;
1008
+ }
1009
+ globalRange = this.range;
1010
+ range = document.createRange();
1011
+ range.setStart(globalRange.startContainer, startPos);
1012
+ range.setEnd(globalRange.startContainer, endPos);
1013
+ range.deleteContents();
1014
+ var element = this.createElement('div');
1015
+ element.innerHTML = value;
1016
+ var frag = document.createDocumentFragment();
1017
+ var node = void 0;
1018
+ var lastNode = void 0;
1019
+ while (node = element.firstChild) {
1020
+ lastNode = frag.appendChild(node);
1021
+ }
1022
+ range.insertNode(frag);
1023
+ if (lastNode) {
1024
+ range = range.cloneRange();
1025
+ range.setStartAfter(lastNode);
1026
+ range.collapse(true);
1027
+ selection.removeAllRanges();
1028
+ selection.addRange(range);
1029
+ }
1030
+ if (this.isPopupOpen) {
1031
+ this.hidePopup();
1032
+ }
1033
+ this.onChangeEvent(e);
1034
+ return true;
1035
+ }
1036
+ };
1037
+ Mention.prototype.mentionVal = function (value) {
1038
+ var showChar = this.showMentionChar ? this.mentionChar : '';
1039
+ if (!isNullOrUndefined(this.displayTemplate)) {
1040
+ value = this.setDisplayTemplate();
1041
+ }
1042
+ if (this.isContentEditable(this.inputElement)) {
1043
+ return '<span contenteditable="false" class="e-mention-chip">' + showChar + value + '</span>'.concat(typeof this.suffixText === 'string' ? this.suffixText : ' ');
1044
+ }
1045
+ else {
1046
+ return showChar + value;
1047
+ }
1048
+ };
1049
+ Mention.prototype.setDisplayTemplate = function () {
1050
+ var compiledString;
1051
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1052
+ if (this.isReact) {
1053
+ this.clearTemplate(['displayTemplate']);
1054
+ if (this.displayTempElement) {
1055
+ detach(this.displayTempElement);
1056
+ this.displayTempElement = null;
1057
+ }
1058
+ }
1059
+ if (!this.displayTempElement) {
1060
+ this.displayTempElement = this.createElement('div');
1061
+ }
1062
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1063
+ if (!this.isReact) {
1064
+ this.displayTempElement.innerHTML = '';
1065
+ }
1066
+ compiledString = compile(this.displayTemplate);
1067
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1068
+ var displayCompTemp = compiledString(this.itemData, this, 'displayTemplate', this.displayTemplateId, this.isStringTemplate, null, this.displayTempElement);
1069
+ if (displayCompTemp && displayCompTemp.length > 0) {
1070
+ for (var i = 0; i < displayCompTemp.length; i++) {
1071
+ this.displayTempElement.appendChild(displayCompTemp[i]);
1072
+ }
1073
+ }
1074
+ this.renderReactTemplates();
1075
+ return this.displayTempElement.innerHTML;
1076
+ };
1077
+ Mention.prototype.setSpinnerTemplate = function () {
1078
+ var compiledString;
1079
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1080
+ if (this.isReact) {
1081
+ this.clearTemplate(['spinnerTemplate']);
1082
+ if (this.spinnerTemplateElement) {
1083
+ detach(this.spinnerTemplateElement);
1084
+ this.spinnerTemplateElement = null;
1085
+ }
1086
+ }
1087
+ if (!this.spinnerTemplateElement) {
1088
+ this.spinnerTemplateElement = this.createElement('div');
1089
+ }
1090
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1091
+ if (!this.isReact) {
1092
+ this.spinnerTemplateElement.innerHTML = '';
1093
+ }
1094
+ compiledString = compile(this.spinnerTemplate);
1095
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1096
+ var spinnerCompTemp = compiledString(null, this, 'spinnerTemplate', this.spinnerTemplateId, this.isStringTemplate, null, this.spinnerTemplateElement);
1097
+ if (spinnerCompTemp && spinnerCompTemp.length > 0) {
1098
+ for (var i = 0; i < spinnerCompTemp.length; i++) {
1099
+ this.spinnerTemplateElement.appendChild(spinnerCompTemp[i]);
1100
+ }
1101
+ }
1102
+ this.renderReactTemplates();
1103
+ };
1104
+ Mention.prototype.onChangeEvent = function (eve) {
1105
+ this.isSelected = false;
1106
+ var items = this.detachMentionChanges(this.itemData);
1107
+ var preItems;
1108
+ if (typeof this.previousItemData === 'string' ||
1109
+ typeof this.previousItemData === 'boolean' ||
1110
+ typeof this.previousItemData === 'number') {
1111
+ preItems = Object.defineProperties({}, {
1112
+ value: {
1113
+ value: this.previousItemData,
1114
+ enumerable: true
1115
+ },
1116
+ text: {
1117
+ value: this.previousItemData,
1118
+ enumerable: true
1119
+ }
1120
+ });
1121
+ }
1122
+ else {
1123
+ preItems = this.previousItemData;
1124
+ }
1125
+ var eventArgs = {
1126
+ e: eve,
1127
+ item: this.item,
1128
+ itemData: items,
1129
+ previousItem: this.previousSelectedLI,
1130
+ previousItemData: preItems,
1131
+ isInteracted: eve ? true : false,
1132
+ value: this.item.innerHTML,
1133
+ element: this.inputElement
1134
+ };
1135
+ this.trigger('change', eventArgs);
1136
+ };
1137
+ Mention.prototype.detachMentionChanges = function (value) {
1138
+ var items;
1139
+ if (typeof value === 'string' ||
1140
+ typeof value === 'boolean' ||
1141
+ typeof value === 'number') {
1142
+ items = Object.defineProperties({}, {
1143
+ value: {
1144
+ value: value,
1145
+ enumerable: true
1146
+ },
1147
+ text: {
1148
+ value: value,
1149
+ enumerable: true
1150
+ }
1151
+ });
1152
+ }
1153
+ else {
1154
+ items = value;
1155
+ }
1156
+ return items;
1157
+ };
1158
+ Mention.prototype.getItemData = function () {
1159
+ var fields = this.fields;
1160
+ var dataItem = null;
1161
+ dataItem = this.itemData;
1162
+ var dataValue;
1163
+ var dataText;
1164
+ if (!isNullOrUndefined(dataItem)) {
1165
+ dataValue = getValue(fields.value, dataItem);
1166
+ dataText = getValue(fields.text, dataItem);
1167
+ }
1168
+ var value = (!isNullOrUndefined(dataItem) &&
1169
+ !isUndefined(dataValue) ? dataValue : dataItem);
1170
+ var text = (!isNullOrUndefined(dataItem) &&
1171
+ !isUndefined(dataValue) ? dataText : dataItem);
1172
+ return { value: value, text: text };
1173
+ };
1174
+ Mention.prototype.removeSelection = function () {
1175
+ if (this.list) {
1176
+ var selectedItems = this.list.querySelectorAll('.' + dropDownBaseClasses.selected);
1177
+ if (selectedItems.length) {
1178
+ removeClass(selectedItems, dropDownBaseClasses.selected);
1179
+ selectedItems[0].removeAttribute('aria-selected');
1180
+ }
1181
+ }
1182
+ };
1183
+ Mention.prototype.onMouseOver = function (e) {
1184
+ var currentLi = closest(e.target, '.' + dropDownBaseClasses.li);
1185
+ this.setHover(currentLi);
1186
+ };
1187
+ Mention.prototype.setHover = function (li) {
1188
+ if (this.enabled && this.isValidLI(li) && !li.classList.contains(dropDownBaseClasses.hover)) {
1189
+ this.removeHover();
1190
+ addClass([li], dropDownBaseClasses.hover);
1191
+ }
1192
+ };
1193
+ Mention.prototype.removeHover = function () {
1194
+ if (this.list) {
1195
+ var hoveredItem = this.list.querySelectorAll('.' + dropDownBaseClasses.hover);
1196
+ if (hoveredItem && hoveredItem.length) {
1197
+ removeClass(hoveredItem, dropDownBaseClasses.hover);
1198
+ }
1199
+ }
1200
+ };
1201
+ Mention.prototype.isValidLI = function (li) {
1202
+ return (li && li.hasAttribute('role') && li.getAttribute('role') === 'option');
1203
+ };
1204
+ Mention.prototype.onMouseLeave = function () {
1205
+ this.removeHover();
1206
+ };
1207
+ /**
1208
+ * Search the entered text and show it in the suggestion list if available.
1209
+ *
1210
+ * @returns {void}
1211
+ */
1212
+ Mention.prototype.search = function (text, positionX, positionY) {
1213
+ if ((this.ignoreCase && (text === this.elementValue() || text === this.elementValue().toLowerCase()))
1214
+ || !this.ignoreCase && text === this.elementValue()) {
1215
+ this.resetList(this.dataSource, this.fields);
1216
+ }
1217
+ else {
1218
+ if (this.isPopupOpen) {
1219
+ this.hidePopup();
1220
+ }
1221
+ return;
1222
+ }
1223
+ if (isNullOrUndefined(this.list)) {
1224
+ this.renderList();
1225
+ this.renderPopup();
1226
+ }
1227
+ else {
1228
+ this.showPopup();
1229
+ }
1230
+ this.popupObj.element.style.left = formatUnit(positionX);
1231
+ this.popupObj.element.style.top = formatUnit(positionY);
1232
+ };
1233
+ /**
1234
+ * Removes the component from the DOM and detaches all its related event handlers. Also it removes the attributes and classes.
1235
+ *
1236
+ * @method destroy
1237
+ * @returns {void}
1238
+ */
1239
+ Mention.prototype.destroy = function () {
1240
+ this.hidePopup();
1241
+ this.unWireEvent();
1242
+ if (this.list) {
1243
+ this.unWireListEvents();
1244
+ }
1245
+ if (this.inputElement && !this.inputElement.classList.contains('e-' + this.getModuleName())) {
1246
+ return;
1247
+ }
1248
+ _super.prototype.destroy.call(this);
1249
+ };
1250
+ Mention.prototype.getLocaleName = function () {
1251
+ return 'mention';
1252
+ };
1253
+ Mention.prototype.getNgDirective = function () {
1254
+ return 'EJS-MENTION';
1255
+ };
1256
+ /**
1257
+ * Return the module name of this component.
1258
+ *
1259
+ * @private
1260
+ * @returns {string} Return the module name of this component.
1261
+ */
1262
+ Mention.prototype.getModuleName = function () {
1263
+ return 'mention';
1264
+ };
1265
+ __decorate([
1266
+ Property(null)
1267
+ ], Mention.prototype, "cssClass", void 0);
1268
+ __decorate([
1269
+ Property('@')
1270
+ ], Mention.prototype, "mentionChar", void 0);
1271
+ __decorate([
1272
+ Property(false)
1273
+ ], Mention.prototype, "showMentionChar", void 0);
1274
+ __decorate([
1275
+ Property(false)
1276
+ ], Mention.prototype, "allowSpaces", void 0);
1277
+ __decorate([
1278
+ Property(null)
1279
+ ], Mention.prototype, "suffixText", void 0);
1280
+ __decorate([
1281
+ Property(25)
1282
+ ], Mention.prototype, "suggestionCount", void 0);
1283
+ __decorate([
1284
+ Property(0)
1285
+ ], Mention.prototype, "minLength", void 0);
1286
+ __decorate([
1287
+ Property('None')
1288
+ ], Mention.prototype, "sortOrder", void 0);
1289
+ __decorate([
1290
+ Property(true)
1291
+ ], Mention.prototype, "ignoreCase", void 0);
1292
+ __decorate([
1293
+ Property(false)
1294
+ ], Mention.prototype, "highlight", void 0);
1295
+ __decorate([
1296
+ Property()
1297
+ ], Mention.prototype, "locale", void 0);
1298
+ __decorate([
1299
+ Property('auto')
1300
+ ], Mention.prototype, "popupWidth", void 0);
1301
+ __decorate([
1302
+ Property('300px')
1303
+ ], Mention.prototype, "popupHeight", void 0);
1304
+ __decorate([
1305
+ Property(null)
1306
+ ], Mention.prototype, "displayTemplate", void 0);
1307
+ __decorate([
1308
+ Property(null)
1309
+ ], Mention.prototype, "itemTemplate", void 0);
1310
+ __decorate([
1311
+ Property('No records found')
1312
+ ], Mention.prototype, "noRecordsTemplate", void 0);
1313
+ __decorate([
1314
+ Property(null)
1315
+ ], Mention.prototype, "spinnerTemplate", void 0);
1316
+ __decorate([
1317
+ Property()
1318
+ ], Mention.prototype, "target", void 0);
1319
+ __decorate([
1320
+ Property([])
1321
+ ], Mention.prototype, "dataSource", void 0);
1322
+ __decorate([
1323
+ Property(null)
1324
+ ], Mention.prototype, "query", void 0);
1325
+ __decorate([
1326
+ Property('Contains')
1327
+ ], Mention.prototype, "filterType", void 0);
1328
+ __decorate([
1329
+ Complex({ text: null, value: null, iconCss: null, groupBy: null }, FieldSettings)
1330
+ ], Mention.prototype, "fields", void 0);
1331
+ __decorate([
1332
+ Event()
1333
+ ], Mention.prototype, "actionBegin", void 0);
1334
+ __decorate([
1335
+ Event()
1336
+ ], Mention.prototype, "actionComplete", void 0);
1337
+ __decorate([
1338
+ Event()
1339
+ ], Mention.prototype, "actionFailure", void 0);
1340
+ __decorate([
1341
+ Event()
1342
+ ], Mention.prototype, "change", void 0);
1343
+ __decorate([
1344
+ Event()
1345
+ ], Mention.prototype, "beforeOpen", void 0);
1346
+ __decorate([
1347
+ Event()
1348
+ ], Mention.prototype, "opened", void 0);
1349
+ __decorate([
1350
+ Event()
1351
+ ], Mention.prototype, "closed", void 0);
1352
+ __decorate([
1353
+ Event()
1354
+ ], Mention.prototype, "select", void 0);
1355
+ __decorate([
1356
+ Event()
1357
+ ], Mention.prototype, "filtering", void 0);
1358
+ __decorate([
1359
+ Event()
1360
+ ], Mention.prototype, "created", void 0);
1361
+ __decorate([
1362
+ Event()
1363
+ ], Mention.prototype, "destroyed", void 0);
1364
+ Mention = __decorate([
1365
+ NotifyPropertyChanges
1366
+ ], Mention);
1367
+ return Mention;
1368
+ }(DropDownBase));
1369
+ export { Mention };