@bagelink/vue 1.20.54 → 1.20.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/calendar/Index.vue.d.ts +5 -0
- package/dist/components/calendar/Index.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/AgendaView.vue.d.ts +6 -0
- package/dist/components/calendar/views/AgendaView.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/core.css +1 -1
- package/dist/index.cjs +71 -71
- package/dist/index.css +1 -1
- package/dist/index.mjs +4764 -4721
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/AddToCalendar.vue +2 -2
- package/src/components/calendar/Index.vue +22 -3
- package/src/components/calendar/views/AgendaView.vue +184 -38
- package/src/components/form/inputs/RichText/index.vue +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.20.
|
|
4
|
+
"version": "1.20.58",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bagel Studio",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@types/signature_pad": "^4.0.0",
|
|
64
64
|
"vue": "^3.5.43",
|
|
65
65
|
"vue-component-type-helpers": "^2.2.12",
|
|
66
|
-
"@bagelink/sdk": "1.20.
|
|
66
|
+
"@bagelink/sdk": "1.20.58"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@bagelink/sdk": "*",
|
|
@@ -64,7 +64,7 @@ const allCalendars = [
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
key: 'ics',
|
|
67
|
-
icon: '
|
|
67
|
+
icon: 'calendar_month',
|
|
68
68
|
action: 'ics',
|
|
69
69
|
color: '#96A2B4',
|
|
70
70
|
prop: 'ics' as const,
|
|
@@ -233,7 +233,7 @@ function handleCalendarClick(type: string) {
|
|
|
233
233
|
|
|
234
234
|
<!-- Multiple calendars: show dropdown -->
|
|
235
235
|
<Dropdown
|
|
236
|
-
v-else-if="availableCalendars.length > 1" :value="t('addToCalendar.addToCalendar')" icon="
|
|
236
|
+
v-else-if="availableCalendars.length > 1" :value="t('addToCalendar.addToCalendar')" icon="calendar_month" color="white"
|
|
237
237
|
class="inline-block" :flat="false"
|
|
238
238
|
>
|
|
239
239
|
<ListItem
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { Component } from 'vue'
|
|
3
3
|
import type { AvailabilitySlot, CalendarEvent, CalendarView, CalendarViewState, WeekStart } from './CalendarTypes'
|
|
4
4
|
import { timeDelta, Btn, ListItem, Dropdown, TabsNav, formatDate, useI18n } from '../../index'
|
|
5
|
-
import { ref, computed, onMounted } from 'vue'
|
|
5
|
+
import { ref, computed, onMounted, watch } from 'vue'
|
|
6
6
|
import CalendarPopover from './CalendarPopover.vue'
|
|
7
7
|
import AgendaView from './views/AgendaView.vue'
|
|
8
8
|
import DayView from './views/DayView.vue'
|
|
@@ -18,6 +18,11 @@ const props = withDefaults(defineProps<{
|
|
|
18
18
|
availabilityEditable?: boolean
|
|
19
19
|
availabilitySlots?: AvailabilitySlot[]
|
|
20
20
|
viewSwitcher?: 'dropdown' | 'tabs' | false
|
|
21
|
+
/**
|
|
22
|
+
* Date the agenda should snap to the top (instead of today). Use when the
|
|
23
|
+
* host navigates explicitly, so picking a date lands on that date.
|
|
24
|
+
*/
|
|
25
|
+
focusDate?: Date
|
|
21
26
|
}>(), {
|
|
22
27
|
startDate: () => new Date(),
|
|
23
28
|
view: 'Week',
|
|
@@ -102,6 +107,19 @@ function handleDateChange(date: Date) {
|
|
|
102
107
|
emit('dateChange', state.value)
|
|
103
108
|
}
|
|
104
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Follow host-driven navigation without remounting.
|
|
112
|
+
*
|
|
113
|
+
* Hosts used to force a remount (via `:key`) to move the calendar, which reset
|
|
114
|
+
* the agenda's scroll position and made the view jump to an arbitrary day.
|
|
115
|
+
* Syncing here lets the same instance re-scope its range and scroll smoothly.
|
|
116
|
+
*/
|
|
117
|
+
watch(() => props.startDate?.getTime(), (next, prev) => {
|
|
118
|
+
if (!next || next === prev) { return }
|
|
119
|
+
currentDate.value = new Date(next)
|
|
120
|
+
emit('dateChange', state.value)
|
|
121
|
+
})
|
|
122
|
+
|
|
105
123
|
// Agenda view emits dateChange on scroll for header display,
|
|
106
124
|
// but we must NOT feed it back into currentDate or it causes a scroll loop.
|
|
107
125
|
function handleAgendaDateChange(date: Date) {
|
|
@@ -157,7 +175,7 @@ onMounted(() => {
|
|
|
157
175
|
</script>
|
|
158
176
|
|
|
159
177
|
<template>
|
|
160
|
-
<div class="
|
|
178
|
+
<div class="calendar_month">
|
|
161
179
|
<div class="flex m_block p-1">
|
|
162
180
|
<h3 class="txt-light my-0 m_pb-05">
|
|
163
181
|
<b>{{ formatDate(currentDate, 'MMMM') }}</b>
|
|
@@ -170,7 +188,7 @@ onMounted(() => {
|
|
|
170
188
|
<ListItem v-for="(_, key) in views" :key="key" thin :title="t(`calendar.views.${key.toLowerCase()}`)" @click="handleViewChange(key)" />
|
|
171
189
|
</Dropdown>
|
|
172
190
|
<div class="flex gap-025">
|
|
173
|
-
<Btn icon="
|
|
191
|
+
<Btn icon="calendar_month" size="sm" class="txt12" color="gray" :value="t('calendar.today')" @click="handleDateChange(new Date())" />
|
|
174
192
|
<Btn
|
|
175
193
|
icon="chevron_left" color="gray" size="sm" class=""
|
|
176
194
|
:disabled="currentView === 'Agenda'"
|
|
@@ -187,6 +205,7 @@ onMounted(() => {
|
|
|
187
205
|
<component
|
|
188
206
|
:is="views[currentView]" :events="events" :start-date="currentDate" :week-start="weekStart"
|
|
189
207
|
:availability-mode="props.availabilityMode" :availability-editable="props.availabilityEditable" :availability-slots="props.availabilitySlots"
|
|
208
|
+
:focus-date="props.focusDate"
|
|
190
209
|
@event-click="handleEventClick" @event-create="handleEventCreate" @event-update="handleEventUpdate"
|
|
191
210
|
@event-delete="handleEventDelete" @date-change="currentView === 'Agenda' ? handleAgendaDateChange($event) : handleDateChange($event)" @open-popover="openPopover"
|
|
192
211
|
@load-previous="emit('loadPrevious', $event)"
|
|
@@ -21,6 +21,12 @@ interface DayGroup {
|
|
|
21
21
|
const props = defineProps<{
|
|
22
22
|
events: CalendarEvent[]
|
|
23
23
|
startDate: Date
|
|
24
|
+
/**
|
|
25
|
+
* Date to snap to the top of the agenda instead of "today". Used when the
|
|
26
|
+
* host navigates explicitly (date picker / previous / next) so the requested
|
|
27
|
+
* day lands at the top rather than the view jumping to the current day.
|
|
28
|
+
*/
|
|
29
|
+
focusDate?: Date
|
|
24
30
|
}>()
|
|
25
31
|
|
|
26
32
|
const emit = defineEmits<{
|
|
@@ -85,41 +91,92 @@ const dayGroups = computed((): DayGroup[] => {
|
|
|
85
91
|
const scrolledOnce = ref(false)
|
|
86
92
|
const loadingPrevious = ref(false)
|
|
87
93
|
let previousScrollHeight = 0
|
|
94
|
+
let previousScrollTop = 0
|
|
88
95
|
let loadPreviousTimer: ReturnType<typeof setTimeout> | undefined
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Day key that was earliest when we last asked the parent for more history.
|
|
98
|
+
* Re-requesting only when this key changes is what stops a single upward
|
|
99
|
+
* scroll gesture from firing dozens of identical range requests.
|
|
100
|
+
*/
|
|
101
|
+
let lastRequestedFirstKey: string | null = null
|
|
102
|
+
let dateChangeFrame: number | undefined
|
|
103
|
+
/**
|
|
104
|
+
* Ignore "reached the top" detections briefly after a programmatic scroll.
|
|
105
|
+
* Swapping the loaded range resets scrollTop to 0, which previously looked like
|
|
106
|
+
* a user gesture and immediately fetched three more months of history — the
|
|
107
|
+
* source of the extra requests on every navigation.
|
|
108
|
+
*/
|
|
109
|
+
let ignoreLoadPreviousUntil = 0
|
|
110
|
+
/** Requested snap target, applied once its day group exists. */
|
|
111
|
+
let pendingFocus: Date | null = null
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Scroll tracking.
|
|
115
|
+
*
|
|
116
|
+
* Two jobs, both throttled: report the nearest day (header label) and detect
|
|
117
|
+
* that the user reached the top so more history can be appended. The previous
|
|
118
|
+
* implementation emitted on every scroll event and re-requested whenever
|
|
119
|
+
* `scrollTop <= 40`, so slow trackpad scrolls hammered the API with the same
|
|
120
|
+
* query over and over.
|
|
121
|
+
*/
|
|
91
122
|
function handleScroll() {
|
|
92
|
-
if (!containerRef.value) { return }
|
|
93
123
|
const container = containerRef.value
|
|
94
|
-
if (container
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
124
|
+
if (!container || !dayGroups.value.length) { return }
|
|
125
|
+
|
|
126
|
+
// Request older history at most once per distinct earliest-day.
|
|
127
|
+
if (container.scrollTop <= 48 && Date.now() > ignoreLoadPreviousUntil) {
|
|
128
|
+
const firstKey = dayGroups.value[0].dateKey
|
|
129
|
+
if (!loadingPrevious.value && lastRequestedFirstKey !== firstKey) {
|
|
130
|
+
lastRequestedFirstKey = firstKey
|
|
131
|
+
loadingPrevious.value = true
|
|
132
|
+
previousScrollHeight = container.scrollHeight
|
|
133
|
+
previousScrollTop = container.scrollTop
|
|
134
|
+
emit('loadPrevious', dayGroups.value[0].date)
|
|
135
|
+
// Safety valve: if the parent can't supply anything older, release the
|
|
136
|
+
// guard so a later gesture is still possible. `lastRequestedFirstKey`
|
|
137
|
+
// keeps the identical query from repeating until the first day moves.
|
|
138
|
+
clearTimeout(loadPreviousTimer)
|
|
139
|
+
loadPreviousTimer = setTimeout(() => { loadingPrevious.value = false }, 4000)
|
|
140
|
+
}
|
|
100
141
|
}
|
|
101
|
-
const dayEls = container.querySelectorAll<HTMLElement>('.agenda-day-group')
|
|
102
|
-
const containerTop = container.getBoundingClientRect().top
|
|
103
142
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
143
|
+
// Nearest-day reporting is coalesced to one emit per animation frame.
|
|
144
|
+
if (dateChangeFrame !== undefined) { return }
|
|
145
|
+
dateChangeFrame = requestAnimationFrame(() => {
|
|
146
|
+
dateChangeFrame = undefined
|
|
147
|
+
const el = containerRef.value
|
|
148
|
+
if (!el) { return }
|
|
149
|
+
const containerTop = el.getBoundingClientRect().top
|
|
150
|
+
let closest: HTMLElement | null = null
|
|
151
|
+
let minDist = Infinity
|
|
152
|
+
el.querySelectorAll<HTMLElement>('.agenda-day-group').forEach((dayEl) => {
|
|
153
|
+
const dist = Math.abs(dayEl.getBoundingClientRect().top - containerTop)
|
|
154
|
+
if (dist < minDist) { minDist = dist; closest = dayEl }
|
|
155
|
+
})
|
|
156
|
+
if (closest) {
|
|
157
|
+
const dateStr = (closest as HTMLElement).dataset.date
|
|
158
|
+
if (dateStr) { emit('dateChange', new Date(dateStr)) }
|
|
159
|
+
}
|
|
110
160
|
})
|
|
111
|
-
|
|
112
|
-
if (closest) {
|
|
113
|
-
const dateStr = (closest as HTMLElement).dataset.date
|
|
114
|
-
if (dateStr) { emit('dateChange', new Date(dateStr)) }
|
|
115
|
-
}
|
|
116
161
|
}
|
|
117
162
|
|
|
118
|
-
|
|
119
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Restore the reading position after older days are prepended.
|
|
165
|
+
*
|
|
166
|
+
* Watches the rendered group count rather than `events.length`: history can
|
|
167
|
+
* arrive with the same number of events (or none at all), and the old
|
|
168
|
+
* length-based check silently skipped the adjustment, which is what made
|
|
169
|
+
* scrolling back feel like it jumped to an arbitrary place.
|
|
170
|
+
*/
|
|
171
|
+
watch(() => dayGroups.value.length, (count, oldCount) => {
|
|
172
|
+
if (!loadingPrevious.value || !containerRef.value) { return }
|
|
120
173
|
nextTick(() => {
|
|
121
|
-
|
|
122
|
-
|
|
174
|
+
const container = containerRef.value
|
|
175
|
+
if (!container) { return }
|
|
176
|
+
const grew = count > (oldCount ?? 0)
|
|
177
|
+
if (grew) {
|
|
178
|
+
container.scrollTop = previousScrollTop + (container.scrollHeight - previousScrollHeight)
|
|
179
|
+
}
|
|
123
180
|
loadingPrevious.value = false
|
|
124
181
|
clearTimeout(loadPreviousTimer)
|
|
125
182
|
})
|
|
@@ -147,10 +204,23 @@ function toMidnight(date: Date): number {
|
|
|
147
204
|
return d.getTime()
|
|
148
205
|
}
|
|
149
206
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Snap a day group to the top of the agenda scrollport.
|
|
209
|
+
*
|
|
210
|
+
* Uses the container's own `scrollTop` instead of `scrollIntoView`, which also
|
|
211
|
+
* scrolls ancestor scrollers/pages — the cause of the whole page lurching when
|
|
212
|
+
* a date was picked.
|
|
213
|
+
*/
|
|
214
|
+
function scrollToDate(
|
|
215
|
+
targetDate: Date,
|
|
216
|
+
behavior: 'smooth' | 'instant' | 'auto' = 'instant',
|
|
217
|
+
direction: 'forward' | 'backward' | 'nearest' = 'nearest'
|
|
218
|
+
) {
|
|
219
|
+
const container = containerRef.value
|
|
220
|
+
if (!container) { return }
|
|
221
|
+
const dayEls = Array.from(container.querySelectorAll<HTMLElement>('.agenda-day-group'))
|
|
153
222
|
if (!dayEls.length) { return }
|
|
223
|
+
|
|
154
224
|
// Normalize to midnight to avoid timestamp-within-day comparison issues
|
|
155
225
|
const targetDay = toMidnight(targetDate)
|
|
156
226
|
let closest: HTMLElement | null = null
|
|
@@ -184,30 +254,106 @@ function scrollToDate(targetDate: Date, behavior: 'smooth' | 'instant' | 'auto'
|
|
|
184
254
|
}
|
|
185
255
|
}
|
|
186
256
|
|
|
187
|
-
closest
|
|
257
|
+
if (!closest) { return }
|
|
258
|
+
const offset = (closest as HTMLElement).getBoundingClientRect().top
|
|
259
|
+
- container.getBoundingClientRect().top
|
|
260
|
+
const nextTop = Math.max(0, container.scrollTop + offset)
|
|
261
|
+
// Reaching the top must not be mistaken for a "load more history" gesture
|
|
262
|
+
// when we are deliberately positioning the view.
|
|
263
|
+
if (behavior === 'smooth' && Math.abs(nextTop - container.scrollTop) > 1) {
|
|
264
|
+
container.scrollTo({ top: nextTop, behavior: 'smooth' })
|
|
265
|
+
} else {
|
|
266
|
+
container.scrollTop = nextTop
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Position the agenda when a host-provided target changes.
|
|
272
|
+
*
|
|
273
|
+
* `focusDate` wins over "today": navigating from the date picker should put the
|
|
274
|
+
* requested day at the top. When no target is supplied we fall back to today,
|
|
275
|
+
* but only once data actually reaches it, so a partial first page can't scroll
|
|
276
|
+
* the view to a day that isn't loaded yet.
|
|
277
|
+
*/
|
|
278
|
+
function snapToTarget(target: Date, direction: 'forward' | 'nearest' = 'forward') {
|
|
279
|
+
// Guard the programmatic reposition from being read as a scroll-to-top.
|
|
280
|
+
ignoreLoadPreviousUntil = Date.now() + 900
|
|
281
|
+
nextTick(() => {
|
|
282
|
+
const container = containerRef.value
|
|
283
|
+
if (!container) { return }
|
|
284
|
+
previousScrollTop = container.scrollTop
|
|
285
|
+
previousScrollHeight = container.scrollHeight
|
|
286
|
+
scrollToDate(target, 'instant', direction)
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Navigate to date when the host changes the target (buttons / date picker).
|
|
291
|
+
watch(
|
|
292
|
+
() => props.focusDate?.getTime(),
|
|
293
|
+
() => {
|
|
294
|
+
if (!props.focusDate) { return }
|
|
295
|
+
scrolledOnce.value = true
|
|
296
|
+
pendingFocus = props.focusDate
|
|
297
|
+
applyPendingFocus()
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Apply a requested target once the agenda actually contains it.
|
|
303
|
+
*
|
|
304
|
+
* Changing the date also refetches a new range, so the first attempt often runs
|
|
305
|
+
* against the previous range's days. Retrying on `dayGroups` changes lands the
|
|
306
|
+
* scroll on the real target as soon as its data arrives.
|
|
307
|
+
*/
|
|
308
|
+
function applyPendingFocus() {
|
|
309
|
+
if (!pendingFocus || !dayGroups.value.length) { return }
|
|
310
|
+
const targetTime = toMidnight(pendingFocus)
|
|
311
|
+
// Wait until the loaded range starts at or before the target. Checking only
|
|
312
|
+
// "some day is on/after the target" passes against the previous range, which
|
|
313
|
+
// cleared the request early and left the view at the top of the old list.
|
|
314
|
+
const earliest = toMidnight(dayGroups.value[0].date)
|
|
315
|
+
if (earliest > targetTime) { return }
|
|
316
|
+
const target = pendingFocus
|
|
317
|
+
pendingFocus = null
|
|
318
|
+
snapToTarget(target, 'forward')
|
|
188
319
|
}
|
|
189
320
|
|
|
190
|
-
|
|
321
|
+
watch(dayGroups, () => {
|
|
322
|
+
if (pendingFocus) { applyPendingFocus() }
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
// Fallback: follow startDate when no explicit focus target is provided.
|
|
191
326
|
watch(() => props.startDate, (newDate, oldDate) => {
|
|
327
|
+
if (props.focusDate) { return }
|
|
192
328
|
const direction = !oldDate || toMidnight(newDate) >= toMidnight(oldDate) ? 'forward' : 'backward'
|
|
193
329
|
nextTick(() => scrollToDate(newDate, 'smooth', direction))
|
|
194
330
|
})
|
|
195
331
|
|
|
196
|
-
// Initial scroll to today — wait until data covers today before scrolling,
|
|
197
|
-
// to avoid scrolling to a wrong date during partial/incremental data load.
|
|
198
332
|
watchEffect(() => {
|
|
199
333
|
if (scrolledOnce.value || !dayGroups.value.length) { return }
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
334
|
+
if (props.focusDate) {
|
|
335
|
+
scrolledOnce.value = true
|
|
336
|
+
pendingFocus = props.focusDate
|
|
337
|
+
applyPendingFocus()
|
|
338
|
+
return
|
|
339
|
+
}
|
|
340
|
+
// No explicit target: fall back to today, but only once it's loaded so a
|
|
341
|
+
// partial first page can't scroll to a day that isn't in the list yet.
|
|
342
|
+
const target = new Date()
|
|
343
|
+
const targetTime = toMidnight(target)
|
|
344
|
+
const covered = dayGroups.value.some(
|
|
345
|
+
g => toMidnight(g.date) >= targetTime || Math.abs(toMidnight(g.date) - targetTime) < 86400000
|
|
346
|
+
)
|
|
347
|
+
if (!covered) { return }
|
|
203
348
|
scrolledOnce.value = true
|
|
204
|
-
|
|
349
|
+
snapToTarget(target, 'nearest')
|
|
205
350
|
})
|
|
206
351
|
|
|
207
352
|
onMounted(() => { containerRef.value?.addEventListener('scroll', handleScroll) })
|
|
208
353
|
onUnmounted(() => {
|
|
209
354
|
containerRef.value?.removeEventListener('scroll', handleScroll)
|
|
210
355
|
clearTimeout(loadPreviousTimer)
|
|
356
|
+
if (dateChangeFrame !== undefined) { cancelAnimationFrame(dateChangeFrame) }
|
|
211
357
|
})
|
|
212
358
|
</script>
|
|
213
359
|
|
|
@@ -215,7 +361,7 @@ onUnmounted(() => {
|
|
|
215
361
|
<div ref="containerRef" class="display-flex column h-100p overflow gap-0">
|
|
216
362
|
<template v-if="dayGroups.length === 0">
|
|
217
363
|
<div class="flex h-100p justify-content-center column gap-1 opacity-3">
|
|
218
|
-
<Icon icon="
|
|
364
|
+
<Icon icon="calendar_month" size="4" weight="200" />
|
|
219
365
|
{{ t('calendar.agenda.noEvents') }}
|
|
220
366
|
</div>
|
|
221
367
|
</template>
|
|
@@ -2672,7 +2672,7 @@ function setupAutoWrapping(doc: Document) {
|
|
|
2672
2672
|
const paragraphDirection = paragraph.getAttribute('dir') as 'ltr' | 'rtl'
|
|
2673
2673
|
|| getTextDirection(paragraph.textContent || '', (doc.body.dir || 'ltr') as 'ltr' | 'rtl')
|
|
2674
2674
|
|
|
2675
|
-
let newParagraph = doc.createElement('p')
|
|
2675
|
+
let newParagraph: HTMLElement = doc.createElement('p')
|
|
2676
2676
|
newParagraph.dir = paragraphDirection
|
|
2677
2677
|
if (paragraph.hasAttribute('data-dir-explicit')) {
|
|
2678
2678
|
newParagraph.setAttribute('data-dir-explicit', 'true')
|