UNPKG

6.1 kBTypeScriptView Raw
1import { RenderFunction, SetupContext, ComponentPublicInstance, Ref } from 'vue'
2import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf } from './component'
3
4/* eslint-disable no-use-before-define */
5
6/**
7 * 组件 - 文本域
8 * @example import { VxeTextarea } from 'vxe-table'
9 */
10export const VxeTextarea: VXEComponent<VxeTextareaProps, VxeTextareaEventProps, VxeTextareaSlots>
11/**
12 * 组件 - 文本域
13 */
14export const Textarea: typeof VxeTextarea
15
16export type VxeTextareaInstance = ComponentPublicInstance<VxeTextareaProps, VxeTextareaConstructor>
17
18export interface VxeTextareaConstructor extends VxeComponentBase, VxeTextareaMethods {
19 props: VxeTextareaProps
20 context: SetupContext<VxeTextareaEmits>
21 reactData: TextareaReactData
22 getRefMaps(): TextareaPrivateRef
23 renderVN: RenderFunction
24}
25
26export interface TextareaReactData {
27 inputValue: any
28}
29
30export interface TextareaPrivateRef {
31 refElem: Ref<HTMLDivElement>
32 refTextarea: Ref<HTMLTextAreaElement>
33}
34export interface VxeTextareaPrivateRef extends TextareaPrivateRef { }
35
36export type VxeTextareaProps = {
37 size?: VxeTextareaPropTypes.Size
38 /**
39 * 绑定值
40 */
41 modelValue?: VxeTextareaPropTypes.ModelValue
42 className?: VxeTextareaPropTypes.ClassName
43 immediate?: VxeTextareaPropTypes.Immediate
44 /**
45 * 原生 name 属性
46 */
47 name?: VxeTextareaPropTypes.Name
48 /**
49 * 是否只读
50 */
51 readonly?: VxeTextareaPropTypes.Readonly
52 /**
53 * 是否禁用
54 */
55 disabled?: VxeTextareaPropTypes.Disabled
56 /**
57 * 当值为空时,显示的占位符
58 */
59 placeholder?: VxeTextareaPropTypes.Placeholder
60 /**
61 * 最大长度
62 */
63 maxlength?: VxeTextareaPropTypes.Maxlength
64 /**
65 * 原生 rows 属性
66 */
67 rows?: VxeTextareaPropTypes.Rows
68 /**
69 * 原生 cols 属性
70 */
71 cols?: VxeTextareaPropTypes.Cols
72 /**
73 * 是否显示字数统计
74 */
75 showWordCount?: VxeTextareaPropTypes.ShowWordCount
76 /**
77 * 自定义字数统计方法
78 */
79 countMethod?: VxeTextareaPropTypes.CountMethod
80 /**
81 * 自适应文本高度
82 */
83 autosize?: VxeTextareaPropTypes.Autosize
84 /**
85 * 原生 form 属性
86 */
87 form?: VxeTextareaPropTypes.Form
88 /**
89 * 调整文本域大小的方式
90 */
91 resize?: VxeTextareaPropTypes.Resize
92}
93
94export namespace VxeTextareaPropTypes {
95 export type Size = SizeType
96 export type ModelValue = string | number
97 export type ClassName = string
98 export type Immediate = boolean
99 export type Name = string
100 export type Readonly = boolean
101 export type Disabled = boolean
102 export type Placeholder = string
103 export type Maxlength = string | number
104 export type Rows = string | number
105 export type Cols = string | number
106 export type ShowWordCount = boolean
107 export type CountMethod = (params: {
108 value: string
109 }) => number
110 export type Autosize = {
111 minRows?: number
112 maxRows?: number
113 }
114 export type Form = string
115 export type Resize = string
116}
117
118export interface TextareaMethods {
119 dispatchEvent(type: ValueOf<VxeTextareaEmits>, params: any, evnt: Event): void
120 /**
121 * 获取焦点
122 */
123 focus(): Promise<any>
124 /**
125 * 失去焦点
126 */
127 blur(): Promise<any>
128}
129export interface VxeTextareaMethods extends TextareaMethods { }
130
131export interface TextareaPrivateMethods { }
132export interface VxeTextareaPrivateMethods extends TextareaPrivateMethods { }
133
134export type VxeTextareaEmits = [
135 'update:modelValue',
136 'input',
137 'keydown',
138 'keyup',
139 'click',
140 'change',
141 'focus',
142 'blur'
143]
144
145export namespace VxeTextareaDefines {
146 interface TextareaEventParams extends VxeEvent {
147 $textarea: VxeTextareaConstructor
148 }
149
150 export interface InputParams {
151 value: string
152 }
153 export interface InputEventParams extends TextareaEventParams, InputParams { }
154
155 export interface ChangeParams extends InputParams {}
156 export interface ChangeEventParams extends TextareaEventParams, ChangeParams { }
157
158 export interface KeyupParams extends InputParams {}
159 export interface KeyupEventParams extends TextareaEventParams, KeyupParams { }
160
161 export interface KeydownParams extends InputParams {}
162 export interface KeydownEventParams extends TextareaEventParams, KeydownParams { }
163
164 export interface ClickParams extends InputParams {}
165 export interface ClickEventParams extends TextareaEventParams, ClickParams { }
166
167 export interface FocusParams extends InputParams {}
168 export interface FocusEventParams extends TextareaEventParams, FocusParams { }
169
170 export interface BlurParams extends InputParams {}
171 export interface BlurEventParams extends TextareaEventParams, BlurParams { }
172}
173
174export type VxeTextareaEventProps = {
175 onInput?: VxeTextareaEvents.Input
176 onChange?: VxeTextareaEvents.Change
177 onKeydown?: VxeTextareaEvents.Keydown
178 onKeyup?: VxeTextareaEvents.Keyup
179 onClick?: VxeTextareaEvents.Click
180 onFocus?: VxeTextareaEvents.Focus
181 onBlur?: VxeTextareaEvents.Blur
182}
183
184export interface VxeTextareaListeners {
185 input?: VxeTextareaEvents.Input
186 change?: VxeTextareaEvents.Change
187 keydown?: VxeTextareaEvents.Keydown
188 keyup?: VxeTextareaEvents.Keyup
189 click?: VxeTextareaEvents.Click
190 focus?: VxeTextareaEvents.Focus
191 blur?: VxeTextareaEvents.Blur
192}
193
194export namespace VxeTextareaEvents {
195 export type Input = (params: VxeTextareaDefines.InputEventParams) => void
196 export type Change = (params: VxeTextareaDefines.ChangeEventParams) => void
197 export type Keydown = (params: VxeTextareaDefines.KeydownEventParams) => void
198 export type Keyup = (params: VxeTextareaDefines.KeyupEventParams) => void
199 export type Click = (params: VxeTextareaDefines.ClickEventParams) => void
200 export type Focus = (params: VxeTextareaDefines.FocusEventParams) => void
201 export type Blur = (params: VxeTextareaDefines.BlurEventParams) => void
202}
203
204export interface VxeTextareaSlots {
205 /**
206 * 自定义插槽模板
207 */
208 [key: string]: ((params: {
209 [key: string]: any
210 }) => any) | undefined
211}