import { ReactNode, MouseEvent, FocusEvent, CSSProperties, Component } from 'react'; import { Dayjs } from 'dayjs'; import { createDelayActionQueue, createListenerGroup } from '@befe/brick-utils'; import { PopperHandle } from '@befe/brick-comp-popper'; import { UiTimePanel, COL_NAMES } from '@befe/brick-comp-time-picker'; import { InputProps } from '@befe/brick-comp-input'; import { ModuleMonthPanel } from '../modules/create-month-panel'; import { createDatePanel } from '../modules/create-date-panel'; import { getValueExtractor } from '../utils/get-value-extractor'; import { QuickActions } from './create-quick-actions'; import { createRangePickerUserInput } from './create-range-input'; import { ActionLink, DatePickerMode, DateValue, PickerSize, PickerStatus } from './prop-types'; type InnerRangePickerPropsFromInput = Pick; export interface RangePickerProps extends InnerRangePickerPropsFromInput { className?: string; startValue?: DateValue; endValue?: DateValue; defaultStartValue?: DateValue; defaultEndValue?: DateValue; disabled?: boolean; size?: PickerSize; status?: PickerStatus; mode?: DatePickerMode; itemFormat?: string; renderItem?: (currentDate: Dayjs, today: Dayjs) => (ReactNode | string | number); getDisabledItem?: (currentDate: Dayjs, today: Dayjs) => boolean; /** * 当日期面板打开时, 设置其 "显示的面板位置" * * 这个可能主要在当没有选择日期时, 用于确定面板月份的显示策略 ( 缺省方案是显示 "当月" + "1 个月" ) */ getDefaultDisplayDateRange?: (today: Dayjs) => { start: Dayjs; end: Dayjs; }; showTime?: boolean; hideNow?: boolean; showSecond?: boolean; getDisabledTime?: (currentDate: Dayjs) => { start: number | null; end: number | null; }; open?: boolean | undefined; clearable?: boolean; startPlaceholder?: string; endPlaceholder?: string; startStyle?: CSSProperties; endStyle?: CSSProperties; popperClassName?: string; onChange?: (start: Dayjs | null, end: Dayjs | null) => void; /** * 这个传递 start, end 的原因, 可参见 date picker 的 onOpenChange 的注释 */ onOpenChange?: (openStatus: boolean, start: Dayjs | null, end: Dayjs | null) => void; renderFooter?: () => ReactNode | ActionLink[]; renderQuickActions?: () => ActionLink[]; onFocus?: (e: FocusEvent) => void; onBlur?: (e: FocusEvent) => void; autoFocus?: boolean; onMouseEnter?: (e: MouseEvent) => void; onMouseLeave?: (e: MouseEvent) => void; yearStart?: number; yearEnd?: number; } export interface RangePickerState { open: boolean; isStartZooming: boolean; isEndZooming: boolean; startValue: Dayjs | null; endValue: Dayjs | null; startDisplayedDate: Dayjs | null; endDisplayedDate: Dayjs | null; startZoomedDisplayedDate: Dayjs | null; endZoomedDisplayedDate: Dayjs | null; isStartUserInput: boolean; startUserInputText: string; isEndUserInput: boolean; endUserInputText: string; startFocus: boolean; endFocus: boolean; isSelecting: boolean; firstSelectedDate: Dayjs | null; secondHoveringDate: Dayjs | null; dateTimeValue: Dayjs | null; dateTimeDisplayedDate: Dayjs | null; dateTimeStage: 'start' | 'end'; dateTimeState: { hour: number | undefined; minute: number | undefined; second: number | undefined; }; } /** * `InnerRangePicker` 现在是「控制器 / facade」类型(原 class 实例类型的等价替身)。 * * class 迁 function 后,`src/modules/*`、`create-range-input` 等仍通过一个 `comp` 对象 * 读写 `comp.props` / `comp.state` / `comp.setState`(动态 key)/ `comp.actionQueue` 等; * 为了让这些模块保持不变,function 组件内部构造一个稳定的 `comp` facade 来呈现与原 class * 实例相同的接口。该接口即此 `InnerRangePicker`,仍 `extends Component<...>` 以保证 * 这些模块里的 `comp as PanelComp`、`comp.setState(...)` 等用法的类型检查与迁移前完全一致。 * * 它同时就是对外 ref 的 handle 类型(消费方 / 测试通过 ref 读 `getValue` / `setValue` / * `focus` / `syncDisplayDate` 等)。 */ export interface InnerRangePicker extends Component { actionQueue: ReturnType; listenerGroup: ReturnType; quickActions: QuickActions; userInput: ReturnType; refPanelWrapper: { readonly elem: PopperHandle | null; ref: (node: PopperHandle | null) => void; }; refUITimePanel: UiTimePanel | null; startDatePanel: ReturnType; endDatePanel: ReturnType; dateTimePanel: ReturnType; zoomedStartDatePanel: ModuleMonthPanel; zoomedEndDatePanel: ModuleMonthPanel; startMonthPanel: ModuleMonthPanel; endMonthPanel: ModuleMonthPanel; readonly size: RangePickerProps['size']; readonly inputElem: HTMLDivElement | null; readonly inputWrapperElem: HTMLDivElement | null; readonly startInputElem: HTMLInputElement | null; readonly endInputElem: HTMLInputElement | null; readonly className: string; readonly popperClassName: string; readonly computedItemFormat: string; readonly computedItemValueExtractor: ReturnType; readonly shouldShowPanel: boolean; readonly isDateTimeRange: boolean | undefined; getWeekDayText: (day: number) => string; getPanelTitle_yearMonth: (date: Dayjs) => string; getPanelTitle_year: (date: Dayjs) => string; getMonthText: (month: number) => string; focus: () => void; triggerChange: (opts: { startValue?: Dayjs | null; endValue?: Dayjs | null; }) => void; handleCalendarIconClick: () => void; setOpenStatus: (opts: { open?: boolean; isStartUserInput?: boolean; isEndUserInput?: boolean; }) => void; syncDateTimeState: (value: Dayjs | null, onStateChanged?: () => void) => void; focusDateTimeStage: (stage: 'start' | 'end') => void; handleDateTimeSelected: (selectedDate: Dayjs) => void; changeDateTime: (propName: typeof COL_NAMES[number], propValue: number) => void; setCurrentDateTime: () => void; confirmDateTime: () => void; getDisabledTimeRangeList: () => Array<[ [ number, number, number ] | null, [ number, number, number ] | null ]>; renderTimeArea: () => JSX.Element; setValue: (start?: DateValue, end?: DateValue) => void; getValue: () => Array; syncDisplayDate: () => void; renderDateTimePanel: () => JSX.Element; renderPanel: () => ReactNode; } export declare const InnerRangePicker: import("react").ForwardRefExoticComponent>; export {};