import React from "react"; import moment, { Moment } from "moment"; import Table, { CellStatus } from "./BaseTable"; import { useTranslation } from "../../i18n"; import { RangeDateType, CalendarTableType, DateChangeContext, } from "../DateProps"; import { noop } from "../../_util/noop"; import { getNow, isAfter, isBefore, isSame } from "../../datepicker/util"; export interface QuarterTableProps { /** * 当前展示时间 */ current: Moment; /** * 允许选择的时间范围限制 */ range?: RangeDateType; cellStatus?: (date: Moment) => CellStatus; onSelect?: (value: Moment, context: DateChangeContext) => void; onTypeChange?: (type: CalendarTableType) => void; onCurrentChange?: (current: Moment) => void; hideCaption?: boolean; disabledQuarter?: (date: Moment) => boolean; } export function QuarterTable({ current, onCurrentChange = noop, range, onSelect = noop, disabledQuarter, onTypeChange = noop, cellStatus = () => CellStatus.Common, hideCaption, }: QuarterTableProps) { const t = useTranslation(); const year = current.year(); const now = getNow(current); function genTable(): number[][] { return [[1, 2, 3, 4]]; } function renderYear() { return ( onTypeChange("year")}> {current.format(t.yearFormat)} ); } const [rangeMin, rangeMax] = range || [null, null]; function isValid(date) { if (moment.isMoment(rangeMin) && isAfter(rangeMin, date, "quarter")) { return false; } if (moment.isMoment(rangeMax) && isBefore(rangeMax, date, "quarter")) { return false; } return disabledQuarter(date); } return (