import { InputProps, CheckboxGroupProps, DatePickerProps, InputNumberProps, RadioGroupProps, SwitchProps, TextAreaProps, SelectProps, PopconfirmProps, SliderProps, SegmentedProps, RateProps, TreeSelectProps, CascaderProps } from '@aplus-frontend/antdv';
import { RangePickerProps } from '@aplus-frontend/antdv/es/date-picker/dayjs';
import { DefaultOptionType } from '@aplus-frontend/antdv/es/select';
import { InputFocusOptions } from '@aplus-frontend/antdv/es/vc-input/utils/commonUtils';
import { RangeValue } from '@aplus-frontend/antdv/es/vc-picker/interface';
import { SharedTimeProps } from '@aplus-frontend/antdv/es/vc-picker/panels/TimePanel';
import { LegacyDataNode } from '@aplus-frontend/antdv/es/vc-tree-select/interface';
import { ZoneAlias } from '@aplus-frontend/utils';
import { Dayjs } from 'dayjs';
import { VNode } from 'vue';
import { LiteralUnion, Recordable } from '../type';
import { ApFormatPresetType } from './date/interface';
import { InputPasswordProps } from './text/input-password-props';
export type FieldMode = 'read' | 'edit';
type CommonApFieldExpose = {
    focus: () => void;
    blur: () => void;
    request: () => void;
};
export type BasicApFieldProps<FieldPropsType = any> = {
    mode?: FieldMode;
    class?: unknown;
    style?: unknown;
    emptyText?: string;
    /**
     * 自定义渲染只读模式（仅输入类型控件支持）
     * @param originalNode 默认渲染的节点
     * @param val 将要渲染的文本
     * @returns
     */
    customReadMode?: (originalNode: any, val?: any) => VNode;
} & FieldPropsType;
export type ApFieldTextProps = BasicApFieldProps<InputProps> & {
    /**
     * 输入生效前的事件，受控输入拦截
     * @param nextVal
     * @returns
     */
    beforeInput?: (nextVal: string) => string;
};
export type ApFieldTextExpose = {
    focus: (options?: InputFocusOptions) => void;
    blur: () => void;
    input: any;
    setSelectionRange: (start: number, end: number, direction?: 'forward' | 'backward' | 'none') => void;
    select: () => void;
};
export type ApFieldTextPasswordProps = BasicApFieldProps<InputPasswordProps>;
export type ApFieldTextPasswordExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldCheckboxProps = BasicApFieldProps<CheckboxGroupProps> & {
    request?: () => Promise<CheckboxGroupProps['options']>;
    vertical?: boolean;
};
export type ApFieldCheckboxExpose = Pick<CommonApFieldExpose, 'request'>;
export type ApFieldDateProps = BasicApFieldProps<Omit<DatePickerProps, 'mode' | 'value' | 'defaultValue' | 'onChange' | 'onOk' | 'format' | 'onUpdate:value'>> & {
    value?: number | null;
    defaultValue?: number;
    'onUpdate:value'?: (ts: number | null) => void;
    onChange?: (ts: number | null, dayStr: string) => void;
    onOk?: (ts: number | null) => void;
    format?: LiteralUnion<ApFormatPresetType, string>;
    /**
     * 只用于显示的自定义格式化
     */
    shownFormat?: DatePickerProps['format'];
    /**
     * 格式化时间时是否以`format`的开始
     * @default true
     */
    formatBegins?: boolean;
    /**
     * 指定时区，指定后value会变为特定时区下的timestamp
     */
    timezone?: ZoneAlias | {
        label?: string;
        value: ZoneAlias;
    }[];
    disabledTime?: SharedTimeProps<Dayjs>['disabledTime'];
};
export type ApFieldDateExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldNumberProps = BasicApFieldProps<Omit<InputNumberProps, 'mode'>> & {
    /**
     * 输入框的显示模式（输入框/数字轮播）
     */
    inputMode?: InputNumberProps['mode'];
    /**
     * 是否展示千分位，只读模式可用
     */
    thousands?: boolean;
    /**
     * 强制保留指定的小数位，只读模式可用，只有在设置了`precision`才生效
     */
    limitDecimalsRetain?: boolean;
};
export type ApiFieldNumberExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldRadioProps = BasicApFieldProps<RadioGroupProps> & {
    request?: () => Promise<RadioGroupProps['options']>;
    vertical?: boolean;
};
export type ApFieldRadioExpose = Pick<CommonApFieldExpose, 'request'>;
export type ApFieldSwitchConfirmConfig = Pick<PopconfirmProps, 'title' | 'okText' | 'cancelText' | 'description' | 'showCancel' | 'icon' | 'okType' | 'onCancel' | 'okButtonProps' | 'cancelButtonProps'>;
export type ApFieldSwitchProps = BasicApFieldProps<Omit<SwitchProps, 'onClick'>> & {
    onAction?: (checked: string | boolean | number, e?: Event) => boolean | Promise<boolean>;
    confirm?: ApFieldSwitchConfirmConfig | ((checked: string | number | boolean) => ApFieldSwitchConfirmConfig);
};
export type ApFieldSwitchExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldTextAreaProps = BasicApFieldProps<Omit<TextAreaProps, 'autosize'>> & {
    /**
     * 输入生效前的事件，受控输入拦截
     * @param nextVal
     * @returns
     */
    beforeInput?: (nextVal: string) => string;
    /**
     * 是否是代码片段
     */
    code?: boolean | {
        language?: 'text' | 'json';
    };
};
export type ApFieldTextAreaExpose = Pick<CommonApFieldExpose, 'blur'> & {
    focus: (options?: InputFocusOptions) => void;
    resizableTextArea: any;
};
export type ApFieldDateRangeProps = BasicApFieldProps<Omit<RangePickerProps, 'value' | 'onChange' | 'onPanelChange' | 'defaultValue' | 'onOk' | 'renderExtraFooter' | 'onUpdate:value' | 'mode' | 'format' | 'presets'>> & {
    value?: RangeValue<number> | null;
    defaultValue?: RangeValue<number>;
    'onUpdate:value'?: (ts: RangeValue<number> | null) => void;
    onChange?: (ts: RangeValue<number> | null, dayStr: [string, string]) => void;
    onOk?: (ts: RangeValue<number>) => void;
    format?: LiteralUnion<ApFormatPresetType, string>;
    /**
     * 只用于显示的format
     */
    shownFormat?: RangePickerProps['format'];
    /**
     * 指定时区，指定后value会变为特定时区下的timestamp
     */
    timezone?: ZoneAlias | {
        label?: string;
        value: ZoneAlias;
    }[];
    /**
     * 只读模式下的分隔符（比插槽优先级更高）
     */
    readModeSeparator?: any;
    presets?: RangePickerProps['presets'] | true | {
        /**
         * 是否显示本周
         */
        thisWeek?: boolean;
        /**
         * 是否显示上周
         */
        lastWeek?: boolean;
        /**
         * 是否显示近7天
         */
        last7Days?: boolean;
        /**
         * 是否显示近30天
         */
        last30Days?: boolean;
        /**
         * 是否显示近90天
         */
        last90Days?: boolean;
        /**
         * 是否显示本月
         */
        thisMonth?: boolean;
        /**
         * 是否显示上月
         */
        lastMonth?: boolean;
        /**
         * 是否显示本季度
         */
        thisQuarter?: boolean;
        /**
         * 是否显示上季度
         */
        lastQuarter?: boolean;
        /**
         * 是否显示今年
         */
        thisYear?: boolean;
        /**
         * 是否显示去年
         */
        lastYear?: boolean;
    };
};
export type ApFieldDateRangeExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldSelectProps = BasicApFieldProps<Omit<SelectProps, 'mode' | 'value' | 'onUpdate:value' | 'onSearch'>> & {
    request?: (value?: string, extraParams?: Recordable) => Promise<SelectProps['options']>;
    multiple?: boolean;
    value?: SelectProps['value'];
    'onUpdate:value'?: SelectProps['onUpdate:value'];
    /**
     * 如果设置showSearch=true，此时设置searchMode=filter将进行前端筛选，设置searchMode=request将会走后端筛选
     */
    searchMode?: 'filter' | 'request';
    /**
     * 是否在Select框聚焦时再次触发选项请求
     * @deprecated 有歧义，请使用fetchOnFocus
     */
    refetchOnFocus?: boolean;
    /**
     * 是否在聚焦时触发网络请求
     * @since 7.15.0
     */
    fetchOnFocus?: boolean;
    /**
     * 是否在打开选项列表时请求列表数据
     * @since 7.17.2
     */
    fetchOnOpen?: boolean;
    /**
     * 是否延迟请求选项列表 true: 不请求选项; 'first-focus': 首次聚焦时触发网络请求
     */
    lazy?: boolean | 'first-focus' | 'first-open';
    /**
     * 添加一个名为全部的节点（只在多选的情况下有效）
     */
    addAll?: boolean | number;
    /**
     * 发起request额外的请求，变更后会自动重新发器请求
     */
    params?: Recordable;
    /**
     * 发起搜索的时间间隔默认300ms
     */
    searchDelay?: number;
    /**
     * 是否允许“仅选此项”，仅多选时可用
     * @default true
     */
    allowOnlySelect?: boolean;
};
export type ApFieldSelectExpose = Omit<CommonApFieldExpose, 'request'> & {
    request: (clear?: boolean) => Promise<void>;
};
export type ApFieldTreeSelectProps = BasicApFieldProps<Omit<TreeSelectProps, 'loadData'>> & {
    /**
     * 用于请求treeNode
     * @param currentNode 异步加载时表示当前节点，非异步请求时为undefined
     * @param extraParams 额外的响应式参数
     * @returns
     */
    request?: (currentNode?: LegacyDataNode, extraParams?: Recordable) => Promise<TreeSelectProps['treeData']>;
    /**
     * 是否跳过首次加载数据
     */
    lazy?: boolean;
    /**
     * 发起request额外的请求，变更后会自动重新发器请求
     */
    params?: Recordable;
    /**
     * 是否懒加载子树
     */
    loadData?: boolean;
};
export type ApFieldTreeSelectExpose = Omit<ApFieldSelectExpose, 'request'> & {
    /**
     * 手动请求treeData
     * @param currentNode 当前树节点（用于请求子树，如果不需要请求子树传入undefined）
     * @param clear 请求数据前是否清空treeData
     * @returns
     */
    request: (currentNode?: LegacyDataNode, clear?: boolean) => Promise<void>;
};
export type ApFieldSliderProps = BasicApFieldProps<Partial<SliderProps>> & {
    defaultValue?: number | [number, number];
};
export type ApFieldSliderExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldSegmentedProps = BasicApFieldProps<SegmentedProps> & {
    defaultValue?: string | number;
    request?: () => Promise<SegmentedProps['options']>;
};
export type ApFieldRateProps = Omit<BasicApFieldProps<RateProps>, 'emptyText'> & {
    defaultValue?: number;
};
export type ApFieldRateExpose = Omit<CommonApFieldExpose, 'request'>;
export type ApFieldSecondProps = BasicApFieldProps<Omit<InputNumberProps, 'mode'>> & {
    placeholder?: string;
};
export type ApFieldSecondExpose = ApiFieldNumberExpose;
export type ApFieldCascaderProps = BasicApFieldProps<Omit<CascaderProps, 'loadData'>> & {
    /**
     * 手动请求节点数据
     * @param currentNode 当前选中项
     * @param clear 请求数据时是否清空数据
     * @returns
     */
    request?: (selectOptions?: DefaultOptionType[], extraParams?: Recordable) => Promise<CascaderProps['options']>;
    /**
     * 是否跳过首次加载数据
     */
    lazy?: boolean;
    /**
     * 发起request额外的请求，变更后会自动重新发器请求
     */
    params?: Recordable;
    /**
     * 是否动态加载选项
     */
    loadData?: boolean;
};
export type ApFieldCascaderExpose = Omit<CommonApFieldExpose, 'request'> & {
    request: (selectOptions?: DefaultOptionType[] | undefined, clear?: boolean) => Promise<void>;
};
export {};
