UNPKG

3.92 kBTypeScriptView Raw
1/// <reference types="react" />
2
3import * as React from 'react';
4import CommonProps from '../util';
5import { PopupProps } from '../overlay';
6import { ButtonProps } from '../button';
7
8interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
9 defaultValue?: any;
10 onChange?: any;
11}
12
13type item = {
14 value?: string | number;
15 label?: React.ReactNode;
16 [propName: string]: any;
17}
18
19export interface SearchProps extends HTMLAttributesWeak, CommonProps {
20 /**
21 * 大小
22 */
23 size?: 'large' | 'medium';
24
25 /**
26 * 搜索框数值
27 */
28 value?: string | number;
29
30 /**
31 * 搜索框默认值
32 */
33 defaultValue?: string;
34
35 /**
36 * 默认提示
37 */
38 placeholder?: string;
39
40 /**
41 * 下拉菜单是否与选择器对齐
42 */
43 autoWidth?: boolean;
44
45 /**
46 * 自定义内联 label
47 */
48 label?: React.ReactNode;
49
50 /**
51 * 是否显示清除按钮
52 */
53 hasClear?: boolean;
54
55 /**
56 * 校验状态
57 */
58 state?: 'error' | 'loading';
59
60 /**
61 * 是否只读,只读模式下可以展开弹层但不能选
62 */
63 readOnly?: boolean;
64
65 /**
66 * 是否禁用
67 */
68 disabled?: boolean;
69
70 /**
71 * 自定义渲染的的下拉框
72 */
73 visible?: boolean;
74
75 /**
76 * 弹层初始化是否显示
77 */
78 defaultVisible?: boolean;
79
80 /**
81 * 弹层显示或隐藏时触发的回调
82 */
83 onVisibleChange?: (visible: boolean) => void;
84
85 /**
86 * 弹层挂载的容器节点
87 */
88 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
89
90 /**
91 * 弹层的 className
92 */
93 popupClassName?: string;
94
95 /**
96 * 弹层的内联样式
97 */
98 popupStyle?: React.CSSProperties;
99
100 /**
101 * 添加到弹层上的属性
102 */
103 popupProps?: PopupProps;
104
105 /**
106 * 自定义渲染的的下拉框
107 */
108 popupContent?: React.ReactNode;
109
110 /**
111 * 是否使用本地过滤,在数据源为远程的时候需要关闭此项
112 */
113 filterLocal?: boolean;
114
115 /**
116 * 选择器
117 */
118 filter?: Array<any>;
119
120 /**
121 * 键盘上下键切换菜单高亮选项的回调
122 */
123 onToggleHighlightItem?: () => void;
124
125 /**
126 * 是否开启虚拟滚动模式
127 */
128 useVirtual?: boolean;
129
130 /**
131 * 搜索框下拉联想列表
132 */
133 dataSource?: Array<any>;
134
135 /**
136 * 渲染 MenuItem 内容的方法
137 */
138 itemRender?: (item: item) => React.ReactNode;
139
140 /**
141 * 输入关键字时的回掉
142 */
143 onChange?: (value: any, actionType: string, item: any) => void;
144
145 /**
146 * 填充到选择框里的值的 key,默认是 value
147 */
148 fillProps?: string;
149
150 /**
151 * 样式前缀
152 */
153 prefix?: string;
154
155 /**
156 * 形状
157 */
158 shape?: 'normal' | 'simple';
159
160 /**
161 * 类型 shape=normal: primary/secondary; shape=simple: normal/dark;
162 */
163 type?: 'primary' | 'secondary' | 'normal' | 'dark';
164
165 /**
166 * 点击搜索按钮触发的回调
167 */
168 onSearch?: (value: string, filterValue?: any) => void;
169
170 /**
171 * 选择器默认值
172 */
173 defaultFilterValue?: string;
174
175 /**
176 * 选择器值
177 */
178 filterValue?: string;
179
180 /**
181 * 选择器发生变化时回调
182 */
183 onFilterChange?: (filter: {}) => void;
184
185 /**
186 * button 的内容
187 */
188 searchText?: React.ReactNode;
189
190 /**
191 * 自定义样式
192 */
193 style?: React.CSSProperties;
194
195 /**
196 * 样式名称
197 */
198 className?: string;
199
200 /**
201 * 选择器的props
202 */
203 filterProps?: any;
204
205 /**
206 * 按钮的额外属性
207 */
208 buttonProps?: ButtonProps;
209
210 /**
211 * 是否显示搜索按钮
212 */
213 hasIcon?: boolean;
214 icons?: {
215 search?: React.ReactNode;
216 };
217}
218
219export default class Search extends React.Component<SearchProps, any> {}