From b5046f07a27e8ca7fc8b961b74fa5e1b0d715149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E6=9C=A8?= Date: Thu, 1 Jul 2021 14:42:29 +0800 Subject: [PATCH] fix(form): fix some prop declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复`submitButtonOptions`、'resetButtonOptions'的类型定义 --- CHANGELOG.zh_CN.md | 1 + src/components/Button/index.ts | 3 +++ src/components/Button/src/BasicButton.vue | 23 ++----------------- src/components/Button/src/props.ts | 19 +++++++++++++++ .../Form/src/components/FormAction.vue | 4 ++-- src/components/Form/src/types/form.ts | 2 +- 6 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 src/components/Button/src/props.ts diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index cd96d4b4..89518703 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -18,6 +18,7 @@ - 修复`ROLE`权限模式下`hasPermission`不工作的问题 - **Table** 修复启用`clickToRowSelect`时,点击行不会触发`selection-change`事件的问题 - **Table** 修复全局配置`fetchSetting`可能会被局部配置意外修改的问题 +- **Form** 修复`submitButtonOptions`和`resetButtonOptions`的类型定义 ## 2.5.2(2021-06-27) diff --git a/src/components/Button/index.ts b/src/components/Button/index.ts index a367faf2..98add5c3 100644 --- a/src/components/Button/index.ts +++ b/src/components/Button/index.ts @@ -1,6 +1,9 @@ import { withInstall } from '/@/utils'; +import type { ExtractPropTypes } from 'vue'; import button from './src/BasicButton.vue'; import popConfirmButton from './src/PopConfirmButton.vue'; +import { buttonProps } from './src/props'; export const Button = withInstall(button); export const PopConfirmButton = withInstall(popConfirmButton); +export declare type ButtonProps = Partial>; diff --git a/src/components/Button/src/BasicButton.vue b/src/components/Button/src/BasicButton.vue index c043ab73..2ae0cf89 100644 --- a/src/components/Button/src/BasicButton.vue +++ b/src/components/Button/src/BasicButton.vue @@ -11,32 +11,13 @@ import { defineComponent, computed } from 'vue'; import { Button } from 'ant-design-vue'; import { Icon } from '/@/components/Icon'; - - const props = { - color: { type: String, validator: (v) => ['error', 'warning', 'success', ''].includes(v) }, - loading: { type: Boolean }, - disabled: { type: Boolean }, - /** - * Text before icon. - */ - preIcon: { type: String }, - /** - * Text after icon. - */ - postIcon: { type: String }, - /** - * preIcon and postIcon icon size. - * @default: 14 - */ - iconSize: { type: Number, default: 14 }, - onClick: { type: Function as PropType<(...args) => any>, default: null }, - }; + import { buttonProps } from './props'; export default defineComponent({ name: 'AButton', components: { Button, Icon }, inheritAttrs: false, - props, + props: buttonProps, setup(props, { attrs }) { // get component class const getButtonClass = computed(() => { diff --git a/src/components/Button/src/props.ts b/src/components/Button/src/props.ts new file mode 100644 index 00000000..d79d378a --- /dev/null +++ b/src/components/Button/src/props.ts @@ -0,0 +1,19 @@ +export const buttonProps = { + color: { type: String, validator: (v) => ['error', 'warning', 'success', ''].includes(v) }, + loading: { type: Boolean }, + disabled: { type: Boolean }, + /** + * Text before icon. + */ + preIcon: { type: String }, + /** + * Text after icon. + */ + postIcon: { type: String }, + /** + * preIcon and postIcon icon size. + * @default: 14 + */ + iconSize: { type: Number, default: 14 }, + onClick: { type: Function as PropType<(...args) => any>, default: null }, +}; diff --git a/src/components/Form/src/components/FormAction.vue b/src/components/Form/src/components/FormAction.vue index ba6ff251..1666dfe8 100644 --- a/src/components/Form/src/components/FormAction.vue +++ b/src/components/Form/src/components/FormAction.vue @@ -39,10 +39,10 @@