@pisell/utils 1.0.57 → 1.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/es/arrayUtils.d.ts +1 -1
- package/es/common/index.d.ts +5 -5
- package/es/common/index.js +2 -2
- package/es/common/stateHelper.d.ts +18 -18
- package/es/common/stateHelper.js +15 -15
- package/es/common/types.d.ts +28 -28
- package/es/constants/index.d.ts +7 -0
- package/es/date.d.ts +28 -28
- package/es/date.js +22 -22
- package/es/document.d.ts +13 -13
- package/es/document.js +7 -7
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/firebase/config/index.d.ts +13 -13
- package/es/firebase/index.d.ts +28 -28
- package/es/format.d.ts +28 -0
- package/es/format.js +14 -14
- package/es/image.d.ts +11 -11
- package/es/image.js +5 -5
- package/es/index.d.ts +24 -24
- package/es/jsBridge/index.d.ts +22 -0
- package/es/jsBridge/index.js +15 -15
- package/es/jsBridge/regDeviceApi.d.ts +15 -15
- package/es/jsBridge/regDeviceApi.js +3 -3
- package/es/jsBridge/types.d.ts +149 -0
- package/es/locales.d.ts +12 -0
- package/es/locales.js +15 -15
- package/es/log.d.ts +10 -10
- package/es/miniRedux.d.ts +16 -0
- package/es/number-input/hooks/index.d.ts +4 -4
- package/es/number-input/hooks/index.js +2 -2
- package/es/number-input/hooks/useNumberInputState.d.ts +25 -25
- package/es/number-input/hooks/useNumberInputState.js +39 -39
- package/es/number-input/index.d.ts +14 -14
- package/es/number-input/index.js +8 -8
- package/es/number-input/types.d.ts +96 -96
- package/es/number-input/utils/formatter.d.ts +53 -53
- package/es/number-input/utils/formatter.js +37 -37
- package/es/number-input/utils/index.d.ts +7 -7
- package/es/number-input/utils/index.js +2 -2
- package/es/number-input/utils/validation.d.ts +27 -27
- package/es/number-input/utils/validation.js +24 -24
- package/es/otherUtils.d.ts +48 -0
- package/es/otherUtils.js +32 -32
- package/es/platform.d.ts +9 -9
- package/es/select/hooks/index.d.ts +5 -5
- package/es/select/hooks/index.js +2 -2
- package/es/select/hooks/useDebouncedSearch.d.ts +20 -20
- package/es/select/hooks/useDebouncedSearch.js +17 -17
- package/es/select/hooks/useSelectState.d.ts +19 -19
- package/es/select/hooks/useSelectState.js +13 -13
- package/es/select/index.d.ts +8 -8
- package/es/select/index.js +3 -3
- package/es/select/types.d.ts +256 -256
- package/es/select/utils/filterOptions.d.ts +22 -22
- package/es/select/utils/filterOptions.js +16 -16
- package/es/select/utils/helpers.d.ts +42 -42
- package/es/select/utils/helpers.js +30 -30
- package/es/select/utils/index.d.ts +7 -7
- package/es/select/utils/index.js +2 -2
- package/es/select/utils/sortOptions.d.ts +12 -12
- package/es/select/utils/sortOptions.js +8 -8
- package/es/select/utils/tagAggregation.d.ts +25 -25
- package/es/select/utils/tagAggregation.js +21 -21
- package/es/text-input/hooks/index.d.ts +4 -4
- package/es/text-input/hooks/index.js +2 -2
- package/es/text-input/hooks/useTextInputState.d.ts +24 -24
- package/es/text-input/hooks/useTextInputState.js +38 -38
- package/es/text-input/index.d.ts +14 -14
- package/es/text-input/index.js +9 -9
- package/es/text-input/types.d.ts +56 -56
- package/es/text-input/utils/index.d.ts +5 -5
- package/es/text-input/utils/index.js +2 -2
- package/es/text-input/utils/validation.d.ts +23 -23
- package/es/text-input/utils/validation.js +20 -20
- package/es/typeUtils.d.ts +42 -42
- package/es/typeUtils.js +26 -26
- package/es/walletValidity.d.ts +44 -0
- package/es/walletValidity.js +85 -85
- package/lib/arrayUtils.d.ts +1 -1
- package/lib/common/index.d.ts +5 -5
- package/lib/common/stateHelper.d.ts +18 -18
- package/lib/common/types.d.ts +28 -28
- package/lib/constants/index.d.ts +7 -0
- package/lib/date.d.ts +28 -28
- package/lib/document.d.ts +13 -13
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/firebase/config/index.d.ts +13 -13
- package/lib/firebase/index.d.ts +28 -28
- package/lib/format.d.ts +28 -0
- package/lib/image.d.ts +11 -11
- package/lib/index.d.ts +24 -24
- package/lib/jsBridge/index.d.ts +22 -0
- package/lib/jsBridge/regDeviceApi.d.ts +15 -15
- package/lib/jsBridge/types.d.ts +149 -0
- package/lib/locales.d.ts +12 -0
- package/lib/log.d.ts +10 -10
- package/lib/miniRedux.d.ts +16 -0
- package/lib/number-input/hooks/index.d.ts +4 -4
- package/lib/number-input/hooks/useNumberInputState.d.ts +25 -25
- package/lib/number-input/index.d.ts +14 -14
- package/lib/number-input/types.d.ts +96 -96
- package/lib/number-input/utils/formatter.d.ts +53 -53
- package/lib/number-input/utils/index.d.ts +7 -7
- package/lib/number-input/utils/validation.d.ts +27 -27
- package/lib/otherUtils.d.ts +48 -0
- package/lib/platform.d.ts +9 -9
- package/lib/select/hooks/index.d.ts +5 -5
- package/lib/select/hooks/useDebouncedSearch.d.ts +20 -20
- package/lib/select/hooks/useSelectState.d.ts +19 -19
- package/lib/select/index.d.ts +8 -8
- package/lib/select/types.d.ts +256 -256
- package/lib/select/utils/filterOptions.d.ts +22 -22
- package/lib/select/utils/helpers.d.ts +42 -42
- package/lib/select/utils/index.d.ts +7 -7
- package/lib/select/utils/sortOptions.d.ts +12 -12
- package/lib/select/utils/tagAggregation.d.ts +25 -25
- package/lib/text-input/hooks/index.d.ts +4 -4
- package/lib/text-input/hooks/useTextInputState.d.ts +24 -24
- package/lib/text-input/index.d.ts +14 -14
- package/lib/text-input/types.d.ts +56 -56
- package/lib/text-input/utils/index.d.ts +5 -5
- package/lib/text-input/utils/validation.d.ts +23 -23
- package/lib/typeUtils.d.ts +42 -42
- package/lib/walletValidity.d.ts +44 -0
- package/package.json +1 -1
package/lib/select/types.d.ts
CHANGED
|
@@ -1,256 +1,256 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select 组件公共类型定义
|
|
3
|
-
* 供 PisellSingleSelect、PisellMultipleSelect 等组件使用
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
export type { DisplayState } from '../common';
|
|
7
|
-
/**
|
|
8
|
-
* 选项基础类型
|
|
9
|
-
* @template T 选项值的类型,默认为 string | number
|
|
10
|
-
*/
|
|
11
|
-
export interface SelectOption<T = string | number> {
|
|
12
|
-
/**
|
|
13
|
-
* 选项值(唯一标识)
|
|
14
|
-
*/
|
|
15
|
-
value: T;
|
|
16
|
-
/**
|
|
17
|
-
* 选项显示文本
|
|
18
|
-
*/
|
|
19
|
-
label: string;
|
|
20
|
-
/**
|
|
21
|
-
* 是否禁用该选项
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* 选项图标(可选)
|
|
27
|
-
*/
|
|
28
|
-
icon?: React.ReactNode;
|
|
29
|
-
/**
|
|
30
|
-
* 标签背景色(多选时用于自定义标签颜色)
|
|
31
|
-
* @example '#61dafb'
|
|
32
|
-
*/
|
|
33
|
-
color?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 选项过滤函数类型
|
|
37
|
-
* @template T 选项值的类型
|
|
38
|
-
* @param input 用户输入的搜索文本
|
|
39
|
-
* @param option 当前选项对象
|
|
40
|
-
* @returns 是否保留该选项
|
|
41
|
-
*/
|
|
42
|
-
export declare type FilterOptionFunc<T = string | number> = (input: string, option: SelectOption<T>) => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* 排序方向
|
|
45
|
-
*/
|
|
46
|
-
export declare type SortDirection = 'asc' | 'desc';
|
|
47
|
-
/**
|
|
48
|
-
* Select 状态 Hook 返回值(单选)
|
|
49
|
-
* @template T 值的类型
|
|
50
|
-
*/
|
|
51
|
-
export interface SelectState<T = string | number> {
|
|
52
|
-
/**
|
|
53
|
-
* 当前选中值
|
|
54
|
-
*/
|
|
55
|
-
value: T | null | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* 设置选中值
|
|
58
|
-
*/
|
|
59
|
-
setValue: (value: T | null) => void;
|
|
60
|
-
/**
|
|
61
|
-
* 清空选中值
|
|
62
|
-
*/
|
|
63
|
-
clearValue: () => void;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Multiple Select 状态 Hook 返回值(多选)
|
|
67
|
-
* @template T 值的类型
|
|
68
|
-
*/
|
|
69
|
-
export interface MultipleSelectState<T = string | number> {
|
|
70
|
-
/**
|
|
71
|
-
* 当前选中值数组
|
|
72
|
-
*/
|
|
73
|
-
value: T[];
|
|
74
|
-
/**
|
|
75
|
-
* 设置选中值数组
|
|
76
|
-
*/
|
|
77
|
-
setValue: (value: T[]) => void;
|
|
78
|
-
/**
|
|
79
|
-
* 添加一个选中值
|
|
80
|
-
*/
|
|
81
|
-
addValue: (value: T) => void;
|
|
82
|
-
/**
|
|
83
|
-
* 移除一个选中值
|
|
84
|
-
*/
|
|
85
|
-
removeValue: (value: T) => void;
|
|
86
|
-
/**
|
|
87
|
-
* 清空所有选中值
|
|
88
|
-
*/
|
|
89
|
-
clearValue: () => void;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 标签显示信息(多选专用)
|
|
93
|
-
* @template T 选项值的类型
|
|
94
|
-
*/
|
|
95
|
-
export interface TagDisplayInfo<T = string | number> {
|
|
96
|
-
/**
|
|
97
|
-
* 可见的标签列表
|
|
98
|
-
*/
|
|
99
|
-
visibleTags: SelectOption<T>[];
|
|
100
|
-
/**
|
|
101
|
-
* 隐藏的标签列表
|
|
102
|
-
*/
|
|
103
|
-
hiddenTags: SelectOption<T>[];
|
|
104
|
-
/**
|
|
105
|
-
* 隐藏的标签数量
|
|
106
|
-
*/
|
|
107
|
-
hiddenCount: number;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* useSelectState Hook 的配置选项(单选)
|
|
111
|
-
* @template T 值的类型
|
|
112
|
-
*/
|
|
113
|
-
export interface UseSelectStateOptions<T = string | number> {
|
|
114
|
-
/**
|
|
115
|
-
* 受控模式:当前值
|
|
116
|
-
*/
|
|
117
|
-
value?: T | null;
|
|
118
|
-
/**
|
|
119
|
-
* 非受控模式:默认值
|
|
120
|
-
*/
|
|
121
|
-
defaultValue?: T;
|
|
122
|
-
/**
|
|
123
|
-
* 值变化回调
|
|
124
|
-
*/
|
|
125
|
-
onChange?: (value: T | null, option: SelectOption<T> | null) => void;
|
|
126
|
-
/**
|
|
127
|
-
* 模式(用于类型区分)
|
|
128
|
-
*/
|
|
129
|
-
mode: 'single';
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* useMultipleSelectState Hook 的配置选项(多选)
|
|
133
|
-
* @template T 值的类型
|
|
134
|
-
*/
|
|
135
|
-
export interface UseMultipleSelectStateOptions<T = string | number> {
|
|
136
|
-
/**
|
|
137
|
-
* 受控模式:当前值数组
|
|
138
|
-
*/
|
|
139
|
-
value?: T[];
|
|
140
|
-
/**
|
|
141
|
-
* 非受控模式:默认值数组
|
|
142
|
-
*/
|
|
143
|
-
defaultValue?: T[];
|
|
144
|
-
/**
|
|
145
|
-
* 值变化回调
|
|
146
|
-
*/
|
|
147
|
-
onChange?: (value: T[], options: SelectOption<T>[]) => void;
|
|
148
|
-
/**
|
|
149
|
-
* 模式(用于类型区分)
|
|
150
|
-
*/
|
|
151
|
-
mode: 'multiple';
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* 基础 Select Props(公共属性)
|
|
155
|
-
* @template T 值的类型
|
|
156
|
-
*/
|
|
157
|
-
export interface BaseSelectProps<T = string | number> {
|
|
158
|
-
/**
|
|
159
|
-
* 选项列表(必填)
|
|
160
|
-
*/
|
|
161
|
-
options: SelectOption<T>[];
|
|
162
|
-
/**
|
|
163
|
-
* 占位符文本
|
|
164
|
-
* @default '请选择'
|
|
165
|
-
*/
|
|
166
|
-
placeholder?: string;
|
|
167
|
-
/**
|
|
168
|
-
* 是否显示搜索框
|
|
169
|
-
* @default false
|
|
170
|
-
*/
|
|
171
|
-
showSearch?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* 是否显示清空按钮
|
|
174
|
-
* @default false
|
|
175
|
-
*/
|
|
176
|
-
allowClear?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* 是否禁用
|
|
179
|
-
* @default false
|
|
180
|
-
*/
|
|
181
|
-
disabled?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* 是否只读
|
|
184
|
-
* @default false
|
|
185
|
-
*/
|
|
186
|
-
readOnly?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* 尺寸
|
|
189
|
-
* @default 'middle'
|
|
190
|
-
*/
|
|
191
|
-
size?: 'small' | 'middle' | 'large';
|
|
192
|
-
/**
|
|
193
|
-
* 自定义类名
|
|
194
|
-
*/
|
|
195
|
-
className?: string;
|
|
196
|
-
/**
|
|
197
|
-
* 自定义样式
|
|
198
|
-
*/
|
|
199
|
-
style?: React.CSSProperties;
|
|
200
|
-
/**
|
|
201
|
-
* 标签文本
|
|
202
|
-
*/
|
|
203
|
-
label?: string;
|
|
204
|
-
/**
|
|
205
|
-
* 辅助提示文本
|
|
206
|
-
*/
|
|
207
|
-
helperText?: string;
|
|
208
|
-
/**
|
|
209
|
-
* 是否必填
|
|
210
|
-
* @default false
|
|
211
|
-
*/
|
|
212
|
-
required?: boolean;
|
|
213
|
-
/**
|
|
214
|
-
* 是否显示错误状态
|
|
215
|
-
* @default false
|
|
216
|
-
*/
|
|
217
|
-
error?: boolean;
|
|
218
|
-
/**
|
|
219
|
-
* 错误提示文本
|
|
220
|
-
*/
|
|
221
|
-
errorText?: string;
|
|
222
|
-
/**
|
|
223
|
-
* 是否启用过滤
|
|
224
|
-
* @default false
|
|
225
|
-
*/
|
|
226
|
-
filterable?: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* 自定义过滤函数
|
|
229
|
-
*/
|
|
230
|
-
filterOption?: FilterOptionFunc<T>;
|
|
231
|
-
/**
|
|
232
|
-
* 是否启用排序
|
|
233
|
-
* @default false
|
|
234
|
-
*/
|
|
235
|
-
sortable?: boolean;
|
|
236
|
-
/**
|
|
237
|
-
* 排序方向
|
|
238
|
-
*/
|
|
239
|
-
sortDirection?: SortDirection;
|
|
240
|
-
/**
|
|
241
|
-
* 搜索输入回调
|
|
242
|
-
*/
|
|
243
|
-
onSearch?: (value: string) => void;
|
|
244
|
-
/**
|
|
245
|
-
* 获得焦点回调
|
|
246
|
-
*/
|
|
247
|
-
onFocus?: (event: React.FocusEvent) => void;
|
|
248
|
-
/**
|
|
249
|
-
* 失去焦点回调
|
|
250
|
-
*/
|
|
251
|
-
onBlur?: (event: React.FocusEvent) => void;
|
|
252
|
-
/**
|
|
253
|
-
* 下拉框显隐回调
|
|
254
|
-
*/
|
|
255
|
-
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
256
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Select 组件公共类型定义
|
|
3
|
+
* 供 PisellSingleSelect、PisellMultipleSelect 等组件使用
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export type { DisplayState } from '../common';
|
|
7
|
+
/**
|
|
8
|
+
* 选项基础类型
|
|
9
|
+
* @template T 选项值的类型,默认为 string | number
|
|
10
|
+
*/
|
|
11
|
+
export interface SelectOption<T = string | number> {
|
|
12
|
+
/**
|
|
13
|
+
* 选项值(唯一标识)
|
|
14
|
+
*/
|
|
15
|
+
value: T;
|
|
16
|
+
/**
|
|
17
|
+
* 选项显示文本
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* 是否禁用该选项
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 选项图标(可选)
|
|
27
|
+
*/
|
|
28
|
+
icon?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* 标签背景色(多选时用于自定义标签颜色)
|
|
31
|
+
* @example '#61dafb'
|
|
32
|
+
*/
|
|
33
|
+
color?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 选项过滤函数类型
|
|
37
|
+
* @template T 选项值的类型
|
|
38
|
+
* @param input 用户输入的搜索文本
|
|
39
|
+
* @param option 当前选项对象
|
|
40
|
+
* @returns 是否保留该选项
|
|
41
|
+
*/
|
|
42
|
+
export declare type FilterOptionFunc<T = string | number> = (input: string, option: SelectOption<T>) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 排序方向
|
|
45
|
+
*/
|
|
46
|
+
export declare type SortDirection = 'asc' | 'desc';
|
|
47
|
+
/**
|
|
48
|
+
* Select 状态 Hook 返回值(单选)
|
|
49
|
+
* @template T 值的类型
|
|
50
|
+
*/
|
|
51
|
+
export interface SelectState<T = string | number> {
|
|
52
|
+
/**
|
|
53
|
+
* 当前选中值
|
|
54
|
+
*/
|
|
55
|
+
value: T | null | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* 设置选中值
|
|
58
|
+
*/
|
|
59
|
+
setValue: (value: T | null) => void;
|
|
60
|
+
/**
|
|
61
|
+
* 清空选中值
|
|
62
|
+
*/
|
|
63
|
+
clearValue: () => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Multiple Select 状态 Hook 返回值(多选)
|
|
67
|
+
* @template T 值的类型
|
|
68
|
+
*/
|
|
69
|
+
export interface MultipleSelectState<T = string | number> {
|
|
70
|
+
/**
|
|
71
|
+
* 当前选中值数组
|
|
72
|
+
*/
|
|
73
|
+
value: T[];
|
|
74
|
+
/**
|
|
75
|
+
* 设置选中值数组
|
|
76
|
+
*/
|
|
77
|
+
setValue: (value: T[]) => void;
|
|
78
|
+
/**
|
|
79
|
+
* 添加一个选中值
|
|
80
|
+
*/
|
|
81
|
+
addValue: (value: T) => void;
|
|
82
|
+
/**
|
|
83
|
+
* 移除一个选中值
|
|
84
|
+
*/
|
|
85
|
+
removeValue: (value: T) => void;
|
|
86
|
+
/**
|
|
87
|
+
* 清空所有选中值
|
|
88
|
+
*/
|
|
89
|
+
clearValue: () => void;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 标签显示信息(多选专用)
|
|
93
|
+
* @template T 选项值的类型
|
|
94
|
+
*/
|
|
95
|
+
export interface TagDisplayInfo<T = string | number> {
|
|
96
|
+
/**
|
|
97
|
+
* 可见的标签列表
|
|
98
|
+
*/
|
|
99
|
+
visibleTags: SelectOption<T>[];
|
|
100
|
+
/**
|
|
101
|
+
* 隐藏的标签列表
|
|
102
|
+
*/
|
|
103
|
+
hiddenTags: SelectOption<T>[];
|
|
104
|
+
/**
|
|
105
|
+
* 隐藏的标签数量
|
|
106
|
+
*/
|
|
107
|
+
hiddenCount: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* useSelectState Hook 的配置选项(单选)
|
|
111
|
+
* @template T 值的类型
|
|
112
|
+
*/
|
|
113
|
+
export interface UseSelectStateOptions<T = string | number> {
|
|
114
|
+
/**
|
|
115
|
+
* 受控模式:当前值
|
|
116
|
+
*/
|
|
117
|
+
value?: T | null;
|
|
118
|
+
/**
|
|
119
|
+
* 非受控模式:默认值
|
|
120
|
+
*/
|
|
121
|
+
defaultValue?: T;
|
|
122
|
+
/**
|
|
123
|
+
* 值变化回调
|
|
124
|
+
*/
|
|
125
|
+
onChange?: (value: T | null, option: SelectOption<T> | null) => void;
|
|
126
|
+
/**
|
|
127
|
+
* 模式(用于类型区分)
|
|
128
|
+
*/
|
|
129
|
+
mode: 'single';
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* useMultipleSelectState Hook 的配置选项(多选)
|
|
133
|
+
* @template T 值的类型
|
|
134
|
+
*/
|
|
135
|
+
export interface UseMultipleSelectStateOptions<T = string | number> {
|
|
136
|
+
/**
|
|
137
|
+
* 受控模式:当前值数组
|
|
138
|
+
*/
|
|
139
|
+
value?: T[];
|
|
140
|
+
/**
|
|
141
|
+
* 非受控模式:默认值数组
|
|
142
|
+
*/
|
|
143
|
+
defaultValue?: T[];
|
|
144
|
+
/**
|
|
145
|
+
* 值变化回调
|
|
146
|
+
*/
|
|
147
|
+
onChange?: (value: T[], options: SelectOption<T>[]) => void;
|
|
148
|
+
/**
|
|
149
|
+
* 模式(用于类型区分)
|
|
150
|
+
*/
|
|
151
|
+
mode: 'multiple';
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 基础 Select Props(公共属性)
|
|
155
|
+
* @template T 值的类型
|
|
156
|
+
*/
|
|
157
|
+
export interface BaseSelectProps<T = string | number> {
|
|
158
|
+
/**
|
|
159
|
+
* 选项列表(必填)
|
|
160
|
+
*/
|
|
161
|
+
options: SelectOption<T>[];
|
|
162
|
+
/**
|
|
163
|
+
* 占位符文本
|
|
164
|
+
* @default '请选择'
|
|
165
|
+
*/
|
|
166
|
+
placeholder?: string;
|
|
167
|
+
/**
|
|
168
|
+
* 是否显示搜索框
|
|
169
|
+
* @default false
|
|
170
|
+
*/
|
|
171
|
+
showSearch?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* 是否显示清空按钮
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
allowClear?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* 是否禁用
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
disabled?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* 是否只读
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
readOnly?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* 尺寸
|
|
189
|
+
* @default 'middle'
|
|
190
|
+
*/
|
|
191
|
+
size?: 'small' | 'middle' | 'large';
|
|
192
|
+
/**
|
|
193
|
+
* 自定义类名
|
|
194
|
+
*/
|
|
195
|
+
className?: string;
|
|
196
|
+
/**
|
|
197
|
+
* 自定义样式
|
|
198
|
+
*/
|
|
199
|
+
style?: React.CSSProperties;
|
|
200
|
+
/**
|
|
201
|
+
* 标签文本
|
|
202
|
+
*/
|
|
203
|
+
label?: string;
|
|
204
|
+
/**
|
|
205
|
+
* 辅助提示文本
|
|
206
|
+
*/
|
|
207
|
+
helperText?: string;
|
|
208
|
+
/**
|
|
209
|
+
* 是否必填
|
|
210
|
+
* @default false
|
|
211
|
+
*/
|
|
212
|
+
required?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* 是否显示错误状态
|
|
215
|
+
* @default false
|
|
216
|
+
*/
|
|
217
|
+
error?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* 错误提示文本
|
|
220
|
+
*/
|
|
221
|
+
errorText?: string;
|
|
222
|
+
/**
|
|
223
|
+
* 是否启用过滤
|
|
224
|
+
* @default false
|
|
225
|
+
*/
|
|
226
|
+
filterable?: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* 自定义过滤函数
|
|
229
|
+
*/
|
|
230
|
+
filterOption?: FilterOptionFunc<T>;
|
|
231
|
+
/**
|
|
232
|
+
* 是否启用排序
|
|
233
|
+
* @default false
|
|
234
|
+
*/
|
|
235
|
+
sortable?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* 排序方向
|
|
238
|
+
*/
|
|
239
|
+
sortDirection?: SortDirection;
|
|
240
|
+
/**
|
|
241
|
+
* 搜索输入回调
|
|
242
|
+
*/
|
|
243
|
+
onSearch?: (value: string) => void;
|
|
244
|
+
/**
|
|
245
|
+
* 获得焦点回调
|
|
246
|
+
*/
|
|
247
|
+
onFocus?: (event: React.FocusEvent) => void;
|
|
248
|
+
/**
|
|
249
|
+
* 失去焦点回调
|
|
250
|
+
*/
|
|
251
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
252
|
+
/**
|
|
253
|
+
* 下拉框显隐回调
|
|
254
|
+
*/
|
|
255
|
+
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
256
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 选项过滤工具函数
|
|
3
|
-
*/
|
|
4
|
-
import type { SelectOption, FilterOptionFunc } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* 默认的选项过滤函数
|
|
7
|
-
* 根据 label 进行模糊匹配(不区分大小写)
|
|
8
|
-
* @template T 选项值的类型
|
|
9
|
-
* @param input 搜索输入文本
|
|
10
|
-
* @param option 选项对象
|
|
11
|
-
* @returns 是否保留该选项
|
|
12
|
-
*/
|
|
13
|
-
export declare function defaultFilterOption<T = string | number>(input: string, option: SelectOption<T>): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* 过滤选项列表
|
|
16
|
-
* @template T 选项值的类型
|
|
17
|
-
* @param options 原始选项列表
|
|
18
|
-
* @param searchText 搜索文本
|
|
19
|
-
* @param filterFunc 自定义过滤函数(可选)
|
|
20
|
-
* @returns 过滤后的选项列表
|
|
21
|
-
*/
|
|
22
|
-
export declare function filterOptions<T = string | number>(options: SelectOption<T>[], searchText: string, filterFunc?: FilterOptionFunc<T>): SelectOption<T>[];
|
|
1
|
+
/**
|
|
2
|
+
* 选项过滤工具函数
|
|
3
|
+
*/
|
|
4
|
+
import type { SelectOption, FilterOptionFunc } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* 默认的选项过滤函数
|
|
7
|
+
* 根据 label 进行模糊匹配(不区分大小写)
|
|
8
|
+
* @template T 选项值的类型
|
|
9
|
+
* @param input 搜索输入文本
|
|
10
|
+
* @param option 选项对象
|
|
11
|
+
* @returns 是否保留该选项
|
|
12
|
+
*/
|
|
13
|
+
export declare function defaultFilterOption<T = string | number>(input: string, option: SelectOption<T>): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 过滤选项列表
|
|
16
|
+
* @template T 选项值的类型
|
|
17
|
+
* @param options 原始选项列表
|
|
18
|
+
* @param searchText 搜索文本
|
|
19
|
+
* @param filterFunc 自定义过滤函数(可选)
|
|
20
|
+
* @returns 过滤后的选项列表
|
|
21
|
+
*/
|
|
22
|
+
export declare function filterOptions<T = string | number>(options: SelectOption<T>[], searchText: string, filterFunc?: FilterOptionFunc<T>): SelectOption<T>[];
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select 组件辅助函数
|
|
3
|
-
*/
|
|
4
|
-
import type { SelectOption } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* 根据值查找选项对象
|
|
7
|
-
* @template T 选项值的类型
|
|
8
|
-
* @param value 选项值
|
|
9
|
-
* @param options 选项列表
|
|
10
|
-
* @returns 找到的选项对象,如果没找到返回 undefined
|
|
11
|
-
*/
|
|
12
|
-
export declare function findOptionByValue<T = string | number>(value: T, options: SelectOption<T>[]): SelectOption<T> | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* 根据值数组查找选项对象数组
|
|
15
|
-
* @template T 选项值的类型
|
|
16
|
-
* @param values 选项值数组
|
|
17
|
-
* @param options 选项列表
|
|
18
|
-
* @returns 找到的选项对象数组
|
|
19
|
-
*/
|
|
20
|
-
export declare function findOptionsByValues<T = string | number>(values: T[], options: SelectOption<T>[]): SelectOption<T>[];
|
|
21
|
-
/**
|
|
22
|
-
* 判断选项是否被选中(单选)
|
|
23
|
-
* @template T 选项值的类型
|
|
24
|
-
* @param optionValue 选项值
|
|
25
|
-
* @param selectedValue 当前选中值
|
|
26
|
-
* @returns 是否选中
|
|
27
|
-
*/
|
|
28
|
-
export declare function isOptionSelected<T = string | number>(optionValue: T, selectedValue: T | null | undefined): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 判断选项是否被选中(多选)
|
|
31
|
-
* @template T 选项值的类型
|
|
32
|
-
* @param optionValue 选项值
|
|
33
|
-
* @param selectedValues 当前选中值数组
|
|
34
|
-
* @returns 是否选中
|
|
35
|
-
*/
|
|
36
|
-
export declare function isOptionSelectedInMultiple<T = string | number>(optionValue: T, selectedValues: T[]): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* 生成唯一 ID
|
|
39
|
-
* @param prefix ID 前缀
|
|
40
|
-
* @returns 唯一 ID
|
|
41
|
-
*/
|
|
42
|
-
export declare function generateId(prefix?: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* Select 组件辅助函数
|
|
3
|
+
*/
|
|
4
|
+
import type { SelectOption } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* 根据值查找选项对象
|
|
7
|
+
* @template T 选项值的类型
|
|
8
|
+
* @param value 选项值
|
|
9
|
+
* @param options 选项列表
|
|
10
|
+
* @returns 找到的选项对象,如果没找到返回 undefined
|
|
11
|
+
*/
|
|
12
|
+
export declare function findOptionByValue<T = string | number>(value: T, options: SelectOption<T>[]): SelectOption<T> | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* 根据值数组查找选项对象数组
|
|
15
|
+
* @template T 选项值的类型
|
|
16
|
+
* @param values 选项值数组
|
|
17
|
+
* @param options 选项列表
|
|
18
|
+
* @returns 找到的选项对象数组
|
|
19
|
+
*/
|
|
20
|
+
export declare function findOptionsByValues<T = string | number>(values: T[], options: SelectOption<T>[]): SelectOption<T>[];
|
|
21
|
+
/**
|
|
22
|
+
* 判断选项是否被选中(单选)
|
|
23
|
+
* @template T 选项值的类型
|
|
24
|
+
* @param optionValue 选项值
|
|
25
|
+
* @param selectedValue 当前选中值
|
|
26
|
+
* @returns 是否选中
|
|
27
|
+
*/
|
|
28
|
+
export declare function isOptionSelected<T = string | number>(optionValue: T, selectedValue: T | null | undefined): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 判断选项是否被选中(多选)
|
|
31
|
+
* @template T 选项值的类型
|
|
32
|
+
* @param optionValue 选项值
|
|
33
|
+
* @param selectedValues 当前选中值数组
|
|
34
|
+
* @returns 是否选中
|
|
35
|
+
*/
|
|
36
|
+
export declare function isOptionSelectedInMultiple<T = string | number>(optionValue: T, selectedValues: T[]): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 生成唯一 ID
|
|
39
|
+
* @param prefix ID 前缀
|
|
40
|
+
* @returns 唯一 ID
|
|
41
|
+
*/
|
|
42
|
+
export declare function generateId(prefix?: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select 工具函数导出
|
|
3
|
-
*/
|
|
4
|
-
export { calculateTagDisplay } from './tagAggregation';
|
|
5
|
-
export { filterOptions, defaultFilterOption } from './filterOptions';
|
|
6
|
-
export { sortOptions } from './sortOptions';
|
|
7
|
-
export { findOptionByValue, findOptionsByValues, isOptionSelected, isOptionSelectedInMultiple, generateId, } from './helpers';
|
|
1
|
+
/**
|
|
2
|
+
* Select 工具函数导出
|
|
3
|
+
*/
|
|
4
|
+
export { calculateTagDisplay } from './tagAggregation';
|
|
5
|
+
export { filterOptions, defaultFilterOption } from './filterOptions';
|
|
6
|
+
export { sortOptions } from './sortOptions';
|
|
7
|
+
export { findOptionByValue, findOptionsByValues, isOptionSelected, isOptionSelectedInMultiple, generateId, } from './helpers';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 选项排序工具函数
|
|
3
|
-
*/
|
|
4
|
-
import type { SelectOption, SortDirection } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* 排序选项列表
|
|
7
|
-
* @template T 选项值的类型
|
|
8
|
-
* @param options 原始选项列表
|
|
9
|
-
* @param direction 排序方向('asc' 升序 | 'desc' 降序)
|
|
10
|
-
* @returns 排序后的选项列表(新数组)
|
|
11
|
-
*/
|
|
12
|
-
export declare function sortOptions<T = string | number>(options: SelectOption<T>[], direction?: SortDirection): SelectOption<T>[];
|
|
1
|
+
/**
|
|
2
|
+
* 选项排序工具函数
|
|
3
|
+
*/
|
|
4
|
+
import type { SelectOption, SortDirection } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* 排序选项列表
|
|
7
|
+
* @template T 选项值的类型
|
|
8
|
+
* @param options 原始选项列表
|
|
9
|
+
* @param direction 排序方向('asc' 升序 | 'desc' 降序)
|
|
10
|
+
* @returns 排序后的选项列表(新数组)
|
|
11
|
+
*/
|
|
12
|
+
export declare function sortOptions<T = string | number>(options: SelectOption<T>[], direction?: SortDirection): SelectOption<T>[];
|