@keenthemes/ktui 1.0.3
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/CONTRIBUTING.md +88 -0
- package/LICENSE.md +21 -0
- package/README.md +124 -0
- package/dist/ktui.js +19201 -0
- package/dist/ktui.min.js +2 -0
- package/dist/ktui.min.js.map +1 -0
- package/lib/cjs/components/accordion/accordion.js +168 -0
- package/lib/cjs/components/accordion/accordion.js.map +1 -0
- package/lib/cjs/components/accordion/index.js +6 -0
- package/lib/cjs/components/accordion/index.js.map +1 -0
- package/lib/cjs/components/accordion/types.js +3 -0
- package/lib/cjs/components/accordion/types.js.map +1 -0
- package/lib/cjs/components/collapse/collapse.js +169 -0
- package/lib/cjs/components/collapse/collapse.js.map +1 -0
- package/lib/cjs/components/collapse/index.js +6 -0
- package/lib/cjs/components/collapse/index.js.map +1 -0
- package/lib/cjs/components/collapse/types.js +3 -0
- package/lib/cjs/components/collapse/types.js.map +1 -0
- package/lib/cjs/components/component.js +135 -0
- package/lib/cjs/components/component.js.map +1 -0
- package/lib/cjs/components/config.js +26 -0
- package/lib/cjs/components/config.js.map +1 -0
- package/lib/cjs/components/config.umd.js +23 -0
- package/lib/cjs/components/config.umd.js.map +1 -0
- package/lib/cjs/components/constants.js +15 -0
- package/lib/cjs/components/constants.js.map +1 -0
- package/lib/cjs/components/datatable/datatable.js +1464 -0
- package/lib/cjs/components/datatable/datatable.js.map +1 -0
- package/lib/cjs/components/datatable/index.js +6 -0
- package/lib/cjs/components/datatable/index.js.map +1 -0
- package/lib/cjs/components/datatable/types.js +3 -0
- package/lib/cjs/components/datatable/types.js.map +1 -0
- package/lib/cjs/components/dismiss/dismiss.js +131 -0
- package/lib/cjs/components/dismiss/dismiss.js.map +1 -0
- package/lib/cjs/components/dismiss/index.js +6 -0
- package/lib/cjs/components/dismiss/index.js.map +1 -0
- package/lib/cjs/components/dismiss/types.js +3 -0
- package/lib/cjs/components/dismiss/types.js.map +1 -0
- package/lib/cjs/components/drawer/drawer.js +347 -0
- package/lib/cjs/components/drawer/drawer.js.map +1 -0
- package/lib/cjs/components/drawer/index.js +6 -0
- package/lib/cjs/components/drawer/index.js.map +1 -0
- package/lib/cjs/components/drawer/types.js +3 -0
- package/lib/cjs/components/drawer/types.js.map +1 -0
- package/lib/cjs/components/dropdown/dropdown.js +403 -0
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -0
- package/lib/cjs/components/dropdown/index.js +6 -0
- package/lib/cjs/components/dropdown/index.js.map +1 -0
- package/lib/cjs/components/dropdown/types.js +3 -0
- package/lib/cjs/components/dropdown/types.js.map +1 -0
- package/lib/cjs/components/image-input/image-input.js +191 -0
- package/lib/cjs/components/image-input/image-input.js.map +1 -0
- package/lib/cjs/components/image-input/index.js +6 -0
- package/lib/cjs/components/image-input/index.js.map +1 -0
- package/lib/cjs/components/image-input/types.js +3 -0
- package/lib/cjs/components/image-input/types.js.map +1 -0
- package/lib/cjs/components/menu/index.js +6 -0
- package/lib/cjs/components/menu/index.js.map +1 -0
- package/lib/cjs/components/menu/menu.js +1021 -0
- package/lib/cjs/components/menu/menu.js.map +1 -0
- package/lib/cjs/components/menu/types.js +3 -0
- package/lib/cjs/components/menu/types.js.map +1 -0
- package/lib/cjs/components/modal/index.js +6 -0
- package/lib/cjs/components/modal/index.js.map +1 -0
- package/lib/cjs/components/modal/modal.js +316 -0
- package/lib/cjs/components/modal/modal.js.map +1 -0
- package/lib/cjs/components/modal/types.js +3 -0
- package/lib/cjs/components/modal/types.js.map +1 -0
- package/lib/cjs/components/reparent/index.js +6 -0
- package/lib/cjs/components/reparent/index.js.map +1 -0
- package/lib/cjs/components/reparent/reparent.js +93 -0
- package/lib/cjs/components/reparent/reparent.js.map +1 -0
- package/lib/cjs/components/reparent/types.js +3 -0
- package/lib/cjs/components/reparent/types.js.map +1 -0
- package/lib/cjs/components/scrollable/index.js +6 -0
- package/lib/cjs/components/scrollable/index.js.map +1 -0
- package/lib/cjs/components/scrollable/scrollable.js +259 -0
- package/lib/cjs/components/scrollable/scrollable.js.map +1 -0
- package/lib/cjs/components/scrollable/types.js +3 -0
- package/lib/cjs/components/scrollable/types.js.map +1 -0
- package/lib/cjs/components/scrollspy/index.js +6 -0
- package/lib/cjs/components/scrollspy/index.js.map +1 -0
- package/lib/cjs/components/scrollspy/scrollspy.js +174 -0
- package/lib/cjs/components/scrollspy/scrollspy.js.map +1 -0
- package/lib/cjs/components/scrollspy/types.js +3 -0
- package/lib/cjs/components/scrollspy/types.js.map +1 -0
- package/lib/cjs/components/scrollto/index.js +6 -0
- package/lib/cjs/components/scrollto/index.js.map +1 -0
- package/lib/cjs/components/scrollto/scrollto.js +103 -0
- package/lib/cjs/components/scrollto/scrollto.js.map +1 -0
- package/lib/cjs/components/scrollto/types.js +3 -0
- package/lib/cjs/components/scrollto/types.js.map +1 -0
- package/lib/cjs/components/stepper/index.js +6 -0
- package/lib/cjs/components/stepper/index.js.map +1 -0
- package/lib/cjs/components/stepper/stepper.js +258 -0
- package/lib/cjs/components/stepper/stepper.js.map +1 -0
- package/lib/cjs/components/stepper/types.js +3 -0
- package/lib/cjs/components/stepper/types.js.map +1 -0
- package/lib/cjs/components/sticky/index.js +6 -0
- package/lib/cjs/components/sticky/index.js.map +1 -0
- package/lib/cjs/components/sticky/sticky.js +297 -0
- package/lib/cjs/components/sticky/sticky.js.map +1 -0
- package/lib/cjs/components/sticky/types.js +3 -0
- package/lib/cjs/components/sticky/types.js.map +1 -0
- package/lib/cjs/components/tabs/index.js +6 -0
- package/lib/cjs/components/tabs/index.js.map +1 -0
- package/lib/cjs/components/tabs/tabs.js +146 -0
- package/lib/cjs/components/tabs/tabs.js.map +1 -0
- package/lib/cjs/components/tabs/types.js +3 -0
- package/lib/cjs/components/tabs/types.js.map +1 -0
- package/lib/cjs/components/theme/index.js +6 -0
- package/lib/cjs/components/theme/index.js.map +1 -0
- package/lib/cjs/components/theme/theme.js +147 -0
- package/lib/cjs/components/theme/theme.js.map +1 -0
- package/lib/cjs/components/theme/types.js +3 -0
- package/lib/cjs/components/theme/types.js.map +1 -0
- package/lib/cjs/components/toggle/index.js +6 -0
- package/lib/cjs/components/toggle/index.js.map +1 -0
- package/lib/cjs/components/toggle/toggle.js +139 -0
- package/lib/cjs/components/toggle/toggle.js.map +1 -0
- package/lib/cjs/components/toggle/types.js +3 -0
- package/lib/cjs/components/toggle/types.js.map +1 -0
- package/lib/cjs/components/toggle-password/index.js +6 -0
- package/lib/cjs/components/toggle-password/index.js.map +1 -0
- package/lib/cjs/components/toggle-password/toggle-password.js +131 -0
- package/lib/cjs/components/toggle-password/toggle-password.js.map +1 -0
- package/lib/cjs/components/toggle-password/types.js +3 -0
- package/lib/cjs/components/toggle-password/types.js.map +1 -0
- package/lib/cjs/components/tooltip/index.js +6 -0
- package/lib/cjs/components/tooltip/index.js.map +1 -0
- package/lib/cjs/components/tooltip/tooltip.js +271 -0
- package/lib/cjs/components/tooltip/tooltip.js.map +1 -0
- package/lib/cjs/components/tooltip/types.js +3 -0
- package/lib/cjs/components/tooltip/types.js.map +1 -0
- package/lib/cjs/helpers/data.js +33 -0
- package/lib/cjs/helpers/data.js.map +1 -0
- package/lib/cjs/helpers/dom.js +297 -0
- package/lib/cjs/helpers/dom.js.map +1 -0
- package/lib/cjs/helpers/event-handler.js +36 -0
- package/lib/cjs/helpers/event-handler.js.map +1 -0
- package/lib/cjs/helpers/utils.js +94 -0
- package/lib/cjs/helpers/utils.js.map +1 -0
- package/lib/cjs/index.js +105 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types.js +3 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/esm/components/accordion/accordion.js +165 -0
- package/lib/esm/components/accordion/accordion.js.map +1 -0
- package/lib/esm/components/accordion/index.js +2 -0
- package/lib/esm/components/accordion/index.js.map +1 -0
- package/lib/esm/components/accordion/types.js +2 -0
- package/lib/esm/components/accordion/types.js.map +1 -0
- package/lib/esm/components/collapse/collapse.js +166 -0
- package/lib/esm/components/collapse/collapse.js.map +1 -0
- package/lib/esm/components/collapse/index.js +2 -0
- package/lib/esm/components/collapse/index.js.map +1 -0
- package/lib/esm/components/collapse/types.js +2 -0
- package/lib/esm/components/collapse/types.js.map +1 -0
- package/lib/esm/components/component.js +133 -0
- package/lib/esm/components/component.js.map +1 -0
- package/lib/esm/components/config.js +24 -0
- package/lib/esm/components/config.js.map +1 -0
- package/lib/esm/components/config.umd.js +23 -0
- package/lib/esm/components/config.umd.js.map +1 -0
- package/lib/esm/components/constants.js +12 -0
- package/lib/esm/components/constants.js.map +1 -0
- package/lib/esm/components/datatable/datatable.js +1461 -0
- package/lib/esm/components/datatable/datatable.js.map +1 -0
- package/lib/esm/components/datatable/index.js +2 -0
- package/lib/esm/components/datatable/index.js.map +1 -0
- package/lib/esm/components/datatable/types.js +2 -0
- package/lib/esm/components/datatable/types.js.map +1 -0
- package/lib/esm/components/dismiss/dismiss.js +128 -0
- package/lib/esm/components/dismiss/dismiss.js.map +1 -0
- package/lib/esm/components/dismiss/index.js +2 -0
- package/lib/esm/components/dismiss/index.js.map +1 -0
- package/lib/esm/components/dismiss/types.js +2 -0
- package/lib/esm/components/dismiss/types.js.map +1 -0
- package/lib/esm/components/drawer/drawer.js +344 -0
- package/lib/esm/components/drawer/drawer.js.map +1 -0
- package/lib/esm/components/drawer/index.js +2 -0
- package/lib/esm/components/drawer/index.js.map +1 -0
- package/lib/esm/components/drawer/types.js +2 -0
- package/lib/esm/components/drawer/types.js.map +1 -0
- package/lib/esm/components/dropdown/dropdown.js +400 -0
- package/lib/esm/components/dropdown/dropdown.js.map +1 -0
- package/lib/esm/components/dropdown/index.js +2 -0
- package/lib/esm/components/dropdown/index.js.map +1 -0
- package/lib/esm/components/dropdown/types.js +2 -0
- package/lib/esm/components/dropdown/types.js.map +1 -0
- package/lib/esm/components/image-input/image-input.js +188 -0
- package/lib/esm/components/image-input/image-input.js.map +1 -0
- package/lib/esm/components/image-input/index.js +2 -0
- package/lib/esm/components/image-input/index.js.map +1 -0
- package/lib/esm/components/image-input/types.js +2 -0
- package/lib/esm/components/image-input/types.js.map +1 -0
- package/lib/esm/components/menu/index.js +2 -0
- package/lib/esm/components/menu/index.js.map +1 -0
- package/lib/esm/components/menu/menu.js +1018 -0
- package/lib/esm/components/menu/menu.js.map +1 -0
- package/lib/esm/components/menu/types.js +2 -0
- package/lib/esm/components/menu/types.js.map +1 -0
- package/lib/esm/components/modal/index.js +2 -0
- package/lib/esm/components/modal/index.js.map +1 -0
- package/lib/esm/components/modal/modal.js +313 -0
- package/lib/esm/components/modal/modal.js.map +1 -0
- package/lib/esm/components/modal/types.js +2 -0
- package/lib/esm/components/modal/types.js.map +1 -0
- package/lib/esm/components/reparent/index.js +2 -0
- package/lib/esm/components/reparent/index.js.map +1 -0
- package/lib/esm/components/reparent/reparent.js +90 -0
- package/lib/esm/components/reparent/reparent.js.map +1 -0
- package/lib/esm/components/reparent/types.js +2 -0
- package/lib/esm/components/reparent/types.js.map +1 -0
- package/lib/esm/components/scrollable/index.js +2 -0
- package/lib/esm/components/scrollable/index.js.map +1 -0
- package/lib/esm/components/scrollable/scrollable.js +256 -0
- package/lib/esm/components/scrollable/scrollable.js.map +1 -0
- package/lib/esm/components/scrollable/types.js +2 -0
- package/lib/esm/components/scrollable/types.js.map +1 -0
- package/lib/esm/components/scrollspy/index.js +2 -0
- package/lib/esm/components/scrollspy/index.js.map +1 -0
- package/lib/esm/components/scrollspy/scrollspy.js +171 -0
- package/lib/esm/components/scrollspy/scrollspy.js.map +1 -0
- package/lib/esm/components/scrollspy/types.js +2 -0
- package/lib/esm/components/scrollspy/types.js.map +1 -0
- package/lib/esm/components/scrollto/index.js +2 -0
- package/lib/esm/components/scrollto/index.js.map +1 -0
- package/lib/esm/components/scrollto/scrollto.js +100 -0
- package/lib/esm/components/scrollto/scrollto.js.map +1 -0
- package/lib/esm/components/scrollto/types.js +2 -0
- package/lib/esm/components/scrollto/types.js.map +1 -0
- package/lib/esm/components/stepper/index.js +2 -0
- package/lib/esm/components/stepper/index.js.map +1 -0
- package/lib/esm/components/stepper/stepper.js +255 -0
- package/lib/esm/components/stepper/stepper.js.map +1 -0
- package/lib/esm/components/stepper/types.js +2 -0
- package/lib/esm/components/stepper/types.js.map +1 -0
- package/lib/esm/components/sticky/index.js +2 -0
- package/lib/esm/components/sticky/index.js.map +1 -0
- package/lib/esm/components/sticky/sticky.js +294 -0
- package/lib/esm/components/sticky/sticky.js.map +1 -0
- package/lib/esm/components/sticky/types.js +2 -0
- package/lib/esm/components/sticky/types.js.map +1 -0
- package/lib/esm/components/tabs/index.js +2 -0
- package/lib/esm/components/tabs/index.js.map +1 -0
- package/lib/esm/components/tabs/tabs.js +143 -0
- package/lib/esm/components/tabs/tabs.js.map +1 -0
- package/lib/esm/components/tabs/types.js +2 -0
- package/lib/esm/components/tabs/types.js.map +1 -0
- package/lib/esm/components/theme/index.js +2 -0
- package/lib/esm/components/theme/index.js.map +1 -0
- package/lib/esm/components/theme/theme.js +144 -0
- package/lib/esm/components/theme/theme.js.map +1 -0
- package/lib/esm/components/theme/types.js +2 -0
- package/lib/esm/components/theme/types.js.map +1 -0
- package/lib/esm/components/toggle/index.js +2 -0
- package/lib/esm/components/toggle/index.js.map +1 -0
- package/lib/esm/components/toggle/toggle.js +136 -0
- package/lib/esm/components/toggle/toggle.js.map +1 -0
- package/lib/esm/components/toggle/types.js +2 -0
- package/lib/esm/components/toggle/types.js.map +1 -0
- package/lib/esm/components/toggle-password/index.js +2 -0
- package/lib/esm/components/toggle-password/index.js.map +1 -0
- package/lib/esm/components/toggle-password/toggle-password.js +128 -0
- package/lib/esm/components/toggle-password/toggle-password.js.map +1 -0
- package/lib/esm/components/toggle-password/types.js +2 -0
- package/lib/esm/components/toggle-password/types.js.map +1 -0
- package/lib/esm/components/tooltip/index.js +2 -0
- package/lib/esm/components/tooltip/index.js.map +1 -0
- package/lib/esm/components/tooltip/tooltip.js +268 -0
- package/lib/esm/components/tooltip/tooltip.js.map +1 -0
- package/lib/esm/components/tooltip/types.js +2 -0
- package/lib/esm/components/tooltip/types.js.map +1 -0
- package/lib/esm/helpers/data.js +31 -0
- package/lib/esm/helpers/data.js.map +1 -0
- package/lib/esm/helpers/dom.js +295 -0
- package/lib/esm/helpers/dom.js.map +1 -0
- package/lib/esm/helpers/event-handler.js +34 -0
- package/lib/esm/helpers/event-handler.js.map +1 -0
- package/lib/esm/helpers/utils.js +92 -0
- package/lib/esm/helpers/utils.js.map +1 -0
- package/lib/esm/index.js +79 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types.js +2 -0
- package/lib/esm/types.js.map +1 -0
- package/package.json +85 -0
- package/prettier.config.js +9 -0
- package/src/components/accordion/accordion-menu.css +51 -0
- package/src/components/accordion/accordion.css +86 -0
- package/src/components/accordion/accordion.ts +221 -0
- package/src/components/accordion/index.ts +7 -0
- package/src/components/accordion/types.ts +16 -0
- package/src/components/alert/alert.css +282 -0
- package/src/components/avatar/avatar.css +46 -0
- package/src/components/badge/badge.css +176 -0
- package/src/components/breadcrumb/breadcrumb.css +38 -0
- package/src/components/btn/btn.css +227 -0
- package/src/components/card/card.css +158 -0
- package/src/components/checkbox/checkbox.css +74 -0
- package/src/components/collapse/collapse.css +14 -0
- package/src/components/collapse/collapse.ts +200 -0
- package/src/components/collapse/index.ts +7 -0
- package/src/components/collapse/types.ts +16 -0
- package/src/components/component.ts +132 -0
- package/src/components/constants.ts +16 -0
- package/src/components/datatable/datatable-checkbox.ts +236 -0
- package/src/components/datatable/datatable-sort.ts +154 -0
- package/src/components/datatable/datatable.css +110 -0
- package/src/components/datatable/datatable.ts +1657 -0
- package/src/components/datatable/index.ts +19 -0
- package/src/components/datatable/types.ts +203 -0
- package/src/components/datepicker/calendar.ts +1397 -0
- package/src/components/datepicker/config.ts +368 -0
- package/src/components/datepicker/datepicker.css +7 -0
- package/src/components/datepicker/datepicker.ts +1287 -0
- package/src/components/datepicker/dropdown.ts +757 -0
- package/src/components/datepicker/events.ts +149 -0
- package/src/components/datepicker/index.ts +10 -0
- package/src/components/datepicker/keyboard.ts +646 -0
- package/src/components/datepicker/locales.ts +80 -0
- package/src/components/datepicker/templates.ts +792 -0
- package/src/components/datepicker/types.ts +154 -0
- package/src/components/datepicker/utils.ts +631 -0
- package/src/components/dismiss/dismiss.css +10 -0
- package/src/components/dismiss/dismiss.ts +152 -0
- package/src/components/dismiss/index.ts +7 -0
- package/src/components/dismiss/types.ts +17 -0
- package/src/components/drawer/drawer.css +97 -0
- package/src/components/drawer/drawer.ts +437 -0
- package/src/components/drawer/index.ts +7 -0
- package/src/components/drawer/types.ts +25 -0
- package/src/components/dropdown/dropdown-menu.css +56 -0
- package/src/components/dropdown/dropdown.css +46 -0
- package/src/components/dropdown/dropdown.ts +549 -0
- package/src/components/dropdown/index.ts +7 -0
- package/src/components/dropdown/types.ts +28 -0
- package/src/components/form/form.css +54 -0
- package/src/components/image-input/image-input.css +56 -0
- package/src/components/image-input/image-input.ts +249 -0
- package/src/components/image-input/index.ts +10 -0
- package/src/components/image-input/types.ts +12 -0
- package/src/components/input/input-group.css +42 -0
- package/src/components/input/input.css +136 -0
- package/src/components/kbd/kbd.css +30 -0
- package/src/components/label/label.css +20 -0
- package/src/components/link/link.css +81 -0
- package/src/components/modal/index.ts +7 -0
- package/src/components/modal/modal.css +73 -0
- package/src/components/modal/modal.ts +382 -0
- package/src/components/modal/types.ts +21 -0
- package/src/components/pagination/pagination.css +26 -0
- package/src/components/popover/popover.css +22 -0
- package/src/components/progress/progress.css +51 -0
- package/src/components/radio/radio.css +51 -0
- package/src/components/reparent/index.ts +7 -0
- package/src/components/reparent/reparent.ts +109 -0
- package/src/components/reparent/types.ts +15 -0
- package/src/components/scrollable/index.ts +10 -0
- package/src/components/scrollable/scrollable.css +29 -0
- package/src/components/scrollable/scrollable.ts +297 -0
- package/src/components/scrollable/types.ts +16 -0
- package/src/components/scrollspy/index.ts +7 -0
- package/src/components/scrollspy/scrollspy.css +13 -0
- package/src/components/scrollspy/scrollspy.ts +224 -0
- package/src/components/scrollspy/types.ts +15 -0
- package/src/components/scrollto/index.ts +7 -0
- package/src/components/scrollto/scrollto.ts +127 -0
- package/src/components/scrollto/types.ts +15 -0
- package/src/components/select/combobox.ts +305 -0
- package/src/components/select/config.ts +324 -0
- package/src/components/select/dropdown.ts +510 -0
- package/src/components/select/index.ts +13 -0
- package/src/components/select/option.ts +43 -0
- package/src/components/select/remote.ts +477 -0
- package/src/components/select/search.ts +430 -0
- package/src/components/select/select.css +105 -0
- package/src/components/select/select.ts +1916 -0
- package/src/components/select/tags.ts +123 -0
- package/src/components/select/templates.ts +531 -0
- package/src/components/select/types.ts +36 -0
- package/src/components/select/utils.ts +747 -0
- package/src/components/select/variants.css +5 -0
- package/src/components/separator/separator.css +14 -0
- package/src/components/skeleton/skeleton.css +10 -0
- package/src/components/stepper/index.ts +7 -0
- package/src/components/stepper/stepper.css +49 -0
- package/src/components/stepper/stepper.ts +308 -0
- package/src/components/stepper/types.ts +13 -0
- package/src/components/sticky/index.ts +7 -0
- package/src/components/sticky/sticky.css +22 -0
- package/src/components/sticky/sticky.ts +381 -0
- package/src/components/sticky/types.ts +23 -0
- package/src/components/switch/switch.css +110 -0
- package/src/components/table/table.css +168 -0
- package/src/components/tabs/index.ts +7 -0
- package/src/components/tabs/tabs.css +40 -0
- package/src/components/tabs/tabs.ts +190 -0
- package/src/components/tabs/types.ts +13 -0
- package/src/components/textarea/textarea.css +35 -0
- package/src/components/theme-switch/index.ts +10 -0
- package/src/components/theme-switch/theme-switch.css +22 -0
- package/src/components/theme-switch/theme-switch.ts +176 -0
- package/src/components/theme-switch/types.ts +15 -0
- package/src/components/toggle/index.ts +7 -0
- package/src/components/toggle/toggle.css +13 -0
- package/src/components/toggle/toggle.ts +173 -0
- package/src/components/toggle/types.ts +18 -0
- package/src/components/toggle-group/toggle-group.css +55 -0
- package/src/components/toggle-password/index.ts +10 -0
- package/src/components/toggle-password/toggle-password.css +13 -0
- package/src/components/toggle-password/toggle-password.ts +159 -0
- package/src/components/toggle-password/types.ts +13 -0
- package/src/components/tooltip/index.ts +7 -0
- package/src/components/tooltip/tooltip.css +18 -0
- package/src/components/tooltip/tooltip.ts +361 -0
- package/src/components/tooltip/types.ts +28 -0
- package/src/helpers/data.ts +46 -0
- package/src/helpers/dom.ts +405 -0
- package/src/helpers/event-handler.ts +61 -0
- package/src/helpers/utils.ts +183 -0
- package/src/index.ts +113 -0
- package/src/types.ts +23 -0
- package/styles.css +48 -0
- package/tsconfig.json +17 -0
- package/webpack.config.js +113 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
|
|
3
|
+
* Copyright 2025 by Keenthemes Inc
|
|
4
|
+
* @version: 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { KTDatepickerConfigInterface, LocaleConfigInterface } from './types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Format a date according to the provided format string
|
|
10
|
+
*
|
|
11
|
+
* @param date - Date to format
|
|
12
|
+
* @param format - Format string
|
|
13
|
+
* @param config - Datepicker configuration
|
|
14
|
+
* @returns Formatted date string
|
|
15
|
+
*/
|
|
16
|
+
export function formatDate(
|
|
17
|
+
date: Date,
|
|
18
|
+
format: string,
|
|
19
|
+
config: KTDatepickerConfigInterface,
|
|
20
|
+
): string {
|
|
21
|
+
if (!date || !(date instanceof Date) || isNaN(date.getTime())) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const locale = getLocaleConfig(config);
|
|
26
|
+
const isLeadingZero = config.forceLeadingZero;
|
|
27
|
+
|
|
28
|
+
// Replace year tokens
|
|
29
|
+
const year = date.getFullYear();
|
|
30
|
+
format = format.replace(/yyyy/g, year.toString());
|
|
31
|
+
format = format.replace(/yy/g, year.toString().slice(-2));
|
|
32
|
+
|
|
33
|
+
// Replace month tokens
|
|
34
|
+
const month = date.getMonth();
|
|
35
|
+
const monthNum = month + 1;
|
|
36
|
+
format = format.replace(/MMMM/g, locale.monthNames[month]);
|
|
37
|
+
format = format.replace(/MMM/g, locale.monthNamesShort[month]);
|
|
38
|
+
format = format.replace(
|
|
39
|
+
/MM/g,
|
|
40
|
+
isLeadingZero ? padZero(monthNum) : monthNum.toString(),
|
|
41
|
+
);
|
|
42
|
+
format = format.replace(/M/g, monthNum.toString());
|
|
43
|
+
|
|
44
|
+
// Replace day tokens
|
|
45
|
+
const day = date.getDate();
|
|
46
|
+
format = format.replace(/dd/g, isLeadingZero ? padZero(day) : day.toString());
|
|
47
|
+
format = format.replace(/d/g, day.toString());
|
|
48
|
+
|
|
49
|
+
// Replace day of week tokens
|
|
50
|
+
const dayOfWeek = date.getDay();
|
|
51
|
+
format = format.replace(/EEEE/g, locale.dayNames[dayOfWeek]);
|
|
52
|
+
format = format.replace(/EEE/g, locale.dayNamesShort[dayOfWeek]);
|
|
53
|
+
format = format.replace(/E/g, locale.dayNamesMin[dayOfWeek]);
|
|
54
|
+
|
|
55
|
+
// Replace time tokens if time is enabled
|
|
56
|
+
if (config.enableTime) {
|
|
57
|
+
const hours = date.getHours();
|
|
58
|
+
const minutes = date.getMinutes();
|
|
59
|
+
const seconds = date.getSeconds();
|
|
60
|
+
|
|
61
|
+
// 24-hour format
|
|
62
|
+
format = format.replace(
|
|
63
|
+
/HH/g,
|
|
64
|
+
isLeadingZero ? padZero(hours) : hours.toString(),
|
|
65
|
+
);
|
|
66
|
+
format = format.replace(/H/g, hours.toString());
|
|
67
|
+
|
|
68
|
+
// 12-hour format
|
|
69
|
+
const hours12 = hours % 12 || 12;
|
|
70
|
+
format = format.replace(
|
|
71
|
+
/hh/g,
|
|
72
|
+
isLeadingZero ? padZero(hours12) : hours12.toString(),
|
|
73
|
+
);
|
|
74
|
+
format = format.replace(/h/g, hours12.toString());
|
|
75
|
+
|
|
76
|
+
// Minutes and seconds
|
|
77
|
+
format = format.replace(
|
|
78
|
+
/mm/g,
|
|
79
|
+
isLeadingZero ? padZero(minutes) : minutes.toString(),
|
|
80
|
+
);
|
|
81
|
+
format = format.replace(/m/g, minutes.toString());
|
|
82
|
+
format = format.replace(
|
|
83
|
+
/ss/g,
|
|
84
|
+
isLeadingZero ? padZero(seconds) : seconds.toString(),
|
|
85
|
+
);
|
|
86
|
+
format = format.replace(/s/g, seconds.toString());
|
|
87
|
+
|
|
88
|
+
// AM/PM
|
|
89
|
+
const ampm = hours >= 12 ? config.pm : config.am;
|
|
90
|
+
format = format.replace(/A/g, ampm);
|
|
91
|
+
format = format.replace(/a/g, ampm.toLowerCase());
|
|
92
|
+
|
|
93
|
+
// Timezone (simplified implementation)
|
|
94
|
+
const timezoneOffset = date.getTimezoneOffset();
|
|
95
|
+
const timezoneOffsetHours = Math.abs(Math.floor(timezoneOffset / 60));
|
|
96
|
+
const timezoneOffsetMinutes = Math.abs(timezoneOffset % 60);
|
|
97
|
+
const timezoneSign = timezoneOffset > 0 ? '-' : '+';
|
|
98
|
+
|
|
99
|
+
const formattedTimezone = `${timezoneSign}${padZero(timezoneOffsetHours)}:${padZero(timezoneOffsetMinutes)}`;
|
|
100
|
+
format = format.replace(/ZZZ/g, formattedTimezone);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return format;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Parse a date string according to the provided format
|
|
108
|
+
*
|
|
109
|
+
* @param dateStr - Date string to parse
|
|
110
|
+
* @param format - Format string
|
|
111
|
+
* @param config - Datepicker configuration
|
|
112
|
+
* @returns Parsed date or null if invalid
|
|
113
|
+
*/
|
|
114
|
+
export function parseDate(
|
|
115
|
+
dateStr: string,
|
|
116
|
+
format: string,
|
|
117
|
+
config: KTDatepickerConfigInterface,
|
|
118
|
+
): Date | null {
|
|
119
|
+
if (!dateStr) return null;
|
|
120
|
+
|
|
121
|
+
// Handle natural language dates if enabled
|
|
122
|
+
if (config.enableNaturalLanguage) {
|
|
123
|
+
const naturalDate = parseNaturalLanguageDate(dateStr);
|
|
124
|
+
if (naturalDate) return naturalDate;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Create a new date object to populate
|
|
128
|
+
const date = new Date();
|
|
129
|
+
date.setHours(0, 0, 0, 0);
|
|
130
|
+
|
|
131
|
+
// Extract parts from the format
|
|
132
|
+
const formatParts: { [key: string]: string } = {};
|
|
133
|
+
|
|
134
|
+
let formatRegex = format
|
|
135
|
+
.replace(/(\w)(\1*)/g, (_, p1, p2) => {
|
|
136
|
+
const length = p1.length + p2.length;
|
|
137
|
+
let token = '';
|
|
138
|
+
|
|
139
|
+
switch (p1) {
|
|
140
|
+
case 'y':
|
|
141
|
+
token = length > 2 ? 'yyyy' : 'yy';
|
|
142
|
+
break;
|
|
143
|
+
case 'M':
|
|
144
|
+
token = ['M', 'MM', 'MMM', 'MMMM'][Math.min(length - 1, 3)];
|
|
145
|
+
break;
|
|
146
|
+
case 'd':
|
|
147
|
+
token = length > 1 ? 'dd' : 'd';
|
|
148
|
+
break;
|
|
149
|
+
case 'E':
|
|
150
|
+
token = length > 3 ? 'EEEE' : length > 1 ? 'EEE' : 'E';
|
|
151
|
+
break;
|
|
152
|
+
case 'h':
|
|
153
|
+
case 'H':
|
|
154
|
+
token = length > 1 ? p1 + p1 : p1;
|
|
155
|
+
break;
|
|
156
|
+
case 'm':
|
|
157
|
+
token = length > 1 ? 'mm' : 'm';
|
|
158
|
+
break;
|
|
159
|
+
case 's':
|
|
160
|
+
token = length > 1 ? 'ss' : 's';
|
|
161
|
+
break;
|
|
162
|
+
case 'a':
|
|
163
|
+
case 'A':
|
|
164
|
+
token = p1;
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
token = p1.repeat(length);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
formatParts[token] = '';
|
|
171
|
+
return `(\\d+|[a-zA-Z]+)`;
|
|
172
|
+
})
|
|
173
|
+
.replace(/[^\w\s]/g, '\\$&');
|
|
174
|
+
|
|
175
|
+
const match = new RegExp(formatRegex).exec(dateStr);
|
|
176
|
+
if (!match) return null;
|
|
177
|
+
|
|
178
|
+
// Map format tokens to their extracted values
|
|
179
|
+
let i = 1;
|
|
180
|
+
for (const token in formatParts) {
|
|
181
|
+
formatParts[token] = match[i++];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Extract year
|
|
185
|
+
if (formatParts.yyyy) {
|
|
186
|
+
date.setFullYear(parseInt(formatParts.yyyy));
|
|
187
|
+
} else if (formatParts.yy) {
|
|
188
|
+
const year = parseInt(formatParts.yy);
|
|
189
|
+
const century = Math.floor(new Date().getFullYear() / 100) * 100;
|
|
190
|
+
date.setFullYear(century + year);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Extract month
|
|
194
|
+
if (formatParts.MM || formatParts.M) {
|
|
195
|
+
const month = parseInt(formatParts.MM || formatParts.M) - 1;
|
|
196
|
+
if (month >= 0 && month <= 11) {
|
|
197
|
+
date.setMonth(month);
|
|
198
|
+
}
|
|
199
|
+
} else if (formatParts.MMM || formatParts.MMMM) {
|
|
200
|
+
const monthName = formatParts.MMMM || formatParts.MMM;
|
|
201
|
+
const locale = getLocaleConfig(config);
|
|
202
|
+
const monthIndex = locale.monthNames.findIndex(
|
|
203
|
+
(m) => m.toLowerCase() === monthName.toLowerCase(),
|
|
204
|
+
);
|
|
205
|
+
if (monthIndex === -1) {
|
|
206
|
+
const shortMonthIndex = locale.monthNamesShort.findIndex(
|
|
207
|
+
(m) => m.toLowerCase() === monthName.toLowerCase(),
|
|
208
|
+
);
|
|
209
|
+
if (shortMonthIndex !== -1) {
|
|
210
|
+
date.setMonth(shortMonthIndex);
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
date.setMonth(monthIndex);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Extract day
|
|
218
|
+
if (formatParts.dd || formatParts.d) {
|
|
219
|
+
const day = parseInt(formatParts.dd || formatParts.d);
|
|
220
|
+
if (day >= 1 && day <= 31) {
|
|
221
|
+
date.setDate(day);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Extract time if needed
|
|
226
|
+
if (config.enableTime) {
|
|
227
|
+
// Hours (24-hour format)
|
|
228
|
+
if (formatParts.HH || formatParts.H) {
|
|
229
|
+
const hours = parseInt(formatParts.HH || formatParts.H);
|
|
230
|
+
if (hours >= 0 && hours <= 23) {
|
|
231
|
+
date.setHours(hours);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Hours (12-hour format)
|
|
235
|
+
else if (formatParts.hh || formatParts.h) {
|
|
236
|
+
let hours = parseInt(formatParts.hh || formatParts.h);
|
|
237
|
+
|
|
238
|
+
// Adjust for AM/PM
|
|
239
|
+
if (formatParts.A) {
|
|
240
|
+
const isPM = formatParts.A.toUpperCase() === config.pm;
|
|
241
|
+
if (isPM && hours < 12) {
|
|
242
|
+
hours += 12;
|
|
243
|
+
} else if (!isPM && hours === 12) {
|
|
244
|
+
hours = 0;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (hours >= 0 && hours <= 23) {
|
|
249
|
+
date.setHours(hours);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Minutes
|
|
254
|
+
if (formatParts.mm || formatParts.m) {
|
|
255
|
+
const minutes = parseInt(formatParts.mm || formatParts.m);
|
|
256
|
+
if (minutes >= 0 && minutes <= 59) {
|
|
257
|
+
date.setMinutes(minutes);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Seconds
|
|
262
|
+
if (formatParts.ss || formatParts.s) {
|
|
263
|
+
const seconds = parseInt(formatParts.ss || formatParts.s);
|
|
264
|
+
if (seconds >= 0 && seconds <= 59) {
|
|
265
|
+
date.setSeconds(seconds);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Validate the final date
|
|
271
|
+
return isValidDate(date) ? date : null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Parse natural language date strings
|
|
276
|
+
*
|
|
277
|
+
* @param input - Natural language date string
|
|
278
|
+
* @returns Parsed date or null if not recognized
|
|
279
|
+
*/
|
|
280
|
+
function parseNaturalLanguageDate(input: string): Date | null {
|
|
281
|
+
const normalized = input.trim().toLowerCase();
|
|
282
|
+
const now = new Date();
|
|
283
|
+
|
|
284
|
+
// Handle common natural language inputs
|
|
285
|
+
switch (normalized) {
|
|
286
|
+
case 'today':
|
|
287
|
+
return new Date(now.setHours(0, 0, 0, 0));
|
|
288
|
+
|
|
289
|
+
case 'yesterday': {
|
|
290
|
+
const yesterday = new Date(now);
|
|
291
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
292
|
+
yesterday.setHours(0, 0, 0, 0);
|
|
293
|
+
return yesterday;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
case 'tomorrow': {
|
|
297
|
+
const tomorrow = new Date(now);
|
|
298
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
299
|
+
tomorrow.setHours(0, 0, 0, 0);
|
|
300
|
+
return tomorrow;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
default: {
|
|
304
|
+
// Handle relative dates like "next week", "last month", etc.
|
|
305
|
+
const relativeMatch = normalized.match(
|
|
306
|
+
/^(next|last|this)\s+(day|week|month|year)$/,
|
|
307
|
+
);
|
|
308
|
+
if (relativeMatch) {
|
|
309
|
+
const [_, direction, unit] = relativeMatch;
|
|
310
|
+
const result = new Date(now);
|
|
311
|
+
result.setHours(0, 0, 0, 0);
|
|
312
|
+
|
|
313
|
+
switch (unit) {
|
|
314
|
+
case 'day':
|
|
315
|
+
result.setDate(
|
|
316
|
+
result.getDate() +
|
|
317
|
+
(direction === 'next' ? 1 : direction === 'last' ? -1 : 0),
|
|
318
|
+
);
|
|
319
|
+
break;
|
|
320
|
+
|
|
321
|
+
case 'week':
|
|
322
|
+
result.setDate(
|
|
323
|
+
result.getDate() +
|
|
324
|
+
(direction === 'next' ? 7 : direction === 'last' ? -7 : 0),
|
|
325
|
+
);
|
|
326
|
+
break;
|
|
327
|
+
|
|
328
|
+
case 'month':
|
|
329
|
+
result.setMonth(
|
|
330
|
+
result.getMonth() +
|
|
331
|
+
(direction === 'next' ? 1 : direction === 'last' ? -1 : 0),
|
|
332
|
+
);
|
|
333
|
+
break;
|
|
334
|
+
|
|
335
|
+
case 'year':
|
|
336
|
+
result.setFullYear(
|
|
337
|
+
result.getFullYear() +
|
|
338
|
+
(direction === 'next' ? 1 : direction === 'last' ? -1 : 0),
|
|
339
|
+
);
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Check if a date is valid
|
|
353
|
+
*
|
|
354
|
+
* @param date - Date to check
|
|
355
|
+
* @returns Whether the date is valid
|
|
356
|
+
*/
|
|
357
|
+
export function isValidDate(date: any): boolean {
|
|
358
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Get the number of days in a month
|
|
363
|
+
*
|
|
364
|
+
* @param year - Year
|
|
365
|
+
* @param month - Month (0-indexed)
|
|
366
|
+
* @returns Number of days in the month
|
|
367
|
+
*/
|
|
368
|
+
export function getDaysInMonth(year: number, month: number): number {
|
|
369
|
+
return new Date(year, month + 1, 0).getDate();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Get the first day of the month
|
|
374
|
+
*
|
|
375
|
+
* @param year - Year
|
|
376
|
+
* @param month - Month (0-indexed)
|
|
377
|
+
* @returns Day of week for the first day (0 = Sunday, 6 = Saturday)
|
|
378
|
+
*/
|
|
379
|
+
export function getFirstDayOfMonth(year: number, month: number): number {
|
|
380
|
+
return new Date(year, month, 1).getDay();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Pad a number with a leading zero if needed
|
|
385
|
+
*
|
|
386
|
+
* @param num - Number to pad
|
|
387
|
+
* @returns Padded number string
|
|
388
|
+
*/
|
|
389
|
+
export function padZero(num: number): string {
|
|
390
|
+
return num < 10 ? `0${num}` : num.toString();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Get locale configuration for the datepicker
|
|
395
|
+
*
|
|
396
|
+
* @param config - Datepicker configuration
|
|
397
|
+
* @returns Locale configuration
|
|
398
|
+
*/
|
|
399
|
+
export function getLocaleConfig(
|
|
400
|
+
config: KTDatepickerConfigInterface,
|
|
401
|
+
): LocaleConfigInterface {
|
|
402
|
+
return config.locales[config.locale] || config.locales['en-US'];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Check if a date is between two other dates (inclusive)
|
|
407
|
+
*
|
|
408
|
+
* @param date - Date to check
|
|
409
|
+
* @param start - Start date
|
|
410
|
+
* @param end - End date
|
|
411
|
+
* @returns Whether the date is between start and end
|
|
412
|
+
*/
|
|
413
|
+
export function isDateBetween(date: Date, start: Date, end: Date): boolean {
|
|
414
|
+
const dateTime = date.getTime();
|
|
415
|
+
return dateTime >= start.getTime() && dateTime <= end.getTime();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Compare two dates for equality (ignoring time)
|
|
420
|
+
*
|
|
421
|
+
* @param date1 - First date
|
|
422
|
+
* @param date2 - Second date
|
|
423
|
+
* @returns Whether the dates are equal
|
|
424
|
+
*/
|
|
425
|
+
export function isSameDay(date1: Date, date2: Date): boolean {
|
|
426
|
+
return (
|
|
427
|
+
date1.getFullYear() === date2.getFullYear() &&
|
|
428
|
+
date1.getMonth() === date2.getMonth() &&
|
|
429
|
+
date1.getDate() === date2.getDate()
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Check if a date is a weekend (Saturday or Sunday)
|
|
435
|
+
*
|
|
436
|
+
* @param date - Date to check
|
|
437
|
+
* @returns Whether the date is a weekend
|
|
438
|
+
*/
|
|
439
|
+
export function isWeekend(date: Date): boolean {
|
|
440
|
+
const day = date.getDay();
|
|
441
|
+
return day === 0 || day === 6;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Check if a date is disabled (outside min/max range or explicitly disabled)
|
|
446
|
+
*
|
|
447
|
+
* @param date - Date to check
|
|
448
|
+
* @param config - Datepicker configuration
|
|
449
|
+
* @returns Whether the date is disabled
|
|
450
|
+
*/
|
|
451
|
+
export function isDateDisabled(
|
|
452
|
+
date: Date,
|
|
453
|
+
config: KTDatepickerConfigInterface,
|
|
454
|
+
): boolean {
|
|
455
|
+
if (!date || !(date instanceof Date) || isNaN(date.getTime())) {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// Set the time to noon for consistent comparison
|
|
460
|
+
const normalizedDate = new Date(date);
|
|
461
|
+
normalizedDate.setHours(12, 0, 0, 0);
|
|
462
|
+
|
|
463
|
+
// Check min date
|
|
464
|
+
if (config.minDate) {
|
|
465
|
+
let minDate: Date | null = null;
|
|
466
|
+
|
|
467
|
+
if (config.minDate instanceof Date) {
|
|
468
|
+
minDate = new Date(config.minDate);
|
|
469
|
+
minDate.setHours(0, 0, 0, 0);
|
|
470
|
+
} else {
|
|
471
|
+
// Try parsing with the configured format
|
|
472
|
+
minDate = parseDate(config.minDate.toString(), config.format, config);
|
|
473
|
+
|
|
474
|
+
// If that fails, try parsing with other common formats
|
|
475
|
+
if (!minDate) {
|
|
476
|
+
// Try DD/MM/YYYY format
|
|
477
|
+
const parts = config.minDate.toString().split('/');
|
|
478
|
+
if (parts.length === 3) {
|
|
479
|
+
const day = parseInt(parts[0], 10);
|
|
480
|
+
const month = parseInt(parts[1], 10) - 1;
|
|
481
|
+
const year = parseInt(parts[2], 10);
|
|
482
|
+
|
|
483
|
+
if (!isNaN(day) && !isNaN(month) && !isNaN(year)) {
|
|
484
|
+
minDate = new Date(year, month, day);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (minDate) {
|
|
491
|
+
// Ensure minDate has time set to beginning of day for accurate comparison
|
|
492
|
+
minDate.setHours(0, 0, 0, 0);
|
|
493
|
+
if (normalizedDate < minDate) {
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Check max date
|
|
500
|
+
if (config.maxDate) {
|
|
501
|
+
let maxDate: Date | null = null;
|
|
502
|
+
|
|
503
|
+
if (config.maxDate instanceof Date) {
|
|
504
|
+
maxDate = new Date(config.maxDate);
|
|
505
|
+
maxDate.setHours(23, 59, 59, 999);
|
|
506
|
+
} else {
|
|
507
|
+
// Try parsing with the configured format
|
|
508
|
+
maxDate = parseDate(config.maxDate.toString(), config.format, config);
|
|
509
|
+
|
|
510
|
+
// If that fails, try parsing with other common formats
|
|
511
|
+
if (!maxDate) {
|
|
512
|
+
// Try DD/MM/YYYY format
|
|
513
|
+
const parts = config.maxDate.toString().split('/');
|
|
514
|
+
if (parts.length === 3) {
|
|
515
|
+
const day = parseInt(parts[0], 10);
|
|
516
|
+
const month = parseInt(parts[1], 10) - 1;
|
|
517
|
+
const year = parseInt(parts[2], 10);
|
|
518
|
+
|
|
519
|
+
if (!isNaN(day) && !isNaN(month) && !isNaN(year)) {
|
|
520
|
+
maxDate = new Date(year, month, day);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (maxDate) {
|
|
527
|
+
// Ensure maxDate has time set to end of day for accurate comparison
|
|
528
|
+
maxDate.setHours(23, 59, 59, 999);
|
|
529
|
+
if (normalizedDate > maxDate) {
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Check explicitly disabled dates
|
|
536
|
+
if (config.disabledDates && config.disabledDates.length > 0) {
|
|
537
|
+
for (const disabledDate of config.disabledDates) {
|
|
538
|
+
const disabled =
|
|
539
|
+
disabledDate instanceof Date
|
|
540
|
+
? disabledDate
|
|
541
|
+
: parseDate(disabledDate.toString(), config.format, config);
|
|
542
|
+
|
|
543
|
+
if (disabled && isSameDay(normalizedDate, disabled)) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Generate a calender for the specified month
|
|
554
|
+
*
|
|
555
|
+
* @param year - Year
|
|
556
|
+
* @param month - Month (0-indexed)
|
|
557
|
+
* @param config - Datepicker configuration
|
|
558
|
+
* @returns Calendar days matrix
|
|
559
|
+
*/
|
|
560
|
+
export function generateCalendarMonth(
|
|
561
|
+
year: number,
|
|
562
|
+
month: number,
|
|
563
|
+
config: KTDatepickerConfigInterface,
|
|
564
|
+
): Date[][] {
|
|
565
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
566
|
+
const firstDayOfMonth = getFirstDayOfMonth(year, month);
|
|
567
|
+
const locale = getLocaleConfig(config);
|
|
568
|
+
const firstDayOfWeek = locale.firstDayOfWeek;
|
|
569
|
+
|
|
570
|
+
// Calculate the offset from the first day of the month to the first day of the calendar
|
|
571
|
+
let startOffset = (firstDayOfMonth - firstDayOfWeek + 7) % 7;
|
|
572
|
+
|
|
573
|
+
// Create a 6x7 matrix for the calendar
|
|
574
|
+
const calendar: Date[][] = [];
|
|
575
|
+
let day = 1 - startOffset;
|
|
576
|
+
|
|
577
|
+
for (let week = 0; week < 6; week++) {
|
|
578
|
+
const weekDays: Date[] = [];
|
|
579
|
+
|
|
580
|
+
for (let i = 0; i < 7; i++) {
|
|
581
|
+
const date = new Date(year, month, day);
|
|
582
|
+
weekDays.push(date);
|
|
583
|
+
day++;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
calendar.push(weekDays);
|
|
587
|
+
|
|
588
|
+
// If we've gone past the end of the month and it's a complete week, we can stop
|
|
589
|
+
if (day > daysInMonth && week >= 4) {
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return calendar;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Check if two dates are the same day
|
|
599
|
+
* (ignoring time part)
|
|
600
|
+
*
|
|
601
|
+
* @param date1 - First date to compare
|
|
602
|
+
* @param date2 - Second date to compare
|
|
603
|
+
* @returns True if dates are the same day
|
|
604
|
+
*/
|
|
605
|
+
export function isDateEqual(date1: Date, date2: Date): boolean {
|
|
606
|
+
return (
|
|
607
|
+
date1.getDate() === date2.getDate() &&
|
|
608
|
+
date1.getMonth() === date2.getMonth() &&
|
|
609
|
+
date1.getFullYear() === date2.getFullYear()
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Check if a date is within a range (inclusive)
|
|
615
|
+
*
|
|
616
|
+
* @param date - Date to check
|
|
617
|
+
* @param startDate - Start date of the range
|
|
618
|
+
* @param endDate - End date of the range
|
|
619
|
+
* @returns True if date is within the range
|
|
620
|
+
*/
|
|
621
|
+
export function isDateInRange(
|
|
622
|
+
date: Date,
|
|
623
|
+
startDate: Date,
|
|
624
|
+
endDate: Date,
|
|
625
|
+
): boolean {
|
|
626
|
+
const time = date.getTime();
|
|
627
|
+
const startTime = startDate.getTime();
|
|
628
|
+
const endTime = endDate.getTime();
|
|
629
|
+
|
|
630
|
+
return time >= startTime && time <= endTime;
|
|
631
|
+
}
|