uiw 4.16.0 → 4.16.1

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
@@ -1896,6 +1896,12 @@ sup.w-badge-count {
1896
1896
  border-top: 1px solid rgba(255, 255, 255, 0.2);
1897
1897
  }
1898
1898
 
1899
+ .w-cascader-close {
1900
+ font-size: 15px;
1901
+ margin-right: 1px;
1902
+ color: #393e48;
1903
+ }
1904
+
1899
1905
  .w-radio {
1900
1906
  vertical-align: middle;
1901
1907
  display: inline-block;
@@ -3920,6 +3926,13 @@ a.w-list-item:hover:not(.w-disabled) {
3920
3926
  cursor: not-allowed;
3921
3927
  resize: none;
3922
3928
  }
3929
+ .w-search-select-multiple-colse {
3930
+ left: 7px;
3931
+ font-size: 15px;
3932
+ }
3933
+ .w-search-select-singe-colse {
3934
+ font-size: 15px;
3935
+ }
3923
3936
 
3924
3937
  .w-split {
3925
3938
  height: 100%;
package/dist/uiw.js CHANGED
@@ -4534,6 +4534,9 @@ Menu.Divider = MenuDivider;
4534
4534
 
4535
4535
  /* harmony default export */ const react_menu_esm = (esm_Menu);
4536
4536
 
4537
+ ;// CONCATENATED MODULE: ../react-cascader/esm/style/index.css
4538
+ // extracted by mini-css-extract-plugin
4539
+ /* harmony default export */ const react_cascader_esm_style = ({});
4537
4540
  ;// CONCATENATED MODULE: ../react-cascader/esm/index.js
4538
4541
 
4539
4542
 
@@ -4543,10 +4546,15 @@ Menu.Divider = MenuDivider;
4543
4546
 
4544
4547
 
4545
4548
 
4549
+
4546
4550
  function Cascader(props) {
4547
4551
  var {
4552
+ value,
4553
+ onChange,
4554
+ onSearch,
4555
+ allowClear,
4548
4556
  placeholder,
4549
- prefixCls = 'w-search-select',
4557
+ prefixCls = 'w-cascader',
4550
4558
  className,
4551
4559
  style = {
4552
4560
  width: 200
@@ -4557,23 +4565,109 @@ function Cascader(props) {
4557
4565
  var cls = [prefixCls, className].filter(Boolean).join(' ').trim();
4558
4566
  var [innerIsOpen, setInnerIsOpen] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false);
4559
4567
  var [selectedValue, setSelectedValue] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
4568
+ var [selectIconType, setSelectIconType] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)('');
4569
+ var [searchText, setSearchText] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)('');
4570
+ var [searchOn, setSearchOn] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false);
4571
+ var [inputValue, setInputValue] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)('');
4572
+ var [searchOption, setSearchOption] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)();
4573
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
4574
+ if (onSearch) {
4575
+ var tempOptions = [];
4576
+ iteratorOption(option, opt => {
4577
+ var label = opt.map(m => m.label).join(' / ');
4578
+ tempOptions.push({
4579
+ label,
4580
+ options: opt
4581
+ });
4582
+ });
4583
+ setSearchOption(tempOptions);
4584
+ }
4585
+ }, [onSearch]);
4586
+
4587
+ var iteratorOption = function iteratorOption(options, cb, opts) {
4588
+ if (opts === void 0) {
4589
+ opts = [];
4590
+ }
4591
+
4592
+ options.map(opt => {
4593
+ var optsTemp = [...opts, opt];
4594
+
4595
+ if (opt.children) {
4596
+ iteratorOption(opt.children, cb, optsTemp);
4597
+ } else {
4598
+ cb == null ? void 0 : cb(optsTemp);
4599
+ }
4600
+ });
4601
+ };
4602
+
4603
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
4604
+ if (value) {
4605
+ var valueTemp = [];
4606
+ var optChildren = option;
4607
+ value == null ? void 0 : value.map(item => {
4608
+ var findOpt = optChildren.find(opt => opt.value === item);
4609
+ optChildren = (findOpt == null ? void 0 : findOpt.children) || [];
4610
+ valueTemp.push(_extends({
4611
+ label: item,
4612
+ value: item
4613
+ }, findOpt));
4614
+ });
4615
+ setSelectedValue(valueTemp);
4616
+ }
4617
+ }, [value]);
4560
4618
 
