@keenthemes/ktui 1.0.8 → 1.0.9

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 (499) hide show
  1. package/dist/ktui.js +16038 -17101
  2. package/dist/ktui.min.js +1 -1
  3. package/dist/ktui.min.js.map +1 -1
  4. package/lib/cjs/components/accordion/accordion.js +20 -11
  5. package/lib/cjs/components/accordion/accordion.js.map +1 -1
  6. package/lib/cjs/components/accordion/index.js +4 -0
  7. package/lib/cjs/components/accordion/index.js.map +1 -1
  8. package/lib/cjs/components/accordion/types.js +4 -0
  9. package/lib/cjs/components/accordion/types.js.map +1 -1
  10. package/lib/cjs/components/collapse/collapse.js +13 -7
  11. package/lib/cjs/components/collapse/collapse.js.map +1 -1
  12. package/lib/cjs/components/collapse/index.js +4 -0
  13. package/lib/cjs/components/collapse/index.js.map +1 -1
  14. package/lib/cjs/components/collapse/types.js +4 -0
  15. package/lib/cjs/components/collapse/types.js.map +1 -1
  16. package/lib/cjs/components/component.js +12 -41
  17. package/lib/cjs/components/component.js.map +1 -1
  18. package/lib/cjs/components/constants.js +4 -0
  19. package/lib/cjs/components/constants.js.map +1 -1
  20. package/lib/cjs/components/datatable/datatable-checkbox.js +217 -0
  21. package/lib/cjs/components/datatable/datatable-checkbox.js.map +1 -0
  22. package/lib/cjs/components/datatable/datatable-sort.js +91 -0
  23. package/lib/cjs/components/datatable/datatable-sort.js.map +1 -0
  24. package/lib/cjs/components/datatable/datatable.js +294 -349
  25. package/lib/cjs/components/datatable/datatable.js.map +1 -1
  26. package/lib/cjs/components/datatable/index.js +4 -0
  27. package/lib/cjs/components/datatable/index.js.map +1 -1
  28. package/lib/cjs/components/datatable/types.js +4 -0
  29. package/lib/cjs/components/datatable/types.js.map +1 -1
  30. package/lib/cjs/components/datepicker/calendar.js +1061 -0
  31. package/lib/cjs/components/datepicker/calendar.js.map +1 -0
  32. package/lib/cjs/components/datepicker/config.js +332 -0
  33. package/lib/cjs/components/datepicker/config.js.map +1 -0
  34. package/lib/cjs/components/datepicker/datepicker.js +949 -0
  35. package/lib/cjs/components/datepicker/datepicker.js.map +1 -0
  36. package/lib/cjs/components/datepicker/dropdown.js +635 -0
  37. package/lib/cjs/components/datepicker/dropdown.js.map +1 -0
  38. package/lib/cjs/components/datepicker/events.js +129 -0
  39. package/lib/cjs/components/datepicker/events.js.map +1 -0
  40. package/lib/cjs/components/datepicker/index.js +13 -0
  41. package/lib/cjs/components/datepicker/index.js.map +1 -0
  42. package/lib/cjs/components/datepicker/keyboard.js +536 -0
  43. package/lib/cjs/components/datepicker/keyboard.js.map +1 -0
  44. package/lib/cjs/components/datepicker/locales.js +78 -0
  45. package/lib/cjs/components/datepicker/locales.js.map +1 -0
  46. package/lib/cjs/components/datepicker/templates.js +403 -0
  47. package/lib/cjs/components/datepicker/templates.js.map +1 -0
  48. package/lib/cjs/components/datepicker/types.js +23 -0
  49. package/lib/cjs/components/datepicker/types.js.map +1 -0
  50. package/lib/cjs/components/datepicker/utils.js +524 -0
  51. package/lib/cjs/components/datepicker/utils.js.map +1 -0
  52. package/lib/cjs/components/dismiss/dismiss.js +10 -6
  53. package/lib/cjs/components/dismiss/dismiss.js.map +1 -1
  54. package/lib/cjs/components/dismiss/index.js +4 -0
  55. package/lib/cjs/components/dismiss/index.js.map +1 -1
  56. package/lib/cjs/components/dismiss/types.js +4 -0
  57. package/lib/cjs/components/dismiss/types.js.map +1 -1
  58. package/lib/cjs/components/drawer/drawer.js +54 -28
  59. package/lib/cjs/components/drawer/drawer.js.map +1 -1
  60. package/lib/cjs/components/drawer/index.js +4 -0
  61. package/lib/cjs/components/drawer/index.js.map +1 -1
  62. package/lib/cjs/components/drawer/types.js +4 -0
  63. package/lib/cjs/components/drawer/types.js.map +1 -1
  64. package/lib/cjs/components/dropdown/dropdown.js +145 -115
  65. package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
  66. package/lib/cjs/components/dropdown/index.js +4 -0
  67. package/lib/cjs/components/dropdown/index.js.map +1 -1
  68. package/lib/cjs/components/dropdown/types.js +4 -0
  69. package/lib/cjs/components/dropdown/types.js.map +1 -1
  70. package/lib/cjs/components/image-input/image-input.js +21 -16
  71. package/lib/cjs/components/image-input/image-input.js.map +1 -1
  72. package/lib/cjs/components/image-input/index.js +4 -0
  73. package/lib/cjs/components/image-input/index.js.map +1 -1
  74. package/lib/cjs/components/image-input/types.js +4 -0
  75. package/lib/cjs/components/image-input/types.js.map +1 -1
  76. package/lib/cjs/components/modal/index.js +4 -0
  77. package/lib/cjs/components/modal/index.js.map +1 -1
  78. package/lib/cjs/components/modal/modal.js +26 -19
  79. package/lib/cjs/components/modal/modal.js.map +1 -1
  80. package/lib/cjs/components/modal/types.js +4 -0
  81. package/lib/cjs/components/modal/types.js.map +1 -1
  82. package/lib/cjs/components/reparent/index.js +4 -0
  83. package/lib/cjs/components/reparent/index.js.map +1 -1
  84. package/lib/cjs/components/reparent/reparent.js +13 -5
  85. package/lib/cjs/components/reparent/reparent.js.map +1 -1
  86. package/lib/cjs/components/reparent/types.js +4 -0
  87. package/lib/cjs/components/reparent/types.js.map +1 -1
  88. package/lib/cjs/components/scrollable/index.js +4 -0
  89. package/lib/cjs/components/scrollable/index.js.map +1 -1
  90. package/lib/cjs/components/scrollable/scrollable.js +17 -10
  91. package/lib/cjs/components/scrollable/scrollable.js.map +1 -1
  92. package/lib/cjs/components/scrollable/types.js +4 -0
  93. package/lib/cjs/components/scrollable/types.js.map +1 -1
  94. package/lib/cjs/components/scrollspy/index.js +4 -0
  95. package/lib/cjs/components/scrollspy/index.js.map +1 -1
  96. package/lib/cjs/components/scrollspy/scrollspy.js +28 -17
  97. package/lib/cjs/components/scrollspy/scrollspy.js.map +1 -1
  98. package/lib/cjs/components/scrollspy/types.js +4 -0
  99. package/lib/cjs/components/scrollspy/types.js.map +1 -1
  100. package/lib/cjs/components/scrollto/index.js +4 -0
  101. package/lib/cjs/components/scrollto/index.js.map +1 -1
  102. package/lib/cjs/components/scrollto/scrollto.js +14 -8
  103. package/lib/cjs/components/scrollto/scrollto.js.map +1 -1
  104. package/lib/cjs/components/scrollto/types.js +4 -0
  105. package/lib/cjs/components/scrollto/types.js.map +1 -1
  106. package/lib/cjs/components/select/combobox.js +237 -0
  107. package/lib/cjs/components/select/combobox.js.map +1 -0
  108. package/lib/cjs/components/select/config.js +226 -0
  109. package/lib/cjs/components/select/config.js.map +1 -0
  110. package/lib/cjs/components/select/dropdown.js +429 -0
  111. package/lib/cjs/components/select/dropdown.js.map +1 -0
  112. package/lib/cjs/components/select/index.js +24 -0
  113. package/lib/cjs/components/select/index.js.map +1 -0
  114. package/lib/cjs/components/select/option.js +53 -0
  115. package/lib/cjs/components/select/option.js.map +1 -0
  116. package/lib/cjs/components/select/remote.js +414 -0
  117. package/lib/cjs/components/select/remote.js.map +1 -0
  118. package/lib/cjs/components/select/search.js +339 -0
  119. package/lib/cjs/components/select/search.js.map +1 -0
  120. package/lib/cjs/components/select/select.js +1538 -0
  121. package/lib/cjs/components/select/select.js.map +1 -0
  122. package/lib/cjs/components/select/tags.js +110 -0
  123. package/lib/cjs/components/select/tags.js.map +1 -0
  124. package/lib/cjs/components/select/templates.js +337 -0
  125. package/lib/cjs/components/select/templates.js.map +1 -0
  126. package/lib/cjs/components/select/types.js +19 -0
  127. package/lib/cjs/components/select/types.js.map +1 -0
  128. package/lib/cjs/components/select/utils.js +606 -0
  129. package/lib/cjs/components/select/utils.js.map +1 -0
  130. package/lib/cjs/components/stepper/index.js +4 -0
  131. package/lib/cjs/components/stepper/index.js.map +1 -1
  132. package/lib/cjs/components/stepper/stepper.js +20 -13
  133. package/lib/cjs/components/stepper/stepper.js.map +1 -1
  134. package/lib/cjs/components/stepper/types.js +4 -0
  135. package/lib/cjs/components/stepper/types.js.map +1 -1
  136. package/lib/cjs/components/sticky/index.js +4 -0
  137. package/lib/cjs/components/sticky/index.js.map +1 -1
  138. package/lib/cjs/components/sticky/sticky.js +60 -38
  139. package/lib/cjs/components/sticky/sticky.js.map +1 -1
  140. package/lib/cjs/components/sticky/types.js +4 -0
  141. package/lib/cjs/components/sticky/types.js.map +1 -1
  142. package/lib/cjs/components/tabs/index.js +4 -0
  143. package/lib/cjs/components/tabs/index.js.map +1 -1
  144. package/lib/cjs/components/tabs/tabs.js +34 -24
  145. package/lib/cjs/components/tabs/tabs.js.map +1 -1
  146. package/lib/cjs/components/tabs/types.js +4 -0
  147. package/lib/cjs/components/tabs/types.js.map +1 -1
  148. package/lib/cjs/components/theme-switch/index.js +10 -0
  149. package/lib/cjs/components/theme-switch/index.js.map +1 -0
  150. package/lib/cjs/components/theme-switch/theme-switch.js +143 -0
  151. package/lib/cjs/components/theme-switch/theme-switch.js.map +1 -0
  152. package/lib/cjs/components/theme-switch/types.js +7 -0
  153. package/lib/cjs/components/theme-switch/types.js.map +1 -0
  154. package/lib/cjs/components/toggle/index.js +4 -0
  155. package/lib/cjs/components/toggle/index.js.map +1 -1
  156. package/lib/cjs/components/toggle/toggle.js +11 -7
  157. package/lib/cjs/components/toggle/toggle.js.map +1 -1
  158. package/lib/cjs/components/toggle/types.js +4 -0
  159. package/lib/cjs/components/toggle/types.js.map +1 -1
  160. package/lib/cjs/components/toggle-password/index.js +4 -0
  161. package/lib/cjs/components/toggle-password/index.js.map +1 -1
  162. package/lib/cjs/components/toggle-password/toggle-password.js +12 -7
  163. package/lib/cjs/components/toggle-password/toggle-password.js.map +1 -1
  164. package/lib/cjs/components/toggle-password/types.js +4 -0
  165. package/lib/cjs/components/toggle-password/types.js.map +1 -1
  166. package/lib/cjs/components/tooltip/index.js +4 -0
  167. package/lib/cjs/components/tooltip/index.js.map +1 -1
  168. package/lib/cjs/components/tooltip/tooltip.js +51 -21
  169. package/lib/cjs/components/tooltip/tooltip.js.map +1 -1
  170. package/lib/cjs/components/tooltip/types.js +4 -0
  171. package/lib/cjs/components/tooltip/types.js.map +1 -1
  172. package/lib/cjs/helpers/data.js +5 -1
  173. package/lib/cjs/helpers/data.js.map +1 -1
  174. package/lib/cjs/helpers/dom.js +34 -29
  175. package/lib/cjs/helpers/dom.js.map +1 -1
  176. package/lib/cjs/helpers/event-handler.js +5 -1
  177. package/lib/cjs/helpers/event-handler.js.map +1 -1
  178. package/lib/cjs/helpers/utils.js +65 -11
  179. package/lib/cjs/helpers/utils.js.map +1 -1
  180. package/lib/cjs/index.js +18 -22
  181. package/lib/cjs/index.js.map +1 -1
  182. package/lib/cjs/types.js +4 -0
  183. package/lib/cjs/types.js.map +1 -1
  184. package/lib/esm/components/accordion/accordion.js +20 -11
  185. package/lib/esm/components/accordion/accordion.js.map +1 -1
  186. package/lib/esm/components/accordion/index.js +4 -0
  187. package/lib/esm/components/accordion/index.js.map +1 -1
  188. package/lib/esm/components/accordion/types.js +4 -0
  189. package/lib/esm/components/accordion/types.js.map +1 -1
  190. package/lib/esm/components/collapse/collapse.js +13 -7
  191. package/lib/esm/components/collapse/collapse.js.map +1 -1
  192. package/lib/esm/components/collapse/index.js +4 -0
  193. package/lib/esm/components/collapse/index.js.map +1 -1
  194. package/lib/esm/components/collapse/types.js +4 -0
  195. package/lib/esm/components/collapse/types.js.map +1 -1
  196. package/lib/esm/components/component.js +12 -41
  197. package/lib/esm/components/component.js.map +1 -1
  198. package/lib/esm/components/constants.js +4 -0
  199. package/lib/esm/components/constants.js.map +1 -1
  200. package/lib/esm/components/datatable/datatable-checkbox.js +214 -0
  201. package/lib/esm/components/datatable/datatable-checkbox.js.map +1 -0
  202. package/lib/esm/components/datatable/datatable-sort.js +88 -0
  203. package/lib/esm/components/datatable/datatable-sort.js.map +1 -0
  204. package/lib/esm/components/datatable/datatable.js +294 -349
  205. package/lib/esm/components/datatable/datatable.js.map +1 -1
  206. package/lib/esm/components/datatable/index.js +4 -0
  207. package/lib/esm/components/datatable/index.js.map +1 -1
  208. package/lib/esm/components/datatable/types.js +4 -0
  209. package/lib/esm/components/datatable/types.js.map +1 -1
  210. package/lib/esm/components/datepicker/calendar.js +1058 -0
  211. package/lib/esm/components/datepicker/calendar.js.map +1 -0
  212. package/lib/esm/components/datepicker/config.js +329 -0
  213. package/lib/esm/components/datepicker/config.js.map +1 -0
  214. package/lib/esm/components/datepicker/datepicker.js +946 -0
  215. package/lib/esm/components/datepicker/datepicker.js.map +1 -0
  216. package/lib/esm/components/datepicker/dropdown.js +632 -0
  217. package/lib/esm/components/datepicker/dropdown.js.map +1 -0
  218. package/lib/esm/components/datepicker/events.js +126 -0
  219. package/lib/esm/components/datepicker/events.js.map +1 -0
  220. package/lib/esm/components/datepicker/index.js +9 -0
  221. package/lib/esm/components/datepicker/index.js.map +1 -0
  222. package/lib/esm/components/datepicker/keyboard.js +533 -0
  223. package/lib/esm/components/datepicker/keyboard.js.map +1 -0
  224. package/lib/esm/components/datepicker/locales.js +74 -0
  225. package/lib/esm/components/datepicker/locales.js.map +1 -0
  226. package/lib/esm/components/datepicker/templates.js +390 -0
  227. package/lib/esm/components/datepicker/templates.js.map +1 -0
  228. package/lib/esm/components/datepicker/types.js +20 -0
  229. package/lib/esm/components/datepicker/types.js.map +1 -0
  230. package/lib/esm/components/datepicker/utils.js +508 -0
  231. package/lib/esm/components/datepicker/utils.js.map +1 -0
  232. package/lib/esm/components/dismiss/dismiss.js +10 -6
  233. package/lib/esm/components/dismiss/dismiss.js.map +1 -1
  234. package/lib/esm/components/dismiss/index.js +4 -0
  235. package/lib/esm/components/dismiss/index.js.map +1 -1
  236. package/lib/esm/components/dismiss/types.js +4 -0
  237. package/lib/esm/components/dismiss/types.js.map +1 -1
  238. package/lib/esm/components/drawer/drawer.js +54 -28
  239. package/lib/esm/components/drawer/drawer.js.map +1 -1
  240. package/lib/esm/components/drawer/index.js +4 -0
  241. package/lib/esm/components/drawer/index.js.map +1 -1
  242. package/lib/esm/components/drawer/types.js +4 -0
  243. package/lib/esm/components/drawer/types.js.map +1 -1
  244. package/lib/esm/components/dropdown/dropdown.js +146 -116
  245. package/lib/esm/components/dropdown/dropdown.js.map +1 -1
  246. package/lib/esm/components/dropdown/index.js +4 -0
  247. package/lib/esm/components/dropdown/index.js.map +1 -1
  248. package/lib/esm/components/dropdown/types.js +4 -0
  249. package/lib/esm/components/dropdown/types.js.map +1 -1
  250. package/lib/esm/components/image-input/image-input.js +21 -16
  251. package/lib/esm/components/image-input/image-input.js.map +1 -1
  252. package/lib/esm/components/image-input/index.js +4 -0
  253. package/lib/esm/components/image-input/index.js.map +1 -1
  254. package/lib/esm/components/image-input/types.js +4 -0
  255. package/lib/esm/components/image-input/types.js.map +1 -1
  256. package/lib/esm/components/modal/index.js +4 -0
  257. package/lib/esm/components/modal/index.js.map +1 -1
  258. package/lib/esm/components/modal/modal.js +26 -19
  259. package/lib/esm/components/modal/modal.js.map +1 -1
  260. package/lib/esm/components/modal/types.js +4 -0
  261. package/lib/esm/components/modal/types.js.map +1 -1
  262. package/lib/esm/components/reparent/index.js +4 -0
  263. package/lib/esm/components/reparent/index.js.map +1 -1
  264. package/lib/esm/components/reparent/reparent.js +13 -5
  265. package/lib/esm/components/reparent/reparent.js.map +1 -1
  266. package/lib/esm/components/reparent/types.js +4 -0
  267. package/lib/esm/components/reparent/types.js.map +1 -1
  268. package/lib/esm/components/scrollable/index.js +4 -0
  269. package/lib/esm/components/scrollable/index.js.map +1 -1
  270. package/lib/esm/components/scrollable/scrollable.js +17 -10
  271. package/lib/esm/components/scrollable/scrollable.js.map +1 -1
  272. package/lib/esm/components/scrollable/types.js +4 -0
  273. package/lib/esm/components/scrollable/types.js.map +1 -1
  274. package/lib/esm/components/scrollspy/index.js +4 -0
  275. package/lib/esm/components/scrollspy/index.js.map +1 -1
  276. package/lib/esm/components/scrollspy/scrollspy.js +28 -17
  277. package/lib/esm/components/scrollspy/scrollspy.js.map +1 -1
  278. package/lib/esm/components/scrollspy/types.js +4 -0
  279. package/lib/esm/components/scrollspy/types.js.map +1 -1
  280. package/lib/esm/components/scrollto/index.js +4 -0
  281. package/lib/esm/components/scrollto/index.js.map +1 -1
  282. package/lib/esm/components/scrollto/scrollto.js +14 -8
  283. package/lib/esm/components/scrollto/scrollto.js.map +1 -1
  284. package/lib/esm/components/scrollto/types.js +4 -0
  285. package/lib/esm/components/scrollto/types.js.map +1 -1
  286. package/lib/esm/components/select/combobox.js +234 -0
  287. package/lib/esm/components/select/combobox.js.map +1 -0
  288. package/lib/esm/components/select/config.js +223 -0
  289. package/lib/esm/components/select/config.js.map +1 -0
  290. package/lib/esm/components/select/dropdown.js +426 -0
  291. package/lib/esm/components/select/dropdown.js.map +1 -0
  292. package/lib/esm/components/select/index.js +12 -0
  293. package/lib/esm/components/select/index.js.map +1 -0
  294. package/lib/esm/components/select/option.js +50 -0
  295. package/lib/esm/components/select/option.js.map +1 -0
  296. package/lib/esm/components/select/remote.js +411 -0
  297. package/lib/esm/components/select/remote.js.map +1 -0
  298. package/lib/esm/components/select/search.js +336 -0
  299. package/lib/esm/components/select/search.js.map +1 -0
  300. package/lib/esm/components/select/select.js +1535 -0
  301. package/lib/esm/components/select/select.js.map +1 -0
  302. package/lib/esm/components/select/tags.js +107 -0
  303. package/lib/esm/components/select/tags.js.map +1 -0
  304. package/lib/esm/components/select/templates.js +332 -0
  305. package/lib/esm/components/select/templates.js.map +1 -0
  306. package/lib/esm/components/select/types.js +16 -0
  307. package/lib/esm/components/select/types.js.map +1 -0
  308. package/lib/esm/components/select/utils.js +598 -0
  309. package/lib/esm/components/select/utils.js.map +1 -0
  310. package/lib/esm/components/stepper/index.js +4 -0
  311. package/lib/esm/components/stepper/index.js.map +1 -1
  312. package/lib/esm/components/stepper/stepper.js +20 -13
  313. package/lib/esm/components/stepper/stepper.js.map +1 -1
  314. package/lib/esm/components/stepper/types.js +4 -0
  315. package/lib/esm/components/stepper/types.js.map +1 -1
  316. package/lib/esm/components/sticky/index.js +4 -0
  317. package/lib/esm/components/sticky/index.js.map +1 -1
  318. package/lib/esm/components/sticky/sticky.js +60 -38
  319. package/lib/esm/components/sticky/sticky.js.map +1 -1
  320. package/lib/esm/components/sticky/types.js +4 -0
  321. package/lib/esm/components/sticky/types.js.map +1 -1
  322. package/lib/esm/components/tabs/index.js +4 -0
  323. package/lib/esm/components/tabs/index.js.map +1 -1
  324. package/lib/esm/components/tabs/tabs.js +34 -24
  325. package/lib/esm/components/tabs/tabs.js.map +1 -1
  326. package/lib/esm/components/tabs/types.js +4 -0
  327. package/lib/esm/components/tabs/types.js.map +1 -1
  328. package/lib/esm/components/theme-switch/index.js +6 -0
  329. package/lib/esm/components/theme-switch/index.js.map +1 -0
  330. package/lib/esm/components/theme-switch/theme-switch.js +140 -0
  331. package/lib/esm/components/theme-switch/theme-switch.js.map +1 -0
  332. package/lib/esm/components/theme-switch/types.js +6 -0
  333. package/lib/esm/components/theme-switch/types.js.map +1 -0
  334. package/lib/esm/components/toggle/index.js +4 -0
  335. package/lib/esm/components/toggle/index.js.map +1 -1
  336. package/lib/esm/components/toggle/toggle.js +11 -7
  337. package/lib/esm/components/toggle/toggle.js.map +1 -1
  338. package/lib/esm/components/toggle/types.js +4 -0
  339. package/lib/esm/components/toggle/types.js.map +1 -1
  340. package/lib/esm/components/toggle-password/index.js +4 -0
  341. package/lib/esm/components/toggle-password/index.js.map +1 -1
  342. package/lib/esm/components/toggle-password/toggle-password.js +12 -7
  343. package/lib/esm/components/toggle-password/toggle-password.js.map +1 -1
  344. package/lib/esm/components/toggle-password/types.js +4 -0
  345. package/lib/esm/components/toggle-password/types.js.map +1 -1
  346. package/lib/esm/components/tooltip/index.js +4 -0
  347. package/lib/esm/components/tooltip/index.js.map +1 -1
  348. package/lib/esm/components/tooltip/tooltip.js +52 -22
  349. package/lib/esm/components/tooltip/tooltip.js.map +1 -1
  350. package/lib/esm/components/tooltip/types.js +4 -0
  351. package/lib/esm/components/tooltip/types.js.map +1 -1
  352. package/lib/esm/helpers/data.js +5 -1
  353. package/lib/esm/helpers/data.js.map +1 -1
  354. package/lib/esm/helpers/dom.js +34 -29
  355. package/lib/esm/helpers/dom.js.map +1 -1
  356. package/lib/esm/helpers/event-handler.js +5 -1
  357. package/lib/esm/helpers/event-handler.js.map +1 -1
  358. package/lib/esm/helpers/utils.js +65 -11
  359. package/lib/esm/helpers/utils.js.map +1 -1
  360. package/lib/esm/index.js +14 -16
  361. package/lib/esm/index.js.map +1 -1
  362. package/lib/esm/types.js +4 -0
  363. package/lib/esm/types.js.map +1 -1
  364. package/package.json +16 -8
  365. package/src/components/accordion/accordion-menu.css +1 -2
  366. package/src/components/accordion/accordion.css +1 -1
  367. package/src/components/accordion/accordion.ts +1 -1
  368. package/src/components/accordion/index.ts +1 -1
  369. package/src/components/accordion/types.ts +1 -1
  370. package/src/components/alert/alert.css +1 -1
  371. package/src/components/avatar/avatar.css +1 -1
  372. package/src/components/badge/badge.css +1 -1
  373. package/src/components/breadcrumb/breadcrumb.css +1 -1
  374. package/src/components/btn/btn.css +1 -1
  375. package/src/components/card/card.css +1 -1
  376. package/src/components/checkbox/checkbox.css +1 -1
  377. package/src/components/collapse/collapse.css +1 -1
  378. package/src/components/collapse/collapse.ts +1 -1
  379. package/src/components/collapse/index.ts +1 -1
  380. package/src/components/collapse/types.ts +1 -1
  381. package/src/components/component.ts +1 -1
  382. package/src/components/constants.ts +1 -1
  383. package/src/components/datatable/datatable-checkbox.ts +1 -1
  384. package/src/components/datatable/datatable-sort.ts +1 -1
  385. package/src/components/datatable/datatable.css +1 -1
  386. package/src/components/datatable/datatable.ts +38 -2
  387. package/src/components/datatable/index.ts +1 -1
  388. package/src/components/datatable/types.ts +1 -1
  389. package/src/components/datepicker/calendar.ts +1 -1
  390. package/src/components/datepicker/config.ts +1 -1
  391. package/src/components/datepicker/datepicker.css +1 -1
  392. package/src/components/datepicker/datepicker.ts +1 -1
  393. package/src/components/datepicker/dropdown.ts +1 -1
  394. package/src/components/datepicker/events.ts +1 -1
  395. package/src/components/datepicker/index.ts +1 -1
  396. package/src/components/datepicker/keyboard.ts +1 -1
  397. package/src/components/datepicker/locales.ts +1 -1
  398. package/src/components/datepicker/templates.ts +1 -1
  399. package/src/components/datepicker/types.ts +1 -1
  400. package/src/components/datepicker/utils.ts +1 -1
  401. package/src/components/dismiss/dismiss.css +1 -1
  402. package/src/components/dismiss/dismiss.ts +1 -1
  403. package/src/components/dismiss/index.ts +1 -1
  404. package/src/components/dismiss/types.ts +1 -1
  405. package/src/components/drawer/drawer.css +1 -1
  406. package/src/components/drawer/drawer.ts +1 -1
  407. package/src/components/drawer/index.ts +1 -1
  408. package/src/components/drawer/types.ts +1 -1
  409. package/src/components/dropdown/dropdown-menu.css +1 -1
  410. package/src/components/dropdown/dropdown.css +1 -1
  411. package/src/components/dropdown/dropdown.ts +1 -1
  412. package/src/components/dropdown/index.ts +1 -1
  413. package/src/components/dropdown/types.ts +1 -1
  414. package/src/components/form/form.css +1 -1
  415. package/src/components/image-input/image-input.css +1 -1
  416. package/src/components/image-input/image-input.ts +1 -1
  417. package/src/components/image-input/index.ts +1 -1
  418. package/src/components/image-input/types.ts +1 -1
  419. package/src/components/input/input-group.css +1 -1
  420. package/src/components/input/input.css +1 -1
  421. package/src/components/kbd/kbd.css +1 -1
  422. package/src/components/label/label.css +1 -1
  423. package/src/components/link/link.css +1 -1
  424. package/src/components/modal/index.ts +1 -1
  425. package/src/components/modal/modal.css +1 -1
  426. package/src/components/modal/modal.ts +1 -1
  427. package/src/components/modal/types.ts +1 -1
  428. package/src/components/pagination/pagination.css +1 -1
  429. package/src/components/popover/popover.css +1 -1
  430. package/src/components/progress/progress.css +2 -2
  431. package/src/components/radio/radio.css +1 -1
  432. package/src/components/reparent/index.ts +1 -1
  433. package/src/components/reparent/reparent.ts +1 -1
  434. package/src/components/reparent/types.ts +1 -1
  435. package/src/components/scrollable/index.ts +1 -1
  436. package/src/components/scrollable/scrollable.css +1 -1
  437. package/src/components/scrollable/scrollable.ts +1 -1
  438. package/src/components/scrollable/types.ts +1 -1
  439. package/src/components/scrollspy/index.ts +1 -1
  440. package/src/components/scrollspy/scrollspy.css +1 -1
  441. package/src/components/scrollspy/scrollspy.ts +1 -1
  442. package/src/components/scrollspy/types.ts +1 -1
  443. package/src/components/scrollto/index.ts +1 -1
  444. package/src/components/scrollto/scrollto.ts +1 -1
  445. package/src/components/scrollto/types.ts +1 -1
  446. package/src/components/select/combobox.ts +1 -1
  447. package/src/components/select/config.ts +1 -1
  448. package/src/components/select/dropdown.ts +1 -1
  449. package/src/components/select/index.ts +1 -1
  450. package/src/components/select/option.ts +1 -1
  451. package/src/components/select/remote.ts +1 -1
  452. package/src/components/select/search.ts +1 -1
  453. package/src/components/select/select.css +1 -1
  454. package/src/components/select/select.ts +1 -1
  455. package/src/components/select/tags.ts +1 -1
  456. package/src/components/select/templates.ts +1 -1
  457. package/src/components/select/types.ts +1 -1
  458. package/src/components/select/utils.ts +1 -1
  459. package/src/components/select/variants.css +1 -1
  460. package/src/components/separator/separator.css +1 -1
  461. package/src/components/skeleton/skeleton.css +1 -1
  462. package/src/components/stepper/index.ts +1 -1
  463. package/src/components/stepper/stepper.css +1 -1
  464. package/src/components/stepper/stepper.ts +1 -1
  465. package/src/components/stepper/types.ts +1 -1
  466. package/src/components/sticky/index.ts +1 -1
  467. package/src/components/sticky/sticky.css +1 -1
  468. package/src/components/sticky/sticky.ts +1 -1
  469. package/src/components/sticky/types.ts +1 -1
  470. package/src/components/switch/switch.css +1 -1
  471. package/src/components/table/table.css +2 -2
  472. package/src/components/tabs/index.ts +1 -1
  473. package/src/components/tabs/tabs.css +1 -1
  474. package/src/components/tabs/tabs.ts +1 -1
  475. package/src/components/tabs/types.ts +1 -1
  476. package/src/components/textarea/textarea.css +1 -1
  477. package/src/components/theme-switch/index.ts +1 -1
  478. package/src/components/theme-switch/theme-switch.css +1 -1
  479. package/src/components/theme-switch/theme-switch.ts +1 -1
  480. package/src/components/theme-switch/types.ts +1 -1
  481. package/src/components/toggle/index.ts +1 -1
  482. package/src/components/toggle/toggle.css +1 -1
  483. package/src/components/toggle/toggle.ts +1 -1
  484. package/src/components/toggle/types.ts +1 -1
  485. package/src/components/toggle-group/toggle-group.css +1 -1
  486. package/src/components/toggle-password/index.ts +1 -1
  487. package/src/components/toggle-password/toggle-password.css +1 -1
  488. package/src/components/toggle-password/toggle-password.ts +1 -1
  489. package/src/components/toggle-password/types.ts +1 -1
  490. package/src/components/tooltip/index.ts +1 -1
  491. package/src/components/tooltip/tooltip.css +1 -1
  492. package/src/components/tooltip/tooltip.ts +1 -1
  493. package/src/components/tooltip/types.ts +1 -1
  494. package/src/helpers/data.ts +1 -1
  495. package/src/helpers/dom.ts +1 -1
  496. package/src/helpers/event-handler.ts +1 -1
  497. package/src/helpers/utils.ts +1 -1
  498. package/src/index.ts +1 -1
  499. package/src/types.ts +1 -1
