@syncfusion/ej2-dropdowns 18.1.57 → 18.2.44-4569

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 (183) hide show
  1. package/.eslintrc.json +244 -0
  2. package/CHANGELOG.md +1524 -1514
  3. package/README.md +118 -118
  4. package/dist/ej2-dropdowns.umd.min.js +1 -10
  5. package/dist/ej2-dropdowns.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-dropdowns.es2015.js +198 -126
  7. package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
  8. package/dist/es6/ej2-dropdowns.es5.js +290 -217
  9. package/dist/es6/ej2-dropdowns.es5.js.map +1 -1
  10. package/dist/global/ej2-dropdowns.min.js +1 -10
  11. package/dist/global/ej2-dropdowns.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/auto-complete/auto-complete.ts +527 -0
  14. package/dist/ts/combo-box/combo-box.ts +957 -0
  15. package/dist/ts/common/highlight-search.ts +47 -0
  16. package/dist/ts/common/incremental-search.ts +81 -0
  17. package/dist/ts/drop-down-base/drop-down-base.ts +1572 -0
  18. package/dist/ts/drop-down-list/drop-down-list.ts +2993 -0
  19. package/dist/ts/drop-down-tree/drop-down-tree.ts +3066 -0
  20. package/dist/ts/list-box/list-box.ts +2317 -0
  21. package/dist/ts/multi-select/checkbox-selection.ts +528 -0
  22. package/dist/ts/multi-select/float-label.ts +155 -0
  23. package/dist/ts/multi-select/interface.ts +66 -0
  24. package/dist/ts/multi-select/multi-select.ts +4216 -0
  25. package/helpers/e2e/index.js +3 -3
  26. package/license +2 -2
  27. package/package.json +77 -77
  28. package/src/auto-complete/auto-complete-model.d.ts +179 -179
  29. package/src/auto-complete/auto-complete.d.ts +12 -12
  30. package/src/auto-complete/auto-complete.js +21 -21
  31. package/src/combo-box/combo-box-model.d.ts +212 -212
  32. package/src/combo-box/combo-box.d.ts +27 -27
  33. package/src/combo-box/combo-box.js +29 -29
  34. package/src/common/incremental-search.d.ts +1 -1
  35. package/src/common/incremental-search.js +4 -2
  36. package/src/drop-down-base/drop-down-base-model.d.ts +191 -191
  37. package/src/drop-down-base/drop-down-base.d.ts +17 -17
  38. package/src/drop-down-base/drop-down-base.js +20 -20
  39. package/src/drop-down-list/drop-down-list-model.d.ts +222 -222
  40. package/src/drop-down-list/drop-down-list.d.ts +3 -2
  41. package/src/drop-down-list/drop-down-list.js +43 -30
  42. package/src/drop-down-tree/drop-down-tree-model.d.ts +344 -344
  43. package/src/drop-down-tree/drop-down-tree.js +32 -26
  44. package/src/list-box/index.d.ts +1 -0
  45. package/src/list-box/index.js +1 -0
  46. package/src/list-box/list-box-model.d.ts +156 -156
  47. package/src/list-box/list-box.d.ts +2 -2
  48. package/src/list-box/list-box.js +57 -59
  49. package/src/multi-select/index.d.ts +1 -0
  50. package/src/multi-select/index.js +1 -0
  51. package/src/multi-select/multi-select-model.d.ts +452 -452
  52. package/src/multi-select/multi-select.d.ts +2 -0
  53. package/src/multi-select/multi-select.js +98 -43
  54. package/styles/_all.scss +3 -3
  55. package/styles/auto-complete/_bootstrap-dark-definition.scss +3 -3
  56. package/styles/auto-complete/_bootstrap4-definition.scss +11 -11
  57. package/styles/auto-complete/_fabric-dark-definition.scss +2 -2
  58. package/styles/auto-complete/_highcontrast-light-definition.scss +2 -2
  59. package/styles/auto-complete/_material-dark-definition.scss +2 -2
  60. package/styles/bootstrap-dark.css +67 -61
  61. package/styles/bootstrap.css +69 -63
  62. package/styles/bootstrap4.css +81 -61
  63. package/styles/combo-box/_bootstrap-dark-definition.scss +2 -2
  64. package/styles/combo-box/_bootstrap4-definition.scss +11 -11
  65. package/styles/combo-box/_fabric-dark-definition.scss +2 -2
  66. package/styles/combo-box/_highcontrast-light-definition.scss +3 -3
  67. package/styles/combo-box/_material-dark-definition.scss +2 -2
  68. package/styles/drop-down-base/_all.scss +2 -2
  69. package/styles/drop-down-base/_bootstrap-dark-definition.scss +64 -64
  70. package/styles/drop-down-base/_bootstrap-definition.scss +64 -64
  71. package/styles/drop-down-base/_bootstrap4-definition.scss +78 -78
  72. package/styles/drop-down-base/_definition.scss +23 -23
  73. package/styles/drop-down-base/_fabric-dark-definition.scss +68 -68
  74. package/styles/drop-down-base/_fabric-definition.scss +66 -66
  75. package/styles/drop-down-base/_highcontrast-definition.scss +82 -82
  76. package/styles/drop-down-base/_highcontrast-light-definition.scss +81 -81
  77. package/styles/drop-down-base/_layout.scss +108 -108
  78. package/styles/drop-down-base/_material-dark-definition.scss +67 -67
  79. package/styles/drop-down-base/_material-definition.scss +65 -65
  80. package/styles/drop-down-base/_theme.scss +242 -242
  81. package/styles/drop-down-list/_all.scss +2 -2
  82. package/styles/drop-down-list/_bootstrap-dark-definition.scss +157 -157
  83. package/styles/drop-down-list/_bootstrap-definition.scss +156 -156
  84. package/styles/drop-down-list/_bootstrap4-definition.scss +184 -184
  85. package/styles/drop-down-list/_fabric-dark-definition.scss +127 -127
  86. package/styles/drop-down-list/_fabric-definition.scss +122 -122
  87. package/styles/drop-down-list/_highcontrast-definition.scss +131 -131
  88. package/styles/drop-down-list/_highcontrast-light-definition.scss +133 -133
  89. package/styles/drop-down-list/_layout.scss +218 -218
  90. package/styles/drop-down-list/_material-dark-definition.scss +143 -143
  91. package/styles/drop-down-list/_material-definition.scss +166 -166
  92. package/styles/drop-down-list/_theme.scss +10 -10
  93. package/styles/drop-down-list/icons/_bootstrap-dark.scss +14 -14
  94. package/styles/drop-down-list/icons/_bootstrap.scss +14 -14
  95. package/styles/drop-down-list/icons/_bootstrap4.scss +14 -14
  96. package/styles/drop-down-list/icons/_fabric-dark.scss +14 -14
  97. package/styles/drop-down-list/icons/_fabric.scss +14 -14
  98. package/styles/drop-down-list/icons/_highcontrast-light.scss +14 -14
  99. package/styles/drop-down-list/icons/_highcontrast.scss +14 -14
  100. package/styles/drop-down-list/icons/_material-dark.scss +14 -14
  101. package/styles/drop-down-list/icons/_material.scss +14 -14
  102. package/styles/drop-down-list/material.css +9 -0
  103. package/styles/drop-down-tree/_all.scss +2 -2
  104. package/styles/drop-down-tree/_bootstrap-dark-definition.scss +62 -49
  105. package/styles/drop-down-tree/_bootstrap-definition.scss +62 -49
  106. package/styles/drop-down-tree/_bootstrap4-definition.scss +63 -50
  107. package/styles/drop-down-tree/_fabric-dark-definition.scss +63 -49
  108. package/styles/drop-down-tree/_fabric-definition.scss +63 -49
  109. package/styles/drop-down-tree/_highcontrast-definition.scss +63 -49
  110. package/styles/drop-down-tree/_highcontrast-light-definition.scss +63 -49
  111. package/styles/drop-down-tree/_layout.scss +437 -398
  112. package/styles/drop-down-tree/_material-dark-definition.scss +61 -54
  113. package/styles/drop-down-tree/_material-definition.scss +61 -54
  114. package/styles/drop-down-tree/_theme.scss +68 -63
  115. package/styles/drop-down-tree/bootstrap-dark.css +67 -61
  116. package/styles/drop-down-tree/bootstrap.css +69 -63
  117. package/styles/drop-down-tree/bootstrap4.css +81 -61
  118. package/styles/drop-down-tree/fabric-dark.css +71 -63
  119. package/styles/drop-down-tree/fabric.css +71 -63
  120. package/styles/drop-down-tree/highcontrast-light.css +71 -63
  121. package/styles/drop-down-tree/highcontrast.css +75 -63
  122. package/styles/drop-down-tree/icons/_bootstrap-dark.scss +11 -11
  123. package/styles/drop-down-tree/icons/_bootstrap.scss +11 -11
  124. package/styles/drop-down-tree/icons/_bootstrap4.scss +11 -11
  125. package/styles/drop-down-tree/icons/_fabric-dark.scss +11 -11
  126. package/styles/drop-down-tree/icons/_fabric.scss +11 -11
  127. package/styles/drop-down-tree/icons/_highcontrast-light.scss +11 -11
  128. package/styles/drop-down-tree/icons/_highcontrast.scss +11 -11
  129. package/styles/drop-down-tree/icons/_material-dark.scss +11 -11
  130. package/styles/drop-down-tree/icons/_material.scss +11 -11
  131. package/styles/drop-down-tree/material-dark.css +76 -85
  132. package/styles/drop-down-tree/material.css +93 -85
  133. package/styles/fabric-dark.css +71 -63
  134. package/styles/fabric.css +71 -63
  135. package/styles/highcontrast-light.css +71 -63
  136. package/styles/highcontrast.css +75 -63
  137. package/styles/list-box/_all.scss +2 -2
  138. package/styles/list-box/_bootstrap-dark-definition.scss +118 -118
  139. package/styles/list-box/_bootstrap-definition.scss +112 -112
  140. package/styles/list-box/_bootstrap4-definition.scss +118 -118
  141. package/styles/list-box/_fabric-dark-definition.scss +118 -118
  142. package/styles/list-box/_fabric-definition.scss +112 -112
  143. package/styles/list-box/_highcontrast-definition.scss +112 -112
  144. package/styles/list-box/_highcontrast-light-definition.scss +118 -118
  145. package/styles/list-box/_layout.scss +458 -458
  146. package/styles/list-box/_material-dark-definition.scss +118 -118
  147. package/styles/list-box/_material-definition.scss +112 -112
  148. package/styles/list-box/_theme.scss +273 -273
  149. package/styles/list-box/icons/_bootstrap-dark.scss +25 -25
  150. package/styles/list-box/icons/_bootstrap.scss +25 -25
  151. package/styles/list-box/icons/_bootstrap4.scss +25 -25
  152. package/styles/list-box/icons/_fabric-dark.scss +25 -25
  153. package/styles/list-box/icons/_fabric.scss +25 -25
  154. package/styles/list-box/icons/_highcontrast-light.scss +25 -25
  155. package/styles/list-box/icons/_highcontrast.scss +25 -25
  156. package/styles/list-box/icons/_material-dark.scss +25 -25
  157. package/styles/list-box/icons/_material.scss +25 -25
  158. package/styles/list-box/material-dark.css +4 -4
  159. package/styles/list-box/material.css +4 -4
  160. package/styles/material-dark.css +80 -89
  161. package/styles/material.css +115 -89
  162. package/styles/multi-select/_all.scss +2 -2
  163. package/styles/multi-select/_bootstrap-dark-definition.scss +171 -171
  164. package/styles/multi-select/_bootstrap-definition.scss +166 -166
  165. package/styles/multi-select/_bootstrap4-definition.scss +233 -233
  166. package/styles/multi-select/_fabric-dark-definition.scss +170 -170
  167. package/styles/multi-select/_fabric-definition.scss +167 -167
  168. package/styles/multi-select/_highcontrast-definition.scss +257 -257
  169. package/styles/multi-select/_highcontrast-light-definition.scss +258 -258
  170. package/styles/multi-select/_layout.scss +1153 -1153
  171. package/styles/multi-select/_material-dark-definition.scss +186 -186
  172. package/styles/multi-select/_material-definition.scss +191 -191
  173. package/styles/multi-select/_theme.scss +384 -384
  174. package/styles/multi-select/icons/_bootstrap-dark.scss +26 -26
  175. package/styles/multi-select/icons/_bootstrap.scss +26 -26
  176. package/styles/multi-select/icons/_bootstrap4.scss +37 -37
  177. package/styles/multi-select/icons/_fabric-dark.scss +26 -26
  178. package/styles/multi-select/icons/_fabric.scss +26 -26
  179. package/styles/multi-select/icons/_highcontrast-light.scss +26 -26
  180. package/styles/multi-select/icons/_highcontrast.scss +26 -26
  181. package/styles/multi-select/icons/_material-dark.scss +26 -26
  182. package/styles/multi-select/icons/_material.scss +324 -324
  183. package/styles/multi-select/material.css +9 -0
