外观
Calendar 日历
在月视图中选择日期,可直接翻月或通过年月菜单快速跳转。
import { SCalendar } from '@icecreamqaq/shadcn/calendar'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SCalendar.v-model | DateValue | DateValue[] | null | 单选时绑定一个日期,开启 multiple 可选择多个日期。清空选中值时会发出 undefined。 |
SCalendar.layout | "month-and-year" | "month-only" | "year-only" | 选择标题中的月份和年份下拉控件。省略时显示普通月份标题。 |
SCalendar.minValue / maxValue | DateValue | 限制可选的最早与最晚日期。 |
SCalendar.locale | string | 控制月份标题和星期的本地化格式,例如 zh-CN。 |
DateValue 来自 @internationalized/date,使用 shallowRef 可以保留日期对象的原始类型。
完整 API
Calendar34 个成员
属性
| 名称 | 类型 |
|---|---|
defaultValue | DateValue |
defaultPlaceholder | DateValue |
placeholder | DateValue |
pagedNavigation | boolean |
preventDeselect | boolean |
weekStartsOn | WeekStartsOn |
weekdayFormat | WeekDayFormat |
calendarLabel | string |
fixedWeeks | boolean |
maxValue | DateValue |
minValue | DateValue |
locale | string |
numberOfMonths | number |
disabled | boolean |
readonly | boolean |
initialFocus | boolean |
isDateDisabled | Matcher |
isDateUnavailable | Matcher |
dir | Direction |
nextPage | ((placeholder: DateValue) => DateValue) |
prevPage | ((placeholder: DateValue) => DateValue) |
modelValue | DateValue | DateValue[] | null |
multiple | boolean |
disableDaysOutsideCurrentView | boolean |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
layout | LayoutTypes |
yearRange | DateValue[] |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((date: DateValue | undefined) => any) |
update:placeholder | ((date: DateValue) => any) |
插槽
| 名称 | 类型 |
|---|---|
calendar-heading | ((props: { date: DateValue; month: ReuseTemplateComponent<{ date: DateValue; }, Record<"default", undefined>>; year: ReuseTemplateComponent<{ date: DateValue; }, Record<...>>; }) => any) |
calendar-prev-icon | ((props: {}) => any) |
calendar-next-icon | ((props: {}) => any) |
CalendarCell5 个成员
属性
| 名称 | 类型 |
|---|---|
date 必填 | DateValue |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarCellTrigger6 个成员
属性
| 名称 | 类型 |
|---|---|
day 必填 | DateValue |
month 必填 | DateValue |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarGrid4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarGridBody3 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarGridHead4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarGridRow4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarHeadCell4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarHeader4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarHeading4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | (props: { headingValue: string; }) => any |
CalendarNextButton5 个成员
属性
| 名称 | 类型 |
|---|---|
nextPage | ((placeholder: DateValue) => DateValue) |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CalendarPrevButton5 个成员
属性
| 名称 | 类型 |
|---|---|
prevPage | ((placeholder: DateValue) => DateValue) |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-calendar>。
组件 SCalendar、SCalendarCell、SCalendarCellTrigger、SCalendarGrid、SCalendarGridBody、SCalendarGridHead、SCalendarGridRow、SCalendarHeadCell、SCalendarHeader、SCalendarHeading、SCalendarNextButton、SCalendarPrevButton
类型 LayoutTypes