QCalendar Documentation

repository·dev·Indexed 19 days ago

https://github.com/quasarframework/quasar-ui-qcalendar

A highly configurable Vue-based calendar component library providing multiple view modes including day, month, scheduler, agenda, resource, and task views. Available as a standalone Vue plugin, UMD module, and Quasar App Extension. Version 5.2.0 requires Node.js >=22.13, pnpm >=11.3.0, and for the app extension, Quasar v2 with @quasar/app-vite >=3.0.0.

Tokens
35.5K
Snippets
87
Records
176
Agent score
67%

What's inside QCalendar

  1. Overview of QCalendar views and features

    dev

    QCalendar is a comprehensive calendar solution for Vue applications. It provides several specialized view modes to handle different scheduling needs:

    • Day views: Supports 1-day to 6-day ranges.
    • Week view: Standard weekly scheduling.
    • Monthly view: Traditional month-at-a-glance.
    • Scheduler view: For managing complex schedules.
    • Agenda view: List-based view of upcoming events.
    • Resource view: View schedules based on specific resources.
    • Task view: Focused on task management.

    Additional features include support for locales, optional theming, setting the first day of the week (e.g., Monday), 5-day work weeks, work week numbers, selected/disabled days, and day of year tracking.

  2. What is QCalendar

    dev

    QCalendar is a highly configurable calendar component for Vue that provides multiple view modes including day, week, monthly, scheduler, agenda, resource, and task views.

    It is designed to be less opinionated than traditional calendar libraries; it does not manage events or reminders internally. Instead, it provides the UI infrastructure (via events, slots, and methods) for developers to implement their own event management logic.

    Key characteristics:

    • Views: Supports various layouts like Scheduler (with hierarchical trees), Resource, Agenda (with Planner modes), and Task (Gantt charts/timesheets).
    • Date Logic: Uses Gregorian dates by default but supports non-Gregorian workflows (Hijri, Saka, Hebrew, Persian) via Timestamp calendar adapters.
    • Customization: Highly extensible through Vue slots and CSS variables.
    • Dependencies: Has no external dependencies like Moment.js or jQuery, relying only on Vue and @timestamp-js/core primitives.
  3. Overview of QCalendar views and capabilities

    dev

    QCalendar is a powerful Quasar component providing multiple calendar view modes. It is highly configurable and supports features like locales, theming, custom work weeks (e.g., 5-day weeks), work week numbers, and day selection/disabling.

    Supported views include:

    • Day view: Viewing 1 to 7 days for a week.
    • Monthly view: Standard month-based calendar.
    • Scheduler view: For managing schedules.
    • Agenda view: List-based view of upcoming events.
    • Resource view: View events mapped to specific resources.
    • Task view: Specialized view for task management.
    • Mini-mode: Compact versions of views (e.g., for multi-month selection).
  4. Identify the components of QCalendar

    dev

    QCalendar is composed of several specialized components designed for different calendar views and use cases. Understanding these components helps in selecting the right view for your application requirements:

    • QCalendarDay: The base component for day-based views.
    • QCalendarDay (week): A specialized version of the day view optimized for weekly layouts.
    • QCalendarMonth: A component for full month grid views.
    • QCalendarMonth (mini-mode): A compact version of the month view, typically used for date pickers or sidebars.
    • QCalendarScheduler: A complex view designed for scheduling tasks or events across time and resources.
    • QCalendarResource: Represents individual resources (like rooms or staff) within a scheduler view.
    • QCalendarAgenda: A list-based view showing upcoming events or tasks.
    • QCalendarTask: The visual representation of an individual event or task within a calendar view.
  5. What is QCalendarResource and when to use it

    dev

    Concept

    QCalendarResource is a specialized calendar view that groups an interval timeline by resource. Instead of a standard date-centric view, each row represents a specific assignable item (such as a person, room, machine, or route), and the columns represent time intervals for the active date range.

    Use cases:

    • Comparing availability or scheduled work across different resources.
    • Room booking systems.
    • Staff assignment and service dispatch.
    • Equipment planning.
    • Any view where the resource identity is as critical as the time dimension.
  6. What is QCalendarScheduler?

    dev
    QCalendarScheduler is a specialized calendar view that groups a day-oriented calendar by resource while keeping date columns visible. It is designed for resource-first planning boards where each resource (e.g., teams, locations, assets, or lanes) owns work across one or more days. Unlike a standard interval grid, it focuses on assigning and reviewing work by day for specific resources.
  7. Bridge between Gregorian and Native Calendar dates

    dev

    When working outside of a QCalendar slot (e.g., processing stored Gregorian data), use the epochDay bridge provided by @timestamp-js/core to convert between systems.

    To convert Gregorian to Native:

    1. Parse the Gregorian timestamp.
    2. Get its epochDay.
    3. Use createCalendarTimestampFromEpochDay with the target adapter.

    To convert Native to Gregorian:

    1. Get the epochDay from the native timestamp.
    2. Use createCalendarTimestampFromEpochDay (passing the adapter) to get a timestamp that can be treated as Gregorian.
    import {
      createCalendarTimestampFromEpochDay,
      getEpochDay,
      parseTimestamp,
      type Timestamp,
    } from '@timestamp-js/core'
    import { islamicCivilCalendar } from '@timestamp-js/calendar-islamic'
    
    // Gregorian -> Hijri
    function toHijri(timestamp: Timestamp) {
      return createCalendarTimestampFromEpochDay(getEpochDay(timestamp), islamicCivilCalendar)
    }
    
    // Hijri -> Gregorian
    function toGregorian(hijriTimestamp: Timestamp) {
      return createCalendarTimestampFromEpochDay(getEpochDay(hijriTimestamp, islamicCivilCalendar))
    }
    
    const selectedGregorian = parseTimestamp('2024-03-25')!
    const selectedHijri = toHijri(selectedGregorian)
  8. Use Calendar Adapters for non-Gregorian systems

    dev

    Use the calendar-system property to follow a non-Gregorian calendar system. When using an adapter:

    • Model values and date-bearing slot data are native to that specific calendar.
    • The adapter controls month boundaries, outside-day state, and navigation (previous/next month).
    • Outside days are disabled based on the native calendar's month boundaries rather than the Gregorian month.
  9. Use non-Gregorian calendar systems

    dev

    You can opt-in to non-Gregorian calendar systems by providing an adapter object to the calendar-system property. This is done using adapters from the @timestamp-js packages.

    When an adapter is active:

    • model-value uses the adapter's native date format.
    • The calendar uses the adapter's default locale, direction, and weekday order.
    • Date-bearing slots and mouse-event scopes receive adapter-native timestamps and a scope.calendarIdentity object containing Gregorian interop metadata like gregorianDate and epochDay.
    <script setup>
    import { ref } from 'vue'
    import { islamicCivilCalendar } from '@timestamp-js/calendar-islamic'
    
    const selectedDate = ref('1445-09-15')
    </script>
    
    <template>
      <q-calendar-month v-model="selectedDate" :calendar-system="islamicCivilCalendar" />
    </template>
  10. Use Slots and Events with Scopes

    dev

    QCalendar uses slots and events that share a common scope object.

    Data Structures

    • Slots: Provide { scope: { ... } }.
    • Events: Provide { scope: { ... }, event: { ... } }.

    Destructuring Scopes

    You can destructure the scope directly in your template:

    <!-- Destructure the whole scope -->
    <q-calendar-day #day="{ scope }" />
    
    <!-- Destructure specific properties like timestamp -->
    <q-calendar-day #day="{ scope: { timestamp } }" />

    Calendar Systems and Timestamps

    When a calendar-system is set, the scope includes additional properties for non-Gregorian systems:

    • timestamp: The native timestamp from the active adapter.
    • calendarTimestamp: The timestamp specific to the calendar system.
    • calendarIdentity: Contains gregorianDate (for external Gregorian systems) and epochDay (for neutral comparisons).

    Range-style events (like change) also expose adapter-aware fields: calendarStart, calendarEnd, calendarDays, and calendarSystem.

    <!-- Accessing advanced calendar identity properties in a slot -->
    <q-calendar-day 
      #day="{ scope: { timestamp, calendarTimestamp, calendarIdentity } }"
    />
  11. Configure QCalendarMonth Mini-Mode

    dev

    QCalendarMonth mini-mode is a compact version of the month calendar designed for dense layouts like sidebars, date pickers, or dashboards. It uses the same date-grid model as the full month calendar but with reduced visual weight.

    Key features include:

    • Responsive Breakpoints: Use mini-mode="auto" combined with a breakpoint prop (e.g., breakpoint="sm") to automatically switch to mini-mode when the viewport is small.
    • Event Handling: The component fires a @mini-mode event (boolean) which can be used to adjust other properties dynamically, such as day-height.
    • Visual Consistency: Mini-mode supports dark mode and responds to the same CSS variables and themes as the full month view.
    <!-- Example of dynamic day-height based on mini-mode state -->
    <QCalendarMonth
      mini-mode="auto"
      breakpoint="sm"
      @mini-mode="isMiniMode = $event"
      :day-height="isMiniMode ? 0 : 50"
    />