@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.
Files changed (167) hide show
  1. package/bin/experimentalGenTypedRoutes.ts +18 -19
  2. package/bin/utils.ts +4 -4
  3. package/dist/components/AddressSearch.vue.d.ts.map +1 -1
  4. package/dist/components/Alert.vue.d.ts.map +1 -1
  5. package/dist/components/BglVideo.vue.d.ts.map +1 -1
  6. package/dist/components/Card.vue.d.ts.map +1 -1
  7. package/dist/components/Carousel.vue.d.ts +2 -2
  8. package/dist/components/Carousel.vue.d.ts.map +1 -1
  9. package/dist/components/Dropdown.vue.d.ts.map +1 -1
  10. package/dist/components/Flag.vue.d.ts.map +1 -1
  11. package/dist/components/IframeVue.vue.d.ts.map +1 -1
  12. package/dist/components/ListItem.vue.d.ts.map +1 -1
  13. package/dist/components/Loading.vue.d.ts.map +1 -1
  14. package/dist/components/Modal.vue.d.ts.map +1 -1
  15. package/dist/components/ModalForm.vue.d.ts.map +1 -1
  16. package/dist/components/NavBar.vue.d.ts +1 -1
  17. package/dist/components/Pill.vue.d.ts.map +1 -1
  18. package/dist/components/Zoomer.vue.d.ts.map +1 -1
  19. package/dist/components/analytics/LineChart.vue.d.ts.map +1 -1
  20. package/dist/components/analytics/PieChart.vue.d.ts +2 -1
  21. package/dist/components/analytics/PieChart.vue.d.ts.map +1 -1
  22. package/dist/components/analytics/index.d.ts +1 -1
  23. package/dist/components/analytics/index.d.ts.map +1 -1
  24. package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
  25. package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
  26. package/dist/components/form/inputs/ColorInput.vue.d.ts.map +1 -1
  27. package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
  28. package/dist/components/form/inputs/PasswordInput.vue.d.ts.map +1 -1
  29. package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
  30. package/dist/components/form/inputs/RangeInput.vue.d.ts +11 -11
  31. package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts.map +1 -1
  32. package/dist/components/form/inputs/RichText/components/TableGridSelector.vue.d.ts.map +1 -1
  33. package/dist/components/form/inputs/RichText/utils/commands.d.ts.map +1 -1
  34. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  35. package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
  36. package/dist/components/layout/AppSidebar.vue.d.ts +1 -0
  37. package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
  38. package/dist/components/layout/Layout.vue.d.ts.map +1 -1
  39. package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
  40. package/dist/components/layout/index.d.ts +3 -3
  41. package/dist/components/layout/index.d.ts.map +1 -1
  42. package/dist/index.cjs +24 -15
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.mjs +4863 -4781
  46. package/dist/style.css +1 -1
  47. package/package.json +1 -2
  48. package/src/components/AccordionItem.vue +11 -11
  49. package/src/components/AddToCalendar.vue +1 -1
  50. package/src/components/AddressSearch.vue +9 -8
  51. package/src/components/Alert.vue +2 -1
  52. package/src/components/Badge.vue +5 -5
  53. package/src/components/BglVideo.vue +44 -45
  54. package/src/components/Btn.vue +15 -15
  55. package/src/components/Card.vue +10 -8
  56. package/src/components/Carousel.vue +159 -162
  57. package/src/components/DataPreview.vue +1 -1
  58. package/src/components/DragOver.vue +6 -6
  59. package/src/components/Dropdown.vue +39 -38
  60. package/src/components/Flag.vue +7 -6
  61. package/src/components/Icon/Icon.vue +22 -22
  62. package/src/components/IframeVue.vue +5 -5
  63. package/src/components/Image.vue +17 -17
  64. package/src/components/ImportData.vue +79 -79
  65. package/src/components/ListItem.vue +12 -11
  66. package/src/components/Loading.vue +10 -9
  67. package/src/components/MapEmbed/Index.vue +24 -24
  68. package/src/components/Modal.vue +11 -9
  69. package/src/components/ModalForm.vue +9 -8
  70. package/src/components/NavBar.vue +6 -6
  71. package/src/components/Pagination.vue +27 -27
  72. package/src/components/Pill.vue +11 -12
  73. package/src/components/Rating.vue +2 -2
  74. package/src/components/Slider.vue +75 -75
  75. package/src/components/Spreadsheet/Index.vue +34 -34
  76. package/src/components/Spreadsheet/SpreadsheetTable.vue +3 -3
  77. package/src/components/Zoomer.vue +165 -168
  78. package/src/components/analytics/BarChart.vue +6 -6
  79. package/src/components/analytics/KpiCard.vue +2 -2
  80. package/src/components/analytics/LineChart.vue +63 -61
  81. package/src/components/analytics/PieChart.vue +104 -90
  82. package/src/components/analytics/index.ts +2 -2
  83. package/src/components/calendar/CalendarPopover.vue +1 -1
  84. package/src/components/calendar/Index.vue +1 -1
  85. package/src/components/calendar/views/AgendaView.vue +3 -3
  86. package/src/components/calendar/views/DayView.vue +6 -6
  87. package/src/components/calendar/views/MonthView.vue +2 -2
  88. package/src/components/calendar/views/WeekView.vue +18 -18
  89. package/src/components/dataTable/DataTable.vue +4 -4
  90. package/src/components/dataTable/useSorting.ts +1 -1
  91. package/src/components/dataTable/useTableData.ts +15 -15
  92. package/src/components/dataTable/useTableSelection.ts +15 -15
  93. package/src/components/dataTable/useTableVirtualization.ts +1 -1
  94. package/src/components/draggable/useDraggable.ts +42 -42
  95. package/src/components/form/BagelForm.vue +15 -15
  96. package/src/components/form/BglFieldSet.vue +5 -3
  97. package/src/components/form/BglMultiStepForm.vue +20 -21
  98. package/src/components/form/inputs/CheckInput.vue +2 -2
  99. package/src/components/form/inputs/CodeEditor/format.ts +7 -7
  100. package/src/components/form/inputs/CodeEditor/useHighlight.ts +6 -6
  101. package/src/components/form/inputs/ColorInput.vue +5 -4
  102. package/src/components/form/inputs/DateInput.vue +8 -9
  103. package/src/components/form/inputs/DatePicker.vue +24 -24
  104. package/src/components/form/inputs/EmailInput.vue +24 -24
  105. package/src/components/form/inputs/NumberInput.vue +26 -26
  106. package/src/components/form/inputs/OTP.vue +7 -7
  107. package/src/components/form/inputs/PasswordInput.vue +3 -2
  108. package/src/components/form/inputs/RadioGroup.vue +28 -25
  109. package/src/components/form/inputs/RadioPillsInput.vue +12 -12
  110. package/src/components/form/inputs/RangeInput.vue +21 -21
  111. package/src/components/form/inputs/RichText/components/EditorToolbar.vue +107 -92
  112. package/src/components/form/inputs/RichText/components/TableGridSelector.vue +64 -64
  113. package/src/components/form/inputs/RichText/components/gridBox.vue +10 -8
  114. package/src/components/form/inputs/RichText/composables/useCommands.ts +1 -1
  115. package/src/components/form/inputs/RichText/composables/useEditor.ts +12 -12
  116. package/src/components/form/inputs/RichText/composables/useEditorKeyboard.ts +1 -1
  117. package/src/components/form/inputs/RichText/index.vue +138 -138
  118. package/src/components/form/inputs/RichText/utils/commands.ts +84 -85
  119. package/src/components/form/inputs/RichText/utils/debug.ts +1 -1
  120. package/src/components/form/inputs/RichText/utils/formatting.ts +39 -39
  121. package/src/components/form/inputs/RichText/utils/selection.ts +28 -28
  122. package/src/components/form/inputs/RichText/utils/table.ts +19 -19
  123. package/src/components/form/inputs/SelectBtn.vue +1 -1
  124. package/src/components/form/inputs/SelectInput.vue +54 -54
  125. package/src/components/form/inputs/SignaturePad.vue +40 -40
  126. package/src/components/form/inputs/TableField.vue +1 -1
  127. package/src/components/form/inputs/TelInput.vue +54 -53
  128. package/src/components/form/inputs/TextInput.vue +19 -19
  129. package/src/components/form/inputs/ToggleInput.vue +2 -2
  130. package/src/components/form/inputs/Upload/useFileUpload.ts +6 -6
  131. package/src/components/form/useBagelFormState.ts +5 -5
  132. package/src/components/layout/AppLayout.vue +2 -2
  133. package/src/components/layout/AppSidebar.vue +77 -16
  134. package/src/components/layout/Layout.vue +12 -10
  135. package/src/components/layout/SidebarMenu.vue +4 -4
  136. package/src/components/layout/TabbedLayout.vue +17 -17
  137. package/src/components/layout/Tabs.vue +4 -5
  138. package/src/components/layout/TabsNav.vue +14 -14
  139. package/src/components/layout/index.ts +3 -5
  140. package/src/components/lightbox/Lightbox.vue +22 -22
  141. package/src/components/lightbox/index.ts +8 -8
  142. package/src/composables/index.ts +8 -8
  143. package/src/composables/useAddToCalendar.ts +13 -13
  144. package/src/composables/useDevice.ts +2 -2
  145. package/src/composables/useFormField.ts +4 -4
  146. package/src/composables/usePolling.ts +8 -8
  147. package/src/composables/useSchemaField.ts +38 -38
  148. package/src/composables/useTheme.ts +9 -9
  149. package/src/composables/useValidateFieldValue.ts +2 -2
  150. package/src/directives/pattern.ts +25 -25
  151. package/src/directives/ripple.ts +4 -4
  152. package/src/directives/vResize.ts +6 -6
  153. package/src/index.ts +1 -0
  154. package/src/plugins/bagel.ts +4 -4
  155. package/src/styles/layout.css +1 -1
  156. package/src/types/index.ts +1 -1
  157. package/src/utils/BagelFormUtils.ts +7 -7
  158. package/src/utils/calendar/Helpers.ts +8 -8
  159. package/src/utils/calendar/dateUtils.ts +22 -22
  160. package/src/utils/calendar/time.ts +25 -25
  161. package/src/utils/calendar/week.ts +25 -25
  162. package/src/utils/elementUtils.ts +27 -27
  163. package/src/utils/sizeParsing.ts +2 -2
  164. package/src/utils/strings.ts +5 -5
  165. package/src/utils/tapDetector.ts +11 -11
  166. package/src/utils/useSearch.ts +29 -29
  167. package/vite.config.ts +0 -2
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { nextTick, onMounted, onUnmounted, watch } from 'vue'
2
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
3
3
 
