Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/calendar/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ 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
readonly | Boolean | - | `1.9.7` | N
switch-mode | String | none | `1.8.2`。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
Expand All @@ -31,7 +32,7 @@ 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`
panel-change | `(detail: { 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`

Expand Down
5 changes: 3 additions & 2 deletions src/calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ 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
readonly | Boolean | - | `1.9.7`。是否只读,只读状态下不能选择日期 | N
switch-mode | String | none | `1.8.2`。切换模式。 `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
Expand All @@ -97,7 +98,7 @@ 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 时有效)
panel-change | `(detail: { 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`。点击日期时触发

Expand Down
3 changes: 2 additions & 1 deletion src/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ export default class Calendar extends SuperComponent {
},

handleSelect(e) {
const { readonly } = this.properties;
const { date, year, month } = e.currentTarget.dataset;

if (date.type === 'disabled') return;
if (date.type === 'disabled' || readonly) return;

const rawValue = this.base.select({ cellType: date.type, year, month, date: date.day });

Expand Down
6 changes: 5 additions & 1 deletion src/calendar/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const props: TdCalendarProps = {
minDate: {
type: Number,
},
/** 切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换 */
/** 是否只读,只读状态下不能选择日期 */
readonly: {
type: Boolean,
},
/** 切换模式。 `none` 表示平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换 */
switchMode: {
type: String,
value: 'none',
Expand Down
9 changes: 8 additions & 1 deletion src/calendar/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ export interface TdCalendarProps {
value?: number;
};
/**
* 切换模式。 `none` 表示水平方向平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
* 是否只读,只读状态下不能选择日期
*/
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 切换模式。 `none` 表示平铺展示所有月份; `month` 表示支持按月切换, `year-month` 表示既按年切换,也支持按月切换
* @default none
*/
switchMode?: {
Expand Down