toast-ui-calendar-vue3

Simple `@toast-ui/calendar` wrapper for vue3, pr welcomes ~
3,674 6
Install
npm install toast-ui-calendar-vue3
Latest Version:0.3.1
Vue:3
License:MIT
Last Updated:Mar 4, 2025
Links: GitHub  ·  npm
Maintainer: lionad

@toast-ui/calendar(for vue3)

Simple @toast-ui/calendar wrapper for vue3, pr welcomes ~

npm package build status LICENSE

Preview

📸 Run Dev

  1. pnpm install
  2. pnpm serve

📸 Usage

<template>
  <div class="intro play-container">
    <button @click="toggle">toggle</button>
    <button @click="next">next</button>
    <button @click="prev">prev</button>
    <tui-calendar  class="my-calendar" ref="calendarRef" :view="currentView" @beforeCreateEvent="createEvent"
      @beforeUpdateEvent="updateEvent" :use-form-popup="true" :use-detail-popup="true" :week="options.week"
      :timezone="options.timezone" :calendars="calendars" :events="myEvents" />
  </div>
</template>

<script setup lang="ts">
import TuiCalendar, { Calendar } from 'toast-ui-calendar-vue3';
import 'toast-ui-calendar-vue3/styles.css'

import { events } from './mock-data.js';
import { computed, ref, onMounted } from 'vue';

const calendarRef = ref<Calendar | undefined>()
const myEvents = ref()
const zones = [
  {
    timezoneName: "Asia/Kolkata",
    displayLabel: "Delhi",
    tooltip: "India Standard Time (UTC+05:30)"
  },
  {
    timezoneName: 'Asia/Seoul',
    displayLabel: 'Seoul',
    tooltip: 'Seoul Time',
  },
]
const defaultTimezoneName = computed(() => zones[0].timezoneName)
const calendars = computed(() => ([
  {
    id: 'home',
    name: 'Home',
    backgroundColor: '#69ff7061',
    borderColor: '#69ff7061',
    dragBackgroundColor: '#69ff7061',
  },
  {
    id: 'work',
    name: 'Work',
    backgroundColor: '#2d9fff61',
    borderColor: '#2d9fff61',
    dragBackgroundColor: '#2d9fff61',
  },
]))

onMounted(() => {
  myEvents.value = events
})

const next = () => {
  calendarRef.value.getInstance().next()
}
const prev = () => {
  calendarRef.value.getInstance().prev()
}
const viewOptions = ["day", "week", "month"];
const currentView = ref("month");

const toggle = () => {
  const currentIndex = viewOptions.findIndex((v) => v === currentView.value);
  const nextIndex = (currentIndex + 1) % viewOptions.length; // Corrected circular logic
  currentView.value = viewOptions[nextIndex];
};

function toDefaultTimeZone(event){
  return {
    ...event,
    start: event.start.local(defaultTimezoneName.value),
    end: event.end.local(defaultTimezoneName.value)
  }
}

function updateEvent({ event, changes }) {
  const updateIndex = myEvents.value.findIndex((innerEvent) => innerEvent.title === event.title)
  const updatedEvent={
    ...event,
    ...changes
  } 
  myEvents.value[updateIndex] = toDefaultTimeZone(updatedEvent)
}

function createEvent(event) {
  myEvents.value.push(toDefaultTimeZone(event))
}

/**
 * Calendar 配置项
 * @see https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md
 */
const options = computed(() => ({
  timezone: {
    zones,
  },
  week: {
    showNowIndicator: true,
    showTimezoneCollapseButton: false,
    timezonesCollapsed: false,
    hourStart: 0,
    hourEnd: 24,
    eventView: ['time'],
    taskView: false,
    collapseDuplicateEvents: true,
  },
}))

</script>

<style scoped>
.intro {
  width: 100%;
  height: 100vh;
}
</style>

<style>
.my-calendar {
  width: 100%;
  height: 100%;
}
</style>

📄 License

MIT License

Related Packages

@lkmadushan/vue-tuicalendar

A Vue.js wrapper for TOAST UI Calendar

4,029 130
@enso-ui/calendar

Calendar page modules and event-management components for Enso UI.

8,197 0
vue-mobile-calendar

a vue component of calendar for mobile Vue移动端日期选择控件

5,490 210
vue2-event-calendar

A vue2 calendar component, have week and month two mode, custom render event

5,382 74
ele-calendar

A Vue.js calendar

3,361

Version History

Version Released Vue License
0.3.1 ^3 MIT
0.2.0 ^3 MIT
0.1.0 ^3 MIT
Pre-releases (1)
Version Released Vue License
0.2.0-beta.0 ^3 MIT