@syncfusion/ej2-dropdowns 24.1.45-12082 → 24.1.46

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 (276) hide show
  1. package/.eslintrc.json +260 -0
  2. package/CHANGELOG.md +2107 -2101
  3. package/{ReadMe.md → README.md} +217 -217
  4. package/dist/ej2-dropdowns.min.js +10 -1
  5. package/dist/ej2-dropdowns.umd.min.js +10 -1
  6. package/dist/ej2-dropdowns.umd.min.js.map +1 -1
  7. package/dist/es6/ej2-dropdowns.es2015.js +127 -61
  8. package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
  9. package/dist/es6/ej2-dropdowns.es5.js +274 -203
  10. package/dist/es6/ej2-dropdowns.es5.js.map +1 -1
  11. package/dist/global/ej2-dropdowns.min.js +10 -1
  12. package/dist/global/ej2-dropdowns.min.js.map +1 -1
  13. package/dist/global/index.d.ts +9 -0
  14. package/helpers/e2e/autocomplete.js +13 -13
  15. package/helpers/e2e/combobox.js +13 -13
  16. package/helpers/e2e/dropdownlist.js +13 -13
  17. package/helpers/e2e/index.js +3 -3
  18. package/helpers/e2e/listboxHelper.js +13 -13
  19. package/helpers/e2e/multiselect.js +13 -13
  20. package/license +2 -2
  21. package/package.json +80 -80
  22. package/src/auto-complete/auto-complete-model.d.ts +188 -188
  23. package/src/auto-complete/auto-complete.d.ts +12 -12
  24. package/src/auto-complete/auto-complete.js +21 -21
  25. package/src/combo-box/combo-box-model.d.ts +224 -224
  26. package/src/combo-box/combo-box.d.ts +27 -27
  27. package/src/combo-box/combo-box.js +29 -29
  28. package/src/common/virtual-scroll.js +46 -46
  29. package/src/drop-down-base/drop-down-base-model.d.ts +200 -200
  30. package/src/drop-down-base/drop-down-base.d.ts +16 -16
  31. package/src/drop-down-base/drop-down-base.js +20 -20
  32. package/src/drop-down-list/drop-down-list-model.d.ts +202 -202
  33. package/src/drop-down-list/drop-down-list.d.ts +4 -4
  34. package/src/drop-down-list/drop-down-list.js +20 -20
  35. package/src/drop-down-tree/drop-down-tree-model.d.ts +468 -468
  36. package/src/drop-down-tree/drop-down-tree.d.ts +3 -0
  37. package/src/drop-down-tree/drop-down-tree.js +95 -24
  38. package/src/list-box/list-box-model.d.ts +193 -193
  39. package/src/list-box/list-box.d.ts +2 -2
  40. package/src/list-box/list-box.js +19 -19
  41. package/src/mention/mention-model.d.ts +261 -261
  42. package/src/mention/mention.js +19 -19
  43. package/src/multi-select/multi-select-model.d.ts +512 -512
  44. package/src/multi-select/multi-select.js +19 -19
  45. package/styles/auto-complete/_all.scss +1 -1
  46. package/styles/auto-complete/_bootstrap-dark-definition.scss +3 -3
  47. package/styles/auto-complete/_bootstrap-definition.scss +2 -2
  48. package/styles/auto-complete/_bootstrap4-definition.scss +11 -11
  49. package/styles/auto-complete/_bootstrap5-definition.scss +2 -2
  50. package/styles/auto-complete/_fabric-dark-definition.scss +2 -2
  51. package/styles/auto-complete/_fabric-definition.scss +2 -2
  52. package/styles/auto-complete/_fluent-definition.scss +2 -2
  53. package/styles/auto-complete/_fusionnew-definition.scss +2 -2
  54. package/styles/auto-complete/_highcontrast-definition.scss +2 -2
  55. package/styles/auto-complete/_highcontrast-light-definition.scss +2 -2
  56. package/styles/auto-complete/_material-dark-definition.scss +2 -2
  57. package/styles/auto-complete/_material-definition.scss +2 -2
  58. package/styles/auto-complete/_material3-definition.scss +2 -2
  59. package/styles/auto-complete/_tailwind-definition.scss +2 -2
  60. package/styles/auto-complete/material3-dark.scss +1 -1
  61. package/styles/auto-complete/material3.scss +1 -1
  62. package/styles/combo-box/_all.scss +1 -1
  63. package/styles/combo-box/_bootstrap-dark-definition.scss +2 -2
  64. package/styles/combo-box/_bootstrap-definition.scss +2 -2
  65. package/styles/combo-box/_bootstrap4-definition.scss +11 -11
  66. package/styles/combo-box/_bootstrap5-definition.scss +2 -2
  67. package/styles/combo-box/_fabric-dark-definition.scss +2 -2
  68. package/styles/combo-box/_fabric-definition.scss +2 -2
  69. package/styles/combo-box/_fluent-definition.scss +2 -2
  70. package/styles/combo-box/_fusionnew-definition.scss +2 -2
  71. package/styles/combo-box/_highcontrast-definition.scss +2 -2
  72. package/styles/combo-box/_highcontrast-light-definition.scss +3 -3
  73. package/styles/combo-box/_material-dark-definition.scss +2 -2
  74. package/styles/combo-box/_material-definition.scss +2 -2
  75. package/styles/combo-box/_material3-definition.scss +2 -2
  76. package/styles/combo-box/_tailwind-definition.scss +2 -2
  77. package/styles/combo-box/material3-dark.scss +1 -1
  78. package/styles/combo-box/material3.scss +1 -1
  79. package/styles/drop-down-base/_all.scss +2 -2
  80. package/styles/drop-down-base/_bootstrap-dark-definition.scss +83 -83
  81. package/styles/drop-down-base/_bootstrap-definition.scss +83 -83
  82. package/styles/drop-down-base/_bootstrap4-definition.scss +90 -90
  83. package/styles/drop-down-base/_bootstrap5-definition.scss +117 -117
  84. package/styles/drop-down-base/_definition.scss +23 -23
  85. package/styles/drop-down-base/_fabric-dark-definition.scss +86 -86
  86. package/styles/drop-down-base/_fabric-definition.scss +84 -84
  87. package/styles/drop-down-base/_fluent-definition.scss +121 -121
  88. package/styles/drop-down-base/_fusionnew-definition.scss +117 -117
  89. package/styles/drop-down-base/_highcontrast-definition.scss +105 -105
  90. package/styles/drop-down-base/_highcontrast-light-definition.scss +105 -105
  91. package/styles/drop-down-base/_layout.scss +192 -192
  92. package/styles/drop-down-base/_material-dark-definition.scss +86 -86
  93. package/styles/drop-down-base/_material-definition.scss +85 -85
  94. package/styles/drop-down-base/_material3-definition.scss +87 -87
  95. package/styles/drop-down-base/_tailwind-definition.scss +129 -129
  96. package/styles/drop-down-base/_theme.scss +391 -391
  97. package/styles/drop-down-base/material3-dark.scss +1 -1
  98. package/styles/drop-down-base/material3.scss +1 -1
  99. package/styles/drop-down-list/_all.scss +3 -3
  100. package/styles/drop-down-list/_bootstrap-dark-definition.scss +157 -157
  101. package/styles/drop-down-list/_bootstrap-definition.scss +156 -156
  102. package/styles/drop-down-list/_bootstrap4-definition.scss +202 -202
  103. package/styles/drop-down-list/_bootstrap5-definition.scss +201 -201
  104. package/styles/drop-down-list/_fabric-dark-definition.scss +128 -128
  105. package/styles/drop-down-list/_fabric-definition.scss +124 -124
  106. package/styles/drop-down-list/_fluent-definition.scss +185 -185
  107. package/styles/drop-down-list/_fusionnew-definition.scss +201 -201
  108. package/styles/drop-down-list/_highcontrast-definition.scss +142 -142
  109. package/styles/drop-down-list/_highcontrast-light-definition.scss +144 -144
  110. package/styles/drop-down-list/_layout.scss +315 -315
  111. package/styles/drop-down-list/_material-dark-definition.scss +143 -143
  112. package/styles/drop-down-list/_material-definition.scss +167 -167
  113. package/styles/drop-down-list/_material3-definition.scss +180 -180
  114. package/styles/drop-down-list/_tailwind-definition.scss +134 -134
  115. package/styles/drop-down-list/_theme.scss +10 -10
  116. package/styles/drop-down-list/icons/_bootstrap-dark.scss +14 -14
  117. package/styles/drop-down-list/icons/_bootstrap.scss +14 -14
  118. package/styles/drop-down-list/icons/_bootstrap4.scss +14 -14
  119. package/styles/drop-down-list/icons/_bootstrap5.scss +14 -14
  120. package/styles/drop-down-list/icons/_fabric-dark.scss +14 -14
  121. package/styles/drop-down-list/icons/_fabric.scss +14 -14
  122. package/styles/drop-down-list/icons/_fluent.scss +14 -14
  123. package/styles/drop-down-list/icons/_fusionnew.scss +14 -14
  124. package/styles/drop-down-list/icons/_highcontrast-light.scss +14 -14
  125. package/styles/drop-down-list/icons/_highcontrast.scss +14 -14
  126. package/styles/drop-down-list/icons/_material-dark.scss +14 -14
  127. package/styles/drop-down-list/icons/_material.scss +14 -14
  128. package/styles/drop-down-list/icons/_material3.scss +14 -14
  129. package/styles/drop-down-list/icons/_tailwind.scss +14 -14
  130. package/styles/drop-down-list/material3-dark.scss +1 -1
  131. package/styles/drop-down-list/material3.scss +1 -1
  132. package/styles/drop-down-tree/_all.scss +2 -2
  133. package/styles/drop-down-tree/_bootstrap-dark-definition.scss +71 -71
  134. package/styles/drop-down-tree/_bootstrap-definition.scss +70 -70
  135. package/styles/drop-down-tree/_bootstrap4-definition.scss +71 -71
  136. package/styles/drop-down-tree/_bootstrap5-definition.scss +59 -59
  137. package/styles/drop-down-tree/_fabric-dark-definition.scss +71 -71
  138. package/styles/drop-down-tree/_fabric-definition.scss +71 -71
  139. package/styles/drop-down-tree/_fluent-definition.scss +65 -65
  140. package/styles/drop-down-tree/_fusionnew-definition.scss +59 -59
  141. package/styles/drop-down-tree/_highcontrast-definition.scss +71 -71
  142. package/styles/drop-down-tree/_highcontrast-light-definition.scss +71 -71
  143. package/styles/drop-down-tree/_layout.scss +1423 -1423
  144. package/styles/drop-down-tree/_material-dark-definition.scss +72 -72
  145. package/styles/drop-down-tree/_material-definition.scss +72 -72
  146. package/styles/drop-down-tree/_material3-definition.scss +76 -76
  147. package/styles/drop-down-tree/_tailwind-definition.scss +61 -61
  148. package/styles/drop-down-tree/_theme.scss +132 -132
  149. package/styles/drop-down-tree/icons/_bootstrap-dark.scss +11 -11
  150. package/styles/drop-down-tree/icons/_bootstrap.scss +11 -11
  151. package/styles/drop-down-tree/icons/_bootstrap4.scss +11 -11
  152. package/styles/drop-down-tree/icons/_bootstrap5.scss +11 -11
  153. package/styles/drop-down-tree/icons/_fabric-dark.scss +11 -11
  154. package/styles/drop-down-tree/icons/_fabric.scss +11 -11
  155. package/styles/drop-down-tree/icons/_fluent.scss +11 -11
  156. package/styles/drop-down-tree/icons/_fusionnew.scss +11 -11
  157. package/styles/drop-down-tree/icons/_highcontrast-light.scss +11 -11
  158. package/styles/drop-down-tree/icons/_highcontrast.scss +11 -11
  159. package/styles/drop-down-tree/icons/_material-dark.scss +11 -11
  160. package/styles/drop-down-tree/icons/_material.scss +11 -11
  161. package/styles/drop-down-tree/icons/_material3.scss +11 -11
  162. package/styles/drop-down-tree/icons/_tailwind-dark.scss +11 -11
  163. package/styles/drop-down-tree/icons/_tailwind.scss +11 -11
  164. package/styles/drop-down-tree/material3-dark.scss +1 -1
  165. package/styles/drop-down-tree/material3.scss +1 -1
  166. package/styles/list-box/_all.scss +2 -2
  167. package/styles/list-box/_bootstrap-dark-definition.scss +126 -126
  168. package/styles/list-box/_bootstrap-definition.scss +119 -119
  169. package/styles/list-box/_bootstrap4-definition.scss +124 -124
  170. package/styles/list-box/_bootstrap5-definition.scss +120 -120
  171. package/styles/list-box/_fabric-dark-definition.scss +126 -126
  172. package/styles/list-box/_fabric-definition.scss +119 -119
  173. package/styles/list-box/_fluent-definition.scss +120 -120
  174. package/styles/list-box/_fusionnew-definition.scss +111 -111
  175. package/styles/list-box/_highcontrast-definition.scss +119 -119
  176. package/styles/list-box/_highcontrast-light-definition.scss +126 -126
  177. package/styles/list-box/_layout.scss +542 -542
  178. package/styles/list-box/_material-dark-definition.scss +126 -126
  179. package/styles/list-box/_material-definition.scss +119 -119
  180. package/styles/list-box/_material3-definition.scss +119 -119
  181. package/styles/list-box/_tailwind-definition.scss +119 -119
  182. package/styles/list-box/_theme.scss +382 -382
  183. package/styles/list-box/icons/_bootstrap-dark.scss +25 -25
  184. package/styles/list-box/icons/_bootstrap.scss +25 -25
  185. package/styles/list-box/icons/_bootstrap4.scss +25 -25
  186. package/styles/list-box/icons/_bootstrap5.scss +25 -25
  187. package/styles/list-box/icons/_fabric-dark.scss +25 -25
  188. package/styles/list-box/icons/_fabric.scss +25 -25
  189. package/styles/list-box/icons/_fluent.scss +25 -25
  190. package/styles/list-box/icons/_fusionnew.scss +25 -25
  191. package/styles/list-box/icons/_highcontrast-light.scss +25 -25
  192. package/styles/list-box/icons/_highcontrast.scss +25 -25
  193. package/styles/list-box/icons/_material-dark.scss +25 -25
  194. package/styles/list-box/icons/_material.scss +25 -25
  195. package/styles/list-box/icons/_material3.scss +25 -25
  196. package/styles/list-box/icons/_tailwind-dark.scss +25 -25
  197. package/styles/list-box/icons/_tailwind.scss +25 -25
  198. package/styles/list-box/material3-dark.scss +1 -1
  199. package/styles/list-box/material3.scss +1 -1
  200. package/styles/material3-dark.scss +1 -1
  201. package/styles/material3.scss +1 -1
  202. package/styles/mention/_all.scss +1 -1
  203. package/styles/mention/_bootstrap-dark-definition.scss +3 -3
  204. package/styles/mention/_bootstrap-definition.scss +3 -3
  205. package/styles/mention/_bootstrap4-definition.scss +3 -3
  206. package/styles/mention/_bootstrap5-definition.scss +1 -1
  207. package/styles/mention/_fabric-dark-definition.scss +2 -2
  208. package/styles/mention/_fabric-definition.scss +3 -3
  209. package/styles/mention/_fluent-definition.scss +1 -1
  210. package/styles/mention/_fusionnew-definition.scss +1 -1
  211. package/styles/mention/_highcontrast-definition.scss +3 -3
  212. package/styles/mention/_highcontrast-light-definition.scss +3 -3
  213. package/styles/mention/_layout.scss +6 -6
  214. package/styles/mention/_material-dark-definition.scss +3 -3
  215. package/styles/mention/_material-definition.scss +3 -3
  216. package/styles/mention/_material3-definition.scss +1 -1
  217. package/styles/mention/_tailwind-definition.scss +1 -1
  218. package/styles/mention/material3-dark.scss +1 -1
  219. package/styles/mention/material3.scss +1 -1
  220. package/styles/multi-select/_all.scss +2 -2
  221. package/styles/multi-select/_bootstrap-dark-definition.scss +203 -203
  222. package/styles/multi-select/_bootstrap-definition.scss +192 -192
  223. package/styles/multi-select/_bootstrap4-definition.scss +278 -278
  224. package/styles/multi-select/_bootstrap5-definition.scss +230 -230
  225. package/styles/multi-select/_fabric-dark-definition.scss +192 -192
  226. package/styles/multi-select/_fabric-definition.scss +183 -183
  227. package/styles/multi-select/_fluent-definition.scss +241 -241
  228. package/styles/multi-select/_fusionnew-definition.scss +227 -227
  229. package/styles/multi-select/_highcontrast-definition.scss +303 -303
  230. package/styles/multi-select/_highcontrast-light-definition.scss +297 -297
  231. package/styles/multi-select/_layout.scss +2199 -2199
  232. package/styles/multi-select/_material-dark-definition.scss +230 -230
  233. package/styles/multi-select/_material-definition.scss +223 -223
  234. package/styles/multi-select/_material3-definition.scss +246 -246
  235. package/styles/multi-select/_tailwind-definition.scss +235 -235
  236. package/styles/multi-select/_theme.scss +586 -586
  237. package/styles/multi-select/icons/_bootstrap-dark.scss +26 -26
  238. package/styles/multi-select/icons/_bootstrap.scss +26 -26
  239. package/styles/multi-select/icons/_bootstrap4.scss +37 -37
  240. package/styles/multi-select/icons/_bootstrap5.scss +26 -26
  241. package/styles/multi-select/icons/_fabric-dark.scss +26 -26
  242. package/styles/multi-select/icons/_fabric.scss +26 -26
  243. package/styles/multi-select/icons/_fluent.scss +55 -55
  244. package/styles/multi-select/icons/_fusionnew.scss +26 -26
  245. package/styles/multi-select/icons/_highcontrast-light.scss +26 -26
  246. package/styles/multi-select/icons/_highcontrast.scss +26 -26
  247. package/styles/multi-select/icons/_material-dark.scss +693 -693
  248. package/styles/multi-select/icons/_material.scss +693 -693
  249. package/styles/multi-select/icons/_material3.scss +692 -692
  250. package/styles/multi-select/icons/_tailwind.scss +26 -26
  251. package/styles/multi-select/material3-dark.scss +1 -1
  252. package/styles/multi-select/material3.scss +1 -1
  253. package/tslint.json +111 -0
  254. package/dist/ts/auto-complete/auto-complete.ts +0 -623
  255. package/dist/ts/combo-box/combo-box.ts +0 -1099
  256. package/dist/ts/common/highlight-search.ts +0 -57
  257. package/dist/ts/common/incremental-search.ts +0 -172
  258. package/dist/ts/common/interface.ts +0 -74
  259. package/dist/ts/common/virtual-scroll.ts +0 -388
  260. package/dist/ts/drop-down-base/drop-down-base.ts +0 -1986
  261. package/dist/ts/drop-down-list/drop-down-list.ts +0 -4261
  262. package/dist/ts/drop-down-tree/drop-down-tree.ts +0 -3747
  263. package/dist/ts/list-box/list-box.ts +0 -2772
  264. package/dist/ts/mention/mention.ts +0 -1875
  265. package/dist/ts/multi-select/checkbox-selection.ts +0 -550
  266. package/dist/ts/multi-select/float-label.ts +0 -176
  267. package/dist/ts/multi-select/interface.ts +0 -70
  268. package/dist/ts/multi-select/multi-select.ts +0 -4882
  269. package/styles/auto-complete/_bds-definition.scss +0 -2
  270. package/styles/combo-box/_bds-definition.scss +0 -2
  271. package/styles/drop-down-base/_bds-definition.scss +0 -129
  272. package/styles/drop-down-list/_bds-definition.scss +0 -134
  273. package/styles/drop-down-tree/_bds-definition.scss +0 -61
  274. package/styles/list-box/_bds-definition.scss +0 -119
  275. package/styles/mention/_bds-definition.scss +0 -1
  276. package/styles/multi-select/_bds-definition.scss +0 -235
