wargerm 0.7.84 → 0.7.85

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/index.esm.js CHANGED
@@ -3451,9 +3451,9 @@ var findParent = function findParent(data, id) {
3451
3451
  var parent = null;
3452
3452
  var loop = function loop(node, arr) {
3453
3453
  for (var i = 0; i < arr.length; i++) {
3454
- var _item$children;
3454
+ var _item$origin, _item$children;
3455
3455
  var item = arr[i];
3456
- if (item.id == id) return parent = node;
3456
+ if ((item.key || item.id || ((_item$origin = item.origin) === null || _item$origin === void 0 ? void 0 : _item$origin.id)) == id) return parent = node;
3457
3457
  if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
3458
3458
  loop(item, item.children);
3459
3459
  }
@@ -3492,10 +3492,11 @@ var handleCheck = function handleCheck(_ref) {
3492
3492
  var currentId = id;
3493
3493
  while (currentId) {
3494
3494
  var _ref2 = findParent(treeData, currentId) || {},
3495
+ key = _ref2.key,
3495
3496
  _id = _ref2.id,
3496
3497
  children = _ref2.children;
3497
3498
  var ids = children === null || children === void 0 ? void 0 : children.map(function (item) {
3498
- return item.id;
3499
+ return item.key || item.id;
3499
3500
  });
3500
3501
  if (!ids) {
3501
3502
  currentId = null;
@@ -3505,21 +3506,21 @@ var handleCheck = function handleCheck(_ref) {
3505
3506
  return values.checked.includes(item);
3506
3507
  })) {
3507
3508
  // 检查每个父 id 都在 checked list 里面,不在则 push半选
3508
- if (!values.halfChecked.includes(_id)) {
3509
+ if (!values.halfChecked.includes(key || _id)) {
3509
3510
  // 判断是否存在
3510
- values.halfChecked.push(_id);
3511
+ values.halfChecked.push(key || _id);
3511
3512
  }
3512
- removeId(values.checked, _id);
3513
- } else if (!values.checked.includes(_id)) {
3513
+ removeId(values.checked, key || _id);
3514
+ } else if (!values.checked.includes(key || _id)) {
3514
3515
  // 每个父 id 是否已存在 checked list ,不在则 push checked list, 并且清空 半选
3515
- values.checked.push(_id);
3516
- removeId(values.halfChecked, _id);
3516
+ values.checked.push(key || _id);
3517
+ removeId(values.halfChecked, key || _id);
3517
3518
  }
3518
3519
  if (!ids.some(function (item) {
3519
3520
  return [].concat(_toConsumableArray(values.checked), _toConsumableArray(values.halfChecked)).includes(item);
3520
3521
  })) {
3521
3522
  // 检查每个父 id 都不在 checked list 里面,不在则 清空半选
3522
- removeId(values.halfChecked, _id);
3523
+ removeId(values.halfChecked, key || _id);
3523
3524
  }
3524
3525
  currentId = parentIds.pop();
3525
3526
  }
@@ -3592,14 +3593,14 @@ var WTree = function WTree(props, ref) {
3592
3593
  };
3593
3594
  deepFn = function deepFn(arr) {
3594
3595
  return arr.map(function (item) {
3595
- var _item$children3, _ref4, _item$origin, _item$origin2;
3596
+ var _item$children3, _ref4, _item$origin2, _item$origin3;
3596
3597
  if (((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length) > 0) {
3597
3598
  item.children = deepFn(item.children);
3598
3599
  }
3599
3600
  allKeysRef.current = [].concat(_toConsumableArray(allKeysRef.current), [item.key]);
3600
3601
  handleCheck({
3601
- parentIds: (_ref4 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin = item.origin) === null || _item$origin === void 0 ? void 0 : _item$origin.parentIds)) === null || _ref4 === void 0 ? void 0 : _ref4.split(',').slice(1),
3602
- id: (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin2 = item.origin) === null || _item$origin2 === void 0 ? void 0 : _item$origin2.id),
3602
+ parentIds: (_ref4 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin2 = item.origin) === null || _item$origin2 === void 0 ? void 0 : _item$origin2.parentIds)) === null || _ref4 === void 0 ? void 0 : _ref4.split(',').slice(1),
3603
+ id: (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin3 = item.origin) === null || _item$origin3 === void 0 ? void 0 : _item$origin3.id),
3603
3604
  values: values,
3604
3605
  treeData: data
3605
3606
  });
@@ -3621,14 +3622,14 @@ var WTree = function WTree(props, ref) {
3621
3622
  };
3622
3623
  _deepFn = function _deepFn(arr) {
3623
3624
  return arr.map(function (item) {
3624
- var _item$children4, _ref5, _item$origin3, _item$origin4;
3625
+ var _item$children4, _ref5, _item$origin4, _item$origin5;
3625
3626
  if (((_item$children4 = item.children) === null || _item$children4 === void 0 ? void 0 : _item$children4.length) > 0) {
3626
3627
  item.children = _deepFn(item.children);
3627
3628
  }
3628
3629
  allKeysRef.current = [].concat(_toConsumableArray(allKeysRef.current), [item.key]);
3629
3630
  handleCheck({
3630
- parentIds: (_ref5 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin3 = item.origin) === null || _item$origin3 === void 0 ? void 0 : _item$origin3.parentIds)) === null || _ref5 === void 0 ? void 0 : _ref5.split(',').slice(1),
3631
- id: (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin4 = item.origin) === null || _item$origin4 === void 0 ? void 0 : _item$origin4.id),
3631
+ parentIds: (_ref5 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin4 = item.origin) === null || _item$origin4 === void 0 ? void 0 : _item$origin4.parentIds)) === null || _ref5 === void 0 ? void 0 : _ref5.split(',').slice(1),
3632
+ id: (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin5 = item.origin) === null || _item$origin5 === void 0 ? void 0 : _item$origin5.id),
3632
3633
  values: _values,
