index.js
2.81 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.DECADE_DISTANCE_COUNT = exports.DECADE_UNIT_DIFF = void 0;
var React = _interopRequireWildcard(require("react"));
var _DecadeHeader = _interopRequireDefault(require("./DecadeHeader"));
var _DecadeBody = _interopRequireWildcard(require("./DecadeBody"));
var _uiUtil = require("../../utils/uiUtil");
var DECADE_UNIT_DIFF = 10;
exports.DECADE_UNIT_DIFF = DECADE_UNIT_DIFF;
var DECADE_DISTANCE_COUNT = DECADE_UNIT_DIFF * 10;
exports.DECADE_DISTANCE_COUNT = DECADE_DISTANCE_COUNT;
function DecadePanel(props) {
var prefixCls = props.prefixCls,
onViewDateChange = props.onViewDateChange,
generateConfig = props.generateConfig,
viewDate = props.viewDate,
operationRef = props.operationRef,
onSelect = props.onSelect,
onPanelChange = props.onPanelChange;
var panelPrefixCls = "".concat(prefixCls, "-decade-panel"); // ======================= Keyboard =======================
operationRef.current = {
onKeyDown: function onKeyDown(event) {
return (0, _uiUtil.createKeyDownHandler)(event, {
onLeftRight: function onLeftRight(diff) {
onSelect(generateConfig.addYear(viewDate, diff * DECADE_UNIT_DIFF), 'key');
},
onCtrlLeftRight: function onCtrlLeftRight(diff) {
onSelect(generateConfig.addYear(viewDate, diff * DECADE_DISTANCE_COUNT), 'key');
},
onUpDown: function onUpDown(diff) {
onSelect(generateConfig.addYear(viewDate, diff * DECADE_UNIT_DIFF * _DecadeBody.DECADE_COL_COUNT), 'key');
},
onEnter: function onEnter() {
onPanelChange('year', viewDate);
}
});
}
}; // ==================== View Operation ====================
var onDecadesChange = function onDecadesChange(diff) {
var newDate = generateConfig.addYear(viewDate, diff * DECADE_DISTANCE_COUNT);
onViewDateChange(newDate);
onPanelChange(null, newDate);
};
var onInternalSelect = function onInternalSelect(date) {
onSelect(date, 'mouse');
onPanelChange('year', date);
};
return /*#__PURE__*/React.createElement("div", {
className: panelPrefixCls
}, /*#__PURE__*/React.createElement(_DecadeHeader.default, Object.assign({}, props, {
prefixCls: prefixCls,
onPrevDecades: function onPrevDecades() {
onDecadesChange(-1);
},
onNextDecades: function onNextDecades() {
onDecadesChange(1);
}
})), /*#__PURE__*/React.createElement(_DecadeBody.default, Object.assign({}, props, {
prefixCls: prefixCls,
onSelect: onInternalSelect
})));
}
var _default = DecadePanel;
exports.default = _default;