linkmore-design 1.1.12 → 1.1.13

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.
@@ -25,12 +25,26 @@ var LMCascader = function LMCascader(props) {
25
25
  dropdownClassName = props.dropdownClassName,
26
26
  _props$placeholder = props.placeholder,
27
27
  placeholder = _props$placeholder === void 0 ? '请选择' : _props$placeholder,
28
- others = __rest(props, ["children", "className", "dropdownClassName", "placeholder"]);
28
+ defaultLabel = props.defaultLabel,
29
+ others = __rest(props, ["children", "className", "dropdownClassName", "placeholder", "defaultLabel"]);
30
+
31
+ var displayRender = function displayRender(label, selectedOptions) {
32
+ var hasOptions = selectedOptions.some(function (v) {
33
+ return !!v;
34
+ });
35
+
36
+ if (!hasOptions && defaultLabel) {
37
+ return defaultLabel;
38
+ }
39
+
40
+ return label.join('/');
41
+ };
29
42
 
30
43
  return /*#__PURE__*/React.createElement(_Cascader, Object.assign({
31
44
  placeholder: placeholder,
32
45
  className: classNames(prefixCls, className),
33
- dropdownClassName: classNames(prefixDropdownCls, dropdownClassName)
46
+ dropdownClassName: classNames(prefixDropdownCls, dropdownClassName),
47
+ displayRender: displayRender
34
48
  }, others));
35
49
  };
36
50
 
@@ -47,17 +47,19 @@ var CLMSelect = /*#__PURE__*/forwardRef(function (props, ref) {
47
47
 
48
48
  if (options) {
49
49
  flag = !!options.some(function (v) {
50
- return v.value === value;
50
+ var _a, _b;
51
+
52
+ return v[(_b = (_a = props.fieldNames) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'value'] === value;
51
53
  });
52
54
  }
53
55
 
54
56
  return flag;
55
- }, [children, value, options]); // 重组value: 传入value但找不到options项时,展示默认label
57
+ }, [children, value, options, props.fieldNames]); // 重组value: 传入value但找不到options项时,展示默认label
56
58
 
57
59
  var resetValue = useMemo(function () {
58
60
  if (value && !hasOption) return defaultLabel !== null && defaultLabel !== void 0 ? defaultLabel : value;
59
61
  return value;
60
- }, [value, hasOption]);
62
+ }, [value, defaultLabel, hasOption]);
61
63
  return /*#__PURE__*/React.createElement(_Select, Object.assign({
62
64
  className: classNames(className, prefixCls),
63
65
  size: size,
@@ -37,12 +37,26 @@ var LMCascader = function LMCascader(props) {
37
37
  dropdownClassName = props.dropdownClassName,
38
38
  _props$placeholder = props.placeholder,
39
39
  placeholder = _props$placeholder === void 0 ? '请选择' : _props$placeholder,
40
- others = __rest(props, ["children", "className", "dropdownClassName", "placeholder"]);
40
+ defaultLabel = props.defaultLabel,
41
+ others = __rest(props, ["children", "className", "dropdownClassName", "placeholder", "defaultLabel"]);
42
+
43
+ var displayRender = function displayRender(label, selectedOptions) {
44
+ var hasOptions = selectedOptions.some(function (v) {
45
+ return !!v;
46
+ });
47
+
48
+ if (!hasOptions && defaultLabel) {
49
+ return defaultLabel;
50
+ }
51
+
52
+ return label.join('/');
53
+ };
41
54
 
42
55
  return /*#__PURE__*/_react.default.createElement(_cascader.default, Object.assign({
43
56
  placeholder: placeholder,
44
57
  className: (0, _classnames.default)(prefixCls, className),
45
- dropdownClassName: (0, _classnames.default)(prefixDropdownCls, dropdownClassName)
58
+ dropdownClassName: (0, _classnames.default)(prefixDropdownCls, dropdownClassName),
59
+ displayRender: displayRender
46
60
  }, others));
47
61
  };
48
62
 
@@ -62,17 +62,19 @@ var CLMSelect = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
62
62
 
63
63
  if (options) {
64
64
  flag = !!options.some(function (v) {
65
- return v.value === value;
65
+ var _a, _b;
66
+
67
+ return v[(_b = (_a = props.fieldNames) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'value'] === value;
66
68
  });
67
69
  }
68
70
 
69
71
  return flag;
70
- }, [children, value, options]); // 重组value: 传入value但找不到options项时,展示默认label
72
+ }, [children, value, options, props.fieldNames]); // 重组value: 传入value但找不到options项时,展示默认label
71
73
 
72
74
  var resetValue = (0, _react.useMemo)(function () {
73
75
  if (value && !hasOption) return defaultLabel !== null && defaultLabel !== void 0 ? defaultLabel : value;
74
76
  return value;
75
- }, [value, hasOption]);
77
+ }, [value, defaultLabel, hasOption]);
76
78
  return /*#__PURE__*/_react.default.createElement(_select.default, Object.assign({
77
79
  className: (0, _classnames.default)(className, prefixCls),
78
80
  size: size,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkmore-design",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "author": {
5
5
  "name": "nowthen",
6
6
  "email": "rnlvwyx@gmail.com"