@syncfusion/ej2-navigations 20.1.48 → 20.1.51-10460

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 (415) hide show
  1. package/.eslintrc.json +243 -243
  2. package/CHANGELOG.md +1601 -1585
  3. package/README.md +194 -194
  4. package/dist/ej2-navigations.min.js +1 -0
  5. package/dist/ej2-navigations.umd.min.js +1 -10
  6. package/dist/ej2-navigations.umd.min.js.map +1 -1
  7. package/dist/es6/ej2-navigations.es2015.js +78 -76
  8. package/dist/es6/ej2-navigations.es2015.js.map +1 -1
  9. package/dist/es6/ej2-navigations.es5.js +234 -232
  10. package/dist/es6/ej2-navigations.es5.js.map +1 -1
  11. package/dist/global/ej2-navigations.min.js +1 -10
  12. package/dist/global/ej2-navigations.min.js.map +1 -1
  13. package/dist/global/index.d.ts +0 -9
  14. package/dist/ts/accordion/accordion.ts +1545 -0
  15. package/dist/ts/breadcrumb/breadcrumb.ts +873 -0
  16. package/dist/ts/carousel/carousel.ts +1181 -0
  17. package/dist/ts/common/h-scroll.ts +477 -0
  18. package/dist/ts/common/menu-base.ts +2357 -0
  19. package/dist/ts/common/menu-scroll.ts +105 -0
  20. package/dist/ts/common/v-scroll.ts +454 -0
  21. package/{src/context-menu/context-menu.d.ts → dist/ts/context-menu/context-menu.ts} +134 -88
  22. package/dist/ts/menu/menu.ts +302 -0
  23. package/dist/ts/sidebar/sidebar.ts +874 -0
  24. package/dist/ts/tab/tab.ts +2637 -0
  25. package/dist/ts/toolbar/toolbar.ts +2378 -0
  26. package/dist/ts/treeview/treeview.ts +5768 -0
  27. package/helpers/e2e/accordionHelper.js +70 -53
  28. package/helpers/e2e/contextmenuHelper.js +52 -35
  29. package/helpers/e2e/index.js +14 -12
  30. package/helpers/e2e/menuHelper.js +52 -35
  31. package/helpers/e2e/sidebarHelper.js +109 -92
  32. package/helpers/e2e/tabHelper.js +73 -56
  33. package/helpers/e2e/toolbarHelper.js +73 -56
  34. package/helpers/e2e/treeview.js +79 -61
  35. package/license +10 -10
  36. package/package.json +164 -164
  37. package/src/accordion/accordion-model.d.ts +190 -190
  38. package/src/accordion/accordion.js +19 -19
  39. package/src/breadcrumb/breadcrumb-model.d.ts +105 -105
  40. package/src/breadcrumb/breadcrumb.js +19 -19
  41. package/src/carousel/carousel-model.d.ts +148 -148
  42. package/src/carousel/carousel.js +19 -19
  43. package/src/common/h-scroll-model.d.ts +6 -6
  44. package/src/common/h-scroll.js +19 -19
  45. package/src/common/menu-base-model.d.ts +206 -206
  46. package/src/common/menu-base.js +22 -20
  47. package/src/common/v-scroll-model.d.ts +6 -6
  48. package/src/common/v-scroll.js +19 -19
  49. package/src/context-menu/context-menu-model.d.ts +18 -18
  50. package/src/context-menu/context-menu.js +19 -19
  51. package/src/menu/menu-model.d.ts +43 -43
  52. package/src/menu/menu.js +19 -19
  53. package/src/sidebar/sidebar-model.d.ts +191 -191
  54. package/src/sidebar/sidebar.js +19 -19
  55. package/src/tab/tab-model.d.ts +291 -291
  56. package/src/tab/tab.js +21 -21
  57. package/src/toolbar/toolbar-model.d.ts +195 -195
  58. package/src/toolbar/toolbar.js +19 -19
  59. package/src/treeview/treeview-model.d.ts +411 -411
  60. package/src/treeview/treeview.js +20 -20
  61. package/styles/accordion/_bds-definition.scss +167 -0
  62. package/styles/accordion/_bigger.scss +121 -0
  63. package/styles/accordion/_bootstrap5.3-definition.scss +168 -0
  64. package/styles/accordion/_fluent2-definition.scss +167 -0
  65. package/styles/accordion/_fusionnew-definition.scss +168 -0
  66. package/styles/accordion/_material3-dark-definition.scss +1 -0
  67. package/styles/accordion/_material3-definition.scss +168 -0
  68. package/styles/accordion/fluent2.scss +4 -0
  69. package/styles/accordion/icons/_bds.scss +15 -0
  70. package/styles/accordion/icons/_bootstrap5.3.scss +15 -0
  71. package/styles/accordion/icons/_fluent2.scss +15 -0
  72. package/styles/accordion/icons/_fusionnew.scss +15 -0
  73. package/styles/accordion/icons/_material3-dark.scss +1 -0
  74. package/styles/accordion/icons/_material3.scss +15 -0
  75. package/styles/accordion/material3-dark.scss +4 -0
  76. package/styles/accordion/material3.scss +4 -0
  77. package/styles/appbar/_all.scss +2 -0
  78. package/styles/appbar/_bds-definition.scss +25 -0
  79. package/styles/appbar/_bigger.scss +15 -0
  80. package/styles/appbar/_bootstrap-dark-definition.scss +6 -0
  81. package/styles/appbar/_bootstrap-definition.scss +6 -0
  82. package/styles/appbar/_bootstrap4-definition.scss +6 -0
  83. package/styles/appbar/_bootstrap5-definition.scss +6 -0
  84. package/styles/appbar/_bootstrap5.3-definition.scss +6 -0
  85. package/styles/appbar/_fabric-dark-definition.scss +6 -0
  86. package/styles/appbar/_fabric-definition.scss +6 -0
  87. package/styles/appbar/_fluent-definition.scss +6 -0
  88. package/styles/appbar/_fluent2-definition.scss +24 -0
  89. package/styles/appbar/_fusionnew-definition.scss +6 -0
  90. package/styles/appbar/_highcontrast-definition.scss +6 -0
  91. package/styles/appbar/_highcontrast-light-definition.scss +6 -0
  92. package/styles/appbar/_layout.scss +76 -0
  93. package/styles/appbar/_material-dark-definition.scss +6 -0
  94. package/styles/appbar/_material-definition.scss +6 -0
  95. package/styles/appbar/_material3-definition.scss +6 -0
  96. package/styles/appbar/_tailwind-definition.scss +6 -0
  97. package/styles/appbar/_theme.scss +216 -0
  98. package/styles/bootstrap-dark.css +1 -1
  99. package/styles/bootstrap.css +1 -1
  100. package/styles/bootstrap4.css +1 -1
  101. package/styles/bootstrap5-dark.css +1 -1
  102. package/styles/bootstrap5.css +1 -1
  103. package/styles/breadcrumb/_bds-definition.scss +60 -0
  104. package/styles/breadcrumb/_bigger.scss +160 -0
  105. package/styles/breadcrumb/_bootstrap5.3-definition.scss +61 -0
  106. package/styles/breadcrumb/_fluent2-definition.scss +61 -0
  107. package/styles/breadcrumb/_fusionnew-definition.scss +59 -0
  108. package/styles/breadcrumb/_layout.scss +1 -1
  109. package/styles/breadcrumb/_material3-dark-definition.scss +1 -0
  110. package/styles/breadcrumb/_material3-definition.scss +60 -0
  111. package/styles/breadcrumb/bootstrap-dark.css +1 -1
  112. package/styles/breadcrumb/bootstrap.css +1 -1
  113. package/styles/breadcrumb/bootstrap4.css +1 -1
  114. package/styles/breadcrumb/bootstrap5-dark.css +1 -1
  115. package/styles/breadcrumb/bootstrap5.css +1 -1
  116. package/styles/breadcrumb/fabric-dark.css +1 -1
  117. package/styles/breadcrumb/fabric.css +1 -1
  118. package/styles/breadcrumb/fluent-dark.css +1 -1
  119. package/styles/breadcrumb/fluent.css +1 -1
  120. package/styles/breadcrumb/fluent2.scss +4 -0
  121. package/styles/breadcrumb/highcontrast-light.css +1 -1
  122. package/styles/breadcrumb/highcontrast.css +1 -1
  123. package/styles/breadcrumb/icons/_bds.scss +23 -0
  124. package/styles/breadcrumb/icons/_bootstrap5.3.scss +23 -0
  125. package/styles/breadcrumb/icons/_fluent2.scss +23 -0
  126. package/styles/breadcrumb/icons/_fusionnew.scss +23 -0
  127. package/styles/breadcrumb/icons/_material3-dark.scss +1 -0
  128. package/styles/breadcrumb/icons/_material3.scss +12 -0
  129. package/styles/breadcrumb/material-dark.css +1 -1
  130. package/styles/breadcrumb/material.css +1 -1
  131. package/styles/breadcrumb/material3-dark.scss +4 -0
  132. package/styles/breadcrumb/material3.scss +4 -0
  133. package/styles/breadcrumb/tailwind-dark.css +1 -1
  134. package/styles/breadcrumb/tailwind.css +1 -1
  135. package/styles/carousel/_bds-definition.scss +20 -0
  136. package/styles/carousel/_bootstrap5.3-definition.scss +20 -0
  137. package/styles/carousel/_fluent2-definition.scss +23 -0
  138. package/styles/carousel/_fusionnew-definition.scss +20 -0
  139. package/styles/carousel/_material3-dark-definition.scss +1 -0
  140. package/styles/carousel/_material3-definition.scss +21 -0
  141. package/styles/carousel/fluent2.scss +4 -0
  142. package/styles/carousel/icons/_bds.scss +30 -0
  143. package/styles/carousel/icons/_bootstrap5.3.scss +30 -0
  144. package/styles/carousel/icons/_fluent2.scss +30 -0
  145. package/styles/carousel/icons/_fusionnew.scss +30 -0
  146. package/styles/carousel/icons/_material3-dark.scss +1 -0
  147. package/styles/carousel/icons/_material3.scss +30 -0
  148. package/styles/carousel/material3-dark.scss +4 -0
  149. package/styles/carousel/material3.scss +4 -0
  150. package/styles/context-menu/_bds-definition.scss +68 -0
  151. package/styles/context-menu/_bigger.scss +96 -0
  152. package/styles/context-menu/_bootstrap5.3-definition.scss +52 -0
  153. package/styles/context-menu/_fluent2-definition.scss +52 -0
  154. package/styles/context-menu/_fusionnew-definition.scss +51 -0
  155. package/styles/context-menu/_material3-dark-definition.scss +1 -0
  156. package/styles/context-menu/_material3-definition.scss +51 -0
  157. package/styles/context-menu/fluent2.scss +4 -0
  158. package/styles/context-menu/icons/_bds.scss +31 -0
  159. package/styles/context-menu/icons/_bootstrap5.3.scss +31 -0
  160. package/styles/context-menu/icons/_fluent2.scss +31 -0
  161. package/styles/context-menu/icons/_fusionnew.scss +31 -0
  162. package/styles/context-menu/icons/_material3-dark.scss +1 -0
  163. package/styles/context-menu/icons/_material3.scss +31 -0
  164. package/styles/context-menu/material3-dark.scss +4 -0
  165. package/styles/context-menu/material3.scss +4 -0
  166. package/styles/fabric-dark.css +1 -1
  167. package/styles/fabric.css +1 -1
  168. package/styles/fluent-dark.css +1 -1
  169. package/styles/fluent.css +1 -1
  170. package/styles/fluent2.scss +34 -0
  171. package/styles/h-scroll/_bds-definition.scss +83 -0
  172. package/styles/h-scroll/_bigger.scss +39 -0
  173. package/styles/h-scroll/_bootstrap5.3-definition.scss +83 -0
  174. package/styles/h-scroll/_fluent2-definition.scss +83 -0
  175. package/styles/h-scroll/_fusionnew-definition.scss +83 -0
  176. package/styles/h-scroll/_material3-dark-definition.scss +1 -0
  177. package/styles/h-scroll/_material3-definition.scss +83 -0
  178. package/styles/h-scroll/fluent2.scss +4 -0
  179. package/styles/h-scroll/icons/_bds.scss +49 -0
  180. package/styles/h-scroll/icons/_bootstrap5.3.scss +49 -0
  181. package/styles/h-scroll/icons/_fluent2.scss +49 -0
  182. package/styles/h-scroll/icons/_fusionnew.scss +49 -0
  183. package/styles/h-scroll/icons/_material3-dark.scss +1 -0
  184. package/styles/h-scroll/icons/_material3.scss +49 -0
  185. package/styles/h-scroll/material3-dark.scss +4 -0
  186. package/styles/h-scroll/material3.scss +4 -0
  187. package/styles/highcontrast-light.css +1 -1
  188. package/styles/highcontrast.css +1 -1
  189. package/styles/material-dark.css +1 -1
  190. package/styles/material.css +1 -1
  191. package/styles/material3-dark.scss +34 -0
  192. package/styles/material3.scss +34 -0
  193. package/styles/menu/_bds-definition.scss +65 -0
  194. package/styles/menu/_bigger.scss +355 -0
  195. package/styles/menu/_bootstrap5.3-definition.scss +66 -0
  196. package/styles/menu/_fluent2-definition.scss +67 -0
  197. package/styles/menu/_fusionnew-definition.scss +66 -0
  198. package/styles/menu/_material3-dark-definition.scss +1 -0
  199. package/styles/menu/_material3-definition.scss +66 -0
  200. package/styles/menu/fluent2.scss +7 -0
  201. package/styles/menu/icons/_bds.scss +104 -0
  202. package/styles/menu/icons/_bootstrap5.3.scss +104 -0
  203. package/styles/menu/icons/_fluent2.scss +104 -0
  204. package/styles/menu/icons/_fusionnew.scss +104 -0
  205. package/styles/menu/icons/_material3-dark.scss +1 -0
  206. package/styles/menu/icons/_material3.scss +104 -0
  207. package/styles/menu/material3-dark.scss +7 -0
  208. package/styles/menu/material3.scss +7 -0
  209. package/styles/pager/_all.scss +2 -0
  210. package/styles/pager/_bds-definition.scss +152 -0
  211. package/styles/pager/_bigger.scss +311 -0
  212. package/styles/pager/_bootstrap-dark-definition.scss +151 -0
  213. package/styles/pager/_bootstrap-definition.scss +151 -0
  214. package/styles/pager/_bootstrap4-definition.scss +151 -0
  215. package/styles/pager/_bootstrap5-definition.scss +166 -0
  216. package/styles/pager/_bootstrap5.3-definition.scss +166 -0
  217. package/styles/pager/_fabric-dark-definition.scss +149 -0
  218. package/styles/pager/_fabric-definition.scss +149 -0
  219. package/styles/pager/_fluent-definition.scss +153 -0
  220. package/styles/pager/_fluent2-definition.scss +152 -0
  221. package/styles/pager/_fusionnew-definition.scss +166 -0
  222. package/styles/pager/_highcontrast-definition.scss +149 -0
  223. package/styles/pager/_highcontrast-light-definition.scss +149 -0
  224. package/styles/pager/_layout.scss +742 -0
  225. package/styles/pager/_material-dark-definition.scss +150 -0
  226. package/styles/pager/_material-definition.scss +150 -0
  227. package/styles/pager/_material3-definition.scss +166 -0
  228. package/styles/pager/_tailwind-definition.scss +152 -0
  229. package/styles/pager/_theme.scss +189 -0
  230. package/styles/pager/icons/_bds.scss +50 -0
  231. package/styles/pager/icons/_bootstrap-dark.scss +50 -0
  232. package/styles/pager/icons/_bootstrap.scss +50 -0
  233. package/styles/pager/icons/_bootstrap4.scss +50 -0
  234. package/styles/pager/icons/_bootstrap5.3.scss +50 -0
  235. package/styles/pager/icons/_bootstrap5.scss +50 -0
  236. package/styles/pager/icons/_fabric-dark.scss +50 -0
  237. package/styles/pager/icons/_fabric.scss +50 -0
  238. package/styles/pager/icons/_fluent.scss +50 -0
  239. package/styles/pager/icons/_fluent2.scss +50 -0
  240. package/styles/pager/icons/_fusionnew.scss +50 -0
  241. package/styles/pager/icons/_highcontrast-light.scss +50 -0
  242. package/styles/pager/icons/_highcontrast.scss +46 -0
  243. package/styles/pager/icons/_material-dark.scss +50 -0
  244. package/styles/pager/icons/_material.scss +46 -0
  245. package/styles/pager/icons/_material3.scss +50 -0
  246. package/styles/pager/icons/_tailwind.scss +50 -0
  247. package/styles/sidebar/_bds-definition.scss +53 -0
  248. package/styles/sidebar/_bootstrap5.3-definition.scss +6 -0
  249. package/styles/sidebar/_fluent2-definition.scss +8 -0
  250. package/styles/sidebar/_fusionnew-definition.scss +6 -0
  251. package/styles/sidebar/_material3-dark-definition.scss +1 -0
  252. package/styles/sidebar/_material3-definition.scss +4 -0
  253. package/styles/sidebar/fluent2.scss +3 -0
  254. package/styles/sidebar/material3-dark.scss +3 -0
  255. package/styles/sidebar/material3.scss +3 -0
  256. package/styles/stepper/_all.scss +2 -0
  257. package/styles/stepper/_bds-definition.scss +72 -0
  258. package/styles/stepper/_bigger.scss +53 -0
  259. package/styles/stepper/_bootstrap-dark-definition.scss +72 -0
  260. package/styles/stepper/_bootstrap-definition.scss +72 -0
  261. package/styles/stepper/_bootstrap4-definition.scss +72 -0
  262. package/styles/stepper/_bootstrap5-definition.scss +73 -0
  263. package/styles/stepper/_bootstrap5.3-definition.scss +72 -0
  264. package/styles/stepper/_fabric-dark-definition.scss +72 -0
  265. package/styles/stepper/_fabric-definition.scss +72 -0
  266. package/styles/stepper/_fluent-definition.scss +72 -0
  267. package/styles/stepper/_fluent2-definition.scss +72 -0
  268. package/styles/stepper/_fusionnew-definition.scss +72 -0
  269. package/styles/stepper/_highcontrast-definition.scss +72 -0
  270. package/styles/stepper/_highcontrast-light-definition.scss +72 -0
  271. package/styles/stepper/_layout.scss +431 -0
  272. package/styles/stepper/_material-dark-definition.scss +72 -0
  273. package/styles/stepper/_material-definition.scss +72 -0
  274. package/styles/stepper/_material3-definition.scss +72 -0
  275. package/styles/stepper/_tailwind-definition.scss +72 -0
  276. package/styles/stepper/_theme.scss +195 -0
  277. package/styles/stepper/icons/_bds.scss +5 -0
  278. package/styles/stepper/icons/_bootstrap-dark.scss +5 -0
  279. package/styles/stepper/icons/_bootstrap.scss +5 -0
  280. package/styles/stepper/icons/_bootstrap4.scss +5 -0
  281. package/styles/stepper/icons/_bootstrap5.3.scss +5 -0
  282. package/styles/stepper/icons/_bootstrap5.scss +5 -0
  283. package/styles/stepper/icons/_fabric-dark.scss +5 -0
  284. package/styles/stepper/icons/_fabric.scss +5 -0
  285. package/styles/stepper/icons/_fluent.scss +5 -0
  286. package/styles/stepper/icons/_fluent2.scss +5 -0
  287. package/styles/stepper/icons/_fusionnew.scss +5 -0
  288. package/styles/stepper/icons/_highcontrast-light.scss +5 -0
  289. package/styles/stepper/icons/_highcontrast.scss +5 -0
  290. package/styles/stepper/icons/_material-dark.scss +5 -0
  291. package/styles/stepper/icons/_material.scss +5 -0
  292. package/styles/stepper/icons/_material3.scss +5 -0
  293. package/styles/stepper/icons/_tailwind.scss +5 -0
  294. package/styles/tab/_bds-definition.scss +661 -0
  295. package/styles/tab/_bigger.scss +1270 -0
  296. package/styles/tab/_bootstrap5.3-definition.scss +636 -0
  297. package/styles/tab/_fluent2-definition.scss +667 -0
  298. package/styles/tab/_fusionnew-definition.scss +634 -0
  299. package/styles/tab/_material3-dark-definition.scss +1 -0
  300. package/styles/tab/_material3-definition.scss +636 -0
  301. package/styles/tab/fluent2.scss +5 -0
  302. package/styles/tab/icons/_bds.scss +90 -0
  303. package/styles/tab/icons/_bootstrap5.3.scss +90 -0
  304. package/styles/tab/icons/_fluent2.scss +98 -0
  305. package/styles/tab/icons/_fusionnew.scss +90 -0
  306. package/styles/tab/icons/_material3-dark.scss +1 -0
  307. package/styles/tab/icons/_material3.scss +90 -0
  308. package/styles/tab/material3-dark.scss +5 -0
  309. package/styles/tab/material3.scss +5 -0
  310. package/styles/tailwind-dark.css +1 -1
  311. package/styles/tailwind.css +1 -1
  312. package/styles/toolbar/_bds-definition.scss +197 -0
  313. package/styles/toolbar/_bigger.scss +309 -0
  314. package/styles/toolbar/_bootstrap5.3-definition.scss +198 -0
  315. package/styles/toolbar/_fluent2-definition.scss +198 -0
  316. package/styles/toolbar/_fusionnew-definition.scss +198 -0
  317. package/styles/toolbar/_material3-dark-definition.scss +1 -0
  318. package/styles/toolbar/_material3-definition.scss +199 -0
  319. package/styles/toolbar/fluent2.scss +6 -0
  320. package/styles/toolbar/icons/_bds.scss +14 -0
  321. package/styles/toolbar/icons/_bootstrap5.3.scss +14 -0
  322. package/styles/toolbar/icons/_fluent2.scss +14 -0
  323. package/styles/toolbar/icons/_fusionnew.scss +14 -0
  324. package/styles/toolbar/icons/_material3-dark.scss +1 -0
  325. package/styles/toolbar/icons/_material3.scss +14 -0
  326. package/styles/toolbar/material3-dark.scss +6 -0
  327. package/styles/toolbar/material3.scss +6 -0
  328. package/styles/treeview/_bds-definition.scss +132 -0
  329. package/styles/treeview/_bigger.scss +393 -0
  330. package/styles/treeview/_bootstrap5.3-definition.scss +119 -0
  331. package/styles/treeview/_fluent2-definition.scss +128 -0
  332. package/styles/treeview/_fusionnew-definition.scss +120 -0
  333. package/styles/treeview/_material3-dark-definition.scss +1 -0
  334. package/styles/treeview/_material3-definition.scss +110 -0
  335. package/styles/treeview/fluent2.scss +4 -0
  336. package/styles/treeview/icons/_bds.scss +44 -0
  337. package/styles/treeview/icons/_bootstrap5.3.scss +44 -0
  338. package/styles/treeview/icons/_fluent2.scss +44 -0
  339. package/styles/treeview/icons/_fusionnew.scss +44 -0
  340. package/styles/treeview/icons/_material3-dark.scss +1 -0
  341. package/styles/treeview/icons/_material3.scss +44 -0
  342. package/styles/treeview/material3-dark.scss +4 -0
  343. package/styles/treeview/material3.scss +4 -0
  344. package/styles/v-scroll/_bds-definition.scss +49 -0
  345. package/styles/v-scroll/_bigger.scss +28 -0
  346. package/styles/v-scroll/_bootstrap5.3-definition.scss +49 -0
  347. package/styles/v-scroll/_fluent2-definition.scss +49 -0
  348. package/styles/v-scroll/_fusionnew-definition.scss +49 -0
  349. package/styles/v-scroll/_material3-dark-definition.scss +1 -0
  350. package/styles/v-scroll/_material3-definition.scss +49 -0
  351. package/styles/v-scroll/fluent2.scss +4 -0
  352. package/styles/v-scroll/icons/_bds.scss +27 -0
  353. package/styles/v-scroll/icons/_bootstrap5.3.scss +27 -0
  354. package/styles/v-scroll/icons/_fluent2.scss +27 -0
  355. package/styles/v-scroll/icons/_fusionnew.scss +27 -0
  356. package/styles/v-scroll/icons/_material3-dark.scss +1 -0
  357. package/styles/v-scroll/icons/_material3.scss +27 -0
  358. package/styles/v-scroll/material3-dark.scss +4 -0
  359. package/styles/v-scroll/material3.scss +4 -0
  360. package/tslint.json +111 -111
  361. package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -63
  362. package/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -39
  363. package/accordion.d.ts +0 -4
  364. package/accordion.js +0 -4
  365. package/breadcrumb.d.ts +0 -4
  366. package/breadcrumb.js +0 -4
  367. package/carousel.d.ts +0 -4
  368. package/carousel.js +0 -4
  369. package/common.d.ts +0 -4
  370. package/common.js +0 -4
  371. package/context-menu.d.ts +0 -4
  372. package/context-menu.js +0 -4
  373. package/helpers/e2e/accordionHelper.d.ts +0 -56
  374. package/helpers/e2e/contextmenuHelper.d.ts +0 -37
  375. package/helpers/e2e/index.d.ts +0 -7
  376. package/helpers/e2e/menuHelper.d.ts +0 -37
  377. package/helpers/e2e/sidebarHelper.d.ts +0 -94
  378. package/helpers/e2e/tabHelper.d.ts +0 -60
  379. package/helpers/e2e/toolbarHelper.d.ts +0 -60
  380. package/helpers/e2e/treeview.d.ts +0 -50
  381. package/index.d.ts +0 -4
  382. package/index.js +0 -4
  383. package/menu.d.ts +0 -4
  384. package/menu.js +0 -4
  385. package/sidebar.d.ts +0 -4
  386. package/sidebar.js +0 -4
  387. package/src/accordion/accordion.d.ts +0 -440
  388. package/src/accordion/index.d.ts +0 -5
  389. package/src/breadcrumb/breadcrumb.d.ts +0 -255
  390. package/src/breadcrumb/index.d.ts +0 -5
  391. package/src/carousel/carousel.d.ts +0 -338
  392. package/src/carousel/index.d.ts +0 -3
  393. package/src/common/h-scroll.d.ts +0 -105
  394. package/src/common/index.d.ts +0 -9
  395. package/src/common/menu-base.d.ts +0 -526
  396. package/src/common/menu-scroll.d.ts +0 -29
  397. package/src/common/v-scroll.d.ts +0 -106
  398. package/src/context-menu/index.d.ts +0 -5
  399. package/src/index.d.ts +0 -13
  400. package/src/menu/index.d.ts +0 -5
  401. package/src/menu/menu.d.ts +0 -121
  402. package/src/sidebar/index.d.ts +0 -5
  403. package/src/sidebar/sidebar.d.ts +0 -321
  404. package/src/tab/index.d.ts +0 -5
  405. package/src/tab/tab.d.ts +0 -650
  406. package/src/toolbar/index.d.ts +0 -5
  407. package/src/toolbar/toolbar.d.ts +0 -470
  408. package/src/treeview/index.d.ts +0 -5
  409. package/src/treeview/treeview.d.ts +0 -1256
  410. package/tab.d.ts +0 -4
  411. package/tab.js +0 -4
  412. package/toolbar.d.ts +0 -4
  413. package/toolbar.js +0 -4
  414. package/treeview.d.ts +0 -4
  415. package/treeview.js +0 -4
