function searchList()

in packages/x-flow/src/components/NodesMenu/index.tsx [17:34]


  function searchList(nodes: any, preResult = []) {
    if (nodes.length === 0) {
      return preResult;
    }

    const [currentNode, ...restNodes] = nodes;
    let result: any = [...preResult];

    if (currentNode.title.toLowerCase().includes(searchTerm)) {
      result.push(currentNode);
    } else if (currentNode?.type === '_group' && currentNode.items) {
      const matchingItems = searchList(currentNode.items);
      if (matchingItems.length > 0) {
        result.push({ ...currentNode, items: matchingItems });
      }
    }
    return searchList(restNodes, result);
  }