@pisell/utils 3.0.6 → 3.0.7

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