diff --git a/components/vc-form/index.js b/components/vc-form/index.js index 160f2c58b..dda23d5a4 100644 --- a/components/vc-form/index.js +++ b/components/vc-form/index.js @@ -1,3 +1,3 @@ -// based on rc-form 2.2.6 +// based on rc-form 2.4.0 import { createForm, createFormField } from './src/' export { createForm, createFormField } diff --git a/components/vc-input-number/src/index.js b/components/vc-input-number/src/index.js index e4ffdcb35..524e5be28 100755 --- a/components/vc-input-number/src/index.js +++ b/components/vc-input-number/src/index.js @@ -1,4 +1,4 @@ -// based on rc-input-number 4.3.1 +// based on rc-input-number 4.3.7 import PropTypes from '../../_util/vue-types' import BaseMixin from '../../_util/BaseMixin' import { initDefaultProps, hasProp, getOptionProps } from '../../_util/props-util' @@ -73,6 +73,8 @@ const inputNumberProps = { required: PropTypes.bool, pattern: PropTypes.string, decimalSeparator: PropTypes.string, + autoComplete: PropTypes.string, + title: PropTypes.string, } export default { @@ -90,6 +92,7 @@ export default { step: 1, parser: defaultParser, required: false, + autoComplete: 'off', }), data () { let value @@ -274,7 +277,7 @@ export default { let val = value if (val === '') { val = '' - } else if (!this.isNotCompleteNumber(val)) { + } else if (!this.isNotCompleteNumber(parseFloat(val, 10))) { val = this.getValidValue(val) } else { val = this.sValue @@ -583,7 +586,8 @@ export default { }, }, render () { - const { prefixCls, disabled, readOnly, useTouch } = this.$props + const { prefixCls, disabled, readOnly, useTouch, autoComplete, + upHandler, downHandler } = this.$props const classes = classNames({ [prefixCls]: true, [`${prefixCls}-disabled`]: disabled, @@ -657,6 +661,7 @@ export default { const contentProps = { on: { mouseenter, mouseleave, mouseover, mouseout }, class: classes, + attrs: { title: this.$props.title }, } const upHandlerProps = { props: { @@ -697,7 +702,7 @@ export default { - {this.upHandler || - {this.downHandler ||
{$slots.default}
{closable diff --git a/components/vc-notification/Notification.jsx b/components/vc-notification/Notification.jsx index 6352044bd..bfffeed93 100644 --- a/components/vc-notification/Notification.jsx +++ b/components/vc-notification/Notification.jsx @@ -7,6 +7,9 @@ import createChainedFunction from '../_util/createChainedFunction' import getTransitionProps from '../_util/getTransitionProps' import Notice from './Notice' +function noop () { +} + let seed = 0 const now = Date.now() @@ -91,6 +94,7 @@ const Notification = { }, on: { close, + click: notice.onClick || noop, }, style, class: className, diff --git a/components/vc-notification/demo/simple.jsx b/components/vc-notification/demo/simple.jsx index 0f3036fd0..9f64ba175 100644 --- a/components/vc-notification/demo/simple.jsx +++ b/components/vc-notification/demo/simple.jsx @@ -35,6 +35,9 @@ function closableFn () { onClose () { console.log('closable close') }, + onClick () { + console.log('clicked!!!') + }, closable: true, }) } diff --git a/components/vc-notification/index.js b/components/vc-notification/index.js index a30798b2a..c90aca1bd 100644 --- a/components/vc-notification/index.js +++ b/components/vc-notification/index.js @@ -1,3 +1,3 @@ -// based on rc-notification 3.2.0 +// based on rc-notification 3.3.0 import Notification from './Notification' export default Notification diff --git a/components/vc-pagination/Pager.jsx b/components/vc-pagination/Pager.jsx index e8903871b..bda79157f 100644 --- a/components/vc-pagination/Pager.jsx +++ b/components/vc-pagination/Pager.jsx @@ -42,6 +42,10 @@ export default { cls = `${cls} ${prefixCls}-active` } + if (!page) { + cls = `${cls} ${prefixCls}-disabled` + } + return (
  • newCurrent ? newCurrent : current if (!hasProp(this, 'current')) { newState.stateCurrent = current @@ -112,42 +120,30 @@ export default { }, }, methods: { - isValid (page) { - return isInteger(page) && page >= 1 && page !== this.stateCurrent + getJumpPrevPage () { + return Math.max(1, this.stateCurrent - (this.showLessItems ? 3 : 5)) + }, + getJumpNextPage () { + return Math.min( + calculatePage(undefined, this.$data, this.$props), + this.stateCurrent + (this.showLessItems ? 3 : 5) + ) }, getItemIcon (icon) { const { prefixCls } = this.$props const iconNode = getComponentFromProp(this, icon, this.$props) || return iconNode }, - calculatePage (p) { - let pageSize = p - if (typeof pageSize === 'undefined') { - pageSize = this.statePageSize - } - return Math.floor((this.total - 1) / pageSize) + 1 - }, - handleGoTO (event) { - if (event.keyCode === KEYCODE.ENTER || event.type === 'click') { - this.handleChange(this.stateCurrentInputValue) - } - }, - prev () { - if (this.hasPrev()) { - this.handleChange(this.stateCurrent - 1) - } - }, - next () { - if (this.hasNext()) { - this.handleChange(this.stateCurrent + 1) - } - }, - hasPrev () { - return this.stateCurrent > 1 - }, - hasNext () { - return this.stateCurrent < this.calculatePage() + isValid (page) { + return isInteger(page) && page >= 1 && page !== this.stateCurrent }, + // calculatePage (p) { + // let pageSize = p + // if (typeof pageSize === 'undefined') { + // pageSize = this.statePageSize + // } + // return Math.floor((this.total - 1) / pageSize) + 1 + // }, handleKeyDown (event) { if (event.keyCode === KEYCODE.ARROW_UP || event.keyCode === KEYCODE.ARROW_DOWN) { event.preventDefault() @@ -183,7 +179,7 @@ export default { changePageSize (size) { let current = this.stateCurrent const preCurrent = current - const newCurrent = this.calculatePage(size) + const newCurrent = calculatePage(size, this.$data, this.$props) current = current > newCurrent ? newCurrent : current // fix the issue: // Once 'total' is 0, 'current' in 'onShowSizeChange' is 0, which is not correct. @@ -212,9 +208,9 @@ export default { handleChange (p) { let page = p if (this.isValid(page)) { - const allTotal = this.calculatePage() - if (page > allTotal) { - page = allTotal + const currentPage = calculatePage(undefined, this.$data, this.$props) + if (page > currentPage) { + page = currentPage } if (!hasProp(this, 'current')) { this.setState({ @@ -229,6 +225,28 @@ export default { } return this.stateCurrent }, + prev () { + if (this.hasPrev()) { + this.handleChange(this.stateCurrent - 1) + } + }, + next () { + if (this.hasNext()) { + this.handleChange(this.stateCurrent + 1) + } + }, + jumpPrev () { + this.handleChange(this.getJumpPrevPage()) + }, + jumpNext () { + this.handleChange(this.getJumpNextPage()) + }, + hasPrev () { + return this.stateCurrent > 1 + }, + hasNext () { + return this.stateCurrent < calculatePage(undefined, this.$data, this.$props) + }, runIfEnter (event, callback, ...restParams) { if (event.key === 'Enter' || event.charCode === 13) { callback(...restParams) @@ -246,17 +264,10 @@ export default { runIfEnterJumpNext (event) { this.runIfEnter(event, this.jumpNext) }, - getJumpPrevPage () { - return Math.max(1, this.stateCurrent - (this.showLessItems ? 3 : 5)) - }, - getJumpNextPage () { - return Math.min(this.calculatePage(), this.stateCurrent + (this.showLessItems ? 3 : 5)) - }, - jumpPrev () { - this.handleChange(this.getJumpPrevPage()) - }, - jumpNext () { - this.handleChange(this.getJumpNextPage()) + handleGoTO (event) { + if (event.keyCode === KEYCODE.ENTER || event.type === 'click') { + this.handleChange(this.stateCurrentInputValue) + } }, }, render () { @@ -268,7 +279,7 @@ export default { const locale = this.locale const prefixCls = this.prefixCls - const allPages = this.calculatePage() + const allPages = calculatePage(undefined, this.$data, this.$props) const pagerList = [] let jumpPrev = null let jumpNext = null @@ -354,19 +365,36 @@ export default { ) } if (allPages <= 5 + pageBufferSize * 2) { + const pagerProps = { + props: { + locale, + rootPrefixCls: prefixCls, + showTitle: props.showTitle, + itemRender: props.itemRender, + }, + on: { + click: this.handleChange, + keypress: this.runIfEnter, + }, + } + if (!allPages) { + pagerList.push( + + ) + } for (let i = 1; i <= allPages; i++) { const active = stateCurrent === i pagerList.push( ) } @@ -530,8 +558,8 @@ export default {
  • ) } - const prevDisabled = !this.hasPrev() - const nextDisabled = !this.hasNext() + const prevDisabled = !this.hasPrev() || !allPages + const nextDisabled = !this.hasNext() || !allPages const buildOptionText = this.buildOptionText || this.$scopedSlots.buildOptionText return (