UNPKG

@progress/kendo-angular-dropdowns

Version:

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

71 lines (70 loc) 3.39 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"; /** * Configures the MultiSelectTree to show one single summary tag for all selected data items. * When a number is set, the summary tag is shown after the corresponding number of data items are selected (see examples). * See [more information and examples]({% slug api_dropdowns_multiselecttreesummarytagdirective %}). * * @example * ```html * <kendo-multiselecttree kendoMultiSelectTreeSummaryTag [data]="data"></kendo-multiselecttree> * ``` * * @example * ```html * <kendo-multiselecttree [kendoMultiSelectTreeSummaryTag]="2" [data]="data"></kendo-multiselecttree> * ``` * * @remarks * Applied to: {@link MultiSelectTreeComponent}. */ export class MultiSelectTreeSummaryTagDirective { multiSelectTreeComponent; /** * Sets the number of data items that need to be selected before the summary tag appears. * * @default 0 */ 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'] }] } });