From 6b8cebc25f4b2df52e0a435a797a522e59ff85d6 Mon Sep 17 00:00:00 2001 From: Amour1688 Date: Mon, 19 Oct 2020 22:11:45 +0800 Subject: [PATCH] refactor: pagination to ts --- .../{MiniSelect.jsx => MiniSelect.tsx} | 5 +++-- .../{Pagination.jsx => Pagination.tsx} | 21 ++++++++++--------- components/pagination/{index.js => index.ts} | 3 ++- .../pagination/style/{index.js => index.ts} | 0 components/vc-select/index.ts | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) rename components/pagination/{MiniSelect.jsx => MiniSelect.tsx} (85%) rename components/pagination/{Pagination.jsx => Pagination.tsx} (94%) rename components/pagination/{index.js => index.ts} (76%) rename components/pagination/style/{index.js => index.ts} (100%) diff --git a/components/pagination/MiniSelect.jsx b/components/pagination/MiniSelect.tsx similarity index 85% rename from components/pagination/MiniSelect.jsx rename to components/pagination/MiniSelect.tsx index ec79f8981..3c9648c17 100644 --- a/components/pagination/MiniSelect.jsx +++ b/components/pagination/MiniSelect.tsx @@ -1,7 +1,8 @@ +import { defineComponent } from 'vue'; import VcSelect, { SelectProps } from '../select'; import { getOptionProps, getSlot } from '../_util/props-util'; -export default { +export default defineComponent({ inheritAttrs: false, props: { ...SelectProps(), @@ -16,4 +17,4 @@ export default { }; return {getSlot(this)}; }, -}; +}); diff --git a/components/pagination/Pagination.jsx b/components/pagination/Pagination.tsx similarity index 94% rename from components/pagination/Pagination.jsx rename to components/pagination/Pagination.tsx index 10b19ab1b..8be780be0 100644 --- a/components/pagination/Pagination.jsx +++ b/components/pagination/Pagination.tsx @@ -1,3 +1,9 @@ +import { defineComponent, inject } from 'vue'; +import LeftOutlined from '@ant-design/icons-vue/LeftOutlined'; +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 { tuple } from '../_util/type'; import PropTypes, { withUndefined } from '../_util/vue-types'; import VcSelect from '../select'; import MiniSelect from './MiniSelect'; @@ -5,12 +11,7 @@ import LocaleReceiver from '../locale-provider/LocaleReceiver'; 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'; -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 { defaultConfigProvider } from '../config-provider'; -import { inject } from 'vue'; import classNames from '../_util/classNames'; export const PaginationProps = () => ({ @@ -39,10 +40,10 @@ export const PaginationProps = () => ({ export const PaginationConfig = () => ({ ...PaginationProps(), - position: PropTypes.oneOf(['top', 'bottom', 'both']), + position: PropTypes.oneOf(tuple('top', 'bottom', 'both')), }); -export default { +export default defineComponent({ name: 'APagination', inheritAttrs: false, props: { @@ -56,7 +57,7 @@ export default { }, methods: { - getIconsProps(prefixCls) { + getIconsProps(prefixCls: string) { const prevIcon = ( @@ -128,7 +129,7 @@ export default { componentName="Pagination" defaultLocale={enUS} children={this.renderPagination} - > + /> ); }, -}; +}); diff --git a/components/pagination/index.js b/components/pagination/index.ts similarity index 76% rename from components/pagination/index.js rename to components/pagination/index.ts index e8338024d..334745233 100644 --- a/components/pagination/index.js +++ b/components/pagination/index.ts @@ -1,9 +1,10 @@ +import { App } from 'vue'; import Pagination from './Pagination'; export { PaginationProps, PaginationConfig } from './Pagination'; /* istanbul ignore next */ -Pagination.install = function(app) { +Pagination.install = function(app: App) { app.component(Pagination.name, Pagination); return app; }; diff --git a/components/pagination/style/index.js b/components/pagination/style/index.ts similarity index 100% rename from components/pagination/style/index.js rename to components/pagination/style/index.ts diff --git a/components/vc-select/index.ts b/components/vc-select/index.ts index 650dce1c6..023af73f7 100644 --- a/components/vc-select/index.ts +++ b/components/vc-select/index.ts @@ -3,7 +3,7 @@ import Option from './Option'; import OptGroup from './OptGroup'; import { BaseProps } from './generate'; -export type SelectProps = ExportedSelectProps; +export type SelectProps = ExportedSelectProps; export { Option, OptGroup, BaseProps }; export default Select;