uiw 4.11.2 → 4.11.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.
package/dist/uiw.css CHANGED
@@ -3788,6 +3788,8 @@ a.w-list-item:hover:not(.w-disabled) {
3788
3788
 
3789
3789
  .w-search-select-input-contents input {
3790
3790
  box-shadow: none;
3791
+ padding: 0px;
3792
+ height: 20px;
3791
3793
  }
3792
3794
  .w-search-select-input-contents .w-input-inner:hover {
3793
3795
  box-shadow: none !important;
@@ -3795,6 +3797,46 @@ a.w-list-item:hover:not(.w-disabled) {
3795
3797
  .w-search-select-input-contents .w-input-inner:focus {
3796
3798
  box-shadow: none !important;
3797
3799
  }
3800
+ .w-search-select-inner {
3801
+ display: flex;
3802
+ justify-content: space-between;
3803
+ outline: none;
3804
+ border: none;
3805
+ align-items: center;
3806
+ border-radius: 3px;
3807
+ box-shadow: 0 0 0 0 rgba(19, 124, 189, 0), 0 0 0 0 rgba(19, 124, 189, 0), inset 0 0 0 1px rgba(16, 22, 26, 0.15), inset 0 1px 1px rgba(16, 22, 26, 0.2);
3808
+ box-sizing: border-box;
3809
+ background: #fff;
3810
+ min-height: 30px;
3811
+ margin: 0 !important;
3812
+ padding: 3px 10px 3px 10px;
3813
+ vertical-align: middle;
3814
+ line-height: 30px;
3815
+ color: #393e48;
3816
+ font-weight: 400;
3817
+ font-size: inherit;
3818
+ transition: box-shadow 0.3s cubic-bezier(0.4, 1, 0.75, 0.9);
3819
+ -webkit-appearance: none;
3820
+ -moz-appearance: none;
3821
+ appearance: none;
3822
+ }
3823
+ .w-search-select-inner:focus {
3824
+ box-shadow: 0 0 0 1px #393e48, 0 0 0 3px rgba(57, 62, 72, 0.17), inset 0 1px 1px rgba(16, 22, 26, 0.2);
3825
+ }
3826
+ .w-search-select-inner:hover {
3827
+ box-shadow: 0 0 0 1px #6e6e6e, 0 0 0 3px rgba(57, 62, 72, 0), inset 0 1px 1px rgba(16, 22, 26, 0.2);
3828
+ }
3829
+ .w-search-select-inner:focus.w-search-select-inner:hover {
3830
+ box-shadow: 0 0 0 1px #6e6e6e, 0 0 0 3px rgba(57, 62, 72, 0.17), inset 0 1px 1px rgba(16, 22, 26, 0.2);
3831
+ }
3832
+ .w-search-select-inner:disabled {
3833
+ box-shadow: none;
3834
+ background: #dddddd;
3835
+ opacity: 0.75;
3836
+ color: #a5a5a5;
3837
+ cursor: not-allowed;
3838
+ resize: none;
3839
+ }
3798
3840
 
3799
3841
  .w-split {
3800
3842
  height: 100%;
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),
@@ -9391,7 +9400,7 @@ var react_tag_esm_excluded = ["prefixCls", "className", "style", "title", "child
9391
9400
 
9392
9401
 
9393
9402
 
9394
- var react_search_select_esm_excluded = ["allowClear", "disabled", "size", "option", "loading", "prefixCls", "className", "mode", "style", "isOpen", "value", "defaultValue", "showSearch", "placeholder", "onSearch", "onChange", "onSelect"];
9403
+ var react_search_select_esm_excluded = ["allowClear", "disabled", "size", "maxTagCount", "option", "loading", "labelInValue", "prefixCls", "className", "mode", "style", "isOpen", "value", "defaultValue", "showSearch", "placeholder", "onSearch", "onChange", "onSelect"];
9395
9404
 
9396
9405
 
9397
9406
 
@@ -9411,10 +9420,13 @@ function SearchSelect(props) {
9411
9420
  disabled = _props$disabled === void 0 ? false : _props$disabled,
9412
9421
  _props$size = props.size,
9413
9422
  size = _props$size === void 0 ? 'default' : _props$size,
9423
+ maxTagCount = props.maxTagCount,
9414
9424
  _props$option = props.option,
9415
9425
  option = _props$option === void 0 ? [] : _props$option,
9416
9426
  _props$loading = props.loading,
9417
9427
  loading = _props$loading === void 0 ? false : _props$loading,
9428
+ _props$labelInValue = props.labelInValue,
9429
+ labelInValue = _props$labelInValue === void 0 ? false : _props$labelInValue,
9418
9430
  _props$prefixCls = props.prefixCls,
9419
9431
  prefixCls = _props$prefixCls === void 0 ? 'w-search-select' : _props$prefixCls,
9420
9432
  className = props.className,
@@ -9440,9 +9452,7 @@ function SearchSelect(props) {
9440
9452
  innerIsOpen = _useState2[0],
9441
9453
  setInnerIsOpen = _useState2[1];
9442
9454
 
9443
- var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(option.filter(function (item) {
9444
- return item.value === value;
9445
- })),
9455
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
9446
9456
  _useState4 = _slicedToArray(_useState3, 2),
9447
9457
  selectedValue = _useState4[0],
9448
9458
  setSelectedValue = _useState4[1];
@@ -9457,19 +9467,58 @@ function SearchSelect(props) {
9457
9467
  selectIconType = _useState8[0],
9458
9468
  setSelectIconType = _useState8[1];
9459
9469
 
9470
+ var omitTagCount = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
9471
+ return maxTagCount && selectedValue.length > maxTagCount ? selectedValue.length - maxTagCount : 0;
9472
+ }, [selectedValue.length]);
9460
9473
  var divRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
9461
9474
  var valueRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
9462
9475
  valueRef.current = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
9463
9476
  return selectedValue;
9464
9477
  }, [selectedValue]);
9465
9478
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
9466
- if (defaultValue) {
9467
- var defaultMenuItem = option.filter(function (opt) {
9468
- return opt.value === defaultValue;
9469
- });
9470
- setSelectedValue(defaultMenuItem);
9479
+ if (value === undefined && defaultValue !== undefined) {
9480
+ selectedValueChange(defaultValue);
9471
9481
  }
9472
9482
  }, []);
9483
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
9484
+ if (value !== undefined) {
9485
+ selectedValueChange(value);
9486
+ }
9487
+ }, [JSON.stringify(value)]);
9488
+
9489
+ var getSelectOption = function getSelectOption(option, value) {
9490
+ var findResult = option.find(function (item) {
9491
+ return item.value === value;
9492
+ });
9493
+ return findResult;
9494
+ };
9495
+
9496
+ function selectedValueChange(changeValue) {
9497
+ var opts = [];
9498
+
9499
+ if (labelInValue) {
9500
+ if (Array.isArray(changeValue)) {
9501
+ opts = changeValue;
9502
+ } else {
9503
+ opts.push(changeValue);
9504
+ }
9505
+ } else {
9506
+ if (Array.isArray(changeValue)) {
9507
+ opts = changeValue.map(function (v) {
9508
+ return getSelectOption(option, v);
9509
+ });
9510
+ } else {
9511
+ var findResult = getSelectOption(option, changeValue);
9512
+
9513
+ if (findResult) {
9514
+ setSelectedLabel(findResult.label);
9515
+ opts.push(findResult);
9516
+ }
9517
+ }
9518
+ }
9519
+
9520
+ setSelectedValue(opts);
9521
+ }
9473
9522
 
