@smallpearl/ngx-helper 0.29.25 → 0.29.29

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.
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
2
2
  import { InjectionToken, input, EventEmitter, computed, Component, ChangeDetectionStrategy, Optional, Inject, Self, ViewChild, Input, Output, HostBinding } from '@angular/core';
3
3
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
4
4
  import * as i3 from '@angular/common';
5
- import { CommonModule } from '@angular/common';
5
+ import { CommonModule, NgTemplateOutlet } from '@angular/common';
6
6
  import * as i1 from '@angular/common/http';
7
7
  import { HttpContextToken, HttpParams, HttpContext } from '@angular/common/http';
8
8
  import * as i2 from '@angular/forms';
@@ -155,6 +155,25 @@ class SPMatSelectEntityComponent {
155
155
  searchText;
156
156
  notFoundText;
157
157
  addItemText;
158
+ /**
159
+ * Template for the option label. If not provided, the default label
160
+ * function will be used. Option label is what is placed inside the
161
+ * <mat-option> tag. The template gets an implicit 'entity' variable
162
+ * in the context, value for which is the entity object.
163
+ *
164
+ * For example:
165
+ * ```
166
+ * <sp-mat-select-entity
167
+ * [url]="'/api/v1/customers/'"
168
+ * [entityLabelFn]="entity => entity.name"
169
+ * [optionLabelTemplate]="optionLabelTemplate"
170
+ * ></sp-mat-select-entity>
171
+ * <ng-template #optionLabelTemplate let-entity>
172
+ * {{ entity.name }} - {{ entity.description }}
173
+ * </ng-template>
174
+ * ```
175
+ */
176
+ optionLabelTemplate = input();
158
177
  _sideloadDataKey = computed(() => {
159
178
  if (this.sideloadDataKey()) {
160
179
  return this.sideloadDataKey();
@@ -249,7 +268,7 @@ class SPMatSelectEntityComponent {
249
268
  this.notFoundText = config.i18n.notFound;
250
269
  }
251
270
  if (!this.addItemText) {
252
- this.addItemText = config.i18n.addItem.replace(/\{\{\s*item\s*}}/, this.entityName ?? "**Item");
271
+ this.addItemText = config.i18n.addItem.replace(/\{\{\s*item\s*}}/, this.entityName ?? '**Item');
253
272
  }
254
273
  }
255
274
  addEntity(entity) {
@@ -260,14 +279,18 @@ class SPMatSelectEntityComponent {
260
279
  }
261
280
  get selectTriggerValue() {
262
281
  if (this.selectValue) {
263
- const firstSelected = Array.isArray(this.selectValue) ? this.selectValue[0] : this.selectValue;
282
+ const firstSelected = Array.isArray(this.selectValue)
283
+ ? this.selectValue[0]
284
+ : this.selectValue;
264
285
  const selectedEntity = this._entities.get(firstSelected);
265
286
  return selectedEntity ? this.entityLabelFn(selectedEntity) : '';
266
287
  }
267
288
  return '';
268
289
  }
269
290
  get selectTriggerValueAsArray() {
270
- return Array.isArray(this.selectValue) ? this.selectValue : [];
291
+ return Array.isArray(this.selectValue)
292
+ ? this.selectValue
293
+ : [];
271
294
  }
272
295
  entityId(entity) {
273
296
  return entity[this.idKey];
@@ -276,7 +299,7 @@ class SPMatSelectEntityComponent {
276
299
  if (Array.isArray(entityId)) {
277
300
  if (this.multiple) {
278
301
  const selectedValues = [];
279
- entityId.forEach(id => {
302
+ entityId.forEach((id) => {
280
303
  if (this._entities.has(id)) {
281
304
  selectedValues.push(id);
282
305
  }
@@ -307,17 +330,17 @@ class SPMatSelectEntityComponent {
307
330
  }
308
331
  set entities(items) {
309
332
  if (!this.group) {
310
- items.forEach(item => {
333
+ items.forEach((item) => {
311
334
  this._entities.set(item[this.idKey], item);
312
335
  });
313
336
  }
314
337
  else {
315
338
  this._groupedEntities = items;
316
- this._groupedEntities.forEach(group => {
339
+ this._groupedEntities.forEach((group) => {
317
340
  const key = this.groupEntitiesKey();
318
341
  const groupEntities = group[key];
319
342
  group['__items__'] = groupEntities;
320
- groupEntities.forEach(item => {
343
+ groupEntities.forEach((item) => {
321
344
  this._entities.set(item[this.idKey], item);
322
345
  });
323
346
  });
@@ -342,7 +365,8 @@ class SPMatSelectEntityComponent {
342
365
  this.stateChanges.next();
343
366
  }
344
367
  get required() {
345
- return this._required ?? this.ngControl?.control?.hasValidator(Validators.required);
368
+ return (this._required ??
369
+ this.ngControl?.control?.hasValidator(Validators.required));
346
370
  }
347
371
  set required(req) {
348
372
  this._required = coerceBooleanProperty(req);
@@ -356,7 +380,6 @@ class SPMatSelectEntityComponent {
356
380
  }
357
381
  set disabled(value) {
358
382
  const disabled = coerceBooleanProperty(value);
359
- ;
360
383
  if (disabled !== this._disabled) {
361
384
  this.setDisabledState(disabled);
362
385
  this.stateChanges.next();
@@ -421,7 +444,7 @@ class SPMatSelectEntityComponent {
421
444
  this.selectValue = ev.value;
422
445
  this.onTouched();
423
446
  this.onChanged(ev.value);
424
- const selectedEntities = ev.value.map(id => this._entities.get(id));
447
+ const selectedEntities = ev.value.map((id) => this._entities.get(id));
425
448
  this.selectionChange.emit(selectedEntities);
426
449
  }
427
450
  else {
@@ -458,7 +481,9 @@ class SPMatSelectEntityComponent {
458
481
  if (this.entityFilterFn) {
459
482
  return this.entityFilterFn(member, search);
460
483
  }
461
- return this.entityLabelFn(member).toLocaleLowerCase().includes(searchLwr);
484
+ return this.entityLabelFn(member)
485
+ .toLocaleLowerCase()
486
+ .includes(searchLwr);
462
487
  }));
463
488
  }
464
489
  }
@@ -483,15 +508,15 @@ class SPMatSelectEntityComponent {
483
508
  }
484
509
  else {
485
510
  const groupEntitiesKey = this.groupEntitiesKey();
486
- const groups = this._groupedEntities.map(ge => {
511
+ const groups = this._groupedEntities.map((ge) => {
487
512
  const label = this.groupLabel(ge);
488
513
  if (label.toLocaleLowerCase().includes(searchLwr)) {
489
514
  return { ...ge };
490
515
  }
491
516
  else {
492
- const groupEntities = ge.__items__?.filter(e => this.entityLabelFn(e).toLocaleLowerCase().includes(searchLwr));
517
+ const groupEntities = ge.__items__?.filter((e) => this.entityLabelFn(e).toLocaleLowerCase().includes(searchLwr));
493
518
  const ret = {
494
- ...ge
519
+ ...ge,
495
520
  };
496
521
  ret['__items__'] = groupEntities ?? [];
497
522
  return ret;
@@ -518,7 +543,7 @@ class SPMatSelectEntityComponent {
518
543
  let params;
519
544
  if (this.httpParams) {
520
545
  params = new HttpParams({
521
- fromString: this.httpParams.toString()
546
+ fromString: this.httpParams.toString(),
522
547
  });
523
548
  }
524
549
  else {
@@ -549,7 +574,8 @@ class SPMatSelectEntityComponent {
549
574
  Array.isArray(entities['results'])) {
550
575
  entities = entities['results'];
551
576
  }
552
- else if ( // sideloaded response, where entities are usually provided in 'entityName'
577
+ else if (
578
+ // sideloaded response, where entities are usually provided in 'entityName'
553
579
  this._sideloadDataKey() &&
554
580
  !Array.isArray(entities) &&
555
581
  typeof entities === 'object' &&
@@ -590,8 +616,11 @@ class SPMatSelectEntityComponent {
590
616
  return group[this.groupEntitiesKey()] ?? [];
591
617
  }
592
618
  groupEntitiesKey() {
593
- return this.groupOptionsKey ? this.groupOptionsKey
594
- : (this.entityName ? plural(this.entityName.toLocaleLowerCase()) : 'items');
619
+ return this.groupOptionsKey
620
+ ? this.groupOptionsKey
621
+ : this.entityName
622
+ ? plural(this.entityName.toLocaleLowerCase())
623
+ : 'items';
595
624
  }
596
625
  existsInCache() {
597
626
  const cacheKey = this.getCacheKey();
@@ -605,7 +634,7 @@ class SPMatSelectEntityComponent {
605
634
  let params;
606
635
  if (this.httpParams) {
607
636
  params = new HttpParams({
608
- fromString: this.httpParams.toString()
637
+ fromString: this.httpParams.toString(),
609
638
  });
610
639
  }
611
640
  else {
@@ -619,7 +648,8 @@ class SPMatSelectEntityComponent {
619
648
  getFromCache() {
620
649
  const cacheKey = this.getCacheKey();
621
650
  if (cacheKey && SPMatSelectEntityComponent._entitiesCache.has(cacheKey)) {
622
- return SPMatSelectEntityComponent._entitiesCache.get(cacheKey)?.entities;
651
+ return SPMatSelectEntityComponent._entitiesCache.get(cacheKey)
652
+ ?.entities;
623
653
  }
624
654
  return [];
625
655
  }
@@ -627,7 +657,10 @@ class SPMatSelectEntityComponent {
627
657
  const cacheKey = this.getCacheKey();
628
658
  if (cacheKey) {
629
659
  if (!SPMatSelectEntityComponent._entitiesCache.has(cacheKey)) {
630
- SPMatSelectEntityComponent._entitiesCache.set(cacheKey, { refCount: 0, entities });
660
+ SPMatSelectEntityComponent._entitiesCache.set(cacheKey, {
661
+ refCount: 0,
662
+ entities,
663
+ });
631
664
  }
632
665
  const cacheEntry = SPMatSelectEntityComponent._entitiesCache.get(cacheKey);
633
666
  cacheEntry.refCount += 1;
@@ -651,12 +684,14 @@ class SPMatSelectEntityComponent {
651
684
  context.set(SP_MAT_SELECT_ENTITY_HTTP_CONTEXT, {
652
685
  entityName: this.entityName ?? '',
653
686
  entityNamePlural: this.entityName ? plural(this.entityName) : '',
654
- endpoint: this.url
687
+ endpoint: this.url,
655
688
  });
656
689
  return context;
657
690
  }
658
691
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPMatSelectEntityComponent, deps: [{ token: i1.HttpClient }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Injector }, { token: MAT_FORM_FIELD, optional: true }, { token: i2.NgControl, optional: true, self: true }, { token: SP_MAT_SELECT_ENTITY_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Component });
659
- /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.6", type: SPMatSelectEntityComponent, isStandalone: true, selector: "sp-mat-select-entity", inputs: { entityLabelFn: { classPropertyName: "entityLabelFn", publicName: "entityLabelFn", isSignal: false, isRequired: true, transformFunction: null }, entityFilterFn: { classPropertyName: "entityFilterFn", publicName: "entityFilterFn", isSignal: false, isRequired: false, transformFunction: null }, idKey: { classPropertyName: "idKey", publicName: "idKey", isSignal: false, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: false, isRequired: false, transformFunction: null }, httpParams: { classPropertyName: "httpParams", publicName: "httpParams", isSignal: false, isRequired: false, transformFunction: null }, loadFromRemoteFn: { classPropertyName: "loadFromRemoteFn", publicName: "loadFromRemoteFn", isSignal: false, isRequired: false, transformFunction: null }, inlineNew: { classPropertyName: "inlineNew", publicName: "inlineNew", isSignal: false, isRequired: false, transformFunction: null }, entityName: { classPropertyName: "entityName", publicName: "entityName", isSignal: false, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: false, isRequired: false, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: false, isRequired: false, transformFunction: null }, groupOptionsKey: { classPropertyName: "groupOptionsKey", publicName: "groupOptionsKey", isSignal: false, isRequired: false, transformFunction: null }, groupLabelFn: { classPropertyName: "groupLabelFn", publicName: "groupLabelFn", isSignal: false, isRequired: false, transformFunction: null }, sideloadDataKey: { classPropertyName: "sideloadDataKey", publicName: "sideloadDataKey", isSignal: true, isRequired: false, transformFunction: null }, responseParserFn: { classPropertyName: "responseParserFn", publicName: "responseParserFn", isSignal: true, isRequired: false, transformFunction: null }, searchText: { classPropertyName: "searchText", publicName: "searchText", isSignal: false, isRequired: false, transformFunction: null }, notFoundText: { classPropertyName: "notFoundText", publicName: "notFoundText", isSignal: false, isRequired: false, transformFunction: null }, addItemText: { classPropertyName: "addItemText", publicName: "addItemText", isSignal: false, isRequired: false, transformFunction: null }, entities: { classPropertyName: "entities", publicName: "entities", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, userAriaDescribedBy: { classPropertyName: "userAriaDescribedBy", publicName: "aria-describedby", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { selectionChange: "selectionChange", createNewItemSelected: "createNewItemSelected" }, host: { properties: { "id": "this.id" } }, providers: [{ provide: MatFormFieldControl, useExisting: SPMatSelectEntityComponent }], viewQueries: [{ propertyName: "matSel", first: true, predicate: MatSelect, descendants: true }, { propertyName: "matSelect", first: true, predicate: MatSelect, descendants: true }], ngImport: i0, template: `
692
+ /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.6", type: SPMatSelectEntityComponent, isStandalone: true, selector: "sp-mat-select-entity", inputs: { entityLabelFn: { classPropertyName: "entityLabelFn", publicName: "entityLabelFn", isSignal: false, isRequired: true, transformFunction: null }, entityFilterFn: { classPropertyName: "entityFilterFn", publicName: "entityFilterFn", isSignal: false, isRequired: false, transformFunction: null }, idKey: { classPropertyName: "idKey", publicName: "idKey", isSignal: false, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: false, isRequired: false, transformFunction: null }, httpParams: { classPropertyName: "httpParams", publicName: "httpParams", isSignal: false, isRequired: false, transformFunction: null }, loadFromRemoteFn: { classPropertyName: "loadFromRemoteFn", publicName: "loadFromRemoteFn", isSignal: false, isRequired: false, transformFunction: null }, inlineNew: { classPropertyName: "inlineNew", publicName: "inlineNew", isSignal: false, isRequired: false, transformFunction: null }, entityName: { classPropertyName: "entityName", publicName: "entityName", isSignal: false, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: false, isRequired: false, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: false, isRequired: false, transformFunction: null }, groupOptionsKey: { classPropertyName: "groupOptionsKey", publicName: "groupOptionsKey", isSignal: false, isRequired: false, transformFunction: null }, groupLabelFn: { classPropertyName: "groupLabelFn", publicName: "groupLabelFn", isSignal: false, isRequired: false, transformFunction: null }, sideloadDataKey: { classPropertyName: "sideloadDataKey", publicName: "sideloadDataKey", isSignal: true, isRequired: false, transformFunction: null }, responseParserFn: { classPropertyName: "responseParserFn", publicName: "responseParserFn", isSignal: true, isRequired: false, transformFunction: null }, searchText: { classPropertyName: "searchText", publicName: "searchText", isSignal: false, isRequired: false, transformFunction: null }, notFoundText: { classPropertyName: "notFoundText", publicName: "notFoundText", isSignal: false, isRequired: false, transformFunction: null }, addItemText: { classPropertyName: "addItemText", publicName: "addItemText", isSignal: false, isRequired: false, transformFunction: null }, optionLabelTemplate: { classPropertyName: "optionLabelTemplate", publicName: "optionLabelTemplate", isSignal: true, isRequired: false, transformFunction: null }, entities: { classPropertyName: "entities", publicName: "entities", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, userAriaDescribedBy: { classPropertyName: "userAriaDescribedBy", publicName: "aria-describedby", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { selectionChange: "selectionChange", createNewItemSelected: "createNewItemSelected" }, host: { properties: { "id": "this.id" } }, providers: [
693
+ { provide: MatFormFieldControl, useExisting: SPMatSelectEntityComponent },
694
+ ], viewQueries: [{ propertyName: "matSel", first: true, predicate: MatSelect, descendants: true }, { propertyName: "matSelect", first: true, predicate: MatSelect, descendants: true }], ngImport: i0, template: `
660
695
  <mat-select
661
696
  [placeholder]="placeholder"
662
697
  (opened)="onSelectOpened($event)"
@@ -667,7 +702,9 @@ class SPMatSelectEntityComponent {
667
702
  <mat-select-trigger>
668
703
  {{ selectTriggerValue }}
669
704
  @if (selectTriggerValueAsArray.length > 1) {
670
- <span class="addl-selection-count"> (+{{ selectTriggerValueAsArray.length - 1 }}) </span>
705
+ <span class="addl-selection-count">
706
+ (+{{ selectTriggerValueAsArray.length - 1 }})
707
+ </span>
671
708
  }
672
709
  </mat-select-trigger>
673
710
 
@@ -683,31 +720,50 @@ class SPMatSelectEntityComponent {
683
720
  </mat-option>
684
721
 
685
722
  <ng-container *ngIf="!group; else groupedOptions">
686
- <span *ngIf="(filteredValues | async) as entities">
687
- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
723
+ <span *ngIf="filteredValues | async as entities">
724
+ <ng-template #defaultOptionLabelTemplate let-entity>
688
725
  {{ entityLabelFn(entity) }}
726
+ </ng-template>
727
+ @for (entity of entities; track entityId(entity)) {
728
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
729
+ <ng-container
730
+ *ngTemplateOutlet="
731
+ optionLabelTemplate() || defaultOptionLabelTemplate;
732
+ context: { $implicit: entity }
733
+ "
734
+ ></ng-container>
689
735
  </mat-option>
736
+ }
737
+
738
+ <!-- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
739
+ {{ entityLabelFn(entity) }}
740
+ </mat-option> -->
690
741
  </span>
691
742
  </ng-container>
692
743
  <ng-template #groupedOptions>
693
- <span *ngIf="(filteredGroupedValues | async) as groups">
744
+ <span *ngIf="filteredGroupedValues | async as groups">
694
745
  @for (group of groups; track groupLabel(group)) {
695
- <mat-optgroup [label]="groupLabel(group)">
696
- @for (entity of group.__items__; track entityId(entity)) {
697
- <mat-option class="sel-entity-option" [value]="entityId(entity)">
698
- {{ entityLabelFn(entity) }}
699
- </mat-option>
700
- }
701
- </mat-optgroup>
746
+ <mat-optgroup [label]="groupLabel(group)">
747
+ @for (entity of group.__items__; track entityId(entity)) {
748
+
749
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
750
+ {{ entityLabelFn(entity) }}
751
+ </mat-option>
752
+ }
753
+ </mat-optgroup>
702
754
  }
703
755
  </span>
704
756
  </ng-template>
705
757
 
706
- <mat-option *ngIf="!multiple && inlineNew" class="add-item-option" value="0" (click)="$event.stopPropagation()"
758
+ <mat-option
759
+ *ngIf="!multiple && inlineNew"
760
+ class="add-item-option"
761
+ value="0"
762
+ (click)="$event.stopPropagation()"
707
763
  >⊕ {{ addItemText }}</mat-option
708
764
  >
709
765
  </mat-select>
710
- `, isInline: true, styles: [".add-item-option{padding-top:2px;border-top:1px solid gray}.addl-selection-count{opacity:.75;font-size:.8em}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }, { 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: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i4.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i5.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i5.MatOptgroup, selector: "mat-optgroup", inputs: ["label", "disabled"], exportAs: ["matOptgroup"] }, { kind: "ngmodule", type: NgxMatSelectSearchModule }, { kind: "component", type: i6.MatSelectSearchComponent, selector: "ngx-mat-select-search", inputs: ["placeholderLabel", "type", "closeIcon", "closeSvgIcon", "noEntriesFoundLabel", "clearSearchInput", "searching", "disableInitialFocus", "enableClearOnEscapePressed", "preventHomeEndKeyPropagation", "disableScrollToActiveOnOptionsChanged", "ariaLabel", "showToggleAllCheckbox", "toggleAllCheckboxChecked", "toggleAllCheckboxIndeterminate", "toggleAllCheckboxTooltipMessage", "toggleAllCheckboxTooltipPosition", "hideClearSearchButton", "alwaysRestoreSelectedOptionsMulti", "recreateValuesArray"], outputs: ["toggleAll"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
766
+ `, isInline: true, styles: [".add-item-option{padding-top:2px;border-top:1px solid gray}.addl-selection-count{opacity:.75;font-size:.8em}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }, { 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: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i4.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i5.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i5.MatOptgroup, selector: "mat-optgroup", inputs: ["label", "disabled"], exportAs: ["matOptgroup"] }, { kind: "ngmodule", type: NgxMatSelectSearchModule }, { kind: "component", type: i6.MatSelectSearchComponent, selector: "ngx-mat-select-search", inputs: ["placeholderLabel", "type", "closeIcon", "closeSvgIcon", "noEntriesFoundLabel", "clearSearchInput", "searching", "disableInitialFocus", "enableClearOnEscapePressed", "preventHomeEndKeyPropagation", "disableScrollToActiveOnOptionsChanged", "ariaLabel", "showToggleAllCheckbox", "toggleAllCheckboxChecked", "toggleAllCheckboxIndeterminate", "toggleAllCheckboxTooltipMessage", "toggleAllCheckboxTooltipPosition", "hideClearSearchButton", "alwaysRestoreSelectedOptionsMulti", "recreateValuesArray"], outputs: ["toggleAll"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
711
767
  }
712
768
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPMatSelectEntityComponent, decorators: [{
713
769
  type: Component,
@@ -722,7 +778,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImpor
722
778
  <mat-select-trigger>
723
779
  {{ selectTriggerValue }}
724
780
  @if (selectTriggerValueAsArray.length > 1) {
725
- <span class="addl-selection-count"> (+{{ selectTriggerValueAsArray.length - 1 }}) </span>
781
+ <span class="addl-selection-count">
782
+ (+{{ selectTriggerValueAsArray.length - 1 }})
783
+ </span>
726
784
  }
727
785
  </mat-select-trigger>
728
786
 
@@ -738,31 +796,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImpor
738
796
  </mat-option>
739
797
 
740
798
  <ng-container *ngIf="!group; else groupedOptions">
741
- <span *ngIf="(filteredValues | async) as entities">
742
- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
799
+ <span *ngIf="filteredValues | async as entities">
800
+ <ng-template #defaultOptionLabelTemplate let-entity>
743
801
  {{ entityLabelFn(entity) }}
802
+ </ng-template>
803
+ @for (entity of entities; track entityId(entity)) {
804
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
805
+ <ng-container
806
+ *ngTemplateOutlet="
807
+ optionLabelTemplate() || defaultOptionLabelTemplate;
808
+ context: { $implicit: entity }
809
+ "
810
+ ></ng-container>
744
811
  </mat-option>
812
+ }
813
+
814
+ <!-- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
815
+ {{ entityLabelFn(entity) }}
816
+ </mat-option> -->
745
817
  </span>
746
818
  </ng-container>
747
819
  <ng-template #groupedOptions>
748
- <span *ngIf="(filteredGroupedValues | async) as groups">
820
+ <span *ngIf="filteredGroupedValues | async as groups">
749
821
  @for (group of groups; track groupLabel(group)) {
750
- <mat-optgroup [label]="groupLabel(group)">
751
- @for (entity of group.__items__; track entityId(entity)) {
752
- <mat-option class="sel-entity-option" [value]="entityId(entity)">
753
- {{ entityLabelFn(entity) }}
754
- </mat-option>
755
- }
756
- </mat-optgroup>
822
+ <mat-optgroup [label]="groupLabel(group)">
823
+ @for (entity of group.__items__; track entityId(entity)) {
824
+
825
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
826
+ {{ entityLabelFn(entity) }}
827
+ </mat-option>
828
+ }
829
+ </mat-optgroup>
757
830
  }
758
831
  </span>
759
832
  </ng-template>
760
833
 
761
- <mat-option *ngIf="!multiple && inlineNew" class="add-item-option" value="0" (click)="$event.stopPropagation()"
834
+ <mat-option
835
+ *ngIf="!multiple && inlineNew"
836
+ class="add-item-option"
837
+ value="0"
838
+ (click)="$event.stopPropagation()"
762
839
  >⊕ {{ addItemText }}</mat-option
763
840
  >
764
841
  </mat-select>
765
- `, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, FormsModule, ReactiveFormsModule, MatSelectModule, NgxMatSelectSearchModule], providers: [{ provide: MatFormFieldControl, useExisting: SPMatSelectEntityComponent }], styles: [".add-item-option{padding-top:2px;border-top:1px solid gray}.addl-selection-count{opacity:.75;font-size:.8em}\n"] }]
842
+ `, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
843
+ CommonModule,
844
+ NgTemplateOutlet,
845
+ FormsModule,
846
+ ReactiveFormsModule,
847
+ MatSelectModule,
848
+ NgxMatSelectSearchModule,
849
+ ], providers: [
850
+ { provide: MatFormFieldControl, useExisting: SPMatSelectEntityComponent },
851
+ ], styles: [".add-item-option{padding-top:2px;border-top:1px solid gray}.addl-selection-count{opacity:.75;font-size:.8em}\n"] }]
766
852
  }], ctorParameters: () => [{ type: i1.HttpClient }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Injector }, { type: i7.MatFormField, decorators: [{
767
853
  type: Optional
768
854
  }, {