tntd 3.0.9-beta.3 → 3.0.10

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.
Files changed (38) hide show
  1. package/es/array-input/index.js +3 -1
  2. package/es/array-input/index.js.map +1 -1
  3. package/es/index.js +1 -1
  4. package/es/index.js.map +1 -1
  5. package/es/query-list-scene/QueryForm.js +3 -6
  6. package/es/query-list-scene/QueryForm.js.map +1 -1
  7. package/es/title/index.js +18 -4
  8. package/es/title/index.js.map +1 -1
  9. package/es/title/index.less +85 -34
  10. package/es/tntd-virtual-tree/index.js +51 -42
  11. package/es/tntd-virtual-tree/index.js.map +1 -1
  12. package/es/tntd-virtual-tree/index.less +29 -16
  13. package/es/tntd-virtual-tree/utils.js +117 -58
  14. package/es/tntd-virtual-tree/utils.js.map +1 -1
  15. package/lib/array-input/index.js +5 -1
  16. package/lib/array-input/index.js.map +1 -1
  17. package/lib/index.d.ts +1 -1
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +2 -2
  20. package/lib/index.js.map +1 -1
  21. package/lib/query-list-scene/QueryForm.d.ts +2 -2
  22. package/lib/query-list-scene/QueryForm.d.ts.map +1 -1
  23. package/lib/query-list-scene/QueryForm.js +8 -10
  24. package/lib/query-list-scene/QueryForm.js.map +1 -1
  25. package/lib/title/index.d.ts +1 -0
  26. package/lib/title/index.d.ts.map +1 -1
  27. package/lib/title/index.js +18 -4
  28. package/lib/title/index.js.map +1 -1
  29. package/lib/title/index.less +85 -34
  30. package/lib/tntd-virtual-tree/index.d.ts.map +1 -1
  31. package/lib/tntd-virtual-tree/index.js +55 -45
  32. package/lib/tntd-virtual-tree/index.js.map +1 -1
  33. package/lib/tntd-virtual-tree/index.less +29 -16
  34. package/lib/tntd-virtual-tree/utils.d.ts +6 -4
  35. package/lib/tntd-virtual-tree/utils.d.ts.map +1 -1
  36. package/lib/tntd-virtual-tree/utils.js +130 -66
  37. package/lib/tntd-virtual-tree/utils.js.map +1 -1
  38. package/package.json +1 -1
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.getNodeValuess = exports.getNodeStr = exports.getNodeParentChoosed = exports.getNodeAllChildrenValue = exports.getIndeterminate = exports.getFullExpandedKeys = exports.getFullCheckedKeys = exports.flatTreeData = exports.addTreeNodeAttrs = void 0;
6
+ exports.getNodeValuess = exports.getNodeStr = exports.getNodeParentChoosed = exports.getNodeNoDisabledLastestChildrenValues = exports.getNodeNoDisabledChildrenValues = exports.getIndeterminate = exports.getFullExpandedKeys = exports.getFullCheckedKeys = exports.flatTreeData = exports.findNodeDetail = exports.addTreeNodeAttrs = void 0;
8
7
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
9
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
11
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -24,7 +20,12 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
24
20
  return t;
25
21
  };
26
22
  /**
27
- * 初始化给树的每个节点增加属性字段(childrenValues, titleTotal, parentsValues, siblingsValue),childrenValues: 当前节点下的所有子节点的value和, titleTotal: 当前节点下的所有子节点的title和 parentsValues: 当前节点所有的父节点 siblingsValue: 当前节点所有上级节点的兄弟节点
23
+ * 初始化给树的每个节点增加以下属性字段
24
+ * childrenValues: 当前节点下的所有子节点的value和(包含了disabled节点)用户展开/收起
25
+ * titleTotal: 当前节点下的所有子节点的title和 (包含了disabled节点)用于搜索
26
+ * needCheckedChildrenValues: 当前节点下的节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中
27
+ * needCheckedLastestChildrenValues: 当前节点下的最底层节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中
28
+ * needCheckedSiblingsValue: 当前节点所有上级节点的兄弟节点, [{ key: '上级节点value', list: [xx] }] list包含非disabled节点 用于选中/取消选中
28
29
  * 用于判断后续展开/收起
29
30
  * @param {*} treeData
30
31
  */
@@ -35,8 +36,7 @@ var addTreeNodeAttrs = exports.addTreeNodeAttrs = function addTreeNodeAttrs(tree
35
36
  children: 'children',
36
37
  disabled: 'disabled'
37
38
  };
