node_modules/ant-design-vue/es/vc-tree/utils/treeUtil.js
/**
 * Flat nest tree data into flatten list. This is used for virtual list render.
 * @param treeNodeList Origin data node list
 * @param expandedKeys
 * need expanded keys, provides `true` means all expanded (used in `rc-tree-select`).
 */
Flat nest tree data into flatten list. This is used for virtual list render.
@param treeNodeList Origin data node list
@param expandedKeys
need expanded keys, provides `true` means all expanded (used in `rc-tree-select`).
Flat nest tree data into flatten list . This is used for virtual list render . @param treeNodeList Origin data node list @param expandedKeys need expanded keys provides ` true ` means all expanded ( used in ` rc - tree - select ` ) .
function flattenTreeData(treeNodeList, expandedKeys, fieldNames) {
  var _fillFieldNames = fillFieldNames(fieldNames),
      fieldTitles = _fillFieldNames._title,
      fieldKey = _fillFieldNames.key,
      fieldChildren = _fillFieldNames.children;
  var expandedKeySet = new Set(expandedKeys === true ? [] : expandedKeys);
  var flattenList = [];
  function dig(list) {
    var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
    return list.map(function (treeNode, index) {
      var pos = getPosition(parent ? parent.pos : '0', index);
      var mergedKey = getKey(treeNode[fieldKey], pos); 
      var mergedTitle;
      for (var i = 0; i < fieldTitles.length; i += 1) {
        var fieldTitle = fieldTitles[i];
        if (treeNode[fieldTitle] !== undefined) {
          mergedTitle = treeNode[fieldTitle];
          break;
        }
      } 
      var flattenNode = _extends(_extends({}, omit(treeNode, [].concat(_toConsumableArray(fieldTitles), [fieldKey, fieldChildren]))), {
        title: mergedTitle,
        key: mergedKey,
        parent: parent,
        pos: pos,
        children: null,
        data: treeNode,
        isStart: [].concat(_toConsumableArray(parent ? parent.isStart : []), [index === 0]),
        isEnd: [].concat(_toConsumableArray(parent ? parent.isEnd : []), [index === list.length - 1])
      });
      flattenList.push(flattenNode); 
      if (expandedKeys === true || expandedKeySet.has(mergedKey)) {
        flattenNode.children = dig(treeNode[fieldChildren] || [], flattenNode);
      } else {
        flattenNode.children = [];
      }
      return flattenNode;
    });
  }
  dig(treeNodeList);
  return flattenList;
}
function flattenTreeData ( treeNodeList , expandedKeys , fieldNames ) { var _fillFieldNames = fillFieldNames ( fieldNames ) , fieldTitles = _fillFieldNames . _title , fieldKey = _fillFieldNames . key , fieldChildren = _fillFieldNames . children ; var expandedKeySet = new Set ( expandedKeys === true ? [ ] : expandedKeys ) ; var flattenList = [ ] ; function dig ( list ) { var parent = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : null ; return list . map ( function ( treeNode , index ) { var pos = getPosition ( parent ? parent . pos : '0' , index ) ; var mergedKey = getKey ( treeNode [ fieldKey ] , pos ) ; var mergedTitle ; for ( var i = 0 ; i < fieldTitles . length ; i += 1 ) { var fieldTitle = fieldTitles [ i ] ; if ( treeNode [ fieldTitle ] !== undefined ) { mergedTitle = treeNode [ fieldTitle ] ; break ; } } var flattenNode = _extends ( _extends ( { } , omit ( treeNode , [ ] . concat ( _toConsumableArray ( fieldTitles ) , [ fieldKey , fieldChildren ] ) ) ) , { title : mergedTitle , key : mergedKey , parent : parent , pos : pos , children : null , data : treeNode , isStart : [ ] . concat ( _toConsumableArray ( parent ? parent . isStart : [ ] ) , [ index === 0 ] ) , isEnd : [ ] . concat ( _toConsumableArray ( parent ? parent . isEnd : [ ] ) , [ index === list . length - 1 ] ) } ) ; flattenList . push ( flattenNode ) ; if ( expandedKeys === true || expandedKeySet . has ( mergedKey ) ) { flattenNode . children = dig ( treeNode [ fieldChildren ] || [ ] , flattenNode ) ; } else { flattenNode . children = [ ] ; } return flattenNode ; } ) ; } dig ( treeNodeList ) ; return flattenList ; }
Flat nest tree data into flatten list.
Flat nest tree data into flatten list .
// Pick matched title in field title list // Add FlattenDataNode into list // Loop treeNode children