@progress/kendo-angular-dropdowns
Version:
A wide variety of native Angular dropdown components including AutoComplete, ComboBox, DropDownList, DropDownTree, MultiColumnComboBox, MultiSelect, and MultiSelectTree
67 lines (66 loc) • 3.14 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* 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";
/**
* A directive which configures the MultiSelect 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 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;
/**
* A numeric value that indicates the number of selected data items after which the summary tag will appear.
*/
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']
}] } });