38
- var parentsValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
39
- var siblingsValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
39
+ var needCheckedSiblingsValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
40
40
  if (Array.isArray(treeData) && !!treeData.length) {
41
41
  return treeData.map(function (item) {
42
42
  item.children = item[fieldNames['children']];
@@ -45,9 +45,22 @@ var addTreeNodeAttrs = exports.addTreeNodeAttrs = function addTreeNodeAttrs(tree
45
45
  var children = item.children,
46
46
  query = __rest(item, ["children"]);
47
47
  if (Array.isArray(children) && !!children.length) {
48
- query.children = addTreeNodeAttrs(children, fieldNames, [item.value].concat(_toConsumableArray(parentsValues)), Object.assign(Object.assign({}, siblingsValue), _defineProperty({}, item.value, children.map(function (i) {
49
- return i[fieldNames['value']];
50
- }))));
48
+ var siblingsSum = needCheckedSiblingsValue;
49
+ if (!item[fieldNames['disabled']]) {
50
+ // 这里注意要逆序,要不然校验的时候会出问题
51
+ siblingsSum = [{
52
+ key: item[fieldNames['value']],
53
+ list: children.reduce(function (total, item) {
54
+ if (!item[fieldNames['disabled']]) {
55
+ total.push(item[fieldNames['value']]);
56
+ }
57
+ return total;
58
+ }, [])
59
+ }].concat(_toConsumableArray(siblingsSum));
60
+ } else {
61
+ siblingsSum = [];
62
+ }
63
+ query.children = addTreeNodeAttrs(children, fieldNames, siblingsSum);
51
64
  }
52
65
  return Object.assign(Object.assign({}, query), {
53
66
  title: query[fieldNames['title']],
@@ -55,8 +68,9 @@ var addTreeNodeAttrs = exports.addTreeNodeAttrs = function addTreeNodeAttrs(tree
55
68
  disabled: query[fieldNames['disabled']],
56
69
  childrenValues: getNodeValuess(query, false),
57
70
  titleTotal: getNodeStr(query, fieldNames['title']),
58
- parentsValues: parentsValues,
59
- siblingsValue: siblingsValue
71
+ needCheckedLastestChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledLastestChildrenValues(item, fieldNames) : [],
72
+ needCheckedChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledChildrenValues(item, fieldNames) : [],
73
+ needCheckedSiblingsValue: !item[fieldNames['disabled']] ? needCheckedSiblingsValue : []
60
74
  });
61
75
  });
62
76
  }
@@ -115,13 +129,9 @@ var flatTreeData = exports.flatTreeData = function flatTreeData(treeData) {
115
129
  var i = _step.value;
116
130
  var value = i.value,
117
131
  children = i.children,
118
- childrenValues = i.childrenValues,
119
- parentsValues = i.parentsValues,
120
132
  titleTotal = i.titleTotal,
121
- siblingsValue = i.siblingsValue,
122
133
  title = i.title,
123
- disabled = i.disabled,
124
- rest = __rest(i, ["value", "children", "childrenValues", "parentsValues", "titleTotal", "siblingsValue", "title", "disabled"]);
134
+ rest = __rest(i, ["value", "children", "titleTotal", "title"]);
125
135
  // 判断是否命中过滤
126
136
  var bingo = true;
127
137
  var transFilterKey = !['', null, undefined].includes(filterKey);
@@ -131,17 +141,9 @@ var flatTreeData = exports.flatTreeData = function flatTreeData(treeData) {
131
141
  }) : false;
132
142
  }
133
143
  if (bingo) {
134
- result.push({
135
- value: value,
136
- children: children,
137
- title: title,
138
- level: level,
139
- titleTotal: titleTotal,
140
- childrenValues: childrenValues,
141
- parentsValues: parentsValues,
142
- siblingsValue: siblingsValue,
143
- disabled: disabled
144
- });
144
+ result.push(Object.assign({
145
+ level: level
146
+ }, i));
145
147
  }
146
148
  var selfIn = Array.isArray(expandedKeys) ? expandedKeys.includes(value) : false;
147
149
  if ((treeDefaultExpandAll || selfIn || transFilterKey && bingo) && Array.isArray(children) && !!children.length) {
@@ -186,7 +188,7 @@ var getFullExpandedKeys = exports.getFullExpandedKeys = function getFullExpanded
186
188
  return result;
187
189
  };
188
190
  /**
189
- * 获取所有选中的节点 (组件传入最后一层,需要将其上层和自身全部加入到expandedKeys)
191
+ * 初始化根据用户传入的值获取其关联节点是否要在checkList
190
192
  * @param {*} treeDataWithKeys
191
193
  * @param {*} transCheckedKeys
192
194
  * @param {*} result
@@ -198,38 +200,66 @@ var getFullCheckedKeys = exports.getFullCheckedKeys = function getFullCheckedKey
198
200
  return [];
199
201
  }
200
202
  treeDataWithKeys.forEach(function (i) {
201
- var childrenValues = i.childrenValues,
202
- value = i.value,
203
- children = i.children;
204
- if (Array.isArray(childrenValues) && [].concat(_toConsumableArray(childrenValues), [value]).some(function (el) {
205
- return transCheckedKeys.includes(el);
206
- })) {
203
+ var value = i.value,
204
+ children = i.children,
205
+ disabled = i.disabled;
206
+ var bingo = transCheckedKeys.includes(value);
207
+ if (bingo) {
207
208
  result.push(value);
208
- if (Array.isArray(children) && !!children.length) {
209
- result = [].concat(_toConsumableArray(result), _toConsumableArray(getFullCheckedKeys(children, transCheckedKeys)));
209
+ }
210
+ if (Array.isArray(children) && !!children.length) {
211
+ var lastestUnDisabledChildrenValues = i.needCheckedLastestChildrenValues;
212
+ // 如果当前节点是被命中,就将其下面所有子节点都选中
213
+ if (Array.isArray(lastestUnDisabledChildrenValues) && !!lastestUnDisabledChildrenValues.length && lastestUnDisabledChildrenValues.every(function (el) {
214
+ return transCheckedKeys.includes(el);
215
+ })) {
216
+ result.push(value);
210
217
  }
218
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getFullCheckedKeys(children, transCheckedKeys)));
211
219
  }
212
220
  });
213
221
  return result;
214
222
  };
215
223
  /**
216
- * 获取当前节点下的所有子节点
224
+ * 递归获取某个节点所有最下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了
225
+ * @param {*} node
217
226
  * @param {*} node
218
- * @param {*} result
219
227
  * @returns
220
228
  */
221
- var getNodeAllChildrenValue = exports.getNodeAllChildrenValue = function getNodeAllChildrenValue(node) {
222
- var isSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
229
+ var getNodeNoDisabledLastestChildrenValues = exports.getNodeNoDisabledLastestChildrenValues = function getNodeNoDisabledLastestChildrenValues(node, fieldNames) {
223
230
  var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
224
- var value = node.value,
225
- children = node.children;
226
- if (!['', null, undefined].includes(value) || !isSelf) {
227
- result.push(value);
231
+ if (Array.isArray(node.children) && !!node.children.length) {
232
+ node.children.forEach(function (element) {
233
+ if (!element[fieldNames['disabled']]) {
234
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeNoDisabledLastestChildrenValues(element, fieldNames)));
235
+ }
236
+ });
237
+ } else {
238
+ if (!node[fieldNames['disabled']]) {
239
+ result.push(node[fieldNames['value']]);
240
+ }
228
241
  }
229
- if (Array.isArray(children)) {
230
- children.forEach(function (i) {
231
- result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeAllChildrenValue(i, false)));
242
+ return result;
243
+ };
244
+ /**
245
+ * 递归获取某个节点所有下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了
246
+ * @param {*} node
247
+ * @param {*} node
248
+ * @returns
249
+ */
250
+ var getNodeNoDisabledChildrenValues = exports.getNodeNoDisabledChildrenValues = function getNodeNoDisabledChildrenValues(node, fieldNames) {
251
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
252
+ if (Array.isArray(node.children) && !!node.children.length) {
253
+ node.children.forEach(function (element) {
254
+ if (!element[fieldNames['disabled']]) {
255
+ result.push(element[fieldNames['value']]);
256
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeNoDisabledChildrenValues(element, fieldNames)));
257
+ }
232
258
  });
259
+ } else {
260
+ if (!node[fieldNames['disabled']]) {
261
+ result.push(node[fieldNames['value']]);
262
+ }
233
263
  }
234
264
  return result;
235
265
  };
