add vc-calendar demo
parent
82715188aa
commit
f0918f2b76
|
@ -16,9 +16,7 @@ export default {
|
|||
} else {
|
||||
this.$listeners[eventName](...args.slice(1))
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -179,6 +179,18 @@ const initDefaultProps = (propTypes, defaultProps) => {
|
|||
Object.keys(defaultProps).forEach(k => { propTypes[k] = propTypes[k].def(defaultProps[k]) })
|
||||
return propTypes
|
||||
}
|
||||
|
||||
export function mergeProps () {
|
||||
const args = [].slice.call(arguments, 0)
|
||||
const props = {}
|
||||
args.forEach((p, i) => {
|
||||
for (const [k, v] of Object.entries(p)) {
|
||||
props[k] = props[k] || {}
|
||||
Object.assign(props[k], v)
|
||||
}
|
||||
})
|
||||
return props
|
||||
}
|
||||
export {
|
||||
hasProp,
|
||||
filterProps,
|
||||
|
|
|
@ -98,7 +98,7 @@ const Demo = {
|
|||
|
||||
toggleDisabled () {
|
||||
this.setState({
|
||||
disabled: !this.state.disabled,
|
||||
disabled: !this.disabled,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -162,7 +162,7 @@ const Demo = {
|
|||
scopedSlots={{
|
||||
default: ({ value }) => {
|
||||
return (
|
||||
<span tabIndex='0' scope={{ value }}>
|
||||
<span tabIndex='0'>
|
||||
<input
|
||||
placeholder='please select'
|
||||
style={{ width: '250px' }}
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
<script>
|
||||
/* eslint react/no-multi-comp:0, no-console:0 */
|
||||
import '../assets/index.less'
|
||||
import PropTypes from '@/components/_util/vue-types'
|
||||
import DatePicker from '../src/Picker'
|
||||
import zhCN from '../src/locale/zh_CN'
|
||||
import enUS from '../src/locale/en_US'
|
||||
import '../../vc-time-picker/assets/index.less'
|
||||
import BaseMixin from '@/components/_util/BaseMixin'
|
||||
|
||||
import MonthCalendar from '../src/MonthCalendar'
|
||||
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/zh-cn'
|
||||
import 'moment/locale/en-gb'
|
||||
|
||||
const format = 'YYYY-MM'
|
||||
const cn = window.location.search.indexOf('cn') !== -1
|
||||
|
||||
const now = moment()
|
||||
if (cn) {
|
||||
now.locale('zh-cn').utcOffset(8)
|
||||
} else {
|
||||
now.locale('en-gb').utcOffset(0)
|
||||
}
|
||||
|
||||
const defaultCalendarValue = now.clone()
|
||||
defaultCalendarValue.add(-1, 'month')
|
||||
|
||||
const Demo = {
|
||||
mixins: [BaseMixin],
|
||||
props: {
|
||||
defaultValue: PropTypes.object,
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
showTime: true,
|
||||
disabled: false,
|
||||
value: this.defaultValue,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChange (value) {
|
||||
console.log(`DatePicker change: ${value && value.format(format)}`)
|
||||
this.setState({
|
||||
value,
|
||||
})
|
||||
},
|
||||
|
||||
onShowTimeChange (e) {
|
||||
this.setState({
|
||||
showTime: e.target.checked,
|
||||
})
|
||||
},
|
||||
|
||||
toggleDisabled () {
|
||||
this.setState({
|
||||
disabled: !this.disabled,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
render () {
|
||||
const state = this.$data
|
||||
const calendar = (<MonthCalendar
|
||||
locale={cn ? zhCN : enUS}
|
||||
style={{ zIndex: 1000 }}
|
||||
/>)
|
||||
return (<div style={{ width: '240px', margin: '20px' }}>
|
||||
<div style={{ marginBottom: '10px' }}>
|
||||
|
||||
<label>
|
||||
<input
|
||||
checked={state.disabled}
|
||||
onChange={this.toggleDisabled}
|
||||
type='checkbox'
|
||||
/> disabled
|
||||
</label>
|
||||
</div>
|
||||
<div style={{
|
||||
boxSizing: 'border-box',
|
||||
position: 'relative',
|
||||
display: 'block',
|
||||
lineHeight: 1.5,
|
||||
marginBottom: '22px',
|
||||
}}
|
||||
>
|
||||
<DatePicker
|
||||
animation='slide-up'
|
||||
disabled={state.disabled}
|
||||
calendar={calendar}
|
||||
value={state.value}
|
||||
onChange={this.onChange}
|
||||
scopedSlots={{
|
||||
default: ({ value }) => {
|
||||
return (
|
||||
<input
|
||||
style={{ width: '200px' }}
|
||||
readOnly
|
||||
disabled={state.disabled}
|
||||
value={value && value.format(format)}
|
||||
placeholder='请选择日期'
|
||||
/>
|
||||
)
|
||||
},
|
||||
}}
|
||||
>
|
||||
</DatePicker>
|
||||
</div>
|
||||
</div>)
|
||||
},
|
||||
}
|
||||
|
||||
function onStandaloneSelect (value) {
|
||||
console.log('month-calendar select', (value && value.format(format)))
|
||||
}
|
||||
|
||||
function onStandaloneChange (value) {
|
||||
console.log('month-calendar change', (value && value.format(format)))
|
||||
}
|
||||
|
||||
function disabledDate (value) {
|
||||
return value.year() > now.year() ||
|
||||
value.year() === now.year() && value.month() > now.month()
|
||||
}
|
||||
|
||||
function onMonthCellContentRender (value) {
|
||||
// console.log('month-calendar onMonthCellContentRender', (value && value.format(format)));
|
||||
return `${value.month() + 1}月`
|
||||
}
|
||||
export default {
|
||||
render () {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
zIndex: 1000,
|
||||
position: 'relative',
|
||||
width: '600px',
|
||||
margin: '0 auto',
|
||||
}}
|
||||
>
|
||||
<MonthCalendar
|
||||
locale={cn ? zhCN : enUS}
|
||||
style={{ zIndex: 1000 }}
|
||||
disabledDate={disabledDate}
|
||||
onSelect={onStandaloneSelect}
|
||||
onChange={onStandaloneChange}
|
||||
monthCellContentRender={onMonthCellContentRender}
|
||||
defaultValue={defaultCalendarValue}
|
||||
/>
|
||||
|
||||
<div style={{ marginTop: '200px' }}>
|
||||
<Demo defaultValue={now} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,204 @@
|
|||
<script>
|
||||
/* eslint react/no-multi-comp:0, no-console:0 */
|
||||
|
||||
import '../assets/index.less'
|
||||
import '@/components/vc-time-picker/assets/index.less'
|
||||
import Picker from '../src/Picker'
|
||||
import zhCN from '../src/locale/zh_CN'
|
||||
import enUS from '../src/locale/en_US'
|
||||
import '../../vc-time-picker/assets/index.less'
|
||||
import TimePickerPanel from '../../vc-time-picker/Panel'
|
||||
import BaseMixin from '@/components/_util/BaseMixin'
|
||||
|
||||
import RangeCalendar from '../src/RangeCalendar'
|
||||
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/zh-cn'
|
||||
import 'moment/locale/en-gb'
|
||||
|
||||
const cn = window.location.search.indexOf('cn') !== -1
|
||||
|
||||
if (cn) {
|
||||
moment.locale('zh-cn')
|
||||
} else {
|
||||
moment.locale('en-gb')
|
||||
}
|
||||
|
||||
const now = moment()
|
||||
if (cn) {
|
||||
now.utcOffset(8)
|
||||
} else {
|
||||
now.utcOffset(0)
|
||||
}
|
||||
|
||||
const defaultCalendarValue = now.clone()
|
||||
defaultCalendarValue.add(-1, 'month')
|
||||
|
||||
const timePickerElement = (h) => <TimePickerPanel defaultValue={[moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')]}/>
|
||||
|
||||
function newArray (start, end) {
|
||||
const result = []
|
||||
for (let i = start; i < end; i++) {
|
||||
result.push(i)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function disabledDate (current) {
|
||||
const date = moment()
|
||||
date.hour(0)
|
||||
date.minute(0)
|
||||
date.second(0)
|
||||
return current.isBefore(date) // can not select days before today
|
||||
}
|
||||
|
||||
function disabledTime (time, type) {
|
||||
console.log('disabledTime', time, type)
|
||||
if (type === 'start') {
|
||||
return {
|
||||
disabledHours () {
|
||||
const hours = newArray(0, 60)
|
||||
hours.splice(20, 4)
|
||||
return hours
|
||||
},
|
||||
disabledMinutes (h) {
|
||||
if (h === 20) {
|
||||
return newArray(0, 31)
|
||||
} else if (h === 23) {
|
||||
return newArray(30, 60)
|
||||
}
|
||||
return []
|
||||
},
|
||||
disabledSeconds () {
|
||||
return [55, 56]
|
||||
},
|
||||
}
|
||||
}
|
||||
return {
|
||||
disabledHours () {
|
||||
const hours = newArray(0, 60)
|
||||
hours.splice(2, 6)
|
||||
return hours
|
||||
},
|
||||
disabledMinutes (h) {
|
||||
if (h === 20) {
|
||||
return newArray(0, 31)
|
||||
} else if (h === 23) {
|
||||
return newArray(30, 60)
|
||||
}
|
||||
return []
|
||||
},
|
||||
disabledSeconds () {
|
||||
return [55, 56]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const formatStr = 'YYYY-MM-DD HH:mm:ss'
|
||||
function format (v) {
|
||||
return v ? v.format(formatStr) : ''
|
||||
}
|
||||
|
||||
function isValidRange (v) {
|
||||
return v && v[0] && v[1]
|
||||
}
|
||||
|
||||
function onStandaloneChange (value) {
|
||||
console.log('onChange')
|
||||
console.log(value[0] && format(value[0]), value[1] && format(value[1]))
|
||||
}
|
||||
|
||||
function onStandaloneSelect (value) {
|
||||
console.log('onSelect')
|
||||
console.log(format(value[0]), format(value[1]))
|
||||
}
|
||||
|
||||
const Demo = {
|
||||
mixins: [BaseMixin],
|
||||
data () {
|
||||
return {
|
||||
value: [],
|
||||
hoverValue: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChange (value) {
|
||||
console.log('onChange', value)
|
||||
this.setState({ value })
|
||||
},
|
||||
|
||||
onHoverChange (hoverValue) {
|
||||
this.setState({ hoverValue })
|
||||
},
|
||||
},
|
||||
render (h) {
|
||||
const state = this.$data
|
||||
const calendar = (
|
||||
<RangeCalendar
|
||||
hoverValue={state.hoverValue}
|
||||
onHoverChange={this.onHoverChange}
|
||||
showWeekNumber={false}
|
||||
dateInputPlaceholder={['start', 'end']}
|
||||
defaultValue={[now, now.clone().add(1, 'months')]}
|
||||
locale={cn ? zhCN : enUS}
|
||||
disabledTime={disabledTime}
|
||||
timePicker={timePickerElement(h)}
|
||||
/>
|
||||
)
|
||||
return (
|
||||
<Picker
|
||||
value={state.value}
|
||||
onChange={this.onChange}
|
||||
animation='slide-up'
|
||||
calendar={calendar}
|
||||
>
|
||||
{
|
||||
({ value }) => {
|
||||
return (<span>
|
||||
<input
|
||||
placeholder='please select'
|
||||
style={{ width: '350px' }}
|
||||
disabled={state.disabled}
|
||||
readOnly
|
||||
className='ant-calendar-picker-input ant-input'
|
||||
value={isValidRange(value) && `${format(value[0])} - ${format(value[1])}` || ''}
|
||||
/>
|
||||
</span>)
|
||||
}
|
||||
}
|
||||
</Picker>)
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
render (h) {
|
||||
return (
|
||||
<div>
|
||||
<h2>calendar</h2>
|
||||
<div style={{ margin: '10px' }}>
|
||||
<RangeCalendar
|
||||
showToday={false}
|
||||
showWeekNumber
|
||||
dateInputPlaceholder={['start', 'end']}
|
||||
locale={cn ? zhCN : enUS}
|
||||
showOk={false}
|
||||
showClear
|
||||
format={formatStr}
|
||||
onChange={onStandaloneChange}
|
||||
onSelect={onStandaloneSelect}
|
||||
disabledDate={disabledDate}
|
||||
timePicker={timePickerElement(h)}
|
||||
disabledTime={disabledTime}
|
||||
/>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<div style={{ margin: '20px' }}>
|
||||
<Demo />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,76 @@
|
|||
<script>
|
||||
/* eslint react/no-multi-comp:0, no-console:0 */
|
||||
import '../assets/index.less'
|
||||
import zhCN from '../src/locale/zh_CN'
|
||||
import enUS from '../src/locale/en_US'
|
||||
import '../../vc-time-picker/assets/index.less'
|
||||
import BaseMixin from '@/components/_util/BaseMixin'
|
||||
|
||||
import FullCalendar from '@/components/vc-calendar/src/FullCalendar'
|
||||
|
||||
import '@/components/vc-select/assets/index.less'
|
||||
import Select from '@/components/vc-select'
|
||||
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/zh-cn'
|
||||
import 'moment/locale/en-gb'
|
||||
|
||||
const format = 'YYYY-MM-DD'
|
||||
const cn = window.location.search.indexOf('cn') !== -1
|
||||
|
||||
const now = moment()
|
||||
if (cn) {
|
||||
now.locale('zh-cn').utcOffset(8)
|
||||
} else {
|
||||
now.locale('en-gb').utcOffset(0)
|
||||
}
|
||||
|
||||
const defaultCalendarValue = now.clone()
|
||||
defaultCalendarValue.add(-1, 'month')
|
||||
|
||||
function onSelect (value) {
|
||||
console.log('select', value.format(format))
|
||||
}
|
||||
|
||||
export default {
|
||||
mixins: [BaseMixin],
|
||||
data () {
|
||||
return {
|
||||
type: 'month',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onTypeChange (type) {
|
||||
this.setState({
|
||||
type,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div style={{ zIndex: 1000, position: 'relative' }}>
|
||||
<FullCalendar
|
||||
style={{ margin: '10px' }}
|
||||
Select={Select}
|
||||
fullscreen={false}
|
||||
onSelect={onSelect}
|
||||
defaultValue={now}
|
||||
locale={cn ? zhCN : enUS}
|
||||
/>
|
||||
<FullCalendar
|
||||
style={{ margin: '10px' }}
|
||||
Select={Select}
|
||||
fullscreen
|
||||
defaultValue={now}
|
||||
onSelect={onSelect}
|
||||
type={this.type}
|
||||
onTypeChange={this.onTypeChange}
|
||||
locale={cn ? zhCN : enUS}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
</script>
|
|
@ -10,8 +10,8 @@ import CalendarFooter from './calendar/CalendarFooter'
|
|||
import CalendarMixin from './mixin/CalendarMixin'
|
||||
import CommonMixin from './mixin/CommonMixin'
|
||||
import DateInput from './date/DateInput'
|
||||
import enUs from './locale/en_US'
|
||||
import { getTimeConfig, getTodayTime, syncTime } from './util'
|
||||
function noop () {}
|
||||
function goStartMonth () {
|
||||
const next = this.sValue.clone()
|
||||
next.startOf('month')
|
||||
|
@ -48,6 +48,9 @@ function goDay (direction) {
|
|||
|
||||
const Calendar = {
|
||||
props: {
|
||||
locale: PropTypes.object.def(enUs),
|
||||
visible: PropTypes.bool.def(true),
|
||||
prefixCls: PropTypes.string.def('rc-calendar'),
|
||||
// prefixCls: PropTypes.string,
|
||||
defaultValue: PropTypes.object,
|
||||
value: PropTypes.object,
|
||||
|
@ -68,8 +71,8 @@ const Calendar = {
|
|||
// onPanelChange: PropTypes.func,
|
||||
disabledDate: PropTypes.func,
|
||||
disabledTime: PropTypes.any,
|
||||
renderFooter: PropTypes.func.def(noop),
|
||||
renderSidebar: PropTypes.func.def(noop),
|
||||
renderFooter: PropTypes.func.def(() => null),
|
||||
renderSidebar: PropTypes.func.def(() => null),
|
||||
},
|
||||
|
||||
mixins: [BaseMixin, CommonMixin, CalendarMixin],
|
||||
|
@ -168,7 +171,8 @@ const Calendar = {
|
|||
onDateTableSelect (value) {
|
||||
const { timePicker, sSelectedValue } = this
|
||||
if (!sSelectedValue && timePicker) {
|
||||
const timePickerDefaultValue = timePicker.props.defaultValue
|
||||
const timePickerProps = getOptionProps(timePicker)
|
||||
const timePickerDefaultValue = timePickerProps.defaultValue
|
||||
if (timePickerDefaultValue) {
|
||||
syncTime(timePickerDefaultValue, value)
|
||||
}
|
||||
|
@ -321,4 +325,4 @@ const Calendar = {
|
|||
}
|
||||
|
||||
export default Calendar
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -7,24 +7,28 @@ import MonthTable from './month/MonthTable'
|
|||
import CalendarMixin from './mixin/CalendarMixin'
|
||||
import CommonMixin from './mixin/CommonMixin'
|
||||
import CalendarHeader from './full-calendar/CalendarHeader'
|
||||
|
||||
import enUs from './locale/en_US'
|
||||
const FullCalendar = {
|
||||
props: {
|
||||
locale: PropTypes.object.def(enUs),
|
||||
visible: PropTypes.bool.def(true),
|
||||
prefixCls: PropTypes.string.def('rc-calendar'),
|
||||
defaultType: PropTypes.string.def('date'),
|
||||
type: PropTypes.string,
|
||||
prefixCls: PropTypes.string,
|
||||
locale: PropTypes.object,
|
||||
// locale: PropTypes.object,
|
||||
// onTypeChange: PropTypes.func,
|
||||
fullscreen: PropTypes.bool.def(false),
|
||||
monthCellRender: PropTypes.func,
|
||||
dateCellRender: PropTypes.func,
|
||||
showTypeSwitch: PropTypes.bool.def(true),
|
||||
Select: PropTypes.func.isRequired,
|
||||
Select: PropTypes.object.isRequired,
|
||||
headerComponents: PropTypes.array,
|
||||
headerComponent: PropTypes.object, // The whole header component
|
||||
headerRender: PropTypes.func,
|
||||
showHeader: PropTypes.bool.def(true),
|
||||
disabledDate: PropTypes.func,
|
||||
renderFooter: PropTypes.func.def(() => null),
|
||||
renderSidebar: PropTypes.func.def(() => null),
|
||||
},
|
||||
mixins: [BaseMixin, CommonMixin, CalendarMixin],
|
||||
data () {
|
||||
|
@ -72,7 +76,7 @@ const FullCalendar = {
|
|||
headerRender,
|
||||
disabledDate,
|
||||
} = props
|
||||
const { sValue: value, sType: type } = this
|
||||
const { sValue: value, sType: type, $listeners } = this
|
||||
|
||||
let header = null
|
||||
if (showHeader) {
|
||||
|
@ -88,6 +92,7 @@ const FullCalendar = {
|
|||
value,
|
||||
},
|
||||
on: {
|
||||
...$listeners,
|
||||
typeChange: this.setType,
|
||||
valueChange: this.setValue,
|
||||
},
|
||||
|
|
|
@ -6,11 +6,18 @@ import CalendarHeader from './calendar/CalendarHeader'
|
|||
import CalendarFooter from './calendar/CalendarFooter'
|
||||
import CalendarMixin from './mixin/CalendarMixin'
|
||||
import CommonMixin from './mixin/CommonMixin'
|
||||
|
||||
import enUs from './locale/en_US'
|
||||
const MonthCalendar = {
|
||||
props: {
|
||||
locale: PropTypes.object.def(enUs),
|
||||
visible: PropTypes.bool.def(true),
|
||||
prefixCls: PropTypes.string.def('rc-calendar'),
|
||||
monthCellRender: PropTypes.func,
|
||||
dateCellRender: PropTypes.func,
|
||||
disabledDate: PropTypes.func,
|
||||
monthCellContentRender: PropTypes.func,
|
||||
renderFooter: PropTypes.func.def(() => null),
|
||||
renderSidebar: PropTypes.func.def(() => null),
|
||||
},
|
||||
mixins: [BaseMixin, CommonMixin, CalendarMixin],
|
||||
|
||||
|
@ -74,25 +81,26 @@ const MonthCalendar = {
|
|||
|
||||
render () {
|
||||
const { mode, sValue: value, $props: props } = this
|
||||
const { prefixCls, locale, disabledDate, monthCellRender, monthCellContentRender, renderFooter } = props
|
||||
const children = (
|
||||
<div class={`${props.prefixCls}-month-calendar-content`}>
|
||||
<div class={`${props.prefixCls}-month-header-wrap`}>
|
||||
<div class={`${prefixCls}-month-calendar-content`}>
|
||||
<div class={`${prefixCls}-month-header-wrap`}>
|
||||
<CalendarHeader
|
||||
prefixCls={props.prefixCls}
|
||||
prefixCls={prefixCls}
|
||||
mode={mode}
|
||||
value={value}
|
||||
locale={props.locale}
|
||||
disabledMonth={props.disabledDate}
|
||||
monthCellRender={props.monthCellRender}
|
||||
monthCellContentRender={props.monthCellContentRender}
|
||||
locale={locale}
|
||||
disabledMonth={disabledDate}
|
||||
monthCellRender={monthCellRender}
|
||||
monthCellContentRender={monthCellContentRender}
|
||||
onMonthSelect={this.onSelect}
|
||||
onValueChange={this.setValue}
|
||||
onPanelChange={this.handlePanelChange}
|
||||
/>
|
||||
</div>
|
||||
<CalendarFooter
|
||||
prefixCls={props.prefixCls}
|
||||
renderFooter={props.renderFooter}
|
||||
prefixCls={prefixCls}
|
||||
renderFooter={renderFooter}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -185,19 +185,23 @@ const Picker = {
|
|||
dropdownClassName,
|
||||
transitionName,
|
||||
} = props
|
||||
const state = this.$data
|
||||
const { sValue, sOpen } = this
|
||||
const children = this.$scopedSlots.default
|
||||
const childrenState = {
|
||||
value: sValue,
|
||||
open: sOpen,
|
||||
}
|
||||
return (<Trigger
|
||||
popupAlign={align}
|
||||
builtinPlacements={placements}
|
||||
popupPlacement={placement}
|
||||
action={(disabled && !state.sOpen) ? [] : ['click']}
|
||||
action={(disabled && !sOpen) ? [] : ['click']}
|
||||
destroyPopupOnHide
|
||||
getPopupContainer={getCalendarContainer}
|
||||
popupStyle={style}
|
||||
popupAnimation={animation}
|
||||
popupTransitionName={transitionName}
|
||||
popupVisible={state.sOpen}
|
||||
popupVisible={sOpen}
|
||||
onPopupVisibleChange={this.onVisibleChange}
|
||||
prefixCls={prefixCls}
|
||||
popupClassName={dropdownClassName}
|
||||
|
@ -205,7 +209,7 @@ const Picker = {
|
|||
<template slot='popup'>
|
||||
{this.getCalendarElement()}
|
||||
</template>
|
||||
{cloneElement(children(state, props), { on: { keydown: this.onKeyDown }})}
|
||||
{cloneElement(children(childrenState, props), { on: { keydown: this.onKeyDown }})}
|
||||
</Trigger>)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<script>
|
||||
import PropTypes from '@/components/_util/vue-types'
|
||||
import BaseMixin from '@/components/_util/BaseMixin'
|
||||
import { getOptionProps, hasProp } from '@/components/_util/props-util'
|
||||
import { getOptionProps, hasProp, mergeProps } from '@/components/_util/props-util'
|
||||
import moment from 'moment'
|
||||
import CalendarPart from './range-calendar/CalendarPart'
|
||||
import TodayButton from './calendar/TodayButton'
|
||||
import OkButton from './calendar/OkButton'
|
||||
import TimePickerButton from './calendar/TimePickerButton'
|
||||
import CommonMixin from './mixin/CommonMixin'
|
||||
import enUs from './locale/en_US'
|
||||
import { syncTime, getTodayTime, isAllowedDate } from './util/'
|
||||
|
||||
function noop () {}
|
||||
|
@ -72,7 +73,9 @@ function onInputSelect (direction, value) {
|
|||
|
||||
const RangeCalendar = {
|
||||
props: {
|
||||
prefixCls: PropTypes.string,
|
||||
locale: PropTypes.object.def(enUs),
|
||||
visible: PropTypes.bool.def(true),
|
||||
prefixCls: PropTypes.string.def('rc-calendar'),
|
||||
dateInputPlaceholder: PropTypes.any,
|
||||
defaultValue: PropTypes.any,
|
||||
value: PropTypes.any,
|
||||
|
@ -84,9 +87,9 @@ const RangeCalendar = {
|
|||
showToday: PropTypes.bool.def(true),
|
||||
defaultSelectedValue: PropTypes.array.def([]),
|
||||
selectedValue: PropTypes.array,
|
||||
onOk: PropTypes.func,
|
||||
showClear: PropTypes.bool,
|
||||
locale: PropTypes.object,
|
||||
showWeekNumber: PropTypes.bool,
|
||||
// locale: PropTypes.object,
|
||||
// onChange: PropTypes.func,
|
||||
// onSelect: PropTypes.func,
|
||||
// onValueChange: PropTypes.func,
|
||||
|
@ -97,6 +100,8 @@ const RangeCalendar = {
|
|||
type: PropTypes.any.def('both'),
|
||||
disabledDate: PropTypes.func,
|
||||
disabledTime: PropTypes.func.def(noop),
|
||||
renderFooter: PropTypes.func.def(() => null),
|
||||
renderSidebar: PropTypes.func.def(() => null),
|
||||
},
|
||||
|
||||
mixins: [BaseMixin, CommonMixin],
|
||||
|
@ -115,26 +120,30 @@ const RangeCalendar = {
|
|||
sMode: props.mode || ['date', 'date'],
|
||||
}
|
||||
},
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
const { state } = this
|
||||
const newState = {}
|
||||
if ('value' in nextProps) {
|
||||
newState.value = normalizeAnchor(nextProps, 0)
|
||||
watch: {
|
||||
value (val) {
|
||||
const newState = {}
|
||||
newState.sValue = normalizeAnchor(val, 0)
|
||||
this.setState(newState)
|
||||
}
|
||||
if ('hoverValue' in nextProps && !isArraysEqual(state.hoverValue, nextProps.hoverValue)) {
|
||||
this.setState({ hoverValue: nextProps.hoverValue })
|
||||
}
|
||||
if ('selectedValue' in nextProps) {
|
||||
newState.selectedValue = nextProps.selectedValue
|
||||
newState.prevSelectedValue = nextProps.selectedValue
|
||||
},
|
||||
hoverValue (val) {
|
||||
if (!isArraysEqual(this.sHoverValue, val)) {
|
||||
this.setState({ sHoverValue: val })
|
||||
}
|
||||
},
|
||||
selectedValue (val) {
|
||||
const newState = {}
|
||||
newState.sSelectedValue = val
|
||||
newState.prevSelectedValue = val
|
||||
this.setState(newState)
|
||||
}
|
||||
if ('mode' in nextProps && !isArraysEqual(state.mode, nextProps.mode)) {
|
||||
this.setState({ mode: nextProps.mode })
|
||||
}
|
||||
},
|
||||
mode (val) {
|
||||
if (!isArraysEqual(this.sMode, val)) {
|
||||
this.setState({ sMode: val })
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
onDatePanelEnter () {
|
||||
if (this.hasSelectedValue()) {
|
||||
|
@ -166,8 +175,7 @@ const RangeCalendar = {
|
|||
} else if (type === 'start') {
|
||||
syncTime(prevSelectedValue[0], value)
|
||||
const endValue = sSelectedValue[1]
|
||||
nextSelectedValue = endValue && this.compare(endValue, value) > 0
|
||||
? [value, endValue] : [value]
|
||||
nextSelectedValue = endValue && this.compare(endValue, value) > 0 ? [value, endValue] : [value]
|
||||
} else { // type === 'end'
|
||||
const startValue = sSelectedValue[0]
|
||||
if (startValue && this.compare(startValue, value) <= 0) {
|
||||
|
@ -275,11 +283,11 @@ const RangeCalendar = {
|
|||
let value = this.sValue[0]
|
||||
const selectedValue = this.sSelectedValue
|
||||
// keep selectedTime when select date
|
||||
if (selectedValue[0] && this.props.timePicker) {
|
||||
if (selectedValue[0] && this.timePicker) {
|
||||
value = value.clone()
|
||||
syncTime(selectedValue[0], value)
|
||||
}
|
||||
if (this.state.showTimePicker && selectedValue[0]) {
|
||||
if (this.showTimePicker && selectedValue[0]) {
|
||||
return selectedValue[0]
|
||||
}
|
||||
return value
|
||||
|
@ -358,14 +366,16 @@ const RangeCalendar = {
|
|||
|
||||
fireSelectValueChange (selectedValue, direct) {
|
||||
const { timePicker, prevSelectedValue } = this
|
||||
console.log('timePicker', timePicker)
|
||||
if (timePicker && timePicker.props.defaultValue) {
|
||||
const timePickerDefaultValue = timePicker.props.defaultValue
|
||||
if (!prevSelectedValue[0] && selectedValue[0]) {
|
||||
syncTime(timePickerDefaultValue[0], selectedValue[0])
|
||||
}
|
||||
if (!prevSelectedValue[1] && selectedValue[1]) {
|
||||
syncTime(timePickerDefaultValue[1], selectedValue[1])
|
||||
if (timePicker) {
|
||||
const timePickerProps = getOptionProps(timePicker)
|
||||
if (timePickerProps.defaultValue) {
|
||||
const timePickerDefaultValue = timePickerProps.defaultValue
|
||||
if (!prevSelectedValue[0] && selectedValue[0]) {
|
||||
syncTime(timePickerDefaultValue[0], selectedValue[0])
|
||||
}
|
||||
if (!prevSelectedValue[1] && selectedValue[1]) {
|
||||
syncTime(timePickerDefaultValue[1], selectedValue[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +484,7 @@ const RangeCalendar = {
|
|||
select: this.onSelect,
|
||||
dayHover: type === 'start' && sSelectedValue[1] ||
|
||||
type === 'end' && sSelectedValue[0] || !!sHoverValue.length
|
||||
? this.onDayHover : undefined,
|
||||
? this.onDayHover : noop,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -506,6 +516,94 @@ const RangeCalendar = {
|
|||
const nextMonthOfStart = startValue.clone().add(1, 'months')
|
||||
const isClosestMonths = nextMonthOfStart.year() === endValue.year() &&
|
||||
nextMonthOfStart.month() === endValue.month()
|
||||
const leftPartProps = mergeProps(baseProps, newProps, {
|
||||
props: {
|
||||
hoverValue: sHoverValue,
|
||||
direction: 'left',
|
||||
disabledTime: this.disabledStartTime,
|
||||
disabledMonth: this.disabledStartMonth,
|
||||
format: this.getFormat(),
|
||||
value: startValue,
|
||||
mode: sMode[0],
|
||||
placeholder: placeholder1,
|
||||
showDateInput: this.showDateInput,
|
||||
timePicker: timePicker,
|
||||
showTimePicker: showTimePicker,
|
||||
enablePrev: true,
|
||||
enableNext: !isClosestMonths || this.isMonthYearPanelShow(sMode[1]),
|
||||
},
|
||||
on: {
|
||||
inputSelect: this.onStartInputSelect,
|
||||
valueChange: this.onStartValueChange,
|
||||
panelChange: this.onStartPanelChange,
|
||||
},
|
||||
})
|
||||
const rightPartProps = mergeProps(baseProps, newProps, {
|
||||
props: {
|
||||
hoverValue: sHoverValue,
|
||||
direction: 'right',
|
||||
format: this.getFormat(),
|
||||
timePickerDisabledTime: this.getEndDisableTime(),
|
||||
placeholder: placeholder2,
|
||||
value: endValue,
|
||||
mode: sMode[1],
|
||||
showDateInput: this.showDateInput,
|
||||
timePicker: timePicker,
|
||||
showTimePicker: showTimePicker,
|
||||
disabledTime: this.disabledEndTime,
|
||||
disabledMonth: this.disabledEndMonth,
|
||||
enablePrev: !isClosestMonths || this.isMonthYearPanelShow(sMode[0]),
|
||||
enableNext: true,
|
||||
},
|
||||
on: {
|
||||
inputSelect: this.onEndInputSelect,
|
||||
valueChange: this.onEndValueChange,
|
||||
panelChange: this.onEndPanelChange,
|
||||
},
|
||||
})
|
||||
let TodayButtonNode = null
|
||||
if (showToday) {
|
||||
const todayButtonProps = mergeProps(baseProps, {
|
||||
props: {
|
||||
disabled: isTodayInView,
|
||||
value: sValue[0],
|
||||
text: locale.backToToday,
|
||||
},
|
||||
on: {
|
||||
today: this.onToday,
|
||||
},
|
||||
})
|
||||
TodayButtonNode = <TodayButton {...todayButtonProps}/>
|
||||
}
|
||||
|
||||
let TimePickerButtonNode = null
|
||||
if (props.timePicker) {
|
||||
const timePickerButtonProps = mergeProps(baseProps, {
|
||||
props: {
|
||||
showTimePicker: showTimePicker,
|
||||
timePickerDisabled: !this.hasSelectedValue() || sHoverValue.length,
|
||||
},
|
||||
on: {
|
||||
openTimePicker: this.onOpenTimePicker,
|
||||
closeTimePicker: this.onCloseTimePicker,
|
||||
},
|
||||
})
|
||||
TimePickerButtonNode = <TimePickerButton {...timePickerButtonProps} />
|
||||
}
|
||||
|
||||
let OkButtonNode = null
|
||||
if (showOkButton) {
|
||||
const okButtonProps = mergeProps(baseProps, {
|
||||
props: {
|
||||
okDisabled: !this.isAllowedDateAndTime(sSelectedValue) || !this.hasSelectedValue() || sHoverValue.length,
|
||||
},
|
||||
on: {
|
||||
ok: this.onOk,
|
||||
},
|
||||
})
|
||||
OkButtonNode = <OkButton {...okButtonProps}/>
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={this.saveRoot}
|
||||
|
@ -526,78 +624,17 @@ const RangeCalendar = {
|
|||
onMouseleave={type !== 'both' ? this.onDatePanelLeave : noop}
|
||||
onMouseenter={type !== 'both' ? this.onDatePanelEnter : noop}
|
||||
>
|
||||
<CalendarPart
|
||||
{...baseProps}
|
||||
{...newProps}
|
||||
hoverValue={sHoverValue}
|
||||
direction='left'
|
||||
disabledTime={this.disabledStartTime}
|
||||
disabledMonth={this.disabledStartMonth}
|
||||
format={this.getFormat()}
|
||||
value={startValue}
|
||||
mode={sMode[0]}
|
||||
placeholder={placeholder1}
|
||||
onInputSelect={this.onStartInputSelect}
|
||||
onValueChange={this.onStartValueChange}
|
||||
onPanelChange={this.onStartPanelChange}
|
||||
showDateInput={this.props.showDateInput}
|
||||
timePicker={timePicker}
|
||||
showTimePicker={showTimePicker}
|
||||
enablePrev
|
||||
enableNext={!isClosestMonths || this.isMonthYearPanelShow(sMode[1])}
|
||||
/>
|
||||
<CalendarPart {...leftPartProps}/>
|
||||
<span class={`${prefixCls}-range-middle`}>~</span>
|
||||
<CalendarPart
|
||||
{...baseProps}
|
||||
{...newProps}
|
||||
hoverValue={sHoverValue}
|
||||
direction='right'
|
||||
format={this.getFormat()}
|
||||
timePickerDisabledTime={this.getEndDisableTime()}
|
||||
placeholder={placeholder2}
|
||||
value={endValue}
|
||||
mode={sMode[1]}
|
||||
onInputSelect={this.onEndInputSelect}
|
||||
onValueChange={this.onEndValueChange}
|
||||
onPanelChange={this.onEndPanelChange}
|
||||
showDateInput={this.props.showDateInput}
|
||||
timePicker={timePicker}
|
||||
showTimePicker={showTimePicker}
|
||||
disabledTime={this.disabledEndTime}
|
||||
disabledMonth={this.disabledEndMonth}
|
||||
enablePrev={!isClosestMonths || this.isMonthYearPanelShow(sMode[0])}
|
||||
enableNext
|
||||
/>
|
||||
<CalendarPart {...rightPartProps}/>
|
||||
</div>
|
||||
<div class={cls}>
|
||||
{props.renderFooter()}
|
||||
{showToday || props.timePicker || showOkButton ? (
|
||||
<div class={`${prefixCls}-footer-btn`}>
|
||||
{showToday ? (
|
||||
<TodayButton
|
||||
{...baseProps}
|
||||
disabled={isTodayInView}
|
||||
value={sValue[0]}
|
||||
onToday={this.onToday}
|
||||
text={locale.backToToday}
|
||||
/>
|
||||
) : null}
|
||||
{props.timePicker
|
||||
? <TimePickerButton
|
||||
{...baseProps}
|
||||
showTimePicker={showTimePicker}
|
||||
onOpenTimePicker={this.onOpenTimePicker}
|
||||
onCloseTimePicker={this.onCloseTimePicker}
|
||||
timePickerDisabled={!this.hasSelectedValue() || sHoverValue.length}
|
||||
/> : null}
|
||||
{showOkButton
|
||||
? <OkButton
|
||||
{...baseProps}
|
||||
onOk={this.onOk}
|
||||
okDisabled={!this.isAllowedDateAndTime(sSelectedValue) ||
|
||||
!this.hasSelectedValue() || sHoverValue.length
|
||||
}
|
||||
/> : null}
|
||||
{TodayButtonNode}
|
||||
{TimePickerButtonNode}
|
||||
{OkButtonNode}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
import PropTypes from '@/components/_util/vue-types'
|
||||
import BaseMixin from '@/components/_util/BaseMixin'
|
||||
import { getOptionProps } from '@/components/_util/props-util'
|
||||
import TodayButton from '../calendar/TodayButton'
|
||||
import OkButton from '../calendar/OkButton'
|
||||
import TimePickerButton from '../calendar/TimePickerButton'
|
||||
import TodayButton from './TodayButton'
|
||||
import OkButton from './OkButton'
|
||||
import TimePickerButton from './TimePickerButton'
|
||||
|
||||
const CalendarFooter = {
|
||||
mixins: [BaseMixin],
|
||||
|
@ -20,7 +20,7 @@ const CalendarFooter = {
|
|||
renderFooter: PropTypes.func,
|
||||
defaultValue: PropTypes.object,
|
||||
locale: PropTypes.object,
|
||||
showToday: PropTypes.bool.def(true),
|
||||
showToday: PropTypes.bool,
|
||||
disabledDate: PropTypes.func,
|
||||
showTimePicker: PropTypes.bool,
|
||||
okDisabled: PropTypes.bool,
|
||||
|
@ -49,7 +49,6 @@ const CalendarFooter = {
|
|||
},
|
||||
on: $listeners,
|
||||
}
|
||||
console.log(props)
|
||||
let nowEl = null
|
||||
if (showToday) {
|
||||
nowEl = <TodayButton {...btnProps} />
|
||||
|
@ -72,7 +71,7 @@ const CalendarFooter = {
|
|||
}
|
||||
const cls = {
|
||||
[`${prefixCls}-footer`]: true,
|
||||
[`${prefixCls}-footer-show-ok`]: okBtn,
|
||||
[`${prefixCls}-footer-show-ok`]: !!okBtn,
|
||||
}
|
||||
footerEl = (
|
||||
<div class={cls}>
|
||||
|
|
|
@ -34,6 +34,7 @@ const CalendarHeader = {
|
|||
enablePrev: PropTypes.any.def(1),
|
||||
enableNext: PropTypes.any.def(1),
|
||||
disabledMonth: PropTypes.func,
|
||||
mode: PropTypes.any,
|
||||
},
|
||||
data () {
|
||||
this.nextMonth = goMonth.bind(this, 1)
|
||||
|
@ -47,7 +48,9 @@ const CalendarHeader = {
|
|||
methods: {
|
||||
onMonthSelect (value) {
|
||||
this.__emit('panelChange', value, 'date')
|
||||
if (this.__emit('monthSelect', value)) {
|
||||
if (this.$listeners.monthSelect) {
|
||||
this.__emit('monthSelect', value)
|
||||
} else {
|
||||
this.__emit('valueChange', value)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,21 +2,19 @@
|
|||
function noop () {}
|
||||
export default {
|
||||
functional: true,
|
||||
render: function (createElement, context) {
|
||||
const { data, listeners = {}} = context
|
||||
const { prefixCls, locale, okDisabled } = data
|
||||
render (createElement, context) {
|
||||
const { props, listeners = {}} = context
|
||||
const { prefixCls, locale, okDisabled } = props
|
||||
const { ok = noop } = listeners
|
||||
let className = `${prefixCls}-ok-btn`
|
||||
if (okDisabled) {
|
||||
className += ` ${prefixCls}-ok-btn-disabled`
|
||||
}
|
||||
return (<a
|
||||
class={className}
|
||||
role='button'
|
||||
onClick={okDisabled ? noop : ok}
|
||||
>
|
||||
{locale.ok}
|
||||
</a>)
|
||||
return (
|
||||
<a class={className} role='button' onClick={okDisabled ? noop : ok}>
|
||||
{locale.ok}
|
||||
</a>
|
||||
)
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
function noop () {}
|
||||
export default {
|
||||
functional: true,
|
||||
render: function (h, context) {
|
||||
render (h, context) {
|
||||
const { props, listeners = {}} = context
|
||||
console.log(context)
|
||||
const {
|
||||
prefixCls, locale, showTimePicker,
|
||||
timePickerDisabled } = props
|
||||
|
|
|
@ -23,7 +23,7 @@ const DateInput = {
|
|||
data () {
|
||||
const selectedValue = this.selectedValue
|
||||
return {
|
||||
str: selectedValue && selectedValue.format(this.props.format) || '',
|
||||
str: selectedValue && selectedValue.format(this.format) || '',
|
||||
invalid: false,
|
||||
}
|
||||
},
|
||||
|
@ -45,7 +45,6 @@ const DateInput = {
|
|||
},
|
||||
methods: {
|
||||
updateState () {
|
||||
console.log('关注下')
|
||||
this.cachedSelectionStart = this.$refs.dateInputInstance.selectionStart
|
||||
this.cachedSelectionEnd = this.$refs.dateInputInstance.selectionEnd
|
||||
// when popup show, click body will call this, bug!
|
||||
|
@ -131,7 +130,7 @@ const DateInput = {
|
|||
value={str}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
onChange={this.onInputChange}
|
||||
onInput={this.onInputChange}
|
||||
/>
|
||||
</div>
|
||||
{showClear ? <a
|
||||
|
|
|
@ -48,7 +48,6 @@ const DateTBody = {
|
|||
showWeekNumber, dateRender, disabledDate,
|
||||
hoverValue,
|
||||
} = props
|
||||
console.log('selectedValue', selectedValue)
|
||||
const { $listeners = {}} = this
|
||||
const { select = noop, dayHover = noop } = $listeners
|
||||
let iIndex
|
||||
|
@ -100,7 +99,7 @@ const DateTBody = {
|
|||
if (showWeekNumber) {
|
||||
weekNumberCell = (
|
||||
<td
|
||||
key={dateTable[passed].week()}
|
||||
key={`week-${dateTable[passed].week()}`}
|
||||
role='gridcell'
|
||||
class={weekNumberCellClass}
|
||||
>
|
||||
|
@ -212,8 +211,7 @@ const DateTBody = {
|
|||
<td
|
||||
key={passed}
|
||||
onClick={disabled ? noop : select.bind(null, current)}
|
||||
onMouseenter={disabled
|
||||
? noop : dayHover.bind(null, current)}
|
||||
onMouseenter={disabled ? noop : dayHover.bind(null, current)}
|
||||
role='gridcell'
|
||||
title={getTitleString(current)} class={cls}
|
||||
>
|
||||
|
|
|
@ -5,7 +5,7 @@ import moment from 'moment'
|
|||
export default {
|
||||
functional: true,
|
||||
render (createElement, context) {
|
||||
const { data: props } = context
|
||||
const { props } = context
|
||||
const value = props.value
|
||||
const localeData = value.localeData()
|
||||
const prefixCls = props.prefixCls
|
||||
|
@ -51,4 +51,4 @@ export default {
|
|||
</thead>)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -11,8 +11,8 @@ export default {
|
|||
props,
|
||||
on: listeners,
|
||||
}
|
||||
return (<table class = {`${prefixCls}-table`} cellSpacing='0' role='grid'>
|
||||
<DateTHead {...props}/>
|
||||
return (<table class={`${prefixCls}-table`} cellSpacing='0' role='grid'>
|
||||
<DateTHead {...bodyProps}/>
|
||||
<DateTBody {...bodyProps}/>
|
||||
</table>)
|
||||
},
|
||||
|
|
|
@ -29,10 +29,9 @@ export default {
|
|||
rootPrefixCls: PropTypes.string,
|
||||
},
|
||||
data () {
|
||||
this.prefixCls = `${this.rootPrefixCls}-decade-panel`
|
||||
this.nextCentury = goYear.bind(this, 100)
|
||||
this.previousCentury = goYear.bind(this, -100)
|
||||
this.state = {
|
||||
return {
|
||||
sValue: this.value || this.defaultValue,
|
||||
}
|
||||
},
|
||||
|
@ -46,7 +45,7 @@ export default {
|
|||
const endYear = startYear + 99
|
||||
const decades = []
|
||||
let index = 0
|
||||
const prefixCls = this.prefixCls
|
||||
const prefixCls = `${this.rootPrefixCls}-decade-panel`
|
||||
|
||||
for (let rowIndex = 0; rowIndex < ROW; rowIndex++) {
|
||||
decades[rowIndex] = []
|
||||
|
@ -99,7 +98,7 @@ export default {
|
|||
})
|
||||
|
||||
return (
|
||||
<div class={this.prefixCls}>
|
||||
<div class={prefixCls}>
|
||||
<div class={`${prefixCls}-header`}>
|
||||
<a
|
||||
class={`${prefixCls}-prev-century-btn`}
|
||||
|
|
|
@ -12,7 +12,7 @@ const CalendarHeader = {
|
|||
yearSelectTotal: PropTypes.number.def(20),
|
||||
// onValueChange: PropTypes.func,
|
||||
// onTypeChange: PropTypes.func,
|
||||
Select: PropTypes.func,
|
||||
Select: PropTypes.object,
|
||||
prefixCls: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
showTypeSwitch: PropTypes.bool,
|
||||
|
|
|
@ -3,7 +3,7 @@ import BaseMixin from '@/components/_util/BaseMixin'
|
|||
import { hasProp } from '@/components/_util/props-util'
|
||||
import moment from 'moment'
|
||||
import { isAllowedDate, getTodayTime } from '../util/index'
|
||||
|
||||
function noop () {}
|
||||
function getNow () {
|
||||
return moment()
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ const CalendarMixin = {
|
|||
ref='rootInstance'
|
||||
class={className}
|
||||
tabIndex='0'
|
||||
onKeydown={this.onKeyDown}
|
||||
onKeydown={this.onKeyDown || noop}
|
||||
>
|
||||
{newProps.children}
|
||||
</div>
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
import PropTypes from '@/components/_util/vue-types'
|
||||
import enUs from '../locale/en_US'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
locale: PropTypes.object.def(enUs),
|
||||
visible: PropTypes.bool.def(true),
|
||||
// onSelect: PropTypes.func,
|
||||
prefixCls: PropTypes.string.def('rc-calendar'),
|
||||
// onChange: PropTypes.func,
|
||||
// onOk: PropTypes.func,
|
||||
},
|
||||
|
||||
// getDefaultProps () {
|
||||
// return {
|
||||
// locale: enUs,
|
||||
|
|
|
@ -17,6 +17,12 @@ function noop () {
|
|||
const MonthPanel = {
|
||||
mixins: [BaseMixin],
|
||||
props: {
|
||||
value: PropTypes.any,
|
||||
defaultValue: PropTypes.any,
|
||||
cellRender: PropTypes.any,
|
||||
contentRender: PropTypes.any,
|
||||
locale: PropTypes.any,
|
||||
rootPrefixCls: PropTypes.string,
|
||||
// onChange: PropTypes.func,
|
||||
disabledDate: PropTypes.func,
|
||||
// onSelect: PropTypes.func,
|
||||
|
|
|
@ -22,6 +22,9 @@ const MonthTable = {
|
|||
cellRender: PropTypes.func,
|
||||
prefixCls: PropTypes.string,
|
||||
value: PropTypes.object,
|
||||
locale: PropTypes.any,
|
||||
contentRender: PropTypes.any,
|
||||
disabledDate: PropTypes.func,
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -71,14 +74,14 @@ const MonthTable = {
|
|||
const today = getTodayTime(value)
|
||||
const months = this.months()
|
||||
const currentMonth = value.month()
|
||||
const { prefixCls, locale, contentRender, cellRender } = props
|
||||
const { prefixCls, locale, contentRender, cellRender, disabledDate } = props
|
||||
const monthsEls = months.map((month, index) => {
|
||||
const tds = month.map(monthData => {
|
||||
let disabled = false
|
||||
if (props.disabledDate) {
|
||||
if (disabledDate) {
|
||||
const testValue = value.clone()
|
||||
testValue.month(monthData.value)
|
||||
disabled = props.disabledDate(testValue)
|
||||
disabled = disabledDate(testValue)
|
||||
}
|
||||
const classNameMap = {
|
||||
[`${prefixCls}-cell`]: 1,
|
||||
|
|
|
@ -19,6 +19,7 @@ const CalendarPart = {
|
|||
locale: PropTypes.any,
|
||||
showDateInput: PropTypes.bool,
|
||||
showTimePicker: PropTypes.bool,
|
||||
showWeekNumber: PropTypes.bool,
|
||||
format: PropTypes.any,
|
||||
placeholder: PropTypes.any,
|
||||
disabledDate: PropTypes.any,
|
||||
|
@ -62,7 +63,6 @@ const CalendarPart = {
|
|||
}
|
||||
const index = direction === 'left' ? 0 : 1
|
||||
const timePickerProps = getOptionProps(timePicker)
|
||||
console.log('timePickerProps', timePickerProps)
|
||||
const timePickerEle = shouldShowTimePicker &&
|
||||
cloneElement(timePicker, {
|
||||
props: {
|
||||
|
@ -141,4 +141,4 @@ const CalendarPart = {
|
|||
}
|
||||
|
||||
export default CalendarPart
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -25,6 +25,7 @@ export default {
|
|||
rootPrefixCls: PropTypes.string,
|
||||
value: PropTypes.object,
|
||||
defaultValue: PropTypes.object,
|
||||
locale: PropTypes.object,
|
||||
},
|
||||
data () {
|
||||
this.nextDecade = goYear.bind(this, 10)
|
||||
|
@ -59,9 +60,8 @@ export default {
|
|||
},
|
||||
|
||||
render () {
|
||||
const props = this.$props
|
||||
const value = this.sValue
|
||||
const locale = props.locale
|
||||
const { sValue: value, locale, $listeners = {}} = this
|
||||
const decadePanelShow = $listeners.decadePanelShow || noop
|
||||
const years = this.years()
|
||||
const currentYear = value.year()
|
||||
const startYear = parseInt(currentYear / 10, 10) * 10
|
||||
|
@ -103,7 +103,7 @@ export default {
|
|||
})
|
||||
|
||||
return (
|
||||
<div class={this.prefixCls}>
|
||||
<div class={prefixCls}>
|
||||
<div>
|
||||
<div class={`${prefixCls}-header`}>
|
||||
<a
|
||||
|
@ -115,7 +115,7 @@ export default {
|
|||
<a
|
||||
class={`${prefixCls}-decade-select`}
|
||||
role='button'
|
||||
onClick={props.onDecadePanelShow}
|
||||
onClick={decadePanelShow}
|
||||
title={locale.decadeSelect}
|
||||
>
|
||||
<span class={`${prefixCls}-decade-select-content`}>
|
||||
|
|
|
@ -112,7 +112,7 @@ export default {
|
|||
<input
|
||||
type='text'
|
||||
value={this.goInputText}
|
||||
onChange={this.handleChange}
|
||||
onInput={this.handleChange}
|
||||
onKeyup={this.go}
|
||||
/>
|
||||
{locale.page}
|
||||
|
|
|
@ -301,7 +301,7 @@ export default {
|
|||
value={this.stateCurrentInputValue}
|
||||
onKeydown={this.handleKeyDown}
|
||||
onKeyup={this.handleKeyUp}
|
||||
onChange={this.handleKeyUp}
|
||||
onInput={this.handleKeyUp}
|
||||
size='3'
|
||||
/>
|
||||
<span class={`${prefixCls}-slash`}>/</span>
|
||||
|
|
|
@ -29,6 +29,7 @@ const Panel = {
|
|||
},
|
||||
},
|
||||
value: PropTypes.object,
|
||||
defaultValue: PropTypes.object,
|
||||
placeholder: PropTypes.string,
|
||||
format: PropTypes.string,
|
||||
inputReadOnly: PropTypes.bool.def(false),
|
||||
|
|
|
@ -288,7 +288,6 @@ export default {
|
|||
onFocus={onFocus}
|
||||
onBlur={onBlur}
|
||||
autoFocus={autoFocus}
|
||||
onChange={noop}
|
||||
readOnly={!!inputReadOnly}
|
||||
/>
|
||||
<span class={`${prefixCls}-icon`}/>
|
||||
|
|
Loading…
Reference in New Issue