@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.
- package/dist/ktui.js +16038 -17101
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/lib/cjs/components/accordion/accordion.js +20 -11
- package/lib/cjs/components/accordion/accordion.js.map +1 -1
- package/lib/cjs/components/accordion/index.js +4 -0
- package/lib/cjs/components/accordion/index.js.map +1 -1
- package/lib/cjs/components/accordion/types.js +4 -0
- package/lib/cjs/components/accordion/types.js.map +1 -1
- package/lib/cjs/components/collapse/collapse.js +13 -7
- package/lib/cjs/components/collapse/collapse.js.map +1 -1
- package/lib/cjs/components/collapse/index.js +4 -0
- package/lib/cjs/components/collapse/index.js.map +1 -1
- package/lib/cjs/components/collapse/types.js +4 -0
- package/lib/cjs/components/collapse/types.js.map +1 -1
- package/lib/cjs/components/component.js +12 -41
- package/lib/cjs/components/component.js.map +1 -1
- package/lib/cjs/components/constants.js +4 -0
- package/lib/cjs/components/constants.js.map +1 -1
- package/lib/cjs/components/datatable/datatable-checkbox.js +217 -0
- package/lib/cjs/components/datatable/datatable-checkbox.js.map +1 -0
- package/lib/cjs/components/datatable/datatable-sort.js +91 -0
- package/lib/cjs/components/datatable/datatable-sort.js.map +1 -0
- package/lib/cjs/components/datatable/datatable.js +294 -349
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/components/datatable/index.js +4 -0
- package/lib/cjs/components/datatable/index.js.map +1 -1
- package/lib/cjs/components/datatable/types.js +4 -0
- package/lib/cjs/components/datatable/types.js.map +1 -1
- package/lib/cjs/components/datepicker/calendar.js +1061 -0
- package/lib/cjs/components/datepicker/calendar.js.map +1 -0
- package/lib/cjs/components/datepicker/config.js +332 -0
- package/lib/cjs/components/datepicker/config.js.map +1 -0
- package/lib/cjs/components/datepicker/datepicker.js +949 -0
- package/lib/cjs/components/datepicker/datepicker.js.map +1 -0
- package/lib/cjs/components/datepicker/dropdown.js +635 -0
- package/lib/cjs/components/datepicker/dropdown.js.map +1 -0
- package/lib/cjs/components/datepicker/events.js +129 -0
- package/lib/cjs/components/datepicker/events.js.map +1 -0
- package/lib/cjs/components/datepicker/index.js +13 -0
- package/lib/cjs/components/datepicker/index.js.map +1 -0
- package/lib/cjs/components/datepicker/keyboard.js +536 -0
- package/lib/cjs/components/datepicker/keyboard.js.map +1 -0
- package/lib/cjs/components/datepicker/locales.js +78 -0
- package/lib/cjs/components/datepicker/locales.js.map +1 -0
- package/lib/cjs/components/datepicker/templates.js +403 -0
- package/lib/cjs/components/datepicker/templates.js.map +1 -0
- package/lib/cjs/components/datepicker/types.js +23 -0
- package/lib/cjs/components/datepicker/types.js.map +1 -0
- package/lib/cjs/components/datepicker/utils.js +524 -0
- package/lib/cjs/components/datepicker/utils.js.map +1 -0
- package/lib/cjs/components/dismiss/dismiss.js +10 -6
- package/lib/cjs/components/dismiss/dismiss.js.map +1 -1
- package/lib/cjs/components/dismiss/index.js +4 -0
- package/lib/cjs/components/dismiss/index.js.map +1 -1
- package/lib/cjs/components/dismiss/types.js +4 -0
- package/lib/cjs/components/dismiss/types.js.map +1 -1
- package/lib/cjs/components/drawer/drawer.js +54 -28
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/drawer/index.js +4 -0
- package/lib/cjs/components/drawer/index.js.map +1 -1
- package/lib/cjs/components/drawer/types.js +4 -0
- package/lib/cjs/components/drawer/types.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js +145 -115
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/dropdown/index.js +4 -0
- package/lib/cjs/components/dropdown/index.js.map +1 -1
- package/lib/cjs/components/dropdown/types.js +4 -0
- package/lib/cjs/components/dropdown/types.js.map +1 -1
- package/lib/cjs/components/image-input/image-input.js +21 -16
- package/lib/cjs/components/image-input/image-input.js.map +1 -1
- package/lib/cjs/components/image-input/index.js +4 -0
- package/lib/cjs/components/image-input/index.js.map +1 -1
- package/lib/cjs/components/image-input/types.js +4 -0
- package/lib/cjs/components/image-input/types.js.map +1 -1
- package/lib/cjs/components/modal/index.js +4 -0
- package/lib/cjs/components/modal/index.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +26 -19
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/modal/types.js +4 -0
- package/lib/cjs/components/modal/types.js.map +1 -1
- package/lib/cjs/components/reparent/index.js +4 -0
- package/lib/cjs/components/reparent/index.js.map +1 -1
- package/lib/cjs/components/reparent/reparent.js +13 -5
- package/lib/cjs/components/reparent/reparent.js.map +1 -1
- package/lib/cjs/components/reparent/types.js +4 -0
- package/lib/cjs/components/reparent/types.js.map +1 -1
- package/lib/cjs/components/scrollable/index.js +4 -0
- package/lib/cjs/components/scrollable/index.js.map +1 -1
- package/lib/cjs/components/scrollable/scrollable.js +17 -10
- package/lib/cjs/components/scrollable/scrollable.js.map +1 -1
- package/lib/cjs/components/scrollable/types.js +4 -0
- package/lib/cjs/components/scrollable/types.js.map +1 -1
- package/lib/cjs/components/scrollspy/index.js +4 -0
- package/lib/cjs/components/scrollspy/index.js.map +1 -1
- package/lib/cjs/components/scrollspy/scrollspy.js +28 -17
- package/lib/cjs/components/scrollspy/scrollspy.js.map +1 -1
- package/lib/cjs/components/scrollspy/types.js +4 -0
- package/lib/cjs/components/scrollspy/types.js.map +1 -1
- package/lib/cjs/components/scrollto/index.js +4 -0
- package/lib/cjs/components/scrollto/index.js.map +1 -1
- package/lib/cjs/components/scrollto/scrollto.js +14 -8
- package/lib/cjs/components/scrollto/scrollto.js.map +1 -1
- package/lib/cjs/components/scrollto/types.js +4 -0
- package/lib/cjs/components/scrollto/types.js.map +1 -1
- package/lib/cjs/components/select/combobox.js +237 -0
- package/lib/cjs/components/select/combobox.js.map +1 -0
- package/lib/cjs/components/select/config.js +226 -0
- package/lib/cjs/components/select/config.js.map +1 -0
- package/lib/cjs/components/select/dropdown.js +429 -0
- package/lib/cjs/components/select/dropdown.js.map +1 -0
- package/lib/cjs/components/select/index.js +24 -0
- package/lib/cjs/components/select/index.js.map +1 -0
- package/lib/cjs/components/select/option.js +53 -0
- package/lib/cjs/components/select/option.js.map +1 -0
- package/lib/cjs/components/select/remote.js +414 -0
- package/lib/cjs/components/select/remote.js.map +1 -0
- package/lib/cjs/components/select/search.js +339 -0
- package/lib/cjs/components/select/search.js.map +1 -0
- package/lib/cjs/components/select/select.js +1538 -0
- package/lib/cjs/components/select/select.js.map +1 -0
- package/lib/cjs/components/select/tags.js +110 -0
- package/lib/cjs/components/select/tags.js.map +1 -0
- package/lib/cjs/components/select/templates.js +337 -0
- package/lib/cjs/components/select/templates.js.map +1 -0
- package/lib/cjs/components/select/types.js +19 -0
- package/lib/cjs/components/select/types.js.map +1 -0
- package/lib/cjs/components/select/utils.js +606 -0
- package/lib/cjs/components/select/utils.js.map +1 -0
- package/lib/cjs/components/stepper/index.js +4 -0
- package/lib/cjs/components/stepper/index.js.map +1 -1
- package/lib/cjs/components/stepper/stepper.js +20 -13
- package/lib/cjs/components/stepper/stepper.js.map +1 -1
- package/lib/cjs/components/stepper/types.js +4 -0
- package/lib/cjs/components/stepper/types.js.map +1 -1
- package/lib/cjs/components/sticky/index.js +4 -0
- package/lib/cjs/components/sticky/index.js.map +1 -1
- package/lib/cjs/components/sticky/sticky.js +60 -38
- package/lib/cjs/components/sticky/sticky.js.map +1 -1
- package/lib/cjs/components/sticky/types.js +4 -0
- package/lib/cjs/components/sticky/types.js.map +1 -1
- package/lib/cjs/components/tabs/index.js +4 -0
- package/lib/cjs/components/tabs/index.js.map +1 -1
- package/lib/cjs/components/tabs/tabs.js +34 -24
- package/lib/cjs/components/tabs/tabs.js.map +1 -1
- package/lib/cjs/components/tabs/types.js +4 -0
- package/lib/cjs/components/tabs/types.js.map +1 -1
- package/lib/cjs/components/theme-switch/index.js +10 -0
- package/lib/cjs/components/theme-switch/index.js.map +1 -0
- package/lib/cjs/components/theme-switch/theme-switch.js +143 -0
- package/lib/cjs/components/theme-switch/theme-switch.js.map +1 -0
- package/lib/cjs/components/theme-switch/types.js +7 -0
- package/lib/cjs/components/theme-switch/types.js.map +1 -0
- package/lib/cjs/components/toggle/index.js +4 -0
- package/lib/cjs/components/toggle/index.js.map +1 -1
- package/lib/cjs/components/toggle/toggle.js +11 -7
- package/lib/cjs/components/toggle/toggle.js.map +1 -1
- package/lib/cjs/components/toggle/types.js +4 -0
- package/lib/cjs/components/toggle/types.js.map +1 -1
- package/lib/cjs/components/toggle-password/index.js +4 -0
- package/lib/cjs/components/toggle-password/index.js.map +1 -1
- package/lib/cjs/components/toggle-password/toggle-password.js +12 -7
- package/lib/cjs/components/toggle-password/toggle-password.js.map +1 -1
- package/lib/cjs/components/toggle-password/types.js +4 -0
- package/lib/cjs/components/toggle-password/types.js.map +1 -1
- package/lib/cjs/components/tooltip/index.js +4 -0
- package/lib/cjs/components/tooltip/index.js.map +1 -1
- package/lib/cjs/components/tooltip/tooltip.js +51 -21
- package/lib/cjs/components/tooltip/tooltip.js.map +1 -1
- package/lib/cjs/components/tooltip/types.js +4 -0
- package/lib/cjs/components/tooltip/types.js.map +1 -1
- package/lib/cjs/helpers/data.js +5 -1
- package/lib/cjs/helpers/data.js.map +1 -1
- package/lib/cjs/helpers/dom.js +34 -29
- package/lib/cjs/helpers/dom.js.map +1 -1
- package/lib/cjs/helpers/event-handler.js +5 -1
- package/lib/cjs/helpers/event-handler.js.map +1 -1
- package/lib/cjs/helpers/utils.js +65 -11
- package/lib/cjs/helpers/utils.js.map +1 -1
- package/lib/cjs/index.js +18 -22
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.js +4 -0
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/components/accordion/accordion.js +20 -11
- package/lib/esm/components/accordion/accordion.js.map +1 -1
- package/lib/esm/components/accordion/index.js +4 -0
- package/lib/esm/components/accordion/index.js.map +1 -1
- package/lib/esm/components/accordion/types.js +4 -0
- package/lib/esm/components/accordion/types.js.map +1 -1
- package/lib/esm/components/collapse/collapse.js +13 -7
- package/lib/esm/components/collapse/collapse.js.map +1 -1
- package/lib/esm/components/collapse/index.js +4 -0
- package/lib/esm/components/collapse/index.js.map +1 -1
- package/lib/esm/components/collapse/types.js +4 -0
- package/lib/esm/components/collapse/types.js.map +1 -1
- package/lib/esm/components/component.js +12 -41
- package/lib/esm/components/component.js.map +1 -1
- package/lib/esm/components/constants.js +4 -0
- package/lib/esm/components/constants.js.map +1 -1
- package/lib/esm/components/datatable/datatable-checkbox.js +214 -0
- package/lib/esm/components/datatable/datatable-checkbox.js.map +1 -0
- package/lib/esm/components/datatable/datatable-sort.js +88 -0
- package/lib/esm/components/datatable/datatable-sort.js.map +1 -0
- package/lib/esm/components/datatable/datatable.js +294 -349
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/components/datatable/index.js +4 -0
- package/lib/esm/components/datatable/index.js.map +1 -1
- package/lib/esm/components/datatable/types.js +4 -0
- package/lib/esm/components/datatable/types.js.map +1 -1
- package/lib/esm/components/datepicker/calendar.js +1058 -0
- package/lib/esm/components/datepicker/calendar.js.map +1 -0
- package/lib/esm/components/datepicker/config.js +329 -0
- package/lib/esm/components/datepicker/config.js.map +1 -0
- package/lib/esm/components/datepicker/datepicker.js +946 -0
- package/lib/esm/components/datepicker/datepicker.js.map +1 -0
- package/lib/esm/components/datepicker/dropdown.js +632 -0
- package/lib/esm/components/datepicker/dropdown.js.map +1 -0
- package/lib/esm/components/datepicker/events.js +126 -0
- package/lib/esm/components/datepicker/events.js.map +1 -0
- package/lib/esm/components/datepicker/index.js +9 -0
- package/lib/esm/components/datepicker/index.js.map +1 -0
- package/lib/esm/components/datepicker/keyboard.js +533 -0
- package/lib/esm/components/datepicker/keyboard.js.map +1 -0
- package/lib/esm/components/datepicker/locales.js +74 -0
- package/lib/esm/components/datepicker/locales.js.map +1 -0
- package/lib/esm/components/datepicker/templates.js +390 -0
- package/lib/esm/components/datepicker/templates.js.map +1 -0
- package/lib/esm/components/datepicker/types.js +20 -0
- package/lib/esm/components/datepicker/types.js.map +1 -0
- package/lib/esm/components/datepicker/utils.js +508 -0
- package/lib/esm/components/datepicker/utils.js.map +1 -0
- package/lib/esm/components/dismiss/dismiss.js +10 -6
- package/lib/esm/components/dismiss/dismiss.js.map +1 -1
- package/lib/esm/components/dismiss/index.js +4 -0
- package/lib/esm/components/dismiss/index.js.map +1 -1
- package/lib/esm/components/dismiss/types.js +4 -0
- package/lib/esm/components/dismiss/types.js.map +1 -1
- package/lib/esm/components/drawer/drawer.js +54 -28
- package/lib/esm/components/drawer/drawer.js.map +1 -1
- package/lib/esm/components/drawer/index.js +4 -0
- package/lib/esm/components/drawer/index.js.map +1 -1
- package/lib/esm/components/drawer/types.js +4 -0
- package/lib/esm/components/drawer/types.js.map +1 -1
- package/lib/esm/components/dropdown/dropdown.js +146 -116
- package/lib/esm/components/dropdown/dropdown.js.map +1 -1
- package/lib/esm/components/dropdown/index.js +4 -0
- package/lib/esm/components/dropdown/index.js.map +1 -1
- package/lib/esm/components/dropdown/types.js +4 -0
- package/lib/esm/components/dropdown/types.js.map +1 -1
- package/lib/esm/components/image-input/image-input.js +21 -16
- package/lib/esm/components/image-input/image-input.js.map +1 -1
- package/lib/esm/components/image-input/index.js +4 -0
- package/lib/esm/components/image-input/index.js.map +1 -1
- package/lib/esm/components/image-input/types.js +4 -0
- package/lib/esm/components/image-input/types.js.map +1 -1
- package/lib/esm/components/modal/index.js +4 -0
- package/lib/esm/components/modal/index.js.map +1 -1
- package/lib/esm/components/modal/modal.js +26 -19
- package/lib/esm/components/modal/modal.js.map +1 -1
- package/lib/esm/components/modal/types.js +4 -0
- package/lib/esm/components/modal/types.js.map +1 -1
- package/lib/esm/components/reparent/index.js +4 -0
- package/lib/esm/components/reparent/index.js.map +1 -1
- package/lib/esm/components/reparent/reparent.js +13 -5
- package/lib/esm/components/reparent/reparent.js.map +1 -1
- package/lib/esm/components/reparent/types.js +4 -0
- package/lib/esm/components/reparent/types.js.map +1 -1
- package/lib/esm/components/scrollable/index.js +4 -0
- package/lib/esm/components/scrollable/index.js.map +1 -1
- package/lib/esm/components/scrollable/scrollable.js +17 -10
- package/lib/esm/components/scrollable/scrollable.js.map +1 -1
- package/lib/esm/components/scrollable/types.js +4 -0
- package/lib/esm/components/scrollable/types.js.map +1 -1
- package/lib/esm/components/scrollspy/index.js +4 -0
- package/lib/esm/components/scrollspy/index.js.map +1 -1
- package/lib/esm/components/scrollspy/scrollspy.js +28 -17
- package/lib/esm/components/scrollspy/scrollspy.js.map +1 -1
- package/lib/esm/components/scrollspy/types.js +4 -0
- package/lib/esm/components/scrollspy/types.js.map +1 -1
- package/lib/esm/components/scrollto/index.js +4 -0
- package/lib/esm/components/scrollto/index.js.map +1 -1
- package/lib/esm/components/scrollto/scrollto.js +14 -8
- package/lib/esm/components/scrollto/scrollto.js.map +1 -1
- package/lib/esm/components/scrollto/types.js +4 -0
- package/lib/esm/components/scrollto/types.js.map +1 -1
- package/lib/esm/components/select/combobox.js +234 -0
- package/lib/esm/components/select/combobox.js.map +1 -0
- package/lib/esm/components/select/config.js +223 -0
- package/lib/esm/components/select/config.js.map +1 -0
- package/lib/esm/components/select/dropdown.js +426 -0
- package/lib/esm/components/select/dropdown.js.map +1 -0
- package/lib/esm/components/select/index.js +12 -0
- package/lib/esm/components/select/index.js.map +1 -0
- package/lib/esm/components/select/option.js +50 -0
- package/lib/esm/components/select/option.js.map +1 -0
- package/lib/esm/components/select/remote.js +411 -0
- package/lib/esm/components/select/remote.js.map +1 -0
- package/lib/esm/components/select/search.js +336 -0
- package/lib/esm/components/select/search.js.map +1 -0
- package/lib/esm/components/select/select.js +1535 -0
- package/lib/esm/components/select/select.js.map +1 -0
- package/lib/esm/components/select/tags.js +107 -0
- package/lib/esm/components/select/tags.js.map +1 -0
- package/lib/esm/components/select/templates.js +332 -0
- package/lib/esm/components/select/templates.js.map +1 -0
- package/lib/esm/components/select/types.js +16 -0
- package/lib/esm/components/select/types.js.map +1 -0
- package/lib/esm/components/select/utils.js +598 -0
- package/lib/esm/components/select/utils.js.map +1 -0
- package/lib/esm/components/stepper/index.js +4 -0
- package/lib/esm/components/stepper/index.js.map +1 -1
- package/lib/esm/components/stepper/stepper.js +20 -13
- package/lib/esm/components/stepper/stepper.js.map +1 -1
- package/lib/esm/components/stepper/types.js +4 -0
- package/lib/esm/components/stepper/types.js.map +1 -1
- package/lib/esm/components/sticky/index.js +4 -0
- package/lib/esm/components/sticky/index.js.map +1 -1
- package/lib/esm/components/sticky/sticky.js +60 -38
- package/lib/esm/components/sticky/sticky.js.map +1 -1
- package/lib/esm/components/sticky/types.js +4 -0
- package/lib/esm/components/sticky/types.js.map +1 -1
- package/lib/esm/components/tabs/index.js +4 -0
- package/lib/esm/components/tabs/index.js.map +1 -1
- package/lib/esm/components/tabs/tabs.js +34 -24
- package/lib/esm/components/tabs/tabs.js.map +1 -1
- package/lib/esm/components/tabs/types.js +4 -0
- package/lib/esm/components/tabs/types.js.map +1 -1
- package/lib/esm/components/theme-switch/index.js +6 -0
- package/lib/esm/components/theme-switch/index.js.map +1 -0
- package/lib/esm/components/theme-switch/theme-switch.js +140 -0
- package/lib/esm/components/theme-switch/theme-switch.js.map +1 -0
- package/lib/esm/components/theme-switch/types.js +6 -0
- package/lib/esm/components/theme-switch/types.js.map +1 -0
- package/lib/esm/components/toggle/index.js +4 -0
- package/lib/esm/components/toggle/index.js.map +1 -1
- package/lib/esm/components/toggle/toggle.js +11 -7
- package/lib/esm/components/toggle/toggle.js.map +1 -1
- package/lib/esm/components/toggle/types.js +4 -0
- package/lib/esm/components/toggle/types.js.map +1 -1
- package/lib/esm/components/toggle-password/index.js +4 -0
- package/lib/esm/components/toggle-password/index.js.map +1 -1
- package/lib/esm/components/toggle-password/toggle-password.js +12 -7
- package/lib/esm/components/toggle-password/toggle-password.js.map +1 -1
- package/lib/esm/components/toggle-password/types.js +4 -0
- package/lib/esm/components/toggle-password/types.js.map +1 -1
- package/lib/esm/components/tooltip/index.js +4 -0
- package/lib/esm/components/tooltip/index.js.map +1 -1
- package/lib/esm/components/tooltip/tooltip.js +52 -22
- package/lib/esm/components/tooltip/tooltip.js.map +1 -1
- package/lib/esm/components/tooltip/types.js +4 -0
- package/lib/esm/components/tooltip/types.js.map +1 -1
- package/lib/esm/helpers/data.js +5 -1
- package/lib/esm/helpers/data.js.map +1 -1
- package/lib/esm/helpers/dom.js +34 -29
- package/lib/esm/helpers/dom.js.map +1 -1
- package/lib/esm/helpers/event-handler.js +5 -1
- package/lib/esm/helpers/event-handler.js.map +1 -1
- package/lib/esm/helpers/utils.js +65 -11
- package/lib/esm/helpers/utils.js.map +1 -1
- package/lib/esm/index.js +14 -16
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.js +4 -0
- package/lib/esm/types.js.map +1 -1
- package/package.json +16 -8
- package/src/components/accordion/accordion-menu.css +1 -2
- package/src/components/accordion/accordion.css +1 -1
- package/src/components/accordion/accordion.ts +1 -1
- package/src/components/accordion/index.ts +1 -1
- package/src/components/accordion/types.ts +1 -1
- package/src/components/alert/alert.css +1 -1
- package/src/components/avatar/avatar.css +1 -1
- package/src/components/badge/badge.css +1 -1
- package/src/components/breadcrumb/breadcrumb.css +1 -1
- package/src/components/btn/btn.css +1 -1
- package/src/components/card/card.css +1 -1
- package/src/components/checkbox/checkbox.css +1 -1
- package/src/components/collapse/collapse.css +1 -1
- package/src/components/collapse/collapse.ts +1 -1
- package/src/components/collapse/index.ts +1 -1
- package/src/components/collapse/types.ts +1 -1
- package/src/components/component.ts +1 -1
- package/src/components/constants.ts +1 -1
- package/src/components/datatable/datatable-checkbox.ts +1 -1
- package/src/components/datatable/datatable-sort.ts +1 -1
- package/src/components/datatable/datatable.css +1 -1
- package/src/components/datatable/datatable.ts +38 -2
- package/src/components/datatable/index.ts +1 -1
- package/src/components/datatable/types.ts +1 -1
- package/src/components/datepicker/calendar.ts +1 -1
- package/src/components/datepicker/config.ts +1 -1
- package/src/components/datepicker/datepicker.css +1 -1
- package/src/components/datepicker/datepicker.ts +1 -1
- package/src/components/datepicker/dropdown.ts +1 -1
- package/src/components/datepicker/events.ts +1 -1
- package/src/components/datepicker/index.ts +1 -1
- package/src/components/datepicker/keyboard.ts +1 -1
- package/src/components/datepicker/locales.ts +1 -1
- package/src/components/datepicker/templates.ts +1 -1
- package/src/components/datepicker/types.ts +1 -1
- package/src/components/datepicker/utils.ts +1 -1
- package/src/components/dismiss/dismiss.css +1 -1
- package/src/components/dismiss/dismiss.ts +1 -1
- package/src/components/dismiss/index.ts +1 -1
- package/src/components/dismiss/types.ts +1 -1
- package/src/components/drawer/drawer.css +1 -1
- package/src/components/drawer/drawer.ts +1 -1
- package/src/components/drawer/index.ts +1 -1
- package/src/components/drawer/types.ts +1 -1
- package/src/components/dropdown/dropdown-menu.css +1 -1
- package/src/components/dropdown/dropdown.css +1 -1
- package/src/components/dropdown/dropdown.ts +1 -1
- package/src/components/dropdown/index.ts +1 -1
- package/src/components/dropdown/types.ts +1 -1
- package/src/components/form/form.css +1 -1
- package/src/components/image-input/image-input.css +1 -1
- package/src/components/image-input/image-input.ts +1 -1
- package/src/components/image-input/index.ts +1 -1
- package/src/components/image-input/types.ts +1 -1
- package/src/components/input/input-group.css +1 -1
- package/src/components/input/input.css +1 -1
- package/src/components/kbd/kbd.css +1 -1
- package/src/components/label/label.css +1 -1
- package/src/components/link/link.css +1 -1
- package/src/components/modal/index.ts +1 -1
- package/src/components/modal/modal.css +1 -1
- package/src/components/modal/modal.ts +1 -1
- package/src/components/modal/types.ts +1 -1
- package/src/components/pagination/pagination.css +1 -1
- package/src/components/popover/popover.css +1 -1
- package/src/components/progress/progress.css +2 -2
- package/src/components/radio/radio.css +1 -1
- package/src/components/reparent/index.ts +1 -1
- package/src/components/reparent/reparent.ts +1 -1
- package/src/components/reparent/types.ts +1 -1
- package/src/components/scrollable/index.ts +1 -1
- package/src/components/scrollable/scrollable.css +1 -1
- package/src/components/scrollable/scrollable.ts +1 -1
- package/src/components/scrollable/types.ts +1 -1
- package/src/components/scrollspy/index.ts +1 -1
- package/src/components/scrollspy/scrollspy.css +1 -1
- package/src/components/scrollspy/scrollspy.ts +1 -1
- package/src/components/scrollspy/types.ts +1 -1
- package/src/components/scrollto/index.ts +1 -1
- package/src/components/scrollto/scrollto.ts +1 -1
- package/src/components/scrollto/types.ts +1 -1
- package/src/components/select/combobox.ts +1 -1
- package/src/components/select/config.ts +1 -1
- package/src/components/select/dropdown.ts +1 -1
- package/src/components/select/index.ts +1 -1
- package/src/components/select/option.ts +1 -1
- package/src/components/select/remote.ts +1 -1
- package/src/components/select/search.ts +1 -1
- package/src/components/select/select.css +1 -1
- package/src/components/select/select.ts +1 -1
- package/src/components/select/tags.ts +1 -1
- package/src/components/select/templates.ts +1 -1
- package/src/components/select/types.ts +1 -1
- package/src/components/select/utils.ts +1 -1
- package/src/components/select/variants.css +1 -1
- package/src/components/separator/separator.css +1 -1
- package/src/components/skeleton/skeleton.css +1 -1
- package/src/components/stepper/index.ts +1 -1
- package/src/components/stepper/stepper.css +1 -1
- package/src/components/stepper/stepper.ts +1 -1
- package/src/components/stepper/types.ts +1 -1
- package/src/components/sticky/index.ts +1 -1
- package/src/components/sticky/sticky.css +1 -1
- package/src/components/sticky/sticky.ts +1 -1
- package/src/components/sticky/types.ts +1 -1
- package/src/components/switch/switch.css +1 -1
- package/src/components/table/table.css +2 -2
- package/src/components/tabs/index.ts +1 -1
- package/src/components/tabs/tabs.css +1 -1
- package/src/components/tabs/tabs.ts +1 -1
- package/src/components/tabs/types.ts +1 -1
- package/src/components/textarea/textarea.css +1 -1
- package/src/components/theme-switch/index.ts +1 -1
- package/src/components/theme-switch/theme-switch.css +1 -1
- package/src/components/theme-switch/theme-switch.ts +1 -1
- package/src/components/theme-switch/types.ts +1 -1
- package/src/components/toggle/index.ts +1 -1
- package/src/components/toggle/toggle.css +1 -1
- package/src/components/toggle/toggle.ts +1 -1
- package/src/components/toggle/types.ts +1 -1
- package/src/components/toggle-group/toggle-group.css +1 -1
- package/src/components/toggle-password/index.ts +1 -1
- package/src/components/toggle-password/toggle-password.css +1 -1
- package/src/components/toggle-password/toggle-password.ts +1 -1
- package/src/components/toggle-password/types.ts +1 -1
- package/src/components/tooltip/index.ts +1 -1
- package/src/components/tooltip/tooltip.css +1 -1
- package/src/components/tooltip/tooltip.ts +1 -1
- package/src/components/tooltip/types.ts +1 -1
- package/src/helpers/data.ts +1 -1
- package/src/helpers/dom.ts +1 -1
- package/src/helpers/event-handler.ts +1 -1
- package/src/helpers/utils.ts +1 -1
- package/src/index.ts +1 -1
- 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 =
|
|
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.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
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: '
|
|
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: '
|
|
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:
|
|
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: '
|
|
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:
|
|
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: '
|
|
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: '
|
|
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
|
-
|
|
236
|
-
|
|
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(/<[^>]*>| /g, '');
|
|
242
|
-
var bText = String(b).replace(/<[^>]*>| /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' &&
|
|
280
|
+
if (typeof value !== 'string' &&
|
|
281
|
+
typeof value !== 'number' &&
|
|
282
|
+
typeof value !== 'boolean') {
|
|
274
283
|
return false;
|
|
275
284
|
}
|
|
276
|
-
var valueText = String(value)
|
|
285
|
+
var valueText = String(value)
|
|
286
|
+
.replace(/<[^>]*>| /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=\"
|
|
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 =
|
|
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*/,
|
|
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
|
-
|
|
388
|
-
|
|
389
|
-
this._initChecbox(headerCheckElement);
|
|
390
|
-
}
|
|
430
|
+
// Initialize checkbox logic
|
|
431
|
+
this._checkbox.init();
|
|
391
432
|
this._attachSearchEvent();
|
|
392
|
-
if (typeof KTComponents !==
|
|
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 ||
|
|
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 &&
|
|
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
|
-
*
|
|
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
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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 =
|
|
551
|
-
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
807
|
-
if (
|
|
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.
|
|
883
|
+
var row = this._tableElement.tBodies[0].insertRow();
|
|
845
884
|
var cell = row.insertCell();
|
|
846
|
-
cell.colSpan =
|
|
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
|
-
|
|
947
|
-
|
|
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 () {
|
|
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 () {
|
|
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(
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|
-
//
|
|
1332
|
-
this.
|
|
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') &&
|
|
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
|