import type { GridRowId } from '../types' import type { Collection } from './types' export function selectAll( collection: Collection, matchedIds?: Set | null ) { const collect = (nodeId: GridRowId, memo: Set) => { if (matchedIds && !matchedIds.has(nodeId)) { return } const meta = collection.meta.get(nodeId) if (meta?.type !== 'group') { memo.add(nodeId) } if (meta?.children?.length) { meta.children.forEach((childId) => collect(childId, memo)) } } const memo = new Set() collection.ids.forEach((id) => { collect(id, memo) }) return memo }