@keenthemes/ktui 1.2.0 → 1.2.2
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 +8355 -5213
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/dist/styles.css +24 -1
- package/lib/cjs/components/carousel/carousel.d.ts +102 -0
- package/lib/cjs/components/carousel/carousel.d.ts.map +1 -0
- package/lib/cjs/components/carousel/carousel.js +769 -0
- package/lib/cjs/components/carousel/carousel.js.map +1 -0
- package/lib/cjs/components/carousel/index.d.ts +7 -0
- package/lib/cjs/components/carousel/index.d.ts.map +1 -0
- package/lib/cjs/components/carousel/index.js +10 -0
- package/lib/cjs/components/carousel/index.js.map +1 -0
- package/lib/cjs/components/carousel/types.d.ts +36 -0
- package/lib/cjs/components/carousel/types.d.ts.map +1 -0
- package/lib/cjs/components/carousel/types.js +7 -0
- package/lib/cjs/components/carousel/types.js.map +1 -0
- package/lib/cjs/components/clipboard/clipboard.d.ts +37 -0
- package/lib/cjs/components/clipboard/clipboard.d.ts.map +1 -0
- package/lib/cjs/components/clipboard/clipboard.js +402 -0
- package/lib/cjs/components/clipboard/clipboard.js.map +1 -0
- package/lib/cjs/components/clipboard/index.d.ts +3 -0
- package/lib/cjs/components/clipboard/index.d.ts.map +1 -0
- package/lib/cjs/components/clipboard/index.js +6 -0
- package/lib/cjs/components/clipboard/index.js.map +1 -0
- package/lib/cjs/components/clipboard/types.d.ts +44 -0
- package/lib/cjs/components/clipboard/types.d.ts.map +1 -0
- package/lib/cjs/components/clipboard/types.js +7 -0
- package/lib/cjs/components/clipboard/types.js.map +1 -0
- package/lib/cjs/components/component.d.ts +3 -3
- package/lib/cjs/components/component.d.ts.map +1 -1
- package/lib/cjs/components/component.js +9 -1
- package/lib/cjs/components/component.js.map +1 -1
- package/lib/cjs/components/datatable/datatable-checkbox.d.ts +1 -1
- package/lib/cjs/components/datatable/datatable-checkbox.d.ts.map +1 -1
- package/lib/cjs/components/datatable/datatable-checkbox.js +1 -1
- package/lib/cjs/components/datatable/datatable-checkbox.js.map +1 -1
- package/lib/cjs/components/datatable/datatable-sort.d.ts +1 -1
- package/lib/cjs/components/datatable/datatable-sort.d.ts.map +1 -1
- package/lib/cjs/components/datatable/datatable-sort.js.map +1 -1
- package/lib/cjs/components/datatable/datatable.d.ts +2 -0
- package/lib/cjs/components/datatable/datatable.d.ts.map +1 -1
- package/lib/cjs/components/datatable/datatable.js +29 -16
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/components/datatable/types.d.ts +2 -1
- package/lib/cjs/components/datatable/types.d.ts.map +1 -1
- package/lib/cjs/components/drawer/drawer.d.ts.map +1 -1
- package/lib/cjs/components/drawer/drawer.js +3 -16
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.d.ts +1 -1
- package/lib/cjs/components/dropdown/dropdown.d.ts.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js +2 -3
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/pin-input/index.d.ts +3 -0
- package/lib/cjs/components/pin-input/index.d.ts.map +1 -0
- package/lib/cjs/components/pin-input/index.js +6 -0
- package/lib/cjs/components/pin-input/index.js.map +1 -0
- package/lib/cjs/components/pin-input/pin-input.d.ts +56 -0
- package/lib/cjs/components/pin-input/pin-input.d.ts.map +1 -0
- package/lib/cjs/components/pin-input/pin-input.js +455 -0
- package/lib/cjs/components/pin-input/pin-input.js.map +1 -0
- package/lib/cjs/components/pin-input/types.d.ts +41 -0
- package/lib/cjs/components/pin-input/types.d.ts.map +1 -0
- package/lib/cjs/components/pin-input/types.js +6 -0
- package/lib/cjs/components/pin-input/types.js.map +1 -0
- package/lib/cjs/components/range-slider/index.d.ts +7 -0
- package/lib/cjs/components/range-slider/index.d.ts.map +1 -0
- package/lib/cjs/components/range-slider/index.js +10 -0
- package/lib/cjs/components/range-slider/index.js.map +1 -0
- package/lib/cjs/components/range-slider/range-slider.d.ts +42 -0
- package/lib/cjs/components/range-slider/range-slider.d.ts.map +1 -0
- package/lib/cjs/components/range-slider/range-slider.js +254 -0
- package/lib/cjs/components/range-slider/range-slider.js.map +1 -0
- package/lib/cjs/components/range-slider/types.d.ts +33 -0
- package/lib/cjs/components/range-slider/types.d.ts.map +1 -0
- package/lib/cjs/components/range-slider/types.js +7 -0
- package/lib/cjs/components/range-slider/types.js.map +1 -0
- package/lib/cjs/components/rating/rating.d.ts.map +1 -1
- package/lib/cjs/components/rating/rating.js +8 -3
- package/lib/cjs/components/rating/rating.js.map +1 -1
- package/lib/cjs/components/repeater/repeater.d.ts.map +1 -1
- package/lib/cjs/components/repeater/repeater.js +3 -2
- package/lib/cjs/components/repeater/repeater.js.map +1 -1
- package/lib/cjs/components/select/combobox.d.ts.map +1 -1
- package/lib/cjs/components/select/combobox.js +25 -15
- package/lib/cjs/components/select/combobox.js.map +1 -1
- package/lib/cjs/components/select/config.d.ts +2 -2
- package/lib/cjs/components/select/config.d.ts.map +1 -1
- package/lib/cjs/components/select/config.js +10 -9
- package/lib/cjs/components/select/config.js.map +1 -1
- package/lib/cjs/components/select/dropdown.js.map +1 -1
- package/lib/cjs/components/select/option.d.ts +2 -1
- package/lib/cjs/components/select/option.d.ts.map +1 -1
- package/lib/cjs/components/select/option.js +9 -3
- package/lib/cjs/components/select/option.js.map +1 -1
- package/lib/cjs/components/select/remote.d.ts +1 -0
- package/lib/cjs/components/select/remote.d.ts.map +1 -1
- package/lib/cjs/components/select/remote.js +21 -14
- package/lib/cjs/components/select/remote.js.map +1 -1
- package/lib/cjs/components/select/search.d.ts +1 -1
- package/lib/cjs/components/select/search.d.ts.map +1 -1
- package/lib/cjs/components/select/search.js +34 -25
- package/lib/cjs/components/select/search.js.map +1 -1
- package/lib/cjs/components/select/select.d.ts +5 -3
- package/lib/cjs/components/select/select.d.ts.map +1 -1
- package/lib/cjs/components/select/select.js +31 -31
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/select/tags.d.ts.map +1 -1
- package/lib/cjs/components/select/tags.js +22 -13
- package/lib/cjs/components/select/tags.js.map +1 -1
- package/lib/cjs/components/select/templates.d.ts.map +1 -1
- package/lib/cjs/components/select/templates.js +4 -4
- package/lib/cjs/components/select/templates.js.map +1 -1
- package/lib/cjs/components/select/types.d.ts +1 -1
- package/lib/cjs/components/select/types.d.ts.map +1 -1
- package/lib/cjs/components/select/utils.d.ts +4 -4
- package/lib/cjs/components/select/utils.d.ts.map +1 -1
- package/lib/cjs/components/select/utils.js +5 -4
- package/lib/cjs/components/select/utils.js.map +1 -1
- package/lib/cjs/components/sticky/sticky.d.ts +1 -1
- package/lib/cjs/components/sticky/sticky.d.ts.map +1 -1
- package/lib/cjs/components/sticky/sticky.js +16 -14
- package/lib/cjs/components/sticky/sticky.js.map +1 -1
- package/lib/cjs/components/toast/toast.d.ts.map +1 -1
- package/lib/cjs/components/toast/toast.js +17 -9
- package/lib/cjs/components/toast/toast.js.map +1 -1
- package/lib/cjs/components/toast/types.d.ts +3 -0
- package/lib/cjs/components/toast/types.d.ts.map +1 -1
- package/lib/cjs/components/toggle-password/toggle-password.d.ts.map +1 -1
- package/lib/cjs/components/toggle-password/toggle-password.js.map +1 -1
- package/lib/cjs/helpers/dom.d.ts +4 -4
- package/lib/cjs/helpers/dom.d.ts.map +1 -1
- package/lib/cjs/helpers/dom.js +8 -10
- package/lib/cjs/helpers/dom.js.map +1 -1
- package/lib/cjs/helpers/event-handler.d.ts +1 -1
- package/lib/cjs/helpers/event-handler.d.ts.map +1 -1
- package/lib/cjs/helpers/event-handler.js +3 -1
- package/lib/cjs/helpers/event-handler.js.map +1 -1
- package/lib/cjs/helpers/utils.d.ts +1 -1
- package/lib/cjs/helpers/utils.d.ts.map +1 -1
- package/lib/cjs/helpers/utils.js +4 -1
- package/lib/cjs/helpers/utils.js.map +1 -1
- package/lib/cjs/index.d.ts +16 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +17 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +1 -1
- package/lib/cjs/types.d.ts.map +1 -1
- package/lib/esm/components/carousel/carousel.d.ts +102 -0
- package/lib/esm/components/carousel/carousel.d.ts.map +1 -0
- package/lib/esm/components/carousel/carousel.js +766 -0
- package/lib/esm/components/carousel/carousel.js.map +1 -0
- package/lib/esm/components/carousel/index.d.ts +7 -0
- package/lib/esm/components/carousel/index.d.ts.map +1 -0
- package/lib/esm/components/carousel/index.js +6 -0
- package/lib/esm/components/carousel/index.js.map +1 -0
- package/lib/esm/components/carousel/types.d.ts +36 -0
- package/lib/esm/components/carousel/types.d.ts.map +1 -0
- package/lib/esm/components/carousel/types.js +6 -0
- package/lib/esm/components/carousel/types.js.map +1 -0
- package/lib/esm/components/clipboard/clipboard.d.ts +37 -0
- package/lib/esm/components/clipboard/clipboard.d.ts.map +1 -0
- package/lib/esm/components/clipboard/clipboard.js +399 -0
- package/lib/esm/components/clipboard/clipboard.js.map +1 -0
- package/lib/esm/components/clipboard/index.d.ts +3 -0
- package/lib/esm/components/clipboard/index.d.ts.map +1 -0
- package/lib/esm/components/clipboard/index.js +2 -0
- package/lib/esm/components/clipboard/index.js.map +1 -0
- package/lib/esm/components/clipboard/types.d.ts +44 -0
- package/lib/esm/components/clipboard/types.d.ts.map +1 -0
- package/lib/esm/components/clipboard/types.js +6 -0
- package/lib/esm/components/clipboard/types.js.map +1 -0
- package/lib/esm/components/component.d.ts +3 -3
- package/lib/esm/components/component.d.ts.map +1 -1
- package/lib/esm/components/component.js +9 -1
- package/lib/esm/components/component.js.map +1 -1
- package/lib/esm/components/datatable/datatable-checkbox.d.ts +1 -1
- package/lib/esm/components/datatable/datatable-checkbox.d.ts.map +1 -1
- package/lib/esm/components/datatable/datatable-checkbox.js +1 -1
- package/lib/esm/components/datatable/datatable-checkbox.js.map +1 -1
- package/lib/esm/components/datatable/datatable-sort.d.ts +1 -1
- package/lib/esm/components/datatable/datatable-sort.d.ts.map +1 -1
- package/lib/esm/components/datatable/datatable-sort.js.map +1 -1
- package/lib/esm/components/datatable/datatable.d.ts +2 -0
- package/lib/esm/components/datatable/datatable.d.ts.map +1 -1
- package/lib/esm/components/datatable/datatable.js +29 -16
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/components/datatable/types.d.ts +2 -1
- package/lib/esm/components/datatable/types.d.ts.map +1 -1
- package/lib/esm/components/drawer/drawer.d.ts.map +1 -1
- package/lib/esm/components/drawer/drawer.js +3 -16
- package/lib/esm/components/drawer/drawer.js.map +1 -1
- package/lib/esm/components/dropdown/dropdown.d.ts +1 -1
- package/lib/esm/components/dropdown/dropdown.d.ts.map +1 -1
- package/lib/esm/components/dropdown/dropdown.js +2 -3
- package/lib/esm/components/dropdown/dropdown.js.map +1 -1
- package/lib/esm/components/pin-input/index.d.ts +3 -0
- package/lib/esm/components/pin-input/index.d.ts.map +1 -0
- package/lib/esm/components/pin-input/index.js +2 -0
- package/lib/esm/components/pin-input/index.js.map +1 -0
- package/lib/esm/components/pin-input/pin-input.d.ts +56 -0
- package/lib/esm/components/pin-input/pin-input.d.ts.map +1 -0
- package/lib/esm/components/pin-input/pin-input.js +452 -0
- package/lib/esm/components/pin-input/pin-input.js.map +1 -0
- package/lib/esm/components/pin-input/types.d.ts +41 -0
- package/lib/esm/components/pin-input/types.d.ts.map +1 -0
- package/lib/esm/components/pin-input/types.js +5 -0
- package/lib/esm/components/pin-input/types.js.map +1 -0
- package/lib/esm/components/range-slider/index.d.ts +7 -0
- package/lib/esm/components/range-slider/index.d.ts.map +1 -0
- package/lib/esm/components/range-slider/index.js +6 -0
- package/lib/esm/components/range-slider/index.js.map +1 -0
- package/lib/esm/components/range-slider/range-slider.d.ts +42 -0
- package/lib/esm/components/range-slider/range-slider.d.ts.map +1 -0
- package/lib/esm/components/range-slider/range-slider.js +251 -0
- package/lib/esm/components/range-slider/range-slider.js.map +1 -0
- package/lib/esm/components/range-slider/types.d.ts +33 -0
- package/lib/esm/components/range-slider/types.d.ts.map +1 -0
- package/lib/esm/components/range-slider/types.js +6 -0
- package/lib/esm/components/range-slider/types.js.map +1 -0
- package/lib/esm/components/rating/rating.d.ts.map +1 -1
- package/lib/esm/components/rating/rating.js +8 -3
- package/lib/esm/components/rating/rating.js.map +1 -1
- package/lib/esm/components/repeater/repeater.d.ts.map +1 -1
- package/lib/esm/components/repeater/repeater.js +3 -2
- package/lib/esm/components/repeater/repeater.js.map +1 -1
- package/lib/esm/components/select/combobox.d.ts.map +1 -1
- package/lib/esm/components/select/combobox.js +25 -15
- package/lib/esm/components/select/combobox.js.map +1 -1
- package/lib/esm/components/select/config.d.ts +2 -2
- package/lib/esm/components/select/config.d.ts.map +1 -1
- package/lib/esm/components/select/config.js +10 -9
- package/lib/esm/components/select/config.js.map +1 -1
- package/lib/esm/components/select/dropdown.js.map +1 -1
- package/lib/esm/components/select/option.d.ts +2 -1
- package/lib/esm/components/select/option.d.ts.map +1 -1
- package/lib/esm/components/select/option.js +9 -3
- package/lib/esm/components/select/option.js.map +1 -1
- package/lib/esm/components/select/remote.d.ts +1 -0
- package/lib/esm/components/select/remote.d.ts.map +1 -1
- package/lib/esm/components/select/remote.js +21 -14
- package/lib/esm/components/select/remote.js.map +1 -1
- package/lib/esm/components/select/search.d.ts +1 -1
- package/lib/esm/components/select/search.d.ts.map +1 -1
- package/lib/esm/components/select/search.js +34 -25
- package/lib/esm/components/select/search.js.map +1 -1
- package/lib/esm/components/select/select.d.ts +5 -3
- package/lib/esm/components/select/select.d.ts.map +1 -1
- package/lib/esm/components/select/select.js +31 -31
- package/lib/esm/components/select/select.js.map +1 -1
- package/lib/esm/components/select/tags.d.ts.map +1 -1
- package/lib/esm/components/select/tags.js +22 -13
- package/lib/esm/components/select/tags.js.map +1 -1
- package/lib/esm/components/select/templates.d.ts.map +1 -1
- package/lib/esm/components/select/templates.js +4 -4
- package/lib/esm/components/select/templates.js.map +1 -1
- package/lib/esm/components/select/types.d.ts +1 -1
- package/lib/esm/components/select/types.d.ts.map +1 -1
- package/lib/esm/components/select/utils.d.ts +4 -4
- package/lib/esm/components/select/utils.d.ts.map +1 -1
- package/lib/esm/components/select/utils.js +5 -4
- package/lib/esm/components/select/utils.js.map +1 -1
- package/lib/esm/components/sticky/sticky.d.ts +1 -1
- package/lib/esm/components/sticky/sticky.d.ts.map +1 -1
- package/lib/esm/components/sticky/sticky.js +16 -14
- package/lib/esm/components/sticky/sticky.js.map +1 -1
- package/lib/esm/components/toast/toast.d.ts.map +1 -1
- package/lib/esm/components/toast/toast.js +17 -9
- package/lib/esm/components/toast/toast.js.map +1 -1
- package/lib/esm/components/toast/types.d.ts +3 -0
- package/lib/esm/components/toast/types.d.ts.map +1 -1
- package/lib/esm/components/toggle-password/toggle-password.d.ts.map +1 -1
- package/lib/esm/components/toggle-password/toggle-password.js.map +1 -1
- package/lib/esm/helpers/dom.d.ts +4 -4
- package/lib/esm/helpers/dom.d.ts.map +1 -1
- package/lib/esm/helpers/dom.js +8 -10
- package/lib/esm/helpers/dom.js.map +1 -1
- package/lib/esm/helpers/event-handler.d.ts +1 -1
- package/lib/esm/helpers/event-handler.d.ts.map +1 -1
- package/lib/esm/helpers/event-handler.js +3 -1
- package/lib/esm/helpers/event-handler.js.map +1 -1
- package/lib/esm/helpers/utils.d.ts +1 -1
- package/lib/esm/helpers/utils.d.ts.map +1 -1
- package/lib/esm/helpers/utils.js +4 -1
- package/lib/esm/helpers/utils.js.map +1 -1
- package/lib/esm/index.d.ts +16 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +12 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +1 -1
- package/lib/esm/types.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/components/carousel/__tests__/carousel.test.ts +326 -0
- package/src/components/carousel/carousel.css +42 -0
- package/src/components/carousel/carousel.ts +847 -0
- package/src/components/carousel/index.ts +11 -0
- package/src/components/carousel/types.ts +38 -0
- package/src/components/clipboard/__tests__/clipboard.test.ts +438 -0
- package/src/components/clipboard/clipboard.ts +416 -0
- package/src/components/clipboard/index.ts +2 -0
- package/src/components/clipboard/types.ts +51 -0
- package/src/components/component.ts +15 -5
- package/src/components/datatable/__tests__/currency-sort.test.ts +6 -13
- package/src/components/datatable/__tests__/multi-row-headers.test.ts +2 -2
- package/src/components/datatable/__tests__/pagination-reset.test.ts +7 -4
- package/src/components/datatable/__tests__/race-conditions.test.ts +11 -14
- package/src/components/datatable/__tests__/setup.ts +1 -1
- package/src/components/datatable/datatable-checkbox.ts +6 -4
- package/src/components/datatable/datatable-sort.ts +27 -7
- package/src/components/datatable/datatable.ts +67 -42
- package/src/components/datatable/types.ts +3 -1
- package/src/components/drawer/drawer.ts +3 -18
- package/src/components/dropdown/dropdown.ts +2 -3
- package/src/components/pin-input/__tests__/pin-input.test.ts +928 -0
- package/src/components/pin-input/index.ts +6 -0
- package/src/components/pin-input/pin-input.ts +499 -0
- package/src/components/pin-input/types.ts +45 -0
- package/src/components/range-slider/__tests__/range-slider.test.ts +659 -0
- package/src/components/range-slider/index.ts +11 -0
- package/src/components/range-slider/range-slider.ts +276 -0
- package/src/components/range-slider/types.ts +36 -0
- package/src/components/rating/__tests__/rating.test.ts +11 -4
- package/src/components/rating/rating.ts +22 -12
- package/src/components/repeater/__tests__/repeater.test.ts +24 -11
- package/src/components/repeater/repeater.ts +5 -3
- package/src/components/select/__tests__/ux-behaviors.test.ts +25 -6
- package/src/components/select/combobox.ts +23 -16
- package/src/components/select/config.ts +15 -14
- package/src/components/select/dropdown.ts +1 -1
- package/src/components/select/option.ts +14 -4
- package/src/components/select/remote.ts +68 -56
- package/src/components/select/search.ts +30 -27
- package/src/components/select/select.ts +41 -37
- package/src/components/select/tags.ts +14 -8
- package/src/components/select/templates.ts +11 -6
- package/src/components/select/types.ts +1 -1
- package/src/components/select/utils.ts +12 -10
- package/src/components/sticky/__tests__/sticky.test.ts +10 -3
- package/src/components/sticky/sticky.ts +16 -26
- package/src/components/sticky/types.ts +3 -3
- package/src/components/toast/toast.ts +34 -21
- package/src/components/toast/types.ts +5 -1
- package/src/components/toggle-password/toggle-password.ts +0 -1
- package/src/helpers/dom.ts +14 -17
- package/src/helpers/event-handler.ts +5 -6
- package/src/helpers/utils.ts +5 -2
- package/src/index.ts +35 -0
- package/src/types.ts +1 -1
- package/styles.css +1 -0
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
|
|
4
|
+
* Copyright 2025 by Keenthemes Inc
|
|
5
|
+
*/
|
|
6
|
+
var __extends = (this && this.__extends) || (function () {
|
|
7
|
+
var extendStatics = function (d, b) {
|
|
8
|
+
extendStatics = Object.setPrototypeOf ||
|
|
9
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11
|
+
return extendStatics(d, b);
|
|
12
|
+
};
|
|
13
|
+
return function (d, b) {
|
|
14
|
+
if (typeof b !== "function" && b !== null)
|
|
15
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
+
extendStatics(d, b);
|
|
17
|
+
function __() { this.constructor = d; }
|
|
18
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.KTCarousel = void 0;
|
|
23
|
+
var data_1 = require("../../helpers/data");
|
|
24
|
+
var component_1 = require("../component");
|
|
25
|
+
var SELECTOR_VIEWPORT = '[data-kt-carousel-viewport]';
|
|
26
|
+
var SELECTOR_ITEM = '[data-kt-carousel-item]';
|
|
27
|
+
var SELECTOR_PREV = '[data-kt-carousel-prev]';
|
|
28
|
+
var SELECTOR_NEXT = '[data-kt-carousel-next]';
|
|
29
|
+
var SELECTOR_PAGINATION = '[data-kt-carousel-pagination]';
|
|
30
|
+
var SELECTOR_PAGINATION_ITEM = '[data-kt-carousel-pagination-item]';
|
|
31
|
+
var SELECTOR_THUMBS = '[data-kt-carousel-thumbnails]';
|
|
32
|
+
var SELECTOR_THUMB = '[data-kt-carousel-thumbnail]';
|
|
33
|
+
var SELECTOR_CURRENT = '[data-kt-carousel-current]';
|
|
34
|
+
var SELECTOR_TOTAL = '[data-kt-carousel-total]';
|
|
35
|
+
var KTCarousel = /** @class */ (function (_super) {
|
|
36
|
+
__extends(KTCarousel, _super);
|
|
37
|
+
function KTCarousel(element, config) {
|
|
38
|
+
if (config === void 0) { config = null; }
|
|
39
|
+
var _this = _super.call(this) || this;
|
|
40
|
+
_this._name = 'carousel';
|
|
41
|
+
_this._defaultConfig = {
|
|
42
|
+
autoplay: false,
|
|
43
|
+
autoplayInterval: 4000,
|
|
44
|
+
infiniteLoop: false,
|
|
45
|
+
rtl: false,
|
|
46
|
+
perView: 1,
|
|
47
|
+
centered: false,
|
|
48
|
+
draggable: false,
|
|
49
|
+
snap: false,
|
|
50
|
+
autoHeight: false,
|
|
51
|
+
showScrollbar: false,
|
|
52
|
+
lazy: false,
|
|
53
|
+
pauseOnHover: true,
|
|
54
|
+
changeEvent: 'kt.carousel.change',
|
|
55
|
+
};
|
|
56
|
+
_this._config = _this
|
|
57
|
+
._defaultConfig;
|
|
58
|
+
_this._viewport = null;
|
|
59
|
+
_this._slides = [];
|
|
60
|
+
_this._index = 0;
|
|
61
|
+
_this._autoplayTimer = null;
|
|
62
|
+
_this._programmaticScroll = false;
|
|
63
|
+
_this._resizeObserver = null;
|
|
64
|
+
_this._prefersReducedMotion = false;
|
|
65
|
+
_this._onPrevClick = null;
|
|
66
|
+
_this._onNextClick = null;
|
|
67
|
+
_this._onScroll = null;
|
|
68
|
+
_this._onScrollEnd = null;
|
|
69
|
+
_this._onKeyDown = null;
|
|
70
|
+
_this._onPointerDown = null;
|
|
71
|
+
_this._onPointerMove = null;
|
|
72
|
+
_this._onPointerUp = null;
|
|
73
|
+
_this._paginationHandlers = [];
|
|
74
|
+
_this._thumbHandlers = [];
|
|
75
|
+
_this._programmaticScrollPrevIndex = null;
|
|
76
|
+
_this._programmaticScrollTargetIndex = null;
|
|
77
|
+
_this._programmaticScrollUserInitiated = false;
|
|
78
|
+
_this._programmaticScrollFallbackTimer = null;
|
|
79
|
+
_this._scrollSyncRaf = 0;
|
|
80
|
+
_this._pauseAutoplay = null;
|
|
81
|
+
_this._resumeAutoplay = null;
|
|
82
|
+
_this._dragStartX = 0;
|
|
83
|
+
_this._dragStartScroll = 0;
|
|
84
|
+
_this._dragging = false;
|
|
85
|
+
_this._dragMoved = false;
|
|
86
|
+
_this._pointerId = null;
|
|
87
|
+
_this._prevButtons = [];
|
|
88
|
+
_this._nextButtons = [];
|
|
89
|
+
_this._currentLabels = [];
|
|
90
|
+
_this._totalLabels = [];
|
|
91
|
+
if (_this._shouldSkipInit(element)) {
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
var viewport = KTCarousel._resolveViewportStatic(element);
|
|
95
|
+
var slides = KTCarousel._collectSlidesStatic(viewport);
|
|
96
|
+
if (!viewport || slides.length === 0) {
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
_this._init(element);
|
|
100
|
+
_this._buildConfig(config);
|
|
101
|
+
_this._syncShowScrollbarAttribute();
|
|
102
|
+
_this._viewport = viewport;
|
|
103
|
+
_this._slides = slides;
|
|
104
|
+
_this._prefersReducedMotion = _this._readPrefersReducedMotion();
|
|
105
|
+
_this._bindControls();
|
|
106
|
+
_this._bindScrollSync();
|
|
107
|
+
_this._bindKeyboard();
|
|
108
|
+
_this._bindAutoplayHoverPause();
|
|
109
|
+
_this._bindDraggable();
|
|
110
|
+
_this._bindAutoHeight();
|
|
111
|
+
_this._syncIndexFromScroll();
|
|
112
|
+
_this._updateInfo();
|
|
113
|
+
_this._updatePaginationState();
|
|
114
|
+
_this._updateThumbState(false);
|
|
115
|
+
_this._startAutoplay();
|
|
116
|
+
return _this;
|
|
117
|
+
}
|
|
118
|
+
KTCarousel.prototype._readPrefersReducedMotion = function () {
|
|
119
|
+
if (typeof window === 'undefined' || !window.matchMedia) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
123
|
+
};
|
|
124
|
+
KTCarousel.prototype._syncShowScrollbarAttribute = function () {
|
|
125
|
+
if (!this._element)
|
|
126
|
+
return;
|
|
127
|
+
var show = this._getOption('showScrollbar') === true;
|
|
128
|
+
if (show) {
|
|
129
|
+
this._element.setAttribute('data-kt-carousel-show-scrollbar', 'true');
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this._element.removeAttribute('data-kt-carousel-show-scrollbar');
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
KTCarousel._resolveViewportStatic = function (root) {
|
|
136
|
+
var explicit = root.querySelector(SELECTOR_VIEWPORT);
|
|
137
|
+
if (explicit)
|
|
138
|
+
return explicit;
|
|
139
|
+
return root;
|
|
140
|
+
};
|
|
141
|
+
KTCarousel._collectSlidesStatic = function (viewport) {
|
|
142
|
+
if (!viewport)
|
|
143
|
+
return [];
|
|
144
|
+
return Array.from(viewport.querySelectorAll(SELECTOR_ITEM));
|
|
145
|
+
};
|
|
146
|
+
KTCarousel.prototype._isRtl = function () {
|
|
147
|
+
var _a;
|
|
148
|
+
if (this._getOption('rtl') === true)
|
|
149
|
+
return true;
|
|
150
|
+
if (((_a = this._element) === null || _a === void 0 ? void 0 : _a.getAttribute('dir')) === 'rtl')
|
|
151
|
+
return true;
|
|
152
|
+
if (this._viewport &&
|
|
153
|
+
getComputedStyle(this._viewport).direction === 'rtl') {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
};
|
|
158
|
+
KTCarousel.prototype._scrollBehavior = function () {
|
|
159
|
+
return this._prefersReducedMotion ? 'auto' : 'smooth';
|
|
160
|
+
};
|
|
161
|
+
KTCarousel.prototype._effectiveDraggable = function () {
|
|
162
|
+
if (this._getOption('snap') === true)
|
|
163
|
+
return false;
|
|
164
|
+
return this._getOption('draggable') === true;
|
|
165
|
+
};
|
|
166
|
+
KTCarousel.prototype._bindControls = function () {
|
|
167
|
+
var _this = this;
|
|
168
|
+
if (!this._element)
|
|
169
|
+
return;
|
|
170
|
+
var root = this._element;
|
|
171
|
+
this._prevButtons = Array.from(root.querySelectorAll(SELECTOR_PREV));
|
|
172
|
+
this._nextButtons = Array.from(root.querySelectorAll(SELECTOR_NEXT));
|
|
173
|
+
this._currentLabels = Array.from(root.querySelectorAll(SELECTOR_CURRENT));
|
|
174
|
+
this._totalLabels = Array.from(root.querySelectorAll(SELECTOR_TOTAL));
|
|
175
|
+
this._onPrevClick = function (e) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
_this.prev(true);
|
|
178
|
+
};
|
|
179
|
+
this._onNextClick = function (e) {
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
_this.next(true);
|
|
182
|
+
};
|
|
183
|
+
this._prevButtons.forEach(function (btn) {
|
|
184
|
+
btn.addEventListener('click', _this._onPrevClick);
|
|
185
|
+
});
|
|
186
|
+
this._nextButtons.forEach(function (btn) {
|
|
187
|
+
btn.addEventListener('click', _this._onNextClick);
|
|
188
|
+
});
|
|
189
|
+
this._bindIndexedClickStrips(SELECTOR_PAGINATION, SELECTOR_PAGINATION_ITEM, this._paginationHandlers);
|
|
190
|
+
this._bindIndexedClickStrips(SELECTOR_THUMBS, SELECTOR_THUMB, this._thumbHandlers);
|
|
191
|
+
};
|
|
192
|
+
KTCarousel.prototype._bindIndexedClickStrips = function (stripSelector, itemSelector, handlers) {
|
|
193
|
+
var _this = this;
|
|
194
|
+
if (!this._element)
|
|
195
|
+
return;
|
|
196
|
+
this._element
|
|
197
|
+
.querySelectorAll(stripSelector)
|
|
198
|
+
.forEach(function (strip) {
|
|
199
|
+
strip.querySelectorAll(itemSelector).forEach(function (item, i) {
|
|
200
|
+
var fn = function (e) {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
_this.goTo(i, true);
|
|
203
|
+
};
|
|
204
|
+
item.addEventListener('click', fn);
|
|
205
|
+
handlers.push({ el: item, fn: fn });
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
KTCarousel.prototype._bindScrollSync = function () {
|
|
210
|
+
var _this = this;
|
|
211
|
+
if (!this._viewport)
|
|
212
|
+
return;
|
|
213
|
+
this._onScroll = function () {
|
|
214
|
+
if (_this._scrollSyncRaf)
|
|
215
|
+
cancelAnimationFrame(_this._scrollSyncRaf);
|
|
216
|
+
_this._scrollSyncRaf = requestAnimationFrame(function () {
|
|
217
|
+
_this._scrollSyncRaf = 0;
|
|
218
|
+
var prev = _this._index;
|
|
219
|
+
_this._applyScrollDerivedIndexChange(prev, {
|
|
220
|
+
dispatch: !_this._programmaticScroll,
|
|
221
|
+
userInitiated: true,
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
this._viewport.addEventListener('scroll', this._onScroll, {
|
|
226
|
+
passive: true,
|
|
227
|
+
});
|
|
228
|
+
this._onScrollEnd = function () {
|
|
229
|
+
if (_this._programmaticScroll) {
|
|
230
|
+
var t = _this._programmaticScrollTargetIndex;
|
|
231
|
+
if (t !== null && _this._nearestIndex() === t) {
|
|
232
|
+
queueMicrotask(function () { return _this._completeProgrammaticScroll(); });
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
var prev = _this._index;
|
|
237
|
+
_this._applyScrollDerivedIndexChange(prev, {
|
|
238
|
+
dispatch: true,
|
|
239
|
+
userInitiated: true,
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
this._viewport.addEventListener('scrollend', this._onScrollEnd);
|
|
243
|
+
};
|
|
244
|
+
KTCarousel.prototype._bindKeyboard = function () {
|
|
245
|
+
var _this = this;
|
|
246
|
+
if (!this._element)
|
|
247
|
+
return;
|
|
248
|
+
this._onKeyDown = function (e) {
|
|
249
|
+
var _a;
|
|
250
|
+
if (!((_a = _this._element) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
|
|
251
|
+
return;
|
|
252
|
+
var t = e.target;
|
|
253
|
+
if (t &&
|
|
254
|
+
(t.tagName === 'INPUT' ||
|
|
255
|
+
t.tagName === 'TEXTAREA' ||
|
|
256
|
+
t.isContentEditable)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')
|
|
260
|
+
return;
|
|
261
|
+
var rtl = _this._isRtl();
|
|
262
|
+
var nextKey = rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
263
|
+
var prevKey = rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
264
|
+
if (e.key === nextKey) {
|
|
265
|
+
e.preventDefault();
|
|
266
|
+
_this.next(true);
|
|
267
|
+
}
|
|
268
|
+
else if (e.key === prevKey) {
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
_this.prev(true);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
this._element.addEventListener('keydown', this._onKeyDown);
|
|
274
|
+
};
|
|
275
|
+
KTCarousel.prototype._bindAutoplayHoverPause = function () {
|
|
276
|
+
var _this = this;
|
|
277
|
+
if (!this._element || !this._viewport)
|
|
278
|
+
return;
|
|
279
|
+
if (this._getOption('pauseOnHover') !== true)
|
|
280
|
+
return;
|
|
281
|
+
this._pauseAutoplay = function () { return _this._stopAutoplay(); };
|
|
282
|
+
this._resumeAutoplay = function () { return _this._startAutoplay(); };
|
|
283
|
+
this._element.addEventListener('mouseenter', this._pauseAutoplay);
|
|
284
|
+
this._element.addEventListener('mouseleave', this._resumeAutoplay);
|
|
285
|
+
this._element.addEventListener('focusin', this._pauseAutoplay);
|
|
286
|
+
this._element.addEventListener('focusout', this._resumeAutoplay);
|
|
287
|
+
};
|
|
288
|
+
KTCarousel.prototype._bindDraggable = function () {
|
|
289
|
+
var _this = this;
|
|
290
|
+
if (!this._viewport || !this._effectiveDraggable())
|
|
291
|
+
return;
|
|
292
|
+
this._onPointerDown = function (e) {
|
|
293
|
+
if (e.pointerType === 'mouse' && e.button !== 0)
|
|
294
|
+
return;
|
|
295
|
+
var t = e.target;
|
|
296
|
+
if (t && t.closest('button,a,input,textarea,select'))
|
|
297
|
+
return;
|
|
298
|
+
_this._pointerId = e.pointerId;
|
|
299
|
+
_this._dragStartX = e.clientX;
|
|
300
|
+
_this._dragStartScroll = _this._viewport.scrollLeft;
|
|
301
|
+
_this._dragging = true;
|
|
302
|
+
_this._dragMoved = false;
|
|
303
|
+
_this._viewport.setPointerCapture(e.pointerId);
|
|
304
|
+
};
|
|
305
|
+
this._onPointerMove = function (e) {
|
|
306
|
+
if (!_this._dragging || e.pointerId !== _this._pointerId)
|
|
307
|
+
return;
|
|
308
|
+
var dx = e.clientX - _this._dragStartX;
|
|
309
|
+
if (Math.abs(dx) > 5)
|
|
310
|
+
_this._dragMoved = true;
|
|
311
|
+
_this._viewport.scrollLeft = _this._dragStartScroll - dx;
|
|
312
|
+
};
|
|
313
|
+
this._onPointerUp = function (e) {
|
|
314
|
+
if (e.pointerId !== _this._pointerId)
|
|
315
|
+
return;
|
|
316
|
+
_this._dragging = false;
|
|
317
|
+
_this._pointerId = null;
|
|
318
|
+
try {
|
|
319
|
+
_this._viewport.releasePointerCapture(e.pointerId);
|
|
320
|
+
}
|
|
321
|
+
catch (_a) {
|
|
322
|
+
/* ignore */
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
this._viewport.addEventListener('pointerdown', this._onPointerDown);
|
|
326
|
+
this._viewport.addEventListener('pointermove', this._onPointerMove);
|
|
327
|
+
this._viewport.addEventListener('pointerup', this._onPointerUp);
|
|
328
|
+
this._viewport.addEventListener('pointercancel', this._onPointerUp);
|
|
329
|
+
};
|
|
330
|
+
KTCarousel.prototype._bindAutoHeight = function () {
|
|
331
|
+
if (!this._viewport || this._getOption('autoHeight') !== true)
|
|
332
|
+
return;
|
|
333
|
+
this._applyAutoHeight();
|
|
334
|
+
this._observeActiveSlideForHeight();
|
|
335
|
+
};
|
|
336
|
+
KTCarousel.prototype._observeActiveSlideForHeight = function () {
|
|
337
|
+
var _this = this;
|
|
338
|
+
if (this._getOption('autoHeight') !== true)
|
|
339
|
+
return;
|
|
340
|
+
var active = this._slides[this._index];
|
|
341
|
+
if (!active || typeof ResizeObserver === 'undefined')
|
|
342
|
+
return;
|
|
343
|
+
if (!this._resizeObserver) {
|
|
344
|
+
this._resizeObserver = new ResizeObserver(function () {
|
|
345
|
+
_this._applyAutoHeight();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
this._resizeObserver.disconnect();
|
|
350
|
+
}
|
|
351
|
+
this._resizeObserver.observe(active);
|
|
352
|
+
};
|
|
353
|
+
KTCarousel.prototype._applyAutoHeight = function () {
|
|
354
|
+
if (!this._viewport || this._getOption('autoHeight') !== true)
|
|
355
|
+
return;
|
|
356
|
+
var slide = this._slides[this._index];
|
|
357
|
+
if (!slide)
|
|
358
|
+
return;
|
|
359
|
+
var h = slide.offsetHeight;
|
|
360
|
+
if (h > 0) {
|
|
361
|
+
this._viewport.style.height = "".concat(h, "px");
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
KTCarousel.prototype._nearestIndex = function () {
|
|
365
|
+
if (!this._viewport || this._slides.length === 0)
|
|
366
|
+
return 0;
|
|
367
|
+
var vp = this._viewport;
|
|
368
|
+
var origin = vp.scrollLeft;
|
|
369
|
+
var best = 0;
|
|
370
|
+
var bestDist = Infinity;
|
|
371
|
+
for (var i = 0; i < this._slides.length; i++) {
|
|
372
|
+
var slide = this._slides[i];
|
|
373
|
+
var dist = Math.abs(slide.offsetLeft - origin);
|
|
374
|
+
if (dist < bestDist) {
|
|
375
|
+
bestDist = dist;
|
|
376
|
+
best = i;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return best;
|
|
380
|
+
};
|
|
381
|
+
KTCarousel.prototype._syncIndexFromScroll = function () {
|
|
382
|
+
if (this._slides.length === 0)
|
|
383
|
+
return;
|
|
384
|
+
this._index = this._nearestIndex();
|
|
385
|
+
};
|
|
386
|
+
KTCarousel.prototype._applyScrollDerivedIndexChange = function (prevIndex, options) {
|
|
387
|
+
this._syncIndexFromScroll();
|
|
388
|
+
if (prevIndex === this._index)
|
|
389
|
+
return;
|
|
390
|
+
this._updateInfo();
|
|
391
|
+
this._updatePaginationState();
|
|
392
|
+
this._updateThumbState(false);
|
|
393
|
+
this._applyAutoHeight();
|
|
394
|
+
this._observeActiveSlideForHeight();
|
|
395
|
+
if (options.dispatch) {
|
|
396
|
+
this._dispatchChange(this._index, prevIndex, options.userInitiated);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
KTCarousel.prototype._setStripItemsActiveState = function (handlers, activeDataAttr) {
|
|
400
|
+
var _this = this;
|
|
401
|
+
handlers.forEach(function (_a, i) {
|
|
402
|
+
var el = _a.el;
|
|
403
|
+
var active = i === _this._index;
|
|
404
|
+
if (active) {
|
|
405
|
+
el.setAttribute('aria-current', 'true');
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
el.removeAttribute('aria-current');
|
|
409
|
+
}
|
|
410
|
+
el.toggleAttribute(activeDataAttr, active);
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Scroll the viewport only. Avoid `Element.scrollIntoView`, which walks
|
|
415
|
+
* ancestor scroll containers and can pull the whole docs page to an embedded
|
|
416
|
+
* carousel (e.g. autoplay ticking on `/docs/carousel`).
|
|
417
|
+
*/
|
|
418
|
+
KTCarousel.prototype._scrollToIndex = function (index, behavior) {
|
|
419
|
+
var _this = this;
|
|
420
|
+
if (!this._viewport)
|
|
421
|
+
return;
|
|
422
|
+
var slide = this._slides[index];
|
|
423
|
+
if (!slide)
|
|
424
|
+
return;
|
|
425
|
+
this._programmaticScroll = true;
|
|
426
|
+
var vp = this._viewport;
|
|
427
|
+
var centered = this._getOption('centered') === true;
|
|
428
|
+
var slideRect = slide.getBoundingClientRect();
|
|
429
|
+
var vpRect = vp.getBoundingClientRect();
|
|
430
|
+
var left = vp.scrollLeft + slideRect.left - vpRect.left;
|
|
431
|
+
if (centered) {
|
|
432
|
+
left -= (vp.clientWidth - slideRect.width) / 2;
|
|
433
|
+
}
|
|
434
|
+
var maxScroll = Math.max(0, vp.scrollWidth - vp.clientWidth);
|
|
435
|
+
left = Math.max(0, Math.min(left, maxScroll));
|
|
436
|
+
try {
|
|
437
|
+
vp.scrollTo({ left: left, top: vp.scrollTop, behavior: behavior });
|
|
438
|
+
}
|
|
439
|
+
catch (_a) {
|
|
440
|
+
vp.scrollLeft = left;
|
|
441
|
+
}
|
|
442
|
+
queueMicrotask(function () {
|
|
443
|
+
if (_this._programmaticScroll &&
|
|
444
|
+
_this._programmaticScrollTargetIndex !== null &&
|
|
445
|
+
_this._nearestIndex() === _this._programmaticScrollTargetIndex) {
|
|
446
|
+
_this._completeProgrammaticScroll();
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
this._clearProgrammaticScrollFallbackTimer();
|
|
450
|
+
var fallbackMs = behavior === 'smooth' ? 550 : 50;
|
|
451
|
+
this._programmaticScrollFallbackTimer = setTimeout(function () {
|
|
452
|
+
_this._programmaticScrollFallbackTimer = null;
|
|
453
|
+
_this._completeProgrammaticScroll();
|
|
454
|
+
}, fallbackMs);
|
|
455
|
+
};
|
|
456
|
+
KTCarousel.prototype._clearProgrammaticScrollFallbackTimer = function () {
|
|
457
|
+
if (this._programmaticScrollFallbackTimer !== null) {
|
|
458
|
+
clearTimeout(this._programmaticScrollFallbackTimer);
|
|
459
|
+
this._programmaticScrollFallbackTimer = null;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
KTCarousel.prototype._completeProgrammaticScroll = function () {
|
|
463
|
+
if (!this._programmaticScroll)
|
|
464
|
+
return;
|
|
465
|
+
var prev = this._programmaticScrollPrevIndex;
|
|
466
|
+
var targetIdx = this._programmaticScrollTargetIndex;
|
|
467
|
+
var userInitiated = this._programmaticScrollUserInitiated;
|
|
468
|
+
if (prev === null || targetIdx === null) {
|
|
469
|
+
this._programmaticScroll = false;
|
|
470
|
+
this._programmaticScrollPrevIndex = null;
|
|
471
|
+
this._programmaticScrollTargetIndex = null;
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (this._scrollSyncRaf) {
|
|
475
|
+
cancelAnimationFrame(this._scrollSyncRaf);
|
|
476
|
+
this._scrollSyncRaf = 0;
|
|
477
|
+
}
|
|
478
|
+
this._clearProgrammaticScrollFallbackTimer();
|
|
479
|
+
this._programmaticScroll = false;
|
|
480
|
+
this._programmaticScrollPrevIndex = null;
|
|
481
|
+
this._programmaticScrollTargetIndex = null;
|
|
482
|
+
this._programmaticScrollUserInitiated = false;
|
|
483
|
+
this._index = targetIdx;
|
|
484
|
+
this._updateInfo();
|
|
485
|
+
this._updatePaginationState();
|
|
486
|
+
this._updateThumbState(true);
|
|
487
|
+
this._applyAutoHeight();
|
|
488
|
+
this._observeActiveSlideForHeight();
|
|
489
|
+
this._dispatchChange(targetIdx, prev, userInitiated);
|
|
490
|
+
};
|
|
491
|
+
KTCarousel.prototype.goTo = function (index, userInitiated) {
|
|
492
|
+
if (userInitiated === void 0) { userInitiated = false; }
|
|
493
|
+
if (this._slides.length === 0)
|
|
494
|
+
return;
|
|
495
|
+
var n = this._slides.length;
|
|
496
|
+
var target = index;
|
|
497
|
+
if (target < 0)
|
|
498
|
+
target = 0;
|
|
499
|
+
if (target >= n)
|
|
500
|
+
target = n - 1;
|
|
501
|
+
var prev = this._index;
|
|
502
|
+
if (target === prev)
|
|
503
|
+
return;
|
|
504
|
+
this._clearProgrammaticScrollFallbackTimer();
|
|
505
|
+
this._programmaticScrollPrevIndex = prev;
|
|
506
|
+
this._programmaticScrollTargetIndex = target;
|
|
507
|
+
this._programmaticScrollUserInitiated = userInitiated;
|
|
508
|
+
this._scrollToIndex(target, this._scrollBehavior());
|
|
509
|
+
};
|
|
510
|
+
KTCarousel.prototype.next = function (userInitiated) {
|
|
511
|
+
if (userInitiated === void 0) { userInitiated = false; }
|
|
512
|
+
if (this._slides.length === 0)
|
|
513
|
+
return;
|
|
514
|
+
var n = this._slides.length;
|
|
515
|
+
var last = n - 1;
|
|
516
|
+
var infinite = this._getOption('infiniteLoop') === true;
|
|
517
|
+
if (this._index >= last) {
|
|
518
|
+
if (infinite) {
|
|
519
|
+
this.goTo(0, userInitiated);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
this.goTo(this._index + 1, userInitiated);
|
|
525
|
+
};
|
|
526
|
+
KTCarousel.prototype.prev = function (userInitiated) {
|
|
527
|
+
if (userInitiated === void 0) { userInitiated = false; }
|
|
528
|
+
if (this._slides.length === 0)
|
|
529
|
+
return;
|
|
530
|
+
var infinite = this._getOption('infiniteLoop') === true;
|
|
531
|
+
if (this._index <= 0) {
|
|
532
|
+
if (infinite) {
|
|
533
|
+
this.goTo(this._slides.length - 1, userInitiated);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
this.goTo(this._index - 1, userInitiated);
|
|
539
|
+
};
|
|
540
|
+
KTCarousel.prototype.getIndex = function () {
|
|
541
|
+
return this._index;
|
|
542
|
+
};
|
|
543
|
+
KTCarousel.prototype.getSlideCount = function () {
|
|
544
|
+
return this._slides.length;
|
|
545
|
+
};
|
|
546
|
+
KTCarousel.prototype._getChangeEventName = function () {
|
|
547
|
+
var name = this._getOption('changeEvent');
|
|
548
|
+
return typeof name === 'string' && name.length > 0
|
|
549
|
+
? name
|
|
550
|
+
: 'kt.carousel.change';
|
|
551
|
+
};
|
|
552
|
+
KTCarousel.prototype._dispatchChange = function (index, prevIndex, userInitiated) {
|
|
553
|
+
if (!this._element)
|
|
554
|
+
return;
|
|
555
|
+
var payload = {
|
|
556
|
+
index: index,
|
|
557
|
+
prevIndex: prevIndex,
|
|
558
|
+
userInitiated: userInitiated,
|
|
559
|
+
};
|
|
560
|
+
var eventName = this._getChangeEventName();
|
|
561
|
+
this._fireEvent(eventName, payload);
|
|
562
|
+
this._dispatchEvent(eventName, payload);
|
|
563
|
+
};
|
|
564
|
+
KTCarousel.prototype._updateInfo = function () {
|
|
565
|
+
if (!this._element)
|
|
566
|
+
return;
|
|
567
|
+
var total = this._slides.length;
|
|
568
|
+
var cur = total === 0 ? 0 : this._index + 1;
|
|
569
|
+
var curStr = String(cur);
|
|
570
|
+
var totalStr = String(total);
|
|
571
|
+
this._currentLabels.forEach(function (label) {
|
|
572
|
+
label.textContent = curStr;
|
|
573
|
+
});
|
|
574
|
+
this._totalLabels.forEach(function (label) {
|
|
575
|
+
label.textContent = totalStr;
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
KTCarousel.prototype._updatePaginationState = function () {
|
|
579
|
+
this._setStripItemsActiveState(this._paginationHandlers, 'data-kt-carousel-pagination-active');
|
|
580
|
+
};
|
|
581
|
+
KTCarousel.prototype._updateThumbState = function (alignStripSmooth) {
|
|
582
|
+
this._setStripItemsActiveState(this._thumbHandlers, 'data-kt-carousel-thumbnail-active');
|
|
583
|
+
this._scrollActiveThumbnailsIntoView(alignStripSmooth ? this._scrollBehavior() : 'auto');
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* Keep the active thumb visible inside each thumbnail strip by scrolling
|
|
587
|
+
* that container only (no `scrollIntoView`, which can scroll ancestor pages).
|
|
588
|
+
*/
|
|
589
|
+
KTCarousel.prototype._scrollActiveThumbnailsIntoView = function (behavior) {
|
|
590
|
+
var _this = this;
|
|
591
|
+
if (!this._element)
|
|
592
|
+
return;
|
|
593
|
+
var pad = 6;
|
|
594
|
+
this._element
|
|
595
|
+
.querySelectorAll(SELECTOR_THUMBS)
|
|
596
|
+
.forEach(function (strip) {
|
|
597
|
+
var items = strip.querySelectorAll(SELECTOR_THUMB);
|
|
598
|
+
var thumb = items[_this._index];
|
|
599
|
+
if (!thumb)
|
|
600
|
+
return;
|
|
601
|
+
_this._alignElementInScrollContainer(thumb, strip, pad, behavior);
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
KTCarousel.prototype._alignElementInScrollContainer = function (el, container, pad, behavior) {
|
|
605
|
+
var c = container.getBoundingClientRect();
|
|
606
|
+
var r = el.getBoundingClientRect();
|
|
607
|
+
var left = container.scrollLeft;
|
|
608
|
+
var top = container.scrollTop;
|
|
609
|
+
if (container.scrollWidth > container.clientWidth + 1) {
|
|
610
|
+
if (r.left < c.left + pad) {
|
|
611
|
+
left += r.left - c.left - pad;
|
|
612
|
+
}
|
|
613
|
+
else if (r.right > c.right - pad) {
|
|
614
|
+
left += r.right - c.right + pad;
|
|
615
|
+
}
|
|
616
|
+
var maxL = Math.max(0, container.scrollWidth - container.clientWidth);
|
|
617
|
+
left = Math.max(0, Math.min(left, maxL));
|
|
618
|
+
}
|
|
619
|
+
if (container.scrollHeight > container.clientHeight + 1) {
|
|
620
|
+
if (r.top < c.top + pad) {
|
|
621
|
+
top += r.top - c.top - pad;
|
|
622
|
+
}
|
|
623
|
+
else if (r.bottom > c.bottom - pad) {
|
|
624
|
+
top += r.bottom - c.bottom + pad;
|
|
625
|
+
}
|
|
626
|
+
var maxT = Math.max(0, container.scrollHeight - container.clientHeight);
|
|
627
|
+
top = Math.max(0, Math.min(top, maxT));
|
|
628
|
+
}
|
|
629
|
+
try {
|
|
630
|
+
container.scrollTo({ left: left, top: top, behavior: behavior });
|
|
631
|
+
}
|
|
632
|
+
catch (_a) {
|
|
633
|
+
container.scrollLeft = left;
|
|
634
|
+
container.scrollTop = top;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
KTCarousel.prototype._startAutoplay = function () {
|
|
638
|
+
var _this = this;
|
|
639
|
+
this._stopAutoplay();
|
|
640
|
+
if (this._getOption('autoplay') !== true)
|
|
641
|
+
return;
|
|
642
|
+
if (this._prefersReducedMotion)
|
|
643
|
+
return;
|
|
644
|
+
if (this._slides.length <= 1)
|
|
645
|
+
return;
|
|
646
|
+
var raw = this._getOption('autoplayInterval');
|
|
647
|
+
var interval = typeof raw === 'number' && raw >= 200 ? raw : 4000;
|
|
648
|
+
this._autoplayTimer = setInterval(function () {
|
|
649
|
+
_this.next(false);
|
|
650
|
+
}, interval);
|
|
651
|
+
};
|
|
652
|
+
KTCarousel.prototype._stopAutoplay = function () {
|
|
653
|
+
if (this._autoplayTimer !== null) {
|
|
654
|
+
clearInterval(this._autoplayTimer);
|
|
655
|
+
this._autoplayTimer = null;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
KTCarousel.prototype.dispose = function () {
|
|
659
|
+
var _this = this;
|
|
660
|
+
this._stopAutoplay();
|
|
661
|
+
this._clearProgrammaticScrollFallbackTimer();
|
|
662
|
+
if (this._scrollSyncRaf) {
|
|
663
|
+
cancelAnimationFrame(this._scrollSyncRaf);
|
|
664
|
+
this._scrollSyncRaf = 0;
|
|
665
|
+
}
|
|
666
|
+
this._programmaticScroll = false;
|
|
667
|
+
this._programmaticScrollPrevIndex = null;
|
|
668
|
+
this._programmaticScrollTargetIndex = null;
|
|
669
|
+
if (this._resizeObserver) {
|
|
670
|
+
this._resizeObserver.disconnect();
|
|
671
|
+
this._resizeObserver = null;
|
|
672
|
+
}
|
|
673
|
+
if (this._element) {
|
|
674
|
+
if (this._onPrevClick) {
|
|
675
|
+
this._prevButtons.forEach(function (btn) {
|
|
676
|
+
return btn.removeEventListener('click', _this._onPrevClick);
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
if (this._onNextClick) {
|
|
680
|
+
this._nextButtons.forEach(function (btn) {
|
|
681
|
+
return btn.removeEventListener('click', _this._onNextClick);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
this._paginationHandlers.forEach(function (_a) {
|
|
685
|
+
var el = _a.el, fn = _a.fn;
|
|
686
|
+
el.removeEventListener('click', fn);
|
|
687
|
+
});
|
|
688
|
+
this._paginationHandlers = [];
|
|
689
|
+
this._thumbHandlers.forEach(function (_a) {
|
|
690
|
+
var el = _a.el, fn = _a.fn;
|
|
691
|
+
el.removeEventListener('click', fn);
|
|
692
|
+
});
|
|
693
|
+
this._thumbHandlers = [];
|
|
694
|
+
if (this._onKeyDown) {
|
|
695
|
+
this._element.removeEventListener('keydown', this._onKeyDown);
|
|
696
|
+
}
|
|
697
|
+
if (this._pauseAutoplay && this._resumeAutoplay) {
|
|
698
|
+
this._element.removeEventListener('mouseenter', this._pauseAutoplay);
|
|
699
|
+
this._element.removeEventListener('mouseleave', this._resumeAutoplay);
|
|
700
|
+
this._element.removeEventListener('focusin', this._pauseAutoplay);
|
|
701
|
+
this._element.removeEventListener('focusout', this._resumeAutoplay);
|
|
702
|
+
}
|
|
703
|
+
this._pauseAutoplay = null;
|
|
704
|
+
this._resumeAutoplay = null;
|
|
705
|
+
}
|
|
706
|
+
if (this._viewport && this._onScroll) {
|
|
707
|
+
this._viewport.removeEventListener('scroll', this._onScroll);
|
|
708
|
+
}
|
|
709
|
+
if (this._viewport && this._onScrollEnd) {
|
|
710
|
+
this._viewport.removeEventListener('scrollend', this._onScrollEnd);
|
|
711
|
+
}
|
|
712
|
+
if (this._viewport && this._onPointerDown) {
|
|
713
|
+
this._viewport.removeEventListener('pointerdown', this._onPointerDown);
|
|
714
|
+
this._viewport.removeEventListener('pointermove', this._onPointerMove);
|
|
715
|
+
this._viewport.removeEventListener('pointerup', this._onPointerUp);
|
|
716
|
+
this._viewport.removeEventListener('pointercancel', this._onPointerUp);
|
|
717
|
+
}
|
|
718
|
+
if (this._viewport && this._getOption('autoHeight') === true) {
|
|
719
|
+
this._viewport.style.height = '';
|
|
720
|
+
}
|
|
721
|
+
this._onPrevClick = null;
|
|
722
|
+
this._onNextClick = null;
|
|
723
|
+
this._onScroll = null;
|
|
724
|
+
this._onScrollEnd = null;
|
|
725
|
+
this._onKeyDown = null;
|
|
726
|
+
this._onPointerDown = null;
|
|
727
|
+
this._onPointerMove = null;
|
|
728
|
+
this._onPointerUp = null;
|
|
729
|
+
this._prevButtons = [];
|
|
730
|
+
this._nextButtons = [];
|
|
731
|
+
this._currentLabels = [];
|
|
732
|
+
this._totalLabels = [];
|
|
733
|
+
_super.prototype.dispose.call(this);
|
|
734
|
+
};
|
|
735
|
+
KTCarousel.getInstance = function (element) {
|
|
736
|
+
if (!element)
|
|
737
|
+
return null;
|
|
738
|
+
if (data_1.default.has(element, 'carousel')) {
|
|
739
|
+
return data_1.default.get(element, 'carousel');
|
|
740
|
+
}
|
|
741
|
+
return null;
|
|
742
|
+
};
|
|
743
|
+
KTCarousel.getOrCreateInstance = function (element, config) {
|
|
744
|
+
var existing = this.getInstance(element);
|
|
745
|
+
if (existing)
|
|
746
|
+
return existing;
|
|
747
|
+
new KTCarousel(element, config !== null && config !== void 0 ? config : undefined);
|
|
748
|
+
return this.getInstance(element);
|
|
749
|
+
};
|
|
750
|
+
KTCarousel.createInstances = function () {
|
|
751
|
+
document
|
|
752
|
+
.querySelectorAll('[data-kt-carousel]')
|
|
753
|
+
.forEach(function (el) {
|
|
754
|
+
if (el.getAttribute('data-kt-carousel-lazy') === 'true') {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
new KTCarousel(el);
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
KTCarousel.init = function () {
|
|
761
|
+
KTCarousel.createInstances();
|
|
762
|
+
};
|
|
763
|
+
return KTCarousel;
|
|
764
|
+
}(component_1.default));
|
|
765
|
+
exports.KTCarousel = KTCarousel;
|
|
766
|
+
if (typeof window !== 'undefined') {
|
|
767
|
+
window.KTCarousel = KTCarousel;
|
|
768
|
+
}
|
|
769
|
+
//# sourceMappingURL=carousel.js.map
|