DecadeBody.js
2.64 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
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.DECADE_COL_COUNT = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var React = _interopRequireWildcard(require("react"));
var _ = require(".");
var _PanelBody = _interopRequireDefault(require("../PanelBody"));
var DECADE_COL_COUNT = 3;
exports.DECADE_COL_COUNT = DECADE_COL_COUNT;
var DECADE_ROW_COUNT = 4;
function DecadeBody(props) {
var DECADE_UNIT_DIFF_DES = _.DECADE_UNIT_DIFF - 1;
var prefixCls = props.prefixCls,
viewDate = props.viewDate,
generateConfig = props.generateConfig,
disabledDate = props.disabledDate;
var cellPrefixCls = "".concat(prefixCls, "-cell");
var yearNumber = generateConfig.getYear(viewDate);
var decadeYearNumber = Math.floor(yearNumber / _.DECADE_UNIT_DIFF) * _.DECADE_UNIT_DIFF;
var startDecadeYear = Math.floor(yearNumber / _.DECADE_DISTANCE_COUNT) * _.DECADE_DISTANCE_COUNT;
var endDecadeYear = startDecadeYear + _.DECADE_DISTANCE_COUNT - 1;
var baseDecadeYear = generateConfig.setYear(viewDate, startDecadeYear - Math.ceil((DECADE_COL_COUNT * DECADE_ROW_COUNT * _.DECADE_UNIT_DIFF - _.DECADE_DISTANCE_COUNT) / 2));
var getCellClassName = function getCellClassName(date) {
var _ref;
var disabled = disabledDate && disabledDate(date);
var startDecadeNumber = generateConfig.getYear(date);
var endDecadeNumber = startDecadeNumber + DECADE_UNIT_DIFF_DES;
return _ref = {}, (0, _defineProperty2.default)(_ref, "".concat(cellPrefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_ref, "".concat(cellPrefixCls, "-in-view"), startDecadeYear <= startDecadeNumber && endDecadeNumber <= endDecadeYear), (0, _defineProperty2.default)(_ref, "".concat(cellPrefixCls, "-selected"), startDecadeNumber === decadeYearNumber), _ref;
};
return /*#__PURE__*/React.createElement(_PanelBody.default, Object.assign({}, props, {
rowNum: DECADE_ROW_COUNT,
colNum: DECADE_COL_COUNT,
baseDate: baseDecadeYear,
getCellText: function getCellText(date) {
var startDecadeNumber = generateConfig.getYear(date);
return "".concat(startDecadeNumber, "-").concat(startDecadeNumber + DECADE_UNIT_DIFF_DES);
},
getCellClassName: getCellClassName,
getCellDate: function getCellDate(date, offset) {
return generateConfig.addYear(date, offset * _.DECADE_UNIT_DIFF);
}
}));
}
var _default = DecadeBody;
exports.default = _default;