@syncfusion/ej2-dropdowns 23.1.43 → 23.2.4-13895

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 (288) hide show
  1. package/CHANGELOG.md +2114 -2084
  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 +83 -71
  7. package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
  8. package/dist/es6/ej2-dropdowns.es5.js +225 -212
  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 +615 -0
  14. package/dist/ts/combo-box/combo-box.ts +1028 -0
  15. package/dist/ts/common/highlight-search.ts +57 -0
  16. package/dist/ts/common/incremental-search.ts +131 -0
  17. package/dist/ts/common/interface.ts +72 -0
  18. package/dist/ts/common/virtual-scroll.ts +354 -0
  19. package/dist/ts/drop-down-base/drop-down-base.ts +1864 -0
  20. package/dist/ts/drop-down-list/drop-down-list.ts +3954 -0
  21. package/dist/ts/drop-down-tree/drop-down-tree.ts +3741 -0
  22. package/dist/ts/list-box/list-box.ts +2753 -0
  23. package/dist/ts/mention/mention.ts +1857 -0
  24. package/dist/ts/multi-select/checkbox-selection.ts +547 -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 +4880 -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 +15 -15
  45. package/src/drop-down-base/drop-down-base.js +23 -21
  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 +4 -4
  48. package/src/drop-down-list/drop-down-list.js +24 -21
  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 +19 -27
  52. package/src/list-box/list-box-model.d.ts +193 -193
  53. package/src/list-box/list-box.d.ts +5 -2
  54. package/src/list-box/list-box.js +38 -21
  55. package/src/mention/mention-model.d.ts +261 -261
  56. package/src/mention/mention.js +20 -21
  57. package/src/multi-select/multi-select-model.d.ts +512 -512
  58. package/src/multi-select/multi-select.js +19 -19
  59. package/styles/auto-complete/_all.scss +1 -1
  60. package/styles/auto-complete/_bootstrap-dark-definition.scss +3 -3
  61. package/styles/auto-complete/_bootstrap-definition.scss +2 -2
  62. package/styles/auto-complete/_bootstrap4-definition.scss +11 -11
  63. package/styles/auto-complete/_bootstrap5-definition.scss +2 -2
  64. package/styles/auto-complete/_fabric-dark-definition.scss +2 -2
  65. package/styles/auto-complete/_fabric-definition.scss +2 -2
  66. package/styles/auto-complete/_fluent-definition.scss +2 -2
  67. package/styles/auto-complete/_fusionnew-definition.scss +2 -2
  68. package/styles/auto-complete/_highcontrast-definition.scss +2 -2
  69. package/styles/auto-complete/_highcontrast-light-definition.scss +2 -2
  70. package/styles/auto-complete/_material-dark-definition.scss +2 -2
  71. package/styles/auto-complete/_material-definition.scss +2 -2
  72. package/styles/auto-complete/_material3-definition.scss +2 -2
  73. package/styles/auto-complete/_tailwind-definition.scss +2 -2
  74. package/styles/auto-complete/material3-dark.scss +1 -1
  75. package/styles/auto-complete/material3.scss +1 -1
  76. package/styles/bootstrap-dark.css +5 -0
  77. package/styles/bootstrap5-dark.css +2 -1
  78. package/styles/bootstrap5.css +2 -1
  79. package/styles/combo-box/_all.scss +1 -1
  80. package/styles/combo-box/_bootstrap-dark-definition.scss +2 -2
  81. package/styles/combo-box/_bootstrap-definition.scss +2 -2
  82. package/styles/combo-box/_bootstrap4-definition.scss +11 -11
  83. package/styles/combo-box/_bootstrap5-definition.scss +2 -2
  84. package/styles/combo-box/_fabric-dark-definition.scss +2 -2
  85. package/styles/combo-box/_fabric-definition.scss +2 -2
  86. package/styles/combo-box/_fluent-definition.scss +2 -2
  87. package/styles/combo-box/_fusionnew-definition.scss +2 -2
  88. package/styles/combo-box/_highcontrast-definition.scss +2 -2
  89. package/styles/combo-box/_highcontrast-light-definition.scss +3 -3
  90. package/styles/combo-box/_material-dark-definition.scss +2 -2
  91. package/styles/combo-box/_material-definition.scss +2 -2
  92. package/styles/combo-box/_material3-definition.scss +2 -2
  93. package/styles/combo-box/_tailwind-definition.scss +2 -2
  94. package/styles/combo-box/material3-dark.scss +1 -1
  95. package/styles/combo-box/material3.scss +1 -1
  96. package/styles/drop-down-base/_all.scss +2 -2
  97. package/styles/drop-down-base/_bootstrap-dark-definition.scss +83 -83
  98. package/styles/drop-down-base/_bootstrap-definition.scss +83 -83
  99. package/styles/drop-down-base/_bootstrap4-definition.scss +90 -90
  100. package/styles/drop-down-base/_bootstrap5-definition.scss +117 -117
  101. package/styles/drop-down-base/_definition.scss +23 -23
  102. package/styles/drop-down-base/_fabric-dark-definition.scss +86 -86
  103. package/styles/drop-down-base/_fabric-definition.scss +84 -84
  104. package/styles/drop-down-base/_fluent-definition.scss +121 -121
  105. package/styles/drop-down-base/_fusionnew-definition.scss +117 -117
  106. package/styles/drop-down-base/_highcontrast-definition.scss +105 -105
  107. package/styles/drop-down-base/_highcontrast-light-definition.scss +105 -105
  108. package/styles/drop-down-base/_layout.scss +195 -195
  109. package/styles/drop-down-base/_material-dark-definition.scss +86 -86
  110. package/styles/drop-down-base/_material-definition.scss +85 -85
  111. package/styles/drop-down-base/_material3-definition.scss +87 -87
  112. package/styles/drop-down-base/_tailwind-definition.scss +129 -129
  113. package/styles/drop-down-base/_theme.scss +391 -391
  114. package/styles/drop-down-base/material3-dark.scss +1 -1
  115. package/styles/drop-down-base/material3.scss +1 -1
  116. package/styles/drop-down-list/_all.scss +3 -3
  117. package/styles/drop-down-list/_bootstrap-dark-definition.scss +157 -157
  118. package/styles/drop-down-list/_bootstrap-definition.scss +156 -156
  119. package/styles/drop-down-list/_bootstrap4-definition.scss +202 -202
  120. package/styles/drop-down-list/_bootstrap5-definition.scss +201 -201
  121. package/styles/drop-down-list/_fabric-dark-definition.scss +128 -128
  122. package/styles/drop-down-list/_fabric-definition.scss +124 -124
  123. package/styles/drop-down-list/_fluent-definition.scss +185 -185
  124. package/styles/drop-down-list/_fusionnew-definition.scss +201 -201
  125. package/styles/drop-down-list/_highcontrast-definition.scss +142 -142
  126. package/styles/drop-down-list/_highcontrast-light-definition.scss +144 -144
  127. package/styles/drop-down-list/_layout.scss +310 -310
  128. package/styles/drop-down-list/_material-dark-definition.scss +143 -143
  129. package/styles/drop-down-list/_material-definition.scss +167 -167
  130. package/styles/drop-down-list/_material3-definition.scss +180 -180
  131. package/styles/drop-down-list/_tailwind-definition.scss +134 -134
  132. package/styles/drop-down-list/_theme.scss +10 -10
  133. package/styles/drop-down-list/icons/_bootstrap-dark.scss +14 -14
  134. package/styles/drop-down-list/icons/_bootstrap.scss +14 -14
  135. package/styles/drop-down-list/icons/_bootstrap4.scss +14 -14
  136. package/styles/drop-down-list/icons/_bootstrap5.scss +14 -14
  137. package/styles/drop-down-list/icons/_fabric-dark.scss +14 -14
  138. package/styles/drop-down-list/icons/_fabric.scss +14 -14
  139. package/styles/drop-down-list/icons/_fluent.scss +14 -14
  140. package/styles/drop-down-list/icons/_fusionnew.scss +14 -14
  141. package/styles/drop-down-list/icons/_highcontrast-light.scss +14 -14
  142. package/styles/drop-down-list/icons/_highcontrast.scss +14 -14
  143. package/styles/drop-down-list/icons/_material-dark.scss +14 -14
  144. package/styles/drop-down-list/icons/_material.scss +14 -14
  145. package/styles/drop-down-list/icons/_material3.scss +14 -14
  146. package/styles/drop-down-list/icons/_tailwind.scss +14 -14
  147. package/styles/drop-down-list/material3-dark.scss +1 -1
  148. package/styles/drop-down-list/material3.scss +1 -1
  149. package/styles/drop-down-tree/_all.scss +2 -2
  150. package/styles/drop-down-tree/_bootstrap-dark-definition.scss +71 -71
  151. package/styles/drop-down-tree/_bootstrap-definition.scss +70 -70
  152. package/styles/drop-down-tree/_bootstrap4-definition.scss +71 -71
  153. package/styles/drop-down-tree/_bootstrap5-definition.scss +59 -59
  154. package/styles/drop-down-tree/_fabric-dark-definition.scss +71 -71
  155. package/styles/drop-down-tree/_fabric-definition.scss +71 -71
  156. package/styles/drop-down-tree/_fluent-definition.scss +65 -65
  157. package/styles/drop-down-tree/_fusionnew-definition.scss +59 -59
  158. package/styles/drop-down-tree/_highcontrast-definition.scss +71 -71
  159. package/styles/drop-down-tree/_highcontrast-light-definition.scss +71 -71
  160. package/styles/drop-down-tree/_layout.scss +1418 -1412
  161. package/styles/drop-down-tree/_material-dark-definition.scss +72 -72
  162. package/styles/drop-down-tree/_material-definition.scss +72 -72
  163. package/styles/drop-down-tree/_material3-definition.scss +76 -76
  164. package/styles/drop-down-tree/_tailwind-definition.scss +61 -61
  165. package/styles/drop-down-tree/_theme.scss +132 -132
  166. package/styles/drop-down-tree/fluent-dark.css +2 -0
  167. package/styles/drop-down-tree/fluent.css +2 -0
  168. package/styles/drop-down-tree/icons/_bootstrap-dark.scss +11 -11
  169. package/styles/drop-down-tree/icons/_bootstrap.scss +11 -11
  170. package/styles/drop-down-tree/icons/_bootstrap4.scss +11 -11
  171. package/styles/drop-down-tree/icons/_bootstrap5.scss +11 -11
  172. package/styles/drop-down-tree/icons/_fabric-dark.scss +11 -11
  173. package/styles/drop-down-tree/icons/_fabric.scss +11 -11
  174. package/styles/drop-down-tree/icons/_fluent.scss +11 -11
  175. package/styles/drop-down-tree/icons/_fusionnew.scss +11 -11
  176. package/styles/drop-down-tree/icons/_highcontrast-light.scss +11 -11
  177. package/styles/drop-down-tree/icons/_highcontrast.scss +11 -11
  178. package/styles/drop-down-tree/icons/_material-dark.scss +11 -11
  179. package/styles/drop-down-tree/icons/_material.scss +11 -11
  180. package/styles/drop-down-tree/icons/_material3.scss +11 -11
  181. package/styles/drop-down-tree/icons/_tailwind-dark.scss +11 -11
  182. package/styles/drop-down-tree/icons/_tailwind.scss +11 -11
  183. package/styles/drop-down-tree/material3-dark.scss +1 -1
  184. package/styles/drop-down-tree/material3.scss +1 -1
  185. package/styles/fabric-dark.css +5 -0
  186. package/styles/fluent-dark.css +4 -1
  187. package/styles/fluent.css +4 -1
  188. package/styles/highcontrast.css +5 -0
  189. package/styles/list-box/_all.scss +2 -2
  190. package/styles/list-box/_bootstrap-dark-definition.scss +126 -126
  191. package/styles/list-box/_bootstrap-definition.scss +119 -119
  192. package/styles/list-box/_bootstrap4-definition.scss +124 -124
  193. package/styles/list-box/_bootstrap5-definition.scss +120 -120
  194. package/styles/list-box/_fabric-dark-definition.scss +126 -126
  195. package/styles/list-box/_fabric-definition.scss +119 -119
  196. package/styles/list-box/_fluent-definition.scss +120 -120
  197. package/styles/list-box/_fusionnew-definition.scss +111 -111
  198. package/styles/list-box/_highcontrast-definition.scss +119 -119
  199. package/styles/list-box/_highcontrast-light-definition.scss +126 -126
  200. package/styles/list-box/_layout.scss +542 -542
  201. package/styles/list-box/_material-dark-definition.scss +126 -126
  202. package/styles/list-box/_material-definition.scss +119 -119
  203. package/styles/list-box/_material3-definition.scss +119 -119
  204. package/styles/list-box/_tailwind-definition.scss +119 -119
  205. package/styles/list-box/_theme.scss +382 -382
  206. package/styles/list-box/icons/_bootstrap-dark.scss +25 -25
  207. package/styles/list-box/icons/_bootstrap.scss +25 -25
  208. package/styles/list-box/icons/_bootstrap4.scss +25 -25
  209. package/styles/list-box/icons/_bootstrap5.scss +25 -25
  210. package/styles/list-box/icons/_fabric-dark.scss +25 -25
  211. package/styles/list-box/icons/_fabric.scss +25 -25
  212. package/styles/list-box/icons/_fluent.scss +25 -25
  213. package/styles/list-box/icons/_fusionnew.scss +25 -25
  214. package/styles/list-box/icons/_highcontrast-light.scss +25 -25
  215. package/styles/list-box/icons/_highcontrast.scss +25 -25
  216. package/styles/list-box/icons/_material-dark.scss +25 -25
  217. package/styles/list-box/icons/_material.scss +25 -25
  218. package/styles/list-box/icons/_material3.scss +25 -25
  219. package/styles/list-box/icons/_tailwind-dark.scss +25 -25
  220. package/styles/list-box/icons/_tailwind.scss +25 -25
  221. package/styles/list-box/material3-dark.scss +1 -1
  222. package/styles/list-box/material3.scss +1 -1
  223. package/styles/material3-dark.scss +1 -1
  224. package/styles/material3.scss +1 -1
  225. package/styles/mention/_all.scss +1 -1
  226. package/styles/mention/_bootstrap-dark-definition.scss +3 -3
  227. package/styles/mention/_bootstrap-definition.scss +3 -3
  228. package/styles/mention/_bootstrap4-definition.scss +3 -3
  229. package/styles/mention/_bootstrap5-definition.scss +1 -1
  230. package/styles/mention/_fabric-dark-definition.scss +2 -2
  231. package/styles/mention/_fabric-definition.scss +3 -3
  232. package/styles/mention/_fluent-definition.scss +1 -1
  233. package/styles/mention/_fusionnew-definition.scss +1 -1
  234. package/styles/mention/_highcontrast-definition.scss +3 -3
  235. package/styles/mention/_highcontrast-light-definition.scss +3 -3
  236. package/styles/mention/_layout.scss +6 -6
  237. package/styles/mention/_material-dark-definition.scss +3 -3
  238. package/styles/mention/_material-definition.scss +3 -3
  239. package/styles/mention/_material3-definition.scss +1 -1
  240. package/styles/mention/_tailwind-definition.scss +1 -1
  241. package/styles/mention/material3-dark.scss +1 -1
  242. package/styles/mention/material3.scss +1 -1
  243. package/styles/multi-select/_all.scss +2 -2
  244. package/styles/multi-select/_bootstrap-dark-definition.scss +203 -198
  245. package/styles/multi-select/_bootstrap-definition.scss +192 -192
  246. package/styles/multi-select/_bootstrap4-definition.scss +278 -278
  247. package/styles/multi-select/_bootstrap5-definition.scss +230 -229
  248. package/styles/multi-select/_fabric-dark-definition.scss +192 -187
  249. package/styles/multi-select/_fabric-definition.scss +183 -183
  250. package/styles/multi-select/_fluent-definition.scss +241 -240
  251. package/styles/multi-select/_fusionnew-definition.scss +227 -227
  252. package/styles/multi-select/_highcontrast-definition.scss +303 -298
  253. package/styles/multi-select/_highcontrast-light-definition.scss +297 -297
  254. package/styles/multi-select/_layout.scss +2199 -2199
  255. package/styles/multi-select/_material-dark-definition.scss +230 -230
  256. package/styles/multi-select/_material-definition.scss +223 -223
  257. package/styles/multi-select/_material3-definition.scss +246 -246
  258. package/styles/multi-select/_tailwind-definition.scss +235 -234
  259. package/styles/multi-select/_theme.scss +586 -586
  260. package/styles/multi-select/bootstrap-dark.css +5 -0
  261. package/styles/multi-select/bootstrap5-dark.css +2 -1
  262. package/styles/multi-select/bootstrap5.css +2 -1
  263. package/styles/multi-select/fabric-dark.css +5 -0
  264. package/styles/multi-select/fluent-dark.css +2 -1
  265. package/styles/multi-select/fluent.css +2 -1
  266. package/styles/multi-select/highcontrast.css +5 -0
  267. package/styles/multi-select/icons/_bootstrap-dark.scss +26 -26
  268. package/styles/multi-select/icons/_bootstrap.scss +26 -26
  269. package/styles/multi-select/icons/_bootstrap4.scss +37 -37
  270. package/styles/multi-select/icons/_bootstrap5.scss +26 -26
  271. package/styles/multi-select/icons/_fabric-dark.scss +26 -26
  272. package/styles/multi-select/icons/_fabric.scss +26 -26
  273. package/styles/multi-select/icons/_fluent.scss +55 -55
  274. package/styles/multi-select/icons/_fusionnew.scss +26 -26
  275. package/styles/multi-select/icons/_highcontrast-light.scss +26 -26
  276. package/styles/multi-select/icons/_highcontrast.scss +26 -26
  277. package/styles/multi-select/icons/_material-dark.scss +693 -693
  278. package/styles/multi-select/icons/_material.scss +693 -693
  279. package/styles/multi-select/icons/_material3.scss +692 -692
  280. package/styles/multi-select/icons/_tailwind.scss +26 -26
  281. package/styles/multi-select/material3-dark.scss +1 -1
  282. package/styles/multi-select/material3.scss +1 -1
  283. package/styles/multi-select/tailwind-dark.css +2 -1
  284. package/styles/multi-select/tailwind.css +2 -1
  285. package/styles/tailwind-dark.css +2 -1
  286. package/styles/tailwind.css +2 -1
  287. package/.eslintrc.json +0 -260
  288. package/tslint.json +0 -111
