@composy/calendar-vue
@composy/calendar-vue
Vue 3 adapter for @composy/calendar-core.
Features
useCalendar: reactiveCalendarCorestate, view data, navigation, localized title, weekday labels, hover date, and event summary.useCalendarEvents: reactiveEventManagerwrapper with batch deletion, conflict lookup, recurring occurrence expansion, and JSON/ICS import/export.useDatePicker: reactive single-date picker state and formatted value.useRangePicker: reactive range picker state, formatted value, day count, presets, and hover preview.useCalendarTheme: Vue wrapper forThemeManager,ldesign-class names, CSS variable maps, stylesheet text, and optional document style injection.calendarVuePluginandcalendarEnginePlugin: service injection for Vue and engine-style runtimes, with typedInjectionKeyexports and legacy string keys.
Quick Start
import {
useCalendar,
useCalendarEvents,
useCalendarTheme,
useRangePicker,
} from '@composy/calendar-vue'
const calendar = useCalendar({
viewMode: 'month',
showLunar: true,
showWeekNumber: true,
locale: 'zh-CN',
})
const events = useCalendarEvents(calendar.core.eventManager)
events.addEvent({
title: 'Sprint planning',
start: new Date(2026, 5, 9, 9, 0),
end: new Date(2026, 5, 9, 10, 0),
allDay: false,
})
const ics = events.exportToICS()
const importedEvents = useCalendarEvents()
importedEvents.importFromICS(ics)
const rangePicker = useRangePicker({ maxRange: 30 })
rangePicker.selectPreset('thisMonth')
rangePicker.setHoverDate(new Date(2026, 5, 12))
const theme = useCalendarTheme({ attachToDocument: true })
The ICS import/export methods support the subset and limitations documented by
@composy/calendar-core.
useCalendar().weekdayLabels remains reactive when firstDayOfWeek changes, including updates made
through the core instance or updateOptions().
Styling Contract
Vue does not duplicate style logic. It reuses @composy/calendar-core/styles.
const { classNames, cssVariables, cssText } = useCalendarTheme()
- Class names are always prefixed with
ldesign-, for exampleldesign-calendar,ldesign-calendar__day-cell, andldesign-calendar--selected. - Calendar variables use
--ldesign-calendar-*. - Color values reference
packages/colorgenerated variables such as--ld-primary-defaultand--ld-bg-surface. - Size values reference
packages/sizegenerated variables such as--ld-px-40,--ld-font-base, and--ld-spacing-md.
Load the color and size token CSS before mounting calendar UI.
When attachToDocument is enabled, useCalendarTheme() creates a stylesheet with the default id
ldesign-calendar-theme-styles and removes it when the owning component unmounts.
Plugin Usage
import { createApp } from 'vue'
import { calendarVuePlugin } from '@composy/calendar-vue'
const app = createApp(App)
app.use(calendarVuePlugin, {
locale: 'zh-CN',
loadChinaHolidays: true,
})
Typed injection keys are exported for new code. Legacy string keys are still provided for compatibility.
import { inject } from 'vue'
import { calendarInjectionKey, calendarThemeInjectionKey } from '@composy/calendar-vue'
const calendar = inject(calendarInjectionKey)
const theme = inject(calendarThemeInjectionKey)
useCalendar() can also wrap an existing CalendarCore instance without taking ownership of its
lifecycle:
const calendar = useCalendar({ core: injectedCalendar })
Build Outputs
@composy/builder generates:
dist/: browser bundlees/: ESM modules and declarationsesm/: mirrored ESM moduleslib/: CommonJS modules and declarations
Validation
pnpm --dir packages/vue run type-check
pnpm --dir packages/vue run type-check:cjs
pnpm --dir packages/vue run lint:check
pnpm --dir packages/vue run build
Builder、ESLint 和 TypeScript 配置位于 packages/vue/.ldesign/;包根的传统配置路径为兼容 shim。
License
MIT
Related Packages
A simple Vue.js datepicker component. Supports disabling of dates, inline mode,...
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.0.2 | 3.5.32 | MIT | |
| 0.0.1 | ^3.5.32 | MIT |