UNPKG

@progress/kendo-angular-dropdowns

Version:

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

69 lines (68 loc) 3.06 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 { MultiSelectComponent } from './multiselect.component'; import * as i0 from "@angular/core"; import * as i1 from "./multiselect.component"; /** * Configures the MultiSelect to show one summary tag for all selected items. * Set a number to display the summary tag after the respective number of items are selected. * [See example]({% slug summarytagmode_multiselect %}). * * @example * ```ts-no-run * <kendo-multiselect kendoMultiSelectSummaryTag [data]="data"></kendo-multiselect> * ``` * * @example * ```ts-no-run * <kendo-multiselect [kendoMultiSelectSummaryTag]="2" [data]="data"></kendo-multiselect> * ``` */ export class SummaryTagDirective { multiSelectComponent; /** * Sets the number of selected items after which the summary tag appears. * * @default 0 */ showAfter = 0; constructor(multiSelectComponent) { this.multiSelectComponent = multiSelectComponent; this.createTagMapper(); } ngOnChanges(changes) { if (isPresent(changes.showAfter)) { this.createTagMapper(); this.multiSelectComponent.onTagMapperChange(); } } createTagMapper() { const showAfter = parseNumber(this.showAfter); this.multiSelectComponent.tagMapper = (tags) => { if (tags.length > showAfter) { const result = tags.slice(0, showAfter); result.push(tags.slice(showAfter, tags.length)); return result; } else { return tags; } }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SummaryTagDirective, deps: [{ token: i1.MultiSelectComponent }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SummaryTagDirective, isStandalone: true, selector: "[kendoMultiSelectSummaryTag]", inputs: { showAfter: ["kendoMultiSelectSummaryTag", "showAfter"] }, usesOnChanges: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SummaryTagDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoMultiSelectSummaryTag]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.MultiSelectComponent }]; }, propDecorators: { showAfter: [{ type: Input, args: ['kendoMultiSelectSummaryTag'] }] } });