@smallpearl/ngx-helper 0.29.39 → 0.29.40

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.
Files changed (33) hide show
  1. package/assets/i18n/sp-mat-entity-crud/en.json +5 -3
  2. package/assets/i18n/sp-mat-entity-crud/zh-hant.json +3 -1
  3. package/assets/i18n/sp-mat-select-entity/en.json +5 -0
  4. package/assets/i18n/sp-mat-select-entity/zh-hant.json +5 -0
  5. package/core/index.d.ts +0 -1
  6. package/entity-field/src/entity-field-spec.d.ts +1 -3
  7. package/fesm2022/smallpearl-ngx-helper-core.mjs +1 -16
  8. package/fesm2022/smallpearl-ngx-helper-core.mjs.map +1 -1
  9. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs +2 -4
  10. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs.map +1 -1
  11. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs +6 -14
  12. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs.map +1 -1
  13. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs +198 -178
  14. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs.map +1 -1
  15. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +48 -55
  16. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -1
  17. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs +145 -166
  18. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs.map +1 -1
  19. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs +1 -4
  20. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs.map +1 -1
  21. package/mat-entity-crud/src/form-view-host.component.d.ts +2 -0
  22. package/mat-entity-crud/src/mat-entity-crud-form-base.d.ts +2 -0
  23. package/mat-entity-crud/src/mat-entity-crud-internal-types.d.ts +6 -0
  24. package/mat-entity-crud/src/mat-entity-crud-types.d.ts +6 -15
  25. package/mat-entity-crud/src/mat-entity-crud.component.d.ts +16 -5
  26. package/mat-entity-crud/src/preview-pane.component.d.ts +1 -4
  27. package/mat-entity-list/src/mat-entity-list.component.d.ts +2 -1
  28. package/mat-select-entity/index.d.ts +0 -1
  29. package/mat-select-entity/src/mat-select-entity.component.d.ts +6 -8
  30. package/package.json +13 -13
  31. package/stationary-with-line-items/src/stationary-with-line-items.component.d.ts +0 -2
  32. package/core/src/ngx-helper.d.ts +0 -7
  33. package/mat-select-entity/src/providers.d.ts +0 -9
@@ -1,36 +1,28 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, input, EventEmitter, computed, inject, ChangeDetectorRef, ElementRef, Component, ChangeDetectionStrategy, ViewChild, Input, Output, HostBinding } from '@angular/core';
3
1
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
4
2
  import * as i1 from '@angular/common';
5
3
  import { CommonModule, NgTemplateOutlet } from '@angular/common';
6
4
  import { HttpContextToken, HttpClient, HttpParams, HttpContext } from '@angular/common/http';
5
+ import * as i0 from '@angular/core';
6
+ import { input, EventEmitter, computed, inject, ChangeDetectorRef, ElementRef, Component, ChangeDetectionStrategy, ViewChild, Input, Output, HostBinding } from '@angular/core';
7
7
  import * as i2 from '@angular/forms';
