-
-
-
-
- {{ showDays[(i - 1) * 7 + (j - 1)].getDate() }}
-
-
+
+
+ {{ item.year }} 年 {{ item.month + 1 }} 月
+
+
+
+
+ {{ dateItem.prefix }}
+ {{ dateItem.day }}
+
+ {{ dateItem.suffix }}
+
+
+
+
-
+
-
- {{ confirmBtn }}
+
@@ -58,183 +56,205 @@
+
+
diff --git a/src/calendar/demos/base.vue b/src/calendar/demos/base.vue
index d5da19b6f..765836139 100644
--- a/src/calendar/demos/base.vue
+++ b/src/calendar/demos/base.vue
@@ -1,18 +1,18 @@
-
-
+
+
diff --git a/src/calendar/demos/cell.vue b/src/calendar/demos/cell.vue
deleted file mode 100644
index f7c48a941..000000000
--- a/src/calendar/demos/cell.vue
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- {{ item }}
-
- 描述
-
-
-
-
-
-
-
diff --git a/src/calendar/demos/color.vue b/src/calendar/demos/color.vue
deleted file mode 100644
index 142fd6772..000000000
--- a/src/calendar/demos/color.vue
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/src/calendar/demos/custom-button.vue b/src/calendar/demos/custom-button.vue
new file mode 100644
index 000000000..0a38047c8
--- /dev/null
+++ b/src/calendar/demos/custom-button.vue
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/src/calendar/demos/custom-range.vue b/src/calendar/demos/custom-range.vue
new file mode 100644
index 000000000..5a7645af5
--- /dev/null
+++ b/src/calendar/demos/custom-range.vue
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/src/calendar/demos/custom-text.vue b/src/calendar/demos/custom-text.vue
new file mode 100644
index 000000000..c302540bb
--- /dev/null
+++ b/src/calendar/demos/custom-text.vue
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
diff --git a/src/calendar/demos/head.vue b/src/calendar/demos/head.vue
deleted file mode 100644
index 0ee0a6aa4..000000000
--- a/src/calendar/demos/head.vue
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- 自定义标题
-
-
-
-
-
-
diff --git a/src/calendar/demos/mobile.vue b/src/calendar/demos/mobile.vue
index 78fefaeae..d714263d1 100644
--- a/src/calendar/demos/mobile.vue
+++ b/src/calendar/demos/mobile.vue
@@ -6,16 +6,18 @@
+
+
-
-
-
-
+
+
+
+
-
+
diff --git a/src/calendar/demos/multiple.vue b/src/calendar/demos/multiple.vue
new file mode 100644
index 000000000..381c09111
--- /dev/null
+++ b/src/calendar/demos/multiple.vue
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
diff --git a/src/calendar/demos/range.vue b/src/calendar/demos/range.vue
new file mode 100644
index 000000000..4b6ee0e8f
--- /dev/null
+++ b/src/calendar/demos/range.vue
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
diff --git a/src/calendar/demos/value.vue b/src/calendar/demos/value.vue
deleted file mode 100644
index 82db1a794..000000000
--- a/src/calendar/demos/value.vue
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/src/calendar/props.ts b/src/calendar/props.ts
index 760cf3aa7..6fe48b28a 100644
--- a/src/calendar/props.ts
+++ b/src/calendar/props.ts
@@ -8,41 +8,49 @@ import { TdCalendarProps } from './type';
import { PropType } from 'vue';
export default {
- /**
- * 控制日历显示隐藏
- */
- modelValue: {
- type: Boolean,
- },
- // 按钮颜色
- bgColor: {
- type: String,
- default: '#0053DB',
- },
- /**
- * 确认按钮
- */
+ /** 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。 */
confirmBtn: {
- type: String,
- default: '确认',
+ type: [String, Object, Function] as PropType
,
+ default: '',
},
- /**
- * 第一天从星期几开始,仅在日历展示维度为月份时(mode = month)有效。默认为 1
- */
+ /** 第一天从星期几开始,默认 0 = 周日 */
firstDayOfWeek: {
type: Number,
+ default: 0,
},
- /**
- * 头部插槽(左上角处,默认不显示任何内容)
- */
- head: {
- type: String,
+ /** 用于格式化日期的函数 */
+ format: {
+ type: Function as PropType,
},
- /**
- * 当前高亮的日期
- */
+ /** 最大可选的日期,不传则默认半年后 */
+ maxDate: {
+ type: [Number, Date] as PropType,
+ },
+ /** 最小可选的日期,不传则默认今天 */
+ minDate: {
+ type: [Number, Date] as PropType,
+ },
+ /** 标题,不传默认为“请选择日期” */
+ title: {
+ type: [String, Function] as PropType,
+ },
+ /** 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择 */
+ type: {
+ type: String as PropType,
+ default: 'single' as TdCalendarProps['type'],
+ validator(val: TdCalendarProps['type']): boolean {
+ if (!val) return true;
+ return ['single', 'multiple', 'range'].includes(val);
+ },
+ },
+ /** 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组 */
value: {
- type: Date as unknown as PropType,
- default: new Date(),
+ type: [Number, Array, Date] as PropType,
},
+ /** 是否显示日历 */
+ visible: Boolean,
+ /** 点击确认按钮时触发 */
+ onConfirm: Function as PropType,
+ /** 选择日期时触发 */
+ onSelect: Function as PropType,
};
diff --git a/src/calendar/type.ts b/src/calendar/type.ts
index ccc9b0c05..54a9f03de 100644
--- a/src/calendar/type.ts
+++ b/src/calendar/type.ts
@@ -3,50 +3,70 @@
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */
+
+import { ButtonProps } from '../button';
+import { TNode } from '../common';
+
export interface TdCalendarProps {
/**
- * 控制日历显示隐藏
+ * 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。
+ * @default ''
*/
- modelValue: boolean;
+ confirmBtn?: string | TNode | ButtonProps | null;
/**
- * 背景颜色
+ * 第一天从星期几开始,默认 0 = 周日
+ * @default 0
*/
- bgColor?: string;
-
+ firstDayOfWeek?: number;
/**
- * 确认按钮
+ * 用于格式化日期的函数
*/
- confirmBtn?: string;
+ format?: (day: TDate) => TDate;
/**
- * 第一天从星期几开始,仅在日历展示维度为月份时(mode = month)有效。默认为 1
+ * 最大可选的日期,不传则默认半年后
*/
- firstDayOfWeek?: number;
+ maxDate?: number | Date;
/**
- * 头部插槽(左上角处,默认不显示任何内容)
+ * 最小可选的日期,不传则默认今天
*/
- head?: string;
+ minDate?: number | Date;
/**
- * 当前高亮的日期
+ * 标题,不传默认为“请选择日期”
*/
- value?: Date;
+ title?: string | TNode;
+ /**
+ * 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择
+ * @default 'single'
+ */
+ type?: 'single' | 'multiple' | 'range';
+ /**
+ * 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组
+ */
+ value?: number | Date | TCalendarValue[];
+ /**
+ * 是否显示日历
+ * @default false
+ */
+ visible?: boolean;
+ /**
+ * 点击确认按钮时触发
+ */
+ onConfirm?: (value: Date) => void;
+ /**
+ * 选择日期时触发
+ */
+ onSelect?: (value: Date) => void;
}
-export interface DateCellDescription {
- date: Date;
- label: string;
-}
+export type TDateType = 'selected' | 'disabled' | 'start' | 'centre' | 'end' | '';
-export type CalendarCell = {
- year: number;
- month: number;
+export interface TDate {
+ date: Date;
day: number;
+ type: TDateType;
+ className?: string;
+ prefix?: string;
+ suffix?: string;
}
-export type CalendarValue = {
- year: number;
- month: number;
- day: number;
- week: number;
- date: string;
- isToday: boolean;
-};
\ No newline at end of file
+export type TCalendarValue = number | Date;