import { ProFormDatePicker } from '@ant-design/pro-components';

type BaseFormDatePickerProps = React.ComponentProps<typeof ProFormDatePicker>;
export type { BaseFormDatePickerProps };

const BaseFormDatePicker = (props: BaseFormDatePickerProps) => {
  return (
    <ProFormDatePicker
      {...props}
      fieldProps={{
        ...props.fieldProps,
        style: { width: '100%', ...props.fieldProps?.style },
      }}
      placeholder={
        props?.placeholder ??
        `请选择${typeof props?.label === 'string' ? props?.label : ''}`
      }
    />
  );
};

const ExportComponent = BaseFormDatePicker as typeof BaseFormDatePicker & {
  Week: typeof ProFormDatePicker.Week;
  Month: typeof ProFormDatePicker.Month;
  Quarter: typeof ProFormDatePicker.Quarter;
  Year: typeof ProFormDatePicker.Year;
};

ExportComponent.Week = ProFormDatePicker.Week;
ExportComponent.Month = ProFormDatePicker.Month;
ExportComponent.Quarter = ProFormDatePicker.Quarter;
ExportComponent.Year = ProFormDatePicker.Year;

export default ExportComponent;
