@ucloud-fe/react-components 1.5.6 → 1.5.7

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,3 +1,6 @@
1
+ /**
2
+ * TODO 需求时间比较紧、大部分时间用作兼容和考虑交互各种遗漏,代码未整合,有时间可以将 selector、popup 中的代码进行抽离
3
+ */
1
4
  import React, { ReactNode } from 'react';
2
5
  import { Size } from '../../type';
3
6
  import { Key } from '../../hooks/group';
@@ -80,7 +80,7 @@ var _this7 = void 0;
80
80
  var _excluded = ["v1"],
81
81
  _excluded2 = ["content"],
82
82
  _excluded3 = ["content"],
83
- _excluded4 = ["v1", "size", "disabled", "multiple", "placeholder", "renderContent", "renderSelector", "renderPopup", "value", "onChange", "visible", "locale", "dataSource", "search", "searchValue", "setSearchValue", "wrapRef", "clearable", "styleType", "block"],
83
+ _excluded4 = ["v1", "size", "disabled", "multiple", "placeholder", "renderContent", "renderSelector", "renderPopup", "value", "onChange", "visible", "setVisible", "locale", "dataSource", "search", "searchValue", "setSearchValue", "wrapRef", "clearable", "styleType", "block"],
84
84
  _excluded5 = ["items", "onClose", "disabled"],
85
85
  _excluded6 = ["size", "value", "defaultValue", "onChange", "onVisibleChange", "disabled", "search", "multiple", "renderContent", "renderSelector", "placeholder", "locale", "options", "children", "emptyContent", "showSelectAll", "extra", "clearable", "customStyle", "popover", "popoverProps", "renderPopup", "virtualList", "block", "styleType"];
86
86
 
@@ -558,6 +558,7 @@ var Selector = /*#__PURE__*/_react.default.memo(function Selector(_ref13) {
558
558
  value = _ref13.value,
559
559
  onChange = _ref13.onChange,
560
560
  visible = _ref13.visible,
561
+ setVisible = _ref13.setVisible,
561
562
  locale = _ref13.locale,
562
563
  dataSource = _ref13.dataSource,
563
564
  search = _ref13.search,
@@ -580,6 +581,7 @@ var Selector = /*#__PURE__*/_react.default.memo(function Selector(_ref13) {
580
581
  value: value,
581
582
  onChange: onChange,
582
583
  visible: visible,
584
+ setVisible: setVisible,
583
585
  locale: locale,
584
586
  dataSource: dataSource,
585
587
  search: search,
@@ -786,6 +788,7 @@ var MultipleListSelector = /*#__PURE__*/_react.default.memo(function MultipleSel
786
788
  var size = props.size,
787
789
  disabled = props.disabled,
788
790
  visible = props.visible,
791
+ setVisible = props.setVisible,
789
792
  dataSource = props.dataSource,
790
793
  value = props.value,
791
794
  onChange = props.onChange,
@@ -850,21 +853,20 @@ var MultipleListSelector = /*#__PURE__*/_react.default.memo(function MultipleSel
850
853
  e.preventDefault();
851
854
 
852
855
  if (!disabled) {
853
- var _inputRef$current2;
856
+ onChange === null || onChange === void 0 ? void 0 : onChange([]); // inputRef.current?.focus();
854
857
 
855
- onChange === null || onChange === void 0 ? void 0 : onChange([]);
856
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
858
+ setVisible(false);
857
859
  }
858
- }.bind(this), [disabled, onChange]);
860
+ }.bind(this), [disabled, onChange, setVisible]);
859
861
  var empty = (0, _react.useMemo)(function () {
860
862
  (0, _newArrowCheck2.default)(this, _this13);
861
863
  return !(value !== null && value !== void 0 && value.length);
862
864
  }.bind(this), [value]);
863
865
  var handleSelectorClick = (0, _react.useCallback)(function (e) {
864
- var _inputRef$current3, _popupProps$onClick;
866
+ var _inputRef$current2, _popupProps$onClick;
865
867
 
866
868
  (0, _newArrowCheck2.default)(this, _this13);
867
- (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus();
869
+ (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
868
870
  (_popupProps$onClick = _popupProps.onClick) === null || _popupProps$onClick === void 0 ? void 0 : _popupProps$onClick.call(_popupProps, e);
869
871
  }.bind(this), [_popupProps]);
870
872
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_style2.SSelectorMultiple, (0, _extends2.default)({
@@ -891,10 +893,10 @@ var MultipleListSelector = /*#__PURE__*/_react.default.memo(function MultipleSel
891
893
  clearable: clearable && !empty,
892
894
  onClick: handleClear
893
895
  }), /*#__PURE__*/_react.default.createElement(_style.InputPart, null, /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
894
- type: visible ? search ? 'search' : 'arrow-up' : 'arrow-down'
895
- }))), items.length ? /*#__PURE__*/_react.default.createElement("div", {
896
+ type: visible ? 'arrow-up' : 'arrow-down'
897
+ }))), items.length ? /*#__PURE__*/_react.default.createElement(_Tag.default.Group, null, /*#__PURE__*/_react.default.createElement("div", {
896
898
  className: _style2.listCls
897
- }, /*#__PURE__*/_react.default.createElement(_Tag.default.Group, null, items.map(renderItem))) : null);
899
+ }, items.map(renderItem))) : null);
898
900
  });
