@coreui/angular-pro 4.0.0-alpha.5 → 4.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4349,27 +4349,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4349
4349
  args: ['class']
4350
4350
  }] } });
4351
4351
 
4352
- class MultiSelectOptgroupComponent {
4353
- get hostClasses() {
4354
- return {
4355
- 'form-multi-select-options': true
4356
- };
4357
- }
4358
- }
4359
- MultiSelectOptgroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptgroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
4360
- MultiSelectOptgroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectOptgroupComponent, selector: "c-multi-select-optgroup", inputs: { label: "label", disabled: "disabled" }, host: { properties: { "class": "this.hostClasses" } }, ngImport: i0, template: "<c-multi-select-optgroup-label *ngIf=\"label\">{{label}}</c-multi-select-optgroup-label>\r\n<ng-content></ng-content>\r\n", styles: [":host{display:block}\n"], components: [{ type: MultiSelectOptgroupLabelComponent, selector: "c-multi-select-optgroup-label" }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4361
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptgroupComponent, decorators: [{
4362
- type: Component,
4363
- args: [{ selector: 'c-multi-select-optgroup', template: "<c-multi-select-optgroup-label *ngIf=\"label\">{{label}}</c-multi-select-optgroup-label>\r\n<ng-content></ng-content>\r\n", styles: [":host{display:block}\n"] }]
4364
- }], propDecorators: { label: [{
4365
- type: Input
4366
- }], disabled: [{
4367
- type: Input
4368
- }], hostClasses: [{
4369
- type: HostBinding,
4370
- args: ['class']
4371
- }] } });
4372
-
4373
4352
  class MultiSelectService {
4374
4353
  constructor() {
4375
4354
  this.multiSelectState = new BehaviorSubject({});
@@ -4391,17 +4370,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4391
4370
  }], ctorParameters: function () { return []; } });
4392
4371
 
4393
4372
  class MultiSelectOptionComponent {
4394
- constructor(elementRef, renderer, focusMonitor, multiSelectService) {
4373
+ constructor(elementRef, renderer, changeDetectorRef, focusMonitor, multiSelectService) {
4395
4374
  this.elementRef = elementRef;
4396
4375
  this.renderer = renderer;
4376
+ this.changeDetectorRef = changeDetectorRef;
4397
4377
  this.focusMonitor = focusMonitor;
4398
4378
  this.multiSelectService = multiSelectService;
4399
- this._disabled = false;
4400
- this._selected = false;
4401
4379
  this.optionsStyle = 'checkbox';
4402
4380
  this.visible = true;
4403
4381
  this.selectedChange = new EventEmitter();
4404
4382
  this.hasContent = true;
4383
+ this.dropdownVisible = false;
4384
+ this._disabled = false;
4385
+ this._selected = false;
4405
4386
  }
4406
4387
  set disabled(value) {
4407
4388
  this._disabled = coerceBooleanProperty(value);
@@ -4415,9 +4396,6 @@ class MultiSelectOptionComponent {
4415
4396
  this._selected = newValue;
4416
4397
  this.selectedChange.emit(newValue);
4417
4398
  this.multiSelectService.toggleOption(this);
4418
- if (newValue) {
4419
- this.focus();
4420
- }
4421
4399
  }
4422
4400
  }
4423
4401
  get selected() {
@@ -4441,14 +4419,16 @@ class MultiSelectOptionComponent {
4441
4419
  get ariaSelected() {
4442
4420
  return this.selected;
4443
4421
  }
4444
- onKeyUp($event) {
4445
- if ($event.key === 'Enter' || $event.code === 'Space') {
4422
+ onKeyDown($event) {
4423
+ if (['Enter', ' '].includes($event.key)) {
4446
4424
  $event.preventDefault();
4447
4425
  this.selected = this.disabled ? this.selected : !this.selected;
4426
+ this.focus('keyboard');
4448
4427
  }
4449
4428
  }
4450
4429
  onClick() {
4451
4430
  this.selected = this.disabled ? this.selected : !this.selected;
4431
+ this.focus('mouse');
4452
4432
  }
4453
4433
  ngAfterContentInit() {
4454
4434
  setTimeout(() => {
@@ -4461,27 +4441,30 @@ class MultiSelectOptionComponent {
4461
4441
  this.value = this.elementRef.nativeElement.innerText || this.label;
4462
4442
  }
4463
4443
  }
4464
- setActiveStyles() {
4465
- }
4466
- setInactiveStyles() {
4467
- }
4468
4444
  getLabel() {
4469
4445
  return (this.label ?? this.value);
4470
4446
  }
4471
4447
  focus(origin) {
4472
- this.focusMonitor.focusVia(this.elementRef, 'program');
4448
+ if (this.dropdownVisible) {
4449
+ this.focusMonitor.focusVia(this.elementRef, origin ?? 'program', { preventScroll: false });
4450
+ this.changeDetectorRef.markForCheck();
4451
+ }
4452
+ }
4453
+ ngOnDestroy() {
4454
+ this.multiselectVisibleSubscription.unsubscribe();
4455
+ }
4456
+ ngOnInit() {
4457
+ this.multiselectVisibleSubscription = this.multiSelectService.multiSelectVisible$.subscribe(visible => {
4458
+ this.dropdownVisible = visible;
4459
+ });
4473
4460
  }
4474
4461
  }
4475
- MultiSelectOptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptionComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1$1.FocusMonitor }, { token: MultiSelectService }], target: i0.ɵɵFactoryTarget.Component });
4476
- MultiSelectOptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectOptionComponent, selector: "c-multi-select-option", inputs: { disabled: "disabled", selected: "selected", optionsStyle: "optionsStyle", label: "label", value: "value", visible: "visible" }, outputs: { selectedChange: "selectedChange" }, host: { listeners: { "keydown": "onKeyUp($event)", "click": "onClick($event)" }, properties: { "class": "this.hostClasses", "attr.tabindex": "this.tabIndex", "attr.disabled": "this.ariaDisabled", "attr.aria-disabled": "this.ariaDisabled", "attr.aria-selected": "this.ariaSelected" } }, viewQueries: [{ propertyName: "content", first: true, predicate: ["contentDiv"], descendants: true }], ngImport: i0, template: "<div #contentDiv><ng-content></ng-content></div>\r\n<div *ngIf=\"!hasContent\">\r\n {{label ?? value}}\r\n</div>\r\n\r\n", styles: [":host{display:block;-webkit-user-select:none;user-select:none}:host.form-multi-select-option.disabled,:host.form-multi-select-option:disabled{pointer-events:all;cursor:default}\n"], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4462
+ MultiSelectOptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptionComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i1$1.FocusMonitor }, { token: MultiSelectService }], target: i0.ɵɵFactoryTarget.Component });
4463
+ MultiSelectOptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectOptionComponent, selector: "c-multi-select-option", inputs: { optionsStyle: "optionsStyle", label: "label", value: "value", visible: "visible", disabled: "disabled", selected: "selected" }, outputs: { selectedChange: "selectedChange" }, host: { listeners: { "keydown": "onKeyDown($event)", "click": "onClick($event)" }, properties: { "class": "this.hostClasses", "attr.tabindex": "this.tabIndex", "attr.disabled": "this.ariaDisabled", "attr.aria-disabled": "this.ariaDisabled", "attr.aria-selected": "this.ariaSelected" } }, viewQueries: [{ propertyName: "content", first: true, predicate: ["contentDiv"], descendants: true }], ngImport: i0, template: "<div #contentDiv><ng-content></ng-content></div>\r\n<div *ngIf=\"!hasContent\">\r\n {{label ?? value}}\r\n</div>\r\n\r\n", styles: [":host{display:block;-webkit-user-select:none;user-select:none}\n"], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4477
4464
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptionComponent, decorators: [{
4478
4465
  type: Component,
4479
- args: [{ selector: 'c-multi-select-option', template: "<div #contentDiv><ng-content></ng-content></div>\r\n<div *ngIf=\"!hasContent\">\r\n {{label ?? value}}\r\n</div>\r\n\r\n", styles: [":host{display:block;-webkit-user-select:none;user-select:none}:host.form-multi-select-option.disabled,:host.form-multi-select-option:disabled{pointer-events:all;cursor:default}\n"] }]
4480
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1$1.FocusMonitor }, { type: MultiSelectService }]; }, propDecorators: { disabled: [{
4481
- type: Input
4482
- }], selected: [{
4483
- type: Input
4484
- }], optionsStyle: [{
4466
+ args: [{ selector: 'c-multi-select-option', template: "<div #contentDiv><ng-content></ng-content></div>\r\n<div *ngIf=\"!hasContent\">\r\n {{label ?? value}}\r\n</div>\r\n\r\n", styles: [":host{display:block;-webkit-user-select:none;user-select:none}\n"] }]
4467
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i1$1.FocusMonitor }, { type: MultiSelectService }]; }, propDecorators: { optionsStyle: [{
4485
4468
  type: Input
4486
4469
  }], label: [{
4487
4470
  type: Input
@@ -4494,6 +4477,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4494
4477
  }], content: [{
4495
4478
  type: ViewChild,
4496
4479
  args: ['contentDiv']
4480
+ }], disabled: [{
4481
+ type: Input
4482
+ }], selected: [{
4483
+ type: Input
4497
4484
  }], hostClasses: [{
4498
4485
  type: HostBinding,
4499
4486
  args: ['class']
@@ -4509,7 +4496,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4509
4496
  }], ariaSelected: [{
4510
4497
  type: HostBinding,
4511
4498
  args: ['attr.aria-selected']
4512
- }], onKeyUp: [{
4499
+ }], onKeyDown: [{
4513
4500
  type: HostListener,
4514
4501
  args: ['keydown', ['$event']]
4515
4502
  }], onClick: [{
@@ -4517,6 +4504,52 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4517
4504
  args: ['click', ['$event']]
4518
4505
  }] } });
