Commit b5046f07a27e8ca7fc8b961b74fa5e1b0d715149

Authored by 无木
1 parent ddf116da

fix(form): fix some prop declaration

修复`submitButtonOptions`、'resetButtonOptions'的类型定义
CHANGELOG.zh_CN.md
... ... @@ -18,6 +18,7 @@
18 18 - 修复`ROLE`权限模式下`hasPermission`不工作的问题
19 19 - **Table** 修复启用`clickToRowSelect`时,点击行不会触发`selection-change`事件的问题
20 20 - **Table** 修复全局配置`fetchSetting`可能会被局部配置意外修改的问题
  21 +- **Form** 修复`submitButtonOptions`和`resetButtonOptions`的类型定义
21 22  
22 23 ## 2.5.2(2021-06-27)
23 24  
... ...
src/components/Button/index.ts
1 1 import { withInstall } from '/@/utils';
  2 +import type { ExtractPropTypes } from 'vue';
2 3 import button from './src/BasicButton.vue';
3 4 import popConfirmButton from './src/PopConfirmButton.vue';
  5 +import { buttonProps } from './src/props';
4 6  
5 7 export const Button = withInstall(button);
6 8 export const PopConfirmButton = withInstall(popConfirmButton);
  9 +export declare type ButtonProps = Partial<ExtractPropTypes<typeof buttonProps>>;
... ...
src/components/Button/src/BasicButton.vue
... ... @@ -11,32 +11,13 @@
11 11 import { defineComponent, computed } from 'vue';
12 12 import { Button } from 'ant-design-vue';
13 13 import { Icon } from '/@/components/Icon';
14   -
15   - const props = {
16   - color: { type: String, validator: (v) => ['error', 'warning', 'success', ''].includes(v) },
17   - loading: { type: Boolean },
18   - disabled: { type: Boolean },
19   - /**
20   - * Text before icon.
21   - */
22   - preIcon: { type: String },
23   - /**
24   - * Text after icon.
25   - */
26   - postIcon: { type: String },
27   - /**
28   - * preIcon and postIcon icon size.
29   - * @default: 14
30   - */
31   - iconSize: { type: Number, default: 14 },
32   - onClick: { type: Function as PropType<(...args) => any>, default: null },
33   - };
  14 + import { buttonProps } from './props';
34 15  
35 16 export default defineComponent({
36 17 name: 'AButton',
37 18 components: { Button, Icon },
38 19 inheritAttrs: false,
39   - props,
  20 + props: buttonProps,
40 21 setup(props, { attrs }) {
41 22 // get component class
42 23 const getButtonClass = computed(() => {
... ...
src/components/Button/src/props.ts 0 → 100644
  1 +export const buttonProps = {
  2 + color: { type: String, validator: (v) => ['error', 'warning', 'success', ''].includes(v) },
  3 + loading: { type: Boolean },
  4 + disabled: { type: Boolean },
  5 + /**
  6 + * Text before icon.
  7 + */
  8 + preIcon: { type: String },
  9 + /**
  10 + * Text after icon.
  11 + */
  12 + postIcon: { type: String },
  13 + /**
  14 + * preIcon and postIcon icon size.
  15 + * @default: 14
  16 + */
  17 + iconSize: { type: Number, default: 14 },
  18 + onClick: { type: Function as PropType<(...args) => any>, default: null },
  19 +};
... ...
src/components/Form/src/components/FormAction.vue
... ... @@ -39,10 +39,10 @@
39 39 </template>
40 40 <script lang="ts">
41 41 import type { ColEx } from '../types/index';
42   - import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes';
  42 + //import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes';
43 43 import { defineComponent, computed, PropType } from 'vue';
44 44 import { Form, Col } from 'ant-design-vue';
45   - import { Button } from '/@/components/Button';
  45 + import { Button, ButtonProps } from '/@/components/Button';
46 46 import { BasicArrow } from '/@/components/Basic/index';
47 47 import { useFormContext } from '../hooks/useFormContext';
48 48 import { useI18n } from '/@/hooks/web/useI18n';
... ...
src/components/Form/src/types/form.ts
1 1 import type { NamePath, RuleObject } from 'ant-design-vue/lib/form/interface';
2 2 import type { VNode } from 'vue';
3   -import type { ButtonProps as AntdButtonProps } from 'ant-design-vue/es/button/buttonTypes';
  3 +import type { ButtonProps as AntdButtonProps } from '/@/components/Button';
4 4 import type { FormItem } from './formItem';
5 5 import type { ColEx, ComponentType } from './index';
6 6 import type { TableActionType } from '/@/components/Table/src/types/table';
... ...