@@ -1,3 +1,7 @@
1
+ /**
2
+ * KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
3
+ * Copyright 2025 by Keenthemes Inc
4
+ */
1
5
  var __extends = (this && this.__extends) || (function () {
2
6
  var extendStatics = function (d, b) {
3
7
  extendStatics = Object.setPrototypeOf ||
@@ -34,8 +38,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
38
  });
35
39
  };
36
40
  var __generator = (this && this.__generator) || function (thisArg, body) {
37
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
41
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
42
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
43
  function verb(n) { return function (v) { return step([n, v]); }; }
40
44
  function step(op) {
41
45
  if (f) throw new TypeError("Generator is already executing.");
@@ -81,10 +85,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
81
85
  return to.concat(ar || Array.prototype.slice.call(from));
82
86
  };
83
87
  import KTComponent from '../component';
84
- import KTEventHandler from '../../helpers/event-handler';
85
88
  import KTUtils from '../../helpers/utils';
86
89
  import KTComponents from '../../index';
87
90
  import KTData from '../../helpers/data';
91
+ import { createCheckboxHandler, } from './datatable-checkbox';
92
+ import { createSortHandler } from './datatable-sort';
88
93
  /**
89
94
  * Custom DataTable plugin class with server-side API, pagination, and sorting
90
95
  * @classdesc A custom KTComponent class that integrates server-side API, pagination, and sorting functionality into a table.
@@ -99,10 +104,11 @@ var KTDataTable = /** @class */ (function (_super) {
99
104
  function KTDataTable(element, config) {
100
105
  var _this = _super.call(this) || this;
101
106
  _this._name = 'datatable';
102
- _this._checkboxListener = function (event) {
103
- _this._checkboxToggle(event); // Toggle row checkbox state
104
- };
105
- // private _searchListener: (value: string) => void;
107
+ _this._originalTbodyClass = ''; // Store original tbody class
108
+ _this._originalTrClasses = []; // Store original tr classes
109
+ _this._originalTheadClass = ''; // Store original thead class
110
+ _this._originalTdClasses = []; // Store original td classes as a 2D array [row][col]
111
+ _this._originalThClasses = []; // Store original th classes
106
112
  _this._data = [];
107
113
  if (KTData.has(element, _this._name))
108
114
  return _this;
@@ -112,13 +118,26 @@ var KTDataTable = /** @class */ (function (_super) {
112
118
  // Store the instance directly on the element
113
119
  element.instance = _this;
114
120
  _this._initElements();
121
+ // Initialize checkbox handler
122
+ _this._checkbox = createCheckboxHandler(_this._element, _this._config, function (eventName, eventData) {
123
+ _this._fireEvent(eventName, eventData);
124
+ _this._dispatchEvent(eventName, eventData);
125
+ });
126
+ // Initialize sort handler
127
+ _this._sortHandler = createSortHandler(_this._config, _this._theadElement, function () { return ({
128
+ sortField: _this.getState().sortField,
129
+ sortOrder: _this.getState().sortOrder,
130
+ }); }, function (field, order) {
131
+ _this._config._state.sortField = field;
132
+ _this._config._state.sortOrder = order;
133
+ }, _this._fireEvent.bind(_this), _this._dispatchEvent.bind(_this), _this._updateData.bind(_this));
134
+ _this._sortHandler.initSort();
115
135
  if (_this._config.stateSave === false) {
116
136
  _this._deleteState();
117
137
  }
118
138
  if (_this._config.stateSave) {
119
139
  _this._loadState();
120
140
  }
121
- _this._initTableHeader();
122
141
  _this._updateData();
123
142
  _this._fireEvent('init');
124
143
  _this._dispatchEvent('init');
@@ -130,6 +149,7 @@ var KTDataTable = /** @class */ (function (_super) {
130
149
  * @returns Default configuration merged with user-provided options
131
150
  */
132
151
  KTDataTable.prototype._initDefaultConfig = function (config) {
152
+ var _this = this;
133
153
  return __assign({
134
154
  /**
135
155
  * HTTP method for server-side API call
@@ -173,7 +193,7 @@ var KTDataTable = /** @class */ (function (_super) {
173
193
  /**
174
194
  * CSS classes to be added to the pagination button
175
195
  */
176
- class: 'btn',
196
+ class: 'kt-datatable-pagination-button',
177
197
  /**
178
198
  * Text to be displayed in the pagination button
179
199
  */
@@ -183,32 +203,32 @@ var KTDataTable = /** @class */ (function (_super) {
183
203
  /**
184
204
  * CSS classes to be added to the previous pagination button
185
205
  */
186
- class: 'btn',
206
+ class: 'kt-datatable-pagination-button kt-datatable-pagination-prev',
187
207
  /**
188
208
  * Text to be displayed in the previous pagination button
189
209
  */
190
- text: '<i class="ki-outline ki-black-left"></i>',
210
+ text: "\n\t\t\t\t\t\t<svg class=\"rtl:transform rtl:rotate-180 size-3.5 shrink-0\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t<path d=\"M8.86501 16.7882V12.8481H21.1459C21.3724 12.8481 21.5897 12.7581 21.7498 12.5979C21.91 12.4378 22 12.2205 22 11.994C22 11.7675 21.91 11.5503 21.7498 11.3901C21.5897 11.2299 21.3724 11.1399 21.1459 11.1399H8.86501V7.2112C8.86628 7.10375 8.83517 6.9984 8.77573 6.90887C8.7163 6.81934 8.63129 6.74978 8.53177 6.70923C8.43225 6.66869 8.32283 6.65904 8.21775 6.68155C8.11267 6.70405 8.0168 6.75766 7.94262 6.83541L2.15981 11.6182C2.1092 11.668 2.06901 11.7274 2.04157 11.7929C2.01413 11.8584 2 11.9287 2 11.9997C2 12.0707 2.01413 12.141 2.04157 12.2065C2.06901 12.272 2.1092 12.3314 2.15981 12.3812L7.94262 17.164C8.0168 17.2417 8.11267 17.2953 8.21775 17.3178C8.32283 17.3403 8.43225 17.3307 8.53177 17.2902C8.63129 17.2496 8.7163 17.18 8.77573 17.0905C8.83517 17.001 8.86628 16.8956 8.86501 16.7882Z\" fill=\"currentColor\"/>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t",
191
211
  },
192
212
  next: {
193
213
  /**
194
214
  * CSS classes to be added to the next pagination button
195
215
  */
196
- class: 'btn',
216
+ class: 'kt-datatable-pagination-button kt-datatable-pagination-next',
197
217
  /**
198
218
  * Text to be displayed in the next pagination button
199
219
  */
200
- text: '<i class="ki-outline ki-black-right"></i>',
220
+ text: "\n\t\t\t\t\t\t<svg class=\"rtl:transform rtl:rotate-180 size-3.5 shrink-0\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t\t<path d=\"M15.135 7.21144V11.1516H2.85407C2.62756 11.1516 2.41032 11.2415 2.25015 11.4017C2.08998 11.5619 2 11.7791 2 12.0056C2 12.2321 2.08998 12.4494 2.25015 12.6096C2.41032 12.7697 2.62756 12.8597 2.85407 12.8597H15.135V16.7884C15.1337 16.8959 15.1648 17.0012 15.2243 17.0908C15.2837 17.1803 15.3687 17.2499 15.4682 17.2904C15.5677 17.3309 15.6772 17.3406 15.7822 17.3181C15.8873 17.2956 15.9832 17.242 16.0574 17.1642L21.8402 12.3814C21.8908 12.3316 21.931 12.2722 21.9584 12.2067C21.9859 12.1412 22 12.0709 22 11.9999C22 11.9289 21.9859 11.8586 21.9584 11.7931C21.931 11.7276 21.8908 11.6683 21.8402 11.6185L16.0574 6.83565C15.9832 6.75791 15.8873 6.70429 15.7822 6.68179C15.6772 6.65929 15.5677 6.66893 15.4682 6.70948C15.3687 6.75002 15.2837 6.81959 15.2243 6.90911C15.1648 6.99864 15.1337 7.10399 15.135 7.21144Z\" fill=\"currentColor\"/>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t",
201
221
  },
202
222
  more: {
203
223
  /**
204
224
  * CSS classes to be added to the pagination more button
205
225
  */
206
- class: 'btn',
226
+ class: 'kt-datatable-pagination-button kt-datatable-pagination-more',
207
227
  /**
208
228
  * Text to be displayed in the pagination more button
209
229
  */
210
230
  text: '...',
211
- }
231
+ },
212
232
  },
213
233
  /**
214
234
  * Sorting options
@@ -218,7 +238,7 @@ var KTDataTable = /** @class */ (function (_super) {
218
238
  * CSS classes to be added to the sortable headers
219
239
  */
220
240
  classes: {
221
- base: 'sort',
241
+ base: 'kt-table-col',
222
242
  asc: 'asc',
223
243
  desc: 'desc',
224
244
  },
@@ -231,22 +251,9 @@ var KTDataTable = /** @class */ (function (_super) {
231
251
  * @returns Sorted data array
232
252
  */
233
253
  callback: function (data, sortField, sortOrder) {
234
- /**
235
- * Compares two values by converting them to strings and removing any HTML tags or white spaces
236
- * @param a First value to be compared
237
- * @param b Second value to be compared
238
- * @returns 1 if a > b, -1 if a < b, 0 if a === b
239
- */
240
- var compareValues = function (a, b) {
241
- var aText = String(a).replace(/<[^>]*>|&nbsp;/g, '');
242
- var bText = String(b).replace(/<[^>]*>|&nbsp;/g, '');
243
- return aText > bText ? (sortOrder === 'asc' ? 1 : -1) : (aText < bText ? (sortOrder === 'asc' ? -1 : 1) : 0);
244
- };
245
- return data.sort(function (a, b) {
246
- var aValue = a[sortField];
247
- var bValue = b[sortField];
248
- return compareValues(aValue, bValue);
249
- });
254
+ return _this._sortHandler
255
+ ? _this._sortHandler.sortData(data, sortField, sortOrder)
256
+ : data;
250
257
  },
251
258
  }, search: {
252
259
  /**
@@ -270,14 +277,18 @@ var KTDataTable = /** @class */ (function (_super) {
270
277
  return false;
271
278
  }
272
279
  return Object.values(item).some(function (value) {
273
- if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') {
280
+ if (typeof value !== 'string' &&
281
+ typeof value !== 'number' &&
282
+ typeof value !== 'boolean') {
274
283
  return false;
275
284
  }
276
- var valueText = String(value).replace(/<[^>]*>|&nbsp;/g, '').toLowerCase();
285
+ var valueText = String(value)
286
+ .replace(/<[^>]*>|&nbsp;/g, '')
287
+ .toLowerCase();
277
288
  return valueText.includes(search.toLowerCase());
278
289
  });
279
290
  });
280
- }
291
+ },
281
292
  },
282
293
  /**
283
294
  * Loading spinner options
@@ -286,11 +297,11 @@ var KTDataTable = /** @class */ (function (_super) {
286
297
  /**
287
298
  * Template to be displayed during data fetching process
288
299
  */
289
- template: "\n\t\t\t\t\t<div class=\"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2\">\n\t\t\t\t\t\t<div class=\"flex items-center gap-2 px-4 py-2 font-medium leading-none text-2sm border border-gray-200 shadow-default rounded-md text-gray-500 bg-light\">\n\t\t\t\t\t\t\t<svg class=\"animate-spin -ml-1 h-5 w-5 text-gray-600\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n\t\t\t\t\t\t\t\t<circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"3\"></circle>\n\t\t\t\t\t\t\t\t<path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"></path>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t{content}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t",
300
+ template: "\n\t\t\t\t\t<div class=\"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2\">\n\t\t\t\t\t\t<div class=\"kt-datatable-loading\">\n\t\t\t\t\t\t\t<svg class=\"animate-spin -ml-1 h-5 w-5 text-gray-600\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n\t\t\t\t\t\t\t\t<circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"3\"></circle>\n\t\t\t\t\t\t\t\t<path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"></path>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t{content}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t",
290
301
  /**
291
302
  * Loading text to be displayed in the template
292
303
  */
293
- content: 'Loading...'
304
+ content: 'Loading...',
294
305
  },
295
306
  /**
296
307
  * Selectors of the elements to be targeted
@@ -299,39 +310,39 @@ var KTDataTable = /** @class */ (function (_super) {
299
310
  /**
300
311
  * Data table element
301
312
  */
302
- table: 'table[data-datatable-table="true"]',
313
+ table: 'table[data-kt-datatable-table="true"]',
303
314
  /**
304
315
  * Pagination info element
305
316
  */
306
- info: '[data-datatable-info="true"]',
317
+ info: '[data-kt-datatable-info="true"]',
307
318
  /**
308
319
  * Page size dropdown element
309
320
  */
310
- size: '[data-datatable-size="true"]',
321
+ size: '[data-kt-datatable-size="true"]',
311
322
  /**
312
323
  * Pagination element
313
324
  */
314
- pagination: '[data-datatable-pagination="true"]',
325
+ pagination: '[data-kt-datatable-pagination="true"]',
315
326
  /**
316
327
  * Spinner element
317
328
  */
318
- spinner: '[data-datatable-spinner="true"]',
329
+ spinner: '[data-kt-datatable-spinner="true"]',
319
330
  /**
320
331
  * Checkbox element
321
332
  */
322
- check: '[data-datatable-check="true"]',
323
- checkbox: '[data-datatable-row-check="true"]'
333
+ check: '[data-kt-datatable-check="true"]',
334
+ checkbox: '[data-kt-datatable-row-check="true"]',
324
335
  },
325
336
  /**
326
337
  * Enable or disable state saving
327
338
  */
328
339
  stateSave: true, checkbox: {
329
- checkedClass: 'checked'
340
+ checkedClass: 'checked',
330
341
  },
331
342
  /**
332
343
  * Private properties
333
344
  */
334
- _state: {} }, config);
345
+ _state: {}, loadingClass: 'loading' }, config);
335
346
  };
336
347
  /**
337
348
  * Initialize table, tbody, thead, info, size, and pagination elements
@@ -345,11 +356,14 @@ var KTDataTable = /** @class */ (function (_super) {
345
356
  /**
346
357
  * Table body element
347
358
  */
348
- this._tbodyElement = this._tableElement.tBodies[0] || this._tableElement.createTBody();
359
+ this._tbodyElement =
360
+ this._tableElement.tBodies[0] || this._tableElement.createTBody();
349
361
  /**
350
362
  * Table head element
351
363
  */
352
364
  this._theadElement = this._tableElement.tHead;
365
+ // Store original classes
366
+ this._storeOriginalClasses();
353
367
  /**
354
368
  * Pagination info element
355
369
  */
@@ -363,6 +377,35 @@ var KTDataTable = /** @class */ (function (_super) {
363
377
  */
364
378
  this._paginationElement = this._element.querySelector(this._config.attributes.pagination);
365
379
  };
380
+ /**
381
+ * Store original classes from table elements
382
+ * @returns {void}
383
+ */
384
+ KTDataTable.prototype._storeOriginalClasses = function () {
385
+ var _this = this;
386
+ // Store tbody class
387
+ if (this._tbodyElement) {
388
+ this._originalTbodyClass = this._tbodyElement.className || '';
389
+ }
390
+ // Store thead class and th classes
391
+ if (this._theadElement) {
392
+ this._originalTheadClass = this._theadElement.className || '';
393
+ // Store th classes
394
+ var thElements = this._theadElement.querySelectorAll('th');
395
+ this._originalThClasses = Array.from(thElements).map(function (th) { return th.className || ''; });
396
+ }
397
+ // Store tr and td classes
398
+ if (this._tbodyElement) {
399
+ var originalRows = this._tbodyElement.querySelectorAll('tr');
400
+ this._originalTrClasses = Array.from(originalRows).map(function (row) { return row.className || ''; });
401
+ // Store td classes as a 2D array
402
+ this._originalTdClasses = [];
403
+ Array.from(originalRows).forEach(function (row, rowIndex) {
404
+ var tdElements = row.querySelectorAll('td');
405
+ _this._originalTdClasses[rowIndex] = Array.from(tdElements).map(function (td) { return td.className || ''; });
406
+ });
407
+ }
408
+ };
366
409
  /**
367
410
  * Fetch data from the server or from the DOM if `apiEndpoint` is not defined.
368
411
  * @returns {Promise<void>} Promise which is resolved after data has been fetched and checkbox plugin initialized.
@@ -372,7 +415,7 @@ var KTDataTable = /** @class */ (function (_super) {
372
415
  return __generator(this, function (_a) {
373
416
  this._showSpinner(); // Show spinner before fetching data
374
417
  // Fetch data from the DOM and initialize the checkbox plugin
375
- return [2 /*return*/, (typeof this._config.apiEndpoint === 'undefined')
418
+ return [2 /*return*/, typeof this._config.apiEndpoint === 'undefined'
376
419
  ? this._fetchDataFromLocal().then(this._finalize.bind(this))
377
420
  : this._fetchDataFromServer().then(this._finalize.bind(this))];
378
421
  });
@@ -384,12 +427,10 @@ var KTDataTable = /** @class */ (function (_super) {
384
427
  */
385
428
  KTDataTable.prototype._finalize = function () {
386
429
  this._element.classList.add('datatable-initialized');
387
- var headerCheckElement = this._element.querySelector(this._config.attributes.check);
388
- if (headerCheckElement) {
389
- this._initChecbox(headerCheckElement);
390
- }
430
+ // Initialize checkbox logic
431
+ this._checkbox.init();
391
432
  this._attachSearchEvent();
392
- if (typeof KTComponents !== "undefined") {
433
+ if (typeof KTComponents !== 'undefined') {
393
434
  KTComponents.init();
394
435
  }
395
436
  /**
@@ -404,7 +445,14 @@ var KTDataTable = /** @class */ (function (_super) {
404
445
  KTDataTable.prototype._attachSearchEvent = function () {
405
446
  var _this = this;
406
447
  var tableId = this._tableId();
407
- var searchElement = document.querySelector("[data-datatable-search=\"#".concat(tableId, "\"]"));
448
+ var searchElement = document.querySelector("[data-kt-datatable-search=\"#".concat(tableId, "\"]"));
449
+ // Get search state
450
+ var search = this.getState().search;
451
+ // Set search value
452
+ if (searchElement) {
453
+ searchElement.value =
454
+ typeof search === 'string' ? search : String(search);
455
+ }
408
456
  if (searchElement) {
409
457
  // Check if a debounced search function already exists
410
458
  if (searchElement._debouncedSearch) {
@@ -421,17 +469,6 @@ var KTDataTable = /** @class */ (function (_super) {
421
469
  searchElement.addEventListener('keyup', debouncedSearch);
422
470
  }
423
471
  };
424
- /**
425
- * Initialize the checkbox plugin
426
- * @param {HTMLInputElement} headerCheckElement - The header checkbox element
427
- * @returns {void}
428
- */
429
- KTDataTable.prototype._initChecbox = function (headerCheckElement) {
430
- this._headerCheckElement = headerCheckElement;
431
- this._headerChecked = headerCheckElement.checked;
432
- this._targetElements = this._element.querySelectorAll(this._config.attributes.checkbox);
433
- this._checkboxHandler();
434
- };
435
472
  /**
436
473
  * Fetch data from the DOM
437
474
  * Fetch data from the table element and save it to the `originalData` state property.
@@ -444,10 +481,16 @@ var KTDataTable = /** @class */ (function (_super) {
444
481
  return __generator(this, function (_d) {
445
482
  switch (_d.label) {
446
483
  case 0:
484
+ this._fireEvent('fetch');
485
+ this._dispatchEvent('fetch');
447
486
  _a = this.getState(), sortField = _a.sortField, sortOrder = _a.sortOrder, page = _a.page, pageSize = _a.pageSize, search = _a.search;
448
487
  originalData = this.getState().originalData;
449
488
  // If the table element or the original data is not defined, bail
450
- if (!this._tableElement || originalData === undefined || this._tableConfigInvalidate() || this._localTableHeaderInvalidate() || this._localTableContentInvalidate()) {
489
+ if (!this._tableElement ||
490
+ originalData === undefined ||
491
+ this._tableConfigInvalidate() ||
492
+ this._localTableHeaderInvalidate() ||
493
+ this._localTableContentInvalidate()) {
451
494
  this._deleteState();
452
495
  _b = this._localExtractTableContent(), originalData_1 = _b.originalData, originalDataAttributes = _b.originalDataAttributes;
453
496
  this._config._state.originalData = originalData_1;
@@ -455,12 +498,14 @@ var KTDataTable = /** @class */ (function (_super) {
455
498
  }
456
499
  // Update the original data variable
457
500
  originalData = this.getState().originalData;
458
- _temp = this._data = __spreadArray([], originalData, true);
501
+ _temp = (this._data = __spreadArray([], originalData, true));
459
502
  if (search) {
460
503
  _temp = this._data = this._config.search.callback.call(this, this._data, search);
461
504
  }
462
505
  // If sorting is defined, sort the data
463
- if (sortField !== undefined && sortOrder !== undefined && sortOrder !== '') {
506
+ if (sortField !== undefined &&
507
+ sortOrder !== undefined &&
508
+ sortOrder !== '') {
464
509
  if (typeof this._config.sort.callback === 'function') {
465
510
  this._data = this._config.sort.callback.call(this, this._data, sortField, sortOrder);
466
511
  }
@@ -478,6 +523,8 @@ var KTDataTable = /** @class */ (function (_super) {
478
523
  case 1:
479
524
  // Draw the data
480
525
  _d.sent();
526
+ this._fireEvent('fetched');
527
+ this._dispatchEvent('fetched');
481
528
  return [2 /*return*/];
482
529
  }
483
530
  });
@@ -509,30 +556,32 @@ var KTDataTable = /** @class */ (function (_super) {
509
556
  return false;
510
557
  };
511
558
  /**
512
- * Extracts the table content and returns it as an object containing an array of original data and an array of original data attributes.
559
+ * Extract the table content and returns it as an object containing an array of original data and an array of original data attributes.
513
560
  *
514
561
  * @returns {{originalData: T[], originalDataAttributes: KTDataTableAttributeInterface[]}} - An object containing an array of original data and an array of original data attributes.
515
562
  */
516
563
  KTDataTable.prototype._localExtractTableContent = function () {
517
564
  var originalData = [];
518
565
  var originalDataAttributes = [];
566
+ this._storeOriginalClasses();
519
567
  var rows = this._tbodyElement.querySelectorAll('tr');
568
+ var ths = this._theadElement
569
+ ? this._theadElement.querySelectorAll('th')
570
+ : [];
520
571
  rows.forEach(function (row) {
521
572
  var dataRow = {};
522
573
  var dataRowAttribute = {};
523
- // Loop through each cell in the row
524
574
  row.querySelectorAll('td').forEach(function (td, index) {
525
- var _a;
526
- var attributes = {};
527
- // Copy all attributes to the cell data
528
- Array.from(td.attributes).forEach(function (attr) {
529
- attributes[attr.name] = attr.value;
530
- });
531
- // Set the data for the current row and cell
532
- dataRow[index] = (_a = td.innerHTML) === null || _a === void 0 ? void 0 : _a.trim();
533
- dataRowAttribute[index] = attributes;
575
+ var _a, _b, _c;
576
+ var colName = (_a = ths[index]) === null || _a === void 0 ? void 0 : _a.getAttribute('data-kt-datatable-column');
577
+ if (colName) {
578
+ dataRow[colName] = (_b = td.innerHTML) === null || _b === void 0 ? void 0 : _b.trim();
579
+ }
580
+ else {
581
+ // Store the original HTML for fallback
582
+ dataRow[index] = (_c = td.innerHTML) === null || _c === void 0 ? void 0 : _c.trim();
583
+ }
534
584
  });
535
- // If the row has any data, add it to the original data array
536
585
  if (Object.keys(dataRow).length > 0) {
537
586
  originalData.push(dataRow);
538
587
  originalDataAttributes.push(dataRowAttribute);
@@ -545,10 +594,13 @@ var KTDataTable = /** @class */ (function (_super) {
545
594
  * @returns {boolean} - Returns true if the table header is invalidated, false otherwise
546
595
  */
547
596
  KTDataTable.prototype._localTableHeaderInvalidate = function () {
548
- var _a;
549
597
  var originalData = this.getState().originalData;
550
- var currentTableHeaders = ((_a = this._getTableHeaders()) === null || _a === void 0 ? void 0 : _a.length) || 0;
551
- var totalColumns = originalData.length ? Object.keys(originalData[0]).length : 0;
598
+ var currentTableHeaders = this._theadElement
599
+ ? this._theadElement.querySelectorAll('th').length
600
+ : 0;
601
+ var totalColumns = originalData.length
602
+ ? Object.keys(originalData[0]).length
603
+ : 0;
552
604
  return currentTableHeaders !== totalColumns;
553
605
  };
554
606
  /**
@@ -590,6 +642,8 @@ var KTDataTable = /** @class */ (function (_super) {
590
642
  return [4 /*yield*/, this._draw()];
591
643
  case 6:
592
644
  _a.sent();
645
+ this._fireEvent('fetched');
646
+ this._dispatchEvent('fetched');
593
647
  return [2 /*return*/];
594
648
  }
595
649
  });
@@ -645,21 +699,51 @@ var KTDataTable = /** @class */ (function (_super) {
645
699
  requestBody = queryParams;
646
700
  }
647
701
  else if (requestMethod === 'GET') {
648
- apiEndpointWithQueryParams = new URL(this._config.apiEndpoint);
702
+ apiEndpointWithQueryParams = this._createUrl(this._config.apiEndpoint);
649
703
  apiEndpointWithQueryParams.search = queryParams.toString();
650
704
  this._config.apiEndpoint = apiEndpointWithQueryParams.toString();
651
705
  }
652
706
  return [2 /*return*/, fetch(this._config.apiEndpoint, {
653
707
  method: requestMethod,
654
708
  body: requestBody,
655
- headers: this._config.requestHeaders
709
+ headers: this._config.requestHeaders,
656
710
  }).catch(function (error) {
711
+ // Trigger an error event
712
+ _this._fireEvent('error', { error: error });
713
+ _this._dispatchEvent('error', { error: error });
657
714
  _this._noticeOnTable('Error performing fetch request: ' + String(error));
658
715
  throw error;
659
716
  })];
660
717
  });
661
718
  });
662
719
  };
720
+ /**
721
+ * Creates a complete URL from a relative path or a full URL.
722
+ *
723
+ * This method accepts a string that can be either a relative path or a full URL.
724
+ * If the string is a complete URL (i.e., it contains a valid protocol), a URL
725
+ * object based on that string is returned. Otherwise, it ensures the path starts
726
+ * with a "/" and combines it with the provided base URL (or the current window's origin)
727
+ * to form a complete URL.
728
+ *
729
+ * @param {string} pathOrUrl - The path or URL to process.
730
+ * @param {string | null} [baseUrl=window.location.origin] - The base URL for resolving the relative path.
731
+ * Defaults to the current window's origin.
732
+ * @returns {URL} The resulting URL object.
733
+ */
734
+ KTDataTable.prototype._createUrl = function (pathOrUrl, baseUrl) {
735
+ if (baseUrl === void 0) { baseUrl = window.location.origin; }
736
+ // Regular expression to check if the input is a full URL
737
+ var isFullUrl = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(pathOrUrl);
738
+ if (isFullUrl) {
739
+ return new URL(pathOrUrl); // Return full URL as URL object
740
+ }
741
+ // Ensure path starts with a slash to avoid incorrect concatenation
742
+ var normalizedPath = pathOrUrl.startsWith('/')
743
+ ? pathOrUrl
744
+ : "/".concat(pathOrUrl);
745
+ return new URL(normalizedPath, baseUrl);
746
+ };
663
747
  /**
664
748
  * Update the table and pagination controls with new data
665
749
  * @returns {Promise<void>} A promise that resolves when the table and pagination controls are updated
@@ -667,7 +751,8 @@ var KTDataTable = /** @class */ (function (_super) {
667
751
  KTDataTable.prototype._draw = function () {
668
752
  return __awaiter(this, void 0, void 0, function () {
669
753
  return __generator(this, function (_a) {
670
- this._config._state.totalPages = Math.ceil(this.getState().totalItems / this.getState().pageSize) || 0;
754
+ this._config._state.totalPages =
755
+ Math.ceil(this.getState().totalItems / this.getState().pageSize) || 0;
671
756
  this._fireEvent('draw');
672
757
  this._dispatchEvent('draw');
673
758
  this._dispose();
@@ -699,89 +784,13 @@ var KTDataTable = /** @class */ (function (_super) {
699
784
  }
700
785
  // Create the table body with the new data
701
786
  var tbodyElement = this._tableElement.createTBody();
787
+ // Apply the original class to the new tbody element
788
+ if (this._originalTbodyClass) {
789
+ tbodyElement.className = this._originalTbodyClass;
790
+ }
702
791
  this._updateTableContent(tbodyElement);
703
792
  return tbodyElement;
704
793
  };
705
- /**
706
- * Initialize the table header
707
- * Add sort event listener to all sortable columns
708
- */
709
- KTDataTable.prototype._initTableHeader = function () {
710
- var _this = this;
711
- if (!this._theadElement) {
712
- return;
713
- }
714
- // Set the initial sort icon
715
- this._setSortIcon(this.getState().sortField, this.getState().sortOrder);
716
- // Get all the table headers
717
- var headers = this._getTableHeaders();
718
- // Loop through each table header
719
- headers.forEach(function (header) {
720
- // If the sort class is not found, it's not a sortable column
721
- if (!header.querySelector(".".concat(_this._config.sort.classes.base))) {
722
- return;
723
- }
724
- var sortAttribute = header.getAttribute('data-datatable-column-sort') || header.getAttribute('data-datatable-column');
725
- var sortField = sortAttribute ? sortAttribute : header.cellIndex;
726
- // Add click event listener to the header
727
- header.addEventListener('click', function () {
728
- var sortOrder = _this._toggleSortOrder(sortField);
729
- _this._setSortIcon(sortField, sortOrder);
730
- _this._sort(sortField);
731
- });
732
- });
733
- };
734
- /**
735
- * Returns an array of table headers as HTMLTableCellElement.
736
- * @returns {HTMLTableCellElement[]} An array of table headers.
737
- */
738
- KTDataTable.prototype._getTableHeaders = function () {
739
- if (!this._theadElement) {
740
- return [];
741
- }
742
- return Array.from(this._theadElement.querySelectorAll('th'));
743
- };
744
- /**
745
- * Sets the sort icon in the table header
746
- * @param sortField The field to set the sort icon for
747
- * @param sortOrder The sort order (ascending or descending)
748
- */
749
- KTDataTable.prototype._setSortIcon = function (sortField, sortOrder) {
750
- var sortClass = sortOrder ? (sortOrder === 'asc' ? this._config.sort.classes.asc : this._config.sort.classes.desc) : '';
751
- // Get the appropriate table header element
752
- var th = typeof sortField === 'number'
753
- ? this._theadElement.querySelectorAll('th')[sortField]
754
- : this._theadElement.querySelector("th[data-datatable-column=\"".concat(String(sortField), "\"], th[data-datatable-column-sort=\"").concat(String(sortField), "\"]"));
755
- if (th) {
756
- var sortElement = th.querySelector(".".concat(this._config.sort.classes.base));
757
- if (sortElement) {
758
- sortElement.className = "".concat(this._config.sort.classes.base, " ").concat(sortClass).trim();
759
- }
760
- }
761
- };
762
- /**
763
- * Toggles the sort order of a column
764
- * @param sortField The field to toggle the sort order for
765
- * @returns The new sort order (ascending, descending or unsorted)
766
- */
767
- KTDataTable.prototype._toggleSortOrder = function (sortField) {
768
- var _this = this;
769
- // If the sort field is the same as the current sort field,
770
- // toggle the sort order. Otherwise, set the sort order to ascending.
771
- return (function () {
772
- if (_this.getState().sortField === sortField) {
773
- switch (_this.getState().sortOrder) {
774
- case 'asc':
775
- return 'desc'; // Descending
776
- case 'desc':
777
- return ''; // Unsorted
778
- default:
779
- return 'asc'; // Ascending
780
- }
781
- }
782
- return 'asc'; // Ascending
783
- })();
784
- };
785
794
  /**
786
795
  * Update the table content
787
796
  * @param tbodyElement The table body element
@@ -795,16 +804,41 @@ var KTDataTable = /** @class */ (function (_super) {
795
804
  this._noticeOnTable(this._config.infoEmpty || '');
796
805
  return tbodyElement;
797
806
  }
807
+ var ths = this._theadElement
808
+ ? this._theadElement.querySelectorAll('th')
809
+ : [];
798
810
  this._data.forEach(function (item, rowIndex) {
799
811
  var row = document.createElement('tr');
812
+ // Apply original tr class if available
813
+ if (_this._originalTrClasses && _this._originalTrClasses[rowIndex]) {
814
+ row.className = _this._originalTrClasses[rowIndex];
815
+ }
800
816
  if (!_this._config.columns) {
801
817
  var dataRowAttributes_1 = _this.getState().originalDataAttributes
802
818
  ? _this.getState().originalDataAttributes[rowIndex]
803
819
  : null;
804
- Object.keys(item).forEach(function (key, colIndex) {
820
+ // Use the order of <th> elements to render <td>s in the correct order
821
+ ths.forEach(function (th, colIndex) {
822
+ var colName = th.getAttribute('data-kt-datatable-column');
805
823
  var td = document.createElement('td');
806
- td.innerHTML = item[key];
807
- if (dataRowAttributes_1) {
824
+ var value;
825
+ if (colName && Object.prototype.hasOwnProperty.call(item, colName)) {
826
+ value = item[colName];
827
+ }
828
+ else if (Object.prototype.hasOwnProperty.call(item, colIndex)) {
829
+ value = item[colIndex];
830
+ }
831
+ else {
832
+ value = '';
833
+ }
834
+ td.innerHTML = value;
835
+ // Apply original td class if available
836
+ if (_this._originalTdClasses &&
837
+ _this._originalTdClasses[rowIndex] &&
838
+ _this._originalTdClasses[rowIndex][colIndex]) {
839
+ td.className = _this._originalTdClasses[rowIndex][colIndex];
840
+ }
841
+ if (dataRowAttributes_1 && dataRowAttributes_1[colIndex]) {
808
842
  for (var attr in dataRowAttributes_1[colIndex]) {
809
843
  td.setAttribute(attr, dataRowAttributes_1[colIndex][attr]);
810
844
  }
@@ -813,9 +847,15 @@ var KTDataTable = /** @class */ (function (_super) {
813
847
  });
814
848
  }
815
849
  else {
816
- Object.keys(_this._config.columns).forEach(function (key) {
850
+ Object.keys(_this._config.columns).forEach(function (key, colIndex) {
817
851
  var td = document.createElement('td');
818
852
  var columnDef = _this._config.columns[key];
853
+ // Apply original td class if available
854
+ if (_this._originalTdClasses &&
855
+ _this._originalTdClasses[rowIndex] &&
856
+ _this._originalTdClasses[rowIndex][colIndex]) {
857
+ td.className = _this._originalTdClasses[rowIndex][colIndex];
858
+ }
819
859
  if (typeof columnDef.render === 'function') {
820
860
  td.innerHTML = columnDef.render.call(_this, item[key], item, _this);
821
861
  }
@@ -839,11 +879,12 @@ var KTDataTable = /** @class */ (function (_super) {
839
879
  * @returns {void}
840
880
  */
841
881
  KTDataTable.prototype._noticeOnTable = function (message) {
842
- var _a;
843
882
  if (message === void 0) { message = ''; }
844
- var row = this._tbodyElement.insertRow();
883
+ var row = this._tableElement.tBodies[0].insertRow();
845
884
  var cell = row.insertCell();
846
- cell.colSpan = ((_a = this._getTableHeaders()) === null || _a === void 0 ? void 0 : _a.length) || 0;
885
+ cell.colSpan = this._theadElement
886
+ ? this._theadElement.querySelectorAll('th').length
887
+ : 0;
847
888
  cell.innerHTML = message;
848
889
  };
849
890
  KTDataTable.prototype._updatePagination = function () {
@@ -943,10 +984,8 @@ var KTDataTable = /** @class */ (function (_super) {
943
984
  * @return {HTMLElement} The container element.
944
985
  */
945
986
  KTDataTable.prototype._createPaginationContainer = function (_paginationElement) {
946
- var paginationContainer = document.createElement('div');
947
- paginationContainer.className = 'pagination';
948
- _paginationElement.appendChild(paginationContainer);
949
- return paginationContainer;
987
+ // No longer create a wrapping div. Just return the pagination element itself.
988
+ return _paginationElement;
950
989
  };
951
990
  /**
952
991
  * Creates the pagination buttons for the component.
@@ -974,7 +1013,9 @@ var KTDataTable = /** @class */ (function (_super) {
974
1013
  var range_1 = this._calculatePageRange(currentPage, totalPages, maxButtons);
975
1014
  // Add start ellipsis
976
1015
  if (range_1.start > 1) {
977
- paginationContainer.appendChild(createButton(more.text, more.class, false, function () { return _this._paginateData(Math.max(1, range_1.start - 1)); }));
1016
+ paginationContainer.appendChild(createButton(more.text, more.class, false, function () {
1017
+ return _this._paginateData(Math.max(1, range_1.start - 1));
1018
+ }));
978
1019
  }
979
1020
  var _loop_1 = function (i) {
980
1021
  paginationContainer.appendChild(createButton(number.text.replace('{page}', i.toString()), "".concat(number.class).concat(currentPage === i ? ' active disabled' : ''), currentPage === i, function () { return _this._paginateData(i); }));
@@ -985,7 +1026,9 @@ var KTDataTable = /** @class */ (function (_super) {
985
1026
  }
986
1027
  // Add end ellipsis
987
1028
  if (pageMoreEnabled && range_1.end < totalPages) {
988
- paginationContainer.appendChild(createButton(more.text, more.class, false, function () { return _this._paginateData(Math.min(totalPages, range_1.end + 1)); }));
1029
+ paginationContainer.appendChild(createButton(more.text, more.class, false, function () {
1030
+ return _this._paginateData(Math.min(totalPages, range_1.end + 1));
1031
+ }));
989
1032
  }
990
1033
  }
991
1034
  else {
@@ -1038,7 +1081,7 @@ var KTDataTable = /** @class */ (function (_super) {
1038
1081
  if (spinner) {
1039
1082
  spinner.style.display = 'block';
1040
1083
  }
1041
- this._element.classList.add('loading');
1084
+ this._element.classList.add(this._config.loadingClass);
1042
1085
  };
1043
1086
  // Method to hide the loading spinner
1044
1087
  KTDataTable.prototype._hideSpinner = function () {
@@ -1046,7 +1089,7 @@ var KTDataTable = /** @class */ (function (_super) {
1046
1089
  if (spinner) {
1047
1090
  spinner.style.display = 'none';
1048
1091
  }
1049
- this._element.classList.remove('loading');
1092
+ this._element.classList.remove(this._config.loadingClass);
1050
1093
  };
1051
1094
  // Method to create a spinner element if it doesn't exist
1052
1095
  KTDataTable.prototype._createSpinner = function () {
@@ -1054,9 +1097,11 @@ var KTDataTable = /** @class */ (function (_super) {
1054
1097
  return null;
1055
1098
  }
1056
1099
  var template = document.createElement('template');
1057
- template.innerHTML = this._config.loading.template.trim().replace('{content}', this._config.loading.content);
1100
+ template.innerHTML = this._config.loading.template
1101
+ .trim()
1102
+ .replace('{content}', this._config.loading.content);
1058
1103
  var spinner = template.content.firstChild;
1059
- spinner.setAttribute('data-datatable-spinner', 'true');
1104
+ spinner.setAttribute('data-kt-datatable-spinner', 'true');
1060
1105
  this._tableElement.appendChild(spinner);
1061
1106
  return spinner;
1062
1107
  };
@@ -1125,25 +1170,8 @@ var KTDataTable = /** @class */ (function (_super) {
1125
1170
  }
1126
1171
  return id;
1127
1172
  };
1128
- /**
1129
- * Sorts the data in the table by the specified field.
1130
- * @param sortField The field to sort by.
1131
- */
1132
- KTDataTable.prototype._sort = function (sortField) {
1133
- // Determine the new sort order based on the current state
1134
- var newSortOrder = this._toggleSortOrder(sortField);
1135
- // Update the current sort field and order
1136
- this._config._state.sortField = sortField;
1137
- this._config._state.sortOrder = newSortOrder;
1138
- this._fireEvent('sort', { field: sortField, order: newSortOrder });
1139
- this._dispatchEvent('sort', { field: sortField, order: newSortOrder });
1140
- // Fetch data from the server with the new sort order
1141
- this._updateData();
1142
- };
1143
1173
  KTDataTable.prototype._dispose = function () {
1144
- if (this._headerCheckElement) {
1145
- this._headerCheckElement.removeEventListener('click', this._checkboxListener);
1146
- }
1174
+ // Remove all event listeners and clean up resources
1147
1175
  };
1148
1176
  KTDataTable.prototype._debounce = function (func, wait) {
1149
1177
  var timeout;
@@ -1160,146 +1188,6 @@ var KTDataTable = /** @class */ (function (_super) {
1160
1188
  timeout = window.setTimeout(later, wait);
1161
1189
  };
1162
1190
  };
1163
- /**
1164
- * Event handlers
1165
- */
1166
- KTDataTable.prototype._checkboxHandler = function () {
1167
- var _this = this;
1168
- // Handle header checkbox change event
1169
- this._headerCheckElement.addEventListener('click', this._checkboxListener);
1170
- // Handle target checbox change event
1171
- KTEventHandler.on(document.body, this._config.attributes.checkbox, 'input', function (event) {
1172
- _this._checkboxUpdate(event); // Update checkbox state based on checked rows
1173
- });
1174
- };
1175
- /**
1176
- * Checks if element is checked
1177
- * @returns {boolean}
1178
- */
1179
- KTDataTable.prototype._isChecked = function () {
1180
- return this._headerChecked;
1181
- };
1182
- /**
1183
- * Change checkbox state
1184
- * @param checked The new state of the checkbox
1185
- * @returns {void}
1186
- */
1187
- KTDataTable.prototype._change = function (checked) {
1188
- var payload = { cancel: false };
1189
- this._fireEvent('change', payload);
1190
- this._dispatchEvent('change', payload);
1191
- if (payload.cancel === true) {
1192
- return;
1193
- }
1194
- this._headerChecked = checked;
1195
- this._headerCheckElement.checked = checked;
1196
- if (this._targetElements) {
1197
- this._targetElements.forEach(function (element) {
1198
- if (element) {
1199
- element.checked = checked;
1200
- }
1201
- });
1202
- }
1203
- this._fireEvent('changed');
1204
- this._dispatchEvent('changed');
1205
- };
1206
- /**
1207
- * Toggle checkbox state
1208
- * @param event The event if available
1209
- * @returns {void}
1210
- */
1211
- KTDataTable.prototype._checkboxToggle = function (event) {
1212
- var checked = !this._isChecked();
1213
- var eventType = checked ? 'checked' : 'unchecked';
1214
- this._fireEvent(eventType);
1215
- this._dispatchEvent(eventType);
1216
- this._change(checked);
1217
- };
1218
- /**
1219
- * Update checkbox state based on checked rows
1220
- * @param event The event if available
1221
- * @returns {void}
1222
- */
1223
- KTDataTable.prototype._checkboxUpdate = function (event) {
1224
- var checked = 0;
1225
- var total = this._targetElements.length;
1226
- for (var i = 0; i < total; i++) {
1227
- var element = this._targetElements[i];
1228
- if (!element) {
1229
- continue;
1230
- }
1231
- var row = element.closest('tr');
1232
- if (!row) {
1233
- continue;
1234
- }
1235
- if (element.checked) {
1236
- row.classList.add(this._config.checkbox.checkedClass);
1237
- checked++;
1238
- }
1239
- else {
1240
- row.classList.remove(this._config.checkbox.checkedClass);
1241
- }
1242
- }
1243
- if (checked === 0) {
1244
- this._headerCheckElement.indeterminate = false;
1245
- this._change(false);
1246
- }
1247
- if (checked > 0 && checked < total) {
1248
- this._headerCheckElement.indeterminate = true;
1249
- }
1250
- if (checked === total) {
1251
- this._headerCheckElement.indeterminate = false;
1252
- this._change(true);
1253
- }
1254
- };
1255
- /**
1256
- * Get checked row IDs
1257
- * @returns {string[]} An array of checked row IDs
1258
- */
1259
- KTDataTable.prototype._getChecked = function () {
1260
- var checked = [];
1261
- this._targetElements.forEach(function (element) {
1262
- if (element && element.checked) {
1263
- var value = element.value;
1264
- if (value) {
1265
- checked.push(value);
1266
- }
1267
- }
1268
- });
1269
- return checked;
1270
- };
1271
- KTDataTable.prototype.isChecked = function () {
1272
- return this._isChecked();
1273
- };
1274
- KTDataTable.prototype.toggle = function () {
1275
- this._checkboxToggle();
1276
- };
1277
- /**
1278
- * Check all rows
1279
- * @returns {void}
1280
- */
1281
- KTDataTable.prototype.check = function () {
1282
- this._change(true);
1283
- this._checkboxUpdate();
1284
- };
1285
- /**
1286
- * Uncheck all rows
1287
- * @returns {void}
1288
- */
1289
- KTDataTable.prototype.uncheck = function () {
1290
- this._change(false);
1291
- };
1292
- /**
1293
- * Get checked row IDs
1294
- * @returns {string[]} An array of checked row IDs
1295
- */
1296
- KTDataTable.prototype.getChecked = function () {
1297
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1298
- return this._getChecked();
1299
- };
1300
- KTDataTable.prototype.update = function () {
1301
- this._checkboxUpdate();
1302
- };
1303
1191
  /**
1304
1192
  * Gets the current state of the table.
1305
1193
  * @returns {KTDataTableStateInterface} The current state of the table.
@@ -1328,8 +1216,15 @@ var KTDataTable = /** @class */ (function (_super) {
1328
1216
  * @param field The field to sort by.
1329
1217
  */
1330
1218
  KTDataTable.prototype.sort = function (field) {
1331
- // Sort the data
1332
- this._sort(field);
1219
+ // Use the sort handler to update state and trigger sorting
1220
+ var state = this.getState();
1221
+ var sortOrder = this._sortHandler.toggleSortOrder(state.sortField, state.sortOrder, field);
1222
+ this._sortHandler.setSortIcon(field, sortOrder);
1223
+ this._config._state.sortField = field;
1224
+ this._config._state.sortOrder = sortOrder;
1225
+ this._fireEvent('sort', { field: field, order: sortOrder });
1226
+ this._dispatchEvent('sort', { field: field, order: sortOrder });
1227
+ this._updateData();
1333
1228
  };
1334
1229
  /**
1335
1230
  * Navigates to the specified page in the data table.
@@ -1399,7 +1294,7 @@ var KTDataTable = /** @class */ (function (_super) {
1399
1294
  */
1400
1295
  KTDataTable.prototype.setFilter = function (filter) {
1401
1296
  this._config._state.filters = __spreadArray(__spreadArray([], (this.getState().filters || []).filter(function (f) { return f.column !== filter.column; }), true), [
1402
- filter
1297
+ filter,
1403
1298
  ], false);
1404
1299
  return this;
1405
1300
  };
@@ -1411,17 +1306,18 @@ var KTDataTable = /** @class */ (function (_super) {
1411
1306
  this.reload();
1412
1307
  };
1413
1308
  /**
1414
- * Create KTDataTable instances for all elements with a data-datatable="true" attribute.
1309
+ * Create KTDataTable instances for all elements with a data-kt-datatable="true" attribute.
1415
1310
  *
1416
1311
  * This function should be called after the control(s) have been
1417
1312
  * loaded and parsed by the browser. It will create instances of
1418
- * KTDataTable for all elements with a data-datatable="true" attribute.
1313
+ * KTDataTable for all elements with a data-kt-datatable="true" attribute.
1419
1314
  */
1420
1315
  KTDataTable.createInstances = function () {
1421
1316
  var _this = this;
1422
- var elements = document.querySelectorAll('[data-datatable="true"]');
1317
+ var elements = document.querySelectorAll('[data-kt-datatable="true"]');
1423
1318
  elements.forEach(function (element) {
1424
- if (element.hasAttribute('data-datatable') && !element.classList.contains('datatable-initialized')) {
1319
+ if (element.hasAttribute('data-kt-datatable') &&
1320
+ !element.classList.contains('datatable-initialized')) {
1425
1321
  /**
1426
1322
  * Create an instance of KTDataTable for the given element
1427
1323
  * @param element The element to create an instance for
@@ -1448,9 +1344,55 @@ var KTDataTable = /** @class */ (function (_super) {
1448
1344
  */
1449
1345
  KTDataTable.init = function () {
1450
1346
  // Create instances of KTDataTable for all elements with a
1451
- // data-datatable="true" attribute
1347
+ // data-kt-datatable="true" attribute
1452
1348
  KTDataTable.createInstances();
1453
1349
  };
1350
+ /**
1351
+ * Check if all visible rows are checked (header checkbox state)
1352
+ * @returns {boolean}
1353
+ */
1354
+ KTDataTable.prototype.isChecked = function () {
1355
+ return this._checkbox.isChecked();
1356
+ };
1357
+ /**
1358
+ * Toggle all visible row checkboxes (header checkbox)
1359
+ * @returns {void}
1360
+ */
1361
+ KTDataTable.prototype.toggle = function () {
1362
+ this._checkbox.toggle();
1363
+ };
1364
+ /**
1365
+ * Check all visible row checkboxes
1366
+ * @returns {void}
1367
+ */
1368
+ KTDataTable.prototype.check = function () {
1369
+ this._checkbox.check();
1370
+ this._fireEvent('checked');
1371
+ this._dispatchEvent('checked');
1372
+ };
1373
+ /**
1374
+ * Uncheck all visible row checkboxes
1375
+ * @returns {void}
1376
+ */
1377
+ KTDataTable.prototype.uncheck = function () {
1378
+ this._checkbox.uncheck();
1379
+ this._fireEvent('unchecked');
1380
+ this._dispatchEvent('unchecked');
1381
+ };
1382
+ /**
1383
+ * Get all checked row IDs (across all pages if preserveSelection is true)
1384
+ * @returns {string[]}
1385
+ */
1386
+ KTDataTable.prototype.getChecked = function () {
1387
+ return this._checkbox.getChecked();
1388
+ };
1389
+ /**
1390
+ * Reapply checked state to visible checkboxes (after redraw/pagination)
1391
+ * @returns {void}
1392
+ */
1393
+ KTDataTable.prototype.update = function () {
1394
+ this._checkbox.updateState();
1395
+ };
1454
1396
  /**
1455
1397
  * Static variables
1456
1398
  */
@@ -1458,4 +1400,7 @@ var KTDataTable = /** @class */ (function (_super) {
1458
1400
  return KTDataTable;
1459
1401
  }(KTComponent));
1460
1402
  export { KTDataTable };
1403
+ if (typeof window !== 'undefined') {
1404
+ window.KTDataTable = KTDataTable;
1405
+ }
1461
1406
  //# sourceMappingURL=datatable.js.map