uiw 4.13.3 → 4.13.4

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.
package/dist/uiw.js CHANGED
@@ -5651,7 +5651,8 @@ function Form(_ref, ref //| React.RefObject<FormRefType>,
5651
5651
  resetForm: handleReset,
5652
5652
  getFieldValues: () => data.current,
5653
5653
  getError: () => data.errors,
5654
- setFields: setFields
5654
+ setFields: setFields,
5655
+ setFieldValue: setFieldValue
5655
5656
  }), [data]);
5656
5657
  var formUnits = {};
5657
5658
 
@@ -5688,6 +5689,16 @@ function Form(_ref, ref //| React.RefObject<FormRefType>,
5688
5689
  setData(tempData);
5689
5690
  }
5690
5691
 
5692
+ function setFieldValue(fieldName, value) {
5693
+ var tempData = _extends({}, data, {
5694
+ current: _extends({}, data.current, {
5695
+ [fieldName]: value
5696
+ })
5697
+ });
5698
+
5699
+ setData(tempData);
5700
+ }
5701
+
5691
5702
  function handleChange(name, validator, element, cb) {
5692
5703
  return (env, list) => {
5693
5704
  var value = env && env.target && 'value' in env.target ? env.target.value : env; // 控件 Checkbox.Group 多选值的处理
@@ -9578,17 +9589,17 @@ function Tree(props) {
9578
9589
  var [curOpenKeys, setCurOpenKeys] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(openKeys);
9579
9590
  var [curSelectedKeys, setCurSelectedKeys] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(selectedKeys);
9580
9591
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
9581
- setCurSelectedKeys(props.selectedKeys);
9592
+ setCurSelectedKeys(props.selectedKeys || []);
9582
9593
  }, [JSON.stringify(props.selectedKeys)]); // useEffect(() => setCurOpenKeys(openKeys), [openKeys]);
9583
9594
  // useEffect(() => setCurSelectedKeys(selectedKeys), [selectedKeys]);
9584
9595
 
9585
9596
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
9586
- var arrOpenKeys = [];
9597
+ var arrOpenKeys = curOpenKeys;
9587
9598
 
9588
9599
  if (defaultExpandAll) {
9589
9600
  arrOpenKeys = getChildKeys(data);
9590
9601
  } else if (autoExpandParent) {
9591
- arrOpenKeys = getChildKeys(data, undefined, 1);
9602
+ arrOpenKeys.push(...getChildKeys(data, undefined, 1));
9592
9603
  }
9593
9604
 
9594
9605
  setCurOpenKeys(arrOpenKeys);
@@ -9725,7 +9736,8 @@ function TreeChecked(_ref) {
9725
9736
  ;// CONCATENATED MODULE: ../react-search-tree/esm/SearchTagInput.js
9726
9737
 
9727
9738
 
9728
- var SearchTagInput_excluded = ["prefixCls", "mode", "size", "disabled", "allowClear", "loading", "className", "style", "placeholder", "content", "options", "values", "onChange", "onSearch"];
9739
+ var SearchTagInput_excluded = ["prefixCls", "mode", "size", "disabled", "allowClear", "loading", "className", "style", "placeholder", "content", "options", "values", "onChange", "onSearch", "emptyOption"];
9740
+
9729
9741
 
9730
9742
 
9731
9743
 
@@ -9751,13 +9763,14 @@ function SearchTagInput(props) {
9751
9763
  options,
9752
9764
  values,
9753
9765
  onChange,
9754
- onSearch
9766
+ onSearch,
9767
+ emptyOption
9755
9768
  } = props,
9756
9769
  others = _objectWithoutPropertiesLoose(props, SearchTagInput_excluded);
9757
9770
 
9758
9771
  var cls = [prefixCls, className].filter(Boolean).join(' ').trim(); // const isMultiple = useMemo(() => mode === 'multiple', [mode]);
9759
- // const [innerIsOpen, setInnerIsOpen] = useState(false);
9760
9772
 
9773
+ var [innerIsOpen, setInnerIsOpen] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false);
9761
9774
  var [selectedOption, setSelectedOption] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(values);
9762
9775
  var optionRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
9763
9776
  var [searchValue, searchValueSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)('');
@@ -9796,8 +9809,9 @@ function SearchTagInput(props) {
9796
9809
  } // 清除选中的值
9797
9810
 
9798
9811
 
9799
- function resetSelectedValue() {
9800
- // setInnerIsOpen(false);
9812
+ function resetSelectedValue(e) {
9813
+ e.stopPropagation();
9814
+ setInnerIsOpen(false);
9801
9815
  setSelectedOption([]);
9802
9816
  handleInputChange('');
9803
9817
  handleSelectChange([]);
@@ -9810,6 +9824,15 @@ function SearchTagInput(props) {
9810
9824
  }
9811
9825
 
9812
9826
  var newContent = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
9827
+ if (emptyOption) {
9828
+ return typeof emptyOption === 'boolean' ? /*#__PURE__*/(0,jsx_runtime.jsx)(react_empty_esm, {
9829
+ style: {
9830
+ minWidth: 200,
9831
+ width: style == null ? void 0 : style.width
9832
+ }
9833
+ }) : emptyOption;
9834
+ }
9835
+
9813
9836
  var newProps = _extends({}, content.props, {
9814
9837
  onSelected: handleSelectChange,
9815
9838
  values: selectedOption,
@@ -9817,12 +9840,16 @@ function SearchTagInput(props) {
9817
9840
  });
9818
9841
 
9819
9842
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().cloneElement(content, newProps);
9820
- }, [selectedOption, options]);
9843
+ }, [selectedOption, options, emptyOption]);
9821
9844
  return /*#__PURE__*/(0,jsx_runtime.jsx)(Dropdown, _extends({
9822
9845
  className: cls,
9823
9846
  trigger: "focus"
9824
9847
  }, others, {
9848
+ isOpen: innerIsOpen,
9825
9849
  menu: /*#__PURE__*/(0,jsx_runtime.jsx)(react_card_esm, {
9850
+ bodyStyle: emptyOption === true ? {
9851
+ padding: 0
9852
+ } : undefined,
9826
9853
  children: newContent
9827
9854
  }),
9828
9855
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
@@ -9873,8 +9900,7 @@ function SearchTagInput(props) {
9873
9900
  onKeyDown: inputKeyDown,
9874
9901
  onChange: e => handleInputChange(e.target.value),
9875
9902
  value: searchValue,
9876
- placeholder: selectedOption.length ? '' : placeholder // readOnly={false}
9877
-
9903
+ placeholder: selectedOption.length ? '' : placeholder
9878
9904
  })]
9879
9905
  }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
