UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 2.9 kB
{"version":3,"file":"calendar.mjs","names":[],"sources":["../../../../../../packages/components/calendar/src/calendar.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isArray,\n isDate,\n} from '@element-plus/utils'\nimport { INPUT_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { ExtractPublicPropTypes } from 'vue'\n\nexport type CalendarDateType =\n | 'prev-month'\n | 'next-month'\n | 'prev-year'\n | 'next-year'\n | 'today'\n\nconst isValidRange = (range: unknown): range is [Date, Date] =>\n isArray(range) && range.length === 2 && range.every((item) => isDate(item))\n\nexport interface CalendarProps {\n /**\n * @description binding value\n */\n modelValue?: Date\n /**\n * @description time range, including start time and end time.\n * Start time must be start day of week, end time must be end day of week, the time span cannot exceed two months.\n */\n range?: [Date, Date]\n /**\n * @description type of the controller for the Calendar header\n */\n controllerType?: 'button' | 'select'\n /**\n * @description format label when `controller-type` is 'select'\n */\n formatter?: (value: number, type: 'year' | 'month') => string | number\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `CalendarProps` instead.\n */\nexport const calendarProps = buildProps({\n /**\n * @description binding value\n */\n modelValue: {\n type: Date,\n },\n /**\n * @description time range, including start time and end time.\n * Start time must be start day of week, end time must be end day of week, the time span cannot exceed two months.\n */\n range: {\n type: definePropType<[Date, Date]>(Array),\n validator: isValidRange,\n },\n /**\n * @description type of the controller for the Calendar header\n */\n controllerType: {\n type: String,\n values: ['button', 'select'],\n default: 'button',\n },\n /**\n * @description format label when `controller-type` is 'select'\n */\n formatter: {\n type: definePropType<\n (value: number, type: 'year' | 'month') => string | number\n >(Function),\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `CalendarProps` instead.\n */\nexport type CalendarPropsPublic = ExtractPublicPropTypes<typeof calendarProps>\n\nexport const calendarEmits = {\n [UPDATE_MODEL_EVENT]: (value: Date) => isDate(value),\n [INPUT_EVENT]: (value: Date) => isDate(value),\n}\nexport type CalendarEmits = typeof calendarEmits\n"],"mappings":";;;;;AAiBA,MAAM,gBAAgB,UACpB,QAAQ,MAAM,IAAI,MAAM,WAAW,KAAK,MAAM,OAAO,SAAS,OAAO,KAAK,CAAC;;;;AAyB7E,MAAa,gBAAgB,WAAW;CAItC,YAAY,EACV,MAAM,MACP;CAKD,OAAO;EACL,MAAM,eAA6B,MAAM;EACzC,WAAW;EACZ;CAID,gBAAgB;EACd,MAAM;EACN,QAAQ,CAAC,UAAU,SAAS;EAC5B,SAAS;EACV;CAID,WAAW,EACT,MAAM,eAEJ,SAAS,EACZ;CACF,CAAU;AAOX,MAAa,gBAAgB;EAC1B,sBAAsB,UAAgB,OAAO,MAAM;EACnD,eAAe,UAAgB,OAAO,MAAM;CAC9C"}