import QuarterHeader from './QuarterHeader'; import QuarterBody from './QuarterBody'; import type { PanelSharedProps } from '../../interface'; import { createKeydownHandler } from '../../utils/uiUtil'; import useMergeProps from '../../hooks/useMergeProps'; export type QuarterPanelProps = {} & PanelSharedProps; function QuarterPanel(_props: QuarterPanelProps) { const props = useMergeProps(_props); const { prefixCls, operationRef, onViewDateChange, generateConfig, value, viewDate, onPanelChange, onSelect, } = props; const panelPrefixCls = `${prefixCls}-quarter-panel`; // ======================= Keyboard ======================= operationRef.value = { onKeydown: (event: KeyboardEvent) => createKeydownHandler(event, { onLeftRight: diff => { onSelect(generateConfig.addMonth(value || viewDate, diff * 3), 'key'); }, onCtrlLeftRight: diff => { onSelect(generateConfig.addYear(value || viewDate, diff), 'key'); }, onUpDown: diff => { onSelect(generateConfig.addYear(value || viewDate, diff), 'key'); }, }), }; // ==================== View Operation ==================== const onYearChange = (diff: number) => { const newDate = generateConfig.addYear(viewDate, diff); onViewDateChange(newDate); onPanelChange(null, newDate); }; return (
{ onYearChange(-1); }} onNextYear={() => { onYearChange(1); }} onYearClick={() => { onPanelChange('year', viewDate); }} /> {...props} prefixCls={prefixCls} onSelect={date => { onSelect(date, 'mouse'); }} />
); } QuarterPanel.displayName = 'QuarterPanel'; QuarterPanel.inheritAttrs = false; export default QuarterPanel;