UNPKG

3.03 kBTypeScriptView Raw
1import { SetupContext, RenderFunction, ComponentPublicInstance } from 'vue'
2import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf } from './component'
3
4/* eslint-disable no-use-before-define */
5
6/**
7 * 组件 - 复选框
8 * @example import { VxeCheckbox } from 'vxe-table'
9 */
10export const VxeCheckbox: VXEComponent<VxeCheckboxProps, VxeCheckboxEventProps, VxeCheckboxSlots>
11/**
12 * 组件 - 复选框
13 */
14export const Checkbox: typeof VxeCheckbox
15
16export type VxeCheckboxInstance = ComponentPublicInstance<VxeCheckboxProps, VxeCheckboxConstructor>
17
18export interface VxeCheckboxConstructor extends VxeComponentBase, VxeCheckboxMethods {
19 props: VxeCheckboxProps
20 context: SetupContext<VxeCheckboxEmits>
21 renderVN: RenderFunction
22}
23
24export type VxeCheckboxProps = {
25 size?: VxeCheckboxPropTypes.Size
26 /**
27 * 绑定值
28 */
29 modelValue?: VxeCheckboxPropTypes.ModelValue
30 /**
31 * 只对 checkbox-group 有效,值
32 */
33 label?: VxeCheckboxPropTypes.Label
34 /**
35 * 是否不确定状态
36 */
37 indeterminate?: VxeCheckboxPropTypes.Indeterminate
38 /**
39 * 原生 title 属性
40 */
41 title?: VxeCheckboxPropTypes.Title
42 checkedValue?: VxeCheckboxPropTypes.CheckedValue
43 uncheckedValue?: VxeCheckboxPropTypes.UncheckedValue
44 /**
45 * 内容
46 */
47 content?: VxeCheckboxPropTypes.Content
48 /**
49 * 是否禁用
50 */
51 disabled?: VxeCheckboxPropTypes.Disabled
52}
53
54export namespace VxeCheckboxPropTypes {
55 export type Size = SizeType
56 export type ModelValue = string | number | boolean
57 export type Label = string | number
58 export type Indeterminate = boolean
59 export type Title = string | number
60 export type CheckedValue = string | number | boolean
61 export type UncheckedValue = string | number | boolean
62 export type Content = string | number
63 export type Disabled = boolean
64}
65
66export interface CheckboxMethods {
67 dispatchEvent(type: ValueOf<VxeCheckboxEmits>, params: any, evnt: Event): void
68}
69export interface VxeCheckboxMethods extends CheckboxMethods { }
70
71export interface CheckboxPrivateMethods { }
72export interface VxeCheckboxPrivateMethods extends CheckboxPrivateMethods { }
73
74export type VxeCheckboxEmits = [
75 'update:modelValue',
76 'change'
77]
78
79export namespace VxeCheckboxDefines {
80 interface CheckboxEventParams extends VxeEvent {
81 $checkbox: VxeCheckboxConstructor
82 }
83
84 export interface ChangeParams {
85 checked: boolean
86 label: any
87 }
88 export interface ChangeEventParams extends CheckboxEventParams, ChangeParams { }
89}
90
91export type VxeCheckboxEventProps = {
92 onChange?: VxeCheckboxEvents.Change
93}
94
95export interface VxeCheckboxListeners {
96 change?: VxeCheckboxEvents.Change
97}
98
99export namespace VxeCheckboxEvents {
100 export type Change = (params: VxeCheckboxDefines.ChangeEventParams) => void
101}
102
103export interface VxeCheckboxSlots {
104 /**
105 * 自定义插槽模板
106 */
107 [key: string]: ((params: {
108 [key: string]: any
109 }) => any) | undefined
110}