@@ -28,6 +28,7 @@ export default {
28
28
defaultValue : PropTypes . object ,
29
29
locale : PropTypes . object ,
30
30
renderFooter : PropTypes . func ,
31
+ disabledDate : PropTypes . func ,
31
32
} ,
32
33
data ( ) {
33
34
this . nextDecade = goYear . bind ( this , 10 ) ;
@@ -67,18 +68,26 @@ export default {
67
68
} ,
68
69
69
70
render ( ) {
70
- const { sValue : value , locale, renderFooter } = this ;
71
+ const { sValue : value , locale, renderFooter, $props } = this ;
71
72
const decadePanelShow = getListeners ( this ) . decadePanelShow || noop ;
72
73
const years = this . years ( ) ;
73
74
const currentYear = value . year ( ) ;
74
75
const startYear = parseInt ( currentYear / 10 , 10 ) * 10 ;
75
76
const endYear = startYear + 9 ;
76
77
const prefixCls = `${ this . rootPrefixCls } -year-panel` ;
78
+ const { disabledDate } = $props ;
77
79
78
80
const yeasEls = years . map ( ( row , index ) => {
79
81
const tds = row . map ( yearData => {
82
+ let disabled = false ;
83
+ if ( disabledDate ) {
84
+ const testValue = value . clone ( ) ;
85
+ testValue . year ( yearData . year ) ;
86
+ disabled = disabledDate ( testValue ) ;
87
+ }
80
88
const classNameMap = {
81
89
[ `${ prefixCls } -cell` ] : 1 ,
90
+ [ `${ prefixCls } -cell-disabled` ] : disabled ,
82
91
[ `${ prefixCls } -selected-cell` ] : yearData . year === currentYear ,
83
92
[ `${ prefixCls } -last-decade-cell` ] : yearData . year < startYear ,
84
93
[ `${ prefixCls } -next-decade-cell` ] : yearData . year > endYear ,
@@ -96,7 +105,7 @@ export default {
96
105
role = "gridcell"
97
106
title = { yearData . title }
98
107
key = { yearData . content }
99
- onClick = { clickHandler }
108
+ onClick = { disabled ? noop : clickHandler }
100
109
class = { classNameMap }
101
110
>
102
111
< a class = { `${ prefixCls } -year` } > { yearData . content } </ a >
0 commit comments