uiw 4.11.2 → 4.11.3
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 +65 -24
- package/dist/uiw.min.js +1 -1
- package/package.json +56 -56
package/dist/uiw.js
CHANGED
|
@@ -9391,7 +9391,7 @@ var react_tag_esm_excluded = ["prefixCls", "className", "style", "title", "child
|
|
|
9391
9391
|
|
|
9392
9392
|
|
|
9393
9393
|
|
|
9394
|
-
var react_search_select_esm_excluded = ["allowClear", "disabled", "size", "option", "loading", "prefixCls", "className", "mode", "style", "isOpen", "value", "defaultValue", "showSearch", "placeholder", "onSearch", "onChange", "onSelect"];
|
|
9394
|
+
var react_search_select_esm_excluded = ["allowClear", "disabled", "size", "maxTagCount", "option", "loading", "prefixCls", "className", "mode", "style", "isOpen", "value", "defaultValue", "showSearch", "placeholder", "onSearch", "onChange", "onSelect"];
|
|
9395
9395
|
|
|
9396
9396
|
|
|
9397
9397
|
|
|
@@ -9411,6 +9411,7 @@ function SearchSelect(props) {
|
|
|
9411
9411
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
9412
9412
|
_props$size = props.size,
|
|
9413
9413
|
size = _props$size === void 0 ? 'default' : _props$size,
|
|
9414
|
+
maxTagCount = props.maxTagCount,
|
|
9414
9415
|
_props$option = props.option,
|
|
9415
9416
|
option = _props$option === void 0 ? [] : _props$option,
|
|
9416
9417
|
_props$loading = props.loading,
|
|
@@ -9440,9 +9441,7 @@ function SearchSelect(props) {
|
|
|
9440
9441
|
innerIsOpen = _useState2[0],
|
|
9441
9442
|
setInnerIsOpen = _useState2[1];
|
|
9442
9443
|
|
|
9443
|
-
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(
|
|
9444
|
-
return item.value === value;
|
|
9445
|
-
})),
|
|
9444
|
+
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
|
|
9446
9445
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
9447
9446
|
selectedValue = _useState4[0],
|
|
9448
9447
|
setSelectedValue = _useState4[1];
|
|
@@ -9457,19 +9456,48 @@ function SearchSelect(props) {
|
|
|
9457
9456
|
selectIconType = _useState8[0],
|
|
9458
9457
|
setSelectIconType = _useState8[1];
|
|
9459
9458
|
|
|
9459
|
+
var omitTagCount = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
|
|
9460
|
+
return maxTagCount && selectedValue.length > maxTagCount ? selectedValue.length - maxTagCount : 0;
|
|
9461
|
+
}, [selectedValue.length]);
|
|
9460
9462
|
var divRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
9461
9463
|
var valueRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
|
|
9462
9464
|
valueRef.current = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
|
|
9463
9465
|
return selectedValue;
|
|
9464
9466
|
}, [selectedValue]);
|
|
9465
9467
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
9466
|
-
if (defaultValue) {
|
|
9467
|
-
|
|
9468
|
-
return opt.value === defaultValue;
|
|
9469
|
-
});
|
|
9470
|
-
setSelectedValue(defaultMenuItem);
|
|
9468
|
+
if (value === undefined && defaultValue !== undefined) {
|
|
9469
|
+
selectedValueChange(defaultValue);
|
|
9471
9470
|
}
|
|
9472
9471
|
}, []);
|
|
9472
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
9473
|
+
if (value !== undefined) {
|
|
9474
|
+
selectedValueChange(value);
|
|
9475
|
+
}
|
|
9476
|
+
}, [JSON.stringify(value)]);
|
|
9477
|
+
|
|
9478
|
+
function selectedValueChange(changeValue) {
|
|
9479
|
+
var opts = [];
|
|
9480
|
+
|
|
9481
|
+
if (Array.isArray(changeValue)) {
|
|
9482
|
+
opts = option.filter(function (item) {
|
|
9483
|
+
var findResult = changeValue.find(function (v) {
|
|
9484
|
+
return item.value === v;
|
|
9485
|
+
});
|
|
9486
|
+
return findResult;
|
|
9487
|
+
});
|
|
9488
|
+
} else if (!isMultiple) {
|
|
9489
|
+
var findResult = option.find(function (item) {
|
|
9490
|
+
return item.value === changeValue;
|
|
9491
|
+
});
|
|
9492
|
+
|
|
9493
|
+
if (findResult) {
|
|
9494
|
+
setSelectedLabel(findResult.label);
|
|
9495
|
+
opts.push(findResult);
|
|
9496
|
+
}
|
|
9497
|
+
}
|
|
9498
|
+
|
|
9499
|
+
setSelectedValue(opts);
|
|
9500
|
+
}
|
|
9473
9501
|
|
|
9474
9502
|
function removeSelectItem(index) {
|
|
9475
9503
|
var selectedValue = valueRef.current;
|
|
@@ -9483,12 +9511,12 @@ function SearchSelect(props) {
|
|
|
9483
9511
|
function handleItemClick(item) {
|
|
9484
9512
|
setInnerIsOpen(false);
|
|
9485
9513
|
var values = [item];
|
|
9486
|
-
setSelectedValue(values);
|
|
9487
9514
|
setSelectedLabel(item.label);
|
|
9488
9515
|
var resultValue = item.value;
|
|
9489
|
-
|
|
9516
|
+
value === undefined && setSelectedValue(values); // 如果存在props.value,内部不维护value状态
|
|
9490
9517
|
|
|
9491
|
-
|
|
9518
|
+
onSelect && onSelect(resultValue);
|
|
9519
|
+
handleSelectChange(resultValue); // 支持form组件
|
|
9492
9520
|
}
|
|
9493
9521
|
|
|
9494
9522
|
function handleItemsClick(item) {
|
|
@@ -9503,13 +9531,12 @@ function SearchSelect(props) {
|
|
|
9503
9531
|
values = [].concat(_toConsumableArray(selectedValue), [item]);
|
|
9504
9532
|
}
|
|
9505
9533
|
|
|
9506
|
-
setSelectedValue(values);
|
|
9507
9534
|
var resultValue = values.map(function (item) {
|
|
9508
9535
|
return item.value;
|
|
9509
9536
|
});
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
handleSelectChange(resultValue);
|
|
9537
|
+
value === undefined && setSelectedValue(values);
|
|
9538
|
+
onSelect && onSelect(resultValue);
|
|
9539
|
+
handleSelectChange(resultValue); // 支持form组件
|
|
9513
9540
|
} // 渲染icon
|
|
9514
9541
|
|
|
9515
9542
|
|
|
@@ -9604,21 +9631,20 @@ function SearchSelect(props) {
|
|
|
9604
9631
|
return renderSelectIcon('leave');
|
|
9605
9632
|
},
|
|
9606
9633
|
style: _extends({
|
|
9607
|
-
width: '
|
|
9634
|
+
width: '100%',
|
|
9608
9635
|
maxWidth: 'none'
|
|
9609
9636
|
}, style),
|
|
9610
9637
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
9611
9638
|
style: isMultiple ? {
|
|
9612
9639
|
display: 'flex',
|
|
9613
9640
|
flexFlow: 'wrap',
|
|
9614
|
-
padding: 2,
|
|
9615
9641
|
borderRadius: 3,
|
|
9616
9642
|
boxShadow: '0px 0px 2px #333'
|
|
9617
9643
|
} : undefined,
|
|
9618
|
-
children: [isMultiple && selectedValue.map(function (item, index) {
|
|
9644
|
+
children: [isMultiple && selectedValue.slice(0, maxTagCount).map(function (item, index) {
|
|
9619
9645
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(react_tag_esm, {
|
|
9620
9646
|
style: {
|
|
9621
|
-
margin:
|
|
9647
|
+
margin: 2,
|
|
9622
9648
|
display: 'flex',
|
|
9623
9649
|
alignItems: 'center'
|
|
9624
9650
|
},
|
|
@@ -9629,6 +9655,14 @@ function SearchSelect(props) {
|
|
|
9629
9655
|
color: "#ccc",
|
|
9630
9656
|
children: item.label
|
|
9631
9657
|
}, index);
|
|
9658
|
+
}), !!omitTagCount && /*#__PURE__*/(0,jsx_runtime.jsxs)(react_tag_esm, {
|
|
9659
|
+
style: {
|
|
9660
|
+
margin: 2,
|
|
9661
|
+
display: 'flex',
|
|
9662
|
+
alignItems: 'center'
|
|
9663
|
+
},
|
|
9664
|
+
disabled: true,
|
|
9665
|
+
children: ["+", omitTagCount, " \u2026", ' ']
|
|
9632
9666
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
|
|
9633
9667
|
style: {
|
|
9634
9668
|
flex: 1,
|
|
@@ -11135,7 +11169,7 @@ var isContained = function isContained(a, b) {
|
|
|
11135
11169
|
return true;
|
|
11136
11170
|
};
|
|
11137
11171
|
|
|
11138
|
-
var getChildKeys = function getChildKeys(childs, result) {
|
|
11172
|
+
var getChildKeys = function getChildKeys(childs, result, depth) {
|
|
11139
11173
|
if (childs === void 0) {
|
|
11140
11174
|
childs = [];
|
|
11141
11175
|
}
|
|
@@ -11146,9 +11180,10 @@ var getChildKeys = function getChildKeys(childs, result) {
|
|
|
11146
11180
|
|
|
11147
11181
|
childs.forEach(function (item) {
|
|
11148
11182
|
result.push(item.key);
|
|
11183
|
+
if (typeof depth === 'number' && !(depth - 1)) return;
|
|
11149
11184
|
|
|
11150
11185
|
if (item.children && item.children.length > 0) {
|
|
11151
|
-
result = result.concat(getChildKeys(item.children));
|
|
11186
|
+
result = result.concat(getChildKeys(item.children, undefined, depth ? depth - 1 : undefined));
|
|
11152
11187
|
}
|
|
11153
11188
|
});
|
|
11154
11189
|
return result;
|
|
@@ -11236,6 +11271,8 @@ function Tree(props) {
|
|
|
11236
11271
|
_props$onSelected = props.onSelected,
|
|
11237
11272
|
onSelected = _props$onSelected === void 0 ? noop : _props$onSelected,
|
|
11238
11273
|
className = props.className,
|
|
11274
|
+
_props$autoExpandPare = props.autoExpandParent,
|
|
11275
|
+
autoExpandParent = _props$autoExpandPare === void 0 ? true : _props$autoExpandPare,
|
|
11239
11276
|
renderTitle = props.renderTitle,
|
|
11240
11277
|
elementProps = _objectWithoutPropertiesLoose(props, react_tree_esm_excluded);
|
|
11241
11278
|
|
|
@@ -11252,11 +11289,15 @@ function Tree(props) {
|
|
|
11252
11289
|
|
|
11253
11290
|
|
|
11254
11291
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
11255
|
-
var arrOpenKeys =
|
|
11292
|
+
var arrOpenKeys = [];
|
|
11256
11293
|
|
|
11257
11294
|
if (defaultExpandAll) {
|
|
11258
|
-
|
|
11295
|
+
arrOpenKeys = getChildKeys(data);
|
|
11296
|
+
} else if (autoExpandParent) {
|
|
11297
|
+
arrOpenKeys = getChildKeys(data, undefined, 1);
|
|
11259
11298
|
}
|
|
11299
|
+
|
|
11300
|
+
setCurOpenKeys(arrOpenKeys);
|
|
11260
11301
|
}, []);
|
|
11261
11302
|
var cls = [className, prefixCls, showLine ? prefixCls + "-line" : null].filter(Boolean).join(' ').trim();
|
|
11262
11303
|
|