4561
4619
  function onVisibleChange(isOpen) {
4562
4620
  setInnerIsOpen(isOpen);
4563
4621
  }
4564
4622
 
4623
+ function renderSelectIcon(type) {
4624
+ var selectIconType;
4625
+
4626
+ if (type === 'enter' && allowClear && selectedValue.length > 0) {
4627
+ selectIconType = 'close';
4628
+ } else {
4629
+ selectIconType = '';
4630
+ }
4631
+
4632
+ setSelectIconType(selectIconType);
4633
+ }
4634
+
4635
+ var searchItemClick = options => {
4636
+ setSearchText('');
4637
+ setInnerIsOpen(false);
4638
+ handelChange(false, options);
4639
+ };
4640
+
4565
4641
  var handleItemClick = (optionsItem, level) => {
4566
4642
  selectedValue.splice(level, selectedValue.length - level, optionsItem);
4567
- setSelectedValue([...selectedValue]);
4568
- handelChange();
4643
+ handelChange(true, selectedValue);
4569
4644
  };
4570
4645
 
4571
- var handelChange = () => {
4646
+ var handelChange = (isSeleted, selectedValue) => {
4647
+ setSelectedValue([...selectedValue]);
4572
4648
  var value = selectedValue.map(item => item.value);
4573
- props.onChange == null ? void 0 : props.onChange(value, selectedValue);
4649
+ onChange == null ? void 0 : onChange(isSeleted, value, selectedValue);
4574
4650
  };
4575
4651
 
4576
- var widths = (style == null ? void 0 : style.width) * 0.6 || undefined;
4652
+ var onClear = e => {
4653
+ e.stopPropagation();
4654
+ handelChange(false, []);
4655
+ };
4656
+
4657
+ var handelSearch = searchText => {
4658
+ setSearchText(searchText);
4659
+ };
4660
+
4661
+ var inputChange = e => {
4662
+ if (!innerIsOpen) {
4663
+ setInnerIsOpen(!innerIsOpen);
4664
+ }
4665
+
4666
+ var value = e.target.value;
4667
+ onSearch && handelSearch(value);
4668
+ };
4669
+
4670
+ var widths = (style == null ? void 0 : style.width) * 0.5 || undefined;
4577
4671
 
4578
4672
  var OptionIter = function OptionIter(option, level) {
4579
4673
  if (level === void 0) {
@@ -4595,25 +4689,26 @@ function Cascader(props) {
4595
4689
  fontSize: 12
4596
4690
  },
4597
4691
  children: '没有数据'
4598
- }) : option.map((item, index) => {
4692
+ }) : option.map((opt, index) => {
4599
4693
  var _selectedValue$level;
4600
4694
 
4601
- var active = ((_selectedValue$level = selectedValue[level]) == null ? void 0 : _selectedValue$level.value) === item.value;
4695
+ var active = ((_selectedValue$level = selectedValue[level]) == null ? void 0 : _selectedValue$level.value) === opt.value;
4602
4696
  return /*#__PURE__*/(0,jsx_runtime.jsx)(react_menu_esm.Item, {
4603
4697
  active: active,
4604
- text: item.label,
4605
- addonAfter: item.children ? /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
4698
+ text: opt.label,
4699
+ addonAfter: opt.children ? /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
4606
4700
  type: "right"
4607
4701
  }) : undefined,
4608
- onClick: () => handleItemClick(item, level)
4702
+ onClick: () => handleItemClick(opt, level)
4609
4703
  }, index);
4610
4704
  })
4611
4705
  }, level);
4612
4706
  };
4613
4707
 
