UNPKG

@progress/kendo-angular-dropdowns

Version:

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

66 lines (65 loc) 3.33 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, Input } from '@angular/core'; import { isPresent, parseNumber } from '../../common/util'; import { MultiSelectTreeComponent } from '../multiselecttree.component'; import * as i0 from "@angular/core"; import * as i1 from "../multiselecttree.component"; /** * A directive which configures the MultiSelectTree to show one single summary tag for all selected data items. * When a number is provided, the summary tag is displayed after the given amount of data items are selected * ([more information and examples]({% slug api_dropdowns_multiselecttreesummarytagdirective %})). * * @example * ```ts-no-run * <kendo-multiselecttree kendoMultiSelectTreeSummaryTag [data]="data"></kendo-multiselecttree> * ``` * * @example * ```ts-no-run * <kendo-multiselecttree [kendoMultiSelectTreeSummaryTag]="2" [data]="data"></kendo-multiselecttree> * ``` */ export class MultiSelectTreeSummaryTagDirective { multiSelectTreeComponent; /** * A numeric value that indicates the number of selected data items after which the summary tag will appear. */ showAfter = 0; constructor(multiSelectTreeComponent) { this.multiSelectTreeComponent = multiSelectTreeComponent; this.createTagMapper(); } ngOnChanges(changes) { if (isPresent(changes.showAfter)) { this.createTagMapper(); this.multiSelectTreeComponent.handleTagMapperChange(this.showAfter); } } createTagMapper() { const showAfter = parseNumber(this.showAfter); this.multiSelectTreeComponent.tagMapper = (tags) => { if (tags.length > showAfter) { // tags provided in an array are rendered as a single group tag return [...tags.slice(0, showAfter), tags.slice(showAfter)]; } else { return tags; } }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiSelectTreeSummaryTagDirective, deps: [{ token: i1.MultiSelectTreeComponent }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: MultiSelectTreeSummaryTagDirective, isStandalone: true, selector: "[kendoMultiSelectTreeSummaryTag]", inputs: { showAfter: ["kendoMultiSelectTreeSummaryTag", "showAfter"] }, usesOnChanges: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiSelectTreeSummaryTagDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoMultiSelectTreeSummaryTag]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.MultiSelectTreeComponent }]; }, propDecorators: { showAfter: [{ type: Input, args: ['kendoMultiSelectTreeSummaryTag'] }] } });