4
4
  const props = defineProps({
5
5
  autoHeight: { type: Boolean, default: false },
@@ -37,23 +37,23 @@ const THRESHOLDS = {
37
37
  const GAP_PERCENT = 1
38
38
 
39
39
  // Template refs and state
40
- const bglSlider = $ref<HTMLElement | undefined>()
41
- const isSliderAvailable = $computed(() => !!bglSlider)
40
+ const bglSlider = ref<HTMLElement | undefined>()
41
+ const isSliderAvailable = computed(() => !!bglSlider.value)
42
42
 
43
- let itemCount = $ref(props.items)
44
- let activeSlideIndex = $ref(props.index)
45
- let slideCount = $ref(0)
46
- let yHeight = $ref('auto')
43
+ const itemCount = ref(props.items)
44
+ const activeSlideIndex = ref(props.index)
45
+ const slideCount = ref(0)
46
+ const yHeight = ref('auto')
47
47
 
48
48
  // Interaction state
49
- let isDragging = $ref(false)
50
- let isPressed = $ref(false)
51
- let startX = $ref(0)
52
- let startY = $ref(0)
53
- let translateX = $ref(0)
54
- let lastX = $ref(0)
55
- let lastTime = $ref(0)
56
- let accumulatedDeltaX = $ref(0)
49
+ const isDragging = ref(false)
50
+ const isPressed = ref(false)
51
+ const startX = ref(0)
52
+ const startY = ref(0)
53
+ const translateX = ref(0)
54
+ const lastX = ref(0)
55
+ const lastTime = ref(0)
56
+ const accumulatedDeltaX = ref(0)
57
57
 
58
58
  let timeout: NodeJS.Timeout | undefined
59
59
  let wheelTimeout: NodeJS.Timeout | undefined
@@ -65,19 +65,19 @@ interface VelocitySample {
65
65
  position: number
66
66
  }
67
67
 
68
- let velocityTracker = $ref<VelocitySample[]>([])
68
+ const velocityTracker = ref<VelocitySample[]>([])
69
69
  const VELOCITY_SAMPLE_DURATION = 100 // ms to track velocity
70
70
 
71
71
  function getAverageVelocity(): number {
72
- if (velocityTracker.length < 2) { return 0 }
72
+ if (velocityTracker.value.length < 2) { return 0 }
73
73
 
74
74
  const now = Date.now()
75
75
  // Only consider samples within our sample duration
76
- const recentSamples = velocityTracker.filter((sample: VelocitySample) => now - sample.time < VELOCITY_SAMPLE_DURATION)
76
+ const recentSamples = velocityTracker.value.filter((sample: VelocitySample) => now - sample.time < VELOCITY_SAMPLE_DURATION)
77
77
 
78
78
  if (recentSamples.length < 2) { return 0 }
79
79
 
80
- const first = recentSamples[0]
80
+ const [first] = recentSamples
81
81
  const last = recentSamples[recentSamples.length - 1]
82
82
  const timeDelta = last.time - first.time
83
83
 
@@ -88,16 +88,16 @@ function getAverageVelocity(): number {
88
88
 
89
89
  // Transform helpers
90
90
  function getCurrentTransform(): number {
91
- if (!bglSlider) { return 0 }
92
- const { transform } = bglSlider.style
93
- const value = transform ? Number.parseInt(transform.replace(/[^-\d.]/g, '')) : 0
91
+ if (!bglSlider.value) { return 0 }
92
+ const { transform } = bglSlider.value.style
93
+ const value = transform ? Number.parseInt(transform.replace(/[^-\d.]/g, ''), 10) : 0
94
94
  return props.rtl ? -value : value
95
95
  }
96
96
 
97
97
  function setTransform(value: number) {
98
- if (!bglSlider) { return }
98
+ if (!bglSlider.value) { return }
99
99
  const rtlValue = props.rtl ? -value : value
100
- bglSlider.style.transform = `translateX(${rtlValue}px)`
100
+ bglSlider.value.style.transform = `translateX(${rtlValue}px)`
101
101
  }
102
102
 
103
103
  function easeInOutQuad(t: number) {
@@ -108,7 +108,7 @@ function animateTransform(start: number, end: number, duration: number) {
108
108
  const startTime = performance.now()
109
109
 
110
110
  function animate(currentTime: number) {
111
- if (!isSliderAvailable) { return }
111
+ if (!isSliderAvailable.value) { return }
112
112
  const timeElapsed = currentTime - startTime
113
113
  const progress = Math.min(timeElapsed / duration, 1)
114
114
  const currentTransform = start + (end - start) * easeInOutQuad(progress)
@@ -122,12 +122,12 @@ function animateTransform(start: number, end: number, duration: number) {
122
122
  // Navigation
123
123
  function goToSlide(index: number, isTouchNav = false) {
124
124
  countSlides()
125
- if (!isSliderAvailable || !bglSlider || index < 0 || index >= slideCount) { return }
125
+ if (!isSliderAvailable.value || !bglSlider.value || index < 0 || index >= slideCount.value) { return }
126
126
 
127
- const containerWidth = bglSlider.offsetWidth
127
+ const containerWidth = bglSlider.value.offsetWidth
128
128
  const gapWidth = (containerWidth * GAP_PERCENT) / 100
129
- const totalGapWidth = (itemCount - 1) * gapWidth
130
- const singleItemWidth = (containerWidth - totalGapWidth) / itemCount
129
+ const totalGapWidth = (itemCount.value - 1) * gapWidth
130
+ const singleItemWidth = (containerWidth - totalGapWidth) / itemCount.value
131
131
 
132
132
  // Account for all gaps before this slide
133
133
  const gapsBeforeSlide = index * gapWidth
@@ -141,39 +141,39 @@ function goToSlide(index: number, isTouchNav = false) {
141
141
  : ANIMATION_TIMINGS.DESKTOP
142
142
 
143
143
  animateTransform(currentTransform, targetTransform, duration)
144
- activeSlideIndex = index
144
+ activeSlideIndex.value = index
145
145
  updateHeight()
146
146
  }
147
147
 
148
148
  function next() {
149
- if (!isSliderAvailable) { return }
149
+ if (!isSliderAvailable.value) { return }
150
150
  countSlides()
151
151
  // In RTL, next and prev are reversed
152
152
  const nextIndex = props.rtl
153
- ? (activeSlideIndex - 1 + slideCount) % slideCount
154
- : (activeSlideIndex + 1) % slideCount
153
+ ? (activeSlideIndex.value - 1 + slideCount.value) % slideCount.value
154
+ : (activeSlideIndex.value + 1) % slideCount.value
155
155
  goToSlide(nextIndex)
156
156
  }
157
157
 
158
158
  function prev() {
159
- if (!isSliderAvailable) { return }
159
+ if (!isSliderAvailable.value) { return }
160
160
  countSlides()
161
161
  // In RTL, next and prev are reversed
162
162
  const prevIndex = props.rtl
163
- ? (activeSlideIndex + 1) % slideCount
164
- : (activeSlideIndex - 1 + slideCount) % slideCount
163
+ ? (activeSlideIndex.value + 1) % slideCount.value
164
+ : (activeSlideIndex.value - 1 + slideCount.value) % slideCount.value
165
165
  goToSlide(prevIndex)
166
166
  }
167
167
 
168
168
  // Height management
169
169
  function calcHeight() {
170
- if (!isSliderAvailable || !bglSlider) { return }
170
+ if (!isSliderAvailable.value || !bglSlider.value) { return }
171
171
  try {
172
- const activeSlide = bglSlider.children[activeSlideIndex]
173
- if (!activeSlide) { return }
172
+ const activeSlide = bglSlider.value.children[activeSlideIndex.value]
173
+ if (!activeSlide || !(activeSlide instanceof HTMLElement)) { return }
174
174
  const children = Array.from(activeSlide.children) as HTMLElement[]
175
175
  const totalHeight = children.reduce((sum, el) => sum + el.clientHeight, 0)
176
- yHeight = `${totalHeight}px`
176
+ yHeight.value = `${totalHeight}px`
177
177
  } catch (error) {
178
178
  console.error('Error calculating height:', error)
179
179
  }
@@ -186,31 +186,31 @@ function updateHeight() {
186
186
 
187
187
  // Slide management
188
188
  function countSlides() {
189
- if (!isSliderAvailable || !bglSlider) { return }
190
- slideCount = bglSlider.children.length
189
+ if (!isSliderAvailable.value || !bglSlider.value) { return }
190
+ slideCount.value = bglSlider.value.children.length
191
191
  }
192
192
 
193
193
  // Event handlers
194
194
  function handleSlideChange() {
195
- if (props.index !== activeSlideIndex) {
196
- emit('update:index', activeSlideIndex)
195
+ if (props.index !== activeSlideIndex.value) {
196
+ emit('update:index', activeSlideIndex.value)
197
197
  }
198
198
  }
199
199
 
200
200
  function handleResize() {
201
- if (!isSliderAvailable || !bglSlider) { return }
202
- itemCount = window.innerWidth < 600
201
+ if (!isSliderAvailable.value || !bglSlider.value) { return }
202
+ itemCount.value = window.innerWidth < 600
203
203
  ? 1
204
204
  : window.innerWidth < 991
205
205
  ? Math.min(props.items, 2)
206
206
  : props.items
207
207
 
208
- const containerWidth = bglSlider.offsetWidth
208
+ const containerWidth = bglSlider.value.offsetWidth
209
209
  const gapWidth = (containerWidth * GAP_PERCENT) / 100
210
- const totalGapWidth = (itemCount - 1) * gapWidth
211
- const singleItemWidth = (containerWidth - totalGapWidth) / itemCount
212
- const gapsBeforeSlide = activeSlideIndex * gapWidth
213
- const targetTransform = -(singleItemWidth * activeSlideIndex + gapsBeforeSlide)
210
+ const totalGapWidth = (itemCount.value - 1) * gapWidth
211
+ const singleItemWidth = (containerWidth - totalGapWidth) / itemCount.value
212
+ const gapsBeforeSlide = activeSlideIndex.value * gapWidth
213
+ const targetTransform = -(singleItemWidth * activeSlideIndex.value + gapsBeforeSlide)
214
214
 
215
215
  setTransform(targetTransform)
216
216
  updateHeight()
@@ -222,7 +222,7 @@ function clearAutoplay() {
222
222
 
223
223
  // Mouse events
224
224
  function preventDefaultClick(e: MouseEvent) {
225
- if (isDragging) {
225
+ if (isDragging.value) {
226
226
  e.preventDefault()
227
227
  e.stopPropagation()
228
228
  }
@@ -230,9 +230,9 @@ function preventDefaultClick(e: MouseEvent) {
230
230
 
231
231
  async function disableDrag() {
232
232
  await nextTick()
233
- if (!isSliderAvailable || !bglSlider) { return }
233
+ if (!isSliderAvailable.value || !bglSlider.value) { return }
234
234
 
235
- const elements = Array.from(bglSlider.querySelectorAll('img, a')) as HTMLElement[]
235
+ const elements = Array.from(bglSlider.value.querySelectorAll('img, a')) as HTMLElement[]
236
236
  elements.forEach((el) => {
237
237
  el.setAttribute('draggable', 'false')
238
238
  // Add click prevention to interactive elements
@@ -240,7 +240,7 @@ async function disableDrag() {
240
240
  el.addEventListener('click', preventDefaultClick, true)
241
241
  })
242
242
 
243
- const slides = Array.from(bglSlider.children)
243
+ const slides = Array.from(bglSlider.value.children)
244
244
  slides.forEach((slide) => {
245
245
  const element = slide as HTMLElement
246
246
  element.setAttribute('draggable', 'false')
@@ -252,34 +252,34 @@ async function disableDrag() {
252
252
 
253
253
  function startDrag(e: MouseEvent) {
254
254
  e.stopPropagation()
255
- if (e.button !== 0 || !props.freeDrag || !isSliderAvailable) { return }
255
+ if (e.button !== 0 || !props.freeDrag || !isSliderAvailable.value) { return }
256
256
 
257
257
  clearAutoplay()
258
- startX = e.pageX
259
- translateX = getCurrentTransform()
260
- isPressed = true
261
- isDragging = false // Reset dragging state on start
258
+ startX.value = e.pageX
259
+ translateX.value = getCurrentTransform()
260
+ isPressed.value = true
261
+ isDragging.value = false // Reset dragging state on start
262
262
 
263
263
  document.addEventListener('mousemove', onDrag)
264
264
  document.addEventListener('mouseup', endDrag)
265
265
  }
266
266
 
267
267
  function onDrag(e: MouseEvent) {
268
- if (!isSliderAvailable || !bglSlider || !isPressed) { return }
268
+ if (!isSliderAvailable.value || !bglSlider.value || !isPressed.value) { return }
269
269
 
270
270
  const x = e.pageX
271
- const distance = x - startX
271
+ const distance = x - startX.value
272
272
 
273
- if (Math.abs(distance) > THRESHOLDS.DRAG) { isDragging = true }
274
- if (isDragging) {
275
- const newTranslate = translateX + (props.rtl ? -distance : distance)
273
+ if (Math.abs(distance) > THRESHOLDS.DRAG) { isDragging.value = true }
274
+ if (isDragging.value) {
275
+ const newTranslate = translateX.value + (props.rtl ? -distance : distance)
276
276
  const maxTranslate = 0
277
277
 
278
- const containerWidth = bglSlider.offsetWidth
278
+ const containerWidth = bglSlider.value.offsetWidth
279
279
  const gapWidth = (containerWidth * GAP_PERCENT) / 100
280
- const totalGapWidth = (itemCount - 1) * gapWidth
281
- const singleItemWidth = (containerWidth - totalGapWidth) / itemCount
282
- const minTranslate = -(singleItemWidth * (slideCount - 1) + gapWidth * (slideCount - 1))
280
+ const totalGapWidth = (itemCount.value - 1) * gapWidth
281
+ const singleItemWidth = (containerWidth - totalGapWidth) / itemCount.value
282
+ const minTranslate = -(singleItemWidth * (slideCount.value - 1) + gapWidth * (slideCount.value - 1))
283
283
 
284
284
  const boundedTranslate = Math.max(minTranslate, Math.min(maxTranslate, newTranslate))
285
285
  setTransform(boundedTranslate)
@@ -287,17 +287,17 @@ function onDrag(e: MouseEvent) {
287
287
  }
288
288
 
289
289
  function endDrag() {
290
- isPressed = false
290
+ isPressed.value = false
291
291
  document.removeEventListener('mousemove', onDrag)
292
292
  document.removeEventListener('mouseup', endDrag)
293
293
 
294
- if (!isSliderAvailable || !bglSlider) { return }
294
+ if (!isSliderAvailable.value || !bglSlider.value) { return }
295
295
 
296
296
  const currentTransform = getCurrentTransform()
297
- const singleItemWidth = bglSlider.offsetWidth / itemCount
297
+ const singleItemWidth = bglSlider.value.offsetWidth / itemCount.value
298
298
  const currentPanel = -currentTransform / singleItemWidth
299
299
 
300
- const totalDragDistance = currentTransform - translateX
300
+ const totalDragDistance = currentTransform - translateX.value
301
301
  const dragPercentage = Math.abs(totalDragDistance) / singleItemWidth
302
302
 
303
303
  let targetPanel = currentPanel
@@ -308,67 +308,67 @@ function endDrag() {
308
308
  targetPanel = Math.round(currentPanel)
309
309
  }
310
310
 
311
- targetPanel = Math.max(0, Math.min(targetPanel, slideCount - 1))
311
+ targetPanel = Math.max(0, Math.min(targetPanel, slideCount.value - 1))
312
312
  goToSlide(targetPanel, true)
313
313
 
314
314
  // Keep isDragging true for a short period to prevent click
315
- if (isDragging) {
315
+ if (isDragging.value) {
316
316
  setTimeout(() => {
317
- isDragging = false
317
+ isDragging.value = false
318
318
  }, 10) // Short timeout to ensure click event is handled first
319
319
  }
320
320
  }
321
321
 
322
322
  // Add a new state variable for tracking scroll direction
323
- let hasScrollDirectionLock = $ref(false)
324
- let isHorizontalScroll = $ref(false)
323
+ const hasScrollDirectionLock = ref(false)
324
+ const isHorizontalScroll = ref(false)
325
325
 
326
326
  function onTouchStart(e: TouchEvent) {
327
- if (!props.freeDrag || !isSliderAvailable) { return }
327
+ if (!props.freeDrag || !isSliderAvailable.value) { return }
328
328
 
329
329
  const target = e.target as HTMLElement
330
330
  const isInteractive = target.matches('button, a, input, select, textarea, [role="button"]')
331
331
  || target.closest('button, a, input, select, textarea, [role="button"]')
332
332
 
333
- if (!isInteractive) {
333
+ if (isInteractive === false || isInteractive === null) {
334
334
  // Don't prevent default immediately - let's wait to see the direction
335
335
  clearAutoplay()
336
- const touch = e.touches[0]
337
- startX = touch.pageX
338
- startY = touch.pageY
339
- lastX = touch.pageX
340
- lastTime = Date.now()
341
- translateX = getCurrentTransform()
342
- velocityTracker = [{ time: lastTime, position: lastX }]
343
- isPressed = true
344
- hasScrollDirectionLock = false
336
+ const [touch] = e.touches
337
+ startX.value = touch.pageX
338
+ startY.value = touch.pageY
339
+ lastX.value = touch.pageX
340
+ lastTime.value = Date.now()
341
+ translateX.value = getCurrentTransform()
342
+ velocityTracker.value = [{ time: lastTime.value, position: lastX.value }]
343
+ isPressed.value = true
344
+ hasScrollDirectionLock.value = false
345
345
 
346
346
  // Ensure no transition is active when starting touch
347
- if (bglSlider) {
348
- bglSlider.style.transition = 'none'
347
+ if (bglSlider.value) {
348
+ bglSlider.value.style.transition = 'none'
349
349
  }
350
350
  }
351
351
  }
352
352
 
353
353
  function onTouchMove(e: TouchEvent) {
354
- if (!isSliderAvailable || !bglSlider || !isPressed) { return }
354
+ if (!isSliderAvailable.value || !bglSlider.value || !isPressed.value) { return }
355
355
 
356
- const touch = e.touches[0]
356
+ const [touch] = e.touches
357
357
  const x = touch.pageX
358
358
  const y = touch.pageY
359
- const deltaX = x - startX
360
- const deltaY = y - startY
359
+ const deltaX = x - startX.value
360
+ const deltaY = y - startY.value
361
361
 
362
362
  // Determine scroll direction if we haven't already
363
- if (!hasScrollDirectionLock) {
363
+ if (!hasScrollDirectionLock.value) {
364
364
  // Only lock in a direction if there's significant movement
365
365
  if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
366
- isHorizontalScroll = Math.abs(deltaX) > Math.abs(deltaY)
367
- hasScrollDirectionLock = true
366
+ isHorizontalScroll.value = Math.abs(deltaX) > Math.abs(deltaY)
367
+ hasScrollDirectionLock.value = true
368
368
 
369
369
  // If it's vertical scrolling, release the touch capture
370
- if (!isHorizontalScroll) {
371
- isPressed = false
370
+ if (!isHorizontalScroll.value) {
371
+ isPressed.value = false
372
372
  return
373
373
  }
374
374
  }
@@ -377,31 +377,31 @@ function onTouchMove(e: TouchEvent) {
377
377
  }
378
378
 
379
379
  // If we've determined this is a vertical scroll, don't handle the touch
380
- if (!isHorizontalScroll) { return }
380
+ if (!isHorizontalScroll.value) { return }
381
381
 
382
382
  // Update velocity tracking
383
383
  const now = Date.now()
384
- velocityTracker.push({ time: now, position: x })
385
- lastX = x
384
+ velocityTracker.value.push({ time: now, position: x })
385
+ lastX.value = x
386
386
 
387
387
  // Keep only recent samples
388
388
  const cutoffTime = now - VELOCITY_SAMPLE_DURATION
389
- velocityTracker = velocityTracker.filter((sample: VelocitySample) => sample.time >= cutoffTime)
389
+ velocityTracker.value = velocityTracker.value.filter((sample: VelocitySample) => sample.time >= cutoffTime)
390
390
 
391
391
  if (Math.abs(deltaX) > THRESHOLDS.TOUCH) {
392
- isDragging = true
392
+ isDragging.value = true
393
393
  e.preventDefault() // Only prevent default if we're sure it's a horizontal drag
394
394
  }
395
395
 
396
- if (isDragging) {
397
- const containerWidth = bglSlider.offsetWidth
396
+ if (isDragging.value) {
397
+ const containerWidth = bglSlider.value.offsetWidth
398
398
  const gapWidth = (containerWidth * GAP_PERCENT) / 100
399
- const totalGapWidth = (itemCount - 1) * gapWidth
400
- const singleItemWidth = (containerWidth - totalGapWidth) / itemCount
401
- const totalWidth = (singleItemWidth * slideCount) + (gapWidth * (slideCount - 1))
399
+ const totalGapWidth = (itemCount.value - 1) * gapWidth
400
+ const singleItemWidth = (containerWidth - totalGapWidth) / itemCount.value
401
+ const totalWidth = (singleItemWidth * slideCount.value) + (gapWidth * (slideCount.value - 1))
402
402
 
403
403
  // Calculate the new position based on touch movement
404
- let newTranslate = translateX + (props.rtl ? -deltaX : deltaX)
404
+ let newTranslate = translateX.value + (props.rtl ? -deltaX : deltaX)
405
405
 
406
406
  // Add smooth resistance when pulling beyond bounds
407
407
  if (newTranslate > 0) {
@@ -417,16 +417,16 @@ function onTouchMove(e: TouchEvent) {
417
417
  }
418
418
 
419
419
  function onTouchEnd() {
420
- if (!isSliderAvailable || !bglSlider || !isPressed || !isHorizontalScroll) {
421
- isPressed = false
422
- hasScrollDirectionLock = false
420
+ if (!isSliderAvailable.value || !bglSlider.value || !isPressed.value || !isHorizontalScroll.value) {
421
+ isPressed.value = false
422
+ hasScrollDirectionLock.value = false
423
423
  return
424
424
  }
425
425
 
426
- const containerWidth = bglSlider.offsetWidth
426
+ const containerWidth = bglSlider.value.offsetWidth
427
427
  const gapWidth = (containerWidth * GAP_PERCENT) / 100
428
- const totalGapWidth = (itemCount - 1) * gapWidth
429
- const singleItemWidth = (containerWidth - totalGapWidth) / itemCount
428
+ const totalGapWidth = (itemCount.value - 1) * gapWidth
429
+ const singleItemWidth = (containerWidth - totalGapWidth) / itemCount.value
430
430
  const totalSlideWidth = singleItemWidth + gapWidth
431
431
 
432
432
  const currentTransform = getCurrentTransform()
@@ -436,7 +436,7 @@ function onTouchEnd() {
436
436
  if (currentTransform > 0) {
437
437
  normalizedTransform = 0
438
438
  } else {
439
- const minTransform = -(singleItemWidth * (slideCount - 1) + gapWidth * (slideCount - 1))
439
+ const minTransform = -(singleItemWidth * (slideCount.value - 1) + gapWidth * (slideCount.value - 1))
440
440
  if (currentTransform < minTransform) {
441
441
  normalizedTransform = minTransform
442
442
  }
@@ -444,7 +444,7 @@ function onTouchEnd() {
444
444
 
445
445
  const currentPanel = Math.abs(normalizedTransform / totalSlideWidth)
446
446
 
447
- const totalSwipeDistance = lastX - startX
447
+ const totalSwipeDistance = lastX.value - startX.value
448
448
  const swipePercentage = Math.abs(totalSwipeDistance) / totalSlideWidth
449
449
 
450
450
  // Get final velocity from tracker
@@ -470,18 +470,18 @@ function onTouchEnd() {
470
470
 
471
471
  if (isMobile) {
472
472
  // On mobile, only move one slide at a time
473
- targetPanel = activeSlideIndex + rtlDirection
473
+ targetPanel = activeSlideIndex.value + rtlDirection
474
474
  } else {
475
475
  // On desktop, keep the current behavior
476
476
  targetPanel = Math.round(currentPanel) + rtlDirection
477
477
  }
478
478
  } else {
479
479
  // If the swipe wasn't strong enough, snap back to the current slide
480
- targetPanel = isMobile ? activeSlideIndex : Math.round(currentPanel)
480
+ targetPanel = isMobile ? activeSlideIndex.value : Math.round(currentPanel)
481
481
  }
482
482
 
483
- targetPanel = Math.max(0, Math.min(targetPanel, slideCount - 1))
484
- activeSlideIndex = targetPanel
483
+ targetPanel = Math.max(0, Math.min(targetPanel, slideCount.value - 1))
484
+ activeSlideIndex.value = targetPanel
485
485
 
486
486
  // Adjust animation duration based on velocity and distance to travel
487
487
  const distance = Math.abs(targetPanel - currentPanel)
@@ -492,7 +492,7 @@ function onTouchEnd() {
492
492
  )
493
493
 
494
494
  // Re-enable transitions for the snap animation
495
- bglSlider.style.transition = `transform ${duration}ms cubic-bezier(0.4, 0, 0.2, 1)`
495
+ bglSlider.value.style.transition = `transform ${duration}ms cubic-bezier(0.4, 0, 0.2, 1)`
496
496
 
497
497
  const gapsBeforeSlide = targetPanel * gapWidth
498
498
  const targetTransform = -(singleItemWidth * targetPanel + gapsBeforeSlide)
@@ -500,17 +500,17 @@ function onTouchEnd() {
500
500
 
501
501
  // Clear transition after animation
502
502
  setTimeout(() => {
503
- if (bglSlider) { bglSlider.style.transition = 'none' }
503
+ if (bglSlider.value) { bglSlider.value.style.transition = 'none' }
504
504
  }, duration)
505
505
 
506
- velocityTracker = []
507
- isDragging = false
508
- hasScrollDirectionLock = false
506
+ velocityTracker.value = []
507
+ isDragging.value = false
508
+ hasScrollDirectionLock.value = false
509
509
  }
510
510
 
511
511
  // Wheel events
512
512
  function onWheel(e: WheelEvent) {
513
- if (!props.allowScroll || !isSliderAvailable || !bglSlider || isPressed || isDragging) { return }
513
+ if (!props.allowScroll || !isSliderAvailable.value || !bglSlider.value || isPressed.value || isDragging.value) { return }
514
514
 
515
515
  const isHorizontal = Math.abs(e.deltaX) > Math.abs(e.deltaY)
516
516
  if (!isHorizontal) { return }
@@ -519,22 +519,22 @@ function onWheel(e: WheelEvent) {
519
519
  if (wheelTimeout) { clearTimeout(wheelTimeout) }
520
520
 
521
521
  // Reverse the delta direction for RTL mode
522
- accumulatedDeltaX += props.rtl ? -e.deltaX : e.deltaX
522
+ accumulatedDeltaX.value += props.rtl ? -e.deltaX : e.deltaX
523
523
 
524
524
  wheelTimeout = setTimeout(() => {
525
- accumulatedDeltaX = 0
525
+ accumulatedDeltaX.value = 0
526
526
  }, 50)
527
527
 
528
- const singleItemWidth = bglSlider.offsetWidth / itemCount
528
+ const singleItemWidth = bglSlider.value.offsetWidth / itemCount.value
529
529
  const moveThreshold = singleItemWidth * THRESHOLDS.WHEEL_PERCENT
530
530
 
531
- if (Math.abs(accumulatedDeltaX) > moveThreshold) {
532
- const direction = accumulatedDeltaX > 0 ? 1 : -1
533
- const nextPanel = Math.max(0, Math.min(activeSlideIndex + direction, slideCount - 1))
531
+ if (Math.abs(accumulatedDeltaX.value) > moveThreshold) {
532
+ const direction = accumulatedDeltaX.value > 0 ? 1 : -1
533
+ const nextPanel = Math.max(0, Math.min(activeSlideIndex.value + direction, slideCount.value - 1))
534
534
 
535
- if (nextPanel !== activeSlideIndex) {
535
+ if (nextPanel !== activeSlideIndex.value) {
536
536
  goToSlide(nextPanel, true)
537
- accumulatedDeltaX = 0
537
+ accumulatedDeltaX.value = 0
538
538
  }
539
539
  }
540
540
  }
@@ -547,8 +547,8 @@ onMounted(() => {
547
547
  countSlides()
548
548
  disableDrag()
549
549
 
550
- if (bglSlider) {
551
- slideCount = bglSlider.children.length
550
+ if (bglSlider.value) {
551
+ slideCount.value = bglSlider.value.children.length
552
552
  }
553
553
 
554
554
  if (props.autoplay) {
@@ -557,8 +557,8 @@ onMounted(() => {
557
557
  })
558
558
 
559
559
  onUnmounted(() => {
560
- if (isSliderAvailable && bglSlider) {
561
- Array.from(bglSlider.children).forEach((child) => {
560
+ if (isSliderAvailable.value && bglSlider.value) {
561
+ Array.from(bglSlider.value.children).forEach((child) => {
562
562
  const element = child as HTMLElement
563
563
  element.removeEventListener('click', preventDefaultClick)
564
564
  })
@@ -573,7 +573,7 @@ onUnmounted(() => {
573
573
 
574
574
  // Watchers
575
575
  watch(() => props.index, (newIndex: number) => { goToSlide(newIndex) })
576
- watch(() => activeSlideIndex, handleSlideChange)
576
+ watch(() => activeSlideIndex.value, handleSlideChange)
577
577
 
578
578
  defineExpose({
579
579
  goToSlide,
@@ -587,32 +587,27 @@ defineExpose({
587
587
  <template>
588
588
  <div class="BglCarousel" :dir="rtl ? 'rtl' : 'ltr'">
589
589
  <div
590
- ref="bglSlider"
591
- class="bgl-slider"
590
+ ref="bglSlider" class="bgl-slider"
592
591
  :class="{ dragging: isDragging, clicking: isPressed, [`slides-${itemCount}`]: true, grab: freeDrag && slideCount > 1, autoHeight }"
593
- :style="{ '--item-count': itemCount, 'height': yHeight }"
594
- @mousedown="startDrag"
595
- @mouseover="clearAutoplay"
596
- @focusin="clearAutoplay"
597
- @touchstart="onTouchStart"
598
- @touchmove="onTouchMove"
599
- @touchend="onTouchEnd"
592
+ :style="{ '--item-count': itemCount, 'height': yHeight }" @mousedown="startDrag" @mouseover="clearAutoplay"
593
+ @focusin="clearAutoplay" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd"
600
594
  @wheel="onWheel"
601
595
  >
602
596
  <slot />
603
597
  </div>
604
598
  <div v-if="props.dots && slideCount > 1" class="dots">
605
599
  <span
606
- v-for="i in slideCount"
607
- :key="i"
608
- class="dot"
609
- :class="{ current: activeSlideIndex === i - 1 }"
600
+ v-for="i in slideCount" :key="i" class="dot" :class="{ current: activeSlideIndex === i - 1 }"
610
601
  @click="goToSlide(i - 1)"
611
602
  />
612
603
  </div>
613
604
  <div class="navigation-buttons" :class="{ rtl }">
614
- <span class="prev" @click="prev"><slot name="prev" :index="activeSlideIndex" :prev="prev" /></span>
615
- <span class="next" @click="next"><slot name="next" :index="activeSlideIndex" :next="next" /></span>
605
+ <span class="prev" @click="prev">
606
+ <slot name="prev" :index="activeSlideIndex" :prev="prev" />
607
+ </span>
608
+ <span class="next" @click="next">
609
+ <slot name="next" :index="activeSlideIndex" :next="next" />
610
+ </span>
616
611
  </div>
617
612
  </div>
618
613
  </template>
@@ -622,14 +617,16 @@ defineExpose({
622
617
  position: relative;
623
618
  width: 100%;
624
619
  overflow: hidden;
625
- touch-action: pan-y pinch-zoom; /* Allow vertical scrolling */
620
+ touch-action: pan-y pinch-zoom;
621
+ /* Allow vertical scrolling */
626
622
  }
627
623
 
628
624
  .bgl-slider {
629
625
  display: flex;
630
626
  position: relative;
631
627
  width: 100%;
632
- touch-action: pan-y pinch-zoom; /* Allow vertical scrolling */
628
+ touch-action: pan-y pinch-zoom;
629
+ /* Allow vertical scrolling */
633
630
  will-change: transform;
634
631
  transform: translateX(0);
635
632
  gap: 1%;
@@ -638,7 +635,7 @@ defineExpose({
638
635
  user-select: none;
639
636
  }
640
637
 
641
- .bgl-slider > * {
638
+ .bgl-slider>* {
642
639
  flex: 0 0 calc((100% - (var(--item-count) - 1) * 1%) / var(--item-count));
643
640
  width: calc((100% - (var(--item-count) - 1) * 1%) / var(--item-count));
644
641
  min-width: calc((100% - (var(--item-count) - 1) * 1%) / var(--item-count));
@@ -646,13 +643,13 @@ defineExpose({
646
643
  overflow: hidden;
647
644
  }
648
645
 
649
- .bgl-slider.slides-1 > * {
646
+ .bgl-slider.slides-1>* {
650
647
  flex: 0 0 100%;
651
648
  width: 100%;
652
649
  min-width: 100%;
653
650
  }
654
651
 
655
- .dragging .bgl-slider > * {
652
+ .dragging .bgl-slider>* {
656
653
  pointer-events: none;
657
654
  user-select: none;
658
655
  }