You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/date-picker/interface.js

96 lines
3.3 KiB

7 years ago
import * as moment from 'moment'
7 years ago
// import { TimePickerProps } from '../time-picker'
7 years ago
import PropTypes from '../_util/vue-types'
export const MomentType = {
type: Object,
validator: function (value) {
return value === undefined || moment.isMoment(value)
7 years ago
},
}
export const PickerProps = () => ({
transitionName: PropTypes.string,
7 years ago
prefixCls: PropTypes.string,
inputPrefixCls: PropTypes.string,
format: PropTypes.string,
disabled: PropTypes.bool,
allowClear: PropTypes.bool,
7 years ago
popupStyle: PropTypes.object,
7 years ago
dropdownClassName: PropTypes.string,
7 years ago
locale: PropTypes.any,
localeCode: PropTypes.string,
7 years ago
size: PropTypes.oneOf(['large', 'small', 'default']),
getCalendarContainer: PropTypes.func,
open: PropTypes.bool,
// onOpenChange: PropTypes.(status: bool) => void,
7 years ago
disabledDate: PropTypes.func,
renderExtraFooter: PropTypes.any,
showToday: PropTypes.bool,
7 years ago
dateRender: PropTypes.any, // (current: moment.Moment, today: moment.Moment) => React.ReactNode,
pickerClass: PropTypes.string,
pickerInputClass: PropTypes.string,
timePicker: PropTypes.any,
autoFocus: PropTypes.bool,
7 years ago
})
export const SinglePickerProps = () => ({
value: MomentType,
defaultValue: MomentType,
defaultPickerValue: MomentType,
// onChange?: (date: moment.Moment, dateString: string) => void;
})
export const DatePickerProps = () => ({
...PickerProps(), ...SinglePickerProps(),
showTime: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
7 years ago
open: PropTypes.bool,
disabledTime: PropTypes.func,
// onOpenChange?: (status: bool) => void;
7 years ago
// onOk?: (selectedTime: moment.Moment) => void;
placeholder: PropTypes.string,
})
export const MonthPickerProps = () => ({
...PickerProps(), ...SinglePickerProps(),
placeholder: PropTypes.string,
monthCellContentRender: PropTypes.func,
7 years ago
})
function isMomentArray (value) {
if (Array.isArray(value)) {
return value.length === 0 || value.findIndex((val) => val === undefined || moment.isMoment(val)) !== -1
}
return false
}
7 years ago
export const RangePickerValue = PropTypes.custom(isMomentArray)
// export const RangePickerPresetRange = PropTypes.oneOfType([RangePickerValue, PropTypes.func])
7 years ago
export const RangePickerProps = () => ({
...PickerProps(),
value: RangePickerValue,
defaultValue: RangePickerValue,
defaultPickerValue: RangePickerValue,
// onChange?: (dates: RangePickerValue, dateStrings: [string, string]) => void;
// onCalendarChange?: (dates: RangePickerValue, dateStrings: [string, string]) => void;
// onOk?: (selectedTime: moment.Moment) => void;
showTime: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
7 years ago
ranges: PropTypes.object,
placeholder: PropTypes.arrayOf(String),
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(String)]),
7 years ago
disabledTime: PropTypes.func,
showToday: PropTypes.bool,
7 years ago
// onPanelChange?: (value?: RangePickerValue, mode?: string | string[]) => void;
})
7 years ago
export const WeekPickerProps = () => ({
7 years ago
...PickerProps(), ...SinglePickerProps(),
placeholder: PropTypes.string,
})
// export interface DatePickerDecorator extends React.ClassicComponentClass<DatePickerProps> {
// RangePicker: React.ClassicComponentClass<RangePickerProps>;
// MonthPicker: React.ClassicComponentClass<MonthPickerProps>;
// WeekPicker: React.ClassicComponentClass<WeexPickerProps>;
// }