diff --git a/db/TDesign.db b/db/TDesign.db
index 3e277867e..b912cf045 100644
Binary files a/db/TDesign.db and b/db/TDesign.db differ
diff --git a/packages/products/tdesign-miniprogram/src/calendar/README.en-US.md b/packages/products/tdesign-miniprogram/src/calendar/README.en-US.md
index e0ba4434f..b9e753b3f 100644
--- a/packages/products/tdesign-miniprogram/src/calendar/README.en-US.md
+++ b/packages/products/tdesign-miniprogram/src/calendar/README.en-US.md
@@ -15,6 +15,7 @@ format | Function | - | Typescript:`CalendarFormatType ` `type CalendarFormatT
locale-text | Object | - | Typescript:`CalendarLocaleText` `interface CalendarLocaleText {title?: string; weekdays?: string[]; monthTitle?: string; months?: string[]; confirm?: string;}`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts) | N
max-date | Number | - | \- | N
min-date | Number | - | \- | N
+switch-mode | String | none | options: none/month/year-month | N
title | String / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
type | String | 'single' | options: single/multiple/range | N
use-popup | Boolean | true | `0.32.0` | N
diff --git a/packages/products/tdesign-miniprogram/src/calendar/README.md b/packages/products/tdesign-miniprogram/src/calendar/README.md
index 3950f8c20..63e693bca 100644
--- a/packages/products/tdesign-miniprogram/src/calendar/README.md
+++ b/packages/products/tdesign-miniprogram/src/calendar/README.md
@@ -15,6 +15,7 @@ format | Function | - | 用于格式化日期的函数。TS 类型:`CalendarFo
locale-text | Object | - | 国际化文案。TS 类型:`CalendarLocaleText` `interface CalendarLocaleText {title?: string; weekdays?: string[]; monthTitle?: string; months?: string[]; confirm?: string;}`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts) | N
max-date | Number | - | 最大可选的日期,不传则默认半年后 | N
min-date | Number | - | 最小可选的日期,不传则默认今天 | N
+switch-mode | String | none | 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换。可选项:none/month/year-month | N
title | String / Slot | - | 标题,不传默认为“请选择日期”。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
type | String | 'single' | 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择。可选项:single/multiple/range | N
use-popup | Boolean | true | `0.32.0`。是否使用弹出层包裹日历 | N
diff --git a/packages/products/tdesign-miniprogram/src/calendar/props.ts b/packages/products/tdesign-miniprogram/src/calendar/props.ts
index ef1144380..4cdb8ceb3 100644
--- a/packages/products/tdesign-miniprogram/src/calendar/props.ts
+++ b/packages/products/tdesign-miniprogram/src/calendar/props.ts
@@ -37,6 +37,11 @@ const props: TdCalendarProps = {
minDate: {
type: Number,
},
+ /** 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换 */
+ switchMode: {
+ type: String,
+ value: 'none',
+ },
/** 标题,不传默认为“请选择日期” */
title: {
type: String,
diff --git a/packages/products/tdesign-miniprogram/src/calendar/type.ts b/packages/products/tdesign-miniprogram/src/calendar/type.ts
index 7e8db7283..7fb466b5f 100644
--- a/packages/products/tdesign-miniprogram/src/calendar/type.ts
+++ b/packages/products/tdesign-miniprogram/src/calendar/type.ts
@@ -59,6 +59,14 @@ export interface TdCalendarProps {
type: NumberConstructor;
value?: number;
};
+ /**
+ * 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
+ * @default none
+ */
+ switchMode?: {
+ type: StringConstructor;
+ value?: 'none' | 'month' | 'year-month';
+ };
/**
* 标题,不传默认为“请选择日期”
*/
diff --git a/packages/products/tdesign-mobile-react/src/calendar/calendar.en-US.md b/packages/products/tdesign-mobile-react/src/calendar/calendar.en-US.md
index 2191bfb21..6f48fe492 100644
--- a/packages/products/tdesign-mobile-react/src/calendar/calendar.en-US.md
+++ b/packages/products/tdesign-mobile-react/src/calendar/calendar.en-US.md
@@ -1,18 +1,27 @@
:: BASE_DOC ::
## API
+
### Calendar Props
name | type | default | description | required
-- | -- | -- | -- | --
-className | String | - | 类名 | N
-style | Object | - | 样式,Typescript:`React.CSSProperties` | N
-confirmBtn | TNode | '' | Typescript:`string \| ButtonProps \| TNode \| null`,[Button API Documents](./button?tab=api)。[see more ts definition](https://github.com/TDesignOteam/tdesign-mobile-react/blob/develop/src/common.ts)。[see more ts definition](https://github.com/TDesignOteam/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+className | String | - | className of component | N
+style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
+autoClose | Boolean | true | \- | N
+confirmBtn | TNode | '' | Typescript:`string \| ButtonProps \| TNode \| null`,[Button API Documents](./button?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
firstDayOfWeek | Number | 0 | \- | N
-maxDate | Number / Date | - | \- | N
-minDate | Number / Date | - | \- | N
-title | String | - | \- | N
-type | String | single | options:single/multiple/range | N
-value | Number / Array / Date | - | Typescript:`CalendarValue \| CalendarValue[]` `type CalendarValue = number \| Date`。[see more ts definition](https://github.com/TDesignOteam/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
-defaultValue | Number / Array / Date | - | uncontrolled property。Typescript:`CalendarValue \| CalendarValue[]` `type CalendarValue = number \| Date`。[see more ts definition](https://github.com/TDesignOteam/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+format | Function | - | Typescript:`CalendarFormatType ` `type CalendarFormatType = (day: TDate) => TDate` `type TDateType = 'selected' \| 'disabled' \| 'start' \| 'centre' \| 'end' \| ''` `interface TDate { date: Date; day: number; type: TDateType; className?: string; prefix?: string; suffix?: string;}`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+maxDate | Number / Date | - | Typescript:` number \| Date` | N
+minDate | Number / Date | - | Typescript:` number \| Date` | N
+switchMode | String | none | options: none/month/year-month | N
+title | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
+type | String | 'single' | options: single/multiple/range | N
+usePopup | Boolean | true | \- | N
+value | Number / Array / Date | - | Typescript:`number \| Date \| TCalendarValue[]` `type TCalendarValue = number \| Date`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+defaultValue | Number / Array / Date | - | uncontrolled property。Typescript:`number \| Date \| TCalendarValue[]` `type TCalendarValue = number \| Date`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
visible | Boolean | false | \- | N
+onChange | Function | | Typescript:`(value: Date) => void`
| N
+onClose | Function | | Typescript:`(trigger: CalendarTrigger) => void`
[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts)。
`type CalendarTrigger = 'close-btn' \| 'confirm-btn' \| 'overlay'`
| N
+onConfirm | Function | | Typescript:`(value: Date) => void`
| N
+onSelect | Function | | Typescript:`(value: Date) => void`
| N
diff --git a/packages/products/tdesign-mobile-react/src/calendar/calendar.md b/packages/products/tdesign-mobile-react/src/calendar/calendar.md
index 5790002f6..69f1e3cac 100644
--- a/packages/products/tdesign-mobile-react/src/calendar/calendar.md
+++ b/packages/products/tdesign-mobile-react/src/calendar/calendar.md
@@ -1,18 +1,27 @@
:: BASE_DOC ::
## API
+
### Calendar Props
-名称 | 类型 | 默认值 | 说明 | 必传
+名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
-confirmBtn | TNode | '' | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。。TS 类型:`string \| ButtonProps \| TNode \| null`,[Button API Documents](./button?tab=api)。[通用类型定义](https://github.com/TDesignOteam/tdesign-mobile-react/blob/develop/src/common.ts)。[详细类型定义](https://github.com/TDesignOteam/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+autoClose | Boolean | true | 自动关闭;在点击关闭按钮、确认按钮、遮罩层时自动关闭,不需要手动设置 visible | N
+confirmBtn | TNode | '' | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。TS 类型:`string \| ButtonProps \| TNode \| null`,[Button API Documents](./button?tab=api)。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
firstDayOfWeek | Number | 0 | 第一天从星期几开始,默认 0 = 周日 | N
-maxDate | Number / Date | - | 最大可选的日期,不传则默认半年后 | N
-minDate | Number / Date | - | 最小可选的日期,不传则默认今天 | N
-title | String | - | 标题,不传默认为“请选择日期” | N
-type | String | single | 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择。可选项:single/multiple/range | N
-value | Number / Array / Date | - | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。TS 类型:`CalendarValue \| CalendarValue[]` `type CalendarValue = number \| Date`。[详细类型定义](https://github.com/TDesignOteam/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
-defaultValue | Number / Array / Date | - | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。非受控属性。TS 类型:`CalendarValue \| CalendarValue[]` `type CalendarValue = number \| Date`。[详细类型定义](https://github.com/TDesignOteam/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
-visible | Boolean | false | 是否显示日历 | N
+format | Function | - | 用于格式化日期的函数。TS 类型:`CalendarFormatType ` `type CalendarFormatType = (day: TDate) => TDate` `type TDateType = 'selected' \| 'disabled' \| 'start' \| 'centre' \| 'end' \| ''` `interface TDate { date: Date; day: number; type: TDateType; className?: string; prefix?: string; suffix?: string;}`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+maxDate | Number / Date | - | 最大可选的日期,不传则默认半年后。TS 类型:` number \| Date` | N
+minDate | Number / Date | - | 最小可选的日期,不传则默认今天。TS 类型:` number \| Date` | N
+switchMode | String | none | 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换。可选项:none/month/year-month | N
+title | TNode | - | 标题,不传默认为“请选择日期”。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
+type | String | 'single' | 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择。可选项:single/multiple/range | N
+usePopup | Boolean | true | 是否使用弹出层包裹日历 | N
+value | Number / Array / Date | - | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。TS 类型:`number \| Date \| TCalendarValue[]` `type TCalendarValue = number \| Date`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+defaultValue | Number / Array / Date | - | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。非受控属性。TS 类型:`number \| Date \| TCalendarValue[]` `type TCalendarValue = number \| Date`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts) | N
+visible | Boolean | false | 是否显示日历;`usePopup` 为 true 时有效 | N
+onChange | Function | | TS 类型:`(value: Date) => void`
不显示 confirm-btn 时,完成选择时触发(暂不支持 type = multiple) | N
+onClose | Function | | TS 类型:`(trigger: CalendarTrigger) => void`
关闭按钮时触发。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/calendar/type.ts)。
`type CalendarTrigger = 'close-btn' \| 'confirm-btn' \| 'overlay'`
| N
+onConfirm | Function | | TS 类型:`(value: Date) => void`
点击确认按钮时触发 | N
+onSelect | Function | | TS 类型:`(value: Date) => void`
点击日期时触发 | N
diff --git a/packages/products/tdesign-mobile-react/src/calendar/defaultProps.ts b/packages/products/tdesign-mobile-react/src/calendar/defaultProps.ts
index 926f628f0..b781f2cc5 100644
--- a/packages/products/tdesign-mobile-react/src/calendar/defaultProps.ts
+++ b/packages/products/tdesign-mobile-react/src/calendar/defaultProps.ts
@@ -5,8 +5,11 @@
import { TdCalendarProps } from './type';
export const calendarDefaultProps: TdCalendarProps = {
+ autoClose: true,
confirmBtn: '',
firstDayOfWeek: 0,
+ switchMode: 'none',
type: 'single',
+ usePopup: true,
visible: false,
};
diff --git a/packages/products/tdesign-mobile-react/src/calendar/type.ts b/packages/products/tdesign-mobile-react/src/calendar/type.ts
index 5f3d4f6d0..83cba61cb 100644
--- a/packages/products/tdesign-mobile-react/src/calendar/type.ts
+++ b/packages/products/tdesign-mobile-react/src/calendar/type.ts
@@ -9,7 +9,12 @@ import { TNode } from '../common';
export interface TdCalendarProps {
/**
- * 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。
+ * 自动关闭;在点击关闭按钮、确认按钮、遮罩层时自动关闭,不需要手动设置 visible
+ * @default true
+ */
+ autoClose?: boolean;
+ /**
+ * 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性
* @default ''
*/
confirmBtn?: ButtonProps | TNode | null;
@@ -18,37 +23,81 @@ export interface TdCalendarProps {
* @default 0
*/
firstDayOfWeek?: number;
+ /**
+ * 用于格式化日期的函数
+ */
+ format?: CalendarFormatType;
/**
* 最大可选的日期,不传则默认半年后
*/
- maxDate?: number | date;
+ maxDate?: number | Date;
/**
* 最小可选的日期,不传则默认今天
*/
- minDate?: number | date;
+ minDate?: number | Date;
+ /**
+ * 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
+ * @default none
+ */
+ switchMode?: 'none' | 'month' | 'year-month';
/**
* 标题,不传默认为“请选择日期”
- * @default ''
*/
- title?: string;
+ title?: TNode;
/**
* 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择
- * @default single
+ * @default 'single'
*/
type?: 'single' | 'multiple' | 'range';
+ /**
+ * 是否使用弹出层包裹日历
+ * @default true
+ */
+ usePopup?: boolean;
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组
*/
- value?: CalendarValue | CalendarValue[];
+ value?: number | Date | TCalendarValue[];
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组,非受控属性
*/
- defaultValue?: CalendarValue | CalendarValue[];
+ defaultValue?: number | Date | TCalendarValue[];
/**
- * 是否显示日历
+ * 是否显示日历;`usePopup` 为 true 时有效
* @default false
*/
visible?: boolean;
+ /**
+ * 不显示 confirm-btn 时,完成选择时触发(暂不支持 type = multiple)
+ */
+ onChange?: (value: Date) => void;
+ /**
+ * 关闭按钮时触发
+ */
+ onClose?: (trigger: CalendarTrigger) => void;
+ /**
+ * 点击确认按钮时触发
+ */
+ onConfirm?: (value: Date) => void;
+ /**
+ * 点击日期时触发
+ */
+ onSelect?: (value: Date) => void;
}
-export type CalendarValue = number | Date;
+export type CalendarFormatType = (day: TDate) => TDate;
+
+export type TDateType = 'selected' | 'disabled' | 'start' | 'centre' | 'end' | '';
+
+export interface TDate {
+ date: Date;
+ day: number;
+ type: TDateType;
+ className?: string;
+ prefix?: string;
+ suffix?: string;
+}
+
+export type TCalendarValue = number | Date;
+
+export type CalendarTrigger = 'close-btn' | 'confirm-btn' | 'overlay';
diff --git a/packages/products/tdesign-mobile-vue/src/calendar/calendar.en-US.md b/packages/products/tdesign-mobile-vue/src/calendar/calendar.en-US.md
index 81e8ad723..cef39b773 100644
--- a/packages/products/tdesign-mobile-vue/src/calendar/calendar.en-US.md
+++ b/packages/products/tdesign-mobile-vue/src/calendar/calendar.en-US.md
@@ -12,6 +12,7 @@ firstDayOfWeek | Number | 0 | \- | N
format | Function | - | Typescript:`CalendarFormatType ` `type CalendarFormatType = (day: TDate) => TDate` `type TDateType = 'selected' \| 'disabled' \| 'start' \| 'centre' \| 'end' \| ''` `interface TDate { date: Date; day: number; type: TDateType; className?: string; prefix?: string; suffix?: string;}`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/calendar/type.ts) | N
maxDate | Number / Date | - | Typescript:` number \| Date` | N
minDate | Number / Date | - | Typescript:` number \| Date` | N
+switchMode | String | none | options: none/month/year-month | N
title | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
type | String | 'single' | options: single/multiple/range | N
usePopup | Boolean | true | \- | N
diff --git a/packages/products/tdesign-mobile-vue/src/calendar/calendar.md b/packages/products/tdesign-mobile-vue/src/calendar/calendar.md
index d094a1a98..ca599e4b0 100644
--- a/packages/products/tdesign-mobile-vue/src/calendar/calendar.md
+++ b/packages/products/tdesign-mobile-vue/src/calendar/calendar.md
@@ -6,12 +6,13 @@
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
-confirmBtn | String / Object / Slot / Function | '' | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。。TS 类型:`string \| ButtonProps \| TNode \| null`,[Button API Documents](./button?tab=api)。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/calendar/type.ts) | N
+confirmBtn | String / Object / Slot / Function | '' | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。TS 类型:`string \| ButtonProps \| TNode \| null`,[Button API Documents](./button?tab=api)。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/calendar/type.ts) | N
defaultVisible | Boolean | false | 是否显示日历;`usePopup` 为 true 时有效。非受控属性 | N
firstDayOfWeek | Number | 0 | 第一天从星期几开始,默认 0 = 周日 | N
format | Function | - | 用于格式化日期的函数。TS 类型:`CalendarFormatType ` `type CalendarFormatType = (day: TDate) => TDate` `type TDateType = 'selected' \| 'disabled' \| 'start' \| 'centre' \| 'end' \| ''` `interface TDate { date: Date; day: number; type: TDateType; className?: string; prefix?: string; suffix?: string;}`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/calendar/type.ts) | N
maxDate | Number / Date | - | 最大可选的日期,不传则默认半年后。TS 类型:` number \| Date` | N
minDate | Number / Date | - | 最小可选的日期,不传则默认今天。TS 类型:` number \| Date` | N
+switchMode | String | none | 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换。可选项:none/month/year-month | N
title | String / Slot / Function | - | 标题,不传默认为“请选择日期”。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
type | String | 'single' | 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择。可选项:single/multiple/range | N
usePopup | Boolean | true | 是否使用弹出层包裹日历 | N
diff --git a/packages/products/tdesign-mobile-vue/src/calendar/props.ts b/packages/products/tdesign-mobile-vue/src/calendar/props.ts
index 1cf5863bf..3fc4b3c0f 100644
--- a/packages/products/tdesign-mobile-vue/src/calendar/props.ts
+++ b/packages/products/tdesign-mobile-vue/src/calendar/props.ts
@@ -8,16 +8,22 @@ import { TdCalendarProps } from './type';
import { PropType } from 'vue';
export default {
- /** 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。 */
+ /** 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性 */
confirmBtn: {
type: [String, Object, Function] as PropType,
default: '',
},
+ /** 是否显示日历;`usePopup` 为 true 时有效。非受控属性 */
+ defaultVisible: Boolean,
/** 第一天从星期几开始,默认 0 = 周日 */
firstDayOfWeek: {
type: Number,
default: 0,
},
+ /** 用于格式化日期的函数 */
+ format: {
+ type: Function as PropType,
+ },
/** 最大可选的日期,不传则默认半年后 */
maxDate: {
type: [Number, Date] as PropType,
@@ -26,10 +32,18 @@ export default {
minDate: {
type: [Number, Date] as PropType,
},
+ /** 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换 */
+ switchMode: {
+ type: String as PropType,
+ default: 'none' as TdCalendarProps['switchMode'],
+ validator(val: TdCalendarProps['switchMode']): boolean {
+ if (!val) return true;
+ return ['none', 'month', 'year-month'].includes(val);
+ },
+ },
/** 标题,不传默认为“请选择日期” */
title: {
- type: String,
- default: '',
+ type: [String, Function] as PropType,
},
/** 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择 */
type: {
@@ -40,6 +54,11 @@ export default {
return ['single', 'multiple', 'range'].includes(val);
},
},
+ /** 是否使用弹出层包裹日历 */
+ usePopup: {
+ type: Boolean,
+ default: true,
+ },
/** 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组 */
value: {
type: [Number, Array, Date] as PropType,
@@ -53,6 +72,14 @@ export default {
defaultValue: {
type: [Number, Array, Date] as PropType,
},
- /** 是否显示日历 */
+ /** 是否显示日历;`usePopup` 为 true 时有效。支持语法糖 `v-model:visible` */
visible: Boolean,
+ /** 不显示 confirm-btn 时,完成选择时触发(暂不支持 type = multiple) */
+ onChange: Function as PropType,
+ /** 关闭按钮时触发 */
+ onClose: Function as PropType,
+ /** 点击确认按钮时触发 */
+ onConfirm: Function as PropType,
+ /** 点击日期时触发 */
+ onSelect: Function as PropType,
};
diff --git a/packages/products/tdesign-mobile-vue/src/calendar/type.ts b/packages/products/tdesign-mobile-vue/src/calendar/type.ts
index 7d5201b5a..0951ced0b 100644
--- a/packages/products/tdesign-mobile-vue/src/calendar/type.ts
+++ b/packages/products/tdesign-mobile-vue/src/calendar/type.ts
@@ -9,50 +9,99 @@ import { TNode } from '../common';
export interface TdCalendarProps {
/**
- * 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。
+ * 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性
* @default ''
*/
confirmBtn?: string | ButtonProps | TNode | null;
+ /**
+ * 是否显示日历;`usePopup` 为 true 时有效。非受控属性
+ * @default false
+ */
+ defaultVisible?: boolean;
/**
* 第一天从星期几开始,默认 0 = 周日
* @default 0
*/
firstDayOfWeek?: number;
+ /**
+ * 用于格式化日期的函数
+ */
+ format?: CalendarFormatType;
/**
* 最大可选的日期,不传则默认半年后
*/
- maxDate?: number | date;
+ maxDate?: number | Date;
/**
* 最小可选的日期,不传则默认今天
*/
- minDate?: number | date;
+ minDate?: number | Date;
+ /**
+ * 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
+ * @default none
+ */
+ switchMode?: 'none' | 'month' | 'year-month';
/**
* 标题,不传默认为“请选择日期”
- * @default ''
*/
- title?: string;
+ title?: string | TNode;
/**
* 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择
- * @default single
+ * @default 'single'
*/
type?: 'single' | 'multiple' | 'range';
+ /**
+ * 是否使用弹出层包裹日历
+ * @default true
+ */
+ usePopup?: boolean;
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组
*/
- value?: CalendarValue | CalendarValue[];
+ value?: number | Date | TCalendarValue[];
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组,非受控属性
*/
- defaultValue?: CalendarValue | CalendarValue[];
+ defaultValue?: number | Date | TCalendarValue[];
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组
*/
- modelValue?: CalendarValue | CalendarValue[];
+ modelValue?: number | Date | TCalendarValue[];
/**
- * 是否显示日历
+ * 是否显示日历;`usePopup` 为 true 时有效。支持语法糖 `v-model:visible`
* @default false
*/
visible?: boolean;
+ /**
+ * 不显示 confirm-btn 时,完成选择时触发(暂不支持 type = multiple)
+ */
+ onChange?: (value: Date) => void;
+ /**
+ * 关闭按钮时触发
+ */
+ onClose?: (trigger: CalendarTrigger) => void;
+ /**
+ * 点击确认按钮时触发
+ */
+ onConfirm?: (value: Date) => void;
+ /**
+ * 点击日期时触发
+ */
+ onSelect?: (value: Date) => void;
}
-export type CalendarValue = number | Date;
+export type CalendarFormatType = (day: TDate) => TDate;
+
+export type TDateType = 'selected' | 'disabled' | 'start' | 'centre' | 'end' | '';
+
+export interface TDate {
+ date: Date;
+ day: number;
+ type: TDateType;
+ className?: string;
+ prefix?: string;
+ suffix?: string;
+}
+
+export type TCalendarValue = number | Date;
+
+export type CalendarTrigger = 'close-btn' | 'confirm-btn' | 'overlay';
diff --git a/packages/scripts/api.json b/packages/scripts/api.json
index 2f30d82e3..c4342fdbe 100644
--- a/packages/scripts/api.json
+++ b/packages/scripts/api.json
@@ -16766,6 +16766,49 @@
"Array"
]
},
+ {
+ "id": 1731498486,
+ "platform_framework": [
+ "8",
+ "16",
+ "32",
+ "64"
+ ],
+ "component": "Calendar",
+ "field_category": 1,
+ "field_name": "switchMode",
+ "field_type": [
+ "1"
+ ],
+ "field_default_value": "none",
+ "field_enum": "none/month/year-month",
+ "field_desc_zh": "【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换",
+ "field_desc_en": null,
+ "field_required": 0,
+ "event_input": "",
+ "create_time": "2024-11-13 11:48:06",
+ "update_time": "2024-11-13 11:48:06",
+ "event_output": null,
+ "custom_field_type": null,
+ "syntactic_sugar": null,
+ "readonly": 1,
+ "html_attribute": 0,
+ "trigger_elements": "",
+ "deprecated": 0,
+ "version": "",
+ "test_description": null,
+ "support_default_value": 0,
+ "field_category_text": "Props",
+ "platform_framework_text": [
+ "Vue(Mobile)",
+ "React(Mobile)",
+ "Angular(Mobile)",
+ "Miniprogram"
+ ],
+ "field_type_text": [
+ "String"
+ ]
+ },
{
"id": 644,
"platform_framework": [