@@ -0,0 +1,2378 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Component, EventHandler, Property, Event, EmitType, BaseEventArgs } from '@syncfusion/ej2-base';
3
+ import { addClass, removeClass, isVisible, closest, attributes, detach, classList, KeyboardEvents } from '@syncfusion/ej2-base';
4
+ import { selectAll, setStyleAttribute as setStyle, KeyboardEventArgs, select } from '@syncfusion/ej2-base';
5
+ import { isNullOrUndefined as isNOU, getUniqueID, formatUnit, Collection, compile as templateCompiler } from '@syncfusion/ej2-base';
6
+ import { INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, Browser, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
7
+ import { Popup } from '@syncfusion/ej2-popups';
8
+ import { calculatePosition } from '@syncfusion/ej2-popups';
9
+ import { Button, IconPosition } from '@syncfusion/ej2-buttons';
10
+ import { HScroll } from '../common/h-scroll';
11
+ import { VScroll } from '../common/v-scroll';
12
+ import { ToolbarModel, ItemModel } from './toolbar-model';
13
+ /**
14
+ * Specifies the options for supporting element types of Toolbar command.
15
+ */
16
+ export type ItemType = 'Button' | 'Separator' | 'Input';
17
+ /**
18
+ * Specifies the options of where the text will be displayed in popup mode of the Toolbar.
19
+ */
20
+ export type DisplayMode = 'Both' | 'Overflow' | 'Toolbar';
21
+ /**
22
+ * Specifies the options of the Toolbar item display area when the Toolbar content overflows to available space.Applicable to `popup` mode.
23
+ */
24
+ export type OverflowOption = 'None' | 'Show' | 'Hide';
25
+ /**
26
+ * Specifies the options of Toolbar display mode. Display option is considered when Toolbar content exceeds the available space.
27
+ */
28
+ export type OverflowMode = 'Scrollable' | 'Popup' | 'MultiRow' | 'Extended';
29
+
30
+ type HTEle = HTMLElement;
31
+ type Str = string;
32
+ type ItmAlign = 'lefts' | 'centers' | 'rights';
33
+
34
+ /**
35
+ * Specifies the options for aligning the Toolbar items.
36
+ */
37
+ export type ItemAlign = 'Left' | 'Center' | 'Right';
38
+
39
+ const CLS_VERTICAL: Str = 'e-vertical';
40
+ const CLS_ITEMS: Str = 'e-toolbar-items';
41
+ const CLS_ITEM: Str = 'e-toolbar-item';
42
+ const CLS_RTL: Str = 'e-rtl';
43
+ const CLS_SEPARATOR: Str = 'e-separator';
44
+ const CLS_POPUPICON: Str = 'e-popup-up-icon';
45
+ const CLS_POPUPDOWN: Str = 'e-popup-down-icon';
46
+ const CLS_POPUPOPEN: Str = 'e-popup-open';
47
+ const CLS_TEMPLATE: Str = 'e-template';
48
+ const CLS_DISABLE: Str = 'e-overlay';
49
+ const CLS_POPUPTEXT: Str = 'e-toolbar-text';
50
+ const CLS_TBARTEXT: Str = 'e-popup-text';
51
+ const CLS_TBAROVERFLOW: Str = 'e-overflow-show';
52
+ const CLS_POPOVERFLOW: Str = 'e-overflow-hide';
53
+ const CLS_TBARBTN: Str = 'e-tbar-btn';
54
+ const CLS_TBARNAV: Str = 'e-hor-nav';
55
+ const CLS_TBARSCRLNAV: Str = 'e-scroll-nav';
56
+ const CLS_TBARRIGHT: Str = 'e-toolbar-right';
57
+ const CLS_TBARLEFT: Str = 'e-toolbar-left';
58
+ const CLS_TBARCENTER: Str = 'e-toolbar-center';
59
+ const CLS_TBARPOS: Str = 'e-tbar-pos';
60
+ const CLS_HSCROLLCNT: Str = 'e-hscroll-content';
61
+ const CLS_VSCROLLCNT: Str = 'e-vscroll-content';
62
+ const CLS_HSCROLLBAR: Str = 'e-hscroll-bar';
63
+ const CLS_POPUPNAV: Str = 'e-hor-nav';
64
+ const CLS_POPUPCLASS: Str = 'e-toolbar-pop';
65
+ const CLS_POPUP: Str = 'e-toolbar-popup';
66
+ const CLS_TBARBTNTEXT: Str = 'e-tbar-btn-text';
67
+ const CLS_TBARNAVACT: Str = 'e-nav-active';
68
+ const CLS_TBARIGNORE: Str = 'e-ignore';
69
+ const CLS_POPPRI: Str = 'e-popup-alone';
70
+ const CLS_HIDDEN: string = 'e-hidden';
71
+ const CLS_MULTIROW: string = 'e-toolbar-multirow';
72
+ const CLS_MULTIROWPOS: string = 'e-multirow-pos';
73
+ const CLS_MULTIROW_SEPARATOR: string = 'e-multirow-separator';
74
+ const CLS_EXTENDABLE_SEPARATOR: string = 'e-extended-separator';
75
+ const CLS_EXTEANDABLE_TOOLBAR: Str = 'e-extended-toolbar';
76
+ const CLS_EXTENDABLECLASS: Str = 'e-toolbar-extended';
77
+ const CLS_EXTENDPOPUP: Str = 'e-expended-nav';
78
+ const CLS_EXTENDEDPOPOPEN: Str = 'e-tbar-extended';
79
+
80
+ interface Template {
81
+ appendTo: (elemnt: HTMLElement) => void
82
+ }
83
+
84
+ interface ToolbarItemAlignIn {
85
+ lefts: HTMLElement[]
86
+ centers: HTMLElement[]
87
+ rights: HTMLElement[]
88
+ }
89
+ /** An interface that holds options to control the toolbar clicked action. */
90
+ export interface ClickEventArgs extends BaseEventArgs {
91
+ /** Defines the current Toolbar Item Object. */
92
+ item: ItemModel
93
+ /**
94
+ * Defines the current Event arguments.
95
+ */
96
+ originalEvent: Event
97
+ /** Defines the prevent action. */
98
+ cancel?: boolean
99
+ }
100
+
101
+ /** An interface that holds options to control before the toolbar create. */
102
+ export interface BeforeCreateArgs extends BaseEventArgs {
103
+ /** Enable or disable the popup collision. */
104
+ enableCollision: boolean
105
+ /** Specifies the scrolling distance in scroller. */
106
+ scrollStep: number
107
+ }
108
+ /** @hidden */
109
+ interface EJ2Instance extends HTMLElement {
110
+ // eslint-disable-next-line camelcase
111
+ ej2_instances: Object[]
112
+ }
113
+
114
+ /**
115
+ * An item object that is used to configure Toolbar commands.
116
+ */
117
+ export class Item extends ChildProperty<Item> {
118
+ /**
119
+ * Specifies the unique ID to be used with button or input element of Toolbar items.
120
+ *
121
+ * @default ""
122
+ */
123
+ @Property('')
124
+ public id: string;
125
+ /**
126
+ * Specifies the text to be displayed on the Toolbar button.
127
+ *
128
+ * @default ""
129
+ */
130
+ @Property('')
131
+ public text: string;
132
+ /**
133
+ * Specifies the width of the Toolbar button commands.
134
+ *
135
+ * @default 'auto'
136
+ */
137
+ @Property('auto')
138
+ public width: number | string;
139
+ /**
140
+ * Defines single/multiple classes (separated by space) to be used for customization of commands.
141
+ *
142
+ * @default ""
143
+ */
144
+ @Property('')
145
+ public cssClass: string;
146
+ /**
147
+ * Defines the priority of items to display it in popup always.
148
+ * It allows to maintain toolbar item on popup always but it does not work for toolbar priority items.
149
+ *
150
+ * @default false
151
+ */
152
+ @Property(false)
153
+ public showAlwaysInPopup: boolean;
154
+ /**
155
+ * Specifies whether an item should be disabled or not.
156
+ *
157
+ * @default false
158
+ */
159
+ @Property(false)
160
+ public disabled: boolean;
161
+ /**
162
+ * Defines single/multiple classes separated by space used to specify an icon for the button.
163
+ * The icon will be positioned before the text content if text is available, otherwise the icon alone will be rendered.
164
+ *
165
+ * @default ""
166
+ */
167
+ @Property('')
168
+ public prefixIcon: string;
169
+ /**
170
+ * Defines single/multiple classes separated by space used to specify an icon for the button.
171
+ * The icon will be positioned after the text content if text is available.
172
+ *
173
+ * @default ""
174
+ */
175
+ @Property('')
176
+ public suffixIcon: string;
177
+ /**
178
+ * Specifies whether an item should be hidden or not.
179
+ *
180
+ * @default true
181
+ */
182
+ @Property(true)
183
+ public visible: boolean;
184
+ /**
185
+ * Specifies the Toolbar command display area when an element's content is too large to fit available space.
186
+ * This is applicable only to `popup` mode. Possible values are:
187
+ * - Show: Always shows the item as the primary priority on the *Toolbar*.
188
+ * - Hide: Always shows the item as the secondary priority on the *popup*.
189
+ * - None: No priority for display, and as per normal order moves to popup when content exceeds.
190
+ *
191
+ * @default 'None'
192
+ */
193
+ @Property('None')
194
+ public overflow: OverflowOption;
195
+ /**
196
+ * Specifies the HTML element/element ID as a string that can be added as a Toolbar command.
197
+ * ```
198
+ * E.g - items: [{ template: '<input placeholder="Search"/>' },{ template: '#checkbox1' }]
199
+ * ```
200
+ *
201
+ * @default ""
202
+ */
203
+ @Property('')
204
+ public template: string | Object;
205
+ /**
206
+ * Specifies the types of command to be rendered in the Toolbar.
207
+ * Supported types are:
208
+ * - Button: Creates the Button control with its given properties like text, prefixIcon, etc.
209
+ * - Separator: Adds a horizontal line that separates the Toolbar commands.
210
+ * - Input: Creates an input element that is applicable to template rendering with Syncfusion controls like DropDownList,
211
+ * AutoComplete, etc.
212
+ *
213
+ * @default 'Button'
214
+ */
215
+ @Property('Button')
216
+ public type: ItemType;
217
+ /**
218
+ * Specifies where the button text will be displayed on *popup mode* of the Toolbar.
219
+ * Possible values are:
220
+ * - Toolbar: Text will be displayed on *Toolbar* only.
221
+ * - Overflow: Text will be displayed only when content overflows to *popup*.
222
+ * - Both: Text will be displayed on *popup* and *Toolbar*.
223
+ *
224
+ * @default 'Both'
225
+ */
226
+ @Property('Both')
227
+ public showTextOn: DisplayMode;
228
+ /**
229
+ * Defines htmlAttributes used to add custom attributes to Toolbar command.
230
+ * Supports HTML attributes such as style, class, etc.
231
+ *
232
+ * @default null
233
+ */
234
+ @Property(null)
235
+ public htmlAttributes: { [key: string]: string };
236
+ /**
237
+ * Specifies the text to be displayed on hovering the Toolbar button.
238
+ *
239
+ * @default ""
240
+ */
241
+ @Property('')
242
+ public tooltipText: string;
243
+ /**
244
+ * Specifies the location for aligning Toolbar items on the Toolbar. Each command will be aligned according to the `align` property.
245
+ * Possible values are:
246
+ * - Left: To align commands to the left side of the Toolbar.
247
+ * - Center: To align commands at the center of the Toolbar.
248
+ * - Right: To align commands to the right side of the Toolbar.
249
+ * ```html
250
+ * <div id="element"> </div>
251
+ * ```
252
+ * ```typescript
253
+ * let toolbar: Toolbar = new Toolbar({
254
+ * items: [
255
+ * { text: "Home" },
256
+ * { text: "My Home Page" , align: 'Center' },
257
+ * { text: "Search", align: 'Right' }
258
+ * { text: "Settings", align: 'Right' }
259
+ * ]
260
+ * });
261
+ * toolbar.appendTo('#element');
262
+ * ```
263
+ *
264
+ * @default "Left"
265
+ */
266
+ @Property('Left')
267
+ public align: ItemAlign;
268
+ /**
269
+ * Event triggers when `click` the toolbar item.
270
+ *
271
+ * @event click
272
+ */
273
+ @Event()
274
+ public click: EmitType<ClickEventArgs>;
275
+ }
276
+ /**
277
+ * The Toolbar control contains a group of commands that are aligned horizontally.
278
+ * ```html
279
+ * <div id="toolbar"/>
280
+ * <script>
281
+ * var toolbarObj = new Toolbar();
282
+ * toolbarObj.appendTo("#toolbar");
283
+ * </script>
284
+ * ```
285
+ */
286
+ @NotifyPropertyChanges
287
+ export class Toolbar extends Component<HTMLElement> implements INotifyPropertyChanged {
288
+ private trgtEle: HTEle;
289
+ private ctrlTem: HTEle;
290
+ private popObj: Popup;
291
+ private tbarEle: HTMLElement[];
292
+ private tbarAlgEle: ToolbarItemAlignIn;
293
+ private tbarAlign: boolean;
294
+ private tbarEleMrgn: number;
295
+ private tbResize: boolean;
296
+ private offsetWid: number;
297
+ private keyModule: KeyboardEvents;
298
+ private scrollModule: HScroll | VScroll;
299
+ private activeEle: HTEle;
300
+ private popupPriCount: number;
301
+ private tbarItemsCol: ItemModel[];
302
+ private isVertical: boolean;
303
+ private tempId: string[];
304
+ private isExtendedOpen: boolean;
305
+ private resizeContext: EventListenerObject = this.resize.bind(this);
306
+
307
+ /**
308
+ * Contains the keyboard configuration of the Toolbar.
309
+ */
310
+ private keyConfigs: { [key: string]: Str } = {
311
+ moveLeft: 'leftarrow',
312
+ moveRight: 'rightarrow',
313
+ moveUp: 'uparrow',
314
+ moveDown: 'downarrow',
315
+ popupOpen: 'enter',
316
+ popupClose: 'escape',
317
+ tab: 'tab',
318
+ home: 'home',
319
+ end: 'end'
320
+ };
321
+ /**
322
+ * An array of items that is used to configure Toolbar commands.
323
+ *
324
+ * @default []
325
+ */
326
+ @Collection<ItemModel>([], Item)
327
+ public items: ItemModel[];
328
+ /**
329
+ * Specifies the width of the Toolbar in pixels/numbers/percentage. Number value is considered as pixels.
330
+ *
331
+ * @default 'auto'
332
+ */
333
+ @Property('auto')
334
+ public width: string | number;
335
+ /**
336
+ * Specifies the height of the Toolbar in pixels/number/percentage. Number value is considered as pixels.
337
+ *
338
+ * @default 'auto'
339
+ */
340
+ @Property('auto')
341
+ public height: string | number;
342
+ /**
343
+ * Sets the CSS classes to root element of the Tab that helps to customize component styles.
344
+ *
345
+ * @default ''
346
+ */
347
+ @Property('')
348
+ public cssClass: string;
349
+ /**
350
+ * Specifies the Toolbar display mode when Toolbar content exceeds the viewing area.
351
+ * Possible modes are:
352
+ * - Scrollable: All the elements are displayed in a single line with horizontal scrolling enabled.
353
+ * - Popup: Prioritized elements are displayed on the Toolbar and the rest of elements are moved to the *popup*.
354
+ * - MultiRow: Displays the overflow toolbar items as an in-line of a toolbar.
355
+ * - Extended: Hide the overflowing toolbar items in the next row. Show the overflowing toolbar items when you click the expand icons.
356
+ * If the popup content overflows the height of the page, the rest of the elements will be hidden.
357
+ *
358
+ * @default 'Scrollable'
359
+ */
360
+ @Property('Scrollable')
361
+ public overflowMode: OverflowMode;
362
+ /**
363
+ * Specifies the scrolling distance in scroller.
364
+ *
365
+ * @default null
366
+ */
367
+ @Property()
368
+ public scrollStep: number;
369
+ /**
370
+ * Enable or disable the popup collision.
371
+ *
372
+ * @default true
373
+ */
374
+ @Property(true)
375
+ public enableCollision: boolean;
376
+ /**
377
+ * Defines whether to allow the cross-scripting site or not.
378
+ *
379
+ * @default true
380
+ */
381
+ @Property(true)
382
+ public enableHtmlSanitizer: boolean;
383
+ /**
384
+ * When this property is set to true, it allows the keyboard interaction in toolbar.
385
+ *
386
+ * @default true
387
+ */
388
+ @Property(true)
389
+ public allowKeyboard: boolean;
390
+
391
+ /**
392
+ * The event will be fired on clicking the Toolbar elements.
393
+ *
394
+ * @event clicked
395
+ */
396
+ @Event()
397
+ public clicked: EmitType<ClickEventArgs>;
398
+ /**
399
+ * The event will be fired when the control is rendered.
400
+ *
401
+ * @event created
402
+ */
403
+ @Event()
404
+ public created: EmitType<Event>;
405
+ /**
406
+ * The event will be fired when the control gets destroyed.
407
+ *
408
+ * @event destroyed
409
+ */
410
+ @Event()
411
+ public destroyed: EmitType<Event>;
412
+ /**
413
+ * The event will be fired before the control is rendered on a page.
414
+ *
415
+ * @event beforeCreate
416
+ */
417
+ @Event()
418
+ public beforeCreate: EmitType<BeforeCreateArgs>;
419
+ /**
420
+ * Removes the control from the DOM and also removes all its related events.
421
+ *
422
+ * @returns {void}.
423
+ */
424
+ public destroy(): void {
425
+ if ((this as any).isReact || (this as any).isAngular) {
426
+ this.clearTemplate();
427
+ }
428
+ const btnItems: NodeList = this.element.querySelectorAll('.e-control.e-btn');
429
+ [].slice.call(btnItems).forEach((el: EJ2Instance) => {
430
+ if (!isNOU(el) && !isNOU(el.ej2_instances) && !isNOU(el.ej2_instances[0]) && !((el.ej2_instances[0] as Button).isDestroyed)) {
431
+ (el.ej2_instances[0] as Button).destroy();
432
+ }
433
+ });
434
+ this.unwireEvents();
435
+ this.tempId.forEach((ele: Str): void => {
436
+ if (!isNOU(this.element.querySelector(ele))) {
437
+ (<HTEle>document.body.appendChild(this.element.querySelector(ele))).style.display = 'none';
438
+ }
439
+ });
440
+ this.destroyItems();
441
+ while (this.element.lastElementChild) {
442
+ this.element.removeChild(this.element.lastElementChild);
443
+ }
444
+ if (this.trgtEle) {
445
+ this.element.appendChild(this.ctrlTem);
446
+ this.trgtEle = null;
447
+ this.ctrlTem = null;
448
+ }
449
+ if (this.popObj) {
450
+ this.popObj.destroy();
451
+ detach(this.popObj.element);
452
+ }
453
+ if (this.activeEle) {
454
+ this.activeEle = null;
455
+ }
456
+ this.popObj = null;
457
+ this.tbarAlign = null;
458
+ this.tbarItemsCol = [];
459
+ this.remove(this.element, 'e-toolpop');
460
+ if (this.cssClass) {
461
+ removeClass([this.element], this.cssClass.split(' '));
462
+ }
463
+ this.element.removeAttribute('style');
464
+ ['aria-disabled', 'aria-orientation', 'aria-haspopup', 'role'].forEach((attrb: string): void =>
465
+ this.element.removeAttribute(attrb));
466
+ super.destroy();
467
+ }
468
+ /**
469
+ * Initialize the event handler
470
+ *
471
+ * @private
472
+ * @returns {void}
473
+ */
474
+ protected preRender(): void {
475
+ const eventArgs: BeforeCreateArgs = { enableCollision: this.enableCollision, scrollStep: this.scrollStep };
476
+ this.trigger('beforeCreate', eventArgs);
477
+ this.enableCollision = eventArgs.enableCollision;
478
+ this.scrollStep = eventArgs.scrollStep;
479
+ this.scrollModule = null;
480
+ this.popObj = null;
481
+ this.tempId = [];
482
+ this.tbarItemsCol = this.items;
483
+ this.isVertical = this.element.classList.contains(CLS_VERTICAL) ? true : false;
484
+ this.isExtendedOpen = false;
485
+ this.popupPriCount = 0;
486
+ if (this.enableRtl) {
487
+ this.add(this.element, CLS_RTL);
488
+ }
489
+ }
490
+ /**
491
+ * Initializes a new instance of the Toolbar class.
492
+ *
493
+ * @param {ToolbarModel} options - Specifies Toolbar model properties as options.
494
+ * @param { string | HTMLElement} element - Specifies the element that is rendered as a Toolbar.
495
+ */
496
+ public constructor(options?: ToolbarModel, element?: string | HTMLElement) {
497
+ super(options, <HTEle | Str>element);
498
+ }
499
+ private wireEvents(): void {
500
+ EventHandler.add(this.element, 'click', this.clickHandler, this);
501
+ window.addEventListener('resize', this.resizeContext);
502
+ if (this.allowKeyboard) {
503
+ this.wireKeyboardEvent();
504
+ }
505
+ }
506
+ private wireKeyboardEvent(): void {
507
+ this.keyModule = new KeyboardEvents(this.element, {
508
+ keyAction: this.keyActionHandler.bind(this),
509
+ keyConfigs: this.keyConfigs
510
+ });
511
+ EventHandler.add(this.element, 'keydown', this.docKeyDown, this);
512
+ this.element.setAttribute('tabIndex', '0');
513
+ }
514
+ private unwireKeyboardEvent(): void {
515
+ if (this.keyModule) {
516
+ EventHandler.remove(this.element, 'keydown', this.docKeyDown);
517
+ this.keyModule.destroy();
518
+ this.keyModule = null;
519
+ }
520
+ }
521
+ private docKeyDown(e: KeyboardEvent): void {
522
+ if ((<HTEle>e.target).tagName === 'INPUT') {
523
+ return;
524
+ }
525
+ const popCheck: boolean = !isNOU(this.popObj) && isVisible(this.popObj.element) && this.overflowMode !== 'Extended';
526
+ if (e.keyCode === 9 && (<HTEle>e.target).classList.contains('e-hor-nav') === true && popCheck) {
527
+ this.popObj.hide({ name: 'FadeOut', duration: 100 });
528
+ }
529
+ const keyCheck: boolean = (e.keyCode === 40 || e.keyCode === 38 || e.keyCode === 35 || e.keyCode === 36);
530
+ if (keyCheck) {
531
+ e.preventDefault();
532
+ }
533
+ }
534
+ private unwireEvents(): void {
535
+ EventHandler.remove(this.element, 'click', this.clickHandler);
536
+ this.destroyScroll();
537
+ this.unwireKeyboardEvent();
538
+ window.removeEventListener('resize', this.resizeContext);
539
+ EventHandler.remove(document, 'scroll', this.docEvent);
540
+ EventHandler.remove(document, 'click', this.docEvent);
541
+ }
542
+ private clearProperty(): void {
543
+ this.tbarEle = [];
544
+ this.tbarAlgEle = { lefts: [], centers: [], rights: [] };
545
+ }
546
+ private docEvent(e: Event): void {
547
+ const popEle: Element = closest(<Element>e.target, '.e-popup');
548
+ if (this.popObj && isVisible(this.popObj.element) && !popEle && this.overflowMode === 'Popup') {
549
+ this.popObj.hide({ name: 'FadeOut', duration: 100 });
550
+ }
551
+ }
552
+ private destroyScroll(): void {
553
+ if (this.scrollModule) {
554
+ if (this.tbarAlign) {
555
+ this.add(this.scrollModule.element, CLS_TBARPOS);
556
+ }
557
+ this.scrollModule.destroy(); this.scrollModule = null;
558
+ }
559
+ }
560
+ private destroyItems(): void {
561
+ if (this.element) {
562
+ [].slice.call(this.element.querySelectorAll('.' + CLS_ITEM)).forEach((el: HTEle) => { detach(el); });
563
+ }
564
+ if (this.tbarAlign) {
565
+ const tbarItems: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
566
+ [].slice.call(tbarItems.children).forEach((el: HTEle) => {
567
+ detach(el);
568
+ });
569
+ this.tbarAlign = false;
570
+ this.remove(tbarItems, CLS_TBARPOS);
571
+ }
572
+ this.clearProperty();
573
+ }
574
+ private destroyMode(): void {
575
+ if (this.scrollModule) {
576
+ this.remove(this.scrollModule.element, CLS_RTL);
577
+ this.destroyScroll();
578
+ }
579
+ this.remove(this.element, CLS_EXTENDEDPOPOPEN);
580
+ this.remove(this.element, CLS_EXTEANDABLE_TOOLBAR);
581
+ const tempEle: HTMLElement = this.element.querySelector('.e-toolbar-multirow');
582
+ if (tempEle) {
583
+ this.remove(tempEle, CLS_MULTIROW);
584
+ }
585
+ if (this.popObj) {
586
+ this.popupRefresh(this.popObj.element, true);
587
+ }
588
+ }
589
+ private add(ele: HTEle, val: Str): void {
590
+ ele.classList.add(val);
591
+ }
592
+ private remove(ele: HTEle, val: Str): void {
593
+ ele.classList.remove(val);
594
+ }
595
+ private elementFocus(ele: HTEle): void {
596
+ const fChild: HTEle = <HTEle>ele.firstElementChild;
597
+ if (fChild) {
598
+ fChild.focus();
599
+ this.activeEleSwitch(ele);
600
+ } else {
601
+ ele.focus();
602
+ }
603
+ }
604
+ private clstElement(tbrNavChk: boolean, trgt: HTEle): HTEle {
605
+ let clst: HTEle;
606
+ if (tbrNavChk && this.popObj && isVisible(this.popObj.element)) {
607
+ clst = <HTEle>this.popObj.element.querySelector('.' + CLS_ITEM);
608
+ } else if (this.element === trgt || tbrNavChk) {
609
+ clst = <HTEle>this.element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_DISABLE + ' ):not(.' + CLS_SEPARATOR + ' ):not(.' + CLS_HIDDEN + ' )');
610
+ } else {
611
+ clst = <HTEle>closest(trgt, '.' + CLS_ITEM);
612
+ }
613
+ return clst;
614
+ }
615
+ private keyHandling(clst: HTEle, e: KeyboardEventArgs, trgt: HTEle, navChk: boolean, scrollChk: boolean): void {
616
+ const popObj: Popup = this.popObj;
617
+ const rootEle: HTEle = this.element;
618
+ const popAnimate: Object = { name: 'FadeOut', duration: 100 };
619
+ const value: Str = e.action === 'moveUp' ? 'previous' : 'next';
620
+ let ele: HTEle;
621
+ let nodes: NodeList;
622
+ switch (e.action) {
623
+ case 'moveRight':
624
+ if (this.isVertical) {
625
+ return;
626
+ }
627
+ if (rootEle === trgt) {
628
+ this.elementFocus(clst);
629
+ } else if (!navChk) {
630
+ this.eleFocus(clst, 'next');
631
+ }
632
+ break;
633
+ case 'moveLeft':
634
+ if (this.isVertical) {
635
+ return;
636
+ }
637
+ if (!navChk) {
638
+ this.eleFocus(clst, 'previous');
639
+ }
640
+ break;
641
+ case 'home':
642
+ case 'end':
643
+ if (clst) {
644
+ let popupCheck: HTEle = <HTEle>closest(clst, '.e-popup');
645
+ const extendedPopup: HTEle = this.element.querySelector('.' + CLS_EXTENDABLECLASS);
646
+ if (this.overflowMode === 'Extended' && extendedPopup && extendedPopup.classList.contains('e-popup-open')) {
647
+ popupCheck = e.action === 'end' ? extendedPopup : null;
648
+ }
649
+ if (popupCheck) {
650
+ if (isVisible(this.popObj.element)) {
651
+ nodes = [].slice.call(popupCheck.children);
652
+ if (e.action === 'home') {
653
+ ele = <HTEle>nodes[0];
654
+ } else {
655
+ ele = <HTEle>nodes[nodes.length - 1];
656
+ }
657
+ }
658
+ } else {
659
+ nodes = this.element.querySelectorAll('.' + CLS_ITEMS + ' .' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + ')');
660
+ if (e.action === 'home') {
661
+ ele = <HTEle>nodes[0];
662
+ } else {
663
+ ele = <HTEle>nodes[nodes.length - 1];
664
+ }
665
+ }
666
+ if (ele) {
667
+ this.elementFocus(ele);
668
+ }
669
+ }
670
+ break;
671
+ case 'moveUp':
672
+ case 'moveDown':
673
+ if (!this.isVertical) {
674
+ if (popObj && closest(trgt, '.e-popup')) {
675
+ const popEle: HTEle = popObj.element;
676
+ const popFrstEle: HTEle = popEle.firstElementChild as HTEle;
677
+ if ((value === 'previous' && popFrstEle === clst) || (value === 'next' && popEle.lastElementChild === clst)) {
678
+ return;
679
+ } else {
680
+ this.eleFocus(clst, value);
681
+ }
682
+ } else if (e.action === 'moveDown' && popObj && isVisible(popObj.element)) {
683
+ this.elementFocus(clst);
684
+ }
685
+ } else {
686
+ if (e.action === 'moveUp') {
687
+ this.eleFocus(clst, 'previous');
688
+ } else {
689
+ this.eleFocus(clst, 'next');
690
+ }
691
+ }
692
+ break;
693
+ case 'tab':
694
+ if (!scrollChk && !navChk) {
695
+ const ele: HTEle = (<HTEle>clst.firstElementChild);
696
+ if (rootEle === trgt) {
697
+ if (this.activeEle) {
698
+ this.activeEle.focus();
699
+ } else {
700
+ this.activeEleRemove(ele);
701
+ ele.focus();
702
+ }
703
+ this.element.removeAttribute('tabindex');
704
+ }
705
+ }
706
+ break;
707
+ case 'popupClose':
708
+ if (popObj && this.overflowMode !== 'Extended') {
709
+ popObj.hide(popAnimate);
710
+ }
711
+ break;
712
+ case 'popupOpen':
713
+ if (!navChk) {
714
+ return;
715
+ }
716
+ if (popObj && !isVisible(popObj.element)) {
717
+ popObj.element.style.top = rootEle.offsetHeight + 'px';
718
+ popObj.show({ name: 'FadeIn', duration: 100 });
719
+ } else {
720
+ popObj.hide(popAnimate);
721
+ }
722
+ break;
723
+ }
724
+ }
725
+ private keyActionHandler(e: KeyboardEventArgs): void {
726
+ const trgt: HTEle = <HTEle>e.target;
727
+ if (trgt.tagName === 'INPUT' || trgt.tagName === 'TEXTAREA' || this.element.classList.contains(CLS_DISABLE)) {
728
+ return;
729
+ }
730
+ e.preventDefault();
731
+ const tbrNavChk: boolean = trgt.classList.contains(CLS_TBARNAV);
732
+ const tbarScrollChk: boolean = trgt.classList.contains(CLS_TBARSCRLNAV);
733
+ const clst: HTEle = this.clstElement(tbrNavChk, trgt);
734
+ if (clst || tbarScrollChk) {
735
+ this.keyHandling(clst, e, trgt, tbrNavChk, tbarScrollChk);
736
+ }
737
+ }
738
+ /**
739
+ * Specifies the value to disable/enable the Toolbar component.
740
+ * When set to `true`, the component will be disabled.
741
+ *
742
+ * @param {boolean} value - Based on this Boolean value, Toolbar will be enabled (false) or disabled (true).
743
+ * @returns {void}.
744
+ */
745
+ public disable(value: boolean): void {
746
+ const rootEle: HTMLElement = this.element;
747
+ if (value) {
748
+ rootEle.classList.add(CLS_DISABLE);
749
+ } else {
750
+ rootEle.classList.remove(CLS_DISABLE);
751
+ }
752
+ rootEle.setAttribute('tabindex', !value ? '0' : '-1');
753
+ if (this.activeEle) {
754
+ this.activeEle.setAttribute('tabindex', !value ? '0' : '-1');
755
+ }
756
+ if (this.scrollModule) {
757
+ this.scrollModule.disable(value);
758
+ }
759
+ if (this.popObj) {
760
+ if (isVisible(this.popObj.element) && this.overflowMode !== 'Extended') {
761
+ this.popObj.hide();
762
+ }
763
+ rootEle.querySelector('#' + rootEle.id + '_nav').setAttribute('tabindex', !value ? '0' : '-1');
764
+ }
765
+ }
766
+ private eleContains(el: HTEle): string | boolean {
767
+ return el.classList.contains(CLS_SEPARATOR) || el.classList.contains(CLS_DISABLE) || el.getAttribute('disabled') || el.classList.contains(CLS_HIDDEN) || !isVisible(el);
768
+ }
769
+ private eleFocus(closest: HTEle, pos: Str): void {
770
+ const sib: HTEle = Object(closest)[pos + 'ElementSibling'];
771
+ if (sib) {
772
+ const skipEle: string | boolean = this.eleContains(sib);
773
+ if (skipEle) {
774
+ this.eleFocus(sib, pos); return;
775
+ }
776
+ this.elementFocus(sib);
777
+ } else if (this.tbarAlign) {
778
+ let elem: HTEle = Object(closest.parentElement)[pos + 'ElementSibling'] as HTEle;
779
+ if (!isNOU(elem) && elem.children.length === 0) {
780
+ elem = Object(elem)[pos + 'ElementSibling'] as HTEle;
781
+ }
782
+ if (!isNOU(elem) && elem.children.length > 0) {
783
+ if (pos === 'next') {
784
+ const el: HTEle = <HTEle>elem.querySelector('.' + CLS_ITEM);
785
+ if (this.eleContains(el)) {
786
+ this.eleFocus(el, pos);
787
+ } else {
788
+ (<HTEle>el.firstElementChild).focus();
789
+ this.activeEleSwitch(el);
790
+ }
791
+ } else {
792
+ const el: HTEle = <HTEle>elem.lastElementChild;
793
+ if (this.eleContains(el)) {
794
+ this.eleFocus(el, pos);
795
+ } else {
796
+ this.elementFocus(el);
797
+ }
798
+ }
799
+ }
800
+ }
801
+ }
802
+ private clickHandler(e: Event): void {
803
+ const trgt: HTEle = <HTEle>e.target;
804
+ const ele: HTEle = this.element;
805
+ const isPopupElement: boolean = !isNOU(closest(trgt, '.' + CLS_POPUPCLASS));
806
+ let clsList: DOMTokenList = trgt.classList;
807
+ let popupNav: HTEle = <HTEle>closest(trgt, ('.' + CLS_TBARNAV));
808
+ if (!popupNav) {
809
+ popupNav = trgt;
810
+ }
811
+ if (!ele.children[0].classList.contains('e-hscroll') && !ele.children[0].classList.contains('e-vscroll')
812
+ && (clsList.contains(CLS_TBARNAV))) {
813
+ clsList = trgt.querySelector('.e-icons').classList;
814
+ }
815
+ if (clsList.contains(CLS_POPUPICON) || clsList.contains(CLS_POPUPDOWN)) {
816
+ this.popupClickHandler(ele, popupNav, CLS_RTL);
817
+ }
818
+ let itemObj: ItemModel;
819
+ const clst: HTEle = <HTEle>closest(<Node>e.target, '.' + CLS_ITEM);
820
+ if ((isNOU(clst) || clst.classList.contains(CLS_DISABLE)) && !popupNav.classList.contains(CLS_TBARNAV)) {
821
+ return;
822
+ }
823
+ if (clst) {
824
+ const tempItem: ItemModel = this.items[this.tbarEle.indexOf(clst)];
825
+ itemObj = tempItem;
826
+ }
827
+ const eventArgs: ClickEventArgs = { originalEvent: e, item: itemObj };
828
+ if (itemObj && !isNOU(itemObj.click)) {
829
+ this.trigger('items[' + this.tbarEle.indexOf(clst) + '].click', eventArgs);
830
+ }
831
+ if (!eventArgs.cancel) {
832
+ this.trigger('clicked', eventArgs, (clickedArgs: ClickEventArgs) => {
833
+ if (!isNOU(this.popObj) && isPopupElement && !clickedArgs.cancel && this.overflowMode === 'Popup' &&
834
+ clickedArgs.item && clickedArgs.item.type !== 'Input') {
835
+ this.popObj.hide({ name: 'FadeOut', duration: 100 });
836
+ }
837
+ });
838
+ }
839
+ }
840
+
841
+ private popupClickHandler(ele: HTMLElement, popupNav: HTMLElement, CLS_RTL: Str): void {
842
+ const popObj: Popup = this.popObj;
843
+ if (isVisible(popObj.element)) {
844
+ popupNav.classList.remove(CLS_TBARNAVACT);
845
+ popObj.hide({ name: 'FadeOut', duration: 100 });
846
+ } else {
847
+ if (ele.classList.contains(CLS_RTL)) {
848
+ popObj.enableRtl = true;
849
+ popObj.position = { X: 'left', Y: 'top' };
850
+ }
851
+ if (popObj.offsetX === 0 && !ele.classList.contains(CLS_RTL)) {
852
+ popObj.enableRtl = false;
853
+ popObj.position = { X: 'right', Y: 'top' };
854
+ }
855
+ popObj.dataBind();
856
+ popObj.refreshPosition();
857
+ popObj.element.style.top = this.getElementOffsetY() + 'px';
858
+ if (this.overflowMode === 'Extended') {
859
+ popObj.element.style.minHeight = '0px';
860
+ }
861
+ popupNav.classList.add(CLS_TBARNAVACT);
862
+ popObj.show({ name: 'FadeIn', duration: 100 });
863
+ }
864
+ }
865
+ /**
866
+ * To Initialize the control rendering
867
+ *
868
+ * @private
869
+ * @returns {void}
870
+ */
871
+ protected render(): void {
872
+ this.initialize();
873
+ this.renderControl();
874
+ this.wireEvents();
875
+ this.renderComplete();
876
+ }
877
+ private initialize(): void {
878
+ const width: Str = formatUnit(this.width);
879
+ const height: Str = formatUnit(this.height);
880
+ if (Browser.info.name !== 'msie' || this.height !== 'auto' || this.overflowMode === 'MultiRow') {
881
+ setStyle(this.element, { 'height': height });
882
+ }
883
+ setStyle(this.element, { 'width': width });
884
+ const ariaAttr: { [key: string]: Str } = {
885
+ 'role': 'toolbar', 'aria-disabled': 'false', 'aria-haspopup': 'false',
886
+ 'aria-orientation': !this.isVertical ? 'horizontal' : 'vertical'
887
+ };
888
+ attributes(this.element, ariaAttr);
889
+ if (this.cssClass) {
890
+ addClass([this.element], this.cssClass.split(' '));
891
+ }
892
+ }
893
+ private renderControl(): void {
894
+ const ele: HTEle = this.element;
895
+ this.trgtEle = (ele.children.length > 0) ? <HTEle>ele.querySelector('div') : null;
896
+ this.tbarAlgEle = { lefts: [], centers: [], rights: [] };
897
+ this.renderItems();
898
+ this.renderLayout();
899
+ }
900
+
901
+ private renderLayout(): void {
902
+ this.renderOverflowMode();
903
+ if (this.tbarAlign) {
904
+ this.itemPositioning();
905
+ }
906
+ if (this.popObj && this.popObj.element.childElementCount > 1 && this.checkPopupRefresh(this.element, this.popObj.element)) {
907
+ this.popupRefresh(this.popObj.element, false);
908
+ }
909
+ this.separator();
910
+ }
911
+
912
+ private itemsAlign(items: ItemModel[], itemEleDom: HTEle): void {
913
+ let innerItem: HTEle;
914
+ let innerPos: HTEle;
915
+ if (!this.tbarEle) {
916
+ this.tbarEle = [];
917
+ }
918
+ for (let i: number = 0; i < items.length; i++) {
919
+ innerItem = this.renderSubComponent(items[i], i);
920
+ if (this.tbarEle.indexOf(innerItem) === -1) {
921
+ this.tbarEle.push(innerItem);
922
+ }
923
+ if (!this.tbarAlign) {
924
+ this.tbarItemAlign(items[i], itemEleDom, i);
925
+ }
926
+ innerPos = <HTEle>itemEleDom.querySelector('.e-toolbar-' + items[i].align.toLowerCase());
927
+ if (innerPos) {
928
+ if (!(items[i].showAlwaysInPopup && items[i].overflow !== 'Show')) {
929
+ this.tbarAlgEle[(items[i].align + 's').toLowerCase() as ItmAlign].push(innerItem);
930
+ }
931
+ innerPos.appendChild(innerItem);
932
+ } else {
933
+ itemEleDom.appendChild(innerItem);
934
+ }
935
+ }
936
+ if ((this as any).isReact) {
937
+ const portals: string = 'portals';
938
+ this.notify('render-react-toolbar-template', (this as any)[portals]);
939
+ this.renderReactTemplates();
940
+ }
941
+ }
942
+
943
+ /**
944
+ * @hidden
945
+ * @returns {void}
946
+ */
947
+ public changeOrientation(): void {
948
+ const ele: HTEle = this.element;
949
+ if (this.isVertical) {
950
+ ele.classList.remove(CLS_VERTICAL);
951
+ this.isVertical = false;
952
+ if (this.height === 'auto' || this.height === '100%') {
953
+ ele.style.height = this.height;
954
+ }
955
+ ele.setAttribute('aria-orientation', 'horizontal');
956
+ } else {
957
+ ele.classList.add(CLS_VERTICAL);
958
+ this.isVertical = true;
959
+ ele.setAttribute('aria-orientation', 'vertical');
960
+ setStyle(this.element, { 'height': formatUnit(this.height), 'width': formatUnit(this.width) });
961
+ }
962
+ this.destroyMode();
963
+ this.refreshOverflow();
964
+ }
965
+ private initScroll(element: HTEle, innerItems: NodeList): void {
966
+ if (!this.scrollModule && this.checkOverflow(element, <HTEle>innerItems[0])) {
967
+ if (this.tbarAlign) {
968
+ this.element.querySelector('.' + CLS_ITEMS + ' .' + CLS_TBARCENTER).removeAttribute('style');
969
+ }
970
+ if (this.isVertical) {
971
+ this.scrollModule = new VScroll({ scrollStep: this.scrollStep, enableRtl: this.enableRtl }, <HTEle>innerItems[0]);
972
+ } else {
973
+ this.scrollModule = new HScroll({ scrollStep: this.scrollStep, enableRtl: this.enableRtl }, <HTEle>innerItems[0]);
974
+ }
975
+ this.remove(this.scrollModule.element, CLS_TBARPOS);
976
+ setStyle(this.element, { overflow: 'hidden' });
977
+ }
978
+ }
979
+ private itemWidthCal(items: HTEle): number {
980
+ let width: number = 0;
981
+ let style: CSSStyleDeclaration;
982
+ [].slice.call(selectAll('.' + CLS_ITEM, items)).forEach((el: HTEle) => {
983
+ if (isVisible(el)) {
984
+ style = window.getComputedStyle(el);
985
+ width += this.isVertical ? el.offsetHeight : el.offsetWidth;
986
+ width += parseFloat(this.isVertical ? style.marginTop : style.marginRight);
987
+ width += parseFloat(this.isVertical ? style.marginBottom : style.marginLeft);
988
+ }
989
+ });
990
+ return width;
991
+ }
992
+ private getScrollCntEle(innerItem: HTEle): HTEle {
993
+ const trgClass: Str = (this.isVertical) ? '.e-vscroll-content' : '.e-hscroll-content';
994
+ return <HTEle>innerItem.querySelector(trgClass);
995
+ }
996
+ private checkOverflow(element: HTEle, innerItem: HTEle): boolean {
997
+ if (isNOU(element) || isNOU(innerItem) || !isVisible(element)) {
998
+ return false;
999
+ }
1000
+ const eleWidth: number = this.isVertical ? element.offsetHeight : element.offsetWidth;
1001
+ let itemWidth: number = this.isVertical ? innerItem.offsetHeight : innerItem.offsetWidth;
1002
+ if (this.tbarAlign || this.scrollModule || (eleWidth === itemWidth)) {
1003
+ itemWidth = this.itemWidthCal(this.scrollModule ? this.getScrollCntEle(innerItem) : innerItem);
1004
+ }
1005
+ const popNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARNAV);
1006
+ const scrollNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARSCRLNAV);
1007
+ let navEleWidth: number = 0;
1008
+ if (popNav) {
1009
+ navEleWidth = this.isVertical ? popNav.offsetHeight : popNav.offsetWidth;
1010
+ } else if (scrollNav) {
1011
+ navEleWidth = this.isVertical ? (scrollNav.offsetHeight * (2)) : (scrollNav.offsetWidth * 2);
1012
+ }
1013
+ if (itemWidth > eleWidth - navEleWidth) {
1014
+ return true;
1015
+ } else {
1016
+ return false;
1017
+ }
1018
+ }
1019
+ /**
1020
+ * Refresh the whole Toolbar component without re-rendering.
1021
+ * - It is used to manually refresh the Toolbar overflow modes such as scrollable, popup, multi row, and extended.
1022
+ * - It will refresh the Toolbar component after loading items dynamically.
1023
+ *
1024
+ * @returns {void}.
1025
+ */
1026
+ public refreshOverflow(): void {
1027
+ this.resize();
1028
+ }
1029
+ private toolbarAlign(innerItems: HTEle): void {
1030
+ if (this.tbarAlign) {
1031
+ this.add(innerItems, CLS_TBARPOS);
1032
+ this.itemPositioning();
1033
+ }
1034
+ }
1035
+ private renderOverflowMode(): void {
1036
+ const ele: HTEle = this.element;
1037
+ const innerItems: HTEle = <HTEle>ele.querySelector('.' + CLS_ITEMS);
1038
+ const priorityCheck: boolean = this.popupPriCount > 0;
1039
+ if (ele && ele.children.length > 0) {
1040
+ this.offsetWid = ele.offsetWidth;
1041
+ this.remove(this.element, 'e-toolpop');
1042
+ if (Browser.info.name === 'msie' && this.height === 'auto') {
1043
+ ele.style.height = '';
1044
+ }
1045
+ switch (this.overflowMode) {
1046
+ case 'Scrollable':
1047
+ if (isNOU(this.scrollModule)) {
1048
+ this.initScroll(ele, [].slice.call(ele.getElementsByClassName(CLS_ITEMS)));
1049
+ }
1050
+ break;
1051
+ case 'Popup':
1052
+ this.add(this.element, 'e-toolpop');
1053
+ if (this.tbarAlign) {
1054
+ this.removePositioning();
1055
+ }
1056
+ if (this.checkOverflow(ele, innerItems) || priorityCheck) {
1057
+ this.setOverflowAttributes(ele);
1058
+ }
1059
+ this.toolbarAlign(innerItems);
1060
+ break;
1061
+ case 'MultiRow':
1062
+ this.add(innerItems, CLS_MULTIROW);
1063
+ if (this.checkOverflow(ele, innerItems) && this.tbarAlign) {
1064
+ this.removePositioning();
1065
+ this.add(innerItems, CLS_MULTIROWPOS);
1066
+ }
1067
+ if (ele.style.overflow === 'hidden') {
1068
+ ele.style.overflow = '';
1069
+ }
1070
+ if (Browser.info.name === 'msie' || ele.style.height !== 'auto') {
1071
+ ele.style.height = 'auto';
1072
+ }
1073
+ break;
1074
+ case 'Extended':
1075
+ this.add(this.element, CLS_EXTEANDABLE_TOOLBAR);
1076
+ if (this.checkOverflow(ele, innerItems) || priorityCheck) {
1077
+ if (this.tbarAlign) {
1078
+ this.removePositioning();
1079
+ }
1080
+ this.setOverflowAttributes(ele);
1081
+ }
1082
+ this.toolbarAlign(innerItems);
1083
+ }
1084
+ }
1085
+ }
1086
+
1087
+ private setOverflowAttributes(ele: HTMLElement): void {
1088
+ this.createPopupEle(ele, [].slice.call(selectAll('.' + CLS_ITEMS + ' .' + CLS_ITEM, ele)));
1089
+ this.element.querySelector('.' + CLS_TBARNAV).setAttribute('tabIndex', '0');
1090
+ this.element.querySelector('.' + CLS_TBARNAV).setAttribute('role', 'list');
1091
+ }
1092
+
1093
+ private separator(): void {
1094
+ const element: HTEle = this.element;
1095
+ const eleItem: HTEle[] = [].slice.call(element.querySelectorAll('.' + CLS_SEPARATOR));
1096
+ const multiVar: HTEle = element.querySelector('.' + CLS_MULTIROW_SEPARATOR) as HTEle;
1097
+ const extendVar: HTEle = element.querySelector('.' + CLS_EXTENDABLE_SEPARATOR) as HTEle;
1098
+ const eleInlineItem: HTEle = this.overflowMode === 'MultiRow' ? multiVar : extendVar;
1099
+ if (eleInlineItem !== null) {
1100
+ if (this.overflowMode === 'MultiRow') {
1101
+ eleInlineItem.classList.remove(CLS_MULTIROW_SEPARATOR);
1102
+ } else if (this.overflowMode === 'Extended') {
1103
+ eleInlineItem.classList.remove(CLS_EXTENDABLE_SEPARATOR);
1104
+ }
1105
+ }
1106
+ for (let i: number = 0; i <= eleItem.length - 1; i++) {
1107
+ if (eleItem[i].offsetLeft < 30 && eleItem[i].offsetLeft !== 0) {
1108
+ if (this.overflowMode === 'MultiRow') {
1109
+ eleItem[i].classList.add(CLS_MULTIROW_SEPARATOR);
1110
+ } else if (this.overflowMode === 'Extended') {
1111
+ eleItem[i].classList.add(CLS_EXTENDABLE_SEPARATOR);
1112
+ }
1113
+ }
1114
+ }
1115
+ }
1116
+
1117
+ private createPopupEle(ele: HTMLElement, innerEle: HTMLElement[]): void {
1118
+ let innerNav: HTEle = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
1119
+ const vertical: boolean = this.isVertical;
1120
+ if (!innerNav) {
1121
+ this.createPopupIcon(ele);
1122
+ }
1123
+ innerNav = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
1124
+ const innerNavDom: number = (vertical ? innerNav.offsetHeight : innerNav.offsetWidth);
1125
+ const eleWidth: number = ((vertical ? ele.offsetHeight : ele.offsetWidth) - (innerNavDom));
1126
+ this.element.classList.remove('e-rtl');
1127
+ setStyle(this.element, { direction: 'initial' });
1128
+ this.checkPriority(ele, innerEle, eleWidth, true);
1129
+ if (this.enableRtl) {
1130
+ this.element.classList.add('e-rtl');
1131
+ }
1132
+ this.element.style.removeProperty('direction');
1133
+ this.createPopup();
1134
+ }
1135
+ private pushingPoppedEle(tbarObj: Toolbar, popupPri: Element[], ele: HTEle, eleHeight: number, sepHeight: number): void {
1136
+ const element: HTEle = tbarObj.element;
1137
+ const poppedEle: HTEle[] = [].slice.call(selectAll('.' + CLS_POPUP, element.querySelector('.' + CLS_ITEMS)));
1138
+ let nodes: HTEle[] = selectAll('.' + CLS_TBAROVERFLOW, ele);
1139
+ let nodeIndex: number = 0;
1140
+ let nodePri: number = 0;
1141
+ poppedEle.forEach((el: HTEle, index: number) => {
1142
+ nodes = selectAll('.' + CLS_TBAROVERFLOW, ele);
1143
+ if (el.classList.contains(CLS_TBAROVERFLOW) && nodes.length > 0) {
1144
+ if (tbarObj.tbResize && nodes.length > index) {
1145
+ ele.insertBefore(el, nodes[index]); ++nodePri;
1146
+ } else {
1147
+ ele.insertBefore(el, ele.children[nodes.length]); ++nodePri;
1148
+ }
1149
+ } else if (el.classList.contains(CLS_TBAROVERFLOW)) {
1150
+ ele.insertBefore(el, ele.firstChild); ++nodePri;
1151
+ } else if (tbarObj.tbResize && el.classList.contains(CLS_POPOVERFLOW) && ele.children.length > 0 && nodes.length === 0) {
1152
+ ele.insertBefore(el, ele.firstChild); ++nodePri;
1153
+ } else if (el.classList.contains(CLS_POPOVERFLOW)) {
1154
+ popupPri.push(el);
1155
+ } else if (tbarObj.tbResize) {
1156
+ ele.insertBefore(el, ele.childNodes[nodeIndex + nodePri]);
1157
+ ++nodeIndex;
1158
+ } else {
1159
+ ele.appendChild(el);
1160
+ }
1161
+ if (el.classList.contains(CLS_SEPARATOR)) {
1162
+ setStyle(el, { display: '', height: sepHeight + 'px' });
1163
+ } else {
1164
+ setStyle(el, { display: '', height: eleHeight + 'px' });
1165
+ }
1166
+ });
1167
+ popupPri.forEach((el: Element) => {
1168
+ ele.appendChild(el);
1169
+ });
1170
+ const tbarEle: HTEle[] = selectAll('.' + CLS_ITEM, element.querySelector('.' + CLS_ITEMS));
1171
+ for (let i: number = tbarEle.length - 1; i >= 0; i--) {
1172
+ const tbarElement: HTEle = tbarEle[i];
1173
+ if (tbarElement.classList.contains(CLS_SEPARATOR) && this.overflowMode !== 'Extended') {
1174
+ setStyle(tbarElement, { display: 'none' });
1175
+ } else {
1176
+ break;
1177
+ }
1178
+ }
1179
+ }
1180
+ private createPopup(): void {
1181
+ const element: HTEle = this.element;
1182
+ let sepHeight: number;
1183
+ let sepItem: Element;
1184
+ if (this.overflowMode === 'Extended') {
1185
+ sepItem = element.querySelector('.' + CLS_SEPARATOR + ':not(.' + CLS_POPUP + ')');
1186
+ sepHeight = (element.style.height === 'auto' || element.style.height === '') ? null : (sepItem as HTEle).offsetHeight;
1187
+ }
1188
+ const eleItem: Element = element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + '):not(.' + CLS_POPUP + ')');
1189
+ const eleHeight: number =
1190
+ (element.style.height === 'auto' || element.style.height === '') ? null : (eleItem && (eleItem as HTEle).offsetHeight);
1191
+ let ele: HTEle;
1192
+ const popupPri: Element[] = [];
1193
+ if (select('#' + element.id + '_popup.' + CLS_POPUPCLASS, element)) {
1194
+ ele = <HTEle>select('#' + element.id + '_popup.' + CLS_POPUPCLASS, element);
1195
+ } else {
1196
+ const extendEle: HTEle = this.createElement('div', {
1197
+ id: element.id + '_popup', className: CLS_POPUPCLASS + ' ' + CLS_EXTENDABLECLASS
1198
+ });
1199
+ const popupEle: HTEle = this.createElement('div', { id: element.id + '_popup', className: CLS_POPUPCLASS });
1200
+ ele = this.overflowMode === 'Extended' ? extendEle : popupEle;
1201
+ }
1202
+ this.pushingPoppedEle(this, popupPri, ele, eleHeight, sepHeight);
1203
+ this.popupInit(element, ele);
1204
+ }
1205
+ private getElementOffsetY(): number {
1206
+ return (this.overflowMode === 'Extended' && window.getComputedStyle(this.element).getPropertyValue('box-sizing') === 'border-box' ?
1207
+ this.element.clientHeight : this.element.offsetHeight);
1208
+ }
1209
+ private popupInit(element: HTEle, ele: HTEle): void {
1210
+ if (!this.popObj) {
1211
+ element.appendChild(ele);
1212
+ setStyle(this.element, { overflow: '' });
1213
+ const eleStyles: CSSStyleDeclaration = window.getComputedStyle(this.element);
1214
+ const popup: Popup = new Popup(null, {
1215
+ relateTo: this.element,
1216
+ offsetY: (this.isVertical) ? 0 : this.getElementOffsetY(),
1217
+ enableRtl: this.enableRtl,
1218
+ open: this.popupOpen.bind(this),
1219
+ close: this.popupClose.bind(this),
1220
+ collision: { Y: this.enableCollision ? 'flip' : 'none' },
1221
+ position: this.enableRtl ? { X: 'left', Y: 'top' } : { X: 'right', Y: 'top' }
1222
+ });
1223
+ popup.appendTo(ele);
1224
+ if (this.overflowMode === 'Extended') {
1225
+ popup.width = parseFloat(eleStyles.width) + ((parseFloat(eleStyles.borderRightWidth)) * 2);
1226
+ popup.offsetX = 0;
1227
+ }
1228
+ EventHandler.add(document, 'scroll', this.docEvent.bind(this));
1229
+ EventHandler.add(document, 'click ', this.docEvent.bind(this));
1230
+ popup.element.style.maxHeight = popup.element.offsetHeight + 'px';
1231
+ if (this.isVertical) {
1232
+ popup.element.style.visibility = 'hidden';
1233
+ }
1234
+ if (this.isExtendedOpen) {
1235
+ const popupNav: HTEle = this.element.querySelector('.' + CLS_TBARNAV);
1236
+ popupNav.classList.add(CLS_TBARNAVACT);
1237
+ classList(popupNav.firstElementChild, [CLS_POPUPICON], [CLS_POPUPDOWN]);
1238
+ this.element.querySelector('.' + CLS_EXTENDABLECLASS).classList.add(CLS_POPUPOPEN);
1239
+ } else {
1240
+ popup.hide();
1241
+ }
1242
+ this.popObj = popup;
1243
+ this.element.setAttribute('aria-haspopup', 'true');
1244
+ } else {
1245
+ const popupEle: HTEle = this.popObj.element;
1246
+ setStyle(popupEle, { maxHeight: '', display: 'block' });
1247
+ setStyle(popupEle, { maxHeight: popupEle.offsetHeight + 'px', display: '' });
1248
+ }
1249
+ }
1250
+ private tbarPopupHandler(isOpen: boolean): void {
1251
+ if (this.overflowMode === 'Extended') {
1252
+ if (isOpen) {
1253
+ this.add(this.element, CLS_EXTENDEDPOPOPEN);
1254
+ } else {
1255
+ this.remove(this.element, CLS_EXTENDEDPOPOPEN);
1256
+ }
1257
+ }
1258
+ }
1259
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1260
+ private popupOpen(e: Event): void {
1261
+ const popObj: Popup = this.popObj;
1262
+ if (!this.isVertical) {
1263
+ popObj.offsetY = this.getElementOffsetY();
1264
+ popObj.dataBind();
1265
+ }
1266
+ const popupEle: HTEle = this.popObj.element;
1267
+ const toolEle: HTEle = this.popObj.element.parentElement;
1268
+ const popupNav: HTEle = <HTEle>toolEle.querySelector('.' + CLS_TBARNAV);
1269
+ setStyle(popObj.element, { height: 'auto', maxHeight: '' });
1270
+ popObj.element.style.maxHeight = popObj.element.offsetHeight + 'px';
1271
+ if (this.overflowMode === 'Extended') {
1272
+ popObj.element.style.minHeight = '';
1273
+ }
1274
+ const popupElePos: number = popupEle.offsetTop + popupEle.offsetHeight + calculatePosition(toolEle).top;
1275
+ const popIcon: Element = (popupNav.firstElementChild as Element);
1276
+ popupNav.classList.add(CLS_TBARNAVACT);
1277
+ classList(popIcon, [CLS_POPUPICON], [CLS_POPUPDOWN]);
1278
+ this.tbarPopupHandler(true);
1279
+ const scrollVal: number = isNOU(window.scrollY) ? 0 : window.scrollY;
1280
+ if (!this.isVertical && ((window.innerHeight + scrollVal) < popupElePos) && (this.element.offsetTop < popupEle.offsetHeight)) {
1281
+ let overflowHeight: number = (popupEle.offsetHeight - ((popupElePos - window.innerHeight - scrollVal) + 5));
1282
+ popObj.height = overflowHeight + 'px';
1283
+ for (let i: number = 0; i <= popupEle.childElementCount; i++) {
1284
+ const ele: HTEle = <HTEle>popupEle.children[i];
1285
+ if (ele.offsetTop + ele.offsetHeight > overflowHeight) {
1286
+ overflowHeight = ele.offsetTop;
1287
+ break;
1288
+ }
1289
+ }
1290
+ setStyle(popObj.element, { maxHeight: overflowHeight + 'px' });
1291
+ } else if (this.isVertical) {
1292
+ const tbEleData: ClientRect = this.element.getBoundingClientRect();
1293
+ setStyle(popObj.element, { maxHeight: (tbEleData.top + this.element.offsetHeight) + 'px', bottom: 0, visibility: '' });
1294
+ }
1295
+ if (popObj) {
1296
+ const popupOffset: ClientRect = popupEle.getBoundingClientRect();
1297
+ if (popupOffset.right > document.documentElement.clientWidth && popupOffset.width > toolEle.getBoundingClientRect().width) {
1298
+ popObj.collision = { Y: 'none' };
1299
+ popObj.dataBind();
1300
+ }
1301
+ popObj.refreshPosition();
1302
+ }
1303
+ }
1304
+
1305
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1306
+ private popupClose(e: Event): void {
1307
+ const element: HTEle = this.element;
1308
+ const popupNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARNAV);
1309
+ const popIcon: Element = (popupNav.firstElementChild as Element);
1310
+ popupNav.classList.remove(CLS_TBARNAVACT);
1311
+ classList(popIcon, [CLS_POPUPDOWN], [CLS_POPUPICON]);
1312
+ this.tbarPopupHandler(false);
1313
+ }
1314
+ private checkPriority(ele: HTEle, inEle: HTEle[], eleWidth: number, pre: boolean): void {
1315
+ const popPriority: boolean = this.popupPriCount > 0;
1316
+ const len: number = inEle.length;
1317
+ const eleWid: number = eleWidth;
1318
+ let eleOffset: number;
1319
+ let checkoffset: boolean;
1320
+ let sepCheck: number = 0; let itemCount: number = 0; let itemPopCount: number = 0;
1321
+ const checkClass: (ele: HTEle, val: Str[]) => boolean = (ele: HTEle, val: Str[]) => {
1322
+ let rVal: boolean = false;
1323
+ val.forEach((cls: string) => {
1324
+ if (ele.classList.contains(cls)) {
1325
+ rVal = true;
1326
+ }
1327
+ });
1328
+ return rVal;
1329
+ };
1330
+ for (let i: number = len - 1; i >= 0; i--) {
1331
+ let mrgn: number;
1332
+ const compuStyle: CSSStyleDeclaration = window.getComputedStyle(inEle[i]);
1333
+ if (this.isVertical) {
1334
+ mrgn = parseFloat((compuStyle).marginTop);
1335
+ mrgn += parseFloat((compuStyle).marginBottom);
1336
+ } else {
1337
+ mrgn = parseFloat((compuStyle).marginRight);
1338
+ mrgn += parseFloat((compuStyle).marginLeft);
1339
+ }
1340
+ const fstEleCheck: boolean = inEle[i] === this.tbarEle[0];
1341
+ if (fstEleCheck) {
1342
+ this.tbarEleMrgn = mrgn;
1343
+ }
1344
+ eleOffset = this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth;
1345
+ const eleWid: number = fstEleCheck ? (eleOffset + mrgn) : eleOffset;
1346
+ if (checkClass(inEle[i], [CLS_POPPRI]) && popPriority) {
1347
+ inEle[i].classList.add(CLS_POPUP);
1348
+ if (this.isVertical) {
1349
+ setStyle(inEle[i], { display: 'none', minHeight: eleWid + 'px' });
1350
+ } else {
1351
+ setStyle(inEle[i], { display: 'none', minWidth: eleWid + 'px' });
1352
+ }
1353
+ itemPopCount++;
1354
+ }
1355
+ if (this.isVertical) {
1356
+ checkoffset = (inEle[i].offsetTop + inEle[i].offsetHeight + mrgn) > eleWidth;
1357
+ } else {
1358
+ checkoffset = (inEle[i].offsetLeft + inEle[i].offsetWidth + mrgn) > eleWidth;
1359
+ }
1360
+ if (checkoffset) {
1361
+ if (inEle[i].classList.contains(CLS_SEPARATOR)) {
1362
+ if (this.overflowMode === 'Extended') {
1363
+ if (itemCount === itemPopCount) {
1364
+ const sepEle: HTEle = (inEle[i] as HTEle);
1365
+ if (checkClass(sepEle, [CLS_SEPARATOR, CLS_TBARIGNORE])) {
1366
+ inEle[i].classList.add(CLS_POPUP);
1367
+ itemPopCount++;
1368
+ }
1369
+ }
1370
+ itemCount++;
1371
+ } else if (this.overflowMode === 'Popup') {
1372
+ if (sepCheck > 0 && itemCount === itemPopCount) {
1373
+ const sepEle: HTEle = (inEle[i + itemCount + (sepCheck - 1)] as HTEle);
1374
+ if (checkClass(sepEle, [CLS_SEPARATOR, CLS_TBARIGNORE])) {
1375
+ setStyle(sepEle, { display: 'none' });
1376
+ }
1377
+ }
1378
+ sepCheck++; itemCount = 0; itemPopCount = 0;
1379
+ }
1380
+ } else {
1381
+ itemCount++;
1382
+ }
1383
+ if (inEle[i].classList.contains(CLS_TBAROVERFLOW) && pre) {
1384
+ eleWidth -= ((this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth) + (mrgn));
1385
+ } else if (!checkClass(inEle[i], [CLS_SEPARATOR, CLS_TBARIGNORE])) {
1386
+ inEle[i].classList.add(CLS_POPUP);
1387
+ if (this.isVertical) {
1388
+ setStyle(inEle[i], { display: 'none', minHeight: eleWid + 'px' });
1389
+ } else {
1390
+ setStyle(inEle[i], { display: 'none', minWidth: eleWid + 'px' });
1391
+ }
1392
+ itemPopCount++;
1393
+ } else {
1394
+ eleWidth -= ((this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth) + (mrgn));
1395
+ }
1396
+ }
1397
+ }
1398
+ if (pre) {
1399
+ const popedEle: HTEle[] = selectAll('.' + CLS_ITEM + ':not(.' + CLS_POPUP + ')', this.element);
1400
+ this.checkPriority(ele, popedEle, eleWid, false);
1401
+ }
1402
+ }
1403
+
1404
+ private createPopupIcon(element: HTEle): void {
1405
+ const id: Str = element.id.concat('_nav');
1406
+ let className: Str = 'e-' + element.id.concat('_nav ' + CLS_POPUPNAV);
1407
+ className = this.overflowMode === 'Extended' ? className + ' ' + CLS_EXTENDPOPUP : className;
1408
+ const nav: HTEle = this.createElement('div', { id: id, className: className });
1409
+ if (Browser.info.name === 'msie' || Browser.info.name === 'edge') {
1410
+ nav.classList.add('e-ie-align');
1411
+ }
1412
+ const navItem: HTEle = this.createElement('div', { className: CLS_POPUPDOWN + ' e-icons' });
1413
+ nav.appendChild(navItem);
1414
+ nav.setAttribute('tabindex', '0');
1415
+ nav.setAttribute('role', 'list');
1416
+ element.appendChild(nav);
1417
+ }
1418
+
1419
+ private tbarPriRef(inEle: HTEle, indx: number, sepPri: number, el: HTEle, des: boolean, elWid: number, wid: number, ig: number): void {
1420
+ const ignoreCount: number = ig;
1421
+ const popEle: HTEle = this.popObj.element;
1422
+ const query: Str = '.' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + '):not(.' + CLS_TBAROVERFLOW + ')';
1423
+ const priEleCnt: number = selectAll('.' + CLS_POPUP + ':not(.' + CLS_TBAROVERFLOW + ')', popEle).length;
1424
+ const checkClass: (ele: HTEle, val: Str) => boolean = (ele: HTEle, val: Str) => {
1425
+ return ele.classList.contains(val);
1426
+ };
1427
+ if (selectAll(query, inEle).length === 0) {
1428
+ const eleSep: HTEle = inEle.children[indx - (indx - sepPri) - 1] as HTEle;
1429
+ const ignoreCheck: boolean = (!isNOU(eleSep) && checkClass(eleSep, CLS_TBARIGNORE));
1430
+ if ((!isNOU(eleSep) && checkClass(eleSep, CLS_SEPARATOR) && !isVisible(eleSep)) || ignoreCheck) {
1431
+ const sepDisplay: Str = 'none';
1432
+ eleSep.style.display = 'inherit';
1433
+ const eleSepWidth: number = eleSep.offsetWidth + (parseFloat(window.getComputedStyle(eleSep).marginRight) * 2);
1434
+ const prevSep: HTEle = eleSep.previousElementSibling as HTEle;
1435
+ if ((elWid + eleSepWidth) < wid || des) {
1436
+ inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - (indx - sepPri)]);
1437
+ if (!isNOU(prevSep)) {
1438
+ prevSep.style.display = '';
1439
+ }
1440
+ } else {
1441
+ if (prevSep.classList.contains(CLS_SEPARATOR)) {
1442
+ prevSep.style.display = sepDisplay;
1443
+ }
1444
+ }
1445
+ eleSep.style.display = '';
1446
+ } else {
1447
+ inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - (indx - sepPri)]);
1448
+ }
1449
+ } else {
1450
+ inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - priEleCnt]);
1451
+ }
1452
+ }
1453
+
1454
+ private popupRefresh(popupEle: HTMLElement, destroy: boolean): void {
1455
+ const ele: HTEle = this.element;
1456
+ const isVer: boolean = this.isVertical;
1457
+ const innerEle: HTEle = <HTEle>ele.querySelector('.' + CLS_ITEMS);
1458
+ let popNav: HTEle = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
1459
+ if (isNOU(popNav)) {
1460
+ return;
1461
+ }
1462
+ innerEle.removeAttribute('style');
1463
+ popupEle.style.display = 'block';
1464
+ let dimension: number;
1465
+ if (isVer) {
1466
+ dimension = ele.offsetHeight - (popNav.offsetHeight + innerEle.offsetHeight);
1467
+ } else {
1468
+ dimension = ele.offsetWidth - (popNav.offsetWidth + innerEle.offsetWidth);
1469
+ }
1470
+ let popupEleWidth: number = 0;
1471
+ [].slice.call(popupEle.children).forEach((el: HTMLElement): void => {
1472
+ popupEleWidth += this.popupEleWidth(el);
1473
+ setStyle(el, { 'position': '' });
1474
+ });
1475
+ if ((dimension + (isVer ? popNav.offsetHeight : popNav.offsetWidth)) > (popupEleWidth) && this.popupPriCount === 0) {
1476
+ destroy = true;
1477
+ }
1478
+ this.popupEleRefresh(dimension, popupEle, destroy);
1479
+ popupEle.style.display = '';
1480
+ if (popupEle.children.length === 0 && popNav && this.popObj) {
1481
+ detach(popNav);
1482
+ popNav = null;
1483
+ this.popObj.destroy();
1484
+ detach(this.popObj.element);
1485
+ this.popObj = null;
1486
+ ele.setAttribute('aria-haspopup', 'false');
1487
+ }
1488
+ }
1489
+ private ignoreEleFetch(index: number, innerEle: HTEle): number {
1490
+ const ignoreEle: HTEle[] = [].slice.call(innerEle.querySelectorAll('.' + CLS_TBARIGNORE));
1491
+ const ignoreInx: number[] = [];
1492
+ let count: number = 0;
1493
+ if (ignoreEle.length > 0) {
1494
+ ignoreEle.forEach((ele: HTEle): void => {
1495
+ ignoreInx.push([].slice.call(innerEle.children).indexOf(ele));
1496
+ });
1497
+ } else {
1498
+ return 0;
1499
+ }
1500
+ ignoreInx.forEach((val: number): void => {
1501
+ if (val <= index) {
1502
+ count++;
1503
+ }
1504
+ });
1505
+ return count;
1506
+ }
1507
+ private checkPopupRefresh(root: HTEle, popEle: HTEle): boolean {
1508
+ popEle.style.display = 'block';
1509
+ const elWid: number = this.popupEleWidth(<HTEle>popEle.firstElementChild);
1510
+ (<HTEle>popEle.firstElementChild).style.removeProperty('Position');
1511
+ const tbarWidth: number = root.offsetWidth - (<HTEle>root.querySelector('.' + CLS_TBARNAV)).offsetWidth;
1512
+ const tbarItemsWid: number = (<HTEle>root.querySelector('.' + CLS_ITEMS)).offsetWidth;
1513
+ popEle.style.removeProperty('display');
1514
+ if (tbarWidth > (elWid + tbarItemsWid)) {
1515
+ return true;
1516
+ }
1517
+ return false;
1518
+ }
1519
+ private popupEleWidth(el: HTEle): number {
1520
+ el.style.position = 'absolute';
1521
+ let elWidth: number = this.isVertical ? el.offsetHeight : el.offsetWidth;
1522
+ const btnText: HTEle = <HTEle>el.querySelector('.' + CLS_TBARBTNTEXT);
1523
+ if (el.classList.contains('e-tbtn-align') || el.classList.contains(CLS_TBARTEXT)) {
1524
+ const btn: HTEle = <HTEle>el.children[0];
1525
+ if (!isNOU(btnText) && el.classList.contains(CLS_TBARTEXT)) {
1526
+ btnText.style.display = 'none';
1527
+ } else if (!isNOU(btnText) && el.classList.contains(CLS_POPUPTEXT)) {
1528
+ btnText.style.display = 'block';
1529
+ }
1530
+ btn.style.minWidth = '0%';
1531
+ elWidth = parseFloat(!this.isVertical ? el.style.minWidth : el.style.minHeight);
1532
+ btn.style.minWidth = '';
1533
+ btn.style.minHeight = '';
1534
+ if (!isNOU(btnText)) {
1535
+ btnText.style.display = '';
1536
+ }
1537
+ }
1538
+ return elWidth;
1539
+ }
1540
+ private popupEleRefresh(width: number, popupEle: HTEle, destroy: boolean): void {
1541
+ const popPriority: boolean = this.popupPriCount > 0;
1542
+ let eleSplice: HTEle[] = this.tbarEle;
1543
+ let priEleCnt: number;
1544
+ let index: number;
1545
+ let innerEle: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
1546
+ let ignoreCount: number = 0;
1547
+ for (const el of [].slice.call(popupEle.children)) {
1548
+ if (el.classList.contains(CLS_POPPRI) && popPriority && !destroy) {
1549
+ continue;
1550
+ }
1551
+ let elWidth: number = this.popupEleWidth(el);
1552
+ if (el === this.tbarEle[0]) {
1553
+ elWidth += this.tbarEleMrgn;
1554
+ }
1555
+ el.style.position = '';
1556
+ if (elWidth < width || destroy) {
1557
+ setStyle(el, { minWidth: '', height: '', minHeight: '' });
1558
+ if (!el.classList.contains(CLS_POPOVERFLOW)) {
1559
+ el.classList.remove(CLS_POPUP);
1560
+ }
1561
+ index = this.tbarEle.indexOf(el);
1562
+ if (this.tbarAlign) {
1563
+ const pos: ItemAlign = this.items[index].align;
1564
+ index = this.tbarAlgEle[(pos + 's').toLowerCase() as ItmAlign].indexOf(el);
1565
+ eleSplice = this.tbarAlgEle[(pos + 's').toLowerCase() as ItmAlign];
1566
+ innerEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS + ' .' + 'e-toolbar-' + pos.toLowerCase());
1567
+ }
1568
+ let sepBeforePri: number = 0;
1569
+ if (this.overflowMode !== 'Extended') {
1570
+ eleSplice.slice(0, index).forEach((el: HTEle) => {
1571
+ if (el.classList.contains(CLS_TBAROVERFLOW) || el.classList.contains(CLS_SEPARATOR)) {
1572
+ if (el.classList.contains(CLS_SEPARATOR)) {
1573
+ el.style.display = '';
1574
+ width -= el.offsetWidth;
1575
+ }
1576
+ sepBeforePri++;
1577
+ }
1578
+ });
1579
+ }
1580
+ ignoreCount = this.ignoreEleFetch(index, innerEle);
1581
+ if (el.classList.contains(CLS_TBAROVERFLOW)) {
1582
+ this.tbarPriRef(innerEle, index, sepBeforePri, el, destroy, elWidth, width, ignoreCount);
1583
+ width -= el.offsetWidth;
1584
+ } else if (index === 0) {
1585
+ innerEle.insertBefore(el, innerEle.firstChild);
1586
+ width -= el.offsetWidth;
1587
+ } else {
1588
+ priEleCnt = selectAll('.' + CLS_TBAROVERFLOW, this.popObj.element).length;
1589
+ innerEle.insertBefore(el, innerEle.children[(index + ignoreCount) - priEleCnt]);
1590
+ width -= el.offsetWidth;
1591
+ }
1592
+ el.style.height = '';
1593
+ } else {
1594
+ break;
1595
+ }
1596
+ }
1597
+ const checkOverflow: boolean = this.checkOverflow(this.element, this.element.getElementsByClassName(CLS_ITEMS)[0] as HTEle);
1598
+ if (checkOverflow && !destroy) {
1599
+ this.renderOverflowMode();
1600
+ }
1601
+ }
1602
+ private removePositioning(): void {
1603
+ const item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
1604
+ if (isNOU(item) || !item.classList.contains(CLS_TBARPOS)) {
1605
+ return;
1606
+ }
1607
+ this.remove(item, CLS_TBARPOS);
1608
+ const innerItem: HTEle[] = [].slice.call(item.childNodes);
1609
+ innerItem[1].removeAttribute('style');
1610
+ innerItem[2].removeAttribute('style');
1611
+ }
1612
+ private refreshPositioning(): void {
1613
+ const item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
1614
+ this.add(item, CLS_TBARPOS);
1615
+ this.itemPositioning();
1616
+ }
1617
+ private itemPositioning(): void {
1618
+ const item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
1619
+ let margin: number;
1620
+ if (isNOU(item) || !item.classList.contains(CLS_TBARPOS)) {
1621
+ return;
1622
+ }
1623
+ const popupNav: HTEle = <HTEle>this.element.querySelector('.' + CLS_TBARNAV);
1624
+ let innerItem: HTEle[];
1625
+ if (this.scrollModule) {
1626
+ const trgClass: Str = (this.isVertical) ? CLS_VSCROLLCNT : CLS_HSCROLLCNT;
1627
+ innerItem = [].slice.call(item.querySelector('.' + trgClass).children);
1628
+ } else {
1629
+ innerItem = [].slice.call(item.childNodes);
1630
+ }
1631
+ if (this.isVertical) {
1632
+ margin = innerItem[0].offsetHeight + innerItem[2].offsetHeight;
1633
+ } else {
1634
+ margin = innerItem[0].offsetWidth + innerItem[2].offsetWidth;
1635
+ }
1636
+ let tbarWid: number = this.isVertical ? this.element.offsetHeight : this.element.offsetWidth;
1637
+ if (popupNav) {
1638
+ tbarWid -= (this.isVertical ? popupNav.offsetHeight : popupNav.offsetWidth);
1639
+ const popWid: string = (this.isVertical ? popupNav.offsetHeight : popupNav.offsetWidth) + 'px';
1640
+ innerItem[2].removeAttribute('style');
1641
+ if (this.isVertical) {
1642
+ if (this.enableRtl) {
1643
+ innerItem[2].style.top = popWid;
1644
+ } else {
1645
+ innerItem[2].style.bottom = popWid;
1646
+ }
1647
+ } else {
1648
+ if (this.enableRtl) {
1649
+ innerItem[2].style.left = popWid;
1650
+ } else {
1651
+ innerItem[2].style.right = popWid;
1652
+ }
1653
+ }
1654
+ }
1655
+ if (tbarWid <= margin) {
1656
+ return;
1657
+ }
1658
+ const value: number = (((tbarWid - margin)) - (!this.isVertical ? innerItem[1].offsetWidth : innerItem[1].offsetHeight)) / 2;
1659
+ innerItem[1].removeAttribute('style');
1660
+ const mrgn: Str = ((!this.isVertical ? innerItem[0].offsetWidth : innerItem[0].offsetHeight) + value) + 'px';
1661
+ if (this.isVertical) {
1662
+ if (this.enableRtl) {
1663
+ innerItem[1].style.marginBottom = mrgn;
1664
+ } else {
1665
+ innerItem[1].style.marginTop = mrgn;
1666
+ }
1667
+ } else {
1668
+ if (this.enableRtl) {
1669
+ innerItem[1].style.marginRight = mrgn;
1670
+ } else {
1671
+ innerItem[1].style.marginLeft = mrgn;
1672
+ }
1673
+ }
1674
+ }
1675
+ private tbarItemAlign(item: ItemModel, itemEle: HTEle, pos: number): void {
1676
+ if (item.showAlwaysInPopup && item.overflow !== 'Show') {
1677
+ return;
1678
+ }
1679
+ const alignDiv: HTMLElement[] = [];
1680
+ alignDiv.push(this.createElement('div', { className: CLS_TBARLEFT }));
1681
+ alignDiv.push(this.createElement('div', { className: CLS_TBARCENTER }));
1682
+ alignDiv.push(this.createElement('div', { className: CLS_TBARRIGHT }));
1683
+ if (pos === 0 && item.align !== 'Left') {
1684
+ alignDiv.forEach((ele: HTEle) => {
1685
+ itemEle.appendChild(ele);
1686
+ });
1687
+ this.tbarAlign = true;
1688
+ this.add(itemEle, CLS_TBARPOS);
1689
+ } else if (item.align !== 'Left') {
1690
+ const alignEle: NodeList = itemEle.childNodes;
1691
+ const leftAlign: HTEle = alignDiv[0];
1692
+ [].slice.call(alignEle).forEach((el: HTEle) => {
1693
+ this.tbarAlgEle.lefts.push(el);
1694
+ leftAlign.appendChild(el);
1695
+ });
1696
+ itemEle.appendChild(leftAlign);
1697
+ itemEle.appendChild(alignDiv[1]);
1698
+ itemEle.appendChild(alignDiv[2]);
1699
+ this.tbarAlign = true;
1700
+ this.add(itemEle, CLS_TBARPOS);
1701
+ }
1702
+ }
1703
+ private ctrlTemplate(): void {
1704
+ this.ctrlTem = <HTEle>this.trgtEle.cloneNode(true);
1705
+ this.add(this.trgtEle, CLS_ITEMS);
1706
+ this.tbarEle = [];
1707
+ const innerEle: HTEle[] = [].slice.call(this.trgtEle.children);
1708
+ innerEle.forEach((ele: HTEle) => {
1709
+ if (ele.tagName === 'DIV') {
1710
+ this.tbarEle.push(ele);
1711
+ ele.setAttribute('aria-disabled', 'false');
1712
+ this.add(ele, CLS_ITEM);
1713
+ }
1714
+ });
1715
+ }
1716
+ private renderItems(): void {
1717
+ const ele: HTEle = this.element;
1718
+ const items: Item[] = <Item[]>this.items;
1719
+ if (this.trgtEle != null) {
1720
+ this.ctrlTemplate();
1721
+ } else if (ele && items.length > 0) {
1722
+ let itemEleDom: HTEle;
1723
+ if (ele && ele.children.length > 0) {
1724
+ itemEleDom = <HTEle>ele.querySelector('.' + CLS_ITEMS);
1725
+ }
1726
+ if (!itemEleDom) {
1727
+ itemEleDom = this.createElement('div', { className: CLS_ITEMS });
1728
+ }
1729
+ this.itemsAlign(items, itemEleDom);
1730
+ ele.appendChild(itemEleDom);
1731
+ }
1732
+ }
1733
+ private setAttr(attr: { [key: string]: Str }, element: HTEle): void {
1734
+ const key: Object[] = Object.keys(attr);
1735
+ let keyVal: Str;
1736
+ for (let i: number = 0; i < key.length; i++) {
1737
+ keyVal = key[i] as Str;
1738
+ if (keyVal === 'class') {
1739
+ this.add(element, attr[keyVal]);
1740
+ } else {
1741
+ element.setAttribute(keyVal, attr[keyVal]);
1742
+ }
1743
+ }
1744
+ }
1745
+ /**
1746
+ * Enables or disables the specified Toolbar item.
1747
+ *
1748
+ * @param {number|HTMLElement|NodeList} items - DOM element or an array of items to be enabled or disabled.
1749
+ * @param {boolean} isEnable - Boolean value that determines whether the command should be enabled or disabled.
1750
+ * By default, `isEnable` is set to true.
1751
+ * @returns {void}.
1752
+ */
1753
+ public enableItems(items: number | HTMLElement | NodeList, isEnable?: boolean): void {
1754
+ const elements: NodeList = <NodeList>items;
1755
+ const len: number = elements.length;
1756
+ let ele: HTEle | number;
1757
+ if (isNOU(isEnable)) {
1758
+ isEnable = true;
1759
+ }
1760
+ const enable: (isEnable: boolean, ele: HTEle) => void = (isEnable: boolean, ele: HTEle) => {
1761
+ if (isEnable) {
1762
+ ele.classList.remove(CLS_DISABLE);
1763
+ ele.setAttribute('aria-disabled', 'false');
1764
+ } else {
1765
+ ele.classList.add(CLS_DISABLE);
1766
+ ele.setAttribute('aria-disabled', 'true');
1767
+ }
1768
+ };
1769
+ if (!isNOU(len) && len >= 1) {
1770
+ for (let a: number = 0, element: HTEle[] = [].slice.call(elements); a < len; a++) {
1771
+ const itemElement: HTEle = element[a];
1772
+ if (typeof (itemElement) === 'number') {
1773
+ ele = this.getElementByIndex(itemElement);
1774
+ if (isNOU(ele)) {
1775
+ return;
1776
+ } else {
1777
+ elements[a] = ele;
1778
+ }
1779
+ } else {
1780
+ ele = itemElement;
1781
+ }
1782
+ enable(isEnable, ele);
1783
+ }
1784
+ if (isEnable) {
1785
+ removeClass(elements, CLS_DISABLE);
1786
+ } else {
1787
+ addClass(elements, CLS_DISABLE);
1788
+ }
1789
+ } else {
1790
+ if (typeof (elements) === 'number') {
1791
+ ele = this.getElementByIndex(elements);
1792
+ if (isNOU(ele)) {
1793
+ return;
1794
+ }
1795
+ } else {
1796
+ ele = <HTEle>items;
1797
+ }
1798
+ enable(isEnable, ele);
1799
+ }
1800
+ }
1801
+ private getElementByIndex(index: number): HTEle {
1802
+ if (this.tbarEle[index]) {
1803
+ return this.tbarEle[index];
1804
+ }
1805
+ return null;
1806
+ }
1807
+ /**
1808
+ * Adds new items to the Toolbar that accepts an array as Toolbar items.
1809
+ *
1810
+ * @param {ItemModel[]} items - DOM element or an array of items to be added to the Toolbar.
1811
+ * @param {number} index - Number value that determines where the command is to be added. By default, index is 0.
1812
+ * @returns {void}.
1813
+ */
1814
+ public addItems(items: ItemModel[], index?: number): void {
1815
+ let innerItems: HTEle[];
1816
+ this.extendedOpen();
1817
+ const itemsDiv: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
1818
+ if (isNOU(itemsDiv)) {
1819
+ this.itemsRerender(items);
1820
+ return;
1821
+ }
1822
+ let innerEle: HTEle;
1823
+ let itemAgn: Str = 'Left';
1824
+ if (isNOU(index)) {
1825
+ index = 0;
1826
+ }
1827
+ items.forEach((e: ItemModel) => {
1828
+ if (!isNOU(e.align) && e.align !== 'Left' && itemAgn === 'Left') {
1829
+ itemAgn = e.align;
1830
+ }
1831
+ });
1832
+ for (const item of items) {
1833
+ if (isNOU(item.type)) {
1834
+ item.type = 'Button';
1835
+ }
1836
+ innerItems = selectAll('.' + CLS_ITEM, this.element);
1837
+ item.align = <ItemAlign>itemAgn;
1838
+ innerEle = this.renderSubComponent(item, index);
1839
+ if (this.tbarEle.length >= index && innerItems.length >= 0) {
1840
+ if (isNOU(this.scrollModule)) {
1841
+ this.destroyMode();
1842
+ }
1843
+ const algIndex: number = item.align[0] === 'L' ? 0 : item.align[0] === 'C' ? 1 : 2;
1844
+ let ele: Element;
1845
+ if (!this.tbarAlign && itemAgn !== 'Left') {
1846
+ this.tbarItemAlign(item, itemsDiv, 1);
1847
+ this.tbarAlign = true;
1848
+ ele = closest(innerItems[0], '.' + CLS_ITEMS).children[algIndex];
1849
+ ele.appendChild(innerEle);
1850
+ this.tbarAlgEle[(item.align + 's').toLowerCase() as ItmAlign].push(innerEle);
1851
+ this.refreshPositioning();
1852
+ } else if (this.tbarAlign) {
1853
+ ele = closest(innerItems[0], '.' + CLS_ITEMS).children[algIndex];
1854
+ ele.insertBefore(innerEle, ele.children[index]);
1855
+ this.tbarAlgEle[(item.align + 's').toLowerCase() as ItmAlign].splice(index, 0, innerEle);
1856
+ this.refreshPositioning();
1857
+ } else if (innerItems.length === 0) {
1858
+ innerItems = selectAll('.' + CLS_ITEMS, this.element);
1859
+ innerItems[0].appendChild(innerEle);
1860
+ } else {
1861
+ innerItems[0].parentNode.insertBefore(innerEle, innerItems[index]);
1862
+ }
1863
+ this.items.splice(index, 0, item);
1864
+ if (item.template) {
1865
+ this.tbarEle.splice(this.tbarEle.length - 1, 1);
1866
+ }
1867
+ this.tbarEle.splice(index, 0, innerEle);
1868
+ index++;
1869
+ this.offsetWid = itemsDiv.offsetWidth;
1870
+ }
1871
+ }
1872
+ itemsDiv.style.width = '';
1873
+ this.renderOverflowMode();
1874
+ if ((this as any).isReact) {
1875
+ this.renderReactTemplates();
1876
+ }
1877
+ }
1878
+ /**
1879
+ * Removes the items from the Toolbar. Acceptable arguments are index of item/HTMLElement/node list.
1880
+ *
1881
+ * @param {number|HTMLElement|NodeList|HTMLElement[]} args
1882
+ * Index or DOM element or an Array of item which is to be removed from the Toolbar.
1883
+ * @returns {void}.
1884
+ */
1885
+ public removeItems(args: number | HTMLElement | NodeList | Element | HTMLElement[]): void {
1886
+ const elements: NodeList = <NodeList>args;
1887
+ let index: number;
1888
+ let innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
1889
+ if (typeof (elements) === 'number') {
1890
+ index = parseInt(args.toString(), 10);
1891
+ this.removeItemByIndex(index, innerItems);
1892
+ } else {
1893
+ if (elements && elements.length > 1) {
1894
+ for (const ele of [].slice.call(elements)) {
1895
+ index = this.tbarEle.indexOf(ele);
1896
+ this.removeItemByIndex(index, innerItems);
1897
+ innerItems = selectAll('.' + CLS_ITEM, this.element);
1898
+ }
1899
+ } else {
1900
+ const ele: HTEle = (elements && elements.length && elements.length === 1) ? <HTEle>elements[0] : <HTEle>args;
1901
+ index = innerItems.indexOf(ele);
1902
+ this.removeItemByIndex(index, innerItems);
1903
+ }
1904
+ }
1905
+ this.resize();
1906
+ }
1907
+ private removeItemByIndex(index: number, innerItems: HTEle[]): void {
1908
+ if (this.tbarEle[index] && innerItems[index]) {
1909
+ const eleIdx: number = this.tbarEle.indexOf(innerItems[index]);
1910
+ if (this.tbarAlign) {
1911
+ const indexAgn: number =
1912
+ this.tbarAlgEle[(this.items[eleIdx].align + 's').toLowerCase() as ItmAlign].indexOf(this.tbarEle[eleIdx]);
1913
+ this.tbarAlgEle[(this.items[eleIdx].align + 's').toLowerCase() as ItmAlign].splice(indexAgn, 1);
1914
+ }
1915
+ if ((this as any).isReact) {
1916
+ this.clearTemplate();
1917
+ }
1918
+ const btnItem: EJ2Instance = innerItems[index].querySelector('.e-control.e-btn');
1919
+ if (!isNOU(btnItem) && !isNOU(btnItem.ej2_instances[0]) && !((btnItem.ej2_instances[0] as Button).isDestroyed)) {
1920
+ (btnItem.ej2_instances[0] as Button).destroy();
1921
+ }
1922
+ detach(innerItems[index]);
1923
+ this.items.splice(eleIdx, 1);
1924
+ this.tbarEle.splice(eleIdx, 1);
1925
+ }
1926
+ }
1927
+ private templateRender(templateProp: Object | Str, innerEle: HTEle, item: ItemModel, index: number): void {
1928
+ const itemType: Str = item.type;
1929
+ const eleObj: Template = <Template>templateProp;
1930
+ let isComponent: boolean;
1931
+ if (typeof (templateProp) === 'object') {
1932
+ isComponent = typeof (eleObj.appendTo) === 'function';
1933
+ }
1934
+ if (typeof (templateProp) === 'string' || !isComponent) {
1935
+ let templateFn: Function;
1936
+ let val: Str = <Str>templateProp;
1937
+ const regEx: RegExp = new RegExp(/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i);
1938
+ val = (typeof (templateProp) === 'string') ? <Str>templateProp.trim() : <Str>templateProp;
1939
+ try {
1940
+ if (typeof (templateProp) === 'object' && !isNOU((templateProp as HTEle).tagName)) {
1941
+ innerEle.appendChild(templateProp as HTEle);
1942
+ } else if (typeof (templateProp) === 'string' && regEx.test(val)) {
1943
+ innerEle.innerHTML = val;
1944
+ } else if (document.querySelectorAll(val).length) {
1945
+ const ele: Element = document.querySelector(val);
1946
+ const tempStr: Str = ele.outerHTML.trim();
1947
+ innerEle.appendChild(ele);
1948
+ (<HTMLElement>ele).style.display = '';
1949
+ if (!isNOU(tempStr)) {
1950
+ this.tempId.push(val);
1951
+ }
1952
+ } else {
1953
+ templateFn = templateCompiler(val);
1954
+ }
1955
+ } catch (e) {
1956
+ templateFn = templateCompiler(val);
1957
+ }
1958
+ let tempArray: HTEle[];
1959
+ if (!isNOU(templateFn)) {
1960
+ const toolbarTemplateID: string = this.element.id + index + '_template';
1961
+ tempArray = templateFn({}, this, 'template', toolbarTemplateID, this.isStringTemplate);
1962
+ }
1963
+ if (!isNOU(tempArray) && tempArray.length > 0) {
1964
+ [].slice.call(tempArray).forEach((ele: HTEle): void => {
1965
+ if (!isNOU(ele.tagName)) {
1966
+ ele.style.display = '';
1967
+ }
1968
+ innerEle.appendChild(ele);
1969
+ });
1970
+ }
1971
+ } else if (itemType === 'Input') {
1972
+ const ele: HTEle = this.createElement('input');
1973
+ if (item.id) {
1974
+ ele.id = item.id;
1975
+ } else {
1976
+ ele.id = getUniqueID('tbr-ipt');
1977
+ }
1978
+ innerEle.appendChild(ele);
1979
+ eleObj.appendTo(ele);
1980
+ }
1981
+ this.add(innerEle, CLS_TEMPLATE);
1982
+ this.tbarEle.push(innerEle);
1983
+ }
1984
+ private buttonRendering(item: ItemModel, innerEle: HTEle): HTEle {
1985
+ const dom: HTEle = this.createElement('button', { className: CLS_TBARBTN });
1986
+ dom.setAttribute('type', 'button');
1987
+ const textStr: Str = item.text;
1988
+ let iconCss: Str;
1989
+ let iconPos: Str;
1990
+ if (item.id) {
1991
+ dom.id = item.id;
1992
+ } else {
1993
+ dom.id = getUniqueID('e-tbr-btn');
1994
+ }
1995
+ const btnTxt: HTEle = this.createElement('span', { className: 'e-tbar-btn-text' });
1996
+ if (textStr) {
1997
+ btnTxt.innerHTML = this.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(textStr) : textStr;
1998
+ dom.appendChild(btnTxt);
1999
+ dom.classList.add('e-tbtn-txt');
2000
+ } else {
2001
+ this.add(innerEle, 'e-tbtn-align');
2002
+ }
2003
+ if (item.prefixIcon || item.suffixIcon) {
2004
+ if ((item.prefixIcon && item.suffixIcon) || item.prefixIcon) {
2005
+ iconCss = item.prefixIcon + ' e-icons';
2006
+ iconPos = 'Left';
2007
+ } else {
2008
+ iconCss = item.suffixIcon + ' e-icons';
2009
+ iconPos = 'Right';
2010
+ }
2011
+ }
2012
+ const btnObj: Button = new Button({ iconCss: iconCss, iconPosition: <IconPosition>iconPos });
2013
+ btnObj.createElement = this.createElement;
2014
+ btnObj.appendTo(dom as HTMLButtonElement);
2015
+ if (item.width) {
2016
+ setStyle(dom, { 'width': formatUnit(item.width) });
2017
+ }
2018
+ return dom;
2019
+ }
2020
+ private renderSubComponent(item: ItemModel, index: number): HTEle {
2021
+ let dom: HTEle;
2022
+ const innerEle: HTEle = this.createElement('div', { className: CLS_ITEM });
2023
+ innerEle.setAttribute('aria-disabled', 'false');
2024
+ const tempDom: HTEle = this.createElement('div', {
2025
+ innerHTML: this.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(item.tooltipText) : item.tooltipText
2026
+ });
2027
+ if (!this.tbarEle) {
2028
+ this.tbarEle = [];
2029
+ }
2030
+ if (item.htmlAttributes) {
2031
+ this.setAttr(item.htmlAttributes, innerEle);
2032
+ }
2033
+ if (item.tooltipText) {
2034
+ innerEle.setAttribute('title', tempDom.textContent);
2035
+ }
2036
+ if (item.cssClass) {
2037
+ innerEle.className = innerEle.className + ' ' + item.cssClass;
2038
+ }
2039
+ if (item.template) {
2040
+ this.templateRender(item.template, innerEle, item, index);
2041
+ } else {
2042
+ switch (item.type) {
2043
+ case 'Button':
2044
+ dom = this.buttonRendering(item, innerEle);
2045
+ dom.setAttribute('tabindex', '-1');
2046
+ dom.setAttribute('aria-label', (item.text || item.tooltipText));
2047
+ innerEle.appendChild(dom);
2048
+ innerEle.addEventListener('click', this.itemClick.bind(this));
2049
+ break;
2050
+ case 'Separator':
2051
+ this.add(innerEle, CLS_SEPARATOR);
2052
+ break;
2053
+ }
2054
+ }
2055
+ if (item.showTextOn) {
2056
+ const sTxt: Str = item.showTextOn;
2057
+ if (sTxt === 'Toolbar') {
2058
+ this.add(innerEle, CLS_POPUPTEXT);
2059
+ this.add(innerEle, 'e-tbtn-align');
2060
+ } else if (sTxt === 'Overflow') {
2061
+ this.add(innerEle, CLS_TBARTEXT);
2062
+ }
2063
+ }
2064
+ if (item.overflow) {
2065
+ const overflow: Str = item.overflow;
2066
+ if (overflow === 'Show') {
2067
+ this.add(innerEle, CLS_TBAROVERFLOW);
2068
+ } else if (overflow === 'Hide') {
2069
+ if (!innerEle.classList.contains(CLS_SEPARATOR)) {
2070
+ this.add(innerEle, CLS_POPOVERFLOW);
2071
+ }
2072
+ }
2073
+ }
2074
+ if (item.overflow !== 'Show' && item.showAlwaysInPopup && !innerEle.classList.contains(CLS_SEPARATOR)) {
2075
+ this.add(innerEle, CLS_POPPRI);
2076
+ this.popupPriCount++;
2077
+ }
2078
+ if (item.disabled) {
2079
+ this.add(innerEle, CLS_DISABLE);
2080
+ }
2081
+ if (item.visible === false) {
2082
+ this.add(innerEle, CLS_HIDDEN);
2083
+ }
2084
+ return innerEle;
2085
+ }
2086
+
2087
+ private itemClick(e: Event): void {
2088
+ this.activeEleSwitch(<HTEle>e.currentTarget);
2089
+ }
2090
+ private activeEleSwitch(ele: HTEle): void {
2091
+ this.activeEleRemove(<HTEle>ele.firstElementChild);
2092
+ this.activeEle.focus();
2093
+ }
2094
+ private activeEleRemove(curEle: HTEle): void {
2095
+ if (!isNOU(this.activeEle)) {
2096
+ this.activeEle.setAttribute('tabindex', '-1');
2097
+ }
2098
+ this.activeEle = curEle;
2099
+ if (isNOU(this.trgtEle) && !(<HTEle>curEle.parentElement).classList.contains(CLS_TEMPLATE)) {
2100
+ curEle.removeAttribute('tabindex');
2101
+ } else {
2102
+ this.activeEle.setAttribute('tabindex', '0');
2103
+ }
2104
+ }
2105
+ protected getPersistData(): string {
2106
+ return this.addOnPersist([]);
2107
+ }
2108
+ /**
2109
+ * Returns the current module name.
2110
+ *
2111
+ * @returns {string} - Returns the module name as string.
2112
+ * @private
2113
+ */
2114
+ protected getModuleName(): string {
2115
+ return 'toolbar';
2116
+ }
2117
+ private itemsRerender(newProp: ItemModel[]): void {
2118
+ this.items = this.tbarItemsCol;
2119
+ if ((this as any).isReact || (this as any).isAngular) {
2120
+ this.clearTemplate();
2121
+ }
2122
+ this.destroyMode();
2123
+ this.destroyItems();
2124
+ this.items = newProp;
2125
+ this.tbarItemsCol = this.items;
2126
+ this.renderItems();
2127
+ this.renderOverflowMode();
2128
+ if ((this as any).isReact) {
2129
+ this.renderReactTemplates();
2130
+ }
2131
+ }
2132
+ private resize(): void {
2133
+ const ele: HTEle = this.element;
2134
+ this.tbResize = true;
2135
+ if (this.tbarAlign) {
2136
+ this.itemPositioning();
2137
+ }
2138
+ if (this.popObj && this.overflowMode === 'Popup') {
2139
+ this.popObj.hide();
2140
+ }
2141
+ const checkOverflow: boolean = this.checkOverflow(ele, ele.getElementsByClassName(CLS_ITEMS)[0] as HTEle);
2142
+ if (!checkOverflow) {
2143
+ this.destroyScroll();
2144
+ const multirowele: HTEle = ele.querySelector('.' + CLS_ITEMS);
2145
+ if (!isNOU(multirowele)) {
2146
+ this.remove(multirowele, CLS_MULTIROWPOS);
2147
+ if (this.tbarAlign) {
2148
+ this.add(multirowele, CLS_TBARPOS);
2149
+ }
2150
+ }
2151
+ }
2152
+ if (checkOverflow && this.scrollModule && (this.offsetWid === ele.offsetWidth)) {
2153
+ return;
2154
+ }
2155
+ if (this.offsetWid > ele.offsetWidth || checkOverflow) {
2156
+ this.renderOverflowMode();
2157
+ }
2158
+ if (this.popObj) {
2159
+ if (this.overflowMode === 'Extended') {
2160
+ const eleStyles: CSSStyleDeclaration = window.getComputedStyle(this.element);
2161
+ this.popObj.width = parseFloat(eleStyles.width) + ((parseFloat(eleStyles.borderRightWidth)) * 2);
2162
+ }
2163
+ if (this.tbarAlign) {
2164
+ this.removePositioning();
2165
+ }
2166
+ this.popupRefresh(this.popObj.element, false);
2167
+ if (this.tbarAlign) {
2168
+ this.refreshPositioning();
2169
+ }
2170
+ }
2171
+ if (this.element.querySelector('.' + CLS_HSCROLLBAR)) {
2172
+ this.scrollStep = (this.element.querySelector('.' + CLS_HSCROLLBAR) as HTMLElement).offsetWidth;
2173
+ }
2174
+ this.offsetWid = ele.offsetWidth;
2175
+ this.tbResize = false;
2176
+ this.separator();
2177
+ }
2178
+
2179
+ private extendedOpen(): void {
2180
+ const sib: HTEle = this.element.querySelector('.' + CLS_EXTENDABLECLASS) as HTEle;
2181
+ if (this.overflowMode === 'Extended' && sib) {
2182
+ this.isExtendedOpen = sib.classList.contains(CLS_POPUPOPEN);
2183
+ }
2184
+ }
2185
+
2186
+ /**
2187
+ * Gets called when the model property changes.The data that describes the old and new values of the property that changed.
2188
+ *
2189
+ * @param {ToolbarModel} newProp - It contains new value of the data.
2190
+ * @param {ToolbarModel} oldProp - It contains old value of the data.
2191
+ * @returns {void}
2192
+ * @private
2193
+ */
2194
+ public onPropertyChanged(newProp: ToolbarModel, oldProp: ToolbarModel): void {
2195
+ const tEle: HTEle = this.element;
2196
+ const wid: number = tEle.offsetWidth;
2197
+ this.extendedOpen();
2198
+ for (const prop of Object.keys(newProp)) {
2199
+ switch (prop) {
2200
+ case 'items':
2201
+ if (!(newProp.items instanceof Array && oldProp.items instanceof Array)) {
2202
+ const changedProb: Object[] = Object.keys(newProp.items);
2203
+ for (let i: number = 0; i < changedProb.length; i++) {
2204
+ const index: number = parseInt(Object.keys(newProp.items)[i], 10);
2205
+ const property: Str = Object.keys(newProp.items[index])[0];
2206
+ const newProperty: Str = Object(newProp.items[index])[property];
2207
+ if (typeof newProperty !== 'function') {
2208
+ if (this.tbarAlign || property === 'align') {
2209
+ this.refresh();
2210
+ this.trigger('created');
2211
+ break;
2212
+ }
2213
+ const popupPriCheck: boolean = property === 'showAlwaysInPopup' && !newProperty;
2214
+ const booleanCheck: boolean = property === 'overflow' && this.popupPriCount !== 0;
2215
+ if ((popupPriCheck) || (this.items[index].showAlwaysInPopup) && booleanCheck) {
2216
+ --this.popupPriCount;
2217
+ }
2218
+ if (isNOU(this.scrollModule)) {
2219
+ this.destroyMode();
2220
+ }
2221
+ const itemCol: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEMS + ' .' + CLS_ITEM, tEle));
2222
+ if ((this as any).isReact) {
2223
+ this.clearTemplate();
2224
+ }
2225
+ detach(itemCol[index]);
2226
+ this.tbarEle.splice(index, 1);
2227
+ this.addItems([this.items[index]], index);
2228
+ this.items.splice(index, 1);
2229
+ if (this.items[index].template) {
2230
+ this.tbarEle.splice(this.items.length, 1);
2231
+ }
2232
+ }
2233
+ }
2234
+ } else {
2235
+ this.itemsRerender(newProp.items);
2236
+ }
2237
+ break;
2238
+ case 'width':
2239
+ setStyle(tEle, { 'width': formatUnit(newProp.width) });
2240
+ this.renderOverflowMode();
2241
+ if (this.popObj && wid < tEle.offsetWidth) {
2242
+ this.popupRefresh(this.popObj.element, false);
2243
+ }
2244
+ break;
2245
+ case 'height':
2246
+ setStyle(this.element, { 'height': formatUnit(newProp.height) });
2247
+ break;
2248
+ case 'overflowMode':
2249
+ this.destroyMode();
2250
+ this.renderOverflowMode();
2251
+ if (this.enableRtl) {
2252
+ this.add(tEle, CLS_RTL);
2253
+ }
2254
+ this.refreshOverflow();
2255
+ break;
2256
+ case 'enableRtl':
2257
+ if (newProp.enableRtl) {
2258
+ this.add(tEle, CLS_RTL);
2259
+ } else {
2260
+ this.remove(tEle, CLS_RTL);
2261
+ }
2262
+ if (!isNOU(this.scrollModule)) {
2263
+ if (newProp.enableRtl) {
2264
+ this.add(this.scrollModule.element, CLS_RTL);
2265
+ } else {
2266
+ this.remove(this.scrollModule.element, CLS_RTL);
2267
+ }
2268
+ }
2269
+ if (!isNOU(this.popObj)) {
2270
+ if (newProp.enableRtl) {
2271
+ this.add(this.popObj.element, CLS_RTL);
2272
+ } else {
2273
+ this.remove(this.popObj.element, CLS_RTL);
2274
+ }
2275
+ }
2276
+ if (this.tbarAlign) {
2277
+ this.itemPositioning();
2278
+ }
2279
+ break;
2280
+ case 'scrollStep':
2281
+ if (this.scrollModule) {
2282
+ this.scrollModule.scrollStep = this.scrollStep;
2283
+ }
2284
+ break;
2285
+ case 'enableCollision':
2286
+ if (this.popObj) {
2287
+ this.popObj.collision = { Y: this.enableCollision ? 'flip' : 'none' };
2288
+ }
2289
+ break;
2290
+ case 'cssClass':
2291
+ if (oldProp.cssClass) {
2292
+ removeClass([this.element], oldProp.cssClass.split(' '));
2293
+ }
2294
+ if (newProp.cssClass) {
2295
+ addClass([this.element], newProp.cssClass.split(' '));
2296
+ }
2297
+ break;
2298
+ case 'allowKeyboard':
2299
+ this.unwireKeyboardEvent();
2300
+ if (newProp.allowKeyboard) {
2301
+ this.wireKeyboardEvent();
2302
+ }
2303
+ break;
2304
+ }
2305
+ }
2306
+ }
2307
+ /**
2308
+ * Shows or hides the Toolbar item that is in the specified index.
2309
+ *
2310
+ * @param {number | HTMLElement} index - Index value of target item or DOM element of items to be hidden or shown.
2311
+ * @param {boolean} value - Based on this Boolean value, item will be hide (true) or show (false). By default, value is false.
2312
+ * @returns {void}.
2313
+ */
2314
+ public hideItem(index: number | HTMLElement | Element, value?: boolean): void {
2315
+ const isElement: boolean = (typeof (index) === 'object') ? true : false;
2316
+ let eleIndex: number = index as number;
2317
+ let initIndex: number;
2318
+ let ele: HTMLElement;
2319
+ const innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
2320
+ if (isElement) {
2321
+ ele = (index as HTMLElement);
2322
+ } else if (this.tbarEle[eleIndex]) {
2323
+ const innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
2324
+ ele = innerItems[eleIndex];
2325
+ }
2326
+ if (ele) {
2327
+ if (value) {
2328
+ ele.classList.add(CLS_HIDDEN);
2329
+ } else {
2330
+ ele.classList.remove(CLS_HIDDEN);
2331
+ }
2332
+ if (value && isNOU(this.element.getAttribute('tabindex')) && !ele.classList.contains(CLS_SEPARATOR)) {
2333
+ if (isNOU(ele.firstElementChild.getAttribute('tabindex'))) {
2334
+ ele.firstElementChild.setAttribute('tabindex', '-1');
2335
+ const innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
2336
+ if (isElement) {
2337
+ eleIndex = innerItems.indexOf(ele);
2338
+ }
2339
+ let nextEle: HTEle = innerItems[++eleIndex];
2340
+ while (nextEle) {
2341
+ const skipEle: string | boolean = this.eleContains(nextEle);
2342
+ if (!skipEle) {
2343
+ nextEle.firstElementChild.removeAttribute('tabindex');
2344
+ break;
2345
+ }
2346
+ nextEle = innerItems[++eleIndex];
2347
+ }
2348
+ }
2349
+ } else if (isNOU(this.element.getAttribute('tabindex')) && !ele.classList.contains(CLS_SEPARATOR)) {
2350
+ initIndex = 0;
2351
+ let setFlag: boolean = false;
2352
+ let removeFlag: boolean = false;
2353
+ let initELe: HTEle = innerItems[initIndex];
2354
+ while (initELe) {
2355
+ if (!initELe.classList.contains(CLS_SEPARATOR)) {
2356
+ if (isNOU(initELe.firstElementChild.getAttribute('tabindex'))) {
2357
+ initELe.firstElementChild.setAttribute('tabindex', '-1');
2358
+ setFlag = true;
2359
+ } else {
2360
+ if (setFlag && removeFlag) {
2361
+ break;
2362
+ }
2363
+ const skipEle: string | boolean = this.eleContains(initELe);
2364
+ if (!skipEle) {
2365
+ initELe.firstElementChild.removeAttribute('tabindex');
2366
+ removeFlag = true;
2367
+ }
2368
+ initELe = innerItems[++initIndex];
2369
+ }
2370
+ } else {
2371
+ initELe = innerItems[++initIndex];
2372
+ }
2373
+ }
2374
+ }
2375
+ this.refreshOverflow();
2376
+ }
2377
+ }
2378
+ }