Vben
2021-06-11 639520ad5ddf829875ab517067abf2b45ebc04c2
提交 | 用户 | age
2407b3 1 import type { ButtonProps } from 'ant-design-vue/lib/button/buttonTypes';
ebf7c8 2 import type { CSSProperties, VNodeChild, ComputedRef } from 'vue';
2f6253 3 import type { ScrollContainerOptions } from '/@/components/Container/index';
4
5 export interface DrawerInstance {
6   setDrawerProps: (props: Partial<DrawerProps> | boolean) => void;
ebf7c8 7   emitVisible?: (visible: boolean, uid: number) => void;
2f6253 8 }
28f7f7 9
2f6253 10 export interface ReturnMethods extends DrawerInstance {
ea24df 11   openDrawer: <T = any>(visible?: boolean, data?: T, openOnSet?: boolean) => void;
639520 12   closeDrawer: () => void;
ebf7c8 13   getVisible?: ComputedRef<boolean>;
2f6253 14 }
28f7f7 15
2f6253 16 export type RegisterFn = (drawerInstance: DrawerInstance, uuid?: string) => void;
17
18 export interface ReturnInnerMethods extends DrawerInstance {
19   closeDrawer: () => void;
20   changeLoading: (loading: boolean) => void;
21   changeOkLoading: (loading: boolean) => void;
ebf7c8 22   getVisible?: ComputedRef<boolean>;
2f6253 23 }
24
25 export type UseDrawerReturnType = [RegisterFn, ReturnMethods];
28f7f7 26
2f6253 27 export type UseDrawerInnerReturnType = [RegisterFn, ReturnInnerMethods];
28
29 export interface DrawerFooterProps {
30   showOkBtn: boolean;
31   showCancelBtn: boolean;
32   /**
33    * Text of the Cancel button
34    * @default 'cancel'
35    * @type string
36    */
37   cancelText: string;
38   /**
39    * Text of the OK button
40    * @default 'OK'
41    * @type string
42    */
43   okText: string;
44
45   /**
46    * Button type of the OK button
47    * @default 'primary'
48    * @type string
49    */
50   okType: 'primary' | 'danger' | 'dashed' | 'ghost' | 'default';
51   /**
52    * The ok button props, follow jsx rules
53    * @type object
54    */
2407b3 55   okButtonProps: { props: ButtonProps; on: {} };
2f6253 56
57   /**
58    * The cancel button props, follow jsx rules
59    * @type object
60    */
2407b3 61   cancelButtonProps: { props: ButtonProps; on: {} };
2f6253 62   /**
63    * Whether to apply loading visual effect for OK button or not
64    * @default false
65    * @type boolean
66    */
67   confirmLoading: boolean;
68
69   showFooter: boolean;
70   footerHeight: string | number;
71 }
72 export interface DrawerProps extends DrawerFooterProps {
2628fb 73   isDetail?: boolean;
2f6253 74   loading?: boolean;
75   showDetailBack?: boolean;
76   visible?: boolean;
77   /**
46e087 78    * Built-in ScrollContainer component configuration
2f6253 79    * @type ScrollContainerOptions
80    */
81   scrollOptions?: ScrollContainerOptions;
81baf1 82   closeFunc?: () => Promise<any>;
2f6253 83   triggerWindowResize?: boolean;
84   /**
85    * Whether a close (x) button is visible on top right of the Drawer dialog or not.
86    * @default true
87    * @type boolean
88    */
89   closable?: boolean;
90
91   /**
92    * Whether to unmount child components on closing drawer or not.
93    * @default false
94    * @type boolean
95    */
96   destroyOnClose?: boolean;
97
98   /**
99    * Return the mounted node for Drawer.
100    * @default 'body'
101    * @type any ( HTMLElement| () => HTMLElement | string)
102    */
103   getContainer?: () => HTMLElement | string;
104
105   /**
106    * Whether to show mask or not.
107    * @default true
108    * @type boolean
109    */
110   mask?: boolean;
111
112   /**
113    * Clicking on the mask (area outside the Drawer) to close the Drawer or not.
114    * @default true
115    * @type boolean
116    */
117   maskClosable?: boolean;
118
119   /**
120    * Style for Drawer's mask element.
121    * @default {}
122    * @type object
123    */
124   maskStyle?: CSSProperties;
125
126   /**
127    * The title for Drawer.
128    * @type any (string | slot)
129    */
130   title?: VNodeChild | JSX.Element;
131
132   /**
133    * The class name of the container of the Drawer dialog.
134    * @type string
135    */
136   wrapClassName?: string;
137
138   /**
139    * Style of wrapper element which **contains mask** compare to `drawerStyle`
140    * @type object
141    */
142   wrapStyle?: CSSProperties;
143
144   /**
145    * Style of the popup layer element
146    * @type object
147    */
148   drawerStyle?: CSSProperties;
149
150   /**
151    * Style of floating layer, typically used for adjusting its position.
152    * @type object
153    */
154   bodyStyle?: CSSProperties;
155   headerStyle?: CSSProperties;
156
157   /**
158    * Width of the Drawer dialog.
159    * @default 256
160    * @type string | number
161    */
162   width?: string | number;
163
164   /**
165    * placement is top or bottom, height of the Drawer dialog.
166    * @type string | number
167    */
168   height?: string | number;
169
170   /**
171    * The z-index of the Drawer.
172    * @default 1000
173    * @type number
174    */
175   zIndex?: number;
176
177   /**
178    * The placement of the Drawer.
179    * @default 'right'
180    * @type string
181    */
182   placement?: 'top' | 'right' | 'bottom' | 'left';
183   afterVisibleChange?: (visible?: boolean) => void;
184   keyboard?: boolean;
185   /**
186    * Specify a callback that will be called when a user clicks mask, close button or Cancel button.
187    */
188   onClose?: (e?: Event) => void;
189 }
190 export interface DrawerActionType {
191   scrollBottom: () => void;
192   scrollTo: (to: number) => void;
193   getScrollWrap: () => Element | null;
194 }