import _ from 'lodash' import { LevelSelectDataItem } from './types' function getItems( data: LevelSelectDataItem[], selected: V[] ): LevelSelectDataItem[] { const items: LevelSelectDataItem[] = [] selected.forEach((value, index) => { const list = index === 0 ? data : items[index - 1].children const match = _.find(list, (item) => item.value === value) items.push(match!) }) return items } export { getItems }