@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,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
|
|
4
|
+
* Copyright 2025 by Keenthemes Inc
|
|
5
|
+
*/
|
|
2
6
|
var __extends = (this && this.__extends) || (function () {
|
|
3
7
|
var extendStatics = function (d, b) {
|
|
4
8
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -35,8 +39,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
35
39
|
});
|
|
36
40
|
};
|
|
37
41
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g =
|
|
42
|
+
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);
|
|
43
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
44
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
45
|
function step(op) {
|
|
42
46
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -84,10 +88,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
84
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
89
|
exports.KTDataTable = void 0;
|
|
86
90
|
var component_1 = require("../component");
|
|
87
|
-
var event_handler_1 = require("../../helpers/event-handler");
|
|
88
91
|
var utils_1 = require("../../helpers/utils");
|
|
89
92
|
var index_1 = require("../../index");
|
|
90
93
|
var data_1 = require("../../helpers/data");
|
|
94
|
+
var datatable_checkbox_1 = require("./datatable-checkbox");
|
|
95
|
+
var datatable_sort_1 = require("./datatable-sort");
|
|
91
96
|
/**
|
|
92
97
|
* Custom DataTable plugin class with server-side API, pagination, and sorting
|
|
93
98
|
* @classdesc A custom KTComponent class that integrates server-side API, pagination, and sorting functionality into a table.
|
|
@@ -102,10 +107,11 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
102
107
|
function KTDataTable(element, config) {
|
|
103
108
|
var _this = _super.call(this) || this;
|
|
104
109
|
_this._name = 'datatable';
|
|
105
|
-
_this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
110
|
+
_this._originalTbodyClass = ''; // Store original tbody class
|
|
111
|
+
_this._originalTrClasses = []; // Store original tr classes
|
|
112
|
+
_this._originalTheadClass = ''; // Store original thead class
|
|
113
|
+
_this._originalTdClasses = []; // Store original td classes as a 2D array [row][col]
|
|
114
|
+
_this._originalThClasses = []; // Store original th classes
|
|
109
115
|
_this._data = [];
|
|
110
116
|
if (data_1.default.has(element, _this._name))
|
|
111
117
|
return _this;
|
|
@@ -115,13 +121,26 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
115
121
|
// Store the instance directly on the element
|
|
116
122
|
element.instance = _this;
|
|
117
123
|
_this._initElements();
|
|
124
|
+
// Initialize checkbox handler
|
|
125
|
+
_this._checkbox = (0, datatable_checkbox_1.createCheckboxHandler)(_this._element, _this._config, function (eventName, eventData) {
|
|
126
|
+
_this._fireEvent(eventName, eventData);
|
|
127
|
+
_this._dispatchEvent(eventName, eventData);
|
|
128
|
+
});
|
|
129
|
+
// Initialize sort handler
|
|
130
|
+
_this._sortHandler = (0, datatable_sort_1.createSortHandler)(_this._config, _this._theadElement, function () { return ({
|
|
131
|
+
sortField: _this.getState().sortField,
|
|
132
|
+
sortOrder: _this.getState().sortOrder,
|
|
133
|
+
}); }, function (field, order) {
|
|
134
|
+
_this._config._state.sortField = field;
|
|
135
|
+
_this._config._state.sortOrder = order;
|
|
136
|
+
}, _this._fireEvent.bind(_this), _this._dispatchEvent.bind(_this), _this._updateData.bind(_this));
|
|
137
|
+
_this._sortHandler.initSort();
|
|
118
138
|
if (_this._config.stateSave === false) {
|
|
119
139
|
_this._deleteState();
|
|
120
140
|
}
|
|
121
141
|
if (_this._config.stateSave) {
|
|
122
142
|
_this._loadState();
|
|
123
143
|
}
|
|
124
|
-
_this._initTableHeader();
|
|
125
144
|
_this._updateData();
|
|
126
145
|
_this._fireEvent('init');
|
|
127
146
|
_this._dispatchEvent('init');
|
|
@@ -133,6 +152,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
133
152
|
* @returns Default configuration merged with user-provided options
|
|
134
153
|
*/
|
|
135
154
|
KTDataTable.prototype._initDefaultConfig = function (config) {
|
|
155
|
+
var _this = this;
|
|
136
156
|
return __assign({
|
|
137
157
|
/**
|
|
138
158
|
* HTTP method for server-side API call
|
|
@@ -176,7 +196,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
176
196
|
/**
|
|
177
197
|
* CSS classes to be added to the pagination button
|
|
178
198
|
*/
|
|
179
|
-
class: '
|
|
199
|
+
class: 'kt-datatable-pagination-button',
|
|
180
200
|
/**
|
|
181
201
|
* Text to be displayed in the pagination button
|
|
182
202
|
*/
|
|
@@ -186,32 +206,32 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
186
206
|
/**
|
|
187
207
|
* CSS classes to be added to the previous pagination button
|
|
188
208
|
*/
|
|
189
|
-
class: '
|
|
209
|
+
class: 'kt-datatable-pagination-button kt-datatable-pagination-prev',
|
|
190
210
|
/**
|
|
191
211
|
* Text to be displayed in the previous pagination button
|
|
192
212
|
*/
|
|
193
|
-
text:
|
|
213
|
+
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",
|
|
194
214
|
},
|
|
195
215
|
next: {
|
|
196
216
|
/**
|
|
197
217
|
* CSS classes to be added to the next pagination button
|
|
198
218
|
*/
|
|
199
|
-
class: '
|
|
219
|
+
class: 'kt-datatable-pagination-button kt-datatable-pagination-next',
|
|
200
220
|
/**
|
|
201
221
|
* Text to be displayed in the next pagination button
|
|
202
222
|
*/
|
|
203
|
-
text:
|
|
223
|
+
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",
|
|
204
224
|
},
|
|
205
225
|
more: {
|
|
206
226
|
/**
|
|
207
227
|
* CSS classes to be added to the pagination more button
|
|
208
228
|
*/
|
|
209
|
-
class: '
|
|
229
|
+
class: 'kt-datatable-pagination-button kt-datatable-pagination-more',
|
|
210
230
|
/**
|
|
211
231
|
* Text to be displayed in the pagination more button
|
|
212
232
|
*/
|
|
213
233
|
text: '...',
|
|
214
|
-
}
|
|
234
|
+
},
|
|
215
235
|
},
|
|
216
236
|
/**
|
|
217
237
|
* Sorting options
|
|
@@ -221,7 +241,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
221
241
|
* CSS classes to be added to the sortable headers
|
|
222
242
|
*/
|
|
223
243
|
classes: {
|
|
224
|
-
base: '
|
|
244
|
+
base: 'kt-table-col',
|
|
225
245
|
asc: 'asc',
|
|
226
246
|
desc: 'desc',
|
|
227
247
|
},
|
|
@@ -234,22 +254,9 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
234
254
|
* @returns Sorted data array
|
|
235
255
|
*/
|
|
236
256
|
callback: function (data, sortField, sortOrder) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
* @param b Second value to be compared
|
|
241
|
-
* @returns 1 if a > b, -1 if a < b, 0 if a === b
|
|
242
|
-
*/
|
|
243
|
-
var compareValues = function (a, b) {
|
|
244
|
-
var aText = String(a).replace(/<[^>]*>| /g, '');
|
|
245
|
-
var bText = String(b).replace(/<[^>]*>| /g, '');
|
|
246
|
-
return aText > bText ? (sortOrder === 'asc' ? 1 : -1) : (aText < bText ? (sortOrder === 'asc' ? -1 : 1) : 0);
|
|
247
|
-
};
|
|
248
|
-
return data.sort(function (a, b) {
|
|
249
|
-
var aValue = a[sortField];
|
|
250
|
-
var bValue = b[sortField];
|
|
251
|
-
return compareValues(aValue, bValue);
|
|
252
|
-
});
|
|
257
|
+
return _this._sortHandler
|
|
258
|
+
? _this._sortHandler.sortData(data, sortField, sortOrder)
|
|
259
|
+
: data;
|
|
253
260
|
},
|
|
254
261
|
}, search: {
|
|
255
262
|
/**
|
|
@@ -273,14 +280,18 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
273
280
|
return false;
|
|
274
281
|
}
|
|
275
282
|
return Object.values(item).some(function (value) {
|
|
276
|
-
if (typeof value !== 'string' &&
|
|
283
|
+
if (typeof value !== 'string' &&
|
|
284
|
+
typeof value !== 'number' &&
|
|
285
|
+
typeof value !== 'boolean') {
|
|
277
286
|
return false;
|
|
278
287
|
}
|
|
279
|
-
var valueText = String(value)
|
|
288
|
+
var valueText = String(value)
|
|
289
|
+
.replace(/<[^>]*>| /g, '')
|
|
290
|
+
.toLowerCase();
|
|
280
291
|
return valueText.includes(search.toLowerCase());
|
|
281
292
|
});
|
|
282
293
|
});
|
|
283
|
-
}
|
|
294
|
+
},
|
|
284
295
|
},
|
|
285
296
|
/**
|
|
286
297
|
* Loading spinner options
|
|
@@ -289,11 +300,11 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
289
300
|
/**
|
|
290
301
|
* Template to be displayed during data fetching process
|
|
291
302
|
*/
|
|
292
|
-
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=\"
|
|
303
|
+
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",
|
|
293
304
|
/**
|
|
294
305
|
* Loading text to be displayed in the template
|
|
295
306
|
*/
|
|
296
|
-
content: 'Loading...'
|
|
307
|
+
content: 'Loading...',
|
|
297
308
|
},
|
|
298
309
|
/**
|
|
299
310
|
* Selectors of the elements to be targeted
|
|
@@ -302,39 +313,39 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
302
313
|
/**
|
|
303
314
|
* Data table element
|
|
304
315
|
*/
|
|
305
|
-
table: 'table[data-datatable-table="true"]',
|
|
316
|
+
table: 'table[data-kt-datatable-table="true"]',
|
|
306
317
|
/**
|
|
307
318
|
* Pagination info element
|
|
308
319
|
*/
|
|
309
|
-
info: '[data-datatable-info="true"]',
|
|
320
|
+
info: '[data-kt-datatable-info="true"]',
|
|
310
321
|
/**
|
|
311
322
|
* Page size dropdown element
|
|
312
323
|
*/
|
|
313
|
-
size: '[data-datatable-size="true"]',
|
|
324
|
+
size: '[data-kt-datatable-size="true"]',
|
|
314
325
|
/**
|
|
315
326
|
* Pagination element
|
|
316
327
|
*/
|
|
317
|
-
pagination: '[data-datatable-pagination="true"]',
|
|
328
|
+
pagination: '[data-kt-datatable-pagination="true"]',
|
|
318
329
|
/**
|
|
319
330
|
* Spinner element
|
|
320
331
|
*/
|
|
321
|
-
spinner: '[data-datatable-spinner="true"]',
|
|
332
|
+
spinner: '[data-kt-datatable-spinner="true"]',
|
|
322
333
|
/**
|
|
323
334
|
* Checkbox element
|
|
324
335
|
*/
|
|
325
|
-
check: '[data-datatable-check="true"]',
|
|
326
|
-
checkbox: '[data-datatable-row-check="true"]'
|
|
336
|
+
check: '[data-kt-datatable-check="true"]',
|
|
337
|
+
checkbox: '[data-kt-datatable-row-check="true"]',
|
|
327
338
|
},
|
|
328
339
|
/**
|
|
329
340
|
* Enable or disable state saving
|
|
330
341
|
*/
|
|
331
342
|
stateSave: true, checkbox: {
|
|
332
|
-
checkedClass: 'checked'
|
|
343
|
+
checkedClass: 'checked',
|
|
333
344
|
},
|
|
334
345
|
/**
|
|
335
346
|
* Private properties
|
|
336
347
|
*/
|
|
337
|
-
_state: {} }, config);
|
|
348
|
+
_state: {}, loadingClass: 'loading' }, config);
|
|
338
349
|
};
|
|
339
350
|
/**
|
|
340
351
|
* Initialize table, tbody, thead, info, size, and pagination elements
|
|
@@ -348,11 +359,14 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
348
359
|
/**
|
|
349
360
|
* Table body element
|
|
350
361
|
*/
|
|
351
|
-
this._tbodyElement =
|
|
362
|
+
this._tbodyElement =
|
|
363
|
+
this._tableElement.tBodies[0] || this._tableElement.createTBody();
|
|
352
364
|
/**
|
|
353
365
|
* Table head element
|
|
354
366
|
*/
|
|
355
367
|
this._theadElement = this._tableElement.tHead;
|
|
368
|
+
// Store original classes
|
|
369
|
+
this._storeOriginalClasses();
|
|
356
370
|
/**
|
|
357
371
|
* Pagination info element
|
|
358
372
|
*/
|
|
@@ -366,6 +380,35 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
366
380
|
*/
|
|
367
381
|
this._paginationElement = this._element.querySelector(this._config.attributes.pagination);
|
|
368
382
|
};
|
|
383
|
+
/**
|
|
384
|
+
* Store original classes from table elements
|
|
385
|
+
* @returns {void}
|
|
386
|
+
*/
|
|
387
|
+
KTDataTable.prototype._storeOriginalClasses = function () {
|
|
388
|
+
var _this = this;
|
|
389
|
+
// Store tbody class
|
|
390
|
+
if (this._tbodyElement) {
|
|
391
|
+
this._originalTbodyClass = this._tbodyElement.className || '';
|
|
392
|
+
}
|
|
393
|
+
// Store thead class and th classes
|
|
394
|
+
if (this._theadElement) {
|
|
395
|
+
this._originalTheadClass = this._theadElement.className || '';
|
|
396
|
+
// Store th classes
|
|
397
|
+
var thElements = this._theadElement.querySelectorAll('th');
|
|
398
|
+
this._originalThClasses = Array.from(thElements).map(function (th) { return th.className || ''; });
|
|
399
|
+
}
|
|
400
|
+
// Store tr and td classes
|
|
401
|
+
if (this._tbodyElement) {
|
|
402
|
+
var originalRows = this._tbodyElement.querySelectorAll('tr');
|
|
403
|
+
this._originalTrClasses = Array.from(originalRows).map(function (row) { return row.className || ''; });
|
|
404
|
+
// Store td classes as a 2D array
|
|
405
|
+
this._originalTdClasses = [];
|
|
406
|
+
Array.from(originalRows).forEach(function (row, rowIndex) {
|
|
407
|
+
var tdElements = row.querySelectorAll('td');
|
|
408
|
+
_this._originalTdClasses[rowIndex] = Array.from(tdElements).map(function (td) { return td.className || ''; });
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
};
|
|
369
412
|
/**
|
|
370
413
|
* Fetch data from the server or from the DOM if `apiEndpoint` is not defined.
|
|
371
414
|
* @returns {Promise<void>} Promise which is resolved after data has been fetched and checkbox plugin initialized.
|
|
@@ -375,7 +418,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
375
418
|
return __generator(this, function (_a) {
|
|
376
419
|
this._showSpinner(); // Show spinner before fetching data
|
|
377
420
|
// Fetch data from the DOM and initialize the checkbox plugin
|
|
378
|
-
return [2 /*return*/,
|
|
421
|
+
return [2 /*return*/, typeof this._config.apiEndpoint === 'undefined'
|
|
379
422
|
? this._fetchDataFromLocal().then(this._finalize.bind(this))
|
|
380
423
|
: this._fetchDataFromServer().then(this._finalize.bind(this))];
|
|
381
424
|
});
|
|
@@ -387,12 +430,10 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
387
430
|
*/
|
|
388
431
|
KTDataTable.prototype._finalize = function () {
|
|
389
432
|
this._element.classList.add('datatable-initialized');
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
this._initChecbox(headerCheckElement);
|
|
393
|
-
}
|
|
433
|
+
// Initialize checkbox logic
|
|
434
|
+
this._checkbox.init();
|
|
394
435
|
this._attachSearchEvent();
|
|
395
|
-
if (typeof index_1.default !==
|
|
436
|
+
if (typeof index_1.default !== 'undefined') {
|
|
396
437
|
index_1.default.init();
|
|
397
438
|
}
|
|
398
439
|
/**
|
|
@@ -407,7 +448,14 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
407
448
|
KTDataTable.prototype._attachSearchEvent = function () {
|
|
408
449
|
var _this = this;
|
|
409
450
|
var tableId = this._tableId();
|
|
410
|
-
var searchElement = document.querySelector("[data-datatable-search=\"#".concat(tableId, "\"]"));
|
|
451
|
+
var searchElement = document.querySelector("[data-kt-datatable-search=\"#".concat(tableId, "\"]"));
|
|
452
|
+
// Get search state
|
|
453
|
+
var search = this.getState().search;
|
|
454
|
+
// Set search value
|
|
455
|
+
if (searchElement) {
|
|
456
|
+
searchElement.value =
|
|
457
|
+
typeof search === 'string' ? search : String(search);
|
|
458
|
+
}
|
|
411
459
|
if (searchElement) {
|
|
412
460
|
// Check if a debounced search function already exists
|
|
413
461
|
if (searchElement._debouncedSearch) {
|
|
@@ -424,17 +472,6 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
424
472
|
searchElement.addEventListener('keyup', debouncedSearch);
|
|
425
473
|
}
|
|
426
474
|
};
|
|
427
|
-
/**
|
|
428
|
-
* Initialize the checkbox plugin
|
|
429
|
-
* @param {HTMLInputElement} headerCheckElement - The header checkbox element
|
|
430
|
-
* @returns {void}
|
|
431
|
-
*/
|
|
432
|
-
KTDataTable.prototype._initChecbox = function (headerCheckElement) {
|
|
433
|
-
this._headerCheckElement = headerCheckElement;
|
|
434
|
-
this._headerChecked = headerCheckElement.checked;
|
|
435
|
-
this._targetElements = this._element.querySelectorAll(this._config.attributes.checkbox);
|
|
436
|
-
this._checkboxHandler();
|
|
437
|
-
};
|
|
438
475
|
/**
|
|
439
476
|
* Fetch data from the DOM
|
|
440
477
|
* Fetch data from the table element and save it to the `originalData` state property.
|
|
@@ -447,10 +484,16 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
447
484
|
return __generator(this, function (_d) {
|
|
448
485
|
switch (_d.label) {
|
|
449
486
|
case 0:
|
|
487
|
+
this._fireEvent('fetch');
|
|
488
|
+
this._dispatchEvent('fetch');
|
|
450
489
|
_a = this.getState(), sortField = _a.sortField, sortOrder = _a.sortOrder, page = _a.page, pageSize = _a.pageSize, search = _a.search;
|
|
451
490
|
originalData = this.getState().originalData;
|
|
452
491
|
// If the table element or the original data is not defined, bail
|
|
453
|
-
if (!this._tableElement ||
|
|
492
|
+
if (!this._tableElement ||
|
|
493
|
+
originalData === undefined ||
|
|
494
|
+
this._tableConfigInvalidate() ||
|
|
495
|
+
this._localTableHeaderInvalidate() ||
|
|
496
|
+
this._localTableContentInvalidate()) {
|
|
454
497
|
this._deleteState();
|
|
455
498
|
_b = this._localExtractTableContent(), originalData_1 = _b.originalData, originalDataAttributes = _b.originalDataAttributes;
|
|
456
499
|
this._config._state.originalData = originalData_1;
|
|
@@ -458,12 +501,14 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
458
501
|
}
|
|
459
502
|
// Update the original data variable
|
|
460
503
|
originalData = this.getState().originalData;
|
|
461
|
-
_temp = this._data = __spreadArray([], originalData, true);
|
|
504
|
+
_temp = (this._data = __spreadArray([], originalData, true));
|
|
462
505
|
if (search) {
|
|
463
506
|
_temp = this._data = this._config.search.callback.call(this, this._data, search);
|
|
464
507
|
}
|
|
465
508
|
// If sorting is defined, sort the data
|
|
466
|
-
if (sortField !== undefined &&
|
|
509
|
+
if (sortField !== undefined &&
|
|
510
|
+
sortOrder !== undefined &&
|
|
511
|
+
sortOrder !== '') {
|
|
467
512
|
if (typeof this._config.sort.callback === 'function') {
|
|
468
513
|
this._data = this._config.sort.callback.call(this, this._data, sortField, sortOrder);
|
|
469
514
|
}
|
|
@@ -481,6 +526,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
481
526
|
case 1:
|
|
482
527
|
// Draw the data
|
|
483
528
|
_d.sent();
|
|
529
|
+
this._fireEvent('fetched');
|
|
530
|
+
this._dispatchEvent('fetched');
|
|
484
531
|
return [2 /*return*/];
|
|
485
532
|
}
|
|
486
533
|
});
|
|
@@ -512,30 +559,32 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
512
559
|
return false;
|
|
513
560
|
};
|
|
514
561
|
/**
|
|
515
|
-
*
|
|
562
|
+
* Extract the table content and returns it as an object containing an array of original data and an array of original data attributes.
|
|
516
563
|
*
|
|
517
564
|
* @returns {{originalData: T[], originalDataAttributes: KTDataTableAttributeInterface[]}} - An object containing an array of original data and an array of original data attributes.
|
|
518
565
|
*/
|
|
519
566
|
KTDataTable.prototype._localExtractTableContent = function () {
|
|
520
567
|
var originalData = [];
|
|
521
568
|
var originalDataAttributes = [];
|
|
569
|
+
this._storeOriginalClasses();
|
|
522
570
|
var rows = this._tbodyElement.querySelectorAll('tr');
|
|
571
|
+
var ths = this._theadElement
|
|
572
|
+
? this._theadElement.querySelectorAll('th')
|
|
573
|
+
: [];
|
|
523
574
|
rows.forEach(function (row) {
|
|
524
575
|
var dataRow = {};
|
|
525
576
|
var dataRowAttribute = {};
|
|
526
|
-
// Loop through each cell in the row
|
|
527
577
|
row.querySelectorAll('td').forEach(function (td, index) {
|
|
528
|
-
var _a;
|
|
529
|
-
var
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
578
|
+
var _a, _b, _c;
|
|
579
|
+
var colName = (_a = ths[index]) === null || _a === void 0 ? void 0 : _a.getAttribute('data-kt-datatable-column');
|
|
580
|
+
if (colName) {
|
|
581
|
+
dataRow[colName] = (_b = td.innerHTML) === null || _b === void 0 ? void 0 : _b.trim();
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
// Store the original HTML for fallback
|
|
585
|
+
dataRow[index] = (_c = td.innerHTML) === null || _c === void 0 ? void 0 : _c.trim();
|
|
586
|
+
}
|
|
537
587
|
});
|
|
538
|
-
// If the row has any data, add it to the original data array
|
|
539
588
|
if (Object.keys(dataRow).length > 0) {
|
|
540
589
|
originalData.push(dataRow);
|
|
541
590
|
originalDataAttributes.push(dataRowAttribute);
|
|
@@ -548,10 +597,13 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
548
597
|
* @returns {boolean} - Returns true if the table header is invalidated, false otherwise
|
|
549
598
|
*/
|
|
550
599
|
KTDataTable.prototype._localTableHeaderInvalidate = function () {
|
|
551
|
-
var _a;
|
|
552
600
|
var originalData = this.getState().originalData;
|
|
553
|
-
var currentTableHeaders =
|
|
554
|
-
|
|
601
|
+
var currentTableHeaders = this._theadElement
|
|
602
|
+
? this._theadElement.querySelectorAll('th').length
|
|
603
|
+
: 0;
|
|
604
|
+
var totalColumns = originalData.length
|
|
605
|
+
? Object.keys(originalData[0]).length
|
|
606
|
+
: 0;
|
|
555
607
|
return currentTableHeaders !== totalColumns;
|
|
556
608
|
};
|
|
557
609
|
/**
|
|
@@ -593,6 +645,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
593
645
|
return [4 /*yield*/, this._draw()];
|
|
594
646
|
case 6:
|
|
595
647
|
_a.sent();
|
|
648
|
+
this._fireEvent('fetched');
|
|
649
|
+
this._dispatchEvent('fetched');
|
|
596
650
|
return [2 /*return*/];
|
|
597
651
|
}
|
|
598
652
|
});
|
|
@@ -648,21 +702,51 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
648
702
|
requestBody = queryParams;
|
|
649
703
|
}
|
|
650
704
|
else if (requestMethod === 'GET') {
|
|
651
|
-
apiEndpointWithQueryParams =
|
|
705
|
+
apiEndpointWithQueryParams = this._createUrl(this._config.apiEndpoint);
|
|
652
706
|
apiEndpointWithQueryParams.search = queryParams.toString();
|
|
653
707
|
this._config.apiEndpoint = apiEndpointWithQueryParams.toString();
|
|
654
708
|
}
|
|
655
709
|
return [2 /*return*/, fetch(this._config.apiEndpoint, {
|
|
656
710
|
method: requestMethod,
|
|
657
711
|
body: requestBody,
|
|
658
|
-
headers: this._config.requestHeaders
|
|
712
|
+
headers: this._config.requestHeaders,
|
|
659
713
|
}).catch(function (error) {
|
|
714
|
+
// Trigger an error event
|
|
715
|
+
_this._fireEvent('error', { error: error });
|
|
716
|
+
_this._dispatchEvent('error', { error: error });
|
|
660
717
|
_this._noticeOnTable('Error performing fetch request: ' + String(error));
|
|
661
718
|
throw error;
|
|
662
719
|
})];
|
|
663
720
|
});
|
|
664
721
|
});
|
|
665
722
|
};
|
|
723
|
+
/**
|
|
724
|
+
* Creates a complete URL from a relative path or a full URL.
|
|
725
|
+
*
|
|
726
|
+
* This method accepts a string that can be either a relative path or a full URL.
|
|
727
|
+
* If the string is a complete URL (i.e., it contains a valid protocol), a URL
|
|
728
|
+
* object based on that string is returned. Otherwise, it ensures the path starts
|
|
729
|
+
* with a "/" and combines it with the provided base URL (or the current window's origin)
|
|
730
|
+
* to form a complete URL.
|
|
731
|
+
*
|
|
732
|
+
* @param {string} pathOrUrl - The path or URL to process.
|
|
733
|
+
* @param {string | null} [baseUrl=window.location.origin] - The base URL for resolving the relative path.
|
|
734
|
+
* Defaults to the current window's origin.
|
|
735
|
+
* @returns {URL} The resulting URL object.
|
|
736
|
+
*/
|
|
737
|
+
KTDataTable.prototype._createUrl = function (pathOrUrl, baseUrl) {
|
|
738
|
+
if (baseUrl === void 0) { baseUrl = window.location.origin; }
|
|
739
|
+
// Regular expression to check if the input is a full URL
|
|
740
|
+
var isFullUrl = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(pathOrUrl);
|
|
741
|
+
if (isFullUrl) {
|
|
742
|
+
return new URL(pathOrUrl); // Return full URL as URL object
|
|
743
|
+
}
|
|
744
|
+
// Ensure path starts with a slash to avoid incorrect concatenation
|
|
745
|
+
var normalizedPath = pathOrUrl.startsWith('/')
|
|
746
|
+
? pathOrUrl
|
|
747
|
+
: "/".concat(pathOrUrl);
|
|
748
|
+
return new URL(normalizedPath, baseUrl);
|
|
749
|
+
};
|
|
666
750
|
/**
|
|
667
751
|
* Update the table and pagination controls with new data
|
|
668
752
|
* @returns {Promise<void>} A promise that resolves when the table and pagination controls are updated
|
|
@@ -670,7 +754,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
670
754
|
KTDataTable.prototype._draw = function () {
|
|
671
755
|
return __awaiter(this, void 0, void 0, function () {
|
|
672
756
|
return __generator(this, function (_a) {
|
|
673
|
-
this._config._state.totalPages =
|
|
757
|
+
this._config._state.totalPages =
|
|
758
|
+
Math.ceil(this.getState().totalItems / this.getState().pageSize) || 0;
|
|
674
759
|
this._fireEvent('draw');
|
|
675
760
|
this._dispatchEvent('draw');
|
|
676
761
|
this._dispose();
|
|
@@ -702,89 +787,13 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
702
787
|
}
|
|
703
788
|
// Create the table body with the new data
|
|
704
789
|
var tbodyElement = this._tableElement.createTBody();
|
|
790
|
+
// Apply the original class to the new tbody element
|
|
791
|
+
if (this._originalTbodyClass) {
|
|
792
|
+
tbodyElement.className = this._originalTbodyClass;
|
|
793
|
+
}
|
|
705
794
|
this._updateTableContent(tbodyElement);
|
|
706
795
|
return tbodyElement;
|
|
707
796
|
};
|
|
708
|
-
/**
|
|
709
|
-
* Initialize the table header
|
|
710
|
-
* Add sort event listener to all sortable columns
|
|
711
|
-
*/
|
|
712
|
-
KTDataTable.prototype._initTableHeader = function () {
|
|
713
|
-
var _this = this;
|
|
714
|
-
if (!this._theadElement) {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
// Set the initial sort icon
|
|
718
|
-
this._setSortIcon(this.getState().sortField, this.getState().sortOrder);
|
|
719
|
-
// Get all the table headers
|
|
720
|
-
var headers = this._getTableHeaders();
|
|
721
|
-
// Loop through each table header
|
|
722
|
-
headers.forEach(function (header) {
|
|
723
|
-
// If the sort class is not found, it's not a sortable column
|
|
724
|
-
if (!header.querySelector(".".concat(_this._config.sort.classes.base))) {
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
var sortAttribute = header.getAttribute('data-datatable-column-sort') || header.getAttribute('data-datatable-column');
|
|
728
|
-
var sortField = sortAttribute ? sortAttribute : header.cellIndex;
|
|
729
|
-
// Add click event listener to the header
|
|
730
|
-
header.addEventListener('click', function () {
|
|
731
|
-
var sortOrder = _this._toggleSortOrder(sortField);
|
|
732
|
-
_this._setSortIcon(sortField, sortOrder);
|
|
733
|
-
_this._sort(sortField);
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
};
|
|
737
|
-
/**
|
|
738
|
-
* Returns an array of table headers as HTMLTableCellElement.
|
|
739
|
-
* @returns {HTMLTableCellElement[]} An array of table headers.
|
|
740
|
-
*/
|
|
741
|
-
KTDataTable.prototype._getTableHeaders = function () {
|
|
742
|
-
if (!this._theadElement) {
|
|
743
|
-
return [];
|
|
744
|
-
}
|
|
745
|
-
return Array.from(this._theadElement.querySelectorAll('th'));
|
|
746
|
-
};
|
|
747
|
-
/**
|
|
748
|
-
* Sets the sort icon in the table header
|
|
749
|
-
* @param sortField The field to set the sort icon for
|
|
750
|
-
* @param sortOrder The sort order (ascending or descending)
|
|
751
|
-
*/
|
|
752
|
-
KTDataTable.prototype._setSortIcon = function (sortField, sortOrder) {
|
|
753
|
-
var sortClass = sortOrder ? (sortOrder === 'asc' ? this._config.sort.classes.asc : this._config.sort.classes.desc) : '';
|
|
754
|
-
// Get the appropriate table header element
|
|
755
|
-
var th = typeof sortField === 'number'
|
|
756
|
-
? this._theadElement.querySelectorAll('th')[sortField]
|
|
757
|
-
: this._theadElement.querySelector("th[data-datatable-column=\"".concat(String(sortField), "\"], th[data-datatable-column-sort=\"").concat(String(sortField), "\"]"));
|
|
758
|
-
if (th) {
|
|
759
|
-
var sortElement = th.querySelector(".".concat(this._config.sort.classes.base));
|
|
760
|
-
if (sortElement) {
|
|
761
|
-
sortElement.className = "".concat(this._config.sort.classes.base, " ").concat(sortClass).trim();
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
/**
|
|
766
|
-
* Toggles the sort order of a column
|
|
767
|
-
* @param sortField The field to toggle the sort order for
|
|
768
|
-
* @returns The new sort order (ascending, descending or unsorted)
|
|
769
|
-
*/
|
|
770
|
-
KTDataTable.prototype._toggleSortOrder = function (sortField) {
|
|
771
|
-
var _this = this;
|
|
772
|
-
// If the sort field is the same as the current sort field,
|
|
773
|
-
// toggle the sort order. Otherwise, set the sort order to ascending.
|
|
774
|
-
return (function () {
|
|
775
|
-
if (_this.getState().sortField === sortField) {
|
|
776
|
-
switch (_this.getState().sortOrder) {
|
|
777
|
-
case 'asc':
|
|
778
|
-
return 'desc'; // Descending
|
|
779
|
-
case 'desc':
|
|
780
|
-
return ''; // Unsorted
|
|
781
|
-
default:
|
|
782
|
-
return 'asc'; // Ascending
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
return 'asc'; // Ascending
|
|
786
|
-
})();
|
|
787
|
-
};
|
|
788
797
|
/**
|
|
789
798
|
* Update the table content
|
|
790
799
|
* @param tbodyElement The table body element
|
|
@@ -798,16 +807,41 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
798
807
|
this._noticeOnTable(this._config.infoEmpty || '');
|
|
799
808
|
return tbodyElement;
|
|
800
809
|
}
|
|
810
|
+
var ths = this._theadElement
|
|
811
|
+
? this._theadElement.querySelectorAll('th')
|
|
812
|
+
: [];
|
|
801
813
|
this._data.forEach(function (item, rowIndex) {
|
|
802
814
|
var row = document.createElement('tr');
|
|
815
|
+
// Apply original tr class if available
|
|
816
|
+
if (_this._originalTrClasses && _this._originalTrClasses[rowIndex]) {
|
|
817
|
+
row.className = _this._originalTrClasses[rowIndex];
|
|
818
|
+
}
|
|
803
819
|
if (!_this._config.columns) {
|
|
804
820
|
var dataRowAttributes_1 = _this.getState().originalDataAttributes
|
|
805
821
|
? _this.getState().originalDataAttributes[rowIndex]
|
|
806
822
|
: null;
|
|
807
|
-
|
|
823
|
+
// Use the order of <th> elements to render <td>s in the correct order
|
|
824
|
+
ths.forEach(function (th, colIndex) {
|
|
825
|
+
var colName = th.getAttribute('data-kt-datatable-column');
|
|
808
826
|
var td = document.createElement('td');
|
|
809
|
-
|
|
810
|
-
if (
|
|
827
|
+
var value;
|
|
828
|
+
if (colName && Object.prototype.hasOwnProperty.call(item, colName)) {
|
|
829
|
+
value = item[colName];
|
|
830
|
+
}
|
|
831
|
+
else if (Object.prototype.hasOwnProperty.call(item, colIndex)) {
|
|
832
|
+
value = item[colIndex];
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
value = '';
|
|
836
|
+
}
|
|
837
|
+
td.innerHTML = value;
|
|
838
|
+
// Apply original td class if available
|
|
839
|
+
if (_this._originalTdClasses &&
|
|
840
|
+
_this._originalTdClasses[rowIndex] &&
|
|
841
|
+
_this._originalTdClasses[rowIndex][colIndex]) {
|
|
842
|
+
td.className = _this._originalTdClasses[rowIndex][colIndex];
|
|
843
|
+
}
|
|
844
|
+
if (dataRowAttributes_1 && dataRowAttributes_1[colIndex]) {
|
|
811
845
|
for (var attr in dataRowAttributes_1[colIndex]) {
|
|
812
846
|
td.setAttribute(attr, dataRowAttributes_1[colIndex][attr]);
|
|
813
847
|
}
|
|
@@ -816,9 +850,15 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
816
850
|
});
|
|
817
851
|
}
|
|
818
852
|
else {
|
|
819
|
-
Object.keys(_this._config.columns).forEach(function (key) {
|
|
853
|
+
Object.keys(_this._config.columns).forEach(function (key, colIndex) {
|
|
820
854
|
var td = document.createElement('td');
|
|
821
855
|
var columnDef = _this._config.columns[key];
|
|
856
|
+
// Apply original td class if available
|
|
857
|
+
if (_this._originalTdClasses &&
|
|
858
|
+
_this._originalTdClasses[rowIndex] &&
|
|
859
|
+
_this._originalTdClasses[rowIndex][colIndex]) {
|
|
860
|
+
td.className = _this._originalTdClasses[rowIndex][colIndex];
|
|
861
|
+
}
|
|
822
862
|
if (typeof columnDef.render === 'function') {
|
|
823
863
|
td.innerHTML = columnDef.render.call(_this, item[key], item, _this);
|
|
824
864
|
}
|
|
@@ -842,11 +882,12 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
842
882
|
* @returns {void}
|
|
843
883
|
*/
|
|
844
884
|
KTDataTable.prototype._noticeOnTable = function (message) {
|
|
845
|
-
var _a;
|
|
846
885
|
if (message === void 0) { message = ''; }
|
|
847
|
-
var row = this.
|
|
886
|
+
var row = this._tableElement.tBodies[0].insertRow();
|
|
848
887
|
var cell = row.insertCell();
|
|
849
|
-
cell.colSpan =
|
|
888
|
+
cell.colSpan = this._theadElement
|
|
889
|
+
? this._theadElement.querySelectorAll('th').length
|
|
890
|
+
: 0;
|
|
850
891
|
cell.innerHTML = message;
|
|
851
892
|
};
|
|
852
893
|
KTDataTable.prototype._updatePagination = function () {
|
|
@@ -946,10 +987,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
946
987
|
* @return {HTMLElement} The container element.
|
|
947
988
|
*/
|
|
948
989
|
KTDataTable.prototype._createPaginationContainer = function (_paginationElement) {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
_paginationElement.appendChild(paginationContainer);
|
|
952
|
-
return paginationContainer;
|
|
990
|
+
// No longer create a wrapping div. Just return the pagination element itself.
|
|
991
|
+
return _paginationElement;
|
|
953
992
|
};
|
|
954
993
|
/**
|
|
955
994
|
* Creates the pagination buttons for the component.
|
|
@@ -977,7 +1016,9 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
977
1016
|
var range_1 = this._calculatePageRange(currentPage, totalPages, maxButtons);
|
|
978
1017
|
// Add start ellipsis
|
|
979
1018
|
if (range_1.start > 1) {
|
|
980
|
-
paginationContainer.appendChild(createButton(more.text, more.class, false, function () {
|
|
1019
|
+
paginationContainer.appendChild(createButton(more.text, more.class, false, function () {
|
|
1020
|
+
return _this._paginateData(Math.max(1, range_1.start - 1));
|
|
1021
|
+
}));
|
|
981
1022
|
}
|
|
982
1023
|
var _loop_1 = function (i) {
|
|
983
1024
|
paginationContainer.appendChild(createButton(number.text.replace('{page}', i.toString()), "".concat(number.class).concat(currentPage === i ? ' active disabled' : ''), currentPage === i, function () { return _this._paginateData(i); }));
|
|
@@ -988,7 +1029,9 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
988
1029
|
}
|
|
989
1030
|
// Add end ellipsis
|
|
990
1031
|
if (pageMoreEnabled && range_1.end < totalPages) {
|
|
991
|
-
paginationContainer.appendChild(createButton(more.text, more.class, false, function () {
|
|
1032
|
+
paginationContainer.appendChild(createButton(more.text, more.class, false, function () {
|
|
1033
|
+
return _this._paginateData(Math.min(totalPages, range_1.end + 1));
|
|
1034
|
+
}));
|
|
992
1035
|
}
|
|
993
1036
|
}
|
|
994
1037
|
else {
|
|
@@ -1041,7 +1084,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1041
1084
|
if (spinner) {
|
|
1042
1085
|
spinner.style.display = 'block';
|
|
1043
1086
|
}
|
|
1044
|
-
this._element.classList.add(
|
|
1087
|
+
this._element.classList.add(this._config.loadingClass);
|
|
1045
1088
|
};
|
|
1046
1089
|
// Method to hide the loading spinner
|
|
1047
1090
|
KTDataTable.prototype._hideSpinner = function () {
|
|
@@ -1049,7 +1092,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1049
1092
|
if (spinner) {
|
|
1050
1093
|
spinner.style.display = 'none';
|
|
1051
1094
|
}
|
|
1052
|
-
this._element.classList.remove(
|
|
1095
|
+
this._element.classList.remove(this._config.loadingClass);
|
|
1053
1096
|
};
|
|
1054
1097
|
// Method to create a spinner element if it doesn't exist
|
|
1055
1098
|
KTDataTable.prototype._createSpinner = function () {
|
|
@@ -1057,9 +1100,11 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1057
1100
|
return null;
|
|
1058
1101
|
}
|
|
1059
1102
|
var template = document.createElement('template');
|
|
1060
|
-
template.innerHTML = this._config.loading.template
|
|
1103
|
+
template.innerHTML = this._config.loading.template
|
|
1104
|
+
.trim()
|
|
1105
|
+
.replace('{content}', this._config.loading.content);
|
|
1061
1106
|
var spinner = template.content.firstChild;
|
|
1062
|
-
spinner.setAttribute('data-datatable-spinner', 'true');
|
|
1107
|
+
spinner.setAttribute('data-kt-datatable-spinner', 'true');
|
|
1063
1108
|
this._tableElement.appendChild(spinner);
|
|
1064
1109
|
return spinner;
|
|
1065
1110
|
};
|
|
@@ -1128,25 +1173,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1128
1173
|
}
|
|
1129
1174
|
return id;
|
|
1130
1175
|
};
|
|
1131
|
-
/**
|
|
1132
|
-
* Sorts the data in the table by the specified field.
|
|
1133
|
-
* @param sortField The field to sort by.
|
|
1134
|
-
*/
|
|
1135
|
-
KTDataTable.prototype._sort = function (sortField) {
|
|
1136
|
-
// Determine the new sort order based on the current state
|
|
1137
|
-
var newSortOrder = this._toggleSortOrder(sortField);
|
|
1138
|
-
// Update the current sort field and order
|
|
1139
|
-
this._config._state.sortField = sortField;
|
|
1140
|
-
this._config._state.sortOrder = newSortOrder;
|
|
1141
|
-
this._fireEvent('sort', { field: sortField, order: newSortOrder });
|
|
1142
|
-
this._dispatchEvent('sort', { field: sortField, order: newSortOrder });
|
|
1143
|
-
// Fetch data from the server with the new sort order
|
|
1144
|
-
this._updateData();
|
|
1145
|
-
};
|
|
1146
1176
|
KTDataTable.prototype._dispose = function () {
|
|
1147
|
-
|
|
1148
|
-
this._headerCheckElement.removeEventListener('click', this._checkboxListener);
|
|
1149
|
-
}
|
|
1177
|
+
// Remove all event listeners and clean up resources
|
|
1150
1178
|
};
|
|
1151
1179
|
KTDataTable.prototype._debounce = function (func, wait) {
|
|
1152
1180
|
var timeout;
|
|
@@ -1163,146 +1191,6 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1163
1191
|
timeout = window.setTimeout(later, wait);
|
|
1164
1192
|
};
|
|
1165
1193
|
};
|
|
1166
|
-
/**
|
|
1167
|
-
* Event handlers
|
|
1168
|
-
*/
|
|
1169
|
-
KTDataTable.prototype._checkboxHandler = function () {
|
|
1170
|
-
var _this = this;
|
|
1171
|
-
// Handle header checkbox change event
|
|
1172
|
-
this._headerCheckElement.addEventListener('click', this._checkboxListener);
|
|
1173
|
-
// Handle target checbox change event
|
|
1174
|
-
event_handler_1.default.on(document.body, this._config.attributes.checkbox, 'input', function (event) {
|
|
1175
|
-
_this._checkboxUpdate(event); // Update checkbox state based on checked rows
|
|
1176
|
-
});
|
|
1177
|
-
};
|
|
1178
|
-
/**
|
|
1179
|
-
* Checks if element is checked
|
|
1180
|
-
* @returns {boolean}
|
|
1181
|
-
*/
|
|
1182
|
-
KTDataTable.prototype._isChecked = function () {
|
|
1183
|
-
return this._headerChecked;
|
|
1184
|
-
};
|
|
1185
|
-
/**
|
|
1186
|
-
* Change checkbox state
|
|
1187
|
-
* @param checked The new state of the checkbox
|
|
1188
|
-
* @returns {void}
|
|
1189
|
-
*/
|
|
1190
|
-
KTDataTable.prototype._change = function (checked) {
|
|
1191
|
-
var payload = { cancel: false };
|
|
1192
|
-
this._fireEvent('change', payload);
|
|
1193
|
-
this._dispatchEvent('change', payload);
|
|
1194
|
-
if (payload.cancel === true) {
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
|
-
this._headerChecked = checked;
|
|
1198
|
-
this._headerCheckElement.checked = checked;
|
|
1199
|
-
if (this._targetElements) {
|
|
1200
|
-
this._targetElements.forEach(function (element) {
|
|
1201
|
-
if (element) {
|
|
1202
|
-
element.checked = checked;
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
this._fireEvent('changed');
|
|
1207
|
-
this._dispatchEvent('changed');
|
|
1208
|
-
};
|
|
1209
|
-
/**
|
|
1210
|
-
* Toggle checkbox state
|
|
1211
|
-
* @param event The event if available
|
|
1212
|
-
* @returns {void}
|
|
1213
|
-
*/
|
|
1214
|
-
KTDataTable.prototype._checkboxToggle = function (event) {
|
|
1215
|
-
var checked = !this._isChecked();
|
|
1216
|
-
var eventType = checked ? 'checked' : 'unchecked';
|
|
1217
|
-
this._fireEvent(eventType);
|
|
1218
|
-
this._dispatchEvent(eventType);
|
|
1219
|
-
this._change(checked);
|
|
1220
|
-
};
|
|
1221
|
-
/**
|
|
1222
|
-
* Update checkbox state based on checked rows
|
|
1223
|
-
* @param event The event if available
|
|
1224
|
-
* @returns {void}
|
|
1225
|
-
*/
|
|
1226
|
-
KTDataTable.prototype._checkboxUpdate = function (event) {
|
|
1227
|
-
var checked = 0;
|
|
1228
|
-
var total = this._targetElements.length;
|
|
1229
|
-
for (var i = 0; i < total; i++) {
|
|
1230
|
-
var element = this._targetElements[i];
|
|
1231
|
-
if (!element) {
|
|
1232
|
-
continue;
|
|
1233
|
-
}
|
|
1234
|
-
var row = element.closest('tr');
|
|
1235
|
-
if (!row) {
|
|
1236
|
-
continue;
|
|
1237
|
-
}
|
|
1238
|
-
if (element.checked) {
|
|
1239
|
-
row.classList.add(this._config.checkbox.checkedClass);
|
|
1240
|
-
checked++;
|
|
1241
|
-
}
|
|
1242
|
-
else {
|
|
1243
|
-
row.classList.remove(this._config.checkbox.checkedClass);
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
if (checked === 0) {
|
|
1247
|
-
this._headerCheckElement.indeterminate = false;
|
|
1248
|
-
this._change(false);
|
|
1249
|
-
}
|
|
1250
|
-
if (checked > 0 && checked < total) {
|
|
1251
|
-
this._headerCheckElement.indeterminate = true;
|
|
1252
|
-
}
|
|
1253
|
-
if (checked === total) {
|
|
1254
|
-
this._headerCheckElement.indeterminate = false;
|
|
1255
|
-
this._change(true);
|
|
1256
|
-
}
|
|
1257
|
-
};
|
|
1258
|
-
/**
|
|
1259
|
-
* Get checked row IDs
|
|
1260
|
-
* @returns {string[]} An array of checked row IDs
|
|
1261
|
-
*/
|
|
1262
|
-
KTDataTable.prototype._getChecked = function () {
|
|
1263
|
-
var checked = [];
|
|
1264
|
-
this._targetElements.forEach(function (element) {
|
|
1265
|
-
if (element && element.checked) {
|
|
1266
|
-
var value = element.value;
|
|
1267
|
-
if (value) {
|
|
1268
|
-
checked.push(value);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
});
|
|
1272
|
-
return checked;
|
|
1273
|
-
};
|
|
1274
|
-
KTDataTable.prototype.isChecked = function () {
|
|
1275
|
-
return this._isChecked();
|
|
1276
|
-
};
|
|
1277
|
-
KTDataTable.prototype.toggle = function () {
|
|
1278
|
-
this._checkboxToggle();
|
|
1279
|
-
};
|
|
1280
|
-
/**
|
|
1281
|
-
* Check all rows
|
|
1282
|
-
* @returns {void}
|
|
1283
|
-
*/
|
|
1284
|
-
KTDataTable.prototype.check = function () {
|
|
1285
|
-
this._change(true);
|
|
1286
|
-
this._checkboxUpdate();
|
|
1287
|
-
};
|
|
1288
|
-
/**
|
|
1289
|
-
* Uncheck all rows
|
|
1290
|
-
* @returns {void}
|
|
1291
|
-
*/
|
|
1292
|
-
KTDataTable.prototype.uncheck = function () {
|
|
1293
|
-
this._change(false);
|
|
1294
|
-
};
|
|
1295
|
-
/**
|
|
1296
|
-
* Get checked row IDs
|
|
1297
|
-
* @returns {string[]} An array of checked row IDs
|
|
1298
|
-
*/
|
|
1299
|
-
KTDataTable.prototype.getChecked = function () {
|
|
1300
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1301
|
-
return this._getChecked();
|
|
1302
|
-
};
|
|
1303
|
-
KTDataTable.prototype.update = function () {
|
|
1304
|
-
this._checkboxUpdate();
|
|
1305
|
-
};
|
|
1306
1194
|
/**
|
|
1307
1195
|
* Gets the current state of the table.
|
|
1308
1196
|
* @returns {KTDataTableStateInterface} The current state of the table.
|
|
@@ -1331,8 +1219,15 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1331
1219
|
* @param field The field to sort by.
|
|
1332
1220
|
*/
|
|
1333
1221
|
KTDataTable.prototype.sort = function (field) {
|
|
1334
|
-
//
|
|
1335
|
-
this.
|
|
1222
|
+
// Use the sort handler to update state and trigger sorting
|
|
1223
|
+
var state = this.getState();
|
|
1224
|
+
var sortOrder = this._sortHandler.toggleSortOrder(state.sortField, state.sortOrder, field);
|
|
1225
|
+
this._sortHandler.setSortIcon(field, sortOrder);
|
|
1226
|
+
this._config._state.sortField = field;
|
|
1227
|
+
this._config._state.sortOrder = sortOrder;
|
|
1228
|
+
this._fireEvent('sort', { field: field, order: sortOrder });
|
|
1229
|
+
this._dispatchEvent('sort', { field: field, order: sortOrder });
|
|
1230
|
+
this._updateData();
|
|
1336
1231
|
};
|
|
1337
1232
|
/**
|
|
1338
1233
|
* Navigates to the specified page in the data table.
|
|
@@ -1402,7 +1297,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1402
1297
|
*/
|
|
1403
1298
|
KTDataTable.prototype.setFilter = function (filter) {
|
|
1404
1299
|
this._config._state.filters = __spreadArray(__spreadArray([], (this.getState().filters || []).filter(function (f) { return f.column !== filter.column; }), true), [
|
|
1405
|
-
filter
|
|
1300
|
+
filter,
|
|
1406
1301
|
], false);
|
|
1407
1302
|
return this;
|
|
1408
1303
|
};
|
|
@@ -1414,17 +1309,18 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1414
1309
|
this.reload();
|
|
1415
1310
|
};
|
|
1416
1311
|
/**
|
|
1417
|
-
* Create KTDataTable instances for all elements with a data-datatable="true" attribute.
|
|
1312
|
+
* Create KTDataTable instances for all elements with a data-kt-datatable="true" attribute.
|
|
1418
1313
|
*
|
|
1419
1314
|
* This function should be called after the control(s) have been
|
|
1420
1315
|
* loaded and parsed by the browser. It will create instances of
|
|
1421
|
-
* KTDataTable for all elements with a data-datatable="true" attribute.
|
|
1316
|
+
* KTDataTable for all elements with a data-kt-datatable="true" attribute.
|
|
1422
1317
|
*/
|
|
1423
1318
|
KTDataTable.createInstances = function () {
|
|
1424
1319
|
var _this = this;
|
|
1425
|
-
var elements = document.querySelectorAll('[data-datatable="true"]');
|
|
1320
|
+
var elements = document.querySelectorAll('[data-kt-datatable="true"]');
|
|
1426
1321
|
elements.forEach(function (element) {
|
|
1427
|
-
if (element.hasAttribute('data-datatable') &&
|
|
1322
|
+
if (element.hasAttribute('data-kt-datatable') &&
|
|
1323
|
+
!element.classList.contains('datatable-initialized')) {
|
|
1428
1324
|
/**
|
|
1429
1325
|
* Create an instance of KTDataTable for the given element
|
|
1430
1326
|
* @param element The element to create an instance for
|
|
@@ -1451,9 +1347,55 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1451
1347
|
*/
|
|
1452
1348
|
KTDataTable.init = function () {
|
|
1453
1349
|
// Create instances of KTDataTable for all elements with a
|
|
1454
|
-
// data-datatable="true" attribute
|
|
1350
|
+
// data-kt-datatable="true" attribute
|
|
1455
1351
|
KTDataTable.createInstances();
|
|
1456
1352
|
};
|
|
1353
|
+
/**
|
|
1354
|
+
* Check if all visible rows are checked (header checkbox state)
|
|
1355
|
+
* @returns {boolean}
|
|
1356
|
+
*/
|
|
1357
|
+
KTDataTable.prototype.isChecked = function () {
|
|
1358
|
+
return this._checkbox.isChecked();
|
|
1359
|
+
};
|
|
1360
|
+
/**
|
|
1361
|
+
* Toggle all visible row checkboxes (header checkbox)
|
|
1362
|
+
* @returns {void}
|
|
1363
|
+
*/
|
|
1364
|
+
KTDataTable.prototype.toggle = function () {
|
|
1365
|
+
this._checkbox.toggle();
|
|
1366
|
+
};
|
|
1367
|
+
/**
|
|
1368
|
+
* Check all visible row checkboxes
|
|
1369
|
+
* @returns {void}
|
|
1370
|
+
*/
|
|
1371
|
+
KTDataTable.prototype.check = function () {
|
|
1372
|
+
this._checkbox.check();
|
|
1373
|
+
this._fireEvent('checked');
|
|
1374
|
+
this._dispatchEvent('checked');
|
|
1375
|
+
};
|
|
1376
|
+
/**
|
|
1377
|
+
* Uncheck all visible row checkboxes
|
|
1378
|
+
* @returns {void}
|
|
1379
|
+
*/
|
|
1380
|
+
KTDataTable.prototype.uncheck = function () {
|
|
1381
|
+
this._checkbox.uncheck();
|
|
1382
|
+
this._fireEvent('unchecked');
|
|
1383
|
+
this._dispatchEvent('unchecked');
|
|
1384
|
+
};
|
|
1385
|
+
/**
|
|
1386
|
+
* Get all checked row IDs (across all pages if preserveSelection is true)
|
|
1387
|
+
* @returns {string[]}
|
|
1388
|
+
*/
|
|
1389
|
+
KTDataTable.prototype.getChecked = function () {
|
|
1390
|
+
return this._checkbox.getChecked();
|
|
1391
|
+
};
|
|
1392
|
+
/**
|
|
1393
|
+
* Reapply checked state to visible checkboxes (after redraw/pagination)
|
|
1394
|
+
* @returns {void}
|
|
1395
|
+
*/
|
|
1396
|
+
KTDataTable.prototype.update = function () {
|
|
1397
|
+
this._checkbox.updateState();
|
|
1398
|
+
};
|
|
1457
1399
|
/**
|
|
1458
1400
|
* Static variables
|
|
1459
1401
|
*/
|
|
@@ -1461,4 +1403,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
1461
1403
|
return KTDataTable;
|
|
1462
1404
|
}(component_1.default));
|
|
1463
1405
|
exports.KTDataTable = KTDataTable;
|
|
1406
|
+
if (typeof window !== 'undefined') {
|
|
1407
|
+
window.KTDataTable = KTDataTable;
|
|
1408
|
+
}
|
|
1464
1409
|
//# sourceMappingURL=datatable.js.map
|