@rc-component/select 1.6.5 → 1.6.6

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.
@@ -29,6 +29,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
29
29
  const [inputChanged, setInputChanged] = React.useState(false);
30
30
  const combobox = mode === 'combobox';
31
31
  const displayValue = displayValues[0];
32
+ const hasDisplayValue = displayValue !== null && displayValue !== undefined;
32
33
 
33
34
  // Implement the same logic as the old SingleSelector
34
35
  const mergedSearchValue = React.useMemo(() => {
@@ -41,7 +42,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
41
42
  let className;
42
43
  let style;
43
44
  let titleValue;
44
- if (displayValue && selectContext?.flattenOptions) {
45
+ if (hasDisplayValue && selectContext?.flattenOptions) {
45
46
  const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
46
47
  if (option?.data) {
47
48
  className = option.data.className;
@@ -49,7 +50,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
49
50
  titleValue = getTitle(option.data);
50
51
  }
51
52
  }
52
- if (displayValue && !titleValue) {
53
+ if (hasDisplayValue && !titleValue) {
53
54
  titleValue = getTitle(displayValue);
54
55
  }
55
56
  if (rootTitle !== undefined) {
@@ -66,7 +67,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
66
67
 
67
68
  // ========================== Render ==========================
68
69
  // Render value
69
- const renderValue = displayValue ? hasOptionStyle ? /*#__PURE__*/React.createElement("div", {
70
+ const renderValue = hasDisplayValue ? hasOptionStyle ? /*#__PURE__*/React.createElement("div", {
70
71
  className: clsx(`${prefixCls}-content-value`, optionClassName),
71
72
  style: {
72
73
  ...(mergedSearchValue ? {
@@ -81,7 +82,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
81
82
 
82
83
  // Render
83
84
  return /*#__PURE__*/React.createElement("div", {
84
- className: clsx(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, mergedSearchValue && `${prefixCls}-content-has-search-value`, hasOptionStyle && `${prefixCls}-content-has-option-style`, classNames?.content),
85
+ className: clsx(`${prefixCls}-content`, hasDisplayValue && `${prefixCls}-content-has-value`, mergedSearchValue && `${prefixCls}-content-has-search-value`, hasOptionStyle && `${prefixCls}-content-has-option-style`, classNames?.content),
85
86
  style: styles?.content,
86
87
  title: hasOptionStyle ? undefined : optionTitle
87
88
  }, renderValue, /*#__PURE__*/React.createElement(Input, _extends({
@@ -38,6 +38,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
38
38
  const [inputChanged, setInputChanged] = React.useState(false);
39
39
  const combobox = mode === 'combobox';
40
40
  const displayValue = displayValues[0];
41
+ const hasDisplayValue = displayValue !== null && displayValue !== undefined;
41
42
 
42
43
  // Implement the same logic as the old SingleSelector
43
44
  const mergedSearchValue = React.useMemo(() => {
@@ -50,7 +51,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
50
51
  let className;
51
52
  let style;
52
53
  let titleValue;
53
- if (displayValue && selectContext?.flattenOptions) {
54
+ if (hasDisplayValue && selectContext?.flattenOptions) {
54
55
  const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
55
56
  if (option?.data) {
56
57
  className = option.data.className;
@@ -58,7 +59,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
58
59
  titleValue = (0, _commonUtil.getTitle)(option.data);
59
60
  }
60
61
  }
61
- if (displayValue && !titleValue) {
62
+ if (hasDisplayValue && !titleValue) {
62
63
  titleValue = (0, _commonUtil.getTitle)(displayValue);
63
64
  }
64
65
  if (rootTitle !== undefined) {
@@ -75,7 +76,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
75
76
 
76
77
  // ========================== Render ==========================
77
78
  // Render value
78
- const renderValue = displayValue ? hasOptionStyle ? /*#__PURE__*/React.createElement("div", {
79
+ const renderValue = hasDisplayValue ? hasOptionStyle ? /*#__PURE__*/React.createElement("div", {
79
80
  className: (0, _clsx.clsx)(`${prefixCls}-content-value`, optionClassName),
80
81
  style: {
81
82
  ...(mergedSearchValue ? {
@@ -90,7 +91,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
90
91
 
91
92
  // Render
92
93
  return /*#__PURE__*/React.createElement("div", {
93
- className: (0, _clsx.clsx)(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, mergedSearchValue && `${prefixCls}-content-has-search-value`, hasOptionStyle && `${prefixCls}-content-has-option-style`, classNames?.content),
94
+ className: (0, _clsx.clsx)(`${prefixCls}-content`, hasDisplayValue && `${prefixCls}-content-has-value`, mergedSearchValue && `${prefixCls}-content-has-search-value`, hasOptionStyle && `${prefixCls}-content-has-option-style`, classNames?.content),
94
95
  style: styles?.content,
95
96
  title: hasOptionStyle ? undefined : optionTitle
96
97
  }, renderValue, /*#__PURE__*/React.createElement(_Input.default, _extends({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/select",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"