Skip to content

Commit 235b566

Browse files
docs(calendar): update range api desc (#791)
* docs(calendar): update `range` api desc * docs(calendar): add `CalendarValue` ts definition --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 057bfa8 commit 235b566

File tree

13 files changed

+156
-92
lines changed

13 files changed

+156
-92
lines changed

db/TDesign.db

0 Bytes
Binary file not shown.

packages/products/tdesign-react/packages/components/calendar/calendar.en-US.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,58 @@
55

66
name | type | default | description | required
77
-- | -- | -- | -- | --
8-
className | String | - | 类名 | N
9-
style | Object | - | 样式,Typescript`React.CSSProperties` | N
10-
cell | TNode | - | Typescript`string \| TNode<CalendarCell>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
11-
cellAppend | TNode | - | Typescript`string \| TNode<CalendarCell>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12-
controllerConfig | Boolean / Object | undefined | Typescript`boolean \| CalendarController` | N
8+
className | String | - | className of component | N
9+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
10+
cell | TNode | - | Typescript: `string \| TNode<CalendarCell>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
11+
cellAppend | TNode | - | Typescript: `string \| TNode<CalendarCell>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12+
controllerConfig | Boolean / Object | undefined | Typescript: `boolean \| CalendarController` | N
1313
fillWithZero | Boolean | true | \- | N
14-
firstDayOfWeek | Number | 1 | options1/2/3/4/5/6/7 | N
14+
firstDayOfWeek | Number | 1 | options: 1/2/3/4/5/6/7 | N
1515
format | String | 'YYYY-MM-DD' | \- | N
16-
head | TNode | - | Typescript`string \| TNode<ControllerOptions>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
16+
head | TNode | - | Typescript: `string \| TNode<ControllerOptions>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
1717
isShowWeekendDefault | Boolean | true | \- | N
18-
mode | String | month | optionsmonth/year | N
18+
mode | String | month | options: month/year | N
1919
month | String / Number | - | \- | N
2020
multiple | Boolean | - | \- | N
2121
preventCellContextmenu | Boolean | false | \- | N
22-
range | Array | - | Typescript`Array<CalendarValue>` | N
23-
theme | String | full | optionsfull/card | N
24-
value | String / Array / Date | - | Typescript`CalendarValue \| CalendarValue[]` `type CalendarValue = string \| Date`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
25-
week | TNode | - | Typescript`Array<string> \| TNode<CalendarWeek>` `interface CalendarWeek { day: WeekDay }` `type WeekDay = 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
22+
range | Array | - | Set the year and month display range of calendar, [start, end]. Example 1: `['2018-08', '2028-04']`. Example 2: `[new Date(2018, 8), new Date(2028, 4)]`. Only when both items from the input list can be parsed normally by `dayjs` can the specified calendar range take effect, while you can set the start or end of the range separately by inputting a list with only one item that can be parsed normally。Typescript: `Array<CalendarValue>` `type CalendarValue = string \| Date`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
23+
theme | String | full | options: full/card | N
24+
value | String / Array / Date | - | Typescript: `CalendarValue \| CalendarValue[]` `type CalendarValue = string \| Date`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
25+
week | TNode | - | Typescript: `Array<string> \| TNode<CalendarWeek>` `interface CalendarWeek { day: WeekDay }` `type WeekDay = 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
2626
year | String / Number | - | \- | N
27-
onCellClick | Function | | Typescript:`(options: { cell: CalendarCell; e: MouseEvent }) => void`<br/> | N
28-
onCellDoubleClick | Function | | Typescript:`(options: { cell: CalendarCell; e: MouseEvent }) => void`<br/> | N
29-
onCellRightClick | Function | | Typescript:`(options: { cell: CalendarCell; e: MouseEvent }) => void`<br/> | N
30-
onControllerChange | Function | | Typescript:`(options: ControllerOptions) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts)。<br/>`interface ControllerOptions { filterDate: Date; formattedFilterDate: string; mode: string; isShowWeekend: boolean }`<br/> | N
31-
onMonthChange | Function | | Typescript:`(options: { month: string; year: string }) => void`<br/> | N
27+
onCellClick | Function | | Typescript: `(options: { cell: CalendarCell; e: MouseEvent }) => void`<br/> | N
28+
onCellDoubleClick | Function | | Typescript: `(options: { cell: CalendarCell; e: MouseEvent }) => void`<br/> | N
29+
onCellRightClick | Function | | Typescript: `(options: { cell: CalendarCell; e: MouseEvent }) => void`<br/> | N
30+
onControllerChange | Function | | Typescript: `(options: ControllerOptions) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts)。<br/>`interface ControllerOptions { filterDate: Date; formattedFilterDate: string; mode: string; isShowWeekend: boolean }`<br/> | N
31+
onMonthChange | Function | | Typescript: `(options: { month: string; year: string }) => void`<br/> | N
32+
33+
### CalendarInstanceFunctions 组件实例方法
34+
35+
name | params | return | description
36+
-- | -- | -- | --
37+
className | String | - | className of component | N
38+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
39+
toCurrent | \- | \- | go to today
3240