899
901
 
900
902
  var MultipleSelector = /*#__PURE__*/_react.default.memo(function MultipleSelector(props) {
@@ -903,6 +905,7 @@ var MultipleSelector = /*#__PURE__*/_react.default.memo(function MultipleSelecto
903
905
  var size = props.size,
904
906
  disabled = props.disabled,
905
907
  visible = props.visible,
908
+ setVisible = props.setVisible,
906
909
  dataSource = props.dataSource,
907
910
  value = props.value,
908
911
  onChange = props.onChange,
@@ -981,10 +984,10 @@ var MultipleSelector = /*#__PURE__*/_react.default.memo(function MultipleSelecto
981
984
  setSearchValue(e.target.value);
982
985
  }.bind(this), [setSearchValue]);
983
986
  (0, _react.useEffect)(function () {
984
- var _inputRef$current4;
987
+ var _inputRef$current3;
985
988
 
986
989
  (0, _newArrowCheck2.default)(this, _this16);
987
- if (visible) (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus();
990
+ if (visible) (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus();
988
991
  }.bind(this), [visible]);
989
992
  var handleClear = (0, _react.useCallback)(function (e) {
990
993
  (0, _newArrowCheck2.default)(this, _this16);
@@ -992,21 +995,20 @@ var MultipleSelector = /*#__PURE__*/_react.default.memo(function MultipleSelecto
992
995
  e.preventDefault();
993
996
 
994
997
  if (!disabled) {
995
- var _inputRef$current5;
998
+ onChange === null || onChange === void 0 ? void 0 : onChange([]); // inputRef.current?.focus();
996
999
 
997
- onChange === null || onChange === void 0 ? void 0 : onChange([]);
998
- (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.focus();
1000
+ setVisible(false);
999
1001
  }
1000
- }.bind(this), [disabled, onChange]);
1002
+ }.bind(this), [disabled, onChange, setVisible]);
1001
1003
  var empty = (0, _react.useMemo)(function () {
1002
1004
  (0, _newArrowCheck2.default)(this, _this16);
1003
1005
  return !(value !== null && value !== void 0 && value.length);
1004
1006
  }.bind(this), [value]);
1005
1007
  var handleSelectorClick = (0, _react.useCallback)(function (e) {
1006
- var _inputRef$current6, _popupProps$onClick2;
1008
+ var _inputRef$current4, _popupProps$onClick2;
1007
1009
 
1008
1010
  (0, _newArrowCheck2.default)(this, _this16);
1009
- (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.focus();
1011
+ (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus();
1010
1012
  (_popupProps$onClick2 = _popupProps.onClick) === null || _popupProps$onClick2 === void 0 ? void 0 : _popupProps$onClick2.call(_popupProps, e);
1011
1013
  }.bind(this), [_popupProps]);
1012
1014
 
@@ -1069,6 +1071,7 @@ var SingleSelector = /*#__PURE__*/_react.default.memo(function SingleSelector(_r
1069
1071
  value = _ref18.value,
1070
1072
  onChange = _ref18.onChange,
1071
1073
  visible = _ref18.visible,
1074
+ setVisible = _ref18.setVisible,
1072
1075
  dataSource = _ref18.dataSource,
1073
1076
  search = _ref18.search,
1074
1077
  _ref18$searchValue = _ref18.searchValue,
@@ -1120,10 +1123,10 @@ var SingleSelector = /*#__PURE__*/_react.default.memo(function SingleSelector(_r
1120
1123
  }, _popupProps);
1121
1124
 
1122
1125
  (0, _react.useEffect)(function () {
1123
- var _inputRef$current7;
1126
+ var _inputRef$current5;
1124
1127
 
1125
1128
  (0, _newArrowCheck2.default)(this, _this19);
1126
- if (visible) (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : _inputRef$current7.focus();
1129
+ if (visible) (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.focus();
1127
1130
  }.bind(this), [visible]);
1128
1131
  var handleClear = (0, _react.useCallback)(function (e) {
1129
1132
  (0, _newArrowCheck2.default)(this, _this19);
@@ -1131,12 +1134,11 @@ var SingleSelector = /*#__PURE__*/_react.default.memo(function SingleSelector(_r
1131
1134
  e.stopPropagation();
1132
1135
 
1133
1136
  if (!disabled) {
1134
- var _inputRef$current8;
1137
+ onChange === null || onChange === void 0 ? void 0 : onChange(undefined); // inputRef.current?.focus();
1135
1138
 
1136
- onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
1137
- (_inputRef$current8 = inputRef.current) === null || _inputRef$current8 === void 0 ? void 0 : _inputRef$current8.focus();
1139
+ setVisible(false);
1138
1140
  }
1139
- }.bind(this), [disabled, onChange]);
1141
+ }.bind(this), [disabled, onChange, setVisible]);
1140
1142
  return /*#__PURE__*/_react.default.createElement(_style2.SSelectorSingle, sharedProps, /*#__PURE__*/_react.default.createElement(_style.InputPart, {
1141
1143
  stretch: true,
1142
1144
  className: _style2.inputWrapCls
@@ -1160,7 +1162,7 @@ var SingleSelector = /*#__PURE__*/_react.default.memo(function SingleSelector(_r
1160
1162
  clearable: clearable && !empty,
1161
1163
  onClick: handleClear
1162
1164
  }), /*#__PURE__*/_react.default.createElement(_style.InputPart, null, /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
1163
- type: visible ? search ? 'search' : 'arrow-up' : 'arrow-down'
1165
+ type: visible ? 'arrow-up' : 'arrow-down'
1164
1166
  })));
1165
1167
  });
1166
1168
 
@@ -1319,6 +1321,12 @@ var Select = function Select(_ref19) {
1319
1321
  _useState6 = (0, _slicedToArray2.default)(_useState5, 1),
1320
1322
  v1 = _useState6[0];
1321
1323
 
1324
+ var handleOnChange = (0, _react.useCallback)(function (v) {
1325
+ (0, _newArrowCheck2.default)(this, _this21);
1326
+ onChange(v);
1327
+ setSearchValue('');
1328
+ }.bind(this), [onChange, setSearchValue]);
1329
+
1322
1330
  var popup = /*#__PURE__*/_react.default.createElement(Popup, {
1323
1331
  v1: v1,
1324
1332
  extra: extra,
@@ -1331,7 +1339,7 @@ var Select = function Select(_ref19) {
1331
1339
  renderPopup: renderPopup,
1332
1340
  handleVisibleChange: handleVisibleChange,
1333
1341
  options: options,
1334
- onChange: onChange,
1342
+ onChange: handleOnChange,
1335
1343
  locale: locale,
1336
1344
  hidePopup: hidePopup,
1337
1345
  dataSource: dataSource,
@@ -1352,6 +1360,7 @@ var Select = function Select(_ref19) {
1352
1360
  value: value,
1353
1361
  onChange: onChange,
1354
1362
  visible: visible,
1363
+ setVisible: setVisible,
1355
1364
  locale: locale,
1356
1365
  dataSource: dataSource,
1357
1366
  clearable: clearable,