hy-virtual-tree 1.1.54 → 1.1.55
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/CHANGELOG.md +8 -0
- package/dist/index.js +13 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1116,9 +1116,13 @@ const isCheckLeaf = (config, node) => {
|
|
|
1116
1116
|
return node.isLeaf;
|
|
1117
1117
|
return node.data.dataType === 3 ? true : node.isLeaf;
|
|
1118
1118
|
};
|
|
1119
|
-
function useCheck(props,
|
|
1119
|
+
function useCheck(props, instance) {
|
|
1120
|
+
const tree = instance._tree;
|
|
1120
1121
|
const checkedKeys = new Set();
|
|
1121
1122
|
let indeterminateKeys = new Set();
|
|
1123
|
+
const isHiddenNode = (key) => {
|
|
1124
|
+
return instance._hiddenNodeKeySet.has(key) || tree.hiddenNodeKeySet.has(key);
|
|
1125
|
+
};
|
|
1122
1126
|
const updateCheckedKeys = () => {
|
|
1123
1127
|
const { checkStrictly } = props.rowSelection;
|
|
1124
1128
|
if (!tree || checkStrictly) {
|
|
@@ -1132,7 +1136,7 @@ function useCheck(props, tree) {
|
|
|
1132
1136
|
if (!nodes)
|
|
1133
1137
|
continue;
|
|
1134
1138
|
nodes.forEach((node) => {
|
|
1135
|
-
if (
|
|
1139
|
+
if (isHiddenNode(node.key) || !isShowSelect(props, node))
|
|
1136
1140
|
return;
|
|
1137
1141
|
if (node.children && !isCheckLeaf(props, node)) {
|
|
1138
1142
|
let allChecked = true;
|
|
@@ -1142,7 +1146,7 @@ function useCheck(props, tree) {
|
|
|
1142
1146
|
const key = childNode.key;
|
|
1143
1147
|
// 通道需要循环处理
|
|
1144
1148
|
if (childNode.data.dataType !== DataType.CHANNEL &&
|
|
1145
|
-
(
|
|
1149
|
+
(isHiddenNode(key) || !isShowSelect(props, node))) {
|
|
1146
1150
|
continue;
|
|
1147
1151
|
}
|
|
1148
1152
|
if ((props.businessConfig?.showOnlineState && childNode.data.deviceStatus !== DeviceStatus.OFF_LINE) ||
|
|
@@ -1183,7 +1187,7 @@ function useCheck(props, tree) {
|
|
|
1183
1187
|
};
|
|
1184
1188
|
const isChecked = (node) => checkedKeys.has(node.key);
|
|
1185
1189
|
const isIndeterminate = (node) => indeterminateKeys.has(node.key);
|
|
1186
|
-
const toggleCheckbox = (node, isChecked, nodeClick = true, immediateUpdate = true, checkOnDbclick = false
|
|
1190
|
+
const toggleCheckbox = (node, isChecked, nodeClick = true, immediateUpdate = true, checkOnDbclick = false) => {
|
|
1187
1191
|
const { type, checkStrictly, cancelable } = props.rowSelection;
|
|
1188
1192
|
const checkedKeySet = checkedKeys;
|
|
1189
1193
|
// 单选
|
|
@@ -1200,7 +1204,7 @@ function useCheck(props, tree) {
|
|
|
1200
1204
|
// 多选
|
|
1201
1205
|
const toggle = (node, checked) => {
|
|
1202
1206
|
// 对隐藏的节点不做处理
|
|
1203
|
-
if (
|
|
1207
|
+
if (instance._hiddenNodeKeySet.has(node.key) || (tree.hiddenNodeKeySet.has(node.key) && nodeClick))
|
|
1204
1208
|
return;
|
|
1205
1209
|
checkedKeySet[checked ? 'add' : 'delete'](node.key);
|
|
1206
1210
|
const children = node.children;
|
|
@@ -1511,7 +1515,6 @@ function useCheck(props, tree) {
|
|
|
1511
1515
|
if (!isIndeterminate(node) || props.rowSelection.checkStrictly || !node.children?.length)
|
|
1512
1516
|
return !isChecked(node);
|
|
1513
1517
|
const { isAllSelect } = getNodeCheckInfo(node.children || []);
|
|
1514
|
-
console.log('isAllSelect', isAllSelect);
|
|
1515
1518
|
return !isAllSelect;
|
|
1516
1519
|
}
|
|
1517
1520
|
// 获取当前项选中信息
|
|
@@ -1521,7 +1524,7 @@ function useCheck(props, tree) {
|
|
|
1521
1524
|
let isCanAllSelect = true;
|
|
1522
1525
|
let isAllSelect = true;
|
|
1523
1526
|
for (const node of children) {
|
|
1524
|
-
if (isChecked(node))
|
|
1527
|
+
if (isChecked(node) || isHiddenNode(node.key))
|
|
1525
1528
|
continue;
|
|
1526
1529
|
// 严格模式 或 非严格模式下没有子元素
|
|
1527
1530
|
if (checkStrictly || (!checkStrictly && !node.children?.length)) {
|
|
@@ -9146,7 +9149,7 @@ class VirtualTree {
|
|
|
9146
9149
|
getCheckedKeys, getCheckedNodes, getCheckedBusinessNodes,
|
|
9147
9150
|
// getHalfCheckedKeys,
|
|
9148
9151
|
// getHalfCheckedNodes,
|
|
9149
|
-
setChecked, setCheckedKeys, setCheckedNodes, getSwitchCheckedValue, } = useCheck(config, this
|
|
9152
|
+
setChecked, setCheckedKeys, setCheckedNodes, getSwitchCheckedValue, } = useCheck(config, this);
|
|
9150
9153
|
this._updateCheckedKeys = updateCheckedKeys;
|
|
9151
9154
|
this.getChecked = getChecked;
|
|
9152
9155
|
this.getCheckedKeys = getCheckedKeys;
|
|
@@ -9286,7 +9289,7 @@ class VirtualTree {
|
|
|
9286
9289
|
onClick: () => {
|
|
9287
9290
|
if (getDisabled(config, item))
|
|
9288
9291
|
return;
|
|
9289
|
-
toggleCheckbox(item, getSwitchCheckedValue(item), true, true, false
|
|
9292
|
+
toggleCheckbox(item, getSwitchCheckedValue(item), true, true, false);
|
|
9290
9293
|
this.refresh();
|
|
9291
9294
|
}
|
|
9292
9295
|
}).mount(el);
|
|
@@ -9786,6 +9789,7 @@ class VirtualTree {
|
|
|
9786
9789
|
this._hiddenExpandIconKeySet = hiddenExpandIconKeySet;
|
|
9787
9790
|
this._hiddenNodeKeySet = hiddenNodeKeySet;
|
|
9788
9791
|
this._isForceHiddenExpandIcon = isForceHiddenExpandIcon;
|
|
9792
|
+
this._updateCheckedKeys();
|
|
9789
9793
|
this._refreshVirtualScroll();
|
|
9790
9794
|
}
|
|
9791
9795
|
};
|