@cloudtower/eagle 490.0.6 → 490.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.
@@ -1,78 +1,149 @@
1
1
  /// <reference types="react" />
2
2
  import { InputProps } from "antd/lib/input";
3
3
  import { SrcType } from "../BaseIcon";
4
+ /**
5
+ * @description 搜索输入框组件,基于 Input 封装,提供防抖搜索、结果导航(上一个/下一个)和最近搜索历史功能。
6
+ * 支持受控和非受控两种模式,适用于表格内搜索、页面全局搜索等场景。
7
+ *
8
+ * @example
9
+ * 基础搜索(带防抖):
10
+ * ```tsx
11
+ * import React, { useState } from "react";
12
+ * import { SearchInput } from "@cloudtower/eagle";
13
+ *
14
+ * const App = () => {
15
+ * const [keyword, setKeyword] = useState("");
16
+ * return (
17
+ * <SearchInput
18
+ * debounceWait={300}
19
+ * onChange={(value) => setKeyword(value)}
20
+ * />
21
+ * );
22
+ * };
23
+ * ```
24
+ *
25
+ * @example
26
+ * 带结果导航(显示匹配数和上下翻页):
27
+ * ```tsx
28
+ * import React from "react";
29
+ * import { SearchInput } from "@cloudtower/eagle";
30
+ *
31
+ * const App = () => (
32
+ * <SearchInput
33
+ * total={10}
34
+ * onChange={(value) => console.log("搜索:", value)}
35
+ * onSearchNext={(value, current) => console.log("下一个:", current)}
36
+ * onSearchPrev={(value, current) => console.log("上一个:", current)}
37
+ * />
38
+ * );
39
+ * ```
40
+ *
41
+ * @example
42
+ * 启用最近搜索历史:
43
+ * ```tsx
44
+ * import React from "react";
45
+ * import { SearchInput } from "@cloudtower/eagle";
46
+ *
47
+ * const App = () => (
48
+ * <SearchInput
49
+ * enableRecentSearch
50
+ * recentSearchLocalStorageKey="vm-search"
51
+ * maxRecentCount={5}
52
+ * onChange={(value) => console.log(value)}
53
+ * />
54
+ * );
55
+ * ```
56
+ *
57
+ * @see Input 基础输入框
58
+ * @see Cascader 级联选择器(内置了 SearchInput 作为搜索区域)
59
+ */
4
60
  export type SearchInputProps = Omit<InputProps, "value" | "onChange"> & {
5
61
  /**
6
- * 配置 value 时,需把 debounceWait 设置为 0 ,否则输入时会有卡顿的问题
62
+ * 输入框的值,用于受控模式。
63
+ * 配置 value 时,需把 debounceWait 设置为 0,否则输入时会有卡顿的问题
7
64
  */
8
65
  value?: InputProps["value"];
9
66
  /**
10
- * 防抖延迟的时间,单位为毫秒,默认为 300ms
67
+ * 防抖延迟时间,单位为毫秒。输入停止后延迟指定时间再触发 onChange
68
+ * @default 300
11
69
  */
12
70
  debounceWait?: number;
13
71
  /**
14
- * 搜索结果的总数
72
+ * 搜索结果的总数。设置后,当同时提供 onSearchNext 和 onSearchPrev 时,
73
+ * 输入框后缀区域将显示 "current/total" 计数器和上下翻页按钮
15
74
  */
16
75
  total?: number;
17
76
  /**
18
- * 当前选中的结果索引,可用于外部控制当前位置
77
+ * 当前选中的结果索引(从 1 开始),可用于外部控制当前位置。
19
78
  * 如果不提供,组件将内部管理此状态
20
79
  */
21
80
  current?: number;
22
81
  /**
23
- * 搜索下一个结果时的回调函数
82
+ * 点击"下一个"按钮或按下 Enter 键时的回调。
83
+ * 需同时提供 onSearchPrev 才会显示导航按钮
84
+ * @param value - 当前搜索关键词
85
+ * @param current - 导航后的结果索引
24
86
  */
25
87
  onSearchNext?: (value: string, current: number) => void;
26
88
  /**
27
- * 搜索上一个结果时的回调函数
89
+ * 点击"上一个"按钮时的回调。
90
+ * 需同时提供 onSearchNext 才会显示导航按钮
91
+ * @param value - 当前搜索关键词
92
+ * @param current - 导航后的结果索引
28
93
  */
29
94
  onSearchPrev?: (value: string, current: number) => void;
30
95
  /**
31
- * 输入内容改变时的回调函数
96
+ * 输入内容改变时的回调函数(经过防抖处理后触发)
97
+ * @param value - 当前输入的搜索关键词
32
98
  */
33
99
  onChange: (value: string) => void;
34
100
  /**
35
- * 搜索的图标
101
+ * 自定义搜索图标(输入框前缀),替换默认的放大镜图标
36
102
  */
37
103
  searchIcon?: SrcType;
38
104
  /**
39
- * 上一个图标
105
+ * 自定义"上一个"按钮的默认态图标
40
106
  */
41
107
  prefixIcon?: SrcType;
42
108
  /**
43
- * 上一个 hover 时的图标
109
+ * 自定义"上一个"按钮的 hover 态图标
44
110
  */
45
111
  prefixHoverIcon?: SrcType;
46
112
  /**
47
- * 下一个图标
113
+ * 自定义"下一个"按钮的默认态图标
48
114
  */
49
115
  nextIcon?: SrcType;
50
116
  /**
51
- * 下一个 hover 时的图标
117
+ * 自定义"下一个"按钮的 hover 态图标
52
118
  */
53
119
  nextHoverIcon?: SrcType;
54
120
  /**
55
- * 清空图标
121
+ * 自定义清空按钮的默认态图标
56
122
  */
57
123
  clearIcon?: SrcType;
58
124
  /**
59
- * 清空 hover 时的图标
125
+ * 自定义清空按钮的 hover 态图标
60
126
  */
61
127
  clearHoverIcon?: SrcType;
62
128
  /**
63
- * 搜索框高度,默认为 276
129
+ * 搜索框宽度
130
+ * @default 276
64
131
  */
65
132
  width?: number | string;
66
133
  /**
67
- * 是否开启最近搜索功能
134
+ * 是否开启最近搜索功能。开启后,聚焦空输入框时会显示最近搜索记录的下拉菜单。
135
+ * 搜索记录通过 localStorage 持久化存储
136
+ * @default false
68
137
  */
69
138
  enableRecentSearch?: boolean;
70
139
  /**
71
- * 最近搜索的本地存储键
140
+ * 最近搜索记录在 localStorage 中的存储键名。
141
+ * 开启 enableRecentSearch 时必须提供,不同业务场景应使用不同的 key 以隔离数据
72
142
  */
73
143
  recentSearchLocalStorageKey?: string;
74
144
  /**
75
- * 最多展示多少条最新的搜索记录,默认 5 条
145
+ * 最近搜索记录的最大展示条数
146
+ * @default 5
76
147
  */
77
148
  maxRecentCount?: number;
78
149
  };