1 | import { SetupContext, RenderFunction, ComponentPublicInstance } from 'vue'
|
2 | import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf } from './component'
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export const VxeSwitch: VXEComponent<VxeSwitchProps, VxeSwitchEventProps, VxeSwitchSlots>
|
11 |
|
12 |
|
13 |
|
14 | export const Switch: typeof VxeSwitch
|
15 |
|
16 | export type VxeSwitchInstance = ComponentPublicInstance<VxeSwitchProps, VxeSwitchConstructor>
|
17 |
|
18 | export interface VxeSwitchConstructor extends VxeComponentBase, VxeSwitchMethods {
|
19 | props: VxeSwitchProps
|
20 | context: SetupContext<VxeSwitchEmits>
|
21 | reactData: SwitchReactData
|
22 | renderVN: RenderFunction
|
23 | }
|
24 |
|
25 | export interface SwitchReactData {
|
26 | isActivated: boolean
|
27 | hasAnimat: boolean
|
28 | offsetLeft: number
|
29 | }
|
30 |
|
31 | export type VxeSwitchProps = {
|
32 | size?: VxeSwitchPropTypes.Size
|
33 | modelValue?: VxeSwitchPropTypes.ModelValue
|
34 | disabled?: VxeSwitchPropTypes.Disabled
|
35 | openLabel?: VxeSwitchPropTypes.OpenLabel
|
36 | closeLabel?: VxeSwitchPropTypes.CloseLabel
|
37 | openValue?: VxeSwitchPropTypes.OpenValue
|
38 | closeValue?: VxeSwitchPropTypes.CloseValue
|
39 | openIcon?: VxeSwitchPropTypes.OpenIcon
|
40 | closeIcon?: VxeSwitchPropTypes.CloseIcon
|
41 | openActiveIcon?: VxeSwitchPropTypes.OpenActiveIcon
|
42 | closeActiveIcon?: VxeSwitchPropTypes.CloseActiveIcon
|
43 | }
|
44 |
|
45 | export namespace VxeSwitchPropTypes {
|
46 | export type Size = SizeType
|
47 | export type ModelValue = string | number | boolean
|
48 | export type Disabled = boolean
|
49 | export type OpenLabel = string
|
50 | export type CloseLabel = string
|
51 | export type OpenValue = string | number | boolean
|
52 | export type CloseValue = string | number | boolean
|
53 | export type OpenIcon = string
|
54 | export type CloseIcon = string
|
55 | export type OpenActiveIcon = string
|
56 | export type CloseActiveIcon = string
|
57 | }
|
58 |
|
59 | export interface SwitchMethods {
|
60 | dispatchEvent(type: ValueOf<VxeSwitchEmits>, params: any, evnt: Event): void
|
61 | |
62 |
|
63 |
|
64 | focus(): Promise<any>
|
65 | |
66 |
|
67 |
|
68 | blur(): Promise<any>
|
69 | }
|
70 | export interface VxeSwitchMethods extends SwitchMethods { }
|
71 |
|
72 | export interface SwitchPrivateMethods { }
|
73 | export interface VxeSwitchPrivateMethods extends SwitchPrivateMethods { }
|
74 |
|
75 | export type VxeSwitchEmits = [
|
76 | 'update:modelValue',
|
77 | 'change',
|
78 | 'focus',
|
79 | 'blur'
|
80 | ]
|
81 |
|
82 | export namespace VxeSwitchDefines {
|
83 | interface SwitchEventParams extends VxeEvent {
|
84 | $switch: VxeSwitchConstructor
|
85 | }
|
86 |
|
87 | export interface ChangeEventParams extends SwitchEventParams { }
|
88 | export interface FocusEventParams extends SwitchEventParams { }
|
89 | export interface BlurEventParams extends SwitchEventParams { }
|
90 | }
|
91 |
|
92 | export type VxeSwitchEventProps = {
|
93 | onChange?: VxeSwitchEvents.Change
|
94 | onFocus?: VxeSwitchEvents.Focus
|
95 | onBlur?: VxeSwitchEvents.Blur
|
96 | }
|
97 |
|
98 | export interface VxeSwitchListeners {
|
99 | change?: VxeSwitchEvents.Change
|
100 | focus?: VxeSwitchEvents.Focus
|
101 | blur?: VxeSwitchEvents.Blur
|
102 | }
|
103 |
|
104 | export namespace VxeSwitchEvents {
|
105 | export type Change = (params: VxeSwitchDefines.ChangeEventParams) => void
|
106 | export type Focus = (params: VxeSwitchDefines.FocusEventParams) => void
|
107 | export type Blur = (params: VxeSwitchDefines.BlurEventParams) => void
|
108 | }
|
109 |
|
110 | export interface VxeSwitchSlots {
|
111 | |
112 |
|
113 |
|
114 | [key: string]: ((params: {
|
115 | [key: string]: any
|
116 | }) => any) | undefined
|
117 | }
|