@bagelink/vue 1.6.47 → 1.6.49
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/bin/experimentalGenTypedRoutes.ts +18 -19
- package/bin/utils.ts +4 -4
- package/dist/components/AddressSearch.vue.d.ts.map +1 -1
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/Carousel.vue.d.ts +2 -2
- package/dist/components/Carousel.vue.d.ts.map +1 -1
- package/dist/components/Dropdown.vue.d.ts.map +1 -1
- package/dist/components/Flag.vue.d.ts.map +1 -1
- package/dist/components/IframeVue.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/Loading.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts +1 -1
- package/dist/components/Pill.vue.d.ts.map +1 -1
- package/dist/components/Zoomer.vue.d.ts.map +1 -1
- package/dist/components/analytics/LineChart.vue.d.ts.map +1 -1
- package/dist/components/analytics/PieChart.vue.d.ts +2 -1
- package/dist/components/analytics/PieChart.vue.d.ts.map +1 -1
- package/dist/components/analytics/index.d.ts +1 -1
- package/dist/components/analytics/index.d.ts.map +1 -1
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ColorInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/PasswordInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RangeInput.vue.d.ts +11 -11
- package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/TableGridSelector.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/commands.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.vue.d.ts +1 -0
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
- package/dist/components/layout/Layout.vue.d.ts.map +1 -1
- package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
- package/dist/components/layout/index.d.ts +3 -3
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/index.cjs +24 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4863 -4781
- package/dist/style.css +1 -1
- package/package.json +1 -2
- package/src/components/AccordionItem.vue +11 -11
- package/src/components/AddToCalendar.vue +1 -1
- package/src/components/AddressSearch.vue +9 -8
- package/src/components/Alert.vue +2 -1
- package/src/components/Badge.vue +5 -5
- package/src/components/BglVideo.vue +44 -45
- package/src/components/Btn.vue +15 -15
- package/src/components/Card.vue +10 -8
- package/src/components/Carousel.vue +159 -162
- package/src/components/DataPreview.vue +1 -1
- package/src/components/DragOver.vue +6 -6
- package/src/components/Dropdown.vue +39 -38
- package/src/components/Flag.vue +7 -6
- package/src/components/Icon/Icon.vue +22 -22
- package/src/components/IframeVue.vue +5 -5
- package/src/components/Image.vue +17 -17
- package/src/components/ImportData.vue +79 -79
- package/src/components/ListItem.vue +12 -11
- package/src/components/Loading.vue +10 -9
- package/src/components/MapEmbed/Index.vue +24 -24
- package/src/components/Modal.vue +11 -9
- package/src/components/ModalForm.vue +9 -8
- package/src/components/NavBar.vue +6 -6
- package/src/components/Pagination.vue +27 -27
- package/src/components/Pill.vue +11 -12
- package/src/components/Rating.vue +2 -2
- package/src/components/Slider.vue +75 -75
- package/src/components/Spreadsheet/Index.vue +34 -34
- package/src/components/Spreadsheet/SpreadsheetTable.vue +3 -3
- package/src/components/Zoomer.vue +165 -168
- package/src/components/analytics/BarChart.vue +6 -6
- package/src/components/analytics/KpiCard.vue +2 -2
- package/src/components/analytics/LineChart.vue +63 -61
- package/src/components/analytics/PieChart.vue +104 -90
- package/src/components/analytics/index.ts +2 -2
- package/src/components/calendar/CalendarPopover.vue +1 -1
- package/src/components/calendar/Index.vue +1 -1
- package/src/components/calendar/views/AgendaView.vue +3 -3
- package/src/components/calendar/views/DayView.vue +6 -6
- package/src/components/calendar/views/MonthView.vue +2 -2
- package/src/components/calendar/views/WeekView.vue +18 -18
- package/src/components/dataTable/DataTable.vue +4 -4
- package/src/components/dataTable/useSorting.ts +1 -1
- package/src/components/dataTable/useTableData.ts +15 -15
- package/src/components/dataTable/useTableSelection.ts +15 -15
- package/src/components/dataTable/useTableVirtualization.ts +1 -1
- package/src/components/draggable/useDraggable.ts +42 -42
- package/src/components/form/BagelForm.vue +15 -15
- package/src/components/form/BglFieldSet.vue +5 -3
- package/src/components/form/BglMultiStepForm.vue +20 -21
- package/src/components/form/inputs/CheckInput.vue +2 -2
- package/src/components/form/inputs/CodeEditor/format.ts +7 -7
- package/src/components/form/inputs/CodeEditor/useHighlight.ts +6 -6
- package/src/components/form/inputs/ColorInput.vue +5 -4
- package/src/components/form/inputs/DateInput.vue +8 -9
- package/src/components/form/inputs/DatePicker.vue +24 -24
- package/src/components/form/inputs/EmailInput.vue +24 -24
- package/src/components/form/inputs/NumberInput.vue +26 -26
- package/src/components/form/inputs/OTP.vue +7 -7
- package/src/components/form/inputs/PasswordInput.vue +3 -2
- package/src/components/form/inputs/RadioGroup.vue +28 -25
- package/src/components/form/inputs/RadioPillsInput.vue +12 -12
- package/src/components/form/inputs/RangeInput.vue +21 -21
- package/src/components/form/inputs/RichText/components/EditorToolbar.vue +107 -92
- package/src/components/form/inputs/RichText/components/TableGridSelector.vue +64 -64
- package/src/components/form/inputs/RichText/components/gridBox.vue +10 -8
- package/src/components/form/inputs/RichText/composables/useCommands.ts +1 -1
- package/src/components/form/inputs/RichText/composables/useEditor.ts +12 -12
- package/src/components/form/inputs/RichText/composables/useEditorKeyboard.ts +1 -1
- package/src/components/form/inputs/RichText/index.vue +138 -138
- package/src/components/form/inputs/RichText/utils/commands.ts +84 -85
- package/src/components/form/inputs/RichText/utils/debug.ts +1 -1
- package/src/components/form/inputs/RichText/utils/formatting.ts +39 -39
- package/src/components/form/inputs/RichText/utils/selection.ts +28 -28
- package/src/components/form/inputs/RichText/utils/table.ts +19 -19
- package/src/components/form/inputs/SelectBtn.vue +1 -1
- package/src/components/form/inputs/SelectInput.vue +54 -54
- package/src/components/form/inputs/SignaturePad.vue +40 -40
- package/src/components/form/inputs/TableField.vue +1 -1
- package/src/components/form/inputs/TelInput.vue +54 -53
- package/src/components/form/inputs/TextInput.vue +19 -19
- package/src/components/form/inputs/ToggleInput.vue +2 -2
- package/src/components/form/inputs/Upload/useFileUpload.ts +6 -6
- package/src/components/form/useBagelFormState.ts +5 -5
- package/src/components/layout/AppLayout.vue +2 -2
- package/src/components/layout/AppSidebar.vue +77 -16
- package/src/components/layout/Layout.vue +12 -10
- package/src/components/layout/SidebarMenu.vue +4 -4
- package/src/components/layout/TabbedLayout.vue +17 -17
- package/src/components/layout/Tabs.vue +4 -5
- package/src/components/layout/TabsNav.vue +14 -14
- package/src/components/layout/index.ts +3 -5
- package/src/components/lightbox/Lightbox.vue +22 -22
- package/src/components/lightbox/index.ts +8 -8
- package/src/composables/index.ts +8 -8
- package/src/composables/useAddToCalendar.ts +13 -13
- package/src/composables/useDevice.ts +2 -2
- package/src/composables/useFormField.ts +4 -4
- package/src/composables/usePolling.ts +8 -8
- package/src/composables/useSchemaField.ts +38 -38
- package/src/composables/useTheme.ts +9 -9
- package/src/composables/useValidateFieldValue.ts +2 -2
- package/src/directives/pattern.ts +25 -25
- package/src/directives/ripple.ts +4 -4
- package/src/directives/vResize.ts +6 -6
- package/src/index.ts +1 -0
- package/src/plugins/bagel.ts +4 -4
- package/src/styles/layout.css +1 -1
- package/src/types/index.ts +1 -1
- package/src/utils/BagelFormUtils.ts +7 -7
- package/src/utils/calendar/Helpers.ts +8 -8
- package/src/utils/calendar/dateUtils.ts +22 -22
- package/src/utils/calendar/time.ts +25 -25
- package/src/utils/calendar/week.ts +25 -25
- package/src/utils/elementUtils.ts +27 -27
- package/src/utils/sizeParsing.ts +2 -2
- package/src/utils/strings.ts +5 -5
- package/src/utils/tapDetector.ts +11 -11
- package/src/utils/useSearch.ts +29 -29
- package/vite.config.ts +0 -2
|
@@ -98,11 +98,11 @@ type ComputedConfig = Omit<Required<CarouselOptions>, 'autoplay'> & { autoplay:
|
|
|
98
98
|
|
|
99
99
|
// perPage calculation - independent of config
|
|
100
100
|
const perPage = computed(() => {
|
|
101
|
-
if (
|
|
101
|
+
if (typeof props.perPage === 'number') {
|
|
102
102
|
return props.perPage
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
if (
|
|
105
|
+
if (typeof props.perPage === 'object') {
|
|
106
106
|
return Object.entries(props.perPage)
|
|
107
107
|
.reduce((acc, [viewport, value]) => innerWidth.value >= Number(viewport) ? value : acc, 1)
|
|
108
108
|
}
|
|
@@ -116,7 +116,7 @@ const config = computed<ComputedConfig>(() => {
|
|
|
116
116
|
// Convert boolean autoplay values to string mode
|
|
117
117
|
let autoplayMode: AutoplayMode = 'disabled'
|
|
118
118
|
|
|
119
|
-
if (
|
|
119
|
+
if (typeof props.autoplay === 'boolean') {
|
|
120
120
|
autoplayMode = props.autoplay ? 'standard' : 'disabled'
|
|
121
121
|
} else {
|
|
122
122
|
autoplayMode = props.autoplay as AutoplayMode
|
|
@@ -149,7 +149,7 @@ const config = computed<ComputedConfig>(() => {
|
|
|
149
149
|
|
|
150
150
|
// Computed property for total number of dots to display
|
|
151
151
|
const totalDots = computed(() => {
|
|
152
|
-
if (!innerElements.value.length) {return 0}
|
|
152
|
+
if (!innerElements.value.length) { return 0 }
|
|
153
153
|
return config.value.loop ? innerElements.value.length : Math.ceil(innerElements.value.length - perPage.value + 1)
|
|
154
154
|
})
|
|
155
155
|
|
|
@@ -200,7 +200,7 @@ onUpdated(() => {
|
|
|
200
200
|
const slotElements = Array.from(slotContainer.value.children)
|
|
201
201
|
|
|
202
202
|
// Only update if count changed or first initialization
|
|
203
|
-
if (slotElements.length !== innerElements.value.length ||
|
|
203
|
+
if (slotElements.length !== innerElements.value.length || innerElements.value.length === 0) {
|
|
204
204
|
// Clone the elements from slot
|
|
205
205
|
innerElements.value = slotElements.map(el => el.cloneNode(true) as Element)
|
|
206
206
|
|
|
@@ -222,7 +222,7 @@ watch(() => props, () => {
|
|
|
222
222
|
// Helper functions
|
|
223
223
|
function webkitOrNot(): string {
|
|
224
224
|
const { style } = document.documentElement
|
|
225
|
-
if (
|
|
225
|
+
if (typeof style.transform === 'string') {
|
|
226
226
|
return 'transform'
|
|
227
227
|
}
|
|
228
228
|
return 'WebkitTransform'
|
|
@@ -257,7 +257,7 @@ function attachEvents(): void {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
// Add mouse enter/leave events for pauseOnHover functionality
|
|
260
|
-
if (
|
|
260
|
+
if (config.value.autoplay !== 'disabled' && config.value.pauseOnHover && carouselRef.value) {
|
|
261
261
|
carouselRef.value.addEventListener('mouseenter', mouseenterHandler)
|
|
262
262
|
carouselRef.value.addEventListener('mouseleave', mouseleaveAutoplayHandler)
|
|
263
263
|
}
|
|
@@ -283,7 +283,7 @@ function detachEvents(): void {
|
|
|
283
283
|
|
|
284
284
|
// Core functionality
|
|
285
285
|
async function init(): Promise<void> {
|
|
286
|
-
if (!carouselRef.value || !slotContainer.value || !isMounted.value) {return}
|
|
286
|
+
if (!carouselRef.value || !slotContainer.value || !isMounted.value) { return }
|
|
287
287
|
|
|
288
288
|
transformProperty.value = webkitOrNot()
|
|
289
289
|
|
|
@@ -323,7 +323,7 @@ async function init(): Promise<void> {
|
|
|
323
323
|
buildSliderFrame()
|
|
324
324
|
|
|
325
325
|
// Start autoplay if enabled
|
|
326
|
-
if (
|
|
326
|
+
if (config.value.autoplay !== 'disabled') {
|
|
327
327
|
startAutoplay()
|
|
328
328
|
}
|
|
329
329
|
|
|
@@ -332,7 +332,7 @@ async function init(): Promise<void> {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
function buildSliderFrame(): void {
|
|
335
|
-
if (!carouselRef.value || !isMounted.value) {return}
|
|
335
|
+
if (!carouselRef.value || !isMounted.value) { return }
|
|
336
336
|
|
|
337
337
|
// Set building flag to prevent interactions during rebuild
|
|
338
338
|
isBuilding.value = true
|
|
@@ -387,9 +387,9 @@ function buildSliderFrame(): void {
|
|
|
387
387
|
const docFragment = document.createDocumentFragment()
|
|
388
388
|
|
|
389
389
|
// Add clones before original items (for loop mode)
|
|
390
|
-
if (config.value.loop &&
|
|
390
|
+
if (config.value.loop && innerElements.value.length > 0) {
|
|
391
391
|
for (let i = originalCount - bufferSize; i < originalCount; i++) {
|
|
392
|
-
if (
|
|
392
|
+
if (i >= 0 && i < originalCount) {
|
|
393
393
|
const original = innerElements.value[i]
|
|
394
394
|
const clone = original.cloneNode(true) as Element
|
|
395
395
|
|
|
@@ -420,9 +420,9 @@ function buildSliderFrame(): void {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
// Add clones after original items (for loop mode)
|
|
423
|
-
if (config.value.loop &&
|
|
423
|
+
if (config.value.loop && innerElements.value.length > 0) {
|
|
424
424
|
for (let i = 0; i < bufferSize; i++) {
|
|
425
|
-
if (
|
|
425
|
+
if (i >= 0 && i < originalCount) {
|
|
426
426
|
const original = innerElements.value[i]
|
|
427
427
|
const clone = original.cloneNode(true) as Element
|
|
428
428
|
|
|
@@ -468,7 +468,7 @@ function copyAttributesAndEvents(original: Element, clone: Element): void {
|
|
|
468
468
|
const allAttrs = original.attributes
|
|
469
469
|
for (let i = 0; i < allAttrs.length; i++) {
|
|
470
470
|
const attr = allAttrs[i]
|
|
471
|
-
if ('id'
|
|
471
|
+
if (attr.name !== 'id') { // Skip id to avoid duplicate IDs
|
|
472
472
|
clone.setAttribute(attr.name, attr.value)
|
|
473
473
|
}
|
|
474
474
|
}
|
|
@@ -476,7 +476,7 @@ function copyAttributesAndEvents(original: Element, clone: Element): void {
|
|
|
476
476
|
// For Vue-specific elements, add a custom click handler that relays to the original
|
|
477
477
|
clone.addEventListener('click', (e) => {
|
|
478
478
|
// Check if original has a click handler
|
|
479
|
-
if (
|
|
479
|
+
if (typeof (original as any).click === 'function') {
|
|
480
480
|
// We need to simulate the click on the original element
|
|
481
481
|
// Create and dispatch a new click event on the original element
|
|
482
482
|
const clickEvent = new MouseEvent('click', {
|
|
@@ -492,7 +492,7 @@ function copyAttributesAndEvents(original: Element, clone: Element): void {
|
|
|
492
492
|
})
|
|
493
493
|
|
|
494
494
|
// Special handling for links
|
|
495
|
-
if (
|
|
495
|
+
if (original.tagName === 'A' && clone.tagName === 'A') {
|
|
496
496
|
const originalHref = original.getAttribute('href')
|
|
497
497
|
if (originalHref) {
|
|
498
498
|
clone.addEventListener('click', (e) => {
|
|
@@ -503,7 +503,7 @@ function copyAttributesAndEvents(original: Element, clone: Element): void {
|
|
|
503
503
|
original.onclick(new MouseEvent('click'))
|
|
504
504
|
} else {
|
|
505
505
|
// Default behavior - navigate like original link would
|
|
506
|
-
const targetBlank =
|
|
506
|
+
const targetBlank = original.getAttribute('target') === '_blank'
|
|
507
507
|
if (targetBlank) {
|
|
508
508
|
window.open(originalHref, '_blank')
|
|
509
509
|
} else {
|
|
@@ -541,7 +541,7 @@ function buildSliderFrameItem(elm: Element): HTMLElement {
|
|
|
541
541
|
function slideToCurrent(enableTransitionFlag?: boolean): void {
|
|
542
542
|
try {
|
|
543
543
|
// Ensure component is still mounted
|
|
544
|
-
if (!isMounted.value || !innerElements.value.length || !sliderFrame.value) {return}
|
|
544
|
+
if (!isMounted.value || !innerElements.value.length || !sliderFrame.value) { return }
|
|
545
545
|
|
|
546
546
|
// Ultra-aggressive buffer size - must match buildSliderFrame buffer size
|
|
547
547
|
const slideBufferSize = Math.max(perPage.value * 8, 20) // Even more buffer for huge screens
|
|
@@ -555,10 +555,10 @@ function slideToCurrent(enableTransitionFlag?: boolean): void {
|
|
|
555
555
|
// Use requestAnimationFrame for smooth transitions
|
|
556
556
|
requestAnimationFrame(() => {
|
|
557
557
|
// Check again that we're still mounted and have the frame
|
|
558
|
-
if (!isMounted.value || !sliderFrame.value) {return}
|
|
558
|
+
if (!isMounted.value || !sliderFrame.value) { return }
|
|
559
559
|
|
|
560
560
|
requestAnimationFrame(() => {
|
|
561
|
-
if (!isMounted.value || !sliderFrame.value) {return}
|
|
561
|
+
if (!isMounted.value || !sliderFrame.value) { return }
|
|
562
562
|
|
|
563
563
|
enableTransition()
|
|
564
564
|
sliderFrame.value.style[transformProperty.value as any] = `translate3d(${offset}px, 0, 0)`
|
|
@@ -573,12 +573,12 @@ function slideToCurrent(enableTransitionFlag?: boolean): void {
|
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
function prev(howManySlides: number = 1): void {
|
|
576
|
-
if (!isMounted.value || isBuilding.value || !innerElements.value.length) {return}
|
|
576
|
+
if (!isMounted.value || isBuilding.value || !innerElements.value.length) { return }
|
|
577
577
|
|
|
578
578
|
const beforeChange = currentSlide.value
|
|
579
579
|
|
|
580
580
|
if (config.value.loop) {
|
|
581
|
-
const isNewIndexClone =
|
|
581
|
+
const isNewIndexClone = currentSlide.value - howManySlides < 0
|
|
582
582
|
|
|
583
583
|
if (isNewIndexClone) {
|
|
584
584
|
disableTransition()
|
|
@@ -605,13 +605,13 @@ function prev(howManySlides: number = 1): void {
|
|
|
605
605
|
slideToCurrent(config.value.loop)
|
|
606
606
|
config.value.onChange()
|
|
607
607
|
}
|
|
608
|
-
if (
|
|
608
|
+
if (config.value.autoplay !== 'disabled') {
|
|
609
609
|
startAutoplay()
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
|
|
613
613
|
function next(howManySlides: number = 1): void {
|
|
614
|
-
if (!isMounted.value || isBuilding.value || !innerElements.value.length) {return}
|
|
614
|
+
if (!isMounted.value || isBuilding.value || !innerElements.value.length) { return }
|
|
615
615
|
|
|
616
616
|
const beforeChange = currentSlide.value
|
|
617
617
|
|
|
@@ -643,7 +643,7 @@ function next(howManySlides: number = 1): void {
|
|
|
643
643
|
slideToCurrent(config.value.loop)
|
|
644
644
|
config.value.onChange()
|
|
645
645
|
}
|
|
646
|
-
if (
|
|
646
|
+
if (config.value.autoplay !== 'disabled') {
|
|
647
647
|
startAutoplay()
|
|
648
648
|
}
|
|
649
649
|
}
|
|
@@ -680,7 +680,7 @@ function enableTransition(): void {
|
|
|
680
680
|
}
|
|
681
681
|
|
|
682
682
|
function updateAfterDrag(): void {
|
|
683
|
-
if (!isMounted.value) {return}
|
|
683
|
+
if (!isMounted.value) { return }
|
|
684
684
|
|
|
685
685
|
const movement = (config.value.rtl ? -1 : 1) * (drag.value.endX - drag.value.startX)
|
|
686
686
|
const movementDistance = Math.abs(movement)
|
|
@@ -688,13 +688,13 @@ function updateAfterDrag(): void {
|
|
|
688
688
|
? Math.ceil(movementDistance / (selectorWidth.value / perPage.value))
|
|
689
689
|
: 1
|
|
690
690
|
|
|
691
|
-
const slideToNegativeClone =
|
|
692
|
-
const slideToPositiveClone =
|
|
691
|
+
const slideToNegativeClone = movement > 0 && currentSlide.value - howManySliderToSlide < 0
|
|
692
|
+
const slideToPositiveClone = movement < 0
|
|
693
693
|
&& currentSlide.value + howManySliderToSlide > innerElements.value.length - perPage.value
|
|
694
694
|
|
|
695
|
-
if (
|
|
695
|
+
if (movement > 0 && movementDistance > config.value.threshold && innerElements.value.length > perPage.value) {
|
|
696
696
|
prev(howManySliderToSlide)
|
|
697
|
-
} else if (
|
|
697
|
+
} else if (movement < 0
|
|
698
698
|
&& movementDistance > config.value.threshold
|
|
699
699
|
&& innerElements.value.length > perPage.value) {
|
|
700
700
|
next(howManySliderToSlide)
|
|
@@ -730,7 +730,7 @@ function clearDrag(): void {
|
|
|
730
730
|
|
|
731
731
|
// Touch event handlers
|
|
732
732
|
function touchstartHandler(e: TouchEvent): void {
|
|
733
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
733
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
734
734
|
|
|
735
735
|
const target = e.target as HTMLElement
|
|
736
736
|
const ignoreTags = ['TEXTAREA', 'OPTION', 'INPUT', 'SELECT'].includes(target.nodeName)
|
|
@@ -749,17 +749,17 @@ function touchstartHandler(e: TouchEvent): void {
|
|
|
749
749
|
drag.value.startY = e.touches[0].pageY
|
|
750
750
|
|
|
751
751
|
// Mark link-related elements for potential preventClick
|
|
752
|
-
const isLink = 'A'
|
|
753
|
-
const isImage = 'IMG'
|
|
752
|
+
const isLink = target.tagName === 'A' || target.closest('a')
|
|
753
|
+
const isImage = target.tagName === 'IMG'
|
|
754
754
|
if (isLink || isImage) {
|
|
755
755
|
drag.value.preventClick = false
|
|
756
756
|
}
|
|
757
757
|
|
|
758
758
|
// When starting drag during linear autoplay, save the current position
|
|
759
|
-
if (
|
|
759
|
+
if (config.value.autoplay === 'linear' && sliderFrame.value) {
|
|
760
760
|
// Get the current transform value and save it to apply during dragging
|
|
761
761
|
const currentTransform = getComputedStyle(sliderFrame.value)[transformProperty.value as any]
|
|
762
|
-
if (currentTransform && 'none'
|
|
762
|
+
if (currentTransform && currentTransform !== 'none') {
|
|
763
763
|
try {
|
|
764
764
|
// Parse the transform matrix to get the current X position
|
|
765
765
|
const matrix = new DOMMatrix(currentTransform)
|
|
@@ -771,7 +771,7 @@ function touchstartHandler(e: TouchEvent): void {
|
|
|
771
771
|
// Adjust for the perPage offset in loop mode
|
|
772
772
|
const totalPosition = Math.abs(currentX)
|
|
773
773
|
const slidePosition = Math.round(totalPosition / itemWidth) - perPage.value
|
|
774
|
-
currentSlide.value =
|
|
774
|
+
currentSlide.value = slidePosition >= 0
|
|
775
775
|
? slidePosition % innerElements.value.length
|
|
776
776
|
: (innerElements.value.length + (slidePosition % innerElements.value.length)) % innerElements.value.length
|
|
777
777
|
} else {
|
|
@@ -790,7 +790,7 @@ function touchstartHandler(e: TouchEvent): void {
|
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
function touchendHandler(e: TouchEvent): void {
|
|
793
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
793
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
794
794
|
|
|
795
795
|
e.stopPropagation()
|
|
796
796
|
|
|
@@ -818,17 +818,17 @@ function touchendHandler(e: TouchEvent): void {
|
|
|
818
818
|
clearDrag()
|
|
819
819
|
|
|
820
820
|
// Restart autoplay after touch interaction
|
|
821
|
-
if (
|
|
821
|
+
if (config.value.autoplay !== 'disabled' && !isHovering.value && isMounted.value) {
|
|
822
822
|
startAutoplay()
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
|
|
826
826
|
function touchmoveHandler(e: TouchEvent): void {
|
|
827
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
827
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
828
828
|
|
|
829
829
|
e.stopPropagation()
|
|
830
830
|
|
|
831
|
-
if (
|
|
831
|
+
if (drag.value.letItGo === null) {
|
|
832
832
|
drag.value.letItGo = Math.abs(drag.value.startY - e.touches[0].pageY)
|
|
833
833
|
< Math.abs(drag.value.startX - e.touches[0].pageX)
|
|
834
834
|
}
|
|
@@ -867,12 +867,12 @@ function touchmoveHandler(e: TouchEvent): void {
|
|
|
867
867
|
|
|
868
868
|
// Mouse event handlers
|
|
869
869
|
function mousedownHandler(e: MouseEvent): void {
|
|
870
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
870
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
871
871
|
|
|
872
872
|
const target = e.target as HTMLElement
|
|
873
873
|
const ignoreTags = ['TEXTAREA', 'OPTION', 'INPUT', 'SELECT'].includes(target.nodeName)
|
|
874
874
|
|
|
875
|
-
if (ignoreTags) {return}
|
|
875
|
+
if (ignoreTags) { return }
|
|
876
876
|
|
|
877
877
|
// Pause autoplay during mouse interaction
|
|
878
878
|
stopAutoplay()
|
|
@@ -884,17 +884,17 @@ function mousedownHandler(e: MouseEvent): void {
|
|
|
884
884
|
drag.value.startX = e.pageX
|
|
885
885
|
|
|
886
886
|
// Mark link-related elements for potential preventClick
|
|
887
|
-
const isLink = 'A'
|
|
888
|
-
const isImage = 'IMG'
|
|
887
|
+
const isLink = target.tagName === 'A' || target.closest('a')
|
|
888
|
+
const isImage = target.tagName === 'IMG'
|
|
889
889
|
if (isLink || isImage) {
|
|
890
890
|
drag.value.preventClick = false // Start with false, will be set to true if actual dragging occurs
|
|
891
891
|
}
|
|
892
892
|
|
|
893
893
|
// When starting drag during linear autoplay, save the current position
|
|
894
|
-
if (
|
|
894
|
+
if (config.value.autoplay === 'linear' && sliderFrame.value) {
|
|
895
895
|
// Get the current transform value and save it to apply during dragging
|
|
896
896
|
const currentTransform = getComputedStyle(sliderFrame.value)[transformProperty.value as any]
|
|
897
|
-
if (currentTransform && 'none'
|
|
897
|
+
if (currentTransform && currentTransform !== 'none') {
|
|
898
898
|
try {
|
|
899
899
|
// Parse the transform matrix to get the current X position
|
|
900
900
|
const matrix = new DOMMatrix(currentTransform)
|
|
@@ -906,7 +906,7 @@ function mousedownHandler(e: MouseEvent): void {
|
|
|
906
906
|
// Adjust for the perPage offset in loop mode
|
|
907
907
|
const totalPosition = Math.abs(currentX)
|
|
908
908
|
const slidePosition = Math.round(totalPosition / itemWidth) - perPage.value
|
|
909
|
-
currentSlide.value =
|
|
909
|
+
currentSlide.value = slidePosition >= 0
|
|
910
910
|
? slidePosition % innerElements.value.length
|
|
911
911
|
: (innerElements.value.length + (slidePosition % innerElements.value.length)) % innerElements.value.length
|
|
912
912
|
} else {
|
|
@@ -925,7 +925,7 @@ function mousedownHandler(e: MouseEvent): void {
|
|
|
925
925
|
}
|
|
926
926
|
|
|
927
927
|
function mouseupHandler(e: MouseEvent): void {
|
|
928
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
928
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
929
929
|
|
|
930
930
|
e.stopPropagation()
|
|
931
931
|
|
|
@@ -958,13 +958,13 @@ function mouseupHandler(e: MouseEvent): void {
|
|
|
958
958
|
clearDrag()
|
|
959
959
|
|
|
960
960
|
// Restart autoplay after mouse interaction if not hovering
|
|
961
|
-
if (
|
|
961
|
+
if (config.value.autoplay !== 'disabled' && !isHovering.value && isMounted.value) {
|
|
962
962
|
startAutoplay()
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
965
|
|
|
966
966
|
function mousemoveHandler(e: MouseEvent): void {
|
|
967
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
967
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
968
968
|
|
|
969
969
|
e.preventDefault()
|
|
970
970
|
|
|
@@ -1004,7 +1004,7 @@ function mousemoveHandler(e: MouseEvent): void {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
|
|
1006
1006
|
function mouseleaveHandler(e: MouseEvent): void {
|
|
1007
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
1007
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
1008
1008
|
|
|
1009
1009
|
if (pointerDown.value) {
|
|
1010
1010
|
pointerDown.value = false
|
|
@@ -1022,7 +1022,7 @@ function mouseleaveHandler(e: MouseEvent): void {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
|
|
1024
1024
|
function clickHandler(e: MouseEvent): void {
|
|
1025
|
-
if (isBuilding.value || !isMounted.value) {return}
|
|
1025
|
+
if (isBuilding.value || !isMounted.value) { return }
|
|
1026
1026
|
|
|
1027
1027
|
if (drag.value.preventClick || isDragging.value) {
|
|
1028
1028
|
e.preventDefault()
|
|
@@ -1036,14 +1036,14 @@ function clickHandler(e: MouseEvent): void {
|
|
|
1036
1036
|
|
|
1037
1037
|
// Add this new function to handle dragstart events
|
|
1038
1038
|
function dragstartHandler(e: DragEvent): void {
|
|
1039
|
-
if (isBuilding.value || !isMounted.value) {return} // Prevent interaction during build
|
|
1039
|
+
if (isBuilding.value || !isMounted.value) { return } // Prevent interaction during build
|
|
1040
1040
|
|
|
1041
1041
|
// Prevent default drag behavior for images and links
|
|
1042
1042
|
if (config.value.draggable) {
|
|
1043
1043
|
const target = e.target as HTMLElement
|
|
1044
|
-
const isDraggableElement = 'IMG'
|
|
1045
|
-
|| 'A'
|
|
1046
|
-
||
|
|
1044
|
+
const isDraggableElement = target.tagName === 'IMG'
|
|
1045
|
+
|| target.tagName === 'A'
|
|
1046
|
+
|| target.parentElement?.tagName === 'A'
|
|
1047
1047
|
|
|
1048
1048
|
if (isDraggableElement) {
|
|
1049
1049
|
e.preventDefault()
|
|
@@ -1053,7 +1053,7 @@ function dragstartHandler(e: DragEvent): void {
|
|
|
1053
1053
|
|
|
1054
1054
|
// Public API
|
|
1055
1055
|
function remove(index: number): void {
|
|
1056
|
-
if (
|
|
1056
|
+
if (index < 0 || index >= innerElements.value.length) {
|
|
1057
1057
|
throw new Error('Item to remove doesn\'t exist 😭')
|
|
1058
1058
|
}
|
|
1059
1059
|
|
|
@@ -1070,7 +1070,7 @@ function remove(index: number): void {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
|
|
1072
1072
|
function insert(item: Element, index: number): void {
|
|
1073
|
-
if (
|
|
1073
|
+
if (index < 0 || index > innerElements.value.length + 1) {
|
|
1074
1074
|
throw new Error('Unable to insert at this index 😭')
|
|
1075
1075
|
}
|
|
1076
1076
|
|
|
@@ -1079,7 +1079,7 @@ function insert(item: Element, index: number): void {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
|
|
1081
1081
|
// Avoid shifting content
|
|
1082
|
-
const shouldItShift = index <= currentSlide.value &&
|
|
1082
|
+
const shouldItShift = index <= currentSlide.value && innerElements.value.length > 0
|
|
1083
1083
|
|
|
1084
1084
|
if (shouldItShift) {
|
|
1085
1085
|
currentSlide.value++
|
|
@@ -1119,36 +1119,36 @@ function destroy(restoreMarkup: boolean = false): void {
|
|
|
1119
1119
|
|
|
1120
1120
|
// Add after init()
|
|
1121
1121
|
async function startAutoplay(): Promise<void> {
|
|
1122
|
-
if (!isMounted.value) {return} // Don't start if not mounted
|
|
1122
|
+
if (!isMounted.value) { return } // Don't start if not mounted
|
|
1123
1123
|
|
|
1124
1124
|
stopAutoplay() // Clear any existing timers first
|
|
1125
1125
|
|
|
1126
|
-
if (
|
|
1126
|
+
if (config.value.autoplay === 'standard') {
|
|
1127
1127
|
autoplayTimer.value = window.setInterval(() => {
|
|
1128
1128
|
// Check if component is still mounted before advancing
|
|
1129
1129
|
if (isMounted.value && !isHovering.value && !isBuilding.value) {
|
|
1130
1130
|
next()
|
|
1131
1131
|
}
|
|
1132
1132
|
}, config.value.autoplayInterval)
|
|
1133
|
-
} else if (
|
|
1133
|
+
} else if (config.value.autoplay === 'linear') {
|
|
1134
1134
|
startLinearAutoplay()
|
|
1135
1135
|
}
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
function stopAutoplay(): void {
|
|
1139
|
-
if (
|
|
1139
|
+
if (autoplayTimer.value !== null) {
|
|
1140
1140
|
clearInterval(autoplayTimer.value)
|
|
1141
1141
|
autoplayTimer.value = null
|
|
1142
1142
|
}
|
|
1143
1143
|
|
|
1144
|
-
if (
|
|
1144
|
+
if (linearAnimationFrame.value !== null) {
|
|
1145
1145
|
cancelAnimationFrame(linearAnimationFrame.value)
|
|
1146
1146
|
linearAnimationFrame.value = null
|
|
1147
1147
|
}
|
|
1148
1148
|
}
|
|
1149
1149
|
|
|
1150
1150
|
function startLinearAutoplay(): void {
|
|
1151
|
-
if (!isMounted.value || !innerElements.value.length) {return}
|
|
1151
|
+
if (!isMounted.value || !innerElements.value.length) { return }
|
|
1152
1152
|
|
|
1153
1153
|
// Reset the linear offset to the current slide position
|
|
1154
1154
|
const itemWidth = selectorWidth.value / perPage.value
|
|
@@ -1163,7 +1163,7 @@ function startLinearAutoplay(): void {
|
|
|
1163
1163
|
return
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
|
-
if (!lastTimestamp) {lastTimestamp = timestamp}
|
|
1166
|
+
if (!lastTimestamp) { lastTimestamp = timestamp }
|
|
1167
1167
|
|
|
1168
1168
|
// Calculate time delta and convert to pixels based on speed
|
|
1169
1169
|
const elapsed = timestamp - lastTimestamp
|
|
@@ -1242,14 +1242,14 @@ function pauseAutoplay(): void {
|
|
|
1242
1242
|
}
|
|
1243
1243
|
|
|
1244
1244
|
function resumeAutoplay(): void {
|
|
1245
|
-
if (
|
|
1245
|
+
if (config.value.autoplay !== 'disabled') {
|
|
1246
1246
|
startAutoplay()
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
1249
|
|
|
1250
1250
|
// Add function to set up the MutationObserver
|
|
1251
1251
|
function setupSlotObserver(): void {
|
|
1252
|
-
if (!slotContainer.value || slotObserver.value) {return}
|
|
1252
|
+
if (!slotContainer.value || slotObserver.value) { return }
|
|
1253
1253
|
|
|
1254
1254
|
// Create a new MutationObserver
|
|
1255
1255
|
slotObserver.value = new MutationObserver((mutations) => {
|
|
@@ -1262,7 +1262,7 @@ function setupSlotObserver(): void {
|
|
|
1262
1262
|
let needsRebuild = false
|
|
1263
1263
|
|
|
1264
1264
|
for (const mutation of mutations) {
|
|
1265
|
-
if ('childList'
|
|
1265
|
+
if (mutation.type === 'childList') {
|
|
1266
1266
|
needsRebuild = true
|
|
1267
1267
|
break
|
|
1268
1268
|
}
|
|
@@ -1293,7 +1293,7 @@ function setupSlotObserver(): void {
|
|
|
1293
1293
|
|
|
1294
1294
|
// Modify updateSlider to safely handle DOM references and always use slotContainer
|
|
1295
1295
|
function updateSlider(): void {
|
|
1296
|
-
if (!carouselRef.value || !slotContainer.value || isBuilding.value || !isMounted.value) {return}
|
|
1296
|
+
if (!carouselRef.value || !slotContainer.value || isBuilding.value || !isMounted.value) { return }
|
|
1297
1297
|
|
|
1298
1298
|
// Prevent too many empty rebuild attempts
|
|
1299
1299
|
if (emptyRebuildAttempts.value >= MAX_EMPTY_REBUILD_ATTEMPTS) {
|
|
@@ -1312,7 +1312,7 @@ function updateSlider(): void {
|
|
|
1312
1312
|
.map(el => el.cloneNode(true) as Element)
|
|
1313
1313
|
|
|
1314
1314
|
// Only proceed if we have elements to work with or if we need to clear for the first time
|
|
1315
|
-
if (
|
|
1315
|
+
if (slotElements.length > 0 || (innerElements.value.length > 0 && emptyRebuildAttempts.value === 0)) {
|
|
1316
1316
|
// Update elements with clones of slot content
|
|
1317
1317
|
innerElements.value = slotElements
|
|
1318
1318
|
|
|
@@ -1321,7 +1321,7 @@ function updateSlider(): void {
|
|
|
1321
1321
|
currentSlide.value = Math.max(0, innerElements.value.length - 1)
|
|
1322
1322
|
}
|
|
1323
1323
|
// Stop autoplay during rebuild to prevent errors
|
|
1324
|
-
const wasAutoplay =
|
|
1324
|
+
const wasAutoplay = config.value.autoplay !== 'disabled'
|
|
1325
1325
|
if (wasAutoplay) {
|
|
1326
1326
|
stopAutoplay()
|
|
1327
1327
|
}
|
|
@@ -1330,7 +1330,7 @@ function updateSlider(): void {
|
|
|
1330
1330
|
buildSliderFrame()
|
|
1331
1331
|
|
|
1332
1332
|
// Resume autoplay if it was active and not hovering
|
|
1333
|
-
if (wasAutoplay && !isHovering.value &&
|
|
1333
|
+
if (wasAutoplay && !isHovering.value && innerElements.value.length > 0) {
|
|
1334
1334
|
// Small delay for stability
|
|
1335
1335
|
setTimeout(() => {
|
|
1336
1336
|
startAutoplay()
|
|
@@ -1362,7 +1362,7 @@ function resetSlider(): void {
|
|
|
1362
1362
|
const slotElements = Array.from(slotContainer.value.children)
|
|
1363
1363
|
.map(el => el.cloneNode(true) as Element)
|
|
1364
1364
|
|
|
1365
|
-
if (
|
|
1365
|
+
if (slotElements.length > 0) {
|
|
1366
1366
|
// We have content now, rebuild
|
|
1367
1367
|
innerElements.value = slotElements
|
|
1368
1368
|
nextTick(() => { buildSliderFrame() })
|