index.js
2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as React from 'react';
import YearHeader from './YearHeader';
import YearBody, { YEAR_COL_COUNT } from './YearBody';
import { createKeyDownHandler } from '../../utils/uiUtil';
export var YEAR_DECADE_COUNT = 10;
function YearPanel(props) {
var prefixCls = props.prefixCls,
operationRef = props.operationRef,
onViewDateChange = props.onViewDateChange,
generateConfig = props.generateConfig,
value = props.value,
viewDate = props.viewDate,
sourceMode = props.sourceMode,
_onSelect = props.onSelect,
onPanelChange = props.onPanelChange;
var panelPrefixCls = "".concat(prefixCls, "-year-panel"); // ======================= Keyboard =======================
operationRef.current = {
onKeyDown: function onKeyDown(event) {
return createKeyDownHandler(event, {
onLeftRight: function onLeftRight(diff) {
_onSelect(generateConfig.addYear(value || viewDate, diff), 'key');
},
onCtrlLeftRight: function onCtrlLeftRight(diff) {
_onSelect(generateConfig.addYear(value || viewDate, diff * YEAR_DECADE_COUNT), 'key');
},
onUpDown: function onUpDown(diff) {
_onSelect(generateConfig.addYear(value || viewDate, diff * YEAR_COL_COUNT), 'key');
},
onEnter: function onEnter() {
onPanelChange(sourceMode === 'date' ? 'date' : 'month', value || viewDate);
}
});
}
}; // ==================== View Operation ====================
var onDecadeChange = function onDecadeChange(diff) {
var newDate = generateConfig.addYear(viewDate, diff * 10);
onViewDateChange(newDate);
onPanelChange(null, newDate);
};
return /*#__PURE__*/React.createElement("div", {
className: panelPrefixCls
}, /*#__PURE__*/React.createElement(YearHeader, Object.assign({}, props, {
prefixCls: prefixCls,
onPrevDecade: function onPrevDecade() {
onDecadeChange(-1);
},
onNextDecade: function onNextDecade() {
onDecadeChange(1);
},
onDecadeClick: function onDecadeClick() {
onPanelChange('decade', viewDate);
}
})), /*#__PURE__*/React.createElement(YearBody, Object.assign({}, props, {
prefixCls: prefixCls,
onSelect: function onSelect(date) {
onPanelChange(sourceMode === 'date' ? 'date' : 'month', date);
_onSelect(date, 'mouse');
}
})));
}
export default YearPanel;