9880
9906
  style: {
@@ -9897,7 +9923,8 @@ function SearchTagInput(props) {
9897
9923
  ;// CONCATENATED MODULE: ../react-search-tree/esm/index.js
9898
9924
 
9899
9925
 
9900
- var react_search_tree_esm_excluded = ["onChange", "onSearch", "options", "value", "treeProps"];
9926
+ var react_search_tree_esm_excluded = ["onChange", "onSearch", "multiple", "options", "value", "emptyOption", "treeProps"];
9927
+
9901
9928
 
9902
9929
 
9903
9930
 
@@ -9974,18 +10001,53 @@ function TreeCheckeds(props) {
9974
10001
  }));
9975
10002
  }
9976
10003
 
10004
+ function SingeTree(props) {
10005
+ var [keys, keysSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
10006
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
10007
+ var _props$values2;
10008
+
10009
+ var keys = [];
10010
+ if ((_props$values2 = props.values) != null && _props$values2.length) keys[0] = props.values[0].key;
10011
+ keysSet(keys);
10012
+ }, [props.values]);
10013
+
10014
+ var onSelected = (_1, _2, isChecked, evn) => {
10015
+ var {
10016
+ key,
10017
+ label
10018
+ } = evn;
10019
+ var cur = {
10020
+ key,
10021
+ label
10022
+ };
10023
+ props.onSelected == null ? void 0 : props.onSelected([cur], cur, isChecked);
10024
+ };
10025
+
10026
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(Tree, _extends({
10027
+ defaultExpandAll: true
10028
+ }, props, {
10029
+ multiple: false,
10030
+ data: props.options,
10031
+ selectedKeys: keys,
10032
+ onSelected: onSelected
10033
+ }));
10034
+ }
10035
+
9977
10036
  function SearchTree(props) {
9978
10037
  var {
9979
10038
  onChange,
9980
10039
  onSearch,
10040
+ multiple = true,
9981
10041
  options = [],
9982
10042
  value = [],
10043
+ emptyOption = !options.length,
9983
10044
  treeProps
9984
10045
  } = props,
9985
10046
  other = _objectWithoutPropertiesLoose(props, react_search_tree_esm_excluded);
9986
10047
 
9987
- var [selectedValues, selectedValuesSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(value);
10048
+ var [selectedValues, selectedValuesSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(Array.isArray(value) ? value : [value]);
9988
10049
  var [selectedOptions, selectedOptionSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(options);
10050
+ var [isEmpty, isEmptySet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(emptyOption);
9989
10051
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
9990
10052
  selectedValuesSet(value);
9991
10053
  }, [JSON.stringify(value)]);
@@ -10027,14 +10089,18 @@ function SearchTree(props) {
10027
10089
 
10028
10090
  hiddenNodeForSeach(options);
10029
10091
  selectedOptionSet([...options]);
10092
+ var isEmpt = true;
10093
+ options.forEach(opt => isEmpt = isEmpt && !!opt.hideNode);
10094
+ isEmptySet(isEmpt);
10030
10095
  };
10031
10096
 
10032
10097
  return /*#__PURE__*/(0,jsx_runtime.jsx)(esm_SearchTagInput, _extends({}, other, {
10098
+ emptyOption: isEmpty,
10033
10099
  onSearch: debounce(selectedSearch, 700),
10034
10100
  onChange: selectedChange,
10035
10101
  values: selectedValues,
10036
10102
  options: selectedOptions,
10037
- content: /*#__PURE__*/(0,jsx_runtime.jsx)(TreeCheckeds, _extends({}, treeProps))
10103
+ content: multiple ? /*#__PURE__*/(0,jsx_runtime.jsx)(TreeCheckeds, _extends({}, treeProps)) : /*#__PURE__*/(0,jsx_runtime.jsx)(SingeTree, _extends({}, treeProps))
10038
10104
  }));
10039
10105
  }
10040
10106