import { Pipe, PipeTransform } from '@angular/core'; // config import { ICaInputWithDropdown } from '../../ca-input/config'; // interfaces import { IOptionModel } from '../interfaces/input-dropdown-option.interface'; @Pipe({ name: 'inputDropdownGetIcons', standalone: true, }) export class InputDropdownGetIconsPipe implements PipeTransform { transform( option: ICaInputWithDropdown, activeItem: IOptionModel | null ): string { const activeItemPath = getValueByPath( activeItem, option.activeItemIconKey ); return `${option.iconsPath}${activeItemPath || ''}`; } } function getValueByPath(obj: any, path: string | undefined): any { return path?.split('.').reduce((acc, part) => acc?.[part], obj); }