uiw 4.11.4 → 4.11.5

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
@@ -6934,6 +6934,7 @@ FormItem.defaultProps = {
6934
6934
 
6935
6935
 
6936
6936
 
6937
+
6937
6938
  var Form_excluded = ["prefixCls", "className", "fields", "children", "resetOnSubmit", "onSubmitError", "onChange", "onSubmit", "afterSubmit"],
6938
6939
  Form_excluded2 = ["children", "validator", "name", "help", "label", "labelFor", "labelClassName", "labelStyle", "inline", "initialValue"];
6939
6940
 
@@ -6959,7 +6960,7 @@ function newFormState(fields, cb) {
6959
6960
  initialValue = _cb.initialValue,
6960
6961
  _currentValue = _cb.currentValue;
6961
6962
 
6962
- state.initial[name] = initialValue;
6963
+ state.initial[name] = Array.isArray(initialValue) ? _toConsumableArray(initialValue) : initialValue;
6963
6964
  state.current[name] = _currentValue;
6964
6965
  }
6965
6966
 
@@ -6999,15 +7000,10 @@ function Form(_ref, ref //| React.RefObject<FormRefType>,
6999
7000
  });
7000
7001
  }, []);
7001
7002
 
7002
- var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(JSON.parse(JSON.stringify(initData))),
7003
+ var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(initData),
7003
7004
  _useState2 = _slicedToArray(_useState, 2),
7004
7005
  data = _useState2[0],
7005
- setDatas = _useState2[1];
7006
-
7007
- var setData = function setData(values) {
7008
- // 解决value为数组时不进行深拷贝,initvalue无法重置问题
7009
- setDatas(JSON.parse(JSON.stringify(values)));
7010
- };
7006
+ setData = _useState2[1];
7011
7007
 
7012
7008
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref, function () {
7013
7009
  return {
@@ -7162,17 +7158,30 @@ function Form(_ref, ref //| React.RefObject<FormRefType>,
7162
7158
 
7163
7159
  function handleReset() {
7164
7160
  var initial = data.initial;
7161
+
7162
+ var initials = _extends({}, initial);
7163
+
7164
+ Object.entries(initials).map(function (_ref3) {
7165
+ var _ref5 = _slicedToArray(_ref3, 2),
7166
+ key = _ref5[0],
7167
+ value = _ref5[1];
7168
+
7169
+ if (Array.isArray(value)) {
7170
+ initials[key] = _toConsumableArray(value);
7171
+ }
7172
+ });
7165
7173
  setData(_extends({}, data, {
7166
- current: initial,
7174
+ initial: initial,
7175
+ current: initials,
7167
7176
  errors: {}
7168
7177
  }));
7169
7178
  }
7170
7179
 
7171
- function controlField(_ref3) {
7172
- var children = _ref3.children,
7173
- validator = _ref3.validator,
7174
- name = _ref3.name,
7175
- other = _objectWithoutPropertiesLoose(_ref3, Form_excluded2);
7180
+ function controlField(_ref4) {
7181
+ var children = _ref4.children,
7182
+ validator = _ref4.validator,
7183
+ name = _ref4.name,
7184
+ other = _objectWithoutPropertiesLoose(_ref4, Form_excluded2);
7176
7185
 
7177
7186
  var element = typeof children !== 'function' ? children : children({
7178
7187
  onChange: handleChange(name, validator),
@@ -9525,31 +9534,22 @@ function SearchSelect(props) {
9525
9534
  var values = [item];
9526
9535
  setSelectedLabel(item.label);
9527
9536
  var resultValue = item.value;
9528
- onSelect && onSelect(resultValue);
9529
- handleSelectChange(resultValue, values); // 支持form组件
9530
-
9531
- value === undefined && setSelectedValue(values); // 如果存在props.value,内部不维护value状态
9537
+ handleChange(resultValue, values);
9532
9538
  }
9533
9539
 
9534
- function handleItemsClick(item) {
9535
- var values = [];
9536
- var index = selectedValue.findIndex(function (finds) {
9537
- return finds.value === item.value;
9538
- });
9539
-
9540
- if (index !== -1) {
9541
- values = removeSelectItem(index);
9542
- } else {
9543
- values = [].concat(_toConsumableArray(selectedValue), [item]);
9544
- }
9545
-
9540
+ function handleItemsClick(index, item) {
9541
+ var values = index !== -1 ? removeSelectItem(index) : [].concat(_toConsumableArray(selectedValue), [item]);
9546
9542
  var resultValue = values.map(function (item) {
9547
9543
  return item.value;
9548
9544
  });
9545
+ handleChange(resultValue, values);
9546
+ }
9547
+
9548
+ function handleChange(resultValue, values) {
9549
9549
  onSelect && onSelect(resultValue);
9550
9550
  handleSelectChange(resultValue, values); // 支持form组件
9551
9551
 
9552
- value === undefined && setSelectedValue(values);
9552
+ value === undefined && setSelectedValue(values); // 如果受控于父组件则不需要内部维护状态
9553
9553
  } // 渲染icon
9554
9554
 
9555
9555
 
@@ -9590,8 +9590,7 @@ function SearchSelect(props) {
9590
9590
 
9591
9591
  function inputKeyDown(e) {
9592
9592
  if (isMultiple && selectedValue.length > 0 && !selectedLabel && e.keyCode === 8) {
9593
- var values = removeSelectItem(selectedValue.length - 1);
9594
- setSelectedValue(values);
9593
+ handleItemsClick(selectedValue.length - 1);
9595
9594
  }
9596
9595
  }
9597
9596
 
@@ -9623,15 +9622,17 @@ function SearchSelect(props) {
9623
9622
  fontSize: 12
9624
9623
  },
9625
9624
  children: loading ? '正在加载数据...' : '没有数据'
9626
- }) : option.map(function (opt, idx) {
9627
- var active = !!getSelectOption(selectedValue, opt.value);
9625
+ }) : option.map(function (item) {
9626
+ var index = selectedValue.findIndex(function (finds) {
9627
+ return finds.value === item.value;
9628
+ });
9628
9629
  return /*#__PURE__*/(0,jsx_runtime.jsx)(react_menu_esm.Item, {
9629
- active: active,
9630
- text: opt.label,
9630
+ active: index !== -1,
9631
+ text: item.label,
9631
9632
  onClick: function onClick() {
9632
- return isMultiple ? handleItemsClick(opt) : handleItemClick(opt);
9633
+ return isMultiple ? handleItemsClick(index, item) : handleItemClick(item);
9633
9634
  }
9634
- }, idx);
9635
+ }, index);
9635
9636
  })
9636
9637
  }),
9637
9638
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
@@ -9664,7 +9665,7 @@ function SearchSelect(props) {
9664
9665
  className: prefixCls + "-tag",
9665
9666
  closable: true,
9666
9667
  onClose: function onClose() {
9667
- return setSelectedValue(removeSelectItem(index));
9668
+ return handleItemsClick(index, item);
9668
9669
  },
9669
9670
  color: "#ccc",
9670
9671
  children: item.label