4614
- var inputValue = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
4615
- return selectedValue.map(item => item.label).join(' / ');
4616
- }, [selectedValue.length]);
4708
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
4709
+ var inputValue = selectedValue.map(opt => opt.label).join(' / ');
4710
+ setInputValue(inputValue);
4711
+ }, [selectedValue]);
4617
4712
  return /*#__PURE__*/(0,jsx_runtime.jsx)(Dropdown, _extends({
4618
4713
  className: cls,
4619
4714
  trigger: "click",
@@ -4626,7 +4721,7 @@ function Cascader(props) {
4626
4721
  }, others, {
4627
4722
  onVisibleChange: onVisibleChange,
4628
4723
  isOpen: innerIsOpen,
4629
- menu: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
4724
+ menu: !searchText ? /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
4630
4725
  style: {
4631
4726
  display: 'flex'
4632
4727
  },
@@ -4636,14 +4731,52 @@ function Cascader(props) {
4636
4731
  var options = index ? (_selectedValue = selectedValue[index - 1]) == null ? void 0 : _selectedValue.children : option;
4637
4732
  return OptionIter(options, index);
4638
4733
  }).filter(m => !!m)
4639
- }),
4640
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
4641
- value: inputValue,
4642
- onChange: () => {},
4643
- placeholder: placeholder,
4734
+ }) : /*#__PURE__*/(0,jsx_runtime.jsx)(react_menu_esm, {
4735
+ bordered: true,
4644
4736
  style: {
4737
+ minHeight: 25,
4738
+ minWidth: style == null ? void 0 : style.width,
4739
+ overflowY: 'scroll',
4645
4740
  width: style == null ? void 0 : style.width
4646
- }
4741
+ },
4742
+ children: !searchOption || searchOption.length === 0 ? /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
4743
+ style: {
4744
+ color: '#c7c7c7',
4745
+ fontSize: 12
4746
+ },
4747
+ children: '没有数据'
4748
+ }) : searchOption.filter(opt => opt.label.includes(searchText.trim())).map((opt, index) => {
4749
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(react_menu_esm.Item, {
4750
+ text: opt.label,
4751
+ onClick: () => searchItemClick(opt.options) //
4752
+
4753
+ }, index);
4754
+ })
4755
+ }),
4756
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
4757
+ onMouseLeave: () => renderSelectIcon('leave'),
4758
+ onMouseOver: () => renderSelectIcon('enter'),
4759
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
4760
+ value: searchOn ? searchText : inputValue,
4761
+ onChange: inputChange,
4762
+ placeholder: searchOn ? inputValue : placeholder,
4763
+ style: {
4764
+ width: style == null ? void 0 : style.width
4765
+ },
4766
+ onFocus: () => onSearch && setSearchOn(true),
4767
+ onBlur: () => onSearch && setSearchOn(false),
4768
+ readOnly: !onSearch,
4769
+ addonAfter: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
4770
+ style: {
4771
+ width: 'auto'
4772
+ },
4773
+ children: selectIconType === 'close' && /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
4774
+ type: selectIconType,
4775
+ onClick: onClear,
4776
+ className: prefixCls + "-close"
4777
+ })
4778
+ })
4779
+ })
4647
4780
  })
4648
4781
  }));
4649
4782
  }
@@ -8386,6 +8519,7 @@ function SearchSelect(props) {
8386
8519
  placeholder: selectedValue.length ? '' : placeholder
8387
8520
  })]
8388
8521
  }), !disabled && (selectIconType === 'close' || selectIconType === 'loading' && loading) && /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
8522
+ className: prefixCls + "-multiple-colse",
8389
8523
  type: selectIconType,
8390
8524
  spin: loading && selectIconType === 'loading',
8391
8525
  onClick: resetSelectedValue
@@ -8400,6 +8534,8 @@ function SearchSelect(props) {
8400
8534
  placeholder: placeholder,
8401
8535
  addonAfter: !disabled && (selectIconType === 'close' || selectIconType === 'loading' && loading) && /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
8402
8536
  type: selectIconType,
8537
+ className: prefixCls + "-singe-colse",
8538
+ color: "#393e48",
8403
8539
  spin: loading && selectIconType === 'loading',
8404
8540
  onClick: resetSelectedValue
8405
8541
  })
@@ -9337,7 +9473,7 @@ class ThComponent extends external_root_React_commonjs2_react_commonjs_react_amd
9337
9473
  var rect = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(this);
9338
9474
  this.props.updateLocation({
9339
9475
  width: rect.getBoundingClientRect().width
9340
- }, this.props.colNum);
9476
+ }, "" + this.props.rowNum + this.props.colNum, this.props.item.key, this.props.item.colSpan);
9341
9477
  }
9342
9478
 
9343
9479
  render() {
@@ -9367,7 +9503,7 @@ class ThComponent extends external_root_React_commonjs2_react_commonjs_react_amd
9367
9503
  }
