@bagelink/vue 1.2.15 → 1.2.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.
- package/dist/components/calendar/CalendarTypes.d.ts +13 -0
- package/dist/components/calendar/CalendarTypes.d.ts.map +1 -0
- package/dist/components/calendar/Index.vue.d.ts +39 -507
- package/dist/components/calendar/Index.vue.d.ts.map +1 -1
- package/dist/components/calendar/utils.d.ts +31 -0
- package/dist/components/calendar/utils.d.ts.map +1 -0
- package/dist/components/calendar/views/AgendaView.vue.d.ts +16 -0
- package/dist/components/calendar/views/AgendaView.vue.d.ts.map +1 -0
- package/dist/components/calendar/views/DayView.vue.d.ts +50 -0
- package/dist/components/calendar/views/DayView.vue.d.ts.map +1 -0
- package/dist/components/calendar/views/MonthView.vue.d.ts +20 -0
- package/dist/components/calendar/views/MonthView.vue.d.ts.map +1 -0
- package/dist/components/calendar/views/WeekView.vue.d.ts +33 -0
- package/dist/components/calendar/views/WeekView.vue.d.ts.map +1 -0
- package/dist/components/form/BglMultiStepForm.vue.d.ts +63 -0
- package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -0
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePicker.vue.d.ts +3 -3
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/index.cjs +2241 -3891
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2242 -3892
- package/dist/style.css +567 -633
- package/dist/utils/BagelFormUtils.d.ts +4 -2
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/dist/utils/calendar/EDate.d.ts +2 -0
- package/dist/utils/calendar/EDate.d.ts.map +1 -0
- package/dist/utils/calendar/Helpers.d.ts +19 -0
- package/dist/utils/calendar/Helpers.d.ts.map +1 -0
- package/dist/utils/calendar/constants.d.ts +3 -0
- package/dist/utils/calendar/constants.d.ts.map +1 -0
- package/dist/utils/calendar/dateUtils.d.ts +30 -0
- package/dist/utils/calendar/dateUtils.d.ts.map +1 -0
- package/dist/utils/calendar/event.interface.d.ts +32 -0
- package/dist/utils/calendar/event.interface.d.ts.map +1 -0
- package/dist/utils/calendar/time.d.ts +117 -0
- package/dist/utils/calendar/time.d.ts.map +1 -0
- package/dist/utils/calendar/types.d.ts +27 -0
- package/dist/utils/calendar/types.d.ts.map +1 -0
- package/dist/utils/calendar/typings.d.ts +87 -0
- package/dist/utils/calendar/typings.d.ts.map +1 -0
- package/dist/utils/calendar/week.d.ts +117 -0
- package/dist/utils/calendar/week.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/calendar/CalendarTypes.ts +13 -0
- package/src/components/calendar/Index.vue +124 -389
- package/src/components/calendar/utils.ts +70 -0
- package/src/components/calendar/views/AgendaView.vue +263 -0
- package/src/components/calendar/views/DayView.vue +373 -0
- package/src/components/calendar/views/MonthView.vue +313 -0
- package/src/components/calendar/views/WeekView.vue +431 -0
- package/src/components/form/BglMultiStepForm.vue +383 -69
- package/src/components/form/index.ts +1 -0
- package/src/components/form/inputs/CodeEditor/Index.vue +11 -0
- package/src/components/form/inputs/DateInput.vue +3 -3
- package/src/components/form/inputs/DatePicker.vue +35 -30
- package/src/components/form/inputs/SelectInput.vue +2 -0
- package/src/components/form/inputs/Upload/upload.types.d.ts +0 -1
- package/src/index.ts +2 -2
- package/src/styles/inputs.css +138 -137
- package/src/styles/layout.css +3 -2
- package/src/styles/mobilLayout.css +4 -2
- package/src/utils/BagelFormUtils.ts +6 -2
- package/src/utils/calendar/EDate.ts +0 -0
- package/src/{components/calendar/helpers → utils/calendar}/Helpers.ts +6 -6
- package/src/utils/calendar/constants.ts +2 -0
- package/src/utils/{timeAgo.ts → calendar/dateUtils.ts} +38 -1
- package/src/utils/calendar/event.interface.ts +33 -0
- package/src/{components/calendar/helpers/Time.ts → utils/calendar/time.ts} +15 -15
- package/src/utils/calendar/types.ts +27 -0
- package/src/{components/calendar/typings/config.interface.ts → utils/calendar/typings.ts} +13 -6
- package/src/utils/calendar/week.ts +588 -0
- package/src/components/calendar/assets/base.css +0 -60
- package/src/components/calendar/components/header/Header.vue +0 -153
- package/src/components/calendar/components/month/AgendaEventTile.vue +0 -135
- package/src/components/calendar/components/month/AgendaEvents.vue +0 -72
- package/src/components/calendar/components/month/Day.vue +0 -256
- package/src/components/calendar/components/month/Event.vue +0 -164
- package/src/components/calendar/components/month/Month.vue +0 -241
- package/src/components/calendar/components/month/WeekDay.vue +0 -15
- package/src/components/calendar/components/partials/EventFlyout.vue +0 -430
- package/src/components/calendar/components/week/Day.vue +0 -198
- package/src/components/calendar/components/week/DayEvent.vue +0 -584
- package/src/components/calendar/components/week/DayTimeline.vue +0 -80
- package/src/components/calendar/components/week/FullDayEvent.vue +0 -121
- package/src/components/calendar/components/week/Week.vue +0 -414
- package/src/components/calendar/components/week/WeekTimeline.vue +0 -101
- package/src/components/calendar/constants.ts +0 -13
- package/src/components/calendar/helpers/DayIntervals.ts +0 -48
- package/src/components/calendar/helpers/EDate.ts +0 -18
- package/src/components/calendar/helpers/Errors.ts +0 -69
- package/src/components/calendar/helpers/EventChange.ts +0 -88
- package/src/components/calendar/helpers/EventConcurrency.ts +0 -69
- package/src/components/calendar/helpers/EventFlyoutPosition.ts +0 -96
- package/src/components/calendar/helpers/EventPosition.ts +0 -154
- package/src/components/calendar/helpers/EventsFilter.ts +0 -50
- package/src/components/calendar/helpers/Week.ts +0 -37
- package/src/components/calendar/language/index.ts +0 -41
- package/src/components/calendar/language/keys.ts +0 -99
- package/src/components/calendar/models/Event.ts +0 -112
- package/src/components/calendar/styles/_mixins.css +0 -21
- package/src/components/calendar/styles/_variables.css +0 -47
- package/src/components/calendar/typings/interfaces/day.interface.ts +0 -10
- package/src/components/calendar/typings/interfaces/event.interface.ts +0 -32
- package/src/components/calendar/typings/interfaces/full-day-events-week.type.ts +0 -8
- package/src/components/calendar/typings/interfaces/period.interface.ts +0 -5
- package/src/components/calendar/typings/interfaces/time-modes.ts +0 -11
- package/src/components/calendar/typings/types.ts +0 -27
|
@@ -1,584 +0,0 @@
|
|
|
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 type { DayInfo, ModeType } from '../../typings/types'
|
|
7
|
-
import { Icon } from '@bagelink/vue'
|
|
8
|
-
|
|
9
|
-
import { ref, computed, onMounted, watch } from 'vue'
|
|
10
|
-
import { EVENT_COLORS } from '../../constants'
|
|
11
|
-
import { EventChange } from '../../helpers/EventChange'
|
|
12
|
-
import Helpers from '../../helpers/Helpers'
|
|
13
|
-
import { DRAG_N_RESIZE_DIRECTION } from '../../typings/types'
|
|
14
|
-
|
|
15
|
-
const props = defineProps({
|
|
16
|
-
eventProp: {
|
|
17
|
-
type: Object as PropType<EventInterface>,
|
|
18
|
-
required: true,
|
|
19
|
-
},
|
|
20
|
-
time: {
|
|
21
|
-
type: Object as PropType<Time>,
|
|
22
|
-
required: true,
|
|
23
|
-
},
|
|
24
|
-
config: {
|
|
25
|
-
type: Object as PropType<ConfigInterface>,
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
dayInfo: {
|
|
29
|
-
type: Object as PropType<DayInfo>,
|
|
30
|
-
required: true,
|
|
31
|
-
},
|
|
32
|
-
mode: {
|
|
33
|
-
type: String as PropType<ModeType>,
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const emit = defineEmits<{
|
|
39
|
-
(e: 'eventWasClicked', data: { clickedEvent: EventInterface, eventElement: HTMLElement }): void
|
|
40
|
-
(e: 'eventWasResized', event: EventInterface): void
|
|
41
|
-
(e: 'eventWasDragged', event: EventInterface): void
|
|
42
|
-
(e: 'dragStart'): void
|
|
43
|
-
(e: 'dragEnd'): void
|
|
44
|
-
}>()
|
|
45
|
-
|
|
46
|
-
const event = ref(props.eventProp)
|
|
47
|
-
const icons = ref({
|
|
48
|
-
clock: 'clock',
|
|
49
|
-
user: 'user',
|
|
50
|
-
description: 'description',
|
|
51
|
-
location: 'location_on',
|
|
52
|
-
topic: 'topic',
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const showResizeElements = ref(false)
|
|
56
|
-
const eventTransformValue = ref('initial')
|
|
57
|
-
const eventZIndexValue = ref<'initial' | number>('initial')
|
|
58
|
-
const dayElement = ref<Element | null>(null)
|
|
59
|
-
|
|
60
|
-
// Resizing events
|
|
61
|
-
const resizingStartingPoint = ref<undefined | number>(undefined)
|
|
62
|
-
const resizingStartingPointEndOfTime = ref(props.eventProp.time.end)
|
|
63
|
-
const resizingStartingPointStartOfTime = ref(props.eventProp.time.start)
|
|
64
|
-
const resizingDirection = ref('')
|
|
65
|
-
const changeInQuarterHoursEventStart = ref(0)
|
|
66
|
-
const changeInQuarterHoursEventEnd = ref(0)
|
|
67
|
-
const isEditable = ref(props.eventProp.isEditable || false)
|
|
68
|
-
const colors = ref(EVENT_COLORS as { [key: string]: string })
|
|
69
|
-
const eventColor = ref('#fff')
|
|
70
|
-
const eventBackgroundColor = ref('')
|
|
71
|
-
const isResizing = ref(false)
|
|
72
|
-
|
|
73
|
-
// Dragging events
|
|
74
|
-
const canDrag = ref(false)
|
|
75
|
-
const clientYDragStart = ref<null | number>(null)
|
|
76
|
-
const clientXDragStart = ref<null | number>(null)
|
|
77
|
-
const changeInQuartersOnDrag = ref(0)
|
|
78
|
-
const changeInDaysOnDrag = ref(0)
|
|
79
|
-
const timeStartDragStart = ref(props.eventProp.time.start)
|
|
80
|
-
const timeEndDragStart = ref(props.eventProp.time.end)
|
|
81
|
-
|
|
82
|
-
const dragMoveListenerNameAndCallbacks = [
|
|
83
|
-
['mousemove', handleDrag],
|
|
84
|
-
['touchmove', handleDrag],
|
|
85
|
-
['mouseup', onMouseUpWhenDragging],
|
|
86
|
-
['touchend', onMouseUpWhenDragging],
|
|
87
|
-
] as const
|
|
88
|
-
|
|
89
|
-
const eventChangeHelper = computed(() => {
|
|
90
|
-
const eventCurrentDay = props.time.addDaysToDateTimeString(changeInDaysOnDrag.value, props.dayInfo.dateTimeString)
|
|
91
|
-
return new EventChange(props.time, props.time.dateStringFrom(eventCurrentDay))
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
const isCustomEvent = computed(() => {
|
|
95
|
-
if (Array.isArray(props.eventProp.isCustom)) {
|
|
96
|
-
return props.eventProp.isCustom.includes(props.mode)
|
|
97
|
-
}
|
|
98
|
-
return props.eventProp.isCustom || false
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const getEventTime = computed(() => {
|
|
102
|
-
return `${props.time.getLocalizedTime(event.value.time.start)} - ${props.time.getLocalizedTime(event.value.time.end)}`
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
const timePointsInDay = computed(() => props.time.HOURS_PER_DAY * 100)
|
|
106
|
-
const timePointsInOneMinute = computed(() => 100 / 60)
|
|
107
|
-
|
|
108
|
-
const getLeftRule = computed(() => {
|
|
109
|
-
if (!event.value.totalConcurrentEvents || !event.value.nOfPreviousConcurrentEvents) {
|
|
110
|
-
return 0
|
|
111
|
-
}
|
|
112
|
-
return (event.value.nOfPreviousConcurrentEvents / event.value.totalConcurrentEvents) * 100
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
const getWidthRule = computed(() => 100 - getLeftRule.value)
|
|
116
|
-
const getBorderRule = computed(() => !event.value.nOfPreviousConcurrentEvents ? 'none' : '1px solid #fff')
|
|
117
|
-
|
|
118
|
-
const eventIsLongerThan30Minutes = computed(() => {
|
|
119
|
-
const { hour: startHour, minutes: startMinutes } = props.time.getAllVariablesFromDateTimeString(event.value.time.start)
|
|
120
|
-
const { hour: endHour, minutes: endMinutes } = props.time.getAllVariablesFromDateTimeString(event.value.time.end)
|
|
121
|
-
const startDateMS = new Date(0, 0, 0, startHour, startMinutes).getTime()
|
|
122
|
-
const endDateMS = new Date(0, 0, 0, endHour, endMinutes).getTime()
|
|
123
|
-
return endDateMS - startDateMS >= 1800000
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const hasDisabledDragAndDrop = computed(() => {
|
|
127
|
-
return !!(props.eventProp.disableDnD && props.eventProp.disableDnD.includes(props.mode))
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
const hasDisabledResize = computed(() => {
|
|
131
|
-
return !!(props.eventProp.disableResize && props.eventProp.disableResize.includes(props.mode))
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
const requiredStyles = computed(() => ({
|
|
135
|
-
top: getPositionInDay(event.value.time.start),
|
|
136
|
-
height: getLengthOfEvent(event.value.time.start, event.value.time.end),
|
|
137
|
-
// 'inset-inline-start': `${getInlineStartRule.value}%`,
|
|
138
|
-
width: `${getWidthRule.value}%`,
|
|
139
|
-
transform: eventTransformValue.value,
|
|
140
|
-
zIndex: eventZIndexValue.value,
|
|
141
|
-
}))
|
|
142
|
-
|
|
143
|
-
// Methods
|
|
144
|
-
function getPositionInDay(dateTimeString: string) {
|
|
145
|
-
return `${props.time.getPercentageOfDayFromDateTimeString(dateTimeString, props.time.DAY_START, props.time.DAY_END).toString()}%`
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function getLengthOfEvent(start: string, end: string) {
|
|
149
|
-
const startOfEvent = props.time.getPercentageOfDayFromDateTimeString(start, props.time.DAY_START, props.time.DAY_END)
|
|
150
|
-
const endOfEvent = props.time.getPercentageOfDayFromDateTimeString(end, props.time.DAY_START, props.time.DAY_END)
|
|
151
|
-
const length = Math.abs(endOfEvent - startOfEvent)
|
|
152
|
-
return `${length}%`
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function handleClickOnEvent(event: any) {
|
|
156
|
-
const eventElement = getEventElementFromChildElement(event)
|
|
157
|
-
if (!eventElement) return
|
|
158
|
-
emit('eventWasClicked', {
|
|
159
|
-
clickedEvent: props.eventProp,
|
|
160
|
-
eventElement,
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function getEventElementFromChildElement(event: any) {
|
|
165
|
-
const eventTarget = event.target
|
|
166
|
-
if (!eventTarget || typeof eventTarget.className.includes !== 'function') return null
|
|
167
|
-
if (eventTarget.className.includes('.calendar-week__event')) return event.target
|
|
168
|
-
return eventTarget.closest('.calendar-week__event')
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function onMouseMoveResize(event: MouseEvent) {
|
|
172
|
-
const eventsContainer = document.querySelector('.calendar-week__events')
|
|
173
|
-
if (!eventsContainer) return
|
|
174
|
-
|
|
175
|
-
if (typeof resizingStartingPoint.value === 'undefined') {
|
|
176
|
-
resizingStartingPoint.value = event.clientY
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const cursorPositionY = event.clientY
|
|
180
|
-
const nOfPixelsDistance = cursorPositionY - resizingStartingPoint.value
|
|
181
|
-
const eventsContainerHeight = eventsContainer.clientHeight
|
|
182
|
-
const percentageOfDayChanged = (nOfPixelsDistance / eventsContainerHeight) * 100
|
|
183
|
-
const changeInTimePoints = (timePointsInDay.value / 100) * percentageOfDayChanged
|
|
184
|
-
const changeInMinutes = getMinutesFromTimePoints(changeInTimePoints)
|
|
185
|
-
|
|
186
|
-
if (resizingDirection.value === 'down') {
|
|
187
|
-
changeInQuarterHoursEventEnd.value = Math.floor(changeInMinutes / 15)
|
|
188
|
-
} else {
|
|
189
|
-
changeInQuarterHoursEventStart.value = Math.floor(changeInMinutes / 15)
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function onMouseUpWhenResizing() {
|
|
194
|
-
stopResizing()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function resizeEvent(direction: 'down' | 'up') {
|
|
198
|
-
isResizing.value = true
|
|
199
|
-
resizingDirection.value = direction
|
|
200
|
-
document.addEventListener('mousemove', onMouseMoveResize)
|
|
201
|
-
document.addEventListener('mouseup', onMouseUpWhenResizing)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function stopResizing() {
|
|
205
|
-
document.removeEventListener('mousemove', onMouseMoveResize)
|
|
206
|
-
document.removeEventListener('mouseup', onMouseUpWhenResizing)
|
|
207
|
-
resetResizingValues()
|
|
208
|
-
emit('eventWasResized', event.value)
|
|
209
|
-
isResizing.value = false
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function resetResizingValues() {
|
|
213
|
-
resizingStartingPoint.value = undefined
|
|
214
|
-
resizingStartingPointStartOfTime.value = props.eventProp.time.start
|
|
215
|
-
resizingStartingPointEndOfTime.value = props.eventProp.time.end
|
|
216
|
-
changeInQuarterHoursEventEnd.value = 0
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function getMinutesFromTimePoints(timePoints: number) {
|
|
220
|
-
return timePoints / timePointsInOneMinute.value
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function setColors() {
|
|
224
|
-
if (
|
|
225
|
-
event.value.colorScheme
|
|
226
|
-
&& props.config.style?.colorSchemes
|
|
227
|
-
&& props.config.style.colorSchemes[event.value.colorScheme]
|
|
228
|
-
) {
|
|
229
|
-
eventColor.value = props.config.style.colorSchemes[event.value.colorScheme].color
|
|
230
|
-
eventBackgroundColor.value = props.config.style.colorSchemes[event.value.colorScheme].backgroundColor
|
|
231
|
-
return
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (event.value.color) {
|
|
235
|
-
eventColor.value = '#fff'
|
|
236
|
-
eventBackgroundColor.value = colors.value[event.value.color]
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
eventBackgroundColor.value = colors.value.blue
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function initDrag(domEvent: UIEvent) {
|
|
244
|
-
if (!event.value.isEditable || hasDisabledDragAndDrop.value) return
|
|
245
|
-
|
|
246
|
-
emit('dragStart')
|
|
247
|
-
|
|
248
|
-
dragMoveListenerNameAndCallbacks.forEach(([name, callback]) => {
|
|
249
|
-
document.addEventListener(name, callback)
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
if (Helpers.isUIEventTouchEvent(domEvent)) {
|
|
253
|
-
setInitialDragValues(
|
|
254
|
-
(domEvent as TouchEvent).touches[0].clientX,
|
|
255
|
-
(domEvent as TouchEvent).touches[0].clientY
|
|
256
|
-
)
|
|
257
|
-
} else {
|
|
258
|
-
setInitialDragValues((domEvent as MouseEvent).clientX, (domEvent as MouseEvent).clientY)
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function setInitialDragValues(clientX: number, clientY: number) {
|
|
263
|
-
canDrag.value = true
|
|
264
|
-
eventZIndexValue.value = 10
|
|
265
|
-
clientYDragStart.value = clientY
|
|
266
|
-
clientXDragStart.value = clientX
|
|
267
|
-
timeStartDragStart.value = event.value.time.start
|
|
268
|
-
timeEndDragStart.value = event.value.time.end
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function onMouseUpWhenDragging() {
|
|
272
|
-
emit('dragEnd')
|
|
273
|
-
handleDragEnd()
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function handleDragEnd() {
|
|
277
|
-
canDrag.value = false
|
|
278
|
-
eventZIndexValue.value = 'initial'
|
|
279
|
-
dragMoveListenerNameAndCallbacks.forEach(([name, callback]) => {
|
|
280
|
-
document.removeEventListener(name, callback)
|
|
281
|
-
})
|
|
282
|
-
const dayChanged = changeInDaysOnDrag.value <= -1 || changeInDaysOnDrag.value > 0
|
|
283
|
-
const timeChanged = changeInQuartersOnDrag.value <= -1 || changeInQuartersOnDrag.value > 0
|
|
284
|
-
if (dayChanged || timeChanged) emit('eventWasDragged', event.value)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function handleDrag(mouseEvent: UIEvent) {
|
|
288
|
-
if (isResizing.value || !canDrag.value || !clientYDragStart.value) return
|
|
289
|
-
|
|
290
|
-
if (Helpers.isUIEventTouchEvent(mouseEvent)) {
|
|
291
|
-
handleVerticalDrag((mouseEvent as TouchEvent).touches[0].clientY)
|
|
292
|
-
handleHorizontalDrag((mouseEvent as TouchEvent).touches[0].clientX)
|
|
293
|
-
} else {
|
|
294
|
-
handleVerticalDrag((mouseEvent as MouseEvent).clientY)
|
|
295
|
-
handleHorizontalDrag((mouseEvent as MouseEvent).clientX)
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function handleVerticalDrag(clientY: number) {
|
|
300
|
-
const eventsContainer = document.querySelector('.calendar-week__events')
|
|
301
|
-
if (!eventsContainer || !clientYDragStart.value) return
|
|
302
|
-
|
|
303
|
-
const nOfPixelsDistance = clientY - clientYDragStart.value
|
|
304
|
-
const eventsContainerHeight = eventsContainer.clientHeight
|
|
305
|
-
const percentageOfDayChanged = (nOfPixelsDistance / eventsContainerHeight) * 100
|
|
306
|
-
const changeInTimePoints = (timePointsInDay.value / 100) * percentageOfDayChanged
|
|
307
|
-
const changeInMinutes = getMinutesFromTimePoints(changeInTimePoints)
|
|
308
|
-
changeInQuartersOnDrag.value = changeInMinutes < 0
|
|
309
|
-
? Math.ceil(changeInMinutes / 15)
|
|
310
|
-
: Math.floor(changeInMinutes / 15)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function handleHorizontalDrag(clientX: number) {
|
|
314
|
-
if (!dayElement.value || !clientXDragStart.value) return
|
|
315
|
-
|
|
316
|
-
const dayWidth = dayElement.value.clientWidth
|
|
317
|
-
const changeInPixelsX = clientX - clientXDragStart.value
|
|
318
|
-
changeInDaysOnDrag.value = changeInPixelsX < 0
|
|
319
|
-
? Math.ceil(changeInPixelsX / dayWidth)
|
|
320
|
-
: Math.floor(changeInPixelsX / dayWidth)
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function updatePositionOnDrag() {
|
|
324
|
-
const minutesChangedVertically = changeInQuartersOnDrag.value * 15
|
|
325
|
-
const minutesChangedHorizontally = changeInDaysOnDrag.value * 1440
|
|
326
|
-
|
|
327
|
-
event.value.time.start = props.time.addMinutesToDateTimeString(
|
|
328
|
-
minutesChangedVertically + minutesChangedHorizontally,
|
|
329
|
-
timeStartDragStart.value
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
event.value.time.end = props.time.addMinutesToDateTimeString(
|
|
333
|
-
minutesChangedVertically + minutesChangedHorizontally,
|
|
334
|
-
timeEndDragStart.value
|
|
335
|
-
)
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Watch effects
|
|
339
|
-
watch(changeInQuarterHoursEventStart, (newValue: number, oldValue: number) => {
|
|
340
|
-
const newStartOfTimeDateTimeString = props.time.addMinutesToDateTimeString(
|
|
341
|
-
15 * newValue,
|
|
342
|
-
resizingStartingPointStartOfTime.value
|
|
343
|
-
)
|
|
344
|
-
const direction = newValue > oldValue ? DRAG_N_RESIZE_DIRECTION.FORWARDS : DRAG_N_RESIZE_DIRECTION.BACKWARDS
|
|
345
|
-
const eventCanBeResizedFurther = eventChangeHelper.value.canEventBeMoved(event.value, direction)
|
|
346
|
-
|
|
347
|
-
if (newStartOfTimeDateTimeString < event.value.time.end && eventCanBeResizedFurther) {
|
|
348
|
-
event.value.time.start = newStartOfTimeDateTimeString
|
|
349
|
-
}
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
watch(changeInQuarterHoursEventEnd, (newValue: number, oldValue: number) => {
|
|
353
|
-
const newEndOfTimeDateTimeString = props.time.addMinutesToDateTimeString(
|
|
354
|
-
15 * newValue,
|
|
355
|
-
resizingStartingPointEndOfTime.value
|
|
356
|
-
)
|
|
357
|
-
const direction = newValue > oldValue ? DRAG_N_RESIZE_DIRECTION.FORWARDS : DRAG_N_RESIZE_DIRECTION.BACKWARDS
|
|
358
|
-
const eventCanBeResizedFurther = eventChangeHelper.value.canEventBeMoved(event.value, direction)
|
|
359
|
-
|
|
360
|
-
if (newEndOfTimeDateTimeString > event.value.time.start && eventCanBeResizedFurther) {
|
|
361
|
-
event.value.time.end = newEndOfTimeDateTimeString
|
|
362
|
-
}
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
watch(changeInQuartersOnDrag, (newValue: number, oldValue: number) => {
|
|
366
|
-
const direction = newValue > oldValue ? DRAG_N_RESIZE_DIRECTION.FORWARDS : DRAG_N_RESIZE_DIRECTION.BACKWARDS
|
|
367
|
-
const eventCanBeDraggedFurther = eventChangeHelper.value.canEventBeMoved(event.value, direction)
|
|
368
|
-
if (!eventCanBeDraggedFurther) return
|
|
369
|
-
updatePositionOnDrag()
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
watch(changeInDaysOnDrag, (newValue: number) => {
|
|
373
|
-
if (!dayElement.value) return
|
|
374
|
-
const upcomingDaysInWeek = props.dayInfo.daysTotalN - (props.dayInfo.thisDayIndex + 1)
|
|
375
|
-
const previousDaysInWeek = 0 - props.dayInfo.thisDayIndex
|
|
376
|
-
if (newValue > upcomingDaysInWeek || newValue < previousDaysInWeek) return
|
|
377
|
-
|
|
378
|
-
const pixelsToTransform = newValue * dayElement.value.clientWidth
|
|
379
|
-
eventTransformValue.value = `translateX(${pixelsToTransform}px)`
|
|
380
|
-
updatePositionOnDrag()
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
onMounted(() => {
|
|
384
|
-
dayElement.value = document.querySelector('.calendar-week__day')
|
|
385
|
-
setColors()
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
// Accessibility handlers
|
|
389
|
-
function handleFocus() {
|
|
390
|
-
if (isEditable.value && !hasDisabledResize.value) {
|
|
391
|
-
showResizeElements.value = true
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function handleBlur() {
|
|
396
|
-
showResizeElements.value = false
|
|
397
|
-
}
|
|
398
|
-
</script>
|
|
399
|
-
|
|
400
|
-
<template>
|
|
401
|
-
<div
|
|
402
|
-
class="calendar-week__event is-event"
|
|
403
|
-
:class="{
|
|
404
|
-
'is-editable': isEditable,
|
|
405
|
-
'has-disabled-dnd': hasDisabledDragAndDrop,
|
|
406
|
-
}"
|
|
407
|
-
:style="{
|
|
408
|
-
...requiredStyles,
|
|
409
|
-
border: getBorderRule,
|
|
410
|
-
}"
|
|
411
|
-
:data-ref="`event-${event.id}`"
|
|
412
|
-
tabindex="0"
|
|
413
|
-
@click="handleClickOnEvent"
|
|
414
|
-
@mouseenter="handleFocus"
|
|
415
|
-
@mouseleave="handleBlur"
|
|
416
|
-
@focus="handleFocus"
|
|
417
|
-
@blur="handleBlur"
|
|
418
|
-
@mousedown="initDrag"
|
|
419
|
-
@touchstart="initDrag"
|
|
420
|
-
>
|
|
421
|
-
<div
|
|
422
|
-
v-if="!isCustomEvent"
|
|
423
|
-
class="calendar-week__event-info-wrapper p-05"
|
|
424
|
-
:style="{
|
|
425
|
-
color: eventColor,
|
|
426
|
-
width: '100%',
|
|
427
|
-
height: '100%',
|
|
428
|
-
backgroundColor: eventBackgroundColor,
|
|
429
|
-
}"
|
|
430
|
-
>
|
|
431
|
-
<div class="calendar-week__event-row is-title">
|
|
432
|
-
{{ event.title }}
|
|
433
|
-
</div>
|
|
434
|
-
|
|
435
|
-
<div class="calendar-week__event-row is-time flex">
|
|
436
|
-
<Icon
|
|
437
|
-
:icon="icons.clock"
|
|
438
|
-
class="calendar-week__event-icon"
|
|
439
|
-
/>
|
|
440
|
-
<span>{{ getEventTime }}</span>
|
|
441
|
-
</div>
|
|
442
|
-
|
|
443
|
-
<div
|
|
444
|
-
v-if="event.location"
|
|
445
|
-
class="calendar-week__event-row is-location"
|
|
446
|
-
>
|
|
447
|
-
<Icon
|
|
448
|
-
:icon="icons.location"
|
|
449
|
-
class="calendar-week__event-icon"
|
|
450
|
-
/>
|
|
451
|
-
<span>{{ event.location }}</span>
|
|
452
|
-
</div>
|
|
453
|
-
|
|
454
|
-
<div
|
|
455
|
-
v-if="event.with"
|
|
456
|
-
class="calendar-week__event-row is-with"
|
|
457
|
-
>
|
|
458
|
-
<Icon
|
|
459
|
-
:icon="icons.user"
|
|
460
|
-
class="calendar-week__event-icon"
|
|
461
|
-
/>
|
|
462
|
-
<span>{{ event.with }}</span>
|
|
463
|
-
</div>
|
|
464
|
-
|
|
465
|
-
<div
|
|
466
|
-
v-if="event.topic"
|
|
467
|
-
class="calendar-week__event-row is-topic"
|
|
468
|
-
>
|
|
469
|
-
<Icon
|
|
470
|
-
:icon="icons.topic"
|
|
471
|
-
class="calendar-week__event-icon"
|
|
472
|
-
/>
|
|
473
|
-
<span>{{ event.topic }}</span>
|
|
474
|
-
</div>
|
|
475
|
-
|
|
476
|
-
<div
|
|
477
|
-
v-if="event.description"
|
|
478
|
-
class="calendar-week__event-row is-description"
|
|
479
|
-
>
|
|
480
|
-
<Icon
|
|
481
|
-
:icon="icons.description"
|
|
482
|
-
class="calendar-week__event-icon"
|
|
483
|
-
/>
|
|
484
|
-
<!-- eslint-disable vue/no-v-html -->
|
|
485
|
-
<p v-html="event.description" />
|
|
486
|
-
<!-- eslint-enable -->
|
|
487
|
-
</div>
|
|
488
|
-
|
|
489
|
-
<div
|
|
490
|
-
v-if="eventIsLongerThan30Minutes"
|
|
491
|
-
class="calendar-week__event-blend-out"
|
|
492
|
-
:style="{
|
|
493
|
-
backgroundImage: `linear-gradient(to bottom, transparent, ${eventBackgroundColor})`,
|
|
494
|
-
}"
|
|
495
|
-
/>
|
|
496
|
-
</div>
|
|
497
|
-
|
|
498
|
-
<slot
|
|
499
|
-
v-else
|
|
500
|
-
name="weekDayEvent"
|
|
501
|
-
:event-data="event"
|
|
502
|
-
/>
|
|
503
|
-
|
|
504
|
-
<div
|
|
505
|
-
v-if="showResizeElements"
|
|
506
|
-
class="calendar-week__event-resize calendar-week__event-resize-up"
|
|
507
|
-
@mousedown="resizeEvent('up')"
|
|
508
|
-
/>
|
|
509
|
-
|
|
510
|
-
<div
|
|
511
|
-
v-if="showResizeElements"
|
|
512
|
-
class="calendar-week__event-resize calendar-week__event-resize-down"
|
|
513
|
-
@mousedown="resizeEvent('down')"
|
|
514
|
-
/>
|
|
515
|
-
</div>
|
|
516
|
-
</template>
|
|
517
|
-
|
|
518
|
-
<style scoped>
|
|
519
|
-
.calendar-week__event {
|
|
520
|
-
position: absolute;
|
|
521
|
-
width: 100%;
|
|
522
|
-
border-radius: 4px;
|
|
523
|
-
cursor: pointer;
|
|
524
|
-
box-sizing: content-box;
|
|
525
|
-
user-select: none;
|
|
526
|
-
overflow: hidden;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
.calendar-week__event.is-editable {
|
|
530
|
-
cursor: grab;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
.calendar-week__event.has-disabled-dnd {
|
|
534
|
-
cursor: initial;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
.calendar-week__event .calendar-week__event-row {
|
|
538
|
-
display: flex;
|
|
539
|
-
align-items: flex-start;
|
|
540
|
-
margin-bottom: 0.25em;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.calendar-week__event .calendar-week__event-row p {
|
|
544
|
-
margin: 0;
|
|
545
|
-
padding: 0;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
.calendar-week__event .calendar-week__event-info-wrapper {
|
|
549
|
-
position: relative;
|
|
550
|
-
padding: var(--qalendar-spacing-half);
|
|
551
|
-
font-size: var(--qalendar-font-xs);
|
|
552
|
-
height: 100%;
|
|
553
|
-
box-sizing: border-box;
|
|
554
|
-
user-select: none;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
.calendar-week__event .calendar-week__event-blend-out {
|
|
558
|
-
position: absolute;
|
|
559
|
-
bottom: 0;
|
|
560
|
-
height: 20px;
|
|
561
|
-
width: 100%;
|
|
562
|
-
transform: translateX(calc(var(--qalendar-spacing-half) * -1));
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
.calendar-week__event .calendar-week__event-icon {
|
|
566
|
-
margin: 2px 4px 0 0;
|
|
567
|
-
font-size: var(--qalendar-font-xs);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
.calendar-week__event .calendar-week__event-resize {
|
|
571
|
-
position: absolute;
|
|
572
|
-
width: 100%;
|
|
573
|
-
cursor: ns-resize;
|
|
574
|
-
height: 5px;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
.calendar-week__event .calendar-week__event-resize-up {
|
|
578
|
-
top: 0;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
.calendar-week__event .calendar-week__event-resize-down {
|
|
582
|
-
bottom: 0;
|
|
583
|
-
}
|
|
584
|
-
</style>
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { PropType } from 'vue'
|
|
3
|
-
import type Time from '../../helpers/Time'
|
|
4
|
-
import type { DAY_TIME_POINT } from '../../typings/config.interface'
|
|
5
|
-
import { ref, onMounted } from 'vue'
|
|
6
|
-
|
|
7
|
-
const props = defineProps({
|
|
8
|
-
time: {
|
|
9
|
-
type: Object as PropType<Time>,
|
|
10
|
-
required: true,
|
|
11
|
-
},
|
|
12
|
-
weekHeight: {
|
|
13
|
-
type: String,
|
|
14
|
-
required: true,
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
// const availableHours = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300] as DAY_TIME_POINT[]
|
|
19
|
-
const timelineHours = ref<DAY_TIME_POINT[]>([])
|
|
20
|
-
|
|
21
|
-
onMounted(() => {
|
|
22
|
-
timelineHours.value = props.time.getTimelineHours()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
function getLocaleTimeString(time: DAY_TIME_POINT): string {
|
|
26
|
-
const { hour } = props.time.getHourAndMinutesFromTimePoints(time)
|
|
27
|
-
return props.time.getLocalizedHour(new Date(2100, 1, 1, hour))
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<template>
|
|
32
|
-
<div class="day-timeline absolute top-0 start-0 space-evenly column display-flex">
|
|
33
|
-
<div
|
|
34
|
-
v-for="hour in timelineHours"
|
|
35
|
-
:key="hour"
|
|
36
|
-
class="day-timeline__hour display-flex column ustify-content-start h-100p ps-05"
|
|
37
|
-
>
|
|
38
|
-
<span class="day-timeline__hour-text line-height-0">
|
|
39
|
-
{{ getLocaleTimeString(hour) }}
|
|
40
|
-
</span>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|
|
44
|
-
|
|
45
|
-
<style scoped>
|
|
46
|
-
.day-timeline {
|
|
47
|
-
width: calc(100% + 10px);
|
|
48
|
-
height: v-bind(weekHeight);
|
|
49
|
-
transform: translateX(-10px);
|
|
50
|
-
}
|
|
51
|
-
[dir="rtl"] .day-timeline {
|
|
52
|
-
transform: translateX(10px);
|
|
53
|
-
}
|
|
54
|
-
[dir="rtl"] .ltr .day-timeline {
|
|
55
|
-
transform: translateX(-10px);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.day-timeline__hour {
|
|
59
|
-
font-size: clamp(10px, 0.625rem, 14px);
|
|
60
|
-
color: var(--qalendar-gray-quite-dark);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.day-timeline__hour-text {
|
|
64
|
-
transform: translate(-40px, 0);
|
|
65
|
-
}
|
|
66
|
-
[dir="rtl"] .day-timeline__hour-text {
|
|
67
|
-
transform: translate(40px, 0);
|
|
68
|
-
}
|
|
69
|
-
[dir="rtl"] .ltr .day-timeline__hour-text {
|
|
70
|
-
transform: translate(-40px, 0);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.day-timeline__hour:first-child .day-timeline__hour-text {
|
|
74
|
-
display: none;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.day-timeline__hour:not(:last-child) {
|
|
78
|
-
border-bottom: var(--qalendar-border-gray-thin);
|
|
79
|
-
}
|
|
80
|
-
</style>
|