@bagelink/vue 0.0.1216 → 0.0.1220
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 +510 -0
- package/dist/components/Calendar/Index.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/header/Header.vue.d.ts +117 -0
- package/dist/components/Calendar/components/header/Header.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/month/AgendaEventTile.vue.d.ts +37 -0
- package/dist/components/Calendar/components/month/AgendaEventTile.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/month/AgendaEvents.vue.d.ts +37 -0
- package/dist/components/Calendar/components/month/AgendaEvents.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/month/Day.vue.d.ts +84 -0
- package/dist/components/Calendar/components/month/Day.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/month/Event.vue.d.ts +69 -0
- package/dist/components/Calendar/components/month/Event.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/month/Month.vue.d.ts +134 -0
- package/dist/components/Calendar/components/month/Month.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/month/WeekDay.vue.d.ts +7 -0
- package/dist/components/Calendar/components/month/WeekDay.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/partials/EventFlyout.vue.d.ts +122 -0
- package/dist/components/Calendar/components/partials/EventFlyout.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/week/Day.vue.d.ts +152 -0
- package/dist/components/Calendar/components/week/Day.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/week/DayEvent.vue.d.ts +136 -0
- package/dist/components/Calendar/components/week/DayEvent.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/week/DayTimeline.vue.d.ts +23 -0
- package/dist/components/Calendar/components/week/DayTimeline.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/week/FullDayEvent.vue.d.ts +42 -0
- package/dist/components/Calendar/components/week/FullDayEvent.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/week/Week.vue.d.ts +196 -0
- package/dist/components/Calendar/components/week/Week.vue.d.ts.map +1 -0
- package/dist/components/Calendar/components/week/WeekTimeline.vue.d.ts +21 -0
- package/dist/components/Calendar/components/week/WeekTimeline.vue.d.ts.map +1 -0
- package/dist/components/Calendar/constants.d.ts +13 -0
- package/dist/components/Calendar/constants.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/DayIntervals.d.ts +17 -0
- package/dist/components/Calendar/helpers/DayIntervals.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/EDate.d.ts +10 -0
- package/dist/components/Calendar/helpers/EDate.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/Errors.d.ts +18 -0
- package/dist/components/Calendar/helpers/Errors.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/EventChange.d.ts +19 -0
- package/dist/components/Calendar/helpers/EventChange.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/EventConcurrency.d.ts +12 -0
- package/dist/components/Calendar/helpers/EventConcurrency.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/EventFlyoutPosition.d.ts +14 -0
- package/dist/components/Calendar/helpers/EventFlyoutPosition.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/EventPosition.d.ts +11 -0
- package/dist/components/Calendar/helpers/EventPosition.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/EventsFilter.d.ts +11 -0
- package/dist/components/Calendar/helpers/EventsFilter.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/Helpers.d.ts +19 -0
- package/dist/components/Calendar/helpers/Helpers.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/Time.d.ts +118 -0
- package/dist/components/Calendar/helpers/Time.d.ts.map +1 -0
- package/dist/components/Calendar/helpers/Week.d.ts +10 -0
- package/dist/components/Calendar/helpers/Week.d.ts.map +1 -0
- package/dist/components/Calendar/index.d.ts +4 -0
- package/dist/components/Calendar/index.d.ts.map +1 -0
- package/dist/components/Calendar/language/index.d.ts +6 -0
- package/dist/components/Calendar/language/index.d.ts.map +1 -0
- package/dist/components/Calendar/language/keys.d.ts +90 -0
- package/dist/components/Calendar/language/keys.d.ts.map +1 -0
- package/dist/components/Calendar/models/Event.d.ts +50 -0
- package/dist/components/Calendar/models/Event.d.ts.map +1 -0
- package/dist/components/Calendar/typings/config.interface.d.ts +77 -0
- package/dist/components/Calendar/typings/config.interface.d.ts.map +1 -0
- package/dist/components/Calendar/typings/interfaces/day.interface.d.ts +10 -0
- package/dist/components/Calendar/typings/interfaces/day.interface.d.ts.map +1 -0
- package/dist/components/Calendar/typings/interfaces/event.interface.d.ts +32 -0
- package/dist/components/Calendar/typings/interfaces/event.interface.d.ts.map +1 -0
- package/dist/components/Calendar/typings/interfaces/full-day-events-week.type.d.ts +7 -0
- package/dist/components/Calendar/typings/interfaces/full-day-events-week.type.d.ts.map +1 -0
- package/dist/components/Calendar/typings/interfaces/period.interface.d.ts +6 -0
- package/dist/components/Calendar/typings/interfaces/period.interface.d.ts.map +1 -0
- package/dist/components/Calendar/typings/interfaces/time-modes.d.ts +6 -0
- package/dist/components/Calendar/typings/interfaces/time-modes.d.ts.map +1 -0
- package/dist/components/Calendar/typings/types.d.ts +21 -0
- package/dist/components/Calendar/typings/types.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/Draggable/useDraggable.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePick.vue.d.ts +8 -0
- package/dist/components/form/inputs/DatePick.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/NumberInput.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/directives/index.d.ts +2 -0
- package/dist/directives/index.d.ts.map +1 -1
- package/dist/directives/vResize.d.ts +18 -0
- package/dist/directives/vResize.d.ts.map +1 -0
- package/dist/index.cjs +3657 -169
- package/dist/index.mjs +3658 -170
- package/dist/style.css +843 -77
- package/package.json +2 -1
- package/src/components/Calendar/Index.vue +420 -0
- package/src/components/Calendar/assets/base.css +60 -0
- package/src/components/Calendar/components/header/Header.vue +274 -0
- package/src/components/Calendar/components/month/AgendaEventTile.vue +137 -0
- package/src/components/Calendar/components/month/AgendaEvents.vue +107 -0
- package/src/components/Calendar/components/month/Day.vue +271 -0
- package/src/components/Calendar/components/month/Event.vue +221 -0
- package/src/components/Calendar/components/month/Month.vue +278 -0
- package/src/components/Calendar/components/month/WeekDay.vue +25 -0
- package/src/components/Calendar/components/partials/EventFlyout.vue +429 -0
- package/src/components/Calendar/components/week/Day.vue +212 -0
- package/src/components/Calendar/components/week/DayEvent.vue +585 -0
- package/src/components/Calendar/components/week/DayTimeline.vue +86 -0
- package/src/components/Calendar/components/week/FullDayEvent.vue +121 -0
- package/src/components/Calendar/components/week/Week.vue +414 -0
- package/src/components/Calendar/components/week/WeekTimeline.vue +126 -0
- package/src/components/Calendar/constants.ts +13 -0
- package/src/components/Calendar/env.d.ts +8 -0
- package/src/components/Calendar/helpers/DayIntervals.ts +48 -0
- package/src/components/Calendar/helpers/EDate.ts +18 -0
- package/src/components/Calendar/helpers/Errors.ts +69 -0
- package/src/components/Calendar/helpers/EventChange.ts +88 -0
- package/src/components/Calendar/helpers/EventConcurrency.ts +69 -0
- package/src/components/Calendar/helpers/EventFlyoutPosition.ts +96 -0
- package/src/components/Calendar/helpers/EventPosition.ts +154 -0
- package/src/components/Calendar/helpers/EventsFilter.ts +50 -0
- package/src/components/Calendar/helpers/Helpers.ts +86 -0
- package/src/components/Calendar/helpers/Time.ts +588 -0
- package/src/components/Calendar/helpers/Week.ts +37 -0
- package/src/components/Calendar/index.ts +4 -0
- package/src/components/Calendar/language/index.ts +37 -0
- package/src/components/Calendar/language/keys.ts +90 -0
- package/src/components/Calendar/models/Event.ts +112 -0
- package/src/components/Calendar/styles/_mixins.css +21 -0
- package/src/components/Calendar/styles/_variables.css +51 -0
- package/src/components/Calendar/typings/config.interface.ts +87 -0
- package/src/components/Calendar/typings/interfaces/day.interface.ts +10 -0
- package/src/components/Calendar/typings/interfaces/event.interface.ts +32 -0
- package/src/components/Calendar/typings/interfaces/full-day-events-week.type.ts +8 -0
- package/src/components/Calendar/typings/interfaces/period.interface.ts +5 -0
- package/src/components/Calendar/typings/interfaces/time-modes.ts +9 -0
- package/src/components/Calendar/typings/types.ts +23 -0
- package/src/components/DataTable/DataTable.vue +4 -0
- package/src/components/Draggable/useDraggable.ts +53 -37
- package/src/components/form/inputs/DatePick.vue +189 -152
- package/src/components/form/inputs/NumberInput.vue +1 -3
- package/src/components/index.ts +3 -6
- package/src/directives/index.ts +2 -0
- package/src/directives/vResize.ts +205 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PropType } from 'vue'
|
|
3
|
+
import type Time from '../../helpers/Time'
|
|
4
|
+
import type { ConfigInterface } from '../../typings/config.interface'
|
|
5
|
+
import type { EventInterface } from '../../typings/interfaces/event.interface'
|
|
6
|
+
import { Icon } from '@bagelink/vue'
|
|
7
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
|
8
|
+
import { EVENT_COLORS } from '../../constants'
|
|
9
|
+
import EventFlyoutPosition, { EVENT_FLYOUT_WIDTH } from '../../helpers/EventFlyoutPosition'
|
|
10
|
+
import Helpers from '../../helpers/Helpers'
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
calendarEventProp: {
|
|
14
|
+
type: Object as PropType<EventInterface | null>,
|
|
15
|
+
default: () => ({}),
|
|
16
|
+
},
|
|
17
|
+
eventElement: {
|
|
18
|
+
type: Object as PropType<HTMLElement | any>,
|
|
19
|
+
default: null,
|
|
20
|
+
},
|
|
21
|
+
time: {
|
|
22
|
+
type: Object as PropType<Time>,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
config: {
|
|
26
|
+
type: Object as PropType<ConfigInterface>,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits(['hide', 'editEvent', 'deleteEvent'])
|
|
32
|
+
|
|
33
|
+
const eventFlyoutPositionHelper = new EventFlyoutPosition()
|
|
34
|
+
|
|
35
|
+
const isVisible = ref(false)
|
|
36
|
+
const top = ref<number | null>(0)
|
|
37
|
+
const left = ref<number | null>(0)
|
|
38
|
+
const calendarEvent = ref(props.calendarEventProp)
|
|
39
|
+
const flyoutWidth = `${EVENT_FLYOUT_WIDTH}px`
|
|
40
|
+
const colors = EVENT_COLORS
|
|
41
|
+
|
|
42
|
+
const icons = {
|
|
43
|
+
clock: 'clock',
|
|
44
|
+
user: 'user',
|
|
45
|
+
description: 'comment',
|
|
46
|
+
trash: 'delete',
|
|
47
|
+
edit: 'edit',
|
|
48
|
+
times: 'close',
|
|
49
|
+
topic: 'help',
|
|
50
|
+
location: 'location_on',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const getEventTime = computed(() => {
|
|
54
|
+
if (!calendarEvent.value || !calendarEvent.value.time) return null
|
|
55
|
+
|
|
56
|
+
const eventType = Helpers.getEventType(calendarEvent.value, props.time)
|
|
57
|
+
|
|
58
|
+
if (['MULTI_DAY_TIMED'].includes(eventType)) {
|
|
59
|
+
const startLocalizedString = `${getDateFromDateString(
|
|
60
|
+
calendarEvent.value.time.start
|
|
61
|
+
)} ${props.time.getLocalizedTime(calendarEvent.value.time.start)}`
|
|
62
|
+
const endLocalizedString = `${getDateFromDateString(
|
|
63
|
+
calendarEvent.value.time.end
|
|
64
|
+
)} ${props.time.getLocalizedTime(calendarEvent.value.time.end)}`
|
|
65
|
+
|
|
66
|
+
return `${startLocalizedString} - ${endLocalizedString}`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (['SINGLE_DAY_FULL_DAY', 'MULTI_DAY_FULL_DAY'].includes(eventType)) {
|
|
70
|
+
const startDate = getDateFromDateString(calendarEvent.value.time.start)
|
|
71
|
+
const endDate = getDateFromDateString(calendarEvent.value.time.end)
|
|
72
|
+
|
|
73
|
+
if (startDate === endDate) return startDate
|
|
74
|
+
|
|
75
|
+
return `${startDate} - ${endDate}`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dateString = getDateFromDateString(calendarEvent.value.time.start)
|
|
79
|
+
const timeString = props.time.getLocalizedTimeRange(
|
|
80
|
+
calendarEvent.value.time.start,
|
|
81
|
+
calendarEvent.value.time.end
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return `${dateString} ⋅ ${timeString}`
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const eventFlyoutInlineStyles = computed(() => {
|
|
88
|
+
if (typeof top.value === 'number' && !left.value) {
|
|
89
|
+
return {
|
|
90
|
+
top: `${top.value}px`,
|
|
91
|
+
left: '50%',
|
|
92
|
+
position: 'fixed' as const,
|
|
93
|
+
transform: 'translateX(-50%)',
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
top: `${top.value}px`,
|
|
99
|
+
left: `${left.value}px`,
|
|
100
|
+
position: 'fixed' as const,
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const isEditable = computed(() => props.calendarEventProp?.isEditable || false)
|
|
105
|
+
|
|
106
|
+
const eventBackgroundColor = computed(() => {
|
|
107
|
+
if (
|
|
108
|
+
calendarEvent.value?.colorScheme
|
|
109
|
+
&& props.config.style?.colorSchemes
|
|
110
|
+
&& props.config.style.colorSchemes[calendarEvent.value.colorScheme]
|
|
111
|
+
) {
|
|
112
|
+
return props.config.style.colorSchemes[calendarEvent.value.colorScheme]
|
|
113
|
+
.backgroundColor
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return colors[calendarEvent.value?.color || 'blue']
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
function setFlyoutPosition() {
|
|
120
|
+
const calendar = props.eventElement?.closest('.calendar-root')
|
|
121
|
+
const flyout = document.querySelector('.event-flyout')
|
|
122
|
+
|
|
123
|
+
if (!props.eventElement) return
|
|
124
|
+
|
|
125
|
+
const flyoutPosition = eventFlyoutPositionHelper.calculateFlyoutPosition(
|
|
126
|
+
props.eventElement?.getBoundingClientRect(),
|
|
127
|
+
{
|
|
128
|
+
height: flyout?.clientHeight || 300,
|
|
129
|
+
width: flyout?.clientWidth || 0,
|
|
130
|
+
},
|
|
131
|
+
calendar ? calendar.getBoundingClientRect() : null
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
top.value = typeof flyoutPosition?.top === 'number' ? flyoutPosition.top : null
|
|
135
|
+
left.value = typeof flyoutPosition?.left === 'number' ? flyoutPosition.left : null
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function editEvent() {
|
|
139
|
+
emit('editEvent', calendarEvent.value?.id)
|
|
140
|
+
closeFlyout()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function deleteEvent() {
|
|
144
|
+
emit('deleteEvent', calendarEvent.value?.id)
|
|
145
|
+
closeFlyout()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function closeFlyout() {
|
|
149
|
+
isVisible.value = false
|
|
150
|
+
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
emit('hide')
|
|
153
|
+
}, 100)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function getDateFromDateString(dateString: string) {
|
|
157
|
+
const { year, month, date } = props.time.getAllVariablesFromDateTimeString(dateString)
|
|
158
|
+
|
|
159
|
+
return new Date(year, month, date).toLocaleDateString(
|
|
160
|
+
props.time.CALENDAR_LOCALE,
|
|
161
|
+
{
|
|
162
|
+
year: 'numeric',
|
|
163
|
+
month: 'long',
|
|
164
|
+
day: 'numeric',
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function closeFlyoutOnClickOutside(e: any) {
|
|
170
|
+
const flyout = document.querySelector('.event-flyout')
|
|
171
|
+
if (!flyout || !isVisible.value) return
|
|
172
|
+
|
|
173
|
+
const isClickOutside = !flyout.contains(e.target)
|
|
174
|
+
const isClickOnEvent = !!e.target.closest('.is-event')
|
|
175
|
+
const closeOnClickOutside = props.config.eventDialog?.closeOnClickOutside ?? true
|
|
176
|
+
|
|
177
|
+
if (isVisible.value && isClickOutside && !isClickOnEvent && closeOnClickOutside) {
|
|
178
|
+
closeFlyout()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Watch for changes
|
|
183
|
+
watch(
|
|
184
|
+
() => props.calendarEventProp,
|
|
185
|
+
(value) => {
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
calendarEvent.value = value
|
|
188
|
+
isVisible.value = !!value
|
|
189
|
+
nextTick(() => { setFlyoutPosition() })
|
|
190
|
+
}, 10)
|
|
191
|
+
},
|
|
192
|
+
{ deep: true }
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
// Lifecycle hooks
|
|
196
|
+
onMounted(() => {
|
|
197
|
+
document.addEventListener('click', closeFlyoutOnClickOutside)
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
onBeforeUnmount(() => {
|
|
201
|
+
document.removeEventListener('click', closeFlyoutOnClickOutside)
|
|
202
|
+
})
|
|
203
|
+
</script>
|
|
204
|
+
|
|
205
|
+
<template>
|
|
206
|
+
<div
|
|
207
|
+
class="event-flyout p-05 bg-white"
|
|
208
|
+
:class="{ 'is-visible': isVisible, 'is-not-editable': !isEditable }"
|
|
209
|
+
:style="eventFlyoutInlineStyles"
|
|
210
|
+
>
|
|
211
|
+
<div
|
|
212
|
+
v-if="!config.eventDialog || !config.eventDialog.isCustom"
|
|
213
|
+
class="event-flyout__relative-wrapper"
|
|
214
|
+
>
|
|
215
|
+
<div class="event-flyout__menu">
|
|
216
|
+
<span
|
|
217
|
+
v-if="isEditable"
|
|
218
|
+
class="event-flyout__menu-editable"
|
|
219
|
+
>
|
|
220
|
+
<Icon
|
|
221
|
+
class="event-flyout__menu-item is-edit-icon"
|
|
222
|
+
:icon="icons.edit"
|
|
223
|
+
@click="editEvent"
|
|
224
|
+
/>
|
|
225
|
+
|
|
226
|
+
<Icon
|
|
227
|
+
class="event-flyout__menu-item is-trash-icon"
|
|
228
|
+
:icon="icons.trash"
|
|
229
|
+
@click="deleteEvent"
|
|
230
|
+
/>
|
|
231
|
+
</span>
|
|
232
|
+
|
|
233
|
+
<span class="event-flyout__menu-close">
|
|
234
|
+
<Icon
|
|
235
|
+
class="event-flyout__menu-item is-times-icon"
|
|
236
|
+
:icon="icons.times"
|
|
237
|
+
@click="closeFlyout"
|
|
238
|
+
/>
|
|
239
|
+
</span>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div
|
|
243
|
+
v-if="calendarEvent"
|
|
244
|
+
class="event-flyout__info-wrapper"
|
|
245
|
+
>
|
|
246
|
+
<div
|
|
247
|
+
v-if="calendarEvent.title"
|
|
248
|
+
class="event-flyout__row is-title"
|
|
249
|
+
>
|
|
250
|
+
<div
|
|
251
|
+
class="event-flyout__color-icon"
|
|
252
|
+
:style="{ backgroundColor: eventBackgroundColor }"
|
|
253
|
+
/>
|
|
254
|
+
{{ calendarEvent.title }}
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<div
|
|
258
|
+
v-if="calendarEvent.time"
|
|
259
|
+
class="event-flyout__row is-time"
|
|
260
|
+
>
|
|
261
|
+
{{ getEventTime }}
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<div
|
|
265
|
+
v-if="calendarEvent.location"
|
|
266
|
+
class="event-flyout__row is-location"
|
|
267
|
+
>
|
|
268
|
+
<Icon :icon="icons.location" />
|
|
269
|
+
{{ calendarEvent.location }}
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<div
|
|
273
|
+
v-if="calendarEvent.with"
|
|
274
|
+
class="event-flyout__row is-with"
|
|
275
|
+
>
|
|
276
|
+
<Icon :icon="icons.user" />
|
|
277
|
+
{{ calendarEvent.with }}
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<div
|
|
281
|
+
v-if="calendarEvent.topic"
|
|
282
|
+
class="event-flyout__row is-topic"
|
|
283
|
+
>
|
|
284
|
+
<Icon :icon="icons.topic" />
|
|
285
|
+
{{ calendarEvent.topic }}
|
|
286
|
+
</div>
|
|
287
|
+
|
|
288
|
+
<div
|
|
289
|
+
v-if="calendarEvent.description"
|
|
290
|
+
class="event-flyout__row is-description"
|
|
291
|
+
>
|
|
292
|
+
<Icon :icon="icons.description" />
|
|
293
|
+
<p v-html="calendarEvent.description" />
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
<slot
|
|
299
|
+
v-else
|
|
300
|
+
:event-dialog-data="calendarEvent"
|
|
301
|
+
:close-event-dialog="closeFlyout"
|
|
302
|
+
/>
|
|
303
|
+
</div>
|
|
304
|
+
</template>
|
|
305
|
+
|
|
306
|
+
<style>
|
|
307
|
+
.event-flyout {
|
|
308
|
+
position: fixed;
|
|
309
|
+
z-index: 50;
|
|
310
|
+
background-color: #fff;
|
|
311
|
+
max-height: 100%;
|
|
312
|
+
width: v-bind(flyoutWidth);
|
|
313
|
+
max-width: 98%;
|
|
314
|
+
border: var(--qalendar-border-gray-thin);
|
|
315
|
+
border-radius: 8px;
|
|
316
|
+
box-shadow: 0 12px 24px rgb(0 0 0 / 9%), 0 6px 12px rgb(0 0 0 / 18%);
|
|
317
|
+
overflow: hidden;
|
|
318
|
+
transition: all 0.2s ease;
|
|
319
|
+
transition-property: opacity, transform;
|
|
320
|
+
transform: translateY(-40px);
|
|
321
|
+
opacity: 0;
|
|
322
|
+
pointer-events: none;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
@media (prefers-color-scheme: dark) {
|
|
326
|
+
.event-flyout {
|
|
327
|
+
background-color: var(--qalendar-dark-mode-elevated-surface);
|
|
328
|
+
border-color: transparent;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.event-flyout.is-visible {
|
|
333
|
+
opacity: 1;
|
|
334
|
+
transform: translateY(0);
|
|
335
|
+
pointer-events: initial;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.event-flyout__relative-wrapper {
|
|
339
|
+
position: relative;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.event-flyout__menu {
|
|
343
|
+
display: flex;
|
|
344
|
+
justify-content: space-between;
|
|
345
|
+
align-items: center;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.event-flyout__menu-editable,
|
|
349
|
+
.event-flyout__menu-close {
|
|
350
|
+
padding: var(--qalendar-spacing) var(--qalendar-spacing) 0 var(--qalendar-spacing);
|
|
351
|
+
display: flex;
|
|
352
|
+
gap: 20px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.is-not-editable .event-flyout__menu-close {
|
|
356
|
+
position: absolute;
|
|
357
|
+
top: 0;
|
|
358
|
+
right: 0;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.event-flyout__menu-item {
|
|
362
|
+
font-size: var(--qalendar-font-l);
|
|
363
|
+
color: gray;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
@media (prefers-color-scheme: dark) {
|
|
367
|
+
.event-flyout__menu-item {
|
|
368
|
+
color: var(--qalendar-dark-mode-text-hint);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.event-flyout__menu-item:hover {
|
|
373
|
+
color: var(--qalendar-theme-color);
|
|
374
|
+
cursor: pointer;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.is-trash-icon:hover {
|
|
378
|
+
color: red;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.event-flyout__info-wrapper {
|
|
382
|
+
padding: var(--qalendar-spacing);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.event-flyout__row {
|
|
386
|
+
display: flex;
|
|
387
|
+
gap: var(--qalendar-spacing);
|
|
388
|
+
margin-bottom: 0.25em;
|
|
389
|
+
font-weight: 400;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.event-flyout__row p {
|
|
393
|
+
margin: 0;
|
|
394
|
+
padding: 0;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.event-flyout__row svg {
|
|
398
|
+
margin-top: 0.1rem;
|
|
399
|
+
color: #5f6368;
|
|
400
|
+
width: 14px;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
@media (prefers-color-scheme: dark) {
|
|
404
|
+
.event-flyout__row svg {
|
|
405
|
+
color: var(--qalendar-dark-mode-text-hint);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.event-flyout__color-icon {
|
|
410
|
+
--icon-height: 16px;
|
|
411
|
+
border-radius: 50%;
|
|
412
|
+
height: var(--icon-height);
|
|
413
|
+
width: var(--icon-height);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.is-title {
|
|
417
|
+
font-size: var(--qalendar-font-l);
|
|
418
|
+
align-items: center;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.is-not-editable .is-title {
|
|
422
|
+
max-width: 90%;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.is-time {
|
|
426
|
+
font-size: var(--qalendar-font-s);
|
|
427
|
+
margin-bottom: 0.75em;
|
|
428
|
+
}
|
|
429
|
+
</style>
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PropType } from 'vue'
|
|
3
|
+
import type { Interval } from '../../helpers/DayIntervals'
|
|
4
|
+
import type Time from '../../helpers/Time'
|
|
5
|
+
import type { ConfigInterface, DayIntervalsType } from '../../typings/config.interface'
|
|
6
|
+
import type { DayInterface } from '../../typings/interfaces/day.interface'
|
|
7
|
+
import type { EventInterface } from '../../typings/interfaces/event.interface'
|
|
8
|
+
import type { DayInfo, modeType } from '../../typings/types'
|
|
9
|
+
import { ref, computed, onMounted } from 'vue'
|
|
10
|
+
import DayIntervals from '../../helpers/DayIntervals'
|
|
11
|
+
import EventConcurrency from '../../helpers/EventConcurrency'
|
|
12
|
+
import DayEvent from './DayEvent.vue'
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
day: {
|
|
16
|
+
type: Object as PropType<DayInterface>,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
time: {
|
|
20
|
+
type: Object as PropType<Time>,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
config: {
|
|
24
|
+
type: Object as PropType<ConfigInterface>,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
dayInfo: {
|
|
28
|
+
type: Object as PropType<DayInfo>,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
mode: {
|
|
32
|
+
type: String as PropType<modeType>,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
dayIntervals: {
|
|
36
|
+
type: Object as PropType<DayIntervalsType>,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
weekHeight: {
|
|
40
|
+
type: Number,
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const emit = defineEmits([
|
|
46
|
+
'eventWasClicked',
|
|
47
|
+
'eventWasResized',
|
|
48
|
+
'eventWasDragged',
|
|
49
|
+
'intervalWasClicked',
|
|
50
|
+
'dayWasClicked',
|
|
51
|
+
'datetimeWasClicked',
|
|
52
|
+
'dragStart',
|
|
53
|
+
'dragEnd',
|
|
54
|
+
])
|
|
55
|
+
|
|
56
|
+
const eventConcurrencyHelper = new EventConcurrency()
|
|
57
|
+
|
|
58
|
+
const events = ref<EventInterface[]>([])
|
|
59
|
+
const intervals = ref<Interval[]>([])
|
|
60
|
+
|
|
61
|
+
const intervalStyles = computed(() => {
|
|
62
|
+
return props.config.dayIntervals?.intervalStyles
|
|
63
|
+
? props.config.dayIntervals.intervalStyles
|
|
64
|
+
: {}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
function calculateEventConcurrency() {
|
|
68
|
+
events.value = eventConcurrencyHelper.calculateConcurrencyForEvents(
|
|
69
|
+
props.day.events
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function handleEventWasResized(event: any) {
|
|
74
|
+
emit('eventWasResized', event)
|
|
75
|
+
calculateEventConcurrency()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function handleClickOnInterval(payload: Interval) {
|
|
79
|
+
const { intervalStart, intervalEnd } = payload
|
|
80
|
+
emit('intervalWasClicked', { intervalStart, intervalEnd })
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function setClickableIntervals() {
|
|
84
|
+
let dayStartTimeString = props.day.dateTimeString
|
|
85
|
+
if (props.time.DAY_START !== 0) {
|
|
86
|
+
const { hour: startHour } = props.time.getHourAndMinutesFromTimePoints(props.time.DAY_START)
|
|
87
|
+
dayStartTimeString = props.time.setSegmentOfDateTimeString(dayStartTimeString, { hour: startHour })
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
intervals.value = new DayIntervals(
|
|
91
|
+
props.dayIntervals.length || 60,
|
|
92
|
+
dayStartTimeString,
|
|
93
|
+
props.time.HOURS_PER_DAY,
|
|
94
|
+
).getIntervals()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getDateStringForFlexibleDayBoundaries(dateString: string, timeClickedHHMM: string) {
|
|
98
|
+
const hourTwoDigits = props.time.doubleDigit(props.time.DAY_START / 100)
|
|
99
|
+
const dayStartTimeHHMM = `${hourTwoDigits}:00`
|
|
100
|
+
const isClickOnNextDay = timeClickedHHMM < dayStartTimeHHMM
|
|
101
|
+
|
|
102
|
+
if (isClickOnNextDay) {
|
|
103
|
+
dateString = props.time.dateStringFrom(
|
|
104
|
+
props.time.addDaysToDateTimeString(1, dateString)
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return dateString
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function handleClickOnDay(event: MouseEvent) {
|
|
112
|
+
const timeClicked = props.time.getTimeFromClick(event.offsetY, props.weekHeight)
|
|
113
|
+
let dateString = props.time.dateStringFrom(props.day.dateTimeString)
|
|
114
|
+
const isFlexibleDay = props.time.DAY_END <= props.time.DAY_START
|
|
115
|
+
if (isFlexibleDay) dateString = getDateStringForFlexibleDayBoundaries(dateString, timeClicked)
|
|
116
|
+
const dateTimeString = `${dateString} ${timeClicked}`
|
|
117
|
+
|
|
118
|
+
emit('dayWasClicked', dateString)
|
|
119
|
+
emit('datetimeWasClicked', dateTimeString)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onMounted(() => {
|
|
123
|
+
calculateEventConcurrency()
|
|
124
|
+
if (props.dayIntervals.displayClickableInterval) setClickableIntervals()
|
|
125
|
+
})
|
|
126
|
+
</script>
|
|
127
|
+
|
|
128
|
+
<template>
|
|
129
|
+
<div
|
|
130
|
+
class="calendar-week__day"
|
|
131
|
+
@click.self="handleClickOnDay"
|
|
132
|
+
>
|
|
133
|
+
<DayEvent
|
|
134
|
+
v-for="(event, eventIndex) in events"
|
|
135
|
+
:key="eventIndex"
|
|
136
|
+
data-test="day-event"
|
|
137
|
+
:event-prop="event"
|
|
138
|
+
:day="day"
|
|
139
|
+
:time="time"
|
|
140
|
+
:config="config"
|
|
141
|
+
:day-info="dayInfo"
|
|
142
|
+
:mode="mode"
|
|
143
|
+
@eventWasClicked="$emit('eventWasClicked', $event)"
|
|
144
|
+
@eventWasDragged="$emit('eventWasDragged', $event)"
|
|
145
|
+
@eventWasResized="handleEventWasResized"
|
|
146
|
+
@dragStart="$emit('dragStart')"
|
|
147
|
+
@dragEnd="$emit('dragEnd')"
|
|
148
|
+
>
|
|
149
|
+
<template #weekDayEvent="p">
|
|
150
|
+
<slot
|
|
151
|
+
:event-data="p.eventData"
|
|
152
|
+
name="weekDayEvent"
|
|
153
|
+
/>
|
|
154
|
+
</template>
|
|
155
|
+
</DayEvent>
|
|
156
|
+
|
|
157
|
+
<template v-if="dayIntervals && dayIntervals.displayClickableInterval">
|
|
158
|
+
<div
|
|
159
|
+
v-for="(interval, intervalIndex) in intervals"
|
|
160
|
+
:id="`interval-${intervalIndex}`"
|
|
161
|
+
:key="interval.intervalStart"
|
|
162
|
+
class="calendar-week__day-interval"
|
|
163
|
+
:class="{ 'has-border': interval.hasBorder }"
|
|
164
|
+
:style="intervalStyles"
|
|
165
|
+
@click="handleClickOnInterval(interval)"
|
|
166
|
+
>
|
|
167
|
+
{{ time.getLocalizedTime(interval.intervalStart) }}
|
|
168
|
+
</div>
|
|
169
|
+
</template>
|
|
170
|
+
</div>
|
|
171
|
+
</template>
|
|
172
|
+
|
|
173
|
+
<style scoped>
|
|
174
|
+
.calendar-week__day {
|
|
175
|
+
position: relative;
|
|
176
|
+
width: 100%;
|
|
177
|
+
height: 100%;
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.calendar-week__day .calendar-week__day-interval {
|
|
183
|
+
flex: 1;
|
|
184
|
+
font-size: var(--qalendar-font-xs);
|
|
185
|
+
color: var(--qalendar-gray);
|
|
186
|
+
padding: 2px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.calendar-week__day .calendar-week__day-interval.has-border {
|
|
190
|
+
border-bottom: var(--qalendar-border-dashed-gray-thin);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.calendar-week__day:first-child {
|
|
194
|
+
border-left: 1px dashed rgb(224 224 224);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@media (prefers-color-scheme: dark) {
|
|
198
|
+
.calendar-week__day:first-child {
|
|
199
|
+
border-color: var(--qalendar-dark-mode-line-color);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.calendar-week__day:not(:last-child) {
|
|
204
|
+
border-right: 1px dashed rgb(224 224 224);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@media (prefers-color-scheme: dark) {
|
|
208
|
+
.calendar-week__day:not(:last-child) {
|
|
209
|
+
border-color: var(--qalendar-dark-mode-line-color);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
</style>
|