9368
9504
 
9369
9505
  return /*#__PURE__*/(0,jsx_runtime.jsx)("th", _extends({}, thProps, {
9370
- style: _extends({}, thProps.style, locationFixed(fixed, locationWidth, colNum)),
9506
+ style: _extends({}, thProps.style, locationFixed(fixed, locationWidth, "" + rowNum + colNum)),
9371
9507
  className: prefixCls + "-tr-children-" + ((item == null ? void 0 : item.align) || 'left') + " " + (item.className || '') + " " + cls,
9372
9508
  onClick: evn => onCellHead == null ? void 0 : onCellHead(item, colNum, rowNum, evn),
9373
9509
  children: titleNode
@@ -9491,7 +9627,8 @@ function TableTr(props) {
9491
9627
  hierarchy,
9492
9628
  indentSize,
9493
9629
  childrenColumnName,
9494
- locationWidth
9630
+ locationWidth,
9631
+ header
9495
9632
  } = props;
9496
9633
  var [isOpacity, setIsOpacity] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false);
9497
9634
  var [childrenIndex, setChildrenIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0);
@@ -9519,6 +9656,15 @@ function TableTr(props) {
9519
9656
  };
9520
9657
  }, [expandIndex]);
9521
9658
 
9659
+ var getIndex = key => {
9660
+ var j = 0;
9661
+ var i = header.findIndex(it => {
9662
+ j = it.findIndex(item => item.key === key);
9663
+ return j > -1;
9664
+ });
9665
+ return "" + i + j;
9666
+ };
9667
+
9522
9668
  if (!Array.isArray(data) || !data.length) {
9523
9669
  return null;
9524
9670
  }
@@ -9573,7 +9719,7 @@ function TableTr(props) {
9573
9719
  }
9574
9720
 
