UNPKG

@progress/kendo-angular-dropdowns

Version:

A wide variety of native Angular dropdown components including AutoComplete, ComboBox, DropDownList, DropDownTree, MultiColumnComboBox, MultiSelect, and MultiSelectTree

83 lines (82 loc) 2.69 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Injectable } from '@angular/core'; import { isPresent, valueFrom } from '../../common/util'; import * as i0 from "@angular/core"; /** * @hidden */ export const nodeIndex = (item) => (item || {}).key; /** * @hidden */ export const buildTreeIndex = (parentIndex, itemIndex) => { return [parentIndex, itemIndex].filter(part => isPresent(part)).join('_'); }; /** * @hidden */ export const buildTreeItem = (dataItem, valueField, currentLevelIndex) => { if (!isPresent(dataItem)) { return null; } return { dataItem, key: valueFrom({ dataItem, level: currentLevelIndex }, valueField) + '_' + currentLevelIndex }; }; /** * @hidden */ export class MultiSelectTreeLookupService { map = new Map(); reset() { this.map.clear(); } registerChildren(index, children) { const item = this.item(index); if (!item) { return; } item.children = children; } item(index) { return this.map.get(index) || null; } registerItem(item, parent) { const currentLookup = { children: [], item, parent: this.item(nodeIndex(parent)) }; this.map.set(item.key, currentLookup); } itemLookup(index) { const item = this.item(index); if (!item) { return null; } return { children: this.mapChildren(item.children), item: item.item, parent: item.parent }; } mapChildren(children = []) { return children.map(c => { const { item, parent, children } = this.item(c.key); return { children: this.mapChildren(children), item, parent }; }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiSelectTreeLookupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiSelectTreeLookupService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiSelectTreeLookupService, decorators: [{ type: Injectable }] });