9474
9523
  function removeSelectItem(index) {
9475
9524
  var selectedValue = valueRef.current;
@@ -9483,33 +9532,24 @@ function SearchSelect(props) {
9483
9532
  function handleItemClick(item) {
9484
9533
  setInnerIsOpen(false);
9485
9534
  var values = [item];
9486
- setSelectedValue(values);
9487
9535
  setSelectedLabel(item.label);
9488
9536
  var resultValue = item.value;
9489
- onSelect && onSelect(resultValue); // 支持form组件
9490
-
9491
- handleSelectChange(resultValue);
9537
+ handleChange(resultValue, values);
9492
9538
  }
9493
9539
 
9494
- function handleItemsClick(item) {
9495
- var values = [];
9496
- var index = selectedValue.findIndex(function (finds) {
9497
- return finds.value === item.value;
9498
- });
9499
-
9500
- if (index !== -1) {
9501
- values = removeSelectItem(index);
9502
- } else {
9503
- values = [].concat(_toConsumableArray(selectedValue), [item]);
9504
- }
9505
-
9506
- setSelectedValue(values);
9540
+ function handleItemsClick(index, item) {
9541
+ var values = index !== -1 ? removeSelectItem(index) : [].concat(_toConsumableArray(selectedValue), [item]);
9507
9542
  var resultValue = values.map(function (item) {
9508
9543
  return item.value;
9509
9544
  });
9510
- onSelect && onSelect(resultValue); // // 支持form组件
9545
+ handleChange(resultValue, values);
9546
+ }
9511
9547
 
9512
- handleSelectChange(resultValue);
9548
+ function handleChange(resultValue, values) {
9549
+ onSelect && onSelect(resultValue);
9550
+ handleSelectChange(resultValue, values); // 支持form组件
9551
+
9552
+ value === undefined && setSelectedValue(values); // 如果受控于父组件则不需要内部维护状态
9513
9553
  } // 渲染icon
9514
9554
 
9515
9555
 
@@ -9540,17 +9580,17 @@ function SearchSelect(props) {
9540
9580
  setSelectedValue([]);
9541
9581
  setSelectedLabel('');
9542
9582
  setSelectIconType('');
9543
- handleSelectChange('');
9583
+ handleSelectChange('', []);
9544
9584
  }
9545
9585
 
9546
- function handleSelectChange(value) {
9547
- onChange && onChange(value);
9586
+ function handleSelectChange(value, options) {
9587
+ if (!onChange) return;
9588
+ onChange(labelInValue ? options : value);
9548
9589
  }
9549
9590
 
9550
9591
  function inputKeyDown(e) {
9551
- if (selectedValue.length > 0 && !!selectedLabel && e.keyCode === 8) {
9552
- var values = removeSelectItem(selectedValue.length - 1);
9553
- setSelectedValue(values);
9592
+ if (isMultiple && selectedValue.length > 0 && !selectedLabel && e.keyCode === 8) {
9593
+ handleItemsClick(selectedValue.length - 1);
9554
9594
  }
9555
9595
  }
9556
9596
 
@@ -9572,7 +9612,7 @@ function SearchSelect(props) {
9572
9612
  style: {
9573
9613
  minHeight: 25,
9574
9614
  maxHeight: 280,
9575
- minWidth: (style == null ? void 0 : style.minWidth) || 200,
9615
+ minWidth: 200,
9576
9616
  overflowY: 'scroll',
9577
9617
  width: divRef.current ? divRef.current.offsetWidth : 'auto'
9578
9618
  },
@@ -9582,17 +9622,17 @@ function SearchSelect(props) {
9582
9622
  fontSize: 12
9583
9623
  },
9584
9624
  children: loading ? '正在加载数据...' : '没有数据'
9585
- }) : option.map(function (item, idx) {
9586
- var active = !!selectedValue.find(function (finds) {
9625
+ }) : option.map(function (item) {
9626
+ var index = selectedValue.findIndex(function (finds) {
9587
9627
  return finds.value === item.value;
9588
9628
  });
9589
9629
  return /*#__PURE__*/(0,jsx_runtime.jsx)(react_menu_esm.Item, {
9590
- active: active,
9630
+ active: index !== -1,
9591
9631
  text: item.label,
9592
9632
  onClick: function onClick() {
9593
- return isMultiple ? handleItemsClick(item) : handleItemClick(item);
9633
+ return isMultiple ? handleItemsClick(index, item) : handleItemClick(item);
9594
9634
  }
9595
- }, idx);
9635
+ }, index);
9596
9636
  })
9597
9637
  }),
9598
9638
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
@@ -9604,50 +9644,71 @@ function SearchSelect(props) {
9604
9644
  return renderSelectIcon('leave');
9605
9645
  },
9606
9646
  style: _extends({
9607
- width: 'auto',
9647
+ width: '100%',
9608
9648
  maxWidth: 'none'
9609
9649
  }, style),
9610
- children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
9611
- style: isMultiple ? {
9612
- display: 'flex',
9613
- flexFlow: 'wrap',
9614
- padding: 2,
9615
- borderRadius: 3,
9616
- boxShadow: '0px 0px 2px #333'
9617
- } : undefined,
9618
- children: [isMultiple && selectedValue.map(function (item, index) {
9619
- return /*#__PURE__*/(0,jsx_runtime.jsx)(react_tag_esm, {
9650
+ children: isMultiple ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
9651
+ className: prefixCls + "-inner",
9652
+ children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
9653
+ style: {
9654
+ display: 'flex',
9655
+ flexFlow: 'wrap'
9656
+ },
9657
+ children: [isMultiple && selectedValue.slice(0, maxTagCount).map(function (item, index) {
9658
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(react_tag_esm, {
9659
+ style: {
9660
+ height: 20,
9661
+ margin: 1,
9662
+ display: 'flex',
9663
+ alignItems: 'center'
9664
+ },
9665
+ className: prefixCls + "-tag",
9666
+ closable: true,
9667
+ onClose: function onClose() {
9668
+ return handleItemsClick(index, item);
9669
+ },
9670
+ color: "#ccc",
9671
+ children: item.label
9672
+ }, index);
9673
+ }), !!omitTagCount && /*#__PURE__*/(0,jsx_runtime.jsxs)(react_tag_esm, {
9620
9674
  style: {
9621
- margin: '0px 3px 3px 0px',
9675
+ height: 20,
9676
+ margin: 1,
9622
9677
  display: 'flex',
9623
9678
  alignItems: 'center'
9624
9679
  },
9625
- closable: true,
9626
- onClose: function onClose() {
9627
- return setSelectedValue(removeSelectItem(index));
9680
+ disabled: true,
9681
+ children: ["+", omitTagCount, " \u2026", ' ']
9682
+ }), /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
9683
+ style: {
9684
+ flex: 1
9628
9685
  },
9629
- color: "#ccc",
9630
- children: item.label
9631
- }, index);
9632
- }), /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
9633
- style: {
9634
- flex: 1,
9635
- boxShadow: 'none'
9636
- },
9637
- className: isMultiple ? prefixCls + "-input-contents" : undefined,
9638
- readOnly: !showSearch,
9639
- size: size,
9640
- disabled: disabled,
9641
- onKeyDown: inputKeyDown,
9642
- onChange: handleInputChange,
9643
- value: selectedLabel,
9644
- placeholder: placeholder,
9645
- addonAfter: (selectIconType === 'close' || selectIconType === 'loading' && loading) && /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
9646
- type: selectIconType,
9647
- spin: loading && selectIconType === 'loading',
9648
- onClick: resetSelectedValue
9649
- })
9686
+ className: prefixCls + "-input-contents",
9687
+ readOnly: !showSearch,
9688
+ size: size,
9689
+ disabled: disabled,
9690
+ onKeyDown: inputKeyDown,
9691
+ onChange: handleInputChange,
9692
+ value: selectedLabel,
9693
+ placeholder: selectedValue.length ? '' : placeholder
9694
+ })]
9695
+ }), (selectIconType === 'close' || selectIconType === 'loading' && loading) && /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
9696
+ type: selectIconType,
9697
+ spin: loading && selectIconType === 'loading',
9698
+ onClick: resetSelectedValue
9650
9699
  })]