@@ -238,47 +268,48 @@ var getNodeAllChildrenValue = exports.getNodeAllChildrenValue = function getNode
238
268
  * @param {*} item
239
269
  * @param {*} checkedList
240
270
  */
241
- var getIndeterminate = exports.getIndeterminate = function getIndeterminate(item, checkedList) {
242
- // 如果没有子节点,判断当前节点是否被选中
271
+ var getIndeterminate = exports.getIndeterminate = function getIndeterminate(item, checkedList, disabledList) {
272
+ // 如果没有子节点,就没有半选情况
243
273
  if (!Array.isArray(item.children) || !item.children.length) {
244
274
  return false;
245
275
  }
246
276
  if (!Array.isArray(checkedList) || !checkedList.length) {
247
277
  return false;
248
278
  }
249
- // 如果有子节点,判断子节点是否都被选中
250
- var list = getNodeAllChildrenValue(item);
279
+ // 当前节点下的去掉disabled的所有末级节点
280
+ var list = Array.isArray(item.needCheckedLastestChildrenValues) ? item.needCheckedLastestChildrenValues : [];
251
281
  var childrenCheckedList = list.filter(function (i) {
252
- return checkedList.includes(i);
282
+ return checkedList === null || checkedList === void 0 ? void 0 : checkedList.includes(i);
253
283
  });
254
284
  return childrenCheckedList.length > 0 && childrenCheckedList.length < list.length;
255
285
  };
256
286
  /**
257
287
  * 获取当前节点的父亲节点是否需要被选中
258
- * @param {*} parentsValues
259
- * @param {*} siblingsValue
288
+ * @param {*} needCheckedSiblingsValue
260
289
  * @param {*} checkedList
261
290
  * @returns
262
291
  */
263
- var getNodeParentChoosed = exports.getNodeParentChoosed = function getNodeParentChoosed(parentsValues, siblingsValue, checkedList) {
264
- if (!Array.isArray(parentsValues) || !parentsValues.length || !Array.isArray(checkedList) || !checkedList.length) {
292
+ var getNodeParentChoosed = exports.getNodeParentChoosed = function getNodeParentChoosed(needCheckedSiblingsValue, checkedList) {
293
+ if (!Array.isArray(checkedList) || !checkedList.length) {
265
294
  return [];
266
295
  }
267
296
  var result = [];
268
- var _iterator2 = _createForOfIteratorHelper(parentsValues),
297
+ var _iterator2 = _createForOfIteratorHelper(needCheckedSiblingsValue),
269
298
  _step2;
270
299
  try {
271
300
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
272
301
  var item = _step2.value;
273
- var list = Array.isArray(siblingsValue[item]) ? siblingsValue[item] : [];
274
- var bool = list.every(function (it) {
302
+ var _ref = item || {},
303
+ key = _ref.key,
304
+ list = _ref.list;
305
+ // 过滤掉子节点为disabled的
306
+ var bool = Array.isArray(list) ? list.every(function (it) {
275
307
  return checkedList.includes(it);
276
- });
277
- if (!bool) {
278
- break;
308
+ }) : false;
309
+ if (bool) {
310
+ checkedList.push(key);
311
+ result.push(key);
279
312
  }
280
- checkedList.push(item);
281
- result.push(item);
282
313
  }
283
314
  } catch (err) {
284
315
  _iterator2.e(err);
@@ -286,4 +317,37 @@ var getNodeParentChoosed = exports.getNodeParentChoosed = function getNodeParent
286
317
  _iterator2.f();
287
318
  }
288
319
  return result;
320
+ };
321
+ /**
322
+ * 获取节点的信息
323
+ * @param {*} tree
324
+ * @param {*} key
325
+ * @param {*} result
326
+ * @returns
327
+ */
328
+ var findNodeDetail = exports.findNodeDetail = function findNodeDetail(tree, key, result) {
329
+ if (Array.isArray(tree) && !!key) {
330
+ var _iterator3 = _createForOfIteratorHelper(tree),
331
+ _step3;
332
+ try {
333
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
334
+ var i = _step3.value;
335
+ if (i.value === key) {
336
+ result = i;
337
+ break;
338
+ }
339
+ if (Array.isArray(i.children) && !!i.children.length) {
340
+ result = findNodeDetail(i.children, key);
341
+ if (result) {
342
+ break;
343
+ }
344
+ }
345
+ }
346
+ } catch (err) {
347
+ _iterator3.e(err);
348
+ } finally {
349
+ _iterator3.f();
350
+ }
351
+ }
352
+ return result;
289
353
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree/utils.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAAQ,EACR,UAAU,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QA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AAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAExE,OAAO,mBAAmB,CAAC,MAAM,GAAG,CAAC,IAAI,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AACpF,CAAC,CAAC;AAhBW,QAAA,gBAAgB,oBAgB3B;AAEF;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;IAChF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;QAChH,OAAO,EAAE,CAAC;KACX;IACD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,IAAI,IAAI,aAAa,EAAE;QAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,EAAE;YACT,MAAM;SACP;QACD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAhBW,QAAA,oBAAoB,wBAgB/B","sourcesContent":["/**\n * 初始化给树的每个节点增加属性字段(childrenValues, titleTotal, parentsValues, siblingsValue),childrenValues: 当前节点下的所有子节点的value和, titleTotal: 当前节点下的所有子节点的title和 parentsValues: 当前节点所有的父节点 siblingsValue: 当前节点所有上级节点的兄弟节点\n * 用于判断后续展开/收起\n * @param {*} treeData\n */\nexport const addTreeNodeAttrs = (\n treeData,\n fieldNames = { title: 'title', value: 'value', children: 'children', disabled: 'disabled' },\n parentsValues = [],\n siblingsValue = {}\n) => {\n if (Array.isArray(treeData) && !!treeData.length) {\n return treeData.map((item) => {\n item.children = item[fieldNames['children']];\n item.title = item[fieldNames['title']];\n item.value = item[fieldNames['value']];\n const { children, ...query } = item;\n if (Array.isArray(children) && !!children.length) {\n query.children = addTreeNodeAttrs(children, fieldNames, [item.value, ...parentsValues], {\n ...siblingsValue,\n [item.value]: children.map((i) => i[fieldNames['value']])\n });\n }\n return {\n ...query,\n title: query[fieldNames['title']],\n value: query[fieldNames['value']],\n disabled: query[fieldNames['disabled']],\n childrenValues: getNodeValuess(query, false),\n titleTotal: getNodeStr(query, fieldNames['title']),\n parentsValues,\n siblingsValue\n };\n });\n }\n\n return [];\n};\n\nexport const getNodeStr = (node, key, result = []) => {\n result.push(node[key]);\n\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n result = [...result, ...getNodeStr(element, key)];\n });\n }\n\n return result;\n};\n\n/**\n * 获取每个节点下面所有子节点的value值\n * @param {*} node\n * @param {*} widthSelf 是否包含自己\n * @param {*} result\n * @returns []\n */\nexport const getNodeValuess = (node, widthSelf = true, result = []) => {\n if (widthSelf) {\n result.push(node.value);\n }\n\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n result = [...result, ...getNodeValuess(element)];\n });\n }\n\n return result;\n};\n\n/**\n * 扁平树\n * @param {*} treeData\n * @param {*} expandedKeys 展开的节点\n * @param {*} treeDefaultExpandAll\n * @param {*} level\n * @param {*} result\n * @returns\n */\nexport const flatTreeData = (treeData, filterKey = '', expandedKeys = [], treeDefaultExpandAll = false, level = 0, result = []) => {\n if (Array.isArray(treeData)) {\n for (const i of treeData) {\n const { value, children, childrenValues, parentsValues, titleTotal, siblingsValue, title, disabled, ...rest } = i;\n\n // 判断是否命中过滤\n let bingo = true;\n const transFilterKey = !['', null, undefined].includes(filterKey);\n if (transFilterKey) {\n bingo = Array.isArray(titleTotal) ? titleTotal.some((i) => i.includes(filterKey)) : false;\n }\n\n if (bingo) {\n result.push({ value, children, title, level, titleTotal, childrenValues, parentsValues, siblingsValue, disabled });\n }\n\n const selfIn = Array.isArray(expandedKeys) ? expandedKeys.includes(value) : false;\n if ((treeDefaultExpandAll || selfIn || (transFilterKey && bingo)) && Array.isArray(children) && !!children.length) {\n result = [...result, ...flatTreeData(children, filterKey, expandedKeys, treeDefaultExpandAll, level + 1)];\n }\n }\n }\n return result;\n};\n\n/**\n * 获取所有展开的节点 (组件传入最后一层,需要将其上层全部加入到expandedKeys)\n * @param {*} treeDataWithKeys\n * @param {*} treeExpandedKeys\n * @param {*} result\n * @returns\n */\nexport const getFullExpandedKeys = (treeDataWithKeys, treeExpandedKeys = [], treeDefaultExpandAll, result = []) => {\n if (\n !treeDefaultExpandAll &&\n (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(treeExpandedKeys) || !treeExpandedKeys.length)\n ) {\n return [];\n }\n\n treeDataWithKeys.forEach((i) => {\n const { childrenValues, value, children } = i;\n\n if (treeDefaultExpandAll || (Array.isArray(childrenValues) && [...childrenValues, value].some((el) => treeExpandedKeys.includes(el)))) {\n result.push(value);\n\n if (Array.isArray(children) && !!children.length) {\n result = [...result, ...getFullExpandedKeys(children, treeExpandedKeys, treeDefaultExpandAll)];\n }\n }\n });\n\n return result;\n};\n\n/**\n * 获取所有选中的节点 (组件传入最后一层,需要将其上层和自身全部加入到expandedKeys)\n * @param {*} treeDataWithKeys\n * @param {*} transCheckedKeys\n * @param {*} result\n * @returns\n */\nexport const getFullCheckedKeys = (treeDataWithKeys, transCheckedKeys, result = []) => {\n if (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(transCheckedKeys) || !transCheckedKeys.length) {\n return [];\n }\n\n treeDataWithKeys.forEach((i) => {\n const { childrenValues, value, children } = i;\n\n if (Array.isArray(childrenValues) && [...childrenValues, value].some((el) => transCheckedKeys.includes(el))) {\n result.push(value);\n\n if (Array.isArray(children) && !!children.length) {\n result = [...result, ...getFullCheckedKeys(children, transCheckedKeys)];\n }\n }\n });\n\n return result;\n};\n\n/**\n * 获取当前节点下的所有子节点\n * @param {*} node\n * @param {*} result\n * @returns\n */\nexport const getNodeAllChildrenValue = (node, isSelf = true, result = []) => {\n const { value, children } = node;\n\n if (!['', null, undefined].includes(value) || !isSelf) {\n result.push(value);\n }\n\n if (Array.isArray(children)) {\n children.forEach((i) => {\n result = [...result, ...getNodeAllChildrenValue(i, false)];\n });\n }\n\n return result;\n};\n\n/**\n * 判断当前节点是否半选\n * @param {*} item\n * @param {*} checkedList\n */\nexport const getIndeterminate = (item, checkedList) => {\n // 如果没有子节点,判断当前节点是否被选中\n if (!Array.isArray(item.children) || !item.children.length) {\n return false;\n }\n\n if (!Array.isArray(checkedList) || !checkedList.length) {\n return false;\n }\n\n // 如果有子节点,判断子节点是否都被选中\n const list = getNodeAllChildrenValue(item);\n\n const childrenCheckedList = list.filter((i) => checkedList.includes(i));\n\n return childrenCheckedList.length > 0 && childrenCheckedList.length < list.length;\n};\n\n/**\n * 获取当前节点的父亲节点是否需要被选中\n * @param {*} parentsValues\n * @param {*} siblingsValue\n * @param {*} checkedList\n * @returns\n */\nexport const getNodeParentChoosed = (parentsValues, siblingsValue, checkedList) => {\n if (!Array.isArray(parentsValues) || !parentsValues.length || !Array.isArray(checkedList) || !checkedList.length) {\n return [];\n }\n let result = [];\n for (let item of parentsValues) {\n const list = Array.isArray(siblingsValue[item]) ? siblingsValue[item] : [];\n const bool = list.every((it) => checkedList.includes(it));\n if (!bool) {\n break;\n }\n checkedList.push(item);\n result.push(item);\n }\n\n return result;\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree/utils.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA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子节点的value和(包含了disabled节点)用户展开/收起\n * titleTotal: 当前节点下的所有子节点的title和 (包含了disabled节点)用于搜索\n * needCheckedChildrenValues: 当前节点下的节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中\n * needCheckedLastestChildrenValues: 当前节点下的最底层节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中\n * needCheckedSiblingsValue: 当前节点所有上级节点的兄弟节点, [{ key: '上级节点value', list: [xx] }] list包含非disabled节点 用于选中/取消选中\n * 用于判断后续展开/收起\n * @param {*} treeData\n */\nexport const addTreeNodeAttrs = (\n treeData,\n fieldNames = { title: 'title', value: 'value', children: 'children', disabled: 'disabled' },\n needCheckedSiblingsValue = []\n) => {\n if (Array.isArray(treeData) && !!treeData.length) {\n return treeData.map((item) => {\n item.children = item[fieldNames['children']];\n item.title = item[fieldNames['title']];\n item.value = item[fieldNames['value']];\n const { children, ...query } = item;\n if (Array.isArray(children) && !!children.length) {\n let siblingsSum = needCheckedSiblingsValue;\n if (!item[fieldNames['disabled']]) {\n // 这里注意要逆序,要不然校验的时候会出问题\n siblingsSum = [\n {\n key: item[fieldNames['value']],\n list: children.reduce((total, item) => {\n if (!item[fieldNames['disabled']]) {\n total.push(item[fieldNames['value']]);\n }\n return total;\n }, [])\n },\n ...siblingsSum\n ];\n } else {\n siblingsSum = [];\n }\n query.children = addTreeNodeAttrs(children, fieldNames, siblingsSum);\n }\n return {\n ...query,\n title: query[fieldNames['title']],\n value: query[fieldNames['value']],\n disabled: query[fieldNames['disabled']],\n childrenValues: getNodeValuess(query, false),\n titleTotal: getNodeStr(query, fieldNames['title']),\n needCheckedLastestChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledLastestChildrenValues(item, fieldNames) : [],\n needCheckedChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledChildrenValues(item, fieldNames) : [],\n needCheckedSiblingsValue: !item[fieldNames['disabled']] ? needCheckedSiblingsValue : []\n };\n });\n }\n\n return [];\n};\n\nexport const getNodeStr = (node, key, result = []) => {\n result.push(node[key]);\n\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n result = [...result, ...getNodeStr(element, key)];\n });\n }\n\n return result;\n};\n\n/**\n * 获取每个节点下面所有子节点的value值\n * @param {*} node\n * @param {*} widthSelf 是否包含自己\n * @param {*} result\n * @returns []\n */\nexport const getNodeValuess = (node, widthSelf = true, result = []) => {\n if (widthSelf) {\n result.push(node.value);\n }\n\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n result = [...result, ...getNodeValuess(element)];\n });\n }\n\n return result;\n};\n\n/**\n * 扁平树\n * @param {*} treeData\n * @param {*} expandedKeys 展开的节点\n * @param {*} treeDefaultExpandAll\n * @param {*} level\n * @param {*} result\n * @returns\n */\nexport const flatTreeData = (treeData, filterKey = '', expandedKeys = [], treeDefaultExpandAll = false, level = 0, result = []) => {\n if (Array.isArray(treeData)) {\n for (const i of treeData) {\n const { value, children, titleTotal, title, ...rest } = i;\n\n // 判断是否命中过滤\n let bingo = true;\n const transFilterKey = !['', null, undefined].includes(filterKey);\n if (transFilterKey) {\n bingo = Array.isArray(titleTotal) ? titleTotal.some((i) => i.includes(filterKey)) : false;\n }\n\n if (bingo) {\n result.push({ level, ...i });\n }\n\n const selfIn = Array.isArray(expandedKeys) ? expandedKeys.includes(value) : false;\n if ((treeDefaultExpandAll || selfIn || (transFilterKey && bingo)) && Array.isArray(children) && !!children.length) {\n result = [...result, ...flatTreeData(children, filterKey, expandedKeys, treeDefaultExpandAll, level + 1)];\n }\n }\n }\n return result;\n};\n\n/**\n * 获取所有展开的节点 (组件传入最后一层,需要将其上层全部加入到expandedKeys)\n * @param {*} treeDataWithKeys\n * @param {*} treeExpandedKeys\n * @param {*} result\n * @returns\n */\nexport const getFullExpandedKeys = (treeDataWithKeys, treeExpandedKeys = [], treeDefaultExpandAll, result = []) => {\n if (\n !treeDefaultExpandAll &&\n (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(treeExpandedKeys) || !treeExpandedKeys.length)\n ) {\n return [];\n }\n\n treeDataWithKeys.forEach((i) => {\n const { childrenValues, value, children } = i;\n\n if (treeDefaultExpandAll || (Array.isArray(childrenValues) && [...childrenValues, value].some((el) => treeExpandedKeys.includes(el)))) {\n result.push(value);\n\n if (Array.isArray(children) && !!children.length) {\n result = [...result, ...getFullExpandedKeys(children, treeExpandedKeys, treeDefaultExpandAll)];\n }\n }\n });\n\n return result;\n};\n\n/**\n * 初始化根据用户传入的值获取其关联节点是否要在checkList\n * @param {*} treeDataWithKeys\n * @param {*} transCheckedKeys\n * @param {*} result\n * @returns\n */\nexport const getFullCheckedKeys = (treeDataWithKeys, transCheckedKeys, result = []) => {\n if (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(transCheckedKeys) || !transCheckedKeys.length) {\n return [];\n }\n\n treeDataWithKeys.forEach((i) => {\n const { value, children, disabled } = i;\n const bingo = transCheckedKeys.includes(value);\n if (bingo) {\n result.push(value);\n }\n\n if (Array.isArray(children) && !!children.length) {\n const lastestUnDisabledChildrenValues = i.needCheckedLastestChildrenValues;\n // 如果当前节点是被命中,就将其下面所有子节点都选中\n if (\n Array.isArray(lastestUnDisabledChildrenValues) &&\n !!lastestUnDisabledChildrenValues.length &&\n lastestUnDisabledChildrenValues.every((el) => transCheckedKeys.includes(el))\n ) {\n result.push(value);\n }\n result = [...result, ...getFullCheckedKeys(children, transCheckedKeys)];\n }\n });\n\n return result;\n};\n\n/**\n * 递归获取某个节点所有最下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了\n * @param {*} node\n * @param {*} node\n * @returns\n */\nexport const getNodeNoDisabledLastestChildrenValues = (node, fieldNames, result = []) => {\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n if (!element[fieldNames['disabled']]) {\n result = [...result, ...getNodeNoDisabledLastestChildrenValues(element, fieldNames)];\n }\n });\n } else {\n if (!node[fieldNames['disabled']]) {\n result.push(node[fieldNames['value']]);\n }\n }\n return result;\n};\n\n/**\n * 递归获取某个节点所有下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了\n * @param {*} node\n * @param {*} node\n * @returns\n */\nexport const getNodeNoDisabledChildrenValues = (node, fieldNames, result = []) => {\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n if (!element[fieldNames['disabled']]) {\n result.push(element[fieldNames['value']]);\n result = [...result, ...getNodeNoDisabledChildrenValues(element, fieldNames)];\n }\n });\n } else {\n if (!node[fieldNames['disabled']]) {\n result.push(node[fieldNames['value']]);\n }\n }\n return result;\n}\n\n/**\n * 判断当前节点是否半选\n * @param {*} item\n * @param {*} checkedList\n */\nexport const getIndeterminate = (item, checkedList, disabledList) => {\n // 如果没有子节点,就没有半选情况\n if (!Array.isArray(item.children) || !item.children.length) {\n return false;\n }\n\n if (!Array.isArray(checkedList) || !checkedList.length) {\n return false;\n }\n\n // 当前节点下的去掉disabled的所有末级节点\n const list = Array.isArray(item.needCheckedLastestChildrenValues) ? item.needCheckedLastestChildrenValues : [];\n const childrenCheckedList = list.filter((i) => checkedList?.includes(i));\n\n return childrenCheckedList.length > 0 && childrenCheckedList.length < list.length;\n};\n\n/**\n * 获取当前节点的父亲节点是否需要被选中\n * @param {*} needCheckedSiblingsValue\n * @param {*} checkedList\n * @returns\n */\nexport const getNodeParentChoosed = (needCheckedSiblingsValue, checkedList) => {\n if (!Array.isArray(checkedList) || !checkedList.length) {\n return [];\n }\n let result = [];\n for (let item of needCheckedSiblingsValue) {\n const { key, list } = item || {};\n // 过滤掉子节点为disabled的\n const bool = Array.isArray(list) ? list.every((it) => checkedList.includes(it)) : false;\n if (bool) {\n checkedList.push(key);\n result.push(key);\n }\n }\n\n return result;\n};\n\n/**\n * 获取节点的信息\n * @param {*} tree \n * @param {*} key \n * @param {*} result \n * @returns \n */\nexport const findNodeDetail = (tree, key, result) => {\n if (Array.isArray(tree) && !!key) {\n for (let i of tree) {\n if (i.value === key) {\n result = i;\n break;\n }\n if (Array.isArray(i.children) && !!i.children.length) {\n result = findNodeDetail(i.children, key);\n if (result) {\n break;\n }\n }\n }\n }\n\n return result;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tntd",
3
- "version": "3.0.9-beta.3",
3
+ "version": "3.0.10",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "start": "heft start --storybook",