primeng
Version:
PrimeNG is an open source UI library for Angular featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeB
2,944 lines • 136 kB
JavaScript
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, forwardRef, EventEmitter, booleanAttribute, numberAttribute, Output, Input, ViewEncapsulation, Component, inject, signal, computed, effect, HostBinding, ContentChildren, ContentChild, ViewChild, ChangeDetectionStrategy, NgModule } from '@angular/core';
import * as i2 from '@angular/forms';
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import { deepEquals, isNotEmpty, isArray, uuid, equals, focus, findLastIndex, resolveFieldData, isPrintableCharacter, getFirstFocusableElement, getLastFocusableElement, findSingle, unblockBodyScroll, hasClass, isHidden, getFocusableElements } from '@primeuix/utils';
import * as i3 from 'primeng/api';
import { SharedModule, TranslationKeys, Footer, Header, PrimeTemplate } from 'primeng/api';
import { AutoFocus } from 'primeng/autofocus';
import { BaseComponent } from 'primeng/basecomponent';
import { Checkbox } from 'primeng/checkbox';
import { Chip } from 'primeng/chip';
import { DomHandler } from 'primeng/dom';
import { IconField } from 'primeng/iconfield';
import { CheckIcon, SearchIcon, TimesIcon, ChevronDownIcon } from 'primeng/icons';
import { InputIcon } from 'primeng/inputicon';
import { InputText } from 'primeng/inputtext';
import { Overlay } from 'primeng/overlay';
import { Ripple } from 'primeng/ripple';
import { Scroller } from 'primeng/scroller';
import { Tooltip } from 'primeng/tooltip';
import { BaseStyle } from 'primeng/base';
import { ObjectUtils } from 'primeng/utils';
const theme = ({ dt }) => `
.p-multiselect {
display: inline-flex;
cursor: pointer;
position: relative;
user-select: none;
background: ${dt('multiselect.background')};
border: 1px solid ${dt('multiselect.border.color')};
transition: background ${dt('multiselect.transition.duration')}, color ${dt('multiselect.transition.duration')}, border-color ${dt('multiselect.transition.duration')}, outline-color ${dt('multiselect.transition.duration')}, box-shadow ${dt('multiselect.transition.duration')};
border-radius: ${dt('multiselect.border.radius')};
outline-color: transparent;
box-shadow: ${dt('multiselect.shadow')};
}
.p-multiselect.ng-invalid.ng-dirty {
border-color: ${dt('multiselect.invalid.border.color')};
}
.p-multiselect:not(.p-disabled):hover {
border-color: ${dt('multiselect.hover.border.color')};
}
.p-multiselect:not(.p-disabled).p-focus {
border-color: ${dt('multiselect.focus.border.color')};
box-shadow: ${dt('multiselect.focus.ring.shadow')};
outline: ${dt('multiselect.focus.ring.width')} ${dt('multiselect.focus.ring.style')} ${dt('multiselect.focus.ring.color')};
outline-offset: ${dt('multiselect.focus.ring.offset')};
}
.p-multiselect.p-variant-filled {
background: ${dt('multiselect.filled.background')};
}
.p-multiselect.p-variant-filled:not(.p-disabled):hover {
background: ${dt('multiselect.filled.hover.background')};
}
.p-multiselect.p-variant-filled.p-focus {
background: ${dt('multiselect.filled.focus.background')};
}
.p-multiselect.p-disabled {
opacity: 1;
background: ${dt('multiselect.disabled.background')};
}
.p-multiselect-dropdown {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
background: transparent;
color: ${dt('multiselect.dropdown.color')};
width: ${dt('multiselect.dropdown.width')};
border-start-end-radius: ${dt('multiselect.border.radius')};
border-end-end-radius: ${dt('multiselect.border.radius')};
}
.p-multiselect-label-container {
overflow: hidden;
flex: 1 1 auto;
cursor: pointer;
}
.p-multiselect-label {
display: flex;
align-items-center;
gap: calc(${dt('multiselect.padding.y')} / 2);
white-space: nowrap;
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
padding: ${dt('multiselect.padding.y')} ${dt('multiselect.padding.x')};
color: ${dt('multiselect.color')};
}
.p-multiselect-label.p-placeholder {
color: ${dt('multiselect.placeholder.color')};
}
p-multiselect.ng-invalid.ng-dirty .p-multiselect-label.p-placeholder {
color: ${dt('multiselect.invalid.placeholder.color')};
}
.p-multiselect.p-disabled .p-multiselect-label {
color: ${dt('multiselect.disabled.color')};
}
.p-multiselect-label-empty {
overflow: hidden;
visibility: hidden;
}
.p-multiselect .p-multiselect-overlay {
min-width: 100%;
}
.p-multiselect-overlay {
background: ${dt('multiselect.overlay.background')};
color: ${dt('multiselect.overlay.color')};
border: 1px solid ${dt('multiselect.overlay.border.color')};
border-radius: ${dt('multiselect.overlay.border.radius')};
box-shadow: ${dt('multiselect.overlay.shadow')};
}
.p-multiselect-header {
display: flex;
align-items: center;
padding: ${dt('multiselect.list.header.padding')};
}
.p-multiselect-header .p-checkbox {
margin-inline-end: ${dt('multiselect.option.gap')};
}
.p-multiselect-filter-container {
flex: 1 1 auto;
}
.p-multiselect-filter {
width: 100%;
}
.p-multiselect-list-container {
overflow: auto;
}
.p-multiselect-list {
margin: 0;
padding: 0;
list-style-type: none;
padding: ${dt('multiselect.list.padding')};
display: flex;
flex-direction: column;
gap: ${dt('multiselect.list.gap')}
}
.p-multiselect-option {
cursor: pointer;
font-weight: normal;
white-space: nowrap;
position: relative;
overflow: hidden;
display: flex;
align-items: center;
gap: ${dt('multiselect.option.gap')};
padding: ${dt('multiselect.option.padding')};
border: 0 none;
color: ${dt('multiselect.option.color')};
background: transparent;
transition: background ${dt('multiselect.transition.duration')}, color ${dt('multiselect.transition.duration')}, border-color ${dt('multiselect.transition.duration')}, box-shadow ${dt('multiselect.transition.duration')}, outline-color ${dt('multiselect.transition.duration')};
border-radius: ${dt('multiselect.option.border.radius')}
}
.p-multiselect-option:not(.p-multiselect-option-selected):not(.p-disabled).p-focus {
background: ${dt('multiselect.option.focus.background')};
color: ${dt('multiselect.option.focus.color')};
}
.p-multiselect-option.p-multiselect-option-selected {
background: ${dt('multiselect.option.selected.background')};
color: ${dt('multiselect.option.selected.color')};
}
.p-multiselect-option.p-multiselect-option-selected.p-focus {
background: ${dt('multiselect.option.selected.focus.background')};
color: ${dt('multiselect.option.selected.focus.color')};
}
.p-multiselect-option-group {
cursor: auto;
margin: 0;
padding: ${dt('multiselect.option.group.padding')};
background: ${dt('multiselect.option.group.background')};
color: ${dt('multiselect.option.group.color')};
font-weight: ${dt('multiselect.option.group.font.weight')};
}
.p-multiselect-empty-message {
padding: ${dt('multiselect.empty.message.padding')};
}
.p-multiselect-label .p-chip {
padding-top: calc(${dt('multiselect.padding.y')} / 2);
padding-bottom: calc(${dt('multiselect.padding.y')} / 2);
border-radius: ${dt('multiselect.chip.border.radius')};
}
.p-multiselect-label:has(.p-chip) {
padding: calc(${dt('multiselect.padding.y')} / 2) calc(${dt('multiselect.padding.x')} / 2);
}
.p-multiselect-fluid {
display: flex;
}
.p-multiselect-sm .p-multiselect-label {
font-size: ${dt('multiselect.sm.font.size')};
padding-block: ${dt('multiselect.sm.padding.y')};
padding-inline: ${dt('multiselect.sm.padding.x')};
}
.p-multiselect-sm .p-multiselect-dropdown .p-icon {
font-size: ${dt('multiselect.sm.font.size')};
width: ${dt('multiselect.sm.font.size')};
height: ${dt('multiselect.sm.font.size')};
}
.p-multiselect-lg .p-multiselect-label {
font-size: ${dt('multiselect.lg.font.size')};
padding-block: ${dt('multiselect.lg.padding.y')};
padding-inline: ${dt('multiselect.lg.padding.x')};
}
.p-multiselect-lg .p-multiselect-dropdown .p-icon {
font-size: ${dt('multiselect.lg.font.size')};
width: ${dt('multiselect.lg.font.size')};
height: ${dt('multiselect.lg.font.size')};
}
.p-multiselect-clear-icon {
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
background: transparent;
color: ${dt('multiselect.clear.icon.color')};
}`;
const inlineStyles = {
root: ({ props }) => ({ position: props.appendTo === 'self' ? 'relative' : undefined })
};
const classes = {
root: ({ instance }) => ({
'p-multiselect p-component p-inputwrapper': true,
'p-multiselect-display-chip': instance.display === 'chip',
'p-disabled': instance.disabled,
'p-invalid': instance.invalid,
'p-variant-filled': instance.variant ? instance.variant === 'filled' : instance.config.inputStyle === 'filled',
'p-focus': instance.focused,
'p-inputwrapper-filled': instance.filled,
'p-inputwrapper-focus': instance.focused || instance.overlayVisible,
'p-multiselect-open': instance.overlayVisible,
'p-multiselect-fluid': instance.hasFluid,
'p-multiselect-sm p-inputfield-sm': instance.size === 'small',
'p-multiselect-lg p-inputfield-lg': instance.size === 'large'
}),
labelContainer: 'p-multiselect-label-container',
label: ({ instance }) => ({
'p-multiselect-label': true,
'p-placeholder': instance.label() === instance.placeholder(),
'p-multiselect-label-empty': !instance.placeholder() && !instance.defaultLabel && (!instance.modelValue() || instance.modelValue().length === 0)
}),
chipItem: 'p-multiselect-chip-item',
pcChip: 'p-multiselect-chip',
chipIcon: 'p-multiselect-chip-icon',
dropdown: 'p-multiselect-dropdown',
loadingIcon: 'p-multiselect-loading-icon',
dropdownIcon: 'p-multiselect-dropdown-icon',
overlay: 'p-multiselect-overlay p-component',
header: 'p-multiselect-header',
pcFilterContainer: 'p-multiselect-filter-container',
pcFilter: 'p-multiselect-filter',
listContainer: 'p-multiselect-list-container',
list: 'p-multiselect-list',
optionGroup: 'p-multiselect-option-group',
option: ({ instance, option, index, getItemOptions }) => ({
'p-multiselect-option': true,
'p-multiselect-option-selected': instance.isSelected(option) && instance.highlightOnSelect,
'p-focus': instance.focusedOptionIndex === instance.getOptionIndex(index, getItemOptions),
'p-disabled': instance.isOptionDisabled(option)
}),
emptyMessage: 'p-multiselect-empty-message'
};
class MultiSelectStyle extends BaseStyle {
name = 'multiselect';
theme = theme;
classes = classes;
inlineStyles = inlineStyles;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectStyle });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectStyle, decorators: [{
type: Injectable
}] });
/**
*
* MultiSelect is used to select multiple items from a collection.
*
* [Live Demo](https://www.primeng.org/multiselect/)
*
* @module multiselectstyle
*
*/
var MultiSelectClasses;
(function (MultiSelectClasses) {
/**
* Class name of the root element
*/
MultiSelectClasses["root"] = "p-multiselect";
/**
* Class name of the label container element
*/
MultiSelectClasses["labelContainer"] = "p-multiselect-label-container";
/**
* Class name of the label element
*/
MultiSelectClasses["label"] = "p-multiselect-label";
/**
* Class name of the chip item element
*/
MultiSelectClasses["chipItem"] = "p-multiselect-chip-item";
/**
* Class name of the chip element
*/
MultiSelectClasses["pcChip"] = "p-multiselect-chip";
/**
* Class name of the chip icon element
*/
MultiSelectClasses["chipIcon"] = "p-multiselect-chip-icon";
/**
* Class name of the dropdown element
*/
MultiSelectClasses["dropdown"] = "p-multiselect-dropdown";
/**
* Class name of the loading icon element
*/
MultiSelectClasses["loadingIcon"] = "p-multiselect-loading-icon";
/**
* Class name of the dropdown icon element
*/
MultiSelectClasses["dropdownIcon"] = "p-multiselect-dropdown-icon";
/**
* Class name of the overlay element
*/
MultiSelectClasses["overlay"] = "p-multiselect-overlay";
/**
* Class name of the header element
*/
MultiSelectClasses["header"] = "p-multiselect-header";
/**
* Class name of the filter container element
*/
MultiSelectClasses["pcFilterContainer"] = "p-multiselect-filter-container";
/**
* Class name of the filter element
*/
MultiSelectClasses["pcFilter"] = "p-multiselect-filter";
/**
* Class name of the list container element
*/
MultiSelectClasses["listContainer"] = "p-multiselect-list-container";
/**
* Class name of the list element
*/
MultiSelectClasses["list"] = "p-multiselect-list";
/**
* Class name of the option group element
*/
MultiSelectClasses["optionGroup"] = "p-multiselect-option-group";
/**
* Class name of the option element
*/
MultiSelectClasses["option"] = "p-multiselect-option";
/**
* Class name of the empty message element
*/
MultiSelectClasses["emptyMessage"] = "p-multiselect-empty-message";
})(MultiSelectClasses || (MultiSelectClasses = {}));
const MULTISELECT_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MultiSelect),
multi: true
};
class MultiSelectItem extends BaseComponent {
id;
option;
selected;
label;
disabled;
itemSize;
focused;
ariaPosInset;
ariaSetSize;
variant;
template;
checkIconTemplate;
itemCheckboxIconTemplate;
onClick = new EventEmitter();
onMouseEnter = new EventEmitter();
onOptionClick(event) {
this.onClick.emit({
originalEvent: event,
option: this.option,
selected: this.selected
});
event.stopPropagation();
event.preventDefault();
}
onOptionMouseEnter(event) {
this.onMouseEnter.emit({
originalEvent: event,
option: this.option,
selected: this.selected
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectItem, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.2", type: MultiSelectItem, isStandalone: true, selector: "p-multiSelectItem, p-multiselect-item", inputs: { id: "id", option: "option", selected: ["selected", "selected", booleanAttribute], label: "label", disabled: ["disabled", "disabled", booleanAttribute], itemSize: ["itemSize", "itemSize", numberAttribute], focused: ["focused", "focused", booleanAttribute], ariaPosInset: "ariaPosInset", ariaSetSize: "ariaSetSize", variant: "variant", template: "template", checkIconTemplate: "checkIconTemplate", itemCheckboxIconTemplate: "itemCheckboxIconTemplate" }, outputs: { onClick: "onClick", onMouseEnter: "onMouseEnter" }, usesInheritance: true, ngImport: i0, template: `
<li
pRipple
role="option"
[ngStyle]="{ height: itemSize + 'px' }"
[ngClass]="{
'p-multiselect-option': true,
'p-disabled': disabled,
'p-focus': focused
}"
[id]="id"
[attr.aria-label]="label"
[attr.aria-setsize]="ariaSetSize"
[attr.aria-posinset]="ariaPosInset"
[attr.aria-selected]="selected"
[attr.data-p-focused]="focused"
[attr.data-p-highlight]="selected"
[attr.data-p-disabled]="disabled"
[attr.aria-checked]="selected"
(click)="onOptionClick($event)"
(mouseenter)="onOptionMouseEnter($event)"
>
<p-checkbox [ngModel]="selected" [binary]="true" [tabindex]="-1" [variant]="variant" [ariaLabel]="label">
<ng-container *ngIf="itemCheckboxIconTemplate">
<ng-template #checkboxicon let-klass="class">
<ng-template *ngTemplateOutlet="itemCheckboxIconTemplate; context: { checked: selected, class: klass }"></ng-template>
</ng-template>
</ng-container>
</p-checkbox>
<span *ngIf="!template">{{ label ?? 'empty' }}</span>
<ng-container *ngTemplateOutlet="template; context: { $implicit: option }"></ng-container>
</li>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: Checkbox, selector: "p-checkbox, p-checkBox, p-check-box", inputs: ["value", "name", "disabled", "binary", "ariaLabelledBy", "ariaLabel", "tabindex", "inputId", "style", "inputStyle", "styleClass", "inputClass", "indeterminate", "size", "formControl", "checkboxIcon", "readonly", "required", "autofocus", "trueValue", "falseValue", "variant"], outputs: ["onChange", "onFocus", "onBlur"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: Ripple, selector: "[pRipple]" }, { kind: "ngmodule", type: SharedModule }], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectItem, decorators: [{
type: Component,
args: [{
selector: 'p-multiSelectItem, p-multiselect-item',
standalone: true,
imports: [CommonModule, Checkbox, FormsModule, Ripple, SharedModule],
template: `
<li
pRipple
role="option"
[ngStyle]="{ height: itemSize + 'px' }"
[ngClass]="{
'p-multiselect-option': true,
'p-disabled': disabled,
'p-focus': focused
}"
[id]="id"
[attr.aria-label]="label"
[attr.aria-setsize]="ariaSetSize"
[attr.aria-posinset]="ariaPosInset"
[attr.aria-selected]="selected"
[attr.data-p-focused]="focused"
[attr.data-p-highlight]="selected"
[attr.data-p-disabled]="disabled"
[attr.aria-checked]="selected"
(click)="onOptionClick($event)"
(mouseenter)="onOptionMouseEnter($event)"
>
<p-checkbox [ngModel]="selected" [binary]="true" [tabindex]="-1" [variant]="variant" [ariaLabel]="label">
<ng-container *ngIf="itemCheckboxIconTemplate">
<ng-template #checkboxicon let-klass="class">
<ng-template *ngTemplateOutlet="itemCheckboxIconTemplate; context: { checked: selected, class: klass }"></ng-template>
</ng-template>
</ng-container>
</p-checkbox>
<span *ngIf="!template">{{ label ?? 'empty' }}</span>
<ng-container *ngTemplateOutlet="template; context: { $implicit: option }"></ng-container>
</li>
`,
encapsulation: ViewEncapsulation.None
}]
}], propDecorators: { id: [{
type: Input
}], option: [{
type: Input
}], selected: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], label: [{
type: Input
}], disabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], itemSize: [{
type: Input,
args: [{ transform: numberAttribute }]
}], focused: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], ariaPosInset: [{
type: Input
}], ariaSetSize: [{
type: Input
}], variant: [{
type: Input
}], template: [{
type: Input
}], checkIconTemplate: [{
type: Input
}], itemCheckboxIconTemplate: [{
type: Input
}], onClick: [{
type: Output
}], onMouseEnter: [{
type: Output
}] } });
// @ts-ignore
/**
* MultiSelect is used to select multiple items from a collection.
* @group Components
*/
class MultiSelect extends BaseComponent {
zone;
filterService;
overlayService;
/**
* Unique identifier of the component
* @group Props
*/
id;
/**
* Defines a string that labels the input for accessibility.
* @group Props
*/
ariaLabel;
/**
* Inline style of the element.
* @group Props
*/
style;
/**
* Style class of the element.
* @group Props
*/
styleClass;
/**
* Inline style of the overlay panel.
* @group Props
*/
panelStyle;
/**
* Style class of the overlay panel element.
* @group Props
*/
panelStyleClass;
/**
* Identifier of the focus input to match a label defined for the component.
* @group Props
*/
inputId;
/**
* When present, it specifies that the element should be disabled.
* @group Props
*/
disabled;
/**
* Spans 100% width of the container when enabled.
* @group Props
*/
fluid;
/**
* When present, it specifies that the component cannot be edited.
* @group Props
*/
readonly;
/**
* Whether to display options as grouped when nested options are provided.
* @group Props
*/
group;
/**
* When specified, displays an input field to filter the items on keyup.
* @group Props
*/
filter = true;
/**
* Defines placeholder of the filter input.
* @group Props
*/
filterPlaceHolder;
/**
* Locale to use in filtering. The default locale is the host environment's current locale.
* @group Props
*/
filterLocale;
/**
* Specifies the visibility of the options panel.
* @group Props
*/
overlayVisible;
/**
* Index of the element in tabbing order.
* @group Props
*/
tabindex = 0;
/**
* Specifies the input variant of the component.
* @group Props
*/
variant;
/**
* Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).
* @group Props
*/
appendTo;
/**
* A property to uniquely identify a value in options.
* @group Props
*/
dataKey;
/**
* Name of the input element.
* @group Props
*/
name;
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
* @group Props
*/
ariaLabelledBy;
/**
* Whether to show labels of selected item labels or use default label.
* @group Props
* @defaultValue true
*/
set displaySelectedLabel(val) {
this._displaySelectedLabel = val;
}
get displaySelectedLabel() {
return this._displaySelectedLabel;
}
/**
* Decides how many selected item labels to show at most.
* @group Props
* @defaultValue 3
*/
set maxSelectedLabels(val) {
this._maxSelectedLabels = val;
}
get maxSelectedLabels() {
return this._maxSelectedLabels;
}
/**
* Decides how many selected item labels to show at most.
* @group Props
*/
selectionLimit;
/**
* Label to display after exceeding max selected labels e.g. ({0} items selected), defaults "ellipsis" keyword to indicate a text-overflow.
* @group Props
*/
selectedItemsLabel;
/**
* Whether to show the checkbox at header to toggle all items at once.
* @group Props
*/
showToggleAll = true;
/**
* Text to display when filtering does not return any results.
* @group Props
*/
emptyFilterMessage = '';
/**
* Text to display when there is no data. Defaults to global value in i18n translation configuration.
* @group Props
*/
emptyMessage = '';
/**
* Clears the filter value when hiding the dropdown.
* @group Props
*/
resetFilterOnHide = false;
/**
* Icon class of the dropdown icon.
* @group Props
*/
dropdownIcon;
/**
* Icon class of the chip icon.
* @group Props
*/
chipIcon;
/**
* Name of the label field of an option.
* @group Props
*/
optionLabel;
/**
* Name of the value field of an option.
* @group Props
*/
optionValue;
/**
* Name of the disabled field of an option.
* @group Props
*/
optionDisabled;
/**
* Name of the label field of an option group.
* @group Props
*/
optionGroupLabel = 'label';
/**
* Name of the options field of an option group.
* @group Props
*/
optionGroupChildren = 'items';
/**
* Whether to show the header.
* @group Props
*/
showHeader = true;
/**
* When filtering is enabled, filterBy decides which field or fields (comma separated) to search against.
* @group Props
*/
filterBy;
/**
* Height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value.
* @group Props
*/
scrollHeight = '200px';
/**
* Defines if data is loaded and interacted with in lazy manner.
* @group Props
*/
lazy = false;
/**
* Whether the data should be loaded on demand during scroll.
* @group Props
*/
virtualScroll;
/**
* Whether the multiselect is in loading state.
* @group Props
*/
loading = false;
/**
* Height of an item in the list for VirtualScrolling.
* @group Props
*/
virtualScrollItemSize;
/**
* Icon to display in loading state.
* @group Props
*/
loadingIcon;
/**
* Whether to use the scroller feature. The properties of scroller component can be used like an object in it.
* @group Props
*/
virtualScrollOptions;
/**
* Whether to use overlay API feature. The properties of overlay API can be used like an object in it.
* @group Props
*/
overlayOptions;
/**
* Defines a string that labels the filter input.
* @group Props
*/
ariaFilterLabel;
/**
* Defines how the items are filtered.
* @group Props
*/
filterMatchMode = 'contains';
/**
* Advisory information to display in a tooltip on hover.
* @group Props
*/
tooltip = '';
/**
* Position of the tooltip.
* @group Props
*/
tooltipPosition = 'right';
/**
* Type of CSS position.
* @group Props
*/
tooltipPositionStyle = 'absolute';
/**
* Style class of the tooltip.
* @group Props
*/
tooltipStyleClass;
/**
* Applies focus to the filter element when the overlay is shown.
* @group Props
*/
autofocusFilter = false;
/**
* Defines how the selected items are displayed.
* @group Props
*/
display = 'comma';
/**
* Defines the autocomplete is active.
* @group Props
*/
autocomplete = 'off';
/**
* Defines the size of the component.
* @group Props
*/
size;
/**
* When enabled, a clear icon is displayed to clear the value.
* @group Props
*/
showClear = false;
/**
* When present, it specifies that the component should automatically get focus on load.
* @group Props
*/
autofocus;
/**
* @deprecated since v14.2.0, use overlayOptions property instead.
* Whether to automatically manage layering.
* @group Props
*/
get autoZIndex() {
return this._autoZIndex;
}
set autoZIndex(val) {
this._autoZIndex = val;
console.log('The autoZIndex property is deprecated since v14.2.0, use overlayOptions property instead.');
}
/**
* @deprecated since v14.2.0, use overlayOptions property instead.
* Base zIndex value to use in layering.
* @group Props
*/
get baseZIndex() {
return this._baseZIndex;
}
set baseZIndex(val) {
this._baseZIndex = val;
console.log('The baseZIndex property is deprecated since v14.2.0, use overlayOptions property instead.');
}
/**
* Transition options of the show animation.
* @group Props
* @deprecated since v14.2.0, use overlayOptions property instead.
*/
get showTransitionOptions() {
return this._showTransitionOptions;
}
set showTransitionOptions(val) {
this._showTransitionOptions = val;
console.log('The showTransitionOptions property is deprecated since v14.2.0, use overlayOptions property instead.');
}
/**
* Transition options of the hide animation.
* @group Props
* @deprecated since v14.2.0, use overlayOptions property instead.
*/
get hideTransitionOptions() {
return this._hideTransitionOptions;
}
set hideTransitionOptions(val) {
this._hideTransitionOptions = val;
console.log('The hideTransitionOptions property is deprecated since v14.2.0, use overlayOptions property instead.');
}
/**
* Label to display when there are no selections.
* @group Props
* @deprecated Use placeholder instead.
*/
set defaultLabel(val) {
this._defaultLabel = val;
console.log('defaultLabel property is deprecated since 16.6.0, use placeholder instead');
}
get defaultLabel() {
return this._defaultLabel;
}
/**
* Label to display when there are no selections.
* @group Props
*/
set placeholder(val) {
this._placeholder.set(val);
}
get placeholder() {
return this._placeholder.asReadonly();
}
/**
* An array of objects to display as the available options.
* @group Props
*/
get options() {
return this._options();
}
set options(val) {
if (!deepEquals(this._options(), val)) {
this._options.set(val);
}
}
/**
* When specified, filter displays with this value.
* @group Props
*/
get filterValue() {
return this._filterValue();
}
set filterValue(val) {
this._filterValue.set(val);
}
/**
* Item size of item to be virtual scrolled.
* @group Props
* @deprecated use virtualScrollItemSize property instead.
*/
get itemSize() {
return this._itemSize;
}
set itemSize(val) {
this._itemSize = val;
console.log('The itemSize property is deprecated, use virtualScrollItemSize property instead.');
}
/**
* Whether all data is selected.
* @group Props
*/
get selectAll() {
return this._selectAll;
}
set selectAll(value) {
this._selectAll = value;
}
/**
* Indicates whether to focus on options when hovering over them, defaults to optionLabel.
* @group Props
*/
focusOnHover = true;
/**
* Fields used when filtering the options, defaults to optionLabel.
* @group Props
*/
filterFields;
/**
* Determines if the option will be selected on focus.
* @group Props
*/
selectOnFocus = false;
/**
* Whether to focus on the first visible or selected element when the overlay panel is shown.
* @group Props
*/
autoOptionFocus = false;
/**
* Callback to invoke when value changes.
* @param {MultiSelectChangeEvent} event - Custom change event.
* @group Emits
*/
onChange = new EventEmitter();
/**
* Callback to invoke when data is filtered.
* @param {MultiSelectFilterEvent} event - Custom filter event.
* @group Emits
*/
onFilter = new EventEmitter();
/**
* Callback to invoke when multiselect receives focus.
* @param {MultiSelectFocusEvent} event - Custom focus event.
* @group Emits
*/
onFocus = new EventEmitter();
/**
* Callback to invoke when multiselect loses focus.
* @param {MultiSelectBlurEvent} event - Custom blur event.
* @group Emits
*/
onBlur = new EventEmitter();
/**
* Callback to invoke when component is clicked.
* @param {Event} event - Browser event.
* @group Emits
*/
onClick = new EventEmitter();
/**
* Callback to invoke when input field is cleared.
* @group Emits
*/
onClear = new EventEmitter();
/**
* Callback to invoke when overlay panel becomes visible.
* @param {AnimationEvent} event - Animation event.
* @group Emits
*/
onPanelShow = new EventEmitter();
/**
* Callback to invoke when overlay panel becomes hidden.
* @param {AnimationEvent} event - Animation event.
* @group Emits
*/
onPanelHide = new EventEmitter();
/**
* Callback to invoke in lazy mode to load new data.
* @param {MultiSelectLazyLoadEvent} event - Lazy load event.
* @group Emits
*/
onLazyLoad = new EventEmitter();
/**
* Callback to invoke in lazy mode to load new data.
* @param {MultiSelectRemoveEvent} event - Remove event.
* @group Emits
*/
onRemove = new EventEmitter();
/**
* Callback to invoke when all data is selected.
* @param {MultiSelectSelectAllChangeEvent} event - Custom select event.
* @group Emits
*/
onSelectAllChange = new EventEmitter();
overlayViewChild;
filterInputChild;
focusInputViewChild;
itemsViewChild;
scroller;
lastHiddenFocusableElementOnOverlay;
firstHiddenFocusableElementOnOverlay;
headerCheckboxViewChild;
footerFacet;
headerFacet;
_componentStyle = inject(MultiSelectStyle);
searchValue;
searchTimeout;
_selectAll = null;
_autoZIndex;
_baseZIndex;
_showTransitionOptions;
_hideTransitionOptions;
_defaultLabel;
_placeholder = signal(undefined);
_itemSize;
_selectionLimit;
_disableTooltip = false;
value;
_filteredOptions;
onModelChange = () => { };
onModelTouched = () => { };
valuesAsString;
focus;
filtered;
itemTemplate;
groupTemplate;
loaderTemplate;
headerTemplate;
filterTemplate;
footerTemplate;
emptyFilterTemplate;
emptyTemplate;
selectedItemsTemplate;
checkIconTemplate;
loadingIconTemplate;
filterIconTemplate;
removeTokenIconTemplate;
chipIconTemplate;
clearIconTemplate;
dropdownIconTemplate;
itemCheckboxIconTemplate;
headerCheckboxIconTemplate;
templates;
_itemTemplate;
_groupTemplate;
_loaderTemplate;
_headerTemplate;
_filterTemplate;
_footerTemplate;
_emptyFilterTemplate;
_emptyTemplate;
_selectedItemsTemplate;
_checkIconTemplate;
_loadingIconTemplate;
_filterIconTemplate;
_removeTokenIconTemplate;
_chipIconTemplate;
_clearIconTemplate;
_dropdownIconTemplate;
_itemCheckboxIconTemplate;
_headerCheckboxIconTemplate;
ngAfterContentInit() {
this.templates.forEach((item) => {
switch (item.getType()) {
case 'item':
this._itemTemplate = item.template;
break;
case 'group':
this._groupTemplate = item.template;
break;
case 'selectedItems':
case 'selecteditems':
this._selectedItemsTemplate = item.template;
break;
case 'header':
this._headerTemplate = item.template;
break;
case 'filter':
this._filterTemplate = item.template;
break;
case 'emptyfilter':
this._emptyFilterTemplate = item.template;
break;
case 'empty':
this._emptyTemplate = item.template;
break;
case 'footer':
this._footerTemplate = item.template;
break;
case 'loader':
this._loaderTemplate = item.template;
break;
case 'checkicon':
this._checkIconTemplate = item.template;
console.warn('checkicon is deprecated and will removed in future. Use itemcheckboxicon or headercheckboxicon templates instead.');
break;
case 'headercheckboxicon':
this._headerCheckboxIconTemplate = item.template;
break;
case 'loadingicon':
this._loadingIconTemplate = item.template;
break;
case 'filtericon':
this._filterIconTemplate = item.template;
break;
case 'removetokenicon':
this._removeTokenIconTemplate = item.template;
break;
case 'clearicon':
this._clearIconTemplate = item.template;
break;
case 'dropdownicon':
this._dropdownIconTemplate = item.template;
break;
case 'itemcheckboxicon':
this._itemCheckboxIconTemplate = item.template;
break;
case 'chipicon':
this._chipIconTemplate = item.template;
break;
default:
this._itemTemplate = item.template;
break;
}
});
}
headerCheckboxFocus;
filterOptions;
preventModelTouched;
preventDocumentDefault;
focused = false;
itemsWrapper;
_displaySelectedLabel = true;
_maxSelectedLabels = 3;
modelValue = signal(null);
_filterValue = signal(null);
_options = signal(null);
startRangeIndex = signal(-1);
focusedOptionIndex = signal(-1);
selectedOptions;
clickInProgress = false;
get hostClasses() {
const classes = [];
if (typeof this.rootClass === 'string') {
classes.push(this.rootClass);
}
else if (Array.isArray(this.rootClass)) {
classes.push(...this.rootClass);
}
else if (typeof this.rootClass === 'object') {
Object.keys(this.rootClass)
.filter((key) => this.rootClass[key])
.forEach((key) => classes.push(key));
}
if (this.styleClass) {
classes.push(this.styleClass);
}
return classes.join(' ');
}
get rootClass() {
return this._componentStyle.classes.root({ instance: this });
}
get labelClass() {
return this._componentStyle.classes.label({ instance: this });
}
get emptyMessageLabel() {
return this.emptyMessage || this.config.getTranslation(TranslationKeys.EMPTY_MESSAGE);
}
get emptyFilterMessageLabel() {
return this.emptyFilterMessage || this.config.getTranslation(TranslationKeys.EMPTY_FILTER_MESSAGE);
}
get filled() {
if (typeof this.modelValue() === 'string')
return !!this.modelValue();
return isNotEmpty(this.modelValue());
}
get isVisibleClearIcon() {
return this.modelValue() != null && this.modelValue() !== '' && isNotEmpty(this.modelValue()) && this.showClear && !this.disabled && !this.readonly && this.filled;
}
get toggleAllAriaLabel() {
return this.config.translation.aria ? this.config.translation.aria[this.allSelected() ? 'selectAll' : 'unselectAll'] : undefined;
}
get closeAriaLabel() {
return this.config.translation.aria ? this.config.translation.aria.close : undefined;
}
get listLabel() {
return this.config.getTranslation(TranslationKeys.ARIA)['listLabel'];
}
get hasFluid() {
const nativeElement = this.el.nativeElement;
const fluidComponent = nativeElement.closest('p-fluid');
return this.fluid || !!fluidComponent;
}
getAllVisibleAndNonVisibleOptions() {
return this.group ? this.flatOptions(this.options) : this.options || [];
}
visibleOptions = computed(() => {
const options = this.getAllVisibleAndNonVisibleOptions();
const isArrayOfObjects = isArray(options) && ObjectUtils.isObject(options[0]);
if (this._filterValue()) {
let filteredOptions;
if (isArrayOfObjects) {
filteredOptions = this.filterService.filter(options, this.searchFields(), this._filterValue(), this.filterMatchMode, this.filterLocale);
}
else {
filteredOptions = options.filter((option) => option.toString().toLocaleLowerCase().includes(this._filterValue().toLocaleLowerCase()));
}
if (this.group) {
const optionGroups = this.options || [];
const filtered = [];
optionGroups.forEach((group) => {
const groupChildren = this.getOptionGroupChildren(group);
const filteredItems = groupChildren.filter((item) => filteredOptions.includes(item));
if (filteredItems.length > 0)
filtered.push({
...group,
[typeof this.optionGroupChildren === 'string' ? this.optionGroupChildren : 'items']: [...filteredItems]
});
});
return this.flatOptions(filtered);
}
return filteredOptions;
}
return options;
});
label = computed(() => {
let label;
const modelValue = this.modelValue();
if (modelValue && modelValue.length && this.displaySelectedLabel) {
if (isNotEmpty(this.maxSelectedLabels) && modelValue.length > this.maxSelectedLabels) {
return this.getSelectedItemsLabel();
}
else {
label = '';
for (let i = 0; i < modelValue.length; i++) {
if (i !== 0) {
label += ', ';
}
label += this.getLabelByValue(modelValue[i]);
}
}
}
else {
label = this.placeholder() || this.defaultLabel || '';
}
return label;
});
chipSelectedItems = computed(() => {
return isNotEmpty(this.maxSelectedLabels) && this.modelValue() && this.modelValue().length > this.maxSelectedLabels ? this.modelValue().slice(0, this.maxSelectedLabels) : this.modelValue();
});
constructor(zone, filterService, overlayService) {
super();
this.zone = zone;
this.filterService = filterService;
this.overlayService = overlayService;
effect(() => {
const modelValue = this.modelValue();
const allVisibleAndNonVisibleOptions = this.getAllVisibleAndNonVisibleOptions();
if (allVisibleAndNonVisibleOptions && isNotEmpty(allVisibleAndNonVisibleOptions)) {
if (this.optionValue && this.optionLabel && modelValue) {
this.selectedOptions = allVisibleAndNonVisibleOptions.filter((option) => modelValue.includes(option[this.optionLabel]) || modelValue.includes(option[this.optionValue]));
}
else {
this.selectedOptions = modelValue;
}
this.cd.markForCheck();
}
});
}
ngOnInit() {
super.ngOnInit();
this.id = this.id || uuid('pn_id_');
this.autoUpdateModel();
if (this.filterBy) {
this.filterOptions = {
filter: (value) => this.onFilterInputChange(value),
reset: () => this.resetFilter()
};
}
}
maxSelectionLimitReached() {
return this.selectionLimit && this.modelValue() && this.modelValue().length === this.selectionLimit;
}
ngAfterViewInit() {
super.ngAfterViewInit();
if (this.overlayVisible) {
this.show();
}
}
ngAfterViewChecked() {
if (this.filtered) {
this.zone.runOutsideAngular(() => {
setTimeout(() => {
this.overlayViewChild?.alignOverlay();
}, 1);
});
this.filtered = false;
}
}
flatOptions(options) {
return (options || []).reduce((result, option, index) => {
result.push({ optionGroup: option, group: true, index });
const optionGroupChildren = this.getOptionGroupChildren(option);
optionGroupChildren && optionGroupChildren.forEach((o) => result.push(o));
return result;
}, []);
}
autoUpdateModel() {
if (this.selectOnFocus && this.autoOptionFocus && !this.hasSelectedOption()) {
this.focusedOptionIndex.set(this.findFirstFocusedOptionIndex());
const value = this.getOptionValue(this.visibleOptions()[this.focusedOptionIndex()]);
this.onOptionSelect({ originalEvent: null, option: [value] });
}
}
/**
* Updates the model value.
* @group Method
*/
updateModel(value, event) {
this.value = value;
this.onModelChange(value);
this.modelValue.set(value);
}
onInputClick(event) {
event.stopPropagation();
event.preventDefault();
this.focusedOptionIndex.set(-1);
}
onOptionSelect(event, isFocus = false, index = -1) {
const { originalEvent, option } = event;
if (this.disabled || this.isOptionDisabled(option)) {
return;
}
let selected = this.isSelected(option);
let value = null;
if (selected) {
value = this.modelValue().filter((val) => !equals(val, this.getOptionValue(option), this.equalityKey()));
}
else {
value = [...(this.modelValue() || []), this.getOptionValue(option)];
}
this.updateModel(value, originalEvent);
index !== -1 && this.focusedOptionIndex.set(index);
isFocus && focus(this.focusInputViewChild?.nativeElement);
this.onChange.emit({
originalEvent: event,
value: value,
itemValue: option
});
}
findSelectedOptionIndex() {
return this.hasSelectedOption() ? this.visibleOptions().findIndex((option) => this.isValidSelectedOption(option)) : -1;
}
onOptionSelectRange(event, start = -1, end = -1) {
start === -1 && (start = this.findNearestSelectedOptionIndex(end, true));
end === -1 && (end = this.findNearestSelectedOptionIndex(start));
if (start !== -1 && end !== -1) {
const rangeStart = Math.min(start, end);
const rangeEnd = Math.max(start, end);
const value = this.visibleOptions()
.slice(rangeStart, rangeEnd + 1)
.filter((option) => this.isValidOption(option))
.map((option) => this.getOptionValue(option));
this.updateModel(value, event);
}
}
searchFields() {
return (this.filterBy || this.optionLabel || 'label').split(',');
}
findNearestSelectedOptionIndex(index, firstCheckUp = false) {
let matchedOptionIndex = -1;
if (this.hasSelectedOption()) {
if (firstCheckUp) {
matchedOptionIndex = this.findPrevSelectedOptionIndex(index);
matchedOptionIndex = matchedOptionIndex === -1 ? this.findNextSelectedOptionIndex(index) : matchedOptionIndex;
}
else {
matchedOptionIndex = this.findNextSelectedOptionIndex(index);
matchedOptionIndex = matchedOptionIndex === -1 ? this.findPrevSelectedOptionIndex(index) : matchedOptionIndex;
}
}
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
}
findPrevSelectedOptionIndex(index) {
const matchedOptionIndex = this.hasSelectedOption() && index > 0 ? findLastIndex(this.visibleOptions().slice(0, index), (option) => this.isValidSelectedOption(option)) : -1;
return matchedOptionIndex > -1 ? matchedOptionIndex : -1;
}
findFirstFocusedOptionIndex() {
const selectedIndex = this.findFirstSelectedOptionIndex();
return selectedIndex < 0 ? this.findFirstOptionIndex() : selectedIndex;
}
findFirstOptionIndex() {
return this.visibleOptions().findIndex((option) => this.isValidOption(option));
}
findFirstSelectedOptionIndex() {
return this.hasSelectedOption() ? this.visibleOptions().findIndex((option) => this.isValidSelectedOption(option)) : -1;
}
findNextSelectedOptionIndex(index) {
const matchedOptionIndex = this.hasSelectedOption() && index < this.visibleOptions().length - 1
? this.visibleOptions()
.slice(index + 1)
.findIndex((option) => this.isValidSelectedOption(option))
: -1;
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : -1;
}
equalityKey() {
return this.optionValue ? null : this.dataKey;
}
hasSelectedOption() {
return isNotEmpty(this.modelValue());
}
isValidSelectedOption(option) {
return this.isValidOption(option) && this.isSelected(option);
}
isOptionGroup(option) {
return (this.group || this.optionGroupLabel) && option.optionGroup && option.group;
}
isValidOption(option) {
return option && !(this.isOptionDisabled(option) || this.isOptionGroup(option));
}
isOptionDisabled(option) {
if (this.maxSelectionLimitReached() && !this.isSelected(option)) {
return true;
}
return this.optionDisabled ? resolveFieldData(option, this.optionDisabled) : option && option.disabled !== undefined ? option.disabled : false;
}
isSelected(option) {
const optionValue = this.getOptionValue(option);
return (this.modelValue() || []).some((value) => equals(value, optionValue, this.equalityKey()));
}
isOptionMatched(option) {
return this.isValidOption(option) && this.getOptionLabel(option).toString().toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale));
}
isEmpty() {
return !this._options() || (this.visibleOptions() && this.visibleOptions().length === 0);
}
getOptionIndex(index, scrollerOptions) {
return this.virtualScrollerDisabled ? index : scrollerOptions && scrollerOptions.getItemOptions(index)['index'];
}
getAriaPosInset(index) {
return ((this.optionGroupLabel
? index -
this.visibleOptions()
.slice(0, index)
.filter((option) => this.isOptionGroup(option)).length
: index) + 1);
}
get ariaSetSize() {
return this.visibleOptions().filter((option) => !this.isOptionGroup(option)).length;
}
getLabelByValue(value) {
const options = this.group ? this.flatOptions(this._options()) : this._options() || [];
const matchedOption = options.find((option) => !this.isOptionGroup(option) && equals(this.getOptionValue(option), value, this.equalityKey()));
return matchedOption ? this.getOptionLabel(matchedOption) : null;
}
getSelectedItemsLabel() {
let pattern = /{(.*?)}/;
let message = this.selectedItemsLabel ? this.selectedItemsLabel : this.config.getTranslation(TranslationKeys.SELECTION_MESSAGE);
if (pattern.test(message)) {
return message.replace(message.match(pattern)[0], this.modelValue().length + '');
}
return message;
}
getOptionLabel(option) {
return this.optionLabel ? resolveFieldData(option, this.optionLabel) : option && option.label != undefined ? option.label : option;
}
getOptionValue(option) {
return this.optionValue ? resolveFieldData(option, this.optionValue) : !this.optionLabel && option && option.value !== undefined ? option.value : option;
}
getOptionGroupLabel(optionGroup) {
return this.optionGroupLabel ? resolveFieldData(optionGroup, this.optionGroupLabel) : optionGroup && optionGroup.label != undefined ? optionGroup.label : optionGroup;
}
getOptionGroupChildren(optionGroup) {
return this.optionGroupChildren ? resolveFieldData(optionGroup, this.optionGroupChildren) : optionGroup.items;
}
onKeyDown(event) {
if (this.disabled) {
event.preventDefault();
return;
}
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
break;
case 'ArrowUp':
this.onArrowUpKey(event);
break;
case 'Home':
this.onHomeKey(event);
break;
case 'End':
this.onEndKey(event);
break;
case 'PageDown':
this.onPageDownKey(event);
break;
case 'PageUp':
this.onPageUpKey(event);
break;
case 'Enter':
case 'Space':
this.onEnterKey(event);
break;
case 'Escape':
this.onEscapeKey(event);
break;
case 'Tab':
this.onTabKey(event);
break;
case 'ShiftLeft':
case 'ShiftRight':
this.onShiftKey();
break;
default:
if (event.code === 'KeyA' && metaKey) {
const value = this.visibleOptions()
.filter((option) => this.isValidOption(option))
.map((option) => this.getOptionValue(option));
this.updateModel(value, event);
event.preventDefault();
break;
}
if (!metaKey && isPrintableCharacter(event.key)) {
!this.overlayVisible && this.show();
this.searchOptions(event, event.key);
event.preventDefault();
}
break;
}
}
onFilterKeyDown(event) {
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
break;
case 'ArrowUp':
this.onArrowUpKey(event, true);
break;
case 'ArrowLeft':
case 'ArrowRight':
this.onArrowLeftKey(event, true);
break;
case 'Home':
this.onHomeKey(event, true);
break;
case 'End':
this.onEndKey(event, true);
break;
case 'Enter':
case 'NumpadEnter':
this.onEnterKey(event);
break;
case 'Escape':
this.onEscapeKey(event);
break;
case 'Tab':
this.onTabKey(event, true);
break;
default:
break;
}
}
onArrowLeftKey(event, pressedInInputText = false) {
pressedInInputText && this.focusedOptionIndex.set(-1);
}
onArrowDownKey(event) {
const optionIndex = this.focusedOptionIndex() !== -1 ? this.findNextOptionIndex(this.focusedOptionIndex()) : this.findFirstFocusedOptionIndex();
if (event.shiftKey) {
this.onOptionSelectRange(event, this.startRangeIndex(), optionIndex);
}
this.changeFocusedOptionIndex(event, optionIndex);
!this.overlayVisible && this.show();
event.preventDefault();
event.stopPropagation();
}
onArrowUpKey(event, pressedInInputText = false) {
if (event.altKey && !pressedInInputText) {
if (this.focusedOptionIndex() !== -1) {
this.onOptionSelect(event, this.visibleOptions()[this.focusedOptionIndex()]);
}
this.overlayVisible && this.hide();
event.preventDefault();
}
else {
const optionIndex = this.focusedOptionIndex() !== -1 ? this.findPrevOptionIndex(this.focusedOptionIndex()) : this.findLastFocusedOptionIndex();
if (event.shiftKey) {
this.onOptionSelectRange(event, optionIndex, this.startRangeIndex());
}
this.changeFocusedOptionIndex(event, optionIndex);
!this.overlayVisible && this.show();
event.preventDefault();
}
event.stopPropagation();
}
onHomeKey(event, pressedInInputText = false) {
const { currentTarget } = event;
if (pressedInInputText) {
const len = currentTarget.value.length;
currentTarget.setSelectionRange(0, event.shiftKey ? len : 0);
this.focusedOptionIndex.set(-1);
}
else {
let metaKey = event.metaKey || event.ctrlKey;
let optionIndex = this.findFirstOptionIndex();
if (event.shiftKey && metaKey) {
this.onOptionSelectRange(event, optionIndex, this.startRangeIndex());
}
this.changeFocusedOptionIndex(event, optionIndex);
!this.overlayVisible && this.show();
}
event.preventDefault();
}
onEndKey(event, pressedInInputText = false) {
const { currentTarget } = event;
if (pressedInInputText) {
const len = currentTarget.value.length;
currentTarget.setSelectionRange(event.shiftKey ? 0 : len, len);
this.focusedOptionIndex.set(-1);
}
else {
let metaKey = event.metaKey || event.ctrlKey;
let optionIndex = this.findLastFocusedOptionIndex();
if (event.shiftKey && metaKey) {
this.onOptionSelectRange(event, this.startRangeIndex(), optionIndex);
}
this.changeFocusedOptionIndex(event, optionIndex);
!this.overlayVisible && this.show();
}
event.preventDefault();
}
onPageDownKey(event) {
this.scrollInView(this.visibleOptions().length - 1);
event.preventDefault();
}
onPageUpKey(event) {
this.scrollInView(0);
event.preventDefault();
}
onEnterKey(event) {
if (!this.overlayVisible) {
this.onArrowDownKey(event);
}
else {
if (this.focusedOptionIndex() !== -1) {
if (event.shiftKey) {
this.onOptionSelectRange(event, this.focusedOptionIndex());
}
else {
this.onOptionSelect({ originalEvent: event, option: this.visibleOptions()[this.focusedOptionIndex()] });
}
}
}
event.preventDefault();
}
onEscapeKey(event) {
this.overlayVisible && this.hide(true);
event.stopPropagation();
event.preventDefault();
}
onDeleteKey(event) {
if (this.showClear) {
this.clear(event);
event.preventDefault();
}
}
onTabKey(event, pressedInInputText = false) {
if (!pressedInInputText) {
if (this.overlayVisible && this.hasFocusableElements()) {
focus(event.shiftKey ? this.lastHiddenFocusableElementOnOverlay.nativeElement : this.firstHiddenFocusableElementOnOverlay.nativeElement);
event.preventDefault();
}
else {
if (this.focusedOptionIndex() !== -1) {
this.onOptionSelect({ originalEvent: event, option: this.visibleOptions()[this.focusedOptionIndex()] });
}
this.overlayVisible && this.hide(this.filter);
}
}
}
onShiftKey() {
this.startRangeIndex.set(this.focusedOptionIndex());
}
onContainerClick(event) {
if (this.disabled || this.loading || this.readonly || event.target.isSameNode(this.focusInputViewChild?.nativeElement)) {
return;
}
if (!this.overlayViewChild || !this.overlayViewChild.el.nativeElement.contains(event.target)) {
if (this.clickInProgress) {
return;
}
this.clickInProgress = true;
setTimeout(() => {
this.clickInProgress = false;
}, 150);
this.overlayVisible ? this.hide(true) : this.show(true);
}
this.focusInputViewChild?.nativeElement.focus({ preventScroll: true });
this.onClick.emit(event);
this.cd.detectChanges();
}
onFirstHiddenFocus(event) {
const focusableEl = event.relatedTarget === this.focusInputViewChild?.nativeElement ? getFirstFocusableElement(this.overlayViewChild?.overlayViewChild?.nativeElement, ':not([data-p-hidden-focusable="true"])') : this.focusInputViewChild?.nativeElement;
focus(focusableEl);
}
onInputFocus(event) {
this.focused = true;
const focusedOptionIndex = this.focusedOptionIndex() !== -1 ? this.focusedOptionIndex() : this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
this.focusedOptionIndex.set(focusedOptionIndex);
this.overlayVisible && this.scrollInView(this.focusedOptionIndex());
this.onFocus.emit({ originalEvent: event });
}
onInputBlur(event) {
this.focused = false;
this.onBlur.emit({ originalEvent: event });
if (!this.preventModelTouched) {
this.onModelTouched();
}
this.preventModelTouched = false;
}
onFilterInputChange(event) {
let value = event.target.value;
this._filterValue.set(value);
this.focusedOptionIndex.set(-1);
this.onFilter.emit({ originalEvent: event, filter: this._filterValue() });
!this.virtualScrollerDisabled && this.scroller.scrollToIndex(0);
setTimeout(() => {
this.overlayViewChild.alignOverlay();
});
}
onLastHiddenFocus(event) {
const focusableEl = event.relatedTarget === this.focusInputViewChild?.nativeElement ? getLastFocusableElement(this.overlayViewChild?.overlayViewChild?.nativeElement, ':not([data-p-hidden-focusable="true"])') : this.focusInputViewChild?.nativeElement;
focus(focusableEl);
}
onOptionMouseEnter(event, index) {
if (this.focusOnHover) {
this.changeFocusedOptionIndex(event, index);
}
}
onHeaderCheckboxKeyDown(event) {
if (this.disabled) {
event.preventDefault();
return;
}
switch (event.code) {
case 'Space':
this.onToggleAll(event);
break;
case 'Enter':
this.onToggleAll(event);
break;
default:
break;
}
}
onFilterBlur(event) {
this.focusedOptionIndex.set(-1);
}
onHeaderCheckboxFocus() {
this.headerCheckboxFocus = true;
}
onHeaderCheckboxBlur() {
this.headerCheckboxFocus = false;
}
onToggleAll(event) {
if (this.disabled || this.readonly) {
return;
}
if (this.selectAll != null) {
this.onSelectAllChange.emit({
originalEvent: event,
checked: !this.allSelected()
});
}
else {
// pre-selected disabled options should always be selected.
const selectedDisabledOptions = this.getAllVisibleAndNonVisibleOptions().filter((option) => this.isSelected(option) && (this.optionDisabled ? resolveFieldData(option, this.optionDisabled) : option && option.disabled !== undefined ? option.disabled : false));
const visibleOptions = this.allSelected()
? this.visibleOptions().filter((option) => !this.isValidOption(option) && this.isSelected(option))
: this.visibleOptions().filter((option) => this.isSelected(option) || this.isValidOption(option));
const optionValues = [...selectedDisabledOptions, ...visibleOptions].map((option) => this.getOptionValue(option));
const value = [...new Set(optionValues)];
this.updateModel(value, event);
// because onToggleAll could have been called during filtering, this additional test needs to be performed before calling onSelectAllChange.emit
if (!value.length || value.length === this.getAllVisibleAndNonVisibleOptions().length) {
this.onSelectAllChange.emit({
originalEvent: event,
checked: !!value.length
});
}
}
if (this.partialSelected()) {
this.selectedOptions = null;
this.cd.markForCheck();
}
this.onChange.emit({ originalEvent: event, value: this.value });
DomHandler.focus(this.headerCheckboxViewChild?.inputViewChild?.nativeElement);
this.headerCheckboxFocus = true;
event.originalEvent.preventDefault();
event.originalEvent.stopPropagation();
}
changeFocusedOptionIndex(event, index) {
if (this.focusedOptionIndex() !== index) {
this.focusedOptionIndex.set(index);
this.scrollInView();
}
}
get virtualScrollerDisabled() {
return !this.virtualScroll;
}
scrollInView(index = -1) {
const id = index !== -1 ? `${this.id}_${index}` : this.focusedOptionId;
if (this.itemsViewChild && this.itemsViewChild.nativeElement) {
const element = findSingle(this.itemsViewChild.nativeElement, `li[id="${id}"]`);
if (element) {
element.scrollIntoView && element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
else if (!this.virtualScrollerDisabled) {
setTimeout(() => {
this.virtualScroll && this.scroller?.scrollToIndex(index !== -1 ? index : this.focusedOptionIndex());
}, 0);
}
}
}
get focusedOptionId() {
return this.focusedOptionIndex() !== -1 ? `${this.id}_${this.focusedOptionIndex()}` : null;
}
writeValue(value) {
this.value = value;
this.modelValue.set(this.value);
this.cd.markForCheck();
}
registerOnChange(fn) {
this.onModelChange = fn;
}
registerOnTouched(fn) {
this.onModelTouched = fn;
}
setDisabledState(val) {
this.disabled = val;
this.cd.markForCheck();
}
allSelected() {
return this.selectAll !== null ? this.selectAll : isNotEmpty(this.visibleOptions()) && this.visibleOptions().every((option) => this.isOptionGroup(option) || this.isOptionDisabled(option) || this.isSelected(option));
}
partialSelected() {
return this.selectedOptions && this.selectedOptions.length > 0 && this.selectedOptions.length < this.options.length;
}
/**
* Displays the panel.
* @group Method
*/
show(isFocus) {
this.overlayVisible = true;
const focusedOptionIndex = this.focusedOptionIndex() !== -1 ? this.focusedOptionIndex() : this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : this.findSelectedOptionIndex();
this.focusedOptionIndex.set(focusedOptionIndex);
if (isFocus) {
focus(this.focusInputViewChild?.nativeElement);
}
this.cd.markForCheck();
}
/**
* Hides the panel.
* @group Method
*/
hide(isFocus) {
this.overlayVisible = false;
this.focusedOptionIndex.set(-1);
if (this.filter && this.resetFilterOnHide) {
this.resetFilter();
}
if (this.overlayOptions?.mode === 'modal') {
unblockBodyScroll();
}
isFocus && focus(this.focusInputViewChild?.nativeElement);
this.cd.markForCheck();
}
onOverlayAnimationStart(event) {
if (event.toState === 'visible') {
this.itemsWrapper = findSingle(this.overlayViewChild?.overlayViewChild?.nativeElement, this.virtualScroll ? '.p-scroller' : '.p-multiselect-list-container');
this.virtualScroll && this.scroller?.setContentEl(this.itemsViewChild?.nativeElement);
if (this.options && this.options.length) {
if (this.virtualScroll) {
const selectedIndex = this.modelValue() ? this.focusedOptionIndex() : -1;
if (selectedIndex !== -1) {
this.scroller?.scrollToIndex(selectedIndex);
}
}
else {
let selectedListItem = findSingle(this.itemsWrapper, '[data-p-highlight="true"]');
if (selectedListItem) {
selectedListItem.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
}
}
if (this.filterInputChild && this.filterInputChild.nativeElement) {
this.preventModelTouched = true;
if (this.autofocusFilter) {
this.filterInputChild.nativeElement.focus();
}
}
this.onPanelShow.emit(event);
}
if (event.toState === 'void') {
this.itemsWrapper = null;
this.onModelTouched();
this.onPanelHide.emit(event);
}
}
resetFilter() {
if (this.filterInputChild && this.filterInputChild.nativeElement) {
this.filterInputChild.nativeElement.value = '';
}
this._filterValue.set(null);
this._filteredOptions = null;
}
close(event) {
this.hide();
event.preventDefault();
event.stopPropagation();
}
clear(event) {
this.value = null;
this.updateModel(null, event);
this.selectedOptions = null;
this.onClear.emit();
this._disableTooltip = true;
event.stopPropagation();
}
labelContainerMouseLeave() {
if (this._disableTooltip)
this._disableTooltip = false;
}
removeOption(optionValue, event) {
let value = this.modelValue().filter((val) => !equals(val, optionValue, this.equalityKey()));
this.updateModel(value, event);
this.onChange.emit({
originalEvent: event,
value: value,
itemValue: optionValue
});
this.onRemove.emit({
newValue: value,
removed: optionValue
});
event && event.stopPropagation();
}
findNextItem(item) {
let nextItem = item.nextElementSibling;
if (nextItem)
return hasClass(nextItem.children[0], 'p-disabled') || isHidden(nextItem.children[0]) || hasClass(nextItem, 'p-multiselect-item-group') ? this.findNextItem(nextItem) : nextItem.children[0];
else
return null;
}
findPrevItem(item) {
let prevItem = item.previousElementSibling;
if (prevItem)
return hasClass(prevItem.children[0], 'p-disabled') || isHidden(prevItem.children[0]) || hasClass(prevItem, 'p-multiselect-item-group') ? this.findPrevItem(prevItem) : prevItem.children[0];
else
return null;
}
findNextOptionIndex(index) {
const matchedOptionIndex = index < this.visibleOptions().length - 1
? this.visibleOptions()
.slice(index + 1)
.findIndex((option) => this.isValidOption(option))
: -1;
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
}
findPrevOptionIndex(index) {
const matchedOptionIndex = index > 0 ? findLastIndex(this.visibleOptions().slice(0, index), (option) => this.isValidOption(option)) : -1;
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
}
findLastSelectedOptionIndex() {
return this.hasSelectedOption() ? findLastIndex(this.visibleOptions(), (option) => this.isValidSelectedOption(option)) : -1;
}
findLastFocusedOptionIndex() {
const selectedIndex = this.findLastSelectedOptionIndex();
return selectedIndex < 0 ? this.findLastOptionIndex() : selectedIndex;
}
findLastOptionIndex() {
return findLastIndex(this.visibleOptions(), (option) => this.isValidOption(option));
}
searchOptions(event, char) {
this.searchValue = (this.searchValue || '') + char;
let optionIndex = -1;
let matched = false;
if (this.focusedOptionIndex() !== -1) {
optionIndex = this.visibleOptions()
.slice(this.focusedOptionIndex())
.findIndex((option) => this.isOptionMatched(option));
optionIndex =
optionIndex === -1
? this.visibleOptions()
.slice(0, this.focusedOptionIndex())
.findIndex((option) => this.isOptionMatched(option))
: optionIndex + this.focusedOptionIndex();
}
else {
optionIndex = this.visibleOptions().findIndex((option) => this.isOptionMatched(option));
}
if (optionIndex !== -1) {
matched = true;
}
if (optionIndex === -1 && this.focusedOptionIndex() === -1) {
optionIndex = this.findFirstFocusedOptionIndex();
}
if (optionIndex !== -1) {
this.changeFocusedOptionIndex(event, optionIndex);
}
if (this.searchTimeout) {
clearTimeout(this.searchTimeout);
}
this.searchTimeout = setTimeout(() => {
this.searchValue = '';
this.searchTimeout = null;
}, 500);
return matched;
}
activateFilter() {
if (this.hasFilter() && this._options) {
if (this.group) {
let filteredGroups = [];
for (let optgroup of this.options) {
let filteredSubOptions = this.filterService.filter(this.getOptionGroupChildren(optgroup), this.searchFields(), this.filterValue, this.filterMatchMode, this.filterLocale);
if (filteredSubOptions && filteredSubOptions.length) {
filteredGroups.push({ ...optgroup, ...{ [this.optionGroupChildren]: filteredSubOptions } });
}
}
this._filteredOptions = filteredGroups;
}
else {
this._filteredOptions = this.filterService.filter(this.options, this.searchFields(), this.filterValue, this.filterMatchMode, this.filterLocale);
}
}
else {
this._filteredOptions = null;
}
}
hasFocusableElements() {
return getFocusableElements(this.overlayViewChild.overlayViewChild.nativeElement, ':not([data-p-hidden-focusable="true"])').length > 0;
}
hasFilter() {
return this._filterValue() && this._filterValue().trim().length > 0;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelect, deps: [{ token: i0.NgZone }, { token: i3.FilterService }, { token: i3.OverlayService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: MultiSelect, isStandalone: true, selector: "p-multiSelect, p-multiselect, p-multi-select", inputs: { id: "id", ariaLabel: "ariaLabel", style: "style", styleClass: "styleClass", panelStyle: "panelStyle", panelStyleClass: "panelStyleClass", inputId: "inputId", disabled: ["disabled", "disabled", booleanAttribute], fluid: ["fluid", "fluid", booleanAttribute], readonly: ["readonly", "readonly", booleanAttribute], group: ["group", "group", booleanAttribute], filter: ["filter", "filter", booleanAttribute], filterPlaceHolder: "filterPlaceHolder", filterLocale: "filterLocale", overlayVisible: ["overlayVisible", "overlayVisible", booleanAttribute], tabindex: ["tabindex", "tabindex", numberAttribute], variant: "variant", appendTo: "appendTo", dataKey: "dataKey", name: "name", ariaLabelledBy: "ariaLabelledBy", displaySelectedLabel: "displaySelectedLabel", maxSelectedLabels: "maxSelectedLabels", selectionLimit: ["selectionLimit", "selectionLimit", numberAttribute], selectedItemsLabel: "selectedItemsLabel", showToggleAll: ["showToggleAll", "showToggleAll", booleanAttribute], emptyFilterMessage: "emptyFilterMessage", emptyMessage: "emptyMessage", resetFilterOnHide: ["resetFilterOnHide", "resetFilterOnHide", booleanAttribute], dropdownIcon: "dropdownIcon", chipIcon: "chipIcon", optionLabel: "optionLabel", optionValue: "optionValue", optionDisabled: "optionDisabled", optionGroupLabel: "optionGroupLabel", optionGroupChildren: "optionGroupChildren", showHeader: ["showHeader", "showHeader", booleanAttribute], filterBy: "filterBy", scrollHeight: "scrollHeight", lazy: ["lazy", "lazy", booleanAttribute], virtualScroll: ["virtualScroll", "virtualScroll", booleanAttribute], loading: ["loading", "loading", booleanAttribute], virtualScrollItemSize: ["virtualScrollItemSize", "virtualScrollItemSize", numberAttribute], loadingIcon: "loadingIcon", virtualScrollOptions: "virtualScrollOptions", overlayOptions: "overlayOptions", ariaFilterLabel: "ariaFilterLabel", filterMatchMode: "filterMatchMode", tooltip: "tooltip", tooltipPosition: "tooltipPosition", tooltipPositionStyle: "tooltipPositionStyle", tooltipStyleClass: "tooltipStyleClass", autofocusFilter: ["autofocusFilter", "autofocusFilter", booleanAttribute], display: "display", autocomplete: "autocomplete", size: "size", showClear: ["showClear", "showClear", booleanAttribute], autofocus: ["autofocus", "autofocus", booleanAttribute], autoZIndex: "autoZIndex", baseZIndex: "baseZIndex", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions", defaultLabel: "defaultLabel", placeholder: "placeholder", options: "options", filterValue: "filterValue", itemSize: "itemSize", selectAll: "selectAll", focusOnHover: ["focusOnHover", "focusOnHover", booleanAttribute], filterFields: "filterFields", selectOnFocus: ["selectOnFocus", "selectOnFocus", booleanAttribute], autoOptionFocus: ["autoOptionFocus", "autoOptionFocus", booleanAttribute] }, outputs: { onChange: "onChange", onFilter: "onFilter", onFocus: "onFocus", onBlur: "onBlur", onClick: "onClick", onClear: "onClear", onPanelShow: "onPanelShow", onPanelHide: "onPanelHide", onLazyLoad: "onLazyLoad", onRemove: "onRemove", onSelectAllChange: "onSelectAllChange" }, host: { listeners: { "click": "onContainerClick($event)" }, properties: { "attr.id": "id", "style": "style", "class.p-variant-filled": "variant === \"filled\" || config.inputVariant() === \"filled\" || config.inputStyle() === \"filled\" ", "class": "this.hostClasses" } }, providers: [MULTISELECT_VALUE_ACCESSOR, MultiSelectStyle], queries: [{ propertyName: "footerFacet", first: true, predicate: Footer, descendants: true }, { propertyName: "headerFacet", first: true, predicate: Header, descendants: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"] }, { propertyName: "groupTemplate", first: true, predicate: ["group"] }, { propertyName: "loaderTemplate", first: true, predicate: ["loader"] }, { propertyName: "headerTemplate", first: true, predicate: ["header"] }, { propertyName: "filterTemplate", first: true, predicate: ["filter"] }, { propertyName: "footerTemplate", first: true, predicate: ["footer"] }, { propertyName: "emptyFilterTemplate", first: true, predicate: ["emptyfilter"] }, { propertyName: "emptyTemplate", first: true, predicate: ["empty"] }, { propertyName: "selectedItemsTemplate", first: true, predicate: ["selecteditems"] }, { propertyName: "checkIconTemplate", first: true, predicate: ["checkicon"] }, { propertyName: "loadingIconTemplate", first: true, predicate: ["loadingicon"] }, { propertyName: "filterIconTemplate", first: true, predicate: ["filtericon"] }, { propertyName: "removeTokenIconTemplate", first: true, predicate: ["removetokenicon"] }, { propertyName: "chipIconTemplate", first: true, predicate: ["chipicon"] }, { propertyName: "clearIconTemplate", first: true, predicate: ["clearicon"] }, { propertyName: "dropdownIconTemplate", first: true, predicate: ["dropdownicon"] }, { propertyName: "itemCheckboxIconTemplate", first: true, predicate: ["itemcheckboxicon"] }, { propertyName: "headerCheckboxIconTemplate", first: true, predicate: ["headercheckboxicon"] }, { propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "overlayViewChild", first: true, predicate: ["overlay"], descendants: true }, { propertyName: "filterInputChild", first: true, predicate: ["filterInput"], descendants: true }, { propertyName: "focusInputViewChild", first: true, predicate: ["focusInput"], descendants: true }, { propertyName: "itemsViewChild", first: true, predicate: ["items"], descendants: true }, { propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true }, { propertyName: "lastHiddenFocusableElementOnOverlay", first: true, predicate: ["lastHiddenFocusableEl"], descendants: true }, { propertyName: "firstHiddenFocusableElementOnOverlay", first: true, predicate: ["firstHiddenFocusableEl"], descendants: true }, { propertyName: "headerCheckboxViewChild", first: true, predicate: ["headerCheckbox"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
<div class="p-hidden-accessible" [attr.data-p-hidden-accessible]="true">
<input
#focusInput
[pTooltip]="tooltip"
[tooltipPosition]="tooltipPosition"
[positionStyle]="tooltipPositionStyle"
[tooltipStyleClass]="tooltipStyleClass"
[attr.aria-disabled]="disabled"
[attr.id]="inputId"
role="combobox"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.aria-haspopup]="'listbox'"
[attr.aria-expanded]="overlayVisible ?? false"
[attr.aria-controls]="overlayVisible ? id + '_list' : null"
[attr.tabindex]="!disabled ? tabindex : -1"
[attr.aria-activedescendant]="focused ? focusedOptionId : undefined"
(focus)="onInputFocus($event)"
(blur)="onInputBlur($event)"
(keydown)="onKeyDown($event)"
[pAutoFocus]="autofocus"
[attr.value]="label() || 'empty'"
/>
</div>
<div
class="p-multiselect-label-container"
[pTooltip]="tooltip"
(mouseleave)="labelContainerMouseLeave()"
[tooltipDisabled]="_disableTooltip"
[tooltipPosition]="tooltipPosition"
[positionStyle]="tooltipPositionStyle"
[tooltipStyleClass]="tooltipStyleClass"
>
<div [ngClass]="labelClass">
<ng-container *ngIf="!selectedItemsTemplate && !_selectedItemsTemplate">
<ng-container *ngIf="display === 'comma'">{{ label() || 'empty' }}</ng-container>
<ng-container *ngIf="display === 'chip'">
<div #token *ngFor="let item of chipSelectedItems(); let i = index" class="p-multiselect-chip-item">
<p-chip styleClass="p-multiselect-chip" [label]="getLabelByValue(item)" [removable]="!disabled && !readonly" (onRemove)="removeOption(item, $event)" [removeIcon]="chipIcon">
<ng-container *ngIf="chipIconTemplate || _chipIconTemplate || removeTokenIconTemplate || _removeTokenIconTemplate">
<ng-template #removeicon>
<ng-container *ngIf="!disabled && !readonly">
<span
class="p-multiselect-chip-icon"
*ngIf="chipIconTemplate || _chipIconTemplate || removeTokenIconTemplate || _removeTokenIconTemplate"
(click)="removeOption(item, $event)"
[attr.data-pc-section]="'clearicon'"
[attr.aria-hidden]="true"
>
<ng-container *ngTemplateOutlet="chipIconTemplate || _chipIconTemplate || removeTokenIconTemplate || _removeTokenIconTemplate; context: { class: 'p-multiselect-chip-icon' }"></ng-container>
</span>
</ng-container>
</ng-template>
</ng-container>
</p-chip>
</div>
<ng-container *ngIf="!modelValue() || modelValue().length === 0">{{ placeholder() || defaultLabel || 'empty' }}</ng-container>
</ng-container>
</ng-container>
<ng-container *ngIf="selectedItemsTemplate || _selectedItemsTemplate">
<ng-container *ngTemplateOutlet="selectedItemsTemplate || _selectedItemsTemplate; context: { $implicit: selectedOptions, removeChip: removeOption.bind(this) }"></ng-container>
<ng-container *ngIf="!modelValue() || modelValue().length === 0">{{ placeholder() || defaultLabel || 'empty' }}</ng-container>
</ng-container>
</div>
</div>
<ng-container *ngIf="isVisibleClearIcon">
<TimesIcon *ngIf="!clearIconTemplate && !_clearIconTemplate" class="p-multiselect-clear-icon" (click)="clear($event)" [attr.data-pc-section]="'clearicon'" [attr.aria-hidden]="true" />
<span *ngIf="clearIconTemplate || _clearIconTemplate" class="p-multiselect-clear-icon" (click)="clear($event)" [attr.data-pc-section]="'clearicon'" [attr.aria-hidden]="true">
<ng-template *ngTemplateOutlet="clearIconTemplate || _clearIconTemplate"></ng-template>
</span>
</ng-container>
<div class="p-multiselect-dropdown">
<ng-container *ngIf="loading; else elseBlock">
<ng-container *ngIf="loadingIconTemplate || _loadingIconTemplate">
<ng-container *ngTemplateOutlet="loadingIconTemplate || _loadingIconTemplate"></ng-container>
</ng-container>
<ng-container *ngIf="!loadingIconTemplate && !_loadingIconTemplate">
<span *ngIf="loadingIcon" [ngClass]="'p-multiselect-loading-icon pi-spin ' + loadingIcon" aria-hidden="true"></span>
<span *ngIf="!loadingIcon" [class]="'p-multiselect-loading-icon pi pi-spinner pi-spin'" aria-hidden="true"></span>
</ng-container>
</ng-container>
<ng-template #elseBlock>
<ng-container *ngIf="!dropdownIconTemplate && !_dropdownIconTemplate">
<span *ngIf="dropdownIcon" class="p-multiselect-dropdown-icon" [ngClass]="dropdownIcon" [attr.data-pc-section]="'triggericon'" [attr.aria-hidden]="true"></span>
<ChevronDownIcon *ngIf="!dropdownIcon" [styleClass]="'p-multiselect-dropdown-icon'" [attr.data-pc-section]="'triggericon'" [attr.aria-hidden]="true" />
</ng-container>
<span *ngIf="dropdownIconTemplate || _dropdownIconTemplate" class="p-multiselect-dropdown-icon" [attr.data-pc-section]="'triggericon'" [attr.aria-hidden]="true">
<ng-template *ngTemplateOutlet="dropdownIconTemplate || _dropdownIconTemplate"></ng-template>
</span>
</ng-template>
</div>
<p-overlay
#overlay
[(visible)]="overlayVisible"
[options]="overlayOptions"
[target]="'@parent'"
[appendTo]="appendTo"
[autoZIndex]="autoZIndex"
[baseZIndex]="baseZIndex"
[showTransitionOptions]="showTransitionOptions"
[hideTransitionOptions]="hideTransitionOptions"
(onAnimationStart)="onOverlayAnimationStart($event)"
(onHide)="hide()"
>
<ng-template #content>
<div [attr.id]="id + '_list'" [ngClass]="'p-multiselect-overlay p-component'" [ngStyle]="panelStyle" [class]="panelStyleClass">
<span
#firstHiddenFocusableEl
role="presentation"
class="p-hidden-accessible p-hidden-focusable"
[attr.tabindex]="0"
(focus)="onFirstHiddenFocus($event)"
[attr.data-p-hidden-accessible]="true"
[attr.data-p-hidden-focusable]="true"
>
</span>
<ng-container *ngTemplateOutlet="headerTemplate || _headerTemplate"></ng-container>
<div class="p-multiselect-header" *ngIf="showHeader">
<ng-content select="p-header"></ng-content>
<ng-container *ngIf="filterTemplate || _filterTemplate; else builtInFilterElement">
<ng-container *ngTemplateOutlet="filterTemplate || _filterTemplate; context: { options: filterOptions }"></ng-container>
</ng-container>
<ng-template #builtInFilterElement>
<p-checkbox [ngModel]="allSelected()" [ariaLabel]="toggleAllAriaLabel" [binary]="true" (onChange)="onToggleAll($event)" *ngIf="showToggleAll && !selectionLimit" [variant]="variant" [disabled]="disabled" #headerCheckbox>
<ng-template #checkboxicon let-klass="class">
<CheckIcon *ngIf="!headerCheckboxIconTemplate && !_headerCheckboxIconTemplate && allSelected()" [styleClass]="klass" [attr.data-pc-section]="'icon'" />
<ng-template
*ngTemplateOutlet="
headerCheckboxIconTemplate || _headerCheckboxIconTemplate;
context: {
checked: allSelected(),
partialSelected: partialSelected(),
class: klass
}
"
></ng-template>
</ng-template>
</p-checkbox>
<div class="p-multiselect-filter-container" *ngIf="filter">
<p-iconfield>
<input
#filterInput
pInputText
[variant]="variant"
type="text"
[attr.autocomplete]="autocomplete"
role="searchbox"
[attr.aria-owns]="id + '_list'"
[attr.aria-activedescendant]="focusedOptionId"
[value]="_filterValue() || ''"
(input)="onFilterInputChange($event)"
(keydown)="onFilterKeyDown($event)"
(click)="onInputClick($event)"
(blur)="onFilterBlur($event)"
class="p-multiselect-filter"
[disabled]="disabled"
[attr.placeholder]="filterPlaceHolder"
[attr.aria-label]="ariaFilterLabel"
/>
<p-inputicon>
<SearchIcon [styleClass]="'p-multiselect-filter-icon'" *ngIf="!filterIconTemplate && !_filterIconTemplate" />
<span *ngIf="filterIconTemplate || _filterIconTemplate" class="p-multiselect-filter-icon">
<ng-template *ngTemplateOutlet="filterIconTemplate || _filterIconTemplate"></ng-template>
</span>
</p-inputicon>
</p-iconfield>
</div>
</ng-template>
</div>
<div class="p-multiselect-list-container" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'">
<p-scroller
*ngIf="virtualScroll"
#scroller
[items]="visibleOptions()"
[style]="{ height: scrollHeight }"
[itemSize]="virtualScrollItemSize || _itemSize"
[autoSize]="true"
[tabindex]="-1"
[lazy]="lazy"
(onLazyLoad)="onLazyLoad.emit($event)"
[options]="virtualScrollOptions"
>
<ng-template #content let-items let-scrollerOptions="options">
<ng-container *ngTemplateOutlet="buildInItems; context: { $implicit: items, options: scrollerOptions }"></ng-container>
</ng-template>
<ng-container *ngIf="loaderTemplate || _loaderTemplate">
<ng-template #loader let-scrollerOptions="options">
<ng-container *ngTemplateOutlet="loaderTemplate || _loaderTemplate; context: { options: scrollerOptions }"></ng-container>
</ng-template>
</ng-container>
</p-scroller>
<ng-container *ngIf="!virtualScroll">
<ng-container *ngTemplateOutlet="buildInItems; context: { $implicit: visibleOptions(), options: {} }"></ng-container>
</ng-container>
<ng-template #buildInItems let-items let-scrollerOptions="options">
<ul #items class="p-multiselect-list" [ngClass]="scrollerOptions.contentStyleClass" [style]="scrollerOptions.contentStyle" role="listbox" aria-multiselectable="true" [attr.aria-label]="listLabel">
<ng-template ngFor let-option [ngForOf]="items" let-i="index">
<ng-container *ngIf="isOptionGroup(option)">
<li [attr.id]="id + '_' + getOptionIndex(i, scrollerOptions)" class="p-multiselect-option-group" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
<span *ngIf="!groupTemplate">{{ getOptionGroupLabel(option.optionGroup) }}</span>
<ng-container *ngTemplateOutlet="groupTemplate; context: { $implicit: option.optionGroup }"></ng-container>
</li>
</ng-container>
<ng-container *ngIf="!isOptionGroup(option)">
<p-multiselect-item
[id]="id + '_' + getOptionIndex(i, scrollerOptions)"
[option]="option"
[selected]="isSelected(option)"
[label]="getOptionLabel(option)"
[disabled]="isOptionDisabled(option)"
[template]="itemTemplate || _itemTemplate"
[checkIconTemplate]="checkIconTemplate || _checkIconTemplate"
[itemCheckboxIconTemplate]="itemCheckboxIconTemplate || _itemCheckboxIconTemplate"
[itemSize]="scrollerOptions.itemSize"
[focused]="focusedOptionIndex() === getOptionIndex(i, scrollerOptions)"
[ariaPosInset]="getAriaPosInset(getOptionIndex(i, scrollerOptions))"
[ariaSetSize]="ariaSetSize"
[variant]="variant"
(onClick)="onOptionSelect($event, false, getOptionIndex(i, scrollerOptions))"
(onMouseEnter)="onOptionMouseEnter($event, getOptionIndex(i, scrollerOptions))"
></p-multiselect-item>
</ng-container>
</ng-template>
<li *ngIf="hasFilter() && isEmpty()" class="p-multiselect-empty-message" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
@if (!emptyFilterTemplate && !_emptyFilterTemplate && !emptyTemplate && !_emptyTemplate) {
{{ emptyFilterMessageLabel }}
} @else {
<ng-container *ngTemplateOutlet="emptyFilterTemplate || _emptyFilterTemplate || emptyTemplate || _emptyFilterTemplate"></ng-container>
}
</li>
<li *ngIf="!hasFilter() && isEmpty()" class="p-multiselect-empty-message" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
@if (!emptyTemplate && !_emptyTemplate) {
{{ emptyMessageLabel }}
} @else {
<ng-container *ngTemplateOutlet="emptyTemplate || _emptyTemplate"></ng-container>
}
</li>
</ul>
</ng-template>
</div>
<div *ngIf="footerFacet || footerTemplate || _footerTemplate">
<ng-content select="p-footer"></ng-content>
<ng-container *ngTemplateOutlet="footerTemplate || _footerTemplate"></ng-container>
</div>
<span
#lastHiddenFocusableEl
role="presentation"
class="p-hidden-accessible p-hidden-focusable"
[attr.tabindex]="0"
(focus)="onLastHiddenFocus($event)"
[attr.data-p-hidden-accessible]="true"
[attr.data-p-hidden-focusable]="true"
></span>
</div>
</ng-template>
</p-overlay>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: MultiSelectItem, selector: "p-multiSelectItem, p-multiselect-item", inputs: ["id", "option", "selected", "label", "disabled", "itemSize", "focused", "ariaPosInset", "ariaSetSize", "variant", "template", "checkIconTemplate", "itemCheckboxIconTemplate"], outputs: ["onClick", "onMouseEnter"] }, { kind: "component", type: Overlay, selector: "p-overlay", inputs: ["visible", "mode", "style", "styleClass", "contentStyle", "contentStyleClass", "target", "appendTo", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "listener", "responsive", "options"], outputs: ["visibleChange", "onBeforeShow", "onShow", "onBeforeHide", "onHide", "onAnimationStart", "onAnimationDone"] }, { kind: "ngmodule", type: SharedModule }, { kind: "directive", type: Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "component", type: Scroller, selector: "p-scroller, p-virtualscroller, p-virtual-scroller, p-virtualScroller", inputs: ["id", "style", "styleClass", "tabindex", "items", "itemSize", "scrollHeight", "scrollWidth", "orientation", "step", "delay", "resizeDelay", "appendOnly", "inline", "lazy", "disabled", "loaderDisabled", "columns", "showSpacer", "showLoader", "numToleratedItems", "loading", "autoSize", "trackBy", "options"], outputs: ["onLazyLoad", "onScroll", "onScrollIndexChange"] }, { kind: "directive", type: AutoFocus, selector: "[pAutoFocus]", inputs: ["autofocus", "pAutoFocus"] }, { kind: "component", type: CheckIcon, selector: "CheckIcon" }, { kind: "component", type: SearchIcon, selector: "SearchIcon" }, { kind: "component", type: TimesIcon, selector: "TimesIcon" }, { kind: "component", type: ChevronDownIcon, selector: "ChevronDownIcon" }, { kind: "component", type: IconField, selector: "p-iconfield, p-iconField, p-icon-field", inputs: ["iconPosition", "styleClass"] }, { kind: "component", type: InputIcon, selector: "p-inputicon, p-inputIcon", inputs: ["styleClass"] }, { kind: "directive", type: InputText, selector: "[pInputText]", inputs: ["variant", "fluid", "pSize"] }, { kind: "component", type: Chip, selector: "p-chip", inputs: ["label", "icon", "image", "alt", "style", "styleClass", "removable", "removeIcon", "chipProps"], outputs: ["onRemove", "onImageError"] }, { kind: "component", type: Checkbox, selector: "p-checkbox, p-checkBox, p-check-box", inputs: ["value", "name", "disabled", "binary", "ariaLabelledBy", "ariaLabel", "tabindex", "inputId", "style", "inputStyle", "styleClass", "inputClass", "indeterminate", "size", "formControl", "checkboxIcon", "readonly", "required", "autofocus", "trueValue", "falseValue", "variant"], outputs: ["onChange", "onFocus", "onBlur"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelect, decorators: [{
type: Component,
args: [{
selector: 'p-multiSelect, p-multiselect, p-multi-select',
standalone: true,
imports: [CommonModule, MultiSelectItem, Overlay, SharedModule, Tooltip, Scroller, AutoFocus, CheckIcon, SearchIcon, TimesIcon, ChevronDownIcon, IconField, InputIcon, InputText, Chip, Checkbox, FormsModule],
template: `
<div class="p-hidden-accessible" [attr.data-p-hidden-accessible]="true">
<input
#focusInput
[pTooltip]="tooltip"
[tooltipPosition]="tooltipPosition"
[positionStyle]="tooltipPositionStyle"
[tooltipStyleClass]="tooltipStyleClass"
[attr.aria-disabled]="disabled"
[attr.id]="inputId"
role="combobox"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.aria-haspopup]="'listbox'"
[attr.aria-expanded]="overlayVisible ?? false"
[attr.aria-controls]="overlayVisible ? id + '_list' : null"
[attr.tabindex]="!disabled ? tabindex : -1"
[attr.aria-activedescendant]="focused ? focusedOptionId : undefined"
(focus)="onInputFocus($event)"
(blur)="onInputBlur($event)"
(keydown)="onKeyDown($event)"
[pAutoFocus]="autofocus"
[attr.value]="label() || 'empty'"
/>
</div>
<div
class="p-multiselect-label-container"
[pTooltip]="tooltip"
(mouseleave)="labelContainerMouseLeave()"
[tooltipDisabled]="_disableTooltip"
[tooltipPosition]="tooltipPosition"
[positionStyle]="tooltipPositionStyle"
[tooltipStyleClass]="tooltipStyleClass"
>
<div [ngClass]="labelClass">
<ng-container *ngIf="!selectedItemsTemplate && !_selectedItemsTemplate">
<ng-container *ngIf="display === 'comma'">{{ label() || 'empty' }}</ng-container>
<ng-container *ngIf="display === 'chip'">
<div #token *ngFor="let item of chipSelectedItems(); let i = index" class="p-multiselect-chip-item">
<p-chip styleClass="p-multiselect-chip" [label]="getLabelByValue(item)" [removable]="!disabled && !readonly" (onRemove)="removeOption(item, $event)" [removeIcon]="chipIcon">
<ng-container *ngIf="chipIconTemplate || _chipIconTemplate || removeTokenIconTemplate || _removeTokenIconTemplate">
<ng-template #removeicon>
<ng-container *ngIf="!disabled && !readonly">
<span
class="p-multiselect-chip-icon"
*ngIf="chipIconTemplate || _chipIconTemplate || removeTokenIconTemplate || _removeTokenIconTemplate"
(click)="removeOption(item, $event)"
[attr.data-pc-section]="'clearicon'"
[attr.aria-hidden]="true"
>
<ng-container *ngTemplateOutlet="chipIconTemplate || _chipIconTemplate || removeTokenIconTemplate || _removeTokenIconTemplate; context: { class: 'p-multiselect-chip-icon' }"></ng-container>
</span>
</ng-container>
</ng-template>
</ng-container>
</p-chip>
</div>
<ng-container *ngIf="!modelValue() || modelValue().length === 0">{{ placeholder() || defaultLabel || 'empty' }}</ng-container>
</ng-container>
</ng-container>
<ng-container *ngIf="selectedItemsTemplate || _selectedItemsTemplate">
<ng-container *ngTemplateOutlet="selectedItemsTemplate || _selectedItemsTemplate; context: { $implicit: selectedOptions, removeChip: removeOption.bind(this) }"></ng-container>
<ng-container *ngIf="!modelValue() || modelValue().length === 0">{{ placeholder() || defaultLabel || 'empty' }}</ng-container>
</ng-container>
</div>
</div>
<ng-container *ngIf="isVisibleClearIcon">
<TimesIcon *ngIf="!clearIconTemplate && !_clearIconTemplate" class="p-multiselect-clear-icon" (click)="clear($event)" [attr.data-pc-section]="'clearicon'" [attr.aria-hidden]="true" />
<span *ngIf="clearIconTemplate || _clearIconTemplate" class="p-multiselect-clear-icon" (click)="clear($event)" [attr.data-pc-section]="'clearicon'" [attr.aria-hidden]="true">
<ng-template *ngTemplateOutlet="clearIconTemplate || _clearIconTemplate"></ng-template>
</span>
</ng-container>
<div class="p-multiselect-dropdown">
<ng-container *ngIf="loading; else elseBlock">
<ng-container *ngIf="loadingIconTemplate || _loadingIconTemplate">
<ng-container *ngTemplateOutlet="loadingIconTemplate || _loadingIconTemplate"></ng-container>
</ng-container>
<ng-container *ngIf="!loadingIconTemplate && !_loadingIconTemplate">
<span *ngIf="loadingIcon" [ngClass]="'p-multiselect-loading-icon pi-spin ' + loadingIcon" aria-hidden="true"></span>
<span *ngIf="!loadingIcon" [class]="'p-multiselect-loading-icon pi pi-spinner pi-spin'" aria-hidden="true"></span>
</ng-container>
</ng-container>
<ng-template #elseBlock>
<ng-container *ngIf="!dropdownIconTemplate && !_dropdownIconTemplate">
<span *ngIf="dropdownIcon" class="p-multiselect-dropdown-icon" [ngClass]="dropdownIcon" [attr.data-pc-section]="'triggericon'" [attr.aria-hidden]="true"></span>
<ChevronDownIcon *ngIf="!dropdownIcon" [styleClass]="'p-multiselect-dropdown-icon'" [attr.data-pc-section]="'triggericon'" [attr.aria-hidden]="true" />
</ng-container>
<span *ngIf="dropdownIconTemplate || _dropdownIconTemplate" class="p-multiselect-dropdown-icon" [attr.data-pc-section]="'triggericon'" [attr.aria-hidden]="true">
<ng-template *ngTemplateOutlet="dropdownIconTemplate || _dropdownIconTemplate"></ng-template>
</span>
</ng-template>
</div>
<p-overlay
#overlay
[(visible)]="overlayVisible"
[options]="overlayOptions"
[target]="'@parent'"
[appendTo]="appendTo"
[autoZIndex]="autoZIndex"
[baseZIndex]="baseZIndex"
[showTransitionOptions]="showTransitionOptions"
[hideTransitionOptions]="hideTransitionOptions"
(onAnimationStart)="onOverlayAnimationStart($event)"
(onHide)="hide()"
>
<ng-template #content>
<div [attr.id]="id + '_list'" [ngClass]="'p-multiselect-overlay p-component'" [ngStyle]="panelStyle" [class]="panelStyleClass">
<span
#firstHiddenFocusableEl
role="presentation"
class="p-hidden-accessible p-hidden-focusable"
[attr.tabindex]="0"
(focus)="onFirstHiddenFocus($event)"
[attr.data-p-hidden-accessible]="true"
[attr.data-p-hidden-focusable]="true"
>
</span>
<ng-container *ngTemplateOutlet="headerTemplate || _headerTemplate"></ng-container>
<div class="p-multiselect-header" *ngIf="showHeader">
<ng-content select="p-header"></ng-content>
<ng-container *ngIf="filterTemplate || _filterTemplate; else builtInFilterElement">
<ng-container *ngTemplateOutlet="filterTemplate || _filterTemplate; context: { options: filterOptions }"></ng-container>
</ng-container>
<ng-template #builtInFilterElement>
<p-checkbox [ngModel]="allSelected()" [ariaLabel]="toggleAllAriaLabel" [binary]="true" (onChange)="onToggleAll($event)" *ngIf="showToggleAll && !selectionLimit" [variant]="variant" [disabled]="disabled" #headerCheckbox>
<ng-template #checkboxicon let-klass="class">
<CheckIcon *ngIf="!headerCheckboxIconTemplate && !_headerCheckboxIconTemplate && allSelected()" [styleClass]="klass" [attr.data-pc-section]="'icon'" />
<ng-template
*ngTemplateOutlet="
headerCheckboxIconTemplate || _headerCheckboxIconTemplate;
context: {
checked: allSelected(),
partialSelected: partialSelected(),
class: klass
}
"
></ng-template>
</ng-template>
</p-checkbox>
<div class="p-multiselect-filter-container" *ngIf="filter">
<p-iconfield>
<input
#filterInput
pInputText
[variant]="variant"
type="text"
[attr.autocomplete]="autocomplete"
role="searchbox"
[attr.aria-owns]="id + '_list'"
[attr.aria-activedescendant]="focusedOptionId"
[value]="_filterValue() || ''"
(input)="onFilterInputChange($event)"
(keydown)="onFilterKeyDown($event)"
(click)="onInputClick($event)"
(blur)="onFilterBlur($event)"
class="p-multiselect-filter"
[disabled]="disabled"
[attr.placeholder]="filterPlaceHolder"
[attr.aria-label]="ariaFilterLabel"
/>
<p-inputicon>
<SearchIcon [styleClass]="'p-multiselect-filter-icon'" *ngIf="!filterIconTemplate && !_filterIconTemplate" />
<span *ngIf="filterIconTemplate || _filterIconTemplate" class="p-multiselect-filter-icon">
<ng-template *ngTemplateOutlet="filterIconTemplate || _filterIconTemplate"></ng-template>
</span>
</p-inputicon>
</p-iconfield>
</div>
</ng-template>
</div>
<div class="p-multiselect-list-container" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'">
<p-scroller
*ngIf="virtualScroll"
#scroller
[items]="visibleOptions()"
[style]="{ height: scrollHeight }"
[itemSize]="virtualScrollItemSize || _itemSize"
[autoSize]="true"
[tabindex]="-1"
[lazy]="lazy"
(onLazyLoad)="onLazyLoad.emit($event)"
[options]="virtualScrollOptions"
>
<ng-template #content let-items let-scrollerOptions="options">
<ng-container *ngTemplateOutlet="buildInItems; context: { $implicit: items, options: scrollerOptions }"></ng-container>
</ng-template>
<ng-container *ngIf="loaderTemplate || _loaderTemplate">
<ng-template #loader let-scrollerOptions="options">
<ng-container *ngTemplateOutlet="loaderTemplate || _loaderTemplate; context: { options: scrollerOptions }"></ng-container>
</ng-template>
</ng-container>
</p-scroller>
<ng-container *ngIf="!virtualScroll">
<ng-container *ngTemplateOutlet="buildInItems; context: { $implicit: visibleOptions(), options: {} }"></ng-container>
</ng-container>
<ng-template #buildInItems let-items let-scrollerOptions="options">
<ul #items class="p-multiselect-list" [ngClass]="scrollerOptions.contentStyleClass" [style]="scrollerOptions.contentStyle" role="listbox" aria-multiselectable="true" [attr.aria-label]="listLabel">
<ng-template ngFor let-option [ngForOf]="items" let-i="index">
<ng-container *ngIf="isOptionGroup(option)">
<li [attr.id]="id + '_' + getOptionIndex(i, scrollerOptions)" class="p-multiselect-option-group" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
<span *ngIf="!groupTemplate">{{ getOptionGroupLabel(option.optionGroup) }}</span>
<ng-container *ngTemplateOutlet="groupTemplate; context: { $implicit: option.optionGroup }"></ng-container>
</li>
</ng-container>
<ng-container *ngIf="!isOptionGroup(option)">
<p-multiselect-item
[id]="id + '_' + getOptionIndex(i, scrollerOptions)"
[option]="option"
[selected]="isSelected(option)"
[label]="getOptionLabel(option)"
[disabled]="isOptionDisabled(option)"
[template]="itemTemplate || _itemTemplate"
[checkIconTemplate]="checkIconTemplate || _checkIconTemplate"
[itemCheckboxIconTemplate]="itemCheckboxIconTemplate || _itemCheckboxIconTemplate"
[itemSize]="scrollerOptions.itemSize"
[focused]="focusedOptionIndex() === getOptionIndex(i, scrollerOptions)"
[ariaPosInset]="getAriaPosInset(getOptionIndex(i, scrollerOptions))"
[ariaSetSize]="ariaSetSize"
[variant]="variant"
(onClick)="onOptionSelect($event, false, getOptionIndex(i, scrollerOptions))"
(onMouseEnter)="onOptionMouseEnter($event, getOptionIndex(i, scrollerOptions))"
></p-multiselect-item>
</ng-container>
</ng-template>
<li *ngIf="hasFilter() && isEmpty()" class="p-multiselect-empty-message" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
@if (!emptyFilterTemplate && !_emptyFilterTemplate && !emptyTemplate && !_emptyTemplate) {
{{ emptyFilterMessageLabel }}
} @else {
<ng-container *ngTemplateOutlet="emptyFilterTemplate || _emptyFilterTemplate || emptyTemplate || _emptyFilterTemplate"></ng-container>
}
</li>
<li *ngIf="!hasFilter() && isEmpty()" class="p-multiselect-empty-message" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
@if (!emptyTemplate && !_emptyTemplate) {
{{ emptyMessageLabel }}
} @else {
<ng-container *ngTemplateOutlet="emptyTemplate || _emptyTemplate"></ng-container>
}
</li>
</ul>
</ng-template>
</div>
<div *ngIf="footerFacet || footerTemplate || _footerTemplate">
<ng-content select="p-footer"></ng-content>
<ng-container *ngTemplateOutlet="footerTemplate || _footerTemplate"></ng-container>
</div>
<span
#lastHiddenFocusableEl
role="presentation"
class="p-hidden-accessible p-hidden-focusable"
[attr.tabindex]="0"
(focus)="onLastHiddenFocus($event)"
[attr.data-p-hidden-accessible]="true"
[attr.data-p-hidden-focusable]="true"
></span>
</div>
</ng-template>
</p-overlay>
`,
providers: [MULTISELECT_VALUE_ACCESSOR, MultiSelectStyle],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
'[attr.id]': 'id',
'[style]': 'style',
'(click)': 'onContainerClick($event)',
'[class.p-variant-filled]': 'variant === "filled" || config.inputVariant() === "filled" || config.inputStyle() === "filled" '
}
}]
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i3.FilterService }, { type: i3.OverlayService }], propDecorators: { id: [{
type: Input
}], ariaLabel: [{
type: Input
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], panelStyle: [{
type: Input
}], panelStyleClass: [{
type: Input
}], inputId: [{
type: Input
}], disabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], fluid: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], readonly: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], group: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], filter: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], filterPlaceHolder: [{
type: Input
}], filterLocale: [{
type: Input
}], overlayVisible: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], tabindex: [{
type: Input,
args: [{ transform: numberAttribute }]
}], variant: [{
type: Input
}], appendTo: [{
type: Input
}], dataKey: [{
type: Input
}], name: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], displaySelectedLabel: [{
type: Input
}], maxSelectedLabels: [{
type: Input
}], selectionLimit: [{
type: Input,
args: [{ transform: numberAttribute }]
}], selectedItemsLabel: [{
type: Input
}], showToggleAll: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], emptyFilterMessage: [{
type: Input
}], emptyMessage: [{
type: Input
}], resetFilterOnHide: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], dropdownIcon: [{
type: Input
}], chipIcon: [{
type: Input
}], optionLabel: [{
type: Input
}], optionValue: [{
type: Input
}], optionDisabled: [{
type: Input
}], optionGroupLabel: [{
type: Input
}], optionGroupChildren: [{
type: Input
}], showHeader: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], filterBy: [{
type: Input
}], scrollHeight: [{
type: Input
}], lazy: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], virtualScroll: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], loading: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], virtualScrollItemSize: [{
type: Input,
args: [{ transform: numberAttribute }]
}], loadingIcon: [{
type: Input
}], virtualScrollOptions: [{
type: Input
}], overlayOptions: [{
type: Input
}], ariaFilterLabel: [{
type: Input
}], filterMatchMode: [{
type: Input
}], tooltip: [{
type: Input
}], tooltipPosition: [{
type: Input
}], tooltipPositionStyle: [{
type: Input
}], tooltipStyleClass: [{
type: Input
}], autofocusFilter: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], display: [{
type: Input
}], autocomplete: [{
type: Input
}], size: [{
type: Input
}], showClear: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autofocus: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoZIndex: [{
type: Input
}], baseZIndex: [{
type: Input
}], showTransitionOptions: [{
type: Input
}], hideTransitionOptions: [{
type: Input
}], defaultLabel: [{
type: Input
}], placeholder: [{
type: Input
}], options: [{
type: Input
}], filterValue: [{
type: Input
}], itemSize: [{
type: Input
}], selectAll: [{
type: Input
}], focusOnHover: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], filterFields: [{
type: Input
}], selectOnFocus: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], autoOptionFocus: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], onChange: [{
type: Output
}], onFilter: [{
type: Output
}], onFocus: [{
type: Output
}], onBlur: [{
type: Output
}], onClick: [{
type: Output
}], onClear: [{
type: Output
}], onPanelShow: [{
type: Output
}], onPanelHide: [{
type: Output
}], onLazyLoad: [{
type: Output
}], onRemove: [{
type: Output
}], onSelectAllChange: [{
type: Output
}], overlayViewChild: [{
type: ViewChild,
args: ['overlay']
}], filterInputChild: [{
type: ViewChild,
args: ['filterInput']
}], focusInputViewChild: [{
type: ViewChild,
args: ['focusInput']
}], itemsViewChild: [{
type: ViewChild,
args: ['items']
}], scroller: [{
type: ViewChild,
args: ['scroller']
}], lastHiddenFocusableElementOnOverlay: [{
type: ViewChild,
args: ['lastHiddenFocusableEl']
}], firstHiddenFocusableElementOnOverlay: [{
type: ViewChild,
args: ['firstHiddenFocusableEl']
}], headerCheckboxViewChild: [{
type: ViewChild,
args: ['headerCheckbox']
}], footerFacet: [{
type: ContentChild,
args: [Footer]
}], headerFacet: [{
type: ContentChild,
args: [Header]
}], itemTemplate: [{
type: ContentChild,
args: ['item', { descendants: false }]
}], groupTemplate: [{
type: ContentChild,
args: ['group', { descendants: false }]
}], loaderTemplate: [{
type: ContentChild,
args: ['loader', { descendants: false }]
}], headerTemplate: [{
type: ContentChild,
args: ['header', { descendants: false }]
}], filterTemplate: [{
type: ContentChild,
args: ['filter', { descendants: false }]
}], footerTemplate: [{
type: ContentChild,
args: ['footer', { descendants: false }]
}], emptyFilterTemplate: [{
type: ContentChild,
args: ['emptyfilter', { descendants: false }]
}], emptyTemplate: [{
type: ContentChild,
args: ['empty', { descendants: false }]
}], selectedItemsTemplate: [{
type: ContentChild,
args: ['selecteditems', { descendants: false }]
}], checkIconTemplate: [{
type: ContentChild,
args: ['checkicon', { descendants: false }]
}], loadingIconTemplate: [{
type: ContentChild,
args: ['loadingicon', { descendants: false }]
}], filterIconTemplate: [{
type: ContentChild,
args: ['filtericon', { descendants: false }]
}], removeTokenIconTemplate: [{
type: ContentChild,
args: ['removetokenicon', { descendants: false }]
}], chipIconTemplate: [{
type: ContentChild,
args: ['chipicon', { descendants: false }]
}], clearIconTemplate: [{
type: ContentChild,
args: ['clearicon', { descendants: false }]
}], dropdownIconTemplate: [{
type: ContentChild,
args: ['dropdownicon', { descendants: false }]
}], itemCheckboxIconTemplate: [{
type: ContentChild,
args: ['itemcheckboxicon', { descendants: false }]
}], headerCheckboxIconTemplate: [{
type: ContentChild,
args: ['headercheckboxicon', { descendants: false }]
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}], hostClasses: [{
type: HostBinding,
args: ['class']
}] } });
class MultiSelectModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectModule, imports: [MultiSelect, SharedModule], exports: [MultiSelect, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectModule, imports: [MultiSelect, SharedModule, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: MultiSelectModule, decorators: [{
type: NgModule,
args: [{
imports: [MultiSelect, SharedModule],
exports: [MultiSelect, SharedModule]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { MULTISELECT_VALUE_ACCESSOR, MultiSelect, MultiSelectClasses, MultiSelectItem, MultiSelectModule, MultiSelectStyle };
//# sourceMappingURL=primeng-multiselect.mjs.map