@@ -1,3747 +0,0 @@
1
- import { Input, InputObject, FloatLabelType, TextBox, InputEventArgs } from '@syncfusion/ej2-inputs';
2
- import { createCheckBox } from '@syncfusion/ej2-buttons';
3
- import { NotifyPropertyChanges, INotifyPropertyChanged, Property, Event, EmitType, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
4
- import { Component, EventHandler, attributes, formatUnit, ChildProperty, remove, L10n, extend } from '@syncfusion/ej2-base';
5
- import { addClass, removeClass, detach, prepend, Complex, closest, setValue, getValue, compile, append } from '@syncfusion/ej2-base';
6
- import { select, selectAll, isNullOrUndefined as isNOU, matches, Browser, KeyboardEvents, KeyboardEventArgs } from '@syncfusion/ej2-base';
7
- import { DataManager, Query, DataUtil } from '@syncfusion/ej2-data';
8
- import { Popup } from '@syncfusion/ej2-popups';
9
- import { TreeView, NodeSelectEventArgs, DataBoundEventArgs, FieldsSettingsModel, NodeClickEventArgs, NodeExpandEventArgs } from '@syncfusion/ej2-navigations';
10
- import { NodeCheckEventArgs, FailureEventArgs} from '@syncfusion/ej2-navigations';
11
- import { DropDownTreeModel, FieldsModel, TreeSettingsModel } from './drop-down-tree-model';
12
-
13
- const RTL: string = 'e-rtl';
14
- const DROPDOWNTREE: string = 'e-ddt';
15
- const HIDDENELEMENT: string = 'e-ddt-hidden';
16
- const DROPDOWNICON: string = 'e-input-group-icon e-ddt-icon e-icons';
17
- const SHOW_CHIP: string = 'e-show-chip';
18
- const SHOW_CLEAR: string = 'e-show-clear';
19
- const SHOW_DD_ICON: string = 'e-show-dd-icon';
20
- const CHIP_INPUT: string = 'e-chip-input';
21
- const INPUTFOCUS: string = 'e-input-focus';
22
- const INPUTGROUP: string = 'e-input-group';
23
- const ICONANIMATION: string = 'e-icon-anim';
24
- const CLOSEICON_CLASS: string = 'e-clear-icon e-icons';
25
- const CHIP_WRAPPER: string = 'e-chips-wrapper';
26
- const CHIP_COLLECTION: string = 'e-chips-collection';
27
- const CHIP: string = 'e-chips';
28
- const CHIP_CONTENT: string = 'e-chipcontent';
29
- const CHIP_CLOSE: string = 'e-chips-close';
30
- const HIDEICON: string = 'e-icon-hide';
31
- const DDTHIDEICON: string = 'e-ddt-icon-hide';
32
- const POPUP_CLASS: string = 'e-ddt e-popup';
33
- const PARENTITEM: string = 'e-list-parent';
34
- const CONTENT: string = 'e-popup-content';
35
- const DROPDOWN: string = 'e-dropdown';
36
- const DISABLED: string = 'e-disabled';
37
- const ICONS: string = 'e-icons';
38
- const CHECKALLPARENT: string = 'e-selectall-parent';
39
- const CHECKALLHIDE: string = 'e-hide-selectall';
40
- const BIGGER: string = 'e-bigger';
41
- const SMALL: string = 'e-small';
42
- const ALLTEXT: string = 'e-all-text';
43
- const CHECKBOXFRAME: string = 'e-frame';
44
- const CHECK: string = 'e-check';
45
- const CHECKBOXWRAP: string = 'e-checkbox-wrapper';
46
- const FILTERWRAP: string = 'e-filter-wrap';
47
- const DDTICON: string = 'e-ddt-icon';
48
- const FOOTER: string = 'e-ddt-footer';
49
- const HEADER: string = 'e-ddt-header';
50
- const NODATACONTAINER: string = 'e-ddt-nodata';
51
- const NODATA: string = 'e-no-data';
52
- const HEADERTEMPLATE: string = 'HeaderTemplate';
53
- const FOOTERTEMPLATE: string = 'FooterTemplate';
54
- const NORECORDSTEMPLATE: string = 'NoRecordsTemplate';
55
- const ACTIONFAILURETEMPLATE: string = 'ActionFailureTemplate';
56
- const CUSTOMTEMPLATE: string = 'CustomTemplate';
57
- const REMAIN_WRAPPER: string = 'e-remain';
58
- const OVERFLOW_VIEW: string = 'e-overflow';
59
- const SHOW_TEXT: string = 'e-show-text';
60
- const TOTAL_COUNT_WRAPPER: string = 'e-total-count';
61
- const REMAIN_COUNT: string = 'e-wrap-count';
62
-
63
- /**
64
- * Specifies the different ways to filter values.
65
- * ```props
66
- * StartsWith :- Checks whether a value begins with the specified value.
67
- * EndsWith :- Checks whether a value ends with the specified value.
68
- * Contains :- Checks whether a value contains with specified value.
69
- * ```
70
- */
71
- export type TreeFilterType = 'StartsWith' | 'EndsWith' | 'Contains';
72
-
73
- export class Fields extends ChildProperty<Fields> {
74
-
75
- /**
76
- * This field specifies the child items or mapping field for the nested child items that contains an array of JSON objects.
77
- */
78
- @Property('child')
79
- public child: string | FieldsModel;
80
-
81
- /**
82
- * Specifies the array of JavaScript objects or instance of Data Manager to populate the dropdown tree items.
83
- *
84
- * @default []
85
- */
86
- /* eslint-disable */
87
- @Property([])
88
- public dataSource: DataManager | { [key: string]: Object }[];
89
- /* eslint-enable */
90
- /**
91
- * This fields specifies the mapping field to define the expanded state of a Dropdown tree item.
92
- */
93
- @Property('expanded')
94
- public expanded: string;
95
-
96
- /**
97
- * This field specifies the mapping field to indicate whether the Dropdown tree item has children or not.
98
- */
99
- @Property('hasChildren')
100
- public hasChildren: string;
101
-
102
- /**
103
- * Specifies the mapping field for htmlAttributes to be added to the Dropdown Tree item.
104
- */
105
- @Property('htmlAttributes')
106
- public htmlAttributes: string;
107
-
108
- /**
109
- * Specifies the mapping field for icon class of each Dropdown Tree item that will be added before the text.
110
- */
111
- @Property('iconCss')
112
- public iconCss: string;
113
-
114
- /**
115
- * Specifies the mapping field for image URL of each Dropdown Tree item where image will be added before the text.
116
- */
117
- @Property('imageUrl')
118
- public imageUrl: string;
119
-
120
- /**
121
- * Specifies the parent value field mapped in the data source.
122
- */
123
- @Property('parentValue')
124
- public parentValue: string;
125
-
126
- /**
127
- * Defines the external [`Query`](https://ej2.syncfusion.com/documentation/api/data/query/)
128
- * that will execute along with the data processing.
129
- *
130
- * @default null
131
- */
132
- @Property(null)
133
- public query: Query;
134
-
135
- /**
136
- * Specifies whether the node can be selected by users or not
137
- * When set to false, the user interaction is prevented for the corresponding node.
138
- */
139
- @Property('selectable')
140
- public selectable: string;
141
-
142
- /**
143
- * Specifies the mapping field for the selected state of the Dropdown Tree item.
144
- */
145
- @Property('selected')
146
- public selected: string;
147
-
148
- /**
149
- * Specifies the table name used to fetch data from a specific table in the server.
150
- */
151
- @Property(null)
152
- public tableName: string;
153
-
154
- /**
155
- * Specifies the mapping field for text displayed as Dropdown Tree items display text.
156
- */
157
- @Property('text')
158
- public text: string;
159
-
160
- /**
161
- * Specifies the mapping field for tooltip that will be displayed as hovering text of the Dropdown Tree item.
162
- */
163
- @Property('tooltip')
164
- public tooltip: string;
165
-
166
- /**
167
- * Specifies the value(ID) field mapped in the data source.
168
- */
169
- @Property('value')
170
- public value: string;
171
- }
172
-
173
- export class TreeSettings extends ChildProperty<TreeSettings> {
174
- /**
175
- * Specifies whether the child and parent tree items check states are dependent over each other when checkboxes are enabled.
176
- *
177
- * @default false
178
- */
179
-
180
- @Property(false)
181
- public autoCheck: boolean;
182
-
183
- /**
184
- * Specifies the action on which the parent items in the pop-up should expand or collapse. The available actions are
185
- * * `Auto` - In desktop, the expand or collapse operation happens when you double-click the node,
186
- * and in mobile devices it happens on single-tap.
187
- * * `Click` - The expand or collapse operation happens when you perform single-click/tap
188
- * on the pop-up item in both desktop and mobile devices.
189
- * * `DblClick` - The expand or collapse operation happens when you perform a double-click/tap
190
- * on the pop-up item in both desktop and mobile devices.
191
- * * `None` - The expand or collapse operation will not happen when you perform single-click/tap
192
- * or double-click/tap on the pop-up items in both desktop and mobile devices.
193
- *
194
- * @default 'Auto'
195
- */
196
- @Property('Auto')
197
- public expandOn: ExpandOn;
198
-
199
- /**
200
- * By default, the load on demand (Lazy load) is set to false.
201
- * Enabling this property will render only the parent tree items in the popup and
202
- * the child items will be rendered on demand when expanding the corresponding parent node.
203
- *
204
- * @default false
205
- */
206
- @Property(false)
207
- public loadOnDemand: boolean;
208
- }
209
-
210
- export interface DdtChangeEventArgs {
211
- /**
212
- * If the event is triggered by interaction, it returns true. Otherwise, it returns false.
213
- */
214
- isInteracted: boolean;
215
- /**
216
- * Returns the component previous values.
217
- */
218
- oldValue: string[];
219
- /**
220
- * Returns the updated component values.
221
- */
222
- value: string[];
223
- /**
224
- * Specifies the original event.
225
- */
226
- e: MouseEvent | KeyboardEvent;
227
- /**
228
- * Returns the root element of the component.
229
- */
230
- element: HTMLElement;
231
- }
232
-
233
- export interface DdtBeforeOpenEventArgs {
234
- /**
235
- * Determines whether the current action needs to be prevented or not.
236
- */
237
- cancel: boolean;
238
- }
239
-
240
- export interface DdtPopupEventArgs {
241
- /**
242
- * Specifies the pop-up object.
243
- */
244
- popup: Popup;
245
- }
246
-
247
- export interface DdtDataBoundEventArgs {
248
- /**
249
- * Return the DropDownTree data.
250
- */
251
- // eslint-disable-next-line
252
- data: { [key: string]: Object }[];
253
- }
254
-
255
-
256
- export interface DdtFocusEventArgs {
257
- /**
258
- * Specifies whether the element is interacted when focusing or not.
259
- */
260
- isInteracted?: boolean;
261
- /**
262
- * Specifies the original event.
263
- */
264
- event?: MouseEvent | FocusEvent | TouchEvent | KeyboardEvent;
265
- }
266
-
267
- export interface DdtFilteringEventArgs {
268
- /**
269
- * To prevent the internal filtering action.
270
- */
271
- preventDefaultAction: boolean;
272
- /**
273
- * Gets the `input` event arguments.
274
- */
275
- event: Event;
276
- /**
277
- * Determines whether the current action needs to be prevented or not.
278
- */
279
- cancel: boolean;
280
- /**
281
- * Filter text value.
282
- */
283
- text: string;
284
- /**
285
- * Gets or sets the fields of Dropdown Tree.
286
- */
287
- fields: FieldsModel;
288
- }
289
-
290
- export interface DdtSelectEventArgs {
291
- /**
292
- * Returns the name of action like select or unselect.
293
- */
294
- action: string;
295
- /**
296
- * If the event is triggered by interacting the Dropdown Tree, it returns true. Otherwise, it returns false.
297
- */
298
- isInteracted: boolean;
299
- /**
300
- * Returns the currently selected Dropdown item.
301
- */
302
- item: HTMLLIElement;
303
- /**
304
- * Return the currently selected item as JSON object from the data source.
305
- */
306
- // eslint-disable-next-line
307
- itemData: { [key: string]: Object };
308
- }
309
-
310
- export interface DdtKeyPressEventArgs {
311
- /**
312
- * If you want to cancel this event then, set cancel as true. Otherwise, false.
313
- */
314
- cancel: boolean;
315
- /**
316
- * Return the actual event.
317
- */
318
- event: KeyboardEventArgs;
319
- }
320
-
321
- /**
322
- * Configures visibility mode for component interaction when allowMultiSelection or checkbox is enabled.
323
- * ```props
324
- * Default :- On blur component will act in the delimiter mode.
325
- * Delimiter :- Selected items will be visualized in the text content.
326
- * Box :- Selected items will be visualized in chip.
327
- * Custom :- Selected items will be visualized with the given custom template value.
328
- * ```
329
- */
330
- export type Mode = 'Default' | 'Delimiter' | 'Box' | 'Custom';
331
-
332
- /**
333
- * Specifies a value that indicates whether the items are sorted in the ascending or descending order, or not sorted at all.
334
- * ```props
335
- * None :- Indicates that the nodes are not sorted.
336
- * Ascending :- Indicates that the nodes are sorted in the ascending order.
337
- * Descending :- Indicates that the nodes are sorted in the descending order.
338
- * ```
339
- */
340
- export type SortOrder = 'None' | 'Ascending' | 'Descending';
341
-
342
- /**
343
- * Specifies the expansion of tree nodes within the Dropdown Tree.
344
- * ```props
345
- * Auto :- In desktop, the expand or collapse operation happens when you double-click the node, and in mobile devices it happens on single-tap.
346
- * Click :- The expand or collapse operation happens when you perform single-click/tap on the pop-up item in both desktop and mobile devices.
347
- * DblClick :- The expand or collapse operation happens when you perform a double-click/tap on the pop-up item in both desktop and mobile devices.
348
- * None :- The expand or collapse operation will not happen when you perform single-click/tap or double-click/tap on the pop-up items in both desktop and mobile devices.
349
- * ```
350
- */
351
- export type ExpandOn = 'Auto' | 'Click' | 'DblClick' | 'None';
352
-
353
- /**
354
- * The Dropdown Tree control allows you to select single or multiple values from hierarchical data in a tree-like structure.
355
- * It has several out-of-the-box features, such as data binding, check boxes, templates, filter,
356
- * UI customization, accessibility, and preselected values.
357
- * ```html
358
- * <input type="text" id="tree"></input>
359
- * ```
360
- * ```typescript
361
- * let ddtObj: DropDownTree = new DropDownTree();
362
- * ddtObj.appendTo("#tree");
363
- * ```
364
- */
365
-
366
- @NotifyPropertyChanges
367
- export class DropDownTree extends Component<HTMLElement> implements INotifyPropertyChanged {
368
- private inputEle: HTMLInputElement;
369
- private inputObj: InputObject;
370
- private hiddenElement: HTMLSelectElement;
371
- private isReverseUpdate: boolean;
372
- private checkSelectAll: boolean;
373
- private inputWrapper: HTMLElement;
374
- private popupDiv: HTMLElement;
375
- private tree: HTMLElement;
376
- private isPopupOpen: boolean;
377
- private inputFocus: boolean;
378
- private popupObj: Popup;
379
- private treeObj: TreeView;
380
- private overAllClear: HTMLElement;
381
- private isClearButtonClick: boolean;
382
- private isDocumentClick: boolean;
383
- private isFirstRender: boolean;
384
- private hasTemplate: string | Function;
385
- private isInitialized: boolean;
386
- private treeDataType: number;
387
- private oldValue: string[];
388
- private removeValue: boolean;
389
- private currentValue: string[];
390
- private currentText: string;
391
- // eslint-disable-next-line
392
- private treeItems: { [key: string]: Object }[];
393
- private filterTimer: number = null;
394
- private filterContainer: HTMLElement;
395
- private isRemoteData: boolean;
396
- private selectedText: string[];
397
- private chipWrapper: HTMLElement;
398
- private chipCollection: HTMLElement;
399
- private isChipDelete: boolean;
400
- private checkAllParent: HTMLElement;
401
- private selectAllSpan: HTMLElement;
402
- private checkBoxElement: Element;
403
- private checkWrapper: HTMLElement;
404
- private isNodeSelected: boolean;
405
- private dataValue: string;
406
- private popupEle: HTMLElement;
407
- private isDynamicChange: boolean;
408
- private header: HTMLElement;
409
- private footer: HTMLElement;
410
- private noRecord: HTMLElement;
411
- private headerTemplateId: string;
412
- private footerTemplateId: string;
413
- private l10n: L10n;
414
- private actionFailureTemplateId: string;
415
- private customTemplateId: string;
416
- private noRecordsTemplateId: string;
417
- private isValueChange: boolean;
418
- private keyEventArgs: KeyboardEvent;
419
- private keyboardModule: KeyboardEvents;
420
- private keyConfigs: { [key: string]: string };
421
- private overFlowWrapper: HTMLElement;
422
- private isFilteredData: boolean = false;
423
- private isFilterRestore: boolean = false;
424
- // eslint-disable-next-line
425
- private treeData: { [key: string]: Object }[];
426
- // eslint-disable-next-line
427
- private selectedData: { [key: string]: Object }[] = [];
428
- private filterObj: TextBox;
429
- private filterDelayTime: number = 300;
430
- private nestedTableUpdate: { flag: boolean, fields: FieldsModel };
431
- private clearIconWidth: number;
432
- private isClicked: boolean = false;
433
- // Specifies if the checkAll method has been called
434
- private isCheckAllCalled: boolean = false;
435
- private isFromFilterChange = false;
436
-
437
- /**
438
- * Specifies the template that renders to the popup list content of the
439
- * Dropdown Tree component when the data fetch request from the remote server fails.
440
- *
441
- * @default 'The Request Failed'
442
- * @aspType string
443
- */
444
- @Property('The Request Failed')
445
- public actionFailureTemplate: string | Function;
446
-
447
- /**
448
- * When allowFiltering is set to true, it shows the filter bar (search text box) of the component.
449
- * The filter action retrieves matched items through the **filtering** event based on the characters typed in the search text box.
450
- * If no match is found, the value of the **noRecordsTemplate** property will be displayed.
451
- *
452
- * @default false
453
- */
454
- @Property(false)
455
- public allowFiltering: boolean;
456
-
457
- /**
458
- * Enables or disables the multi-selection of items. To select multiple items:
459
- * * Select the items by holding down the **Ctrl** key when clicking on the items.
460
- * * Select consecutive items by clicking the first item to select and hold down the **Shift** key and click the last item to select.
461
- *
462
- * @default false
463
- */
464
- @Property(false)
465
- public allowMultiSelection: boolean;
466
-
467
- /**
468
- * By default, the Dropdown Tree component fires the change event while focusing out the component.
469
- * If you want to fire the change event on every value selection and remove, then disable this property.
470
- *
471
- * @default true
472
- */
473
- @Property(true)
474
- public changeOnBlur: boolean;
475
-
476
- /**
477
- * Specifies the CSS classes to be added with the root and popup element of the Dropdown Tree component.
478
- * that allows customization of appearance.
479
- *
480
- * @default ''
481
- */
482
- @Property('')
483
- public cssClass: string;
484
-
485
- /**
486
- * This property is used to customize the display text of the selected items in the Dropdown Tree. The given custom template is
487
- * added to the input instead of the selected item text in the Dropdown Tree when the multi-selection or checkbox support is enabled.
488
- *
489
- * @default "${value.length} item(s) selected"
490
- * @aspType string
491
- */
492
- @Property("${value.length} item(s) selected")
493
- public customTemplate: string | Function;
494
-
495
- /**
496
- * Defines the value separator character in the input element when multi-selection or checkbox is enabled in the Dropdown Tree.
497
- * The delimiter character is applicable only for **default** and **delimiter** visibility modes.
498
- *
499
- * @default ","
500
- */
501
- @Property(',')
502
- public delimiterChar: string;
503
-
504
- /**
505
- * Specifies a value that indicates whether the Dropdown Tree component is enabled or not.
506
- *
507
- * @default true
508
- */
509
- @Property(true)
510
- public enabled: boolean;
511
-
512
- /**
513
- * Specifies the data source and mapping fields to render Dropdown Tree items.
514
- *
515
- * @default {value: 'value', text: 'text', dataSource: [], child: 'child', parentValue: 'parentValue', hasChildren: 'hasChildren',
516
- * expanded: 'expanded', htmlAttributes: 'htmlAttributes', iconCss: 'iconCss', imageUrl: 'imageUrl',
517
- * query: null, selected: 'selected', selectable: 'selectable', tableName: null, tooltip: 'tooltip' }
518
- */
519
- @Complex<FieldsModel>({}, Fields)
520
- public fields: FieldsModel;
521
-
522
- /**
523
- * Accepts the value to be displayed as a watermark text on the filter bar.
524
- *
525
- * @default null
526
- */
527
- @Property(null)
528
- public filterBarPlaceholder: string;
529
-
530
- /**
531
- * Determines on which filter type, the component needs to be considered on search action.
532
- * The **TreeFilterType** and its supported data types are,
533
- *
534
- * <table>
535
- * <tr>
536
- * <td colSpan=1 rowSpan=1><b>
537
- * TreeFilterType</b></td><td colSpan=1 rowSpan=1><b>
538
- * Description</b></td><td colSpan=1 rowSpan=1><b>
539
- * Supported Types</b></td></tr>
540
- * <tr>
541
- * <td colSpan=1 rowSpan=1>
542
- * StartsWith<br/></td><td colSpan=1 rowSpan=1>
543
- * Checks whether a value begins with the specified value.<br/></td><td colSpan=1 rowSpan=1>
544
- * String<br/></td></tr>
545
- * <tr>
546
- * <td colSpan=1 rowSpan=1>
547
- * EndsWith<br/></td><td colSpan=1 rowSpan=1>
548
- * Checks whether a value ends with the specified value.<br/></td><td colSpan=1 rowSpan=1>
549
- * String<br/></td></tr>
550
- * <tr>
551
- * <td colSpan=1 rowSpan=1>
552
- * Contains<br/></td><td colSpan=1 rowSpan=1>
553
- * Checks whether a value contains with specified value.<br/></td><td colSpan=1 rowSpan=1>
554
- * String<br/></td></tr>
555
- * </table>
556
- *
557
- * The default value set to **StartsWith**, all the suggestion items which starts with typed characters to listed in the
558
- * suggestion popup.
559
- *
560
- * @default 'StartsWith'
561
- */
562
- @Property('StartsWith')
563
- public filterType: TreeFilterType;
564
-
565
- /**
566
- * Specifies whether to display the floating label above the input element.
567
- * Possible values are:
568
- * * Never: The label will never float in the input when the placeholder is available.
569
- * * Always: The floating label will always float above the input.
570
- * * Auto: The floating label will float above the input after focusing or entering a value in the input.
571
- *
572
- * @default Syncfusion.EJ2.Inputs.FloatLabelType.Never
573
- * @isEnumeration true
574
- */
575
- @Property('Never')
576
- public floatLabelType: FloatLabelType;
577
-
578
- /**
579
- * Specifies the template that renders a customized footer container at the bottom of the pop-up list.
580
- * By default, the footerTemplate will be null and there will be no footer container for the pop-up list.
581
- *
582
- * @default null
583
- * @angularType string | object
584
- * @reactType string | function | JSX.Element
585
- * @vueType string | function
586
- * @aspType string
587
- */
588
- @Property(null)
589
- public footerTemplate: string | Function;
590
-
591
- /**
592
- * When **ignoreAccent** is set to true, then it ignores the diacritic characters or accents when filtering.
593
- */
594
- @Property(false)
595
- public ignoreAccent: boolean;
596
-
597
- /**
598
- * When set to false, consider the case-sensitive on performing the search to find suggestions. By default, consider the casing.
599
- *
600
- * @default true
601
- */
602
- @Property(true)
603
- public ignoreCase: boolean;
604
-
605
- /**
606
- * Specifies the template that renders a customized header container at the top of the pop-up list.
607
- * By default, the headerTemplate will be null and there will be no header container for the pop-up list.
608
- *
609
- * @default null
610
- * @angularType string | object
611
- * @reactType string | function | JSX.Element
612
- * @vueType string | function
613
- * @aspType string
614
- */
615
- @Property(null)
616
- public headerTemplate: string | Function;
617
-
618
- /**
619
- * Allows additional HTML attributes such as title, name, etc., and accepts n number of attributes in a key-value pair format.
620
- *
621
- * @default {}
622
- */
623
- @Property({})
624
- public htmlAttributes: { [key: string]: string; };
625
-
626
- /**
627
- * Specifies a template to render customized content for all the items.
628
- * If the **itemTemplate** property is set, the template content overrides the displayed item text.
629
- * The property accepts [template string](https://ej2.syncfusion.com/documentation/common/template-engine/)
630
- * or HTML element ID holding the content.
631
- *
632
- * @default null
633
- * @angularType string | object
634
- * @reactType string | function | JSX.Element
635
- * @vueType string | function
636
- * @aspType string
637
- */
638
- @Property(null)
639
- public itemTemplate: string | Function;
640
-
641
- /**
642
- * Configures visibility mode for component interaction when allowMultiSelection or checkbox is enabled.
643
- * Different modes are:
644
- * * Box : Selected items will be visualized in chip.
645
- * * Delimiter : Selected items will be visualized in the text content.
646
- * * Default : On focus in component will act in the box mode. On blur component will act in the delimiter mode.
647
- * * Custom : Selected items will be visualized with the given custom template value. The given custom template
648
- * is added to the input instead of the selected item text in the Dropdown Tree when the multi-selection or checkbox support is enabled.
649
- */
650
- @Property('Default')
651
- public mode: Mode;
652
-
653
- /**
654
- * Specifies the template that renders a customized pop-up list content when there is no data available
655
- * to be displayed within the pop-up.
656
- *
657
- * @default 'No Records Found'
658
- * @aspType string
659
- */
660
- @Property('No Records Found')
661
- public noRecordsTemplate: string | Function;
662
-
663
- /**
664
- * Specifies a short hint that describes the expected value of the Dropdown Tree component.
665
- *
666
- * @default null
667
- */
668
- @Property(null)
669
- public placeholder: string;
670
-
671
- /**
672
- * Specifies the height of the pop-up list.
673
- *
674
- * @default '300px'
675
- */
676
- @Property('300px')
677
- public popupHeight: string | number;
678
-
679
- /**
680
- * Specifies the width of the popup list. By default, the popup width sets based on the width of the Dropdown Tree element.
681
- *
682
- * @default '100%'
683
- */
684
- @Property('100%')
685
- public popupWidth: string | number;
686
-
687
- /**
688
- * When set to true, the user interactions on the component will be disabled.
689
- *
690
- * @default false
691
- */
692
- @Property(false)
693
- public readonly: boolean;
694
-
695
- /**
696
- * Specifies whether to show or hide the selectAll checkbox in the pop-up which allows you to select all the items in the pop-up.
697
- *
698
- * @default false
699
- */
700
- @Property(false)
701
- public showSelectAll: boolean;
702
- /**
703
- * Specifies the display text for the selectAll checkbox in the pop-up.
704
- *
705
- * @default 'Select All'
706
- */
707
- @Property('Select All')
708
- public selectAllText: string;
709
-
710
- /**
711
- * Enables or disables the checkbox option in the Dropdown Tree component.
712
- * If enabled, the Checkbox will be displayed next to the expand or collapse icon of the tree items.
713
- *
714
- * @default false
715
- */
716
- @Property(false)
717
- public showCheckBox: boolean;
718
-
719
- /**
720
- * Specifies whether to allow rendering of untrusted HTML values in the Dropdown Tree component.
721
- * While enable this property, it sanitize suspected untrusted strings and script, and update in the Dropdown Tree component.
722
- *
723
- * @default false
724
- */
725
- @Property(false)
726
- public enableHtmlSanitizer: boolean;
727
-
728
- /**
729
- * Specifies whether to show or hide the clear icon in textbox.
730
- * When the clear button is clicked, `value`, `text` properties will be reset to null.
731
- *
732
- * @default true
733
- */
734
- @Property(true)
735
- public showClearButton: boolean;
736
-
737
- /**
738
- * Specifies whether to show or hide the Dropdown button.
739
- *
740
- * @default true
741
- */
742
- @Property(true)
743
- public showDropDownIcon: boolean;
744
-
745
- /**
746
- * Specifies a value that indicates whether the items are sorted in the ascending or descending order, or not sorted at all.
747
- * The available types of sort order are,
748
- * * `None` - The items are not sorted.
749
- * * `Ascending` - The items are sorted in the ascending order.
750
- * * `Descending` - The items are sorted in the descending order.
751
- *
752
- * @default 'None'
753
- */
754
- @Property('None')
755
- public sortOrder: SortOrder;
756
-
757
- /**
758
- * Gets or sets the display text of the selected item which maps the data **text** field in the component.
759
- *
760
- * @default null
761
- */
762
- @Property(null)
763
- public text: string;
764
-
765
- /**
766
- * Configures the pop-up tree settings.
767
- *
768
- * @default {autoCheck: false, expandOn: 'Auto', loadOnDemand: false}
769
- */
770
- @Complex<TreeSettingsModel>({}, TreeSettings)
771
- public treeSettings: TreeSettingsModel;
772
-
773
- /**
774
- * Specifies the display text for the unselect all checkbox in the pop-up.
775
- *
776
- * @default 'Unselect All'
777
- */
778
- @Property('Unselect All')
779
- public unSelectAllText: string;
780
-
781
- /**
782
- * Gets or sets the value of selected item(s) which maps the data **value** field in the component.
783
- *
784
- * @default null
785
- * @aspType Object
786
- */
787
- @Property(null)
788
- public value: string[];
789
- /**
790
- * Specifies the width of the component. By default, the component width sets based on the width of its parent container.
791
- * You can also set the width in pixel values.
792
- *
793
- * @default '100%'
794
- */
795
- @Property('100%')
796
- public width: string | number;
797
-
798
- /**
799
- * Specifies the z-index value of the pop-up element.
800
- *
801
- * @default 1000
802
- */
803
- @Property(1000)
804
- public zIndex: number;
805
-
806
- /**
807
- * Defines whether to enable or disable the feature called wrap the selected items into multiple lines when the selected item's text
808
- * content exceeded the input width limit.
809
- *
810
- * @default false
811
- */
812
- @Property(false)
813
- public wrapText: boolean;
814
-
815
- /**
816
- * Triggers when the data fetch request from the remote server fails.
817
- *
818
- * @event
819
- */
820
- /* eslint-disable */
821
- @Event()
822
- public actionFailure: EmitType<Object>;
823
- /* eslint-enable */
824
-
825
- /**
826
- * Fires when popup opens before animation.
827
- *
828
- * @event
829
- */
830
- @Event()
831
- public beforeOpen: EmitType<DdtBeforeOpenEventArgs>;
832
-
833
- /**
834
- * Triggers when an item in a popup is selected or when the model value is changed by user.
835
- *
836
- * @event
837
- */
838
- @Event()
839
- public change: EmitType<DdtChangeEventArgs>;
840
- /**
841
- * Fires when popup close after animation completion.
842
- *
843
- * @event
844
- */
845
- @Event()
846
- public close: EmitType<DdtPopupEventArgs>;
847
-
848
- /**
849
- * Triggers when the Dropdown Tree input element gets focus-out.
850
- *
851
- * @event
852
- */
853
- /* eslint-disable */
854
- @Event()
855
- public blur: EmitType<Object>;
856
- /* eslint-enable */
857
- /**
858
- * Triggers when the Dropdown Tree is created successfully.
859
- *
860
- * @event
861
- */
862
- /* eslint-disable */
863
- @Event()
864
- public created: EmitType<Object>;
865
- /* eslint-enable */
866
-
867
- /**
868
-      * Triggers when data source is populated in the Dropdown Tree.
869
- *
870
-      * @event
871
-      */
872
- @Event()
873
- public dataBound: EmitType<DdtDataBoundEventArgs>;
874
-
875
- /**
876
- * Triggers when the Dropdown Tree is destroyed successfully.
877
- *
878
- * @event
879
- */
880
- /* eslint-disable */
881
- @Event()
882
- public destroyed: EmitType<Object>;
883
- /* eslint-enable */
884
-
885
- /**
886
- * Triggers on typing a character in the filter bar when the **allowFiltering** is enabled.
887
- *
888
- * @event
889
- */
890
- @Event()
891
- public filtering: EmitType<DdtFilteringEventArgs>;
892
-
893
- /**
894
- * Triggers when the Dropdown Tree input element is focused.
895
- *
896
- * @event
897
- */
898
- @Event()
899
- public focus: EmitType<DdtFocusEventArgs>;
900
-
901
- /**
902
- * Triggers when key press is successful. It helps to customize the operations at key press.
903
- *
904
- * @event
905
- */
906
- @Event()
907
- public keyPress: EmitType<DdtKeyPressEventArgs>;
908
-
909
- /**
910
- * Fires when popup opens after animation completion.
911
- *
912
- * @event
913
- */
914
- @Event()
915
- public open: EmitType<DdtPopupEventArgs>;
916
-
917
- /**
918
- * Triggers when an item in the popup is selected by the user either with mouse/tap or with keyboard navigation.
919
- *
920
- * @event
921
- */
922
- @Event()
923
- public select: EmitType<DdtSelectEventArgs>;
924
-
925
- constructor(options?: DropDownTreeModel, element?: string | HTMLElement) {
926
- super(options, <HTMLElement | string>element);
927
- }
928
-
929
- /**
930
- * Get the properties to be maintained in the persisted state.
931
- *
932
- * @returns {string}
933
- * @hidden
934
- */
935
-
936
- public getPersistData(): string {
937
- const keyEntity: string[] = ['value'];
938
- return this.addOnPersist(keyEntity);
939
- }
940
-
941
- public getLocaleName(): string {
942
- return 'drop-down-tree';
943
- }
944
-
945
- /**
946
- * Initialize the event handler.
947
- *
948
- * @returns {void}
949
- * @private
950
- */
951
- protected preRender(): void {
952
- this.inputFocus = false;
953
- this.isPopupOpen = false;
954
- this.isFirstRender = true;
955
- this.isInitialized = false;
956
- this.currentText = null;
957
- this.currentValue = null;
958
- this.oldValue = null;
959
- this.removeValue = false;
960
- this.selectedText = [];
961
- this.treeItems = [];
962
- this.dataValue = null;
963
- this.isNodeSelected = false;
964
- this.isDynamicChange = false;
965
- this.clearIconWidth = 0;
966
- this.headerTemplateId = `${this.element.id}${HEADERTEMPLATE}`;
967
- this.footerTemplateId = `${this.element.id}${FOOTERTEMPLATE}`;
968
- this.actionFailureTemplateId = `${this.element.id}${ACTIONFAILURETEMPLATE}`;
969
- this.noRecordsTemplateId = `${this.element.id}${NORECORDSTEMPLATE}`;
970
- this.customTemplateId = `${this.element.id}${CUSTOMTEMPLATE}`;
971
- this.keyConfigs = {
972
- escape: 'escape',
973
- altUp: 'alt+uparrow',
974
- altDown: 'alt+downarrow',
975
- tab: 'tab',
976
- shiftTab: 'shift+tab',
977
- end: 'end',
978
- enter: 'enter',
979
- home: 'home',
980
- moveDown: 'downarrow',
981
- moveLeft: 'leftarrow',
982
- moveRight: 'rightarrow',
983
- moveUp: 'uparrow',
984
- ctrlDown: 'ctrl+downarrow',
985
- ctrlUp: 'ctrl+uparrow',
986
- ctrlEnter: 'ctrl+enter',
987
- ctrlHome: 'ctrl+home',
988
- ctrlEnd: 'ctrl+end',
989
- shiftDown: 'shift+downarrow',
990
- shiftUp: 'shift+uparrow',
991
- shiftEnter: 'shift+enter',
992
- shiftHome: 'shift+home',
993
- shiftEnd: 'shift+end',
994
- csDown: 'ctrl+shift+downarrow',
995
- csUp: 'ctrl+shift+uparrow',
996
- csEnter: 'ctrl+shift+enter',
997
- csHome: 'ctrl+shift+home',
998
- csEnd: 'ctrl+shift+end',
999
- space: 'space',
1000
- ctrlA: 'ctrl+A'
1001
- };
1002
- }
1003
-
1004
- /**
1005
- * To Initialize the control rendering
1006
- *
1007
- * @private
1008
- * @returns {void}
1009
- */
1010
- public render(): void {
1011
- const isTree: Element = select('#' + this.element.id + '_tree', document);
1012
- if (isTree) {
1013
- const popupDiv: Element = select('#' + this.element.id + '_options', document);
1014
- detach(popupDiv ? popupDiv : isTree.parentElement);
1015
- }
1016
- if (this.element.tagName === 'INPUT') {
1017
- this.inputEle = this.element as HTMLInputElement;
1018
- if (isNOU(this.inputEle.getAttribute('role'))) {
1019
- this.inputEle.setAttribute('aria-expanded', 'false');
1020
- this.inputEle.setAttribute('role', 'combobox');
1021
- this.inputEle.setAttribute('aria-haspopup', 'tree');
1022
- this.inputEle.setAttribute('aria-controls', this.element.id + "_options");
1023
- }
1024
- if (isNOU(this.inputEle.getAttribute('type'))) {
1025
- this.inputEle.setAttribute('type', 'text');
1026
- }
1027
- } else {
1028
- this.inputEle = this.createElement('input', { attrs: { role: 'textbox', type: 'text' } }) as HTMLInputElement;
1029
- this.element.parentElement.insertBefore(this.inputEle, this.element);
1030
- }
1031
- this.inputObj = Input.createInput(
1032
- {
1033
- element: this.inputEle,
1034
- floatLabelType: this.floatLabelType,
1035
- buttons: this.showDropDownIcon ? [DROPDOWNICON] : null,
1036
- properties: {
1037
- readonly: true,
1038
- placeholder: this.placeholder,
1039
- enabled: this.enabled,
1040
- cssClass: this.cssClass,
1041
- enableRtl: this.enableRtl
1042
- }
1043
- },
1044
- this.createElement
1045
- );
1046
- this.inputWrapper = this.inputObj.container;
1047
- if (!this.inputWrapper.classList.contains(INPUTGROUP)) {
1048
- this.inputWrapper.classList.add(INPUTGROUP);
1049
- }
1050
- if (this.showDropDownIcon) {
1051
- this.inputWrapper.classList.add(SHOW_DD_ICON);
1052
- }
1053
- if (this.element.tagName === this.getDirective()) {
1054
- this.element.appendChild(this.inputWrapper);
1055
- }
1056
- this.createHiddenElement();
1057
- this.createClearIcon();
1058
- this.inputWrapper.classList.add(DROPDOWNTREE);
1059
- this.setElementWidth(this.width);
1060
- this.updateDataAttribute();
1061
- this.setHTMLAttributes();
1062
- this.setAttributes();
1063
- this.popupDiv = this.createElement('div', { className: CONTENT });
1064
- this.popupDiv.classList.add(DROPDOWN);
1065
- this.tree = this.createElement('div', { id: this.element.id + '_tree' });
1066
- this.popupDiv.appendChild(this.tree);
1067
- document.body.appendChild(this.popupDiv);
1068
- this.wireTreeEvents();
1069
- addClass([this.popupDiv], DDTHIDEICON);
1070
- this.renderTree();
1071
- this.isRemoteData = this.fields.dataSource instanceof DataManager;
1072
- if (this.allowMultiSelection || this.showCheckBox) {
1073
- if (this.mode !== 'Delimiter') {
1074
- this.createChip();
1075
- }
1076
- if (!this.wrapText && this.mode !== 'Custom') {
1077
- this.overFlowWrapper = this.createElement('span', { className: OVERFLOW_VIEW + ' ' + HIDEICON });
1078
- this.inputWrapper.insertBefore(this.overFlowWrapper, this.hiddenElement);
1079
- if (this.mode !== 'Box') {
1080
- addClass([this.overFlowWrapper], SHOW_TEXT);
1081
- }
1082
- }
1083
- }
1084
- if (!this.isRemoteData) {
1085
- this.setTreeValue();
1086
- this.setTreeText();
1087
- this.updateHiddenValue();
1088
- this.setSelectedValue();
1089
- if (!this.wrapText ) {
1090
- this.updateView();
1091
- }
1092
- }
1093
- this.wireEvents();
1094
- const firstUl: Element = select('.' + PARENTITEM, this.treeObj.element);
1095
- if (firstUl && firstUl.getAttribute('aria-multiselectable')) {
1096
- firstUl.removeAttribute('aria-multiselectable');
1097
- }
1098
- this.oldValue = this.value;
1099
- this.isInitialized = true;
1100
- this.hasTemplate = this.itemTemplate || this.headerTemplate || this.footerTemplate || this.actionFailureTemplate
1101
- || this.noRecordsTemplate || this.customTemplate;
1102
- this.renderComplete();
1103
- }
1104
-
1105
- private hideCheckAll(flag: boolean): void {
1106
- const checkAllEle : HTMLElement = !isNOU(this.popupEle) ? (this.popupEle.querySelector('.' + CHECKALLPARENT) as HTMLElement) : null;
1107
- if (!isNOU(checkAllEle)) {
1108
- if (flag && !checkAllEle.classList.contains(CHECKALLHIDE)) {
1109
- addClass([checkAllEle], CHECKALLHIDE);
1110
- } else if (!flag && checkAllEle.classList.contains(CHECKALLHIDE)) {
1111
- removeClass([checkAllEle], CHECKALLHIDE);
1112
- }
1113
- }
1114
- }
1115
-
1116
- private renderFilter(): void {
1117
- this.filterContainer = this.createElement('div', {
1118
- id: this.element.id + '_filter_wrap',
1119
- className: FILTERWRAP
1120
- });
1121
- const filterInput: HTMLElement = this.createElement('input', {
1122
- id: this.element.id + '_filter',
1123
- attrs: { autocomplete: 'off', 'aria-label': this.filterBarPlaceholder }
1124
- });
1125
- this.filterContainer.appendChild(filterInput);
1126
- prepend([this.filterContainer], this.popupEle);
1127
- this.filterObj = new TextBox({
1128
- value: '',
1129
- showClearButton: true,
1130
- placeholder: this.filterBarPlaceholder,
1131
- input: this.filterChangeHandler.bind(this)
1132
- });
1133
- this.filterObj.appendTo('#' + this.element.id + '_filter');
1134
- }
1135
- private filterChangeHandler(args?: InputEventArgs): void {
1136
- if (!isNOU(args.value)) {
1137
- window.clearTimeout(this.filterTimer);
1138
- this.filterTimer = window.setTimeout(() => { this.filterHandler(args.value, args.event); }, this.filterDelayTime);
1139
- }
1140
- }
1141
-
1142
- private filterHandler(value: string, event: Event): void {
1143
- this.isFromFilterChange = true;
1144
- if (!this.isFilteredData) { this.treeData = this.treeObj.getTreeData(); }
1145
- const filterFields: FieldsModel = this.cloneFields(this.fields);
1146
- const args: DdtFilteringEventArgs = {
1147
- cancel: false,
1148
- preventDefaultAction: false,
1149
- event: event,
1150
- text: value,
1151
- fields: filterFields
1152
- };
1153
- this.trigger('filtering', args, (args: DdtFilteringEventArgs) => {
1154
- if (!args.cancel) {
1155
- let flag: boolean = false;
1156
- let fields: FieldsModel;
1157
- this.isFilteredData = true;
1158
- if (value === '') {
1159
- this.isFilteredData = false;
1160
- this.isFilterRestore = true;
1161
- fields = this.cloneFields(this.fields);
1162
- } else if (args.preventDefaultAction) {
1163
- fields = args.fields;
1164
- } else {
1165
- if (this.treeDataType === 1) {
1166
- fields = this.selfReferencefilter(value, args.fields);
1167
- } else {
1168
- if (this.fields.dataSource instanceof DataManager) {
1169
- flag = true;
1170
- } else {
1171
- fields = this.nestedFilter(value, args.fields);
1172
- }
1173
- }
1174
- }
1175
- this.hideCheckAll(this.isFilteredData);
1176
- if (flag) { return; }
1177
- this.treeObj.fields = this.getTreeFields(fields);
1178
- this.treeObj.dataBind();
1179
- if (this.hasTemplate && (this as any).portals && (this.treeObj as any).portals) {
1180
- for (let i: number = 0; i < (this.treeObj as any).portals.length; i++) {
1181
- if ((this as any).portals.indexOf((this.treeObj as any).portals[i as number]) == -1) {
1182
- (this as any).portals.push((this.treeObj as any).portals[i as number]);
1183
- }
1184
- }
1185
- if ((this as any).isReact) {
1186
- this.renderReactTemplates();
1187
- }
1188
- }
1189
- }
1190
- });
1191
- }
1192
-
1193
- private nestedFilter(value: string, filteredFields: FieldsModel): FieldsModel {
1194
- // eslint-disable-next-line
1195
- const matchedDataSource: { [key: string]: Object }[] = [];
1196
- for (let i: number = 0; i < this.treeData.length; i++) {
1197
- // eslint-disable-next-line
1198
- const filteredChild: { [key: string]: Object } = this.nestedChildFilter(value, this.treeData[i]);
1199
- if (!isNOU(filteredChild)) { matchedDataSource.push(filteredChild); }
1200
- }
1201
- filteredFields.dataSource = matchedDataSource;
1202
- return filteredFields;
1203
- }
1204
-
1205
- // eslint-disable-next-line
1206
- private nestedChildFilter(value: string, node: { [key: string]: Object }): { [key: string]: Object } {
1207
- // eslint-disable-next-line
1208
- const children: { [key: string]: Object }[] = <{ [key: string]: Object }[]>node[this.fields.child as string];
1209
- if (isNOU(children)) {
1210
- return (this.isMatchedNode(value, node)) ? node : null;
1211
- } else {
1212
- // eslint-disable-next-line
1213
- const matchedChildren: { [key: string]: Object }[] = [];
1214
- for (let i: number = 0; i < children.length; i++) {
1215
- // eslint-disable-next-line
1216
- const filteredChild: { [key: string]: Object } = this.nestedChildFilter(value, children[i]);
1217
- if (!isNOU(filteredChild)) { matchedChildren.push(filteredChild); }
1218
- }
1219
- let filteredItems: any = (<any>Object).assign({}, node);
1220
- if (matchedChildren.length !== 0) {
1221
- filteredItems[this.fields.child as string] = matchedChildren;
1222
- return filteredItems;
1223
- } else {
1224
- filteredItems[this.fields.child as string] = null;
1225
- return (this.isMatchedNode(value, filteredItems)) ? filteredItems : null;
1226
- }
1227
- }
1228
- }
1229
-
1230
- private selfReferencefilter(value: string, filteredFields: FieldsModel): FieldsModel {
1231
- // eslint-disable-next-line
1232
- const matchedData: { [key: string]: Object }[] = [];
1233
- // eslint-disable-next-line
1234
- const matchedDataSource: { [key: string]: Object }[] = [];
1235
- for (let i: number = 0; i < this.treeData.length; i++) {
1236
- if (this.isMatchedNode(value, this.treeData[i as number])) {
1237
- matchedData.push(this.treeData[i as number]);
1238
- }
1239
- }
1240
- for (let i: number = 0; i < matchedData.length; i++) {
1241
- if (matchedDataSource.indexOf(matchedData[i as number]) === -1) {
1242
- matchedDataSource.push(matchedData[i as number]);
1243
- // eslint-disable-next-line
1244
- let parentId: object = matchedData[i][this.fields.parentValue];
1245
- while (!isNOU(parentId)) {
1246
- // eslint-disable-next-line
1247
- let parent: { [key: string]: Object } = null;
1248
- for (let j: number = 0; j < this.treeData.length; j++) {
1249
- // eslint-disable-next-line
1250
- const value: object = this.treeData[j][this.fields.value];
1251
- if (!isNOU(value) && (value === parentId)) {
1252
- parent = this.treeData[j as number];
1253
- break;
1254
- }
1255
- }
1256
- if (!isNOU(parent) && (matchedDataSource.indexOf(parent) === -1)) {
1257
- matchedDataSource.push(parent);
1258
- parentId = parent[this.fields.parentValue];
1259
- } else {
1260
- break;
1261
- }
1262
- }
1263
- }
1264
- }
1265
- filteredFields.dataSource = matchedDataSource;
1266
- return filteredFields;
1267
- }
1268
-
1269
- // eslint-disable-next-line
1270
- private isMatchedNode(value: string, node: { [key: string]: Object }): boolean {
1271
- let checkValue: string = node[this.fields.text] as string;
1272
- if (this.ignoreCase) {
1273
- checkValue = checkValue.toLowerCase();
1274
- value = value.toLowerCase();
1275
- }
1276
- if (this.ignoreAccent) {
1277
- checkValue = DataUtil.ignoreDiacritics(checkValue) as string;
1278
- value = DataUtil.ignoreDiacritics(value) as string;
1279
- }
1280
- if (this.filterType === 'StartsWith') {
1281
- return checkValue.slice(0, value.length) === value;
1282
- } else if (this.filterType === 'EndsWith') {
1283
- return checkValue.slice(-value.length) === value;
1284
- } else {
1285
- return checkValue.indexOf(value) !== -1;
1286
- }
1287
- }
1288
-
1289
- /* To wire events for the dropdown tree */
1290
- private wireEvents(): void {
1291
- EventHandler.add(this.inputWrapper, 'mouseup', this.dropDownClick, this);
1292
- EventHandler.add(this.inputWrapper, 'focus', this.focusIn, this);
1293
- EventHandler.add(this.inputWrapper, 'blur', this.focusOut, this);
1294
- EventHandler.add(this.inputWrapper, 'mousemove', this.mouseIn, this);
1295
- EventHandler.add(this.inputWrapper, 'mouseout', this.onMouseLeave, this);
1296
- EventHandler.add(this.overAllClear, 'mousedown', this.clearAll, this);
1297
- EventHandler.add(<HTMLElement & Window><unknown>window, 'resize', this.windowResize, this);
1298
- const formElement: HTMLFormElement = closest(this.inputWrapper, 'form') as HTMLFormElement;
1299
- if (formElement) {
1300
- EventHandler.add(formElement, 'reset', this.resetValueHandler, this);
1301
- }
1302
- this.keyboardModule = new KeyboardEvents(
1303
- this.inputWrapper,
1304
- {
1305
- keyAction: this.keyActionHandler.bind(this),
1306
- keyConfigs: this.keyConfigs,
1307
- eventName: 'keydown'
1308
- }
1309
- );
1310
- }
1311
-
1312
- private wireTreeEvents(): void {
1313
- this.keyboardModule = new KeyboardEvents(
1314
- this.tree,
1315
- {
1316
- keyAction: this.treeAction.bind(this),
1317
- keyConfigs: this.keyConfigs,
1318
- eventName: 'keydown'
1319
- }
1320
- );
1321
- }
1322
-
1323
- private wireCheckAllWrapperEvents(): void {
1324
- this.keyboardModule = new KeyboardEvents(
1325
- this.checkAllParent,
1326
- {
1327
- keyAction: this.checkAllAction.bind(this),
1328
- keyConfigs: this.keyConfigs,
1329
- eventName: 'keydown'
1330
- }
1331
- );
1332
- }
1333
-
1334
- /* To unwire events for the dropdown tree */
1335
- private unWireEvents(): void {
1336
- EventHandler.remove(this.inputWrapper, 'mouseup', this.dropDownClick);
1337
- EventHandler.remove(this.inputWrapper, 'focus', this.focusIn);
1338
- EventHandler.remove(this.inputWrapper, 'blur', this.focusOut);
1339
- EventHandler.remove(this.inputWrapper, 'mousemove', this.mouseIn);
1340
- EventHandler.remove(this.inputWrapper, 'mouseout', this.onMouseLeave);
1341
- EventHandler.remove(this.overAllClear, 'mousedown', this.clearAll);
1342
- EventHandler.remove(<HTMLElement & Window><unknown>window, 'resize', this.windowResize);
1343
- const formElement: HTMLFormElement = closest(this.inputWrapper, 'form') as HTMLFormElement;
1344
- if (formElement) {
1345
- EventHandler.remove(formElement, 'reset', this.resetValueHandler);
1346
- }
1347
- }
1348
-
1349
- /* Trigger when the dropdown is clicked */
1350
- private dropDownClick(e: MouseEvent): void {
1351
- if (!this.enabled || this.readonly) {
1352
- return;
1353
- }
1354
- if (this.isClearButtonClick) {
1355
- this.isClearButtonClick = false;
1356
- return;
1357
- }
1358
- if (this.isPopupOpen) {
1359
- this.hidePopup();
1360
- } else {
1361
- this.focusIn(e);
1362
- this.renderPopup();
1363
- }
1364
- this.showOverAllClear();
1365
- }
1366
-
1367
- private mouseIn(): void {
1368
- if (this.enabled || !this.readonly) {
1369
- this.showOverAllClear();
1370
- }
1371
- }
1372
-
1373
- private onMouseLeave(): void {
1374
- if (!this.inputFocus) {
1375
- addClass([this.overAllClear], HIDEICON);
1376
- removeClass([this.inputWrapper], SHOW_CLEAR);
1377
- }
1378
- }
1379
-
1380
- protected getDirective(): string {
1381
- return 'EJS-DROPDOWNTREE';
1382
- }
1383
-
1384
- private focusOut(e: MouseEvent): void {
1385
- if (!this.enabled || this.readonly || !this.inputFocus) {
1386
- return;
1387
- }
1388
- if ((Browser.isIE || Browser.info.name === 'edge') && (e.target === this.inputWrapper)) {
1389
- return;
1390
- }
1391
- const target: HTMLElement = <HTMLElement>e.relatedTarget;
1392
- if ((target !== this.inputEle) && (isNOU(target)) && (e.target !== this.inputWrapper || !this.isPopupOpen)) {
1393
- this.onFocusOut(e);
1394
- }
1395
- }
1396
-
1397
- private onFocusOut(event?: MouseEvent): void {
1398
- this.inputFocus = false;
1399
- if (this.isPopupOpen) {
1400
- this.hidePopup();
1401
- }
1402
- if (this.isClearButtonClick) {
1403
- this.isClearButtonClick = false;
1404
- }
1405
- if (this.showClearButton) {
1406
- this.clearIconWidth = (<HTMLElement>select('.e-clear-icon', this.inputWrapper)).offsetWidth;
1407
- addClass([this.overAllClear], HIDEICON);
1408
- removeClass([this.inputWrapper], SHOW_CLEAR);
1409
- }
1410
- removeClass([this.inputWrapper], [INPUTFOCUS]);
1411
- if ((this.allowMultiSelection || this.showCheckBox)) {
1412
- const isValue: boolean = this.value ? (this.value.length ? true : false) : false;
1413
- if (this.mode !== 'Delimiter' && this.mode !== 'Custom') {
1414
- if (this.chipWrapper && (this.mode === 'Default')) {
1415
- addClass([this.chipWrapper], HIDEICON);
1416
- removeClass([this.inputWrapper], SHOW_CHIP);
1417
- removeClass([this.inputEle], CHIP_INPUT);
1418
- }
1419
- }
1420
- if (!this.wrapText && isValue) {
1421
- this.updateView();
1422
- }
1423
- }
1424
- if (this.changeOnBlur) {
1425
- this.triggerChangeEvent(event);
1426
- }
1427
- this.removeValue = false;
1428
- this.oldValue = this.value;
1429
- this.trigger('blur');
1430
- }
1431
-
1432
- private updateView(): void {
1433
- if ((!this.showCheckBox && !this.allowMultiSelection) || this.mode === 'Custom' || this.inputFocus) {
1434
- return;
1435
- }
1436
- if (this.mode !== 'Box') {
1437
- addClass([this.inputWrapper, this.overFlowWrapper], SHOW_TEXT);
1438
- } else {
1439
- addClass([this.inputWrapper], SHOW_CHIP);
1440
- }
1441
- if (this.value && this.value.length !== 0) {
1442
- if (this.inputWrapper.contains(this.chipWrapper)) {
1443
- addClass([this.chipWrapper], HIDEICON);
1444
- }
1445
- addClass([this.inputEle], CHIP_INPUT);
1446
- this.updateOverFlowView();
1447
- this.ensurePlaceHolder();
1448
- }
1449
- }
1450
-
1451
- private triggerChangeEvent(event?: MouseEvent | KeyboardEvent): void {
1452
- const isEqual: boolean = this.ddtCompareValues(this.oldValue, this.value);
1453
- if ((!isEqual || this.isChipDelete) && !this.removeValue) {
1454
- const eventArgs: DdtChangeEventArgs = {
1455
- e: event,
1456
- oldValue: this.oldValue,
1457
- value: this.value,
1458
- isInteracted: event ? true : false,
1459
- element: this.element
1460
- };
1461
- this.trigger('change', eventArgs);
1462
- this.oldValue = this.value;
1463
- }
1464
- }
1465
-
1466
- private ddtCompareValues(oldValue: string[], newValue: string[]): boolean {
1467
- if (oldValue === null || newValue === null ) {
1468
- const isValid: boolean = oldValue === null ? ((newValue === oldValue) ? true : false) :
1469
- (oldValue.length === 0 ? (newValue === oldValue) : false);
1470
- return isValid;
1471
- } else if (oldValue.length !== newValue.length) {
1472
- return false;
1473
- }
1474
- for (let i: number = 0; i < oldValue.length; i++) {
1475
- if (oldValue[i as number] !== newValue[i as number]) {
1476
- return false;
1477
- }
1478
- }
1479
- return true;
1480
- }
1481
-
1482
- private focusIn(e?: FocusEvent | MouseEvent | KeyboardEvent | TouchEvent): void {
1483
- if (!this.enabled || this.readonly || this.inputFocus) {
1484
- return;
1485
- }
1486
- this.showOverAllClear();
1487
- this.inputFocus = true;
1488
- addClass([this.inputWrapper], [INPUTFOCUS]);
1489
- if (this.allowMultiSelection || this.showCheckBox) {
1490
- if (this.mode !== 'Delimiter' && this.inputFocus) {
1491
- if (this.chipWrapper && (this.value && this.value.length !== 0)) {
1492
- removeClass([this.chipWrapper], HIDEICON);
1493
- addClass([this.inputEle], CHIP_INPUT);
1494
- }
1495
- addClass([this.inputWrapper], SHOW_CHIP);
1496
- if (this.popupObj) {
1497
- this.popupObj.refreshPosition();
1498
- }
1499
- }
1500
- if (!this.wrapText && this.mode !== 'Custom') {
1501
- if (this.inputWrapper.contains(this.overFlowWrapper)) {
1502
- addClass([this.overFlowWrapper], HIDEICON);
1503
- }
1504
- if (this.mode === 'Delimiter') {
1505
- removeClass([this.inputWrapper], SHOW_CHIP);
1506
- removeClass([this.inputEle], CHIP_INPUT);
1507
- } else {
1508
- addClass([this.inputWrapper], SHOW_CHIP);
1509
- }
1510
- removeClass([this.inputWrapper], SHOW_TEXT);
1511
- this.ensurePlaceHolder();
1512
- }
1513
- }
1514
- const args: DdtFocusEventArgs = { isInteracted: e ? true : false, event: e };
1515
- this.trigger('focus', args);
1516
- }
1517
-
1518
- private treeAction(e: KeyboardEventArgs): void {
1519
- const eventArgs: DdtKeyPressEventArgs = {
1520
- cancel: false,
1521
- event: e
1522
- };
1523
- this.trigger('keyPress', eventArgs, (observedArgs: DdtKeyPressEventArgs) => {
1524
- if (!observedArgs.cancel) {
1525
- switch (e.action) {
1526
- case 'escape':
1527
- case 'altUp':
1528
- this.inputWrapper.focus();
1529
- e.preventDefault();
1530
- if (this.isPopupOpen) {
1531
- this.hidePopup();
1532
- }
1533
- break;
1534
- case 'tab':
1535
- case 'shiftTab':
1536
- if (this.isPopupOpen) {
1537
- this.hidePopup();
1538
- }
1539
- break;
1540
- case 'enter':
1541
- case 'ctrlEnter':
1542
- case 'shiftEnter':
1543
- case 'csEnter':
1544
- if (!this.showCheckBox) {
1545
- this.isValueChange = true;
1546
- this.keyEventArgs = e;
1547
- }
1548
- break;
1549
- case 'space':
1550
- this.isValueChange = true;
1551
- this.keyEventArgs = e;
1552
- break;
1553
- case 'ctrlA':
1554
- if (this.allowMultiSelection) {
1555
- this.selectAll(true);
1556
- }
1557
- break;
1558
- case 'moveRight':
1559
- case 'moveLeft':
1560
- case 'shiftDown':
1561
- case 'moveDown':
1562
- case 'ctrlDown':
1563
- case 'csDown':
1564
- case 'shiftUp':
1565
- case 'moveUp':
1566
- case 'ctrlUp':
1567
- case 'csUp':
1568
- case 'home':
1569
- case 'shiftHome':
1570
- case 'ctrlHome':
1571
- case 'csHome':
1572
- case 'end':
1573
- case 'shiftEnd':
1574
- case 'ctrlEnd':
1575
- case 'csEnd':
1576
- }
1577
- } else {
1578
- e.stopImmediatePropagation();
1579
- }
1580
- });
1581
- }
1582
-
1583
- private keyActionHandler(e: KeyboardEventArgs): void {
1584
- const eventArgs: DdtKeyPressEventArgs = {
1585
- cancel: false,
1586
- event: e
1587
- };
1588
- this.trigger('keyPress', eventArgs, (observedArgs: DdtKeyPressEventArgs) => {
1589
- if (!observedArgs.cancel) {
1590
- switch (e.action) {
1591
- case 'escape':
1592
- case 'altUp':
1593
- if (this.isPopupOpen) {
1594
- this.hidePopup();
1595
- }
1596
- break;
1597
- case 'shiftTab':
1598
- case 'tab':
1599
- if (this.isPopupOpen) {
1600
- this.hidePopup();
1601
- }
1602
- if (this.inputFocus) {
1603
- this.onFocusOut();
1604
- }
1605
- break;
1606
- case 'altDown':
1607
- if (!this.isPopupOpen) {
1608
- this.showPopup();
1609
- e.preventDefault();
1610
- }
1611
- break;
1612
- case 'moveDown':
1613
- if (this.showSelectAll && this.showCheckBox) {
1614
- this.checkAllParent.focus();
1615
- }
1616
- break;
1617
- }
1618
- }
1619
- });
1620
- }
1621
-
1622
- private checkAllAction(e: KeyboardEventArgs): void {
1623
- const eventArgs: DdtKeyPressEventArgs = {
1624
- cancel: false,
1625
- event: e
1626
- };
1627
- this.trigger('keyPress', eventArgs, (observedArgs: DdtKeyPressEventArgs) => {
1628
- if (!observedArgs.cancel) {
1629
- switch (e.action) {
1630
- case 'space':
1631
- this.clickHandler(e);
1632
- break;
1633
- case 'moveDown':
1634
- let focusedElement: HTMLElement= this.treeObj.element.querySelector('li');
1635
- focusedElement.focus();
1636
- addClass([focusedElement], ['e-node-focus']);
1637
- }
1638
- }
1639
- });
1640
- }
1641
-
1642
- private windowResize(): void {
1643
- if (this.popupObj) {
1644
- this.popupObj.setProperties({ width: this.setWidth() });
1645
- this.popupObj.refreshPosition();
1646
- }
1647
- }
1648
-
1649
- private resetValueHandler(e: Event): void {
1650
- const formElement: HTMLFormElement = closest(this.inputWrapper, 'form') as HTMLFormElement;
1651
- if (formElement && e.target === formElement) {
1652
- this.isDynamicChange = true;
1653
- this.setProperties({ value: null }, true);
1654
- this.resetValue(true);
1655
- this.isDynamicChange = false;
1656
- }
1657
- }
1658
-
1659
- protected getAriaAttributes(): { [key: string]: string } {
1660
- return {
1661
- };
1662
- }
1663
-
1664
- private updateOverFlowView(): void {
1665
- this.overFlowWrapper.classList.remove(TOTAL_COUNT_WRAPPER);
1666
- removeClass([this.overFlowWrapper], HIDEICON);
1667
- if (this.value && this.value.length) {
1668
- let data: string = ''; let overAllContainer: number;
1669
- let temp: string; let tempData: string;
1670
- let tempIndex: number = 1; let wrapperleng: number;
1671
- let remaining: number; let downIconWidth: number = 0;
1672
- this.overFlowWrapper.innerHTML = '';
1673
- // eslint-disable-next-line
1674
- const l10nLocale: Object = { overflowCountTemplate: '+${count} more..', totalCountTemplate: '${count} selected' };
1675
- this.l10n = new L10n(this.getLocaleName(), l10nLocale, this.locale);
1676
- const remainContent: string = this.l10n.getConstant('overflowCountTemplate');
1677
- const totalContent: string = this.l10n.getConstant('totalCountTemplate');
1678
- const remainElement: HTMLElement = this.createElement('span', { className: REMAIN_WRAPPER });
1679
- this.overFlowWrapper.appendChild(remainElement);
1680
- remainElement.innerText = remainContent.replace('${count}',this.value.length.toString());
1681
- const remainSize: number = remainElement.offsetWidth;
1682
- remove(remainElement);
1683
- if (this.showDropDownIcon) {
1684
- downIconWidth = (<HTMLElement>select('.' + DDTICON, this.inputWrapper)).offsetWidth;
1685
- }
1686
- if (!isNOU(this.value)) {
1687
- if (this.mode !== 'Box') {
1688
- for (let index: number = 0; !isNOU(this.value[index as number]); index++) {
1689
- data += (index === 0) ? '' : this.delimiterChar + ' ';
1690
- temp = this.getOverflowVal(index);
1691
- data += temp;
1692
- temp = this.overFlowWrapper.innerHTML;
1693
- if (this.enableHtmlSanitizer) {
1694
- this.overFlowWrapper.innerText = SanitizeHtmlHelper.sanitize(data);
1695
- }
1696
- else { this.overFlowWrapper.innerHTML = data; }
1697
- wrapperleng = this.overFlowWrapper.offsetWidth;
1698
- overAllContainer = this.inputWrapper.offsetWidth;
1699
- if ((wrapperleng + downIconWidth + this.clearIconWidth) > overAllContainer) {
1700
- if (tempData !== undefined && tempData !== '') {
1701
- temp = tempData;
1702
- index = tempIndex + 1;
1703
- }
1704
- this.overFlowWrapper.innerHTML = temp;
1705
- remaining = this.value.length - index;
1706
- wrapperleng = this.overFlowWrapper.offsetWidth;
1707
- while (((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) >= overAllContainer)
1708
- && wrapperleng !== 0 && this.overFlowWrapper.innerHTML !== '') {
1709
- const textArr: string[] = this.overFlowWrapper.innerHTML.split(this.delimiterChar);
1710
- textArr.pop();
1711
- this.overFlowWrapper.innerHTML = textArr.join(this.delimiterChar);
1712
- remaining++;
1713
- wrapperleng = this.overFlowWrapper.offsetWidth;
1714
- }
1715
- break;
1716
- } else if ((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) <= overAllContainer) {
1717
- tempData = data; tempIndex = index;
1718
- } else if (index === 0) { tempData = ''; tempIndex = -1; }
1719
- }
1720
- } else {
1721
- addClass([this.chipWrapper], HIDEICON);
1722
- const ele: HTMLElement = <HTMLElement>(this.chipWrapper as Node).cloneNode(true);
1723
- const chips: HTMLElement[] = selectAll('.' + CHIP, ele);
1724
- for (let i: number = 0; i < chips.length; i++) {
1725
- temp = this.overFlowWrapper.innerHTML;
1726
- this.overFlowWrapper.appendChild(chips[i as number]);
1727
- data = this.overFlowWrapper.innerHTML;
1728
- wrapperleng = this.overFlowWrapper.offsetWidth;
1729
- overAllContainer = this.inputWrapper.offsetWidth;
1730
- if ((wrapperleng + downIconWidth + this.clearIconWidth) > overAllContainer) {
1731
- if (tempData !== undefined && tempData !== '') {
1732
- temp = tempData; i = tempIndex + 1;
1733
- }
1734
- this.overFlowWrapper.innerHTML = temp;
1735
- remaining = this.value.length - i;
1736
- wrapperleng = this.overFlowWrapper.offsetWidth;
1737
- while (((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) >= overAllContainer)
1738
- && wrapperleng !== 0 && this.overFlowWrapper.innerHTML !== '') {
1739
- this.overFlowWrapper.removeChild( this.overFlowWrapper.lastChild);
1740
- remaining++;
1741
- wrapperleng = this.overFlowWrapper.offsetWidth;
1742
- }
1743
- break;
1744
- } else if ((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) <= overAllContainer) {
1745
- tempData = data; tempIndex = i;
1746
- } else if (i === 0) {
1747
- tempData = ''; tempIndex = -1;
1748
- }
1749
- }
1750
- }
1751
- }
1752
- if (remaining > 0) {
1753
- this.overFlowWrapper.appendChild(
1754
- this.updateRemainTemplate(remainElement, remaining, remainContent, totalContent)
1755
- );
1756
- }
1757
- if (this.mode === 'Box' && !this.overFlowWrapper.classList.contains(TOTAL_COUNT_WRAPPER)) {
1758
- addClass([remainElement], REMAIN_COUNT);
1759
- }
1760
- } else {
1761
- this.overFlowWrapper.innerHTML = '';
1762
- addClass([this.overFlowWrapper], HIDEICON);
1763
- }
1764
- this.updateDelimMode();
1765
- }
1766
-
1767
- private updateRemainTemplate(
1768
- remainElement: HTMLElement,
1769
- remaining: number,
1770
- remainContent: string,
1771
- totalContent: string): HTMLElement {
1772
- if (this.overFlowWrapper.firstChild && this.overFlowWrapper.firstChild.nodeType === 3 &&
1773
- this.overFlowWrapper.firstChild.nodeValue === '') {
1774
- this.overFlowWrapper.removeChild(this.overFlowWrapper.firstChild);
1775
- }
1776
- remainElement.innerHTML = '';
1777
- remainElement.innerText = (this.overFlowWrapper.firstChild && (this.overFlowWrapper.firstChild.nodeType === 3 || this.mode === 'Box')) ?
1778
- remainContent.replace('${count}', remaining.toString()) : totalContent.replace('${count}', remaining.toString());
1779
- if (this.overFlowWrapper.firstChild && (this.overFlowWrapper.firstChild.nodeType === 3 || this.mode === 'Box')) {
1780
- removeClass([this.overFlowWrapper], TOTAL_COUNT_WRAPPER);
1781
- } else {
1782
- addClass([this.overFlowWrapper], TOTAL_COUNT_WRAPPER);
1783
- removeClass([this.overFlowWrapper], REMAIN_COUNT);
1784
- }
1785
- return remainElement;
1786
- }
1787
-
1788
- private getOverflowVal(index: number): string {
1789
- // eslint-disable-next-line
1790
- const selectedData: { [key: string]: Object } = this.getSelectedData(this.value[index]);
1791
- return getValue(this.treeSettings.loadOnDemand ? this.fields.text : 'text', selectedData);
1792
- }
1793
-
1794
- private updateDelimMode(): void {
1795
- if (this.mode !== 'Box') {
1796
- if (select('.' + REMAIN_WRAPPER, this.overFlowWrapper) && !this.overFlowWrapper.classList.contains(TOTAL_COUNT_WRAPPER)) {
1797
- addClass([this.overFlowWrapper], REMAIN_COUNT);
1798
- addClass([this.overFlowWrapper], SHOW_TEXT);
1799
- } else {
1800
- this.overFlowWrapper.classList.remove(REMAIN_COUNT);
1801
- removeClass([this.overFlowWrapper], REMAIN_COUNT);
1802
- }
1803
- } else if (select('.' + REMAIN_WRAPPER, this.overFlowWrapper)) {
1804
- this.overFlowWrapper.classList.remove(REMAIN_COUNT);
1805
- }
1806
- }
1807
-
1808
- private createHiddenElement(): void {
1809
- if (this.allowMultiSelection || this.showCheckBox) {
1810
- this.hiddenElement = this.createElement('select', {
1811
- attrs: { 'aria-hidden': 'true', 'class': HIDDENELEMENT, 'tabindex': '-1', 'multiple': '' }
1812
- }) as HTMLSelectElement;
1813
- } else {
1814
- this.hiddenElement = this.createElement('select', {
1815
- attrs: { 'aria-hidden': 'true', 'tabindex': '-1', 'class': HIDDENELEMENT }
1816
- }) as HTMLSelectElement;
1817
- }
1818
- prepend([this.hiddenElement], this.inputWrapper);
1819
- this.validationAttribute();
1820
- }
1821
-
1822
- private createClearIcon(): void {
1823
- this.overAllClear = this.createElement('span', {
1824
- className: CLOSEICON_CLASS
1825
- });
1826
- addClass([this.overAllClear], HIDEICON);
1827
- removeClass([this.inputWrapper], SHOW_CLEAR);
1828
- if (this.showClearButton) {
1829
- this.inputWrapper.insertBefore(this.overAllClear, this.inputObj.buttons[0]);
1830
- }
1831
- }
1832
-
1833
- private validationAttribute(): void {
1834
- const name: string = this.inputEle.getAttribute('name') ? this.inputEle.getAttribute('name') : this.inputEle.getAttribute('id');
1835
- this.hiddenElement.setAttribute('name', name);
1836
- this.inputEle.removeAttribute('name');
1837
- const attributes: string[] = ['required', 'aria-required', 'form'];
1838
- for (let i: number = 0; i < attributes.length; i++) {
1839
- const attr: string = this.inputEle.getAttribute(attributes[i as number]);
1840
- if (attr) {
1841
- this.hiddenElement.setAttribute(attributes[i as number], attr);
1842
- this.inputEle.removeAttribute(attributes[i as number]);
1843
- }
1844
- }
1845
- }
1846
-
1847
- private createChip(): void {
1848
- if (!this.inputWrapper.contains(this.chipWrapper)) {
1849
- this.chipWrapper = this.createElement('span', {
1850
- className: CHIP_WRAPPER
1851
- });
1852
- this.chipCollection = this.createElement('span', {
1853
- className: CHIP_COLLECTION
1854
- });
1855
- this.chipWrapper.appendChild(this.chipCollection);
1856
- this.inputWrapper.insertBefore(this.chipWrapper, this.hiddenElement);
1857
- addClass([this.inputWrapper], SHOW_CHIP);
1858
- const isValid: boolean = this.getValidMode();
1859
- if (isValid && this.value !== null && (this.value && this.value.length !== 0)) {
1860
- addClass([this.inputEle], CHIP_INPUT);
1861
- } else if (this.value === null || (this.value && this.value.length === 0) || this.checkWrapper) {
1862
- addClass([this.chipWrapper], HIDEICON);
1863
- }
1864
- }
1865
- }
1866
-
1867
- private getValidMode(): boolean {
1868
- if (this.allowMultiSelection || this.showCheckBox) {
1869
- return this.mode === 'Box' ? true : (this.mode === 'Default' && this.inputFocus) ? true : false;
1870
- } else {
1871
- return false;
1872
- }
1873
- }
1874
-
1875
- private createSelectAllWrapper(): void {
1876
- this.checkAllParent = this.createElement('div', {
1877
- className: CHECKALLPARENT, attrs: { 'tabindex': '0' }
1878
- });
1879
- this.selectAllSpan = this.createElement('span', {
1880
- className: ALLTEXT
1881
- });
1882
- this.selectAllSpan.textContent = '';
1883
- const ele: Element = closest(this.element, '.' + BIGGER);
1884
- const touchClass: string = isNOU(ele) ? '' : SMALL;
1885
- this.checkBoxElement = createCheckBox(this.createElement, true, { cssClass: touchClass });
1886
- this.checkBoxElement.setAttribute('role', 'checkbox');
1887
- this.checkAllParent.appendChild(this.checkBoxElement);
1888
- this.checkAllParent.appendChild(this.selectAllSpan);
1889
- this.setLocale();
1890
- EventHandler.add(this.checkAllParent, 'mouseup', this.clickHandler, this);
1891
- this.wireCheckAllWrapperEvents();
1892
- }
1893
-
1894
- private clickHandler(e: MouseEvent| KeyboardEvent): void {
1895
- let target: EventTarget;
1896
- if ((e.currentTarget && (e.currentTarget as HTMLElement).classList.contains(CHECKALLPARENT))) {
1897
- target = (e.currentTarget as HTMLElement).firstElementChild.lastElementChild;
1898
- } else {
1899
- target = <Element>e.target;
1900
- }
1901
- this.checkWrapper = closest((target as HTMLElement), '.' + CHECKBOXWRAP) as HTMLElement;
1902
- if (!isNOU(this.checkWrapper)) {
1903
- this.isClicked = true;
1904
- const checkElement: Element = select('.' + CHECKBOXFRAME, this.checkWrapper);
1905
- this.changeState(this.checkWrapper, checkElement.classList.contains(CHECK) ? 'uncheck' : 'check', e);
1906
- this.isClicked = false;
1907
- }
1908
- e.preventDefault();
1909
- }
1910
-
1911
- private changeState(
1912
- wrapper: HTMLElement | Element, state: string, e?: MouseEvent | KeyboardEvent): void {
1913
- let ariaState: string;
1914
- const frameSpan: Element = wrapper.getElementsByClassName(CHECKBOXFRAME)[0];
1915
- if (state === 'check' && !frameSpan.classList.contains(CHECK)) {
1916
- frameSpan.classList.add(CHECK);
1917
- ariaState = 'true';
1918
- if (!this.isReverseUpdate) {
1919
- this.isCheckAllCalled = true;
1920
- this.treeObj.checkAll();
1921
- if (!this.changeOnBlur) {
1922
- this.triggerChangeEvent(e);
1923
- }
1924
- }
1925
- this.setLocale(true);
1926
- } else if (state === 'uncheck' && (frameSpan.classList.contains(CHECK))) {
1927
- frameSpan.classList.remove(CHECK);
1928
- ariaState = 'false';
1929
- if (!this.isReverseUpdate) {
1930
- this.treeObj.uncheckAll();
1931
- if (!this.changeOnBlur) {
1932
- this.triggerChangeEvent(e);
1933
- }
1934
- }
1935
- this.setLocale(false);
1936
- }
1937
- this.setMultiSelect();
1938
- this.ensurePlaceHolder();
1939
- ariaState = state === 'check' ? 'true' : 'false';
1940
- if (!isNOU(ariaState)) {
1941
- wrapper.setAttribute('aria-checked', ariaState);
1942
- }
1943
- }
1944
-
1945
- private setLocale(unSelect?: boolean): void {
1946
- if (!this.selectAllSpan) {return; }
1947
- if (this.selectAllText !== 'Select All' || this.unSelectAllText !== 'Unselect All') {
1948
- const template: string = unSelect ? this.unSelectAllText : this.selectAllText;
1949
- this.selectAllSpan.textContent = '';
1950
- // eslint-disable-next-line
1951
- const compiledString: Function = compile(template);
1952
- const templateName: string = unSelect ? 'unSelectAllText' : 'selectAllText';
1953
- for (const item of compiledString({}, this, templateName, null, !this.isStringTemplate)) {
1954
- this.selectAllSpan.textContent = item.textContent;
1955
- }
1956
- } else {
1957
- this.selectAllSpan.textContent = unSelect ? this.unSelectAllText : this.selectAllText;
1958
- }
1959
- }
1960
-
1961
- private setAttributes(): void {
1962
- this.inputEle.setAttribute('tabindex', '-1');
1963
- const id: string = this.element.getAttribute('id');
1964
- this.hiddenElement.id = id + '_hidden';
1965
- this.inputWrapper.setAttribute('tabindex', '0');
1966
- attributes(this.inputWrapper, this.getAriaAttributes());
1967
- }
1968
-
1969
- private setHTMLAttributes(): void {
1970
- if (Object.keys(this.htmlAttributes).length) {
1971
- for (const htmlAttr of Object.keys(this.htmlAttributes)) {
1972
- if (htmlAttr === 'class') {
1973
- this.inputWrapper.classList.add(this.htmlAttributes[`${htmlAttr}`]);
1974
- } else if (htmlAttr === 'disabled' && this.htmlAttributes[`${htmlAttr}`] === 'disabled') {
1975
- this.setProperties({ enabled: false }, true);
1976
- this.setEnable();
1977
- } else if (htmlAttr === 'readonly' && !isNOU(this.htmlAttributes[`${htmlAttr}`])) {
1978
- this.setProperties({ readonly: true }, true);
1979
- this.dataBind();
1980
- } else if (htmlAttr === 'style') {
1981
- this.inputWrapper.setAttribute('style', this.htmlAttributes[`${htmlAttr}`]);
1982
- } else {
1983
- const defaultAttr: string[] = ['title', 'id', 'placeholder', 'aria-placeholder',
1984
- 'role', 'autocorrect', 'autocomplete', 'autocapitalize', 'spellcheck', 'minlength', 'maxlength'];
1985
- const validateAttr: string[] = ['name', 'required'];
1986
- if (htmlAttr.indexOf('data') === 0 || validateAttr.indexOf(htmlAttr) > -1) {
1987
- this.hiddenElement.setAttribute(htmlAttr, this.htmlAttributes[`${htmlAttr}`]);
1988
- } else if (defaultAttr.indexOf(htmlAttr) > -1) {
1989
- if (htmlAttr === 'placeholder') {
1990
- Input.setPlaceholder(this.htmlAttributes[`${htmlAttr}`], this.inputEle);
1991
- } else {
1992
- this.inputEle.setAttribute(htmlAttr, this.htmlAttributes[`${htmlAttr}`]);
1993
- }
1994
- } else {
1995
- this.inputEle.setAttribute(htmlAttr, this.htmlAttributes[`${htmlAttr}`]);
1996
- }
1997
- }
1998
- }
1999
- }
2000
- }
2001
-
2002
- private updateDataAttribute() : void {
2003
- const value: { [key: string]: string; } = this.htmlAttributes;
2004
- const invalidAttr: string[] = ['class', 'style', 'id', 'type'];
2005
- const attr: { [key: string]: string; } = {};
2006
- for (let a: number = 0; a < this.element.attributes.length; a++) {
2007
- if (invalidAttr.indexOf(this.element.attributes[a as number].name) === -1 &&
2008
- !( this.element.attributes[a as number].name === 'readonly')) {
2009
- attr[this.element.attributes[a as number].name] = this.element.getAttribute(this.element.attributes[a as number].name);
2010
- }
2011
- }
2012
- extend(attr, value, attr);
2013
- this.setProperties({ htmlAttributes: attr }, true);
2014
- }
2015
-
2016
- private showOverAllClear(): void {
2017
- if (!this.enabled || this.readonly) {
2018
- return;
2019
- }
2020
- if (this.overAllClear) {
2021
- const isValue: boolean = this.value ? (this.value.length ? true : false) : false;
2022
- if (isValue && this.showClearButton) {
2023
- removeClass([this.overAllClear], HIDEICON);
2024
- addClass([this.inputWrapper], SHOW_CLEAR);
2025
- } else {
2026
- addClass([this.overAllClear], HIDEICON);
2027
- removeClass([this.inputWrapper], SHOW_CLEAR);
2028
- }
2029
- }
2030
- }
2031
-
2032
- private setTreeValue(): void {
2033
- if (this.value !== null && this.value.length !== 0) {
2034
- // eslint-disable-next-line
2035
- let data: { [key: string]: Object };
2036
- if (this.showCheckBox || this.allowMultiSelection) {
2037
- for (let i: number = 0; i < this.value.length; i++) {
2038
- data = this.treeObj.getTreeData(this.value[i as number])[0];
2039
- if (isNOU(data)) {
2040
- this.value.splice(this.value.indexOf(this.value[i as number]), 1);
2041
- }
2042
- }
2043
- if (this.value.length !== 0) {
2044
- this.setValidValue();
2045
- }
2046
- } else {
2047
- data = this.treeObj.getTreeData(this.value[0])[0];
2048
- if (!isNOU(data)) {
2049
- this.setProperties({ text: data[this.fields.text] }, true);
2050
- this.setValidValue();
2051
- } else {
2052
- this.setProperties({ value: this.currentValue }, true);
2053
- }
2054
- }
2055
- }
2056
- }
2057
-
2058
- private setTreeText(): void {
2059
- if (this.value !== null && !this.isInitialized) {
2060
- return;
2061
- }
2062
- if (this.text !== null) {
2063
- // eslint-disable-next-line
2064
- let data: { [key: string]: Object };
2065
- const valArr: string[] = [];
2066
- if (this.showCheckBox || this.allowMultiSelection) {
2067
- const textArr: string[] = this.text.split(this.delimiterChar);
2068
- for (let i: number = 0; i < textArr.length; i++) {
2069
- data = this.getItems(textArr[i as number]);
2070
- if (!isNOU(data)) {
2071
- valArr.push(data[this.fields.value].toString());
2072
- }
2073
- }
2074
- if (valArr.length !== 0) {
2075
- this.oldValue = this.value;
2076
- this.setProperties({ value: valArr }, true);
2077
- this.setValidValue();
2078
- } else {
2079
- this.setProperties({ text: this.currentText }, true);
2080
- }
2081
- } else {
2082
- data = this.getItems(this.text);
2083
- if (!isNOU(data)) {
2084
- this.oldValue = this.value;
2085
- this.setProperties({ value: [data[this.fields.value].toString()] }, true);
2086
- this.setValidValue();
2087
- } else {
2088
- this.setProperties({ text: this.currentText }, true);
2089
- }
2090
- }
2091
- }
2092
- }
2093
-
2094
- private setSelectedValue(): void {
2095
- if (this.value != null) {
2096
- return;
2097
- }
2098
- if (!this.isInitialized) {
2099
- this.oldValue = this.value;
2100
- if (this.treeObj.selectedNodes.length > 0 && !this.showCheckBox) {
2101
- this.setProperties({ value: this.treeObj.selectedNodes }, true);
2102
- if (this.allowMultiSelection) {
2103
- this.updateMode();
2104
- }
2105
- } else if (this.showCheckBox && this.treeObj.checkedNodes) {
2106
- if (this.treeObj.checkedNodes.length > 0) {
2107
- this.setProperties({ value: this.treeObj.checkedNodes }, true);
2108
- setValue('selectedNodes', [], this.treeObj);
2109
- this.treeObj.dataBind();
2110
- this.updateMode();
2111
- }
2112
- }
2113
- this.updateSelectedValues();
2114
- this.currentText = this.text;
2115
- this.currentValue = this.value;
2116
- }
2117
- }
2118
-
2119
- private setValidValue(): void {
2120
- if (!this.showCheckBox && !this.allowMultiSelection) {
2121
- Input.setValue(this.text, this.inputEle, this.floatLabelType);
2122
- const id: string = this.value[0].toString();
2123
- if (this.treeObj.selectedNodes[0] !== id) {
2124
- setValue('selectedNodes', [id], this.treeObj);
2125
- }
2126
- } else {
2127
- if (this.showCheckBox) {
2128
- let difference: string[] = this.value.filter((e) => {
2129
- return this.treeObj.checkedNodes.indexOf(e) === -1;
2130
- });
2131
- if (difference.length > 0 || this.treeSettings.autoCheck) {
2132
- this.treeObj.checkedNodes = this.value.slice();
2133
- this.treeObj.dataBind();
2134
- this.setMultiSelect();
2135
- }
2136
- } else {
2137
- this.treeObj.selectedNodes = this.value.slice();
2138
- this.selectedText = [];
2139
- this.updateSelectedValues();
2140
- }
2141
- this.treeObj.dataBind();
2142
- }
2143
- this.currentText = this.text;
2144
- this.currentValue = this.value;
2145
- if (this.isInitialized) {
2146
- this.triggerChangeEvent();
2147
- }
2148
- }
2149
-
2150
- // eslint-disable-next-line
2151
- private getItems(givenText: string): { [key: string]: Object } {
2152
- // eslint-disable-next-line
2153
- let data: { [key: string]: Object };
2154
- if (this.treeDataType === 1) {
2155
- for (let i: number = 0; i < this.treeItems.length; i++) {
2156
- // eslint-disable-next-line
2157
- const text: Object = getValue(this.fields.text, this.treeItems[i]);
2158
- if (!isNOU(this.treeItems[i as number]) && !isNOU(text) && text === givenText) {
2159
- data = this.treeItems[i as number];
2160
- break;
2161
- }
2162
- }
2163
- } else {
2164
- data = this.getNestedItems(this.treeItems, this.fields, givenText);
2165
- }
2166
- return data;
2167
- }
2168
-
2169
- // eslint-disable-next-line
2170
- private getNestedItems(data: { [key: string]: Object }[], field: FieldsModel, givenText: string): { [key: string]: Object } {
2171
- // eslint-disable-next-line
2172
- let newData: { [key: string]: Object };
2173
- for (let i: number = 0, objlen: number = data.length; i < objlen; i++) {
2174
- // eslint-disable-next-line
2175
- const dataId: Object = getValue(this.fields.text, data[i]);
2176
- if (data[i as number] && dataId && dataId.toString() === givenText) {
2177
- return data[i as number];
2178
- } else if (typeof field.child === 'string' && !isNOU(getValue(field.child, data[i as number]))) {
2179
- // eslint-disable-next-line
2180
- const childData: Object = getValue(field.child, data[i]);
2181
- // eslint-disable-next-line
2182
- newData = this.getNestedItems(<{ [key: string]: Object }[]>childData, this.getChildType(field), givenText);
2183
- if (newData !== undefined) {
2184
- break;
2185
- }
2186
- } else if (this.fields.dataSource instanceof DataManager && !isNOU(getValue('child', data[i as number]))) {
2187
- const child: string = 'child';
2188
- // eslint-disable-next-line
2189
- newData = this.getNestedItems(<{ [key: string]: Object }[]>getValue(child, data[i]), this.getChildType(field), givenText);
2190
- if (newData !== undefined) {
2191
- break;
2192
- }
2193
- }
2194
- }
2195
- return newData;
2196
- }
2197
-
2198
- private getChildType(mapper: FieldsModel): FieldsModel {
2199
- return (typeof mapper.child === 'string' || isNOU(mapper.child)) ? mapper : mapper.child;
2200
- }
2201
-
2202
- /* To render the treeview */
2203
- private renderTree(): void {
2204
- this.treeObj = new TreeView({
2205
- fields: this.getTreeFields(this.fields),
2206
- enableRtl: this.enableRtl,
2207
- nodeSelected: this.onNodeSelected.bind(this),
2208
- nodeChecked: this.onNodeChecked.bind(this),
2209
- nodeChecking: this.beforeCheck.bind(this),
2210
- nodeExpanded: this.onNodeExpanded.bind(this),
2211
- actionFailure: this.onActionFailure.bind(this),
2212
- nodeClicked: this.onNodeClicked.bind(this),
2213
- dataBound: this.OnDataBound.bind(this),
2214
- allowMultiSelection: this.allowMultiSelection,
2215
- enableHtmlSanitizer: this.enableHtmlSanitizer,
2216
- showCheckBox: this.showCheckBox,
2217
- autoCheck: this.treeSettings.autoCheck,
2218
- sortOrder: this.sortOrder,
2219
- expandOn: this.treeSettings.expandOn,
2220
- loadOnDemand: this.treeSettings.loadOnDemand,
2221
- nodeSelecting: this.onBeforeSelect.bind(this),
2222
- nodeTemplate: this.itemTemplate
2223
- });
2224
- this.treeObj.root = this.root ? this.root : this;
2225
- this.treeObj.appendTo('#' + this.tree.id);
2226
- }
2227
-
2228
- /* To render the popup element */
2229
- private renderPopup(): void {
2230
- if (this.isFilteredData) {
2231
- this.filterObj.value = '';
2232
- this.treeObj.fields = this.getTreeFields(this.fields);
2233
- if ((this as any).isReact) this.refresh();
2234
- this.isFilterRestore = true;
2235
- this.isFilteredData = false;
2236
- this.hideCheckAll(false);
2237
- }
2238
- let isCancelled: boolean = false;
2239
- const args: DdtBeforeOpenEventArgs = { cancel: false };
2240
- this.trigger('beforeOpen', args, (args: DdtBeforeOpenEventArgs) => {
2241
- if (!args.cancel) {
2242
- addClass([this.inputWrapper], [ICONANIMATION]);
2243
- if (this.isFirstRender) {
2244
- this.popupEle = this.createElement('div', {
2245
- id: this.element.id + '_options', className: POPUP_CLASS + ' ' + (this.cssClass != null ? this.cssClass : '')
2246
- });
2247
- this.popupEle.setAttribute('role', 'region');
2248
- this.popupEle.setAttribute('aria-label', this.element.id);
2249
- document.body.appendChild(this.popupEle);
2250
- this.createPopup(this.popupEle);
2251
- } else {
2252
- this.popupEle = this.popupObj.element;
2253
- }
2254
- } else {
2255
- isCancelled = true;
2256
- }
2257
- if (this.isFirstRender && !isCancelled) {
2258
- prepend([this.popupDiv], this.popupEle);
2259
- removeClass([this.popupDiv], DDTHIDEICON);
2260
- if (this.allowFiltering) { this.renderFilter(); }
2261
- if (this.showCheckBox && this.showSelectAll && (!this.popupDiv.classList.contains(NODATA))) {
2262
- this.createSelectAllWrapper();
2263
- this.popupEle.insertBefore(this.checkAllParent, this.popupDiv);
2264
- }
2265
- if (this.headerTemplate) { this.setHeaderTemplate(); }
2266
- if (this.footerTemplate) { this.setFooterTemplate(); }
2267
- this.isFirstRender = false;
2268
- /* eslint-disable */
2269
- if (this.hasTemplate && (this as any).portals) {
2270
- (this as any).portals = (this as any).portals.concat((this.treeObj as any).portals);
2271
- /* eslint-enable */
2272
- this.renderReactTemplates();
2273
- }
2274
- }
2275
- if (!isCancelled) {
2276
- attributes(this.inputEle, { 'aria-expanded': 'true' });
2277
- this.popupObj.show(null, (this.zIndex === 1000) ? this.inputEle : null);
2278
- removeClass([this.popupEle], DDTHIDEICON);
2279
- this.updatePopupHeight();
2280
- this.popupObj.refreshPosition();
2281
- if (!(this.showCheckBox && this.showSelectAll) && (!this.popupDiv.classList.contains(NODATA)
2282
- && this.treeItems.length > 0)) {
2283
- let focusedElement: HTMLElement= this.treeObj.element.querySelector('li');
2284
- focusedElement.focus();
2285
- addClass([focusedElement], ['e-node-focus']);
2286
- }
2287
- if (this.checkSelectAll && this.checkBoxElement) {
2288
- const wrap: HTMLElement = closest((this.checkBoxElement as HTMLElement), '.' + CHECKBOXWRAP) as HTMLElement;
2289
- this.changeState(wrap, 'check');
2290
- this.checkSelectAll = false;
2291
- }
2292
- if (this.allowFiltering) {
2293
- removeClass([this.inputWrapper], [INPUTFOCUS]);
2294
- this.filterObj.element.focus();
2295
- }
2296
- const eventArgs: DdtPopupEventArgs = { popup: this.popupObj };
2297
- this.trigger('open', eventArgs);
2298
- }
2299
- });
2300
- }
2301
-
2302
- private updatePopupHeight(): void {
2303
- if (this.isFirstRender) {return; }
2304
- let popupHeight: string = this.getHeight();
2305
- this.popupEle.style.maxHeight = popupHeight;
2306
- if (this.allowFiltering) {
2307
- const height: number = Math.round(this.filterContainer.getBoundingClientRect().height);
2308
- popupHeight = formatUnit(parseInt(popupHeight, 10) - height + 'px');
2309
- }
2310
- if (this.headerTemplate) {
2311
- const height: number = Math.round(this.header.getBoundingClientRect().height);
2312
- popupHeight = formatUnit(parseInt(popupHeight, 10) - height + 'px');
2313
- }
2314
- if (this.showCheckBox && this.showSelectAll && (!this.popupDiv.classList.contains(NODATA))) {
2315
- const height: number = Math.round(this.checkAllParent.getBoundingClientRect().height);
2316
- popupHeight = formatUnit(parseInt(popupHeight, 10) - height + 'px');
2317
- }
2318
- if (this.footerTemplate) {
2319
- const height: number = Math.round(this.footer.getBoundingClientRect().height);
2320
- popupHeight = formatUnit(parseInt(popupHeight, 10) - height + 'px');
2321
- }
2322
- let border: number = parseInt(window.getComputedStyle(this.popupEle).borderTopWidth, 10);
2323
- border = border + parseInt(window.getComputedStyle(this.popupEle).borderBottomWidth, 10);
2324
- popupHeight = formatUnit(parseInt(popupHeight, 10) - border + 'px');
2325
- this.popupDiv.style.maxHeight = popupHeight;
2326
- }
2327
-
2328
- private createPopup(element: HTMLElement): void {
2329
- if (this.isFirstRender) {
2330
- this.popupObj = new Popup(element, {
2331
- width: this.setWidth(),
2332
- targetType: 'relative',
2333
- collision: { X: 'flip', Y: 'flip' },
2334
- relateTo: this.inputWrapper,
2335
- zIndex: this.zIndex,
2336
- enableRtl: this.enableRtl,
2337
- position: { X: 'left', Y: 'bottom' },
2338
- close: () => {
2339
- this.isPopupOpen = false;
2340
- },
2341
- open: () => {
2342
- EventHandler.add(document, 'mousedown', this.onDocumentClick, this);
2343
- this.isPopupOpen = true;
2344
- },
2345
- targetExitViewport: () => {
2346
- if (!Browser.isDevice) { this.hidePopup(); }
2347
- }
2348
- });
2349
- }
2350
- }
2351
-
2352
- /* To calculate the width when change via set model */
2353
- private setElementWidth(inputWidth: string | number): void {
2354
- const ddElement: HTMLElement = this.inputWrapper;
2355
- if (!isNOU(inputWidth)) {
2356
- if (typeof inputWidth === 'number') {
2357
- ddElement.style.width = formatUnit(inputWidth);
2358
- } else if (typeof inputWidth === 'string') {
2359
- ddElement.style.width = (inputWidth.match(/px|%|em/)) ? (inputWidth) :
2360
- (formatUnit(inputWidth));
2361
- }
2362
- }
2363
- }
2364
-
2365
- /* To calculate the width of the popup */
2366
- private setWidth(): string {
2367
- let width: string = formatUnit(this.popupWidth);
2368
- if (width.indexOf('%') > -1) {
2369
- width = (this.inputWrapper.offsetWidth * parseFloat(width) / 100).toString() + 'px';
2370
- } else if (typeof this.popupWidth === 'string') {
2371
- width = (this.popupWidth.match(/px|em/)) ? (this.popupWidth) : width;
2372
- }
2373
- return width;
2374
- }
2375
-
2376
- /* To calculate the height of the popup */
2377
- private getHeight(): string {
2378
- let height: string = formatUnit(this.popupHeight);
2379
- if (height.indexOf('%') > -1) {
2380
- // Will set the height of the popup according to the view port height
2381
- height = (document.documentElement.clientHeight * parseFloat(height) / 100).toString() + 'px';
2382
- } else if (typeof this.popupHeight === 'string') {
2383
- height = (this.popupHeight.match(/px|em/)) ? (this.popupHeight) : height;
2384
- }
2385
- return height;
2386
- }
2387
-
2388
- private onDocumentClick(e: MouseEvent): void {
2389
- const target: HTMLElement = <HTMLElement>e.target;
2390
- const isTree: Element = closest(target, '.' + PARENTITEM);
2391
- const isFilter: Element = closest(target, '.' + FILTERWRAP);
2392
- const isHeader: Element = closest(target, '.' + HEADER);
2393
- const isFooter: Element = closest(target, '.' + FOOTER);
2394
- const isScroller: boolean = target.classList.contains(DROPDOWN) ? true :
2395
- (matches(target, '.e-ddt .e-popup') || matches(target, '.e-ddt .e-treeview'));
2396
- if ((this.isPopupOpen && ((!isNOU(this.inputWrapper) && this.inputWrapper.contains(target)) || isTree || isScroller || isHeader || isFooter)) ||
2397
- ((this.allowMultiSelection || this.showCheckBox) && (this.isPopupOpen && target.classList.contains(CHIP_CLOSE) ||
2398
- (this.isPopupOpen && (target.classList.contains(CHECKALLPARENT) || target.classList.contains(ALLTEXT)
2399
- || target.classList.contains(CHECKBOXFRAME)))))) {
2400
- this.isDocumentClick = false;
2401
- e.preventDefault();
2402
- } else if (!isNOU(this.inputWrapper) && !this.inputWrapper.contains(target) && this.inputFocus && !isFilter) {
2403
- this.focusOut(e);
2404
- }
2405
- }
2406
-
2407
- private onActionFailure(e: FailureEventArgs): void {
2408
- this.trigger('actionFailure', e);
2409
- this.l10nUpdate(true);
2410
- addClass([this.popupDiv], NODATA);
2411
- }
2412
-
2413
- private OnDataBound(args: DataBoundEventArgs): void {
2414
- this.treeItems = args.data;
2415
- if (this.treeItems.length <= 0) {
2416
- this.l10nUpdate();
2417
- addClass([this.popupDiv], NODATA);
2418
- this.hideCheckAll(true);
2419
- } else if (this.popupDiv.classList.contains(NODATA) && this.treeItems.length >= 1) {
2420
- removeClass([this.popupDiv], NODATA);
2421
- this.hideCheckAll(false);
2422
- }
2423
- this.treeDataType = this.getTreeDataType(this.treeItems, this.fields);
2424
- if (this.isFirstRender && this.isRemoteData) {
2425
- this.setTreeValue();
2426
- this.setTreeText();
2427
- this.updateHiddenValue();
2428
- this.setSelectedValue();
2429
- if (!this.wrapText ) {
2430
- this.updateView();
2431
- }
2432
- this.treeObj.element.focus();
2433
- }
2434
- const eventArgs: DdtDataBoundEventArgs = { data: args.data };
2435
- this.trigger('dataBound', eventArgs);
2436
- if (this.filterObj === null) { this.isFilteredData = false; }
2437
- if (this.isFilteredData) { this.treeObj.expandAll(); }
2438
- if (this.isFilterRestore) {
2439
- this.restoreFilterSelection();
2440
- this.isFilterRestore = false;
2441
- }
2442
- }
2443
-
2444
- private restoreFilterSelection(): void {
2445
- if (this.showCheckBox) {
2446
- this.treeObj.checkedNodes = this.value ? this.value : [];
2447
- } else {
2448
- this.treeObj.selectedNodes = this.value ? this.value : [];
2449
- }
2450
- }
2451
-
2452
- /* To set cssclass for the dropdowntree */
2453
- private setCssClass(newClass: string, oldClass: string): void {
2454
- const elements: HTMLElement[] = this.popupObj ? [this.inputWrapper, this.popupObj.element] : [this.inputWrapper];
2455
- if (!isNOU(oldClass) && oldClass !== '') {
2456
- removeClass(elements, oldClass.split(' '));
2457
- }
2458
- if (!isNOU(newClass) && newClass !== '') {
2459
- addClass(elements, newClass.split(' '));
2460
- }
2461
- }
2462
-
2463
- private setEnableRTL(state: boolean): void {
2464
- if (state) {
2465
- this.inputWrapper.classList.add(RTL);
2466
- } else {
2467
- this.inputWrapper.classList.remove(RTL);
2468
- }
2469
- if (this.popupObj) {
2470
- this.popupObj.enableRtl = state;
2471
- this.popupObj.dataBind();
2472
- }
2473
- if (this.treeObj) {
2474
- this.treeObj.enableRtl = state;
2475
- this.treeObj.dataBind();
2476
- }
2477
- }
2478
-
2479
- /* To set enable property */
2480
- private setEnable(): void {
2481
- Input.setEnabled(this.enabled, this.inputEle);
2482
- if (this.enabled) {
2483
- removeClass([this.inputWrapper], DISABLED);
2484
- this.inputEle.setAttribute('aria-disabled', 'false');
2485
- this.inputWrapper.setAttribute('aria-disabled', 'false');
2486
- } else {
2487
- if (this.isPopupOpen) {
2488
- this.hidePopup();
2489
- }
2490
- addClass([this.inputWrapper], DISABLED);
2491
- if (this.inputWrapper && this.inputWrapper.classList.contains(INPUTFOCUS)) {
2492
- removeClass([this.inputWrapper], [INPUTFOCUS]);
2493
- }
2494
- this.inputEle.setAttribute('aria-disabled', 'true');
2495
- this.inputWrapper.setAttribute('aria-disabled', 'true');
2496
- }
2497
- }
2498
- private cloneFields(fields: FieldsModel): FieldsModel {
2499
- const clonedField: FieldsModel = {
2500
- dataSource: fields.dataSource, value: fields.value, text: fields.text, parentValue: fields.parentValue,
2501
- child: this.cloneChildField(fields.child), hasChildren: fields.hasChildren, expanded: fields.expanded,
2502
- iconCss: fields.iconCss, imageUrl: fields.imageUrl, htmlAttributes: fields.htmlAttributes, query: fields.query,
2503
- selected: fields.selected, selectable: fields.selectable, tableName: fields.tableName, tooltip: fields.tooltip
2504
- };
2505
- return clonedField;
2506
- }
2507
- private cloneChildField(fields: FieldsModel | string): string | FieldsModel {
2508
- if (typeof fields === 'string') {
2509
- return fields;
2510
- } else {
2511
- const clonedField: FieldsModel = {
2512
- dataSource: fields.dataSource, value: fields.value, text: fields.text, parentValue: fields.parentValue,
2513
- child: (fields.child ? this.cloneChildField(fields.child) : null), hasChildren: fields.hasChildren,
2514
- expanded: fields.expanded, iconCss: fields.iconCss, imageUrl: fields.imageUrl, htmlAttributes: fields.htmlAttributes,
2515
- query: fields.query, selected: fields.selected, selectable: fields.selectable, tableName: fields.tableName, tooltip: fields.tooltip
2516
- };
2517
- return clonedField;
2518
- }
2519
- }
2520
-
2521
- private getTreeFields(fields: FieldsModel): FieldsSettingsModel {
2522
- const treeFields: FieldsSettingsModel = {
2523
- dataSource: fields.dataSource, id: fields.value, text: fields.text, parentID: fields.parentValue,
2524
- child: this.getTreeChildren(fields.child), hasChildren: fields.hasChildren, expanded: fields.expanded,
2525
- iconCss: fields.iconCss, imageUrl: fields.imageUrl, isChecked: fields.selected,
2526
- htmlAttributes: fields.htmlAttributes, query: fields.query, selectable: fields.selectable, selected: fields.selected,
2527
- tableName: fields.tableName, tooltip: fields.tooltip
2528
- };
2529
- return treeFields;
2530
- }
2531
-
2532
- private getTreeChildren(mapper: FieldsModel | string): FieldsSettingsModel | string {
2533
- if (typeof mapper === 'string') {
2534
- return mapper;
2535
- } else if (!isNOU(mapper)) {
2536
- mapper = this.getActualProperties(mapper) as FieldsModel;
2537
- const childFields: FieldsSettingsModel | string = mapper;
2538
- if (mapper.value) {
2539
- childFields.id = mapper.value;
2540
- }
2541
- if (mapper.parentValue) {
2542
- childFields.parentID = mapper.parentValue;
2543
- }
2544
- if (mapper.child) {
2545
- childFields.child = this.getTreeChildren(mapper.child);
2546
- }
2547
- if (mapper.selected && this.showCheckBox) {
2548
- childFields.isChecked = mapper.selected;
2549
- }
2550
- return childFields;
2551
- }
2552
- return null;
2553
- }
2554
-
2555
- // eslint-disable-next-line
2556
- private getTreeDataType(ds: { [key: string]: Object }[], field: FieldsModel): number {
2557
- if (this.fields.dataSource instanceof DataManager) {
2558
- for (let i: number = 0; i < ds.length; i++) {
2559
- if ((typeof field.child === 'string') && isNOU(getValue(field.child, ds[i as number]))) {
2560
- return 1;
2561
- }
2562
- }
2563
- return 2;
2564
- }
2565
- if(isNOU(this.fields.dataSource)) this.fields.dataSource = [];
2566
- for (let i: number = 0, len: number = this.fields.dataSource.length; i < len; i++) {
2567
- if ((typeof field.child === 'string') && !isNOU(getValue(field.child, this.fields.dataSource[i as number]))) {
2568
- return 2;
2569
- }
2570
- if (!isNOU(getValue(field.parentValue, this.fields.dataSource[i as number])) || !isNOU(getValue(field.hasChildren, this.fields.dataSource[i as number]))) {
2571
- return 1;
2572
- }
2573
- }
2574
- return 1;
2575
- }
2576
-
2577
- /* Triggers when the tree fields is changed dynamically */
2578
- private setFields(): void {
2579
- this.resetValue();
2580
- if (this.hasTemplate) {
2581
- this.updateTemplate();
2582
- }
2583
- this.treeObj.fields = this.getTreeFields(this.fields);
2584
- this.treeObj.dataBind();
2585
- }
2586
- private getEventArgs(args: NodeCheckEventArgs | NodeSelectEventArgs): DdtSelectEventArgs {
2587
- // eslint-disable-next-line
2588
- const checkData: { [key: string]: Object }[] = (args as NodeCheckEventArgs).data;
2589
- // eslint-disable-next-line
2590
- const selectData: { [key: string]: Object } = (args as NodeSelectEventArgs).nodeData;
2591
- let state: string;
2592
- if (this.showCheckBox) {
2593
- if (args.action === 'check') {
2594
- state = 'select';
2595
- } else if (args.action === 'uncheck') {
2596
- state = 'un-select';
2597
- }
2598
- }
2599
- const eventArgs: DdtSelectEventArgs = {
2600
- action: this.showCheckBox ? state : args.action,
2601
- isInteracted: this.isClicked ? true : args.isInteracted,
2602
- item: args.node,
2603
- itemData: this.showCheckBox ? checkData[0] : selectData
2604
- };
2605
- return eventArgs;
2606
- }
2607
-
2608
- private onBeforeSelect(args: NodeSelectEventArgs): void {
2609
- if (args.isInteracted) {
2610
- this.oldValue = this.value ? this.value.slice() : this.value;
2611
- if (this.value === null) {
2612
- this.setProperties({ value: [] }, true);
2613
- }
2614
- }
2615
- }
2616
-
2617
- private updateHiddenValue(): void {
2618
- if (this.allowMultiSelection || this.showCheckBox) {
2619
- return;
2620
- }
2621
- if (this.value && this.value.length) {
2622
- this.hiddenElement.innerHTML = '<option selected value ="' + this.value[0] + '">' + this.text + '</option>';
2623
- } else {
2624
- this.hiddenElement.innerHTML = '';
2625
- }
2626
- }
2627
-
2628
- /* Triggers when the tree node is selected */
2629
- private onNodeSelected(args: NodeSelectEventArgs): void {
2630
- if (this.showCheckBox) {
2631
- return;
2632
- }
2633
- let selectedText: string;
2634
- if (args.isInteracted) {
2635
- const id: string = getValue('id', args.nodeData).toString();
2636
- if (!this.allowMultiSelection) {
2637
- this.hiddenElement.innerHTML = '';
2638
- this.setProperties({ value: [id] }, true);
2639
- if (this.itemTemplate) {
2640
- selectedText = getValue('text', this.treeObj.getNode(id));
2641
- } else {
2642
- selectedText = getValue('text', args.nodeData).toString();
2643
- }
2644
- Input.setValue(selectedText, this.inputEle, this.floatLabelType);
2645
- this.setProperties({ text: selectedText }, true);
2646
- this.currentText = this.text;
2647
- this.currentValue = this.value;
2648
- attributes(this.inputWrapper, { 'aria-describedby': this.element.id });
2649
- attributes(this.inputWrapper, { 'aria-activedescendant': id.toString() });
2650
- this.updateHiddenValue();
2651
- this.showOverAllClear();
2652
- this.hidePopup();
2653
- this.isNodeSelected = true;
2654
- } else if (this.allowMultiSelection) {
2655
- this.setMultiSelect();
2656
- }
2657
- }
2658
- const eventArgs: DdtSelectEventArgs = this.getEventArgs(args);
2659
- this.trigger('select', eventArgs);
2660
- if (this.isValueChange && !this.changeOnBlur) {
2661
- this.triggerChangeEvent(this.keyEventArgs);
2662
- this.isValueChange = false;
2663
- }
2664
- }
2665
-
2666
- private onNodeClicked(args: NodeClickEventArgs): void {
2667
- if (!this.changeOnBlur && this.isNodeSelected) {
2668
- this.triggerChangeEvent(args.event);
2669
- this.isNodeSelected = false;
2670
- }
2671
- const target: Element = <Element>args.event.target;
2672
- if ((target.classList.contains('e-fullrow') || target.classList.contains('e-list-text')) && this.showCheckBox) {
2673
- this.isClicked = true;
2674
- // eslint-disable-next-line
2675
- const getNodeDetails: { [key: string]: Object } = this.treeObj.getNode(args.node);
2676
- if (getNodeDetails.isChecked === 'true') {
2677
- this.treeObj.uncheckAll([args.node]);
2678
- } else {
2679
- this.treeObj.checkAll([args.node]);
2680
- }
2681
- this.isClicked = false;
2682
- this.setMultiSelect();
2683
- this.ensurePlaceHolder();
2684
- }
2685
- if (!this.changeOnBlur && (this.allowMultiSelection || this.showCheckBox)) {
2686
- this.triggerChangeEvent(args.event);
2687
- }
2688
- }
2689
-
2690
- private onNodeChecked(args: NodeCheckEventArgs): void {
2691
- const eventArgs: DdtSelectEventArgs = this.getEventArgs(args);
2692
- this.trigger('select', eventArgs);
2693
- if (this.isFilteredData && args.action === 'uncheck') {
2694
- const id: string = getValue('id', args.data[0]).toString();
2695
- this.removeSelectedData(id , true);
2696
- }
2697
- if (!this.isChipDelete && args.isInteracted) {
2698
- this.setMultiSelect();
2699
- this.ensurePlaceHolder();
2700
- }
2701
- if (this.showSelectAll && this.checkBoxElement) {
2702
- const nodes: NodeList = this.treeObj.element.querySelectorAll('li');
2703
- const checkedNodes: NodeList = this.treeObj.element.querySelectorAll('li .e-checkbox-wrapper[aria-checked=true]');
2704
- const wrap: HTMLElement = closest((this.checkBoxElement as HTMLElement), '.' + CHECKBOXWRAP) as HTMLElement;
2705
- if (wrap && args.action === 'uncheck' && (args.isInteracted || checkedNodes.length === 0 || (!isNOU(args.data[0]) && args.data[0].isChecked === 'false'))) {
2706
- this.isReverseUpdate = true;
2707
- this.changeState(wrap, 'uncheck');
2708
- this.isReverseUpdate = false;
2709
- } else if (wrap && args.action === 'check' && checkedNodes.length === nodes.length && (args.isInteracted || this.isCheckAllCalled || (!isNOU(args.data[0]) && args.data[0].isChecked === 'true'))) {
2710
- this.isReverseUpdate = true;
2711
- this.isCheckAllCalled = false;
2712
- this.changeState(wrap, 'check');
2713
- this.isReverseUpdate = false;
2714
- }
2715
- }
2716
- }
2717
-
2718
- private beforeCheck(args: NodeCheckEventArgs): void {
2719
- if (args.isInteracted) {
2720
- this.oldValue = this.value ? this.value.slice() : this.value;
2721
- }
2722
- }
2723
-
2724
- private onNodeExpanded(args: NodeExpandEventArgs): void {
2725
- if (this.hasTemplate && (this as any).portals && (this.treeObj as any).portals) {
2726
- for (let i: number = 0; i < (this.treeObj as any).portals.length; i++) {
2727
- if ((this as any).portals.indexOf((this.treeObj as any).portals[i as number]) == -1) {
2728
- (this as any).portals.push((this.treeObj as any).portals[i as number]);
2729
- }
2730
- }
2731
- /* eslint-enable */
2732
- this.renderReactTemplates();
2733
- }
2734
- }
2735
-
2736
- private updateClearButton(state: boolean): void {
2737
- if (state) {
2738
- if (!this.inputWrapper.contains(this.overAllClear)) {
2739
- this.inputEle.parentElement.insertBefore(this.overAllClear, this.inputEle.nextSibling);
2740
- } else {
2741
- removeClass([this.overAllClear], HIDEICON);
2742
- addClass([this.inputWrapper], SHOW_CLEAR);
2743
- }
2744
- } else {
2745
- addClass([this.overAllClear], HIDEICON);
2746
- removeClass([this.inputWrapper], SHOW_CLEAR);
2747
- }
2748
- if ((this.allowMultiSelection || this.showCheckBox) && this.chipWrapper) {
2749
- const chipClose: Element[] = selectAll('.' + CHIP_CLOSE, this.chipWrapper);
2750
- for (let i: number = 0; i < chipClose.length; i++) {
2751
- if (!state) {
2752
- addClass([chipClose[i as number]], HIDEICON);
2753
- } else {
2754
- removeClass([chipClose[i as number]], HIDEICON);
2755
- }
2756
- }
2757
- }
2758
- }
2759
-
2760
- private updateDropDownIconState(state: boolean): void {
2761
- const spinIcon: Element = select('.' + DDTICON, this.inputWrapper);
2762
- if (state) {
2763
- if (!spinIcon) {
2764
- Input.appendSpan(DROPDOWNICON, this.inputWrapper, this.createElement);
2765
- } else {
2766
- removeClass([spinIcon], HIDEICON);
2767
- }
2768
- addClass([this.inputWrapper], SHOW_DD_ICON);
2769
- } else {
2770
- addClass([spinIcon], HIDEICON);
2771
- removeClass([this.inputWrapper], SHOW_DD_ICON);
2772
- }
2773
- }
2774
-
2775
- private updateMode(): void {
2776
- if (this.mode === 'Custom') { return; }
2777
- if (this.mode !== 'Delimiter') {
2778
- if (!this.inputWrapper.contains(this.chipWrapper)) {
2779
- this.createChip();
2780
- }
2781
- const isValid: boolean = this.getValidMode();
2782
- if (this.chipWrapper.classList.contains(HIDEICON) && isValid) {
2783
- removeClass([this.chipWrapper], HIDEICON);
2784
- addClass([this.inputWrapper], SHOW_CHIP);
2785
- } else if (!isValid) {
2786
- addClass([this.chipWrapper], HIDEICON);
2787
- removeClass([this.inputWrapper], SHOW_CHIP);
2788
- }
2789
- const isValue: boolean = this.value !== null ? (this.value.length !== 0 ? true : false) : false;
2790
- if (isValid && isValue) {
2791
- addClass([this.inputEle], CHIP_INPUT);
2792
- } else {
2793
- removeClass([this.inputEle], CHIP_INPUT);
2794
- }
2795
- } else if (this.inputEle.classList.contains(CHIP_INPUT)) {
2796
- removeClass([this.inputEle], CHIP_INPUT);
2797
- if (this.chipWrapper) {
2798
- addClass([this.chipWrapper], HIDEICON);
2799
- removeClass([this.inputWrapper], SHOW_CHIP);
2800
- }
2801
- }
2802
- }
2803
-
2804
- private ensurePlaceHolder(): void {
2805
- if (isNOU(this.value) || (this.value && this.value.length === 0)) {
2806
- removeClass([this.inputEle], CHIP_INPUT);
2807
- if (this.chipWrapper) {
2808
- addClass([this.chipWrapper], HIDEICON);
2809
- }
2810
- }
2811
- }
2812
- private ensureClearIconPosition(floatLabelType: FloatLabelType): void {
2813
- if (floatLabelType !== 'Never') {
2814
- this.inputWrapper.insertBefore(this.overAllClear, this.inputObj.buttons[0]);
2815
- }
2816
- }
2817
-
2818
- private setMultiSelectValue(newValues: string[]): void {
2819
- if (!this.isFilteredData) {
2820
- this.setProperties({ value: this.isFromFilterChange && newValues && newValues.length == 0 ? this.value : newValues }, true);
2821
- this.isFromFilterChange = false;
2822
- if (newValues && newValues.length !== 0 && !this.showCheckBox) {
2823
- this.treeObj.selectedNodes = this.value.slice();
2824
- this.treeObj.dataBind();
2825
- }
2826
- } else {
2827
- const selectedValues: string[] = isNOU(this.value) ? [] : this.value;
2828
- for (let i: number = 0; i < newValues.length; i++) {
2829
- if (isNOU(this.value) || this.value.indexOf(newValues[i as number]) === -1) {
2830
- selectedValues.push(newValues[i as number]);
2831
- }
2832
- }
2833
- this.setProperties({ value: selectedValues }, true);
2834
- }
2835
- }
2836
-
2837
- private setMultiSelect(): void {
2838
- if (this.showCheckBox && !this.isDynamicChange) {
2839
- this.setMultiSelectValue(this.treeObj.checkedNodes.slice());
2840
- } else {
2841
- const ddtValue: string[] = this.allowMultiSelection ? (this.showCheckBox ? this.treeObj.checkedNodes
2842
- : this.treeObj.selectedNodes) : (this.value ? (this.showCheckBox ? this.value : [this.value[0]]) : null);
2843
- this.setMultiSelectValue(ddtValue);
2844
- if (this.showCheckBox && this.value !== null) {
2845
- this.treeObj.checkedNodes = this.value;
2846
- this.treeObj.dataBind();
2847
- }
2848
- }
2849
- this.selectedText = [];
2850
- const checkSelection: boolean = this.allowMultiSelection ? true : (this.showCheckBox ? true : false);
2851
- if (this.inputWrapper.contains(this.chipWrapper) && !checkSelection) {
2852
- removeClass([this.inputEle], CHIP_INPUT);
2853
- detach(this.chipWrapper);
2854
- }
2855
- const isValid: boolean = this.getValidMode();
2856
- if (isValid && this.value !== null) {
2857
- addClass([this.inputEle], CHIP_INPUT);
2858
- if (this.chipWrapper) {
2859
- removeClass([this.chipWrapper], HIDEICON);
2860
- }
2861
- }
2862
- const isValue: boolean = this.value ? (this.value.length ? true : false) : false;
2863
- if (this.chipWrapper && (this.mode === 'Box' && !isValue)) {
2864
- addClass([this.chipWrapper], HIDEICON);
2865
- removeClass([this.inputEle], CHIP_INPUT);
2866
- }
2867
- this.updateSelectedValues();
2868
- }
2869
-
2870
- // eslint-disable-next-line
2871
- private getSelectedData(value: string): { [key: string]: Object } {
2872
- // eslint-disable-next-line
2873
- let data: { [key: string]: Object } = null;
2874
- if (this.isFilteredData) {
2875
- for (let i: number = 0; i < this.selectedData.length; i++) {
2876
- if (getValue(this.treeSettings.loadOnDemand ? this.fields.value : 'id', this.selectedData[i as number]).toString() === value) {
2877
- data = this.selectedData[i as number];
2878
- break;
2879
- }
2880
- }
2881
- }
2882
- if (isNOU(data)) {
2883
- if (this.treeSettings.loadOnDemand) {
2884
- data = this.getNodeData(value);
2885
- } else {
2886
- data = this.treeObj.getNode(value);
2887
- }
2888
- if (!isNOU(data)) { this.selectedData.push(data); }
2889
- }
2890
- return data;
2891
- }
2892
-
2893
- private getNodeData(id: string): { [key: string]: Object } {
2894
- let childItems: { [key: string]: Object };
2895
- if (isNOU(id)) {
2896
- return childItems;
2897
- } else if (this.treeDataType === 1) {
2898
- for (let i: number = 0, objlen: number = this.treeItems.length; i < objlen; i++) {
2899
- let dataId: Object = getValue(this.fields.value, this.treeItems[i as number]);
2900
- if (!isNOU(this.treeItems[i as number]) && !isNOU(dataId) && dataId.toString() === id) {
2901
- return this.treeItems[i as number];
2902
- }
2903
- }
2904
- } else {
2905
- return this.getChildNodeData(this.treeItems, this.fields, id);
2906
- }
2907
- return childItems;
2908
- }
2909
-
2910
- private getChildNodeData(obj: { [key: string]: Object }[], mapper: FieldsModel, id: string): { [key: string]: Object } {
2911
- let newChildItems: { [key: string]: Object };
2912
- if (isNOU(obj)) {
2913
- return newChildItems;
2914
- }
2915
- for (let i: number = 0, objlen: number = obj.length; i < objlen; i++) {
2916
- let dataValue: Object = getValue(mapper.value, obj[i as number]);
2917
- if (obj[i as number] && dataValue && dataValue.toString() === id) {
2918
- return obj[i as number];
2919
- } else if (typeof mapper.child === 'string' && !isNOU(getValue(mapper.child, obj[i as number]))) {
2920
- let childNodeData: Object = getValue(mapper.child, obj[i as number]);
2921
- newChildItems = this.getChildNodeData(<{ [key: string]: Object }[]>childNodeData, this.getChildMapperFields(mapper), id);
2922
- if (newChildItems !== undefined) {
2923
- break;
2924
- }
2925
- } else if (this.fields.dataSource instanceof DataManager && !isNOU(getValue('child', obj[i as number]))) {
2926
- let child: string = 'child';
2927
- newChildItems = this.getChildNodeData(<{ [key: string]: Object }[]>getValue(child, obj[i as number]), this.getChildMapperFields(mapper), id);
2928
- if (newChildItems !== undefined) {
2929
- break;
2930
- }
2931
- }
2932
- }
2933
- return newChildItems;
2934
- }
2935
-
2936
- private getChildMapperFields(mapper: FieldsSettingsModel): FieldsSettingsModel {
2937
- return (typeof mapper.child === 'string' || isNOU(mapper.child)) ? mapper : mapper.child;
2938
- }
2939
-
2940
- private removeSelectedData(value: string, muteOnChange: boolean): void {
2941
- const selectedValues: string[] = isNOU(this.value) ? [] : this.value.slice();
2942
- selectedValues.splice(selectedValues.indexOf(value), 1);
2943
- this.setProperties({ value: selectedValues }, muteOnChange);
2944
- for (let i: number = 0; i < this.selectedData.length; i++) {
2945
- if (getValue(this.treeSettings.loadOnDemand ? this.fields.value : 'id', this.selectedData[i as number]).toString() === value) {
2946
- this.selectedData.splice(i, 1);
2947
- break;
2948
- }
2949
- }
2950
- }
2951
-
2952
- private updateSelectedValues(): void {
2953
- this.dataValue = '';
2954
- let temp: string;
2955
- let text: string;
2956
- let textValue: string = '';
2957
- // eslint-disable-next-line
2958
- let selectedData: { [key: string]: Object };
2959
- this.hiddenElement.innerHTML = '';
2960
- let hiddenInputValue = '';
2961
- if ((!this.isChipDelete || this.treeSettings.autoCheck) && (this.inputWrapper.contains(this.chipWrapper))) {
2962
- this.chipCollection.innerHTML = '';
2963
- }
2964
- if (!this.isFilteredData) { this.selectedData = []; }
2965
- if (!isNOU(this.value)) {
2966
- for (let i: number = 0, len: number = this.value.length; i < len; i++) {
2967
- selectedData = this.getSelectedData(this.value[i as number]);
2968
- text = getValue(this.treeSettings.loadOnDemand ? this.fields.text : 'text', selectedData);
2969
- this.selectedText.push(text);
2970
- temp = this.selectedText[this.selectedText.length - 1];
2971
- if (this.selectedText.length > 1) {
2972
- this.dataValue += (this.delimiterChar + ' ' + temp);
2973
- textValue += (',' + temp);
2974
- } else {
2975
- this.dataValue += temp;
2976
- textValue += temp;
2977
- }
2978
- if (this.mode !== 'Custom' && this.mode !== 'Delimiter' && (!this.isChipDelete || this.treeSettings.autoCheck) &&
2979
- (this.allowMultiSelection || this.showCheckBox)) {
2980
- this.setChipValues(temp, this.value[i as number]);
2981
- }
2982
- hiddenInputValue += '<option selected value ="' + this.value[i as number] + '">' +
2983
- this.selectedText[this.selectedText.length - 1] + '</option>';
2984
- }
2985
- if (this.selectedText.length >= 1) {
2986
- this.setProperties({ text: textValue }, true);
2987
- }
2988
- this.hiddenElement.innerHTML = hiddenInputValue;
2989
- if (this.mode === 'Custom' && (this.allowMultiSelection || this.showCheckBox)) {
2990
- this.setTagValues();
2991
- }
2992
- }
2993
- const isValid: boolean = this.getValidMode();
2994
- if (this.mode !== 'Custom' && this.mode !== 'Box' && (this.allowMultiSelection || this.showCheckBox) && !isValid) {
2995
- if (this.chipWrapper) {
2996
- addClass([this.chipWrapper], HIDEICON);
2997
- removeClass([this.inputWrapper], SHOW_CHIP);
2998
- }
2999
- }
3000
- Input.setValue(this.dataValue, this.inputEle, this.floatLabelType);
3001
- if (textValue === '') {
3002
- this.setProperties({ text: null }, true);
3003
- } else {
3004
- this.setProperties({ text: textValue }, true);
3005
- }
3006
- if (this.showClearButton && this.inputFocus) {
3007
- this.showOverAllClear();
3008
- }
3009
- if ((this.allowMultiSelection || this.showCheckBox) && this.popupObj) {
3010
- this.popupObj.refreshPosition();
3011
- }
3012
- this.currentText = this.text;
3013
- this.currentValue = this.value;
3014
- }
3015
- private setChipValues(text: string, value: string): void {
3016
- if (!this.inputWrapper.contains(this.chipWrapper)) {
3017
- this.createChip();
3018
- }
3019
- const chip: HTMLElement = this.createElement('span', {
3020
- className: CHIP,
3021
- attrs: { 'data-value': <string>value }
3022
- });
3023
- const chipContent: HTMLElement = this.createElement('span', { className: CHIP_CONTENT });
3024
- const chipClose: HTMLElement = this.createElement('span', { className: CHIP_CLOSE + ' ' + ICONS });
3025
- if (this.enableHtmlSanitizer){
3026
- chipContent.innerText = SanitizeHtmlHelper.sanitize(text);
3027
- }
3028
- else { chipContent.innerHTML = text; }
3029
- chip.appendChild(chipContent);
3030
- this.chipCollection.appendChild(chip);
3031
- if (this.showClearButton) {
3032
- chip.appendChild(chipClose);
3033
- EventHandler.add(chipClose, 'mousedown', this.removeChip, this);
3034
- }
3035
- }
3036
-
3037
- private setTagValues(): void {
3038
- if (this.value === null || this.text == null) { return; }
3039
- if (!this.inputWrapper.contains(this.chipWrapper)) {
3040
- this.createChip();
3041
- }
3042
- if (!this.inputWrapper.classList.contains(SHOW_CHIP)) {
3043
- addClass([this.inputWrapper], SHOW_CHIP);
3044
- }
3045
- const chip: HTMLElement = this.createElement('span', {
3046
- className: CHIP,
3047
- });
3048
- if (!this.inputEle.classList.contains(CHIP_INPUT)) {
3049
- addClass([this.inputEle], CHIP_INPUT);
3050
- }
3051
- if (this.chipWrapper.classList.contains(HIDEICON)) {
3052
- removeClass([this.chipWrapper], HIDEICON);
3053
- }
3054
- const chipContent: HTMLElement = this.createElement('span', { className: CHIP_CONTENT });
3055
- const template: string | Function = this.customTemplate;
3056
- const templateId: string = this.customTemplateId;
3057
- const templatestring: string = 'customTemplate';
3058
- const compiledString: Function = this.templateComplier(template);
3059
- let tempArr: Element[] = compiledString({'value': this.value, 'text': this.text}, this, templatestring, templateId, this.isStringTemplate, undefined, chipContent);
3060
- if (tempArr) {
3061
- tempArr = Array.prototype.slice.call(tempArr);
3062
- append(tempArr, chipContent);
3063
- }
3064
- chip.appendChild(chipContent);
3065
- this.chipCollection.appendChild(chip);
3066
- }
3067
-
3068
- private setSelectAllWrapper(state: boolean): void {
3069
- if (this.isFirstRender) {return; }
3070
- if (state && !this.popupEle.contains(this.checkAllParent) && this.showCheckBox) {
3071
- this.createSelectAllWrapper();
3072
- this.popupEle.insertBefore(this.checkAllParent, this.popupDiv);
3073
- } else if (this.popupEle.contains(this.checkAllParent)) {
3074
- detach(this.checkAllParent);
3075
- this.checkAllParent = null;
3076
- }
3077
- }
3078
-
3079
- private setHeaderTemplate(): void {
3080
- if (this.header) {
3081
- this.header.innerHTML = '';
3082
- } else {
3083
- this.header = this.createElement('div');
3084
- addClass([this.header], HEADER);
3085
- }
3086
- // eslint-disable-next-line
3087
- const compiledString: Function = this.templateComplier(this.headerTemplate);
3088
- let tempArr: Element[] = compiledString({}, this, 'headerTemplate', this.headerTemplateId, this.isStringTemplate, undefined, this.header);
3089
- if (tempArr) {
3090
- tempArr = Array.prototype.slice.call(tempArr);
3091
- append(tempArr, this.header);
3092
- }
3093
- this.popupEle.insertBefore(this.header, this.checkAllParent ? this.checkAllParent : this.popupDiv);
3094
- }
3095
-
3096
- // eslint-disable-next-line
3097
- private templateComplier(template: string | Function): Function {
3098
- if (template) {
3099
- // eslint-disable-next-line
3100
- let e: Object;
3101
- try {
3102
- if (typeof template !== 'function' && document.querySelectorAll(template).length) {
3103
- return compile(document.querySelector(template).innerHTML.trim());
3104
- } else {
3105
- return compile(template);
3106
- }
3107
- } catch (e) {
3108
- return compile(template);
3109
- }
3110
- }
3111
- return compile(template);
3112
- }
3113
-
3114
-
3115
- private setFooterTemplate(): void {
3116
- if (this.footer) {
3117
- this.footer.innerHTML = '';
3118
- } else {
3119
- this.footer = this.createElement('div');
3120
- addClass([this.footer], FOOTER);
3121
- }
3122
- // eslint-disable-next-line
3123
- const compiledString: Function = this.templateComplier(this.footerTemplate);
3124
- let tempArr: Element[] = compiledString({}, this, 'footerTemplate', this.footerTemplateId, this.isStringTemplate, undefined, this.footer);
3125
- if (tempArr) {
3126
- tempArr = Array.prototype.slice.call(tempArr);
3127
- append(tempArr, this.footer);
3128
- }
3129
- append([this.footer], this.popupEle);
3130
- }
3131
-
3132
- private clearAll(e?: MouseEvent): void {
3133
- if (!this.enabled || this.readonly) {
3134
- return;
3135
- }
3136
- this.resetValue();
3137
- this.showOverAllClear();
3138
- if ((this.allowMultiSelection || this.showCheckBox)) {
3139
- if ( this.popupObj) {
3140
- this.popupObj.refreshPosition();
3141
- }
3142
- if (!this.wrapText) {
3143
- this.updateOverflowWrapper(true);
3144
- }
3145
- }
3146
- if (e) {
3147
- this.isClearButtonClick = true;
3148
- }
3149
- if (!this.changeOnBlur) {
3150
- this.triggerChangeEvent(e);
3151
- }
3152
- }
3153
-
3154
- private removeChip(e: MouseEvent): void {
3155
- if (!this.enabled || this.readonly) {
3156
- return;
3157
- }
3158
- const element: HTMLElement = (<HTMLElement>e.target).parentElement;
3159
- const value: string = element.getAttribute('data-value');
3160
- if (this.chipCollection) {
3161
- if (element) {
3162
- remove(element);
3163
- }
3164
- }
3165
- this.isChipDelete = true;
3166
- this.isClearButtonClick = true;
3167
- this.removeSelectedData(value, true);
3168
- this.selectedText = [];
3169
- if (this.allowMultiSelection) {
3170
- this.treeObj.selectedNodes = this.value.slice();
3171
- this.updateSelectedValues();
3172
- }
3173
- if (this.showCheckBox) {
3174
- this.treeObj.uncheckAll([value]);
3175
- this.clearCheckAll();
3176
- this.setMultiSelect();
3177
- }
3178
- this.triggerChangeEvent(e);
3179
- this.isChipDelete = false;
3180
- this.ensurePlaceHolder();
3181
- }
3182
-
3183
- private resetValue(isDynamicChange?: boolean): void {
3184
- if (this.value == [] && this.text == null) { return; }
3185
- Input.setValue(null, this.inputEle, this.floatLabelType);
3186
- if (!isDynamicChange) {
3187
- this.oldValue = this.value;
3188
- this.setProperties({ value: [] }, true);
3189
- }
3190
- this.dataValue = null;
3191
- this.setProperties({ text: null }, true);
3192
- this.selectedData = [];
3193
- setValue('selectedNodes', [], this.treeObj);
3194
- this.hiddenElement.innerHTML = '';
3195
- if (this.showCheckBox) {
3196
- this.treeObj.uncheckAll();
3197
- this.setMultiSelect();
3198
- this.clearCheckAll();
3199
- }
3200
- if (this.oldValue === null && !isDynamicChange) {
3201
- this.removeValue = true;
3202
- } else if (isDynamicChange) {
3203
- this.triggerChangeEvent();
3204
- }
3205
- if ((this.allowMultiSelection || this.showCheckBox) && this.chipWrapper) {
3206
- this.chipCollection.innerHTML = '';
3207
- if (!this.wrapText) {
3208
- this.updateOverflowWrapper(true);
3209
- }
3210
- this.ensurePlaceHolder();
3211
- }
3212
- }
3213
-
3214
- private clearCheckAll(): void {
3215
- if (this.showSelectAll && this.value && this.value.length === 0) {
3216
- this.setLocale(false);
3217
- }
3218
- }
3219
-
3220
- private selectAllItems(state: boolean): void {
3221
- if (this.showCheckBox) {
3222
- if (state) {
3223
- this.isCheckAllCalled = true;
3224
- this.treeObj.checkAll();
3225
- }
3226
- else {
3227
- this.treeObj.uncheckAll();
3228
- }
3229
- this.checkSelectAll = state ;
3230
- } else if (this.allowMultiSelection) {
3231
- if (!state) {
3232
- this.treeObj.selectedNodes = [];
3233
- } else {
3234
- const li: HTMLElement[] = selectAll('li', this.treeObj.element);
3235
- let id: string;
3236
- const arr: string[] = [];
3237
- for (let i: number = 0; i < li.length; i++) {
3238
- id = li[i as number].getAttribute('data-uid').toString();
3239
- arr.push(id);
3240
- }
3241
- this.treeObj.selectedNodes = arr;
3242
- }
3243
- }
3244
- this.updateMode();
3245
- this.setMultiSelect();
3246
- if (!this.wrapText) {
3247
- if (state) { this.updateView(); } else{ this.updateOverflowWrapper(true); }
3248
- }
3249
- }
3250
-
3251
- private updateTreeSettings(prop: DropDownTreeModel): void {
3252
- const value: string = Object.keys(prop.treeSettings)[0];
3253
- if (value === 'autoCheck') {
3254
- this.treeObj.autoCheck = this.treeSettings.autoCheck;
3255
- } else if (value === 'loadOnDemand') {
3256
- this.treeObj.loadOnDemand = this.treeSettings.loadOnDemand;
3257
- } else if (value === 'expandOn') {
3258
- this.treeObj.expandOn = this.treeSettings.expandOn;
3259
- this.treeObj.dataBind();
3260
- return;
3261
- }
3262
- this.treeObj.dataBind();
3263
- this.setMultiSelect();
3264
- this.updateValue(this.value);
3265
- }
3266
-
3267
- private updateCheckBoxState(checkBox: boolean): void {
3268
- if (this.hasTemplate) {
3269
- this.updateTemplate();
3270
- }
3271
- if (!this.wrapText) {
3272
- this.updateOverflowWrapper(false);
3273
- }
3274
- this.treeObj.showCheckBox = checkBox;
3275
- this.treeObj.dataBind();
3276
- this.isDynamicChange = true;
3277
- this.setSelectAllWrapper(this.showSelectAll);
3278
- if (this.showSelectAll) {
3279
- this.setLocale();
3280
- }
3281
- if (this.showCheckBox) {
3282
- this.updateMode();
3283
- }
3284
- this.setMultiSelect();
3285
- this.isDynamicChange = false;
3286
- }
3287
-
3288
-
3289
- private updateTemplate(): void {
3290
- if (this.popupObj) {
3291
- this.clearTemplate();
3292
- /* eslint-disable */
3293
- (this as any).portals = [];
3294
- /* eslint-enable */
3295
- this.popupObj.destroy();
3296
- if (this.isPopupOpen) {
3297
- this.hidePopup();
3298
- this.isFirstRender = true;
3299
- this.renderPopup();
3300
- } else {
3301
- this.isFirstRender = true;
3302
- }
3303
- }
3304
- }
3305
-
3306
- private l10nUpdate(actionFailure?: boolean): void {
3307
- if (this.noRecord) {
3308
- this.noRecord.innerHTML = '';
3309
- } else {
3310
- this.noRecord = this.createElement('div');
3311
- }
3312
- if (this.noRecordsTemplate !== 'No Records Found' || this.actionFailureTemplate !== 'The Request Failed') {
3313
- const template: string | Function = actionFailure ? this.actionFailureTemplate : this.noRecordsTemplate;
3314
- const templateId: string = actionFailure ? this.actionFailureTemplateId : this.noRecordsTemplateId;
3315
- const templatestring: string = actionFailure ? 'actionFailureTemplate' : 'noRecordsTemplate';
3316
- // eslint-disable-next-line
3317
- const compiledString: Function = this.templateComplier(template);
3318
- let tempArr: Element[] = compiledString({}, this, templatestring, templateId, this.isStringTemplate, undefined, this.noRecord);
3319
- if (tempArr) {
3320
- tempArr = Array.prototype.slice.call(tempArr);
3321
- append(tempArr, this.noRecord);
3322
- }
3323
- } else {
3324
- // eslint-disable-next-line
3325
- const l10nLocale: Object = { noRecordsTemplate: 'No Records Found', actionFailureTemplate: 'The Request Failed'};
3326
- this.l10n = new L10n(this.getLocaleName(), l10nLocale, this.locale);
3327
- this.noRecord.innerHTML = actionFailure ?
3328
- this.l10n.getConstant('actionFailureTemplate') : this.l10n.getConstant('noRecordsTemplate');
3329
- }
3330
- addClass([this.noRecord], NODATACONTAINER);
3331
- prepend([this.noRecord], this.popupDiv);
3332
- }
3333
-
3334
- private updateRecordTemplate(action?: boolean): void {
3335
- if (this.treeItems && this.treeItems.length <= 0) {
3336
- this.l10nUpdate(action);
3337
- if (this.hasTemplate) {
3338
- this.updateTemplate();
3339
- }
3340
- }
3341
- }
3342
-
3343
- private updateOverflowWrapper(state: boolean): void {
3344
- if (!state) {
3345
- if (!this.inputWrapper.contains(this.overFlowWrapper)) {
3346
- this.overFlowWrapper = this.createElement('span', { className: OVERFLOW_VIEW + ' ' + HIDEICON });
3347
- this.inputWrapper.insertBefore(this.overFlowWrapper, this.hiddenElement);
3348
- }
3349
- } else if (this.inputWrapper.contains(this.overFlowWrapper) && state) {
3350
- this.overFlowWrapper.innerHTML = '';
3351
- }
3352
- }
3353
-
3354
-
3355
- private updateMultiSelection(state: boolean): void {
3356
- if (!this.wrapText) {
3357
- this.updateOverflowWrapper(false);
3358
- }
3359
- this.treeObj.allowMultiSelection = state;
3360
- this.treeObj.dataBind();
3361
- this.updateOption();
3362
- if (this.allowMultiSelection) {
3363
- this.updateMode();
3364
- }
3365
- this.setMultiSelect();
3366
- }
3367
-
3368
- private updateAllowFiltering(state: boolean): void {
3369
- if (!this.isFirstRender) {
3370
- if (state) {
3371
- this.renderFilter();
3372
- } else {
3373
- this.destroyFilter();
3374
- }
3375
- }
3376
- }
3377
-
3378
- private updateFilterPlaceHolder(): void {
3379
- if (this.filterObj) {
3380
- this.filterObj.placeholder = this.filterBarPlaceholder;
3381
- this.filterObj.element.setAttribute('aria-label', this.filterBarPlaceholder);
3382
- }
3383
- }
3384
-
3385
- private updateValue(value: string[]): void {
3386
- this.isDynamicChange = true;
3387
- if (isNOU(value) || value.length === 0) {
3388
- this.resetValue(true);
3389
- } else {
3390
- this.setTreeValue();
3391
- if ((this.allowMultiSelection || this.showCheckBox) && !this.wrapText) {
3392
- this.updateOverflowWrapper(false);
3393
- this.updateView();
3394
- }
3395
- }
3396
- this.updateHiddenValue();
3397
- this.isDynamicChange = false;
3398
- }
3399
-
3400
- private updateText(text: string): void {
3401
- if (isNOU(text)) {
3402
- this.resetValue();
3403
- } else {
3404
- this.setTreeText();
3405
- if ((this.allowMultiSelection || this.showCheckBox) && !this.wrapText) {
3406
- this.updateOverflowWrapper(false);
3407
- this.updateView();
3408
- }
3409
- }
3410
- this.updateHiddenValue();
3411
- }
3412
-
3413
- private updateModelMode(): void {
3414
- const validMode: boolean = this.allowMultiSelection ? true : (this.showCheckBox ? true : false);
3415
- if (!validMode) { return; }
3416
- if (!this.wrapText) {
3417
- const overFlow: Element = select('.' + OVERFLOW_VIEW, this.inputWrapper);
3418
- if (overFlow) {
3419
- overFlow.innerHTML = '';
3420
- }
3421
- }
3422
- this.updateMode();
3423
- this.setMultiSelect();
3424
- if (!this.wrapText && (this.value && this.value.length !== 0)) {
3425
- this.updateOverFlowView();
3426
- addClass([this.inputEle], CHIP_INPUT);
3427
- if (this.mode === 'Box') {
3428
- removeClass([this.overFlowWrapper, this.inputWrapper], SHOW_TEXT);
3429
- } else {
3430
- addClass([this.overFlowWrapper, this.inputWrapper], SHOW_TEXT);
3431
- }
3432
- }
3433
- }
3434
-
3435
- private updateOption(): void {
3436
- if (!this.hiddenElement.hasAttribute('multiple') && (this.allowMultiSelection || this.showCheckBox)) {
3437
- this.hiddenElement.setAttribute('multiple', '');
3438
- } else if (this.hiddenElement.hasAttribute('multiple') && (!this.allowMultiSelection && !this.showCheckBox)) {
3439
- this.hiddenElement.removeAttribute('multiple');
3440
- }
3441
- }
3442
-
3443
- /**
3444
- * Dynamically change the value of properties.
3445
- *
3446
- * @param {DropDownTreeModel} newProp - specifies the newProp value.
3447
- * @param {DropDownTreeModel} oldProp - specifies the newProp value.
3448
- * @returns {void}
3449
- * @private
3450
- */
3451
- public onPropertyChanged(newProp: DropDownTreeModel, oldProp: DropDownTreeModel): void {
3452
- for (const prop of Object.keys(newProp)) {
3453
- switch (prop) {
3454
- case 'width': this.setElementWidth(newProp.width);
3455
- if (this.popupObj) {
3456
- this.popupObj.element.style.width = this.setWidth();
3457
- }
3458
- break;
3459
- case 'placeholder': Input.setPlaceholder(newProp.placeholder, this.inputEle); break;
3460
- case 'cssClass': this.setCssClass(newProp.cssClass, oldProp.cssClass); break;
3461
- case 'enableRtl': this.setEnableRTL(this.enableRtl); break;
3462
- case 'fields': this.setFields(); break;
3463
- case 'readonly': Input.setReadonly(newProp.readonly, this.inputEle); break;
3464
- case 'enabled': this.setEnable(); break;
3465
- case 'floatLabelType':
3466
- Input.removeFloating(this.inputObj);
3467
- Input.addFloating(this.inputEle, newProp.floatLabelType, this.placeholder, this.createElement);
3468
- this.ensureClearIconPosition(newProp.floatLabelType);
3469
- break;
3470
- case 'showClearButton': this.updateClearButton(newProp.showClearButton); break;
3471
- case 'allowFiltering':
3472
- this.updateAllowFiltering(newProp.allowFiltering);
3473
- break;
3474
- case 'filterBarPlaceholder':
3475
- this.updateFilterPlaceHolder();
3476
- break;
3477
- case 'value':
3478
- this.oldValue = oldProp.value;
3479
- this.updateValue(newProp.value); break;
3480
- case 'text': this.updateText(newProp.text); break;
3481
- case 'allowMultiSelection': this.updateMultiSelection(newProp.allowMultiSelection); break;
3482
- case 'mode':
3483
- if (!this.showCheckBox && !this.allowMultiSelection) { return;}
3484
- if (this.mode === 'Custom') {
3485
- if (this.overFlowWrapper) {
3486
- detach(this.overFlowWrapper);
3487
- }
3488
- if (this.chipWrapper) {
3489
- detach(this.chipWrapper);
3490
- }
3491
- this.setTagValues();
3492
- } else {
3493
- if (oldProp.mode === 'Custom') { this.updateOverflowWrapper(this.wrapText); }
3494
- this.updateModelMode();
3495
- }
3496
- break;
3497
- case 'delimiterChar':
3498
- if (this.mode === 'Box') { return; }
3499
- if (this.showCheckBox || this.allowMultiSelection) {
3500
- this.setMultiSelect();
3501
- }
3502
- break;
3503
- case 'selectAllText':
3504
- if (this.showCheckBox && this.showSelectAll) { this.setLocale(); }
3505
- break;
3506
- case 'unSelectAllText':
3507
- if (this.showCheckBox && this.showSelectAll) { this.setLocale(false); }
3508
- break;
3509
- case 'showSelectAll':
3510
- if (this.showCheckBox) {
3511
- this.setSelectAllWrapper(newProp.showSelectAll);
3512
- this.updatePopupHeight();
3513
- }
3514
- break;
3515
- case 'showCheckBox':
3516
- this.updateCheckBoxState(newProp.showCheckBox);
3517
- if (!this.wrapText) {
3518
- this.updateOverflowWrapper(true);
3519
- }
3520
- this.updatePopupHeight();
3521
- this.updateOption();
3522
- break;
3523
- case 'treeSettings':
3524
- this.updateTreeSettings(newProp);
3525
- break;
3526
- case 'customTemplate':
3527
- if (this.mode !== "Custom") { return; }
3528
- this.chipCollection.innerHTML = "";
3529
- this.setTagValues();
3530
- break;
3531
- case 'sortOrder':
3532
- if (this.hasTemplate) { this.updateTemplate(); }
3533
- this.treeObj.sortOrder = newProp.sortOrder;
3534
- this.treeObj.dataBind();
3535
- this.updateValue(this.value);
3536
- break;
3537
- case 'showDropDownIcon': this.updateDropDownIconState(newProp.showDropDownIcon); break;
3538
- case 'popupWidth':
3539
- if (this.popupObj) {
3540
- this.popupObj.element.style.width = this.setWidth();
3541
- }
3542
- break;
3543
- case 'popupHeight':
3544
- if (this.popupObj) {
3545
- this.updatePopupHeight();
3546
- }
3547
- break;
3548
- case 'zIndex':
3549
- if (this.popupObj) {
3550
- this.popupObj.zIndex = newProp.zIndex;
3551
- this.popupObj.dataBind();
3552
- }
3553
- break;
3554
- case 'headerTemplate': this.updateTemplate(); break;
3555
- case 'footerTemplate': this.updateTemplate(); break;
3556
- case 'itemTemplate':
3557
- this.updateTemplate();
3558
- this.treeObj.nodeTemplate = newProp.itemTemplate;
3559
- this.treeObj.dataBind();
3560
- break;
3561
- case 'noRecordsTemplate': this.updateRecordTemplate(); break;
3562
- case 'actionFailureTemplate':
3563
- this.updateRecordTemplate(true);
3564
- break;
3565
- case 'htmlAttributes': this.setHTMLAttributes(); break;
3566
- case 'wrapText':
3567
- this.updateOverflowWrapper(this.wrapText);
3568
- if ((this.allowMultiSelection || this.showCheckBox) && !this.wrapText) {
3569
- this.updateView();
3570
- } else {
3571
- addClass([this.overFlowWrapper], HIDEICON);
3572
- if (this.chipWrapper && this.mode === 'Box') {
3573
- removeClass([this.chipWrapper], HIDEICON);
3574
- } else {
3575
- removeClass([this.inputWrapper], SHOW_CHIP);
3576
- removeClass([this.inputEle], CHIP_INPUT);
3577
- }
3578
- this.ensurePlaceHolder();
3579
- }
3580
- break;
3581
- }
3582
- }
3583
- }
3584
-
3585
- /**
3586
- * Allows you to clear the selected values from the Dropdown Tree component.
3587
- *
3588
- * @method clear
3589
- * @returns {void}
3590
- */
3591
- public clear(): void {
3592
- this.clearAll();
3593
- if (this.inputFocus) {
3594
- this.onFocusOut();
3595
- } else {
3596
- if (this.changeOnBlur) {
3597
- this.triggerChangeEvent();
3598
- }
3599
- this.removeValue = false;
3600
- }
3601
- }
3602
-
3603
- /**
3604
- * Removes the component from the DOM and detaches all its related event handlers. Also, it removes the attributes and classes.
3605
- *
3606
- * @method destroy
3607
- * @returns {void}
3608
- */
3609
- public destroy(): void {
3610
- this.clearTemplate();
3611
- this.unWireEvents();
3612
- this.setCssClass(null, this.cssClass);
3613
- this.setProperties({ text: null }, true);
3614
- this.treeObj.destroy();
3615
- this.destroyFilter();
3616
- if (this.popupObj) {
3617
- this.popupObj.destroy();
3618
- detach(this.popupObj.element);
3619
- }
3620
- if (this.element.tagName !== this.getDirective()) {
3621
- this.inputWrapper.parentElement.insertBefore(this.element, this.inputWrapper);
3622
- }
3623
- Input.setValue(null, this.inputEle, this.floatLabelType);
3624
- detach(this.inputWrapper);
3625
- detach(this.popupDiv);
3626
- detach(this.hiddenElement);
3627
- this.element.classList.remove('e-input');
3628
- if (this.showCheckBox || this.allowMultiSelection) {
3629
- this.element.classList.remove(CHIP_INPUT);
3630
- }
3631
- this.inputObj = null;
3632
- while (this.hiddenElement.options.length > 0) {
3633
- this.hiddenElement.remove(0);
3634
- }
3635
- this.hiddenElement.innerHTML = '';
3636
- this.hiddenElement = null;
3637
- this.inputWrapper = null;
3638
- this.popupDiv = null;
3639
- this.tree = null;
3640
- this.popupObj = null;
3641
- this.treeObj = null;
3642
- this.overAllClear = null;
3643
- this.chipWrapper = null;
3644
- this.chipCollection = null;
3645
- this.checkAllParent = null;
3646
- this.selectAllSpan = null;
3647
- this.checkBoxElement = null;
3648
- this.checkWrapper = null;
3649
- this.popupEle = null;
3650
- this.header = null;
3651
- this.footer = null;
3652
- this.overFlowWrapper = null;
3653
- this.keyboardModule = null;
3654
- super.destroy();
3655
- this.setProperties({ value: [] }, true);
3656
- }
3657
-
3658
- private destroyFilter(): void {
3659
- if (this.filterObj) {
3660
- this.filterObj.destroy();
3661
- detach(this.filterObj.element);
3662
- detach(this.filterContainer);
3663
- this.filterObj = null;
3664
- }
3665
- }
3666
-
3667
- /**
3668
- * Ensures visibility of the Dropdown Tree item by using item value or item element.
3669
- * If many Dropdown Tree items are present, and we are in need to find a particular item, then the `ensureVisible` property
3670
- * helps you to bring the item to visibility by expanding the Dropdown Tree and scrolling to the specific item.
3671
- *
3672
- * @param {string | Element} item - Specifies the value of Dropdown Tree item/ Dropdown Tree item element.
3673
- * @returns {void}
3674
- */
3675
- public ensureVisible(item: string | Element): void {
3676
- this.treeObj.ensureVisible(item);
3677
- }
3678
-
3679
- /**
3680
- * To get the updated data source of the Dropdown Tree.
3681
- *
3682
- * @param {string | Element} item - Specifies the value of Dropdown Tree item/ Dropdown Tree item element
3683
- * @returns {'{[key: string]: Object }[]'} - returns the updated data source of the Dropdown Tree.
3684
- */
3685
- // eslint-disable-next-line
3686
- public getData(item?: string | Element): { [key: string]: Object }[] {
3687
- return this.treeObj.getTreeData(item);
3688
- }
3689
-
3690
- /**
3691
- * Close the Dropdown tree pop-up.
3692
- *
3693
- * @returns {void}
3694
- */
3695
- public hidePopup(): void {
3696
- const eventArgs: DdtPopupEventArgs = { popup: this.popupObj };
3697
- this.inputWrapper.classList.remove(ICONANIMATION);
3698
- if (this.popupEle) {
3699
- addClass([this.popupEle], DDTHIDEICON);
3700
- }
3701
- attributes(this.inputEle, { 'aria-expanded': 'false' });
3702
- if (this.popupObj && this.isPopupOpen) {
3703
- this.popupObj.hide();
3704
- if (this.inputFocus) {
3705
- this.inputWrapper.focus();
3706
- if (this.allowFiltering) {
3707
- addClass([this.inputWrapper], [INPUTFOCUS]);
3708
- }
3709
- }
3710
- this.trigger('close', eventArgs);
3711
- }
3712
- }
3713
-
3714
- /**
3715
- * Based on the state parameter, entire list item will be selected or deselected.
3716
- *
3717
- * @param {boolean} state - Unselects/Selects entire Dropdown Tree items.
3718
- * @returns {void}
3719
- *
3720
- */
3721
- public selectAll(state: boolean): void {
3722
- this.selectAllItems(state);
3723
- }
3724
-
3725
- /**
3726
- * Opens the popup that displays the Dropdown Tree items.
3727
- *
3728
- * @returns {void}
3729
- */
3730
- public showPopup(): void {
3731
- if (!this.enabled || this.readonly || this.isPopupOpen) {
3732
- return;
3733
- }
3734
- this.renderPopup();
3735
- this.focusIn();
3736
- }
3737
-
3738
- /**
3739
- * Return the module name.
3740
- *
3741
- * @private
3742
- * @returns {string} - returns the module name.
3743
- */
3744
- public getModuleName(): string {
3745
- return 'dropdowntree';
3746
- }
3747
- }