@bagelink/vue 1.5.15 → 1.5.20

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 (135) hide show
  1. package/bin/experimentalGenTypedRoutes.ts +15 -15
  2. package/bin/generateFormSchema.ts +12 -12
  3. package/bin/utils.ts +4 -4
  4. package/dist/components/Dropdown.vue.d.ts.map +1 -1
  5. package/dist/components/RouterWrapper.vue.d.ts.map +1 -1
  6. package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
  7. package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
  8. package/dist/components/form/FieldArray.vue.d.ts +5 -4
  9. package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
  10. package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
  11. package/dist/components/form/inputs/RichText/index.vue.d.ts +1 -0
  12. package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
  13. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  14. package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
  15. package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts.map +1 -1
  16. package/dist/composables/useFormField.d.ts.map +1 -1
  17. package/dist/composables/useSchemaField.d.ts.map +1 -1
  18. package/dist/index.cjs +68 -55
  19. package/dist/index.mjs +34035 -143
  20. package/dist/style.css +1 -1
  21. package/package.json +1 -1
  22. package/src/components/AccordionItem.vue +2 -2
  23. package/src/components/AddToCalendar.vue +1 -1
  24. package/src/components/BglVideo.vue +8 -8
  25. package/src/components/Btn.vue +9 -9
  26. package/src/components/Card.vue +4 -4
  27. package/src/components/Carousel.vue +44 -44
  28. package/src/components/DataPreview.vue +1 -1
  29. package/src/components/DragOver.vue +6 -6
  30. package/src/components/Dropdown.vue +14 -14
  31. package/src/components/Flag.vue +3 -3
  32. package/src/components/Icon/Icon.vue +13 -13
  33. package/src/components/Image.vue +4 -4
  34. package/src/components/ImportData.vue +79 -79
  35. package/src/components/ListItem.vue +7 -7
  36. package/src/components/MapEmbed/Index.vue +6 -6
  37. package/src/components/Modal.vue +10 -10
  38. package/src/components/ModalForm.vue +4 -4
  39. package/src/components/NavBar.vue +2 -2
  40. package/src/components/Pagination.vue +9 -9
  41. package/src/components/Pill.vue +1 -1
  42. package/src/components/Rating.vue +2 -2
  43. package/src/components/RouterWrapper.vue +3 -3
  44. package/src/components/Slider.vue +77 -77
  45. package/src/components/Spreadsheet/Index.vue +34 -34
  46. package/src/components/Spreadsheet/SpreadsheetTable.vue +3 -3
  47. package/src/components/Zoomer.vue +28 -28
  48. package/src/components/analytics/BarChart.vue +6 -6
  49. package/src/components/analytics/KpiCard.vue +2 -2
  50. package/src/components/analytics/LineChart.vue +14 -14
  51. package/src/components/analytics/PieChart.vue +11 -11
  52. package/src/components/calendar/CalendarPopover.vue +1 -1
  53. package/src/components/calendar/Index.vue +1 -1
  54. package/src/components/calendar/views/AgendaView.vue +2 -2
  55. package/src/components/calendar/views/DayView.vue +6 -6
  56. package/src/components/calendar/views/MonthView.vue +2 -2
  57. package/src/components/calendar/views/WeekView.vue +18 -18
  58. package/src/components/dataTable/DataTable.vue +3 -3
  59. package/src/components/dataTable/useSorting.ts +1 -1
  60. package/src/components/dataTable/useTableData.ts +15 -15
  61. package/src/components/dataTable/useTableSelection.ts +8 -8
  62. package/src/components/dataTable/useTableVirtualization.ts +1 -1
  63. package/src/components/draggable/useDraggable.ts +42 -42
  64. package/src/components/form/BagelForm.vue +66 -23
  65. package/src/components/form/BglMultiStepForm.vue +18 -18
  66. package/src/components/form/FieldArray.vue +177 -67
  67. package/src/components/form/inputs/CheckInput.vue +2 -1
  68. package/src/components/form/inputs/CodeEditor/Index.vue +1 -1
  69. package/src/components/form/inputs/CodeEditor/format.ts +7 -7
  70. package/src/components/form/inputs/CodeEditor/useHighlight.ts +6 -6
  71. package/src/components/form/inputs/DateInput.vue +6 -6
  72. package/src/components/form/inputs/DatePicker.vue +19 -19
  73. package/src/components/form/inputs/EmailInput.vue +14 -14
  74. package/src/components/form/inputs/NumberInput.vue +6 -6
  75. package/src/components/form/inputs/OTP.vue +3 -3
  76. package/src/components/form/inputs/RadioGroup.vue +1 -1
  77. package/src/components/form/inputs/RadioPillsInput.vue +8 -8
  78. package/src/components/form/inputs/RichText/components/EditorToolbar.vue +10 -10
  79. package/src/components/form/inputs/RichText/components/TableGridSelector.vue +1 -1
  80. package/src/components/form/inputs/RichText/composables/useCommands.ts +1 -1
  81. package/src/components/form/inputs/RichText/composables/useEditor.ts +12 -12
  82. package/src/components/form/inputs/RichText/composables/useEditorKeyboard.ts +1 -1
  83. package/src/components/form/inputs/RichText/index.vue +300 -132
  84. package/src/components/form/inputs/RichText/utils/commands.ts +69 -69
  85. package/src/components/form/inputs/RichText/utils/debug.ts +1 -1
  86. package/src/components/form/inputs/RichText/utils/formatting.ts +39 -39
  87. package/src/components/form/inputs/RichText/utils/media.ts +6 -6
  88. package/src/components/form/inputs/RichText/utils/selection.ts +28 -28
  89. package/src/components/form/inputs/RichText/utils/table.ts +19 -19
  90. package/src/components/form/inputs/SelectBtn.vue +1 -1
  91. package/src/components/form/inputs/SelectInput.vue +50 -26
  92. package/src/components/form/inputs/SignaturePad.vue +15 -15
  93. package/src/components/form/inputs/TableField.vue +1 -1
  94. package/src/components/form/inputs/TelInput.vue +6 -6
  95. package/src/components/form/inputs/TextInput.vue +5 -5
  96. package/src/components/form/inputs/ToggleInput.vue +2 -1
  97. package/src/components/form/inputs/Upload/UploadInput.vue +155 -102
  98. package/src/components/form/inputs/Upload/upload.ts +1 -1
  99. package/src/components/form/inputs/Upload/useFileUpload.ts +6 -6
  100. package/src/components/form/useBagelFormState.ts +5 -5
  101. package/src/components/layout/AppContent.vue +1 -1
  102. package/src/components/layout/AppLayout.vue +1 -1
  103. package/src/components/layout/Layout.vue +4 -4
  104. package/src/components/layout/TabbedLayout.vue +1 -1
  105. package/src/components/layout/Tabs.vue +2 -2
  106. package/src/components/layout/TabsNav.vue +7 -7
  107. package/src/components/lightbox/Lightbox.vue +8 -8
  108. package/src/components/lightbox/index.ts +8 -8
  109. package/src/composables/index.ts +2 -2
  110. package/src/composables/useAddToCalendar.ts +13 -13
  111. package/src/composables/useDevice.ts +2 -2
  112. package/src/composables/useExcel.ts +6 -6
  113. package/src/composables/useFormField.ts +5 -9
  114. package/src/composables/usePolling.ts +8 -8
  115. package/src/composables/useSchemaField.ts +53 -38
  116. package/src/composables/useTheme.ts +9 -9
  117. package/src/composables/useValidateFieldValue.ts +2 -2
  118. package/src/directives/pattern.ts +25 -25
  119. package/src/directives/ripple.ts +4 -4
  120. package/src/directives/vResize.ts +6 -6
  121. package/src/plugins/bagel.ts +4 -4
  122. package/src/plugins/useModal.ts +3 -3
  123. package/src/styles/layout.css +7 -1
  124. package/src/utils/BagelFormUtils.ts +7 -7
  125. package/src/utils/calendar/Helpers.ts +8 -8
  126. package/src/utils/calendar/dateUtils.ts +22 -22
  127. package/src/utils/calendar/time.ts +25 -25
  128. package/src/utils/calendar/week.ts +25 -25
  129. package/src/utils/elementUtils.ts +27 -27
  130. package/src/utils/index.ts +22 -22
  131. package/src/utils/sizeParsing.ts +2 -2
  132. package/src/utils/strings.ts +5 -5
  133. package/src/utils/tapDetector.ts +11 -11
  134. package/src/utils/useSearch.ts +29 -29
  135. package/vite.config.ts +1 -1
