antd-mobile 5.6.1 → 5.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/cjs/components/calendar/calendar.d.ts +4 -3
- package/2x/cjs/components/calendar/calendar.js +67 -56
- package/2x/cjs/components/calendar/convert.d.ts +2 -0
- package/2x/cjs/components/calendar/convert.js +22 -0
- package/2x/cjs/components/collapse/collapse.js +7 -0
- package/2x/cjs/components/dialog/confirm.js +9 -1
- package/2x/cjs/components/form/form-item.js +6 -3
- package/2x/cjs/components/modal/confirm.js +9 -1
- package/2x/cjs/components/passcode-input/passcode-input.js +1 -1
- package/2x/cjs/components/picker/picker.js +6 -9
- package/2x/cjs/components/picker-view/columns-extend.d.ts +3 -0
- package/2x/cjs/components/picker-view/columns-extend.js +45 -0
- package/2x/cjs/components/picker-view/picker-view.d.ts +1 -0
- package/2x/cjs/components/picker-view/picker-view.js +14 -16
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +11 -1
- package/2x/cjs/components/result/result.d.ts +2 -2
- package/2x/cjs/components/virtual-input/virtual-input.js +25 -14
- package/2x/cjs/locales/base.d.ts +6 -0
- package/2x/cjs/locales/base.js +7 -1
- package/2x/cjs/locales/en-US.d.ts +6 -0
- package/2x/cjs/locales/fa-IR.d.ts +101 -0
- package/2x/cjs/locales/fa-IR.js +108 -0
- package/2x/cjs/locales/zh-CN.d.ts +6 -0
- package/2x/cjs/locales/zh-CN.js +7 -1
- package/2x/cjs/locales/zh-HK.d.ts +101 -0
- package/2x/cjs/locales/zh-HK.js +58 -0
- package/2x/cjs/locales/zh-TW.d.ts +101 -0
- package/2x/cjs/locales/zh-TW.js +58 -0
- package/2x/cjs/utils/with-cache.d.ts +1 -0
- package/2x/cjs/utils/with-cache.js +17 -0
- package/2x/es/components/calendar/calendar.d.ts +4 -3
- package/2x/es/components/calendar/calendar.js +67 -58
- package/2x/es/components/calendar/convert.d.ts +2 -0
- package/2x/es/components/calendar/convert.js +15 -0
- package/2x/es/components/collapse/collapse.js +7 -0
- package/2x/es/components/dialog/confirm.js +8 -1
- package/2x/es/components/form/form-item.js +6 -3
- package/2x/es/components/modal/confirm.js +8 -1
- package/2x/es/components/passcode-input/passcode-input.js +1 -1
- package/2x/es/components/picker/picker.js +6 -8
- package/2x/es/components/picker-view/columns-extend.d.ts +3 -0
- package/2x/es/components/picker-view/columns-extend.js +34 -0
- package/2x/es/components/picker-view/picker-view.d.ts +1 -0
- package/2x/es/components/picker-view/picker-view.js +14 -15
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +10 -1
- package/2x/es/components/result/result.d.ts +2 -2
- package/2x/es/components/virtual-input/virtual-input.js +23 -14
- package/2x/es/locales/base.d.ts +6 -0
- package/2x/es/locales/base.js +7 -1
- package/2x/es/locales/en-US.d.ts +6 -0
- package/2x/es/locales/fa-IR.d.ts +101 -0
- package/2x/es/locales/fa-IR.js +98 -0
- package/2x/es/locales/zh-CN.d.ts +6 -0
- package/2x/es/locales/zh-CN.js +7 -1
- package/2x/es/locales/zh-HK.d.ts +101 -0
- package/2x/es/locales/zh-HK.js +48 -0
- package/2x/es/locales/zh-TW.d.ts +101 -0
- package/2x/es/locales/zh-TW.js +48 -0
- package/2x/es/utils/with-cache.d.ts +1 -0
- package/2x/es/utils/with-cache.js +10 -0
- package/2x/package.json +1 -1
- package/cjs/components/calendar/calendar.d.ts +4 -3
- package/cjs/components/calendar/calendar.js +67 -56
- package/cjs/components/calendar/convert.d.ts +2 -0
- package/cjs/components/calendar/convert.js +22 -0
- package/cjs/components/collapse/collapse.js +7 -0
- package/cjs/components/dialog/confirm.js +9 -1
- package/cjs/components/form/form-item.js +6 -3
- package/cjs/components/modal/confirm.js +9 -1
- package/cjs/components/passcode-input/passcode-input.js +1 -1
- package/cjs/components/picker/picker.js +6 -9
- package/cjs/components/picker-view/columns-extend.d.ts +3 -0
- package/cjs/components/picker-view/columns-extend.js +45 -0
- package/cjs/components/picker-view/picker-view.d.ts +1 -0
- package/cjs/components/picker-view/picker-view.js +14 -16
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +11 -1
- package/cjs/components/result/result.d.ts +2 -2
- package/cjs/components/virtual-input/virtual-input.js +25 -14
- package/cjs/locales/base.d.ts +6 -0
- package/cjs/locales/base.js +7 -1
- package/cjs/locales/en-US.d.ts +6 -0
- package/cjs/locales/fa-IR.d.ts +101 -0
- package/cjs/locales/fa-IR.js +108 -0
- package/cjs/locales/zh-CN.d.ts +6 -0
- package/cjs/locales/zh-CN.js +7 -1
- package/cjs/locales/zh-HK.d.ts +101 -0
- package/cjs/locales/zh-HK.js +58 -0
- package/cjs/locales/zh-TW.d.ts +101 -0
- package/cjs/locales/zh-TW.js +58 -0
- package/cjs/utils/with-cache.d.ts +1 -0
- package/cjs/utils/with-cache.js +17 -0
- package/es/components/calendar/calendar.d.ts +4 -3
- package/es/components/calendar/calendar.js +67 -58
- package/es/components/calendar/convert.d.ts +2 -0
- package/es/components/calendar/convert.js +15 -0
- package/es/components/collapse/collapse.js +7 -0
- package/es/components/dialog/confirm.js +8 -1
- package/es/components/form/form-item.js +6 -3
- package/es/components/modal/confirm.js +8 -1
- package/es/components/passcode-input/passcode-input.js +1 -1
- package/es/components/picker/picker.js +6 -8
- package/es/components/picker-view/columns-extend.d.ts +3 -0
- package/es/components/picker-view/columns-extend.js +34 -0
- package/es/components/picker-view/picker-view.d.ts +1 -0
- package/es/components/picker-view/picker-view.js +14 -15
- package/es/components/pull-to-refresh/pull-to-refresh.js +10 -1
- package/es/components/result/result.d.ts +2 -2
- package/es/components/virtual-input/virtual-input.js +23 -14
- package/es/locales/base.d.ts +6 -0
- package/es/locales/base.js +7 -1
- package/es/locales/en-US.d.ts +6 -0
- package/es/locales/fa-IR.d.ts +101 -0
- package/es/locales/fa-IR.js +98 -0
- package/es/locales/zh-CN.d.ts +6 -0
- package/es/locales/zh-CN.js +7 -1
- package/es/locales/zh-HK.d.ts +101 -0
- package/es/locales/zh-HK.js +48 -0
- package/es/locales/zh-TW.d.ts +101 -0
- package/es/locales/zh-TW.js +48 -0
- package/es/utils/with-cache.d.ts +1 -0
- package/es/utils/with-cache.js +10 -0
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/picker-view/use-columns.d.ts +0 -2
- package/2x/cjs/components/picker-view/use-columns.js +0 -18
- package/2x/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/2x/cjs/components/picker-view/use-picker-value-extend.js +0 -37
- package/2x/es/components/picker-view/use-columns.d.ts +0 -2
- package/2x/es/components/picker-view/use-columns.js +0 -10
- package/2x/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/2x/es/components/picker-view/use-picker-value-extend.js +0 -26
- package/cjs/components/picker-view/use-columns.d.ts +0 -2
- package/cjs/components/picker-view/use-columns.js +0 -18
- package/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/cjs/components/picker-view/use-picker-value-extend.js +0 -37
- package/es/components/picker-view/use-columns.d.ts +0 -2
- package/es/components/picker-view/use-columns.js +0 -10
- package/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/es/components/picker-view/use-picker-value-extend.js +0 -26
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
declare const zhHK: {
|
|
2
|
+
common: {
|
|
3
|
+
confirm: string;
|
|
4
|
+
cancel: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
};
|
|
7
|
+
Calendar: {
|
|
8
|
+
markItems: string[];
|
|
9
|
+
renderYearAndMonth: (year: number, month: number) => string;
|
|
10
|
+
};
|
|
11
|
+
Cascader: {
|
|
12
|
+
placeholder: string;
|
|
13
|
+
};
|
|
14
|
+
Dialog: {
|
|
15
|
+
ok: string;
|
|
16
|
+
};
|
|
17
|
+
ErrorBlock: {
|
|
18
|
+
default: {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
busy: {
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
disconnected: {
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
empty: {
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
Form: {
|
|
36
|
+
required: string;
|
|
37
|
+
optional: string;
|
|
38
|
+
defaultValidateMessages: {
|
|
39
|
+
default: string;
|
|
40
|
+
required: string;
|
|
41
|
+
enum: string;
|
|
42
|
+
whitespace: string;
|
|
43
|
+
date: {
|
|
44
|
+
format: string;
|
|
45
|
+
parse: string;
|
|
46
|
+
invalid: string;
|
|
47
|
+
};
|
|
48
|
+
types: {
|
|
49
|
+
string: string;
|
|
50
|
+
method: string;
|
|
51
|
+
array: string;
|
|
52
|
+
object: string;
|
|
53
|
+
number: string;
|
|
54
|
+
date: string;
|
|
55
|
+
boolean: string;
|
|
56
|
+
integer: string;
|
|
57
|
+
float: string;
|
|
58
|
+
regexp: string;
|
|
59
|
+
email: string;
|
|
60
|
+
url: string;
|
|
61
|
+
hex: string;
|
|
62
|
+
};
|
|
63
|
+
string: {
|
|
64
|
+
len: string;
|
|
65
|
+
min: string;
|
|
66
|
+
max: string;
|
|
67
|
+
range: string;
|
|
68
|
+
};
|
|
69
|
+
number: {
|
|
70
|
+
len: string;
|
|
71
|
+
min: string;
|
|
72
|
+
max: string;
|
|
73
|
+
range: string;
|
|
74
|
+
};
|
|
75
|
+
array: {
|
|
76
|
+
len: string;
|
|
77
|
+
min: string;
|
|
78
|
+
max: string;
|
|
79
|
+
range: string;
|
|
80
|
+
};
|
|
81
|
+
pattern: {
|
|
82
|
+
mismatch: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
ImageUploader: {
|
|
87
|
+
uploading: string;
|
|
88
|
+
};
|
|
89
|
+
Mask: {
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
Modal: {
|
|
93
|
+
ok: string;
|
|
94
|
+
};
|
|
95
|
+
PullToRefresh: {
|
|
96
|
+
pulling: string;
|
|
97
|
+
canRelease: string;
|
|
98
|
+
complete: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export default zhHK;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _mergeLocale = require("../utils/merge-locale");
|
|
9
|
+
|
|
10
|
+
var _base = require("./base");
|
|
11
|
+
|
|
12
|
+
const zhHK = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
13
|
+
common: {
|
|
14
|
+
confirm: '確定',
|
|
15
|
+
cancel: '取消',
|
|
16
|
+
loading: '加載中……'
|
|
17
|
+
},
|
|
18
|
+
Cascader: {
|
|
19
|
+
placeholder: '請選擇'
|
|
20
|
+
},
|
|
21
|
+
Dialog: {
|
|
22
|
+
ok: '我知道了'
|
|
23
|
+
},
|
|
24
|
+
ErrorBlock: {
|
|
25
|
+
default: {
|
|
26
|
+
title: '頁面遇到一些小問題',
|
|
27
|
+
description: '待會來試試'
|
|
28
|
+
},
|
|
29
|
+
busy: {
|
|
30
|
+
title: '前方擁堵',
|
|
31
|
+
description: '刷新試試'
|
|
32
|
+
},
|
|
33
|
+
disconnected: {
|
|
34
|
+
title: '網絡有點忙',
|
|
35
|
+
description: '動動手指幫忙修復'
|
|
36
|
+
},
|
|
37
|
+
empty: {
|
|
38
|
+
title: '沒有找到您需要的東西',
|
|
39
|
+
description: '找找其他的吧'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
ImageUploader: {
|
|
43
|
+
uploading: '上傳中...'
|
|
44
|
+
},
|
|
45
|
+
Mask: {
|
|
46
|
+
name: '遮罩層'
|
|
47
|
+
},
|
|
48
|
+
Modal: {
|
|
49
|
+
ok: '我知道了'
|
|
50
|
+
},
|
|
51
|
+
PullToRefresh: {
|
|
52
|
+
pulling: '下拉刷新',
|
|
53
|
+
canRelease: '釋放立即刷新',
|
|
54
|
+
complete: '刷新成功'
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
var _default = zhHK;
|
|
58
|
+
exports.default = _default;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
declare const zhTW: {
|
|
2
|
+
common: {
|
|
3
|
+
confirm: string;
|
|
4
|
+
cancel: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
};
|
|
7
|
+
Calendar: {
|
|
8
|
+
markItems: string[];
|
|
9
|
+
renderYearAndMonth: (year: number, month: number) => string;
|
|
10
|
+
};
|
|
11
|
+
Cascader: {
|
|
12
|
+
placeholder: string;
|
|
13
|
+
};
|
|
14
|
+
Dialog: {
|
|
15
|
+
ok: string;
|
|
16
|
+
};
|
|
17
|
+
ErrorBlock: {
|
|
18
|
+
default: {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
busy: {
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
disconnected: {
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
empty: {
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
Form: {
|
|
36
|
+
required: string;
|
|
37
|
+
optional: string;
|
|
38
|
+
defaultValidateMessages: {
|
|
39
|
+
default: string;
|
|
40
|
+
required: string;
|
|
41
|
+
enum: string;
|
|
42
|
+
whitespace: string;
|
|
43
|
+
date: {
|
|
44
|
+
format: string;
|
|
45
|
+
parse: string;
|
|
46
|
+
invalid: string;
|
|
47
|
+
};
|
|
48
|
+
types: {
|
|
49
|
+
string: string;
|
|
50
|
+
method: string;
|
|
51
|
+
array: string;
|
|
52
|
+
object: string;
|
|
53
|
+
number: string;
|
|
54
|
+
date: string;
|
|
55
|
+
boolean: string;
|
|
56
|
+
integer: string;
|
|
57
|
+
float: string;
|
|
58
|
+
regexp: string;
|
|
59
|
+
email: string;
|
|
60
|
+
url: string;
|
|
61
|
+
hex: string;
|
|
62
|
+
};
|
|
63
|
+
string: {
|
|
64
|
+
len: string;
|
|
65
|
+
min: string;
|
|
66
|
+
max: string;
|
|
67
|
+
range: string;
|
|
68
|
+
};
|
|
69
|
+
number: {
|
|
70
|
+
len: string;
|
|
71
|
+
min: string;
|
|
72
|
+
max: string;
|
|
73
|
+
range: string;
|
|
74
|
+
};
|
|
75
|
+
array: {
|
|
76
|
+
len: string;
|
|
77
|
+
min: string;
|
|
78
|
+
max: string;
|
|
79
|
+
range: string;
|
|
80
|
+
};
|
|
81
|
+
pattern: {
|
|
82
|
+
mismatch: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
ImageUploader: {
|
|
87
|
+
uploading: string;
|
|
88
|
+
};
|
|
89
|
+
Mask: {
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
Modal: {
|
|
93
|
+
ok: string;
|
|
94
|
+
};
|
|
95
|
+
PullToRefresh: {
|
|
96
|
+
pulling: string;
|
|
97
|
+
canRelease: string;
|
|
98
|
+
complete: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export default zhTW;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _mergeLocale = require("../utils/merge-locale");
|
|
9
|
+
|
|
10
|
+
var _base = require("./base");
|
|
11
|
+
|
|
12
|
+
const zhTW = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
13
|
+
common: {
|
|
14
|
+
confirm: '確定',
|
|
15
|
+
cancel: '取消',
|
|
16
|
+
loading: '加載中……'
|
|
17
|
+
},
|
|
18
|
+
Cascader: {
|
|
19
|
+
placeholder: '請選擇'
|
|
20
|
+
},
|
|
21
|
+
Dialog: {
|
|
22
|
+
ok: '我知道了'
|
|
23
|
+
},
|
|
24
|
+
ErrorBlock: {
|
|
25
|
+
default: {
|
|
26
|
+
title: '頁面遇到一些小問題',
|
|
27
|
+
description: '待會來試試'
|
|
28
|
+
},
|
|
29
|
+
busy: {
|
|
30
|
+
title: '前方擁堵',
|
|
31
|
+
description: '刷新試試'
|
|
32
|
+
},
|
|
33
|
+
disconnected: {
|
|
34
|
+
title: '網路有點忙',
|
|
35
|
+
description: '動動手指幫忙修復'
|
|
36
|
+
},
|
|
37
|
+
empty: {
|
|
38
|
+
title: '沒有找到您需要的東西',
|
|
39
|
+
description: '找找其他的吧'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
ImageUploader: {
|
|
43
|
+
uploading: '上傳中...'
|
|
44
|
+
},
|
|
45
|
+
Mask: {
|
|
46
|
+
name: '遮罩層'
|
|
47
|
+
},
|
|
48
|
+
Modal: {
|
|
49
|
+
ok: '我知道了'
|
|
50
|
+
},
|
|
51
|
+
PullToRefresh: {
|
|
52
|
+
pulling: '下拉刷新',
|
|
53
|
+
canRelease: '釋放立即刷新',
|
|
54
|
+
complete: '刷新成功'
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
var _default = zhTW;
|
|
58
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withCache<T>(generate: () => T): () => T;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withCache = withCache;
|
|
7
|
+
|
|
8
|
+
function withCache(generate) {
|
|
9
|
+
let cache = null;
|
|
10
|
+
return () => {
|
|
11
|
+
if (cache === null) {
|
|
12
|
+
cache = generate();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return cache;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -9,9 +9,10 @@ export declare type CalenderRef = {
|
|
|
9
9
|
jumpToToday: () => void;
|
|
10
10
|
};
|
|
11
11
|
export declare type CalendarProps = {
|
|
12
|
+
onPageChange?: (year: number, month: number) => void;
|
|
12
13
|
weekStartsOn?: 'Monday' | 'Sunday';
|
|
13
14
|
renderLabel?: (date: Date) => string | null | undefined;
|
|
14
|
-
|
|
15
|
+
allowClear?: boolean;
|
|
15
16
|
} & ({
|
|
16
17
|
selectionMode?: undefined;
|
|
17
18
|
value?: undefined;
|
|
@@ -21,12 +22,12 @@ export declare type CalendarProps = {
|
|
|
21
22
|
selectionMode: 'single';
|
|
22
23
|
value?: Date | null;
|
|
23
24
|
defaultValue?: Date | null;
|
|
24
|
-
onChange?: (val: Date) => void;
|
|
25
|
+
onChange?: (val: Date | null) => void;
|
|
25
26
|
} | {
|
|
26
27
|
selectionMode: 'range';
|
|
27
28
|
value?: [Date, Date] | null;
|
|
28
29
|
defaultValue?: [Date, Date] | null;
|
|
29
|
-
onChange?: (val: [Date, Date]) => void;
|
|
30
|
+
onChange?: (val: [Date, Date] | null) => void;
|
|
30
31
|
}) & NativeProps;
|
|
31
32
|
export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<CalenderRef>>;
|
|
32
33
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef,
|
|
1
|
+
import React, { forwardRef, useState, useImperativeHandle } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -7,11 +7,15 @@ import { ArrowLeft } from './arrow-left';
|
|
|
7
7
|
import { ArrowLeftDouble } from './arrow-left-double';
|
|
8
8
|
import { useConfig } from '../config-provider';
|
|
9
9
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
10
|
-
import {
|
|
10
|
+
import { useUpdateEffect } from 'ahooks';
|
|
11
|
+
import { usePropsValue } from '../../utils/use-props-value';
|
|
12
|
+
import { convertValueToRange } from './convert';
|
|
11
13
|
dayjs.extend(isoWeek);
|
|
12
14
|
const classPrefix = 'adm-calendar';
|
|
13
15
|
const defaultProps = {
|
|
14
|
-
weekStartsOn: 'Sunday'
|
|
16
|
+
weekStartsOn: 'Sunday',
|
|
17
|
+
defaultValue: null,
|
|
18
|
+
allowClear: true
|
|
15
19
|
};
|
|
16
20
|
export const Calendar = forwardRef((p, ref) => {
|
|
17
21
|
const today = dayjs();
|
|
@@ -26,29 +30,21 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
26
30
|
if (item) markItems.unshift(item);
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
const dateRange =
|
|
30
|
-
|
|
33
|
+
const [dateRange, setDateRange] = usePropsValue({
|
|
34
|
+
value: props.value === undefined ? undefined : convertValueToRange(props.selectionMode, props.value),
|
|
35
|
+
defaultValue: convertValueToRange(props.selectionMode, props.defaultValue),
|
|
36
|
+
onChange: v => {
|
|
37
|
+
var _a, _b;
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else {
|
|
38
|
-
return [null, null];
|
|
39
|
+
if (props.selectionMode === 'single') {
|
|
40
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v ? v[0] : null);
|
|
41
|
+
} else if (props.selectionMode === 'range') {
|
|
42
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
|
-
}, [props.selectionMode, props.value, props.defaultValue]);
|
|
41
|
-
const [begin, setBegin] = useState(null);
|
|
42
|
-
const [end, setEnd] = useState(null);
|
|
43
|
-
useIsomorphicLayoutEffect(() => {
|
|
44
|
-
setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
|
|
45
|
-
setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
|
|
46
|
-
}, [dateRange[0], dateRange[1]]);
|
|
47
|
-
const [current, setCurrent] = useState(() => {
|
|
48
|
-
var _a;
|
|
49
|
-
|
|
50
|
-
return dayjs((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
|
|
51
45
|
});
|
|
46
|
+
const [intermediate, setIntermediate] = useState(false);
|
|
47
|
+
const [current, setCurrent] = useState(() => dayjs(dateRange ? dateRange[0] : today).date(1));
|
|
52
48
|
useUpdateEffect(() => {
|
|
53
49
|
var _a;
|
|
54
50
|
|
|
@@ -111,14 +107,16 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
111
107
|
|
|
112
108
|
while (cells.length < 6 * 7) {
|
|
113
109
|
const d = iterator;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
110
|
+
let isSelect = false;
|
|
111
|
+
let isBegin = false;
|
|
112
|
+
let isEnd = false;
|
|
113
|
+
|
|
114
|
+
if (dateRange) {
|
|
115
|
+
const [begin, end] = dateRange;
|
|
116
|
+
isBegin = d.isSame(begin, 'day');
|
|
117
|
+
isEnd = d.isSame(end, 'day');
|
|
118
|
+
isSelect = isBegin || isEnd || d.isAfter(begin, 'day') && d.isBefore(end, 'day');
|
|
119
|
+
}
|
|
122
120
|
|
|
123
121
|
const inThisMonth = d.month() === current.month();
|
|
124
122
|
cells.push(React.createElement("div", {
|
|
@@ -126,41 +124,52 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
126
124
|
className: classNames(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
|
|
127
125
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
128
126
|
[`${classPrefix}-cell-selected`]: isSelect,
|
|
129
|
-
[`${classPrefix}-cell-selected-begin`]:
|
|
130
|
-
[`${classPrefix}-cell-selected-end`]:
|
|
127
|
+
[`${classPrefix}-cell-selected-begin`]: isBegin,
|
|
128
|
+
[`${classPrefix}-cell-selected-end`]: isEnd
|
|
131
129
|
}),
|
|
132
130
|
onClick: () => {
|
|
133
|
-
var _a, _b, _c;
|
|
134
|
-
|
|
135
131
|
if (!props.selectionMode) return;
|
|
132
|
+
const date = d.toDate();
|
|
133
|
+
|
|
134
|
+
if (!inThisMonth) {
|
|
135
|
+
setCurrent(d.clone().date(1));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function shouldClear() {
|
|
139
|
+
if (!props.allowClear) return false;
|
|
140
|
+
if (!dateRange) return false;
|
|
141
|
+
const [begin, end] = dateRange;
|
|
142
|
+
return d.isSame(begin, 'date') && d.isSame(end, 'day');
|
|
143
|
+
}
|
|
136
144
|
|
|
137
145
|
if (props.selectionMode === 'single') {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
if (props.allowClear && shouldClear()) {
|
|
147
|
+
setDateRange(null);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
setDateRange([date, date]);
|
|
141
152
|
} else if (props.selectionMode === 'range') {
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
if (d.isBefore(begin)) {
|
|
148
|
-
setEnd(begin);
|
|
149
|
-
setBegin(d);
|
|
150
|
-
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, [d.toDate(), begin.toDate()]);
|
|
151
|
-
} else {
|
|
152
|
-
setEnd(d);
|
|
153
|
-
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, [begin.toDate(), d.toDate()]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
setBegin(d);
|
|
158
|
-
setEnd(null);
|
|
153
|
+
if (!dateRange) {
|
|
154
|
+
setDateRange([date, date]);
|
|
155
|
+
setIntermediate(true);
|
|
156
|
+
return;
|
|
159
157
|
}
|
|
160
|
-
}
|
|
161
158
|
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
if (shouldClear()) {
|
|
160
|
+
setDateRange(null);
|
|
161
|
+
setIntermediate(false);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (intermediate) {
|
|
166
|
+
const another = dateRange[0];
|
|
167
|
+
setDateRange(another > date ? [date, another] : [another, date]);
|
|
168
|
+
setIntermediate(false);
|
|
169
|
+
} else {
|
|
170
|
+
setDateRange([date, date]);
|
|
171
|
+
setIntermediate(true);
|
|
172
|
+
}
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
175
|
}, React.createElement("div", {
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { show } from './show';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
+
import { getDefaultConfig } from '../config-provider';
|
|
4
5
|
const defaultProps = {
|
|
5
6
|
confirmText: '确认',
|
|
6
7
|
cancelText: '取消'
|
|
7
8
|
};
|
|
8
9
|
export function confirm(p) {
|
|
9
|
-
const
|
|
10
|
+
const {
|
|
11
|
+
locale
|
|
12
|
+
} = getDefaultConfig();
|
|
13
|
+
const props = mergeProps(defaultProps, {
|
|
14
|
+
confirmText: locale.common.confirm,
|
|
15
|
+
cancelText: locale.common.cancel
|
|
16
|
+
}, p);
|
|
10
17
|
return new Promise(resolve => {
|
|
11
18
|
show(Object.assign(Object.assign({}, props), {
|
|
12
19
|
closeOnAction: true,
|
|
@@ -67,12 +67,15 @@ const FormItemLayout = props => {
|
|
|
67
67
|
const labelElement = label ? React.createElement("label", {
|
|
68
68
|
className: `${classPrefix}-label`,
|
|
69
69
|
htmlFor: htmlFor
|
|
70
|
-
}, label, requiredMark, help && React.createElement(
|
|
71
|
-
className: `${classPrefix}-label-help`
|
|
72
|
-
}, React.createElement(Popover, {
|
|
70
|
+
}, label, requiredMark, help && React.createElement(Popover, {
|
|
73
71
|
content: help,
|
|
74
72
|
mode: 'dark',
|
|
75
73
|
trigger: 'click'
|
|
74
|
+
}, React.createElement("span", {
|
|
75
|
+
className: `${classPrefix}-label-help`,
|
|
76
|
+
onClick: e => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
}
|
|
76
79
|
}, React.createElement(QuestionCircleOutline, null)))) : null;
|
|
77
80
|
const description = React.createElement(React.Fragment, null, props.description, hasFeedback && React.createElement(React.Fragment, null, props.errors.map((error, index) => React.createElement("div", {
|
|
78
81
|
key: `error-${index}`,
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { show } from './show';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
+
import { getDefaultConfig } from '../config-provider';
|
|
4
5
|
const defaultProps = {
|
|
5
6
|
confirmText: '确认',
|
|
6
7
|
cancelText: '取消'
|
|
7
8
|
};
|
|
8
9
|
export function confirm(p) {
|
|
9
|
-
const
|
|
10
|
+
const {
|
|
11
|
+
locale
|
|
12
|
+
} = getDefaultConfig();
|
|
13
|
+
const props = mergeProps(defaultProps, {
|
|
14
|
+
confirmText: locale.common.confirm,
|
|
15
|
+
cancelText: locale.common.cancel
|
|
16
|
+
}, p);
|
|
10
17
|
return new Promise(resolve => {
|
|
11
18
|
show(Object.assign(Object.assign({}, props), {
|
|
12
19
|
closeOnAction: true,
|
|
@@ -27,7 +27,7 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
27
27
|
if (value.length >= cellLength) {
|
|
28
28
|
(_a = props.onFill) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
29
29
|
}
|
|
30
|
-
}, [
|
|
30
|
+
}, [value, cellLength]);
|
|
31
31
|
|
|
32
32
|
const onFocus = () => {
|
|
33
33
|
var _a, _b;
|
|
@@ -4,9 +4,8 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
5
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
6
|
import PickerView from '../picker-view';
|
|
7
|
-
import {
|
|
7
|
+
import { generateColumnsExtend, useColumnsExtend } from '../picker-view/columns-extend';
|
|
8
8
|
import { useConfig } from '../config-provider';
|
|
9
|
-
import { usePickerValueExtend } from '../picker-view/use-picker-value-extend';
|
|
10
9
|
import { useMemoizedFn } from 'ahooks';
|
|
11
10
|
import SafeArea from '../safe-area';
|
|
12
11
|
const classPrefix = `adm-picker`;
|
|
@@ -28,12 +27,11 @@ export const Picker = memo(p => {
|
|
|
28
27
|
onChange: val => {
|
|
29
28
|
var _a;
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
const extend = generateColumnsExtend(props.columns, val);
|
|
31
|
+
(_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
|
|
32
32
|
}
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
const columns = useColumns(props.columns, value);
|
|
36
|
-
const generateValueExtend = usePickerValueExtend(columns);
|
|
33
|
+
}));
|
|
34
|
+
const extend = useColumnsExtend(props.columns, value);
|
|
37
35
|
const [innerValue, setInnerValue] = useState(value);
|
|
38
36
|
useEffect(() => {
|
|
39
37
|
if (innerValue !== value) {
|
|
@@ -104,6 +102,6 @@ export const Picker = memo(p => {
|
|
|
104
102
|
}, pickerElement, React.createElement(SafeArea, {
|
|
105
103
|
position: 'bottom'
|
|
106
104
|
}));
|
|
107
|
-
return React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props,
|
|
105
|
+
return React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, extend.items));
|
|
108
106
|
});
|
|
109
107
|
Picker.displayName = 'Picker';
|