diff --git a/components/locale-provider/LocaleReceiver.jsx b/components/locale-provider/LocaleReceiver.jsx index ea68373fd3..843417348e 100644 --- a/components/locale-provider/LocaleReceiver.jsx +++ b/components/locale-provider/LocaleReceiver.jsx @@ -41,6 +41,6 @@ export default { const { $slots } = this; const children = this.children || $slots.default; const { antLocale } = this.localeData; - return children(this.getLocale(), this.getLocaleCode(), antLocale); + return children?.(this.getLocale(), this.getLocaleCode(), antLocale); }, }; diff --git a/components/pagination/MiniSelect.jsx b/components/pagination/MiniSelect.jsx index 568768719d..80e63b66e0 100644 --- a/components/pagination/MiniSelect.jsx +++ b/components/pagination/MiniSelect.jsx @@ -1,7 +1,8 @@ import VcSelect, { SelectProps } from '../select'; -import { getOptionProps, filterEmpty, getListeners } from '../_util/props-util'; +import { getOptionProps, getSlot } from '../_util/props-util'; export default { + inheritAttrs: false, props: { ...SelectProps, }, @@ -9,12 +10,10 @@ export default { render() { const selectOptionsProps = getOptionProps(this); const selelctProps = { - props: { - ...selectOptionsProps, - size: 'small', - }, - on: getListeners(this), + ...selectOptionsProps, + size: 'small', + ...this.$attrs, }; - return {filterEmpty(this.$slots.default)}; + return {getSlot(this)}; }, }; diff --git a/components/pagination/Pagination.jsx b/components/pagination/Pagination.jsx index 8029c3715f..58dd57a62b 100644 --- a/components/pagination/Pagination.jsx +++ b/components/pagination/Pagination.jsx @@ -2,7 +2,7 @@ import PropTypes from '../_util/vue-types'; import VcSelect from '../select'; import MiniSelect from './MiniSelect'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; -import { getOptionProps, getListeners } from '../_util/props-util'; +import { getOptionProps } from '../_util/props-util'; import VcPagination from '../vc-pagination'; import enUS from '../vc-pagination/locale/en_US'; import LeftOutlined from '@ant-design/icons-vue/LeftOutlined'; @@ -10,6 +10,8 @@ import RightOutlined from '@ant-design/icons-vue/RightOutlined'; import DoubleLeftOutlined from '@ant-design/icons-vue/DoubleLeftOutlined'; import DoubleRightOutlined from '@ant-design/icons-vue/DoubleRightOutlined'; import { ConfigConsumerProps } from '../config-provider'; +import { inject } from 'vue'; +import classNames from 'classnames'; export const PaginationProps = () => ({ total: PropTypes.number, @@ -42,26 +44,27 @@ export const PaginationConfig = () => ({ export default { name: 'APagination', - model: { - prop: 'current', - event: 'change.current', - }, + inheritAttrs: false, props: { ...PaginationProps(), }, - inject: { - configProvider: { default: () => ConfigConsumerProps }, + + setup() { + return { + configProvider: inject('configProvider', ConfigConsumerProps), + }; }, + methods: { getIconsProps(prefixCls) { const prevIcon = ( - + ); const nextIcon = ( - + ); const jumpPrevIcon = ( @@ -104,19 +107,15 @@ export default { const isSmall = size === 'small'; const paginationProps = { - props: { - prefixCls, - selectPrefixCls, - ...restProps, - ...this.getIconsProps(prefixCls), - selectComponentClass: isSmall ? MiniSelect : VcSelect, - locale: { ...contextLocale, ...customLocale }, - buildOptionText: buildOptionText || this.$scopedSlots.buildOptionText, - }, - class: { - mini: isSmall, - }, - on: getListeners(this), + prefixCls, + selectPrefixCls, + ...restProps, + ...this.getIconsProps(prefixCls), + selectComponentClass: isSmall ? MiniSelect : VcSelect, + locale: { ...contextLocale, ...customLocale }, + buildOptionText: buildOptionText || this.$slots.buildOptionText?.(), + ...this.$attrs, + class: classNames({ mini: isSmall }, this.$attrs.class), }; return ; @@ -127,8 +126,8 @@ export default { + slots={{ default: this.renderPagination }} + > ); }, }; diff --git a/components/pagination/index.js b/components/pagination/index.js index 81a12e1337..181bd30c57 100644 --- a/components/pagination/index.js +++ b/components/pagination/index.js @@ -4,9 +4,9 @@ import Base from '../base'; export { PaginationProps, PaginationConfig } from './Pagination'; /* istanbul ignore next */ -Pagination.install = function(Vue) { - Vue.use(Base); - Vue.component(Pagination.name, Pagination); +Pagination.install = function(app) { + app.use(Base); + app.component(Pagination.name, Pagination); }; export default Pagination; diff --git a/components/vc-pagination/Pager.jsx b/components/vc-pagination/Pager.jsx index 2d576fc0f7..ac230e3ed7 100644 --- a/components/vc-pagination/Pager.jsx +++ b/components/vc-pagination/Pager.jsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; export default { name: 'Pager', + inheritAttrs: false, props: { rootPrefixCls: PropTypes.string, page: PropTypes.number, @@ -24,20 +25,27 @@ export default { }, }, render() { + const { class: _cls, style } = this.$attrs; const props = this.$props; const prefixCls = `${props.rootPrefixCls}-item`; - const cls = classNames(prefixCls, `${prefixCls}-${props.page}`, { - [`${prefixCls}-active`]: props.active, - [`${prefixCls}-disabled`]: !props.page, - }); + const cls = classNames( + prefixCls, + `${prefixCls}-${props.page}`, + { + [`${prefixCls}-active`]: props.active, + [`${prefixCls}-disabled`]: !props.page, + }, + _cls, + ); return (
  • {this.itemRender(this.page, 'page', {this.page})}
  • diff --git a/components/vc-pagination/Pagination.jsx b/components/vc-pagination/Pagination.jsx index 14d75f3e98..784cc6af0a 100644 --- a/components/vc-pagination/Pagination.jsx +++ b/components/vc-pagination/Pagination.jsx @@ -1,10 +1,11 @@ import PropTypes from '../_util/vue-types'; import BaseMixin from '../_util/BaseMixin'; -import { hasProp, getComponentFromProp, getOptionProps } from '../_util/props-util'; +import { hasProp, getOptionProps, getComponent } from '../_util/props-util'; import Pager from './Pager'; import Options from './Options'; import LOCALE from './locale/zh_CN'; import KEYCODE from './KeyCode'; +import classNames from 'classnames'; function noop() {} @@ -28,6 +29,7 @@ function calculatePage(p, state, props) { export default { name: 'Pagination', mixins: [BaseMixin], + inheritAttrs: false, model: { prop: 'current', event: 'change.current', @@ -151,7 +153,7 @@ export default { }, getItemIcon(icon) { const { prefixCls } = this.$props; - const iconNode = getComponentFromProp(this, icon, this.$props) || ( + const iconNode = getComponent(this, icon, this.$props) || ( ); return iconNode; @@ -359,8 +361,9 @@ export default { } const hasPrev = this.hasPrev(); const hasNext = this.hasNext(); + return ( -