Skip to content

Commit

Permalink
feat(Calendar): add panel-change event (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao authored Dec 23, 2024
1 parent 874a874 commit 284f568
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 11 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ name | params | description
change | `(value: timestamp)` | `0.28.0`
close | `(trigger: CalendarTrigger)` | `0.34.0`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts)。<br/>`type CalendarTrigger = 'close-btn' \| 'confirm-btn' \| 'overlay'`<br/>
confirm | `(value: timestamp)` | \-
panel-change | `(year: number; month: number)` | `1.8.4`
scroll | `({scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY})` | `1.4.6`。triggered when scrolling
select | `(value: timestamp)` | `0.28.0`
7 changes: 4 additions & 3 deletions packages/products/tdesign-miniprogram/src/calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ 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
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
using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
value | Number / Array | - | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。TS 类型:`number \| number[]` | N
default-value | Number / Array | undefined | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。非受控属性。TS 类型:`number \| number[]` | N
value | Number / Array | - | 当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组。TS 类型:`number \| number[]` | N
default-value | Number / Array | undefined | 当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组。非受控属性。TS 类型:`number \| number[]` | N
visible | Boolean | false | 是否显示日历;`usePopup` 为 true 时有效 | N

### Calendar Events
Expand All @@ -31,5 +31,6 @@ visible | Boolean | false | 是否显示日历;`usePopup` 为 true 时有效 |
change | `(value: timestamp)` | `0.28.0`。不显示 confirm-btn 时,完成选择时触发(暂不支持 type = multiple)
close | `(trigger: CalendarTrigger)` | `0.34.0`。关闭按钮时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts)。<br/>`type CalendarTrigger = 'close-btn' \| 'confirm-btn' \| 'overlay'`<br/>
confirm | `(value: timestamp)` | 点击确认按钮时触发
panel-change | `(year: number; month: number)` | `1.8.4`。切换月或年时触发(switch-mode 不为 none 时有效)
scroll | `({scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY})` | `1.4.6`。滚动时触发
select | `(value: timestamp)` | `0.28.0`。点击日期时触发
6 changes: 3 additions & 3 deletions packages/products/tdesign-miniprogram/src/calendar/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const props: TdCalendarProps = {
minDate: {
type: Number,
},
/** 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换 */
/** 切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换 */
switchMode: {
type: String,
value: 'none',
Expand All @@ -61,12 +61,12 @@ const props: TdCalendarProps = {
type: Boolean,
value: false,
},
/** 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组 */
/** 当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组 */
value: {
type: null,
value: null,
},
/** 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组,非受控属性 */
/** 当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组,非受控属性 */
defaultValue: {
type: null,
},
Expand Down
6 changes: 3 additions & 3 deletions packages/products/tdesign-miniprogram/src/calendar/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface TdCalendarProps {
value?: number;
};
/**
* 【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
* 切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
* @default none
*/
switchMode?: {
Expand Down Expand Up @@ -99,14 +99,14 @@ export interface TdCalendarProps {
value?: boolean;
};
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组
* 当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组
*/
value?: {
type: null;
value?: number | number[];
};
/**
* 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组,非受控属性
* 当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组,非受控属性
*/
defaultValue?: {
type: null;
Expand Down
41 changes: 39 additions & 2 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -16823,7 +16823,7 @@
],
"field_default_value": "none",
"field_enum": "none/month/year-month",
"field_desc_zh": "【开发中】切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换",
"field_desc_zh": "切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换",
"field_desc_en": null,
"field_required": 0,
"event_input": "",
Expand Down Expand Up @@ -17118,7 +17118,7 @@
],
"field_default_value": "",
"field_enum": "",
"field_desc_zh": "当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组",
"field_desc_zh": "当前选择的日期,不传则选用 minDate 属性值或今天,优先级:minDate > today。当 type = multiple 或 range 时传入数组",
"field_desc_en": null,
"field_required": 0,
"event_input": "",
Expand Down Expand Up @@ -17716,6 +17716,43 @@
],
"field_type_text": []
},
{
"id": 1734943734,
"platform_framework": [
"64"
],
"component": "Calendar",
"field_category": 2,
"field_name": "panelChange",
"field_type": [
"16"
],
"field_default_value": "",
"field_enum": "",
"field_desc_zh": "切换月或年时触发(switch-mode 不为 none 时有效)",
"field_desc_en": null,
"field_required": 0,
"event_input": "(year: number; month: number)",
"create_time": "2024-12-23 08:48:55",
"update_time": "2024-12-23 08:48:55",
"event_output": null,
"custom_field_type": null,
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
"trigger_elements": "",
"deprecated": 0,
"version": "{\"Miniprogram\": \"1.8.4\"}",
"test_description": null,
"support_default_value": 0,
"field_category_text": "Events",
"platform_framework_text": [
"Miniprogram"
],
"field_type_text": [
"Array"
]
},
{
"id": 1720685482,
"platform_framework": [
Expand Down

0 comments on commit 284f568

Please sign in to comment.