@@ -42,7 +42,7 @@ const views: Record<CalendarView, Component> = {
42
42
  const visibleDateRange = computed(() => {
43
43
  const start = new Date(currentDate.value)
44
44
  let end = new Date(currentDate.value)
45
- const addSunday = props.weekStart === 'Sunday' ? 0 : 1
45
+ const addSunday = 'Sunday' === props.weekStart ? 0 : 1
46
46
  switch (currentView.value) {
47
47
  case 'Week':
48
48
  start.setDate(start.getDate() - start.getDay() + addSunday)
@@ -40,7 +40,7 @@ const processedEvents = computed(() => {
40
40
  // Group events by date
41
41
  const eventsByDate = sortedEvents.reduce((acc, event) => {
42
42
  const date = new Date(event.start_time).toDateString()
43
- if (!acc[date]) acc[date] = []
43
+ if (!acc[date]) {acc[date] = []}
44
44
  acc[date].push(event)
45
45
  return acc
46
46
  }, {} as { [key: string]: CalendarEvent[] })
@@ -69,7 +69,7 @@ const processedEvents = computed(() => {
69
69
 
70
70
  // Handle scroll to determine visible date
71
71
  function handleScroll() {
72
- if (!containerRef.value) return
72
+ if (!containerRef.value) {return}
73
73
 
74
74
  const container = containerRef.value
75
75
  const eventElements = container.querySelectorAll('.event')
@@ -40,7 +40,7 @@ const currentTimeInterval = ref(null as any)
40
40
  const timeSlots = computed(() => {
41
41
  const slots = []
42
42
  for (let hour = timeRange.start; hour < timeRange.end; hour++) {
43
- for (let minute = 0; minute < 60; minute += slotDuration) {
43
+ for (let minute = 0; 60 > minute; minute += slotDuration) {
44
44
  slots.push({
45
45
  hour,
46
46
  minute,
@@ -91,7 +91,7 @@ function updateCurrentTimeIndicator() {
91
91
  // Event handlers for drag-to-create functionality
92
92
  function handleMouseDown(e: MouseEvent) {
93
93
  const target = e.target as HTMLElement
94
- if (!target.closest('.time-slot')) return
94
+ if (!target.closest('.time-slot')) {return}
95
95
 
96
96
  dragState.value.isDragging = true
97
97
  dragState.value.start = { x: e.clientX, y: e.clientY }
@@ -102,20 +102,20 @@ function handleMouseDown(e: MouseEvent) {
102
102
  }
103
103
 
104
104
  function handleMouseMove(e: MouseEvent) {
105
- if (!dragState.value.isDragging) return
105
+ if (!dragState.value.isDragging) {return}
106
106
 
107
107
  dragState.value.end = { x: e.clientX, y: e.clientY }
108
108
  dragState.value.endTime = getTimeFromPosition(e.clientY)
109
109
  }
110
110
 
111
111
  function handleMouseUp() {
112
- if (!dragState.value.isDragging || !dragState.value.startTime || !dragState.value.endTime) return
112
+ if (!dragState.value.isDragging || !dragState.value.startTime || !dragState.value.endTime) {return}
113
113
 
114
114
  let start = new Date(dragState.value.startTime)
115
115
  let end = new Date(dragState.value.endTime)
116
116
 
117
117
  // Ensure end time is after start time
118
- if (end < start) [start, end] = [end, start]
118
+ if (end < start) {[start, end] = [end, start]}
119
119
 
120
120
  emit('eventCreate', { start_time: start, end_time: end })
121
121
 
@@ -134,7 +134,7 @@ function handleMouseUp() {
134
134
 
135
135
  function getTimeFromPosition(y: number): Date {
136
136
  const rect = document.querySelector('.time-slots')?.getBoundingClientRect()
137
- if (!rect) return new Date()
137
+ if (!rect) {return new Date()}
138
138
 
139
139
  // Calculate time using the same formula as for events
140
140
  const relativeY = y - rect.top
@@ -24,7 +24,7 @@ const emit = defineEmits<{
24
24
  const slots: SetupContext['slots'] = useSlots()
25
25
 
26
26
  // Responsive state
27
- const isMobile = computed(() => window.innerWidth < 768)
27
+ const isMobile = computed(() => 768 > window.innerWidth)
28
28
 
29
29
  // Calendar data
30
30
  const weekDays = computed(() => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
@@ -42,7 +42,7 @@ const currentMonth = computed(() => {
42
42
 
43
43
  // Add days from previous month to fill the calendar grid
44
44
  const prevMonthLastDay = new Date(year, month, 0).getDate()
45
- for (let i = startingDay - 1; i >= 0; i--) {
45
+ for (let i = startingDay - 1; 0 <= i; i--) {
46
46
  const date = new Date(year, month - 1, prevMonthLastDay - i)
47
47
  days.push({
48
48
  date,
@@ -67,7 +67,7 @@ const scrollableContainer = ref<HTMLElement>()
67
67
  const weekDays = computed(() => {
68
68
  const days = []
69
69
  const start = new Date(props.startDate)
70
- const weekStartOffset = props.weekStart === 'Sunday' ? 0 : 1
70
+ const weekStartOffset = 'Sunday' === props.weekStart ? 0 : 1
71
71
 
72
72
  // Adjust to start of week
73
73
  const dayOfWeek = start.getDay()
@@ -75,7 +75,7 @@ const weekDays = computed(() => {
75
75
  start.setHours(0, 0, 0, 0) // Set time to start of day
76
76
 
77
77
  // Create array of 7 day dates
78
- for (let i = 0; i < 7; i++) {
78
+ for (let i = 0; 7 > i; i++) {
79
79
  const date = new Date(start)
80
80
  date.setDate(start.getDate() + i)
81
81
  days.push(date)
@@ -87,7 +87,7 @@ const weekDays = computed(() => {
87
87
  const timeSlots = computed(() => {
88
88
  const slots = []
89
89
  for (let hour = timeRange.start; hour < timeRange.end; hour++) {
90
- for (let minute = 0; minute < 60; minute += slotDuration) {
90
+ for (let minute = 0; 60 > minute; minute += slotDuration) {
91
91
  slots.push({
92
92
  hour,
93
93
  minute,
@@ -130,7 +130,7 @@ const processedEvents = computed(() => {
130
130
  && day.getFullYear() === startDate.getFullYear()
131
131
  )
132
132
 
133
- if (dayIndex === -1) return
133
+ if (-1 === dayIndex) {return}
134
134
 
135
135
  // Calculate vertical positioning
136
136
  const startMinutes = startDate.getHours() * 60 + startDate.getMinutes()
@@ -164,7 +164,7 @@ const processedEvents = computed(() => {
164
164
  let currentGroup: WeekViewEvent[] = []
165
165
 
166
166
  dayEventList.forEach((event) => {
167
- if (currentGroup.length === 0) {
167
+ if (0 === currentGroup.length) {
168
168
  currentGroup = [event]
169
169
  } else {
170
170
  // Check if this event overlaps with any event in the current group
@@ -181,7 +181,7 @@ const processedEvents = computed(() => {
181
181
  currentGroup.push(event)
182
182
  } else {
183
183
  // No overlap, finalize current group and start new one
184
- if (currentGroup.length > 0) {
184
+ if (0 < currentGroup.length) {
185
185
  overlappingGroups.push([...currentGroup])
186
186
  }
187
187
  currentGroup = [event]
@@ -190,13 +190,13 @@ const processedEvents = computed(() => {
190
190
  })
191
191
 
192
192
  // Don't forget the last group
193
- if (currentGroup.length > 0) {
193
+ if (0 < currentGroup.length) {
194
194
  overlappingGroups.push(currentGroup)
195
195
  }
196
196
 
197
197
  // Position overlapping events with elegant spacing
198
198
  overlappingGroups.forEach((group) => {
199
- if (group.length > 1) {
199
+ if (1 < group.length) {
200
200
  // Add some spacing between overlapping events (2% gap)
201
201
  const gap = 2
202
202
  const availableWidth = 100 - (gap * (group.length - 1))
@@ -219,15 +219,15 @@ const processedEvents = computed(() => {
219
219
  // Mouse event handlers for drag-to-create functionality
220
220
  function handleMouseDown(e: MouseEvent, day: Date) {
221
221
  // Only allow drag-to-create if the feature is enabled
222
- if (!isDragToCreateEnabled.value) return
222
+ if (!isDragToCreateEnabled.value) {return}
223
223
 
224
- if (!calendarGrid.value || !dayColumnsContainer.value) return
224
+ if (!calendarGrid.value || !dayColumnsContainer.value) {return}
225
225
 
226
226
  // Find the clicked day column
227
227
  let clickedDayIndex = -1
228
228
  for (let i = 0; i < dayColumns.value.length; i++) {
229
229
  const columnEl = dayColumns.value[i]
230
- if (!columnEl) continue
230
+ if (!columnEl) {continue}
231
231
 
232
232
  const rect = columnEl.getBoundingClientRect()
233
233
  if (e.clientX >= rect.left && e.clientX <= rect.right) {
@@ -236,7 +236,7 @@ function handleMouseDown(e: MouseEvent, day: Date) {
236
236
  }
237
237
  }
238
238
 
239
- if (clickedDayIndex === -1) return
239
+ if (-1 === clickedDayIndex) {return}
240
240
 
241
241
  // Get the clicked day column's position and dimensions
242
242
  const dayColumnRect = dayColumns.value[clickedDayIndex].getBoundingClientRect()
@@ -263,13 +263,13 @@ function handleMouseDown(e: MouseEvent, day: Date) {
263
263
  }
264
264
 
265
265
  function handleMouseMove(e: MouseEvent) {
266
- if (!isDragToCreateEnabled.value || !dragState.value.isDragging || !dragState.value.start || !dayColumns.value.length || !calendarGrid.value || !dayColumnsContainer.value) return
266
+ if (!isDragToCreateEnabled.value || !dragState.value.isDragging || !dragState.value.start || !dayColumns.value.length || !calendarGrid.value || !dayColumnsContainer.value) {return}
267
267
 
268
268
  // Find which day column we're hovering over
269
269
  let targetDayIndex = -1
270
270
  for (let i = 0; i < dayColumns.value.length; i++) {
271
271
  const columnEl = dayColumns.value[i]
272
- if (!columnEl) continue
272
+ if (!columnEl) {continue}
273
273
 
274
274
  const rect = columnEl.getBoundingClientRect()
275
275
  if (e.clientX >= rect.left && e.clientX <= rect.right) {
@@ -278,7 +278,7 @@ function handleMouseMove(e: MouseEvent) {
278
278
  }
279
279
  }
280
280
 
281
- if (targetDayIndex === -1) return
281
+ if (-1 === targetDayIndex) {return}
282
282
 
283
283
  // Update which days are selected
284
284
  dragState.value.endDay = targetDayIndex
@@ -287,7 +287,7 @@ function handleMouseMove(e: MouseEvent) {
287
287
  y: e.clientY - dayColumnsContainer.value.getBoundingClientRect().top
288
288
  }
289
289
 
290
- if (targetDayIndex >= 0 && targetDayIndex < weekDays.value.length) {
290
+ if (0 <= targetDayIndex && targetDayIndex < weekDays.value.length) {
291
291
  // Always use the starting day as the base date for the event
292
292
  const startDay = new Date(weekDays.value[dragState.value.startDay])
293
293
  startDay.setHours(0, 0, 0, 0)
@@ -300,7 +300,7 @@ function handleMouseMove(e: MouseEvent) {
300
300
  }
301
301
 
302
302
  function handleMouseUp() {
303
- if (!isDragToCreateEnabled.value || !dragState.value.isDragging || !dragState.value.startTime || !dragState.value.endTime) return
303
+ if (!isDragToCreateEnabled.value || !dragState.value.isDragging || !dragState.value.startTime || !dragState.value.endTime) {return}
304
304
 
305
305
  let start = new Date(dragState.value.startTime)
306
306
  let end = new Date(dragState.value.endTime)
@@ -331,7 +331,7 @@ function handleMouseUp() {
331
331
 
332
332
  // Consistent time positioning function that uses the same coordinate system as events
333
333
  function getTimeFromPositionConsistent(y: number, day: Date): Date {
334
- if (!dayColumnsContainer.value) return new Date(day)
334
+ if (!dayColumnsContainer.value) {return new Date(day)}
335
335
 
336
336
  const containerRect = dayColumnsContainer.value.getBoundingClientRect()
337
337
 
@@ -91,8 +91,8 @@ const computedItemHeight = $computed(() => `${itemHeight.value}px`)
91
91
  watch(
92
92
  () => loading.value,
93
93
  (newLoadingVal, oldLoadingVal) => {
94
- if (newLoadingVal === oldLoadingVal) return
95
- if (!newLoadingVal) registerLastItemObserver()
94
+ if (newLoadingVal === oldLoadingVal) {return}
95
+ if (!newLoadingVal) {registerLastItemObserver()}
96
96
  },
97
97
  { immediate: true }
98
98
  )
@@ -105,7 +105,7 @@ watch(
105
105
  watch(
106
106
  () => computedData.value,
107
107
  (newData, oldData) => {
108
- if (newData.length === oldData.length || props.onLastItemVisible !== undefined) return
108
+ if (newData.length === oldData.length || props.onLastItemVisible !== undefined) {return}
109
109
  scrollTo(0)
110
110
  }
111
111
  )
@@ -10,7 +10,7 @@ export function useSorting(options: SortingOptions) {
10
10
 
11
11
  function sort(fieldname: string) {
12
12
  if (sortFieldRef.value === fieldname) {
13
- if (sortDirectionRef.value === 'ASC') {
13
+ if ('ASC' === sortDirectionRef.value) {
14
14
  sortDirectionRef.value = 'DESC'
15
15
  } else {
16
16
  sortFieldRef.value = ''
@@ -32,7 +32,7 @@ interface TransformedDataBase {
32
32
  type TransformedData<TransDataT> = TransDataT & TransformedDataBase
33
33
 
34
34
  function autoTransform<T>(field: Field<T, DefaultPathsOptions>): Field<T, DefaultPathsOptions> {
35
- if ((field.id === 'created_at' || field.id === 'updated_at') && !field.transform) {
35
+ if (('created_at' === field.id || 'updated_at' === field.id) && !field.transform) {
36
36
  field.transform = (val?: any) => val ? formatDate(val) : val
37
37
  }
38
38
  return field
@@ -62,18 +62,18 @@ export function useTableData<T extends { [key: string]: any }>(options: UseTable
62
62
  })
63
63
 
64
64
  // If we have a valid schema with fields, filter out fields without an ID
65
- if (Array.isArray(schema) && schema.length > 0) {
65
+ if (Array.isArray(schema) && 0 < schema.length) {
66
66
  resolvedSchema.value = (schema as SchemaField<T>[])
67
67
  .filter(field => field)
68
68
  .map(field => field as Field<T>)
69
69
  .map(autoTransform)
70
- } else if (Array.isArray(dataValue) && dataValue.length > 0) {
70
+ } else if (Array.isArray(dataValue) && 0 < dataValue.length) {
71
71
  // If no schema is provided or it's empty, generate a default schema from the data
72
72
  const firstItem = dataValue[0]
73
73
 
74
74
  // Create a schema based on the keys of the first item
75
75
  resolvedSchema.value = Object.keys(firstItem || {})
76
- .filter(key => key !== 'id' && !key.startsWith('_')) // Exclude id and internal fields
76
+ .filter(key => 'id' !== key && !key.startsWith('_')) // Exclude id and internal fields
77
77
  .map(key => ({
78
78
  id: key as any, // Cast to any to resolve type issues with Path<T>
79
79
  label: keyToLabel(key),
@@ -81,7 +81,7 @@ export function useTableData<T extends { [key: string]: any }>(options: UseTable
81
81
  transform: (val?: any) => {
82
82
  // Handle date fields
83
83
  const dateFields = ['created_at', 'updated_at']
84
- if (dateFields.includes(key)) return val ? new Date(val).toLocaleString() : val
84
+ if (dateFields.includes(key)) {return val ? new Date(val).toLocaleString() : val}
85
85
  return val
86
86
  }
87
87
  }))
@@ -129,8 +129,8 @@ export function useTableData<T extends { [key: string]: any }>(options: UseTable
129
129
  ;(transformed as TransformedDataBase)[originalKey] = fieldData
130
130
 
131
131
  // Determine if this component should receive value as slot or src
132
- const isSlotValueComponent = typeof field.$el === 'string' && SLOT_VALUE_COMPONENTS.has(field.$el)
133
- const isSrcValueComponent = typeof field.$el === 'string' && SRC_VALUE_COMPONENTS.has(field.$el)
132
+ const isSlotValueComponent = 'string' === typeof field.$el && SLOT_VALUE_COMPONENTS.has(field.$el)
133
+ const isSrcValueComponent = 'string' === typeof field.$el && SRC_VALUE_COMPONENTS.has(field.$el)
134
134
 
135
135
  ;(transformed as TransformedDataBase)[slotKey] = isSlotValueComponent
136
136
  ;(transformed as TransformedDataBase)[srcKey] = isSrcValueComponent
@@ -167,11 +167,11 @@ export function useTableData<T extends { [key: string]: any }>(options: UseTable
167
167
  const currentData = toValue(options.data) || []
168
168
 
169
169
  // If there's no data, return an empty array
170
- if (!Array.isArray(currentData) || currentData.length === 0) {
170
+ if (!Array.isArray(currentData) || 0 === currentData.length) {
171
171
  return []
172
172
  }
173
173
 
174
- if (!sortField.value || toValue(options.useServerSort) === true) {
174
+ if (!sortField.value || true === toValue(options.useServerSort)) {
175
175
  return currentData.map(transform)
176
176
  }
177
177
 
@@ -182,7 +182,7 @@ export function useTableData<T extends { [key: string]: any }>(options: UseTable
182
182
  const bValue = (z as any)[computedSortField.value] ?? ''
183
183
 
184
184
  if (isDate(aValue) && isDate(bValue)) {
185
- return sortDirection.value === 'ASC'
185
+ return 'ASC' === sortDirection.value
186
186
  ? new Date(aValue).getTime() - new Date(bValue).getTime()
187
187
  : new Date(bValue).getTime() - new Date(aValue).getTime()
188
188
  }
@@ -191,20 +191,20 @@ export function useTableData<T extends { [key: string]: any }>(options: UseTable
191
191
  const numBValue = Number.parseInt(`${bValue}`.replaceAll(NON_DIGIT_REGEX, ''), 10)
192
192
 
193
193
  if (!Number.isNaN(numAValue) && !Number.isNaN(numBValue)) {
194
- return sortDirection.value === 'ASC' ? numAValue - numBValue : numBValue - numAValue
194
+ return 'ASC' === sortDirection.value ? numAValue - numBValue : numBValue - numAValue
195
195
  }
196
196
 
197
- if (typeof aValue === 'string') {
198
- return sortDirection.value === 'ASC' ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue)
197
+ if ('string' === typeof aValue) {
198
+ return 'ASC' === sortDirection.value ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue)
199
199
  }
200
200
 
201
- return sortDirection.value === 'ASC' ? (aValue < bValue ? -1 : 1) : (aValue < bValue ? 1 : -1)
201
+ return 'ASC' === sortDirection.value ? (aValue < bValue ? -1 : 1) : (aValue < bValue ? 1 : -1)
202
202
  })
203
203
  })
204
204
 
205
205
  function toggleSort(fieldname: string) {
206
206
  if (sortField.value === fieldname) {
207
- if (sortDirection.value === 'ASC') {
207
+ if ('ASC' === sortDirection.value) {
208
208
  sortDirection.value = 'DESC'
209
209
  } else {
210
210
  sortField.value = ''
@@ -11,15 +11,15 @@ export function useTableSelection<T extends { [key: string]: any }>(options: Use
11
11
  const allSelectorEl = ref<HTMLInputElement>()
12
12
  const lastSelectedIndex = ref<number | null>(null)
13
13
  const computedSelectedItems = computed(() => options.selectedItems.value)
14
- const isSelectable = computed(() => options.selectable === true && Array.isArray(options.selectedItems.value))
14
+ const isSelectable = computed(() => true === options.selectable && Array.isArray(options.selectedItems.value))
15
15
  const allItems = $computed(() => options.data.value)
16
16
 
17
17
  function updateAllSelectorState() {
18
- if (allSelectorEl.value === undefined) return
18
+ if (allSelectorEl.value === undefined) {return}
19
19
 
20
20
  // If we don't know the total items, we can't determine if "all" are selected
21
21
  if (!allItems) {
22
- allSelectorEl.value.indeterminate = options.selectedItems.value.length > 0
22
+ allSelectorEl.value.indeterminate = 0 < options.selectedItems.value.length
23
23
  return
24
24
  }
25
25
 
@@ -28,7 +28,7 @@ export function useTableSelection<T extends { [key: string]: any }>(options: Use
28
28
 
29
29
  // Check if all items are selected
30
30
  const allSelected
31
- = allItemIds.length > 0
31
+ = 0 < allItemIds.length
32
32
  && options.selectedItems.value.length === allItemIds.length
33
33
  && allItemIds.every(id => options.selectedItems.value.includes(id))
34
34
 
@@ -37,14 +37,14 @@ export function useTableSelection<T extends { [key: string]: any }>(options: Use
37
37
 
38
38
  // Set indeterminate state (some but not all items selected)
39
39
  allSelectorEl.value.indeterminate
40
- = !allSelected && options.selectedItems.value.length > 0
40
+ = !allSelected && 0 < options.selectedItems.value.length
41
41
  }
42
42
 
43
43
  function toggleSelectItem(item: T, event?: MouseEvent) {
44
44
  const currentIndex = allItems.findIndex(i => i.id === item.id)
45
45
 
46
46
  // Handle Shift+click for range selection
47
- if (event?.shiftKey && lastSelectedIndex.value !== null && currentIndex !== -1) {
47
+ if (event?.shiftKey && null !== lastSelectedIndex.value && -1 !== currentIndex) {
48
48
  const startIndex = Math.min(lastSelectedIndex.value, currentIndex)
49
49
  const endIndex = Math.max(lastSelectedIndex.value, currentIndex)
50
50
 
@@ -71,7 +71,7 @@ export function useTableSelection<T extends { [key: string]: any }>(options: Use
71
71
  }
72
72
 
73
73
  // Regular single item selection logic
74
- if (computedSelectedItems.value.length === 0) {
74
+ if (0 === computedSelectedItems.value.length) {
75
75
  // Clean the item if a cleanData function is provided, otherwise use the default cleaning
76
76
  const cleanItem = options.cleanData ? options.cleanData(item) : { ...item }
77
77
 
@@ -90,7 +90,7 @@ export function useTableSelection<T extends { [key: string]: any }>(options: Use
90
90
  }
91
91
 
92
92
  const index = computedSelectedItems.value.indexOf(item.id)
93
- if (index > -1) {
93
+ if (-1 < index) {
94
94
  options.selectedItems.value.splice(index, 1)
95
95
  } else {
96
96
  options.selectedItems.value.push(item.id)
@@ -32,7 +32,7 @@ export function useTableVirtualization<T>(options: TableVirtualizationOptions<T>
32
32
  // Check if options.data.value exists and has length
33
33
  const dataLength = toValue(options.data).length || 0
34
34
 
35
- if (entry.isIntersecting && dataLength > 0) {
35
+ if (entry.isIntersecting && 0 < dataLength) {
36
36
  options.onLastItemVisible?.()
37
37
  }
38
38
  })