4519
4506
 
4507
+ class MultiSelectOptgroupComponent {
4508
+ constructor() {
4509
+ this._disabled = false;
4510
+ }
4511
+ set disabled(value) {
4512
+ this._disabled = coerceBooleanProperty(value);
4513
+ }
4514
+ get disabled() {
4515
+ return this._disabled;
4516
+ }
4517
+ get hostClasses() {
4518
+ return {
4519
+ 'form-multi-select-options': true
4520
+ };
4521
+ }
4522
+ ngAfterContentInit() {
4523
+ this.updateMultiSelectOptions();
4524
+ }
4525
+ ngOnChanges(changes) {
4526
+ if (changes['disabled']) {
4527
+ this.updateMultiSelectOptions();
4528
+ }
4529
+ }
4530
+ updateMultiSelectOptions() {
4531
+ this.multiSelectOptions?.forEach((option) => {
4532
+ option.disabled = this.disabled;
4533
+ });
4534
+ }
4535
+ }
4536
+ MultiSelectOptgroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptgroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
4537
+ MultiSelectOptgroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectOptgroupComponent, selector: "c-multi-select-optgroup", inputs: { label: "label", disabled: "disabled" }, host: { properties: { "class": "this.hostClasses" } }, queries: [{ propertyName: "multiSelectOptions", predicate: MultiSelectOptionComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<c-multi-select-optgroup-label *ngIf=\"label\">{{label}}</c-multi-select-optgroup-label>\r\n<ng-content></ng-content>\r\n", styles: [":host{display:block}\n"], components: [{ type: MultiSelectOptgroupLabelComponent, selector: "c-multi-select-optgroup-label" }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4538
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectOptgroupComponent, decorators: [{
4539
+ type: Component,
4540
+ args: [{ selector: 'c-multi-select-optgroup', template: "<c-multi-select-optgroup-label *ngIf=\"label\">{{label}}</c-multi-select-optgroup-label>\r\n<ng-content></ng-content>\r\n", styles: [":host{display:block}\n"] }]
4541
+ }], propDecorators: { label: [{
4542
+ type: Input
4543
+ }], disabled: [{
4544
+ type: Input
4545
+ }], multiSelectOptions: [{
4546
+ type: ContentChildren,
4547
+ args: [MultiSelectOptionComponent, { descendants: true }]
4548
+ }], hostClasses: [{
4549
+ type: HostBinding,
4550
+ args: ['class']
4551
+ }] } });
4552
+
4520
4553
  class MultiSelectTagComponent {
4521
4554
  constructor(multiSelectService) {
4522
4555
  this.multiSelectService = multiSelectService;
@@ -4576,10 +4609,10 @@ class MultiSelectNativeSelectComponent {
4576
4609
  }
4577
4610
  }
4578
4611
  MultiSelectNativeSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectNativeSelectComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
4579
- MultiSelectNativeSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectNativeSelectComponent, selector: "c-multi-select-native-select", inputs: { form: "form", id: "id", multiple: "multiple", name: "name", options: "options", disabled: "disabled" }, ngImport: i0, template: "<select [multiple]=\"multiple\" [name]=\"name\" style=\"display: none\" tabindex=\"-1\" [id]=\"id\" [disabled]=\"disabled\">\r\n <option\r\n *ngFor=\"let option of options\"\r\n [label]=\"option.label\"\r\n [selected]=\"option.selected\"\r\n [value]=\"option.value\"\r\n [disabled]=\"disabled\"\r\n tabindex=\"-1\"\r\n ></option>\r\n</select>\r\n\r\n", styles: [":host{display:none}\n"], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i5.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4612
+ MultiSelectNativeSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectNativeSelectComponent, selector: "c-multi-select-native-select", inputs: { form: "form", id: "id", multiple: "multiple", name: "name", options: "options", disabled: "disabled" }, ngImport: i0, template: "<select [multiple]=\"multiple\" [name]=\"name\" style=\"display: none\" tabindex=\"-1\" [id]=\"id\" [disabled]=\"disabled\">\n <option\n *ngFor=\"let option of options\"\n [label]=\"option.label\"\n [attr.selected]=\"option.selected ? '' : null\"\n [value]=\"option.value\"\n [disabled]=\"disabled\"\n tabindex=\"-1\"\n ></option>\n</select>\n\n", styles: [":host{display:none}\n"], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i5.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4580
4613
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectNativeSelectComponent, decorators: [{
4581
4614
  type: Component,
4582
- args: [{ selector: 'c-multi-select-native-select', changeDetection: ChangeDetectionStrategy.OnPush, template: "<select [multiple]=\"multiple\" [name]=\"name\" style=\"display: none\" tabindex=\"-1\" [id]=\"id\" [disabled]=\"disabled\">\r\n <option\r\n *ngFor=\"let option of options\"\r\n [label]=\"option.label\"\r\n [selected]=\"option.selected\"\r\n [value]=\"option.value\"\r\n [disabled]=\"disabled\"\r\n tabindex=\"-1\"\r\n ></option>\r\n</select>\r\n\r\n", styles: [":host{display:none}\n"] }]
4615
+ args: [{ selector: 'c-multi-select-native-select', changeDetection: ChangeDetectionStrategy.OnPush, template: "<select [multiple]=\"multiple\" [name]=\"name\" style=\"display: none\" tabindex=\"-1\" [id]=\"id\" [disabled]=\"disabled\">\n <option\n *ngFor=\"let option of options\"\n [label]=\"option.label\"\n [attr.selected]=\"option.selected ? '' : null\"\n [value]=\"option.value\"\n [disabled]=\"disabled\"\n tabindex=\"-1\"\n ></option>\n</select>\n\n", styles: [":host{display:none}\n"] }]
4583
4616
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { form: [{
4584
4617
  type: Input
4585
4618
  }], id: [{
@@ -4594,20 +4627,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4594
4627
  type: Input
4595
4628
  }] } });
4596
4629
 
4597
- // const flattenArray = (options: IOption[]): IOption[] => {
4598
- // return options.reduce((acc: IOption[], val: IOption) => {
4599
- // return acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val);
4600
- // }, []);
4601
- // };
4602
- //
4603
- // const getSelectedOptions = (options: IOption[]) => {
4604
- // return flattenArray(options).filter((option: IOption) => {
4605
- // if (option.selected) {
4606
- // return option;
4607
- // }
4608
- // return;
4609
- // });
4610
- // };
4611
4630
  class MultiSelectComponent {
4612
4631
  constructor(elementRef, renderer, ngZone, changeDetectorRef, viewContainerRef, focusMonitor, multiSelectService
4613
4632
  // private listenersService: ListenersService
@@ -4635,6 +4654,7 @@ class MultiSelectComponent {
4635
4654
  this.selectAllLabel = 'Select all options';
4636
4655
  this.selectionType = 'tags';
4637
4656
  this.selectionTypeCounterText = 'item(s) selected';
4657
+ this.selectionTypeCounterTextPluralMap = { '=1': 'item selected', 'other': 'items selected' };
4638
4658
  this._value = [''];
4639
4659
  this.valueChange = new EventEmitter();
4640
4660
  this._visible = false;
@@ -4643,14 +4663,12 @@ class MultiSelectComponent {
4643
4663
  this._selectedOptions = [];
4644
4664
  this._tabIndex = '-1';
4645
4665
  this.visibleOptions = 0;
4646
- this._inputValue = '';
4666
+ this._searchValue = '';
4647
4667
  this._subtreeFocused = this.focusOrigin(null);
4648
4668
  }
4649
4669
  writeValue(value) {
4650
- // console.log('writeValue', value)
4651
4670
  if (value !== null) {
4652
4671
  this.value = value;
4653
- // this.onChange(this.value);
4654
4672
  }
4655
4673
  }
4656
4674
  registerOnChange(fn) {
@@ -4676,7 +4694,6 @@ class MultiSelectComponent {
4676
4694
  set value(value) {
4677
4695
  const newValue = Array.isArray(value) ? [...value] : [value ?? ''];
4678
4696
  if (this._value.toString() !== newValue.toString()) {
4679
- // console.log('set value', value)
4680
4697
  this._value = newValue;
4681
4698
  this.onChange(newValue);
4682
4699
  this.updateNativeSelect();
@@ -4691,11 +4708,19 @@ class MultiSelectComponent {
4691
4708
  if (newValue !== this._visible) {
4692
4709
  this._visible = newValue;
4693
4710
  this.multiSelectService.toggleVisible(newValue);
4711
+ if (newValue) {
4712
+ this.listKeyManager.setFirstItemActive();
4713
+ }
4694
4714
  }
4695
4715
  }
4696
4716
  get visible() {
4697
4717
  return this._visible;
4698
4718
  }
4719
+ set selectedOptions(value) {
4720
+ this._selectedOptions = value;
4721
+ this.value = this.selectedOptions.map(item => item.value);
4722
+ this.inputElementSize();
4723
+ }
4699
4724
  get selectedOptions() {
4700
4725
  return this._selectedOptions;
4701
4726
  }
@@ -4705,6 +4730,10 @@ class MultiSelectComponent {
4705
4730
  get counterText() {
4706
4731
  return `${this.selectedOptions.length} ${this.selectionTypeCounterText}`;
4707
4732
  }
4733
+ get counterTextType() {
4734
+ return typeof this.selectionTypeCounterTextPluralMap ?? typeof this.selectionTypeCounterText;
4735
+ }
4736
+ ;
4708
4737
  get hostClasses() {
4709
4738
  return {
4710
4739
  'form-multi-select': true,
@@ -4718,52 +4747,53 @@ class MultiSelectComponent {
4718
4747
  }
4719
4748
  set tabIndex(value) {
4720
4749
  setTimeout(() => {
4721
- this._tabIndex = this._disabled || this.search ? '-1' : value === null ? null : '0';
4750
+ this._tabIndex = this.disabled || this.search ? '-1' : value === null ? null : '0';
4722
4751
  });
4723
4752
  }
4724
4753
  onKeyUp($event) {
4725
- // console.log('keyup', $event.key);
4726
- if (!this.disabled) {
4727
- if ($event.key === 'Escape') {
4728
- this.visible = false;
4729
- this.inputValue = '';
4754
+ if (this.disabled)
4755
+ return;
4756
+ if ($event.key === 'Escape') {
4757
+ this.visible = false;
4758
+ this.searchValue = '';
4759
+ this.setFocus();
4760
+ return;
4761
+ }
4762
+ if (['Enter', ' ', 'ArrowDown'].includes($event.key) && [this.inputElement?.nativeElement ?? this.elementRef.nativeElement].includes($event.target)) {
4763
+ this.visible = true;
4764
+ if (!this.search) {
4730
4765
  this.setFocus();
4731
- // this.focusMonitor.focusVia(this.inputElement ?? this.elementRef, 'keyboard');
4732
- }
4733
- else if ($event.key === 'Enter') {
4734
- // } else {
4735
- this.visible = true;
4736
- if (!this.search) {
4737
- this.setFocus();
4738
- }
4739
4766
  }
4767
+ return;
4740
4768
  }
4741
- }
4742
- manage($event) {
4743
- // console.log('keydown', $event.key);
4744
- if (!this.disabled) {
4745
- if ($event.key === 'Enter' && $event.target === this.inputElement.nativeElement) {
4746
- $event.preventDefault();
4769
+ if ($event.key === 'Tab' && $event.target === this.elementRef.nativeElement) {
4770
+ this.visible = true;
4771
+ if (!this.search) {
4772
+ this.setFocus();
4747
4773
  }
4748
- this.listKeyManager.onKeydown($event);
4774
+ return;
4749
4775
  }
4750
4776
  }
4777
+ onKeyDown($event) {
4778
+ if (this.disabled)
4779
+ return;
4780
+ this.listKeyManager.onKeydown($event);
4781
+ }
4751
4782
  onClick($event) {
4752
- if (!this.disabled) {
4753
- if (!this.visible) {
4754
- this.visible = !this.visible;
4755
- }
4756
- this.setFocus();
4783
+ if (this.disabled)
4784
+ return;
4785
+ if (!this.visible) {
4786
+ this.visible = true;
4757
4787
  }
4758
4788
  }
4759
- set inputValue(value) {
4760
- // console.log('inputValue', value);
4761
- this._inputValue = value;
4762
- // this.visible = !!value ?? this.visible;
4763
- this.filterOptions(value);
4789
+ set searchValue(value) {
4790
+ this._searchValue = value.trim();
4791
+ this.visible = !!this.searchValue.length || this.visible;
4792
+ this.filterOptions(this.searchValue);
4793
+ this.inputElementSize();
4764
4794
  }
4765
- get inputValue() {
4766
- return this._inputValue;
4795
+ get searchValue() {
4796
+ return this._searchValue;
4767
4797
  }
4768
4798
  get subtreeFocused() {
4769
4799
  return this._subtreeFocused;
@@ -4774,7 +4804,7 @@ class MultiSelectComponent {
4774
4804
  }
4775
4805
  focusOrigin(origin) {
4776
4806
  const focused = !!origin;
4777
- this.inputValue = focused ? this.inputValue : '';
4807
+ this.searchValue = focused ? this.searchValue : '';
4778
4808
  return focused;
4779
4809
  }
4780
4810
  ngOnInit() {
@@ -4792,13 +4822,11 @@ class MultiSelectComponent {
4792
4822
  option.optionsStyle = this.optionsStyle;
4793
4823
  option.selected = option.value !== undefined ? this.value.includes(option.value) || option.selected : option.selected;
4794
4824
  });
4795
- this._selectedOptions = this.multiSelectOptions.filter((option) => !!option.selected);
4796
- setTimeout(() => {
4797
- this.value = this._selectedOptions.map(item => item.value);
4798
- });
4799
- // this.value = this._selectedOptions.map(item => item.value);
4800
- this.listKeyManager = new FocusKeyManager(this.multiSelectOptions).withHomeAndEnd();
4801
- this.listKeyManager.skipPredicate(item => !item.visible);
4825
+ this.selectedOptionsUpdate();
4826
+ this.inputElementSize();
4827
+ this.listKeyManager = new FocusKeyManager(this.multiSelectOptions).withHomeAndEnd().withTypeAhead();
4828
+ this.listKeyManager.skipPredicate(item => (!item.visible || item.disabled));
4829
+ this.listKeyManager.setFirstItemActive();
4802
4830
  this.multiselectSubscribe();
4803
4831
  this.createNativeSelect();
4804
4832
  }
@@ -4810,11 +4838,8 @@ class MultiSelectComponent {
4810
4838
  this.changeDetectorRef.markForCheck();
4811
4839
  }
4812
4840
  }));
4841
+ this.inputElementSize();
4813
4842
  }
4814
- // handleInputClick($event: MouseEvent) {
4815
- // console.log('handleInputClick', $event);
4816
- // // this.visible = !this.visible;
4817
- // }
4818
4843
  multiselectSubscribe(subscribe = true) {
4819
4844
  if (subscribe) {
4820
4845
  this.multiselectVisibleSubscription = this.multiSelectService.multiSelectVisible$.subscribe((visible) => {
@@ -4823,17 +4848,14 @@ class MultiSelectComponent {
4823
4848
  });
4824
4849
  this.multiselectStateSubscription = this.multiSelectService.multiSelectState$.subscribe((option) => {
4825
4850
  if (option.selected === true && !this.multiple) {
4826
- const selectedOptions = this.multiSelectOptions
4827
- .toArray()
4828
- .filter((item) => item.selected);
4851
+ const selectedOptions = this.multiSelectOptions.toArray().filter((item) => item.selected);
4829
4852
  selectedOptions.reverse().forEach((item) => {
4830
4853
  if (item !== option) {
4831
4854
  item.selected = false;
4832
4855
  }
4833
4856
  });
4834
4857
  }
4835
- this._selectedOptions = this.multiSelectOptions.filter((option) => !!option.selected);
4836
- this.value = this._selectedOptions.map(item => item.value);
4858
+ this.selectedOptionsUpdate();
4837
4859
  });
4838
4860
  }
4839
4861
  else {
@@ -4843,7 +4865,7 @@ class MultiSelectComponent {
4843
4865
  }
4844
4866
  }
4845
4867
  clearAllOptions($event) {
4846
- this._selectedOptions.forEach((option) => {
4868
+ this.selectedOptions.forEach((option) => {
4847
4869
  if (!option._disabled)
4848
4870
  option.selected = false;
4849
4871
  });
@@ -4885,26 +4907,30 @@ class MultiSelectComponent {
4885
4907
  // };
4886
4908
  // this.listenersService.setListeners(configForHost);
4887
4909
  // }
4888
- clearListeners() {
4889
- // this.listenersService.clearListeners();
4890
- }
4910
+ // private clearListeners() {
4911
+ // this.listenersService.clearListeners();
4912
+ // }
4891
4913
  handleTagRemove($event) {
4892
4914
  this.setFocus();
4893
4915
  }
4894
4916
  setFocus() {
4895
- const firstSelectedOption = this.selectedOptions.find((item) => item.selected) ??
4896
- this.multiSelectOptions.find((item, index) => index === 0);
4897
- if (firstSelectedOption && this.isDropdownVisible) {
4898
- this.listKeyManager.setActiveItem(firstSelectedOption);
4899
- this.changeDetectorRef.markForCheck();
4900
- if (!this.search) {
4901
- return;
4902
- }
4903
- }
4904
- if (!this.disabled) {
4905
- this.focusMonitor.focusVia(this.inputElement ?? this.elementRef, 'program');
4906
- }
4907
- }
4917
+ if (this.disabled)
4918
+ return;
4919
+ this.focusMonitor.focusVia(this.inputElement ?? this.elementRef, 'program');
4920
+ }
4921
+ // setFirstSelectedOptionActive() {
4922
+ // const firstSelectedOption = this.selectedOptions.find((item) => item.selected) ??
4923
+ // this.multiSelectOptions.find((item, index) => index === 0);
4924
+ // if (firstSelectedOption && this.isDropdownVisible) {
4925
+ // // this.listKeyManager.setFocusOrigin('keyboard');
4926
+ // this.listKeyManager.setActiveItem(firstSelectedOption);
4927
+ // this.changeDetectorRef.markForCheck();
4928
+ // } else {
4929
+ // // this.listKeyManager.setFocusOrigin('keyboard');
4930
+ // this.listKeyManager.setFirstItemActive();
4931
+ // this.changeDetectorRef.markForCheck();
4932
+ // }
4933
+ // }
4908
4934
  filterOptions(value) {
4909
4935
  const searchString = value.toLowerCase() ?? '';
4910
4936
  this.multiSelectOptions?.forEach((item, index) => {
@@ -4919,8 +4945,7 @@ class MultiSelectComponent {
4919
4945
  }
4920
4946
  createNativeSelect() {
4921
4947
  this.viewContainerRef.clear();
4922
- const nativeSelectRef = this.viewContainerRef.createComponent(MultiSelectNativeSelectComponent);
4923
- this.nativeSelectRef = nativeSelectRef;
4948
+ this.nativeSelectRef = this.viewContainerRef.createComponent(MultiSelectNativeSelectComponent);
4924
4949
  this.updateNativeSelect();
4925
4950
  }
4926
4951
  updateNativeSelect() {
@@ -4930,17 +4955,46 @@ class MultiSelectComponent {
4930
4955
  const { selected, value, label } = item;
4931
4956
  return { selected, value, label };
4932
4957
  });
4933
- // const nativeSelectRef = this.nativeSelectRef;
4934
4958
  this.nativeSelectRef.instance.multiple = this.multiple;
4935
4959
  this.nativeSelectRef.instance.name = this.nativeName;
4936
4960
  this.nativeSelectRef.instance.form = this.nativeId;
4937
- this.nativeSelectRef.instance.options = options;
4961
+ this.nativeSelectRef.instance.options = [...options];
4938
4962
  this.nativeSelectRef.instance.disabled = this.disabled;
4939
4963
  this.nativeSelectRef.instance.changeDetectorRef.detectChanges();
4940
4964
  }
4965
+ inputElementSize() {
4966
+ if (this.inputElement) {
4967
+ if (this.selectedOptions.length > 0 || this.selectionType === 'counter') {
4968
+ this.renderer.setAttribute(this.inputElement.nativeElement, 'size', (this.searchValue.length + 2).toString());
4969
+ }
4970
+ else {
4971
+ this.renderer.removeAttribute(this.inputElement.nativeElement, 'size');
4972
+ }
4973
+ }
4974
+ }
4975
+ handleSearchKeyDown($event) {
4976
+ if (this.searchValue.length || this.selectedOptions.length === 0)
4977
+ return;
4978
+ if (['Backspace', 'Delete'].includes($event.key)) {
4979
+ $event.stopPropagation();
4980
+ const last = this.selectedOptions.filter(option => !option.disabled).pop();
4981
+ this.selectOption(last, false);
4982
+ }
4983
+ }
4984
+ selectOption(option, selected) {
4985
+ this.multiSelectOptions.forEach(item => {
4986
+ if (item === option) {
4987
+ option.selected = selected;
4988
+ }
4989
+ });
4990
+ this.selectedOptionsUpdate();
4991
+ }
4992
+ selectedOptionsUpdate() {
4993
+ this.selectedOptions = this.multiSelectOptions.filter((option) => !!option.selected);
4994
+ }
4941
4995
  }
4942
4996
  MultiSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: i0.ViewContainerRef }, { token: i1$1.FocusMonitor }, { token: MultiSelectService }], target: i0.ɵɵFactoryTarget.Component });
4943
- MultiSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectComponent, selector: "c-multi-select", inputs: { cleaner: "cleaner", disabled: "disabled", multiple: "multiple", nativeName: "nativeName", nativeId: "nativeId", optionsMaxHeight: "optionsMaxHeight", optionsStyle: "optionsStyle", placeholder: "placeholder", search: "search", searchNoResultsLabel: "searchNoResultsLabel", selectAll: "selectAll", selectAllLabel: "selectAllLabel", selectionType: "selectionType", selectionTypeCounterText: "selectionTypeCounterText", value: "value", visible: "visible" }, outputs: { valueChange: "valueChange", visibleChange: "visibleChange" }, host: { listeners: { "keyup": "onKeyUp($event)", "keydown": "manage($event)", "click": "onClick($event)" }, properties: { "class": "this.hostClasses", "attr.tabindex": "this.tabIndex" } }, providers: [
4997
+ MultiSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: MultiSelectComponent, selector: "c-multi-select", inputs: { cleaner: "cleaner", disabled: "disabled", multiple: "multiple", nativeName: "nativeName", nativeId: "nativeId", optionsMaxHeight: "optionsMaxHeight", optionsStyle: "optionsStyle", placeholder: "placeholder", search: "search", searchNoResultsLabel: "searchNoResultsLabel", selectAll: "selectAll", selectAllLabel: "selectAllLabel", selectionType: "selectionType", selectionTypeCounterText: "selectionTypeCounterText", selectionTypeCounterTextPluralMap: "selectionTypeCounterTextPluralMap", value: "value", visible: "visible" }, outputs: { valueChange: "valueChange", visibleChange: "visibleChange" }, host: { listeners: { "keyup": "onKeyUp($event)", "keydown": "onKeyDown($event)", "click": "onClick($event)" }, properties: { "class": "this.hostClasses", "attr.tabindex": "this.tabIndex" } }, providers: [
4944
4998
  MultiSelectService,
4945
4999
  // ListenersService,
4946
5000
  {
@@ -4948,7 +5002,7 @@ MultiSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", v
4948
5002
  useExisting: forwardRef(() => MultiSelectComponent),
4949
5003
  multi: true
4950
5004
  }
4951
- ], queries: [{ propertyName: "multiSelectOptions", predicate: MultiSelectOptionComponent, descendants: true }], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true }, { propertyName: "dropdownElement", first: true, predicate: ["dropdownElement"], descendants: true }], exportAs: ["cMultiSelect"], ngImport: i0, template: "<div class=\"form-multi-select-selection\">\r\n <ng-template [ngIf]=\"selectionType==='tags'\">\r\n <c-multi-select-tag (remove)=\"handleTagRemove($event)\" *ngFor=\"let option of selectedOptions; index as i\"\r\n [option]=\"option\" tabindex=\"-1\"></c-multi-select-tag>\r\n </ng-template>\r\n <ng-template [ngIf]=\"selectionType==='text'\">\r\n <span class=\"bg-light\">{{selectedOptionsText}}</span>\r\n </ng-template>\r\n <ng-template [ngIf]=\"selectionType==='counter'\">\r\n <span>{{counterText}}</span>\r\n </ng-template>\r\n</div>\r\n\r\n<input #inputElement\r\n [(ngModel)]=\"inputValue\"\r\n [disabled]=\"disabled || !search\"\r\n [placeholder]=\"(selectedOptions.length === 0 && selectionType!=='counter') ? placeholder : ''\"\r\n autocomplete=\"off\"\r\n [ngClass]=\"{'form-multi-select-search ms-1': true, disabled: disabled}\" tabindex=\"{{disabled ? '-1' : '0'}}\"\r\n type=\"text\">\r\n\r\n<button (click)=\"clearAllOptions($event)\"\r\n *ngIf=\"cleaner && selectedOptions.length > 0\"\r\n [disabled]=\"disabled || !isDropdownVisible\"\r\n aria-label=\"Clear all\"\r\n cButtonClose\r\n class=\"form-multi-select-selection-cleaner\"\r\n size=\"sm\">\r\n</button>\r\n\r\n<div #dropdownElement class=\"form-multi-select-dropdown\">\r\n <ng-template [ngIf]=\"visibleOptions>0\" [ngIfElse]=\"optionsEmpty\">\r\n <button (click)=\"selectAllOptions()\"\r\n *ngIf=\"selectAll && multiple\"\r\n class=\"form-multi-select-all\">\r\n {{selectAllLabel}}\r\n </button>\r\n <div #multiselectOptionsDiv\r\n [ngStyle]=\"optionsMaxHeight !== 'auto' ? { 'maxHeight.px': optionsMaxHeight, 'overflow': 'scroll'} : {}\"\r\n class=\"form-multi-select-options\">\r\n <ng-content></ng-content>\r\n </div>\r\n </ng-template>\r\n <ng-template #optionsEmpty>\r\n <div class=\"form-multi-select-options-empty\">{{searchNoResultsLabel}}</div>\r\n </ng-template>\r\n</div>\r\n\r\n", styles: [":host{display:block}:host.cdk-focused:not(.disabled){color:var(--cui-form-multi-select-focus-color, rgba(44, 56, 74, .95));background-color:var(--cui-form-multi-select-focus-bg, #fff);border-color:var(--cui-form-multi-select-focus-border-color, #6557e4);box-shadow:0 0 0 .25rem #321fdb40}:host .form-multi-select-search:disabled,:host .form-multi-select-search.disabled{background-color:var(--cui-input-disabled-bg, #d8dbe0);border-color:var(--cui-input-disabled-border-color, #b1b7c1);opacity:1}\n"], components: [{ type: MultiSelectTagComponent, selector: "c-multi-select-tag", inputs: ["option"], outputs: ["remove"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: ButtonCloseDirective, selector: "[cButtonClose]", inputs: ["white"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
5005
+ ], queries: [{ propertyName: "multiSelectOptions", predicate: MultiSelectOptionComponent, descendants: true }], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true }, { propertyName: "dropdownElement", first: true, predicate: ["dropdownElement"], descendants: true }], exportAs: ["cMultiSelect"], ngImport: i0, template: "<div class=\"form-multi-select-selection\">\n <ng-template [ngIf]=\"selectionType === 'tags'\">\n <c-multi-select-tag *ngFor=\"let option of selectedOptions; index as i\"\n (remove)=\"handleTagRemove($event)\"\n [option]=\"option\"\n tabindex=\"-1\">\n </c-multi-select-tag>\n </ng-template>\n <ng-template [ngIf]=\"selectionType === 'text' && !!selectedOptionsText\">\n <span>{{ selectedOptionsText }}</span>\n </ng-template>\n <ng-template [ngIf]=\"selectionType === 'counter'\">\n <span *ngIf=\"counterTextType === 'string'; else pluralMap\">{{ counterText }}</span>\n <ng-template #pluralMap>\n <span>{{selectedOptions.length}} {{ selectedOptions.length | i18nPlural: selectionTypeCounterTextPluralMap ?? { other: counterText } }}</span>\n </ng-template>\n </ng-template>\n <ng-template [ngIf]=\"!search && selectedOptions.length === 0 && selectionType !== 'counter'\">\n <span>{{ placeholder }}</span>\n </ng-template>\n</div>\n\n<input\n #inputElement\n (keydown)=\"handleSearchKeyDown($event)\"\n *ngIf=\"search && !disabled\"\n [(ngModel)]=\"searchValue\"\n [disabled]=\"disabled || !search\"\n [ngClass]=\"{ 'form-multi-select-search': true, disabled: disabled }\"\n [placeholder]=\"selectedOptions.length === 0 && selectionType !== 'counter' ? placeholder : ''\"\n autocomplete=\"off\"\n tabindex=\"{{ disabled ? '-1' : '0' }}\"\n type=\"text\"\n>\n\n<button\n (click)=\"clearAllOptions($event)\"\n *ngIf=\"cleaner && selectedOptions.length > 0 && !disabled\"\n [disabled]=\"disabled || !isDropdownVisible\"\n aria-label=\"Clear all\"\n cButtonClose\n class=\"form-multi-select-selection-cleaner\"\n size=\"sm\"\n></button>\n\n<div #dropdownElement *ngIf=\"!disabled\" class=\"form-multi-select-dropdown\">\n <ng-template [ngIfElse]=\"optionsEmpty\" [ngIf]=\"visibleOptions > 0\">\n <button (click)=\"selectAllOptions()\" *ngIf=\"selectAll && multiple\" class=\"form-multi-select-all\">\n {{ selectAllLabel }}\n </button>\n <div #multiselectOptionsDiv\n [ngStyle]=\"optionsMaxHeight !== 'auto' ? { 'maxHeight.px': optionsMaxHeight, overflow: 'scroll' } : {}\"\n class=\"form-multi-select-options\"\n >\n <ng-content></ng-content>\n </div>\n </ng-template>\n <ng-template #optionsEmpty>\n <div class=\"form-multi-select-options-empty\">{{ searchNoResultsLabel }}</div>\n </ng-template>\n</div>\n", styles: [":host{display:block}:host.cdk-focused:not(.disabled){color:var(--cui-form-multi-select-focus-color, rgba(44, 56, 74, .95));background-color:var(--cui-form-multi-select-focus-bg, #fff);border-color:var(--cui-form-multi-select-focus-border-color, #6557e4);box-shadow:0 0 0 .25rem #321fdb40}:host .form-multi-select-search:disabled,:host .form-multi-select-search.disabled{background-color:var(--cui-input-disabled-bg, #d8dbe0);border-color:var(--cui-input-disabled-border-color, #b1b7c1);opacity:1}:host .form-multi-select-search[size]{display:inline}\n"], components: [{ type: MultiSelectTagComponent, selector: "c-multi-select-tag", inputs: ["option"], outputs: ["remove"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: ButtonCloseDirective, selector: "[cButtonClose]", inputs: ["white"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], pipes: { "i18nPlural": i2.I18nPluralPipe } });
4952
5006
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: MultiSelectComponent, decorators: [{
4953
5007
  type: Component,
4954
5008
  args: [{ selector: 'c-multi-select', exportAs: 'cMultiSelect', providers: [
@@ -4959,7 +5013,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4959
5013
  useExisting: forwardRef(() => MultiSelectComponent),
4960
5014
  multi: true
4961
5015
  }
4962
- ], template: "<div class=\"form-multi-select-selection\">\r\n <ng-template [ngIf]=\"selectionType==='tags'\">\r\n <c-multi-select-tag (remove)=\"handleTagRemove($event)\" *ngFor=\"let option of selectedOptions; index as i\"\r\n [option]=\"option\" tabindex=\"-1\"></c-multi-select-tag>\r\n </ng-template>\r\n <ng-template [ngIf]=\"selectionType==='text'\">\r\n <span class=\"bg-light\">{{selectedOptionsText}}</span>\r\n </ng-template>\r\n <ng-template [ngIf]=\"selectionType==='counter'\">\r\n <span>{{counterText}}</span>\r\n </ng-template>\r\n</div>\r\n\r\n<input #inputElement\r\n [(ngModel)]=\"inputValue\"\r\n [disabled]=\"disabled || !search\"\r\n [placeholder]=\"(selectedOptions.length === 0 && selectionType!=='counter') ? placeholder : ''\"\r\n autocomplete=\"off\"\r\n [ngClass]=\"{'form-multi-select-search ms-1': true, disabled: disabled}\" tabindex=\"{{disabled ? '-1' : '0'}}\"\r\n type=\"text\">\r\n\r\n<button (click)=\"clearAllOptions($event)\"\r\n *ngIf=\"cleaner && selectedOptions.length > 0\"\r\n [disabled]=\"disabled || !isDropdownVisible\"\r\n aria-label=\"Clear all\"\r\n cButtonClose\r\n class=\"form-multi-select-selection-cleaner\"\r\n size=\"sm\">\r\n</button>\r\n\r\n<div #dropdownElement class=\"form-multi-select-dropdown\">\r\n <ng-template [ngIf]=\"visibleOptions>0\" [ngIfElse]=\"optionsEmpty\">\r\n <button (click)=\"selectAllOptions()\"\r\n *ngIf=\"selectAll && multiple\"\r\n class=\"form-multi-select-all\">\r\n {{selectAllLabel}}\r\n </button>\r\n <div #multiselectOptionsDiv\r\n [ngStyle]=\"optionsMaxHeight !== 'auto' ? { 'maxHeight.px': optionsMaxHeight, 'overflow': 'scroll'} : {}\"\r\n class=\"form-multi-select-options\">\r\n <ng-content></ng-content>\r\n </div>\r\n </ng-template>\r\n <ng-template #optionsEmpty>\r\n <div class=\"form-multi-select-options-empty\">{{searchNoResultsLabel}}</div>\r\n </ng-template>\r\n</div>\r\n\r\n", styles: [":host{display:block}:host.cdk-focused:not(.disabled){color:var(--cui-form-multi-select-focus-color, rgba(44, 56, 74, .95));background-color:var(--cui-form-multi-select-focus-bg, #fff);border-color:var(--cui-form-multi-select-focus-border-color, #6557e4);box-shadow:0 0 0 .25rem #321fdb40}:host .form-multi-select-search:disabled,:host .form-multi-select-search.disabled{background-color:var(--cui-input-disabled-bg, #d8dbe0);border-color:var(--cui-input-disabled-border-color, #b1b7c1);opacity:1}\n"] }]
5016
+ ], template: "<div class=\"form-multi-select-selection\">\n <ng-template [ngIf]=\"selectionType === 'tags'\">\n <c-multi-select-tag *ngFor=\"let option of selectedOptions; index as i\"\n (remove)=\"handleTagRemove($event)\"\n [option]=\"option\"\n tabindex=\"-1\">\n </c-multi-select-tag>\n </ng-template>\n <ng-template [ngIf]=\"selectionType === 'text' && !!selectedOptionsText\">\n <span>{{ selectedOptionsText }}</span>\n </ng-template>\n <ng-template [ngIf]=\"selectionType === 'counter'\">\n <span *ngIf=\"counterTextType === 'string'; else pluralMap\">{{ counterText }}</span>\n <ng-template #pluralMap>\n <span>{{selectedOptions.length}} {{ selectedOptions.length | i18nPlural: selectionTypeCounterTextPluralMap ?? { other: counterText } }}</span>\n </ng-template>\n </ng-template>\n <ng-template [ngIf]=\"!search && selectedOptions.length === 0 && selectionType !== 'counter'\">\n <span>{{ placeholder }}</span>\n </ng-template>\n</div>\n\n<input\n #inputElement\n (keydown)=\"handleSearchKeyDown($event)\"\n *ngIf=\"search && !disabled\"\n [(ngModel)]=\"searchValue\"\n [disabled]=\"disabled || !search\"\n [ngClass]=\"{ 'form-multi-select-search': true, disabled: disabled }\"\n [placeholder]=\"selectedOptions.length === 0 && selectionType !== 'counter' ? placeholder : ''\"\n autocomplete=\"off\"\n tabindex=\"{{ disabled ? '-1' : '0' }}\"\n type=\"text\"\n>\n\n<button\n (click)=\"clearAllOptions($event)\"\n *ngIf=\"cleaner && selectedOptions.length > 0 && !disabled\"\n [disabled]=\"disabled || !isDropdownVisible\"\n aria-label=\"Clear all\"\n cButtonClose\n class=\"form-multi-select-selection-cleaner\"\n size=\"sm\"\n></button>\n\n<div #dropdownElement *ngIf=\"!disabled\" class=\"form-multi-select-dropdown\">\n <ng-template [ngIfElse]=\"optionsEmpty\" [ngIf]=\"visibleOptions > 0\">\n <button (click)=\"selectAllOptions()\" *ngIf=\"selectAll && multiple\" class=\"form-multi-select-all\">\n {{ selectAllLabel }}\n </button>\n <div #multiselectOptionsDiv\n [ngStyle]=\"optionsMaxHeight !== 'auto' ? { 'maxHeight.px': optionsMaxHeight, overflow: 'scroll' } : {}\"\n class=\"form-multi-select-options\"\n >\n <ng-content></ng-content>\n </div>\n </ng-template>\n <ng-template #optionsEmpty>\n <div class=\"form-multi-select-options-empty\">{{ searchNoResultsLabel }}</div>\n </ng-template>\n</div>\n", styles: [":host{display:block}:host.cdk-focused:not(.disabled){color:var(--cui-form-multi-select-focus-color, rgba(44, 56, 74, .95));background-color:var(--cui-form-multi-select-focus-bg, #fff);border-color:var(--cui-form-multi-select-focus-border-color, #6557e4);box-shadow:0 0 0 .25rem #321fdb40}:host .form-multi-select-search:disabled,:host .form-multi-select-search.disabled{background-color:var(--cui-input-disabled-bg, #d8dbe0);border-color:var(--cui-input-disabled-border-color, #b1b7c1);opacity:1}:host .form-multi-select-search[size]{display:inline}\n"] }]
4963
5017
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i0.ViewContainerRef }, { type: i1$1.FocusMonitor }, { type: MultiSelectService }]; }, propDecorators: { cleaner: [{
4964
5018
  type: Input
4965
5019
  }], disabled: [{
@@ -4988,6 +5042,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
4988
5042
  type: Input
4989
5043
  }], selectionTypeCounterText: [{
4990
5044
  type: Input
5045
+ }], selectionTypeCounterTextPluralMap: [{
5046
+ type: Input
4991
5047
  }], value: [{
4992
5048
  type: Input
4993
5049
  }], valueChange: [{
@@ -5014,7 +5070,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
5014
5070
  }], onKeyUp: [{
5015
5071
  type: HostListener,
5016
5072
  args: ['keyup', ['$event']]
5017
- }], manage: [{
5073
+ }], onKeyDown: [{
5018
5074
  type: HostListener,
5019
5075
  args: ['keydown', ['$event']]
5020
5076
  }], onClick: [{