@rc-component/select 1.5.2 → 1.6.1
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.
|
@@ -37,51 +37,54 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
37
37
|
}
|
|
38
38
|
return showSearch ? searchValue : '';
|
|
39
39
|
}, [combobox, activeValue, inputChanged, triggerOpen, searchValue, showSearch]);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
className: `${prefixCls}-content-value`,
|
|
45
|
-
style: mergedSearchValue ? {
|
|
46
|
-
visibility: 'hidden'
|
|
47
|
-
} : {}
|
|
48
|
-
};
|
|
40
|
+
const [optionClassName, optionStyle, optionTitle, hasOptionStyle] = React.useMemo(() => {
|
|
41
|
+
let className;
|
|
42
|
+
let style;
|
|
43
|
+
let titleValue;
|
|
49
44
|
if (displayValue && selectContext?.flattenOptions) {
|
|
50
45
|
const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
|
|
51
46
|
if (option?.data) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} = option.data;
|
|
56
|
-
Object.assign(restProps, {
|
|
57
|
-
title: getTitle(option.data),
|
|
58
|
-
className: clsx(restProps.className, className),
|
|
59
|
-
style: {
|
|
60
|
-
...restProps.style,
|
|
61
|
-
...style
|
|
62
|
-
}
|
|
63
|
-
});
|
|
47
|
+
className = option.data.className;
|
|
48
|
+
style = option.data.style;
|
|
49
|
+
titleValue = getTitle(option.data);
|
|
64
50
|
}
|
|
65
51
|
}
|
|
66
|
-
if (displayValue && !
|
|
67
|
-
|
|
52
|
+
if (displayValue && !titleValue) {
|
|
53
|
+
titleValue = getTitle(displayValue);
|
|
68
54
|
}
|
|
69
55
|
if (rootTitle !== undefined) {
|
|
70
|
-
|
|
56
|
+
titleValue = rootTitle;
|
|
71
57
|
}
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
const nextHasStyle = !!className || !!style;
|
|
59
|
+
return [className, style, titleValue, nextHasStyle];
|
|
60
|
+
}, [displayValue, selectContext?.flattenOptions, rootTitle]);
|
|
74
61
|
React.useEffect(() => {
|
|
75
62
|
if (combobox) {
|
|
76
63
|
setInputChanged(false);
|
|
77
64
|
}
|
|
78
65
|
}, [combobox, activeValue]);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
|
|
67
|
+
// ========================== Render ==========================
|
|
68
|
+
// Render value
|
|
69
|
+
const renderValue = displayValue ? hasOptionStyle ? /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: clsx(`${prefixCls}-content-value`, optionClassName),
|
|
71
|
+
style: {
|
|
72
|
+
...(mergedSearchValue ? {
|
|
73
|
+
visibility: 'hidden'
|
|
74
|
+
} : {}),
|
|
75
|
+
...optionStyle
|
|
76
|
+
},
|
|
77
|
+
title: optionTitle
|
|
78
|
+
}, displayValue.label) : displayValue.label : /*#__PURE__*/React.createElement(Placeholder, {
|
|
83
79
|
show: !mergedSearchValue
|
|
84
|
-
})
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Render
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: clsx(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, classNames?.content),
|
|
85
|
+
style: styles?.content,
|
|
86
|
+
title: hasOptionStyle ? undefined : optionTitle
|
|
87
|
+
}, renderValue, /*#__PURE__*/React.createElement(Input, _extends({
|
|
85
88
|
ref: ref
|
|
86
89
|
}, inputProps, {
|
|
87
90
|
value: mergedSearchValue,
|
|
@@ -46,51 +46,54 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
46
46
|
}
|
|
47
47
|
return showSearch ? searchValue : '';
|
|
48
48
|
}, [combobox, activeValue, inputChanged, triggerOpen, searchValue, showSearch]);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
className: `${prefixCls}-content-value`,
|
|
54
|
-
style: mergedSearchValue ? {
|
|
55
|
-
visibility: 'hidden'
|
|
56
|
-
} : {}
|
|
57
|
-
};
|
|
49
|
+
const [optionClassName, optionStyle, optionTitle, hasOptionStyle] = React.useMemo(() => {
|
|
50
|
+
let className;
|
|
51
|
+
let style;
|
|
52
|
+
let titleValue;
|
|
58
53
|
if (displayValue && selectContext?.flattenOptions) {
|
|
59
54
|
const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
|
|
60
55
|
if (option?.data) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} = option.data;
|
|
65
|
-
Object.assign(restProps, {
|
|
66
|
-
title: (0, _commonUtil.getTitle)(option.data),
|
|
67
|
-
className: (0, _clsx.clsx)(restProps.className, className),
|
|
68
|
-
style: {
|
|
69
|
-
...restProps.style,
|
|
70
|
-
...style
|
|
71
|
-
}
|
|
72
|
-
});
|
|
56
|
+
className = option.data.className;
|
|
57
|
+
style = option.data.style;
|
|
58
|
+
titleValue = (0, _commonUtil.getTitle)(option.data);
|
|
73
59
|
}
|
|
74
60
|
}
|
|
75
|
-
if (displayValue && !
|
|
76
|
-
|
|
61
|
+
if (displayValue && !titleValue) {
|
|
62
|
+
titleValue = (0, _commonUtil.getTitle)(displayValue);
|
|
77
63
|
}
|
|
78
64
|
if (rootTitle !== undefined) {
|
|
79
|
-
|
|
65
|
+
titleValue = rootTitle;
|
|
80
66
|
}
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
const nextHasStyle = !!className || !!style;
|
|
68
|
+
return [className, style, titleValue, nextHasStyle];
|
|
69
|
+
}, [displayValue, selectContext?.flattenOptions, rootTitle]);
|
|
83
70
|
React.useEffect(() => {
|
|
84
71
|
if (combobox) {
|
|
85
72
|
setInputChanged(false);
|
|
86
73
|
}
|
|
87
74
|
}, [combobox, activeValue]);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
|
|
76
|
+
// ========================== Render ==========================
|
|
77
|
+
// Render value
|
|
78
|
+
const renderValue = displayValue ? hasOptionStyle ? /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: (0, _clsx.clsx)(`${prefixCls}-content-value`, optionClassName),
|
|
80
|
+
style: {
|
|
81
|
+
...(mergedSearchValue ? {
|
|
82
|
+
visibility: 'hidden'
|
|
83
|
+
} : {}),
|
|
84
|
+
...optionStyle
|
|
85
|
+
},
|
|
86
|
+
title: optionTitle
|
|
87
|
+
}, displayValue.label) : displayValue.label : /*#__PURE__*/React.createElement(_Placeholder.default, {
|
|
92
88
|
show: !mergedSearchValue
|
|
93
|
-
})
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Render
|
|
92
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
className: (0, _clsx.clsx)(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, classNames?.content),
|
|
94
|
+
style: styles?.content,
|
|
95
|
+
title: hasOptionStyle ? undefined : optionTitle
|
|
96
|
+
}, renderValue, /*#__PURE__*/React.createElement(_Input.default, _extends({
|
|
94
97
|
ref: ref
|
|
95
98
|
}, inputProps, {
|
|
96
99
|
value: mergedSearchValue,
|