zy-react-library 1.0.164 → 1.0.165
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,5 +1,5 @@
|
|
|
1
1
|
import type { SelectProps } from "antd/es/select";
|
|
2
|
-
import type { FC } from "react";
|
|
2
|
+
import type { FC, ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
@@ -19,11 +19,13 @@ export interface BasicSelectProps extends SelectProps {
|
|
|
19
19
|
onGetOption?: (option: Record<string, any> | Record<string, any>[]) => void;
|
|
20
20
|
/** 获取数据 */
|
|
21
21
|
onGetData?: (data: Record<string, any>[]) => void;
|
|
22
|
+
/** 自定义 label 的渲染函数 */
|
|
23
|
+
labelRender?: (item: Record<string, any>) => ReactNode;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* 基础下拉组件(不建议直接使用此组件,二次继承使用)
|
|
26
28
|
*/
|
|
27
|
-
declare const
|
|
29
|
+
declare const BasicSelect: FC<BasicSelectProps>;
|
|
28
30
|
|
|
29
|
-
export default
|
|
31
|
+
export default BasicSelect;
|
|
@@ -14,6 +14,7 @@ function BasicSelect(props) {
|
|
|
14
14
|
data = [],
|
|
15
15
|
nameKey = "name",
|
|
16
16
|
idKey = "id",
|
|
17
|
+
labelRender,
|
|
17
18
|
...restProps
|
|
18
19
|
} = props;
|
|
19
20
|
|
|
@@ -59,7 +60,7 @@ function BasicSelect(props) {
|
|
|
59
60
|
<Select placeholder={`请选择${placeholder}`} showSearch allowClear optionFilterProp="children" onChange={handleChange} {...restProps}>
|
|
60
61
|
{data.map((item) => {
|
|
61
62
|
const value = item[idKey];
|
|
62
|
-
const label = item[nameKey];
|
|
63
|
+
const label = labelRender ? labelRender(item) : item[nameKey];
|
|
63
64
|
return (
|
|
64
65
|
<Select.Option key={value} value={value}>
|
|
65
66
|
{label}
|