3341
### CalendarController
3442

3543
name | type | default | description | required
3644
-- | -- | -- | -- | --
37-
current | Object | - | Typescript`{ visible?: boolean; currentDayButtonProps?: ButtonProps; currentMonthButtonProps?: ButtonProps }`[Button API Documents](./button?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
45+
current | Object | - | Typescript: `{ visible?: boolean; currentDayButtonProps?: ButtonProps; currentMonthButtonProps?: ButtonProps }`[Button API Documents](./button?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
3846
disabled | Boolean | false | \- | N
39-
mode | Object | - | Typescript`{ visible?: boolean; radioGroupProps?: RadioGroupProps }`[Radio API Documents](./radio?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
40-
month | Object | - | Typescript`{ visible?: boolean; selectProps?: SelectProps }` | N
41-
weekend | Object | - | Typescript`{ visible?: boolean; showWeekendButtonProps?: CheckTagProps; hideWeekendButtonProps?: CheckTagProps }`[Tag API Documents](./tag?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
42-
year | Object | - | Typescript`{ visible?: boolean; selectProps?: SelectProps }`[Select API Documents](./select?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
47+
mode | Object | - | Typescript: `{ visible?: boolean; radioGroupProps?: RadioGroupProps }`[Radio API Documents](./radio?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
48+
month | Object | - | Typescript: `{ visible?: boolean; selectProps?: SelectProps }` | N
49+
weekend | Object | - | Typescript: `{ visible?: boolean; showWeekendButtonProps?: CheckTagProps; hideWeekendButtonProps?: CheckTagProps }`[Tag API Documents](./tag?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
50+
year | Object | - | Typescript: `{ visible?: boolean; selectProps?: SelectProps }`[Select API Documents](./select?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
4351

4452
### CalendarCell
4553

4654
name | type | default | description | required
4755
-- | -- | -- | -- | --
4856
belongTo | Number | - | \- | N
49-
date | Object | - | Typescript`Date` | N
57+
date | Object | - | Typescript: `Date` | N
5058
day | Number | - | \- | N
5159
formattedDate | String | - | \- | N
5260
isCurrent | Boolean | - | \- | N
5361
weekOrder | Number | - | \- | N
54-
`ControllerOptions` | \- | - | \- | N
62+
`ControllerOptions` | \- | - | extends `ControllerOptions` | N

packages/products/tdesign-react/packages/components/calendar/calendar.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## API
44
### Calendar Props
55

6-
名称 | 类型 | 默认值 | 说明 | 必传
6+
名称 | 类型 | 默认值 | 描述 | 必传
77
-- | -- | -- | -- | --
88
className | String | - | 类名 | N
99
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
@@ -19,7 +19,7 @@ mode | String | month | 日历展示维度。可选项:month/year | N
1919
month | String / Number | - | 控制当前面板展示月份,优先级高于 `controllerConfig.month` | N
2020
multiple | Boolean | - | 是否高亮多个日期单元格 | N
2121
preventCellContextmenu | Boolean | false | 是否禁用单元格右键默认系统菜单 | N
22-
range | Array | - | 用于设置日历的年月份显示范围,[范围开始,范围结束]。TS 类型:`Array<CalendarValue>` | N
22+
range | Array | - | 用于设置日历的年月份显示范围,[范围开始,范围结束]示例一:`['2018-08', '2028-04']`。示例二:`[new Date(2018, 8), new Date(2028, 4)]`。传入列表的两项均能被`dayjs`正常解析时才能使指定的日历范围生效,仅有一项正常解析时则为仅指定日历范围上限或下限。TS 类型:`Array<CalendarValue>` `type CalendarValue = string \| Date`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
2323
theme | String | full | 日历风格。可选项:full/card | N
2424
value | String / Array / Date | - | 当前高亮的日期。TS 类型:`CalendarValue \| CalendarValue[]` `type CalendarValue = string \| Date`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
2525
week | TNode | - | 用于自定义日历星期呈现方式。CalendarWeek.day 表示当前是星期几。示例一:['周一', '周二', '周三', '周四', '周五', '星期六', '星期天']。示例二:`({ day }) => '周' + day`。TS 类型:`Array<string> \| TNode<CalendarWeek>` `interface CalendarWeek { day: WeekDay }` `type WeekDay = 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
@@ -30,9 +30,17 @@ onCellRightClick | Function | | TS 类型:`(options: { cell: CalendarCell; e:
3030
onControllerChange | Function | | TS 类型:`(options: ControllerOptions) => void`<br/>右上角控件组选中值有变化的时候触发。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts)。<br/>`interface ControllerOptions { filterDate: Date; formattedFilterDate: string; mode: string; isShowWeekend: boolean }`<br/> | N
3131
onMonthChange | Function | | TS 类型:`(options: { month: string; year: string }) => void`<br/>月份切换时触发 | N
3232

33+
### CalendarInstanceFunctions 组件实例方法
34+
35+
名称 | 参数 | 返回值 | 描述
36+
-- | -- | -- | --
37+
className | String | - | 类名 | N
38+
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
39+
toCurrent | \- | \- | 跳转到今天
40+
3341
### CalendarController
3442

35-
名称 | 类型 | 默认值 | 说明 | 必传
43+
名称 | 类型 | 默认值 | 描述 | 必传
3644
-- | -- | -- | -- | --
3745
current | Object | - | “今天(本月)”按钮控制器。TS 类型:`{ visible?: boolean; currentDayButtonProps?: ButtonProps; currentMonthButtonProps?: ButtonProps }`[Button API Documents](./button?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/calendar/type.ts) | N
3846
disabled | Boolean | false | 是否禁用右上角控制器 | N
@@ -43,12 +51,12 @@ year | Object | - | 日历年份控制器。TS 类型:`{ visible?: boolean; se
4351

4452
### CalendarCell
4553

46-
名称 | 类型 | 默认值 | 说明 | 必传
54+
名称 | 类型 | 默认值 | 描述 | 必传
4755
-- | -- | -- | -- | --
4856
belongTo | Number | - | 用于表示日期单元格属于哪一个月份。值为 0 表示是当前日历显示的月份中的日期,值为 -1 表示是上个月的,值为 1 表示是下个月的(日历展示维度是“月”时有值) | N
4957
date | Object | - | 日历单元格日期。TS 类型:`Date` | N
5058
day | Number | - | 日期单元格对应的星期,值为 1~7,表示周一到周日。(日历展示维度是“月”时有值) | N
5159
formattedDate | String | - | 日历单元格日期字符串(输出日期的格式和 format 有关) | N
5260
isCurrent | Boolean | - | 日期单元格是否为当前高亮日期或高亮月份 | N
5361
weekOrder | Number | - | 日期在本月的第几周(日历展示维度是“月”时有值) | N
54-
`ControllerOptions` | \- | - | 继承 `ControllerOptions` 中的全部 API | N
62+
`ControllerOptions` | \- | - | 继承 `ControllerOptions` 中的全部属性 | N

packages/products/tdesign-react/packages/components/calendar/type.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface TdCalendarProps {
6565
*/
6666
preventCellContextmenu?: boolean;
6767
/**
68-
* 用于设置日历的年月份显示范围,[范围开始,范围结束]
68+
* 用于设置日历的年月份显示范围,[范围开始,范围结束]。示例一:`['2018-08', '2028-04']`。示例二:`[new Date(2018, 8), new Date(2028, 4)]`。传入列表的两项均能被`dayjs`正常解析时才能使指定的日历范围生效,仅有一项正常解析时则为仅指定日历范围上限或下限
6969
*/
7070
range?: Array<CalendarValue>;
7171
/**
@@ -107,6 +107,14 @@ export interface TdCalendarProps {
107107
onMonthChange?: (options: { month: string; year: string }) => void;
108108
}
109109

110+
/** 组件实例方法 */
111+
export interface CalendarInstanceFunctions {
112+
/**
113+
* 跳转到今天
114+
*/
115+
toCurrent?: () => void;
116+
}
117+
110118
export interface CalendarController {
111119
/**
112120
* “今天(本月)”按钮控制器

0 commit comments

Comments
 (0)