9575
9721
  return /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement)("td", _extends({}, objs, {
9576
- style: _extends({}, locationFixed(keyName.fixed, locationWidth, colNum)),
9722
+ style: keyName.fixed ? _extends({}, locationFixed(keyName.fixed, locationWidth, "" + getIndex(keyName.key || 'undefined'))) : {},
9577
9723
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
9578
9724
  className: ellipsis && ellipsis[keyName.key] ? prefixCls + "-ellipsis" : undefined,
9579
9725
  children: objs.children
@@ -9637,34 +9783,71 @@ function Table(props) {
9637
9783
  var [locationWidth, setLocationWidth] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({});
9638
9784
  var finalLocationWidth = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({});
9639
9785
 
9640
- var updateLocation = (params, index) => {
9786
+ var updateLocation = function updateLocation(params, index, key, colSpan) {
9787
+ if (colSpan === void 0) {
9788
+ colSpan = 0;
9789
+ }
9790
+
9641
9791
  finalLocationWidth.current = _extends({}, finalLocationWidth.current, {
9642
- [index]: _extends({}, finalLocationWidth.current[index], params)
9792
+ [index]: _extends({}, finalLocationWidth.current[index], params, {
9793
+ key: key,
9794
+ colSpan
9795
+ })
9643
9796
  });
9644
9797
 
9645
- if (index === columns.length - 1) {
9798
+ if (index === "" + (header.length - 1) + (header[header.length - 1].length - 1)) {
9646
9799
  setLocationWidth(computed());
9647
9800
  }
9648
9801
  };
9649
9802
 
9650
- var computed = () => {
9651
- var left = 0,
9652
- right = 0;
9803
+ var deepClumnsLocation = (params, fistIndex, leftOrRight, isReverse) => {
9804
+ var initialValue = 0,
9805
+ lastIndex = isReverse ? 0 : params.length - 1,
9806
+ deepParams = [];
9807
+ params.forEach(() => {
9808
+ var abs = Math.abs(lastIndex);
9809
+ var i = "" + fistIndex + abs;
9653
9810
 
9654
- for (var _index = 0; _index < columns.length; _index++) {
9655
- if (finalLocationWidth.current[_index]) {
9656
- finalLocationWidth.current[_index].left = left;
9657
- left = finalLocationWidth.current[_index].width + left;
9811
+ if (isReverse) {
9812
+ lastIndex += 1;
9813
+ } else {
9814
+ lastIndex -= 1;
9658
9815
  }
9659
- }
9660
9816
 
9661
- for (var _index2 = columns.length - 1; _index2 > -1; _index2--) {
9662
- if (finalLocationWidth.current[_index2]) {
9663
- finalLocationWidth.current[_index2].right = right;
9664
- right = finalLocationWidth.current[_index2].width + right;
9817
+ if (typeof params[abs] === 'number') {
9818
+ initialValue = params[abs] + initialValue;
9819
+ deepParams.push(params[abs]);
9820
+ return;
9665
9821
  }
9666
- }
9667
9822
 
9823
+ if (finalLocationWidth.current[i]) {
9824
+ finalLocationWidth.current[i][leftOrRight] = initialValue;
9825
+ initialValue = finalLocationWidth.current[i].width + initialValue;
9826
+ }
9827
+
9828
+ if (Array.isArray(params[abs].children)) {
9829
+ deepParams.push(...params[abs].children);
9830
+ return;
9831
+ }
9832
+
9833
+ if (finalLocationWidth.current[i]) {
9834
+ deepParams.push(finalLocationWidth.current[i].width);
9835
+ } else {
9836
+ var parent = header.find(it => it.find(it => it.key === params[abs].key)) || [];
9837
+ var sub = parent.findIndex(it => it.key === params[abs].key);
9838
+
9839
+ if (finalLocationWidth.current["" + i[0] + sub]) {
9840
+ // 合并单元格
9841
+ deepParams.push(finalLocationWidth.current["" + i[0] + sub].width);
9842
+ }
9843
+ }
9844
+ });
9845
+ if (deepParams.filter(it => typeof it !== 'number').length) deepClumnsLocation(deepParams, fistIndex + 1, leftOrRight, isReverse);
9846
+ };
9847
+
9848
+ var computed = () => {
9849
+ deepClumnsLocation(columns, 0, 'left', true);
9850
+ deepClumnsLocation(columns, 0, 'right', false);
9668
9851
  return finalLocationWidth.current;
9669
9852
  };
9670
9853
 
@@ -9838,6 +10021,7 @@ function Table(props) {
9838
10021
  rowKey: rowKey,
9839
10022
  locationWidth: locationWidth,
9840
10023
  data: data,
10024
+ header: header,
9841
10025
  keys: self.keys,
9842
10026
  render: render,
9843
10027
  ellipsis: ellipsis,
@@ -9905,6 +10089,7 @@ var react_tabs_esm_excluded = ["prefixCls", "className", "children", "type", "ac
9905
10089
 
9906
10090
 
9907
10091
  Tabs.Pane = Pane;
10092
+ var labelWidth = 0;
9908
10093
  function Tabs(props) {
9909
10094
  var _flowNav$nav;
9910
10095
 
@@ -9950,12 +10135,16 @@ function Tabs(props) {
9950
10135
  flowNavSet(_extends({}, flowNav));
9951
10136
  }
9952
10137
  }, []);
9953
- var divNavRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)((node, key) => {
10138
+ var divNavRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)((node, key, itemKey) => {
9954
10139
  if (node !== null) {
9955
10140
  node.addEventListener('click', e => {
9956
10141
  activeItem.current = node;
9957
10142
  });
9958
10143
  divNavWidthChange(node.getBoundingClientRect().width, key);
10144
+
10145
+ if (itemKey === props.activeKey && type === 'line' && labelWidth === 0) {
10146
+ activeItem.current = node;
10147
+ }
9959
10148
  }
9960
10149
  }, []);
9961
10150
 
@@ -9994,6 +10183,7 @@ function Tabs(props) {
9994
10183
 
9995
10184
  function calcSlideStyle() {
9996
10185
  if (activeItem.current && type === 'line') {
10186
+ labelWidth = activeItem.current.clientWidth;
9997
10187
  setSlideStyle({
9998
10188
  width: activeItem.current.clientWidth,
9999
10189
  left: activeItem.current.offsetLeft
@@ -10071,7 +10261,7 @@ function Tabs(props) {
10071
10261
  }
10072
10262
 
10073
10263
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", _extends({
10074
- ref: _ref => divNavRef(_ref, key)
10264
+ ref: _ref => divNavRef(_ref, key, item.key)
10075
10265
  }, divProps), key);
10076
10266
  });
10077
10267
  }