@@ -0,0 +1,2753 @@
1
+ // eslint-disable-next-line @typescript-eslint/triple-slash-reference
2
+ /// <reference path='../drop-down-base/drop-down-base-model.d.ts'/>
3
+ import { Input, InputObject } from '@syncfusion/ej2-inputs';
4
+ import { DropDownBase, dropDownBaseClasses, FilteringEventArgs, SelectEventArgs } from '../drop-down-base/drop-down-base';
5
+ import { FieldSettingsModel } from '../drop-down-base/drop-down-base-model';
6
+ import { EventHandler, closest, removeClass, addClass, Complex, Property, ChildProperty, BaseEventArgs, L10n } from '@syncfusion/ej2-base';
7
+ import { ModuleDeclaration, NotifyPropertyChanges, getComponent, EmitType, Event, extend, detach, attributes } from '@syncfusion/ej2-base';
8
+ import { getUniqueID, Browser, formatUnit, isNullOrUndefined, getValue } from '@syncfusion/ej2-base';
9
+ import { prepend, append } from '@syncfusion/ej2-base';
10
+ import { cssClass, Sortable, moveTo } from '@syncfusion/ej2-lists';
11
+ import { SelectionSettingsModel, ListBoxModel, ToolbarSettingsModel } from './list-box-model';
12
+ import { Button } from '@syncfusion/ej2-buttons';
13
+ import { createSpinner, showSpinner, hideSpinner, getZindexPartial } from '@syncfusion/ej2-popups';
14
+ import { DataManager, Query } from '@syncfusion/ej2-data';
15
+ /**
16
+ * Defines the selection mode in ListBox component.
17
+ * ```props
18
+ * Multiple :- Specifies that the ListBox should allow multiple item selection.
19
+ * Single :- Specifies that the ListBox should allow single item selection.
20
+ * ```
21
+ */
22
+ export type SelectionMode = 'Multiple' | 'Single';
23
+ /**
24
+ * Defines the position of the toolbar in ListBox component.
25
+ * ```props
26
+ * Left :- Specifies that the toolbar should be positioned to the left of the ListBox.
27
+ * Right :- Specifies that the toolbar should be positioned to the right of the ListBox.
28
+ * ```
29
+ */
30
+ export type ToolBarPosition = 'Left' | 'Right';
31
+ /**
32
+ * Defines the position of the checkbox in ListBox component.
33
+ * ```props
34
+ * Left :- Specifies that the checkbox should be positioned to the left of the ListBox.
35
+ * Right :- Specifies that the checkbox should be positioned to the right of the ListBox.
36
+ * ```
37
+ */
38
+ export type CheckBoxPosition = 'Left' | 'Right';
39
+
40
+ type dataType = { [key: string]: object } | string | boolean | number;
41
+ type obj = { [key: string]: object };
42
+ const ITEMTEMPLATE_PROPERTY: string = 'ItemTemplate';
43
+ /**
44
+ * Defines the Selection settings of List Box.
45
+ */
46
+ export class SelectionSettings extends ChildProperty<SelectionSettings> {
47
+ /**
48
+ * Specifies the selection modes. The possible values are
49
+ * * `Single`: Allows you to select a single item in the ListBox.
50
+ * * `Multiple`: Allows you to select more than one item in the ListBox.
51
+ *
52
+ * @default 'Multiple'
53
+ */
54
+ @Property('Multiple')
55
+ public mode: SelectionMode;
56
+
57
+ /**
58
+ * If 'showCheckbox' is set to true, then 'checkbox' will be visualized in the list item.
59
+ *
60
+ * @default false
61
+ */
62
+ @Property(false)
63
+ public showCheckbox: boolean;
64
+
65
+ /**
66
+ * Allows you to either show or hide the selectAll option on the component.
67
+ *
68
+ * @default false
69
+ */
70
+ @Property(false)
71
+ public showSelectAll: boolean;
72
+
73
+ /**
74
+ * Set the position of the checkbox.
75
+ *
76
+ * @default 'Left'
77
+ */
78
+ @Property('Left')
79
+ public checkboxPosition: CheckBoxPosition;
80
+ }
81
+ /**
82
+ * Defines the toolbar settings of List Box.
83
+ */
84
+ export class ToolbarSettings extends ChildProperty<ToolbarSettings> {
85
+ /**
86
+ * Specifies the list of tools for dual ListBox.
87
+ * The predefined tools are 'moveUp', 'moveDown', 'moveTo', 'moveFrom', 'moveAllTo', and 'moveAllFrom'.
88
+ *
89
+ * @default []
90
+ */
91
+ @Property([])
92
+ public items: string[];
93
+
94
+ /**
95
+ * Positions the toolbar before/after the ListBox.
96
+ * The possible values are:
97
+ * * Left: The toolbar will be positioned to the left of the ListBox.
98
+ * * Right: The toolbar will be positioned to the right of the ListBox.
99
+ *
100
+ * @default 'Right'
101
+ */
102
+ @Property('Right')
103
+ public position: ToolBarPosition;
104
+ }
105
+
106
+ /**
107
+ * The ListBox is a graphical user interface component used to display a list of items.
108
+ * Users can select one or more items in the list using a checkbox or by keyboard selection.
109
+ * It supports sorting, grouping, reordering and drag and drop of items.
110
+ * ```html
111
+ * <select id="listbox">
112
+ * <option value='1'>Badminton</option>
113
+ * <option value='2'>Basketball</option>
114
+ * <option value='3'>Cricket</option>
115
+ * <option value='4'>Football</option>
116
+ * <option value='5'>Tennis</option>
117
+ * </select>
118
+ * ```
119
+ * ```typescript
120
+ * <script>
121
+ * var listObj = new ListBox();
122
+ * listObj.appendTo("#listbox");
123
+ * </script>
124
+ * ```
125
+ */
126
+ @NotifyPropertyChanges
127
+ export class ListBox extends DropDownBase {
128
+ private prevSelIdx: number;
129
+ private listCurrentOptions: FieldSettingsModel;
130
+ private allowDragAll: boolean;
131
+ private checkBoxSelectionModule: { onDocumentClick: Function, checkAllParent: HTMLElement, clearIconElement: HTMLElement };
132
+ private tBListBox: ListBox;
133
+ private initLoad: boolean;
134
+ private spinner: HTMLElement;
135
+ private initialSelectedOptions: string[] | number[] | boolean[];
136
+ private showSelectAll: boolean;
137
+ private selectAllText: string;
138
+ private unSelectAllText: string;
139
+ private popupWrapper: Element;
140
+ private targetInputElement: HTMLInputElement | string;
141
+ private isValidKey: boolean = false;
142
+ private isFiltered: boolean;
143
+ private clearFilterIconElem: Element;
144
+ private remoteFilterAction: boolean;
145
+ private mainList: HTMLElement;
146
+ private remoteCustomValue: boolean;
147
+ private filterParent: HTMLElement;
148
+ protected inputString: string;
149
+ protected filterInput: HTMLInputElement;
150
+ protected isCustomFiltering: boolean;
151
+ private jsonData: { [key: string]: Object }[] | string[] | boolean[] | number[];
152
+ private toolbarAction: string;
153
+ private isDataSourceUpdate: boolean = false;
154
+ private dragValue: string;
155
+ private customDraggedItem: Object[];
156
+ private timer: number;
157
+ /**
158
+ * Sets the CSS classes to root element of this component, which helps to customize the
159
+ * complete styles.
160
+ *
161
+ * @default ''
162
+ */
163
+ @Property('')
164
+ public cssClass: string;
165
+
166
+ /**
167
+ * Sets the specified item to the selected state or gets the selected item in the ListBox.
168
+ *
169
+ * @default []
170
+ * @aspType object
171
+ * @isGenericType true
172
+ */
173
+ @Property([])
174
+ public value: string[] | number[] | boolean[];
175
+
176
+ /**
177
+ * Sets the height of the ListBox component.
178
+ *
179
+ * @default ''
180
+ */
181
+ @Property('')
182
+ public height: number | string;
183
+
184
+ /**
185
+ * Specifies a value that indicates whether the component is enabled or not.
186
+ *
187
+ * @default true
188
+ * @deprecated
189
+ */
190
+ @Property(true)
191
+ public enabled: boolean;
192
+
193
+ /**
194
+ * Enable or disable persisting component's state between page reloads.
195
+ * If enabled, following list of states will be persisted.
196
+ * 1. value
197
+ *
198
+ * @default false
199
+ * @deprecated
200
+ */
201
+ @Property(false)
202
+ public enablePersistence: boolean;
203
+
204
+ /**
205
+ * If 'allowDragAndDrop' is set to true, then you can perform drag and drop of the list item.
206
+ * ListBox contains same 'scope' property enables drag and drop between multiple ListBox.
207
+ *
208
+ * @default false
209
+ */
210
+ @Property(false)
211
+ public allowDragAndDrop: boolean;
212
+
213
+ /**
214
+ * Sets limitation to the value selection.
215
+ * based on the limitation, list selection will be prevented.
216
+ *
217
+ * @default 1000
218
+ */
219
+ @Property(1000)
220
+ public maximumSelectionLength: number;
221
+
222
+ /**
223
+ * To enable the filtering option in this component.
224
+ * Filter action performs when type in search box and collect the matched item through `filtering` event.
225
+ * If searching character does not match, `noRecordsTemplate` property value will be shown.
226
+ *
227
+ * @default false
228
+ */
229
+ @Property(false)
230
+ public allowFiltering: boolean;
231
+
232
+ /**
233
+ * Defines the scope value to group sets of draggable and droppable ListBox.
234
+ * A draggable with the same scope value will be accepted by the droppable.
235
+ *
236
+ * @default ''
237
+ */
238
+ @Property('')
239
+ public scope: string;
240
+
241
+ /**
242
+ * When set to ‘false’, consider the `case-sensitive` on performing the search to find suggestions.
243
+ * By default consider the casing.
244
+ *
245
+ * @default true
246
+ * @private
247
+ */
248
+ @Property(true)
249
+ public ignoreCase: boolean;
250
+
251
+ /**
252
+ * Accepts the value to be displayed as a watermark text on the filter bar.
253
+ *
254
+ * @default null
255
+ */
256
+ @Property(null)
257
+ public filterBarPlaceholder: string;
258
+
259
+ /**
260
+ * Triggers while rendering each list item.
261
+ *
262
+ * @event beforeItemRender
263
+ * @blazorProperty 'OnItemRender'
264
+ */
265
+ @Event()
266
+ public beforeItemRender: EmitType<BeforeItemRenderEventArgs>;
267
+
268
+ /**
269
+ * Triggers on typing a character in the component.
270
+ *
271
+ * @event filtering
272
+ * @blazorProperty 'ItemSelected'
273
+ */
274
+ @Event()
275
+ public filtering: EmitType<FilteringEventArgs>;
276
+
277
+ /**
278
+ * Triggers when an item in the popup is selected by the user either with mouse/tap or with keyboard navigation.
279
+ *
280
+ * @event select
281
+ * @private
282
+ */
283
+ @Event()
284
+ public select: EmitType<SelectEventArgs>;
285
+
286
+ /**
287
+ * Adds a new item to the popup list. By default, new item appends to the list as the last item,
288
+ * but you can insert based on the index parameter.
289
+ *
290
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
291
+ * @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
292
+ * @returns {void}.
293
+ * @private
294
+ */
295
+ public addItem(
296
+ items: { [key: string]: Object }[] | { [key: string]: Object } | string | boolean | number | string[] | boolean[] | number[],
297
+ itemIndex?: number): void {
298
+ super.addItem(items, itemIndex);
299
+ }
300
+
301
+ /**
302
+ * Triggers while select / unselect the list item.
303
+ *
304
+ * @event change
305
+ * @blazorProperty 'ValueChange'
306
+ */
307
+ @Event()
308
+ public change: EmitType<ListBoxChangeEventArgs>;
309
+
310
+ /**
311
+ * Triggers before dropping the list item on another list item.
312
+ *
313
+ * @event beforeDrop
314
+ * @blazorProperty 'OnDrop'
315
+ */
316
+ @Event()
317
+ public beforeDrop: EmitType<DropEventArgs>;
318
+
319
+ /**
320
+ * Triggers after dragging the list item.
321
+ *
322
+ * @event dragStart
323
+ * @blazorProperty 'DragStart'
324
+ */
325
+ @Event()
326
+ public dragStart: EmitType<DragEventArgs>;
327
+
328
+ /**
329
+ * Triggers while dragging the list item.
330
+ *
331
+ * @event drag
332
+ * @blazorProperty 'Dragging'
333
+ */
334
+ @Event()
335
+ public drag: EmitType<DragEventArgs>;
336
+
337
+ /**
338
+ * Triggers before dropping the list item on another list item.
339
+ *
340
+ * @event drop
341
+ * @blazorProperty 'Dropped'
342
+ */
343
+ @Event()
344
+ public drop: EmitType<DragEventArgs>;
345
+
346
+ /**
347
+ * Triggers when data source is populated in the list.
348
+ *
349
+ * @event dataBound
350
+ */
351
+ @Event()
352
+ public dataBound: EmitType<Object>;
353
+
354
+ /**
355
+ * Accepts the template design and assigns it to the group headers present in the list.
356
+ *
357
+ * @default null
358
+ * @private
359
+ */
360
+ @Property(null)
361
+ public groupTemplate: string;
362
+ /**
363
+ * Accepts the template and assigns it to the list content of the ListBox component
364
+ * when the data fetch request from the remote server fails.
365
+ *
366
+ * @default 'Request Failed'
367
+ * @private
368
+ */
369
+ @Property('Request failed')
370
+ public actionFailureTemplate: string;
371
+
372
+ /**
373
+ * specifies the z-index value of the component popup element.
374
+ *
375
+ * @default 1000
376
+ * @private
377
+ */
378
+ @Property(1000)
379
+ public zIndex: number;
380
+ /**
381
+ * ignoreAccent set to true, then ignores the diacritic characters or accents when filtering.
382
+ *
383
+ * @private
384
+ */
385
+ @Property(false)
386
+ public ignoreAccent: boolean;
387
+
388
+ /**
389
+ * Specifies the toolbar items and its position.
390
+ *
391
+ * @default { items: [], position: 'Right' }
392
+ */
393
+ @Complex<ToolbarSettingsModel>({}, ToolbarSettings)
394
+ public toolbarSettings: ToolbarSettingsModel;
395
+
396
+ /**
397
+ * Specifies the selection mode and its type.
398
+ *
399
+ * @default { mode: 'Multiple', type: 'Default' }
400
+ */
401
+ @Complex<SelectionSettingsModel>({}, SelectionSettings)
402
+ public selectionSettings: SelectionSettingsModel;
403
+
404
+ /**
405
+ * Constructor for creating the ListBox component.
406
+ *
407
+ * @param {ListBoxModel} options - Specifies ListBox model
408
+ * @param {string | HTMLElement} element - Specifies the element.
409
+ */
410
+ constructor(options?: ListBoxModel, element?: string | HTMLElement) {
411
+ super(options, element);
412
+ }
413
+
414
+ /**
415
+ * Build and render the component.
416
+ *
417
+ * @private
418
+ * @returns {void}
419
+ */
420
+ public render(): void {
421
+ this.inputString = '';
422
+ this.initLoad = true;
423
+ this.isCustomFiltering = false;
424
+ this.initialSelectedOptions = this.value;
425
+ super.render();
426
+ this.setEnabled();
427
+ this.renderComplete();
428
+ }
429
+
430
+ private initWrapper(): void {
431
+ const hiddenSelect: HTMLElement = this.createElement('select', { className: 'e-hidden-select', attrs: { 'multiple': '' } });
432
+ hiddenSelect.style.visibility = 'hidden';
433
+ this.list.classList.add('e-listbox-wrapper');
434
+ if (this.itemTemplate) {
435
+ this.list.classList.add('e-list-template');
436
+ }
437
+ this.list.classList.add('e-wrapper');
438
+ this.list.classList.add('e-lib');
439
+ if (this.element.tagName === 'EJS-LISTBOX') {
440
+ this.element.setAttribute('tabindex', '0');
441
+ if (this.initLoad) {
442
+ this.element.appendChild(this.list);
443
+ }
444
+ } else {
445
+ if (this.initLoad) {
446
+ this.element.parentElement.insertBefore(this.list, this.element);
447
+ }
448
+ this.list.insertBefore(this.element, this.list.firstChild);
449
+ this.element.style.display = 'none';
450
+ }
451
+ this.list.insertBefore(hiddenSelect, this.list.firstChild);
452
+ if (this.list.getElementsByClassName('e-list-item')[0]) {
453
+ this.list.getElementsByClassName('e-list-item')[0].classList.remove(dropDownBaseClasses.focus);
454
+ }
455
+ if (this.itemTemplate) { this.renderReactTemplates(); }
456
+ removeClass([this.list], [dropDownBaseClasses.content, dropDownBaseClasses.root]);
457
+ this.validationAttribute(this.element as HTMLInputElement, hiddenSelect as HTMLSelectElement);
458
+ this.list.setAttribute('role', 'listbox');
459
+ attributes(this.list, { 'role': 'listbox', 'aria-label': 'listbox', 'aria-multiselectable': this.selectionSettings.mode === 'Multiple' ? 'true' : 'false' });
460
+ this.updateSelectionSettings();
461
+ }
462
+
463
+ private updateSelectionSettings(): void {
464
+ if (this.selectionSettings.showCheckbox && this.selectionSettings.showSelectAll && this.liCollections.length) {
465
+ const l10nSelect: L10n = new L10n(
466
+ this.getModuleName(), { selectAllText: 'Select All', unSelectAllText: 'Unselect All' }, this.locale);
467
+ this.showSelectAll = true;
468
+ this.selectAllText = l10nSelect.getConstant('selectAllText');
469
+ this.unSelectAllText = l10nSelect.getConstant('unSelectAllText');
470
+ this.popupWrapper = this.list;
471
+ this.checkBoxSelectionModule.checkAllParent = null;
472
+ this.notify('selectAll', {});
473
+ }
474
+ }
475
+
476
+ private initDraggable(): void {
477
+ if (this.ulElement) {
478
+ this.ulElement.id = this.element.id + '_parent';
479
+ }
480
+ if (this.allowDragAndDrop) {
481
+ new Sortable(this.ulElement, {
482
+ scope: this.scope,
483
+ itemClass: 'e-list-item',
484
+ dragStart: this.triggerDragStart.bind(this),
485
+ drag: this.triggerDrag.bind(this),
486
+ beforeDrop: this.beforeDragEnd.bind(this),
487
+ drop: this.dragEnd.bind(this),
488
+ placeHolder: () => { return this.createElement('span', { className: 'e-placeholder' }); },
489
+ helper: (e: { sender: Element }) => {
490
+ const wrapper: HTMLElement = this.list.cloneNode() as HTMLElement;
491
+ const ele: HTMLElement = e.sender.cloneNode(true) as HTMLElement;
492
+ wrapper.appendChild(ele);
493
+ const refEle: HTMLElement = this.getItems()[0] as HTMLElement;
494
+ wrapper.style.width = refEle.offsetWidth + 'px';
495
+ wrapper.style.height = refEle.offsetHeight + 'px';
496
+ if ((this.value && this.value.length) > 1 && this.isSelected(ele)) {
497
+ ele.appendChild(this.createElement('span', {
498
+ className: 'e-list-badge', innerHTML: this.value.length + ''
499
+ }));
500
+ }
501
+ wrapper.style.zIndex = getZindexPartial(this.element) + '';
502
+ return wrapper;
503
+ }
504
+ }
505
+ );
506
+ }
507
+ }
508
+
509
+ protected updateActionCompleteData(li: HTMLElement, item: { [key: string]: Object }, index: number): void {
510
+ (this.jsonData as { [key: string]: Object }[]).splice(index, 0, item);
511
+ }
512
+
513
+ private initToolbar(): void {
514
+ const pos: string = this.toolbarSettings.position;
515
+ const prevScope: string = this.element.getAttribute('data-value');
516
+ if (this.toolbarSettings.items.length) {
517
+ const toolElem: Element = this.createElement('div', { className: 'e-listbox-tool', attrs: { 'role': 'toolbar' } });
518
+ const wrapper: Element = this.createElement('div', {
519
+ className: 'e-listboxtool-wrapper e-lib e-' + pos.toLowerCase()
520
+ });
521
+ this.list.parentElement.insertBefore(wrapper, this.list);
522
+ wrapper.appendChild(pos === 'Right' ? this.list : toolElem);
523
+ wrapper.appendChild(pos === 'Right' ? toolElem : this.list);
524
+ this.createButtons(toolElem);
525
+ if (!this.element.id) {
526
+ this.element.id = getUniqueID('e-' + this.getModuleName());
527
+ }
528
+ if (this.scope) {
529
+ document.querySelector(this.scope).setAttribute('data-value', this.element.id);
530
+ } else {
531
+ this.updateToolBarState();
532
+ }
533
+ }
534
+ const scope: string = this.element.getAttribute('data-value');
535
+ if (prevScope && scope && (prevScope !== scope)) {
536
+ this.tBListBox = getComponent(document.getElementById(prevScope), this.getModuleName());
537
+ this.tBListBox.updateToolBarState();
538
+ } else if (scope) {
539
+ this.tBListBox = getComponent(document.getElementById(scope), this.getModuleName());
540
+ this.tBListBox.updateToolBarState();
541
+ }
542
+ }
543
+
544
+ private createButtons(toolElem: Element): void {
545
+ let btn: Button;
546
+ let ele: HTMLButtonElement;
547
+ let title: string;
548
+ const l10n: L10n = new L10n(
549
+ this.getModuleName(),
550
+ {
551
+ moveUp: 'Move Up', moveDown: 'Move Down', moveTo: 'Move To',
552
+ moveFrom: 'Move From', moveAllTo: 'Move All To', moveAllFrom: 'Move All From'
553
+ },
554
+ this.locale
555
+ );
556
+ this.toolbarSettings.items.forEach((value: string) => {
557
+ title = l10n.getConstant(value);
558
+ ele = this.createElement('button', {
559
+ attrs: {
560
+ 'type': 'button',
561
+ 'data-value': value,
562
+ 'title': title,
563
+ 'aria-label': title
564
+ }
565
+ }) as HTMLButtonElement;
566
+ toolElem.appendChild(ele);
567
+ btn = new Button({ iconCss: 'e-icons e-' + value.toLowerCase() }, ele);
568
+ btn.createElement = this.createElement;
569
+ });
570
+ }
571
+
572
+ protected validationAttribute(input: HTMLInputElement, hiddenSelect: HTMLSelectElement): void {
573
+ super.validationAttribute(input, hiddenSelect);
574
+ hiddenSelect.required = input.required;
575
+ input.required = false;
576
+ }
577
+
578
+ private setHeight(): void {
579
+ const ele: HTMLElement = this.toolbarSettings.items.length ? this.list.parentElement : this.list;
580
+ ele.style.height = formatUnit(this.height);
581
+ if (this.allowFiltering && this.height.toString().indexOf('%') < 0) {
582
+ addClass([this.list], 'e-filter-list');
583
+ } else {
584
+ removeClass([this.list], 'e-filter-list');
585
+ }
586
+ }
587
+
588
+ private setCssClass(): void {
589
+ const wrap: Element = this.toolbarSettings.items.length ? this.list.parentElement : this.list;
590
+ if (this.cssClass) {
591
+ addClass([wrap], this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
592
+ }
593
+ if (this.enableRtl) {
594
+ addClass([this.list], 'e-rtl');
595
+ }
596
+ }
597
+
598
+ private setEnable(): void {
599
+ const ele: Element = this.toolbarSettings.items.length ? this.list.parentElement : this.list;
600
+ if (this.enabled) {
601
+ removeClass([ele], cssClass.disabled);
602
+ } else {
603
+ addClass([ele], cssClass.disabled);
604
+ }
605
+ }
606
+
607
+ public showSpinner(): void {
608
+ if (!this.spinner) {
609
+ this.spinner = this.createElement('div', { className: 'e-listbox-wrapper' });
610
+ }
611
+ this.spinner.style.height = formatUnit(this.height);
612
+ this.element.parentElement.insertBefore(this.spinner, this.element.nextSibling);
613
+ createSpinner({ target: this.spinner }, this.createElement);
614
+ showSpinner(this.spinner);
615
+ }
616
+
617
+ public hideSpinner(): void {
618
+ if (this.spinner.querySelector('.e-spinner-pane')) {
619
+ hideSpinner(this.spinner);
620
+ }
621
+ if (this.spinner.parentElement) {
622
+ detach(this.spinner);
623
+ }
624
+ }
625
+
626
+ private onInput(): void {
627
+ this.isDataSourceUpdate = false;
628
+ if (this.keyDownStatus) {
629
+ this.isValidKey = true;
630
+ } else {
631
+ this.isValidKey = false;
632
+ }
633
+ this.keyDownStatus = false;
634
+ this.refreshClearIcon();
635
+ }
636
+
637
+ private clearText(): void {
638
+ this.filterInput.value = '';
639
+ this.refreshClearIcon();
640
+ const event: KeyboardEvent = document.createEvent('KeyboardEvent');
641
+ this.isValidKey = true;
642
+ this.KeyUp(event);
643
+ }
644
+
645
+ private refreshClearIcon(): void {
646
+ if (this.filterInput.parentElement.querySelector('.' + listBoxClasses.clearIcon)) {
647
+ const clearElement: HTMLElement = <HTMLElement>this.filterInput.parentElement.querySelector('.' + listBoxClasses.clearIcon);
648
+ clearElement.style.visibility = this.filterInput.value === '' ? 'hidden' : 'visible';
649
+ }
650
+ }
651
+
652
+ protected onActionComplete(
653
+ ulElement: HTMLElement,
654
+ list: obj[] | boolean[] | string[] | number[],
655
+ e?: Object): void {
656
+ let searchEle: Element;
657
+ if (this.allowFiltering && this.list.getElementsByClassName('e-filter-parent')[0]) {
658
+ searchEle = this.list.getElementsByClassName('e-filter-parent')[0].cloneNode(true) as Element;
659
+ }
660
+ if (list.length === 0) {
661
+ const noRecElem: Element = ulElement.childNodes[0] as Element;
662
+ if (noRecElem) {
663
+ ulElement.removeChild(noRecElem);
664
+ }
665
+ }
666
+ super.onActionComplete(ulElement, list, e);
667
+ if (this.allowFiltering && !isNullOrUndefined(searchEle)) {
668
+ this.list.insertBefore(searchEle, this.list.firstElementChild);
669
+ this.filterParent = this.list.getElementsByClassName('e-filter-parent')[0] as HTMLElement;
670
+ this.filterWireEvents(searchEle);
671
+ }
672
+ this.initWrapper();
673
+ this.setSelection();
674
+ this.initDraggable();
675
+ this.mainList = this.ulElement;
676
+ if (this.initLoad) {
677
+ this.jsonData = []; extend(this.jsonData, list, []);
678
+ this.initToolbarAndStyles();
679
+ this.wireEvents();
680
+ if (this.showCheckbox) {
681
+ this.setCheckboxPosition();
682
+ }
683
+ if (this.allowFiltering) {
684
+ this.setFiltering();
685
+ }
686
+ } else {
687
+ if (this.isDataSourceUpdate) {
688
+ this.jsonData = []; extend(this.jsonData, list, []);
689
+ this.isDataSourceUpdate = false;
690
+ }
691
+ if (this.allowFiltering) {
692
+ const filterElem: HTMLInputElement = (this.list.getElementsByClassName('e-input-filter')[0] as HTMLInputElement);
693
+ const txtLength: number = this.filterInput.value.length;
694
+ filterElem.selectionStart = txtLength;
695
+ filterElem.selectionEnd = txtLength;
696
+ filterElem.focus();
697
+ }
698
+ }
699
+ if (this.toolbarSettings.items.length && this.scope && this.scope.indexOf('#') > -1 && !isNullOrUndefined(e)) {
700
+ const scope: string = this.scope.replace('#', '');
701
+ const scopedLB: ListBox = getComponent(document.getElementById(scope), this.getModuleName());
702
+ scopedLB.initToolbar();
703
+ }
704
+ this.initLoad = false;
705
+ }
706
+
707
+ private initToolbarAndStyles(): void {
708
+ this.initToolbar();
709
+ this.setCssClass();
710
+ this.setEnable();
711
+ this.setHeight();
712
+ }
713
+
714
+ private triggerDragStart(args: DragEventArgs ): void {
715
+ let badge: Element;
716
+ args = extend(this.getDragArgs(args), { dragSelected: true }) as DragEventArgs;
717
+ if (Browser.isIos) {
718
+ this.list.style.overflow = 'hidden';
719
+ }
720
+ this.trigger('dragStart', args, (dragEventArgs: DragEventArgs) => {
721
+ this.allowDragAll = dragEventArgs.dragSelected;
722
+ if (!this.allowDragAll) {
723
+ badge = this.ulElement.getElementsByClassName('e-list-badge')[0];
724
+ if (badge) { detach(badge); }
725
+ }
726
+ });
727
+ }
728
+
729
+ private triggerDrag(args: DragEventArgs): void {
730
+ let scrollParent: HTMLElement; let boundRect: DOMRect; const scrollMoved: number = 36;
731
+ let scrollHeight: number = 10;
732
+ if (this.itemTemplate && args.target) {
733
+ if (args.target && args.target.closest('.e-list-item')) {
734
+ scrollHeight = args.target.closest('.e-list-item').scrollHeight;
735
+ } else {
736
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
737
+ const listItem: HTMLElement = (args as any).element.querySelector('.e-list-item');
738
+ if (listItem) {
739
+ scrollHeight = listItem.scrollHeight;
740
+ }
741
+ }
742
+ }
743
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
744
+ const event: any = (args as any).event; let wrapper: HTMLElement; this.stopTimer();
745
+ if (args.target && (args.target.classList.contains('e-listbox-wrapper') || args.target.classList.contains('e-list-item')
746
+ || args.target.classList.contains('e-filter-parent') || args.target.classList.contains('e-input-group')
747
+ || args.target.closest('.e-list-item'))) {
748
+ if (args.target.classList.contains('e-list-item') || args.target.classList.contains('e-filter-parent')
749
+ || args.target.classList.contains('e-input-group')
750
+ || args.target.closest('.e-list-item')) {
751
+ wrapper = args.target.closest('.e-listbox-wrapper') as HTMLElement;
752
+ } else {
753
+ wrapper = args.target as HTMLElement;
754
+ }
755
+ if (this.allowFiltering) {
756
+ scrollParent = wrapper.querySelector('.e-list-parent');
757
+ } else {
758
+ scrollParent = wrapper;
759
+ }
760
+ boundRect = scrollParent.getBoundingClientRect() as DOMRect;
761
+ if ((boundRect.y + scrollParent.offsetHeight) - (event.clientY + scrollMoved) < 1) {
762
+ this.timer = window.setInterval(() => { this.setScrollDown(scrollParent, scrollHeight, true); }, 70);
763
+ }
764
+ else if ((event.clientY - scrollMoved) - boundRect.y < 1) {
765
+ this.timer = window.setInterval(() => { this.setScrollDown(scrollParent, scrollHeight, false); }, 70);
766
+ }
767
+ }
768
+ if (args.target === null) {
769
+ return;
770
+ }
771
+ this.trigger('drag', this.getDragArgs(args as DragEventArgs));
772
+ }
773
+
774
+ private setScrollDown(scrollElem: Element, scrollPixel: number, isScrollDown: boolean): void {
775
+ if (isScrollDown) {
776
+ scrollElem.scrollTop = scrollElem.scrollTop + scrollPixel;
777
+ } else {
778
+ scrollElem.scrollTop = scrollElem.scrollTop - scrollPixel;
779
+ }
780
+ }
781
+
782
+ private stopTimer(): void {
783
+ window.clearInterval(this.timer);
784
+ }
785
+
786
+ private beforeDragEnd(args: DropEventArgs): void {
787
+ this.stopTimer();
788
+ let items: object[] = [];
789
+ this.dragValue = this.getFormattedValue(args.droppedElement.getAttribute('data-value')) as string;
790
+ if ((this.value as string[]).indexOf(this.dragValue) > -1) {
791
+ args.items = this.getDataByValues(this.value);
792
+ } else {
793
+ args.items = this.getDataByValues([this.dragValue]);
794
+ }
795
+ extend(items, args.items);
796
+ this.trigger('beforeDrop', args);
797
+ if (args.items !== items) {
798
+ this.customDraggedItem = args.items;
799
+ }
800
+ }
801
+
802
+ private dragEnd(args: DropEventArgs): void {
803
+ let listData: dataType[]; let liColl: HTMLElement[]; let jsonData: dataType[]; let droppedData: dataType;
804
+ let selectedOptions: (string | boolean | number)[]; let sortedData: dataType[];
805
+ const dropValue: string | number | boolean = this.getFormattedValue(args.droppedElement.getAttribute('data-value'));
806
+ const listObj: ListBox = this.getComponent(args.droppedElement);
807
+ const getArgs: Object = this.getDragArgs({ target: args.droppedElement } as DragEventArgs , true);
808
+ const sourceArgs: Object = { previousData: this.dataSource }; const destArgs: Object = { previousData: listObj.dataSource };
809
+ let dragArgs: Object = extend({}, getArgs, { target: args.target, source: { previousData: this.dataSource },
810
+ previousIndex: args.previousIndex, currentIndex: args.currentIndex });
811
+ if (listObj !== this) {
812
+ const sourceArgs1: Object = extend( sourceArgs, {currentData: this.listData});
813
+ dragArgs = extend(dragArgs, { source: sourceArgs1, destination: destArgs} );
814
+ }
815
+ if (Browser.isIos) {
816
+ this.list.style.overflow = '';
817
+ }
818
+ const targetListObj: ListBox = this.getComponent(args.target);
819
+ if (targetListObj && targetListObj.listData.length === 0) {
820
+ const noRecElem: Element = targetListObj.ulElement.childNodes[0] as Element;
821
+ if (noRecElem) {
822
+ targetListObj.ulElement.removeChild(noRecElem);
823
+ }
824
+ }
825
+ if (listObj === this) {
826
+ const ul: Element = this.ulElement;
827
+ listData = [].slice.call(this.listData); liColl = [].slice.call(this.liCollections);
828
+ jsonData = [].slice.call(this.jsonData); sortedData = [].slice.call(this.sortedData);
829
+ const toSortIdx: number = args.currentIndex;
830
+ let toIdx: number = args.currentIndex = this.getCurIdx(this, args.currentIndex);
831
+ const rIdx: number = listData.indexOf(this.getDataByValue(dropValue));
832
+ const jsonIdx: number = jsonData.indexOf(this.getDataByValue(dropValue));
833
+ const sIdx: number = sortedData.indexOf(this.getDataByValue(dropValue));
834
+ listData.splice(toIdx, 0, listData.splice(rIdx, 1)[0] as obj);
835
+ sortedData.splice(toSortIdx, 0, sortedData.splice(sIdx, 1)[0] as obj);
836
+ jsonData.splice(toIdx, 0, jsonData.splice(jsonIdx, 1)[0] as obj);
837
+ liColl.splice(toIdx, 0, liColl.splice(rIdx, 1)[0] as HTMLElement);
838
+ if (this.allowDragAll) {
839
+ selectedOptions = this.value && Array.prototype.indexOf.call(this.value, dropValue) > -1 ? this.value : [dropValue];
840
+ if (!isNullOrUndefined(this.customDraggedItem)) {
841
+ selectedOptions = [];
842
+ this.customDraggedItem.forEach((item: object) => {
843
+ selectedOptions.push(getValue(this.fields.value, item));
844
+ })
845
+ }
846
+ selectedOptions.forEach((value: string) => {
847
+ if (value !== dropValue) {
848
+ const idx: number = listData.indexOf(this.getDataByValue(value));
849
+ const jsonIdx: number = jsonData.indexOf(this.getDataByValue(value));
850
+ const sIdx: number = sortedData.indexOf(this.getDataByValue(value));
851
+ if (idx > toIdx) {
852
+ toIdx++;
853
+ }
854
+ jsonData.splice(toIdx, 0, jsonData.splice(jsonIdx, 1)[0] as obj);
855
+ listData.splice(toIdx, 0, listData.splice(idx, 1)[0] as obj);
856
+ sortedData.splice(toSortIdx, 0, sortedData.splice(sIdx, 1)[0] as obj);
857
+ liColl.splice(toIdx, 0, liColl.splice(idx, 1)[0] as HTMLElement);
858
+ ul.insertBefore(this.getItems()[this.getIndexByValue(value)], ul.getElementsByClassName('e-placeholder')[0]);
859
+ }
860
+ });
861
+ }
862
+ (this.listData as dataType[]) = listData; (this.jsonData as dataType[]) = jsonData;
863
+ (this.sortedData as dataType[]) = sortedData; this.liCollections = liColl;
864
+ } else {
865
+ let li: Element; const fLiColl: HTMLElement[] = [].slice.call(this.liCollections);
866
+ let currIdx: number = args.currentIndex = this.getCurIdx(listObj, args.currentIndex); const ul: Element = listObj.ulElement;
867
+ listData = [].slice.call(listObj.listData); liColl = [].slice.call(listObj.liCollections);
868
+ jsonData = [].slice.call(listObj.jsonData); sortedData = [].slice.call(listObj.sortedData);
869
+ selectedOptions = (this.value && Array.prototype.indexOf.call(this.value, dropValue) > -1 && this.allowDragAll)
870
+ ? this.value : [dropValue];
871
+ if (!isNullOrUndefined(this.customDraggedItem)) {
872
+ selectedOptions = [];
873
+ this.customDraggedItem.forEach((item: object) => {
874
+ selectedOptions.push(getValue(this.fields.value, item));
875
+ })
876
+ }
877
+ const fListData: dataType[] = [].slice.call(this.listData); const fSortData: dataType[] = [].slice.call(this.sortedData);
878
+ selectedOptions.forEach((value: string, index: number) => {
879
+ droppedData = this.getDataByValue(value);
880
+ const srcIdx: number = (this.listData as dataType[]).indexOf(droppedData);
881
+ const jsonSrcIdx: number = (this.jsonData as dataType[]).indexOf(droppedData);
882
+ const sortIdx: number = (this.sortedData as dataType[]).indexOf(droppedData);
883
+ fListData.splice(srcIdx, 1); this.jsonData.splice(jsonSrcIdx, 1);
884
+ fSortData.splice(sortIdx, 1); (this.listData as dataType[]) = fListData; (this.sortedData as dataType[]) = fSortData;
885
+ const destIdx: number = value === dropValue ? args.currentIndex : currIdx;
886
+ listData.splice(destIdx, 0, droppedData); jsonData.splice(destIdx, 0, droppedData);
887
+ sortedData.splice(destIdx, 0, droppedData);
888
+ liColl.splice(destIdx, 0, fLiColl.splice(srcIdx, 1)[0]);
889
+ if (!value) {
890
+ const liCollElem: Element[] = this.getItems();
891
+ for (let i: number = 0; i < liCollElem.length; i++ ) {
892
+ if (liCollElem[i as number].getAttribute('data-value') === null && liCollElem[i as number].classList.contains('e-list-item')) {
893
+ li = liCollElem[i as number];
894
+ break;
895
+ }
896
+ }
897
+ } else {
898
+ li = this.getItems()[this.getIndexByValue(value)];
899
+ }
900
+ if (!li) { li = args.helper; }
901
+ this.removeSelected(this, value === dropValue ? [args.droppedElement] : [li]);
902
+ ul.insertBefore(li, ul.getElementsByClassName('e-placeholder')[0]);
903
+ currIdx++;
904
+ });
905
+ if (this.fields.groupBy) {
906
+ const sourceElem: HTMLElement = this.renderItems(this.listData as obj[], this.fields);
907
+ this.updateListItems(sourceElem, this.ulElement); this.setSelection();
908
+ }
909
+ if (listObj.sortOrder !== 'None' || this.selectionSettings.showCheckbox
910
+ !== listObj.selectionSettings.showCheckbox || listObj.fields.groupBy || listObj.itemTemplate || this.itemTemplate) {
911
+ const sortable: { placeHolderElement: Element } = getComponent(ul as HTMLElement, 'sortable');
912
+ const sourceElem: HTMLElement = listObj.renderItems(listData as obj[], listObj.fields);
913
+ listObj.updateListItems(sourceElem, ul as HTMLElement); this.setSelection();
914
+ if (sortable.placeHolderElement) {
915
+ ul.appendChild(sortable.placeHolderElement);
916
+ }
917
+ ul.appendChild(args.helper); listObj.setSelection();
918
+ }
919
+ this.liCollections = fLiColl; listObj.liCollections = liColl;
920
+ (listObj.jsonData as dataType[]) = extend([], [], jsonData, false) as dataType[];
921
+ (listObj.listData as dataType[]) = extend([], [], listData, false) as dataType[];
922
+ (listObj.sortedData as dataType[]) = extend([], [], sortedData, false) as dataType[];
923
+ if (this.listData.length === 0) {
924
+ this.l10nUpdate();
925
+ }
926
+ }
927
+ if (this === listObj) {
928
+ const sourceArgs1: Object = extend( sourceArgs, {currentData: listData});
929
+ dragArgs = extend(dragArgs, {source: sourceArgs1});
930
+ } else {
931
+ const dragArgs1: Object = extend(destArgs, {currentData: listData});
932
+ dragArgs = extend(dragArgs, { destination: dragArgs1 });
933
+ }
934
+ if (!isNullOrUndefined(this.customDraggedItem)) {
935
+ (dragArgs as DragEventArgs).items = this.customDraggedItem;
936
+ }
937
+ this.trigger('drop', dragArgs);
938
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
939
+ const liCollElem: NodeListOf<Element> = (dragArgs as any).elements;
940
+ if (liCollElem.length) {
941
+ for (let i: number = 0; i < liCollElem.length; i++) {
942
+ liCollElem[i as number].classList.remove('e-grabbed');
943
+ }
944
+ }
945
+ }
946
+
947
+ private updateListItems(sourceElem: HTMLElement, destElem: HTMLElement): void {
948
+ const i: number = 0;
949
+ destElem.innerHTML = '';
950
+ while (i < sourceElem.childNodes.length) {
951
+ destElem.appendChild(sourceElem.childNodes[i as number]);
952
+ }
953
+ }
954
+
955
+ private removeSelected(listObj: ListBox, elems: Element[]): void {
956
+ if (listObj.selectionSettings.showCheckbox) {
957
+ elems.forEach((ele: Element) => { ele.getElementsByClassName('e-frame')[0].classList.remove('e-check'); });
958
+ } else {
959
+ removeClass(elems, cssClass.selected);
960
+ }
961
+ }
962
+
963
+ private getCurIdx(listObj: ListBox, idx: number): number {
964
+ if (listObj.fields.groupBy) {
965
+ idx -= [].slice.call(listObj.ulElement.children).slice(0, idx)
966
+ .filter((ele: Element) => ele.classList.contains(cssClass.group)).length;
967
+ }
968
+ return idx;
969
+ }
970
+
971
+ private getComponent(li: Element): ListBox {
972
+ let listObj: ListBox;
973
+ const ele: HTMLElement = (this.element.tagName === 'EJS-LISTBOX' ? closest(li, '.e-listbox')
974
+ : closest(li, '.e-listbox-wrapper') && closest(li, '.e-listbox-wrapper').querySelector('.e-listbox')) as HTMLElement;
975
+ if (ele) {
976
+ listObj = getComponent(ele, this.getModuleName());
977
+ }
978
+ return listObj;
979
+ }
980
+
981
+ /**
982
+ * Sets the enabled state to DropDownBase.
983
+ *
984
+ * @returns {void}
985
+ */
986
+ protected setEnabled(): void {
987
+ this.element.setAttribute('aria-disabled', (this.enabled) ? 'false' : 'true');
988
+ }
989
+
990
+ protected listOption(
991
+ dataSource: obj[] | string[] | number[] | boolean[],
992
+ fields: FieldSettingsModel): FieldSettingsModel {
993
+ this.listCurrentOptions = super.listOption(dataSource, fields);
994
+ this.listCurrentOptions = extend({}, this.listCurrentOptions, { itemCreated: this.triggerBeforeItemRender.bind(this) }, true);
995
+ this.notify('listoption', { module: 'CheckBoxSelection' });
996
+ return this.listCurrentOptions;
997
+ }
998
+
999
+ private triggerBeforeItemRender(e: { item: Element, curData: obj }): void {
1000
+ e.item.setAttribute('tabindex', '-1');
1001
+ this.trigger('beforeItemRender', { element: e.item, item: e.curData });
1002
+ }
1003
+
1004
+ public requiredModules(): ModuleDeclaration[] {
1005
+ const modules: ModuleDeclaration[] = [];
1006
+ if (this.selectionSettings.showCheckbox) {
1007
+ modules.push({
1008
+ member: 'CheckBoxSelection',
1009
+ args: [this]
1010
+ });
1011
+ }
1012
+ return modules;
1013
+ }
1014
+
1015
+ /**
1016
+ * This method is used to enable or disable the items in the ListBox based on the items and enable argument.
1017
+ *
1018
+ * @param {string[]} items - Text items that needs to be enabled/disabled.
1019
+ * @param {boolean} enable - Set `true`/`false` to enable/disable the list items.
1020
+ * @param {boolean} isValue - Set `true` if `items` parameter is a array of unique values.
1021
+ * @returns {void}
1022
+ */
1023
+ public enableItems(items: string[], enable: boolean = true, isValue?: boolean): void {
1024
+ let li: HTMLElement;
1025
+ items.forEach((item: string) => {
1026
+ const text: string = item;
1027
+ li = this.findListElement(this.list, 'li', 'data-value', isValue ? text : this.getValueByText(text));
1028
+ if (!li) { return; }
1029
+ if (enable) {
1030
+ removeClass([li], cssClass.disabled);
1031
+ li.removeAttribute('aria-disabled');
1032
+ } else {
1033
+ addClass([li], cssClass.disabled);
1034
+ li.setAttribute('aria-disabled', 'true');
1035
+ }
1036
+ });
1037
+ }
1038
+
1039
+ /**
1040
+ * Based on the state parameter, specified list item will be selected/deselected.
1041
+ *
1042
+ * @param {string[]} items - Array of text value of the item.
1043
+ * @param {boolean} state - Set `true`/`false` to select/un select the list items.
1044
+ * @param {boolean} isValue - Set `true` if `items` parameter is a array of unique values.
1045
+ * @returns {void}
1046
+ */
1047
+ public selectItems(items: string[], state: boolean = true, isValue?: boolean): void {
1048
+ if (state && !this.selectionSettings.showCheckbox && this.selectionSettings.mode === 'Single') {
1049
+ this.getSelectedItems().forEach((li: Element) => {
1050
+ li.classList.remove('e-active');
1051
+ li.removeAttribute('aria-selected');
1052
+ removeClass([li], cssClass.selected);
1053
+ });
1054
+ }
1055
+ this.setSelection(items, state, !isValue);
1056
+ this.updateSelectedOptions();
1057
+ let selElems: Element[] = [];
1058
+ for (let i: number = 0; i < items.length; i++) {
1059
+ const liColl: NodeListOf<Element> = this.list.querySelectorAll('[aria-selected="true"]');
1060
+ for (let j: number = 0; j < liColl.length; j++) {
1061
+ if (items[i as number] === this.getFormattedValue(liColl[j as number].getAttribute('data-value')) as string) {
1062
+ selElems.push(liColl[j as number])
1063
+ }
1064
+ }
1065
+ }
1066
+ this.triggerChange(selElems, null);
1067
+ }
1068
+
1069
+ /**
1070
+ * Based on the state parameter, entire list item will be selected/deselected.
1071
+ *
1072
+ * @param {boolean} state - Set `true`/`false` to select/un select the entire list items.
1073
+ * @returns {void}
1074
+ */
1075
+ public selectAll(state: boolean = true): void {
1076
+ this.selectAllItems(state);
1077
+ }
1078
+
1079
+ /**
1080
+ * Adds a new item to the list. By default, new item appends to the list as the last item,
1081
+ * but you can insert based on the index parameter.
1082
+ *
1083
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
1084
+ * @param { number } itemIndex - Specifies the index to place the newly added item in the list.
1085
+ * @returns {void}.
1086
+ */
1087
+ public addItems(items: obj[] | obj, itemIndex?: number): void {
1088
+ super.addItem(items, itemIndex);
1089
+ }
1090
+ /**
1091
+ * Removes a item from the list. By default, removed the last item in the list,
1092
+ * but you can remove based on the index parameter.
1093
+ *
1094
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
1095
+ * @param { number } itemIndex - Specifies the index to remove the item from the list.
1096
+ * @returns {void}.
1097
+ */
1098
+ public removeItems(items?: obj[] | obj, itemIndex?: number): void {
1099
+ this.removeItem(items, itemIndex);
1100
+ }
1101
+ /**
1102
+ * Removes a item from the list. By default, removed the last item in the list,
1103
+ * but you can remove based on the index parameter.
1104
+ *
1105
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
1106
+ * @param { number } itemIndex - Specifies the index to remove the item from the list.
1107
+ * @returns {void}.
1108
+ */
1109
+ public removeItem(
1110
+ items?: { [key: string]: Object }[] | { [key: string]: Object } | string | boolean | number | string[] | boolean[] | number[],
1111
+ itemIndex?: number): void {
1112
+ const liCollections: HTMLElement[] = [];
1113
+ const liElement: HTMLElement[] | NodeListOf<HTMLLIElement> = this.list.querySelectorAll('.' + dropDownBaseClasses.li);
1114
+ if (items) {
1115
+ items = (items instanceof Array ? items : [items]) as { [key: string]: Object }[] | string[] | boolean[] | number[];
1116
+ const fields: FieldSettingsModel = this.fields; let dataValue: string; let objValue: string;
1117
+ const dupData: {[key: string]: Object }[] = []; let itemIdx: number;
1118
+ extend(dupData, [], this.jsonData as { [key: string]: Object }[]);
1119
+ const removeIdxes: number [] = []; const removeLiIdxes: number [] = [];
1120
+ for (let j: number = 0; j < items.length; j++) {
1121
+ if (items[j as number] instanceof Object) {
1122
+ dataValue = getValue(fields.value, items[j as number]);
1123
+ } else {
1124
+ dataValue = items[j as number].toString();
1125
+ }
1126
+ for (let i: number = 0, len: number = dupData.length; i < len; i++) {
1127
+ if (dupData[i as number] instanceof Object) {
1128
+ objValue = getValue(fields.value, dupData[i as number]);
1129
+ } else {
1130
+ objValue = dupData[i as number].toString();
1131
+ }
1132
+ if (objValue === dataValue) {
1133
+ itemIdx = this.getIndexByValue(dataValue);
1134
+ const idx: number = itemIdx === i ? itemIdx : i;
1135
+ liCollections.push(liElement[idx as number]);
1136
+ removeIdxes.push(idx);
1137
+ removeLiIdxes.push(idx);
1138
+ }
1139
+ }
1140
+ }
1141
+ for (let k: number = removeIdxes.length - 1; k >= 0; k--) {
1142
+ (this.listData as { [key: string]: Object }[]).splice(removeIdxes[k as number], 1);
1143
+ }
1144
+ for (let k: number = removeIdxes.length - 1; k >= 0; k--) {
1145
+ (this.jsonData as { [key: string]: Object }[]).splice(removeIdxes[k as number], 1);
1146
+ }
1147
+ for (let k: number = removeLiIdxes.length - 1; k >= 0; k--) {
1148
+ this.updateLiCollection(removeLiIdxes[k as number]);
1149
+ }
1150
+ } else {
1151
+ itemIndex = itemIndex ? itemIndex : 0;
1152
+ liCollections.push(liElement[itemIndex as number]);
1153
+ (this.listData as { [key: string]: Object }[]).splice(itemIndex, 1);
1154
+ (this.jsonData as { [key: string]: Object }[]).splice(itemIndex, 1);
1155
+ this.updateLiCollection(itemIndex);
1156
+ }
1157
+ for (let i: number = 0; i < liCollections.length; i++) {
1158
+ this.ulElement.removeChild(liCollections[i as number]);
1159
+ }
1160
+ if (this.listData.length === 0) {
1161
+ this.l10nUpdate();
1162
+ }
1163
+ this.value = [];
1164
+ this.updateToolBarState();
1165
+ }
1166
+ /**
1167
+ * Gets the array of data Object that matches the given array of values.
1168
+ *
1169
+ * @param { string[] | number[] | boolean[] } value - Specifies the array value of the list item.
1170
+ * @returns {object[]}.
1171
+ */
1172
+ public getDataByValues(value: string[] | number[] | boolean[] ): { [key: string]: Object }[] {
1173
+ const data: string | number | boolean | { [key: string]: Object }[] = [];
1174
+ for (let i: number = 0; i < value.length; i++) {
1175
+ data.push(this.getDataByValue(value[i as number]) as { [key: string]: Object });
1176
+ }
1177
+ return data;
1178
+ }
1179
+ /**
1180
+ * Moves the given value(s) / selected value(s) upwards.
1181
+ *
1182
+ * @param { string[] | number[] | boolean[] } value - Specifies the value(s).
1183
+ * @returns {void}
1184
+ */
1185
+ public moveUp(value?: string[] | number[] | boolean[]): void {
1186
+ const elem: Element[] = (value) ? this.getElemByValue(value) : this.getSelectedItems();
1187
+ this.moveUpDown(true, false, elem);
1188
+ }
1189
+ /**
1190
+ * Moves the given value(s) / selected value(s) downwards.
1191
+ *
1192
+ * @param { string[] | number[] | boolean[] } value - Specifies the value(s).
1193
+ * @returns {void}
1194
+ */
1195
+ public moveDown(value?: string[] | number[] | boolean[]): void {
1196
+ const elem: Element[] = (value) ? this.getElemByValue(value) : this.getSelectedItems();
1197
+ this.moveUpDown(false, false, elem);
1198
+ }
1199
+ /**
1200
+ * Moves the given value(s) / selected value(s) in Top of the list.
1201
+ *
1202
+ * @param { string[] | number[] | boolean[] } value - Specifies the value(s).
1203
+ * @returns {void}
1204
+ */
1205
+ public moveTop(value?: string[] | number[] | boolean[]): void {
1206
+ const elem: Element[] = (value) ? this.getElemByValue(value) : this.getSelectedItems();
1207
+ this.moveUpDown(null, false, elem, true);
1208
+ }
1209
+ /**
1210
+ * Moves the given value(s) / selected value(s) in bottom of the list.
1211
+ *
1212
+ * @param { string[] | number[] | boolean[] } value - Specifies the value(s).
1213
+ * @returns {void}
1214
+ */
1215
+ public moveBottom(value?: string[] | number[] | boolean[]): void {
1216
+ const elem: Element[] = (value) ? this.getElemByValue(value) : this.getSelectedItems();
1217
+ this.moveUpDown(true, false, elem, false, true);
1218
+ }
1219
+ /**
1220
+ * Moves the given value(s) / selected value(s) to the given / default scoped ListBox.
1221
+ *
1222
+ * @param { string[] | number[] | boolean[] } value - Specifies the value or array value of the list item.
1223
+ * @param {number} index - Specifies the index.
1224
+ * @param {string} targetId - Specifies the target id.
1225
+ * @returns {void}
1226
+ */
1227
+ public moveTo(value?: string[] | number[] | boolean[], index?: number, targetId?: string): void {
1228
+ const elem: Element[] = (value) ? this.getElemByValue(value) : this.getSelectedItems();
1229
+ const tlistbox: ListBox = (targetId) ? getComponent(targetId, ListBox) : this.getScopedListBox();
1230
+ this.moveData(this, tlistbox, false, elem, index);
1231
+ }
1232
+ /**
1233
+ * Moves all the values from one ListBox to the scoped ListBox.
1234
+ *
1235
+ * @param { string } targetId - Specifies the scoped ListBox ID.
1236
+ * @param { string } index - Specifies the index to where the items moved.
1237
+ * @returns {void}
1238
+ */
1239
+ public moveAllTo(targetId?: string, index?: number): void {
1240
+ if (this.listData.length > 0) {
1241
+ const tlistbox: ListBox = (targetId) ? getComponent(targetId, ListBox) : this.getScopedListBox();
1242
+ this.moveAllData(this, tlistbox, false, index);
1243
+ }
1244
+ }
1245
+ /* eslint-disable */
1246
+ /**
1247
+ * Gets the updated dataSource in ListBox.
1248
+ *
1249
+ * @returns {{ [key: string]: Object }[] | string[] | boolean[] | number[]} - Updated DataSource.
1250
+ */
1251
+ /* eslint-enable */
1252
+ public getDataList(): { [key: string]: Object }[] | string[] | boolean[] | number[] {
1253
+ return this.jsonData;
1254
+ }
1255
+ /* eslint-disable */
1256
+ /**
1257
+ * Returns the sorted Data in ListBox.
1258
+ *
1259
+ * @returns {{ [key: string]: Object }[] | string[] | boolean[] | number[]} - Sorted data
1260
+ */
1261
+ /* eslint-enable */
1262
+ public getSortedList(): { [key: string]: Object }[] | string[] | boolean[] | number[] {
1263
+ let sortData: dataType[]; let tempData: { [key: string]: Object }[] | string[] | boolean[] | number[];
1264
+ sortData = tempData = this.sortedData;
1265
+ if (this.fields.groupBy) {
1266
+ sortData = [];
1267
+ for (let i: number = 0; i < tempData.length; i++) {
1268
+ if ((tempData[i as number] as { [key: string]: Object }).isHeader) {
1269
+ continue;
1270
+ }
1271
+ sortData.push(tempData[i as number]);
1272
+ }
1273
+ }
1274
+ return sortData as { [key: string]: Object }[] | string[] | boolean[] | number[];
1275
+ }
1276
+ private getElemByValue(value: string[] | number[] | boolean[]): Element[] {
1277
+ const elem: Element[] = [];
1278
+ for (let i: number = 0; i < value.length; i++) {
1279
+ elem.push(this.ulElement.querySelector('[data-value ="' + value[i as number] + '"]'));
1280
+ }
1281
+ return elem;
1282
+ }
1283
+ private updateLiCollection(index: number): void {
1284
+ const tempLi: HTMLElement[] = [].slice.call(this.liCollections);
1285
+ tempLi.splice(index, 1);
1286
+ this.liCollections = tempLi;
1287
+ }
1288
+ private selectAllItems(state: boolean, event?: MouseEvent): void {
1289
+ [].slice.call(this.getItems()).forEach((li: Element) => {
1290
+ if (!li.classList.contains(cssClass.disabled)) {
1291
+ if (this.selectionSettings.showCheckbox) {
1292
+ const ele: Element = li.getElementsByClassName('e-check')[0];
1293
+ if ((!ele && state) || (ele && !state)) {
1294
+ this.notify('updatelist', { li: li, module: 'listbox' });
1295
+ if (this.maximumSelectionLength >= this.list.querySelectorAll('.e-list-item span.e-check').length) {
1296
+ this.checkMaxSelection();
1297
+ }
1298
+ }
1299
+ } else {
1300
+ if (state) {
1301
+ li.classList.add(cssClass.selected);
1302
+ } else {
1303
+ li.classList.remove(cssClass.selected);
1304
+ }
1305
+ }
1306
+ }
1307
+ });
1308
+ this.updateSelectedOptions();
1309
+ if (this.allowFiltering && this.selectionSettings.showCheckbox) {
1310
+ const liEle: HTMLCollectionOf<HTMLLIElement> = this.list.getElementsByTagName('li') as HTMLCollectionOf<HTMLLIElement>;
1311
+ let index: number = 0;
1312
+ if (state) {
1313
+ for (index = 0; index < liEle.length; index++) {
1314
+ const dataValue1: string = this.getFormattedValue(liEle[index as number].getAttribute('data-value')) as string;
1315
+ if (!(this.value as string[]).some((e: string) => e === dataValue1)) {
1316
+ (this.value as string[]).push(this.getFormattedValue(liEle[index as number].getAttribute('data-value')) as string);
1317
+ }
1318
+ }
1319
+ } else {
1320
+ for (index = 0; index < liEle.length; index++) {
1321
+ const dataValue2: string = this.getFormattedValue(liEle[index as number].getAttribute('data-value')) as string;
1322
+ this.value = (this.value as string[]).filter((e: string) => e !== dataValue2);
1323
+ }
1324
+ }
1325
+ if (document.querySelectorAll('ul').length < 2) {
1326
+ this.updateMainList();
1327
+ }
1328
+ }
1329
+ this.triggerChange(this.getSelectedItems(), event);
1330
+ }
1331
+
1332
+ private updateMainList(): void {
1333
+ const mainList: NodeListOf<Element> = this.mainList.querySelectorAll('.e-list-item');
1334
+ const ulList: NodeListOf<Element> = this.ulElement.querySelectorAll('.e-list-item');
1335
+ const mainCount: number = mainList.length; const ulEleCount: number = ulList.length;
1336
+ if (this.selectionSettings.showCheckbox || (document.querySelectorAll('ul').length > 1 || mainCount !== ulEleCount)) {
1337
+ let listindex: number = 0;
1338
+ let valueindex: number = 0;
1339
+ let count: number = 0;
1340
+ for (listindex; listindex < mainCount; ) {
1341
+ if (this.value) {
1342
+ for (valueindex; valueindex < this.value.length; valueindex++) {
1343
+ if (mainList[listindex as number].getAttribute('data-value') === this.value[valueindex as number]) {
1344
+ count++;
1345
+ }
1346
+ }
1347
+ }
1348
+ if (!count && this.selectionSettings.showCheckbox) {
1349
+ mainList[listindex as number].getElementsByClassName('e-frame')[0].classList.remove('e-check');
1350
+ }
1351
+ if (document.querySelectorAll('ul').length > 1 && count && mainCount !== ulEleCount) {
1352
+ this.mainList.removeChild(this.mainList.getElementsByTagName('li')[listindex as number]);
1353
+ listindex = 0;
1354
+ } else {
1355
+ listindex++;
1356
+ }
1357
+ count = 0;
1358
+ valueindex = 0;
1359
+ }
1360
+ }
1361
+ }
1362
+
1363
+ private wireEvents(): void {
1364
+ const form: Element = closest(this.element, 'form');
1365
+ const wrapper: Element = this.element.tagName === 'EJS-LISTBOX' ? this.element : this.list;
1366
+ EventHandler.add(this.list, 'click', this.clickHandler, this);
1367
+ EventHandler.add(wrapper, 'keydown', this.keyDownHandler, this);
1368
+ EventHandler.add(wrapper, 'focusout', this.focusOutHandler, this);
1369
+ this.wireToolbarEvent();
1370
+ if (this.selectionSettings.showCheckbox) {
1371
+ EventHandler.remove(document, 'mousedown', this.checkBoxSelectionModule.onDocumentClick);
1372
+ }
1373
+ if (this.fields.groupBy || this.element.querySelector('select>optgroup')) {
1374
+ EventHandler.remove(this.list, 'scroll', this.setFloatingHeader);
1375
+ }
1376
+ if (form) {
1377
+ EventHandler.add(form, 'reset', this.formResetHandler, this);
1378
+ }
1379
+ }
1380
+
1381
+ private wireToolbarEvent(): void {
1382
+ if (this.toolbarSettings.items.length) {
1383
+ EventHandler.add(this.getToolElem(), 'click', this.toolbarClickHandler, this);
1384
+ }
1385
+ }
1386
+
1387
+ private unwireEvents(): void {
1388
+ const form: Element = closest(this.element, 'form');
1389
+ const wrapper: Element = this.element.tagName === 'EJS-LISTBOX' ? this.element : this.list;
1390
+ EventHandler.remove(this.list, 'click', this.clickHandler);
1391
+ EventHandler.remove(wrapper, 'keydown', this.keyDownHandler);
1392
+ EventHandler.remove(wrapper, 'focusout', this.focusOutHandler);
1393
+ if (this.allowFiltering && this.clearFilterIconElem) {
1394
+ EventHandler.remove(this.clearFilterIconElem, 'click', this.clearText);
1395
+ }
1396
+ if (this.toolbarSettings.items.length) {
1397
+ EventHandler.remove(this.getToolElem(), 'click', this.toolbarClickHandler);
1398
+ }
1399
+ if (form) {
1400
+ EventHandler.remove(form, 'reset', this.formResetHandler);
1401
+ }
1402
+ }
1403
+
1404
+ private clickHandler(e: MouseEvent): void {
1405
+ this.selectHandler(e);
1406
+ }
1407
+
1408
+ private checkSelectAll(): void {
1409
+ let searchCount: number = 0;
1410
+ const liItems: NodeListOf<Element> = this.list.querySelectorAll('li.' + dropDownBaseClasses.li);
1411
+ for (let i: number = 0; i < liItems.length; i++) {
1412
+ if (!liItems[i as number].classList.contains('e-disabled')) {
1413
+ searchCount++;
1414
+ }
1415
+ }
1416
+ const len: number = this.getSelectedItems().length;
1417
+ if (this.showSelectAll && searchCount) {
1418
+ this.notify('checkSelectAll', { module: 'CheckBoxSelection',
1419
+ value: (searchCount === len) ? 'check' : (len === 0) ? 'uncheck' : 'indeterminate'});
1420
+ }
1421
+ }
1422
+
1423
+ protected getQuery(query: Query): Query {
1424
+ let filterQuery: Query = query ? query.clone() : this.query ? this.query.clone() : new Query();
1425
+ if (this.allowFiltering) {
1426
+ const filterType: string = this.inputString === '' ? 'contains' : this.filterType;
1427
+ let dataType: string = <string>this.typeOfData(this.dataSource as { [key: string]: Object; }[]).typeof;
1428
+ if (dataType === null) {
1429
+ dataType = <string>this.typeOfData(this.jsonData as { [key: string]: Object; }[]).typeof;
1430
+ }
1431
+ if (!(this.dataSource instanceof DataManager) && dataType === 'string' || dataType === 'number') {
1432
+ filterQuery.where('', filterType, this.inputString, this.ignoreCase, this.ignoreAccent);
1433
+ } else {
1434
+ const fields: string = (this.fields.text) ? this.fields.text : '';
1435
+ filterQuery.where(fields, filterType, this.inputString, this.ignoreCase, this.ignoreAccent);
1436
+ }
1437
+ } else {
1438
+ filterQuery = query ? query : this.query ? this.query : new Query();
1439
+ }
1440
+ return filterQuery;
1441
+ }
1442
+
1443
+ private setFiltering(): InputObject | void {
1444
+ let filterInputObj: InputObject;
1445
+ if (this.initLoad || isNullOrUndefined(this.filterParent)) {
1446
+ this.filterParent = this.createElement('span', {
1447
+ className: listBoxClasses.filterParent
1448
+ });
1449
+ this.filterInput = <HTMLInputElement>this.createElement('input', {
1450
+ attrs: { type: 'text' },
1451
+ className: listBoxClasses.filterInput
1452
+ });
1453
+ this.element.parentNode.insertBefore(this.filterInput, this.element);
1454
+ filterInputObj = Input.createInput(
1455
+ {
1456
+ element: this.filterInput,
1457
+ buttons: [listBoxClasses.filterBarClearIcon],
1458
+ properties: { placeholder: this.filterBarPlaceholder }
1459
+ },
1460
+ this.createElement
1461
+ );
1462
+ append([filterInputObj.container], this.filterParent);
1463
+ prepend([this.filterParent], this.list);
1464
+ attributes(this.filterInput, {
1465
+ 'aria-disabled': 'false',
1466
+ 'aria-label': 'search list item',
1467
+ 'autocomplete': 'off',
1468
+ 'autocorrect': 'off',
1469
+ 'autocapitalize': 'off',
1470
+ 'spellcheck': 'false'
1471
+ });
1472
+ if (this.height.toString().indexOf('%') < 0) {
1473
+ addClass([this.list], 'e-filter-list');
1474
+ }
1475
+ this.inputString = this.filterInput.value;
1476
+ this.filterWireEvents();
1477
+ return filterInputObj;
1478
+ }
1479
+ }
1480
+
1481
+ private filterWireEvents(filterElem?: Element): void {
1482
+ if (filterElem) {
1483
+ this.filterInput = filterElem.querySelector('.e-input-filter');
1484
+ }
1485
+ this.clearFilterIconElem = this.filterInput.parentElement.querySelector('.' + listBoxClasses.clearIcon);
1486
+ if (this.clearFilterIconElem) {
1487
+ EventHandler.add(this.clearFilterIconElem, 'click', this.clearText, this);
1488
+ if (!filterElem) {
1489
+ (this.clearFilterIconElem as HTMLElement).style.visibility = 'hidden';
1490
+ }
1491
+ }
1492
+ EventHandler.add(this.filterInput, 'input', this.onInput, this);
1493
+ EventHandler.add(this.filterInput, 'keyup', this.KeyUp, this);
1494
+ EventHandler.add(this.filterInput, 'keydown', this.onKeyDown, this);
1495
+ }
1496
+
1497
+ private selectHandler(e: MouseEvent | { target: EventTarget, ctrlKey?: boolean, shiftKey?: boolean,
1498
+ metaKey?: boolean}, isKey?: boolean): void {
1499
+ let isSelect: boolean = true;
1500
+ let currSelIdx: number;
1501
+ const li: Element = closest(e.target as Element, '.' + 'e-list-item');
1502
+ let selectedLi: Element[] = [li];
1503
+ if (li && li.parentElement) {
1504
+ currSelIdx = [].slice.call(li.parentElement.children).indexOf(li);
1505
+ if (!this.selectionSettings.showCheckbox) {
1506
+ if ((e.ctrlKey || e.metaKey || Browser.isDevice) && this.isSelected(li)) {
1507
+ li.classList.remove(cssClass.selected);
1508
+ li.removeAttribute('aria-selected');
1509
+ isSelect = false;
1510
+ } else if (!(this.selectionSettings.mode === 'Multiple' && (e.ctrlKey || e.metaKey || Browser.isDevice))) {
1511
+ this.getSelectedItems().forEach((ele: Element) => {
1512
+ ele.removeAttribute('aria-selected');
1513
+ });
1514
+ removeClass(this.getSelectedItems(), cssClass.selected);
1515
+ }
1516
+ } else {
1517
+ isSelect = !li.getElementsByClassName('e-frame')[0].classList.contains('e-check');
1518
+ }
1519
+ if (e.shiftKey && !this.selectionSettings.showCheckbox && this.selectionSettings.mode !== 'Single') {
1520
+ selectedLi = [].slice.call(li.parentElement.children)
1521
+ .slice(Math.min(currSelIdx, this.prevSelIdx), Math.max(currSelIdx, this.prevSelIdx) + 1)
1522
+ .filter((ele: Element) => { return ele.classList.contains('e-list-item'); });
1523
+ } else {
1524
+ this.prevSelIdx = [].slice.call(li.parentElement.children).indexOf(li);
1525
+ }
1526
+ if (isSelect) {
1527
+ if (!this.selectionSettings.showCheckbox) {
1528
+ addClass(selectedLi, cssClass.selected);
1529
+ }
1530
+ selectedLi.forEach((ele: Element) => {
1531
+ ele.setAttribute('aria-selected', 'true');
1532
+ });
1533
+ this.list.setAttribute('aria-activedescendant', li.id);
1534
+ } else {
1535
+ selectedLi.forEach((ele: Element) => {
1536
+ ele.setAttribute('aria-selected', 'false');
1537
+ });
1538
+ }
1539
+ if (!isKey && (this.maximumSelectionLength > (this.value && this.value.length) || !isSelect) &&
1540
+ (this.maximumSelectionLength >= (this.value && this.value.length) || !isSelect) &&
1541
+ !(this.maximumSelectionLength < (this.value && this.value.length))) {
1542
+ this.notify('updatelist', { li: li, e: e, module: 'listbox' });
1543
+ }
1544
+ if (this.allowFiltering && !isKey) {
1545
+ const liDataValue: string = this.getFormattedValue(li.getAttribute('data-value')) as string;
1546
+ if (!isSelect) {
1547
+ this.value = (this.value as string[]).filter((value1: string) =>
1548
+ value1 !== liDataValue);
1549
+ } else {
1550
+ const values: string[] = [];
1551
+ extend(values, this.value); values.push(liDataValue);
1552
+ this.value = values;
1553
+ }
1554
+ if (document.querySelectorAll('ul').length < 2) {
1555
+ this.updateMainList();
1556
+ }
1557
+ }
1558
+ this.updateSelectedOptions();
1559
+ this.triggerChange(this.getSelectedItems(), e as MouseEvent);
1560
+ if (this.list) {
1561
+ this.checkMaxSelection();
1562
+ }
1563
+ }
1564
+ }
1565
+
1566
+ private triggerChange(selectedLis: Element[], event: MouseEvent): void {
1567
+ this.trigger('change', { elements: selectedLis, items: this.getDataByElements(selectedLis), value: this.value, event: event });
1568
+ }
1569
+
1570
+ private getDataByElems(elems: Element[]): Object[] {
1571
+ const data: Object[] = [];
1572
+ for (let i: number = 0, len: number = elems.length; i < len; i++) {
1573
+ data.push(this.getDataByValue(this.getFormattedValue(elems[i as number].getAttribute('data-value'))));
1574
+ }
1575
+ return data;
1576
+ }
1577
+ private getDataByElements(elems: Element[]): Object[] {
1578
+
1579
+ const data: Object[] = []; let value: string | number | boolean; let sIdx: number = 0;
1580
+ if (!isNullOrUndefined(this.listData)) {
1581
+ const type: string = this.typeOfData(this.listData).typeof as string;
1582
+ if (type === 'string' || type === 'number' || type === 'boolean') {
1583
+ for (const item of this.listData) {
1584
+ for (let i: number = sIdx, len: number = elems.length; i < len; i++) {
1585
+ value = this.getFormattedValue((elems[i as number] as Element).getAttribute('data-value'));
1586
+ if (!isNullOrUndefined(item) && item === value as Object) {
1587
+ sIdx = i; data.push(item); break;
1588
+ }
1589
+ }
1590
+ if (elems.length === data.length) {
1591
+ break;
1592
+ }
1593
+ }
1594
+ } else {
1595
+ for (const item of this.listData) {
1596
+ for (let i: number = sIdx, len: number = elems.length; i < len; i++) {
1597
+ value = this.getFormattedValue((elems[i as number] as Element).getAttribute('data-value'));
1598
+ if (!isNullOrUndefined(item) && getValue((this.fields.value ? this.fields.value : 'value'), item) === value) {
1599
+ sIdx = i; data.push(item); break;
1600
+ }
1601
+ }
1602
+ if (elems.length === data.length) {
1603
+ break;
1604
+ }
1605
+ }
1606
+ }
1607
+ return data;
1608
+ }
1609
+ return null;
1610
+ }
1611
+ private checkMaxSelection(): InputObject | void {
1612
+ const limit: number = this.list.querySelectorAll('.e-list-item span.e-check').length;
1613
+ if (this.selectionSettings.showCheckbox) {
1614
+ let index: number = 0;
1615
+ const liCollElem: HTMLCollectionOf<HTMLLIElement> = this.list.getElementsByClassName('e-list-item') as HTMLCollectionOf<HTMLLIElement>;
1616
+ for (index; index < liCollElem.length; index++) {
1617
+ if (!liCollElem[index as number].querySelector('.e-frame.e-check')) {
1618
+ if (limit === this.maximumSelectionLength) {
1619
+ liCollElem[index as number].classList.add('e-disable');
1620
+ } else if (liCollElem[index as number].classList.contains('e-disable')) {
1621
+ liCollElem[index as number].classList.remove('e-disable');
1622
+ }
1623
+ }
1624
+ }
1625
+ }
1626
+ }
1627
+
1628
+ private toolbarClickHandler(e: MouseEvent): void {
1629
+ const btn: Element = closest(e.target as Element, 'button');
1630
+ if (btn) {
1631
+ this.toolbarAction = btn.getAttribute('data-value');
1632
+ if ((btn as HTMLButtonElement).disabled) {
1633
+ return;
1634
+ }
1635
+ switch (this.toolbarAction) {
1636
+ case 'moveUp':
1637
+ this.moveUpDown(true);
1638
+ break;
1639
+ case 'moveDown':
1640
+ this.moveUpDown();
1641
+ break;
1642
+ case 'moveTo':
1643
+ this.moveItemTo();
1644
+ break;
1645
+ case 'moveFrom':
1646
+ this.moveItemFrom();
1647
+ break;
1648
+ case 'moveAllTo':
1649
+ this.moveAllItemTo();
1650
+ break;
1651
+ case 'moveAllFrom':
1652
+ this.moveAllItemFrom();
1653
+ break;
1654
+ default:
1655
+ this.trigger('actionBegin', { cancel: false, items: this.getDataByElems(this.getSelectedItems()),
1656
+ eventName: this.toolbarAction });
1657
+ break;
1658
+ }
1659
+ }
1660
+ }
1661
+
1662
+ private moveUpDown(isUp?: boolean, isKey?: boolean, value?: Element[], isTop?: boolean, isBottom?: boolean): void {
1663
+ let elems: Element[] = this.getSelectedItems();
1664
+ if (value) {
1665
+ elems = value;
1666
+ }
1667
+ if (((isUp && this.isSelected(this.ulElement.firstElementChild))
1668
+ || (!isUp && this.isSelected(this.ulElement.lastElementChild))) && !value ) {
1669
+ return;
1670
+ }
1671
+ const tempItems: Object[] = this.getDataByElems(elems);
1672
+ const localDataArgs: { [key: string]: Object } = { cancel: false, items: tempItems, eventName: this.toolbarAction };
1673
+ this.trigger('actionBegin', localDataArgs);
1674
+ if (localDataArgs.cancel) {
1675
+ return;
1676
+ }
1677
+ (isUp ? elems : elems.reverse()).forEach((ele: Element) => {
1678
+ const jsonToIdx: number = Array.prototype.indexOf.call(this.ulElement.querySelectorAll('.e-list-item'), ele);
1679
+ const idx: number = Array.prototype.indexOf.call(this.ulElement.children, ele);
1680
+ if (isTop) {
1681
+ moveTo(this.ulElement, this.ulElement, [idx], 0);
1682
+ this.changeData(idx, 0 , jsonToIdx, ele);
1683
+ }
1684
+ else if(isBottom) {
1685
+ moveTo(this.ulElement, this.ulElement, [idx], this.ulElement.querySelectorAll('.e-list-item').length);
1686
+ this.changeData(idx, this.ulElement.querySelectorAll('.e-list-item').length, jsonToIdx, ele);
1687
+ }
1688
+ else {
1689
+ moveTo(this.ulElement, this.ulElement, [idx], isUp ? idx - 1 : idx + 2);
1690
+ this.changeData(idx, isUp ? idx - 1 : idx + 1, isUp ? jsonToIdx - 1 : jsonToIdx + 1, ele);
1691
+ }
1692
+ });
1693
+ this.trigger('actionComplete', { items: tempItems, eventName: this.toolbarAction });
1694
+ (elems[0] as HTMLElement).focus();
1695
+ if (!isKey && this.toolbarSettings.items.length) {
1696
+ (this.getToolElem().querySelector('[data-value=' + (isUp ? 'moveUp' : 'moveDown') + ']') as HTMLElement).focus();
1697
+ }
1698
+ this.updateToolBarState();
1699
+ }
1700
+
1701
+ private moveItemTo(): void {
1702
+ this.moveData(this, this.getScopedListBox());
1703
+ }
1704
+
1705
+ private moveItemFrom(): void {
1706
+ this.moveData(this.getScopedListBox(), this);
1707
+ }
1708
+
1709
+ /**
1710
+ * Called internally if any of the property value changed.
1711
+ *
1712
+ * @param {ListBox} fListBox - Specifies the from listbox.
1713
+ * @param {ListBox} tListBox - Specifies the to listbox.
1714
+ * @param {boolean} isKey - Specifies the key.
1715
+ * @param {Element[]} value - Specifies the value.
1716
+ * @param {number} index - Specifies the index.
1717
+ * @returns {void}
1718
+ * @private
1719
+ */
1720
+ private moveData(fListBox: ListBox, tListBox: ListBox, isKey?: boolean, value?: Element[], index?: number): void {
1721
+ const idx: number[] = []; const dataIdx: number[] = []; const jsonIdx: number[] = []; const sortIdx: number[] = [];
1722
+ const listData: dataType[] = [].slice.call(fListBox.listData); const tListData: dataType[] = [].slice.call(tListBox.listData);
1723
+ const sortData: dataType[] = [].slice.call(fListBox.sortedData); let tSortData: dataType[] = [].slice.call(tListBox.sortedData);
1724
+ const fliCollections: HTMLElement[] = [].slice.call(fListBox.liCollections); const dataLiIdx: number[] = [];
1725
+ const tliCollections: HTMLElement[] = [].slice.call(tListBox.liCollections);
1726
+ const tempItems: dataType[] = [];
1727
+ const data: dataType[] = []; let elems: Element[] = fListBox.getSelectedItems();
1728
+ if (value) {
1729
+ elems = value;
1730
+ }
1731
+ const isRefresh: boolean | string | Function = tListBox.sortOrder !== 'None' || (tListBox.selectionSettings.showCheckbox !==
1732
+ fListBox.selectionSettings.showCheckbox) || tListBox.fields.groupBy || tListBox.itemTemplate || fListBox.itemTemplate;
1733
+ fListBox.value = [];
1734
+ if (elems.length) {
1735
+ this.removeSelected(fListBox, elems);
1736
+ elems.forEach((ele: Element) => {
1737
+ idx.push(Array.prototype.indexOf.call(fListBox.ulElement.children, ele)); // update sortable elem
1738
+ // To update lb view data
1739
+ dataLiIdx.push(Array.prototype.indexOf.call(fListBox.ulElement.querySelectorAll('.e-list-item'), ele));
1740
+ // To update lb listdata data
1741
+ dataIdx.push(Array.prototype.indexOf.call(fListBox.listData, fListBox.getDataByElems([ele])[0]));
1742
+ // To update lb sorted data
1743
+ sortIdx.push(Array.prototype.indexOf.call(fListBox.sortedData, fListBox.getDataByElems([ele])[0]));
1744
+ // To update lb original data
1745
+ jsonIdx.push(Array.prototype.indexOf.call(fListBox.jsonData, fListBox.getDataByElems([ele])[0]));
1746
+ });
1747
+ if (this.sortOrder !== 'None') {
1748
+ sortIdx.forEach((i: number) => {
1749
+ tempItems.push(fListBox.sortedData[i as number]);
1750
+ });
1751
+ } else {
1752
+ jsonIdx.forEach((i: number) => {
1753
+ tempItems.push(fListBox.jsonData[i as number]);
1754
+ });
1755
+ }
1756
+ const localDataArgs: { [key: string]: Object } = { cancel: false, items: tempItems, eventName: this.toolbarAction };
1757
+ fListBox.trigger('actionBegin', localDataArgs);
1758
+ if (localDataArgs.cancel) {
1759
+ return;
1760
+ }
1761
+ const rLiCollection: HTMLElement[] = [];
1762
+ dataLiIdx.sort((n1: number, n2: number) => n1 - n2).reverse().forEach((i: number) => {
1763
+ rLiCollection.push(fliCollections.splice(i, 1)[0]);
1764
+ });
1765
+ fListBox.liCollections = fliCollections;
1766
+ if (index) {
1767
+ const toColl: HTMLElement[] = tliCollections.splice(0, index);
1768
+ tListBox.liCollections = toColl.concat(rLiCollection.reverse()).concat(tliCollections);
1769
+ } else {
1770
+ tListBox.liCollections = tliCollections.concat(rLiCollection.reverse());
1771
+ }
1772
+ if (tListBox.listData.length === 0) {
1773
+ const noRecElem: Element = tListBox.ulElement.childNodes[0] as Element;
1774
+ if (noRecElem) {
1775
+ tListBox.ulElement.removeChild(noRecElem);
1776
+ }
1777
+ }
1778
+ dataIdx.sort((n1: number, n2: number) => n2 - n1).forEach((i: number) => {
1779
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
1780
+ listData.splice(i, 1)[0];
1781
+ });
1782
+ sortIdx.sort((n1: number, n2: number) => n2 - n1).forEach((i: number) => {
1783
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
1784
+ sortData.splice(i, 1)[0];
1785
+ });
1786
+ jsonIdx.slice().reverse().forEach((i: number) => {
1787
+ data.push(fListBox.jsonData.splice(i, 1)[0]);
1788
+ });
1789
+ if (isRefresh) {
1790
+ if (fListBox.fields.groupBy) {
1791
+ const sourceElem: HTMLElement = fListBox.renderItems(listData as obj[], fListBox.fields);
1792
+ fListBox.updateListItems(sourceElem, fListBox.ulElement);
1793
+ } else {
1794
+ elems.forEach((ele: Element) => { detach(ele); });
1795
+ }
1796
+ } else {
1797
+ moveTo(fListBox.ulElement, tListBox.ulElement, idx, index);
1798
+ fListBox.trigger('actionComplete', { items: tempItems, eventName: this.toolbarAction });
1799
+ }
1800
+ if (tListBox.mainList.childElementCount !== tListBox.jsonData.length) {
1801
+ tListBox.mainList = tListBox.ulElement;
1802
+ }
1803
+ fListBox.updateMainList();
1804
+ const tJsonData: dataType[] = [].slice.call(tListBox.jsonData);
1805
+ tSortData = [].slice.call(tListBox.sortedData);
1806
+ this.selectNextList(elems, dataLiIdx, dataIdx, fListBox);
1807
+ if (isKey) { this.list.focus(); }
1808
+ (fListBox.listData as dataType[]) = listData;
1809
+ (fListBox.sortedData as dataType[]) = sortData;
1810
+ index = (index) ? index : tListData.length;
1811
+ for (let i: number = tempItems.length - 1; i >= 0; i--) {
1812
+ tListData.splice(index, 0, tempItems[i as number]);
1813
+ tJsonData.splice(index, 0, tempItems[i as number]);
1814
+ tSortData.splice(index, 0, tempItems[i as number]);
1815
+ }
1816
+ (tListBox.listData as dataType[]) = tListData;
1817
+ tListBox.jsonData = tJsonData as {[key: string]: object}[];
1818
+ tListBox.sortedData = tSortData as {[key: string]: object}[];
1819
+ if (isRefresh) {
1820
+ const sourceElem: HTMLElement = tListBox.renderItems(tListData as obj[], tListBox.fields);
1821
+ tListBox.updateListItems(sourceElem, tListBox.ulElement);
1822
+ tListBox.setSelection();
1823
+ fListBox.trigger('actionComplete', { items: tempItems, eventName: this.toolbarAction });
1824
+ }
1825
+ fListBox.updateSelectedOptions();
1826
+ if (fListBox.listData.length === 0) {
1827
+ fListBox.l10nUpdate();
1828
+ }
1829
+ }
1830
+ if (fListBox.value.length === 1 && fListBox.getSelectedItems().length) {
1831
+ fListBox.value[0] = fListBox.getFormattedValue(fListBox.getSelectedItems()[0].getAttribute('data-value'));
1832
+ }
1833
+ }
1834
+
1835
+ private selectNextList(elems: Element[], dataLiIdx: number[], dataIdx: number[], inst: ListBox): void {
1836
+ const childCnt: number = inst.ulElement.querySelectorAll('.e-list-item').length;
1837
+ let ele: Element; let liIdx: number;
1838
+ let validIdx: number = -1;
1839
+ if (elems.length === 1 && childCnt && !inst.selectionSettings.showCheckbox) {
1840
+ liIdx = childCnt <= dataLiIdx[0] ? childCnt - 1 : dataLiIdx[0];
1841
+ ele = inst.ulElement.querySelectorAll('.e-list-item')[liIdx as number];
1842
+ validIdx = inst.getValidIndex(ele, liIdx, childCnt === dataIdx[0] ? 38 : 40);
1843
+ if (validIdx > -1) {
1844
+ (inst.ulElement.querySelectorAll('.e-list-item')[validIdx as number].classList.add(cssClass.selected));
1845
+ }
1846
+ }
1847
+ }
1848
+
1849
+ private moveAllItemTo(): void {
1850
+ this.moveAllData(this, this.getScopedListBox());
1851
+ }
1852
+
1853
+ private moveAllItemFrom(): void {
1854
+ this.moveAllData(this.getScopedListBox(), this);
1855
+ }
1856
+
1857
+ private moveAllData(fListBox: ListBox, tListBox: ListBox, isKey?: boolean, index?: number): void {
1858
+ type sortedType = dataType | { isHeader: boolean };
1859
+ let listData: dataType[] = [].slice.call(tListBox.listData);
1860
+ const jsonData: {[key: string]: object}[] = [].slice.call(tListBox.jsonData);
1861
+ const isRefresh: boolean | string | Function = tListBox.sortOrder !== 'None' || (tListBox.selectionSettings.showCheckbox !==
1862
+ fListBox.selectionSettings.showCheckbox) || tListBox.fields.groupBy || tListBox.itemTemplate || fListBox.itemTemplate;
1863
+ this.removeSelected(fListBox, fListBox.getSelectedItems());
1864
+ const tempItems: Object[] = [].slice.call(fListBox.listData);
1865
+ const localDataArgs: { [key: string]: Object } = { cancel: false, items: tempItems, eventName: this.toolbarAction };
1866
+ fListBox.trigger('actionBegin', localDataArgs);
1867
+ if (localDataArgs.cancel) {
1868
+ return;
1869
+ }
1870
+ if (tListBox.listData.length === 0) {
1871
+ const noRecElem: Element = tListBox.ulElement.childNodes[0] as Element;
1872
+ if (noRecElem) {
1873
+ tListBox.ulElement.removeChild(noRecElem);
1874
+ }
1875
+ }
1876
+ if (isRefresh) {
1877
+ const noRecElem: Element = fListBox.ulElement.childNodes[0] as Element;
1878
+ if (noRecElem) {
1879
+ fListBox.ulElement.removeChild(noRecElem);
1880
+ }
1881
+ }
1882
+ moveTo(
1883
+ fListBox.ulElement, tListBox.ulElement,
1884
+ // eslint-disable-next-line prefer-spread
1885
+ Array.apply(null, { length: fListBox.ulElement.childElementCount }).map(Number.call, Number), index);
1886
+ this.trigger('actionComplete', { items: tempItems, eventName: this.toolbarAction });
1887
+ if (isKey) { this.list.focus(); }
1888
+ index = (index) ? index : listData.length;
1889
+ for (let i: number = 0; i < fListBox.listData.length; i++) {
1890
+ listData.splice(index + i, 0, fListBox.listData[i as number]);
1891
+ }
1892
+ for (let i: number = 0; i < fListBox.jsonData.length; i++) {
1893
+ jsonData.splice(index + i, 0, fListBox.jsonData[i as number] as {[key: string]: object});
1894
+ }
1895
+ const fliCollections: HTMLElement[] = [].slice.call(fListBox.liCollections);
1896
+ const tliCollections: HTMLElement[] = [].slice.call(tListBox.liCollections);
1897
+ fListBox.liCollections = [];
1898
+ if (index) {
1899
+ const toColl: HTMLElement[] = tliCollections.splice(0, index);
1900
+ tListBox.liCollections = toColl.concat(fliCollections).concat(tliCollections);
1901
+ } else {
1902
+ tListBox.liCollections = tliCollections.concat(fliCollections);
1903
+ }
1904
+ fListBox.value = [];
1905
+ (listData as sortedType[]) = (listData as sortedType[])
1906
+ .filter((data: sortedType) => (data as { isHeader: boolean }).isHeader !== true);
1907
+ const sortedData: dataType[] = listData.filter(function(val: dataType): dataType {
1908
+ return (tListBox.jsonData as dataType[]).indexOf(val) === -1;
1909
+ });
1910
+ for (let i: number = 0; i < sortedData.length; i++) {
1911
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1912
+ tListBox.jsonData.splice(index + i, 0, sortedData[i as number] as any);
1913
+ }
1914
+ (tListBox.listData as dataType[]) = listData;
1915
+ if (fListBox.listData.length === fListBox.jsonData.length) {
1916
+ fListBox.listData = fListBox.sortedData = fListBox.jsonData = [];
1917
+ } else if (fListBox.allowFiltering) {
1918
+ for (let i: number = 0; i < fListBox.listData.length; i++) {
1919
+ for (let j: number = 0; j < fListBox.jsonData.length; j++) {
1920
+ if (fListBox.listData[i as number] === fListBox.jsonData[j as number]) {
1921
+ fListBox.jsonData.splice(j, 1);
1922
+ }
1923
+ }
1924
+ }
1925
+ fListBox.listData = fListBox.sortedData = [];
1926
+ }
1927
+ if (isRefresh) {
1928
+ const sourceElem: HTMLElement = tListBox.renderItems(listData as obj[], tListBox.fields);
1929
+ tListBox.updateListItems(sourceElem, tListBox.ulElement);
1930
+ this.trigger('actionComplete', { items: tempItems, eventName: this.toolbarAction });
1931
+ } else {
1932
+ (tListBox.sortedData as dataType[]) = listData;
1933
+ }
1934
+ fListBox.updateSelectedOptions();
1935
+ if (fListBox.listData.length === 0) {
1936
+ fListBox.l10nUpdate();
1937
+ }
1938
+ }
1939
+
1940
+ private changeData(fromIdx: number, toIdx: number, jsonToIdx: number, ele: Element): void {
1941
+ const listData: obj[] = [].slice.call(this.listData);
1942
+ const jsonData: obj[] = [].slice.call(this.jsonData);
1943
+ const sortData: obj[] = [].slice.call(this.sortedData);
1944
+ const jsonIdx: number = Array.prototype.indexOf.call(this.jsonData, this.getDataByElems([ele])[0]);
1945
+ const sortIdx: number = Array.prototype.indexOf.call(this.sortedData, this.getDataByElems([ele])[0]);
1946
+ const liColl: HTMLElement[] = [].slice.call(this.liCollections);
1947
+ listData.splice(toIdx, 0, listData.splice(fromIdx, 1)[0] as obj);
1948
+ jsonData.splice(jsonToIdx, 0, jsonData.splice(jsonIdx, 1)[0] as obj);
1949
+ sortData.splice(toIdx, 0, sortData.splice(sortIdx, 1)[0] as obj);
1950
+ liColl.splice(toIdx, 0, liColl.splice(fromIdx, 1)[0] as HTMLElement);
1951
+ this.listData = listData;
1952
+ this.jsonData = jsonData;
1953
+ this.liCollections = liColl;
1954
+ this.sortedData = sortData;
1955
+ }
1956
+
1957
+ private getSelectedItems(): Element[] {
1958
+ let ele: Element[] = [];
1959
+ if (this.selectionSettings.showCheckbox) {
1960
+ [].slice.call(this.ulElement.getElementsByClassName('e-check')).forEach((cbox: Element) => {
1961
+ ele.push(closest(cbox, '.' + 'e-list-item'));
1962
+ });
1963
+ } else {
1964
+ ele = [].slice.call(this.ulElement.getElementsByClassName(cssClass.selected));
1965
+ }
1966
+ return ele;
1967
+ }
1968
+
1969
+ private getScopedListBox(): ListBox {
1970
+ let listObj: ListBox;
1971
+ if (this.scope) {
1972
+ [].slice.call(document.querySelectorAll(this.scope)).forEach((ele: Element) => {
1973
+ if (getComponent(ele as HTMLElement, this.getModuleName())) {
1974
+ listObj = getComponent(ele as HTMLElement, this.getModuleName());
1975
+ }
1976
+ });
1977
+ }
1978
+ return listObj;
1979
+ }
1980
+
1981
+ private getGrabbedItems(args: DragEventArgs): Element[] {
1982
+ let grabbItems : boolean = false;
1983
+ for (let i: number = 0; i < this.value.length; i++) {
1984
+ if (this.value[i as number] === this.getFormattedValue(args.target.getAttribute('data-value')) as string) {
1985
+ grabbItems = true;
1986
+ break;
1987
+ }
1988
+ }
1989
+ if (grabbItems) {
1990
+ for (let i: number = 0; i < this.value.length; i++) {
1991
+ const liColl: NodeListOf<Element> = this.list.querySelectorAll('[aria-selected="true"]');
1992
+ for (let j: number = 0; j < liColl.length; j++) {
1993
+ if (this.value[i as number] === this.getFormattedValue(liColl[j as number].getAttribute('data-value')) as string) {
1994
+ liColl[j as number].classList.add('e-grabbed');
1995
+ }
1996
+ }
1997
+ }
1998
+ }
1999
+ let elems: Element[];
2000
+ if (this.isAngular) {
2001
+ elems = Array.prototype.slice.call(this.element.getElementsByClassName('e-list-parent')[0].querySelectorAll('.e-grabbed'));
2002
+ } else {
2003
+ elems = Array.prototype.slice.call(this.element.nextElementSibling.querySelectorAll('.e-grabbed'));
2004
+ }
2005
+ return elems;
2006
+ }
2007
+
2008
+ private getDragArgs(args: DragEventArgs , isDragEnd?: boolean): DragEventArgs {
2009
+ let elems: Element[] = this.getGrabbedItems(args);
2010
+ if (elems.length) {
2011
+ if (isDragEnd) {
2012
+ elems.push(args.target);
2013
+ }
2014
+ } else {
2015
+ elems = [args.target];
2016
+ }
2017
+ return { elements: elems, items: this.getDataByElems(elems) } as DragEventArgs;
2018
+ }
2019
+
2020
+ private onKeyDown(e: KeyboardEvent): void {
2021
+ this.keyDownHandler(e);
2022
+ e.stopPropagation();
2023
+ }
2024
+
2025
+ private keyDownStatus: boolean = false;
2026
+
2027
+ private keyDownHandler(e: KeyboardEvent): void {
2028
+ if ([32, 35, 36, 37, 38, 39, 40, 65].indexOf(e.keyCode) > -1 && !this.allowFiltering) {
2029
+ if (e.target && (e.target as Element).className.indexOf('e-edit-template') > -1) {
2030
+ return;
2031
+ }
2032
+ e.preventDefault();
2033
+ if (e.keyCode === 32 && this.ulElement.children.length) {
2034
+ this.selectHandler({
2035
+ target: this.ulElement.getElementsByClassName('e-focused')[0],
2036
+ ctrlKey: e.ctrlKey, shiftKey: e.shiftKey
2037
+ });
2038
+ } else if (e.keyCode === 65 && e.ctrlKey) {
2039
+ this.selectAll();
2040
+ } else if ((e.keyCode === 38 || e.keyCode === 40) && e.ctrlKey && e.shiftKey) {
2041
+ this.moveUpDown(e.keyCode === 38 ? true : false, true);
2042
+ } else if ((this.toolbarSettings.items.length || this.tBListBox) && (e.keyCode === 39 || e.keyCode === 37) && e.ctrlKey) {
2043
+ const listObj: ListBox = this.tBListBox || this.getScopedListBox();
2044
+ if (e.keyCode === 39) {
2045
+ if (e.shiftKey) {
2046
+ this.moveAllData(this, listObj, true);
2047
+ } else {
2048
+ this.moveData(this, listObj, true);
2049
+ }
2050
+ } else {
2051
+ if (e.shiftKey) {
2052
+ this.moveAllData(listObj, this, true);
2053
+ } else {
2054
+ this.moveData(listObj, this, true);
2055
+ }
2056
+ }
2057
+ } else if (e.keyCode !== 37 && e.keyCode !== 39 && e.code !== 'KeyA') {
2058
+ this.upDownKeyHandler(e);
2059
+ }
2060
+ } else if (this.allowFiltering) {
2061
+ if (e.keyCode === 40 || e.keyCode === 38) {
2062
+ this.upDownKeyHandler(e);
2063
+ }
2064
+ }
2065
+ }
2066
+
2067
+ private upDownKeyHandler(e: KeyboardEvent): void {
2068
+ const ul: Element = this.ulElement;
2069
+ const defaultIdx: number = (e.keyCode === 40 || e.keyCode === 36) ? 0 : ul.childElementCount - 1;
2070
+ let fliIdx: number = defaultIdx;
2071
+ const fli: Element = ul.getElementsByClassName('e-focused')[0] || ul.getElementsByClassName(cssClass.selected)[0];
2072
+ if (fli) {
2073
+ if (e.keyCode !== 35 && e.keyCode !== 36) {
2074
+ fliIdx = Array.prototype.indexOf.call(ul.children, fli);
2075
+ if (e.keyCode === 40) {
2076
+ fliIdx++;
2077
+ } else {
2078
+ fliIdx--;
2079
+ }
2080
+ if (fliIdx < 0 || fliIdx > ul.childElementCount - 1) {
2081
+ return;
2082
+ }
2083
+ }
2084
+ removeClass([fli], 'e-focused');
2085
+ }
2086
+ const cli: Element = ul.children[fliIdx as number];
2087
+ if (cli) {
2088
+ fliIdx = this.getValidIndex(cli, fliIdx, e.keyCode);
2089
+ if (fliIdx === -1) {
2090
+ addClass([fli], 'e-focused');
2091
+ return;
2092
+ }
2093
+ (ul.children[fliIdx as number] as HTMLElement).focus();
2094
+ ul.children[fliIdx as number].classList.add('e-focused');
2095
+ if (!e.ctrlKey || !this.selectionSettings.showCheckbox && e.shiftKey && (e.keyCode === 36 || e.keyCode === 35)) {
2096
+ this.selectHandler({ target: ul.children[fliIdx as number], ctrlKey: e.ctrlKey, shiftKey: e.shiftKey }, true);
2097
+ }
2098
+ if (this.selectionSettings.showCheckbox && e.ctrlKey && e.shiftKey && (e.keyCode === 36 || e.keyCode === 35)) {
2099
+ const selectedidx : number = Array.prototype.indexOf.call(ul.children, fli);
2100
+ const sidx : number = e.code === 'Home' ? 0 : selectedidx;
2101
+ const eidx : number = e.code === 'Home' ? selectedidx : ul.children.length - 1;
2102
+ for (let i: number = sidx; i <= eidx; i++) {
2103
+ const item: Element = ul.children[i as number];
2104
+ this.notify('updatelist', { li: item, e: {
2105
+ target: this.ulElement.getElementsByClassName('e-focused')[0],
2106
+ ctrlKey: e.ctrlKey, shiftKey: e.shiftKey
2107
+ }, module: 'listbox' });
2108
+ }
2109
+ }
2110
+ }
2111
+ }
2112
+
2113
+ private KeyUp(e: KeyboardEvent): void {
2114
+ const char: string = String.fromCharCode(e.keyCode);
2115
+ const isWordCharacter: Object = char.match(/\w/);
2116
+ if (!isNullOrUndefined(isWordCharacter)) {
2117
+ this.isValidKey = true;
2118
+ }
2119
+ this.isValidKey = (e.keyCode === 8) || (e.keyCode === 46) || this.isValidKey;
2120
+ if (this.isValidKey) {
2121
+ this.isValidKey = false;
2122
+ switch (e.keyCode) {
2123
+ default:
2124
+ if (this.allowFiltering) {
2125
+ const eventArgsData: { [key: string]: Object } = {
2126
+ preventDefaultAction: false,
2127
+ text: this.targetElement(),
2128
+ updateData: (
2129
+ dataSource: {
2130
+ [key: string]: Object
2131
+ }[] | DataManager | string[] | number[], query?: Query, fields?: FieldSettingsModel) => {
2132
+ if (eventArgsData.cancel) { return; }
2133
+ this.isFiltered = true;
2134
+ this.remoteFilterAction = true;
2135
+ this.dataUpdater(dataSource, query, fields);
2136
+ },
2137
+ event: e,
2138
+ cancel: false
2139
+ };
2140
+ this.trigger('filtering', eventArgsData, (args: FilteringEventArgs) => {
2141
+ this.isDataFetched = false;
2142
+ if (args.cancel || (this.filterInput.value !== '' && this.isFiltered)) {
2143
+ return;
2144
+ }
2145
+ if (!args.cancel && !this.isCustomFiltering && !args.preventDefaultAction) {
2146
+ this.inputString = this.filterInput.value;
2147
+ this.filteringAction(this.jsonData, new Query(), this.fields);
2148
+ }
2149
+ if (!this.isFiltered && !this.isCustomFiltering && !args.preventDefaultAction) {
2150
+ this.dataUpdater(this.jsonData, new Query(), this.fields);
2151
+ }
2152
+ });
2153
+ }
2154
+ }
2155
+ }
2156
+ }
2157
+ /**
2158
+ * To filter the data from given data source by using query.
2159
+ *
2160
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
2161
+ * @param {Query} query - Specify the query to filter the data.
2162
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
2163
+ * @returns {void}.
2164
+ */
2165
+ public filter(
2166
+ dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
2167
+ query?: Query, fields?: FieldSettingsModel): void {
2168
+ this.isCustomFiltering = true;
2169
+ this.filteringAction(dataSource, query, fields);
2170
+ }
2171
+
2172
+ private filteringAction(
2173
+ dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
2174
+ query?: Query, fields?: FieldSettingsModel): void {
2175
+ this.resetList(dataSource, fields, query);
2176
+ }
2177
+
2178
+
2179
+ protected targetElement(): string {
2180
+ this.targetInputElement = this.list.getElementsByClassName('e-input-filter')[0] as HTMLInputElement;
2181
+ return this.targetInputElement.value;
2182
+ }
2183
+
2184
+ private dataUpdater(
2185
+ dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
2186
+ query?: Query, fields?: FieldSettingsModel): void {
2187
+ this.isDataFetched = false;
2188
+ const backCommand: boolean = true;
2189
+ if (this.targetElement().trim() === '') {
2190
+ let list: HTMLElement = this.mainList.cloneNode ? <HTMLElement>this.mainList.cloneNode(true) : this.mainList;
2191
+ if (backCommand) {
2192
+ this.remoteCustomValue = false;
2193
+ if (this.isAngular && this.itemTemplate) {
2194
+ list = this.renderItems(this.listData as obj[], fields);
2195
+ }
2196
+ this.onActionComplete(list, this.jsonData as { [key: string]: Object }[] | string[] | number[] | boolean[]);
2197
+ this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.selectionSettings.showCheckbox, e: this });
2198
+ }
2199
+ } else {
2200
+ this.resetList(dataSource, fields, query);
2201
+ }
2202
+ }
2203
+
2204
+ private focusOutHandler(): void {
2205
+ const ele: Element = this.list.getElementsByClassName('e-focused')[0];
2206
+ if (ele) {
2207
+ ele.classList.remove('e-focused');
2208
+ }
2209
+ if (this.allowFiltering) {
2210
+ this.refreshClearIcon();
2211
+ }
2212
+ }
2213
+
2214
+ private getValidIndex(cli: Element, index: number, keyCode: number): number {
2215
+ const cul: Element = this.ulElement;
2216
+ if (cli.classList.contains('e-disabled') || cli.classList.contains(cssClass.group)) {
2217
+ if (keyCode === 40 || keyCode === 36) {
2218
+ index++;
2219
+ } else {
2220
+ index--;
2221
+ }
2222
+ }
2223
+ if (index < 0 || index === cul.childElementCount) {
2224
+ return -1;
2225
+ }
2226
+ cli = (cul.childNodes as NodeListOf<Element>)[index as number];
2227
+ if (cli.classList.contains('e-disabled') || cli.classList.contains(cssClass.group)) {
2228
+ index = this.getValidIndex(cli, index, keyCode);
2229
+ }
2230
+ return index;
2231
+ }
2232
+
2233
+ private updateSelectedOptions(): void {
2234
+ const selectedOptions: string[] = [];
2235
+ const values: string[] = [];
2236
+ extend(values, this.value as string[]);
2237
+ this.getSelectedItems().forEach((ele: Element) => {
2238
+ if (!ele.classList.contains('e-grabbed')) {
2239
+ selectedOptions.push(this.getFormattedValue(ele.getAttribute('data-value')) as string);
2240
+ }
2241
+ });
2242
+ if (this.mainList.childElementCount === this.ulElement.childElementCount) {
2243
+ if (this.allowFiltering && this.selectionSettings.showCheckbox) {
2244
+ for (let i: number = 0; i < selectedOptions.length; i++) {
2245
+ if (values.indexOf(selectedOptions[i as number]) > -1) {
2246
+ continue;
2247
+ } else {
2248
+ values.push(selectedOptions[i as number]);
2249
+ }
2250
+ }
2251
+ this.setProperties({ value: values }, true);
2252
+ } else {
2253
+ this.setProperties({ value: selectedOptions }, true);
2254
+ }
2255
+
2256
+ }
2257
+ this.updateSelectTag();
2258
+ this.updateToolBarState();
2259
+ if (this.tBListBox) {
2260
+ this.tBListBox.updateToolBarState();
2261
+ }
2262
+ }
2263
+
2264
+ private clearSelection(values: (string | number | boolean)[] = this.value): void {
2265
+ if (this.selectionSettings.showCheckbox) {
2266
+ let dvalue: string | number | boolean;
2267
+ this.getSelectedItems().forEach((li: Element) => {
2268
+ dvalue = this.getFormattedValue(li.getAttribute('data-value'));
2269
+ if (values.indexOf(dvalue) < 0) {
2270
+ li.getElementsByClassName('e-check')[0].classList.remove('e-check');
2271
+ li.removeAttribute('aria-selected');
2272
+ }
2273
+ });
2274
+ }
2275
+ }
2276
+
2277
+ private setSelection(
2278
+ values: (string | boolean | number | object)[] = this.value, isSelect: boolean = true, isText: boolean = false): void {
2279
+ let li: Element;
2280
+ let liselect: boolean;
2281
+ if (values) {
2282
+ values.forEach((value: string) => {
2283
+ let text: string | number | boolean;
2284
+ if (isText) {
2285
+ text = this.getValueByText(value);
2286
+ } else {
2287
+ text = value;
2288
+ }
2289
+ if (typeof(text) === 'string') {
2290
+ text = text.split('\\').join('\\\\');
2291
+ li = this.list.querySelector('[data-value="' + text.replace(/"/g, '\\"') + '"]');
2292
+ } else {
2293
+ li = this.list.querySelector('[data-value="' + text + '"]');
2294
+ }
2295
+ if (li) {
2296
+ if (this.selectionSettings.showCheckbox) {
2297
+ liselect = li.getElementsByClassName('e-frame')[0].classList.contains('e-check');
2298
+ } else {
2299
+ liselect = li.classList.contains('e-selected');
2300
+ }
2301
+ if (!isSelect && liselect || isSelect && !liselect && li) {
2302
+ if (this.selectionSettings.showCheckbox) {
2303
+ this.notify('updatelist', { li: li, module: 'listbox' });
2304
+ (li as HTMLElement).focus();
2305
+ } else {
2306
+ if (isSelect) {
2307
+ li.classList.add(cssClass.selected);
2308
+ li.setAttribute('aria-selected', 'true');
2309
+ (li as HTMLElement).focus();
2310
+ } else {
2311
+ li.classList.remove(cssClass.selected);
2312
+ li.removeAttribute('aria-selected');
2313
+ }
2314
+ }
2315
+ }
2316
+ }
2317
+ });
2318
+ }
2319
+ this.updateSelectTag();
2320
+ }
2321
+
2322
+ private updateSelectTag(): void {
2323
+ const ele: Element = this.getSelectTag(); let innerHTML: string = '';
2324
+ ele.innerHTML = '';
2325
+ if (this.value) {
2326
+ for (let i: number = 0, len: number = this.value.length; i < len; i++) {
2327
+ innerHTML += '<option selected>' + this.value[i as number] + '</option>';
2328
+ }
2329
+ ele.innerHTML += innerHTML;
2330
+ for (let i: number = 0, len: number = ele.childNodes.length; i < len; i++) {
2331
+ (ele.childNodes[i as number] as HTMLElement).setAttribute('value', this.value[i as number].toString());
2332
+ }
2333
+ }
2334
+ this.checkSelectAll();
2335
+ }
2336
+
2337
+ private checkDisabledState(inst: ListBox): boolean {
2338
+ return inst.ulElement.querySelectorAll('.' + cssClass.li).length === 0;
2339
+ }
2340
+
2341
+ private updateToolBarState(): void {
2342
+ if (this.toolbarSettings.items.length) {
2343
+ const listObj: ListBox = this.getScopedListBox();
2344
+ const wrap: Element = this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
2345
+ this.toolbarSettings.items.forEach((value: string) => {
2346
+ const btn: HTMLButtonElement = wrap.querySelector('[data-value="' + value + '"]');
2347
+ switch (value) {
2348
+ case 'moveAllTo':
2349
+ btn.disabled = this.checkDisabledState(this);
2350
+ break;
2351
+ case 'moveAllFrom':
2352
+ btn.disabled = this.checkDisabledState(listObj);
2353
+ break;
2354
+ case 'moveFrom':
2355
+ btn.disabled = listObj.value && listObj.value.length ? false : true;
2356
+ break;
2357
+ case 'moveUp':
2358
+ btn.disabled = this.value && this.value.length
2359
+ && !this.isSelected(this.ulElement.children[0]) ? false : true;
2360
+ break;
2361
+ case 'moveDown':
2362
+ btn.disabled = this.value && this.value.length
2363
+ && !this.isSelected(this.ulElement.children[this.ulElement.childElementCount - 1]) ? false : true;
2364
+ break;
2365
+ default:
2366
+ btn.disabled = this.value && this.value.length ? false : true;
2367
+ break;
2368
+ }
2369
+ });
2370
+ }
2371
+ }
2372
+
2373
+ private setCheckboxPosition(): void {
2374
+ const listWrap: HTMLElement = this.list;
2375
+ if (!this.initLoad && this.selectionSettings.checkboxPosition === 'Left') {
2376
+ listWrap.classList.remove('e-right');
2377
+ }
2378
+ if (this.selectionSettings.checkboxPosition === 'Right') {
2379
+ listWrap.classList.add('e-right');
2380
+ }
2381
+ }
2382
+
2383
+ private showCheckbox(showCheckbox: boolean): void {
2384
+ let index: number = 0;
2385
+ const liColl: NodeListOf<Element> = this.list.lastElementChild.querySelectorAll('li');
2386
+ const liCollLen: number = this.list.lastElementChild.getElementsByClassName('e-list-item').length;
2387
+ if (showCheckbox) {
2388
+ this.ulElement = this.renderItems(this.listData as obj[], this.fields);
2389
+ this.mainList = this.ulElement;
2390
+ this.list.removeChild(this.list.getElementsByTagName('ul')[0]);
2391
+ this.list.appendChild(this.ulElement);
2392
+ if (this.selectionSettings.showSelectAll && !this.list.getElementsByClassName('e-selectall-parent')[0]) {
2393
+ const l10nShow: L10n = new L10n(
2394
+ this.getModuleName(), { selectAllText: 'Select All', unSelectAllText: 'Unselect All' }, this.locale);
2395
+ this.showSelectAll = true;
2396
+ this.selectAllText = l10nShow.getConstant('selectAllText');
2397
+ this.unSelectAllText = l10nShow.getConstant('unSelectAllText');
2398
+ this.popupWrapper = this.list;
2399
+ this.checkBoxSelectionModule.checkAllParent = null;
2400
+ this.notify('selectAll', {});
2401
+ this.checkSelectAll();
2402
+ }
2403
+ } else {
2404
+ if (this.list.getElementsByClassName('e-selectall-parent')[0]) {
2405
+ this.list.removeChild(this.list.getElementsByClassName('e-selectall-parent')[0]);
2406
+ }
2407
+ for (index; index < liCollLen; index++) {
2408
+ if (liColl[index as number].classList.contains('e-list-item')) {
2409
+ liColl[index as number].removeChild(liColl[index as number].getElementsByClassName('e-checkbox-wrapper')[0]);
2410
+ }
2411
+ if (liColl[index as number].hasAttribute('aria-selected')) {
2412
+ liColl[index as number].removeAttribute('aria-selected');
2413
+ }
2414
+ }
2415
+ this.mainList = this.ulElement;
2416
+ }
2417
+ this.value = [];
2418
+ }
2419
+
2420
+ private isSelected(ele: Element): boolean {
2421
+ if (!isNullOrUndefined(ele)) {
2422
+ return ele.classList.contains(cssClass.selected) || ele.querySelector('.e-check') !== null;
2423
+ } else {
2424
+ return false;
2425
+ }
2426
+ }
2427
+
2428
+ private getSelectTag(): Element {
2429
+ return this.list.getElementsByClassName('e-hidden-select')[0];
2430
+ }
2431
+
2432
+ private getToolElem(): Element {
2433
+ return this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
2434
+ }
2435
+
2436
+ private formResetHandler(): void {
2437
+ this.value = this.initialSelectedOptions;
2438
+ }
2439
+
2440
+ /**
2441
+ * Return the module name.
2442
+ *
2443
+ * @private
2444
+ * @returns {string} - Module name
2445
+ */
2446
+ public getModuleName(): string {
2447
+ return 'listbox';
2448
+ }
2449
+
2450
+ /**
2451
+ * Get the properties to be maintained in the persisted state.
2452
+ *
2453
+ * @returns {string} - Persist data
2454
+ */
2455
+ protected getPersistData(): string {
2456
+ return this.addOnPersist(['value']);
2457
+ }
2458
+
2459
+ protected getLocaleName(): string {
2460
+ return 'listbox';
2461
+ }
2462
+
2463
+ public destroy(): void {
2464
+ this.unwireEvents();
2465
+ if (this.element.tagName === 'EJS-LISTBOX') {
2466
+ this.element.innerHTML = '';
2467
+ } else {
2468
+ this.element.style.display = 'inline-block';
2469
+ if (this.toolbarSettings.items.length) {
2470
+ this.list.parentElement.parentElement.insertBefore(this.list, this.list.parentElement);
2471
+ detach(this.list.nextElementSibling);
2472
+ }
2473
+ this.list.parentElement.insertBefore(this.element, this.list);
2474
+ }
2475
+ super.destroy();
2476
+ this.enableRtlElements = []; this.liCollections = null; this.list = null; this.ulElement = null;
2477
+ this.mainList = null; this.spinner = null; this.rippleFun = null;
2478
+ if (this.itemTemplate) { this.clearTemplate(); }
2479
+ }
2480
+
2481
+ /**
2482
+ * Called internally if any of the property value changed.
2483
+ *
2484
+ * @param {ListBoxModel} newProp - Specifies the new properties.
2485
+ * @param {ListBoxModel} oldProp - Specifies the old properties.
2486
+ * @returns {void}
2487
+ * @private
2488
+ */
2489
+ public onPropertyChanged(newProp: ListBoxModel, oldProp: ListBoxModel): void {
2490
+ const wrap: Element = this.toolbarSettings.items.length ? this.list.parentElement : this.list;
2491
+ super.onPropertyChanged(newProp, oldProp);
2492
+ this.setUpdateInitial(['fields', 'query', 'dataSource'], newProp as { [key: string]: string; });
2493
+ for (const prop of Object.keys(newProp)) {
2494
+ switch (prop) {
2495
+ case 'cssClass':
2496
+ if (oldProp.cssClass) {
2497
+ removeClass([wrap], oldProp.cssClass.split(' '));
2498
+ }
2499
+ if (newProp.cssClass) {
2500
+ addClass([wrap], newProp.cssClass.replace(/\s+/g, ' ').trim().split(' '));
2501
+ }
2502
+ break;
2503
+ case 'enableRtl':
2504
+ if (newProp.enableRtl) {
2505
+ this.list.classList.add('e-rtl');
2506
+ } else {
2507
+ this.list.classList.remove('e-rtl');
2508
+ }
2509
+ break;
2510
+ case 'value':
2511
+ removeClass(this.list.querySelectorAll('.' + cssClass.selected), cssClass.selected);
2512
+ this.clearSelection(this.value);
2513
+ this.setSelection();
2514
+ break;
2515
+ case 'height':
2516
+ this.setHeight();
2517
+ break;
2518
+ case 'enabled':
2519
+ this.setEnable();
2520
+ break;
2521
+ case 'allowDragAndDrop':
2522
+ if (newProp.allowDragAndDrop) {
2523
+ this.initDraggable();
2524
+ } else {
2525
+ (getComponent(this.ulElement, 'sortable') as Sortable).destroy();
2526
+ }
2527
+ break;
2528
+ case 'allowFiltering':
2529
+ if (this.allowFiltering) {
2530
+ this.setFiltering();
2531
+ } else {
2532
+ this.list.removeChild(this.list.getElementsByClassName('e-filter-parent')[0]);
2533
+ this.filterParent = null;
2534
+ removeClass([this.list], 'e-filter-list');
2535
+ }
2536
+ break;
2537
+ case 'filterBarPlaceholder':
2538
+ if (this.allowFiltering) {
2539
+ if (this.filterInput) { Input.setPlaceholder(newProp.filterBarPlaceholder, this.filterInput as HTMLInputElement); }
2540
+ }
2541
+ break;
2542
+ case 'scope':
2543
+ if (this.allowDragAndDrop) {
2544
+ (getComponent(this.ulElement, 'sortable') as Sortable).scope = newProp.scope;
2545
+ }
2546
+ if (this.toolbarSettings.items.length) {
2547
+ if (oldProp.scope) {
2548
+ (getComponent(document.querySelector(oldProp.scope) as HTMLElement, this.getModuleName()) as ListBox)
2549
+ .tBListBox = null;
2550
+ }
2551
+ if (newProp.scope) {
2552
+ (getComponent(document.querySelector(newProp.scope) as HTMLElement, this.getModuleName()) as ListBox)
2553
+ .tBListBox = this;
2554
+ }
2555
+ }
2556
+ break;
2557
+ case 'toolbarSettings': {
2558
+ let ele: Element;
2559
+ const pos: string = newProp.toolbarSettings.position;
2560
+ const toolElem: Element = this.getToolElem();
2561
+ if (pos) {
2562
+ removeClass([wrap], ['e-right', 'e-left']);
2563
+ wrap.classList.add('e-' + pos.toLowerCase());
2564
+ if (pos === 'Left') {
2565
+ wrap.insertBefore(toolElem, this.list);
2566
+ } else {
2567
+ wrap.appendChild(toolElem);
2568
+ }
2569
+ }
2570
+ if (newProp.toolbarSettings.items) {
2571
+ if (oldProp.toolbarSettings && oldProp.toolbarSettings.items.length) {
2572
+ ele = this.list.parentElement;
2573
+ ele.parentElement.insertBefore(this.list, ele);
2574
+ detach(ele);
2575
+ }
2576
+ this.initToolbarAndStyles();
2577
+ this.wireToolbarEvent();
2578
+ }
2579
+ break;
2580
+ }
2581
+ case 'selectionSettings': {
2582
+ const showSelectAll: boolean = newProp.selectionSettings.showSelectAll;
2583
+ const showCheckbox: boolean = newProp.selectionSettings.showCheckbox;
2584
+ if (!isNullOrUndefined(showSelectAll)) {
2585
+ this.showSelectAll = showSelectAll;
2586
+ if (this.showSelectAll) {
2587
+ const l10nSel: L10n = new L10n(
2588
+ this.getModuleName(), { selectAllText: 'Select All', unSelectAllText: 'Unselect All' }, this.locale);
2589
+ this.checkBoxSelectionModule.checkAllParent = null;
2590
+ this.showSelectAll = true;
2591
+ this.selectAllText = l10nSel.getConstant('selectAllText');
2592
+ this.unSelectAllText = l10nSel.getConstant('selectAllText');
2593
+ this.popupWrapper = this.list;
2594
+ }
2595
+ this.notify('selectAll', {});
2596
+ this.checkSelectAll();
2597
+ }
2598
+ if (!isNullOrUndefined(showCheckbox)) {
2599
+ this.showCheckbox(showCheckbox);
2600
+ }
2601
+ if (this.selectionSettings.showCheckbox) {
2602
+ this.setCheckboxPosition();
2603
+ }
2604
+ break;
2605
+ }
2606
+ case 'dataSource':
2607
+ this.isDataSourceUpdate = true;
2608
+ this.jsonData = [].slice.call(this.dataSource);
2609
+ break;
2610
+ }
2611
+ }
2612
+ }
2613
+ }
2614
+
2615
+ /**
2616
+ * Interface for before item render event.
2617
+ */
2618
+ export interface BeforeItemRenderEventArgs extends BaseEventArgs {
2619
+ /**
2620
+ * Returns the list element before rendering.
2621
+ */
2622
+ element: Element;
2623
+ /**
2624
+ * Returns the list item before rendering.
2625
+ */
2626
+ item: { [key: string]: Object };
2627
+ }
2628
+
2629
+ /**
2630
+ * Interface for drag and drop event args.
2631
+ */
2632
+ export interface SourceDestinationModel {
2633
+ /**
2634
+ * Specifies the list items before drag or drop in the ListBox.
2635
+ */
2636
+ previousData?: string[] | boolean[] | number[] | { [key: string]: Object; }[] | DataManager;
2637
+ /**
2638
+ * Specifies the list items after drag or drop in the ListBox.
2639
+ */
2640
+ currentData?: string[] | boolean[] | number[] | { [key: string]: Object; }[] | DataManager;
2641
+ }
2642
+
2643
+ /**
2644
+ * Interface for drag and drop event.
2645
+ */
2646
+ export interface DragEventArgs {
2647
+ /**
2648
+ * Returns the previous index of the selected list item.
2649
+ */
2650
+ previousIndex?: number;
2651
+ /**
2652
+ * Returns the current index of the selected list item.
2653
+ */
2654
+ currentIndex?: number;
2655
+ /**
2656
+ * Returns the selected list element.
2657
+ */
2658
+ elements: Element[];
2659
+ /**
2660
+ * Returns the selected list items.
2661
+ */
2662
+ items: Object[];
2663
+ /**
2664
+ * Returns the target list element where the selected list element to be dropped.
2665
+ */
2666
+ target?: Element;
2667
+ /**
2668
+ * Returns true if the list element is dragged from ListBox. Otherwise, it remains false.
2669
+ */
2670
+ dragSelected?: boolean;
2671
+ /**
2672
+ * Returns the previous list item.
2673
+ */
2674
+ previousItem?: object[];
2675
+ /**
2676
+ * Returns the previous and current list items of the source list box.
2677
+ */
2678
+ source?: SourceDestinationModel;
2679
+ /**
2680
+ * Returns the previous and current list items of the destination list box.
2681
+ */
2682
+ destination?: SourceDestinationModel;
2683
+ }
2684
+
2685
+ /**
2686
+ * Interface for change event args.
2687
+ */
2688
+ export interface ListBoxChangeEventArgs extends BaseEventArgs {
2689
+ /**
2690
+ * Returns the selected list elements.
2691
+ */
2692
+ elements: Element[];
2693
+ /**
2694
+ * Returns the selected list items.
2695
+ */
2696
+ items: Object[];
2697
+ /**
2698
+ * Returns the selected state or selected list item in the ListBox.
2699
+ */
2700
+ value: number | string | boolean;
2701
+ /**
2702
+ * Specifies the event.
2703
+ */
2704
+ event: Event;
2705
+ }
2706
+
2707
+ /**
2708
+ * Interface for Drop event args.
2709
+ */
2710
+ export interface DropEventArgs {
2711
+ /**
2712
+ * Returns the previous index of the selected list item.
2713
+ */
2714
+ previousIndex: number;
2715
+ /**
2716
+ * Returns the current index of the selected list item.
2717
+ */
2718
+ currentIndex: number;
2719
+ /**
2720
+ * Returns the selected list element to be dropped.
2721
+ */
2722
+ droppedElement: Element;
2723
+ /**
2724
+ * Returns the target list element where the selected list element to be dropped.
2725
+ */
2726
+ target: Element;
2727
+ /**
2728
+ * Returns the dragged list element.
2729
+ */
2730
+ helper: Element;
2731
+ /**
2732
+ * Illustrates whether the current action needs to be prevented or not.
2733
+ */
2734
+ cancel?: boolean;
2735
+ /**
2736
+ * Returns the selected list items.
2737
+ */
2738
+ items?: Object[];
2739
+ }
2740
+ interface ListBoxClassList {
2741
+ backIcon: string;
2742
+ filterBarClearIcon: string;
2743
+ filterInput: string;
2744
+ filterParent: string;
2745
+ clearIcon: string;
2746
+ }
2747
+ const listBoxClasses: ListBoxClassList = {
2748
+ backIcon: 'e-input-group-icon e-back-icon e-icons',
2749
+ filterBarClearIcon: 'e-input-group-icon e-clear-icon e-icons',
2750
+ filterInput: 'e-input-filter',
2751
+ filterParent: 'e-filter-parent',
2752
+ clearIcon: 'e-clear-icon'
2753
+ };