amis-rpc-design/node_modules/rc-picker/es/panels/DecadePanel/DecadeHeader.js

27 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
import Header from "../Header";
import { DECADE_DISTANCE_COUNT } from "./constant";
import PanelContext from "../../PanelContext";
function DecadeHeader(props) {
var prefixCls = props.prefixCls,
generateConfig = props.generateConfig,
viewDate = props.viewDate,
onPrevDecades = props.onPrevDecades,
onNextDecades = props.onNextDecades;
var _React$useContext = React.useContext(PanelContext),
hideHeader = _React$useContext.hideHeader;
if (hideHeader) {
return null;
}
var headerPrefixCls = "".concat(prefixCls, "-header");
var yearNumber = generateConfig.getYear(viewDate);
var startYear = Math.floor(yearNumber / DECADE_DISTANCE_COUNT) * DECADE_DISTANCE_COUNT;
var endYear = startYear + DECADE_DISTANCE_COUNT - 1;
return /*#__PURE__*/React.createElement(Header, _extends({}, props, {
prefixCls: headerPrefixCls,
onSuperPrev: onPrevDecades,
onSuperNext: onNextDecades
}), startYear, "-", endYear);
}
export default DecadeHeader;