9700
+ }) : /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
9701
+ readOnly: !showSearch,
9702
+ size: size,
9703
+ disabled: disabled,
9704
+ onChange: handleInputChange,
9705
+ value: selectedLabel,
9706
+ placeholder: placeholder,
9707
+ addonAfter: (selectIconType === 'close' || selectIconType === 'loading' && loading) && /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
9708
+ type: selectIconType,
9709
+ spin: loading && selectIconType === 'loading',
9710
+ onClick: resetSelectedValue
9711
+ })
9651
9712
  })
9652
9713
  })
9653
9714
  }));
@@ -11135,7 +11196,7 @@ var isContained = function isContained(a, b) {
11135
11196
  return true;
11136
11197
  };
11137
11198
 
11138
- var getChildKeys = function getChildKeys(childs, result) {
11199
+ var getChildKeys = function getChildKeys(childs, result, depth) {
11139
11200
  if (childs === void 0) {
11140
11201
  childs = [];
11141
11202
  }
@@ -11146,9 +11207,10 @@ var getChildKeys = function getChildKeys(childs, result) {
11146
11207
 
11147
11208
  childs.forEach(function (item) {
11148
11209
  result.push(item.key);
11210
+ if (typeof depth === 'number' && !(depth - 1)) return;
11149
11211
 
11150
11212
  if (item.children && item.children.length > 0) {
11151
- result = result.concat(getChildKeys(item.children));
11213
+ result = result.concat(getChildKeys(item.children, undefined, depth ? depth - 1 : undefined));
11152
11214
  }
11153
11215
  });
11154
11216
  return result;
@@ -11236,6 +11298,8 @@ function Tree(props) {
11236
11298
  _props$onSelected = props.onSelected,
11237
11299
  onSelected = _props$onSelected === void 0 ? noop : _props$onSelected,
11238
11300
  className = props.className,
11301
+ _props$autoExpandPare = props.autoExpandParent,
11302
+ autoExpandParent = _props$autoExpandPare === void 0 ? true : _props$autoExpandPare,
11239
11303
  renderTitle = props.renderTitle,
11240
11304
  elementProps = _objectWithoutPropertiesLoose(props, react_tree_esm_excluded);
11241
11305
 
@@ -11252,11 +11316,15 @@ function Tree(props) {
11252
11316
 
11253
11317
 
11254
11318
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
11255
- var arrOpenKeys = getChildKeys(data);
11319
+ var arrOpenKeys = [];
11256
11320
 
11257
11321
  if (defaultExpandAll) {
11258
- setCurOpenKeys(arrOpenKeys);
11322
+ arrOpenKeys = getChildKeys(data);
11323
+ } else if (autoExpandParent) {
11324
+ arrOpenKeys = getChildKeys(data, undefined, 1);
11259
11325
  }
11326
+
11327
+ setCurOpenKeys(arrOpenKeys);
11260
11328
  }, []);
11261
11329
  var cls = [className, prefixCls, showLine ? prefixCls + "-line" : null].filter(Boolean).join(' ').trim();
11262
11330