v-calendar-3 1.0.0
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/LICENSE +9 -0
- package/README.md +142 -0
- package/dist/cjs/index.css +1133 -0
- package/dist/cjs/index.js +10699 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/es/index.js +10678 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/style.css +1134 -0
- package/dist/iife/index.js +2 -0
- package/dist/iife/index.js.map +1 -0
- package/dist/mjs/index.mjs +10678 -0
- package/dist/mjs/index.mjs.map +1 -0
- package/dist/mjs/style.css +1134 -0
- package/dist/style.css +1134 -0
- package/dist/types/components/BaseIcon/BaseIcon.vue.d.ts +41 -0
- package/dist/types/components/BaseIcon/icons/IconChevronDown.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/IconChevronLeft.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/IconChevronRight.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/IconClock.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/index.d.ts +4 -0
- package/dist/types/components/BaseSelect/BaseSelect.vue.d.ts +26 -0
- package/dist/types/components/Calendar/Calendar.vue.d.ts +2526 -0
- package/dist/types/components/Calendar/CalendarDay.vue.d.ts +83 -0
- package/dist/types/components/Calendar/CalendarDayPopover.vue.d.ts +3 -0
- package/dist/types/components/Calendar/CalendarHeader.vue.d.ts +13 -0
- package/dist/types/components/Calendar/CalendarNav.vue.d.ts +4 -0
- package/dist/types/components/Calendar/CalendarNavPopover.vue.d.ts +3 -0
- package/dist/types/components/Calendar/CalendarPage.vue.d.ts +3 -0
- package/dist/types/components/Calendar/CalendarPageProvider.vue.d.ts +17 -0
- package/dist/types/components/Calendar/CalendarSlot.vue.d.ts +15 -0
- package/dist/types/components/Calendar/CalendarTitleSelect.vue.d.ts +15 -0
- package/dist/types/components/CalendarGrid/CalendarCell.vue.d.ts +9 -0
- package/dist/types/components/CalendarGrid/CalendarCellPopover.vue.d.ts +209 -0
- package/dist/types/components/CalendarGrid/CalendarDayCell.vue.d.ts +8 -0
- package/dist/types/components/CalendarGrid/CalendarEventDetails.vue.d.ts +15 -0
- package/dist/types/components/CalendarGrid/CalendarEventEdit.vue.d.ts +26 -0
- package/dist/types/components/CalendarGrid/CalendarGrid.vue.d.ts +134 -0
- package/dist/types/components/CalendarGrid/CalendarGridWeek.vue.d.ts +8 -0
- package/dist/types/components/CalendarGrid/CalendarViewSelect.vue.d.ts +3 -0
- package/dist/types/components/CalendarGrid/CalendarWeekCell.vue.d.ts +10 -0
- package/dist/types/components/CalendarGrid/Constraints.d.ts +16 -0
- package/dist/types/components/DatePicker/DatePicker.vue.d.ts +15251 -0
- package/dist/types/components/DatePicker/DatePickerBase.vue.d.ts +3 -0
- package/dist/types/components/DatePicker/DatePickerPopover.vue.d.ts +3 -0
- package/dist/types/components/DatePicker/TimePicker.vue.d.ts +10089 -0
- package/dist/types/components/Popover/Popover.vue.d.ts +72 -0
- package/dist/types/components/Popover/PopoverRow.vue.d.ts +17 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/index.d.cts +40981 -0
- package/dist/types/index.d.mts +40981 -0
- package/dist/types/index.d.ts +40981 -0
- package/dist/types/use/base.d.ts +67 -0
- package/dist/types/use/calendar.d.ts +2422 -0
- package/dist/types/use/calendarGrid.d.ts +9370 -0
- package/dist/types/use/datePicker.d.ts +20210 -0
- package/dist/types/use/page.d.ts +20 -0
- package/dist/types/use/slots.d.ts +5 -0
- package/dist/types/use/timePicker.d.ts +10089 -0
- package/dist/types/utils/attribute.d.ts +49 -0
- package/dist/types/utils/cache.d.ts +10 -0
- package/dist/types/utils/calendar/event.d.ts +111 -0
- package/dist/types/utils/config/index.d.ts +5 -0
- package/dist/types/utils/date/helpers.d.ts +161 -0
- package/dist/types/utils/date/range.d.ts +74 -0
- package/dist/types/utils/date/repeat.d.ts +34 -0
- package/dist/types/utils/date/rules.d.ts +82 -0
- package/dist/types/utils/defaults/index.d.ts +30 -0
- package/dist/types/utils/defaults/locales.d.ts +9 -0
- package/dist/types/utils/glyph.d.ts +58 -0
- package/dist/types/utils/helpers.d.ts +49 -0
- package/dist/types/utils/locale.d.ts +48 -0
- package/dist/types/utils/page.d.ts +95 -0
- package/dist/types/utils/plugins/index.d.ts +4 -0
- package/dist/types/utils/popovers.d.ts +47 -0
- package/dist/types/utils/theme.d.ts +17 -0
- package/dist/types/utils/touch.d.ts +8 -0
- package/dist/types/utils/useDisplayMode.d.ts +12 -0
- package/dist/types/utils/watchers.d.ts +6 -0
- package/package.json +115 -0
- package/src/components/BaseIcon/BaseIcon.vue +29 -0
- package/src/components/BaseIcon/icons/IconChevronDown.vue +5 -0
- package/src/components/BaseIcon/icons/IconChevronLeft.vue +5 -0
- package/src/components/BaseIcon/icons/IconChevronRight.vue +5 -0
- package/src/components/BaseIcon/icons/IconClock.vue +11 -0
- package/src/components/BaseIcon/icons/index.ts +4 -0
- package/src/components/BaseSelect/BaseSelect.vue +136 -0
- package/src/components/Calendar/Calendar.vue +116 -0
- package/src/components/Calendar/CalendarDay.vue +422 -0
- package/src/components/Calendar/CalendarDayPopover.vue +44 -0
- package/src/components/Calendar/CalendarHeader.vue +203 -0
- package/src/components/Calendar/CalendarNav.vue +325 -0
- package/src/components/Calendar/CalendarNavPopover.vue +24 -0
- package/src/components/Calendar/CalendarPage.vue +140 -0
- package/src/components/Calendar/CalendarPageProvider.vue +15 -0
- package/src/components/Calendar/CalendarSlot.vue +36 -0
- package/src/components/Calendar/CalendarTitleSelect.vue +72 -0
- package/src/components/CalendarGrid/CalendarCell.vue +112 -0
- package/src/components/CalendarGrid/CalendarCellPopover.vue +93 -0
- package/src/components/CalendarGrid/CalendarDayCell.vue +57 -0
- package/src/components/CalendarGrid/CalendarEventDetails.vue +71 -0
- package/src/components/CalendarGrid/CalendarEventEdit.vue +195 -0
- package/src/components/CalendarGrid/CalendarGrid.vue +715 -0
- package/src/components/CalendarGrid/CalendarGridWeek.vue +60 -0
- package/src/components/CalendarGrid/CalendarViewSelect.vue +34 -0
- package/src/components/CalendarGrid/CalendarWeekCell.vue +52 -0
- package/src/components/CalendarGrid/Constraints.ts +40 -0
- package/src/components/DatePicker/DatePicker.vue +27 -0
- package/src/components/DatePicker/DatePickerBase.vue +53 -0
- package/src/components/DatePicker/DatePickerPopover.vue +37 -0
- package/src/components/DatePicker/TimePicker.vue +167 -0
- package/src/components/Popover/Popover.vue +572 -0
- package/src/components/Popover/PopoverRow.vue +94 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +24 -0
- package/src/styles/index.css +48 -0
- package/src/styles/theme.css +322 -0
- package/src/styles/transitions.css +77 -0
- package/src/use/base.ts +144 -0
- package/src/use/calendar.ts +796 -0
- package/src/use/calendarGrid.ts +954 -0
- package/src/use/datePicker.ts +909 -0
- package/src/use/page.ts +78 -0
- package/src/use/slots.ts +17 -0
- package/src/use/timePicker.ts +194 -0
- package/src/utils/attribute.ts +107 -0
- package/src/utils/cache.ts +30 -0
- package/src/utils/calendar/event.ts +335 -0
- package/src/utils/config/index.ts +11 -0
- package/src/utils/date/helpers.ts +1039 -0
- package/src/utils/date/range.ts +274 -0
- package/src/utils/date/repeat.ts +135 -0
- package/src/utils/date/rules.ts +290 -0
- package/src/utils/defaults/index.ts +77 -0
- package/src/utils/defaults/locales.ts +123 -0
- package/src/utils/defaults/masks.json +15 -0
- package/src/utils/defaults/touch.json +5 -0
- package/src/utils/glyph.ts +305 -0
- package/src/utils/helpers.ts +181 -0
- package/src/utils/locale.ts +275 -0
- package/src/utils/page.ts +608 -0
- package/src/utils/plugins/index.ts +24 -0
- package/src/utils/popovers.ts +216 -0
- package/src/utils/theme.ts +58 -0
- package/src/utils/touch.ts +72 -0
- package/src/utils/useDisplayMode.ts +198 -0
- package/src/utils/watchers.ts +26 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:data-cell-id="event.key"
|
|
4
|
+
class="vc-grid-event"
|
|
5
|
+
:class="[
|
|
6
|
+
`vc-${event.color}`,
|
|
7
|
+
{
|
|
8
|
+
'is-all-day': event.allDay,
|
|
9
|
+
'is-dragging': event.dragging,
|
|
10
|
+
'is-selected': event.selected,
|
|
11
|
+
'is-resizing': event.resizing,
|
|
12
|
+
},
|
|
13
|
+
]"
|
|
14
|
+
:tabindex="1"
|
|
15
|
+
@mousedown.prevent="onEventMouseDown($event, event)"
|
|
16
|
+
@touchstart.passive="onEventTouchStart($event, event)"
|
|
17
|
+
@touchmove.passive="onEventTouchMove($event, event)"
|
|
18
|
+
@touchend.passive="onEventTouchEnd($event, event)"
|
|
19
|
+
>
|
|
20
|
+
<div class="vc-grid-event-content-wrapper">
|
|
21
|
+
<div class="vc-grid-event-content">
|
|
22
|
+
<template v-if="event.isWeekly">
|
|
23
|
+
<div class="vc-grid-event-summary">{{ event.summary }}</div>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-else>
|
|
26
|
+
<span v-if="isMonthly" class="vc-grid-event-indicator" />
|
|
27
|
+
<div class="vc-grid-event-summary">{{ event.summary }}</div>
|
|
28
|
+
<div class="vc-grid-event-start-date-label">
|
|
29
|
+
{{ event.startTimeLabel }}
|
|
30
|
+
</div>
|
|
31
|
+
<div class="vc-grid-event-date-label">
|
|
32
|
+
{{ event.timeLabel }}
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
</div>
|
|
36
|
+
<!--Resize start-->
|
|
37
|
+
<div
|
|
38
|
+
v-if="resizable"
|
|
39
|
+
class="vc-grid-event-resizer is-start"
|
|
40
|
+
:class="{
|
|
41
|
+
'is-horizontal': resizableHorizontal,
|
|
42
|
+
'is-vertical': resizableVertical,
|
|
43
|
+
}"
|
|
44
|
+
@click.prevent
|
|
45
|
+
@mousedown="onEventResizeStartMouseDown($event, event)"
|
|
46
|
+
@touchstart.passive="onEventResizeStartTouchStart($event, event)"
|
|
47
|
+
/>
|
|
48
|
+
<!--Resize end-->
|
|
49
|
+
<div
|
|
50
|
+
v-if="resizable"
|
|
51
|
+
class="vc-grid-event-resizer is-end"
|
|
52
|
+
:class="{
|
|
53
|
+
'is-horizontal': resizableHorizontal,
|
|
54
|
+
'is-vertical': resizableVertical,
|
|
55
|
+
}"
|
|
56
|
+
@click.prevent
|
|
57
|
+
@mousedown="onEventResizeEndMouseDown($event, event)"
|
|
58
|
+
@touchstart.passive="onEventResizeEndTouchStart($event, event)"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script lang="ts">
|
|
65
|
+
import { computed, defineComponent } from 'vue';
|
|
66
|
+
import type { Event } from '../../utils/calendar/event';
|
|
67
|
+
import type { DateRangeCell } from '../../utils/date/range';
|
|
68
|
+
import { popoverDirective } from '../../utils/popovers';
|
|
69
|
+
|
|
70
|
+
export default defineComponent({
|
|
71
|
+
name: 'CalendarCell',
|
|
72
|
+
directives: { popover: popoverDirective },
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import { useCalendarGrid } from '../../use/calendarGrid';
|
|
78
|
+
|
|
79
|
+
const props = defineProps<{
|
|
80
|
+
cell: DateRangeCell<Event>;
|
|
81
|
+
}>();
|
|
82
|
+
|
|
83
|
+
const {
|
|
84
|
+
isDaily,
|
|
85
|
+
isMonthly,
|
|
86
|
+
onEventMouseDown,
|
|
87
|
+
onEventTouchStart,
|
|
88
|
+
onEventTouchMove,
|
|
89
|
+
onEventTouchEnd,
|
|
90
|
+
onEventResizeStartMouseDown,
|
|
91
|
+
onEventResizeEndMouseDown,
|
|
92
|
+
onEventResizeStartTouchStart,
|
|
93
|
+
onEventResizeEndTouchStart,
|
|
94
|
+
} = useCalendarGrid();
|
|
95
|
+
|
|
96
|
+
const event = computed(() => props.cell.data);
|
|
97
|
+
|
|
98
|
+
const resizable = computed(() => event.value.resizable);
|
|
99
|
+
const resizableHorizontal = computed(() => {
|
|
100
|
+
if (!event.value.resizable) return false;
|
|
101
|
+
if (isDaily.value) return false;
|
|
102
|
+
if (isMonthly.value) return true;
|
|
103
|
+
if (event.value.isWeekly) return true;
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
106
|
+
const resizableVertical = computed(() => {
|
|
107
|
+
if (!event.value.resizable) return false;
|
|
108
|
+
if (isMonthly.value) return false;
|
|
109
|
+
if (event.value.isWeekly) return false;
|
|
110
|
+
return true;
|
|
111
|
+
});
|
|
112
|
+
</script>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Popover
|
|
3
|
+
:id="popoverId"
|
|
4
|
+
:class="[`vc-${color}`, `vc-${displayMode}`]"
|
|
5
|
+
@after-hide="onAfterHide"
|
|
6
|
+
ref="popoverRef"
|
|
7
|
+
>
|
|
8
|
+
<CalendarEventEdit
|
|
9
|
+
v-if="event"
|
|
10
|
+
:event="event"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
@close="hide"
|
|
13
|
+
/>
|
|
14
|
+
</Popover>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import { computed, defineComponent, reactive, ref, toRefs } from 'vue';
|
|
19
|
+
import { useCalendar } from '../../use/calendar';
|
|
20
|
+
import type { Event } from '../../utils/calendar/event';
|
|
21
|
+
import {
|
|
22
|
+
type PopoverOptions,
|
|
23
|
+
hidePopover,
|
|
24
|
+
showPopover,
|
|
25
|
+
} from '../../utils/popovers';
|
|
26
|
+
import Popover from '../Popover/Popover.vue';
|
|
27
|
+
import CalendarEventEdit from './CalendarEventEdit.vue';
|
|
28
|
+
|
|
29
|
+
interface State {
|
|
30
|
+
event: Event | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default defineComponent({
|
|
34
|
+
name: 'CalendarCellPopover',
|
|
35
|
+
components: { Popover, CalendarEventEdit },
|
|
36
|
+
inheritAttrs: false,
|
|
37
|
+
props: {
|
|
38
|
+
popoverId: { type: String, default: 'vc-grid-popover' },
|
|
39
|
+
},
|
|
40
|
+
setup(props) {
|
|
41
|
+
const popoverRef = ref(null);
|
|
42
|
+
const state: State = reactive({
|
|
43
|
+
event: null,
|
|
44
|
+
});
|
|
45
|
+
const { displayMode, color } = useCalendar();
|
|
46
|
+
|
|
47
|
+
const popoverOptions = computed(
|
|
48
|
+
() =>
|
|
49
|
+
({
|
|
50
|
+
id: props.popoverId,
|
|
51
|
+
placement: 'right',
|
|
52
|
+
} as Partial<PopoverOptions>),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
function show(event: Event) {
|
|
56
|
+
state.event = event;
|
|
57
|
+
showPopover({
|
|
58
|
+
...popoverOptions.value,
|
|
59
|
+
target: event.refSelector,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function update(event: Event) {
|
|
64
|
+
event.editing = false;
|
|
65
|
+
state.event = event;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hide() {
|
|
69
|
+
hidePopover({
|
|
70
|
+
...popoverOptions.value,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isVisible() {
|
|
75
|
+
return !!popoverRef.value && (popoverRef.value as any).isVisible;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
popoverRef,
|
|
80
|
+
...toRefs(state),
|
|
81
|
+
displayMode,
|
|
82
|
+
color,
|
|
83
|
+
show,
|
|
84
|
+
update,
|
|
85
|
+
hide,
|
|
86
|
+
isVisible,
|
|
87
|
+
onAfterHide() {
|
|
88
|
+
state.event = null;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
</script>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<CalendarCell
|
|
3
|
+
:cell="cell"
|
|
4
|
+
:class="[`is-${size}`, `is-${fill}`]"
|
|
5
|
+
:style="style"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed } from 'vue';
|
|
11
|
+
import { useCalendarGrid } from '../../use/calendarGrid';
|
|
12
|
+
import { Event } from '../../utils/calendar/event';
|
|
13
|
+
import { MS_PER_HOUR } from '../../utils/date/helpers';
|
|
14
|
+
import { DateRangeCell } from '../../utils/date/range';
|
|
15
|
+
import { roundTenth } from '../../utils/helpers';
|
|
16
|
+
import CalendarCell from './CalendarCell.vue';
|
|
17
|
+
|
|
18
|
+
const props = defineProps<{
|
|
19
|
+
cell: DateRangeCell<Event>;
|
|
20
|
+
}>();
|
|
21
|
+
|
|
22
|
+
const { pixelsPerHour } = useCalendarGrid();
|
|
23
|
+
|
|
24
|
+
const event = computed(() => props.cell.data);
|
|
25
|
+
|
|
26
|
+
const position = computed(() => {
|
|
27
|
+
const { startTime } = props.cell;
|
|
28
|
+
const yHours = startTime / MS_PER_HOUR;
|
|
29
|
+
return Math.max(roundTenth(yHours * pixelsPerHour.value), 0);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const height = computed(() => {
|
|
33
|
+
const { startTime, endTime } = props.cell;
|
|
34
|
+
const heightHours = (endTime - startTime) / MS_PER_HOUR;
|
|
35
|
+
const fullHeight = 24 * pixelsPerHour.value;
|
|
36
|
+
return Math.max(
|
|
37
|
+
Math.min(heightHours * pixelsPerHour.value, fullHeight - position.value),
|
|
38
|
+
0,
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const size = computed(() => {
|
|
43
|
+
if (height.value <= 16) return '2xs';
|
|
44
|
+
if (height.value <= 30) return 'xs';
|
|
45
|
+
if (height.value <= 48) return 'sm';
|
|
46
|
+
return 'md';
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const style = computed(() => {
|
|
50
|
+
return {
|
|
51
|
+
top: `${position.value}px`,
|
|
52
|
+
height: `${height.value}px`,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const fill = computed(() => event.value.fill);
|
|
57
|
+
</script>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vc-calendar-event-details">
|
|
3
|
+
<template v-if="single">
|
|
4
|
+
<div class="vc-field">
|
|
5
|
+
<div class="vc-label">Title</div>
|
|
6
|
+
<input v-model="single.summary" type="text" class="vc-input" />
|
|
7
|
+
</div>
|
|
8
|
+
<div class="vc-field">
|
|
9
|
+
<div class="vc-label">Start</div>
|
|
10
|
+
<VDatePicker v-model="startDate" mode="dateTime">
|
|
11
|
+
<template #default="{ inputValue, inputEvents }">
|
|
12
|
+
<input class="vc-input" :value="inputValue" v-on="inputEvents" />
|
|
13
|
+
</template>
|
|
14
|
+
</VDatePicker>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
<div v-else-if="events.length">
|
|
18
|
+
<div class="vc-label">{{ events.length }} events selected</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div v-else>
|
|
21
|
+
<div class="vc-label">No event selected</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { type PropType, computed, ref } from 'vue';
|
|
28
|
+
import { Event } from '../../utils/calendar/event';
|
|
29
|
+
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
events: { type: Array as PropType<Event[]>, required: true },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const single = computed(() => {
|
|
35
|
+
if (!props.events.length || props.events.length > 1) return null;
|
|
36
|
+
return props.events[0];
|
|
37
|
+
});
|
|
38
|
+
const startDate = ref(new Date());
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.vc-calendar-cell-details {
|
|
43
|
+
background: var(--vc-gray-100);
|
|
44
|
+
border: solid 1px var(--vc-gray-300);
|
|
45
|
+
min-width: 400px;
|
|
46
|
+
padding: 1rem 1.5rem;
|
|
47
|
+
margin: 2.5rem 0 1rem 1rem;
|
|
48
|
+
border-radius: var(--vc-rounded-lg);
|
|
49
|
+
|
|
50
|
+
.vc-field {
|
|
51
|
+
}
|
|
52
|
+
.vc-label {
|
|
53
|
+
font-size: var(--vc-text-sm);
|
|
54
|
+
color: var(--vc-gray-600);
|
|
55
|
+
font-weight: var(--vc-font-medium);
|
|
56
|
+
letter-spacing: var(--tracking-wide);
|
|
57
|
+
}
|
|
58
|
+
.vc-input {
|
|
59
|
+
font-size: var(--vc-text-sm);
|
|
60
|
+
display: block;
|
|
61
|
+
margin-top: 0.25rem;
|
|
62
|
+
shadow: var(--vc-shadow-sm);
|
|
63
|
+
border: 1px solid var(--vc-gray-300);
|
|
64
|
+
padding: 0.25rem 0.75rem;
|
|
65
|
+
border-radius: var(--vc-rounded-md);
|
|
66
|
+
width: 100%;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* focus:ring-indigo-500 focus:border-indigo-500 */
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-80">
|
|
3
|
+
<!--Header-->
|
|
4
|
+
<div class="flex items-center justify-between py-1 px-2 space-x-3">
|
|
5
|
+
<!--Label-->
|
|
6
|
+
<input
|
|
7
|
+
v-if="event.editing"
|
|
8
|
+
v-model="event.summary"
|
|
9
|
+
v-focus
|
|
10
|
+
placeholder="Add event label"
|
|
11
|
+
class="color-white placeholder-gray-300 bg-gray-600 px-2 py-1 rounded border border-gray-500"
|
|
12
|
+
/>
|
|
13
|
+
<h3 v-else class="font-bold">{{ event.summary }}</h3>
|
|
14
|
+
<!--Buttons-->
|
|
15
|
+
<div class="flex justify-end items-center space-x-3">
|
|
16
|
+
<!--Edit button-->
|
|
17
|
+
<button
|
|
18
|
+
v-if="!event.editing"
|
|
19
|
+
type="button"
|
|
20
|
+
class="w-5 h-5 text-blue-500 hover:opacity-50"
|
|
21
|
+
@click="onToggleEditing()"
|
|
22
|
+
>
|
|
23
|
+
<svg
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
fill="none"
|
|
26
|
+
viewBox="0 0 24 24"
|
|
27
|
+
stroke="currentColor"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
stroke-linecap="round"
|
|
31
|
+
stroke-linejoin="round"
|
|
32
|
+
stroke-width="2"
|
|
33
|
+
d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
</button>
|
|
37
|
+
<!--Remove button-->
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
class="w-5 h-5 text-red-500 hover:opacity-50"
|
|
41
|
+
@click="onRemove"
|
|
42
|
+
>
|
|
43
|
+
<svg
|
|
44
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
+
fill="none"
|
|
46
|
+
viewBox="0 0 24 24"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
>
|
|
49
|
+
<path
|
|
50
|
+
stroke-linecap="round"
|
|
51
|
+
stroke-linejoin="round"
|
|
52
|
+
stroke-width="2"
|
|
53
|
+
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
</button>
|
|
57
|
+
<!--Close button-->
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
class="w-5 h-5 hover:opacity-50"
|
|
61
|
+
@click="$emit('close')"
|
|
62
|
+
>
|
|
63
|
+
<svg
|
|
64
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
65
|
+
fill="none"
|
|
66
|
+
viewBox="0 0 24 24"
|
|
67
|
+
stroke="currentColor"
|
|
68
|
+
>
|
|
69
|
+
<path
|
|
70
|
+
stroke-linecap="round"
|
|
71
|
+
stroke-linejoin="round"
|
|
72
|
+
stroke-width="2"
|
|
73
|
+
d="M6 18L18 6M6 6l12 12"
|
|
74
|
+
/>
|
|
75
|
+
</svg>
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<div v-if="event.editing">
|
|
80
|
+
<div class="flex justify-end items-center space-x-2 mt-3 mb-1">
|
|
81
|
+
<!--Save button-->
|
|
82
|
+
<button
|
|
83
|
+
type="button"
|
|
84
|
+
class="flex justify-center items-center bg-blue-200 text-sm text-blue-800 hover:bg-blue-300 px-2 py-1 rounded"
|
|
85
|
+
@click="onSave"
|
|
86
|
+
>
|
|
87
|
+
Save
|
|
88
|
+
</button>
|
|
89
|
+
<!--Cancel button-->
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
class="flex justify-center items-center text-sm px-2 py-1 rounded hover:bg-gray-500"
|
|
93
|
+
@click="onCancel"
|
|
94
|
+
>
|
|
95
|
+
Cancel
|
|
96
|
+
</button>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
<div v-else class="py-2 px-3 space-y-2">
|
|
100
|
+
<!--Date-->
|
|
101
|
+
<div class="flex items-center">
|
|
102
|
+
<!--Date icon-->
|
|
103
|
+
<svg
|
|
104
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
105
|
+
class="h-5 w-5 text-gray-400 current-color"
|
|
106
|
+
fill="none"
|
|
107
|
+
viewBox="0 0 24 24"
|
|
108
|
+
stroke="currentColor"
|
|
109
|
+
>
|
|
110
|
+
<path
|
|
111
|
+
stroke-linecap="round"
|
|
112
|
+
stroke-linejoin="round"
|
|
113
|
+
stroke-width="2"
|
|
114
|
+
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
115
|
+
/>
|
|
116
|
+
</svg>
|
|
117
|
+
<!--Date label-->
|
|
118
|
+
<div class="ml-2 text-gray-200 font-medium">
|
|
119
|
+
{{ event.formatDate(event.startDate, 'WWWW, MMMM D') }}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
<!--Time-->
|
|
123
|
+
<div class="flex items-center">
|
|
124
|
+
<!--Time icon-->
|
|
125
|
+
<svg
|
|
126
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
127
|
+
class="h-5 w-5 text-gray-400 current-color"
|
|
128
|
+
fill="none"
|
|
129
|
+
viewBox="0 0 24 24"
|
|
130
|
+
stroke="currentColor"
|
|
131
|
+
>
|
|
132
|
+
<path
|
|
133
|
+
stroke-linecap="round"
|
|
134
|
+
stroke-linejoin="round"
|
|
135
|
+
stroke-width="2"
|
|
136
|
+
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
137
|
+
/>
|
|
138
|
+
</svg>
|
|
139
|
+
<!--Time label-->
|
|
140
|
+
<div class="ml-2 text-gray-200 font-medium">
|
|
141
|
+
<span v-if="event.allDay"> All Day </span>
|
|
142
|
+
<span v-else-if="event.isMultiDay"
|
|
143
|
+
>{{ event.startTimeLabel }}-{{ event.endTimeLabel }}</span
|
|
144
|
+
>
|
|
145
|
+
<span v-else
|
|
146
|
+
>{{ event.startTimeLabel }}-{{ event.endTimeLabel }}</span
|
|
147
|
+
>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</template>
|
|
153
|
+
|
|
154
|
+
<script lang="ts">
|
|
155
|
+
import { PropType, defineComponent, reactive, toRefs } from 'vue';
|
|
156
|
+
import { useCalendarGrid } from '../../use/calendarGrid';
|
|
157
|
+
import { Event } from '../../utils/calendar/event';
|
|
158
|
+
|
|
159
|
+
export default defineComponent({
|
|
160
|
+
name: 'CalendarEventEdit',
|
|
161
|
+
emits: ['close'],
|
|
162
|
+
props: {
|
|
163
|
+
event: { type: Object as PropType<Event>, required: true },
|
|
164
|
+
},
|
|
165
|
+
directives: {
|
|
166
|
+
focus: {
|
|
167
|
+
mounted(el) {
|
|
168
|
+
el.focus();
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
setup(props) {
|
|
173
|
+
const { removeEvent } = useCalendarGrid();
|
|
174
|
+
|
|
175
|
+
const state = reactive({
|
|
176
|
+
// editing: false,
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
...toRefs(state),
|
|
180
|
+
onRemove() {
|
|
181
|
+
removeEvent(props.event);
|
|
182
|
+
},
|
|
183
|
+
onToggleEditing() {
|
|
184
|
+
props.event.editing = !props.event.editing;
|
|
185
|
+
},
|
|
186
|
+
onSave() {
|
|
187
|
+
props.event.editing = false;
|
|
188
|
+
},
|
|
189
|
+
onCancel() {
|
|
190
|
+
props.event.editing = false;
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
</script>
|