@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
|
@@ -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;
|
|
43
|
+
for (let minute = 0; minute < 60; 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(() =>
|
|
27
|
+
const isMobile = computed(() => window.innerWidth < 768)
|
|
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;
|
|
45
|
+
for (let i = startingDay - 1; i >= 0; 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 = 'Sunday'
|
|
70
|
+
const weekStartOffset = props.weekStart === 'Sunday' ? 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;
|
|
78
|
+
for (let i = 0; i < 7; 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;
|
|
90
|
+
for (let minute = 0; minute < 60; 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 (
|
|
133
|
+
if (dayIndex === -1) { 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 (
|
|
167
|
+
if (currentGroup.length === 0) {
|
|
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 (
|
|
184
|
+
if (currentGroup.length > 0) {
|
|
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 (
|
|
193
|
+
if (currentGroup.length > 0) {
|
|
194
194
|
overlappingGroups.push(currentGroup)
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// Position overlapping events with elegant spacing
|
|
198
198
|
overlappingGroups.forEach((group) => {
|
|
199
|
-
if (
|
|
199
|
+
if (group.length > 1) {
|
|
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 (
|
|
239
|
+
if (clickedDayIndex === -1) { 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 (
|
|
281
|
+
if (targetDayIndex === -1) { 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 (
|
|
290
|
+
if (targetDayIndex >= 0 && 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
|
|
|
@@ -86,13 +86,13 @@ function renderFieldForRow(field: Field<T>, row: T) {
|
|
|
86
86
|
return renderField({ ...field, label: '' } as BaseBagelField<T, Path<T>>, slots as unknown as BaseBagelField<T, Path<T>>['slots'])
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const computedItemHeight =
|
|
89
|
+
const computedItemHeight = computed(() => `${itemHeight.value}px`)
|
|
90
90
|
|
|
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 ('ASC'
|
|
13
|
+
if (sortDirectionRef.value === 'ASC') {
|
|
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 (('created_at'
|
|
35
|
+
if ((field.id === 'created_at' || field.id === 'updated_at') && !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) &&
|
|
65
|
+
if (Array.isArray(schema) && schema.length > 0) {
|
|
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) &&
|
|
70
|
+
} else if (Array.isArray(dataValue) && dataValue.length > 0) {
|
|
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 => 'id'
|
|
76
|
+
.filter(key => key !== 'id' && !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 =
|
|
133
|
-
const isSrcValueComponent =
|
|
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)
|
|
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) ||
|
|
170
|
+
if (!Array.isArray(currentData) || currentData.length === 0) {
|
|
171
171
|
return []
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
if (!sortField.value ||
|
|
174
|
+
if (!sortField.value || toValue(options.useServerSort) === true) {
|
|
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 'ASC'
|
|
185
|
+
return sortDirection.value === 'ASC'
|
|
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 'ASC'
|
|
194
|
+
return sortDirection.value === 'ASC' ? numAValue - numBValue : numBValue - numAValue
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
if ('string'
|
|
198
|
-
return 'ASC'
|
|
197
|
+
if (typeof aValue === 'string') {
|
|
198
|
+
return sortDirection.value === 'ASC' ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue)
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
return 'ASC'
|
|
201
|
+
return sortDirection.value === 'ASC' ? (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 ('ASC'
|
|
207
|
+
if (sortDirection.value === 'ASC') {
|
|
208
208
|
sortDirection.value = 'DESC'
|
|
209
209
|
} else {
|
|
210
210
|
sortField.value = ''
|
|
@@ -11,24 +11,24 @@ 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(() =>
|
|
15
|
-
const allItems =
|
|
14
|
+
const isSelectable = computed(() => options.selectable === true && Array.isArray(options.selectedItems.value))
|
|
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
|
-
if (!allItems) {
|
|
22
|
-
allSelectorEl.value.indeterminate =
|
|
21
|
+
if (!allItems.value) {
|
|
22
|
+
allSelectorEl.value.indeterminate = options.selectedItems.value.length > 0
|
|
23
23
|
return
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Get all possible item IDs
|
|
27
|
-
const allItemIds = allItems.map(item => item.id)
|
|
27
|
+
const allItemIds = allItems.value.map(item => item.id)
|
|
28
28
|
|
|
29
29
|
// Check if all items are selected
|
|
30
30
|
const allSelected
|
|
31
|
-
=
|
|
31
|
+
= allItemIds.length > 0
|
|
32
32
|
&& options.selectedItems.value.length === allItemIds.length
|
|
33
33
|
&& allItemIds.every(id => options.selectedItems.value.includes(id))
|
|
34
34
|
|
|
@@ -37,19 +37,19 @@ 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 &&
|
|
40
|
+
= !allSelected && options.selectedItems.value.length > 0
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function toggleSelectItem(item: T, event?: MouseEvent) {
|
|
44
|
-
const currentIndex = allItems.findIndex(i => i.id === item.id)
|
|
44
|
+
const currentIndex = allItems.value.findIndex(i => i.id === item.id)
|
|
45
45
|
|
|
46
46
|
// Handle Shift+click for range selection
|
|
47
|
-
if (event?.shiftKey &&
|
|
47
|
+
if (event?.shiftKey && lastSelectedIndex.value !== null && currentIndex !== -1) {
|
|
48
48
|
const startIndex = Math.min(lastSelectedIndex.value, currentIndex)
|
|
49
49
|
const endIndex = Math.max(lastSelectedIndex.value, currentIndex)
|
|
50
50
|
|
|
51
51
|
// Get all items in the range
|
|
52
|
-
const rangeItems = allItems.slice(startIndex, endIndex + 1)
|
|
52
|
+
const rangeItems = allItems.value.slice(startIndex, endIndex + 1)
|
|
53
53
|
const rangeItemIds = rangeItems.map(i => i.id)
|
|
54
54
|
|
|
55
55
|
// Check if all items in range are currently selected
|
|
@@ -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 (
|
|
74
|
+
if (computedSelectedItems.value.length === 0) {
|
|
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 (-1
|
|
93
|
+
if (index > -1) {
|
|
94
94
|
options.selectedItems.value.splice(index, 1)
|
|
95
95
|
} else {
|
|
96
96
|
options.selectedItems.value.push(item.id)
|
|
@@ -104,8 +104,8 @@ export function useTableSelection<T extends { [key: string]: any }>(options: Use
|
|
|
104
104
|
function toggleSelectAll(event: Event) {
|
|
105
105
|
const value = (event.target as HTMLInputElement).checked
|
|
106
106
|
|
|
107
|
-
if (allItems && value) {
|
|
108
|
-
options.selectedItems.value = allItems.map(item => item.id)
|
|
107
|
+
if (allItems.value && value) {
|
|
108
|
+
options.selectedItems.value = allItems.value.map(item => item.id)
|
|
109
109
|
} else {
|
|
110
110
|
options.selectedItems.value = []
|
|
111
111
|
}
|
|
@@ -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 &&
|
|
35
|
+
if (entry.isIntersecting && dataLength > 0) {
|
|
36
36
|
options.onLastItemVisible?.()
|
|
37
37
|
}
|
|
38
38
|
})
|