3633
3634
  treeData: dataSource
3634
3635
  });
@@ -3666,7 +3667,7 @@ var WTree = function WTree(props, ref) {
3666
3667
  var _info$node, _info$node$parentIds, _info$node2;
3667
3668
  var checked = info === null || info === void 0 ? void 0 : info.checked;
3668
3669
  var parentIds = info === null || info === void 0 ? void 0 : (_info$node = info.node) === null || _info$node === void 0 ? void 0 : (_info$node$parentIds = _info$node.parentIds) === null || _info$node$parentIds === void 0 ? void 0 : _info$node$parentIds.split(',').slice(1);
3669
- var currentId = info === null || info === void 0 ? void 0 : info.node.id;
3670
+ var currentId = (info === null || info === void 0 ? void 0 : info.node.key) || (info === null || info === void 0 ? void 0 : info.node.id);
3670
3671
  handleCheck({
3671
3672
  parentIds: parentIds,
3672
3673
  id: currentId,
@@ -3674,7 +3675,7 @@ var WTree = function WTree(props, ref) {
3674
3675
  treeData: treeData
3675
3676
  });
3676
3677
  var childrenIds = flatChildren((info === null || info === void 0 ? void 0 : (_info$node2 = info.node) === null || _info$node2 === void 0 ? void 0 : _info$node2.children) || []).map(function (item) {
3677
- return item.id;
3678
+ return item.key || item.id;
3678
3679
  });
3679
3680
  // TODO 全选反选
3680
3681
  if (checked) {
package/dist/index.js CHANGED
@@ -3495,9 +3495,9 @@ var findParent = function findParent(data, id) {
3495
3495
  var parent = null;
3496
3496
  var loop = function loop(node, arr) {
3497
3497
  for (var i = 0; i < arr.length; i++) {
3498
- var _item$children;
3498
+ var _item$origin, _item$children;
3499
3499
  var item = arr[i];
3500
- if (item.id == id) return parent = node;
3500
+ if ((item.key || item.id || ((_item$origin = item.origin) === null || _item$origin === void 0 ? void 0 : _item$origin.id)) == id) return parent = node;
3501
3501
  if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
3502
3502
  loop(item, item.children);
3503
3503
  }
@@ -3536,10 +3536,11 @@ var handleCheck = function handleCheck(_ref) {
3536
3536
  var currentId = id;
3537
3537
  while (currentId) {
3538
3538
  var _ref2 = findParent(treeData, currentId) || {},
3539
+ key = _ref2.key,
3539
3540
  _id = _ref2.id,
3540
3541
  children = _ref2.children;
3541
3542
  var ids = children === null || children === void 0 ? void 0 : children.map(function (item) {
3542
- return item.id;
3543
+ return item.key || item.id;
3543
3544
  });
3544
3545
  if (!ids) {
3545
3546
  currentId = null;
@@ -3549,21 +3550,21 @@ var handleCheck = function handleCheck(_ref) {
3549
3550
  return values.checked.includes(item);
3550
3551
  })) {
3551
3552
  // 检查每个父 id 都在 checked list 里面,不在则 push半选
3552
- if (!values.halfChecked.includes(_id)) {
3553
+ if (!values.halfChecked.includes(key || _id)) {
3553
3554
  // 判断是否存在
3554
- values.halfChecked.push(_id);
3555
+ values.halfChecked.push(key || _id);
3555
3556
  }
3556
- removeId(values.checked, _id);
3557
- } else if (!values.checked.includes(_id)) {
3557
+ removeId(values.checked, key || _id);
3558
+ } else if (!values.checked.includes(key || _id)) {
3558
3559
  // 每个父 id 是否已存在 checked list ,不在则 push checked list, 并且清空 半选
3559
- values.checked.push(_id);
3560
- removeId(values.halfChecked, _id);
3560
+ values.checked.push(key || _id);
3561
+ removeId(values.halfChecked, key || _id);
3561
3562
  }
3562
3563
  if (!ids.some(function (item) {
3563
3564
  return [].concat(_toConsumableArray(values.checked), _toConsumableArray(values.halfChecked)).includes(item);
3564
3565
  })) {
3565
3566
  // 检查每个父 id 都不在 checked list 里面,不在则 清空半选
3566
- removeId(values.halfChecked, _id);
3567
+ removeId(values.halfChecked, key || _id);
3567
3568
  }
3568
3569
  currentId = parentIds.pop();
3569
3570
  }
@@ -3636,14 +3637,14 @@ var WTree = function WTree(props, ref) {
3636
3637
  };
3637
3638
  deepFn = function deepFn(arr) {
3638
3639
  return arr.map(function (item) {
3639
- var _item$children3, _ref4, _item$origin, _item$origin2;
3640
+ var _item$children3, _ref4, _item$origin2, _item$origin3;
3640
3641
  if (((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length) > 0) {
3641
3642
  item.children = deepFn(item.children);
3642
3643
  }
3643
3644
  allKeysRef.current = [].concat(_toConsumableArray(allKeysRef.current), [item.key]);
3644
3645
  handleCheck({
3645
- parentIds: (_ref4 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin = item.origin) === null || _item$origin === void 0 ? void 0 : _item$origin.parentIds)) === null || _ref4 === void 0 ? void 0 : _ref4.split(',').slice(1),
3646
- id: (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin2 = item.origin) === null || _item$origin2 === void 0 ? void 0 : _item$origin2.id),
3646
+ parentIds: (_ref4 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin2 = item.origin) === null || _item$origin2 === void 0 ? void 0 : _item$origin2.parentIds)) === null || _ref4 === void 0 ? void 0 : _ref4.split(',').slice(1),
3647
+ id: (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin3 = item.origin) === null || _item$origin3 === void 0 ? void 0 : _item$origin3.id),
3647
3648
  values: values,
3648
3649
  treeData: data
3649
3650
  });
@@ -3665,14 +3666,14 @@ var WTree = function WTree(props, ref) {
3665
3666
  };
3666
3667
  _deepFn = function _deepFn(arr) {
3667
3668
  return arr.map(function (item) {
3668
- var _item$children4, _ref5, _item$origin3, _item$origin4;
3669
+ var _item$children4, _ref5, _item$origin4, _item$origin5;
3669
3670
  if (((_item$children4 = item.children) === null || _item$children4 === void 0 ? void 0 : _item$children4.length) > 0) {
3670
3671
  item.children = _deepFn(item.children);
3671
3672
  }
3672
3673
  allKeysRef.current = [].concat(_toConsumableArray(allKeysRef.current), [item.key]);
3673
3674
  handleCheck({
3674
- parentIds: (_ref5 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin3 = item.origin) === null || _item$origin3 === void 0 ? void 0 : _item$origin3.parentIds)) === null || _ref5 === void 0 ? void 0 : _ref5.split(',').slice(1),
3675
- id: (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin4 = item.origin) === null || _item$origin4 === void 0 ? void 0 : _item$origin4.id),
3675
+ parentIds: (_ref5 = (item === null || item === void 0 ? void 0 : item.parentIds) || ((_item$origin4 = item.origin) === null || _item$origin4 === void 0 ? void 0 : _item$origin4.parentIds)) === null || _ref5 === void 0 ? void 0 : _ref5.split(',').slice(1),
3676
+ id: (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : item.id) || ((_item$origin5 = item.origin) === null || _item$origin5 === void 0 ? void 0 : _item$origin5.id),
3676
3677
  values: _values,
3677
3678
  treeData: dataSource
3678
3679
  });
@@ -3710,7 +3711,7 @@ var WTree = function WTree(props, ref) {
3710
3711
  var _info$node, _info$node$parentIds, _info$node2;
3711
3712
  var checked = info === null || info === void 0 ? void 0 : info.checked;
3712
3713
  var parentIds = info === null || info === void 0 ? void 0 : (_info$node = info.node) === null || _info$node === void 0 ? void 0 : (_info$node$parentIds = _info$node.parentIds) === null || _info$node$parentIds === void 0 ? void 0 : _info$node$parentIds.split(',').slice(1);
3713
- var currentId = info === null || info === void 0 ? void 0 : info.node.id;
3714
+ var currentId = (info === null || info === void 0 ? void 0 : info.node.key) || (info === null || info === void 0 ? void 0 : info.node.id);
3714
3715
  handleCheck({
3715
3716
  parentIds: parentIds,
3716
3717
  id: currentId,
@@ -3718,7 +3719,7 @@ var WTree = function WTree(props, ref) {
3718
3719
  treeData: treeData
3719
3720
  });
3720
3721
  var childrenIds = flatChildren((info === null || info === void 0 ? void 0 : (_info$node2 = info.node) === null || _info$node2 === void 0 ? void 0 : _info$node2.children) || []).map(function (item) {
3721
- return item.id;
3722
+ return item.key || item.id;
3722
3723
  });
3723
3724
  // TODO 全选反选
3724
3725
  if (checked) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "wargerm",
4
- "version": "0.7.84",
4
+ "version": "0.7.85",
5
5
  "scripts": {
6
6
  "dev": "dumi dev",
7
7
  "docs:build": "dumi build",