@@ -0,0 +1,4216 @@
1
+ /// <reference path='../drop-down-base/drop-down-base-model.d.ts'/>
2
+ import { DropDownBase, SelectEventArgs, dropDownBaseClasses, PopupEventArgs, FilteringEventArgs } from '../drop-down-base/drop-down-base';
3
+ import { ResultData, FocusEventArgs, BeforeOpenEventArgs, FilterType, FieldSettings } from '../drop-down-base/drop-down-base';
4
+ import { FieldSettingsModel } from '../drop-down-base/drop-down-base-model';
5
+ import { Popup, createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
6
+ import { IInput, FloatLabelType } from '@syncfusion/ej2-inputs';
7
+ import { attributes, setValue } from '@syncfusion/ej2-base';
8
+ import { NotifyPropertyChanges, extend } from '@syncfusion/ej2-base';
9
+ import { EventHandler, Property, Event, compile, L10n, EmitType, KeyboardEventArgs } from '@syncfusion/ej2-base';
10
+ import { Animation, AnimationModel, Browser, prepend, isBlazor, Complex } from '@syncfusion/ej2-base';
11
+ import { MultiSelectModel } from '../multi-select';
12
+ import { Search } from '../common/incremental-search';
13
+ import { append, addClass, removeClass, closest, detach, remove, select } from '@syncfusion/ej2-base';
14
+ import { getUniqueID, formatUnit, isNullOrUndefined, isUndefined, ModuleDeclaration } from '@syncfusion/ej2-base';
15
+ /* tslint:disable */
16
+ import { DataManager, Query, Predicate } from '@syncfusion/ej2-data';
17
+ import { SortOrder } from '@syncfusion/ej2-lists';
18
+ import { CheckBoxSelection } from './checkbox-selection';
19
+ import { createFloatLabel, removeFloating, floatLabelFocus, floatLabelBlur } from './float-label';
20
+ import { IMulitSelect } from './interface';
21
+ export interface RemoveEventArgs extends SelectEventArgs { }
22
+ /* tslint:enable */
23
+ const FOCUS: string = 'e-input-focus';
24
+ const DISABLED: string = 'e-disabled';
25
+ const OVER_ALL_WRAPPER: string = 'e-multiselect e-input-group e-control-wrapper';
26
+ const ELEMENT_WRAPPER: string = 'e-multi-select-wrapper';
27
+ const ELEMENT_MOBILE_WRAPPER: string = 'e-mob-wrapper';
28
+ const HIDE_LIST: string = 'e-hide-listitem';
29
+ const DELIMITER_VIEW: string = 'e-delim-view';
30
+ const CHIP_WRAPPER: string = 'e-chips-collection';
31
+ const CHIP: string = 'e-chips';
32
+ const CHIP_CONTENT: string = 'e-chipcontent';
33
+ const CHIP_CLOSE: string = 'e-chips-close';
34
+ const CHIP_SELECTED: string = 'e-chip-selected';
35
+ const SEARCHBOX_WRAPPER: string = 'e-searcher';
36
+ const DELIMITER_VIEW_WRAPPER: string = 'e-delimiter';
37
+ const ZERO_SIZE: string = 'e-zero-size';
38
+ const REMAIN_WRAPPER: string = 'e-remain';
39
+ const CLOSEICON_CLASS: string = 'e-chips-close e-close-hooker';
40
+ const DELIMITER_WRAPPER: string = 'e-delim-values';
41
+ const POPUP_WRAPPER: string = 'e-ddl e-popup e-multi-select-list-wrapper';
42
+ const INPUT_ELEMENT: string = 'e-dropdownbase';
43
+ const RTL_CLASS: string = 'e-rtl';
44
+ const CLOSE_ICON_HIDE: string = 'e-close-icon-hide';
45
+ const MOBILE_CHIP: string = 'e-mob-chip';
46
+ const FOOTER: string = 'e-ddl-footer';
47
+ const HEADER: string = 'e-ddl-header';
48
+ const DISABLE_ICON: string = 'e-ddl-disable-icon';
49
+ const SPINNER_CLASS: string = 'e-ms-spinner-icon';
50
+ const HIDDEN_ELEMENT: string = 'e-multi-hidden';
51
+ const destroy: string = 'destroy';
52
+ const dropdownIcon: string = 'e-input-group-icon e-ddl-icon';
53
+ const iconAnimation: string = 'e-icon-anim';
54
+ const TOTAL_COUNT_WRAPPER: string = 'e-delim-total';
55
+ const BOX_ELEMENT: string = 'e-multiselect-box';
56
+ const FILTERPARENT: string = 'e-filter-parent';
57
+ const CUSTOM_WIDTH: string = 'e-search-custom-width';
58
+ /**
59
+ * The Multiselect allows the user to pick a more than one value from list of predefined values.
60
+ * ```html
61
+ * <select id="list">
62
+ * <option value='1'>Badminton</option>
63
+ * <option value='2'>Basketball</option>
64
+ * <option value='3'>Cricket</option>
65
+ * <option value='4'>Football</option>
66
+ * <option value='5'>Tennis</option>
67
+ * </select>
68
+ * ```
69
+ * ```typescript
70
+ * <script>
71
+ * var multiselectObj = new Multiselect();
72
+ * multiselectObj.appendTo("#list");
73
+ * </script>
74
+ * ```
75
+ */
76
+
77
+ @NotifyPropertyChanges
78
+ export class MultiSelect extends DropDownBase implements IInput {
79
+ private spinnerElement: HTMLElement;
80
+ private selectAllAction: Function;
81
+ private setInitialValue: Function;
82
+ private setDynValue: boolean;
83
+ private listCurrentOptions: { [key: string]: Object };
84
+ private targetInputElement: HTMLInputElement | string;
85
+ private selectAllHeight?: number;
86
+ private searchBoxHeight?: number;
87
+ private mobFilter?: boolean;
88
+ private isFiltered: boolean;
89
+ private isFirstClick: boolean;
90
+ private focused: boolean;
91
+ private initial: boolean;
92
+ private backCommand: boolean;
93
+ private keyAction: boolean;
94
+ private isSelectAll: boolean;
95
+
96
+ /**
97
+ * The `fields` property maps the columns of the data table and binds the data to the component.
98
+ * * text - Maps the text column from data table for each list item.
99
+ * * value - Maps the value column from data table for each list item.
100
+ * * iconCss - Maps the icon class column from data table for each list item.
101
+ * * groupBy - Group the list items with it's related items by mapping groupBy field.
102
+ * ```html
103
+ * <input type="text" tabindex="1" id="list"> </input>
104
+ * ```
105
+ * ```typescript
106
+ * let customers: MultiSelect = new MultiSelect({
107
+ * dataSource:new DataManager({ url:'http://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/' }),
108
+ * query: new Query().from('Customers').select(['ContactName', 'CustomerID']).take(5),
109
+ * fields: { text: 'ContactName', value: 'CustomerID' },
110
+ * placeholder: 'Select a customer'
111
+ * });
112
+ * customers.appendTo("#list");
113
+ * ```
114
+ * @default {text: null, value: null, iconCss: null, groupBy: null}
115
+ */
116
+ @Complex<FieldSettingsModel>({ text: null, value: null, iconCss: null, groupBy: null }, FieldSettings)
117
+ public fields: FieldSettingsModel;
118
+ /**
119
+ * Enable or disable persisting MultiSelect component's state between page reloads.
120
+ * If enabled, following list of states will be persisted.
121
+ * 1. value
122
+ * @default false
123
+ */
124
+ @Property(false)
125
+ public enablePersistence: boolean;
126
+ /**
127
+ * Accepts the template design and assigns it to the group headers present in the MultiSelect popup list.
128
+ * @default null
129
+ */
130
+ @Property(null)
131
+ public groupTemplate: string;
132
+ /**
133
+ * Accepts the template design and assigns it to popup list of MultiSelect component
134
+ * when no data is available on the component.
135
+ * @default 'No records found'
136
+ */
137
+ @Property('No records found')
138
+ public noRecordsTemplate: string;
139
+ /**
140
+ * Accepts the template and assigns it to the popup list content of the MultiSelect component
141
+ * when the data fetch request from the remote server fails.
142
+ * @default 'Request failed'
143
+ */
144
+ @Property('Request failed')
145
+ public actionFailureTemplate: string;
146
+ /**
147
+ * Specifies the `sortOrder` to sort the data source. The available type of sort orders are
148
+ * * `None` - The data source is not sorting.
149
+ * * `Ascending` - The data source is sorting with ascending order.
150
+ * * `Descending` - The data source is sorting with descending order.
151
+ * @default None
152
+ */
153
+ @Property<SortOrder>('None')
154
+ public sortOrder: SortOrder;
155
+ /**
156
+ * Specifies a value that indicates whether the MultiSelect component is enabled or not.
157
+ * @default true
158
+ */
159
+ @Property(true)
160
+ public enabled: boolean;
161
+ /**
162
+ * Accepts the list items either through local or remote service and binds it to the MultiSelect component.
163
+ * It can be an array of JSON Objects or an instance of
164
+ * `DataManager`.
165
+ * @default []
166
+ */
167
+ @Property([])
168
+ public dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[];
169
+ /**
170
+ * Accepts the external `Query`
171
+ * which will execute along with the data processing in MultiSelect.
172
+ * @default null
173
+ */
174
+ @Property(null)
175
+ public query: Query;
176
+ /**
177
+ * Determines on which filter type, the MultiSelect component needs to be considered on search action.
178
+ * The `FilterType` and its supported data types are
179
+ *
180
+ * <table>
181
+ * <tr>
182
+ * <td colSpan=1 rowSpan=1>
183
+ * FilterType<br/></td><td colSpan=1 rowSpan=1>
184
+ * Description<br/></td><td colSpan=1 rowSpan=1>
185
+ * Supported Types<br/></td></tr>
186
+ * <tr>
187
+ * <td colSpan=1 rowSpan=1>
188
+ * StartsWith<br/></td><td colSpan=1 rowSpan=1>
189
+ * Checks whether a value begins with the specified value.<br/></td><td colSpan=1 rowSpan=1>
190
+ * String<br/></td></tr>
191
+ * <tr>
192
+ * <td colSpan=1 rowSpan=1>
193
+ * EndsWith<br/></td><td colSpan=1 rowSpan=1>
194
+ * Checks whether a value ends with specified value.<br/><br/></td><td colSpan=1 rowSpan=1>
195
+ * <br/>String<br/></td></tr>
196
+ * <tr>
197
+ * <td colSpan=1 rowSpan=1>
198
+ * Contains<br/></td><td colSpan=1 rowSpan=1>
199
+ * Checks whether a value contains with specified value.<br/><br/></td><td colSpan=1 rowSpan=1>
200
+ * <br/>String<br/></td></tr>
201
+ * </table>
202
+ *
203
+ * The default value set to `StartsWith`, all the suggestion items which contain typed characters to listed in the suggestion popup.
204
+ * @default 'StartsWith'
205
+ */
206
+ @Property('StartsWith')
207
+ public filterType: FilterType;
208
+ /**
209
+ * specifies the z-index value of the component popup element.
210
+ * @default 1000
211
+ */
212
+ @Property(1000)
213
+ public zIndex: number;
214
+ /**
215
+ * ignoreAccent set to true, then ignores the diacritic characters or accents when filtering.
216
+ */
217
+ @Property(false)
218
+ public ignoreAccent: boolean;
219
+ /**
220
+ * Overrides the global culture and localization value for this component. Default global culture is 'en-US'.
221
+ * @default 'en-US'
222
+ */
223
+ @Property()
224
+ public locale: string;
225
+ /**
226
+ * Specifies a Boolean value that indicates the whether the grouped list items are
227
+ * allowed to check by checking the group header in checkbox mode.
228
+ * By default, there is no checkbox provided for group headers.
229
+ * This property allows you to render checkbox for group headers and to select
230
+ * all the grouped items at once
231
+ * @default false
232
+ */
233
+ @Property(false)
234
+ public enableGroupCheckBox: boolean;
235
+
236
+
237
+ /**
238
+ * Sets the CSS classes to root element of this component which helps to customize the
239
+ * complete styles.
240
+ * @default null
241
+ */
242
+ @Property(null)
243
+ public cssClass: string;
244
+ /**
245
+ * Gets or sets the width of the component. By default, it sizes based on its parent.
246
+ * container dimension.
247
+ * @default '100%'
248
+ * @aspType string
249
+ * @blazorType string
250
+ */
251
+ @Property('100%')
252
+ public width: string | number;
253
+ /**
254
+ * Gets or sets the height of the popup list. By default it renders based on its list item.
255
+ * > For more details about the popup configuration refer to
256
+ * [`Popup Configuration`](../../multi-select/getting-started/#configure-the-popup-list) documentation.
257
+ *
258
+ * @default '300px'
259
+ * @aspType string
260
+ * @blazorType string
261
+ */
262
+ @Property('300px')
263
+ public popupHeight: string | number;
264
+ /**
265
+ * Gets or sets the width of the popup list and percentage values has calculated based on input width.
266
+ * > For more details about the popup configuration refer to
267
+ * [`Popup Configuration`](../../multi-select/getting-started/#configure-the-popup-list) documentation.
268
+ *
269
+ * @default '100%'
270
+ * @aspType string
271
+ * @blazorType string
272
+ */
273
+ @Property('100%')
274
+ public popupWidth: string | number;
275
+ /**
276
+ * Gets or sets the placeholder in the component to display the given information
277
+ * in input when no item selected.
278
+ * @default null
279
+ */
280
+ @Property(null)
281
+ public placeholder: string;
282
+ /**
283
+ * Accepts the value to be displayed as a watermark text on the filter bar.
284
+ * @default null
285
+ */
286
+ @Property(null)
287
+ public filterBarPlaceholder: string;
288
+ /**
289
+ * Gets or sets the additional attribute to `HtmlAttributes` property in MultiSelect,
290
+ * which helps to add attribute like title, name etc, input should be key value pair.
291
+ *
292
+ * {% codeBlock src='multiselect/htmlAttributes/index.md' %}{% endcodeBlock %}
293
+ * @default {}
294
+ */
295
+ @Property({})
296
+ public htmlAttributes: { [key: string]: string; };
297
+ /**
298
+ * Accepts the template design and assigns it to the selected list item in the input element of the component.
299
+ * For more details about the available template options refer to
300
+ * [`Template`](../../multi-select/templates) documentation.
301
+ *
302
+ * We have built-in `template engine`
303
+ * which provides options to compile template string into a executable function.
304
+ * For EX: We have expression evolution as like ES6 expression string literals.
305
+ * @default null
306
+ */
307
+ @Property(null)
308
+ public valueTemplate: string;
309
+ /**
310
+ * Accepts the template design and assigns it to the header container of the popup list.
311
+ * > For more details about the available template options refer to [`Template`](../../multi-select/templates) documentation.
312
+ *
313
+ * @default null
314
+ */
315
+ @Property(null)
316
+ public headerTemplate: string;
317
+ /**
318
+ * Accepts the template design and assigns it to the footer container of the popup list.
319
+ * > For more details about the available template options refer to [`Template`](../../multi-select/templates) documentation.
320
+ *
321
+ * @default null
322
+ */
323
+ @Property(null)
324
+ public footerTemplate: string;
325
+ /**
326
+ * Accepts the template design and assigns it to each list item present in the popup.
327
+ * > For more details about the available template options refer to [`Template`](../../multi-select/templates) documentation.
328
+ *
329
+ * We have built-in `template engine`
330
+ * which provides options to compile template string into a executable function.
331
+ * For EX: We have expression evolution as like ES6 expression string literals.
332
+ * @default null
333
+ */
334
+ @Property(null)
335
+ public itemTemplate: string;
336
+ /**
337
+ * To enable the filtering option in this component.
338
+ * Filter action performs when type in search box and collect the matched item through `filtering` event.
339
+ * If searching character does not match, `noRecordsTemplate` property value will be shown.
340
+ *
341
+ * {% codeBlock src="multiselect/allow-filtering-api/index.ts" %}{% endcodeBlock %}
342
+ *
343
+ * {% codeBlock src="multiselect/allow-filtering-api/index.html" %}{% endcodeBlock %}
344
+ *
345
+ * @default null
346
+ * @isBlazorNullableType true
347
+ * @blazorDefaultValue
348
+ */
349
+ @Property(null)
350
+ public allowFiltering: boolean;
351
+ /**
352
+ * By default, the multiselect component fires the change event while focus out the component.
353
+ * If you want to fires the change event on every value selection and remove, then disable the changeOnBlur property.
354
+ *
355
+ * @default true
356
+ */
357
+ @Property(true)
358
+ public changeOnBlur: boolean;
359
+ /**
360
+ * Allows user to add a
361
+ * [`custom value`](../../multi-select/custom-value), the value which is not present in the suggestion list.
362
+ * @default false
363
+ */
364
+ @Property(false)
365
+ public allowCustomValue: boolean;
366
+ /**
367
+ * Enables close icon with the each selected item.
368
+ * @default true
369
+ */
370
+ @Property(true)
371
+ public showClearButton: boolean;
372
+ /**
373
+ * Sets limitation to the value selection.
374
+ * based on the limitation, list selection will be prevented.
375
+ * @default 1000
376
+ * @blazorType int
377
+ */
378
+ @Property(1000)
379
+ public maximumSelectionLength: number;
380
+ /**
381
+ * Gets or sets the `readonly` to input or not. Once enabled, just you can copy or highlight
382
+ * the text however tab key action will perform.
383
+ *
384
+ * @default false
385
+ */
386
+ @Property(false)
387
+ public readonly: boolean;
388
+ /**
389
+ * Selects the list item which maps the data `text` field in the component.
390
+ * @default null
391
+ */
392
+ @Property(null)
393
+ public text: string;
394
+ /**
395
+ * Selects the list item which maps the data `value` field in the component.
396
+ * {% codeBlock src='multiselect/value/index.md' %}{% endcodeBlock %}
397
+ * @default null
398
+ * @isGenericType true
399
+ */
400
+ @Property(null)
401
+ public value: number[] | string[] | boolean[];
402
+ /**
403
+ * Hides the selected item from the list item.
404
+ * @default true
405
+ */
406
+ @Property(true)
407
+ public hideSelectedItem: boolean;
408
+ /**
409
+ * Based on the property, when item get select popup visibility state will changed.
410
+ * @default true
411
+ */
412
+ @Property(true)
413
+ public closePopupOnSelect: boolean;
414
+ /**
415
+ * configures visibility mode for component interaction.
416
+ *
417
+ * - `Box` - selected items will be visualized in chip.
418
+ *
419
+ * - `Delimiter` - selected items will be visualized in text content.
420
+ *
421
+ * - `Default` - on `focus in` component will act in `box` mode.
422
+ * on `blur` component will act in `delimiter` mode.
423
+ *
424
+ * - `CheckBox` - The 'checkbox' will be visualized in list item.
425
+ *
426
+ * {% codeBlock src="multiselect/visual-mode-api/index.ts" %}{% endcodeBlock %}
427
+ *
428
+ * {% codeBlock src="multiselect/visual-mode-api/index.html" %}{% endcodeBlock %}
429
+ *
430
+ * @default Default
431
+ */
432
+ @Property('Default')
433
+ public mode: visualMode;
434
+ /**
435
+ * Sets the delimiter character for 'default' and 'delimiter' visibility modes.
436
+ * @default ','
437
+ */
438
+ @Property(',')
439
+ public delimiterChar: string;
440
+ /**
441
+ * Sets [`case sensitive`](../../multi-select/filtering/#case-sensitive-filtering)
442
+ * option for filter operation.
443
+ * @default true
444
+ */
445
+ @Property(true)
446
+ public ignoreCase: boolean;
447
+ /**
448
+ * Allows you to either show or hide the DropDown button on the component
449
+ *
450
+ * @default false
451
+ */
452
+ @Property(false)
453
+ public showDropDownIcon: boolean;
454
+ /**
455
+ * Specifies whether to display the floating label above the input element.
456
+ * Possible values are:
457
+ * * Never: The label will never float in the input when the placeholder is available.
458
+ * * Always: The floating label will always float above the input.
459
+ * * Auto: The floating label will float above the input after focusing or entering a value in the input.
460
+ *
461
+ * @default Syncfusion.EJ2.Inputs.FloatLabelType.Never
462
+ * @aspType Syncfusion.EJ2.Inputs.FloatLabelType
463
+ * @isEnumeration true
464
+ * @blazorType Syncfusion.Blazor.Inputs.FloatLabelType
465
+ */
466
+ @Property('Never')
467
+ public floatLabelType: FloatLabelType;
468
+ /**
469
+ * Allows you to either show or hide the selectAll option on the component.
470
+ *
471
+ * @default false
472
+ */
473
+ @Property(false)
474
+ public showSelectAll: boolean;
475
+ /**
476
+ * Specifies the selectAllText to be displayed on the component.
477
+ *
478
+ * @default 'select All'
479
+ */
480
+ @Property('Select All')
481
+ public selectAllText: string;
482
+ /**
483
+ * Specifies the UnSelectAllText to be displayed on the component.
484
+ *
485
+ * @default 'select All'
486
+ */
487
+ @Property('Unselect All')
488
+ public unSelectAllText: string;
489
+ /**
490
+ * Reorder the selected items in popup visibility state.
491
+ *
492
+ * @default true
493
+ */
494
+ @Property(true)
495
+ public enableSelectionOrder: boolean;
496
+ /**
497
+ * Whether to automatically open the popup when the control is clicked.
498
+ * @default true
499
+ */
500
+ @Property(true)
501
+ public openOnClick: boolean;
502
+ /**
503
+ * Fires each time when selection changes happened in list items after model and input value get affected.
504
+ * @event
505
+ * @blazorProperty 'ValueChange'
506
+ */
507
+ @Event()
508
+ public change: EmitType<MultiSelectChangeEventArgs>;
509
+ /**
510
+ * Fires before the selected item removed from the widget.
511
+ * @event
512
+ * @blazorProperty 'OnValueRemove'
513
+ */
514
+ @Event()
515
+ public removing: EmitType<RemoveEventArgs>;
516
+ /**
517
+ * Fires after the selected item removed from the widget.
518
+ * @event
519
+ * @blazorProperty 'ValueRemoved'
520
+ */
521
+ @Event()
522
+ public removed: EmitType<RemoveEventArgs>;
523
+ /**
524
+ * Fires after select all process completion.
525
+ * @event
526
+ * @blazorProperty 'SelectedAll'
527
+ */
528
+ @Event()
529
+ public selectedAll: EmitType<ISelectAllEventArgs>;
530
+ /**
531
+ * Fires when popup opens before animation.
532
+ * @event
533
+ * @blazorProperty 'OnOpen'
534
+ * @blazorType BeforeOpenEventArgs
535
+ */
536
+ @Event()
537
+ public beforeOpen: EmitType<Object>;
538
+ /**
539
+ * Fires when popup opens after animation completion.
540
+ * @event
541
+ * @blazorProperty 'Opened'
542
+ */
543
+ @Event()
544
+ public open: EmitType<PopupEventArgs>;
545
+ /**
546
+ * Fires when popup close after animation completion.
547
+ * @event
548
+ * @blazorProperty 'OnClose'
549
+ */
550
+ @Event()
551
+ public close: EmitType<PopupEventArgs>;
552
+ /**
553
+ * Event triggers when the input get focus-out.
554
+ * @event
555
+ */
556
+ @Event()
557
+ public blur: EmitType<Object>;
558
+ /**
559
+ * Event triggers when the input get focused.
560
+ * @event
561
+ */
562
+ @Event()
563
+ public focus: EmitType<Object>;
564
+ /**
565
+ * Event triggers when the chip selection.
566
+ * @event
567
+ * @blazorProperty 'ChipSelected'
568
+ */
569
+ @Event()
570
+ public chipSelection: EmitType<Object>;
571
+ /**
572
+ * Triggers event,when user types a text in search box.
573
+ * > For more details about filtering, refer to [`Filtering`](../../multi-select/filtering) documentation.
574
+ *
575
+ * @event
576
+ * @blazorProperty 'Filtering'
577
+ */
578
+ @Event()
579
+ public filtering: EmitType<FilteringEventArgs>;
580
+ /**
581
+ * Fires before set the selected item as chip in the component.
582
+ * > For more details about chip customization refer [`Chip Customization`](../../multi-select/chip-customization)
583
+ *
584
+ * @event
585
+ * @blazorProperty 'OnChipTag'
586
+ */
587
+ @Event()
588
+ public tagging: EmitType<TaggingEventArgs>;
589
+ /**
590
+ * Triggers when the [`customValue`](../../multi-select/custom-value) is selected.
591
+ * @event
592
+ * @blazorProperty 'CustomValueSpecifier'
593
+ */
594
+ @Event()
595
+ public customValueSelection: EmitType<CustomValueEventArgs>;
596
+ /**
597
+ * Constructor for creating the DropDownList widget.
598
+ */
599
+ constructor(option?: MultiSelectModel, element?: string | HTMLElement) {
600
+ super(option, element);
601
+ };
602
+ private isValidKey: boolean = false;
603
+ private mainList: HTMLElement;
604
+ public ulElement: HTMLElement;
605
+ private mainData: { [key: string]: Object }[] | string[] | number[] | boolean[];
606
+ private mainListCollection: HTMLElement[];
607
+ private customValueFlag: boolean;
608
+ private inputElement: HTMLInputElement;
609
+ private componentWrapper: HTMLDivElement;
610
+ private overAllWrapper: HTMLDivElement;
611
+ private searchWrapper: HTMLElement;
612
+ private viewWrapper: HTMLElement;
613
+ private chipCollectionWrapper: HTMLElement;
614
+ private overAllClear: HTMLElement;
615
+ private dropIcon: HTMLElement;
616
+ private hiddenElement: HTMLSelectElement;
617
+ private delimiterWrapper: HTMLElement;
618
+ private popupObj: Popup;
619
+ private inputFocus: boolean;
620
+ private header: HTMLElement;
621
+ private footer: HTMLElement;
622
+ private initStatus: boolean;
623
+ private popupWrapper: HTMLDivElement;
624
+ private keyCode: number;
625
+ private beforePopupOpen: boolean;
626
+ private remoteCustomValue: boolean;
627
+ private filterAction: boolean;
628
+ private remoteFilterAction: boolean;
629
+ private selectAllEventData: FieldSettingsModel[] = [];
630
+ private selectAllEventEle: HTMLLIElement[] = [];
631
+ private filterParent: HTMLElement;
632
+ private removeIndex: number;
633
+ private isDynamicDataChange: boolean = false;
634
+ private enableRTL(state: boolean): void {
635
+ if (state) {
636
+ this.overAllWrapper.classList.add(RTL_CLASS);
637
+ } else {
638
+ this.overAllWrapper.classList.remove(RTL_CLASS);
639
+ }
640
+ if (this.popupObj) {
641
+ this.popupObj.enableRtl = state;
642
+ this.popupObj.dataBind();
643
+ }
644
+ }
645
+
646
+ public requiredModules(): ModuleDeclaration[] {
647
+ let modules: ModuleDeclaration[] = [];
648
+ if (this.mode === 'CheckBox') {
649
+ this.isGroupChecking = this.enableGroupCheckBox;
650
+ if (this.enableGroupCheckBox) {
651
+ let prevOnChange: boolean = this.isProtectedOnChange;
652
+ this.isProtectedOnChange = true;
653
+ this.enableSelectionOrder = false;
654
+ this.isProtectedOnChange = prevOnChange;
655
+ }
656
+ this.allowCustomValue = false;
657
+ this.hideSelectedItem = false;
658
+ this.closePopupOnSelect = false;
659
+ modules.push({
660
+ member: 'CheckBoxSelection',
661
+ args: [this]
662
+ });
663
+ }
664
+ return modules;
665
+ }
666
+ private updateHTMLAttribute(): void {
667
+ if (Object.keys(this.htmlAttributes).length) {
668
+ for (let htmlAttr of Object.keys(this.htmlAttributes)) {
669
+ switch (htmlAttr) {
670
+ case 'class':
671
+ let updatedClassValue : string = (this.htmlAttributes[htmlAttr].replace(/\s+/g, ' ')).trim();
672
+ if (updatedClassValue !== '') {
673
+ addClass([this.overAllWrapper], updatedClassValue.split(' '));
674
+ addClass([this.popupWrapper], updatedClassValue.split(' '));
675
+ }
676
+ break;
677
+ case 'disabled':
678
+ this.enable(false);
679
+ break;
680
+ case 'placeholder':
681
+ if (!this.placeholder) {
682
+ this.inputElement.setAttribute(htmlAttr, this.htmlAttributes[htmlAttr]);
683
+ this.setProperties({placeholder: this.inputElement.placeholder}, true);
684
+ this.refreshPlaceHolder();
685
+ }
686
+ break;
687
+ default:
688
+ let defaultAttr: string[] = ['id'];
689
+ let validateAttr: string[] = ['name', 'required', 'aria-required', 'form'];
690
+ let containerAttr: string[] = ['title', 'role', 'style', 'class'];
691
+ if (defaultAttr.indexOf(htmlAttr) > -1) {
692
+ this.element.setAttribute(htmlAttr, this.htmlAttributes[htmlAttr]);
693
+ } else if (htmlAttr.indexOf('data') === 0 || validateAttr.indexOf(htmlAttr) > -1) {
694
+ this.hiddenElement.setAttribute(htmlAttr, this.htmlAttributes[htmlAttr]);
695
+ } else if (containerAttr.indexOf(htmlAttr) > -1) {
696
+ this.overAllWrapper.setAttribute(htmlAttr, this.htmlAttributes[htmlAttr]);
697
+ } else {
698
+ this.inputElement.setAttribute(htmlAttr, this.htmlAttributes[htmlAttr]);
699
+ }
700
+ break;
701
+ }
702
+ }
703
+ }
704
+ }
705
+
706
+ private updateReadonly(state: boolean): void {
707
+ if (state || this.mode === 'CheckBox') {
708
+ this.inputElement.setAttribute('readonly', 'true');
709
+ } else {
710
+ this.inputElement.removeAttribute('readonly');
711
+ }
712
+ }
713
+
714
+ private updateClearButton(state: boolean): void {
715
+ if (state) {
716
+ if (this.overAllClear.parentNode) {
717
+ this.overAllClear.style.display = '';
718
+ } else {
719
+ this.componentWrapper.appendChild(this.overAllClear);
720
+ }
721
+ this.componentWrapper.classList.remove(CLOSE_ICON_HIDE);
722
+ } else {
723
+ this.overAllClear.style.display = 'none';
724
+ this.componentWrapper.classList.add(CLOSE_ICON_HIDE);
725
+ }
726
+ }
727
+ private updateCssClass(): void {
728
+ if (!isNullOrUndefined(this.cssClass) && this.cssClass !== '') {
729
+ let updatedCssClassValues : string = this.cssClass;
730
+ updatedCssClassValues = (this.cssClass.replace(/\s+/g, ' ')).trim();
731
+ if (updatedCssClassValues !== '') {
732
+ addClass([this.overAllWrapper], updatedCssClassValues.split(' '));
733
+ addClass([this.popupWrapper], updatedCssClassValues.split(' '));
734
+ }
735
+ }
736
+ }
737
+ private updateOldPropCssClass(oldClass : string) : void {
738
+ if (!isNullOrUndefined(oldClass) && oldClass !== '') {
739
+ oldClass = (oldClass.replace(/\s+/g, ' ')).trim();
740
+ if (oldClass !== '' ) {
741
+ removeClass([this.overAllWrapper], oldClass.split(' '));
742
+ removeClass([this.popupWrapper], oldClass.split(' '));
743
+ }
744
+ }
745
+ }
746
+ private onPopupShown(): void {
747
+ let listItems: NodeListOf<Element>;
748
+ let mainListItems: NodeListOf<Element>;
749
+ if (Browser.isDevice && (this.mode === 'CheckBox' && this.allowFiltering)) {
750
+ let proxy: this = this;
751
+ window.onpopstate = () => {
752
+ proxy.hidePopup();
753
+ proxy.inputElement.focus();
754
+ };
755
+ history.pushState({}, '');
756
+ }
757
+ let animModel: AnimationModel = { name: 'FadeIn', duration: 100 };
758
+ let eventArgs: PopupEventArgs = { popup: this.popupObj, cancel: false, animation: animModel };
759
+ this.trigger('open', eventArgs, (eventArgs: PopupEventArgs) => {
760
+ if (!eventArgs.cancel) {
761
+ this.focusAtFirstListItem();
762
+ document.body.appendChild(this.popupObj.element);
763
+ if (this.mode === 'CheckBox' && this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
764
+ this.updateListItems(this.list.querySelectorAll('li.e-list-item'), this.mainList.querySelectorAll('li.e-list-item'));
765
+ }
766
+ if (this.mode === 'CheckBox' || this.showDropDownIcon) {
767
+ addClass([this.overAllWrapper], [iconAnimation]);
768
+ }
769
+ this.refreshPopup();
770
+ this.popupObj.show(eventArgs.animation, (this.zIndex === 1000) ? this.element : null);
771
+ attributes(this.inputElement, { 'aria-expanded': 'true' });
772
+ if (this.isFirstClick) {
773
+ this.loadTemplate();
774
+ }
775
+ }
776
+ });
777
+ }
778
+ private updateListItems(listItems: NodeListOf<Element> , mainListItems: NodeListOf<Element>): void {
779
+ for (let i: number = 0; i < listItems.length; i++) {
780
+ this.findGroupStart(listItems[i] as HTMLElement);
781
+ this.findGroupStart(mainListItems[i] as HTMLElement);
782
+ }
783
+ this.deselectHeader();
784
+ }
785
+ private loadTemplate(): void {
786
+ this.refreshListItems(null);
787
+ if (this.mode === 'CheckBox') { this.removeFocus(); }
788
+ this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', e: this });
789
+
790
+ }
791
+ private setScrollPosition(): void {
792
+ if (((!this.hideSelectedItem && this.mode !== 'CheckBox') || (this.mode === 'CheckBox' && !this.enableSelectionOrder)) &&
793
+ (!isNullOrUndefined(this.value) && ( this.value.length > 0 ))) {
794
+ let valueEle: HTMLElement = this.findListElement(
795
+ (this.hideSelectedItem ? this.ulElement : this.list),
796
+ 'li',
797
+ 'data-value',
798
+ this.value[this.value.length - 1]);
799
+ if (!isNullOrUndefined(valueEle)) {
800
+ this.scrollBottom(valueEle);
801
+ }
802
+ }
803
+ }
804
+ private focusAtFirstListItem(): void {
805
+ if (this.ulElement && this.ulElement.querySelector('li.'
806
+ + dropDownBaseClasses.li)) {
807
+ let element: HTMLElement;
808
+ if (this.mode === 'CheckBox') {
809
+ this.removeFocus();
810
+ return;
811
+ } else {
812
+ element = <HTMLElement>this.ulElement.querySelector('li.'
813
+ + dropDownBaseClasses.li + ':not(.'
814
+ + HIDE_LIST + ')');
815
+ }
816
+ if (element !== null) {
817
+ this.removeFocus();
818
+ this.addListFocus(element);
819
+ }
820
+ }
821
+ }
822
+ private focusAtLastListItem(data: string): void {
823
+ let activeElement: { [key: string]: Element | number };
824
+ if (data) {
825
+ activeElement = Search(data, this.liCollections, 'StartsWith', this.ignoreCase);
826
+ } else {
827
+ if (this.value && this.value.length) {
828
+ Search(<string>this.value[this.value.length - 1], this.liCollections, 'StartsWith', this.ignoreCase);
829
+ } else {
830
+ activeElement = null;
831
+ }
832
+ }
833
+ if (activeElement && activeElement.item !== null) {
834
+ this.addListFocus((<HTMLElement>activeElement.item));
835
+ this.scrollBottom((<HTMLElement>activeElement.item), <number>activeElement.index);
836
+ }
837
+ }
838
+
839
+ protected getAriaAttributes(): { [key: string]: string } {
840
+ let ariaAttributes: { [key: string]: string } = {
841
+ 'aria-disabled': 'false',
842
+ 'aria-owns': this.element.id + '_options',
843
+ 'role': 'listbox',
844
+ 'aria-multiselectable': 'true',
845
+ 'aria-activedescendant': 'null',
846
+ 'aria-haspopup': 'true',
847
+ 'aria-expanded': 'false'
848
+ };
849
+ return ariaAttributes;
850
+ }
851
+ private updateListARIA(): void {
852
+ attributes(this.ulElement, { 'id': this.element.id + '_options', 'role': 'listbox', 'aria-hidden': 'false' });
853
+ let disableStatus: boolean = (this.inputElement.disabled) ? true : false;
854
+ attributes(this.inputElement, this.getAriaAttributes());
855
+ if (disableStatus) {
856
+ attributes(this.inputElement, { 'aria-disabled': 'true' });
857
+ }
858
+ this.ensureAriaDisabled((disableStatus) ? 'true' : 'false');
859
+ }
860
+ private ensureAriaDisabled(status: string): void {
861
+ if (this.htmlAttributes && this.htmlAttributes['aria-disabled']) {
862
+ let attr: { [key: string]: string; } = this.htmlAttributes;
863
+ extend(attr, {'aria-disabled' : status }, attr);
864
+ this.setProperties({ htmlAttributes: attr }, true);
865
+ }
866
+ }
867
+ private removelastSelection(e: KeyboardEventArgs): void {
868
+ let elements: NodeListOf<Element>;
869
+ elements = <NodeListOf<HTMLElement>>
870
+ this.chipCollectionWrapper.querySelectorAll('span.' + CHIP);
871
+ let value: string = elements[elements.length - 1].getAttribute('data-value');
872
+ if (!isNullOrUndefined(this.value)) {
873
+ this.tempValues = <string[]>this.value.slice();
874
+ }
875
+ this.removeValue(value, e);
876
+ this.removeChipSelection();
877
+ this.updateDelimeter(this.delimiterChar, e);
878
+ this.makeTextBoxEmpty();
879
+ if (this.mainList && this.listData) {
880
+ this.refreshSelection();
881
+ }
882
+ this.checkPlaceholderSize();
883
+ }
884
+ protected onActionFailure(e: Object): void {
885
+ super.onActionFailure(e);
886
+ this.renderPopup();
887
+ this.onPopupShown();
888
+ }
889
+ protected targetElement(): string {
890
+ this.targetInputElement = this.inputElement;
891
+ if (this.mode === 'CheckBox' && this.allowFiltering) {
892
+ this.notify('targetElement', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
893
+ }
894
+ return this.targetInputElement.value;
895
+ }
896
+
897
+ private getForQuery(valuecheck: string[]): Query {
898
+ let predicate: Predicate;
899
+ let field: string = isNullOrUndefined(this.fields.value) ? this.fields.text : this.fields.value;
900
+ for (let i: number = 0; i < valuecheck.length; i++) {
901
+ if (i === 0) {
902
+ predicate = new Predicate(field, 'equal', (valuecheck[i] as string));
903
+ } else {
904
+ predicate = predicate.or(field, 'equal', (valuecheck[i] as string));
905
+ }
906
+ }
907
+ return this.getQuery(this.query).where(predicate);
908
+ }
909
+ protected onActionComplete(
910
+ ulElement: HTMLElement,
911
+ list: { [key: string]: Object }[] | number[] | boolean[] | string[],
912
+ e?: Object, isUpdated?: boolean): void {
913
+ super.onActionComplete(ulElement, list, e);
914
+ this.updateSelectElementData(this.allowFiltering);
915
+ let proxy: MultiSelect = this;
916
+ let valuecheck: string[] = [];
917
+ if (isBlazor() && this.isServerRendered && this.isDynamicDataChange && this.value !== null && this.value.length > 0) {
918
+ let items: { [key: string]: Object }[] = [];
919
+ for (let k: number = 0; k < this.value.length; k++) {
920
+ let itemsData: string | number | boolean | {[key: string]: Object} = this.getDataByValue(this.value[k]);
921
+ if (itemsData) {
922
+ // tslint:disable-next-line
923
+ items.push((itemsData as any)[this.fields.value]); // remove the condition for hybrid
924
+ }
925
+ }
926
+ if (items.length === 0) {
927
+ this.setProperties({ 'value': null });
928
+ }
929
+ }
930
+ if (!isNullOrUndefined(this.value) && !this.allowCustomValue) {
931
+ for (let i: number = 0; i < this.value.length; i++) {
932
+ let checkEle: Element = this.findListElement(
933
+ ((this.allowFiltering && !isNullOrUndefined(this.mainList)) ? this.mainList : ulElement),
934
+ 'li',
935
+ 'data-value',
936
+ proxy.value[i]);
937
+ if (!checkEle) {
938
+ valuecheck.push(proxy.value[i] as string);
939
+ }
940
+ }
941
+ }
942
+ if (valuecheck.length > 0 && this.dataSource instanceof DataManager && !isNullOrUndefined(this.value)) {
943
+ (this.dataSource as DataManager).executeQuery(this.getForQuery(valuecheck)).then((e: Object) => {
944
+ proxy.addItem((e as ResultData).result, list.length);
945
+ proxy.updateActionList(ulElement, list, e);
946
+ });
947
+ } else {
948
+ this.updateActionList(ulElement, list, e);
949
+ }
950
+ if (isBlazor() && this.isServerRendered && this.allowFiltering && this.mode === 'CheckBox') {
951
+ this.removeFocus();
952
+ }
953
+ if (isBlazor() && this.isServerRendered && this.isDynamicDataChange && this.value && this.value.length > 0) {
954
+ this.updateVal(this.value, null, 'value');
955
+ this.addValidInputClass();
956
+ this.isDynamicDataChange = false;
957
+ }
958
+ }
959
+
960
+ private updateActionList(
961
+ ulElement: HTMLElement,
962
+ list: { [key: string]: Object }[] | number[] | boolean[] | string[],
963
+ e?: Object, isUpdated?: boolean): void {
964
+ if (this.mode === 'CheckBox' && this.showSelectAll) {
965
+ this.notify('selectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
966
+ }
967
+ if (!this.mainList && !this.mainData) {
968
+ this.mainList = ulElement.cloneNode ? <HTMLElement>ulElement.cloneNode(true) : ulElement;
969
+ this.mainData = list;
970
+ this.mainListCollection = this.liCollections;
971
+ } else if (isNullOrUndefined(this.mainData) || this.mainData.length === 0) {
972
+ this.mainData = list;
973
+ }
974
+ if ((this.remoteCustomValue || list.length <= 0) && this.allowCustomValue && this.inputFocus && this.allowFiltering) {
975
+ this.checkForCustomValue(this.tempQuery, this.fields);
976
+ return;
977
+ }
978
+ if (this.value && this.value.length && ((this.mode !== 'CheckBox' && this.inputElement.value !== '') ||
979
+ this.mode === 'CheckBox')) {
980
+ this.refreshSelection();
981
+ }
982
+ this.updateListARIA();
983
+ this.unwireListEvents();
984
+ this.wireListEvents();
985
+ if (!isNullOrUndefined(this.setInitialValue)) { this.setInitialValue(); }
986
+ if (!isNullOrUndefined(this.selectAllAction)) { this.selectAllAction(); }
987
+ if (this.setDynValue) {
988
+ if (!isNullOrUndefined(this.text) && (isNullOrUndefined(this.value) || this.value.length === 0)) {
989
+ this.initialTextUpdate();
990
+ }
991
+ this.initialValueUpdate();
992
+ this.initialUpdate();
993
+ this.refreshPlaceHolder();
994
+ if (this.mode !== 'CheckBox' && this.changeOnBlur) { this.updateValueState(null, this.value, null); }
995
+ }
996
+ this.renderPopup();
997
+ if (this.beforePopupOpen) {
998
+ this.beforePopupOpen = false;
999
+ this.onPopupShown();
1000
+ }
1001
+ }
1002
+ private refreshSelection(): void {
1003
+ let value: string | number | boolean;
1004
+ let element: HTMLElement;
1005
+ let className: string = this.hideSelectedItem ?
1006
+ HIDE_LIST :
1007
+ dropDownBaseClasses.selected;
1008
+ if (!isNullOrUndefined(this.value)) {
1009
+ for (let index: number = 0; !isNullOrUndefined(this.value[index]); index++) {
1010
+ value = this.value[index];
1011
+ element = this.findListElement(this.list, 'li', 'data-value', value);
1012
+ if (element) {
1013
+ addClass([element], className);
1014
+ if (this.hideSelectedItem && element.previousSibling
1015
+ && element.previousElementSibling.classList.contains(dropDownBaseClasses.group)
1016
+ && (!element.nextElementSibling ||
1017
+ element.nextElementSibling.classList.contains(dropDownBaseClasses.group))) {
1018
+ addClass([element.previousElementSibling], className);
1019
+ }
1020
+ if (this.hideSelectedItem && this.fields.groupBy && !element.previousElementSibling.classList.contains(HIDE_LIST)) {
1021
+ this.hideGroupItem(value);
1022
+ }
1023
+ if (this.hideSelectedItem && element.classList.contains(dropDownBaseClasses.focus)) {
1024
+ removeClass([element], dropDownBaseClasses.focus);
1025
+ let listEle: NodeListOf<Element> = element.parentElement.querySelectorAll('.' +
1026
+ dropDownBaseClasses.li + ':not(.' + HIDE_LIST + ')');
1027
+ if (listEle.length > 0) {
1028
+ addClass([listEle[0]], dropDownBaseClasses.focus);
1029
+ } else {
1030
+ this.ulElement = this.ulElement.cloneNode ? <HTMLElement>this.ulElement.cloneNode(true) : this.ulElement;
1031
+ this.l10nUpdate();
1032
+ addClass([this.list], dropDownBaseClasses.noData);
1033
+ }
1034
+ }
1035
+ element.setAttribute('aria-selected', 'true');
1036
+ if (this.mode === 'CheckBox' && element.classList.contains('e-active')) {
1037
+ let ariaValue: string | null = element.firstElementChild.getAttribute('aria-checked');
1038
+ if (isNullOrUndefined(ariaValue) || ariaValue === 'false') {
1039
+ let args: { [key: string]: Object | string } = {
1040
+ module: 'CheckBoxSelection',
1041
+ enable: this.mode === 'CheckBox',
1042
+ li: element,
1043
+ e: null
1044
+ };
1045
+ this.notify('updatelist', args);
1046
+ }
1047
+ }
1048
+ }
1049
+ }
1050
+ }
1051
+ this.checkSelectAll();
1052
+ this.checkMaxSelection();
1053
+ }
1054
+
1055
+ private hideGroupItem(value: string | number | boolean): void {
1056
+ let element: HTMLElement;
1057
+ let element1: HTMLElement;
1058
+ let className: string = this.hideSelectedItem ?
1059
+ HIDE_LIST :
1060
+ dropDownBaseClasses.selected;
1061
+ element1 = element = this.findListElement(this.ulElement, 'li', 'data-value', value);
1062
+ let i: number = 0;
1063
+ let j: number = 0;
1064
+ let temp: boolean = true;
1065
+ let temp1: boolean = true;
1066
+ do {
1067
+ if (element && element.previousElementSibling
1068
+ && (!element.previousElementSibling.classList.contains(HIDE_LIST) &&
1069
+ element.previousElementSibling.classList.contains(dropDownBaseClasses.li))) {
1070
+ temp = false;
1071
+ }
1072
+ if (!temp || !element || (element.previousElementSibling
1073
+ && element.previousElementSibling.classList.contains(dropDownBaseClasses.group))) {
1074
+ i = 10;
1075
+ } else {
1076
+ element = element.previousElementSibling as HTMLElement;
1077
+ }
1078
+ if (element1 && element1.nextElementSibling
1079
+ && (!element1.nextElementSibling.classList.contains(HIDE_LIST) &&
1080
+ element1.nextElementSibling.classList.contains(dropDownBaseClasses.li))) {
1081
+ temp1 = false;
1082
+ }
1083
+ if (!temp1 || !element1 || (element1.nextElementSibling
1084
+ && element1.nextElementSibling.classList.contains(dropDownBaseClasses.group))) {
1085
+ j = 10;
1086
+ } else {
1087
+ element1 = element1.nextElementSibling as HTMLElement;
1088
+ }
1089
+ }
1090
+ while (i < 10 || j < 10);
1091
+ if (temp && temp1 && !element.previousElementSibling.classList.contains(HIDE_LIST)) {
1092
+ addClass([element.previousElementSibling], className);
1093
+ } else if (temp && temp1 && element.previousElementSibling.classList.contains(HIDE_LIST)) {
1094
+ removeClass([element.previousElementSibling], className);
1095
+ }
1096
+ }
1097
+ private checkSelectAll(): void {
1098
+ let groupItemLength: number = this.list.querySelectorAll('li.e-list-group-item.e-active').length;
1099
+ let listItem: NodeListOf<Element> = this.list.querySelectorAll('li.e-list-item');
1100
+ let searchCount: number = this.list.querySelectorAll('li.' + dropDownBaseClasses.li).length;
1101
+ let searchActiveCount: number = this.list.querySelectorAll('li.' + dropDownBaseClasses.selected).length;
1102
+ if (this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
1103
+ searchActiveCount = searchActiveCount - groupItemLength;
1104
+ }
1105
+ if ((searchCount === searchActiveCount || searchActiveCount === this.maximumSelectionLength)
1106
+ && (this.mode === 'CheckBox' && this.showSelectAll)) {
1107
+ this.notify('checkSelectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'check' });
1108
+ } else if ((searchCount !== searchActiveCount) && (this.mode === 'CheckBox' && this.showSelectAll)) {
1109
+ this.notify('checkSelectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'uncheck' });
1110
+ }
1111
+ if (this.enableGroupCheckBox && this.fields.groupBy && !this.enableSelectionOrder) {
1112
+ for (let i: number = 0; i < listItem.length; i++) {
1113
+ this.findGroupStart(listItem[i] as HTMLElement);
1114
+ }
1115
+ this.deselectHeader();
1116
+ }
1117
+ }
1118
+ private openClick(e: KeyboardEventArgs): void {
1119
+ if (!this.openOnClick && this.mode !== 'CheckBox') {
1120
+ if (this.targetElement() !== '') {
1121
+ this.showPopup();
1122
+ } else {
1123
+ this.hidePopup();
1124
+ }
1125
+ } else if (!this.openOnClick && this.mode === 'CheckBox' && !this.isPopupOpen()) {
1126
+ this.showPopup();
1127
+ }
1128
+ }
1129
+ private KeyUp(e: KeyboardEventArgs): void {
1130
+ if (this.mode === 'CheckBox' && !this.openOnClick) {
1131
+ let char: string = String.fromCharCode(e.keyCode);
1132
+ let isWordCharacter: Object = char.match(/\w/);
1133
+ if (!isNullOrUndefined(isWordCharacter)) {
1134
+ this.isValidKey = true;
1135
+ }
1136
+ }
1137
+ this.isValidKey = (this.isPopupOpen() && e.keyCode === 8) || this.isValidKey;
1138
+ this.isValidKey = e.ctrlKey && e.keyCode === 86 ? false : this.isValidKey;
1139
+ if (this.isValidKey) {
1140
+ this.isValidKey = false;
1141
+ this.expandTextbox();
1142
+ this.showOverAllClear();
1143
+ switch (e.keyCode) {
1144
+ default:
1145
+ // For filtering works in mobile firefox
1146
+ this.search(e);
1147
+ }
1148
+ }
1149
+ }
1150
+ /**
1151
+ * To filter the multiselect data from given data source by using query
1152
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
1153
+ * @param {Query} query - Specify the query to filter the data.
1154
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
1155
+ * @return {void}.
1156
+ */
1157
+ public filter(
1158
+ dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
1159
+ query?: Query, fields?: FieldSettingsModel): void {
1160
+ this.isFiltered = true;
1161
+ this.remoteFilterAction = true;
1162
+ this.dataUpdater(dataSource, query, fields);
1163
+ }
1164
+ protected getQuery(query: Query): Query {
1165
+ let filterQuery: Query = query ? query.clone() : this.query ? this.query.clone() : new Query();
1166
+ if (this.filterAction) {
1167
+ if (this.targetElement() !== null) {
1168
+ let dataType: string = <string>this.typeOfData(this.dataSource as { [key: string]: Object; }[]).typeof;
1169
+ if (!(this.dataSource instanceof DataManager) && dataType === 'string' || dataType === 'number') {
1170
+ filterQuery.where('', this.filterType, this.targetElement(), this.ignoreCase, this.ignoreAccent);
1171
+ } else {
1172
+ let fields: FieldSettingsModel = this.fields;
1173
+ filterQuery.where(
1174
+ !isNullOrUndefined(fields.text) ? fields.text : '',
1175
+ this.filterType, this.targetElement(), this.ignoreCase, this.ignoreAccent);
1176
+ }
1177
+ }
1178
+ return filterQuery;
1179
+ } else {
1180
+ return query ? query : this.query ? this.query : new Query();
1181
+ }
1182
+
1183
+ }
1184
+
1185
+ private dataUpdater(
1186
+ dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
1187
+ query?: Query, fields?: FieldSettingsModel): void {
1188
+ this.isDataFetched = false;
1189
+ if (this.targetElement().trim() === '') {
1190
+ let list: HTMLElement = this.mainList.cloneNode ? <HTMLElement>this.mainList.cloneNode(true) : this.mainList;
1191
+ if (this.backCommand) {
1192
+ this.remoteCustomValue = false;
1193
+ this.onActionComplete(list, this.mainData);
1194
+ if (this.value && this.value.length) {
1195
+ this.refreshSelection();
1196
+ }
1197
+ if (this.keyCode !== 8) {
1198
+ this.focusAtFirstListItem();
1199
+ }
1200
+ this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', e: this });
1201
+ }
1202
+ } else {
1203
+ this.resetList(dataSource, fields, query);
1204
+ if (this.allowCustomValue) {
1205
+ if (!(dataSource instanceof DataManager)) {
1206
+ this.checkForCustomValue(query, fields);
1207
+ } else {
1208
+ this.remoteCustomValue = true;
1209
+ this.tempQuery = query;
1210
+ }
1211
+ }
1212
+ }
1213
+ this.refreshPopup();
1214
+ if (this.mode === 'CheckBox') {
1215
+ this.removeFocus();
1216
+ }
1217
+ }
1218
+ private tempQuery: Query;
1219
+ private tempValues: string[] | number[] | boolean[];
1220
+ private checkForCustomValue(query?: Query, fields?: FieldSettingsModel): void {
1221
+ let dataChecks: boolean = !this.getValueByText(this.inputElement.value, this.ignoreCase);
1222
+ if (this.allowCustomValue && dataChecks) {
1223
+ let value: string = this.inputElement.value;
1224
+ let field: FieldSettingsModel = fields ? fields : this.fields;
1225
+ let customData: Object | string = (!isNullOrUndefined(this.mainData) && this.mainData.length > 0) ?
1226
+ (this.mainData as { [key: string]: Object; }[])[0] : this.mainData;
1227
+ if (typeof (customData) !== 'string') {
1228
+ let dataItem: { [key: string]: string | Object } = {};
1229
+ setValue(field.text, value, dataItem);
1230
+ setValue(field.value, value, dataItem);
1231
+ let tempData: [{ [key: string]: Object }] = JSON.parse(JSON.stringify(this.listData));
1232
+ tempData.splice(0, 0, dataItem);
1233
+ this.resetList(tempData, field, query);
1234
+ } else {
1235
+ let tempData: string[] = [this.inputElement.value];
1236
+ this.resetList(tempData, field);
1237
+ }
1238
+ }
1239
+ if (this.value && this.value.length) {
1240
+ this.refreshSelection();
1241
+ }
1242
+ }
1243
+ protected getNgDirective(): string {
1244
+ return 'EJS-MULTISELECT';
1245
+ }
1246
+ private wrapperClick(e: MouseEvent): void {
1247
+ this.setDynValue = false;
1248
+ if (!this.enabled) {
1249
+ return;
1250
+ }
1251
+ if ((<HTMLElement>e.target) === this.overAllClear) {
1252
+ e.preventDefault();
1253
+ return;
1254
+ }
1255
+ if (!this.inputFocus) {
1256
+ this.inputElement.focus();
1257
+ }
1258
+ if (!this.readonly) {
1259
+ if (e.target && (<HTMLElement>e.target).classList.toString().indexOf(CHIP_CLOSE) !== -1) {
1260
+ if (this.isPopupOpen()) {
1261
+ this.refreshPopup();
1262
+ }
1263
+ return;
1264
+ }
1265
+ if (!this.isPopupOpen() &&
1266
+ (this.openOnClick || (this.showDropDownIcon && e.target && (<HTMLElement>e.target).className === dropdownIcon))) {
1267
+ this.showPopup();
1268
+ } else {
1269
+ this.hidePopup();
1270
+ if (this.mode === 'CheckBox') {
1271
+ this.showOverAllClear();
1272
+ this.inputFocus = true;
1273
+ if (!this.overAllWrapper.classList.contains(FOCUS)) {
1274
+ this.overAllWrapper.classList.add(FOCUS);
1275
+ }
1276
+ }
1277
+ }
1278
+ }
1279
+ e.preventDefault();
1280
+ }
1281
+ private enable(state: boolean): void {
1282
+ if (state) {
1283
+ this.overAllWrapper.classList.remove(DISABLED);
1284
+ this.inputElement.removeAttribute('disabled');
1285
+ attributes(this.inputElement, { 'aria-disabled': 'false' });
1286
+ this.ensureAriaDisabled('false');
1287
+ } else {
1288
+ this.overAllWrapper.classList.add(DISABLED);
1289
+ this.inputElement.setAttribute('disabled', 'true');
1290
+ attributes(this.inputElement, { 'aria-disabled': 'true' });
1291
+ this.ensureAriaDisabled('true');
1292
+ }
1293
+ if (this.enabled !== state) {
1294
+ this.enabled = state;
1295
+ }
1296
+ this.hidePopup();
1297
+ }
1298
+ private scrollFocusStatus: boolean = false;
1299
+ private keyDownStatus: boolean = false;
1300
+ private onBlur(eve?: MouseEvent, isDocClickFromCheck?: boolean): void {
1301
+ let target: HTMLElement;
1302
+ if (!isNullOrUndefined(eve)) {
1303
+ target = <HTMLElement>eve.relatedTarget;
1304
+ }
1305
+ if (this.popupObj && document.body.contains(this.popupObj.element) && this.popupObj.element.contains(target)) {
1306
+ if (this.mode !== 'CheckBox') { this.inputElement.focus(); } else if ((this.floatLabelType === 'Auto' &&
1307
+ ((this.overAllWrapper.classList.contains('e-outline')) || (this.overAllWrapper.classList.contains('e-filled'))))) {
1308
+ addClass([this.overAllWrapper], 'e-valid-input');
1309
+ }
1310
+ return;
1311
+ }
1312
+ if (this.floatLabelType === 'Auto' && (this.overAllWrapper.classList.contains('e-outline')) && this.mode === 'CheckBox' &&
1313
+ ((isNullOrUndefined(this.value)) || this.value.length === 0)) {
1314
+ removeClass([this.overAllWrapper], 'e-valid-input');
1315
+ }
1316
+ if (this.mode === 'CheckBox' && Browser.isIE && !isNullOrUndefined(eve) && !isDocClickFromCheck) {
1317
+ this.inputFocus = false;
1318
+ this.overAllWrapper.classList.remove(FOCUS);
1319
+ return;
1320
+ }
1321
+ if (this.scrollFocusStatus) {
1322
+ if (!isNullOrUndefined(eve)) {
1323
+ eve.preventDefault();
1324
+ }
1325
+ this.inputElement.focus();
1326
+ this.scrollFocusStatus = false;
1327
+ return;
1328
+ }
1329
+ this.inputFocus = false;
1330
+ this.overAllWrapper.classList.remove(FOCUS);
1331
+ this.refreshListItems(null);
1332
+ if (this.mode !== 'Box' && this.mode !== 'CheckBox') {
1333
+ this.updateDelimView();
1334
+ }
1335
+ if (this.changeOnBlur) {
1336
+ this.updateValueState(eve, this.value, this.tempValues);
1337
+ this.dispatchEvent(this.hiddenElement as HTMLElement, 'change');
1338
+ }
1339
+ this.overAllClear.style.display = 'none';
1340
+ if (this.isPopupOpen()) {
1341
+ this.DropDownBaseresetBlazorTemplates(false, false, true, true, false, true, true);
1342
+ this.hidePopup();
1343
+ }
1344
+ this.makeTextBoxEmpty();
1345
+ this.trigger('blur');
1346
+ this.focused = true;
1347
+ if (Browser.isDevice && this.mode !== 'Delimiter' && this.mode !== 'CheckBox') {
1348
+ this.removeChipFocus();
1349
+ }
1350
+ this.removeChipSelection();
1351
+ this.refreshInputHight();
1352
+ floatLabelBlur(
1353
+ this.overAllWrapper,
1354
+ this.componentWrapper,
1355
+ this.value,
1356
+ this.floatLabelType,
1357
+ this.placeholder
1358
+ );
1359
+ this.refreshPlaceHolder();
1360
+ if ((this.allowFiltering || (this.enableSelectionOrder === true && this.mode === 'CheckBox'))
1361
+ && !isNullOrUndefined(this.mainList)) {
1362
+ this.ulElement = this.mainList;
1363
+ }
1364
+ this.checkPlaceholderSize();
1365
+ }
1366
+ private checkPlaceholderSize(): void {
1367
+ if (this.showDropDownIcon) {
1368
+ let downIconWidth: number = this.dropIcon.offsetWidth +
1369
+ parseInt(window.getComputedStyle(this.dropIcon).marginRight, 10);
1370
+ this.setPlaceholderSize(downIconWidth);
1371
+ } else {
1372
+ if (!isNullOrUndefined(this.dropIcon)) {
1373
+ this.setPlaceholderSize(this.showDropDownIcon ? this.dropIcon.offsetWidth : 0);
1374
+ }
1375
+ }
1376
+ }
1377
+ private setPlaceholderSize(downIconWidth: number): void {
1378
+ if (isNullOrUndefined(this.value) || this.value.length === 0) {
1379
+ if (this.dropIcon.offsetWidth !== 0) {
1380
+ this.searchWrapper.style.width = ('calc(100% - ' + (downIconWidth + 10)) + 'px';
1381
+ } else {
1382
+ addClass([this.searchWrapper], CUSTOM_WIDTH);
1383
+ }
1384
+ } else if (!isNullOrUndefined(this.value)) {
1385
+ this.searchWrapper.removeAttribute('style');
1386
+ removeClass([this.searchWrapper], CUSTOM_WIDTH);
1387
+ }
1388
+ }
1389
+ private refreshInputHight(): void {
1390
+ if ((!this.value || !this.value.length) && (isNullOrUndefined(this.text) || this.text === '')) {
1391
+ this.searchWrapper.classList.remove(ZERO_SIZE);
1392
+ } else {
1393
+ this.searchWrapper.classList.add(ZERO_SIZE);
1394
+ }
1395
+ }
1396
+ private validateValues(newValue: string[] | number[] | boolean[], oldValue: string[] | number[] | boolean[]): boolean {
1397
+ return JSON.stringify((newValue as string[]).slice().sort()) !== JSON.stringify((oldValue as string[]).slice().sort());
1398
+ }
1399
+ private updateValueState(
1400
+ event: KeyboardEventArgs | MouseEvent,
1401
+ newVal: string[] | number[] | boolean[],
1402
+ oldVal: string[] | number[] | boolean[]): void {
1403
+ let newValue: string[] | number[] | boolean[] = newVal ? newVal : <string[]>[];
1404
+ let oldValue: string[] | number[] | boolean[] = oldVal ? oldVal : <string[]>[];
1405
+ if (this.initStatus && this.validateValues(newValue, oldValue)) {
1406
+ let eventArgs: MultiSelectChangeEventArgs = {
1407
+ e: event,
1408
+ oldValue: <string[]>oldVal,
1409
+ value: <string[]>newVal,
1410
+ isInteracted: event ? true : false,
1411
+ element: this.element
1412
+ };
1413
+ this.trigger('change', eventArgs);
1414
+ this.updateTempValue();
1415
+ if (!this.changeOnBlur) {
1416
+ this.dispatchEvent(this.hiddenElement as HTMLElement, 'change');
1417
+ }
1418
+ }
1419
+ }
1420
+ private updateTempValue(): void {
1421
+ if (!this.value) {
1422
+ this.tempValues = this.value;
1423
+ } else {
1424
+ this.tempValues = <string[]>this.value.slice();
1425
+ }
1426
+ }
1427
+ private getPagingCount(): number {
1428
+ let height: string = this.list.classList.contains(dropDownBaseClasses.noData) ? null :
1429
+ getComputedStyle(this.getItems()[0], null).getPropertyValue('height');
1430
+ return Math.round(this.list.offsetHeight / parseInt(height, 10));
1431
+ }
1432
+
1433
+ private pageUpSelection(steps: number): void {
1434
+ let collection: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.'
1435
+ + dropDownBaseClasses.li + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1436
+ let previousItem: Element;
1437
+ previousItem = steps >= 0 ? collection[steps + 1] : collection[0];
1438
+ this.addListFocus(<HTMLElement>previousItem);
1439
+ this.scrollBottom(<HTMLElement>previousItem, this.getIndexByValue(previousItem.getAttribute('data-value')));
1440
+ };
1441
+
1442
+ private pageDownSelection(steps: number): void {
1443
+ let list: Element[] = this.getItems();
1444
+ let collection: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.'
1445
+ + dropDownBaseClasses.li + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1446
+ let previousItem: Element;
1447
+ previousItem = steps <= collection.length ? collection[steps - 1] : collection[collection.length - 1];
1448
+ this.addListFocus(<HTMLElement>previousItem);
1449
+ this.scrollBottom(<HTMLElement>previousItem, this.getIndexByValue(previousItem.getAttribute('data-value')));
1450
+ }
1451
+ public getItems(): Element[] {
1452
+ if (!this.list) {
1453
+ super.render();
1454
+ }
1455
+ return this.ulElement && (<HTMLElement[] & NodeListOf<Element>>
1456
+ this.ulElement.querySelectorAll('.' + dropDownBaseClasses.li)).length > 0 ?
1457
+ <HTMLElement[] & NodeListOf<Element>>this.ulElement.querySelectorAll('.' + dropDownBaseClasses.li
1458
+ + ':not(.' + HIDE_LIST + ')') : [];
1459
+
1460
+ }
1461
+ private focusInHandler(e?: FocusEvent | MouseEvent | KeyboardEvent | TouchEvent): boolean {
1462
+ if (this.enabled) {
1463
+ this.showOverAllClear();
1464
+ this.inputFocus = true;
1465
+ if (this.value && this.value.length) {
1466
+ if (this.mode !== 'Delimiter' && this.mode !== 'CheckBox') {
1467
+ this.chipCollectionWrapper.style.display = '';
1468
+ } else {
1469
+ this.showDelimWrapper();
1470
+ }
1471
+ if (this.mode !== 'CheckBox') {
1472
+ this.viewWrapper.style.display = 'none';
1473
+ }
1474
+ }
1475
+ if (this.mode !== 'CheckBox') {
1476
+ this.searchWrapper.classList.remove(ZERO_SIZE);
1477
+ }
1478
+ this.checkPlaceholderSize();
1479
+ if (this.focused) {
1480
+ let args: FocusEventArgs = { isInteracted: e ? true : false, event: e };
1481
+ this.trigger('focus', args);
1482
+ this.focused = false;
1483
+ }
1484
+ if (!this.overAllWrapper.classList.contains(FOCUS)) {
1485
+ this.overAllWrapper.classList.add(FOCUS);
1486
+ }
1487
+ floatLabelFocus(this.overAllWrapper, this.componentWrapper);
1488
+ if (this.isPopupOpen()) {
1489
+ this.refreshPopup();
1490
+ }
1491
+ return true;
1492
+ } else {
1493
+ return false;
1494
+ }
1495
+ }
1496
+ private showDelimWrapper(): void {
1497
+ if (this.mode === 'CheckBox') {
1498
+ this.viewWrapper.style.display = '';
1499
+ } else {
1500
+ this.delimiterWrapper.style.display = '';
1501
+ }
1502
+ this.componentWrapper.classList.add(DELIMITER_VIEW_WRAPPER);
1503
+ }
1504
+ private hideDelimWrapper(): void {
1505
+ this.delimiterWrapper.style.display = 'none';
1506
+ this.componentWrapper.classList.remove(DELIMITER_VIEW_WRAPPER);
1507
+ }
1508
+ private expandTextbox(): void {
1509
+ let size: number = 5;
1510
+ if (this.placeholder) {
1511
+ size = size > this.inputElement.placeholder.length ? size : this.inputElement.placeholder.length;
1512
+ }
1513
+ if (this.inputElement.value.length > size) {
1514
+ this.inputElement.size = this.inputElement.value.length;
1515
+ } else {
1516
+ this.inputElement.size = size;
1517
+ }
1518
+ }
1519
+ private isPopupOpen(): boolean {
1520
+ return ((this.popupWrapper !== null) && (this.popupWrapper.parentElement !== null));
1521
+ }
1522
+ private refreshPopup(): void {
1523
+ if (this.popupObj && this.mobFilter) {
1524
+ this.popupObj.setProperties({ width: this.calcPopupWidth() });
1525
+ this.popupObj.refreshPosition(this.overAllWrapper);
1526
+ }
1527
+ }
1528
+ private checkTextLength(): boolean {
1529
+ return this.targetElement().length < 1;
1530
+ }
1531
+ private popupKeyActions(e: KeyboardEventArgs): void {
1532
+ switch (e.keyCode) {
1533
+ case 38:
1534
+ this.hidePopup();
1535
+ if (this.mode === 'CheckBox') { this.inputElement.focus(); }
1536
+ e.preventDefault();
1537
+ break;
1538
+ case 40:
1539
+ if (!this.isPopupOpen()) {
1540
+ this.showPopup();
1541
+ e.preventDefault();
1542
+ }
1543
+ break;
1544
+ }
1545
+ }
1546
+
1547
+ private updateAriaAttribute(): void {
1548
+ let focusedItem: HTMLElement = <HTMLElement>this.list.querySelector('.' + dropDownBaseClasses.focus);
1549
+ if (!isNullOrUndefined(focusedItem)) {
1550
+ this.inputElement.setAttribute('aria-activedescendant', focusedItem.id);
1551
+ }
1552
+ }
1553
+
1554
+ private homeNavigation(isHome: boolean): void {
1555
+ this.removeFocus();
1556
+ let scrollEle: NodeListOf<HTMLElement> = this.ulElement.querySelectorAll('li.' + dropDownBaseClasses.li
1557
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1558
+ if (scrollEle.length > 0) {
1559
+ let element: HTMLElement = scrollEle[(isHome) ? 0 : (scrollEle.length - 1)];
1560
+ element.classList.add(dropDownBaseClasses.focus);
1561
+ this.scrollBottom(element);
1562
+ }
1563
+ }
1564
+
1565
+ private onKeyDown(e: KeyboardEventArgs): void {
1566
+ if (this.readonly || !this.enabled && this.mode !== 'CheckBox') { return; }
1567
+ this.keyDownStatus = true;
1568
+ if (e.keyCode > 111 && e.keyCode < 124) { return; }
1569
+ if (e.altKey) {
1570
+ this.popupKeyActions(e);
1571
+ return;
1572
+ } else if (this.isPopupOpen()) {
1573
+ let focusedItem: Element = this.list.querySelector('.' + dropDownBaseClasses.focus);
1574
+ let activeIndex: number;
1575
+ switch (e.keyCode) {
1576
+ case 36:
1577
+ case 35:
1578
+ this.homeNavigation((e.keyCode === 36) ? true : false);
1579
+ break;
1580
+ case 33:
1581
+ e.preventDefault();
1582
+ if (focusedItem) {
1583
+ this.getIndexByValue(focusedItem.getAttribute('data-value'));
1584
+ this.pageUpSelection(activeIndex - this.getPagingCount());
1585
+ this.updateAriaAttribute();
1586
+ }
1587
+ return;
1588
+ case 34:
1589
+ e.preventDefault();
1590
+ if (focusedItem) {
1591
+ this.getIndexByValue(focusedItem.getAttribute('data-value'));
1592
+ this.pageDownSelection(activeIndex + this.getPagingCount());
1593
+ this.updateAriaAttribute();
1594
+ }
1595
+ return;
1596
+ case 38:
1597
+ this.arrowUp(e);
1598
+ break;
1599
+ case 40:
1600
+ this.arrowDown(e);
1601
+ break;
1602
+ case 27:
1603
+ e.preventDefault();
1604
+ this.hidePopup();
1605
+ if (this.mode === 'CheckBox') { this.inputElement.focus(); }
1606
+ return;
1607
+ case 13:
1608
+ e.preventDefault();
1609
+ if (this.mode !== 'CheckBox') { this.selectByKey(e); }
1610
+ this.checkPlaceholderSize();
1611
+ return;
1612
+ case 32:
1613
+ this.spaceKeySelection(e);
1614
+ return;
1615
+ case 9:
1616
+ e.preventDefault();
1617
+ this.hidePopup();
1618
+ this.inputElement.focus();
1619
+ this.overAllWrapper.classList.add(FOCUS);
1620
+ }
1621
+ } else {
1622
+ switch (e.keyCode) {
1623
+ case 13:
1624
+ case 9:
1625
+ case 16:
1626
+ case 17:
1627
+ case 20:
1628
+ return;
1629
+ case 40:
1630
+ if (this.openOnClick) { this.showPopup(); }
1631
+ break;
1632
+ case 27:
1633
+ e.preventDefault();
1634
+ this.escapeAction();
1635
+ return;
1636
+ }
1637
+ }
1638
+ if (this.checkTextLength()) {
1639
+ this.keyNavigation(e);
1640
+ }
1641
+ if (this.mode === 'CheckBox' && this.enableSelectionOrder) { this.checkBackCommand(e); }
1642
+ this.expandTextbox();
1643
+ this.refreshPopup();
1644
+ }
1645
+ private arrowDown(e: KeyboardEventArgs): void {
1646
+ e.preventDefault();
1647
+ this.moveByList(1);
1648
+ this.keyAction = true;
1649
+ if (document.activeElement.classList.contains('e-input-filter')
1650
+ || (this.mode === 'CheckBox' && !this.allowFiltering && document.activeElement !== this.list)) {
1651
+ this.list.focus();
1652
+ EventHandler.add(this.list, 'keydown', this.onKeyDown, this);
1653
+ }
1654
+ this.updateAriaAttribute();
1655
+ }
1656
+ private arrowUp(e: KeyboardEventArgs): void {
1657
+ e.preventDefault();
1658
+ this.keyAction = true;
1659
+ let list: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.'
1660
+ + dropDownBaseClasses.li
1661
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1662
+ if (this.enableGroupCheckBox && this.mode === 'CheckBox' && !isNullOrUndefined(this.fields.groupBy)) {
1663
+ list = this.list.querySelectorAll('li.'
1664
+ + dropDownBaseClasses.li + ',li.' + dropDownBaseClasses.group
1665
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1666
+ }
1667
+ let focuseElem: Element = <HTMLElement>this.list.querySelector('li.' + dropDownBaseClasses.focus);
1668
+ let index: number = Array.prototype.slice.call(list).indexOf(focuseElem);
1669
+ if (index <= 0 && (this.mode === 'CheckBox' && this.allowFiltering)) {
1670
+ this.keyAction = false;
1671
+ this.notify('inputFocus', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'focus' });
1672
+ } else {
1673
+ this.list.focus();
1674
+ }
1675
+ this.moveByList(-1);
1676
+ this.updateAriaAttribute();
1677
+ }
1678
+ private spaceKeySelection(e: KeyboardEventArgs): void {
1679
+ if (this.mode === 'CheckBox') {
1680
+ if (!document.activeElement.classList.contains('e-input-filter')) {
1681
+ e.preventDefault();
1682
+ this.keyAction = true;
1683
+ this.list.focus();
1684
+ }
1685
+ this.selectByKey(e);
1686
+ }
1687
+ this.checkPlaceholderSize();
1688
+ }
1689
+ private checkBackCommand(e: KeyboardEventArgs): void {
1690
+ if (e.keyCode === 8 && this.targetElement() === '') {
1691
+ this.backCommand = false;
1692
+ } else {
1693
+ this.backCommand = true;
1694
+ }
1695
+ }
1696
+ private keyNavigation(e: KeyboardEventArgs): void {
1697
+ if ((this.mode !== 'Delimiter' && this.mode !== 'CheckBox') && this.value && this.value.length) {
1698
+ switch (e.keyCode) {
1699
+ case 37: //left arrow
1700
+ e.preventDefault();
1701
+ this.moveBy(-1, e);
1702
+ break;
1703
+ case 39: //right arrow
1704
+ e.preventDefault();
1705
+ this.moveBy(1, e);
1706
+ break;
1707
+ case 8:
1708
+ this.removelastSelection(e);
1709
+ break;
1710
+ case 46: //del
1711
+ this.removeSelectedChip(e);
1712
+ break;
1713
+ }
1714
+ } else if (e.keyCode === 8 && this.mode === 'Delimiter') {
1715
+ if (this.value && this.value.length) {
1716
+ e.preventDefault();
1717
+ let temp: string | number | boolean = this.value[this.value.length - 1];
1718
+ this.removeValue(temp, e);
1719
+ this.updateDelimeter(this.delimiterChar, e);
1720
+ this.focusAtLastListItem(<string>temp);
1721
+ }
1722
+ }
1723
+ }
1724
+ private selectByKey(e: KeyboardEventArgs): void {
1725
+ this.removeChipSelection();
1726
+ this.selectListByKey(e);
1727
+ if (this.hideSelectedItem) {
1728
+ this.focusAtFirstListItem();
1729
+ }
1730
+ }
1731
+ private escapeAction(): void {
1732
+ let temp: string[] | number[] = this.tempValues ? <string[]>this.tempValues.slice() : <string[]>[];
1733
+ if (this.value && this.validateValues(this.value, temp)) {
1734
+ if (this.mode !== 'CheckBox') {
1735
+ this.value = temp;
1736
+ this.initialValueUpdate();
1737
+ }
1738
+ if (this.mode !== 'Delimiter' && this.mode !== 'CheckBox') {
1739
+ this.chipCollectionWrapper.style.display = '';
1740
+ } else {
1741
+ this.showDelimWrapper();
1742
+ }
1743
+ this.refreshPlaceHolder();
1744
+ if (this.value.length) {
1745
+ this.showOverAllClear();
1746
+ } else {
1747
+ this.hideOverAllClear();
1748
+ }
1749
+ }
1750
+ this.makeTextBoxEmpty();
1751
+ }
1752
+ private scrollBottom(selectedLI: HTMLElement, activeIndex?: number): void {
1753
+ let currentOffset: number = this.list.offsetHeight;
1754
+ let nextBottom: number = selectedLI.offsetTop + selectedLI.offsetHeight - this.list.scrollTop;
1755
+ let nextOffset: number = this.list.scrollTop + nextBottom - currentOffset;
1756
+ let boxRange: number = (selectedLI.offsetTop + selectedLI.offsetHeight - this.list.scrollTop);
1757
+ boxRange = this.fields.groupBy && !isNullOrUndefined(this.fixedHeaderElement) ?
1758
+ boxRange - this.fixedHeaderElement.offsetHeight : boxRange;
1759
+ if (activeIndex === 0) {
1760
+ this.list.scrollTop = 0;
1761
+ } else if (nextBottom > currentOffset) {
1762
+ this.list.scrollTop = nextOffset;
1763
+ } else if (!(boxRange > 0 && this.list.offsetHeight > boxRange)) {
1764
+ this.list.scrollTop = nextOffset;
1765
+ }
1766
+ }
1767
+ private scrollTop(selectedLI: HTMLElement, activeIndex: number): void {
1768
+ let nextOffset: number = selectedLI.offsetTop - this.list.scrollTop;
1769
+ let nextBottom: number = selectedLI.offsetTop + selectedLI.offsetHeight - this.list.scrollTop;
1770
+ nextOffset = this.fields.groupBy && !isUndefined(this.fixedHeaderElement) ?
1771
+ nextOffset - this.fixedHeaderElement.offsetHeight : nextOffset;
1772
+ let boxRange: number = (selectedLI.offsetTop + selectedLI.offsetHeight - this.list.scrollTop);
1773
+ if (activeIndex === 0) {
1774
+ this.list.scrollTop = 0;
1775
+ } else if (nextOffset < 0) {
1776
+ this.list.scrollTop = this.list.scrollTop + nextOffset;
1777
+ } else if (!(boxRange > 0 && this.list.offsetHeight > boxRange)) {
1778
+ this.list.scrollTop = selectedLI.offsetTop - (this.fields.groupBy && !isUndefined(this.fixedHeaderElement) ?
1779
+ this.fixedHeaderElement.offsetHeight : 0);
1780
+ }
1781
+ }
1782
+ private selectListByKey(e: KeyboardEventArgs): void {
1783
+ let li: HTMLElement = <HTMLElement>this.list.querySelector('li.' + dropDownBaseClasses.focus);
1784
+ let limit: number = this.value && this.value.length ? this.value.length : 0;
1785
+ let target : HTMLElement;
1786
+ if (li !== null) {
1787
+ if (li.classList.contains('e-active')) {
1788
+ limit = limit - 1;
1789
+ }
1790
+ if (this.isValidLI(li) && limit < this.maximumSelectionLength) {
1791
+ this.updateListSelection(li, e);
1792
+ this.addListFocus(<HTMLElement>li);
1793
+ if (this.mode === 'CheckBox') {
1794
+ this.updateDelimView();
1795
+ this.updateDelimeter(this.delimiterChar, e);
1796
+ this.refreshInputHight();
1797
+ this.checkPlaceholderSize();
1798
+ if (this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
1799
+ (target as Element) = li.firstElementChild.lastElementChild;
1800
+ this.findGroupStart(target);
1801
+ this.deselectHeader();
1802
+ }
1803
+ } else {
1804
+ this.updateDelimeter(this.delimiterChar, e);
1805
+ }
1806
+ this.makeTextBoxEmpty();
1807
+ if (this.mode !== 'CheckBox') {
1808
+ this.refreshListItems(li.textContent);
1809
+ }
1810
+ if (!this.changeOnBlur) {
1811
+ this.updateValueState(e, this.value, this.tempValues);
1812
+ }
1813
+ this.refreshPopup();
1814
+ }else {
1815
+ if (!this.isValidLI(li) && limit < this.maximumSelectionLength) {
1816
+ (target as Element) = li.firstElementChild.lastElementChild;
1817
+ target.classList.contains('e-check') ? this.selectAllItem(false, e, li) : this.selectAllItem(true, e, li);
1818
+ }
1819
+ }
1820
+ this.refreshSelection();
1821
+ if (this.closePopupOnSelect) {
1822
+ this.hidePopup();
1823
+ }
1824
+ }
1825
+ this.refreshPlaceHolder();
1826
+ }
1827
+ private refreshListItems(data: string): void {
1828
+ if ((this.allowFiltering || (this.mode === 'CheckBox' && this.enableSelectionOrder === true)
1829
+ || this.allowCustomValue) && this.mainList && this.listData) {
1830
+ let list: HTMLElement;
1831
+ list = this.mainList.cloneNode ? <HTMLElement>this.mainList.cloneNode(true) : this.mainList;
1832
+ this.onActionComplete(list, this.mainData);
1833
+ this.focusAtLastListItem(data);
1834
+ if (this.value && this.value.length) {
1835
+ this.refreshSelection();
1836
+ }
1837
+ }
1838
+ }
1839
+ private removeSelectedChip(e: KeyboardEventArgs): void {
1840
+ let selectedElem: Element = <HTMLElement>this.chipCollectionWrapper.querySelector('span.' + CHIP_SELECTED);
1841
+ let temp: Element;
1842
+ if (selectedElem !== null) {
1843
+ if (!isNullOrUndefined(this.value)) {
1844
+ this.tempValues = <string[]>this.value.slice();
1845
+ }
1846
+ temp = selectedElem.nextElementSibling;
1847
+ if (temp !== null) {
1848
+ this.removeChipSelection();
1849
+ this.addChipSelection(temp, e);
1850
+ }
1851
+ this.removeValue(selectedElem.getAttribute('data-value'), e);
1852
+ this.makeTextBoxEmpty();
1853
+ }
1854
+ if (this.closePopupOnSelect) {
1855
+ this.hidePopup();
1856
+ }
1857
+ this.checkPlaceholderSize();
1858
+ }
1859
+ private moveByTop(state: boolean): void {
1860
+ let elements: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.' + dropDownBaseClasses.li);
1861
+ let index: number;
1862
+ if (elements.length > 1) {
1863
+ this.removeFocus();
1864
+ index = state ? 0 : (elements.length - 1);
1865
+ this.addListFocus(<HTMLElement>elements[index]);
1866
+ this.scrollBottom(<HTMLElement>elements[index], index);
1867
+ }
1868
+ this.updateAriaAttribute();
1869
+ }
1870
+ private moveByList(position: number): void {
1871
+ if (this.list) {
1872
+ let elements: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.'
1873
+ + dropDownBaseClasses.li
1874
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1875
+ if (this.mode === 'CheckBox' && this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
1876
+ elements = this.list.querySelectorAll('li.'
1877
+ + dropDownBaseClasses.li + ',li.' + dropDownBaseClasses.group
1878
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
1879
+ }
1880
+ let selectedElem: Element = <HTMLElement>this.list.querySelector('li.' + dropDownBaseClasses.focus);
1881
+ let temp: number = -1;
1882
+ if (elements.length) {
1883
+ for (let index: number = 0; index < elements.length; index++) {
1884
+ if (elements[index] === selectedElem) {
1885
+ temp = index;
1886
+ break;
1887
+ }
1888
+ }
1889
+ if (position > 0) {
1890
+ if (temp < (elements.length - 1)) {
1891
+ this.removeFocus();
1892
+ this.addListFocus(<HTMLElement>elements[++temp]);
1893
+ this.updateCheck(elements[temp]);
1894
+ this.scrollBottom(<HTMLElement>elements[temp], temp);
1895
+ }
1896
+ } else {
1897
+ if (temp > 0) {
1898
+ this.removeFocus();
1899
+ this.addListFocus(<HTMLElement>elements[--temp]);
1900
+ this.updateCheck(elements[temp]);
1901
+ this.scrollTop(<HTMLElement>elements[temp], temp);
1902
+ }
1903
+ }
1904
+
1905
+ }
1906
+ }
1907
+ }
1908
+ private updateCheck(element: Element): void {
1909
+ if (this.mode === 'CheckBox' && this.enableGroupCheckBox &&
1910
+ !isNullOrUndefined(this.fields.groupBy)) {
1911
+ let checkElement: Element = element.firstElementChild.lastElementChild;
1912
+ if (checkElement.classList.contains('e-check')) {
1913
+ element.classList.add('e-active');
1914
+ } else {
1915
+ element.classList.remove('e-active');
1916
+ }
1917
+ }
1918
+ }
1919
+ private moveBy(position: number, e?: KeyboardEventArgs): void {
1920
+ let elements: NodeListOf<Element>;
1921
+ let selectedElem: Element;
1922
+ let temp: Element;
1923
+ elements = <NodeListOf<HTMLElement>>this.chipCollectionWrapper.querySelectorAll('span.' + CHIP);
1924
+ selectedElem = <HTMLElement>this.chipCollectionWrapper.querySelector('span.' + CHIP_SELECTED);
1925
+ if (selectedElem === null) {
1926
+ if (position < 0) {
1927
+ this.addChipSelection(elements[elements.length - 1], e);
1928
+ }
1929
+ } else {
1930
+ if (position < 0) {
1931
+ temp = selectedElem.previousElementSibling;
1932
+ if (temp !== null) {
1933
+ this.removeChipSelection();
1934
+ this.addChipSelection(temp, e);
1935
+ }
1936
+ } else {
1937
+ temp = selectedElem.nextElementSibling;
1938
+ this.removeChipSelection();
1939
+ if (temp !== null) {
1940
+ this.addChipSelection(temp, e);
1941
+ }
1942
+ }
1943
+ }
1944
+ }
1945
+ private chipClick(e: MouseEvent): void {
1946
+ if (this.enabled) {
1947
+ let elem: HTMLElement = <HTMLElement>closest(<HTMLElement>e.target, '.' + CHIP);
1948
+ this.removeChipSelection();
1949
+ this.addChipSelection(elem, e);
1950
+ }
1951
+ }
1952
+ private removeChipSelection(): void {
1953
+ if (this.chipCollectionWrapper) {
1954
+ this.removeChipFocus();
1955
+ }
1956
+ }
1957
+ private addChipSelection(element: Element, e?: MouseEvent | KeyboardEventArgs): void {
1958
+ addClass([element], CHIP_SELECTED);
1959
+ this.trigger('chipSelection', e);
1960
+ }
1961
+ private onChipRemove(e: MouseEvent): void {
1962
+ if (e.which === 3 || e.button === 2) { return; }
1963
+ if (this.enabled && !this.readonly) {
1964
+ let element: HTMLElement = (<HTMLElement>e.target).parentElement;
1965
+ let customVal: string | number | boolean = element.getAttribute('data-value');
1966
+ let value: string | number | boolean = this.getFormattedValue(customVal);
1967
+ if (this.allowCustomValue && (( customVal !== 'false' && value === false ) ||
1968
+ (!isNullOrUndefined(value) && value.toString() === 'NaN'))) {
1969
+ value = customVal;
1970
+ }
1971
+ if (this.isPopupOpen() && this.mode !== 'CheckBox') {
1972
+ this.hidePopup();
1973
+ }
1974
+ if (!this.inputFocus) {
1975
+ this.inputElement.focus();
1976
+ }
1977
+ this.removeValue(value, e);
1978
+ if (isNullOrUndefined(this.findListElement(this.list, 'li', 'data-value', value)) && this.mainList && this.listData) {
1979
+ let list: HTMLElement = this.mainList.cloneNode ? <HTMLElement>this.mainList.cloneNode(true) : this.mainList;
1980
+ this.onActionComplete(list, this.mainData);
1981
+ }
1982
+ this.updateDelimeter(this.delimiterChar, e);
1983
+ if (this.placeholder && this.floatLabelType === 'Never') {
1984
+ this.makeTextBoxEmpty();
1985
+ this.checkPlaceholderSize();
1986
+ } else {
1987
+ this.inputElement.value = '';
1988
+ }
1989
+ e.preventDefault();
1990
+ }
1991
+ }
1992
+ private makeTextBoxEmpty(): void {
1993
+ this.inputElement.value = '';
1994
+ this.refreshPlaceHolder();
1995
+ }
1996
+ private refreshPlaceHolder(): void {
1997
+ if (this.placeholder && this.floatLabelType === 'Never') {
1998
+ if ((this.value && this.value.length) || (!isNullOrUndefined(this.text) && this.text !== '')) {
1999
+ this.inputElement.placeholder = '';
2000
+ } else {
2001
+ this.inputElement.placeholder = this.placeholder;
2002
+ }
2003
+ } else {
2004
+ this.setFloatLabelType();
2005
+ }
2006
+ this.expandTextbox();
2007
+ }
2008
+ private removeValue(
2009
+ value: string | number | boolean,
2010
+ eve: MouseEvent | KeyboardEventArgs,
2011
+ length?: number,
2012
+ isClearAll?: boolean): void {
2013
+ let index: number = (this.value as string[]).indexOf(this.getFormattedValue(<string>value) as string);
2014
+ if (index === -1 && this.allowCustomValue && !isNullOrUndefined(value)) {
2015
+ index = (this.value as string[]).indexOf(value.toString());
2016
+ }
2017
+ let targetEle: HTMLElement = eve && eve.target as HTMLElement;
2018
+ isClearAll = (isClearAll || targetEle && targetEle.classList.contains('e-close-hooker')) ? true : null;
2019
+ let className: string = this.hideSelectedItem ?
2020
+ HIDE_LIST :
2021
+ dropDownBaseClasses.selected;
2022
+ if (index !== -1) {
2023
+ let element: HTMLElement = this.findListElement(this.list, 'li', 'data-value', value);
2024
+ let val: FieldSettingsModel = this.getDataByValue(value) as FieldSettingsModel;
2025
+ let eventArgs: RemoveEventArgs = {
2026
+ e: eve,
2027
+ item: <HTMLLIElement>element,
2028
+ itemData: val,
2029
+ isInteracted: eve ? true : false,
2030
+ cancel: false
2031
+ };
2032
+ this.trigger('removing', eventArgs, (eventArgs: RemoveEventArgs) => {
2033
+ if (eventArgs.cancel) {
2034
+ this.removeIndex++;
2035
+ } else {
2036
+ let removeVal: number[] | string[] | boolean[] = this.value.slice(0);
2037
+ removeVal.splice(index, 1);
2038
+ if (isBlazor() && this.isServerRendered) {
2039
+ let removedValues: number[] | string[] | boolean[] = ([].concat([], removeVal) as number[] | string[] | boolean[]);
2040
+ this.setProperties({ value: removedValues.length === 0 ? null : removedValues }, true);
2041
+ } else {
2042
+ this.setProperties({ value: <[number | string]>[].concat([], removeVal) }, true);
2043
+ }
2044
+ if (element !== null) {
2045
+ let hideElement: HTMLElement = this.findListElement(this.mainList, 'li', 'data-value', value);
2046
+ element.setAttribute('aria-selected', 'false');
2047
+ removeClass([element], className);
2048
+ if (hideElement) {
2049
+ hideElement.setAttribute('aria-selected', 'false');
2050
+ removeClass([element, hideElement], className);
2051
+ }
2052
+ this.notify('activeList', {
2053
+ module: 'CheckBoxSelection',
2054
+ enable: this.mode === 'CheckBox', li: element,
2055
+ e: this, index: index
2056
+ });
2057
+ this.notify('updatelist', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', li: element, e: eve });
2058
+ attributes(this.inputElement, { 'aria-activedescendant': element.id });
2059
+ if ((this.value && this.value.length !== this.mainData.length)
2060
+ && (this.mode === 'CheckBox' && this.showSelectAll)) {
2061
+ this.notify(
2062
+ 'checkSelectAll',
2063
+ { module: 'CheckBoxSelection',
2064
+ enable: this.mode === 'CheckBox',
2065
+ value: 'uncheck' });
2066
+ }
2067
+ }
2068
+ if (this.hideSelectedItem && this.fields.groupBy) { this.hideGroupItem(value); }
2069
+ this.updateMainList(true, <string>value);
2070
+ this.removeChip(value);
2071
+ this.updateChipStatus();
2072
+ let limit: number = this.value && this.value.length ? this.value.length : 0;
2073
+ if (limit < this.maximumSelectionLength) {
2074
+ let collection: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.'
2075
+ + dropDownBaseClasses.li + ':not(.e-active)');
2076
+ removeClass(collection, 'e-disable');
2077
+ }
2078
+ this.trigger('removed', eventArgs);
2079
+ let targetEle: HTMLElement = eve && eve.currentTarget as HTMLElement;
2080
+ let isSelectAll: boolean = (targetEle && targetEle.classList.contains('e-selectall-parent')) ? true : null;
2081
+ if (!this.changeOnBlur && !isClearAll && (eve && length && !isSelectAll)) {
2082
+ this.updateValueState(eve, this.value, this.tempValues);
2083
+ }
2084
+ if (length) {
2085
+ this.selectAllEventData.push(val);
2086
+ this.selectAllEventEle.push(<HTMLLIElement>element);
2087
+ }
2088
+ if (length === 1) {
2089
+ if (!this.changeOnBlur) {
2090
+ this.updateValueState(eve, this.value, this.tempValues);
2091
+ }
2092
+ let args: ISelectAllEventArgs = {
2093
+ event: eve,
2094
+ items: this.selectAllEventEle,
2095
+ itemData: this.selectAllEventData,
2096
+ isInteracted: eve ? true : false,
2097
+ isChecked: false
2098
+ };
2099
+ this.trigger('selectedAll', args);
2100
+ this.selectAllEventData = [];
2101
+ this.selectAllEventEle = [];
2102
+ }
2103
+ if (isClearAll && (length === 1 || length === null)) { this.clearAllCallback(eve as MouseEvent, isClearAll); }
2104
+ if (isBlazor() && this.isServerRendered && (isNullOrUndefined(this.value) || this.value.length === 0)) {
2105
+ this.updatedataValueItems(eve);
2106
+ }
2107
+ }
2108
+ });
2109
+ }
2110
+ }
2111
+ private updateMainList(state: boolean, value: string): void {
2112
+ if (this.allowFiltering || this.mode === 'CheckBox') {
2113
+ let element2: HTMLElement = this.findListElement(this.mainList, 'li', 'data-value', value);
2114
+ if (element2) {
2115
+ if (state) {
2116
+ element2.setAttribute('aria-selected', 'false');
2117
+ removeClass([element2], this.hideSelectedItem ?
2118
+ HIDE_LIST :
2119
+ dropDownBaseClasses.selected);
2120
+ if (this.mode === 'CheckBox') {
2121
+ element2.firstElementChild.setAttribute('aria-checked', 'false');
2122
+ removeClass([element2.firstElementChild.lastElementChild], 'e-check');
2123
+ }
2124
+ } else {
2125
+ element2.setAttribute('aria-selected', 'true');
2126
+ addClass([element2], this.hideSelectedItem ?
2127
+ HIDE_LIST :
2128
+ dropDownBaseClasses.selected);
2129
+ if (this.mode === 'CheckBox') {
2130
+ element2.firstElementChild.setAttribute('aria-checked', 'true');
2131
+ addClass([element2.firstElementChild.lastElementChild], 'e-check');
2132
+ }
2133
+ }
2134
+ }
2135
+ }
2136
+ }
2137
+ private removeChip(value: string | number | boolean): void {
2138
+ if (this.chipCollectionWrapper) {
2139
+ let element: HTMLElement = this.findListElement(this.chipCollectionWrapper, 'span', 'data-value', value);
2140
+ if (element) {
2141
+ remove(element);
2142
+ }
2143
+ }
2144
+
2145
+ }
2146
+ private setWidth(width: number | string): void {
2147
+ if (!isNullOrUndefined(width)) {
2148
+ if (typeof width === 'number') {
2149
+ this.overAllWrapper.style.width = formatUnit(width);
2150
+ } else if (typeof width === 'string') {
2151
+ this.overAllWrapper.style.width = (width.match(/px|%|em/)) ? <string>(width) : <string>(formatUnit(width));
2152
+ }
2153
+ }
2154
+ }
2155
+ private updateChipStatus(): void {
2156
+ if (this.value && this.value.length) {
2157
+ if (!isNullOrUndefined(this.chipCollectionWrapper)) {
2158
+ (this.chipCollectionWrapper.style.display = '');
2159
+ }
2160
+ if (this.mode === 'Delimiter' || this.mode === 'CheckBox') {
2161
+ this.showDelimWrapper();
2162
+ }
2163
+ this.showOverAllClear();
2164
+ } else {
2165
+ if (!isNullOrUndefined(this.chipCollectionWrapper)) {
2166
+ this.chipCollectionWrapper.style.display = 'none';
2167
+ }
2168
+ if (!isNullOrUndefined(this.delimiterWrapper)) {
2169
+ (this.delimiterWrapper.style.display = 'none');
2170
+ }
2171
+ this.hideOverAllClear();
2172
+ }
2173
+ }
2174
+ private addValue(value: string | number | boolean, text: string, eve: MouseEvent | KeyboardEventArgs): void {
2175
+ if (!this.value) {
2176
+ this.value = <string[]>[];
2177
+ }
2178
+ if ((this.value as string[]).indexOf(value as string) < 0) {
2179
+ this.setProperties({ value: <[number | string]>[].concat([], this.value, [value]) }, true);
2180
+ }
2181
+ let element: HTMLElement = this.findListElement(this.list, 'li', 'data-value', value);
2182
+ this.removeFocus();
2183
+ if (element) {
2184
+ this.addListFocus(element);
2185
+ this.addListSelection(element);
2186
+ }
2187
+ if (this.mode !== 'Delimiter' && this.mode !== 'CheckBox') {
2188
+ this.addChip(text, value, eve);
2189
+ }
2190
+ if (this.hideSelectedItem && this.fields.groupBy) { this.hideGroupItem(value); }
2191
+ this.updateChipStatus();
2192
+ this.checkMaxSelection();
2193
+ }
2194
+ private checkMaxSelection(): void {
2195
+ let limit: number = this.value && this.value.length ? this.value.length : 0;
2196
+ if (limit === this.maximumSelectionLength) {
2197
+ let collection: NodeListOf<Element> = <NodeListOf<HTMLElement>>this.list.querySelectorAll('li.'
2198
+ + dropDownBaseClasses.li + ':not(.e-active)');
2199
+ addClass(collection, 'e-disable');
2200
+ }
2201
+ }
2202
+ private dispatchSelect(
2203
+ value: string | number | boolean,
2204
+ eve: MouseEvent | KeyboardEventArgs,
2205
+ element: HTMLElement,
2206
+ isNotTrigger: boolean,
2207
+ length?: number): void {
2208
+ if (this.initStatus && !isNotTrigger) {
2209
+ let val: FieldSettingsModel = this.getDataByValue(value) as FieldSettingsModel;
2210
+ let eventArgs: SelectEventArgs = {
2211
+ e: eve,
2212
+ item: <HTMLLIElement>element,
2213
+ itemData: val,
2214
+ isInteracted: eve ? true : false,
2215
+ cancel: false
2216
+ };
2217
+ this.trigger('select', eventArgs, (eventArgs: SelectEventArgs) => {
2218
+ if (!eventArgs.cancel) {
2219
+ if (length) {
2220
+ this.selectAllEventData.push(val);
2221
+ this.selectAllEventEle.push(<HTMLLIElement>element);
2222
+ }
2223
+ if (length === 1) {
2224
+ let args: ISelectAllEventArgs = {
2225
+ event: eve,
2226
+ items: this.selectAllEventEle,
2227
+ itemData: this.selectAllEventData,
2228
+ isInteracted: eve ? true : false,
2229
+ isChecked: true
2230
+ };
2231
+ this.trigger('selectedAll', args);
2232
+ this.selectAllEventData = [];
2233
+ }
2234
+ this.updateListSelectEventCallback(value, element, eve);
2235
+ }
2236
+ });
2237
+ }
2238
+ }
2239
+ private addChip(text: string, value: string | number | boolean, e?: MouseEvent | KeyboardEventArgs): void {
2240
+ if (this.chipCollectionWrapper) {
2241
+ this.getChip(text, value, e);
2242
+ }
2243
+ }
2244
+ private removeChipFocus(): void {
2245
+ let elements: NodeListOf<Element>;
2246
+ let closeElements: NodeListOf<Element>;
2247
+ elements = <NodeListOf<HTMLElement>>
2248
+ this.chipCollectionWrapper.querySelectorAll('span.' + CHIP);
2249
+ closeElements = <NodeListOf<HTMLElement>>
2250
+ this.chipCollectionWrapper.querySelectorAll('span.' + CHIP_CLOSE.split(' ')[0]);
2251
+ removeClass(elements, CHIP_SELECTED);
2252
+ if (Browser.isDevice) {
2253
+ for (let index: number = 0; index < closeElements.length; index++) {
2254
+ (<HTMLElement>closeElements[index]).style.display = 'none';
2255
+ }
2256
+ }
2257
+
2258
+ }
2259
+ private onMobileChipInteraction(e: MouseEvent): void {
2260
+ let chipElem: HTMLElement = <HTMLElement>closest(<HTMLElement>e.target, '.' + CHIP);
2261
+ let chipClose: HTMLElement = <HTMLElement>chipElem.querySelector('span.' + CHIP_CLOSE.split(' ')[0]);
2262
+ if (this.enabled && !this.readonly) {
2263
+ if (!chipElem.classList.contains(CHIP_SELECTED)) {
2264
+ this.removeChipFocus();
2265
+ chipClose.style.display = '';
2266
+ chipElem.classList.add(CHIP_SELECTED);
2267
+ }
2268
+ this.refreshPopup();
2269
+ e.preventDefault();
2270
+ }
2271
+ }
2272
+ private multiCompiler(multiselectTemplate: string): boolean {
2273
+ let checkTemplate: boolean = false;
2274
+ if (multiselectTemplate) {
2275
+ let exception: Object;
2276
+ try {
2277
+ checkTemplate = (document.querySelectorAll(multiselectTemplate).length) ? true : false;
2278
+ } catch (exception) {
2279
+ checkTemplate = false;
2280
+ }
2281
+ }
2282
+ return checkTemplate;
2283
+ }
2284
+ private getChip(
2285
+ data: string, value: string | number | boolean,
2286
+ e?: MouseEvent | KeyboardEventArgs): void {
2287
+ let itemData: { [key: string]: Object } | string | boolean | number = { text: value, value: value };
2288
+ let chip: HTMLElement = this.createElement('span', {
2289
+ className: CHIP,
2290
+ attrs: { 'data-value': <string>value, 'title': data }
2291
+ });
2292
+ let compiledString: Function;
2293
+ let chipContent: HTMLElement = this.createElement('span', { className: CHIP_CONTENT });
2294
+ let chipClose: HTMLElement = this.createElement('span', { className: CHIP_CLOSE });
2295
+ if (this.mainData) {
2296
+ itemData = (isBlazor() && this.isServerRendered) ? JSON.parse(JSON.stringify(this.getDataByValue(value)))
2297
+ : this.getDataByValue(value);
2298
+ }
2299
+ if (this.valueTemplate && !isNullOrUndefined(itemData)) {
2300
+ let valuecheck: boolean = this.multiCompiler(this.valueTemplate);
2301
+ if (valuecheck) {
2302
+ compiledString = compile(document.querySelector(this.valueTemplate).innerHTML.trim());
2303
+ } else {
2304
+ compiledString = compile(this.valueTemplate);
2305
+ }
2306
+ for (let item of compiledString(itemData, null, null, this.valueTemplateId, this.isStringTemplate)) {
2307
+ chipContent.appendChild(item);
2308
+ }
2309
+ this.DropDownBaseupdateBlazorTemplates(false, false, false, false, true, false, false, false);
2310
+ } else {
2311
+ chipContent.innerHTML = data;
2312
+ }
2313
+ chip.appendChild(chipContent);
2314
+ let eventArgs: { [key: string]: Object } = {
2315
+ isInteracted: e ? true : false,
2316
+ itemData: itemData,
2317
+ e: e,
2318
+ setClass: (classes: string) => {
2319
+ addClass([chip], classes);
2320
+ },
2321
+ cancel: false
2322
+ };
2323
+ this.trigger('tagging', eventArgs, (eventArgs: TaggingEventArgs) => {
2324
+ if (!eventArgs.cancel) {
2325
+ if (eventArgs.setClass && typeof eventArgs.setClass === 'string' && (isBlazor() && this.isServerRendered)) {
2326
+ addClass([chip], eventArgs.setClass);
2327
+ }
2328
+ if (Browser.isDevice) {
2329
+ chip.classList.add(MOBILE_CHIP);
2330
+ append([chipClose], chip);
2331
+ chipClose.style.display = 'none';
2332
+ EventHandler.add(chip, 'click', this.onMobileChipInteraction, this);
2333
+ } else {
2334
+ EventHandler.add(chip, 'mousedown', this.chipClick, this);
2335
+ if (this.showClearButton) {
2336
+ chip.appendChild(chipClose);
2337
+ }
2338
+ }
2339
+ EventHandler.add(chipClose, 'mousedown', this.onChipRemove, this);
2340
+ this.chipCollectionWrapper.appendChild(chip as HTMLElement);
2341
+ if (!this.changeOnBlur && e) {
2342
+ this.updateValueState(e, this.value, this.tempValues);
2343
+ }
2344
+ }
2345
+ });
2346
+ }
2347
+ private calcPopupWidth(): string {
2348
+ let width: string = formatUnit(this.popupWidth);
2349
+ if (width.indexOf('%') > -1) {
2350
+ let inputWidth: number = (this.componentWrapper.offsetWidth) * parseFloat(width) / 100;
2351
+ width = inputWidth.toString() + 'px';
2352
+ }
2353
+ return width;
2354
+ }
2355
+ private mouseIn(): void {
2356
+ if (this.enabled && !this.readonly) {
2357
+ this.showOverAllClear();
2358
+ }
2359
+ }
2360
+ private mouseOut(): void {
2361
+ if (!this.inputFocus) {
2362
+ this.overAllClear.style.display = 'none';
2363
+ }
2364
+ }
2365
+
2366
+ protected listOption(dataSource: { [key: string]: Object }[], fields: FieldSettingsModel): FieldSettingsModel {
2367
+ let iconCss: boolean = isNullOrUndefined(fields.iconCss) ? false : true;
2368
+ let fieldProperty: Object = isNullOrUndefined((fields as FieldSettingsModel & { properties: Object }).properties) ? fields :
2369
+ (fields as FieldSettingsModel & { properties: Object }).properties;
2370
+ this.listCurrentOptions = (fields.text !== null || fields.value !== null) ? {
2371
+ fields: fieldProperty, showIcon: iconCss, ariaAttributes: { groupItemRole: 'presentation' }
2372
+ } : { fields: { value: 'text' } as Object };
2373
+ extend(this.listCurrentOptions, this.listCurrentOptions, fields, true);
2374
+ if (this.mode === 'CheckBox') {
2375
+ this.notify('listoption', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', dataSource, fieldProperty });
2376
+ }
2377
+ return this.listCurrentOptions;
2378
+ }
2379
+
2380
+ private renderPopup(): void {
2381
+ if (!this.list) { super.render(); }
2382
+ if (!this.popupObj) {
2383
+ let args: BeforeOpenEventArgs = { cancel: false };
2384
+ this.trigger('beforeOpen', args, (args: BeforeOpenEventArgs) => {
2385
+ if (!args.cancel) {
2386
+ document.body.appendChild(this.popupWrapper);
2387
+ let checkboxFilter: HTMLElement = this.popupWrapper.querySelector('.' + FILTERPARENT);
2388
+ if (this.mode === 'CheckBox' && !this.allowFiltering && checkboxFilter && this.filterParent) {
2389
+ checkboxFilter.remove();
2390
+ this.filterParent = null;
2391
+ }
2392
+ let overAllHeight: number = parseInt(<string>this.popupHeight, 10);
2393
+ this.popupWrapper.style.visibility = 'hidden';
2394
+ if (this.headerTemplate) {
2395
+ this.setHeaderTemplate();
2396
+ overAllHeight -= this.header.offsetHeight;
2397
+ }
2398
+ append([this.list], this.popupWrapper);
2399
+ if (this.footerTemplate) {
2400
+ this.setFooterTemplate();
2401
+ overAllHeight -= this.footer.offsetHeight;
2402
+ }
2403
+ if (this.mode === 'CheckBox' && this.showSelectAll) {
2404
+ this.notify('selectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
2405
+ overAllHeight -= this.selectAllHeight;
2406
+ } else if (this.mode === 'CheckBox' && !this.showSelectAll && (!this.headerTemplate || !this.footerTemplate)) {
2407
+ this.notify('selectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
2408
+ overAllHeight = parseInt(<string>this.popupHeight, 10);
2409
+ } else if (this.mode === 'CheckBox' && !this.showSelectAll) {
2410
+ this.notify('selectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
2411
+ overAllHeight = parseInt(<string>this.popupHeight, 10);
2412
+ if (this.headerTemplate && this.header) { overAllHeight -= this.header.offsetHeight; }
2413
+ if (this.footerTemplate && this.footer) { overAllHeight -= this.footer.offsetHeight; }
2414
+ }
2415
+ if (this.mode === 'CheckBox') {
2416
+ let args: { [key: string]: Object | string } = {
2417
+ module: 'CheckBoxSelection',
2418
+ enable: this.mode === 'CheckBox',
2419
+ popupElement: this.popupWrapper
2420
+ };
2421
+ if (this.allowFiltering) {
2422
+ this.notify('searchBox', args);
2423
+ overAllHeight -= this.searchBoxHeight;
2424
+ }
2425
+ addClass([this.popupWrapper], 'e-checkbox');
2426
+ }
2427
+ if (this.popupHeight !== 'auto') {
2428
+ this.list.style.maxHeight = formatUnit(overAllHeight);
2429
+ this.popupWrapper.style.maxHeight = formatUnit(this.popupHeight);
2430
+ } else { this.list.style.maxHeight = formatUnit(this.popupHeight); }
2431
+ this.popupObj = new Popup(this.popupWrapper, {
2432
+ width: this.calcPopupWidth(), targetType: 'relative', position: { X: 'left', Y: 'bottom' },
2433
+ relateTo: this.overAllWrapper, collision: { X: 'flip', Y: 'flip' }, offsetY: 1,
2434
+ enableRtl: this.enableRtl, zIndex: this.zIndex,
2435
+ close: () => {
2436
+ if (this.popupObj.element.parentElement) {
2437
+ this.popupObj.unwireScrollEvents();
2438
+ detach(this.popupObj.element);
2439
+ }
2440
+ },
2441
+ open: () => {
2442
+ if (!this.isFirstClick) {
2443
+ let ulElement: HTMLElement = this.list.querySelector('ul');
2444
+ if (ulElement) {
2445
+ if (this.itemTemplate && (isBlazor() && this.isServerRendered)) {
2446
+ setTimeout((): void => { this.mainList = this.ulElement; }, 0);
2447
+ } else if (!(this.mode !== 'CheckBox' && (this.allowFiltering || this.allowCustomValue) &&
2448
+ this.targetElement().trim() !== '')) {
2449
+ this.mainList = ulElement.cloneNode ? (ulElement.cloneNode(true) as HTMLElement) : ulElement;
2450
+ }
2451
+ }
2452
+ this.isFirstClick = true;
2453
+ }
2454
+ this.popupObj.wireScrollEvents();
2455
+ if (!(this.mode !== 'CheckBox' && (this.allowFiltering || this.allowCustomValue) &&
2456
+ this.targetElement().trim() !== '')) {
2457
+ this.loadTemplate();
2458
+ }
2459
+ this.setScrollPosition();
2460
+ if (this.allowFiltering) {
2461
+ this.notify(
2462
+ 'inputFocus',
2463
+ {
2464
+ module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'focus'
2465
+ });
2466
+ }
2467
+ }, targetExitViewport: () => {
2468
+ if (!Browser.isDevice) { this.hidePopup(); }
2469
+ }
2470
+ });
2471
+ if (this.mode === 'CheckBox' && Browser.isDevice && this.allowFiltering) {
2472
+ this.notify('deviceSearchBox', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
2473
+ }
2474
+ this.popupObj.close();
2475
+ this.popupWrapper.style.visibility = '';
2476
+ }
2477
+ });
2478
+ }
2479
+ }
2480
+ private setHeaderTemplate(): void {
2481
+ let compiledString: Function;
2482
+ if (this.header) {
2483
+ this.header.remove();
2484
+ }
2485
+ this.header = this.createElement('div');
2486
+ addClass([this.header], HEADER);
2487
+ let headercheck: boolean = this.multiCompiler(this.headerTemplate);
2488
+ if (headercheck) {
2489
+ compiledString = compile(document.querySelector(this.headerTemplate).innerHTML.trim());
2490
+ } else {
2491
+ compiledString = compile(this.headerTemplate);
2492
+ }
2493
+ let elements: [Element] = compiledString({}, null, null, this.headerTemplateId, this.isStringTemplate);
2494
+ for (let temp: number = 0; temp < elements.length; temp++) {
2495
+ this.header.appendChild(elements[temp]);
2496
+ }
2497
+ this.DropDownBaseupdateBlazorTemplates(false, false, false, false, false, true, false);
2498
+ if (this.mode === 'CheckBox' && this.showSelectAll) {
2499
+ prepend([this.header], this.popupWrapper);
2500
+ } else {
2501
+ append([this.header], this.popupWrapper);
2502
+ }
2503
+ EventHandler.add(this.header, 'mousedown', this.onListMouseDown, this);
2504
+ }
2505
+ private setFooterTemplate(): void {
2506
+ let compiledString: Function;
2507
+ if (this.footer) {
2508
+ this.footer.remove();
2509
+ }
2510
+ this.footer = this.createElement('div');
2511
+ addClass([this.footer], FOOTER);
2512
+ let footercheck: boolean = this.multiCompiler(this.footerTemplate);
2513
+ if (footercheck) {
2514
+ compiledString = compile(document.querySelector(this.footerTemplate).innerHTML.trim());
2515
+ } else {
2516
+ compiledString = compile(this.footerTemplate);
2517
+ }
2518
+ let elements: [Element] = compiledString({}, null, null, this.footerTemplateId, this.isStringTemplate);
2519
+ for (let temp: number = 0; temp < elements.length; temp++) {
2520
+ this.footer.appendChild(elements[temp]);
2521
+ }
2522
+ this.DropDownBaseupdateBlazorTemplates(false, false, false, false, false, false, true);
2523
+ append([this.footer], this.popupWrapper);
2524
+ EventHandler.add(this.footer, 'mousedown', this.onListMouseDown, this);
2525
+ }
2526
+ private ClearAll(e: MouseEvent): void {
2527
+ if (this.enabled && !this.readonly) {
2528
+ let temp: string | number | boolean;
2529
+ if (this.value && this.value.length > 0) {
2530
+ let liElement: NodeListOf<Element> = this.list && this.list.querySelectorAll('li.e-list-item');
2531
+ if (liElement && liElement.length > 0) {
2532
+ this.selectAllItems(false, e);
2533
+ } else {
2534
+ this.removeIndex = 0;
2535
+ for (temp = this.value[this.removeIndex]; this.removeIndex < this.value.length; temp = this.value[this.removeIndex]) {
2536
+ this.removeValue(temp, e, null, true);
2537
+ }
2538
+ }
2539
+ } else {
2540
+ this.clearAllCallback(e);
2541
+ }
2542
+ }
2543
+ }
2544
+ private clearAllCallback(e: MouseEvent, isClearAll?: boolean): void {
2545
+ let tempValues: string[] | number[] = this.value ? <string[]>this.value.slice() : <string[]>[];
2546
+ if (this.mainList && this.listData && ((this.allowFiltering && this.mode !== 'CheckBox') || this.allowCustomValue)) {
2547
+ let list: HTMLElement = this.mainList.cloneNode ? <HTMLElement>this.mainList.cloneNode(true) : this.mainList;
2548
+ this.onActionComplete(list, this.mainData);
2549
+ }
2550
+ this.focusAtFirstListItem();
2551
+ this.updateDelimeter(this.delimiterChar, e);
2552
+ if (this.mode !== 'Box' && (!this.inputFocus || this.mode === 'CheckBox')) {
2553
+ this.updateDelimView();
2554
+ }
2555
+ this.makeTextBoxEmpty();
2556
+ this.checkPlaceholderSize();
2557
+ if (this.isPopupOpen()) {
2558
+ this.refreshPopup();
2559
+ }
2560
+ if (!this.inputFocus) {
2561
+ if (this.changeOnBlur) { this.updateValueState(e, this.value, tempValues); }
2562
+ if (this.mode !== 'CheckBox') {
2563
+ this.inputElement.focus();
2564
+ }
2565
+ }
2566
+ if (this.mode === 'CheckBox') {
2567
+ this.refreshPlaceHolder();
2568
+ this.refreshInputHight();
2569
+ if (this.changeOnBlur && isClearAll && (isNullOrUndefined(this.value) || this.value.length === 0)) {
2570
+ this.updateValueState(e, this.value, this.tempValues);
2571
+ }
2572
+ }
2573
+ if (!this.changeOnBlur && isClearAll && (isNullOrUndefined(this.value) || this.value.length === 0)) {
2574
+ this.updateValueState(e, this.value, this.tempValues);
2575
+ }
2576
+ if (this.mode === 'CheckBox' && this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
2577
+ this.updateListItems(this.list.querySelectorAll('li.e-list-item'), this.mainList.querySelectorAll('li.e-list-item'));
2578
+ }
2579
+ e.preventDefault();
2580
+ }
2581
+ private windowResize(): void {
2582
+ this.refreshPopup();
2583
+ if ((!this.inputFocus || this.mode === 'CheckBox') && this.viewWrapper && this.viewWrapper.parentElement) {
2584
+ this.updateDelimView();
2585
+ }
2586
+ }
2587
+ private resetValueHandler(e: Event): void {
2588
+ let formElement: HTMLFormElement = closest(this.inputElement, 'form') as HTMLFormElement;
2589
+ if (formElement && e.target === formElement) {
2590
+ let textVal: string = (this.element.tagName === this.getNgDirective()) ? null : this.element.getAttribute('data-initial-value');
2591
+ this.text = textVal;
2592
+ }
2593
+ }
2594
+ protected wireEvent(): void {
2595
+ EventHandler.add(this.componentWrapper, 'mousedown', this.wrapperClick, this);
2596
+ EventHandler.add(<HTMLElement & Window>window, 'resize', this.windowResize, this);
2597
+ EventHandler.add(this.inputElement, 'focus', this.focusInHandler, this);
2598
+ EventHandler.add(this.inputElement, 'keydown', this.onKeyDown, this);
2599
+ EventHandler.add(this.inputElement, 'keyup', this.KeyUp, this);
2600
+ if (this.mode !== 'CheckBox') { EventHandler.add(this.inputElement, 'input', this.onInput, this); }
2601
+ EventHandler.add(this.inputElement, 'blur', this.onBlur, this);
2602
+ EventHandler.add(this.componentWrapper, 'mousemove', this.mouseIn, this);
2603
+ let formElement: HTMLFormElement = closest(this.inputElement, 'form') as HTMLFormElement;
2604
+ if (formElement) {
2605
+ EventHandler.add(formElement, 'reset', this.resetValueHandler, this);
2606
+ }
2607
+ EventHandler.add(this.componentWrapper, 'mouseout', this.mouseOut, this);
2608
+ EventHandler.add(this.overAllClear, 'mouseup', this.ClearAll, this);
2609
+ EventHandler.add(this.inputElement, 'paste', this.pasteHandler, this);
2610
+ }
2611
+ private onInput(e: KeyboardEventArgs): void {
2612
+ if (this.keyDownStatus) {
2613
+ this.isValidKey = true;
2614
+ } else {
2615
+ this.isValidKey = false;
2616
+ }
2617
+ this.keyDownStatus = false;
2618
+ // For Filtering works in mobile firefox
2619
+ if (Browser.isDevice && Browser.info.name === 'mozilla') {
2620
+ this.search(e);
2621
+ }
2622
+ }
2623
+ private pasteHandler (event: KeyboardEventArgs): void {
2624
+ setTimeout((): void => {
2625
+ this.search(event);
2626
+ });
2627
+ }
2628
+ private search(e: KeyboardEventArgs): void {
2629
+ if (!this.isPopupOpen() && this.openOnClick) {
2630
+ this.showPopup();
2631
+ }
2632
+ this.openClick(e);
2633
+ if (this.checkTextLength() && !this.allowFiltering && (e.keyCode !== 8)) {
2634
+ this.focusAtFirstListItem();
2635
+ } else {
2636
+ let text: string = this.targetElement();
2637
+ this.keyCode = e.keyCode;
2638
+ if (this.allowFiltering) {
2639
+ let eventArgs: { [key: string]: Object } = {
2640
+ preventDefaultAction: false,
2641
+ text: this.targetElement(),
2642
+ updateData: (
2643
+ dataSource: {
2644
+ [key: string]: Object
2645
+ }[] | DataManager | string[] | number[], query?: Query, fields?: FieldSettingsModel) => {
2646
+ if (eventArgs.cancel) { return; }
2647
+ this.isFiltered = true;
2648
+ this.remoteFilterAction = true;
2649
+ this.dataUpdater(dataSource, query, fields);
2650
+ },
2651
+ event: e,
2652
+ cancel: false
2653
+ };
2654
+ this.trigger('filtering', eventArgs, (eventArgs: FilteringEventArgs) => {
2655
+ if (!eventArgs.cancel) {
2656
+ if (!this.isFiltered && !eventArgs.preventDefaultAction) {
2657
+ this.filterAction = true;
2658
+ this.dataUpdater(this.dataSource, null, this.fields);
2659
+ }
2660
+ }
2661
+ });
2662
+ } else if (this.allowCustomValue) {
2663
+ let query: Query = new Query();
2664
+ query = (text !== '') ? query.where(
2665
+ this.fields.text, 'startswith', text, this.ignoreCase, this.ignoreAccent) : query;
2666
+ this.dataUpdater(this.mainData, query, this.fields);
2667
+ } else {
2668
+ let liCollections: HTMLElement[];
2669
+ liCollections = <HTMLElement[] & NodeListOf<Element>>
2670
+ this.list.querySelectorAll('li.' + dropDownBaseClasses.li + ':not(.e-hide-listitem)');
2671
+ let activeElement: { [key: string]: Element | number } =
2672
+ Search(this.targetElement(), liCollections, 'StartsWith', this.ignoreCase);
2673
+
2674
+ if (activeElement && activeElement.item !== null) {
2675
+ this.addListFocus((<HTMLElement>activeElement.item));
2676
+ this.list.scrollTop =
2677
+ (<HTMLElement>activeElement.item).offsetHeight * (<number>activeElement.index);
2678
+ } else if (this.targetElement() !== '') {
2679
+ this.removeFocus();
2680
+ } else {
2681
+ this.focusAtFirstListItem();
2682
+ }
2683
+ }
2684
+ }
2685
+ }
2686
+
2687
+ protected preRender(): void {
2688
+ if (this.allowFiltering === null) {
2689
+ this.allowFiltering = (this.mode === 'CheckBox') ? true : false;
2690
+ }
2691
+ this.initializeData();
2692
+ this.updateDataAttribute(this.htmlAttributes);
2693
+ super.preRender();
2694
+ }
2695
+ protected getLocaleName(): string {
2696
+ return 'multi-select';
2697
+ };
2698
+ private initializeData(): void {
2699
+ this.mainListCollection = [];
2700
+ this.beforePopupOpen = false;
2701
+ this.filterAction = false;
2702
+ this.remoteFilterAction = false;
2703
+ this.isFirstClick = false;
2704
+ this.mobFilter = true;
2705
+ this.isFiltered = false;
2706
+ this.focused = true;
2707
+ this.initial = true;
2708
+ this.backCommand = true;
2709
+ }
2710
+
2711
+ private updateData(delimiterChar: string, e?: MouseEvent | KeyboardEventArgs): void {
2712
+ let data: string = '';
2713
+ let delim: boolean = this.mode === 'Delimiter' || this.mode === 'CheckBox';
2714
+ let text: string[] = <string[]>[];
2715
+ let temp: string;
2716
+ let tempData: Object = this.listData;
2717
+ this.listData = this.mainData;
2718
+ this.hiddenElement.innerHTML = '';
2719
+ if (!isNullOrUndefined(this.value)) {
2720
+ for (let index: number = 0; !isNullOrUndefined(this.value[index]); index++) {
2721
+ if (this.listData) {
2722
+ temp = this.getTextByValue(this.value[index]);
2723
+ } else {
2724
+ temp = <string>this.value[index];
2725
+ }
2726
+ data += temp + delimiterChar + ' ';
2727
+ text.push(temp);
2728
+ this.hiddenElement.innerHTML += '<option selected value ="' + this.value[index] + '">' + index + '</option>';
2729
+ }
2730
+ }
2731
+ this.setProperties({ text: text.toString() }, true);
2732
+ if (delim) {
2733
+ this.delimiterWrapper.innerHTML = data;
2734
+ this.delimiterWrapper.setAttribute('id', getUniqueID('delim_val'));
2735
+ this.inputElement.setAttribute('aria-describedby', this.delimiterWrapper.id);
2736
+ }
2737
+ let targetEle: HTMLElement = e && e.target as HTMLElement;
2738
+ let isClearAll: boolean = (targetEle && targetEle.classList.contains('e-close-hooker')) ? true : null;
2739
+ if (!this.changeOnBlur && ((e && !isClearAll)) || this.isSelectAll) {
2740
+ this.isSelectAll = false;
2741
+ this.updateValueState(e, this.value, this.tempValues);
2742
+ }
2743
+ this.listData = <{ [key: string]: Object }[]>tempData;
2744
+ this.addValidInputClass();
2745
+ }
2746
+ private initialTextUpdate(): void {
2747
+ if (!isNullOrUndefined(this.text)) {
2748
+ let textArr: string[] = this.text.split(this.delimiterChar);
2749
+ let textVal: string[] | number[] | boolean[] = [];
2750
+ for (let index: number = 0; textArr.length > index; index++) {
2751
+ let val: string | boolean | number = this.getValueByText(textArr[index]);
2752
+ if (!isNullOrUndefined(val)) {
2753
+ (<string[]>textVal).push(val as string);
2754
+ } else if ( this.allowCustomValue ) {
2755
+ (<string[]>textVal).push(textArr[index] as string);
2756
+ }
2757
+ }
2758
+ if (textVal && textVal.length) {
2759
+ this.setProperties({ value: textVal }, true);
2760
+ }
2761
+ } else {
2762
+ this.setProperties({ value: null }, true);
2763
+ }
2764
+ }
2765
+ protected renderList(isEmptyData?: boolean): void {
2766
+ if (!isEmptyData && this.allowCustomValue && this.list && (this.list.textContent === this.noRecordsTemplate
2767
+ || this.list.querySelector('.e-ul') && this.list.querySelector('.e-ul').childElementCount === 0)) {
2768
+ isEmptyData = true;
2769
+ }
2770
+ super.render(isEmptyData);
2771
+ this.unwireListEvents();
2772
+ this.wireListEvents();
2773
+ }
2774
+ private initialValueUpdate(): void {
2775
+ if (this.list) {
2776
+ let text: string;
2777
+ let textField: string;
2778
+ let valueField: string | number;
2779
+ let element: HTMLElement;
2780
+ let value: string | number | boolean;
2781
+ if (this.chipCollectionWrapper) {
2782
+ this.chipCollectionWrapper.innerHTML = '';
2783
+ }
2784
+ this.removeListSelection();
2785
+ if (!isNullOrUndefined(this.value)) {
2786
+ for (let index: number = 0; !isNullOrUndefined(this.value[index]); index++) {
2787
+ value = this.value[index];
2788
+ element = this.findListElement( this.hideSelectedItem ? this.ulElement : this.list, 'li', 'data-value', value);
2789
+ text = this.getTextByValue(value);
2790
+ if ((element && (element.getAttribute('aria-selected') !== 'true')) ||
2791
+ (element && (element.getAttribute('aria-selected') === 'true' && this.hideSelectedItem) &&
2792
+ (this.mode === 'Box' || this.mode === 'Default'))) {
2793
+ this.addChip(text, value);
2794
+ this.addListSelection(element);
2795
+ } else if (value && this.allowCustomValue) {
2796
+ let indexItem: number = this.listData.length;
2797
+ let newValue: { [key: string]: string | Object } = {};
2798
+ setValue(this.fields.text, value, newValue);
2799
+ setValue(this.fields.value, value, newValue);
2800
+ let noDataEle: HTMLElement = this.popupWrapper.querySelector('.' + dropDownBaseClasses.noData);
2801
+ this.addItem(newValue, indexItem);
2802
+ if (this.popupWrapper.contains(noDataEle)) {
2803
+ this.list.setAttribute('style', noDataEle.getAttribute('style'));
2804
+ this.popupWrapper.replaceChild(this.list, noDataEle);
2805
+ this.wireListEvents();
2806
+ }
2807
+ this.addChip(text, value);
2808
+ this.addListSelection(element);
2809
+ }
2810
+ }
2811
+ }
2812
+ if (this.mode === 'CheckBox') {
2813
+ this.updateDelimView();
2814
+ if (this.changeOnBlur) { this.updateValueState(null, this.value, this.tempValues); }
2815
+ this.updateDelimeter(this.delimiterChar);
2816
+ this.refreshInputHight();
2817
+ } else {
2818
+ this.updateDelimeter(this.delimiterChar);
2819
+ }
2820
+ if (this.mode === 'CheckBox' && this.showSelectAll && (isNullOrUndefined(this.value) || !this.value.length)) {
2821
+ this.notify('checkSelectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'uncheck' });
2822
+ }
2823
+ if (this.mode === 'Box') {
2824
+ this.chipCollectionWrapper.style.display = '';
2825
+ } else if (this.mode === 'Delimiter' || this.mode === 'CheckBox') {
2826
+ this.showDelimWrapper();
2827
+ }
2828
+ }
2829
+ }
2830
+ protected updateActionCompleteData(li: HTMLElement, item: { [key: string]: Object }): void {
2831
+ if (this.value && (this.value as string[]).indexOf(li.getAttribute('data-value')) > -1) {
2832
+ this.mainList = this.ulElement;
2833
+ if (this.hideSelectedItem) {
2834
+ addClass([li], HIDE_LIST);
2835
+ }
2836
+ }
2837
+ }
2838
+ protected updateAddItemList(list: HTMLElement, itemCount: number): void {
2839
+ if (this.popupObj && this.popupObj.element && this.popupObj.element.querySelector('.' + dropDownBaseClasses.noData) && list) {
2840
+ this.list = list;
2841
+ this.mainList = this.ulElement = list.querySelector('ul');
2842
+ remove(this.popupWrapper.querySelector('.e-content'));
2843
+ this.popupObj = null;
2844
+ this.renderPopup();
2845
+ }
2846
+ }
2847
+ protected updateDataList(): void {
2848
+ if (this.mainList && this.ulElement && this.mainList.childElementCount < this.ulElement.childElementCount) {
2849
+ this.mainList = this.ulElement.cloneNode ? <HTMLElement>this.ulElement.cloneNode(true) : this.ulElement;
2850
+ }
2851
+ }
2852
+ protected isValidLI(li: Element | HTMLElement): boolean {
2853
+ return (li && !li.classList.contains(dropDownBaseClasses.disabled) && !li.classList.contains(dropDownBaseClasses.group) &&
2854
+ li.classList.contains(dropDownBaseClasses.li));
2855
+ };
2856
+ protected updateListSelection(li: Element, e: MouseEvent | KeyboardEventArgs, length?: number): void {
2857
+ let customVal: string | number | boolean = li.getAttribute('data-value');
2858
+ let value: string | number | boolean = this.getFormattedValue(customVal);
2859
+ if (this.allowCustomValue && (( customVal !== 'false' && value === false ) ||
2860
+ (!isNullOrUndefined(value) && value.toString() === 'NaN'))) {
2861
+ value = customVal;
2862
+ }
2863
+ let text: string = this.getTextByValue(value);
2864
+ this.removeHover();
2865
+ if (!this.value || (this.value as string[]).indexOf(value as string) === -1) {
2866
+ this.dispatchSelect(value, e, <HTMLElement>li, (li.getAttribute('aria-selected') === 'true'), length);
2867
+ } else {
2868
+ this.removeValue(value, e, length);
2869
+ }
2870
+ }
2871
+ private updateListSelectEventCallback(value: string | number | boolean, li: Element, e: MouseEvent | KeyboardEventArgs): void {
2872
+ let text: string = this.getTextByValue(value);
2873
+ if ((this.allowCustomValue || this.allowFiltering) && !this.findListElement(this.mainList, 'li', 'data-value', value)) {
2874
+ let temp: HTMLElement = <HTMLElement>li.cloneNode(true);
2875
+ let data: Object = this.getDataByValue(value);
2876
+ let eventArgs: CustomValueEventArgs = {
2877
+ newData: data,
2878
+ cancel: false
2879
+ };
2880
+ this.trigger('customValueSelection', eventArgs, (eventArgs: CustomValueEventArgs) => {
2881
+ if (!eventArgs.cancel) {
2882
+ append([temp], this.mainList);
2883
+ (this.mainData as { [key: string]: object }[]).push(data as { [key: string]: object });
2884
+ this.remoteCustomValue = false;
2885
+ this.addValue(value, text, e);
2886
+ }
2887
+ });
2888
+ } else {
2889
+ this.remoteCustomValue = false;
2890
+ this.addValue(value, text, e);
2891
+ }
2892
+ if (isBlazor() && this.isServerRendered && this.value && this.list &&
2893
+ this.value.length === this.list.querySelectorAll('li.e-list-item').length ||
2894
+ this.value.length === this.maximumSelectionLength) {
2895
+ this.updatedataValueItems(e);
2896
+ this.checkPlaceholderSize();
2897
+ }
2898
+ if (isBlazor() && this.isServerRendered) {
2899
+ this.checkPlaceholderSize();
2900
+ this.makeTextBoxEmpty();
2901
+ }
2902
+ }
2903
+ protected removeListSelection(): void {
2904
+ let className: string = this.hideSelectedItem ?
2905
+ HIDE_LIST :
2906
+ dropDownBaseClasses.selected;
2907
+ let selectedItems: Element[] = <NodeListOf<Element> & Element[]>this.list.querySelectorAll('.' + className);
2908
+ let temp: number = selectedItems.length;
2909
+ if (selectedItems && selectedItems.length) {
2910
+ removeClass(selectedItems, className);
2911
+ while (temp > 0) {
2912
+ selectedItems[temp - 1].setAttribute('aria-selected', 'false');
2913
+ temp--;
2914
+ }
2915
+ }
2916
+ if (!isNullOrUndefined(this.mainList)) {
2917
+ let selectItems: Element[] = <NodeListOf<Element> & Element[]>this.mainList.querySelectorAll('.' + className);
2918
+ let temp1: number = selectItems.length;
2919
+ if (selectItems && selectItems.length) {
2920
+ removeClass(selectItems, className);
2921
+ while (temp1 > 0) {
2922
+ selectItems[temp1 - 1].setAttribute('aria-selected', 'false');
2923
+ if (this.mode === 'CheckBox') {
2924
+ if (selectedItems && (selectedItems.length > (temp1 - 1))) {
2925
+ selectedItems[temp1 - 1].firstElementChild.setAttribute('aria-checked', 'false');
2926
+ removeClass([selectedItems[temp1 - 1].firstElementChild.lastElementChild], 'e-check');
2927
+ }
2928
+ selectItems[temp1 - 1].firstElementChild.setAttribute('aria-checked', 'false');
2929
+ removeClass([selectItems[temp1 - 1].firstElementChild.lastElementChild], 'e-check');
2930
+ }
2931
+ temp1--;
2932
+ }
2933
+ }
2934
+ }
2935
+ };
2936
+ private removeHover(): void {
2937
+ let hoveredItem: Element[] = <NodeListOf<Element> & Element[]>this.list.querySelectorAll('.' + dropDownBaseClasses.hover);
2938
+ if (hoveredItem && hoveredItem.length) {
2939
+ removeClass(hoveredItem, dropDownBaseClasses.hover);
2940
+ }
2941
+ };
2942
+ private removeFocus(): void {
2943
+ if (this.list && this.mainList) {
2944
+ let hoveredItem: Element[] = <NodeListOf<Element> & Element[]>this.list.querySelectorAll('.' + dropDownBaseClasses.focus);
2945
+ let mainlist: Element[] = <NodeListOf<Element> & Element[]>this.mainList.querySelectorAll('.' + dropDownBaseClasses.focus);
2946
+ if (hoveredItem && hoveredItem.length) {
2947
+ removeClass(hoveredItem, dropDownBaseClasses.focus);
2948
+ removeClass(mainlist, dropDownBaseClasses.focus);
2949
+ }
2950
+ }
2951
+ };
2952
+ private addListHover(li: HTMLElement): void {
2953
+ if (this.enabled && this.isValidLI(li)) {
2954
+ this.removeHover();
2955
+ addClass([li], dropDownBaseClasses.hover);
2956
+ } else {
2957
+ if ((li !== null && li.classList.contains('e-list-group-item')) && this.enableGroupCheckBox && this.mode === 'CheckBox'
2958
+ && !isNullOrUndefined(this.fields.groupBy)) {
2959
+ this.removeHover();
2960
+ addClass([li], dropDownBaseClasses.hover);
2961
+ }
2962
+ }
2963
+ };
2964
+ private addListFocus(element: HTMLElement): void {
2965
+ if (this.enabled && this.isValidLI(element)) {
2966
+ this.removeFocus();
2967
+ addClass([element], dropDownBaseClasses.focus);
2968
+ } else {
2969
+ if (this.enableGroupCheckBox && this.mode === 'CheckBox' && !isNullOrUndefined(this.fields.groupBy)) {
2970
+ addClass([element], dropDownBaseClasses.focus);
2971
+ }
2972
+ }
2973
+ }
2974
+ private addListSelection(element: HTMLElement): void {
2975
+ let className: string = this.hideSelectedItem ?
2976
+ HIDE_LIST :
2977
+ dropDownBaseClasses.selected;
2978
+ if (this.isValidLI(element) && !element.classList.contains(dropDownBaseClasses.hover)) {
2979
+ addClass([element], className);
2980
+ this.updateMainList(false, <string>element.getAttribute('data-value'));
2981
+ element.setAttribute('aria-selected', 'true');
2982
+ if (this.mode === 'CheckBox') {
2983
+ let ariaCheck: string | null = element.firstElementChild.getAttribute('aria-checked');
2984
+ if (ariaCheck === 'false' || isNullOrUndefined(ariaCheck)) {
2985
+ this.notify('updatelist', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', li: element, e: this });
2986
+ }
2987
+ }
2988
+ this.notify('activeList', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', li: element, e: this });
2989
+ if (this.chipCollectionWrapper !== null) {
2990
+ this.removeChipSelection();
2991
+ }
2992
+ attributes(this.inputElement, { 'aria-activedescendant': element.id });
2993
+ }
2994
+ }
2995
+ private updateDelimeter(delimChar: string, e?: MouseEvent | KeyboardEventArgs): void {
2996
+ this.updateData(delimChar, e);
2997
+ }
2998
+ private onMouseClick(e: MouseEvent): void {
2999
+ this.scrollFocusStatus = false;
3000
+ let target: Element = <Element>e.target;
3001
+ let li: HTMLElement = <HTMLElement>closest(target, '.' + dropDownBaseClasses.li);
3002
+ let headerLi : HTMLElement = <HTMLElement>closest(target, '.' + dropDownBaseClasses.group);
3003
+ if (headerLi && this.enableGroupCheckBox && this.mode === 'CheckBox' && this.fields.groupBy) {
3004
+ target = target.classList.contains('e-list-group-item') ? target.firstElementChild.lastElementChild
3005
+ : <Element>e.target;
3006
+ if (target.classList.contains('e-check')) {
3007
+ this.selectAllItem(false, e);
3008
+ target.classList.remove('e-check');
3009
+ target.classList.remove('e-stop');
3010
+ closest(target, '.' + 'e-list-group-item').classList.remove('e-active');
3011
+ target.setAttribute('aria-selected', 'false');
3012
+ } else {
3013
+ this.selectAllItem(true, e);
3014
+ target.classList.remove('e-stop');
3015
+ target.classList.add('e-check');
3016
+ closest(target, '.' + 'e-list-group-item').classList.add('e-active');
3017
+ target.setAttribute('aria-selected', 'true');
3018
+ }
3019
+ this.refreshSelection();
3020
+ this.checkSelectAll();
3021
+ } else {
3022
+ if (this.isValidLI(li)) {
3023
+ let limit: number = this.value && this.value.length ? this.value.length : 0;
3024
+ if (li.classList.contains('e-active')) {
3025
+ limit = limit - 1;
3026
+ }
3027
+ if (limit < this.maximumSelectionLength) {
3028
+ this.updateListSelection(li, e);
3029
+ this.checkPlaceholderSize();
3030
+ this.addListFocus(<HTMLElement>li);
3031
+ if ((this.allowCustomValue || this.allowFiltering) && this.mainList && this.listData) {
3032
+ if (this.mode !== 'CheckBox') {
3033
+ this.focusAtLastListItem(<string>li.getAttribute('data-value'));
3034
+ }
3035
+ this.refreshSelection();
3036
+ } else {
3037
+ this.makeTextBoxEmpty();
3038
+ }
3039
+ }
3040
+ if (this.mode === 'CheckBox') {
3041
+ this.updateDelimView();
3042
+ this.updateDelimeter(this.delimiterChar, e);
3043
+ this.refreshInputHight();
3044
+ } else {
3045
+ this.updateDelimeter(this.delimiterChar, e);
3046
+ }
3047
+ this.checkSelectAll();
3048
+ this.refreshPopup();
3049
+ if (this.hideSelectedItem) {
3050
+ this.focusAtFirstListItem();
3051
+ }
3052
+ if (this.closePopupOnSelect) {
3053
+ this.hidePopup();
3054
+ } else {
3055
+ e.preventDefault();
3056
+ }
3057
+ this.makeTextBoxEmpty();
3058
+ this.findGroupStart(target as HTMLElement);
3059
+ } else {
3060
+ e.preventDefault();
3061
+ }
3062
+ if (this.mode !== 'CheckBox') {
3063
+ this.refreshListItems(isNullOrUndefined(li) ? null : li.textContent);
3064
+ }
3065
+ this.refreshPlaceHolder();
3066
+ this.deselectHeader();
3067
+ }
3068
+ }
3069
+ private findGroupStart(target: HTMLElement): void {
3070
+ if (this.enableGroupCheckBox && this.mode === 'CheckBox' && !isNullOrUndefined(this.fields.groupBy)) {
3071
+ let count: number = 0;
3072
+ let liChecked : number = 0;
3073
+ let liUnchecked : number = 0;
3074
+ let groupValues: number[];
3075
+ if (this.itemTemplate && !target.getElementsByClassName('e-frame').length) {
3076
+ while (!target.getElementsByClassName('e-frame').length) {
3077
+ target = target.parentElement;
3078
+ }
3079
+ }
3080
+ if (target.classList.contains('e-frame')) {
3081
+ target = target.parentElement.parentElement;
3082
+ }
3083
+ groupValues = this.findGroupAttrtibutes(target, liChecked, liUnchecked, count, 0);
3084
+ groupValues = this.findGroupAttrtibutes(target, groupValues[0], groupValues[1], groupValues[2], 1);
3085
+ while (!target.classList.contains('e-list-group-item')) {
3086
+ if (target.classList.contains('e-list-icon')) {
3087
+ target = target.parentElement;
3088
+ }
3089
+ (target as Element) = target.previousElementSibling;
3090
+ if (target == null) {
3091
+ break;
3092
+ }
3093
+ }
3094
+ this.updateCheckBox(target, groupValues[0], groupValues[1], groupValues[2]);
3095
+ }
3096
+ }
3097
+
3098
+ private findGroupAttrtibutes(listElement: Element, checked: number, unChecked: number, count: number, position: number): number[] {
3099
+ while (!listElement.classList.contains('e-list-group-item')) {
3100
+ if (listElement.classList.contains('e-list-icon')) {
3101
+ listElement = listElement.parentElement;
3102
+ }
3103
+ if (listElement.getElementsByClassName('e-frame')[0].classList.contains('e-check') &&
3104
+ listElement.classList.contains('e-list-item')) {
3105
+ checked++;
3106
+ } else if (listElement.classList.contains('e-list-item')) {
3107
+ unChecked++;
3108
+ }
3109
+ count++;
3110
+ (listElement as Element) = position ? listElement.nextElementSibling : listElement.previousElementSibling;
3111
+ if (listElement == null) {
3112
+ break;
3113
+ }
3114
+ }
3115
+ return [checked, unChecked, count];
3116
+ }
3117
+ private updateCheckBox(groupHeader: Element, checked: number, unChecked: number, count: number): void {
3118
+ if (groupHeader === null) {
3119
+ return;
3120
+ }
3121
+ let checkBoxElement : Element = groupHeader.getElementsByClassName('e-frame')[0];
3122
+ if (count === checked) {
3123
+ checkBoxElement.classList.remove('e-stop');
3124
+ checkBoxElement.classList.add('e-check');
3125
+ closest(checkBoxElement, '.' + 'e-list-group-item').classList.add('e-active');
3126
+ groupHeader.setAttribute('aria-selected', 'true');
3127
+ } else if (count === unChecked) {
3128
+ checkBoxElement.classList.remove('e-check');
3129
+ checkBoxElement.classList.remove('e-stop');
3130
+ closest(checkBoxElement, '.' + 'e-list-group-item').classList.remove('e-active');
3131
+ groupHeader.setAttribute('aria-selected', 'false');
3132
+ } else if (this.maximumSelectionLength === checked - 1) {
3133
+ checkBoxElement.classList.remove('e-stop');
3134
+ groupHeader.setAttribute('aria-selected', 'true');
3135
+ closest(checkBoxElement, '.' + 'e-list-group-item').classList.add('e-active');
3136
+ checkBoxElement.classList.add('e-check');
3137
+ } else {
3138
+ checkBoxElement.classList.remove('e-check');
3139
+ checkBoxElement.classList.add('e-stop');
3140
+ closest(checkBoxElement, '.' + 'e-list-group-item').classList.add('e-active');
3141
+ groupHeader.setAttribute('aria-selected', 'false');
3142
+ }
3143
+ }
3144
+ private deselectHeader (): void {
3145
+ let limit: number = this.value && this.value.length ? this.value.length : 0;
3146
+ let collection: NodeList = this.list.querySelectorAll('li.e-list-group-item:not(.e-active)');
3147
+ if (limit < this.maximumSelectionLength) {
3148
+ removeClass(collection, 'e-disable');
3149
+ }
3150
+ if (limit === this.maximumSelectionLength) {
3151
+ addClass(collection, 'e-disable');
3152
+ }
3153
+ }
3154
+ private onMouseOver(e: MouseEvent): void {
3155
+ let currentLi: HTMLElement = <HTMLElement>closest(<Element>e.target, '.' + dropDownBaseClasses.li);
3156
+ if (currentLi === null && this.mode === 'CheckBox' && !isNullOrUndefined(this.fields.groupBy)
3157
+ && this.enableGroupCheckBox) {
3158
+ currentLi = <HTMLElement>closest(<Element>e.target, '.' + dropDownBaseClasses.group);
3159
+ }
3160
+ this.addListHover(currentLi);
3161
+ }
3162
+ private onMouseLeave(e: MouseEvent): void {
3163
+ this.removeHover();
3164
+ }
3165
+ private onListMouseDown(e: MouseEvent): void {
3166
+ e.preventDefault();
3167
+ this.scrollFocusStatus = true;
3168
+ }
3169
+ private onDocumentClick(e: MouseEvent): void {
3170
+ if (this.mode !== 'CheckBox') {
3171
+ let target: HTMLElement = <HTMLElement>e.target;
3172
+ if (!(!isNullOrUndefined(this.popupObj) && closest(target, '#' + this.popupObj.element.id)) &&
3173
+ !this.overAllWrapper.contains(e.target as Node)) {
3174
+ this.scrollFocusStatus = false;
3175
+ } else {
3176
+ this.scrollFocusStatus = (Browser.isIE || Browser.info.name === 'edge') && (document.activeElement === this.inputElement);
3177
+ }
3178
+ }
3179
+ }
3180
+ private wireListEvents(): void {
3181
+ EventHandler.add(document, 'mousedown', this.onDocumentClick, this);
3182
+ EventHandler.add(this.list, 'mousedown', this.onListMouseDown, this);
3183
+ EventHandler.add(this.list, 'mouseup', this.onMouseClick, this);
3184
+ EventHandler.add(this.list, 'mouseover', this.onMouseOver, this);
3185
+ EventHandler.add(this.list, 'mouseout', this.onMouseLeave, this);
3186
+ };
3187
+ private unwireListEvents(): void {
3188
+ EventHandler.remove(document, 'mousedown', this.onDocumentClick);
3189
+ if (this.list) {
3190
+ EventHandler.remove(this.list, 'mousedown', this.onListMouseDown);
3191
+ EventHandler.remove(this.list, 'mouseup', this.onMouseClick);
3192
+ EventHandler.remove(this.list, 'mouseover', this.onMouseOver);
3193
+ EventHandler.remove(this.list, 'mouseout', this.onMouseLeave);
3194
+
3195
+ }
3196
+ };
3197
+ private hideOverAllClear(): void {
3198
+ if (!this.value || !this.value.length || this.inputElement.value === '') {
3199
+ this.overAllClear.style.display = 'none';
3200
+ }
3201
+ }
3202
+ private showOverAllClear(): void {
3203
+ if (((this.value && this.value.length) || this.inputElement.value !== '') && this.showClearButton && this.readonly !== true) {
3204
+ this.overAllClear.style.display = '';
3205
+ } else {
3206
+ this.overAllClear.style.display = 'none';
3207
+ }
3208
+ }
3209
+
3210
+ /**
3211
+ * Sets the focus to widget for interaction.
3212
+ * @returns void
3213
+ */
3214
+ public focusIn(): void {
3215
+ if (document.activeElement !== this.inputElement && this.enabled) {
3216
+ this.inputElement.focus();
3217
+ }
3218
+ }
3219
+
3220
+ /**
3221
+ * Remove the focus from widget, if the widget is in focus state.
3222
+ * @returns void
3223
+ */
3224
+ public focusOut(): void {
3225
+ if (document.activeElement === this.inputElement && this.enabled) {
3226
+ this.inputElement.blur();
3227
+ }
3228
+ }
3229
+ /**
3230
+ * Shows the spinner loader.
3231
+ * @returns void.
3232
+ */
3233
+ public showSpinner(): void {
3234
+ if (isNullOrUndefined(this.spinnerElement)) {
3235
+ if (this.overAllClear.style.display !== 'none') {
3236
+ this.spinnerElement = this.overAllClear;
3237
+ } else {
3238
+ this.spinnerElement = this.createElement('span', { className: CLOSEICON_CLASS + ' ' + SPINNER_CLASS });
3239
+ this.componentWrapper.appendChild(this.spinnerElement);
3240
+ }
3241
+ createSpinner({ target: this.spinnerElement, width: Browser.isDevice ? '16px' : '14px' }, this.createElement);
3242
+ addClass([this.spinnerElement], DISABLE_ICON);
3243
+ showSpinner(this.spinnerElement);
3244
+ }
3245
+ }
3246
+ /**
3247
+ * Hides the spinner loader.
3248
+ * @returns void.
3249
+ */
3250
+ public hideSpinner(): void {
3251
+ if (!isNullOrUndefined(this.spinnerElement)) {
3252
+ hideSpinner(this.spinnerElement);
3253
+ removeClass([this.spinnerElement], DISABLE_ICON);
3254
+ if (this.spinnerElement.classList.contains(SPINNER_CLASS)) {
3255
+ detach(this.spinnerElement);
3256
+ } else {
3257
+ this.spinnerElement.innerHTML = '';
3258
+ }
3259
+ this.spinnerElement = null;
3260
+ }
3261
+ }
3262
+ private updateDelimView(): void {
3263
+ if (this.delimiterWrapper) {
3264
+ this.hideDelimWrapper();
3265
+ }
3266
+ if (this.chipCollectionWrapper) {
3267
+ this.chipCollectionWrapper.style.display = 'none';
3268
+ }
3269
+ this.viewWrapper.style.display = '';
3270
+ this.viewWrapper.style.width = '';
3271
+ this.viewWrapper.classList.remove(TOTAL_COUNT_WRAPPER);
3272
+ if (this.value && this.value.length) {
3273
+ let data: string = '';
3274
+ let temp: string;
3275
+ let tempData: string;
3276
+ let tempIndex: number = 1;
3277
+ let wrapperleng: number;
3278
+ let remaining: number;
3279
+ let downIconWidth: number = 0;
3280
+ let overAllContainer: number;
3281
+ this.viewWrapper.innerHTML = '';
3282
+ let l10nLocale: Object = {
3283
+ noRecordsTemplate: 'No records found',
3284
+ actionFailureTemplate: 'Request failed',
3285
+ overflowCountTemplate: '+${count} more..',
3286
+ totalCountTemplate: '${count} selected'
3287
+ };
3288
+ let l10n: L10n = new L10n(this.getLocaleName(), {}, this.locale);
3289
+ if (l10n.getConstant('actionFailureTemplate') === '') {
3290
+ l10n = new L10n('dropdowns', l10nLocale, this.locale);
3291
+ }
3292
+ let remainContent: string = l10n.getConstant('overflowCountTemplate');
3293
+ let raminElement: HTMLElement = this.createElement('span', {
3294
+ className: REMAIN_WRAPPER
3295
+ });
3296
+ let compiledString: Function = compile(remainContent);
3297
+ let totalCompiledString: Function = compile(l10n.getConstant('totalCountTemplate'));
3298
+ raminElement.appendChild(compiledString({ 'count': this.value.length }, null, null, null, !this.isStringTemplate)[0]);
3299
+ this.viewWrapper.appendChild(raminElement);
3300
+ let remainSize: number = raminElement.offsetWidth;
3301
+ remove(raminElement);
3302
+ if (this.showDropDownIcon) {
3303
+ downIconWidth = this.dropIcon.offsetWidth +
3304
+ parseInt(window.getComputedStyle(this.dropIcon).marginRight, 10);
3305
+ }
3306
+ if (!isNullOrUndefined(this.value)) {
3307
+ for (let index: number = 0; !isNullOrUndefined(this.value[index]); index++) {
3308
+ data += (index === 0) ? '' : this.delimiterChar + ' ';
3309
+ temp = this.getOverflowVal(index);
3310
+ data += temp;
3311
+ temp = this.viewWrapper.innerHTML;
3312
+ this.viewWrapper.innerHTML = data;
3313
+ wrapperleng = this.viewWrapper.offsetWidth +
3314
+ parseInt(window.getComputedStyle(this.viewWrapper).paddingRight, 10);
3315
+ overAllContainer = this.componentWrapper.offsetWidth -
3316
+ parseInt(window.getComputedStyle(this.componentWrapper).paddingLeft, 10) -
3317
+ parseInt(window.getComputedStyle(this.componentWrapper).paddingRight, 10);
3318
+ if ((wrapperleng + downIconWidth) > overAllContainer) {
3319
+ if (tempData !== undefined && tempData !== '') {
3320
+ temp = tempData;
3321
+ index = tempIndex + 1;
3322
+ }
3323
+ this.viewWrapper.innerHTML = temp;
3324
+ remaining = this.value.length - index;
3325
+ wrapperleng = this.viewWrapper.offsetWidth;
3326
+ while (((wrapperleng + remainSize + downIconWidth) > overAllContainer) && wrapperleng !== 0
3327
+ && this.viewWrapper.innerHTML !== '') {
3328
+ let textArr: string[] = this.viewWrapper.innerHTML.split(this.delimiterChar);
3329
+ textArr.pop();
3330
+ this.viewWrapper.innerHTML = textArr.join(this.delimiterChar);
3331
+ if (this.viewWrapper.innerHTML === '') {
3332
+ remaining++;
3333
+ }
3334
+ wrapperleng = this.viewWrapper.offsetWidth;
3335
+ }
3336
+ break;
3337
+ } else if ((wrapperleng + remainSize + downIconWidth) <= overAllContainer) {
3338
+ tempData = data;
3339
+ tempIndex = index;
3340
+ } else if (index === 0) {
3341
+ tempData = '';
3342
+ tempIndex = -1;
3343
+ }
3344
+ }
3345
+ }
3346
+ if (remaining > 0) {
3347
+ let totalWidth: number = overAllContainer - downIconWidth;
3348
+ this.viewWrapper.appendChild(
3349
+ this.updateRemainTemplate( raminElement, this.viewWrapper, remaining, compiledString, totalCompiledString, totalWidth)
3350
+ );
3351
+ this.updateRemainWidth(this.viewWrapper, totalWidth);
3352
+ this.updateRemainingText(raminElement, downIconWidth, remaining, compiledString, totalCompiledString);
3353
+ }
3354
+ } else {
3355
+ this.viewWrapper.innerHTML = '';
3356
+ this.viewWrapper.style.display = 'none';
3357
+ }
3358
+ }
3359
+ private updateRemainWidth(viewWrapper: HTMLElement, totalWidth: number): void {
3360
+ if (viewWrapper.classList.contains(TOTAL_COUNT_WRAPPER) && totalWidth < (viewWrapper.offsetWidth +
3361
+ parseInt(window.getComputedStyle(viewWrapper).paddingLeft, 10)
3362
+ + parseInt(window.getComputedStyle(viewWrapper).paddingLeft, 10))) {
3363
+ viewWrapper.style.width = totalWidth + 'px';
3364
+ }
3365
+ }
3366
+ private updateRemainTemplate(
3367
+ raminElement: HTMLElement,
3368
+ viewWrapper: HTMLElement,
3369
+ remaining: number,
3370
+ compiledString: Function,
3371
+ totalCompiledString: Function,
3372
+ totalWidth?: number): HTMLElement {
3373
+ if (viewWrapper.firstChild && viewWrapper.firstChild.nodeType === 3 && viewWrapper.firstChild.nodeValue === '') {
3374
+ viewWrapper.removeChild(viewWrapper.firstChild);
3375
+ }
3376
+ raminElement.innerHTML = '';
3377
+ raminElement.appendChild(
3378
+ (viewWrapper.firstChild && viewWrapper.firstChild.nodeType === 3) ?
3379
+ compiledString({ 'count': remaining }, null, null, null, !this.isStringTemplate)[0] :
3380
+ totalCompiledString({ 'count': remaining }, null, null, null, !this.isStringTemplate)[0]);
3381
+ if (viewWrapper.firstChild && viewWrapper.firstChild.nodeType === 3) {
3382
+ viewWrapper.classList.remove(TOTAL_COUNT_WRAPPER);
3383
+ } else {
3384
+ viewWrapper.classList.add(TOTAL_COUNT_WRAPPER);
3385
+ this.updateRemainWidth(viewWrapper, totalWidth);
3386
+ }
3387
+ return raminElement;
3388
+ }
3389
+ private updateRemainingText(
3390
+ raminElement: HTMLElement,
3391
+ downIconWidth: number,
3392
+ remaining: number,
3393
+ compiledString: Function,
3394
+ totalCompiledString: Function): void {
3395
+ let overAllContainer: number = this.componentWrapper.offsetWidth -
3396
+ parseInt(window.getComputedStyle(this.componentWrapper).paddingLeft, 10) -
3397
+ parseInt(window.getComputedStyle(this.componentWrapper).paddingRight, 10);
3398
+ let wrapperleng: number = this.viewWrapper.offsetWidth + parseInt(window.getComputedStyle(this.viewWrapper).paddingRight, 10);
3399
+ if (((wrapperleng + downIconWidth) >= overAllContainer) && wrapperleng !== 0 && this.viewWrapper.firstChild &&
3400
+ this.viewWrapper.firstChild.nodeType === 3) {
3401
+ while (((wrapperleng + downIconWidth) > overAllContainer) && wrapperleng !== 0 && this.viewWrapper.firstChild &&
3402
+ this.viewWrapper.firstChild.nodeType === 3) {
3403
+ let textArr: string[] = (this.viewWrapper.firstChild as Text).nodeValue.split(this.delimiterChar);
3404
+ textArr.pop();
3405
+ this.viewWrapper.firstChild.nodeValue = textArr.join(this.delimiterChar);
3406
+ if (this.viewWrapper.firstChild.nodeValue === '') {
3407
+ this.viewWrapper.removeChild(this.viewWrapper.firstChild);
3408
+ }
3409
+ remaining++;
3410
+ wrapperleng = this.viewWrapper.offsetWidth;
3411
+ }
3412
+ let totalWidth: number = overAllContainer - downIconWidth;
3413
+ this.updateRemainTemplate( raminElement, this.viewWrapper, remaining, compiledString, totalCompiledString, totalWidth);
3414
+ }
3415
+ }
3416
+ private getOverflowVal(index: number): string {
3417
+ let temp: string;
3418
+ if (this.mainData && this.mainData.length) {
3419
+ if (this.mode === 'CheckBox') {
3420
+ let newTemp: { [key: string]: Object }[] | number[] | boolean[] | string[] = this.listData;
3421
+ this.listData = this.mainData;
3422
+ temp = this.getTextByValue(this.value[index]);
3423
+ this.listData = newTemp;
3424
+ } else {
3425
+ temp = this.getTextByValue(this.value[index]);
3426
+ }
3427
+ } else {
3428
+ temp = <string>this.value[index];
3429
+ }
3430
+ return temp;
3431
+ }
3432
+ private unWireEvent(): void {
3433
+ EventHandler.remove(this.componentWrapper, 'mousedown', this.wrapperClick);
3434
+ EventHandler.remove(<HTMLElement & Window>window, 'resize', this.windowResize);
3435
+ EventHandler.remove(this.inputElement, 'focus', this.focusInHandler);
3436
+ EventHandler.remove(this.inputElement, 'keydown', this.onKeyDown);
3437
+ if (this.mode !== 'CheckBox') { EventHandler.remove(this.inputElement, 'input', this.onInput); }
3438
+ EventHandler.remove(this.inputElement, 'keyup', this.KeyUp);
3439
+ let formElement: HTMLFormElement = closest(this.inputElement, 'form') as HTMLFormElement;
3440
+ if (formElement) {
3441
+ EventHandler.remove(formElement, 'reset', this.resetValueHandler);
3442
+ }
3443
+ EventHandler.remove(this.inputElement, 'blur', this.onBlur);
3444
+ EventHandler.remove(this.componentWrapper, 'mousemove', this.mouseIn);
3445
+ EventHandler.remove(this.componentWrapper, 'mouseout', this.mouseOut);
3446
+ EventHandler.remove(this.overAllClear, 'mousedown', this.ClearAll);
3447
+ EventHandler.remove(this.inputElement, 'paste', this.pasteHandler);
3448
+ }
3449
+ private selectAllItem(state: boolean, event?: MouseEvent | KeyboardEventArgs, list? : HTMLElement): void {
3450
+ let li: HTMLElement[] & NodeListOf<Element>;
3451
+ li = <HTMLElement[] & NodeListOf<Element>>this.list.querySelectorAll(state ?
3452
+ 'li.e-list-item:not([aria-selected="true"]):not(.e-reorder-hide)' :
3453
+ 'li.e-list-item[aria-selected="true"]:not(.e-reorder-hide)');
3454
+ if (this.value && this.value.length && this.isPopupOpen() && event && event.target
3455
+ && closest(event.target as Element, '.e-close-hooker') && this.allowFiltering) {
3456
+ li = <HTMLElement[] & NodeListOf<Element>>this.mainList.querySelectorAll(state ?
3457
+ 'li.e-list-item:not([aria-selected="true"]):not(.e-reorder-hide)' :
3458
+ 'li.e-list-item[aria-selected="true"]:not(.e-reorder-hide)');
3459
+ }
3460
+ if (this.enableGroupCheckBox && this.mode === 'CheckBox' && !isNullOrUndefined(this.fields.groupBy)) {
3461
+ let target: Element = <Element>(event ? event.target : null);
3462
+ target = (event && (event as KeyboardEvent).keyCode === 32) ? list : target;
3463
+ target = (target && target.classList.contains('e-frame')) ? target.parentElement.parentElement : target;
3464
+ if (target && target.classList.contains('e-list-group-item')) {
3465
+ let listElement : Element = target.nextElementSibling;
3466
+ if (isNullOrUndefined(listElement)) {
3467
+ return;
3468
+ }
3469
+ while (listElement.classList.contains('e-list-item')) {
3470
+ if (state) {
3471
+ if (!listElement.firstElementChild.lastElementChild.classList.contains('e-check')) {
3472
+ let selectionLimit: number = this.value && this.value.length ? this.value.length : 0;
3473
+ if (listElement.classList.contains('e-active')) {
3474
+ selectionLimit -= 1;
3475
+ }
3476
+ if (selectionLimit < this.maximumSelectionLength) {
3477
+ this.updateListSelection(listElement, event);
3478
+ }
3479
+ }
3480
+ } else {
3481
+ if (listElement.firstElementChild.lastElementChild.classList.contains('e-check')) {
3482
+ this.updateListSelection(listElement, event);
3483
+ }
3484
+ }
3485
+ listElement = listElement.nextElementSibling;
3486
+ if (listElement == null) {
3487
+ break;
3488
+ }
3489
+ }
3490
+ if (target.classList.contains('e-list-group-item')) {
3491
+ let focusedElement: Element = this.list.getElementsByClassName('e-item-focus')[0];
3492
+ if (focusedElement) {
3493
+ focusedElement.classList.remove('e-item-focus');
3494
+ }
3495
+ state ? target.classList.add('e-active') : target.classList.remove('e-active');
3496
+ target.classList.add('e-item-focus');
3497
+ }
3498
+ this.textboxValueUpdate();
3499
+ this.checkPlaceholderSize();
3500
+ if (!this.changeOnBlur && event) {
3501
+ this.updateValueState(event, this.value, this.tempValues);
3502
+ }
3503
+ } else {
3504
+ this.updateValue(event, li, state);
3505
+ }
3506
+ } else {
3507
+ this.updateValue(event, li, state);
3508
+ }
3509
+ }
3510
+ private updateValue (event: MouseEvent | KeyboardEventArgs, li : NodeListOf<HTMLElement>| HTMLElement[], state: boolean): void {
3511
+ let length: number = li.length;
3512
+ if (li && li.length) {
3513
+ let index: number = 0;
3514
+ let count: number = 0;
3515
+ if (this.enableGroupCheckBox) {
3516
+ count = state ? this.maximumSelectionLength - (this.value ? this.value.length : 0) : li.length;
3517
+ } else {
3518
+ count = state ? this.maximumSelectionLength - (this.value ? this.value.length : 0) : this.maximumSelectionLength;
3519
+ }
3520
+ while (index < length && index <= 50 && index < count) {
3521
+ this.updateListSelection(li[index], event, length - index);
3522
+ this.findGroupStart(li[index]);
3523
+ index++;
3524
+ }
3525
+ if (length > 50) {
3526
+ setTimeout(
3527
+ (): void => {
3528
+ while (index < length && index < count) {
3529
+ this.updateListSelection(li[index], event, length - index);
3530
+ this.findGroupStart(li[index]);
3531
+ index++;
3532
+ }
3533
+ if (!(isBlazor() && this.isServerRendered)) {
3534
+ this.updatedataValueItems(event);
3535
+ }
3536
+ },
3537
+ 0
3538
+ );
3539
+ }
3540
+ }
3541
+ if (!(isBlazor() && this.isServerRendered)) {
3542
+ this.updatedataValueItems(event);
3543
+ this.checkPlaceholderSize();
3544
+ }
3545
+ }
3546
+
3547
+ private updatedataValueItems(event?: MouseEvent | KeyboardEventArgs): void {
3548
+ this.deselectHeader();
3549
+ this.textboxValueUpdate(event);
3550
+ }
3551
+ private textboxValueUpdate(event?: MouseEvent | KeyboardEventArgs): void {
3552
+ if (this.mode !== 'Box' && !this.isPopupOpen()) {
3553
+ this.updateDelimView();
3554
+ } else {
3555
+ this.searchWrapper.classList.remove(ZERO_SIZE);
3556
+ }
3557
+ if (this.mode === 'CheckBox') {
3558
+ this.updateDelimView();
3559
+ this.updateDelimeter(this.delimiterChar, event);
3560
+ this.refreshInputHight();
3561
+ } else {
3562
+ this.updateDelimeter(this.delimiterChar, event);
3563
+ }
3564
+ this.refreshPlaceHolder();
3565
+ }
3566
+ protected setZIndex(): void {
3567
+ if (this.popupObj) {
3568
+ this.popupObj.setProperties({ 'zIndex': this.zIndex });
3569
+ }
3570
+ }
3571
+ protected updateDataSource(prop?: MultiSelectModel): void {
3572
+ if (isNullOrUndefined(this.list)) {
3573
+ this.renderPopup();
3574
+ } else {
3575
+ this.resetList(this.dataSource);
3576
+ }
3577
+ if (this.value && this.value.length && !(isBlazor() && this.isServerRendered)) {
3578
+ this.setProperties({ 'value': this.value });
3579
+ this.refreshSelection();
3580
+ }
3581
+ }
3582
+ private onLoadSelect(): void {
3583
+ this.setDynValue = true;
3584
+ this.renderPopup();
3585
+ }
3586
+ protected selectAllItems(state: boolean, event?: MouseEvent): void {
3587
+ if (isNullOrUndefined(this.list)) {
3588
+ this.selectAllAction = () => {
3589
+ if (this.mode === 'CheckBox' && this.showSelectAll) {
3590
+ let args: { [key: string]: Object | string } = {
3591
+ module: 'CheckBoxSelection',
3592
+ enable: this.mode === 'CheckBox',
3593
+ value: state ? 'check' : 'uncheck'
3594
+ };
3595
+ this.notify('checkSelectAll', args);
3596
+ }
3597
+ this.selectAllItem(state, event);
3598
+ this.selectAllAction = null;
3599
+ };
3600
+ super.render();
3601
+ } else {
3602
+ this.selectAllAction = null;
3603
+ if (this.mode === 'CheckBox' && this.showSelectAll) {
3604
+ let args: { [key: string]: Object | string } = {
3605
+ value: state ? 'check' : 'uncheck',
3606
+ enable: this.mode === 'CheckBox',
3607
+ module: 'CheckBoxSelection'
3608
+ };
3609
+ this.notify('checkSelectAll', args);
3610
+ }
3611
+ this.selectAllItem(state, event);
3612
+ }
3613
+ }
3614
+ /**
3615
+ * Get the properties to be maintained in the persisted state.
3616
+ */
3617
+ protected getPersistData(): string {
3618
+ return this.addOnPersist(['value']);
3619
+ };
3620
+
3621
+ /**
3622
+ * Dynamically change the value of properties.
3623
+ * @private
3624
+ */
3625
+ public onPropertyChanged(newProp: MultiSelectModel, oldProp: MultiSelectModel): void {
3626
+ if (newProp.dataSource && !isNullOrUndefined(Object.keys(newProp.dataSource))
3627
+ || newProp.query && !isNullOrUndefined(Object.keys(newProp.query))) {
3628
+ this.mainList = null;
3629
+ this.mainData = null;
3630
+ this.isFirstClick = false;
3631
+ this.isDynamicDataChange = true;
3632
+ }
3633
+ if (this.getModuleName() === 'multiselect') {
3634
+ this.filterAction = false;
3635
+ this.setUpdateInitial(['fields', 'query', 'dataSource'], newProp as { [key: string]: string; });
3636
+ }
3637
+ for (let prop of Object.keys(newProp)) {
3638
+ switch (prop) {
3639
+ case 'query':
3640
+ case 'dataSource':
3641
+ if (this.mode === 'CheckBox' && this.showSelectAll) {
3642
+ if (!isNullOrUndefined(this.popupObj)) {
3643
+ this.popupObj.destroy();
3644
+ this.popupObj = null;
3645
+ }
3646
+ this.renderPopup();
3647
+ }
3648
+ break;
3649
+ case 'htmlAttributes': this.updateHTMLAttribute();
3650
+ break;
3651
+ case 'showClearButton': this.updateClearButton(newProp.showClearButton);
3652
+ break;
3653
+ case 'text': this.updateVal(this.value, this.value, 'text');
3654
+ break;
3655
+ case 'value':
3656
+ this.updateVal(this.value, oldProp.value, 'value');
3657
+ this.addValidInputClass();
3658
+ break;
3659
+ case 'width':
3660
+ this.setWidth(newProp.width);
3661
+ this.popupObj.setProperties({ width: this.calcPopupWidth() });
3662
+ break;
3663
+ case 'placeholder': this.refreshPlaceHolder();
3664
+ break;
3665
+ case 'filterBarPlaceholder':
3666
+ if (this.allowFiltering) {
3667
+ this.notify('filterBarPlaceholder', { filterBarPlaceholder: newProp.filterBarPlaceholder });
3668
+ }
3669
+ break;
3670
+ case 'delimiterChar':
3671
+ if (this.mode !== 'Box') { this.updateDelimView(); }
3672
+ this.updateData(newProp.delimiterChar);
3673
+ break;
3674
+ case 'cssClass':
3675
+ this.updateOldPropCssClass(oldProp.cssClass);
3676
+ this.updateCssClass();
3677
+ break;
3678
+ case 'enableRtl':
3679
+ this.enableRTL(newProp.enableRtl);
3680
+ super.onPropertyChanged(newProp, oldProp);
3681
+ break;
3682
+ case 'readonly':
3683
+ this.updateReadonly(newProp.readonly);
3684
+ this.hidePopup();
3685
+ break;
3686
+ case 'enabled':
3687
+ this.hidePopup();
3688
+ this.enable(newProp.enabled);
3689
+ break;
3690
+ case 'showSelectAll':
3691
+ if (this.popupObj) {
3692
+ this.popupObj.destroy();
3693
+ this.popupObj = null;
3694
+ }
3695
+ this.renderPopup();
3696
+ break;
3697
+ case 'showDropDownIcon': this.dropDownIcon();
3698
+ break;
3699
+ case 'floatLabelType':
3700
+ this.setFloatLabelType();
3701
+ this.addValidInputClass();
3702
+ break;
3703
+ case 'enableSelectionOrder':
3704
+ break;
3705
+ case 'selectAllText': this.notify('selectAllText', false);
3706
+ break;
3707
+ case 'popupHeight':
3708
+ case 'headerTemplate':
3709
+ case 'footerTemplate':
3710
+ this.reInitializePoup();
3711
+ break;
3712
+ case 'allowFiltering':
3713
+ if (this.mode === 'CheckBox' && this.popupObj) { this.reInitializePoup(); }
3714
+ this.updateSelectElementData(this.allowFiltering);
3715
+ break;
3716
+ default:
3717
+ let msProps: { [key: string]: Object };
3718
+ msProps = this.getPropObject(prop, <{ [key: string]: string; }>newProp, <{ [key: string]: string; }>oldProp);
3719
+ super.onPropertyChanged(msProps.newProperty, msProps.oldProperty);
3720
+ break;
3721
+ }
3722
+ }
3723
+ }
3724
+ private reInitializePoup(): void {
3725
+ if (this.popupObj) {
3726
+ this.popupObj.destroy();
3727
+ this.popupObj = null;
3728
+ }
3729
+ this.renderPopup();
3730
+ }
3731
+ private presentItemValue(ulElement: HTMLElement) {
3732
+ let valuecheck: string[] = [];
3733
+ for (let i: number = 0; i < this.value.length; i++) {
3734
+ let checkEle: Element = this.findListElement(
3735
+ ((this.allowFiltering && !isNullOrUndefined(this.mainList)) ? this.mainList : ulElement),
3736
+ 'li',
3737
+ 'data-value',
3738
+ this.value[i]);
3739
+ if (!checkEle) {
3740
+ valuecheck.push(this.value[i] as string);
3741
+ }
3742
+ }
3743
+ return valuecheck;
3744
+ };
3745
+ private addNonPresentItems(valuecheck: string[], ulElement: HTMLElement,
3746
+ list: { [key: string]: Object }[] | number[] | boolean[] | string[],
3747
+ event?: Object): void {
3748
+ this.showSpinner();
3749
+ (this.dataSource as DataManager).executeQuery(this.getForQuery(valuecheck)).then((e: Object) => {
3750
+ this.hideSpinner();
3751
+ this.addItem((e as ResultData).result, list.length);
3752
+ this.updateActionList(ulElement, list, event);
3753
+ });
3754
+ };
3755
+ private updateVal(
3756
+ newProp: string[] | boolean[] | number[],
3757
+ oldProp: string[] | boolean[] | number[],
3758
+ prop: string): void {
3759
+ if (!this.list) {
3760
+ this.onLoadSelect();
3761
+ } else {
3762
+ let valuecheck: string[] = [];
3763
+ if (!isNullOrUndefined(this.value) && !this.allowCustomValue) {
3764
+ valuecheck = this.presentItemValue(this.ulElement);
3765
+ }
3766
+ if (prop == 'value' && valuecheck.length > 0 && this.dataSource instanceof DataManager && !isNullOrUndefined(this.value)
3767
+ && this.listData != null) {
3768
+ this.mainData = null;
3769
+ this.setDynValue = true;
3770
+ this.addNonPresentItems(valuecheck, this.ulElement, this.listData)
3771
+ } else {
3772
+ if (prop === 'text') {
3773
+ this.initialTextUpdate();
3774
+ newProp = this.value;
3775
+ }
3776
+ if (isNullOrUndefined(this.value) || this.value.length === 0) { this.tempValues = oldProp; }
3777
+ this.initialValueUpdate();
3778
+ if (this.mode !== 'Box' && !this.inputFocus) { this.updateDelimView(); }
3779
+ if (!this.inputFocus) { this.refreshInputHight(); }
3780
+ this.refreshPlaceHolder();
3781
+ if (this.mode !== 'CheckBox' && this.changeOnBlur) { this.updateValueState(null, newProp, oldProp); }
3782
+ this.checkPlaceholderSize();
3783
+ }
3784
+ }
3785
+ if (!this.changeOnBlur) {
3786
+ this.updateValueState(null, newProp, oldProp);
3787
+ }
3788
+ }
3789
+ /**
3790
+ * Adds a new item to the multiselect popup list. By default, new item appends to the list as the last item,
3791
+ * but you can insert based on the index parameter.
3792
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
3793
+ * @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
3794
+ * @return {void}.
3795
+ */
3796
+ public addItem(
3797
+ items: { [key: string]: Object }[] | { [key: string]: Object } | string | boolean | number | string[] | boolean[] | number[],
3798
+ itemIndex?: number): void {
3799
+ super.addItem(items, itemIndex);
3800
+ }
3801
+ /**
3802
+ * Hides the popup, if the popup in a open state.
3803
+ * @returns void
3804
+ */
3805
+ public hidePopup(): void {
3806
+ let delay: number = 100;
3807
+ if (this.isPopupOpen()) {
3808
+ let animModel: AnimationModel = {
3809
+ name: 'FadeOut',
3810
+ duration: 100,
3811
+ delay: delay ? delay : 0
3812
+ };
3813
+ let eventArgs: PopupEventArgs = { popup: this.popupObj, cancel: false, animation: animModel };
3814
+ this.trigger('close', eventArgs, (eventArgs: PopupEventArgs) => {
3815
+ if (!eventArgs.cancel) {
3816
+ this.beforePopupOpen = false;
3817
+ this.overAllWrapper.classList.remove(iconAnimation);
3818
+ this.popupObj.hide(new Animation(eventArgs.animation));
3819
+ attributes(this.inputElement, { 'aria-expanded': 'false' });
3820
+ if (this.allowFiltering) {
3821
+ this.notify('inputFocus', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'clear' });
3822
+ }
3823
+ this.popupObj.hide();
3824
+ removeClass([document.body, this.popupObj.element], 'e-popup-full-page');
3825
+ EventHandler.remove(this.list, 'keydown', this.onKeyDown);
3826
+ }
3827
+ });
3828
+ }
3829
+ }
3830
+ /**
3831
+ * Shows the popup, if the popup in a closed state.
3832
+ * @returns void
3833
+ */
3834
+ public showPopup(): void {
3835
+ if (!this.enabled) {
3836
+ return;
3837
+ }
3838
+ if ((isBlazor() && this.isServerRendered) && this.itemTemplate) {
3839
+ this.DropDownBaseupdateBlazorTemplates(true, false, false, false, false, false, false, false);
3840
+ if (this.mode !== 'CheckBox' && this.list) {
3841
+ this.refreshSelection();
3842
+ }
3843
+ }
3844
+ if (!this.ulElement) {
3845
+ this.beforePopupOpen = true;
3846
+ super.render();
3847
+ if (this.mode === 'CheckBox' && Browser.isDevice && this.allowFiltering) {
3848
+ this.notify('popupFullScreen', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
3849
+ }
3850
+ return;
3851
+ }
3852
+ if (this.mode === 'CheckBox' && Browser.isDevice && this.allowFiltering) {
3853
+ this.notify('popupFullScreen', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox' });
3854
+ }
3855
+
3856
+ let mainLiLength: number = this.ulElement.querySelectorAll('li.' + 'e-list-item').length;
3857
+ let liLength: number = this.ulElement.querySelectorAll('li.'
3858
+ + dropDownBaseClasses.li + '.' + HIDE_LIST).length;
3859
+ if (mainLiLength > 0 && (mainLiLength === liLength) && (liLength === this.mainData.length)) {
3860
+ this.beforePopupOpen = false;
3861
+ return;
3862
+ }
3863
+ this.onPopupShown();
3864
+ }
3865
+ /**
3866
+ * Based on the state parameter, entire list item will be selected/deselected.
3867
+ * parameter
3868
+ * `true` - Selects entire list items.
3869
+ * `false` - Un Selects entire list items.
3870
+ * @returns void
3871
+ */
3872
+ public selectAll(state: boolean): void {
3873
+ this.isSelectAll = true;
3874
+ this.selectAllItems(state);
3875
+ }
3876
+
3877
+ public getModuleName(): string {
3878
+ return 'multiselect';
3879
+ };
3880
+
3881
+ /**
3882
+ * Allows you to clear the selected values from the Multiselect component.
3883
+ * @returns void
3884
+ */
3885
+ public clear(): void {
3886
+ this.selectAll(false);
3887
+ this.setProperties({value: null}, true);
3888
+ }
3889
+ /**
3890
+ * To Initialize the control rendering
3891
+ * @private
3892
+ */
3893
+ public render(): void {
3894
+ this.setDynValue = this.initStatus = false;
3895
+ this.isSelectAll = false;
3896
+ this.searchWrapper = this.createElement('span', { className: SEARCHBOX_WRAPPER + ' ' + ((this.mode === 'Box') ? BOX_ELEMENT : '')});
3897
+ this.viewWrapper = this.createElement('span', { className: DELIMITER_VIEW + ' ' + DELIMITER_WRAPPER, styles: 'display:none;' });
3898
+ this.overAllClear = this.createElement('span', {
3899
+ className: CLOSEICON_CLASS, styles: 'display:none;'
3900
+ });
3901
+ this.componentWrapper = this.createElement('div', { className: ELEMENT_WRAPPER }) as HTMLDivElement;
3902
+ this.overAllWrapper = this.createElement('div', { className: OVER_ALL_WRAPPER }) as HTMLDivElement;
3903
+ if (this.mode === 'CheckBox') { addClass([this.overAllWrapper], 'e-checkbox'); }
3904
+ if (Browser.isDevice) {
3905
+ this.componentWrapper.classList.add(ELEMENT_MOBILE_WRAPPER);
3906
+ }
3907
+ this.setWidth(this.width);
3908
+ this.overAllWrapper.appendChild(this.componentWrapper);
3909
+ this.popupWrapper = this.createElement('div', { id: this.element.id + '_popup', className: POPUP_WRAPPER }) as HTMLDivElement;
3910
+ if (this.mode === 'Delimiter' || this.mode === 'CheckBox') {
3911
+ this.delimiterWrapper = this.createElement('span', { className: DELIMITER_WRAPPER, styles: 'display:none' });
3912
+ this.componentWrapper.appendChild(this.delimiterWrapper);
3913
+ } else {
3914
+ this.chipCollectionWrapper = this.createElement('span', {
3915
+ className: CHIP_WRAPPER,
3916
+ styles: 'display:none'
3917
+ });
3918
+ if (this.mode === 'Default') {
3919
+ this.chipCollectionWrapper.setAttribute('id', getUniqueID('chip_default'));
3920
+ } else if (this.mode === 'Box') {
3921
+ this.chipCollectionWrapper.setAttribute('id', getUniqueID('chip_box'));
3922
+ }
3923
+ this.componentWrapper.appendChild(this.chipCollectionWrapper);
3924
+ }
3925
+ if (this.mode !== 'Box') {
3926
+ this.componentWrapper.appendChild(this.viewWrapper);
3927
+ }
3928
+ this.componentWrapper.appendChild(this.searchWrapper);
3929
+ if (this.showClearButton && !Browser.isDevice) {
3930
+ this.componentWrapper.appendChild(this.overAllClear);
3931
+ } else {
3932
+ this.componentWrapper.classList.add(CLOSE_ICON_HIDE);
3933
+ }
3934
+ this.dropDownIcon();
3935
+ this.inputElement = this.createElement('input', {
3936
+ className: INPUT_ELEMENT,
3937
+ attrs: {
3938
+ spellcheck: 'false',
3939
+ type: 'text',
3940
+ autocomplete: 'off',
3941
+ tabindex: '0'
3942
+ }
3943
+ }) as HTMLInputElement;
3944
+ if (this.mode === 'Default' || this.mode === 'Box') {
3945
+ this.inputElement.setAttribute('aria-describedby', this.chipCollectionWrapper.id);
3946
+ }
3947
+ if (this.element.tagName !== this.getNgDirective()) {
3948
+ this.element.style.display = 'none';
3949
+ }
3950
+ if (this.element.tagName === this.getNgDirective()) {
3951
+ this.element.appendChild(this.overAllWrapper);
3952
+ this.searchWrapper.appendChild(this.inputElement);
3953
+ } else {
3954
+ this.element.parentElement.insertBefore(this.overAllWrapper, this.element);
3955
+ this.searchWrapper.appendChild(this.inputElement);
3956
+ this.searchWrapper.appendChild(this.element);
3957
+ this.element.removeAttribute('tabindex');
3958
+ }
3959
+ if (this.floatLabelType !== 'Never') {
3960
+ createFloatLabel(
3961
+ this.overAllWrapper, this.searchWrapper,
3962
+ this.element, this.inputElement,
3963
+ this.value, this.floatLabelType, this.placeholder
3964
+ );
3965
+ } else if (this.floatLabelType === 'Never') {
3966
+ this.refreshPlaceHolder();
3967
+ }
3968
+ this.addValidInputClass();
3969
+ this.element.style.opacity = '';
3970
+ let id: string = this.element.getAttribute('id') ? this.element.getAttribute('id') : getUniqueID('ej2_dropdownlist');
3971
+ this.element.id = id;
3972
+ this.hiddenElement = this.createElement('select', {
3973
+ attrs: { 'aria-hidden': 'true', 'class': HIDDEN_ELEMENT, 'tabindex': '-1', 'multiple': '' }
3974
+ }) as HTMLSelectElement;
3975
+ this.componentWrapper.appendChild(this.hiddenElement);
3976
+ this.validationAttribute(this.element, this.hiddenElement);
3977
+ if (this.mode !== 'CheckBox') { this.hideOverAllClear(); }
3978
+ this.wireEvent();
3979
+ this.enable(this.enabled);
3980
+ this.enableRTL(this.enableRtl);
3981
+ this.checkInitialValue();
3982
+ this.renderComplete();
3983
+ }
3984
+ private checkInitialValue(): void {
3985
+ let isData: boolean = this.dataSource instanceof Array ? (this.dataSource.length > 0)
3986
+ : !isNullOrUndefined(this.dataSource);
3987
+ if (!(this.value && this.value.length) &&
3988
+ isNullOrUndefined(this.text) &&
3989
+ !isData &&
3990
+ this.element.tagName === 'SELECT' &&
3991
+ (<HTMLSelectElement>this.element).options.length > 0) {
3992
+ let optionsElement: HTMLOptionsCollection = (<HTMLSelectElement>this.element).options;
3993
+ let valueCol: string[] = [];
3994
+ let textCol: string = '';
3995
+ for (let index: number = 0, optionsLen: number = optionsElement.length; index < optionsLen; index++) {
3996
+ let opt: HTMLOptionElement = optionsElement[index];
3997
+ if (!isNullOrUndefined(opt.getAttribute('selected'))) {
3998
+ (opt.getAttribute('value')) ? valueCol.push(opt.getAttribute('value')) : textCol += (opt.text + this.delimiterChar);
3999
+ }
4000
+ }
4001
+ if (valueCol.length > 0) {
4002
+ this.setProperties({value: valueCol}, true);
4003
+ } else if (textCol !== '') {
4004
+ this.setProperties({text: textCol}, true);
4005
+ }
4006
+ if (valueCol.length > 0 || textCol !== '') {
4007
+ this.refreshInputHight();
4008
+ this.refreshPlaceHolder();
4009
+ }
4010
+ }
4011
+ if ((this.value && this.value.length) || !isNullOrUndefined(this.text)) { this.renderPopup(); }
4012
+ if (!isNullOrUndefined(this.text) && (isNullOrUndefined(this.value) || this.value.length === 0)) { this.initialTextUpdate(); }
4013
+ if (this.value && this.value.length) {
4014
+ if (!(this.dataSource instanceof DataManager)) {
4015
+ this.initialValueUpdate();
4016
+ this.initialUpdate();
4017
+ } else {
4018
+ this.setInitialValue = () => {
4019
+ this.initStatus = false;
4020
+ this.initialValueUpdate();
4021
+ this.initialUpdate();
4022
+ this.setInitialValue = null;
4023
+ this.initStatus = true;
4024
+ };
4025
+ }
4026
+ this.updateTempValue();
4027
+ } else {
4028
+ this.initialUpdate();
4029
+ }
4030
+ this.initStatus = true;
4031
+ this.checkAutoFocus();
4032
+ if (!isNullOrUndefined(this.text)) {
4033
+ this.element.setAttribute('data-initial-value', this.text);
4034
+ }
4035
+ }
4036
+ private checkAutoFocus(): void {
4037
+ if (this.element.hasAttribute('autofocus')) {
4038
+ this.inputElement.focus();
4039
+ }
4040
+ }
4041
+ private setFloatLabelType(): void {
4042
+ removeFloating(
4043
+ this.overAllWrapper,
4044
+ this.componentWrapper,
4045
+ this.searchWrapper,
4046
+ this.inputElement,
4047
+ this.value,
4048
+ this.floatLabelType,
4049
+ this.placeholder
4050
+ );
4051
+ if (this.floatLabelType !== 'Never') {
4052
+ createFloatLabel(
4053
+ this.overAllWrapper,
4054
+ this.searchWrapper,
4055
+ this.element,
4056
+ this.inputElement,
4057
+ this.value,
4058
+ this.floatLabelType,
4059
+ this.placeholder
4060
+ );
4061
+ }
4062
+ }
4063
+ private addValidInputClass(): void {
4064
+ if ((!isNullOrUndefined(this.value) && this.value.length) || this.floatLabelType === 'Always') {
4065
+ addClass([this.overAllWrapper], 'e-valid-input');
4066
+ } else {
4067
+ removeClass([this.overAllWrapper], 'e-valid-input');
4068
+ }
4069
+ }
4070
+ private dropDownIcon(): void {
4071
+ if (this.showDropDownIcon) {
4072
+ this.dropIcon = this.createElement('span', { className: dropdownIcon });
4073
+ this.componentWrapper.appendChild(this.dropIcon);
4074
+ addClass([this.componentWrapper], ['e-down-icon']);
4075
+ } else {
4076
+ if (!isNullOrUndefined(this.dropIcon)) {
4077
+ this.dropIcon.parentElement.removeChild(this.dropIcon);
4078
+ removeClass([this.componentWrapper], ['e-down-icon']);
4079
+ }
4080
+ }
4081
+ }
4082
+ private initialUpdate(): void {
4083
+ if (this.mode !== 'Box') {
4084
+ this.updateDelimView();
4085
+ }
4086
+ this.updateCssClass();
4087
+ this.updateHTMLAttribute();
4088
+ this.updateReadonly(this.readonly);
4089
+ this.refreshInputHight();
4090
+ this.checkPlaceholderSize();
4091
+ }
4092
+ /**
4093
+ * Removes the component from the DOM and detaches all its related event handlers. Also it removes the attributes and classes.
4094
+ * @method destroy
4095
+ * @return {void}
4096
+ */
4097
+ public destroy(): void {
4098
+ if (this.popupObj) {
4099
+ this.popupObj.hide();
4100
+ }
4101
+ this.notify(destroy, {});
4102
+ this.unwireListEvents();
4103
+ this.unWireEvent();
4104
+ this.list = null;
4105
+ this.popupObj = null;
4106
+ this.mainList = null;
4107
+ this.mainData = null;
4108
+ this.filterParent = null;
4109
+ this.ulElement = null;
4110
+ super.destroy();
4111
+ let temp: string[] = ['readonly', 'aria-disabled', 'aria-placeholder', 'placeholder'];
4112
+ let length: number = temp.length;
4113
+ while (length > 0) {
4114
+ this.inputElement.removeAttribute(temp[length - 1]);
4115
+ length--;
4116
+ }
4117
+ this.element.removeAttribute('data-initial-value');
4118
+ this.element.style.display = 'block';
4119
+ if (this.overAllWrapper.parentElement) {
4120
+ if (this.overAllWrapper.parentElement.tagName === this.getNgDirective()) {
4121
+ remove(this.overAllWrapper);
4122
+ } else {
4123
+ this.overAllWrapper.parentElement.insertBefore(this.element, this.overAllWrapper);
4124
+ remove(this.overAllWrapper);
4125
+ }
4126
+ }
4127
+ };
4128
+ }
4129
+ export interface CustomValueEventArgs {
4130
+ /**
4131
+ * Gets the newly added data.
4132
+ * @blazorType object
4133
+ */
4134
+ newData: Object;
4135
+ /**
4136
+ * Illustrates whether the current action needs to be prevented or not.
4137
+ */
4138
+ cancel: boolean;
4139
+ }
4140
+
4141
+ export interface TaggingEventArgs {
4142
+ /**
4143
+ * If the event is triggered by interaction, it returns true. Otherwise, it returns false.
4144
+ */
4145
+ isInteracted: boolean;
4146
+ /**
4147
+ * Returns the selected item as JSON Object from the data source.
4148
+ * @blazorType object
4149
+ */
4150
+ itemData: FieldSettingsModel;
4151
+ /**
4152
+ * Specifies the original event arguments.
4153
+ */
4154
+ e: MouseEvent | KeyboardEvent | TouchEvent;
4155
+ /**
4156
+ * To set the classes to chip element
4157
+ * @param { string } classes - Specify the classes to chip element.
4158
+ * @return {void}.
4159
+ * @blazorType string
4160
+ */
4161
+ setClass: Function;
4162
+ /**
4163
+ * Illustrates whether the current action needs to be prevented or not.
4164
+ */
4165
+ cancel: boolean;
4166
+ }
4167
+ export interface MultiSelectChangeEventArgs {
4168
+ /**
4169
+ * If the event is triggered by interaction, it returns true. Otherwise, it returns false.
4170
+ */
4171
+ isInteracted: boolean;
4172
+ /**
4173
+ * Returns the component initial Value.
4174
+ * @isGenericType true
4175
+ */
4176
+ oldValue: number[] | string[] | boolean[];
4177
+ /**
4178
+ * Returns the updated component Values.
4179
+ * @isGenericType true
4180
+ */
4181
+ value: number[] | string[] | boolean[];
4182
+ /**
4183
+ * Specifies the original event arguments.
4184
+ */
4185
+ e: MouseEvent | KeyboardEvent | TouchEvent;
4186
+ /**
4187
+ * Returns the root element of the component.
4188
+ */
4189
+ element: HTMLElement;
4190
+ }
4191
+ export type visualMode = 'Default' | 'Delimiter' | 'Box' | 'CheckBox';
4192
+
4193
+ export interface ISelectAllEventArgs {
4194
+ /**
4195
+ * If the event is triggered by interaction, it returns true. Otherwise, it returns false.
4196
+ */
4197
+ isInteracted: boolean;
4198
+ /**
4199
+ * Returns the selected list items.
4200
+ */
4201
+ items: HTMLLIElement[];
4202
+ /**
4203
+ * Returns the selected items as JSON Object from the data source.
4204
+ * @blazorType object
4205
+ */
4206
+ itemData: FieldSettingsModel[];
4207
+ /**
4208
+ * Specifies the original event arguments.
4209
+ */
4210
+ event: MouseEvent | KeyboardEvent | TouchEvent;
4211
+ /**
4212
+ * Specifies whether it is selectAll or deSelectAll.
4213
+ */
4214
+ isChecked?: boolean;
4215
+
4216
+ }