Skip to content

Commit 44d7deb

Browse files
authored
feat(DateTimePicker): support auto-close props (#3263)
* feat(DateTimePicker): support auto-close props * feat(DateTimePicker): update demo * test: update snapshots
1 parent 49ce199 commit 44d7deb

File tree

8 files changed

+31
-14
lines changed

8 files changed

+31
-14
lines changed

src/date-time-picker/README.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ name | type | default | description | required
88
-- | -- | -- | -- | --
99
style | Object | - | CSS(Cascading Style Sheets) | N
1010
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
11+
auto-close | Boolean | false | \- | N
1112
cancel-btn | String | 取消 | \- | N
1213
confirm-btn | String | - | \- | N
1314
custom-locale | String | zh | \- | N

src/date-time-picker/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ isComponent: true
6262
-- | -- | -- | -- | --
6363
style | Object | - | 样式 | N
6464
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
65+
auto-close | Boolean | false | 自动关闭;在确认、取消、点击遮罩层自动关闭,不需要手动设置 visible | N
6566
cancel-btn | String | 取消 | 取消按钮文字 | N
6667
confirm-btn | String | - | 确定按钮文字 | N
6768
custom-locale | String | zh | 组件国际化语言,目前支持: 简体中文(zh)、(tc)、英文(en)、日语(ja)、韩语(ko)、俄语(ru)等六种语言 | N

src/date-time-picker/__test__/__snapshots__/demo.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ exports[`DateTimePicker DateTimePicker year-month-date demo works fine 1`] = `
177177
bind:tap="showPicker"
178178
/>
179179
<t-date-time-picker
180+
autoClose="{{true}}"
180181
defaultValue="{{1640217600000}}"
181182
end="2030-09-09 12:12:12"
182183
filter="{{[Function]}}"
@@ -192,6 +193,7 @@ exports[`DateTimePicker DateTimePicker year-month-date demo works fine 1`] = `
192193
visible="{{false}}"
193194
bind:cancel="hidePicker"
194195
bind:change="onConfirm"
196+
bind:close="handleClose"
195197
bind:pick="onColumnChange"
196198
/>
197199
</year-month-date>

src/date-time-picker/_example/year-month-date/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ Page({
2525
[`${mode}Visible`]: true,
2626
});
2727
},
28-
hidePicker() {
29-
const { mode } = this.data;
30-
this.setData({
31-
[`${mode}Visible`]: false,
32-
});
28+
29+
handleClose(e) {
30+
console.log('handleClose:', e);
3331
},
32+
3433
onConfirm(e) {
3534
const { value } = e.detail;
3635
const { mode } = this.data;
@@ -41,8 +40,6 @@ Page({
4140
[mode]: value,
4241
[`${mode}Text`]: value,
4342
});
44-
45-
this.hidePicker();
4643
},
4744

4845
onColumnChange(e) {

src/date-time-picker/_example/year-month-date/index.wxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
<!-- 年月日 -->
1313
<t-date-time-picker
14+
auto-close
1415
title="选择日期"
1516
visible="{{dateVisible}}"
1617
mode="date"
17-
defaultValue="{{date}}"
18+
default-value="{{date}}"
1819
format="YYYY-MM-DD"
1920
start="{{start}}"
2021
end="{{end}}"
@@ -23,4 +24,5 @@
2324
bindchange="onConfirm"
2425
bindpick="onColumnChange"
2526
bindcancel="hidePicker"
27+
bindclose="handleClose"
2628
/>

src/date-time-picker/date-time-picker.wxml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
class="class {{prefix}}-class {{classPrefix}}"
55
visible="{{visible}}"
66
value="{{columnsValue}}"
7+
header="{{header}}"
8+
title="{{title}}"
9+
auto-close="{{autoClose}}"
10+
confirm-btn="{{confirmBtn || locale.confirm}}"
11+
cancel-btn="{{cancelBtn || locale.cancel}}"
12+
use-popup="{{usePopup}}"
13+
popup-props="{{ popupProps }}"
714
bind:pick="onColumnChange"
815
bind:change="onConfirm"
916
bind:cancel="onCancel"
1017
bind:visible-change="onVisibleChange"
1118
bind:close="onClose"
12-
header="{{header}}"
13-
title="{{title}}"
14-
confirmBtn="{{confirmBtn || locale.confirm}}"
15-
cancelBtn="{{cancelBtn || locale.cancel}}"
16-
usePopup="{{usePopup}}"
17-
popupProps="{{ popupProps }}"
1819
>
1920
<slot slot="header" name="header" />
2021
<t-picker-item

src/date-time-picker/props.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
import { TdDateTimePickerProps } from './type';
88
const props: TdDateTimePickerProps = {
9+
/** 自动关闭;在确认、取消、点击遮罩层自动关闭,不需要手动设置 visible */
10+
autoClose: {
11+
type: Boolean,
12+
value: false,
13+
},
914
/** 取消按钮文字 */
1015
cancelBtn: {
1116
type: String,

src/date-time-picker/type.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
import { PopupProps } from '../popup/index';
88

99
export interface TdDateTimePickerProps {
10+
/**
11+
* 自动关闭;在确认、取消、点击遮罩层自动关闭,不需要手动设置 visible
12+
* @default false
13+
*/
14+
autoClose?: {
15+
type: BooleanConstructor;
16+
value?: boolean;
17+
};
1018
/**
1119
* 取消按钮文字
1220
* @default 取消

0 commit comments

Comments
 (0)