8
8
  import { NgControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
9
9
  import { MAT_FORM_FIELD, MatFormFieldControl } from '@angular/material/form-field';
10
10
  import * as i3 from '@angular/material/select';
11
11
  import { MatSelect, MatSelectModule } from '@angular/material/select';
12
- import { getNgxHelperConfig } from '@smallpearl/ngx-helper/core';
13
12
  import { camelCase } from 'lodash';
14
- import * as i5 from 'ngx-mat-select-search';
13
+ import * as i6 from 'ngx-mat-select-search';
15
14
  import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
16
15
  import { plural } from 'pluralize';
17
16
  import { Subject, BehaviorSubject, combineLatest, debounceTime, takeUntil, switchMap, of, tap } from 'rxjs';
17
+ import * as i5 from '@jsverse/transloco';
18
+ import { TranslocoService, provideTranslocoScope, TranslocoModule } from '@jsverse/transloco';
18
19
  import * as i4 from '@angular/material/core';
19
20
 
20
- const SP_MAT_SELECT_ENTITY_CONFIG = new InjectionToken('SPMatSelectEntityConfig');
21
-
22
21
  const SP_MAT_SELECT_ENTITY_HTTP_CONTEXT = new HttpContextToken(() => ({
23
22
  entityName: '',
24
23
  entityNamePlural: '',
25
24
  endpoint: '',
26
25
  }));
27
- const DEFAULT_SP_MAT_SELECT_ENTITY_CONFIG = {
28
- i18n: {
29
- search: 'Search',
30
- notFound: 'Not found',
31
- addItem: 'New Item',
32
- },
33
- };
34
26
  /**
35
27
  * This is a generic component to display a <mat-select> for a FK field
36
28
  * where the select's options are dynamically loaded from the server using
@@ -143,9 +135,9 @@ class SPMatSelectEntityComponent {
143
135
  selectionChange = new EventEmitter();
144
136
  createNewItemSelected = new EventEmitter();
145
137
  // allow per component customization
146
- searchText;
147
- notFoundText;
148
- addItemText;
138
+ searchText = input();
139
+ notFoundText = input();
140
+ addItemText = input();
149
141
  /**
150
142
  * Template for the option label. If not provided, the default label
151
143
  * function will be used. Option label is what is placed inside the
@@ -199,20 +191,18 @@ class SPMatSelectEntityComponent {
199
191
  static nextId = 0;
200
192
  id = `sp-select-entity-${SPMatSelectEntityComponent.nextId++}`;
201
193
  _placeholder;
202
- ngxHelperConfig = getNgxHelperConfig();
203
194
  http = inject(HttpClient);
204
195
  cdr = inject(ChangeDetectorRef);
205
196
  _elementRef = inject((ElementRef));
206
197
  _formField = inject(MAT_FORM_FIELD, { optional: true });
207
- config = inject(SP_MAT_SELECT_ENTITY_CONFIG, { optional: true });
208
198
  ngControl = inject(NgControl, { optional: true });
199
+ transloco = inject(TranslocoService);
209
200
  constructor() {
210
201
  if (this.ngControl != null) {
211
202
  this.ngControl.valueAccessor = this;
212
203
  }
213
204
  }
214
205
  ngOnInit() {
215
- this._initStrings();
216
206
  combineLatest([this.filter$.pipe(debounceTime(400)), this.load$])
217
207
  .pipe(takeUntil(this.destroy), switchMap(([str, load]) => {
218
208
  if (load && !this.loaded) {
@@ -249,18 +239,6 @@ class SPMatSelectEntityComponent {
249
239
  // }
250
240
  // }
251
241
  }
252
- _initStrings() {
253
- const config = this.config ?? DEFAULT_SP_MAT_SELECT_ENTITY_CONFIG;
254
- if (!this.searchText) {
255
- this.searchText = config.i18n.search;
256
- }
257
- if (!this.notFoundText) {
258
- this.notFoundText = config.i18n.notFound;
259
- }
260
- if (!this.addItemText) {
261
- this.addItemText = config.i18n.addItem.replace(/\{\{\s*item\s*}}/, this.entityName ?? '**Item');
262
- }
263
- }
264
242
  addEntity(entity) {
265
243
  this._entities.set(entity[this.idKey], entity);
266
244
  // So that the newly added entity will be added to the <mat-option> list.
@@ -679,164 +657,171 @@ class SPMatSelectEntityComponent {
679
657
  return context;
680
658
  }
681
659
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPMatSelectEntityComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
682
- /** @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: [
660
+ /** @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: true, isRequired: false, transformFunction: null }, notFoundText: { classPropertyName: "notFoundText", publicName: "notFoundText", isSignal: true, isRequired: false, transformFunction: null }, addItemText: { classPropertyName: "addItemText", publicName: "addItemText", isSignal: true, 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: [
661
+ provideTranslocoScope('sp-mat-select-entity'),
683
662
  { provide: MatFormFieldControl, useExisting: SPMatSelectEntityComponent },
684
663
  ], viewQueries: [{ propertyName: "matSel", first: true, predicate: MatSelect, descendants: true }, { propertyName: "matSelect", first: true, predicate: MatSelect, descendants: true }], ngImport: i0, template: `
685
- <mat-select
686
- [placeholder]="placeholder"
687
- (opened)="onSelectOpened($event)"
688
- (selectionChange)="onSelectionChange($event)"
689
- [multiple]="multiple"
690
- [(ngModel)]="selectValue"
691
- >
692
- <mat-select-trigger>
693
- {{ selectTriggerValue }}
694
- @if (selectTriggerValueAsArray.length > 1) {
695
- <span class="addl-selection-count">
696
- (+{{ selectTriggerValueAsArray.length - 1 }})
697
- </span>
698
- }
699
- </mat-select-trigger>
664
+ <ng-container *transloco="let t; scope: 'sp-mat-select-entity'">
665
+ <mat-select
666
+ [placeholder]="placeholder"
667
+ (opened)="onSelectOpened($event)"
668
+ (selectionChange)="onSelectionChange($event)"
669
+ [multiple]="multiple"
670
+ [(ngModel)]="selectValue"
671
+ >
672
+ <mat-select-trigger>
673
+ {{ selectTriggerValue }}
674
+ @if (selectTriggerValueAsArray.length > 1) {
675
+ <span class="addl-selection-count">
676
+ (+{{ selectTriggerValueAsArray.length - 1 }})
677
+ </span>
678
+ }
679
+ </mat-select-trigger>
700
680
 
701
- <mat-option>
702
- <ngx-mat-select-search
703
- [(ngModel)]="filterStr"
704
- (ngModelChange)="this.filter$.next($event)"
705
- [placeholderLabel]="searchText"
706
- [noEntriesFoundLabel]="notFoundText"
707
- [searching]="searching"
708
- >
709
- </ngx-mat-select-search>
710
- </mat-option>
681
+ <mat-option>
682
+ <ngx-mat-select-search
683
+ [(ngModel)]="filterStr"
684
+ (ngModelChange)="this.filter$.next($event)"
685
+ [placeholderLabel]="searchText() ? searchText() : t('spMatSelectEntity.search')"
686
+ [noEntriesFoundLabel]="notFoundText() ? notFoundText() : t('spMatSelectEntity.notFound')"
687
+ [searching]="searching"
688
+ >
689
+ </ngx-mat-select-search>
690
+ </mat-option>
711
691
 
712
- <ng-container *ngIf="!group; else groupedOptions">
713
- <span *ngIf="filteredValues | async as entities">
714
- <ng-template #defaultOptionLabelTemplate let-entity>
715
- {{ entityLabelFn(entity) }}
716
- </ng-template>
717
- @for (entity of entities; track entityId(entity)) {
718
- <mat-option class="sel-entity-option" [value]="entityId(entity)">
719
- <ng-container
720
- *ngTemplateOutlet="
721
- optionLabelTemplate() || defaultOptionLabelTemplate;
722
- context: { $implicit: entity }
723
- "
724
- ></ng-container>
725
- </mat-option>
726
- }
692
+ <ng-container *ngIf="!group; else groupedOptions">
693
+ <span *ngIf="filteredValues | async as entities">
694
+ <ng-template #defaultOptionLabelTemplate let-entity>
695
+ {{ entityLabelFn(entity) }}
696
+ </ng-template>
697
+ @for (entity of entities; track entityId(entity)) {
698
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
699
+ <ng-container
700
+ *ngTemplateOutlet="
701
+ optionLabelTemplate() || defaultOptionLabelTemplate;
702
+ context: { $implicit: entity }
703
+ "
704
+ ></ng-container>
705
+ </mat-option>
706
+ }
727
707
 
728
- <!-- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
708
+ <!-- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
729
709
  {{ entityLabelFn(entity) }}
730
710
  </mat-option> -->
731
- </span>
732
- </ng-container>
733
- <ng-template #groupedOptions>
734
- <span *ngIf="filteredGroupedValues | async as groups">
735
- @for (group of groups; track groupLabel(group)) {
736
- <mat-optgroup [label]="groupLabel(group)">
737
- @for (entity of group.__items__; track entityId(entity)) {
711
+ </span>
712
+ </ng-container>
713
+ <ng-template #groupedOptions>
714
+ <span *ngIf="filteredGroupedValues | async as groups">
715
+ @for (group of groups; track groupLabel(group)) {
716
+ <mat-optgroup [label]="groupLabel(group)">
717
+ @for (entity of group.__items__; track entityId(entity)) {
738
718
 
739
- <mat-option class="sel-entity-option" [value]="entityId(entity)">
740
- {{ entityLabelFn(entity) }}
741
- </mat-option>
719
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
720
+ {{ entityLabelFn(entity) }}
721
+ </mat-option>
722
+ }
723
+ </mat-optgroup>
742
724
  }
743
- </mat-optgroup>
744
- }
745
- </span>
746
- </ng-template>
725
+ </span>
726
+ </ng-template>
747
727
 
748
- <mat-option
749
- *ngIf="!multiple && inlineNew"
750
- class="add-item-option"
751
- value="0"
752
- (click)="$event.stopPropagation()"
753
- >⊕ {{ addItemText }}</mat-option
754
- >
755
- </mat-select>
756
- `, 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: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.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: i3.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: i3.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i4.MatOptgroup, selector: "mat-optgroup", inputs: ["label", "disabled"], exportAs: ["matOptgroup"] }, { kind: "ngmodule", type: NgxMatSelectSearchModule }, { kind: "component", type: i5.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 });
728
+ <mat-option
729
+ *ngIf="!multiple && inlineNew"
730
+ class="add-item-option"
731
+ value="0"
732
+ (click)="$event.stopPropagation()"
733
+ >⊕ {{ this.addItemText() ? this.addItemText() : t('spMatSelectEntity.addItem', { item: this.entityName }) }}</mat-option
734
+ >
735
+ </mat-select>
736
+ </ng-container>
737
+ `, 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: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.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: i3.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: i3.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i4.MatOptgroup, selector: "mat-optgroup", inputs: ["label", "disabled"], exportAs: ["matOptgroup"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "directive", type: i5.TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { 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 });
757
738
  }
758
739
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPMatSelectEntityComponent, decorators: [{
759
740
  type: Component,
760
741
  args: [{ selector: 'sp-mat-select-entity', template: `
761
- <mat-select
762
- [placeholder]="placeholder"
763
- (opened)="onSelectOpened($event)"
764
- (selectionChange)="onSelectionChange($event)"
765
- [multiple]="multiple"
766
- [(ngModel)]="selectValue"
767
- >
768
- <mat-select-trigger>
769
- {{ selectTriggerValue }}
770
- @if (selectTriggerValueAsArray.length > 1) {
771
- <span class="addl-selection-count">
772
- (+{{ selectTriggerValueAsArray.length - 1 }})
773
- </span>
774
- }
775
- </mat-select-trigger>
742
+ <ng-container *transloco="let t; scope: 'sp-mat-select-entity'">
743
+ <mat-select
744
+ [placeholder]="placeholder"
745
+ (opened)="onSelectOpened($event)"
746
+ (selectionChange)="onSelectionChange($event)"
747
+ [multiple]="multiple"
748
+ [(ngModel)]="selectValue"
749
+ >
750
+ <mat-select-trigger>
751
+ {{ selectTriggerValue }}
752
+ @if (selectTriggerValueAsArray.length > 1) {
753
+ <span class="addl-selection-count">
754
+ (+{{ selectTriggerValueAsArray.length - 1 }})
755
+ </span>
756
+ }
757
+ </mat-select-trigger>
776
758
 
777
- <mat-option>
778
- <ngx-mat-select-search
779
- [(ngModel)]="filterStr"
780
- (ngModelChange)="this.filter$.next($event)"
781
- [placeholderLabel]="searchText"
782
- [noEntriesFoundLabel]="notFoundText"
783
- [searching]="searching"
784
- >
785
- </ngx-mat-select-search>
786
- </mat-option>
759
+ <mat-option>
760
+ <ngx-mat-select-search
761
+ [(ngModel)]="filterStr"
762
+ (ngModelChange)="this.filter$.next($event)"
763
+ [placeholderLabel]="searchText() ? searchText() : t('spMatSelectEntity.search')"
764
+ [noEntriesFoundLabel]="notFoundText() ? notFoundText() : t('spMatSelectEntity.notFound')"
765
+ [searching]="searching"
766
+ >
767
+ </ngx-mat-select-search>
768
+ </mat-option>
787
769
 
788
- <ng-container *ngIf="!group; else groupedOptions">
789
- <span *ngIf="filteredValues | async as entities">
790
- <ng-template #defaultOptionLabelTemplate let-entity>
791
- {{ entityLabelFn(entity) }}
792
- </ng-template>
793
- @for (entity of entities; track entityId(entity)) {
794
- <mat-option class="sel-entity-option" [value]="entityId(entity)">
795
- <ng-container
796
- *ngTemplateOutlet="
797
- optionLabelTemplate() || defaultOptionLabelTemplate;
798
- context: { $implicit: entity }
799
- "
800
- ></ng-container>
801
- </mat-option>
802
- }
770
+ <ng-container *ngIf="!group; else groupedOptions">
771
+ <span *ngIf="filteredValues | async as entities">
772
+ <ng-template #defaultOptionLabelTemplate let-entity>
773
+ {{ entityLabelFn(entity) }}
774
+ </ng-template>
775
+ @for (entity of entities; track entityId(entity)) {
776
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
777
+ <ng-container
778
+ *ngTemplateOutlet="
779
+ optionLabelTemplate() || defaultOptionLabelTemplate;
780
+ context: { $implicit: entity }
781
+ "
782
+ ></ng-container>
783
+ </mat-option>
784
+ }
803
785
 
804
- <!-- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
786
+ <!-- <mat-option class="sel-entity-option" *ngFor="let entity of entities" [value]="entityId(entity)">
805
787
  {{ entityLabelFn(entity) }}
806
788
  </mat-option> -->
807
- </span>
808
- </ng-container>
809
- <ng-template #groupedOptions>
810
- <span *ngIf="filteredGroupedValues | async as groups">
811
- @for (group of groups; track groupLabel(group)) {
812
- <mat-optgroup [label]="groupLabel(group)">
813
- @for (entity of group.__items__; track entityId(entity)) {
789
+ </span>
790
+ </ng-container>
791
+ <ng-template #groupedOptions>
792
+ <span *ngIf="filteredGroupedValues | async as groups">
793
+ @for (group of groups; track groupLabel(group)) {
794
+ <mat-optgroup [label]="groupLabel(group)">
795
+ @for (entity of group.__items__; track entityId(entity)) {
814
796
 
815
- <mat-option class="sel-entity-option" [value]="entityId(entity)">
816
- {{ entityLabelFn(entity) }}
817
- </mat-option>
797
+ <mat-option class="sel-entity-option" [value]="entityId(entity)">
798
+ {{ entityLabelFn(entity) }}
799
+ </mat-option>
800
+ }
801
+ </mat-optgroup>
818
802
  }
819
- </mat-optgroup>
820
- }
821
- </span>
822
- </ng-template>
803
+ </span>
804
+ </ng-template>
823
805
 
824
- <mat-option
825
- *ngIf="!multiple && inlineNew"
826
- class="add-item-option"
827
- value="0"
828
- (click)="$event.stopPropagation()"
829
- >⊕ {{ addItemText }}</mat-option
830
- >
831
- </mat-select>
806
+ <mat-option
807
+ *ngIf="!multiple && inlineNew"
808
+ class="add-item-option"
809
+ value="0"
810
+ (click)="$event.stopPropagation()"
811
+ >⊕ {{ this.addItemText() ? this.addItemText() : t('spMatSelectEntity.addItem', { item: this.entityName }) }}</mat-option
812
+ >
813
+ </mat-select>
814
+ </ng-container>
832
815
  `, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
833
816
  CommonModule,
834
817
  NgTemplateOutlet,
835
818
  FormsModule,
836
819
  ReactiveFormsModule,
837
820
  MatSelectModule,
821
+ TranslocoModule,
838
822
  NgxMatSelectSearchModule,
839
823
  ], providers: [
824
+ provideTranslocoScope('sp-mat-select-entity'),
840
825
  { provide: MatFormFieldControl, useExisting: SPMatSelectEntityComponent },
841
826
  ], styles: [".add-item-option{padding-top:2px;border-top:1px solid gray}.addl-selection-count{opacity:.75;font-size:.8em}\n"] }]
842
827
  }], ctorParameters: () => [], propDecorators: { matSel: [{
@@ -882,12 +867,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImpor
882
867
  type: Output
883
868
  }], createNewItemSelected: [{
884
869
  type: Output
885
- }], searchText: [{
886
- type: Input
887
- }], notFoundText: [{
888
- type: Input
889
- }], addItemText: [{
890
- type: Input
891
870
  }], matSelect: [{
892
871
  type: ViewChild,
893
872
  args: [MatSelect]
@@ -912,5 +891,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImpor
912
891
  * Generated bundle index. Do not edit.
913
892
  */
914
893
 
915
- export { SPMatSelectEntityComponent, SP_MAT_SELECT_ENTITY_CONFIG, SP_MAT_SELECT_ENTITY_HTTP_CONTEXT };
894
+ export { SPMatSelectEntityComponent, SP_MAT_SELECT_ENTITY_HTTP_CONTEXT };
916
895
  //# sourceMappingURL=smallpearl-ngx-helper-mat-select-entity.mjs.map