zy-react-library 1.0.164 → 1.0.166
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.
|
@@ -253,7 +253,7 @@ const FormItemsRenderer = ({
|
|
|
253
253
|
<Select placeholder={placeholder} showSearch allowClear optionFilterProp="children" {...componentProps}>
|
|
254
254
|
{(option.items || []).map((item) => {
|
|
255
255
|
const value = item[itemsFieldKey.valueKey];
|
|
256
|
-
const label = item[itemsFieldKey.labelKey];
|
|
256
|
+
const label = item[typeof itemsFieldKey.labelKey === "function" ? itemsFieldKey.labelKey(item) : itemsFieldKey.labelKey];
|
|
257
257
|
return (
|
|
258
258
|
<Select.Option key={value} value={value}>
|
|
259
259
|
{label}
|
|
@@ -268,7 +268,7 @@ const FormItemsRenderer = ({
|
|
|
268
268
|
<Radio.Group {...componentProps}>
|
|
269
269
|
{(option.items || []).map((item) => {
|
|
270
270
|
const value = item[itemsFieldKey.valueKey];
|
|
271
|
-
const label = item[itemsFieldKey.labelKey];
|
|
271
|
+
const label = item[typeof itemsFieldKey.labelKey === "function" ? itemsFieldKey.labelKey(item) : itemsFieldKey.labelKey];
|
|
272
272
|
return (
|
|
273
273
|
<Radio key={value} value={value}>
|
|
274
274
|
{label}
|
|
@@ -283,7 +283,7 @@ const FormItemsRenderer = ({
|
|
|
283
283
|
<Checkbox.Group {...componentProps}>
|
|
284
284
|
{(option.items || []).map((item) => {
|
|
285
285
|
const value = item[itemsFieldKey.valueKey];
|
|
286
|
-
const label = item[itemsFieldKey.labelKey];
|
|
286
|
+
const label = item[typeof itemsFieldKey.labelKey === "function" ? itemsFieldKey.labelKey(item) : itemsFieldKey.labelKey];
|
|
287
287
|
return (
|
|
288
288
|
<Checkbox key={value} value={value}>
|
|
289
289
|
{label}
|
|
@@ -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}
|